From df457585e9efdfb515f3cf1e11cb9e8ae0524b59 Mon Sep 17 00:00:00 2001 From: Rahul Kothari Date: Tue, 10 Oct 2023 16:15:02 +0000 Subject: [PATCH] use fn selector --- yarn-project/acir-simulator/package.json | 3 ++- .../acir-simulator/src/client/private_execution.test.ts | 8 ++++---- yarn-project/acir-simulator/src/public/index.test.ts | 4 ++-- yarn-project/yarn.lock | 1 + 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/yarn-project/acir-simulator/package.json b/yarn-project/acir-simulator/package.json index dab0530657fe..070ee6ba9521 100644 --- a/yarn-project/acir-simulator/package.json +++ b/yarn-project/acir-simulator/package.json @@ -36,7 +36,8 @@ "@noir-lang/acvm_js": "0.26.1", "levelup": "^5.1.1", "memdown": "^6.1.1", - "tslib": "^2.4.0" + "tslib": "^2.4.0", + "viem": "^1.2.5" }, "devDependencies": { "@aztec/merkle-tree": "workspace:^", diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index 5190c0ad9c1a..43aae8e5d71a 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -48,6 +48,7 @@ import { jest } from '@jest/globals'; import { MockProxy, mock } from 'jest-mock-extended'; import { default as levelup } from 'levelup'; import { type MemDown, default as memdown } from 'memdown'; +import { getFunctionSelector } from 'viem'; import { buildL1ToL2Message, getFunctionArtifact } from '../test/utils.js'; import { computeSlotForMapping } from '../utils.js'; @@ -649,14 +650,13 @@ describe('Private Execution test suite', () => { it('Should be able to consume a dummy cross chain message', async () => { const bridgedAmount = 100n; - const artifact = getFunctionArtifact(TestContractAbi, 'consume_mint_private_message'); + const artifact = getFunctionArtifact(TestContractArtifact, 'consume_mint_private_message'); const secretForL1ToL2MessageConsumption = new Fr(1n); const secretHashForRedeemingNotes = new Fr(2n); const canceller = EthAddress.random(); - // Function selector: 0x25d46b0f keccak256('mint_private(uint256,bytes32,address)') const preimage = await buildL1ToL2Message( - '25d46b0f', + getFunctionSelector('mint_private(uint256,bytes32,address)').substring(2), [new Fr(bridgedAmount), secretHashForRedeemingNotes, canceller.toField()], contractAddress, secretForL1ToL2MessageConsumption, @@ -690,7 +690,7 @@ describe('Private Execution test suite', () => { it('Should be able to consume a dummy public to private message', async () => { const amount = 100n; - const artifact = getFunctionArtifact(TokenContractAbi, 'redeem_shield'); + const artifact = getFunctionArtifact(TokenContractArtifact, 'redeem_shield'); const wasm = await CircuitsWasm.get(); const secret = new Fr(1n); diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index f6480fe6f5d7..539b10c20f1d 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -23,6 +23,7 @@ import { import { MockProxy, mock } from 'jest-mock-extended'; import { type MemDown, default as memdown } from 'memdown'; +import { getFunctionSelector } from 'viem'; import { buildL1ToL2Message } from '../test/utils.js'; import { computeSlotForMapping } from '../utils.js'; @@ -358,9 +359,8 @@ describe('ACIR public execution simulator', () => { const secret = new Fr(1n); const recipient = AztecAddress.random(); - // Function selector: 0x63c9440d keccak256('mint_public(uint256,bytes32,address)') const preimage = await buildL1ToL2Message( - '63c9440d', + getFunctionSelector('mint_public(uint256,bytes32,address)').substring(2), [new Fr(bridgedAmount), recipient.toField(), canceller.toField()], contractAddress, secret, diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 605dcd7c10a0..0415549e0855 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -82,6 +82,7 @@ __metadata: ts-node: ^10.9.1 tslib: ^2.4.0 typescript: ^5.0.4 + viem: ^1.2.5 languageName: unknown linkType: soft