@artblocks/abx-cli 0.1.0-alpha.4 → 0.1.0-alpha.40

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 (180) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/assets/renderer-scaffold/README.md +29 -11
  3. package/assets/renderer-scaffold/foundry.toml +1 -0
  4. package/assets/renderer-scaffold/remappings.txt +1 -1
  5. package/assets/renderer-scaffold/script/DeployHooks.s.sol +24 -0
  6. package/assets/renderer-scaffold/src/MyHooks.sol +20 -0
  7. package/assets/renderer-scaffold/src/MyRenderer.sol +4 -4
  8. package/assets/renderer-scaffold/src/MyTraits.sol +2 -2
  9. package/assets/renderer-scaffold/test/MyRenderer.t.sol +60 -3
  10. package/dist/bin.d.ts +26 -0
  11. package/dist/bin.d.ts.map +1 -0
  12. package/dist/bin.js +63 -0
  13. package/dist/bin.js.map +1 -0
  14. package/dist/capabilities.d.ts +94 -0
  15. package/dist/capabilities.d.ts.map +1 -0
  16. package/dist/capabilities.js +135 -0
  17. package/dist/capabilities.js.map +1 -0
  18. package/dist/commands/auth.d.ts +54 -0
  19. package/dist/commands/auth.d.ts.map +1 -0
  20. package/dist/commands/auth.js +447 -0
  21. package/dist/commands/auth.js.map +1 -0
  22. package/dist/commands/deploy.d.ts +242 -0
  23. package/dist/commands/deploy.d.ts.map +1 -0
  24. package/dist/commands/deploy.js +4763 -0
  25. package/dist/commands/deploy.js.map +1 -0
  26. package/dist/commands/feedback.d.ts +7 -0
  27. package/dist/commands/feedback.d.ts.map +1 -0
  28. package/dist/commands/feedback.js +147 -0
  29. package/dist/commands/feedback.js.map +1 -0
  30. package/dist/commands/project.d.ts +257 -0
  31. package/dist/commands/project.d.ts.map +1 -0
  32. package/dist/commands/project.js +1414 -0
  33. package/dist/commands/project.js.map +1 -0
  34. package/dist/commands/reads.d.ts +64 -0
  35. package/dist/commands/reads.d.ts.map +1 -0
  36. package/dist/commands/reads.js +701 -0
  37. package/dist/commands/reads.js.map +1 -0
  38. package/dist/commands/scaffold.d.ts +89 -0
  39. package/dist/commands/scaffold.d.ts.map +1 -0
  40. package/dist/commands/scaffold.js +733 -0
  41. package/dist/commands/scaffold.js.map +1 -0
  42. package/dist/commands/service.d.ts +67 -0
  43. package/dist/commands/service.d.ts.map +1 -0
  44. package/dist/commands/service.js +741 -0
  45. package/dist/commands/service.js.map +1 -0
  46. package/dist/commands/storage.d.ts +51 -0
  47. package/dist/commands/storage.d.ts.map +1 -0
  48. package/dist/commands/storage.js +370 -0
  49. package/dist/commands/storage.js.map +1 -0
  50. package/dist/commands/submit-app.d.ts +59 -0
  51. package/dist/commands/submit-app.d.ts.map +1 -0
  52. package/dist/commands/submit-app.js +513 -0
  53. package/dist/commands/submit-app.js.map +1 -0
  54. package/dist/config.d.ts +90 -2
  55. package/dist/config.d.ts.map +1 -1
  56. package/dist/config.js +284 -11
  57. package/dist/config.js.map +1 -1
  58. package/dist/conformance.d.ts +31 -0
  59. package/dist/conformance.d.ts.map +1 -0
  60. package/dist/conformance.js +390 -0
  61. package/dist/conformance.js.map +1 -0
  62. package/dist/contract-read-error.d.ts +5 -0
  63. package/dist/contract-read-error.d.ts.map +1 -0
  64. package/dist/contract-read-error.js +37 -0
  65. package/dist/contract-read-error.js.map +1 -0
  66. package/dist/deps.d.ts +6 -39
  67. package/dist/deps.d.ts.map +1 -1
  68. package/dist/deps.js +4 -68
  69. package/dist/deps.js.map +1 -1
  70. package/dist/errors.d.ts +20 -0
  71. package/dist/errors.d.ts.map +1 -0
  72. package/dist/errors.js +25 -0
  73. package/dist/errors.js.map +1 -0
  74. package/dist/flag-allowlists.d.ts +53 -0
  75. package/dist/flag-allowlists.d.ts.map +1 -0
  76. package/dist/flag-allowlists.js +180 -0
  77. package/dist/flag-allowlists.js.map +1 -0
  78. package/dist/flags.d.ts +41 -0
  79. package/dist/flags.d.ts.map +1 -1
  80. package/dist/flags.js +111 -1
  81. package/dist/flags.js.map +1 -1
  82. package/dist/jsonout.d.ts +37 -0
  83. package/dist/jsonout.d.ts.map +1 -0
  84. package/dist/jsonout.js +68 -0
  85. package/dist/jsonout.js.map +1 -0
  86. package/dist/kind.d.ts +57 -0
  87. package/dist/kind.d.ts.map +1 -0
  88. package/dist/kind.js +122 -0
  89. package/dist/kind.js.map +1 -0
  90. package/dist/main.js +747 -4838
  91. package/dist/main.js.map +1 -1
  92. package/dist/mintpage.d.ts +17 -2
  93. package/dist/mintpage.d.ts.map +1 -1
  94. package/dist/mintpage.js +241 -54
  95. package/dist/mintpage.js.map +1 -1
  96. package/dist/output.d.ts +179 -0
  97. package/dist/output.d.ts.map +1 -0
  98. package/dist/output.js +780 -0
  99. package/dist/output.js.map +1 -0
  100. package/dist/ownerops.d.ts +312 -57
  101. package/dist/ownerops.d.ts.map +1 -1
  102. package/dist/ownerops.js +1808 -357
  103. package/dist/ownerops.js.map +1 -1
  104. package/dist/preview.d.ts +23 -5
  105. package/dist/preview.d.ts.map +1 -1
  106. package/dist/preview.js +95 -43
  107. package/dist/preview.js.map +1 -1
  108. package/dist/prompt.d.ts +17 -0
  109. package/dist/prompt.d.ts.map +1 -0
  110. package/dist/prompt.js +19 -0
  111. package/dist/prompt.js.map +1 -0
  112. package/dist/provision.d.ts +3 -13
  113. package/dist/provision.d.ts.map +1 -1
  114. package/dist/provision.js +19 -21
  115. package/dist/provision.js.map +1 -1
  116. package/dist/remote.d.ts +157 -52
  117. package/dist/remote.d.ts.map +1 -1
  118. package/dist/remote.js +435 -46
  119. package/dist/remote.js.map +1 -1
  120. package/dist/riskgate.d.ts +62 -0
  121. package/dist/riskgate.d.ts.map +1 -0
  122. package/dist/riskgate.js +234 -0
  123. package/dist/riskgate.js.map +1 -0
  124. package/dist/scaffold.d.ts +12 -0
  125. package/dist/scaffold.d.ts.map +1 -0
  126. package/dist/scaffold.js +56 -0
  127. package/dist/scaffold.js.map +1 -0
  128. package/dist/schema.d.ts +36 -1
  129. package/dist/schema.d.ts.map +1 -1
  130. package/dist/schema.js +121 -26
  131. package/dist/schema.js.map +1 -1
  132. package/dist/script-chunks.d.ts +8 -0
  133. package/dist/script-chunks.d.ts.map +1 -0
  134. package/dist/script-chunks.js +35 -0
  135. package/dist/script-chunks.js.map +1 -0
  136. package/dist/served.d.ts +30 -0
  137. package/dist/served.d.ts.map +1 -0
  138. package/dist/served.js +112 -0
  139. package/dist/served.js.map +1 -0
  140. package/dist/signer.d.ts +13 -0
  141. package/dist/signer.d.ts.map +1 -1
  142. package/dist/signer.js +84 -15
  143. package/dist/signer.js.map +1 -1
  144. package/dist/update-check.d.ts +86 -5
  145. package/dist/update-check.d.ts.map +1 -1
  146. package/dist/update-check.js +161 -20
  147. package/dist/update-check.js.map +1 -1
  148. package/package.json +13 -12
  149. package/skill/SKILL.md +179 -347
  150. package/skill/agents/openai.yaml +4 -0
  151. package/skill/reference/capabilities.md +188 -0
  152. package/skill/reference/code.md +211 -0
  153. package/skill/reference/creator-token.md +94 -0
  154. package/skill/reference/deploy.md +167 -0
  155. package/skill/reference/diagnose.md +165 -0
  156. package/skill/reference/hosting.md +161 -94
  157. package/skill/reference/operate.md +181 -0
  158. package/skill/reference/services.md +121 -0
  159. package/skill/reference/setup.md +140 -36
  160. package/assets/renderer-scaffold/src/interfaces/IAbxFieldRenderer.sol +0 -32
  161. package/assets/renderer-scaffold/src/interfaces/IAbxParams.sol +0 -26
  162. package/dist/inspect.d.ts +0 -48
  163. package/dist/inspect.d.ts.map +0 -1
  164. package/dist/inspect.js +0 -184
  165. package/dist/inspect.js.map +0 -1
  166. package/dist/migrate.d.ts +0 -65
  167. package/dist/migrate.d.ts.map +0 -1
  168. package/dist/migrate.js +0 -180
  169. package/dist/migrate.js.map +0 -1
  170. package/dist/onchain-uri.d.ts +0 -97
  171. package/dist/onchain-uri.d.ts.map +0 -1
  172. package/dist/onchain-uri.js +0 -243
  173. package/dist/onchain-uri.js.map +0 -1
  174. package/dist/upload.d.ts +0 -28
  175. package/dist/upload.d.ts.map +0 -1
  176. package/dist/upload.js +0 -41
  177. package/dist/upload.js.map +0 -1
  178. package/skill/reference/code-projects.md +0 -246
  179. package/skill/reference/operating.md +0 -116
  180. package/skill/reference/troubleshooting.md +0 -28
