@humanode-hyperlane/cli 30.0.0 → 1045.2.0

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 (53) hide show
  1. package/README.md +1 -1
  2. package/bundle/154.index.js +462 -0
  3. package/bundle/230.index.js +572 -0
  4. package/bundle/25.index.js +9569 -0
  5. package/bundle/{214.index.js → 308.index.js} +192 -88
  6. package/bundle/367.index.js +4 -0
  7. package/bundle/461.index.js +49 -0
  8. package/bundle/505.index.js +126369 -0
  9. package/bundle/529.index.js +3603 -0
  10. package/bundle/576.index.js +36 -0
  11. package/bundle/610.index.js +86 -0
  12. package/bundle/628.index.js +152 -0
  13. package/bundle/633.index.js +86 -0
  14. package/bundle/697.index.js +410 -0
  15. package/bundle/{30fb121a258f7502fa97.js → 7183ea1c1bf0a5da980d.js} +1 -1
  16. package/bundle/748.index.js +674 -0
  17. package/bundle/78.index.js +372 -0
  18. package/bundle/787.index.js +175 -0
  19. package/bundle/841.index.js +2093 -0
  20. package/bundle/{172.index.js → 848.index.js} +779 -915
  21. package/bundle/868.index.js +460 -0
  22. package/bundle/902.index.js +173 -0
  23. package/bundle/956.index.js +9901 -0
  24. package/bundle/aleo_wasm.wasm +0 -0
  25. package/bundle/aleo_wasm1.wasm +0 -0
  26. package/bundle/build/Release/bigint_buffer.node +0 -0
  27. package/bundle/index.js +2 -2
  28. package/bundle/worker2.js +9123 -3469
  29. package/bundle/worker3.js +9109 -3455
  30. package/examples/layerzero/layerzero-warp-route.yaml +91 -0
  31. package/examples/sealevel/core-config-composite-ism.yaml +21 -0
  32. package/examples/sealevel/igp-hook-config.yaml +13 -0
  33. package/examples/sealevel/warp-config-routing-message-id-multisig-ism.yaml +21 -0
  34. package/examples/warp-base.yaml +24 -0
  35. package/examples/warp-config-predicate-mainnet.yaml +14 -0
  36. package/examples/warp-deployed-predicate-mainnet.yaml +19 -0
  37. package/examples/warp-ethereum.yaml +19 -0
  38. package/examples/wormhole/wormhole-warp-route.yaml +46 -0
  39. package/package.json +35 -28
  40. package/bundle/100.index.js +0 -1453
  41. package/bundle/12.index.js +0 -91
  42. package/bundle/213.index.js +0 -901
  43. package/bundle/306.index.js +0 -1037
  44. package/bundle/467.index.js +0 -222
  45. package/bundle/485.index.js +0 -85430
  46. package/bundle/515.index.js +0 -5191
  47. package/bundle/544.index.js +0 -792
  48. package/bundle/617.index.js +0 -1612
  49. package/bundle/660.index.js +0 -223
  50. package/bundle/688.index.js +0 -232
  51. package/bundle/756.index.js +0 -8595
  52. package/bundle/824.index.js +0 -385
  53. package/bundle/95.index.js +0 -264
