Skip to content

Commit

Permalink
addressing Jan's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Aug 13, 2024
1 parent 7ec6080 commit 4c33a50
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export {
EncryptedLogOutgoingBody,
EventType,
ExtendedNote,
ExtendedNoteWithNonce,
UniqueNote,
FunctionCall,
L1Actor,
L1ToL2Message,
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/aztec.js/src/rpc_clients/pxe_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
AuthWitness,
EncryptedNoteL2BlockL2Logs,
ExtendedNote,
ExtendedNoteWithNonce,
ExtendedUnencryptedL2Log,
L2Block,
LogId,
Expand All @@ -16,6 +15,7 @@ import {
TxHash,
TxReceipt,
UnencryptedL2BlockL2Logs,
UniqueNote,
} from '@aztec/circuit-types';
import {
AztecAddress,
Expand Down Expand Up @@ -46,7 +46,7 @@ export const createPXEClient = (url: string, fetch = makeFetch([1, 2, 3], false)
FunctionSelector,
EthAddress,
ExtendedNote,
ExtendedNoteWithNonce,
UniqueNote,
ExtendedUnencryptedL2Log,
Fr,
GrumpkinScalar,
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,7 +3,6 @@ import {
type EventMetadata,
type EventType,
type ExtendedNote,
type ExtendedNoteWithNonce,
type GetUnencryptedLogsResponse,
type IncomingNotesFilter,
type L2Block,
Expand All @@ -18,6 +17,7 @@ import {
type TxExecutionRequest,
type TxHash,
type TxReceipt,
type UniqueNote,
} from '@aztec/circuit-types';
import { type NoteProcessorStats } from '@aztec/circuit-types/stats';
import {
Expand Down Expand Up @@ -121,10 +121,10 @@ export abstract class BaseWallet implements Wallet {
getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
return this.pxe.getTxReceipt(txHash);
}
getIncomingNotes(filter: IncomingNotesFilter): Promise<ExtendedNoteWithNonce[]> {
getIncomingNotes(filter: IncomingNotesFilter): Promise<UniqueNote[]> {
return this.pxe.getIncomingNotes(filter);
}
getOutgoingNotes(filter: OutgoingNotesFilter): Promise<ExtendedNoteWithNonce[]> {
getOutgoingNotes(filter: OutgoingNotesFilter): Promise<UniqueNote[]> {
return this.pxe.getOutgoingNotes(filter);
}
getPublicStorageAt(contract: AztecAddress, storageSlot: Fr): Promise<any> {
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/circuit-types/src/interfaces/pxe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { type AuthWitness } from '../auth_witness.js';
import { type L2Block } from '../l2_block.js';
import { type GetUnencryptedLogsResponse, type L1EventPayload, type LogFilter } from '../logs/index.js';
import { type IncomingNotesFilter } from '../notes/incoming_notes_filter.js';
import { type ExtendedNote, type ExtendedNoteWithNonce, type OutgoingNotesFilter } from '../notes/index.js';
import { type ExtendedNote, type OutgoingNotesFilter, type UniqueNote } from '../notes/index.js';
import { type NoteProcessorStats } from '../stats/stats.js';
import { type SimulatedTx, type Tx, type TxHash, type TxReceipt } from '../tx/index.js';
import { type TxEffect } from '../tx_effect.js';
Expand Down Expand Up @@ -235,14 +235,14 @@ export interface PXE {
* @param filter - The filter to apply to the notes.
* @returns The requested notes.
*/
getIncomingNotes(filter: IncomingNotesFilter): Promise<ExtendedNoteWithNonce[]>;
getIncomingNotes(filter: IncomingNotesFilter): Promise<UniqueNote[]>;

/**
* Gets outgoing notes of accounts registered in this PXE based on the provided filter.
* @param filter - The filter to apply to the notes.
* @returns The requested notes.
*/
getOutgoingNotes(filter: OutgoingNotesFilter): Promise<ExtendedNoteWithNonce[]>;
getOutgoingNotes(filter: OutgoingNotesFilter): Promise<UniqueNote[]>;

/**
* Adds a note to the database.
Expand Down
8 changes: 4 additions & 4 deletions yarn-project/circuit-types/src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { Fr } from '@aztec/foundation/fields';
import { type ContractInstanceWithAddress, SerializableContractInstance } from '@aztec/types/contracts';

import { EncryptedNoteTxL2Logs, EncryptedTxL2Logs, Note, UnencryptedTxL2Logs } from './logs/index.js';
import { ExtendedNote, ExtendedNoteWithNonce } from './notes/index.js';
import { ExtendedNote, UniqueNote } from './notes/index.js';
import { PublicExecutionRequest } from './public_execution_request.js';
import { NestedProcessReturnValues, PublicSimulationOutput, SimulatedTx, Tx, TxHash } from './tx/index.js';

Expand Down Expand Up @@ -256,14 +256,14 @@ export const randomExtendedNote = ({
return new ExtendedNote(note, owner, contractAddress, storageSlot, noteTypeId, txHash);
};

export const randomExtendedNoteWithNonce = ({
export const randomUniqueNote = ({
note = Note.random(),
owner = AztecAddress.random(),
contractAddress = AztecAddress.random(),
txHash = randomTxHash(),
storageSlot = Fr.random(),
noteTypeId = NoteSelector.random(),
nonce = Fr.random(),
}: Partial<ExtendedNoteWithNonce> = {}) => {
return new ExtendedNoteWithNonce(note, owner, contractAddress, storageSlot, noteTypeId, txHash, nonce);
}: Partial<UniqueNote> = {}) => {
return new UniqueNote(note, owner, contractAddress, storageSlot, noteTypeId, txHash, nonce);
};
12 changes: 6 additions & 6 deletions yarn-project/circuit-types/src/notes/extended_note.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { randomExtendedNote, randomExtendedNoteWithNonce } from '../mocks.js';
import { ExtendedNote, ExtendedNoteWithNonce } from './extended_note.js';
import { randomExtendedNote, randomUniqueNote } from '../mocks.js';
import { ExtendedNote, UniqueNote } from './extended_note.js';

describe('Extended Note', () => {
it('convert to and from buffer', () => {
Expand All @@ -9,10 +9,10 @@ describe('Extended Note', () => {
});
});

describe('Extended Note with nonce', () => {
describe('Unique Note', () => {
it('convert to and from buffer', () => {
const extendedNote = randomExtendedNoteWithNonce();
const buf = extendedNote.toBuffer();
expect(ExtendedNoteWithNonce.fromBuffer(buf)).toEqual(extendedNote);
const uniqueNote = randomUniqueNote();
const buf = uniqueNote.toBuffer();
expect(UniqueNote.fromBuffer(buf)).toEqual(uniqueNote);
});
});
4 changes: 2 additions & 2 deletions yarn-project/circuit-types/src/notes/extended_note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class ExtendedNote {
}
}

export class ExtendedNoteWithNonce extends ExtendedNote {
export class UniqueNote extends ExtendedNote {
constructor(
/** The note as emitted from the Noir contract. */
note: Note,
Expand Down Expand Up @@ -106,6 +106,6 @@ export class ExtendedNoteWithNonce extends ExtendedNote {

static override fromString(str: string) {
const hex = str.replace(/^0x/, '');
return ExtendedNoteWithNonce.fromBuffer(Buffer.from(hex, 'hex'));
return UniqueNote.fromBuffer(Buffer.from(hex, 'hex'));
}
}
6 changes: 3 additions & 3 deletions yarn-project/circuit-types/src/tx/tx_receipt.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RevertCode } from '@aztec/circuits.js';
import { type Fr } from '@aztec/foundation/fields';

import { type ExtendedNoteWithNonce } from '../notes/extended_note.js';
import { type UniqueNote } from '../notes/extended_note.js';
import { type PublicDataWrite } from '../public_data_write.js';
import { TxHash } from './tx_hash.js';

Expand Down Expand Up @@ -126,11 +126,11 @@ interface DebugInfo {
* in the PXE which was used to submit the tx. You will not get notes of accounts which are not registered in
* the PXE here even though they were created in this tx.
*/
visibleIncomingNotes: ExtendedNoteWithNonce[];
visibleIncomingNotes: UniqueNote[];
/**
* Notes created in this tx which were successfully decoded with the outgoing keys of accounts which are registered
* in the PXE which was used to submit the tx. You will not get notes of accounts which are not registered in
* the PXE here even though they were created in this tx.
*/
visibleOutgoingNotes: ExtendedNoteWithNonce[];
visibleOutgoingNotes: UniqueNote[];
}
24 changes: 12 additions & 12 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 @@ -6,13 +6,13 @@ import {
type CheatCodes,
type DebugLogger,
ExtendedNote,
type ExtendedNoteWithNonce,
Fr,
Note,
type PXE,
PackedValues,
TxExecutionRequest,
type TxHash,
type UniqueNote,
computeSecretHash,
deriveKeys,
} from '@aztec/aztec.js';
Expand Down Expand Up @@ -181,22 +181,22 @@ describe('e2e_crowdfunding_and_claim', () => {
]);
};

// Processes extended note such that it can be passed to a claim function of Claim contract
const processExtendedNote = (extendedNote: ExtendedNoteWithNonce) => {
// Processes unique note such that it can be passed to a claim function of Claim contract
const processUniqueNote = (uniqueNote: UniqueNote) => {
return {
header: {
// eslint-disable-next-line camelcase
contract_address: extendedNote.contractAddress,
contract_address: uniqueNote.contractAddress,
// eslint-disable-next-line camelcase
storage_slot: extendedNote.storageSlot,
storage_slot: uniqueNote.storageSlot,
// eslint-disable-next-line camelcase
note_hash_counter: 0, // set as 0 as note is not transient
nonce: extendedNote.nonce,
nonce: uniqueNote.nonce,
},
value: extendedNote.note.items[0],
value: uniqueNote.note.items[0],
// eslint-disable-next-line camelcase
npk_m_hash: extendedNote.note.items[1],
randomness: extendedNote.note.items[2],
npk_m_hash: uniqueNote.note.items[1],
randomness: uniqueNote.note.items[2],
};
};

Expand Down Expand Up @@ -229,7 +229,7 @@ describe('e2e_crowdfunding_and_claim', () => {
expect(notes!.length).toEqual(1);

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

// 3) We claim the reward token via the Claim contract
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('e2e_crowdfunding_and_claim', () => {
expect(notes!.length).toEqual(1);

// Set the value note in a format which can be passed to claim function
const anotherDonationNote = processExtendedNote(notes![0]);
const anotherDonationNote = processUniqueNote(notes![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 @@ -352,7 +352,7 @@ describe('e2e_crowdfunding_and_claim', () => {
const receipt = await inclusionsProofsContract.methods.create_note(owner, 5n).send().wait({ debug: true });
const { visibleIncomingNotes } = receipt.debugInfo!;
expect(visibleIncomingNotes.length).toEqual(1);
note = processExtendedNote(visibleIncomingNotes![0]);
note = processUniqueNote(visibleIncomingNotes![0]);
}

// 3) Test the note was included
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/pxe/src/pxe_http/pxe_http_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
CompleteAddress,
EncryptedNoteL2BlockL2Logs,
ExtendedNote,
ExtendedNoteWithNonce,
ExtendedUnencryptedL2Log,
L2Block,
LogId,
Expand All @@ -17,6 +16,7 @@ import {
TxHash,
TxReceipt,
UnencryptedL2BlockL2Logs,
UniqueNote,
} from '@aztec/circuit-types';
import { FunctionSelector } from '@aztec/circuits.js';
import { NoteSelector } from '@aztec/foundation/abi';
Expand Down Expand Up @@ -49,7 +49,7 @@ export function createPXERpcServer(pxeService: PXE): JsonRpcServer {
GrumpkinScalar,
Note,
ExtendedNote,
ExtendedNoteWithNonce,
UniqueNote,
AuthWitness,
L2Block,
TxEffect,
Expand Down
10 changes: 5 additions & 5 deletions yarn-project/pxe/src/pxe_service/pxe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
type EventMetadata,
EventType,
type ExtendedNote,
ExtendedNoteWithNonce,
type FunctionCall,
type GetUnencryptedLogsResponse,
type IncomingNotesFilter,
Expand All @@ -27,6 +26,7 @@ import {
type TxHash,
type TxReceipt,
UnencryptedTxL2Logs,
UniqueNote,
isNoirCallStackUnresolved,
} from '@aztec/circuit-types';
import {
Expand Down Expand Up @@ -297,7 +297,7 @@ export class PXEService implements PXE {
return await this.node.getPublicStorageAt(contract, slot, 'latest');
}

public async getIncomingNotes(filter: IncomingNotesFilter): Promise<ExtendedNoteWithNonce[]> {
public async getIncomingNotes(filter: IncomingNotesFilter): Promise<UniqueNote[]> {
const noteDaos = await this.db.getIncomingNotes(filter);

// TODO(#6531): Refactor --> This type conversion is ugly but I decided to keep it this way for now because
Expand All @@ -313,7 +313,7 @@ export class PXEService implements PXE {
}
owner = completeAddresses.address;
}
return new ExtendedNoteWithNonce(
return new UniqueNote(
dao.note,
owner,
dao.contractAddress,
Expand All @@ -326,7 +326,7 @@ export class PXEService implements PXE {
return Promise.all(extendedNotes);
}

public async getOutgoingNotes(filter: OutgoingNotesFilter): Promise<ExtendedNoteWithNonce[]> {
public async getOutgoingNotes(filter: OutgoingNotesFilter): Promise<UniqueNote[]> {
const noteDaos = await this.db.getOutgoingNotes(filter);

// TODO(#6532): Refactor --> This type conversion is ugly but I decided to keep it this way for now because
Expand All @@ -342,7 +342,7 @@ export class PXEService implements PXE {
}
owner = completeAddresses.address;
}
return new ExtendedNoteWithNonce(
return new UniqueNote(
dao.note,
owner,
dao.contractAddress,
Expand Down

0 comments on commit 4c33a50

Please sign in to comment.