Skip to content

Commit

Permalink
use fn selector
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-kothari committed Oct 11, 2023
1 parent 5118fd6 commit 06bd42f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion yarn-project/acir-simulator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:^",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/acir-simulator/src/public/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions yarn-project/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 06bd42f

Please sign in to comment.