@azguardwallet/aztec-wallet 2.0.3 → 3.0.0-devnet.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,7 +30,7 @@ const wallet = await AztecWallet.connect(
30
30
  logo: "...",
31
31
  url: "..."
32
32
  },
33
- "testnet" // or "sandbox", or CAIP-string like "aztec:11155111"
33
+ "devnet" // or "sandbox", or CAIP-string like "aztec:1674512022"
34
34
  );
35
35
  ```
36
36
 
@@ -41,14 +41,15 @@ import { AztecAddress } from '@aztec/aztec.js/addresses';
41
41
  import { SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee';
42
42
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
43
43
 
44
- const address = wallet.getAddress();
44
+ const accounts = await wallet.getAccounts();
45
+ const address = accounts[0].item;
45
46
 
46
47
  const tokenAddress = AztecAddress.fromString("0x...");
47
48
  const tokenContract = await TokenContract.at(tokenAddress, wallet);
48
49
 
49
50
  // get token private balance
50
51
 
51
- const prvBalance = await token.methods
52
+ const prvBalance = await tokenContract.methods
52
53
  .balance_of_private(address)
53
54
  .simulate({from: address});
54
55
 
@@ -56,7 +57,7 @@ console.log("Private balance", prvBalance);
56
57
 
57
58
  // get token public balance
58
59
 
59
- const pubBalance = await token.methods
60
+ const pubBalance = await tokenContract.methods
60
61
  .balance_of_public(address)
61
62
  .simulate({from: address});
62
63
 
@@ -70,7 +71,7 @@ const feeOptions = {
70
71
  ),
71
72
  };
72
73
 
73
- const txReceipt = await token.methods
74
+ const txReceipt = await tokenContract.methods
74
75
  .transfer(AztecAddress.fromString("0x..."), 100000000n)
75
76
  .send({from: address, fee: feeOptions})
76
77
  .wait();
@@ -87,7 +88,9 @@ When Azguard user confirms connection from a dapp (`AztecWallet.connect()`), a d
87
88
  Even though the `AztecWallet` client reconnects automatically, you might want to additionally track the connection state. You can do the following:
88
89
 
89
90
  ```js
90
- // connect the wallet (in most cases it's called automatically under the hood, so you don't have to call it manually)
91
+ // connect the wallet
92
+ // (in most cases it's called automatically under the hood,
93
+ // so you don't have to call it manually)
91
94
  await wallet.connect();
92
95
 
93
96
  // check if the wallet is connected
package/dist/azguard.d.ts CHANGED
@@ -1,21 +1,25 @@
1
1
  import { CaipChain, DappMetadata } from "@azguardwallet/types";
2
- import { AuthWitness, AztecAddress, CompleteAddress, ContractArtifact, ContractInstanceWithAddress, Fr, IntentAction, IntentInnerHash, NodeInfo, Tx, TxExecutionRequest, TxHash, TxProfileResult, TxReceipt, Wallet } from "@aztec/aztec.js";
3
- import { FeeOptions, TxExecutionOptions } from "@aztec/entrypoints/interfaces";
2
+ import { CallIntent, IntentInnerHash } from "@aztec/aztec.js/authorization";
3
+ import { Aliased, BatchableMethods, BatchedMethod, BatchResults, ContractInstanceAndArtifact, ProfileOptions, SendOptions, SimulateOptions, Wallet } from "@aztec/aztec.js/wallet";
4
+ import { ChainInfo } from "@aztec/entrypoints/interfaces";
4
5
  import { ExecutionPayload } from "@aztec/entrypoints/payload";
5
- import { GasFees } from "@aztec/stdlib/gas";
6
- import { ContractClassMetadata, ContractMetadata, PXEInfo, EventMetadataDefinition } from "@aztec/stdlib/interfaces/client";
7
- import { SimulationOverrides, TxSimulationResult, UtilitySimulationResult, PrivateExecutionResult, TxProvingResult } from "@aztec/stdlib/tx";
6
+ import { Fr } from "@aztec/foundation/fields";
7
+ import { ContractArtifact, EventMetadataDefinition } from "@aztec/stdlib/abi";
8
+ import { AztecAddress } from "@aztec/stdlib/aztec-address";
9
+ import { AuthWitness } from "@aztec/stdlib/auth-witness";
10
+ import { ContractClassMetadata, ContractInstanceWithAddress, ContractInstantiationData, ContractMetadata } from "@aztec/stdlib/contract";
11
+ import { TxSimulationResult, UtilitySimulationResult, TxHash, TxReceipt, TxProfileResult } from "@aztec/stdlib/tx";
8
12
  /** Azguard Wallet client fully compatible with Aztec.js' `Wallet` interface */
