@aztec/cli-wallet 0.82.3 → 0.83.0

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/bin/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Fr, computeSecretHash, fileURLToPath } from '@aztec/aztec.js';
1
+ import { Fr, computeSecretHash, createCompatibleClient, fileURLToPath } from '@aztec/aztec.js';
2
2
  import { LOCALHOST } from '@aztec/cli/cli-utils';
3
3
  import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
4
4
  import { openStoreAt } from '@aztec/kv-store/lmdb-v2';
@@ -46,7 +46,7 @@ function injectInternalCommands(program, log, db) {
46
46
  const pxeWrapper = new PXEWrapper();
47
47
  const program = new Command('wallet');
48
48
  program.description('Aztec wallet').version(walletVersion).option('-d, --data-dir <string>', 'Storage directory for wallet data', WALLET_DATA_DIRECTORY).option('-p, --prover <string>', 'wasm|native|none', PXE_PROVER).addOption(new Option('--remote-pxe', 'Connect to an external PXE RPC server, instead of the local one').env('REMOTE_PXE').default(false).conflicts('rpc-url')).addOption(new Option('-n, --node-url <string>', 'URL of the Aztec node to connect to').env('AZTEC_NODE_URL').default(`http://${LOCALHOST}:8080`)).hook('preSubcommand', async (command)=>{
49
- const { dataDir, remotePxe, nodeUrl, prover } = command.optsWithGlobals();
49
+ const { dataDir, remotePxe, nodeUrl, prover, rpcUrl } = command.optsWithGlobals();
50
50
  if (!remotePxe) {
51
51
  debugLogger.info('Using local PXE service');
52
52
  const proverEnabled = prover !== 'none';
@@ -63,6 +63,20 @@ function injectInternalCommands(program, log, db) {
63
63
  await pxeWrapper.init(nodeUrl, join(dataDir, 'pxe'), overridePXEConfig);
64
64
  }
65
65
  await db.init(await openStoreAt(dataDir));
66
+ let protocolContractsRegistered;
67
+ try {
68
+ protocolContractsRegistered = !!await db.retrieveAlias('contracts:classRegisterer');
69
+ // eslint-disable-next-line no-empty
70
+ } catch {}
71
+ if (!protocolContractsRegistered) {
72
+ userLog('Registering protocol contract aliases...');
73
+ const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
74
+ const { protocolContractAddresses } = await client.getPXEInfo();
75
+ for (const [name, address] of Object.entries(protocolContractAddresses)){
76
+ await db.storeAlias('contracts', name, Buffer.from(address.toString()), userLog);
77
+ await db.storeAlias('artifacts', address.toString(), Buffer.from(`${name.slice(0, 1).toUpperCase()}${name.slice(1)}`), userLog);
78
+ }
79
+ }
66
80
  });
67
81
  injectCommands(program, userLog, debugLogger, db, pxeWrapper);
68
82
  injectInternalCommands(program, userLog, db);
@@ -1,6 +1,6 @@
1
- import { type AccountWalletWithSecretKey, Fr, type PXE } from '@aztec/aztec.js';
1
+ import { type AccountWalletWithSecretKey, 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(client: PXE, 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, debugLogger: Logger, log: LogFn, logJson: (output: any) => void): Promise<import("@aztec/aztec.js").AztecAddress | undefined>;
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, debugLogger: Logger, log: LogFn, logJson: (output: any) => void): Promise<import("@aztec/aztec.js").AztecAddress | undefined>;
6
6
  //# sourceMappingURL=deploy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":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BAA0B,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,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK,EACV,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,+DAkF/B"}
@@ -1,12 +1,13 @@
1
1
  import { ContractDeployer, Fr } from '@aztec/aztec.js';
2
2
  import { encodeArgs, getContractArtifact } from '@aztec/cli/utils';
3
- import { getInitializer } from '@aztec/stdlib/abi';
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
- export async function deploy(client, wallet, artifactPath, json, publicKeys, rawArgs, salt, initializer, skipPublicDeployment, skipClassRegistration, skipInitialization, universalDeploy, wait, feeOpts, debugLogger, log, logJson) {
6
+ export async function deploy(wallet, artifactPath, json, publicKeys, rawArgs, salt, initializer, skipPublicDeployment, skipClassRegistration, skipInitialization, universalDeploy, wait, feeOpts, debugLogger, log, logJson) {
7
7
  salt ??= Fr.random();
8
8
  const contractArtifact = await getContractArtifact(artifactPath, log);
9
- const constructorArtifact = getInitializer(contractArtifact, initializer);
9
+ const hasInitializer = getAllFunctionAbis(contractArtifact).some((fn)=>fn.isInitializer);
10
+ const constructorArtifact = hasInitializer ? getInitializer(contractArtifact, initializer) : undefined;
10
11
  // TODO(#12081): Add contractArtifact.noirVersion and check here (via Noir.lock)?
11
12
  const deployer = new ContractDeployer(contractArtifact, wallet, publicKeys ?? PublicKeys.default(), initializer);
12
13
  let args = [];
@@ -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;AAuBxD,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,WAmmBxB"}
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;AAuBxD,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,WAsoBxB"}
@@ -75,7 +75,7 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
75
75
  const wallet = await account.getWallet();
76
76
  const artifactPath = await artifactPathPromise;
77
77
  debugLogger.info(`Using wallet with address ${wallet.getCompleteAddress().address.toString()}`);
78
- const address = await deploy(client, 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), debugLogger, log, logJson(log));
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), debugLogger, log, logJson(log));
79
79
  if (db && address) {
80
80
  await db.storeContract(address, artifactPath, log, alias);
81
81
  }
@@ -210,15 +210,15 @@ export function injectCommands(program, log, debugLogger, db, pxeWrapper) {
210
210
  await db.storeSender(address, alias, log);
211
211
  }
212
212
  });
