shinjuku-shielded 0.3.33 → 0.3.35
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 +3 -3
- package/package.json +3 -3
- package/shinjuku-wallet.mjs +63 -7
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": "fc7329d0267d82e7f06546009c64924d0ec713165c3bfe270512ba0672b94cbd",
|
|
5
|
+
"bytes": 11187416,
|
|
6
|
+
"sourceCommit": "dcbbb1497a0fcf92d4e0ff9bd78fb81b72075631",
|
|
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",
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shielded",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.35",
|
|
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": "fc7329d0",
|
|
7
|
+
"shinjukuSha256": "fc7329d0267d82e7f06546009c64924d0ec713165c3bfe270512ba0672b94cbd",
|
|
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
|
@@ -53257,6 +53257,7 @@ async function retryTransientRpc(operation, {
|
|
|
53257
53257
|
} catch (error) {
|
|
53258
53258
|
if (!isTransientRpcError(error)) throw error;
|
|
53259
53259
|
lastError = error;
|
|
53260
|
+
markPhase(`rpc-retry-${transientCause(error)}`);
|
|
53260
53261
|
if (attempt + 1 < attempts) {
|
|
53261
53262
|
await new Promise((resolve38) => setTimeout(resolve38, baseDelayMs * 2 ** attempt));
|
|
53262
53263
|
}
|
|
@@ -53274,6 +53275,10 @@ function reuseRefusalCause(error) {
|
|
|
53274
53275
|
if (status) return `http_${status}`;
|
|
53275
53276
|
return error instanceof import_web396.SolanaJSONRPCError ? "rpc_error" : "read_failed";
|
|
53276
53277
|
}
|
|
53278
|
+
function transientCause(error) {
|
|
53279
|
+
if (error instanceof import_web396.SolanaJSONRPCError) return String(-error.code);
|
|
53280
|
+
return reuseRefusalCause(error);
|
|
53281
|
+
}
|
|
53277
53282
|
function isTransientRpcError(error) {
|
|
53278
53283
|
if (error?.transientRpcError === true) return true;
|
|
53279
53284
|
if (error instanceof import_web396.SolanaJSONRPCError) return LAGGING_NODE_RPC_CODES.has(error.code);
|
|
@@ -54216,6 +54221,7 @@ var init_walk = __esm({
|
|
|
54216
54221
|
init_esm2();
|
|
54217
54222
|
init_chain2();
|
|
54218
54223
|
init_proxy();
|
|
54224
|
+
init_phaseTiming();
|
|
54219
54225
|
init_quote2();
|
|
54220
54226
|
init_compressedReplay();
|
|
54221
54227
|
init_p03E1Tree();
|
|
@@ -56322,7 +56328,6 @@ async function loadWalletP03History(args) {
|
|
|
56322
56328
|
}
|
|
56323
56329
|
if (runKey !== void 0 && recentScope.getStore() === true && strictScope.getStore() !== true && args.forceRead !== true) {
|
|
56324
56330
|
const recent = recentLoads.get(runKey);
|
|
56325
|
-
recentLoads.delete(runKey);
|
|
56326
56331
|
if (recent !== void 0 && Date.now() - recent.startedAt <= HISTORY_PREWARM_JOIN_MS) {
|
|
56327
56332
|
PREWARMED_REPORTS.add(recent.report);
|
|
56328
56333
|
markPhase("walk-recent");
|
|
@@ -56367,6 +56372,7 @@ async function loadWalletP03HistoryNow({ store, connection: given, programId, po
|
|
|
56367
56372
|
const earlier = remembered !== void 0 && Date.now() - remembered.at <= HISTORY_WARM_FRESH_MS ? remembered.report : void 0;
|
|
56368
56373
|
let movedSnapshot;
|
|
56369
56374
|
if (earlier !== void 0) {
|
|
56375
|
+
markPhase("refresh-start");
|
|
56370
56376
|
try {
|
|
56371
56377
|
const refreshed = await refreshFinalizedP03HistorySnapshot({ connection, programId, pool: pool2, history: earlier });
|
|
56372
56378
|
markPhase("walk-refreshed");
|
|
@@ -56534,7 +56540,7 @@ function reportHistoryRpc(split5, source, result, crossChecked) {
|
|
|
56534
56540
|
writeStderr(`history: ${who} answered ${list(split5.history)}; your own RPC answered ${list(split5.own)} (the pool account the history must match, and the cross-check)${window2}${integrity}
|
|
56535
56541
|
`);
|
|
56536
56542
|
}
|
|
56537
|
-
var strictScope, withStrictHistorySource, recentScope, withRecentWalletHistory, recentLoads, historyCacheKey, HISTORY_PREWARM_JOIN_MS, prewarmedWalks, PREWARMED_REPORTS, isPrewarmedWalletHistory, COMPACT_BEHIND_RETRY_MS, lastRunReports, writeStderr, announcedSources;
|
|
56543
|
+
var strictScope, withStrictHistorySource, recentScope, withRecentWalletHistory, recentLoads, forgetRecentWalletHistory, historyCacheKey, HISTORY_PREWARM_JOIN_MS, prewarmedWalks, PREWARMED_REPORTS, isPrewarmedWalletHistory, COMPACT_BEHIND_RETRY_MS, lastRunReports, writeStderr, announcedSources;
|
|
56538
56544
|
var init_walletHistory = __esm({
|
|
56539
56545
|
"wallet/src/history/walletHistory.mjs"() {
|
|
56540
56546
|
"use strict";
|
|
@@ -56551,6 +56557,9 @@ var init_walletHistory = __esm({
|
|
|
56551
56557
|
recentScope = new AsyncLocalStorage2();
|
|
56552
56558
|
withRecentWalletHistory = (fn) => recentScope.run(true, fn);
|
|
56553
56559
|
recentLoads = /* @__PURE__ */ new Map();
|
|
56560
|
+
forgetRecentWalletHistory = () => {
|
|
56561
|
+
recentLoads.clear();
|
|
56562
|
+
};
|
|
56554
56563
|
historyCacheKey = (store) => createHmac5("sha256", Buffer.from(store.state.seedHex, "hex")).update("carbon-shielded-wallet/history-cache-key/v1").digest("hex");
|
|
56555
56564
|
HISTORY_PREWARM_JOIN_MS = 1e4;
|
|
56556
56565
|
prewarmedWalks = /* @__PURE__ */ new Map();
|
|
@@ -61134,6 +61143,7 @@ var init_errorCodes = __esm({
|
|
|
61134
61143
|
"p03_merchant_respend_evidence_account_file_invalid_json",
|
|
61135
61144
|
"p03_merchant_respend_evidence_digests_invalid_json",
|
|
61136
61145
|
"p03_merchant_respend_accounts_split_merge_first",
|
|
61146
|
+
"walk_history_required",
|
|
61137
61147
|
"merge_id_invalid",
|
|
61138
61148
|
"merge_id_reserved",
|
|
61139
61149
|
"p03_merchant_respend_insufficient_recovered_value",
|
|
@@ -62914,6 +62924,7 @@ var init_errorCodes = __esm({
|
|
|
62914
62924
|
"absorb_note_ambiguous",
|
|
62915
62925
|
"p03_payer_float_absorb_pocket_mismatch",
|
|
62916
62926
|
"p03_payer_float_absorb_exit_failed",
|
|
62927
|
+
"p03_payer_float_absorb_merge_failed",
|
|
62917
62928
|
"reverted_payment",
|
|
62918
62929
|
"config_invalid",
|
|
62919
62930
|
"p03_payer_float_journal_unwritable",
|
|
@@ -71956,6 +71967,26 @@ function startFinalizedChainTime(connection) {
|
|
|
71956
71967
|
return time + Math.floor(age / 1e3);
|
|
71957
71968
|
};
|
|
71958
71969
|
}
|
|
71970
|
+
async function everyAccountHeld({ store, connection, programId, serviceUrl: serviceUrl2, reservedReplayValues, deps = {} }) {
|
|
71971
|
+
if (typeof deps.walkHistory !== "function") fail15("walk_history_required");
|
|
71972
|
+
const viewing = deriveWalletViewingAuthority2({ seedBytes: seedBytes5(store.state), generator: pinnedGenerator4() });
|
|
71973
|
+
const history = assertAuthenticatedFinalizedP03History(await withRecentWalletHistory(() => deps.walkHistory()));
|
|
71974
|
+
const recovery = await (deps.recover ?? runRecover)({
|
|
71975
|
+
store,
|
|
71976
|
+
connection,
|
|
71977
|
+
programId: new import_web3106.PublicKey(programId),
|
|
71978
|
+
serviceUrl: serviceUrl2,
|
|
71979
|
+
deps: { fetchImpl: deps.fetchImpl, finalizedHistory: history, transitionContextFor: history.transitionContextFor }
|
|
71980
|
+
});
|
|
71981
|
+
return recovery.recovered.filter((entry) => entry.kind === "account" && entry.spendStatus === "unspent").every((entry) => {
|
|
71982
|
+
if (entry.leafIndex === void 0 || entry.leafIndex === null) return true;
|
|
71983
|
+
try {
|
|
71984
|
+
return reservedReplayValues.has(accountNullifier(entry.commitment, viewing.eta, entry.leafIndex).toString());
|
|
71985
|
+
} catch {
|
|
71986
|
+
return true;
|
|
71987
|
+
}
|
|
71988
|
+
});
|
|
71989
|
+
}
|
|
71959
71990
|
async function prepareRecoveredPayment({
|
|
71960
71991
|
store,
|
|
71961
71992
|
connection,
|
|
@@ -72034,6 +72065,7 @@ async function prepareRecoveredPayment({
|
|
|
72034
72065
|
quoteCommitment: witnessQuote.quoteCommitment,
|
|
72035
72066
|
amountAtomic: witnessQuote.amountAtomic
|
|
72036
72067
|
});
|
|
72068
|
+
forgetRecentWalletHistory();
|
|
72037
72069
|
return {
|
|
72038
72070
|
replayed: false,
|
|
72039
72071
|
walName: walName2,
|
|
@@ -72223,6 +72255,7 @@ async function prepareRecoveredPayment({
|
|
|
72223
72255
|
if (persisted !== void 0 && persisted.requestHash !== requestHash2) {
|
|
72224
72256
|
fail15("wal_request_binding_mismatch");
|
|
72225
72257
|
}
|
|
72258
|
+
forgetRecentWalletHistory();
|
|
72226
72259
|
const proved = await (deps.provePayment ?? proveRecoveredP03Payment)({ request, tools: proofTools });
|
|
72227
72260
|
const binding = {
|
|
72228
72261
|
poolDomain: request.poolDomain,
|
|
@@ -91553,7 +91586,8 @@ async function payViaFloat({
|
|
|
91553
91586
|
method: "POST",
|
|
91554
91587
|
body: Buffer.from(record.bodyBase64, "base64"),
|
|
91555
91588
|
headers: { "content-type": "application/json" },
|
|
91556
|
-
|
|
91589
|
+
// settlePriorBeforeQuote: a prior answer that holds every input is settled before the leg-1 402 (one quote, one row).
|
|
91590
|
+
deps: { ...withoutCallerBody(deps), fetchImpl: floatFetch(fetchImpl, seen), settlePriorBeforeQuote: true }
|
|
91557
91591
|
});
|
|
91558
91592
|
} catch (error) {
|
|
91559
91593
|
if (seen.refusal) {
|
|
@@ -92494,6 +92528,31 @@ async function payResourceOnce({
|
|
|
92494
92528
|
}
|
|
92495
92529
|
await settlePrior(name);
|
|
92496
92530
|
}
|
|
92531
|
+
const settleDeferred = async () => {
|
|
92532
|
+
const answeredAt = (name) => store.readWal(name)?.answeredAtMs ?? 0;
|
|
92533
|
+
const shared2 = {};
|
|
92534
|
+
for (const name of deferred.splice(0).sort((a, b) => answeredAt(b) - answeredAt(a))) await settlePrior(name, shared2);
|
|
92535
|
+
held.clear();
|
|
92536
|
+
};
|
|
92537
|
+
if (deps.settlePriorBeforeQuote === true && deferred.length > 0 && !record) {
|
|
92538
|
+
let first = false;
|
|
92539
|
+
try {
|
|
92540
|
+
first = await withPhaseScope(mark, "held", () => (deps.everyAccountHeld ?? everyAccountHeld)({
|
|
92541
|
+
store,
|
|
92542
|
+
connection,
|
|
92543
|
+
programId,
|
|
92544
|
+
serviceUrl: serviceUrl2,
|
|
92545
|
+
reservedReplayValues: held,
|
|
92546
|
+
deps: { fetchImpl: deps.fetchImpl, walkHistory: finality.walkHistory }
|
|
92547
|
+
}));
|
|
92548
|
+
} catch {
|
|
92549
|
+
first = false;
|
|
92550
|
+
}
|
|
92551
|
+
if (first === true) {
|
|
92552
|
+
mark("prior-finality-first");
|
|
92553
|
+
await settleDeferred();
|
|
92554
|
+
}
|
|
92555
|
+
}
|
|
92497
92556
|
if (!record?.paymentHeader && typeof deps.warmHistory === "function") {
|
|
92498
92557
|
if (walkedThisRun && deps.warmHistory === deps.walkHistory) {
|
|
92499
92558
|
mark("history-warm-reused");
|
|
@@ -92631,10 +92690,7 @@ async function payResourceOnce({
|
|
|
92631
92690
|
const noProof = store.readWal(`resource-proof-${requestKey}`)?.proved === void 0;
|
|
92632
92691
|
if (noProof && deferred.length > 0 && /^p03_merchant_respend_inputs_held_by_pending_payment/.test(message)) {
|
|
92633
92692
|
mark("prior-finality-fallback");
|
|
92634
|
-
|
|
92635
|
-
const shared2 = {};
|
|
92636
|
-
for (const name of deferred.splice(0).sort((a, b) => answeredAt(b) - answeredAt(a))) await settlePrior(name, shared2);
|
|
92637
|
-
held.clear();
|
|
92693
|
+
await settleDeferred();
|
|
92638
92694
|
continue;
|
|
92639
92695
|
}
|
|
92640
92696
|
if (!requoted && noProof && (/^p03_merchant_respend_quote_life_short_requote/.test(message) || /^p03_merchant_respend_quote_expired/.test(message))) {
|