diff --git a/.changeset/brown-scissors-search.md b/.changeset/brown-scissors-search.md deleted file mode 100644 index 8ce588212d2..00000000000 --- a/.changeset/brown-scissors-search.md +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -ci(deps): bump dawidd6/action-download-artifact from 6 to 7 diff --git a/.changeset/calm-buttons-help.md b/.changeset/calm-buttons-help.md deleted file mode 100644 index 00b00dff4cc..00000000000 --- a/.changeset/calm-buttons-help.md +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -chore: remove legacy API docs diff --git a/.changeset/cyan-panthers-carry.md b/.changeset/cyan-panthers-carry.md deleted file mode 100644 index 817ae1f110a..00000000000 --- a/.changeset/cyan-panthers-carry.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@fuel-ts/abi-typegen": patch -"@fuel-ts/contract": patch -"fuels": patch ---- - -fix: typegen and storage slots integration diff --git a/.changeset/itchy-forks-worry.md b/.changeset/itchy-forks-worry.md deleted file mode 100644 index a845151cc84..00000000000 --- a/.changeset/itchy-forks-worry.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/khaki-berries-divide.md b/.changeset/khaki-berries-divide.md deleted file mode 100644 index c7a5a85077e..00000000000 --- a/.changeset/khaki-berries-divide.md +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -chore: fix markdown lint check diff --git a/.changeset/khaki-teachers-study.md b/.changeset/khaki-teachers-study.md deleted file mode 100644 index 43c4f5fa078..00000000000 --- a/.changeset/khaki-teachers-study.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@fuel-ts/account": patch ---- - -chore: upgrade `graphql-request@6.1.0` diff --git a/.changeset/large-points-arrive.md b/.changeset/large-points-arrive.md deleted file mode 100644 index c3195aac96b..00000000000 --- a/.changeset/large-points-arrive.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -"@fuel-ts/abi-typegen": patch -"@fuel-ts/abi-coder": patch -"@fuel-ts/account": patch -"@fuel-ts/address": patch -"@fuel-ts/program": patch -"@fuel-ts/script": patch -"@fuel-ts/math": patch ---- - -chore: added noImplicitOverride option to config diff --git a/.changeset/late-pugs-carry.md b/.changeset/late-pugs-carry.md deleted file mode 100644 index 202b2028f3a..00000000000 --- a/.changeset/late-pugs-carry.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@fuel-ts/interfaces": patch -"@fuel-ts/address": patch -"@fuel-ts/errors": patch ---- - -chore: deprecate bech32 addresses diff --git a/.changeset/long-ducks-jump.md b/.changeset/long-ducks-jump.md deleted file mode 100644 index a845151cc84..00000000000 --- a/.changeset/long-ducks-jump.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/polite-impalas-fetch.md b/.changeset/polite-impalas-fetch.md deleted file mode 100644 index bcf807eabc9..00000000000 --- a/.changeset/polite-impalas-fetch.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@internal/fuel-core": patch -"@fuel-ts/versions": patch ---- - -chore: bump `fuel-core` to `0.40.1` diff --git a/.changeset/polite-mugs-stare.md b/.changeset/polite-mugs-stare.md deleted file mode 100644 index e3511505d08..00000000000 --- a/.changeset/polite-mugs-stare.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@fuel-ts/recipes": patch ---- - -docs: proxy contract cookbook diff --git a/.changeset/polite-seas-taste.md b/.changeset/polite-seas-taste.md deleted file mode 100644 index b7ea3220336..00000000000 --- a/.changeset/polite-seas-taste.md +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -chore: move type:check to lint hook diff --git a/.changeset/quiet-cups-turn.md b/.changeset/quiet-cups-turn.md deleted file mode 100644 index 2d8e72a0c71..00000000000 --- a/.changeset/quiet-cups-turn.md +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -chore: ship API documentation diff --git a/.changeset/rare-hornets-rush.md b/.changeset/rare-hornets-rush.md new file mode 100644 index 00000000000..6addec2382c --- /dev/null +++ b/.changeset/rare-hornets-rush.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/utils": patch +--- + +chore: integrate vitest matchers globally diff --git a/.changeset/red-trainers-mix.md b/.changeset/red-trainers-mix.md deleted file mode 100644 index 2459d658394..00000000000 --- a/.changeset/red-trainers-mix.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@fuel-ts/recipes": patch ---- - -chore: recipes build clean ups diff --git a/.changeset/rotten-chefs-shake.md b/.changeset/rotten-chefs-shake.md new file mode 100644 index 00000000000..21aba98f83f --- /dev/null +++ b/.changeset/rotten-chefs-shake.md @@ -0,0 +1,4 @@ +--- +--- + +docs: add docs for splitting UTXOs, `maxOutputs` and `maxInputs` \ No newline at end of file diff --git a/.changeset/spicy-mails-sort.md b/.changeset/spicy-mails-sort.md deleted file mode 100644 index 14b887f7d93..00000000000 --- a/.changeset/spicy-mails-sort.md +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -docs: improve `cookbook/transaction-request` diff --git a/.changeset/tasty-pumas-approve.md b/.changeset/tasty-pumas-approve.md deleted file mode 100644 index cf29d992cb7..00000000000 --- a/.changeset/tasty-pumas-approve.md +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -docs: document hidden tx summary methods diff --git a/.changeset/twenty-needles-buy.md b/.changeset/twenty-needles-buy.md deleted file mode 100644 index 1d73fa27fd9..00000000000 --- a/.changeset/twenty-needles-buy.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@fuel-ts/contract": patch ---- - -feat: better typegen contract factory integration with `launchTestNode` diff --git a/.changeset/wise-ladybugs-nail.md b/.changeset/wise-ladybugs-nail.md deleted file mode 100644 index c2e47010682..00000000000 --- a/.changeset/wise-ladybugs-nail.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@fuel-ts/account": patch ---- - -fix: enable `fuel-core` node cleanup to work in Bun diff --git a/apps/docs/.vitepress/config.ts b/apps/docs/.vitepress/config.ts index 406d3de6703..f1a007accd1 100644 --- a/apps/docs/.vitepress/config.ts +++ b/apps/docs/.vitepress/config.ts @@ -425,6 +425,10 @@ export default defineConfig({ text: 'Combining UTXOs', link: '/guide/cookbook/combining-utxos', }, + { + text: 'Splitting UTXOs', + link: '/guide/cookbook/splitting-utxos', + }, ], }, { diff --git a/apps/docs/README.md b/apps/docs/README.md index f7cbd7f83b6..fa97e16d3c4 100644 --- a/apps/docs/README.md +++ b/apps/docs/README.md @@ -8,6 +8,7 @@ - [Table of contents](#table-of-contents) - [Building](#building) - [Testing](#testing) + - [Referencing snippets](#referencing-snippets) ## Building @@ -42,3 +43,17 @@ If no environment is specified, it will run in the browser and node environments ```sh pnpm test ``` + +## Referencing snippets + +To reference a snippet outside of the current directory, you need to use the following syntax (`<<< @/`): + +```md +`<<< @/../../path/to/snippet.ts#snippet-name{language:line-numbers} +``` + +To reference a snippet in the current directory, you can use the following syntax (`<<< @./`): + +```md +`<<< @./snippets/transaction-request/fetch-resources.ts#transaction-request-5{ts:line-numbers} +``` diff --git a/apps/docs/spell-check-custom-words.txt b/apps/docs/spell-check-custom-words.txt index ff1ea80f563..aa3ebc175d7 100644 --- a/apps/docs/spell-check-custom-words.txt +++ b/apps/docs/spell-check-custom-words.txt @@ -291,6 +291,7 @@ tsconfig TTL tuple's turbofish +TxParameters TypeChain typeclass typedoc @@ -321,6 +322,7 @@ Utils Utils UTXO UTXOs +utxos validator validators vercel diff --git a/apps/docs/src/guide/contracts/contract-balance.md b/apps/docs/src/guide/contracts/contract-balance.md index 2aa3867ea16..aa60d1a211c 100644 --- a/apps/docs/src/guide/contracts/contract-balance.md +++ b/apps/docs/src/guide/contracts/contract-balance.md @@ -4,7 +4,7 @@ When working with contracts, it's crucial to be aware of the available contract ## 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`](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. 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 0039de9d2cf..020cea63a49 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`](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: <<< @/../../../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 718b1da118e..1511624f3e4 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](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. 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 0a71cd61400..34571fb4039 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`](https://fuels-ts-docs-api.vercel.app/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/minted-token-asset-id.md b/apps/docs/src/guide/contracts/minted-token-asset-id.md index a7cfce24f29..29d09589779 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://docs.fuel.network/docs/fuels-ts/interfaces/#assetid), 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](https://fuels-ts-docs-api.vercel.app/types/_fuel_ts_interfaces.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/cookbook/combining-utxos.md b/apps/docs/src/guide/cookbook/combining-utxos.md index e67a37f44d9..a08677e1936 100644 --- a/apps/docs/src/guide/cookbook/combining-utxos.md +++ b/apps/docs/src/guide/cookbook/combining-utxos.md @@ -9,3 +9,9 @@ One way to avoid these errors is to combine your UTXOs. This can be done by perf > **Note:** You will not be able to have a single UTXO for the base asset after combining, as one output will be for the transfer, and you will have another for the fees. <<< @./snippets/combining-utxos.ts#combining-utxos{ts:line-numbers} + +## Max Inputs and Outputs + +It's also important to note that depending on the chain configuration, you may be limited on the number of inputs and/or outputs that you can have in a transaction. These amounts can be queried via the [TxParameters](https://docs.fuel.network/docs/graphql/reference/objects/#txparameters) GraphQL query. + +<<< @./snippets/max-outputs.ts#max-outputs{ts:line-numbers} diff --git a/apps/docs/src/guide/cookbook/snippets/max-outputs.ts b/apps/docs/src/guide/cookbook/snippets/max-outputs.ts new file mode 100644 index 00000000000..82e41e7ff5b --- /dev/null +++ b/apps/docs/src/guide/cookbook/snippets/max-outputs.ts @@ -0,0 +1,13 @@ +// #region max-outputs +import { Provider } from 'fuels'; + +import { LOCAL_NETWORK_URL } from '../../../env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); + +const { maxInputs, maxOutputs } = + provider.getChain().consensusParameters.txParameters; + +// #endregion max-outputs +console.log('Max Inputs', maxInputs); +console.log('Max Outputs', maxOutputs); diff --git a/apps/docs/src/guide/cookbook/snippets/splitting-utxos.ts b/apps/docs/src/guide/cookbook/snippets/splitting-utxos.ts new file mode 100644 index 00000000000..6a8dd0e976b --- /dev/null +++ b/apps/docs/src/guide/cookbook/snippets/splitting-utxos.ts @@ -0,0 +1,59 @@ +// #region splitting-utxos +import { Provider, Wallet } from 'fuels'; + +import { LOCAL_NETWORK_URL, WALLET_PVT_KEY } from '../../../env'; + +const provider = await Provider.create(LOCAL_NETWORK_URL); +// This is the wallet that will fund the sending wallet +const fundingWallet = Wallet.fromPrivateKey(WALLET_PVT_KEY, provider); + +// This is the wallet that will send the funds +const wallet = Wallet.generate({ provider }); +// This is the wallet that will receive the funds +const destinationWallet = Wallet.generate({ provider }); + +// Let's fund the sending wallet with 1000 of the base asset +const fundingTx = await fundingWallet.transfer( + wallet.address, + 1000, + provider.getBaseAssetId() +); +await fundingTx.waitForResult(); + +// We can fetch the coins to see how many UTXOs we have and confirm it is 1 +const { coins: initialCoins } = await wallet.getCoins( + provider.getBaseAssetId() +); +console.log('Initial Coins Length', initialCoins.length); +// 1 + +// Now we can split the large 1000 UTXO into 5 UTXOs of 200 each, +// Including the address to send the funds to and the assetId we want to send +const splitTxns = new Array(5).fill({ + amount: 200, + assetId: provider.getBaseAssetId(), + destination: destinationWallet.address, +}); + +// We will also need add some funds to the wallet to cover the fee +// We could have also spent less than 200 for each UTXO, but this is just an example +const fundTx = await fundingWallet.transfer( + wallet.address, + 500, + provider.getBaseAssetId() +); +await fundTx.waitForResult(); + +console.log('Split UTXOs', splitTxns); +// [ +// { amount: 200, assetId: '0x0', destination : '0x...' }, +// { amount: 200, assetId: '0x0', destination: '0x...' }, +// { amount: 200, assetId: '0x0', destination: '0x...' }, +// { amount: 200, assetId: '0x0', destination: '0x...' }, +// { amount: 200, assetId: '0x0', destination: '0x...' } +// ] + +// Then we can send the transactions using the batchTransfer function +const batchTx = await wallet.batchTransfer(splitTxns); +await batchTx.waitForResult(); +// #endregion splitting-utxos diff --git a/apps/docs/src/guide/cookbook/splitting-utxos.md b/apps/docs/src/guide/cookbook/splitting-utxos.md new file mode 100644 index 00000000000..c7e1131629b --- /dev/null +++ b/apps/docs/src/guide/cookbook/splitting-utxos.md @@ -0,0 +1,7 @@ +# Splitting UTXOs + +There may be times when you want to split one large UTXO into multiple smaller UTXOs. This can be useful if you want to send multiple concurrent transactions without having to wait for them to be processed sequentially. + +> **Note:** Depending on how many smaller UTXOs you want to create, you may need to fund the wallet with additional funds to cover the fees. As we see in the example below, we fund the sending wallet with 500 to cover the fees for the batch transfer. + +<<< @./snippets/splitting-utxos.ts#splitting-utxos{ts:line-numbers} diff --git a/apps/docs/src/guide/predicates/methods.md b/apps/docs/src/guide/predicates/methods.md index b01557af6d6..a1d768c2a58 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://docs.fuel.network/docs/fuels-ts/account/) 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`](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: - `Checking Balances` - `Transactions` diff --git a/apps/docs/src/guide/provider/provider-options.md b/apps/docs/src/guide/provider/provider-options.md index 1eb6bab5f55..6a9ce98c1db 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/modules/_fuel_ts_account.html#provideroptions) on `Provider` instantiation to modify its behavior. +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. ### `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 118bd70bbd7..304dfc6c445 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/modules/_fuel_ts_contract.test_utils.html#launchtestnode). +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). ## Explicit Resource Management diff --git a/apps/docs/src/guide/transactions/transaction-request.md b/apps/docs/src/guide/transactions/transaction-request.md index 95ceb4847bb..6d7b7337a82 100644 --- a/apps/docs/src/guide/transactions/transaction-request.md +++ b/apps/docs/src/guide/transactions/transaction-request.md @@ -60,7 +60,7 @@ If needed, you can manually include specific coins or messages in the transactio Imagine that you have a Sway script that manually calls a contract: -<<< @../../../../sway/script-call-contract/src/main.sw#transaction-request-7{rs:line-numbers} +<<< @/../../docs/sway/script-call-contract/src/main.sw#transaction-request-7{rs:line-numbers} In those cases, you will need to add both an `InputContract` and `OutputContract` to the transaction request: diff --git a/apps/docs/src/guide/utilities/using-assets.md b/apps/docs/src/guide/utilities/using-assets.md index afe5ce152e6..88728f3b51b 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://docs.fuel.network/docs/fuels-ts/account/#asset) 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`](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). 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/modules/_fuel_ts_account.html#assetfuel) and [`AssetEth`](https://fuels-ts-docs-api.vercel.app/modules/_fuel_ts_account.html#asseteth) 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`](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). <<< @./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 08d19d9f018..6c9450dbdf7 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`](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. <<< @./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/modules/_fuel_ts_account.html#coinquantity). This is useful for getting a comprehensive view of your holdings. +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. <<< @./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 29f921c470c..5b771d08e9a 100644 --- a/apps/docs/src/guide/wallets/connectors.md +++ b/apps/docs/src/guide/wallets/connectors.md @@ -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/modules/_fuel_ts_account.html#network) object containing the current network information. +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. <<< @./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/modules/_fuel_ts_account.html#network) object containing the current network information. +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. <<< @./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/modules/_fuel_ts_account.html#asset) objects available on the network. +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. <<< @./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/modules/_fuel_ts_account.html#fuelabi) object. +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. <<< @./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/modules/_fuel_ts_account.html#transactionrequestlike)) +- `transaction` ([`TransactionRequestLike`](https://fuels-ts-docs-api.vercel.app/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/modules/_fuel_ts_account.html#asset)) that are available on the network. +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. <<< @/../../../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/modules/_fuel_ts_account.html#asset)) +- `asset` ([`Asset`](https://fuels-ts-docs-api.vercel.app/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/modules/_fuel_ts_account.html#asset)). +- `assets` (an Array of [`Asset`](https://fuels-ts-docs-api.vercel.app/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/modules/_fuel_ts_account.html#network)). +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)). <<< @/../../../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/modules/_fuel_ts_account.html#network)). +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)). <<< @/../../../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/modules/_fuel_ts_account.html#network)) +- `network` ([`Network`](https://fuels-ts-docs-api.vercel.app/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/modules/_fuel_ts_account.html#fuelabi)). +- `abi` ([`FuelABI`](https://fuels-ts-docs-api.vercel.app/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/modules/_fuel_ts_account.html#fuelabi)) or `null` if the data is unavailable. +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. <<< @/../../../packages/account/src/connectors/fuel-connector.ts#fuel-connector-method-getABI{ts:line-numbers} diff --git a/internal/benchmarks/CHANGELOG.md b/internal/benchmarks/CHANGELOG.md index 8b84540a0ea..c062bac1c9b 100644 --- a/internal/benchmarks/CHANGELOG.md +++ b/internal/benchmarks/CHANGELOG.md @@ -1,5 +1,12 @@ # @internal/benchmarks +## 1.0.9 + +### Patch Changes + +- Updated dependencies [2cef020] + - fuels@0.97.1 + ## 1.0.8 ### Patch Changes diff --git a/internal/benchmarks/package.json b/internal/benchmarks/package.json index f7531e44bb1..1bc55986896 100644 --- a/internal/benchmarks/package.json +++ b/internal/benchmarks/package.json @@ -14,5 +14,5 @@ "fuels": "workspace:*", "@internal/utils": "workspace:*" }, - "version": "1.0.8" + "version": "1.0.9" } diff --git a/internal/check-imports/CHANGELOG.md b/internal/check-imports/CHANGELOG.md index 9091dd7ab9b..3cff6c2142b 100644 --- a/internal/check-imports/CHANGELOG.md +++ b/internal/check-imports/CHANGELOG.md @@ -1,5 +1,36 @@ # @internal/check-imports +## 0.0.16 + +### Patch Changes + +- Updated dependencies [2cef020] +- Updated dependencies [260274a] +- Updated dependencies [c904a98] +- Updated dependencies [27e8808] +- Updated dependencies [7390114] +- Updated dependencies [3a178b0] +- Updated dependencies [165c49c] +- Updated dependencies [6ab3e6b] +- Updated dependencies [4131e74] + - @fuel-ts/abi-typegen@0.97.1 + - @fuel-ts/contract@0.97.1 + - fuels@0.97.1 + - @fuel-ts/account@0.97.1 + - @fuel-ts/abi-coder@0.97.1 + - @fuel-ts/address@0.97.1 + - @fuel-ts/program@0.97.1 + - @fuel-ts/script@0.97.1 + - @fuel-ts/math@0.97.1 + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/errors@0.97.1 + - @fuel-ts/versions@0.97.1 + - @fuel-ts/transactions@0.97.1 + - @fuel-ts/crypto@0.97.1 + - @fuel-ts/merkle@0.97.1 + - @fuel-ts/utils@0.97.1 + - @fuel-ts/hasher@0.97.1 + ## 0.0.15 ### Patch Changes diff --git a/internal/check-imports/package.json b/internal/check-imports/package.json index e1ae86efdda..9e825284c71 100644 --- a/internal/check-imports/package.json +++ b/internal/check-imports/package.json @@ -27,5 +27,5 @@ "@fuel-ts/account": "workspace:*", "fuels": "workspace:*" }, - "version": "0.0.15" + "version": "0.0.16" } diff --git a/internal/fuel-core/CHANGELOG.md b/internal/fuel-core/CHANGELOG.md index 2e0d9a173b5..538df4a12c2 100644 --- a/internal/fuel-core/CHANGELOG.md +++ b/internal/fuel-core/CHANGELOG.md @@ -1,5 +1,11 @@ # @internal/fuel-core +## 0.89.6 + +### Patch Changes + +- 165c49c: chore: bump `fuel-core` to `0.40.1` + ## 0.89.5 ### Patch Changes diff --git a/internal/fuel-core/package.json b/internal/fuel-core/package.json index 113b7b54117..523ab4a3a9c 100644 --- a/internal/fuel-core/package.json +++ b/internal/fuel-core/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@internal/fuel-core", - "version": "0.89.5", + "version": "0.89.6", "description": "NPM bin wrapper around `fuel-core`", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/abi-coder/CHANGELOG.md b/packages/abi-coder/CHANGELOG.md index 55f902ab466..260fd961c27 100644 --- a/packages/abi-coder/CHANGELOG.md +++ b/packages/abi-coder/CHANGELOG.md @@ -1,5 +1,19 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- c904a98: chore: added noImplicitOverride option to config +- Updated dependencies [c904a98] +- Updated dependencies [27e8808] + - @fuel-ts/math@0.97.1 + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/errors@0.97.1 + - @fuel-ts/crypto@0.97.1 + - @fuel-ts/utils@0.97.1 + - @fuel-ts/hasher@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/abi-coder/package.json b/packages/abi-coder/package.json index 2b3e07d7cfc..47ae912974d 100644 --- a/packages/abi-coder/package.json +++ b/packages/abi-coder/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/abi-coder", - "version": "0.97.0", + "version": "0.97.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/abi-typegen/CHANGELOG.md b/packages/abi-typegen/CHANGELOG.md index 3b3507849dd..3045edcd58c 100644 --- a/packages/abi-typegen/CHANGELOG.md +++ b/packages/abi-typegen/CHANGELOG.md @@ -1,5 +1,18 @@ # @fuel-ts/abi-typegen +## 0.97.1 + +### Patch Changes + +- 2cef020: fix: typegen and storage slots integration +- c904a98: chore: added noImplicitOverride option to config +- Updated dependencies [27e8808] +- Updated dependencies [165c49c] + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/errors@0.97.1 + - @fuel-ts/versions@0.97.1 + - @fuel-ts/utils@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/abi-typegen/package.json b/packages/abi-typegen/package.json index e43d35c3328..b3f96c2002a 100644 --- a/packages/abi-typegen/package.json +++ b/packages/abi-typegen/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/abi-typegen", - "version": "0.97.0", + "version": "0.97.1", "description": "Generates Typescript definitions from Sway ABI Json files", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/abi-typegen/src/cli.test.ts b/packages/abi-typegen/src/cli.test.ts index 4c4a1d55716..c960b9a48d2 100644 --- a/packages/abi-typegen/src/cli.test.ts +++ b/packages/abi-typegen/src/cli.test.ts @@ -164,7 +164,7 @@ describe('cli.ts', () => { test('should handle errors when running cli action', () => { const runTypegenError = new Error('Pretty message'); - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); const { exit } = mockDeps({ runTypegenError }); const inputs = ['*-no-abis-here.json']; diff --git a/packages/abi-typegen/src/runTypegen.test.ts b/packages/abi-typegen/src/runTypegen.test.ts index 2ea943f2c98..3fe0e2ae1bb 100644 --- a/packages/abi-typegen/src/runTypegen.test.ts +++ b/packages/abi-typegen/src/runTypegen.test.ts @@ -153,7 +153,7 @@ describe('runTypegen.js', () => { }); test('should log messages to stdout', async () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); // setup temp sway project const project = getTypegenForcProject(AbiTypegenProjectsEnum.SCRIPT); @@ -272,7 +272,7 @@ describe('runTypegen.js', () => { cpSync(fromBin, toBin); // mocking - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); // executes program const fn = () => diff --git a/packages/account/CHANGELOG.md b/packages/account/CHANGELOG.md index 64ec897515a..7aa0a1fb5c7 100644 --- a/packages/account/CHANGELOG.md +++ b/packages/account/CHANGELOG.md @@ -1,5 +1,29 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- 260274a: chore: upgrade `graphql-request@6.1.0` +- c904a98: chore: added noImplicitOverride option to config +- 7390114: fix: `transferToContract` method now allows big numbers +- 3a178b0: chore: avoid re-estimate `gasPrice` at `estimateTxDependencies` +- 4131e74: fix: enable `fuel-core` node cleanup to work in Bun +- Updated dependencies [c904a98] +- Updated dependencies [27e8808] +- Updated dependencies [165c49c] + - @fuel-ts/abi-coder@0.97.1 + - @fuel-ts/address@0.97.1 + - @fuel-ts/math@0.97.1 + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/errors@0.97.1 + - @fuel-ts/versions@0.97.1 + - @fuel-ts/transactions@0.97.1 + - @fuel-ts/crypto@0.97.1 + - @fuel-ts/merkle@0.97.1 + - @fuel-ts/utils@0.97.1 + - @fuel-ts/hasher@0.97.1 + ## 0.97.0 ### Minor Changes diff --git a/packages/account/package.json b/packages/account/package.json index e38e30885f5..73ba68c9cec 100644 --- a/packages/account/package.json +++ b/packages/account/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/account", - "version": "0.97.0", + "version": "0.97.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/account/src/account.ts b/packages/account/src/account.ts index 112aaaaa318..60484577999 100644 --- a/packages/account/src/account.ts +++ b/packages/account/src/account.ts @@ -323,6 +323,7 @@ export class Account extends AbstractAccount { const { maxFee } = await this.provider.estimateTxGasAndFee({ transactionRequest: requestToReestimate, + gasPrice, }); request.maxFee = maxFee; diff --git a/packages/account/src/providers/provider.test.ts b/packages/account/src/providers/provider.test.ts index 4c32b9c5f2a..d9775e3252d 100644 --- a/packages/account/src/providers/provider.test.ts +++ b/packages/account/src/providers/provider.test.ts @@ -250,7 +250,7 @@ describe('Provider', () => { }); // Spy on console.warn - const consoleWarnSpy = vi.spyOn(console, 'warn'); + const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); // Verify that only one transaction was returned (the known type) const transaction = await mockProvider.getTransaction('0x1234567890abcdef'); @@ -298,7 +298,7 @@ describe('Provider', () => { }); // Spy on console.warn - const consoleWarnSpy = vi.spyOn(console, 'warn'); + const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); // Verify that only one transaction was returned (the known type) const { transactions } = await mockProvider.getTransactions(); @@ -448,7 +448,7 @@ describe('Provider', () => { using launched = await setupTestProviderAndWallets(); const { provider } = launched; - const { cleanup, url } = await launchNode({ port: '0' }); + const { cleanup, url } = await launchNode({ port: '0', loggingEnabled: false }); const spyFetchChainAndNodeInfo = vi.spyOn(Provider.prototype, 'fetchChainAndNodeInfo'); @@ -1181,7 +1181,7 @@ describe('Provider', () => { const spy = vi.spyOn(fuelTsVersionsMod, 'checkFuelCoreVersionCompatibility'); spy.mockImplementationOnce(() => mock); - const consoleWarnSpy = vi.spyOn(console, 'warn'); + const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); using launched = await setupTestProviderAndWallets(); const { provider } = launched; @@ -1216,7 +1216,7 @@ Supported fuel-core version: ${mock.supportedVersion}.` const spy = vi.spyOn(fuelTsVersionsMod, 'checkFuelCoreVersionCompatibility'); spy.mockImplementationOnce(() => mock); - const consoleWarnSpy = vi.spyOn(console, 'warn'); + const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); using launched = await setupTestProviderAndWallets(); const { provider } = launched; diff --git a/packages/account/src/providers/provider.ts b/packages/account/src/providers/provider.ts index b07bcfd1d67..5f9ffe88f42 100644 --- a/packages/account/src/providers/provider.ts +++ b/packages/account/src/providers/provider.ts @@ -1011,6 +1011,7 @@ Supported fuel-core version: ${supportedVersion}.` } = await this.operations.dryRun({ encodedTransactions: [hexlify(transactionRequest.toTransactionBytes())], utxoValidation: false, + gasPrice: '0', }); receipts = rawReceipts.map(processGqlReceipt); @@ -1032,6 +1033,7 @@ Supported fuel-core version: ${supportedVersion}.` const { maxFee } = await this.estimateTxGasAndFee({ transactionRequest, + gasPrice: bn(0), }); // eslint-disable-next-line no-param-reassign @@ -1204,7 +1206,7 @@ Supported fuel-core version: ${supportedVersion}.` const { gasPriceFactor, maxGasPerTx } = this.getGasConfig(); const minGas = transactionRequest.calculateMinGas(chainInfo); - if (!gasPrice) { + if (!isDefined(gasPrice)) { gasPrice = await this.estimateGasPrice(10); } diff --git a/packages/account/src/test-utils/launchNode.test.ts b/packages/account/src/test-utils/launchNode.test.ts index 410ca85ac32..ab52fd47603 100644 --- a/packages/account/src/test-utils/launchNode.test.ts +++ b/packages/account/src/test-utils/launchNode.test.ts @@ -117,7 +117,7 @@ describe('launchNode', () => { }); test('should throw on error and log error message', { timeout: 15000 }, async () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); const invalidCoin = { asset_id: 'whatever', @@ -132,7 +132,7 @@ describe('launchNode', () => { const error = await expectToThrowFuelError( async () => launchNode({ - loggingEnabled: false, + loggingEnabled: true, snapshotConfig: { ...defaultSnapshotConfigs, stateConfig: { @@ -238,7 +238,7 @@ describe('launchNode', () => { test('calling cleanup on externally killed node does not throw', async () => { const mkdirSyncSpy = vi.spyOn(fsMod, 'mkdirSync'); - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); const { pid, cleanup } = await launchNode({ loggingEnabled: false }); expect(mkdirSyncSpy).toHaveBeenCalledTimes(1); diff --git a/packages/account/src/test-utils/launchNode.ts b/packages/account/src/test-utils/launchNode.ts index d88ac171ab0..2e24f9ce4ee 100644 --- a/packages/account/src/test-utils/launchNode.ts +++ b/packages/account/src/test-utils/launchNode.ts @@ -314,6 +314,9 @@ export const launchNode = async ({ } }); + // Increase the max listeners to avoid a warning + process.setMaxListeners(100); + // Process exit. process.on('exit', cleanup); diff --git a/packages/account/src/utils/formatTransferToContractScriptData.test.ts b/packages/account/src/utils/formatTransferToContractScriptData.test.ts index 956677fe332..1cee087afa1 100644 --- a/packages/account/src/utils/formatTransferToContractScriptData.test.ts +++ b/packages/account/src/utils/formatTransferToContractScriptData.test.ts @@ -72,4 +72,27 @@ describe('util', () => { expect(arrayify).toHaveBeenCalledTimes(2); expect(encode).toHaveBeenCalledTimes(1); }); + + it('should ensure "formatScriptDataForTransferringToContract" returns script data just fine', () => { + const contractId = '0xf3eb53ed00347d305fc6f6e3a57e91ea6c3182a9efc253488db29494f63c9610'; + const amount: BigNumberish = bn(2).pow(64).sub(1); // Max u64 + const assetId: BytesLike = '0x0f622143ec845f9095bdf02d80273ac48556efcf9f95c1fdadb9351fd8ffcd24'; + + const scriptData = formatTransferToContractScriptData([ + { + contractId, + amount, + assetId, + }, + ]); + + expect(scriptData).toStrictEqual( + new Uint8Array([ + 243, 235, 83, 237, 0, 52, 125, 48, 95, 198, 246, 227, 165, 126, 145, 234, 108, 49, 130, 169, + 239, 194, 83, 72, 141, 178, 148, 148, 246, 60, 150, 16, 255, 255, 255, 255, 255, 255, 255, + 255, 15, 98, 33, 67, 236, 132, 95, 144, 149, 189, 240, 45, 128, 39, 58, 196, 133, 86, 239, + 207, 159, 149, 193, 253, 173, 185, 53, 31, 216, 255, 205, 36, + ]) + ); + }); }); diff --git a/packages/account/src/utils/formatTransferToContractScriptData.ts b/packages/account/src/utils/formatTransferToContractScriptData.ts index d290ccbd949..1c441314e4c 100644 --- a/packages/account/src/utils/formatTransferToContractScriptData.ts +++ b/packages/account/src/utils/formatTransferToContractScriptData.ts @@ -1,7 +1,7 @@ import { ASSET_ID_LEN, BigNumberCoder, CONTRACT_ID_LEN, WORD_SIZE } from '@fuel-ts/abi-coder'; import { Address } from '@fuel-ts/address'; import type { BytesLike } from '@fuel-ts/interfaces'; -import { BN } from '@fuel-ts/math'; +import type { BN } from '@fuel-ts/math'; import { arrayify, concat } from '@fuel-ts/utils'; import * as asm from '@fuels/vm-asm'; @@ -17,7 +17,7 @@ export const formatTransferToContractScriptData = ( const numberCoder = new BigNumberCoder('u64'); return transferParams.reduce((acc, transferParam) => { const { assetId, amount, contractId } = transferParam; - const encoded = numberCoder.encode(new BN(amount).toNumber()); + const encoded = numberCoder.encode(amount); const scriptData = concat([ Address.fromAddressOrString(contractId).toBytes(), encoded, diff --git a/packages/address/CHANGELOG.md b/packages/address/CHANGELOG.md index f23afee5e59..6dee7356960 100644 --- a/packages/address/CHANGELOG.md +++ b/packages/address/CHANGELOG.md @@ -1,5 +1,17 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- c904a98: chore: added noImplicitOverride option to config +- 27e8808: chore: deprecate bech32 addresses +- Updated dependencies [27e8808] + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/errors@0.97.1 + - @fuel-ts/crypto@0.97.1 + - @fuel-ts/utils@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/address/package.json b/packages/address/package.json index 6e6a0426e41..87fc595fd74 100644 --- a/packages/address/package.json +++ b/packages/address/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/address", - "version": "0.97.0", + "version": "0.97.1", "description": "Utilities for encoding and decoding addresses", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/contract/CHANGELOG.md b/packages/contract/CHANGELOG.md index aa19fb66913..081db43f4d0 100644 --- a/packages/contract/CHANGELOG.md +++ b/packages/contract/CHANGELOG.md @@ -1,5 +1,31 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- 2cef020: fix: typegen and storage slots integration +- 6ab3e6b: feat: better typegen contract factory integration with `launchTestNode` +- Updated dependencies [260274a] +- Updated dependencies [c904a98] +- Updated dependencies [27e8808] +- Updated dependencies [7390114] +- Updated dependencies [3a178b0] +- Updated dependencies [165c49c] +- Updated dependencies [4131e74] + - @fuel-ts/account@0.97.1 + - @fuel-ts/abi-coder@0.97.1 + - @fuel-ts/program@0.97.1 + - @fuel-ts/math@0.97.1 + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/errors@0.97.1 + - @fuel-ts/versions@0.97.1 + - @fuel-ts/transactions@0.97.1 + - @fuel-ts/crypto@0.97.1 + - @fuel-ts/merkle@0.97.1 + - @fuel-ts/utils@0.97.1 + - @fuel-ts/hasher@0.97.1 + ## 0.97.0 ### Minor Changes diff --git a/packages/contract/package.json b/packages/contract/package.json index 74997bfa3f3..efbd33ea195 100644 --- a/packages/contract/package.json +++ b/packages/contract/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/contract", - "version": "0.97.0", + "version": "0.97.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/create-fuels/CHANGELOG.md b/packages/create-fuels/CHANGELOG.md index 837e0b37665..51dacbda2d0 100644 --- a/packages/create-fuels/CHANGELOG.md +++ b/packages/create-fuels/CHANGELOG.md @@ -1,5 +1,14 @@ # create-fuels +## 0.97.1 + +### Patch Changes + +- Updated dependencies [27e8808] +- Updated dependencies [165c49c] + - @fuel-ts/errors@0.97.1 + - @fuel-ts/versions@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/create-fuels/package.json b/packages/create-fuels/package.json index 78783fa6b25..fa4dd3840b0 100644 --- a/packages/create-fuels/package.json +++ b/packages/create-fuels/package.json @@ -1,6 +1,6 @@ { "name": "create-fuels", - "version": "0.97.0", + "version": "0.97.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/create-fuels/src/utils/logger.test.ts b/packages/create-fuels/src/utils/logger.test.ts index 3a3344abbd1..fc13e87d273 100644 --- a/packages/create-fuels/src/utils/logger.test.ts +++ b/packages/create-fuels/src/utils/logger.test.ts @@ -28,7 +28,7 @@ describe('logger', () => { }); test('should log', () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); configureLogging({ isLoggingEnabled: true, isDebugEnabled: false }); log('message'); expect(logSpy).toHaveBeenCalledTimes(1); @@ -36,7 +36,7 @@ describe('logger', () => { }); test('should not log', () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); configureLogging({ isLoggingEnabled: false, isDebugEnabled: false }); log('any message'); @@ -44,7 +44,7 @@ describe('logger', () => { }); test('should debug', () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); configureLogging({ isLoggingEnabled: true, isDebugEnabled: true }); debug('message'); @@ -53,7 +53,7 @@ describe('logger', () => { }); test('should not log', () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); configureLogging({ isLoggingEnabled: false, isDebugEnabled: false }); loggerMod.debug('any debug message'); @@ -61,14 +61,14 @@ describe('logger', () => { }); test('should warn', () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); warn('message1', 'message2'); expect(logSpy).toHaveBeenCalledTimes(1); expect(logSpy).toHaveBeenCalledWith(chalk.yellow('message1 message2')); }); test('should error', () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); error('message1', 'message2'); expect(logSpy).toHaveBeenCalledTimes(1); expect(logSpy).toHaveBeenCalledWith(chalk.red('message1 message2')); diff --git a/packages/crypto/CHANGELOG.md b/packages/crypto/CHANGELOG.md index a635ec1eb0c..4b3754b39f8 100644 --- a/packages/crypto/CHANGELOG.md +++ b/packages/crypto/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- Updated dependencies [c904a98] +- Updated dependencies [27e8808] + - @fuel-ts/math@0.97.1 + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/errors@0.97.1 + - @fuel-ts/utils@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 396e92ae580..dfd2c6727bd 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/crypto", - "version": "0.97.0", + "version": "0.97.1", "description": "Utilities for encrypting and decrypting data", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/errors/CHANGELOG.md b/packages/errors/CHANGELOG.md index 494c2b2ef88..ea6166e2a5a 100644 --- a/packages/errors/CHANGELOG.md +++ b/packages/errors/CHANGELOG.md @@ -1,5 +1,13 @@ # @fuel-ts/errors +## 0.97.1 + +### Patch Changes + +- 27e8808: chore: deprecate bech32 addresses +- Updated dependencies [165c49c] + - @fuel-ts/versions@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/errors/package.json b/packages/errors/package.json index 46b08fb86d8..fad17a07904 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/errors", - "version": "0.97.0", + "version": "0.97.1", "description": "Error class and error codes that the fuels-ts library throws", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/fuel-gauge/src/abi/abi-coder.test.ts b/packages/fuel-gauge/src/abi/abi-coder.test.ts index cf3b9459fbd..5f7fe677b1a 100644 --- a/packages/fuel-gauge/src/abi/abi-coder.test.ts +++ b/packages/fuel-gauge/src/abi/abi-coder.test.ts @@ -47,9 +47,6 @@ import { U8_MAX, U8_MIN, } from './constants'; -import { toEqualBn } from './vitest.matcher'; - -expect.extend({ toEqualBn }); /** * @group browser @@ -761,7 +758,6 @@ describe('AbiCoder', () => { const EXPECTED_STRUCT = { a: { - // @ts-expect-error: Custom matcher 'toEqualBn' a: expect.toEqualBn(20), }, b: 'B', @@ -885,7 +881,6 @@ describe('AbiCoder', () => { describe('types_struct_with_tuple', () => { it('should encode/decode just fine', async () => { const input: StructSingleGenericInput<[boolean, BigNumberish]> = { a: [true, 10] }; - // @ts-expect-error: Custom matcher 'toEqualBn' const expected = { a: [false, expect.toEqualBn(20)] }; const { waitForResult } = await contract.functions.types_struct_with_tuple(input).call(); @@ -942,7 +937,6 @@ describe('AbiCoder', () => { describe('types_struct_external', () => { it('should encode/decode just fine', async () => { const input = { value: 10 }; - // @ts-expect-error: Custom matcher 'toEqualBn' const expected = { value: expect.toEqualBn(20) }; const { waitForResult } = await contract.functions.types_struct_external(input).call(); @@ -1136,7 +1130,6 @@ describe('AbiCoder', () => { it('should encode/decode just fine', async () => { const INPUT_STRUCT = { a: { a: 10 }, b: 'A' }; const input: StructWithNestedArrayInput = { a: [INPUT_STRUCT, INPUT_STRUCT] }; - // @ts-expect-error: Custom matcher 'toEqualBn' const EXPECTED_STRUCT = { a: { a: expect.toEqualBn(20) }, b: 'B' }; const EXPECTED = { a: [EXPECTED_STRUCT, EXPECTED_STRUCT] }; @@ -1170,7 +1163,6 @@ describe('AbiCoder', () => { describe('types_struct_with_nested_tuple', () => { it('should encode/decode just fine', async () => { const input: StructWithNestedTupleInput = { a: [10, { a: { a: 20 } }, 'ABC'] }; - // @ts-expect-error: Custom matcher 'toEqualBn' const expected = { a: [30, { a: { a: expect.toEqualBn(40) } }, 'CBA'] }; const { waitForResult } = await contract.functions @@ -1375,7 +1367,6 @@ describe('AbiCoder', () => { StructSingleGenericInput>, string, ]; - // @ts-expect-error: Custom matcher 'toEqualBn' const expected = [3, { a: { a: expect.toEqualBn(30) } }, 'CBA']; const { waitForResult } = await contract.functions.types_tuple_complex(input).call(); @@ -1505,7 +1496,6 @@ describe('AbiCoder', () => { describe('types_enum_with_builtin_type', () => { it('should encode/decode just fine', async () => { const input: EnumWithBuiltinTypeInput = { a: true }; - // @ts-expect-error: Custom matcher 'toEqualBn' const expected: EnumWithBuiltinTypeOutput = { b: expect.toEqualBn(20) }; const { waitForResult } = await contract.functions.types_enum_with_builtin_type(input).call(); @@ -2053,7 +2043,6 @@ describe('AbiCoder', () => { Ok: 10, }; const expected: Result = { - // @ts-expect-error: Custom matcher 'toEqualBn' Ok: expect.toEqualBn(2), }; @@ -2292,7 +2281,6 @@ describe('AbiCoder', () => { it('should encode/decode just fine', async () => { const inputX = 1; const inputY = 2; - // @ts-expect-error: Custom matcher 'toEqualBn' const expected = expect.toEqualBn(3); const { waitForResult } = await contract.functions.multi_arg_u64_u64(inputX, inputY).call(); diff --git a/packages/fuel-gauge/src/abi/vitest.matcher.ts b/packages/fuel-gauge/src/abi/vitest.matcher.ts deleted file mode 100644 index 32a1cd3b4a8..00000000000 --- a/packages/fuel-gauge/src/abi/vitest.matcher.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { bn } from 'fuels'; -import type { BNInput } from 'fuels'; - -export const toEqualBn = (_received: BNInput, _argument: BNInput) => { - const received = bn(_received); - const argument = bn(_argument); - - const pass = received.eq(argument); - - if (pass) { - return { - message: () => `Expected ${received.toString()} not to equal ${argument.toString()}`, - pass: true, - }; - } - return { - message: () => `expected ${received.toString()} to equal ${argument.toString()}`, - pass: false, - }; -}; diff --git a/packages/fuel-gauge/src/contract.test.ts b/packages/fuel-gauge/src/contract.test.ts index baeccb057a8..04fe5dffc7d 100644 --- a/packages/fuel-gauge/src/contract.test.ts +++ b/packages/fuel-gauge/src/contract.test.ts @@ -691,6 +691,83 @@ describe('Contract', () => { expect(finalBalance).toBe(initialBalance + amountToContract.toNumber()); }); + it('should transferToContract with a large amount of assets', async () => { + using launched = await launchTestNode({ + contractsConfigs, + walletsConfig: { + amountPerCoin: 2 ** 62, + }, + }); + const { + provider, + wallets: [wallet], + contracts: [contract], + } = launched; + + const initialBalance = new BN(await contract.getBalance(provider.getBaseAssetId())).toNumber(); + const amountToContract = bn(2).pow(62); // Very big number + + const tx = await wallet.transferToContract( + contract.id, + amountToContract, + provider.getBaseAssetId() + ); + + await tx.waitForResult(); + + const finalBalance = new BN(await contract.getBalance(provider.getBaseAssetId())).toString(); + expect(finalBalance).toBe(amountToContract.add(initialBalance).toString()); + }); + + it('should batch transfer with a large amount of assets', async () => { + using launched = await launchTestNode({ + contractsConfigs, + walletsConfig: { + amountPerCoin: 2 ** 62, + }, + }); + const { + provider, + wallets: [wallet], + contracts: [contract], + } = launched; + + const baseAssetId = provider.getBaseAssetId(); + const contractTransferParams: ContractTransferParams[] = [ + { + contractId: contract.id, + amount: bn(2).pow(50), + assetId: baseAssetId, + }, + { + contractId: contract.id, + amount: bn(2).pow(10), + assetId: baseAssetId, + }, + ]; + + const tx = await wallet.batchTransferToContracts(contractTransferParams); + + const { receipts } = await tx.waitForResult(); + + const transferReceipts = receipts.filter( + ({ type }) => type === ReceiptType.Transfer + ) as ReceiptTransfer[]; + + expect(transferReceipts.length).toBe(contractTransferParams.length); + + contractTransferParams.forEach(({ amount, contractId, assetId = baseAssetId }) => { + const foundReceipt = transferReceipts.find( + (r) => + r.amount.eq(amount) && + r.to.toLowerCase() === contractId.toString().toLowerCase() && + r.assetId === assetId + ); + + expect(foundReceipt).toBeDefined(); + }); + }); + it('should transfer assets to deployed contracts just fine', async () => { using launched = await launchTestNode({ contractsConfigs: [ diff --git a/packages/fuel-gauge/src/fee.test.ts b/packages/fuel-gauge/src/fee.test.ts index 17b87f5d055..f5c5a53440e 100644 --- a/packages/fuel-gauge/src/fee.test.ts +++ b/packages/fuel-gauge/src/fee.test.ts @@ -3,6 +3,7 @@ import { InputMessageCoder, ScriptTransactionRequest, Wallet, + getMintedAssetId, getRandomB256, hexlify, isCoin, @@ -40,6 +41,8 @@ describe('Fee', () => { } }; + const SUB_ID = '0x4a778acfad1abc155a009dc976d2cf0db6197d3d360194d74b1fb92b96986b00'; + it('should ensure fee is properly calculated when minting and burning coins', async () => { using launched = await launchTestNode({ contractsConfigs: [ @@ -431,5 +434,81 @@ describe('Fee', () => { expect(cost.dryRunStatus?.type).toBe('DryRunSuccessStatus'); }); + + it('should not run estimateGasPrice in between estimateTxDependencies dry run attempts', async () => { + using launched = await launchTestNode({ + contractsConfigs: [ + { + factory: MultiTokenContractFactory, + }, + ], + }); + + const { + contracts: [contract], + wallets: [wallet], + provider, + } = launched; + + const assetId = getMintedAssetId(contract.id.toB256(), SUB_ID); + + // Minting coins first + const mintCall = await contract.functions.mint_coins(SUB_ID, 10_000).call(); + await mintCall.waitForResult(); + + const estimateGasPrice = vi.spyOn(provider, 'estimateGasPrice'); + const dryRun = vi.spyOn(provider.operations, 'dryRun'); + + /** + * Sway transfer without adding `OutputVariable` which will result in + * 2 dry runs at the `Provider.estimateTxDependencies` method: + * - 1st dry run will fail due to missing `OutputVariable` + * - 2nd dry run will succeed + */ + const transferCall = await contract.functions + .transfer_to_address({ bits: wallet.address.toB256() }, { bits: assetId }, 10_000) + .call(); + + await transferCall.waitForResult(); + + expect(estimateGasPrice).toHaveBeenCalledOnce(); + expect(dryRun).toHaveBeenCalledTimes(2); + }); + + it('should ensure estimateGasPrice runs only once when funding a transaction.', async () => { + const amountPerCoin = 100; + + using launched = await launchTestNode({ + walletsConfig: { + amountPerCoin, // Funding with multiple UTXOs so the fee will change after funding the TX. + coinsPerAsset: 250, + }, + contractsConfigs: [ + { + factory: MultiTokenContractFactory, + }, + ], + }); + + const { + wallets: [wallet], + provider, + } = launched; + + const fund = vi.spyOn(wallet, 'fund'); + const estimateGasPrice = vi.spyOn(provider, 'estimateGasPrice'); + + const tx = await wallet.transfer( + wallet.address, + amountPerCoin * 20, + provider.getBaseAssetId() + ); + const { isStatusSuccess } = await tx.waitForResult(); + + expect(fund).toHaveBeenCalledOnce(); + expect(estimateGasPrice).toHaveBeenCalledOnce(); + + expect(isStatusSuccess).toBeTruthy(); + }); }); }); diff --git a/packages/fuels/CHANGELOG.md b/packages/fuels/CHANGELOG.md index 2bb1dff2305..6486ee8373b 100644 --- a/packages/fuels/CHANGELOG.md +++ b/packages/fuels/CHANGELOG.md @@ -1,5 +1,39 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- 2cef020: fix: typegen and storage slots integration +- Updated dependencies [2cef020] +- Updated dependencies [260274a] +- Updated dependencies [c904a98] +- Updated dependencies [27e8808] +- Updated dependencies [7390114] +- Updated dependencies [3a178b0] +- Updated dependencies [165c49c] +- Updated dependencies [ef94263] +- Updated dependencies [283a684] +- Updated dependencies [6ab3e6b] +- Updated dependencies [4131e74] + - @fuel-ts/abi-typegen@0.97.1 + - @fuel-ts/contract@0.97.1 + - @fuel-ts/account@0.97.1 + - @fuel-ts/abi-coder@0.97.1 + - @fuel-ts/address@0.97.1 + - @fuel-ts/program@0.97.1 + - @fuel-ts/script@0.97.1 + - @fuel-ts/math@0.97.1 + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/errors@0.97.1 + - @fuel-ts/versions@0.97.1 + - @fuel-ts/recipes@0.97.1 + - @fuel-ts/transactions@0.97.1 + - @fuel-ts/crypto@0.97.1 + - @fuel-ts/merkle@0.97.1 + - @fuel-ts/utils@0.97.1 + - @fuel-ts/hasher@0.97.1 + ## 0.97.0 ### Minor Changes diff --git a/packages/fuels/package.json b/packages/fuels/package.json index 2a4a4a4bda1..f45ef4266b3 100644 --- a/packages/fuels/package.json +++ b/packages/fuels/package.json @@ -1,6 +1,6 @@ { "name": "fuels", - "version": "0.97.0", + "version": "0.97.1", "description": "Fuel TS SDK", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/fuels/src/cli/commands/build/buildSwayProgram.test.ts b/packages/fuels/src/cli/commands/build/buildSwayProgram.test.ts index f10c9968f35..d91ef982b67 100644 --- a/packages/fuels/src/cli/commands/build/buildSwayProgram.test.ts +++ b/packages/fuels/src/cli/commands/build/buildSwayProgram.test.ts @@ -56,7 +56,7 @@ describe('buildSwayPrograms', () => { test('logs to console when logging is enabled', async () => { const { spawn } = mockAll(); - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); configureLogging({ isLoggingEnabled: true, isDebugEnabled: false }); @@ -70,7 +70,7 @@ describe('buildSwayPrograms', () => { test('logs debug to console when debug is enabled', async () => { const { spawn } = mockAll(); - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); configureLogging({ isLoggingEnabled: true, isDebugEnabled: true }); await buildSwayProgram(fuelsConfig, '/any/workspace/path'); diff --git a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts index d950c510c91..f5290233ed9 100644 --- a/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts +++ b/packages/fuels/src/cli/commands/dev/autoStartFuelCore.test.ts @@ -26,7 +26,7 @@ describe('autoStartFuelCore', () => { }); }); - function mockLaunchNode() { + function mockAll() { const launchNode = vi.spyOn(testUtilsMod, 'launchNode').mockReturnValue( Promise.resolve({ cleanup: () => {}, @@ -37,11 +37,12 @@ describe('autoStartFuelCore', () => { pid: 1234, }) ); - return { launchNode }; + const log = vi.spyOn(console, 'log').mockImplementation(() => {}); + return { launchNode, log }; } test('should auto start `fuel-core`', async () => { - const { launchNode } = mockLaunchNode(); + const { launchNode, log } = mockAll(); const config = structuredClone(fuelsConfig); config.autoStartFuelCore = true; @@ -49,10 +50,11 @@ describe('autoStartFuelCore', () => { await autoStartFuelCore(config); expect(launchNode).toHaveBeenCalledTimes(1); + expect(log).toHaveBeenCalledTimes(1); }); test('should not start `fuel-core`', async () => { - const { launchNode } = mockLaunchNode(); + const { launchNode, log } = mockAll(); const config = structuredClone(fuelsConfig); config.autoStartFuelCore = false; @@ -60,10 +62,11 @@ describe('autoStartFuelCore', () => { await autoStartFuelCore(config); expect(launchNode).toHaveBeenCalledTimes(0); + expect(log).toHaveBeenCalledTimes(0); }); test('should start `fuel-core` node using custom binary', async () => { - const { launchNode } = mockLaunchNode(); + const { launchNode, log } = mockAll(); const copyConfig: FuelsConfig = structuredClone(fuelsConfig); copyConfig.fuelCorePath = 'fuels-core'; @@ -86,12 +89,13 @@ describe('autoStartFuelCore', () => { fuelCorePath: 'fuels-core', }) ); + expect(log).toHaveBeenCalledTimes(1); core.killChildProcess(); }); test('should start `fuel-core` node using system binary', async () => { - const { launchNode } = mockLaunchNode(); + const { launchNode, log } = mockAll(); const config = structuredClone(fuelsConfig); const core = (await autoStartFuelCore(config)) as FuelCoreNode; @@ -103,6 +107,7 @@ describe('autoStartFuelCore', () => { expect(core.port).toBeGreaterThanOrEqual(4000); expect(core.providerUrl).toMatch(/http:\/\/127\.0\.0\.1:([0-9]+)\/v1\/graphql/); expect(core.killChildProcess).toBeTruthy(); + expect(log).toHaveBeenCalledTimes(1); core.killChildProcess(); }); diff --git a/packages/fuels/src/cli/utils/checkForAndDisplayUpdates.test.ts b/packages/fuels/src/cli/utils/checkForAndDisplayUpdates.test.ts index 113f70f096d..d58f57fb47d 100644 --- a/packages/fuels/src/cli/utils/checkForAndDisplayUpdates.test.ts +++ b/packages/fuels/src/cli/utils/checkForAndDisplayUpdates.test.ts @@ -26,8 +26,8 @@ describe('checkForAndDisplayUpdates', () => { FUEL_CORE: '1.0.0', }); - const log = vi.spyOn(loggerMod, 'log'); - const warn = vi.spyOn(loggerMod, 'warn'); + const log = vi.spyOn(loggerMod, 'log').mockImplementation(() => {}); + const warn = vi.spyOn(loggerMod, 'warn').mockImplementation(() => {}); return { log, warn }; }; @@ -67,7 +67,7 @@ describe('checkForAndDisplayUpdates', () => { new Error('Failed to fetch') ); - const log = vi.spyOn(loggerMod, 'log'); + const log = vi.spyOn(loggerMod, 'log').mockImplementation(() => {}); await checkForAndDisplayUpdatesMod.checkForAndDisplayUpdates(); diff --git a/packages/fuels/src/cli/utils/logger.test.ts b/packages/fuels/src/cli/utils/logger.test.ts index 7c8cd22069c..82f8d48fd97 100644 --- a/packages/fuels/src/cli/utils/logger.test.ts +++ b/packages/fuels/src/cli/utils/logger.test.ts @@ -26,7 +26,7 @@ describe('logger', () => { }); test('should log', () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); configureLogging({ isLoggingEnabled: true, isDebugEnabled: false }); log('message'); expect(logSpy).toHaveBeenCalledTimes(1); @@ -34,7 +34,7 @@ describe('logger', () => { }); test('should not log', () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); configureLogging({ isLoggingEnabled: false, isDebugEnabled: false }); log('any message'); @@ -42,7 +42,7 @@ describe('logger', () => { }); test('should debug', () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); configureLogging({ isLoggingEnabled: true, isDebugEnabled: true }); debug('message'); @@ -51,7 +51,7 @@ describe('logger', () => { }); test('should not log', () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); configureLogging({ isLoggingEnabled: false, isDebugEnabled: false }); loggerMod.debug('any debug message'); @@ -59,14 +59,14 @@ describe('logger', () => { }); test('should warn', () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); warn('message1', 'message2'); expect(logSpy).toHaveBeenCalledTimes(1); expect(logSpy).toHaveBeenCalledWith(chalk.yellow('message1 message2')); }); test('should error', () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); error('message1', 'message2'); expect(logSpy).toHaveBeenCalledTimes(1); expect(logSpy).toHaveBeenCalledWith(chalk.red('message1 message2')); diff --git a/packages/fuels/test/features/build.test.ts b/packages/fuels/test/features/build.test.ts index 4c2956c1c9f..f03a6388419 100644 --- a/packages/fuels/test/features/build.test.ts +++ b/packages/fuels/test/features/build.test.ts @@ -1,4 +1,4 @@ -import { existsSync, readFileSync, writeFileSync } from 'fs'; +import { existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'fs'; import { join } from 'path'; import * as deployMod from '../../src/cli/commands/deploy/index'; @@ -24,6 +24,7 @@ describe('build', { timeout: 180000 }, () => { afterEach(() => { resetConfigAndMocks(paths.fuelsConfigPath); + rmSync(paths.outputDir, { recursive: true, force: true }); }); afterAll(() => { @@ -76,12 +77,12 @@ describe('build', { timeout: 180000 }, () => { expect(killChildProcess).toHaveBeenCalledTimes(0); }); - it('should run `build` command with contracts-only', async () => { + it('should run `build` command with contracts-only [single contract]', async () => { const { autoStartFuelCore, killChildProcess, deploy } = mockAll(); await runInit({ root: paths.root, - contracts: paths.contractsDir, + contracts: paths.contractsFooDir, output: paths.outputDir, forcPath: paths.forcPath, fuelCorePath: paths.fuelCorePath, @@ -96,7 +97,42 @@ describe('build', { timeout: 180000 }, () => { 'index.ts', ].map((f) => join(paths.outputDir, f)); - files.forEach((file) => expect(existsSync(file)).toBeTruthy()); + files.forEach((file) => expect(existsSync(file), `${file} does not exist`).toBeTruthy()); + expect(readdirSync(paths.outputContractsDir)).toHaveLength(3); + + expect(autoStartFuelCore).toHaveBeenCalledTimes(0); + expect(deploy).toHaveBeenCalledTimes(0); + expect(killChildProcess).toHaveBeenCalledTimes(0); + }); + + it('should run `build` command with contracts-only [with glob]', async () => { + const { autoStartFuelCore, killChildProcess, deploy } = mockAll(); + + await runInit({ + root: paths.root, + contracts: `${paths.contractsDir}/*`, + output: paths.outputDir, + forcPath: paths.forcPath, + fuelCorePath: paths.fuelCorePath, + }); + + await runBuild({ root: paths.root }); + + const files = [ + 'contracts/UpgradableChunked.ts', + 'contracts/UpgradableChunkedFactory.ts', + 'contracts/Upgradable.ts', + 'contracts/UpgradableFactory.ts', + 'contracts/BarFoo.ts', + 'contracts/BarFooFactory.ts', + 'contracts/FooBar.ts', + 'contracts/FooBarFactory.ts', + 'contracts/index.ts', + 'index.ts', + ].map((f) => join(paths.outputDir, f)); + + files.forEach((file) => expect(existsSync(file), `${file} does not exist`).toBeTruthy()); + expect(readdirSync(paths.outputContractsDir)).toHaveLength(9); expect(autoStartFuelCore).toHaveBeenCalledTimes(0); expect(deploy).toHaveBeenCalledTimes(0); diff --git a/packages/fuels/test/features/init.test.ts b/packages/fuels/test/features/init.test.ts index 93b9fd72b7e..4c7be45929f 100644 --- a/packages/fuels/test/features/init.test.ts +++ b/packages/fuels/test/features/init.test.ts @@ -87,7 +87,7 @@ describe('init', () => { }); it('should error if no inputs/workspace is supplied', async () => { - const logSpy = vi.spyOn(console, 'log'); + const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {}); const exit = vi.spyOn(process, 'exit').mockResolvedValue({} as never); await runCommand(Commands.init, ['--path', paths.root, '-o', paths.outputDir]); diff --git a/packages/fuels/test/utils/runCommands.ts b/packages/fuels/test/utils/runCommands.ts index 88fd9edf656..3558d04eb97 100644 --- a/packages/fuels/test/utils/runCommands.ts +++ b/packages/fuels/test/utils/runCommands.ts @@ -40,14 +40,17 @@ export function bootstrapProject(testFilepath: string) { cpSync(sampleWorkspaceDir, workspaceDir, { recursive: true }); const contractsDir = join(workspaceDir, 'contracts'); + const contractsBarDir = join(contractsDir, 'bar'); const contractsFooDir = join(contractsDir, 'foo'); - const scriptsDir = join(workspaceDir, 'scripts'); - const predicateDir = join(workspaceDir, 'predicate'); const fooContractMainPath = join(contractsDir, 'foo', 'src', 'main.sw'); const upgradableContractPath = join(contractsDir, 'upgradable'); const upgradableChunkedContractPath = join(contractsDir, 'upgradable-chunked'); + const scriptsDir = join(workspaceDir, 'scripts'); + const predicateDir = join(workspaceDir, 'predicate'); + const outputDir = join(root, 'output'); + const outputContractsDir = join(outputDir, 'contracts'); const contractsJsonPath = join(outputDir, 'contract-ids.json'); const fooContractFactoryPath = join(outputDir, 'contracts', 'factories', 'FooBarAbi.ts'); @@ -58,7 +61,11 @@ export function bootstrapProject(testFilepath: string) { root, workspaceDir, contractsDir, + outputContractsDir, + contractsBarDir, contractsFooDir, + upgradableContractPath, + upgradableChunkedContractPath, scriptsDir, predicateDir, fooContractMainPath, @@ -68,8 +75,6 @@ export function bootstrapProject(testFilepath: string) { fooContractFactoryPath, forcPath, fuelCorePath, - upgradableContractPath, - upgradableChunkedContractPath, }; } diff --git a/packages/hasher/CHANGELOG.md b/packages/hasher/CHANGELOG.md index a1ac99d67db..b5a55e7bde2 100644 --- a/packages/hasher/CHANGELOG.md +++ b/packages/hasher/CHANGELOG.md @@ -1,5 +1,14 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- Updated dependencies [27e8808] + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/crypto@0.97.1 + - @fuel-ts/utils@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/hasher/package.json b/packages/hasher/package.json index 34ae2bf02f4..3106a7004ca 100644 --- a/packages/hasher/package.json +++ b/packages/hasher/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/hasher", - "version": "0.97.0", + "version": "0.97.1", "description": "Sha256 hash utility for Fuel", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/interfaces/CHANGELOG.md b/packages/interfaces/CHANGELOG.md index 9327f53c299..753c62ae787 100644 --- a/packages/interfaces/CHANGELOG.md +++ b/packages/interfaces/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- 27e8808: chore: deprecate bech32 addresses + ## 0.97.0 ## 0.96.1 diff --git a/packages/interfaces/package.json b/packages/interfaces/package.json index 8ded2e27a61..ae371647051 100644 --- a/packages/interfaces/package.json +++ b/packages/interfaces/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/interfaces", - "version": "0.97.0", + "version": "0.97.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/logger/CHANGELOG.md b/packages/logger/CHANGELOG.md index 6304643e90b..b3ebef2b05d 100644 --- a/packages/logger/CHANGELOG.md +++ b/packages/logger/CHANGELOG.md @@ -1,5 +1,15 @@ # @fuel-ts/logger +## 0.97.1 + +### Patch Changes + +- Updated dependencies [c904a98] +- Updated dependencies [27e8808] + - @fuel-ts/address@0.97.1 + - @fuel-ts/math@0.97.1 + - @fuel-ts/interfaces@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/logger/package.json b/packages/logger/package.json index 6a67289ae5c..6f40bba1365 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/logger", - "version": "0.97.0", + "version": "0.97.1", "author": "Fuel Labs (https://fuel.network/)", "description": "A logger for the Fuel-TS ecosystem", "main": "dist/index.js", diff --git a/packages/math/CHANGELOG.md b/packages/math/CHANGELOG.md index 1d388ce35e2..0f569c049f6 100644 --- a/packages/math/CHANGELOG.md +++ b/packages/math/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- c904a98: chore: added noImplicitOverride option to config +- Updated dependencies [27e8808] + - @fuel-ts/errors@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/math/package.json b/packages/math/package.json index 20a3e18a851..73bd309d3bb 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/math", - "version": "0.97.0", + "version": "0.97.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/merkle/CHANGELOG.md b/packages/merkle/CHANGELOG.md index 79de6b50ed1..feede49d5e9 100644 --- a/packages/merkle/CHANGELOG.md +++ b/packages/merkle/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- Updated dependencies [c904a98] + - @fuel-ts/math@0.97.1 + - @fuel-ts/hasher@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/merkle/package.json b/packages/merkle/package.json index f197b3390b2..dff1ea558b9 100644 --- a/packages/merkle/package.json +++ b/packages/merkle/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/merkle", - "version": "0.97.0", + "version": "0.97.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/program/CHANGELOG.md b/packages/program/CHANGELOG.md index 40f185c8ff8..07403a9873c 100644 --- a/packages/program/CHANGELOG.md +++ b/packages/program/CHANGELOG.md @@ -1,5 +1,25 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- c904a98: chore: added noImplicitOverride option to config +- Updated dependencies [260274a] +- Updated dependencies [c904a98] +- Updated dependencies [27e8808] +- Updated dependencies [7390114] +- Updated dependencies [3a178b0] +- Updated dependencies [4131e74] + - @fuel-ts/account@0.97.1 + - @fuel-ts/abi-coder@0.97.1 + - @fuel-ts/address@0.97.1 + - @fuel-ts/math@0.97.1 + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/errors@0.97.1 + - @fuel-ts/transactions@0.97.1 + - @fuel-ts/utils@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/program/package.json b/packages/program/package.json index 8ae76833db3..2a33d9eefad 100644 --- a/packages/program/package.json +++ b/packages/program/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/program", - "version": "0.97.0", + "version": "0.97.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/recipes/CHANGELOG.md b/packages/recipes/CHANGELOG.md index 420e6f23d0e..d2a1ad0acfe 100644 --- a/packages/recipes/CHANGELOG.md +++ b/packages/recipes/CHANGELOG.md @@ -1 +1,24 @@ # Change Log + +## 0.97.1 + +### Patch Changes + +- ef94263: docs: proxy contract cookbook +- 283a684: chore: recipes build clean ups +- Updated dependencies [2cef020] +- Updated dependencies [260274a] +- Updated dependencies [c904a98] +- Updated dependencies [27e8808] +- Updated dependencies [7390114] +- Updated dependencies [3a178b0] +- Updated dependencies [6ab3e6b] +- Updated dependencies [4131e74] + - @fuel-ts/abi-typegen@0.97.1 + - @fuel-ts/contract@0.97.1 + - @fuel-ts/account@0.97.1 + - @fuel-ts/abi-coder@0.97.1 + - @fuel-ts/program@0.97.1 + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/transactions@0.97.1 + - @fuel-ts/utils@0.97.1 diff --git a/packages/recipes/package.json b/packages/recipes/package.json index ad436f02427..05200e09806 100644 --- a/packages/recipes/package.json +++ b/packages/recipes/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/recipes", - "version": "0.97.0", + "version": "0.97.1", "description": "Recipes for Sway Programs", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", @@ -20,10 +20,10 @@ "dist" ], "scripts": { - "build": "run-s build:package build:recipes build:format", - "build:package": "tsup", + "build": "run-s build:recipes build:package build:format", "build:recipes": "tsx ./scripts/build-recipes.ts", - "build:format": "prettier --config ../../.prettierrc --write .", + "build:package": "tsup", + "build:format": "prettier --config ../../.prettierrc --log-level error --write .", "postbuild": "tsx ../../scripts/postbuild.ts" }, "license": "Apache-2.0", diff --git a/packages/script/CHANGELOG.md b/packages/script/CHANGELOG.md index ded10d0a36e..2b3759ee417 100644 --- a/packages/script/CHANGELOG.md +++ b/packages/script/CHANGELOG.md @@ -1,5 +1,26 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- c904a98: chore: added noImplicitOverride option to config +- Updated dependencies [260274a] +- Updated dependencies [c904a98] +- Updated dependencies [27e8808] +- Updated dependencies [7390114] +- Updated dependencies [3a178b0] +- Updated dependencies [4131e74] + - @fuel-ts/account@0.97.1 + - @fuel-ts/abi-coder@0.97.1 + - @fuel-ts/address@0.97.1 + - @fuel-ts/program@0.97.1 + - @fuel-ts/math@0.97.1 + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/errors@0.97.1 + - @fuel-ts/transactions@0.97.1 + - @fuel-ts/utils@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/script/package.json b/packages/script/package.json index ead7b90d01f..390a175c337 100644 --- a/packages/script/package.json +++ b/packages/script/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/script", - "version": "0.97.0", + "version": "0.97.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/transactions/CHANGELOG.md b/packages/transactions/CHANGELOG.md index 5cec914b256..d656ed16123 100644 --- a/packages/transactions/CHANGELOG.md +++ b/packages/transactions/CHANGELOG.md @@ -1,5 +1,19 @@ # Change Log +## 0.97.1 + +### Patch Changes + +- Updated dependencies [c904a98] +- Updated dependencies [27e8808] + - @fuel-ts/abi-coder@0.97.1 + - @fuel-ts/address@0.97.1 + - @fuel-ts/math@0.97.1 + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/errors@0.97.1 + - @fuel-ts/utils@0.97.1 + - @fuel-ts/hasher@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/transactions/package.json b/packages/transactions/package.json index 3e9ca1f06f7..2cd41236c50 100644 --- a/packages/transactions/package.json +++ b/packages/transactions/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/transactions", - "version": "0.97.0", + "version": "0.97.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index bb2358f5e9f..eba5e7e7931 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -1,5 +1,17 @@ # @fuel-ts/utils +## 0.97.1 + +### Patch Changes + +- Updated dependencies [c904a98] +- Updated dependencies [27e8808] +- Updated dependencies [165c49c] + - @fuel-ts/math@0.97.1 + - @fuel-ts/interfaces@0.97.1 + - @fuel-ts/errors@0.97.1 + - @fuel-ts/versions@0.97.1 + ## 0.97.0 ### Patch Changes diff --git a/packages/utils/package.json b/packages/utils/package.json index fb25a551622..484d3f1d12b 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/utils", - "version": "0.97.0", + "version": "0.97.1", "description": "Utilities (and test utilities) collection", "author": "Fuel Labs (https://fuel.network/)", "main": "dist/index.js", diff --git a/packages/utils/src/test-utils.ts b/packages/utils/src/test-utils.ts index bfad80a17ed..266fa8b5b55 100644 --- a/packages/utils/src/test-utils.ts +++ b/packages/utils/src/test-utils.ts @@ -2,3 +2,4 @@ export * from './test-utils/getForcProject'; export * from './test-utils/expectToBeInRange'; export * from './test-utils/constants'; export * from './test-utils/wait-until-unreachable'; +export * from './test-utils/vitest.matchers'; diff --git a/packages/utils/src/test-utils/vitest.matchers.ts b/packages/utils/src/test-utils/vitest.matchers.ts new file mode 100644 index 00000000000..0240caa917e --- /dev/null +++ b/packages/utils/src/test-utils/vitest.matchers.ts @@ -0,0 +1,37 @@ +import { bn } from '@fuel-ts/math'; +import type { BN, BNInput } from '@fuel-ts/math'; + +interface Matchers { + toEqualBn: (expected: BNInput) => R; +} +declare module 'vitest' { + interface Assertion extends Matchers {} + interface AsymmetricMatchersContaining extends Matchers {} + interface ExpectStatic { + toEqualBn(expected: BNInput): BN; + } +} + +export const setupTestMatchers = () => { + expect.extend({ + toEqualBn(received: BNInput, expected: BNInput) { + const actualBn = bn(received); + const expectedBn = bn(expected); + const pass = actualBn.eq(expectedBn); + + if (pass) { + return { + pass, + message: () => `Expected ${actualBn} not to equal ${expectedBn}`, + actual: actualBn, + }; + } + + return { + pass, + message: () => `Expected ${actualBn} to equal ${expectedBn}`, + actual: expectedBn, + }; + }, + }); +}; diff --git a/packages/utils/src/utils/toUtf8String.test.ts b/packages/utils/src/utils/toUtf8String.test.ts index c61f36079e7..263c434bfdd 100644 --- a/packages/utils/src/utils/toUtf8String.test.ts +++ b/packages/utils/src/utils/toUtf8String.test.ts @@ -5,6 +5,10 @@ import { toUtf8String } from './toUtf8String'; * @group browser */ describe('toUtf8String', () => { + beforeAll(() => { + vi.spyOn(console, 'log').mockImplementation(() => {}); + }); + it('should convert valid UTF-8 bytes to a string', () => { const bytes = new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]); expect(toUtf8String(bytes)).toEqual('Hello World'); diff --git a/packages/versions/CHANGELOG.md b/packages/versions/CHANGELOG.md index 976d41f169e..765642b0c49 100644 --- a/packages/versions/CHANGELOG.md +++ b/packages/versions/CHANGELOG.md @@ -1,5 +1,11 @@ # @fuel-ts/versions +## 0.97.1 + +### Patch Changes + +- 165c49c: chore: bump `fuel-core` to `0.40.1` + ## 0.97.0 ### Patch Changes diff --git a/packages/versions/package.json b/packages/versions/package.json index 46eb544e4af..37578dcf2a8 100644 --- a/packages/versions/package.json +++ b/packages/versions/package.json @@ -1,6 +1,6 @@ { "name": "@fuel-ts/versions", - "version": "0.97.0", + "version": "0.97.1", "description": "Validates supported versions of the Fuel toolchain", "author": "Fuel Labs (https://fuel.network/)", "bin": { diff --git a/packages/versions/src/lib/checkFuelCoreVersionCompatibility.test.ts b/packages/versions/src/lib/checkFuelCoreVersionCompatibility.test.ts index 5753e268b32..3a71c11b4dd 100644 --- a/packages/versions/src/lib/checkFuelCoreVersionCompatibility.test.ts +++ b/packages/versions/src/lib/checkFuelCoreVersionCompatibility.test.ts @@ -69,7 +69,7 @@ describe('getDifferenceToUserFuelCoreVersion', () => { }); it("warns when the version doesn't conform to strict major.minor.patch versioning (e.g. nightly build)", () => { - const consoleWarnSpy = vi.spyOn(console, 'warn'); + const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); vi.spyOn(getBuiltinVersionsMod, 'getBuiltinVersions').mockImplementation(() => ({ FUELS: '1', // not under test @@ -92,7 +92,7 @@ This unreleased fuel-core build may include features and updates not yet support FUEL_CORE: '0.1.2', })); - const consoleWarnSpy = vi.spyOn(console, 'warn'); + const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); checkFuelCoreVersionCompatibility('0.1.2'); diff --git a/packages/versions/src/lib/getBuiltinVersions.ts b/packages/versions/src/lib/getBuiltinVersions.ts index b5b099e5ee0..66829a030dc 100644 --- a/packages/versions/src/lib/getBuiltinVersions.ts +++ b/packages/versions/src/lib/getBuiltinVersions.ts @@ -4,6 +4,6 @@ export function getBuiltinVersions(): Versions { return { FORC: '0.66.4', FUEL_CORE: '0.40.1', - FUELS: '0.97.0', + FUELS: '0.97.1', }; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 96063a81597..ad3495498f4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,7 +31,7 @@ importers: version: 6.0.0 '@codspeed/vitest-plugin': specifier: ^3.1.1 - version: 3.1.1(vite@5.4.9(@types/node@22.5.5)(terser@5.36.0))(vitest@2.0.5) + version: 3.1.1(vite@5.4.9(@types/node@22.5.5)(terser@5.36.0))(vitest@2.0.5(@types/node@22.5.5)(@vitest/browser@2.0.5)(jsdom@16.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.4))(terser@5.36.0)) '@fuel-ts/utils': specifier: workspace:* version: link:packages/utils @@ -70,7 +70,7 @@ importers: version: 2.0.5(bufferutil@4.0.8)(playwright@1.47.2)(typescript@5.6.3)(utf-8-validate@6.0.4)(vitest@2.0.5)(webdriverio@9.0.9(bufferutil@4.0.8)(utf-8-validate@6.0.4)) '@vitest/coverage-istanbul': specifier: ~2.0.5 - version: 2.0.5(vitest@2.0.5) + version: 2.0.5(vitest@2.0.5(@types/node@22.5.5)(@vitest/browser@2.0.5)(jsdom@16.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.4))(terser@5.36.0)) autocannon: specifier: ^7.15.0 version: 7.15.0 @@ -18738,7 +18738,7 @@ snapshots: transitivePeerDependencies: - debug - '@codspeed/vitest-plugin@3.1.1(vite@5.4.9(@types/node@22.5.5)(terser@5.36.0))(vitest@2.0.5)': + '@codspeed/vitest-plugin@3.1.1(vite@5.4.9(@types/node@22.5.5)(terser@5.36.0))(vitest@2.0.5(@types/node@22.5.5)(@vitest/browser@2.0.5)(jsdom@16.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.4))(terser@5.36.0))': dependencies: '@codspeed/core': 3.1.1 vite: 5.4.9(@types/node@22.5.5)(terser@5.36.0) @@ -22873,7 +22873,7 @@ snapshots: - typescript - utf-8-validate - '@vitest/coverage-istanbul@2.0.5(vitest@2.0.5)': + '@vitest/coverage-istanbul@2.0.5(vitest@2.0.5(@types/node@22.5.5)(@vitest/browser@2.0.5)(jsdom@16.7.0(bufferutil@4.0.8)(utf-8-validate@6.0.4))(terser@5.36.0))': dependencies: '@istanbuljs/schema': 0.1.3 debug: 4.3.7(supports-color@5.5.0) diff --git a/vitest.setup-files.ts b/vitest.setup-files.ts new file mode 100644 index 00000000000..8cd866cc303 --- /dev/null +++ b/vitest.setup-files.ts @@ -0,0 +1,3 @@ +import { setupTestMatchers } from '@fuel-ts/utils/test-utils'; + +setupTestMatchers(); diff --git a/vitest.shared.config.mts b/vitest.shared.config.mts index dbde7fc4409..799cd7bc2e5 100644 --- a/vitest.shared.config.mts +++ b/vitest.shared.config.mts @@ -17,6 +17,7 @@ export default defineConfig({ esbuild: { target: "es2022" }, test: { globalSetup: ["vitest.global-setup.ts"], + setupFiles: ["./vitest.setup-files.ts"], coverage: { enabled: true, provider: "istanbul",