Skip to content

Commit 921976a

Browse files
authored
chore!: rename get senders (#17860)
Closes https://linear.app/aztec-labs/issue/F-72/renamegetsenders-to-getaddressbook Build on top of #17835, the diff should be pretty small
2 parents 2718683 + 6d1a6bf commit 921976a

File tree

6 files changed

+25
-9
lines changed

6 files changed

+25
-9
lines changed

docs/docs/developers/migration_notes.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ Aztec is in full-speed development. Literally every version breaks compatibility
99

1010
## TBD
1111

12+
### `getSenders` renamed to `getAddressBook` in wallet interface
13+
14+
An app could request "contacts" from the wallet, which don't necessarily have to be senders in the wallet's PXE. This method has been renamed to reflect that fact:
15+
16+
```diff
17+
-wallet.getSenders();
18+
+wallet.getAddressBook();
19+
```
20+
1221
### Removal of `proveTx` from `Wallet` interface
1322

1423
Exposing this method on the interface opened the door for certain types of attacks, were an app could route proven transactions through malicious nodes (that stored them for later decryption, or collected user IPs for example). It also made transactions difficult to track for the wallet, since they could be sent without their knowledge at any time. This change also affects `ContractFunctionInteraction` and `DeployMethod`, which no longer expose a `prove()` method.

playground/src/components/common/FnParameter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ export function FunctionParameter({ parameter, required, onParameterChange, defa
6969
const setAliases = async () => {
7070
setLoading(true);
7171
const accounts = await wallet.getAccounts();
72-
const senders = await wallet.getSenders();
72+
const contacts = await wallet.getAddressBook();
7373

7474
const contracts = parseAliasedBuffersAsString(await playgroundDB.listAliases('contracts')).map(
7575
({ alias, item }) => ({ alias, item: AztecAddress.fromString(item) }),
7676
);
77-
setAliasedAddresses([...accounts, ...senders, ...contracts]);
77+
setAliasedAddresses([...accounts, ...contacts, ...contracts]);
7878
setLoading(false);
7979
};
8080
if (wallet && playgroundDB) {

playground/src/wallet/embedded_wallet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export class EmbeddedWallet extends BaseWallet {
198198
return this.pxe.registerSender(address);
199199
}
200200

201-
override async getSenders(): Promise<Aliased<AztecAddress>[]> {
201+
override async getAddressBook(): Promise<Aliased<AztecAddress>[]> {
202202
const senders = await this.pxe.getSenders();
203203
const storedSenders = await this.walletDB.listSenders();
204204
for (const storedSender of storedSenders) {

yarn-project/aztec.js/src/wallet/base_wallet.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@ export abstract class BaseWallet implements Wallet {
8787

8888
abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
8989

90-
async getSenders(): Promise<Aliased<AztecAddress>[]> {
90+
/**
91+
* Returns the list of aliased contacts associated with the wallet.
92+
* This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
93+
* - Senders: Addresses we check during synching in case they sent us notes,
94+
* - Contacts: more general concept akin to a phone's contact list.
95+
* @returns The aliased collection of AztecAddresses that form this wallet's address book
96+
*/
97+
async getAddressBook(): Promise<Aliased<AztecAddress>[]> {
9198
const senders: AztecAddress[] = await this.pxe.getSenders();
9299
return senders.map(sender => ({ item: sender, alias: '' }));
93100
}

yarn-project/aztec.js/src/wallet/wallet.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ describe('WalletSchema', () => {
100100
expect(result).toBeInstanceOf(AztecAddress);
101101
});
102102

103-
it('getSenders', async () => {
104-
const result = await context.client.getSenders();
103+
it('getAddressBook', async () => {
104+
const result = await context.client.getAddressBook();
105105
expect(result).toEqual([{ alias: 'sender1', item: expect.any(AztecAddress) }]);
106106
});
107107

@@ -284,7 +284,7 @@ class MockWallet implements Wallet {
284284
return Promise.resolve(address);
285285
}
286286

287-
async getSenders(): Promise<Aliased<AztecAddress>[]> {
287+
async getAddressBook(): Promise<Aliased<AztecAddress>[]> {
288288
return [{ alias: 'sender1', item: await AztecAddress.random() }];
289289
}
290290

yarn-project/aztec.js/src/wallet/wallet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export type Wallet = {
161161
getChainInfo(): Promise<ChainInfo>;
162162
getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
163163
registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
164-
getSenders(): Promise<Aliased<AztecAddress>[]>;
164+
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
165165
getAccounts(): Promise<Aliased<AztecAddress>[]>;
166166
registerContract(
167167
instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact,
@@ -321,7 +321,7 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
321321
.args(schemas.AztecAddress, EventMetadataDefinitionSchema, z.number(), z.number(), z.array(schemas.AztecAddress))
322322
.returns(z.array(AbiDecodedSchema)),
323323
registerSender: z.function().args(schemas.AztecAddress, optional(z.string())).returns(schemas.AztecAddress),
324-
getSenders: z
324+
getAddressBook: z
325325
.function()
326326
.args()
327327
.returns(z.array(z.object({ alias: z.string(), item: schemas.AztecAddress }))),

0 commit comments

Comments
 (0)