package/dist/remote.js CHANGED
@@ -1,54 +1,443 @@
1
1
  /**
2
- * Talk to a REMOTE resolver's admin control plane the HTTP form of `abx add` /
3
- * `abx index` / `abx forget`, pointed at a hosted node (fly/render/vps) instead of
4
- * this machine's local projection. This is the bridge the toolkit was missing: a
5
- * contract you deploy here is registered with the *local* store; the resolver baked
6
- * into your on-chain tokenURI is a *different* store and must be told separately, or
7
- * it answers "unknown project". These helpers do the telling.
2
+ * Remote-resolver resolution which service `--remote` means, and whose credential drives it.
3
+ * The HTTP client itself lives in the SDK (`AbxServiceClient`, speaking the /v1 control plane from
4
+ * site/content/docs/using-abx/remote-services.mdx); this module owns the CLI conventions around it:
8
5
  *
9
- * The admin token authorizes indexing control only never on-chain signing so the
10
- * "no signing key on the host" rule is intact. It lives in `.env` as
11
- * ABX_RESOLVER_ADMIN_TOKEN and must match the token set on the resolver.
6
+ * --remote <name> a NAMED remote`ABX_REMOTE_<NAME>_URL` + `ABX_REMOTE_<NAME>_TOKEN` in .env
7
+ * (same env-name normalization as ABX_RPC_URLS_<CHAIN>). "self" is just a name
8
+ * under this SAME convention the node YOU run reads ABX_REMOTE_SELF_URL/_TOKEN
9
+ * with zero special-casing below. A managed provider's per-account API key lives
10
+ * under its own name — and deliberately NEVER falls back to ABX_REMOTE_SELF_TOKEN,
11
+ * so your node-admin secret can't silently go to a third party.
12
+ * `abx` is the built-in first-party name: https://services.abx.io plus
13
+ * ABX_SERVICES_API_KEY. It needs no URL pasted into project configuration.
14
+ * --remote <url> an ad-hoc URL — token from --remote-token or ABX_REMOTE_SELF_TOKEN (the local
15
+ * client credential for a node you run; `abx deploy-resolver` generates it).
16
+ * --remote bare: the self-host default — ABX_PUBLIC_BASE_URL (the URL baked on-chain,
17
+ * else ABX_RESOLVER_URL) + ABX_REMOTE_SELF_TOKEN.
18
+ *
19
+ * Every token here authorizes indexing/metadata control only — never on-chain signing — so the
20
+ * "no signing key on the host" rule is intact. (`--remote-token`, not `--token`: `--token` already
21
+ * means a token ID across the owner ops.)
22
+ *
23
+ * The RESOLVER's own env var — what gates ITS control plane, server-side (packages/token-api/src/
24
+ * control-plane.ts) — is unchanged: still `ABX_RESOLVER_ADMIN_TOKEN`. Only the CLIENT-side lookup
25
+ * for a self-run node moved to the named-remote grammar above; `abx deploy-resolver` prints the exact
26
+ * command that carries the value across the name boundary (fly secrets set ABX_RESOLVER_ADMIN_TOKEN
27
+ * from your local ABX_REMOTE_SELF_TOKEN).
28
+ */
29
+ import { AbxIndexTimeoutError, AbxServiceClient, AbxServiceError, envSuffix, indexProgress, isAccepted, } from '@artblocks/abx-sdk';
30
+ import { CHAIN } from './config.js';
31
+ import { bold, c, dim, g, info, ok, warn } from './output.js';
32
+ export const ABX_SERVICES_URL = 'https://services.abx.io';
33
+ export const ABX_SERVICES_API_KEY_VAR = 'ABX_SERVICES_API_KEY';
34
+ /** How to refer to the credential this target is using, in an error the creator has to act on. */
35
+ export function tokenSourceLabel(t) {
36
+ return t.tokenFrom === 'flag' ? 'the token you passed with --remote-token' : t.tokenVar;
37
+ }
38
+ /**
39
+ * Resolve the `--remote` flag value (undefined = local op → null). Pure: pass `env` in tests.
40
+ * `tokenFlag` is `--remote-token` and wins over any env token for this invocation.
41
+ */
42
+ export function resolveRemote(spec, tokenFlag, env = process.env) {
43
+ if (spec === undefined)
44
+ return null;
45
+ const strip = (u) => u.replace(/\/+$/, '');
46
+ // bare `--remote` — the self-host default (the resolver this project's on-chain URIs point at)
47
+ if (spec === 'true' || spec === '') {
48
+ const base = env.ABX_PUBLIC_BASE_URL ?? env.ABX_RESOLVER_URL;
49
+ if (!base) {
50
+ throw new Error('`--remote` needs a target: pass `--remote <name>` (ABX_REMOTE_<NAME>_URL in .env), `--remote https://host`, or set ABX_PUBLIC_BASE_URL in .env');
51
+ }
52
+ return { url: strip(base), token: tokenFlag ?? env.ABX_REMOTE_SELF_TOKEN, source: 'default', tokenVar: 'ABX_REMOTE_SELF_TOKEN', tokenFrom: tokenFlag ? 'flag' : 'env' };
53
+ }
54
+ // `--remote <url>` — ad-hoc URL, self-host credential conventions
55
+ if (spec.includes('://')) {
56
+ return { url: strip(spec), token: tokenFlag ?? env.ABX_REMOTE_SELF_TOKEN, source: 'url', tokenVar: 'ABX_REMOTE_SELF_TOKEN', tokenFrom: tokenFlag ? 'flag' : 'env' };
57
+ }
58
+ // The first-party provider has a stable, verified identity. Keep it out of standing agent docs
59
+ // and generic URL config: a user stores only the credential, while an explicit URL remains the
60
+ // escape hatch for local/staging services.
61
+ if (envSuffix(spec) === 'ABX') {
62
+ return {
63
+ url: ABX_SERVICES_URL,
64
+ token: tokenFlag ?? env[ABX_SERVICES_API_KEY_VAR],
65
+ name: 'ABX',
66
+ source: 'builtin',
67
+ tokenVar: ABX_SERVICES_API_KEY_VAR,
68
+ tokenFrom: tokenFlag ? 'flag' : 'env',
69
+ };
70
+ }
71
+ // `--remote <name>` — a named remote (a managed provider, another node of yours, a staging box)
72
+ const name = envSuffix(spec);
73
+ const urlVar = `ABX_REMOTE_${name}_URL`;
74
+ const tokenVar = `ABX_REMOTE_${name}_TOKEN`;
75
+ const url = env[urlVar];
76
+ if (!url) {
77
+ throw new Error(`--remote ${spec}: no ${urlVar} in your .env. Set ${urlVar}=<the provider's base URL> (+ ${tokenVar}=<your API key>). ` +
78
+ `(Meant a URL? Pass a scheme: --remote https://host)`);
79
+ }
80
+ return { url: strip(url), token: tokenFlag ?? env[tokenVar], name, source: 'named', tokenVar, tokenFrom: tokenFlag ? 'flag' : 'env' };
81
+ }
82
+ /**
83
+ * The OLD client-side var (`ABX_RESOLVER_ADMIN_TOKEN`) sitting unused in `.env` because the
84
+ * self-host default's credential moved to the named-remote grammar (`ABX_REMOTE_SELF_TOKEN`) — a
85
+ * silent fallback would mean an operator's `.env` never gets renamed, so this is the ONE place both
86
+ * {@link requireRemoteToken} (the hard-stop for a real command) and `abx doctor` (the same fault,
87
+ * surfaced before a command needs it) decide whether to flag it — sharing the check means they can
88
+ * never drift on the condition. `null` when there's nothing to flag (old var absent, or the new one
89
+ * is already set and simply wins).
90
+ */
91
+ export function selfTokenMigrationWarning(env = process.env) {
92
+ if (!env.ABX_RESOLVER_ADMIN_TOKEN || env.ABX_REMOTE_SELF_TOKEN)
93
+ return null;
94
+ return ('ABX_RESOLVER_ADMIN_TOKEN is set but is no longer read for the self-host default — rename it to ' +
95
+ 'ABX_REMOTE_SELF_TOKEN (and, if you address it by name, ABX_REMOTE_SELF_URL).');
96
+ }
97
+ /** The token, when the remote is the command's OBJECT (add/index/forget/render/migrate-dest) —
98
+ * a missing credential is a hard stop that names the exact var to set. */
99
+ export function requireRemoteToken(t, env = process.env) {
100
+ if (t.token)
101
+ return t.token;
102
+ if (t.source === 'builtin') {
103
+ throw new Error(`remote 'abx' needs ${ABX_SERVICES_API_KEY_VAR} in your private .env, or --remote-token. ` +
104
+ `Run \`abx auth login\` for the browser-approved flow (manual fallback: ${ABX_SERVICES_URL}/signup).`);
105
+ }
106
+ if (t.source === 'named') {
107
+ // The likeliest cause of "URL but no token" is a near-miss var name, and the value is sitting
108
+ // right there in .env — so name it instead of letting them diff strings by eye.
109
+ const nearMiss = misnamedRemoteVars(env).find((v) => v.suggestion === t.tokenVar);
110
+ throw new Error(`remote '${t.name}' has a URL but no token — set ${t.tokenVar} in your .env (the API key the provider issued), or pass --remote-token.` +
111
+ (nearMiss ? `\n Found ${nearMiss.key} in your env — that name isn't read; rename it to ${t.tokenVar}.` : ''));
112
+ }
113
+ // The self-host default/URL lane used to read ABX_RESOLVER_ADMIN_TOKEN directly. It's now just
114
+ // the named remote called "self" — no special-casing, same grammar as any other name — so the OLD
115
+ // var is never read here. No silent fallback: point at both new vars, once, by name.
116
+ const migration = selfTokenMigrationWarning(env);
117
+ if (migration)
118
+ throw new Error(`${migration} Or pass --remote-token.`);
119
+ throw new Error(`remote ops need ${t.tokenVar} in your .env — it must match the token set on the resolver ` +
120
+ '(`abx deploy-resolver` generates one and wires both sides). Or pass --remote-token.');
121
+ }
122
+ /** Every named remote configured in the env (`ABX_REMOTE_<NAME>_URL`). The normalized name is
123
+ * canonical — the env convention is lossy, so enumeration reads the env, never inverts it. */
124
+ export function listConfiguredRemotes(env = process.env) {
125
+ const out = [
126
+ { name: 'ABX', url: ABX_SERVICES_URL, hasToken: !!env[ABX_SERVICES_API_KEY_VAR] },
127
+ ];
128
+ for (const [key, value] of Object.entries(env)) {
129
+ const m = /^ABX_REMOTE_(.+)_URL$/.exec(key);
130
+ if (!m || !value)
131
+ continue;
132
+ if (m[1] === 'ABX')
133
+ continue;
134
+ out.push({ name: m[1], url: value.replace(/\/+$/, ''), hasToken: !!env[`ABX_REMOTE_${m[1]}_TOKEN`] });
135
+ }
136
+ return out.sort((a, b) => a.name.localeCompare(b.name));
137
+ }
138
+ /**
139
+ * `ABX_REMOTE_*` vars that follow no recognized suffix — i.e. a typo. The convention has exactly two
140
+ * suffixes (`_URL`, `_TOKEN`), and anything else (`_KEY`, `_APIKEY`, `_SECRET`) is silently ignored:
141
+ * the CLI reports "no token" while the value sits right there in `.env`. Cheap to detect, so detect
142
+ * it rather than leaving the creator to compare strings by eye.
143
+ */
144
+ export function misnamedRemoteVars(env = process.env) {
145
+ const out = [];
146
+ for (const key of Object.keys(env)) {
147
+ if (!key.startsWith('ABX_REMOTE_') || key === 'ABX_REMOTE_TOKEN')
148
+ continue;
149
+ if (/_URL$/.test(key) || /_TOKEN$/.test(key))
150
+ continue;
151
+ // Strip a trailing credential-ish word to recover the intended remote name.
152
+ const name = key.replace(/^ABX_REMOTE_/, '').replace(/_(KEY|APIKEY|API_KEY|SECRET|PASS|PASSWORD|BEARER|AUTH)$/, '');
153
+ out.push({ key, suggestion: `ABX_REMOTE_${name}_TOKEN` });
154
+ }
155
+ return out.sort((a, b) => a.key.localeCompare(b.key));
156
+ }
157
+ /** The SDK service client bound to this target (call {@link requireRemoteToken} first when the
158
+ * operation needs auth). */
159
+ export function serviceClient(t) {
160
+ return new AbxServiceClient({ baseUrl: t.url, token: t.token });
161
+ }
162
+ /**
163
+ * Is this named remote's stored credential actually accepted? One cheap authed read, so `doctor` can
164
+ * report capability instead of mere presence.
165
+ *
166
+ * Doctor is the command a creator runs FIRST, and it used to print a clean `remotes: meridian` for a
167
+ * key the service rejects — the 401 only surfaced later, from `abx remote <name>`, after they had
168
+ * already trusted the line. Same class as an RPC that answers `[]` because it pruned its logs: an
169
+ * empty success is not evidence of capability.
170
+ *
171
+ * Never throws and never blocks doctor for long: a short per-attempt timeout, and anything that is
172
+ * not a definitive rejection is reported as a soft note rather than a ✗, because a slow or briefly
173
+ * unreachable provider is not a misconfiguration the creator can act on.
174
+ */
175
+ export async function probeRemoteCredential(name, timeoutMs = 4000) {
176
+ const target = resolveRemote(name);
177
+ if (!target)
178
+ return { ok: false, fatal: false, detail: '(unresolved)' };
179
+ try {
180
+ // retryDelayMs 0: a 401 is definitive and never retries anyway, but an unreachable provider
181
+ // would otherwise back off across four attempts and stall the one command that must stay quick.
182
+ const client = new AbxServiceClient({ baseUrl: target.url, token: target.token, timeoutMs, retryDelayMs: 0 });
183
+ const projects = await client.listProjects();
184
+ return { ok: true, fatal: false, detail: `· ${projects.length} project(s) visible` };
185
+ }
186
+ catch (err) {
187
+ if (err instanceof AbxServiceError && err.status === 401) {
188
+ return { ok: false, fatal: true, detail: `token rejected (401) — fix or rotate ${tokenVarFor(name)}` };
189
+ }
190
+ if (err instanceof AbxServiceError && err.status === 403) {
191
+ return { ok: false, fatal: false, detail: '(authorized key, scoped by the provider — not a misconfiguration)' };
192
+ }
193
+ return { ok: false, fatal: false, detail: `(unreachable right now: ${err.message.slice(0, 60)})` };
194
+ }
195
+ }
196
+ /** The env var a named remote's token is read from — the one to name when it is rejected. */
197
+ export function tokenVarFor(name) {
198
+ if (name.toUpperCase() === 'ABX')
199
+ return ABX_SERVICES_API_KEY_VAR;
200
+ return `ABX_REMOTE_${name.toUpperCase()}_TOKEN`;
201
+ }
202
+ /**
203
+ * Map a control-plane failure to an actionable CLI error. Keys off `AbxServiceError.code`/status,
204
+ * never off message prose (the machine-code half of the interface spec):
205
+ * 401 — the credential itself was rejected → name the var that supplied it.
206
+ * 403 — credential fine, not authorized for this resource → provider scoping, don't retry.
207
+ * `disabled` — the node has no control-plane token configured at all.
208
+ * bare 404 on /v1 — no control plane at this URL (pre-/v1 node, or not an ABX service).
12
209
  */
