shinjuku-shielded 0.3.1 → 0.3.2
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 +34 -6
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": "d2a7291f11d583fab55b39ab67cc820808e5c7607618d1456c70cda34eb3450f",
|
|
5
|
+
"bytes": 10441804,
|
|
6
|
+
"sourceCommit": "537bcd4b3976e43c021d3a854622623b5baaeaab",
|
|
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.2",
|
|
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": "d2a7291f",
|
|
7
|
+
"shinjukuSha256": "d2a7291f11d583fab55b39ab67cc820808e5c7607618d1456c70cda34eb3450f",
|
|
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
|
@@ -57652,6 +57652,7 @@ var init_errorCodes = __esm({
|
|
|
57652
57652
|
"external_appends_already_bound",
|
|
57653
57653
|
"facilitator_origin_invalid",
|
|
57654
57654
|
"facilitator_pending",
|
|
57655
|
+
"facilitator_underfunded",
|
|
57655
57656
|
"facilitator_url_invalid",
|
|
57656
57657
|
"failed_pre_broadcast",
|
|
57657
57658
|
"failed_record_unwritable",
|
|
@@ -57872,6 +57873,7 @@ var init_errorCodes = __esm({
|
|
|
57872
57873
|
"p03_exit_account_path_signature_context_missing",
|
|
57873
57874
|
"p03_exit_account_path_subtree_not_found",
|
|
57874
57875
|
"p03_exit_account_path_subtree_root_mismatch",
|
|
57876
|
+
"p03_facilitator_underfunded",
|
|
57875
57877
|
"p03_history_authenticated_report_required",
|
|
57876
57878
|
"p03_history_base58_invalid",
|
|
57877
57879
|
"p03_history_block_gap",
|
|
@@ -82823,8 +82825,10 @@ async function unconfirmedResponseError(response) {
|
|
|
82823
82825
|
error.httpStatus = response.status;
|
|
82824
82826
|
try {
|
|
82825
82827
|
const text3 = response.body ? await readBounded(response, 4096) : "";
|
|
82826
|
-
const
|
|
82828
|
+
const answer = JSON.parse(text3);
|
|
82829
|
+
const code = answer?.code;
|
|
82827
82830
|
if (typeof code === "string" && /^[a-z][a-z0-9_]{0,63}$/.test(code)) error.sellerCode = code;
|
|
82831
|
+
if (answer?.reason === SELLER_REASON_FACILITATOR_UNDERFUNDED) error.sellerReason = answer.reason;
|
|
82828
82832
|
} catch {
|
|
82829
82833
|
}
|
|
82830
82834
|
return error;
|
|
@@ -83542,8 +83546,9 @@ async function payResourceOnce({
|
|
|
83542
83546
|
store.writeWal(walName2, { ...record, state: "cancelled", refused: { sellerCode: unconfirmed.sellerCode } });
|
|
83543
83547
|
releaseReservation(store, requestKey);
|
|
83544
83548
|
mark("refused");
|
|
83549
|
+
const underfunded = unconfirmed.sellerReason === SELLER_REASON_FACILITATOR_UNDERFUNDED;
|
|
83545
83550
|
throw Object.assign(
|
|
83546
|
-
new Error("p03_resource_payment_refused_pay_again_new_request_id"),
|
|
83551
|
+
new Error(underfunded ? "p03_facilitator_underfunded" : "p03_resource_payment_refused_pay_again_new_request_id"),
|
|
83547
83552
|
{ httpStatus: response.status, sellerCode: unconfirmed.sellerCode }
|
|
83548
83553
|
);
|
|
83549
83554
|
}
|
|
@@ -83574,7 +83579,7 @@ async function payResourceOnce({
|
|
|
83574
83579
|
mark("receipt-pending");
|
|
83575
83580
|
return { replayed: false, receipt, resultBase64, receiptFinality: "pending" };
|
|
83576
83581
|
}
|
|
83577
|
-
var import_web3108, fail17, hash9, OWNER_UNSHIELD_REQUEST, OWNER_UNSHIELD_ORIGIN, POCKET_FILL_ID, RECEIPT_FINALITY_TIMEOUT_MS, RECEIPT_FINALITY_POLL_MS, FINALITY_GATE_MARGIN_SLOTS, FINALITY_GATE_POLL_MS, FINALITY_GATE_SKIP_AFTER_MS, PENDING_FINALITY, isPending, REPLAY_INPUTS, PAYMENT_OUTPUT_INPUT2, QUOTE_MARGIN_SECONDS, SELLER_REFUSED_PAY_AGAIN, ANCHOR_EPOCH_MS, ANCHOR_MARGIN_MS, ANCHOR_WAIT_CAP_MS, DEAD_PAYMENT_MARGIN_SECONDS, SYSVAR_OWNER, quoteLiveAt, replayValuesOf;
|
|
83582
|
+
var import_web3108, fail17, hash9, OWNER_UNSHIELD_REQUEST, OWNER_UNSHIELD_ORIGIN, POCKET_FILL_ID, RECEIPT_FINALITY_TIMEOUT_MS, RECEIPT_FINALITY_POLL_MS, FINALITY_GATE_MARGIN_SLOTS, FINALITY_GATE_POLL_MS, FINALITY_GATE_SKIP_AFTER_MS, PENDING_FINALITY, isPending, REPLAY_INPUTS, PAYMENT_OUTPUT_INPUT2, QUOTE_MARGIN_SECONDS, SELLER_REFUSED_PAY_AGAIN, SELLER_REASON_FACILITATOR_UNDERFUNDED, ANCHOR_EPOCH_MS, ANCHOR_MARGIN_MS, ANCHOR_WAIT_CAP_MS, DEAD_PAYMENT_MARGIN_SECONDS, SYSVAR_OWNER, quoteLiveAt, replayValuesOf;
|
|
83578
83583
|
var init_payResource = __esm({
|
|
83579
83584
|
"wallet/src/pay/payResource.mjs"() {
|
|
83580
83585
|
"use strict";
|
|
@@ -83613,6 +83618,7 @@ var init_payResource = __esm({
|
|
|
83613
83618
|
PAYMENT_OUTPUT_INPUT2 = 4;
|
|
83614
83619
|
QUOTE_MARGIN_SECONDS = 120;
|
|
83615
83620
|
SELLER_REFUSED_PAY_AGAIN = "payment_refused_pay_again";
|
|
83621
|
+
SELLER_REASON_FACILITATOR_UNDERFUNDED = "facilitator_underfunded";
|
|
83616
83622
|
ANCHOR_EPOCH_MS = 3e5;
|
|
83617
83623
|
ANCHOR_MARGIN_MS = 2e4;
|
|
83618
83624
|
ANCHOR_WAIT_CAP_MS = ANCHOR_EPOCH_MS + 6e4;
|
|
@@ -86524,7 +86530,7 @@ function sellerHttpReply(result) {
|
|
|
86524
86530
|
const headers = { "Content-Type": result.result?.contentType ?? "application/json" };
|
|
86525
86531
|
if (result.paymentRequired) headers["PAYMENT-REQUIRED"] = encodeHeader(result.paymentRequired);
|
|
86526
86532
|
if (result.receipt) headers["PAYMENT-RESPONSE"] = encodeHeader(publicReceipt(result.receipt));
|
|
86527
|
-
const body = result.result ? Buffer.from(result.result.bodyBase64, "base64") : Buffer.from(JSON.stringify(result.paymentRequired ?? { code: result.code }));
|
|
86533
|
+
const body = result.result ? Buffer.from(result.result.bodyBase64, "base64") : Buffer.from(JSON.stringify(result.paymentRequired ?? { code: result.code, ...result.reason === FACILITATOR_UNDERFUNDED ? { reason: result.reason } : {} }));
|
|
86528
86534
|
return { status: result.status, headers, body };
|
|
86529
86535
|
}
|
|
86530
86536
|
async function createSellerAdapter({
|
|
@@ -87018,7 +87024,11 @@ async function createSellerAdapter({
|
|
|
87018
87024
|
if (refusedBeforeSettlement(receipt)) {
|
|
87019
87025
|
await put(nonce, { ...offer, phase: "prepared", settleAttempted: false });
|
|
87020
87026
|
mark("settle-refused-before-record");
|
|
87021
|
-
return {
|
|
87027
|
+
return {
|
|
87028
|
+
status: 202,
|
|
87029
|
+
code: PAYMENT_REFUSED,
|
|
87030
|
+
...receipt.errorReason === "p03_settler_underfunded" ? { reason: FACILITATOR_UNDERFUNDED } : {}
|
|
87031
|
+
};
|
|
87022
87032
|
}
|
|
87023
87033
|
offer = await persistReceipt(nonce, offer, receipt, mark);
|
|
87024
87034
|
return { status: offer.result.status, result: offer.result, receipt: offer.receipt };
|
|
@@ -87156,7 +87166,7 @@ async function createSellerAdapter({
|
|
|
87156
87166
|
}));
|
|
87157
87167
|
return { server, handle, close, signerPublicKey, settledTransactions, offerSummaries };
|
|
87158
87168
|
}
|
|
87159
|
-
var import_web3113, BINDING, SCHEMA2, OFFERS_LAYOUT, SNAPSHOT_EVERY_MS, LOADER2, canonical, storeProfileIdentity, jsonSafe, bigint, encodeHeader, PAYMENT_REFUSED, DEFINITE_VERIFY_REFUSALS, definiteVerifyRefusal, refusedBeforeSettlement, ANCHOR_REQUEST_TIMEOUT_MS, ANCHOR_POLL_ATTEMPTS, ANCHOR_POLL_MS, pause, FOLLOW_UP_DELAYS_MS, FOLLOW_UP_RESETTLE_FROM;
|
|
87169
|
+
var import_web3113, BINDING, SCHEMA2, OFFERS_LAYOUT, SNAPSHOT_EVERY_MS, LOADER2, canonical, storeProfileIdentity, jsonSafe, bigint, encodeHeader, PAYMENT_REFUSED, FACILITATOR_UNDERFUNDED, DEFINITE_VERIFY_REFUSALS, definiteVerifyRefusal, refusedBeforeSettlement, ANCHOR_REQUEST_TIMEOUT_MS, ANCHOR_POLL_ATTEMPTS, ANCHOR_POLL_MS, pause, FOLLOW_UP_DELAYS_MS, FOLLOW_UP_RESETTLE_FROM;
|
|
87160
87170
|
var init_service = __esm({
|
|
87161
87171
|
"wallet/src/seller/service.mjs"() {
|
|
87162
87172
|
"use strict";
|
|
@@ -87188,6 +87198,7 @@ var init_service = __esm({
|
|
|
87188
87198
|
bigint = (bytes2) => BigInt(`0x${Buffer.from(bytes2).toString("hex")}`);
|
|
87189
87199
|
encodeHeader = (v) => Buffer.from(JSON.stringify(v)).toString("base64");
|
|
87190
87200
|
PAYMENT_REFUSED = "payment_refused_pay_again";
|
|
87201
|
+
FACILITATOR_UNDERFUNDED = "facilitator_underfunded";
|
|
87191
87202
|
DEFINITE_VERIFY_REFUSALS = /* @__PURE__ */ new Set([
|
|
87192
87203
|
"p03_quote_expired",
|
|
87193
87204
|
"p03_quote_commitment_invalid",
|
|
@@ -110886,6 +110897,8 @@ function createAutoPockets({
|
|
|
110886
110897
|
next = `Nothing was paid. Do not retry this URL now. Tell your owner: the facilitator refuses pocket size ${sizeAtomic} atomic (${code}); the self-paid note went back to the shielded balance`;
|
|
110887
110898
|
} else if (result?.reason === "facilitator_offers_no_pockets") {
|
|
110888
110899
|
next = "Nothing was paid. Do not retry this URL now. Tell your owner: the facilitator (--memo-service) offers no pockets, so an exact-only seller cannot be paid";
|
|
110900
|
+
} else if (code === "p03_facilitator_underfunded") {
|
|
110901
|
+
next = `Nothing was spent. The facilitator cannot pay network fees right now (its settler is below its funding gate), so the pocket fill stopped. Try again later: call x402_pay again with request_id "${requestId}" after ${Math.ceil(FILL_RETRY_AFTER_MS / 6e4)} min (the fill starts again with a new quote). If it repeats, tell your owner: the facilitator's settler needs SOL`;
|
|
110889
110902
|
} else if (result?.reason === "scan_needed") {
|
|
110890
110903
|
next = `Nothing was paid. This wallet was restored and reads its pockets from the chain first; call x402_pay again with request_id "${requestId}" in ${POLL_SECONDS * 4} s`;
|
|
110891
110904
|
} else if (shieldedShort()) {
|
|
@@ -112727,6 +112740,15 @@ function createWalletTools({
|
|
|
112727
112740
|
`Nothing was sent. If wallet_balance shows shieldedAtomic below 1000000 (one pocket), call wallet_shield first. Then call x402_pay again with request_id "${requestId}" and the same url, method, headers, and body: it fills a pocket and pays once. If the same code repeats, tell your owner: ${code}`,
|
|
112728
112741
|
{ requestId }
|
|
112729
112742
|
);
|
|
112743
|
+
} else if (code === "p03_facilitator_underfunded") {
|
|
112744
|
+
return refuse8(
|
|
112745
|
+
code,
|
|
112746
|
+
"the facilitator cannot pay network fees right now; nothing was spent",
|
|
112747
|
+
"Nothing was spent, and this request_id is closed (its reserved amount came back). Try again later: call x402_pay with a NEW request_id and the same url, method, headers, and body in a few minutes. If it repeats, tell your owner: the facilitator's settler needs SOL",
|
|
112748
|
+
{ requestId }
|
|
112749
|
+
);
|
|
112750
|
+
} else if (code === "p03_resource_payment_refused_pay_again_new_request_id") {
|
|
112751
|
+
next = "Nothing was paid, and the seller closed this request_id. To pay, call x402_pay with a NEW request_id and the same url, method, headers, and body; if the same refusal repeats, tell your owner what the detail says";
|
|
112730
112752
|
} else if (code.startsWith("wallet_spend_refused_")) {
|
|
112731
112753
|
next = "the wallet file's own budget refused it (init --max-payment / --max-cumulative); nothing was paid. Read wallet_balance detail.budget";
|
|
112732
112754
|
} else if (code.startsWith("wallet_quote_refused_") || code.startsWith("fetch_")) {
|
|
@@ -113358,6 +113380,8 @@ function createWalletTools({
|
|
|
113358
113380
|
next = atAddress ? `Nothing was moved. The facilitator does not relay a deposit this small: call wallet_shield_from_elsewhere again with request_id "${job.requestId}" and a larger amount_atomic (this request keeps its address)` : "Nothing was moved and no address was made. The facilitator does not relay a deposit this small: call wallet_shield_from_elsewhere with a NEW request_id and a larger amount_atomic";
|
|
113359
113381
|
} else if (kind === "elsewhere" && /relay_not_offered|relay_config_mismatch|relay_config_invalid|proof_tools_missing/.test(code)) {
|
|
113360
113382
|
next = `Nothing new was moved. Tell your owner: ${code} (the facilitator at --memo-service must relay deposits for this wallet's pool, and --proof-tools must hold the deposit prover).${atAddress}`;
|
|
113383
|
+
} else if (code === "p03_facilitator_underfunded") {
|
|
113384
|
+
next = `Nothing was spent. The facilitator cannot pay network fees right now (its settler is below its funding gate), and this request_id is closed. Try again later: call ${KINDS[kind].tool} with a NEW request_id in a few minutes. If it repeats, tell your owner: the facilitator's settler needs SOL`;
|
|
113361
113385
|
} else if (/_use_new_unshield_id$/.test(code)) next = "the self-payment provably never landed, so nothing was spent; this request_id is closed: call wallet_unshield with a NEW request_id";
|
|
113362
113386
|
else if (/own_key_usdc_not_finalized/.test(code)) next = "Nothing was moved. The USDC just arrived and is not final on chain yet. Call wallet_shield again with the same request_id and amount_atomic in 30 s";
|
|
113363
113387
|
else if (/insufficient_token_balance|above_balance/.test(code)) next = "Nothing was moved. The wallet's own key holds less public USDC than amount_atomic (wallet_balance unshieldedAtomic). Tell the user, or call wallet_shield with a NEW request_id and a smaller amount_atomic";
|
|
@@ -121418,6 +121442,10 @@ function failureHint(command, reason, deps, values) {
|
|
|
121418
121442
|
}
|
|
121419
121443
|
if (/another_request_unresolved/.test(reason)) return `finish the earlier payment (rerun its pay command) or close it (${CLI2} help cancel); ${CLI2} balance lists it`;
|
|
121420
121444
|
if (/resource_cli_out_unwritable/.test(reason)) return "the payment is recorded, but the --out file could not be written; rerun the same pay command (same --request-id) with a --out path you can write: it replays the receipt and never pays twice";
|
|
121445
|
+
if (/p03_facilitator_underfunded/.test(reason)) {
|
|
121446
|
+
const again = command.name === "unshield" ? "rerun the same command with a new --unshield-id" : command.name === "pocket fill" ? "rerun the same pocket fill command (it starts the fill again with a new quote)" : "pay again with a new --request-id";
|
|
121447
|
+
return `the facilitator cannot pay network fees right now (its settler is below its funding gate); nothing was spent. The wallet closed the request and released its reserved amount. Try again later: ${again}`;
|
|
121448
|
+
}
|
|
121421
121449
|
if (/p03_resource_payment_refused_pay_again_new_request_id/.test(reason)) {
|
|
121422
121450
|
const again = command.name === "unshield" ? "rerun the same command with a new --unshield-id" : "pay again with a new --request-id";
|
|
121423
121451
|
return `the facilitator refused this payment before any money moved (for example its quote ran out, the facilitator was short of fee funds, or the payment failed a fixed check; the line names the seller's code). The wallet closed the request and released its reserved amount; ${again}`;
|