@aztec/cli-wallet 1.2.1 → 2.0.0-nightly.20250813

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 (43) hide show
  1. package/dest/bin/index.js +1 -1
  2. package/dest/cmds/authorize_action.d.ts +1 -1
  3. package/dest/cmds/authorize_action.d.ts.map +1 -1
  4. package/dest/cmds/authorize_action.js +4 -2
  5. package/dest/cmds/cancel_tx.d.ts.map +1 -1
  6. package/dest/cmds/cancel_tx.js +4 -1
  7. package/dest/cmds/create_account.d.ts +2 -2
  8. package/dest/cmds/create_account.d.ts.map +1 -1
  9. package/dest/cmds/create_account.js +10 -7
  10. package/dest/cmds/deploy.d.ts +2 -2
  11. package/dest/cmds/deploy.d.ts.map +1 -1
  12. package/dest/cmds/deploy.js +15 -14
  13. package/dest/cmds/deploy_account.d.ts +2 -2
  14. package/dest/cmds/deploy_account.d.ts.map +1 -1
  15. package/dest/cmds/deploy_account.js +7 -4
  16. package/dest/cmds/index.d.ts.map +1 -1
  17. package/dest/cmds/index.js +9 -7
  18. package/dest/cmds/profile.js +1 -1
  19. package/dest/cmds/register_contract.js +2 -2
  20. package/dest/cmds/simulate.d.ts.map +1 -1
  21. package/dest/cmds/simulate.js +9 -0
  22. package/dest/utils/authorizations.d.ts +5 -0
  23. package/dest/utils/authorizations.d.ts.map +1 -0
  24. package/dest/utils/authorizations.js +28 -0
  25. package/dest/utils/options/fees.d.ts.map +1 -1
  26. package/dest/utils/options/fees.js +1 -0
  27. package/dest/utils/profiling.d.ts +1 -1
  28. package/dest/utils/profiling.d.ts.map +1 -1
  29. package/dest/utils/profiling.js +3 -3
  30. package/package.json +12 -12
  31. package/src/bin/index.ts +1 -1
  32. package/src/cmds/authorize_action.ts +2 -1
  33. package/src/cmds/cancel_tx.ts +4 -1
  34. package/src/cmds/create_account.ts +20 -10
  35. package/src/cmds/deploy.ts +24 -11
  36. package/src/cmds/deploy_account.ts +17 -7
  37. package/src/cmds/index.ts +30 -5
  38. package/src/cmds/profile.ts +1 -1
  39. package/src/cmds/register_contract.ts +2 -2
  40. package/src/cmds/simulate.ts +16 -0
  41. package/src/utils/authorizations.ts +49 -0
  42. package/src/utils/options/fees.ts +1 -0
  43. package/src/utils/profiling.ts +3 -2