@@ -0,0 +1,674 @@
1
+ export const id = 748;
2
+ export const ids = [748];
3
+ export const modules = {
4
+
5
+ /***/ 60367:
6
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7
+
8
+
9
+ // EXPORTS
10
+ __webpack_require__.d(__webpack_exports__, {
11
+ createSvmForkManager: () => (/* reexport */ createSvmForkManager),
12
+ parseSvmForkConfig: () => (/* reexport */ parseSvmForkConfig)
13
+ });
14
+
15
+ // UNUSED EXPORTS: PrintableSvmTransactionSchema, SURFPOOL_MIN_VERSION, SolanaCluster, SurfpoolDatasourceMode, SvmForkManager, SvmRawForkConfigSchema, runSurfpoolNode
16
+
17
+ // EXTERNAL MODULE: external "child_process"
18
+ var external_child_process_ = __webpack_require__(35317);
19
+ // EXTERNAL MODULE: external "node:fs"
20
+ var external_node_fs_ = __webpack_require__(73024);
21
+ // EXTERNAL MODULE: external "node:net"
22
+ var external_node_net_ = __webpack_require__(77030);
23
+ // EXTERNAL MODULE: external "node:os"
24
+ var external_node_os_ = __webpack_require__(48161);
25
+ // EXTERNAL MODULE: external "node:path"
26
+ var external_node_path_ = __webpack_require__(76760);
27
+ // EXTERNAL MODULE: ../forking-sdk/dist/index.js + 3 modules
28
+ var dist = __webpack_require__(65310);
29
+ // EXTERNAL MODULE: ../utils/dist/logging.js
30
+ var logging = __webpack_require__(94523);
31
+ // EXTERNAL MODULE: ../utils/dist/typeof.js
32
+ var dist_typeof = __webpack_require__(73689);
33
+ // EXTERNAL MODULE: ../utils/dist/validation.js
34
+ var validation = __webpack_require__(21387);
35
+ // EXTERNAL MODULE: ../svm-sdk/dist/rpc.js + 9 modules
36
+ var dist_rpc = __webpack_require__(48080);
37
+ ;// CONCATENATED MODULE: ../svm-sdk/dist/fork/surfpool-node.js
38
+ // eslint-disable-next-line import/no-nodejs-modules
39
+
40
+ // eslint-disable-next-line import/no-nodejs-modules
41
+
42
+ // eslint-disable-next-line import/no-nodejs-modules
43
+
44
+ // eslint-disable-next-line import/no-nodejs-modules
45
+
46
+ // eslint-disable-next-line import/no-nodejs-modules
47
+
48
+
49
+
50
+
51
+ const SEMVER_REGEX = /(\d+)\.(\d+)\.(\d+)/;
52
+ const SURFPOOL_VERSION_REGEX = /surfpool\s+(\d+\.\d+\.\d+)/;
53
+ const logger = logging/* rootLogger */.Jk.child({ module: 'surfpool-node' });
54
+ // Minimum acceptable local `surfpool` version; aligned with the docker image
55
+ // `surfpool/surfpool:1.5.0` used by the container runner in test infra.
56
+ const SURFPOOL_MIN_VERSION = '1.5.0';
57
+ // Install guidance surfaced whenever a compatible `surfpool` binary is missing.
58
+ // Points at the pinned, checksum-verified release rather than the mutable
59
+ // `run.surfpool.run` installer, so an operator (or agent) never pipes remote
60
+ // code to a shell.
61
+ const SURFPOOL_INSTALL_GUIDANCE = `Install a pinned surfpool ${SURFPOOL_MIN_VERSION}+ release from ` +
62
+ 'https://github.com/txtx/surfpool/releases and verify its SHA-256 checksum; ' +
63
+ 'do not pipe the mutable run.surfpool.run installer to a shell.';
64
+ // Env var surfpool reads for its fork datasource. Passing the (possibly
65
+ // credential-bearing) upstream URL this way keeps it out of the process argv.
66
+ const SURFPOOL_DATASOURCE_RPC_URL_ENV = 'SURFPOOL_DATASOURCE_RPC_URL';
67
+ // Per-probe RPC timeout so a single hung request fails fast and the bounded
68
+ // readiness loop can continue.
69
+ const RPC_PROBE_TIMEOUT_MS = 5000;
70
+ // Cap on the retained tail of surfpool stderr, surfaced in exit errors.
71
+ const STDERR_TAIL_MAX = 8192;
72
+ const REDACTED_DATASOURCE_URL = '<redacted-datasource-url>';
73
+ // URL userinfo credentials (scheme://user:pass@host). A defense-in-depth
74
+ // backstop that scrubs a reformatted/percent-encoded credential the exact
75
+ // datasource-URL match would miss.
76
+ const URL_USERINFO_CREDENTIALS_RE = /\/\/[^/@\s]+:[^/@\s]+@/g;
77
+ /**
78
+ * Scrubs secrets from surfpool stderr before it is embedded in a surfaced error.
79
+ * surfpool prints stderr verbatim (not shell-escaped), so the known
80
+ * credential-bearing datasource URL is removed by exact-string replacement;
81
+ * stripping URL userinfo credentials is a backstop for any other credential URL.
82
+ */
83
+ function redactSurfpoolStderr(detail, datasourceUrl) {
84
+ const withoutDatasource = (0,dist_typeof/* isNullish */.u)(datasourceUrl)
85
+ ? detail
86
+ : detail.split(datasourceUrl).join(REDACTED_DATASOURCE_URL);
87
+ return withoutDatasource.replace(URL_USERINFO_CREDENTIALS_RE, '//<redacted>@');
88
+ }
89
+ const SurfpoolDatasourceMode = {
90
+ Fork: 'fork',
91
+ Network: 'network',
92
+ Offline: 'offline',
93
+ };
94
+ const SolanaCluster = {
95
+ Mainnet: 'mainnet',
96
+ Devnet: 'devnet',
97
+ Testnet: 'testnet',
98
+ };
99
+ const SURFPOOL_BINARY_PATHS = [
100
+ (0,external_node_path_.join)((0,external_node_os_.homedir)(), '.cargo/bin'),
101
+ '/opt/homebrew/bin',
102
+ '/usr/local/bin',
103
+ ];
104
+ function parseVersion(version) {
105
+ const match = version.match(SEMVER_REGEX);
106
+ if (!match)
107
+ return null;
108
+ const [, major, minor, patch] = match;
109
+ (0,validation/* assert */.v)(major && minor && patch, `Invalid surfpool version: ${version}`);
110
+ return {
111
+ major: parseInt(major, 10),
112
+ minor: parseInt(minor, 10),
113
+ patch: parseInt(patch, 10),
114
+ };
115
+ }
116
+ function meetsMinVersion(version, min) {
117
+ if (version.major !== min.major)
118
+ return version.major > min.major;
119
+ if (version.minor !== min.minor)
120
+ return version.minor > min.minor;
121
+ return version.patch >= min.patch;
122
+ }
123
+ function getSurfpoolVersion(binaryPath) {
124
+ try {
125
+ const output = (0,external_child_process_.execFileSync)(binaryPath, ['--version'], {
126
+ encoding: 'utf-8',
127
+ });
128
+ const match = output.match(SURFPOOL_VERSION_REGEX);
129
+ return match?.[1] ?? null;
130
+ }
131
+ catch (error) {
132
+ logger.debug({ err: error }, `failed to get surfpool version at ${binaryPath}`);
133
+ return null;
134
+ }
135
+ }
136
+ function findSurfpoolCandidates() {
137
+ const candidates = [];
138
+ for (const basePath of SURFPOOL_BINARY_PATHS) {
139
+ const binaryPath = (0,external_node_path_.join)(basePath, 'surfpool');
140
+ if ((0,external_node_fs_.existsSync)(binaryPath)) {
141
+ const version = getSurfpoolVersion(binaryPath);
142
+ if (version) {
143
+ candidates.push({ path: binaryPath, version });
144
+ }
145
+ }
146
+ }
147
+ try {
148
+ const result = (0,external_child_process_.execSync)('which surfpool', { encoding: 'utf-8' }).trim();
149
+ if (result && (0,external_node_fs_.existsSync)(result)) {
150
+ const version = getSurfpoolVersion(result);
151
+ if (version && !candidates.some((c) => c.path === result)) {
152
+ candidates.push({ path: result, version });
153
+ }
154
+ }
155
+ }
156
+ catch (error) {
157
+ logger.debug({ err: error }, 'surfpool not found in PATH');
158
+ }
159
+ return candidates;
160
+ }
161
+ function buildSurfpoolArgs(config, datasource, bindHost) {
162
+ const args = [
163
+ 'start',
164
+ '--no-tui',
165
+ '--no-studio',
166
+ '--no-deploy',
167
+ '--host',
168
+ bindHost,
169
+ '--port',
170
+ String(config.rpcPort),
171
+ ];
172
+ if (!(0,dist_typeof/* isNullish */.u)(config.wsPort)) {
173
+ args.push('--ws-port', String(config.wsPort));
174
+ }
175
+ if (datasource.mode === SurfpoolDatasourceMode.Network) {
176
+ args.push('--network', datasource.network);
177
+ }
178
+ else if (datasource.mode === SurfpoolDatasourceMode.Offline) {
179
+ args.push('--offline');
180
+ }
181
+ // Fork mode: the datasource URL is passed via the SURFPOOL_DATASOURCE_RPC_URL
182
+ // env (see buildSurfpoolDatasourceEnv) rather than argv.
183
+ if (config.skipSignatureVerification) {
184
+ args.push('--skip-signature-verification');
185
+ }
186
+ if (config.skipBlockhashCheck) {
187
+ args.push('--skip-blockhash-check');
188
+ }
189
+ if (config.airdrops && config.airdrops.addresses.length > 0) {
190
+ for (const address of config.airdrops.addresses) {
191
+ args.push('--airdrop', address);
192
+ }
193
+ args.push('--airdrop-amount', config.airdrops.lamports.toString());
194
+ }
195
+ return args;
196
+ }
197
+ /**
198
+ * Spawn env carrying surfpool's fork datasource URL. Empty for network/offline
199
+ * datasources, which take no credentials and are expressed via argv flags.
200
+ */
201
+ function buildSurfpoolDatasourceEnv(datasource) {
202
+ if (datasource.mode !== SurfpoolDatasourceMode.Fork) {
203
+ return {};
204
+ }
205
+ return { [SURFPOOL_DATASOURCE_RPC_URL_ENV]: datasource.rpcUrl };
206
+ }
207
+ /**
208
+ * Per-attempt abort signal that fires after `timeoutMs`, or immediately when
209
+ * `parent` aborts (so a caller cancelling the readiness loop also cancels the
210
+ * in-flight probe request). Composed manually to stay usable on Node <17, which
211
+ * lacks `AbortSignal.timeout`/`AbortSignal.any`. `dispose` clears the timer and
212
+ * detaches the parent listener so nothing lingers between attempts.
213
+ */
214
+ function probeTimeoutSignal(timeoutMs, parent) {
215
+ const controller = new AbortController();
216
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
217
+ const onParentAbort = () => controller.abort();
218
+ if (parent) {
219
+ if (parent.aborted) {
220
+ controller.abort();
221
+ }
222
+ else {
223
+ parent.addEventListener('abort', onParentAbort, { once: true });
224
+ }
225
+ }
226
+ const dispose = () => {
227
+ clearTimeout(timer);
228
+ parent?.removeEventListener('abort', onParentAbort);
229
+ };
230
+ return { signal: controller.signal, dispose };
231
+ }
232
+ async function waitForSolanaRpcReady(rpcUrl, signal) {
233
+ const rpc = (0,dist_rpc/* createRpc */.C8)(rpcUrl);
234
+ await (0,dist/* waitUntilReady */.bs)(async () => {
235
+ const { signal: probeSignal, dispose } = probeTimeoutSignal(RPC_PROBE_TIMEOUT_MS, signal);
236
+ try {
237
+ const health = await rpc.getHealth().send({ abortSignal: probeSignal });
238
+ (0,validation/* assert */.v)(health === 'ok', `surfpool RPC not healthy: ${health}`);
239
+ }
240
+ finally {
241
+ dispose();
242
+ }
243
+ }, { attempts: 60, baseRetryMs: 1000, signal });
244
+ }
245
+ /**
246
+ * Rejects if `port` on 127.0.0.1 is already bound. A bind-test up front closes
247
+ * the port-collision race: proving RPC health after spawn can otherwise pass
248
+ * against an unrelated node already listening on the port, before our freshly
249
+ * spawned child fails with EADDRINUSE.
250
+ */
251
+ async function assertPortAvailable(port) {
252
+ await new Promise((resolve, reject) => {
253
+ const server = (0,external_node_net_.createServer)();
254
+ server.once('error', (error) => {
255
+ const code = 'code' in error ? error.code : undefined;
256
+ reject(code === 'EADDRINUSE'
257
+ ? new Error(`port ${port} is already in use`)
258
+ : error);
259
+ });
260
+ server.once('listening', () => {
261
+ server.close(() => resolve());
262
+ });
263
+ server.listen(port, '127.0.0.1');
264
+ });
265
+ }
266
+ // A single process-level `exit` hook kills every still-running fork, rather than
267
+ // one listener per fork — which would trip MaxListenersExceededWarning past ten
268
+ // forks and retain each child's closure until process exit. A fork joins the
269
+ // registry on start and leaves when it is killed or its child exits.
270
+ const runningForkKills = new Set();
271
+ let forkExitHookInstalled = false;
272
+ function trackForkExit(killFork) {
273
+ runningForkKills.add(killFork);
274
+ if (!forkExitHookInstalled) {
275
+ forkExitHookInstalled = true;
276
+ process.once('exit', () => {
277
+ for (const kill of Array.from(runningForkKills)) {
278
+ kill();
279
+ }
280
+ });
281
+ }
282
+ return () => {
283
+ runningForkKills.delete(killFork);
284
+ };
285
+ }
286
+ async function startLocalSurfpool(config, binaryPath, waitForRpcReady = waitForSolanaRpcReady) {
287
+ // Fail fast if any bind port is taken, before spawning, so we never treat
288
+ // another process's RPC as our fork and never spawn a doomed child that would
289
+ // fail to bind an occupied ws port.
290
+ await assertPortAvailable(config.rpcPort);
291
+ if (!(0,dist_typeof/* isNullish */.u)(config.wsPort)) {
292
+ await assertPortAvailable(config.wsPort);
293
+ }
294
+ const args = buildSurfpoolArgs(config, config.datasource, '127.0.0.1');
295
+ // Suppress surfpool's own logs (its default ./.surfpool/logs dir would clutter
296
+ // the working dir); startup/bind failures still surface on stderr, drained below.
297
+ args.push('--log-level', 'none');
298
+ const proc = (0,external_child_process_.spawn)(binaryPath, args, {
299
+ stdio: ['ignore', 'ignore', 'pipe'],
300
+ detached: false,
301
+ env: { ...process.env, ...buildSurfpoolDatasourceEnv(config.datasource) },
302
+ });
303
+ // Drain stderr into a bounded tail; reading it also keeps the pipe from
304
+ // filling and blocking the child.
305
+ let stderrTail = '';
306
+ proc.stderr?.on('data', (chunk) => {
307
+ stderrTail = (stderrTail + chunk.toString()).slice(-STDERR_TAIL_MAX);
308
+ });
309
+ const rpcUrl = `http://127.0.0.1:${config.rpcPort}`;
310
+ const datasourceUrl = config.datasource.mode === SurfpoolDatasourceMode.Fork
311
+ ? config.datasource.rpcUrl
312
+ : undefined;
313
+ const kill = () => {
314
+ // Leave the process-exit registry whenever the child is gone (killed here,
315
+ // or exited/errored below) so a dead fork never keeps being tracked.
316
+ untrackFork();
317
+ if (config.keepRunning) {
318
+ return;
319
+ }
320
+ if ((0,dist_typeof/* isNullish */.u)(proc.exitCode)) {
321
+ proc.kill('SIGTERM');
322
+ }
323
+ };
324
+ const untrackFork = trackForkExit(kill);
325
+ // A failed spawn (e.g. ENOENT) emits `error` with no guaranteed `exit`, so the
326
+ // readiness race must reject on it — otherwise readiness burns the full probe
327
+ // timeout and reports a misleading RPC error instead of the real spawn failure.
328
+ // Attach synchronously here so no `error` can fire before a listener exists.
329
+ const errored = new Promise((_, reject) => {
330
+ proc.once('error', (error) => {
331
+ untrackFork();
332
+ logger.debug({ err: error }, 'surfpool process error');
333
+ reject(error);
334
+ });
335
+ });
336
+ // A spawn error arriving after readiness (or exit) has already settled the race
337
+ // must not surface as an unhandled rejection.
338
+ errored.catch(() => { });
339
+ // Capture the child's exit synchronously after spawn rather than lazily inside
340
+ // `waitForReady`: `exit` is not replayed, so a caller that waits after the
341
+ // child has already exited must still observe it instead of polling to the
342
+ // readiness bound. Rejecting here also drops the fork from the exit registry.
343
+ const exited = new Promise((_, reject) => {
344
+ proc.once('exit', (code, signal) => {
345
+ untrackFork();
346
+ const detail = redactSurfpoolStderr(stderrTail.trim(), datasourceUrl);
347
+ reject(new Error(`surfpool exited before its RPC was ready (code=${code}, signal=${signal})` +
348
+ (detail ? `: ${detail}` : '')));
349
+ });
350
+ });
351
+ // A later exit (e.g. on kill once readiness has won) must not surface as an
352
+ // unhandled rejection after the race settles.
353
+ exited.catch(() => { });
354
+ const waitForReady = async () => {
355
+ // Abort the readiness probe the instant the race settles so no retry timer
356
+ // keeps polling a dead port after an early exit or spawn error wins.
357
+ const controller = new AbortController();
358
+ try {
359
+ await Promise.race([
360
+ waitForRpcReady(rpcUrl, controller.signal),
361
+ exited,
362
+ errored,
363
+ ]);
364
+ }
365
+ finally {
366
+ controller.abort();
367
+ }
368
+ };
369
+ return { node: { rpcUrl, kill }, waitForReady };
370
+ }
371
+ // A caller-supplied binary is an explicit choice, so failures name the specific
372
+ // cause (missing / not executable / too old) instead of the generic auto-
373
+ // discovery "no compatible binary" message, which would otherwise report the
374
+ // substituted "unknown" version and hide the real problem.
375
+ function resolveExplicitBinary(binaryPath, min) {
376
+ (0,validation/* assert */.v)((0,external_node_fs_.existsSync)(binaryPath), `surfpool binary not found at ${binaryPath}`);
377
+ const version = getSurfpoolVersion(binaryPath);
378
+ (0,validation/* assert */.v)(version, `surfpool binary at ${binaryPath} could not be run (check it is executable and 'surfpool --version' works).`);
379
+ const parsed = parseVersion(version);
380
+ (0,validation/* assert */.v)(parsed && meetsMinVersion(parsed, min), `surfpool at ${binaryPath} is version ${version} but ${SURFPOOL_MIN_VERSION}+ is required. ` +
381
+ SURFPOOL_INSTALL_GUIDANCE);
382
+ return { path: binaryPath, version };
383
+ }
384
+ function resolveDiscoveredBinary(min) {
385
+ const candidates = findSurfpoolCandidates();
386
+ const match = candidates.find((candidate) => {
387
+ const parsed = parseVersion(candidate.version);
388
+ return parsed !== null && meetsMinVersion(parsed, min);
389
+ });
390
+ (0,validation/* assert */.v)(match, candidates.length === 0
391
+ ? `surfpool ${SURFPOOL_MIN_VERSION}+ is required but no surfpool binary was found on PATH. ` +
392
+ SURFPOOL_INSTALL_GUIDANCE
393
+ : `surfpool ${SURFPOOL_MIN_VERSION}+ is required but only found version(s) ` +
394
+ `${candidates.map((c) => c.version).join(', ')}. ` +
395
+ SURFPOOL_INSTALL_GUIDANCE);
396
+ return match;
397
+ }
398
+ /**
399
+ * Starts a surfpool node from a locally-installed `surfpool` binary (version
400
+ * {@link SURFPOOL_MIN_VERSION} or newer) and waits for its RPC to be ready.
401
+ * An explicit `config.binaryPath` is validated up front with a specific error;
402
+ * otherwise the PATH is searched and an install-guidance error is thrown if no
403
+ * compatible binary is found.
404
+ */
405
+ async function runSurfpoolNode(config) {
406
+ const min = parseVersion(SURFPOOL_MIN_VERSION);
407
+ (0,validation/* assert */.v)(min, `Invalid SURFPOOL_MIN_VERSION: ${SURFPOOL_MIN_VERSION}`);
408
+ const match = config.binaryPath
409
+ ? resolveExplicitBinary(config.binaryPath, min)
410
+ : resolveDiscoveredBinary(min);
411
+ logger.debug(`Using local surfpool binary: ${match.path} (v${match.version})`);
412
+ const { node, waitForReady } = await startLocalSurfpool(config, match.path);
413
+ try {
414
+ await waitForReady();
415
+ }
416
+ catch (error) {
417
+ node.kill();
418
+ throw error;
419
+ }
420
+ return node;
421
+ }
422
+ //# sourceMappingURL=surfpool-node.js.map
423
+ // EXTERNAL MODULE: ../../node_modules/.pnpm/@solana+codecs-strings@8.2.0_@typescript+typescript6@6.0.2_fastestsmallesttextencoderdecoder@1.0.22/node_modules/@solana/codecs-strings/dist/index.node.mjs
424
+ var index_node = __webpack_require__(48990);
425
+ // EXTERNAL MODULE: ../../node_modules/.pnpm/@solana+transactions@8.2.0_@typescript+typescript6@6.0.2_fastestsmallesttextencoderdecoder@1.0.22/node_modules/@solana/transactions/dist/index.node.mjs
426
+ var dist_index_node = __webpack_require__(11508);
427
+ // EXTERNAL MODULE: ../../node_modules/.pnpm/@solana+transaction-messages@8.2.0_@typescript+typescript6@6.0.2_fastestsmallesttextencoderdecoder@1.0.22/node_modules/@solana/transaction-messages/dist/index.node.mjs
428
+ var transaction_messages_dist_index_node = __webpack_require__(13464);
429
+ // EXTERNAL MODULE: ../utils/dist/async.js
430
+ var dist_async = __webpack_require__(14918);
431
+ // EXTERNAL MODULE: ../svm-sdk/dist/accounts/address-lookup-table.js
432
+ var address_lookup_table = __webpack_require__(96971);
433
+ // EXTERNAL MODULE: ../svm-sdk/dist/constants.js
434
+ var constants = __webpack_require__(94327);
435
+ // EXTERNAL MODULE: ../svm-sdk/dist/tx.js
436
+ var tx = __webpack_require__(55960);
437
+ // EXTERNAL MODULE: ../svm-sdk/dist/fork/impersonation.js
438
+ var impersonation = __webpack_require__(44391);
439
+ ;// CONCATENATED MODULE: ../svm-sdk/dist/fork/svm-fork-manager.js
440
+
441
+
442
+
443
+
444
+
445
+
446
+
447
+
448
+ const svm_fork_manager_logger = logging/* rootLogger */.Jk.child({ module: 'svm-fork-manager' });
449
+ const RPC_COMMITMENT = 'confirmed';
450
+ const POLL_INTERVAL_MS = 500;
451
+ const POLL_MAX_ATTEMPTS = 60;
452
+ const RESOLVE_ALT_CONCURRENCY = 4;
453
+ const base58Encoder = (0,index_node/* getBase58Encoder */.nZ)();
454
+ const transactionDecoder = (0,dist_index_node/* getTransactionDecoder */.BX)();
455
+ const compiledMessageDecoder = (0,transaction_messages_dist_index_node/* getCompiledTransactionMessageDecoder */.fr)();
456
+ /**
457
+ * Fetches the addresses stored in each address-lookup table referenced by a
458
+ * compiled message, producing the map kit needs to decompile the message and
459
+ * re-compress it against the same tables. Returns `undefined` for a message
460
+ * that uses no lookup tables (so callers can skip compression entirely).
461
+ */
462
+ async function resolveForkLookupTables(rpc, compiledMessage) {
463
+ const lookups = 'addressTableLookups' in compiledMessage
464
+ ? compiledMessage.addressTableLookups
465
+ : undefined;
466
+ if ((0,dist_typeof/* isNullish */.u)(lookups) || lookups.length === 0) {
467
+ return undefined;
468
+ }
469
+ const entries = await (0,dist_async/* concurrentMap */.q1)(RESOLVE_ALT_CONCURRENCY, lookups, async (lookup) => {
470
+ const state = await (0,address_lookup_table/* fetchAddressLookupTableState */.a)(rpc, lookup.lookupTableAddress);
471
+ return [lookup.lookupTableAddress, state.addresses];
472
+ });
473
+ return Object.fromEntries(entries);
474
+ }
475
+ /**
476
+ * Rebuilds the wire transaction to replay against a fork.
477
+ *
478
+ * `transaction_base58` is serialized without the compute-budget instruction
479
+ * (an external executor — Squads / file submitter — prepends it from
480
+ * `computeUnits`, defaulting to {@link DEFAULT_COMPUTE_UNITS}). Replaying it
481
+ * verbatim leaves the tx under the runtime per-instruction default, so a tx that
482
+ * consumes more than that (e.g. a program upgrade) fails on the fork even though
483
+ * real execution succeeds. To match live/Squads execution exactly, every replay
484
+ * tx is decoded and re-emitted with the same `SetComputeUnitLimit` an external
485
+ * executor would prepend — using `computeUnits` when set, `DEFAULT_COMPUTE_UNITS`
486
+ * otherwise (mirroring `buildTransactionMessage`/`transactionToInstructions`).
487
+ *
488
+ * Any address-lookup-table compression in the source tx is preserved: the
489
+ * message is re-compressed against the same tables before compiling, so an
490
+ * ALT-heavy tx (e.g. cross-collateral reconciliation) stays under the 1232-byte
491
+ * packet limit instead of being re-emitted with the accounts inlined. The zero
492
+ * DEFAULT_BLOCKHASH is preserved and accepted because the fork runs with
493
+ * `skipBlockhashCheck` and the send uses `skipPreflight`.
494
+ */
495
+ async function buildForkReplayTransaction(rpc, transaction) {
496
+ const wireBytes = base58Encoder.encode(transaction.transaction_base58);
497
+ const decoded = transactionDecoder.decode(wireBytes);
498
+ const units = transaction.computeUnits ?? constants/* DEFAULT_COMPUTE_UNITS */.I1;
499
+ const compiledMessage = compiledMessageDecoder.decode(decoded.messageBytes);
500
+ (0,validation/* assert */.v)(compiledMessage.version !== 1, 'v1 fork replay requires header-based compute budget support');
501
+ const addressLookupTables = await resolveForkLookupTables(rpc, compiledMessage);
502
+ const message = (0,transaction_messages_dist_index_node/* decompileTransactionMessage */.mm)(compiledMessage, {
503
+ addressesByLookupTableAddress: addressLookupTables,
504
+ });
505
+ const withComputeBudget = (0,transaction_messages_dist_index_node/* prependTransactionMessageInstructions */.rR)((0,tx/* getComputeBudgetInstructions */.oR)(units), message);
506
+ if ((0,dist_typeof/* isNullish */.u)(addressLookupTables)) {
507
+ return (0,dist_index_node/* getBase64EncodedWireTransaction */.RO)((0,dist_index_node/* compileTransaction */.i5)(withComputeBudget));
508
+ }
509
+ // Only versioned (v0) messages reference lookup tables, so a defined ALT map
510
+ // implies a non-legacy message; narrow so kit's compressor accepts it.
511
+ (0,validation/* assert */.v)(withComputeBudget.version === 0, 'address-lookup tables require a v0 transaction');
512
+ const recompressed = (0,transaction_messages_dist_index_node/* compressTransactionMessageUsingAddressLookupTables */.Zg)(withComputeBudget, addressLookupTables);
513
+ return (0,dist_index_node/* getBase64EncodedWireTransaction */.RO)((0,dist_index_node/* compileTransaction */.i5)(recompressed));
514
+ }
515
+ /**
516
+ * Ensures the fork airdrops SOL to the fixed fork-only impersonation fee payer
517
+ * at boot, so keyless impersonated applies can pay fees. surfpool airdrops a
518
+ * single amount to every address, so the fee payer is merged into the caller's
519
+ * address list and the amount is raised to at least the impersonation buffer.
520
+ */
521
+ function withImpersonationAirdrop(airdrops) {
522
+ const feePayer = impersonation/* FORK_IMPERSONATION_FEE_PAYER */.P.address;
523
+ if (!airdrops) {
524
+ return {
525
+ addresses: [feePayer],
526
+ lamports: impersonation/* FORK_IMPERSONATION_AIRDROP_LAMPORTS */.X,
527
+ };
528
+ }
529
+ const addresses = airdrops.addresses.includes(feePayer)
530
+ ? airdrops.addresses
531
+ : [...airdrops.addresses, feePayer];
532
+ const lamports = airdrops.lamports > impersonation/* FORK_IMPERSONATION_AIRDROP_LAMPORTS */.X
533
+ ? airdrops.lamports
534
+ : impersonation/* FORK_IMPERSONATION_AIRDROP_LAMPORTS */.X;
535
+ return { addresses, lamports };
536
+ }
537
+ class RunningSvmFork {
538
+ node;
539
+ rpc;
540
+ rpcUrl;
541
+ constructor(node, rpc, rpcUrl) {
542
+ this.node = node;
543
+ this.rpc = rpc;
544
+ this.rpcUrl = rpcUrl;
545
+ }
546
+ }
547
+ async function startSvmFork(config) {
548
+ const runNode = config.runNode ?? runSurfpoolNode;
549
+ const node = await runNode({
550
+ datasource: {
551
+ mode: SurfpoolDatasourceMode.Fork,
552
+ rpcUrl: config.upstreamRpcUrl,
553
+ },
554
+ rpcPort: config.rpcPort,
555
+ wsPort: config.wsPort,
556
+ airdrops: withImpersonationAirdrop(config.airdrops),
557
+ skipSignatureVerification: true,
558
+ skipBlockhashCheck: true,
559
+ image: config.image,
560
+ binaryPath: config.binaryPath,
561
+ keepRunning: config.keepRunning,
562
+ });
563
+ return new RunningSvmFork(node, (0,dist_rpc/* createRpc */.C8)(node.rpcUrl), node.rpcUrl);
564
+ }
565
+ class SvmForkManager {
566
+ config;
567
+ running;
568
+ constructor(config) {
569
+ this.config = config;
570
+ }
571
+ get requireRunning() {
572
+ const running = this.running;
573
+ (0,validation/* assert */.v)(running, `Fork not started for chain ${this.config.chainName}`);
574
+ return running;
575
+ }
576
+ async start() {
577
+ this.running = await startSvmFork(this.config);
578
+ }
579
+ async applyForkConfig(config) {
580
+ const { rpc } = this.requireRunning;
581
+ for (const transaction of config.transactions) {
582
+ await this.submitTransaction(rpc, transaction);
583
+ }
584
+ }
585
+ getForkedChainMetadata() {
586
+ return {
587
+ rpcUrls: [{ http: this.requireRunning.rpcUrl }],
588
+ blocks: { confirmations: 1 },
589
+ };
590
+ }
591
+ kill() {
592
+ this.running?.node.kill();
593
+ }
594
+ async submitTransaction(rpc, transaction) {
595
+ const wireTransaction = await buildForkReplayTransaction(rpc, transaction);
596
+ svm_fork_manager_logger.debug({ annotation: transaction.annotation }, 'replaying transaction against fork');
597
+ const signature = await rpc
598
+ .sendTransaction(wireTransaction, {
599
+ encoding: 'base64',
600
+ skipPreflight: true,
601
+ maxRetries: 0n,
602
+ preflightCommitment: RPC_COMMITMENT,
603
+ })
604
+ .send();
605
+ const status = await (0,dist_async/* pollAsync */.kp)(async () => {
606
+ const { value } = await rpc.getSignatureStatuses([signature]).send();
607
+ const result = value[0];
608
+ (0,validation/* assert */.v)(result, `transaction ${signature} not processed yet`);
609
+ // A failed tx is terminal: resolve immediately so the assert below
610
+ // surfaces the failure instead of polling until the attempts run out.
611
+ if (!(0,dist_typeof/* isNullish */.u)(result.err)) {
612
+ return result;
613
+ }
614
+ // kit 6.x can report `processed` before `confirmed`; wait for the
615
+ // configured commitment so a dependent next tx doesn't race an
616
+ // unconfirmed one.
617
+ const confirmation = result.confirmationStatus;
618
+ (0,validation/* assert */.v)(confirmation === RPC_COMMITMENT || confirmation === 'finalized', `transaction ${signature} not yet ${RPC_COMMITMENT} (status: ${confirmation})`);
619
+ return result;
620
+ }, POLL_INTERVAL_MS, POLL_MAX_ATTEMPTS);
621
+ (0,validation/* assert */.v)((0,dist_typeof/* isNullish */.u)(status.err), `fork replay transaction ${signature} failed: ${JSON.stringify(status.err, (_key, value) => (typeof value === 'bigint' ? value.toString() : value))}`);
622
+ if (transaction.waitForSlotAdvance) {
623
+ const confirmedSlot = status.slot;
624
+ await (0,dist_async/* pollAsync */.kp)(async () => {
625
+ const slot = await rpc.getSlot({ commitment: RPC_COMMITMENT }).send();
626
+ (0,validation/* assert */.v)(slot > confirmedSlot, `slot ${slot} has not advanced past ${confirmedSlot}`);
627
+ }, POLL_INTERVAL_MS, POLL_MAX_ATTEMPTS);
628
+ }
629
+ }
630
+ }
631
+ function createSvmForkManager(config) {
632
+ return new SvmForkManager(config);
633
+ }
634
+ //# sourceMappingURL=svm-fork-manager.js.map
635
+ // EXTERNAL MODULE: ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/classic/schemas.js + 7 modules
636
+ var schemas = __webpack_require__(58228);
637
+ ;// CONCATENATED MODULE: ../svm-sdk/dist/fork/svm-fork-config.js
638
+
639
+ const PrintableSvmTransactionSchema = schemas/* object */.Ik({
640
+ annotation: schemas/* string */.Yj().optional(),
641
+ instructions: schemas/* array */.YO(schemas/* unknown */.L5()).optional(),
642
+ computeUnits: schemas/* number */.ai().optional(),
643
+ transaction_base58: schemas/* string */.Yj(),
644
+ message_base58: schemas/* string */.Yj().optional(),
645
+ waitForSlotAdvance: schemas/* boolean */.zM().optional(),
646
+ });
647
+ const SvmRawForkConfigSchema = schemas/* union */.KC([
648
+ schemas/* object */.Ik({ transactions: schemas/* array */.YO(PrintableSvmTransactionSchema) }),
649
+ schemas/* object */.Ik({ path: schemas/* string */.Yj() }),
650
+ ]);
651
+ /**
652
+ * Parses a per-chain SVM fork-config slice. A `path` reference loads the
653
+ * `warp apply --submitter file` output (a `PrintableSvmTransaction[]`) via the
654
+ * injected file reader; inline `transactions` are used directly.
655
+ */
656
+ function parseSvmForkConfig(raw, fileReader) {
657
+ const parsed = SvmRawForkConfigSchema.parse(raw);
658
+ if ('path' in parsed) {
659
+ const transactions = schemas/* array */.YO(PrintableSvmTransactionSchema)
660
+ .parse(fileReader(parsed.path));
661
+ return { transactions };
662
+ }
663
+ return { transactions: parsed.transactions };
664
+ }
665
+ //# sourceMappingURL=svm-fork-config.js.map
666
+ ;// CONCATENATED MODULE: ../svm-sdk/dist/fork/index.js
667
+
668
+
669
+
670
+ //# sourceMappingURL=index.js.map
671
+
672
+ /***/ })
673
+
674
+ };