diff --git a/.changeset/khaki-hairs-heal.md b/.changeset/khaki-hairs-heal.md new file mode 100644 index 00000000000..6c208c4a8ff --- /dev/null +++ b/.changeset/khaki-hairs-heal.md @@ -0,0 +1,4 @@ +--- +--- + +docs: segregate api docs url/deployment diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2cd3cc4ad08..c65f68eb49c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -125,17 +125,29 @@ jobs: HOME: ${{ github.workspace }} npm_config_registry: "https://npm.pkg.github.com" - # ensure docs are always deployed after merge of changeset PR + # 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 should be deployed + - 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 SHOULD_DEPLOY_DOCS=true >> $GITHUB_ENV + 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: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_TS_DOCS_API_PROJECT_ID }} + run: | + pnpm install --global vercel@latest + vercel --prod --token=${{ secrets.VERCEL_TOKEN }} # # Commenting out as we require permissions to trigger across repos - # - 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 diff --git a/apps/docs-api/index.md b/apps/docs-api/index.md index 9e9f1c5e6bc..13381c922a5 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](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](modules/_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/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index db542cac46b..934c071ee9e 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -14,8 +14,21 @@ export default defineConfig({ md.use(snippetPlugin); md.use(codeInContextPlugin); md.block.ruler.disable('snippet'); + 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); + }); }, }, + 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 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' }], ['meta', { property: 'og:type', content: 'website' }], diff --git a/apps/docs/package.json b/apps/docs/package.json index 62a7d39fb1c..a9c12a35855 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -5,14 +5,18 @@ "description": "", "type": "module", "scripts": { - "dev": "nodemon --config nodemon.config.json -x 'run-s build:snippets dev:docs'", + "dev": "nodemon --config nodemon.config.json -x 'run-s build:snippets build:docs-api dev:docs'", "build": "run-s build:snippets build:docs", - "preview": "run-s build:snippets preview: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", - "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" 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 f1977349357..2d625604b02 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/b256.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/b256.md) format. When you log the `contractId` property of an instantiated Contract using `console.log`, the output appears as follows: @@ -22,10 +22,10 @@ If you have already an instantiated and deployed contract in hands you can creat <<< @./snippets/managing-deployed-contracts.ts#with-contractId{ts:line-numbers} -The previous example assumes that you have a [`Contract`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.Contract.html) instance at hand. However, some Fuel tools and Sway use the [`B256`](../types/b256.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/b256.md) type format, a hex-encoded string-like type, for contract IDs. You might have this format instead, for example, if you have deployed your contract with `forc deploy`. -The process of instantiating a [`Contract`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_program.Contract.html) remains the same when using a contract ID of type `B256`: +The process of instantiating a [`Contract`](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 db92e0c33be..794c0727359 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 f30c5a5efef..94c6a7bad71 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 364216f1d61..2f3e1d75d34 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`](./b256.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`](./b256.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} ### From an EVM Address -To create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) from an EVM address, use the following code snippet: +To create an [`Address`](DOCS_API_URL/classes/_fuel_ts_address.Address.html) from an EVM address, use the following code snippet: <<< @./snippets/address/from-an-evm-address.ts#full{ts:line-numbers} ### From an existing Address -To create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) from an existing [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) instance, use the following code snippet: +To create an [`Address`](DOCS_API_URL/classes/_fuel_ts_address.Address.html) from an existing [`Address`](DOCS_API_URL/classes/_fuel_ts_address.Address.html) instance, use the following code snippet: <<< @./snippets/address/from-an-existing-address.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 c9af27c0f35..e1d87caebd1 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/b256.md) value. The following example shows how to create an [`Address`](https://fuels-ts-docs-api.vercel.app/classes/_fuel_ts_address.Address.html) from a `B256` type: +[Asset IDs](../types/asset-id.md) are a wrapped [`B256`](../types/b256.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/). diff --git a/link-check.config.json b/link-check.config.json index e8acbc5157c..8c0b1c21b19 100644 --- a/link-check.config.json +++ b/link-check.config.json @@ -14,5 +14,15 @@ { "pattern": "https://explorer-indexer-testnet.fuel.network" } + ], + "replacementPatterns": [ + { + "pattern": "DOCS_API_URL", + "replacement": "http://localhost:9876" + }, + { + "pattern": "^modules/_fuel_ts", + "replacement": "http://localhost:9876/modules/_fuel_ts" + } ] } diff --git a/scripts/lint-md-links.ts b/scripts/lint-md-links.ts index a530688d5a1..1f7e919df42 100644 --- a/scripts/lint-md-links.ts +++ b/scripts/lint-md-links.ts @@ -1,23 +1,31 @@ #!/usr/bin/env node -import { execSync } from 'child_process'; +import { execSync, spawn } from 'child_process'; import { globSync } from 'glob'; 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'], }); - // 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));