9
13
  export declare class AztecWallet implements Wallet {
10
14
  #private;
11
15
  /**
12
16
  * Creates `AztecWallet` instance, connected to Azguard Wallet
13
17
  * @param dapp Dapp metadata (default: { name: window.location.hostname })
14
- * @param chain Chain (default: "testnet")
18
+ * @param chain Chain (default: "devnet")
15
19
  * @param timeout Timeout in ms for the `window.azguard` object lookup (default: 1000ms)
16
20
  * @returns AztecWallet instance
17
21
  */
18
- static connect(dapp?: DappMetadata, chain?: "testnet" | "sandbox" | CaipChain, timeout?: number): Promise<AztecWallet>;
22
+ static connect(dapp?: DappMetadata, chain?: "devnet" | "sandbox" | CaipChain, timeout?: number): Promise<AztecWallet>;
19
23
  /** Indicates whether the wallet is connected or not */
20
24
  get connected(): boolean;
21
25
  /** Event handlers invoked when the wallet is connected */
@@ -27,32 +31,19 @@ export declare class AztecWallet implements Wallet {
27
31
  /** Disconnects from the wallet */
28
32
  disconnect(): Promise<void>;
29
33
  private constructor();
30
- getCompleteAddress(): CompleteAddress;
31
- getAddress(): AztecAddress;
32
- getChainId(): Fr;
33
- getVersion(): Fr;
34
- createTxExecutionRequest(exec: ExecutionPayload, fee: FeeOptions, options: TxExecutionOptions): Promise<TxExecutionRequest>;
35
- createAuthWit(messageHashOrIntent: IntentAction | IntentInnerHash | Fr | Buffer): Promise<AuthWitness>;
36
- simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, skipTxValidation?: boolean, skipFeeEnforcement?: boolean, overrides?: SimulationOverrides, scopes?: AztecAddress[]): Promise<TxSimulationResult>;
37
- simulateUtility(functionName: string, args: any[], to: AztecAddress, authwits?: AuthWitness[], from?: AztecAddress, scopes?: AztecAddress[]): Promise<UtilitySimulationResult>;
38
- profileTx(txRequest: TxExecutionRequest, profileMode: "gates" | "execution-steps" | "full", skipProofGeneration?: boolean, msgSender?: AztecAddress): Promise<TxProfileResult>;
39
- sendTx(tx: Tx): Promise<TxHash>;
40
34
  getContractClassMetadata(id: Fr, includeArtifact?: boolean): Promise<ContractClassMetadata>;
41
35
  getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
42
- registerContract(contract: {
43
- instance: ContractInstanceWithAddress;
44
- artifact?: ContractArtifact;
45
- }): Promise<void>;
46
- registerContractClass(artifact: ContractArtifact): Promise<void>;
47
- proveTx(txRequest: TxExecutionRequest, privateExecutionResult?: PrivateExecutionResult): Promise<TxProvingResult>;
48
- getNodeInfo(): Promise<NodeInfo>;
49
- getPXEInfo(): Promise<PXEInfo>;
50
- getCurrentBaseFees(): Promise<GasFees>;
51
- updateContract(contractAddress: AztecAddress, artifact: ContractArtifact): Promise<void>;
52
- registerSender(address: AztecAddress): Promise<AztecAddress>;
53
- getSenders(): Promise<AztecAddress[]>;
54
- removeSender(address: AztecAddress): Promise<void>;
55
- getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
56
36
  getPrivateEvents<T>(contractAddress: AztecAddress, eventMetadata: EventMetadataDefinition, from: number, numBlocks: number, recipients: AztecAddress[]): Promise<T[]>;
57
- getPublicEvents<T>(eventMetadata: EventMetadataDefinition, from: number, limit: number): Promise<T[]>;
37
+ getChainInfo(): Promise<ChainInfo>;
38
+ getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
39
+ registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
40
+ getAddressBook(): Promise<Aliased<AztecAddress>[]>;
41
+ getAccounts(): Promise<Aliased<AztecAddress>[]>;
42
+ registerContract(instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
43
+ simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
44
+ simulateUtility(functionName: string, args: any[], to: AztecAddress, authwits?: AuthWitness[]): Promise<UtilitySimulationResult>;
45
+ profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
46
+ sendTx(exec: ExecutionPayload, opts: SendOptions): Promise<TxHash>;
47
+ createAuthWit(from: AztecAddress, messageHashOrIntent: Fr | Buffer<ArrayBuffer> | IntentInnerHash | CallIntent): Promise<AuthWitness>;
48
+ batch<const T extends readonly BatchedMethod<keyof BatchableMethods>[]>(methods: T): Promise<BatchResults<T>>;
58
49
  }
package/dist/azguard.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import { AzguardClient } from "@azguardwallet/client";
2
- import { AuthWitness, AztecAddress, CompleteAddress, ContractFunctionInteraction, Fr, TxExecutionRequest, TxHash, TxProfileResult, TxReceipt, } from "@aztec/aztec.js";
3
- import { GasFees } from "@aztec/stdlib/gas";
4
- import { TxSimulationResult, UtilitySimulationResult, TxProvingResult, } from "@aztec/stdlib/tx";
5
- import { NodeInfoSchema } from "@aztec/stdlib/contract";
2
+ import { AztecAddress } from "@aztec/stdlib/aztec-address";
3
+ import { AuthWitness } from "@aztec/stdlib/auth-witness";
4
+ import { ContractInstanceWithAddressSchema, } from "@aztec/stdlib/contract";
5
+ import { TxSimulationResult, UtilitySimulationResult, TxHash, TxReceipt, TxProfileResult } from "@aztec/stdlib/tx";
6
6
  import z from "zod";
7
- import { ContractClassMetadataSchema, ContractMetadataSchema, PXEInfoSchema } from "./schemas";
7
+ import { AddressBookSchema, ChainInfoSchema, ContractClassMetadataSchema, ContractMetadataSchema } from "./schemas";
8
8
  import { aztecMethods } from "./methods";
9
9
  /** Azguard Wallet client fully compatible with Aztec.js' `Wallet` interface */
10
10
  export class AztecWallet {
11
11
  /**
12
12
  * Creates `AztecWallet` instance, connected to Azguard Wallet
13
13
  * @param dapp Dapp metadata (default: { name: window.location.hostname })
14
- * @param chain Chain (default: "testnet")
14
+ * @param chain Chain (default: "devnet")
15
15
  * @param timeout Timeout in ms for the `window.azguard` object lookup (default: 1000ms)
16
16
  * @returns AztecWallet instance
17
17
  */
@@ -19,11 +19,11 @@ export class AztecWallet {
19
19
  if (!dapp?.name) {
20
20
  dapp = { ...dapp, name: window.location.hostname };
21
21
  }
22
- if (!chain || chain === "testnet") {
23
- chain = "aztec:11155111";
22
+ if (!chain || chain === "devnet") {
23
+ chain = "aztec:1674512022";
24
24
  }
25
25
  else if (chain === "sandbox") {
26
- chain = "aztec:31337";
26
+ chain = "aztec:0";
27
27
  }
28
28
  const azguard = await AzguardClient.create("aztec.js", timeout ?? 1000);
29
29
  const wallet = new AztecWallet(azguard, chain, dapp);
@@ -53,35 +53,21 @@ export class AztecWallet {
53
53
  #azguard;
54
54
  #chain;
55
55
  #dapp;
56
- #completeAddress;
57
- #address;
58
- #chainId;
59
- #version;
60
56
  constructor(azguard, chain, dapp) {
61
57
  this.#azguard = azguard;
62
58
  this.#chain = chain;
63
59
  this.#dapp = dapp;
64
60
  this.#azguard.onAccountsChanged.addHandler(this.#onAccountsChanged);
65
61
  this.#azguard.onPermissionsChanged.addHandler(this.#onPermissionsChanged);
66
- this.#azguard.onDisconnected.addHandler(this.#onDisconnected);
67
62
  }
68
- #onAccountsChanged = (accounts) => {
69
- const currentAccount = this.#address?.toString();
70
- if (currentAccount && !accounts.some((x) => x.endsWith(currentAccount))) {
71
- this.#azguard.disconnect();
72
- }
63
+ #onAccountsChanged = () => {
64
+ this.#azguard.disconnect();
73
65
  };
74
66
  #onPermissionsChanged = (permissions) => {
75
67
  if (aztecMethods.some((x) => !permissions.some((p) => p.chains?.includes(this.#chain) && p.methods?.includes(x)))) {
76
68
  this.#azguard.disconnect();
77
69
  }
78
70
  };
79
- #onDisconnected = () => {
80
- this.#completeAddress = undefined;
81
- this.#address = undefined;
82
- this.#chainId = undefined;
83
- this.#version = undefined;
84
- };
85
71
  async #ensureConnected() {
86
72
  if (!this.#azguard.connected) {
87
73
  await this.#azguard.connect(this.#dapp, [
@@ -91,33 +77,6 @@ export class AztecWallet {
91
77
  },
92
78
  ]);
93
79
  }
94
- if (!this.#version) {
95
- const [r1, r2, r3, r4] = await this.#azguard.execute([
96
- {
97
- kind: "aztec_getCompleteAddress",
98
- account: this.#azguard.accounts[0],
99
- },
100
- {
101
- kind: "aztec_getAddress",
102
- account: this.#azguard.accounts[0],
103
- },
104
- {
105
- kind: "aztec_getChainId",
106
- chain: this.#chain,
107
- },
108
- {
109
- kind: "aztec_getVersion",
110
- chain: this.#chain,
111
- },
112
- ]);
113
- if (r1.status !== "ok" || r2.status !== "ok" || r3.status !== "ok" || r4.status !== "ok") {
114
- throw new Error("Failed to initialize aztec wallet");
115
- }
116
- this.#completeAddress = await CompleteAddress.schema.parseAsync(r1.result);
117
- this.#address = await AztecAddress.schema.parseAsync(r2.result);
118
- this.#chainId = await Fr.schema.parseAsync(r3.result);
119
- this.#version = await Fr.schema.parseAsync(r4.result);
120
- }
121
80
  }
