Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: renaming getIncomingNotes #10743

Merged
merged 5 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/utils/cheat_codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class AztecCheatCodes {
* @returns The notes stored at the given slot
*/
public async loadPrivate(owner: AztecAddress, contract: AztecAddress, slot: Fr | bigint): Promise<Note[]> {
const extendedNotes = await this.pxe.getIncomingNotes({
const extendedNotes = await this.pxe.getNotes({
owner,
contractAddress: contract,
storageSlot: new Fr(slot),
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/aztec.js/src/wallet/base_wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
type EventMetadataDefinition,
type ExtendedNote,
type GetUnencryptedLogsResponse,
type IncomingNotesFilter,
type L2Block,
type LogFilter,
type NotesFilter,
type PXE,
type PXEInfo,
type PrivateExecutionResult,
Expand Down Expand Up @@ -134,8 +134,8 @@ export abstract class BaseWallet implements Wallet {
getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
return this.pxe.getTxReceipt(txHash);
}
getIncomingNotes(filter: IncomingNotesFilter): Promise<UniqueNote[]> {
return this.pxe.getIncomingNotes(filter);
getNotes(filter: NotesFilter): Promise<UniqueNote[]> {
return this.pxe.getNotes(filter);
}
getPublicStorageAt(contract: AztecAddress, storageSlot: Fr): Promise<any> {
return this.pxe.getPublicStorageAt(contract, storageSlot);
Expand Down
8 changes: 4 additions & 4 deletions yarn-project/circuit-types/src/interfaces/pxe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import { AuthWitness } from '../auth_witness.js';
import { type InBlock } from '../in_block.js';
import { L2Block } from '../l2_block.js';
import { ExtendedUnencryptedL2Log, type GetUnencryptedLogsResponse, type LogFilter } from '../logs/index.js';
import { type IncomingNotesFilter } from '../notes/incoming_notes_filter.js';
import { ExtendedNote, UniqueNote } from '../notes/index.js';
import { type NotesFilter } from '../notes/notes_filter.js';
import { PrivateExecutionResult } from '../private_execution_result.js';
import { type EpochProofQuote } from '../prover_coordination/epoch_proof_quote.js';
import { SiblingPath } from '../sibling_path/sibling_path.js';
Expand Down Expand Up @@ -190,8 +190,8 @@ describe('PXESchema', () => {
expect(result).toBeInstanceOf(Fr);
});

it('getIncomingNotes', async () => {
const result = await context.client.getIncomingNotes({ contractAddress: address });
it('getNotes', async () => {
const result = await context.client.getNotes({ contractAddress: address });
expect(result).toEqual([expect.any(UniqueNote)]);
});

Expand Down Expand Up @@ -409,7 +409,7 @@ class MockPXE implements PXE {
expect(slot).toBeInstanceOf(Fr);
return Promise.resolve(Fr.random());
}
getIncomingNotes(filter: IncomingNotesFilter): Promise<UniqueNote[]> {
getNotes(filter: NotesFilter): Promise<UniqueNote[]> {
expect(filter.contractAddress).toEqual(this.address);
return Promise.resolve([UniqueNote.random()]);
}
Expand Down
8 changes: 4 additions & 4 deletions yarn-project/circuit-types/src/interfaces/pxe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import {
type LogFilter,
LogFilterSchema,
} from '../logs/index.js';
import { type IncomingNotesFilter, IncomingNotesFilterSchema } from '../notes/incoming_notes_filter.js';
import { ExtendedNote, UniqueNote } from '../notes/index.js';
import { type NotesFilter, NotesFilterSchema } from '../notes/notes_filter.js';
import { PrivateExecutionResult } from '../private_execution_result.js';
import { SiblingPath } from '../sibling_path/sibling_path.js';
import { Tx, TxHash, TxProvingResult, TxReceipt, TxSimulationResult } from '../tx/index.js';
Expand Down Expand Up @@ -232,11 +232,11 @@ export interface PXE {
getPublicStorageAt(contract: AztecAddress, slot: Fr): Promise<Fr>;

/**
* Gets incoming notes of accounts registered in this PXE based on the provided filter.
* Gets notes registered in this PXE based on the provided filter.
* @param filter - The filter to apply to the notes.
* @returns The requested notes.
*/
getIncomingNotes(filter: IncomingNotesFilter): Promise<UniqueNote[]>;
getNotes(filter: NotesFilter): Promise<UniqueNote[]>;

/**
* Fetches an L1 to L2 message from the node.
Expand Down Expand Up @@ -483,7 +483,7 @@ export const PXESchema: ApiSchemaFor<PXE> = {
.args(TxHash.schema)
.returns(z.union([inBlockSchemaFor(TxEffect.schema), z.undefined()])),
getPublicStorageAt: z.function().args(schemas.AztecAddress, schemas.Fr).returns(schemas.Fr),
getIncomingNotes: z.function().args(IncomingNotesFilterSchema).returns(z.array(UniqueNote.schema)),
getNotes: z.function().args(NotesFilterSchema).returns(z.array(UniqueNote.schema)),
getL1ToL2MembershipWitness: z
.function()
.args(schemas.AztecAddress, schemas.Fr, schemas.Fr)
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuit-types/src/notes/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './comparator.js';
export * from './extended_note.js';
export * from './incoming_notes_filter.js';
export * from './notes_filter.js';
export * from './note_status.js';
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { TxHash } from '../tx/tx_hash.js';
import { NoteStatus } from './note_status.js';

/**
* A filter used to fetch incoming notes.
* A filter used to fetch notes.
* @remarks This filter is applied as an intersection of all its params.
*/
export type IncomingNotesFilter = {
export type NotesFilter = {
/** Hash of a transaction from which to fetch the notes. */
txHash?: TxHash;
/** The contract address the note belongs to. */
Expand All @@ -23,11 +23,11 @@ export type IncomingNotesFilter = {
status?: NoteStatus;
/** The siloed nullifier for the note. */
siloedNullifier?: Fr;
/** The scopes in which to get incoming notes from. This defaults to all scopes. */
/** The scopes in which to get notes from. This defaults to all scopes. */
scopes?: AztecAddress[];
};

export const IncomingNotesFilterSchema: ZodFor<IncomingNotesFilter> = z.object({
export const NotesFilterSchema: ZodFor<NotesFilter> = z.object({
txHash: TxHash.schema.optional(),
contractAddress: schemas.AztecAddress.optional(),
storageSlot: schemas.Fr.optional(),
Expand Down
14 changes: 7 additions & 7 deletions yarn-project/cli/src/utils/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export async function inspectTx(
log: LogFn,
opts: { includeBlockInfo?: boolean; artifactMap?: ArtifactMap } = {},
) {
const [receipt, effectsInBlock, incomingNotes] = await Promise.all([
const [receipt, effectsInBlock, getNotes] = await Promise.all([
pxe.getTxReceipt(txHash),
pxe.getTxEffect(txHash),
pxe.getIncomingNotes({ txHash, status: NoteStatus.ACTIVE_OR_NULLIFIED }),
pxe.getNotes({ txHash, status: NoteStatus.ACTIVE_OR_NULLIFIED }),
]);
// Base tx data
log(`Tx ${txHash.toString()}`);
Expand Down Expand Up @@ -88,10 +88,10 @@ export async function inspectTx(
const notes = effects.noteHashes;
if (notes.length > 0) {
log(' Created notes:');
log(` Total: ${notes.length}. Incoming: ${incomingNotes.length}.`);
if (incomingNotes.length) {
log(' Incoming notes:');
for (const note of incomingNotes) {
log(` Total: ${notes.length}. Found: ${getNotes.length}.`);
if (getNotes.length) {
log(' Found notes:');
for (const note of getNotes) {
inspectNote(note, artifactMap, log);
}
}
Expand All @@ -103,7 +103,7 @@ export async function inspectTx(
if (nullifierCount > 0) {
log(' Nullifiers:');
for (const nullifier of effects.nullifiers) {
const [note] = await pxe.getIncomingNotes({ siloedNullifier: nullifier });
const [note] = await pxe.getNotes({ siloedNullifier: nullifier });
const deployed = deployNullifiers[nullifier.toString()];
const initialized = initNullifiers[nullifier.toString()];
const registered = classNullifiers[nullifier.toString()];
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/end-to-end/src/e2e_2_pxes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ describe('e2e_2_pxes', () => {
.send()
.wait();
await testContract.methods.sync_notes().simulate();
const incomingNotes = await walletA.getIncomingNotes({ txHash: receipt.txHash });
expect(incomingNotes).toHaveLength(1);
note = incomingNotes[0];
const notes = await walletA.getNotes({ txHash: receipt.txHash });
expect(notes).toHaveLength(1);
note = notes[0];
}

// 3. Nullify the note
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ describe('e2e_blacklist_token_contract mint', () => {
// Trigger a note sync
await asset.methods.sync_notes().simulate();
// 1 note should have been created containing `amount` of tokens
const visibleIncomingNotes = await wallets[0].getIncomingNotes({ txHash: receiptClaim.txHash });
expect(visibleIncomingNotes.length).toBe(1);
expect(visibleIncomingNotes[0].note.items[0].toBigInt()).toBe(amount);
const visibleNotes = await wallets[0].getNotes({ txHash: receiptClaim.txHash });
expect(visibleNotes.length).toBe(1);
expect(visibleNotes[0].note.items[0].toBigInt()).toBe(amount);
});
});

Expand Down
22 changes: 11 additions & 11 deletions yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ describe('e2e_crowdfunding_and_claim', () => {

// Get the notes emitted by the Crowdfunding contract and check that only 1 was emitted (the value note)
await crowdfundingContract.withWallet(donorWallets[0]).methods.sync_notes().simulate();
const incomingNotes = await donorWallets[0].getIncomingNotes({ txHash: donateTxReceipt.txHash });
const notes = incomingNotes.filter(x => x.contractAddress.equals(crowdfundingContract.address));
expect(notes!.length).toEqual(1);
const notes = await donorWallets[0].getNotes({ txHash: donateTxReceipt.txHash });
const filteredNotes = notes.filter(x => x.contractAddress.equals(crowdfundingContract.address));
expect(filteredNotes!.length).toEqual(1);

// Set the value note in a format which can be passed to claim function
valueNote = processUniqueNote(notes![0]);
valueNote = processUniqueNote(filteredNotes![0]);
}

// 3) We claim the reward token via the Claim contract
Expand Down Expand Up @@ -243,12 +243,12 @@ describe('e2e_crowdfunding_and_claim', () => {

// Get the notes emitted by the Crowdfunding contract and check that only 1 was emitted (the value note)
await crowdfundingContract.withWallet(donorWallets[0]).methods.sync_notes().simulate();
const incomingNotes = await donorWallets[0].getIncomingNotes({ txHash: donateTxReceipt.txHash });
const notes = incomingNotes.filter(x => x.contractAddress.equals(crowdfundingContract.address));
expect(notes!.length).toEqual(1);
const notes = await donorWallets[0].getNotes({ txHash: donateTxReceipt.txHash });
const filtered = notes.filter(x => x.contractAddress.equals(crowdfundingContract.address));
expect(filtered!.length).toEqual(1);

// Set the value note in a format which can be passed to claim function
const anotherDonationNote = processUniqueNote(notes![0]);
const anotherDonationNote = processUniqueNote(filtered![0]);

// We create an unrelated pxe and wallet without access to the nsk_app that correlates to the npk_m specified in the proof note.
let unrelatedWallet: AccountWallet;
Expand Down Expand Up @@ -299,9 +299,9 @@ describe('e2e_crowdfunding_and_claim', () => {
{
const receipt = await inclusionsProofsContract.methods.create_note(owner, 5n).send().wait({ debug: true });
await inclusionsProofsContract.methods.sync_notes().simulate();
const incomingNotes = await wallets[0].getIncomingNotes({ txHash: receipt.txHash });
expect(incomingNotes.length).toEqual(1);
note = processUniqueNote(incomingNotes[0]);
const notes = await wallets[0].getNotes({ txHash: receipt.txHash });
expect(notes.length).toEqual(1);
note = processUniqueNote(notes[0]);
}

// 3) Test the note was included
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ describe('e2e_pending_note_hashes_contract', () => {

await deployedContract.methods.sync_notes().simulate();

const incomingNotes = await wallet.getIncomingNotes({ txHash: txReceipt.txHash });
const notes = await wallet.getNotes({ txHash: txReceipt.txHash });

expect(incomingNotes.length).toBe(1);
expect(notes.length).toBe(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('e2e_inclusion_proofs_contract', () => {
describe('proves note existence and its nullifier non-existence and nullifier non-existence failure case', () => {
// Owner of a note
let noteCreationBlockNumber: number;
let noteHashes, visibleIncomingNotes: ExtendedNote[];
let noteHashes, visibleNotes: ExtendedNote[];
const value = 100n;
let validNoteBlockNumber: any;

Expand All @@ -65,13 +65,13 @@ describe('e2e_inclusion_proofs_contract', () => {
({ noteHashes } = receipt.debugInfo!);

await contract.methods.sync_notes().simulate();
visibleIncomingNotes = await wallets[0].getIncomingNotes({ txHash: receipt.txHash });
visibleNotes = await wallets[0].getNotes({ txHash: receipt.txHash });
});

it('should return the correct values for creating a note', () => {
expect(noteHashes.length).toBe(1);
expect(visibleIncomingNotes.length).toBe(1);
const [receivedValue, receivedOwner, _randomness] = visibleIncomingNotes[0].note.items;
expect(visibleNotes.length).toBe(1);
const [receivedValue, receivedOwner, _randomness] = visibleNotes[0].note.items;
expect(receivedValue.toBigInt()).toBe(value);
expect(receivedOwner).toEqual(owner.toField());
});
Expand Down Expand Up @@ -161,11 +161,11 @@ describe('e2e_inclusion_proofs_contract', () => {
const { noteHashes } = receipt.debugInfo!;

await contract.methods.sync_notes().simulate();
const visibleIncomingNotes = await wallets[0].getIncomingNotes({ txHash: receipt.txHash });
const visibleNotes = await wallets[0].getNotes({ txHash: receipt.txHash });

expect(noteHashes.length).toBe(1);
expect(visibleIncomingNotes.length).toBe(1);
const [receivedValue, receivedOwner, _randomness] = visibleIncomingNotes[0].note.items;
expect(visibleNotes.length).toBe(1);
const [receivedValue, receivedOwner, _randomness] = visibleNotes[0].note.items;
expect(receivedValue.toBigInt()).toBe(value);
expect(receivedOwner).toEqual(owner.toField());
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/guides/dapp_testing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('guides/dapp/testing', () => {
it('checks private storage', async () => {
// docs:start:private-storage
await token.methods.sync_notes().simulate();
const notes = await pxe.getIncomingNotes({
const notes = await pxe.getNotes({
owner: owner.getAddress(),
contractAddress: token.address,
storageSlot: ownerSlot,
Expand Down
9 changes: 0 additions & 9 deletions yarn-project/pxe/src/database/incoming_note_dao.test.ts

This file was deleted.

Loading
Loading