Skip to content

Commit

Permalink
Update balancesOf method in MRC20 contract to accept final parameter …
Browse files Browse the repository at this point in the history
…and adjust related tests
  • Loading branch information
Ben-Rey committed Nov 27, 2024
1 parent dd84f87 commit 61c1721
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
11 changes: 7 additions & 4 deletions src/contracts-wrappers/token.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -85,16 +85,19 @@ export class MRC20 extends SmartContract {
return U256.fromBytes(res.value)
}

async balancesOf(addresses: string[]): Promise<
async balancesOf(

Check warning on line 88 in src/contracts-wrappers/token.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
addresses: string[],
final = true

Check warning on line 90 in src/contracts-wrappers/token.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
): Promise<
{
address: string
balance: bigint
}[]
> {
const res = await this.provider.readStorage(
this.address,
addresses.map((a) => strToBytes(`BALANCE${a}`)),
true
addresses.map((a) => `BALANCE${a}`),

Check warning on line 99 in src/contracts-wrappers/token.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 99 in src/contracts-wrappers/token.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
final

Check warning on line 100 in src/contracts-wrappers/token.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
)

return res.map((v, i) => ({
Expand Down
14 changes: 7 additions & 7 deletions test/integration/MRC20.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { account, Account } from '../../src'
import { Account } from '../../src'
import { MRC20 } from '../../src/contracts-wrappers'
import { provider } from './setup'

Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit 61c1721

Please sign in to comment.