shinjuku-shield 0.3.202 → 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 +117 -34
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
|
@@ -106148,11 +106148,23 @@ async function pocketPaymentBlocker({ store, name, record, connection, waitMs, c
|
|
|
106148
106148
|
}
|
|
106149
106149
|
let before;
|
|
106150
106150
|
for (let page = 0; page < HISTORY_PAGES; page += 1) {
|
|
106151
|
-
|
|
106152
|
-
|
|
106153
|
-
|
|
106154
|
-
|
|
106155
|
-
|
|
106151
|
+
let list;
|
|
106152
|
+
for (; ; ) {
|
|
106153
|
+
try {
|
|
106154
|
+
list = await connection.getSignaturesForAddress(
|
|
106155
|
+
new import_web3116.PublicKey(record.pocketAta),
|
|
106156
|
+
{ limit: HISTORY_PAGE, minContextSlot: finalizedSlot, ...before ? { before } : {} },
|
|
106157
|
+
"finalized"
|
|
106158
|
+
);
|
|
106159
|
+
break;
|
|
106160
|
+
} catch (error) {
|
|
106161
|
+
if (error?.code !== MIN_CONTEXT_SLOT_NOT_REACHED) throw error;
|
|
106162
|
+
if (clock2.now() + DEAD_POLL_MS > deadline) {
|
|
106163
|
+
return { why: `its blockhash is proven expired at finalized slot ${finalizedSlot}, but this RPC's history has not reached that slot yet; rerun in a few seconds (nothing is lost)` };
|
|
106164
|
+
}
|
|
106165
|
+
await clock2.sleep(DEAD_POLL_MS);
|
|
106166
|
+
}
|
|
106167
|
+
}
|
|
106156
106168
|
for (const entry of list) {
|
|
106157
106169
|
if (lifetime && entry.slot <= Number(lifetime.readAtSlot) || entry.signature === exits.first) return { finalizedSlot };
|
|
106158
106170
|
if (entry.err !== null || exits.all.has(entry.signature)) continue;
|
|
@@ -110133,6 +110145,16 @@ function floatSellerHost(record) {
|
|
|
110133
110145
|
return void 0;
|
|
110134
110146
|
}
|
|
110135
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
|
+
}
|
|
110136
110158
|
function readFloatRefundOutcomes(store) {
|
|
110137
110159
|
const outcomes = [];
|
|
110138
110160
|
let names;
|
|
@@ -110147,7 +110169,17 @@ function readFloatRefundOutcomes(store) {
|
|
|
110147
110169
|
const record = store.readWal(name);
|
|
110148
110170
|
if (record?.schema !== FLOAT_PAYMENT_SCHEMA2 || floatRecordState(record) !== "refund_pending") continue;
|
|
110149
110171
|
if (record.refundOutcome === void 0 || record.refundOutcomeShown !== false) continue;
|
|
110150
|
-
|
|
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
|
+
});
|
|
110151
110183
|
} catch {
|
|
110152
110184
|
}
|
|
110153
110185
|
}
|
|
@@ -112093,7 +112125,7 @@ function paidResult(record, replayed) {
|
|
|
112093
112125
|
float: { floatId: record.floatId }
|
|
112094
112126
|
};
|
|
112095
112127
|
}
|
|
112096
|
-
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;
|
|
112097
112129
|
var init_floatPay = __esm({
|
|
112098
112130
|
"wallet/src/pay/floatPay.mjs"() {
|
|
112099
112131
|
"use strict";
|
|
@@ -112188,6 +112220,8 @@ var init_floatPay = __esm({
|
|
|
112188
112220
|
RESIGN_ANSWER_MAX_BYTES = 128 * 1024;
|
|
112189
112221
|
floatPaymentWalName = (requestKey) => `${FLOAT_PAYMENT_WAL_PREFIX2}${requestKey}`;
|
|
112190
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);
|
|
112191
112225
|
FLOAT_KEEP_BYTES_MS = 6e5;
|
|
112192
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 ?? "")));
|
|
112193
112227
|
FLOAT_KEEP_OPEN_REQUEST_MS = 36e5;
|
|
@@ -116238,6 +116272,13 @@ function sellerInputLine(missing, line, room = SAY_MAX_WORDS) {
|
|
|
116238
116272
|
const lines = tries.map((text3) => line(text3, list.length));
|
|
116239
116273
|
return lines.find((text3) => words(text3) <= room) ?? lines[lines.length - 1];
|
|
116240
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
|
+
}
|
|
116241
116282
|
function spendSentence(a, tails = ["."], room = SAY_MAX_WORDS) {
|
|
116242
116283
|
if (!ATOMIC7.test(String(a?.balanceAtomic ?? ""))) return void 0;
|
|
116243
116284
|
const heads = spendHeads(a.balanceAtomic, a.largestPaymentAtomic, a);
|
|
@@ -117705,7 +117746,7 @@ var init_say = __esm({
|
|
|
117705
117746
|
doneInText = (a) => Number.isSafeInteger(a.doneInMinutesLow) && Number.isSafeInteger(a.doneInMinutesHigh) ? `about ${a.doneInMinutesLow} to ${a.doneInMinutesHigh} minutes` : "";
|
|
117706
117747
|
positive = (text3) => text3 !== void 0 && text3 !== "0";
|
|
117707
117748
|
str = (value2) => typeof value2 === "string" ? value2 : "";
|
|
117708
|
-
refundInFlight = (a) =>
|
|
117749
|
+
refundInFlight = (a) => usdcText2(refundInFlightAtomic(a.breakdown));
|
|
117709
117750
|
sellerAnswered = (status, data) => status >= 500 ? "had a server error" : status >= 400 ? "refused the request" : `sent no ${data}`;
|
|
117710
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";
|
|
117711
117752
|
OWN_WORK_WORDS = Object.freeze({
|
|
@@ -135739,11 +135780,51 @@ async function sellerTokenAccountExists(connection, asset, payTo) {
|
|
|
135739
135780
|
return void 0;
|
|
135740
135781
|
}
|
|
135741
135782
|
}
|
|
135742
|
-
function refundOutcomeText(outcome) {
|
|
135743
|
-
const amount = ATOMIC_TEXT.test(String(outcome?.paidAtomic ?? "")) ? `${usdcText3(outcome.paidAtomic)} USDC` : "
|
|
135744
|
-
const
|
|
135745
|
-
|
|
135746
|
-
|
|
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) };
|
|
135747
135828
|
}
|
|
135748
135829
|
function floatRefusal(error, overLimit, tool = "pay_for_service") {
|
|
135749
135830
|
const code2 = String(error?.message ?? "").split(/[\s:;(]/, 1)[0];
|
|
@@ -137427,12 +137508,12 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
137427
137508
|
...share ? { share } : {}
|
|
137428
137509
|
});
|
|
137429
137510
|
const shownRefunds = /* @__PURE__ */ new Set();
|
|
137430
|
-
const takeRefundNotices = (store) => {
|
|
137511
|
+
const takeRefundNotices = (store, exceptFloatId) => {
|
|
137431
137512
|
let open5;
|
|
137432
137513
|
try {
|
|
137433
137514
|
open5 = store ?? session.openStore();
|
|
137434
137515
|
} catch {
|
|
137435
|
-
return {};
|
|
137516
|
+
return { notices: {}, arrived: [] };
|
|
137436
137517
|
}
|
|
137437
137518
|
let outcomes;
|
|
137438
137519
|
try {
|
|
@@ -137440,18 +137521,16 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
137440
137521
|
} catch {
|
|
137441
137522
|
outcomes = [];
|
|
137442
137523
|
}
|
|
137443
|
-
|
|
137444
|
-
|
|
137445
|
-
|
|
137446
|
-
|
|
137447
|
-
|
|
137448
|
-
|
|
137449
|
-
|
|
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
|
+
})
|
|
137450
137533
|
});
|
|
137451
|
-
return {
|
|
137452
|
-
...fresh.length ? { refundNotices: fresh.map(refundOutcomeText) } : {},
|
|
137453
|
-
...unkept.length ? { paidNotices: unkept.map(answerNotKeptNoticeWords) } : {}
|
|
137454
|
-
};
|
|
137455
137534
|
};
|
|
137456
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("");
|
|
137457
137536
|
const withRefundNotices = (answer, store) => {
|
|
@@ -137462,10 +137541,11 @@ ${key}`).digest("hex").slice(0, 40)}.json`);
|
|
|
137462
137541
|
return answer;
|
|
137463
137542
|
}
|
|
137464
137543
|
if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return answer;
|
|
137465
|
-
const notices = takeRefundNotices(store);
|
|
137544
|
+
const { notices, arrived: arrived2 } = takeRefundNotices(store, value2.floatId);
|
|
137466
137545
|
if (!notices.refundNotices && !notices.paidNotices) return answer;
|
|
137467
137546
|
return json4({
|
|
137468
137547
|
...value2,
|
|
137548
|
+
...value2.breakdown ? { breakdown: markArrivedRefunds(value2.breakdown, arrived2) } : {},
|
|
137469
137549
|
...notices,
|
|
137470
137550
|
...typeof value2.next === "string" ? { next: `${value2.next.replace(/[.\s]+$/, "")}${noticesStep(notices)}` } : {}
|
|
137471
137551
|
});
|
|
@@ -139145,7 +139225,8 @@ ${canonical5}`;
|
|
|
139145
139225
|
}
|
|
139146
139226
|
mark("mcp-result");
|
|
139147
139227
|
const shinjukuTransaction = floatPaid ? leg1Transaction(paidStore, float, requestId) : null;
|
|
139148
|
-
const notices = takeRefundNotices(paidStore);
|
|
139228
|
+
const { notices, arrived: arrivedRefunds } = takeRefundNotices(paidStore, float?.floatId);
|
|
139229
|
+
const shownBalance = balanceAnswer(one);
|
|
139149
139230
|
return answerResult(paidAnswerContent({
|
|
139150
139231
|
status: response.status,
|
|
139151
139232
|
headers: response.headers,
|
|
@@ -139165,7 +139246,8 @@ ${canonical5}`;
|
|
|
139165
139246
|
receiptFinality: unpaid ? "never-finalized" : receipt.receiptFinality ?? null,
|
|
139166
139247
|
// Leg 1 (this wallet's private payment to Shinjuku, a pool transaction): the seller may return no settle signature.
|
|
139167
139248
|
...floatPaid ? { via: "shinjuku", shinjukuTransaction } : {},
|
|
139168
|
-
...
|
|
139249
|
+
...shownBalance,
|
|
139250
|
+
...shownBalance.breakdown ? { breakdown: markArrivedRefunds(shownBalance.breakdown, arrivedRefunds) } : {},
|
|
139169
139251
|
...notices,
|
|
139170
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)
|
|
139171
139253
|
}, "pay_for_service")
|
|
@@ -140073,11 +140155,12 @@ ${canonical5}`;
|
|
|
140073
140155
|
}
|
|
140074
140156
|
}
|
|
140075
140157
|
const landedFrom = (total, sales) => sales <= 0n ? "USDC you added" : sales >= total ? "USDC from your sales" : "USDC you added and from your sales";
|
|
140076
|
-
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 = {} }) {
|
|
140077
140159
|
const known = ATOMIC_TEXT.test(String(one.balanceAtomic ?? ""));
|
|
140078
140160
|
const landing = `${landingAtomic > 0n ? `; ${usdcText3(landingAtomic)} ${landedFrom(landingAtomic, landingSalesAtomic)} is being counted` : ""}${sales ? `; ${sales.line}` : ""}`;
|
|
140079
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";
|
|
140080
|
-
const
|
|
140162
|
+
const inFlightAtomic = refundInFlightAtomic(refundBreakdown);
|
|
140163
|
+
const inFlight = /^0*[1-9][0-9]*$/.test(String(inFlightAtomic ?? "")) ? usdcText3(inFlightAtomic) : void 0;
|
|
140081
140164
|
const checking = refresh.refreshing === true && (refresh.refreshReason === void 0 || refresh.refreshReason === "refund_check");
|
|
140082
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}`];
|
|
140083
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`);
|
|
@@ -140622,7 +140705,7 @@ ${canonical5}`;
|
|
|
140622
140705
|
if (sales) {
|
|
140623
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`;
|
|
140624
140707
|
}
|
|
140625
|
-
const notices = takeRefundNotices();
|
|
140708
|
+
const { notices, arrived: arrivedRefunds } = takeRefundNotices();
|
|
140626
140709
|
next = `${next}${noticesStep(notices)}`;
|
|
140627
140710
|
if (ownTokens?.tokens.length) {
|
|
140628
140711
|
const count3 = ownTokens.tokens.length + ownTokens.more;
|
|
@@ -140663,7 +140746,7 @@ ${canonical5}`;
|
|
|
140663
140746
|
}
|
|
140664
140747
|
internal.unshieldedTotalAtomic = exitedTotalAtomic ?? null;
|
|
140665
140748
|
const { setAsideAtomic, ...breakdownRest } = one.breakdown;
|
|
140666
|
-
const breakdown = setAsideAtomic === "0" ? breakdownRest : one.breakdown;
|
|
140749
|
+
const breakdown = markArrivedRefunds(setAsideAtomic === "0" ? breakdownRest : one.breakdown, arrivedRefunds);
|
|
140667
140750
|
if (setAsideAtomic === "0") internal.setAsideAtomic = "0";
|
|
140668
140751
|
const noLimit = (atomic5) => atomic5 === void 0 || atomic5 === null || String(atomic5) === NO_LIMIT_ATOMIC;
|
|
140669
140752
|
const capWords2 = (atomic5) => noLimit(atomic5) ? "no limit" : `${usdcText3(atomic5)} USDC`;
|
|
@@ -140686,7 +140769,7 @@ ${canonical5}`;
|
|
|
140686
140769
|
...reportPublic,
|
|
140687
140770
|
...firstRead ? { status: "reading" } : {},
|
|
140688
140771
|
...balanceTextFields(one),
|
|
140689
|
-
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 }),
|
|
140690
140773
|
...lastRead ? { lastRead } : {},
|
|
140691
140774
|
// joinSteps: the joins, one after another (autoJoin.mjs joinParts joins), when the wallet gets the balance ready by
|
|
140692
140775
|
// itself; doneInMinutes*: the time to send all of it (UX128-9).
|