shinjuku-shielded 0.3.20 → 0.3.22
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 +71 -15
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": "00da3f6dfb766d83cd9f1fdb8c3a335c2de51a5dbab0d13b0e6ce3d50106cf02",
|
|
5
|
+
"bytes": 11131156,
|
|
6
|
+
"sourceCommit": "de187f4fedfed133b529b7763adc27c639613f2f",
|
|
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.22",
|
|
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": "00da3f6d",
|
|
7
|
+
"shinjukuSha256": "00da3f6dfb766d83cd9f1fdb8c3a335c2de51a5dbab0d13b0e6ce3d50106cf02",
|
|
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
|
@@ -54737,7 +54737,7 @@ function canonicalField(value, label) {
|
|
|
54737
54737
|
}
|
|
54738
54738
|
return value;
|
|
54739
54739
|
}
|
|
54740
|
-
var FIELD_MODULUS4, SUBTREE_LEAVES2, LOCAL_DEPTH, OUTER_DEPTH, TREE_DEPTH, P03_RECOVERY_PATH_SOURCE_MODEL, P03_PINNED_POSEIDON_PARAMETERS_SHA256, P03_PINNED_ZERO_LEAF, hash3, REBUILT_BY_REPORT, lastFold, FOLDS_IN_FLIGHT, ZERO_UPPER_ROOTS, LOCAL_ZERO_ROOTS, lastOuter;
|
|
54740
|
+
var FIELD_MODULUS4, SUBTREE_LEAVES2, LOCAL_DEPTH, OUTER_DEPTH, TREE_DEPTH, P03_RECOVERY_PATH_SOURCE_MODEL, P03_PINNED_POSEIDON_PARAMETERS_SHA256, P03_PINNED_ZERO_LEAF, hashCalls, hash3, REBUILT_BY_REPORT, lastFold, FOLDS_IN_FLIGHT, ZERO_UPPER_ROOTS, LOCAL_ZERO_ROOTS, lastOuter;
|
|
54741
54741
|
var init_recoveryPath = __esm({
|
|
54742
54742
|
"wallet/src/recovery/recoveryPath.mjs"() {
|
|
54743
54743
|
"use strict";
|
|
@@ -54753,10 +54753,14 @@ var init_recoveryPath = __esm({
|
|
|
54753
54753
|
P03_RECOVERY_PATH_SOURCE_MODEL = "carbon/shielded-x402-wallet/p03-finalized-recovery-path/v1";
|
|
54754
54754
|
P03_PINNED_POSEIDON_PARAMETERS_SHA256 = "d979d972277a601aeaf628d703e7b070a6662e952e9946d60e5f6f2304bb6e1b";
|
|
54755
54755
|
P03_PINNED_ZERO_LEAF = 7848971562719066880601334108362337871940338669244961380918189469732108181768n;
|
|
54756
|
-
|
|
54757
|
-
|
|
54758
|
-
|
|
54759
|
-
|
|
54756
|
+
hashCalls = 0;
|
|
54757
|
+
hash3 = (left, right) => {
|
|
54758
|
+
hashCalls += 1;
|
|
54759
|
+
return poseidon2([
|
|
54760
|
+
canonicalField(left, "hash_left"),
|
|
54761
|
+
canonicalField(right, "hash_right")
|
|
54762
|
+
], 3);
|
|
54763
|
+
};
|
|
54760
54764
|
REBUILT_BY_REPORT = /* @__PURE__ */ new WeakMap();
|
|
54761
54765
|
FOLDS_IN_FLIGHT = /* @__PURE__ */ new WeakMap();
|
|
54762
54766
|
}
|
|
@@ -118247,8 +118251,8 @@ function channelListsSet(body, { facilitator, pool, dir, sumsSha256 }) {
|
|
|
118247
118251
|
// wallet/src/setup/proofTools.mjs
|
|
118248
118252
|
var PINNED_PROOF_TOOLS = Object.freeze({
|
|
118249
118253
|
[DEFAULT_FACILITATOR_ORIGIN]: Object.freeze({
|
|
118250
|
-
dir: "
|
|
118251
|
-
sumsSha256: "
|
|
118254
|
+
dir: "78c71143",
|
|
118255
|
+
sumsSha256: "78c71143ecedf22096fdc1901eda5160e29c141f6961cce935b92e714ff85bd9"
|
|
118252
118256
|
})
|
|
118253
118257
|
});
|
|
118254
118258
|
var UPDATE_NEXT = "update the wallet: npx -y shinjuku-shielded@latest setup";
|
|
@@ -118871,6 +118875,7 @@ var SELF_PAY_ORIGIN2 = "https://self-pay.invalid/";
|
|
|
118871
118875
|
var POCKET_FILL_RECORD = "self-pay-pocket-";
|
|
118872
118876
|
var MERGE_RECORD = "self-pay-merge-";
|
|
118873
118877
|
var POOL_MOVE_SCHEMA = "carbon-shielded-wallet/pool-move/v1";
|
|
118878
|
+
var FLOAT_PAYMENT_SCHEMA2 = "carbon-shielded-wallet/float-payment/v1";
|
|
118874
118879
|
var POOL_MOVE_PATH2 = "/api/x402/move/pay/";
|
|
118875
118880
|
var POOL_SUCCESSION_SCHEMAS = /* @__PURE__ */ new Set([
|
|
118876
118881
|
"carbon-shielded-wallet/pool-succession/v1",
|
|
@@ -118989,6 +118994,7 @@ function classify(name, record) {
|
|
|
118989
118994
|
if (name.startsWith("add-funds-")) return { type: "add-funds", phase: "plan", state };
|
|
118990
118995
|
if (name.startsWith("move-") && record?.schema === POOL_MOVE_SCHEMA) return { type: "pool-move", phase: "plan", state };
|
|
118991
118996
|
if (name.startsWith("succ-") && POOL_SUCCESSION_SCHEMAS.has(record?.schema)) return { type: "pool-succession", phase: "plan", state };
|
|
118997
|
+
if (name.startsWith("float-") && record?.schema === FLOAT_PAYMENT_SCHEMA2) return { type: "float-payment", phase: "plan", state };
|
|
118992
118998
|
return { type: "other", phase: "other", state };
|
|
118993
118999
|
}
|
|
118994
119000
|
function refreshCommand(state, programId = "<program id>") {
|
|
@@ -119097,6 +119103,7 @@ function computeBalance({ store, snapshotRead, source = "local", now = Date.now(
|
|
|
119097
119103
|
const snapshotDigests = new Set(snapshot.outputs.map((output2) => output2.digest));
|
|
119098
119104
|
const unspentAtomic = sum2([...unspent.values()].map((output2) => output2.valueAtomic));
|
|
119099
119105
|
detail.unspentAtomic = unspentAtomic.toString();
|
|
119106
|
+
const settling = [];
|
|
119100
119107
|
const movable = snapshot.outputs.filter((output2) => output2.spendStatus === "succession-movable");
|
|
119101
119108
|
const successionMovableAtomic = sum2(movable.map((output2) => output2.valueAtomic));
|
|
119102
119109
|
detail.successionMovableAtomic = successionMovableAtomic.toString();
|
|
@@ -119110,17 +119117,37 @@ function computeBalance({ store, snapshotRead, source = "local", now = Date.now(
|
|
|
119110
119117
|
ageSeconds: Math.max(0, Math.floor((now - Date.parse(snapshot.refreshedAt)) / 1e3)),
|
|
119111
119118
|
programId: snapshot.programId
|
|
119112
119119
|
};
|
|
119120
|
+
const settlingReasons = [];
|
|
119121
|
+
const settlingPayment = (entry) => {
|
|
119122
|
+
if (entry.type !== "payment" || String(entry.record.url ?? "").startsWith(SELF_PAY_ORIGIN2) || String(entry.record.url ?? "").includes(POOL_MOVE_PATH2)) return void 0;
|
|
119123
|
+
const inputs = provenInputs(byName.get(`resource-proof-${entry.name.slice("resource-payment-".length)}`)?.record);
|
|
119124
|
+
const amount = paymentAmount(entry.record);
|
|
119125
|
+
return inputs !== void 0 && amount !== void 0 && inputs.every((commitment) => unspent.has(commitment)) ? { inputs, amountAtomic: BigInt(amount) } : void 0;
|
|
119126
|
+
};
|
|
119113
119127
|
for (const entry of records) {
|
|
119114
119128
|
const before = Object.hasOwn(snapshot.walStates, entry.name) ? snapshot.walStates[entry.name] : void 0;
|
|
119115
119129
|
const beforePhase = before === void 0 ? "absent" : classify(entry.name, { ...entry.record, state: before }).phase;
|
|
119116
119130
|
if (entry.phase === "done" && beforePhase !== "done") {
|
|
119131
|
+
const paying = settlingPayment(entry);
|
|
119132
|
+
if (paying) {
|
|
119133
|
+
settling.push(paying);
|
|
119134
|
+
settlingReasons.push(`payment record ${entry.name} was answered after the last refresh: the balance counts it as paid; refresh again in a minute`);
|
|
119135
|
+
continue;
|
|
119136
|
+
}
|
|
119117
119137
|
reasons.push(`${entry.type} record ${entry.name} reached ${entry.state} after the last refresh`);
|
|
119118
119138
|
} else if (entry.phase === "other" && before !== entry.state) {
|
|
119119
119139
|
reasons.push(`record ${entry.name} changed after the last refresh and this command cannot read it`);
|
|
119120
119140
|
} else if (entry.phase === "done" && ["deposit", "payment"].includes(entry.type)) {
|
|
119121
119141
|
const digest2 = digestKey(entry.record.memoDigest);
|
|
119122
119142
|
if (digest2 && !snapshotDigests.has(digest2)) {
|
|
119123
|
-
|
|
119143
|
+
const answered = entry.type === "payment" && ["pending", "confirmed"].includes(entry.record.receiptFinality);
|
|
119144
|
+
const paying = answered ? settlingPayment(entry) : void 0;
|
|
119145
|
+
if (paying) {
|
|
119146
|
+
settling.push(paying);
|
|
119147
|
+
settlingReasons.push(`payment record ${entry.name} was answered and its settlement is on its way to finality: the balance counts it as paid; refresh again in a minute`);
|
|
119148
|
+
continue;
|
|
119149
|
+
}
|
|
119150
|
+
reasons.push(answered ? `payment record ${entry.name} was answered, but its settlement may not have been final at the last refresh; refresh again in a minute` : `${entry.type} record ${entry.name} finished before the last refresh, but the walk has no output from its memo (unpublished memo, or --fresh before publication)`);
|
|
119124
119151
|
}
|
|
119125
119152
|
}
|
|
119126
119153
|
}
|
|
@@ -119195,10 +119222,23 @@ function computeBalance({ store, snapshotRead, source = "local", now = Date.now(
|
|
|
119195
119222
|
if (reasons.length) return report("stale", null, refreshCommand(state, snapshot.programId));
|
|
119196
119223
|
const reservedAtomic = unknownInputs ? unspentAtomic : sum2([...reserved].filter((commitment) => unspent.has(commitment)).map((commitment) => unspent.get(commitment).valueAtomic));
|
|
119197
119224
|
detail.reservedAtomic = reservedAtomic.toString();
|
|
119198
|
-
const
|
|
119225
|
+
const settlingInputs = new Set(settling.flatMap((payment) => payment.inputs));
|
|
119226
|
+
if (settling.some((payment) => payment.inputs.some((commitment) => reserved.has(commitment))) || unknownInputs && settling.length) {
|
|
119227
|
+
reasons.push(...settlingReasons);
|
|
119228
|
+
return report("stale", null, refreshCommand(state, snapshot.programId));
|
|
119229
|
+
}
|
|
119230
|
+
const spendable = unspentAtomic - reservedAtomic - sum2(settling.map((payment) => payment.amountAtomic));
|
|
119231
|
+
if (spendable < 0n) {
|
|
119232
|
+
reasons.push(...settlingReasons);
|
|
119233
|
+
return report("stale", null, refreshCommand(state, snapshot.programId));
|
|
119234
|
+
}
|
|
119199
119235
|
const anchorIndex = canonicalAtomic(snapshot.anchorIndex) ? BigInt(snapshot.anchorIndex) : void 0;
|
|
119200
|
-
detail.fundedAccounts = unknownInputs ? 0 : [...unspent.values()].filter((output2) => output2.kind === "account" && BigInt(output2.valueAtomic) > 0n && !reserved.has(output2.commitment) && (anchorIndex === void 0 || BigInt(output2.leafIndex) < anchorIndex)).length;
|
|
119236
|
+
detail.fundedAccounts = unknownInputs ? 0 : [...unspent.values()].filter((output2) => output2.kind === "account" && BigInt(output2.valueAtomic) > 0n && !reserved.has(output2.commitment) && !settlingInputs.has(output2.commitment) && (anchorIndex === void 0 || BigInt(output2.leafIndex) < anchorIndex)).length;
|
|
119201
119237
|
const next = detail.inFlight.length ? "finish or cancel the work in detail.inFlight; the wallet runs one payment at a time" : pendingDeposits.length ? `deposit ${pendingDeposits[0].depositId} is not finished: rerun the same deposit command with --submit --service <facilitator URL>` : pocketsUnscanned ? scanPockets2 : unspentAtomic === 0n && successionMovableAtomic > 0n ? "this pool was succeeded by a new pool: its value moves there (a move per account, the facilitator pays the fee) and counts in this balance until then" : unspentAtomic === 0n ? "nothing to spend: deposit (shinjuku-wallet help deposit), or run balance --refresh if a payment to this wallet settled" : void 0;
|
|
119238
|
+
if (settling.length) {
|
|
119239
|
+
reasons.push(...settlingReasons);
|
|
119240
|
+
return report("stale", spendable + successionMovableAtomic, next ?? refreshCommand(state, snapshot.programId));
|
|
119241
|
+
}
|
|
119202
119242
|
return report("current", spendable + successionMovableAtomic, next);
|
|
119203
119243
|
}
|
|
119204
119244
|
function combinePoolBalances(partsAtomic, movingAtomic2 = "0") {
|
|
@@ -122821,7 +122861,7 @@ function createSuccessionScheduler(options) {
|
|
|
122821
122861
|
} = options;
|
|
122822
122862
|
const now = options.now ?? Date.now;
|
|
122823
122863
|
const randomInt9 = options.randomInt ?? cryptoRandomInt;
|
|
122824
|
-
const valueOf = options.valueOf ?? ((store) => {
|
|
122864
|
+
const valueOf = (Object.hasOwn(options, "valueOf") ? options.valueOf : void 0) ?? ((store) => {
|
|
122825
122865
|
try {
|
|
122826
122866
|
return computeBalance({ store, snapshotRead: readBalanceSnapshot(store), source: "local" }).split?.shieldedAtomic ?? null;
|
|
122827
122867
|
} catch {
|
|
@@ -122911,6 +122951,7 @@ function createSuccessionScheduler(options) {
|
|
|
122911
122951
|
});
|
|
122912
122952
|
}
|
|
122913
122953
|
if (verified.record.importDone) job = schedule(store, job);
|
|
122954
|
+
else job = save2(store, job, {});
|
|
122914
122955
|
return job;
|
|
122915
122956
|
}
|
|
122916
122957
|
const base = (entry, value, verified) => ({
|
|
@@ -123014,6 +123055,10 @@ function createSuccessionScheduler(options) {
|
|
|
123014
123055
|
}
|
|
123015
123056
|
switch (job.state) {
|
|
123016
123057
|
case "linked-waiting-import": {
|
|
123058
|
+
try {
|
|
123059
|
+
if (hasWallet(job.to) && !readSuccessionJob(storeOf(job.to), entry.from)) job = save2(store, job, {});
|
|
123060
|
+
} catch {
|
|
123061
|
+
}
|
|
123017
123062
|
if (now() - (recordCheckedAt.get(entry.from) ?? -Infinity) < SUCCESSION_TICK_MS - 1e3) return job;
|
|
123018
123063
|
recordCheckedAt.set(entry.from, now());
|
|
123019
123064
|
let verified;
|
|
@@ -124334,7 +124379,11 @@ var FORBIDDEN_HEADERS3 = ["host", "content-length", "connection", "transfer-enco
|
|
|
124334
124379
|
var MAX_BODY_BYTES2 = 16 * 1024 * 1024;
|
|
124335
124380
|
var PREVIEW_TIMEOUT_MS = 3e4;
|
|
124336
124381
|
var SAFE_TEXT = /^(fetch_|spend_|mcp_|wallet_locked)/;
|
|
124337
|
-
var MCP_TOOL_ALIASES = Object.freeze({
|
|
124382
|
+
var MCP_TOOL_ALIASES = Object.freeze({
|
|
124383
|
+
fetch_paid: "x402_pay",
|
|
124384
|
+
wallet_pool_switch_status: "wallet_move_status",
|
|
124385
|
+
wallet_status: "wallet_balance"
|
|
124386
|
+
});
|
|
124338
124387
|
var POOL_SWITCH_WHY = "Your facilitator upgraded to a new pool. The wallet moves your balance there by itself. Your money is safe, and you do not need to do anything.";
|
|
124339
124388
|
var POOL_SWITCH_NEXT = "Nothing to do. Tell the user each message where tellUser is true. wallet_move_status shows the details.";
|
|
124340
124389
|
var SWITCH_STATES = /* @__PURE__ */ new Set(["pending", "scheduled", "running", "done", "failed"]);
|
|
@@ -125505,7 +125554,11 @@ function createWalletTools({
|
|
|
125505
125554
|
let report = computeBalance({ store, snapshotRead: readBalanceSnapshot(store), source: "local" });
|
|
125506
125555
|
let refresh = {};
|
|
125507
125556
|
const recentlyFailed = refreshFailedAt && Date.now() - refreshFailedAt < REFRESH_RETRY_MS && !refreshRun;
|
|
125508
|
-
if (report.split?.shieldedAtomic
|
|
125557
|
+
if (report.split?.shieldedAtomic != null && report.status === "stale") {
|
|
125558
|
+
if (!recentlyFailed) refreshShared().catch(() => {
|
|
125559
|
+
});
|
|
125560
|
+
refresh = { refreshing: true };
|
|
125561
|
+
} else if (report.split?.shieldedAtomic == null && recentlyFailed) {
|
|
125509
125562
|
refresh = { refreshed: false, refreshError: refreshFailedCode ?? "mcp_refresh_failed" };
|
|
125510
125563
|
} else if (report.split?.shieldedAtomic == null) {
|
|
125511
125564
|
const run5 = refreshShared().then(() => "done", (error2) => ({ failed: errorCode2(error2, "mcp_refresh_failed") }));
|
|
@@ -126476,7 +126529,10 @@ function createWalletTools({
|
|
|
126476
126529
|
await mover.refreshRelease();
|
|
126477
126530
|
} catch {
|
|
126478
126531
|
}
|
|
126479
|
-
|
|
126532
|
+
const moved2 = mover.status();
|
|
126533
|
+
const lead = switches.find((item) => item.state !== "done") ?? switches[0];
|
|
126534
|
+
if (moved2.state === "none" && lead) return json({ ok: true, ...moved2, state: lead.state, detail: lead.message, next: POOL_SWITCH_NEXT, ...extra });
|
|
126535
|
+
return json({ ok: true, ...moved2, ...extra });
|
|
126480
126536
|
}
|
|
126481
126537
|
};
|
|
126482
126538
|
const discover = discoverTool(join26(dirname23(session.walletPath), "discover-cache"));
|
|
@@ -126755,7 +126811,7 @@ var validId = (id) => id === null || typeof id === "string" || typeof id === "nu
|
|
|
126755
126811
|
function createMcpDispatcher({ tools, instructions: instructions2 = INSTRUCTIONS, aliases = {}, log = () => {
|
|
126756
126812
|
}, client, listChanged = false }) {
|
|
126757
126813
|
const byName = new Map(tools.map((tool) => [tool.name, tool]));
|
|
126758
|
-
for (const [alias, target] of Object.entries(aliases)) if (byName.has(target)) byName.set(alias, byName.get(target));
|
|
126814
|
+
for (const [alias, target] of Object.entries(aliases)) if (byName.has(target) && !byName.has(alias)) byName.set(alias, byName.get(target));
|
|
126759
126815
|
return async function dispatch(entry) {
|
|
126760
126816
|
const invalid4 = { jsonrpc: "2.0", id: null, error: { code: -32600, message: "Invalid request" } };
|
|
126761
126817
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return invalid4;
|