@aztec/cli-wallet 0.0.1-commit.b9865e97 → 0.0.1-commit.be03c316

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 (45) hide show
  1. package/dest/cmds/check_tx.js +8 -6
  2. package/dest/cmds/create_account.d.ts +4 -2
  3. package/dest/cmds/create_account.d.ts.map +1 -1
  4. package/dest/cmds/create_account.js +26 -10
  5. package/dest/cmds/deploy.js +3 -6
  6. package/dest/cmds/deploy_account.js +4 -7
  7. package/dest/cmds/import_test_accounts.d.ts +1 -1
  8. package/dest/cmds/import_test_accounts.d.ts.map +1 -1
  9. package/dest/cmds/import_test_accounts.js +2 -1
  10. package/dest/cmds/index.d.ts +1 -1
  11. package/dest/cmds/index.d.ts.map +1 -1
  12. package/dest/cmds/index.js +8 -7
  13. package/dest/cmds/send.js +3 -6
  14. package/dest/cmds/simulate.d.ts +1 -1
  15. package/dest/cmds/simulate.d.ts.map +1 -1
  16. package/dest/cmds/simulate.js +2 -1
  17. package/dest/storage/wallet_db.d.ts +7 -4
  18. package/dest/storage/wallet_db.d.ts.map +1 -1
  19. package/dest/storage/wallet_db.js +15 -1
  20. package/dest/utils/constants.d.ts +2 -2
  21. package/dest/utils/constants.d.ts.map +1 -1
  22. package/dest/utils/constants.js +1 -0
  23. package/dest/utils/options/fees.d.ts +1 -1
  24. package/dest/utils/options/fees.d.ts.map +1 -1
  25. package/dest/utils/options/fees.js +4 -1
  26. package/dest/utils/options/options.d.ts +2 -2
  27. package/dest/utils/options/options.d.ts.map +1 -1
  28. package/dest/utils/options/options.js +5 -5
  29. package/dest/utils/wallet.d.ts +25 -5
  30. package/dest/utils/wallet.d.ts.map +1 -1
  31. package/dest/utils/wallet.js +89 -67
  32. package/package.json +15 -15
  33. package/src/cmds/check_tx.ts +11 -10
  34. package/src/cmds/create_account.ts +27 -15
  35. package/src/cmds/deploy.ts +3 -3
  36. package/src/cmds/deploy_account.ts +4 -4
  37. package/src/cmds/import_test_accounts.ts +12 -1
  38. package/src/cmds/index.ts +11 -9
  39. package/src/cmds/send.ts +3 -3
  40. package/src/cmds/simulate.ts +2 -1
  41. package/src/storage/wallet_db.ts +24 -2
  42. package/src/utils/constants.ts +7 -1
  43. package/src/utils/options/fees.ts +4 -2
  44. package/src/utils/options/options.ts +5 -5
  45. package/src/utils/wallet.ts +132 -85
@@ -1,14 +1,16 @@
1
1
  import { type Account } from '@aztec/aztec.js/account';
2
2
  import { type InteractionFeeOptions } from '@aztec/aztec.js/contracts';
3
3
  import type { AztecNode } from '@aztec/aztec.js/node';
4
- import { AccountManager, type Aliased, type SimulateOptions } from '@aztec/aztec.js/wallet';
4
+ import { AccountManager, type Aliased } from '@aztec/aztec.js/wallet';
5
5
  import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
6
6
  import { Fr } from '@aztec/foundation/curves/bn254';
7
+ import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
7
8
  import type { LogFn } from '@aztec/foundation/log';
8
9
  import type { NotesFilter } from '@aztec/pxe/client/lazy';
9
10
  import type { PXEConfig } from '@aztec/pxe/config';
10
11
  import type { PXE } from '@aztec/pxe/server';
11
12
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
13
+ import type { Gas, GasUsed } from '@aztec/stdlib/gas';
12
14
  import { NoteDao } from '@aztec/stdlib/note';
13
15
  import type { TxProvingResult } from '@aztec/stdlib/tx';
14
16
  import { ExecutionPayload } from '@aztec/stdlib/tx';
