shinjuku-shielded 0.3.72 → 0.3.73
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/manifest.json +4 -4
- package/package.json +3 -3
- package/shinjuku-wallet.mjs +216 -27
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": "ff6f25bccfd2a50929a8dc82137b4fb42172790f9d71a6c07f166bda3e052d22",
|
|
5
|
+
"bytes": 12210958,
|
|
6
|
+
"sourceCommit": "0e33e750c294c38e85c041b105e87cf864edd5db",
|
|
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",
|
|
@@ -1282,5 +1282,5 @@
|
|
|
1282
1282
|
"version": "1.8.0"
|
|
1283
1283
|
}
|
|
1284
1284
|
],
|
|
1285
|
-
"publishedAt": "2026-10-
|
|
1285
|
+
"publishedAt": "2026-10-22T18:10:20.059Z"
|
|
1286
1286
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shielded",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.73",
|
|
4
4
|
"mcpName": "io.github.ShinjukuStaition/shinjuku-mcp",
|
|
5
5
|
"description": "Shinjuku Shielded, the private x402 facilitator 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": "ff6f25bc",
|
|
7
|
+
"shinjukuSha256": "ff6f25bccfd2a50929a8dc82137b4fb42172790f9d71a6c07f166bda3e052d22",
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"author": "Shinjuku Shielded",
|
|
10
10
|
"homepage": "https://github.com/ShinjukuStaition/shinjuku-mcp#readme",
|
package/shinjuku-wallet.mjs
CHANGED
|
@@ -57150,6 +57150,16 @@ function rewriteFoldRoots(pool2, cache, next) {
|
|
|
57150
57150
|
})().catch(() => {
|
|
57151
57151
|
});
|
|
57152
57152
|
}
|
|
57153
|
+
function dropCompactCacheRecords(pool2, cache) {
|
|
57154
|
+
if (cache === void 0 || cache === null) return Promise.resolve();
|
|
57155
|
+
return (async () => {
|
|
57156
|
+
const current = await cache.load();
|
|
57157
|
+
if (!current || current.pool !== pool2) return;
|
|
57158
|
+
const { foldRoots, savedAt, served, ...rest } = current;
|
|
57159
|
+
await cache.save({ ...rest, served: servedWithoutRecords(served) }, { savedAt });
|
|
57160
|
+
})().catch(() => {
|
|
57161
|
+
});
|
|
57162
|
+
}
|
|
57153
57163
|
function markFoldRootsVerified(pool2, cache) {
|
|
57154
57164
|
rewriteFoldRoots(pool2, cache, (foldRoots) => {
|
|
57155
57165
|
const hashed = lastFolds.get(pool2);
|
|
@@ -57224,12 +57234,12 @@ function canonicalAddress(value, label) {
|
|
|
57224
57234
|
}
|
|
57225
57235
|
throw refuse3("p03_compact_history_record_invalid");
|
|
57226
57236
|
}
|
|
57227
|
-
function validateImport(raw, from) {
|
|
57237
|
+
function validateImport(raw, from, size = P03_COMPACT_PAGE) {
|
|
57228
57238
|
const invalid5 = () => refuse3("p03_compact_history_source_answer_invalid");
|
|
57229
57239
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw) || Object.keys(raw).sort().join(",") !== IMPORT_KEYS.join(",")) throw invalid5();
|
|
57230
57240
|
const { afterOrdinal, record, values, signature: signature2, slot: slot3, transactionIndex, instructionIndex } = raw;
|
|
57231
57241
|
if (!isIndex(afterOrdinal) || !isSignature(signature2) || !isIndex(slot3) || !isIndex(transactionIndex) || !isIndex(instructionIndex)) throw invalid5();
|
|
57232
|
-
if (from !== void 0 && !(afterOrdinal > from && afterOrdinal <= from +
|
|
57242
|
+
if (from !== void 0 && !(afterOrdinal > from && afterOrdinal <= from + size || from === 0 && afterOrdinal === 0)) {
|
|
57233
57243
|
throw invalid5();
|
|
57234
57244
|
}
|
|
57235
57245
|
if (!Array.isArray(values) || values.length > IMPORT_MAX_VALUES) throw invalid5();
|
|
@@ -57509,8 +57519,70 @@ function requestCompactFirstPage({ history, pool: pool2, signal }) {
|
|
|
57509
57519
|
return Promise.resolve({ error });
|
|
57510
57520
|
}
|
|
57511
57521
|
}
|
|
57512
|
-
function pageShapeValid(result, pool2, from) {
|
|
57513
|
-
return Boolean(result) && typeof result === "object" && result.pool === pool2 && result.fromOrdinal === from && isIndex(result.total) && isIndex(result.syncedSlot) && Array.isArray(result.records) && result.records.length === Math.max(0, Math.min(result.total, from +
|
|
57522
|
+
function pageShapeValid(result, pool2, from, size = P03_COMPACT_PAGE) {
|
|
57523
|
+
return Boolean(result) && typeof result === "object" && result.pool === pool2 && result.fromOrdinal === from && isIndex(result.total) && isIndex(result.syncedSlot) && Array.isArray(result.records) && result.records.length === Math.max(0, Math.min(result.total, from + size) - from) && Boolean(result.initialization) && isSignature(result.initialization.signature) && isIndex(result.initialization.slot);
|
|
57524
|
+
}
|
|
57525
|
+
function requestTailPage(history, pool2, from, grid) {
|
|
57526
|
+
return Promise.resolve().then(() => history._rpcRequest("getP03Transitions", [pool2, { commitment: "finalized", fromOrdinal: from, toOrdinal: from + grid }])).then((response) => ({ response }), (error) => ({ error }));
|
|
57527
|
+
}
|
|
57528
|
+
function requestCompactTailPage({ history, pool: pool2, currentIndex }) {
|
|
57529
|
+
try {
|
|
57530
|
+
const count2 = Number(BigInt(currentIndex) / SUBTREE_LEAVES3);
|
|
57531
|
+
if (!Number.isSafeInteger(count2) || count2 === 0) return Promise.resolve({ error: new Error("no records") });
|
|
57532
|
+
const source = typeof history === "string" ? connect2(history, "finalized", { timeoutMs: HISTORY_RPC_REQUEST_TIMEOUT_MS }) : history;
|
|
57533
|
+
if (!source || typeof source._rpcRequest !== "function") return Promise.resolve({ error: refuse3("p03_compact_history_connection_invalid") });
|
|
57534
|
+
return requestTailPage(source, new import_web397.PublicKey(pool2).toBase58(), tailFrom(count2, P03_COMPACT_TAIL_GRID), P03_COMPACT_TAIL_GRID);
|
|
57535
|
+
} catch (error) {
|
|
57536
|
+
return Promise.resolve({ error });
|
|
57537
|
+
}
|
|
57538
|
+
}
|
|
57539
|
+
function combineCompactTail(prefix, answer, { pool: pool2, from, count: count2, grid }) {
|
|
57540
|
+
if (answer.error !== void 0) return { miss: "fetch-failed" };
|
|
57541
|
+
const { response } = answer;
|
|
57542
|
+
if (response === null || typeof response !== "object" || "error" in response) return { miss: "fetch-failed" };
|
|
57543
|
+
const result = response.result;
|
|
57544
|
+
if (!pageShapeValid(result, pool2, from, grid)) return { miss: "shape-invalid" };
|
|
57545
|
+
if (result.total < count2) return { miss: "behind" };
|
|
57546
|
+
if (result.initialization.signature !== prefix.initialization.signature || result.initialization.slot !== prefix.initialization.slot) {
|
|
57547
|
+
return { miss: "init-mismatch" };
|
|
57548
|
+
}
|
|
57549
|
+
if (isIndex(prefix.syncedSlot) && result.syncedSlot < prefix.syncedSlot) return { miss: "synced-older" };
|
|
57550
|
+
let tailImports = [];
|
|
57551
|
+
if (result.imports !== void 0) {
|
|
57552
|
+
if (!Array.isArray(result.imports)) return { miss: "import-invalid" };
|
|
57553
|
+
try {
|
|
57554
|
+
for (const entry of result.imports) validateImport(entry, from, grid);
|
|
57555
|
+
} catch {
|
|
57556
|
+
return { miss: "import-invalid" };
|
|
57557
|
+
}
|
|
57558
|
+
tailImports = result.imports;
|
|
57559
|
+
}
|
|
57560
|
+
const cachedImports = Array.isArray(prefix.imports) ? prefix.imports : [];
|
|
57561
|
+
const held = Math.min(prefix.records.length, count2);
|
|
57562
|
+
for (let ordinal = from; ordinal < held; ordinal += 1) {
|
|
57563
|
+
if (!sameJson(prefix.records[ordinal], result.records[ordinal - from])) return { miss: "overlap-mismatch" };
|
|
57564
|
+
}
|
|
57565
|
+
const between = (entry) => entry?.afterOrdinal > from && entry.afterOrdinal < held;
|
|
57566
|
+
if (!sameJson(cachedImports.filter(between), tailImports.filter(between))) return { miss: "overlap-mismatch" };
|
|
57567
|
+
return { page: {
|
|
57568
|
+
records: [...prefix.records.slice(0, from), ...result.records.slice(0, count2 - from)],
|
|
57569
|
+
imports: [...from === 0 ? [] : cachedImports.filter((entry) => entry?.afterOrdinal <= from), ...tailImports],
|
|
57570
|
+
initialization: result.initialization,
|
|
57571
|
+
syncedSlot: result.syncedSlot
|
|
57572
|
+
} };
|
|
57573
|
+
}
|
|
57574
|
+
function comparePageZero(first, prefix, { pool: pool2, from }) {
|
|
57575
|
+
return first.then((answer) => {
|
|
57576
|
+
const result = answer?.response?.result;
|
|
57577
|
+
if (answer?.error !== void 0 || !pageShapeValid(result, pool2, 0)) return "unavailable";
|
|
57578
|
+
const upTo = Math.min(from, result.records.length);
|
|
57579
|
+
for (let ordinal = 0; ordinal < upTo; ordinal += 1) {
|
|
57580
|
+
if (!sameJson(prefix.records[ordinal], result.records[ordinal])) return "mismatch";
|
|
57581
|
+
}
|
|
57582
|
+
const reach = result.total > upTo ? upTo : upTo - 1;
|
|
57583
|
+
const imports = (list) => (Array.isArray(list) ? list : []).filter((entry) => entry?.afterOrdinal <= reach);
|
|
57584
|
+
return sameJson(imports(prefix.imports), imports(result.imports)) ? "match" : "mismatch";
|
|
57585
|
+
}, () => "unavailable");
|
|
57514
57586
|
}
|
|
57515
57587
|
function isCompactPageZeroAnswer(response, pool2) {
|
|
57516
57588
|
if (response === null || typeof response !== "object" || "error" in response) return false;
|
|
@@ -57882,7 +57954,19 @@ async function readCompactP03HistoryNow({
|
|
|
57882
57954
|
// check: they are NOT verified yet. A payment asks the memo service for their memos here
|
|
57883
57955
|
// (payAndFetch.mjs), and uses an answer only for a context the verified report names. Its
|
|
57884
57956
|
// result and any throw are ignored.
|
|
57885
|
-
onList
|
|
57957
|
+
onList,
|
|
57958
|
+
// compactP03HistoryReport: the records of a compact cache that is not warm (cached.served). When the
|
|
57959
|
+
// list is read (no knownSnapshot), these records (or `served`'s, when the pool outgrew them) that pass
|
|
57960
|
+
// the start of the pool's last grid page take that page instead of every page (3b, combineCompactTail);
|
|
57961
|
+
// page 0 still goes out and is read to its end.
|
|
57962
|
+
prefix,
|
|
57963
|
+
// The tail page's size; P03_COMPACT_TAIL_GRID outside tests.
|
|
57964
|
+
tailGrid = P03_COMPACT_TAIL_GRID,
|
|
57965
|
+
// false: no tail request (compactP03HistoryReport's read again after a refused tail hit; it sent its tail already).
|
|
57966
|
+
tail = true,
|
|
57967
|
+
// compactP03HistoryReport: called on a tail hit with { first (page 0's answer promise), snapshot (the pool
|
|
57968
|
+
// account read) }, so a refused list can be read again from that same page 0 and pool read.
|
|
57969
|
+
onTailHit
|
|
57886
57970
|
}) {
|
|
57887
57971
|
const program = new import_web397.PublicKey(programId);
|
|
57888
57972
|
const poolKey = new import_web397.PublicKey(pool2);
|
|
@@ -57915,18 +57999,57 @@ async function readCompactP03HistoryNow({
|
|
|
57915
57999
|
const count2 = Number(snapshot.currentIndex / SUBTREE_LEAVES3);
|
|
57916
58000
|
if (!Number.isSafeInteger(count2)) throw refuse3("p03_compact_history_snapshot_invalid");
|
|
57917
58001
|
const anchors = freezeFinalizedAnchors(snapshot);
|
|
57918
|
-
const readServedPages = () => {
|
|
58002
|
+
const readServedPages = (zero = first) => {
|
|
57919
58003
|
if (reusedFirst !== void 0) markPhase("compact-behind-page0-reused");
|
|
57920
58004
|
if (first === void 0 && preFirst !== void 0) markPhase("compact-page0-handed-over");
|
|
57921
|
-
return readPages(source, poolString, count2,
|
|
58005
|
+
return readPages(source, poolString, count2, zero ?? preFirst, { wakeSlot: snapshot.slot });
|
|
58006
|
+
};
|
|
58007
|
+
let prefixCheck;
|
|
58008
|
+
const readTailOrPages = async () => {
|
|
58009
|
+
if (knownSnapshot !== void 0 || !tail) return readServedPages();
|
|
58010
|
+
const zero = first ?? preFirst ?? requestPage(source, poolString, 0);
|
|
58011
|
+
if (first === void 0 && preFirst === void 0) markPhase("compact-page0-sent");
|
|
58012
|
+
const from = tailFrom(count2, tailGrid);
|
|
58013
|
+
const tailRead = requestTailPage(source, poolString, from, tailGrid);
|
|
58014
|
+
markPhase("compact-tail-sent");
|
|
58015
|
+
const cachedRecords = served ?? prefix;
|
|
58016
|
+
if (!Array.isArray(cachedRecords?.records) || !cachedRecords.initialization) {
|
|
58017
|
+
markPhase("compact-tail-miss-no-cache");
|
|
58018
|
+
return readServedPages(zero);
|
|
58019
|
+
}
|
|
58020
|
+
if (cachedRecords.records.length <= from) {
|
|
58021
|
+
markPhase("compact-tail-miss-k-not-above-from");
|
|
58022
|
+
return readServedPages(zero);
|
|
58023
|
+
}
|
|
58024
|
+
if (await Promise.race([zero.then((answer) => answer.error === void 0), tailRead.then(() => false)])) {
|
|
58025
|
+
markPhase("compact-tail-miss-page0-first");
|
|
58026
|
+
return readServedPages(zero);
|
|
58027
|
+
}
|
|
58028
|
+
const combined = combineCompactTail(cachedRecords, await tailRead, { pool: poolString, from, count: count2, grid: tailGrid });
|
|
58029
|
+
if (combined.miss !== void 0) {
|
|
58030
|
+
markPhase(`compact-tail-miss-${combined.miss}`);
|
|
58031
|
+
return readServedPages(zero);
|
|
58032
|
+
}
|
|
58033
|
+
markPhase("compact-tail-hit");
|
|
58034
|
+
prefixCheck = comparePageZero(zero, cachedRecords, { pool: poolString, from });
|
|
58035
|
+
try {
|
|
58036
|
+
onTailHit?.({ first: zero, snapshot, check: prefixCheck });
|
|
58037
|
+
} catch {
|
|
58038
|
+
}
|
|
58039
|
+
return combined.page;
|
|
57922
58040
|
};
|
|
57923
|
-
const
|
|
58041
|
+
const servedReaches = count2 > 0 && served !== void 0 && Array.isArray(served.records) && served.records.length >= count2 && Boolean(served.initialization);
|
|
58042
|
+
if (servedReaches && knownSnapshot === void 0 && tail && (first !== void 0 || preFirst !== void 0)) {
|
|
58043
|
+
requestTailPage(source, poolString, tailFrom(count2, tailGrid), tailGrid);
|
|
58044
|
+
markPhase("compact-tail-sent-unused");
|
|
58045
|
+
}
|
|
58046
|
+
const page = count2 === 0 ? { records: [], imports: [], initialization: void 0, syncedSlot: void 0 } : servedReaches ? {
|
|
57924
58047
|
records: served.records.slice(0, count2),
|
|
57925
58048
|
imports: Array.isArray(served.imports) ? served.imports : [],
|
|
57926
58049
|
initialization: served.initialization,
|
|
57927
58050
|
syncedSlot: served.syncedSlot,
|
|
57928
58051
|
cached: true
|
|
57929
|
-
} : await
|
|
58052
|
+
} : await readTailOrPages().catch((error) => {
|
|
57930
58053
|
if (error?.compactHistoryRefusal === "p03_compact_history_source_behind") error.behindSnapshot = snapshot;
|
|
57931
58054
|
throw error;
|
|
57932
58055
|
});
|
|
@@ -58085,7 +58208,9 @@ async function readCompactP03HistoryNow({
|
|
|
58085
58208
|
...page.imports.length > 0 ? { imports: page.imports } : {},
|
|
58086
58209
|
initialization: page.initialization,
|
|
58087
58210
|
syncedSlot: page.syncedSlot
|
|
58088
|
-
})
|
|
58211
|
+
}),
|
|
58212
|
+
// 3b, a tail hit only: resolves "match", "mismatch" or "unavailable" when page 0 has come in full (comparePageZero).
|
|
58213
|
+
...prefixCheck !== void 0 ? { prefixCheck } : {}
|
|
58089
58214
|
});
|
|
58090
58215
|
}
|
|
58091
58216
|
function refusalReason(error) {
|
|
@@ -58116,7 +58241,8 @@ async function compactP03HistoryReportRun({
|
|
|
58116
58241
|
knownFirst,
|
|
58117
58242
|
poolPreRead,
|
|
58118
58243
|
firstPreRead,
|
|
58119
|
-
onList
|
|
58244
|
+
onList,
|
|
58245
|
+
tailGrid
|
|
58120
58246
|
}) {
|
|
58121
58247
|
if (deploymentIdentity === void 0) throw new Error("p03_history_deployment_identity_required");
|
|
58122
58248
|
const program = new import_web397.PublicKey(programId);
|
|
@@ -58189,7 +58315,7 @@ async function compactP03HistoryReportRun({
|
|
|
58189
58315
|
};
|
|
58190
58316
|
const preFold = cached ? startCompactPreFold(poolKey.toBase58(), cached) : void 0;
|
|
58191
58317
|
const e1Ahead = cached ? startCompactE1Candidate(program.toBase58(), poolKey.toBase58(), cached, preFold) : void 0;
|
|
58192
|
-
const
|
|
58318
|
+
const readOnce = (extra) => readCompactP03History({
|
|
58193
58319
|
history,
|
|
58194
58320
|
own: connection,
|
|
58195
58321
|
programId,
|
|
@@ -58203,8 +58329,48 @@ async function compactP03HistoryReportRun({
|
|
|
58203
58329
|
...firstPreRead !== void 0 ? { firstPreRead } : {},
|
|
58204
58330
|
...onList !== void 0 ? { onList } : {},
|
|
58205
58331
|
...warm ? { served: cached.served } : {},
|
|
58206
|
-
...cached ? { initialization: cached.initialization } : {}
|
|
58332
|
+
...cached ? { initialization: cached.initialization } : {},
|
|
58333
|
+
...tailGrid !== void 0 ? { tailGrid } : {},
|
|
58334
|
+
...extra
|
|
58335
|
+
});
|
|
58336
|
+
let pageZeroMismatch = false;
|
|
58337
|
+
let readAgain = false;
|
|
58338
|
+
let replaced = false;
|
|
58339
|
+
let saving;
|
|
58340
|
+
let dropping;
|
|
58341
|
+
const watchPageZero = (check) => check.then((result) => {
|
|
58342
|
+
markPhase(`compact-page0-compare-${result}`);
|
|
58343
|
+
if (result !== "mismatch") return;
|
|
58344
|
+
try {
|
|
58345
|
+
process.stderr.write("history: WARNING the history source's page 0 differs from this wallet's cached records before the pool's last page; the cache's records are replaced or dropped so the next read takes every page\n");
|
|
58346
|
+
} catch {
|
|
58347
|
+
}
|
|
58348
|
+
pageZeroMismatch = true;
|
|
58349
|
+
if (replaced) return;
|
|
58350
|
+
if (!readAgain) lastFolds.delete(poolKey.toBase58());
|
|
58351
|
+
const drop = () => replaced ? void 0 : dropCompactCacheRecords(poolKey.toBase58(), cache);
|
|
58352
|
+
dropping = (saving ?? Promise.resolve()).then(drop, drop);
|
|
58353
|
+
}).catch(() => {
|
|
58207
58354
|
});
|
|
58355
|
+
let tailHit;
|
|
58356
|
+
let compact;
|
|
58357
|
+
try {
|
|
58358
|
+
compact = await readOnce(cached ? { ...warm ? {} : { prefix: cached.served }, onTailHit: (hit) => {
|
|
58359
|
+
tailHit = hit;
|
|
58360
|
+
watchPageZero(hit.check);
|
|
58361
|
+
} } : {});
|
|
58362
|
+
} catch (error) {
|
|
58363
|
+
if (tailHit === void 0 || !TAIL_RETRY_REFUSALS.has(error?.compactHistoryRefusal)) throw error;
|
|
58364
|
+
markPhase("compact-tail-refused-page0");
|
|
58365
|
+
readAgain = true;
|
|
58366
|
+
lastFolds.delete(poolKey.toBase58());
|
|
58367
|
+
try {
|
|
58368
|
+
process.stderr.write(`history: WARNING this wallet's cached records with the pool's last page failed a check (${error.compactHistoryRefusal}); reading every page again
|
|
58369
|
+
`);
|
|
58370
|
+
} catch {
|
|
58371
|
+
}
|
|
58372
|
+
compact = await readOnce({ firstPreRead: tailHit.first, poolPreRead: Promise.resolve(tailHit.snapshot), tail: false });
|
|
58373
|
+
}
|
|
58208
58374
|
const initialization = compact.verifiedInitialization;
|
|
58209
58375
|
if (initialization === void 0) throw refuse3("p03_compact_history_pool_empty");
|
|
58210
58376
|
const snapshot = compact.poolSnapshot;
|
|
@@ -58267,8 +58433,9 @@ async function compactP03HistoryReportRun({
|
|
|
58267
58433
|
});
|
|
58268
58434
|
}
|
|
58269
58435
|
if (cache) {
|
|
58436
|
+
if (dropping !== void 0) await dropping;
|
|
58270
58437
|
try {
|
|
58271
|
-
await cache.save({
|
|
58438
|
+
await (saving = Promise.resolve().then(() => cache.save({
|
|
58272
58439
|
programId: program.toBase58(),
|
|
58273
58440
|
pool: poolKey.toBase58(),
|
|
58274
58441
|
snapshot: {
|
|
@@ -58280,10 +58447,12 @@ async function compactP03HistoryReportRun({
|
|
|
58280
58447
|
// pre-fold hashes their roots ahead. Counts only: every root is checked live again.
|
|
58281
58448
|
anchorCounts: [...new Set(compact.finalizedPoolSnapshot.anchors.map((anchor) => Number(anchor.index / SUBTREE_LEAVES3)))]
|
|
58282
58449
|
},
|
|
58283
|
-
served: compact.served,
|
|
58450
|
+
served: pageZeroMismatch && !readAgain ? servedWithoutRecords(compact.served) : compact.served,
|
|
58284
58451
|
initialization,
|
|
58285
58452
|
attestation: attested.attestation
|
|
58286
|
-
})
|
|
58453
|
+
})).then(() => {
|
|
58454
|
+
if (readAgain) replaced = true;
|
|
58455
|
+
}));
|
|
58287
58456
|
} catch {
|
|
58288
58457
|
}
|
|
58289
58458
|
}
|
|
@@ -58304,7 +58473,7 @@ async function tryCompactP03HistoryReport(options) {
|
|
|
58304
58473
|
return { ok: false, reason, ...detail ? { detail } : {}, error };
|
|
58305
58474
|
}
|
|
58306
58475
|
}
|
|
58307
|
-
var import_web397, 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_PREFIX2, VERSION_1_PREFIX2, HEX64, BASE58, REPLAY_STORE_INDEXED2, PROFILES2, MOVE_HEAD_BYTES2, MOVE_INSERTED_VALUES2, refuse3, hash4, bitAt, zeroRootsMemo, lastFolds, PRE_FOLD_SLICE_MS, preFolds, hex64, droppedPools, verifyQuietMs, VERIFY_SLICE_MS, VERIFY_POLL_MS, verifying, unrefTurn, isSignature, isIndex, IMPORT_KEYS, IMPORT_MAX_VALUES, LIST_ATTEMPTS, pageZeroInFlight, OWN_READ_TIMEOUT_MS, BOUNDED_OWN_METHODS, SPOT_HEDGE_AFTER_MS, SPOT_HEDGE_LANE, spotReadId, POOL_HEDGE_AFTER_MS, POOL_HEDGE_LANE, poolReadId, compactReportsRunning, compactHistoryReadsRunning;
|
|
58476
|
+
var import_web397, 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_PREFIX2, VERSION_1_PREFIX2, HEX64, BASE58, REPLAY_STORE_INDEXED2, PROFILES2, MOVE_HEAD_BYTES2, MOVE_INSERTED_VALUES2, refuse3, hash4, bitAt, zeroRootsMemo, lastFolds, PRE_FOLD_SLICE_MS, preFolds, hex64, droppedPools, servedWithoutRecords, verifyQuietMs, VERIFY_SLICE_MS, VERIFY_POLL_MS, verifying, unrefTurn, isSignature, isIndex, IMPORT_KEYS, IMPORT_MAX_VALUES, LIST_ATTEMPTS, pageZeroInFlight, OWN_READ_TIMEOUT_MS, BOUNDED_OWN_METHODS, P03_COMPACT_TAIL_GRID, TAIL_RETRY_REFUSALS, tailFrom, sameJson, SPOT_HEDGE_AFTER_MS, SPOT_HEDGE_LANE, spotReadId, POOL_HEDGE_AFTER_MS, POOL_HEDGE_LANE, poolReadId, compactReportsRunning, compactHistoryReadsRunning;
|
|
58308
58477
|
var init_compact = __esm({
|
|
58309
58478
|
"wallet/src/history/compact.mjs"() {
|
|
58310
58479
|
"use strict";
|
|
@@ -58421,6 +58590,11 @@ var init_compact = __esm({
|
|
|
58421
58590
|
preFolds = /* @__PURE__ */ new Map();
|
|
58422
58591
|
hex64 = (value) => value.toString(16).padStart(64, "0");
|
|
58423
58592
|
droppedPools = /* @__PURE__ */ new Set();
|
|
58593
|
+
servedWithoutRecords = (served) => ({
|
|
58594
|
+
records: [],
|
|
58595
|
+
initialization: served.initialization,
|
|
58596
|
+
...served.syncedSlot !== void 0 ? { syncedSlot: served.syncedSlot } : {}
|
|
58597
|
+
});
|
|
58424
58598
|
verifyQuietMs = 3e3;
|
|
58425
58599
|
VERIFY_SLICE_MS = 20;
|
|
58426
58600
|
VERIFY_POLL_MS = 250;
|
|
@@ -58437,6 +58611,17 @@ var init_compact = __esm({
|
|
|
58437
58611
|
pageZeroInFlight = /* @__PURE__ */ new Map();
|
|
58438
58612
|
OWN_READ_TIMEOUT_MS = HISTORY_RPC_REQUEST_TIMEOUT_MS;
|
|
58439
58613
|
BOUNDED_OWN_METHODS = /* @__PURE__ */ new Set(["getAccountInfo", "getAccountInfoAndContext", "getMultipleAccountsInfo", "getMultipleAccountsInfoAndContext"]);
|
|
58614
|
+
P03_COMPACT_TAIL_GRID = 512;
|
|
58615
|
+
TAIL_RETRY_REFUSALS = /* @__PURE__ */ new Set([
|
|
58616
|
+
"p03_compact_history_root_mismatch",
|
|
58617
|
+
"p03_compact_history_kind_count_mismatch",
|
|
58618
|
+
"p03_compact_history_record_order_invalid",
|
|
58619
|
+
"p03_compact_history_record_invalid",
|
|
58620
|
+
"p03_compact_history_record_after_snapshot",
|
|
58621
|
+
"p03_compact_history_source_answer_invalid"
|
|
58622
|
+
]);
|
|
58623
|
+
tailFrom = (count2, grid) => Math.floor((count2 - 1) / grid) * grid;
|
|
58624
|
+
sameJson = (left, right) => JSON.stringify(left) === JSON.stringify(right);
|
|
58440
58625
|
SPOT_HEDGE_AFTER_MS = 4e3;
|
|
58441
58626
|
SPOT_HEDGE_LANE = "spot-hedge";
|
|
58442
58627
|
spotReadId = 0;
|
|
@@ -59241,7 +59426,7 @@ async function walkWalletP03HistoryNow({ store, connection: given, programId, po
|
|
|
59241
59426
|
} else if (earlier !== void 0) {
|
|
59242
59427
|
markPhase("refresh-start");
|
|
59243
59428
|
let slicedPreRead;
|
|
59244
|
-
let
|
|
59429
|
+
let page0Asked = false;
|
|
59245
59430
|
let page0Answered = false;
|
|
59246
59431
|
if (compactNext) {
|
|
59247
59432
|
const started = startCompactPoolSnapshot({ connection, programId, pool: pool2 });
|
|
@@ -59249,8 +59434,8 @@ async function walkWalletP03HistoryNow({ store, connection: given, programId, po
|
|
|
59249
59434
|
poolPreRead = started.full;
|
|
59250
59435
|
markPhase("compact-pool-prestarted");
|
|
59251
59436
|
if (inTorRun() || Date.now() - remembered.at > PAGE0_PREREAD_AFTER_MS) {
|
|
59252
|
-
|
|
59253
|
-
firstPreRead = requestCompactFirstPage({ history: connection.historyRpcSource, pool: pool2
|
|
59437
|
+
page0Asked = true;
|
|
59438
|
+
firstPreRead = requestCompactFirstPage({ history: connection.historyRpcSource, pool: pool2 });
|
|
59254
59439
|
firstPreRead.then(() => {
|
|
59255
59440
|
page0Answered = true;
|
|
59256
59441
|
});
|
|
@@ -59279,9 +59464,13 @@ async function walkWalletP03HistoryNow({ store, connection: given, programId, po
|
|
|
59279
59464
|
try {
|
|
59280
59465
|
const refreshed = await refreshing;
|
|
59281
59466
|
markPhase("walk-refreshed");
|
|
59282
|
-
if (
|
|
59283
|
-
markPhase(page0Answered ? "compact-page0-answered-before-hit" : "compact-page0-
|
|
59284
|
-
|
|
59467
|
+
if (page0Asked) {
|
|
59468
|
+
markPhase(page0Answered ? "compact-page0-answered-before-hit" : "compact-page0-read-on-after-hit");
|
|
59469
|
+
const currentIndex = refreshed?.finalizedPoolSnapshot?.currentIndex;
|
|
59470
|
+
if (typeof currentIndex === "bigint" && currentIndex > 0n) {
|
|
59471
|
+
requestCompactTailPage({ history: connection.historyRpcSource, pool: pool2, currentIndex });
|
|
59472
|
+
markPhase("compact-tail-sent-on-hit");
|
|
59473
|
+
}
|
|
59285
59474
|
}
|
|
59286
59475
|
rememberRunReport(runKey, refreshed);
|
|
59287
59476
|
writeStderr("history: the pool made no transition since this run's last walk; that history was moved to the current pool account " + (fromSliced ? "(your own RPC read the pool account and the program's deployment account in one request)\n" : "(your own RPC read the pool account and the program's deployment account; the history source answered one signature read)\n"));
|
|
@@ -103892,7 +104081,7 @@ function hostConfigText({ home, env = process.env, platform = process.platform }
|
|
|
103892
104081
|
function isOlderSetupEntry(existing, entry) {
|
|
103893
104082
|
if (!isPlainObject3(existing) || entry.command !== "npx" || !Array.isArray(entry.args)) return false;
|
|
103894
104083
|
const older = { ...entry, args: entry.args.filter((arg) => !NPX_INSTALL_FLAGS.includes(arg)) };
|
|
103895
|
-
return older.args.length !== entry.args.length &&
|
|
104084
|
+
return older.args.length !== entry.args.length && sameJson2(existing, older);
|
|
103896
104085
|
}
|
|
103897
104086
|
function restrictToOwnerWindows(file, { run: run5 = execFileSync2 } = {}) {
|
|
103898
104087
|
const system32 = join18(process.env.SystemRoot || "C:/Windows", "System32");
|
|
@@ -103925,7 +104114,7 @@ function addToJsonHost(file, entry, { now = /* @__PURE__ */ new Date(), force =
|
|
|
103925
104114
|
}
|
|
103926
104115
|
const existing = current.mcpServers?.[MCP_SERVER_NAME];
|
|
103927
104116
|
if (existing !== void 0) {
|
|
103928
|
-
if (
|
|
104117
|
+
if (sameJson2(existing, entry)) return { file, changed: false };
|
|
103929
104118
|
if (!force && !isOlderSetupEntry(existing, entry)) {
|
|
103930
104119
|
throw new Error(`setup_host_config_conflict: the host's config file already has a different "${MCP_SERVER_NAME}" server, so setup left it alone; rerun setup with --force to replace it (the old file is backed up first), or edit it by hand`);
|
|
103931
104120
|
}
|
|
@@ -103973,7 +104162,7 @@ function addToJsonHost(file, entry, { now = /* @__PURE__ */ new Date(), force =
|
|
|
103973
104162
|
}
|
|
103974
104163
|
return { file, changed: true, ...backup ? { backup } : {} };
|
|
103975
104164
|
}
|
|
103976
|
-
var import_web3118, CONFIG_SCHEMA, CONFIG_FILE, NPX_PACKAGE, NPX_INSTALL_FLAGS, MCP_SERVER_NAME, P03_BINDING2, PRODUCTION, RETIRED_POOLS, NO_LIMIT_ATOMIC2, DEFAULT_CAPS, OLD_DEFAULT_SETUP_CAPS, OLD_DEFAULT_WALLET_BUDGETS, capText, POSITIVE_ATOMIC2, configPath, homeWalletPath, invalid3, isPubkey, HOST_TARGETS, WINDOWS_SHELL_CODE, isPlainObject3,
|
|
104165
|
+
var import_web3118, CONFIG_SCHEMA, CONFIG_FILE, NPX_PACKAGE, NPX_INSTALL_FLAGS, MCP_SERVER_NAME, P03_BINDING2, PRODUCTION, RETIRED_POOLS, NO_LIMIT_ATOMIC2, DEFAULT_CAPS, OLD_DEFAULT_SETUP_CAPS, OLD_DEFAULT_WALLET_BUDGETS, capText, POSITIVE_ATOMIC2, configPath, homeWalletPath, invalid3, isPubkey, HOST_TARGETS, WINDOWS_SHELL_CODE, isPlainObject3, sameJson2;
|
|
103977
104166
|
var init_config2 = __esm({
|
|
103978
104167
|
"wallet/src/setup/config.mjs"() {
|
|
103979
104168
|
"use strict";
|
|
@@ -104024,7 +104213,7 @@ var init_config2 = __esm({
|
|
|
104024
104213
|
HOST_TARGETS = Object.freeze(["claude-code", "claude-desktop", "cursor"]);
|
|
104025
104214
|
WINDOWS_SHELL_CODE = /[%$`"\r\n]/;
|
|
104026
104215
|
isPlainObject3 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
104027
|
-
|
|
104216
|
+
sameJson2 = (a, b) => {
|
|
104028
104217
|
const canonical5 = (value) => Array.isArray(value) ? value.map(canonical5) : isPlainObject3(value) ? Object.fromEntries(Object.keys(value).sort().map((key) => [key, canonical5(value[key])])) : value;
|
|
104029
104218
|
return JSON.stringify(canonical5(a)) === JSON.stringify(canonical5(b));
|
|
104030
104219
|
};
|