@aztec/cli-wallet 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108
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 +30 -0
- package/dest/bin/index.d.ts +1 -1
- package/dest/bin/index.js +38 -23
- package/dest/cmds/authorize_action.d.ts +4 -3
- package/dest/cmds/authorize_action.d.ts.map +1 -1
- package/dest/cmds/authorize_action.js +6 -7
- package/dest/cmds/bridge_fee_juice.d.ts +4 -4
- package/dest/cmds/bridge_fee_juice.d.ts.map +1 -1
- package/dest/cmds/bridge_fee_juice.js +9 -7
- package/dest/cmds/check_tx.d.ts +5 -3
- package/dest/cmds/check_tx.d.ts.map +1 -1
- package/dest/cmds/check_tx.js +144 -6
- package/dest/cmds/create_account.d.ts +7 -6
- package/dest/cmds/create_account.d.ts.map +1 -1
- package/dest/cmds/create_account.js +36 -48
- package/dest/cmds/create_authwit.d.ts +4 -3
- package/dest/cmds/create_authwit.d.ts.map +1 -1
- package/dest/cmds/create_authwit.js +6 -6
- package/dest/cmds/deploy.d.ts +7 -4
- package/dest/cmds/deploy.d.ts.map +1 -1
- package/dest/cmds/deploy.js +57 -46
- package/dest/cmds/deploy_account.d.ts +6 -8
- package/dest/cmds/deploy_account.d.ts.map +1 -1
- package/dest/cmds/deploy_account.js +36 -51
- package/dest/cmds/import_test_accounts.d.ts +3 -3
- package/dest/cmds/import_test_accounts.d.ts.map +1 -1
- package/dest/cmds/import_test_accounts.js +6 -9
- package/dest/cmds/index.d.ts +3 -3
- package/dest/cmds/index.d.ts.map +1 -1
- package/dest/cmds/index.js +73 -112
- package/dest/cmds/profile.d.ts +7 -4
- package/dest/cmds/profile.d.ts.map +1 -1
- package/dest/cmds/profile.js +9 -4
- package/dest/cmds/register_contract.d.ts +7 -3
- package/dest/cmds/register_contract.d.ts.map +1 -1
- package/dest/cmds/register_contract.js +5 -6
- package/dest/cmds/register_sender.d.ts +4 -3
- package/dest/cmds/register_sender.d.ts.map +1 -1
- package/dest/cmds/send.d.ts +8 -9
- package/dest/cmds/send.d.ts.map +1 -1
- package/dest/cmds/send.js +27 -24
- package/dest/cmds/simulate.d.ts +7 -4
- package/dest/cmds/simulate.d.ts.map +1 -1
- package/dest/cmds/simulate.js +9 -4
- package/dest/storage/wallet_db.d.ts +6 -16
- package/dest/storage/wallet_db.d.ts.map +1 -1
- package/dest/storage/wallet_db.js +2 -23
- package/dest/utils/authorizations.d.ts +3 -2
- package/dest/utils/authorizations.d.ts.map +1 -1
- package/dest/utils/authorizations.js +1 -1
- 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/ecdsa.d.ts +1 -1
- package/dest/utils/options/fees.d.ts +22 -28
- package/dest/utils/options/fees.d.ts.map +1 -1
- package/dest/utils/options/fees.js +66 -133
- package/dest/utils/options/index.d.ts +1 -1
- package/dest/utils/options/options.d.ts +4 -3
- package/dest/utils/options/options.d.ts.map +1 -1
- package/dest/utils/options/options.js +1 -1
- package/dest/utils/profiling.d.ts +1 -1
- package/dest/utils/wallet.d.ts +36 -0
- package/dest/utils/wallet.d.ts.map +1 -0
- package/dest/utils/wallet.js +195 -0
- package/package.json +17 -14
- package/src/bin/index.ts +38 -31
- package/src/cmds/authorize_action.ts +14 -6
- package/src/cmds/bridge_fee_juice.ts +15 -11
- package/src/cmds/check_tx.ts +181 -5
- package/src/cmds/create_account.ts +43 -53
- package/src/cmds/create_authwit.ts +9 -5
- package/src/cmds/deploy.ts +58 -56
- package/src/cmds/deploy_account.ts +43 -51
- package/src/cmds/import_test_accounts.ts +7 -11
- package/src/cmds/index.ts +120 -206
- package/src/cmds/profile.ts +14 -6
- package/src/cmds/register_contract.ts +9 -11
- package/src/cmds/register_sender.ts +3 -2
- package/src/cmds/send.ts +22 -32
- package/src/cmds/simulate.ts +14 -6
- package/src/storage/wallet_db.ts +3 -31
- package/src/utils/authorizations.ts +3 -1
- package/src/utils/cli_wallet_and_node_wrapper.ts +35 -0
- package/src/utils/options/fees.ts +88 -178
- package/src/utils/options/options.ts +3 -2
- package/src/utils/wallet.ts +266 -0
- package/dest/cmds/cancel_tx.d.ts +0 -11
- package/dest/cmds/cancel_tx.d.ts.map +0 -1
- package/dest/cmds/cancel_tx.js +0 -43
- package/dest/utils/accounts.d.ts +0 -9
- package/dest/utils/accounts.d.ts.map +0 -1
- package/dest/utils/accounts.js +0 -61
- package/dest/utils/pxe_wrapper.d.ts +0 -12
- package/dest/utils/pxe_wrapper.d.ts.map +0 -1
- package/dest/utils/pxe_wrapper.js +0 -26
- package/src/cmds/cancel_tx.ts +0 -66
- package/src/utils/accounts.ts +0 -77
- package/src/utils/pxe_wrapper.ts +0 -32
package/README.md
CHANGED
|
@@ -1,2 +1,32 @@
|
|
|
1
1
|
# Aztec wallet Documentation
|
|
2
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
|
+
|
package/dest/bin/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iaW4vaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
package/dest/bin/index.js
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computeSecretHash } from '@aztec/aztec.js/crypto';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
|
+
import { createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
4
|
+
import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
|
|
5
|
+
import { BackendType, Barretenberg } from '@aztec/bb.js';
|
|
2
6
|
import { LOCALHOST } from '@aztec/cli/cli-utils';
|
|
3
7
|
import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
|
|
4
8
|
import { openStoreAt } from '@aztec/kv-store/lmdb-v2';
|
|
5
9
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
6
10
|
import { Argument, Command, Option } from 'commander';
|
|
7
|
-
import { mkdirSync } from 'fs';
|
|
8
11
|
import { homedir } from 'os';
|
|
9
|
-
import {
|
|
12
|
+
import { join } from 'path';
|
|
10
13
|
import { injectCommands } from '../cmds/index.js';
|
|
11
14
|
import { Aliases, WalletDB } from '../storage/wallet_db.js';
|
|
15
|
+
import { CliWalletAndNodeWrapper } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
12
16
|
import { createAliasOption } from '../utils/options/index.js';
|
|
13
|
-
import {
|
|
17
|
+
import { CLIWallet } from '../utils/wallet.js';
|
|
14
18
|
const userLog = createConsoleLogger();
|
|
15
19
|
const debugLogger = createLogger('wallet');
|
|
16
20
|
const { WALLET_DATA_DIRECTORY = join(homedir(), '.aztec/wallet') } = process.env;
|
|
21
|
+
// TODO: This function is only used in 1 place so we could just inline this
|
|
17
22
|
function injectInternalCommands(program, log, db) {
|
|
18
23
|
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)=>{
|
|
19
24
|
value = db.tryRetrieveAlias(value) || value;
|
|
@@ -43,29 +48,38 @@ function injectInternalCommands(program, log, db) {
|
|
|
43
48
|
/** CLI wallet main entrypoint */ async function main() {
|
|
44
49
|
const walletVersion = getPackageVersion() ?? '0.0.0';
|
|
45
50
|
const db = WalletDB.getInstance();
|
|
46
|
-
const
|
|
51
|
+
const walletAndNodeWrapper = new CliWalletAndNodeWrapper();
|
|
47
52
|
const program = new Command('wallet');
|
|
48
|
-
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
|
|
53
|
+
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([
|
|
49
54
|
'wasm',
|
|
50
55
|
'native',
|
|
51
56
|
'none'
|
|
52
|
-
]).env('PXE_PROVER').default('native')).addOption(new Option('
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
const proverEnabled = prover !== 'none';
|
|
57
|
-
const bbBinaryPath = prover === 'native' ? resolve(dirname(fileURLToPath(import.meta.url)), '../../../../barretenberg/cpp/build/bin/bb') : undefined;
|
|
58
|
-
const bbWorkingDirectory = dataDir + '/bb';
|
|
59
|
-
mkdirSync(bbWorkingDirectory, {
|
|
60
|
-
recursive: true
|
|
61
|
-
});
|
|
62
|
-
const overridePXEConfig = {
|
|
63
|
-
proverEnabled,
|
|
64
|
-
bbBinaryPath: prover === 'native' ? bbBinaryPath : undefined,
|
|
65
|
-
bbWorkingDirectory: prover === 'native' ? bbWorkingDirectory : undefined
|
|
66
|
-
};
|
|
67
|
-
pxeWrapper.prepare(nodeUrl, join(dataDir, 'pxe'), overridePXEConfig);
|
|
57
|
+
]).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)=>{
|
|
58
|
+
// Skip initialization if user is just requesting help
|
|
59
|
+
if (command.args.includes('--help') || command.args.includes('-h')) {
|
|
60
|
+
return;
|
|
68
61
|
}
|
|
62
|
+
const { dataDir, nodeUrl, prover } = command.optsWithGlobals();
|
|
63
|
+
const proverEnabled = prover !== 'none';
|
|
64
|
+
switch(prover){
|
|
65
|
+
case 'native':
|
|
66
|
+
await Barretenberg.initSingleton({
|
|
67
|
+
backend: BackendType.NativeUnixSocket
|
|
68
|
+
});
|
|
69
|
+
break;
|
|
70
|
+
case 'wasm':
|
|
71
|
+
await Barretenberg.initSingleton({
|
|
72
|
+
backend: BackendType.Wasm
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
const overridePXEConfig = {
|
|
77
|
+
proverEnabled,
|
|
78
|
+
dataDirectory: join(dataDir, 'pxe')
|
|
79
|
+
};
|
|
80
|
+
const node = createAztecNodeClient(nodeUrl);
|
|
81
|
+
const wallet = await CLIWallet.create(node, userLog, db, overridePXEConfig);
|
|
82
|
+
walletAndNodeWrapper.setNodeAndWallet(node, wallet);
|
|
69
83
|
await db.init(await openStoreAt(dataDir));
|
|
70
84
|
let protocolContractsRegistered;
|
|
71
85
|
try {
|
|
@@ -80,9 +94,10 @@ function injectInternalCommands(program, log, db) {
|
|
|
80
94
|
}
|
|
81
95
|
}
|
|
82
96
|
});
|
|
83
|
-
injectCommands(program, userLog, debugLogger,
|
|
97
|
+
injectCommands(program, userLog, debugLogger, walletAndNodeWrapper, db);
|
|
84
98
|
injectInternalCommands(program, userLog, db);
|
|
85
99
|
await program.parseAsync(process.argv);
|
|
100
|
+
await Barretenberg.destroySingleton();
|
|
86
101
|
}
|
|
87
102
|
main().catch((err)=>{
|
|
88
103
|
debugLogger.error(`Error in command execution`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
2
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
export declare function authorizeAction(wallet:
|
|
4
|
-
//# sourceMappingURL=
|
|
4
|
+
export declare function authorizeAction(wallet: Wallet, from: AztecAddress, functionName: string, caller: AztecAddress, functionArgsIn: any[], contractArtifactPath: string, contractAddress: AztecAddress, log: LogFn): Promise<import("../../../stdlib/dest/tx/tx_receipt.js").TxReceipt>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aG9yaXplX2FjdGlvbi5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvYXV0aG9yaXplX2FjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUc5RCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUVyRCxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUluRCx3QkFBc0IsZUFBZSxDQUNuQyxNQUFNLEVBQUUsTUFBTSxFQUNkLElBQUksRUFBRSxZQUFZLEVBQ2xCLFlBQVksRUFBRSxNQUFNLEVBQ3BCLE1BQU0sRUFBRSxZQUFZLEVBQ3BCLGNBQWMsRUFBRSxHQUFHLEVBQUUsRUFDckIsb0JBQW9CLEVBQUUsTUFBTSxFQUM1QixlQUFlLEVBQUUsWUFBWSxFQUM3QixHQUFHLEVBQUUsS0FBSyxzRUE2QlgifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize_action.d.ts","sourceRoot":"","sources":["../../src/cmds/authorize_action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"authorize_action.d.ts","sourceRoot":"","sources":["../../src/cmds/authorize_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,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,sEA6BX"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SetPublicAuthwitContractInteraction } from '@aztec/aztec.js/authorization';
|
|
2
|
+
import { Contract } from '@aztec/aztec.js/contracts';
|
|
2
3
|
import { prepTx } from '@aztec/cli/utils';
|
|
3
|
-
import { DEFAULT_TX_TIMEOUT_S } from '../utils/
|
|
4
|
+
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
4
5
|
export async function authorizeAction(wallet, from, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
|
|
5
6
|
const { functionArgs, contractArtifact, isPrivate } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
6
7
|
if (isPrivate) {
|
|
7
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');
|
|
8
9
|
}
|
|
9
|
-
const contract =
|
|
10
|
+
const contract = Contract.at(contractAddress, contractArtifact, wallet);
|
|
10
11
|
const action = contract.methods[functionName](...functionArgs);
|
|
11
|
-
const setAuthwitnessInteraction = await
|
|
12
|
+
const setAuthwitnessInteraction = await SetPublicAuthwitContractInteraction.create(wallet, from, {
|
|
12
13
|
caller,
|
|
13
14
|
action
|
|
14
15
|
}, true);
|
|
15
|
-
const witness = await setAuthwitnessInteraction.send({
|
|
16
|
-
from
|
|
17
|
-
}).wait({
|
|
16
|
+
const witness = await setAuthwitnessInteraction.send().wait({
|
|
18
17
|
timeout: DEFAULT_TX_TIMEOUT_S
|
|
19
18
|
});
|
|
20
19
|
log(`Authorized action ${functionName} on contract ${contractAddress} for caller ${caller}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
export declare function bridgeL1FeeJuice(amount: bigint, recipient: AztecAddress,
|
|
6
|
-
//# sourceMappingURL=
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJpZGdlX2ZlZV9qdWljZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NtZHMvYnJpZGdlX2ZlZV9qdWljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUt0RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQzNELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBR2hFLHdCQUFzQixnQkFBZ0IsQ0FDcEMsTUFBTSxFQUFFLE1BQU0sRUFDZCxTQUFTLEVBQUUsWUFBWSxFQUN2QixJQUFJLEVBQUUsU0FBUyxFQUNmLFNBQVMsRUFBRSxNQUFNLEVBQUUsRUFDbkIsT0FBTyxFQUFFLE1BQU0sRUFDZixVQUFVLEVBQUUsTUFBTSxHQUFHLFNBQVMsRUFDOUIsUUFBUSxFQUFFLE1BQU0sRUFDaEIsSUFBSSxFQUFFLE9BQU8sRUFDYixJQUFJLEVBQUUsT0FBTyxFQUNiLElBQUksRUFBRSxPQUFPLEVBQ2IsUUFBUSxvQkFBUyxFQUNqQixHQUFHLEVBQUUsS0FBSyxFQUNWLFdBQVcsRUFBRSxNQUFNLGtDQW1FcEIifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge_fee_juice.d.ts","sourceRoot":"","sources":["../../src/cmds/bridge_fee_juice.ts"],"names":[],"mappings":"
|
|
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,sBAAsB,CAAC;AAKtD,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,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"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { L1FeeJuicePortalManager } from '@aztec/aztec.js';
|
|
1
|
+
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
2
|
+
import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
|
|
2
3
|
import { prettyPrintJSON } from '@aztec/cli/utils';
|
|
3
|
-
import { createEthereumChain
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
5
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
6
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
|
+
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
8
|
+
export async function bridgeL1FeeJuice(amount, recipient, node, l1RpcUrls, chainId, privateKey, mnemonic, mint, json, wait, interval = 60_000, log, debugLogger) {
|
|
6
9
|
// Prepare L1 client
|
|
7
10
|
const chain = createEthereumChain(l1RpcUrls, chainId);
|
|
8
11
|
const client = createExtendedL1Client(chain.rpcUrls, privateKey ?? mnemonic, chain.chainInfo);
|
|
9
|
-
const { protocolContractAddresses: { feeJuice: feeJuiceAddress } } = await pxe.getPXEInfo();
|
|
10
12
|
// Setup portal manager
|
|
11
|
-
const portal = await L1FeeJuicePortalManager.new(
|
|
13
|
+
const portal = await L1FeeJuicePortalManager.new(node, client, debugLogger);
|
|
12
14
|
const { claimAmount, claimSecret, messageHash, messageLeafIndex } = await portal.bridgeTokensPublic(recipient, amount, mint);
|
|
13
15
|
if (json) {
|
|
14
16
|
const out = {
|
|
@@ -33,7 +35,7 @@ export async function bridgeL1FeeJuice(amount, recipient, pxe, l1RpcUrls, chainI
|
|
|
33
35
|
const delayedCheck = (delay)=>{
|
|
34
36
|
return new Promise((resolve, reject)=>{
|
|
35
37
|
setTimeout(()=>{
|
|
36
|
-
void
|
|
38
|
+
void getNonNullifiedL1ToL2MessageWitness(node, ProtocolContractAddress.FeeJuice, Fr.fromHexString(messageHash), claimSecret).then((witness)=>resolve(witness)).catch((err)=>reject(err));
|
|
37
39
|
}, delay);
|
|
38
40
|
});
|
|
39
41
|
};
|
package/dest/cmds/check_tx.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
2
|
+
import type { TxHash } from '@aztec/aztec.js/tx';
|
|
2
3
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
|
|
4
|
-
|
|
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/aztec.js/tx").TxStatus | undefined>;
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2tfdHguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2NoZWNrX3R4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBRXRELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQ2pELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBSW5ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixPQUFPLENBQzNCLE1BQU0sRUFBRSxTQUFTLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLE1BQU0sRUFBRSxNQUFNLEVBQ2QsVUFBVSxFQUFFLE9BQU8sRUFDbkIsR0FBRyxFQUFFLEtBQUssOERBUVgifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check_tx.d.ts","sourceRoot":"","sources":["../../src/cmds/check_tx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"check_tx.d.ts","sourceRoot":"","sources":["../../src/cmds/check_tx.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,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,8DAQX"}
|
package/dest/cmds/check_tx.js
CHANGED
|
@@ -1,11 +1,149 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ProtocolContractAddress } from '@aztec/aztec.js/protocol';
|
|
2
|
+
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
3
|
+
export async function checkTx(wallet, aztecNode, txHash, statusOnly, log) {
|
|
3
4
|
if (statusOnly) {
|
|
4
|
-
const receipt = await
|
|
5
|
+
const receipt = await aztecNode.getTxReceipt(txHash);
|
|
5
6
|
return receipt.status;
|
|
6
7
|
} else {
|
|
7
|
-
await inspectTx(
|
|
8
|
-
includeBlockInfo: true
|
|
9
|
-
});
|
|
8
|
+
await inspectTx(wallet, aztecNode, txHash, log);
|
|
10
9
|
}
|
|
11
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, effectsInBlock] = await Promise.all([
|
|
15
|
+
aztecNode.getTxReceipt(txHash),
|
|
16
|
+
aztecNode.getTxEffect(txHash)
|
|
17
|
+
]);
|
|
18
|
+
// Base tx data
|
|
19
|
+
log(`Tx ${txHash.toString()}`);
|
|
20
|
+
log(` Status: ${receipt.status} ${effectsInBlock ? `(${effectsInBlock.data.revertCode.getDescription()})` : ''}`);
|
|
21
|
+
if (receipt.error) {
|
|
22
|
+
log(` Error: ${receipt.error}`);
|
|
23
|
+
}
|
|
24
|
+
if (!effectsInBlock) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const effects = effectsInBlock.data;
|
|
28
|
+
const artifactMap = await getKnownArtifacts(wallet);
|
|
29
|
+
log(` Block: ${receipt.blockNumber} (${receipt.blockHash?.toString()})`);
|
|
30
|
+
if (receipt.transactionFee) {
|
|
31
|
+
log(` Fee: ${receipt.transactionFee.toString()}`);
|
|
32
|
+
}
|
|
33
|
+
// Public logs
|
|
34
|
+
const publicLogs = effects.publicLogs;
|
|
35
|
+
if (publicLogs.length > 0) {
|
|
36
|
+
log(' Logs:');
|
|
37
|
+
for (const publicLog of publicLogs){
|
|
38
|
+
log(` ${publicLog.toHumanReadable()}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Public data writes
|
|
42
|
+
const writes = effects.publicDataWrites;
|
|
43
|
+
if (writes.length > 0) {
|
|
44
|
+
log(' Public data writes:');
|
|
45
|
+
for (const write of writes){
|
|
46
|
+
log(` Leaf ${write.leafSlot.toString()} = ${write.value.toString()}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Created notes
|
|
50
|
+
const notes = effects.noteHashes;
|
|
51
|
+
if (notes.length > 0) {
|
|
52
|
+
log(' Created notes:');
|
|
53
|
+
log(` Total: ${notes.length}`);
|
|
54
|
+
for (const note of notes){
|
|
55
|
+
log(` Note hash: ${note.toShortString()}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Nullifiers
|
|
59
|
+
const nullifierCount = effects.nullifiers.length;
|
|
60
|
+
const { deployNullifiers, initNullifiers, classNullifiers } = await getKnownNullifiers(wallet, artifactMap);
|
|
61
|
+
if (nullifierCount > 0) {
|
|
62
|
+
log(' Nullifiers:');
|
|
63
|
+
for (const nullifier of effects.nullifiers){
|
|
64
|
+
const deployed = deployNullifiers[nullifier.toString()];
|
|
65
|
+
const note = deployed ? (await wallet.getNotes({
|
|
66
|
+
siloedNullifier: nullifier,
|
|
67
|
+
contractAddress: deployed
|
|
68
|
+
}))[0] : undefined;
|
|
69
|
+
const initialized = initNullifiers[nullifier.toString()];
|
|
70
|
+
const registered = classNullifiers[nullifier.toString()];
|
|
71
|
+
if (nullifier.toBuffer().equals(txHash.toBuffer())) {
|
|
72
|
+
log(` Transaction hash nullifier ${nullifier.toShortString()}`);
|
|
73
|
+
} else if (note) {
|
|
74
|
+
inspectNote(note, artifactMap, log, `Nullifier ${nullifier.toShortString()} for note`);
|
|
75
|
+
} else if (deployed) {
|
|
76
|
+
log(` Contract ${toFriendlyAddress(deployed, artifactMap)} deployed via nullifier ${nullifier.toShortString()}`);
|
|
77
|
+
} else if (initialized) {
|
|
78
|
+
log(` Contract ${toFriendlyAddress(initialized, artifactMap)} initialized via nullifier ${nullifier.toShortString()}`);
|
|
79
|
+
} else if (registered) {
|
|
80
|
+
log(` Class ${registered} registered via nullifier ${nullifier.toShortString()}`);
|
|
81
|
+
} else {
|
|
82
|
+
log(` Unknown nullifier ${nullifier.toString()}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// L2 to L1 messages
|
|
87
|
+
if (effects.l2ToL1Msgs.length > 0) {
|
|
88
|
+
log(` L2 to L1 messages:`);
|
|
89
|
+
for (const msg of effects.l2ToL1Msgs){
|
|
90
|
+
log(` ${msg.toString()}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function inspectNote(note, artifactMap, log, text = 'Note') {
|
|
95
|
+
const artifact = artifactMap[note.contractAddress.toString()];
|
|
96
|
+
const contract = artifact?.name ?? note.contractAddress.toString();
|
|
97
|
+
log(` ${text} at ${contract}`);
|
|
98
|
+
for (const field of note.note.items){
|
|
99
|
+
log(` ${field.toString()}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function toFriendlyAddress(address, artifactMap) {
|
|
103
|
+
const artifact = artifactMap[address.toString()];
|
|
104
|
+
if (!artifact) {
|
|
105
|
+
return address.toString();
|
|
106
|
+
}
|
|
107
|
+
return `${artifact.name}<${address.toString()}>`;
|
|
108
|
+
}
|
|
109
|
+
async function getKnownNullifiers(wallet, artifactMap) {
|
|
110
|
+
const knownContracts = await wallet.getContracts();
|
|
111
|
+
const deployerAddress = ProtocolContractAddress.ContractInstanceRegistry;
|
|
112
|
+
const classRegistryAddress = ProtocolContractAddress.ContractClassRegistry;
|
|
113
|
+
const initNullifiers = {};
|
|
114
|
+
const deployNullifiers = {};
|
|
115
|
+
const classNullifiers = {};
|
|
116
|
+
for (const contract of knownContracts){
|
|
117
|
+
initNullifiers[(await siloNullifier(contract, contract.toField())).toString()] = contract;
|
|
118
|
+
deployNullifiers[(await siloNullifier(deployerAddress, contract.toField())).toString()] = contract;
|
|
119
|
+
}
|
|
120
|
+
for (const artifact of Object.values(artifactMap)){
|
|
121
|
+
classNullifiers[(await siloNullifier(classRegistryAddress, artifact.classId)).toString()] = `${artifact.name}Class<${artifact.classId}>`;
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
initNullifiers,
|
|
125
|
+
deployNullifiers,
|
|
126
|
+
classNullifiers
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
async function getKnownArtifacts(wallet) {
|
|
130
|
+
const knownContractAddresses = await wallet.getContracts();
|
|
131
|
+
const knownContracts = (await Promise.all(knownContractAddresses.map((contractAddress)=>wallet.getContractMetadata(contractAddress)))).map((contractMetadata)=>contractMetadata.contractInstance);
|
|
132
|
+
const classIds = [
|
|
133
|
+
...new Set(knownContracts.map((contract)=>contract?.currentContractClassId))
|
|
134
|
+
];
|
|
135
|
+
const knownArtifacts = (await Promise.all(classIds.map((classId)=>classId ? wallet.getContractClassMetadata(classId) : undefined))).map((contractClassMetadata)=>contractClassMetadata ? {
|
|
136
|
+
...contractClassMetadata.artifact,
|
|
137
|
+
classId: contractClassMetadata.contractClass?.id
|
|
138
|
+
} : undefined);
|
|
139
|
+
const map = {};
|
|
140
|
+
for (const instance of knownContracts){
|
|
141
|
+
if (instance) {
|
|
142
|
+
const artifact = knownArtifacts.find((a)=>a?.classId?.equals(instance.currentContractClassId));
|
|
143
|
+
if (artifact) {
|
|
144
|
+
map[instance.address.toString()] = artifact;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return map;
|
|
149
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { AztecAddress
|
|
2
|
-
import {
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
4
|
-
import {
|
|
5
|
-
import { type
|
|
6
|
-
export declare function createAccount(
|
|
5
|
+
import { CLIFeeArgs } from '../utils/options/fees.js';
|
|
6
|
+
import { type AccountType, CLIWallet } from '../utils/wallet.js';
|
|
7
|
+
export declare function createAccount(wallet: CLIWallet, aztecNode: AztecNode, accountType: AccountType, secretKey: Fr | undefined, publicKey: string | undefined, alias: string | undefined, deployer: AztecAddress | undefined, registerOnly: boolean, skipInitialization: boolean, publicDeploy: boolean, registerClass: boolean, wait: boolean, feeOpts: CLIFeeArgs, json: boolean, verbose: boolean, debugLogger: Logger, log: LogFn): Promise<{
|
|
7
8
|
alias: string | undefined;
|
|
8
9
|
address: AztecAddress;
|
|
9
10
|
secretKey: Fr;
|
|
10
11
|
salt: Fr;
|
|
11
12
|
}>;
|
|
12
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2FjY291bnQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2NyZWF0ZV9hY2NvdW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUd0RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRzNELE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUV0RCxPQUFPLEVBQUUsS0FBSyxXQUFXLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFakUsd0JBQXNCLGFBQWEsQ0FDakMsTUFBTSxFQUFFLFNBQVMsRUFDakIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsV0FBVyxFQUFFLFdBQVcsRUFDeEIsU0FBUyxFQUFFLEVBQUUsR0FBRyxTQUFTLEVBQ3pCLFNBQVMsRUFBRSxNQUFNLEdBQUcsU0FBUyxFQUM3QixLQUFLLEVBQUUsTUFBTSxHQUFHLFNBQVMsRUFDekIsUUFBUSxFQUFFLFlBQVksR0FBRyxTQUFTLEVBQ2xDLFlBQVksRUFBRSxPQUFPLEVBQ3JCLGtCQUFrQixFQUFFLE9BQU8sRUFDM0IsWUFBWSxFQUFFLE9BQU8sRUFDckIsYUFBYSxFQUFFLE9BQU8sRUFDdEIsSUFBSSxFQUFFLE9BQU8sRUFDYixPQUFPLEVBQUUsVUFBVSxFQUNuQixJQUFJLEVBQUUsT0FBTyxFQUNiLE9BQU8sRUFBRSxPQUFPLEVBQ2hCLFdBQVcsRUFBRSxNQUFNLEVBQ25CLEdBQUcsRUFBRSxLQUFLOzs7OztHQWlIWCJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/cmds/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"create_account.d.ts","sourceRoot":"","sources":["../../src/cmds/create_account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,KAAK,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEjE,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,EAAE,GAAG,SAAS,EACzB,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,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,KAAK;;;;;GAiHX"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { AztecAddress } from '@aztec/aztec.js';
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import { prettyPrintJSON } from '@aztec/cli/cli-utils';
|
|
3
|
-
import { Fr } from '@aztec/foundation/
|
|
4
|
-
import {
|
|
5
|
-
import { printGasEstimates } from '../utils/options/fees.js';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { DEFAULT_TX_TIMEOUT_S } from '../utils/cli_wallet_and_node_wrapper.js';
|
|
6
5
|
import { printProfileResult } from '../utils/profiling.js';
|
|
7
|
-
|
|
8
|
-
export async function createAccount(client, accountType, secretKey, publicKey, alias, registerOnly, publicDeploy, skipInitialization, wait, feeOpts, json, verbose, debugLogger, log) {
|
|
6
|
+
export async function createAccount(wallet, aztecNode, accountType, secretKey, publicKey, alias, deployer, registerOnly, skipInitialization, publicDeploy, registerClass, wait, feeOpts, json, verbose, debugLogger, log) {
|
|
9
7
|
secretKey ??= Fr.random();
|
|
10
|
-
const account = await createOrRetrieveAccount(
|
|
8
|
+
const account = await wallet.createOrRetrieveAccount(undefined /* address, we don't have it yet */ , secretKey, accountType, Fr.ZERO, publicKey);
|
|
11
9
|
const { salt } = account.getInstance();
|
|
12
10
|
const { address, publicKeys, partialAddress } = await account.getCompleteAddress();
|
|
13
11
|
const out = {};
|
|
@@ -20,7 +18,6 @@ export async function createAccount(client, accountType, secretKey, publicKey, a
|
|
|
20
18
|
out.partialAddress = partialAddress;
|
|
21
19
|
out.salt = salt;
|
|
22
20
|
out.initHash = account.getInstance().initializationHash;
|
|
23
|
-
out.deployer = account.getInstance().deployer;
|
|
24
21
|
} else {
|
|
25
22
|
log(`\nNew account:\n`);
|
|
26
23
|
log(`Address: ${address.toString()}`);
|
|
@@ -31,64 +28,55 @@ export async function createAccount(client, accountType, secretKey, publicKey, a
|
|
|
31
28
|
log(`Partial address: ${partialAddress.toString()}`);
|
|
32
29
|
log(`Salt: ${salt.toString()}`);
|
|
33
30
|
log(`Init hash: ${account.getInstance().initializationHash.toString()}`);
|
|
34
|
-
log(`Deployer: ${account.getInstance().deployer.toString()}`);
|
|
35
31
|
}
|
|
36
32
|
let tx;
|
|
37
33
|
let txReceipt;
|
|
38
|
-
if (registerOnly) {
|
|
39
|
-
await
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
skipClassPublication: !
|
|
34
|
+
if (!registerOnly) {
|
|
35
|
+
const { paymentMethod, gasSettings } = await feeOpts.toUserFeeOptions(aztecNode, wallet, address);
|
|
36
|
+
const delegatedDeployment = deployer && !account.address.equals(deployer);
|
|
37
|
+
const from = delegatedDeployment ? deployer : AztecAddress.ZERO;
|
|
38
|
+
const deployAccountOpts = {
|
|
39
|
+
skipClassPublication: !registerClass,
|
|
44
40
|
skipInstancePublication: !publicDeploy,
|
|
45
|
-
skipInitialization
|
|
46
|
-
|
|
41
|
+
skipInitialization,
|
|
42
|
+
from,
|
|
43
|
+
fee: {
|
|
44
|
+
paymentMethod,
|
|
45
|
+
gasSettings
|
|
46
|
+
}
|
|
47
47
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
...deployOpts.fee,
|
|
57
|
-
paymentMethod: await account.getSelfPaymentMethod(deployOpts.fee.paymentMethod)
|
|
58
|
-
} : deployOpts?.fee;
|
|
59
|
-
const deployMethod = await account.getDeployMethod(deployOpts.deployWallet);
|
|
48
|
+
const deployMethod = await account.getDeployMethod();
|
|
49
|
+
const { estimatedGas, stats } = await deployMethod.simulate({
|
|
50
|
+
...deployAccountOpts,
|
|
51
|
+
fee: {
|
|
52
|
+
...deployAccountOpts.fee,
|
|
53
|
+
estimateGas: true
|
|
54
|
+
}
|
|
55
|
+
});
|
|
60
56
|
if (feeOpts.estimateOnly) {
|
|
61
|
-
const gas = await deployMethod.estimateGas({
|
|
62
|
-
...deployOpts,
|
|
63
|
-
from: AztecAddress.ZERO,
|
|
64
|
-
universalDeploy: true,
|
|
65
|
-
contractAddressSalt: salt
|
|
66
|
-
});
|
|
67
57
|
if (json) {
|
|
68
58
|
out.fee = {
|
|
69
59
|
gasLimits: {
|
|
70
|
-
da:
|
|
71
|
-
l2:
|
|
60
|
+
da: estimatedGas.gasLimits.daGas,
|
|
61
|
+
l2: estimatedGas.gasLimits.l2Gas
|
|
72
62
|
},
|
|
73
63
|
teardownGasLimits: {
|
|
74
|
-
da:
|
|
75
|
-
l2:
|
|
64
|
+
da: estimatedGas.teardownGasLimits.daGas,
|
|
65
|
+
l2: estimatedGas.teardownGasLimits
|
|
76
66
|
}
|
|
77
67
|
};
|
|
78
|
-
} else {
|
|
79
|
-
printGasEstimates(feeOpts, gas, log);
|
|
80
68
|
}
|
|
81
69
|
} else {
|
|
82
|
-
|
|
83
|
-
...
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
70
|
+
tx = deployMethod.send({
|
|
71
|
+
...deployAccountOpts,
|
|
72
|
+
fee: deployAccountOpts.fee ? {
|
|
73
|
+
...deployAccountOpts.fee,
|
|
74
|
+
gasSettings: estimatedGas
|
|
75
|
+
} : undefined
|
|
87
76
|
});
|
|
88
77
|
if (verbose) {
|
|
89
|
-
printProfileResult(
|
|
78
|
+
printProfileResult(stats, log);
|
|
90
79
|
}
|
|
91
|
-
tx = provenTx.send();
|
|
92
80
|
const txHash = await tx.getTxHash();
|
|
93
81
|
debugLogger.debug(`Account contract tx sent with hash ${txHash.toString()}`);
|
|
94
82
|
out.txHash = txHash;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
-
|
|
4
|
-
|
|
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("../../../stdlib/dest/auth_witness/auth_witness.js").AuthWitness>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX2F1dGh3aXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jbWRzL2NyZWF0ZV9hdXRod2l0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRzlELE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRW5ELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXBELHdCQUFzQixhQUFhLENBQ2pDLE1BQU0sRUFBRSxTQUFTLEVBQ2pCLElBQUksRUFBRSxZQUFZLEVBQ2xCLFlBQVksRUFBRSxNQUFNLEVBQ3BCLE1BQU0sRUFBRSxZQUFZLEVBQ3BCLGNBQWMsRUFBRSxHQUFHLEVBQUUsRUFDckIsb0JBQW9CLEVBQUUsTUFBTSxFQUM1QixlQUFlLEVBQUUsWUFBWSxFQUM3QixHQUFHLEVBQUUsS0FBSyxvRkF1QlgifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_authwit.d.ts","sourceRoot":"","sources":["../../src/cmds/create_authwit.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"create_authwit.d.ts","sourceRoot":"","sources":["../../src/cmds/create_authwit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,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,oFAuBX"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Contract } from '@aztec/aztec.js';
|
|
1
|
+
import { Contract } from '@aztec/aztec.js/contracts';
|
|
2
2
|
import { prepTx } from '@aztec/cli/utils';
|
|
3
|
-
export async function createAuthwit(wallet, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
|
|
3
|
+
export async function createAuthwit(wallet, from, functionName, caller, functionArgsIn, contractArtifactPath, contractAddress, log) {
|
|
4
4
|
const { functionArgs, contractArtifact, isPrivate } = await prepTx(contractArtifactPath, functionName, functionArgsIn, log);
|
|
5
5
|
if (!isPrivate) {
|
|
6
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
7
|
}
|
|
8
|
-
const contract =
|
|
9
|
-
const
|
|
10
|
-
const witness = await wallet.createAuthWit({
|
|
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
11
|
caller,
|
|
12
|
-
|
|
12
|
+
call
|
|
13
13
|
});
|
|
14
14
|
log(`Created authorization witness for action ${functionName} on contract ${contractAddress} for caller ${caller}`);
|
|
15
15
|
return witness;
|