From 68aab059819d5db853306096fa4bc2693070f2d8 Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 18 Dec 2024 18:39:42 +0000 Subject: [PATCH] refactor: PXE.registerContact --> PXE.registerSender --- docs/docs/migration_notes.md | 11 +++++++++++ yarn-project/aztec.js/src/wallet/base_wallet.ts | 4 ++-- yarn-project/circuit-types/src/interfaces/pxe.test.ts | 6 +++--- yarn-project/circuit-types/src/interfaces/pxe.ts | 4 ++-- yarn-project/cli-wallet/src/cmds/index.ts | 4 ++-- yarn-project/cli-wallet/src/cmds/register_contact.ts | 4 ++-- yarn-project/end-to-end/src/e2e_2_pxes.test.ts | 8 ++++---- .../end-to-end/src/e2e_crowdfunding_and_claim.test.ts | 2 +- yarn-project/pxe/src/pxe_service/pxe_service.ts | 2 +- 9 files changed, 28 insertions(+), 17 deletions(-) diff --git a/docs/docs/migration_notes.md b/docs/docs/migration_notes.md index b7817ae8bd7..52f7122d806 100644 --- a/docs/docs/migration_notes.md +++ b/docs/docs/migration_notes.md @@ -6,6 +6,17 @@ keywords: [sandbox, aztec, notes, migration, updating, upgrading] Aztec is in full-speed development. Literally every version breaks compatibility with the previous ones. This page attempts to target errors and difficulties you might encounter when upgrading, and how to resolve them. +## TBD + +### PXE.registerContact --> PXE.registerSender +`registerContact` has been deemed confusing because the name is too similar to `registerContract`. +For this reason we've decided to rename it: + +```diff +- await pxe.registerContact(address); ++ await pxe.registerSender(address); +``` + ## 0.67.1 ### Noir contracts package no longer exposes artifacts as default export diff --git a/yarn-project/aztec.js/src/wallet/base_wallet.ts b/yarn-project/aztec.js/src/wallet/base_wallet.ts index e455ee4c0be..ff59ba0cee3 100644 --- a/yarn-project/aztec.js/src/wallet/base_wallet.ts +++ b/yarn-project/aztec.js/src/wallet/base_wallet.ts @@ -86,8 +86,8 @@ export abstract class BaseWallet implements Wallet { getRegisteredAccount(address: AztecAddress): Promise { return this.pxe.getRegisteredAccount(address); } - registerContact(address: AztecAddress): Promise { - return this.pxe.registerContact(address); + registerSender(address: AztecAddress): Promise { + return this.pxe.registerSender(address); } getContacts(): Promise { return this.pxe.getContacts(); diff --git a/yarn-project/circuit-types/src/interfaces/pxe.test.ts b/yarn-project/circuit-types/src/interfaces/pxe.test.ts index 9bf3ca99f59..562601f082a 100644 --- a/yarn-project/circuit-types/src/interfaces/pxe.test.ts +++ b/yarn-project/circuit-types/src/interfaces/pxe.test.ts @@ -118,8 +118,8 @@ describe('PXESchema', () => { expect(result).toBeInstanceOf(CompleteAddress); }); - it('registerContact', async () => { - const result = await context.client.registerContact(address); + it('registerSender', async () => { + const result = await context.client.registerSender(address); expect(result).toEqual(address); }); @@ -343,7 +343,7 @@ class MockPXE implements PXE { expect(address).toBeInstanceOf(AztecAddress); return Promise.resolve(CompleteAddress.random()); } - registerContact(address: AztecAddress): Promise { + registerSender(address: AztecAddress): Promise { expect(address).toBeInstanceOf(AztecAddress); return Promise.resolve(this.address); } diff --git a/yarn-project/circuit-types/src/interfaces/pxe.ts b/yarn-project/circuit-types/src/interfaces/pxe.ts index 62c99eb84ba..42dfcd2b99f 100644 --- a/yarn-project/circuit-types/src/interfaces/pxe.ts +++ b/yarn-project/circuit-types/src/interfaces/pxe.ts @@ -123,7 +123,7 @@ export interface PXE { * @param address - Address of the user to add to the address book * @returns The address address of the account. */ - registerContact(address: AztecAddress): Promise; + registerSender(address: AztecAddress): Promise; /** * Retrieves the addresses stored as contacts on this PXE Service. @@ -466,7 +466,7 @@ export const PXESchema: ApiSchemaFor = { .function() .args(schemas.AztecAddress) .returns(z.union([CompleteAddress.schema, z.undefined()])), - registerContact: z.function().args(schemas.AztecAddress).returns(schemas.AztecAddress), + registerSender: z.function().args(schemas.AztecAddress).returns(schemas.AztecAddress), getContacts: z.function().returns(z.array(schemas.AztecAddress)), removeContact: z.function().args(schemas.AztecAddress).returns(z.void()), registerContractClass: z.function().args(ContractArtifactSchema).returns(z.void()), diff --git a/yarn-project/cli-wallet/src/cmds/index.ts b/yarn-project/cli-wallet/src/cmds/index.ts index 1915e080af7..e8ded3a0c28 100644 --- a/yarn-project/cli-wallet/src/cmds/index.ts +++ b/yarn-project/cli-wallet/src/cmds/index.ts @@ -628,13 +628,13 @@ export function injectCommands( .addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)) .addOption(createAliasOption('Alias for the contact. Used for easy reference in subsequent commands.', !db)) .action(async (address, options) => { - const { registerContact } = await import('./register_contact.js'); + const { registerSender } = await import('./register_contact.js'); const { from: parsedFromAddress, rpcUrl, secretKey, alias } = options; const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger)); const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey); const wallet = await getWalletWithScopes(account, db); - await registerContact(wallet, address, log); + await registerSender(wallet, address, log); if (db && alias) { await db.storeContact(address, alias, log); diff --git a/yarn-project/cli-wallet/src/cmds/register_contact.ts b/yarn-project/cli-wallet/src/cmds/register_contact.ts index 8a3c9ea9d6f..91247257df8 100644 --- a/yarn-project/cli-wallet/src/cmds/register_contact.ts +++ b/yarn-project/cli-wallet/src/cmds/register_contact.ts @@ -1,7 +1,7 @@ import { type AccountWalletWithSecretKey, type AztecAddress } from '@aztec/aztec.js'; import { type LogFn } from '@aztec/foundation/log'; -export async function registerContact(wallet: AccountWalletWithSecretKey, address: AztecAddress, log: LogFn) { - await wallet.registerContact(address); +export async function registerSender(wallet: AccountWalletWithSecretKey, address: AztecAddress, log: LogFn) { + await wallet.registerSender(address); log(`Contact registered: ${address}`); } diff --git a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts index d52f3494ecd..c5f7b3134d9 100644 --- a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts @@ -49,8 +49,8 @@ describe('e2e_2_pxes', () => { What is a more robust solution? */ await sleep(5000); - await walletA.registerContact(walletB.getAddress()); - await walletB.registerContact(walletA.getAddress()); + await walletA.registerSender(walletB.getAddress()); + await walletB.registerSender(walletA.getAddress()); }); afterEach(async () => { @@ -182,13 +182,13 @@ describe('e2e_2_pxes', () => { const sharedAccountAddress = sharedAccountOnA.getCompleteAddress(); const sharedWalletOnA = await sharedAccountOnA.waitSetup(); - await sharedWalletOnA.registerContact(walletA.getAddress()); + await sharedWalletOnA.registerSender(walletA.getAddress()); const sharedAccountOnB = getUnsafeSchnorrAccount(pxeB, sharedSecretKey, sharedAccountOnA.salt); await sharedAccountOnB.register(); const sharedWalletOnB = await sharedAccountOnB.getWallet(); - await sharedWalletOnB.registerContact(sharedWalletOnA.getAddress()); + await sharedWalletOnB.registerSender(sharedWalletOnA.getAddress()); // deploy the contract on PXE A const token = await deployToken(walletA, initialBalance, logger); diff --git a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts index 0ac2e55f332..8918c3eb74a 100644 --- a/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts +++ b/yarn-project/end-to-end/src/e2e_crowdfunding_and_claim.test.ts @@ -116,7 +116,7 @@ describe('e2e_crowdfunding_and_claim', () => { // as a contact to all donor wallets, so they can receive notes await Promise.all( donorWallets.map(async wallet => { - await wallet.registerContact(operatorWallet.getAddress()); + await wallet.registerSender(operatorWallet.getAddress()); }), ); // Now we mint DNT to donors diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index ec8c0226d61..0160a8cff62 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -164,7 +164,7 @@ export class PXEService implements PXE { return accountCompleteAddress; } - public async registerContact(address: AztecAddress): Promise { + public async registerSender(address: AztecAddress): Promise { const accounts = await this.keyStore.getAccounts(); if (accounts.includes(address)) { this.log.info(`Account:\n "${address.toString()}"\n already registered.`);