From 61c17219c7d61d871e46e9fcd96cad768aedf53e Mon Sep 17 00:00:00 2001 From: BenRey Date: Wed, 27 Nov 2024 11:09:00 +0100 Subject: [PATCH] Update balancesOf method in MRC20 contract to accept final parameter and adjust related tests --- src/contracts-wrappers/token.ts | 11 +++++++---- test/integration/MRC20.spec.ts | 14 +++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/contracts-wrappers/token.ts b/src/contracts-wrappers/token.ts index 2c2a67a4..636a8a4d 100644 --- a/src/contracts-wrappers/token.ts +++ b/src/contracts-wrappers/token.ts @@ -1,4 +1,4 @@ -import { Args, bytesToStr, strToBytes, U256, U8 } from '../basicElements' +import { Args, bytesToStr, U256, U8 } from '../basicElements' import { Operation } from '../operation' import { CallSCOptions, ReadSCOptions, SmartContract } from '../smartContracts' @@ -85,7 +85,10 @@ export class MRC20 extends SmartContract { return U256.fromBytes(res.value) } - async balancesOf(addresses: string[]): Promise< + async balancesOf( + addresses: string[], + final = true + ): Promise< { address: string balance: bigint @@ -93,8 +96,8 @@ export class MRC20 extends SmartContract { > { const res = await this.provider.readStorage( this.address, - addresses.map((a) => strToBytes(`BALANCE${a}`)), - true + addresses.map((a) => `BALANCE${a}`), + final ) return res.map((v, i) => ({ diff --git a/test/integration/MRC20.spec.ts b/test/integration/MRC20.spec.ts index ad9fe922..8c42ca33 100644 --- a/test/integration/MRC20.spec.ts +++ b/test/integration/MRC20.spec.ts @@ -1,4 +1,4 @@ -import { account, Account } from '../../src' +import { Account } from '../../src' import { MRC20 } from '../../src/contracts-wrappers' import { provider } from './setup' @@ -94,18 +94,18 @@ describe('Generic token wrapper tests', () => { expect(balance).toBe(0n) } - const operation = await usdcContract.transfer( - recipientAddresses[0], - amounts[0] - ) + await usdcContract.transfer(recipientAddresses[0], amounts[0]) const operation2 = await usdcContract.transfer( recipientAddresses[1], amounts[1] ) - await operation2.waitFinalExecution() + await operation2.waitSpeculativeExecution() - const recipientBalance = await usdcContract.balancesOf(recipientAddresses) + const recipientBalance = await usdcContract.balancesOf( + recipientAddresses, + false + ) expect(recipientBalance[0].balance).toBe(amounts[0]) expect(recipientBalance[0].address).toBe(recipientAddresses[0])