213
- program.command('register-contract').description("Registers a contract in this wallet's PXE").argument('[address]', 'The address of the contract to register', (address)=>aliasedAddressParser('accounts', address, db)).argument('[artifact]', ARTIFACT_DESCRIPTION, artifactPathParser).addOption(createArgsOption(true, db)).addOption(pxeOption).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createAliasOption('Alias for the contact. Used for easy reference in subsequent commands.', !db)).action(async (address, artifactPathPromise, _options, command)=>{
213
+ program.command('register-contract').description("Registers a contract in this wallet's PXE").argument('[address]', 'The address of the contract to register', (address)=>aliasedAddressParser('accounts', address, db)).argument('[artifact]', ARTIFACT_DESCRIPTION, artifactPathParser).option('--init <string>', 'The contract initializer function to call', 'constructor').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('--deployer <string>', 'The address of the account that deployed the contract', (address)=>aliasedAddressParser('accounts', address, db)).addOption(createArgsOption(true, db)).addOption(pxeOption).addOption(createAccountOption('Alias or address of the account to simulate from', !db, db)).addOption(createAliasOption('Alias for the contact. Used for easy reference in subsequent commands.', !db)).action(async (address, artifactPathPromise, _options, command)=>{
214
214
  const { registerContract } = await import('./register_contract.js');
215
- const { from: parsedFromAddress, rpcUrl, nodeUrl, secretKey, alias } = command.optsWithGlobals();
215
+ const { from: parsedFromAddress, rpcUrl, nodeUrl, secretKey, alias, init, publicKey, salt, deployer, args } = command.optsWithGlobals();
216
216
  const client = pxeWrapper?.getPXE() ?? await createCompatibleClient(rpcUrl, debugLogger);
217
217
  const node = pxeWrapper?.getNode() ?? createAztecNodeClient(nodeUrl);
218
218
  const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
219
219
  const wallet = await account.getWallet();
220
220
  const artifactPath = await artifactPathPromise;
221
- const instance = await registerContract(wallet, node, address, artifactPath, log);
221
+ const instance = await registerContract(wallet, node, address, artifactPath, log, init, publicKey, args, salt, deployer);
222
222
  if (db && alias) {
223
223
  await db.storeContract(instance.address, artifactPath, log, alias);
224
224
  }
@@ -1,4 +1,4 @@
1
- import type { AccountWalletWithSecretKey, AztecAddress, AztecNode } from '@aztec/aztec.js';
1
+ import { type AccountWalletWithSecretKey, type AztecAddress, type AztecNode, type Fr, PublicKeys } from '@aztec/aztec.js';
2
2
  import type { LogFn } from '@aztec/foundation/log';
3
- export declare function registerContract(wallet: AccountWalletWithSecretKey, node: AztecNode, address: AztecAddress, artifactPath: string, log: LogFn): Promise<import("@aztec/aztec.js").ContractInstanceWithAddress>;
3
+ export declare function registerContract(wallet: AccountWalletWithSecretKey, node: AztecNode, address: AztecAddress, artifactPath: string, log: LogFn, initializer?: string, publicKeys?: PublicKeys, rawArgs?: any[], salt?: Fr, deployer?: AztecAddress | undefined): Promise<import("@aztec/aztec.js").ContractInstanceWithAddress>;
4
4
  //# sourceMappingURL=register_contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"register_contract.d.ts","sourceRoot":"","sources":["../../src/cmds/register_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE3F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,0BAA0B,EAClC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,YAAY,EACrB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,KAAK,kEAUX"}
1
+ {"version":3,"file":"register_contract.d.ts","sourceRoot":"","sources":["../../src/cmds/register_contract.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,EAAE,EACP,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,0BAA0B,EAClC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,YAAY,EACrB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,KAAK,EACV,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,UAAU,EACvB,OAAO,CAAC,EAAE,GAAG,EAAE,EACf,IAAI,CAAC,EAAE,EAAE,EACT,QAAQ,CAAC,EAAE,YAAY,GAAG,SAAS,kEAsBpC"}
@@ -1,9 +1,23 @@
1
+ import { PublicKeys, getContractInstanceFromDeployParams } from '@aztec/aztec.js';
1
2
  import { getContractArtifact } from '@aztec/cli/cli-utils';
2
- export async function registerContract(wallet, node, address, artifactPath, log) {
3
+ import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
4
+ export async function registerContract(wallet, node, address, artifactPath, log, initializer, publicKeys, rawArgs, salt, deployer) {
3
5
  const contractArtifact = await getContractArtifact(artifactPath, log);
4
- const contractInstance = await node.getContract(address);
6
+ const hasInitializer = getAllFunctionAbis(contractArtifact).some((fn)=>fn.isInitializer);
7
+ const constructorArtifact = hasInitializer ? getInitializer(contractArtifact, initializer) : undefined;
8
+ let contractInstance = await node.getContract(address);
5
9
  if (!contractInstance) {
6
- throw new Error(`Contract not found at address: ${address}`);
10
+ log(`Contract not found in the node at ${address}. Computing instance locally...`);
11
+ contractInstance = await getContractInstanceFromDeployParams(contractArtifact, {
12
+ constructorArtifact,
13
+ publicKeys: publicKeys ?? PublicKeys.default(),
14
+ constructorArgs: rawArgs,
15
+ salt,
16
+ deployer
17
+ });
18
+ }
19
+ if (!contractInstance.address.equals(address)) {
20
+ throw new Error(`Contract address mismatch: expected ${address}, got ${contractInstance.address}`);
7
21
  }
8
22
  await wallet.registerContract({
9
23
  instance: contractInstance,
@@ -58,7 +58,7 @@ export declare class WalletDB {
58
58
  address: string | AztecAddress;
59
59
  secretKey: Fr;
60
60
  salt: Fr;
61
- type: "schnorr" | "ecdsasecp256r1ssh" | "ecdsasecp256k1";
61
+ type: "schnorr" | "ecdsasecp256r1" | "ecdsasecp256r1ssh" | "ecdsasecp256k1";
62
62
  }>;
63
63
  storeAlias(type: AliasType, key: string, value: Buffer, log: LogFn): Promise<void>;
64
64
  }
@@ -3,7 +3,7 @@ import { Fr } from '@aztec/foundation/fields';
3
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import type { PXE } from '@aztec/stdlib/interfaces/client';
5
5
  import type { WalletDB } from '../storage/wallet_db.js';
6
- export declare const AccountTypes: readonly ["schnorr", "ecdsasecp256r1ssh", "ecdsasecp256k1"];
6
+ export declare const AccountTypes: readonly ["schnorr", "ecdsasecp256r1", "ecdsasecp256r1ssh", "ecdsasecp256k1"];
7
7
  export type AccountType = (typeof AccountTypes)[number];
8
8
  export declare function createOrRetrieveAccount(pxe: PXE, address?: AztecAddress, db?: WalletDB, secretKey?: Fr, type?: AccountType, salt?: Fr, publicKey?: string | undefined): Promise<AccountManager>;
9
9
  //# sourceMappingURL=accounts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/utils/accounts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD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AuB,EAC7B,IAAI,CAAC,EAAE,EAAE,EACT,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAAC,cAAc,CAAC,CAuDzB"}
@@ -4,6 +4,7 @@ import { deriveSigningKey } from '@aztec/stdlib/keys';
4
4
  import { extractECDSAPublicKeyFromBase64String } from './ecdsa.js';
5
5
  export const AccountTypes = [
6
6
  'schnorr',
7
+ 'ecdsasecp256r1',
7
8
  'ecdsasecp256r1ssh',
8
9
  'ecdsasecp256k1'
9
10
  ];
@@ -26,6 +27,12 @@ export async function createOrRetrieveAccount(pxe, address, db, secretKey, type
26
27
  account = getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt);
27
28
  break;
28
29
  }
30
+ case 'ecdsasecp256r1':
31
+ {
32
+ const { getEcdsaRAccount } = await import('@aztec/accounts/ecdsa');
33
+ account = getEcdsaRAccount(pxe, secretKey, deriveSigningKey(secretKey).toBuffer(), salt);
34
+ break;
35
+ }
29
36
  case 'ecdsasecp256r1ssh':
30
37
  {
31
38
  let publicSigningKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/cli-wallet",
3
- "version": "0.82.3",
3
+ "version": "0.83.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/cmds/index.js",
@@ -65,17 +65,17 @@
65
65
  ]
66
66
  },
67
67
  "dependencies": {
68
- "@aztec/accounts": "0.82.3",
69
- "@aztec/aztec.js": "0.82.3",
70
- "@aztec/cli": "0.82.3",
71
- "@aztec/entrypoints": "0.82.3",
72
- "@aztec/ethereum": "0.82.3",
73
- "@aztec/foundation": "0.82.3",
74
- "@aztec/kv-store": "0.82.3",
75
- "@aztec/noir-contracts.js": "0.82.3",
76
- "@aztec/noir-noirc_abi": "0.82.3",
77
- "@aztec/pxe": "0.82.3",
78
- "@aztec/stdlib": "0.82.3",
68
+ "@aztec/accounts": "0.83.0",
69
+ "@aztec/aztec.js": "0.83.0",
70
+ "@aztec/cli": "0.83.0",
71
+ "@aztec/entrypoints": "0.83.0",
72
+ "@aztec/ethereum": "0.83.0",
73
+ "@aztec/foundation": "0.83.0",
74
+ "@aztec/kv-store": "0.83.0",
75
+ "@aztec/noir-contracts.js": "0.83.0",
76
+ "@aztec/noir-noirc_abi": "0.83.0",
77
+ "@aztec/pxe": "0.83.0",
78
+ "@aztec/stdlib": "0.83.0",
79
79
  "@msgpack/msgpack": "^3.0.0-beta2",
80
80
  "commander": "^12.1.0",
81
81
  "inquirer": "^10.1.8",
package/src/bin/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Fr, computeSecretHash, fileURLToPath } from '@aztec/aztec.js';
1
+ import { Fr, computeSecretHash, createCompatibleClient, fileURLToPath } from '@aztec/aztec.js';
2
2
  import { LOCALHOST } from '@aztec/cli/cli-utils';
3
3
  import { type LogFn, createConsoleLogger, createLogger } from '@aztec/foundation/log';
4
4
  import { openStoreAt } from '@aztec/kv-store/lmdb-v2';
@@ -90,7 +90,7 @@ async function main() {
90
90
  .default(`http://${LOCALHOST}:8080`),
91
91
  )
92
92
  .hook('preSubcommand', async command => {
93
- const { dataDir, remotePxe, nodeUrl, prover } = command.optsWithGlobals();
93
+ const { dataDir, remotePxe, nodeUrl, prover, rpcUrl } = command.optsWithGlobals();
94
94
 
95
95
  if (!remotePxe) {
96
96
  debugLogger.info('Using local PXE service');
@@ -113,6 +113,25 @@ async function main() {
113
113
  await pxeWrapper.init(nodeUrl, join(dataDir, 'pxe'), overridePXEConfig);
114
114
  }
115
115
  await db.init(await openStoreAt(dataDir));
116
+ let protocolContractsRegistered;
117
+ try {
118
+ protocolContractsRegistered = !!(await db.retrieveAlias('contracts:classRegisterer'));
119
+ // eslint-disable-next-line no-empty
120
+ } catch {}
121
+ if (!protocolContractsRegistered) {
122
+ userLog('Registering protocol contract aliases...');
123
+ const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
124
+ const { protocolContractAddresses } = await client.getPXEInfo();
125
+ for (const [name, address] of Object.entries(protocolContractAddresses)) {
126
+ await db.storeAlias('contracts', name, Buffer.from(address.toString()), userLog);
127
+ await db.storeAlias(
128
+ 'artifacts',
129
+ address.toString(),
130
+ Buffer.from(`${name.slice(0, 1).toUpperCase()}${name.slice(1)}`),
131
+ userLog,
132
+ );
133
+ }
134
+ }
116
135
  });
117
136
 
118
137
  injectCommands(program, userLog, debugLogger, db, pxeWrapper);
@@ -1,13 +1,12 @@
1
- import { type AccountWalletWithSecretKey, ContractDeployer, type DeployOptions, Fr, type PXE } from '@aztec/aztec.js';
1
+ import { type AccountWalletWithSecretKey, ContractDeployer, type DeployOptions, Fr } from '@aztec/aztec.js';
2
2
  import { encodeArgs, getContractArtifact } from '@aztec/cli/utils';
3
3
  import type { LogFn, Logger } from '@aztec/foundation/log';
4
- import { getInitializer } from '@aztec/stdlib/abi';
4
+ import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
5
5
  import { PublicKeys } from '@aztec/stdlib/keys';
6
6
 
7
7
  import { type IFeeOpts, printGasEstimates } from '../utils/options/fees.js';
8
8
 
9
9
  export async function deploy(
10
- client: PXE,
11
10
  wallet: AccountWalletWithSecretKey,
12
11
  artifactPath: string,
13
12
  json: boolean,
@@ -27,7 +26,8 @@ export async function deploy(
27
26
  ) {
28
27
  salt ??= Fr.random();
29
28
  const contractArtifact = await getContractArtifact(artifactPath, log);
30
- const constructorArtifact = getInitializer(contractArtifact, initializer);
29
+ const hasInitializer = getAllFunctionAbis(contractArtifact).some(fn => fn.isInitializer);
30
+ const constructorArtifact = hasInitializer ? getInitializer(contractArtifact, initializer) : undefined;
31
31
 
32
32
  // TODO(#12081): Add contractArtifact.noirVersion and check here (via Noir.lock)?
33
33
 
package/src/cmds/index.ts CHANGED
@@ -226,7 +226,6 @@ export function injectCommands(
226
226
  debugLogger.info(`Using wallet with address ${wallet.getCompleteAddress().address.toString()}`);
227
227
 
228
228
  const address = await deploy(
229
- client,
230
229
  wallet,
231
230
  artifactPath,
232
231
  json,
@@ -639,13 +638,38 @@ export function injectCommands(
639
638
  aliasedAddressParser('accounts', address, db),
640
639
  )
641
640
  .argument('[artifact]', ARTIFACT_DESCRIPTION, artifactPathParser)
641
+ .option('--init <string>', 'The contract initializer function to call', 'constructor')
642
+ .option(
643
+ '-k, --public-key <string>',
644
+ '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.',
645
+ parsePublicKey,
646
+ )
647
+ .option(
648
+ '-s, --salt <hex string>',
649
+ 'Optional deployment salt as a hex string for generating the deployment address.',
650
+ parseFieldFromHexString,
651
+ )
652
+ .option('--deployer <string>', 'The address of the account that deployed the contract', address =>
653
+ aliasedAddressParser('accounts', address, db),
654
+ )
642
655
  .addOption(createArgsOption(true, db))
643
656
  .addOption(pxeOption)
644
657
  .addOption(createAccountOption('Alias or address of the account to simulate from', !db, db))
645
658
  .addOption(createAliasOption('Alias for the contact. Used for easy reference in subsequent commands.', !db))
646
659
  .action(async (address, artifactPathPromise, _options, command) => {
647
660
  const { registerContract } = await import('./register_contract.js');
648
- const { from: parsedFromAddress, rpcUrl, nodeUrl, secretKey, alias } = command.optsWithGlobals();
661
+ const {
662
+ from: parsedFromAddress,
663
+ rpcUrl,
664
+ nodeUrl,
665
+ secretKey,
666
+ alias,
667
+ init,
668
+ publicKey,
669
+ salt,
670
+ deployer,
671
+ args,
672
+ } = command.optsWithGlobals();
649
673
  const client = pxeWrapper?.getPXE() ?? (await createCompatibleClient(rpcUrl, debugLogger));
650
674
  const node = pxeWrapper?.getNode() ?? createAztecNodeClient(nodeUrl);
651
675
  const account = await createOrRetrieveAccount(client, parsedFromAddress, db, secretKey);
@@ -653,7 +677,18 @@ export function injectCommands(
653
677
 
654
678
  const artifactPath = await artifactPathPromise;
655
679
 
656
- const instance = await registerContract(wallet, node, address, artifactPath, log);
680
+ const instance = await registerContract(
681
+ wallet,
682
+ node,
683
+ address,
684
+ artifactPath,
685
+ log,
686
+ init,
687
+ publicKey,
688
+ args,
689
+ salt,
690
+ deployer,
691
+ );
657
692
 
658
693
  if (db && alias) {
659
694
  await db.storeContract(instance.address, artifactPath, log, alias);
@@ -1,6 +1,14 @@
1
- import type { AccountWalletWithSecretKey, AztecAddress, AztecNode } from '@aztec/aztec.js';
1
+ import {
2
+ type AccountWalletWithSecretKey,
3
+ type AztecAddress,
4
+ type AztecNode,
5
+ type Fr,
6
+ PublicKeys,
7
+ getContractInstanceFromDeployParams,
8
+ } from '@aztec/aztec.js';
2
9
  import { getContractArtifact } from '@aztec/cli/cli-utils';
3
10
  import type { LogFn } from '@aztec/foundation/log';
11
+ import { getAllFunctionAbis, getInitializer } from '@aztec/stdlib/abi';
4
12
 
5
13
  export async function registerContract(
6
14
  wallet: AccountWalletWithSecretKey,
@@ -8,11 +16,28 @@ export async function registerContract(
8
16
  address: AztecAddress,
9
17
  artifactPath: string,
10
18
  log: LogFn,
19
+ initializer?: string,
20
+ publicKeys?: PublicKeys,
21
+ rawArgs?: any[],
22
+ salt?: Fr,
23
+ deployer?: AztecAddress | undefined,
11
24
  ) {
12
25
  const contractArtifact = await getContractArtifact(artifactPath, log);
13
- const contractInstance = await node.getContract(address);
26
+ const hasInitializer = getAllFunctionAbis(contractArtifact).some(fn => fn.isInitializer);
27
+ const constructorArtifact = hasInitializer ? getInitializer(contractArtifact, initializer) : undefined;
28
+ let contractInstance = await node.getContract(address);
14
29
  if (!contractInstance) {
15
- throw new Error(`Contract not found at address: ${address}`);
30
+ log(`Contract not found in the node at ${address}. Computing instance locally...`);
31
+ contractInstance = await getContractInstanceFromDeployParams(contractArtifact, {
32
+ constructorArtifact,
33
+ publicKeys: publicKeys ?? PublicKeys.default(),
34
+ constructorArgs: rawArgs,
35
+ salt,
36
+ deployer,
37
+ });
38
+ }
39
+ if (!contractInstance.address.equals(address)) {
40
+ throw new Error(`Contract address mismatch: expected ${address}, got ${contractInstance.address}`);
16
41
  }
17
42
  await wallet.registerContract({ instance: contractInstance, artifact: contractArtifact });
18
43
  log(`Contract registered: at ${contractInstance.address}`);
@@ -8,7 +8,7 @@ import { deriveSigningKey } from '@aztec/stdlib/keys';
8
8
  import type { WalletDB } from '../storage/wallet_db.js';
9
9
  import { extractECDSAPublicKeyFromBase64String } from './ecdsa.js';
10
10
 
11
- export const AccountTypes = ['schnorr', 'ecdsasecp256r1ssh', 'ecdsasecp256k1'] as const;
11
+ export const AccountTypes = ['schnorr', 'ecdsasecp256r1', 'ecdsasecp256r1ssh', 'ecdsasecp256k1'] as const;
12
12
  export type AccountType = (typeof AccountTypes)[number];
13
13
 
14
14
  export async function createOrRetrieveAccount(
@@ -42,6 +42,11 @@ export async function createOrRetrieveAccount(
42
42
  account = getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt);
43
43
  break;
44
44
  }
45
+ case 'ecdsasecp256r1': {
46
+ const { getEcdsaRAccount } = await import('@aztec/accounts/ecdsa');
47
+ account = getEcdsaRAccount(pxe, secretKey, deriveSigningKey(secretKey).toBuffer(), salt);
48
+ break;
49
+ }
45
50
  case 'ecdsasecp256r1ssh': {
46
51
  let publicSigningKey;
47
52
  if (db && address) {