@aztec-labs/aztec 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 +57 -0
- package/dest/bin/index.d.ts +3 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +61 -0
- package/dest/cli/admin_api_key_store.d.ts +45 -0
- package/dest/cli/admin_api_key_store.d.ts.map +1 -0
- package/dest/cli/admin_api_key_store.js +98 -0
- package/dest/cli/aztec_start_action.d.ts +3 -0
- package/dest/cli/aztec_start_action.d.ts.map +1 -0
- package/dest/cli/aztec_start_action.js +153 -0
- package/dest/cli/aztec_start_options.d.ts +17 -0
- package/dest/cli/aztec_start_options.d.ts.map +1 -0
- package/dest/cli/aztec_start_options.js +290 -0
- package/dest/cli/cli.d.ts +9 -0
- package/dest/cli/cli.d.ts.map +1 -0
- package/dest/cli/cli.js +37 -0
- package/dest/cli/cmds/compile.d.ts +4 -0
- package/dest/cli/cmds/compile.d.ts.map +1 -0
- package/dest/cli/cmds/compile.js +174 -0
- package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
- package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
- package/dest/cli/cmds/migrate_ha_db.js +27 -0
- package/dest/cli/cmds/profile.d.ts +4 -0
- package/dest/cli/cmds/profile.d.ts.map +1 -0
- package/dest/cli/cmds/profile.js +8 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
- package/dest/cli/cmds/profile_flamegraph.js +52 -0
- package/dest/cli/cmds/profile_gates.d.ts +4 -0
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
- package/dest/cli/cmds/profile_gates.js +76 -0
- package/dest/cli/cmds/profile_utils.d.ts +18 -0
- package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
- package/dest/cli/cmds/profile_utils.js +50 -0
- package/dest/cli/cmds/prover.d.ts +4 -0
- package/dest/cli/cmds/prover.d.ts.map +1 -0
- package/dest/cli/cmds/prover.js +24 -0
- package/dest/cli/cmds/standby.d.ts +56 -0
- package/dest/cli/cmds/standby.d.ts.map +1 -0
- package/dest/cli/cmds/standby.js +140 -0
- package/dest/cli/cmds/start_bot.d.ts +8 -0
- package/dest/cli/cmds/start_bot.d.ts.map +1 -0
- package/dest/cli/cmds/start_bot.js +53 -0
- package/dest/cli/cmds/start_node.d.ts +8 -0
- package/dest/cli/cmds/start_node.d.ts.map +1 -0
- package/dest/cli/cmds/start_node.js +150 -0
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts +6 -0
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -0
- package/dest/cli/cmds/start_p2p_bootstrap.js +30 -0
- package/dest/cli/cmds/start_prover_agent.d.ts +4 -0
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -0
- package/dest/cli/cmds/start_prover_agent.js +58 -0
- package/dest/cli/cmds/start_prover_broker.d.ts +9 -0
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -0
- package/dest/cli/cmds/start_prover_broker.js +46 -0
- package/dest/cli/cmds/start_txe.d.ts +3 -0
- package/dest/cli/cmds/start_txe.d.ts.map +1 -0
- package/dest/cli/cmds/start_txe.js +12 -0
- package/dest/cli/cmds/utils/artifacts.d.ts +26 -0
- package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
- package/dest/cli/cmds/utils/artifacts.js +24 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
- package/dest/cli/cmds/utils/needs_recompile.js +90 -0
- package/dest/cli/cmds/utils/spawn.d.ts +3 -0
- package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
- package/dest/cli/cmds/utils/spawn.js +16 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
- package/dest/cli/index.d.ts +2 -0
- package/dest/cli/index.d.ts.map +1 -0
- package/dest/cli/index.js +1 -0
- package/dest/cli/preload_crs.d.ts +3 -0
- package/dest/cli/preload_crs.d.ts.map +1 -0
- package/dest/cli/preload_crs.js +6 -0
- package/dest/cli/util.d.ts +71 -0
- package/dest/cli/util.d.ts.map +1 -0
- package/dest/cli/util.js +261 -0
- package/dest/cli/versioning.d.ts +4 -0
- package/dest/cli/versioning.d.ts.map +1 -0
- package/dest/cli/versioning.js +9 -0
- package/dest/examples/token.d.ts +2 -0
- package/dest/examples/token.d.ts.map +1 -0
- package/dest/examples/token.js +59 -0
- package/dest/examples/util.d.ts +19 -0
- package/dest/examples/util.d.ts.map +1 -0
- package/dest/examples/util.js +30 -0
- package/dest/index.d.ts +2 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +1 -0
- package/dest/local-network/auth_registry.d.ts +5 -0
- package/dest/local-network/auth_registry.d.ts.map +1 -0
- package/dest/local-network/auth_registry.js +17 -0
- package/dest/local-network/banana_fpc.d.ts +11 -0
- package/dest/local-network/banana_fpc.d.ts.map +1 -0
- package/dest/local-network/banana_fpc.js +81 -0
- package/dest/local-network/index.d.ts +4 -0
- package/dest/local-network/index.d.ts.map +1 -0
- package/dest/local-network/index.js +3 -0
- package/dest/local-network/local-network.d.ts +51 -0
- package/dest/local-network/local-network.d.ts.map +1 -0
- package/dest/local-network/local-network.js +205 -0
- package/dest/local-network/sponsored_fpc.d.ts +5 -0
- package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
- package/dest/local-network/sponsored_fpc.js +18 -0
- package/dest/mnemonic.d.ts +2 -0
- package/dest/mnemonic.d.ts.map +1 -0
- package/dest/mnemonic.js +1 -0
- package/dest/splash.d.ts +3 -0
- package/dest/splash.d.ts.map +1 -0
- package/dest/splash.js +2 -0
- package/dest/testing/cheat_codes.d.ts +37 -0
- package/dest/testing/cheat_codes.d.ts.map +1 -0
- package/dest/testing/cheat_codes.js +36 -0
- package/dest/testing/epoch_test_settler.d.ts +19 -0
- package/dest/testing/epoch_test_settler.d.ts.map +1 -0
- package/dest/testing/epoch_test_settler.js +42 -0
- package/dest/testing/index.d.ts +6 -0
- package/dest/testing/index.d.ts.map +1 -0
- package/dest/testing/index.js +5 -0
- package/dest/testing/local-network.d.ts +51 -0
- package/dest/testing/local-network.d.ts.map +1 -0
- package/dest/testing/local-network.js +60 -0
- package/dest/testing/token_allowed_setup.d.ts +12 -0
- package/dest/testing/token_allowed_setup.d.ts.map +1 -0
- package/dest/testing/token_allowed_setup.js +24 -0
- package/package.json +125 -0
- package/scripts/add_crate.sh +53 -0
- package/scripts/aztec.sh +73 -0
- package/scripts/init.sh +39 -0
- package/scripts/new.sh +83 -0
- package/scripts/setup_workspace.sh +69 -0
- package/scripts/templates/blank/contract/Nargo.toml +6 -0
- package/scripts/templates/blank/contract/src/main.nr +10 -0
- package/scripts/templates/blank/test/Nargo.toml +7 -0
- package/scripts/templates/blank/test/src/lib.nr +11 -0
- package/scripts/templates/counter/contract/Nargo.toml +7 -0
- package/scripts/templates/counter/contract/src/main.nr +48 -0
- package/scripts/templates/counter/test/Nargo.toml +7 -0
- package/scripts/templates/counter/test/src/lib.nr +32 -0
- package/src/bin/index.ts +73 -0
- package/src/cli/admin_api_key_store.ts +127 -0
- package/src/cli/aztec_start_action.ts +173 -0
- package/src/cli/aztec_start_options.ts +333 -0
- package/src/cli/cli.ts +55 -0
- package/src/cli/cmds/compile.ts +205 -0
- package/src/cli/cmds/migrate_ha_db.ts +42 -0
- package/src/cli/cmds/profile.ts +25 -0
- package/src/cli/cmds/profile_flamegraph.ts +64 -0
- package/src/cli/cmds/profile_gates.ts +84 -0
- package/src/cli/cmds/profile_utils.ts +58 -0
- package/src/cli/cmds/prover.ts +41 -0
- package/src/cli/cmds/standby.ts +183 -0
- package/src/cli/cmds/start_bot.ts +78 -0
- package/src/cli/cmds/start_node.ts +199 -0
- package/src/cli/cmds/start_p2p_bootstrap.ts +37 -0
- package/src/cli/cmds/start_prover_agent.ts +77 -0
- package/src/cli/cmds/start_prover_broker.ts +69 -0
- package/src/cli/cmds/start_txe.ts +17 -0
- package/src/cli/cmds/utils/artifacts.ts +49 -0
- package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
- package/src/cli/cmds/utils/needs_recompile.ts +98 -0
- package/src/cli/cmds/utils/spawn.ts +16 -0
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +75 -0
- package/src/cli/index.ts +1 -0
- package/src/cli/preload_crs.ts +7 -0
- package/src/cli/util.ts +310 -0
- package/src/cli/versioning.ts +13 -0
- package/src/examples/token.ts +77 -0
- package/src/examples/util.ts +42 -0
- package/src/index.ts +6 -0
- package/src/local-network/auth_registry.ts +19 -0
- package/src/local-network/banana_fpc.ts +89 -0
- package/src/local-network/index.ts +7 -0
- package/src/local-network/local-network.ts +254 -0
- package/src/local-network/sponsored_fpc.ts +26 -0
- package/src/mnemonic.ts +1 -0
- package/src/splash.ts +10 -0
- package/src/testing/cheat_codes.ts +48 -0
- package/src/testing/epoch_test_settler.ts +47 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/local-network.ts +96 -0
- package/src/testing/token_allowed_setup.ts +26 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
2
|
+
import { DEV_VERSION, getPackageVersion } from '@aztec-labs/stdlib/update-checker';
|
|
3
|
+
import TOML from '@iarna/toml';
|
|
4
|
+
import { readFile } from 'fs/promises';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
|
|
7
|
+
import { collectCrateDirs } from './collect_crate_dirs.js';
|
|
8
|
+
|
|
9
|
+
/** Returns true if the given git URL points to the AztecProtocol/aztec-nr repository. */
|
|
10
|
+
function isAztecNrGitUrl(gitUrl: string): boolean {
|
|
11
|
+
let url: URL;
|
|
12
|
+
try {
|
|
13
|
+
url = new URL(gitUrl);
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (url.hostname !== 'github.com') {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const repoPath = url.pathname
|
|
21
|
+
.replace(/^\//, '')
|
|
22
|
+
.replace(/\.git$/, '')
|
|
23
|
+
.replace(/\/$/, '');
|
|
24
|
+
return repoPath === 'AztecProtocol/aztec-nr';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Warns if any aztec-nr git dependency in a crate's Nargo.toml has a tag that doesn't match the CLI version. */
|
|
28
|
+
export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string): Promise<void> {
|
|
29
|
+
const version = cliVersion ?? getPackageVersion();
|
|
30
|
+
if (version === DEV_VERSION) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const expectedTag = `v${version}`;
|
|
35
|
+
const mismatches: { file: string; depName: string; tag: string }[] = [];
|
|
36
|
+
|
|
37
|
+
const crateDirs = await collectCrateDirs('.', { skipGitDeps: true });
|
|
38
|
+
|
|
39
|
+
for (const dir of crateDirs) {
|
|
40
|
+
const tomlPath = join(dir, 'Nargo.toml');
|
|
41
|
+
let content: string;
|
|
42
|
+
try {
|
|
43
|
+
content = await readFile(tomlPath, 'utf-8');
|
|
44
|
+
} catch {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const parsed = TOML.parse(content) as Record<string, any>;
|
|
49
|
+
const deps = (parsed.dependencies as Record<string, any>) ?? {};
|
|
50
|
+
|
|
51
|
+
for (const [depName, dep] of Object.entries(deps)) {
|
|
52
|
+
// Skip non-object deps (e.g. malformed entries) and anything that isn't a tagged git dep.
|
|
53
|
+
if (!dep || typeof dep !== 'object' || typeof dep.git !== 'string' || typeof dep.tag !== 'string') {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
// Only flag deps that are sourced from the aztec-nr repo.
|
|
57
|
+
if (!isAztecNrGitUrl(dep.git)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (dep.tag !== expectedTag) {
|
|
61
|
+
mismatches.push({ file: tomlPath, depName, tag: dep.tag });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (mismatches.length > 0) {
|
|
67
|
+
const details = mismatches.map(m => ` ${m.file} — ${m.depName} (${m.tag})`).join('\n');
|
|
68
|
+
log(
|
|
69
|
+
`WARNING: Aztec dependency version mismatch detected.\n` +
|
|
70
|
+
`The following aztec-nr dependencies do not match the CLI version (${expectedTag}):\n` +
|
|
71
|
+
`${details}\n\n` +
|
|
72
|
+
`See https://docs.aztec.network/errors/9 for how to update your dependencies.`,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
}
|
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './cli.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LogFn, Logger } from '@aztec-labs/foundation/log';
|
|
2
|
+
|
|
3
|
+
import { preloadCrsDataForServerSideProving } from './util.js';
|
|
4
|
+
|
|
5
|
+
export async function preloadCrs(_options: any, userLog: LogFn, _debugLogger: Logger) {
|
|
6
|
+
await preloadCrsDataForServerSideProving({ realProofs: true }, userLog);
|
|
7
|
+
}
|
package/src/cli/util.ts
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import type { AztecNodeConfig } from '@aztec-labs/aztec-node';
|
|
2
|
+
import type { AccountManager } from '@aztec-labs/aztec.js/wallet';
|
|
3
|
+
import type { ConfigMappingsType } from '@aztec-labs/foundation/config';
|
|
4
|
+
import { jsonStringify } from '@aztec-labs/foundation/json-rpc';
|
|
5
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
6
|
+
import type { ProverConfig } from '@aztec-labs/stdlib/interfaces/server';
|
|
7
|
+
import type { EmbeddedWallet } from '@aztec-labs/wallets/embedded';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import type { Command } from 'commander';
|
|
10
|
+
|
|
11
|
+
import { type AztecStartOption, aztecStartOptions } from './aztec_start_options.js';
|
|
12
|
+
|
|
13
|
+
export const enum ExitCode {
|
|
14
|
+
SUCCESS = 0,
|
|
15
|
+
ERROR = 1,
|
|
16
|
+
ROLLUP_UPGRADE = 78, // EX_CONFIG from FreeBSD (https://man.freebsd.org/cgi/man.cgi?query=sysexits)
|
|
17
|
+
VERSION_UPGRADE = 79, // prev + 1 because there's nothing better
|
|
18
|
+
// 128 + int(SIGNAL)
|
|
19
|
+
SIGHUP = 129,
|
|
20
|
+
SIGINT = 130,
|
|
21
|
+
SIGQUIT = 131,
|
|
22
|
+
SIGTERM = 143,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let shutdownPromise: Promise<never> | undefined;
|
|
26
|
+
export function shutdown(logFn: LogFn, exitCode: ExitCode, cb?: Array<() => Promise<void>>): Promise<never> {
|
|
27
|
+
if (shutdownPromise) {
|
|
28
|
+
logFn('Already shutting down.');
|
|
29
|
+
return shutdownPromise;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
logFn('Shutting down...', { exitCode });
|
|
33
|
+
if (cb) {
|
|
34
|
+
shutdownPromise = Promise.allSettled(cb.map(fn => fn())).then(() => process.exit(exitCode));
|
|
35
|
+
} else {
|
|
36
|
+
// synchronously shuts down the process
|
|
37
|
+
// no need to set shutdownPromise on this branch of the if statement because no more code will be executed
|
|
38
|
+
process.exit(exitCode);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return shutdownPromise;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function isShuttingDown(): boolean {
|
|
45
|
+
return shutdownPromise !== undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Stops the node's subsystems (via the registered signal handlers) without exiting the process, leaving
|
|
50
|
+
* the HTTP health server listening so K8s liveness/readiness probes keep passing. Unlike {@link shutdown}
|
|
51
|
+
* this deliberately does not latch `shutdownPromise` or call `process.exit`; instead it re-arms
|
|
52
|
+
* SIGTERM/SIGINT so a later K8s pod deletion still terminates the wound-down pod with a clean exit.
|
|
53
|
+
*/
|
|
54
|
+
export async function softShutdown(logFn: LogFn, signalHandlers: Array<() => Promise<void>>): Promise<void> {
|
|
55
|
+
logFn('Canonical rollup upgrade detected: stopping subsystems, health server stays up.', {
|
|
56
|
+
exitCode: ExitCode.ROLLUP_UPGRADE,
|
|
57
|
+
});
|
|
58
|
+
await Promise.allSettled(signalHandlers.map(fn => fn()));
|
|
59
|
+
for (const sig of ['SIGTERM', 'SIGINT'] as const) {
|
|
60
|
+
process.removeAllListeners(sig);
|
|
61
|
+
process.once(sig, () => process.exit(ExitCode.ROLLUP_UPGRADE));
|
|
62
|
+
}
|
|
63
|
+
logFn('Subsystems stopped due to rollup upgrade. Health server remains active.');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise<void>>) => {
|
|
67
|
+
const signals = [
|
|
68
|
+
['SIGINT', ExitCode.SIGINT],
|
|
69
|
+
['SIGTERM', ExitCode.SIGTERM],
|
|
70
|
+
['SIGHUP', ExitCode.SIGHUP],
|
|
71
|
+
['SIQUIT', ExitCode.SIGQUIT],
|
|
72
|
+
] as const;
|
|
73
|
+
|
|
74
|
+
for (const [signal, exitCode] of signals) {
|
|
75
|
+
process.removeAllListeners(signal);
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
77
|
+
process.once(signal, () => shutdown(logFn, exitCode, cb));
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Creates logs for the initial accounts
|
|
83
|
+
* @param accounts - The initial accounts
|
|
84
|
+
* @param wallet - A EmbeddedWallet instance to get the registered accounts
|
|
85
|
+
* @returns A string array containing the initial accounts details
|
|
86
|
+
*/
|
|
87
|
+
export async function createAccountLogs(accountManagers: AccountManager[], wallet: EmbeddedWallet) {
|
|
88
|
+
const registeredAccounts = await wallet.getAccounts();
|
|
89
|
+
const accountLogStrings = [`Initial Accounts:\n\n`];
|
|
90
|
+
for (const accountManager of accountManagers) {
|
|
91
|
+
const account = await accountManager.getAccount();
|
|
92
|
+
const completeAddress = account.getCompleteAddress();
|
|
93
|
+
if (registeredAccounts.find(a => a.item.equals(completeAddress.address))) {
|
|
94
|
+
accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
|
|
95
|
+
accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
|
|
96
|
+
accountLogStrings.push(` Secret Key: ${accountManager.getSecretKey().toString()}\n`);
|
|
97
|
+
accountLogStrings.push(` Master nullifier public key hash: ${completeAddress.publicKeys.npkMHash.toString()}\n`);
|
|
98
|
+
accountLogStrings.push(` Master incoming viewing public key: ${completeAddress.publicKeys.ivpkM.toString()}\n\n`);
|
|
99
|
+
accountLogStrings.push(
|
|
100
|
+
` Master outgoing viewing public key hash: ${completeAddress.publicKeys.ovpkMHash.toString()}\n\n`,
|
|
101
|
+
);
|
|
102
|
+
accountLogStrings.push(` Master tagging public key hash: ${completeAddress.publicKeys.tpkMHash.toString()}\n\n`);
|
|
103
|
+
accountLogStrings.push(
|
|
104
|
+
` Master message-signing public key hash: ${completeAddress.publicKeys.mspkMHash.toString()}\n\n`,
|
|
105
|
+
);
|
|
106
|
+
accountLogStrings.push(
|
|
107
|
+
` Master fallback public key hash: ${completeAddress.publicKeys.fbpkMHash.toString()}\n\n`,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return accountLogStrings;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function getMaxLengths(sections: { [key: string]: AztecStartOption[] }): [number, number] {
|
|
115
|
+
let maxFlagLength = 0;
|
|
116
|
+
let maxDefaultLength = 0;
|
|
117
|
+
|
|
118
|
+
Object.values(sections).forEach(options => {
|
|
119
|
+
options.forEach(option => {
|
|
120
|
+
if (option.flag.length > maxFlagLength) {
|
|
121
|
+
maxFlagLength = option.flag.length;
|
|
122
|
+
}
|
|
123
|
+
const defaultLength = option.defaultValue ? option.defaultValue.length : 0;
|
|
124
|
+
if (defaultLength > maxDefaultLength) {
|
|
125
|
+
maxDefaultLength = defaultLength;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
return [maxFlagLength + 1, maxDefaultLength + 1];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function formatHelpLine(
|
|
134
|
+
option: string,
|
|
135
|
+
defaultValue: string,
|
|
136
|
+
envVar: string,
|
|
137
|
+
maxOptionLength: number,
|
|
138
|
+
maxDefaultLength: number,
|
|
139
|
+
): string {
|
|
140
|
+
const paddedOption = option.padEnd(maxOptionLength + 2, ' ');
|
|
141
|
+
const paddedDefault = defaultValue.padEnd(maxDefaultLength + 2, ' ');
|
|
142
|
+
|
|
143
|
+
return `${chalk.cyan(paddedOption)}${chalk.yellow(paddedDefault)}${chalk.green(envVar)}`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const getDefaultOrEnvValue = (opt: AztecStartOption) => {
|
|
147
|
+
let val;
|
|
148
|
+
|
|
149
|
+
// if the option is set in the environment, use that
|
|
150
|
+
if (opt.env) {
|
|
151
|
+
val = process.env[opt.env];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// if we have fallback env vars, check those
|
|
155
|
+
if (!val && opt.fallback && opt.fallback.length > 0) {
|
|
156
|
+
for (const fallback of opt.fallback) {
|
|
157
|
+
val = process.env[fallback];
|
|
158
|
+
if (val) {
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// if we have a value, optionally parse it and return
|
|
165
|
+
if (val) {
|
|
166
|
+
if (opt.parseVal) {
|
|
167
|
+
return opt.parseVal(val);
|
|
168
|
+
}
|
|
169
|
+
return val;
|
|
170
|
+
} else if (opt.defaultValue !== undefined) {
|
|
171
|
+
return opt.defaultValue;
|
|
172
|
+
}
|
|
173
|
+
return undefined;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// Function to add options dynamically
|
|
177
|
+
export const addOptions = (cmd: Command, options: AztecStartOption[]) => {
|
|
178
|
+
options.forEach(opt => {
|
|
179
|
+
cmd.option(
|
|
180
|
+
opt.flag,
|
|
181
|
+
`${opt.description} (default: ${opt.defaultValue}) ($${opt.env})`,
|
|
182
|
+
opt.parseVal ? opt.parseVal : val => val,
|
|
183
|
+
getDefaultOrEnvValue(opt),
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export const printAztecStartHelpText = () => {
|
|
189
|
+
const helpTextLines: string[] = [''];
|
|
190
|
+
const [maxFlagLength, maxDefaultLength] = getMaxLengths(aztecStartOptions);
|
|
191
|
+
|
|
192
|
+
Object.keys(aztecStartOptions).forEach(category => {
|
|
193
|
+
helpTextLines.push(chalk.bold.blue(` ${category}`));
|
|
194
|
+
helpTextLines.push('');
|
|
195
|
+
|
|
196
|
+
aztecStartOptions[category].forEach(opt => {
|
|
197
|
+
const defaultValueText =
|
|
198
|
+
opt.defaultValue || (Array.isArray(opt.defaultValue) && opt.defaultValue.length > 0)
|
|
199
|
+
? `(default: ${opt.printDefault ? opt.printDefault(opt.defaultValue) : opt.defaultValue})`
|
|
200
|
+
: '';
|
|
201
|
+
const envVarText = opt.env ? `($${opt.env})` : '';
|
|
202
|
+
const flagText = `${opt.flag}`;
|
|
203
|
+
|
|
204
|
+
const paddedText = formatHelpLine(flagText, defaultValueText, envVarText, maxFlagLength, maxDefaultLength);
|
|
205
|
+
|
|
206
|
+
helpTextLines.push(` ${paddedText}`);
|
|
207
|
+
helpTextLines.push(` ${chalk.white(opt.description)}`);
|
|
208
|
+
helpTextLines.push('');
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return helpTextLines.join('\n');
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Extracts namespaced options from a key-value map.
|
|
217
|
+
* @param options - Key-value map of options.
|
|
218
|
+
* @param namespace - The namespace to extract.
|
|
219
|
+
* @returns Key-value map of namespaced options.
|
|
220
|
+
*/
|
|
221
|
+
export const extractNamespacedOptions = (options: Record<string, any>, namespace: string) => {
|
|
222
|
+
const extract = `${namespace}.`;
|
|
223
|
+
const namespacedOptions: Record<string, any> = {};
|
|
224
|
+
for (const key in options) {
|
|
225
|
+
if (key.startsWith(extract)) {
|
|
226
|
+
namespacedOptions[key.replace(extract, '')] = options[key];
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return namespacedOptions;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Extracts relevant options from a key-value map.
|
|
234
|
+
* @template T - The type of the relevant options.
|
|
235
|
+
* @param options - Key-value map of options.
|
|
236
|
+
* @param mappings - The mappings to extract.
|
|
237
|
+
* @param namespace - The namespace to extract for.
|
|
238
|
+
* @returns Key-value map of relevant options.
|
|
239
|
+
*/
|
|
240
|
+
export const extractRelevantOptions = <T>(
|
|
241
|
+
options: Record<string, any>,
|
|
242
|
+
mappings: ConfigMappingsType<T>,
|
|
243
|
+
namespace: string,
|
|
244
|
+
): T => {
|
|
245
|
+
const relevantOptions: T = {} as T;
|
|
246
|
+
|
|
247
|
+
// Iterate over each key in the options
|
|
248
|
+
Object.keys(options).forEach(optionKey => {
|
|
249
|
+
const keyParts = optionKey.split('.');
|
|
250
|
+
const optionNamespace = keyParts.length > 1 ? keyParts[0] : '';
|
|
251
|
+
const mainKey = keyParts.length > 1 ? keyParts[1] : keyParts[0];
|
|
252
|
+
|
|
253
|
+
// Check if the key exists in the mappings
|
|
254
|
+
if (mainKey in mappings) {
|
|
255
|
+
// Check for duplicates in the options
|
|
256
|
+
const duplicates = Object.keys(options).filter(optKey => {
|
|
257
|
+
const optKeyParts = optKey.split('.');
|
|
258
|
+
return optKeyParts[1] === mainKey || optKeyParts[0] === mainKey;
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// If duplicates are found, use the namespace to differentiate
|
|
262
|
+
if (duplicates.length > 1) {
|
|
263
|
+
if (namespace === optionNamespace) {
|
|
264
|
+
relevantOptions[mainKey as keyof T] = options[optionKey];
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
// If no duplicates, extract the value without considering the namespace
|
|
268
|
+
relevantOptions[mainKey as keyof T] = options[optionKey];
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
return relevantOptions;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Downloads just enough points to be able to verify Chonk proofs.
|
|
278
|
+
* @param opts - Whether proof are to be verifier
|
|
279
|
+
* @param log - Logging function
|
|
280
|
+
*/
|
|
281
|
+
export async function preloadCrsDataForVerifying(
|
|
282
|
+
{ realProofs }: Pick<AztecNodeConfig, 'realProofs'>,
|
|
283
|
+
log: LogFn,
|
|
284
|
+
): Promise<void> {
|
|
285
|
+
if (realProofs) {
|
|
286
|
+
const { Crs, GrumpkinCrs } = await import('@aztec/bb.js');
|
|
287
|
+
await Promise.all([Crs.new(2 ** 1, undefined, log), GrumpkinCrs.new(2 ** 16, undefined, log)]);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Downloads enough points to be able to prove every server-side circuit
|
|
293
|
+
* @param opts - Whether real proof are to be generated
|
|
294
|
+
* @param log - Logging function
|
|
295
|
+
*/
|
|
296
|
+
export async function preloadCrsDataForServerSideProving(
|
|
297
|
+
{ realProofs }: Pick<ProverConfig, 'realProofs'>,
|
|
298
|
+
log: LogFn,
|
|
299
|
+
): Promise<void> {
|
|
300
|
+
if (realProofs) {
|
|
301
|
+
const { Crs, GrumpkinCrs } = await import('@aztec/bb.js');
|
|
302
|
+
await Promise.all([Crs.new(2 ** 25, undefined, log), GrumpkinCrs.new(2 ** 18, undefined, log)]);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export function stringifyConfig(config: object): string {
|
|
307
|
+
return Object.entries(config)
|
|
308
|
+
.map(([key, value]) => `${key}=${jsonStringify(value)}`)
|
|
309
|
+
.join(' ');
|
|
310
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getVKTreeRoot } from '@aztec-labs/noir-protocol-circuits-types/vk-tree';
|
|
2
|
+
import { protocolContractsHash } from '@aztec-labs/protocol-contracts';
|
|
3
|
+
import type { ChainConfig } from '@aztec-labs/stdlib/config';
|
|
4
|
+
import { type ComponentsVersions, getComponentsVersionsFromConfig } from '@aztec-labs/stdlib/versioning';
|
|
5
|
+
|
|
6
|
+
export function getVersions(config?: ChainConfig): Partial<ComponentsVersions> {
|
|
7
|
+
return config
|
|
8
|
+
? getComponentsVersionsFromConfig(config, protocolContractsHash, getVKTreeRoot())
|
|
9
|
+
: {
|
|
10
|
+
l2CircuitsVkTreeRoot: getVKTreeRoot().toString(),
|
|
11
|
+
l2ProtocolContractsHash: protocolContractsHash.toString(),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { getInitialTestAccountsData } from '@aztec-labs/accounts/testing';
|
|
2
|
+
import { createAztecNodeClient } from '@aztec-labs/aztec.js/node';
|
|
3
|
+
import { createLogger } from '@aztec-labs/foundation/log';
|
|
4
|
+
import { TokenContract } from '@aztec-labs/noir-contracts.js/Token';
|
|
5
|
+
import { EmbeddedWallet } from '@aztec-labs/wallets/embedded';
|
|
6
|
+
|
|
7
|
+
const logger = createLogger('example:token');
|
|
8
|
+
|
|
9
|
+
const nodeUrl = 'http://localhost:8080';
|
|
10
|
+
|
|
11
|
+
const node = createAztecNodeClient(nodeUrl);
|
|
12
|
+
|
|
13
|
+
const ALICE_MINT_BALANCE = 333n;
|
|
14
|
+
const TRANSFER_AMOUNT = 33n;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Main function.
|
|
18
|
+
*/
|
|
19
|
+
async function main() {
|
|
20
|
+
logger.info('Running token contract test on HTTP interface.');
|
|
21
|
+
|
|
22
|
+
const wallet = await EmbeddedWallet.create(node);
|
|
23
|
+
|
|
24
|
+
// During local network setup we create a few initializerless accounts. Below we add them to our wallet.
|
|
25
|
+
const [aliceInitialAccountData, bobInitialAccountData] = await getInitialTestAccountsData();
|
|
26
|
+
await wallet.createSchnorrInitializerlessAccount(
|
|
27
|
+
aliceInitialAccountData.secret,
|
|
28
|
+
aliceInitialAccountData.salt,
|
|
29
|
+
aliceInitialAccountData.signingKey,
|
|
30
|
+
);
|
|
31
|
+
await wallet.createSchnorrInitializerlessAccount(
|
|
32
|
+
bobInitialAccountData.secret,
|
|
33
|
+
bobInitialAccountData.salt,
|
|
34
|
+
bobInitialAccountData.signingKey,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const alice = aliceInitialAccountData.address;
|
|
38
|
+
const bob = bobInitialAccountData.address;
|
|
39
|
+
|
|
40
|
+
logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
|
|
41
|
+
|
|
42
|
+
logger.info('Deploying Token...');
|
|
43
|
+
const { contract: token } = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({
|
|
44
|
+
from: alice,
|
|
45
|
+
});
|
|
46
|
+
logger.info('Token deployed');
|
|
47
|
+
|
|
48
|
+
// Mint tokens to Alice
|
|
49
|
+
logger.info(`Minting ${ALICE_MINT_BALANCE} more coins to Alice...`);
|
|
50
|
+
await token.methods.mint_to_private(alice, ALICE_MINT_BALANCE).send({ from: alice });
|
|
51
|
+
|
|
52
|
+
logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
|
|
53
|
+
|
|
54
|
+
const { result: balanceAfterMint } = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
55
|
+
logger.info(`Tokens successfully minted. New Alice's balance: ${balanceAfterMint}`);
|
|
56
|
+
|
|
57
|
+
// We will now transfer tokens from Alice to Bob
|
|
58
|
+
logger.info(`Transferring ${TRANSFER_AMOUNT} tokens from Alice to Bob...`);
|
|
59
|
+
await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice });
|
|
60
|
+
|
|
61
|
+
// Check the new balances
|
|
62
|
+
const { result: aliceBalance } = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
63
|
+
logger.info(`Alice's balance ${aliceBalance}`);
|
|
64
|
+
|
|
65
|
+
const { result: bobBalance } = await token.methods.balance_of_private(bob).simulate({ from: bob });
|
|
66
|
+
logger.info(`Bob's balance ${bobBalance}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
main()
|
|
70
|
+
.then(() => {
|
|
71
|
+
logger.info('Finished running successfully.');
|
|
72
|
+
process.exit(0);
|
|
73
|
+
})
|
|
74
|
+
.catch(err => {
|
|
75
|
+
logger.error('Error in main fn: ', err);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec-labs/aztec.js/addresses';
|
|
2
|
+
import type { ExtendedViemWalletClient } from '@aztec-labs/ethereum/types';
|
|
3
|
+
import { jsonStringify } from '@aztec-labs/foundation/json-rpc';
|
|
4
|
+
import type { Abi, Narrow } from 'abitype';
|
|
5
|
+
import type { Hex } from 'viem';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to deploy ETH contracts.
|
|
9
|
+
* @param l1Client - A viem WalletClient extended with public actions.
|
|
10
|
+
* @param abi - The ETH contract's ABI (as abitype's Abi).
|
|
11
|
+
* @param bytecode - The ETH contract's bytecode.
|
|
12
|
+
* @param args - Constructor arguments for the contract.
|
|
13
|
+
* @returns The ETH address the contract was deployed to.
|
|
14
|
+
*/
|
|
15
|
+
export async function deployL1Contract(
|
|
16
|
+
l1Client: ExtendedViemWalletClient,
|
|
17
|
+
abi: Narrow<Abi | readonly unknown[]>,
|
|
18
|
+
bytecode: Hex,
|
|
19
|
+
args: readonly unknown[] = [],
|
|
20
|
+
): Promise<EthAddress> {
|
|
21
|
+
const hash = await l1Client.deployContract({
|
|
22
|
+
abi,
|
|
23
|
+
bytecode,
|
|
24
|
+
args,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const receipt = await l1Client.waitForTransactionReceipt({ hash });
|
|
28
|
+
const contractAddress = receipt.contractAddress;
|
|
29
|
+
if (!contractAddress) {
|
|
30
|
+
throw new Error(`No contract address found in receipt: ${jsonStringify(receipt)}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return EthAddress.fromString(receipt.contractAddress!);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Sleep for a given number of milliseconds.
|
|
38
|
+
* @param ms - the number of milliseconds to sleep for
|
|
39
|
+
*/
|
|
40
|
+
export function delay(ms: number): Promise<void> {
|
|
41
|
+
return new Promise<void>(resolve => setTimeout(resolve, ms));
|
|
42
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { WaitOpts } from '@aztec-labs/aztec.js/contracts';
|
|
2
|
+
import { publishContractClass, publishInstance } from '@aztec-labs/aztec.js/deployment';
|
|
3
|
+
import type { Wallet } from '@aztec-labs/aztec.js/wallet';
|
|
4
|
+
import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec-labs/standard-contracts/auth-registry';
|
|
5
|
+
import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
6
|
+
|
|
7
|
+
export async function publishStandardAuthRegistry(
|
|
8
|
+
wallet: Wallet,
|
|
9
|
+
from: AztecAddress,
|
|
10
|
+
waitOpts?: WaitOpts,
|
|
11
|
+
): Promise<void> {
|
|
12
|
+
const { instance, contractClass } = await getStandardAuthRegistry();
|
|
13
|
+
if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
|
|
14
|
+
await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from, wait: waitOpts });
|
|
15
|
+
}
|
|
16
|
+
if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
|
|
17
|
+
await publishInstance(wallet, instance).send({ from, wait: waitOpts });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type InitialAccountData, getInitialTestAccountsData } from '@aztec-labs/accounts/testing';
|
|
2
|
+
import type { WaitOpts } from '@aztec-labs/aztec.js/contracts';
|
|
3
|
+
import type { Wallet } from '@aztec-labs/aztec.js/wallet';
|
|
4
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
5
|
+
import type { LogFn } from '@aztec-labs/foundation/log';
|
|
6
|
+
import { FPCContract } from '@aztec-labs/noir-contracts.js/FPC';
|
|
7
|
+
import { TokenContract } from '@aztec-labs/noir-contracts.js/Token';
|
|
8
|
+
import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
9
|
+
import {
|
|
10
|
+
type ContractInstanceWithAddress,
|
|
11
|
+
getContractInstanceFromInstantiationParams,
|
|
12
|
+
} from '@aztec-labs/stdlib/contract';
|
|
13
|
+
|
|
14
|
+
const BANANA_COIN_SALT = new Fr(0);
|
|
15
|
+
const bananaCoinArgs = {
|
|
16
|
+
name: 'BC',
|
|
17
|
+
symbol: 'BC',
|
|
18
|
+
decimal: 18n,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const BANANA_FPC_SALT = new Fr(0);
|
|
22
|
+
|
|
23
|
+
function getBananaAdmin(initialAccounts: InitialAccountData[]): AztecAddress {
|
|
24
|
+
return initialAccounts[0]?.address ?? AztecAddress.ZERO;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function getBananaCoinInstance(initialAccounts: InitialAccountData[]): Promise<ContractInstanceWithAddress> {
|
|
28
|
+
const admin = getBananaAdmin(initialAccounts);
|
|
29
|
+
return await getContractInstanceFromInstantiationParams(TokenContract.artifact, {
|
|
30
|
+
constructorArgs: [admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal],
|
|
31
|
+
salt: BANANA_COIN_SALT,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function getBananaCoinAddress(initialAccounts: InitialAccountData[]) {
|
|
36
|
+
return (await getBananaCoinInstance(initialAccounts)).address;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function getBananaFPCInstance(initialAccounts: InitialAccountData[]): Promise<ContractInstanceWithAddress> {
|
|
40
|
+
const bananaCoin = await getBananaCoinAddress(initialAccounts);
|
|
41
|
+
const admin = getBananaAdmin(initialAccounts);
|
|
42
|
+
return await getContractInstanceFromInstantiationParams(FPCContract.artifact, {
|
|
43
|
+
constructorArgs: [bananaCoin, admin],
|
|
44
|
+
salt: BANANA_FPC_SALT,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function getBananaFPCAddress(initialAccounts: InitialAccountData[]) {
|
|
49
|
+
return (await getBananaFPCInstance(initialAccounts)).address;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function setupBananaFPC(
|
|
53
|
+
initialAccounts: InitialAccountData[],
|
|
54
|
+
wallet: Wallet,
|
|
55
|
+
log: LogFn,
|
|
56
|
+
waitOpts?: WaitOpts,
|
|
57
|
+
) {
|
|
58
|
+
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
59
|
+
const admin = getBananaAdmin(initialAccounts);
|
|
60
|
+
const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
|
|
61
|
+
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
|
|
62
|
+
salt: BANANA_COIN_SALT,
|
|
63
|
+
universalDeploy: true,
|
|
64
|
+
}).send({ from: admin, wait: waitOpts }),
|
|
65
|
+
FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
|
|
66
|
+
from: admin,
|
|
67
|
+
wait: waitOpts,
|
|
68
|
+
}),
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
log(`BananaCoin: ${bananaCoin.address}`);
|
|
72
|
+
log(`FPC: ${fpc.address}`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export async function registerDeployedBananaCoinInWalletAndGetAddress(wallet: Wallet) {
|
|
76
|
+
const initialAccounts = await getInitialTestAccountsData();
|
|
77
|
+
const bananaCoin = await getBananaCoinInstance(initialAccounts);
|
|
78
|
+
// The following is no-op if the contract is already registered
|
|
79
|
+
await wallet.registerContract(bananaCoin, TokenContract.artifact);
|
|
80
|
+
return bananaCoin.address;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export async function registerDeployedBananaFPCInWalletAndGetAddress(wallet: Wallet) {
|
|
84
|
+
const initialAccounts = await getInitialTestAccountsData();
|
|
85
|
+
const fpc = await getBananaFPCInstance(initialAccounts);
|
|
86
|
+
// The following is no-op if the contract is already registered
|
|
87
|
+
await wallet.registerContract(fpc, FPCContract.artifact);
|
|
88
|
+
return fpc.address;
|
|
89
|
+
}
|