Skip to content

Commit

Permalink
Merge branch 'master' into aa/feat/sync-provider-init
Browse files Browse the repository at this point in the history
  • Loading branch information
arboleya committed Jan 2, 2025
2 parents 1340f16 + e8a8c71 commit 3bb5b78
Show file tree
Hide file tree
Showing 74 changed files with 858 additions and 859 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-bikes-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

chore: bumped `@fuels/*` deps to `0.36.1`
5 changes: 5 additions & 0 deletions .changeset/gentle-toes-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/account": patch
---

feat: added method to duplicate predicate
5 changes: 5 additions & 0 deletions .changeset/lazy-ears-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

feat: auto-detect package manager in `create fuels`
8 changes: 8 additions & 0 deletions .changeset/small-plums-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@fuel-ts/address": minor
"@fuel-ts/errors": patch
"@fuel-ts/recipes": patch
"@fuel-ts/logger": minor
---

chore!: remove Bech32 address
7 changes: 1 addition & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,7 @@ During the CI process an automated end-to-end (e2e) test is executed. This test
The e2e test can be found at:
`packages/fuel-gauge/src/e2e-script.test.ts`

The Bech32 address of this wallet is `fuel1x33ajpj0jy5p2wcqqu45e32r75zrwfeh6hwqfv5un670rv4p0mns58enjg`. This address can be funded via the [faucet](https://faucet-testnet.fuel.network/).

> [!NOTE] Note
> `Bech32` addresses like `fuel1..` are now deprecated. Use `B256` addresses instead. ([help](https://docs.fuel.network/docs/specs/abi/argument-encoding/#b256))
The B256 address of this wallet is `0x3463d9064f9128153b00072b4cc543f504372737d5dc04b29c9ebcf1b2a17ee7`. This address can be funded via the [faucet](https://faucet-testnet.fuel.network/).

If you want to run an e2e test locally, you can provide your own wallet address and private key. For obvious security reasons, the private key should not be shared.

Expand All @@ -270,8 +267,6 @@ This will enable you to run the e2e test locally against the live network:
pnpm test:filter e2e-script
```

<!-- TODO: add/fix block explorer URL after testnet support- Checking Wallet Balance: https://fuellabs.github.io/block-explorer-v2/beta-5/?#/address/fuel1x33ajpj0jy5p2wcqqu45e32r75zrwfeh6hwqfv5un670rv4p0mns58enjg -->

# Commit Convention

Before you create a Pull Request, please check whether your commits comply with
Expand Down
4 changes: 2 additions & 2 deletions apps/create-fuels-counter-guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"postbuild": "run-s fuels:build original:build"
},
"dependencies": {
"@fuels/connectors": "^0.27.1",
"@fuels/react": "^0.27.1",
"@fuels/connectors": "^0.36.1",
"@fuels/react": "^0.36.1",
"@tanstack/react-query": "^5.55.4",
"clsx": "2.1.1",
"@wagmi/connectors": "^5.1.14",
Expand Down
3 changes: 2 additions & 1 deletion apps/create-fuels-counter-guide/src/lib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const isTestnet = environment === environments.TESTNET;
export const localProviderUrl = `http://127.0.0.1:${process.env.VITE_FUEL_NODE_PORT || 4000}/v1/graphql`;
export const testnetProviderUrl = 'https://testnet.fuel.network/v1/graphql';
export const providerUrl = isLocal ? localProviderUrl : testnetProviderUrl;
export const chainId = 0; // Local and testnet are both on chain 0
export const playgroundUrl = providerUrl.replace('v1/graphql', 'v1/playground');

// #region deploying-dapp-to-testnet-frontend-contract-id
Expand All @@ -28,7 +29,7 @@ export const renderTransactionId = (transactionId: string) => {

return (
<a
href={`https://app.fuel.network/tx/${transactionId}/simple`}
href={`https://app-testnet.fuel.network/tx/${transactionId}/simple`}
target="_blank"
rel="noreferrer"
className="underline"
Expand Down
10 changes: 6 additions & 4 deletions apps/create-fuels-counter-guide/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { FuelProvider } from "@fuels/react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { ToastContainer } from "react-toastify";
import { Provider } from "fuels";
import { Network, Provider } from "fuels";

import App from "./App.tsx";
import { providerUrl } from "./lib.tsx";
import { chainId, providerUrl } from "./lib.tsx";

import "react-toastify/dist/ReactToastify.css";
import "./index.css";
Expand All @@ -16,13 +16,15 @@ const queryClient = new QueryClient();

const connectors = defaultConnectors({
devMode: true,
burnerWalletConfig: { fuelProvider: new Provider(providerUrl) },
fuelProvider: new Provider(providerUrl),
});

const networks: Network[] = [{ url: providerUrl, chainId }];

createRoot(document.getElementById("root")!).render(
<StrictMode>
<QueryClientProvider client={queryClient}>
<FuelProvider theme="dark" fuelConfig={{ connectors }}>
<FuelProvider theme="dark" fuelConfig={{ connectors }} networks={networks}>
<App />
<ToastContainer theme="dark" />
</FuelProvider>
Expand Down
4 changes: 2 additions & 2 deletions apps/demo-wallet-sdk-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"lint": "next lint"
},
"dependencies": {
"@fuels/connectors": "^0.27.1",
"@fuels/react": "^0.27.1",
"@fuels/connectors": "^0.36.1",
"@fuels/react": "^0.36.1",
"@tanstack/react-query": "^5.55.4",
"fuels": "workspace:*",
"next": "14.2.15",
Expand Down
4 changes: 0 additions & 4 deletions apps/docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,6 @@ export default defineConfig({
text: 'Asset Id',
link: '/guide/types/asset-id',
},
{
text: 'Bech32',
link: '/guide/types/bech32',
},
{
text: 'Bits256',
link: '/guide/types/bits256',
Expand Down
1 change: 0 additions & 1 deletion apps/docs/spell-check-custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ backends
backoff
backtrace
backtraces
Bech
BigNumber
Bitfield
bitmask
Expand Down
7 changes: 2 additions & 5 deletions apps/docs/src/guide/contracts/managing-deployed-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ To interact with a deployed contract using the SDK without redeploying it, you o

The `contractId` property from the [`Contract`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.Contract.html) class is of type [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html), an abstract class that is exclusively extended by the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class.

The [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class wraps all methods from the [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html) class and adds a single property: `bech32Address`. This property is a string encoded in [`Bech32`](../types/bech32.md) format, recognizable by the human-readable prefix `fuel` followed by the separator `1`.

> [!NOTE] Note
> `Bech32` addresses like `fuel1..` are now deprecated; please switch to B256 format, for more details see [here](https://docs.fuel.network/docs/specs/abi/argument-encoding/#b256).
The [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class wraps all methods from the [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html) class and adds a single property: `b256Address`. This property is a string encoded in [`B256`](../types/bits256.md) format.

When you log the `contractId` property of an instantiated Contract using `console.log`, the output appears as follows:

```console
Address {
bech32Address: 'fuel1e5tdjlzufcvwut5dvs5yglweepmrevpnvuvt2djj6pyl3mygkwaq8m7f20'
b256Address: '0xcd16d97c5c4e18ee2e8d6428447dd9c8763cb0336718b53652d049f8ec88b3ba'
}
```

Expand Down
6 changes: 3 additions & 3 deletions apps/docs/src/guide/creating-a-fuel-dapp/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ The first step is to run the command:
::: code-group

```sh-vue [npm]
npm create fuels@{{fuels}} -- --npm
npm create fuels@{{fuels}}
```

```sh-vue [pnpm]
pnpm create fuels@{{fuels}} --pnpm
pnpm create fuels@{{fuels}}
```

```sh-vue [bun]
bunx --bun create-fuels@{{fuels}} --bun
bun create fuels@{{fuels}}
```

:::
Expand Down
18 changes: 3 additions & 15 deletions apps/docs/src/guide/creating-a-fuel-dapp/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ The `npm create fuels` command has several command-line options that you can use
::: code-group

```sh-vue [pnpm]
pnpm create fuels@{{fuels}} --pnpm [project-name] [options]
pnpm create fuels@{{fuels}} [project-name] [options]
```

```sh-vue [npm]
npm create fuels@{{fuels}} -- --npm [project-name] [options]
npm create fuels@{{fuels}} -- [project-name] [options]
```

```sh-vue [bun]
bunx --bun create-fuels@{{fuels}} --bun [project-name] [options]
bun create fuels@{{fuels}} [project-name] [options]
```

:::
Expand All @@ -27,18 +27,6 @@ bunx --bun create-fuels@{{fuels}} --bun [project-name] [options]

Specifies the template to use for your project. The available templates are: `vite` and `nextjs`. The default template is `vite`.

## `--pnpm`

Notifies the tool to use pnpm as the package manager to install the necessary dependencies.

## `--npm`

Notifies the tool to use npm as the package manager to install the necessary dependencies.

## `--bun`

Notifies the tool to use bun as the package manager to install the necessary dependencies.

## `--verbose`

Enables verbose logging. Useful when debugging issues with the tool.
Expand Down
19 changes: 5 additions & 14 deletions apps/docs/src/guide/types/address.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,31 @@ The SDK defines the [AbstractAddress](https://fuels-ts-docs-api.vercel.app/class

## Address Class

Besides conforming to the interface of the [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html), the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class also defines one property; `bech32Address`, which is of the [`Bech32`](./bech32.md) type.
Besides conforming to the interface of the [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html), the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class also defines one property; `b256Address`, which is of the [`B256`](./bits256.md) type.

<<< @/../../../packages/address/src/address.ts#address-2{ts:line-numbers}

## Creating an Address

Thanks to the utility functions provided by the [`AbstractAddress`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_interfaces.AbstractAddress.html) class, there are several ways to create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) instance:

### From a `Bech32` Address
### From a b256 address

To create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) from a `Bech32` address, use the following code snippet:

<<< @./snippets/address/creating-an-address.ts#full{ts:line-numbers}
To create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) from a 256-bit address, use the following code snippet:

> [!NOTE] Note
> `Bech32` addresses like `fuel1..` are now deprecated. Use `B256` addresses instead. ([help](https://docs.fuel.network/docs/specs/abi/argument-encoding/#b256))
<<< @./snippets/address/from-a-b256.ts#full{ts:line-numbers}

### From a Public Key

To create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) from a public key, use the following code snippet:

<<< @./snippets/address/from-a-public-key.ts#full{ts:line-numbers}

### From a 256-bit Address

To create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) from a 256-bit address, use the following code snippet:

<<< @./snippets/address/from-a-b256.ts#full{ts:line-numbers}

## Utility Functions

The [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class also provides some practical utility functions:

1. `fromString`: Create a new [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) from an ambiguous source that may be a `Bech32` or `B256` address:
1. `fromString`: Create a new [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) from an ambiguous source that may be a `B256` address:

<<< @./snippets/address/utilities-function-1.ts#full{ts:line-numbers}

Expand Down
22 changes: 0 additions & 22 deletions apps/docs/src/guide/types/bech32.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// #region full
import { Address } from 'fuels';

const ADDRESS_BECH32 =
'fuel1elnmzsav56dqnp95sx4e2pckq36cvae9ser44m5zlvgtwxw49fmqd7e42e';
const ADDRESS_B256 =
'0xcfe7b143aca69a0984b481ab950716047586772586475aee82fb10b719d52a76';

const address = new Address(ADDRESS_BECH32);
const address = new Address(ADDRESS_B256);
// #endregion full

console.log('address', address);
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { Address } from 'fuels';

const address = Address.fromRandom();

const addressCloneFromBech = Address.fromString(address.toString());
const addressCloneFromB256 = Address.fromString(address.toB256());
// #endregion full

console.log('addressCloneFromBech', addressCloneFromBech);
console.log('addressCloneFromB256', addressCloneFromB256);
6 changes: 6 additions & 0 deletions apps/docs/src/guide/types/snippets/b256.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// #region addresses-1
const b256 =
'0x9ae5b658754e096e4d681c548daf46354495a437cc61492599e33fc64dcdc30c';
// #endregion addresses-1

console.log('b256', b256);
16 changes: 0 additions & 16 deletions apps/docs/src/guide/types/snippets/bech32.ts

This file was deleted.

27 changes: 2 additions & 25 deletions apps/docs/src/guide/utilities/address-conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

Addresses and varying address formats are commonplace when interacting with decentralized applications. Furthermore, different networks may enforce different address formats.

The Fuel Network uses the [`Bech32`](../types/bech32.md) address format for its interactions, an example of which can be seen below:
The Fuel Network uses the [`Bits256`](../types/bits256.md) address format for its interactions, an example of which can be seen below:

<<< @/../../docs/src/guide/types/snippets/bech32.ts#addresses-1{ts:line-numbers}

> [!NOTE] Note
> `Bech32` addresses like `fuel1..` are now deprecated. Use `B256` addresses instead. ([help](https://docs.fuel.network/docs/specs/abi/argument-encoding/#b256))
<<< @/../../docs/src/guide/types/snippets/b256.ts#addresses-1{ts:line-numbers}

However, a hexlified [Bits256](../types/bits256.md) (hex) is another common address format; an example can be seen below:

Expand All @@ -26,26 +23,6 @@ The following [conversion guide](./address-conversion.md#address-conversion) wil

This guide demonstrates how to convert between address formats and Sway Standard Types using helper functions. Native types are wrappers for bytes, and you can perform conversions between them by leveraging these functions and classes.

## From `Bech32` to `b256`

By instantiating an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html), we can validate a `Bech32` address and easily convert it to a `b256`:

<<< @./snippets/address-conversion/bech32-to-b256.ts#conversion-5{ts:line-numbers}

Or, if you'd prefer to use utility functions directly for validation and conversion, you can use `isBech32` and `toB256`:

<<< @./snippets/address-conversion/bech32-to-b256-utilities.ts#conversion-6{ts:line-numbers}

## From `b256` to `Bech32`

In a similar fashion, we have both class functions on the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) and utilities available for `b256` validation and conversion:

<<< @./snippets/address-conversion/b256-to-bech32.ts#conversion-7{ts:line-numbers}

And by using the `isB256` and `toBech32` utilities:

<<< @./snippets/address-conversion/b256-to-bech32-utilities.ts#conversion-8{ts:line-numbers}

## Converting a Contract ID

The Contract `id` property has the [`AbstractAddress`](../types/address.md#abstractaddress-class) type. Therefore, it can be converted using the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class functions such as `toAddress` and `toB256`:
Expand Down

This file was deleted.

Loading

0 comments on commit 3bb5b78

Please sign in to comment.