@aztec/aztec 0.0.1-commit.3fd054f6 → 0.0.1-commit.431c48d

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.
Files changed (157) hide show
  1. package/dest/bin/index.js +3 -1
  2. package/dest/cli/aztec_start_action.d.ts +1 -1
  3. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  4. package/dest/cli/aztec_start_action.js +33 -33
  5. package/dest/cli/aztec_start_options.d.ts +2 -2
  6. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_options.js +21 -16
  8. package/dest/cli/cmds/compile.d.ts +1 -1
  9. package/dest/cli/cmds/compile.d.ts.map +1 -1
  10. package/dest/cli/cmds/compile.js +32 -24
  11. package/dest/cli/cmds/profile.d.ts +1 -1
  12. package/dest/cli/cmds/profile.d.ts.map +1 -1
  13. package/dest/cli/cmds/profile.js +1 -1
  14. package/dest/cli/cmds/profile_gates.d.ts +2 -2
  15. package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
  16. package/dest/cli/cmds/profile_gates.js +21 -3
  17. package/dest/cli/cmds/prover.d.ts +4 -0
  18. package/dest/cli/cmds/prover.d.ts.map +1 -0
  19. package/dest/cli/cmds/prover.js +24 -0
  20. package/dest/cli/cmds/standby.d.ts +30 -6
  21. package/dest/cli/cmds/standby.d.ts.map +1 -1
  22. package/dest/cli/cmds/standby.js +48 -5
  23. package/dest/cli/cmds/start_bot.d.ts +1 -1
  24. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  25. package/dest/cli/cmds/start_bot.js +8 -4
  26. package/dest/cli/cmds/start_node.d.ts +1 -1
  27. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  28. package/dest/cli/cmds/start_node.js +23 -47
  29. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  30. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  31. package/dest/cli/cmds/start_prover_agent.js +5 -17
  32. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  33. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  34. package/dest/cli/cmds/start_prover_broker.js +11 -8
  35. package/dest/cli/cmds/start_txe.d.ts +2 -2
  36. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  37. package/dest/cli/cmds/start_txe.js +6 -5
  38. package/dest/cli/cmds/utils/artifacts.d.ts +6 -1
  39. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -1
  40. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  41. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  42. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  43. package/dest/cli/cmds/utils/needs_recompile.d.ts +1 -1
  44. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -1
  45. package/dest/cli/cmds/utils/needs_recompile.js +9 -53
  46. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  47. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  48. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
  49. package/dest/cli/util.d.ts +10 -5
  50. package/dest/cli/util.d.ts.map +1 -1
  51. package/dest/cli/util.js +26 -53
  52. package/dest/deploy/bridging.d.ts +84 -0
  53. package/dest/deploy/bridging.d.ts.map +1 -0
  54. package/dest/deploy/bridging.js +121 -0
  55. package/dest/deploy/fees.d.ts +120 -0
  56. package/dest/deploy/fees.d.ts.map +1 -0
  57. package/dest/deploy/fees.js +278 -0
  58. package/dest/deploy/graph.d.ts +40 -0
  59. package/dest/deploy/graph.d.ts.map +1 -0
  60. package/dest/deploy/graph.js +120 -0
  61. package/dest/deploy/index.d.ts +19 -0
  62. package/dest/deploy/index.d.ts.map +1 -0
  63. package/dest/deploy/index.js +15 -0
  64. package/dest/deploy/reporter.d.ts +106 -0
  65. package/dest/deploy/reporter.d.ts.map +1 -0
  66. package/dest/deploy/reporter.js +76 -0
  67. package/dest/deploy/runner.d.ts +8 -0
  68. package/dest/deploy/runner.d.ts.map +1 -0
  69. package/dest/deploy/runner.js +886 -0
  70. package/dest/deploy/state.d.ts +19 -0
  71. package/dest/deploy/state.d.ts.map +1 -0
  72. package/dest/deploy/state.js +59 -0
  73. package/dest/deploy/types.d.ts +233 -0
  74. package/dest/deploy/types.d.ts.map +1 -0
  75. package/dest/deploy/types.js +9 -0
  76. package/dest/examples/token.js +3 -3
  77. package/dest/local-network/auth_registry.d.ts +5 -0
  78. package/dest/local-network/auth_registry.d.ts.map +1 -0
  79. package/dest/local-network/auth_registry.js +17 -0
  80. package/dest/local-network/banana_fpc.d.ts +3 -2
  81. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  82. package/dest/local-network/banana_fpc.js +11 -7
  83. package/dest/local-network/local-network.d.ts +10 -32
  84. package/dest/local-network/local-network.d.ts.map +1 -1
  85. package/dest/local-network/local-network.js +52 -73
  86. package/dest/testing/cheat_codes.d.ts +17 -23
  87. package/dest/testing/cheat_codes.d.ts.map +1 -1
  88. package/dest/testing/cheat_codes.js +17 -43
  89. package/dest/testing/epoch_test_settler.d.ts +2 -2
  90. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  91. package/dest/testing/epoch_test_settler.js +6 -25
  92. package/dest/testing/index.d.ts +2 -2
  93. package/dest/testing/index.d.ts.map +1 -1
  94. package/dest/testing/index.js +1 -1
  95. package/dest/testing/local-network.d.ts +51 -0
  96. package/dest/testing/local-network.d.ts.map +1 -0
  97. package/dest/testing/local-network.js +60 -0
  98. package/dest/testing/token_allowed_setup.d.ts +9 -4
  99. package/dest/testing/token_allowed_setup.d.ts.map +1 -1
  100. package/dest/testing/token_allowed_setup.js +12 -8
  101. package/package.json +37 -34
  102. package/scripts/add_crate.sh +11 -60
  103. package/scripts/aztec.sh +6 -2
  104. package/scripts/init.sh +5 -5
  105. package/scripts/new.sh +2 -2
  106. package/scripts/setup_workspace.sh +3 -2
  107. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  108. package/scripts/templates/blank/contract/src/main.nr +10 -0
  109. package/scripts/templates/blank/test/Nargo.toml +7 -0
  110. package/scripts/templates/blank/test/src/lib.nr +11 -0
  111. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  112. package/scripts/templates/counter/contract/src/main.nr +48 -0
  113. package/scripts/templates/counter/test/Nargo.toml +7 -0
  114. package/scripts/templates/counter/test/src/lib.nr +32 -0
  115. package/src/bin/index.ts +3 -1
  116. package/src/cli/aztec_start_action.ts +38 -25
  117. package/src/cli/aztec_start_options.ts +27 -23
  118. package/src/cli/cmds/compile.ts +37 -23
  119. package/src/cli/cmds/profile.ts +2 -1
  120. package/src/cli/cmds/profile_gates.ts +20 -4
  121. package/src/cli/cmds/prover.ts +42 -0
  122. package/src/cli/cmds/standby.ts +59 -7
  123. package/src/cli/cmds/start_bot.ts +9 -6
  124. package/src/cli/cmds/start_node.ts +32 -39
  125. package/src/cli/cmds/start_prover_agent.ts +5 -8
  126. package/src/cli/cmds/start_prover_broker.ts +10 -11
  127. package/src/cli/cmds/start_txe.ts +7 -5
  128. package/src/cli/cmds/utils/artifacts.ts +5 -0
  129. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  130. package/src/cli/cmds/utils/needs_recompile.ts +8 -61
  131. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
  132. package/src/cli/util.ts +27 -68
  133. package/src/deploy/bridging.ts +191 -0
  134. package/src/deploy/fees.ts +322 -0
  135. package/src/deploy/graph.ts +137 -0
  136. package/src/deploy/index.ts +41 -0
  137. package/src/deploy/reporter.ts +184 -0
  138. package/src/deploy/runner.ts +936 -0
  139. package/src/deploy/state.ts +66 -0
  140. package/src/deploy/types.ts +244 -0
  141. package/src/examples/token.ts +11 -3
  142. package/src/local-network/auth_registry.ts +19 -0
  143. package/src/local-network/banana_fpc.ts +12 -8
  144. package/src/local-network/local-network.ts +61 -83
  145. package/src/testing/cheat_codes.ts +18 -49
  146. package/src/testing/epoch_test_settler.ts +8 -31
  147. package/src/testing/index.ts +1 -1
  148. package/src/testing/local-network.ts +97 -0
  149. package/src/testing/token_allowed_setup.ts +15 -8
  150. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  151. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  152. package/dest/cli/cmds/start_archiver.js +0 -48
  153. package/dest/testing/anvil_test_watcher.d.ts +0 -42
  154. package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
  155. package/dest/testing/anvil_test_watcher.js +0 -181
  156. package/src/cli/cmds/start_archiver.ts +0 -50
  157. package/src/testing/anvil_test_watcher.ts +0 -210
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Observability for the deploy framework. {@link runDeployment} emits structured lifecycle events
3
+ * to a {@link DeployReporter} instead of writing to the console directly, so callers control where
4
+ * the signal goes: the default ({@link consoleReporter}) renders human-readably to **stderr** —
5
+ * keeping stdout clear for the deploy scripts' `export KEY=VAL` lines, which an orchestrator evals —
6
+ * while e2e, a progress UI, or structured CI logging can inject their own reporter and consume the
7
+ * events as data. Every hook is optional; an empty `{}` is a valid (silent) reporter.
8
+ */
9
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
10
+ import type { TxHash } from '@aztec/stdlib/tx';
11
+
12
+ import { formatLayers, formatList } from './graph.js';
13
+
14
+ /** What a unit did: publish a contract, send an action's tx, or fund an address with Fee Juice. */
15
+ export type DeployUnitKind = 'publish' | 'action' | 'fund';
16
+
17
+ /** Identity of one execution unit (a single tx), as reported by the unit lifecycle hooks. */
18
+ export interface DeployUnitInfo {
19
+ /** Human label, e.g. `publish goCoin`, `action mintGoCoin`. */
20
+ label: string;
21
+ kind: DeployUnitKind;
22
+ /** The account that sends and pays for this tx. */
23
+ account: AztecAddress;
24
+ }
25
+
26
+ /** What a unit produced once its tx settled. Fields beyond `durationMs` come from the receipt. */
27
+ export interface DeployUnitResult {
28
+ txHash?: TxHash;
29
+ blockNumber?: number;
30
+ feePaid?: bigint;
31
+ status?: string;
32
+ durationMs: number;
33
+ }
34
+
35
+ /** An account's funding posture for this run, as resolved at planning time. */
36
+ export type AccountFunding =
37
+ | { kind: 'idle' } // no pending work this run, so funding is moot
38
+ | { kind: 'sponsored' } // a SponsoredFPC pays
39
+ | { kind: 'funded'; balance: bigint } // pays from its own Fee Juice
40
+ | { kind: 'not-funded'; balance: bigint; fundAmount: bigint }; // will bridge before paying
41
+
42
+ export interface DeployPlanAccount {
43
+ alias: string;
44
+ address: AztecAddress;
45
+ funding: AccountFunding;
46
+ }
47
+
48
+ export interface DeployPlanStep {
49
+ id: string;
50
+ kind: 'contract' | 'action' | 'fund';
51
+ /**
52
+ * Status at the start of the run: a contract is `published` / `to publish` (public) or
53
+ * `registered` (private); an action is `done` / `to run`; a fund step is `funded` / `to fund`.
54
+ */
55
+ status: 'published' | 'to publish' | 'registered' | 'done' | 'to run' | 'funded' | 'to fund';
56
+ /** Steps it depends on (constructor-arg refs and explicit `dependsOn`). */
57
+ dependsOn: string[];
58
+ }
59
+
60
+ export interface DeployPlan {
61
+ /** Human label for the target (e.g. `local`, or a caller-chosen name). */
62
+ label: string;
63
+ accounts: DeployPlanAccount[];
64
+ steps: DeployPlanStep[];
65
+ /** Execution layers (step ids) — what will actually run, in dependency order. A layer runs parallel. */
66
+ layers: string[][];
67
+ }
68
+
69
+ export interface DeploySummary {
70
+ label: string;
71
+ contracts: { alias: string; address: AztecAddress; status: 'published' | 'registered' }[];
72
+ accounts: { alias: string; address: AztecAddress }[];
73
+ }
74
+
75
+ export interface BridgeEvent {
76
+ recipient: AztecAddress;
77
+ amount: bigint;
78
+ /** True when resuming a persisted claim instead of bridging anew. */
79
+ reused: boolean;
80
+ }
81
+
82
+ /** Lifecycle hooks the framework emits during a run. All optional — implement only what you need. */
83
+ export interface DeployReporter {
84
+ /** The resolved plan, before execution. */
85
+ onPlan?(plan: DeployPlan): void;
86
+ /** Everything is already on-chain; nothing will be sent. */
87
+ onNothingToDo?(label: string): void;
88
+ /** An account's Fee Juice is being topped up (or a persisted claim is being resumed). */
89
+ onBridge?(event: BridgeEvent): void;
90
+ /** A unit's tx is about to be sent. */
91
+ onUnitStart?(unit: DeployUnitInfo): void;
92
+ /** A unit's tx settled successfully. */
93
+ onUnitSettled?(unit: DeployUnitInfo, result: DeployUnitResult): void;
94
+ /** A unit's tx threw; the run will abort after this. */
95
+ onUnitError?(unit: DeployUnitInfo, error: unknown): void;
96
+ /** The run finished; `summary` holds the final resolved state. */
97
+ onComplete?(summary: DeploySummary): void;
98
+ }
99
+
100
+ const MS_PER_SECOND = 1000;
101
+ const WEI_PER_FEE_JUICE = 10n ** 18n;
102
+ const seconds = (ms: number): string => `${(ms / MS_PER_SECOND).toFixed(1)}s`;
103
+ const feeJuice = (wei: bigint): string => `${wei / WEI_PER_FEE_JUICE} FJ`;
104
+
105
+ function describeFunding(f: AccountFunding): string {
106
+ switch (f.kind) {
107
+ case 'idle':
108
+ return 'idle (no work)';
109
+ case 'sponsored':
110
+ return 'sponsored';
111
+ case 'funded':
112
+ return `funded (${feeJuice(f.balance)})`;
113
+ case 'not-funded':
114
+ return `not funded (${feeJuice(f.balance)}) → will bridge ${feeJuice(f.fundAmount)}`;
115
+ }
116
+ }
117
+
118
+ /**
119
+ * The default reporter: renders events human-readably to **stderr**. Stderr (not stdout) so the
120
+ * traces survive an orchestrator that captures stdout for the scripts' `export` lines.
121
+ */
122
+ export function consoleReporter(): DeployReporter {
123
+ const log = (line: string): void => void process.stderr.write(`${line}\n`);
124
+ return {
125
+ onPlan(plan) {
126
+ log(`\n── Plan (${plan.label}) ──`);
127
+ log(
128
+ formatList(
129
+ 'accounts',
130
+ plan.accounts.map(a => ({ name: a.alias, tag: describeFunding(a.funding) })),
131
+ ),
132
+ );
133
+ log(
134
+ formatList(
135
+ 'steps',
136
+ plan.steps.map(s => ({
137
+ name: s.id,
138
+ tag: `${s.kind} · ${s.status}`,
139
+ dependencies: s.dependsOn,
140
+ })),
141
+ ),
142
+ );
143
+ log(
144
+ formatLayers(
145
+ 'execution layers',
146
+ plan.layers.map(layer => layer.map(name => ({ name }))),
147
+ ),
148
+ );
149
+ },
150
+ onNothingToDo(label) {
151
+ log(`\nNothing to do on ${label} — everything is already on-chain.`);
152
+ },
153
+ onBridge({ recipient, amount, reused }) {
154
+ log(
155
+ reused
156
+ ? `Reusing a pending bridge claim for ${recipient} (resuming a top-up).`
157
+ : `Bridging ${amount} Fee Juice to ${recipient} (this can take a few minutes)...`,
158
+ );
159
+ },
160
+ onUnitStart(unit) {
161
+ log(`→ ${unit.label}...`);
162
+ },
163
+ onUnitSettled(unit, result) {
164
+ const bits = [
165
+ result.txHash ? `tx ${result.txHash.toString().slice(0, 10)}…` : undefined,
166
+ result.blockNumber != null ? `block ${result.blockNumber}` : undefined,
167
+ seconds(result.durationMs),
168
+ ].filter(Boolean);
169
+ log(`✓ ${unit.label} ${bits.join(' ')}`);
170
+ },
171
+ onUnitError(unit, error) {
172
+ log(`✗ ${unit.label} failed: ${error instanceof Error ? error.message : String(error)}`);
173
+ },
174
+ onComplete(summary) {
175
+ log(`\n── Deployed to ${summary.label} ──`);
176
+ for (const c of summary.contracts) {
177
+ log(` ${c.alias.padEnd(16)} ${c.address} (${c.status})`);
178
+ }
179
+ for (const a of summary.accounts) {
180
+ log(` account ${a.alias}: ${a.address}`);
181
+ }
182
+ },
183
+ };
184
+ }