shinjuku-shield 0.3.136 → 0.3.138
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 +5 -5
- package/manifest.json +4 -4
- package/package.json +3 -3
- package/shinjuku-wallet.mjs +324 -36
package/README.md
CHANGED
|
@@ -6,19 +6,19 @@ 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.
|
|
9
|
+
This is version 0.3.138. The npm packages `shinjuku-shield` and
|
|
10
10
|
`shinjuku-shielded` hold the same files. The command is `shinjuku`.
|
|
11
11
|
|
|
12
12
|
## Set up
|
|
13
13
|
|
|
14
14
|
```sh
|
|
15
|
-
npm install -g shinjuku@0.3.
|
|
15
|
+
npm install -g shinjuku@0.3.138
|
|
16
16
|
shinjuku setup
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Type the two lines as they are. `npx install shinjuku` does not work: npx
|
|
20
20
|
reads `install` as the name of another npm package. To set up without
|
|
21
|
-
installing, type `npx shinjuku@0.3.
|
|
21
|
+
installing, type `npx shinjuku@0.3.138 setup`.
|
|
22
22
|
|
|
23
23
|
Setup makes the wallet on this machine, a private passphrase file, and the
|
|
24
24
|
checked proof tools (about 191 MB), and writes `config.json`. It also writes
|
|
@@ -36,13 +36,13 @@ Every wallet command works after `shinjuku`, for example `shinjuku balance`,
|
|
|
36
36
|
Claude Code:
|
|
37
37
|
|
|
38
38
|
```sh
|
|
39
|
-
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.
|
|
39
|
+
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.138 mcp
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
Claude Desktop (`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):
|
|
43
43
|
|
|
44
44
|
```json
|
|
45
|
-
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.
|
|
45
|
+
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.138", "mcp"] } } }
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
On native Windows, if the host cannot find `npx`, use `"command": "cmd"` and
|
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": "5bfd21041455a7de19335b0e0d943f0bbbf61823f50124656586a5cbb8fe2e95",
|
|
5
|
+
"bytes": 8916541,
|
|
6
|
+
"sourceCommit": "d8bee04b8e02e00509302854d9259e8163aa8bd5",
|
|
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",
|
|
@@ -1037,5 +1037,5 @@
|
|
|
1037
1037
|
"version": "1.8.0"
|
|
1038
1038
|
}
|
|
1039
1039
|
],
|
|
1040
|
-
"publishedAt": "2026-
|
|
1040
|
+
"publishedAt": "2026-11-01T01:48:06.179Z"
|
|
1041
1041
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shield",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.138",
|
|
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": "5bfd2104",
|
|
7
|
+
"shinjukuSha256": "5bfd21041455a7de19335b0e0d943f0bbbf61823f50124656586a5cbb8fe2e95",
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"author": "Shinjuku Shielded",
|
|
10
10
|
"homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
|
package/shinjuku-wallet.mjs
CHANGED
|
@@ -66416,11 +66416,13 @@ var init_errorCodes = __esm({
|
|
|
66416
66416
|
"p03_resource_payment_another_request_unresolved",
|
|
66417
66417
|
"p03_resource_payment_resource_mismatch",
|
|
66418
66418
|
"p03_resource_payment_answer_not_kept",
|
|
66419
|
+
"p03_resource_paid_seller_failed",
|
|
66419
66420
|
"p03_seller_anchor_not_ready",
|
|
66420
66421
|
"p03_seller_http_failed",
|
|
66421
66422
|
"p03_seller_lock_release_failed",
|
|
66422
66423
|
"p03_seller_ready",
|
|
66423
66424
|
"p03_seller_start_failed",
|
|
66425
|
+
"p03_seller_upstream_failed",
|
|
66424
66426
|
"p03_service_resource_nonce_invalid",
|
|
66425
66427
|
"pay_refused",
|
|
66426
66428
|
"pay_to_checksum_invalid",
|
|
@@ -72400,7 +72402,7 @@ import { dirname as dirname12, isAbsolute as isAbsolute4, join as join11, resolv
|
|
|
72400
72402
|
function retiredPoolText(pool2, npmVersion) {
|
|
72401
72403
|
const next = RETIRED_POOLS[pool2];
|
|
72402
72404
|
if (!next) return void 0;
|
|
72403
|
-
return `pool ${pool2} is retired: Shinjuku
|
|
72405
|
+
return `pool ${pool2} is retired: Shinjuku runs a newer pool now, and nothing serves the old pool. It held no user balance when it was retired. Your old wallet file stays where it is; run ${oneTimeCommandLine("setup", npmVersion)} to make a wallet for the new pool`;
|
|
72404
72406
|
}
|
|
72405
72407
|
function holdsWallet(dir) {
|
|
72406
72408
|
if (existsSync(join11(dir, CONFIG_FILE))) return true;
|
|
@@ -73014,10 +73016,11 @@ var init_config = __esm({
|
|
|
73014
73016
|
memoService: DEFAULT_FACILITATOR_ORIGIN
|
|
73015
73017
|
});
|
|
73016
73018
|
RETIRED_POOLS = Object.freeze({
|
|
73017
|
-
// Setup moves an AAG16 config.json to the pool the facilitator runs NOW (setup.mjs
|
|
73019
|
+
// Setup moves an AAG16 config.json to the pool the facilitator runs NOW (setup.mjs takes the release's pool).
|
|
73018
73020
|
AAG16mNWTtC1sBeu2tTVTwWjqWXCefLTCByVPj5X3kV8: "F7MWGF8vG8Bv3Y4pRRFqky5YzZndGtQaUXbMMvpmtoRV",
|
|
73019
|
-
// 45mh (production 2026-10-10 to 2026-10-12) drained into F7MW; its vault held only our own notes
|
|
73020
|
-
// 2026-10-13 (docs/x402 slice 01
|
|
73021
|
+
// 45mh (production 2026-10-10 to 2026-10-12) drained into F7MW; its vault held only our own notes, went to 0 USDC and
|
|
73022
|
+
// its tree was closed on 2026-10-13 (docs/x402 slice 01; the pool account and the empty vault account stay open on
|
|
73023
|
+
// chain). A home still on it paid nothing: the float refused its refundTo (float_body_invalid).
|
|
73021
73024
|
"45mhosfA2MuygZWeqYRVcEZX2Q3gA8KR8FwP6AZkK1zR": "F7MWGF8vG8Bv3Y4pRRFqky5YzZndGtQaUXbMMvpmtoRV"
|
|
73022
73025
|
});
|
|
73023
73026
|
NO_LIMIT_ATOMIC = "18446744073709551615";
|
|
@@ -81131,6 +81134,7 @@ var init_config2 = __esm({
|
|
|
81131
81134
|
init_fs();
|
|
81132
81135
|
import_web3111 = __toESM(require_index_cjs(), 1);
|
|
81133
81136
|
init_sellerKey();
|
|
81137
|
+
init_rpcDefault();
|
|
81134
81138
|
fail16 = (code2) => {
|
|
81135
81139
|
throw new Error(`p03_seller_${code2}`);
|
|
81136
81140
|
};
|
|
@@ -82294,6 +82298,67 @@ async function createSellerAdapter({
|
|
|
82294
82298
|
throw error;
|
|
82295
82299
|
}
|
|
82296
82300
|
}
|
|
82301
|
+
async function callUpstream(offer, body, contentType) {
|
|
82302
|
+
const path = new URL(offer.url).pathname;
|
|
82303
|
+
const upstream = config.routes.find((candidate) => candidate.method === offer.method && candidate.path === path)?.upstream;
|
|
82304
|
+
if (!upstream) return upstreamFailure();
|
|
82305
|
+
let answeredStatus;
|
|
82306
|
+
try {
|
|
82307
|
+
const response = await fetchImpl(upstream.url, {
|
|
82308
|
+
method: offer.method,
|
|
82309
|
+
redirect: "error",
|
|
82310
|
+
signal: AbortSignal.timeout(upstream.timeoutMs),
|
|
82311
|
+
headers: { ...upstream.headers, ...offer.method === "POST" ? { "Content-Type": contentType } : {} },
|
|
82312
|
+
...offer.method === "POST" ? { body } : {}
|
|
82313
|
+
});
|
|
82314
|
+
if (response.status < 200 || response.status > 299) {
|
|
82315
|
+
await response.body?.cancel();
|
|
82316
|
+
return upstreamFailure(response.status);
|
|
82317
|
+
}
|
|
82318
|
+
answeredStatus = response.status;
|
|
82319
|
+
if (Number(response.headers.get("content-length")) > UPSTREAM_BODY_MAX) {
|
|
82320
|
+
await response.body?.cancel();
|
|
82321
|
+
return upstreamFailure(answeredStatus);
|
|
82322
|
+
}
|
|
82323
|
+
const chunks = [];
|
|
82324
|
+
let size = 0;
|
|
82325
|
+
const reader = response.body?.getReader();
|
|
82326
|
+
if (reader) {
|
|
82327
|
+
try {
|
|
82328
|
+
while (true) {
|
|
82329
|
+
const { done, value: value2 } = await reader.read();
|
|
82330
|
+
if (done) break;
|
|
82331
|
+
size += value2.length;
|
|
82332
|
+
if (size > UPSTREAM_BODY_MAX) {
|
|
82333
|
+
await reader.cancel();
|
|
82334
|
+
return upstreamFailure(answeredStatus);
|
|
82335
|
+
}
|
|
82336
|
+
chunks.push(Buffer.from(value2));
|
|
82337
|
+
}
|
|
82338
|
+
} finally {
|
|
82339
|
+
reader.releaseLock();
|
|
82340
|
+
}
|
|
82341
|
+
}
|
|
82342
|
+
const type = response.headers.get("content-type");
|
|
82343
|
+
return {
|
|
82344
|
+
status: response.status,
|
|
82345
|
+
contentType: typeof type === "string" && /^[\x20-\x7e]{1,128}$/.test(type) ? type : offer.resource?.mimeType ?? "application/octet-stream",
|
|
82346
|
+
bodyBase64: Buffer.concat(chunks).toString("base64")
|
|
82347
|
+
};
|
|
82348
|
+
} catch {
|
|
82349
|
+
return upstreamFailure(answeredStatus);
|
|
82350
|
+
}
|
|
82351
|
+
}
|
|
82352
|
+
async function paidReply(nonce, offer, body, contentType, mark) {
|
|
82353
|
+
let paid = offer;
|
|
82354
|
+
if (!paid.result && paid.upstream) {
|
|
82355
|
+
const result = await callUpstream(paid, body, contentType);
|
|
82356
|
+
paid = { ...paid, result };
|
|
82357
|
+
await put(nonce, paid);
|
|
82358
|
+
mark(result.status === 502 ? "upstream-failed" : "upstream-answered");
|
|
82359
|
+
}
|
|
82360
|
+
return { status: paid.result.status, result: paid.result, receipt: paid.receipt };
|
|
82361
|
+
}
|
|
82297
82362
|
async function renewPreSettlementAcceptance(nonce, offer, read) {
|
|
82298
82363
|
if (offer.settleAttempted) fail16("acceptance_renewal_after_settlement_refused");
|
|
82299
82364
|
const outbound = JSON.parse(offer.outboundJson);
|
|
@@ -82316,7 +82381,7 @@ async function createSellerAdapter({
|
|
|
82316
82381
|
await put(nonce, renewed);
|
|
82317
82382
|
return renewed;
|
|
82318
82383
|
}
|
|
82319
|
-
async function acceptPayment(route, body, header2, arrivedAt) {
|
|
82384
|
+
async function acceptPayment(route, body, header2, arrivedAt, contentType) {
|
|
82320
82385
|
const payment = decodePayment(header2);
|
|
82321
82386
|
const nonce = payment.accepted?.extra?.resourceNonce;
|
|
82322
82387
|
const mark = timing.start();
|
|
@@ -82333,7 +82398,7 @@ async function createSellerAdapter({
|
|
|
82333
82398
|
}
|
|
82334
82399
|
if (!visible) return { status: 202, code: "payment_pending_retry_same_payment" };
|
|
82335
82400
|
}
|
|
82336
|
-
return
|
|
82401
|
+
return paidReply(nonce, original, body, contentType, mark);
|
|
82337
82402
|
}
|
|
82338
82403
|
let offer = original;
|
|
82339
82404
|
let intakeChain;
|
|
@@ -82460,7 +82525,7 @@ async function createSellerAdapter({
|
|
|
82460
82525
|
if (!firstIntake) mark("claim");
|
|
82461
82526
|
if (claimed) {
|
|
82462
82527
|
offer = await persistReceipt(nonce, offer, claimed, mark);
|
|
82463
|
-
return
|
|
82528
|
+
return await paidReply(nonce, offer, body, contentType, mark);
|
|
82464
82529
|
}
|
|
82465
82530
|
if (!offer.settleAttempted) {
|
|
82466
82531
|
const chain = await preVerifyRead;
|
|
@@ -82496,7 +82561,7 @@ async function createSellerAdapter({
|
|
|
82496
82561
|
};
|
|
82497
82562
|
}
|
|
82498
82563
|
offer = await persistReceipt(nonce, offer, receipt, mark);
|
|
82499
|
-
return
|
|
82564
|
+
return await paidReply(nonce, offer, body, contentType, mark);
|
|
82500
82565
|
} catch (error) {
|
|
82501
82566
|
mark("failed", timingCode(error));
|
|
82502
82567
|
if (!offer.outboundJson && error?.message === "p03_quote_expired") return { status: 202, code: PAYMENT_REFUSED };
|
|
@@ -82512,14 +82577,14 @@ async function createSellerAdapter({
|
|
|
82512
82577
|
if (!route || origin === void 0 || origin === config.publicOrigin || !(config.aliasOrigins ?? []).includes(origin)) return route;
|
|
82513
82578
|
return { ...route, resource: { ...route.resource, url: `${origin}${route.path}` } };
|
|
82514
82579
|
};
|
|
82515
|
-
async function handleUnlocked({ method, path, body, paymentHeader, origin, arrivedAt }) {
|
|
82580
|
+
async function handleUnlocked({ method, path, body, paymentHeader, origin, arrivedAt, contentType }) {
|
|
82516
82581
|
const route = resourceAt(config.routes.find((candidate) => candidate.method === method && candidate.path === path), origin);
|
|
82517
82582
|
if (paymentHeader !== void 0) return acceptPayment(route ?? {
|
|
82518
82583
|
method,
|
|
82519
82584
|
resource: { url: `${(config.aliasOrigins ?? []).includes(origin) ? origin : config.publicOrigin}${path}` }
|
|
82520
|
-
}, body, paymentHeader, arrivedAt);
|
|
82585
|
+
}, body, paymentHeader, arrivedAt, forwardedContentType(contentType));
|
|
82521
82586
|
if (!route) return { status: 404, code: "resource_not_found" };
|
|
82522
|
-
const result = route.resultFor ? await route.resultFor(body) : route.result;
|
|
82587
|
+
const result = route.upstream ? void 0 : route.resultFor ? await route.resultFor(body) : route.result;
|
|
82523
82588
|
if (route.resultFor && (result?.status !== 200 || typeof result.contentType !== "string" || typeof result.bodyBase64 !== "string")) fail16("route_result_invalid");
|
|
82524
82589
|
const mark = timing.start();
|
|
82525
82590
|
const anchor = await readAnchor({ requireCapacity: true });
|
|
@@ -82556,7 +82621,7 @@ async function createSellerAdapter({
|
|
|
82556
82621
|
bodyDigest,
|
|
82557
82622
|
nonceOpening,
|
|
82558
82623
|
paymentRequired: issued.paymentRequired,
|
|
82559
|
-
result
|
|
82624
|
+
...route.upstream ? { upstream: true } : { result }
|
|
82560
82625
|
};
|
|
82561
82626
|
await put(nonce, offer);
|
|
82562
82627
|
mark("challenge");
|
|
@@ -82591,7 +82656,13 @@ async function createSellerAdapter({
|
|
|
82591
82656
|
return;
|
|
82592
82657
|
}
|
|
82593
82658
|
const body = await limitedBody(request);
|
|
82594
|
-
const result = await handle({
|
|
82659
|
+
const result = await handle({
|
|
82660
|
+
method: request.method,
|
|
82661
|
+
path: request.url,
|
|
82662
|
+
body,
|
|
82663
|
+
paymentHeader,
|
|
82664
|
+
contentType: request.headers["content-type"]
|
|
82665
|
+
});
|
|
82595
82666
|
const reply = sellerHttpReply(result);
|
|
82596
82667
|
response.statusCode = reply.status;
|
|
82597
82668
|
for (const [name, value2] of Object.entries(reply.headers)) response.setHeader(name, value2);
|
|
@@ -82650,7 +82721,7 @@ async function createSellerAdapter({
|
|
|
82650
82721
|
};
|
|
82651
82722
|
return { server, handle, close, signerPublicKey, settledTransactions, offerSummaries, discardUnsentOffer };
|
|
82652
82723
|
}
|
|
82653
|
-
var import_web3113, LOOPBACK_ORIGIN, BINDING, SCHEMA2, OFFERS_LAYOUT, SNAPSHOT_EVERY_MS, LOADER2, canonical4, storeProfileIdentity, jsonSafe, bigint, encodeHeader, PROGRAM_DATA_HEADER_BYTES, hashedProgramDataHeaders, PAYMENT_REFUSED, FACILITATOR_UNDERFUNDED, DEFINITE_VERIFY_REFUSALS, definiteVerifyRefusal, refusedBeforeSettlement, ANCHOR_REQUEST_TIMEOUT_MS2, ANCHOR_POLL_ATTEMPTS, ANCHOR_POLL_MS, ANCHOR_BUSY_DEFAULT_SECONDS, ANCHOR_BUSY_MAX_SECONDS, MEMO_PRECOMPUTES_MAX, MEMO_PRECOMPUTE_WAIT_MS, WALLET_MERCHANT_SLOT, PRE_SETTLE_REUSE_MARGIN_S, PRE_SETTLE_REUSE_MAX_AGE_MS, FINALIZED_MEMO_MAX_AGE_MS, INTAKE_REUSE_MAX_AGE_MS, pause, FOLLOW_UP_DELAYS_MS, FOLLOW_UP_RESETTLE_FROM, CONFIRMED_TRANSACTION_READ;
|
|
82724
|
+
var import_web3113, LOOPBACK_ORIGIN, BINDING, SCHEMA2, OFFERS_LAYOUT, SNAPSHOT_EVERY_MS, LOADER2, canonical4, storeProfileIdentity, jsonSafe, bigint, encodeHeader, PROGRAM_DATA_HEADER_BYTES, hashedProgramDataHeaders, PAYMENT_REFUSED, FACILITATOR_UNDERFUNDED, DEFINITE_VERIFY_REFUSALS, definiteVerifyRefusal, refusedBeforeSettlement, ANCHOR_REQUEST_TIMEOUT_MS2, ANCHOR_POLL_ATTEMPTS, ANCHOR_POLL_MS, ANCHOR_BUSY_DEFAULT_SECONDS, ANCHOR_BUSY_MAX_SECONDS, MEMO_PRECOMPUTES_MAX, MEMO_PRECOMPUTE_WAIT_MS, WALLET_MERCHANT_SLOT, PRE_SETTLE_REUSE_MARGIN_S, PRE_SETTLE_REUSE_MAX_AGE_MS, FINALIZED_MEMO_MAX_AGE_MS, INTAKE_REUSE_MAX_AGE_MS, pause, FOLLOW_UP_DELAYS_MS, FOLLOW_UP_RESETTLE_FROM, UPSTREAM_FAILED, UPSTREAM_BODY_MAX, upstreamFailure, forwardedContentType, CONFIRMED_TRANSACTION_READ;
|
|
82654
82725
|
var init_service = __esm({
|
|
82655
82726
|
"wallet/src/seller/service.mjs"() {
|
|
82656
82727
|
"use strict";
|
|
@@ -82732,6 +82803,17 @@ var init_service = __esm({
|
|
|
82732
82803
|
6e5
|
|
82733
82804
|
]);
|
|
82734
82805
|
FOLLOW_UP_RESETTLE_FROM = 4;
|
|
82806
|
+
UPSTREAM_FAILED = "p03_seller_upstream_failed";
|
|
82807
|
+
UPSTREAM_BODY_MAX = 1024 * 1024;
|
|
82808
|
+
upstreamFailure = (upstreamStatus) => ({
|
|
82809
|
+
status: 502,
|
|
82810
|
+
contentType: "application/json",
|
|
82811
|
+
bodyBase64: Buffer.from(JSON.stringify({
|
|
82812
|
+
code: UPSTREAM_FAILED,
|
|
82813
|
+
...upstreamStatus === void 0 ? {} : { upstreamStatus }
|
|
82814
|
+
})).toString("base64")
|
|
82815
|
+
});
|
|
82816
|
+
forwardedContentType = (value2) => typeof value2 === "string" && /^[\x20-\x7e]{1,128}$/.test(value2) ? value2 : "application/octet-stream";
|
|
82735
82817
|
CONFIRMED_TRANSACTION_READ = Object.freeze({ commitment: "confirmed", maxSupportedTransactionVersion: 1 });
|
|
82736
82818
|
}
|
|
82737
82819
|
});
|
|
@@ -101395,6 +101477,18 @@ function floatOutcomeWords(code2, error, t) {
|
|
|
101395
101477
|
return t.ai ? [code2, `the AI provider cannot be paid now: ${why}${asks}; nothing was paid`, t.ai.other] : [code2, `this seller cannot be paid: ${why}${asks}; nothing was paid`, `Do not pay this URL. Pay a different seller${t.discover}`];
|
|
101396
101478
|
}
|
|
101397
101479
|
switch (code2) {
|
|
101480
|
+
case PAID_SELLER_FAILED_CODE: {
|
|
101481
|
+
const status = Number.isInteger(error?.httpStatus) ? ` (it answered HTTP ${error.httpStatus}${typeof error?.sellerCode === "string" ? `, ${error.sellerCode}` : ""})` : "";
|
|
101482
|
+
const paid = ATOMIC4.test(String(error?.paidAtomic ?? "")) ? totalText(error) : ATOMIC4.test(String(error?.priceAtomic ?? "")) ? usdcWords(error.priceAtomic) : "the price";
|
|
101483
|
+
const kept2 = error?.replayed === true ? " This is the answer the wallet kept for this request; nothing was sent or paid again." : "";
|
|
101484
|
+
const support = typeof error?.transaction === "string" ? ` (give them the transaction ${error.transaction})` : "";
|
|
101485
|
+
const later = t.ai ? t.ai.other : `If ${stillWants(t)} the data, try ${p.this} later with ${t.newId} (that is a new payment), once its service works, or ask ${p.the}'s support about this payment${support}`;
|
|
101486
|
+
return [
|
|
101487
|
+
code2,
|
|
101488
|
+
`PAID ${paid}: the payment went through${withTransaction(error)}, and ${p.the} has it, but ${p.the}'s own service failed after it took the payment${status}, so no data came back.${kept2}`,
|
|
101489
|
+
`Do not ${t.noRepeat}: the same request gets the same error and never pays twice, and no refund comes from Shinjuku. ${later}`
|
|
101490
|
+
];
|
|
101491
|
+
}
|
|
101398
101492
|
case "p03_float_refund_pending":
|
|
101399
101493
|
case "p03_float_answer_invalid_refund_pending": {
|
|
101400
101494
|
const amount = amountText(error?.paidAtomic, "the amount paid");
|
|
@@ -101576,7 +101670,7 @@ function floatOutcomeWords(code2, error, t) {
|
|
|
101576
101670
|
return void 0;
|
|
101577
101671
|
}
|
|
101578
101672
|
}
|
|
101579
|
-
var ATOMIC4, TRANSFER_DEAD_WORDS, payeeOf, floatSellerCanBeFixed, floatSeller4xx, answeredInstead, floatStillSettling, floatChargeTooLate, amountText, withTransaction, stillWants, AI_SERVER_WRONG, QUOTE_REFUSED_WHY;
|
|
101673
|
+
var ATOMIC4, TRANSFER_DEAD_WORDS, payeeOf, floatSellerCanBeFixed, floatSeller4xx, answeredInstead, floatStillSettling, floatChargeTooLate, amountText, withTransaction, PAID_SELLER_FAILED_CODE, stillWants, AI_SERVER_WRONG, QUOTE_REFUSED_WHY;
|
|
101580
101674
|
var init_floatWords = __esm({
|
|
101581
101675
|
"wallet/src/pay/floatWords.mjs"() {
|
|
101582
101676
|
"use strict";
|
|
@@ -101595,6 +101689,7 @@ var init_floatWords = __esm({
|
|
|
101595
101689
|
floatChargeTooLate = (error) => error?.sellerChargeFailed === true && Number.isSafeInteger(error?.sellerAnswerSeconds) && error.sellerAnswerSeconds > 25;
|
|
101596
101690
|
amountText = (atomic4, missing) => ATOMIC4.test(String(atomic4 ?? "")) ? usdcWords(atomic4) : missing;
|
|
101597
101691
|
withTransaction = (error) => typeof error?.transaction === "string" ? ` (${error.transaction})` : "";
|
|
101692
|
+
PAID_SELLER_FAILED_CODE = "p03_resource_paid_seller_failed";
|
|
101598
101693
|
stillWants = (t) => t.userReads === true ? "you still want" : "the user still wants";
|
|
101599
101694
|
AI_SERVER_WRONG = "the Shinjuku server in this wallet's settings cannot make this payment; nothing was paid";
|
|
101600
101695
|
QUOTE_REFUSED_WHY = Object.freeze({
|
|
@@ -103809,7 +103904,34 @@ async function payViaFloat({
|
|
|
103809
103904
|
}
|
|
103810
103905
|
const lostAnswer = record.state === "submitted";
|
|
103811
103906
|
const wasKept = record.state === "seller_kept";
|
|
103907
|
+
const sellerFailedKept = (status, transaction, sellerReason, { replayed = false, resent = false } = {}) => {
|
|
103908
|
+
const landedTransaction = isSolanaSignature(transaction) ? transaction : record.landedTransaction;
|
|
103909
|
+
if (record.state !== "seller_kept" || record.sellerFailed !== true || record.sellerStatus !== status || record.landedTransaction !== landedTransaction) {
|
|
103910
|
+
record = {
|
|
103911
|
+
...record,
|
|
103912
|
+
state: "seller_kept",
|
|
103913
|
+
sellerFailed: true,
|
|
103914
|
+
sellerKeptAtMs: record.sellerKeptAtMs ?? Date.now(),
|
|
103915
|
+
...Number.isInteger(status) ? { sellerStatus: status } : {},
|
|
103916
|
+
...isSolanaSignature(landedTransaction) ? { landedTransaction } : {}
|
|
103917
|
+
};
|
|
103918
|
+
store.writeWal(walName2, record);
|
|
103919
|
+
}
|
|
103920
|
+
throw Object.assign(paidSellerFailedError({
|
|
103921
|
+
httpStatus: record.sellerStatus,
|
|
103922
|
+
transaction: record.landedTransaction,
|
|
103923
|
+
paidAtomic: record.paidAtomic,
|
|
103924
|
+
priceAtomic: record.priceAtomic,
|
|
103925
|
+
feeAtomic: record.feeAtomic,
|
|
103926
|
+
floatId: record.floatId,
|
|
103927
|
+
replayed,
|
|
103928
|
+
resent
|
|
103929
|
+
}), sellerReason ? { sellerReason } : {});
|
|
103930
|
+
};
|
|
103812
103931
|
const keptAgain = (status, sellerReason) => {
|
|
103932
|
+
if (record.sellerFailed === true) {
|
|
103933
|
+
sellerFailedKept(record.sellerStatus, record.landedTransaction, sellerReason, { replayed: true, resent: record.keptResent === true });
|
|
103934
|
+
}
|
|
103813
103935
|
if (Number.isInteger(status) && record.sellerStatus !== status) {
|
|
103814
103936
|
record = { ...record, sellerStatus: status };
|
|
103815
103937
|
store.writeWal(walName2, record);
|
|
@@ -103825,7 +103947,7 @@ async function payViaFloat({
|
|
|
103825
103947
|
resent: true
|
|
103826
103948
|
});
|
|
103827
103949
|
};
|
|
103828
|
-
if (wasKept && record.keptResent === true) keptAgain();
|
|
103950
|
+
if (wasKept && (record.keptResent === true || record.sellerFailed === true)) keptAgain();
|
|
103829
103951
|
if (record.requestPruned === true) {
|
|
103830
103952
|
if (wasKept) finishedPruned(record);
|
|
103831
103953
|
if (lostAnswer) byVerdict(await floatVerdict(record, fetchImpl, statusSleep, verdictUntil(Date.now())), {}, {});
|
|
@@ -104003,6 +104125,9 @@ async function payViaFloat({
|
|
|
104003
104125
|
store.writeWal(walName2, record);
|
|
104004
104126
|
refundPendingAnswer(record, sellerReason ? { sellerReason } : {});
|
|
104005
104127
|
}
|
|
104128
|
+
if (state?.state === "final" && response.status >= 500) {
|
|
104129
|
+
sellerFailedKept(response.status, state.transaction, sellerReason);
|
|
104130
|
+
}
|
|
104006
104131
|
if (state?.state === "final") {
|
|
104007
104132
|
fail20("p03_float_seller_unanswered_paid_retry_same_request", {
|
|
104008
104133
|
httpStatus: response.status,
|
|
@@ -104097,6 +104222,17 @@ async function selfBroadcastLeg({ store, walName: walName2, record, sendRequest,
|
|
|
104097
104222
|
store.writeWal(walName2, record);
|
|
104098
104223
|
refundPendingAnswer(record);
|
|
104099
104224
|
};
|
|
104225
|
+
if (record.state === "seller_kept" && record.sellerFailed === true) {
|
|
104226
|
+
throw paidSellerFailedError({
|
|
104227
|
+
httpStatus: record.sellerStatus,
|
|
104228
|
+
transaction: isSolanaSignature(record.broadcastSignature) ? record.broadcastSignature : record.landedTransaction,
|
|
104229
|
+
paidAtomic: record.paidAtomic,
|
|
104230
|
+
priceAtomic: record.priceAtomic,
|
|
104231
|
+
feeAtomic: record.feeAtomic,
|
|
104232
|
+
floatId: record.floatId,
|
|
104233
|
+
replayed: true
|
|
104234
|
+
});
|
|
104235
|
+
}
|
|
104100
104236
|
if (!isSolanaSignature(record.broadcastSignature)) {
|
|
104101
104237
|
if (record.state === "seller_kept") keptUnknown();
|
|
104102
104238
|
const settleUrl = new URL("/api/x402/settle", new URL(record.payUrlPrefix).origin).href;
|
|
@@ -104254,6 +104390,20 @@ async function selfBroadcastLeg({ store, walName: walName2, record, sendRequest,
|
|
|
104254
104390
|
attempt -= 1;
|
|
104255
104391
|
continue;
|
|
104256
104392
|
}
|
|
104393
|
+
if (response.status >= 500) {
|
|
104394
|
+
record = {
|
|
104395
|
+
...record,
|
|
104396
|
+
state: "seller_kept",
|
|
104397
|
+
sellerFailed: true,
|
|
104398
|
+
sellerStatus: response.status,
|
|
104399
|
+
sellerKeptAtMs: record.sellerKeptAtMs ?? Date.now()
|
|
104400
|
+
};
|
|
104401
|
+
store.writeWal(walName2, record);
|
|
104402
|
+
throw Object.assign(
|
|
104403
|
+
paidSellerFailedError({ httpStatus: response.status, ...landed }),
|
|
104404
|
+
unansweredReason ? { sellerReason: unansweredReason } : {}
|
|
104405
|
+
);
|
|
104406
|
+
}
|
|
104257
104407
|
fail20("p03_float_seller_unanswered_paid_retry_same_request", {
|
|
104258
104408
|
httpStatus: response.status,
|
|
104259
104409
|
...unansweredReason ? { sellerReason: unansweredReason } : {},
|
|
@@ -106338,6 +106488,31 @@ async function unconfirmedResponseError(response) {
|
|
|
106338
106488
|
}
|
|
106339
106489
|
return error;
|
|
106340
106490
|
}
|
|
106491
|
+
function paidSellerFailedError({
|
|
106492
|
+
httpStatus,
|
|
106493
|
+
sellerCode,
|
|
106494
|
+
transaction,
|
|
106495
|
+
paidAtomic,
|
|
106496
|
+
priceAtomic,
|
|
106497
|
+
feeAtomic,
|
|
106498
|
+
floatId,
|
|
106499
|
+
replayed = false,
|
|
106500
|
+
resent
|
|
106501
|
+
} = {}) {
|
|
106502
|
+
const atomic4 = (value2) => /^[0-9]+$/.test(String(value2 ?? "")) ? String(value2) : void 0;
|
|
106503
|
+
return Object.assign(new Error("p03_resource_paid_seller_failed"), {
|
|
106504
|
+
paid: true,
|
|
106505
|
+
replayed: replayed === true,
|
|
106506
|
+
...Number.isSafeInteger(httpStatus) ? { httpStatus } : {},
|
|
106507
|
+
...typeof sellerCode === "string" && sellerCode ? { sellerCode } : {},
|
|
106508
|
+
...typeof transaction === "string" && transaction ? { transaction } : {},
|
|
106509
|
+
...atomic4(paidAtomic) ? { paidAtomic: atomic4(paidAtomic) } : {},
|
|
106510
|
+
...atomic4(priceAtomic) ? { priceAtomic: atomic4(priceAtomic) } : {},
|
|
106511
|
+
...atomic4(feeAtomic) ? { feeAtomic: atomic4(feeAtomic) } : {},
|
|
106512
|
+
...typeof floatId === "string" && floatId ? { floatId } : {},
|
|
106513
|
+
...resent === true ? { resent: true } : {}
|
|
106514
|
+
});
|
|
106515
|
+
}
|
|
106341
106516
|
async function readBounded(response, limit) {
|
|
106342
106517
|
const reader = response.body.getReader();
|
|
106343
106518
|
const chunks = [];
|
|
@@ -107264,7 +107439,10 @@ async function payResourceOnce({
|
|
|
107264
107439
|
let current = record;
|
|
107265
107440
|
if (isPending(current)) {
|
|
107266
107441
|
current = await finalizePendingReceipt({ store, connection, programId, name: walName2, ...finalityWait, deps: finality });
|
|
107267
|
-
if (isPending(current))
|
|
107442
|
+
if (isPending(current)) {
|
|
107443
|
+
if (current.sellerFailed !== void 0) throw directPaidSellerFailed(current, { replayed: true, amountAtomic: recordAmount() });
|
|
107444
|
+
fail24("receipt_finality_pending_retry_same_request");
|
|
107445
|
+
}
|
|
107268
107446
|
}
|
|
107269
107447
|
if (current.receiptFinality === "never-finalized") {
|
|
107270
107448
|
releaseNeverFinalizedReservation({ store, requestId });
|
|
@@ -107272,6 +107450,9 @@ async function payResourceOnce({
|
|
|
107272
107450
|
}
|
|
107273
107451
|
if (current.receiptMismatch) fail24("receipt_payment_transaction_mismatch");
|
|
107274
107452
|
if (current.answerMissing) fail24("refused_payment_landed_no_answer");
|
|
107453
|
+
if (current.sellerFailed !== void 0) {
|
|
107454
|
+
throw directPaidSellerFailed(current, { replayed: true, amountAtomic: recordAmount() });
|
|
107455
|
+
}
|
|
107275
107456
|
if (current.memoryOnly === true) {
|
|
107276
107457
|
const kept2 = current.answerNotKept === true ? void 0 : memoryAnswer(current);
|
|
107277
107458
|
if (kept2 === void 0) {
|
|
@@ -107687,11 +107868,13 @@ async function payResourceOnce({
|
|
|
107687
107868
|
}
|
|
107688
107869
|
mark("answered");
|
|
107689
107870
|
const encoded = response.headers.get("PAYMENT-RESPONSE");
|
|
107690
|
-
|
|
107871
|
+
const receiptCarried = Boolean(encoded) && encoded.length <= 128 * 1024;
|
|
107872
|
+
const paidError = !response.ok && response.status >= 400 && receiptCarried;
|
|
107873
|
+
if (landed && !paidError && (!response.ok || !receiptCarried)) {
|
|
107691
107874
|
await response.body?.cancel();
|
|
107692
107875
|
recordLandedWithoutAnswer(store, walName2, record);
|
|
107693
107876
|
}
|
|
107694
|
-
if (!response.ok || !
|
|
107877
|
+
if (!paidError && (!response.ok || !receiptCarried)) {
|
|
107695
107878
|
const unconfirmed = await unconfirmedResponseError(response);
|
|
107696
107879
|
if (response.status === 202 && unconfirmed.sellerCode === SELLER_REFUSED_PAY_AGAIN) {
|
|
107697
107880
|
store.writeWal(walName2, { ...record, state: "cancelled", refused: { sellerCode: unconfirmed.sellerCode } });
|
|
@@ -107713,12 +107896,36 @@ async function payResourceOnce({
|
|
|
107713
107896
|
receipt = decodePaymentResponseHeader(encoded);
|
|
107714
107897
|
validateReceipt(receipt, record, store.state, programId, { acceptFronted: deps.acceptFrontedReceipt === true });
|
|
107715
107898
|
} catch (error) {
|
|
107899
|
+
if (paidError) {
|
|
107900
|
+
const unconfirmed = await unconfirmedResponseError(response);
|
|
107901
|
+
if (landed) recordLandedWithoutAnswer(store, walName2, record);
|
|
107902
|
+
throw unconfirmed;
|
|
107903
|
+
}
|
|
107716
107904
|
if (landed) {
|
|
107717
107905
|
await response.body?.cancel();
|
|
107718
107906
|
recordLandedWithoutAnswer(store, walName2, record);
|
|
107719
107907
|
}
|
|
107720
107908
|
throw error;
|
|
107721
107909
|
}
|
|
107910
|
+
if (paidError) {
|
|
107911
|
+
const said = await unconfirmedResponseError(response);
|
|
107912
|
+
const fronted2 = receipt.extra.finality === "fronted";
|
|
107913
|
+
const answeredSettleSlot2 = fronted2 ? void 0 : receiptSettleSlot(receipt.extra?.settleSlot);
|
|
107914
|
+
const failedRecord = {
|
|
107915
|
+
...record,
|
|
107916
|
+
state: "receipt",
|
|
107917
|
+
receipt,
|
|
107918
|
+
receiptFinality: "pending",
|
|
107919
|
+
answeredAtMs: Date.now(),
|
|
107920
|
+
sellerFailed: { httpStatus: response.status, ...said.sellerCode ? { sellerCode: said.sellerCode } : {} },
|
|
107921
|
+
...fronted2 ? { fronted: true } : {},
|
|
107922
|
+
...answeredSettleSlot2 !== void 0 ? { answeredSettleSlot: answeredSettleSlot2 } : {}
|
|
107923
|
+
};
|
|
107924
|
+
store.writeWal(walName2, failedRecord);
|
|
107925
|
+
mark("receipt-seller-failed");
|
|
107926
|
+
withPhaseScope(mark, "anchor-next", () => requestSubAnchorForNewLeaf());
|
|
107927
|
+
throw directPaidSellerFailed(failedRecord, { amountAtomic: recordAmount() });
|
|
107928
|
+
}
|
|
107722
107929
|
let resultBase64;
|
|
107723
107930
|
try {
|
|
107724
107931
|
resultBase64 = await readResult(response);
|
|
@@ -107744,7 +107951,7 @@ async function payResourceOnce({
|
|
|
107744
107951
|
withPhaseScope(mark, "anchor-next", () => requestSubAnchorForNewLeaf());
|
|
107745
107952
|
return { replayed: false, receipt, resultBase64, receiptFinality: "pending" };
|
|
107746
107953
|
}
|
|
107747
|
-
var import_web3118, fail24, failResource, failUnresolved, hash9, OWNER_UNSHIELD_REQUEST, OWNER_UNSHIELD_ORIGIN, POCKET_FILL_ID, POOL_MOVE_PATH2, RECEIPT_FINALITY_TIMEOUT_MS, RECEIPT_FINALITY_POLL_MS, FINALITY_GATE_MARGIN_SLOTS, FINALITY_GATE_POLL_MS, FINALITY_GATE_CLAIM_POLL_MS, FINALITY_GATE_CLAIM_TIMEOUT_MS, FINALITY_GATE_CLAIM_GRACE_MS, FINALITY_GATE_SETTLE_MARGIN_SLOTS, FINALITY_GATE_SETTLE_WINDOW_SLOTS, receiptSettleSlot, FINALITY_GATE_SKIP_AFTER_MS, PENDING_FINALITY, isPending, REPLAY_INPUTS2, PAYMENT_OUTPUT_INPUT2, QUOTE_MARGIN_SECONDS, SUBMIT_CLOCK_MARGIN_SECONDS, SELLER_REFUSED_PAY_AGAIN, SELLER_REASON_FACILITATOR_UNDERFUNDED, ANCHOR_EPOCH_MS, ANCHOR_MARGIN_MS, ANCHOR_WAIT_CAP_MS, FLOAT_OPEN_STATES, closedFloats, floatReadAt, FLOAT_READ_AGAIN_MS, FLOAT_SETTLE_READS, DEAD_PAYMENT_MARGIN_SECONDS, SYSVAR_OWNER, quoteLiveAt, payloadOf, sentPaymentOf, replayValuesOf, finalPayments, FINAL_UNCHANGED, PRIOR_SCAN_YIELD_EVERY;
|
|
107954
|
+
var import_web3118, fail24, failResource, failUnresolved, hash9, OWNER_UNSHIELD_REQUEST, OWNER_UNSHIELD_ORIGIN, POCKET_FILL_ID, POOL_MOVE_PATH2, RECEIPT_FINALITY_TIMEOUT_MS, RECEIPT_FINALITY_POLL_MS, FINALITY_GATE_MARGIN_SLOTS, FINALITY_GATE_POLL_MS, FINALITY_GATE_CLAIM_POLL_MS, FINALITY_GATE_CLAIM_TIMEOUT_MS, FINALITY_GATE_CLAIM_GRACE_MS, FINALITY_GATE_SETTLE_MARGIN_SLOTS, FINALITY_GATE_SETTLE_WINDOW_SLOTS, receiptSettleSlot, FINALITY_GATE_SKIP_AFTER_MS, PENDING_FINALITY, isPending, REPLAY_INPUTS2, PAYMENT_OUTPUT_INPUT2, QUOTE_MARGIN_SECONDS, SUBMIT_CLOCK_MARGIN_SECONDS, SELLER_REFUSED_PAY_AGAIN, SELLER_REASON_FACILITATOR_UNDERFUNDED, ANCHOR_EPOCH_MS, ANCHOR_MARGIN_MS, ANCHOR_WAIT_CAP_MS, directPaidSellerFailed, FLOAT_OPEN_STATES, closedFloats, floatReadAt, FLOAT_READ_AGAIN_MS, FLOAT_SETTLE_READS, DEAD_PAYMENT_MARGIN_SECONDS, SYSVAR_OWNER, quoteLiveAt, payloadOf, sentPaymentOf, replayValuesOf, finalPayments, FINAL_UNCHANGED, PRIOR_SCAN_YIELD_EVERY;
|
|
107748
107955
|
var init_payResource = __esm({
|
|
107749
107956
|
"wallet/src/pay/payResource.mjs"() {
|
|
107750
107957
|
"use strict";
|
|
@@ -107826,6 +108033,14 @@ var init_payResource = __esm({
|
|
|
107826
108033
|
ANCHOR_EPOCH_MS = 3e5;
|
|
107827
108034
|
ANCHOR_MARGIN_MS = 2e4;
|
|
107828
108035
|
ANCHOR_WAIT_CAP_MS = ANCHOR_EPOCH_MS + 6e4;
|
|
108036
|
+
directPaidSellerFailed = (record, { replayed = false, amountAtomic } = {}) => paidSellerFailedError({
|
|
108037
|
+
httpStatus: record?.sellerFailed?.httpStatus,
|
|
108038
|
+
sellerCode: record?.sellerFailed?.sellerCode,
|
|
108039
|
+
transaction: record?.receipt?.transaction,
|
|
108040
|
+
paidAtomic: amountAtomic,
|
|
108041
|
+
priceAtomic: amountAtomic,
|
|
108042
|
+
replayed
|
|
108043
|
+
});
|
|
107829
108044
|
FLOAT_OPEN_STATES = /* @__PURE__ */ new Set(["float_paid", "broadcasting", "broadcast", "submitted"]);
|
|
107830
108045
|
closedFloats = /* @__PURE__ */ new Map();
|
|
107831
108046
|
floatReadAt = /* @__PURE__ */ new Map();
|
|
@@ -108374,7 +108589,14 @@ function spendSentence(a, tails = ["."], room = SAY_MAX_WORDS) {
|
|
|
108374
108589
|
const refund = refundInFlight(a);
|
|
108375
108590
|
const refunds = !positive(refund) ? [""] : a.refreshReason === "refund_check" ? [`, plus a ${refund} USDC refund the wallet is checking`, `, plus ${refund} refund being checked`] : [`, plus ${refund} USDC refund on its way`, `, plus ${refund} refund coming`];
|
|
108376
108591
|
const unsure = usdcText2(a.breakdown?.refundsNotCertainAtomic);
|
|
108377
|
-
const
|
|
108592
|
+
const open4 = usdcText2(a.breakdown?.openPaymentsAtomic);
|
|
108593
|
+
const longNotes = [
|
|
108594
|
+
positive(open4) ? `${open4} USDC is in a payment still waiting on its seller; asking again finishes it, else it comes back by itself` : "",
|
|
108595
|
+
positive(unsure) ? `${unsure} USDC more is not certain yet` : ""
|
|
108596
|
+
].filter(Boolean);
|
|
108597
|
+
const shortNotes = [positive(open4) ? `${open4} USDC waits on its seller` : "", positive(unsure) ? `${unsure} more not certain yet` : ""].filter(Boolean);
|
|
108598
|
+
const midNotes = [positive(open4) ? `${open4} USDC waits on its seller; asking again finishes it, else it comes back` : "", ...shortNotes.slice(positive(open4) ? 1 : 0)];
|
|
108599
|
+
const unsures = longNotes.length ? [[` (${longNotes.join("; ")})`, ` (${midNotes.join("; ")})`, ` (${shortNotes.join("; ")})`], [""]] : [[""]];
|
|
108378
108600
|
const lines = unsures.flatMap((notes) => tails.flatMap((tail) => heads.flatMap((head) => notes.flatMap((note) => refunds.map((part) => `${head}${part}${note}${tail}`)))));
|
|
108379
108601
|
return lines.find((line) => words(line) <= room) ?? lines.at(-1);
|
|
108380
108602
|
}
|
|
@@ -108548,6 +108770,15 @@ function refusalSay(a, tool, again, npmVersion) {
|
|
|
108548
108770
|
`Not known yet if ${seller} kept ${what}. Nothing to do now.`
|
|
108549
108771
|
].find((line) => words(line) <= SAY_MAX_WORDS) ?? `Not known yet if ${seller} kept ${what}. Nothing to do now.`;
|
|
108550
108772
|
}
|
|
108773
|
+
if (code2 === "p03_resource_paid_seller_failed") {
|
|
108774
|
+
const failed = Number.isInteger(a.httpStatus) ? `${seller}'s service failed (HTTP ${a.httpStatus})` : `${seller}'s service failed`;
|
|
108775
|
+
const paid = total ? `Paid ${total} USDC` : "Paid";
|
|
108776
|
+
return [
|
|
108777
|
+
`${paid}, but ${failed} after it took the payment. Do not pay again now; try later, or ask ${seller}'s support.`,
|
|
108778
|
+
`${paid}, but ${failed}. Do not pay again now; try later, or ask ${seller}.`,
|
|
108779
|
+
`${paid}, but ${failed}. Do not pay again now.`
|
|
108780
|
+
].find((line) => words(line) <= SAY_MAX_WORDS) ?? `${paid}, but ${failed}. Do not pay again now.`;
|
|
108781
|
+
}
|
|
108551
108782
|
if (code2 === "p03_float_transfer_expired") {
|
|
108552
108783
|
const status = Number.isInteger(a.httpStatus);
|
|
108553
108784
|
const head = status ? `${Seller} ${sellerAnswered(a.httpStatus, data)}.` : `No ${data} came back in time.`;
|
|
@@ -109003,6 +109234,7 @@ function zeroOnTheWay(a) {
|
|
|
109003
109234
|
if (Object.hasOwn(a, "depositArrivingAtomic")) return `your deposit${of(a.depositArrivingAtomic)} is on its way; ask again once it arrives.`;
|
|
109004
109235
|
if (Object.hasOwn(a, "refundComingAtomic")) return `a refund${of(a.refundComingAtomic)} is on its way to it; ask again once it arrives.`;
|
|
109005
109236
|
if (Object.hasOwn(a, "refundMayComeAtomic")) return `a refund${of(a.refundMayComeAtomic)} may still come back to it; that is not certain yet.`;
|
|
109237
|
+
if (Object.hasOwn(a, "paymentWaitingAtomic")) return `a payment${of(a.paymentWaitingAtomic)} waits on its seller; asking again finishes it, else it comes back by itself.`;
|
|
109006
109238
|
return void 0;
|
|
109007
109239
|
}
|
|
109008
109240
|
function emptyUnshieldSay(a) {
|
|
@@ -112203,6 +112435,8 @@ function floatRefunds(store, snapshot) {
|
|
|
112203
112435
|
let notCertain = 0n;
|
|
112204
112436
|
const provenFor = [];
|
|
112205
112437
|
const notCertainFor = [];
|
|
112438
|
+
let open4 = 0n;
|
|
112439
|
+
const openFor = [];
|
|
112206
112440
|
for (const name of store.listWal()) {
|
|
112207
112441
|
if (!name.startsWith(FLOAT_PAYMENT_WAL_PREFIX2)) continue;
|
|
112208
112442
|
let record;
|
|
@@ -112216,6 +112450,12 @@ function floatRefunds(store, snapshot) {
|
|
|
112216
112450
|
if (floatLegNeverLanded(store, record.innerRequestId)) continue;
|
|
112217
112451
|
const state = floatRecordState(record);
|
|
112218
112452
|
const refusedOpen = state === "submitted" && record.ambiguous === true;
|
|
112453
|
+
if (state === "submitted" && !refusedOpen && !floatRefundHeld(snapshot, record)) {
|
|
112454
|
+
const { refundAtomic, ...payment } = refundOf(record);
|
|
112455
|
+
open4 += BigInt(record.paidAtomic);
|
|
112456
|
+
openFor.push({ ...payment, paidAtomic: refundAtomic });
|
|
112457
|
+
continue;
|
|
112458
|
+
}
|
|
112219
112459
|
if (state !== "refund_pending" && !refusedOpen || floatRefundHeld(snapshot, record)) continue;
|
|
112220
112460
|
if (refusedOpen || !knowsRecipients) {
|
|
112221
112461
|
notCertain += BigInt(record.paidAtomic);
|
|
@@ -112225,7 +112465,7 @@ function floatRefunds(store, snapshot) {
|
|
|
112225
112465
|
provenFor.push(refundOf(record));
|
|
112226
112466
|
}
|
|
112227
112467
|
}
|
|
112228
|
-
return { proven, notCertain, provenFor, notCertainFor };
|
|
112468
|
+
return { proven, notCertain, provenFor, notCertainFor, open: open4, openFor };
|
|
112229
112469
|
}
|
|
112230
112470
|
function balanceView(store) {
|
|
112231
112471
|
const neverReceived = /* @__PURE__ */ new Set();
|
|
@@ -112263,6 +112503,7 @@ function partsOf(report, store, snapshot) {
|
|
|
112263
112503
|
changeUpToAtomic: null,
|
|
112264
112504
|
refundsInFlightAtomic: null,
|
|
112265
112505
|
refundsNotCertainAtomic: null,
|
|
112506
|
+
openPaymentsAtomic: null,
|
|
112266
112507
|
setAsideAtomic: null,
|
|
112267
112508
|
totalAtomic: null,
|
|
112268
112509
|
privateSendPendingAtomic: report?.split?.privateSendPendingAtomic ?? null,
|
|
@@ -112286,6 +112527,8 @@ function partsOf(report, store, snapshot) {
|
|
|
112286
112527
|
refundsNotCertainAtomic: refunds.notCertain.toString(),
|
|
112287
112528
|
refundsInFlight: refunds.provenFor,
|
|
112288
112529
|
refundsNotCertain: refunds.notCertainFor,
|
|
112530
|
+
openPaymentsAtomic: refunds.open.toString(),
|
|
112531
|
+
openPayments: refunds.openFor,
|
|
112289
112532
|
setAsideAtomic: setAside.toString(),
|
|
112290
112533
|
totalAtomic: (spendable + setAside + refunds.proven).toString(),
|
|
112291
112534
|
privateSendPendingAtomic: report.split.privateSendPendingAtomic,
|
|
@@ -112331,6 +112574,14 @@ function balanceNow(store, { programId, source = "local", now, firstDepositEstim
|
|
|
112331
112574
|
return null;
|
|
112332
112575
|
}
|
|
112333
112576
|
}
|
|
112577
|
+
function openPaymentWords(parts) {
|
|
112578
|
+
if (!POSITIVE2.test(String(parts?.openPaymentsAtomic ?? ""))) return "";
|
|
112579
|
+
const list = Array.isArray(parts.openPayments) ? parts.openPayments : [];
|
|
112580
|
+
const one = list.length === 1 ? list[0] : void 0;
|
|
112581
|
+
const which = one?.seller ? `the payment to ${one.seller}` : list.length > 1 ? "those payments" : "that payment";
|
|
112582
|
+
const rerun = one?.requestId ? `run the same command again with --request-id ${one.requestId}` : "run the same command again with its --request-id";
|
|
112583
|
+
return `To finish ${which}, ${rerun} (it never pays twice); if the seller never takes it, Shinjuku sends it back to your private balance by itself within about ${Math.round(FLOAT_REFUND_ETA_SECONDS / 60)} minutes.`;
|
|
112584
|
+
}
|
|
112334
112585
|
function balanceWords(parts, { afterSend = false } = {}) {
|
|
112335
112586
|
const prepareCommand = commandLine("prepare");
|
|
112336
112587
|
const heads = parts && parts.spendableAtomic !== null ? spendHeads(parts.spendableAtomic, parts.largestPaymentAtomic, parts, { surface: "cli", prepareCommand }) : [];
|
|
@@ -112338,6 +112589,7 @@ function balanceWords(parts, { afterSend = false } = {}) {
|
|
|
112338
112589
|
if (spend === void 0) return void 0;
|
|
112339
112590
|
const positive2 = (atomic4) => POSITIVE2.test(String(atomic4 ?? ""));
|
|
112340
112591
|
const notes = [
|
|
112592
|
+
positive2(parts.openPaymentsAtomic) ? `${usdcWords(parts.openPaymentsAtomic)} in a payment waiting on its seller` : "",
|
|
112341
112593
|
positive2(parts.refundsNotCertainAtomic) ? `${usdcWords(parts.refundsNotCertainAtomic)} refund not certain yet` : "",
|
|
112342
112594
|
positive2(parts.setAsideAtomic) ? `${usdcWords(parts.setAsideAtomic)} set aside by an older version` : ""
|
|
112343
112595
|
].filter(Boolean);
|
|
@@ -112418,11 +112670,12 @@ function knownShortBalance(store, { needAtomic = 1n, payment = false, maxAgeMs }
|
|
|
112418
112670
|
addFundsOpen: deposits2.some((deposit) => deposit.addFunds),
|
|
112419
112671
|
refundsInFlightAtomic: parts.refundsInFlightAtomic,
|
|
112420
112672
|
refundsNotCertainAtomic: parts.refundsNotCertainAtomic,
|
|
112673
|
+
openPaymentsAtomic: parts.openPaymentsAtomic,
|
|
112421
112674
|
parts
|
|
112422
112675
|
};
|
|
112423
112676
|
}
|
|
112424
112677
|
function plainZero(short, { deposits: deposits2 = false } = {}) {
|
|
112425
|
-
return short !== void 0 && !short.receivedOnly && BigInt(short.spendableAtomic) === 0n && (deposits2 || short.deposits.length === 0) && ![short.refundsInFlightAtomic, short.refundsNotCertainAtomic].some((atomic4) => ABOVE_0.test(String(atomic4 ?? "")));
|
|
112678
|
+
return short !== void 0 && !short.receivedOnly && BigInt(short.spendableAtomic) === 0n && (deposits2 || short.deposits.length === 0) && ![short.refundsInFlightAtomic, short.refundsNotCertainAtomic, short.openPaymentsAtomic].some((atomic4) => ABOVE_0.test(String(atomic4 ?? "")));
|
|
112426
112679
|
}
|
|
112427
112680
|
function shortBalanceSentences(short, { costAtomic, outcome = short.payment ? "paid" : "send" } = {}) {
|
|
112428
112681
|
const balance = usdcWords(short.spendableAtomic);
|
|
@@ -112431,6 +112684,9 @@ function shortBalanceSentences(short, { costAtomic, outcome = short.payment ? "p
|
|
|
112431
112684
|
const sentences = [short.receivedOnly ? `${spendHeads(short.spendableAtomic, "0", { report: short.parts?.report })[0]}.${outcome === "paid" ? ` ${paid}` : ""}` : outcome === "none" ? `Your private balance is ${balance}.` : outcome === "send" ? BigInt(short.spendableAtomic) === 0n ? `Your private balance is ${balance}, so there is nothing to send.` : `Your private balance is ${balance}, less than ${usdcWords(short.needAtomic)}, so nothing was sent.` : cost ? `Your private balance is ${balance}. ${paid}` : `Your private balance is ${balance}, so nothing was paid.`];
|
|
112432
112685
|
if (ABOVE_0.test(String(short.refundsInFlightAtomic ?? ""))) sentences.push(`A refund of ${usdcWords(short.refundsInFlightAtomic)} is on its way to your private balance.`);
|
|
112433
112686
|
if (ABOVE_0.test(String(short.refundsNotCertainAtomic ?? ""))) sentences.push(`A refund of ${usdcWords(short.refundsNotCertainAtomic)} may still come back; that is not certain yet.`);
|
|
112687
|
+
if (ABOVE_0.test(String(short.openPaymentsAtomic ?? ""))) {
|
|
112688
|
+
sentences.push(`A payment of ${usdcWords(short.openPaymentsAtomic)} waits on its seller: asking for the same thing again finishes it (it never pays twice); if the seller never takes it, it comes back to your private balance by itself within about ${Math.round(FLOAT_REFUND_ETA_SECONDS / 60)} minutes.`);
|
|
112689
|
+
}
|
|
112434
112690
|
for (const addFunds2 of [false, true]) {
|
|
112435
112691
|
const open4 = short.deposits.filter((deposit) => deposit.addFunds === addFunds2);
|
|
112436
112692
|
if (!open4.length) continue;
|
|
@@ -112448,6 +112704,7 @@ var init_knownZero = __esm({
|
|
|
112448
112704
|
"use strict";
|
|
112449
112705
|
init_balanceNow();
|
|
112450
112706
|
init_usdcWords();
|
|
112707
|
+
init_floatPay();
|
|
112451
112708
|
ATOMIC6 = /^[0-9]{1,31}$/;
|
|
112452
112709
|
ABOVE_0 = /^0*[1-9]/;
|
|
112453
112710
|
}
|
|
@@ -128967,6 +129224,9 @@ function balanceFields(parts) {
|
|
|
128967
129224
|
// another payment's 0.011 USDC refund with no payment named, and the agent read it as this payment's refund.
|
|
128968
129225
|
...parts.refundsInFlight?.length ? { refundsInFlight: parts.refundsInFlight } : {},
|
|
128969
129226
|
...parts.refundsNotCertain?.length ? { refundsNotCertain: parts.refundsNotCertain } : {},
|
|
129227
|
+
// UX136-1: a payment whose seller answered an error while Shinjuku's transfer is open (balanceNow.mjs openPaymentsAtomic).
|
|
129228
|
+
openPaymentsAtomic: parts.openPaymentsAtomic,
|
|
129229
|
+
...parts.openPayments?.length ? { openPayments: parts.openPayments } : {},
|
|
128970
129230
|
setAsideAtomic: parts.setAsideAtomic,
|
|
128971
129231
|
totalAtomic: parts.totalAtomic,
|
|
128972
129232
|
// Parts of a running wallet_unshield private send not sent yet: already taken off shieldedAtomic (R4, no overspend in flight).
|
|
@@ -129520,7 +129780,7 @@ function createWalletTools({
|
|
|
129520
129780
|
const parts = balanceNow(session.openStore(), { programId: session.programId });
|
|
129521
129781
|
if (ATOMIC_TEXT.test(String(parts?.totalAtomic ?? ""))) {
|
|
129522
129782
|
const atomicOf = (value2) => ATOMIC_TEXT.test(String(value2 ?? "")) ? BigInt(value2) : 0n;
|
|
129523
|
-
whole = BigInt(parts.totalAtomic) + atomicOf(parts.refundsNotCertainAtomic) + (parts.report?.detail?.pendingDeposits ?? []).reduce((sum2, deposit) => sum2 + atomicOf(deposit?.amountAtomic), 0n);
|
|
129783
|
+
whole = BigInt(parts.totalAtomic) + atomicOf(parts.refundsNotCertainAtomic) + atomicOf(parts.openPaymentsAtomic) + (parts.report?.detail?.pendingDeposits ?? []).reduce((sum2, deposit) => sum2 + atomicOf(deposit?.amountAtomic), 0n);
|
|
129524
129784
|
}
|
|
129525
129785
|
} catch {
|
|
129526
129786
|
whole = void 0;
|
|
@@ -130354,12 +130614,14 @@ ${canonical5}`;
|
|
|
130354
130614
|
const above0 = (atomic4) => /^0*[1-9]/.test(String(atomic4 ?? "")) ? String(atomic4) : void 0;
|
|
130355
130615
|
const refund = above0(short.refundsInFlightAtomic);
|
|
130356
130616
|
const mayCome = above0(short.refundsNotCertainAtomic);
|
|
130617
|
+
const waitsOnSeller = above0(short.openPaymentsAtomic);
|
|
130357
130618
|
return {
|
|
130358
130619
|
balanceAtomic: "0",
|
|
130359
130620
|
...waiting.length ? { depositWaitingAtomic: sum2(waiting), ...waiting.some((deposit) => deposit.addFunds) ? { depositAddFunds: true } : {} } : {},
|
|
130360
130621
|
...arriving.length ? { depositArrivingAtomic: sum2(arriving) } : {},
|
|
130361
130622
|
...refund ? { refundComingAtomic: refund } : {},
|
|
130362
|
-
...mayCome ? { refundMayComeAtomic: mayCome } : {}
|
|
130623
|
+
...mayCome ? { refundMayComeAtomic: mayCome } : {},
|
|
130624
|
+
...waitsOnSeller ? { paymentWaitingAtomic: waitsOnSeller } : {}
|
|
130363
130625
|
};
|
|
130364
130626
|
};
|
|
130365
130627
|
const shortZeroStep = (short, then) => {
|
|
@@ -131147,6 +131409,9 @@ ${canonical5}`;
|
|
|
131147
131409
|
...error?.resent === true ? { resent: true } : {},
|
|
131148
131410
|
...error?.pruned === true ? { pruned: true } : {},
|
|
131149
131411
|
...typeof error?.floatCode === "string" ? { floatCode: error.floatCode } : {},
|
|
131412
|
+
// AB164: the seller's own code beside its error after it took the payment (floatWords.mjs PAID_SELLER_FAILED_CODE).
|
|
131413
|
+
...code2 === PAID_SELLER_FAILED_CODE && typeof error?.sellerCode === "string" ? { sellerCode: error.sellerCode } : {},
|
|
131414
|
+
...code2 === PAID_SELLER_FAILED_CODE && error?.replayed === true ? { replayed: true } : {},
|
|
131150
131415
|
...typeof error?.priceAtomic === "string" ? { priceAtomic: error.priceAtomic } : {},
|
|
131151
131416
|
...typeof error?.feeAtomic === "string" ? { feeAtomic: error.feeAtomic } : {},
|
|
131152
131417
|
// conversationNotKept (floatPay.mjs finishedPruned): a private conversation, whose answer the wallet never kept.
|
|
@@ -131679,6 +131944,9 @@ ${canonical5}`;
|
|
|
131679
131944
|
const inFlight = /^[1-9][0-9]*$/.test(String(one.breakdown?.refundsInFlightAtomic ?? "")) && !refundNotices?.length ? usdcText3(one.breakdown.refundsInFlightAtomic) : void 0;
|
|
131680
131945
|
const checking = refresh.refreshing === true && (refresh.refreshReason === void 0 || refresh.refreshReason === "refund_check");
|
|
131681
131946
|
const lines = [!known ? `Private balance: not known yet (${reading})${landing}` : checking ? `Private balance: last known ${usdcText3(one.balanceAtomic)} USDC${inFlight ? `, plus a ${inFlight} USDC refund` : ""}; the wallet is checking it now${landing}` : `Private balance: ${spendHeads(one.balanceAtomic, one.largestPaymentAtomic, one)[0].replace(/^You /, "you ")}${inFlight ? `, plus ${inFlight} USDC refund on its way` : ""}${landing}`];
|
|
131947
|
+
if (/^[1-9][0-9]*$/.test(String(one.breakdown?.openPaymentsAtomic ?? ""))) {
|
|
131948
|
+
lines.push(`Payment waiting on its seller: ${usdcText3(one.breakdown.openPaymentsAtomic)} USDC (asking for the same thing again finishes it and never pays twice; if the seller never takes it, Shinjuku sends it back by itself within about ${Math.round(FLOAT_REFUND_ETA_SECONDS / 60)} minutes)`);
|
|
131949
|
+
}
|
|
131682
131950
|
if (ATOMIC_TEXT.test(String(unshielded.unshieldedAtomic ?? ""))) lines.push(`Public USDC on this wallet's own key: ${usdcText3(unshielded.unshieldedAtomic)} USDC`);
|
|
131683
131951
|
let mode;
|
|
131684
131952
|
try {
|
|
@@ -131708,7 +131976,7 @@ ${canonical5}`;
|
|
|
131708
131976
|
const balance = {
|
|
131709
131977
|
name: "wallet_balance",
|
|
131710
131978
|
title: "Balance",
|
|
131711
|
-
description: `Use this when the user asks "what is my balance" or "how much USDC do I have": it answers ONE balance (balanceAtomic, what a payment can spend) and the public (unshielded) USDC. Always safe: it ${BALANCE_READ_DOES}.
|
|
131979
|
+
description: `Use this when the user asks "what is my balance" or "how much USDC do I have": it answers ONE balance (balanceAtomic, what a payment can spend) and the public (unshielded) USDC. Always safe: it ${BALANCE_READ_DOES}. On "show my wallet", print \`card\` as it is (at most 8 lines). largestPaymentAtomic: the most ONE payment can spend now; a payment above it is not refused: x402_pay gets the balance ready first (a tell-first answer, then doneInMinutesLow to doneInMinutesHigh minutes) (changeSettling: 0 only while the last payment's change settles, about changeReadyInSeconds; then one payment can use it all, or up to changeUpToAtomic). balanceParts (only above 1): never tell the user about parts, accounts or a merge; say only that a large payment or send first gets the balance ready. balanceAtomic is one number; breakdown names the rest (shieldedAtomic is the same value; privateSendPendingAtomic is what a running private send has not sent yet, already taken off; refundsInFlightAtomic is a refund Shinjuku proved, on its way, not in balanceAtomic; refundsNotCertainAtomic a refund the seller may have kept, in no number; openPaymentsAtomic: paid, waiting on its seller (same request_id finishes it, else refunded);setAsideAtomic (when not 0): value an older version set aside; totalAtomic adds these; during a pool move, pools lists each pool's share and movingAtomic is value on its way from the old pool to the new one; the move field shows the move, poolSwitches each switch). unshieldedAtomic is the public USDC on the wallet's own Solana key (ownAddress), which wallet_shield makes private; unshieldedSolLamports is that key's SOL (Shinjuku pays every fee and rent). A stale balance (a new deposit, a received payment) reads the chain first; past about 20 s it answers the last balance with refreshing: true and finishes in the background (call again in 30 s). A balance with refreshing: true and refreshReason is exact (payment_settling: a payment settles and the number counts it; account_join: the wallet gets its own balance ready to send and the number counts all of it; pool_move: value from the old pool arrives and the number counts it; refund_check: a refund counted from an old read, which the wallet checks now (never tell the user it is still on its way); first_check: a new wallet's first history check, the number is its own landed deposits). status reading (balanceAtomic null): the first balance read of a wallet that may hold money is not done; call wallet_balance again in 30 s. If the public read fails, unshieldedAtomic is null with unshieldedReason. ownKeyTokens: the other tokens on ownAddress (not its USDC; [] when none; null when not read now: say nothing of other tokens), each { mint, amountAtomic, decimals, amount }, at most 10 (ownKeyTokensMore counts the rest); a token is its mint, never a name or symbol; wallet_transfer_token with that mint as token_mint sells one and sends the USDC privately. earlierDeposits (when any): USDC at an earlier pool's one-time deposit address, each with a notice line to tell the user; the wallet moves it by itself. addFunds (when any): each wallet_add_funds address still open, with its state and the USDC known to wait there (heldAtomic; null with heldNote when not read in time). startsAtNextRequest true (old name): its deposit starts by itself once USDC is seen there (startsInMinutes; 0: at once). landingAtomic (only when not 0): USDC you added whose deposit landed on chain and that balanceAtomic does not count yet; this call finishes it and waits about 20 s for it, past that it is being counted: call wallet_balance again when next says. session: the spending limits (null or "none": no limit), what is left, and how to change them (session.summary, only when a limit is set). With no limit set, say nothing about limits or the session counters. To add money, use wallet_add_funds. version: this wallet's version. Amounts are atomic units (1000000 = 1 USDC); say and usdc give USDC.`,
|
|
131712
131980
|
inputSchema: { type: "object", properties: {
|
|
131713
131981
|
verbose: { type: "boolean", description: "Optional. true adds `internal`: the engineering numbers (funded balance records, notes, payments without waiting, a 0 set-aside value). Default false." }
|
|
131714
131982
|
}, additionalProperties: false },
|
|
@@ -132473,6 +132741,18 @@ ${canonical5}`;
|
|
|
132473
132741
|
};
|
|
132474
132742
|
const rows2 = [];
|
|
132475
132743
|
const refundHeld = refundWalkHolds(store);
|
|
132744
|
+
const sellerFailedFields = (record) => {
|
|
132745
|
+
const failed = record?.sellerFailed;
|
|
132746
|
+
if (!failed) return {};
|
|
132747
|
+
const status = [failed?.httpStatus, record?.sellerStatus].find(Number.isInteger);
|
|
132748
|
+
const code2 = [failed?.sellerCode, record?.sellerCode].find((one) => typeof one === "string" && /^[a-z][a-z0-9_]{0,63}$/.test(one));
|
|
132749
|
+
return {
|
|
132750
|
+
sellerFailed: true,
|
|
132751
|
+
...status !== void 0 ? { httpStatus: status } : {},
|
|
132752
|
+
...code2 ? { sellerCode: code2 } : {},
|
|
132753
|
+
note: `paid: the payment went through and the seller has it, but the seller's service failed after it took the payment${status !== void 0 ? ` (HTTP ${status}${code2 ? `, ${code2}` : ""})` : ""}, so no data came back and no refund comes; asking for the same request again gets the same error and pays nothing`
|
|
132754
|
+
};
|
|
132755
|
+
};
|
|
132476
132756
|
const row = (key, record, view2, extra) => {
|
|
132477
132757
|
const at = Number.isSafeInteger(record.answeredAtMs) ? record.answeredAtMs : -1;
|
|
132478
132758
|
const transaction = view2.sellerTransaction ?? view2.privateTransaction ?? (typeof record.receipt?.transaction === "string" && record.receipt.transaction !== "" ? record.receipt.transaction : sigOrNull(record.settledTransaction));
|
|
@@ -132559,7 +132839,7 @@ ${canonical5}`;
|
|
|
132559
132839
|
scheme: "exact",
|
|
132560
132840
|
state: !refunded ? "seller_kept" : told.state,
|
|
132561
132841
|
...refund,
|
|
132562
|
-
...refunded ? {} : { note: "the seller took this payment and did not serve the request; no refund comes" }
|
|
132842
|
+
...refunded ? {} : { note: "the seller took this payment and did not serve the request; no refund comes", ...sellerFailedFields(record) }
|
|
132563
132843
|
}
|
|
132564
132844
|
);
|
|
132565
132845
|
continue;
|
|
@@ -132591,7 +132871,7 @@ ${canonical5}`;
|
|
|
132591
132871
|
if (record?.state !== "receipt" || String(record.url ?? "").startsWith(SELF_PAY_ORIGIN3)) continue;
|
|
132592
132872
|
const key = name.slice(shielded ? RESOURCE_PAYMENT_WAL_PREFIX2.length : POCKET_PAYMENT_WAL_PREFIX.length);
|
|
132593
132873
|
if (isFloatLegRecord(record) && !openLegKeys.has(key)) continue;
|
|
132594
|
-
row(key, record, receiptView(record), { scheme: shielded ? "shielded-exact" : "exact", ...record.receiptFinality === "never-finalized" ? NEVER_LANDED :
|
|
132874
|
+
row(key, record, receiptView(record), { scheme: shielded ? "shielded-exact" : "exact", ...record.receiptFinality === "never-finalized" ? NEVER_LANDED : sellerFailedFields(record) });
|
|
132595
132875
|
}
|
|
132596
132876
|
return rows2;
|
|
132597
132877
|
}
|
|
@@ -132876,7 +133156,7 @@ ${canonical5}`;
|
|
|
132876
133156
|
const receipts = {
|
|
132877
133157
|
name: "wallet_receipts",
|
|
132878
133158
|
title: "List recent receipts and wallet moves",
|
|
132879
|
-
description: `List this wallet's most recent receipts, newest first. Payments (kind x402 or inference): seller (the URL paid), sellerHost, item (what was bought), priceAtomic, feeAtomic, amountAtomic (the total), sellerTransaction, privateTransaction (this wallet's private payment), facilitator, answeredAt, and transaction / host (the seller's when known). pay.shinjukustaition.com is Shinjuku, the private payment service, never the seller. A payment the seller did not take shows state refund_pending (the refund is on its way; floatId, refundState: Shinjuku's refund step in words), refund_sent once Shinjuku sent it (refundTransaction; the balance counts it at a later read), then refunded once the balance holds it. A payment the seller has not served yet shows waiting_for_seller (or seller_paid_not_served once the transfer to the seller landed): call x402_pay again with its requestId to get it. seller_refused (the seller refused it, sellerStatus) or outcome_not_certain (an earlier send got no clear answer): not certain yet whether the seller kept the payment; do not pay again until the row changes. never_landed: the payment never went through; nothing was paid and nothing comes back. The wallet's own moves (kind shield, add-funds, unshield, private-send, token-transfer, or an older deposit kind): requestId, amountAtomic, state, transaction, at; a private-send row with smaller payments still to go shows partsAt (the time and state of each) and next (it is not stuck); a token-transfer row (wallet_transfer_token) shows tokenMint, tokenAmountAtomic, usdcAtomic (what the sell gave) and sentAtomic; an add-funds row also shows heldAtomic, the USDC waiting at its address (it becomes private by itself: never close an address that holds USDC; belowMinimum: less than minimumAtomic waits there for a top-up). An add-funds row with via "cli" was made by the shinjuku add-funds command in a terminal: amountAtomic, state (done or not_finished), transaction; it has no requestId, and wallet_add_funds never continues it. An unshield row with via "cli" is this wallet's own send, made by the shinjuku unshield command in a terminal: amountAtomic, state (sent, not_finished, not_sent), transaction, and next (with unshieldId, the terminal's own id) when it is not finished; it has no requestId, and wallet_unshield never continues it. A received payment (kind received, a move): amountAtomic and state done; at is null and it sorts last (no sender, no time). requestId is shown for payments made by this wallet process; older ones show requestKey (its SHA-256). kind "payments" or "moves" lists one group only.`,
|
|
133159
|
+
description: `List this wallet's most recent receipts, newest first. Payments (kind x402 or inference): seller (the URL paid), sellerHost, item (what was bought), priceAtomic, feeAtomic, amountAtomic (the total), sellerTransaction, privateTransaction (this wallet's private payment), facilitator, answeredAt, and transaction / host (the seller's when known). pay.shinjukustaition.com is Shinjuku, the private payment service, never the seller. A payment the seller did not take shows state refund_pending (the refund is on its way; floatId, refundState: Shinjuku's refund step in words), refund_sent once Shinjuku sent it (refundTransaction; the balance counts it at a later read), then refunded once the balance holds it. A payment the seller has not served yet shows waiting_for_seller (or seller_paid_not_served once the transfer to the seller landed): call x402_pay again with its requestId to get it. seller_refused (the seller refused it, sellerStatus) or outcome_not_certain (an earlier send got no clear answer): not certain yet whether the seller kept the payment; do not pay again until the row changes. never_landed: the payment never went through; nothing was paid and nothing comes back. sellerFailed: true (with httpStatus, sellerCode): paid, but the seller's service failed after it took the payment, so no data came back and no refund comes; never call x402_pay again with its requestId (same error, nothing paid); a new payment is the user's choice, later. The wallet's own moves (kind shield, add-funds, unshield, private-send, token-transfer, or an older deposit kind): requestId, amountAtomic, state, transaction, at; a private-send row with smaller payments still to go shows partsAt (the time and state of each) and next (it is not stuck); a token-transfer row (wallet_transfer_token) shows tokenMint, tokenAmountAtomic, usdcAtomic (what the sell gave) and sentAtomic; an add-funds row also shows heldAtomic, the USDC waiting at its address (it becomes private by itself: never close an address that holds USDC; belowMinimum: less than minimumAtomic waits there for a top-up). An add-funds row with via "cli" was made by the shinjuku add-funds command in a terminal: amountAtomic, state (done or not_finished), transaction; it has no requestId, and wallet_add_funds never continues it. An unshield row with via "cli" is this wallet's own send, made by the shinjuku unshield command in a terminal: amountAtomic, state (sent, not_finished, not_sent), transaction, and next (with unshieldId, the terminal's own id) when it is not finished; it has no requestId, and wallet_unshield never continues it. A received payment (kind received, a move): amountAtomic and state done; at is null and it sorts last (no sender, no time). requestId is shown for payments made by this wallet process; older ones show requestKey (its SHA-256). kind "payments" or "moves" lists one group only.`,
|
|
132880
133160
|
inputSchema: {
|
|
132881
133161
|
type: "object",
|
|
132882
133162
|
properties: {
|
|
@@ -138959,7 +139239,7 @@ var init_tools = __esm({
|
|
|
138959
139239
|
});
|
|
138960
139240
|
stageWords = (stage) => STAGE_WORDS[stage] ?? String(stage ?? "").replace(/self-pay/g, "preparing").replace(/^part (\d+\/\d+)/, "payment $1");
|
|
138961
139241
|
INTERNAL_BALANCE_DETAIL = /* @__PURE__ */ new Set(["successionMovableAtomic", "unspentNotes", "fundedAccounts", "budget", "unspentAccounts"]);
|
|
138962
|
-
shownBreakdown = (breakdown) => breakdown && typeof breakdown === "object" ? Object.fromEntries(Object.entries(breakdown).filter(([name, value2]) => !(["setAsideAtomic", "refundsInFlightAtomic", "refundsNotCertainAtomic"].includes(name) && value2 === "0"))) : breakdown;
|
|
139242
|
+
shownBreakdown = (breakdown) => breakdown && typeof breakdown === "object" ? Object.fromEntries(Object.entries(breakdown).filter(([name, value2]) => !(["setAsideAtomic", "refundsInFlightAtomic", "refundsNotCertainAtomic", "openPaymentsAtomic"].includes(name) && value2 === "0"))) : breakdown;
|
|
138963
139243
|
sessionLeftShown = (policy, store) => {
|
|
138964
139244
|
if (String(policy.limits?.maxSessionAtomic) === NO_LIMIT_ATOMIC) return null;
|
|
138965
139245
|
if (store) {
|
|
@@ -139216,7 +139496,8 @@ var init_tools = __esm({
|
|
|
139216
139496
|
"p03_float_paid_finishing_retry_same_request",
|
|
139217
139497
|
"p03_float_already_paid",
|
|
139218
139498
|
"p03_float_refund_pending",
|
|
139219
|
-
"p03_float_transfer_expired"
|
|
139499
|
+
"p03_float_transfer_expired",
|
|
139500
|
+
PAID_SELLER_FAILED_CODE
|
|
139220
139501
|
]);
|
|
139221
139502
|
FLOAT_NOT_CERTAIN_CODES = /* @__PURE__ */ new Set(["p03_float_seller_refused_after_payment", "p03_float_outcome_not_certain", "p03_float_transfer_expired"]);
|
|
139222
139503
|
FLOAT_PRIVATE_LEG = "a private payment, so this answer has no transaction ID; wallet_receipts lists it";
|
|
@@ -143831,7 +144112,7 @@ async function runSetup(options, deps = {}) {
|
|
|
143831
144112
|
} catch {
|
|
143832
144113
|
releasePools = void 0;
|
|
143833
144114
|
}
|
|
143834
|
-
if (old && old.pool !== identity.pool && !
|
|
144115
|
+
if (old && old.pool !== identity.pool && !retired) {
|
|
143835
144116
|
const pools = releasePools;
|
|
143836
144117
|
const succeeded = successorChain(successions, old.pool).includes(identity.pool);
|
|
143837
144118
|
if (!succeeded && !(pools?.migration?.to.pool === identity.pool && pools.migration.from.some((entry) => entry.pool === old.pool))) {
|
|
@@ -149936,6 +150217,7 @@ function paymentRow(name, record, store, walk) {
|
|
|
149936
150217
|
} else if (state === "seller_kept") {
|
|
149937
150218
|
ok = false;
|
|
149938
150219
|
at = paidAt;
|
|
150220
|
+
if (record.sellerFailed) words2 = SELLER_FAILED_WORDS;
|
|
149939
150221
|
} else if (state === "submitted") {
|
|
149940
150222
|
at = paidAt;
|
|
149941
150223
|
words2 = "not certain yet";
|
|
@@ -149944,12 +150226,14 @@ function paymentRow(name, record, store, walk) {
|
|
|
149944
150226
|
if (record?.state !== "receipt" || record.receiptFinality === "never-finalized" || isFloatLegRecord(record)) return void 0;
|
|
149945
150227
|
const url = String(record.url ?? "");
|
|
149946
150228
|
if (url.startsWith(SELF_PAY_ORIGIN4) || url.includes(POOL_MOVE_PATH3)) return void 0;
|
|
149947
|
-
ok =
|
|
150229
|
+
ok = !record.sellerFailed;
|
|
150230
|
+
if (record.sellerFailed) words2 = SELLER_FAILED_WORDS;
|
|
149948
150231
|
at = record.answeredAtMs;
|
|
149949
150232
|
}
|
|
149950
150233
|
if (!Number.isSafeInteger(at) || seller === null || !POSITIVE3.test(String(view2.totalAtomic ?? ""))) return void 0;
|
|
149951
150234
|
return { at, seller, amount: words2 ? `${usdcWords(view2.totalAtomic)} ${words2}` : usdcWords(view2.totalAtomic), ok };
|
|
149952
150235
|
}
|
|
150236
|
+
var SELLER_FAILED_WORDS = "paid, service failed";
|
|
149953
150237
|
function lastPayments(store, nowMs, walk = null) {
|
|
149954
150238
|
const prefixes = [FLOAT_PAYMENT_WAL_PREFIX2, RESOURCE_PAYMENT_WAL_PREFIX3, POCKET_PAYMENT_WAL_PREFIX];
|
|
149955
150239
|
const rows2 = [];
|
|
@@ -155276,8 +155560,10 @@ function privateBalanceLine(parts, { afterSend = false } = {}) {
|
|
|
155276
155560
|
const why = report && report.status !== "current" && report.status !== "empty" ? ` (${balanceNotCurrentWhy(report)})` : "";
|
|
155277
155561
|
return `Your private balance is not known yet${why}; run ${cli2()} balance --refresh to read it.`;
|
|
155278
155562
|
}
|
|
155279
|
-
|
|
155280
|
-
|
|
155563
|
+
const open4 = openPaymentWords(parts);
|
|
155564
|
+
const next = open4 ? ` ${open4}` : "";
|
|
155565
|
+
if (report.status === "current" || report.status === "empty") return `${words2}.${next}`;
|
|
155566
|
+
return `${words2} (not final yet: ${balanceNotCurrentWhy(report)}; ${cli2()} balance --refresh reads it again).${next}`;
|
|
155281
155567
|
}
|
|
155282
155568
|
async function refreshAfterUnshield(walletFile, values, deps, io) {
|
|
155283
155569
|
const pool2 = /([1-9A-HJ-NP-Za-km-z]{32,44})[\\/]wallet\.json$/.exec(resolve33(walletFile))?.[1];
|
|
@@ -156247,6 +156533,8 @@ async function runBalance(args, values, deps, io) {
|
|
|
156247
156533
|
spend: spendHeads(parts.spendableAtomic, parts.largestPaymentAtomic, parts, { surface: "cli", prepareCommand: `${cli2()} prepare` })[0] ?? null,
|
|
156248
156534
|
refundsInFlightAtomic: parts.refundsInFlightAtomic,
|
|
156249
156535
|
refundsNotCertainAtomic: parts.refundsNotCertainAtomic,
|
|
156536
|
+
openPaymentsAtomic: parts.openPaymentsAtomic,
|
|
156537
|
+
...parts.openPayments?.length ? { openPayments: parts.openPayments } : {},
|
|
156250
156538
|
setAsideAtomic: parts.setAsideAtomic,
|
|
156251
156539
|
totalAtomic: parts.totalAtomic,
|
|
156252
156540
|
total: parts.totalAtomic === null ? null : formatAtomic(BigInt(parts.totalAtomic), Number(store.state.decimals)),
|
|
@@ -156765,7 +157053,7 @@ function failureHint(command, reason, deps, values, floatError) {
|
|
|
156765
157053
|
if (/p03_recovery_requested_anchor_not_finalized/.test(reason)) {
|
|
156766
157054
|
return "the pool anchor this quote names is not in your finalized history yet; nothing was signed. Rerun the same command in about 30 seconds";
|
|
156767
157055
|
}
|
|
156768
|
-
const floatCode = /\b(p03_float_[a-z_]+|wallet_quote_refused_[a-z0-9_]
|
|
157056
|
+
const floatCode = /\b(p03_float_[a-z_]+|wallet_quote_refused_[a-z0-9_]+|p03_resource_paid_seller_failed)\b/.exec(reason)?.[1];
|
|
156769
157057
|
const facts = REQUEST_ID_TAKEN2.test(reason) ? { ...floatError, ...conflictRecordFacts(reason, values, deps) } : floatError;
|
|
156770
157058
|
const float = floatCode ? floatOutcomeWords(floatCode, facts, CLI_FLOAT_TERMS(values, deps, command)) : void 0;
|
|
156771
157059
|
if (float) return `${float[1].replace(/[.;\s]+$/, "")}. ${float[2]}`;
|