@aztec-labs/cli-wallet 6.0.0-nightly.20260829
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/README.md +32 -0
- package/dest/bin/index.d.ts +3 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +96 -0
- package/dest/cmds/authorize_action.d.ts +5 -0
- package/dest/cmds/authorize_action.d.ts.map +1 -0
- package/dest/cmds/authorize_action.js +23 -0
- package/dest/cmds/bridge_fee_juice.d.ts +6 -0
- package/dest/cmds/bridge_fee_juice.d.ts.map +1 -0
- package/dest/cmds/bridge_fee_juice.js +54 -0
- package/dest/cmds/check_tx.d.ts +6 -0
- package/dest/cmds/check_tx.d.ts.map +1 -0
- package/dest/cmds/check_tx.js +181 -0
- package/dest/cmds/create_account.d.ts +17 -0
- package/dest/cmds/create_account.d.ts.map +1 -0
- package/dest/cmds/create_account.js +146 -0
- package/dest/cmds/create_authwit.d.ts +5 -0
- package/dest/cmds/create_authwit.d.ts.map +1 -0
- package/dest/cmds/create_authwit.js +16 -0
- package/dest/cmds/deploy.d.ts +10 -0
- package/dest/cmds/deploy.d.ts.map +1 -0
- package/dest/cmds/deploy.js +129 -0
- package/dest/cmds/deploy_account.d.ts +8 -0
- package/dest/cmds/deploy_account.d.ts.map +1 -0
- package/dest/cmds/deploy_account.js +111 -0
- package/dest/cmds/get_fee_juice_balance.d.ts +5 -0
- package/dest/cmds/get_fee_juice_balance.d.ts.map +1 -0
- package/dest/cmds/get_fee_juice_balance.js +27 -0
- package/dest/cmds/import_test_accounts.d.ts +5 -0
- package/dest/cmds/import_test_accounts.d.ts.map +1 -0
- package/dest/cmds/import_test_accounts.js +40 -0
- package/dest/cmds/index.d.ts +6 -0
- package/dest/cmds/index.d.ts.map +1 -0
- package/dest/cmds/index.js +208 -0
- package/dest/cmds/profile.d.ts +8 -0
- package/dest/cmds/profile.d.ts.map +1 -0
- package/dest/cmds/profile.js +28 -0
- package/dest/cmds/register_contract.d.ts +8 -0
- package/dest/cmds/register_contract.d.ts.map +1 -0
- package/dest/cmds/register_contract.js +27 -0
- package/dest/cmds/register_sender.d.ts +5 -0
- package/dest/cmds/register_sender.d.ts.map +1 -0
- package/dest/cmds/register_sender.js +4 -0
- package/dest/cmds/send.d.ts +11 -0
- package/dest/cmds/send.d.ts.map +1 -0
- package/dest/cmds/send.js +73 -0
- package/dest/cmds/simulate.d.ts +8 -0
- package/dest/cmds/simulate.d.ts.map +1 -0
- package/dest/cmds/simulate.js +33 -0
- package/dest/storage/wallet_db.d.ts +61 -0
- package/dest/storage/wallet_db.d.ts.map +1 -0
- package/dest/storage/wallet_db.js +231 -0
- package/dest/utils/authorizations.d.ts +6 -0
- package/dest/utils/authorizations.d.ts.map +1 -0
- package/dest/utils/authorizations.js +28 -0
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts +12 -0
- package/dest/utils/cli_wallet_and_node_wrapper.d.ts.map +1 -0
- package/dest/utils/cli_wallet_and_node_wrapper.js +25 -0
- package/dest/utils/constants.d.ts +4 -0
- package/dest/utils/constants.d.ts.map +1 -0
- package/dest/utils/constants.js +8 -0
- package/dest/utils/ecdsa.d.ts +2 -0
- package/dest/utils/ecdsa.d.ts.map +1 -0
- package/dest/utils/ecdsa.js +13 -0
- package/dest/utils/options/fees.d.ts +36 -0
- package/dest/utils/options/fees.d.ts.map +1 -0
- package/dest/utils/options/fees.js +250 -0
- package/dest/utils/options/index.d.ts +3 -0
- package/dest/utils/options/index.d.ts.map +1 -0
- package/dest/utils/options/index.js +2 -0
- package/dest/utils/options/options.d.ts +24 -0
- package/dest/utils/options/options.d.ts.map +1 -0
- package/dest/utils/options/options.js +134 -0
- package/dest/utils/profiling.d.ts +5 -0
- package/dest/utils/profiling.d.ts.map +1 -0
- package/dest/utils/profiling.js +68 -0
- package/dest/utils/wallet.d.ts +64 -0
- package/dest/utils/wallet.d.ts.map +1 -0
- package/dest/utils/wallet.js +285 -0
- package/dest/utils/well_known_contracts.d.ts +8 -0
- package/dest/utils/well_known_contracts.d.ts.map +1 -0
- package/dest/utils/well_known_contracts.js +38 -0
- package/package.json +108 -0
- package/src/bin/index.ts +141 -0
- package/src/cmds/authorize_action.ts +47 -0
- package/src/cmds/bridge_fee_juice.ts +92 -0
- package/src/cmds/check_tx.ts +220 -0
- package/src/cmds/create_account.ts +176 -0
- package/src/cmds/create_authwit.ts +39 -0
- package/src/cmds/deploy.ts +157 -0
- package/src/cmds/deploy_account.ts +140 -0
- package/src/cmds/get_fee_juice_balance.ts +37 -0
- package/src/cmds/import_test_accounts.ts +54 -0
- package/src/cmds/index.ts +732 -0
- package/src/cmds/profile.ts +47 -0
- package/src/cmds/register_contract.ts +43 -0
- package/src/cmds/register_sender.ts +8 -0
- package/src/cmds/send.ts +96 -0
- package/src/cmds/simulate.ts +55 -0
- package/src/storage/wallet_db.ts +264 -0
- package/src/utils/authorizations.ts +50 -0
- package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
- package/src/utils/constants.ts +10 -0
- package/src/utils/ecdsa.ts +15 -0
- package/src/utils/options/fees.ts +325 -0
- package/src/utils/options/index.ts +2 -0
- package/src/utils/options/options.ts +196 -0
- package/src/utils/profiling.ts +171 -0
- package/src/utils/wallet.ts +377 -0
- package/src/utils/well_known_contracts.ts +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Aztec wallet Documentation
|
|
2
|
+
|
|
3
|
+
### Run tests locally
|
|
4
|
+
|
|
5
|
+
1) Start a local Ethereum node (Anvil) in one terminal:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
anvil --host 127.0.0.1 --port 8545
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
2) In another terminal, start the Aztec local network from `yarn-project/aztec`:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
cd yarn-project/aztec
|
|
15
|
+
NODE_NO_WARNINGS=1 ETHEREUM_HOSTS=http://127.0.0.1:8545 node ./dest/bin/index.js start --local-network
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
3) Run the wallet tests from `yarn-project/cli-wallet/test`:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
cd yarn-project/cli-wallet/test
|
|
22
|
+
./test.sh --filter <partialnameoftest>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Notes:
|
|
26
|
+
- **Filter tests**: Omit `--filter` to run all tests, or pass part of a test filename to run a subset.
|
|
27
|
+
- **Docker mode**: You can run tests using Docker by adding `--docker`:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
./test.sh --docker --filter <partialnameoftest>
|
|
31
|
+
```
|
|
32
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { BackendType, Barretenberg } from '@aztec/bb.js';
|
|
3
|
+
import { computeSecretHash } from '@aztec-labs/aztec.js/crypto';
|
|
4
|
+
import { Fr } from '@aztec-labs/aztec.js/fields';
|
|
5
|
+
import { createAztecNodeClient } from '@aztec-labs/aztec.js/node';
|
|
6
|
+
import { LOCALHOST } from '@aztec-labs/cli/cli-utils';
|
|
7
|
+
import { createConsoleLogger, createLogger } from '@aztec-labs/foundation/log';
|
|
8
|
+
import { openStoreAt } from '@aztec-labs/kv-store/lmdb-v2';
|
|
9
|
+
import { getPackageVersion } from '@aztec-labs/stdlib/update-checker';
|
|
10
|
+
import { Argument, Command, Option } from 'commander';
|
|
11
|
+
import { homedir } from 'os';
|
|
12
|
+
import { join } from 'path';
|
|
13
|
+
import { injectCommands } from '../cmds/index.js';
|
|
14
|
+
import { Aliases, WalletDB } from '../storage/wallet_db.js';
|
|
15
|
+
import { CliWalletAndNodeWrapper } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
16
|
+
import { createAliasOption } from '../utils/options/index.js';
|
|
17
|
+
import { CLIWallet } from '../utils/wallet.js';
|
|
18
|
+
import { registerWellKnownContractAliases } from '../utils/well_known_contracts.js';
|
|
19
|
+
const userLog = createConsoleLogger();
|
|
20
|
+
const debugLogger = createLogger('wallet');
|
|
21
|
+
const { WALLET_DATA_DIRECTORY = join(homedir(), '.aztec/wallet') } = process.env;
|
|
22
|
+
// TODO: This function is only used in 1 place so we could just inline this
|
|
23
|
+
function injectInternalCommands(program, log, db) {
|
|
24
|
+
program.command('alias').description('Aliases information for easy reference.').addArgument(new Argument('<type>', 'Type of alias to create').choices(Aliases)).argument('<key>', 'Key to alias.').argument('<value>', 'Value to assign to the alias.').action(async (type, key, value)=>{
|
|
25
|
+
value = db.tryRetrieveAlias(value) || value;
|
|
26
|
+
await db.storeAlias(type, key, value, log);
|
|
27
|
+
});
|
|
28
|
+
program.command('get-alias').description('Shows stored aliases').addArgument(new Argument('[alias]', 'Alias to retrieve')).action(async (alias)=>{
|
|
29
|
+
if (alias?.includes(':')) {
|
|
30
|
+
const value = await db.retrieveAlias(alias);
|
|
31
|
+
log(value);
|
|
32
|
+
} else {
|
|
33
|
+
const aliases = await db.listAliases(alias);
|
|
34
|
+
for (const { key, value } of aliases){
|
|
35
|
+
log(`${key} -> ${value}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
program.command('create-secret').description('Creates an aliased secret to use in other commands').addOption(createAliasOption('Key to alias the secret with', false).makeOptionMandatory(true)).action(async (_options, command)=>{
|
|
40
|
+
const options = command.optsWithGlobals();
|
|
41
|
+
const { alias } = options;
|
|
42
|
+
const value = Fr.random();
|
|
43
|
+
const hash = await computeSecretHash(value);
|
|
44
|
+
await db.storeAlias('secrets', alias, Buffer.from(value.toString()), log);
|
|
45
|
+
await db.storeAlias('secrets', `${alias}:hash`, Buffer.from(hash.toString()), log);
|
|
46
|
+
});
|
|
47
|
+
return program;
|
|
48
|
+
}
|
|
49
|
+
/** CLI wallet main entrypoint */ async function main() {
|
|
50
|
+
const walletVersion = getPackageVersion();
|
|
51
|
+
const db = WalletDB.getInstance();
|
|
52
|
+
const walletAndNodeWrapper = new CliWalletAndNodeWrapper();
|
|
53
|
+
const program = new Command('wallet');
|
|
54
|
+
program.description('Aztec wallet').version(walletVersion).option('-d, --data-dir <string>', 'Storage directory for wallet data', WALLET_DATA_DIRECTORY).addOption(new Option('-p, --prover <string>', 'The type of prover the wallet uses').choices([
|
|
55
|
+
'wasm',
|
|
56
|
+
'native',
|
|
57
|
+
'none'
|
|
58
|
+
]).env('PXE_PROVER').default('native')).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)=>{
|
|
59
|
+
// Skip initialization if user is just requesting help
|
|
60
|
+
if (command.args.includes('--help') || command.args.includes('-h')) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const { dataDir, nodeUrl, prover } = command.optsWithGlobals();
|
|
64
|
+
const proverEnabled = prover !== 'none';
|
|
65
|
+
switch(prover){
|
|
66
|
+
case 'native':
|
|
67
|
+
await Barretenberg.initSingleton({
|
|
68
|
+
backend: BackendType.NativeUnixSocket
|
|
69
|
+
});
|
|
70
|
+
break;
|
|
71
|
+
case 'wasm':
|
|
72
|
+
await Barretenberg.initSingleton({
|
|
73
|
+
backend: BackendType.Wasm
|
|
74
|
+
});
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
const overridePXEConfig = {
|
|
78
|
+
proverEnabled,
|
|
79
|
+
dataDirectory: join(dataDir, 'pxe')
|
|
80
|
+
};
|
|
81
|
+
const node = createAztecNodeClient(nodeUrl);
|
|
82
|
+
const wallet = await CLIWallet.create(node, userLog, db, overridePXEConfig);
|
|
83
|
+
walletAndNodeWrapper.setNodeAndWallet(node, wallet);
|
|
84
|
+
await db.init(await openStoreAt(dataDir));
|
|
85
|
+
await registerWellKnownContractAliases(db, userLog);
|
|
86
|
+
});
|
|
87
|
+
injectCommands(program, userLog, debugLogger, walletAndNodeWrapper, db);
|
|
88
|
+
injectInternalCommands(program, userLog, db);
|
|
89
|
+
await program.parseAsync(process.argv);
|
|
90
|
+
await Barretenberg.destroySingleton();
|
|
91
|
+
}
|
|
92
|
+
main().catch((err)=>{
|
|
93
|
+
debugLogger.error(`Error in command execution`);
|
|
94
|
+
debugLogger.error(err + '\n' + err.stack);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec-labs/aztec.js/addresses';
|
|
2
|
+
import type { Wallet } from '@aztec-labs/aztec.js/wallet';
|
|
3
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
4
|
+
export declare function authorizeAction(wallet: Wallet, from: AztecAddress, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("@aztec-labs/aztec.js/contracts").TxSendResultMined<import("@aztec-labs/stdlib/tx").TxReceipt>>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aG9yaXplX2FjdGlvbi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvYXV0aG9yaXplX2FjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUduRSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUUxRCxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUl4RCx3QkFBc0IsZUFBZSxDQUNuQyxNQUFNLEVBQUUsTUFBTSxFQUNkLElBQUksRUFBRSxZQUFZLEVBQ2xCLFlBQVksRUFBRSxNQUFNLEVBQ3BCLE1BQU0sRUFBRSxZQUFZLEVBQ3BCLGNBQWMsRUFBRSxHQUFHLEVBQUUsRUFDckIsb0JBQW9CLEVBQUUsTUFBTSxFQUM1QixlQUFlLEVBQUUsWUFBWSxFQUM3QixHQUFHLEVBQUUsS0FBSyxrSEE2QlgifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize_action.d.ts","sourceRoot":"","sources":["../../src/cmds/authorize_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAIxD,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,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,kHA6BX"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SetPublicAuthwitContractInteraction } from '@aztec-labs/aztec.js/authorization';
|
|
2
|
+
import { Contract } from '@aztec-labs/aztec.js/contracts';
|
|
3
|
+
import { prepTx } from '@aztec-labs/cli/utils';
|
|
4
|
+
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
5
|
+
export async function authorizeAction(wallet, from, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
|
|
6
|
+
const { functionArgs, contractArtifact, isPrivate } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
7
|
+
if (isPrivate) {
|
|
8
|
+
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');
|
|
9
|
+
}
|
|
10
|
+
const contract = Contract.at(contractAddress, contractArtifact, wallet);
|
|
11
|
+
const action = contract.methods[functionName](...functionArgs);
|
|
12
|
+
const setAuthwitnessInteraction = await SetPublicAuthwitContractInteraction.create(wallet, from, {
|
|
13
|
+
caller,
|
|
14
|
+
action
|
|
15
|
+
}, true);
|
|
16
|
+
const witness = await setAuthwitnessInteraction.send({
|
|
17
|
+
wait: {
|
|
18
|
+
timeout: DEFAULT_TX_TIMEOUT_S
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
log(`Authorized action ${functionName} on contract ${contractAddress} for caller ${caller}`);
|
|
22
|
+
return witness;
|
|
23
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AztecNode } from '@aztec-labs/aztec.js/node';
|
|
2
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
3
|
+
import type { LogFn, Logger } from '@aztec-labs/foundation/log';
|
|
4
|
+
import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
5
|
+
export declare function bridgeL1FeeJuice(amount: bigint, recipient: AztecAddress, node: AztecNode, l1RpcUrls: string[], chainId: number, privateKey: string | undefined, mnemonic: string, mint: boolean, json: boolean, wait: boolean, interval: number | undefined, log: LogFn, debugLogger: Logger): Promise<readonly [Fr, bigint]>;
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJpZGdlX2ZlZV9qdWljZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvYnJpZGdlX2ZlZV9qdWljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUszRCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0scUNBQXFDLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLGtDQUFrQyxDQUFDO0FBR3JFLHdCQUFzQixnQkFBZ0IsQ0FDcEMsTUFBTSxFQUFFLE1BQU0sRUFDZCxTQUFTLEVBQUUsWUFBWSxFQUN2QixJQUFJLEVBQUUsU0FBUyxFQUNmLFNBQVMsRUFBRSxNQUFNLEVBQUUsRUFDbkIsT0FBTyxFQUFFLE1BQU0sRUFDZixVQUFVLEVBQUUsTUFBTSxHQUFHLFNBQVMsRUFDOUIsUUFBUSxFQUFFLE1BQU0sRUFDaEIsSUFBSSxFQUFFLE9BQU8sRUFDYixJQUFJLEVBQUUsT0FBTyxFQUNiLElBQUksRUFBRSxPQUFPLEVBQ2IsUUFBUSxvQkFBUyxFQUNqQixHQUFHLEVBQUUsS0FBSyxFQUNWLFdBQVcsRUFBRSxNQUFNLGtDQW1FcEIifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge_fee_juice.d.ts","sourceRoot":"","sources":["../../src/cmds/bridge_fee_juice.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAK3D,OAAO,EAAE,EAAE,EAAE,MAAM,qCAAqC,CAAC;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAGrE,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY,EACvB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,EAAE,EACnB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,OAAO,EACb,QAAQ,oBAAS,EACjB,GAAG,EAAE,KAAK,EACV,WAAW,EAAE,MAAM,kCAmEpB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { L1FeeJuicePortalManager } from '@aztec-labs/aztec.js/ethereum';
|
|
2
|
+
import { ProtocolContractAddress } from '@aztec-labs/aztec.js/protocol';
|
|
3
|
+
import { prettyPrintJSON } from '@aztec-labs/cli/utils';
|
|
4
|
+
import { createEthereumChain } from '@aztec-labs/ethereum/chain';
|
|
5
|
+
import { createExtendedL1Client } from '@aztec-labs/ethereum/client';
|
|
6
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
7
|
+
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec-labs/stdlib/messaging';
|
|
8
|
+
export async function bridgeL1FeeJuice(amount, recipient, node, l1RpcUrls, chainId, privateKey, mnemonic, mint, json, wait, interval = 60_000, log, debugLogger) {
|
|
9
|
+
// Prepare L1 client
|
|
10
|
+
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
11
|
+
const client = createExtendedL1Client(chain.rpcUrls, privateKey ?? mnemonic, chain.chainInfo);
|
|
12
|
+
// Setup portal manager
|
|
13
|
+
const portal = await L1FeeJuicePortalManager.new(node, client, debugLogger);
|
|
14
|
+
const { claimAmount, claimSecret, messageHash, messageLeafIndex } = await portal.bridgeTokensPublic(recipient, amount, mint);
|
|
15
|
+
if (json) {
|
|
16
|
+
const out = {
|
|
17
|
+
claimAmount,
|
|
18
|
+
claimSecret,
|
|
19
|
+
messageLeafIndex
|
|
20
|
+
};
|
|
21
|
+
log(prettyPrintJSON(out));
|
|
22
|
+
} else {
|
|
23
|
+
if (mint) {
|
|
24
|
+
log(`Minted ${claimAmount} fee juice on L1 and pushed to L2 portal`);
|
|
25
|
+
} else {
|
|
26
|
+
log(`Bridged ${claimAmount} fee juice to L2 portal`);
|
|
27
|
+
}
|
|
28
|
+
log(`claimAmount=${claimAmount},claimSecret=${claimSecret},messageHash=${messageHash},messageLeafIndex=${messageLeafIndex}\n`);
|
|
29
|
+
log(`Note: You need to wait for two L2 blocks before pulling them from the L2 side`);
|
|
30
|
+
if (wait) {
|
|
31
|
+
log(`This command will now continually poll every ${interval / 1000}s for the inclusion of the newly created L1 to L2 message`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (wait) {
|
|
35
|
+
const delayedCheck = (delay)=>{
|
|
36
|
+
return new Promise((resolve, reject)=>{
|
|
37
|
+
setTimeout(()=>{
|
|
38
|
+
void getNonNullifiedL1ToL2MessageWitness(node, ProtocolContractAddress.FeeJuice, Fr.fromHexString(messageHash), claimSecret).then((witness)=>resolve(witness)).catch((err)=>reject(err));
|
|
39
|
+
}, delay);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
let witness;
|
|
43
|
+
while(!witness){
|
|
44
|
+
witness = await delayedCheck(interval);
|
|
45
|
+
if (!witness) {
|
|
46
|
+
log(`No L1 to L2 message found yet, checking again in ${interval / 1000}s`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return [
|
|
51
|
+
claimSecret,
|
|
52
|
+
messageLeafIndex
|
|
53
|
+
];
|
|
54
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AztecNode } from '@aztec-labs/aztec.js/node';
|
|
2
|
+
import type { TxHash } from '@aztec-labs/aztec.js/tx';
|
|
3
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
4
|
+
import type { CLIWallet } from '../utils/wallet.js';
|
|
5
|
+
export declare function checkTx(wallet: CLIWallet, aztecNode: AztecNode, txHash: TxHash, statusOnly: boolean, log: LogFn): Promise<import("@aztec-labs/aztec.js/tx").TxStatus | undefined>;
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2tfdHguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2NoZWNrX3R4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRTNELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3RELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBUXhELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixPQUFPLENBQzNCLE1BQU0sRUFBRSxTQUFTLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLE1BQU0sRUFBRSxNQUFNLEVBQ2QsVUFBVSxFQUFFLE9BQU8sRUFDbkIsR0FBRyxFQUFFLEtBQUssbUVBUVgifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check_tx.d.ts","sourceRoot":"","sources":["../../src/cmds/check_tx.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAQxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,OAAO,CAC3B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,OAAO,EACnB,GAAG,EAAE,KAAK,mEAQX"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { ProtocolContractAddress } from '@aztec-labs/aztec.js/protocol';
|
|
2
|
+
import { computeSiloedPrivateInitializationNullifier, computeSiloedPublicInitializationNullifier, siloNullifier } from '@aztec-labs/stdlib/hash';
|
|
3
|
+
export async function checkTx(wallet, aztecNode, txHash, statusOnly, log) {
|
|
4
|
+
if (statusOnly) {
|
|
5
|
+
const receipt = await aztecNode.getTxReceipt(txHash);
|
|
6
|
+
return receipt.status;
|
|
7
|
+
} else {
|
|
8
|
+
await inspectTx(wallet, aztecNode, txHash, log);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
// The rest of the code here was copied over here from CLI because in CLI I needed to prune the inspect function of the PXE
|
|
12
|
+
// dependency when dropping PXE JSON RPC Server.
|
|
13
|
+
async function inspectTx(wallet, aztecNode, txHash, log) {
|
|
14
|
+
const receipt = await aztecNode.getTxReceipt(txHash, {
|
|
15
|
+
includeTxEffect: true
|
|
16
|
+
});
|
|
17
|
+
// Base tx data
|
|
18
|
+
log(`Tx ${txHash.toString()}`);
|
|
19
|
+
log(` Status: ${receipt.status}`);
|
|
20
|
+
if (receipt.executionResult) {
|
|
21
|
+
log(` Execution result: ${receipt.executionResult}`);
|
|
22
|
+
}
|
|
23
|
+
if (receipt.error) {
|
|
24
|
+
log(` Error: ${receipt.error}`);
|
|
25
|
+
}
|
|
26
|
+
if (!receipt.isMined() || !receipt.txEffect) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const effects = receipt.txEffect;
|
|
30
|
+
const artifactMap = await getKnownArtifacts(wallet);
|
|
31
|
+
log(` Block: ${receipt.blockNumber} (${receipt.blockHash?.toString()})`);
|
|
32
|
+
if (receipt.transactionFee) {
|
|
33
|
+
log(` Fee: ${receipt.transactionFee.toString()}`);
|
|
34
|
+
}
|
|
35
|
+
// Public logs
|
|
36
|
+
const publicLogs = effects.publicLogs;
|
|
37
|
+
if (publicLogs.length > 0) {
|
|
38
|
+
log(' Logs:');
|
|
39
|
+
for (const publicLog of publicLogs){
|
|
40
|
+
log(` ${publicLog.toHumanReadable()}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Public data writes
|
|
44
|
+
const writes = effects.publicDataWrites;
|
|
45
|
+
if (writes.length > 0) {
|
|
46
|
+
log(' Public data writes:');
|
|
47
|
+
for (const write of writes){
|
|
48
|
+
log(` Leaf ${write.leafSlot.toString()} = ${write.value.toString()}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Created notes
|
|
52
|
+
const notes = effects.noteHashes;
|
|
53
|
+
if (notes.length > 0) {
|
|
54
|
+
log(' Created notes:');
|
|
55
|
+
log(` Total: ${notes.length}`);
|
|
56
|
+
for (const note of notes){
|
|
57
|
+
log(` Note hash: ${note.toShortString()}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Nullifiers
|
|
61
|
+
const nullifierCount = effects.nullifiers.length;
|
|
62
|
+
const { deployNullifiers, initNullifiers, classNullifiers } = await getKnownNullifiers(wallet, artifactMap);
|
|
63
|
+
const accounts = (await wallet.getAccounts()).map((a)=>a.item);
|
|
64
|
+
if (nullifierCount > 0) {
|
|
65
|
+
log(' Nullifiers:');
|
|
66
|
+
for (const nullifier of effects.nullifiers){
|
|
67
|
+
const deployed = deployNullifiers[nullifier.toString()];
|
|
68
|
+
const note = deployed ? (await wallet.getNotes({
|
|
69
|
+
siloedNullifier: nullifier,
|
|
70
|
+
contractAddress: deployed,
|
|
71
|
+
scopes: accounts
|
|
72
|
+
}))[0] : undefined;
|
|
73
|
+
const initialized = initNullifiers[nullifier.toString()];
|
|
74
|
+
const registered = classNullifiers[nullifier.toString()];
|
|
75
|
+
if (nullifier.toBuffer().equals(txHash.toBuffer())) {
|
|
76
|
+
log(` Transaction hash nullifier ${nullifier.toShortString()}`);
|
|
77
|
+
} else if (note) {
|
|
78
|
+
inspectNote(note, artifactMap, log, `Nullifier ${nullifier.toShortString()} for note`);
|
|
79
|
+
} else if (deployed) {
|
|
80
|
+
log(` Contract ${toFriendlyAddress(deployed, artifactMap)} deployed via nullifier ${nullifier.toShortString()}`);
|
|
81
|
+
} else if (initialized) {
|
|
82
|
+
log(` Contract ${toFriendlyAddress(initialized, artifactMap)} initialized via nullifier ${nullifier.toShortString()}`);
|
|
83
|
+
} else if (registered) {
|
|
84
|
+
log(` Class ${registered} registered via nullifier ${nullifier.toShortString()}`);
|
|
85
|
+
} else {
|
|
86
|
+
log(` Unknown nullifier ${nullifier.toString()}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// L2 to L1 messages
|
|
91
|
+
if (effects.l2ToL1Msgs.length > 0) {
|
|
92
|
+
log(` L2 to L1 messages:`);
|
|
93
|
+
for (const msg of effects.l2ToL1Msgs){
|
|
94
|
+
log(` ${msg.toString()}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function inspectNote(note, artifactMap, log, text = 'Note') {
|
|
99
|
+
const artifact = artifactMap[note.contractAddress.toString()];
|
|
100
|
+
const contract = artifact?.name ?? note.contractAddress.toString();
|
|
101
|
+
log(` ${text} at ${contract}`);
|
|
102
|
+
for (const field of note.note.items){
|
|
103
|
+
log(` ${field.toString()}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function toFriendlyAddress(address, artifactMap) {
|
|
107
|
+
const artifact = artifactMap[address.toString()];
|
|
108
|
+
if (!artifact) {
|
|
109
|
+
return address.toString();
|
|
110
|
+
}
|
|
111
|
+
return `${artifact.name}<${address.toString()}>`;
|
|
112
|
+
}
|
|
113
|
+
async function getKnownNullifiers(wallet, artifactMap) {
|
|
114
|
+
const knownContracts = await wallet.getContracts();
|
|
115
|
+
const [contractResults, classResults] = await Promise.all([
|
|
116
|
+
Promise.all(knownContracts.map((contract)=>getContractNullifiers(wallet, contract))),
|
|
117
|
+
Promise.all(Object.values(artifactMap).map((artifact)=>getClassNullifier(artifact)))
|
|
118
|
+
]);
|
|
119
|
+
const initNullifiers = {};
|
|
120
|
+
const deployNullifiers = {};
|
|
121
|
+
const classNullifiers = {};
|
|
122
|
+
for (const { contract, deployNullifier, privateInitNullifier, publicInitNullifier } of contractResults){
|
|
123
|
+
deployNullifiers[deployNullifier.toString()] = contract;
|
|
124
|
+
if (privateInitNullifier) {
|
|
125
|
+
initNullifiers[privateInitNullifier.toString()] = contract;
|
|
126
|
+
}
|
|
127
|
+
initNullifiers[publicInitNullifier.toString()] = contract;
|
|
128
|
+
}
|
|
129
|
+
for (const { nullifier, label } of classResults){
|
|
130
|
+
classNullifiers[nullifier.toString()] = label;
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
initNullifiers,
|
|
134
|
+
deployNullifiers,
|
|
135
|
+
classNullifiers
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async function getContractNullifiers(wallet, contract) {
|
|
139
|
+
const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
|
|
140
|
+
const deployNullifier = await siloNullifier(deployerAddress, contract.toField());
|
|
141
|
+
const metadata = await wallet.getContractMetadata(contract);
|
|
142
|
+
const privateInitNullifier = metadata.instance ? await computeSiloedPrivateInitializationNullifier(contract, metadata.instance.initializationHash) : undefined;
|
|
143
|
+
const publicInitNullifier = await computeSiloedPublicInitializationNullifier(contract);
|
|
144
|
+
return {
|
|
145
|
+
contract,
|
|
146
|
+
deployNullifier,
|
|
147
|
+
privateInitNullifier,
|
|
148
|
+
publicInitNullifier
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async function getClassNullifier(artifact) {
|
|
152
|
+
const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
|
|
153
|
+
const nullifier = await siloNullifier(classRegistryAddress, artifact.classId);
|
|
154
|
+
return {
|
|
155
|
+
nullifier,
|
|
156
|
+
label: `${artifact.name}Class<${artifact.classId}>`
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
async function getKnownArtifacts(wallet) {
|
|
160
|
+
const knownContractAddresses = await wallet.getContracts();
|
|
161
|
+
const knownContracts = await Promise.all(knownContractAddresses.map((contractAddress)=>wallet.getContractMetadata(contractAddress)));
|
|
162
|
+
const classIdFor = (metadata)=>metadata.updatedContractClassId ?? metadata.instance?.originalContractClassId;
|
|
163
|
+
const classIds = [
|
|
164
|
+
...new Set(knownContracts.map(classIdFor))
|
|
165
|
+
];
|
|
166
|
+
const knownArtifacts = (await Promise.all(classIds.map((classId)=>classId ? wallet.getContractArtifact(classId) : undefined))).map((artifact, index)=>artifact ? {
|
|
167
|
+
...artifact,
|
|
168
|
+
classId: classIds[index]
|
|
169
|
+
} : undefined);
|
|
170
|
+
const map = {};
|
|
171
|
+
for (const metadata of knownContracts){
|
|
172
|
+
const classId = classIdFor(metadata);
|
|
173
|
+
if (metadata.instance && classId) {
|
|
174
|
+
const artifact = knownArtifacts.find((a)=>a?.classId?.equals(classId));
|
|
175
|
+
if (artifact) {
|
|
176
|
+
map[metadata.instance.address.toString()] = artifact;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return map;
|
|
181
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AztecAddress } from '@aztec-labs/aztec.js/addresses';
|
|
2
|
+
import { type AztecNode } from '@aztec-labs/aztec.js/node';
|
|
3
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
4
|
+
import { GrumpkinScalar } from '@aztec-labs/foundation/curves/grumpkin';
|
|
5
|
+
import type { LogFn, Logger } from '@aztec-labs/foundation/log';
|
|
6
|
+
import { TxStatus } from '@aztec-labs/stdlib/tx';
|
|
7
|
+
import type { AccountType } from '../utils/constants.js';
|
|
8
|
+
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
9
|
+
import { CLIWallet } from '../utils/wallet.js';
|
|
10
|
+
export declare function createAccount(wallet: CLIWallet, aztecNode: AztecNode, accountType: AccountType, signingKey: GrumpkinScalar | undefined, salt: Fr | undefined, publicKey: string | undefined, alias: string | undefined, deployer: AztecAddress | undefined, registerOnly: boolean, skipInitialization: boolean, publicDeploy: boolean, registerClass: boolean, wait: boolean, feeOpts: CLIFeeArgs, waitForStatus: TxStatus, json: boolean, verbose: boolean, debugLogger: Logger, log: LogFn): Promise<{
|
|
11
|
+
alias: string | undefined;
|
|
12
|
+
address: AztecAddress;
|
|
13
|
+
signingKey: import("@aztec-labs/foundation/curves/bn254").Fq | undefined;
|
|
14
|
+
secretKey: Fr;
|
|
15
|
+
salt: Fr;
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2FjY291bnQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2NyZWF0ZV9hY2NvdW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUU5RCxPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQWEsTUFBTSwyQkFBMkIsQ0FBQztBQUd0RSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0scUNBQXFDLENBQUM7QUFDekQsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLHdDQUF3QyxDQUFDO0FBQ3hFLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUNoRSxPQUFPLEVBQStCLFFBQVEsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRzlFLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ3pELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUV0RCxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFL0Msd0JBQXNCLGFBQWEsQ0FDakMsTUFBTSxFQUFFLFNBQVMsRUFDakIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsV0FBVyxFQUFFLFdBQVcsRUFDeEIsVUFBVSxFQUFFLGNBQWMsR0FBRyxTQUFTLEVBQ3RDLElBQUksRUFBRSxFQUFFLEdBQUcsU0FBUyxFQUNwQixTQUFTLEVBQUUsTUFBTSxHQUFHLFNBQVMsRUFDN0IsS0FBSyxFQUFFLE1BQU0sR0FBRyxTQUFTLEVBQ3pCLFFBQVEsRUFBRSxZQUFZLEdBQUcsU0FBUyxFQUNsQyxZQUFZLEVBQUUsT0FBTyxFQUNyQixrQkFBa0IsRUFBRSxPQUFPLEVBQzNCLFlBQVksRUFBRSxPQUFPLEVBQ3JCLGFBQWEsRUFBRSxPQUFPLEVBQ3RCLElBQUksRUFBRSxPQUFPLEVBQ2IsT0FBTyxFQUFFLFVBQVUsRUFDbkIsYUFBYSxFQUFFLFFBQVEsRUFDdkIsSUFBSSxFQUFFLE9BQU8sRUFDYixPQUFPLEVBQUUsT0FBTyxFQUNoQixXQUFXLEVBQUUsTUFBTSxFQUNuQixHQUFHLEVBQUUsS0FBSzs7Ozs7O0dBMElYIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/cmds/create_account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,2BAA2B,CAAC;AAGtE,OAAO,EAAE,EAAE,EAAE,MAAM,qCAAqC,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAA+B,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAG9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,cAAc,GAAG,SAAS,EACtC,IAAI,EAAE,EAAE,GAAG,SAAS,EACpB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,QAAQ,EAAE,YAAY,GAAG,SAAS,EAClC,YAAY,EAAE,OAAO,EACrB,kBAAkB,EAAE,OAAO,EAC3B,YAAY,EAAE,OAAO,EACrB,aAAa,EAAE,OAAO,EACtB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,UAAU,EACnB,aAAa,EAAE,QAAQ,EACvB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK;;;;;;GA0IX"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { deriveSecretKeyFromSigningKey } from '@aztec-labs/accounts/utils';
|
|
2
|
+
import { NO_FROM } from '@aztec-labs/aztec.js/account';
|
|
3
|
+
import { NO_WAIT } from '@aztec-labs/aztec.js/contracts';
|
|
4
|
+
import { waitForTx } from '@aztec-labs/aztec.js/node';
|
|
5
|
+
import { prettyPrintJSON } from '@aztec-labs/cli/cli-utils';
|
|
6
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
7
|
+
import { GrumpkinScalar } from '@aztec-labs/foundation/curves/grumpkin';
|
|
8
|
+
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
9
|
+
import { printProfileResult } from '../utils/profiling.js';
|
|
10
|
+
export async function createAccount(wallet, aztecNode, accountType, signingKey, salt, publicKey, alias, deployer, registerOnly, skipInitialization, publicDeploy, registerClass, wait, feeOpts, waitForStatus, json, verbose, debugLogger, log) {
|
|
11
|
+
let secretKey;
|
|
12
|
+
if (accountType === 'ecdsasecp256r1ssh') {
|
|
13
|
+
// SSH accounts sign with a key held in the agent, and so we cannot derive their privacy secret key from it. Instead
|
|
14
|
+
// we pick a random value.
|
|
15
|
+
secretKey = Fr.random();
|
|
16
|
+
} else {
|
|
17
|
+
signingKey ??= GrumpkinScalar.random();
|
|
18
|
+
secretKey = await deriveSecretKeyFromSigningKey(signingKey);
|
|
19
|
+
}
|
|
20
|
+
const account = await wallet.createAccount(accountType, signingKey, secretKey, salt, publicKey);
|
|
21
|
+
const instanceSalt = account.getInstance().salt;
|
|
22
|
+
const { address, publicKeys, partialAddress } = await account.getCompleteAddress();
|
|
23
|
+
const out = {};
|
|
24
|
+
if (json) {
|
|
25
|
+
out.address = address;
|
|
26
|
+
out.publicKey = publicKeys;
|
|
27
|
+
if (signingKey) {
|
|
28
|
+
out.signingKey = signingKey;
|
|
29
|
+
}
|
|
30
|
+
if (secretKey) {
|
|
31
|
+
out.secretKey = secretKey;
|
|
32
|
+
}
|
|
33
|
+
out.partialAddress = partialAddress;
|
|
34
|
+
out.salt = instanceSalt;
|
|
35
|
+
out.initHash = account.getInstance().initializationHash;
|
|
36
|
+
} else {
|
|
37
|
+
log(`\nNew account:\n`);
|
|
38
|
+
log(`Address: ${address.toString()}`);
|
|
39
|
+
log(`Public key: ${publicKeys.toString()}`);
|
|
40
|
+
if (signingKey) {
|
|
41
|
+
log(`Signing key: ${signingKey.toString()}`);
|
|
42
|
+
}
|
|
43
|
+
if (secretKey) {
|
|
44
|
+
log(`Secret key: ${secretKey.toString()}`);
|
|
45
|
+
}
|
|
46
|
+
log(`Partial address: ${partialAddress.toString()}`);
|
|
47
|
+
log(`Salt: ${instanceSalt.toString()}`);
|
|
48
|
+
log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
|
|
49
|
+
}
|
|
50
|
+
let txHash;
|
|
51
|
+
let txReceipt;
|
|
52
|
+
// Initializerless accounts have no deployment tx — creating one only registers it locally — so there is
|
|
53
|
+
// nothing to deploy on-chain.
|
|
54
|
+
if (!registerOnly && accountType !== 'schnorr_initializerless') {
|
|
55
|
+
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
|
|
56
|
+
const delegatedDeployment = deployer && !account.address.equals(deployer);
|
|
57
|
+
const from = delegatedDeployment ? deployer : NO_FROM;
|
|
58
|
+
const deployAccountOpts = {
|
|
59
|
+
skipClassPublication: !registerClass,
|
|
60
|
+
skipInstancePublication: !publicDeploy,
|
|
61
|
+
skipInitialization,
|
|
62
|
+
from,
|
|
63
|
+
fee: {
|
|
64
|
+
paymentMethod,
|
|
65
|
+
gasSettings
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const localStart = performance.now();
|
|
69
|
+
const deployMethod = await account.getDeployMethod();
|
|
70
|
+
const sim = await deployMethod.simulate({
|
|
71
|
+
...deployAccountOpts,
|
|
72
|
+
includeMetadata: true
|
|
73
|
+
});
|
|
74
|
+
// includeMetadata: true guarantees these fields are present
|
|
75
|
+
const estimatedGas = await wallet.estimateGasLimits(sim.gasUsed);
|
|
76
|
+
const stats = sim.stats;
|
|
77
|
+
if (feeOpts.estimateOnly) {
|
|
78
|
+
if (json) {
|
|
79
|
+
out.fee = {
|
|
80
|
+
gasLimits: {
|
|
81
|
+
da: estimatedGas.gasLimits.daGas,
|
|
82
|
+
l2: estimatedGas.gasLimits.l2Gas
|
|
83
|
+
},
|
|
84
|
+
teardownGasLimits: {
|
|
85
|
+
da: estimatedGas.teardownGasLimits.daGas,
|
|
86
|
+
l2: estimatedGas.teardownGasLimits
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
if (verbose) {
|
|
92
|
+
printProfileResult(stats, log);
|
|
93
|
+
}
|
|
94
|
+
if (!json) {
|
|
95
|
+
log(`\nWaiting for account contract deployment...`);
|
|
96
|
+
}
|
|
97
|
+
const sendOpts = {
|
|
98
|
+
...deployAccountOpts,
|
|
99
|
+
fee: deployAccountOpts.fee ? {
|
|
100
|
+
...deployAccountOpts.fee,
|
|
101
|
+
gasSettings: estimatedGas
|
|
102
|
+
} : undefined
|
|
103
|
+
};
|
|
104
|
+
({ txHash } = await deployMethod.send({
|
|
105
|
+
...sendOpts,
|
|
106
|
+
wait: NO_WAIT
|
|
107
|
+
}));
|
|
108
|
+
const localTimeMs = performance.now() - localStart;
|
|
109
|
+
if (wait) {
|
|
110
|
+
const nodeStart = performance.now();
|
|
111
|
+
txReceipt = await waitForTx(aztecNode, txHash, {
|
|
112
|
+
timeout: DEFAULT_TX_TIMEOUT_S,
|
|
113
|
+
waitForStatus
|
|
114
|
+
});
|
|
115
|
+
const nodeTimeMs = performance.now() - nodeStart;
|
|
116
|
+
out.txReceipt = {
|
|
117
|
+
status: txReceipt.status,
|
|
118
|
+
transactionFee: txReceipt.transactionFee
|
|
119
|
+
};
|
|
120
|
+
if (!json) {
|
|
121
|
+
log(` Local processing time: ${(localTimeMs / 1000).toFixed(1)}s`);
|
|
122
|
+
log(` Node inclusion time: ${(nodeTimeMs / 1000).toFixed(1)}s`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
126
|
+
out.txHash = txHash;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (json) {
|
|
130
|
+
log(prettyPrintJSON(out));
|
|
131
|
+
} else {
|
|
132
|
+
if (txHash) {
|
|
133
|
+
log(`Deploy tx hash: ${txHash.toString()}`);
|
|
134
|
+
}
|
|
135
|
+
if (txReceipt) {
|
|
136
|
+
log(`Deploy tx fee: ${txReceipt.transactionFee}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
alias,
|
|
141
|
+
address,
|
|
142
|
+
signingKey,
|
|
143
|
+
secretKey,
|
|
144
|
+
salt: instanceSalt
|
|
145
|
+
};
|
|
146
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec-labs/aztec.js/addresses';
|
|
2
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
3
|
+
import type { CLIWallet } from '../utils/wallet.js';
|
|
4
|
+
export declare function createAuthwit(wallet: CLIWallet, from: AztecAddress, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("@aztec-labs/stdlib/auth-witness").AuthWitness>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2F1dGh3aXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2NyZWF0ZV9hdXRod2l0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBR25FLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBRXhELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixhQUFhLENBQ2pDLE1BQU0sRUFBRSxTQUFTLEVBQ2pCLElBQUksRUFBRSxZQUFZLEVBQ2xCLFlBQVksRUFBRSxNQUFNLEVBQ3BCLE1BQU0sRUFBRSxZQUFZLEVBQ3BCLGNBQWMsRUFBRSxHQUFHLEVBQUUsRUFDckIsb0JBQW9CLEVBQUUsTUFBTSxFQUM1QixlQUFlLEVBQUUsWUFBWSxFQUM3QixHQUFHLEVBQUUsS0FBSyxrRUF1QlgifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create_authwit.d.ts","sourceRoot":"","sources":["../../src/cmds/create_authwit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,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,kEAuBX"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Contract } from '@aztec-labs/aztec.js/contracts';
|
|
2
|
+
import { prepTx } from '@aztec-labs/cli/utils';
|
|
3
|
+
export async function createAuthwit(wallet, from, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
|
|
4
|
+
const { functionArgs, contractArtifact, isPrivate } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
5
|
+
if (!isPrivate) {
|
|
6
|
+
throw new Error('Cannot create an authwit for a public function. To allow a third party to call a public function, please authorize the action via the authorize-action command');
|
|
7
|
+
}
|
|
8
|
+
const contract = Contract.at(contractAddress, contractArtifact, wallet);
|
|
9
|
+
const call = await contract.methods[functionName](...functionArgs).getFunctionCall();
|
|
10
|
+
const witness = await wallet.createAuthWit(from, {
|
|
11
|
+
caller,
|
|
12
|
+
call
|
|
13
|
+
});
|
|
14
|
+
log(`Created authorization witness for action ${functionName} on contract ${contractAddress} for caller ${caller}`);
|
|
15
|
+
return witness;
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec-labs/aztec.js/addresses';
|
|
2
|
+
import { Fr } from '@aztec-labs/aztec.js/fields';
|
|
3
|
+
import { type AztecNode } from '@aztec-labs/aztec.js/node';
|
|
4
|
+
import type { LogFn, Logger } from '@aztec-labs/foundation/log';
|
|
5
|
+
import { PublicKeys } from '@aztec-labs/stdlib/keys';
|
|
6
|
+
import type { TxStatus } from '@aztec-labs/stdlib/tx';
|
|
7
|
+
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
8
|
+
import type { CLIWallet } from '../utils/wallet.js';
|
|
9
|
+
export declare function deploy(wallet: CLIWallet, node: AztecNode, deployer: AztecAddress, 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: CLIFeeArgs, waitForStatus: TxStatus, verbose: boolean, timeout: number | undefined, debugLogger: Logger, log: LogFn, universal?: boolean): Promise<AztecAddress>;
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY21kcy9kZXBsb3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFJbkUsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2pELE9BQU8sRUFBRSxLQUFLLFNBQVMsRUFBYSxNQUFNLDJCQUEyQixDQUFDO0FBRXRFLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUVoRSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDckQsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFHdEQsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBRXRELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixNQUFNLENBQzFCLE1BQU0sRUFBRSxTQUFTLEVBQ2pCLElBQUksRUFBRSxTQUFTLEVBQ2YsUUFBUSxFQUFFLFlBQVksRUFDdEIsWUFBWSxFQUFFLE1BQU0sRUFDcEIsSUFBSSxFQUFFLE9BQU8sRUFDYixVQUFVLEVBQUUsVUFBVSxHQUFHLFNBQVMsRUFDbEMsT0FBTyxFQUFFLEdBQUcsRUFBRSxFQUNkLElBQUksRUFBRSxFQUFFLEdBQUcsU0FBUyxFQUNwQixXQUFXLEVBQUUsTUFBTSxHQUFHLFNBQVMsRUFDL0IsdUJBQXVCLEVBQUUsT0FBTyxFQUNoQyxvQkFBb0IsRUFBRSxPQUFPLEVBQzdCLGtCQUFrQixFQUFFLE9BQU8sR0FBRyxTQUFTLEVBQ3ZDLElBQUksRUFBRSxPQUFPLEVBQ2IsT0FBTyxFQUFFLFVBQVUsRUFDbkIsYUFBYSxFQUFFLFFBQVEsRUFDdkIsT0FBTyxFQUFFLE9BQU8sRUFDaEIsT0FBTyxvQkFBK0IsRUFDdEMsV0FBVyxFQUFFLE1BQU0sRUFDbkIsR0FBRyxFQUFFLEtBQUssRUFDVixTQUFTLENBQUMsRUFBRSxPQUFPLHlCQXNIcEIifQ==
|