diff --git a/yarn-project/aztec.js/src/index.ts b/yarn-project/aztec.js/src/index.ts index e17f3436d24..fc1a49e5adb 100644 --- a/yarn-project/aztec.js/src/index.ts +++ b/yarn-project/aztec.js/src/index.ts @@ -46,6 +46,7 @@ export { type L2AmountClaimWithRecipient, type L2Claim, type WrappedFieldLike, + type IntentAction, } from './utils/index.js'; export { NoteSelector } from '@aztec/foundation/abi'; diff --git a/yarn-project/aztec.js/src/wallet/base_wallet.ts b/yarn-project/aztec.js/src/wallet/base_wallet.ts index 7087fc3414b..47b431f4ae2 100644 --- a/yarn-project/aztec.js/src/wallet/base_wallet.ts +++ b/yarn-project/aztec.js/src/wallet/base_wallet.ts @@ -211,4 +211,7 @@ export abstract class BaseWallet implements Wallet { ): Promise<[bigint, SiblingPath]> { return this.pxe.getL1ToL2MembershipWitness(contractAddress, messageHash, secret); } + getL2ToL1MembershipWitness(blockNumber: number, l2Tol1Message: Fr): Promise<[bigint, SiblingPath]> { + return this.pxe.getL2ToL1MembershipWitness(blockNumber, l2Tol1Message); + } } diff --git a/yarn-project/circuit-types/src/interfaces/pxe.test.ts b/yarn-project/circuit-types/src/interfaces/pxe.test.ts index 88af066544c..8cd0b35ee90 100644 --- a/yarn-project/circuit-types/src/interfaces/pxe.test.ts +++ b/yarn-project/circuit-types/src/interfaces/pxe.test.ts @@ -200,6 +200,11 @@ describe('PXESchema', () => { expect(result).toEqual([expect.any(BigInt), expect.any(SiblingPath)]); }); + it('getL2ToL1MembershipWitness', async () => { + const result = await context.client.getL2ToL1MembershipWitness(42, Fr.random()); + expect(result).toEqual([expect.any(BigInt), expect.any(SiblingPath)]); + }); + it('addNote', async () => { await context.client.addNote(ExtendedNote.random(), address); }); @@ -423,6 +428,11 @@ class MockPXE implements PXE { expect(secret).toBeInstanceOf(Fr); return Promise.resolve([1n, SiblingPath.random(L1_TO_L2_MSG_TREE_HEIGHT)]); } + getL2ToL1MembershipWitness(blockNumber: number, l2Tol1Message: Fr): Promise<[bigint, SiblingPath]> { + expect(typeof blockNumber).toEqual('number'); + expect(l2Tol1Message).toBeInstanceOf(Fr); + return Promise.resolve([1n, SiblingPath.random(4)]); + } addNote(note: ExtendedNote, scope?: AztecAddress | undefined): Promise { expect(note).toBeInstanceOf(ExtendedNote); expect(scope).toEqual(this.address); diff --git a/yarn-project/circuit-types/src/interfaces/pxe.ts b/yarn-project/circuit-types/src/interfaces/pxe.ts index 3aba7950797..1cfaa5af4e9 100644 --- a/yarn-project/circuit-types/src/interfaces/pxe.ts +++ b/yarn-project/circuit-types/src/interfaces/pxe.ts @@ -252,6 +252,14 @@ export interface PXE { secret: Fr, ): Promise<[bigint, SiblingPath]>; + /** + * Gets the membership witness for a message that was emitted at a particular block + * @param blockNumber - The block number in which to search for the message + * @param l2Tol1Message - The message to search for + * @returns The membership witness for the message + */ + getL2ToL1MembershipWitness(blockNumber: number, l2Tol1Message: Fr): Promise<[bigint, SiblingPath]>; + /** * Adds a note to the database. * @throws If the note hash of the note doesn't exist in the tree. @@ -488,6 +496,10 @@ export const PXESchema: ApiSchemaFor = { .function() .args(schemas.AztecAddress, schemas.Fr, schemas.Fr) .returns(z.tuple([schemas.BigInt, SiblingPath.schemaFor(L1_TO_L2_MSG_TREE_HEIGHT)])), + getL2ToL1MembershipWitness: z + .function() + .args(z.number(), schemas.Fr) + .returns(z.tuple([schemas.BigInt, SiblingPath.schema])), addNote: z.function().args(ExtendedNote.schema, optional(schemas.AztecAddress)).returns(z.void()), addNullifiedNote: z.function().args(ExtendedNote.schema).returns(z.void()), getBlock: z diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index 8f1091e04be..4388a7a99f3 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -307,6 +307,10 @@ export class PXEService implements PXE { return await getNonNullifiedL1ToL2MessageWitness(this.node, contractAddress, messageHash, secret); } + public getL2ToL1MembershipWitness(blockNumber: number, l2Tol1Message: Fr): Promise<[bigint, SiblingPath]> { + return this.node.getL2ToL1MessageMembershipWitness(blockNumber, l2Tol1Message); + } + public async addNote(note: ExtendedNote, scope?: AztecAddress) { const owner = await this.db.getCompleteAddress(note.owner); if (!owner) {