shinjuku-shield 0.3.205 → 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 -4
- package/manifest.json +4 -4
- package/package.json +3 -3
- package/shinjuku-wallet.mjs +104 -56
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:
|
|
@@ -100,7 +100,7 @@ Add it yourself. The name of the wallet in your app is `shinjuku`.
|
|
|
100
100
|
Claude Code:
|
|
101
101
|
|
|
102
102
|
```sh
|
|
103
|
-
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.
|
|
103
|
+
claude mcp add --scope user shinjuku -- npx -y --no-audit --no-fund shinjuku-shield@0.3.206 mcp
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
## For builders: check what you install
|
|
@@ -116,7 +116,7 @@ with the Releases table in
|
|
|
116
116
|
Versions are published from GitHub Actions with npm provenance.
|
|
117
117
|
|
|
118
118
|
`shinjuku-shield` is the package that holds the wallet. `shinjuku-shielded`
|
|
119
|
-
0.3.
|
|
119
|
+
0.3.206, its older name, runs this package at the same version, so wallets
|
|
120
120
|
installed under that name keep updating. New installs use `shinjuku`.
|
|
121
121
|
|
|
122
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
|
@@ -110156,7 +110156,7 @@ function paymentTimeText(paidAtMs, nowMs = Date.now()) {
|
|
|
110156
110156
|
function validPaymentTimeMs(ms) {
|
|
110157
110157
|
return Number.isSafeInteger(ms) && ms >= PAYMENT_TIME_MIN_MS && ms <= PAYMENT_TIME_MAX_MS && Number.isFinite(new Date(ms).getTime());
|
|
110158
110158
|
}
|
|
110159
|
-
function readFloatRefundOutcomes(store, now = Date.now()) {
|
|
110159
|
+
function readFloatRefundOutcomes(store, now = Date.now(), arrived2 = []) {
|
|
110160
110160
|
const outcomes = [];
|
|
110161
110161
|
let names;
|
|
110162
110162
|
try {
|
|
@@ -110164,29 +110164,71 @@ function readFloatRefundOutcomes(store, now = Date.now()) {
|
|
|
110164
110164
|
} catch {
|
|
110165
110165
|
return outcomes;
|
|
110166
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));
|
|
110167
110171
|
for (const name of names) {
|
|
110168
110172
|
if (!name.startsWith(FLOAT_PAYMENT_WAL_PREFIX2)) continue;
|
|
110169
110173
|
try {
|
|
110170
110174
|
const record = store.readWal(name);
|
|
110171
110175
|
if (record?.schema !== FLOAT_PAYMENT_SCHEMA2 || !["refund_pending", "submitted"].includes(floatRecordState(record))) continue;
|
|
110172
|
-
if (record.refundOutcome === void 0
|
|
110173
|
-
|
|
110174
|
-
|
|
110175
|
-
|
|
110176
|
-
|
|
110177
|
-
|
|
110178
|
-
|
|
110179
|
-
|
|
110180
|
-
// The first VALID time (Codex round 1 on 7faf9c93: `??` took an invalid non-null time before a valid later one).
|
|
110181
|
-
// and never one after now (Codex round 1 on 41e095b2: a time in the future is no time).
|
|
110182
|
-
paidAtMs: [record.floatPaidAtMs, record.submittedAtMs, record.createdAtMs].find((ms) => validPaymentTimeMs(ms) && ms <= now),
|
|
110183
|
-
...inner.endsWith(":float") ? { requestId: inner.slice(0, -":float".length) } : {}
|
|
110184
|
-
});
|
|
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));
|
|
110185
110184
|
} catch {
|
|
110186
110185
|
}
|
|
110187
110186
|
}
|
|
110188
110187
|
return outcomes;
|
|
110189
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
|
+
}
|
|
110190
110232
|
function markFloatRefundOutcomesShown(store, shown) {
|
|
110191
110233
|
const wanted = new Map(shown.map(({ floatId, outcome }) => [floatId, outcome]));
|
|
110192
110234
|
if (!wanted.size) return;
|
|
@@ -116274,13 +116316,6 @@ function sellerInputLine(missing, line, room = SAY_MAX_WORDS) {
|
|
|
116274
116316
|
const lines = tries.map((text3) => line(text3, list.length));
|
|
116275
116317
|
return lines.find((text3) => words(text3) <= room) ?? lines[lines.length - 1];
|
|
116276
116318
|
}
|
|
116277
|
-
function refundInFlightAtomic(breakdown) {
|
|
116278
|
-
const total = String(breakdown?.refundsInFlightAtomic ?? "");
|
|
116279
|
-
if (!ATOMIC7.test(total)) return void 0;
|
|
116280
|
-
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);
|
|
116281
|
-
const left = BigInt(total) - arrived2;
|
|
116282
|
-
return (left > 0n ? left : 0n).toString();
|
|
116283
|
-
}
|
|
116284
116319
|
function spendSentence(a, tails = ["."], room = SAY_MAX_WORDS) {
|
|
116285
116320
|
if (!ATOMIC7.test(String(a?.balanceAtomic ?? ""))) return void 0;
|
|
116286
116321
|
const heads = spendHeads(a.balanceAtomic, a.largestPaymentAtomic, a);
|
|
@@ -117748,7 +117783,7 @@ var init_say = __esm({
|
|
|
117748
117783
|
doneInText = (a) => Number.isSafeInteger(a.doneInMinutesLow) && Number.isSafeInteger(a.doneInMinutesHigh) ? `about ${a.doneInMinutesLow} to ${a.doneInMinutesHigh} minutes` : "";
|
|
117749
117784
|
positive = (text3) => text3 !== void 0 && text3 !== "0";
|
|
117750
117785
|
str = (value2) => typeof value2 === "string" ? value2 : "";
|
|
117751
|
-
refundInFlight = (a) => usdcText2(
|
|
117786
|
+
refundInFlight = (a) => usdcText2(a.breakdown?.refundsInFlightAtomic);
|
|
117752
117787
|
sellerAnswered = (status, data) => status >= 500 ? "had a server error" : status >= 400 ? "refused the request" : `sent no ${data}`;
|
|
117753
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";
|
|
117754
117789
|
OWN_WORK_WORDS = Object.freeze({
|
|
@@ -121590,6 +121625,7 @@ function floatRefunds(store, snapshot) {
|
|
|
121590
121625
|
const notCertainFor = [];
|
|
121591
121626
|
let open5 = 0n;
|
|
121592
121627
|
const openFor = [];
|
|
121628
|
+
const arrivedFor = [];
|
|
121593
121629
|
for (const name of store.listWal()) {
|
|
121594
121630
|
if (!name.startsWith(FLOAT_PAYMENT_WAL_PREFIX2)) continue;
|
|
121595
121631
|
let record;
|
|
@@ -121609,7 +121645,9 @@ function floatRefunds(store, snapshot) {
|
|
|
121609
121645
|
openFor.push({ ...payment, paidAtomic: refundAtomic });
|
|
121610
121646
|
continue;
|
|
121611
121647
|
}
|
|
121612
|
-
|
|
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;
|
|
121613
121651
|
if (refusedOpen || !knowsRecipients) {
|
|
121614
121652
|
notCertain += BigInt(record.paidAtomic);
|
|
121615
121653
|
notCertainFor.push(refundOf(record));
|
|
@@ -121618,7 +121656,7 @@ function floatRefunds(store, snapshot) {
|
|
|
121618
121656
|
provenFor.push(refundOf(record));
|
|
121619
121657
|
}
|
|
121620
121658
|
}
|
|
121621
|
-
return { proven, notCertain, provenFor, notCertainFor, open: open5, openFor };
|
|
121659
|
+
return { proven, notCertain, provenFor, notCertainFor, open: open5, openFor, arrivedFor };
|
|
121622
121660
|
}
|
|
121623
121661
|
function balanceView(store) {
|
|
121624
121662
|
const neverReceived = /* @__PURE__ */ new Set();
|
|
@@ -121684,6 +121722,7 @@ function partsOf(report, store, snapshot) {
|
|
|
121684
121722
|
refundsNotCertain: refunds.notCertainFor,
|
|
121685
121723
|
openPaymentsAtomic: refunds.open.toString(),
|
|
121686
121724
|
openPayments: refunds.openFor,
|
|
121725
|
+
refundsArrived: refunds.arrivedFor,
|
|
121687
121726
|
setAsideAtomic: setAside.toString(),
|
|
121688
121727
|
totalAtomic: (spendable + setAside + refunds.proven).toString(),
|
|
121689
121728
|
privateSendPendingAtomic: report.split.privateSendPendingAtomic,
|
|
@@ -135790,20 +135829,41 @@ function refundOutcomeText(outcome, nowMs = Date.now()) {
|
|
|
135790
135829
|
if (outcome?.outcome === "refund_arrived") return `The ${amount}refund for ${payment} arrived.`;
|
|
135791
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.`;
|
|
135792
135831
|
}
|
|
135793
|
-
function
|
|
135794
|
-
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));
|
|
135795
135854
|
}
|
|
135796
135855
|
function noticesOnce({
|
|
135797
135856
|
outcomes,
|
|
135798
135857
|
readUnkept,
|
|
135799
135858
|
shown,
|
|
135800
135859
|
exceptFloatId,
|
|
135860
|
+
breakdown,
|
|
135801
135861
|
markRefunds,
|
|
135802
135862
|
markUnkept,
|
|
135803
135863
|
textOf: textOf2 = (outcome) => refundOutcomeText(outcome),
|
|
135804
135864
|
unkeptText = answerNotKeptNoticeWords
|
|
135805
135865
|
}) {
|
|
135806
|
-
const fresh = refundOutcomesToShow(outcomes, shown, exceptFloatId);
|
|
135866
|
+
const fresh = refundOutcomesToShow(outcomes, shown, exceptFloatId, breakdown);
|
|
135807
135867
|
let unkept;
|
|
135808
135868
|
let refundNotices;
|
|
135809
135869
|
let paidNotices;
|
|
@@ -135812,21 +135872,13 @@ function noticesOnce({
|
|
|
135812
135872
|
refundNotices = fresh.map((outcome) => textOf2(outcome));
|
|
135813
135873
|
paidNotices = unkept.map((notice) => unkeptText(notice));
|
|
135814
135874
|
} catch {
|
|
135815
|
-
return {
|
|
135875
|
+
return {};
|
|
135816
135876
|
}
|
|
135817
135877
|
for (const { floatId, outcome } of fresh) shown.add(`${floatId}:${outcome}`);
|
|
135818
135878
|
for (const { requestId } of unkept) shown.add(`unkept:${requestId}`);
|
|
135819
135879
|
if (fresh.length) markRefunds(fresh);
|
|
135820
135880
|
if (unkept.length) markUnkept(unkept);
|
|
135821
|
-
return {
|
|
135822
|
-
notices: { ...refundNotices.length ? { refundNotices } : {}, ...paidNotices.length ? { paidNotices } : {} },
|
|
135823
|
-
arrived: fresh.filter(({ outcome }) => outcome === "refund_arrived")
|
|
135824
|
-
};
|
|
135825
|
-
}
|
|
135826
|
-
function markArrivedRefunds(breakdown, arrived2) {
|
|
135827
|
-
if (!breakdown || !Array.isArray(breakdown.refundsInFlight) || !arrived2?.length) return breakdown;
|
|
135828
|
-
const named = (entry) => arrived2.some((one) => typeof entry?.requestId === "string" && entry.requestId === one.requestId || typeof entry?.floatId === "string" && entry.floatId === one.floatId);
|
|
135829
|
-
return { ...breakdown, refundsInFlight: breakdown.refundsInFlight.map((entry) => named(entry) ? { ...entry, refundArrived: true } : entry) };
|
|
135881
|
+
return { ...refundNotices.length ? { refundNotices } : {}, ...paidNotices.length ? { paidNotices } : {} };
|
|
135830
135882
|
}
|
|
135831
135883
|
function floatRefusal(error, overLimit, tool = "pay_for_service") {
|
|
135832
135884
|
const code2 = String(error?.message ?? "").split(/[\s:;(]/, 1)[0];
|
|
@@ -136993,6 +137045,9 @@ function balanceFields(parts) {
|
|
|
136993
137045
|
// UX136-1: a payment whose seller answered an error while Shinjuku's transfer is open (balanceNow.mjs openPaymentsAtomic).
|
|
136994
137046
|
openPaymentsAtomic: parts.openPaymentsAtomic,
|
|
136995
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 } : {},
|
|
136996
137051
|
setAsideAtomic: parts.setAsideAtomic,
|
|
136997
137052
|
totalAtomic: parts.totalAtomic,
|
|
136998
137053
|
// Parts of a running wallet_unshield private send not sent yet: already taken off shieldedAtomic (R4, no overspend in flight).
|
|
@@ -137510,25 +137565,21 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
137510
137565
|
...share ? { share } : {}
|
|
137511
137566
|
});
|
|
137512
137567
|
const shownRefunds = /* @__PURE__ */ new Set();
|
|
137513
|
-
const takeRefundNotices = (store, exceptFloatId) => {
|
|
137568
|
+
const takeRefundNotices = (store, exceptFloatId, breakdown) => {
|
|
137514
137569
|
let open5;
|
|
137515
137570
|
try {
|
|
137516
137571
|
open5 = store ?? session.openStore();
|
|
137517
137572
|
} catch {
|
|
137518
|
-
return {
|
|
137519
|
-
}
|
|
137520
|
-
let outcomes;
|
|
137521
|
-
try {
|
|
137522
|
-
outcomes = readFloatRefundOutcomes(open5);
|
|
137523
|
-
} catch {
|
|
137524
|
-
outcomes = [];
|
|
137573
|
+
return {};
|
|
137525
137574
|
}
|
|
137575
|
+
const outcomes = answerRefundOutcomes(open5, breakdown);
|
|
137526
137576
|
return noticesOnce({
|
|
137527
137577
|
outcomes,
|
|
137528
137578
|
readUnkept: () => readAnswerNotKeptNotices(open5),
|
|
137529
137579
|
shown: shownRefunds,
|
|
137530
137580
|
exceptFloatId,
|
|
137531
|
-
|
|
137581
|
+
breakdown,
|
|
137582
|
+
markRefunds: (fresh) => underLease((leased) => writeToldRefunds(leased, fresh)).catch(() => {
|
|
137532
137583
|
}),
|
|
137533
137584
|
markUnkept: (unkept) => underLease((leased) => markAnswerNotKeptShown(leased, unkept)).catch(() => {
|
|
137534
137585
|
})
|
|
@@ -137543,11 +137594,10 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
137543
137594
|
return answer;
|
|
137544
137595
|
}
|
|
137545
137596
|
if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return answer;
|
|
137546
|
-
const
|
|
137597
|
+
const notices = takeRefundNotices(store, value2.floatId, value2.breakdown);
|
|
137547
137598
|
if (!notices.refundNotices && !notices.paidNotices) return answer;
|
|
137548
137599
|
return json4({
|
|
137549
137600
|
...value2,
|
|
137550
|
-
...value2.breakdown ? { breakdown: markArrivedRefunds(value2.breakdown, arrived2) } : {},
|
|
137551
137601
|
...notices,
|
|
137552
137602
|
...typeof value2.next === "string" ? { next: `${value2.next.replace(/[.\s]+$/, "")}${noticesStep(notices)}` } : {}
|
|
137553
137603
|
});
|
|
@@ -139227,8 +139277,8 @@ ${canonical5}`;
|
|
|
139227
139277
|
}
|
|
139228
139278
|
mark("mcp-result");
|
|
139229
139279
|
const shinjukuTransaction = floatPaid ? leg1Transaction(paidStore, float, requestId) : null;
|
|
139230
|
-
const { notices, arrived: arrivedRefunds } = takeRefundNotices(paidStore, float?.floatId);
|
|
139231
139280
|
const shownBalance = balanceAnswer(one);
|
|
139281
|
+
const notices = takeRefundNotices(paidStore, float?.floatId, shownBalance.breakdown);
|
|
139232
139282
|
return answerResult(paidAnswerContent({
|
|
139233
139283
|
status: response.status,
|
|
139234
139284
|
headers: response.headers,
|
|
@@ -139249,7 +139299,6 @@ ${canonical5}`;
|
|
|
139249
139299
|
// Leg 1 (this wallet's private payment to Shinjuku, a pool transaction): the seller may return no settle signature.
|
|
139250
139300
|
...floatPaid ? { via: "shinjuku", shinjukuTransaction } : {},
|
|
139251
139301
|
...shownBalance,
|
|
139252
|
-
...shownBalance.breakdown ? { breakdown: markArrivedRefunds(shownBalance.breakdown, arrivedRefunds) } : {},
|
|
139253
139302
|
...notices,
|
|
139254
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)
|
|
139255
139304
|
}, "pay_for_service")
|
|
@@ -140157,12 +140206,11 @@ ${canonical5}`;
|
|
|
140157
140206
|
}
|
|
140158
140207
|
}
|
|
140159
140208
|
const landedFrom = (total, sales) => sales <= 0n ? "USDC you added" : sales >= total ? "USDC from your sales" : "USDC you added and from your sales";
|
|
140160
|
-
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 = {} }) {
|
|
140161
140210
|
const known = ATOMIC_TEXT.test(String(one.balanceAtomic ?? ""));
|
|
140162
140211
|
const landing = `${landingAtomic > 0n ? `; ${usdcText3(landingAtomic)} ${landedFrom(landingAtomic, landingSalesAtomic)} is being counted` : ""}${sales ? `; ${sales.line}` : ""}`;
|
|
140163
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";
|
|
140164
|
-
const
|
|
140165
|
-
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;
|
|
140166
140214
|
const checking = refresh.refreshing === true && (refresh.refreshReason === void 0 || refresh.refreshReason === "refund_check");
|
|
140167
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}`];
|
|
140168
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`);
|
|
@@ -140707,7 +140755,7 @@ ${canonical5}`;
|
|
|
140707
140755
|
if (sales) {
|
|
140708
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`;
|
|
140709
140757
|
}
|
|
140710
|
-
const
|
|
140758
|
+
const notices = takeRefundNotices(void 0, void 0, one?.breakdown);
|
|
140711
140759
|
next = `${next}${noticesStep(notices)}`;
|
|
140712
140760
|
if (ownTokens?.tokens.length) {
|
|
140713
140761
|
const count3 = ownTokens.tokens.length + ownTokens.more;
|
|
@@ -140748,7 +140796,7 @@ ${canonical5}`;
|
|
|
140748
140796
|
}
|
|
140749
140797
|
internal.unshieldedTotalAtomic = exitedTotalAtomic ?? null;
|
|
140750
140798
|
const { setAsideAtomic, ...breakdownRest } = one.breakdown;
|
|
140751
|
-
const breakdown =
|
|
140799
|
+
const breakdown = setAsideAtomic === "0" ? breakdownRest : one.breakdown;
|
|
140752
140800
|
if (setAsideAtomic === "0") internal.setAsideAtomic = "0";
|
|
140753
140801
|
const noLimit = (atomic5) => atomic5 === void 0 || atomic5 === null || String(atomic5) === NO_LIMIT_ATOMIC;
|
|
140754
140802
|
const capWords2 = (atomic5) => noLimit(atomic5) ? "no limit" : `${usdcText3(atomic5)} USDC`;
|
|
@@ -140771,7 +140819,7 @@ ${canonical5}`;
|
|
|
140771
140819
|
...reportPublic,
|
|
140772
140820
|
...firstRead ? { status: "reading" } : {},
|
|
140773
140821
|
...balanceTextFields(one),
|
|
140774
|
-
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 }),
|
|
140775
140823
|
...lastRead ? { lastRead } : {},
|
|
140776
140824
|
// joinSteps: the joins, one after another (autoJoin.mjs joinParts joins), when the wallet gets the balance ready by
|
|
140777
140825
|
// itself; doneInMinutes*: the time to send all of it (UX128-9).
|