shinjuku-shielded 0.3.40 → 0.3.42
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/manifest.json +3 -3
- package/package.json +3 -3
- package/shinjuku-wallet.mjs +176 -35
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": "f55f1fb8f1b63bf4caf94b552f06f6c3126ed8fd598d6d8fe8fc9abd7377b509",
|
|
5
|
+
"bytes": 11232354,
|
|
6
|
+
"sourceCommit": "602ba18e9b8035f26155973016e9d4df9beaa718",
|
|
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",
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shinjuku-shielded",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.42",
|
|
4
4
|
"mcpName": "io.github.ShinjukuStaition/shinjuku-mcp",
|
|
5
5
|
"description": "Shinjuku Shielded, the private x402 facilitator on Solana: the self-custody wallet CLI and its MCP server. Shield, pay, and unshield USDC from any MCP agent, under caps you set.",
|
|
6
|
-
"shinjukuRelease": "
|
|
7
|
-
"shinjukuSha256": "
|
|
6
|
+
"shinjukuRelease": "f55f1fb8",
|
|
7
|
+
"shinjukuSha256": "f55f1fb8f1b63bf4caf94b552f06f6c3126ed8fd598d6d8fe8fc9abd7377b509",
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
9
9
|
"author": "Shinjuku Shielded",
|
|
10
10
|
"homepage": "https://github.com/ShinjukuStaition/shinjuku-mcp#readme",
|
package/shinjuku-wallet.mjs
CHANGED
|
@@ -48426,10 +48426,21 @@ function walNames(directory) {
|
|
|
48426
48426
|
});
|
|
48427
48427
|
}
|
|
48428
48428
|
function bindWalDirectory(directory, key, claim = true) {
|
|
48429
|
-
mkdirSync(directory, { recursive: true, mode: 448 });
|
|
48430
48429
|
const ownerPath = join3(directory, WAL_OWNER_FILE);
|
|
48430
|
+
const verified = verifiedWalOwners.get(key);
|
|
48431
|
+
try {
|
|
48432
|
+
if (verified?.get(resolve3(directory)) === ownerStatId(ownerPath)) return;
|
|
48433
|
+
} catch {
|
|
48434
|
+
}
|
|
48435
|
+
mkdirSync(directory, { recursive: true, mode: 448 });
|
|
48431
48436
|
const identity = createHmac("sha256", key).update(WAL_OWNER_SCHEMA).digest("hex");
|
|
48432
48437
|
const verifyOwner = () => {
|
|
48438
|
+
let statId;
|
|
48439
|
+
try {
|
|
48440
|
+
statId = ownerStatId(ownerPath);
|
|
48441
|
+
} catch {
|
|
48442
|
+
statId = void 0;
|
|
48443
|
+
}
|
|
48433
48444
|
let owner;
|
|
48434
48445
|
try {
|
|
48435
48446
|
owner = JSON.parse(readFileSync(ownerPath, "utf8"));
|
|
@@ -48439,6 +48450,10 @@ function bindWalDirectory(directory, key, claim = true) {
|
|
|
48439
48450
|
if (owner?.schema !== WAL_OWNER_SCHEMA || owner.identity !== identity || Object.keys(owner).sort().join() !== "identity,schema") {
|
|
48440
48451
|
throw new WalletStoreError("wallet_wal_owner_mismatch");
|
|
48441
48452
|
}
|
|
48453
|
+
if (statId === void 0) return;
|
|
48454
|
+
let byDirectory = verifiedWalOwners.get(key);
|
|
48455
|
+
if (!byDirectory) verifiedWalOwners.set(key, byDirectory = /* @__PURE__ */ new Map());
|
|
48456
|
+
byDirectory.set(resolve3(directory), statId);
|
|
48442
48457
|
};
|
|
48443
48458
|
if (existsSync(ownerPath)) {
|
|
48444
48459
|
verifyOwner();
|
|
@@ -48571,7 +48586,7 @@ function openWalletStore(path, passphrase2) {
|
|
|
48571
48586
|
};
|
|
48572
48587
|
return store;
|
|
48573
48588
|
}
|
|
48574
|
-
var STORE_SCHEMA, WAL_SCHEMA, SCRYPT, WAL_OWNER_FILE, WAL_OWNER_SCHEMA, WalletStoreError, KEY_CACHE_LIMIT, keyCacheSecret, keyCache, keyStats, keyCacheId, rememberKey, assertPassphrase, assertWalName;
|
|
48589
|
+
var STORE_SCHEMA, WAL_SCHEMA, SCRYPT, WAL_OWNER_FILE, WAL_OWNER_SCHEMA, WalletStoreError, KEY_CACHE_LIMIT, keyCacheSecret, keyCache, keyStats, keyCacheId, rememberKey, verifiedWalOwners, ownerStatId, assertPassphrase, assertWalName;
|
|
48575
48590
|
var init_store = __esm({
|
|
48576
48591
|
"wallet/src/store/store.mjs"() {
|
|
48577
48592
|
"use strict";
|
|
@@ -48597,6 +48612,11 @@ var init_store = __esm({
|
|
|
48597
48612
|
keyCache.set(id, key);
|
|
48598
48613
|
while (keyCache.size > KEY_CACHE_LIMIT) keyCache.delete(keyCache.keys().next().value);
|
|
48599
48614
|
};
|
|
48615
|
+
verifiedWalOwners = /* @__PURE__ */ new WeakMap();
|
|
48616
|
+
ownerStatId = (path) => {
|
|
48617
|
+
const stat = statSync(path, { bigint: true });
|
|
48618
|
+
return `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
|
|
48619
|
+
};
|
|
48600
48620
|
assertPassphrase = (passphrase2) => {
|
|
48601
48621
|
if (typeof passphrase2 !== "string" || passphrase2.length < 8) {
|
|
48602
48622
|
throw new WalletStoreError("wallet_passphrase_too_short: the wallet passphrase must be at least 8 characters");
|
|
@@ -56623,6 +56643,23 @@ function walletCompactHistoryCache(store) {
|
|
|
56623
56643
|
async function loadWalletP03History(args) {
|
|
56624
56644
|
const runKey = lastRunReportKey(args.store, args.programId, args.pool, args.deploymentIdentity, args.cache);
|
|
56625
56645
|
const prewarm = runKey === void 0 ? void 0 : prewarmedWalks.get(runKey);
|
|
56646
|
+
const share = args.share;
|
|
56647
|
+
if (share !== void 0) {
|
|
56648
|
+
if (prewarm !== void 0 && strictScope.getStore() !== true && args.forceRead !== true && Number.isFinite(share.notBeforeMs) && prewarm.startedAt >= share.notBeforeMs && Date.now() - prewarm.startedAt <= HISTORY_PREWARM_JOIN_MS) {
|
|
56649
|
+
try {
|
|
56650
|
+
const report3 = await prewarm.promise;
|
|
56651
|
+
PREWARMED_REPORTS.add(report3);
|
|
56652
|
+
markPhase("walk-prewarm-shared");
|
|
56653
|
+
return report3;
|
|
56654
|
+
} catch {
|
|
56655
|
+
}
|
|
56656
|
+
}
|
|
56657
|
+
const { share: _share, ...walkArgs } = args;
|
|
56658
|
+
const startedAt2 = Date.now();
|
|
56659
|
+
const report2 = await loadWalletP03HistoryNow(walkArgs);
|
|
56660
|
+
if (runKey !== void 0) recentLoads.set(runKey, { startedAt: startedAt2, report: report2 });
|
|
56661
|
+
return report2;
|
|
56662
|
+
}
|
|
56626
56663
|
if (prewarm !== void 0) {
|
|
56627
56664
|
prewarmedWalks.delete(runKey);
|
|
56628
56665
|
if (strictScope.getStore() !== true && args.forceRead !== true && Date.now() - prewarm.startedAt <= HISTORY_PREWARM_JOIN_MS) {
|
|
@@ -60112,6 +60149,7 @@ var init_sealedCache = __esm({
|
|
|
60112
60149
|
});
|
|
60113
60150
|
|
|
60114
60151
|
// wallet/src/recovery/recoveryCache.mjs
|
|
60152
|
+
import { performance as performance2 } from "node:perf_hooks";
|
|
60115
60153
|
function contextBinding(context) {
|
|
60116
60154
|
return [
|
|
60117
60155
|
context.transitionKind,
|
|
@@ -60163,7 +60201,28 @@ function decodeOutput(value) {
|
|
|
60163
60201
|
VERIFIED_OPENINGS.add(opening);
|
|
60164
60202
|
return { ...output2, leafIndex: decimal3(value.leafIndex) };
|
|
60165
60203
|
}
|
|
60166
|
-
function openRecoveryCache(store,
|
|
60204
|
+
function openRecoveryCache(store, ids) {
|
|
60205
|
+
const run5 = openRecoveryCacheSteps(store, ids);
|
|
60206
|
+
let step = run5.next();
|
|
60207
|
+
while (!step.done) step = run5.next();
|
|
60208
|
+
return step.value;
|
|
60209
|
+
}
|
|
60210
|
+
async function openRecoveryCacheSliced(store, ids) {
|
|
60211
|
+
const run5 = openRecoveryCacheSteps(store, ids);
|
|
60212
|
+
let started = performance2.now();
|
|
60213
|
+
let step = run5.next();
|
|
60214
|
+
while (!step.done) {
|
|
60215
|
+
if (performance2.now() - started >= 25) {
|
|
60216
|
+
await new Promise((resolve38) => {
|
|
60217
|
+
setImmediate(resolve38);
|
|
60218
|
+
});
|
|
60219
|
+
started = performance2.now();
|
|
60220
|
+
}
|
|
60221
|
+
step = run5.next();
|
|
60222
|
+
}
|
|
60223
|
+
return step.value;
|
|
60224
|
+
}
|
|
60225
|
+
function* openRecoveryCacheSteps(store, { programId, pool: pool2 }) {
|
|
60167
60226
|
const file = sealedCacheFile(store, { file: RECOVERY_CACHE_FILE, schema: RECOVERY_CACHE_SCHEMA, keyLabel: KEY_LABEL });
|
|
60168
60227
|
if (!file) return void 0;
|
|
60169
60228
|
const read = file.read();
|
|
@@ -60180,6 +60239,7 @@ function openRecoveryCache(store, { programId, pool: pool2 }) {
|
|
|
60180
60239
|
entryKey(memo2.digest, memo2.binding),
|
|
60181
60240
|
{ digest: memo2.digest, binding: memo2.binding, outputs: memo2.outputs.map(decodeOutput) }
|
|
60182
60241
|
);
|
|
60242
|
+
yield;
|
|
60183
60243
|
}
|
|
60184
60244
|
} catch {
|
|
60185
60245
|
entries.clear();
|
|
@@ -60245,14 +60305,14 @@ var init_recoveryCache = __esm({
|
|
|
60245
60305
|
|
|
60246
60306
|
// wallet/src/recovery/memoDecryptPool.mjs
|
|
60247
60307
|
import { availableParallelism } from "node:os";
|
|
60248
|
-
import { performance as
|
|
60308
|
+
import { performance as performance3 } from "node:perf_hooks";
|
|
60249
60309
|
import { Worker as Worker2 } from "node:worker_threads";
|
|
60250
60310
|
function sliceClock() {
|
|
60251
|
-
let started =
|
|
60311
|
+
let started = performance3.now();
|
|
60252
60312
|
return async () => {
|
|
60253
|
-
if (
|
|
60313
|
+
if (performance3.now() - started < SLICE_MS) return;
|
|
60254
60314
|
await yieldTurn();
|
|
60255
|
-
started =
|
|
60315
|
+
started = performance3.now();
|
|
60256
60316
|
};
|
|
60257
60317
|
}
|
|
60258
60318
|
async function sharedXOnMainThread(xs, eta) {
|
|
@@ -60581,7 +60641,7 @@ var init_successorHistories = __esm({
|
|
|
60581
60641
|
// wallet/src/recovery/recover.mjs
|
|
60582
60642
|
import { createHash as createHash15 } from "node:crypto";
|
|
60583
60643
|
import { join as join10, resolve as resolve10 } from "node:path";
|
|
60584
|
-
import { performance as
|
|
60644
|
+
import { performance as performance4 } from "node:perf_hooks";
|
|
60585
60645
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
60586
60646
|
function pinnedGenerator2(profileVector) {
|
|
60587
60647
|
if (profileVector?.payerKeys?.generator) return profileVector.payerKeys.generator;
|
|
@@ -60652,18 +60712,18 @@ function walMemoBundles(store) {
|
|
|
60652
60712
|
}
|
|
60653
60713
|
async function walMemoBundlesSliced(store) {
|
|
60654
60714
|
const bundles = /* @__PURE__ */ new Map();
|
|
60655
|
-
let started =
|
|
60715
|
+
let started = performance4.now();
|
|
60656
60716
|
for (const name of store.listWal()) {
|
|
60657
60717
|
const record = store.readWal(name);
|
|
60658
60718
|
if (record?.memoBundleHex) {
|
|
60659
60719
|
const bytes2 = Uint8Array.from(Buffer.from(hexOf2(record.memoBundleHex), "hex"));
|
|
60660
60720
|
bundles.set(hexOf2(record.memoDigest ?? bundleDigest2(bytes2)), bytes2);
|
|
60661
60721
|
}
|
|
60662
|
-
if (
|
|
60722
|
+
if (performance4.now() - started >= 25) {
|
|
60663
60723
|
await new Promise((resolve38) => {
|
|
60664
60724
|
setImmediate(resolve38);
|
|
60665
60725
|
});
|
|
60666
|
-
started =
|
|
60726
|
+
started = performance4.now();
|
|
60667
60727
|
}
|
|
60668
60728
|
}
|
|
60669
60729
|
return bundles;
|
|
@@ -60742,7 +60802,7 @@ async function legacyOutputs({ store, digests, serviceUrl: serviceUrl2, fresh, d
|
|
|
60742
60802
|
return { entries, bundlesExamined: bundles.length };
|
|
60743
60803
|
}
|
|
60744
60804
|
async function syncedOutputs({ store, finalizedHistory: finalizedHistory2, digests, serviceUrl: serviceUrl2, fresh, deps, chainProgramId, pool: pool2, eta, decrypt }) {
|
|
60745
|
-
const cache = deps.recoveryCache !== void 0 ? deps.recoveryCache :
|
|
60805
|
+
const cache = deps.recoveryCache !== void 0 ? deps.recoveryCache : await openRecoveryCacheSliced(store, { programId: chainProgramId.toBase58(), pool: pool2.toBase58() });
|
|
60746
60806
|
const contexts = finalizedHistory2.contexts;
|
|
60747
60807
|
const found = /* @__PURE__ */ new Map();
|
|
60748
60808
|
const pending = [];
|
|
@@ -60779,13 +60839,13 @@ async function syncedOutputs({ store, finalizedHistory: finalizedHistory2, diges
|
|
|
60779
60839
|
}
|
|
60780
60840
|
}
|
|
60781
60841
|
const items = [];
|
|
60782
|
-
let sliceStart =
|
|
60842
|
+
let sliceStart = performance4.now();
|
|
60783
60843
|
for (const context of chunk) {
|
|
60784
|
-
if (
|
|
60844
|
+
if (performance4.now() - sliceStart >= 25) {
|
|
60785
60845
|
await new Promise((resolve38) => {
|
|
60786
60846
|
setImmediate(resolve38);
|
|
60787
60847
|
});
|
|
60788
|
-
sliceStart =
|
|
60848
|
+
sliceStart = performance4.now();
|
|
60789
60849
|
}
|
|
60790
60850
|
const digest2 = hexOf2(context.memoDigest);
|
|
60791
60851
|
const fromService = served.get(digest2);
|
|
@@ -60940,8 +61000,15 @@ async function runRecover({ store, connection, programId, digests, serviceUrl: s
|
|
|
60940
61000
|
}
|
|
60941
61001
|
markPhase("recover-memos");
|
|
60942
61002
|
const recovered = [];
|
|
61003
|
+
let replayStarted = performance4.now();
|
|
60943
61004
|
for (const { digest: digest2, context, outputs } of read.entries) {
|
|
60944
61005
|
for (const output2 of outputs) {
|
|
61006
|
+
if (performance4.now() - replayStarted >= 25) {
|
|
61007
|
+
await new Promise((resolve38) => {
|
|
61008
|
+
setImmediate(resolve38);
|
|
61009
|
+
});
|
|
61010
|
+
replayStarted = performance4.now();
|
|
61011
|
+
}
|
|
60945
61012
|
const replayValue = replayValueOf(
|
|
60946
61013
|
output2.kind,
|
|
60947
61014
|
context.poolDomain,
|
|
@@ -72476,8 +72543,15 @@ function respendNoteSubset({ accounts, notes, outputIndex, amountAtomic, refused
|
|
|
72476
72543
|
return void 0;
|
|
72477
72544
|
}
|
|
72478
72545
|
function exitReservedNoteCommitments(store) {
|
|
72546
|
+
const run5 = exitReservedNoteCommitmentSteps(store);
|
|
72547
|
+
let step = run5.next();
|
|
72548
|
+
while (!step.done) step = run5.next();
|
|
72549
|
+
return step.value;
|
|
72550
|
+
}
|
|
72551
|
+
function* exitReservedNoteCommitmentSteps(store) {
|
|
72479
72552
|
const reserved = /* @__PURE__ */ new Set();
|
|
72480
72553
|
for (const name of typeof store?.listWal === "function" ? store.listWal() : []) {
|
|
72554
|
+
yield;
|
|
72481
72555
|
const selfPay2 = name.startsWith("self-pay-");
|
|
72482
72556
|
if (!selfPay2 && !name.startsWith("note-exit-")) continue;
|
|
72483
72557
|
if (name.startsWith("self-pay-merge-")) continue;
|
|
@@ -72531,7 +72605,7 @@ function startFinalizedChainTime(connection) {
|
|
|
72531
72605
|
return time + Math.floor(age / 1e3);
|
|
72532
72606
|
};
|
|
72533
72607
|
}
|
|
72534
|
-
async function everyAccountHeld({ store, connection, programId, serviceUrl: serviceUrl2, reservedReplayValues, deps = {} }) {
|
|
72608
|
+
async function everyAccountHeld({ store, connection, programId, serviceUrl: serviceUrl2, reservedReplayValues, amountAtomic, deps = {} }) {
|
|
72535
72609
|
if (typeof deps.walkHistory !== "function") fail15("walk_history_required");
|
|
72536
72610
|
const viewing = deriveWalletViewingAuthority2({ seedBytes: seedBytes5(store.state), generator: pinnedGenerator4() });
|
|
72537
72611
|
const history = assertAuthenticatedFinalizedP03History(await withRecentWalletHistory(() => deps.walkHistory()));
|
|
@@ -72542,14 +72616,31 @@ async function everyAccountHeld({ store, connection, programId, serviceUrl: serv
|
|
|
72542
72616
|
serviceUrl: serviceUrl2,
|
|
72543
72617
|
deps: { fetchImpl: deps.fetchImpl, finalizedHistory: history, transitionContextFor: history.transitionContextFor }
|
|
72544
72618
|
});
|
|
72545
|
-
|
|
72619
|
+
const poolDomain = history.contexts[0]?.poolDomain;
|
|
72620
|
+
const held = (entry) => {
|
|
72546
72621
|
if (entry.leafIndex === void 0 || entry.leafIndex === null) return true;
|
|
72547
72622
|
try {
|
|
72548
|
-
|
|
72623
|
+
const value = entry.kind === "account" ? accountNullifier(entry.commitment, viewing.eta, entry.leafIndex) : noteNullifier2(poolDomain, entry.commitment, viewing.eta, entry.leafIndex);
|
|
72624
|
+
return reservedReplayValues.has(value.toString());
|
|
72549
72625
|
} catch {
|
|
72550
72626
|
return true;
|
|
72551
72627
|
}
|
|
72552
|
-
}
|
|
72628
|
+
};
|
|
72629
|
+
const unspent = (kind) => recovery.recovered.filter((entry) => entry.kind === kind && entry.spendStatus === "unspent");
|
|
72630
|
+
const unspentAccounts = unspent("account");
|
|
72631
|
+
const unheldAccounts = unspentAccounts.filter((entry) => !held(entry));
|
|
72632
|
+
if (unheldAccounts.length === 0) return true;
|
|
72633
|
+
if (amountAtomic === void 0) return false;
|
|
72634
|
+
const unspentNotes = unspent("note");
|
|
72635
|
+
const unheldNotes = unspentNotes.filter((entry) => !held(entry));
|
|
72636
|
+
const anyHeld = unheldAccounts.length !== unspentAccounts.length || unheldNotes.length !== unspentNotes.length && (() => {
|
|
72637
|
+
const exitReserved = exitReservedNoteCommitments(store);
|
|
72638
|
+
return unspentNotes.some((entry) => held(entry) && !exitReserved.has(BigInt(entry.commitment).toString()));
|
|
72639
|
+
})();
|
|
72640
|
+
if (!anyHeld) return false;
|
|
72641
|
+
const largestAccount = unheldAccounts.reduce((max, entry) => BigInt(entry.account.b) > max ? BigInt(entry.account.b) : max, 0n);
|
|
72642
|
+
const notesValue = unheldNotes.reduce((sum2, entry) => sum2 + BigInt(entry.note.b), 0n);
|
|
72643
|
+
return largestAccount + notesValue < BigInt(amountAtomic);
|
|
72553
72644
|
}
|
|
72554
72645
|
async function prepareRecoveredPayment({
|
|
72555
72646
|
store,
|
|
@@ -93148,6 +93239,7 @@ async function payResourceOnce({
|
|
|
93148
93239
|
programId,
|
|
93149
93240
|
serviceUrl: serviceUrl2,
|
|
93150
93241
|
reservedReplayValues: held,
|
|
93242
|
+
amountAtomic: maximumAtomic,
|
|
93151
93243
|
deps: { fetchImpl: deps.fetchImpl, walkHistory: finality.walkHistory }
|
|
93152
93244
|
}));
|
|
93153
93245
|
} catch {
|
|
@@ -96638,6 +96730,30 @@ function sellerHttpReply(result) {
|
|
|
96638
96730
|
const body = result.result ? Buffer.from(result.result.bodyBase64, "base64") : Buffer.from(JSON.stringify(result.paymentRequired ?? { code: result.code, ...result.reason === FACILITATOR_UNDERFUNDED ? { reason: result.reason } : {} }));
|
|
96639
96731
|
return { status: result.status, headers, body };
|
|
96640
96732
|
}
|
|
96733
|
+
function earlyConfirmedTransaction(connection, signature) {
|
|
96734
|
+
if (typeof connection.getTransaction !== "function" || typeof connection.getVerifiedTransaction === "function" || typeof connection.getVerifiedTransactions === "function") {
|
|
96735
|
+
return void 0;
|
|
96736
|
+
}
|
|
96737
|
+
return connection.getTransaction(signature, CONFIRMED_TRANSACTION_READ).then((raw) => raw ?? null, () => null);
|
|
96738
|
+
}
|
|
96739
|
+
function withPrefetchedTransaction(connection, signature, prefetched) {
|
|
96740
|
+
let pending = prefetched;
|
|
96741
|
+
const getTransaction = (requested, options) => {
|
|
96742
|
+
if (pending && requested === signature && options?.commitment === CONFIRMED_TRANSACTION_READ.commitment && options?.maxSupportedTransactionVersion === CONFIRMED_TRANSACTION_READ.maxSupportedTransactionVersion) {
|
|
96743
|
+
const answer = pending;
|
|
96744
|
+
pending = void 0;
|
|
96745
|
+
return Promise.resolve(answer);
|
|
96746
|
+
}
|
|
96747
|
+
return connection.getTransaction(requested, options);
|
|
96748
|
+
};
|
|
96749
|
+
return new Proxy(connection, {
|
|
96750
|
+
get(target, property) {
|
|
96751
|
+
if (property === "getTransaction") return getTransaction;
|
|
96752
|
+
const value = Reflect.get(target, property, target);
|
|
96753
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
96754
|
+
}
|
|
96755
|
+
});
|
|
96756
|
+
}
|
|
96641
96757
|
async function createSellerAdapter({
|
|
96642
96758
|
config,
|
|
96643
96759
|
connection,
|
|
@@ -96953,11 +97069,21 @@ async function createSellerAdapter({
|
|
|
96953
97069
|
mark("receipt-unverified");
|
|
96954
97070
|
return completed2;
|
|
96955
97071
|
}
|
|
96956
|
-
const
|
|
97072
|
+
const early = earlyConfirmedTransaction(connection, receipt.transaction);
|
|
97073
|
+
let polled = false;
|
|
97074
|
+
const status = await visibleReceiptStatus(
|
|
97075
|
+
connection,
|
|
97076
|
+
receipt.transaction,
|
|
97077
|
+
{ ...visibility, sleep: (ms) => {
|
|
97078
|
+
polled = true;
|
|
97079
|
+
return visibility.sleep(ms);
|
|
97080
|
+
} }
|
|
97081
|
+
);
|
|
96957
97082
|
const level = receiptStatusLevel(status);
|
|
96958
97083
|
if (!level || require2 === "finalized" && level !== "finalized") fail26("receipt_pending");
|
|
97084
|
+
const prefetched = early && !polled && level === "confirmed" ? await early : null;
|
|
96959
97085
|
await validateReceiptTransaction(
|
|
96960
|
-
connection,
|
|
97086
|
+
prefetched ? withPrefetchedTransaction(connection, receipt.transaction, prefetched) : connection,
|
|
96961
97087
|
receipt,
|
|
96962
97088
|
{ paymentHeader: offer.paymentHeader },
|
|
96963
97089
|
{ pool: profile.pool },
|
|
@@ -97289,7 +97415,7 @@ async function createSellerAdapter({
|
|
|
97289
97415
|
}));
|
|
97290
97416
|
return { server, handle, close, signerPublicKey, settledTransactions, offerSummaries };
|
|
97291
97417
|
}
|
|
97292
|
-
var import_web3120, BINDING, SCHEMA2, OFFERS_LAYOUT, SNAPSHOT_EVERY_MS, LOADER2, canonical4, storeProfileIdentity, jsonSafe, bigint, encodeHeader, PAYMENT_REFUSED, FACILITATOR_UNDERFUNDED, DEFINITE_VERIFY_REFUSALS, definiteVerifyRefusal, refusedBeforeSettlement, ANCHOR_REQUEST_TIMEOUT_MS2, ANCHOR_POLL_ATTEMPTS, ANCHOR_POLL_MS, PRE_SETTLE_REUSE_MARGIN_S, PRE_SETTLE_REUSE_MAX_AGE_MS, FINALIZED_MEMO_MAX_AGE_MS, pause, FOLLOW_UP_DELAYS_MS, FOLLOW_UP_RESETTLE_FROM;
|
|
97418
|
+
var import_web3120, BINDING, SCHEMA2, OFFERS_LAYOUT, SNAPSHOT_EVERY_MS, LOADER2, canonical4, storeProfileIdentity, jsonSafe, bigint, encodeHeader, PAYMENT_REFUSED, FACILITATOR_UNDERFUNDED, DEFINITE_VERIFY_REFUSALS, definiteVerifyRefusal, refusedBeforeSettlement, ANCHOR_REQUEST_TIMEOUT_MS2, ANCHOR_POLL_ATTEMPTS, ANCHOR_POLL_MS, PRE_SETTLE_REUSE_MARGIN_S, PRE_SETTLE_REUSE_MAX_AGE_MS, FINALIZED_MEMO_MAX_AGE_MS, pause, FOLLOW_UP_DELAYS_MS, FOLLOW_UP_RESETTLE_FROM, CONFIRMED_TRANSACTION_READ;
|
|
97293
97419
|
var init_service = __esm({
|
|
97294
97420
|
"wallet/src/seller/service.mjs"() {
|
|
97295
97421
|
"use strict";
|
|
@@ -97358,6 +97484,7 @@ var init_service = __esm({
|
|
|
97358
97484
|
6e5
|
|
97359
97485
|
]);
|
|
97360
97486
|
FOLLOW_UP_RESETTLE_FROM = 4;
|
|
97487
|
+
CONFIRMED_TRANSACTION_READ = Object.freeze({ commitment: "confirmed", maxSupportedTransactionVersion: 1 });
|
|
97361
97488
|
}
|
|
97362
97489
|
});
|
|
97363
97490
|
|
|
@@ -97533,20 +97660,19 @@ async function selfPay({
|
|
|
97533
97660
|
...record,
|
|
97534
97661
|
state: "paid",
|
|
97535
97662
|
transaction,
|
|
97536
|
-
noteCommitment: (deps.findNote ?? selfPaidNoteCommitment)(store, unshieldId, eta).toString()
|
|
97663
|
+
noteCommitment: (await (deps.findNote ?? selfPaidNoteCommitment)(store, unshieldId, eta)).toString()
|
|
97537
97664
|
};
|
|
97538
97665
|
store.writeWal(name, record);
|
|
97539
97666
|
return record;
|
|
97540
97667
|
}
|
|
97541
|
-
function selfPaidNoteCommitment(store, unshieldId, eta) {
|
|
97668
|
+
async function selfPaidNoteCommitment(store, unshieldId, eta) {
|
|
97542
97669
|
const key = sha256Hex2(Buffer.from(selfPayRequestId(unshieldId), "utf8"));
|
|
97543
97670
|
const payment = store.readWal(`resource-payment-${key}`);
|
|
97544
97671
|
const proof = store.readWal(`resource-proof-${key}`)?.proved?.output;
|
|
97545
97672
|
const accepted = payment?.paymentRequired?.accepts?.find((entry) => entry.scheme === "shielded-exact");
|
|
97546
97673
|
if (!proof?.memoBundleHex || !accepted) fail27("payment_wal_missing");
|
|
97547
|
-
const { accepted: outputs } =
|
|
97674
|
+
const [{ accepted: outputs }] = await trialDecryptBundles([{
|
|
97548
97675
|
bundleBytes: Uint8Array.from(Buffer.from(proof.memoBundleHex.replace(/^0x/, ""), "hex")),
|
|
97549
|
-
eta,
|
|
97550
97676
|
poolDomain: BigInt(proof.poolDomain),
|
|
97551
97677
|
outCommitment: BigInt(proof.outCommitment),
|
|
97552
97678
|
contextCommitment: BigInt(proof.quoteCommitment),
|
|
@@ -97554,7 +97680,7 @@ function selfPaidNoteCommitment(store, unshieldId, eta) {
|
|
|
97554
97680
|
transitionKind: 2,
|
|
97555
97681
|
zeroLeaf: P03_PINNED_ZERO_LEAF,
|
|
97556
97682
|
subtreeStartIndex: 0n
|
|
97557
|
-
});
|
|
97683
|
+
}], eta);
|
|
97558
97684
|
const notes = outputs.filter((entry) => entry.kind === "note");
|
|
97559
97685
|
if (notes.length !== 1 || notes[0].note.b !== BigInt(proof.amountAtomic)) fail27("self_paid_note_not_found");
|
|
97560
97686
|
return notes[0].commitment;
|
|
@@ -97566,7 +97692,7 @@ var init_selfPay = __esm({
|
|
|
97566
97692
|
init_fs();
|
|
97567
97693
|
init_service();
|
|
97568
97694
|
init_notes2();
|
|
97569
|
-
|
|
97695
|
+
init_memoDecryptPool();
|
|
97570
97696
|
init_store();
|
|
97571
97697
|
init_recoveryPath();
|
|
97572
97698
|
init_payResource();
|
|
@@ -126400,16 +126526,17 @@ async function runShieldFromElsewhere({ session, depositId, amountAtomic, onStag
|
|
|
126400
126526
|
const result = await (steps.submit ?? submitRelayedDeposit)(common);
|
|
126401
126527
|
return { state: result.state, transaction: typeof result.receipt?.signature === "string" ? result.receipt.signature : null };
|
|
126402
126528
|
}
|
|
126403
|
-
var walkWalletHistory = (session, store) => loadWalletP03History({
|
|
126529
|
+
var walkWalletHistory = (session, store, share) => loadWalletP03History({
|
|
126404
126530
|
store,
|
|
126405
126531
|
connection: connectSplit(session.connection, session.historyUrl),
|
|
126406
126532
|
programId: session.programId,
|
|
126407
126533
|
pool: store.state.pool,
|
|
126408
|
-
deploymentIdentity: session.proofTools.deploymentIdentity
|
|
126534
|
+
deploymentIdentity: session.proofTools.deploymentIdentity,
|
|
126535
|
+
...share ? { share } : {}
|
|
126409
126536
|
});
|
|
126410
|
-
async function refreshWallet({ session, store, history: walked }) {
|
|
126537
|
+
async function refreshWallet({ session, store, history: walked, share }) {
|
|
126411
126538
|
const walStates = captureWalStates(store);
|
|
126412
|
-
const history = walked ?? await walkWalletHistory(session, store);
|
|
126539
|
+
const history = walked ?? await walkWalletHistory(session, store, share);
|
|
126413
126540
|
const result = await runRecover({
|
|
126414
126541
|
store,
|
|
126415
126542
|
connection: session.connection,
|
|
@@ -126666,7 +126793,13 @@ function createWalletTools({
|
|
|
126666
126793
|
let refreshFailedAt = 0;
|
|
126667
126794
|
let refreshFailedCode;
|
|
126668
126795
|
let refreshInBackground = false;
|
|
126669
|
-
const refreshStep = (store, history) => (ops.refresh ?? refreshWallet)({
|
|
126796
|
+
const refreshStep = (store, history, share) => (ops.refresh ?? refreshWallet)({
|
|
126797
|
+
session,
|
|
126798
|
+
store,
|
|
126799
|
+
...history ? { history } : {},
|
|
126800
|
+
...share ? { share } : {}
|
|
126801
|
+
});
|
|
126802
|
+
let lastWriterEndedAt = 0;
|
|
126670
126803
|
const refreshWalk = ops.refreshWalk ?? (ops.refresh ? void 0 : (store) => walkWalletHistory(session, store));
|
|
126671
126804
|
const errorCode2 = (error, fallback) => describeError(error, { fallback, safeText: SAFE_TEXT }).split(/[\s:;(]/, 1)[0];
|
|
126672
126805
|
const underLease = (task) => session.serial(async () => {
|
|
@@ -126680,6 +126813,7 @@ function createWalletTools({
|
|
|
126680
126813
|
return await task(session.openStore());
|
|
126681
126814
|
} finally {
|
|
126682
126815
|
await release();
|
|
126816
|
+
lastWriterEndedAt = Date.now();
|
|
126683
126817
|
}
|
|
126684
126818
|
});
|
|
126685
126819
|
const autoPockets = createAutoPockets({
|
|
@@ -126764,7 +126898,12 @@ function createWalletTools({
|
|
|
126764
126898
|
}
|
|
126765
126899
|
};
|
|
126766
126900
|
const withPoolSwitch = (tool) => ({ ...tool, run: async (...args) => {
|
|
126767
|
-
|
|
126901
|
+
let output2;
|
|
126902
|
+
try {
|
|
126903
|
+
output2 = await tool.run(...args);
|
|
126904
|
+
} finally {
|
|
126905
|
+
if (tool.annotations?.readOnlyHint !== true) lastWriterEndedAt = Date.now();
|
|
126906
|
+
}
|
|
126768
126907
|
if (!succession || !output2 || output2.isError || typeof output2.text !== "string") return output2;
|
|
126769
126908
|
const read = readSwitch();
|
|
126770
126909
|
const field4 = switchField(read);
|
|
@@ -126814,6 +126953,7 @@ function createWalletTools({
|
|
|
126814
126953
|
function refreshShared({ background = false } = {}) {
|
|
126815
126954
|
if (!refreshRun) {
|
|
126816
126955
|
refreshInBackground = background;
|
|
126956
|
+
const calledAt = Date.now();
|
|
126817
126957
|
refreshRun = (async () => {
|
|
126818
126958
|
let early;
|
|
126819
126959
|
if (background && refreshWalk) {
|
|
@@ -126829,7 +126969,8 @@ function createWalletTools({
|
|
|
126829
126969
|
return underLease((store) => {
|
|
126830
126970
|
const same2 = early !== void 0 && early.pool === store.state.pool && early.records === JSON.stringify(captureWalStates(store));
|
|
126831
126971
|
if (early !== void 0 && !same2) log("MCP_REFRESH_WALK_AGAIN");
|
|
126832
|
-
|
|
126972
|
+
const share = early !== void 0 && !same2 ? { notBeforeMs: Math.max(calledAt, lastWriterEndedAt) } : void 0;
|
|
126973
|
+
return refreshStep(store, same2 ? early.history : void 0, share);
|
|
126833
126974
|
});
|
|
126834
126975
|
})().then(() => {
|
|
126835
126976
|
refreshFailedAt = 0;
|