@aztec/aztec 0.0.1-commit.f504929 → 0.0.1-commit.f5a9928
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/index.js +4 -2
- package/dest/cli/aztec_start_action.d.ts +1 -1
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +42 -33
- package/dest/cli/aztec_start_options.d.ts +2 -2
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +22 -18
- package/dest/cli/cmds/compile.d.ts +1 -1
- package/dest/cli/cmds/compile.d.ts.map +1 -1
- package/dest/cli/cmds/compile.js +35 -21
- package/dest/cli/cmds/profile.d.ts +1 -1
- package/dest/cli/cmds/profile.d.ts.map +1 -1
- package/dest/cli/cmds/profile.js +1 -1
- package/dest/cli/cmds/profile_flamegraph.d.ts +1 -1
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -1
- package/dest/cli/cmds/profile_flamegraph.js +2 -1
- package/dest/cli/cmds/profile_gates.d.ts +2 -2
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
- package/dest/cli/cmds/profile_gates.js +23 -4
- 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 +1 -1
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +8 -4
- package/dest/cli/cmds/start_node.d.ts +3 -2
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +36 -112
- package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_agent.js +5 -17
- package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_broker.js +22 -13
- package/dest/cli/cmds/start_txe.d.ts +2 -2
- package/dest/cli/cmds/start_txe.d.ts.map +1 -1
- package/dest/cli/cmds/start_txe.js +6 -5
- package/dest/cli/cmds/utils/artifacts.d.ts +6 -1
- package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -1
- 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/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/util.d.ts +9 -6
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +26 -94
- package/dest/deploy/bridging.d.ts +84 -0
- package/dest/deploy/bridging.d.ts.map +1 -0
- package/dest/deploy/bridging.js +121 -0
- package/dest/deploy/fees.d.ts +120 -0
- package/dest/deploy/fees.d.ts.map +1 -0
- package/dest/deploy/fees.js +278 -0
- package/dest/deploy/graph.d.ts +40 -0
- package/dest/deploy/graph.d.ts.map +1 -0
- package/dest/deploy/graph.js +120 -0
- package/dest/deploy/index.d.ts +19 -0
- package/dest/deploy/index.d.ts.map +1 -0
- package/dest/deploy/index.js +15 -0
- package/dest/deploy/reporter.d.ts +106 -0
- package/dest/deploy/reporter.d.ts.map +1 -0
- package/dest/deploy/reporter.js +76 -0
- package/dest/deploy/runner.d.ts +8 -0
- package/dest/deploy/runner.d.ts.map +1 -0
- package/dest/deploy/runner.js +886 -0
- package/dest/deploy/state.d.ts +19 -0
- package/dest/deploy/state.d.ts.map +1 -0
- package/dest/deploy/state.js +59 -0
- package/dest/deploy/types.d.ts +233 -0
- package/dest/deploy/types.d.ts.map +1 -0
- package/dest/deploy/types.js +9 -0
- package/dest/examples/token.js +3 -3
- 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 +3 -2
- package/dest/local-network/banana_fpc.d.ts.map +1 -1
- package/dest/local-network/banana_fpc.js +11 -7
- package/dest/local-network/local-network.d.ts +10 -32
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +60 -73
- package/dest/testing/cheat_codes.d.ts +17 -23
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +17 -43
- package/dest/testing/epoch_test_settler.d.ts +2 -2
- package/dest/testing/epoch_test_settler.d.ts.map +1 -1
- package/dest/testing/epoch_test_settler.js +6 -26
- package/dest/testing/index.d.ts +3 -2
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +2 -1
- 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 +38 -35
- package/scripts/add_crate.sh +11 -60
- package/scripts/aztec.sh +9 -2
- package/scripts/init.sh +5 -5
- package/scripts/new.sh +2 -2
- package/scripts/setup_workspace.sh +3 -2
- 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 +4 -2
- package/src/cli/aztec_start_action.ts +44 -27
- package/src/cli/aztec_start_options.ts +28 -25
- package/src/cli/cmds/compile.ts +41 -20
- package/src/cli/cmds/profile.ts +2 -1
- package/src/cli/cmds/profile_flamegraph.ts +2 -1
- package/src/cli/cmds/profile_gates.ts +22 -5
- package/src/cli/cmds/prover.ts +42 -0
- package/src/cli/cmds/standby.ts +184 -0
- package/src/cli/cmds/start_bot.ts +9 -6
- package/src/cli/cmds/start_node.ts +46 -131
- package/src/cli/cmds/start_prover_agent.ts +5 -8
- package/src/cli/cmds/start_prover_broker.ts +23 -24
- package/src/cli/cmds/start_txe.ts +7 -5
- package/src/cli/cmds/utils/artifacts.ts +5 -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/warn_if_aztec_version_mismatch.ts +76 -0
- package/src/cli/util.ts +26 -100
- package/src/deploy/bridging.ts +191 -0
- package/src/deploy/fees.ts +322 -0
- package/src/deploy/graph.ts +137 -0
- package/src/deploy/index.ts +41 -0
- package/src/deploy/reporter.ts +184 -0
- package/src/deploy/runner.ts +936 -0
- package/src/deploy/state.ts +66 -0
- package/src/deploy/types.ts +244 -0
- package/src/examples/token.ts +11 -3
- package/src/local-network/auth_registry.ts +19 -0
- package/src/local-network/banana_fpc.ts +12 -8
- package/src/local-network/local-network.ts +67 -83
- package/src/testing/cheat_codes.ts +18 -49
- package/src/testing/epoch_test_settler.ts +8 -32
- package/src/testing/index.ts +2 -1
- package/src/testing/local-network.ts +97 -0
- package/src/testing/token_allowed_setup.ts +26 -0
- package/dest/cli/cmds/start_archiver.d.ts +0 -9
- package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
- package/dest/cli/cmds/start_archiver.js +0 -48
- package/dest/cli/release_version.d.ts +0 -2
- package/dest/cli/release_version.d.ts.map +0 -1
- package/dest/cli/release_version.js +0 -14
- package/dest/testing/anvil_test_watcher.d.ts +0 -42
- package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
- package/dest/testing/anvil_test_watcher.js +0 -181
- package/src/cli/cmds/start_archiver.ts +0 -50
- package/src/cli/release_version.ts +0 -21
- package/src/testing/anvil_test_watcher.ts +0 -210
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resume state for {@link runDeployment}, persisted to `<stateDir>/state.json`.
|
|
3
|
+
*
|
|
4
|
+
* On-chain inventory makes contract deploys and actions idempotent on their own, but a
|
|
5
|
+
* bridge claim lives off-chain between "bridged on L1" and "claimed on L2". We persist
|
|
6
|
+
* pending claims here so a run that dies in that window resumes the claim instead of
|
|
7
|
+
* bridging again. Resolved addresses are stored too, as a human-readable record.
|
|
8
|
+
*
|
|
9
|
+
* The state file is keyed only by `stateDir`; point separate targets (local vs. a remote
|
|
10
|
+
* network) at separate `stateDir`s to keep their state apart.
|
|
11
|
+
*/
|
|
12
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
|
|
16
|
+
const deployStateSchema = z.object({
|
|
17
|
+
addresses: z.record(z.string(), z.string()).default({}),
|
|
18
|
+
pendingClaims: z
|
|
19
|
+
.record(z.string(), z.object({ claimAmount: z.string(), claimSecret: z.string(), messageLeafIndex: z.string() }))
|
|
20
|
+
.default({}),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export interface DeployState {
|
|
24
|
+
/** alias → resolved address (informational). */
|
|
25
|
+
addresses: Record<string, string>;
|
|
26
|
+
/** deployer address → a bridge claim that's been funded on L1 but not yet consumed. */
|
|
27
|
+
pendingClaims: Record<string, { claimAmount: string; claimSecret: string; messageLeafIndex: string }>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function statePath(dir: string): string {
|
|
31
|
+
return join(dir, 'state.json');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Loads the persisted state, or an empty one when no file exists yet. A file that exists but can't
|
|
36
|
+
* be read or doesn't match the schema throws instead of being treated as empty: silently starting
|
|
37
|
+
* fresh would discard `pendingClaims`, and a lost claim secret strands the bridged funds forever.
|
|
38
|
+
*/
|
|
39
|
+
export function loadState(dir: string): DeployState {
|
|
40
|
+
let raw: string;
|
|
41
|
+
try {
|
|
42
|
+
raw = readFileSync(statePath(dir), 'utf8');
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
45
|
+
return { addresses: {}, pendingClaims: {} };
|
|
46
|
+
}
|
|
47
|
+
throw new Error(`Failed to read deploy state at ${statePath(dir)}.`, { cause: error });
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
return deployStateSchema.parse(JSON.parse(raw));
|
|
51
|
+
} catch (error) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`Corrupt deploy state at ${statePath(dir)}. Fix or remove it manually — removing abandons any pending ` +
|
|
54
|
+
`bridge claims recorded in it (their funds become unclaimable).`,
|
|
55
|
+
{ cause: error },
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Persists atomically (write + rename), so a crash mid-write can't truncate the previous state. */
|
|
61
|
+
export function saveState(dir: string, state: DeployState): void {
|
|
62
|
+
mkdirSync(dir, { recursive: true });
|
|
63
|
+
const path = statePath(dir);
|
|
64
|
+
writeFileSync(`${path}.tmp`, JSON.stringify(state, null, 2));
|
|
65
|
+
renameSync(`${path}.tmp`, path);
|
|
66
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declarative deployment spec — the "what", not the "how".
|
|
3
|
+
*
|
|
4
|
+
* A {@link DeploymentSpec} is one graph of {@link StepSpec | steps} — each either a `contract`
|
|
5
|
+
* (published on-chain, or registered privately in the PXE) or an `action` (a tx) — sent from named
|
|
6
|
+
* {@link AccountSpec | accounts}. {@link runDeployment} resolves deterministic addresses upfront,
|
|
7
|
+
* inventories what's on-chain, funds the accounts, and executes only what's missing in dependency
|
|
8
|
+
* order — idempotently and resumably.
|
|
9
|
+
*/
|
|
10
|
+
import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
11
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
12
|
+
import type { ContractBase, ContractFunctionInteraction } from '@aztec/aztec.js/contracts';
|
|
13
|
+
import type { Fr } from '@aztec/aztec.js/fields';
|
|
14
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
15
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
16
|
+
|
|
17
|
+
import type { DeployReporter } from './reporter.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* How txs are paid.
|
|
21
|
+
* - `sponsored`: a SponsoredFPC pays (the local-network default).
|
|
22
|
+
* - `fee-juice`: the account pays from its own Fee Juice; if below `threshold` with work to do,
|
|
23
|
+
* bridge `fundAmount` from L1 and claim it on the first paying tx. `l1FunderKey`/`l1RpcUrl`/
|
|
24
|
+
* `l1ChainId` are caller-supplied; omit `l1FunderKey` for the faucet + ephemeral key. On a
|
|
25
|
+
* non-local network `l1RpcUrl` and `l1ChainId` are required (there are no hardcoded defaults);
|
|
26
|
+
* on local they default to anvil (`127.0.0.1:8545`, chain `31337`).
|
|
27
|
+
*/
|
|
28
|
+
export type FeePolicy =
|
|
29
|
+
| { kind: 'sponsored' }
|
|
30
|
+
| {
|
|
31
|
+
kind: 'fee-juice';
|
|
32
|
+
threshold: bigint;
|
|
33
|
+
fundAmount: bigint;
|
|
34
|
+
l1FunderKey?: `0x${string}`;
|
|
35
|
+
l1RpcUrl?: string;
|
|
36
|
+
l1ChainId?: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** An account the deployment sends from: a v0 initializerless Schnorr account (no deploy tx). */
|
|
40
|
+
export interface AccountSpec {
|
|
41
|
+
/**
|
|
42
|
+
* The account's privacy master secret — the seed its nullifier, viewing and tagging keys derive
|
|
43
|
+
* from. The signing key is derived from it too, separately (domain-separated as the master
|
|
44
|
+
* message-signing key), so this one value pins the account
|
|
45
|
+
*/
|
|
46
|
+
secret: Fr;
|
|
47
|
+
/** Fee policy for this account's txs, overriding {@link DeploymentSpec.fees}. */
|
|
48
|
+
fees?: FeePolicy;
|
|
49
|
+
/** Salt for this account's derivation, overriding {@link DeploymentSpec.salt}. */
|
|
50
|
+
salt?: Fr;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Resolve addresses of accounts / contracts (for initializer args, action targets, the deployer). */
|
|
54
|
+
export interface Resolver {
|
|
55
|
+
/** The resolved address of the account declared under `alias`. Throws on an unknown alias. */
|
|
56
|
+
account(alias: string): AztecAddress;
|
|
57
|
+
/** The resolved address of the contract step declared under `alias`. Throws on an unknown alias. */
|
|
58
|
+
contract(alias: string): AztecAddress;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The static side of a codegen'd contract class (e.g. `TokenContract`): the single source of both
|
|
63
|
+
* the artifact and a typed `.at`. Carries the instance type `T`, surfaced by {@link Ctx.instance}.
|
|
64
|
+
*/
|
|
65
|
+
export interface GeneratedContractClass<T extends ContractBase = ContractBase> {
|
|
66
|
+
artifact: ContractArtifact;
|
|
67
|
+
at(address: AztecAddress, wallet: Wallet): T;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** What a contract step declares however its initializer args are produced. */
|
|
71
|
+
interface ContractStepBase<T extends ContractBase = ContractBase> {
|
|
72
|
+
kind: 'contract';
|
|
73
|
+
/** The generated contract class — provides the artifact and the typed `.at`. */
|
|
74
|
+
contract: GeneratedContractClass<T>;
|
|
75
|
+
/** Account that salts + sends the deploy, e.g. `(r) => r.account("admin")`. */
|
|
76
|
+
deployer: (resolve: Resolver) => AztecAddress;
|
|
77
|
+
/** Per-contract salt, overriding {@link DeploymentSpec.salt}. */
|
|
78
|
+
salt?: Fr;
|
|
79
|
+
/**
|
|
80
|
+
* For contracts that own private notes (e.g. an FPC): the contract's privacy master secret. The
|
|
81
|
+
* framework derives its `PublicKeys` from it. Omit for ordinary contracts (default keys).
|
|
82
|
+
*/
|
|
83
|
+
secret?: Fr;
|
|
84
|
+
/** Name of a non-default `#[initializer]` to call. Defaults to the contract's constructor. */
|
|
85
|
+
initializer?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A step that puts a contract on-chain (or in the PXE):
|
|
90
|
+
* - `publish` → register the class + deploy the instance + run its initializer (a tx).
|
|
91
|
+
* - `register` → private; only derive the deterministic address and register it in the PXE (no tx).
|
|
92
|
+
*
|
|
93
|
+
* The address is deterministic in (class id, deployer, salt, initializer + its args). The two ways
|
|
94
|
+
* to supply those args are the union's two variants, so a step can only pick one.
|
|
95
|
+
*/
|
|
96
|
+
export type ContractStep<C = Steps, T extends ContractBase = ContractBase> =
|
|
97
|
+
| (ContractStepBase<T> & {
|
|
98
|
+
mode: 'publish' | 'register';
|
|
99
|
+
/**
|
|
100
|
+
* Deterministic initializer args — a pure function of resolved addresses + static config. Its
|
|
101
|
+
* contract→contract dependencies are auto-derived and the address is resolved UPFRONT.
|
|
102
|
+
*/
|
|
103
|
+
initializerArgs?: (resolve: Resolver) => unknown[];
|
|
104
|
+
deferredInitializerArgs?: never;
|
|
105
|
+
/** Steps that must complete first, on top of those auto-derived from {@link initializerArgs}. */
|
|
106
|
+
dependsOn?: string[];
|
|
107
|
+
})
|
|
108
|
+
| (ContractStepBase<T> & {
|
|
109
|
+
/** Deferred args resolve once the run is underway, so there has to be a tx to defer. */
|
|
110
|
+
mode: 'publish';
|
|
111
|
+
/**
|
|
112
|
+
* Runtime initializer args — may read live state (e.g. `ctx.instance(x).methods.f().simulate()`).
|
|
113
|
+
* Resolved at inventory time when the state it reads already exists (the re-run case, which is
|
|
114
|
+
* what makes re-runs no-ops), and otherwise AT EXECUTION TIME, once {@link dependsOn} has run.
|
|
115
|
+
*/
|
|
116
|
+
deferredInitializerArgs: (ctx: Ctx<C>) => unknown[] | Promise<unknown[]>;
|
|
117
|
+
initializerArgs?: never;
|
|
118
|
+
/**
|
|
119
|
+
* The steps whose effects the args read.
|
|
120
|
+
* The initializer args resolve only once these are in place
|
|
121
|
+
*/
|
|
122
|
+
dependsOn: string[];
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
/** A step that sends a tx once its dependencies exist. */
|
|
126
|
+
export interface ActionStep<C = Steps> {
|
|
127
|
+
kind: 'action';
|
|
128
|
+
/** Account that sends (and pays for) this tx, e.g. `(r) => r.account("admin")`. */
|
|
129
|
+
from: (resolve: Resolver) => AztecAddress;
|
|
130
|
+
/**
|
|
131
|
+
* Builds the interaction to send. May be async (e.g. to read state first). The EmbeddedWallet
|
|
132
|
+
* creates required authwits at send time, so the interaction usually needs no `.with(...)`.
|
|
133
|
+
*/
|
|
134
|
+
call: (ctx: Ctx<C>) => ContractFunctionInteraction | Promise<ContractFunctionInteraction>;
|
|
135
|
+
/**
|
|
136
|
+
* Idempotency gate: if it resolves true, the action is skipped this run. Not consulted until the
|
|
137
|
+
* contracts in {@link dependsOn} are in place. Anything it throws aborts the run.
|
|
138
|
+
*/
|
|
139
|
+
done: (ctx: Ctx<C>) => Promise<boolean>;
|
|
140
|
+
/**
|
|
141
|
+
* Steps that must complete first: every contract this action calls or its {@link done} gate
|
|
142
|
+
* reads, plus the actions it follows.
|
|
143
|
+
*/
|
|
144
|
+
dependsOn?: string[];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* A step that provisions an address — any address, not just a sending account — with bridged Fee
|
|
149
|
+
* Juice: bridge `amount` from L1, then send a `FeeJuice.claim` tx from {@link from} crediting
|
|
150
|
+
* {@link recipient}. Used to fund contracts that pay for others (e.g. an FPC). Idempotent on the
|
|
151
|
+
* recipient's public balance, and resumable: the bridge claim persists (see ./state.ts) as soon as
|
|
152
|
+
* it exists on L1, so a crash between bridge and claim resumes instead of stranding the funds.
|
|
153
|
+
*/
|
|
154
|
+
export interface FundStep {
|
|
155
|
+
kind: 'fund';
|
|
156
|
+
/** Recipient of the bridged Fee Juice, e.g. `(r) => r.contract("fpc")`. */
|
|
157
|
+
recipient: (resolve: Resolver) => AztecAddress;
|
|
158
|
+
/** Bridge + claim only when the recipient's public Fee Juice balance is below this (wei). */
|
|
159
|
+
threshold: bigint;
|
|
160
|
+
/**
|
|
161
|
+
* Amount to bridge (wei). On a network with a fee-asset faucet whose mint amount exceeds the L1
|
|
162
|
+
* funder's balance, the faucet's own mint amount is what arrives.
|
|
163
|
+
*/
|
|
164
|
+
amount: bigint;
|
|
165
|
+
/** Account that sends (and pays for) the L2 claim tx, e.g. `(r) => r.account("admin")`. */
|
|
166
|
+
from: (resolve: Resolver) => AztecAddress;
|
|
167
|
+
/** L1 funder key signing the bridge tx; omit for the faucet + an ephemeral key (or anvil's dev key on local). */
|
|
168
|
+
l1FunderKey?: `0x${string}`;
|
|
169
|
+
/** L1 connection for the bridge; required on non-local networks, defaults to anvil on local. */
|
|
170
|
+
l1RpcUrl?: string;
|
|
171
|
+
l1ChainId?: number;
|
|
172
|
+
/** Steps that must complete first (e.g. the contract being funded). */
|
|
173
|
+
dependsOn?: string[];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export type StepSpec<C = Steps> = ContractStep<C> | ActionStep<C> | FundStep;
|
|
177
|
+
/**
|
|
178
|
+
* A steps map: alias → step. The element generic is `any` so the alias isn't self-referential
|
|
179
|
+
* (`Steps → StepSpec<Steps> → …`); a concrete spec's `C` is inferred at the {@link runDeployment}
|
|
180
|
+
* call site, which is what types `ctx.instance`.
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
export type Steps = Record<string, StepSpec<any>>;
|
|
184
|
+
|
|
185
|
+
/** The concrete contract type a contract step produces (else the base type). */
|
|
186
|
+
export type InstanceOf<S> = S extends { contract: GeneratedContractClass<infer T> } ? T : ContractBase;
|
|
187
|
+
/** The aliases of the contract steps in C — so `ctx.instance` only accepts those. */
|
|
188
|
+
export type ContractAlias<C> = {
|
|
189
|
+
[K in keyof C]: C[K] extends { kind: 'contract' } ? K : never;
|
|
190
|
+
}[keyof C] &
|
|
191
|
+
string;
|
|
192
|
+
|
|
193
|
+
/** Everything a step needs at build/idempotency time: typed resolution + bound instances + handles. */
|
|
194
|
+
export interface Ctx<C = Steps> extends Resolver {
|
|
195
|
+
/** The contract bound to the wallet, typed from the step's class. */
|
|
196
|
+
instance<K extends ContractAlias<C>>(alias: K): InstanceOf<C[K]>;
|
|
197
|
+
/**
|
|
198
|
+
* Whether step `id` is already satisfied this run — it will NOT do work. Mode-aware: an action
|
|
199
|
+
* whose `done` gate passed, a published contract that's on-chain, or a registered (private)
|
|
200
|
+
* contract that's in the wallet. Can be true without {@link ran} (e.g. a published contract a
|
|
201
|
+
* prior run left on-chain). Lets a step defer to another's gate: `done: (ctx) => ctx.done("amm")`.
|
|
202
|
+
*/
|
|
203
|
+
done(id: string): Promise<boolean>;
|
|
204
|
+
/**
|
|
205
|
+
* Whether step `id` did work *this run*: an action that sent its tx, a contract published this
|
|
206
|
+
* run (absent before), or a contract (re)registered this run. Use for "do B because A happened
|
|
207
|
+
* this run", e.g. a mint gated on a fresh token: `done: (ctx) => !ctx.ran("goCoin")`.
|
|
208
|
+
*/
|
|
209
|
+
ran(id: string): Promise<boolean>;
|
|
210
|
+
wallet: Wallet;
|
|
211
|
+
node: AztecNode;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** The full declarative input to {@link runDeployment}: target, accounts, steps, fees, and hooks. */
|
|
215
|
+
export interface DeploymentSpec<C extends Steps = Steps> {
|
|
216
|
+
/**
|
|
217
|
+
* The node to deploy against: a JSON-RPC URL, or an already-connected node (e.g. an in-process
|
|
218
|
+
* `AztecNodeService` from a test fixture). Local time-warping while a bridge settles reaches the
|
|
219
|
+
* debug API through whichever is given — a URL builds a debug client, an in-process node serves
|
|
220
|
+
* it directly.
|
|
221
|
+
*/
|
|
222
|
+
node: string | AztecNode;
|
|
223
|
+
/**
|
|
224
|
+
* Whether the target is a local (anvil) network. Local uses the deterministic sandbox defaults:
|
|
225
|
+
* sponsored fees, no real proofs, warp-based L1→L2 message advancement, and anvil's dev funder.
|
|
226
|
+
* Everything else (default) uses fee-juice, real proofs, and polling; L1 details for bridging must
|
|
227
|
+
* be supplied on the fee-juice {@link FeePolicy}.
|
|
228
|
+
*/
|
|
229
|
+
local?: boolean;
|
|
230
|
+
/** Human label for logs + reporter; defaults to `local`/`network` based on {@link local}. */
|
|
231
|
+
label?: string;
|
|
232
|
+
/** Default salt for account + contract derivation; each can override. Defaults to Fr(0). */
|
|
233
|
+
salt?: Fr;
|
|
234
|
+
/** Directory for the resume-state file. Defaults to `<cwd>/.deploy-state`. */
|
|
235
|
+
stateDir?: string;
|
|
236
|
+
accounts: Record<string, AccountSpec>;
|
|
237
|
+
steps: C;
|
|
238
|
+
/** Default fee policy; per-account {@link AccountSpec.fees} overrides it. Defaults per {@link local}. */
|
|
239
|
+
fees?: FeePolicy;
|
|
240
|
+
/** Where lifecycle events go. Defaults to {@link consoleReporter} (stderr). `{}` silences them. */
|
|
241
|
+
reporter?: DeployReporter;
|
|
242
|
+
/** Hook to write app artifacts (e.g. a frontend manifest) from resolved state; runs after execution. */
|
|
243
|
+
output?: (ctx: Ctx<C>) => void | Promise<void>;
|
|
244
|
+
}
|
package/src/examples/token.ts
CHANGED
|
@@ -21,10 +21,18 @@ async function main() {
|
|
|
21
21
|
|
|
22
22
|
const wallet = await EmbeddedWallet.create(node);
|
|
23
23
|
|
|
24
|
-
// During local network setup we
|
|
24
|
+
// During local network setup we create a few initializerless accounts. Below we add them to our wallet.
|
|
25
25
|
const [aliceInitialAccountData, bobInitialAccountData] = await getInitialTestAccountsData();
|
|
26
|
-
await wallet.
|
|
27
|
-
|
|
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
|
+
);
|
|
28
36
|
|
|
29
37
|
const alice = aliceInitialAccountData.address;
|
|
30
38
|
const bob = bobInitialAccountData.address;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
3
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
4
|
+
import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
|
|
5
|
+
import type { AztecAddress } from '@aztec/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
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
2
3
|
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
3
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
5
|
import type { LogFn } from '@aztec/foundation/log';
|
|
@@ -45,19 +46,22 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
|
|
|
45
46
|
return (await getBananaFPCInstance(initialAccounts)).address;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
export async function setupBananaFPC(
|
|
49
|
+
export async function setupBananaFPC(
|
|
50
|
+
initialAccounts: InitialAccountData[],
|
|
51
|
+
wallet: Wallet,
|
|
52
|
+
log: LogFn,
|
|
53
|
+
waitOpts?: WaitOpts,
|
|
54
|
+
) {
|
|
49
55
|
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
50
56
|
const admin = getBananaAdmin(initialAccounts);
|
|
51
57
|
const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
|
|
52
|
-
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal
|
|
53
|
-
|
|
54
|
-
contractAddressSalt: BANANA_COIN_SALT,
|
|
58
|
+
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
|
|
59
|
+
salt: BANANA_COIN_SALT,
|
|
55
60
|
universalDeploy: true,
|
|
56
|
-
}),
|
|
57
|
-
FPCContract.deploy(wallet, bananaCoinAddress, admin).send({
|
|
61
|
+
}).send({ from: admin, wait: waitOpts }),
|
|
62
|
+
FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
|
|
58
63
|
from: admin,
|
|
59
|
-
|
|
60
|
-
universalDeploy: true,
|
|
64
|
+
wait: waitOpts,
|
|
61
65
|
}),
|
|
62
66
|
]);
|
|
63
67
|
|