@@ -25,13 +27,31 @@ export declare class CLIWallet extends BaseWallet {
25
27
  private registerAuthRegistry;
26
28
  private initStubClasses;
27
29
  getAccounts(): Promise<Aliased<AztecAddress>[]>;
30
+ /**
31
+ * Derives suggested total and teardown gas limits from simulated gas usage, padded and clamped to the
32
+ * network's per-tx admission limits.
33
+ * @param gasUsed - The gas consumed during simulation (from a `simulate({ includeMetadata: true })` result).
34
+ */
35
+ estimateGasLimits(gasUsed: GasUsed): Promise<{
36
+ gasLimits: Gas;
37
+ teardownGasLimits: Gas;
38
+ }>;
28
39
  private createCancellationTxExecutionRequest;
29
40
  proveCancellationTx(from: AztecAddress, txNonce: Fr, increasedFee: InteractionFeeOptions): Promise<TxProvingResult>;
30
41
  getAccountFromAddress(address: AztecAddress): Promise<Account>;
31
- private createAccount;
32
- createOrRetrieveAccount(address?: AztecAddress, secretKey?: Fr, type?: AccountType, salt?: Fr, publicKey?: string): Promise<AccountManager>;
42
+ /**
43
+ * Creates an account from freshly supplied keys. SSH accounts sign with a key held in the agent (resolved from
44
+ * `publicKey`), every other type is rooted on `signingKey`, with `secretKey` as its privacy secret.
45
+ */
46
+ createAccount(type: AccountType, signingKey: GrumpkinScalar | undefined, secretKey: Fr | undefined, salt?: Fr, publicKey?: string): Promise<AccountManager>;
47
+ /**
48
+ * Retrieves a previously stored account by address, loading its keys, type and salt from the wallet database.
49
+ */
50
+ retrieveAccount(address: AztecAddress): Promise<AccountManager>;
51
+ private buildAccount;
52
+ private resolveSshPublicSigningKey;
53
+ private materializeAccount;
33
54
  private getFakeAccountDataFor;
34
- simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset>;
35
55
  /**
36
56
  * Uses a stub account for kernelless simulation, bypassing real account authorization.
37
57
  * Uses DefaultEntrypoint directly for NO_FROM transactions.
@@ -41,4 +61,4 @@ export declare class CLIWallet extends BaseWallet {
41
61
  getNotes(filter: NotesFilter): Promise<NoteDao[]>;
42
62
  getContractArtifact(id: Fr): Promise<import("@aztec/stdlib/abi").ContractArtifact | undefined>;
43
63
  }
44
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FsbGV0LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sRUFBRSxLQUFLLE9BQU8sRUFBaUMsTUFBTSx5Q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AiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,GAAG,CAAC;QAAC,iBAAiB,EAAE,GAAG,CAAA;KAAE,CAAC,CAG7F;YAEa,oCAAoC;IA4B5C,mBAAmB,CACvB,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,EAAE,EACX,YAAY,EAAE,qBAAqB,GAClC,OAAO,CAAC,eAAe,CAAC,CAM1B;IAEc,qBAAqB,CAAC,OAAO,EAAE,YAAY,oBAazD;IAED;;;OAGG;IACG,aAAa,CACjB,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,cAAc,GAAG,SAAS,EACtC,SAAS,EAAE,EAAE,GAAG,SAAS,EACzB,IAAI,GAAE,EAAY,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,CAIzB;IAED;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAcpE;YAEa,YAAY;YAqCZ,0BAA0B;YAc1B,kBAAkB;YA+BlB,qBAAqB;IAsBnC;;;OAGG;IACH,UAAyB,qBAAqB,CAC5C,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,4BAA4B,GACjC,OAAO,CAAC,+BAA+B,CAAC,CA2C1C;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"}
@@ -1,10 +1,10 @@
1
- import { EcdsaRAccountContract, EcdsaRSSHAccountContract } from '@aztec/accounts/ecdsa';
2
- import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
3
- import { StubEcdsaAccountContractArtifact, createStubEcdsaAccount } from '@aztec/accounts/stub/ecdsa';
4
- import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/stub/schnorr';
1
+ import { EcdsaKAccountContract, EcdsaRAccountContract, EcdsaRSSHAccountContract } from '@aztec/accounts/ecdsa';
2
+ import { StubEcdsaAccountContractArtifact, createStubEcdsaAccount } from '@aztec/accounts/ecdsa/stub';
3
+ import { SchnorrAccountContract, SchnorrInitializerlessAccountContract } from '@aztec/accounts/schnorr';
4
+ import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/schnorr/stub';
5
5
  import { getIdentities } from '@aztec/accounts/utils';
6
6
  import { NO_FROM } from '@aztec/aztec.js/account';
7
- import { getContractClassFromArtifact, getGasLimits } from '@aztec/aztec.js/contracts';
7
+ import { ContractFunctionInteraction, getContractClassFromArtifact } from '@aztec/aztec.js/contracts';
8
8
  import { AccountManager } from '@aztec/aztec.js/wallet';
9
9
  import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
10
10
  import { DefaultEntrypoint } from '@aztec/entrypoints/default';
@@ -12,11 +12,10 @@ import { Fr } from '@aztec/foundation/curves/bn254';
12
12
  import { createPXE, getPXEConfig } from '@aztec/pxe/server';
13
13
  import { getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
14
14
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
15
- import { deriveSigningKey } from '@aztec/stdlib/keys';
16
15
  import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
17
- import { BaseWallet } from '@aztec/wallet-sdk/base-wallet';
16
+ import { BaseWallet, getGasLimits } from '@aztec/wallet-sdk/base-wallet';
18
17
  import { extractECDSAPublicKeyFromBase64String } from './ecdsa.js';
19
- import { printGasEstimates } from './options/fees.js';
18
+ /** Padding the CLI wallet applies to simulated gas usage when deriving declared gas limits. */ const DEFAULT_ESTIMATED_GAS_PADDING = 0.1;
20
19
  export class CLIWallet extends BaseWallet {
21
20
  userLog;
22
21
  db;
@@ -38,10 +37,8 @@ export class CLIWallet extends BaseWallet {
38
37
  }
39
38
  async registerAuthRegistry() {
40
39
  const { instance, artifact } = await getStandardAuthRegistry();
41
- await this.pxe.registerContract({
42
- instance,
43
- artifact
44
- });
40
+ await this.pxe.registerContractClass(artifact);
41
+ await this.pxe.registerContract(instance);
45
42
  }
46
43
  /**
47
44
  * Hashes and registers the stub class for every supported account type with PXE, populating
@@ -53,6 +50,7 @@ export class CLIWallet extends BaseWallet {
53
50
  const { id: ecdsaClassId } = await getContractClassFromArtifact(StubEcdsaAccountContractArtifact);
54
51
  await this.pxe.registerContractClass(StubEcdsaAccountContractArtifact);
55
52
  this.stubClassIds.set('schnorr', schnorrClassId);
53
+ this.stubClassIds.set('schnorr_initializerless', schnorrClassId);
56
54
  this.stubClassIds.set('ecdsasecp256k1', ecdsaClassId);
57
55
  this.stubClassIds.set('ecdsasecp256r1', ecdsaClassId);
58
56
  this.stubClassIds.set('ecdsasecp256r1ssh', ecdsaClassId);
@@ -63,10 +61,18 @@ export class CLIWallet extends BaseWallet {
63
61
  const alias = key.includes(':') ? key.slice(key.indexOf(':') + 1) : key;
64
62
  return {
65
63
  alias,
66
- item: AztecAddress.fromString(value)
64
+ item: AztecAddress.fromStringUnsafe(value)
67
65
  };
68
66
  }));
69
67
  }
68
+ /**
69
+ * Derives suggested total and teardown gas limits from simulated gas usage, padded and clamped to the
70
+ * network's per-tx admission limits.
71
+ * @param gasUsed - The gas consumed during simulation (from a `simulate({ includeMetadata: true })` result).
72
+ */ async estimateGasLimits(gasUsed) {
73
+ const maxTxGasLimits = await this.getMaxTxGasLimits();
74
+ return getGasLimits(gasUsed, maxTxGasLimits, DEFAULT_ESTIMATED_GAS_PADDING);
75
+ }
70
76
  async createCancellationTxExecutionRequest(from, txNonce, increasedFee) {
71
77
  const executionPayload = ExecutionPayload.empty();
72
78
  const feeOptions = await this.completeFeeOptions({
@@ -88,7 +94,7 @@ export class CLIWallet extends BaseWallet {
88
94
  async proveCancellationTx(from, txNonce, increasedFee) {
89
95
  const cancellationTxRequest = await this.createCancellationTxExecutionRequest(from, txNonce, increasedFee);
90
96
  return await this.pxe.proveTx(cancellationTxRequest, {
91
- scopes: this.scopesFrom(from),
97
+ scopes: this.scopesFrom(from, [], undefined),
92
98
  senderForTags: from
93
99
  });
94
100
  }
@@ -97,7 +103,7 @@ export class CLIWallet extends BaseWallet {
97
103
  if (this.accountCache.has(address.toString())) {
98
104
  return this.accountCache.get(address.toString());
99
105
  } else {
100
- const accountManager = await this.createOrRetrieveAccount(address);
106
+ const accountManager = await this.retrieveAccount(address);
101
107
  account = await accountManager.getAccount();
102
108
  }
103
109
  if (!account) {
@@ -105,60 +111,89 @@ export class CLIWallet extends BaseWallet {
105
111
  }
106
112
  return account;
107
113
  }
108
- async createAccount(secret, salt, contract) {
109
- const accountManager = await AccountManager.create(this, secret, contract, {
110
- salt
111
- });
112
- const instance = accountManager.getInstance();
113
- const artifact = await contract.getContractArtifact();
114
- await this.registerContract(instance, artifact, secret);
115
- this.accountCache.set(accountManager.address.toString(), await accountManager.getAccount());
116
- return accountManager;
114
+ /**
115
+ * Creates an account from freshly supplied keys. SSH accounts sign with a key held in the agent (resolved from
116
+ * `publicKey`), every other type is rooted on `signingKey`, with `secretKey` as its privacy secret.
117
+ */ async createAccount(type, signingKey, secretKey, salt = Fr.ZERO, publicKey) {
118
+ const publicSigningKey = type === 'ecdsasecp256r1ssh' ? await this.resolveSshPublicSigningKey(publicKey) : undefined;
119
+ return this.buildAccount(type, salt, signingKey, secretKey, publicSigningKey);
117
120
  }
118
- async createOrRetrieveAccount(address, secretKey, type = 'schnorr', salt, publicKey) {
119
- let account;
120
- salt ??= Fr.ZERO;
121
- if (this.db && address) {
122
- ({ type, secretKey, salt } = await this.db.retrieveAccount(address));
121
+ /**
122
+ * Retrieves a previously stored account by address, loading its keys, type and salt from the wallet database.
123
+ */ async retrieveAccount(address) {
124
+ if (!this.db) {
125
+ throw new Error('Cannot retrieve an account without a wallet database');
123
126
  }
124
- if (!secretKey) {
125
- throw new Error('Cannot retrieve/create wallet without secret key');
127
+ const { type, signingKey, secretKey, salt } = await this.db.retrieveAccount(address);
128
+ if (type !== 'ecdsasecp256r1ssh' && !signingKey) {
129
+ throw new Error(`Account ${address} has no stored signing key: it was created with an older version of aztec-wallet and is ` + `incompatible with this one. Create a new account to continue.`);
126
130
  }
131
+ const publicSigningKey = type === 'ecdsasecp256r1ssh' ? await this.db.retrieveAccountMetadata(address, 'publicSigningKey') : undefined;
132
+ return this.buildAccount(type, salt, signingKey, secretKey, publicSigningKey);
133
+ }
134
+ async buildAccount(type, salt, signingKey, secretKey, publicSigningKey) {
127
135
  switch(type){
128
136
  case 'schnorr':
129
- {
130
- account = await this.createAccount(secretKey, salt, new SchnorrAccountContract(deriveSigningKey(secretKey)));
131
- break;
132
- }
137
+ case 'schnorr_initializerless':
133
138
  case 'ecdsasecp256r1':
139
+ case 'ecdsasecp256k1':
134
140
  {
135
- account = await this.createAccount(secretKey, salt, new EcdsaRAccountContract(deriveSigningKey(secretKey).toBuffer()));
136
- break;
141
+ if (!signingKey || !secretKey) {
142
+ throw new Error('Cannot build account without signing key and secret key');
143
+ }
144
+ const contract = type === 'schnorr' ? new SchnorrAccountContract(signingKey) : type === 'schnorr_initializerless' ? new SchnorrInitializerlessAccountContract(signingKey) : type === 'ecdsasecp256r1' ? new EcdsaRAccountContract(signingKey.toBuffer()) : new EcdsaKAccountContract(signingKey.toBuffer());
145
+ return await this.materializeAccount(secretKey, salt, contract);
137
146
  }
138
147
  case 'ecdsasecp256r1ssh':
139
148
  {
140
- let publicSigningKey;
141
- if (this.db && address) {
142
- publicSigningKey = await this.db.retrieveAccountMetadata(address, 'publicSigningKey');
143
- } else if (publicKey) {
144
- const identities = await getIdentities();
145
- const foundIdentity = identities.find((identity)=>identity.type === 'ecdsa-sha2-nistp256' && identity.publicKey === publicKey);
146
- if (!foundIdentity) {
147
- throw new Error(`Identity for public key ${publicKey} not found in the SSH agent`);
148
- }
149
- publicSigningKey = extractECDSAPublicKeyFromBase64String(foundIdentity.publicKey);
150
- } else {
151
- throw new Error('Public key must be provided for ECDSA SSH account');
149
+ if (!secretKey || !publicSigningKey) {
150
+ throw new Error('Cannot build SSH account without secret key and public signing key');
152
151
  }
153
- account = await this.createAccount(secretKey, salt, new EcdsaRSSHAccountContract(publicSigningKey));
154
- break;
152
+ return await this.materializeAccount(secretKey, salt, new EcdsaRSSHAccountContract(publicSigningKey));
155
153
  }
156
154
  default:
157
155
  {
158
156
  throw new Error(`Unsupported account type: ${type}`);
159
157
  }
160
158
  }
161
- return account;
159
+ }
160
+ async resolveSshPublicSigningKey(publicKey) {
161
+ if (!publicKey) {
162
+ throw new Error('Public key must be provided for ECDSA SSH account');
163
+ }
164
+ const identities = await getIdentities();
165
+ const foundIdentity = identities.find((identity)=>identity.type === 'ecdsa-sha2-nistp256' && identity.publicKey === publicKey);
166
+ if (!foundIdentity) {
167
+ throw new Error(`Identity for public key ${publicKey} not found in the SSH agent`);
168
+ }
169
+ return extractECDSAPublicKeyFromBase64String(foundIdentity.publicKey);
170
+ }
171
+ async materializeAccount(secret, salt, contract) {
172
+ const accountManager = await AccountManager.create(this, secret, contract, {
173
+ salt
174
+ });
175
+ const instance = accountManager.getInstance();
176
+ const artifact = await contract.getContractArtifact();
177
+ await this.registerContract(instance, artifact, secret);
178
+ this.accountCache.set(accountManager.address.toString(), await accountManager.getAccount());
179
+ // Initializerless accounts have no deployment tx; their address commits to the signing public key
180
+ // (via the contract's immutablesHash, resolved by AccountManager.create) and the constructor's
181
+ // storage writes are materialized locally via a simulated "store" call here.
182
+ if (contract instanceof SchnorrInitializerlessAccountContract) {
183
+ const constructorAbi = artifact.functions.find((f)=>f.name === 'constructor');
184
+ if (!constructorAbi) {
185
+ throw new Error('Could not create SchnorrInitializerlessAccount: constructor ABI not found');
186
+ }
187
+ const { x, y } = await contract.getSigningPublicKey();
188
+ const storeCall = new ContractFunctionInteraction(this, instance.address, constructorAbi, [
189
+ x,
190
+ y
191
+ ]);
192
+ await storeCall.simulate({
193
+ from: instance.address
194
+ });
195
+ }
196
+ return accountManager;
162
197
  }
163
198
  /**
164
199
  * Creates a stub account that impersonates the given address, allowing kernelless simulations
@@ -173,7 +208,7 @@ export class CLIWallet extends BaseWallet {
173
208
  throw new Error(`No contract instance found for address: ${originalAddress.address}`);
174
209
  }
175
210
  const { type } = await this.db.retrieveAccount(address);
176
- const stubAccount = type === 'schnorr' ? createStubSchnorrAccount(originalAddress) : createStubEcdsaAccount(originalAddress);
211
+ const stubAccount = type === 'schnorr' || type === 'schnorr_initializerless' ? createStubSchnorrAccount(originalAddress) : createStubEcdsaAccount(originalAddress);
177
212
  const stubClassId = this.stubClassIds.get(type);
178
213
  if (!stubClassId) {
179
214
  throw new Error(`Stub class for account type '${type}' was not registered at wallet init. This is a bug — initStubClasses should cover every supported AccountType.`);
@@ -187,25 +222,12 @@ export class CLIWallet extends BaseWallet {
187
222
  instance
188
223
  };
189
224
  }
190
- async simulateTx(executionPayload, opts) {
191
- const simulationResults = await super.simulateTx(executionPayload, opts);
192
- if (opts.fee?.estimateGas) {
193
- const feeOptions = await this.completeFeeOptions({
194
- from: opts.from,
195
- feePayer: executionPayload.feePayer,
196
- gasSettings: opts.fee?.gasSettings
197
- });
198
- const limits = getGasLimits(simulationResults, opts.fee?.estimatedGasPadding);
199
- printGasEstimates(feeOptions, limits, this.userLog);
200
- }
201
- return simulationResults;
202
- }
203
225
  /**
204
226
  * Uses a stub account for kernelless simulation, bypassing real account authorization.
205
227
  * Uses DefaultEntrypoint directly for NO_FROM transactions.
206
228
  */ async simulateViaEntrypoint(executionPayload, opts) {
207
229
  const { from, feeOptions, additionalScopes, sendMessagesAs } = opts;
208
- const scopes = this.scopesFrom(from, additionalScopes);
230
+ const scopes = this.scopesFrom(from, additionalScopes ?? [], sendMessagesAs);
209
231
  const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
210
232
  const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
211
233
  feeExecutionPayload,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli-wallet",
3
- "version": "0.0.1-commit.b9865e97",
3
+ "version": "0.0.1-commit.be03c316",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/cmds/index.js",
@@ -67,20 +67,20 @@
67
67
  ]
68
68
  },
69
69
  "dependencies": {
70
- "@aztec/accounts": "0.0.1-commit.b9865e97",
71
- "@aztec/aztec.js": "0.0.1-commit.b9865e97",
72
- "@aztec/bb.js": "0.0.1-commit.b9865e97",
73
- "@aztec/cli": "0.0.1-commit.b9865e97",
74
- "@aztec/entrypoints": "0.0.1-commit.b9865e97",
75
- "@aztec/ethereum": "0.0.1-commit.b9865e97",
76
- "@aztec/foundation": "0.0.1-commit.b9865e97",
77
- "@aztec/kv-store": "0.0.1-commit.b9865e97",
78
- "@aztec/noir-contracts.js": "0.0.1-commit.b9865e97",
79
- "@aztec/noir-noirc_abi": "0.0.1-commit.b9865e97",
80
- "@aztec/pxe": "0.0.1-commit.b9865e97",
81
- "@aztec/standard-contracts": "0.0.1-commit.b9865e97",
82
- "@aztec/stdlib": "0.0.1-commit.b9865e97",
83
- "@aztec/wallet-sdk": "0.0.1-commit.b9865e97",
70
+ "@aztec/accounts": "0.0.1-commit.be03c316",
71
+ "@aztec/aztec.js": "0.0.1-commit.be03c316",
72
+ "@aztec/bb.js": "0.0.1-commit.be03c316",
73
+ "@aztec/cli": "0.0.1-commit.be03c316",
74
+ "@aztec/entrypoints": "0.0.1-commit.be03c316",
75
+ "@aztec/ethereum": "0.0.1-commit.be03c316",
76
+ "@aztec/foundation": "0.0.1-commit.be03c316",
77
+ "@aztec/kv-store": "0.0.1-commit.be03c316",
78
+ "@aztec/noir-contracts.js": "0.0.1-commit.be03c316",
79
+ "@aztec/noir-noirc_abi": "0.0.1-commit.be03c316",
80
+ "@aztec/pxe": "0.0.1-commit.be03c316",
81
+ "@aztec/standard-contracts": "0.0.1-commit.be03c316",
82
+ "@aztec/stdlib": "0.0.1-commit.be03c316",
83
+ "@aztec/wallet-sdk": "0.0.1-commit.be03c316",
84
84
  "commander": "^12.1.0",
85
85
  "inquirer": "^10.1.8",
86
86
  "source-map-support": "^0.5.21",
@@ -197,21 +197,22 @@ type ContractArtifactWithClassId = ContractArtifact & { classId: Fr };
197
197
 
198
198
  async function getKnownArtifacts(wallet: CLIWallet): Promise<ArtifactMap> {
199
199
  const knownContractAddresses = await wallet.getContracts();
200
- const knownContracts = (
201
- await Promise.all(knownContractAddresses.map(contractAddress => wallet.getContractMetadata(contractAddress)))
202
- ).map(contractMetadata => contractMetadata.instance);
203
- const classIds = [...new Set(knownContracts.map(contract => contract?.currentContractClassId))];
200
+ const knownContracts = await Promise.all(
201
+ knownContractAddresses.map(contractAddress => wallet.getContractMetadata(contractAddress)),
202
+ );
203
+ const classIdFor = (metadata: (typeof knownContracts)[number]): Fr | undefined =>
204
+ metadata.updatedContractClassId ?? metadata.instance?.originalContractClassId;
205
+ const classIds = [...new Set(knownContracts.map(classIdFor))];
204
206
  const knownArtifacts = (
205
207
  await Promise.all(classIds.map(classId => (classId ? wallet.getContractArtifact(classId) : undefined)))
206
208
  ).map((artifact, index) => (artifact ? { ...artifact, classId: classIds[index] } : undefined));
207
209
  const map: Record<string, ContractArtifactWithClassId> = {};
208
- for (const instance of knownContracts) {
209
- if (instance) {
210
- const artifact = knownArtifacts.find(a =>
211
- a?.classId?.equals(instance.currentContractClassId),
212
- ) as ContractArtifactWithClassId;
210
+ for (const metadata of knownContracts) {
211
+ const classId = classIdFor(metadata);
212
+ if (metadata.instance && classId) {
213
+ const artifact = knownArtifacts.find(a => a?.classId?.equals(classId)) as ContractArtifactWithClassId;
213
214
  if (artifact) {
214
- map[instance.address.toString()] = artifact;
215
+ map[metadata.instance.address.toString()] = artifact;
215
216
  }
216
217
  }
217
218
  }
@@ -1,3 +1,4 @@
1
+ import { deriveSecretKeyFromSigningKey } from '@aztec/accounts/utils';
1
2
  import { NO_FROM } from '@aztec/aztec.js/account';
2
3
  import { AztecAddress } from '@aztec/aztec.js/addresses';
3
4
  import { NO_WAIT } from '@aztec/aztec.js/contracts';
@@ -5,6 +6,7 @@ import { type AztecNode, waitForTx } from '@aztec/aztec.js/node';
5
6
  import type { DeployAccountOptions } from '@aztec/aztec.js/wallet';
6
7
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
7
8
  import { Fr } from '@aztec/foundation/curves/bn254';
9
+ import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
8
10
  import type { LogFn, Logger } from '@aztec/foundation/log';
9
11
  import { type TxHash, type TxReceipt, TxStatus } from '@aztec/stdlib/tx';
10
12
 
@@ -18,7 +20,7 @@ export async function createAccount(
18
20
  wallet: CLIWallet,
19
21
  aztecNode: AztecNode,
20
22
  accountType: AccountType,
21
- secretKey: Fr | undefined,
23
+ signingKey: GrumpkinScalar | undefined,
22
24
  salt: Fr | undefined,
23
25
  publicKey: string | undefined,
24
26
  alias: string | undefined,
@@ -35,15 +37,17 @@ export async function createAccount(
35
37
  debugLogger: Logger,
36
38
  log: LogFn,
37
39
  ) {
38
- secretKey ??= Fr.random();
39
-
40
- const account = await wallet.createOrRetrieveAccount(
41
- undefined /* address, we don't have it yet */,
42
- secretKey,
43
- accountType,
44
- salt,
45
- publicKey,
46
- );
40
+ let secretKey: Fr;
41
+ if (accountType === 'ecdsasecp256r1ssh') {
42
+ // SSH accounts sign with a key held in the agent, and so we cannot derive their privacy secret key from it. Instead
43
+ // we pick a random value.
44
+ secretKey = Fr.random();
45
+ } else {
46
+ signingKey ??= GrumpkinScalar.random();
47
+ secretKey = await deriveSecretKeyFromSigningKey(signingKey);
48
+ }
49
+
50
+ const account = await wallet.createAccount(accountType, signingKey, secretKey, salt, publicKey);
47
51
  const instanceSalt = account.getInstance().salt;
48
52
  const { address, publicKeys, partialAddress } = await account.getCompleteAddress();
49
53
 
@@ -51,6 +55,9 @@ export async function createAccount(
51
55
  if (json) {
52
56
  out.address = address;
53
57
  out.publicKey = publicKeys;
58
+ if (signingKey) {
59
+ out.signingKey = signingKey;
60
+ }
54
61
  if (secretKey) {
55
62
  out.secretKey = secretKey;
56
63
  }
@@ -61,6 +68,9 @@ export async function createAccount(
61
68
  log(`\nNew account:\n`);
62
69
  log(`Address: ${address.toString()}`);
63
70
  log(`Public key: ${publicKeys.toString()}`);
71
+ if (signingKey) {
72
+ log(`Signing key: ${signingKey.toString()}`);
73
+ }
64
74
  if (secretKey) {
65
75
  log(`Secret key: ${secretKey.toString()}`);
66
76
  }
@@ -71,7 +81,9 @@ export async function createAccount(
71
81
 
72
82
  let txHash: TxHash | undefined;
73
83
  let txReceipt: TxReceipt | undefined;
74
- if (!registerOnly) {
84
+ // Initializerless accounts have no deployment tx — creating one only registers it locally — so there is
85
+ // nothing to deploy on-chain.
86
+ if (!registerOnly && accountType !== 'schnorr_initializerless') {
75
87
  const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
76
88
 
77
89
  const delegatedDeployment = deployer && !account.address.equals(deployer);
@@ -89,10 +101,10 @@ export async function createAccount(
89
101
  const deployMethod = await account.getDeployMethod();
90
102
  const sim = await deployMethod.simulate({
91
103
  ...deployAccountOpts,
92
- fee: { ...deployAccountOpts.fee, estimateGas: true },
104
+ includeMetadata: true,
93
105
  });
94
- // estimateGas: true guarantees these fields are present
95
- const estimatedGas = sim.estimatedGas!;
106
+ // includeMetadata: true guarantees these fields are present
107
+ const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed!);
96
108
  const stats = sim.stats!;
97
109
 
98
110
  if (feeOpts.estimateOnly) {
@@ -160,5 +172,5 @@ export async function createAccount(
160
172
  }
161
173
  }
162
174
 
163
- return { alias, address, secretKey, salt: instanceSalt };
175
+ return { alias, address, signingKey, secretKey, salt: instanceSalt };
164
176
  }
@@ -75,10 +75,10 @@ export async function deploy(
75
75
  const localStart = performance.now();
76
76
  const sim = await deployInteraction.simulate({
77
77
  ...deployOpts,
78
- fee: { ...deployOpts.fee, estimateGas: true },
78
+ includeMetadata: true,
79
79
  });
80
- // estimateGas: true guarantees these fields are present
81
- const estimatedGas = sim.estimatedGas!;
80
+ // includeMetadata: true guarantees these fields are present
81
+ const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed!);
82
82
  const stats = sim.stats!;
83
83
 
84
84
  if (feeOpts.estimateOnly) {
@@ -30,7 +30,7 @@ export async function deployAccount(
30
30
  ) {
31
31
  const out: Record<string, any> = {};
32
32
 
33
- const account = await wallet.createOrRetrieveAccount(address);
33
+ const account = await wallet.retrieveAccount(address);
34
34
  const { partialAddress, publicKeys } = await account.getCompleteAddress();
35
35
  const { initializationHash, salt } = account.getInstance();
36
36
 
@@ -68,10 +68,10 @@ export async function deployAccount(
68
68
  const deployMethod = await account.getDeployMethod();
69
69
  const sim = await deployMethod.simulate({
70
70
  ...deployAccountOpts,
71
- fee: { ...deployAccountOpts.fee, estimateGas: true },
71
+ includeMetadata: true,
72
72
  });
73
- // estimateGas: true guarantees these fields are present
74
- const estimatedGas = sim.estimatedGas!;
73
+ // includeMetadata: true guarantees these fields are present
74
+ const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed!);
75
75
  const stats = sim.stats!;
76
76
 
77
77
  if (feeOpts.estimateOnly) {
@@ -16,7 +16,18 @@ export async function importTestAccounts(wallet: CLIWallet, db: WalletDB, json:
16
16
  const secret = testAccounts[i].secret;
17
17
  const salt = new Fr(account.salt);
18
18
  const address = account.address;
19
- await db.storeAccount(address, { type: 'schnorr', secretKey: secret, salt, alias, publicKey: undefined }, log);
19
+ await db.storeAccount(
20
+ address,
21
+ {
22
+ type: 'schnorr_initializerless',
23
+ signingKey: account.signingKey,
24
+ secretKey: secret,
25
+ salt,
26
+ alias,
27
+ publicKey: undefined,
28
+ },
29
+ log,
30
+ );
20
31
 
21
32
  if (json) {
22
33
  out[alias] = {
package/src/cmds/index.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  ETHEREUM_HOSTS,
5
5
  PRIVATE_KEY,
6
6
  addOptions,
7
- createSecretKeyOption,
7
+ createSigningKeyOption,
8
8
  l1ChainIdOption,
9
9
  parseBigint,
10
10
  parseFieldFromHexString,
@@ -24,7 +24,7 @@ import {
24
24
  ARTIFACT_DESCRIPTION,
25
25
  CLIFeeArgs,
26
26
  aliasedAddressParser,
27
- aliasedSecretKeyParser,
27
+ aliasedSigningKeyParser,
28
28
  aliasedTxHashParser,
29
29
  artifactPathFromPromiseOrAlias,
30
30
  artifactPathParser,
@@ -96,8 +96,8 @@ export function injectCommands(
96
96
  'Public key that identifies a private signing key stored outside of the wallet. Used for ECDSA SSH accounts over the secp256r1 curve.',
97
97
  )
98
98
  .addOption(
99
- createSecretKeyOption('Secret key for account. Uses random by default.', false, sk =>
100
- aliasedSecretKeyParser(sk, db),
99
+ createSigningKeyOption('Signing key for account. Uses random by default.', false, sk =>
100
+ aliasedSigningKeyParser(sk, db),
101
101
  ).conflicts('public-key'),
102
102
  )
103
103
  .addOption(createAliasOption('Alias for the account. Used for easy reference in subsequent commands.', !db))
@@ -124,7 +124,7 @@ export function injectCommands(
124
124
  const {
125
125
  type,
126
126
  from: parsedFromAddress,
127
- secretKey,
127
+ signingKey,
128
128
  salt,
129
129
  wait,
130
130
  waitForStatus: waitForStatusStr,
@@ -156,7 +156,7 @@ export function injectCommands(
156
156
  wallet,
157
157
  node,
158
158
  type,
159
- secretKey,
159
+ signingKey,
160
160
  salt,
161
161
  publicKey,
162
162
  alias,
@@ -174,8 +174,8 @@ export function injectCommands(
174
174
  log,
175
175
  );
176
176
  if (db) {
177
- const { address, alias, secretKey, salt } = accountCreationResult;
178
- await db.storeAccount(address, { type, secretKey, salt, alias, publicKey }, log);
177
+ const { address, alias, signingKey, secretKey, salt } = accountCreationResult;
178
+ await db.storeAccount(address, { type, signingKey, secretKey, salt, alias, publicKey }, log);
179
179
  }
180
180
  });
181
181
 
@@ -399,7 +399,9 @@ export function injectCommands(
399
399
  .addOption(createContractAddressOption(db))
400
400
  .addOption(createArtifactOption(db))
401
401
  .addOption(
402
- createSecretKeyOption("The sender's secret key", !db, sk => aliasedSecretKeyParser(sk, db)).conflicts('account'),
402
+ createSigningKeyOption("The sender's signing key", !db, sk => aliasedSigningKeyParser(sk, db)).conflicts(
403
+ 'account',
404
+ ),
403
405
  )
404
406
  .addOption(createAuthwitnessOption('Authorization witness to use for the simulation', !db, db))
405
407
  .addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))