@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.
- package/dest/cmds/check_tx.js +8 -6
- package/dest/cmds/create_account.d.ts +4 -2
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +26 -10
- package/dest/cmds/deploy.js +3 -6
- package/dest/cmds/deploy_account.js +4 -7
- package/dest/cmds/import_test_accounts.d.ts +1 -1
- package/dest/cmds/import_test_accounts.d.ts.map +1 -1
- package/dest/cmds/import_test_accounts.js +2 -1
- package/dest/cmds/index.d.ts +1 -1
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +8 -7
- package/dest/cmds/send.js +3 -6
- package/dest/cmds/simulate.d.ts +1 -1
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +2 -1
- package/dest/storage/wallet_db.d.ts +7 -4
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +15 -1
- package/dest/utils/constants.d.ts +2 -2
- package/dest/utils/constants.d.ts.map +1 -1
- package/dest/utils/constants.js +1 -0
- package/dest/utils/options/fees.d.ts +1 -1
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +4 -1
- package/dest/utils/options/options.d.ts +2 -2
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +5 -5
- package/dest/utils/wallet.d.ts +25 -5
- package/dest/utils/wallet.d.ts.map +1 -1
- package/dest/utils/wallet.js +89 -67
- package/package.json +15 -15
- package/src/cmds/check_tx.ts +11 -10
- package/src/cmds/create_account.ts +27 -15
- package/src/cmds/deploy.ts +3 -3
- package/src/cmds/deploy_account.ts +4 -4
- package/src/cmds/import_test_accounts.ts +12 -1
- package/src/cmds/index.ts +11 -9
- package/src/cmds/send.ts +3 -3
- package/src/cmds/simulate.ts +2 -1
- package/src/storage/wallet_db.ts +24 -2
- package/src/utils/constants.ts +7 -1
- package/src/utils/options/fees.ts +4 -2
- package/src/utils/options/options.ts +5 -5
- package/src/utils/wallet.ts +132 -85
package/dest/utils/wallet.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
32
|
-
|
|
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,
|
|
64
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uI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XpCO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/utils/wallet.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAiC,MAAM,yBAAyB,CAAC;AACtF,OAAO,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/utils/wallet.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAiC,MAAM,yBAAyB,CAAC;AACtF,OAAO,EAEL,KAAK,qBAAqB,EAE3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAGzE,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,KAAK,EAA2C,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAA0B,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,KAAK,4BAA4B,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ED;;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"}
|
package/dest/utils/wallet.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { EcdsaRAccountContract, EcdsaRSSHAccountContract } from '@aztec/accounts/ecdsa';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/stub
|
|
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 {
|
|
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
|
-
|
|
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.
|
|
42
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (this.db
|
|
122
|
-
(
|
|
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
|
-
|
|
125
|
-
|
|
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
|
-
|
|
136
|
-
|
|
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
|
-
|
|
141
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
71
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
72
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
73
|
-
"@aztec/cli": "0.0.1-commit.
|
|
74
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
75
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
76
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
77
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
78
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
79
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
80
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
81
|
-
"@aztec/standard-contracts": "0.0.1-commit.
|
|
82
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
83
|
-
"@aztec/wallet-sdk": "0.0.1-commit.
|
|
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",
|
package/src/cmds/check_tx.ts
CHANGED
|
@@ -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
|
-
|
|
202
|
-
)
|
|
203
|
-
const
|
|
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
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
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
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
secretKey
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
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
|
-
|
|
104
|
+
includeMetadata: true,
|
|
93
105
|
});
|
|
94
|
-
//
|
|
95
|
-
const estimatedGas = sim.
|
|
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
|
}
|
package/src/cmds/deploy.ts
CHANGED
|
@@ -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
|
-
|
|
78
|
+
includeMetadata: true,
|
|
79
79
|
});
|
|
80
|
-
//
|
|
81
|
-
const estimatedGas = sim.
|
|
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.
|
|
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
|
-
|
|
71
|
+
includeMetadata: true,
|
|
72
72
|
});
|
|
73
|
-
//
|
|
74
|
-
const estimatedGas = sim.
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
100
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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))
|