From 44ea54c007ae7ad1f259c5989fdab9389ee974ed Mon Sep 17 00:00:00 2001 From: nedsalk Date: Tue, 14 Jan 2025 14:06:34 +0100 Subject: [PATCH 01/21] replace links with magic string `DOCS_API_URL` --- apps/docs-api/index.md | 24 +++++++------- .../src/guide/contracts/contract-balance.md | 4 +-- .../src/guide/contracts/cost-estimation.md | 2 +- .../guide/contracts/dependency-estimation.md | 2 +- .../guide/contracts/deploying-contracts.md | 2 +- .../contracts/managing-deployed-contracts.md | 8 ++--- .../guide/contracts/minted-token-asset-id.md | 2 +- .../contracts/using-different-wallets.md | 2 +- ...custom-transactions-from-contract-calls.md | 2 +- .../src/guide/cookbook/custom-transactions.md | 4 +-- apps/docs/src/guide/errors/index.md | 6 ++-- .../predicates/instantiating-a-predicate.md | 2 +- apps/docs/src/guide/predicates/methods.md | 2 +- .../send-and-spend-funds-from-predicates.md | 2 +- apps/docs/src/guide/provider/index.md | 2 +- .../src/guide/provider/provider-options.md | 2 +- .../guide/testing/launching-a-test-node.md | 2 +- .../src/guide/testing/test-node-options.md | 4 +-- .../transactions/modifying-the-request.md | 2 +- apps/docs/src/guide/types/address.md | 16 +++++----- apps/docs/src/guide/types/bits256.md | 2 +- .../src/guide/utilities/address-conversion.md | 6 ++-- apps/docs/src/guide/utilities/using-assets.md | 4 +-- .../src/guide/wallets/checking-balances.md | 4 +-- apps/docs/src/guide/wallets/connectors.md | 32 +++++++++---------- .../wallets/encrypting-and-decrypting.md | 8 ++--- apps/docs/src/guide/wallets/index.md | 8 ++--- .../guide/wallets/instantiating-wallets.md | 8 ++--- .../guide/wallets/locking-and-unlocking.md | 26 +++++++-------- apps/docs/src/index.md | 2 +- 30 files changed, 96 insertions(+), 96 deletions(-) diff --git a/apps/docs-api/index.md b/apps/docs-api/index.md index 9e9f1c5e6bc..90f1c944220 100644 --- a/apps/docs-api/index.md +++ b/apps/docs-api/index.md @@ -12,15 +12,15 @@ # Modules -- [abi-coder](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_abi_coder.html) -- [abi-typegen](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_abi_typegen.html) -- [account](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_account.html) -- [address](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_address.html) -- [crypto](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_crypto.html) -- [errors](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_errors.html) -- [hasher](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_hasher.html) -- [math](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_math.html) -- [program](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_program.html) -- [script](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_script.html) -- [transactions](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_transactions.html) -- [utils](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_utils.html) +- [abi-coder](DOCS_API_URL/modules/_fuel_ts_abi_coder.html) +- [abi-typegen](DOCS_API_URL/modules/_fuel_ts_abi_typegen.html) +- [account](DOCS_API_URL/modules/_fuel_ts_account.html) +- [address](DOCS_API_URL/modules/_fuel_ts_address.html) +- [crypto](DOCS_API_URL/modules/_fuel_ts_crypto.html) +- [errors](DOCS_API_URL/modules/_fuel_ts_errors.html) +- [hasher](DOCS_API_URL/modules/_fuel_ts_hasher.html) +- [math](DOCS_API_URL/modules/_fuel_ts_math.html) +- [program](DOCS_API_URL/modules/_fuel_ts_program.html) +- [script](DOCS_API_URL/modules/_fuel_ts_script.html) +- [transactions](DOCS_API_URL/modules/_fuel_ts_transactions.html) +- [utils](DOCS_API_URL/modules/_fuel_ts_utils.html) diff --git a/apps/docs/src/guide/contracts/contract-balance.md b/apps/docs/src/guide/contracts/contract-balance.md index aa60d1a211c..316e14ed689 100644 --- a/apps/docs/src/guide/contracts/contract-balance.md +++ b/apps/docs/src/guide/contracts/contract-balance.md @@ -1,10 +1,10 @@ # Contract Balance -When working with contracts, it's crucial to be aware of the available contract balance of an asset while paying for costly operations. This guide will explain the `getBalance` method in the [Contract](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.Contract.html) class, which allows you to check a contract's available balance. +When working with contracts, it's crucial to be aware of the available contract balance of an asset while paying for costly operations. This guide will explain the `getBalance` method in the [Contract](DOCS_API_URL/classes/_fuel_ts_program.Contract.html) class, which allows you to check a contract's available balance. ## The `getBalance` Method -The [`Contract.getBalance`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.Contract.html#getBalance) method retrieves the available balance of a specific asset on your contract. This method is particularly useful for determining the remaining balance after sending assets to a contract and executing contract calls. +The [`Contract.getBalance`](DOCS_API_URL/classes/_fuel_ts_program.Contract.html#getBalance) method retrieves the available balance of a specific asset on your contract. This method is particularly useful for determining the remaining balance after sending assets to a contract and executing contract calls. It is important to note that this method returns the total available contract balance, regardless of how often assets have been sent to it or spent. diff --git a/apps/docs/src/guide/contracts/cost-estimation.md b/apps/docs/src/guide/contracts/cost-estimation.md index 020cea63a49..30aed4176a2 100644 --- a/apps/docs/src/guide/contracts/cost-estimation.md +++ b/apps/docs/src/guide/contracts/cost-estimation.md @@ -1,6 +1,6 @@ # Estimating Contract Call Cost -The [`FunctionInvocationScope.getTransactionCost`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.FunctionInvocationScope.html#getTransactionCost) method allows you to estimate the cost of a specific contract call. The return type, `TransactionCost`, is an object containing relevant information for the estimation: +The [`FunctionInvocationScope.getTransactionCost`](DOCS_API_URL/classes/_fuel_ts_program.FunctionInvocationScope.html#getTransactionCost) method allows you to estimate the cost of a specific contract call. The return type, `TransactionCost`, is an object containing relevant information for the estimation: <<< @/../../../packages/account/src/providers/provider.ts#cost-estimation-1{ts:line-numbers} diff --git a/apps/docs/src/guide/contracts/dependency-estimation.md b/apps/docs/src/guide/contracts/dependency-estimation.md index 1511624f3e4..aea783d8592 100644 --- a/apps/docs/src/guide/contracts/dependency-estimation.md +++ b/apps/docs/src/guide/contracts/dependency-estimation.md @@ -4,6 +4,6 @@ In [variable outputs](./variable-outputs.md), we mention that a contract call mi However, by default the SDK always automatically estimates these dependencies and double-checks if everything is in order whenever you invoke a contract function or attempt to send a transaction. -The SDK uses the [Provider.estimateTxDependencies](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Provider.html#estimateTxDependencies) method to set any missing dependencies identified during the estimation process. This requires simulating the transaction a few times in the background. +The SDK uses the [Provider.estimateTxDependencies](DOCS_API_URL/classes/_fuel_ts_account.Provider.html#estimateTxDependencies) method to set any missing dependencies identified during the estimation process. This requires simulating the transaction a few times in the background. While relying on the SDK's automatic estimation is a decent default behavior, we recommend manually specifying the dependencies if they are known in advance to avoid the performance impact of the estimation process. diff --git a/apps/docs/src/guide/contracts/deploying-contracts.md b/apps/docs/src/guide/contracts/deploying-contracts.md index 34571fb4039..86ebf11f646 100644 --- a/apps/docs/src/guide/contracts/deploying-contracts.md +++ b/apps/docs/src/guide/contracts/deploying-contracts.md @@ -53,7 +53,7 @@ Now that the contract is deployed, you can interact with it by submitting a cont ## Deploying a Large Contract as Blobs -In the above guide we use the recommended `deploy` method. If you are working with a contract that is too large to be deployed in a single transaction, then the SDK will chunk the contract for you and submit it as blobs, to then be accessed later by a create transaction. This process is handled by the [`ContractFactory.deployAsBlobTx`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_contract.index.ContractFactory.html#deployAsBlobTx) method. +In the above guide we use the recommended `deploy` method. If you are working with a contract that is too large to be deployed in a single transaction, then the SDK will chunk the contract for you and submit it as blobs, to then be accessed later by a create transaction. This process is handled by the [`ContractFactory.deployAsBlobTx`](DOCS_API_URL/classes/_fuel_ts_contract.index.ContractFactory.html#deployAsBlobTx) method. <<< @./snippets/deploying-contracts/deployment.ts#blobs{ts:line-numbers} diff --git a/apps/docs/src/guide/contracts/managing-deployed-contracts.md b/apps/docs/src/guide/contracts/managing-deployed-contracts.md index 4be51241b5c..08ec300ab06 100644 --- a/apps/docs/src/guide/contracts/managing-deployed-contracts.md +++ b/apps/docs/src/guide/contracts/managing-deployed-contracts.md @@ -4,9 +4,9 @@ To interact with a deployed contract using the SDK without redeploying it, you o ## Contract ID -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 `contractId` property from the [`Contract`](DOCS_API_URL/classes/_fuel_ts_program.Contract.html) class is an instance of the [`Address`](DOCS_API_URL/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`](DOCS_API_URL/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. 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`](DOCS_API_URL/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. 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`](DOCS_API_URL/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..7a028b75d14 100644 --- a/apps/docs/src/guide/contracts/minted-token-asset-id.md +++ b/apps/docs/src/guide/contracts/minted-token-asset-id.md @@ -23,6 +23,6 @@ Since the asset ID depends on the contract ID, which is always dynamic (unlike t ## Create Asset Id -The SDK provides a helper named `createAssetId` which takes the contract ID and sub ID as parameters. This helper internally calls `getMintedAssetId` and returns the Sway native parameter [AssetId](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_address.AssetId.html), ready to be used in a Sway program invocation: +The SDK provides a helper named `createAssetId` which takes the contract ID and sub ID as parameters. This helper internally calls `getMintedAssetId` and returns the Sway native parameter [AssetId](DOCS_API_URL/types/_fuel_ts_address.AssetId.html), ready to be used in a Sway program invocation: <<< @./snippets/utilities/create-asset-id.ts#create-asset-id-1{ts:line-numbers} diff --git a/apps/docs/src/guide/contracts/using-different-wallets.md b/apps/docs/src/guide/contracts/using-different-wallets.md index a82de3c8e3e..23cc2057971 100644 --- a/apps/docs/src/guide/contracts/using-different-wallets.md +++ b/apps/docs/src/guide/contracts/using-different-wallets.md @@ -1,6 +1,6 @@ # Making Calls with Different Wallets or Providers -This guide demonstrates how to make contract calls using different wallets and providers by passing either an [`Account`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Account.html) or a [`Provider`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Provider.html) to the contract on instantiation. +This guide demonstrates how to make contract calls using different wallets and providers by passing either an [`Account`](DOCS_API_URL/classes/_fuel_ts_account.Account.html) or a [`Provider`](DOCS_API_URL/classes/_fuel_ts_account.Provider.html) to the contract on instantiation. ## Changing Wallets diff --git a/apps/docs/src/guide/cookbook/custom-transactions-from-contract-calls.md b/apps/docs/src/guide/cookbook/custom-transactions-from-contract-calls.md index cc1245bc329..0283dbcc77f 100644 --- a/apps/docs/src/guide/cookbook/custom-transactions-from-contract-calls.md +++ b/apps/docs/src/guide/cookbook/custom-transactions-from-contract-calls.md @@ -1,6 +1,6 @@ # Custom Transactions From Contract Calls -In the previous example we demonstrated how you can instantiate a [`ScriptTransactionRequest`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.ScriptTransactionRequest.html) to customize and build out a more complex transaction via a script. The same can be done using contracts, but this allows us to utilize functions available in the contract and access on-chain state. Allowing us to harness all of the power from an invocation scope and a transaction request. +In the previous example we demonstrated how you can instantiate a [`ScriptTransactionRequest`](DOCS_API_URL/classes/_fuel_ts_account.ScriptTransactionRequest.html) to customize and build out a more complex transaction via a script. The same can be done using contracts, but this allows us to utilize functions available in the contract and access on-chain state. Allowing us to harness all of the power from an invocation scope and a transaction request. This cookbook demonstrates how we can utilize a contract call to build out a custom transaction, allowing us to update on-chain state and transfer assets to a recipient address. diff --git a/apps/docs/src/guide/cookbook/custom-transactions.md b/apps/docs/src/guide/cookbook/custom-transactions.md index a794879a64f..e387ae84537 100644 --- a/apps/docs/src/guide/cookbook/custom-transactions.md +++ b/apps/docs/src/guide/cookbook/custom-transactions.md @@ -1,12 +1,12 @@ # Custom Transactions -There may be scenarios where you need to build out transactions that involve multiple program types and assets; this can be done by instantiating a [`ScriptTransactionRequest`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.ScriptTransactionRequest.html). This class allows you to a append multiple program types and assets to a single transaction. +There may be scenarios where you need to build out transactions that involve multiple program types and assets; this can be done by instantiating a [`ScriptTransactionRequest`](DOCS_API_URL/classes/_fuel_ts_account.ScriptTransactionRequest.html). This class allows you to a append multiple program types and assets to a single transaction. Consider the following script that transfers multiple assets to a contract: <<< @/../../docs/sway/script-transfer-to-contract/src/main.sw#custom-transactions-1{rust:line-numbers} -This script can be executed by creating a [`ScriptTransactionRequest`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.ScriptTransactionRequest.html), appending the resource and contract inputs/outputs and then sending the transaction, as follows: +This script can be executed by creating a [`ScriptTransactionRequest`](DOCS_API_URL/classes/_fuel_ts_account.ScriptTransactionRequest.html), appending the resource and contract inputs/outputs and then sending the transaction, as follows: <<< @/../../docs/src/guide/scripts/snippets/script-custom-transaction.ts#custom-transactions-2{ts:line-numbers} diff --git a/apps/docs/src/guide/errors/index.md b/apps/docs/src/guide/errors/index.md index f28a91ef8b4..7a69096255e 100644 --- a/apps/docs/src/guide/errors/index.md +++ b/apps/docs/src/guide/errors/index.md @@ -20,7 +20,7 @@ Check that the arguments supplied to the function match the required type. ### `ACCOUNT_REQUIRED` -When an [`Account`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Account.html) is required for an operation. This will usually be in the form of a [`Wallet`](../wallets/index.md). +When an [`Account`](DOCS_API_URL/classes/_fuel_ts_account.Account.html) is required for an operation. This will usually be in the form of a [`Wallet`](../wallets/index.md). It could be caused during the deployments of contracts when an account is required to sign the transaction. This can be resolved by following the deployment guide [here](../contracts/deploying-contracts.md). @@ -220,7 +220,7 @@ Check the status received is within `TransactionStatus`. When the transaction type from the Fuel Node is _not_ supported. -The type is within [`TransactionType`](https://fuels-ts-docs-api.vercel.app/enums/_fuel_ts_account.TransactionType.html). +The type is within [`TransactionType`](DOCS_API_URL/enums/_fuel_ts_account.TransactionType.html). ### `INVALID_TTL` @@ -262,7 +262,7 @@ Ensure that a connector has been supplied to the `Account` or `Wallet`. A provider is missing when it's required for a given operation. -It could be caused by the provider not being set for either an [`Account`](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_account.html) or a [`Wallet`](../wallets/index.md) - use the `connect` method to attach a provider. +It could be caused by the provider not being set for either an [`Account`](DOCS_API_URL/modules/_fuel_ts_account.html) or a [`Wallet`](../wallets/index.md) - use the `connect` method to attach a provider. ### `MISSING_REQUIRED_PARAMETER` diff --git a/apps/docs/src/guide/predicates/instantiating-a-predicate.md b/apps/docs/src/guide/predicates/instantiating-a-predicate.md index e406d217bdd..27e5d3a0ff9 100644 --- a/apps/docs/src/guide/predicates/instantiating-a-predicate.md +++ b/apps/docs/src/guide/predicates/instantiating-a-predicate.md @@ -12,7 +12,7 @@ After compiling, you will obtain the binary of the predicate and its JSON ABI (A <<< @./snippets/instantiation/simple.ts#predicate-simple-2{ts:line-numbers} -The created [`Predicate`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Predicate.html) instance, among other things, has three important properties: the predicate `bytes` (byte code), the `chainId`, and the predicate `address`. +The created [`Predicate`](DOCS_API_URL/classes/_fuel_ts_account.Predicate.html) instance, among other things, has three important properties: the predicate `bytes` (byte code), the `chainId`, and the predicate `address`. This address, generated from the byte code, corresponds to the Pay-to-Script-Hash (P2SH) address used in Bitcoin. diff --git a/apps/docs/src/guide/predicates/methods.md b/apps/docs/src/guide/predicates/methods.md index a1d768c2a58..b07e361cd03 100644 --- a/apps/docs/src/guide/predicates/methods.md +++ b/apps/docs/src/guide/predicates/methods.md @@ -1,6 +1,6 @@ # Interacting With Predicates -The `Predicate` class extends the [`Account`](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_account.html) class, inheriting all its methods. Therefore, there are multiple ways to interact with predicates, but broadly speaking, we can think about three: +The `Predicate` class extends the [`Account`](DOCS_API_URL/modules/_fuel_ts_account.html) class, inheriting all its methods. Therefore, there are multiple ways to interact with predicates, but broadly speaking, we can think about three: - `Checking Balances` - `Transactions` 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..afec9a16399 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 @@ -38,7 +38,7 @@ Once the predicate resolves with a return value `true` based on its predefined c --- -In a similar approach, you can use the `createTransfer` method, which returns a [`ScriptTransactionRequest`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.ScriptTransactionRequest.html). Then, we can submit this transaction request by calling the `sendTransaction` method. +In a similar approach, you can use the `createTransfer` method, which returns a [`ScriptTransactionRequest`](DOCS_API_URL/classes/_fuel_ts_account.ScriptTransactionRequest.html). Then, we can submit this transaction request by calling the `sendTransaction` method. The following example, we are pre-staging a transaction and therefore we are able to know the transaction ID without actually submitting the transaction. diff --git a/apps/docs/src/guide/provider/index.md b/apps/docs/src/guide/provider/index.md index d8a09b86e83..b737b31db9a 100644 --- a/apps/docs/src/guide/provider/index.md +++ b/apps/docs/src/guide/provider/index.md @@ -1,6 +1,6 @@ # Provider -The [`Provider`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Provider.html) lets you connect to a Fuel node ([_*docs*_](../getting-started/connecting-to-the-network.md)) and interact with it, encapsulating common client operations in the SDK. Those operations include querying the blockchain for network, block, and transaction-related info (and [more](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Provider.html)), as well as sending [transactions](../transactions/index.md) to the blockchain. +The [`Provider`](DOCS_API_URL/classes/_fuel_ts_account.Provider.html) lets you connect to a Fuel node ([_*docs*_](../getting-started/connecting-to-the-network.md)) and interact with it, encapsulating common client operations in the SDK. Those operations include querying the blockchain for network, block, and transaction-related info (and [more](DOCS_API_URL/classes/_fuel_ts_account.Provider.html)), as well as sending [transactions](../transactions/index.md) to the blockchain. All higher-level abstractions (e.g. [`Wallet`](../wallets/index.md), [`Contract`](../contracts/index.md)) that interact with the blockchain go through the `Provider`, so it's used for various actions like getting a wallet's balance, deploying contracts, querying their state, etc. diff --git a/apps/docs/src/guide/provider/provider-options.md b/apps/docs/src/guide/provider/provider-options.md index 6a9ce98c1db..1748913a2e7 100644 --- a/apps/docs/src/guide/provider/provider-options.md +++ b/apps/docs/src/guide/provider/provider-options.md @@ -1,6 +1,6 @@ # Provider Options -You can provide various [options](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.ProviderOptions.html) on `Provider` instantiation to modify its behavior. +You can provide various [options](DOCS_API_URL/types/_fuel_ts_account.ProviderOptions.html) on `Provider` instantiation to modify its behavior. ### `retryOptions` diff --git a/apps/docs/src/guide/testing/launching-a-test-node.md b/apps/docs/src/guide/testing/launching-a-test-node.md index 304dfc6c445..c12dba644aa 100644 --- a/apps/docs/src/guide/testing/launching-a-test-node.md +++ b/apps/docs/src/guide/testing/launching-a-test-node.md @@ -4,7 +4,7 @@ To simplify testing in isolation, we provide a utility called `launchTestNode`. It allows you to spin up a short-lived `fuel-core` node, set up a custom provider, wallets, deploy contracts, and much more in one go. -For usage information for `launchTestNode` including it's inputs, outputs and options, please check the [API reference](https://fuels-ts-docs-api.vercel.app/functions/_fuel_ts_contract.test_utils.launchTestNode.html). +For usage information for `launchTestNode` including it's inputs, outputs and options, please check the [API reference](DOCS_API_URL/functions/_fuel_ts_contract.test_utils.launchTestNode.html). ## Explicit Resource Management diff --git a/apps/docs/src/guide/testing/test-node-options.md b/apps/docs/src/guide/testing/test-node-options.md index cb8855b44ef..70a986a79cd 100644 --- a/apps/docs/src/guide/testing/test-node-options.md +++ b/apps/docs/src/guide/testing/test-node-options.md @@ -9,7 +9,7 @@ This reference describes all the options of the [`launchTestNode`](./launching-a <<< @./snippets/launching-a-test-node.ts#options{ts:line-numbers} -Check out the [API reference](https://fuels-ts-docs-api.vercel.app/interfaces/_fuel_ts_contract.test_utils.LaunchTestNodeOptions.html) for usage information on the Test Node Options. +Check out the [API reference](DOCS_API_URL/interfaces/_fuel_ts_contract.test_utils.LaunchTestNodeOptions.html) for usage information on the Test Node Options. ## `walletsConfig` @@ -44,7 +44,7 @@ Used to deploy contracts on the node the `launchTestNode` utility launches. It's - `factory`: contract factory class outputted by `pnpm fuels typegen`. - `walletIndex`: the index of the wallets generated by [`walletsConfig`](./test-node-options.md#walletsconfig) that you want to deploy the contract with. -- `options`: options for [contract deployment](../contracts/deploying-contracts.md#2-contract-deployment) that get passed to the [`ContractFactory.deploy`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_contract.index.ContractFactory.html#deploy) method. +- `options`: options for [contract deployment](../contracts/deploying-contracts.md#2-contract-deployment) that get passed to the [`ContractFactory.deploy`](DOCS_API_URL/classes/_fuel_ts_contract.index.ContractFactory.html#deploy) method. ## `nodeOptions` diff --git a/apps/docs/src/guide/transactions/modifying-the-request.md b/apps/docs/src/guide/transactions/modifying-the-request.md index 06e9bc724a9..3a2173eed95 100644 --- a/apps/docs/src/guide/transactions/modifying-the-request.md +++ b/apps/docs/src/guide/transactions/modifying-the-request.md @@ -48,7 +48,7 @@ The other more manual approach is as so: <<< @./snippets/transaction-request/get-transaction-cost.ts#transaction-request-4{ts:line-numbers} -This approach provides the same behaviour as the `estimateAndFund` helper, but gives more granular control over the transaction request. The `getTransactionCost` method also returns various information about the simulated request that you may want to use to further modify the transaction request, more on that can be found in the [API reference](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.TransactionCost.html). +This approach provides the same behaviour as the `estimateAndFund` helper, but gives more granular control over the transaction request. The `getTransactionCost` method also returns various information about the simulated request that you may want to use to further modify the transaction request, more on that can be found in the [API reference](DOCS_API_URL/types/_fuel_ts_account.TransactionCost.html). ### Manually Fetching Resources diff --git a/apps/docs/src/guide/types/address.md b/apps/docs/src/guide/types/address.md index d295ec41cd3..4eda6b64591 100644 --- a/apps/docs/src/guide/types/address.md +++ b/apps/docs/src/guide/types/address.md @@ -1,38 +1,38 @@ # 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`](DOCS_API_URL/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](DOCS_API_URL/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`](DOCS_API_URL/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. <<< @/../../../packages/address/src/address.ts#address-2{ts:line-numbers} ## Creating an Address -There are several ways to create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) instance: +There are several ways to create an [`Address`](DOCS_API_URL/classes/_fuel_ts_address.Address.html) instance: ### From a b256 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: +To create an [`Address`](DOCS_API_URL/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} ### 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: +To create an [`Address`](DOCS_API_URL/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} ## Utility Functions -The [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class also provides some practical utility functions: +The [`Address`](DOCS_API_URL/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 `B256` address: +1. `fromString`: Create a new [`Address`](DOCS_API_URL/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} -2. `fromDynamicInput`: Create a new [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) when the address source is unknown: +2. `fromDynamicInput`: Create a new [`Address`](DOCS_API_URL/classes/_fuel_ts_address.Address.html) when the address source is unknown: <<< @./snippets/address/utilities-function-2.ts#full{ts:line-numbers} diff --git a/apps/docs/src/guide/types/bits256.md b/apps/docs/src/guide/types/bits256.md index 5cc9d26c021..192304c1701 100644 --- a/apps/docs/src/guide/types/bits256.md +++ b/apps/docs/src/guide/types/bits256.md @@ -16,6 +16,6 @@ To convert between a `b256` hexlified string and a `Uint8Array`, you can use the ## 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: +A `b256` value is also supported as part of the [`Address`](DOCS_API_URL/classes/_fuel_ts_address.Address.html) class, providing seamless integration with other components of your application. To create an [`Address`](DOCS_API_URL/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/utilities/address-conversion.md b/apps/docs/src/guide/utilities/address-conversion.md index dbb8d82bfd6..653b0baee2e 100644 --- a/apps/docs/src/guide/utilities/address-conversion.md +++ b/apps/docs/src/guide/utilities/address-conversion.md @@ -25,18 +25,18 @@ This guide demonstrates how to convert between address formats and Sway Standard ## Converting a Contract ID -The Contract `id` property is an instance of the [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class. 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`: +The Contract `id` property is an instance of the [`Address`](DOCS_API_URL/classes/_fuel_ts_address.Address.html) class. Therefore, it can be converted using the [`Address`](DOCS_API_URL/classes/_fuel_ts_address.Address.html) class functions such as `toAddress` and `toB256`: <<< @./snippets/address-conversion/contract.ts#conversion-2{ts:line-numbers} ## Converting a Wallet Address -Similarly, the Wallet `address` property is also of type [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) and can therefore use the same [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) class functions for conversion: +Similarly, the Wallet `address` property is also of type [`Address`](DOCS_API_URL/classes/_fuel_ts_address.Address.html) and can therefore use the same [`Address`](DOCS_API_URL/classes/_fuel_ts_address.Address.html) class functions for conversion: <<< @./snippets/address-conversion/wallet.ts#conversion-3{ts:line-numbers} ## 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/bits256.md) value. The following example shows how to create an [`Address`](DOCS_API_URL/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/src/guide/utilities/using-assets.md b/apps/docs/src/guide/utilities/using-assets.md index 88728f3b51b..47a147f0a89 100644 --- a/apps/docs/src/guide/utilities/using-assets.md +++ b/apps/docs/src/guide/utilities/using-assets.md @@ -1,6 +1,6 @@ # Assets -We export an array of [`Asset`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.Asset.html) objects, that can be useful when creating your dApp. The `Asset` object has useful metadata about the different assets that are available on blockchain networks (Fuel and Ethereum). +We export an array of [`Asset`](DOCS_API_URL/types/_fuel_ts_account.Asset.html) objects, that can be useful when creating your dApp. The `Asset` object has useful metadata about the different assets that are available on blockchain networks (Fuel and Ethereum). Included assets such as: @@ -9,6 +9,6 @@ Included assets such as: - USD Coin (USDC) - Wrapped ETH (WETH) -The helper functions `getAssetFuel` and `getAssetEth` can be used to get an asset's details relative to each network. These return a combination of the asset, and network information (the return types are [`AssetFuel`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.AssetFuel.html) and [`AssetEth`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.AssetEth.html) respectively). +The helper functions `getAssetFuel` and `getAssetEth` can be used to get an asset's details relative to each network. These return a combination of the asset, and network information (the return types are [`AssetFuel`](DOCS_API_URL/types/_fuel_ts_account.AssetFuel.html) and [`AssetEth`](DOCS_API_URL/types/_fuel_ts_account.AssetEth.html) respectively). <<< @./snippets/using-assets.ts#using-assets-1{ts:line-numbers} diff --git a/apps/docs/src/guide/wallets/checking-balances.md b/apps/docs/src/guide/wallets/checking-balances.md index 6c9450dbdf7..2b95f1d6bbb 100644 --- a/apps/docs/src/guide/wallets/checking-balances.md +++ b/apps/docs/src/guide/wallets/checking-balances.md @@ -1,9 +1,9 @@ # Checking balances -To check the balance of a specific asset, you can use [`getBalance`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Account.html#getBalance) method. This function aggregates the amounts of all unspent coins of the given asset in your wallet. +To check the balance of a specific asset, you can use [`getBalance`](DOCS_API_URL/classes/_fuel_ts_account.Account.html#getBalance) method. This function aggregates the amounts of all unspent coins of the given asset in your wallet. <<< @./snippets/checking-balances.ts#checking-balances-1{ts:line-numbers} -To retrieve the balances of all assets in your wallet, use the [`getBalances`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Account.html#getBalances) method, it returns an array of [`CoinQuantity`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.CoinQuantity.html). This is useful for getting a comprehensive view of your holdings. +To retrieve the balances of all assets in your wallet, use the [`getBalances`](DOCS_API_URL/classes/_fuel_ts_account.Account.html#getBalances) method, it returns an array of [`CoinQuantity`](DOCS_API_URL/types/_fuel_ts_account.CoinQuantity.html). This is useful for getting a comprehensive view of your holdings. <<< @./snippets/checking-balances-two.ts#checking-balances-2{ts:line-numbers} diff --git a/apps/docs/src/guide/wallets/connectors.md b/apps/docs/src/guide/wallets/connectors.md index 5b771d08e9a..68dc1e029c4 100644 --- a/apps/docs/src/guide/wallets/connectors.md +++ b/apps/docs/src/guide/wallets/connectors.md @@ -6,7 +6,7 @@ Fuel Wallet Connectors offer a standardized interface to integrate multiple wall `Fuel Connectors` are a set of standardized interfaces that provide a way to interact with various wallets and services. They offer a consistent way to interact with different wallets and services, allowing developers to focus on building their applications rather than worrying about wallet integration. -To build your own wallet integration, you can create a custom connector that extends the abstract [`FuelConnector`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.FuelConnector.html) class. This interface provides a set of methods and events that allow you to interact with the wallet and handle various operations such as connecting, disconnecting, signing messages, and sending transactions. +To build your own wallet integration, you can create a custom connector that extends the abstract [`FuelConnector`](DOCS_API_URL/classes/_fuel_ts_account.FuelConnector.html) class. This interface provides a set of methods and events that allow you to interact with the wallet and handle various operations such as connecting, disconnecting, signing messages, and sending transactions. <<< @./snippets/connectors.ts#fuel-connector-extends{ts:line-numbers} @@ -67,13 +67,13 @@ The `accounts` event is emitted every time a connector's accounts change. The ev #### `connectors` -The `connectors` event is emitted when the connectors are initialized. The event data is an array of [`FuelConnector`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.FuelConnector.html) objects available on the network. +The `connectors` event is emitted when the connectors are initialized. The event data is an array of [`FuelConnector`](DOCS_API_URL/classes/_fuel_ts_account.FuelConnector.html) objects available on the network. <<< @./snippets/connectors.ts#fuel-connector-events-connectors{ts:line-numbers} #### `currentConnector` -The `currentConnector` event is emitted every time the current connector changes. The event data is a [`FuelConnector`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.FuelConnector.html) object that is currently connected. +The `currentConnector` event is emitted every time the current connector changes. The event data is a [`FuelConnector`](DOCS_API_URL/classes/_fuel_ts_account.FuelConnector.html) object that is currently connected. <<< @./snippets/connectors.ts#fuel-connector-events-currentConnector{ts:line-numbers} @@ -91,25 +91,25 @@ The `connection` event is emitted every time the connection status changes. The #### `networks` -The `networks` event is emitted every time the network changes. The event data will be a [`Network`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.Network.html) object containing the current network information. +The `networks` event is emitted every time the network changes. The event data will be a [`Network`](DOCS_API_URL/types/_fuel_ts_account.Network.html) object containing the current network information. <<< @./snippets/connectors.ts#fuel-connector-events-networks{ts:line-numbers} #### `currentNetwork` -The `currentNetwork` event is emitted every time the current network changes. The event data will be a [`Network`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.Network.html) object containing the current network information. +The `currentNetwork` event is emitted every time the current network changes. The event data will be a [`Network`](DOCS_API_URL/types/_fuel_ts_account.Network.html) object containing the current network information. <<< @./snippets/connectors.ts#fuel-connector-events-currentNetwork{ts:line-numbers} #### `assets` -The `assets` event is emitted every time the assets change. The event data will be an array of [`Asset`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.Asset.html) objects available on the network. +The `assets` event is emitted every time the assets change. The event data will be an array of [`Asset`](DOCS_API_URL/types/_fuel_ts_account.Asset.html) objects available on the network. <<< @./snippets/connectors.ts#fuel-connector-events-assets{ts:line-numbers} #### `abis` -The `abis` event is emitted every time an ABI is added to a connector. The event data will be an array of [`FuelABI`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.FuelABI.html) object. +The `abis` event is emitted every time an ABI is added to a connector. The event data will be an array of [`FuelABI`](DOCS_API_URL/types/_fuel_ts_account.FuelABI.html) object. <<< @./snippets/connectors.ts#fuel-connector-events-assets{ts:line-numbers} @@ -197,7 +197,7 @@ The `signTransaction` method initiates the send transaction flow for the current It requires two arguments: - `address` (`string`) -- `transaction` ([`TransactionRequestLike`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.TransactionRequestLike.html)) +- `transaction` ([`TransactionRequestLike`](DOCS_API_URL/types/_fuel_ts_account.TransactionRequestLike.html)) It will return the transaction signature (as a `string`) if it is successfully signed. @@ -207,7 +207,7 @@ It will return the transaction signature (as a `string`) if it is successfully s The `assets` method returns a list of all the assets available for the current connection. -It will return a promise that will resolve to an array of assets (see [`Asset`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.Asset.html)) that are available on the network. +It will return a promise that will resolve to an array of assets (see [`Asset`](DOCS_API_URL/types/_fuel_ts_account.Asset.html)) that are available on the network. <<< @/../../../packages/account/src/connectors/fuel-connector.ts#fuel-connector-method-assets{ts:line-numbers} @@ -217,7 +217,7 @@ The `addAsset` method adds asset metadata to the connector. It requires a single argument: -- `asset` ([`Asset`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.Asset.html)) +- `asset` ([`Asset`](DOCS_API_URL/types/_fuel_ts_account.Asset.html)) It returns a promise that resolves to `true` if the asset is successfully added; otherwise, it resolves to `false`. @@ -229,7 +229,7 @@ The `addAssets` method adds multiple asset metadata to the connector. It requires a single argument: -- `assets` (an Array of [`Asset`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.Asset.html)). +- `assets` (an Array of [`Asset`](DOCS_API_URL/types/_fuel_ts_account.Asset.html)). Returns a promise that resolves to `true` if the assets are successfully added; otherwise, resolves to `false`. @@ -253,7 +253,7 @@ It should throw an error if the network is not available or the network already The `networks` method returns a list of all the networks available for the current connection. -Returns a promise that resolves to an array of available networks (see [`Network`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.Network.html)). +Returns a promise that resolves to an array of available networks (see [`Network`](DOCS_API_URL/types/_fuel_ts_account.Network.html)). <<< @/../../../packages/account/src/connectors/fuel-connector.ts#fuel-connector-method-networks{ts:line-numbers} @@ -261,7 +261,7 @@ Returns a promise that resolves to an array of available networks (see [`Network The `currentNetwork` method will return the current network that is connected. -It will return a promise that will resolve to the current network (see [`Network`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.Network.html)). +It will return a promise that will resolve to the current network (see [`Network`](DOCS_API_URL/types/_fuel_ts_account.Network.html)). <<< @/../../../packages/account/src/connectors/fuel-connector.ts#fuel-connector-method-currentNetwork{ts:line-numbers} @@ -271,7 +271,7 @@ The `selectNetwork` method requests the user to select a network for the current It requires a single argument: -- `network` ([`Network`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.Network.html)) +- `network` ([`Network`](DOCS_API_URL/types/_fuel_ts_account.Network.html)) You call this method with either the `providerUrl` or `chainId` to select the network. @@ -288,7 +288,7 @@ The `addABI` method adds ABI information about a contract to the connector. This It requires two arguments: - `contractId` (`string`) -- `abi` ([`FuelABI`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.FuelABI.html)). +- `abi` ([`FuelABI`](DOCS_API_URL/types/_fuel_ts_account.FuelABI.html)). It will return a promise that will resolve to `true` if the ABI is successfully added; otherwise `false`. @@ -302,7 +302,7 @@ It requires a single argument: - `contractId` (`string`) -Returns a promise that resolves to the ABI information (as a [`FuelABI`](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_account.FuelABI.html)) or `null` if the data is unavailable. +Returns a promise that resolves to the ABI information (as a [`FuelABI`](DOCS_API_URL/types/_fuel_ts_account.FuelABI.html)) or `null` if the data is unavailable. <<< @/../../../packages/account/src/connectors/fuel-connector.ts#fuel-connector-method-getABI{ts:line-numbers} diff --git a/apps/docs/src/guide/wallets/encrypting-and-decrypting.md b/apps/docs/src/guide/wallets/encrypting-and-decrypting.md index 22ee86d28a7..118a97db5f8 100644 --- a/apps/docs/src/guide/wallets/encrypting-and-decrypting.md +++ b/apps/docs/src/guide/wallets/encrypting-and-decrypting.md @@ -4,23 +4,23 @@ JSON wallets are a standardized way of storing wallets securely. They follow a s ## Encrypting a Wallet -We will be calling `encrypt` from the [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html) instance which will take a password as the argument. It will encrypt the private key using a cipher and returns the JSON keystore wallet. You can then securely store this JSON wallet. +We will be calling `encrypt` from the [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html) instance which will take a password as the argument. It will encrypt the private key using a cipher and returns the JSON keystore wallet. You can then securely store this JSON wallet. Here is an example of how you can accomplish this: <<< @./snippets/encrypting-and-decrypting-wallets.ts#encrypting-and-decrypting-json-wallets-1{ts:line-numbers} -Please note that `encrypt` must be called within an instance of [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html). This instance can only be achieved through passing a private key or mnemonic phrase to a locked wallet. +Please note that `encrypt` must be called within an instance of [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html). This instance can only be achieved through passing a private key or mnemonic phrase to a locked wallet. ## Decrypting a Wallet -To decrypt the JSON wallet and retrieve your private key, you can call `fromEncryptedJson` on a [Wallet](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Wallet.html) instance. It takes the encrypted JSON wallet and the password as its arguments, and returns the decrypted wallet. +To decrypt the JSON wallet and retrieve your private key, you can call `fromEncryptedJson` on a [Wallet](DOCS_API_URL/classes/_fuel_ts_account.Wallet.html) instance. It takes the encrypted JSON wallet and the password as its arguments, and returns the decrypted wallet. Here is an example: <<< @./snippets/encrypting-and-decrypting-json-wallets-two.ts#encrypting-and-decrypting-json-wallets-2{ts:line-numbers} -In this example, `decryptedWallet` is an instance of [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html) class, now available for use. +In this example, `decryptedWallet` is an instance of [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html) class, now available for use. ## Important diff --git a/apps/docs/src/guide/wallets/index.md b/apps/docs/src/guide/wallets/index.md index ac11239aea0..81801083543 100644 --- a/apps/docs/src/guide/wallets/index.md +++ b/apps/docs/src/guide/wallets/index.md @@ -11,13 +11,13 @@ Wallets can be used for many important things, for instance: The SDK has multiple classes related to a Wallet instance: -- [Wallet](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Wallet.html): Works simply like a wrapper providing methods to create and instantiating `WalletUnlocked` and `WalletLocked` instances. +- [Wallet](DOCS_API_URL/classes/_fuel_ts_account.Wallet.html): Works simply like a wrapper providing methods to create and instantiating `WalletUnlocked` and `WalletLocked` instances. -- [WalletLocked](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletLocked.html): Provides the functionalities for a locked wallet. +- [WalletLocked](DOCS_API_URL/classes/_fuel_ts_account.WalletLocked.html): Provides the functionalities for a locked wallet. -- [WalletUnlocked](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html): Provides the functionalities for an unlocked wallet. +- [WalletUnlocked](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html): Provides the functionalities for an unlocked wallet. -- [Account](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Account.html): Provides an abstraction with basic functionalities for wallets or accounts to interact with the network. It is essential to notice that both `WalletLocked` and `WalletUnlocked` extend from the `Account` class. +- [Account](DOCS_API_URL/classes/_fuel_ts_account.Account.html): Provides an abstraction with basic functionalities for wallets or accounts to interact with the network. It is essential to notice that both `WalletLocked` and `WalletUnlocked` extend from the `Account` class. Let's explore these different approaches in the following sub-chapters. diff --git a/apps/docs/src/guide/wallets/instantiating-wallets.md b/apps/docs/src/guide/wallets/instantiating-wallets.md index b7a501ee524..330d295b8ed 100644 --- a/apps/docs/src/guide/wallets/instantiating-wallets.md +++ b/apps/docs/src/guide/wallets/instantiating-wallets.md @@ -4,13 +4,13 @@ Wallets can be instantiated in multiple ways within the SDK. ## Generating new wallets -To generate a new, unlocked wallet, use the [`generate`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Wallet.html#generate) method. This method creates a new [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html) instance, which is immediately ready for use. +To generate a new, unlocked wallet, use the [`generate`](DOCS_API_URL/classes/_fuel_ts_account.Wallet.html#generate) method. This method creates a new [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html) instance, which is immediately ready for use. <<< @./snippets/instantiating/generate.ts#instantiating-wallets-1{ts:line-numbers} ## Instantiating Unlocked Wallets -Creating [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html) instances of your existing wallets is easy and can be done in several ways: +Creating [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html) instances of your existing wallets is easy and can be done in several ways: From a private key: @@ -38,13 +38,13 @@ It's possible to instantiate a `WalletUnlocked` from a `WalletLocked`: ## Instantiating Locked Wallets -You can also instantiate [`WalletLocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletLocked.html) instances using just the wallet address: +You can also instantiate [`WalletLocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletLocked.html) instances using just the wallet address: <<< @./snippets/instantiating/from-b256-address.ts#instantiating-wallets-8{ts:line-numbers} ## Connecting to a Provider -While wallets can be used independently of a [`Provider`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Provider.html), operations requiring blockchain interaction will need one. +While wallets can be used independently of a [`Provider`](DOCS_API_URL/classes/_fuel_ts_account.Provider.html), operations requiring blockchain interaction will need one. Connecting an existing wallet to a Provider: diff --git a/apps/docs/src/guide/wallets/locking-and-unlocking.md b/apps/docs/src/guide/wallets/locking-and-unlocking.md index 592784e3942..e4c3806d7a5 100644 --- a/apps/docs/src/guide/wallets/locking-and-unlocking.md +++ b/apps/docs/src/guide/wallets/locking-and-unlocking.md @@ -1,25 +1,25 @@ # Locking and Unlocking -The kinds of operations we can perform with a [`Wallet`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Wallet.html) instance depend on +The kinds of operations we can perform with a [`Wallet`](DOCS_API_URL/classes/_fuel_ts_account.Wallet.html) instance depend on whether or not we have access to the wallet's private key. -In order to differentiate between [`Wallet`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.Wallet.html) instances that know their private key -and those that do not, we use the [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html) and [`WalletLocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletLocked.html) types +In order to differentiate between [`Wallet`](DOCS_API_URL/classes/_fuel_ts_account.Wallet.html) instances that know their private key +and those that do not, we use the [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html) and [`WalletLocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletLocked.html) types respectively. ## Wallet States -The [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html) type represents a wallet whose private key is known and -stored internally in memory. A wallet must be of type [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html) in order +The [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html) type represents a wallet whose private key is known and +stored internally in memory. A wallet must be of type [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html) in order to perform operations that involve [signing messages or transactions](./signing.md). -The [`WalletLocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletLocked.html) type represents a wallet whose private key is _not_ known or stored -in memory. Instead, [`WalletLocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletLocked.html) only knows its public address. A [`WalletLocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletLocked.html) cannot be +The [`WalletLocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletLocked.html) type represents a wallet whose private key is _not_ known or stored +in memory. Instead, [`WalletLocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletLocked.html) only knows its public address. A [`WalletLocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletLocked.html) cannot be used to sign transactions, however it may still perform a whole suite of useful operations including listing transactions, assets, querying balances, and so on. -Note that the [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html) type implements most methods available on the [`WalletLocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletLocked.html) -type. In other words, [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html) can be thought of as a thin wrapper around [`WalletLocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletLocked.html) that +Note that the [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html) type implements most methods available on the [`WalletLocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletLocked.html) +type. In other words, [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html) can be thought of as a thin wrapper around [`WalletLocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletLocked.html) that provides greater access via its private key. ## Basic Example @@ -34,16 +34,16 @@ You can choose not to pass through a provider argument on `Wallet` construction: ## Transitioning States -A [`WalletLocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletLocked.html) instance can be unlocked by providing the private key: +A [`WalletLocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletLocked.html) instance can be unlocked by providing the private key: <<< @./snippets/locked-to-unlocked.ts#wallet-locked-to-unlocked{ts:line-numbers} -A [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html) instance can be locked using the `lock` method: +A [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html) instance can be locked using the `lock` method: <<< @./snippets/unlocked-to-locked.ts#wallet-unlocked-to-locked{ts:line-numbers} Most wallet constructors that create or generate a new wallet are provided on -the [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html) type. Consider locking the wallet with the `lock` method after the new private +the [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html) 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. @@ -51,7 +51,7 @@ key is stored in memory. When designing APIs that accept a wallet as an input, we should think carefully about the kind of access that we require. API developers should aim to minimise -their usage of [`WalletUnlocked`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_account.WalletUnlocked.html) in order to ensure private keys are stored in +their usage of [`WalletUnlocked`](DOCS_API_URL/classes/_fuel_ts_account.WalletUnlocked.html) in order to ensure private keys are stored in memory no longer than necessary to reduce the surface area for attacks and vulnerabilities in downstream libraries and applications. diff --git a/apps/docs/src/index.md b/apps/docs/src/index.md index baf08f9e267..a8331ed8c57 100644 --- a/apps/docs/src/index.md +++ b/apps/docs/src/index.md @@ -23,4 +23,4 @@ This documentation was generated using Fuels `v{{fuels}}`, Fuel Core `v{{fuelCor ## API Documentation -The Complete API documentation for the SDK is available [here](https://fuels-ts-docs-api.vercel.app/). +The Complete API documentation for the SDK is available [here](DOCS_API_URL/). From c0741681a537b33719fc32fa077332b4acf2f1a0 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Fri, 17 Jan 2025 08:45:59 +0100 Subject: [PATCH 02/21] made vitepress docs work --- apps/docs/.env.development | 1 + apps/docs/.env.production | 1 + apps/docs/.vitepress/config.ts | 1136 ++++++++++++++++---------------- apps/docs/package.json | 11 +- 4 files changed, 581 insertions(+), 568 deletions(-) create mode 100644 apps/docs/.env.development create mode 100644 apps/docs/.env.production diff --git a/apps/docs/.env.development b/apps/docs/.env.development new file mode 100644 index 00000000000..e0c814a27fe --- /dev/null +++ b/apps/docs/.env.development @@ -0,0 +1 @@ +VITE_DOCS_API_URL=http://localhost:5174 \ No newline at end of file diff --git a/apps/docs/.env.production b/apps/docs/.env.production new file mode 100644 index 00000000000..916b7598738 --- /dev/null +++ b/apps/docs/.env.production @@ -0,0 +1 @@ +VITE_DOCS_API_URL=http://localhost:4173/api \ No newline at end of file diff --git a/apps/docs/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index 3ec8a73afd3..1bf543290d4 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -1,570 +1,578 @@ -import { defineConfig } from 'vitepress'; +import { defineConfig, loadEnv } from 'vitepress'; import { codeInContextPlugin } from './plugins/codeInContextPlugin'; import { snippetPlugin } from './plugins/snippetPlugin'; -export default defineConfig({ - title: 'Fuels-ts', - description: 'Fuel Typescript SDK', - srcDir: 'src', - outDir: 'dist', - lang: 'en-US', - appearance: 'dark', - markdown: { - config: (md) => { - md.use(snippetPlugin); - md.use(codeInContextPlugin); - md.block.ruler.disable('snippet'); - }, - }, - head: [ - ['link', { rel: 'icon', href: '/fuels-ts/favicon.ico', type: 'image/png' }], - ['meta', { property: 'og:type', content: 'website' }], - ['meta', { property: 'og:url', content: 'https://fuellabs.github.io/fuels-ts/' }], - ], - themeConfig: { - logo: 'fuel-logo.png', - nav: [ - { - text: 'Home', - link: '/', +// @ts-expect-error type not available +export default ({ mode }) => + defineConfig({ + title: 'Fuels-ts', + description: 'Fuel Typescript SDK', + srcDir: 'src', + outDir: 'dist', + lang: 'en-US', + appearance: 'dark', + markdown: { + config: (md) => { + md.use(snippetPlugin); + md.use(codeInContextPlugin); + md.block.ruler.disable('snippet'); + md.core.ruler.before('normalize', 'replace-magic-string', (state) => { + const env = loadEnv(mode, process.cwd()); + // Replace the magic string in the Markdown content + state.src = state.src.replace(/DOCS_API_URL/g, env.VITE_DOCS_API_URL); + }); }, - ], - socialLinks: [ - { icon: 'github', link: 'https://github.com/FuelLabs/fuels-ts' }, - { icon: 'twitter', link: 'https://twitter.com/fuel_network' }, - { icon: 'discord', link: 'https://discord.com/invite/xfpK4Pe' }, - ], - editLink: { - pattern: 'https://github.com/fuellabs/fuels-ts/edit/master/apps/docs/src/:path', - text: 'Edit this page on GitHub', }, - sidebar: [ - { - items: [ - { - text: 'Getting Started', - link: '/guide/getting-started/', - collapsed: true, - items: [ - { - text: 'Installation', - link: '/guide/getting-started/installation', - }, - { - text: 'Connecting to the Network', - link: '/guide/getting-started/connecting-to-the-network', - }, - { - text: 'Running a local Fuel node', - link: '/guide/getting-started/running-a-local-fuel-node', - }, - { - text: 'React Example', - link: '/guide/getting-started/react-example', - }, - { - text: 'CDN Usage', - link: '/guide/getting-started/cdn-usage', - }, - { - text: 'Next Steps', - link: '/guide/getting-started/next-steps', - }, - ], - }, - { - text: 'The UTXO Model', - link: '/guide/the-utxo-model/', - collapsed: false, - items: [], - }, - { - text: 'Creating a Fuel dApp', - link: '/guide/creating-a-fuel-dapp/', - collapsed: true, - items: [ - { - text: 'Options', - link: '/guide/creating-a-fuel-dapp/options', - }, - { - text: 'Deploying a dApp to Testnet', - link: '/guide/creating-a-fuel-dapp/deploying-a-dapp-to-testnet', - }, - { - text: 'Working with Predicates', - link: '/guide/creating-a-fuel-dapp/working-with-predicates', - }, - ], - }, - { - text: 'fuels CLI', - link: '/guide/fuels-cli/', - collapsed: true, - items: [ - { - text: 'Config File', - link: '/guide/fuels-cli/config-file', - }, - { - text: 'Commands', - link: '/guide/fuels-cli/commands', - }, - { - text: 'ABI Typegen', - link: '/guide/fuels-cli/abi-typegen', - }, - { - text: 'Generating Types', - link: '/guide/fuels-cli/generating-types', - }, - { - text: 'Using Generated Types', - link: '/guide/fuels-cli/using-generated-types', - }, - ], - }, - { - text: 'Provider', - link: '/guide/provider/', - collapsed: true, - items: [ - { - text: 'Provider Options', - link: '/guide/provider/provider-options', - }, - { - text: 'Pagination', - link: '/guide/provider/pagination', - }, - { - text: 'Querying the Chain', - link: '/guide/provider/querying-the-chain', - }, - ], - }, - { - text: 'Wallets', - link: '/guide/wallets/', - collapsed: true, - items: [ - { - text: 'Instantiating Wallets', - link: '/guide/wallets/instantiating-wallets', - }, - { - text: 'Private Keys', - link: '/guide/wallets/private-keys', - }, - { - text: 'Mnemonic Wallet', - link: '/guide/wallets/mnemonic-wallet', - }, - { - text: 'Encrypting and Decrypting', - link: '/guide/wallets/encrypting-and-decrypting', - }, - { - text: 'Checking Balances', - link: '/guide/wallets/checking-balances', - }, - { - text: 'Wallet Transferring', - link: '/guide/wallets/wallet-transferring', - }, - { - text: 'Signing', - link: '/guide/wallets/signing', - }, - { - text: 'Connectors', - link: '/guide/wallets/connectors', - }, - { - text: 'Wallet Manager', - link: '/guide/wallets/wallet-manager', - }, - { - text: 'Locking and Unlocking', - link: '/guide/wallets/locking-and-unlocking', - }, - ], - }, - { - text: 'Contracts', - link: '/guide/contracts/', - collapsed: true, - items: [ - { - text: 'Methods', - link: '/guide/contracts/methods', - }, - { - text: 'Call Parameters', - link: '/guide/contracts/call-parameters', - }, - { - text: 'Contract Balance', - link: '/guide/contracts/contract-balance', - }, - { - text: 'Cost Estimation', - link: '/guide/contracts/cost-estimation', - }, - { - text: 'Dependency Estimation', - link: '/guide/contracts/dependency-estimation', - }, - { - text: 'Variable Outputs', - link: '/guide/contracts/variable-outputs', - }, - { - text: 'Logs', - link: '/guide/contracts/logs', - }, - { - text: 'Inter-contract Calls', - link: '/guide/contracts/inter-contract-calls', - }, - { - text: 'Multi-contract calls', - link: '/guide/contracts/multi-contract-calls', - }, - { - text: 'Using different Wallets', - link: '/guide/contracts/using-different-wallets', - }, - { - text: 'Transferring Assets', - link: '/guide/contracts/transferring-assets', - }, - { - text: 'Deploying Contracts', - link: '/guide/contracts/deploying-contracts', - }, - { - text: 'Storage Slots', - link: '/guide/contracts/storage-slots', - }, - { - text: 'Configurable Constants', - link: '/guide/contracts/configurable-constants', - }, - { - text: 'Minted Token Asset ID', - link: '/guide/contracts/minted-token-asset-id', - }, - { - text: 'Managing Deployed Contracts', - link: '/guide/contracts/managing-deployed-contracts', - }, - { - text: 'Proxy Contracts', - link: '/guide/contracts/proxy-contracts', - }, - { - text: 'Understanding the FuelVM Binary File', - link: '/guide/contracts/understanding-the-fuelvm-binary-file', - }, - ], - }, - { - text: 'Scripts', - link: '/guide/scripts/', - collapsed: true, - items: [ - { - text: 'Instantiating A Script', - link: '/guide/scripts/instantiating-a-script', - }, - { - text: 'Deploying Scripts', - link: '/guide/scripts/deploying-scripts', - }, - { - text: 'Configurable Constants', - link: '/guide/scripts/configurable-constants', - }, - { - text: 'Running scripts', - link: '/guide/scripts/running-scripts', - }, - { - text: 'Custom script Call', - link: '/guide/scripts/custom-script-call', - }, - ], - }, - { - text: 'Predicates', - link: '/guide/predicates/', - collapsed: true, - items: [ - { - text: 'Instantiating A Predicate', - link: '/guide/predicates/instantiating-a-predicate', - }, - { - text: 'Deploying Predicates', - link: '/guide/predicates/deploying-predicates', - }, - { - text: 'Configurable Constants', - link: '/guide/predicates/configurable-constants', - }, - { - text: 'Send And Spend Funds From Predicates', - link: '/guide/predicates/send-and-spend-funds-from-predicates', - }, - { - text: 'Methods', - link: '/guide/predicates/methods', - }, - { - text: 'Custom Transactions', - link: '/guide/predicates/custom-transactions', - }, - ], - }, - { - text: 'Transactions', - link: '/guide/transactions/', - collapsed: true, - items: [ - { - text: 'Modifying the Request', - link: '/guide/transactions/modifying-the-request', - }, - { - text: 'Adding Parameters', - link: '/guide/transactions/adding-parameters', - }, - { - text: 'Adding Policies', - link: '/guide/transactions/adding-policies', - }, - { - text: 'Getting the Response', - link: '/guide/transactions/getting-the-response', - }, - { - text: 'Optimizing Frontend Apps', - link: '/guide/transactions/optimizing-frontend-apps', - }, - ], - }, - { - text: 'Encoding', - link: '/guide/encoding/', - collapsed: true, - items: [ - { - text: 'Encode and Decode', - link: '/guide/encoding/encode-and-decode', - }, - { - text: 'Working with Bytes', - link: '/guide/encoding/working-with-bytes', - }, - ], - }, - { - text: 'Utilities', - link: '/guide/utilities/', - collapsed: true, - items: [ - { - text: 'Date conversion', - link: '/guide/utilities/date-conversion', - }, - { - text: 'Address conversion', - link: '/guide/utilities/address-conversion', - }, - { - text: 'Unit conversion', - link: '/guide/utilities/unit-conversion', - }, - { - text: 'Using assets', - link: '/guide/utilities/using-assets', - }, - ], - }, - { - text: 'Cookbook', - link: '/guide/cookbook/', - collapsed: true, - items: [ - { - text: 'Deposit And Withdraw', - link: '/guide/cookbook/deposit-and-withdraw', - }, - { - text: 'Wallet SDK and React Hooks', - link: '/guide/cookbook/wallet-sdk-and-react-hooks', - }, - { - text: 'Custom Transactions', - link: '/guide/cookbook/custom-transactions', - }, - { - text: 'Custom Transactions from Contract Calls', - link: '/guide/cookbook/custom-transactions-from-contract-calls', - }, - { - text: 'Generate Fake Resources', - link: '/guide/cookbook/generate-fake-resources', - }, - { - text: 'Transactions with Multiple Signers', - link: '/guide/cookbook/transactions-with-multiple-signers', - }, - { - text: 'GraphQL Integration', - link: '/guide/cookbook/graphql-integration', - }, - { - text: 'Resubmitting Failed Transactions', - link: '/guide/cookbook/resubmitting-failed-transactions', - }, - { - text: 'Combining UTXOs', - link: '/guide/cookbook/combining-utxos', - }, - { - text: 'Splitting UTXOs', - link: '/guide/cookbook/splitting-utxos', - }, - { - text: 'Optimized React Example', - link: '/guide/cookbook/optimized-react-example', - }, - ], - }, - { - text: 'Testing', - link: '/guide/testing/', - collapsed: true, - items: [ - { - text: 'Launching a Test Node', - link: '/guide/testing/launching-a-test-node', - }, - { - text: 'Test Node Options', - link: '/guide/testing/test-node-options', - }, - { - text: 'Fuel Core Options', - link: '/guide/testing/fuel-core-options', - }, - { - text: 'Basic Example', - link: '/guide/testing/basic-example', - }, - { - text: 'Advanced Example', - link: '/guide/testing/advanced-example', - }, - { - text: 'Custom Blocks', - link: '/guide/testing/custom-blocks', - }, - { - text: 'Setting up test wallets', - link: '/guide/testing/setting-up-test-wallets', - }, - ], - }, - { - text: 'Types', - link: '/guide/types/', - collapsed: true, - items: [ - { - text: 'Address', - link: '/guide/types/address', - }, - { - text: 'Arrays', - link: '/guide/types/arrays', - }, - { - text: 'Asset Id', - link: '/guide/types/asset-id', - }, - { - text: 'Bits256', - link: '/guide/types/bits256', - }, - { - text: 'Bits512', - link: '/guide/types/bits512', - }, - { - text: 'Bytes', - link: '/guide/types/bytes', - }, - { - text: 'Bytes32', - link: '/guide/types/bytes32', - }, - { - text: 'Enums', - link: '/guide/types/enums', - }, - { - text: 'Evm Address', - link: '/guide/types/evm-address', - }, - { - text: 'Native Parameters', - link: '/guide/types/native-parameters', - }, - { - text: 'Numbers', - link: '/guide/types/numbers', - }, - { - text: 'Options', - link: '/guide/types/options', - }, - { - text: 'Raw Slice', - link: '/guide/types/raw-slice', - }, - { - text: 'Std String', - link: '/guide/types/std-string', - }, - { - text: 'String', - link: '/guide/types/string', - }, - { - text: 'Structs', - link: '/guide/types/structs', - }, - { - text: 'Tuples', - link: '/guide/types/tuples', - }, - { - text: 'Vectors', - link: '/guide/types/vectors', - }, - ], - }, - { - text: 'Errors', - link: '/guide/errors/', - collapsed: false, - items: [], - }, - ], - }, + ignoreDeadLinks: true, + head: [ + ['link', { rel: 'icon', href: '/fuels-ts/favicon.ico', type: 'image/png' }], + ['meta', { property: 'og:type', content: 'website' }], + ['meta', { property: 'og:url', content: 'https://fuellabs.github.io/fuels-ts/' }], ], - }, -}); + themeConfig: { + logo: 'fuel-logo.png', + nav: [ + { + text: 'Home', + link: '/', + }, + ], + socialLinks: [ + { icon: 'github', link: 'https://github.com/FuelLabs/fuels-ts' }, + { icon: 'twitter', link: 'https://twitter.com/fuel_network' }, + { icon: 'discord', link: 'https://discord.com/invite/xfpK4Pe' }, + ], + editLink: { + pattern: 'https://github.com/fuellabs/fuels-ts/edit/master/apps/docs/src/:path', + text: 'Edit this page on GitHub', + }, + sidebar: [ + { + items: [ + { + text: 'Getting Started', + link: '/guide/getting-started/', + collapsed: true, + items: [ + { + text: 'Installation', + link: '/guide/getting-started/installation', + }, + { + text: 'Connecting to the Network', + link: '/guide/getting-started/connecting-to-the-network', + }, + { + text: 'Running a local Fuel node', + link: '/guide/getting-started/running-a-local-fuel-node', + }, + { + text: 'React Example', + link: '/guide/getting-started/react-example', + }, + { + text: 'CDN Usage', + link: '/guide/getting-started/cdn-usage', + }, + { + text: 'Next Steps', + link: '/guide/getting-started/next-steps', + }, + ], + }, + { + text: 'The UTXO Model', + link: '/guide/the-utxo-model/', + collapsed: false, + items: [], + }, + { + text: 'Creating a Fuel dApp', + link: '/guide/creating-a-fuel-dapp/', + collapsed: true, + items: [ + { + text: 'Options', + link: '/guide/creating-a-fuel-dapp/options', + }, + { + text: 'Deploying a dApp to Testnet', + link: '/guide/creating-a-fuel-dapp/deploying-a-dapp-to-testnet', + }, + { + text: 'Working with Predicates', + link: '/guide/creating-a-fuel-dapp/working-with-predicates', + }, + ], + }, + { + text: 'fuels CLI', + link: '/guide/fuels-cli/', + collapsed: true, + items: [ + { + text: 'Config File', + link: '/guide/fuels-cli/config-file', + }, + { + text: 'Commands', + link: '/guide/fuels-cli/commands', + }, + { + text: 'ABI Typegen', + link: '/guide/fuels-cli/abi-typegen', + }, + { + text: 'Generating Types', + link: '/guide/fuels-cli/generating-types', + }, + { + text: 'Using Generated Types', + link: '/guide/fuels-cli/using-generated-types', + }, + ], + }, + { + text: 'Provider', + link: '/guide/provider/', + collapsed: true, + items: [ + { + text: 'Provider Options', + link: '/guide/provider/provider-options', + }, + { + text: 'Pagination', + link: '/guide/provider/pagination', + }, + { + text: 'Querying the Chain', + link: '/guide/provider/querying-the-chain', + }, + ], + }, + { + text: 'Wallets', + link: '/guide/wallets/', + collapsed: true, + items: [ + { + text: 'Instantiating Wallets', + link: '/guide/wallets/instantiating-wallets', + }, + { + text: 'Private Keys', + link: '/guide/wallets/private-keys', + }, + { + text: 'Mnemonic Wallet', + link: '/guide/wallets/mnemonic-wallet', + }, + { + text: 'Encrypting and Decrypting', + link: '/guide/wallets/encrypting-and-decrypting', + }, + { + text: 'Checking Balances', + link: '/guide/wallets/checking-balances', + }, + { + text: 'Wallet Transferring', + link: '/guide/wallets/wallet-transferring', + }, + { + text: 'Signing', + link: '/guide/wallets/signing', + }, + { + text: 'Connectors', + link: '/guide/wallets/connectors', + }, + { + text: 'Wallet Manager', + link: '/guide/wallets/wallet-manager', + }, + { + text: 'Locking and Unlocking', + link: '/guide/wallets/locking-and-unlocking', + }, + ], + }, + { + text: 'Contracts', + link: '/guide/contracts/', + collapsed: true, + items: [ + { + text: 'Methods', + link: '/guide/contracts/methods', + }, + { + text: 'Call Parameters', + link: '/guide/contracts/call-parameters', + }, + { + text: 'Contract Balance', + link: '/guide/contracts/contract-balance', + }, + { + text: 'Cost Estimation', + link: '/guide/contracts/cost-estimation', + }, + { + text: 'Dependency Estimation', + link: '/guide/contracts/dependency-estimation', + }, + { + text: 'Variable Outputs', + link: '/guide/contracts/variable-outputs', + }, + { + text: 'Logs', + link: '/guide/contracts/logs', + }, + { + text: 'Inter-contract Calls', + link: '/guide/contracts/inter-contract-calls', + }, + { + text: 'Multi-contract calls', + link: '/guide/contracts/multi-contract-calls', + }, + { + text: 'Using different Wallets', + link: '/guide/contracts/using-different-wallets', + }, + { + text: 'Transferring Assets', + link: '/guide/contracts/transferring-assets', + }, + { + text: 'Deploying Contracts', + link: '/guide/contracts/deploying-contracts', + }, + { + text: 'Storage Slots', + link: '/guide/contracts/storage-slots', + }, + { + text: 'Configurable Constants', + link: '/guide/contracts/configurable-constants', + }, + { + text: 'Minted Token Asset ID', + link: '/guide/contracts/minted-token-asset-id', + }, + { + text: 'Managing Deployed Contracts', + link: '/guide/contracts/managing-deployed-contracts', + }, + { + text: 'Proxy Contracts', + link: '/guide/contracts/proxy-contracts', + }, + { + text: 'Understanding the FuelVM Binary File', + link: '/guide/contracts/understanding-the-fuelvm-binary-file', + }, + ], + }, + { + text: 'Scripts', + link: '/guide/scripts/', + collapsed: true, + items: [ + { + text: 'Instantiating A Script', + link: '/guide/scripts/instantiating-a-script', + }, + { + text: 'Deploying Scripts', + link: '/guide/scripts/deploying-scripts', + }, + { + text: 'Configurable Constants', + link: '/guide/scripts/configurable-constants', + }, + { + text: 'Running scripts', + link: '/guide/scripts/running-scripts', + }, + { + text: 'Custom script Call', + link: '/guide/scripts/custom-script-call', + }, + ], + }, + { + text: 'Predicates', + link: '/guide/predicates/', + collapsed: true, + items: [ + { + text: 'Instantiating A Predicate', + link: '/guide/predicates/instantiating-a-predicate', + }, + { + text: 'Deploying Predicates', + link: '/guide/predicates/deploying-predicates', + }, + { + text: 'Configurable Constants', + link: '/guide/predicates/configurable-constants', + }, + { + text: 'Send And Spend Funds From Predicates', + link: '/guide/predicates/send-and-spend-funds-from-predicates', + }, + { + text: 'Methods', + link: '/guide/predicates/methods', + }, + { + text: 'Custom Transactions', + link: '/guide/predicates/custom-transactions', + }, + ], + }, + { + text: 'Transactions', + link: '/guide/transactions/', + collapsed: true, + items: [ + { + text: 'Modifying the Request', + link: '/guide/transactions/modifying-the-request', + }, + { + text: 'Adding Parameters', + link: '/guide/transactions/adding-parameters', + }, + { + text: 'Adding Policies', + link: '/guide/transactions/adding-policies', + }, + { + text: 'Getting the Response', + link: '/guide/transactions/getting-the-response', + }, + { + text: 'Optimizing Frontend Apps', + link: '/guide/transactions/optimizing-frontend-apps', + }, + ], + }, + { + text: 'Encoding', + link: '/guide/encoding/', + collapsed: true, + items: [ + { + text: 'Encode and Decode', + link: '/guide/encoding/encode-and-decode', + }, + { + text: 'Working with Bytes', + link: '/guide/encoding/working-with-bytes', + }, + ], + }, + { + text: 'Utilities', + link: '/guide/utilities/', + collapsed: true, + items: [ + { + text: 'Date conversion', + link: '/guide/utilities/date-conversion', + }, + { + text: 'Address conversion', + link: '/guide/utilities/address-conversion', + }, + { + text: 'Unit conversion', + link: '/guide/utilities/unit-conversion', + }, + { + text: 'Using assets', + link: '/guide/utilities/using-assets', + }, + ], + }, + { + text: 'Cookbook', + link: '/guide/cookbook/', + collapsed: true, + items: [ + { + text: 'Deposit And Withdraw', + link: '/guide/cookbook/deposit-and-withdraw', + }, + { + text: 'Wallet SDK and React Hooks', + link: '/guide/cookbook/wallet-sdk-and-react-hooks', + }, + { + text: 'Custom Transactions', + link: '/guide/cookbook/custom-transactions', + }, + { + text: 'Custom Transactions from Contract Calls', + link: '/guide/cookbook/custom-transactions-from-contract-calls', + }, + { + text: 'Generate Fake Resources', + link: '/guide/cookbook/generate-fake-resources', + }, + { + text: 'Transactions with Multiple Signers', + link: '/guide/cookbook/transactions-with-multiple-signers', + }, + { + text: 'GraphQL Integration', + link: '/guide/cookbook/graphql-integration', + }, + { + text: 'Resubmitting Failed Transactions', + link: '/guide/cookbook/resubmitting-failed-transactions', + }, + { + text: 'Combining UTXOs', + link: '/guide/cookbook/combining-utxos', + }, + { + text: 'Splitting UTXOs', + link: '/guide/cookbook/splitting-utxos', + }, + { + text: 'Optimized React Example', + link: '/guide/cookbook/optimized-react-example', + }, + ], + }, + { + text: 'Testing', + link: '/guide/testing/', + collapsed: true, + items: [ + { + text: 'Launching a Test Node', + link: '/guide/testing/launching-a-test-node', + }, + { + text: 'Test Node Options', + link: '/guide/testing/test-node-options', + }, + { + text: 'Fuel Core Options', + link: '/guide/testing/fuel-core-options', + }, + { + text: 'Basic Example', + link: '/guide/testing/basic-example', + }, + { + text: 'Advanced Example', + link: '/guide/testing/advanced-example', + }, + { + text: 'Custom Blocks', + link: '/guide/testing/custom-blocks', + }, + { + text: 'Setting up test wallets', + link: '/guide/testing/setting-up-test-wallets', + }, + ], + }, + { + text: 'Types', + link: '/guide/types/', + collapsed: true, + items: [ + { + text: 'Address', + link: '/guide/types/address', + }, + { + text: 'Arrays', + link: '/guide/types/arrays', + }, + { + text: 'Asset Id', + link: '/guide/types/asset-id', + }, + { + text: 'Bits256', + link: '/guide/types/bits256', + }, + { + text: 'Bits512', + link: '/guide/types/bits512', + }, + { + text: 'Bytes', + link: '/guide/types/bytes', + }, + { + text: 'Bytes32', + link: '/guide/types/bytes32', + }, + { + text: 'Enums', + link: '/guide/types/enums', + }, + { + text: 'Evm Address', + link: '/guide/types/evm-address', + }, + { + text: 'Native Parameters', + link: '/guide/types/native-parameters', + }, + { + text: 'Numbers', + link: '/guide/types/numbers', + }, + { + text: 'Options', + link: '/guide/types/options', + }, + { + text: 'Raw Slice', + link: '/guide/types/raw-slice', + }, + { + text: 'Std String', + link: '/guide/types/std-string', + }, + { + text: 'String', + link: '/guide/types/string', + }, + { + text: 'Structs', + link: '/guide/types/structs', + }, + { + text: 'Tuples', + link: '/guide/types/tuples', + }, + { + text: 'Vectors', + link: '/guide/types/vectors', + }, + ], + }, + { + text: 'Errors', + link: '/guide/errors/', + collapsed: false, + items: [], + }, + ], + }, + ], + }, + }); diff --git a/apps/docs/package.json b/apps/docs/package.json index 62a7d39fb1c..f86d73363bc 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -5,14 +5,17 @@ "description": "", "type": "module", "scripts": { - "dev": "nodemon --config nodemon.config.json -x 'run-s build:snippets dev:docs'", - "build": "run-s build:snippets build:docs", - "preview": "run-s build:snippets preview:docs", + "dev": "nodemon --config nodemon.config.json -x 'run-s build:snippets build:docs-api dev:docs'", + "build": "run-s build:snippets build:docs build:docs-api", + "preview": "run-s build:snippets build:docs-api preview:docs", "test": "cd ../.. && pnpm run test:filter apps/docs", "build:snippets": "run-s wrap:snippets build:forc", "build:docs": "vitepress build", + "build:docs-api": "cd ../docs-api && pnpm build && cp -r ./src/api ../docs/dist", "preview:docs": "vitepress preview", - "dev:docs": "vitepress dev", + "preview:docs-api": "pnpm vite preview --port 5174 --outDir ../docs-api/src/api", + "dev:docs": "run-p docs:dev preview:docs-api", + "docs:dev": "vitepress dev", "wrap:snippets": "tsx ./scripts/wrap-snippets.ts", "build:forc": "pnpm fuels build --deploy", "type:check": "pnpm tsc --noEmit --project tsconfig.emit.json" From a30fa14af11a3bf3c6691eb5fede42bf02288a72 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Fri, 17 Jan 2025 12:54:37 +0100 Subject: [PATCH 03/21] working link checker local --- scripts/lint-md-links.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/lint-md-links.ts b/scripts/lint-md-links.ts index a530688d5a1..7163409b7ac 100644 --- a/scripts/lint-md-links.ts +++ b/scripts/lint-md-links.ts @@ -1,14 +1,31 @@ #!/usr/bin/env node -import { execSync } from 'child_process'; +import { exec, execSync, spawn } from 'child_process'; +import { readFileSync, writeFileSync } from 'fs'; import { globSync } from 'glob'; +import { cwd } from 'process'; const { log } = console; -(() => { +// eslint-disable-next-line no-void +void (async () => { + const docsApi = spawn(`pnpm vite preview --port 9876 --outDir apps/docs-api/src/api`, { + shell: true, + }); + + await new Promise((resolve) => { + docsApi.stdout.on('data', () => { + resolve(undefined); + }); + }); + const mdFiles = globSync('**/*.md', { ignore: ['**/node_modules/**', 'apps/demo-*/**', '.changeset/**', '**/CHANGELOG.md'], }); + mdFiles.forEach((filepath) => { + const content = readFileSync(filepath).toString(); + writeFileSync(filepath, content.replace(/DOCS_API_URL/g, 'http://localhost:9876')); + }); // TODO: Stop ignoring doc links in `link-check.config.json` // The above requires this to be merged and deployed: // - https://github.com/FuelLabs/fuels-ts/pull/3500 From bb6e88ae5de1e0a07471e146b8fc44234296a874 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Sun, 19 Jan 2025 09:13:09 +0100 Subject: [PATCH 04/21] remove dependency on env vars --- apps/docs-api/index.md | 24 ++++++++++++------------ apps/docs/.env.development | 1 - apps/docs/.env.production | 1 - apps/docs/.vitepress/config.ts | 17 +++++++++++++---- apps/docs/package.json | 5 +++-- 5 files changed, 28 insertions(+), 20 deletions(-) delete mode 100644 apps/docs/.env.development delete mode 100644 apps/docs/.env.production diff --git a/apps/docs-api/index.md b/apps/docs-api/index.md index 90f1c944220..2ce85b70768 100644 --- a/apps/docs-api/index.md +++ b/apps/docs-api/index.md @@ -12,15 +12,15 @@ # Modules -- [abi-coder](DOCS_API_URL/modules/_fuel_ts_abi_coder.html) -- [abi-typegen](DOCS_API_URL/modules/_fuel_ts_abi_typegen.html) -- [account](DOCS_API_URL/modules/_fuel_ts_account.html) -- [address](DOCS_API_URL/modules/_fuel_ts_address.html) -- [crypto](DOCS_API_URL/modules/_fuel_ts_crypto.html) -- [errors](DOCS_API_URL/modules/_fuel_ts_errors.html) -- [hasher](DOCS_API_URL/modules/_fuel_ts_hasher.html) -- [math](DOCS_API_URL/modules/_fuel_ts_math.html) -- [program](DOCS_API_URL/modules/_fuel_ts_program.html) -- [script](DOCS_API_URL/modules/_fuel_ts_script.html) -- [transactions](DOCS_API_URL/modules/_fuel_ts_transactions.html) -- [utils](DOCS_API_URL/modules/_fuel_ts_utils.html) +- [abi-coder](modules/_fuel_ts_abi_coder.html) +- [abi-typegen](modules/_fuel_ts_abi_typegen.html) +- [account](modules/_fuel_ts_account.html) +- [address](modules/_fuel_ts_address.html) +- [crypto](modules/_fuel_ts_crypto.html) +- [errors](modules/_fuel_ts_errors.html) +- [hasher](modules/_fuel_ts_hasher.html) +- [math](/odules/_fuel_ts_math.html) +- [program](modules/_fuel_ts_program.html) +- [script](modules/_fuel_ts_script.html) +- [transactions](modules/_fuel_ts_transactions.html) +- [utils](modules/_fuel_ts_utils.html) diff --git a/apps/docs/.env.development b/apps/docs/.env.development deleted file mode 100644 index e0c814a27fe..00000000000 --- a/apps/docs/.env.development +++ /dev/null @@ -1 +0,0 @@ -VITE_DOCS_API_URL=http://localhost:5174 \ No newline at end of file diff --git a/apps/docs/.env.production b/apps/docs/.env.production deleted file mode 100644 index 916b7598738..00000000000 --- a/apps/docs/.env.production +++ /dev/null @@ -1 +0,0 @@ -VITE_DOCS_API_URL=http://localhost:4173/api \ No newline at end of file diff --git a/apps/docs/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index 1bf543290d4..7bf4944afc9 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -1,4 +1,4 @@ -import { defineConfig, loadEnv } from 'vitepress'; +import { defineConfig } from 'vitepress'; import { codeInContextPlugin } from './plugins/codeInContextPlugin'; import { snippetPlugin } from './plugins/snippetPlugin'; @@ -17,12 +17,21 @@ export default ({ mode }) => md.use(codeInContextPlugin); md.block.ruler.disable('snippet'); md.core.ruler.before('normalize', 'replace-magic-string', (state) => { - const env = loadEnv(mode, process.cwd()); - // Replace the magic string in the Markdown content - state.src = state.src.replace(/DOCS_API_URL/g, env.VITE_DOCS_API_URL); + const apiUrl = mode === 'development' ? 'http://localhost:5174' : '/api'; + state.src = state.src.replace(/DOCS_API_URL/g, apiUrl); }); }, }, + transformHtml: (code) => { + // make the API links open in a new tab + // because opening in the same tab doesn't work in the preview + return code.replace( + /(]*href="\/api\/[^"]*")/g, + '$1 target="_blank" rel="noreferrer"' + ); + }, + // finds dead DOCS_API_URL links + // which get replaced later in the markdown transformer ignoreDeadLinks: true, head: [ ['link', { rel: 'icon', href: '/fuels-ts/favicon.ico', type: 'image/png' }], diff --git a/apps/docs/package.json b/apps/docs/package.json index f86d73363bc..a9c12a35855 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -6,11 +6,12 @@ "type": "module", "scripts": { "dev": "nodemon --config nodemon.config.json -x 'run-s build:snippets build:docs-api dev:docs'", - "build": "run-s build:snippets build:docs build:docs-api", + "build": "run-s build:snippets build:docs", "preview": "run-s build:snippets build:docs-api preview:docs", "test": "cd ../.. && pnpm run test:filter apps/docs", "build:snippets": "run-s wrap:snippets build:forc", - "build:docs": "vitepress build", + "build:docs": "run-s build:docs-app build:docs-api", + "build:docs-app": "vitepress build", "build:docs-api": "cd ../docs-api && pnpm build && cp -r ./src/api ../docs/dist", "preview:docs": "vitepress preview", "preview:docs-api": "pnpm vite preview --port 5174 --outDir ../docs-api/src/api", From 7685e590ba1ba66658b6587079775b82a1361548 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Sun, 19 Jan 2025 09:44:19 +0100 Subject: [PATCH 05/21] wip vercel deployment --- .github/workflows/release.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 98c20fa8953..0284f5c57d2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -131,6 +131,15 @@ jobs: repo: FuelLabs/docs-hub token: ${{ secrets.REPO_TOKEN }} + - name: Update Docs API (stable) + if: github.ref_name == 'master' && env.SHOULD_DEPLOY_DOCS == 'true' + env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_TS_DOCS_PROJECT_ID }} + run: | + pnpm install --global vercel@latest + vercel --prod --token=${{ secrets.VERCEL_TOKEN }} + - name: Create PR to apply latest release to master if: steps.changesets.outputs.published == 'true' && startsWith(github.ref_name, 'release/') && env.RELEASE_VERSION_HIGHER_THAN_LATEST == 'true' run: | From 9e1fa81519784c3baf526d2c19120e2382e2f105 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Tue, 21 Jan 2025 11:50:25 +0100 Subject: [PATCH 06/21] bad merge --- packages/account/src/providers/resource-cache.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/account/src/providers/resource-cache.test.ts b/packages/account/src/providers/resource-cache.test.ts index 9b024055d1a..f4f42839162 100644 --- a/packages/account/src/providers/resource-cache.test.ts +++ b/packages/account/src/providers/resource-cache.test.ts @@ -10,6 +10,12 @@ import { ResourceCache } from './resource-cache'; describe('Resource Cache', () => { const randomValue = () => hexlify(randomBytes(32)); + afterEach(() => { + // Reset the cache after each test + const resourceCache = new ResourceCache(1000); + resourceCache.clear(); + }); + it('can instantiate [valid numerical ttl]', () => { const memCache = new ResourceCache(1000); From c5c07ec59d01bb45e6efcbc27cc0b3f9a3603662 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Tue, 21 Jan 2025 11:50:47 +0100 Subject: [PATCH 07/21] empty changeset --- .changeset/khaki-hairs-heal.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changeset/khaki-hairs-heal.md diff --git a/.changeset/khaki-hairs-heal.md b/.changeset/khaki-hairs-heal.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/khaki-hairs-heal.md @@ -0,0 +1,2 @@ +--- +--- From 64f54be7eec69793104dca300d2429f9d5b589d8 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Tue, 21 Jan 2025 11:53:09 +0100 Subject: [PATCH 08/21] add PR name to changeset --- .changeset/khaki-hairs-heal.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.changeset/khaki-hairs-heal.md b/.changeset/khaki-hairs-heal.md index a845151cc84..6c208c4a8ff 100644 --- a/.changeset/khaki-hairs-heal.md +++ b/.changeset/khaki-hairs-heal.md @@ -1,2 +1,4 @@ --- --- + +docs: segregate api docs url/deployment From 2584b8f2450fe69ffe9d4746d0ce26a82c2df367 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Tue, 21 Jan 2025 11:55:09 +0100 Subject: [PATCH 09/21] fix --- apps/docs-api/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs-api/index.md b/apps/docs-api/index.md index 2ce85b70768..13381c922a5 100644 --- a/apps/docs-api/index.md +++ b/apps/docs-api/index.md @@ -19,7 +19,7 @@ - [crypto](modules/_fuel_ts_crypto.html) - [errors](modules/_fuel_ts_errors.html) - [hasher](modules/_fuel_ts_hasher.html) -- [math](/odules/_fuel_ts_math.html) +- [math](modules/_fuel_ts_math.html) - [program](modules/_fuel_ts_program.html) - [script](modules/_fuel_ts_script.html) - [transactions](modules/_fuel_ts_transactions.html) From 132787d77e406e89dbf1d52f548cccecd4103e67 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Tue, 21 Jan 2025 12:05:06 +0100 Subject: [PATCH 10/21] use NODE_ENV --- apps/docs/.vitepress/config.ts | 1155 ++++++++++++++++---------------- 1 file changed, 575 insertions(+), 580 deletions(-) diff --git a/apps/docs/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index 7e39ac9fbca..2829fb4d128 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -2,586 +2,581 @@ import { defineConfig } from 'vitepress'; import { codeInContextPlugin } from './plugins/codeInContextPlugin'; import { snippetPlugin } from './plugins/snippetPlugin'; -// @ts-expect-error this works but the types aren't available -export default ({ mode }) => - defineConfig({ - title: 'Fuels-ts', - description: 'Fuel Typescript SDK', - srcDir: 'src', - outDir: 'dist', - lang: 'en-US', - appearance: 'dark', - markdown: { - config: (md) => { - md.use(snippetPlugin); - md.use(codeInContextPlugin); - md.block.ruler.disable('snippet'); - md.core.ruler.before('normalize', 'replace-magic-string', (state) => { - const apiUrl = mode === 'development' ? 'http://localhost:5174' : '/api'; - state.src = state.src.replace(/DOCS_API_URL/g, apiUrl); - }); - }, - }, - transformHtml: (code) => { - // make the API links open in a new tab - // because opening in the same tab doesn't work in the preview - return code.replace( - /(]*href="\/api\/[^"]*")/g, - '$1 target="_blank" rel="noreferrer"' - ); +export default defineConfig({ + title: 'Fuels-ts', + description: 'Fuel Typescript SDK', + srcDir: 'src', + outDir: 'dist', + lang: 'en-US', + appearance: 'dark', + markdown: { + config: (md) => { + md.use(snippetPlugin); + md.use(codeInContextPlugin); + md.block.ruler.disable('snippet'); + md.core.ruler.before('normalize', 'replace-magic-string', (state) => { + const apiUrl = process.env.NODE_ENV === 'development' ? 'http://localhost:5174' : '/api'; + state.src = state.src.replace(/DOCS_API_URL/g, apiUrl); + }); }, - // finds dead DOCS_API_URL links - // which get replaced later in the markdown transformer - ignoreDeadLinks: true, - head: [ - ['link', { rel: 'icon', href: '/fuels-ts/favicon.ico', type: 'image/png' }], - ['meta', { property: 'og:type', content: 'website' }], - ['meta', { property: 'og:url', content: 'https://fuellabs.github.io/fuels-ts/' }], - ], - themeConfig: { - logo: 'fuel-logo.png', - nav: [ - { - text: 'Home', - link: '/', - }, - ], - socialLinks: [ - { icon: 'github', link: 'https://github.com/FuelLabs/fuels-ts' }, - { icon: 'twitter', link: 'https://twitter.com/fuel_network' }, - { icon: 'discord', link: 'https://discord.com/invite/xfpK4Pe' }, - ], - editLink: { - pattern: 'https://github.com/fuellabs/fuels-ts/edit/master/apps/docs/src/:path', - text: 'Edit this page on GitHub', + }, + transformHtml: (code) => { + // make the API links open in a new tab + // because opening in the same tab doesn't work in the preview + return code.replace(/(]*href="\/api\/[^"]*")/g, '$1 target="_blank" rel="noreferrer"'); + }, + // finds dead DOCS_API_URL links + // which get replaced later in the markdown transformer + ignoreDeadLinks: true, + head: [ + ['link', { rel: 'icon', href: '/fuels-ts/favicon.ico', type: 'image/png' }], + ['meta', { property: 'og:type', content: 'website' }], + ['meta', { property: 'og:url', content: 'https://fuellabs.github.io/fuels-ts/' }], + ], + themeConfig: { + logo: 'fuel-logo.png', + nav: [ + { + text: 'Home', + link: '/', }, - sidebar: [ - { - items: [ - { - text: 'Getting Started', - link: '/guide/getting-started/', - collapsed: true, - items: [ - { - text: 'Installation', - link: '/guide/getting-started/installation', - }, - { - text: 'Connecting to the Network', - link: '/guide/getting-started/connecting-to-the-network', - }, - { - text: 'Running a local Fuel node', - link: '/guide/getting-started/running-a-local-fuel-node', - }, - { - text: 'React Example', - link: '/guide/getting-started/react-example', - }, - { - text: 'CDN Usage', - link: '/guide/getting-started/cdn-usage', - }, - { - text: 'Next Steps', - link: '/guide/getting-started/next-steps', - }, - ], - }, - { - text: 'The UTXO Model', - link: '/guide/the-utxo-model/', - collapsed: false, - items: [], - }, - { - text: 'Creating a Fuel dApp', - link: '/guide/creating-a-fuel-dapp/', - collapsed: true, - items: [ - { - text: 'Options', - link: '/guide/creating-a-fuel-dapp/options', - }, - { - text: 'Deploying a dApp to Testnet', - link: '/guide/creating-a-fuel-dapp/deploying-a-dapp-to-testnet', - }, - { - text: 'Working with Predicates', - link: '/guide/creating-a-fuel-dapp/working-with-predicates', - }, - ], - }, - { - text: 'fuels CLI', - link: '/guide/fuels-cli/', - collapsed: true, - items: [ - { - text: 'Config File', - link: '/guide/fuels-cli/config-file', - }, - { - text: 'Commands', - link: '/guide/fuels-cli/commands', - }, - { - text: 'ABI Typegen', - link: '/guide/fuels-cli/abi-typegen', - }, - { - text: 'Generating Types', - link: '/guide/fuels-cli/generating-types', - }, - { - text: 'Using Generated Types', - link: '/guide/fuels-cli/using-generated-types', - }, - ], - }, - { - text: 'Provider', - link: '/guide/provider/', - collapsed: true, - items: [ - { - text: 'Provider Options', - link: '/guide/provider/provider-options', - }, - { - text: 'Pagination', - link: '/guide/provider/pagination', - }, - { - text: 'Querying the Chain', - link: '/guide/provider/querying-the-chain', - }, - ], - }, - { - text: 'Wallets', - link: '/guide/wallets/', - collapsed: true, - items: [ - { - text: 'Instantiating Wallets', - link: '/guide/wallets/instantiating-wallets', - }, - { - text: 'Private Keys', - link: '/guide/wallets/private-keys', - }, - { - text: 'Mnemonic Wallet', - link: '/guide/wallets/mnemonic-wallet', - }, - { - text: 'Encrypting and Decrypting', - link: '/guide/wallets/encrypting-and-decrypting', - }, - { - text: 'Checking Balances', - link: '/guide/wallets/checking-balances', - }, - { - text: 'Wallet Transferring', - link: '/guide/wallets/wallet-transferring', - }, - { - text: 'Signing', - link: '/guide/wallets/signing', - }, - { - text: 'Connectors', - link: '/guide/wallets/connectors', - }, - { - text: 'Wallet Manager', - link: '/guide/wallets/wallet-manager', - }, - { - text: 'Locking and Unlocking', - link: '/guide/wallets/locking-and-unlocking', - }, - ], - }, - { - text: 'Contracts', - link: '/guide/contracts/', - collapsed: true, - items: [ - { - text: 'Methods', - link: '/guide/contracts/methods', - }, - { - text: 'Call Parameters', - link: '/guide/contracts/call-parameters', - }, - { - text: 'Contract Balance', - link: '/guide/contracts/contract-balance', - }, - { - text: 'Cost Estimation', - link: '/guide/contracts/cost-estimation', - }, - { - text: 'Dependency Estimation', - link: '/guide/contracts/dependency-estimation', - }, - { - text: 'Variable Outputs', - link: '/guide/contracts/variable-outputs', - }, - { - text: 'Logs', - link: '/guide/contracts/logs', - }, - { - text: 'Inter-contract Calls', - link: '/guide/contracts/inter-contract-calls', - }, - { - text: 'Multi-contract calls', - link: '/guide/contracts/multi-contract-calls', - }, - { - text: 'Using different Wallets', - link: '/guide/contracts/using-different-wallets', - }, - { - text: 'Transferring Assets', - link: '/guide/contracts/transferring-assets', - }, - { - text: 'Deploying Contracts', - link: '/guide/contracts/deploying-contracts', - }, - { - text: 'Storage Slots', - link: '/guide/contracts/storage-slots', - }, - { - text: 'Configurable Constants', - link: '/guide/contracts/configurable-constants', - }, - { - text: 'Minted Token Asset ID', - link: '/guide/contracts/minted-token-asset-id', - }, - { - text: 'Managing Deployed Contracts', - link: '/guide/contracts/managing-deployed-contracts', - }, - { - text: 'Proxy Contracts', - link: '/guide/contracts/proxy-contracts', - }, - { - text: 'Understanding the FuelVM Binary File', - link: '/guide/contracts/understanding-the-fuelvm-binary-file', - }, - ], - }, - { - text: 'Scripts', - link: '/guide/scripts/', - collapsed: true, - items: [ - { - text: 'Instantiating A Script', - link: '/guide/scripts/instantiating-a-script', - }, - { - text: 'Deploying Scripts', - link: '/guide/scripts/deploying-scripts', - }, - { - text: 'Configurable Constants', - link: '/guide/scripts/configurable-constants', - }, - { - text: 'Running scripts', - link: '/guide/scripts/running-scripts', - }, - { - text: 'Custom script Call', - link: '/guide/scripts/custom-script-call', - }, - ], - }, - { - text: 'Predicates', - link: '/guide/predicates/', - collapsed: true, - items: [ - { - text: 'Instantiating A Predicate', - link: '/guide/predicates/instantiating-a-predicate', - }, - { - text: 'Deploying Predicates', - link: '/guide/predicates/deploying-predicates', - }, - { - text: 'Configurable Constants', - link: '/guide/predicates/configurable-constants', - }, - { - text: 'Send And Spend Funds From Predicates', - link: '/guide/predicates/send-and-spend-funds-from-predicates', - }, - { - text: 'Methods', - link: '/guide/predicates/methods', - }, - { - text: 'Custom Transactions', - link: '/guide/predicates/custom-transactions', - }, - ], - }, - { - text: 'Transactions', - link: '/guide/transactions/', - collapsed: true, - items: [ - { - text: 'Modifying the Request', - link: '/guide/transactions/modifying-the-request', - }, - { - text: 'Adding Parameters', - link: '/guide/transactions/adding-parameters', - }, - { - text: 'Adding Policies', - link: '/guide/transactions/adding-policies', - }, - { - text: 'Getting the Response', - link: '/guide/transactions/getting-the-response', - }, - { - text: 'Optimizing Frontend Apps', - link: '/guide/transactions/optimizing-frontend-apps', - }, - ], - }, - { - text: 'Encoding', - link: '/guide/encoding/', - collapsed: true, - items: [ - { - text: 'Encode and Decode', - link: '/guide/encoding/encode-and-decode', - }, - { - text: 'Working with Bytes', - link: '/guide/encoding/working-with-bytes', - }, - ], - }, - { - text: 'Utilities', - link: '/guide/utilities/', - collapsed: true, - items: [ - { - text: 'Date conversion', - link: '/guide/utilities/date-conversion', - }, - { - text: 'Address conversion', - link: '/guide/utilities/address-conversion', - }, - { - text: 'Unit conversion', - link: '/guide/utilities/unit-conversion', - }, - { - text: 'Using assets', - link: '/guide/utilities/using-assets', - }, - ], - }, - { - text: 'Cookbook', - link: '/guide/cookbook/', - collapsed: true, - items: [ - { - text: 'Deposit And Withdraw', - link: '/guide/cookbook/deposit-and-withdraw', - }, - { - text: 'Wallet SDK and React Hooks', - link: '/guide/cookbook/wallet-sdk-and-react-hooks', - }, - { - text: 'Custom Transactions', - link: '/guide/cookbook/custom-transactions', - }, - { - text: 'Custom Transactions from Contract Calls', - link: '/guide/cookbook/custom-transactions-from-contract-calls', - }, - { - text: 'Generate Fake Resources', - link: '/guide/cookbook/generate-fake-resources', - }, - { - text: 'Transactions with Multiple Signers', - link: '/guide/cookbook/transactions-with-multiple-signers', - }, - { - text: 'GraphQL Integration', - link: '/guide/cookbook/graphql-integration', - }, - { - text: 'Resubmitting Failed Transactions', - link: '/guide/cookbook/resubmitting-failed-transactions', - }, - { - text: 'Combining UTXOs', - link: '/guide/cookbook/combining-utxos', - }, - { - text: 'Splitting UTXOs', - link: '/guide/cookbook/splitting-utxos', - }, - { - text: 'Optimized React Example', - link: '/guide/cookbook/optimized-react-example', - }, - ], - }, - { - text: 'Testing', - link: '/guide/testing/', - collapsed: true, - items: [ - { - text: 'Launching a Test Node', - link: '/guide/testing/launching-a-test-node', - }, - { - text: 'Test Node Options', - link: '/guide/testing/test-node-options', - }, - { - text: 'Fuel Core Options', - link: '/guide/testing/fuel-core-options', - }, - { - text: 'Basic Example', - link: '/guide/testing/basic-example', - }, - { - text: 'Advanced Example', - link: '/guide/testing/advanced-example', - }, - { - text: 'Custom Blocks', - link: '/guide/testing/custom-blocks', - }, - { - text: 'Setting up test wallets', - link: '/guide/testing/setting-up-test-wallets', - }, - ], - }, - { - text: 'Types', - link: '/guide/types/', - collapsed: true, - items: [ - { - text: 'Address', - link: '/guide/types/address', - }, - { - text: 'Arrays', - link: '/guide/types/arrays', - }, - { - text: 'Asset Id', - link: '/guide/types/asset-id', - }, - { - text: 'B256', - link: '/guide/types/b256', - }, - { - text: 'B512', - link: '/guide/types/b512', - }, - { - text: 'Bytes', - link: '/guide/types/bytes', - }, - { - text: 'Bytes32', - link: '/guide/types/bytes32', - }, - { - text: 'Enums', - link: '/guide/types/enums', - }, - { - text: 'Evm Address', - link: '/guide/types/evm-address', - }, - { - text: 'Native Parameters', - link: '/guide/types/native-parameters', - }, - { - text: 'Numbers', - link: '/guide/types/numbers', - }, - { - text: 'Options', - link: '/guide/types/options', - }, - { - text: 'Raw Slice', - link: '/guide/types/raw-slice', - }, - { - text: 'Std String', - link: '/guide/types/std-string', - }, - { - text: 'String', - link: '/guide/types/string', - }, - { - text: 'Structs', - link: '/guide/types/structs', - }, - { - text: 'Tuples', - link: '/guide/types/tuples', - }, - { - text: 'Vectors', - link: '/guide/types/vectors', - }, - ], - }, - { - text: 'Errors', - link: '/guide/errors/', - collapsed: false, - items: [], - }, - ], - }, - ], + ], + socialLinks: [ + { icon: 'github', link: 'https://github.com/FuelLabs/fuels-ts' }, + { icon: 'twitter', link: 'https://twitter.com/fuel_network' }, + { icon: 'discord', link: 'https://discord.com/invite/xfpK4Pe' }, + ], + editLink: { + pattern: 'https://github.com/fuellabs/fuels-ts/edit/master/apps/docs/src/:path', + text: 'Edit this page on GitHub', }, - }); + sidebar: [ + { + items: [ + { + text: 'Getting Started', + link: '/guide/getting-started/', + collapsed: true, + items: [ + { + text: 'Installation', + link: '/guide/getting-started/installation', + }, + { + text: 'Connecting to the Network', + link: '/guide/getting-started/connecting-to-the-network', + }, + { + text: 'Running a local Fuel node', + link: '/guide/getting-started/running-a-local-fuel-node', + }, + { + text: 'React Example', + link: '/guide/getting-started/react-example', + }, + { + text: 'CDN Usage', + link: '/guide/getting-started/cdn-usage', + }, + { + text: 'Next Steps', + link: '/guide/getting-started/next-steps', + }, + ], + }, + { + text: 'The UTXO Model', + link: '/guide/the-utxo-model/', + collapsed: false, + items: [], + }, + { + text: 'Creating a Fuel dApp', + link: '/guide/creating-a-fuel-dapp/', + collapsed: true, + items: [ + { + text: 'Options', + link: '/guide/creating-a-fuel-dapp/options', + }, + { + text: 'Deploying a dApp to Testnet', + link: '/guide/creating-a-fuel-dapp/deploying-a-dapp-to-testnet', + }, + { + text: 'Working with Predicates', + link: '/guide/creating-a-fuel-dapp/working-with-predicates', + }, + ], + }, + { + text: 'fuels CLI', + link: '/guide/fuels-cli/', + collapsed: true, + items: [ + { + text: 'Config File', + link: '/guide/fuels-cli/config-file', + }, + { + text: 'Commands', + link: '/guide/fuels-cli/commands', + }, + { + text: 'ABI Typegen', + link: '/guide/fuels-cli/abi-typegen', + }, + { + text: 'Generating Types', + link: '/guide/fuels-cli/generating-types', + }, + { + text: 'Using Generated Types', + link: '/guide/fuels-cli/using-generated-types', + }, + ], + }, + { + text: 'Provider', + link: '/guide/provider/', + collapsed: true, + items: [ + { + text: 'Provider Options', + link: '/guide/provider/provider-options', + }, + { + text: 'Pagination', + link: '/guide/provider/pagination', + }, + { + text: 'Querying the Chain', + link: '/guide/provider/querying-the-chain', + }, + ], + }, + { + text: 'Wallets', + link: '/guide/wallets/', + collapsed: true, + items: [ + { + text: 'Instantiating Wallets', + link: '/guide/wallets/instantiating-wallets', + }, + { + text: 'Private Keys', + link: '/guide/wallets/private-keys', + }, + { + text: 'Mnemonic Wallet', + link: '/guide/wallets/mnemonic-wallet', + }, + { + text: 'Encrypting and Decrypting', + link: '/guide/wallets/encrypting-and-decrypting', + }, + { + text: 'Checking Balances', + link: '/guide/wallets/checking-balances', + }, + { + text: 'Wallet Transferring', + link: '/guide/wallets/wallet-transferring', + }, + { + text: 'Signing', + link: '/guide/wallets/signing', + }, + { + text: 'Connectors', + link: '/guide/wallets/connectors', + }, + { + text: 'Wallet Manager', + link: '/guide/wallets/wallet-manager', + }, + { + text: 'Locking and Unlocking', + link: '/guide/wallets/locking-and-unlocking', + }, + ], + }, + { + text: 'Contracts', + link: '/guide/contracts/', + collapsed: true, + items: [ + { + text: 'Methods', + link: '/guide/contracts/methods', + }, + { + text: 'Call Parameters', + link: '/guide/contracts/call-parameters', + }, + { + text: 'Contract Balance', + link: '/guide/contracts/contract-balance', + }, + { + text: 'Cost Estimation', + link: '/guide/contracts/cost-estimation', + }, + { + text: 'Dependency Estimation', + link: '/guide/contracts/dependency-estimation', + }, + { + text: 'Variable Outputs', + link: '/guide/contracts/variable-outputs', + }, + { + text: 'Logs', + link: '/guide/contracts/logs', + }, + { + text: 'Inter-contract Calls', + link: '/guide/contracts/inter-contract-calls', + }, + { + text: 'Multi-contract calls', + link: '/guide/contracts/multi-contract-calls', + }, + { + text: 'Using different Wallets', + link: '/guide/contracts/using-different-wallets', + }, + { + text: 'Transferring Assets', + link: '/guide/contracts/transferring-assets', + }, + { + text: 'Deploying Contracts', + link: '/guide/contracts/deploying-contracts', + }, + { + text: 'Storage Slots', + link: '/guide/contracts/storage-slots', + }, + { + text: 'Configurable Constants', + link: '/guide/contracts/configurable-constants', + }, + { + text: 'Minted Token Asset ID', + link: '/guide/contracts/minted-token-asset-id', + }, + { + text: 'Managing Deployed Contracts', + link: '/guide/contracts/managing-deployed-contracts', + }, + { + text: 'Proxy Contracts', + link: '/guide/contracts/proxy-contracts', + }, + { + text: 'Understanding the FuelVM Binary File', + link: '/guide/contracts/understanding-the-fuelvm-binary-file', + }, + ], + }, + { + text: 'Scripts', + link: '/guide/scripts/', + collapsed: true, + items: [ + { + text: 'Instantiating A Script', + link: '/guide/scripts/instantiating-a-script', + }, + { + text: 'Deploying Scripts', + link: '/guide/scripts/deploying-scripts', + }, + { + text: 'Configurable Constants', + link: '/guide/scripts/configurable-constants', + }, + { + text: 'Running scripts', + link: '/guide/scripts/running-scripts', + }, + { + text: 'Custom script Call', + link: '/guide/scripts/custom-script-call', + }, + ], + }, + { + text: 'Predicates', + link: '/guide/predicates/', + collapsed: true, + items: [ + { + text: 'Instantiating A Predicate', + link: '/guide/predicates/instantiating-a-predicate', + }, + { + text: 'Deploying Predicates', + link: '/guide/predicates/deploying-predicates', + }, + { + text: 'Configurable Constants', + link: '/guide/predicates/configurable-constants', + }, + { + text: 'Send And Spend Funds From Predicates', + link: '/guide/predicates/send-and-spend-funds-from-predicates', + }, + { + text: 'Methods', + link: '/guide/predicates/methods', + }, + { + text: 'Custom Transactions', + link: '/guide/predicates/custom-transactions', + }, + ], + }, + { + text: 'Transactions', + link: '/guide/transactions/', + collapsed: true, + items: [ + { + text: 'Modifying the Request', + link: '/guide/transactions/modifying-the-request', + }, + { + text: 'Adding Parameters', + link: '/guide/transactions/adding-parameters', + }, + { + text: 'Adding Policies', + link: '/guide/transactions/adding-policies', + }, + { + text: 'Getting the Response', + link: '/guide/transactions/getting-the-response', + }, + { + text: 'Optimizing Frontend Apps', + link: '/guide/transactions/optimizing-frontend-apps', + }, + ], + }, + { + text: 'Encoding', + link: '/guide/encoding/', + collapsed: true, + items: [ + { + text: 'Encode and Decode', + link: '/guide/encoding/encode-and-decode', + }, + { + text: 'Working with Bytes', + link: '/guide/encoding/working-with-bytes', + }, + ], + }, + { + text: 'Utilities', + link: '/guide/utilities/', + collapsed: true, + items: [ + { + text: 'Date conversion', + link: '/guide/utilities/date-conversion', + }, + { + text: 'Address conversion', + link: '/guide/utilities/address-conversion', + }, + { + text: 'Unit conversion', + link: '/guide/utilities/unit-conversion', + }, + { + text: 'Using assets', + link: '/guide/utilities/using-assets', + }, + ], + }, + { + text: 'Cookbook', + link: '/guide/cookbook/', + collapsed: true, + items: [ + { + text: 'Deposit And Withdraw', + link: '/guide/cookbook/deposit-and-withdraw', + }, + { + text: 'Wallet SDK and React Hooks', + link: '/guide/cookbook/wallet-sdk-and-react-hooks', + }, + { + text: 'Custom Transactions', + link: '/guide/cookbook/custom-transactions', + }, + { + text: 'Custom Transactions from Contract Calls', + link: '/guide/cookbook/custom-transactions-from-contract-calls', + }, + { + text: 'Generate Fake Resources', + link: '/guide/cookbook/generate-fake-resources', + }, + { + text: 'Transactions with Multiple Signers', + link: '/guide/cookbook/transactions-with-multiple-signers', + }, + { + text: 'GraphQL Integration', + link: '/guide/cookbook/graphql-integration', + }, + { + text: 'Resubmitting Failed Transactions', + link: '/guide/cookbook/resubmitting-failed-transactions', + }, + { + text: 'Combining UTXOs', + link: '/guide/cookbook/combining-utxos', + }, + { + text: 'Splitting UTXOs', + link: '/guide/cookbook/splitting-utxos', + }, + { + text: 'Optimized React Example', + link: '/guide/cookbook/optimized-react-example', + }, + ], + }, + { + text: 'Testing', + link: '/guide/testing/', + collapsed: true, + items: [ + { + text: 'Launching a Test Node', + link: '/guide/testing/launching-a-test-node', + }, + { + text: 'Test Node Options', + link: '/guide/testing/test-node-options', + }, + { + text: 'Fuel Core Options', + link: '/guide/testing/fuel-core-options', + }, + { + text: 'Basic Example', + link: '/guide/testing/basic-example', + }, + { + text: 'Advanced Example', + link: '/guide/testing/advanced-example', + }, + { + text: 'Custom Blocks', + link: '/guide/testing/custom-blocks', + }, + { + text: 'Setting up test wallets', + link: '/guide/testing/setting-up-test-wallets', + }, + ], + }, + { + text: 'Types', + link: '/guide/types/', + collapsed: true, + items: [ + { + text: 'Address', + link: '/guide/types/address', + }, + { + text: 'Arrays', + link: '/guide/types/arrays', + }, + { + text: 'Asset Id', + link: '/guide/types/asset-id', + }, + { + text: 'B256', + link: '/guide/types/b256', + }, + { + text: 'B512', + link: '/guide/types/b512', + }, + { + text: 'Bytes', + link: '/guide/types/bytes', + }, + { + text: 'Bytes32', + link: '/guide/types/bytes32', + }, + { + text: 'Enums', + link: '/guide/types/enums', + }, + { + text: 'Evm Address', + link: '/guide/types/evm-address', + }, + { + text: 'Native Parameters', + link: '/guide/types/native-parameters', + }, + { + text: 'Numbers', + link: '/guide/types/numbers', + }, + { + text: 'Options', + link: '/guide/types/options', + }, + { + text: 'Raw Slice', + link: '/guide/types/raw-slice', + }, + { + text: 'Std String', + link: '/guide/types/std-string', + }, + { + text: 'String', + link: '/guide/types/string', + }, + { + text: 'Structs', + link: '/guide/types/structs', + }, + { + text: 'Tuples', + link: '/guide/types/tuples', + }, + { + text: 'Vectors', + link: '/guide/types/vectors', + }, + ], + }, + { + text: 'Errors', + link: '/guide/errors/', + collapsed: false, + items: [], + }, + ], + }, + ], + }, +}); From cf5b022b42523e7641b8e9aafdfddcdb397498f6 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Tue, 21 Jan 2025 12:07:03 +0100 Subject: [PATCH 11/21] improve comments --- apps/docs/.vitepress/config.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/docs/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index 2829fb4d128..9e512f6b00b 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -25,8 +25,9 @@ export default defineConfig({ // because opening in the same tab doesn't work in the preview return code.replace(/(]*href="\/api\/[^"]*")/g, '$1 target="_blank" rel="noreferrer"'); }, - // finds dead DOCS_API_URL links - // which get replaced later in the markdown transformer + // Finds dead DOCS_API_URL links and fails, + // but they get replaced later in the markdown transformer. + // We have the md link checker workflow which covers this. ignoreDeadLinks: true, head: [ ['link', { rel: 'icon', href: '/fuels-ts/favicon.ico', type: 'image/png' }], From be155b053a60657999124241d859487464a7150a Mon Sep 17 00:00:00 2001 From: nedsalk Date: Tue, 21 Jan 2025 12:49:56 +0100 Subject: [PATCH 12/21] fix lint --- scripts/lint-md-links.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/lint-md-links.ts b/scripts/lint-md-links.ts index 7163409b7ac..8031e35bc05 100644 --- a/scripts/lint-md-links.ts +++ b/scripts/lint-md-links.ts @@ -1,8 +1,7 @@ #!/usr/bin/env node -import { exec, execSync, spawn } from 'child_process'; +import { execSync, spawn } from 'child_process'; import { readFileSync, writeFileSync } from 'fs'; import { globSync } from 'glob'; -import { cwd } from 'process'; const { log } = console; From 62bffbbf3873074d63eec2f475e68845e7b736a4 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Wed, 29 Jan 2025 13:43:51 +0100 Subject: [PATCH 13/21] Use replacement pattern instead of file change --- link-check.config.json | 9 +++++++++ scripts/lint-md-links.ts | 5 ----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/link-check.config.json b/link-check.config.json index 8ce8f969d75..45a02b8a72d 100644 --- a/link-check.config.json +++ b/link-check.config.json @@ -13,6 +13,15 @@ }, { "pattern": "https://docs.fuel.network/docs/fuels-ts/getting-started/running-a-local-fuel-node" + }, + { + "pattern": "^modules/_fuel_ts" + } + ], + "replacementPatterns": [ + { + "pattern": "DOCS_API_URL", + "replacement": "http://localhost:9876" } ] } diff --git a/scripts/lint-md-links.ts b/scripts/lint-md-links.ts index 8031e35bc05..929426db5a6 100644 --- a/scripts/lint-md-links.ts +++ b/scripts/lint-md-links.ts @@ -1,6 +1,5 @@ #!/usr/bin/env node import { execSync, spawn } from 'child_process'; -import { readFileSync, writeFileSync } from 'fs'; import { globSync } from 'glob'; const { log } = console; @@ -21,10 +20,6 @@ void (async () => { ignore: ['**/node_modules/**', 'apps/demo-*/**', '.changeset/**', '**/CHANGELOG.md'], }); - mdFiles.forEach((filepath) => { - const content = readFileSync(filepath).toString(); - writeFileSync(filepath, content.replace(/DOCS_API_URL/g, 'http://localhost:9876')); - }); // TODO: Stop ignoring doc links in `link-check.config.json` // The above requires this to be merged and deployed: // - https://github.com/FuelLabs/fuels-ts/pull/3500 From 4faaafb0ed31a084f158b24089bdb9a518c074d7 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Wed, 29 Jan 2025 16:44:52 +0100 Subject: [PATCH 14/21] use replacement pattern instead of ignoring --- link-check.config.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/link-check.config.json b/link-check.config.json index 45a02b8a72d..73f5801411a 100644 --- a/link-check.config.json +++ b/link-check.config.json @@ -13,15 +13,16 @@ }, { "pattern": "https://docs.fuel.network/docs/fuels-ts/getting-started/running-a-local-fuel-node" - }, - { - "pattern": "^modules/_fuel_ts" } ], "replacementPatterns": [ { "pattern": "DOCS_API_URL", "replacement": "http://localhost:9876" + }, + { + "pattern": "^modules/_fuel_ts", + "replacement": "http://localhost:9876/modules/_fuel_ts" } ] } From ff53c1d19b9427b7f394e26cef756337eac5b8a3 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Wed, 29 Jan 2025 16:44:59 +0100 Subject: [PATCH 15/21] fix linting not exiting --- scripts/lint-md-links.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/lint-md-links.ts b/scripts/lint-md-links.ts index 929426db5a6..576565c77c8 100644 --- a/scripts/lint-md-links.ts +++ b/scripts/lint-md-links.ts @@ -23,12 +23,12 @@ void (async () => { // TODO: Stop ignoring doc links in `link-check.config.json` // The above requires this to be merged and deployed: // - https://github.com/FuelLabs/fuels-ts/pull/3500 - try { - execSync(`pnpm markdown-link-check -q -c ./link-check.config.json ${mdFiles.join(' ')}`, { - stdio: 'inherit', - }); - } catch { + execSync(`pnpm markdown-link-check -q -c ./link-check.config.json ${mdFiles.join(' ')}`, { + stdio: 'inherit', + }); +})() + .catch(() => { log('Some files have broken links. Please fix them.'); process.exit(1); - } -})(); + }) + .then(() => process.exit(0)); From 025750822b52f01f18181dd225a1eb7d77980f92 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Wed, 29 Jan 2025 17:39:58 +0100 Subject: [PATCH 16/21] Always run nightly workflow --- .github/workflows/release.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f69cdf9a4e6..417cd50a474 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -111,16 +111,8 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # ensure docs are always deployed after merge of changeset PR - - name: Get the last commit message and set env vars - run: echo LAST_COMMIT_MSG=$(git --no-pager log -1 --pretty=%B) >> $GITHUB_ENV - - - name: Decides if Docs should be deployed - if: startsWith(env.LAST_COMMIT_MSG, 'ci(release):') && env.RELEASE_VERSION_HIGHER_THAN_LATEST == 'true' - run: echo SHOULD_DEPLOY_DOCS=true >> $GITHUB_ENV - - - name: Update docs (nightly) - if: github.ref_name == 'master' && env.SHOULD_DEPLOY_DOCS == 'true' + - name: Update docs + if: github.ref_name == 'master' uses: benc-uk/workflow-dispatch@v1 with: workflow: update-nightly.yml @@ -128,8 +120,16 @@ jobs: repo: FuelLabs/docs-hub token: ${{ secrets.GITHUB_TOKEN }} + # ensure docs API is always deployed after merge of changeset PR + - name: Get the last commit message and set env vars + run: echo LAST_COMMIT_MSG=$(git --no-pager log -1 --pretty=%B) >> $GITHUB_ENV + + - name: Decides if Docs API should be deployed + if: startsWith(env.LAST_COMMIT_MSG, 'ci(release):') && env.RELEASE_VERSION_HIGHER_THAN_LATEST == 'true' + run: echo DEPLOY_STABLE_DOCS_API=true >> $GITHUB_ENV + - name: Update Docs API (stable) - if: github.ref_name == 'master' && env.SHOULD_DEPLOY_DOCS == 'true' + if: github.ref_name == 'master' && env.DEPLOY_STABLE_DOCS_API == 'true' env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_TS_DOCS_PROJECT_ID }} From a83cca8034a122c2d5a4e985eb223ce8a26c6ab7 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Wed, 29 Jan 2025 17:43:34 +0100 Subject: [PATCH 17/21] reordering --- .github/workflows/release.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 417cd50a474..8d278528040 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -111,15 +111,6 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Update docs - if: github.ref_name == 'master' - uses: benc-uk/workflow-dispatch@v1 - with: - workflow: update-nightly.yml - ref: master - repo: FuelLabs/docs-hub - token: ${{ secrets.GITHUB_TOKEN }} - # ensure docs API is always deployed after merge of changeset PR - name: Get the last commit message and set env vars run: echo LAST_COMMIT_MSG=$(git --no-pager log -1 --pretty=%B) >> $GITHUB_ENV @@ -137,6 +128,15 @@ jobs: pnpm install --global vercel@latest vercel --prod --token=${{ secrets.VERCEL_TOKEN }} + - name: Update docs + if: github.ref_name == 'master' + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: update-nightly.yml + ref: master + repo: FuelLabs/docs-hub + token: ${{ secrets.GITHUB_TOKEN }} + - name: Create PR to apply latest release to master if: steps.changesets.outputs.published == 'true' && startsWith(github.ref_name, 'release/') && env.RELEASE_VERSION_HIGHER_THAN_LATEST == 'true' run: | From 94df66d946b67d212b1f30b401e9c477338a69f0 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Wed, 29 Jan 2025 17:46:17 +0100 Subject: [PATCH 18/21] add comment --- .github/workflows/release.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8d278528040..a191f1d21e7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -119,6 +119,9 @@ jobs: if: startsWith(env.LAST_COMMIT_MSG, 'ci(release):') && env.RELEASE_VERSION_HIGHER_THAN_LATEST == 'true' run: echo DEPLOY_STABLE_DOCS_API=true >> $GITHUB_ENV + # nightly docs API gets updated on every merge to master + # and is configured in the vercel dashboard + # stable docs API gets updated only when a new release is published - name: Update Docs API (stable) if: github.ref_name == 'master' && env.DEPLOY_STABLE_DOCS_API == 'true' env: From d840435d4fee81d4b269ed3f35aea295dbf02c08 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Wed, 29 Jan 2025 17:56:08 +0100 Subject: [PATCH 19/21] rename rule --- apps/docs/.vitepress/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index 9e512f6b00b..c68da116054 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -14,7 +14,7 @@ export default defineConfig({ md.use(snippetPlugin); md.use(codeInContextPlugin); md.block.ruler.disable('snippet'); - md.core.ruler.before('normalize', 'replace-magic-string', (state) => { + md.core.ruler.before('normalize', 'replace-docs-api-url', (state) => { const apiUrl = process.env.NODE_ENV === 'development' ? 'http://localhost:5174' : '/api'; state.src = state.src.replace(/DOCS_API_URL/g, apiUrl); }); From 19246472253c531901128f64f247ea5a99cd4a6e Mon Sep 17 00:00:00 2001 From: nedsalk Date: Wed, 29 Jan 2025 18:01:21 +0100 Subject: [PATCH 20/21] rename secret env variable name --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a191f1d21e7..88c575e2ef9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -126,7 +126,7 @@ jobs: if: github.ref_name == 'master' && env.DEPLOY_STABLE_DOCS_API == 'true' env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_TS_DOCS_PROJECT_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_TS_DOCS_API_PROJECT_ID }} run: | pnpm install --global vercel@latest vercel --prod --token=${{ secrets.VERCEL_TOKEN }} From 9f083245d0f63ca0bd102d352c006f9127136a0c Mon Sep 17 00:00:00 2001 From: nedsalk Date: Fri, 7 Feb 2025 12:52:00 +0100 Subject: [PATCH 21/21] remove todo --- scripts/lint-md-links.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/lint-md-links.ts b/scripts/lint-md-links.ts index 576565c77c8..1f7e919df42 100644 --- a/scripts/lint-md-links.ts +++ b/scripts/lint-md-links.ts @@ -20,9 +20,6 @@ void (async () => { ignore: ['**/node_modules/**', 'apps/demo-*/**', '.changeset/**', '**/CHANGELOG.md'], }); - // TODO: Stop ignoring doc links in `link-check.config.json` - // The above requires this to be merged and deployed: - // - https://github.com/FuelLabs/fuels-ts/pull/3500 execSync(`pnpm markdown-link-check -q -c ./link-check.config.json ${mdFiles.join(' ')}`, { stdio: 'inherit', });