13
- /** Normalize a resolver base URL to its `/admin/projects` control-plane endpoint. */
14
- export function adminProjectsUrl(base) {
15
- return base.replace(/\/+$/, '') + '/admin/projects';
210
+ export function describeRemoteError(err, t, label) {
211
+ if (!(err instanceof AbxServiceError))
212
+ return err;
213
+ if (err.status === 0) {
214
+ // Nothing answered. Say WHERE we asked and, for the bare form, which env var chose it — a lone
215
+ // `fetch failed` leaves the creator with no idea which URL was even tried.
216
+ const from = t.source === 'default'
217
+ ? ' (bare `--remote` uses ABX_PUBLIC_BASE_URL, else ABX_RESOLVER_URL)'
218
+ : t.source === 'named'
219
+ ? ` (from ABX_REMOTE_${t.name}_URL)`
220
+ : t.source === 'builtin'
221
+ ? ' (built-in first-party ABX Services target)'
222
+ : '';
223
+ return new Error(`${label}: nothing responded at ${t.url}${from}. Is it running, and is that the right address?`);
224
+ }
225
+ if (err.status === 401) {
226
+ return new Error(`${label}: 401 unauthorized — ${t.url} rejected ${tokenSourceLabel(t)}. ` +
227
+ (t.tokenFrom === 'flag'
228
+ ? `That value is wrong or stale — get a fresh key from the provider (${t.tokenVar} in .env is what a normal run reads).`
229
+ : 'Fix or rotate the key (or pass --remote-token to test a replacement).'));
230
+ }
231
+ if (err.status === 403) {
232
+ return new Error(`${label}: 403 forbidden — the token is valid but not authorized for this project/chain (provider-side scoping, not a typo). ` +
233
+ `Check the provider's dashboard and its descriptor (\`abx remote ${t.name ?? t.url}\`).`);
234
+ }
235
+ if (err.code === 'not_registered') {
236
+ // The likeliest cause when READING a remote (status/index/render) is that the bridge step was
237
+ // never done — the service has no idea this contract exists. Name the fix, not the 404.
238
+ return new Error(`${label}: ${t.url} doesn't have this project registered — it can't serve or report on a contract it was never told about. ` +
239
+ `Register it: \`abx add <address> --remote ${t.name?.toLowerCase() ?? t.url}\`.`);
240
+ }
241
+ if (err.code === 'disabled') {
242
+ return new Error(`${label}: the resolver at ${t.url} has no control-plane token configured — it can't accept remote registrations. For your own node, set ABX_RESOLVER_ADMIN_TOKEN on it (\`abx deploy-resolver\` wires it).`);
243
+ }
244
+ if (err.status === 404 && !err.code) {
245
+ return new Error(`${label}: ${t.url} has no /v1 control plane — an older resolver (redeploy it: \`abx deploy-resolver\`), or not an ABX service. ` +
246
+ `Check: curl ${t.url}/.well-known/abx-service`);
247
+ }
248
+ // A 5xx that volunteered a failure CLASS is the difference between "wait" and "something is
249
+ // broken" — and it's the only thing a credential-free 500 body is allowed to tell us, so use it.
250
+ if (err.class === 'rpc_rate_limited' || err.class === 'rpc_unavailable') {
251
+ return new Error(`${label}: the service reached its chain RPC ${err.class === 'rpc_rate_limited' ? 'rate limit' : 'and got no answer'} (${err.class}) — ` +
252
+ `not your credential and not your address. It retries with backoff; check progress with \`abx status <address> --remote ${t.name?.toLowerCase() ?? t.url}\`.`);
253
+ }
254
+ return new Error(`${label}: ${err.message}`);
255
+ }
256
+ // The `--remote <name|url>` target (remote.ts owns the convention): a named remote's
257
+ // `ABX_REMOTE_<NAME>_URL/_TOKEN`, an ad-hoc URL, or bare `--remote` = the self-host default.
258
+ // Returns null for a local op (the default).
259
+ export function remoteFlag(flags) {
260
+ return resolveRemote(flags.remote, flags['remote-token']);
261
+ }
262
+ /**
263
+ * The factory-verification tri-state, said plainly. `null` means the check never ran (no factory
264
+ * configured, or the configured one has no code on this chain — common on a local/dev chain), which
265
+ * is NOT the same as the chain telling us this contract isn't a clone of it.
266
+ */
267
+ export function canonicalLabel(isCanonical, provenance) {
268
+ if (isCanonical === true) {
269
+ // Say WHICH generation stamped it, and its core version — "canonically ABX v2" is a thing a
270
+ // consumer can repeat, and `abxVersion()` on the clone is where they can verify it themselves.
271
+ const v = provenance?.coreVersion !== null && provenance?.coreVersion !== undefined ? ` — ABX v${provenance.coreVersion}` : '';
272
+ if (provenance?.generation === 'prior') {
273
+ return `${g('yes (factory-verified)')}${dim(`${v}, a PRIOR anchor generation — canonically ABX, deployed by a factory since replaced`)}`;
274
+ }
275
+ return g(`yes (factory-verified${v})`);
276
+ }
277
+ // "the configured factory" (singular) understated the check and misdirected the reader: since the
278
+ // edition anchors were added, `detectCanonicalFactory` probes ALL SIX trust anchors (three 721 +
279
+ // three ERC-1155) and only falls back to the 1/1 anchor when none of them claim the clone. So a
280
+ // `false` means "no trust anchor this CLI knows deployed this", not "you configured the wrong one" —
281
+ // and the usual real cause is a contract from a SUPERSEDED factory, or one deployed by hand.
282
+ if (isCanonical === false) {
283
+ return `${c.orange}NO — not a clone of any trust anchor this CLI knows${c.reset}${dim(' (a superseded factory, or deployed outside one — `abx doctor` lists the current anchors)')}`;
284
+ }
285
+ if (provenance && provenance.anchorsAnswered === 0) {
286
+ return dim('not checked (no anchor answered — a coverage gap, not a verdict; retry or check the RPC)');
287
+ }
288
+ return dim('not checked (no canonical factory for this chain — `abx doctor` shows which)');
289
+ }
290
+ /** How a lifecycle state reads at a glance — the same word everywhere it's printed. */
291
+ export function statusLabel(s) {
292
+ if (s === 'live')
293
+ return g('live');
294
+ if (s === 'failed')
295
+ return `${c.orange}failed${c.reset}`;
296
+ if (s === 'stale')
297
+ return `${c.orange}stale${c.reset}`;
298
+ return dim(s); // queued | backfilling — in progress, not a problem
299
+ }
300
+ /** `label value` with only the label dimmed — status values carry their own color, and wrapping
301
+ * them in `info()` would fight it. */
302
+ export const statusRow = (label, value) => console.log(` ${dim(label.padEnd(10))} ${value}`);
303
+ /**
304
+ * What to DO about a failure class — whose problem it is and whether waiting is the answer.
305
+ * The class alone told an agent enough to reason it out; it does not tell a creator, and "whose
306
+ * problem is this" is the single question a failed catch-up has to answer.
307
+ */
308
+ export function indexErrorAction(cls) {
309
+ if (cls === 'rpc_rate_limited')
310
+ return "the SERVICE's chain RPC is throttled — not your key, address, or chain. It retries on its own; if it stays this way, that's the operator's to fix.";
311
+ if (cls === 'rpc_unavailable')
312
+ return "the SERVICE can't reach its chain RPC — not your key, address, or chain. It retries on its own; if it stays this way, contact the operator.";
313
+ if (cls === 'not_abx_contract')
314
+ return 'the service found no ABX events at that address on this chain — check the address and that the service serves the right chain.';
315
+ return 'the cause is in the service operator’s logs — nothing you can fix from here; contact them if it persists.';
316
+ }
317
+ /** The one wording for "registered, but catch-up failed" — shared by add/index so both say the same
318
+ * thing: what failed, whose problem it is, and that the registration survived. */
319
+ export function failedCatchUpMessage(address, remote, err, check) {
320
+ const cls = err?.class;
321
+ return (`${address} is registered on ${remote.url}, but its catch-up FAILED` +
322
+ `${cls ? ` (${cls}${err?.message ? `: ${err.message}` : ''})` : ''}.\n` +
323
+ ` ${cls ? `→ ${indexErrorAction(cls)}\n ` : ''}` +
324
+ `The registration is durable and the service retries with backoff — watch it with ${bold(check + ' --watch')}.`);
16
325
  }
17
- function authHeaders(token) {
18
- return { authorization: `Bearer ${token}`, 'content-type': 'application/json' };
326
+ /**
327
+ * One human line for a status read: where it is, how far along, and why if it's unhappy.
328
+ *
329
+ * What "where" means depends on the state, so say the right thing rather than one number that reads
330
+ * differently in each: a percentage is only honest while BACKFILLING (see indexProgress). A `live`
331
+ * project's `toBlock` only advances when that project has events, so on a busy chain a perfectly
332
+ * current project sits far below head — printing that as a ratio makes healthy look broken.
333
+ */
334
+ export function statusLine(s) {
335
+ const p = indexProgress(s);
336
+ let where;
337
+ if (p)
338
+ where = `${s.toBlock}/${s.headBlock} ${dim(`(${p.percent}%)`)}`;
339
+ else if (!s.toBlock)
340
+ where = dim('not indexed yet');
341
+ else if (s.status === 'live')
342
+ where = `${g('caught up')} ${dim(`· scanned through block ${s.toBlock}`)}`;
343
+ else if (s.status === 'stale')
344
+ where = `${dim('not tracking head right now')} ${dim(`· scanned through block ${s.toBlock}${s.headBlock ? ` of ${s.headBlock}` : ''}`)}`;
345
+ else
346
+ where = dim(`scanned through block ${s.toBlock}`);
347
+ const why = s.error ? ` ${c.orange}${s.error.class}${c.reset}${s.error.message ? dim(` — ${s.error.message}`) : ''}` : '';
348
+ return `${statusLabel(s.status)} ${where}${why}`;
19
349
  }
20
- /** Map a non-2xx admin response into a useful Error (surfaces the server's message). */
21
- async function asError(label, resp) {
22
- let detail = '';
350
+ /**
351
+ * Report a register/reindex answer, whichever of the two conformant shapes the service used.
352
+ *
353
+ * A `200` already carries the counts. A `202` means the registration is durable and catch-up is still
354
+ * running — so by default we poll to a terminal state and print the SAME summary line, giving the
355
+ * human the "waits, then tells you what happened" UX without the service holding a socket open for
356
+ * minutes. `--no-wait` stops at the 202 and names the command that checks later.
357
+ */
358
+ export async function reportRemoteIndexing(remote, chainId, address, r, flags, verb) {
359
+ // A real ABX clone ALWAYS emits a spine (its extension registrations at minimum), so a caught-up
360
+ // projection with zero events means the service scanned the wrong chain/floor or its RPC hasn't
361
+ // served the logs — not that the project is empty. A ✓ there is the lie that produces an empty
362
+ // dashboard (the same guard `reindexAfterDeploy` applies locally).
363
+ const settledLine = (events, tail) => {
364
+ if (events > 0)
365
+ ok(`remote resolver ${verb} ${address}: ${tail}`);
366
+ else
367
+ warn(`${address} is registered and caught up on ${remote.url}, but with ${bold('0 events')} — it will serve nothing. Check the service covers ${CHAIN} and that its RPC serves logs from the deploy block.`);
368
+ };
369
+ if (!isAccepted(r)) {
370
+ settledLine(r.project.eventCount, `${r.project.eventCount} events ${dim(`(${r.mode}, ${r.elapsedMs}ms)`)}`);
371
+ return;
372
+ }
373
+ const spec = remote.name ? remote.name.toLowerCase() : remote.source === 'default' ? '' : remote.url;
374
+ const check = `abx status ${address} --remote${spec ? ` ${spec}` : ''}`;
375
+ // The registration is durable in EVERY branch here — but don't claim it "is catching up" when the
376
+ // service already told us the catch-up failed. Two different sentences for two different facts.
377
+ if (r.project.status === 'failed') {
378
+ // Lead with the outcome, not the successful sub-step: a line starting "registered on …" reads
379
+ // as success even with the failure later in the sentence.
380
+ warn(`${bold('catch-up FAILED')} on ${remote.url} — nothing is being served yet ${dim('(the registration itself is durable; the service retries it)')}`);
381
+ }
382
+ else {
383
+ info(`registered — ${r.project.status} ${dim('(the service accepted it and is catching up; the registration is durable)')}`);
384
+ }
385
+ // A known failure is not something to "not wait" for — we already have the answer, so report it as
386
+ // one regardless of --no-wait (never a ✓ over a broken index).
387
+ if (flags['no-wait'] !== undefined && r.project.status !== 'failed') {
388
+ info(`not waiting (--no-wait). Check with ${bold(check)}`);
389
+ return;
390
+ }
391
+ const label = `remote ${verb === 'indexed' ? 'add' : 'index'}`;
392
+ if (r.project.status === 'failed') {
393
+ // Fetch the class the register response may not have carried, so the "whose problem" line is
394
+ // never missing on the path that reports the failure soonest.
395
+ const st = await serviceClient(remote).projectStatus(chainId, address).catch(() => undefined);
396
+ throw new Error(`${label}: ${failedCatchUpMessage(address, remote, st?.error ?? undefined, check)}`);
397
+ }
398
+ let shown = -100;
399
+ let lastStatus;
23
400
  try {
24
- detail = (await resp.json()).error ?? '';
25
- }
26
- catch {
27
- /* non-JSON body */
28
- }
29
- if (resp.status === 401) {
30
- return new Error(`${label}: 401 unauthorized — ABX_RESOLVER_ADMIN_TOKEN doesn't match the token on the resolver.`);
31
- }
32
- if (resp.status === 404 && detail.includes('disabled')) {
33
- return new Error(`${label}: the resolver has no admin token set — it can't accept remote add/remove. ${detail}`);
34
- }
35
- return new Error(`${label}: ${resp.status} ${detail || resp.statusText}`);
36
- }
37
- /** Register + index a project with a remote resolver (remote `abx add`/`index`). */
38
- export async function remoteAddProject(base, token, body) {
39
- const resp = await fetch(adminProjectsUrl(base), {
40
- method: 'POST',
41
- headers: authHeaders(token),
42
- body: JSON.stringify(body),
43
- });
44
- if (!resp.ok)
45
- throw await asError('remote add', resp);
46
- return (await resp.json());
47
- }
48
- /** Stop a remote resolver from indexing a project (remote `abx forget`). */
49
- export async function remoteRemoveProject(base, token, address) {
50
- const resp = await fetch(`${adminProjectsUrl(base)}/${address}`, { method: 'DELETE', headers: authHeaders(token) });
51
- if (!resp.ok && resp.status !== 404)
52
- throw await asError('remote remove', resp);
401
+ const final = await serviceClient(remote).awaitIndexed(chainId, address, {
402
+ onProgress: (s) => {
403
+ const p = indexProgress(s);
404
+ // Print on a state change or a meaningful step — a poll line every 3s is noise in a log an
405
+ // agent has to read back.
406
+ if (s.status !== lastStatus || (p && p.percent - shown >= 10)) {
407
+ lastStatus = s.status;
408
+ if (p)
409
+ shown = p.percent;
410
+ console.log(` ${statusLine(s)}`);
411
+ }
412
+ },
413
+ });
414
+ if (final.status === 'failed') {
415
+ throw new Error(`${label}: ${failedCatchUpMessage(address, remote, final.error, check)}`);
416
+ }
417
+ settledLine(final.eventCount, `${final.eventCount} events, ${final.tokenCount} token(s) ${dim('(live)')}`);
418
+ }
419
+ catch (err) {
420
+ if (err instanceof AbxIndexTimeoutError) {
421
+ warn(`${address} is still ${err.last?.status ?? 'catching up'} on ${remote.url} — nothing is lost, it just isn't done.`);
422
+ info(`follow it with ${bold(check + ' --watch')}`);
423
+ return;
424
+ }
425
+ // The service went away mid-wait (or rejected the poll). The registration still landed — say
426
+ // which failure this is, in the same words every other remote command uses.
427
+ if (err instanceof AbxServiceError)
428
+ throw describeRemoteError(err, remote, `remote ${verb}: registered, but polling status`);
429
+ throw err;
430
+ }
431
+ }
432
+ /** "3 live, 1 backfilling, 1 failed (rpc_rate_limited)" — the one-line answer to "is my stuff ok?" */
433
+ export function rollUp(projects) {
434
+ const counts = new Map();
435
+ for (const p of projects) {
436
+ const k = p.status ?? 'unknown';
437
+ counts.set(k, (counts.get(k) ?? 0) + 1);
438
+ }
439
+ const classes = [...new Set(projects.filter((p) => p.error).map((p) => p.error.class))];
440
+ const parts = [...counts.entries()].map(([k, n]) => `${n} ${k}`);
441
+ return `${parts.join(', ')}${classes.length ? ` ${dim(`(${classes.join(', ')})`)}` : ''}`;
53
442
  }
54
443
  //# sourceMappingURL=remote.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"remote.js","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA6BH,qFAAqF;AACrF,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,iBAAiB,CAAC;AACtD,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,EAAC,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAC,CAAC;AAChF,CAAC;AAED,wFAAwF;AACxF,KAAK,UAAU,OAAO,CAAC,KAAa,EAAE,IAAc;IAClD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,GAAI,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAsB,CAAC,KAAK,IAAI,EAAE,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,mBAAmB;IACrB,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACxB,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,wFAAwF,CAAC,CAAC;IACrH,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACvD,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,8EAA8E,MAAM,EAAE,CAAC,CAAC;IACnH,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC,MAAM,IAAI,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAY,EAAE,KAAa,EAAE,IAAm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C,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzF,MAAM,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjE,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAC5F,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { type Address } from '@artblocks/abx-sdk';
2
+ import { type Lane, type SignResult, type TxProvider } from './signer.js';
3
+ import { type Flags } from './flags.js';
4
+ /** Resolve the signing lane from flags: `--unsigned` (cold) · `--sign` (wallet) · default hot. The
5
+ * one place this decision is made — every write reads the same three flags the same way. */
6
+ export declare function laneFromFlags(flags: Flags): Lane;
7
+ /**
8
+ * Refuse a real deploy on the HOT lane when there is no key to sign with — before the command has
9
+ * spent anything.
10
+ *
11
+ * The signing lanes are checked at *signing* time, which is the end of a deploy. Everything that
12
+ * makes a deploy possible happens first, and some of it is neither free nor reversible: `--backend
13
+ * arweave|ipfs|cloud` UPLOADS the creator's art before any transaction is prepared. So a deploy run
14
+ * with no key, and no `--dry-run` to say "preview only", would mint an Arweave identity, publish the
15
+ * art, and only THEN discover it could never have deployed. Under Turbo's free tier the upload
16
+ * *succeeds*, so the art is published permanently — an irreversible side effect from a run that was
17
+ * always going to fail.
18
+ *
19
+ * `--dry-run` guards every signing choke point (`isDryRun`, `gatedSend`); this is the same idea one
20
+ * step earlier, and the rule it enforces is the sibling of that one: **a spend or a publish never
21
+ * precedes the check that this run can be signed at all.** Only the hot lane is checked — `--sign`
22
+ * (browser wallet) and `--unsigned` (offline signer) deliberately have no local key, and a preview
23
+ * spends nothing.
24
+ */
25
+ export declare function assertLaneCanSign(flags: Flags): void;
26
+ /**
27
+ * Opt-in pre-send confirmation gate (`--confirm`). OFF by default → scripted use is untouched. Even
28
+ * when opted in, it never blocks automation: `--yes` or a non-TTY stdin proceeds silently. Only an
29
+ * interactive `--confirm` prints the summary and waits for a y/N. Aborts on anything but yes.
30
+ */
31
+ export declare function confirmSend(summary: string, flags: Flags): Promise<void>;
32
+ export interface DryRunSimulation {
33
+ status: 'would-succeed' | 'would-revert' | 'unknown';
34
+ reason?: string;
35
+ }
36
+ /**
37
+ * A revert's own name, when the payload carries one — `RoyaltyTooHigh()` instead of a raw hex dump
38
+ * or "reverted for an unknown reason".
39
+ *
40
+ * Whether we get one is the NODE's choice, not ours: many public endpoints (measured:
41
+ * `base-sepolia-rpc.publicnode.com` and `sepolia.base.org`) answer a failed `eth_call` with a bare
42
+ * `execution reverted` and no data at all. So the no-data case says *that*, rather than implying we
43
+ * looked at a reason and couldn't read it.
44
+ */
45
+ export declare function revertReason(err: unknown): string;
46
+ export interface GatedSendOptions {
47
+ chainKey: string;
48
+ /** The address that must sign (onlyOwner / token holder) — shown to the human, guards the hot
49
+ * lane, and (when set) printed on the dry-run preview. */
50
+ expectedSigner?: Address;
51
+ }
52
+ /**
53
+ * The one send choke point for a SINGLE already-prepared write: `--dry-run` preview (nothing sent,
54
+ * returns `null`) → optional `--confirm` prompt → lane selection → `signTx`. Every caller — an
55
+ * owner-op's `runWrite`/`runMinterWrite`, or the deploy family's resumed-setup send — resolves to
56
+ * this, so the two families can never again each carry their own (possibly diverging) idea of what
57
+ * `--dry-run` or `--confirm` means. The historical bug class this forecloses structurally: a write
58
+ * reaching the send lane under `--dry-run` because some caller re-derived the check by hand and
59
+ * missed a branch.
60
+ */
61
+ export declare function gatedSend(provider: TxProvider, flags: Flags, opts: GatedSendOptions): Promise<SignResult | null>;
62
+ //# sourceMappingURL=riskgate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"riskgate.d.ts","sourceRoot":"","sources":["../src/riskgate.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAgE,KAAK,OAAO,EAAkB,MAAM,oBAAoB,CAAC;AAChI,OAAO,EAAS,KAAK,IAAI,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAC,MAAM,aAAa,CAAC;AAChF,OAAO,EAAW,KAAK,KAAK,EAAC,MAAM,YAAY,CAAC;AAOhD;6FAC6F;AAC7F,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAoBhD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAUpD;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAO9E;AAaD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,GAAG,cAAc,GAAG,SAAS,CAAC;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAkBjD;AA4DD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB;+DAC2D;IAC3D,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA+BtH"}