122
81
  async #account() {
123
82
  await this.#ensureConnected();
@@ -134,118 +93,6 @@ export class AztecWallet {
134
93
  }
135
94
  return await schema.parseAsync(result.result);
136
95
  }
137
- getCompleteAddress() {
138
- if (!this.#completeAddress) {
139
- throw new Error("Aztec wallet was disconnected by the user");
140
- }
141
- return this.#completeAddress;
142
- }
143
- getAddress() {
144
- if (!this.#address) {
145
- throw new Error("Aztec wallet was disconnected by the user");
146
- }
147
- return this.#address;
148
- }
149
- getChainId() {
150
- if (!this.#chainId) {
151
- throw new Error("Aztec wallet was disconnected by the user");
152
- }
153
- return this.#chainId;
154
- }
155
- getVersion() {
156
- if (!this.#version) {
157
- throw new Error("Aztec wallet was disconnected by the user");
158
- }
159
- return this.#version;
160
- }
161
- async createTxExecutionRequest(exec, fee, options) {
162
- let asset;
163
- try {
164
- asset = await fee.paymentMethod.getAsset();
165
- }
166
- catch { }
167
- const paymentMethodDto = {
168
- asset,
169
- executionPayload: await fee.paymentMethod.getExecutionPayload(fee.gasSettings),
170
- feePayer: await fee.paymentMethod.getFeePayer(fee.gasSettings),
171
- };
172
- return await this.#execute(TxExecutionRequest.schema, {
173
- kind: "aztec_createTxExecutionRequest",
174
- account: await this.#account(),
175
- exec,
176
- fee: {
177
- paymentMethod: paymentMethodDto,
178
- gasSettings: fee.gasSettings,
179
- },
180
- options,
181
- });
182
- }
183
- async createAuthWit(messageHashOrIntent) {
184
- let intentDto;
185
- if (typeof messageHashOrIntent === "object" && "caller" in messageHashOrIntent) {
186
- intentDto = {
187
- caller: messageHashOrIntent.caller,
188
- action: messageHashOrIntent.action instanceof ContractFunctionInteraction
189
- ? (await messageHashOrIntent.action.request()).calls[0]
190
- : messageHashOrIntent.action,
191
- };
192
- }
193
- else if (typeof messageHashOrIntent === "object" && "consumer" in messageHashOrIntent) {
194
- intentDto = {
195
- consumer: messageHashOrIntent.consumer,
196
- innerHash: new Fr(messageHashOrIntent.innerHash),
197
- };
198
- }
199
- else {
200
- intentDto = new Fr(messageHashOrIntent);
201
- }
202
- return await this.#execute(AuthWitness.schema, {
203
- kind: "aztec_createAuthWit",
204
- account: await this.#account(),
205
- messageHashOrIntent: intentDto,
206
- });
207
- }
208
- async simulateTx(txRequest, simulatePublic, skipTxValidation, skipFeeEnforcement, overrides, scopes) {
209
- return await this.#execute(TxSimulationResult.schema, {
210
- kind: "aztec_simulateTx",
211
- chain: this.#chain,
212
- txRequest,
213
- simulatePublic,
214
- skipTxValidation,
215
- skipFeeEnforcement,
216
- overrides,
217
- scopes,
218
- });
219
- }
220
- async simulateUtility(functionName, args, to, authwits, from, scopes) {
221
- return await this.#execute(UtilitySimulationResult.schema, {
222
- kind: "aztec_simulateUtility",
223
- chain: this.#chain,
224
- functionName,
225
- args,
226
- to,
227
- authwits,
228
- from,
229
- scopes,
230
- });
231
- }
232
- async profileTx(txRequest, profileMode, skipProofGeneration, msgSender) {
233
- return await this.#execute(TxProfileResult.schema, {
234
- kind: "aztec_profileTx",
235
- chain: this.#chain,
236
- txRequest,
237
- profileMode,
238
- skipProofGeneration,
239
- msgSender,
240
- });
241
- }
242
- async sendTx(tx) {
243
- return await this.#execute(TxHash.schema, {
244
- kind: "aztec_sendTx",
245
- chain: this.#chain,
246
- tx,
247
- });
248
- }
249
96
  async getContractClassMetadata(id, includeArtifact) {
250
97
  return await this.#execute(ContractClassMetadataSchema, {
251
98
  kind: "aztec_getContractClassMetadata",
@@ -261,99 +108,223 @@ export class AztecWallet {
261
108
  address,
262
109
  });
263
110
  }
264
- async registerContract(contract) {
265
- return await this.#execute(z.void(), {
266
- kind: "aztec_registerContract",
111
+ async getPrivateEvents(contractAddress, eventMetadata, from, numBlocks, recipients) {
112
+ return await this.#execute(z.any(), {
113
+ kind: "aztec_getPrivateEvents",
267
114
  chain: this.#chain,
268
- contract,
115
+ contractAddress,
116
+ eventMetadata,
117
+ from,
118
+ numBlocks,
119
+ recipients,
269
120
  });
270
121
  }
271
- async registerContractClass(artifact) {
272
- return await this.#execute(z.void(), {
273
- kind: "aztec_registerContractClass",
122
+ async getChainInfo() {
123
+ return await this.#execute(ChainInfoSchema, {
124
+ kind: "aztec_getChainInfo",
274
125
  chain: this.#chain,
275
- artifact,
276
126
  });
277
127
  }
278
- async proveTx(txRequest, privateExecutionResult) {
279
- return await this.#execute(TxProvingResult.schema, {
280
- kind: "aztec_proveTx",
128
+ async getTxReceipt(txHash) {
129
+ return await this.#execute(TxReceipt.schema, {
130
+ kind: "aztec_getTxReceipt",
281
131
  chain: this.#chain,
282
- txRequest,
283
- privateExecutionResult,
132
+ txHash,
284
133
  });
285
134
  }
286
- async getNodeInfo() {
287
- return await this.#execute(NodeInfoSchema, {
288
- kind: "aztec_getNodeInfo",
135
+ async registerSender(address, alias) {
136
+ return await this.#execute(AztecAddress.schema, {
137
+ kind: "aztec_registerSender",
289
138
  chain: this.#chain,
139
+ address,
140
+ alias,
290
141
  });
291
142
  }
292
- async getPXEInfo() {
293
- return await this.#execute(PXEInfoSchema, {
294
- kind: "aztec_getPXEInfo",
143
+ async getAddressBook() {
144
+ return await this.#execute(AddressBookSchema, {
145
+ kind: "aztec_getAddressBook",
295
146
  chain: this.#chain,
296
147
  });
297
148
  }
298
- async getCurrentBaseFees() {
299
- return await this.#execute(GasFees.schema, {
300
- kind: "aztec_getCurrentBaseFees",
301
- chain: this.#chain,
302
- });
149
+ async getAccounts() {
150
+ await this.#ensureConnected();
151
+ return this.#azguard.accounts.map((x, i) => ({
152
+ alias: `Account ${i + 1}`,
153
+ item: AztecAddress.fromString(x.split(":").at(-1)),
154
+ }));
303
155
  }
304
- async updateContract(contractAddress, artifact) {
305
- return await this.#execute(z.void(), {
306
- kind: "aztec_updateContract",
156
+ async registerContract(instanceData, artifact, secretKey) {
157
+ return await this.#execute(ContractInstanceWithAddressSchema, {
158
+ kind: "aztec_registerContract",
307
159
  chain: this.#chain,
308
- contractAddress,
160
+ instanceData,
309
161
  artifact,
162
+ secretKey,
310
163
  });
311
164
  }
312
- async registerSender(address) {
313
- return await this.#execute(AztecAddress.schema, {
314
- kind: "aztec_registerSender",
315
- chain: this.#chain,
316
- address,
165
+ async simulateTx(exec, opts) {
166
+ await this.#ensureConnected();
167
+ const account = this.#azguard.accounts.find((x) => x.endsWith(opts?.from?.toString()));
168
+ if (!account) {
169
+ throw new Error("Unauthorized 'from' account");
170
+ }
171
+ return await this.#execute(TxSimulationResult.schema, {
172
+ kind: "aztec_simulateTx",
173
+ account,
174
+ exec,
175
+ opts,
317
176
  });
318
177
  }
319
- async getSenders() {
320
- return await this.#execute(z.array(AztecAddress.schema), {
321
- kind: "aztec_getSenders",
322
- chain: this.#chain,
178
+ async simulateUtility(functionName, args, to, authwits) {
179
+ return await this.#execute(UtilitySimulationResult.schema, {
180
+ kind: "aztec_simulateUtility",
181
+ account: await this.#account(),
182
+ functionName,
183
+ args,
184
+ to,
185
+ authwits,
323
186
  });
324
187
  }
325
- async removeSender(address) {
326
- return await this.#execute(z.void(), {
327
- kind: "aztec_removeSender",
328
- chain: this.#chain,
329
- address,
188
+ async profileTx(exec, opts) {
189
+ await this.#ensureConnected();
190
+ const account = this.#azguard.accounts.find((x) => x.endsWith(opts?.from?.toString()));
191
+ if (!account) {
192
+ throw new Error("Unauthorized 'from' account");
193
+ }
194
+ return await this.#execute(TxProfileResult.schema, {
195
+ kind: "aztec_profileTx",
196
+ account,
197
+ exec,
198
+ opts,
330
199
  });
331
200
  }
332
- async getTxReceipt(txHash) {
333
- return await this.#execute(TxReceipt.schema, {
334
- kind: "aztec_getTxReceipt",
335
- chain: this.#chain,
336
- txHash,
201
+ async sendTx(exec, opts) {
202
+ await this.#ensureConnected();
203
+ const account = this.#azguard.accounts.find((x) => x.endsWith(opts?.from?.toString()));
204
+ if (!account) {
205
+ throw new Error("Unauthorized 'from' account");
206
+ }
207
+ return await this.#execute(TxHash.schema, {
208
+ kind: "aztec_sendTx",
209
+ account,
210
+ exec,
211
+ opts,
337
212
  });
338
213
  }
339
- async getPrivateEvents(contractAddress, eventMetadata, from, numBlocks, recipients) {
340
- return await this.#execute(z.any(), {
341
- kind: "aztec_getPrivateEvents",
342
- chain: this.#chain,
343
- contractAddress,
344
- eventMetadata,
345
- from,
346
- numBlocks,
347
- recipients,
214
+ async createAuthWit(from, messageHashOrIntent) {
215
+ await this.#ensureConnected();
216
+ const account = this.#azguard.accounts.find((x) => x.endsWith(from?.toString()));
217
+ if (!account) {
218
+ throw new Error("Unauthorized 'from' account");
219
+ }
220
+ return await this.#execute(AuthWitness.schema, {
221
+ kind: "aztec_createAuthWit",
222
+ account,
223
+ messageHashOrIntent,
348
224
  });
349
225
  }
350
- async getPublicEvents(eventMetadata, from, limit) {
351
- return await this.#execute(z.any(), {
352
- kind: "aztec_getPublicEvents",
353
- chain: this.#chain,
354
- eventMetadata,
355
- from,
356
- limit,
357
- });
226
+ async batch(methods) {
227
+ await this.#ensureConnected();
228
+ const operations = [];
229
+ for (const method of methods) {
230
+ switch (method.name) {
231
+ case "registerContract": {
232
+ const [instanceData, artifact, secretKey] = method.args;
233
+ operations.push({
234
+ kind: "aztec_registerContract",
235
+ chain: this.#chain,
236
+ instanceData,
237
+ artifact,
238
+ secretKey,
239
+ });
240
+ break;
241
+ }
242
+ case "registerSender": {
243
+ const [address, alias] = method.args;
244
+ operations.push({
245
+ kind: "aztec_registerSender",
246
+ chain: this.#chain,
247
+ address,
248
+ alias: alias,
249
+ });
250
+ break;
251
+ }
252
+ case "sendTx": {
253
+ const [exec, opts] = method.args;
254
+ const account = this.#azguard.accounts.find((x) => x.endsWith(opts?.from?.toString()));
255
+ if (!account) {
256
+ throw new Error("Unauthorized 'from' account");
257
+ }
258
+ operations.push({
259
+ kind: "aztec_sendTx",
260
+ account,
261
+ exec,
262
+ opts,
263
+ });
264
+ break;
265
+ }
266
+ case "simulateUtility": {
267
+ const [functionName, args, to, authwits] = method.args;
268
+ operations.push({
269
+ kind: "aztec_simulateUtility",
270
+ account: await this.#account(),
271
+ functionName: functionName,
272
+ args: args,
273
+ to,
274
+ authwits,
275
+ });
276
+ break;
277
+ }
278
+ default: {
279
+ throw new Error("Unsupported batch method");
280
+ }
281
+ }
282
+ }
283
+ const results = await this.#azguard.execute(operations);
284
+ const output = [];
285
+ for (let i = 0; i < results.length; i++) {
286
+ const method = methods[i].name;
287
+ const result = results[i];
288
+ if (result.status === "failed") {
289
+ throw new Error(`${method} failed with '${result.error}'`);
290
+ }
291
+ if (result.status === "skipped") {
292
+ throw new Error(`${method} was skipped`);
293
+ }
294
+ switch (method) {
295
+ case "registerContract": {
296
+ output.push({
297
+ method,
298
+ result: await ContractInstanceWithAddressSchema.parseAsync(result.result),
299
+ });
300
+ break;
301
+ }
302
+ case "registerSender": {
303
+ output.push({
304
+ method,
305
+ result: await AztecAddress.schema.parseAsync(result.result),
306
+ });
307
+ break;
308
+ }
309
+ case "sendTx": {
310
+ output.push({
311
+ method,
312
+ result: await TxHash.schema.parseAsync(result.result),
313
+ });
314
+ break;
315
+ }
316
+ case "simulateUtility": {
317
+ output.push({
318
+ method,
319
+ result: await UtilitySimulationResult.schema.parseAsync(result.result),
320
+ });
321
+ break;
322
+ }
323
+ default: {
324
+ throw new Error("Unsupported batch method");
325
+ }
326
+ }
327
+ }
328
+ return output;
358
329
  }
359
330
  }
package/dist/methods.js CHANGED
@@ -1,27 +1,15 @@
1
1
  export const aztecMethods = [
2
+ "aztec_getContractClassMetadata",
3
+ "aztec_getContractMetadata",
4
+ "aztec_getPrivateEvents",
5
+ "aztec_getChainInfo",
6
+ "aztec_getTxReceipt",
7
+ "aztec_registerSender",
8
+ "aztec_getAddressBook",
9
+ "aztec_registerContract",
2
10
  "aztec_simulateTx",
3
11
  "aztec_simulateUtility",
4
12
  "aztec_profileTx",
5
13
  "aztec_sendTx",
6
- "aztec_getContractClassMetadata",
7
- "aztec_getContractMetadata",
8
- "aztec_registerContract",
9
- "aztec_registerContractClass",
10
- "aztec_proveTx",
11
- "aztec_getNodeInfo",
12
- "aztec_getPXEInfo",
13
- "aztec_getCurrentBaseFees",
14
- "aztec_updateContract",
15
- "aztec_registerSender",
16
- "aztec_getSenders",
17
- "aztec_removeSender",
18
- "aztec_getTxReceipt",
19
- "aztec_getPrivateEvents",
20
- "aztec_getPublicEvents",
21
- "aztec_getCompleteAddress",
22
- "aztec_getAddress",
23
- "aztec_getChainId",
24
- "aztec_getVersion",
25
- "aztec_createTxExecutionRequest",
26
14
  "aztec_createAuthWit",
27
15
  ];
package/dist/schemas.d.ts CHANGED
@@ -1,227 +1,11 @@
1
- import { EventSelector } from "@aztec/stdlib/abi";
1
+ import { Aliased } from "@aztec/aztec.js/wallet";
2
+ import { ChainInfo } from "@aztec/entrypoints/interfaces";
2
3
  import { ZodFor } from "@aztec/foundation/schemas";
3
- import z from "zod";
4
- export declare const ContractClassMetadataSchema: z.ZodObject<{
5
- contractClass: z.ZodUnion<[z.ZodObject<{
6
- version: z.ZodLiteral<1>;
7
- artifactHash: z.ZodType<import("@aztec/aztec.js").Fr, any, string>;
8
- privateFunctions: z.ZodArray<z.ZodObject<{
9
- selector: ZodFor<import("@aztec/aztec.js").FunctionSelector>;
10
- vkHash: z.ZodType<import("@aztec/aztec.js").Fr, any, string>;
11
- }, "strip", z.ZodTypeAny, {
12
- selector: import("@aztec/aztec.js").FunctionSelector;
13
- vkHash: import("@aztec/aztec.js").Fr;
14
- }, {
15
- vkHash: string;
16
- selector?: any;
17
- }>, "many">;
18
- packedBytecode: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Buffer<ArrayBuffer>, string>, z.ZodEffects<z.ZodObject<{
19
- type: z.ZodLiteral<"Buffer">;
20
- data: z.ZodArray<z.ZodNumber, "many">;
21
- }, "strip", z.ZodTypeAny, {
22
- type: "Buffer";
23
- data: number[];
24
- }, {
25
- type: "Buffer";
26
- data: number[];
27
- }>, Buffer<ArrayBuffer>, {
28
- type: "Buffer";
29
- data: number[];
30
- }>]>;
31
- } & {
32
- id: z.ZodType<import("@aztec/aztec.js").Fr, any, string>;
33
- }, "strip", z.ZodTypeAny, {
34
- version: 1;
35
- id: import("@aztec/aztec.js").Fr;
36
- artifactHash: import("@aztec/aztec.js").Fr;
37
- packedBytecode: Buffer<ArrayBuffer>;
38
- privateFunctions: {
39
- selector: import("@aztec/aztec.js").FunctionSelector;
40
- vkHash: import("@aztec/aztec.js").Fr;
41
- }[];
42
- }, {
43
- version: 1;
44
- id: string;
45
- artifactHash: string;
46
- packedBytecode: string | {
47
- type: "Buffer";
48
- data: number[];
49
- };
50
- privateFunctions: {
51
- vkHash: string;
52
- selector?: any;
53
- }[];
54
- }>, z.ZodUndefined]>;
55
- isContractClassPubliclyRegistered: z.ZodBoolean;
56
- artifact: z.ZodUnion<[ZodFor<import("@aztec/aztec.js").ContractArtifact>, z.ZodUndefined]>;
57
- }, "strip", z.ZodTypeAny, {
58
- isContractClassPubliclyRegistered: boolean;
59
- contractClass?: {
60
- version: 1;
61
- id: import("@aztec/aztec.js").Fr;
62
- artifactHash: import("@aztec/aztec.js").Fr;
63
- packedBytecode: Buffer<ArrayBuffer>;
64
- privateFunctions: {
65
- selector: import("@aztec/aztec.js").FunctionSelector;
66
- vkHash: import("@aztec/aztec.js").Fr;
67
- }[];
68
- } | undefined;
69
- artifact?: import("@aztec/aztec.js").ContractArtifact | undefined;
70
- }, {
71
- isContractClassPubliclyRegistered: boolean;
72
- contractClass?: {
73
- version: 1;
74
- id: string;
75
- artifactHash: string;
76
- packedBytecode: string | {
77
- type: "Buffer";
78
- data: number[];
79
- };
80
- privateFunctions: {
81
- vkHash: string;
82
- selector?: any;
83
- }[];
84
- } | undefined;
85
- artifact?: any;
86
- }>;
87
- export declare const ContractMetadataSchema: z.ZodObject<{
88
- contractInstance: z.ZodUnion<[z.ZodIntersection<z.ZodObject<{
89
- version: z.ZodLiteral<1>;
90
- salt: ZodFor<import("@aztec/aztec.js").Fr>;
91
- deployer: ZodFor<import("@aztec/aztec.js").AztecAddress>;
92
- currentContractClassId: ZodFor<import("@aztec/aztec.js").Fr>;
93
- originalContractClassId: ZodFor<import("@aztec/aztec.js").Fr>;
94
- initializationHash: ZodFor<import("@aztec/aztec.js").Fr>;
95
- publicKeys: z.ZodEffects<z.ZodObject<{
96
- masterNullifierPublicKey: z.ZodType<import("@aztec/aztec.js").Point, any, string>;
97
- masterIncomingViewingPublicKey: z.ZodType<import("@aztec/aztec.js").Point, any, string>;
98
- masterOutgoingViewingPublicKey: z.ZodType<import("@aztec/aztec.js").Point, any, string>;
99
- masterTaggingPublicKey: z.ZodType<import("@aztec/aztec.js").Point, any, string>;
100
- }, "strip", z.ZodTypeAny, {
101
- masterNullifierPublicKey: import("@aztec/aztec.js").Point;
102
- masterIncomingViewingPublicKey: import("@aztec/aztec.js").Point;
103
- masterOutgoingViewingPublicKey: import("@aztec/aztec.js").Point;
104
- masterTaggingPublicKey: import("@aztec/aztec.js").Point;
105
- }, {
106
- masterNullifierPublicKey: string;
107
- masterIncomingViewingPublicKey: string;
108
- masterOutgoingViewingPublicKey: string;
109
- masterTaggingPublicKey: string;
110
- }>, import("@aztec/aztec.js").PublicKeys, {
111
- masterNullifierPublicKey: string;
112
- masterIncomingViewingPublicKey: string;
113
- masterOutgoingViewingPublicKey: string;
114
- masterTaggingPublicKey: string;
115
- }>;
116
- }, "strip", z.ZodTypeAny, {
117
- version: 1;
118
- salt: import("@aztec/aztec.js").Fr;
119
- publicKeys: import("@aztec/aztec.js").PublicKeys;
120
- deployer: import("@aztec/aztec.js").AztecAddress;
121
- currentContractClassId: import("@aztec/aztec.js").Fr;
122
- originalContractClassId: import("@aztec/aztec.js").Fr;
123
- initializationHash: import("@aztec/aztec.js").Fr;
124
- }, {
125
- version: 1;
126
- publicKeys: {
127
- masterNullifierPublicKey: string;
128
- masterIncomingViewingPublicKey: string;
129
- masterOutgoingViewingPublicKey: string;
130
- masterTaggingPublicKey: string;
131
- };
132
- salt?: any;
133
- deployer?: any;
134
- currentContractClassId?: any;
135
- originalContractClassId?: any;
136
- initializationHash?: any;
137
- }>, z.ZodObject<{
138
- address: ZodFor<import("@aztec/aztec.js").AztecAddress>;
139
- }, "strip", z.ZodTypeAny, {
140
- address: import("@aztec/aztec.js").AztecAddress;
141
- }, {
142
- address?: any;
143
- }>>, z.ZodUndefined]>;
144
- isContractInitialized: z.ZodBoolean;
145
- isContractPublished: z.ZodBoolean;
146
- }, "strip", z.ZodTypeAny, {
147
- isContractInitialized: boolean;
148
- isContractPublished: boolean;
149
- contractInstance?: ({
150
- version: 1;
151
- salt: import("@aztec/aztec.js").Fr;
152
- publicKeys: import("@aztec/aztec.js").PublicKeys;
153
- deployer: import("@aztec/aztec.js").AztecAddress;
154
- currentContractClassId: import("@aztec/aztec.js").Fr;
155
- originalContractClassId: import("@aztec/aztec.js").Fr;
156
- initializationHash: import("@aztec/aztec.js").Fr;
157
- } & {
158
- address: import("@aztec/aztec.js").AztecAddress;
159
- }) | undefined;
160
- }, {
161
- isContractInitialized: boolean;
162
- isContractPublished: boolean;
163
- contractInstance?: ({
164
- version: 1;
165
- publicKeys: {
166
- masterNullifierPublicKey: string;
167
- masterIncomingViewingPublicKey: string;
168
- masterOutgoingViewingPublicKey: string;
169
- masterTaggingPublicKey: string;
170
- };
171
- salt?: any;
172
- deployer?: any;
173
- currentContractClassId?: any;
174
- originalContractClassId?: any;
175
- initializationHash?: any;
176
- } & {
177
- address?: any;
178
- }) | undefined;
179
- }>;
180
- export declare const PXEInfoSchema: z.ZodObject<{
181
- pxeVersion: z.ZodString;
182
- protocolContractAddresses: z.ZodObject<{
183
- classRegistry: import("@aztec/stdlib/schemas").ZodFor<import("@aztec/aztec.js").AztecAddress>;
184
- feeJuice: import("@aztec/stdlib/schemas").ZodFor<import("@aztec/aztec.js").AztecAddress>;
185
- instanceRegistry: import("@aztec/stdlib/schemas").ZodFor<import("@aztec/aztec.js").AztecAddress>;
186
- multiCallEntrypoint: import("@aztec/stdlib/schemas").ZodFor<import("@aztec/aztec.js").AztecAddress>;
187
- }, "strip", z.ZodTypeAny, {
188
- classRegistry: import("@aztec/aztec.js").AztecAddress;
189
- feeJuice: import("@aztec/aztec.js").AztecAddress;
190
- instanceRegistry: import("@aztec/aztec.js").AztecAddress;
191
- multiCallEntrypoint: import("@aztec/aztec.js").AztecAddress;
192
- }, {
193
- classRegistry?: any;
194
- feeJuice?: any;
195
- instanceRegistry?: any;
196
- multiCallEntrypoint?: any;
197
- }>;
198
- }, "strip", z.ZodTypeAny, {
199
- pxeVersion: string;
200
- protocolContractAddresses: {
201
- classRegistry: import("@aztec/aztec.js").AztecAddress;
202
- feeJuice: import("@aztec/aztec.js").AztecAddress;
203
- instanceRegistry: import("@aztec/aztec.js").AztecAddress;
204
- multiCallEntrypoint: import("@aztec/aztec.js").AztecAddress;
205
- };
206
- }, {
207
- pxeVersion: string;
208
- protocolContractAddresses: {
209
- classRegistry?: any;
210
- feeJuice?: any;
211
- instanceRegistry?: any;
212
- multiCallEntrypoint?: any;
213
- };
214
- }>;
215
- export declare const EventMetadataDefinitionSchema: z.ZodObject<{
216
- eventSelector: z.ZodType<EventSelector, any, string>;
217
- abiType: z.ZodType<import("@aztec/aztec.js").AbiType, z.ZodTypeDef, import("@aztec/aztec.js").AbiType>;
218
- fieldNames: z.ZodArray<z.ZodString, "many">;
219
- }, "strip", z.ZodTypeAny, {
220
- eventSelector: EventSelector;
221
- abiType: import("@aztec/aztec.js").AbiType;
222
- fieldNames: string[];
223
- }, {
224
- eventSelector: string;
225
- abiType: import("@aztec/aztec.js").AbiType;
226
- fieldNames: string[];
227
- }>;
4
+ import { EventMetadataDefinition } from "@aztec/stdlib/abi";
5
+ import { AztecAddress } from "@aztec/stdlib/aztec-address";
6
+ import { ContractClassMetadata, ContractMetadata } from "@aztec/stdlib/contract";
7
+ export declare const ContractClassMetadataSchema: ZodFor<ContractClassMetadata>;
8
+ export declare const ContractMetadataSchema: ZodFor<ContractMetadata>;
9
+ export declare const EventMetadataDefinitionSchema: ZodFor<EventMetadataDefinition>;
10
+ export declare const ChainInfoSchema: ZodFor<ChainInfo>;
11
+ export declare const AddressBookSchema: ZodFor<Aliased<AztecAddress>[]>;
package/dist/schemas.js CHANGED
@@ -1,5 +1,7 @@
1
+ import { Fr } from "@aztec/foundation/fields";
1
2
  import { AbiTypeSchema, ContractArtifactSchema, EventSelector } from "@aztec/stdlib/abi";
