shinjuku-shield 0.3.193 → 0.3.194
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/manifest.json +6 -6
- package/package.json +3 -3
- package/shinjuku-seller.mjs +103 -25
- package/shinjuku-wallet.mjs +278 -45
package/README.md
CHANGED
|
@@ -6,8 +6,8 @@ answers privately, in a terminal chat or for your agent app. Its `mcp`
|
|
|
6
6
|
command runs a local MCP server (stdio) for your agent. Your keys never
|
|
7
7
|
leave your machine.
|
|
8
8
|
|
|
9
|
-
This is version 0.3.
|
|
10
|
-
is the one package that holds the wallet. `shinjuku-shielded` 0.3.
|
|
9
|
+
This is version 0.3.194. The command is `shinjuku`. `shinjuku-shield`
|
|
10
|
+
is the one package that holds the wallet. `shinjuku-shielded` 0.3.194,
|
|
11
11
|
its older npm name, is a small package that runs this package at the same
|
|
12
12
|
version, so wallets installed under it keep updating (0.3.186 and earlier
|
|
13
13
|
versions of `shinjuku-shielded` hold the same files as this package). New
|
|
@@ -16,7 +16,7 @@ installs use `shinjuku`.
|
|
|
16
16
|
## Set up
|
|
17
17
|
|
|
18
18
|
```sh
|
|
19
|
-
npx -y shinjuku@0.3.
|
|
19
|
+
npx -y shinjuku@0.3.194 setup
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
Setup offers to install the `shinjuku` command and, on Windows, adds npm's
|
|
@@ -39,13 +39,13 @@ Every wallet command works after `shinjuku`, for example `shinjuku balance`,
|
|
|
39
39
|
Claude Code:
|
|
40
40
|
|
|
41
41
|
```sh
|
|
42
|
-
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.
|
|
42
|
+
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.194 mcp
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
Claude Desktop (`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):
|
|
46
46
|
|
|
47
47
|
```json
|
|
48
|
-
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.
|
|
48
|
+
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.194", "mcp"] } } }
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
On native Windows, if the host cannot find `npx`, use `"command": "cmd"` and
|
|
@@ -58,7 +58,7 @@ Codex (the Codex app and Codex CLI read the same file, `~/.codex/config.toml`):
|
|
|
58
58
|
```toml
|
|
59
59
|
[mcp_servers.shinjuku]
|
|
60
60
|
command = "npx"
|
|
61
|
-
args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.
|
|
61
|
+
args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.194", "mcp"]
|
|
62
62
|
startup_timeout_sec = 120
|
|
63
63
|
tool_timeout_sec = 300
|
|
64
64
|
```
|
package/manifest.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": "carbon-shielded-wallet/bundle-manifest/v1",
|
|
3
3
|
"file": "shinjuku-wallet.mjs",
|
|
4
|
-
"sha256": "
|
|
5
|
-
"bytes":
|
|
6
|
-
"sourceCommit": "
|
|
4
|
+
"sha256": "33c8013b5b98881e3247ff282f4997f433affbe6a72c2d65540c6df14746982c",
|
|
5
|
+
"bytes": 9396980,
|
|
6
|
+
"sourceCommit": "ff9c661fa46bbb59d4c7883782ec0784fc560ca6",
|
|
7
7
|
"sourceDirty": false,
|
|
8
8
|
"installRecordMatchesLockfile": true,
|
|
9
9
|
"releaseRule": "valid only when two fresh npm ci --ignore-scripts builds on different OSes give the same sha256; installRecordMatchesLockfile true means every entry npm installed equals its package-lock.json entry and every entry not marked optional, devOptional included, is installed: an optional entry (a package for another platform) may be absent",
|
|
@@ -1040,8 +1040,8 @@
|
|
|
1040
1040
|
],
|
|
1041
1041
|
"seller": {
|
|
1042
1042
|
"file": "shinjuku-seller.mjs",
|
|
1043
|
-
"sha256": "
|
|
1044
|
-
"bytes":
|
|
1043
|
+
"sha256": "b75563dafd994a2c214b627a7149a053c04a23bc0103b8dfdd14adbfcf53ec88",
|
|
1044
|
+
"bytes": 3702204,
|
|
1045
1045
|
"entry": "wallet/src/seller/exact/index.mjs",
|
|
1046
1046
|
"external": [
|
|
1047
1047
|
"@x402/core/http",
|
|
@@ -1932,5 +1932,5 @@
|
|
|
1932
1932
|
}
|
|
1933
1933
|
]
|
|
1934
1934
|
},
|
|
1935
|
-
"publishedAt": "2026-11-
|
|
1935
|
+
"publishedAt": "2026-11-08T14:36:34.606Z"
|
|
1936
1936
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shield",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.194",
|
|
4
4
|
"mcpName": "io.github.ShinjukuStaition/shinjuku-shield",
|
|
5
5
|
"description": "Shinjuku Shield, private x402 payments on Solana: the self-custody wallet CLI and its MCP server. Shield, pay, and unshield USDC from any MCP agent, under caps you set.",
|
|
6
|
-
"shinjukuRelease": "
|
|
7
|
-
"shinjukuSha256": "
|
|
6
|
+
"shinjukuRelease": "33c8013b",
|
|
7
|
+
"shinjukuSha256": "33c8013b5b98881e3247ff282f4997f433affbe6a72c2d65540c6df14746982c",
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"author": "Shinjuku Shield",
|
|
10
10
|
"homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
|
package/shinjuku-seller.mjs
CHANGED
|
@@ -35014,7 +35014,7 @@ function untilAborted(promise, signal) {
|
|
|
35014
35014
|
promise.then(resolve17, reject).finally(() => signal.removeEventListener("abort", onAbort));
|
|
35015
35015
|
});
|
|
35016
35016
|
}
|
|
35017
|
-
var SITE_ONIONS, SITE_SPARE_ONIONS, PINNED_FACILITATOR_ONIONS, PINNED_SPARE_ONIONS, HISTORY_ONIONS, HISTORY_SPARE_ONIONS, PINNED_HISTORY_ONIONS, PINNED_HISTORY_SPARE_ONIONS, KEPT_ANSWER_BYTES, SPARE_CAUSE, routedGroupOf, onionDispatchers, ownTag, ownTagDispatchers, onOwnTagNow;
|
|
35017
|
+
var SITE_ONIONS, SITE_SPARE_ONIONS, PINNED_FACILITATOR_ONIONS, PINNED_SPARE_ONIONS, HISTORY_ONIONS, HISTORY_SPARE_ONIONS, PINNED_HISTORY_ONIONS, PINNED_HISTORY_SPARE_ONIONS, KEPT_ANSWER_BYTES, SPARE_CAUSE, routedGroups, historyOnionWinner, routedGroupOf, onionDispatchers, ownTag, ownTagDispatchers, onOwnTagNow;
|
|
35018
35018
|
var init_facilitatorOnion = __esm({
|
|
35019
35019
|
"wallet/src/net/facilitatorOnion.mjs"() {
|
|
35020
35020
|
"use strict";
|
|
@@ -35051,6 +35051,19 @@ var init_facilitatorOnion = __esm({
|
|
|
35051
35051
|
PINNED_HISTORY_SPARE_ONIONS = Object.freeze({ [HISTORY_ONIONS[0]]: HISTORY_SPARE_ONIONS });
|
|
35052
35052
|
KEPT_ANSWER_BYTES = 16 * 1024;
|
|
35053
35053
|
SPARE_CAUSE = Object.freeze({ silent: "no pinned onion answered", failed: "every pinned probe failed", wait: "a request's route wait ended" });
|
|
35054
|
+
routedGroups = [];
|
|
35055
|
+
historyOnionWinner = (url) => {
|
|
35056
|
+
if (url !== void 0) {
|
|
35057
|
+
let origin;
|
|
35058
|
+
try {
|
|
35059
|
+
origin = new URL(String(url)).origin;
|
|
35060
|
+
} catch {
|
|
35061
|
+
return void 0;
|
|
35062
|
+
}
|
|
35063
|
+
if (routedGroupOf.get(origin)?.kind !== "history") return void 0;
|
|
35064
|
+
}
|
|
35065
|
+
return routedGroups.find((group) => group.kind === "history")?.winner;
|
|
35066
|
+
};
|
|
35054
35067
|
routedGroupOf = /* @__PURE__ */ new Map();
|
|
35055
35068
|
onionDispatchers = /* @__PURE__ */ new Map();
|
|
35056
35069
|
ownTag = new AsyncLocalStorage2();
|
|
@@ -35926,7 +35939,8 @@ async function relayLimitOf(response, now = Date.now()) {
|
|
|
35926
35939
|
const reason = body?.error?.code === -32054 ? body.error.data?.reason : void 0;
|
|
35927
35940
|
if (!REASONS.has(reason)) return void 0;
|
|
35928
35941
|
const header2 = String(response.headers.get("retry-after") ?? "").trim();
|
|
35929
|
-
const
|
|
35942
|
+
const most = reason === "relay_budget_unavailable" ? BUDGET_PAUSE_MAX_SECONDS : fallbackSeconds(reason, now);
|
|
35943
|
+
const seconds = /^\d{1,6}$/.test(header2) ? Math.min(Math.max(1, Number(header2)), most) : fallbackSeconds(reason, now);
|
|
35930
35944
|
return { reason, retryAfterSeconds: seconds };
|
|
35931
35945
|
}
|
|
35932
35946
|
function closeRelay(origin, { reason, retryAfterSeconds: retryAfterSeconds2 }, now = Date.now()) {
|
|
@@ -35954,7 +35968,8 @@ function relayLimitNow(now = Date.now()) {
|
|
|
35954
35968
|
function relayLimitWords(state2 = relayLimitNow(), { now = Date.now(), ownRpc } = {}) {
|
|
35955
35969
|
if (!state2) return void 0;
|
|
35956
35970
|
const left = waitWords(state2.opensAtMs - now);
|
|
35957
|
-
const
|
|
35971
|
+
const at = clockWords(state2.opensAtMs);
|
|
35972
|
+
const what = state2.reason === "relay_daily_limit" ? `reached its limit for today; it opens again at ${at} (in about ${left})` : state2.reason === "relay_budget_unavailable" ? `could not take requests for a moment; it opens again at ${at} (in about ${left})` : `reached its limit for this hour; it opens again at ${at} (in about ${left})`;
|
|
35958
35973
|
return `Shinjuku's free Solana chain reader ${what}. It did not pass this step's request to the Solana network.` + (ownRpc ? ` To go on now, ${ownRpc}.` : "");
|
|
35959
35974
|
}
|
|
35960
35975
|
function relayLimitError(state2, now) {
|
|
@@ -35971,7 +35986,7 @@ function isRelayLimitError(error) {
|
|
|
35971
35986
|
}
|
|
35972
35987
|
return false;
|
|
35973
35988
|
}
|
|
35974
|
-
var REASONS, RELAY_BUDGET_RETRY_MAX_SECONDS, fallbackSeconds, closed, waitWords, clockWords;
|
|
35989
|
+
var REASONS, RELAY_BUDGET_RETRY_MAX_SECONDS, fallbackSeconds, BUDGET_PAUSE_MAX_SECONDS, closed, waitWords, clockWords;
|
|
35975
35990
|
var init_relayLimit = __esm({
|
|
35976
35991
|
"wallet/src/net/relayLimit.mjs"() {
|
|
35977
35992
|
"use strict";
|
|
@@ -35983,6 +35998,7 @@ var init_relayLimit = __esm({
|
|
|
35983
35998
|
const next = reason === "relay_daily_limit" ? Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate() + 1) : Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours() + 1);
|
|
35984
35999
|
return Math.max(1, Math.ceil((next - now) / 1e3));
|
|
35985
36000
|
};
|
|
36001
|
+
BUDGET_PAUSE_MAX_SECONDS = 300;
|
|
35986
36002
|
closed = /* @__PURE__ */ new Map();
|
|
35987
36003
|
waitWords = (ms) => {
|
|
35988
36004
|
const minutes = Math.max(1, Math.ceil(ms / 6e4));
|
|
@@ -36210,12 +36226,39 @@ function torLaneInit(lane, init = {}) {
|
|
|
36210
36226
|
dispatcher = proxyDispatcher(global2.constructor, proxy);
|
|
36211
36227
|
laneDispatchers.set(lane, dispatcher);
|
|
36212
36228
|
laneOfDispatcher.set(dispatcher, lane);
|
|
36229
|
+
laneProxyOf.set(dispatcher, proxy);
|
|
36213
36230
|
}
|
|
36214
36231
|
return { ...init, dispatcher };
|
|
36215
36232
|
} catch {
|
|
36216
36233
|
return init;
|
|
36217
36234
|
}
|
|
36218
36235
|
}
|
|
36236
|
+
function dropTorLane(lane) {
|
|
36237
|
+
try {
|
|
36238
|
+
prebuiltLanes.delete(lane);
|
|
36239
|
+
const dispatcher = laneDispatchers.get(lane);
|
|
36240
|
+
if (dispatcher === void 0) return;
|
|
36241
|
+
laneDispatchers.delete(lane);
|
|
36242
|
+
setImmediate(() => {
|
|
36243
|
+
try {
|
|
36244
|
+
dispatcher.close().catch(() => {
|
|
36245
|
+
});
|
|
36246
|
+
} catch {
|
|
36247
|
+
}
|
|
36248
|
+
});
|
|
36249
|
+
} catch {
|
|
36250
|
+
}
|
|
36251
|
+
}
|
|
36252
|
+
function torLaneReady(lane, onionOrigin) {
|
|
36253
|
+
try {
|
|
36254
|
+
const built = prebuiltLanes.get(lane);
|
|
36255
|
+
if (built === void 0 || runEnded() || laneDispatchers.get(lane) !== built.dispatcher) return false;
|
|
36256
|
+
const target = new URL(onionOrigin);
|
|
36257
|
+
return built.target === `${target.hostname}:${target.port || 80}`;
|
|
36258
|
+
} catch {
|
|
36259
|
+
return false;
|
|
36260
|
+
}
|
|
36261
|
+
}
|
|
36219
36262
|
function onCurrentCircuit(init) {
|
|
36220
36263
|
const lane = laneOfDispatcher.get(init?.dispatcher);
|
|
36221
36264
|
return lane === void 0 || laneDispatchers.get(lane) === init.dispatcher ? init : torLaneInit(lane, init);
|
|
@@ -36312,7 +36355,7 @@ async function rpcFetch(input, init) {
|
|
|
36312
36355
|
rpcNotBefore.set(post.key, Math.max(rpcNotBefore.get(post.key) ?? 0, Date.now() + retryAfterMs(response)));
|
|
36313
36356
|
}
|
|
36314
36357
|
}
|
|
36315
|
-
var relayKeyOf, READ_ONLY_METHOD, readOnlyPost, TOR_HTTP_TUNNEL, LOCAL_PROOF_TIMEOUT_MS, LOCAL_PROOF_MAX_BYTES, MARK, ownProxyRefused, ONION_V3, RETRY_AFTER_CAP_MS, RETRY_AFTER_FLOOR_MS, RETRY_AFTER_DEFAULT_MS, RPC_NO_ANSWER_LIMIT_MS, RPC_PACING_CAP_MS, PACING_NOTICE_EVERY_MS, PACING_RATE_WINDOW_MS, TOR_MAX_ROTATIONS, runStartedAt, rpcNotBefore, pacingWaiters, pacingSince, pacedMs, rpcAnswered, lastAnswerAt, readSteps, pacingNoticeAt, pacingSamples, torMoves, torCircuitId, torMovesRefused, pendingMove, inTorRunOf, inTorRun, isOnionOrigin, TOR_MIN_VERSION, TOR_EXPERT_BUNDLE, TOR_EXPERT_BUNDLE_SHA256, TOR_EXPERT_BUNDLE_URL, TUNNEL_LINE, TOR_DEB_KEY, TOR_DEB_KEYRING, TOR_INSTALL, torStart, LOCAL_TUNNEL, torStartText, TOR_WINDOW, torUpdateHow, TOR_STOP_OLD_WINDOWS, torTooOldWhy, TOR_WAIT_WORDS, TOR_WAIT_PLAIN, withRunTag, proxyEnv, pacedSoFar, RESENDABLE_METHOD, torCircuit, GLOBAL_DISPATCHER2, laneDispatchers, laneOfDispatcher;
|
|
36358
|
+
var relayKeyOf, READ_ONLY_METHOD, readOnlyPost, TOR_HTTP_TUNNEL, LOCAL_PROOF_TIMEOUT_MS, LOCAL_PROOF_MAX_BYTES, MARK, ownProxyRefused, ONION_V3, RETRY_AFTER_CAP_MS, RETRY_AFTER_FLOOR_MS, RETRY_AFTER_DEFAULT_MS, RPC_NO_ANSWER_LIMIT_MS, RPC_PACING_CAP_MS, PACING_NOTICE_EVERY_MS, PACING_RATE_WINDOW_MS, TOR_MAX_ROTATIONS, runStartedAt, rpcNotBefore, pacingWaiters, pacingSince, pacedMs, rpcAnswered, lastAnswerAt, readSteps, pacingNoticeAt, pacingSamples, torMoves, torCircuitId, torMovesRefused, pendingMove, inTorRunOf, inTorRun, isOnionOrigin, TOR_MIN_VERSION, TOR_EXPERT_BUNDLE, TOR_EXPERT_BUNDLE_SHA256, TOR_EXPERT_BUNDLE_URL, TUNNEL_LINE, TOR_DEB_KEY, TOR_DEB_KEYRING, TOR_INSTALL, torStart, LOCAL_TUNNEL, torStartText, TOR_WINDOW, torUpdateHow, TOR_STOP_OLD_WINDOWS, torTooOldWhy, TOR_WAIT_WORDS, TOR_WAIT_PLAIN, withRunTag, proxyEnv, pacedSoFar, RESENDABLE_METHOD, torCircuit, GLOBAL_DISPATCHER2, laneDispatchers, laneOfDispatcher, laneProxyOf, prebuiltLanes, prebuildSockets;
|
|
36316
36359
|
var init_proxy = __esm({
|
|
36317
36360
|
"wallet/src/net/proxy.mjs"() {
|
|
36318
36361
|
"use strict";
|
|
@@ -36423,7 +36466,11 @@ ${command}`;
|
|
|
36423
36466
|
GLOBAL_DISPATCHER2 = /* @__PURE__ */ Symbol.for("undici.globalDispatcher.1");
|
|
36424
36467
|
laneDispatchers = /* @__PURE__ */ new Map();
|
|
36425
36468
|
laneOfDispatcher = /* @__PURE__ */ new WeakMap();
|
|
36469
|
+
laneProxyOf = /* @__PURE__ */ new WeakMap();
|
|
36470
|
+
prebuiltLanes = /* @__PURE__ */ new Map();
|
|
36471
|
+
prebuildSockets = /* @__PURE__ */ new Set();
|
|
36426
36472
|
registerRunDispatchers(() => laneDispatchers.values());
|
|
36473
|
+
registerRunDispatchers(() => [...prebuildSockets].map((socket) => ({ destroy: () => socket.destroy() })));
|
|
36427
36474
|
}
|
|
36428
36475
|
});
|
|
36429
36476
|
|
|
@@ -38211,6 +38258,9 @@ var init_errorCodes = __esm({
|
|
|
38211
38258
|
"p03_compact_history_spot_check_mismatch",
|
|
38212
38259
|
"p03_compact_history_spot_check_unavailable",
|
|
38213
38260
|
"p03_deposit_relay_approval_standing",
|
|
38261
|
+
// deposit.mjs: the cause of relay_not_settled_rerun_same_id when the deposit was sent and called final, and only its
|
|
38262
|
+
// confirmation read is stale; nothing is sent again.
|
|
38263
|
+
"p03_deposit_relay_sent_confirmation_unread",
|
|
38214
38264
|
"p03_deposit_relay_buffer_message_account_flags_invalid",
|
|
38215
38265
|
"p03_deposit_relay_buffer_message_accounts_invalid",
|
|
38216
38266
|
"p03_deposit_relay_buffer_message_approve_invalid",
|
|
@@ -48439,7 +48489,7 @@ function connect2(rpcUrl, commitment = "finalized", { timeoutMs, wrapFetch = (fe
|
|
|
48439
48489
|
headers.delete("content-length");
|
|
48440
48490
|
return new Response(body, { status: response.status, statusText: response.statusText, headers });
|
|
48441
48491
|
} catch (error) {
|
|
48442
|
-
if (stalled.signal.aborted && !init?.signal?.aborted) await moveTorCircuitAfterStall(circuit);
|
|
48492
|
+
if (stalled.signal.aborted && !init?.signal?.aborted && !init?.ownLane) await moveTorCircuitAfterStall(circuit);
|
|
48443
48493
|
throw error;
|
|
48444
48494
|
} finally {
|
|
48445
48495
|
clearTimeout(timer);
|
|
@@ -48467,7 +48517,8 @@ function connect2(rpcUrl, commitment = "finalized", { timeoutMs, wrapFetch = (fe
|
|
|
48467
48517
|
headers: { "content-type": "application/json" },
|
|
48468
48518
|
body: JSON.stringify({ jsonrpc: "2.0", id: id ?? randomUUID2(), method, params })
|
|
48469
48519
|
};
|
|
48470
|
-
const
|
|
48520
|
+
const laneInit = lane === void 0 ? init : torLaneInit(lane, init);
|
|
48521
|
+
const response = await fetch2(rpcUrl, laneInit !== init && laneInit.dispatcher !== void 0 ? { ...laneInit, ownLane: true } : laneInit);
|
|
48471
48522
|
onResponseHead(response);
|
|
48472
48523
|
if (rejectHttpError && !response.ok) throw new Error(`${response.status} ${response.statusText}: ${await response.text()}`);
|
|
48473
48524
|
return response.json();
|
|
@@ -53324,7 +53375,7 @@ function validateRecord(raw, ordinal, { programId, pool: pool2, poolDomain, snap
|
|
|
53324
53375
|
function requestPage(history, pool2, from, signal) {
|
|
53325
53376
|
return requestList(history, pool2, from, P03_COMPACT_PAGE, { signal }).read;
|
|
53326
53377
|
}
|
|
53327
|
-
function requestList(history, pool2, from, size, { attempts = LIST_ATTEMPTS, signal } = {}) {
|
|
53378
|
+
function requestList(history, pool2, from, size, { attempts = LIST_ATTEMPTS, signal, lane } = {}) {
|
|
53328
53379
|
if (signal?.aborted) return { read: Promise.resolve({ error: signal.reason }), release() {
|
|
53329
53380
|
} };
|
|
53330
53381
|
const source = typeof history?.rpcEndpoint === "string" ? history.rpcEndpoint : history;
|
|
@@ -53338,7 +53389,7 @@ function requestList(history, pool2, from, size, { attempts = LIST_ATTEMPTS, sig
|
|
|
53338
53389
|
markPhase("compact-list-ask", `from${from}_to${from + size}_joined_${joined}`);
|
|
53339
53390
|
if (!joined) {
|
|
53340
53391
|
const stop = new AbortController();
|
|
53341
|
-
entry = { holders: 0, stop, done: false, read: requestListNow(history, pool2, from, size, attempts, stop.signal) };
|
|
53392
|
+
entry = { holders: 0, stop, done: false, read: requestListNow(history, pool2, from, size, attempts, stop.signal, lane) };
|
|
53342
53393
|
if (byKey === void 0) listInFlight.set(source, byKey = /* @__PURE__ */ new Map());
|
|
53343
53394
|
byKey.set(key2, entry);
|
|
53344
53395
|
entry.forget = () => {
|
|
@@ -53382,14 +53433,20 @@ function requestList(history, pool2, from, size, { attempts = LIST_ATTEMPTS, sig
|
|
|
53382
53433
|
}
|
|
53383
53434
|
return handle;
|
|
53384
53435
|
}
|
|
53385
|
-
function requestListNow(history, pool2, from, size, attempts, signal) {
|
|
53436
|
+
function requestListNow(history, pool2, from, size, attempts, signal, lane) {
|
|
53386
53437
|
const params = [pool2, { commitment: "finalized", fromOrdinal: from, toOrdinal: from + size }];
|
|
53387
53438
|
const attempt = async (index) => {
|
|
53388
53439
|
if (runEnded()) return { error: runEndedError() };
|
|
53389
53440
|
const circuit = torCircuit();
|
|
53390
53441
|
try {
|
|
53391
|
-
return { response: await listRequest(history, params, { signal, label: attempts === 1 ? `tail${from}` : `page${from}_try${index + 1}` }) };
|
|
53442
|
+
return { response: await listRequest(history, params, { signal, lane, label: attempts === 1 ? `tail${from}` : `page${from}_try${index + 1}` }) };
|
|
53392
53443
|
} catch (error) {
|
|
53444
|
+
if (lane !== void 0 && !runEnded() && !signal.aborted && !proxyRefusedConnection(error)) {
|
|
53445
|
+
dropTorLane(lane);
|
|
53446
|
+
markPhase("compact-tail-lane-dropped", failureCause(error));
|
|
53447
|
+
lane = void 0;
|
|
53448
|
+
return attempt(index);
|
|
53449
|
+
}
|
|
53393
53450
|
if (runEnded() || index + 1 >= attempts || proxyRefusedConnection(error) || sourceUnreachable(error, circuit) || signal.aborted) return { error };
|
|
53394
53451
|
markPhase("compact-list-retry");
|
|
53395
53452
|
await runSleep(Math.min(8e3, 1e3 * 2 ** index));
|
|
@@ -53399,6 +53456,14 @@ function requestListNow(history, pool2, from, size, attempts, signal) {
|
|
|
53399
53456
|
};
|
|
53400
53457
|
return attempt(0);
|
|
53401
53458
|
}
|
|
53459
|
+
function tailLane(history) {
|
|
53460
|
+
if (!inTorRun()) return void 0;
|
|
53461
|
+
const winner = historyOnionWinner(history?.rpcEndpoint);
|
|
53462
|
+
if (winner === void 0) return void 0;
|
|
53463
|
+
const own = torLaneReady(HISTORY_TAIL_LANE, winner);
|
|
53464
|
+
markPhase("compact-tail-lane", own ? "own" : "main");
|
|
53465
|
+
return own ? HISTORY_TAIL_LANE : void 0;
|
|
53466
|
+
}
|
|
53402
53467
|
function sendRestOfSet(history, pool2, count2, grid, signal) {
|
|
53403
53468
|
const pages = /* @__PURE__ */ new Map();
|
|
53404
53469
|
if (!(count2 > 0)) return { pages, tail: void 0, tailSize: grid };
|
|
@@ -53407,11 +53472,11 @@ function sendRestOfSet(history, pool2, count2, grid, signal) {
|
|
|
53407
53472
|
}
|
|
53408
53473
|
const from = tailFrom(count2, grid);
|
|
53409
53474
|
const onPage = from % P03_COMPACT_PAGE === 0;
|
|
53410
|
-
const tail = onPage ? pages.get(from) : requestList(history, pool2, from, grid, { attempts: 1, signal });
|
|
53475
|
+
const tail = onPage ? pages.get(from) : requestList(history, pool2, from, grid, { attempts: 1, signal, lane: tailLane(history) });
|
|
53411
53476
|
markPhase("compact-rest-sent", `pages${pages.size}`);
|
|
53412
53477
|
return { pages, tail, tailSize: onPage ? P03_COMPACT_PAGE : grid };
|
|
53413
53478
|
}
|
|
53414
|
-
async function listRequest(history, params, { signal, label }) {
|
|
53479
|
+
async function listRequest(history, params, { signal, label, lane }) {
|
|
53415
53480
|
if (typeof history.abortableRpcRequest !== "function") {
|
|
53416
53481
|
markPhase("compact-list-request", label);
|
|
53417
53482
|
return history._rpcRequest("getP03Transitions", params);
|
|
@@ -53433,7 +53498,7 @@ async function listRequest(history, params, { signal, label }) {
|
|
|
53433
53498
|
clearTimeout(timer);
|
|
53434
53499
|
markPhase("compact-list-head", label);
|
|
53435
53500
|
},
|
|
53436
|
-
{ rejectHttpError: true, bodyStallMs: LIST_BODY_STALL_MS, totalCapMs: LIST_TOTAL_CAP_MS }
|
|
53501
|
+
{ rejectHttpError: true, bodyStallMs: LIST_BODY_STALL_MS, totalCapMs: LIST_TOTAL_CAP_MS, ...lane === void 0 ? {} : { lane } }
|
|
53437
53502
|
);
|
|
53438
53503
|
read.catch(() => {
|
|
53439
53504
|
});
|
|
@@ -53442,14 +53507,14 @@ async function listRequest(history, params, { signal, label }) {
|
|
|
53442
53507
|
timer = setTimeout(() => {
|
|
53443
53508
|
headless.abort();
|
|
53444
53509
|
reject(new Error(LIST_HEAD_STALLED));
|
|
53445
|
-
}, LIST_HEAD_TIMEOUT_MS);
|
|
53510
|
+
}, lane === void 0 ? LIST_HEAD_TIMEOUT_MS : LANE_HEAD_TIMEOUT_MS);
|
|
53446
53511
|
})]) : read);
|
|
53447
53512
|
markPhase("compact-list-answer", label);
|
|
53448
53513
|
return response;
|
|
53449
53514
|
} catch (error) {
|
|
53450
53515
|
if (error?.message === LIST_HEAD_STALLED) {
|
|
53451
53516
|
markPhase("compact-list-head-timeout", label);
|
|
53452
|
-
await moveTorCircuitAfterStall(circuit);
|
|
53517
|
+
if (lane === void 0) await moveTorCircuitAfterStall(circuit);
|
|
53453
53518
|
} else {
|
|
53454
53519
|
const cause = signal?.aborted ? "stopped" : { [HISTORY_BODY_STALLED]: "body_stall", [HISTORY_BODY_CAPPED]: "capped" }[error?.message] ?? failureCause(error);
|
|
53455
53520
|
markPhase("compact-list-failed", `${label}_${cause}`);
|
|
@@ -54678,7 +54743,7 @@ async function tryCompactP03HistoryReport(options) {
|
|
|
54678
54743
|
return { ok: false, reason, ...detail ? { detail } : {}, error };
|
|
54679
54744
|
}
|
|
54680
54745
|
}
|
|
54681
|
-
var import_web398, P03_COMPACT_HISTORY_SOURCE_MODEL, P03_COMPACT_PAGE, P03_COMPACT_SPOT_CHECKS, FIELD_MODULUS5, SUBTREE_LEAVES3, LOCAL_DEPTH2, OUTER_DEPTH2, PRIMARY_PROOF_BYTES2, FIELD_BYTES3, ED25519_SPKI_PREFIX3, VERSION_1_PREFIX2, HEX64, BASE58, REPLAY_STORE_INDEXED2, PROFILES2, MOVE_HEAD_BYTES2, MOVE_INSERTED_VALUES2, refuse2, hash4, bitAt, zeroRootsMemo, lastFolds, PRE_FOLD_SLICE_MS, preFolds, FOLD_CHECKPOINT_EVERY, foldNode, foldFrontier, foldHex, servedWithoutRecords, isSignature, isIndex, IMPORT_KEYS, IMPORT_MAX_VALUES, LIST_ATTEMPTS, listInFlight, LIST_HEAD_TIMEOUT_MS, LIST_HEAD_STALLED, LIST_BODY_STALL_MS, LIST_TOTAL_CAP_MS, OWN_READ_TIMEOUT_MS, BOUNDED_OWN_METHODS, P03_COMPACT_TAIL_GRID, TAIL_RETRY_REFUSALS, tailFrom, sameJson, SPOT_HEDGE_AFTER_MS, SPOT_HEDGE_LANE, POOL_HEDGE_AFTER_MS, POOL_HEDGE_LANE, compactReportsRunning;
|
|
54746
|
+
var import_web398, P03_COMPACT_HISTORY_SOURCE_MODEL, P03_COMPACT_PAGE, P03_COMPACT_SPOT_CHECKS, FIELD_MODULUS5, SUBTREE_LEAVES3, LOCAL_DEPTH2, OUTER_DEPTH2, PRIMARY_PROOF_BYTES2, FIELD_BYTES3, ED25519_SPKI_PREFIX3, VERSION_1_PREFIX2, HEX64, BASE58, REPLAY_STORE_INDEXED2, PROFILES2, MOVE_HEAD_BYTES2, MOVE_INSERTED_VALUES2, refuse2, hash4, bitAt, zeroRootsMemo, lastFolds, PRE_FOLD_SLICE_MS, preFolds, FOLD_CHECKPOINT_EVERY, foldNode, foldFrontier, foldHex, servedWithoutRecords, isSignature, isIndex, IMPORT_KEYS, IMPORT_MAX_VALUES, LIST_ATTEMPTS, listInFlight, HISTORY_TAIL_LANE, LIST_HEAD_TIMEOUT_MS, LIST_HEAD_STALLED, LANE_HEAD_TIMEOUT_MS, LIST_BODY_STALL_MS, LIST_TOTAL_CAP_MS, OWN_READ_TIMEOUT_MS, BOUNDED_OWN_METHODS, P03_COMPACT_TAIL_GRID, TAIL_RETRY_REFUSALS, tailFrom, sameJson, SPOT_HEDGE_AFTER_MS, SPOT_HEDGE_LANE, POOL_HEDGE_AFTER_MS, POOL_HEDGE_LANE, compactReportsRunning;
|
|
54682
54747
|
var init_compact = __esm({
|
|
54683
54748
|
"wallet/src/history/compact.mjs"() {
|
|
54684
54749
|
"use strict";
|
|
@@ -54823,8 +54888,10 @@ var init_compact = __esm({
|
|
|
54823
54888
|
IMPORT_MAX_VALUES = 3;
|
|
54824
54889
|
LIST_ATTEMPTS = 6;
|
|
54825
54890
|
listInFlight = /* @__PURE__ */ new Map();
|
|
54891
|
+
HISTORY_TAIL_LANE = "history-tail";
|
|
54826
54892
|
LIST_HEAD_TIMEOUT_MS = 1e4;
|
|
54827
54893
|
LIST_HEAD_STALLED = "ETIMEDOUT: history list answer head stalled";
|
|
54894
|
+
LANE_HEAD_TIMEOUT_MS = 1500;
|
|
54828
54895
|
LIST_BODY_STALL_MS = 8e3;
|
|
54829
54896
|
LIST_TOTAL_CAP_MS = 6e4;
|
|
54830
54897
|
OWN_READ_TIMEOUT_MS = HISTORY_RPC_REQUEST_TIMEOUT_MS;
|
|
@@ -57526,7 +57593,8 @@ async function tokenAccount(connection, address2, commitment = "finalized") {
|
|
|
57526
57593
|
throw error;
|
|
57527
57594
|
}
|
|
57528
57595
|
});
|
|
57529
|
-
} catch {
|
|
57596
|
+
} catch (error) {
|
|
57597
|
+
if (isRelayLimitError(error)) throw error;
|
|
57530
57598
|
fail13("token_balance_unreadable");
|
|
57531
57599
|
}
|
|
57532
57600
|
}
|
|
@@ -58095,7 +58163,8 @@ async function addressHasHistory(connection, address2) {
|
|
|
58095
58163
|
try {
|
|
58096
58164
|
if (typeof connection.getSignaturesForAddress !== "function") throw new Error("no history read");
|
|
58097
58165
|
history = await retryRpc2(() => connection.getSignaturesForAddress(new import_web3104.PublicKey(address2), { limit: 1 }, "confirmed"));
|
|
58098
|
-
} catch {
|
|
58166
|
+
} catch (error) {
|
|
58167
|
+
if (isRelayLimitError(error)) throw error;
|
|
58099
58168
|
fail13("relay_history_unreadable");
|
|
58100
58169
|
}
|
|
58101
58170
|
if (!Array.isArray(history)) fail13("relay_history_unreadable");
|
|
@@ -58414,7 +58483,7 @@ async function submitRelayedDepositLeased({ store, connection, programId, proofT
|
|
|
58414
58483
|
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
58415
58484
|
const historyConnection = deps.historyConnection ?? (connection.historyRpcChoice !== void 0 || connection.historyRpc ? connection : connectSplit(connection, historyUrl));
|
|
58416
58485
|
const loadHistory = () => finalizedHistory({ store, connection: historyConnection, id, proofTools, deps });
|
|
58417
|
-
const refuse6 = async (reason) => {
|
|
58486
|
+
const refuse6 = async (reason, why) => {
|
|
58418
58487
|
record.relay.lastRefusal = { reason, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
58419
58488
|
store.writeWal(name, record);
|
|
58420
58489
|
let approved;
|
|
@@ -58427,7 +58496,9 @@ async function submitRelayedDepositLeased({ store, connection, programId, proofT
|
|
|
58427
58496
|
record.relay.approvedOnChain = approved;
|
|
58428
58497
|
store.writeWal(name, record);
|
|
58429
58498
|
}
|
|
58430
|
-
|
|
58499
|
+
const standing = approved ? new Error("p03_deposit_relay_approval_standing") : void 0;
|
|
58500
|
+
const cause = why ? new Error(`p03_deposit_${why}`, standing ? { cause: standing } : void 0) : standing;
|
|
58501
|
+
throw new Error(`p03_deposit_${reason}`, cause ? { cause } : void 0);
|
|
58431
58502
|
};
|
|
58432
58503
|
const foreignFunded = async () => {
|
|
58433
58504
|
if (!record.foreignFunding.memoPublished) {
|
|
@@ -58439,7 +58510,7 @@ async function submitRelayedDepositLeased({ store, connection, programId, proofT
|
|
|
58439
58510
|
};
|
|
58440
58511
|
if (record.state === "foreign_funded") return foreignFunded();
|
|
58441
58512
|
for (let round = 0; record.state === "proved" || record.state === "submitted"; round += 1) {
|
|
58442
|
-
if (round >= RELAY_ROUNDS) await refuse6("relay_not_settled_rerun_same_id");
|
|
58513
|
+
if (round >= RELAY_ROUNDS) await refuse6("relay_not_settled_rerun_same_id", record.relay.result ? "relay_sent_confirmation_unread" : void 0);
|
|
58443
58514
|
const settled = (promise) => {
|
|
58444
58515
|
promise.catch(() => void 0);
|
|
58445
58516
|
return promise;
|
|
@@ -58473,7 +58544,7 @@ async function submitRelayedDepositLeased({ store, connection, programId, proofT
|
|
|
58473
58544
|
store.writeWal(name, record);
|
|
58474
58545
|
break;
|
|
58475
58546
|
}
|
|
58476
|
-
if (record.relay.result
|
|
58547
|
+
if (record.relay.result) {
|
|
58477
58548
|
await pause2(5e3);
|
|
58478
58549
|
continue;
|
|
58479
58550
|
}
|
|
@@ -59048,8 +59119,14 @@ async function runDepositReclaimCommand(args, cli2) {
|
|
|
59048
59119
|
const lines = [];
|
|
59049
59120
|
if (result.reclaimed) lines.push(`The deposit's USDC came back from the one-time address ${result.oneTimeAddress}: ${moved(result.reclaimed)}.`);
|
|
59050
59121
|
for (const entry of result.leftovers ?? []) lines.push(`USDC that reached the one-time address after its deposit came back: ${moved(entry)}.`);
|
|
59051
|
-
|
|
59052
|
-
|
|
59122
|
+
const back = [result.reclaimed, ...result.leftovers ?? []].filter(Boolean);
|
|
59123
|
+
if (back.length === 0) {
|
|
59124
|
+
lines.push(`Nothing moved: the one-time address ${result.oneTimeAddress} of deposit ${result.depositId} holds no USDC to take back.`);
|
|
59125
|
+
if (result.state === "published" || result.state === "finalized") lines.push("This deposit is already in your private balance.");
|
|
59126
|
+
} else {
|
|
59127
|
+
const places = [...new Set(back.map((entry) => entry.to))].join(" and ");
|
|
59128
|
+
lines.push(`That USDC is now at ${places}, outside your private balance (add-funds makes it private again).`);
|
|
59129
|
+
}
|
|
59053
59130
|
console.log(lines.join("\n"));
|
|
59054
59131
|
}
|
|
59055
59132
|
async function runDepositScanCommand(args, cli2) {
|
|
@@ -59219,6 +59296,7 @@ var init_deposit = __esm({
|
|
|
59219
59296
|
init_keys2();
|
|
59220
59297
|
init_serviceUrl();
|
|
59221
59298
|
init_proxy();
|
|
59299
|
+
init_relayLimit();
|
|
59222
59300
|
init_approveInBuffer();
|
|
59223
59301
|
init_processLease();
|
|
59224
59302
|
init_witness();
|
package/shinjuku-wallet.mjs
CHANGED
|
@@ -44270,7 +44270,7 @@ async function routeFacilitatorsOverOnion(argv2, {
|
|
|
44270
44270
|
return response;
|
|
44271
44271
|
}, (error) => {
|
|
44272
44272
|
const why = noAnswer(error, signal);
|
|
44273
|
-
if (why) moveOn(group, onion, why);
|
|
44273
|
+
if (why && !init?.ownLane) moveOn(group, onion, why);
|
|
44274
44274
|
throw error;
|
|
44275
44275
|
});
|
|
44276
44276
|
};
|
|
@@ -44292,7 +44292,7 @@ async function routeFacilitatorsOverOnion(argv2, {
|
|
|
44292
44292
|
}
|
|
44293
44293
|
};
|
|
44294
44294
|
}
|
|
44295
|
-
var SITE_ONIONS, SITE_SPARE_ONIONS, PINNED_FACILITATOR_ONIONS, PINNED_SPARE_ONIONS, HISTORY_ONIONS, HISTORY_SPARE_ONIONS, PINNED_HISTORY_ONIONS, PINNED_HISTORY_SPARE_ONIONS, HISTORY_PROBE_PATH, SITE_PROBE_PATH, SITE_PROBE_ANSWERS, KEPT_ANSWER_MS, KEPT_ANSWER_BYTES, KEPT_BODY_MS, FACILITATOR_FLAGS, V3_ONION, DISCOVERY_TIMEOUT_MS, WARM_TIMEOUT_MS, RACE_TIMEOUT_MS, ROUTE_WAIT_MS, SPARE_AFTER_MS, SPARE_CAUSE, routedGroups, liveOnions, hostOf, noAnswer, routedOnions, routedOrigins, onionsOfOrigin, routesOverOnion, routedGroupOf, firstRaces, firstRaceRecords, firstRacesMarked, firstOnionRace, GLOBAL_DISPATCHER3, onionDispatchers, ownTag, ownTagDispatchers, onOwnTagNow, ownTagInit;
|
|
44295
|
+
var SITE_ONIONS, SITE_SPARE_ONIONS, PINNED_FACILITATOR_ONIONS, PINNED_SPARE_ONIONS, HISTORY_ONIONS, HISTORY_SPARE_ONIONS, PINNED_HISTORY_ONIONS, PINNED_HISTORY_SPARE_ONIONS, HISTORY_PROBE_PATH, SITE_PROBE_PATH, SITE_PROBE_ANSWERS, KEPT_ANSWER_MS, KEPT_ANSWER_BYTES, KEPT_BODY_MS, FACILITATOR_FLAGS, V3_ONION, DISCOVERY_TIMEOUT_MS, WARM_TIMEOUT_MS, RACE_TIMEOUT_MS, ROUTE_WAIT_MS, SPARE_AFTER_MS, SPARE_CAUSE, routedGroups, liveOnions, hostOf, noAnswer, historyOnionWinner, historyOnionRaced, routedOnions, routedOrigins, onionsOfOrigin, routesOverOnion, routedGroupOf, firstRaces, firstRaceRecords, firstRacesMarked, firstOnionRace, GLOBAL_DISPATCHER3, onionDispatchers, ownTag, ownTagDispatchers, onOwnTagNow, ownTagInit;
|
|
44296
44296
|
var init_facilitatorOnion = __esm({
|
|
44297
44297
|
"wallet/src/net/facilitatorOnion.mjs"() {
|
|
44298
44298
|
"use strict";
|
|
@@ -44349,6 +44349,23 @@ var init_facilitatorOnion = __esm({
|
|
|
44349
44349
|
if (error?.name === "TimeoutError") return "no answer before the request's timeout";
|
|
44350
44350
|
return error instanceof TypeError ? "the stream failed" : void 0;
|
|
44351
44351
|
};
|
|
44352
|
+
historyOnionWinner = (url) => {
|
|
44353
|
+
if (url !== void 0) {
|
|
44354
|
+
let origin;
|
|
44355
|
+
try {
|
|
44356
|
+
origin = new URL(String(url)).origin;
|
|
44357
|
+
} catch {
|
|
44358
|
+
return void 0;
|
|
44359
|
+
}
|
|
44360
|
+
if (routedGroupOf.get(origin)?.kind !== "history") return void 0;
|
|
44361
|
+
}
|
|
44362
|
+
return routedGroups.find((group) => group.kind === "history")?.winner;
|
|
44363
|
+
};
|
|
44364
|
+
historyOnionRaced = () => {
|
|
44365
|
+
const group = routedGroups.find((one) => one.kind === "history");
|
|
44366
|
+
if (group === void 0) return Promise.resolve(void 0);
|
|
44367
|
+
return group.winner !== void 0 ? Promise.resolve(group.winner) : Promise.resolve(group.pending).then(() => group.winner, () => void 0);
|
|
44368
|
+
};
|
|
44352
44369
|
routedOnions = () => [...new Set(routedGroups.flatMap((group) => group.winner ? [group.winner] : liveOnions(group)))];
|
|
44353
44370
|
routedOrigins = /* @__PURE__ */ new Map();
|
|
44354
44371
|
onionsOfOrigin = (origin) => routedOrigins.get(origin) ?? PINNED_FACILITATOR_ONIONS[origin] ?? [];
|
|
@@ -48270,7 +48287,8 @@ async function relayLimitOf(response, now = Date.now()) {
|
|
|
48270
48287
|
const reason = body?.error?.code === -32054 ? body.error.data?.reason : void 0;
|
|
48271
48288
|
if (!REASONS.has(reason)) return void 0;
|
|
48272
48289
|
const header = String(response.headers.get("retry-after") ?? "").trim();
|
|
48273
|
-
const
|
|
48290
|
+
const most = reason === "relay_budget_unavailable" ? BUDGET_PAUSE_MAX_SECONDS : fallbackSeconds(reason, now);
|
|
48291
|
+
const seconds2 = /^\d{1,6}$/.test(header) ? Math.min(Math.max(1, Number(header)), most) : fallbackSeconds(reason, now);
|
|
48274
48292
|
return { reason, retryAfterSeconds: seconds2 };
|
|
48275
48293
|
}
|
|
48276
48294
|
function closeRelay(origin, { reason, retryAfterSeconds: retryAfterSeconds2 }, now = Date.now()) {
|
|
@@ -48298,7 +48316,8 @@ function relayLimitNow(now = Date.now()) {
|
|
|
48298
48316
|
function relayLimitWords(state2 = relayLimitNow(), { now = Date.now(), ownRpc } = {}) {
|
|
48299
48317
|
if (!state2) return void 0;
|
|
48300
48318
|
const left = waitWords(state2.opensAtMs - now);
|
|
48301
|
-
const
|
|
48319
|
+
const at = clockWords(state2.opensAtMs);
|
|
48320
|
+
const what = state2.reason === "relay_daily_limit" ? `reached its limit for today; it opens again at ${at} (in about ${left})` : state2.reason === "relay_budget_unavailable" ? `could not take requests for a moment; it opens again at ${at} (in about ${left})` : `reached its limit for this hour; it opens again at ${at} (in about ${left})`;
|
|
48302
48321
|
return `Shinjuku's free Solana chain reader ${what}. It did not pass this step's request to the Solana network.` + (ownRpc ? ` To go on now, ${ownRpc}.` : "");
|
|
48303
48322
|
}
|
|
48304
48323
|
function relayLimitError(state2, now) {
|
|
@@ -48315,7 +48334,7 @@ function isRelayLimitError(error) {
|
|
|
48315
48334
|
}
|
|
48316
48335
|
return false;
|
|
48317
48336
|
}
|
|
48318
|
-
var REASONS, RELAY_BUDGET_RETRY_MAX_SECONDS, fallbackSeconds, closed, waitWords, clockWords;
|
|
48337
|
+
var REASONS, RELAY_BUDGET_RETRY_MAX_SECONDS, fallbackSeconds, BUDGET_PAUSE_MAX_SECONDS, closed, waitWords, clockWords;
|
|
48319
48338
|
var init_relayLimit = __esm({
|
|
48320
48339
|
"wallet/src/net/relayLimit.mjs"() {
|
|
48321
48340
|
"use strict";
|
|
@@ -48327,6 +48346,7 @@ var init_relayLimit = __esm({
|
|
|
48327
48346
|
const next = reason === "relay_daily_limit" ? Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate() + 1) : Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours() + 1);
|
|
48328
48347
|
return Math.max(1, Math.ceil((next - now) / 1e3));
|
|
48329
48348
|
};
|
|
48349
|
+
BUDGET_PAUSE_MAX_SECONDS = 300;
|
|
48330
48350
|
closed = /* @__PURE__ */ new Map();
|
|
48331
48351
|
waitWords = (ms) => {
|
|
48332
48352
|
const minutes = Math.max(1, Math.ceil(ms / 6e4));
|
|
@@ -48759,12 +48779,92 @@ function torLaneInit(lane, init = {}) {
|
|
|
48759
48779
|
dispatcher = proxyDispatcher(global2.constructor, proxy);
|
|
48760
48780
|
laneDispatchers.set(lane, dispatcher);
|
|
48761
48781
|
laneOfDispatcher.set(dispatcher, lane);
|
|
48782
|
+
laneProxyOf.set(dispatcher, proxy);
|
|
48762
48783
|
}
|
|
48763
48784
|
return { ...init, dispatcher };
|
|
48764
48785
|
} catch {
|
|
48765
48786
|
return init;
|
|
48766
48787
|
}
|
|
48767
48788
|
}
|
|
48789
|
+
function prebuildTorLane(lane, onionOrigin, { timeoutMs = PREBUILD_TIMEOUT_MS } = {}) {
|
|
48790
|
+
try {
|
|
48791
|
+
if (lane === 0 || !inTorRun() || runEnded()) return Promise.resolve(false);
|
|
48792
|
+
prebuiltLanes.delete(lane);
|
|
48793
|
+
const target = new URL(onionOrigin);
|
|
48794
|
+
if (target.protocol !== "http:" || !/^[a-z2-7]{56}\.onion$/.test(target.hostname)) return Promise.resolve(false);
|
|
48795
|
+
const dispatcher = torLaneInit(lane, {}).dispatcher;
|
|
48796
|
+
const proxy = dispatcher === void 0 ? void 0 : laneProxyOf.get(dispatcher);
|
|
48797
|
+
if (proxy === void 0) return Promise.resolve(false);
|
|
48798
|
+
const tunnel = new URL(proxy);
|
|
48799
|
+
const hostPort = `${target.hostname}:${target.port || 80}`;
|
|
48800
|
+
const auth = Buffer.from(`${decodeURIComponent(tunnel.username)}:${decodeURIComponent(tunnel.password)}`).toString("base64");
|
|
48801
|
+
return new Promise((resolve42) => {
|
|
48802
|
+
let done = false;
|
|
48803
|
+
const socket = net2.connect(Number(tunnel.port || 80), tunnel.hostname);
|
|
48804
|
+
prebuildSockets.add(socket);
|
|
48805
|
+
const finish = (ok) => {
|
|
48806
|
+
if (done) return;
|
|
48807
|
+
done = true;
|
|
48808
|
+
clearTimeout(timer);
|
|
48809
|
+
prebuildSockets.delete(socket);
|
|
48810
|
+
socket.destroy();
|
|
48811
|
+
if (ok && !runEnded() && laneDispatchers.get(lane) === dispatcher) {
|
|
48812
|
+
prebuiltLanes.set(lane, { dispatcher, target: hostPort });
|
|
48813
|
+
markPhase("tor-lane-prebuilt", String(lane));
|
|
48814
|
+
resolve42(true);
|
|
48815
|
+
return;
|
|
48816
|
+
}
|
|
48817
|
+
dropTorLane(lane);
|
|
48818
|
+
markPhase("tor-lane-prebuild-failed", String(lane));
|
|
48819
|
+
resolve42(false);
|
|
48820
|
+
};
|
|
48821
|
+
const timer = setTimeout(() => finish(false), timeoutMs);
|
|
48822
|
+
timer.unref?.();
|
|
48823
|
+
let reply = Buffer.alloc(0);
|
|
48824
|
+
socket.once("connect", () => socket.write(`CONNECT ${hostPort} HTTP/1.1\r
|
|
48825
|
+
Host: ${hostPort}\r
|
|
48826
|
+
Proxy-Authorization: Basic ${auth}\r
|
|
48827
|
+
\r
|
|
48828
|
+
`));
|
|
48829
|
+
socket.on("data", (chunk) => {
|
|
48830
|
+
reply = Buffer.concat([reply, chunk]);
|
|
48831
|
+
const end2 = reply.indexOf("\r\n");
|
|
48832
|
+
if (end2 < 0) return;
|
|
48833
|
+
finish(/^HTTP\/1\.[01] 200\b/.test(reply.subarray(0, end2).toString("latin1")));
|
|
48834
|
+
});
|
|
48835
|
+
socket.on("error", () => finish(false));
|
|
48836
|
+
socket.on("close", () => finish(false));
|
|
48837
|
+
});
|
|
48838
|
+
} catch {
|
|
48839
|
+
return Promise.resolve(false);
|
|
48840
|
+
}
|
|
48841
|
+
}
|
|
48842
|
+
function dropTorLane(lane) {
|
|
48843
|
+
try {
|
|
48844
|
+
prebuiltLanes.delete(lane);
|
|
48845
|
+
const dispatcher = laneDispatchers.get(lane);
|
|
48846
|
+
if (dispatcher === void 0) return;
|
|
48847
|
+
laneDispatchers.delete(lane);
|
|
48848
|
+
setImmediate(() => {
|
|
48849
|
+
try {
|
|
48850
|
+
dispatcher.close().catch(() => {
|
|
48851
|
+
});
|
|
48852
|
+
} catch {
|
|
48853
|
+
}
|
|
48854
|
+
});
|
|
48855
|
+
} catch {
|
|
48856
|
+
}
|
|
48857
|
+
}
|
|
48858
|
+
function torLaneReady(lane, onionOrigin) {
|
|
48859
|
+
try {
|
|
48860
|
+
const built = prebuiltLanes.get(lane);
|
|
48861
|
+
if (built === void 0 || runEnded() || laneDispatchers.get(lane) !== built.dispatcher) return false;
|
|
48862
|
+
const target = new URL(onionOrigin);
|
|
48863
|
+
return built.target === `${target.hostname}:${target.port || 80}`;
|
|
48864
|
+
} catch {
|
|
48865
|
+
return false;
|
|
48866
|
+
}
|
|
48867
|
+
}
|
|
48768
48868
|
function torOwnCircuitInit(lane, init = {}) {
|
|
48769
48869
|
if (lane === 0 || !inTorRun()) return void 0;
|
|
48770
48870
|
const made = torLaneInit(lane, init);
|
|
@@ -49048,7 +49148,7 @@ function torChild(argv2, stdio) {
|
|
|
49048
49148
|
if (!options.mode) throw new ProxyUsageError("torChild needs --tor");
|
|
49049
49149
|
return proxiedChild(options.args, options.proxy, stdio);
|
|
49050
49150
|
}
|
|
49051
|
-
var relayKeyOf, READ_ONLY_METHOD, readOnlyPost, TOR_HTTP_TUNNEL, TOR_CHECK, PROOF_TIMEOUT_MS, LOCAL_PROOF_TIMEOUT_MS, LOCAL_PROOF_MAX_BYTES, torProvenAt, proxyProvenAt, MARK, TOR_RUN_STARTED_ENV, ownProxyRefused, ONION_V3, RETRY_AFTER_CAP_MS, RETRY_AFTER_FLOOR_MS, RETRY_AFTER_DEFAULT_MS, RPC_NO_ANSWER_LIMIT_MS, RPC_PACING_CAP_MS, PACING_NOTICE_EVERY_MS, PACING_RATE_WINDOW_MS, TOR_MAX_ROTATIONS, runStartedAt, rpcNotBefore, pacingWaiters, pacingSince, pacedMs, rpcAnswered, lastAnswerAt, readSteps, pacingNoticeAt, pacingSamples, torMoves, torCircuitId, torMovesRefused, pendingMove, inTorRunOf, inTorRun, runNetworkMode, isOnionOrigin, ProxyUsageError, isOnionHost, PROXY_REMOVED, ENV_PROXY_NAMES, OUTER_PROXY_ENV, DIRECT_RUN_MARK, USE_ENV_PROXY_FLAG, withoutEnvProxyFlag, TOR_MIN_VERSION, localTorProof, TOR_EXPERT_BUNDLE, TOR_EXPERT_BUNDLE_SHA256, TOR_EXPERT_BUNDLE_URL, TUNNEL_LINE, TOR_DEB_KEY, TOR_DEB_KEYRING, TOR_INSTALL, torStart, LOCAL_TUNNEL, torStartText, TOR_WINDOW, torNotRunningMessage, torUpdateHow, TOR_STOP_OLD_WINDOWS, torTooOldWhy, torTooOldMessage, NOTICE, TOR_NOTICE_LINE, ONION_DETAIL_LINE, withoutOnionDetail, QUIET_RUN_MARK, QUIET_RUNS, QUIET_TERMINAL_COMMANDS, INFER_SUBCOMMANDS, quietRun, TOR_TROUBLE_LINE, TOR_WAIT_WORDS, TOR_WAIT_PLAIN, TOR_TROUBLE_PLAIN, promptRedraw, TOR_TROUBLE_SAID, quietTorErr, withRunTag, proxyEnv, pacedSoFar, RESENDABLE_METHOD, torCircuit, GLOBAL_DISPATCHER4, laneDispatchers, laneOfDispatcher, PROXY_WARNING_FLAG, proxiedExecArgv, proxiedNodeOptions, TOR_FROM_CONFIG_ENV, TOR_FROM_CONFIG_HINT, TOR_FROM_CONFIG_SENTENCE, launcherPid, torStarter;
|
|
49151
|
+
var relayKeyOf, READ_ONLY_METHOD, readOnlyPost, TOR_HTTP_TUNNEL, TOR_CHECK, PROOF_TIMEOUT_MS, LOCAL_PROOF_TIMEOUT_MS, LOCAL_PROOF_MAX_BYTES, torProvenAt, proxyProvenAt, MARK, TOR_RUN_STARTED_ENV, ownProxyRefused, ONION_V3, RETRY_AFTER_CAP_MS, RETRY_AFTER_FLOOR_MS, RETRY_AFTER_DEFAULT_MS, RPC_NO_ANSWER_LIMIT_MS, RPC_PACING_CAP_MS, PACING_NOTICE_EVERY_MS, PACING_RATE_WINDOW_MS, TOR_MAX_ROTATIONS, runStartedAt, rpcNotBefore, pacingWaiters, pacingSince, pacedMs, rpcAnswered, lastAnswerAt, readSteps, pacingNoticeAt, pacingSamples, torMoves, torCircuitId, torMovesRefused, pendingMove, inTorRunOf, inTorRun, runNetworkMode, isOnionOrigin, ProxyUsageError, isOnionHost, PROXY_REMOVED, ENV_PROXY_NAMES, OUTER_PROXY_ENV, DIRECT_RUN_MARK, USE_ENV_PROXY_FLAG, withoutEnvProxyFlag, TOR_MIN_VERSION, localTorProof, TOR_EXPERT_BUNDLE, TOR_EXPERT_BUNDLE_SHA256, TOR_EXPERT_BUNDLE_URL, TUNNEL_LINE, TOR_DEB_KEY, TOR_DEB_KEYRING, TOR_INSTALL, torStart, LOCAL_TUNNEL, torStartText, TOR_WINDOW, torNotRunningMessage, torUpdateHow, TOR_STOP_OLD_WINDOWS, torTooOldWhy, torTooOldMessage, NOTICE, TOR_NOTICE_LINE, ONION_DETAIL_LINE, withoutOnionDetail, QUIET_RUN_MARK, QUIET_RUNS, QUIET_TERMINAL_COMMANDS, INFER_SUBCOMMANDS, quietRun, TOR_TROUBLE_LINE, TOR_WAIT_WORDS, TOR_WAIT_PLAIN, TOR_TROUBLE_PLAIN, promptRedraw, TOR_TROUBLE_SAID, quietTorErr, withRunTag, proxyEnv, pacedSoFar, RESENDABLE_METHOD, torCircuit, GLOBAL_DISPATCHER4, laneDispatchers, laneOfDispatcher, laneProxyOf, prebuiltLanes, prebuildSockets, PREBUILD_TIMEOUT_MS, PROXY_WARNING_FLAG, proxiedExecArgv, proxiedNodeOptions, TOR_FROM_CONFIG_ENV, TOR_FROM_CONFIG_HINT, TOR_FROM_CONFIG_SENTENCE, launcherPid, torStarter;
|
|
49052
49152
|
var init_proxy = __esm({
|
|
49053
49153
|
"wallet/src/net/proxy.mjs"() {
|
|
49054
49154
|
"use strict";
|
|
@@ -49240,7 +49340,12 @@ ${command}`;
|
|
|
49240
49340
|
GLOBAL_DISPATCHER4 = /* @__PURE__ */ Symbol.for("undici.globalDispatcher.1");
|
|
49241
49341
|
laneDispatchers = /* @__PURE__ */ new Map();
|
|
49242
49342
|
laneOfDispatcher = /* @__PURE__ */ new WeakMap();
|
|
49343
|
+
laneProxyOf = /* @__PURE__ */ new WeakMap();
|
|
49344
|
+
prebuiltLanes = /* @__PURE__ */ new Map();
|
|
49345
|
+
prebuildSockets = /* @__PURE__ */ new Set();
|
|
49243
49346
|
registerRunDispatchers(() => laneDispatchers.values());
|
|
49347
|
+
registerRunDispatchers(() => [...prebuildSockets].map((socket) => ({ destroy: () => socket.destroy() })));
|
|
49348
|
+
PREBUILD_TIMEOUT_MS = 3e4;
|
|
49244
49349
|
PROXY_WARNING_FLAG = "--disable-warning=UNDICI-EHPA";
|
|
49245
49350
|
proxiedExecArgv = (execArgv = process.execArgv) => execArgv.includes(PROXY_WARNING_FLAG) ? [...execArgv] : [...execArgv, PROXY_WARNING_FLAG];
|
|
49246
49351
|
proxiedNodeOptions = (nodeOptions = process.env.NODE_OPTIONS) => {
|
|
@@ -53065,7 +53170,7 @@ function connect2(rpcUrl, commitment = "finalized", { timeoutMs, wrapFetch = (fe
|
|
|
53065
53170
|
headers.delete("content-length");
|
|
53066
53171
|
return new Response(body, { status: response.status, statusText: response.statusText, headers });
|
|
53067
53172
|
} catch (error) {
|
|
53068
|
-
if (stalled.signal.aborted && !init?.signal?.aborted) await moveTorCircuitAfterStall(circuit);
|
|
53173
|
+
if (stalled.signal.aborted && !init?.signal?.aborted && !init?.ownLane) await moveTorCircuitAfterStall(circuit);
|
|
53069
53174
|
throw error;
|
|
53070
53175
|
} finally {
|
|
53071
53176
|
clearTimeout(timer);
|
|
@@ -53093,7 +53198,8 @@ function connect2(rpcUrl, commitment = "finalized", { timeoutMs, wrapFetch = (fe
|
|
|
53093
53198
|
headers: { "content-type": "application/json" },
|
|
53094
53199
|
body: JSON.stringify({ jsonrpc: "2.0", id: id ?? randomUUID(), method, params })
|
|
53095
53200
|
};
|
|
53096
|
-
const
|
|
53201
|
+
const laneInit = lane === void 0 ? init : torLaneInit(lane, init);
|
|
53202
|
+
const response = await fetch2(rpcUrl, laneInit !== init && laneInit.dispatcher !== void 0 ? { ...laneInit, ownLane: true } : laneInit);
|
|
53097
53203
|
onResponseHead(response);
|
|
53098
53204
|
if (rejectHttpError && !response.ok) throw new Error(`${response.status} ${response.statusText}: ${await response.text()}`);
|
|
53099
53205
|
return response.json();
|
|
@@ -61978,7 +62084,7 @@ function validateRecord(raw, ordinal, { programId, pool: pool2, poolDomain, snap
|
|
|
61978
62084
|
function requestPage(history, pool2, from, signal) {
|
|
61979
62085
|
return requestList(history, pool2, from, P03_COMPACT_PAGE, { signal }).read;
|
|
61980
62086
|
}
|
|
61981
|
-
function requestList(history, pool2, from, size, { attempts = LIST_ATTEMPTS, signal } = {}) {
|
|
62087
|
+
function requestList(history, pool2, from, size, { attempts = LIST_ATTEMPTS, signal, lane } = {}) {
|
|
61982
62088
|
if (signal?.aborted) return { read: Promise.resolve({ error: signal.reason }), release() {
|
|
61983
62089
|
} };
|
|
61984
62090
|
const source = typeof history?.rpcEndpoint === "string" ? history.rpcEndpoint : history;
|
|
@@ -61992,7 +62098,7 @@ function requestList(history, pool2, from, size, { attempts = LIST_ATTEMPTS, sig
|
|
|
61992
62098
|
markPhase("compact-list-ask", `from${from}_to${from + size}_joined_${joined}`);
|
|
61993
62099
|
if (!joined) {
|
|
61994
62100
|
const stop2 = new AbortController();
|
|
61995
|
-
entry = { holders: 0, stop: stop2, done: false, read: requestListNow(history, pool2, from, size, attempts, stop2.signal) };
|
|
62101
|
+
entry = { holders: 0, stop: stop2, done: false, read: requestListNow(history, pool2, from, size, attempts, stop2.signal, lane) };
|
|
61996
62102
|
if (byKey === void 0) listInFlight.set(source, byKey = /* @__PURE__ */ new Map());
|
|
61997
62103
|
byKey.set(key, entry);
|
|
61998
62104
|
entry.forget = () => {
|
|
@@ -62036,14 +62142,20 @@ function requestList(history, pool2, from, size, { attempts = LIST_ATTEMPTS, sig
|
|
|
62036
62142
|
}
|
|
62037
62143
|
return handle;
|
|
62038
62144
|
}
|
|
62039
|
-
function requestListNow(history, pool2, from, size, attempts, signal) {
|
|
62145
|
+
function requestListNow(history, pool2, from, size, attempts, signal, lane) {
|
|
62040
62146
|
const params = [pool2, { commitment: "finalized", fromOrdinal: from, toOrdinal: from + size }];
|
|
62041
62147
|
const attempt = async (index) => {
|
|
62042
62148
|
if (runEnded()) return { error: runEndedError() };
|
|
62043
62149
|
const circuit = torCircuit();
|
|
62044
62150
|
try {
|
|
62045
|
-
return { response: await listRequest(history, params, { signal, label: attempts === 1 ? `tail${from}` : `page${from}_try${index + 1}` }) };
|
|
62151
|
+
return { response: await listRequest(history, params, { signal, lane, label: attempts === 1 ? `tail${from}` : `page${from}_try${index + 1}` }) };
|
|
62046
62152
|
} catch (error) {
|
|
62153
|
+
if (lane !== void 0 && !runEnded() && !signal.aborted && !proxyRefusedConnection(error)) {
|
|
62154
|
+
dropTorLane(lane);
|
|
62155
|
+
markPhase("compact-tail-lane-dropped", failureCause(error));
|
|
62156
|
+
lane = void 0;
|
|
62157
|
+
return attempt(index);
|
|
62158
|
+
}
|
|
62047
62159
|
if (runEnded() || index + 1 >= attempts || proxyRefusedConnection(error) || sourceUnreachable(error, circuit) || signal.aborted) return { error };
|
|
62048
62160
|
markPhase("compact-list-retry");
|
|
62049
62161
|
await runSleep(Math.min(8e3, 1e3 * 2 ** index));
|
|
@@ -62053,6 +62165,14 @@ function requestListNow(history, pool2, from, size, attempts, signal) {
|
|
|
62053
62165
|
};
|
|
62054
62166
|
return attempt(0);
|
|
62055
62167
|
}
|
|
62168
|
+
function tailLane(history) {
|
|
62169
|
+
if (!inTorRun()) return void 0;
|
|
62170
|
+
const winner = historyOnionWinner(history?.rpcEndpoint);
|
|
62171
|
+
if (winner === void 0) return void 0;
|
|
62172
|
+
const own = torLaneReady(HISTORY_TAIL_LANE, winner);
|
|
62173
|
+
markPhase("compact-tail-lane", own ? "own" : "main");
|
|
62174
|
+
return own ? HISTORY_TAIL_LANE : void 0;
|
|
62175
|
+
}
|
|
62056
62176
|
function sendRestOfSet(history, pool2, count3, grid, signal) {
|
|
62057
62177
|
const pages = /* @__PURE__ */ new Map();
|
|
62058
62178
|
if (!(count3 > 0)) return { pages, tail: void 0, tailSize: grid };
|
|
@@ -62061,11 +62181,11 @@ function sendRestOfSet(history, pool2, count3, grid, signal) {
|
|
|
62061
62181
|
}
|
|
62062
62182
|
const from = tailFrom(count3, grid);
|
|
62063
62183
|
const onPage = from % P03_COMPACT_PAGE === 0;
|
|
62064
|
-
const tail = onPage ? pages.get(from) : requestList(history, pool2, from, grid, { attempts: 1, signal });
|
|
62184
|
+
const tail = onPage ? pages.get(from) : requestList(history, pool2, from, grid, { attempts: 1, signal, lane: tailLane(history) });
|
|
62065
62185
|
markPhase("compact-rest-sent", `pages${pages.size}`);
|
|
62066
62186
|
return { pages, tail, tailSize: onPage ? P03_COMPACT_PAGE : grid };
|
|
62067
62187
|
}
|
|
62068
|
-
async function listRequest(history, params, { signal, label }) {
|
|
62188
|
+
async function listRequest(history, params, { signal, label, lane }) {
|
|
62069
62189
|
if (typeof history.abortableRpcRequest !== "function") {
|
|
62070
62190
|
markPhase("compact-list-request", label);
|
|
62071
62191
|
return history._rpcRequest("getP03Transitions", params);
|
|
@@ -62087,7 +62207,7 @@ async function listRequest(history, params, { signal, label }) {
|
|
|
62087
62207
|
clearTimeout(timer);
|
|
62088
62208
|
markPhase("compact-list-head", label);
|
|
62089
62209
|
},
|
|
62090
|
-
{ rejectHttpError: true, bodyStallMs: LIST_BODY_STALL_MS, totalCapMs: LIST_TOTAL_CAP_MS }
|
|
62210
|
+
{ rejectHttpError: true, bodyStallMs: LIST_BODY_STALL_MS, totalCapMs: LIST_TOTAL_CAP_MS, ...lane === void 0 ? {} : { lane } }
|
|
62091
62211
|
);
|
|
62092
62212
|
read.catch(() => {
|
|
62093
62213
|
});
|
|
@@ -62096,14 +62216,14 @@ async function listRequest(history, params, { signal, label }) {
|
|
|
62096
62216
|
timer = setTimeout(() => {
|
|
62097
62217
|
headless.abort();
|
|
62098
62218
|
reject(new Error(LIST_HEAD_STALLED));
|
|
62099
|
-
}, LIST_HEAD_TIMEOUT_MS);
|
|
62219
|
+
}, lane === void 0 ? LIST_HEAD_TIMEOUT_MS : LANE_HEAD_TIMEOUT_MS);
|
|
62100
62220
|
})]) : read);
|
|
62101
62221
|
markPhase("compact-list-answer", label);
|
|
62102
62222
|
return response;
|
|
62103
62223
|
} catch (error) {
|
|
62104
62224
|
if (error?.message === LIST_HEAD_STALLED) {
|
|
62105
62225
|
markPhase("compact-list-head-timeout", label);
|
|
62106
|
-
await moveTorCircuitAfterStall(circuit);
|
|
62226
|
+
if (lane === void 0) await moveTorCircuitAfterStall(circuit);
|
|
62107
62227
|
} else {
|
|
62108
62228
|
const cause = signal?.aborted ? "stopped" : { [HISTORY_BODY_STALLED]: "body_stall", [HISTORY_BODY_CAPPED]: "capped" }[error?.message] ?? failureCause(error);
|
|
62109
62229
|
markPhase("compact-list-failed", `${label}_${cause}`);
|
|
@@ -63332,7 +63452,7 @@ async function tryCompactP03HistoryReport(options) {
|
|
|
63332
63452
|
return { ok: false, reason, ...detail ? { detail } : {}, error };
|
|
63333
63453
|
}
|
|
63334
63454
|
}
|
|
63335
|
-
var import_web398, P03_COMPACT_HISTORY_SOURCE_MODEL, P03_COMPACT_PAGE, P03_COMPACT_SPOT_CHECKS, FIELD_MODULUS5, SUBTREE_LEAVES3, LOCAL_DEPTH2, OUTER_DEPTH2, PRIMARY_PROOF_BYTES2, FIELD_BYTES3, ED25519_SPKI_PREFIX3, VERSION_1_PREFIX2, HEX642, BASE58, REPLAY_STORE_INDEXED2, PROFILES2, MOVE_HEAD_BYTES2, MOVE_INSERTED_VALUES2, refuse3, hash4, bitAt, zeroRootsMemo, lastFolds, PRE_FOLD_SLICE_MS, preFolds, FOLD_CHECKPOINT_EVERY, foldNode, foldFrontier, foldHex, servedWithoutRecords, isSignature, isIndex, IMPORT_KEYS, IMPORT_MAX_VALUES, LIST_ATTEMPTS, listInFlight, LIST_HEAD_TIMEOUT_MS, LIST_HEAD_STALLED, LIST_BODY_STALL_MS, LIST_TOTAL_CAP_MS, OWN_READ_TIMEOUT_MS, BOUNDED_OWN_METHODS, P03_COMPACT_TAIL_GRID, TAIL_RETRY_REFUSALS, tailFrom, sameJson2, SPOT_HEDGE_AFTER_MS, SPOT_HEDGE_LANE, POOL_HEDGE_AFTER_MS, POOL_HEDGE_LANE, compactReportsRunning, compactHistoryReadsRunning;
|
|
63455
|
+
var import_web398, P03_COMPACT_HISTORY_SOURCE_MODEL, P03_COMPACT_PAGE, P03_COMPACT_SPOT_CHECKS, FIELD_MODULUS5, SUBTREE_LEAVES3, LOCAL_DEPTH2, OUTER_DEPTH2, PRIMARY_PROOF_BYTES2, FIELD_BYTES3, ED25519_SPKI_PREFIX3, VERSION_1_PREFIX2, HEX642, BASE58, REPLAY_STORE_INDEXED2, PROFILES2, MOVE_HEAD_BYTES2, MOVE_INSERTED_VALUES2, refuse3, hash4, bitAt, zeroRootsMemo, lastFolds, PRE_FOLD_SLICE_MS, preFolds, FOLD_CHECKPOINT_EVERY, foldNode, foldFrontier, foldHex, servedWithoutRecords, isSignature, isIndex, IMPORT_KEYS, IMPORT_MAX_VALUES, LIST_ATTEMPTS, listInFlight, HISTORY_TAIL_LANE, LIST_HEAD_TIMEOUT_MS, LIST_HEAD_STALLED, LANE_HEAD_TIMEOUT_MS, LIST_BODY_STALL_MS, LIST_TOTAL_CAP_MS, OWN_READ_TIMEOUT_MS, BOUNDED_OWN_METHODS, P03_COMPACT_TAIL_GRID, TAIL_RETRY_REFUSALS, tailFrom, sameJson2, SPOT_HEDGE_AFTER_MS, SPOT_HEDGE_LANE, POOL_HEDGE_AFTER_MS, POOL_HEDGE_LANE, compactReportsRunning, compactHistoryReadsRunning;
|
|
63336
63456
|
var init_compact = __esm({
|
|
63337
63457
|
"wallet/src/history/compact.mjs"() {
|
|
63338
63458
|
"use strict";
|
|
@@ -63477,8 +63597,10 @@ var init_compact = __esm({
|
|
|
63477
63597
|
IMPORT_MAX_VALUES = 3;
|
|
63478
63598
|
LIST_ATTEMPTS = 6;
|
|
63479
63599
|
listInFlight = /* @__PURE__ */ new Map();
|
|
63600
|
+
HISTORY_TAIL_LANE = "history-tail";
|
|
63480
63601
|
LIST_HEAD_TIMEOUT_MS = 1e4;
|
|
63481
63602
|
LIST_HEAD_STALLED = "ETIMEDOUT: history list answer head stalled";
|
|
63603
|
+
LANE_HEAD_TIMEOUT_MS = 1500;
|
|
63482
63604
|
LIST_BODY_STALL_MS = 8e3;
|
|
63483
63605
|
LIST_TOTAL_CAP_MS = 6e4;
|
|
63484
63606
|
OWN_READ_TIMEOUT_MS = HISTORY_RPC_REQUEST_TIMEOUT_MS;
|
|
@@ -67060,7 +67182,8 @@ async function tokenAccount(connection, address4, commitment = "finalized") {
|
|
|
67060
67182
|
throw error;
|
|
67061
67183
|
}
|
|
67062
67184
|
});
|
|
67063
|
-
} catch {
|
|
67185
|
+
} catch (error) {
|
|
67186
|
+
if (isRelayLimitError(error)) throw error;
|
|
67064
67187
|
fail15("token_balance_unreadable");
|
|
67065
67188
|
}
|
|
67066
67189
|
}
|
|
@@ -67637,7 +67760,8 @@ async function addressHasHistory(connection, address4) {
|
|
|
67637
67760
|
try {
|
|
67638
67761
|
if (typeof connection.getSignaturesForAddress !== "function") throw new Error("no history read");
|
|
67639
67762
|
history = await retryRpc2(() => connection.getSignaturesForAddress(new import_web3104.PublicKey(address4), { limit: 1 }, "confirmed"));
|
|
67640
|
-
} catch {
|
|
67763
|
+
} catch (error) {
|
|
67764
|
+
if (isRelayLimitError(error)) throw error;
|
|
67641
67765
|
fail15("relay_history_unreadable");
|
|
67642
67766
|
}
|
|
67643
67767
|
if (!Array.isArray(history)) fail15("relay_history_unreadable");
|
|
@@ -67991,7 +68115,7 @@ async function submitRelayedDepositLeased({ store, connection, programId, proofT
|
|
|
67991
68115
|
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
67992
68116
|
const historyConnection = deps.historyConnection ?? (connection.historyRpcChoice !== void 0 || connection.historyRpc ? connection : connectSplit(connection, historyUrl));
|
|
67993
68117
|
const loadHistory = () => finalizedHistory({ store, connection: historyConnection, id, proofTools, deps });
|
|
67994
|
-
const refuse12 = async (reason) => {
|
|
68118
|
+
const refuse12 = async (reason, why) => {
|
|
67995
68119
|
record.relay.lastRefusal = { reason, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
67996
68120
|
store.writeWal(name, record);
|
|
67997
68121
|
let approved;
|
|
@@ -68004,7 +68128,9 @@ async function submitRelayedDepositLeased({ store, connection, programId, proofT
|
|
|
68004
68128
|
record.relay.approvedOnChain = approved;
|
|
68005
68129
|
store.writeWal(name, record);
|
|
68006
68130
|
}
|
|
68007
|
-
|
|
68131
|
+
const standing = approved ? new Error("p03_deposit_relay_approval_standing") : void 0;
|
|
68132
|
+
const cause = why ? new Error(`p03_deposit_${why}`, standing ? { cause: standing } : void 0) : standing;
|
|
68133
|
+
throw new Error(`p03_deposit_${reason}`, cause ? { cause } : void 0);
|
|
68008
68134
|
};
|
|
68009
68135
|
const foreignFunded = async () => {
|
|
68010
68136
|
if (!record.foreignFunding.memoPublished) {
|
|
@@ -68016,7 +68142,7 @@ async function submitRelayedDepositLeased({ store, connection, programId, proofT
|
|
|
68016
68142
|
};
|
|
68017
68143
|
if (record.state === "foreign_funded") return foreignFunded();
|
|
68018
68144
|
for (let round = 0; record.state === "proved" || record.state === "submitted"; round += 1) {
|
|
68019
|
-
if (round >= RELAY_ROUNDS) await refuse12("relay_not_settled_rerun_same_id");
|
|
68145
|
+
if (round >= RELAY_ROUNDS) await refuse12("relay_not_settled_rerun_same_id", record.relay.result ? "relay_sent_confirmation_unread" : void 0);
|
|
68020
68146
|
const settled = (promise) => {
|
|
68021
68147
|
promise.catch(() => void 0);
|
|
68022
68148
|
return promise;
|
|
@@ -68050,7 +68176,7 @@ async function submitRelayedDepositLeased({ store, connection, programId, proofT
|
|
|
68050
68176
|
store.writeWal(name, record);
|
|
68051
68177
|
break;
|
|
68052
68178
|
}
|
|
68053
|
-
if (record.relay.result
|
|
68179
|
+
if (record.relay.result) {
|
|
68054
68180
|
await pause4(5e3);
|
|
68055
68181
|
continue;
|
|
68056
68182
|
}
|
|
@@ -68625,8 +68751,14 @@ async function runDepositReclaimCommand(args, cli5) {
|
|
|
68625
68751
|
const lines = [];
|
|
68626
68752
|
if (result.reclaimed) lines.push(`The deposit's USDC came back from the one-time address ${result.oneTimeAddress}: ${moved(result.reclaimed)}.`);
|
|
68627
68753
|
for (const entry of result.leftovers ?? []) lines.push(`USDC that reached the one-time address after its deposit came back: ${moved(entry)}.`);
|
|
68628
|
-
|
|
68629
|
-
|
|
68754
|
+
const back = [result.reclaimed, ...result.leftovers ?? []].filter(Boolean);
|
|
68755
|
+
if (back.length === 0) {
|
|
68756
|
+
lines.push(`Nothing moved: the one-time address ${result.oneTimeAddress} of deposit ${result.depositId} holds no USDC to take back.`);
|
|
68757
|
+
if (result.state === "published" || result.state === "finalized") lines.push("This deposit is already in your private balance.");
|
|
68758
|
+
} else {
|
|
68759
|
+
const places = [...new Set(back.map((entry) => entry.to))].join(" and ");
|
|
68760
|
+
lines.push(`That USDC is now at ${places}, outside your private balance (add-funds makes it private again).`);
|
|
68761
|
+
}
|
|
68630
68762
|
console.log(lines.join("\n"));
|
|
68631
68763
|
}
|
|
68632
68764
|
async function runDepositScanCommand(args, cli5) {
|
|
@@ -68796,6 +68928,7 @@ var init_deposit = __esm({
|
|
|
68796
68928
|
init_keys2();
|
|
68797
68929
|
init_serviceUrl();
|
|
68798
68930
|
init_proxy();
|
|
68931
|
+
init_relayLimit();
|
|
68799
68932
|
init_approveInBuffer();
|
|
68800
68933
|
init_processLease();
|
|
68801
68934
|
init_witness();
|
|
@@ -70673,6 +70806,9 @@ var init_errorCodes = __esm({
|
|
|
70673
70806
|
"p03_compact_history_spot_check_mismatch",
|
|
70674
70807
|
"p03_compact_history_spot_check_unavailable",
|
|
70675
70808
|
"p03_deposit_relay_approval_standing",
|
|
70809
|
+
// deposit.mjs: the cause of relay_not_settled_rerun_same_id when the deposit was sent and called final, and only its
|
|
70810
|
+
// confirmation read is stale; nothing is sent again.
|
|
70811
|
+
"p03_deposit_relay_sent_confirmation_unread",
|
|
70676
70812
|
"p03_deposit_relay_buffer_message_account_flags_invalid",
|
|
70677
70813
|
"p03_deposit_relay_buffer_message_accounts_invalid",
|
|
70678
70814
|
"p03_deposit_relay_buffer_message_approve_invalid",
|
|
@@ -115205,8 +115341,9 @@ function refusalSay(a, tool, again, npmVersion) {
|
|
|
115205
115341
|
}
|
|
115206
115342
|
if (code2 === "mcp_max_payment_not_usdc") {
|
|
115207
115343
|
const cap = usdcText2(a.capAtomic);
|
|
115208
|
-
const
|
|
115209
|
-
|
|
115344
|
+
const what2 = cap ? `the cap reads as ${cap} USDC` : "the cap";
|
|
115345
|
+
const why2 = a.wholeBalanceAtomic === void 0 ? "which looks like a mistake" : "more than your balance";
|
|
115346
|
+
return `Nothing was paid: ${what2}, ${why2}. A cap is in USDC, like 0.01 for one cent. Ask again.`;
|
|
115210
115347
|
}
|
|
115211
115348
|
if (a.walletUpdateNeeded === true) {
|
|
115212
115349
|
const cannot = "this wallet version cannot read the private balance record";
|
|
@@ -115763,6 +115900,10 @@ function linkSay(a) {
|
|
|
115763
115900
|
// Another stage ("pending": the wallet was busy): the step of its next (addFunds.mjs nextFor default), not a promise
|
|
115764
115901
|
// of one (a live check 0.3.115 terminal pass follow-up, 2026-10-28).
|
|
115765
115902
|
default:
|
|
115903
|
+
if (a.stage === "waiting" && a.code === "rpc_relay_limit") {
|
|
115904
|
+
const opens = relayLimitWords(relayLimitNow());
|
|
115905
|
+
return `${opens ? opens.split(/(?<=\.)\s/)[0] : "Shinjuku's free Solana chain reader reached its limit for now."} Nothing is lost; ask again after that time.`;
|
|
115906
|
+
}
|
|
115766
115907
|
return "The USDC is safe at the address and not private yet. I can check your balance in a minute; it then becomes private by itself.";
|
|
115767
115908
|
}
|
|
115768
115909
|
}
|
|
@@ -124543,7 +124684,7 @@ async function statusPass({ run: run2, id, prepare = prepareRelayedDeposit, subm
|
|
|
124543
124684
|
return true;
|
|
124544
124685
|
});
|
|
124545
124686
|
} catch (error) {
|
|
124546
|
-
return answer("waiting", { code:
|
|
124687
|
+
return answer("waiting", { code: errorCodeOf(error) });
|
|
124547
124688
|
}
|
|
124548
124689
|
if (!removed) return answer("waiting", { code: "payme_round_address_mismatch" });
|
|
124549
124690
|
}
|
|
@@ -124558,7 +124699,7 @@ async function statusPass({ run: run2, id, prepare = prepareRelayedDeposit, subm
|
|
|
124558
124699
|
try {
|
|
124559
124700
|
legacy = record.keyPool && record.keyPool !== familyRoot(store.state.pool) ? { keyPool: record.keyPool } : void 0;
|
|
124560
124701
|
} catch (error) {
|
|
124561
|
-
return answer("waiting", { code:
|
|
124702
|
+
return answer("waiting", { code: errorCodeOf(error) });
|
|
124562
124703
|
}
|
|
124563
124704
|
try {
|
|
124564
124705
|
await prepare({
|
|
@@ -124575,12 +124716,12 @@ async function statusPass({ run: run2, id, prepare = prepareRelayedDeposit, subm
|
|
|
124575
124716
|
return answer("below_minimum", { ...error.minimumAtomic ? { minimumAtomic: String(error.minimumAtomic) } : {} });
|
|
124576
124717
|
}
|
|
124577
124718
|
if (message === "p03_deposit_another_deposit_unresolved") return answer("pending");
|
|
124578
|
-
return answer("waiting", { code:
|
|
124719
|
+
return answer("waiting", { code: errorCodeOf(error) });
|
|
124579
124720
|
}
|
|
124580
124721
|
try {
|
|
124581
124722
|
await onShield({ amountAtomic: amount.toString(), round });
|
|
124582
124723
|
} catch (error) {
|
|
124583
|
-
return answer("waiting", { code:
|
|
124724
|
+
return answer("waiting", { code: errorCodeOf(error) });
|
|
124584
124725
|
}
|
|
124585
124726
|
if (!shielding || record.shieldAtomic !== amount.toString()) {
|
|
124586
124727
|
record = update(store, record, {
|
|
@@ -124603,7 +124744,7 @@ async function statusPass({ run: run2, id, prepare = prepareRelayedDeposit, subm
|
|
|
124603
124744
|
} catch (error) {
|
|
124604
124745
|
const message = String(error?.message ?? error);
|
|
124605
124746
|
if (/not_settled_rerun_same_id|in_flight/.test(message)) return answer("shielding");
|
|
124606
|
-
return answer("waiting", { code:
|
|
124747
|
+
return answer("waiting", { code: errorCodeOf(error) });
|
|
124607
124748
|
}
|
|
124608
124749
|
}
|
|
124609
124750
|
function carryPayMeLinks(source, target) {
|
|
@@ -124695,7 +124836,7 @@ function payMeNotice(outcome) {
|
|
|
124695
124836
|
return `${usdc5(outcome.heldAtomic)} USDC reached the address; the deposit cannot go in now (${outcome.code ?? "waiting"}). It is safe at the address; check again in a minute.`;
|
|
124696
124837
|
}
|
|
124697
124838
|
}
|
|
124698
|
-
var import_web3130, formatAtomic2, PAY_ME_WAL_SCHEMA2, PAY_ME_ID, payMeWalName, payMeDepositId, KEY_PROBES, TOKEN_ACCOUNT_LEN, PAY_ME_MIN_ATOMIC, NOTE_MAX_CHARS, PayMeError, fail43, isOneTimeDeposit, readPayMe, TOKEN_PROGRAMS, solCoinWords, tokenCoinWords, wrongCoinLine, addressTouched, update, payMeRoundDepositId, codeOf3;
|
|
124839
|
+
var import_web3130, formatAtomic2, PAY_ME_WAL_SCHEMA2, PAY_ME_ID, payMeWalName, payMeDepositId, KEY_PROBES, TOKEN_ACCOUNT_LEN, PAY_ME_MIN_ATOMIC, NOTE_MAX_CHARS, PayMeError, fail43, isOneTimeDeposit, readPayMe, TOKEN_PROGRAMS, solCoinWords, tokenCoinWords, wrongCoinLine, addressTouched, update, payMeRoundDepositId, codeOf3, errorCodeOf;
|
|
124699
124840
|
var init_payMe = __esm({
|
|
124700
124841
|
"wallet/src/payme/payMe.mjs"() {
|
|
124701
124842
|
"use strict";
|
|
@@ -124706,6 +124847,7 @@ var init_payMe = __esm({
|
|
|
124706
124847
|
init_deposit();
|
|
124707
124848
|
init_oneTimeKeys();
|
|
124708
124849
|
init_proxy();
|
|
124850
|
+
init_relayLimit();
|
|
124709
124851
|
init_keys();
|
|
124710
124852
|
init_processLease();
|
|
124711
124853
|
formatAtomic2 = (atomic5, decimals) => formatAtomic(atomic5, decimals).replace(/(\.\d*?[1-9])0+$|\.0+$/, "$1");
|
|
@@ -124746,6 +124888,7 @@ var init_payMe = __esm({
|
|
|
124746
124888
|
};
|
|
124747
124889
|
payMeRoundDepositId = (id, round) => round === 1 ? payMeDepositId(id) : `${payMeDepositId(id)}-${round}`;
|
|
124748
124890
|
codeOf3 = (message) => message.split(":")[0].trim().slice(0, 96);
|
|
124891
|
+
errorCodeOf = (error) => isRelayLimitError(error) ? "rpc_relay_limit" : codeOf3(String(error?.message ?? error));
|
|
124749
124892
|
}
|
|
124750
124893
|
});
|
|
124751
124894
|
|
|
@@ -131409,6 +131552,9 @@ function createAddFundsTool({
|
|
|
131409
131552
|
const original = typeof answer.next === "string" ? answer.next : "";
|
|
131410
131553
|
if (original && !/wallet_pay_me/.test(original)) return prefix + original;
|
|
131411
131554
|
const check = `call wallet_add_funds with request_id "${agentId}"`;
|
|
131555
|
+
if (answer.stage === "waiting" && answer.code === "rpc_relay_limit") {
|
|
131556
|
+
return `${prefix}Tell the user: ${relayLimitWords(relayLimitNow()) ?? "Shinjuku's free Solana chain reader reached its limit for now."} The deposit keeps its record, so nothing is lost; ask again after that time. Do not poll before then; after that time, ${check}.`;
|
|
131557
|
+
}
|
|
131412
131558
|
const max = usdc(maxAtomic());
|
|
131413
131559
|
switch (answer.stage) {
|
|
131414
131560
|
case "waiting_for_payment":
|
|
@@ -131528,6 +131674,14 @@ function createAddFundsTool({
|
|
|
131528
131674
|
const limits = error.code === "payme_amount_invalid" ? { minAtomic: PAY_ME_MIN_ATOMIC.toString(), maxAtomic: maxAtomic().toString() } : error.code === "payme_note_invalid" ? { noteMaxChars: NOTE_MAX_CHARS } : {};
|
|
131529
131675
|
return refuse9(error.code, `${detail || error.code}; nothing was moved`, next, { ...extra, ...limits });
|
|
131530
131676
|
}
|
|
131677
|
+
if (isRelayLimitError(error)) {
|
|
131678
|
+
return refuse9(
|
|
131679
|
+
"rpc_relay_limit",
|
|
131680
|
+
`${relayLimitWords(relayLimitNow()) ?? "Shinjuku's free Solana chain reader reached its limit for now."} The deposit keeps its record, so nothing is lost`,
|
|
131681
|
+
`Tell the user that line. Call wallet_add_funds again${agentId ? ` with request_id "${agentId}"` : ""} after that time, not before`,
|
|
131682
|
+
extra
|
|
131683
|
+
);
|
|
131684
|
+
}
|
|
131531
131685
|
const code2 = codeOf5(error);
|
|
131532
131686
|
const locked2 = /wallet_locked|wallet_process_locked/.test(code2);
|
|
131533
131687
|
return refuse9(
|
|
@@ -131721,6 +131875,7 @@ var init_addFunds = __esm({
|
|
|
131721
131875
|
init_phaseTiming();
|
|
131722
131876
|
init_payMe();
|
|
131723
131877
|
init_qr();
|
|
131878
|
+
init_relayLimit();
|
|
131724
131879
|
init_say();
|
|
131725
131880
|
WRONG_COIN_READ_EVERY_MS = 6e4;
|
|
131726
131881
|
json = (value2) => ({ text: JSON.stringify(value2, null, 2) });
|
|
@@ -134188,7 +134343,21 @@ function checkRequest(args) {
|
|
|
134188
134343
|
return { refusal: ["mcp_argument_invalid", "body must be a string (send JSON as its text)", "pass body as a string, or leave it out"] };
|
|
134189
134344
|
}
|
|
134190
134345
|
if (method === "GET" && args.body) return { refusal: ["mcp_argument_invalid", "a GET request carries no body", "use method POST to send a body"] };
|
|
134191
|
-
|
|
134346
|
+
const body = args.body ?? void 0;
|
|
134347
|
+
const typed = Object.keys(headers).some((name) => name.toLowerCase() === "content-type");
|
|
134348
|
+
return { method, headers: !typed && isJsonBody(body) ? { ...headers, "content-type": "application/json" } : headers, body };
|
|
134349
|
+
}
|
|
134350
|
+
function isJsonBody(body) {
|
|
134351
|
+
if (typeof body !== "string") return false;
|
|
134352
|
+
const text3 = body.trim();
|
|
134353
|
+
if (!text3) return false;
|
|
134354
|
+
if (text3.length > JSON_SNIFF_MAX_CHARS) return text3[0] === "{" || text3[0] === "[";
|
|
134355
|
+
try {
|
|
134356
|
+
JSON.parse(text3);
|
|
134357
|
+
return true;
|
|
134358
|
+
} catch {
|
|
134359
|
+
return false;
|
|
134360
|
+
}
|
|
134192
134361
|
}
|
|
134193
134362
|
function payCapArgument(args) {
|
|
134194
134363
|
if (args.max_payment !== void 0 && args.max_payment !== null) {
|
|
@@ -136831,7 +137000,7 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
136831
137000
|
properties: {
|
|
136832
137001
|
url: { type: "string", description: "The absolute https URL of the paid resource." },
|
|
136833
137002
|
method: { type: "string", enum: ["GET", "POST"], description: "HTTP method; default GET." },
|
|
136834
|
-
headers: { type: "object", additionalProperties: { type: "string" }, description: "Extra request headers (never payment or transport headers)." },
|
|
137003
|
+
headers: { type: "object", additionalProperties: { type: "string" }, description: "Extra request headers (never payment or transport headers). A JSON body with no content-type goes as application/json." },
|
|
136835
137004
|
body: { type: "string", description: "Request body text (POST only)." }
|
|
136836
137005
|
},
|
|
136837
137006
|
required: ["url"],
|
|
@@ -136986,7 +137155,7 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
136986
137155
|
properties: {
|
|
136987
137156
|
url: { type: "string", description: "The absolute https URL of the paid resource." },
|
|
136988
137157
|
method: { type: "string", enum: ["GET", "POST"], description: "HTTP method; default GET." },
|
|
136989
|
-
headers: { type: "object", additionalProperties: { type: "string" }, description: "Extra request headers (never payment or transport headers)." },
|
|
137158
|
+
headers: { type: "object", additionalProperties: { type: "string" }, description: "Extra request headers (never payment or transport headers). A JSON body with no content-type goes as application/json." },
|
|
136990
137159
|
body: { type: "string", description: "Request body text (POST only)." },
|
|
136991
137160
|
max_payment: { type: "string", description: 'Optional: the most this call may pay, in USDC, like "0.01" (not atomic units); at most the spending limit.' },
|
|
136992
137161
|
max_payment_atomic: { type: "string", pattern: "^[1-9][0-9]*$", description: "The same in atomic units (1000000 = 1 USDC). Give max_payment or max_payment_atomic, not both with different values." },
|
|
@@ -143274,6 +143443,7 @@ ${canonical5}`;
|
|
|
143274
143443
|
const DEPOSIT_HELD_MS = 30 * 6e4;
|
|
143275
143444
|
const DEPOSIT_RETRY_MS = 6e4;
|
|
143276
143445
|
const DEPOSIT_TRIES_MAX = 10;
|
|
143446
|
+
const DEPOSIT_RELAY_WAITS_MAX = 3;
|
|
143277
143447
|
const DEPOSIT_HELD_STAGES = /* @__PURE__ */ new Set(["over_cap", "below_minimum", "paid_not_shielded", "closed", "waiting_for_payment", "reclaimed"]);
|
|
143278
143448
|
const depositTries = /* @__PURE__ */ new Map();
|
|
143279
143449
|
const depositHeld = /* @__PURE__ */ new Map();
|
|
@@ -143383,16 +143553,27 @@ ${canonical5}`;
|
|
|
143383
143553
|
if (link3.dueAt > now || payMePasses.has(link3.id)) continue;
|
|
143384
143554
|
const tried = depositTries.get(link3.id);
|
|
143385
143555
|
if (tried && (tried.running || now - tried.atMs < DEPOSIT_RETRY_MS)) continue;
|
|
143386
|
-
const attempt = { atMs: now, tries: (tried?.tries ?? 0) + 1, running: true };
|
|
143556
|
+
const attempt = { atMs: now, tries: (tried?.tries ?? 0) + 1, running: true, relayWaits: tried?.relayWaits ?? 0 };
|
|
143387
143557
|
depositTries.set(link3.id, attempt);
|
|
143388
143558
|
log(`MCP_DEPOSIT_RESUME requestId=${link3.id}`);
|
|
143559
|
+
const relayClosed = () => {
|
|
143560
|
+
const relay = relayLimitNow();
|
|
143561
|
+
if (!relay || attempt.relayWaits >= DEPOSIT_RELAY_WAITS_MAX) return false;
|
|
143562
|
+
attempt.relayWaits += 1;
|
|
143563
|
+
attempt.tries -= 1;
|
|
143564
|
+
attempt.atMs = relay.opensAtMs + 5e3 - DEPOSIT_RETRY_MS;
|
|
143565
|
+
log(`MCP_DEPOSIT_RESUME_RELAY_LIMIT requestId=${link3.id} opens=${new Date(relay.opensAtMs).toISOString()}`);
|
|
143566
|
+
return true;
|
|
143567
|
+
};
|
|
143389
143568
|
depositPass(link3.id, "runner").then((outcome) => {
|
|
143390
143569
|
const stage = outcome?.stage;
|
|
143391
143570
|
if (stage === "done" || stage === "partly_shielded") return;
|
|
143392
143571
|
const code2 = typeof outcome?.code === "string" ? outcome.code : void 0;
|
|
143572
|
+
if (code2 === "rpc_relay_limit" && relayClosed()) return;
|
|
143393
143573
|
const why = DEPOSIT_HELD_STAGES.has(stage) || stage === "waiting" && PAY_ME_OWNER_CODES.test(code2 ?? "") ? code2 ?? stage : attempt.tries >= DEPOSIT_TRIES_MAX ? `${code2 ?? stage ?? "unknown"} after ${attempt.tries} passes` : void 0;
|
|
143394
143574
|
if (why) holdDeposit(link3.id, why, outcome?.record?.state ?? link3.state);
|
|
143395
143575
|
}, (error) => {
|
|
143576
|
+
if (isRelayLimitError(error) && relayClosed()) return;
|
|
143396
143577
|
const code2 = errorCode4(error, "mcp_add_funds_failed");
|
|
143397
143578
|
log(`MCP_DEPOSIT_RESUME_FAILED requestId=${link3.id} ${code2}`);
|
|
143398
143579
|
if (attempt.tries >= DEPOSIT_TRIES_MAX) holdDeposit(link3.id, `${code2} after ${attempt.tries} passes`, link3.state);
|
|
@@ -143851,7 +144032,7 @@ ${canonical5}`;
|
|
|
143851
144032
|
const finished = stage === "done";
|
|
143852
144033
|
const differs = askedVsArrived(record, stage);
|
|
143853
144034
|
const shown = extra.requestId ?? shownId(record.requestId, record.id);
|
|
143854
|
-
const next = stage === "waiting_for_payment" ? `give the user link and line; after the payer sends, call wallet_pay_me_status with request_id "${shown}"` : finished ? `Tell the user: ${differs ? `${differs.sentence}, and it` : "the payment arrived and"} is now in the private (shielded) balance${outcome.again ? "; the link was paid more than once, so never share a used link" : ""}. wallet_balance shows the new balance. If the user wants another payment, call wallet_pay_me with a NEW request_id` : stage === "partly_shielded" ? `${differs ? `Tell the user: ${differs.sentence}. ` : ""}call wallet_pay_me_status with request_id "${shown}" again now: it shields the rest as the next round` : stage === "over_cap" ? `tell the user what detail says; nothing was shielded and the USDC is safe at the address. Call wallet_pay_me_status with request_id "${shown}" again once the balance has room (after a payment or a wallet_unshield)${outcome.code === "mcp_shield_cap_exceeded" ? `, or tell the user how to raise the shield limit: ${capRaiseText("--max-shield")}` : ""}` : stage === "below_minimum" ? "tell the user what detail says; nothing more to do now. If the payer sends more to the same address, call wallet_pay_me_status again: it all goes in" : stage === "waiting" && PAY_ME_OWNER_CODES.test(String(outcome.code ?? "")) ? "Nothing was moved; the USDC is safe at the address. Do not poll. Tell the user: Shinjuku does not relay this deposit now, so the USDC stays at the address, and the wallet keeps its record" : stage === "paid_not_shielded" ? "Nothing was moved. Tell the user: shielding a pay-me payment needs the wallet's setup files and Shinjuku, which relays the deposit (setup records both), and shielding must not be turned off in this app's wallet entry; run setup again in a terminal, then reconnect the wallet. The USDC stays at the address until then" : stage === "closed" ? `nothing to do now; if USDC is sent to this address later, call wallet_add_funds with request_id "${shown}" and it goes in. For a new address call wallet_add_funds without request_id` : stage === "reclaimed" ? "Tell the user what detail says: this link is finished (its deposit was taken back or closed), so nothing goes in through it; do not send to this address again. Do not poll it. For a new payment call wallet_pay_me with a NEW request_id" : `call wallet_pay_me_status with request_id "${shown}" again in ${POLL_SECONDS2} s`;
|
|
144035
|
+
const next = stage === "waiting_for_payment" ? `give the user link and line; after the payer sends, call wallet_pay_me_status with request_id "${shown}"` : finished ? `Tell the user: ${differs ? `${differs.sentence}, and it` : "the payment arrived and"} is now in the private (shielded) balance${outcome.again ? "; the link was paid more than once, so never share a used link" : ""}. wallet_balance shows the new balance. If the user wants another payment, call wallet_pay_me with a NEW request_id` : stage === "partly_shielded" ? `${differs ? `Tell the user: ${differs.sentence}. ` : ""}call wallet_pay_me_status with request_id "${shown}" again now: it shields the rest as the next round` : stage === "over_cap" ? `tell the user what detail says; nothing was shielded and the USDC is safe at the address. Call wallet_pay_me_status with request_id "${shown}" again once the balance has room (after a payment or a wallet_unshield)${outcome.code === "mcp_shield_cap_exceeded" ? `, or tell the user how to raise the shield limit: ${capRaiseText("--max-shield")}` : ""}` : stage === "below_minimum" ? "tell the user what detail says; nothing more to do now. If the payer sends more to the same address, call wallet_pay_me_status again: it all goes in" : stage === "waiting" && outcome.code === "rpc_relay_limit" ? `Tell the user: ${relayLimitWords(relayLimitNow()) ?? "Shinjuku's free Solana chain reader reached its limit for now."} The deposit keeps its record, so nothing is lost; ask again after that time. Do not poll before then; after that time, call wallet_pay_me_status with request_id "${shown}"` : stage === "waiting" && PAY_ME_OWNER_CODES.test(String(outcome.code ?? "")) ? "Nothing was moved; the USDC is safe at the address. Do not poll. Tell the user: Shinjuku does not relay this deposit now, so the USDC stays at the address, and the wallet keeps its record" : stage === "paid_not_shielded" ? "Nothing was moved. Tell the user: shielding a pay-me payment needs the wallet's setup files and Shinjuku, which relays the deposit (setup records both), and shielding must not be turned off in this app's wallet entry; run setup again in a terminal, then reconnect the wallet. The USDC stays at the address until then" : stage === "closed" ? `nothing to do now; if USDC is sent to this address later, call wallet_add_funds with request_id "${shown}" and it goes in. For a new address call wallet_add_funds without request_id` : stage === "reclaimed" ? "Tell the user what detail says: this link is finished (its deposit was taken back or closed), so nothing goes in through it; do not send to this address again. Do not poll it. For a new payment call wallet_pay_me with a NEW request_id" : `call wallet_pay_me_status with request_id "${shown}" again in ${POLL_SECONDS2} s`;
|
|
143855
144036
|
return json4({
|
|
143856
144037
|
ok: true,
|
|
143857
144038
|
requestId: shown,
|
|
@@ -146083,7 +146264,7 @@ function createSetupTools({
|
|
|
146083
146264
|
doneTool: sayOnRefusal(doneTool)
|
|
146084
146265
|
};
|
|
146085
146266
|
}
|
|
146086
|
-
var import_web3133, X402_V1_NEXT, shownCaps, RELEASE_RETRY_MS, STAGE_WORDS, slowReadWords, stageWords, INTERNAL_BALANCE_DETAIL, shownBreakdown, sessionLeftShown, RESOURCE_PAYMENT_WAL_PREFIX2, POOL_LAYOUT_CODE, POOL_LAYOUT_UPDATE, USEPOD_VIA_INFERENCE_CHAT, SEND_RUNS_ON, DEPOSIT_RUNS_ON, CLI_FUNDS_PLAN_PREFIX, CLI_FUNDS_SCHEMA, SELF_PAY_ORIGIN3, REQUEST_ID4, POSITIVE_ATOMIC6, PRIVATE_HOST3, FORBIDDEN_HEADERS3, MAX_BODY_BYTES2, PREVIEW_TIMEOUT_MS, PREVIEW_SELLER_READ_MS, CALL_BUDGET_MS, budgetLeft, PAY_ANSWER_MARGIN_MS, MONEY_FIRST_ANSWER_MS, BALANCE_AFTER_LANDING_MS, JOIN_CALL_MAX_MS, JOIN_CALL_ANSWER_MARGIN_S, PAY_AFTER_JOIN_MS, joinAnswerSeconds, JOIN_TIME_MS, JOIN_NUDGE_QUIET_MS, JOIN_STEP_MS, sleep2, PROGRESS_EVERY_MS2, READ_BUDGET_MS, UNPAID_TOR_TRY_MS, UNPAID_CLEAR_MS, READ_BUDGET_TOOLS, FLOAT_BUSY_CODES, RETRY_MARGIN_MS, ASK_PAY_CODES, runningNpmVersion, terminalCommand2, capPlaceWords, noLimitSetLine, CAP_NAMES, capName, entryPlaces, capRaiseText, runningLimits, payCapFlag, noPriceFits, cheaperText, limitNext, overLimitStep, SAFE_TEXT, causesLog, MCP_TOOL_ALIASES, POOL_SWITCH_WHY, POOL_SWITCH_NEXT, SWITCH_STATES, quietSwitch, switchKey, ATOMIC_TEXT, MAX_PAYMENT_ATOMIC_LEAST, movedTo, FLOAT_ID2, ANSWERED_EXIT_RETRY_MS, ANSWERED_EXIT_UNCONFIRMED_MS, ANSWERED_EXIT_RETRY_WINDOW_MS, ANSWERED_EXIT_CLOSED, switchAmount, switchEta, switchRows, OWNER_CAP_CODES, JOIN_END_MCP, JOIN_END_TERMINAL_LIBRARY, JOIN_RETRY_BACKOFF_MS, WALLET_CAP_FIX, ENTRY_CAP_CODES, MCP_CAP_FIX, capFix, ownerOnlyNext, mcpNext, CONFIDENTIAL_RETIRED, json4, answerResult, discoverTool, LAUNCH_CAP_CODES, dayCapKind, refuse11, newRequestIdFor, payCapName, limitQuestion, stableJson, requestPrint, publicOffer, FLOAT_PAID_CODES, FLOAT_NOT_CERTAIN_CODES, FLOAT_PRIVATE_LEG, SELLER_ONLY_HERE, outsideWalletRule, TOR_START_STEP, MONEY_ID2, toRecordId, linkKindOf, moneyId, REFUSED_CODES, SEND_STOPPED, SEND_STOP_NOT_SAVED, sendStoppedError, refusedCodeOf, PLAIN_REASONS, insufficientCause, INSUFFICIENT_REASONS, reasonOf, plainReason, KEPT_SEND_TRIES, shownId, isSplitSend, PROMISED_NEXT, partFailReason, sendAnswerOf, PUBLIC_READ_TIMEOUT_MS, RECIPIENT_CHECK_TIMEOUT_MS, withTimeout, ownKey, readFailure, OWN_KEY_TOKENS_MAX, tokenAmountText, elsewhereId, AGENT_ID_SCHEMA, agentIdName, minutesText2, ageWords2, DEPOSIT_SENT_STATES, depositLanded, usdcText3, walkWalletHistory, REFRESH_LEASE_WALK_MS, HOME_MARKS_SETTLED_MS2, AUTO_BACKUPS_KEPT, AUTO_BACKUP_NAME, AUTO_BACKUP_VERIFIED, FRONTED_SETTLE_MARGIN_SLOTS, RECIPIENT_READ_TOTAL_MS, RECIPIENT_READ_SLOW_MS, slowReadSaid, UNSHIELD_WINDOW_YIELD_MS, NOT_FINAL_YET, FINISH_FINALITY_WAIT_MS, FINISH_FINALITY_WAITS, FINISH_FINALITY_RECENT_MS, walkStillCurrent, DIRECT_EXIT_GONE, BALANCE_REFRESH_WAIT_MS, BALANCE_REFRESH_GRACE_MS, BALANCE_REFRESH_LONG_MS, INBOUND_REFRESH_AGE_MS, SALE_VIEW_AGE_SECONDS, saleViewRead, balanceTextFields, changeFields, balanceAnswer, CAP_BALANCE_WAIT_MS, CAP_BALANCE_RETRY_MS, REFRESH_RETRY_MS, FINALITY_POLL_MS, FINALITY_WAIT_MS, FINALITY_REFRESH_LIMIT_MS, FINALITY_CLOSE_WAIT_MS, POOL_WATCH_MS, POOL_WATCH_POLL_MS, EARLY_BALANCE_DELAY_MS, FINALITY_SETTLE_WINDOW_SLOTS, PUBLIC_READ_ANSWER_MS, LINK_READ_ANSWER_MS, OWN_READS_AHEAD_MS, OWN_PUBLIC_KNOWN_MS, FLOAT_CORRECT_WAIT_MS, SWITCH_WAIT_MS, UNSHIELD_TO_NO_USDC_DETAIL, UNSHIELD_TO_INVALID_NEXT, INFERENCE_MIN_MAX_TOKENS, ELICIT_TIMEOUT_MS, ALLOW_BOX_HOSTS, ALLOW_BOX_PROGRESS_MS, ELICIT_UNSHOWN_MS, elicitUnshown, POLL_SECONDS2, TEMP_CLEAN_DELAY_MS, KEPT_ON_DISK, MAX_SHIELDED_BALANCE_ATOMIC, receiveGenerator, MCP_TOOL_NAMES, MCP_HIDDEN_TOOL_NAMES, setupTerminalNext, SETUP_RUNNING_SAY, SETUP_WAITING_SAY, ACCEPTED_NEXT, SETUP_RUNNING_NEXT, SETUP_ANSWER_WAIT_MS, SETUP_CONFIRMING_SAY, SETUP_CONFIRMING_NEXT, OWN_ADDRESS_QUESTION, OWN_ADDRESS_WHERE, OWN_ADDRESS_INVALID, HOST_CHAT_NOT_PRIVATE, PRIVATE_INFERENCE_WHY, RESTART_STEPS, HOST_BLOCKED_LINE, TOR_BROWSER_PORT, SETUP_TOR_TITLE, SETUP_TOR_WHY;
|
|
146267
|
+
var import_web3133, X402_V1_NEXT, shownCaps, RELEASE_RETRY_MS, STAGE_WORDS, slowReadWords, stageWords, INTERNAL_BALANCE_DETAIL, shownBreakdown, sessionLeftShown, RESOURCE_PAYMENT_WAL_PREFIX2, POOL_LAYOUT_CODE, POOL_LAYOUT_UPDATE, USEPOD_VIA_INFERENCE_CHAT, SEND_RUNS_ON, DEPOSIT_RUNS_ON, CLI_FUNDS_PLAN_PREFIX, CLI_FUNDS_SCHEMA, SELF_PAY_ORIGIN3, REQUEST_ID4, POSITIVE_ATOMIC6, PRIVATE_HOST3, FORBIDDEN_HEADERS3, MAX_BODY_BYTES2, PREVIEW_TIMEOUT_MS, PREVIEW_SELLER_READ_MS, CALL_BUDGET_MS, budgetLeft, PAY_ANSWER_MARGIN_MS, MONEY_FIRST_ANSWER_MS, BALANCE_AFTER_LANDING_MS, JOIN_CALL_MAX_MS, JOIN_CALL_ANSWER_MARGIN_S, PAY_AFTER_JOIN_MS, joinAnswerSeconds, JOIN_TIME_MS, JOIN_NUDGE_QUIET_MS, JOIN_STEP_MS, sleep2, PROGRESS_EVERY_MS2, READ_BUDGET_MS, UNPAID_TOR_TRY_MS, UNPAID_CLEAR_MS, READ_BUDGET_TOOLS, FLOAT_BUSY_CODES, RETRY_MARGIN_MS, ASK_PAY_CODES, runningNpmVersion, terminalCommand2, capPlaceWords, noLimitSetLine, CAP_NAMES, capName, entryPlaces, capRaiseText, runningLimits, payCapFlag, noPriceFits, cheaperText, limitNext, overLimitStep, SAFE_TEXT, causesLog, MCP_TOOL_ALIASES, POOL_SWITCH_WHY, POOL_SWITCH_NEXT, SWITCH_STATES, quietSwitch, switchKey, ATOMIC_TEXT, MAX_PAYMENT_ATOMIC_LEAST, movedTo, FLOAT_ID2, ANSWERED_EXIT_RETRY_MS, ANSWERED_EXIT_UNCONFIRMED_MS, ANSWERED_EXIT_RETRY_WINDOW_MS, ANSWERED_EXIT_CLOSED, switchAmount, switchEta, switchRows, OWNER_CAP_CODES, JOIN_END_MCP, JOIN_END_TERMINAL_LIBRARY, JOIN_RETRY_BACKOFF_MS, WALLET_CAP_FIX, ENTRY_CAP_CODES, MCP_CAP_FIX, capFix, ownerOnlyNext, mcpNext, CONFIDENTIAL_RETIRED, json4, answerResult, discoverTool, LAUNCH_CAP_CODES, dayCapKind, refuse11, newRequestIdFor, payCapName, limitQuestion, stableJson, requestPrint, JSON_SNIFF_MAX_CHARS, publicOffer, FLOAT_PAID_CODES, FLOAT_NOT_CERTAIN_CODES, FLOAT_PRIVATE_LEG, SELLER_ONLY_HERE, outsideWalletRule, TOR_START_STEP, MONEY_ID2, toRecordId, linkKindOf, moneyId, REFUSED_CODES, SEND_STOPPED, SEND_STOP_NOT_SAVED, sendStoppedError, refusedCodeOf, PLAIN_REASONS, insufficientCause, INSUFFICIENT_REASONS, reasonOf, plainReason, KEPT_SEND_TRIES, shownId, isSplitSend, PROMISED_NEXT, partFailReason, sendAnswerOf, PUBLIC_READ_TIMEOUT_MS, RECIPIENT_CHECK_TIMEOUT_MS, withTimeout, ownKey, readFailure, OWN_KEY_TOKENS_MAX, tokenAmountText, elsewhereId, AGENT_ID_SCHEMA, agentIdName, minutesText2, ageWords2, DEPOSIT_SENT_STATES, depositLanded, usdcText3, walkWalletHistory, REFRESH_LEASE_WALK_MS, HOME_MARKS_SETTLED_MS2, AUTO_BACKUPS_KEPT, AUTO_BACKUP_NAME, AUTO_BACKUP_VERIFIED, FRONTED_SETTLE_MARGIN_SLOTS, RECIPIENT_READ_TOTAL_MS, RECIPIENT_READ_SLOW_MS, slowReadSaid, UNSHIELD_WINDOW_YIELD_MS, NOT_FINAL_YET, FINISH_FINALITY_WAIT_MS, FINISH_FINALITY_WAITS, FINISH_FINALITY_RECENT_MS, walkStillCurrent, DIRECT_EXIT_GONE, BALANCE_REFRESH_WAIT_MS, BALANCE_REFRESH_GRACE_MS, BALANCE_REFRESH_LONG_MS, INBOUND_REFRESH_AGE_MS, SALE_VIEW_AGE_SECONDS, saleViewRead, balanceTextFields, changeFields, balanceAnswer, CAP_BALANCE_WAIT_MS, CAP_BALANCE_RETRY_MS, REFRESH_RETRY_MS, FINALITY_POLL_MS, FINALITY_WAIT_MS, FINALITY_REFRESH_LIMIT_MS, FINALITY_CLOSE_WAIT_MS, POOL_WATCH_MS, POOL_WATCH_POLL_MS, EARLY_BALANCE_DELAY_MS, FINALITY_SETTLE_WINDOW_SLOTS, PUBLIC_READ_ANSWER_MS, LINK_READ_ANSWER_MS, OWN_READS_AHEAD_MS, OWN_PUBLIC_KNOWN_MS, FLOAT_CORRECT_WAIT_MS, SWITCH_WAIT_MS, UNSHIELD_TO_NO_USDC_DETAIL, UNSHIELD_TO_INVALID_NEXT, INFERENCE_MIN_MAX_TOKENS, ELICIT_TIMEOUT_MS, ALLOW_BOX_HOSTS, ALLOW_BOX_PROGRESS_MS, ELICIT_UNSHOWN_MS, elicitUnshown, POLL_SECONDS2, TEMP_CLEAN_DELAY_MS, KEPT_ON_DISK, MAX_SHIELDED_BALANCE_ATOMIC, receiveGenerator, MCP_TOOL_NAMES, MCP_HIDDEN_TOOL_NAMES, setupTerminalNext, SETUP_RUNNING_SAY, SETUP_WAITING_SAY, ACCEPTED_NEXT, SETUP_RUNNING_NEXT, SETUP_ANSWER_WAIT_MS, SETUP_CONFIRMING_SAY, SETUP_CONFIRMING_NEXT, OWN_ADDRESS_QUESTION, OWN_ADDRESS_WHERE, OWN_ADDRESS_INVALID, HOST_CHAT_NOT_PRIVATE, PRIVATE_INFERENCE_WHY, RESTART_STEPS, HOST_BLOCKED_LINE, TOR_BROWSER_PORT, SETUP_TOR_TITLE, SETUP_TOR_WHY;
|
|
146087
146268
|
var init_tools = __esm({
|
|
146088
146269
|
"wallet/src/mcp/tools.mjs"() {
|
|
146089
146270
|
"use strict";
|
|
@@ -146129,6 +146310,7 @@ var init_tools = __esm({
|
|
|
146129
146310
|
init_store();
|
|
146130
146311
|
init_proxy();
|
|
146131
146312
|
init_facilitatorOnion();
|
|
146313
|
+
init_relayLimit();
|
|
146132
146314
|
init_book();
|
|
146133
146315
|
init_pay();
|
|
146134
146316
|
init_errorLine();
|
|
@@ -146451,6 +146633,7 @@ var init_tools = __esm({
|
|
|
146451
146633
|
return `{${Object.keys(value2).filter((key) => value2[key] !== void 0).sort().map((key) => `${JSON.stringify(key)}:${stableJson(value2[key])}`).join(",")}}`;
|
|
146452
146634
|
};
|
|
146453
146635
|
requestPrint = (value2) => sha256Hex2(Buffer.from(stableJson(value2), "utf8"));
|
|
146636
|
+
JSON_SNIFF_MAX_CHARS = 1048576;
|
|
146454
146637
|
publicOffer = (offer) => ({
|
|
146455
146638
|
scheme: String(offer?.scheme ?? ""),
|
|
146456
146639
|
network: String(offer?.network ?? ""),
|
|
@@ -146848,6 +147031,7 @@ __export(stdioServer_exports, {
|
|
|
146848
147031
|
mcpServerVersion: () => mcpServerVersion,
|
|
146849
147032
|
moneyOptions: () => moneyOptions,
|
|
146850
147033
|
openWalletServer: () => openWalletServer,
|
|
147034
|
+
prebuildHistoryTailLane: () => prebuildHistoryTailLane,
|
|
146851
147035
|
publishedRelease: () => publishedRelease,
|
|
146852
147036
|
runMcp: () => runMcp,
|
|
146853
147037
|
runMcpServer: () => runMcpServer,
|
|
@@ -147290,6 +147474,7 @@ function startOnionKeepWarm({
|
|
|
147290
147474
|
inTor = inTorRun,
|
|
147291
147475
|
onions = routedOnions,
|
|
147292
147476
|
warm = warmOnions,
|
|
147477
|
+
prebuild = prebuildHistoryTailLane,
|
|
147293
147478
|
setIntervalImpl,
|
|
147294
147479
|
setTimeoutImpl = setIntervalImpl ?? setTimeout,
|
|
147295
147480
|
clearTimeoutImpl = clearTimeout
|
|
@@ -147301,12 +147486,21 @@ function startOnionKeepWarm({
|
|
|
147301
147486
|
};
|
|
147302
147487
|
let timer;
|
|
147303
147488
|
let stopped = false;
|
|
147489
|
+
const prebuildNow = () => {
|
|
147490
|
+
try {
|
|
147491
|
+
Promise.resolve(prebuild()).catch(() => {
|
|
147492
|
+
});
|
|
147493
|
+
} catch {
|
|
147494
|
+
}
|
|
147495
|
+
};
|
|
147496
|
+
prebuildNow();
|
|
147304
147497
|
const schedule = () => {
|
|
147305
147498
|
timer = setTimeoutImpl(() => {
|
|
147306
147499
|
clearTimeoutImpl(timer);
|
|
147307
147500
|
if (stopped) return;
|
|
147308
147501
|
abort();
|
|
147309
147502
|
abort = warm({ onions: onions() });
|
|
147503
|
+
prebuildNow();
|
|
147310
147504
|
schedule();
|
|
147311
147505
|
}, low + Math.floor(random2() * (high - low + 1)));
|
|
147312
147506
|
timer?.unref?.();
|
|
@@ -147318,6 +147512,15 @@ function startOnionKeepWarm({
|
|
|
147318
147512
|
abort();
|
|
147319
147513
|
};
|
|
147320
147514
|
}
|
|
147515
|
+
async function prebuildHistoryTailLane({ raced = historyOnionRaced, build: build2 = prebuildTorLane } = {}) {
|
|
147516
|
+
try {
|
|
147517
|
+
const winner = await raced();
|
|
147518
|
+
if (winner === void 0) return false;
|
|
147519
|
+
return await build2(HISTORY_TAIL_LANE, winner);
|
|
147520
|
+
} catch {
|
|
147521
|
+
return false;
|
|
147522
|
+
}
|
|
147523
|
+
}
|
|
147321
147524
|
function startUpdateNotice({ facilitator, log = () => {
|
|
147322
147525
|
}, check = checkWalletUpdate, commandCheck = check === false ? false : olderCommandOnPath } = {}) {
|
|
147323
147526
|
let update3;
|
|
@@ -151690,13 +151893,13 @@ function holdProgressLines(stream = process.stderr) {
|
|
|
151690
151893
|
if (held2.length) original.call(stream, held2.join(""));
|
|
151691
151894
|
};
|
|
151692
151895
|
}
|
|
151693
|
-
function
|
|
151896
|
+
function errorCodeOf2(error) {
|
|
151694
151897
|
if (error?.name === "InferenceError" && typeof error.code === "string") return error.code;
|
|
151695
151898
|
if (error?.name === "SpendRefusalError" && typeof error.error === "string") return error.error;
|
|
151696
151899
|
return localErrorCodes(error)[0];
|
|
151697
151900
|
}
|
|
151698
151901
|
function ownCodeWords(error) {
|
|
151699
|
-
const own =
|
|
151902
|
+
const own = errorCodeOf2(error);
|
|
151700
151903
|
const code2 = own && !/^E[A-Z0-9_]+$/.test(own) ? own : "wallet_command_failed";
|
|
151701
151904
|
return error?.name === "InferenceError" && SELF_TEACHING_CODES.test(code2) && error.detail ? `${code2}: ${error.detail}` : code2;
|
|
151702
151905
|
}
|
|
@@ -152658,7 +152861,7 @@ The next question uses it${state2.mode === "talk" ? ", with the conversation so
|
|
|
152658
152861
|
}
|
|
152659
152862
|
};
|
|
152660
152863
|
const failed = async (error, turn) => {
|
|
152661
|
-
const code2 =
|
|
152864
|
+
const code2 = errorCodeOf2(error);
|
|
152662
152865
|
const surelyNothing = nothingPaid(error);
|
|
152663
152866
|
const paidLeft = [error, error?.cause].map((one) => one?.paidLeft).find((one) => one && typeof one === "object" && typeof one.left === "boolean");
|
|
152664
152867
|
const leftAtomic = paidLeft?.left === true && /^[1-9][0-9]{0,30}$/.test(String(paidLeft.atomic ?? "")) ? BigInt(paidLeft.atomic) : void 0;
|
|
@@ -157384,9 +157587,15 @@ async function runStep(ctx, argv2) {
|
|
|
157384
157587
|
...last ? { last } : {},
|
|
157385
157588
|
code: ok && typeof result.code === "string" ? result.code : void 0,
|
|
157386
157589
|
codes: ok && Array.isArray(result.codes) ? result.codes.filter((code2) => typeof code2 === "string") : [],
|
|
157387
|
-
details: ok && result.details && typeof result.details === "object" ? result.details : {}
|
|
157590
|
+
details: ok && result.details && typeof result.details === "object" ? result.details : {},
|
|
157591
|
+
...ok ? relayLimitOfRun(result.relayLimit) : {}
|
|
157388
157592
|
};
|
|
157389
157593
|
}
|
|
157594
|
+
var RELAY_LIMIT_REASONS = /* @__PURE__ */ new Set(["relay_daily_limit", "relay_hourly_limit", "relay_caller_hourly_limit", "relay_budget_unavailable"]);
|
|
157595
|
+
function relayLimitOfRun(value2) {
|
|
157596
|
+
if (!value2 || !RELAY_LIMIT_REASONS.has(value2.reason) || !Number.isSafeInteger(value2.opensAtMs) || value2.opensAtMs <= 0) return {};
|
|
157597
|
+
return { relayLimit: { reason: value2.reason, opensAtMs: value2.opensAtMs } };
|
|
157598
|
+
}
|
|
157390
157599
|
var advance2 = () => ({ kind: "advance" });
|
|
157391
157600
|
var wait = (ms, waitsFor, extra = {}) => ({ kind: "wait", ms: Math.max(0, ms), waitsFor, ...extra });
|
|
157392
157601
|
var stop = (run2, waitsFor) => ({ kind: "stop", run: run2, waitsFor });
|
|
@@ -157412,6 +157621,11 @@ var RETRY_WORDS = [
|
|
|
157412
157621
|
now: "the deposit is in the pool; the chain does not show the wallet its receipt yet, so it reads again",
|
|
157413
157622
|
waitsFor: "the chain to show the deposit's receipt (the deposit is in the pool)"
|
|
157414
157623
|
}],
|
|
157624
|
+
// Before the not-settled words: the deposit was sent and called final; only its confirmation read was stale (deposit.mjs).
|
|
157625
|
+
[/^p03_deposit_relay_sent_confirmation_unread$/, {
|
|
157626
|
+
now: "the deposit was sent, and the chain does not show the wallet its confirmation yet; nothing is sent again, and the wallet reads again",
|
|
157627
|
+
waitsFor: "the chain to show the sent deposit's confirmation (nothing is sent again)"
|
|
157628
|
+
}],
|
|
157415
157629
|
[/^p03_deposit_relay_not_settled_rerun_same_id$/, {
|
|
157416
157630
|
now: "the server has not moved the deposit into the pool yet, so the wallet asks again",
|
|
157417
157631
|
waitsFor: "the server to move the deposit into the pool"
|
|
@@ -157439,11 +157653,25 @@ function transient(ctx, run2, words2) {
|
|
|
157439
157653
|
const code2 = run2.code ?? run2.codes[0];
|
|
157440
157654
|
return wait(has(run2, SOON_CODES) ? SOON_MS : LATER_MS, words2.waitsFor, { transient: true, said: words2.now, ...code2 ? { code: code2 } : {} });
|
|
157441
157655
|
}
|
|
157656
|
+
function relayLimitWait(ctx, run2) {
|
|
157657
|
+
const now = ctx.now();
|
|
157658
|
+
const reason = run2.relayLimit?.reason ?? "relay_hourly_limit";
|
|
157659
|
+
const hour = new Date(now);
|
|
157660
|
+
const fallback = reason === "relay_budget_unavailable" ? now + 2e4 : reason === "relay_daily_limit" ? Date.UTC(hour.getUTCFullYear(), hour.getUTCMonth(), hour.getUTCDate() + 1) : Date.UTC(hour.getUTCFullYear(), hour.getUTCMonth(), hour.getUTCDate(), hour.getUTCHours() + 1);
|
|
157661
|
+
const opensAtMs = run2.relayLimit && run2.relayLimit.opensAtMs > now && run2.relayLimit.opensAtMs <= now + 864e5 ? run2.relayLimit.opensAtMs : fallback;
|
|
157662
|
+
const clock2 = `${new Date(opensAtMs).toISOString().slice(11, 16)} UTC`;
|
|
157663
|
+
const limit = reason === "relay_daily_limit" ? "its limit for today" : reason === "relay_budget_unavailable" ? "a short pause" : "its limit for this hour";
|
|
157664
|
+
const waitsFor = `Shinjuku's free Solana chain reader to open again at ${clock2} (it reached ${limit} and did not pass the refused request to the Solana network; the deposit keeps its record, and nothing was lost)`;
|
|
157665
|
+
if (opensAtMs - now > RELAY_WAIT_MAX_MS) return { ...stop(run2, waitsFor), relayClosedUntil: clock2 };
|
|
157666
|
+
return wait(opensAtMs - now + 5e3, waitsFor, { code: "rpc_relay_limit" });
|
|
157667
|
+
}
|
|
157668
|
+
var RELAY_WAIT_MAX_MS = 2 * MINUTE2;
|
|
157442
157669
|
function otherwise(ctx, run2) {
|
|
157443
157670
|
if (run2.aborted) return stop(run2, "stopped");
|
|
157444
157671
|
if (run2.stalled) return transient(ctx, run2, STALLED);
|
|
157445
157672
|
if (run2.exit === 2) return stop(run2, "the step's command line was refused");
|
|
157446
157673
|
if (!run2.code && !run2.codes.length) return transient(ctx, run2, NO_CODE);
|
|
157674
|
+
if (has(run2, /^rpc_relay_limit$/)) return relayLimitWait(ctx, run2);
|
|
157447
157675
|
if (has(run2, FACILITATOR_LATER)) {
|
|
157448
157676
|
return wait(LATER_MS, has(run2, /_paused_retry_later$/) ? "Shinjuku's server to take this step again (it is paused right now)" : "Shinjuku's server to have money for the network fee again");
|
|
157449
157677
|
}
|
|
@@ -158055,6 +158283,9 @@ async function addFunds(values, deps) {
|
|
|
158055
158283
|
plan.status = { stage: label, at: iso(deps.now()), stopped: outcome.run?.code ?? outcome.run?.codes?.[0] ?? "refused", waitsFor: outcome.waitsFor, ...said.length ? { said } : {} };
|
|
158056
158284
|
save2();
|
|
158057
158285
|
if (outcome.closed) throw failure("stopped", `${outcome.waitsFor}, and this add-funds run cannot continue. ${stepWords("To add money", "add-funds", `${cli()} add-funds`)}`);
|
|
158286
|
+
if (outcome.relayClosedUntil) {
|
|
158287
|
+
throw failure("stopped", `the ${label} step waits for ${outcome.waitsFor}. There is nothing for you to fix. Run this same add-funds command after ${outcome.relayClosedUntil}: it continues at ${label}`);
|
|
158288
|
+
}
|
|
158058
158289
|
if (outcome.serverFault) {
|
|
158059
158290
|
throw failure("stopped", `the ${label} step stopped on a fault at Shinjuku's server: it refused this deposit's private record. There is nothing for you to fix, and no USDC moved: it is safe at the one-time address. Run this same add-funds command after Shinjuku fixes it: it continues at ${label}`);
|
|
158060
158291
|
}
|
|
@@ -167114,13 +167345,15 @@ function publicDetails(error) {
|
|
|
167114
167345
|
function writeRunResult(deps, command, exit, error, codes = error === void 0 ? [] : localErrorCodes(error)) {
|
|
167115
167346
|
const path = deps.env?.[RESULT_FILE_ENV];
|
|
167116
167347
|
if (!path) return;
|
|
167348
|
+
const relay = codes.includes("rpc_relay_limit") ? relayLimitNow() : void 0;
|
|
167117
167349
|
const result = {
|
|
167118
167350
|
schema: RUN_RESULT_SCHEMA,
|
|
167119
167351
|
command: command?.name ?? null,
|
|
167120
167352
|
exit,
|
|
167121
167353
|
...codes.length ? { code: codes[0], codes } : {},
|
|
167122
167354
|
// Only named public numbers, by shape (DETAIL_SHAPES), never a raw object.
|
|
167123
|
-
...error === void 0 ? {} : { details: publicDetails(error) }
|
|
167355
|
+
...error === void 0 ? {} : { details: publicDetails(error) },
|
|
167356
|
+
...relay ? { relayLimit: { reason: relay.reason, opensAtMs: relay.opensAtMs } } : {}
|
|
167124
167357
|
};
|
|
167125
167358
|
try {
|
|
167126
167359
|
writeFileSync(path, JSON.stringify(result), { flag: "wx", mode: 384 });
|