package/dest/bin/index.js CHANGED
@@ -69,7 +69,7 @@ function injectInternalCommands(program, log, db) {
69
69
  await db.init(await openStoreAt(dataDir));
70
70
  let protocolContractsRegistered;
71
71
  try {
72
- protocolContractsRegistered = !!await db.retrieveAlias('contracts:ContractClassRegisterer');
72
+ protocolContractsRegistered = !!await db.retrieveAlias('contracts:ContractClassRegistry');
73
73
  // eslint-disable-next-line no-empty
74
74
  } catch {}
75
75
  if (!protocolContractsRegistered) {
@@ -1,4 +1,4 @@
1
1
  import { type AccountWalletWithSecretKey, type AztecAddress } from '@aztec/aztec.js';
2
2
  import type { LogFn } from '@aztec/foundation/log';
3
- export declare function authorizeAction(wallet: AccountWalletWithSecretKey, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("@aztec/aztec.js").FieldsOf<import("@aztec/aztec.js").TxReceipt>>;
3
+ export declare function authorizeAction(wallet: AccountWalletWithSecretKey, from: AztecAddress, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("@aztec/aztec.js").FieldsOf<import("@aztec/aztec.js").TxReceipt>>;
4
4
  //# sourceMappingURL=authorize_action.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authorize_action.d.ts","sourceRoot":"","sources":["../../src/cmds/authorize_action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,KAAK,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAE/F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,wBAAsB,eAAe,CACnC,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,GAAG,EAAE,KAAK,oFAwBX"}
1
+ {"version":3,"file":"authorize_action.d.ts","sourceRoot":"","sources":["../../src/cmds/authorize_action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,KAAK,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAE/F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,wBAAsB,eAAe,CACnC,MAAM,EAAE,0BAA0B,EAClC,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,GAAG,EAAE,KAAK,oFAwBX"}
@@ -1,7 +1,7 @@
1
1
  import { Contract } from '@aztec/aztec.js';
2
2
  import { prepTx } from '@aztec/cli/utils';
3
3
  import { DEFAULT_TX_TIMEOUT_S } from '../utils/pxe_wrapper.js';
4
- export async function authorizeAction(wallet, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
4
+ export async function authorizeAction(wallet, from, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
5
5
  const { functionArgs, contractArtifact, isPrivate } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
6
6
  if (isPrivate) {
7
7
  throw new Error('Cannot authorize private function. To allow a third party to call a private function, please create an authorization witness via the create-authwit command');
@@ -12,7 +12,9 @@ export async function authorizeAction(wallet, functionName, caller, functionArgs
12
12
  caller,
13
13
  action
14
14
  }, true);
15
- const witness = await setAuthwitnessInteraction.send().wait({
15
+ const witness = await setAuthwitnessInteraction.send({
16
+ from
17
+ }).wait({
16
18
  timeout: DEFAULT_TX_TIMEOUT_S
17
19
  });
18
20
  log(`Authorized action ${functionName} on contract ${contractAddress} for caller ${caller}`);
@@ -1 +1 @@
1
- {"version":3,"file":"cancel_tx.d.ts","sourceRoot":"","sources":["../../src/cmds/cancel_tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,KAAK,gBAAgB,EAAU,KAAK,MAAM,EAAY,MAAM,iBAAiB,CAAC;AAGxH,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIzD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,0BAA0B,EAClC,EACE,MAAM,EACN,WAAW,EAAE,iBAAiB,EAC9B,OAAO,EACP,WAAW,GACZ,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,EAClF,aAAa,EAAE,gBAAgB,EAC/B,aAAa,EAAE,OAAO,EACtB,aAAa,EAAE,OAAO,GAAG,SAAS,EAClC,GAAG,EAAE,KAAK,iBA0CX"}
1
+ {"version":3,"file":"cancel_tx.d.ts","sourceRoot":"","sources":["../../src/cmds/cancel_tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,KAAK,gBAAgB,EAAU,KAAK,MAAM,EAAY,MAAM,iBAAiB,CAAC;AAGxH,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIzD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,0BAA0B,EAClC,EACE,MAAM,EACN,WAAW,EAAE,iBAAiB,EAC9B,OAAO,EACP,WAAW,GACZ,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,EAClF,aAAa,EAAE,gBAAgB,EAC/B,aAAa,EAAE,OAAO,EACtB,aAAa,EAAE,OAAO,GAAG,SAAS,EAClC,GAAG,EAAE,KAAK,iBA6CX"}
@@ -23,7 +23,10 @@ export async function cancelTx(wallet, { txHash, gasSettings: prevTxGasSettings,
23
23
  });
24
24
  const txSimulationResult = await wallet.simulateTx(txRequest, true);
25
25
  const txProvingResult = await wallet.proveTx(txRequest, txSimulationResult.privateExecutionResult);
26
- const sentTx = new SentTx(wallet, ()=>wallet.sendTx(txProvingResult.toTx()));
26
+ const sentTx = new SentTx(wallet, async ()=>{
27
+ const tx = await txProvingResult.toTx();
28
+ return wallet.sendTx(tx);
29
+ });
27
30
  try {
28
31
  await sentTx.wait({
29
32
  timeout: DEFAULT_TX_TIMEOUT_S
@@ -1,11 +1,11 @@
1
- import type { PXE } from '@aztec/aztec.js';
1
+ import { AztecAddress, type PXE } from '@aztec/aztec.js';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
  import type { LogFn, Logger } from '@aztec/foundation/log';
4
4
  import { type AccountType } from '../utils/accounts.js';
5
5
  import { type IFeeOpts } from '../utils/options/fees.js';
6
6
  export declare function createAccount(client: PXE, accountType: AccountType, secretKey: Fr | undefined, publicKey: string | undefined, alias: string | undefined, registerOnly: boolean, publicDeploy: boolean, skipInitialization: boolean, wait: boolean, feeOpts: IFeeOpts, json: boolean, verbose: boolean, debugLogger: Logger, log: LogFn): Promise<{
7
7
  alias: string | undefined;
8
- address: import("@aztec/aztec.js").AztecAddress;
8
+ address: AztecAddress;
9
9
  secretKey: Fr;
10
10
  salt: Fr;
11
11
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/cmds/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,KAAK,WAAW,EAA2B,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAI5E,wBAAsB,aAAa,CACjC,MAAM,EAAE,GAAG,EACX,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,EAAE,GAAG,SAAS,EACzB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,OAAO,EACrB,kBAAkB,EAAE,OAAO,EAC3B,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK;;;;;GAsHX"}
1
+ {"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/cmds/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6B,KAAK,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEpF,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,KAAK,WAAW,EAA2B,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAI5E,wBAAsB,aAAa,CACjC,MAAM,EAAE,GAAG,EACX,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,EAAE,GAAG,SAAS,EACzB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,OAAO,EACrB,kBAAkB,EAAE,OAAO,EAC3B,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK;;;;;GAgIX"}
@@ -1,3 +1,4 @@
1
+ import { AztecAddress } from '@aztec/aztec.js';
1
2
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
2
3
  import { Fr } from '@aztec/foundation/fields';
3
4
  import { createOrRetrieveAccount } from '../utils/accounts.js';
@@ -39,17 +40,17 @@ export async function createAccount(client, accountType, secretKey, publicKey, a
39
40
  } else {
40
41
  const wallet = await account.getWallet();
41
42
  const deployOpts = {
42
- skipClassRegistration: !publicDeploy,
43
- skipPublicDeployment: !publicDeploy,
43
+ skipClassPublication: !publicDeploy,
44
+ skipInstancePublication: !publicDeploy,
44
45
  skipInitialization: skipInitialization,
45
46
  ...await feeOpts.toDeployAccountOpts(wallet)
46
47
  };
47
48
  /*
48
- * This is usually handled by accountManager.deploy(), but we're accessing the lower
49
+ * This is usually handled by accountManager.create(), but we're accessing the lower
49
50
  * level method to get gas and timings. That means we have to replicate some of the logic here.
50
- * In case we're deploying our own account, we need to hijack the payment method for the fee,
51
+ * In case we're initializing and/or publishing our own account, we need to hijack the payment method for the fee,
51
52
  * wrapping it in the one that will make use of the freshly deployed account's
52
- * entrypoint. For reference, see aztec.js/src/account_manager.ts:deploy()
53
+ * entrypoint. For reference, see aztec.js/src/account_manager.ts:sendAccountContractSetupTx()
53
54
  * Also, salt and universalDeploy have to be explicitly provided
54
55
  */ deployOpts.fee = !deployOpts?.deployWallet && deployOpts?.fee ? {
55
56
  ...deployOpts.fee,
@@ -59,6 +60,7 @@ export async function createAccount(client, accountType, secretKey, publicKey, a
59
60
  if (feeOpts.estimateOnly) {
60
61
  const gas = await deployMethod.estimateGas({
61
62
  ...deployOpts,
63
+ from: AztecAddress.ZERO,
62
64
  universalDeploy: true,
63
65
  contractAddressSalt: salt
64
66
  });
@@ -79,6 +81,7 @@ export async function createAccount(client, accountType, secretKey, publicKey, a
79
81
  } else {
80
82
  const provenTx = await deployMethod.prove({
81
83
  ...deployOpts,
84
+ from: AztecAddress.ZERO,
82
85
  universalDeploy: true,
83
86
  contractAddressSalt: salt
84
87
  });
@@ -87,7 +90,7 @@ export async function createAccount(client, accountType, secretKey, publicKey, a
87
90
  }
88
91
  tx = provenTx.send();
89
92
  const txHash = await tx.getTxHash();
90
- debugLogger.debug(`Account contract tx sent with hash ${txHash}`);
93
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
91
94
  out.txHash = txHash;
92
95
  if (wait) {
93
96
  if (!json) {
@@ -107,7 +110,7 @@ export async function createAccount(client, accountType, secretKey, publicKey, a
107
110
  log(prettyPrintJSON(out));
108
111
  } else {
109
112
  if (tx) {
110
- log(`Deploy tx hash: ${await tx.getTxHash()}`);
113
+ log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
111
114
  }
112
115
  if (txReceipt) {
113
116
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
@@ -1,6 +1,6 @@
1
- import { type AccountWalletWithSecretKey, Fr } from '@aztec/aztec.js';
1
+ import { type AccountWalletWithSecretKey, AztecAddress, Fr } from '@aztec/aztec.js';
2
2
  import type { LogFn, Logger } from '@aztec/foundation/log';
3
3
  import { PublicKeys } from '@aztec/stdlib/keys';
4
4
  import { type IFeeOpts } from '../utils/options/fees.js';
5
- export declare function deploy(wallet: AccountWalletWithSecretKey, artifactPath: string, json: boolean, publicKeys: PublicKeys | undefined, rawArgs: any[], salt: Fr | undefined, initializer: string | undefined, skipPublicDeployment: boolean, skipClassRegistration: boolean, skipInitialization: boolean | undefined, universalDeploy: boolean | undefined, wait: boolean, feeOpts: IFeeOpts, verbose: boolean, debugLogger: Logger, log: LogFn, logJson: (output: any) => void): Promise<import("@aztec/aztec.js").AztecAddress | undefined>;
5
+ export declare function deploy(wallet: AccountWalletWithSecretKey, deployer: AztecAddress | undefined, artifactPath: string, json: boolean, publicKeys: PublicKeys | undefined, rawArgs: any[], salt: Fr | undefined, initializer: string | undefined, skipInstancePublication: boolean, skipClassPublication: boolean, skipInitialization: boolean | undefined, wait: boolean, feeOpts: IFeeOpts, verbose: boolean, timeout: number | undefined, debugLogger: Logger, log: LogFn, logJson: (output: any) => void): Promise<AztecAddress | undefined>;
6
6
  //# sourceMappingURL=deploy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAwC,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAE5G,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAI5E,wBAAsB,MAAM,CAC1B,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,OAAO,EAAE,GAAG,EAAE,EACd,IAAI,EAAE,EAAE,GAAG,SAAS,EACpB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,oBAAoB,EAAE,OAAO,EAC7B,qBAAqB,EAAE,OAAO,EAC9B,kBAAkB,EAAE,OAAO,GAAG,SAAS,EACvC,eAAe,EAAE,OAAO,GAAG,SAAS,EACpC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK,EACV,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,+DAuF/B"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,0BAA0B,EAC/B,YAAY,EAGZ,EAAE,EACH,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAI5E,wBAAsB,MAAM,CAC1B,MAAM,EAAE,0BAA0B,EAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,OAAO,EAAE,GAAG,EAAE,EACd,IAAI,EAAE,EAAE,GAAG,SAAS,EACpB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,uBAAuB,EAAE,OAAO,EAChC,oBAAoB,EAAE,OAAO,EAC7B,kBAAkB,EAAE,OAAO,GAAG,SAAS,EACvC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,YAAuB,EACtC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK,EACV,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,qCA6F/B"}
@@ -1,17 +1,17 @@
1
- import { ContractDeployer, Fr } from '@aztec/aztec.js';
1
+ import { AztecAddress, ContractDeployer, Fr } from '@aztec/aztec.js';
2
2
  import { encodeArgs, getContractArtifact } from '@aztec/cli/utils';
3
3
  import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
4
4
  import { PublicKeys } from '@aztec/stdlib/keys';
5
5
  import { printGasEstimates } from '../utils/options/fees.js';
6
6
  import { printProfileResult } from '../utils/profiling.js';
7
7
  import { DEFAULT_TX_TIMEOUT_S } from '../utils/pxe_wrapper.js';
8
- export async function deploy(wallet, artifactPath, json, publicKeys, rawArgs, salt, initializer, skipPublicDeployment, skipClassRegistration, skipInitialization, universalDeploy, wait, feeOpts, verbose, debugLogger, log, logJson) {
8
+ export async function deploy(wallet, deployer, artifactPath, json, publicKeys, rawArgs, salt, initializer, skipInstancePublication, skipClassPublication, skipInitialization, wait, feeOpts, verbose, timeout = DEFAULT_TX_TIMEOUT_S, debugLogger, log, logJson) {
9
9
  salt ??= Fr.random();
10
10
  const contractArtifact = await getContractArtifact(artifactPath, log);
11
11
  const hasInitializer = getAllFunctionAbis(contractArtifact).some((fn)=>fn.isInitializer);
12
12
  const constructorArtifact = hasInitializer ? getInitializer(contractArtifact, initializer) : undefined;
13
13
  // TODO(#12081): Add contractArtifact.noirVersion and check here (via Noir.lock)?
14
- const deployer = new ContractDeployer(contractArtifact, wallet, publicKeys ?? PublicKeys.default(), initializer);
14
+ const contractDeployer = new ContractDeployer(contractArtifact, wallet, publicKeys ?? PublicKeys.default(), initializer);
15
15
  let args = [];
16
16
  if (rawArgs.length > 0) {
17
17
  if (!constructorArtifact) {
@@ -21,30 +21,31 @@ export async function deploy(wallet, artifactPath, json, publicKeys, rawArgs, sa
21
21
  args = encodeArgs(rawArgs, constructorArtifact.parameters);
22
22
  debugLogger.debug(`Encoded arguments: ${args.join(', ')}`);
23
23
  }
24
- const deploy = deployer.deploy(...args);
24
+ const deploy1 = contractDeployer.deploy(...args);
25
25
  const deployOpts = {
26
26
  ...await feeOpts.toDeployAccountOpts(wallet),
27
+ from: deployer ?? AztecAddress.ZERO,
27
28
  contractAddressSalt: salt,
28
- universalDeploy,
29
- skipClassRegistration,
29
+ universalDeploy: !deployer,
30
+ skipClassPublication,
30
31
  skipInitialization,
31
- skipPublicDeployment
32
+ skipInstancePublication
32
33
  };
33
34
  if (feeOpts.estimateOnly) {
34
- const gas = await deploy.estimateGas(deployOpts);
35
+ const gas = await deploy1.estimateGas(deployOpts);
35
36
  printGasEstimates(feeOpts, gas, log);
36
37
  return;
37
38
  }
38
- const provenTx = await deploy.prove(deployOpts);
39
+ const provenTx = await deploy1.prove(deployOpts);
39
40
  if (verbose) {
40
41
  printProfileResult(provenTx.stats, log);
41
42
  }
42
43
  const tx = provenTx.send();
43
44
  const txHash = await tx.getTxHash();
44
- debugLogger.debug(`Deploy tx sent with hash ${txHash}`);
45
+ debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
45
46
  if (wait) {
46
47
  const deployed = await tx.wait({
47
- timeout: DEFAULT_TX_TIMEOUT_S
48
+ timeout
48
49
  });
49
50
  const { address, partialAddress, instance } = deployed.contract;
50
51
  if (json) {
@@ -64,8 +65,8 @@ export async function deploy(wallet, artifactPath, json, publicKeys, rawArgs, sa
64
65
  log(`Deployment fee: ${deployed.transactionFee}`);
65
66
  }
66
67
  } else {
67
- const { address, partialAddress } = deploy;
68
- const instance = await deploy.getInstance();
68
+ const { address, partialAddress } = deploy1;
69
+ const instance = await deploy1.getInstance();
69
70
  if (json) {
70
71
  logJson({
71
72
  address: address?.toString() ?? 'N/A',
@@ -84,5 +85,5 @@ export async function deploy(wallet, artifactPath, json, publicKeys, rawArgs, sa
84
85
  log(`Deployer: ${instance.deployer.toString()}`);
85
86
  }
86
87
  }
87
- return deploy.address;
88
+ return deploy1.address;
88
89
  }
@@ -1,8 +1,8 @@
1
- import type { AccountManager } from '@aztec/aztec.js';
1
+ import { type AccountManager, AztecAddress } from '@aztec/aztec.js';
2
2
  import type { LogFn, Logger } from '@aztec/foundation/log';
3
3
  import { type IFeeOpts } from '../utils/options/fees.js';
4
4
  export declare function deployAccount(account: AccountManager, wait: boolean, registerClass: boolean, publicDeploy: boolean, feeOpts: IFeeOpts, json: boolean, verbose: boolean, debugLogger: Logger, log: LogFn): Promise<{
5
- address: import("@aztec/aztec.js").AztecAddress;
5
+ address: AztecAddress;
6
6
  secretKey: import("@aztec/aztec.js").Fr;
7
7
  salt: import("@aztec/aztec.js").Fr;
8
8
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"deploy_account.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy_account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,iBAAiB,CAAC;AAE5E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAI5E,wBAAsB,aAAa,CACjC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,OAAO,EACb,aAAa,EAAE,OAAO,EACtB,YAAY,EAAE,OAAO,EACrB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK;;;;GAqGX"}
1
+ {"version":3,"file":"deploy_account.d.ts","sourceRoot":"","sources":["../../src/cmds/deploy_account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,YAAY,EAA6B,MAAM,iBAAiB,CAAC;AAE/F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,KAAK,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAI5E,wBAAsB,aAAa,CACjC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,OAAO,EACb,aAAa,EAAE,OAAO,EACtB,YAAY,EAAE,OAAO,EACrB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK;;;;GA+GX"}
@@ -1,3 +1,4 @@
1
+ import { AztecAddress } from '@aztec/aztec.js';
1
2
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
2
3
  import { printGasEstimates } from '../utils/options/fees.js';
3
4
  import { printProfileResult } from '../utils/profiling.js';
@@ -29,8 +30,8 @@ export async function deployAccount(account, wait, registerClass, publicDeploy,
29
30
  let tx;
30
31
  let txReceipt;
31
32
  const deployOpts = {
32
- skipPublicDeployment: !publicDeploy,
33
- skipClassRegistration: !registerClass,
33
+ skipInstancePublication: !publicDeploy,
34
+ skipClassPublication: !registerClass,
34
35
  ...await feeOpts.toDeployAccountOpts(wallet)
35
36
  };
36
37
  /*
@@ -48,6 +49,7 @@ export async function deployAccount(account, wait, registerClass, publicDeploy,
48
49
  if (feeOpts.estimateOnly) {
49
50
  const gas = await deployMethod.estimateGas({
50
51
  ...deployOpts,
52
+ from: AztecAddress.ZERO,
51
53
  universalDeploy: true,
52
54
  contractAddressSalt: salt
53
55
  });
@@ -68,6 +70,7 @@ export async function deployAccount(account, wait, registerClass, publicDeploy,
68
70
  } else {
69
71
  const provenTx = await deployMethod.prove({
70
72
  ...deployOpts,
73
+ from: AztecAddress.ZERO,
71
74
  universalDeploy: true,
72
75
  contractAddressSalt: salt
73
76
  });
@@ -76,7 +79,7 @@ export async function deployAccount(account, wait, registerClass, publicDeploy,
76
79
  }
77
80
  tx = provenTx.send();
78
81
  const txHash = await tx.getTxHash();
79
- debugLogger.debug(`Account contract tx sent with hash ${txHash}`);
82
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
80
83
  out.txHash = txHash;
81
84
  if (wait) {
82
85
  if (!json) {
@@ -95,7 +98,7 @@ export async function deployAccount(account, wait, registerClass, publicDeploy,
95
98
  log(prettyPrintJSON(out));
96
99
  } else {
97
100
  if (tx) {
98
- log(`Deploy tx hash: ${await tx.getTxHash()}`);
101
+ log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
99
102
  }
100
103
  if (txReceipt) {
101
104
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cmds/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAI3D,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,WAAW,CAAC;AAGjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAwBxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,EACnB,EAAE,CAAC,EAAE,QAAQ,EACb,UAAU,CAAC,EAAE,UAAU,WA4qBxB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cmds/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAI3D,OAAO,EAAE,KAAK,OAAO,EAAU,MAAM,WAAW,CAAC;AAGjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAwBxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,EACnB,EAAE,CAAC,EAAE,QAAQ,EACb,UAAU,CAAC,EAAE,UAAU,WAosBxB"}
@@ -1,3 +1,4 @@
1
+ import { CopyCatAccountWallet } from '@aztec/accounts/copy-cat';
1
2
  import { getIdentities } from '@aztec/accounts/utils';
2
3
  import { createCompatibleClient } from '@aztec/aztec.js/rpc';
3
4
  import { TxHash } from '@aztec/aztec.js/tx_hash';
@@ -19,7 +20,7 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
19
20
  const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
20
21
  await importTestAccounts(client, db, json, log);
21
22
  });
22
- const createAccountCommand = program.command('create-account').description('Creates an aztec account that can be used for sending transactions. Registers the account on the PXE and deploys an account contract. Uses a Schnorr single-key account which uses the same key for encryption and authentication (not secure for production usage).').summary('Creates an aztec account that can be used for sending transactions.').option('--skip-initialization', 'Skip initializing the account contract. Useful for publicly deploying an existing account.').option('--public-deploy', 'Publicly deploys the account and registers the class if needed.').option('-p, --public-key <string>', 'Public key that identifies a private signing key stored outside of the wallet. Used for ECDSA SSH accounts over the secp256r1 curve.').addOption(pxeOption).addOption(createSecretKeyOption('Secret key for account. Uses random by default.', false, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('public-key')).addOption(createAliasOption('Alias for the account. Used for easy reference in subsequent commands.', !db)).addOption(createTypeOption(true)).option('--register-only', 'Just register the account on the PXE. Do not deploy or initialize the account contract.').option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
23
+ const createAccountCommand = program.command('create-account').description('Creates an aztec account that can be used for sending transactions. Registers the account on the PXE and deploys an account contract. Uses a Schnorr single-key account which uses the same key for encryption and authentication (not secure for production usage).').summary('Creates an aztec account that can be used for sending transactions.').option('--skip-initialization', 'Skip initializing the account contract. Useful for publicly deploying an existing account.').option('--public-deploy', 'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.').option('-p, --public-key <string>', 'Public key that identifies a private signing key stored outside of the wallet. Used for ECDSA SSH accounts over the secp256r1 curve.').addOption(pxeOption).addOption(createSecretKeyOption('Secret key for account. Uses random by default.', false, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('public-key')).addOption(createAliasOption('Alias for the account. Used for easy reference in subsequent commands.', !db)).addOption(createTypeOption(true)).option('--register-only', 'Just register the account on the PXE. Do not deploy or initialize the account contract.').option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
23
24
  // https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
24
25
  .option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').addOption(createVerboseOption());
25
26
  addOptions(createAccountCommand, FeeOptsWithFeePayer.getOptions()).action(async (_options, command)=>{
@@ -54,7 +55,7 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
54
55
  });
55
56
  const deployAccountCommand = program.command('deploy-account').description('Deploys an already registered aztec account that can be used for sending transactions.').addOption(createAccountOption('Alias or address of the account to deploy', !db, db)).addOption(pxeOption).option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
56
57
  // https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
57
- .option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--register-class', 'Register the contract class (useful for when the contract class has not been deployed yet).').option('--public-deploy', 'Publicly deploy this account contract (only useful if it contains public functions').addOption(createVerboseOption());
58
+ .option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--register-class', 'Register the contract class (useful for when the contract class has not been deployed yet).').option('--public-deploy', 'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.').addOption(createVerboseOption());
58
59
  addOptions(deployAccountCommand, FeeOptsWithFeePayer.getOptions()).action(async (_options, command)=>{
59
60
  const { deployAccount } = await import('./deploy_account.js');
60
61
  const options = command.optsWithGlobals();
@@ -65,17 +66,17 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
65
66
  });
66
67
  const deployCommand = program.command('deploy').description('Deploys a compiled Aztec.nr contract to Aztec.').argument('[artifact]', ARTIFACT_DESCRIPTION, artifactPathParser).option('--init <string>', 'The contract initializer function to call', 'constructor').option('--no-init', 'Leave the contract uninitialized').option('-k, --public-key <string>', 'Optional encryption public key for this address. Set this value only if this contract is expected to receive private notes, which will be encrypted using this public key.', parsePublicKey).option('-s, --salt <hex string>', 'Optional deployment salt as a hex string for generating the deployment address.', parseFieldFromHexString).option('--universal', 'Do not mix the sender address into the deployment.').addOption(pxeOption).addOption(createArgsOption(true, db)).addOption(createSecretKeyOption("The sender's secret key", !db, (sk)=>aliasedSecretKeyParser(sk, db)).conflicts('account')).addOption(createAccountOption('Alias or address of the account to deploy from', !db, db)).addOption(createAliasOption('Alias for the contract. Used for easy reference subsequent commands.', !db)).option('--json', 'Emit output as json')// `options.wait` is default true. Passing `--no-wait` will set it to false.
67
68
  // https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue
68
- .option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--no-class-registration', "Don't register this contract class").option('--no-public-deployment', "Don't emit this contract's public bytecode").addOption(createVerboseOption());
69
+ .option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction').option('--no-class-registration', "Don't register this contract class").option('--no-public-deployment', "Don't emit this contract's public bytecode").addOption(new Option('--timeout <number>', 'The amount of time in seconds to wait for the deployment to post to L2').conflicts('wait')).addOption(createVerboseOption());
69
70
  addOptions(deployCommand, FeeOpts.getOptions()).action(async (artifactPathPromise, _options, command)=>{
70
71
  const { deploy } = await import('./deploy.js');
71
72
  const options = command.optsWithGlobals();
72
- const { json, publicKey, args, salt, wait, secretKey, classRegistration, init, publicDeployment, universal, rpcUrl, from: parsedFromAddress, alias, verbose } = options;
73
+ const { json, publicKey, args, salt, wait, secretKey, classRegistration, init, publicDeployment, universal, rpcUrl, from: parsedFromAddress, alias, timeout, verbose } = options;
73
74
  const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
74
75
  const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
75
76
  const wallet = await account.getWallet();
76
77
  const artifactPath = await artifactPathPromise;
77
78
  debugLogger.info(`Using wallet with address ${wallet.getCompleteAddress().address.toString()}`);
78
- const address = await deploy(wallet, artifactPath, json, publicKey, args, salt, typeof init === 'string' ? init : undefined, !publicDeployment, !classRegistration, typeof init === 'string' ? false : init, universal, wait, await FeeOpts.fromCli(options, client, log, db), verbose, debugLogger, log, logJson(log));
79
+ const address = await deploy(wallet, universal ? undefined : wallet.getAddress(), artifactPath, json, publicKey, args, salt, typeof init === 'string' ? init : undefined, !publicDeployment, !classRegistration, typeof init === 'string' ? false : init, wait, await FeeOpts.fromCli(options, client, log, db), timeout, verbose, debugLogger, log, logJson(log));
79
80
  if (db && address) {
80
81
  await db.storeContract(address, artifactPath, log, alias);
81
82
  }
@@ -104,7 +105,8 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
104
105
  const { args, contractArtifact: artifactPathPromise, contractAddress, from: parsedFromAddress, rpcUrl, secretKey, verbose, authWitness } = options;
105
106
  const client = await pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
106
107
  const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
107
- const wallet = await account.getWallet();
108
+ const originalWallet = await account.getWallet();
109
+ const wallet = await CopyCatAccountWallet.create(client, originalWallet);
108
110
  const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
109
111
  const authWitnesses = cleanupAuthWitnesses(authWitness);
110
112
  await simulate(wallet, functionName, args, artifactPath, contractAddress, await FeeOpts.fromCli(options, client, log, db), authWitnesses, verbose, log);
@@ -155,7 +157,7 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
155
157
  const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
156
158
  const wallet = await account.getWallet();
157
159
  const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
158
- await authorizeAction(wallet, functionName, caller, args, artifactPath, contractAddress, log);
160
+ await authorizeAction(wallet, wallet.getAddress(), functionName, caller, args, artifactPath, contractAddress, log);
159
161
  });
160
162
  program.command('get-tx').description('Gets the status of the recent txs, or a detailed view if a specific transaction hash is provided').argument('[txHash]', 'A transaction hash to get the receipt for.', (txHash)=>aliasedTxHashParser(txHash, db)).addOption(pxeOption).option('-p, --page <number>', 'The page number to display', (value)=>integerArgParser(value, '--page', 1), 1).option('-s, --page-size <number>', 'The number of transactions to display per page', (value)=>integerArgParser(value, '--page-size', 1), 10).action(async (txHash, options)=>{
161
163
  const { checkTx } = await import('./check_tx.js');
@@ -14,7 +14,7 @@ export async function profile(wallet, functionName, functionArgsIn, contractArti
14
14
  authWitnesses,
15
15
  skipProofGeneration: false
16
16
  });
17
- printProfileResult(result.stats, log, result.executionSteps);
17
+ printProfileResult(result.stats, log, true, result.executionSteps);
18
18
  if (debugOutputPath) {
19
19
  const ivcInputsPath = path.join(debugOutputPath, 'ivc-inputs.msgpack');
20
20
  log(`Debug output written to ${ivcInputsPath}.`);
@@ -1,4 +1,4 @@
1
- import { PublicKeys, getContractInstanceFromDeployParams } from '@aztec/aztec.js';
1
+ import { PublicKeys, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js';
2
2
  import { getContractArtifact } from '@aztec/cli/cli-utils';
3
3
  import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
4
4
  export async function registerContract(wallet, node, address, artifactPath, log, initializer, publicKeys, rawArgs, salt, deployer) {
@@ -8,7 +8,7 @@ export async function registerContract(wallet, node, address, artifactPath, log,
8
8
  let contractInstance = await node.getContract(address);
9
9
  if (!contractInstance) {
10
10
  log(`Contract not found in the node at ${address}. Computing instance locally...`);
11
- contractInstance = await getContractInstanceFromDeployParams(contractArtifact, {
11
+ contractInstance = await getContractInstanceFromInstantiationParams(contractArtifact, {
12
12
  constructorArtifact,
13
13
  publicKeys: publicKeys ?? PublicKeys.default(),
14
14
  constructorArgs: rawArgs,
@@ -1 +1 @@
1
- {"version":3,"file":"simulate.d.ts","sourceRoot":"","sources":["../../src/cmds/simulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,WAAW,EAAE,KAAK,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAE5G,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGzD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,WAAW,EAAE,EAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK,iBAeX"}
1
+ {"version":3,"file":"simulate.d.ts","sourceRoot":"","sources":["../../src/cmds/simulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,WAAW,EAAE,KAAK,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAE5G,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAKnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGzD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,GAAG,EAAE,EACrB,oBAAoB,EAAE,MAAM,EAC5B,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,WAAW,EAAE,EAC5B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,KAAK,iBA8BX"}
@@ -1,6 +1,7 @@
1
1
  import { Contract } from '@aztec/aztec.js';
2
2
  import { prepTx } from '@aztec/cli/utils';
3
3
  import { format } from 'util';
4
+ import { printAuthorizations } from '../utils/authorizations.js';
4
5
  import { printProfileResult } from '../utils/profiling.js';
5
6
  export async function simulate(wallet, functionName, functionArgsIn, contractArtifactPath, contractAddress, feeOpts, authWitnesses, verbose, log) {
6
7
  const { functionArgs, contractArtifact } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
@@ -12,6 +13,14 @@ export async function simulate(wallet, functionName, functionArgsIn, contractArt
12
13
  includeMetadata: true
13
14
  });
14
15
  if (verbose) {
16
+ await printAuthorizations(simulationResult.offchainEffects, async (address)=>{
17
+ const metadata = await wallet.getContractMetadata(address);
18
+ if (!metadata.contractInstance) {
19
+ return undefined;
20
+ }
21
+ const classMetadata = await wallet.getContractClassMetadata(metadata.contractInstance.currentContractClassId, true);
22
+ return classMetadata.artifact;
23
+ }, log);
15
24
  printProfileResult(simulationResult.stats, log);
16
25
  }
17
26
  log(format('\nSimulation result: ', simulationResult.result, '\n'));
@@ -0,0 +1,5 @@
1
+ import { type AztecAddress, type ContractArtifact } from '@aztec/aztec.js';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+ import type { OffchainEffect } from '@aztec/stdlib/tx';
4
+ export declare function printAuthorizations(offchainEffects: OffchainEffect[], artifactRetriever: (address: AztecAddress) => Promise<ContractArtifact | undefined>, log: LogFn): Promise<void>;
5
+ //# sourceMappingURL=authorizations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorizations.d.ts","sourceRoot":"","sources":["../../src/utils/authorizations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAA4B,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD,wBAAsB,mBAAmB,CACvC,eAAe,EAAE,cAAc,EAAE,EACjC,iBAAiB,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,EACnF,GAAG,EAAE,KAAK,iBAsCX"}
@@ -0,0 +1,28 @@
1
+ import { CallAuthorizationRequest } from '@aztec/aztec.js';
2
+ import { decodeFromAbi, getFunctionArtifact } from '@aztec/stdlib/abi';
3
+ import { format } from 'util';
4
+ export async function printAuthorizations(offchainEffects, artifactRetriever, log) {
5
+ log(format('\nAuthorizations requested by the tx:\n'));
6
+ const callAuthorizationSelector = await CallAuthorizationRequest.getSelector();
7
+ const callAuthorizationEffects = offchainEffects.filter((effect)=>effect.data[0].equals(callAuthorizationSelector.toField()));
8
+ for (const callAuthorizationEffect of callAuthorizationEffects){
9
+ const callAuthorizationRequest = await CallAuthorizationRequest.fromFields(callAuthorizationEffect.data);
10
+ const artifact = await artifactRetriever(callAuthorizationEffect.contractAddress);
11
+ if (!artifact) {
12
+ log(format(' -', `Call authorization. Inner hash: ${callAuthorizationRequest.innerHash.toString()}\n`));
13
+ log(format(' ', `Contract: unknown@${callAuthorizationEffect.contractAddress}`));
14
+ log(format(' ', `${callAuthorizationRequest.functionSelector.toString()}(\n${callAuthorizationRequest.args.map((arg)=>` ${arg.toString()}`).join(',\n')}\n )`));
15
+ } else {
16
+ const functionAbi = await getFunctionArtifact(artifact, callAuthorizationRequest.functionSelector);
17
+ const callData = decodeFromAbi(functionAbi.parameters.map((param)=>param.type), callAuthorizationRequest.args);
18
+ const parameters = functionAbi.parameters.map((param, i)=>({
19
+ name: param.name,
20
+ value: callData[i]
21
+ }));
22
+ log(format(' -', `Call authorization. Inner hash: ${callAuthorizationRequest.innerHash.toString()}`));
23
+ log(format(' ', `Contract: ${artifact.name}@${callAuthorizationEffect.contractAddress}`));
24
+ log(format(' ', /* eslint-disable-next-line @typescript-eslint/no-base-to-string */ `${functionAbi.name}(\n${parameters.map((p)=>` ${p.name}: ${p.value}`).join(',\n')}\n )`));
25
+ }
26
+ log(`\n`);
27
+ }
28
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"fees.d.ts","sourceRoot":"","sources":["../../../src/utils/options/fees.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAEzB,KAAK,gBAAgB,EACrB,KAAK,GAAG,EACR,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAO,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAI3D,MAAM,MAAM,UAAU,GAAG;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9D,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC3E;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,QAAQ,EACjB,YAAY,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB,CAAC,EAClE,GAAG,EAAE,KAAK,QAIX;AAuGD,qBAAa,OAAQ,YAAW,QAAQ;IAE7B,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,WAAW;IAC/B,OAAO,CAAC,oBAAoB;IAC5B,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,WAAW;gBAPZ,YAAY,EAAE,OAAO,EACrB,WAAW,EAAE,WAAW,EACvB,oBAAoB,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,gBAAgB,CAAC,EAC1E,eAAe,EAAE,CACvB,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,gBAAgB,KAC5B,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,EAC/B,WAAW,EAAE,OAAO;IAGxB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAU7D,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAa/E,MAAM,CAAC,mBAAmB;IAI1B,MAAM,CAAC,UAAU;WAIJ,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,QAAQ;CAsB3E;AAED,qBAAa,mBAAoB,SAAQ,OAAO;WAC9B,mBAAmB;WAInB,UAAU;WAIJ,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,QAAQ;CA2BpF;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,mBAAmB,EAAE,OAAO,EAC5B,GAAG,EAAE,KAAK,EACV,EAAE,CAAC,EAAE,QAAQ,GACZ,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAoFtD;AAyBD,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAkBrD"}
1
+ {"version":3,"file":"fees.d.ts","sourceRoot":"","sources":["../../../src/utils/options/fees.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAEzB,KAAK,gBAAgB,EACrB,KAAK,GAAG,EACR,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAO,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAI3D,MAAM,MAAM,UAAU,GAAG;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9D,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC3E;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,QAAQ,EACjB,YAAY,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB,CAAC,EAClE,GAAG,EAAE,KAAK,QAIX;AAuGD,qBAAa,OAAQ,YAAW,QAAQ;IAE7B,YAAY,EAAE,OAAO;IACrB,WAAW,EAAE,WAAW;IAC/B,OAAO,CAAC,oBAAoB;IAC5B,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,WAAW;gBAPZ,YAAY,EAAE,OAAO,EACrB,WAAW,EAAE,WAAW,EACvB,oBAAoB,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,gBAAgB,CAAC,EAC1E,eAAe,EAAE,CACvB,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,gBAAgB,KAC5B,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,EAC/B,WAAW,EAAE,OAAO;IAGxB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAW7D,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAa/E,MAAM,CAAC,mBAAmB;IAI1B,MAAM,CAAC,UAAU;WAIJ,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,QAAQ;CAsB3E;AAED,qBAAa,mBAAoB,SAAQ,OAAO;WAC9B,mBAAmB;WAInB,UAAU;WAIJ,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,QAAQ;CA2BpF;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,mBAAmB,EAAE,OAAO,EAC5B,GAAG,EAAE,KAAK,EACV,EAAE,CAAC,EAAE,QAAQ,GACZ,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAoFtD;AAyBD,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAkBrD"}
@@ -111,6 +111,7 @@ export class FeeOpts {
111
111
  }
112
112
  async toSendOpts(sender) {
113
113
  return {
114
+ from: sender.getAddress(),
114
115
  fee: {
115
116
  estimateGas: this.estimateGas,
116
117
  gasSettings: this.gasSettings,
@@ -1,5 +1,5 @@
1
1
  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
- export declare function printProfileResult(stats: ProvingStats | SimulationStats, log: LogFn, executionSteps?: PrivateExecutionStep[]): void;
4
+ export declare function printProfileResult(stats: ProvingStats | SimulationStats, log: LogFn, printOracles?: boolean, executionSteps?: PrivateExecutionStep[]): void;
5
5
  //# sourceMappingURL=profiling.d.ts.map
@@ -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,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,QA6IxC"}
@@ -1,9 +1,9 @@
1
1
  import { format } from 'util';
2
- const FN_NAME_PADDING = 50;
2
+ const FN_NAME_PADDING = 60;
3
3
  const COLUMN_MIN_WIDTH = 13;
4
4
  const COLUMN_MAX_WIDTH = 15;
5
5
  const ORACLE_NAME_PADDING = 50;
6
- export function printProfileResult(stats, log, executionSteps) {
6
+ export function printProfileResult(stats, log, printOracles = false, executionSteps) {
7
7
  log(format('\nPer circuit breakdown:\n'));
8
8
  log(format(' ', 'Function name'.padEnd(FN_NAME_PADDING), 'Time'.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), executionSteps ? 'Gates'.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH) : '', executionSteps ? 'Subtotal'.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH) : ''));
9
9
  log(format(''.padEnd(FN_NAME_PADDING + COLUMN_MAX_WIDTH + COLUMN_MAX_WIDTH + (executionSteps ? COLUMN_MAX_WIDTH + COLUMN_MAX_WIDTH : 0), '-')));
@@ -17,7 +17,7 @@ export function printProfileResult(stats, log, executionSteps) {
17
17
  }
18
18
  acc += currentExecutionStep ? currentExecutionStep.gateCount : 0;
19
19
  log(format(' - ', fn.functionName.padEnd(FN_NAME_PADDING), `${fn.time.toFixed(2)}ms`.padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH), currentExecutionStep ? currentExecutionStep.gateCount.toLocaleString().padStart(COLUMN_MIN_WIDTH).padEnd(COLUMN_MAX_WIDTH) : '', currentExecutionStep ? acc.toLocaleString().padStart(COLUMN_MAX_WIDTH) : ''));
20
- if (fn.oracles) {
20
+ if (printOracles && fn.oracles) {
21
21
  log('');
22
22
  for (const [oracleName, { times }] of Object.entries(fn.oracles)){
23
23
  const calls = times.length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli-wallet",
3
- "version": "1.2.1",
3
+ "version": "2.0.0-nightly.20250813",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/cmds/index.js",
@@ -67,17 +67,17 @@
67
67
  ]
68
68
  },
69
69
  "dependencies": {
70
- "@aztec/accounts": "1.2.1",
71
- "@aztec/aztec.js": "1.2.1",
72
- "@aztec/cli": "1.2.1",
73
- "@aztec/entrypoints": "1.2.1",
74
- "@aztec/ethereum": "1.2.1",
75
- "@aztec/foundation": "1.2.1",
76
- "@aztec/kv-store": "1.2.1",
77
- "@aztec/noir-contracts.js": "1.2.1",
78
- "@aztec/noir-noirc_abi": "1.2.1",
79
- "@aztec/pxe": "1.2.1",
80
- "@aztec/stdlib": "1.2.1",
70
+ "@aztec/accounts": "2.0.0-nightly.20250813",
71
+ "@aztec/aztec.js": "2.0.0-nightly.20250813",
72
+ "@aztec/cli": "2.0.0-nightly.20250813",
73
+ "@aztec/entrypoints": "2.0.0-nightly.20250813",
74
+ "@aztec/ethereum": "2.0.0-nightly.20250813",
75
+ "@aztec/foundation": "2.0.0-nightly.20250813",
76
+ "@aztec/kv-store": "2.0.0-nightly.20250813",
77
+ "@aztec/noir-contracts.js": "2.0.0-nightly.20250813",
78
+ "@aztec/noir-noirc_abi": "2.0.0-nightly.20250813",
79
+ "@aztec/pxe": "2.0.0-nightly.20250813",
80
+ "@aztec/stdlib": "2.0.0-nightly.20250813",
81
81
  "commander": "^12.1.0",
82
82
  "inquirer": "^10.1.8",
83
83
  "source-map-support": "^0.5.21",
package/src/bin/index.ts CHANGED
@@ -120,7 +120,7 @@ async function main() {
120
120
  await db.init(await openStoreAt(dataDir));
121
121
  let protocolContractsRegistered;
122
122
  try {
123
- protocolContractsRegistered = !!(await db.retrieveAlias('contracts:ContractClassRegisterer'));
123
+ protocolContractsRegistered = !!(await db.retrieveAlias('contracts:ContractClassRegistry'));
124
124
  // eslint-disable-next-line no-empty
125
125
  } catch {}
126
126
  if (!protocolContractsRegistered) {
@@ -6,6 +6,7 @@ import { DEFAULT_TX_TIMEOUT_S } from '../utils/pxe_wrapper.js';
6
6
 
7
7
  export async function authorizeAction(
8
8
  wallet: AccountWalletWithSecretKey,
9
+ from: AztecAddress,
9
10
  functionName: string,
10
11
  caller: AztecAddress,
11
12
  functionArgsIn: any[],
@@ -30,7 +31,7 @@ export async function authorizeAction(
30
31
  const action = contract.methods[functionName](...functionArgs);
31
32
 
32
33
  const setAuthwitnessInteraction = await wallet.setPublicAuthWit({ caller, action }, true);
33
- const witness = await setAuthwitnessInteraction.send().wait({ timeout: DEFAULT_TX_TIMEOUT_S });
34
+ const witness = await setAuthwitnessInteraction.send({ from }).wait({ timeout: DEFAULT_TX_TIMEOUT_S });
34
35
 
35
36
  log(`Authorized action ${functionName} on contract ${contractAddress} for caller ${caller}`);
36
37
 
@@ -46,7 +46,10 @@ export async function cancelTx(
46
46
  });
47
47
  const txSimulationResult = await wallet.simulateTx(txRequest, true);
48
48
  const txProvingResult = await wallet.proveTx(txRequest, txSimulationResult.privateExecutionResult);
49
- const sentTx = new SentTx(wallet, () => wallet.sendTx(txProvingResult.toTx()));
49
+ const sentTx = new SentTx(wallet, async () => {
50
+ const tx = await txProvingResult.toTx();
51
+ return wallet.sendTx(tx);
52
+ });
50
53
  try {
51
54
  await sentTx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
52
55
 
@@ -1,4 +1,4 @@
1
- import type { DeployAccountOptions, PXE } from '@aztec/aztec.js';
1
+ import { AztecAddress, type DeployAccountOptions, type PXE } from '@aztec/aztec.js';
2
2
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
3
3
  import { Fr } from '@aztec/foundation/fields';
4
4
  import type { LogFn, Logger } from '@aztec/foundation/log';
@@ -69,17 +69,17 @@ export async function createAccount(
69
69
  } else {
70
70
  const wallet = await account.getWallet();
71
71
  const deployOpts: DeployAccountOptions = {
72
- skipClassRegistration: !publicDeploy,
73
- skipPublicDeployment: !publicDeploy,
72
+ skipClassPublication: !publicDeploy,
73
+ skipInstancePublication: !publicDeploy,
74
74
  skipInitialization: skipInitialization,
75
75
  ...(await feeOpts.toDeployAccountOpts(wallet)),
76
76
  };
77
77
  /*
78
- * This is usually handled by accountManager.deploy(), but we're accessing the lower
78
+ * This is usually handled by accountManager.create(), but we're accessing the lower
79
79
  * level method to get gas and timings. That means we have to replicate some of the logic here.
80
- * In case we're deploying our own account, we need to hijack the payment method for the fee,
80
+ * In case we're initializing and/or publishing our own account, we need to hijack the payment method for the fee,
81
81
  * wrapping it in the one that will make use of the freshly deployed account's
82
- * entrypoint. For reference, see aztec.js/src/account_manager.ts:deploy()
82
+ * entrypoint. For reference, see aztec.js/src/account_manager.ts:sendAccountContractSetupTx()
83
83
  * Also, salt and universalDeploy have to be explicitly provided
84
84
  */
85
85
  deployOpts.fee =
@@ -90,7 +90,12 @@ export async function createAccount(
90
90
  const deployMethod = await account.getDeployMethod(deployOpts.deployWallet);
91
91
 
92
92
  if (feeOpts.estimateOnly) {
93
- const gas = await deployMethod.estimateGas({ ...deployOpts, universalDeploy: true, contractAddressSalt: salt });
93
+ const gas = await deployMethod.estimateGas({
94
+ ...deployOpts,
95
+ from: AztecAddress.ZERO,
96
+ universalDeploy: true,
97
+ contractAddressSalt: salt,
98
+ });
94
99
  if (json) {
95
100
  out.fee = {
96
101
  gasLimits: {
@@ -106,14 +111,19 @@ export async function createAccount(
106
111
  printGasEstimates(feeOpts, gas, log);
107
112
  }
108
113
  } else {
109
- const provenTx = await deployMethod.prove({ ...deployOpts, universalDeploy: true, contractAddressSalt: salt });
114
+ const provenTx = await deployMethod.prove({
115
+ ...deployOpts,
116
+ from: AztecAddress.ZERO,
117
+ universalDeploy: true,
118
+ contractAddressSalt: salt,
119
+ });
110
120
  if (verbose) {
111
121
  printProfileResult(provenTx.stats!, log);
112
122
  }
113
123
  tx = provenTx.send();
114
124
 
115
125
  const txHash = await tx.getTxHash();
116
- debugLogger.debug(`Account contract tx sent with hash ${txHash}`);
126
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
117
127
  out.txHash = txHash;
118
128
  if (wait) {
119
129
  if (!json) {
@@ -132,7 +142,7 @@ export async function createAccount(
132
142
  log(prettyPrintJSON(out));
133
143
  } else {
134
144
  if (tx) {
135
- log(`Deploy tx hash: ${await tx.getTxHash()}`);
145
+ log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
136
146
  }
137
147
  if (txReceipt) {
138
148
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
@@ -1,4 +1,10 @@
1
- import { type AccountWalletWithSecretKey, ContractDeployer, type DeployOptions, Fr } from '@aztec/aztec.js';
1
+ import {
2
+ type AccountWalletWithSecretKey,
3
+ AztecAddress,
4
+ ContractDeployer,
5
+ type DeployOptions,
6
+ Fr,
7
+ } from '@aztec/aztec.js';
2
8
  import { encodeArgs, getContractArtifact } from '@aztec/cli/utils';
3
9
  import type { LogFn, Logger } from '@aztec/foundation/log';
4
10
  import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
@@ -10,19 +16,20 @@ import { DEFAULT_TX_TIMEOUT_S } from '../utils/pxe_wrapper.js';
10
16
 
11
17
  export async function deploy(
12
18
  wallet: AccountWalletWithSecretKey,
19
+ deployer: AztecAddress | undefined,
13
20
  artifactPath: string,
14
21
  json: boolean,
15
22
  publicKeys: PublicKeys | undefined,
16
23
  rawArgs: any[],
17
24
  salt: Fr | undefined,
18
25
  initializer: string | undefined,
19
- skipPublicDeployment: boolean,
20
- skipClassRegistration: boolean,
26
+ skipInstancePublication: boolean,
27
+ skipClassPublication: boolean,
21
28
  skipInitialization: boolean | undefined,
22
- universalDeploy: boolean | undefined,
23
29
  wait: boolean,
24
30
  feeOpts: IFeeOpts,
25
31
  verbose: boolean,
32
+ timeout: number = DEFAULT_TX_TIMEOUT_S,
26
33
  debugLogger: Logger,
27
34
  log: LogFn,
28
35
  logJson: (output: any) => void,
@@ -34,7 +41,12 @@ export async function deploy(
34
41
 
35
42
  // TODO(#12081): Add contractArtifact.noirVersion and check here (via Noir.lock)?
36
43
 
37
- const deployer = new ContractDeployer(contractArtifact, wallet, publicKeys ?? PublicKeys.default(), initializer);
44
+ const contractDeployer = new ContractDeployer(
45
+ contractArtifact,
46
+ wallet,
47
+ publicKeys ?? PublicKeys.default(),
48
+ initializer,
49
+ );
38
50
 
39
51
  let args = [];
40
52
  if (rawArgs.length > 0) {
@@ -46,14 +58,15 @@ export async function deploy(
46
58
  debugLogger.debug(`Encoded arguments: ${args.join(', ')}`);
47
59
  }
48
60
 
49
- const deploy = deployer.deploy(...args);
61
+ const deploy = contractDeployer.deploy(...args);
50
62
  const deployOpts: DeployOptions = {
51
63
  ...(await feeOpts.toDeployAccountOpts(wallet)),
64
+ from: deployer ?? AztecAddress.ZERO,
52
65
  contractAddressSalt: salt,
53
- universalDeploy,
54
- skipClassRegistration,
66
+ universalDeploy: !deployer,
67
+ skipClassPublication,
55
68
  skipInitialization,
56
- skipPublicDeployment,
69
+ skipInstancePublication,
57
70
  };
58
71
 
59
72
  if (feeOpts.estimateOnly) {
@@ -70,9 +83,9 @@ export async function deploy(
70
83
  const tx = provenTx.send();
71
84
 
72
85
  const txHash = await tx.getTxHash();
73
- debugLogger.debug(`Deploy tx sent with hash ${txHash}`);
86
+ debugLogger.debug(`Deploy tx sent with hash ${txHash.toString()}`);
74
87
  if (wait) {
75
- const deployed = await tx.wait({ timeout: DEFAULT_TX_TIMEOUT_S });
88
+ const deployed = await tx.wait({ timeout });
76
89
  const { address, partialAddress, instance } = deployed.contract;
77
90
  if (json) {
78
91
  logJson({
@@ -1,4 +1,4 @@
1
- import type { AccountManager, DeployAccountOptions } from '@aztec/aztec.js';
1
+ import { type AccountManager, AztecAddress, type DeployAccountOptions } from '@aztec/aztec.js';
2
2
  import { prettyPrintJSON } from '@aztec/cli/cli-utils';
3
3
  import type { LogFn, Logger } from '@aztec/foundation/log';
4
4
 
@@ -46,8 +46,8 @@ export async function deployAccount(
46
46
  let txReceipt;
47
47
 
48
48
  const deployOpts: DeployAccountOptions = {
49
- skipPublicDeployment: !publicDeploy,
50
- skipClassRegistration: !registerClass,
49
+ skipInstancePublication: !publicDeploy,
50
+ skipClassPublication: !registerClass,
51
51
  ...(await feeOpts.toDeployAccountOpts(wallet)),
52
52
  };
53
53
 
@@ -67,7 +67,12 @@ export async function deployAccount(
67
67
  const deployMethod = await account.getDeployMethod(deployOpts.deployWallet);
68
68
 
69
69
  if (feeOpts.estimateOnly) {
70
- const gas = await deployMethod.estimateGas({ ...deployOpts, universalDeploy: true, contractAddressSalt: salt });
70
+ const gas = await deployMethod.estimateGas({
71
+ ...deployOpts,
72
+ from: AztecAddress.ZERO,
73
+ universalDeploy: true,
74
+ contractAddressSalt: salt,
75
+ });
71
76
  if (json) {
72
77
  out.fee = {
73
78
  gasLimits: {
@@ -83,14 +88,19 @@ export async function deployAccount(
83
88
  printGasEstimates(feeOpts, gas, log);
84
89
  }
85
90
  } else {
86
- const provenTx = await deployMethod.prove({ ...deployOpts, universalDeploy: true, contractAddressSalt: salt });
91
+ const provenTx = await deployMethod.prove({
92
+ ...deployOpts,
93
+ from: AztecAddress.ZERO,
94
+ universalDeploy: true,
95
+ contractAddressSalt: salt,
96
+ });
87
97
  if (verbose) {
88
98
  printProfileResult(provenTx.stats!, log);
89
99
  }
90
100
  tx = provenTx.send();
91
101
 
92
102
  const txHash = await tx.getTxHash();
93
- debugLogger.debug(`Account contract tx sent with hash ${txHash}`);
103
+ debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
94
104
  out.txHash = txHash;
95
105
  if (wait) {
96
106
  if (!json) {
@@ -108,7 +118,7 @@ export async function deployAccount(
108
118
  log(prettyPrintJSON(out));
109
119
  } else {
110
120
  if (tx) {
111
- log(`Deploy tx hash: ${await tx.getTxHash()}`);
121
+ log(`Deploy tx hash: ${(await tx.getTxHash()).toString()}`);
112
122
  }
113
123
  if (txReceipt) {
114
124
  log(`Deploy tx fee: ${txReceipt.transactionFee}`);
package/src/cmds/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { CopyCatAccountWallet } from '@aztec/accounts/copy-cat';
1
2
  import { getIdentities } from '@aztec/accounts/utils';
2
3
  import { createCompatibleClient } from '@aztec/aztec.js/rpc';
3
4
  import { TxHash } from '@aztec/aztec.js/tx_hash';
@@ -80,7 +81,10 @@ export function injectCommands(
80
81
  '--skip-initialization',
81
82
  'Skip initializing the account contract. Useful for publicly deploying an existing account.',
82
83
  )
83
- .option('--public-deploy', 'Publicly deploys the account and registers the class if needed.')
84
+ .option(
85
+ '--public-deploy',
86
+ 'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.',
87
+ )
84
88
  .option(
85
89
  '-p, --public-key <string>',
86
90
  'Public key that identifies a private signing key stored outside of the wallet. Used for ECDSA SSH accounts over the secp256r1 curve.',
@@ -158,7 +162,10 @@ export function injectCommands(
158
162
  '--register-class',
159
163
  'Register the contract class (useful for when the contract class has not been deployed yet).',
160
164
  )
161
- .option('--public-deploy', 'Publicly deploy this account contract (only useful if it contains public functions')
165
+ .option(
166
+ '--public-deploy',
167
+ 'Publishes the account contract instance (and the class, if needed). Needed if the contract contains public functions.',
168
+ )
162
169
  .addOption(createVerboseOption());
163
170
 
164
171
  addOptions(deployAccountCommand, FeeOptsWithFeePayer.getOptions()).action(async (_options, command) => {
@@ -212,6 +219,12 @@ export function injectCommands(
212
219
  .option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction')
213
220
  .option('--no-class-registration', "Don't register this contract class")
214
221
  .option('--no-public-deployment', "Don't emit this contract's public bytecode")
222
+ .addOption(
223
+ new Option(
224
+ '--timeout <number>',
225
+ 'The amount of time in seconds to wait for the deployment to post to L2',
226
+ ).conflicts('wait'),
227
+ )
215
228
  .addOption(createVerboseOption());
216
229
 
217
230
  addOptions(deployCommand, FeeOpts.getOptions()).action(async (artifactPathPromise, _options, command) => {
@@ -231,6 +244,7 @@ export function injectCommands(
231
244
  rpcUrl,
232
245
  from: parsedFromAddress,
233
246
  alias,
247
+ timeout,
234
248
  verbose,
235
249
  } = options;
236
250
  const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
@@ -242,6 +256,7 @@ export function injectCommands(
242
256
 
243
257
  const address = await deploy(
244
258
  wallet,
259
+ universal ? undefined : wallet.getAddress(),
245
260
  artifactPath,
246
261
  json,
247
262
  publicKey,
@@ -251,9 +266,9 @@ export function injectCommands(
251
266
  !publicDeployment,
252
267
  !classRegistration,
253
268
  typeof init === 'string' ? false : init,
254
- universal,
255
269
  wait,
256
270
  await FeeOpts.fromCli(options, client, log, db),
271
+ timeout,
257
272
  verbose,
258
273
  debugLogger,
259
274
  log,
@@ -364,7 +379,8 @@ export function injectCommands(
364
379
 
365
380
  const client = (await pxeWrapper?.getPXE()) ?? (await createCompatibleClient(rpcUrl, debugLogger));
366
381
  const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
367
- const wallet = await account.getWallet();
382
+ const originalWallet = await account.getWallet();
383
+ const wallet = await CopyCatAccountWallet.create(client, originalWallet);
368
384
  const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
369
385
  const authWitnesses = cleanupAuthWitnesses(authWitness);
370
386
  await simulate(
@@ -560,7 +576,16 @@ export function injectCommands(
560
576
  const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
561
577
  const wallet = await account.getWallet();
562
578
  const artifactPath = await artifactPathFromPromiseOrAlias(artifactPathPromise, contractAddress, db);
563
- await authorizeAction(wallet, functionName, caller, args, artifactPath, contractAddress, log);
579
+ await authorizeAction(
580
+ wallet,
581
+ wallet.getAddress(),
582
+ functionName,
583
+ caller,
584
+ args,
585
+ artifactPath,
586
+ contractAddress,
587
+ log,
588
+ );
564
589
  });
565
590
 
566
591
  program
@@ -31,7 +31,7 @@ export async function profile(
31
31
  authWitnesses,
32
32
  skipProofGeneration: false,
33
33
  });
34
- printProfileResult(result.stats, log, result.executionSteps);
34
+ printProfileResult(result.stats, log, true, result.executionSteps);
35
35
  if (debugOutputPath) {
36
36
  const ivcInputsPath = path.join(debugOutputPath, 'ivc-inputs.msgpack');
37
37
  log(`Debug output written to ${ivcInputsPath}.`);
@@ -4,7 +4,7 @@ import {
4
4
  type AztecNode,
5
5
  type Fr,
6
6
  PublicKeys,
7
- getContractInstanceFromDeployParams,
7
+ getContractInstanceFromInstantiationParams,
8
8
  } from '@aztec/aztec.js';
9
9
  import { getContractArtifact } from '@aztec/cli/cli-utils';
10
10
  import type { LogFn } from '@aztec/foundation/log';
@@ -28,7 +28,7 @@ export async function registerContract(
28
28
  let contractInstance = await node.getContract(address);
29
29
  if (!contractInstance) {
30
30
  log(`Contract not found in the node at ${address}. Computing instance locally...`);
31
- contractInstance = await getContractInstanceFromDeployParams(contractArtifact, {
31
+ contractInstance = await getContractInstanceFromInstantiationParams(contractArtifact, {
32
32
  constructorArtifact,
33
33
  publicKeys: publicKeys ?? PublicKeys.default(),
34
34
  constructorArgs: rawArgs,
@@ -4,6 +4,7 @@ import type { LogFn } from '@aztec/foundation/log';
4
4
 
5
5
  import { format } from 'util';
6
6
 
7
+ import { printAuthorizations } from '../utils/authorizations.js';
7
8
  import type { IFeeOpts } from '../utils/options/fees.js';
8
9
  import { printProfileResult } from '../utils/profiling.js';
9
10
 
@@ -28,6 +29,21 @@ export async function simulate(
28
29
  includeMetadata: true,
29
30
  });
30
31
  if (verbose) {
32
+ await printAuthorizations(
33
+ simulationResult.offchainEffects!,
34
+ async (address: AztecAddress) => {
35
+ const metadata = await wallet.getContractMetadata(address);
36
+ if (!metadata.contractInstance) {
37
+ return undefined;
38
+ }
39
+ const classMetadata = await wallet.getContractClassMetadata(
40
+ metadata.contractInstance.currentContractClassId,
41
+ true,
42
+ );
43
+ return classMetadata.artifact;
44
+ },
45
+ log,
46
+ );
31
47
  printProfileResult(simulationResult.stats!, log);
32
48
  }
33
49
  log(format('\nSimulation result: ', simulationResult.result, '\n'));
@@ -0,0 +1,49 @@
1
+ import { type AztecAddress, CallAuthorizationRequest, type ContractArtifact } from '@aztec/aztec.js';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+ import { type AbiDecoded, decodeFromAbi, getFunctionArtifact } from '@aztec/stdlib/abi';
4
+ import type { OffchainEffect } from '@aztec/stdlib/tx';
5
+
6
+ import { format } from 'util';
7
+
8
+ export async function printAuthorizations(
9
+ offchainEffects: OffchainEffect[],
10
+ artifactRetriever: (address: AztecAddress) => Promise<ContractArtifact | undefined>,
11
+ log: LogFn,
12
+ ) {
13
+ log(format('\nAuthorizations requested by the tx:\n'));
14
+ const callAuthorizationSelector = await CallAuthorizationRequest.getSelector();
15
+ const callAuthorizationEffects = offchainEffects.filter(effect =>
16
+ effect.data[0].equals(callAuthorizationSelector.toField()),
17
+ );
18
+ for (const callAuthorizationEffect of callAuthorizationEffects) {
19
+ const callAuthorizationRequest = await CallAuthorizationRequest.fromFields(callAuthorizationEffect.data);
20
+ const artifact = await artifactRetriever(callAuthorizationEffect.contractAddress);
21
+ if (!artifact) {
22
+ log(format(' -', `Call authorization. Inner hash: ${callAuthorizationRequest.innerHash.toString()}\n`));
23
+ log(format(' ', `Contract: unknown@${callAuthorizationEffect.contractAddress}`));
24
+ log(
25
+ format(
26
+ ' ',
27
+ `${callAuthorizationRequest.functionSelector.toString()}(\n${callAuthorizationRequest.args.map(arg => ` ${arg.toString()}`).join(',\n')}\n )`,
28
+ ),
29
+ );
30
+ } else {
31
+ const functionAbi = await getFunctionArtifact(artifact, callAuthorizationRequest.functionSelector);
32
+ const callData = decodeFromAbi(
33
+ functionAbi.parameters.map(param => param.type),
34
+ callAuthorizationRequest.args,
35
+ ) as AbiDecoded[];
36
+ const parameters = functionAbi.parameters.map((param, i) => ({ name: param.name, value: callData[i] }));
37
+ log(format(' -', `Call authorization. Inner hash: ${callAuthorizationRequest.innerHash.toString()}`));
38
+ log(format(' ', `Contract: ${artifact.name}@${callAuthorizationEffect.contractAddress}`));
39
+ log(
40
+ format(
41
+ ' ',
42
+ /* eslint-disable-next-line @typescript-eslint/no-base-to-string */
43
+ `${functionAbi.name}(\n${parameters.map(p => ` ${p.name}: ${p.value}`).join(',\n')}\n )`,
44
+ ),
45
+ );
46
+ }
47
+ log(`\n`);
48
+ }
49
+ }
@@ -157,6 +157,7 @@ export class FeeOpts implements IFeeOpts {
157
157
 
158
158
  async toSendOpts(sender: AccountWallet): Promise<SendMethodOptions> {
159
159
  return {
160
+ from: sender.getAddress(),
160
161
  fee: {
161
162
  estimateGas: this.estimateGas,
162
163
  gasSettings: this.gasSettings,
@@ -4,7 +4,7 @@ import type { ProvingStats, ProvingTimings, SimulationStats, SimulationTimings }
4
4
 
5
5
  import { format } from 'util';
6
6
 
7
- const FN_NAME_PADDING = 50;
7
+ const FN_NAME_PADDING = 60;
8
8
  const COLUMN_MIN_WIDTH = 13;
9
9
  const COLUMN_MAX_WIDTH = 15;
10
10
 
@@ -13,6 +13,7 @@ const ORACLE_NAME_PADDING = 50;
13
13
  export function printProfileResult(
14
14
  stats: ProvingStats | SimulationStats,
15
15
  log: LogFn,
16
+ printOracles: boolean = false,
16
17
  executionSteps?: PrivateExecutionStep[],
17
18
  ) {
18
19
  log(format('\nPer circuit breakdown:\n'));
@@ -58,7 +59,7 @@ export function printProfileResult(
58
59
  currentExecutionStep ? acc.toLocaleString().padStart(COLUMN_MAX_WIDTH) : '',
59
60
  ),
60
61
  );
61
- if (fn.oracles) {
62
+ if (printOracles && fn.oracles) {
62
63
  log('');
63
64
  for (const [oracleName, { times }] of Object.entries(fn.oracles)) {
64
65
  const calls = times.length;