From 7d8fe92ea7d92d1caa5adf2f199e109dccbc16a6 Mon Sep 17 00:00:00 2001 From: Sarah Schwartz <58856580+sarahschwartz@users.noreply.github.com> Date: Fri, 8 Dec 2023 09:05:43 -0700 Subject: [PATCH] docs: configure spell-check (#1224) This PR configures the spell-check added to the docs workflow in the github-actions repo: https://github.com/FuelLabs/github-actions/pull/23 The files checked are configured in `.spellcheck.yml`. This is also where you can configure what types of elements are ignored. Right now it ignores: - All code blocks that have a language (and will check code blocks that do not have a language) - Anything in between backticks - Words in `spell-check-custom-words.txt` (case sensitive, only exact match) - Numbers, even if they are attached to a word - Links in markdown link format #### Handling errors: If the test fails: - look up the word in the question to verify it is a real word and is correctly spelled - If it is a file name or is code, use backticks to ignore the word. - If it is a real word that is spelled correctly, or an acronym that is either common or is defined already, add it to `spell-check-custom-words.txt`. - If needed, rewrite the sentence. Ex: DON'T use "`lock`ing" and add "ing" to the custom words list. Instead, rewrite the sentence as "locking with the `lock` method". - If it otherwise should be ignored, you can configure the pipeline in `.spellcheck.yml`. --- .github/workflows/docs.yml | 1 + docs/.spellcheck.yml | 30 +++ docs/spell-check-custom-words.txt | 227 ++++++++++++++++++ docs/src/SUMMARY.md | 22 +- docs/src/abigen/the-abigen-macro.md | 6 +- docs/src/calling-contracts/call-response.md | 4 +- .../custom-asset-transfer.md | 2 +- docs/src/calling-contracts/read-only.md | 2 +- .../tx-dependency-estimation.md | 2 +- docs/src/cli/fuels-abi-cli.md | 2 +- docs/src/codec/index.md | 4 +- docs/src/connecting/external-node.md | 2 +- docs/src/connecting/querying.md | 6 +- docs/src/connecting/retrying.md | 4 +- docs/src/connecting/rocksdb.md | 4 +- docs/src/connecting/short-lived.md | 2 +- docs/src/contributing/CONTRIBUTING.md | 2 +- docs/src/cookbook/custom-chain.md | 2 +- docs/src/cookbook/transfer-all-assets.md | 2 +- .../transaction-builders.md | 4 +- docs/src/debugging/function-selector.md | 6 +- .../deploying/interacting-with-contracts.md | 4 +- docs/src/predicates/index.md | 2 +- .../testing/the-setup-program-test-macro.md | 2 +- docs/src/types/B512.md | 2 +- docs/src/types/address.md | 2 +- docs/src/types/asset-id.md | 2 +- docs/src/types/bech32.md | 6 +- docs/src/types/bits256.md | 2 +- docs/src/types/bytes.md | 2 +- docs/src/types/bytes32.md | 4 +- docs/src/types/contract-id.md | 2 +- docs/src/types/evm_address.md | 6 +- docs/src/types/string.md | 2 +- docs/src/wallets/access.md | 2 +- docs/src/wallets/signing.md | 2 +- docs/src/wallets/test-wallets.md | 6 +- 37 files changed, 321 insertions(+), 63 deletions(-) create mode 100644 docs/.spellcheck.yml create mode 100644 docs/spell-check-custom-words.txt diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f086e8586e..75acd5f179 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,3 +14,4 @@ jobs: with: docs-src-path: "docs/src" pre-command: 'cargo run --package versions-replacer -- ./docs --manifest-path ./Cargo.toml --filename-regex "\.md$"' + spellcheck-config-path: 'docs/.spellcheck.yml' diff --git a/docs/.spellcheck.yml b/docs/.spellcheck.yml new file mode 100644 index 0000000000..cff5e24471 --- /dev/null +++ b/docs/.spellcheck.yml @@ -0,0 +1,30 @@ +matrix: + - name: SPCheck + aspell: + lang: en + dictionary: + encoding: utf-8 + wordlists: + - docs/spell-check-custom-words.txt + pipeline: + - pyspelling.filters.context: + context_visible_first: true + escapes: \\[\\`~] + delimiters: + # Ignore all code blocks + - open: '(?s)^(?P *`{3,}\s*(\w+\s*,?\s*)+.*?)$' + close: '^( *`{3,})$' + - pyspelling.filters.markdown: + markdown_extensions: + - pymdownx.superfences: + - pyspelling.filters.html: + comments: false + ignores: + - code + - pre + sources: + - 'docs/*.md' + - 'docs/src/*.md' + - 'docs/src/**/*.md' + default_encoding: utf-8 + \ No newline at end of file diff --git a/docs/spell-check-custom-words.txt b/docs/spell-check-custom-words.txt new file mode 100644 index 0000000000..9b22e581a8 --- /dev/null +++ b/docs/spell-check-custom-words.txt @@ -0,0 +1,227 @@ +ABI +ABIs +ASM +IDE +IDEs +LSP +namespace +ALU +APIs +JSON +BrowserStack +CLI +Deserialization +deserializing +DApp +subcurrency +Subcurrency +intrinsics +Intrinsics +workspace +workspaces +Workspaces +neovim +EVM +EVM's +EOA +ERC +Ethereum +Ethereum's +FVM +FuelVM +Fuelup +Github +GraphQL +Infura +JSON +LSP +Merkle +PoA +PoS +PoW +RPC +SDK +SDK's +SDKs +SauceLabs +Sepolia +Structs +Sway +TAI +TODO +TypeScript +UTF +UTXO +UTXOs +Utils +VM +VSCode +abigen +args +async +backend +backtraces +blockchain +blockchain's +bytecode +codespace +codespaces +config +cryptographic +customizable +customizations +dapp +dev +dropdown +enum +enums +env +forc +frontend +fuelup +fullstack +graphQL +graphql +http +https +js +localhost +mainnet +mempool +merkle +monorepo +monorepos +natively +npm +nvm +onboarding +params +pnpm +prerelease +queryable +quickstart +relayer +relayers +repo +repos +runnable +stateful +struct +structs +struct's +testnet +testnets +toolchain +toolchains +urql +validator +validators +superABI +superABIs +SuperABIs +supertraits +compositional +typeclass +turbofish +DSL +TOML +IPFS +Bitwise +Bitwise +runtime +runtimes +formatter +deployable +Utils +ETH +initializer +initializers +destructuring +instantiation +VMs +superset +CEI +pre +entrancy +interoperable +blockchains +keccak +SHA +UI +backtrace +Collateralized +collateralized +submodule +DEX +TypeChain +inlines +inlining +MiB +FuelVM's +deterministically +CLI +VS +GraphViz +DOT +DCA +AST +GitHub +decrypt +subcommand +subcommands +Subcommands +supertrait +supertraits +Supertraits +incrementor +monomorphization +Booleans +boolean +Orchestrator +orchestrator +growable +arity +tuple's +unary +SRC +DEX +FuelLabs +PRs +codebase +PostgreSQL +Postgres +MacOS +macOS +backends +hoc +semver +SQLx +Homebrew +Changelog +lookups +namespaces +YAML +WASM +WebAssembly +dApp +dApps +JWT +Schemas +schemas +AssemblyScript +indexable +Macbook +Dockerized +TLDR +IaaS +Updatable +dereferenced +dereference +dereferencing +codec +Codec +calldata +configurables +Cardinality +RocksDB +cryptographically \ No newline at end of file diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 4d9b86cd3f..38fd55b8a1 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -6,7 +6,7 @@ - [Connecting to a Fuel node](./connecting/index.md) - [Connecting to the Testnet or an external node](./connecting/external-node.md) - [Running a short-lived Fuel node with the SDK](./connecting/short-lived.md) - - [Rocksdb](./connecting/rocksdb.md) + - [RocksDB](./connecting/rocksdb.md) - [Querying the blockchain](./connecting/querying.md) - [Retrying upon errors](./connecting/retrying.md) - [Accounts](./accounts.md) @@ -47,18 +47,18 @@ - [Transaction builders](./custom-transactions/transaction-builders.md) - [Custom contract and script calls](./custom-transactions/custom-calls.md) - [Types](./types/index.md) - - [Bytes32](./types/bytes32.md) - - [Address](./types/address.md) - - [ContractId](./types/contract-id.md) - - [AssetId](./types/asset-id.md) + - [`Bytes32`](./types/bytes32.md) + - [`Address`](./types/address.md) + - [`ContractId`](./types/contract-id.md) + - [`AssetId`](./types/asset-id.md) - [Converting native types](./types/conversion.md) - - [Bech32](./types/bech32.md) + - [`Bech32`](./types/bech32.md) - [Structs and enums](./types/custom_types.md) - - [String](./types/string.md) - - [Bits256](./types/bits256.md) - - [Bytes](./types/bytes.md) - - [B512](./types/B512.md) - - [EvmAddress](./types/evm_address.md) + - [`String`](./types/string.md) + - [`Bits256`](./types/bits256.md) + - [`Bytes`](./types/bytes.md) + - [`B512`](./types/B512.md) + - [`EvmAddress`](./types/evm_address.md) - [Vectors](./types/vectors.md) - [Codec](./codec/index.md) - [Encoding](./codec/encoding.md) diff --git a/docs/src/abigen/the-abigen-macro.md b/docs/src/abigen/the-abigen-macro.md index d9aa541205..45d37e0782 100644 --- a/docs/src/abigen/the-abigen-macro.md +++ b/docs/src/abigen/the-abigen-macro.md @@ -14,7 +14,7 @@ where: - `name` is the name that will be given to the generated bindings, -- `abi` is either a path to the json abi file or its actual contents. +- `abi` is either a path to the JSON ABI file or its actual contents. --- @@ -62,9 +62,9 @@ Each `ProgramType` gets its own `mod` based on the `name` given in the `abigen!` One extra `mod` called `shared_types` is generated if `abigen!` detects that the given programs share types. Instead of each `mod` regenerating the type for itself, the type is lifted out into the `shared_types` module, generated only once, and then shared between all program bindings that use it. Reexports are added to each mod so that even if a type is deemed shared, you can still access it as though each `mod` had generated the type for itself (i.e. `my_contract_mod::SharedType`). -A type is deemed shared if its name and definition match up. This can happen either because you've used the same library (a custom one or a type from the stdlib) or because you've happened to define the exact same type. +A type is deemed shared if its name and definition match up. This can happen either because you've used the same library (a custom one or a type from the `stdlib`) or because you've happened to define the exact same type. -Finally, `pub use` statements are inserted, so you don't have to fully qualify the generated types. To avoid conflict, only types that have unique names will get a `pub use` statement. If you find rustc can't find your type, it might just be that there is another generated type with the same name. To fix the issue just qualify the path by doing `abigen_bindings::whatever_contract_mod::TheType`. +Finally, `pub use` statements are inserted, so you don't have to fully qualify the generated types. To avoid conflict, only types that have unique names will get a `pub use` statement. If you find `rustc` can't find your type, it might just be that there is another generated type with the same name. To fix the issue just qualify the path by doing `abigen_bindings::whatever_contract_mod::TheType`. > **Note:** > It is **highly** encouraged that you generate all your bindings in one `abigen!` call. Doing it in this manner will allow type sharing and avoid name collisions you'd normally get when calling `abigen!` multiple times inside the same namespace. If you choose to proceed otherwise, keep in mind the generated code overview presented above and appropriately separate the `abigen!` calls into different modules to resolve the collision. diff --git a/docs/src/calling-contracts/call-response.md b/docs/src/calling-contracts/call-response.md index 233f028c6a..309c9b25b1 100644 --- a/docs/src/calling-contracts/call-response.md +++ b/docs/src/calling-contracts/call-response.md @@ -20,7 +20,7 @@ Once you unwrap the `FuelCallResponse`, you have access to this struct: -Where `value` will hold the value returned by its respective contract method, represented by the exact type returned by the FuelVM, E.g., if your contract returns a FuelVM's `u64`, `value`'s `D` will be a `u64`. If it's a FuelVM's tuple `(u8,bool)`, then `D` will be a `(u8,bool)`. If it's a custom type, for instance, a Sway struct `MyStruct` containing two components, a `u64`, and a `b256`, `D` will be a struct generated at compile-time, called `MyStruct` with `u64` and a `[u8; 32]` (the equivalent of `b256` in Rust-land). +Where `value` will hold the value returned by its respective contract method, represented by the exact type returned by the FuelVM, E.g., if your contract returns a FuelVM's `u64`, `value`'s `D` will be a `u64`. If it's a FuelVM's tuple `(u8,bool)`, then `D` will be a `(u8,bool)`. If it's a custom type, for instance, a Sway struct `MyStruct` containing two components, a `u64`, and a `b256`, `D` will be a struct generated at compile-time, called `MyStruct` with `u64` and a `[u8; 32]` (the equivalent of `b256` in Rust). - `receipts` will hold all [receipts](https://specs.fuel.network/master/protocol/abi/receipts.html) generated by that specific contract call. - `gas_used` is the amount of gas it consumed by the contract call. @@ -31,7 +31,7 @@ Where `value` will hold the value returned by its respective contract method, re -You can use the `is_ok` and `is_err` methods to check if a contract call `Result` is ok or contains an error. These methods will return either `true` or `false`. +You can use the `is_ok` and `is_err` methods to check if a contract call `Result` is `Ok` or contains an error. These methods will return either `true` or `false`. diff --git a/docs/src/calling-contracts/custom-asset-transfer.md b/docs/src/calling-contracts/custom-asset-transfer.md index a5838ae2c2..48e78bedb1 100644 --- a/docs/src/calling-contracts/custom-asset-transfer.md +++ b/docs/src/calling-contracts/custom-asset-transfer.md @@ -2,7 +2,7 @@ -The SDK provides the option to transfer assets within the same transaction, when making a contract call. By using `add_custom_asset()` you specify the asset id, the amount, and the destination address: +The SDK provides the option to transfer assets within the same transaction, when making a contract call. By using `add_custom_asset()` you specify the asset ID, the amount, and the destination address: ```rust,ignore diff --git a/docs/src/calling-contracts/read-only.md b/docs/src/calling-contracts/read-only.md index 72444bffdc..f3fd3eaeea 100644 --- a/docs/src/calling-contracts/read-only.md +++ b/docs/src/calling-contracts/read-only.md @@ -6,7 +6,7 @@ Sometimes you want to call a contract method that doesn't change the state of th In this case, there's no need to generate an actual blockchain transaction; you only want to read a value quickly. -You can do this with the SDK. Instead of `.call()`ing the method, use `.simulate()`: +You can do this with the SDK. Instead of calling the method with `.call()`, use `.simulate()`: ```rust,ignore diff --git a/docs/src/calling-contracts/tx-dependency-estimation.md b/docs/src/calling-contracts/tx-dependency-estimation.md index 19f460b22c..e545b36b93 100644 --- a/docs/src/calling-contracts/tx-dependency-estimation.md +++ b/docs/src/calling-contracts/tx-dependency-estimation.md @@ -14,7 +14,7 @@ As mentioned in previous chapters, you can specify the external contract with `. {{#include ../../../examples/contracts/src/lib.rs:dependency_estimation_manual}} ``` -But this requires you to know the contract id of the external contract and the needed number of output variables. Alternatively, by chaining `.estimate_tx_dependencies()` instead, the dependencies will be estimated by the SDK and set automatically. The optional parameter is the maximum number of simulation attempts: +But this requires you to know the contract ID of the external contract and the needed number of output variables. Alternatively, by chaining `.estimate_tx_dependencies()` instead, the dependencies will be estimated by the SDK and set automatically. The optional parameter is the maximum number of simulation attempts: ```rust,ignore {{#include ../../../examples/contracts/src/lib.rs:dependency_estimation}} diff --git a/docs/src/cli/fuels-abi-cli.md b/docs/src/cli/fuels-abi-cli.md index d1e4faa41a..5a6e81f684 100644 --- a/docs/src/cli/fuels-abi-cli.md +++ b/docs/src/cli/fuels-abi-cli.md @@ -38,7 +38,7 @@ $ cargo run -- encode params -v bool true -v u32 42 -v u32 100 0000000000000001000000000000002a0000000000000064 ``` -Note that for every param you want to encode, you must pass a `-v` flag followed by the type, and then the value: `-v -v -v ` +Note that for every parameter you want to encode, you must pass a `-v` flag followed by the type, and then the value: `-v -v -v ` ### Encoding function call diff --git a/docs/src/codec/index.md b/docs/src/codec/index.md index ba23d7cb88..2d6e43f269 100644 --- a/docs/src/codec/index.md +++ b/docs/src/codec/index.md @@ -1,10 +1,10 @@ # Codec -Encoding and decoding are done as per [the fuel spec](https://specs.fuel.network/master/abi/argument-encoding.html). To this end, `fuels` makes use of the [ABIEncoder](https://docs.rs/fuels/latest/fuels/core/codec/struct.ABIEncoder.html) and the [ABIDecoder](https://docs.rs/fuels/latest/fuels/core/codec/struct.ABIDecoder.html). +Encoding and decoding are done as per [the fuel spec](https://specs.fuel.network/master/abi/argument-encoding.html). To this end, `fuels` makes use of the [`ABIEncoder`](https://docs.rs/fuels/latest/fuels/core/codec/struct.ABIEncoder.html) and the [`ABIDecoder`](https://docs.rs/fuels/latest/fuels/core/codec/struct.ABIDecoder.html). ## Prerequisites for decoding/encoding -To encode a type, you must first convert it into a [`Token`](https://docs.rs/fuels/latest/fuels/types/enum.Token.html). This is commonly done by implementing the [Tokenizable](https://docs.rs/fuels/latest/fuels/core/traits/trait.Tokenizable.html) trait. +To encode a type, you must first convert it into a [`Token`](https://docs.rs/fuels/latest/fuels/types/enum.Token.html). This is commonly done by implementing the [`Tokenizable`](https://docs.rs/fuels/latest/fuels/core/traits/trait.Tokenizable.html) trait. To decode, you also need to provide a [`ParamType`](https://docs.rs/fuels/latest/fuels/types/param_types/enum.ParamType.html) describing the schema of the type in question. This is commonly done by implementing the [Parameterize](https://docs.rs/fuels/latest/fuels/core/traits/trait.Parameterize.html) trait. diff --git a/docs/src/connecting/external-node.md b/docs/src/connecting/external-node.md index 5e752ad80c..502a5a0a5b 100644 --- a/docs/src/connecting/external-node.md +++ b/docs/src/connecting/external-node.md @@ -22,7 +22,7 @@ In the code example, we connected a new provider to the Testnet node and created > > [block-explorer](https://fuellabs.github.io/block-explorer-v2) -If you want to connect to another node just change the url or IP and port. For example, to connect to a local node that was created with `fuel-core` you can use: +If you want to connect to another node just change the URL or IP and port. For example, to connect to a local node that was created with `fuel-core` you can use: ```rust,ignore {{#include ../../../examples/providers/src/lib.rs:local_node_address}} diff --git a/docs/src/connecting/querying.md b/docs/src/connecting/querying.md index 7f3dfbe8bc..77a94e954b 100644 --- a/docs/src/connecting/querying.md +++ b/docs/src/connecting/querying.md @@ -25,13 +25,13 @@ This method returns all unspent coins (of a given asset ID) from a wallet. ## Get spendable resources owned by an address -The following example shows how to fetch resources owned by an address. First, you create a `ResourceFilter` which specifies the target address, asset id, and amount. You can also define utxo ids and message ids that should be excluded when retrieving the resources: +The following example shows how to fetch resources owned by an address. First, you create a `ResourceFilter` which specifies the target address, asset ID, and amount. You can also define UTXO IDs and message IDs that should be excluded when retrieving the resources: ```rust,ignore {{#include ../../../packages/fuels-accounts/src/provider.rs:resource_filter}} ``` -The example uses default values for the asset id and the exclusion lists. This resolves to the base asset id and empty vectors for the id lists respectively: +The example uses default values for the asset ID and the exclusion lists. This resolves to the base asset ID and empty vectors for the ID lists respectively: ```rust,ignore {{#include ../../../examples/providers/src/lib.rs:get_spendable_resources}} @@ -39,7 +39,7 @@ The example uses default values for the asset id and the exclusion lists. This r ## Get balances from an address -Get all the spendable balances of all assets for an address. This is different from getting the coins because we only return the numbers (the sum of UTXOs coins amount for each asset id) and not the UTXOs coins themselves. +Get all the spendable balances of all assets for an address. This is different from getting the coins because we only return the numbers (the sum of UTXOs coins amount for each asset ID) and not the UTXOs coins themselves. ```rust,ignore {{#include ../../../examples/providers/src/lib.rs:get_balances}} diff --git a/docs/src/connecting/retrying.md b/docs/src/connecting/retrying.md index ab51cb11cd..d987a65b75 100644 --- a/docs/src/connecting/retrying.md +++ b/docs/src/connecting/retrying.md @@ -6,7 +6,7 @@ The [`Provider`](https://docs.rs/fuels/0.47.0/fuels/accounts/provider/struct.Pro We can configure the number of retry attempts and the retry strategy as detailed below. -## RetryConfig +## `RetryConfig` The retry behavior can be altered by giving a custom `RetryConfig`. It allows for configuring the maximum number of attempts and the interval strategy used. @@ -18,7 +18,7 @@ The retry behavior can be altered by giving a custom `RetryConfig`. It allows fo {{#include ../../../examples/providers/src/lib.rs:configure_retry}} ``` -## Interval strategy - Backoff +## Interval strategy - `Backoff` `Backoff` defines different strategies for managing intervals between retry attempts. Each strategy allows you to customize the waiting time before a new attempt based on the number of attempts made. diff --git a/docs/src/connecting/rocksdb.md b/docs/src/connecting/rocksdb.md index 46de7b362f..0dc07bf5ef 100644 --- a/docs/src/connecting/rocksdb.md +++ b/docs/src/connecting/rocksdb.md @@ -1,6 +1,6 @@ -# RocksDb +# RocksDB -RocksDb enables the preservation of the blockchain's state locally, facilitating its future utilization. +RocksDB enables the preservation of the blockchain's state locally, facilitating its future utilization. To create or use a local database, follow these instructions: diff --git a/docs/src/connecting/short-lived.md b/docs/src/connecting/short-lived.md index d7fd7b0d8f..4d0713efc4 100644 --- a/docs/src/connecting/short-lived.md +++ b/docs/src/connecting/short-lived.md @@ -30,7 +30,7 @@ The `fuel-core-lib` feature allows us to run a `fuel-core` node without installi fuels = { version = "0.53.0", features = ["fuel-core-lib"] } ``` -### RocksDb +### RocksDB The `rocksdb` is an additional feature that, when combined with `fuel-core-lib`, provides persistent storage capabilities while using `fuel-core` as a library. diff --git a/docs/src/contributing/CONTRIBUTING.md b/docs/src/contributing/CONTRIBUTING.md index bdad1d7524..e0a2a046ac 100644 --- a/docs/src/contributing/CONTRIBUTING.md +++ b/docs/src/contributing/CONTRIBUTING.md @@ -11,7 +11,7 @@ If you run into any difficulties getting started, you can always ask questions o You may contribute to the project in many ways, some of which involve coding knowledge and some which do not. A few examples include: - Reporting bugs -- Adding new features or bugfixes for which there is already an open issue +- Adding new features or bug fixes for which there is already an open issue - Making feature requests Check out our [Help Wanted](https://github.com/FuelLabs/fuels-rs/labels/help%20wanted) or [Good First Issues](https://github.com/FuelLabs/fuels-rs/labels/good%20first%20issue) to find a suitable task. diff --git a/docs/src/cookbook/custom-chain.md b/docs/src/cookbook/custom-chain.md index 7c31c0a4be..8f5843283f 100644 --- a/docs/src/cookbook/custom-chain.md +++ b/docs/src/cookbook/custom-chain.md @@ -20,7 +20,7 @@ Before we can start a node, we probably also want to define some genesis coins a {{#include ../../../examples/cookbook/src/lib.rs:custom_chain_coins}} ``` -Finally, we call `setup_test_provider()`, which starts a node with the given configs and returns a +Finally, we call `setup_test_provider()`, which starts a node with the given configurations and returns a provider attached to that node: ```rust,ignore diff --git a/docs/src/cookbook/transfer-all-assets.md b/docs/src/cookbook/transfer-all-assets.md index 7a6f0662d5..40486fe9e0 100644 --- a/docs/src/cookbook/transfer-all-assets.md +++ b/docs/src/cookbook/transfer-all-assets.md @@ -10,7 +10,7 @@ Lets quickly go over the setup: We prepare two wallets with randomized addresses. Next, we want one of our wallets to have some random assets, so we set them up with `setup_multiple_assets_coins()`. Having created the coins, we can start a provider and assign it to the previously created wallets. -Transactions require us to define input and output coins. Let's assume we do not know the assets owned by `wallet_1`. We retrieve its balances, i.e. tuples consisting of a string representing the asset id and the respective amount. This lets us use the helpers `get_asset_inputs_for_amount()`, `get_asset_outputs_for_amount()` to create the appropriate inputs and outputs. +Transactions require us to define input and output coins. Let's assume we do not know the assets owned by `wallet_1`. We retrieve its balances, i.e. tuples consisting of a string representing the asset ID and the respective amount. This lets us use the helpers `get_asset_inputs_for_amount()`, `get_asset_outputs_for_amount()` to create the appropriate inputs and outputs. For the sake of simplicity, we avoid transferring the base asset so we don't have to worry about transaction fees: diff --git a/docs/src/custom-transactions/transaction-builders.md b/docs/src/custom-transactions/transaction-builders.md index d364cc39c7..9560ea275d 100644 --- a/docs/src/custom-transactions/transaction-builders.md +++ b/docs/src/custom-transactions/transaction-builders.md @@ -14,7 +14,7 @@ When your transaction involves predicates with dynamic data as inputs, like vect Similarly, adding signatures for signed coins requires the signed coin input to hold an index corresponding to the signature in the witnesses array. These indexes can also become invalid if the witness order changes. The Rust SDK again defers the resolution of these indexes until the transaction is finalized. It handles the assignment of correct index witnesses behind the scenes, sparing you the hassle of dealing with indexing intricacies during input definition. -Another added benefit of the builder pattern is that it guards against changes once the tx is finalized. The transactions resultign from a builder don't permit any changes to the struct that could cause the transaction ID to be modified. This eliminates the headache of calculating and storing a transaction ID for future use, only to accidentally modify the transaction later, resulting in a different transaction ID. +Another added benefit of the builder pattern is that it guards against changes once the transaction is finalized. The transactions resulting from a builder don't permit any changes to the struct that could cause the transaction ID to be modified. This eliminates the headache of calculating and storing a transaction ID for future use, only to accidentally modify the transaction later, resulting in a different transaction ID. ## Creating a custom transaction @@ -60,7 +60,7 @@ As we have used coins that require a signature, we sign the transaction builder > **Note** The signature is not created until the transaction is finalized with `build(&provider)` -We need to do one more thing before we stop thinking about transaction inputs. Executing the transaction also incurs a fee that is paid with the base asset. Our base asset inputs need to be large enough so that the total amount covers the transaction fee and any other operations we are doing. The Account trait lets us use `adjust_for_fee()` for adjusting the transaction inputs if needed to cover the fee. The second argument to `adjust_for_fee()` is the total amount of the base asset that we expect our tx to spend regardless of fees. In our case, this is the **ask_amount** we are transferring to the predicate. +We need to do one more thing before we stop thinking about transaction inputs. Executing the transaction also incurs a fee that is paid with the base asset. Our base asset inputs need to be large enough so that the total amount covers the transaction fee and any other operations we are doing. The Account trait lets us use `adjust_for_fee()` for adjusting the transaction inputs if needed to cover the fee. The second argument to `adjust_for_fee()` is the total amount of the base asset that we expect our transaction to spend regardless of fees. In our case, this is the **ask_amount** we are transferring to the predicate. ```rust,ignore {{#include ../../../examples/cookbook/src/lib.rs:custom_tx_adjust}} diff --git a/docs/src/debugging/function-selector.md b/docs/src/debugging/function-selector.md index 77aaaf7807..cdb3a84014 100644 --- a/docs/src/debugging/function-selector.md +++ b/docs/src/debugging/function-selector.md @@ -9,10 +9,10 @@ If, for whatever reason, you wish to generate the function selector yourself you {{#include ../../../examples/debugging/src/lib.rs:example_fn_selector}} ``` -## If you don't have the ParamType +## If you don't have the `ParamType` -If you won't or can't run the `abigen!` macro and all you have is the JSON ABI of you contract, you can still get the fn -selector, but you have to jump through an extra hoop to get the ParamTypes: +If you won't or can't run the `abigen!` macro and all you have is the JSON ABI of you contract, you can still get the function +selector, but you have to jump through an extra hoop to get the `ParamTypes`: ```rust,ignore {{#include ../../../examples/debugging/src/lib.rs:example_fn_selector_json}} diff --git a/docs/src/deploying/interacting-with-contracts.md b/docs/src/deploying/interacting-with-contracts.md index 95b14580d3..4037dc4cb1 100644 --- a/docs/src/deploying/interacting-with-contracts.md +++ b/docs/src/deploying/interacting-with-contracts.md @@ -6,10 +6,10 @@ If you already have a deployed contract and want to call its methods using the S {{#include ../../../examples/contracts/src/lib.rs:deployed_contracts}} ``` -The above example assumes that your contract id string is encoded in the bech32m format. You can recognize it by the human-readable-part "fuel" followed by the separator "1". However, when using other Fuel tools, you might end up with a hex-encoded contract id string. In that case, you can create your contract instance as follows: +The above example assumes that your contract ID string is encoded in the `bech32` format. You can recognize it by the human-readable-part "fuel" followed by the separator "1". However, when using other Fuel tools, you might end up with a hex-encoded contract ID string. In that case, you can create your contract instance as follows: ```rust,ignore {{#include ../../../examples/contracts/src/lib.rs:deployed_contracts_hex}} ``` -You can learn more about the Fuel SDK bech32 types [here](../types/bech32.md). +You can learn more about the Fuel SDK `bech32` types [here](../types/bech32.md). diff --git a/docs/src/predicates/index.md b/docs/src/predicates/index.md index 266711e79b..0d84784b40 100644 --- a/docs/src/predicates/index.md +++ b/docs/src/predicates/index.md @@ -12,7 +12,7 @@ Let's consider the following predicate example: We will look at a complete example of using the SDK to send and receive funds from a predicate. -First, we set up the wallets and a node instance. The call to the `abigen!` macro will generate all the types specified in the predicate plus two custom stucts: +First, we set up the wallets and a node instance. The call to the `abigen!` macro will generate all the types specified in the predicate plus two custom structs: - an encoder with an `encode_data` function that will conveniently encode all the arguments of the main function for us. - a configurables struct which holds methods for setting all the configurables mentioned in the predicate diff --git a/docs/src/testing/the-setup-program-test-macro.md b/docs/src/testing/the-setup-program-test-macro.md index a9722c2003..81dcf57959 100644 --- a/docs/src/testing/the-setup-program-test-macro.md +++ b/docs/src/testing/the-setup-program-test-macro.md @@ -66,7 +66,7 @@ Description: Deploys the `contract` (with salt) using `wallet`. Will create a co Cardinality: 0 or N. -## LoadScript +## `LoadScript` Example: `LoadScript(name = "script_instance", script = "MyScript", wallet = "wallet")` diff --git a/docs/src/types/B512.md b/docs/src/types/B512.md index b5489da52f..8d53d5b436 100644 --- a/docs/src/types/B512.md +++ b/docs/src/types/B512.md @@ -1,4 +1,4 @@ -# B512 +# `B512` In the Rust SDK, the `B512` definition matches the Sway standard library type with the same name and will be converted accordingly when interacting with contracts: diff --git a/docs/src/types/address.md b/docs/src/types/address.md index 3aac7381f5..8ced0feb63 100644 --- a/docs/src/types/address.md +++ b/docs/src/types/address.md @@ -1,4 +1,4 @@ -# Address +# `Address` Like `Bytes32`, `Address` is a wrapper on `[u8; 32]` with similar methods and implements the same traits (see [fuel-types documentation](https://docs.rs/fuel-types/{{versions.fuel-types}}/fuel_types/struct.Address.html)). diff --git a/docs/src/types/asset-id.md b/docs/src/types/asset-id.md index 71f43348aa..1ae05f0251 100644 --- a/docs/src/types/asset-id.md +++ b/docs/src/types/asset-id.md @@ -1,4 +1,4 @@ -# AssetId +# `AssetId` Like `Bytes32`, `AssetId` is a wrapper on `[u8; 32]` with similar methods and implements the same traits (see [fuel-types documentation](https://docs.rs/fuel-types/{{versions.fuel-types}}/fuel_types/struct.AssetId.html)). diff --git a/docs/src/types/bech32.md b/docs/src/types/bech32.md index fb3701c265..511fb98969 100644 --- a/docs/src/types/bech32.md +++ b/docs/src/types/bech32.md @@ -1,6 +1,6 @@ -# Bech32 +# `Bech32` -`Bech32Address` and `Bech32ContractId` enable the use of addresses and contract ids in the bech32 format. They can easily be converted to their counterparts `Address` and `ContractId`. +`Bech32Address` and `Bech32ContractId` enable the use of addresses and contract IDs in the `bech32` format. They can easily be converted to their counterparts `Address` and `ContractId`. Here are the main ways of creating a `Bech32Address`, but note that the same applies to `Bech32ContractId`: @@ -8,4 +8,4 @@ Here are the main ways of creating a `Bech32Address`, but note that the same app {{#include ../../../examples/types/src/lib.rs:bech32}} ``` -> **Note:** when creating a `Bech32Address` from `Address` or `Bech32ContractId` from `ContractId` the HRP (Human-Readable Part) is set to **"fuel"** per default. +> **Note:** when creating a `Bech32Address` from `Address` or `Bech32ContractId` from `ContractId` the `HRP` (Human-Readable Part) is set to **"fuel"** per default. diff --git a/docs/src/types/bits256.md b/docs/src/types/bits256.md index 5e466f6272..430134953e 100644 --- a/docs/src/types/bits256.md +++ b/docs/src/types/bits256.md @@ -1,4 +1,4 @@ -# Bits256 +# `Bits256` In Fuel, a type called `b256` represents hashes and holds a 256-bit value. The Rust SDK represents `b256` as `Bits256(value)` where `value` is a `[u8; 32]`. If your contract method takes a `b256` as input, you must pass a `Bits256([u8; 32])` when calling it from the SDK. diff --git a/docs/src/types/bytes.md b/docs/src/types/bytes.md index cd7749db67..0b02e0efef 100644 --- a/docs/src/types/bytes.md +++ b/docs/src/types/bytes.md @@ -1,4 +1,4 @@ -# Bytes +# `Bytes` In Fuel, a type called `Bytes` represents a collection of tightly-packed bytes. The Rust SDK represents `Bytes` as `Bytes(Vec)`. Here's an example of using `Bytes` in a contract call: diff --git a/docs/src/types/bytes32.md b/docs/src/types/bytes32.md index 041fc2d46e..4558e77b8a 100644 --- a/docs/src/types/bytes32.md +++ b/docs/src/types/bytes32.md @@ -1,4 +1,4 @@ -# Bytes32 +# `Bytes32` In Sway and the FuelVM, `Bytes32` represents hashes. They hold a 256-bit (32-byte) value. `Bytes32` is a wrapper on a 32-sized slice of `u8`: `pub struct Bytes32([u8; 32]);`. @@ -8,7 +8,7 @@ These are the main ways of creating a `Bytes32`: {{#include ../../../examples/types/src/lib.rs:bytes32}} ``` -`Bytes32` also implements _fmt's_ `Debug`, `Display`, `LowerHex` and `UpperHex` traits. For example, you can get the display and hex representations with: +`Bytes32` also implements the `fmt` module's `Debug`, `Display`, `LowerHex` and `UpperHex` traits. For example, you can get the display and hex representations with: ```rust,ignore {{#include ../../../examples/types/src/lib.rs:bytes32_format}} diff --git a/docs/src/types/contract-id.md b/docs/src/types/contract-id.md index a14dd877ce..b4c8e2c6c7 100644 --- a/docs/src/types/contract-id.md +++ b/docs/src/types/contract-id.md @@ -1,4 +1,4 @@ -# ContractId +# `ContractId` Like `Bytes32`, `ContractId` is a wrapper on `[u8; 32]` with similar methods and implements the same traits (see [fuel-types documentation](https://docs.rs/fuel-types/{{versions.fuel-types}}/fuel_types/struct.ContractId.html)). diff --git a/docs/src/types/evm_address.md b/docs/src/types/evm_address.md index 0e6fbe690d..a43b60e100 100644 --- a/docs/src/types/evm_address.md +++ b/docs/src/types/evm_address.md @@ -1,6 +1,6 @@ -# EvmAddress +# `EvmAddress` -In the Rust SDK, Ethereum Virtual Machine (EVM) addresses can be represented with the 'EvmAddress' type. Its definition matches with the Sway standard library type with the same name and will be converted accordingly when interacting with contracts: +In the Rust SDK, Ethereum Virtual Machine (EVM) addresses can be represented with the `EvmAddress` type. Its definition matches with the Sway standard library type with the same name and will be converted accordingly when interacting with contracts: ```rust,ignore {{#include ../../../packages/fuels-core/src/types/core/bits.rs:evm_address}} @@ -12,4 +12,4 @@ Here's an example: {{#include ../../../packages/fuels/tests/bindings.rs:evm_address_arg}} ``` -> **Note:** when creating an `EvmAddress` from `Bits256`, the first 12 bytes will be cleared because an evm address is only 20 bytes long. +> **Note:** when creating an `EvmAddress` from `Bits256`, the first 12 bytes will be cleared because an EVM address is only 20 bytes long. diff --git a/docs/src/types/string.md b/docs/src/types/string.md index 611d7084fc..e9e4eecc07 100644 --- a/docs/src/types/string.md +++ b/docs/src/types/string.md @@ -1,4 +1,4 @@ -# String +# `String` The Rust SDK represents Fuel's `String`s as `SizedAsciiString`, where the generic parameter `LEN` is the length of a given string. This abstraction is necessary because all strings in Fuel and Sway are statically-sized, i.e., you must know the size of the string beforehand. diff --git a/docs/src/wallets/access.md b/docs/src/wallets/access.md index 5ac7458148..635633d6e6 100644 --- a/docs/src/wallets/access.md +++ b/docs/src/wallets/access.md @@ -50,7 +50,7 @@ let wallet_locked = wallet_unlocked.lock(); ``` Most wallet constructors that create or generate a new wallet are provided on -the `WalletUnlocked` type. Consider `lock`ing the wallet after the new private +the `WalletUnlocked` type. Consider locking the wallet with the `lock` method after the new private key has been handled in order to reduce the scope in which the wallet's private key is stored in memory. diff --git a/docs/src/wallets/signing.md b/docs/src/wallets/signing.md index 92a48df48f..b0144e1c0e 100644 --- a/docs/src/wallets/signing.md +++ b/docs/src/wallets/signing.md @@ -8,7 +8,7 @@ Once you've instantiated your wallet in an unlocked state using one of the previ ## Signing a transaction -Every signed resource in the inputs needs to have a witness index that points to a valid witness. Changing the witness index inside an input will change the transaction id. This means that we need to set all witness indexes before finally signing the tx. Previously, the user had to make sure that the witness indexes and the order of the witnesses are correct. To automate this process, the SDK will keep track of the signatures in the transaction builder and resolve the final transaction automatically. This is done by storing the secret keys of all signers until the final transaction is built. +Every signed resource in the inputs needs to have a witness index that points to a valid witness. Changing the witness index inside an input will change the transaction ID. This means that we need to set all witness indexes before finally signing the transaction. Previously, the user had to make sure that the witness indexes and the order of the witnesses are correct. To automate this process, the SDK will keep track of the signatures in the transaction builder and resolve the final transaction automatically. This is done by storing the secret keys of all signers until the final transaction is built. To sign a _transaction builder_ use the `wallet.sign_transaction`. Below is a full example of how to create a transaction and sign it. diff --git a/docs/src/wallets/test-wallets.md b/docs/src/wallets/test-wallets.md index 6940c4f407..d23ee56a1d 100644 --- a/docs/src/wallets/test-wallets.md +++ b/docs/src/wallets/test-wallets.md @@ -36,8 +36,8 @@ You can create a test wallet containing multiple assets (including the base asse {{#include ../../../examples/wallets/src/lib.rs:multiple_assets_wallet}} ``` -- coins: `Vec<(UtxoId, Coin)>` has num_assets * coins_per_assets coins (UTXOs) -- asset_ids: `Vec` contains the num_assets randomly generated `AssetId`s (always includes the base asset) +- coins: `Vec<(UtxoId, Coin)>` has `num_assets` * `coins_per_assets` coins (UTXOs) +- asset_ids: `Vec` contains the `num_assets` randomly generated `AssetId`s (always includes the base asset) ## Setting up a test wallet with multiple custom assets @@ -60,7 +60,7 @@ This can also be achieved directly with the `WalletsConfig`. The Fuel blockchain holds many different assets; you can create your asset with its unique `AssetId` or create random assets for testing purposes. -You can use only one asset to pay for transaction fees and gas: the base asset, whose AssetId is `0x000...0`, a 32-byte zeroed value. +You can use only one asset to pay for transaction fees and gas: the base asset, whose `AssetId` is `0x000...0`, a 32-byte zeroed value. For testing purposes, you can configure coins and amounts for assets. You can use `setup_multiple_assets_coins`: