@aztec/cli-wallet 0.0.1-fake-ceab37513c → 0.0.2-commit.217f559981

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.
Files changed (106) hide show
  1. package/README.md +30 -0
  2. package/dest/bin/index.d.ts +2 -1
  3. package/dest/bin/index.js +39 -23
  4. package/dest/cmds/authorize_action.d.ts +4 -3
  5. package/dest/cmds/authorize_action.d.ts.map +1 -1
  6. package/dest/cmds/authorize_action.js +8 -7
  7. package/dest/cmds/bridge_fee_juice.d.ts +4 -4
  8. package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
  9. package/dest/cmds/bridge_fee_juice.js +9 -7
  10. package/dest/cmds/check_tx.d.ts +5 -3
  11. package/dest/cmds/check_tx.d.ts.map +1 -1
  12. package/dest/cmds/check_tx.js +148 -6
  13. package/dest/cmds/create_account.d.ts +8 -6
  14. package/dest/cmds/create_account.d.ts.map +1 -1
  15. package/dest/cmds/create_account.js +56 -62
  16. package/dest/cmds/create_authwit.d.ts +4 -3
  17. package/dest/cmds/create_authwit.d.ts.map +1 -1
  18. package/dest/cmds/create_authwit.js +6 -6
  19. package/dest/cmds/deploy.d.ts +7 -4
  20. package/dest/cmds/deploy.d.ts.map +1 -1
  21. package/dest/cmds/deploy.js +84 -50
  22. package/dest/cmds/deploy_account.d.ts +6 -8
  23. package/dest/cmds/deploy_account.d.ts.map +1 -1
  24. package/dest/cmds/deploy_account.js +56 -65
  25. package/dest/cmds/import_test_accounts.d.ts +3 -3
  26. package/dest/cmds/import_test_accounts.d.ts.map +1 -1
  27. package/dest/cmds/import_test_accounts.js +6 -9
  28. package/dest/cmds/index.d.ts +3 -3
  29. package/dest/cmds/index.d.ts.map +1 -1
  30. package/dest/cmds/index.js +73 -112
  31. package/dest/cmds/profile.d.ts +7 -4
  32. package/dest/cmds/profile.d.ts.map +1 -1
  33. package/dest/cmds/profile.js +9 -4
  34. package/dest/cmds/register_contract.d.ts +7 -3
  35. package/dest/cmds/register_contract.d.ts.map +1 -1
  36. package/dest/cmds/register_contract.js +5 -6
  37. package/dest/cmds/register_sender.d.ts +4 -3
  38. package/dest/cmds/register_sender.d.ts.map +1 -1
  39. package/dest/cmds/send.d.ts +8 -9
  40. package/dest/cmds/send.d.ts.map +1 -1
  41. package/dest/cmds/send.js +46 -31
  42. package/dest/cmds/simulate.d.ts +7 -4
  43. package/dest/cmds/simulate.d.ts.map +1 -1
  44. package/dest/cmds/simulate.js +12 -7
  45. package/dest/storage/wallet_db.d.ts +6 -16
  46. package/dest/storage/wallet_db.d.ts.map +1 -1
  47. package/dest/storage/wallet_db.js +48 -54
  48. package/dest/utils/authorizations.d.ts +3 -2
  49. package/dest/utils/authorizations.d.ts.map +1 -1
  50. package/dest/utils/authorizations.js +1 -1
  51. package/dest/utils/cli_wallet_and_node_wrapper.d.ts +12 -0
  52. package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -0
  53. package/dest/utils/cli_wallet_and_node_wrapper.js +25 -0
  54. package/dest/utils/constants.d.ts +4 -0
  55. package/dest/utils/constants.d.ts.map +1 -0
  56. package/dest/utils/constants.js +7 -0
  57. package/dest/utils/ecdsa.d.ts +1 -1
  58. package/dest/utils/options/fees.d.ts +22 -28
  59. package/dest/utils/options/fees.d.ts.map +1 -1
  60. package/dest/utils/options/fees.js +66 -133
  61. package/dest/utils/options/index.d.ts +1 -1
  62. package/dest/utils/options/options.d.ts +3 -2
  63. package/dest/utils/options/options.d.ts.map +1 -1
  64. package/dest/utils/options/options.js +1 -1
  65. package/dest/utils/profiling.d.ts +1 -1
  66. package/dest/utils/profiling.d.ts.map +1 -1
  67. package/dest/utils/profiling.js +9 -1
  68. package/dest/utils/wallet.d.ts +40 -0
  69. package/dest/utils/wallet.d.ts.map +1 -0
  70. package/dest/utils/wallet.js +208 -0
  71. package/package.json +17 -14
  72. package/src/bin/index.ts +39 -31
  73. package/src/cmds/authorize_action.ts +14 -6
  74. package/src/cmds/bridge_fee_juice.ts +15 -11
  75. package/src/cmds/check_tx.ts +180 -5
  76. package/src/cmds/create_account.ts +63 -66
  77. package/src/cmds/create_authwit.ts +9 -5
  78. package/src/cmds/deploy.ts +82 -61
  79. package/src/cmds/deploy_account.ts +62 -64
  80. package/src/cmds/import_test_accounts.ts +7 -11
  81. package/src/cmds/index.ts +120 -206
  82. package/src/cmds/profile.ts +14 -6
  83. package/src/cmds/register_contract.ts +9 -11
  84. package/src/cmds/register_sender.ts +3 -2
  85. package/src/cmds/send.ts +42 -40
  86. package/src/cmds/simulate.ts +17 -12
  87. package/src/storage/wallet_db.ts +52 -67
  88. package/src/utils/authorizations.ts +3 -1
  89. package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
  90. package/src/utils/constants.ts +4 -0
  91. package/src/utils/options/fees.ts +88 -178
  92. package/src/utils/options/options.ts +3 -2
  93. package/src/utils/profiling.ts +15 -1
  94. package/src/utils/wallet.ts +290 -0
  95. package/dest/cmds/cancel_tx.d.ts +0 -11
  96. package/dest/cmds/cancel_tx.d.ts.map +0 -1
  97. package/dest/cmds/cancel_tx.js +0 -43
  98. package/dest/utils/accounts.d.ts +0 -9
  99. package/dest/utils/accounts.d.ts.map +0 -1
  100. package/dest/utils/accounts.js +0 -61
  101. package/dest/utils/pxe_wrapper.d.ts +0 -12
  102. package/dest/utils/pxe_wrapper.d.ts.map +0 -1
  103. package/dest/utils/pxe_wrapper.js +0 -26
  104. package/src/cmds/cancel_tx.ts +0 -66
  105. package/src/utils/accounts.ts +0 -77
  106. package/src/utils/pxe_wrapper.ts +0 -32
@@ -1,33 +1,9 @@
1
- import { FeeJuicePaymentMethod } from '@aztec/aztec.js';
2
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
2
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
3
  import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
5
4
  import { Option } from 'commander';
6
- import { createOrRetrieveAccount } from '../accounts.js';
5
+ import { MIN_FEE_PADDING } from '../constants.js';
7
6
  import { aliasedAddressParser } from './options.js';
8
- export function printGasEstimates(feeOpts, gasEstimates, log) {
9
- log(`Estimated gas usage: ${formatGasEstimate(gasEstimates)}`);
10
- log(`Maximum total tx fee: ${getEstimatedCost(gasEstimates, feeOpts.gasSettings.maxFeesPerGas)}`);
11
- }
12
- function formatGasEstimate(estimate) {
13
- return `da=${estimate.gasLimits.daGas},l2=${estimate.gasLimits.l2Gas},teardownDA=${estimate.teardownGasLimits.daGas},teardownL2=${estimate.teardownGasLimits.l2Gas}`;
14
- }
15
- function getEstimatedCost(estimate, maxFeesPerGas) {
16
- return GasSettings.default({
17
- ...estimate,
18
- maxFeesPerGas
19
- }).getFeeLimit().toBigInt();
20
- }
21
- async function parseGasSettings(args, pxe) {
22
- const gasLimits = args.gasLimits ? parseGasLimits(args.gasLimits) : {};
23
- const maxFeesPerGas = args.maxFeesPerGas ? parseGasFees(args.maxFeesPerGas) : await pxe.getCurrentBaseFees();
24
- const maxPriorityFeesPerGas = args.maxPriorityFeesPerGas ? parseGasFees(args.maxPriorityFeesPerGas) : undefined;
25
- return GasSettings.default({
26
- ...gasLimits,
27
- maxFeesPerGas,
28
- maxPriorityFeesPerGas
29
- });
30
- }
31
7
  function printOptionParams(params) {
32
8
  const paramsWithDescription = Object.keys(params).filter((name)=>params[name].description);
33
9
  const maxParamWidth = paramsWithDescription.reduce((v, name)=>Math.max(v, name.length), 0);
@@ -38,20 +14,13 @@ function printOptionParams(params) {
38
14
  ].join(' '));
39
15
  return descriptionList.length ? `\n Parameters:\n${descriptionList.join('\n')}\nFormat: --payment ${Object.keys(params).slice(0, 3).map((name)=>`${name}=${params[name].type}`)} ${Object.keys(params).length > 3 ? '...' : ''}` : '';
40
16
  }
41
- function getFeePaymentMethodParams(allowCustomFeePayer) {
42
- const feePayer = allowCustomFeePayer ? {
43
- type: 'address',
44
- description: 'The account paying the fee.'
45
- } : undefined;
17
+ function getFeePaymentMethodParams() {
46
18
  return {
47
19
  method: {
48
20
  type: 'name',
49
21
  description: 'Valid values: "fee_juice", "fpc-public", "fpc-private", "fpc-sponsored"',
50
22
  default: 'fee_juice'
51
23
  },
52
- ...feePayer ? {
53
- feePayer
54
- } : {},
55
24
  asset: {
56
25
  type: 'address',
57
26
  description: 'The asset used for fee payment. Required for "fpc-public" and "fpc-private".'
@@ -75,109 +44,33 @@ function getFeePaymentMethodParams(allowCustomFeePayer) {
75
44
  messageLeafIndex: {
76
45
  type: 'bigint',
77
46
  description: 'The index of the claim in the l1toL2Message tree.'
78
- },
79
- feeRecipient: {
80
- type: 'string',
81
- description: 'Recipient of the fee.'
82
47
  }
83
48
  };
84
49
  }
85
- function getPaymentMethodOption(allowCustomFeePayer) {
86
- const params = getFeePaymentMethodParams(allowCustomFeePayer);
50
+ export function getPaymentMethodOption() {
51
+ const params = getFeePaymentMethodParams();
87
52
  return new Option(`--payment <options>`, `Fee payment method and arguments.${printOptionParams(params)}`);
88
53
  }
89
- function getFeeOptions(allowCustomFeePayer) {
54
+ function getFeeOptions() {
90
55
  return [
91
- getPaymentMethodOption(allowCustomFeePayer),
56
+ getPaymentMethodOption(),
92
57
  new Option('--gas-limits <da=100,l2=100,teardownDA=10,teardownL2=10>', 'Gas limits for the tx.'),
93
58
  new Option('--max-fees-per-gas <da=100,l2=100>', 'Maximum fees per gas unit for DA and L2 computation.'),
94
59
  new Option('--max-priority-fees-per-gas <da=0,l2=0>', 'Maximum priority fees per gas unit for DA and L2 computation.'),
95
- new Option('--estimate-gas', 'Whether to automatically estimate gas limits for the tx.'),
96
60
  new Option('--estimate-gas-only', 'Only report gas estimation for the tx, do not send it.')
97
61
  ];
98
62
  }
99
- export class FeeOpts {
100
- estimateOnly;
101
- gasSettings;
102
- paymentMethodFactory;
103
- getDeployWallet;
104
- estimateGas;
105
- constructor(estimateOnly, gasSettings, paymentMethodFactory, getDeployWallet, estimateGas){
106
- this.estimateOnly = estimateOnly;
107
- this.gasSettings = gasSettings;
108
- this.paymentMethodFactory = paymentMethodFactory;
109
- this.getDeployWallet = getDeployWallet;
110
- this.estimateGas = estimateGas;
111
- }
112
- async toSendOpts(sender) {
113
- return {
114
- from: sender.getAddress(),
115
- fee: {
116
- estimateGas: this.estimateGas,
117
- gasSettings: this.gasSettings,
118
- paymentMethod: await this.paymentMethodFactory(sender)
119
- }
120
- };
121
- }
122
- async toDeployAccountOpts(sender) {
123
- const paymentMethod = await this.paymentMethodFactory(sender);
124
- const deployWallet = await this.getDeployWallet(sender, paymentMethod);
125
- return {
126
- deployWallet,
127
- fee: {
128
- estimateGas: this.estimateGas,
129
- gasSettings: this.gasSettings,
130
- paymentMethod
131
- }
132
- };
133
- }
134
- static paymentMethodOption() {
135
- return getPaymentMethodOption(false);
136
- }
137
- static getOptions() {
138
- return getFeeOptions(false);
139
- }
140
- static async fromCli(args, pxe, log, db) {
141
- const estimateOnly = args.estimateGasOnly;
142
- const gasSettings = await parseGasSettings(args, pxe);
143
- const defaultPaymentMethod = async (sender)=>{
144
- const { FeeJuicePaymentMethod } = await import('@aztec/aztec.js/fee');
145
- return new FeeJuicePaymentMethod(sender.getAddress());
146
- };
147
- const getDeployWallet = ()=>{
148
- // Returns undefined. The sender's wallet will be used by default.
149
- return Promise.resolve(undefined);
150
- };
151
- return new FeeOpts(estimateOnly, gasSettings, args.payment ? parsePaymentMethod(args.payment, false, log, db) : defaultPaymentMethod, getDeployWallet, !!args.estimateGas);
152
- }
153
- }
154
- export class FeeOptsWithFeePayer extends FeeOpts {
155
- static paymentMethodOption() {
156
- return getPaymentMethodOption(true);
157
- }
158
- static getOptions() {
159
- return getFeeOptions(true);
160
- }
161
- static async fromCli(args, pxe, log, db) {
162
- const estimateOnly = args.estimateGasOnly;
163
- const gasSettings = await parseGasSettings(args, pxe);
164
- const defaultPaymentMethod = async (sender)=>{
165
- const { FeeJuicePaymentMethod } = await import('@aztec/aztec.js/fee');
166
- return new FeeJuicePaymentMethod(sender.getAddress());
167
- };
168
- const getDeployWallet = async (sender, paymentMethod)=>{
169
- if (paymentMethod instanceof FeeJuicePaymentMethod) {
170
- const feePayer = await paymentMethod.getFeePayer();
171
- if (!sender.getAddress().equals(feePayer)) {
172
- return (await createOrRetrieveAccount(pxe, feePayer, db)).getWallet();
173
- }
174
- }
175
- return undefined;
176
- };
177
- return new FeeOptsWithFeePayer(estimateOnly, gasSettings, args.payment ? parsePaymentMethod(args.payment, true, log, db) : defaultPaymentMethod, getDeployWallet, !!args.estimateGas);
178
- }
63
+ function parseGasSettings(args) {
64
+ const gasLimits = args.gasLimits ? parseGasLimits(args.gasLimits) : {};
65
+ const maxFeesPerGas = args.maxFeesPerGas ? parseGasFees(args.maxFeesPerGas) : undefined;
66
+ const maxPriorityFeesPerGas = args.maxPriorityFeesPerGas ? parseGasFees(args.maxPriorityFeesPerGas) : undefined;
67
+ return {
68
+ ...gasLimits,
69
+ maxFeesPerGas,
70
+ maxPriorityFeesPerGas
71
+ };
179
72
  }
180
- export function parsePaymentMethod(payment, allowCustomFeePayer, log, db) {
73
+ export function parsePaymentMethod(payment, log, db) {
181
74
  const parsed = payment.split(',').reduce((acc, item)=>{
182
75
  const [dimension, value] = item.split('=');
183
76
  acc[dimension] = value ?? 1;
@@ -195,29 +88,27 @@ export function parsePaymentMethod(payment, allowCustomFeePayer, log, db) {
195
88
  }
196
89
  return AztecAddress.fromString(parsed.asset);
197
90
  };
198
- return async (sender)=>{
91
+ return async (wallet, from, gasSettings)=>{
199
92
  switch(parsed.method){
200
93
  case 'fee_juice':
201
94
  {
202
95
  if (parsed.claim || parsed.claimSecret && parsed.claimAmount && parsed.messageLeafIndex) {
203
96
  let claimAmount, claimSecret, messageLeafIndex;
204
97
  if (parsed.claim && db) {
205
- ({ amount: claimAmount, secret: claimSecret, leafIndex: messageLeafIndex } = await db.popBridgedFeeJuice(sender.getAddress(), log));
98
+ ({ amount: claimAmount, secret: claimSecret, leafIndex: messageLeafIndex } = await db.popBridgedFeeJuice(from, log));
206
99
  } else {
207
100
  ({ claimAmount, claimSecret, messageLeafIndex } = parsed);
208
101
  }
209
102
  log(`Using Fee Juice for fee payments with claim for ${claimAmount} tokens`);
210
103
  const { FeeJuicePaymentMethodWithClaim } = await import('@aztec/aztec.js/fee');
211
- return new FeeJuicePaymentMethodWithClaim(sender, {
104
+ return new FeeJuicePaymentMethodWithClaim(from, {
212
105
  claimAmount: (typeof claimAmount === 'string' ? Fr.fromHexString(claimAmount) : new Fr(claimAmount)).toBigInt(),
213
106
  claimSecret: Fr.fromHexString(claimSecret),
214
107
  messageLeafIndex: BigInt(messageLeafIndex)
215
108
  });
216
109
  } else {
217
- log(`Using Fee Juice for fee payment`);
218
- const { FeeJuicePaymentMethod } = await import('@aztec/aztec.js/fee');
219
- const feePayer = parsed.feePayer && allowCustomFeePayer ? aliasedAddressParser('accounts', parsed.feePayer, db) : sender.getAddress();
220
- return new FeeJuicePaymentMethod(feePayer);
110
+ log(`Using Fee Juice for fee payment with the balance of account ${from}`);
111
+ return;
221
112
  }
222
113
  }
223
114
  case 'fpc-public':
@@ -226,7 +117,7 @@ export function parsePaymentMethod(payment, allowCustomFeePayer, log, db) {
226
117
  const asset = getAsset();
227
118
  log(`Using public fee payment with asset ${asset} via paymaster ${fpc}`);
228
119
  const { PublicFeePaymentMethod } = await import('@aztec/aztec.js/fee');
229
- return new PublicFeePaymentMethod(fpc, sender);
120
+ return new PublicFeePaymentMethod(fpc, from, wallet, gasSettings);
230
121
  }
231
122
  case 'fpc-private':
232
123
  {
@@ -234,7 +125,7 @@ export function parsePaymentMethod(payment, allowCustomFeePayer, log, db) {
234
125
  const asset = getAsset();
235
126
  log(`Using private fee payment with asset ${asset} via paymaster ${fpc}`);
236
127
  const { PrivateFeePaymentMethod } = await import('@aztec/aztec.js/fee');
237
- return new PrivateFeePaymentMethod(fpc, sender);
128
+ return new PrivateFeePaymentMethod(fpc, from, wallet, gasSettings);
238
129
  }
239
130
  case 'fpc-sponsored':
240
131
  {
@@ -289,3 +180,45 @@ export function parseGasFees(gasFees) {
289
180
  }
290
181
  return new GasFees(parsed.da, parsed.l2);
291
182
  }
183
+ export class CLIFeeArgs {
184
+ estimateOnly;
185
+ paymentMethod;
186
+ gasSettings;
187
+ constructor(estimateOnly, paymentMethod, gasSettings){
188
+ this.estimateOnly = estimateOnly;
189
+ this.paymentMethod = paymentMethod;
190
+ this.gasSettings = gasSettings;
191
+ }
192
+ async toUserFeeOptions(node, wallet, from) {
193
+ const maxFeesPerGas = (await node.getCurrentMinFees()).mul(1 + MIN_FEE_PADDING);
194
+ const gasSettings = GasSettings.default({
195
+ ...this.gasSettings,
196
+ maxFeesPerGas
197
+ });
198
+ const paymentMethod = await this.paymentMethod(wallet, from, gasSettings);
199
+ return {
200
+ paymentMethod,
201
+ gasSettings
202
+ };
203
+ }
204
+ static parse(args, log, db) {
205
+ return new CLIFeeArgs(!!args.estimateGasOnly, parsePaymentMethod(args.payment ?? 'method=fee_juice', log, db), parseGasSettings(args));
206
+ }
207
+ static getOptions() {
208
+ return getFeeOptions();
209
+ }
210
+ }
211
+ // Printing
212
+ export function printGasEstimates(feeOpts, gasEstimates, log) {
213
+ log(`Estimated gas usage: ${formatGasEstimate(gasEstimates)}`);
214
+ log(`Maximum total tx fee: ${getEstimatedCost(gasEstimates, feeOpts.gasSettings.maxFeesPerGas)}`);
215
+ }
216
+ function formatGasEstimate(estimate) {
217
+ return `da=${estimate.gasLimits.daGas},l2=${estimate.gasLimits.l2Gas},teardownDA=${estimate.teardownGasLimits.daGas},teardownL2=${estimate.teardownGasLimits.l2Gas}`;
218
+ }
219
+ function getEstimatedCost(estimate, maxFeesPerGas) {
220
+ return GasSettings.default({
221
+ ...estimate,
222
+ maxFeesPerGas
223
+ }).getFeeLimit().toBigInt();
224
+ }
@@ -1,3 +1,3 @@
1
1
  export * from './fees.js';
2
2
  export * from './options.js';
3
- //# sourceMappingURL=index.d.ts.map
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy91dGlscy9vcHRpb25zL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMsY0FBYyxDQUFDIn0=
@@ -1,10 +1,11 @@
1
+ import { TxHash } from '@aztec/aztec.js/tx';
1
2
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
2
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
4
  import { Option } from 'commander';
4
5
  import type { AliasType, WalletDB } from '../../storage/wallet_db.js';
5
6
  export declare const ARTIFACT_DESCRIPTION = "Path to a compiled Aztec contract's artifact in JSON format. If executed inside a nargo workspace, a package and contract name can be specified as package@contract";
6
7
  export declare function integerArgParser(value: string, argName: string, min?: number, max?: number): number;
7
- export declare function aliasedTxHashParser(txHash: string, db?: WalletDB): import("@aztec/aztec.js/tx_hash").TxHash;
8
+ export declare function aliasedTxHashParser(txHash: string, db?: WalletDB): TxHash;
8
9
  export declare function aliasedAuthWitParser(witnesses: string, db?: WalletDB): AuthWitness[];
9
10
  export declare function aliasedAddressParser(defaultPrefix: AliasType, address: string, db?: WalletDB): AztecAddress;
10
11
  export declare function aliasedSecretKeyParser(sk: string, db?: WalletDB): import("@aztec/foundation/schemas").Fr;
@@ -20,4 +21,4 @@ export declare function artifactPathParser(filePath: string, db?: WalletDB): Pro
20
21
  export declare function artifactPathFromPromiseOrAlias(artifactPathPromise: Promise<string>, contractAddress: AztecAddress, db?: WalletDB): Promise<string>;
21
22
  export declare function createArtifactOption(db?: WalletDB): Option;
22
23
  export declare function cleanupAuthWitnesses(authWitnesses: AuthWitness[] | undefined): AuthWitness[];
23
- //# sourceMappingURL=options.d.ts.map
24
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9ucy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZ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AC,EAAE,QAAQ,gBAQ5F;AAED,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,0CAQ/D;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,UAEnE;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,QAAQ,UAIpF;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,QAAQ,UAIxF;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,OAAO,UAMlD;AAED,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,QAAQ,UAQrE;AAED,wBAAgB,2BAA2B,CAAC,EAAE,CAAC,EAAE,QAAQ,UAIxD;AAED,wBAAgB,kCAAkC,WAKjD;AAED,wBAAgB,mBAAmB,WAKlC;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,mBAajE;AAED,wBAAsB,8BAA8B,CAClD,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,EACpC,eAAe,EAAE,YAAY,EAC7B,EAAE,CAAC,EAAE,QAAQ,mBAWd;AAED,wBAAgB,oBAAoB,CAAC,EAAE,CAAC,EAAE,QAAQ,UAIjD;AA6BD,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,WAAW,EAAE,GAAG,SAAS,GAAG,WAAW,EAAE,CAE5F"}
@@ -2,7 +2,7 @@ import { parseAztecAddress, parseSecretKey, parseTxHash } from '@aztec/cli/utils
2
2
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
3
3
  import { Option } from 'commander';
4
4
  import { readdir, stat } from 'fs/promises';
5
- import { AccountTypes } from '../accounts.js';
5
+ import { AccountTypes } from '../constants.js';
6
6
  const TARGET_DIR = 'target';
7
7
  export const ARTIFACT_DESCRIPTION = "Path to a compiled Aztec contract's artifact in JSON format. If executed inside a nargo workspace, a package and contract name can be specified as package@contract";
8
8
  export function integerArgParser(value, argName, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
@@ -2,4 +2,4 @@ import type { LogFn } from '@aztec/foundation/log';
2
2
  import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
3
3
  import type { ProvingStats, SimulationStats } from '@aztec/stdlib/tx';
4
4
  export declare function printProfileResult(stats: ProvingStats | SimulationStats, log: LogFn, printOracles?: boolean, executionSteps?: PrivateExecutionStep[]): void;
5
- //# sourceMappingURL=profiling.d.ts.map
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsaW5nLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvcHJvZmlsaW5nLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ25ELE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFrQixlQUFlLEVBQXFCLE1BQU0sa0JBQWtCLENBQUM7QUFVekcsd0JBQWdCLGtCQUFrQixDQUNoQyxLQUFLLEVBQUUsWUFBWSxHQUFHLGVBQWUsRUFDckMsR0FBRyxFQUFFLEtBQUssRUFDVixZQUFZLEdBQUUsT0FBZSxFQUM3QixjQUFjLENBQUMsRUFBRSxvQkFBb0IsRUFBRSxRQTJKeEMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"profiling.d.ts","sourceRoot":"","sources":["../../src/utils/profiling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAkB,eAAe,EAAqB,MAAM,kBAAkB,CAAC;AAUzG,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,GAAG,eAAe,EACrC,GAAG,EAAE,KAAK,EACV,YAAY,GAAE,OAAe,EAC7B,cAAc,CAAC,EAAE,oBAAoB,EAAE,QA6IxC"}
1
+ {"version":3,"file":"profiling.d.ts","sourceRoot":"","sources":["../../src/utils/profiling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAkB,eAAe,EAAqB,MAAM,kBAAkB,CAAC;AAUzG,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,GAAG,eAAe,EACrC,GAAG,EAAE,KAAK,EACV,YAAY,GAAE,OAAe,EAC7B,cAAc,CAAC,EAAE,oBAAoB,EAAE,QA2JxC"}
@@ -35,7 +35,7 @@ export function printProfileResult(stats, log, printOracles = false, executionSt
35
35
  }
36
36
  if (stats.nodeRPCCalls) {
37
37
  log(format('\nRPC calls:\n'));
38
- for (const [method, { times }] of Object.entries(stats.nodeRPCCalls)){
38
+ for (const [method, { times }] of Object.entries(stats.nodeRPCCalls.perMethod)){
39
39
  const calls = times.length;
40
40
  const total = times.reduce((acc, time)=>acc + time, 0);
41
41
  const avg = total / calls;
@@ -43,6 +43,14 @@ export function printProfileResult(stats, log, printOracles = false, executionSt
43
43
  const max = Math.max(...times);
44
44
  log(format(method.padEnd(ORACLE_NAME_PADDING), `${calls} calls`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `${total.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `min: ${min.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `avg: ${avg.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), `max: ${max.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH)));
45
45
  }
46
+ const { roundTrips } = stats.nodeRPCCalls;
47
+ log(format('\nRound trips (actual blocking waits):\n'));
48
+ log(format('Round trips:'.padEnd(25), `${roundTrips.roundTrips}`.padStart(COLUMN_MAX_WIDTH)));
49
+ log(format('Total blocking time:'.padEnd(25), `${roundTrips.totalBlockingTime.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
50
+ if (roundTrips.roundTrips > 0) {
51
+ const avgRoundTrip = roundTrips.totalBlockingTime / roundTrips.roundTrips;
52
+ log(format('Avg round trip:'.padEnd(25), `${avgRoundTrip.toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
53
+ }
46
54
  }
47
55
  log(format('\nSync time:'.padEnd(25), `${timings.sync?.toFixed(2)}ms`.padStart(16)));
48
56
  log(format('Private simulation time:'.padEnd(25), `${timings.perFunction.reduce((acc, { time })=>acc + time, 0).toFixed(2)}ms`.padStart(COLUMN_MAX_WIDTH)));
@@ -0,0 +1,40 @@
1
+ import { type Account } from '@aztec/aztec.js/account';
2
+ import { type InteractionFeeOptions } from '@aztec/aztec.js/contracts';
3
+ import type { AztecNode } from '@aztec/aztec.js/node';
4
+ import { AccountManager, type Aliased, type SimulateOptions } from '@aztec/aztec.js/wallet';
5
+ import { Fr } from '@aztec/foundation/curves/bn254';
6
+ import type { LogFn } from '@aztec/foundation/log';
7
+ import type { AccessScopes, NotesFilter } from '@aztec/pxe/client/lazy';
8
+ import type { PXEConfig } from '@aztec/pxe/config';
9
+ import type { PXE } from '@aztec/pxe/server';
10
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
11
+ import { NoteDao } from '@aztec/stdlib/note';
12
+ import type { TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
13
+ import { ExecutionPayload } from '@aztec/stdlib/tx';
14
+ import { BaseWallet, type FeeOptions } from '@aztec/wallet-sdk/base-wallet';
15
+ import type { WalletDB } from '../storage/wallet_db.js';
16
+ import type { AccountType } from './constants.js';
17
+ export declare class CLIWallet extends BaseWallet {
18
+ private userLog;
19
+ private db?;
20
+ private accountCache;
21
+ constructor(pxe: PXE, node: AztecNode, userLog: LogFn, db?: WalletDB | undefined);
22
+ static create(node: AztecNode, log: LogFn, db?: WalletDB, overridePXEConfig?: Partial<PXEConfig>): Promise<CLIWallet>;
23
+ getAccounts(): Promise<Aliased<AztecAddress>[]>;
24
+ private createCancellationTxExecutionRequest;
25
+ proveCancellationTx(from: AztecAddress, txNonce: Fr, increasedFee: InteractionFeeOptions): Promise<TxProvingResult>;
26
+ getAccountFromAddress(address: AztecAddress): Promise<Account>;
27
+ private createAccount;
28
+ createOrRetrieveAccount(address?: AztecAddress, secretKey?: Fr, type?: AccountType, salt?: Fr, publicKey?: string): Promise<AccountManager>;
29
+ private getFakeAccountDataFor;
30
+ simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
31
+ /**
32
+ * Uses a stub account for kernelless simulation, bypassing real account authorization.
33
+ * Falls through to the standard entrypoint path for SignerlessAccount (ZERO address).
34
+ */
35
+ protected simulateViaEntrypoint(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions, scopes: AccessScopes, skipTxValidation?: boolean, skipFeeEnforcement?: boolean): Promise<TxSimulationResult>;
36
+ getContracts(): Promise<AztecAddress[]>;
37
+ getNotes(filter: NotesFilter): Promise<NoteDao[]>;
38
+ getContractArtifact(id: Fr): Promise<import("@aztec/stdlib/abi").ContractArtifact | undefined>;
39
+ }
40
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0LmQudHMiLCJzb3VyY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,EAAE,qBAAqB,GAClC,OAAO,CAAC,eAAe,CAAC,CAG1B;IAEc,qBAAqB,CAAC,OAAO,EAAE,YAAY,oBAezD;YAEa,aAAa;IAWrB,uBAAuB,CAC3B,OAAO,CAAC,EAAE,YAAY,EACtB,SAAS,CAAC,EAAE,EAAE,EACd,IAAI,GAAE,WAAuB,EAC7B,IAAI,CAAC,EAAE,EAAE,EACT,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,CAmDzB;YAQa,qBAAqB;IAwBpB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAShH;IAED;;;OAGG;IACH,UAAyB,qBAAqB,CAC5C,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,YAAY,EAClB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,YAAY,EACpB,gBAAgB,CAAC,EAAE,OAAO,EAC1B,kBAAkB,CAAC,EAAE,OAAO,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CAuC7B;IAID,YAAY,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAEtC;IAID,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAEhD;IAID,mBAAmB,CAAC,EAAE,EAAE,EAAE,qEAEzB;CACF"}
@@ -0,0 +1,208 @@
1
+ import { EcdsaRAccountContract, EcdsaRSSHAccountContract } from '@aztec/accounts/ecdsa';
2
+ import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
3
+ import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/stub';
4
+ import { getIdentities } from '@aztec/accounts/utils';
5
+ import { SignerlessAccount } from '@aztec/aztec.js/account';
6
+ import { getContractInstanceFromInstantiationParams, getGasLimits } from '@aztec/aztec.js/contracts';
7
+ import { AccountManager } from '@aztec/aztec.js/wallet';
8
+ import { Fr } from '@aztec/foundation/curves/bn254';
9
+ import { createPXE, getPXEConfig } from '@aztec/pxe/server';
10
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
11
+ import { deriveSigningKey } from '@aztec/stdlib/keys';
12
+ import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
13
+ import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
14
+ import { extractECDSAPublicKeyFromBase64String } from './ecdsa.js';
15
+ import { printGasEstimates } from './options/fees.js';
16
+ export class CLIWallet extends BaseWallet {
17
+ userLog;
18
+ db;
19
+ accountCache;
20
+ constructor(pxe, node, userLog, db){
21
+ super(pxe, node), this.userLog = userLog, this.db = db, this.accountCache = new Map();
22
+ this.cancellableTransactions = true;
23
+ }
24
+ static async create(node, log, db, overridePXEConfig) {
25
+ const pxeConfig = Object.assign(getPXEConfig(), overridePXEConfig);
26
+ const pxe = await createPXE(node, pxeConfig);
27
+ return new CLIWallet(pxe, node, log, db);
28
+ }
29
+ async getAccounts() {
30
+ const accounts = await this.db?.listAliases('accounts') ?? [];
31
+ return Promise.resolve(accounts.map(({ key, value })=>({
32
+ alias: value,
33
+ item: AztecAddress.fromString(key)
34
+ })));
35
+ }
36
+ async createCancellationTxExecutionRequest(from, txNonce, increasedFee) {
37
+ const executionPayload = ExecutionPayload.empty();
38
+ const feeOptions = await this.completeFeeOptions(from, executionPayload.feePayer, increasedFee.gasSettings);
39
+ const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
40
+ const fromAccount = await this.getAccountFromAddress(from);
41
+ const chainInfo = await this.getChainInfo();
42
+ const executionOptions = {
43
+ txNonce,
44
+ cancellable: this.cancellableTransactions,
45
+ feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
46
+ };
47
+ return await fromAccount.createTxExecutionRequest(feeExecutionPayload ?? executionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
48
+ }
49
+ async proveCancellationTx(from, txNonce, increasedFee) {
50
+ const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
51
+ return await this.pxe.proveTx(cancellationTxRequest, this.scopesFrom(from));
52
+ }
53
+ async getAccountFromAddress(address) {
54
+ let account;
55
+ if (address.equals(AztecAddress.ZERO)) {
56
+ account = new SignerlessAccount();
57
+ } else if (this.accountCache.has(address.toString())) {
58
+ return this.accountCache.get(address.toString());
59
+ } else {
60
+ const accountManager = await this.createOrRetrieveAccount(address);
61
+ account = await accountManager.getAccount();
62
+ }
63
+ if (!account) {
64
+ throw new Error(`Account not found in wallet for address: ${address}`);
65
+ }
66
+ return account;
67
+ }
68
+ async createAccount(secret, salt, contract) {
69
+ const accountManager = await AccountManager.create(this, secret, contract, salt);
70
+ const instance = accountManager.getInstance();
71
+ const artifact = await contract.getContractArtifact();
72
+ await this.registerContract(instance, artifact, secret);
73
+ this.accountCache.set(accountManager.address.toString(), await accountManager.getAccount());
74
+ return accountManager;
75
+ }
76
+ async createOrRetrieveAccount(address, secretKey, type = 'schnorr', salt, publicKey) {
77
+ let account;
78
+ salt ??= Fr.ZERO;
79
+ if (this.db && address) {
80
+ ({ type, secretKey, salt } = await this.db.retrieveAccount(address));
81
+ }
82
+ if (!secretKey) {
83
+ throw new Error('Cannot retrieve/create wallet without secret key');
84
+ }
85
+ switch(type){
86
+ case 'schnorr':
87
+ {
88
+ account = await this.createAccount(secretKey, salt, new SchnorrAccountContract(deriveSigningKey(secretKey)));
89
+ break;
90
+ }
91
+ case 'ecdsasecp256r1':
92
+ {
93
+ account = await this.createAccount(secretKey, salt, new EcdsaRAccountContract(deriveSigningKey(secretKey).toBuffer()));
94
+ break;
95
+ }
96
+ case 'ecdsasecp256r1ssh':
97
+ {
98
+ let publicSigningKey;
99
+ if (this.db && address) {
100
+ publicSigningKey = await this.db.retrieveAccountMetadata(address, 'publicSigningKey');
101
+ } else if (publicKey) {
102
+ const identities = await getIdentities();
103
+ const foundIdentity = identities.find((identity)=>identity.type === 'ecdsa-sha2-nistp256' && identity.publicKey === publicKey);
104
+ if (!foundIdentity) {
105
+ throw new Error(`Identity for public key ${publicKey} not found in the SSH agent`);
106
+ }
107
+ publicSigningKey = extractECDSAPublicKeyFromBase64String(foundIdentity.publicKey);
108
+ } else {
109
+ throw new Error('Public key must be provided for ECDSA SSH account');
110
+ }
111
+ account = await this.createAccount(secretKey, salt, new EcdsaRSSHAccountContract(publicSigningKey));
112
+ break;
113
+ }
114
+ default:
115
+ {
116
+ throw new Error(`Unsupported account type: ${type}`);
117
+ }
118
+ }
119
+ return account;
120
+ }
121
+ /**
122
+ * Creates a stub account that impersonates the given address, allowing kernelless simulations
123
+ * to bypass the account's authorization mechanisms via contract overrides.
124
+ * @param address - The address of the account to impersonate
125
+ * @returns The stub account, contract instance, and artifact for simulation
126
+ */ async getFakeAccountDataFor(address) {
127
+ const originalAccount = await this.getAccountFromAddress(address);
128
+ // Account contracts can only be overridden if they have an associated address
129
+ // Overwriting SignerlessAccount is not supported, and does not really make sense
130
+ // since it has no authorization mechanism.
131
+ if (originalAccount instanceof SignerlessAccount) {
132
+ throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
133
+ }
134
+ const originalAddress = originalAccount.getCompleteAddress();
135
+ const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
136
+ if (!contractInstance) {
137
+ throw new Error(`No contract instance found for address: ${originalAddress.address}`);
138
+ }
139
+ const stubAccount = createStubAccount(originalAddress);
140
+ const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
141
+ salt: Fr.random()
142
+ });
143
+ return {
144
+ account: stubAccount,
145
+ instance,
146
+ artifact: StubAccountContractArtifact
147
+ };
148
+ }
149
+ async simulateTx(executionPayload, opts) {
150
+ const simulationResults = await super.simulateTx(executionPayload, opts);
151
+ if (opts.fee?.estimateGas) {
152
+ const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
153
+ const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
154
+ printGasEstimates(feeOptions, limits, this.userLog);
155
+ }
156
+ return simulationResults;
157
+ }
158
+ /**
159
+ * Uses a stub account for kernelless simulation, bypassing real account authorization.
160
+ * Falls through to the standard entrypoint path for SignerlessAccount (ZERO address).
161
+ */ async simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement) {
162
+ if (from.equals(AztecAddress.ZERO)) {
163
+ return super.simulateViaEntrypoint(executionPayload, from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement);
164
+ }
165
+ const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
166
+ const executionOptions = {
167
+ txNonce: Fr.random(),
168
+ cancellable: this.cancellableTransactions,
169
+ feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions
170
+ };
171
+ const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
172
+ feeExecutionPayload,
173
+ executionPayload
174
+ ]) : executionPayload;
175
+ const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(from);
176
+ const chainInfo = await this.getChainInfo();
177
+ const txRequest = await fromAccount.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo, executionOptions);
178
+ return this.pxe.simulateTx(txRequest, {
179
+ simulatePublic: true,
180
+ skipFeeEnforcement: true,
181
+ skipTxValidation: true,
182
+ overrides: {
183
+ contracts: {
184
+ [from.toString()]: {
185
+ instance,
186
+ artifact
187
+ }
188
+ }
189
+ },
190
+ scopes
191
+ });
192
+ }
193
+ // Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
194
+ // this is just a CLI wallet.
195
+ getContracts() {
196
+ return this.pxe.getContracts();
197
+ }
198
+ // Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
199
+ // this is just a CLI wallet.
200
+ getNotes(filter) {
201
+ return this.pxe.debug.getNotes(filter);
202
+ }
203
+ // Exposed because of the `aztec-wallet get-tx` command. It has been decided that it's fine to keep around because
204
+ // this is just a CLI wallet.
205
+ getContractArtifact(id) {
206
+ return this.pxe.getContractArtifact(id);
207
+ }
208
+ }