From 674218db1ad93d7eeb98452ce9eadd6da9a87abf Mon Sep 17 00:00:00 2001 From: Torres-ssf Date: Thu, 16 Jan 2025 08:48:35 -0300 Subject: [PATCH 1/7] made setupTestProviderAndWallets accept bn amount --- packages/account/src/test-utils/wallet-config.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/account/src/test-utils/wallet-config.ts b/packages/account/src/test-utils/wallet-config.ts index 0715819a4f5..1086d323093 100644 --- a/packages/account/src/test-utils/wallet-config.ts +++ b/packages/account/src/test-utils/wallet-config.ts @@ -1,5 +1,6 @@ import { randomBytes } from '@fuel-ts/crypto'; import { FuelError } from '@fuel-ts/errors'; +import { bn, type BigNumberish } from '@fuel-ts/math'; import { defaultSnapshotConfigs, hexlify, type SnapshotConfigs } from '@fuel-ts/utils'; import type { PartialDeep } from 'type-fest'; @@ -29,7 +30,7 @@ export interface WalletsConfigOptions { /** * For each coin, the amount it'll contain. */ - amountPerCoin: number; + amountPerCoin: BigNumberish; /** * Messages that are supposed to be on the wallet. @@ -105,7 +106,7 @@ export class WalletsConfig { baseAssetId: string, assets: number | TestAssetId[], coinsPerAsset: number, - amountPerCoin: number + amountPerCoin: BigNumberish ) { const coins: SnapshotConfigs['stateConfig']['coins'] = []; @@ -122,7 +123,7 @@ export class WalletsConfig { assetIds.forEach((assetId) => { for (let index = 0; index < coinsPerAsset; index++) { coins.push({ - amount: amountPerCoin, + amount: bn(amountPerCoin), asset_id: assetId, owner: walletAddress, tx_pointer_block_height: 0, @@ -167,7 +168,7 @@ export class WalletsConfig { 'Number of coins per asset must be greater than zero.' ); } - if (amountPerCoin < 0) { + if (bn(amountPerCoin).lt(0)) { throw new FuelError( FuelError.CODES.INVALID_INPUT_PARAMETERS, 'Amount per coin must be greater than or equal to zero.' From edd1f433a37d6ad1bfe16c880dae581205a2a5a2 Mon Sep 17 00:00:00 2001 From: Torres-ssf Date: Thu, 16 Jan 2025 08:48:44 -0300 Subject: [PATCH 2/7] update test case --- packages/fuel-gauge/src/contract.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/fuel-gauge/src/contract.test.ts b/packages/fuel-gauge/src/contract.test.ts index 1f7d38cc9a0..46cc029706d 100644 --- a/packages/fuel-gauge/src/contract.test.ts +++ b/packages/fuel-gauge/src/contract.test.ts @@ -701,7 +701,7 @@ describe('Contract', () => { using launched = await launchTestNode({ contractsConfigs, walletsConfig: { - amountPerCoin: 2 ** 62, + amountPerCoin: bn(2).pow(62), }, }); const { @@ -713,7 +713,7 @@ describe('Contract', () => { const initialBalance = new BN( await contract.getBalance(await provider.getBaseAssetId()) ).toNumber(); - const amountToContract = bn(2).pow(62); // Very big number + const amountToContract = bn(2).pow(61); // Very big number const tx = await wallet.transferToContract( contract.id, @@ -733,7 +733,7 @@ describe('Contract', () => { using launched = await launchTestNode({ contractsConfigs, walletsConfig: { - amountPerCoin: 2 ** 62, + amountPerCoin: bn(2).pow(62), }, }); const { From e208883872d3be45052fafd3c26072db50b49e1b Mon Sep 17 00:00:00 2001 From: Torres-ssf Date: Thu, 16 Jan 2025 08:53:59 -0300 Subject: [PATCH 3/7] add changeset --- .changeset/pink-mails-dream.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .changeset/pink-mails-dream.md diff --git a/.changeset/pink-mails-dream.md b/.changeset/pink-mails-dream.md new file mode 100644 index 00000000000..ec71f5966ee --- /dev/null +++ b/.changeset/pink-mails-dream.md @@ -0,0 +1,4 @@ +--- +--- + +test: update `amountPerCoin` prop in `WalletConfig` to accept BN From 68fa119512a274f13a4a2fd865864bec718a9fbb Mon Sep 17 00:00:00 2001 From: Torres-ssf Date: Thu, 16 Jan 2025 08:57:44 -0300 Subject: [PATCH 4/7] fix changeset --- .changeset/pink-mails-dream.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/pink-mails-dream.md b/.changeset/pink-mails-dream.md index ec71f5966ee..c21bc99f984 100644 --- a/.changeset/pink-mails-dream.md +++ b/.changeset/pink-mails-dream.md @@ -1,4 +1,4 @@ --- --- -test: update `amountPerCoin` prop in `WalletConfig` to accept BN +chore: update `amountPerCoin` prop in `WalletConfig` to accept BN From a70f1bf7670428c82b97d51b5eb4616634194c2d Mon Sep 17 00:00:00 2001 From: Torres-ssf Date: Thu, 23 Jan 2025 13:24:33 -0300 Subject: [PATCH 5/7] modify property type --- packages/utils/src/utils/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/utils/src/utils/types.ts b/packages/utils/src/utils/types.ts index 680ac900abf..662649b8dd8 100644 --- a/packages/utils/src/utils/types.ts +++ b/packages/utils/src/utils/types.ts @@ -1,4 +1,4 @@ -import type { BN } from '@fuel-ts/math'; +import type { BigNumberish, BN } from '@fuel-ts/math'; interface Coin { tx_id: string; @@ -6,7 +6,7 @@ interface Coin { tx_pointer_block_height: number; tx_pointer_tx_idx: number; owner: string; - amount: number | BN; + amount: BigNumberish; asset_id: string; } From 7fa3ba736119ad168aa968fb0ba11d5942c5e43c Mon Sep 17 00:00:00 2001 From: Torres-ssf Date: Thu, 23 Jan 2025 13:25:14 -0300 Subject: [PATCH 6/7] adjusting test coin amount type --- packages/account/src/test-utils/wallet-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/account/src/test-utils/wallet-config.ts b/packages/account/src/test-utils/wallet-config.ts index 1086d323093..7cd6ae84b34 100644 --- a/packages/account/src/test-utils/wallet-config.ts +++ b/packages/account/src/test-utils/wallet-config.ts @@ -123,7 +123,7 @@ export class WalletsConfig { assetIds.forEach((assetId) => { for (let index = 0; index < coinsPerAsset; index++) { coins.push({ - amount: bn(amountPerCoin), + amount: bn(amountPerCoin).toString(), asset_id: assetId, owner: walletAddress, tx_pointer_block_height: 0, From 0478cd778ccdcb57c610fa90dfa9d6ce560ce01b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Torres?= <30977845+Torres-ssf@users.noreply.github.com> Date: Thu, 23 Jan 2025 14:08:57 -0300 Subject: [PATCH 7/7] Update .changeset/pink-mails-dream.md Co-authored-by: Peter Smith --- .changeset/pink-mails-dream.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.changeset/pink-mails-dream.md b/.changeset/pink-mails-dream.md index c21bc99f984..f40584f090e 100644 --- a/.changeset/pink-mails-dream.md +++ b/.changeset/pink-mails-dream.md @@ -1,4 +1,6 @@ --- +"@fuel-ts/account": patch +"@fuel-ts/utils": patch --- chore: update `amountPerCoin` prop in `WalletConfig` to accept BN