shinjuku-shield 0.3.203 → 0.3.204
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 +6 -6
- package/manifest.json +4 -4
- package/package.json +3 -3
- package/shinjuku-wallet.mjs +100 -29
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@ web services and AI answers from your private balance, so the payment does
|
|
|
5
5
|
not show who paid. It works inside your AI app (Claude, Cursor, Codex) and in
|
|
6
6
|
a terminal. Only you hold the keys: they never leave your computer.
|
|
7
7
|
|
|
8
|
-
This is version 0.3.
|
|
8
|
+
This is version 0.3.204. The command is `shinjuku`.
|
|
9
9
|
|
|
10
10
|
## Set up
|
|
11
11
|
|
|
12
12
|
```sh
|
|
13
|
-
npx -y shinjuku@0.3.
|
|
13
|
+
npx -y shinjuku@0.3.204 setup
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Setup does every step for you:
|
|
@@ -107,14 +107,14 @@ Add it yourself. The name of the wallet in your app is `shinjuku`.
|
|
|
107
107
|
Claude Code:
|
|
108
108
|
|
|
109
109
|
```sh
|
|
110
|
-
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.
|
|
110
|
+
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.204 mcp
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
In this test version only (not offered yet), the same entry for Claude Desktop
|
|
114
114
|
(`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):
|
|
115
115
|
|
|
116
116
|
```json
|
|
117
|
-
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.
|
|
117
|
+
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.204", "mcp"] } } }
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
On Windows, if the app cannot find `npx`, use `"command": "cmd"` and put
|
|
@@ -126,7 +126,7 @@ CLI read `~/.codex/config.toml`):
|
|
|
126
126
|
```toml
|
|
127
127
|
[mcp_servers.shinjuku]
|
|
128
128
|
command = "npx"
|
|
129
|
-
args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.
|
|
129
|
+
args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.204", "mcp"]
|
|
130
130
|
startup_timeout_sec = 120
|
|
131
131
|
tool_timeout_sec = 300
|
|
132
132
|
```
|
|
@@ -144,7 +144,7 @@ with the Releases table in
|
|
|
144
144
|
Versions are published from GitHub Actions with npm provenance.
|
|
145
145
|
|
|
146
146
|
`shinjuku-shield` is the package that holds the wallet. `shinjuku-shielded`
|
|
147
|
-
0.3.
|
|
147
|
+
0.3.204, its older name, runs this package at the same version, so wallets
|
|
148
148
|
installed under that name keep updating. New installs use `shinjuku`.
|
|
149
149
|
|
|
150
150
|
The full guide is
|
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": "3a493f914e0d58e854685af40d3f380b1021aaca963528edb50a6a4447da7ff6",
|
|
5
|
+
"bytes": 9497352,
|
|
6
|
+
"sourceCommit": "3c56cca30529dbbccc0f7f62c7b52762e2a88416",
|
|
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",
|
|
@@ -1932,5 +1932,5 @@
|
|
|
1932
1932
|
}
|
|
1933
1933
|
]
|
|
1934
1934
|
},
|
|
1935
|
-
"publishedAt": "2026-11-
|
|
1935
|
+
"publishedAt": "2026-11-09T08:48:48.690Z"
|
|
1936
1936
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shield",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.204",
|
|
4
4
|
"mcpName": "io.github.ShinjukuStaition/shinjuku-shield",
|
|
5
5
|
"description": "Shinjuku Shield, private x402 payments 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": "3a493f91",
|
|
7
|
+
"shinjukuSha256": "3a493f914e0d58e854685af40d3f380b1021aaca963528edb50a6a4447da7ff6",
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"author": "Shinjuku Shield",
|
|
10
10
|
"homepage": "https://github.com/ShinjukuStaition/shinjuku-shield#readme",
|
package/shinjuku-wallet.mjs
CHANGED
|
@@ -110145,6 +110145,16 @@ function floatSellerHost(record) {
|
|
|
110145
110145
|
return void 0;
|
|
110146
110146
|
}
|
|
110147
110147
|
}
|
|
110148
|
+
function paymentTimeText(paidAtMs, nowMs = Date.now()) {
|
|
110149
|
+
if (!validPaymentTimeMs(paidAtMs)) return void 0;
|
|
110150
|
+
const at = new Date(paidAtMs).toISOString();
|
|
110151
|
+
const day = at.slice(0, 10);
|
|
110152
|
+
const today = Number.isFinite(new Date(nowMs).getTime()) ? new Date(nowMs).toISOString().slice(0, 10) : void 0;
|
|
110153
|
+
return `${at.slice(11, 16)} UTC${day === today ? "" : ` on ${day}`}`;
|
|
110154
|
+
}
|
|
110155
|
+
function validPaymentTimeMs(ms) {
|
|
110156
|
+
return Number.isSafeInteger(ms) && ms >= PAYMENT_TIME_MIN_MS && ms <= PAYMENT_TIME_MAX_MS && Number.isFinite(new Date(ms).getTime());
|
|
110157
|
+
}
|
|
110148
110158
|
function readFloatRefundOutcomes(store) {
|
|
110149
110159
|
const outcomes = [];
|
|
110150
110160
|
let names;
|
|
@@ -110159,7 +110169,17 @@ function readFloatRefundOutcomes(store) {
|
|
|
110159
110169
|
const record = store.readWal(name);
|
|
110160
110170
|
if (record?.schema !== FLOAT_PAYMENT_SCHEMA2 || floatRecordState(record) !== "refund_pending") continue;
|
|
110161
110171
|
if (record.refundOutcome === void 0 || record.refundOutcomeShown !== false) continue;
|
|
110162
|
-
|
|
110172
|
+
const inner = String(record.innerRequestId ?? "");
|
|
110173
|
+
outcomes.push({
|
|
110174
|
+
floatId: record.floatId,
|
|
110175
|
+
paidAtomic: record.paidAtomic,
|
|
110176
|
+
host: floatSellerHost(record),
|
|
110177
|
+
outcome: record.refundOutcome,
|
|
110178
|
+
atMs: record.refundOutcomeAtMs,
|
|
110179
|
+
// The first VALID time (Codex round 1 on 7faf9c93: `??` took an invalid non-null time before a valid later one).
|
|
110180
|
+
paidAtMs: [record.floatPaidAtMs, record.submittedAtMs, record.createdAtMs].find(validPaymentTimeMs),
|
|
110181
|
+
...inner.endsWith(":float") ? { requestId: inner.slice(0, -":float".length) } : {}
|
|
110182
|
+
});
|
|
110163
110183
|
} catch {
|
|
110164
110184
|
}
|
|
110165
110185
|
}
|
|
@@ -112105,7 +112125,7 @@ function paidResult(record, replayed) {
|
|
|
112105
112125
|
float: { floatId: record.floatId }
|
|
112106
112126
|
};
|
|
112107
112127
|
}
|
|
112108
|
-
var import_web3117, FLOAT_PAYMENT_SCHEMA2, REGENERATE_CODES, FLOAT_PAYMENT_WAL_PREFIX2, FLOAT_CONFIG_SCHEMA, FLOAT_PAY_PATH, FLOAT_MEMO_PATH, FLOAT_STATUS_PATH, MAX_BODY_BYTES, FLOAT_REFUND_ETA_SECONDS, REFUND_READ_EARLY_MS, REFUND_ETA_MAX_SECONDS, RERUN_STATUS_READ_MAX_MS, REFUND_SENT_FLOOR_SECONDS, refundDueOf, REFUND_SETTLED_AFTER_MS, REFUND_OUTCOME_NEWS_MS, FINISHING_POLL_MS, FINISHING_LIMIT_MS, SELLER_TIMEOUT_MS, SELLER_TIMEOUT_ABSURD_SECONDS, SELLER_STALL_CHECK_AFTER_MS, SELLER_STALL_CHECK_EVERY_MS, SELLER_STALL_CHECK_TIMEOUT_MS, SELLER_STALL_MISSES, RESULT_LIMIT_BYTES, FLOAT_STATUS_START_MS, FLOAT_STATUS_POLL_MS, FLOAT_STATUS_TIMEOUT_MS, CONFIRM_READ_MS, FLOAT_TRANSFER_DEAD, FLOAT_PAYMENT_REVERTED, VERDICT_POLL_MS, SELLER_ANSWER_VERDICT_MS, TRANSFER_MIN_BLOCKS_LEFT, TRANSFER_FRESH_MS, BLOCK_HEIGHT_TIMEOUT_MS, CONFIG_TIMEOUT_MS, MEMO_UPLOAD_TIMEOUT_MS, CONFIG_CACHE_MS, FLOAT_POOL_WARM_MS, DECIMAL3, POSITIVE, PENDING_CODES, FLOAT_FRONT_HEADER, hash7, fail25, GENERIC_REASON, SELLER_REASON_MAX, SELLER_REASON_READ_BYTES, FEE_PAYER_RESENDS, FEE_PAYER_RESEND_MS, GLOBAL_DISPATCHER5, sortedJson, MODEL_ID, RESIGN_ASK_WINDOW_MS, RESIGN_ASK_TIMEOUT_MS, RESIGN_FINISHING_WAIT_MS, RESIGN_MIN_SELLER_LEFT_MS, RESIGN_ANSWER_MAX_BYTES, floatPaymentWalName, floatRecordName, FLOAT_KEEP_BYTES_MS, memoryOnlyNeedsScrub, FLOAT_KEEP_OPEN_REQUEST_MS, configCache, configGeneration, configReadSequence, configReads, configRefreshes, SPECULATED_MAX_AGE_MS, speculatedQuotes, poolDomains, FLOAT_FACTS_SCHEMA, floatFacts, floatFactsKey, floatFactsMac, poolDomainReads, poolDomainWarmFailedAt, WARM_RETRY_MS, payerGenerator, etaEntry, loadPayerGenerator, plainText, quoteLimits, originOf, BROADCAST_REFUSED, BROADCAST_REFUSED_STANDARD, BROADCAST_DEAD, TRANSFER_LANDING_WINDOW_MS, PROOF_DELIVERY_MS, SELF_BROADCAST_LEG1_LEFT_MS, BROADCAST_UNSIGNED, BROADCAST_NO_LOOKUP, BROADCAST_LANDED, BROADCAST_LIMIT_MS, BROADCAST_QUOTE_MARGIN_MS, SELF_BROADCAST_RESEND_MS, SELF_BROADCAST_UNANSWERED_RESEND_MS, SELLER_HEADERS_MAX_COUNT, SELLER_HEADERS_MAX_BYTES, FINAL_AFTER_202_MS, SELLER_HEADERS_KEPT;
|
|
112128
|
+
var import_web3117, FLOAT_PAYMENT_SCHEMA2, REGENERATE_CODES, FLOAT_PAYMENT_WAL_PREFIX2, FLOAT_CONFIG_SCHEMA, FLOAT_PAY_PATH, FLOAT_MEMO_PATH, FLOAT_STATUS_PATH, MAX_BODY_BYTES, FLOAT_REFUND_ETA_SECONDS, REFUND_READ_EARLY_MS, REFUND_ETA_MAX_SECONDS, RERUN_STATUS_READ_MAX_MS, REFUND_SENT_FLOOR_SECONDS, refundDueOf, REFUND_SETTLED_AFTER_MS, REFUND_OUTCOME_NEWS_MS, FINISHING_POLL_MS, FINISHING_LIMIT_MS, SELLER_TIMEOUT_MS, SELLER_TIMEOUT_ABSURD_SECONDS, SELLER_STALL_CHECK_AFTER_MS, SELLER_STALL_CHECK_EVERY_MS, SELLER_STALL_CHECK_TIMEOUT_MS, SELLER_STALL_MISSES, RESULT_LIMIT_BYTES, FLOAT_STATUS_START_MS, FLOAT_STATUS_POLL_MS, FLOAT_STATUS_TIMEOUT_MS, CONFIRM_READ_MS, FLOAT_TRANSFER_DEAD, FLOAT_PAYMENT_REVERTED, VERDICT_POLL_MS, SELLER_ANSWER_VERDICT_MS, TRANSFER_MIN_BLOCKS_LEFT, TRANSFER_FRESH_MS, BLOCK_HEIGHT_TIMEOUT_MS, CONFIG_TIMEOUT_MS, MEMO_UPLOAD_TIMEOUT_MS, CONFIG_CACHE_MS, FLOAT_POOL_WARM_MS, DECIMAL3, POSITIVE, PENDING_CODES, FLOAT_FRONT_HEADER, hash7, fail25, GENERIC_REASON, SELLER_REASON_MAX, SELLER_REASON_READ_BYTES, FEE_PAYER_RESENDS, FEE_PAYER_RESEND_MS, GLOBAL_DISPATCHER5, sortedJson, MODEL_ID, RESIGN_ASK_WINDOW_MS, RESIGN_ASK_TIMEOUT_MS, RESIGN_FINISHING_WAIT_MS, RESIGN_MIN_SELLER_LEFT_MS, RESIGN_ANSWER_MAX_BYTES, floatPaymentWalName, floatRecordName, PAYMENT_TIME_MIN_MS, PAYMENT_TIME_MAX_MS, FLOAT_KEEP_BYTES_MS, memoryOnlyNeedsScrub, FLOAT_KEEP_OPEN_REQUEST_MS, configCache, configGeneration, configReadSequence, configReads, configRefreshes, SPECULATED_MAX_AGE_MS, speculatedQuotes, poolDomains, FLOAT_FACTS_SCHEMA, floatFacts, floatFactsKey, floatFactsMac, poolDomainReads, poolDomainWarmFailedAt, WARM_RETRY_MS, payerGenerator, etaEntry, loadPayerGenerator, plainText, quoteLimits, originOf, BROADCAST_REFUSED, BROADCAST_REFUSED_STANDARD, BROADCAST_DEAD, TRANSFER_LANDING_WINDOW_MS, PROOF_DELIVERY_MS, SELF_BROADCAST_LEG1_LEFT_MS, BROADCAST_UNSIGNED, BROADCAST_NO_LOOKUP, BROADCAST_LANDED, BROADCAST_LIMIT_MS, BROADCAST_QUOTE_MARGIN_MS, SELF_BROADCAST_RESEND_MS, SELF_BROADCAST_UNANSWERED_RESEND_MS, SELLER_HEADERS_MAX_COUNT, SELLER_HEADERS_MAX_BYTES, FINAL_AFTER_202_MS, SELLER_HEADERS_KEPT;
|
|
112109
112129
|
var init_floatPay = __esm({
|
|
112110
112130
|
"wallet/src/pay/floatPay.mjs"() {
|
|
112111
112131
|
"use strict";
|
|
@@ -112200,6 +112220,8 @@ var init_floatPay = __esm({
|
|
|
112200
112220
|
RESIGN_ANSWER_MAX_BYTES = 128 * 1024;
|
|
112201
112221
|
floatPaymentWalName = (requestKey) => `${FLOAT_PAYMENT_WAL_PREFIX2}${requestKey}`;
|
|
112202
112222
|
floatRecordName = (requestId) => floatPaymentWalName(hash7(requestId));
|
|
112223
|
+
PAYMENT_TIME_MIN_MS = Date.UTC(2024, 0, 1);
|
|
112224
|
+
PAYMENT_TIME_MAX_MS = Date.UTC(9999, 11, 31);
|
|
112203
112225
|
FLOAT_KEEP_BYTES_MS = 6e5;
|
|
112204
112226
|
memoryOnlyNeedsScrub = (record) => record?.memoryOnly === true && (record.resultSha256 !== void 0 || Array.isArray(record.sellerHeaders) && record.sellerHeaders.length > 0 || record.request?.bodySha256 !== void 0 || record.request?.headersSha256 !== void 0 || !/^memory-[0-9a-f]{64}$/.test(String(record.fingerprint ?? "")));
|
|
112205
112227
|
FLOAT_KEEP_OPEN_REQUEST_MS = 36e5;
|
|
@@ -116250,6 +116272,13 @@ function sellerInputLine(missing, line, room = SAY_MAX_WORDS) {
|
|
|
116250
116272
|
const lines = tries.map((text3) => line(text3, list.length));
|
|
116251
116273
|
return lines.find((text3) => words(text3) <= room) ?? lines[lines.length - 1];
|
|
116252
116274
|
}
|
|
116275
|
+
function refundInFlightAtomic(breakdown) {
|
|
116276
|
+
const total = String(breakdown?.refundsInFlightAtomic ?? "");
|
|
116277
|
+
if (!ATOMIC7.test(total)) return void 0;
|
|
116278
|
+
const arrived2 = (Array.isArray(breakdown.refundsInFlight) ? breakdown.refundsInFlight : []).filter((entry) => entry?.refundArrived === true && ATOMIC7.test(String(entry.refundAtomic ?? ""))).reduce((sum2, entry) => sum2 + BigInt(entry.refundAtomic), 0n);
|
|
116279
|
+
const left = BigInt(total) - arrived2;
|
|
116280
|
+
return (left > 0n ? left : 0n).toString();
|
|
116281
|
+
}
|
|
116253
116282
|
function spendSentence(a, tails = ["."], room = SAY_MAX_WORDS) {
|
|
116254
116283
|
if (!ATOMIC7.test(String(a?.balanceAtomic ?? ""))) return void 0;
|
|
116255
116284
|
const heads = spendHeads(a.balanceAtomic, a.largestPaymentAtomic, a);
|
|
@@ -117717,7 +117746,7 @@ var init_say = __esm({
|
|
|
117717
117746
|
doneInText = (a) => Number.isSafeInteger(a.doneInMinutesLow) && Number.isSafeInteger(a.doneInMinutesHigh) ? `about ${a.doneInMinutesLow} to ${a.doneInMinutesHigh} minutes` : "";
|
|
117718
117747
|
positive = (text3) => text3 !== void 0 && text3 !== "0";
|
|
117719
117748
|
str = (value2) => typeof value2 === "string" ? value2 : "";
|
|
117720
|
-
refundInFlight = (a) =>
|
|
117749
|
+
refundInFlight = (a) => usdcText2(refundInFlightAtomic(a.breakdown));
|
|
117721
117750
|
sellerAnswered = (status, data) => status >= 500 ? "had a server error" : status >= 400 ? "refused the request" : `sent no ${data}`;
|
|
117722
117751
|
urlAnswered = (status) => status === 404 || status === 410 ? "was not found" : status === 401 || status === 403 ? "refused access" : status >= 500 ? "had a server error" : "refused the request";
|
|
117723
117752
|
OWN_WORK_WORDS = Object.freeze({
|
|
@@ -135751,11 +135780,51 @@ async function sellerTokenAccountExists(connection, asset, payTo) {
|
|
|
135751
135780
|
return void 0;
|
|
135752
135781
|
}
|
|
135753
135782
|
}
|
|
135754
|
-
function refundOutcomeText(outcome) {
|
|
135755
|
-
const amount = ATOMIC_TEXT.test(String(outcome?.paidAtomic ?? "")) ? `${usdcText3(outcome.paidAtomic)} USDC` : "
|
|
135756
|
-
const
|
|
135757
|
-
|
|
135758
|
-
|
|
135783
|
+
function refundOutcomeText(outcome, nowMs = Date.now()) {
|
|
135784
|
+
const amount = ATOMIC_TEXT.test(String(outcome?.paidAtomic ?? "")) ? `${usdcText3(outcome.paidAtomic)} USDC ` : "";
|
|
135785
|
+
const host = typeof outcome?.host === "string" && /^[a-z0-9.-]{1,253}$/i.test(outcome.host) ? outcome.host : void 0;
|
|
135786
|
+
const when = paymentTimeText(outcome?.paidAtMs, nowMs);
|
|
135787
|
+
const payment = `your earlier ${host ? `payment to ${host}` : "Shinjuku payment"}${when ? ` (paid ${when})` : ""}`;
|
|
135788
|
+
if (outcome?.outcome === "refund_arrived") return `The ${amount}refund for ${payment} arrived.`;
|
|
135789
|
+
return `The ${amount}refund for ${payment} could not be matched in your balance (this balance read cannot tell refunds apart); if it came back, balanceAtomic counts it already.`;
|
|
135790
|
+
}
|
|
135791
|
+
function refundOutcomesToShow(outcomes, shown, exceptFloatId) {
|
|
135792
|
+
return outcomes.filter(({ floatId, outcome }) => !shown.has(`${floatId}:${outcome}`) && !(typeof exceptFloatId === "string" && floatId === exceptFloatId));
|
|
135793
|
+
}
|
|
135794
|
+
function noticesOnce({
|
|
135795
|
+
outcomes,
|
|
135796
|
+
readUnkept,
|
|
135797
|
+
shown,
|
|
135798
|
+
exceptFloatId,
|
|
135799
|
+
markRefunds,
|
|
135800
|
+
markUnkept,
|
|
135801
|
+
textOf: textOf2 = (outcome) => refundOutcomeText(outcome),
|
|
135802
|
+
unkeptText = answerNotKeptNoticeWords
|
|
135803
|
+
}) {
|
|
135804
|
+
const fresh = refundOutcomesToShow(outcomes, shown, exceptFloatId);
|
|
135805
|
+
let unkept;
|
|
135806
|
+
let refundNotices;
|
|
135807
|
+
let paidNotices;
|
|
135808
|
+
try {
|
|
135809
|
+
unkept = readUnkept().filter(({ requestId }) => !shown.has(`unkept:${requestId}`));
|
|
135810
|
+
refundNotices = fresh.map((outcome) => textOf2(outcome));
|
|
135811
|
+
paidNotices = unkept.map((notice) => unkeptText(notice));
|
|
135812
|
+
} catch {
|
|
135813
|
+
return { notices: {}, arrived: [] };
|
|
135814
|
+
}
|
|
135815
|
+
for (const { floatId, outcome } of fresh) shown.add(`${floatId}:${outcome}`);
|
|
135816
|
+
for (const { requestId } of unkept) shown.add(`unkept:${requestId}`);
|
|
135817
|
+
if (fresh.length) markRefunds(fresh);
|
|
135818
|
+
if (unkept.length) markUnkept(unkept);
|
|
135819
|
+
return {
|
|
135820
|
+
notices: { ...refundNotices.length ? { refundNotices } : {}, ...paidNotices.length ? { paidNotices } : {} },
|
|
135821
|
+
arrived: fresh.filter(({ outcome }) => outcome === "refund_arrived")
|
|
135822
|
+
};
|
|
135823
|
+
}
|
|
135824
|
+
function markArrivedRefunds(breakdown, arrived2) {
|
|
135825
|
+
if (!breakdown || !Array.isArray(breakdown.refundsInFlight) || !arrived2?.length) return breakdown;
|
|
135826
|
+
const named = (entry) => arrived2.some((one) => typeof entry?.requestId === "string" && entry.requestId === one.requestId || typeof entry?.floatId === "string" && entry.floatId === one.floatId);
|
|
135827
|
+
return { ...breakdown, refundsInFlight: breakdown.refundsInFlight.map((entry) => named(entry) ? { ...entry, refundArrived: true } : entry) };
|
|
135759
135828
|
}
|
|
135760
135829
|
function floatRefusal(error, overLimit, tool = "pay_for_service") {
|
|
135761
135830
|
const code2 = String(error?.message ?? "").split(/[\s:;(]/, 1)[0];
|
|
@@ -137439,12 +137508,12 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
137439
137508
|
...share ? { share } : {}
|
|
137440
137509
|
});
|
|
137441
137510
|
const shownRefunds = /* @__PURE__ */ new Set();
|
|
137442
|
-
const takeRefundNotices = (store) => {
|
|
137511
|
+
const takeRefundNotices = (store, exceptFloatId) => {
|
|
137443
137512
|
let open5;
|
|
137444
137513
|
try {
|
|
137445
137514
|
open5 = store ?? session.openStore();
|
|
137446
137515
|
} catch {
|
|
137447
|
-
return {};
|
|
137516
|
+
return { notices: {}, arrived: [] };
|
|
137448
137517
|
}
|
|
137449
137518
|
let outcomes;
|
|
137450
137519
|
try {
|
|
@@ -137452,18 +137521,16 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
137452
137521
|
} catch {
|
|
137453
137522
|
outcomes = [];
|
|
137454
137523
|
}
|
|
137455
|
-
|
|
137456
|
-
|
|
137457
|
-
|
|
137458
|
-
|
|
137459
|
-
|
|
137460
|
-
|
|
137461
|
-
|
|
137524
|
+
return noticesOnce({
|
|
137525
|
+
outcomes,
|
|
137526
|
+
readUnkept: () => readAnswerNotKeptNotices(open5),
|
|
137527
|
+
shown: shownRefunds,
|
|
137528
|
+
exceptFloatId,
|
|
137529
|
+
markRefunds: (fresh) => underLease((leased) => markFloatRefundOutcomesShown(leased, fresh)).catch(() => {
|
|
137530
|
+
}),
|
|
137531
|
+
markUnkept: (unkept) => underLease((leased) => markAnswerNotKeptShown(leased, unkept)).catch(() => {
|
|
137532
|
+
})
|
|
137462
137533
|
});
|
|
137463
|
-
return {
|
|
137464
|
-
...fresh.length ? { refundNotices: fresh.map(refundOutcomeText) } : {},
|
|
137465
|
-
...unkept.length ? { paidNotices: unkept.map(answerNotKeptNoticeWords) } : {}
|
|
137466
|
-
};
|
|
137467
137534
|
};
|
|
137468
137535
|
const noticesStep = (notices) => [notices.refundNotices ? "refundNotices" : void 0, notices.paidNotices ? "paidNotices" : void 0].filter(Boolean).map((field5) => `. Tell the user each ${field5} line`).join("");
|
|
137469
137536
|
const withRefundNotices = (answer, store) => {
|
|
@@ -137474,10 +137541,11 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
137474
137541
|
return answer;
|
|
137475
137542
|
}
|
|
137476
137543
|
if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return answer;
|
|
137477
|
-
const notices = takeRefundNotices(store);
|
|
137544
|
+
const { notices, arrived: arrived2 } = takeRefundNotices(store, value2.floatId);
|
|
137478
137545
|
if (!notices.refundNotices && !notices.paidNotices) return answer;
|
|
137479
137546
|
return json4({
|
|
137480
137547
|
...value2,
|
|
137548
|
+
...value2.breakdown ? { breakdown: markArrivedRefunds(value2.breakdown, arrived2) } : {},
|
|
137481
137549
|
...notices,
|
|
137482
137550
|
...typeof value2.next === "string" ? { next: `${value2.next.replace(/[.\s]+$/, "")}${noticesStep(notices)}` } : {}
|
|
137483
137551
|
});
|
|
@@ -139157,7 +139225,8 @@ ${canonical5}`;
|
|
|
139157
139225
|
}
|
|
139158
139226
|
mark("mcp-result");
|
|
139159
139227
|
const shinjukuTransaction = floatPaid ? leg1Transaction(paidStore, float, requestId) : null;
|
|
139160
|
-
const notices = takeRefundNotices(paidStore);
|
|
139228
|
+
const { notices, arrived: arrivedRefunds } = takeRefundNotices(paidStore, float?.floatId);
|
|
139229
|
+
const shownBalance = balanceAnswer(one);
|
|
139161
139230
|
return answerResult(paidAnswerContent({
|
|
139162
139231
|
status: response.status,
|
|
139163
139232
|
headers: response.headers,
|
|
@@ -139177,7 +139246,8 @@ ${canonical5}`;
|
|
|
139177
139246
|
receiptFinality: unpaid ? "never-finalized" : receipt.receiptFinality ?? null,
|
|
139178
139247
|
// Leg 1 (this wallet's private payment to Shinjuku, a pool transaction): the seller may return no settle signature.
|
|
139179
139248
|
...floatPaid ? { via: "shinjuku", shinjukuTransaction } : {},
|
|
139180
|
-
...
|
|
139249
|
+
...shownBalance,
|
|
139250
|
+
...shownBalance.breakdown ? { breakdown: markArrivedRefunds(shownBalance.breakdown, arrivedRefunds) } : {},
|
|
139181
139251
|
...notices,
|
|
139182
139252
|
next: (unpaid ? "nothing was paid: this request id's payment never landed (the pool's public history proves it), and the answer it got came back again; nothing new was paid. Tell the user nothing was paid for it" : receipt.replayed === true ? "this request id was already paid: the stored receipt came back and nothing new was paid" + (floatPaid && receipt.receiptFinality === "pending" ? `. ${floatPaidNext({ transaction, shinjukuTransaction, pending: true })}` : "") : floatPaid ? floatPaidNext({ transaction: unpaid ? null : transaction, shinjukuTransaction, pending: receipt.receiptFinality === "pending" }) + (receipt.stallResent === true || float?.sellerStallResent === true ? `. Tell the user too: ${stallResentLine()}` : "") : "paid; tell the user what was paid (amountAtomic, transaction). wallet_receipts lists this payment, wallet_balance shows the new balance") + noticesStep(notices)
|
|
139183
139253
|
}, "pay_for_service")
|
|
@@ -140085,11 +140155,12 @@ ${canonical5}`;
|
|
|
140085
140155
|
}
|
|
140086
140156
|
}
|
|
140087
140157
|
const landedFrom = (total, sales) => sales <= 0n ? "USDC you added" : sales >= total ? "USDC from your sales" : "USDC you added and from your sales";
|
|
140088
|
-
function walletCard({ one, unshielded, landingAtomic, landingSalesAtomic = 0n, recordFaultAtomic = 0n, sales, store, lastRead,
|
|
140158
|
+
function walletCard({ one, unshielded, landingAtomic, landingSalesAtomic = 0n, recordFaultAtomic = 0n, sales, store, lastRead, refundBreakdown = one.breakdown, refresh = {} }) {
|
|
140089
140159
|
const known = ATOMIC_TEXT.test(String(one.balanceAtomic ?? ""));
|
|
140090
140160
|
const landing = `${landingAtomic > 0n ? `; ${usdcText3(landingAtomic)} ${landedFrom(landingAtomic, landingSalesAtomic)} is being counted` : ""}${sales ? `; ${sales.line}` : ""}`;
|
|
140091
140161
|
const reading2 = lastRead ? `the wallet is still reading it; the last full read, ${ageWords2(lastRead.ageMinutes)} ago, showed ${usdcText3(lastRead.privateAtomic)} USDC` : "the wallet is still reading it";
|
|
140092
|
-
const
|
|
140162
|
+
const inFlightAtomic = refundInFlightAtomic(refundBreakdown);
|
|
140163
|
+
const inFlight = /^0*[1-9][0-9]*$/.test(String(inFlightAtomic ?? "")) ? usdcText3(inFlightAtomic) : void 0;
|
|
140093
140164
|
const checking = refresh.refreshing === true && (refresh.refreshReason === void 0 || refresh.refreshReason === "refund_check");
|
|
140094
140165
|
const lines = [!known ? `Private balance: not known yet (${reading2})${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}`];
|
|
140095
140166
|
if (recordFaultAtomic > 0n) lines.push(`${usdcText3(recordFaultAtomic)} USDC you added landed, but Shinjuku's record of it does not match; nothing is lost; do not send it again`);
|
|
@@ -140634,7 +140705,7 @@ ${canonical5}`;
|
|
|
140634
140705
|
if (sales) {
|
|
140635
140706
|
next = `${next}. Tell the user: buyers paid ${sales.usdc} USDC for ${sales.payments === 1 ? "a sale" : `${sales.payments} sales`}, and the wallet is moving it into the private balance by itself (it is not in the balance yet; nothing to do). Call wallet_balance in a few minutes to see it in the balance`;
|
|
140636
140707
|
}
|
|
140637
|
-
const notices = takeRefundNotices();
|
|
140708
|
+
const { notices, arrived: arrivedRefunds } = takeRefundNotices();
|
|
140638
140709
|
next = `${next}${noticesStep(notices)}`;
|
|
140639
140710
|
if (ownTokens?.tokens.length) {
|
|
140640
140711
|
const count3 = ownTokens.tokens.length + ownTokens.more;
|
|
@@ -140675,7 +140746,7 @@ ${canonical5}`;
|
|
|
140675
140746
|
}
|
|
140676
140747
|
internal.unshieldedTotalAtomic = exitedTotalAtomic ?? null;
|
|
140677
140748
|
const { setAsideAtomic, ...breakdownRest } = one.breakdown;
|
|
140678
|
-
const breakdown = setAsideAtomic === "0" ? breakdownRest : one.breakdown;
|
|
140749
|
+
const breakdown = markArrivedRefunds(setAsideAtomic === "0" ? breakdownRest : one.breakdown, arrivedRefunds);
|
|
140679
140750
|
if (setAsideAtomic === "0") internal.setAsideAtomic = "0";
|
|
140680
140751
|
const noLimit = (atomic5) => atomic5 === void 0 || atomic5 === null || String(atomic5) === NO_LIMIT_ATOMIC;
|
|
140681
140752
|
const capWords2 = (atomic5) => noLimit(atomic5) ? "no limit" : `${usdcText3(atomic5)} USDC`;
|
|
@@ -140698,7 +140769,7 @@ ${canonical5}`;
|
|
|
140698
140769
|
...reportPublic,
|
|
140699
140770
|
...firstRead ? { status: "reading" } : {},
|
|
140700
140771
|
...balanceTextFields(one),
|
|
140701
|
-
card: walletCard({ one, unshielded, landingAtomic, landingSalesAtomic: landingParts.salesAtomic, recordFaultAtomic: landingParts.recordFaultAtomic, sales, store, lastRead,
|
|
140772
|
+
card: walletCard({ one, unshielded, landingAtomic, landingSalesAtomic: landingParts.salesAtomic, recordFaultAtomic: landingParts.recordFaultAtomic, sales, store, lastRead, refundBreakdown: breakdown, refresh }),
|
|
140702
140773
|
...lastRead ? { lastRead } : {},
|
|
140703
140774
|
// joinSteps: the joins, one after another (autoJoin.mjs joinParts joins), when the wallet gets the balance ready by
|
|
140704
140775
|
// itself; doneInMinutes*: the time to send all of it (UX128-9).
|