shinjuku-shield 0.3.204 → 0.3.206
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 +4 -32
- package/manifest.json +4 -4
- package/package.json +3 -3
- package/shinjuku-wallet.mjs +113 -63
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.206. 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.206 setup
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Setup does every step for you:
|
|
@@ -42,13 +42,6 @@ shinjuku setup --add-to claude-code
|
|
|
42
42
|
Then reconnect the wallet in Claude Code: type `/mcp`, pick `shinjuku`, and
|
|
43
43
|
choose Reconnect.
|
|
44
44
|
|
|
45
|
-
> **In this test version (not offered yet):**
|
|
46
|
-
> - On Windows, the wallet downloads and starts Tor by itself, and starts it
|
|
47
|
-
> again after a restart.
|
|
48
|
-
> - `setup --add-to claude-desktop`, `--add-to cursor` and `--add-to codex` add
|
|
49
|
-
> the wallet to Claude Desktop, Cursor and Codex. At the end of setup, the
|
|
50
|
-
> wallet prints this line for every app it knows.
|
|
51
|
-
|
|
52
45
|
## Add money
|
|
53
46
|
|
|
54
47
|
Ask your AI app: "Add 0.50 USDC to my private balance." It gives you a
|
|
@@ -107,28 +100,7 @@ Add it yourself. The name of the wallet in your app is `shinjuku`.
|
|
|
107
100
|
Claude Code:
|
|
108
101
|
|
|
109
102
|
```sh
|
|
110
|
-
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
In this test version only (not offered yet), the same entry for Claude Desktop
|
|
114
|
-
(`claude_desktop_config.json`) or Cursor (`~/.cursor/mcp.json`):
|
|
115
|
-
|
|
116
|
-
```json
|
|
117
|
-
{ "mcpServers": { "shinjuku": { "command": "npx", "args": ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.204", "mcp"] } } }
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
On Windows, if the app cannot find `npx`, use `"command": "cmd"` and put
|
|
121
|
-
`"/c", "npx"` at the start of `args`.
|
|
122
|
-
|
|
123
|
-
In this test version only (not offered yet), Codex (the Codex app and Codex
|
|
124
|
-
CLI read `~/.codex/config.toml`):
|
|
125
|
-
|
|
126
|
-
```toml
|
|
127
|
-
[mcp_servers.shinjuku]
|
|
128
|
-
command = "npx"
|
|
129
|
-
args = ["-y", "--no-audit", "--no-fund", "shinjuku-shield@0.3.204", "mcp"]
|
|
130
|
-
startup_timeout_sec = 120
|
|
131
|
-
tool_timeout_sec = 300
|
|
103
|
+
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.206 mcp
|
|
132
104
|
```
|
|
133
105
|
|
|
134
106
|
## For builders: check what you install
|
|
@@ -144,7 +116,7 @@ with the Releases table in
|
|
|
144
116
|
Versions are published from GitHub Actions with npm provenance.
|
|
145
117
|
|
|
146
118
|
`shinjuku-shield` is the package that holds the wallet. `shinjuku-shielded`
|
|
147
|
-
0.3.
|
|
119
|
+
0.3.206, its older name, runs this package at the same version, so wallets
|
|
148
120
|
installed under that name keep updating. New installs use `shinjuku`.
|
|
149
121
|
|
|
150
122
|
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": "f733f68a13bd6ac7a1cbb747e88504c18a09eda4a5bb15bb6d5eb076698f4682",
|
|
5
|
+
"bytes": 9499679,
|
|
6
|
+
"sourceCommit": "47204ab6fdb94c468ccea6374da751968cb4a261",
|
|
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-09T10:25:27.386Z"
|
|
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.206",
|
|
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": "f733f68a",
|
|
7
|
+
"shinjukuSha256": "f733f68a13bd6ac7a1cbb747e88504c18a09eda4a5bb15bb6d5eb076698f4682",
|
|
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
|
@@ -110113,6 +110113,10 @@ function refundArrived(snapshot, refundTo) {
|
|
|
110113
110113
|
function floatRefundHeld(snapshot, record) {
|
|
110114
110114
|
return refundArrived(snapshot, record?.refundTo);
|
|
110115
110115
|
}
|
|
110116
|
+
function submittedNewsOld(times, atMs) {
|
|
110117
|
+
const since = times.find((ms) => validPaymentTimeMs(ms) && ms <= atMs);
|
|
110118
|
+
return since === void 0 ? false : atMs - since >= REFUND_OUTCOME_NEWS_MS;
|
|
110119
|
+
}
|
|
110116
110120
|
function returnArrivedFloatRefundBudgets(store, snapshot) {
|
|
110117
110121
|
const refreshedAtMs = Date.parse(snapshot?.refreshedAt ?? "");
|
|
110118
110122
|
const knowsRecipients = snapshotKnowsRecipients(snapshot);
|
|
@@ -110121,17 +110125,14 @@ function returnArrivedFloatRefundBudgets(store, snapshot) {
|
|
|
110121
110125
|
const record = store.readWal(name);
|
|
110122
110126
|
if (record?.schema !== FLOAT_PAYMENT_SCHEMA2 || typeof record.innerRequestId !== "string") continue;
|
|
110123
110127
|
const state2 = floatRecordState(record);
|
|
110124
|
-
|
|
110125
|
-
|
|
110126
|
-
continue;
|
|
110127
|
-
}
|
|
110128
|
-
if (state2 !== "refund_pending") continue;
|
|
110128
|
+
const submitted = state2 === "submitted";
|
|
110129
|
+
if (!submitted && state2 !== "refund_pending") continue;
|
|
110129
110130
|
const arrivedNow = refundArrived(snapshot, record.refundTo);
|
|
110130
110131
|
if (arrivedNow) releaseRefundedReservation({ store, requestId: record.innerRequestId });
|
|
110131
|
-
const outcome = arrivedNow ? "refund_arrived" : record.refundOutcome === void 0 && refundCountStopped(record, refreshedAtMs, knowsRecipients) ? "refund_not_seen" : void 0;
|
|
110132
|
+
const outcome = arrivedNow ? "refund_arrived" : !submitted && record.refundOutcome === void 0 && refundCountStopped(record, refreshedAtMs, knowsRecipients) ? "refund_not_seen" : void 0;
|
|
110132
110133
|
if (outcome === void 0 || outcome === record.refundOutcome) continue;
|
|
110133
110134
|
const atMs = Number.isFinite(refreshedAtMs) ? refreshedAtMs : Date.now();
|
|
110134
|
-
const old = !(atMs - record.refundPendingAtMs < REFUND_OUTCOME_NEWS_MS);
|
|
110135
|
+
const old = submitted ? submittedNewsOld([record.submittedAtMs, record.floatPaidAtMs, record.createdAtMs], atMs) : !(atMs - record.refundPendingAtMs < REFUND_OUTCOME_NEWS_MS);
|
|
110135
110136
|
try {
|
|
110136
110137
|
store.writeWal(name, { ...record, refundOutcome: outcome, refundOutcomeAtMs: atMs, refundOutcomeShown: old });
|
|
110137
110138
|
} catch {
|
|
@@ -110155,7 +110156,7 @@ function paymentTimeText(paidAtMs, nowMs = Date.now()) {
|
|
|
110155
110156
|
function validPaymentTimeMs(ms) {
|
|
110156
110157
|
return Number.isSafeInteger(ms) && ms >= PAYMENT_TIME_MIN_MS && ms <= PAYMENT_TIME_MAX_MS && Number.isFinite(new Date(ms).getTime());
|
|
110157
110158
|
}
|
|
110158
|
-
function readFloatRefundOutcomes(store) {
|
|
110159
|
+
function readFloatRefundOutcomes(store, now = Date.now(), arrived2 = []) {
|
|
110159
110160
|
const outcomes = [];
|
|
110160
110161
|
let names;
|
|
110161
110162
|
try {
|
|
@@ -110163,28 +110164,71 @@ function readFloatRefundOutcomes(store) {
|
|
|
110163
110164
|
} catch {
|
|
110164
110165
|
return outcomes;
|
|
110165
110166
|
}
|
|
110167
|
+
const keys3 = new Set((Array.isArray(arrived2) ? arrived2 : []).flatMap((one) => [
|
|
110168
|
+
typeof one?.requestId === "string" ? `r:${one.requestId}` : void 0,
|
|
110169
|
+
typeof one?.floatId === "string" ? `f:${one.floatId}` : void 0
|
|
110170
|
+
]).filter(Boolean));
|
|
110166
110171
|
for (const name of names) {
|
|
110167
110172
|
if (!name.startsWith(FLOAT_PAYMENT_WAL_PREFIX2)) continue;
|
|
110168
110173
|
try {
|
|
110169
110174
|
const record = store.readWal(name);
|
|
110170
|
-
if (record?.schema !== FLOAT_PAYMENT_SCHEMA2 || floatRecordState(record)
|
|
110171
|
-
if (record.refundOutcome === void 0
|
|
110172
|
-
|
|
110173
|
-
|
|
110174
|
-
|
|
110175
|
-
|
|
110176
|
-
|
|
110177
|
-
|
|
110178
|
-
|
|
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
|
-
});
|
|
110175
|
+
if (record?.schema !== FLOAT_PAYMENT_SCHEMA2 || !["refund_pending", "submitted"].includes(floatRecordState(record))) continue;
|
|
110176
|
+
if (record.refundOutcome === void 0) {
|
|
110177
|
+
const key = refundKeyOf(record);
|
|
110178
|
+
const told = keys3.has(key) ? heldRefundOutcome(record, now) : void 0;
|
|
110179
|
+
if (told) outcomes.push({ ...told, held: true });
|
|
110180
|
+
continue;
|
|
110181
|
+
}
|
|
110182
|
+
if (record.refundOutcomeShown !== false) continue;
|
|
110183
|
+
outcomes.push(refundOutcomeView(record, record.refundOutcome, record.refundOutcomeAtMs, now));
|
|
110183
110184
|
} catch {
|
|
110184
110185
|
}
|
|
110185
110186
|
}
|
|
110186
110187
|
return outcomes;
|
|
110187
110188
|
}
|
|
110189
|
+
function refundKeyOf(record) {
|
|
110190
|
+
const inner = String(record?.innerRequestId ?? "");
|
|
110191
|
+
return inner.endsWith(":float") ? `r:${inner.slice(0, -":float".length)}` : `f:${record?.floatId}`;
|
|
110192
|
+
}
|
|
110193
|
+
function writeHeldRefundOutcomes(store, floatIds, now = Date.now()) {
|
|
110194
|
+
const wanted = new Set(floatIds);
|
|
110195
|
+
if (!wanted.size) return;
|
|
110196
|
+
let names;
|
|
110197
|
+
try {
|
|
110198
|
+
names = store.listWal();
|
|
110199
|
+
} catch {
|
|
110200
|
+
return;
|
|
110201
|
+
}
|
|
110202
|
+
for (const name of names) {
|
|
110203
|
+
if (!name.startsWith(FLOAT_PAYMENT_WAL_PREFIX2)) continue;
|
|
110204
|
+
try {
|
|
110205
|
+
const record = store.readWal(name);
|
|
110206
|
+
if (record?.schema !== FLOAT_PAYMENT_SCHEMA2 || !wanted.has(record.floatId) || record.refundOutcome !== void 0) continue;
|
|
110207
|
+
if (!["refund_pending", "submitted"].includes(floatRecordState(record)) || typeof record.innerRequestId !== "string") continue;
|
|
110208
|
+
releaseRefundedReservation({ store, requestId: record.innerRequestId });
|
|
110209
|
+
store.writeWal(name, { ...record, refundOutcome: "refund_arrived", refundOutcomeAtMs: now, refundOutcomeShown: false });
|
|
110210
|
+
} catch {
|
|
110211
|
+
}
|
|
110212
|
+
}
|
|
110213
|
+
}
|
|
110214
|
+
function refundOutcomeView(record, outcome, atMs, now) {
|
|
110215
|
+
const inner = String(record.innerRequestId ?? "");
|
|
110216
|
+
return {
|
|
110217
|
+
floatId: record.floatId,
|
|
110218
|
+
paidAtomic: record.paidAtomic,
|
|
110219
|
+
host: floatSellerHost(record),
|
|
110220
|
+
outcome,
|
|
110221
|
+
atMs,
|
|
110222
|
+
paidAtMs: [record.floatPaidAtMs, record.submittedAtMs, record.createdAtMs].find((ms) => validPaymentTimeMs(ms) && ms <= now),
|
|
110223
|
+
...inner.endsWith(":float") ? { requestId: inner.slice(0, -":float".length) } : {}
|
|
110224
|
+
};
|
|
110225
|
+
}
|
|
110226
|
+
function heldRefundOutcome(record, now = Date.now()) {
|
|
110227
|
+
const state2 = floatRecordState(record);
|
|
110228
|
+
if (record?.refundOutcome !== void 0 || state2 !== "submitted" && state2 !== "refund_pending") return void 0;
|
|
110229
|
+
const old = state2 === "submitted" ? submittedNewsOld([record.submittedAtMs, record.floatPaidAtMs, record.createdAtMs], now) : !(now - record.refundPendingAtMs < REFUND_OUTCOME_NEWS_MS);
|
|
110230
|
+
return old ? void 0 : refundOutcomeView(record, "refund_arrived", now, now);
|
|
110231
|
+
}
|
|
110188
110232
|
function markFloatRefundOutcomesShown(store, shown) {
|
|
110189
110233
|
const wanted = new Map(shown.map(({ floatId, outcome }) => [floatId, outcome]));
|
|
110190
110234
|
if (!wanted.size) return;
|
|
@@ -116272,13 +116316,6 @@ function sellerInputLine(missing, line, room = SAY_MAX_WORDS) {
|
|
|
116272
116316
|
const lines = tries.map((text3) => line(text3, list.length));
|
|
116273
116317
|
return lines.find((text3) => words(text3) <= room) ?? lines[lines.length - 1];
|
|
116274
116318
|
}
|
|
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
|
-
}
|
|
116282
116319
|
function spendSentence(a, tails = ["."], room = SAY_MAX_WORDS) {
|
|
116283
116320
|
if (!ATOMIC7.test(String(a?.balanceAtomic ?? ""))) return void 0;
|
|
116284
116321
|
const heads = spendHeads(a.balanceAtomic, a.largestPaymentAtomic, a);
|
|
@@ -117746,7 +117783,7 @@ var init_say = __esm({
|
|
|
117746
117783
|
doneInText = (a) => Number.isSafeInteger(a.doneInMinutesLow) && Number.isSafeInteger(a.doneInMinutesHigh) ? `about ${a.doneInMinutesLow} to ${a.doneInMinutesHigh} minutes` : "";
|
|
117747
117784
|
positive = (text3) => text3 !== void 0 && text3 !== "0";
|
|
117748
117785
|
str = (value2) => typeof value2 === "string" ? value2 : "";
|
|
117749
|
-
refundInFlight = (a) => usdcText2(
|
|
117786
|
+
refundInFlight = (a) => usdcText2(a.breakdown?.refundsInFlightAtomic);
|
|
117750
117787
|
sellerAnswered = (status, data) => status >= 500 ? "had a server error" : status >= 400 ? "refused the request" : `sent no ${data}`;
|
|
117751
117788
|
urlAnswered = (status) => status === 404 || status === 410 ? "was not found" : status === 401 || status === 403 ? "refused access" : status >= 500 ? "had a server error" : "refused the request";
|
|
117752
117789
|
OWN_WORK_WORDS = Object.freeze({
|
|
@@ -121588,6 +121625,7 @@ function floatRefunds(store, snapshot) {
|
|
|
121588
121625
|
const notCertainFor = [];
|
|
121589
121626
|
let open5 = 0n;
|
|
121590
121627
|
const openFor = [];
|
|
121628
|
+
const arrivedFor = [];
|
|
121591
121629
|
for (const name of store.listWal()) {
|
|
121592
121630
|
if (!name.startsWith(FLOAT_PAYMENT_WAL_PREFIX2)) continue;
|
|
121593
121631
|
let record;
|
|
@@ -121607,7 +121645,9 @@ function floatRefunds(store, snapshot) {
|
|
|
121607
121645
|
openFor.push({ ...payment, paidAtomic: refundAtomic });
|
|
121608
121646
|
continue;
|
|
121609
121647
|
}
|
|
121610
|
-
|
|
121648
|
+
const held2 = floatRefundHeld(snapshot, record);
|
|
121649
|
+
if (held2 && heldRefundOutcome(record) !== void 0) arrivedFor.push(refundOf(record));
|
|
121650
|
+
if (state2 !== "refund_pending" && !refusedOpen || held2) continue;
|
|
121611
121651
|
if (refusedOpen || !knowsRecipients) {
|
|
121612
121652
|
notCertain += BigInt(record.paidAtomic);
|
|
121613
121653
|
notCertainFor.push(refundOf(record));
|
|
@@ -121616,7 +121656,7 @@ function floatRefunds(store, snapshot) {
|
|
|
121616
121656
|
provenFor.push(refundOf(record));
|
|
121617
121657
|
}
|
|
121618
121658
|
}
|
|
121619
|
-
return { proven, notCertain, provenFor, notCertainFor, open: open5, openFor };
|
|
121659
|
+
return { proven, notCertain, provenFor, notCertainFor, open: open5, openFor, arrivedFor };
|
|
121620
121660
|
}
|
|
121621
121661
|
function balanceView(store) {
|
|
121622
121662
|
const neverReceived = /* @__PURE__ */ new Set();
|
|
@@ -121682,6 +121722,7 @@ function partsOf(report, store, snapshot) {
|
|
|
121682
121722
|
refundsNotCertain: refunds.notCertainFor,
|
|
121683
121723
|
openPaymentsAtomic: refunds.open.toString(),
|
|
121684
121724
|
openPayments: refunds.openFor,
|
|
121725
|
+
refundsArrived: refunds.arrivedFor,
|
|
121685
121726
|
setAsideAtomic: setAside.toString(),
|
|
121686
121727
|
totalAtomic: (spendable + setAside + refunds.proven).toString(),
|
|
121687
121728
|
privateSendPendingAtomic: report.split.privateSendPendingAtomic,
|
|
@@ -135788,20 +135829,41 @@ function refundOutcomeText(outcome, nowMs = Date.now()) {
|
|
|
135788
135829
|
if (outcome?.outcome === "refund_arrived") return `The ${amount}refund for ${payment} arrived.`;
|
|
135789
135830
|
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
135831
|
}
|
|
135791
|
-
function
|
|
135792
|
-
return
|
|
135832
|
+
function answerCountsBalance(breakdown) {
|
|
135833
|
+
return Boolean(breakdown) && typeof breakdown === "object" && /^[0-9]+$/.test(String(breakdown.shieldedAtomic ?? ""));
|
|
135834
|
+
}
|
|
135835
|
+
function answerRefundOutcomes(store, breakdown, now = Date.now()) {
|
|
135836
|
+
if (!answerCountsBalance(breakdown)) return [];
|
|
135837
|
+
try {
|
|
135838
|
+
return readFloatRefundOutcomes(store, now, breakdown.refundsArrived);
|
|
135839
|
+
} catch {
|
|
135840
|
+
return [];
|
|
135841
|
+
}
|
|
135842
|
+
}
|
|
135843
|
+
function writeToldRefunds(leased, fresh) {
|
|
135844
|
+
writeHeldRefundOutcomes(leased, fresh.filter(({ held: held2 }) => held2 === true).map(({ floatId }) => floatId));
|
|
135845
|
+
markFloatRefundOutcomesShown(leased, fresh);
|
|
135846
|
+
}
|
|
135847
|
+
function refundNotCounted(breakdown, outcome) {
|
|
135848
|
+
if (outcome?.outcome !== "refund_arrived" || !breakdown || typeof breakdown !== "object") return false;
|
|
135849
|
+
const names = (entry) => typeof entry?.requestId === "string" && entry.requestId === outcome.requestId || typeof entry?.floatId === "string" && entry.floatId === outcome.floatId;
|
|
135850
|
+
return [breakdown.refundsInFlight, breakdown.refundsNotCertain, breakdown.openPayments].some((list) => Array.isArray(list) && list.some(names));
|
|
135851
|
+
}
|
|
135852
|
+
function refundOutcomesToShow(outcomes, shown, exceptFloatId, breakdown) {
|
|
135853
|
+
return outcomes.filter((outcome) => !shown.has(`${outcome.floatId}:${outcome.outcome}`) && !(typeof exceptFloatId === "string" && outcome.floatId === exceptFloatId) && !refundNotCounted(breakdown, outcome));
|
|
135793
135854
|
}
|
|
135794
135855
|
function noticesOnce({
|
|
135795
135856
|
outcomes,
|
|
135796
135857
|
readUnkept,
|
|
135797
135858
|
shown,
|
|
135798
135859
|
exceptFloatId,
|
|
135860
|
+
breakdown,
|
|
135799
135861
|
markRefunds,
|
|
135800
135862
|
markUnkept,
|
|
135801
135863
|
textOf: textOf2 = (outcome) => refundOutcomeText(outcome),
|
|
135802
135864
|
unkeptText = answerNotKeptNoticeWords
|
|
135803
135865
|
}) {
|
|
135804
|
-
const fresh = refundOutcomesToShow(outcomes, shown, exceptFloatId);
|
|
135866
|
+
const fresh = refundOutcomesToShow(outcomes, shown, exceptFloatId, breakdown);
|
|
135805
135867
|
let unkept;
|
|
135806
135868
|
let refundNotices;
|
|
135807
135869
|
let paidNotices;
|
|
@@ -135810,21 +135872,13 @@ function noticesOnce({
|
|
|
135810
135872
|
refundNotices = fresh.map((outcome) => textOf2(outcome));
|
|
135811
135873
|
paidNotices = unkept.map((notice) => unkeptText(notice));
|
|
135812
135874
|
} catch {
|
|
135813
|
-
return {
|
|
135875
|
+
return {};
|
|
135814
135876
|
}
|
|
135815
135877
|
for (const { floatId, outcome } of fresh) shown.add(`${floatId}:${outcome}`);
|
|
135816
135878
|
for (const { requestId } of unkept) shown.add(`unkept:${requestId}`);
|
|
135817
135879
|
if (fresh.length) markRefunds(fresh);
|
|
135818
135880
|
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) };
|
|
135881
|
+
return { ...refundNotices.length ? { refundNotices } : {}, ...paidNotices.length ? { paidNotices } : {} };
|
|
135828
135882
|
}
|
|
135829
135883
|
function floatRefusal(error, overLimit, tool = "pay_for_service") {
|
|
135830
135884
|
const code2 = String(error?.message ?? "").split(/[\s:;(]/, 1)[0];
|
|
@@ -136991,6 +137045,9 @@ function balanceFields(parts) {
|
|
|
136991
137045
|
// UX136-1: a payment whose seller answered an error while Shinjuku's transfer is open (balanceNow.mjs openPaymentsAtomic).
|
|
136992
137046
|
openPaymentsAtomic: parts.openPaymentsAtomic,
|
|
136993
137047
|
...parts.openPayments?.length ? { openPayments: parts.openPayments } : {},
|
|
137048
|
+
// Lotus to-do 85 follow-up: refunds already in shieldedAtomic with no notice told yet; this answer's notice step tells
|
|
137049
|
+
// them (takeRefundNotices reads only its own answer's breakdown).
|
|
137050
|
+
...parts.refundsArrived?.length ? { refundsArrived: parts.refundsArrived } : {},
|
|
136994
137051
|
setAsideAtomic: parts.setAsideAtomic,
|
|
136995
137052
|
totalAtomic: parts.totalAtomic,
|
|
136996
137053
|
// Parts of a running wallet_unshield private send not sent yet: already taken off shieldedAtomic (R4, no overspend in flight).
|
|
@@ -137508,25 +137565,21 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
137508
137565
|
...share ? { share } : {}
|
|
137509
137566
|
});
|
|
137510
137567
|
const shownRefunds = /* @__PURE__ */ new Set();
|
|
137511
|
-
const takeRefundNotices = (store, exceptFloatId) => {
|
|
137568
|
+
const takeRefundNotices = (store, exceptFloatId, breakdown) => {
|
|
137512
137569
|
let open5;
|
|
137513
137570
|
try {
|
|
137514
137571
|
open5 = store ?? session.openStore();
|
|
137515
137572
|
} catch {
|
|
137516
|
-
return {
|
|
137517
|
-
}
|
|
137518
|
-
let outcomes;
|
|
137519
|
-
try {
|
|
137520
|
-
outcomes = readFloatRefundOutcomes(open5);
|
|
137521
|
-
} catch {
|
|
137522
|
-
outcomes = [];
|
|
137573
|
+
return {};
|
|
137523
137574
|
}
|
|
137575
|
+
const outcomes = answerRefundOutcomes(open5, breakdown);
|
|
137524
137576
|
return noticesOnce({
|
|
137525
137577
|
outcomes,
|
|
137526
137578
|
readUnkept: () => readAnswerNotKeptNotices(open5),
|
|
137527
137579
|
shown: shownRefunds,
|
|
137528
137580
|
exceptFloatId,
|
|
137529
|
-
|
|
137581
|
+
breakdown,
|
|
137582
|
+
markRefunds: (fresh) => underLease((leased) => writeToldRefunds(leased, fresh)).catch(() => {
|
|
137530
137583
|
}),
|
|
137531
137584
|
markUnkept: (unkept) => underLease((leased) => markAnswerNotKeptShown(leased, unkept)).catch(() => {
|
|
137532
137585
|
})
|
|
@@ -137541,11 +137594,10 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
137541
137594
|
return answer;
|
|
137542
137595
|
}
|
|
137543
137596
|
if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return answer;
|
|
137544
|
-
const
|
|
137597
|
+
const notices = takeRefundNotices(store, value2.floatId, value2.breakdown);
|
|
137545
137598
|
if (!notices.refundNotices && !notices.paidNotices) return answer;
|
|
137546
137599
|
return json4({
|
|
137547
137600
|
...value2,
|
|
137548
|
-
...value2.breakdown ? { breakdown: markArrivedRefunds(value2.breakdown, arrived2) } : {},
|
|
137549
137601
|
...notices,
|
|
137550
137602
|
...typeof value2.next === "string" ? { next: `${value2.next.replace(/[.\s]+$/, "")}${noticesStep(notices)}` } : {}
|
|
137551
137603
|
});
|
|
@@ -139225,8 +139277,8 @@ ${canonical5}`;
|
|
|
139225
139277
|
}
|
|
139226
139278
|
mark("mcp-result");
|
|
139227
139279
|
const shinjukuTransaction = floatPaid ? leg1Transaction(paidStore, float, requestId) : null;
|
|
139228
|
-
const { notices, arrived: arrivedRefunds } = takeRefundNotices(paidStore, float?.floatId);
|
|
139229
139280
|
const shownBalance = balanceAnswer(one);
|
|
139281
|
+
const notices = takeRefundNotices(paidStore, float?.floatId, shownBalance.breakdown);
|
|
139230
139282
|
return answerResult(paidAnswerContent({
|
|
139231
139283
|
status: response.status,
|
|
139232
139284
|
headers: response.headers,
|
|
@@ -139247,7 +139299,6 @@ ${canonical5}`;
|
|
|
139247
139299
|
// Leg 1 (this wallet's private payment to Shinjuku, a pool transaction): the seller may return no settle signature.
|
|
139248
139300
|
...floatPaid ? { via: "shinjuku", shinjukuTransaction } : {},
|
|
139249
139301
|
...shownBalance,
|
|
139250
|
-
...shownBalance.breakdown ? { breakdown: markArrivedRefunds(shownBalance.breakdown, arrivedRefunds) } : {},
|
|
139251
139302
|
...notices,
|
|
139252
139303
|
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)
|
|
139253
139304
|
}, "pay_for_service")
|
|
@@ -140155,12 +140206,11 @@ ${canonical5}`;
|
|
|
140155
140206
|
}
|
|
140156
140207
|
}
|
|
140157
140208
|
const landedFrom = (total, sales) => sales <= 0n ? "USDC you added" : sales >= total ? "USDC from your sales" : "USDC you added and from your sales";
|
|
140158
|
-
function walletCard({ one, unshielded, landingAtomic, landingSalesAtomic = 0n, recordFaultAtomic = 0n, sales, store, lastRead,
|
|
140209
|
+
function walletCard({ one, unshielded, landingAtomic, landingSalesAtomic = 0n, recordFaultAtomic = 0n, sales, store, lastRead, refresh = {} }) {
|
|
140159
140210
|
const known = ATOMIC_TEXT.test(String(one.balanceAtomic ?? ""));
|
|
140160
140211
|
const landing = `${landingAtomic > 0n ? `; ${usdcText3(landingAtomic)} ${landedFrom(landingAtomic, landingSalesAtomic)} is being counted` : ""}${sales ? `; ${sales.line}` : ""}`;
|
|
140161
140212
|
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";
|
|
140162
|
-
const
|
|
140163
|
-
const inFlight = /^0*[1-9][0-9]*$/.test(String(inFlightAtomic ?? "")) ? usdcText3(inFlightAtomic) : void 0;
|
|
140213
|
+
const inFlight = /^[1-9][0-9]*$/.test(String(one.breakdown?.refundsInFlightAtomic ?? "")) ? usdcText3(one.breakdown.refundsInFlightAtomic) : void 0;
|
|
140164
140214
|
const checking = refresh.refreshing === true && (refresh.refreshReason === void 0 || refresh.refreshReason === "refund_check");
|
|
140165
140215
|
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}`];
|
|
140166
140216
|
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`);
|
|
@@ -140705,7 +140755,7 @@ ${canonical5}`;
|
|
|
140705
140755
|
if (sales) {
|
|
140706
140756
|
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`;
|
|
140707
140757
|
}
|
|
140708
|
-
const
|
|
140758
|
+
const notices = takeRefundNotices(void 0, void 0, one?.breakdown);
|
|
140709
140759
|
next = `${next}${noticesStep(notices)}`;
|
|
140710
140760
|
if (ownTokens?.tokens.length) {
|
|
140711
140761
|
const count3 = ownTokens.tokens.length + ownTokens.more;
|
|
@@ -140746,7 +140796,7 @@ ${canonical5}`;
|
|
|
140746
140796
|
}
|
|
140747
140797
|
internal.unshieldedTotalAtomic = exitedTotalAtomic ?? null;
|
|
140748
140798
|
const { setAsideAtomic, ...breakdownRest } = one.breakdown;
|
|
140749
|
-
const breakdown =
|
|
140799
|
+
const breakdown = setAsideAtomic === "0" ? breakdownRest : one.breakdown;
|
|
140750
140800
|
if (setAsideAtomic === "0") internal.setAsideAtomic = "0";
|
|
140751
140801
|
const noLimit = (atomic5) => atomic5 === void 0 || atomic5 === null || String(atomic5) === NO_LIMIT_ATOMIC;
|
|
140752
140802
|
const capWords2 = (atomic5) => noLimit(atomic5) ? "no limit" : `${usdcText3(atomic5)} USDC`;
|
|
@@ -140769,7 +140819,7 @@ ${canonical5}`;
|
|
|
140769
140819
|
...reportPublic,
|
|
140770
140820
|
...firstRead ? { status: "reading" } : {},
|
|
140771
140821
|
...balanceTextFields(one),
|
|
140772
|
-
card: walletCard({ one, unshielded, landingAtomic, landingSalesAtomic: landingParts.salesAtomic, recordFaultAtomic: landingParts.recordFaultAtomic, sales, store, lastRead,
|
|
140822
|
+
card: walletCard({ one, unshielded, landingAtomic, landingSalesAtomic: landingParts.salesAtomic, recordFaultAtomic: landingParts.recordFaultAtomic, sales, store, lastRead, refresh }),
|
|
140773
140823
|
...lastRead ? { lastRead } : {},
|
|
140774
140824
|
// joinSteps: the joins, one after another (autoJoin.mjs joinParts joins), when the wallet gets the balance ready by
|
|
140775
140825
|
// itself; doneInMinutes*: the time to send all of it (UX128-9).
|