diff --git a/.changeset/pink-mails-dream.md b/.changeset/pink-mails-dream.md new file mode 100644 index 00000000000..c21bc99f984 --- /dev/null +++ b/.changeset/pink-mails-dream.md @@ -0,0 +1,4 @@ +--- +--- + +chore: update `amountPerCoin` prop in `WalletConfig` to accept BN 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.' 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 {