From 8e5ce4eb5ba7db70afc35d5df702d6a70fce79f5 Mon Sep 17 00:00:00 2001 From: Peter Smith Date: Mon, 20 Jan 2025 15:11:58 +0000 Subject: [PATCH] docs: favour `B256` and `B512` type references (#3599) * chore: `Bits256/512` -> `B256/512` * chore: changeset * chore: capitalize B * Update .changeset/wet-radios-collect.md --- .changeset/wet-radios-collect.md | 4 +++ apps/docs/.vitepress/config.ts | 8 +++--- .../plugins/utils/extractImports.test.ts | 4 +-- .../contracts/managing-deployed-contracts.md | 6 ++--- .../guide/contracts/minted-token-asset-id.md | 2 +- .../utilities/minted-token-asset-id.ts | 2 +- .../src/guide/encoding/working-with-bytes.md | 4 +-- .../send-and-spend-funds-from-predicates.md | 4 +-- apps/docs/src/guide/types/address.md | 4 +-- apps/docs/src/guide/types/asset-id.md | 2 +- apps/docs/src/guide/types/b256.md | 21 ++++++++++++++++ apps/docs/src/guide/types/b512.md | 25 +++++++++++++++++++ apps/docs/src/guide/types/bits256.md | 21 ---------------- apps/docs/src/guide/types/bits512.md | 25 ------------------- apps/docs/src/guide/types/bytes32.md | 2 +- apps/docs/src/guide/types/evm-address.md | 4 +-- .../guide/types/snippets/asset-id/intro.ts | 4 +-- .../converting-between-b256-uint8.ts | 0 .../generating-random-b256.ts | 0 .../support-from-address-class.ts | 0 .../{bits512 => b512}/b512-in-the-sdk.ts | 0 .../{bits512 => b512}/echoing-a-b512.ts | 0 .../guide/types/snippets/evm-address/intro.ts | 4 +-- apps/docs/src/guide/types/structs.md | 2 +- .../src/guide/utilities/address-conversion.md | 6 ++--- apps/docs/sway/bytecode-input/src/main.sw | 2 +- apps/docs/sway/echo-values/src/main.sw | 4 +-- 27 files changed, 82 insertions(+), 78 deletions(-) create mode 100644 .changeset/wet-radios-collect.md create mode 100644 apps/docs/src/guide/types/b256.md create mode 100644 apps/docs/src/guide/types/b512.md delete mode 100644 apps/docs/src/guide/types/bits256.md delete mode 100644 apps/docs/src/guide/types/bits512.md rename apps/docs/src/guide/types/snippets/{bits256 => b256}/converting-between-b256-uint8.ts (100%) rename apps/docs/src/guide/types/snippets/{bits256 => b256}/generating-random-b256.ts (100%) rename apps/docs/src/guide/types/snippets/{bits256 => b256}/support-from-address-class.ts (100%) rename apps/docs/src/guide/types/snippets/{bits512 => b512}/b512-in-the-sdk.ts (100%) rename apps/docs/src/guide/types/snippets/{bits512 => b512}/echoing-a-b512.ts (100%) diff --git a/.changeset/wet-radios-collect.md b/.changeset/wet-radios-collect.md new file mode 100644 index 00000000000..a493bc93821 --- /dev/null +++ b/.changeset/wet-radios-collect.md @@ -0,0 +1,4 @@ +--- +--- + +docs: favour `B256` and `B512` type references diff --git a/apps/docs/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index 3ec8a73afd3..288308581b4 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -496,12 +496,12 @@ export default defineConfig({ link: '/guide/types/asset-id', }, { - text: 'Bits256', - link: '/guide/types/bits256', + text: 'B256', + link: '/guide/types/b256', }, { - text: 'Bits512', - link: '/guide/types/bits512', + text: 'B512', + link: '/guide/types/b512', }, { text: 'Bytes', diff --git a/apps/docs/.vitepress/plugins/utils/extractImports.test.ts b/apps/docs/.vitepress/plugins/utils/extractImports.test.ts index f13e357a620..ebbbfca576f 100644 --- a/apps/docs/.vitepress/plugins/utils/extractImports.test.ts +++ b/apps/docs/.vitepress/plugins/utils/extractImports.test.ts @@ -108,7 +108,7 @@ describe('extractImports', () => { '// #import { AssetId };', '', 'const assetId: AssetId = {', - ' value: Bits256,', + ' value: B256,', '};', ]; const filepath = '/some/file/asset-id.test.ts'; @@ -197,7 +197,7 @@ describe('extractImports', () => { ' // #import { AssetId, Address };', '', ' const assetId: AssetId = {', - ' value: Bits256,', + ' value: B256,', ' };', ' const address: Address = new Address();', ]; diff --git a/apps/docs/src/guide/contracts/managing-deployed-contracts.md b/apps/docs/src/guide/contracts/managing-deployed-contracts.md index 4be51241b5c..f1977349357 100644 --- a/apps/docs/src/guide/contracts/managing-deployed-contracts.md +++ b/apps/docs/src/guide/contracts/managing-deployed-contracts.md @@ -6,7 +6,7 @@ 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 an instance of 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 also provides a set of utility functions for easy manipulation and conversion between address formats along with one property; `b256Address`, which is a string encoded in [`B256`](../types/bits256.md) format. +The [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class also provides a set of utility functions for easy manipulation and conversion between address formats along with one property; `b256Address`, which is a string encoded in [`B256`](../types/b256.md) format. When you log the `contractId` property of an instantiated Contract using `console.log`, the output appears as follows: @@ -22,10 +22,10 @@ If you have already an instantiated and deployed contract in hands you can creat <<< @./snippets/managing-deployed-contracts.ts#with-contractId{ts:line-numbers} -The previous example assumes that you have a [`Contract`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.Contract.html) instance at hand. However, some Fuel tools and Sway use the [`b256`](../types/bits256.md) type format, a hex-encoded string-like type, for contract IDs. +The previous example assumes that you have a [`Contract`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.Contract.html) instance at hand. However, some Fuel tools and Sway use the [`B256`](../types/b256.md) type format, a hex-encoded string-like type, for contract IDs. You might have this format instead, for example, if you have deployed your contract with `forc deploy`. -The process of instantiating a [`Contract`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.Contract.html) remains the same when using a contract ID of type `b256`: +The process of instantiating a [`Contract`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.Contract.html) remains the same when using a contract ID of type `B256`: <<< @./snippets/managing-deployed-contracts.ts#with-b256{ts:line-numbers} diff --git a/apps/docs/src/guide/contracts/minted-token-asset-id.md b/apps/docs/src/guide/contracts/minted-token-asset-id.md index d8bd72cc0ba..db92e0c33be 100644 --- a/apps/docs/src/guide/contracts/minted-token-asset-id.md +++ b/apps/docs/src/guide/contracts/minted-token-asset-id.md @@ -5,7 +5,7 @@ The asset ID of a token on the Fuel network is determined by two factors: - The ID of the contract that minted the token, - A sub-identifier (Sub ID) -> Both of which are [bits256](../types/bits256.md) strings. +> Both of which are [B256](../types/b256.md) strings. The process involves applying a SHA-256 hash algorithm to the combination of the Contract ID and the Sub ID, to derive an Asset ID - as explained [here](https://docs.fuel.network/docs/specs/identifiers/asset/#asset-id). diff --git a/apps/docs/src/guide/contracts/snippets/utilities/minted-token-asset-id.ts b/apps/docs/src/guide/contracts/snippets/utilities/minted-token-asset-id.ts index 70ca8e96c79..237277e3224 100644 --- a/apps/docs/src/guide/contracts/snippets/utilities/minted-token-asset-id.ts +++ b/apps/docs/src/guide/contracts/snippets/utilities/minted-token-asset-id.ts @@ -10,7 +10,7 @@ const deployer = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); const deployContract = await TokenFactory.deploy(deployer); const { contract } = await deployContract.waitForResult(); -// Any valid bits256 string can be used as a sub ID +// Any valid B256 string can be used as a sub ID const subID = '0xc7fd1d987ada439fc085cfa3c49416cf2b504ac50151e3c2335d60595cb90745'; const mintAmount = bn(1000); diff --git a/apps/docs/src/guide/encoding/working-with-bytes.md b/apps/docs/src/guide/encoding/working-with-bytes.md index a11ec7a6f51..9d1f8149cbb 100644 --- a/apps/docs/src/guide/encoding/working-with-bytes.md +++ b/apps/docs/src/guide/encoding/working-with-bytes.md @@ -24,9 +24,9 @@ A fixed-length string's size is known at compile time due to the argument declar <<< @./snippets/working-with-bytes.ts#working-with-bytes-3{ts:line-numbers} -### `b256` / `b512` +### `B256` / `B512` -These are fixed-length byte arrays, with `b256` containing 256 bits and `b512` containing 512 bits. You can use them for address and signature formats. +These are fixed-length byte arrays, with `B256` containing 256 bits and `B512` containing 512 bits. You can use them for address and signature formats. <<< @./snippets/working-with-bytes.ts#working-with-bytes-4{ts:line-numbers} diff --git a/apps/docs/src/guide/predicates/send-and-spend-funds-from-predicates.md b/apps/docs/src/guide/predicates/send-and-spend-funds-from-predicates.md index 3d1352a7ba2..f30c5a5efef 100644 --- a/apps/docs/src/guide/predicates/send-and-spend-funds-from-predicates.md +++ b/apps/docs/src/guide/predicates/send-and-spend-funds-from-predicates.md @@ -10,7 +10,7 @@ Consider the following predicate: <<< @/../../docs/sway/simple-predicate/src/main.sw#send-and-spend-funds-from-predicates-1{rust:line-numbers} -This predicate accepts an address of type `b256` and compares it with a hard-coded address of the same type. If both addresses are equal, the predicate returns true, otherwise it will return false. +This predicate accepts an address of type `B256` and compares it with a hard-coded address of the same type. If both addresses are equal, the predicate returns true, otherwise it will return false. ## Interacting with the Predicate Using SDK @@ -18,7 +18,7 @@ Let's use the above predicate to validate our transaction. Once you've compiled the predicate (`forc build`), you'll obtain two important artifacts: the JSON ABI and the predicate's binary code. These are needed to instantiate a new predicate. -This is where we also pass in the predicate's data. Note that the `main` function in our predicate example requires a parameter called `input_address` of type `b256`. We will pass this parameter to the `Predicate` constructor along with the bytecode and the JSON ABI. +This is where we also pass in the predicate's data. Note that the `main` function in our predicate example requires a parameter called `input_address` of type `B256`. We will pass this parameter to the `Predicate` constructor along with the bytecode and the JSON ABI. <<< @./snippets/cookbook/transferring-assets.ts#send-and-spend-funds-from-predicates-2{ts:line-numbers} diff --git a/apps/docs/src/guide/types/address.md b/apps/docs/src/guide/types/address.md index d295ec41cd3..62b09430696 100644 --- a/apps/docs/src/guide/types/address.md +++ b/apps/docs/src/guide/types/address.md @@ -1,10 +1,10 @@ # Address -In Sway, the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) type serves as a type-safe wrapper around the primitive `b256` type. The SDK takes a different approach and has its own abstraction for the [Address](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) type. +In Sway, the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) type serves as a type-safe wrapper around the primitive `B256` type. The SDK takes a different approach and has its own abstraction for the [Address](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) type. ## Address Class -The [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class also provides a set of utility functions for easy manipulation and conversion between address formats along with one property; `b256Address`, which is of the [`B256`](./bits256.md) type. +The [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class also provides a set of utility functions for easy manipulation and conversion between address formats along with one property; `b256Address`, which is of the [`B256`](./b256.md) type. <<< @/../../../packages/address/src/address.ts#address-2{ts:line-numbers} diff --git a/apps/docs/src/guide/types/asset-id.md b/apps/docs/src/guide/types/asset-id.md index 8bf7f00249e..6aad7a9bbfb 100644 --- a/apps/docs/src/guide/types/asset-id.md +++ b/apps/docs/src/guide/types/asset-id.md @@ -1,6 +1,6 @@ # Asset ID -An Asset ID can be represented using the `AssetId` type. It's definition matches the Sway standard library type being a `Struct` wrapper around an inner `Bits256` value. +An Asset ID can be represented using the `AssetId` type. It's definition matches the Sway standard library type being a `Struct` wrapper around an inner `B256` value. <<< @./snippets/asset-id/intro.ts#full{ts:line-numbers} diff --git a/apps/docs/src/guide/types/b256.md b/apps/docs/src/guide/types/b256.md new file mode 100644 index 00000000000..a0519b1ddfd --- /dev/null +++ b/apps/docs/src/guide/types/b256.md @@ -0,0 +1,21 @@ +# `B256` + +The type `B256` in Fuel represents hashes and holds a 256-bit (32-bytes) value. The TypeScript SDK represents `B256` as a hexlified string value for portability and provides utilities to convert to `Uint8Array` when the [raw bytes](./bytes32.md) are required. + +## Generating random `B256` values + +To generate a random `B256` value, you can use the `getRandomB256()` function: + +<<< @./snippets/b256/generating-random-b256.ts#full{ts:line-numbers} + +### Converting between `B256` and `Uint8Array` + +To convert between a `B256` hexlified string and a `Uint8Array`, you can use the `arrayify` and `hexlify` functions: + +<<< @./snippets/b256/converting-between-b256-uint8.ts#full{ts:line-numbers} + +## Support from `Address` Class + +A `B256` value is also supported as part of the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class, providing seamless integration with other components of your application. To create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) instance from a b256 value, use the `Address.fromB256()` method: + +<<< @./snippets/b256/support-from-address-class.ts#full{ts:line-numbers} diff --git a/apps/docs/src/guide/types/b512.md b/apps/docs/src/guide/types/b512.md new file mode 100644 index 00000000000..f9508f6ad3b --- /dev/null +++ b/apps/docs/src/guide/types/b512.md @@ -0,0 +1,25 @@ +# B512 + +In Sway, the `B512` type is commonly used to handle public keys and signatures. This guide will explain how the `B512` type is defined in Sway, how to visualize a `B512` value using the SDK, and how to interact with a contract function that accepts a `B512` parameter. + +The `B512` type in Sway is a wrapper around two `B256` types, allowing for the representation of 64-byte values. It is defined as a struct: + +<<< @/../../docs/sway/bytecode-input/src/main.sw#b512-1{rs:line-numbers} + +## `B512` in the SDK + +In the SDK, you can visualize a `B512` value by examining a wallet's public key: + +<<< @./snippets/b512/b512-in-the-sdk.ts#snippet-1{ts:line-numbers} + +## Example: Echoing a `B512` Value in a Contract Function + +Let's consider a contract function that accepts a `B512` parameter and returns the same value: + +<<< @/../../docs/sway/echo-values/src/main.sw#b512-3{rust:line-numbers} + +To call this function and validate the returned value, follow these steps: + +<<< @./snippets/b512/echoing-a-b512.ts#snippet-1{ts:line-numbers} + +In this example, we generate a wallet, use its public key as the `B512` input, call the `echo_b512` contract function, and expect the returned value to match the original input. diff --git a/apps/docs/src/guide/types/bits256.md b/apps/docs/src/guide/types/bits256.md deleted file mode 100644 index 5cc9d26c021..00000000000 --- a/apps/docs/src/guide/types/bits256.md +++ /dev/null @@ -1,21 +0,0 @@ -# `Bits256` - -The type `b256` in Fuel represents hashes and holds a 256-bit (32-bytes) value. The TypeScript SDK represents `b256` as a hexlified string value for portability and provides utilities to convert to `Uint8Array` when the [raw bytes](./bytes32.md) are required. - -## Generating random `b256` values - -To generate a random `b256` value, you can use the `getRandomB256()` function: - -<<< @./snippets/bits256/generating-random-b256.ts#full{ts:line-numbers} - -### Converting between `b256` and `Uint8Array` - -To convert between a `b256` hexlified string and a `Uint8Array`, you can use the `arrayify` and `hexlify` functions: - -<<< @./snippets/bits256/converting-between-b256-uint8.ts#full{ts:line-numbers} - -## Support from `Address` Class - -A `b256` value is also supported as part of the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class, providing seamless integration with other components of your application. To create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) instance from a b256 value, use the `Address.fromB256()` method: - -<<< @./snippets/bits256/support-from-address-class.ts#full{ts:line-numbers} diff --git a/apps/docs/src/guide/types/bits512.md b/apps/docs/src/guide/types/bits512.md deleted file mode 100644 index f4fa8da6d1f..00000000000 --- a/apps/docs/src/guide/types/bits512.md +++ /dev/null @@ -1,25 +0,0 @@ -# Bits512 - -In Sway, the `b512` type is commonly used to handle public keys and signatures. This guide will explain how the `b512` type is defined in Sway, how to visualize a `b512` value using the SDK, and how to interact with a contract function that accepts a `b512` parameter. - -The `b512` type in Sway is a wrapper around two `b256` types, allowing for the representation of 64-byte values. It is defined as a struct: - -<<< @/../../docs/sway/bytecode-input/src/main.sw#b512-1{rs:line-numbers} - -## `b512` in the SDK - -In the SDK, you can visualize a `b512` value by examining a wallet's public key: - -<<< @./snippets/bits512/b512-in-the-sdk.ts#snippet-1{ts:line-numbers} - -## Example: Echoing a `b512` Value in a Contract Function - -Let's consider a contract function that accepts a `b512` parameter and returns the same value: - -<<< @/../../docs/sway/echo-values/src/main.sw#bits512-3{rust:line-numbers} - -To call this function and validate the returned value, follow these steps: - -<<< @./snippets/bits512/echoing-a-b512.ts#snippet-1{ts:line-numbers} - -In this example, we generate a wallet, use its public key as the `b512` input, call the `echo_b512` contract function, and expect the returned value to match the original input. diff --git a/apps/docs/src/guide/types/bytes32.md b/apps/docs/src/guide/types/bytes32.md index 580006b8ca0..ec6811d5076 100644 --- a/apps/docs/src/guide/types/bytes32.md +++ b/apps/docs/src/guide/types/bytes32.md @@ -16,4 +16,4 @@ You can use the `hexlify` function to convert a byte array to a hex string, and ## Working with b256 in Fuel -In Fuel, there is a special type called b256, which is similar to `bytes32`. Like `bytes32`, `b256` is also used to represent hashes and holds a 256-bit value. You can learn more about working with `b256` values in the [Bits256 documentation](./bits256.md). +In Fuel, there is a special type called b256, which is similar to `bytes32`. Like `bytes32`, `B256` is also used to represent hashes and holds a 256-bit value. You can learn more about working with `B256` values in the [B256 documentation](./b256.md). diff --git a/apps/docs/src/guide/types/evm-address.md b/apps/docs/src/guide/types/evm-address.md index d2bd9fd466a..9a50704093a 100644 --- a/apps/docs/src/guide/types/evm-address.md +++ b/apps/docs/src/guide/types/evm-address.md @@ -1,12 +1,12 @@ # `EvmAddress` -An Ethereum Virtual Machine (EVM) Address can be represented using the `EvmAddress` type. It's definition matches the Sway standard library type being a `Struct` wrapper around an inner `Bits256` value. +An Ethereum Virtual Machine (EVM) Address can be represented using the `EvmAddress` type. It's definition matches the Sway standard library type being a `Struct` wrapper around an inner `B256` value. <<< @./snippets/evm-address/intro.ts#snippet-1{ts:line-numbers} ## Creating an EVM Address -An EVM Address only has 20 bytes therefore the first 12 bytes of the `Bits256` value are set to 0. Within the SDK, an `Address` can be instantiated and converted to a wrapped and Sway compatible EVM Address using the `toEvmAddress()` function: +An EVM Address only has 20 bytes therefore the first 12 bytes of the `B256` value are set to 0. Within the SDK, an `Address` can be instantiated and converted to a wrapped and Sway compatible EVM Address using the `toEvmAddress()` function: <<< @./snippets/evm-address/creating-an-evm.ts#snippet-1{ts:line-numbers} diff --git a/apps/docs/src/guide/types/snippets/asset-id/intro.ts b/apps/docs/src/guide/types/snippets/asset-id/intro.ts index 38822f65c97..7747c1f4a6a 100644 --- a/apps/docs/src/guide/types/snippets/asset-id/intro.ts +++ b/apps/docs/src/guide/types/snippets/asset-id/intro.ts @@ -2,10 +2,10 @@ import type { AssetId } from 'fuels'; import { getRandomB256 } from 'fuels'; -const bits256 = getRandomB256(); +const b256 = getRandomB256(); const assetId: AssetId = { - bits: bits256, + bits: b256, }; // #endregion full console.log(assetId, 'assetId'); diff --git a/apps/docs/src/guide/types/snippets/bits256/converting-between-b256-uint8.ts b/apps/docs/src/guide/types/snippets/b256/converting-between-b256-uint8.ts similarity index 100% rename from apps/docs/src/guide/types/snippets/bits256/converting-between-b256-uint8.ts rename to apps/docs/src/guide/types/snippets/b256/converting-between-b256-uint8.ts diff --git a/apps/docs/src/guide/types/snippets/bits256/generating-random-b256.ts b/apps/docs/src/guide/types/snippets/b256/generating-random-b256.ts similarity index 100% rename from apps/docs/src/guide/types/snippets/bits256/generating-random-b256.ts rename to apps/docs/src/guide/types/snippets/b256/generating-random-b256.ts diff --git a/apps/docs/src/guide/types/snippets/bits256/support-from-address-class.ts b/apps/docs/src/guide/types/snippets/b256/support-from-address-class.ts similarity index 100% rename from apps/docs/src/guide/types/snippets/bits256/support-from-address-class.ts rename to apps/docs/src/guide/types/snippets/b256/support-from-address-class.ts diff --git a/apps/docs/src/guide/types/snippets/bits512/b512-in-the-sdk.ts b/apps/docs/src/guide/types/snippets/b512/b512-in-the-sdk.ts similarity index 100% rename from apps/docs/src/guide/types/snippets/bits512/b512-in-the-sdk.ts rename to apps/docs/src/guide/types/snippets/b512/b512-in-the-sdk.ts diff --git a/apps/docs/src/guide/types/snippets/bits512/echoing-a-b512.ts b/apps/docs/src/guide/types/snippets/b512/echoing-a-b512.ts similarity index 100% rename from apps/docs/src/guide/types/snippets/bits512/echoing-a-b512.ts rename to apps/docs/src/guide/types/snippets/b512/echoing-a-b512.ts diff --git a/apps/docs/src/guide/types/snippets/evm-address/intro.ts b/apps/docs/src/guide/types/snippets/evm-address/intro.ts index 1f5c1bbe47c..7fd08ee00f9 100644 --- a/apps/docs/src/guide/types/snippets/evm-address/intro.ts +++ b/apps/docs/src/guide/types/snippets/evm-address/intro.ts @@ -1,11 +1,11 @@ // #region snippet-1 import type { B256AddressEvm, EvmAddress } from 'fuels'; -const bits256: B256AddressEvm = +const b256: B256AddressEvm = '0x000000000000000000000000210cf886ce41952316441ae4cac35f00f0e882a6'; const evmAddress: EvmAddress = { - bits: bits256, + bits: b256, }; // #endregion snippet-1 diff --git a/apps/docs/src/guide/types/structs.md b/apps/docs/src/guide/types/structs.md index 81a2aad3934..92a497351fd 100644 --- a/apps/docs/src/guide/types/structs.md +++ b/apps/docs/src/guide/types/structs.md @@ -18,4 +18,4 @@ Please note that TypeScript does not have native support for `u8` and `u64` type Additionally, TypeScript does not support specifying string length, so just use `string` for the `name`. -In a similar way, since the type `b256` on the SDK is just an hexlified string, we use `string` as well. +In a similar way, since the type `B256` on the SDK is just an hexlified string, we use `string` as well. diff --git a/apps/docs/src/guide/utilities/address-conversion.md b/apps/docs/src/guide/utilities/address-conversion.md index dbb8d82bfd6..c9af27c0f35 100644 --- a/apps/docs/src/guide/utilities/address-conversion.md +++ b/apps/docs/src/guide/utilities/address-conversion.md @@ -2,11 +2,11 @@ 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 [`Bits256`](../types/bits256.md) address format for its interactions, an example of which can be seen below: +The Fuel Network uses the [`B256`](../types/b256.md) address format for its interactions, an example of which can be seen below: <<< @/../../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: +However, a hexlified [B256](../types/b256.md) (hex) is another common address format; an example can be seen below: <<< @/../../docs/src/guide/types/snippets/evm-address/creating-an-evm.ts#snippet-2{ts:line-numbers} apps/ @@ -37,6 +37,6 @@ Similarly, the Wallet `address` property is also of type [`Address`](https://fue ## Converting an Asset ID -[Asset IDs](../types/asset-id.md) are a wrapped [b256](../types/bits256.md) value. The following example shows how to create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) from a `b256` type: +[Asset IDs](../types/asset-id.md) are a wrapped [`B256`](../types/b256.md) value. The following example shows how to create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) from a `B256` type: <<< @./snippets/address-conversion/asset-id.ts#conversion-4{ts:line-numbers} diff --git a/apps/docs/sway/bytecode-input/src/main.sw b/apps/docs/sway/bytecode-input/src/main.sw index 72efbb2df17..1cf1a1c9459 100644 --- a/apps/docs/sway/bytecode-input/src/main.sw +++ b/apps/docs/sway/bytecode-input/src/main.sw @@ -6,7 +6,7 @@ abi MyContract { // #region b512-1 pub struct B512 { - /// The two `b256`s that make up the `B512`. + /// The two `B256`s that make up the `B512`. bits: [b256; 2], } // #endregion b512-1 diff --git a/apps/docs/sway/echo-values/src/main.sw b/apps/docs/sway/echo-values/src/main.sw index f48734129c6..653e4b76335 100644 --- a/apps/docs/sway/echo-values/src/main.sw +++ b/apps/docs/sway/echo-values/src/main.sw @@ -38,11 +38,11 @@ impl EchoValues for Contract { } // #endregion tuples-2 - // #region bits512-3 + // #region b512-3 fn echo_b512(input: B512) -> B512 { input } - // #endregion bits512-3 + // #endregion b512-3 fn echo_u64(value: u64) -> u64 { value }