Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Dec 7, 2024
1 parent 621cbaf commit 4b6b5db
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 34 deletions.
3 changes: 0 additions & 3 deletions yarn-project/aztec.js/src/wallet/base_wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ export abstract class BaseWallet implements Wallet {
getRegisteredAccounts(): Promise<CompleteAddress[]> {
return this.pxe.getRegisteredAccounts();
}
getRegisteredAccount(address: AztecAddress): Promise<CompleteAddress | undefined> {
return this.pxe.getRegisteredAccount(address);
}
registerContact(address: AztecAddress): Promise<AztecAddress> {
return this.pxe.registerContact(address);
}
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function getWallet(
address: AztecAddress,
accountContract: AccountContract,
): Promise<AccountWallet> {
const completeAddress = await pxe.getRegisteredAccount(address);
const completeAddress = (await pxe.getRegisteredAccounts()).find(completeAddress => completeAddress.address.equals(address));
if (!completeAddress) {
throw new Error(`Account ${address} not found`);
}
Expand Down
5 changes: 0 additions & 5 deletions yarn-project/circuit-types/src/interfaces/pxe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ describe('PXESchema', () => {
expect(result).toEqual([expect.any(CompleteAddress)]);
});

it('getRegisteredAccount', async () => {
const result = await context.client.getRegisteredAccount(address);
expect(result).toBeInstanceOf(CompleteAddress);
});

it('registerContact', async () => {
const result = await context.client.registerContact(address);
expect(result).toEqual(address);
Expand Down
13 changes: 0 additions & 13 deletions yarn-project/circuit-types/src/interfaces/pxe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,6 @@ export interface PXE {
*/
getRegisteredAccounts(): Promise<CompleteAddress[]>;

/**
* Retrieves the complete address of the account corresponding to the provided aztec address.
* Complete addresses include the address, the partial address, and the encryption public key.
*
* @param address - The address of account.
* @returns The complete address of the requested account if found.
*/
getRegisteredAccount(address: AztecAddress): Promise<CompleteAddress | undefined>;

/**
* Registers a user contact in PXE.
*
Expand Down Expand Up @@ -478,10 +469,6 @@ export const PXESchema: ApiSchemaFor<PXE> = {
addCapsule: z.function().args(z.array(schemas.Fr)).returns(z.void()),
registerAccount: z.function().args(schemas.Fr, schemas.Fr).returns(CompleteAddress.schema),
getRegisteredAccounts: z.function().returns(z.array(CompleteAddress.schema)),
getRegisteredAccount: z
.function()
.args(schemas.AztecAddress)
.returns(z.union([CompleteAddress.schema, z.undefined()])),
registerContact: 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()),
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/cli/src/cmds/pxe/get_account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type DebugLogger, type LogFn } from '@aztec/foundation/log';

export async function getAccount(aztecAddress: AztecAddress, rpcUrl: string, debugLogger: DebugLogger, log: LogFn) {
const client = await createCompatibleClient(rpcUrl, debugLogger);
const account = await client.getRegisteredAccount(aztecAddress);
const account = (await client.getRegisteredAccounts()).find(completeAddress => completeAddress.address.equals(aztecAddress));

if (!account) {
log(`Unknown account ${aztecAddress.toString()}`);
Expand Down
8 changes: 1 addition & 7 deletions yarn-project/pxe/src/pxe_service/pxe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,6 @@ export class PXEService implements PXE {
);
}

public async getRegisteredAccount(address: AztecAddress): Promise<CompleteAddress | undefined> {
const result = await this.getRegisteredAccounts();
const account = result.find(r => r.address.equals(address));
return Promise.resolve(account);
}

public async registerContractClass(artifact: ContractArtifact): Promise<void> {
const contractClassId = computeContractClassId(getContractClassFromArtifact(artifact));
await this.db.addContractArtifact(contractClassId, artifact);
Expand Down Expand Up @@ -914,7 +908,7 @@ export class PXEService implements PXE {
const [keyPrefix, account] = this.keyStore.getKeyPrefixAndAccount(vpk);
let secretKey = await this.keyStore.getMasterSecretKey(vpk);
if (keyPrefix === 'iv') {
const registeredAccount = await this.getRegisteredAccount(account);
const registeredAccount = (await this.getRegisteredAccounts()).find(completeAddress => completeAddress.address.equals(account));
if (!registeredAccount) {
throw new Error('No registered account');
}
Expand Down
4 changes: 0 additions & 4 deletions yarn-project/pxe/src/pxe_service/test/pxe_test_suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ export const pxeTestSuite = (testName: string, pxeSetup: () => Promise<PXE>) =>
// Check that the account is correctly registered using the getAccounts and getRecipients methods
const accounts = await pxe.getRegisteredAccounts();
expect(accounts).toContainEqual(completeAddress);

// Check that the account is correctly registered using the getAccount and getRecipient methods
const account = await pxe.getRegisteredAccount(completeAddress.address);
expect(account).toEqual(completeAddress);
});

it('does not throw when registering the same account twice (just ignores the second attempt)', async () => {
Expand Down

0 comments on commit 4b6b5db

Please sign in to comment.