From bf09dca20b2d491ccbc5eee4081628b3220f8a24 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Wed, 20 Sep 2023 11:19:46 -0300 Subject: [PATCH 1/3] Encode address instances as address structs automatically --- yarn-project/aztec.js/src/utils/abi_types.ts | 8 ++- .../foundation/src/abi/encoder.test.ts | 56 ++++++++++++++++++- yarn-project/foundation/src/abi/encoder.ts | 10 +++- yarn-project/foundation/src/abi/index.ts | 1 + yarn-project/foundation/src/abi/utils.ts | 28 ++++++++++ yarn-project/foundation/src/fields/fields.ts | 10 ++++ .../src/contract-interface-gen/typescript.ts | 12 +++- 7 files changed, 118 insertions(+), 7 deletions(-) create mode 100644 yarn-project/foundation/src/abi/utils.ts diff --git a/yarn-project/aztec.js/src/utils/abi_types.ts b/yarn-project/aztec.js/src/utils/abi_types.ts index fdebe26003a..eb637142f20 100644 --- a/yarn-project/aztec.js/src/utils/abi_types.ts +++ b/yarn-project/aztec.js/src/utils/abi_types.ts @@ -1,4 +1,10 @@ -import { Fr } from '@aztec/circuits.js'; +import { AztecAddress, EthAddress, Fr } from '@aztec/circuits.js'; /** Any type that can be converted into a field for a contract call. */ export type FieldLike = Fr | Buffer | bigint | number | { /** Converts to field */ toField: () => Fr }; + +/** Any type that can be converted into an EthereumAddress Aztec.nr struct. */ +export type EthAddressLike = { /** Wrapped address */ address: FieldLike } | EthAddress; + +/** Any type that can be converted into an EthereumAddress Aztec.nr struct. */ +export type AztecAddressLike = { /** Wrapped address */ address: FieldLike } | AztecAddress; diff --git a/yarn-project/foundation/src/abi/encoder.test.ts b/yarn-project/foundation/src/abi/encoder.test.ts index 8922d1e7c94..da033335b9c 100644 --- a/yarn-project/foundation/src/abi/encoder.test.ts +++ b/yarn-project/foundation/src/abi/encoder.test.ts @@ -1,7 +1,61 @@ -import { ABIParameterVisibility, FunctionAbi, FunctionType } from './abi.js'; +import { AztecAddress } from '../aztec-address/index.js'; +import { Fr } from '../fields/fields.js'; +import { ABIParameterVisibility, FunctionAbi, FunctionAbiHeader, FunctionType, StructType } from './abi.js'; import { encodeArguments } from './encoder.js'; describe('abi/encoder', () => { + it('serializes fields as fields', () => { + const abi: FunctionAbiHeader = { + name: 'constructor', + functionType: FunctionType.SECRET, + isInternal: false, + parameters: [ + { + name: 'owner', + type: { + kind: 'field', + }, + visibility: ABIParameterVisibility.SECRET, + }, + ], + returnTypes: [], + }; + + const field = Fr.random(); + expect(encodeArguments(abi, [field])).toEqual([field]); + }); + + it.each(['AztecAddress', 'EthereumAddress'])('accepts address instance for %s structs', (structType: string) => { + const abi: FunctionAbiHeader = { + name: 'constructor', + functionType: FunctionType.SECRET, + isInternal: false, + parameters: [ + { + name: 'owner', + type: { + kind: 'struct', + path: `aztec::types::address::${structType}`, + fields: [ + { + name: 'address', + type: { kind: 'field' }, + }, + ], + }, + visibility: ABIParameterVisibility.SECRET, + }, + ], + returnTypes: [], + }; + + const address = AztecAddress.random(); + + expect(encodeArguments(abi, [address])).toEqual([address.toField()]); + expect(encodeArguments(abi, [{ address }])).toEqual([address.toField()]); + expect(encodeArguments(abi, [{ address: address.toField() }])).toEqual([address.toField()]); + }); + it('throws when passing string argument as field', () => { const testFunctionAbi: FunctionAbi = { name: 'constructor', diff --git a/yarn-project/foundation/src/abi/encoder.ts b/yarn-project/foundation/src/abi/encoder.ts index 9c0ebb01f54..9faa6213c1e 100644 --- a/yarn-project/foundation/src/abi/encoder.ts +++ b/yarn-project/foundation/src/abi/encoder.ts @@ -1,4 +1,4 @@ -import { ABIType, FunctionAbiHeader } from '@aztec/foundation/abi'; +import { ABIType, FunctionAbiHeader, isAddressStruct } from '@aztec/foundation/abi'; import { Fr } from '@aztec/foundation/fields'; /** @@ -33,8 +33,6 @@ class ArgumentEncoder { this.flattened.push(Fr.fromBuffer(arg)); } else if (typeof arg.toField === 'function') { this.flattened.push(arg.toField()); - } else if (arg instanceof Fr) { - this.flattened.push(arg); } else { throw new Error(`Argument for ${name} cannot be serialised to a field`); } @@ -51,6 +49,12 @@ class ArgumentEncoder { } break; case 'struct': + // If the abi expects a struct like { address: Field } and the supplied arg does not have + // an address field in it, we try to encode it as if it were a field directly. + if (isAddressStruct(abiType) && typeof arg.address === 'undefined') { + this.encodeArgument({ kind: 'field' }, arg, `${name}.address`); + break; + } for (const field of abiType.fields) { this.encodeArgument(field.type, arg[field.name], `${name}.${field.name}`); } diff --git a/yarn-project/foundation/src/abi/index.ts b/yarn-project/foundation/src/abi/index.ts index 556c2150f39..8ec67fd2c74 100644 --- a/yarn-project/foundation/src/abi/index.ts +++ b/yarn-project/foundation/src/abi/index.ts @@ -3,3 +3,4 @@ export * from './abi_coder.js'; export * from './encoder.js'; export * from './decoder.js'; export * from './function_selector.js'; +export * from './utils.js'; diff --git a/yarn-project/foundation/src/abi/utils.ts b/yarn-project/foundation/src/abi/utils.ts new file mode 100644 index 00000000000..b2ee62d2dd5 --- /dev/null +++ b/yarn-project/foundation/src/abi/utils.ts @@ -0,0 +1,28 @@ +import { ABIType } from './abi.js'; + +/** + * Returns whether the ABI type is an Aztec or Ethereum Address defined in Aztec.nr. + * @param abiType - Type to check. + * @returns Boolean. + */ +export function isAddressStruct(abiType: ABIType) { + return isEthereumAddressStruct(abiType) || isAztecAddressStruct(abiType); +} + +/** + * Returns whether the ABI type is an Ethereum Address defined in Aztec.nr. + * @param abiType - Type to check. + * @returns Boolean. + */ +export function isEthereumAddressStruct(abiType: ABIType) { + return abiType.kind === 'struct' && abiType.path.endsWith('::types::address::EthereumAddress'); +} + +/** + * Returns whether the ABI type is an Aztec Address defined in Aztec.nr. + * @param abiType - Type to check. + * @returns Boolean. + */ +export function isAztecAddressStruct(abiType: ABIType) { + return abiType.kind === 'struct' && abiType.path.endsWith('::types::address::AztecAddress'); +} diff --git a/yarn-project/foundation/src/fields/fields.ts b/yarn-project/foundation/src/fields/fields.ts index 1004f1b8bca..57749cc01d2 100644 --- a/yarn-project/foundation/src/fields/fields.ts +++ b/yarn-project/foundation/src/fields/fields.ts @@ -148,6 +148,11 @@ export class Fr { toFriendlyJSON() { return this.toString(); } + + /** Returns self. */ + toField() { + return this; + } } /** @@ -243,4 +248,9 @@ export class Fq { toFriendlyJSON() { return this.toString(); } + + /** Returns self. */ + toField() { + return this; + } } diff --git a/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts b/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts index 92fa4c18b24..a2fc7a94c2d 100644 --- a/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts +++ b/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts @@ -1,4 +1,10 @@ -import { ABIParameter, ContractAbi, FunctionAbi } from '@aztec/foundation/abi'; +import { + ABIParameter, + ContractAbi, + FunctionAbi, + isAztecAddressStruct, + isEthereumAddressStruct, +} from '@aztec/foundation/abi'; import compact from 'lodash.compact'; @@ -20,6 +26,8 @@ function abiTypeToTypescript(type: ABIParameter['type']): string { case 'array': return `${abiTypeToTypescript(type.type)}[]`; case 'struct': + if (isEthereumAddressStruct(type)) return 'EthAddressLike'; + if (isAztecAddressStruct(type)) return 'AztecAddressLike'; return `{ ${type.fields.map(f => `${f.name}: ${abiTypeToTypescript(f.type)}`).join(', ')} }`; default: throw new Error(`Unknown type ${type}`); @@ -170,7 +178,7 @@ export function generateTypescriptContractInterface(input: ContractAbi, abiImpor /* Autogenerated file, do not edit! */ /* eslint-disable */ -import { AztecAddress, CompleteAddress, ContractBase, ContractFunctionInteraction, ContractMethod, DeployMethod, FieldLike, Wallet } from '@aztec/aztec.js'; +import { AztecAddress, CompleteAddress, ContractBase, ContractFunctionInteraction, ContractMethod, DeployMethod, FieldLike, AztecAddressLike, EthAddressLike, Wallet } from '@aztec/aztec.js'; import { Fr, Point } from '@aztec/foundation/fields'; import { AztecRPC, PublicKey } from '@aztec/types'; import { ContractAbi } from '@aztec/foundation/abi'; From f103e7e25eb06853f3b5bb749c74acaac4ea818c Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Wed, 20 Sep 2023 11:20:14 -0300 Subject: [PATCH 2/3] Apply change to all end to end tests --- yarn-project/end-to-end/src/canary/browser.ts | 13 +- .../end-to-end/src/e2e_2_rpc_servers.test.ts | 16 +- .../src/e2e_cross_chain_messaging.test.ts | 12 +- .../src/e2e_escrow_contract.test.ts | 16 +- .../src/e2e_lending_contract.test.ts | 10 +- .../e2e_multiple_accounts_1_enc_key.test.ts | 15 +- .../e2e_public_cross_chain_messaging.test.ts | 23 +- .../src/e2e_sandbox_example.test.ts | 22 +- .../end-to-end/src/e2e_token_contract.test.ts | 371 +++++++----------- .../src/fixtures/cross_chain_test_harness.ts | 45 +-- yarn-project/end-to-end/src/fixtures/utils.ts | 9 +- .../src/guides/dapp_testing.test.ts | 72 +--- .../end-to-end/src/sample-dapp/deploy.mjs | 2 +- .../end-to-end/src/sample-dapp/index.mjs | 10 +- .../end-to-end/src/sample-dapp/index.test.mjs | 13 +- 15 files changed, 244 insertions(+), 405 deletions(-) diff --git a/yarn-project/end-to-end/src/canary/browser.ts b/yarn-project/end-to-end/src/canary/browser.ts index 7aa320a2079..42354dc6f90 100644 --- a/yarn-project/end-to-end/src/canary/browser.ts +++ b/yarn-project/end-to-end/src/canary/browser.ts @@ -123,7 +123,7 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL const owner = (await client.getRegisteredAccounts())[0].address; const [wallet] = await AztecJs.getSandboxAccountsWallets(client); const contract = await Contract.at(AztecAddress.fromString(contractAddress), TokenContractAbi, wallet); - const balance = await contract.methods.balance_of_private({ address: owner }).view({ from: owner }); + const balance = await contract.methods.balance_of_private(owner).view({ from: owner }); return balance; }, SANDBOX_URL, @@ -143,12 +143,9 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL const receiver = accounts[1].address; const [wallet] = await AztecJs.getSandboxAccountsWallets(client); const contract = await Contract.at(AztecAddress.fromString(contractAddress), TokenContractAbi, wallet); - await contract.methods - .transfer({ address: accounts[0].address }, { address: receiver }, transferAmount, 0) - .send() - .wait(); + await contract.methods.transfer(accounts[0].address, receiver, transferAmount, 0).send().wait(); console.log(`Transferred ${transferAmount} tokens to new Account`); - return await contract.methods.balance_of_private({ address: receiver }).view({ from: receiver }); + return await contract.methods.balance_of_private(receiver).view({ from: receiver }); }, SANDBOX_URL, (await getTokenAddress()).toString(), @@ -186,11 +183,11 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL console.log(`Contract Deployed: ${receipt.contractAddress}`); const token = await Contract.at(receipt.contractAddress!, TokenContractAbi, owner); - await token.methods._initialize({ address: owner.getAddress() }).send().wait(); + await token.methods._initialize(owner.getAddress()).send().wait(); const secret = Fr.random(); const secretHash = await computeMessageSecretHash(secret); await token.methods.mint_private(initialBalance, secretHash).send().wait(); - await token.methods.redeem_shield({ address: owner.getAddress() }, initialBalance, secret).send().wait(); + await token.methods.redeem_shield(owner.getAddress(), initialBalance, secret).send().wait(); return receipt.txHash.toString(); }, diff --git a/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts b/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts index 94e8aeba8af..6b7f7e97b49 100644 --- a/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts @@ -72,7 +72,7 @@ describe('e2e_2_rpc_servers', () => { // Then check the balance const contractWithWallet = await TokenContract.at(tokenAddress, wallet); - const balance = await contractWithWallet.methods.balance_of_private({ address: owner }).view({ from: owner }); + const balance = await contractWithWallet.methods.balance_of_private(owner).view({ from: owner }); logger(`Account ${owner} balance: ${balance}`); expect(balance).toBe(expectedBalance); }; @@ -80,7 +80,7 @@ describe('e2e_2_rpc_servers', () => { const deployTokenContract = async (initialBalance: bigint, owner: AztecAddress) => { logger(`Deploying Token contract...`); const contract = await TokenContract.deploy(walletA).send().deployed(); - expect((await contract.methods._initialize({ address: owner }).send().wait()).status).toBe(TxStatus.MINED); + expect((await contract.methods._initialize(owner).send().wait()).status).toBe(TxStatus.MINED); const secret = Fr.random(); const secretHash = await computeMessageSecretHash(secret); @@ -88,9 +88,9 @@ describe('e2e_2_rpc_servers', () => { expect((await contract.methods.mint_private(initialBalance, secretHash).send().wait()).status).toEqual( TxStatus.MINED, ); - expect( - (await contract.methods.redeem_shield({ address: owner }, initialBalance, secret).send().wait()).status, - ).toEqual(TxStatus.MINED); + expect((await contract.methods.redeem_shield(owner, initialBalance, secret).send().wait()).status).toEqual( + TxStatus.MINED, + ); logger('L2 contract deployed'); @@ -127,7 +127,7 @@ describe('e2e_2_rpc_servers', () => { // Transfer funds from A to B via RPC server A const contractWithWalletA = await TokenContract.at(tokenAddress, walletA); const receiptAToB = await contractWithWalletA.methods - .transfer({ address: userA.address }, { address: userB.address }, transferAmount1, 0) + .transfer(userA.address, userB.address, transferAmount1, 0) .send() .wait(); expect(receiptAToB.status).toBe(TxStatus.MINED); @@ -140,7 +140,7 @@ describe('e2e_2_rpc_servers', () => { // Transfer funds from B to A via RPC server B const contractWithWalletB = await TokenContract.at(tokenAddress, walletB); await contractWithWalletB.methods - .transfer({ address: userB.address }, { address: userA.address }, transferAmount2, 0) + .transfer(userB.address, userA.address, transferAmount2, 0) .send() .wait({ interval: 0.1 }); @@ -189,7 +189,7 @@ describe('e2e_2_rpc_servers', () => { await awaitServerSynchronised(aztecRpcServerA); - const storedValue = await getChildStoredValue({ address: childCompleteAddress.address }, aztecRpcServerB); + const storedValue = await getChildStoredValue(childCompleteAddress, aztecRpcServerB); expect(storedValue).toBe(newValueToSet); }, 60_000); }); diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts index 76b18022a0f..bf86c1d5e0e 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts @@ -168,7 +168,7 @@ describe('e2e_cross_chain_messaging', () => { .methods.claim_private( bridgeAmount, secretHashForL2MessageConsumption, - { address: ethAccount.toField() }, + ethAccount, messageKey, secretForL2MessageConsumption, ) @@ -181,7 +181,7 @@ describe('e2e_cross_chain_messaging', () => { .methods.claim_private( bridgeAmount, secretHashForRedeemingMintedNotes, - { address: ethAccount.toField() }, + ethAccount, messageKey, secretForL2MessageConsumption, ) @@ -212,13 +212,7 @@ describe('e2e_cross_chain_messaging', () => { await expect( l2Bridge .withWallet(user1Wallet) - .methods.exit_to_l1_private( - { address: ethAccount.toField() }, - { address: l2Token.address }, - withdrawAmount, - { address: EthAddress.ZERO.toField() }, - nonce, - ) + .methods.exit_to_l1_private(ethAccount, l2Token.address, withdrawAmount, EthAddress.ZERO, nonce) .simulate(), ).rejects.toThrowError(`Unknown auth witness for message hash 0x${expectedBurnMessageHash.toString('hex')}`); }); diff --git a/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts b/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts index 94571b751e1..323bb2dcac6 100644 --- a/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_escrow_contract.test.ts @@ -53,15 +53,15 @@ describe('e2e_escrow_contract', () => { // Deploy Private Token contract and mint funds for the escrow contract token = await TokenContract.deploy(wallet).send().deployed(); - expect((await token.methods._initialize({ address: owner }).send().wait()).status).toBe(TxStatus.MINED); + expect((await token.methods._initialize(owner).send().wait()).status).toBe(TxStatus.MINED); const secret = Fr.random(); const secretHash = await computeMessageSecretHash(secret); expect((await token.methods.mint_private(100n, secretHash).send().wait()).status).toEqual(TxStatus.MINED); - expect( - (await token.methods.redeem_shield({ address: escrowContract.address }, 100n, secret).send().wait()).status, - ).toEqual(TxStatus.MINED); + expect((await token.methods.redeem_shield(escrowContract.address, 100n, secret).send().wait()).status).toEqual( + TxStatus.MINED, + ); logger(`Token contract deployed at ${token.address}`); }, 100_000); @@ -72,7 +72,7 @@ describe('e2e_escrow_contract', () => { }, 30_000); const expectBalance = async (who: AztecAddress, expectedBalance: bigint) => { - const balance = await token.methods.balance_of_private({ address: who }).view({ from: who }); + const balance = await token.methods.balance_of_private(who).view({ from: who }); logger(`Account ${who} balance: ${balance}`); expect(balance).toBe(expectedBalance); }; @@ -102,14 +102,12 @@ describe('e2e_escrow_contract', () => { const secretHash = await computeMessageSecretHash(secret); expect((await token.methods.mint_private(50n, secretHash).send().wait()).status).toEqual(TxStatus.MINED); - expect((await token.methods.redeem_shield({ address: owner }, 50n, secret).send().wait()).status).toEqual( - TxStatus.MINED, - ); + expect((await token.methods.redeem_shield(owner, 50n, secret).send().wait()).status).toEqual(TxStatus.MINED); await expectBalance(owner, 50n); const actions = [ - token.methods.transfer({ address: owner }, { address: recipient }, 10, 0).request(), + token.methods.transfer(owner, recipient, 10, 0).request(), escrowContract.methods.withdraw(token.address, 20, recipient).request(), ]; diff --git a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts index b92f539d8fe..0f22ae8808a 100644 --- a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts @@ -73,9 +73,9 @@ describe('e2e_lending_contract', () => { } await waitForSuccess(collateralAsset.methods._initialize(accounts[0]).send()); - await waitForSuccess(collateralAsset.methods.set_minter({ address: lendingContract.address }, true).send()); + await waitForSuccess(collateralAsset.methods.set_minter(lendingContract.address, true).send()); await waitForSuccess(stableCoin.methods._initialize(accounts[0]).send()); - await waitForSuccess(stableCoin.methods.set_minter({ address: lendingContract.address }, true).send()); + await waitForSuccess(stableCoin.methods.set_minter(lendingContract.address, true).send()); return { priceFeedContract, lendingContract, collateralAsset, stableCoin }; }; @@ -127,13 +127,11 @@ describe('e2e_lending_contract', () => { const secret = Fr.random(); const secretHash = await computeMessageSecretHash(secret); - const a = asset.methods.mint_public({ address: lendingAccount.address }, mintAmount).send(); + const a = asset.methods.mint_public(lendingAccount.address, mintAmount).send(); const b = asset.methods.mint_private(mintAmount, secretHash).send(); await Promise.all([a, b].map(waitForSuccess)); - await waitForSuccess( - asset.methods.redeem_shield({ address: lendingAccount.address }, mintAmount, secret).send(), - ); + await waitForSuccess(asset.methods.redeem_shield(lendingAccount.address, mintAmount, secret).send()); } } diff --git a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts index 467c3de7d35..18ecda90659 100644 --- a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts +++ b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts @@ -47,15 +47,15 @@ describe('e2e_multiple_accounts_1_enc_key', () => { tokenAddress = token.address; logger(`Token deployed at ${tokenAddress}`); - expect((await token.methods._initialize({ address: accounts[0] }).send().wait()).status).toBe(TxStatus.MINED); + expect((await token.methods._initialize(accounts[0]).send().wait()).status).toBe(TxStatus.MINED); const secret = Fr.random(); const secretHash = await computeMessageSecretHash(secret); expect((await token.methods.mint_private(initialBalance, secretHash).send().wait()).status).toEqual(TxStatus.MINED); - expect( - (await token.methods.redeem_shield({ address: accounts[0] }, initialBalance, secret).send().wait()).status, - ).toEqual(TxStatus.MINED); + expect((await token.methods.redeem_shield(accounts[0], initialBalance, secret).send().wait()).status).toEqual( + TxStatus.MINED, + ); }, 100_000); afterEach(async () => { @@ -71,7 +71,7 @@ describe('e2e_multiple_accounts_1_enc_key', () => { // Then check the balance const contractWithWallet = await TokenContract.at(tokenAddress, wallet); - const balance = await contractWithWallet.methods.balance_of_private({ address: owner }).view({ from: owner }); + const balance = await contractWithWallet.methods.balance_of_private(owner).view({ from: owner }); logger(`Account ${owner} balance: ${balance}`); expect(balance).toBe(expectedBalance); }; @@ -89,10 +89,7 @@ describe('e2e_multiple_accounts_1_enc_key', () => { const contractWithWallet = await TokenContract.at(tokenAddress, wallets[senderIndex]); - const receipt = await contractWithWallet.methods - .transfer({ address: sender }, { address: receiver }, transferAmount, 0) - .send() - .wait(); + const receipt = await contractWithWallet.methods.transfer(sender, receiver, transferAmount, 0).send().wait(); expect(receipt.status).toBe(TxStatus.MINED); for (let i = 0; i < expectedBalances.length; i++) { diff --git a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts index 82afbdce887..5ec2453ae2a 100644 --- a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts @@ -151,13 +151,7 @@ describe('e2e_public_cross_chain_messaging', () => { await expect( l2Bridge .withWallet(user2Wallet) - .methods.claim_public( - { address: user2Wallet.getAddress() }, - bridgeAmount, - { address: ownerEthAddress.toField() }, - messageKey, - secret, - ) + .methods.claim_public(user2Wallet.getAddress(), bridgeAmount, ownerEthAddress, messageKey, secret) .simulate(), ).rejects.toThrow(); @@ -165,13 +159,7 @@ describe('e2e_public_cross_chain_messaging', () => { logger("user2 consumes owner's message on L2 Publicly"); const tx = l2Bridge .withWallet(user2Wallet) - .methods.claim_public( - { address: ownerAddress }, - bridgeAmount, - { address: ownerEthAddress.toField() }, - messageKey, - secret, - ) + .methods.claim_public(ownerAddress, bridgeAmount, ownerEthAddress, messageKey, secret) .send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); @@ -190,12 +178,7 @@ describe('e2e_public_cross_chain_messaging', () => { await expect( l2Bridge .withWallet(ownerWallet) - .methods.exit_to_l1_public( - { address: ownerEthAddress.toField() }, - withdrawAmount, - { address: EthAddress.ZERO.toField() }, - nonce, - ) + .methods.exit_to_l1_public(ownerEthAddress, withdrawAmount, EthAddress.ZERO, nonce) .simulate(), ).rejects.toThrowError('Assertion failed: Message not authorized by account'); }); diff --git a/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts b/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts index 301095748f8..eddee6de9d6 100644 --- a/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts +++ b/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts @@ -95,8 +95,8 @@ describe('e2e_sandbox_example', () => { const tokenContractAlice = await TokenContract.at(contract.address, await accounts[0].getWallet()); // Initialize the contract and add Bob as a minter - await tokenContractAlice.methods._initialize({ address: alice }).send().wait(); - await tokenContractAlice.methods.set_minter({ address: bob }, true).send().wait(); + await tokenContractAlice.methods._initialize(alice).send().wait(); + await tokenContractAlice.methods.set_minter(bob, true).send().wait(); logger(`Contract successfully deployed at address ${contract.address.toShortString()}`); @@ -104,7 +104,7 @@ describe('e2e_sandbox_example', () => { const secretHash = await computeMessageSecretHash(secret); await tokenContractAlice.methods.mint_private(initialSupply, secretHash).send().wait(); - await tokenContractAlice.methods.redeem_shield({ address: alice }, initialSupply, secret).send().wait(); + await tokenContractAlice.methods.redeem_shield(alice, initialSupply, secret).send().wait(); // docs:end:Deployment // ensure that token contract is registered in the rpc @@ -118,10 +118,10 @@ describe('e2e_sandbox_example', () => { // Since we already have a token link, we can simply create a new instance of the contract linked to Bob's wallet const tokenContractBob = tokenContractAlice.withWallet(await accounts[1].getWallet()); - let aliceBalance = await tokenContractAlice.methods.balance_of_private({ address: alice }).view(); + let aliceBalance = await tokenContractAlice.methods.balance_of_private(alice).view(); logger(`Alice's balance ${aliceBalance}`); - let bobBalance = await tokenContractBob.methods.balance_of_private({ address: bob }).view(); + let bobBalance = await tokenContractBob.methods.balance_of_private(bob).view(); logger(`Bob's balance ${bobBalance}`); // docs:end:Balance @@ -135,13 +135,13 @@ describe('e2e_sandbox_example', () => { // We will now transfer tokens from ALice to Bob const transferQuantity = 543n; logger(`Transferring ${transferQuantity} tokens from Alice to Bob...`); - await tokenContractAlice.methods.transfer({ address: alice }, { address: bob }, transferQuantity, 0).send().wait(); + await tokenContractAlice.methods.transfer(alice, bob, transferQuantity, 0).send().wait(); // Check the new balances - aliceBalance = await tokenContractAlice.methods.balance_of_private({ address: alice }).view(); + aliceBalance = await tokenContractAlice.methods.balance_of_private(alice).view(); logger(`Alice's balance ${aliceBalance}`); - bobBalance = await tokenContractBob.methods.balance_of_private({ address: bob }).view(); + bobBalance = await tokenContractBob.methods.balance_of_private(bob).view(); logger(`Bob's balance ${bobBalance}`); // docs:end:Transfer @@ -155,13 +155,13 @@ describe('e2e_sandbox_example', () => { const mintQuantity = 10_000n; logger(`Minting ${mintQuantity} tokens to Bob...`); await tokenContractBob.methods.mint_private(mintQuantity, secretHash).send().wait(); - await tokenContractBob.methods.redeem_shield({ address: bob }, mintQuantity, secret).send().wait(); + await tokenContractBob.methods.redeem_shield(bob, mintQuantity, secret).send().wait(); // Check the new balances - aliceBalance = await tokenContractAlice.methods.balance_of_private({ address: alice }).view(); + aliceBalance = await tokenContractAlice.methods.balance_of_private(alice).view(); logger(`Alice's balance ${aliceBalance}`); - bobBalance = await tokenContractBob.methods.balance_of_private({ address: bob }).view(); + bobBalance = await tokenContractBob.methods.balance_of_private(bob).view(); logger(`Bob's balance ${bobBalance}`); // docs:end:Mint diff --git a/yarn-project/end-to-end/src/e2e_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_token_contract.test.ts index 5f86afedac6..9464789a759 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract.test.ts @@ -46,7 +46,7 @@ describe('e2e_token_contract', () => { accounts.map(a => a.address), ); - await asset.methods._initialize({ address: accounts[0].address }).send().wait(); + await asset.methods._initialize(accounts[0].address).send().wait(); expect(await asset.methods.admin().view()).toBe(accounts[0].address.toBigInt()); asset.abi.functions.forEach(fn => { @@ -72,34 +72,34 @@ describe('e2e_token_contract', () => { describe('Access controlled functions', () => { it('Set admin', async () => { - const tx = asset.methods.set_admin({ address: accounts[1].address }).send(); + const tx = asset.methods.set_admin(accounts[1].address).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); expect(await asset.methods.admin().view()).toBe(accounts[1].address.toBigInt()); }); it('Add minter as admin', async () => { - const tx = asset.withWallet(wallets[1]).methods.set_minter({ address: accounts[1].address }, true).send(); + const tx = asset.withWallet(wallets[1]).methods.set_minter(accounts[1].address, true).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); - expect(await asset.methods.is_minter({ address: accounts[1].address }).view()).toBe(true); + expect(await asset.methods.is_minter(accounts[1].address).view()).toBe(true); }); it('Revoke minter as admin', async () => { - const tx = asset.withWallet(wallets[1]).methods.set_minter({ address: accounts[1].address }, false).send(); + const tx = asset.withWallet(wallets[1]).methods.set_minter(accounts[1].address, false).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); - expect(await asset.methods.is_minter({ address: accounts[1].address }).view()).toBe(false); + expect(await asset.methods.is_minter(accounts[1].address).view()).toBe(false); }); describe('failure cases', () => { it('Set admin (not admin)', async () => { - await expect(asset.methods.set_admin({ address: accounts[0].address }).simulate()).rejects.toThrowError( + await expect(asset.methods.set_admin(accounts[0].address).simulate()).rejects.toThrowError( 'Assertion failed: caller is not admin', ); }); it('Revoke minter not as admin', async () => { - await expect(asset.methods.set_minter({ address: accounts[0].address }, false).simulate()).rejects.toThrowError( + await expect(asset.methods.set_minter(accounts[0].address, false).simulate()).rejects.toThrowError( 'Assertion failed: caller is not admin', ); }); @@ -110,12 +110,12 @@ describe('e2e_token_contract', () => { describe('Public', () => { it('as minter', async () => { const amount = 10000n; - const tx = asset.methods.mint_public({ address: accounts[0].address }, amount).send(); + const tx = asset.methods.mint_public(accounts[0].address, amount).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); tokenSim.mintPublic(accounts[0].address, amount); - expect(await asset.methods.balance_of_public({ address: accounts[0].address }).view()).toEqual( + expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual( tokenSim.balanceOfPublic(accounts[0].address), ); expect(await asset.methods.total_supply().view()).toEqual(tokenSim.totalSupply); @@ -125,29 +125,29 @@ describe('e2e_token_contract', () => { it('as non-minter', async () => { const amount = 10000n; await expect( - asset.withWallet(wallets[1]).methods.mint_public({ address: accounts[0].address }, amount).simulate(), + asset.withWallet(wallets[1]).methods.mint_public(accounts[0].address, amount).simulate(), ).rejects.toThrowError('Assertion failed: caller is not minter'); }); it('mint >u120 tokens to overflow', async () => { const amount = 2n ** 120n; // SafeU120::max() + 1; - await expect( - asset.methods.mint_public({ address: accounts[0].address }, amount).simulate(), - ).rejects.toThrowError('Assertion failed: Value too large for SafeU120'); + await expect(asset.methods.mint_public(accounts[0].address, amount).simulate()).rejects.toThrowError( + 'Assertion failed: Value too large for SafeU120', + ); }); it('mint u120', async () => { const amount = 2n ** 120n - tokenSim.balanceOfPublic(accounts[0].address); - await expect( - asset.methods.mint_public({ address: accounts[0].address }, amount).simulate(), - ).rejects.toThrowError('Assertion failed: Overflow'); + await expect(asset.methods.mint_public(accounts[0].address, amount).simulate()).rejects.toThrowError( + 'Assertion failed: Overflow', + ); }); it('mint u120', async () => { const amount = 2n ** 120n - tokenSim.balanceOfPublic(accounts[0].address); - await expect( - asset.methods.mint_public({ address: accounts[1].address }, amount).simulate(), - ).rejects.toThrowError('Assertion failed: Overflow'); + await expect(asset.methods.mint_public(accounts[1].address, amount).simulate()).rejects.toThrowError( + 'Assertion failed: Overflow', + ); }); }); }); @@ -170,7 +170,7 @@ describe('e2e_token_contract', () => { }); it('redeem as recipient', async () => { - const txClaim = asset.methods.redeem_shield({ address: accounts[0].address }, amount, secret).send(); + const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send(); const receiptClaim = await txClaim.wait(); expect(receiptClaim.status).toBe(TxStatus.MINED); tokenSim.redeemShield(accounts[0].address, amount); @@ -179,7 +179,7 @@ describe('e2e_token_contract', () => { describe('failure cases', () => { it('try to redeem as recipient (double-spend) [REVERTS]', async () => { - const txClaim = asset.methods.redeem_shield({ address: accounts[0].address }, amount, secret).send(); + const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send(); await txClaim.isMined(); const receipt = await txClaim.getReceipt(); expect(receipt.status).toBe(TxStatus.DROPPED); @@ -237,12 +237,10 @@ describe('e2e_token_contract', () => { }; it('transfer less than balance', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods - .transfer_public({ address: accounts[0].address }, { address: accounts[1].address }, amount, 0) - .send(); + const tx = asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, 0).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); @@ -250,12 +248,10 @@ describe('e2e_token_contract', () => { }); it('transfer to self', async () => { - const balance = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods - .transfer_public({ address: accounts[0].address }, { address: accounts[0].address }, amount, 0) - .send(); + const tx = asset.methods.transfer_public(accounts[0].address, accounts[0].address, amount, 0).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); @@ -263,7 +259,7 @@ describe('e2e_token_contract', () => { }); it('transfer on behalf of other', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); const nonce = Fr.random(); @@ -275,7 +271,7 @@ describe('e2e_token_contract', () => { // Perform the transfer const tx = asset .withWallet(wallets[1]) - .methods.transfer_public({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) + .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); @@ -285,7 +281,7 @@ describe('e2e_token_contract', () => { // Check that the message hash is no longer valid. Need to try to send since nullifiers are handled by sequencer. const txReplay = asset .withWallet(wallets[1]) - .methods.transfer_public({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) + .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .send(); await txReplay.isMined(); const receiptReplay = await txReplay.getReceipt(); @@ -294,47 +290,38 @@ describe('e2e_token_contract', () => { describe('failure cases', () => { it('transfer more than balance', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 + 1n; const nonce = 0; await expect( - asset.methods - .transfer_public({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) - .simulate(), + asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce).simulate(), ).rejects.toThrowError('Assertion failed: Underflow'); }); it('transfer on behalf of self with non-zero nonce', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 - 1n; const nonce = 1; await expect( - asset.methods - .transfer_public({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) - .simulate(), + asset.methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce).simulate(), ).rejects.toThrowError('Assertion failed: invalid nonce'); }); it('transfer on behalf of other without "approval"', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 + 1n; const nonce = Fr.random(); await expect( asset .withWallet(wallets[1]) - .methods.transfer_public( - { address: accounts[0].address }, - { address: accounts[1].address }, - amount, - nonce, - ) + .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), ).rejects.toThrowError('Assertion failed: Message not authorized by account'); }); it('transfer more than balance on behalf of other', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); - const balance1 = await asset.methods.balance_of_public({ address: accounts[1].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); + const balance1 = await asset.methods.balance_of_public(accounts[1].address).view(); const amount = balance0 + 1n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -347,22 +334,17 @@ describe('e2e_token_contract', () => { await expect( asset .withWallet(wallets[1]) - .methods.transfer_public( - { address: accounts[0].address }, - { address: accounts[1].address }, - amount, - nonce, - ) + .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), ).rejects.toThrowError('Assertion failed: Underflow'); - expect(await asset.methods.balance_of_public({ address: accounts[0].address }).view()).toEqual(balance0); - expect(await asset.methods.balance_of_public({ address: accounts[1].address }).view()).toEqual(balance1); + expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual(balance0); + expect(await asset.methods.balance_of_public(accounts[1].address).view()).toEqual(balance1); }); it('transfer on behalf of other, wrong designated caller', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); - const balance1 = await asset.methods.balance_of_public({ address: accounts[1].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); + const balance1 = await asset.methods.balance_of_public(accounts[1].address).view(); const amount = balance0 + 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -375,22 +357,17 @@ describe('e2e_token_contract', () => { await expect( asset .withWallet(wallets[1]) - .methods.transfer_public( - { address: accounts[0].address }, - { address: accounts[1].address }, - amount, - nonce, - ) + .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), ).rejects.toThrowError('Assertion failed: Message not authorized by account'); - expect(await asset.methods.balance_of_public({ address: accounts[0].address }).view()).toEqual(balance0); - expect(await asset.methods.balance_of_public({ address: accounts[1].address }).view()).toEqual(balance1); + expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual(balance0); + expect(await asset.methods.balance_of_public(accounts[1].address).view()).toEqual(balance1); }); it('transfer on behalf of other, wrong designated caller', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); - const balance1 = await asset.methods.balance_of_public({ address: accounts[1].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); + const balance1 = await asset.methods.balance_of_public(accounts[1].address).view(); const amount = balance0 + 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -403,17 +380,12 @@ describe('e2e_token_contract', () => { await expect( asset .withWallet(wallets[1]) - .methods.transfer_public( - { address: accounts[0].address }, - { address: accounts[1].address }, - amount, - nonce, - ) + .methods.transfer_public(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), ).rejects.toThrowError('Assertion failed: Message not authorized by account'); - expect(await asset.methods.balance_of_public({ address: accounts[0].address }).view()).toEqual(balance0); - expect(await asset.methods.balance_of_public({ address: accounts[1].address }).view()).toEqual(balance1); + expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual(balance0); + expect(await asset.methods.balance_of_public(accounts[1].address).view()).toEqual(balance1); }); it.skip('transfer into account to overflow', () => { @@ -445,31 +417,27 @@ describe('e2e_token_contract', () => { }; it('transfer less than balance', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods - .transfer({ address: accounts[0].address }, { address: accounts[1].address }, amount, 0) - .send(); + const tx = asset.methods.transfer(accounts[0].address, accounts[1].address, amount, 0).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); tokenSim.transferPrivate(accounts[0].address, accounts[1].address, amount); }); it('transfer to self', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods - .transfer({ address: accounts[0].address }, { address: accounts[0].address }, amount, 0) - .send(); + const tx = asset.methods.transfer(accounts[0].address, accounts[0].address, amount, 0).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); tokenSim.transferPrivate(accounts[0].address, accounts[0].address, amount); }); it('transfer on behalf of other', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 / 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -486,7 +454,7 @@ describe('e2e_token_contract', () => { // Perform the transfer const tx = asset .withWallet(wallets[1]) - .methods.transfer({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) + .methods.transfer(accounts[0].address, accounts[1].address, amount, nonce) .send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); @@ -495,7 +463,7 @@ describe('e2e_token_contract', () => { // Perform the transfer again, should fail const txReplay = asset .withWallet(wallets[1]) - .methods.transfer({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) + .methods.transfer(accounts[0].address, accounts[1].address, amount, nonce) .send(); await txReplay.isMined(); const receiptReplay = await txReplay.getReceipt(); @@ -504,30 +472,26 @@ describe('e2e_token_contract', () => { describe('failure cases', () => { it('transfer more than balance', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 + 1n; expect(amount).toBeGreaterThan(0n); await expect( - asset.methods - .transfer({ address: accounts[0].address }, { address: accounts[1].address }, amount, 0) - .simulate(), + asset.methods.transfer(accounts[0].address, accounts[1].address, amount, 0).simulate(), ).rejects.toThrowError('Assertion failed: Balance too low'); }); it('transfer on behalf of self with non-zero nonce', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 - 1n; expect(amount).toBeGreaterThan(0n); await expect( - asset.methods - .transfer({ address: accounts[0].address }, { address: accounts[1].address }, amount, 1) - .simulate(), + asset.methods.transfer(accounts[0].address, accounts[1].address, amount, 1).simulate(), ).rejects.toThrowError('Assertion failed: invalid nonce'); }); it('transfer more than balance on behalf of other', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); - const balance1 = await asset.methods.balance_of_private({ address: accounts[1].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); + const balance1 = await asset.methods.balance_of_private(accounts[1].address).view(); const amount = balance0 + 1n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -545,11 +509,11 @@ describe('e2e_token_contract', () => { await expect( asset .withWallet(wallets[1]) - .methods.transfer({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) + .methods.transfer(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), ).rejects.toThrowError('Assertion failed: Balance too low'); - expect(await asset.methods.balance_of_private({ address: accounts[0].address }).view()).toEqual(balance0); - expect(await asset.methods.balance_of_private({ address: accounts[1].address }).view()).toEqual(balance1); + expect(await asset.methods.balance_of_private(accounts[0].address).view()).toEqual(balance0); + expect(await asset.methods.balance_of_private(accounts[1].address).view()).toEqual(balance1); }); it.skip('transfer into account to overflow', () => { @@ -560,7 +524,7 @@ describe('e2e_token_contract', () => { }); it('transfer on behalf of other without approval', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 / 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -571,13 +535,13 @@ describe('e2e_token_contract', () => { await expect( asset .withWallet(wallets[1]) - .methods.transfer({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) + .methods.transfer(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), ).rejects.toThrowError(`Unknown auth witness for message hash 0x${messageHash.toString('hex')}`); }); it('transfer on behalf of other, wrong designated caller', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 / 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -592,10 +556,10 @@ describe('e2e_token_contract', () => { await expect( asset .withWallet(wallets[2]) - .methods.transfer({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) + .methods.transfer(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), ).rejects.toThrowError(`Unknown auth witness for message hash 0x${expectedMessageHash.toString('hex')}`); - expect(await asset.methods.balance_of_private({ address: accounts[0].address }).view()).toEqual(balance0); + expect(await asset.methods.balance_of_private(accounts[0].address).view()).toEqual(balance0); }); }); }); @@ -628,11 +592,11 @@ describe('e2e_token_contract', () => { }; it('on behalf of self', async () => { - const balancePub = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balancePub = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balancePub / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.shield({ address: accounts[0].address }, amount, secretHash, 0).send(); + const tx = asset.methods.shield(accounts[0].address, amount, secretHash, 0).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); @@ -640,21 +604,21 @@ describe('e2e_token_contract', () => { await tokenSim.check(); // Redeem it - const txClaim = asset.methods.redeem_shield({ address: accounts[0].address }, amount, secret).send(); + const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send(); const receiptClaim = await txClaim.wait(); expect(receiptClaim.status).toBe(TxStatus.MINED); tokenSim.redeemShield(accounts[0].address, amount); // Check that claiming again will hit a double-spend and fail due to pending note already consumed. - const txClaimDoubleSpend = asset.methods.redeem_shield({ address: accounts[0].address }, amount, secret).send(); + const txClaimDoubleSpend = asset.methods.redeem_shield(accounts[0].address, amount, secret).send(); await txClaimDoubleSpend.isMined(); const receiptDoubleSpend = await txClaimDoubleSpend.getReceipt(); expect(receiptDoubleSpend.status).toBe(TxStatus.DROPPED); }); it('on behalf of other', async () => { - const balancePub = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balancePub = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balancePub / 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -663,10 +627,7 @@ describe('e2e_token_contract', () => { const messageHash = await shieldMessageHash(accounts[1], accounts[0], amount, secretHash, nonce); await wallets[0].setPublicAuth(messageHash, true).send().wait(); - const tx = asset - .withWallet(wallets[1]) - .methods.shield({ address: accounts[0].address }, amount, secretHash, nonce) - .send(); + const tx = asset.withWallet(wallets[1]).methods.shield(accounts[0].address, amount, secretHash, nonce).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); @@ -676,21 +637,21 @@ describe('e2e_token_contract', () => { // Check that replaying the shield should fail! const txReplay = asset .withWallet(wallets[1]) - .methods.shield({ address: accounts[0].address }, amount, secretHash, nonce) + .methods.shield(accounts[0].address, amount, secretHash, nonce) .send(); await txReplay.isMined(); const receiptReplay = await txReplay.getReceipt(); expect(receiptReplay.status).toBe(TxStatus.DROPPED); // Redeem it - const txClaim = asset.methods.redeem_shield({ address: accounts[0].address }, amount, secret).send(); + const txClaim = asset.methods.redeem_shield(accounts[0].address, amount, secret).send(); const receiptClaim = await txClaim.wait(); expect(receiptClaim.status).toBe(TxStatus.MINED); tokenSim.redeemShield(accounts[0].address, amount); // Check that claiming again will hit a double-spend and fail due to pending note already consumed. - const txClaimDoubleSpend = asset.methods.redeem_shield({ address: accounts[0].address }, amount, secret).send(); + const txClaimDoubleSpend = asset.methods.redeem_shield(accounts[0].address, amount, secret).send(); await txClaimDoubleSpend.isMined(); const receiptDoubleSpend = await txClaimDoubleSpend.getReceipt(); expect(receiptDoubleSpend.status).toBe(TxStatus.DROPPED); @@ -698,27 +659,27 @@ describe('e2e_token_contract', () => { describe('failure cases', () => { it('on behalf of self (more than balance)', async () => { - const balancePub = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balancePub = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balancePub + 1n; expect(amount).toBeGreaterThan(0n); - await expect( - asset.methods.shield({ address: accounts[0].address }, amount, secretHash, 0).simulate(), - ).rejects.toThrowError('Assertion failed: Underflow'); + await expect(asset.methods.shield(accounts[0].address, amount, secretHash, 0).simulate()).rejects.toThrowError( + 'Assertion failed: Underflow', + ); }); it('on behalf of self (invalid nonce)', async () => { - const balancePub = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balancePub = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balancePub + 1n; expect(amount).toBeGreaterThan(0n); - await expect( - asset.methods.shield({ address: accounts[0].address }, amount, secretHash, 1).simulate(), - ).rejects.toThrowError('Assertion failed: invalid nonce'); + await expect(asset.methods.shield(accounts[0].address, amount, secretHash, 1).simulate()).rejects.toThrowError( + 'Assertion failed: invalid nonce', + ); }); it('on behalf of other (more than balance)', async () => { - const balancePub = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balancePub = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balancePub + 1n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -728,15 +689,12 @@ describe('e2e_token_contract', () => { await wallets[0].setPublicAuth(messageHash, true).send().wait(); await expect( - asset - .withWallet(wallets[1]) - .methods.shield({ address: accounts[0].address }, amount, secretHash, nonce) - .simulate(), + asset.withWallet(wallets[1]).methods.shield(accounts[0].address, amount, secretHash, nonce).simulate(), ).rejects.toThrowError('Assertion failed: Underflow'); }); it('on behalf of other (wrong designated caller)', async () => { - const balancePub = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balancePub = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balancePub + 1n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -746,16 +704,13 @@ describe('e2e_token_contract', () => { await wallets[0].setPublicAuth(messageHash, true).send().wait(); await expect( - asset - .withWallet(wallets[2]) - .methods.shield({ address: accounts[0].address }, amount, secretHash, nonce) - .simulate(), + asset.withWallet(wallets[2]).methods.shield(accounts[0].address, amount, secretHash, nonce).simulate(), ).rejects.toThrowError('Assertion failed: Message not authorized by account'); }); it('on behalf of other (wrong designated caller)', async () => { - const balancePub = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); - const balancePriv = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balancePub = await asset.methods.balance_of_public(accounts[0].address).view(); + const balancePriv = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balancePub + 1n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -765,27 +720,21 @@ describe('e2e_token_contract', () => { await wallets[0].setPublicAuth(messageHash, true).send().wait(); await expect( - asset - .withWallet(wallets[2]) - .methods.shield({ address: accounts[0].address }, amount, secretHash, nonce) - .simulate(), + asset.withWallet(wallets[2]).methods.shield(accounts[0].address, amount, secretHash, nonce).simulate(), ).rejects.toThrowError('Assertion failed: Message not authorized by account'); - expect(await asset.methods.balance_of_public({ address: accounts[0].address }).view()).toEqual(balancePub); - expect(await asset.methods.balance_of_private({ address: accounts[0].address }).view()).toEqual(balancePriv); + expect(await asset.methods.balance_of_public(accounts[0].address).view()).toEqual(balancePub); + expect(await asset.methods.balance_of_private(accounts[0].address).view()).toEqual(balancePriv); }); it('on behalf of other (without approval)', async () => { - const balance = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance / 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); await expect( - asset - .withWallet(wallets[1]) - .methods.shield({ address: accounts[0].address }, amount, secretHash, nonce) - .simulate(), + asset.withWallet(wallets[1]).methods.shield(accounts[0].address, amount, secretHash, nonce).simulate(), ).rejects.toThrowError(`Assertion failed: Message not authorized by account`); }); }); @@ -811,13 +760,11 @@ describe('e2e_token_contract', () => { }; it('on behalf of self', async () => { - const balancePriv = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balancePriv = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balancePriv / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods - .unshield({ address: accounts[0].address }, { address: accounts[0].address }, amount, 0) - .send(); + const tx = asset.methods.unshield(accounts[0].address, accounts[0].address, amount, 0).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); @@ -825,7 +772,7 @@ describe('e2e_token_contract', () => { }); it('on behalf of other', async () => { - const balancePriv0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balancePriv0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balancePriv0 / 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -841,7 +788,7 @@ describe('e2e_token_contract', () => { const tx = asset .withWallet(wallets[1]) - .methods.unshield({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) + .methods.unshield(accounts[0].address, accounts[1].address, amount, nonce) .send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); @@ -850,7 +797,7 @@ describe('e2e_token_contract', () => { // Perform the transfer again, should fail const txReplay = asset .withWallet(wallets[1]) - .methods.unshield({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) + .methods.unshield(accounts[0].address, accounts[1].address, amount, nonce) .send(); await txReplay.isMined(); const receiptReplay = await txReplay.getReceipt(); @@ -859,31 +806,27 @@ describe('e2e_token_contract', () => { describe('failure cases', () => { it('on behalf of self (more than balance)', async () => { - const balancePriv = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balancePriv = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balancePriv + 1n; expect(amount).toBeGreaterThan(0n); await expect( - asset.methods - .unshield({ address: accounts[0].address }, { address: accounts[0].address }, amount, 0) - .simulate(), + asset.methods.unshield(accounts[0].address, accounts[0].address, amount, 0).simulate(), ).rejects.toThrowError('Assertion failed: Balance too low'); }); it('on behalf of self (invalid nonce)', async () => { - const balancePriv = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balancePriv = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balancePriv + 1n; expect(amount).toBeGreaterThan(0n); await expect( - asset.methods - .unshield({ address: accounts[0].address }, { address: accounts[0].address }, amount, 1) - .simulate(), + asset.methods.unshield(accounts[0].address, accounts[0].address, amount, 1).simulate(), ).rejects.toThrowError('Assertion failed: invalid nonce'); }); it('on behalf of other (more than balance)', async () => { - const balancePriv0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balancePriv0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balancePriv0 + 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -900,13 +843,13 @@ describe('e2e_token_contract', () => { await expect( asset .withWallet(wallets[1]) - .methods.unshield({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) + .methods.unshield(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), ).rejects.toThrowError('Assertion failed: Balance too low'); }); it('on behalf of other (invalid designated caller)', async () => { - const balancePriv0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balancePriv0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balancePriv0 + 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -924,7 +867,7 @@ describe('e2e_token_contract', () => { await expect( asset .withWallet(wallets[2]) - .methods.unshield({ address: accounts[0].address }, { address: accounts[1].address }, amount, nonce) + .methods.unshield(accounts[0].address, accounts[1].address, amount, nonce) .simulate(), ).rejects.toThrowError(`Unknown auth witness for message hash 0x${expectedMessageHash.toString('hex')}`); }); @@ -945,10 +888,10 @@ describe('e2e_token_contract', () => { }; it('burn less than balance', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.burn_public({ address: accounts[0].address }, amount, 0).send(); + const tx = asset.methods.burn_public(accounts[0].address, amount, 0).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); @@ -956,7 +899,7 @@ describe('e2e_token_contract', () => { }); it('burn on behalf of other', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); const nonce = Fr.random(); @@ -965,20 +908,14 @@ describe('e2e_token_contract', () => { const messageHash = await burnMessageHash(accounts[1], accounts[0], amount, nonce); await wallets[0].setPublicAuth(messageHash, true).send().wait(); - const tx = asset - .withWallet(wallets[1]) - .methods.burn_public({ address: accounts[0].address }, amount, nonce) - .send(); + const tx = asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); tokenSim.burnPublic(accounts[0].address, amount); // Check that the message hash is no longer valid. Need to try to send since nullifiers are handled by sequencer. - const txReplay = asset - .withWallet(wallets[1]) - .methods.burn_public({ address: accounts[0].address }, amount, nonce) - .send(); + const txReplay = asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).send(); await txReplay.isMined(); const receiptReplay = await txReplay.getReceipt(); expect(receiptReplay.status).toBe(TxStatus.DROPPED); @@ -986,38 +923,35 @@ describe('e2e_token_contract', () => { describe('failure cases', () => { it('burn more than balance', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 + 1n; const nonce = 0; - await expect( - asset.methods.burn_public({ address: accounts[0].address }, amount, nonce).simulate(), - ).rejects.toThrowError('Assertion failed: Underflow'); + await expect(asset.methods.burn_public(accounts[0].address, amount, nonce).simulate()).rejects.toThrowError( + 'Assertion failed: Underflow', + ); }); it('burn on behalf of self with non-zero nonce', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 - 1n; expect(amount).toBeGreaterThan(0n); const nonce = 1; - await expect( - asset.methods.burn_public({ address: accounts[0].address }, amount, nonce).simulate(), - ).rejects.toThrowError('Assertion failed: invalid nonce'); + await expect(asset.methods.burn_public(accounts[0].address, amount, nonce).simulate()).rejects.toThrowError( + 'Assertion failed: invalid nonce', + ); }); it('burn on behalf of other without "approval"', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 + 1n; const nonce = Fr.random(); await expect( - asset - .withWallet(wallets[1]) - .methods.burn_public({ address: accounts[0].address }, amount, nonce) - .simulate(), + asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).simulate(), ).rejects.toThrowError('Assertion failed: Message not authorized by account'); }); it('burn more than balance on behalf of other', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 + 1n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -1027,15 +961,12 @@ describe('e2e_token_contract', () => { await wallets[0].setPublicAuth(messageHash, true).send().wait(); await expect( - asset - .withWallet(wallets[1]) - .methods.burn_public({ address: accounts[0].address }, amount, nonce) - .simulate(), + asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).simulate(), ).rejects.toThrowError('Assertion failed: Underflow'); }); it('burn on behalf of other, wrong designated caller', async () => { - const balance0 = await asset.methods.balance_of_public({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_public(accounts[0].address).view(); const amount = balance0 + 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -1045,10 +976,7 @@ describe('e2e_token_contract', () => { await wallets[0].setPublicAuth(messageHash, true).send().wait(); await expect( - asset - .withWallet(wallets[1]) - .methods.burn_public({ address: accounts[0].address }, amount, nonce) - .simulate(), + asset.withWallet(wallets[1]).methods.burn_public(accounts[0].address, amount, nonce).simulate(), ).rejects.toThrowError('Assertion failed: Message not authorized by account'); }); }); @@ -1067,17 +995,17 @@ describe('e2e_token_contract', () => { }; it('burn less than balance', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 / 2n; expect(amount).toBeGreaterThan(0n); - const tx = asset.methods.burn({ address: accounts[0].address }, amount, 0).send(); + const tx = asset.methods.burn(accounts[0].address, amount, 0).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); tokenSim.burnPrivate(accounts[0].address, amount); }); it('burn on behalf of other', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 / 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -1091,16 +1019,13 @@ describe('e2e_token_contract', () => { const witness = await wallets[0].createAuthWitness(messageHash); await wallets[1].addAuthWitness(witness); - const tx = asset.withWallet(wallets[1]).methods.burn({ address: accounts[0].address }, amount, nonce).send(); + const tx = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); tokenSim.burnPrivate(accounts[0].address, amount); // Perform the transfer again, should fail - const txReplay = asset - .withWallet(wallets[1]) - .methods.burn({ address: accounts[0].address }, amount, nonce) - .send(); + const txReplay = asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).send(); await txReplay.isMined(); const receiptReplay = await txReplay.getReceipt(); expect(receiptReplay.status).toBe(TxStatus.DROPPED); @@ -1108,25 +1033,25 @@ describe('e2e_token_contract', () => { describe('failure cases', () => { it('burn more than balance', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 + 1n; expect(amount).toBeGreaterThan(0n); - await expect(asset.methods.burn({ address: accounts[0].address }, amount, 0).simulate()).rejects.toThrowError( + await expect(asset.methods.burn(accounts[0].address, amount, 0).simulate()).rejects.toThrowError( 'Assertion failed: Balance too low', ); }); it('burn on behalf of self with non-zero nonce', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 - 1n; expect(amount).toBeGreaterThan(0n); - await expect(asset.methods.burn({ address: accounts[0].address }, amount, 1).simulate()).rejects.toThrowError( + await expect(asset.methods.burn(accounts[0].address, amount, 1).simulate()).rejects.toThrowError( 'Assertion failed: invalid nonce', ); }); it('burn more than balance on behalf of other', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 + 1n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -1141,12 +1066,12 @@ describe('e2e_token_contract', () => { await wallets[1].addAuthWitness(witness); await expect( - asset.withWallet(wallets[1]).methods.burn({ address: accounts[0].address }, amount, nonce).simulate(), + asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).simulate(), ).rejects.toThrowError('Assertion failed: Balance too low'); }); it('burn on behalf of other without approval', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 / 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -1155,12 +1080,12 @@ describe('e2e_token_contract', () => { const messageHash = await burnMessageHash(accounts[1], accounts[0], amount, nonce); await expect( - asset.withWallet(wallets[1]).methods.burn({ address: accounts[0].address }, amount, nonce).simulate(), + asset.withWallet(wallets[1]).methods.burn(accounts[0].address, amount, nonce).simulate(), ).rejects.toThrowError(`Unknown auth witness for message hash 0x${messageHash.toString('hex')}`); }); it('burn on behalf of other, wrong designated caller', async () => { - const balance0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balance0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balance0 / 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -1173,13 +1098,13 @@ describe('e2e_token_contract', () => { await wallets[2].addAuthWitness(witness); await expect( - asset.withWallet(wallets[2]).methods.burn({ address: accounts[0].address }, amount, nonce).simulate(), + asset.withWallet(wallets[2]).methods.burn(accounts[0].address, amount, nonce).simulate(), ).rejects.toThrowError(`Unknown auth witness for message hash 0x${expectedMessageHash.toString('hex')}`); }); }); it('on behalf of other (invalid designated caller)', async () => { - const balancePriv0 = await asset.methods.balance_of_private({ address: accounts[0].address }).view(); + const balancePriv0 = await asset.methods.balance_of_private(accounts[0].address).view(); const amount = balancePriv0 + 2n; const nonce = Fr.random(); expect(amount).toBeGreaterThan(0n); @@ -1195,7 +1120,7 @@ describe('e2e_token_contract', () => { await wallets[2].addAuthWitness(witness); await expect( - asset.withWallet(wallets[2]).methods.burn({ address: accounts[0].address }, amount, nonce).simulate(), + asset.withWallet(wallets[2]).methods.burn(accounts[0].address, amount, nonce).simulate(), ).rejects.toThrowError(`Unknown auth witness for message hash 0x${expectedMessageHash.toString('hex')}`); }); }); diff --git a/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts b/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts index ca6866dafb0..e34244ade3f 100644 --- a/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts +++ b/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts @@ -60,10 +60,10 @@ export class CrossChainTestHarness { if (initialBalance) { logger(`Minting ${initialBalance} tokens to ${owner.address}...`); - const mintTx = l2Token.methods.mint_public({ address: owner.address }, initialBalance).send(); + const mintTx = l2Token.methods.mint_public(owner.address, initialBalance).send(); const mintReceipt = await mintTx.wait(); expect(mintReceipt.status).toBe(TxStatus.MINED); - expect(l2Token.methods.balance_of_public({ address: owner.address }).view()).toBe(initialBalance); + expect(l2Token.methods.balance_of_public(owner.address).view()).toBe(initialBalance); logger(`Minted ${initialBalance} tokens to ${owner.address}.`); } @@ -195,16 +195,14 @@ export class CrossChainTestHarness { } async mintTokensPublicOnL2(amount: bigint) { - const tx = this.l2Token.methods.mint_public({ address: this.ownerAddress }, amount).send(); + const tx = this.l2Token.methods.mint_public(this.ownerAddress, amount).send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); } async performL2Transfer(transferAmount: bigint) { // send a transfer tx to force through rollup with the message included - const transferTx = this.l2Token.methods - .transfer_public({ address: this.ownerAddress }, { address: this.receiver }, transferAmount, 0) - .send(); + const transferTx = this.l2Token.methods.transfer_public(this.ownerAddress, this.receiver, transferAmount, 0).send(); const receipt = await transferTx.wait(); expect(receipt.status).toBe(TxStatus.MINED); } @@ -221,7 +219,7 @@ export class CrossChainTestHarness { .claim_private( bridgeAmount, secretHashForRedeemingMintedNotes, - { address: this.ethAccount.toField() }, + this.ethAccount, messageKey, secretForL2MessageConsumption, ) @@ -234,13 +232,7 @@ export class CrossChainTestHarness { this.logger('Consuming messages on L2 Publicly'); // Call the mint tokens function on the Aztec.nr contract const tx = this.l2Bridge.methods - .claim_public( - { address: this.ownerAddress }, - bridgeAmount, - { address: this.ethAccount.toField() }, - messageKey, - secret, - ) + .claim_public(this.ownerAddress, bridgeAmount, this.ethAccount, messageKey, secret) .send(); const receipt = await tx.wait(); expect(receipt.status).toBe(TxStatus.MINED); @@ -248,13 +240,7 @@ export class CrossChainTestHarness { async withdrawPrivateFromAztecToL1(withdrawAmount: bigint, nonce: Fr = Fr.ZERO) { const withdrawTx = this.l2Bridge.methods - .exit_to_l1_private( - { address: this.ethAccount.toField() }, - { address: this.l2Token.address }, - withdrawAmount, - { address: EthAddress.ZERO.toField() }, - nonce, - ) + .exit_to_l1_private(this.ethAccount, this.l2Token.address, withdrawAmount, EthAddress.ZERO, nonce) .send(); const withdrawReceipt = await withdrawTx.wait(); expect(withdrawReceipt.status).toBe(TxStatus.MINED); @@ -262,19 +248,14 @@ export class CrossChainTestHarness { async withdrawPublicFromAztecToL1(withdrawAmount: bigint, nonce: Fr = Fr.ZERO) { const withdrawTx = this.l2Bridge.methods - .exit_to_l1_public( - { address: this.ethAccount.toField() }, - withdrawAmount, - { address: EthAddress.ZERO.toField() }, - nonce, - ) + .exit_to_l1_public(this.ethAccount, withdrawAmount, EthAddress.ZERO, nonce) .send(); const withdrawReceipt = await withdrawTx.wait(); expect(withdrawReceipt.status).toBe(TxStatus.MINED); } async getL2PrivateBalanceOf(owner: AztecAddress) { - return await this.l2Token.methods.balance_of_private({ address: owner }).view({ from: owner }); + return await this.l2Token.methods.balance_of_private(owner).view({ from: owner }); } async expectPrivateBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) { @@ -284,7 +265,7 @@ export class CrossChainTestHarness { } async expectPublicBalanceOnL2(owner: AztecAddress, expectedBalance: bigint) { - const balance = await this.l2Token.methods.balance_of_public({ address: owner }).view({ from: owner }); + const balance = await this.l2Token.methods.balance_of_public(owner).view({ from: owner }); expect(balance).toBe(expectedBalance); } @@ -331,14 +312,14 @@ export class CrossChainTestHarness { } async shieldFundsOnL2(shieldAmount: bigint, secretHash: Fr) { - const shieldTx = this.l2Token.methods.shield({ address: this.ownerAddress }, shieldAmount, secretHash, 0).send(); + const shieldTx = this.l2Token.methods.shield(this.ownerAddress, shieldAmount, secretHash, 0).send(); const shieldReceipt = await shieldTx.wait(); expect(shieldReceipt.status).toBe(TxStatus.MINED); } async redeemShieldPrivatelyOnL2(shieldAmount: bigint, secret: Fr) { this.logger('Spending commitment in private call'); - const privateTx = this.l2Token.methods.redeem_shield({ address: this.ownerAddress }, shieldAmount, secret).send(); + const privateTx = this.l2Token.methods.redeem_shield(this.ownerAddress, shieldAmount, secret).send(); const privateReceipt = await privateTx.wait(); expect(privateReceipt.status).toBe(TxStatus.MINED); } @@ -346,7 +327,7 @@ export class CrossChainTestHarness { async unshieldTokensOnL2(unshieldAmount: bigint, nonce = Fr.ZERO) { this.logger('Unshielding tokens'); const unshieldTx = this.l2Token.methods - .unshield({ address: this.ownerAddress }, { address: this.ownerAddress }, unshieldAmount, nonce) + .unshield(this.ownerAddress, this.ownerAddress, unshieldAmount, nonce) .send(); const unshieldReceipt = await unshieldTx.wait(); expect(unshieldReceipt.status).toBe(TxStatus.MINED); diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index 9624c2c12bc..df49c2dc438 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -352,10 +352,10 @@ export async function deployAndInitializeStandardizedTokenAndBridgeContracts( const bridgeAddress = bridge.address.toString() as `0x${string}`; // initialize l2 token - const initializeTx = token.methods._initialize({ address: owner }).send(); + const initializeTx = token.methods._initialize(owner).send(); // initialize bridge - const initializeBridgeTx = bridge.methods._initialize({ address: token.address }).send(); + const initializeBridgeTx = bridge.methods._initialize(token.address).send(); // now we wait for the txs to be mined. This way we send all tx in the same rollup. const initializeReceipt = await initializeTx.wait(); @@ -370,12 +370,11 @@ export async function deployAndInitializeStandardizedTokenAndBridgeContracts( throw new Error(`Bridge token is not ${token.address}`); // make the bridge a minter on the token: - const makeMinterTx = token.methods.set_minter({ address: bridge.address }, true).send(); + const makeMinterTx = token.methods.set_minter(bridge.address, true).send(); const makeMinterReceipt = await makeMinterTx.wait(); if (makeMinterReceipt.status !== TxStatus.MINED) throw new Error(`Make bridge a minter tx status is ${makeMinterReceipt.status}`); - if ((await token.methods.is_minter({ address: bridge.address }).view()) === 1n) - throw new Error(`Bridge is not a minter`); + if ((await token.methods.is_minter(bridge.address).view()) === 1n) throw new Error(`Bridge is not a minter`); // initialize portal await tokenPortal.write.initialize( diff --git a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts index 0f8b46252b4..161454e4afa 100644 --- a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts +++ b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts @@ -32,7 +32,7 @@ describe('guides/dapp/testing', () => { owner = await createAccount(rpc); recipient = await createAccount(rpc); token = await TokenContract.deploy(owner).send().deployed(); - await token.methods._initialize({ address: owner.getAddress() }).send().wait(); + await token.methods._initialize(owner.getAddress()).send().wait(); }, 60_000); // docs:start:stop-in-proc-sandbox @@ -40,12 +40,12 @@ describe('guides/dapp/testing', () => { // docs:end:stop-in-proc-sandbox it('increases recipient funds on mint', async () => { - expect(await token.methods.balance_of_private({ address: recipient.getAddress() }).view()).toEqual(0n); + expect(await token.methods.balance_of_private(recipient.getAddress()).view()).toEqual(0n); const secret = Fr.random(); const secretHash = await computeMessageSecretHash(secret); await token.methods.mint_private(20n, secretHash).send().wait(); - await token.methods.redeem_shield({ address: recipient.getAddress() }, 20n, secret).send().wait(); - expect(await token.methods.balance_of_private({ address: recipient.getAddress() }).view()).toEqual(20n); + await token.methods.redeem_shield(recipient.getAddress(), 20n, secret).send().wait(); + expect(await token.methods.balance_of_private(recipient.getAddress()).view()).toEqual(20n); }, 30_000); }); }); @@ -68,16 +68,16 @@ describe('guides/dapp/testing', () => { owner = await createAccount(rpc); recipient = await createAccount(rpc); token = await TokenContract.deploy(owner).send().deployed(); - await token.methods._initialize({ address: owner.getAddress() }).send().wait(); + await token.methods._initialize(owner.getAddress()).send().wait(); }, 30_000); it('increases recipient funds on mint', async () => { - expect(await token.methods.balance_of_private({ address: recipient.getAddress() }).view()).toEqual(0n); + expect(await token.methods.balance_of_private(recipient.getAddress()).view()).toEqual(0n); const secret = Fr.random(); const secretHash = await computeMessageSecretHash(secret); await token.methods.mint_private(20n, secretHash).send().wait(); - await token.methods.redeem_shield({ address: recipient.getAddress() }, 20n, secret).send().wait(); - expect(await token.methods.balance_of_private({ address: recipient.getAddress() }).view()).toEqual(20n); + await token.methods.redeem_shield(recipient.getAddress(), 20n, secret).send().wait(); + expect(await token.methods.balance_of_private(recipient.getAddress()).view()).toEqual(20n); }, 30_000); }); // docs:end:sandbox-example @@ -93,17 +93,17 @@ describe('guides/dapp/testing', () => { rpc = createAztecRpcClient(SANDBOX_URL); [owner, recipient] = await getSandboxAccountsWallets(rpc); token = await TokenContract.deploy(owner).send().deployed(); - await token.methods._initialize({ address: owner.getAddress() }).send().wait(); + await token.methods._initialize(owner.getAddress()).send().wait(); // docs:end:use-existing-wallets }, 30_000); it('increases recipient funds on mint', async () => { - expect(await token.methods.balance_of_private({ address: recipient.getAddress() }).view()).toEqual(0n); + expect(await token.methods.balance_of_private(recipient.getAddress()).view()).toEqual(0n); const secret = Fr.random(); const secretHash = await computeMessageSecretHash(secret); await token.methods.mint_private(20n, secretHash).send().wait(); - await token.methods.redeem_shield({ address: recipient.getAddress() }, 20n, secret).send().wait(); - expect(await token.methods.balance_of_private({ address: recipient.getAddress() }).view()).toEqual(20n); + await token.methods.redeem_shield(recipient.getAddress(), 20n, secret).send().wait(); + expect(await token.methods.balance_of_private(recipient.getAddress()).view()).toEqual(20n); }, 30_000); }); @@ -144,11 +144,11 @@ describe('guides/dapp/testing', () => { recipient = await createAccount(rpc); testContract = await TestContract.deploy(owner).send().deployed(); token = await TokenContract.deploy(owner).send().deployed(); - await token.methods._initialize({ address: owner.getAddress() }).send().wait(); + await token.methods._initialize(owner.getAddress()).send().wait(); const secret = Fr.random(); const secretHash = await computeMessageSecretHash(secret); await token.methods.mint_private(100n, secretHash).send().wait(); - await token.methods.redeem_shield({ address: owner.getAddress() }, 100n, secret).send().wait(); + await token.methods.redeem_shield(owner.getAddress(), 100n, secret).send().wait(); // docs:start:calc-slot cheats = await CheatCodes.create(ETHEREUM_HOST, rpc); @@ -168,7 +168,7 @@ describe('guides/dapp/testing', () => { it('checks public storage', async () => { // docs:start:public-storage - await token.methods.mint_public({ address: owner.getAddress() }, 100n).send().wait(); + await token.methods.mint_public(owner.getAddress(), 100n).send().wait(); const ownerPublicBalanceSlot = cheats.aztec.computeSlotInMap(6n, owner.getAddress()); const balance = await rpc.getPublicStorageAt(token.address, ownerPublicBalanceSlot); expect(toBigIntBE(balance!)).toEqual(100n); @@ -187,42 +187,22 @@ describe('guides/dapp/testing', () => { it('asserts a local transaction simulation fails by calling simulate', async () => { // docs:start:local-tx-fails - const call = token.methods.transfer( - { address: owner.getAddress() }, - { address: recipient.getAddress() }, - 200n, - 0, - ); + const call = token.methods.transfer(owner.getAddress(), recipient.getAddress(), 200n, 0); await expect(call.simulate()).rejects.toThrowError(/Balance too low/); // docs:end:local-tx-fails }); it('asserts a local transaction simulation fails by calling send', async () => { // docs:start:local-tx-fails-send - const call = token.methods.transfer( - { address: owner.getAddress() }, - { address: recipient.getAddress() }, - 200n, - 0, - ); + const call = token.methods.transfer(owner.getAddress(), recipient.getAddress(), 200n, 0); await expect(call.send().wait()).rejects.toThrowError(/Balance too low/); // docs:end:local-tx-fails-send }); it('asserts a transaction is dropped', async () => { // docs:start:tx-dropped - const call1 = token.methods.transfer( - { address: owner.getAddress() }, - { address: recipient.getAddress() }, - 80n, - 0, - ); - const call2 = token.methods.transfer( - { address: owner.getAddress() }, - { address: recipient.getAddress() }, - 50n, - 0, - ); + const call1 = token.methods.transfer(owner.getAddress(), recipient.getAddress(), 80n, 0); + const call2 = token.methods.transfer(owner.getAddress(), recipient.getAddress(), 50n, 0); await call1.simulate(); await call2.simulate(); @@ -234,24 +214,14 @@ describe('guides/dapp/testing', () => { it('asserts a simulation for a public function call fails', async () => { // docs:start:local-pub-fails - const call = token.methods.transfer_public( - { address: owner.getAddress() }, - { address: recipient.getAddress() }, - 1000n, - 0, - ); + const call = token.methods.transfer_public(owner.getAddress(), recipient.getAddress(), 1000n, 0); await expect(call.simulate()).rejects.toThrowError(/Underflow/); // docs:end:local-pub-fails }); it('asserts a transaction with a failing public call is dropped (until we get public reverts)', async () => { // docs:start:pub-dropped - const call = token.methods.transfer_public( - { address: owner.getAddress() }, - { address: recipient.getAddress() }, - 1000n, - 0, - ); + const call = token.methods.transfer_public(owner.getAddress(), recipient.getAddress(), 1000n, 0); await expect(call.send({ skipPublicSimulation: true }).wait()).rejects.toThrowError(/dropped/); // docs:end:pub-dropped }); diff --git a/yarn-project/end-to-end/src/sample-dapp/deploy.mjs b/yarn-project/end-to-end/src/sample-dapp/deploy.mjs index 9010da5a29b..b620819eb33 100644 --- a/yarn-project/end-to-end/src/sample-dapp/deploy.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/deploy.mjs @@ -12,7 +12,7 @@ async function main() { const [owner] = await getSandboxAccountsWallets(client); const token = await Contract.deploy(client, TokenContractAbi, []).send().deployed(); - await token.withWallet(owner).methods._initialize({ address: owner.getAddress() }).send().wait(); + await token.withWallet(owner).methods._initialize(owner.getAddress()).send().wait(); console.log(`Token deployed at ${token.address.toString()}`); diff --git a/yarn-project/end-to-end/src/sample-dapp/index.mjs b/yarn-project/end-to-end/src/sample-dapp/index.mjs index e07d8d78ed9..17b6e9024eb 100644 --- a/yarn-project/end-to-end/src/sample-dapp/index.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/index.mjs @@ -25,7 +25,7 @@ async function showPrivateBalances(client) { for (const account of accounts) { // highlight-next-line:showPrivateBalances - const balance = await token.methods.balance_of_private({ address: account.address }).view(); + const balance = await token.methods.balance_of_private(account.address).view(); console.log(`Balance of ${account.address}: ${balance}`); } // docs:end:showPrivateBalances @@ -41,7 +41,7 @@ async function mintPrivateFunds(client) { const secret = Fr.random(); const secretHash = await computeMessageSecretHash(secret); await token.methods.mint_private(mintAmount, secretHash).send().wait(); - await token.methods.redeem_shield({ address: owner.getAddress() }, mintAmount, secret).send().wait(); + await token.methods.redeem_shield(owner.getAddress(), mintAmount, secret).send().wait(); await showPrivateBalances(client); } @@ -51,7 +51,7 @@ async function transferPrivateFunds(client) { const [owner, recipient] = await getSandboxAccountsWallets(client); const token = await getToken(owner); - const tx = token.methods.transfer({ address: owner.getAddress() }, { address: recipient.getAddress() }, 1n, 0).send(); + const tx = token.methods.transfer(owner.getAddress(), recipient.getAddress(), 1n, 0).send(); console.log(`Sent transfer transaction ${await tx.getTxHash()}`); await showPrivateBalances(client); @@ -69,7 +69,7 @@ async function showPublicBalances(client) { for (const account of accounts) { // highlight-next-line:showPublicBalances - const balance = await token.methods.balance_of_public({ address: account.address }).view(); + const balance = await token.methods.balance_of_public(account.address).view(); console.log(`Balance of ${account.address}: ${balance}`); } // docs:end:showPublicBalances @@ -80,7 +80,7 @@ async function mintPublicFunds(client) { const [owner] = await getSandboxAccountsWallets(client); const token = await getToken(owner); - const tx = token.methods.mint_public({ address: owner.getAddress() }, 100n).send(); + const tx = token.methods.mint_public(owner.getAddress(), 100n).send(); console.log(`Sent mint transaction ${await tx.getTxHash()}`); await showPublicBalances(client); diff --git a/yarn-project/end-to-end/src/sample-dapp/index.test.mjs b/yarn-project/end-to-end/src/sample-dapp/index.test.mjs index 88f8cf4d335..34d7b3fe8d9 100644 --- a/yarn-project/end-to-end/src/sample-dapp/index.test.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/index.test.mjs @@ -11,13 +11,13 @@ describe('token', () => { recipient = await createAccount(rpc); token = await Contract.deploy(owner, TokenContractAbi, []).send().deployed(); - await token.methods._initialize({ address: owner.getAddress() }).send().wait(); + await token.methods._initialize(owner.getAddress()).send().wait(); const initialBalance = 20n; const secret = Fr.random(); const secretHash = await computeMessageSecretHash(secret); await token.methods.mint_private(initialBalance, secretHash).send().wait(); - await token.methods.redeem_shield({ address: owner.getAddress() }, initialBalance, secret).send().wait(); + await token.methods.redeem_shield(owner.getAddress(), initialBalance, secret).send().wait(); }, 60_000); afterAll(() => stop()); @@ -25,12 +25,9 @@ describe('token', () => { // docs:start:test it('increases recipient funds on transfer', async () => { - expect(await token.methods.balance_of_private({ address: recipient.getAddress() }).view()).toEqual(0n); - await token.methods - .transfer({ address: owner.getAddress() }, { address: recipient.getAddress() }, 20n, 0) - .send() - .wait(); - expect(await token.methods.balance_of_private({ address: recipient.getAddress() }).view()).toEqual(20n); + expect(await token.methods.balance_of_private(recipient.getAddress()).view()).toEqual(0n); + await token.methods.transfer(owner.getAddress(), recipient.getAddress(), 20n, 0).send().wait(); + expect(await token.methods.balance_of_private(recipient.getAddress()).view()).toEqual(20n); }); // docs:end:test }); From f5a30b53934f4c8f1220fa6ff11aacd3d36512a4 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Wed, 20 Sep 2023 11:35:04 -0300 Subject: [PATCH 3/3] Lint --- yarn-project/foundation/src/abi/encoder.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/foundation/src/abi/encoder.test.ts b/yarn-project/foundation/src/abi/encoder.test.ts index da033335b9c..4d8a5de6027 100644 --- a/yarn-project/foundation/src/abi/encoder.test.ts +++ b/yarn-project/foundation/src/abi/encoder.test.ts @@ -1,6 +1,6 @@ import { AztecAddress } from '../aztec-address/index.js'; import { Fr } from '../fields/fields.js'; -import { ABIParameterVisibility, FunctionAbi, FunctionAbiHeader, FunctionType, StructType } from './abi.js'; +import { ABIParameterVisibility, FunctionAbi, FunctionAbiHeader, FunctionType } from './abi.js'; import { encodeArguments } from './encoder.js'; describe('abi/encoder', () => {