2
- import { ContractClassWithIdSchema, ContractInstanceWithAddressSchema, ProtocolContractAddressesSchema, } from "@aztec/stdlib/contract";
3
+ import { AztecAddress } from "@aztec/stdlib/aztec-address";
4
+ import { ContractClassWithIdSchema, ContractInstanceWithAddressSchema, } from "@aztec/stdlib/contract";
3
5
  import z from "zod";
4
6
  // copied from aztec.js, because it's not exported
5
7
  export const ContractClassMetadataSchema = z.object({
@@ -12,12 +14,16 @@ export const ContractMetadataSchema = z.object({
12
14
  isContractInitialized: z.boolean(),
13
15
  isContractPublished: z.boolean(),
14
16
  });
15
- export const PXEInfoSchema = z.object({
16
- pxeVersion: z.string(),
17
- protocolContractAddresses: ProtocolContractAddressesSchema,
18
- });
19
17
  export const EventMetadataDefinitionSchema = z.object({
20
18
  eventSelector: EventSelector.schema,
21
19
  abiType: AbiTypeSchema,
22
20
  fieldNames: z.array(z.string()),
23
21
  });
22
+ export const ChainInfoSchema = z.object({
23
+ chainId: Fr.schema,
24
+ version: Fr.schema,
25
+ });
26
+ export const AddressBookSchema = z.array(z.object({
27
+ alias: z.string(),
28
+ item: AztecAddress.schema,
29
+ }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azguardwallet/aztec-wallet",
3
- "version": "2.0.3",
3
+ "version": "3.0.0-devnet.5",
4
4
  "description": "Azguard Wallet client fully compatible with Aztec.js' Wallet interface",
5
5
  "author": "Azguard Wallet",
6
6
  "homepage": "https://github.com/AzguardWallet/aztec-wallet",
@@ -22,12 +22,12 @@
22
22
  "build": "rm -rf dist && tsc"
23
23
  },
24
24
  "dependencies": {
25
- "@azguardwallet/client": "0.5.0",
26
- "@azguardwallet/types": "0.5.0",
27
- "@aztec/aztec.js": "2.0.3",
28
- "@aztec/entrypoints": "2.0.3",
29
- "@aztec/foundation": "2.0.3",
30
- "@aztec/stdlib": "2.0.3",
31
- "zod": "^3.23.8"
25
+ "@azguardwallet/client": "0.6.0",
26
+ "@azguardwallet/types": "0.6.0",
27
+ "@aztec/aztec.js": "3.0.0-devnet.5",
28
+ "@aztec/entrypoints": "3.0.0-devnet.5",
29
+ "@aztec/foundation": "3.0.0-devnet.5",
30
+ "@aztec/stdlib": "3.0.0-devnet.5",
31
+ "zod": "^3.23.8"
32
32
  }
33
33
  }