Skip to content

Commit

Permalink
refactor: PXE.registerContact --> PXE.registerSender
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Dec 18, 2024
1 parent 51d82aa commit 68aab05
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 17 deletions.
11 changes: 11 additions & 0 deletions docs/docs/migration_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/aztec.js/src/wallet/base_wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export abstract class BaseWallet implements Wallet {
getRegisteredAccount(address: AztecAddress): Promise<CompleteAddress | undefined> {
return this.pxe.getRegisteredAccount(address);
}
registerContact(address: AztecAddress): Promise<AztecAddress> {
return this.pxe.registerContact(address);
registerSender(address: AztecAddress): Promise<AztecAddress> {
return this.pxe.registerSender(address);
}
getContacts(): Promise<AztecAddress[]> {
return this.pxe.getContacts();
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/circuit-types/src/interfaces/pxe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -343,7 +343,7 @@ class MockPXE implements PXE {
expect(address).toBeInstanceOf(AztecAddress);
return Promise.resolve(CompleteAddress.random());
}
registerContact(address: AztecAddress): Promise<AztecAddress> {
registerSender(address: AztecAddress): Promise<AztecAddress> {
expect(address).toBeInstanceOf(AztecAddress);
return Promise.resolve(this.address);
}
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/circuit-types/src/interfaces/pxe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AztecAddress>;
registerSender(address: AztecAddress): Promise<AztecAddress>;

/**
* Retrieves the addresses stored as contacts on this PXE Service.
Expand Down Expand Up @@ -466,7 +466,7 @@ export const PXESchema: ApiSchemaFor<PXE> = {
.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()),
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/cli-wallet/src/cmds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/cli-wallet/src/cmds/register_contact.ts
Original file line number Diff line number Diff line change
@@ -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}`);
}
8 changes: 4 additions & 4 deletions yarn-project/end-to-end/src/e2e_2_pxes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/pxe/src/pxe_service/pxe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class PXEService implements PXE {
return accountCompleteAddress;
}

public async registerContact(address: AztecAddress): Promise<AztecAddress> {
public async registerSender(address: AztecAddress): Promise<AztecAddress> {
const accounts = await this.keyStore.getAccounts();
if (accounts.includes(address)) {
this.log.info(`Account:\n "${address.toString()}"\n already registered.`);
Expand Down

0 comments on commit 68aab05

Please sign in to comment.