@cloak.dev/sdk 0.2.6-staging.4f665f8 → 0.2.6-staging.abb3ae6
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/CHANGELOG.md +15 -0
- package/README.md +3 -0
- package/dist/index.cjs +169 -40
- package/dist/index.d.cts +57 -2
- package/dist/index.d.ts +57 -2
- package/dist/index.js +169 -40
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -146,6 +146,21 @@ of every confirmed Cloak transaction that the relay indexes once, server side. A
|
|
|
146
146
|
* Note Index reads never set the relay clock. Complete pages are immutable and cacheable for a
|
|
147
147
|
year, so a cached response replays a stale `x-cloak-server-time`; learning from it would date
|
|
148
148
|
later signed requests in the past.
|
|
149
|
+
* One malformed, crafted or undecryptable entry never aborts a restore or a sync (QA2 F9). A legacy
|
|
150
|
+
viewing key may be public, so anyone could deposit to the owner key derived from it and spend
|
|
151
|
+
that deposit with a chain note under the same key carrying a salt of 0 (or over 96 bits); the
|
|
152
|
+
output-1 conservation path threw on it and every restore passing that key failed, for good.
|
|
153
|
+
Such an entry is now skipped and counted in `stats.skipped` (with a generic warning), and so is
|
|
154
|
+
anything else a matcher throws for one item, and a known-kind item whose body fails its format
|
|
155
|
+
checks while its framing in the page is intact (`parseNoteIndexPage(bytes, expect,
|
|
156
|
+
{ skipMalformedItems: true })`, which also reports `skippedMalformed` and each item's
|
|
157
|
+
`itemPositions`). Page-level faults (header, framing, hash chain, head) still fail the run.
|
|
158
|
+
* What a restored note is checked against, precisely: it opens under AES-GCM keyed by HKDF(nk,
|
|
159
|
+
the item's own `comm0`), its commitment recomputes from the opened values, and it sits at its
|
|
160
|
+
leaf in a chain-authenticated tree. The proof-bound `chainNoteHash` is NOT re-checked: an index
|
|
161
|
+
item does not carry it (nor the `extDataHash` its preimage needs), and fetching it would cost RPC
|
|
162
|
+
per transaction. It would add nothing: a chain note written for one transaction never opens
|
|
163
|
+
when the relay pairs it with another, so a mispairing can hide notes but never yield a wrong one.
|
|
149
164
|
|
|
150
165
|
### Fixed
|
|
151
166
|
|
package/README.md
CHANGED
|
@@ -660,6 +660,9 @@ a tree the chain authenticates. A dishonest relay can hide items; it cannot inje
|
|
|
660
660
|
re-point a note. A hidden nullifier can make a spent note look unspent, so spend restored notes
|
|
661
661
|
through `transact`, `transfer`, `partialWithdraw`, `fullWithdraw` or `swapUtxo`, which run
|
|
662
662
|
`preflightNullifiers` before proving.
|
|
663
|
+
One malformed or crafted entry (anyone can write a note under a public legacy viewing key) is
|
|
664
|
+
skipped and counted in `stats.skipped`, never fatal; only a broken page, hash chain or head fails
|
|
665
|
+
the run.
|
|
663
666
|
|
|
664
667
|
**The cursor.** JSON, no key material, but it records which index items are the wallet's: store it
|
|
665
668
|
as privately as the notes, one per wallet and relay origin, and never hand one wallet's cursor to
|
package/dist/index.cjs
CHANGED
|
@@ -2813,6 +2813,14 @@ function isSubmissionOutcomeUnknownResponse(responseText) {
|
|
|
2813
2813
|
return false;
|
|
2814
2814
|
}
|
|
2815
2815
|
}
|
|
2816
|
+
function isRelayRequestInFlightResponse(responseText) {
|
|
2817
|
+
try {
|
|
2818
|
+
const parsed = JSON.parse(responseText);
|
|
2819
|
+
return parsed?.code === "transient_upstream" && typeof parsed.message === "string" && parsed.message.includes("is already processing");
|
|
2820
|
+
} catch {
|
|
2821
|
+
return false;
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2816
2824
|
function classifyRelayError(responseText, httpStatus) {
|
|
2817
2825
|
let inner = "";
|
|
2818
2826
|
try {
|
|
@@ -6854,6 +6862,12 @@ var NEAR_TIP_ONCHAIN_FALLBACK_MAX_DISTANCE_LOCAL_RPC = 8;
|
|
|
6854
6862
|
var DEFAULT_RELAY_REQUEST_TIMEOUT_MS = 45e3;
|
|
6855
6863
|
var DEFAULT_RELAY_NETWORK_RETRIES = 6;
|
|
6856
6864
|
var RETRYABLE_RELAY_STATUSES = /* @__PURE__ */ new Set([408, 409, 425, 429, 500, 502, 503, 504, 522, 524]);
|
|
6865
|
+
var RELAY_SOURCE_LEASE_MS = 18e4;
|
|
6866
|
+
var RELAY_SOURCE_LEASE_MARGIN_MS = 5e3;
|
|
6867
|
+
var MAX_LEASE_EXPIRY_REPLAYS = 2;
|
|
6868
|
+
var RELAY_IN_FLIGHT_POLL_MS = 5e3;
|
|
6869
|
+
var RELAY_LANDED_POLL_MS = 1e3;
|
|
6870
|
+
var MAX_LANDED_POLLS = 5;
|
|
6857
6871
|
function parseMissingRelayIndexError(message) {
|
|
6858
6872
|
const match = message.match(
|
|
6859
6873
|
/Relay tree missing required commitment index\s+(\d+)\s+\(tree length:\s*(\d+)\)/i
|
|
@@ -8438,6 +8452,20 @@ async function reconcileCommitmentIndicesWithRelay(relayUrl, mint, suggestedIndi
|
|
|
8438
8452
|
function sleep2(ms) {
|
|
8439
8453
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
8440
8454
|
}
|
|
8455
|
+
function sleepUnlessAborted(ms, signal) {
|
|
8456
|
+
if (signal?.aborted) return Promise.resolve(false);
|
|
8457
|
+
return new Promise((resolve) => {
|
|
8458
|
+
const onAbort = () => {
|
|
8459
|
+
clearTimeout(timer);
|
|
8460
|
+
resolve(false);
|
|
8461
|
+
};
|
|
8462
|
+
const timer = setTimeout(() => {
|
|
8463
|
+
signal?.removeEventListener("abort", onAbort);
|
|
8464
|
+
resolve(true);
|
|
8465
|
+
}, ms);
|
|
8466
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
8467
|
+
});
|
|
8468
|
+
}
|
|
8441
8469
|
function hexToBytes2(hex) {
|
|
8442
8470
|
const bytes = new Uint8Array(hex.length / 2);
|
|
8443
8471
|
for (let i = 0; i < hex.length; i += 2) {
|
|
@@ -8672,6 +8700,9 @@ async function submitTransactToRelay(args) {
|
|
|
8672
8700
|
let unknownOutcomeSignature = null;
|
|
8673
8701
|
let possiblySubmitted = false;
|
|
8674
8702
|
let networkRetry = 0;
|
|
8703
|
+
let leaseReplays = 0;
|
|
8704
|
+
let landedPolls = 0;
|
|
8705
|
+
let leaseBaseMs = null;
|
|
8675
8706
|
const verifySettlement = (signature, timeoutMs) => confirmTransactSettlement({
|
|
8676
8707
|
connection: settlement.connection,
|
|
8677
8708
|
programId: settlement.programId,
|
|
@@ -8727,6 +8758,7 @@ async function submitTransactToRelay(args) {
|
|
|
8727
8758
|
const controller = new AbortController();
|
|
8728
8759
|
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
8729
8760
|
let response;
|
|
8761
|
+
leaseBaseMs ?? (leaseBaseMs = Date.now());
|
|
8730
8762
|
try {
|
|
8731
8763
|
response = await doFetch(`${relayUrl}/transact`, {
|
|
8732
8764
|
method: "POST",
|
|
@@ -8745,6 +8777,49 @@ async function submitTransactToRelay(args) {
|
|
|
8745
8777
|
if (isSubmissionOutcomeUnknownResponse(responseText) || isRetryableRelayStatus(response.status)) {
|
|
8746
8778
|
possiblySubmitted = true;
|
|
8747
8779
|
}
|
|
8780
|
+
if ((isRelayRequestInFlightResponse(responseText) || isSubmissionOutcomeUnknownResponse(responseText)) && leaseReplays < MAX_LEASE_EXPIRY_REPLAYS) {
|
|
8781
|
+
networkRetry = 0;
|
|
8782
|
+
const leaseEndsMs = (leaseBaseMs ?? Date.now()) + RELAY_SOURCE_LEASE_MS + RELAY_SOURCE_LEASE_MARGIN_MS;
|
|
8783
|
+
const polling = Date.now() < leaseEndsMs;
|
|
8784
|
+
const probe = await verifySettlement(
|
|
8785
|
+
unknownOutcomeSignature,
|
|
8786
|
+
polling ? 0 : args.failureProbeTimeoutMs ?? Math.min(settlementTimeoutMs(), 1e4)
|
|
8787
|
+
);
|
|
8788
|
+
if (probe.status === "landed") {
|
|
8789
|
+
landedPolls++;
|
|
8790
|
+
if (!polling || landedPolls > MAX_LANDED_POLLS) {
|
|
8791
|
+
return await resolveFailure(
|
|
8792
|
+
new Error(relayFailureMessage("Relay error", responseText, requestBody))
|
|
8793
|
+
);
|
|
8794
|
+
}
|
|
8795
|
+
if (!await sleepUnlessAborted(RELAY_LANDED_POLL_MS, args.signal)) {
|
|
8796
|
+
return await resolveFailure(new Error("Relay lease-expiry replay aborted by caller"));
|
|
8797
|
+
}
|
|
8798
|
+
continue;
|
|
8799
|
+
}
|
|
8800
|
+
if (polling) {
|
|
8801
|
+
onProgress?.("Relay is still processing this request; checking again shortly...");
|
|
8802
|
+
const pollMs = Math.min(RELAY_IN_FLIGHT_POLL_MS, leaseEndsMs - Date.now());
|
|
8803
|
+
if (!await sleepUnlessAborted(pollMs, args.signal)) {
|
|
8804
|
+
return await resolveFailure(new Error("Relay lease-expiry replay aborted by caller"));
|
|
8805
|
+
}
|
|
8806
|
+
continue;
|
|
8807
|
+
}
|
|
8808
|
+
leaseReplays++;
|
|
8809
|
+
const waitMs = Math.max(
|
|
8810
|
+
0,
|
|
8811
|
+
(leaseBaseMs ?? Date.now()) + RELAY_SOURCE_LEASE_MS + RELAY_SOURCE_LEASE_MARGIN_MS - Date.now()
|
|
8812
|
+
);
|
|
8813
|
+
onProgress?.(
|
|
8814
|
+
`Relay has not confirmed the outcome. Waiting ${Math.ceil(waitMs / 1e3)}s for its request lease to expire, then replaying the identical signed request (${leaseReplays}/${MAX_LEASE_EXPIRY_REPLAYS})...`
|
|
8815
|
+
);
|
|
8816
|
+
if (!await sleepUnlessAborted(waitMs, args.signal)) {
|
|
8817
|
+
return await resolveFailure(new Error("Relay lease-expiry replay aborted by caller"));
|
|
8818
|
+
}
|
|
8819
|
+
networkRetry = 0;
|
|
8820
|
+
leaseBaseMs = null;
|
|
8821
|
+
continue;
|
|
8822
|
+
}
|
|
8748
8823
|
if (isRetryableRelayStatus(response.status) && networkRetry < maxNetworkRetries) {
|
|
8749
8824
|
networkRetry++;
|
|
8750
8825
|
const delay = relayBackoffMs(networkRetry);
|
|
@@ -12875,7 +12950,7 @@ function parseSwapRefund(r) {
|
|
|
12875
12950
|
checkLeafPair(commitment, leaf, "SWAP_REFUND");
|
|
12876
12951
|
return { kind: 3, mint, slot, commitment, leaf, amountAfterFee, nullifier0, signature };
|
|
12877
12952
|
}
|
|
12878
|
-
function parseNoteIndexPage(bytes, expect) {
|
|
12953
|
+
function parseNoteIndexPage(bytes, expect, options = {}) {
|
|
12879
12954
|
if (!(bytes instanceof Uint8Array)) throw new NoteIndexFormatError("page must be a Uint8Array");
|
|
12880
12955
|
if (bytes.length > NOTE_INDEX_MAX_PAGE_BYTES) {
|
|
12881
12956
|
throw new NoteIndexFormatError(`page is ${bytes.length} bytes, over the ${NOTE_INDEX_MAX_PAGE_BYTES}-byte bound`);
|
|
@@ -12907,7 +12982,9 @@ function parseNoteIndexPage(bytes, expect) {
|
|
|
12907
12982
|
}
|
|
12908
12983
|
const items = [];
|
|
12909
12984
|
const rawItems = [];
|
|
12985
|
+
const itemPositions = [];
|
|
12910
12986
|
let skippedUnknown = 0;
|
|
12987
|
+
let skippedMalformed = 0;
|
|
12911
12988
|
let offset = NOTE_INDEX_HEADER_LEN;
|
|
12912
12989
|
for (let i = 0; i < count; i++) {
|
|
12913
12990
|
if (offset + ITEM_HEADER_LEN > bytes.length) throw new NoteIndexFormatError(`truncated item ${i} header`);
|
|
@@ -12916,34 +12993,45 @@ function parseNoteIndexPage(bytes, expect) {
|
|
|
12916
12993
|
const bodyStart = offset + ITEM_HEADER_LEN;
|
|
12917
12994
|
const bodyEnd = bodyStart + bodyLen;
|
|
12918
12995
|
if (bodyEnd > bytes.length) throw new NoteIndexFormatError(`truncated item ${i} body`);
|
|
12919
|
-
|
|
12996
|
+
if (kind !== NOTE_INDEX_KIND_TX && kind !== NOTE_INDEX_KIND_DELIVERY && kind !== NOTE_INDEX_KIND_SWAP_REFUND) {
|
|
12997
|
+
if (bodyLen > MAX_UNKNOWN_BODY_LEN) throw new NoteIndexFormatError(`unknown kind ${kind} with body_len ${bodyLen}`);
|
|
12998
|
+
skippedUnknown++;
|
|
12999
|
+
offset = bodyEnd;
|
|
13000
|
+
continue;
|
|
13001
|
+
}
|
|
12920
13002
|
let item;
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
|
|
12927
|
-
|
|
12928
|
-
item = parseDelivery(r);
|
|
12929
|
-
break;
|
|
12930
|
-
case NOTE_INDEX_KIND_SWAP_REFUND:
|
|
12931
|
-
if (bodyLen !== SWAP_REFUND_BODY_LEN) throw new NoteIndexFormatError(`SWAP_REFUND: body_len ${bodyLen}`);
|
|
12932
|
-
item = parseSwapRefund(r);
|
|
12933
|
-
break;
|
|
12934
|
-
default:
|
|
12935
|
-
if (bodyLen > MAX_UNKNOWN_BODY_LEN) throw new NoteIndexFormatError(`unknown kind ${kind} with body_len ${bodyLen}`);
|
|
12936
|
-
skippedUnknown++;
|
|
12937
|
-
offset = bodyEnd;
|
|
12938
|
-
continue;
|
|
13003
|
+
try {
|
|
13004
|
+
item = parseKnownBody(bytes, kind, bodyStart, bodyEnd, i);
|
|
13005
|
+
} catch (error) {
|
|
13006
|
+
if (!options.skipMalformedItems || !(error instanceof NoteIndexFormatError)) throw error;
|
|
13007
|
+
skippedMalformed++;
|
|
13008
|
+
offset = bodyEnd;
|
|
13009
|
+
continue;
|
|
12939
13010
|
}
|
|
12940
|
-
if (r.position !== bodyEnd) throw new NoteIndexFormatError(`item ${i} body has unread bytes`);
|
|
12941
13011
|
items.push(item);
|
|
12942
13012
|
rawItems.push(bytes.slice(offset, bodyEnd));
|
|
13013
|
+
itemPositions.push(i);
|
|
12943
13014
|
offset = bodyEnd;
|
|
12944
13015
|
}
|
|
12945
13016
|
if (offset !== bytes.length) throw new NoteIndexFormatError(`${bytes.length - offset} trailing bytes after ${count} items`);
|
|
12946
|
-
return { epoch, page, firstSeq, complete, count, prevChain, items, rawItems, skippedUnknown };
|
|
13017
|
+
return { epoch, page, firstSeq, complete, count, prevChain, items, rawItems, skippedUnknown, itemPositions, skippedMalformed };
|
|
13018
|
+
}
|
|
13019
|
+
function parseKnownBody(bytes, kind, bodyStart, bodyEnd, i) {
|
|
13020
|
+
const bodyLen = bodyEnd - bodyStart;
|
|
13021
|
+
const r = new Reader(bytes, bodyStart, bodyEnd);
|
|
13022
|
+
let item;
|
|
13023
|
+
if (kind === NOTE_INDEX_KIND_TX) {
|
|
13024
|
+
if (bodyLen < TX_FIXED_LEN) throw new NoteIndexFormatError(`TX: body_len ${bodyLen}`);
|
|
13025
|
+
item = parseTx(r, bodyLen);
|
|
13026
|
+
} else if (kind === NOTE_INDEX_KIND_DELIVERY) {
|
|
13027
|
+
if (bodyLen !== DELIVERY_BODY_LEN) throw new NoteIndexFormatError(`DELIVERY: body_len ${bodyLen}`);
|
|
13028
|
+
item = parseDelivery(r);
|
|
13029
|
+
} else {
|
|
13030
|
+
if (bodyLen !== SWAP_REFUND_BODY_LEN) throw new NoteIndexFormatError(`SWAP_REFUND: body_len ${bodyLen}`);
|
|
13031
|
+
item = parseSwapRefund(r);
|
|
13032
|
+
}
|
|
13033
|
+
if (r.position !== bodyEnd) throw new NoteIndexFormatError(`item ${i} body has unread bytes`);
|
|
13034
|
+
return item;
|
|
12947
13035
|
}
|
|
12948
13036
|
function parseNoteIndexItem(raw) {
|
|
12949
13037
|
if (!(raw instanceof Uint8Array) || raw.length < ITEM_HEADER_LEN) throw new NoteIndexFormatError("truncated item");
|
|
@@ -13375,6 +13463,14 @@ async function trialItem(item, trials) {
|
|
|
13375
13463
|
}
|
|
13376
13464
|
return null;
|
|
13377
13465
|
}
|
|
13466
|
+
async function trialItemIsolated(item, trials, stats) {
|
|
13467
|
+
try {
|
|
13468
|
+
return await trialItem(item, trials);
|
|
13469
|
+
} catch {
|
|
13470
|
+
stats.skipped++;
|
|
13471
|
+
return null;
|
|
13472
|
+
}
|
|
13473
|
+
}
|
|
13378
13474
|
async function trialItemWith(item, trial) {
|
|
13379
13475
|
if (item.kind === 1) {
|
|
13380
13476
|
if (item.note.length === 0) return null;
|
|
@@ -13406,7 +13502,14 @@ function leafOfTxOutput(item, commitment) {
|
|
|
13406
13502
|
if (!isAllZero3(item.comm1) && commitment === bytesToBigint3(item.comm1)) return Number(item.leaf1);
|
|
13407
13503
|
return null;
|
|
13408
13504
|
}
|
|
13409
|
-
|
|
13505
|
+
function changeBlindingOrNull(nk, noteSalt, outputIndex) {
|
|
13506
|
+
try {
|
|
13507
|
+
return deriveChangeNoteBlinding(nk, noteSalt, outputIndex);
|
|
13508
|
+
} catch {
|
|
13509
|
+
return null;
|
|
13510
|
+
}
|
|
13511
|
+
}
|
|
13512
|
+
async function matchOwnItems(own, owner, onReject, onSkip) {
|
|
13410
13513
|
const candidates = [];
|
|
13411
13514
|
const claimed = /* @__PURE__ */ new Set();
|
|
13412
13515
|
const byNullifier = /* @__PURE__ */ new Map();
|
|
@@ -13496,7 +13599,7 @@ async function matchOwnItems(own, owner, onReject) {
|
|
|
13496
13599
|
});
|
|
13497
13600
|
return true;
|
|
13498
13601
|
};
|
|
13499
|
-
|
|
13602
|
+
const direct = async (o) => {
|
|
13500
13603
|
const item = o.item;
|
|
13501
13604
|
if (item.kind === 1 && o.note?.noteSalt !== void 0) {
|
|
13502
13605
|
const note = o.note;
|
|
@@ -13510,7 +13613,7 @@ async function matchOwnItems(own, owner, onReject) {
|
|
|
13510
13613
|
const mint = addressFromBytes(item.mint);
|
|
13511
13614
|
if (o.delivery.amount <= 0n || o.delivery.blinding === 0n) {
|
|
13512
13615
|
onReject(o);
|
|
13513
|
-
|
|
13616
|
+
return;
|
|
13514
13617
|
}
|
|
13515
13618
|
const commitment = await computeCommitment2({
|
|
13516
13619
|
amount: o.delivery.amount,
|
|
@@ -13520,7 +13623,7 @@ async function matchOwnItems(own, owner, onReject) {
|
|
|
13520
13623
|
});
|
|
13521
13624
|
if (commitment !== bytesToBigint3(item.commitment)) {
|
|
13522
13625
|
onReject(o);
|
|
13523
|
-
|
|
13626
|
+
return;
|
|
13524
13627
|
}
|
|
13525
13628
|
await add(o, {
|
|
13526
13629
|
kind: "received",
|
|
@@ -13544,6 +13647,13 @@ async function matchOwnItems(own, owner, onReject) {
|
|
|
13544
13647
|
leaf: Number(item.leaf)
|
|
13545
13648
|
});
|
|
13546
13649
|
}
|
|
13650
|
+
};
|
|
13651
|
+
for (const o of own) {
|
|
13652
|
+
try {
|
|
13653
|
+
await direct(o);
|
|
13654
|
+
} catch {
|
|
13655
|
+
onSkip(o);
|
|
13656
|
+
}
|
|
13547
13657
|
}
|
|
13548
13658
|
const processTx = async (o) => {
|
|
13549
13659
|
const item = o.item;
|
|
@@ -13558,8 +13668,9 @@ async function matchOwnItems(own, owner, onReject) {
|
|
|
13558
13668
|
const sumIn = inputs.reduce((acc, c) => acc + c.amount, 0n);
|
|
13559
13669
|
if (!claimed.has(`${o.seq}:1`) && note.outAmount0 !== void 0 && !isAllZero3(item.comm1)) {
|
|
13560
13670
|
const out1 = sumIn + item.publicAmount - note.outAmount0;
|
|
13561
|
-
|
|
13562
|
-
|
|
13671
|
+
const blinding = out1 > 0n ? changeBlindingOrNull(o.trial.nk, note.noteSalt, 1) : null;
|
|
13672
|
+
if (out1 > 0n && blinding === null) onSkip(o);
|
|
13673
|
+
else if (blinding !== null) {
|
|
13563
13674
|
const owners = [{ keypair: owner, atRisk: false }];
|
|
13564
13675
|
const legacyInput = legacyKeys.get(inputs[0].keypair.publicKey);
|
|
13565
13676
|
if (legacyInput && legacyInput.publicKey !== owner.publicKey) owners.push({ keypair: legacyInput, atRisk: true });
|
|
@@ -13580,7 +13691,11 @@ async function matchOwnItems(own, owner, onReject) {
|
|
|
13580
13691
|
for (let i = 0; i < queue.length; i++) {
|
|
13581
13692
|
const o = queue[i];
|
|
13582
13693
|
queued.delete(o);
|
|
13583
|
-
|
|
13694
|
+
try {
|
|
13695
|
+
await processTx(o);
|
|
13696
|
+
} catch {
|
|
13697
|
+
onSkip(o);
|
|
13698
|
+
}
|
|
13584
13699
|
}
|
|
13585
13700
|
return candidates;
|
|
13586
13701
|
}
|
|
@@ -13827,7 +13942,8 @@ async function recoverNotesFromIndex(params) {
|
|
|
13827
13942
|
candidates: 0,
|
|
13828
13943
|
spent: 0,
|
|
13829
13944
|
conflicts: 0,
|
|
13830
|
-
pendingDropped: 0
|
|
13945
|
+
pendingDropped: 0,
|
|
13946
|
+
skipped: 0
|
|
13831
13947
|
};
|
|
13832
13948
|
const rpc = new Proxy(connection, {
|
|
13833
13949
|
get(target, prop, receiver) {
|
|
@@ -13894,10 +14010,11 @@ async function recoverNotesFromIndex(params) {
|
|
|
13894
14010
|
let outcome = await runOnce(ctx, cursor);
|
|
13895
14011
|
if (outcome instanceof FullPassSignal) {
|
|
13896
14012
|
warnings.push(`${outcome.reason}; re-syncing from page 0`);
|
|
13897
|
-
Object.assign(stats, { dropped: 0, decrypted: 0, candidates: 0, spent: 0, conflicts: 0, pendingDropped: 0 });
|
|
14013
|
+
Object.assign(stats, { dropped: 0, decrypted: 0, candidates: 0, spent: 0, conflicts: 0, pendingDropped: 0, skipped: 0 });
|
|
13898
14014
|
outcome = await runOnce(ctx, void 0);
|
|
13899
14015
|
if (outcome instanceof FullPassSignal) throw new Error(`note index recovery failed: ${outcome.reason}`);
|
|
13900
14016
|
}
|
|
14017
|
+
if (stats.skipped > 0) warnings.push(`${stats.skipped} note index entries could not be processed and were skipped`);
|
|
13901
14018
|
stats.ms = Date.now() - startedAt;
|
|
13902
14019
|
return { ...outcome, stats, warnings };
|
|
13903
14020
|
}
|
|
@@ -13974,11 +14091,13 @@ async function runOnce(ctx, cursor) {
|
|
|
13974
14091
|
if (signal.aborted) throw abortError2();
|
|
13975
14092
|
const bytes = await fetchNoteIndexPage(relayUrl, head.epoch, pageNo, { signal });
|
|
13976
14093
|
stats.bytes += bytes.length;
|
|
13977
|
-
const page2 = parseNoteIndexPage(bytes, { epoch: head.epoch, page: pageNo });
|
|
14094
|
+
const page2 = parseNoteIndexPage(bytes, { epoch: head.epoch, page: pageNo }, { skipMalformedItems: true });
|
|
13978
14095
|
if (pageNo < head.completePages && !page2.complete) {
|
|
13979
14096
|
throw new NoteIndexFormatError(`page ${pageNo} is below complete_pages but not complete`);
|
|
13980
14097
|
}
|
|
13981
14098
|
stats.pages++;
|
|
14099
|
+
stats.skipped += page2.skippedMalformed;
|
|
14100
|
+
const seqOf = (i) => pageNo * NOTE_INDEX_PAGE_SIZE + page2.itemPositions[i];
|
|
13982
14101
|
waiting.set(pageNo, { bytes: page2.complete ? bytes : new Uint8Array(0), prevChain: toHex2(page2.prevChain), complete: page2.complete });
|
|
13983
14102
|
advanceChain();
|
|
13984
14103
|
const data = { complete: page2.complete, leaves: /* @__PURE__ */ new Map() };
|
|
@@ -13999,7 +14118,7 @@ async function runOnce(ctx, cursor) {
|
|
|
13999
14118
|
else data.leaves.set(mint, [entry]);
|
|
14000
14119
|
};
|
|
14001
14120
|
page2.items.forEach((item, i) => {
|
|
14002
|
-
const seq =
|
|
14121
|
+
const seq = seqOf(i);
|
|
14003
14122
|
if (item.kind === 1) {
|
|
14004
14123
|
addLeaf(item.mint, item.comm0, item.leaf0, seq);
|
|
14005
14124
|
addLeaf(item.mint, item.comm1, item.leaf1, seq);
|
|
@@ -14016,7 +14135,7 @@ async function runOnce(ctx, cursor) {
|
|
|
14016
14135
|
for (let i = 0; i < page2.items.length; i += ITEM_BATCH) {
|
|
14017
14136
|
if (signal.aborted) throw abortError2();
|
|
14018
14137
|
const batch = page2.items.slice(i, i + ITEM_BATCH);
|
|
14019
|
-
const opened = await Promise.all(batch.map((item) =>
|
|
14138
|
+
const opened = await Promise.all(batch.map((item) => trialItemIsolated(item, trials, stats)));
|
|
14020
14139
|
opened.forEach((o, k) => {
|
|
14021
14140
|
if (!o) return;
|
|
14022
14141
|
stats.decrypted++;
|
|
@@ -14026,7 +14145,7 @@ async function runOnce(ctx, cursor) {
|
|
|
14026
14145
|
stats.dropped++;
|
|
14027
14146
|
return;
|
|
14028
14147
|
}
|
|
14029
|
-
ownItems.push({ page: pageNo, seq:
|
|
14148
|
+
ownItems.push({ page: pageNo, seq: seqOf(i + k), raw, id, item: batch[k], fromCursor: false, ...o, trial: o.trial });
|
|
14030
14149
|
});
|
|
14031
14150
|
stats.items += batch.length;
|
|
14032
14151
|
}
|
|
@@ -14059,7 +14178,7 @@ async function runOnce(ctx, cursor) {
|
|
|
14059
14178
|
throw new NoteIndexFormatError("hash chain does not reach the head's chain_tip");
|
|
14060
14179
|
}
|
|
14061
14180
|
for (const entry of cursor?.items ?? []) {
|
|
14062
|
-
const o = await
|
|
14181
|
+
const o = await trialItemIsolated(entry.item, trials, stats);
|
|
14063
14182
|
if (!o) continue;
|
|
14064
14183
|
const page2 = Math.floor(entry.seq / NOTE_INDEX_PAGE_SIZE);
|
|
14065
14184
|
ownItems.push({ page: page2, seq: entry.seq, raw: entry.raw, id: itemIdentity(entry.raw), item: entry.item, fromCursor: true, ...o, trial: o.trial });
|
|
@@ -14071,10 +14190,20 @@ async function runOnce(ctx, cursor) {
|
|
|
14071
14190
|
const knownSpent = cursor?.spent ?? /* @__PURE__ */ new Set();
|
|
14072
14191
|
ownItems.sort((a, b) => a.seq - b.seq);
|
|
14073
14192
|
const rejectedNow = /* @__PURE__ */ new Set();
|
|
14074
|
-
const
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14193
|
+
const skippedNow = /* @__PURE__ */ new Set();
|
|
14194
|
+
const allCandidates = await matchOwnItems(
|
|
14195
|
+
ownItems,
|
|
14196
|
+
owner,
|
|
14197
|
+
(o) => {
|
|
14198
|
+
stats.dropped++;
|
|
14199
|
+
rejectedNow.add(o.id);
|
|
14200
|
+
},
|
|
14201
|
+
(o) => {
|
|
14202
|
+
if (skippedNow.has(o)) return;
|
|
14203
|
+
skippedNow.add(o);
|
|
14204
|
+
stats.skipped++;
|
|
14205
|
+
}
|
|
14206
|
+
);
|
|
14078
14207
|
stats.candidates = allCandidates.length;
|
|
14079
14208
|
const cutoff = params.legacyCutoffLeaf ?? {};
|
|
14080
14209
|
const candidates = allCandidates.filter((c) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -3756,6 +3756,8 @@ interface SubmitTransactToRelayArgs {
|
|
|
3756
3756
|
settlementTimeoutMs?: number;
|
|
3757
3757
|
/** Shorter window used to ask "did it land anyway?" after a terminal relay failure. */
|
|
3758
3758
|
failureProbeTimeoutMs?: number;
|
|
3759
|
+
/** Stops the wait for the relay's source lease to expire; the chain is still checked after. */
|
|
3760
|
+
signal?: AbortSignal;
|
|
3759
3761
|
}
|
|
3760
3762
|
/**
|
|
3761
3763
|
* POST one logical `/transact` request and REPORT ONLY WHAT THE CHAIN CONFIRMS.
|
|
@@ -5232,6 +5234,28 @@ interface NoteIndexPage {
|
|
|
5232
5234
|
rawItems: Uint8Array[];
|
|
5233
5235
|
/** Items of unknown kinds, skipped by `body_len`. */
|
|
5234
5236
|
skippedUnknown: number;
|
|
5237
|
+
/**
|
|
5238
|
+
* Position in the page (0-based, unknown and malformed kinds counted) of each entry of `items`,
|
|
5239
|
+
* so `page * NOTE_INDEX_PAGE_SIZE + itemPositions[i]` is the item's real sequence number.
|
|
5240
|
+
*/
|
|
5241
|
+
itemPositions: number[];
|
|
5242
|
+
/**
|
|
5243
|
+
* Known-kind items whose body failed that kind's checks and were skipped by `body_len`. Always 0
|
|
5244
|
+
* unless {@link ParseNoteIndexPageOptions.skipMalformedItems} is set (otherwise they throw).
|
|
5245
|
+
*/
|
|
5246
|
+
skippedMalformed: number;
|
|
5247
|
+
}
|
|
5248
|
+
/** Options of {@link parseNoteIndexPage}. */
|
|
5249
|
+
interface ParseNoteIndexPageOptions {
|
|
5250
|
+
/**
|
|
5251
|
+
* Skip (and count in `skippedMalformed`) a known-kind item whose body fails that kind's checks,
|
|
5252
|
+
* instead of refusing the whole page. Only the BODY is forgiven: the page header, the item
|
|
5253
|
+
* framing (`kind | body_len` inside the page, no truncation, no trailing bytes) and the hash
|
|
5254
|
+
* chain stay strict, so a skipped item is exactly a hidden item, which an untrusted relay can
|
|
5255
|
+
* already do. `recoverNotesFromIndex` sets it, so that one bad entry cannot abort every
|
|
5256
|
+
* wallet's restore.
|
|
5257
|
+
*/
|
|
5258
|
+
skipMalformedItems?: boolean;
|
|
5235
5259
|
}
|
|
5236
5260
|
/** Input to {@link encodeNoteIndexPage}. */
|
|
5237
5261
|
interface EncodeNoteIndexPageParams {
|
|
@@ -5249,11 +5273,15 @@ interface EncodeNoteIndexPageParams {
|
|
|
5249
5273
|
* other than `expect`, an item whose body_len differs from the exact length of its kind, a note
|
|
5250
5274
|
* whose version disagrees with its length, an out-of-range ix_tag / note_source, a refund whose mint
|
|
5251
5275
|
* is not WSOL, an unknown kind longer than 1024 bytes, a truncated item, or trailing bytes.
|
|
5276
|
+
*
|
|
5277
|
+
* With `options.skipMalformedItems`, an item whose body alone is at fault (its framing inside the
|
|
5278
|
+
* page is intact) is skipped and counted in `skippedMalformed` instead; everything else above
|
|
5279
|
+
* still throws.
|
|
5252
5280
|
*/
|
|
5253
5281
|
declare function parseNoteIndexPage(bytes: Uint8Array, expect?: {
|
|
5254
5282
|
epoch: bigint;
|
|
5255
5283
|
page: number;
|
|
5256
|
-
}): NoteIndexPage;
|
|
5284
|
+
}, options?: ParseNoteIndexPageOptions): NoteIndexPage;
|
|
5257
5285
|
/**
|
|
5258
5286
|
* Parse ONE raw item (`kind | body_len | body`), as kept in `NoteIndexPage.rawItems` and in a
|
|
5259
5287
|
* persisted cursor. Same strictness as the page parser; unknown kinds are an error here.
|
|
@@ -5302,6 +5330,25 @@ declare function encodeNoteIndexPage(params: EncodeNoteIndexPageParams): Uint8Ar
|
|
|
5302
5330
|
* A HIDDEN nullifier makes a spent note look unspent; the spend-time `preflightNullifiers` in every
|
|
5303
5331
|
* spend entry point is what catches that, and it stays mandatory.
|
|
5304
5332
|
*
|
|
5333
|
+
* What is NOT checked: the proof-bound `chainNoteHash`. An index item does not carry it (nor the
|
|
5334
|
+
* `extDataHash` its preimage needs), and fetching either per transaction would break the one-RPC
|
|
5335
|
+
* budget. It is not needed for (a) to (c): the chain note is AES-GCM under a key HKDF'd from nk
|
|
5336
|
+
* with the item's own `comm0` as salt (`comm1` for a v2 note), so a note written for one
|
|
5337
|
+
* transaction never opens when the relay attaches it to another (a mispaired CLK1 carrier), for its
|
|
5338
|
+
* real owner or anyone else, and whatever does open (a note crafted for the transaction it sits
|
|
5339
|
+
* on, say under a public legacy key) is still held to (b) and (c). The item's other public fields (`publicAmount`,
|
|
5340
|
+
* the nullifiers) feed only derivations whose result must reproduce a published commitment, so a
|
|
5341
|
+
* wrong value there can only make a note fail to match. The cost of a mispairing is therefore
|
|
5342
|
+
* hidden notes (the memo's real owner's, and the paired source's own), never a wrong note, and no
|
|
5343
|
+
* client-side check can recover them: only the relay can pair correctly.
|
|
5344
|
+
*
|
|
5345
|
+
* ── One bad entry never aborts a run ──────────────────────────────────────────────────────────
|
|
5346
|
+
* The index carries what anyone can put on chain, and a legacy viewing key may be public, so a
|
|
5347
|
+
* stranger can write a note that opens for a wallet. An item whose body is malformed (framing
|
|
5348
|
+
* intact), or whose opened contents make a matcher throw, is skipped and counted in
|
|
5349
|
+
* `stats.skipped`, exactly as if it were not this wallet's. Only page-level faults (header,
|
|
5350
|
+
* framing, hash chain, head) still fail the run, since they are not one entry's.
|
|
5351
|
+
*
|
|
5305
5352
|
* ── The cursor never depends on what the wallet owns (contract property 1) ────────────────────
|
|
5306
5353
|
* Every run downloads from the persisted cursor page, so that page must be a function of public
|
|
5307
5354
|
* data only. It is always `floor(complete_pages / 8) * 8` of the head this run saw (or the previous
|
|
@@ -5467,6 +5514,14 @@ interface NoteIndexRecoveryStats {
|
|
|
5467
5514
|
conflicts: number;
|
|
5468
5515
|
/** Pending candidates over the carry limit, not carried to the next run. */
|
|
5469
5516
|
pendingDropped: number;
|
|
5517
|
+
/**
|
|
5518
|
+
* Index entries skipped instead of failing the run (each one is treated as not this wallet's):
|
|
5519
|
+
* an item whose body fails its kind's format checks while its framing in the page is intact, and
|
|
5520
|
+
* an item that opened under this wallet's keys but whose contents no derivation accepts (a chain
|
|
5521
|
+
* note salt of 0 or over 96 bits, or anything else that throws while it is matched). Anyone who
|
|
5522
|
+
* can read a legacy viewing key can write such a note, so none of this may abort a restore.
|
|
5523
|
+
*/
|
|
5524
|
+
skipped: number;
|
|
5470
5525
|
}
|
|
5471
5526
|
interface RecoverNotesFromIndexResult {
|
|
5472
5527
|
/** Verified, unspent, owned by `ownerUtxoKeypair`; deduped by (mint, leaf). */
|
|
@@ -6366,4 +6421,4 @@ declare const VERSION = "0.2.6";
|
|
|
6366
6421
|
/** True when scanner supports TransactSwap (tag 1). Check this to verify the correct SDK bundle is loaded. */
|
|
6367
6422
|
declare const SCANNER_SUPPORTS_TRANSACT_SWAP = true;
|
|
6368
6423
|
|
|
6369
|
-
export { BRIDGE_ESCROW_LABEL, BRIDGE_ESCROW_LABEL_V2, BUILD_ALLOWS_LOCAL_ENDPOINTS, type BridgeDeliveryState, type BridgeDeposit, type BridgeDepositState, type BridgeQuoteAssessment, type BridgeQuoteInput, type BridgeRail, type BridgeRailAttestation, type BridgeRailProblem, type BridgeRailQuoteOption, type BridgeRailQuoteRequest, type BridgeRailQuoteResponse, type BridgeRailStatusResult, type BuildRecipientDeliveryNotesParams, CHAIN_NOTE_SALT_BITS, CLEANUP_FEE_BUDGET, CLOAK_PRODUCTION_RELAY_URL, CLOAK_PROGRAM_ID, type ChainNoteTxType, type CircuitVerificationResult, type CleanupResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, type CloakRpc, type CommitmentEntry, type CommitmentsResponse, type CompactChainNote, type ComplianceReport, type ComplianceTxType, type ConfirmSettlementParams, type CreateRecoverableDepositUtxoParams, DEFAULT_CIRCUITS_URL, DEFAULT_TRANSACTION_CIRCUITS_URL, DELIVERY_MEMO_TAG, DELIVERY_REGISTRY_SEED, type DeliveredNote, DepositError, type DepositInstructionParams, type DepositNoteSecrets, type DepositOptions, type DepositOutcome, type DepositRef, type DepositResult, type DepositStatus, type DiscoverOptions, type DiscoverSwapRefundsOptions, type DiscoveredSwapRefund, DoNotRetry, ECONOMIC_MINIMUM, EXPECTED_CIRCUIT_HASHES, type EncodeNoteIndexPageParams, type EncryptedMetadataBundle, type EncryptedNote$1 as EncryptedNote, type ErrorCategory, type ExpandedSpendKey, type ExternalFeePayerAdapter, FEE_BUDGET, FIXED_FEE_LAMPORTS, type FundingPlan, type Groth16Proof, type IndexedRecoveredNote, type IndexedRecoveredNoteKind, InsecureRandomnessError, LAMPORTS_PER_SOL, type LegacyWalletAdapter, type WalletSigner as LegacyWalletSigner, LocalStorageAdapter, type LogLevel, type Logger, type LookupTable, MAINNET_RENT_0, MAINNET_RENT_1, MAX_RECEIVER_INDEX, MERKLE_TREE_HEIGHT, MIN_DEPOSIT_LAMPORTS, MIN_DEPOSIT_SPL_BASE_UNITS, type MasterKey, type MatchChangeNoteParams, type MatchDepositNoteParams, type MatchSwapRefundLeafParams, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, MerkleTree, type MessageSigner, NATIVE_SOL_MINT, NOTE_INDEX_NO_LEAF, NOTE_INDEX_PAGE_SIZE, type Network, type NoteData, type NoteIndexCursor, type NoteIndexDeliveryItem, type NoteIndexFetchOptions, NoteIndexFormatError, type NoteIndexHead, NoteIndexHeadBehindError, type NoteIndexItem, type NoteIndexPage, type NoteIndexRecoveryStats, type NoteIndexSwapRefundItem, type NoteIndexTxItem, ONECLICK_PUBKEY_B58, type OnchainMerkleProof, type ParsedDeliveryCarrier, type PaymasterTopUpExpectation, type PaymasterTopUpResult, type PendingDeposit, type PendingWithdrawal, type PostFailureVerdict, RECIPIENT_DELIVERY_CIPHERTEXT_LEN, RECIPIENT_DELIVERY_EPHEMERAL_PK_LEN, RECIPIENT_DELIVERY_NONCE_LEN, RECIPIENT_DELIVERY_NOTE_BYTES, RECIPIENT_DELIVERY_PLAINTEXT_LEN, RECIPIENT_DELIVERY_TAG_LEN, RELAY_BATCH_AUTH_MAX_ITEMS, RELAY_ORIGIN_ALLOWLIST, REQUEST_AUTH_BATCH_DOMAIN, REQUEST_AUTH_BATCH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS, type RecipientDeliveryNote, type RecoverNotesFromIndexParams, type RecoverNotesFromIndexResult, type RecoveredChangeNote, type RecoveredChangeNoteRecord, type RecoveredDepositNote, type RecoveredDepositNoteRecord, type RecoveredSwapRefund, type RelayAuthMode, type RelayAuthPreimage, type RelayAuthSigner, RelayBatchAuthCoordinator, type RelayBatchAuthCoordinatorOptions, type RelayBatchAuthEnvelope, type RelayBatchAuthFields, type RelayBatchAuthItemHandle, RelayInternalError, RelayService, type RelaySubmissionResult, type RentRates, type RetryHooks, type RiskQuoteInstructionResponse, RootNotFoundError, SCANNER_SUPPORTS_TRANSACT_SWAP, SIGN_IN_MESSAGE, SanctionsQuoteError, type ScanOptions, type ScanRecipientDeliveryOptions, type ScanResult, type ScanSummary, type ScannedTransaction, type SettlementConnection, type SettlementContext, type SettlementStatus, type SettlementVerdict, SettlementVerificationError, ShieldPoolErrors, type ShieldPoolPDAs, SimpleWallet, type SpendKey, type SpendOptions, type StorageAdapter, type SubmitTransactToRelayArgs, type SwapOptions, type SwapParams, type SwapRefundAuthorization, type SwapResult, TERMINAL_FAILURE, TRANSACTION_CIRCUITS_VERSION, TRANSACT_AUTH_FIELDS, TRANSACT_SWAP_AUTH_FIELDS, type TransactBatchItem, type TransactBatchItemOutcome, type TransactBatchOptions, type TransactBatchResult, type TransactOptions, type TransactParams, type TransactRequestBodyParams, type TransactResult, TransactionConfirmationError, type TransactionMetadata, type Transfer, type TransferOptions, type TransferResult, type TxStatus, type UserFriendlyError, type Utxo, UtxoAlreadySpentError, type EncryptedNote as UtxoEncryptedNote, type UtxoKeypair, type UtxoSwapParams, type UtxoSwapResult, UtxoWallet, VARIABLE_FEE_DENOMINATOR, VARIABLE_FEE_NUMERATOR, VARIABLE_FEE_RATE, VERSION, type VerifyUtxosResult, type ViewKey, type ViewingKeyPair, WITHDRAW_FEE_BPS, WITHDRAW_FIXED_FEE, type WalletAdapterBridgeOptions, type WalletSigner$1 as WalletSigner, type WalletUtxo, type Web3Module, type WithdrawOptions, type WithdrawSubmissionResult, accountMeta, addressBytes, addressFromBytes, addressFromPublicKey, assertDirectSubmissionLanded, assertInputMints, assertTransactionCircuitIntegrity, assessBridgeQuote, bigintToBytes32$1 as bigintToBytes32, bigintToHex, buildAuthTransactionMessage, buildMerkleTree, buildMerkleTreeFromChain, buildMerkleTreeFromRelay, buildRecipientDeliveryNotes, buildRelayAuthPreimage, buildRelayBatchAuthMessage, buildTransactRequestBody, buildTransactionMessage, bytesToHex, calculateFee, calculateFeeBigint, calculateRelayFee, canRebuildMerkleTreeFromChain, canonicalJson, canonicalPayloadString, chainNoteFromBase64, chainNoteToBase64, classifyPostFailure, classifyRelayError, cleanupReceivingAddress, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, cloakBridgeRail, computeChainNoteHash, computeExtDataHash, computeMerkleRoot, computeNoteIndexChain, computeProofForLatestDeposit, computeProofFromChain, computeSignature, computeSwapRefundCommitment, computeCommitment as computeUtxoCommitment, computeNullifier as computeUtxoNullifier, confirmSignature, confirmTransactSettlement, copyNoteToClipboard, createCloakError, createCloakRpc, createDepositInstruction, createLogger, createRecoverableChangeUtxo, createRecoverableDepositUtxo, createRelayBatchAuthCoordinator, createUtxo, createZeroUtxo, decryptCompactChainNote, decryptComplianceMetadataWithMasterKey, decryptTransactionMetadata, depositFromDerivedKey, deriveBridgeReceiver, deriveChangeNoteBlinding, deriveDepositNoteBlinding, deriveDiversifiedViewingKey, deriveDiversifier, deriveFundingTargets, deriveInputNullifierPdas, deriveLegacyBridgeReceiver, deriveLegacyDepositNoteSecrets, deriveLegacySwapRefundAuthorization, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, deriveSwapRefundBlinding, deriveUserCompliancePublicKey, deriveUserComplianceScalar, deriveUtxoKeypairFromSpendKey, deriveViewKey, deriveViewingKeyFromNk, deriveViewingKeyFromSpendKey, deriveViewingKeyFromUtxoPrivateKey, deserializeUtxo, detectNetworkFromRpcUrl, discoverSwapRefunds, downloadNote, encodeDeliveryCarrierMemo, encodeNoteIndexItem, encodeNoteIndexPage, encodeNoteSimple, encodeRecipientDeliveryNote, encryptCompactChainNote, encryptNoteForRecipient, encryptTransactionMetadata, encryptTransactionMetadataBundle, expandSpendKey, explainRelayAuthRejection, exportKeys, exportNote, exportWalletKeys, fetchAccountBytes, fetchCommitments, fetchLatestBlockhash, fetchLookupTables, fetchNoteIndexHead, fetchNoteIndexPage, fetchRiskQuoteInstruction, fetchRiskQuoteIx, fetchSignaturesForAddress, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, findProgramAddress, formatAmount, formatComplianceCsv, formatErrorForLogging, formatSol, fullWithdraw, fundReceiverViaPaymaster, generateCloakKeys, generateCommitmentAsync, generateMasterSeed, generateNoteFromWallet, generateUtxoKeypair, generateViewingKeyPair, getAddressExplorerUrl, getChainNoteRegistryPDA, getCircuitsPath, getDeliveryRegistryPDA, getDistributableAmount, getExplorerUrl, getNkFromUtxoPrivateKey, getNullifierPDA, getPendingOperationsSummary, getPoolAuthorityConfigPDA, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getSwapStatePDA, getViewKey, hasPendingOperations, hexToBigint$1 as hexToBigint, hexToBytes, importKeys, importWalletKeys, isBrowser, isBrowserLike, isDebugEnabled, isMessageSigner, isPlausibleSignature, isReactNative, isRootNotFoundError, isSubmissionOutcomeUnknownResponse, isTerminalFailure, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawAmountSufficient, isWithdrawable, listBridgeDeposits, loadPendingDeposits, loadPendingWithdrawals, loadVerifiedCircuitArtifacts, matchChangeNote, matchDepositNote, matchSwapRefundLeaf, mayRetry, messageSignerFromCallback, openRecipientDeliveryNote, parseAmount, parseDeliveryCarrierMemo, parseError, parseNote, parseNoteIndexItem, parseNoteIndexPage, parseRelayErrorResponse, parseRelayErrorSignature, parseTransactionError, partialWithdraw, partiallySignTransaction, poseidonHash, preflightCheck, preflightNullifiers, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, programInstruction, proofToBytes, pubkeyToFieldElement, pubkeyToLimbs, randomBytes, randomChangeNoteSalt, randomDepositNoteSalt, randomFieldElement, readMerkleTreeState, readRent, recipientDeliveryNoteToBase64, recoverNotesFromIndex, registerViewingKey, relayRequestDigestHex, removePendingDeposit, removePendingWithdrawal, renderAssessment, resolveCircuitsBase, retryDelayMs, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, scanRecipientDeliveryNotes, scanTransactions, sdkLogger, selectUtxos, sendInstructions, sendRawTransaction, sendTransaction, serializeAuthTransactionMessage, serializeNote, serializeUtxo, setCircuitsPath, setDebugMode, signCompiledTransaction, signMessageBytes, signRelayAuthPayload, signTransaction, signerFromKeypair, signerFromSecretKey, signerFromWalletAdapter, splitTo2Limbs, submitTransactToRelay, sumUtxoAmounts, swapUtxo, swapWithChange, toAddress, toComplianceReport, transact, transactBatch, transactionBase64, transactionBytes, transactionFromBytes, transactionWireSize, transfer, truncate, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, bigintToBytes32 as utxoBigintToBytes32, utxoEquals, hexToBigint as utxoHexToBigint, validateDepositParams, validateNote, validateOutputsSum, validatePaymasterTopUpTransaction, validateRoot, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity, verifyQuoteSignature, verifyUtxos, waitForRoot, withShieldRetries, withTiming, withdrawFeeFor };
|
|
6424
|
+
export { BRIDGE_ESCROW_LABEL, BRIDGE_ESCROW_LABEL_V2, BUILD_ALLOWS_LOCAL_ENDPOINTS, type BridgeDeliveryState, type BridgeDeposit, type BridgeDepositState, type BridgeQuoteAssessment, type BridgeQuoteInput, type BridgeRail, type BridgeRailAttestation, type BridgeRailProblem, type BridgeRailQuoteOption, type BridgeRailQuoteRequest, type BridgeRailQuoteResponse, type BridgeRailStatusResult, type BuildRecipientDeliveryNotesParams, CHAIN_NOTE_SALT_BITS, CLEANUP_FEE_BUDGET, CLOAK_PRODUCTION_RELAY_URL, CLOAK_PROGRAM_ID, type ChainNoteTxType, type CircuitVerificationResult, type CleanupResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, type CloakRpc, type CommitmentEntry, type CommitmentsResponse, type CompactChainNote, type ComplianceReport, type ComplianceTxType, type ConfirmSettlementParams, type CreateRecoverableDepositUtxoParams, DEFAULT_CIRCUITS_URL, DEFAULT_TRANSACTION_CIRCUITS_URL, DELIVERY_MEMO_TAG, DELIVERY_REGISTRY_SEED, type DeliveredNote, DepositError, type DepositInstructionParams, type DepositNoteSecrets, type DepositOptions, type DepositOutcome, type DepositRef, type DepositResult, type DepositStatus, type DiscoverOptions, type DiscoverSwapRefundsOptions, type DiscoveredSwapRefund, DoNotRetry, ECONOMIC_MINIMUM, EXPECTED_CIRCUIT_HASHES, type EncodeNoteIndexPageParams, type EncryptedMetadataBundle, type EncryptedNote$1 as EncryptedNote, type ErrorCategory, type ExpandedSpendKey, type ExternalFeePayerAdapter, FEE_BUDGET, FIXED_FEE_LAMPORTS, type FundingPlan, type Groth16Proof, type IndexedRecoveredNote, type IndexedRecoveredNoteKind, InsecureRandomnessError, LAMPORTS_PER_SOL, type LegacyWalletAdapter, type WalletSigner as LegacyWalletSigner, LocalStorageAdapter, type LogLevel, type Logger, type LookupTable, MAINNET_RENT_0, MAINNET_RENT_1, MAX_RECEIVER_INDEX, MERKLE_TREE_HEIGHT, MIN_DEPOSIT_LAMPORTS, MIN_DEPOSIT_SPL_BASE_UNITS, type MasterKey, type MatchChangeNoteParams, type MatchDepositNoteParams, type MatchSwapRefundLeafParams, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, MerkleTree, type MessageSigner, NATIVE_SOL_MINT, NOTE_INDEX_NO_LEAF, NOTE_INDEX_PAGE_SIZE, type Network, type NoteData, type NoteIndexCursor, type NoteIndexDeliveryItem, type NoteIndexFetchOptions, NoteIndexFormatError, type NoteIndexHead, NoteIndexHeadBehindError, type NoteIndexItem, type NoteIndexPage, type NoteIndexRecoveryStats, type NoteIndexSwapRefundItem, type NoteIndexTxItem, ONECLICK_PUBKEY_B58, type OnchainMerkleProof, type ParseNoteIndexPageOptions, type ParsedDeliveryCarrier, type PaymasterTopUpExpectation, type PaymasterTopUpResult, type PendingDeposit, type PendingWithdrawal, type PostFailureVerdict, RECIPIENT_DELIVERY_CIPHERTEXT_LEN, RECIPIENT_DELIVERY_EPHEMERAL_PK_LEN, RECIPIENT_DELIVERY_NONCE_LEN, RECIPIENT_DELIVERY_NOTE_BYTES, RECIPIENT_DELIVERY_PLAINTEXT_LEN, RECIPIENT_DELIVERY_TAG_LEN, RELAY_BATCH_AUTH_MAX_ITEMS, RELAY_ORIGIN_ALLOWLIST, REQUEST_AUTH_BATCH_DOMAIN, REQUEST_AUTH_BATCH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS, type RecipientDeliveryNote, type RecoverNotesFromIndexParams, type RecoverNotesFromIndexResult, type RecoveredChangeNote, type RecoveredChangeNoteRecord, type RecoveredDepositNote, type RecoveredDepositNoteRecord, type RecoveredSwapRefund, type RelayAuthMode, type RelayAuthPreimage, type RelayAuthSigner, RelayBatchAuthCoordinator, type RelayBatchAuthCoordinatorOptions, type RelayBatchAuthEnvelope, type RelayBatchAuthFields, type RelayBatchAuthItemHandle, RelayInternalError, RelayService, type RelaySubmissionResult, type RentRates, type RetryHooks, type RiskQuoteInstructionResponse, RootNotFoundError, SCANNER_SUPPORTS_TRANSACT_SWAP, SIGN_IN_MESSAGE, SanctionsQuoteError, type ScanOptions, type ScanRecipientDeliveryOptions, type ScanResult, type ScanSummary, type ScannedTransaction, type SettlementConnection, type SettlementContext, type SettlementStatus, type SettlementVerdict, SettlementVerificationError, ShieldPoolErrors, type ShieldPoolPDAs, SimpleWallet, type SpendKey, type SpendOptions, type StorageAdapter, type SubmitTransactToRelayArgs, type SwapOptions, type SwapParams, type SwapRefundAuthorization, type SwapResult, TERMINAL_FAILURE, TRANSACTION_CIRCUITS_VERSION, TRANSACT_AUTH_FIELDS, TRANSACT_SWAP_AUTH_FIELDS, type TransactBatchItem, type TransactBatchItemOutcome, type TransactBatchOptions, type TransactBatchResult, type TransactOptions, type TransactParams, type TransactRequestBodyParams, type TransactResult, TransactionConfirmationError, type TransactionMetadata, type Transfer, type TransferOptions, type TransferResult, type TxStatus, type UserFriendlyError, type Utxo, UtxoAlreadySpentError, type EncryptedNote as UtxoEncryptedNote, type UtxoKeypair, type UtxoSwapParams, type UtxoSwapResult, UtxoWallet, VARIABLE_FEE_DENOMINATOR, VARIABLE_FEE_NUMERATOR, VARIABLE_FEE_RATE, VERSION, type VerifyUtxosResult, type ViewKey, type ViewingKeyPair, WITHDRAW_FEE_BPS, WITHDRAW_FIXED_FEE, type WalletAdapterBridgeOptions, type WalletSigner$1 as WalletSigner, type WalletUtxo, type Web3Module, type WithdrawOptions, type WithdrawSubmissionResult, accountMeta, addressBytes, addressFromBytes, addressFromPublicKey, assertDirectSubmissionLanded, assertInputMints, assertTransactionCircuitIntegrity, assessBridgeQuote, bigintToBytes32$1 as bigintToBytes32, bigintToHex, buildAuthTransactionMessage, buildMerkleTree, buildMerkleTreeFromChain, buildMerkleTreeFromRelay, buildRecipientDeliveryNotes, buildRelayAuthPreimage, buildRelayBatchAuthMessage, buildTransactRequestBody, buildTransactionMessage, bytesToHex, calculateFee, calculateFeeBigint, calculateRelayFee, canRebuildMerkleTreeFromChain, canonicalJson, canonicalPayloadString, chainNoteFromBase64, chainNoteToBase64, classifyPostFailure, classifyRelayError, cleanupReceivingAddress, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, cloakBridgeRail, computeChainNoteHash, computeExtDataHash, computeMerkleRoot, computeNoteIndexChain, computeProofForLatestDeposit, computeProofFromChain, computeSignature, computeSwapRefundCommitment, computeCommitment as computeUtxoCommitment, computeNullifier as computeUtxoNullifier, confirmSignature, confirmTransactSettlement, copyNoteToClipboard, createCloakError, createCloakRpc, createDepositInstruction, createLogger, createRecoverableChangeUtxo, createRecoverableDepositUtxo, createRelayBatchAuthCoordinator, createUtxo, createZeroUtxo, decryptCompactChainNote, decryptComplianceMetadataWithMasterKey, decryptTransactionMetadata, depositFromDerivedKey, deriveBridgeReceiver, deriveChangeNoteBlinding, deriveDepositNoteBlinding, deriveDiversifiedViewingKey, deriveDiversifier, deriveFundingTargets, deriveInputNullifierPdas, deriveLegacyBridgeReceiver, deriveLegacyDepositNoteSecrets, deriveLegacySwapRefundAuthorization, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, deriveSwapRefundBlinding, deriveUserCompliancePublicKey, deriveUserComplianceScalar, deriveUtxoKeypairFromSpendKey, deriveViewKey, deriveViewingKeyFromNk, deriveViewingKeyFromSpendKey, deriveViewingKeyFromUtxoPrivateKey, deserializeUtxo, detectNetworkFromRpcUrl, discoverSwapRefunds, downloadNote, encodeDeliveryCarrierMemo, encodeNoteIndexItem, encodeNoteIndexPage, encodeNoteSimple, encodeRecipientDeliveryNote, encryptCompactChainNote, encryptNoteForRecipient, encryptTransactionMetadata, encryptTransactionMetadataBundle, expandSpendKey, explainRelayAuthRejection, exportKeys, exportNote, exportWalletKeys, fetchAccountBytes, fetchCommitments, fetchLatestBlockhash, fetchLookupTables, fetchNoteIndexHead, fetchNoteIndexPage, fetchRiskQuoteInstruction, fetchRiskQuoteIx, fetchSignaturesForAddress, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, findProgramAddress, formatAmount, formatComplianceCsv, formatErrorForLogging, formatSol, fullWithdraw, fundReceiverViaPaymaster, generateCloakKeys, generateCommitmentAsync, generateMasterSeed, generateNoteFromWallet, generateUtxoKeypair, generateViewingKeyPair, getAddressExplorerUrl, getChainNoteRegistryPDA, getCircuitsPath, getDeliveryRegistryPDA, getDistributableAmount, getExplorerUrl, getNkFromUtxoPrivateKey, getNullifierPDA, getPendingOperationsSummary, getPoolAuthorityConfigPDA, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getSwapStatePDA, getViewKey, hasPendingOperations, hexToBigint$1 as hexToBigint, hexToBytes, importKeys, importWalletKeys, isBrowser, isBrowserLike, isDebugEnabled, isMessageSigner, isPlausibleSignature, isReactNative, isRootNotFoundError, isSubmissionOutcomeUnknownResponse, isTerminalFailure, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawAmountSufficient, isWithdrawable, listBridgeDeposits, loadPendingDeposits, loadPendingWithdrawals, loadVerifiedCircuitArtifacts, matchChangeNote, matchDepositNote, matchSwapRefundLeaf, mayRetry, messageSignerFromCallback, openRecipientDeliveryNote, parseAmount, parseDeliveryCarrierMemo, parseError, parseNote, parseNoteIndexItem, parseNoteIndexPage, parseRelayErrorResponse, parseRelayErrorSignature, parseTransactionError, partialWithdraw, partiallySignTransaction, poseidonHash, preflightCheck, preflightNullifiers, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, programInstruction, proofToBytes, pubkeyToFieldElement, pubkeyToLimbs, randomBytes, randomChangeNoteSalt, randomDepositNoteSalt, randomFieldElement, readMerkleTreeState, readRent, recipientDeliveryNoteToBase64, recoverNotesFromIndex, registerViewingKey, relayRequestDigestHex, removePendingDeposit, removePendingWithdrawal, renderAssessment, resolveCircuitsBase, retryDelayMs, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, scanRecipientDeliveryNotes, scanTransactions, sdkLogger, selectUtxos, sendInstructions, sendRawTransaction, sendTransaction, serializeAuthTransactionMessage, serializeNote, serializeUtxo, setCircuitsPath, setDebugMode, signCompiledTransaction, signMessageBytes, signRelayAuthPayload, signTransaction, signerFromKeypair, signerFromSecretKey, signerFromWalletAdapter, splitTo2Limbs, submitTransactToRelay, sumUtxoAmounts, swapUtxo, swapWithChange, toAddress, toComplianceReport, transact, transactBatch, transactionBase64, transactionBytes, transactionFromBytes, transactionWireSize, transfer, truncate, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, bigintToBytes32 as utxoBigintToBytes32, utxoEquals, hexToBigint as utxoHexToBigint, validateDepositParams, validateNote, validateOutputsSum, validatePaymasterTopUpTransaction, validateRoot, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity, verifyQuoteSignature, verifyUtxos, waitForRoot, withShieldRetries, withTiming, withdrawFeeFor };
|
package/dist/index.d.ts
CHANGED
|
@@ -3756,6 +3756,8 @@ interface SubmitTransactToRelayArgs {
|
|
|
3756
3756
|
settlementTimeoutMs?: number;
|
|
3757
3757
|
/** Shorter window used to ask "did it land anyway?" after a terminal relay failure. */
|
|
3758
3758
|
failureProbeTimeoutMs?: number;
|
|
3759
|
+
/** Stops the wait for the relay's source lease to expire; the chain is still checked after. */
|
|
3760
|
+
signal?: AbortSignal;
|
|
3759
3761
|
}
|
|
3760
3762
|
/**
|
|
3761
3763
|
* POST one logical `/transact` request and REPORT ONLY WHAT THE CHAIN CONFIRMS.
|
|
@@ -5232,6 +5234,28 @@ interface NoteIndexPage {
|
|
|
5232
5234
|
rawItems: Uint8Array[];
|
|
5233
5235
|
/** Items of unknown kinds, skipped by `body_len`. */
|
|
5234
5236
|
skippedUnknown: number;
|
|
5237
|
+
/**
|
|
5238
|
+
* Position in the page (0-based, unknown and malformed kinds counted) of each entry of `items`,
|
|
5239
|
+
* so `page * NOTE_INDEX_PAGE_SIZE + itemPositions[i]` is the item's real sequence number.
|
|
5240
|
+
*/
|
|
5241
|
+
itemPositions: number[];
|
|
5242
|
+
/**
|
|
5243
|
+
* Known-kind items whose body failed that kind's checks and were skipped by `body_len`. Always 0
|
|
5244
|
+
* unless {@link ParseNoteIndexPageOptions.skipMalformedItems} is set (otherwise they throw).
|
|
5245
|
+
*/
|
|
5246
|
+
skippedMalformed: number;
|
|
5247
|
+
}
|
|
5248
|
+
/** Options of {@link parseNoteIndexPage}. */
|
|
5249
|
+
interface ParseNoteIndexPageOptions {
|
|
5250
|
+
/**
|
|
5251
|
+
* Skip (and count in `skippedMalformed`) a known-kind item whose body fails that kind's checks,
|
|
5252
|
+
* instead of refusing the whole page. Only the BODY is forgiven: the page header, the item
|
|
5253
|
+
* framing (`kind | body_len` inside the page, no truncation, no trailing bytes) and the hash
|
|
5254
|
+
* chain stay strict, so a skipped item is exactly a hidden item, which an untrusted relay can
|
|
5255
|
+
* already do. `recoverNotesFromIndex` sets it, so that one bad entry cannot abort every
|
|
5256
|
+
* wallet's restore.
|
|
5257
|
+
*/
|
|
5258
|
+
skipMalformedItems?: boolean;
|
|
5235
5259
|
}
|
|
5236
5260
|
/** Input to {@link encodeNoteIndexPage}. */
|
|
5237
5261
|
interface EncodeNoteIndexPageParams {
|
|
@@ -5249,11 +5273,15 @@ interface EncodeNoteIndexPageParams {
|
|
|
5249
5273
|
* other than `expect`, an item whose body_len differs from the exact length of its kind, a note
|
|
5250
5274
|
* whose version disagrees with its length, an out-of-range ix_tag / note_source, a refund whose mint
|
|
5251
5275
|
* is not WSOL, an unknown kind longer than 1024 bytes, a truncated item, or trailing bytes.
|
|
5276
|
+
*
|
|
5277
|
+
* With `options.skipMalformedItems`, an item whose body alone is at fault (its framing inside the
|
|
5278
|
+
* page is intact) is skipped and counted in `skippedMalformed` instead; everything else above
|
|
5279
|
+
* still throws.
|
|
5252
5280
|
*/
|
|
5253
5281
|
declare function parseNoteIndexPage(bytes: Uint8Array, expect?: {
|
|
5254
5282
|
epoch: bigint;
|
|
5255
5283
|
page: number;
|
|
5256
|
-
}): NoteIndexPage;
|
|
5284
|
+
}, options?: ParseNoteIndexPageOptions): NoteIndexPage;
|
|
5257
5285
|
/**
|
|
5258
5286
|
* Parse ONE raw item (`kind | body_len | body`), as kept in `NoteIndexPage.rawItems` and in a
|
|
5259
5287
|
* persisted cursor. Same strictness as the page parser; unknown kinds are an error here.
|
|
@@ -5302,6 +5330,25 @@ declare function encodeNoteIndexPage(params: EncodeNoteIndexPageParams): Uint8Ar
|
|
|
5302
5330
|
* A HIDDEN nullifier makes a spent note look unspent; the spend-time `preflightNullifiers` in every
|
|
5303
5331
|
* spend entry point is what catches that, and it stays mandatory.
|
|
5304
5332
|
*
|
|
5333
|
+
* What is NOT checked: the proof-bound `chainNoteHash`. An index item does not carry it (nor the
|
|
5334
|
+
* `extDataHash` its preimage needs), and fetching either per transaction would break the one-RPC
|
|
5335
|
+
* budget. It is not needed for (a) to (c): the chain note is AES-GCM under a key HKDF'd from nk
|
|
5336
|
+
* with the item's own `comm0` as salt (`comm1` for a v2 note), so a note written for one
|
|
5337
|
+
* transaction never opens when the relay attaches it to another (a mispaired CLK1 carrier), for its
|
|
5338
|
+
* real owner or anyone else, and whatever does open (a note crafted for the transaction it sits
|
|
5339
|
+
* on, say under a public legacy key) is still held to (b) and (c). The item's other public fields (`publicAmount`,
|
|
5340
|
+
* the nullifiers) feed only derivations whose result must reproduce a published commitment, so a
|
|
5341
|
+
* wrong value there can only make a note fail to match. The cost of a mispairing is therefore
|
|
5342
|
+
* hidden notes (the memo's real owner's, and the paired source's own), never a wrong note, and no
|
|
5343
|
+
* client-side check can recover them: only the relay can pair correctly.
|
|
5344
|
+
*
|
|
5345
|
+
* ── One bad entry never aborts a run ──────────────────────────────────────────────────────────
|
|
5346
|
+
* The index carries what anyone can put on chain, and a legacy viewing key may be public, so a
|
|
5347
|
+
* stranger can write a note that opens for a wallet. An item whose body is malformed (framing
|
|
5348
|
+
* intact), or whose opened contents make a matcher throw, is skipped and counted in
|
|
5349
|
+
* `stats.skipped`, exactly as if it were not this wallet's. Only page-level faults (header,
|
|
5350
|
+
* framing, hash chain, head) still fail the run, since they are not one entry's.
|
|
5351
|
+
*
|
|
5305
5352
|
* ── The cursor never depends on what the wallet owns (contract property 1) ────────────────────
|
|
5306
5353
|
* Every run downloads from the persisted cursor page, so that page must be a function of public
|
|
5307
5354
|
* data only. It is always `floor(complete_pages / 8) * 8` of the head this run saw (or the previous
|
|
@@ -5467,6 +5514,14 @@ interface NoteIndexRecoveryStats {
|
|
|
5467
5514
|
conflicts: number;
|
|
5468
5515
|
/** Pending candidates over the carry limit, not carried to the next run. */
|
|
5469
5516
|
pendingDropped: number;
|
|
5517
|
+
/**
|
|
5518
|
+
* Index entries skipped instead of failing the run (each one is treated as not this wallet's):
|
|
5519
|
+
* an item whose body fails its kind's format checks while its framing in the page is intact, and
|
|
5520
|
+
* an item that opened under this wallet's keys but whose contents no derivation accepts (a chain
|
|
5521
|
+
* note salt of 0 or over 96 bits, or anything else that throws while it is matched). Anyone who
|
|
5522
|
+
* can read a legacy viewing key can write such a note, so none of this may abort a restore.
|
|
5523
|
+
*/
|
|
5524
|
+
skipped: number;
|
|
5470
5525
|
}
|
|
5471
5526
|
interface RecoverNotesFromIndexResult {
|
|
5472
5527
|
/** Verified, unspent, owned by `ownerUtxoKeypair`; deduped by (mint, leaf). */
|
|
@@ -6366,4 +6421,4 @@ declare const VERSION = "0.2.6";
|
|
|
6366
6421
|
/** True when scanner supports TransactSwap (tag 1). Check this to verify the correct SDK bundle is loaded. */
|
|
6367
6422
|
declare const SCANNER_SUPPORTS_TRANSACT_SWAP = true;
|
|
6368
6423
|
|
|
6369
|
-
export { BRIDGE_ESCROW_LABEL, BRIDGE_ESCROW_LABEL_V2, BUILD_ALLOWS_LOCAL_ENDPOINTS, type BridgeDeliveryState, type BridgeDeposit, type BridgeDepositState, type BridgeQuoteAssessment, type BridgeQuoteInput, type BridgeRail, type BridgeRailAttestation, type BridgeRailProblem, type BridgeRailQuoteOption, type BridgeRailQuoteRequest, type BridgeRailQuoteResponse, type BridgeRailStatusResult, type BuildRecipientDeliveryNotesParams, CHAIN_NOTE_SALT_BITS, CLEANUP_FEE_BUDGET, CLOAK_PRODUCTION_RELAY_URL, CLOAK_PROGRAM_ID, type ChainNoteTxType, type CircuitVerificationResult, type CleanupResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, type CloakRpc, type CommitmentEntry, type CommitmentsResponse, type CompactChainNote, type ComplianceReport, type ComplianceTxType, type ConfirmSettlementParams, type CreateRecoverableDepositUtxoParams, DEFAULT_CIRCUITS_URL, DEFAULT_TRANSACTION_CIRCUITS_URL, DELIVERY_MEMO_TAG, DELIVERY_REGISTRY_SEED, type DeliveredNote, DepositError, type DepositInstructionParams, type DepositNoteSecrets, type DepositOptions, type DepositOutcome, type DepositRef, type DepositResult, type DepositStatus, type DiscoverOptions, type DiscoverSwapRefundsOptions, type DiscoveredSwapRefund, DoNotRetry, ECONOMIC_MINIMUM, EXPECTED_CIRCUIT_HASHES, type EncodeNoteIndexPageParams, type EncryptedMetadataBundle, type EncryptedNote$1 as EncryptedNote, type ErrorCategory, type ExpandedSpendKey, type ExternalFeePayerAdapter, FEE_BUDGET, FIXED_FEE_LAMPORTS, type FundingPlan, type Groth16Proof, type IndexedRecoveredNote, type IndexedRecoveredNoteKind, InsecureRandomnessError, LAMPORTS_PER_SOL, type LegacyWalletAdapter, type WalletSigner as LegacyWalletSigner, LocalStorageAdapter, type LogLevel, type Logger, type LookupTable, MAINNET_RENT_0, MAINNET_RENT_1, MAX_RECEIVER_INDEX, MERKLE_TREE_HEIGHT, MIN_DEPOSIT_LAMPORTS, MIN_DEPOSIT_SPL_BASE_UNITS, type MasterKey, type MatchChangeNoteParams, type MatchDepositNoteParams, type MatchSwapRefundLeafParams, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, MerkleTree, type MessageSigner, NATIVE_SOL_MINT, NOTE_INDEX_NO_LEAF, NOTE_INDEX_PAGE_SIZE, type Network, type NoteData, type NoteIndexCursor, type NoteIndexDeliveryItem, type NoteIndexFetchOptions, NoteIndexFormatError, type NoteIndexHead, NoteIndexHeadBehindError, type NoteIndexItem, type NoteIndexPage, type NoteIndexRecoveryStats, type NoteIndexSwapRefundItem, type NoteIndexTxItem, ONECLICK_PUBKEY_B58, type OnchainMerkleProof, type ParsedDeliveryCarrier, type PaymasterTopUpExpectation, type PaymasterTopUpResult, type PendingDeposit, type PendingWithdrawal, type PostFailureVerdict, RECIPIENT_DELIVERY_CIPHERTEXT_LEN, RECIPIENT_DELIVERY_EPHEMERAL_PK_LEN, RECIPIENT_DELIVERY_NONCE_LEN, RECIPIENT_DELIVERY_NOTE_BYTES, RECIPIENT_DELIVERY_PLAINTEXT_LEN, RECIPIENT_DELIVERY_TAG_LEN, RELAY_BATCH_AUTH_MAX_ITEMS, RELAY_ORIGIN_ALLOWLIST, REQUEST_AUTH_BATCH_DOMAIN, REQUEST_AUTH_BATCH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS, type RecipientDeliveryNote, type RecoverNotesFromIndexParams, type RecoverNotesFromIndexResult, type RecoveredChangeNote, type RecoveredChangeNoteRecord, type RecoveredDepositNote, type RecoveredDepositNoteRecord, type RecoveredSwapRefund, type RelayAuthMode, type RelayAuthPreimage, type RelayAuthSigner, RelayBatchAuthCoordinator, type RelayBatchAuthCoordinatorOptions, type RelayBatchAuthEnvelope, type RelayBatchAuthFields, type RelayBatchAuthItemHandle, RelayInternalError, RelayService, type RelaySubmissionResult, type RentRates, type RetryHooks, type RiskQuoteInstructionResponse, RootNotFoundError, SCANNER_SUPPORTS_TRANSACT_SWAP, SIGN_IN_MESSAGE, SanctionsQuoteError, type ScanOptions, type ScanRecipientDeliveryOptions, type ScanResult, type ScanSummary, type ScannedTransaction, type SettlementConnection, type SettlementContext, type SettlementStatus, type SettlementVerdict, SettlementVerificationError, ShieldPoolErrors, type ShieldPoolPDAs, SimpleWallet, type SpendKey, type SpendOptions, type StorageAdapter, type SubmitTransactToRelayArgs, type SwapOptions, type SwapParams, type SwapRefundAuthorization, type SwapResult, TERMINAL_FAILURE, TRANSACTION_CIRCUITS_VERSION, TRANSACT_AUTH_FIELDS, TRANSACT_SWAP_AUTH_FIELDS, type TransactBatchItem, type TransactBatchItemOutcome, type TransactBatchOptions, type TransactBatchResult, type TransactOptions, type TransactParams, type TransactRequestBodyParams, type TransactResult, TransactionConfirmationError, type TransactionMetadata, type Transfer, type TransferOptions, type TransferResult, type TxStatus, type UserFriendlyError, type Utxo, UtxoAlreadySpentError, type EncryptedNote as UtxoEncryptedNote, type UtxoKeypair, type UtxoSwapParams, type UtxoSwapResult, UtxoWallet, VARIABLE_FEE_DENOMINATOR, VARIABLE_FEE_NUMERATOR, VARIABLE_FEE_RATE, VERSION, type VerifyUtxosResult, type ViewKey, type ViewingKeyPair, WITHDRAW_FEE_BPS, WITHDRAW_FIXED_FEE, type WalletAdapterBridgeOptions, type WalletSigner$1 as WalletSigner, type WalletUtxo, type Web3Module, type WithdrawOptions, type WithdrawSubmissionResult, accountMeta, addressBytes, addressFromBytes, addressFromPublicKey, assertDirectSubmissionLanded, assertInputMints, assertTransactionCircuitIntegrity, assessBridgeQuote, bigintToBytes32$1 as bigintToBytes32, bigintToHex, buildAuthTransactionMessage, buildMerkleTree, buildMerkleTreeFromChain, buildMerkleTreeFromRelay, buildRecipientDeliveryNotes, buildRelayAuthPreimage, buildRelayBatchAuthMessage, buildTransactRequestBody, buildTransactionMessage, bytesToHex, calculateFee, calculateFeeBigint, calculateRelayFee, canRebuildMerkleTreeFromChain, canonicalJson, canonicalPayloadString, chainNoteFromBase64, chainNoteToBase64, classifyPostFailure, classifyRelayError, cleanupReceivingAddress, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, cloakBridgeRail, computeChainNoteHash, computeExtDataHash, computeMerkleRoot, computeNoteIndexChain, computeProofForLatestDeposit, computeProofFromChain, computeSignature, computeSwapRefundCommitment, computeCommitment as computeUtxoCommitment, computeNullifier as computeUtxoNullifier, confirmSignature, confirmTransactSettlement, copyNoteToClipboard, createCloakError, createCloakRpc, createDepositInstruction, createLogger, createRecoverableChangeUtxo, createRecoverableDepositUtxo, createRelayBatchAuthCoordinator, createUtxo, createZeroUtxo, decryptCompactChainNote, decryptComplianceMetadataWithMasterKey, decryptTransactionMetadata, depositFromDerivedKey, deriveBridgeReceiver, deriveChangeNoteBlinding, deriveDepositNoteBlinding, deriveDiversifiedViewingKey, deriveDiversifier, deriveFundingTargets, deriveInputNullifierPdas, deriveLegacyBridgeReceiver, deriveLegacyDepositNoteSecrets, deriveLegacySwapRefundAuthorization, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, deriveSwapRefundBlinding, deriveUserCompliancePublicKey, deriveUserComplianceScalar, deriveUtxoKeypairFromSpendKey, deriveViewKey, deriveViewingKeyFromNk, deriveViewingKeyFromSpendKey, deriveViewingKeyFromUtxoPrivateKey, deserializeUtxo, detectNetworkFromRpcUrl, discoverSwapRefunds, downloadNote, encodeDeliveryCarrierMemo, encodeNoteIndexItem, encodeNoteIndexPage, encodeNoteSimple, encodeRecipientDeliveryNote, encryptCompactChainNote, encryptNoteForRecipient, encryptTransactionMetadata, encryptTransactionMetadataBundle, expandSpendKey, explainRelayAuthRejection, exportKeys, exportNote, exportWalletKeys, fetchAccountBytes, fetchCommitments, fetchLatestBlockhash, fetchLookupTables, fetchNoteIndexHead, fetchNoteIndexPage, fetchRiskQuoteInstruction, fetchRiskQuoteIx, fetchSignaturesForAddress, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, findProgramAddress, formatAmount, formatComplianceCsv, formatErrorForLogging, formatSol, fullWithdraw, fundReceiverViaPaymaster, generateCloakKeys, generateCommitmentAsync, generateMasterSeed, generateNoteFromWallet, generateUtxoKeypair, generateViewingKeyPair, getAddressExplorerUrl, getChainNoteRegistryPDA, getCircuitsPath, getDeliveryRegistryPDA, getDistributableAmount, getExplorerUrl, getNkFromUtxoPrivateKey, getNullifierPDA, getPendingOperationsSummary, getPoolAuthorityConfigPDA, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getSwapStatePDA, getViewKey, hasPendingOperations, hexToBigint$1 as hexToBigint, hexToBytes, importKeys, importWalletKeys, isBrowser, isBrowserLike, isDebugEnabled, isMessageSigner, isPlausibleSignature, isReactNative, isRootNotFoundError, isSubmissionOutcomeUnknownResponse, isTerminalFailure, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawAmountSufficient, isWithdrawable, listBridgeDeposits, loadPendingDeposits, loadPendingWithdrawals, loadVerifiedCircuitArtifacts, matchChangeNote, matchDepositNote, matchSwapRefundLeaf, mayRetry, messageSignerFromCallback, openRecipientDeliveryNote, parseAmount, parseDeliveryCarrierMemo, parseError, parseNote, parseNoteIndexItem, parseNoteIndexPage, parseRelayErrorResponse, parseRelayErrorSignature, parseTransactionError, partialWithdraw, partiallySignTransaction, poseidonHash, preflightCheck, preflightNullifiers, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, programInstruction, proofToBytes, pubkeyToFieldElement, pubkeyToLimbs, randomBytes, randomChangeNoteSalt, randomDepositNoteSalt, randomFieldElement, readMerkleTreeState, readRent, recipientDeliveryNoteToBase64, recoverNotesFromIndex, registerViewingKey, relayRequestDigestHex, removePendingDeposit, removePendingWithdrawal, renderAssessment, resolveCircuitsBase, retryDelayMs, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, scanRecipientDeliveryNotes, scanTransactions, sdkLogger, selectUtxos, sendInstructions, sendRawTransaction, sendTransaction, serializeAuthTransactionMessage, serializeNote, serializeUtxo, setCircuitsPath, setDebugMode, signCompiledTransaction, signMessageBytes, signRelayAuthPayload, signTransaction, signerFromKeypair, signerFromSecretKey, signerFromWalletAdapter, splitTo2Limbs, submitTransactToRelay, sumUtxoAmounts, swapUtxo, swapWithChange, toAddress, toComplianceReport, transact, transactBatch, transactionBase64, transactionBytes, transactionFromBytes, transactionWireSize, transfer, truncate, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, bigintToBytes32 as utxoBigintToBytes32, utxoEquals, hexToBigint as utxoHexToBigint, validateDepositParams, validateNote, validateOutputsSum, validatePaymasterTopUpTransaction, validateRoot, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity, verifyQuoteSignature, verifyUtxos, waitForRoot, withShieldRetries, withTiming, withdrawFeeFor };
|
|
6424
|
+
export { BRIDGE_ESCROW_LABEL, BRIDGE_ESCROW_LABEL_V2, BUILD_ALLOWS_LOCAL_ENDPOINTS, type BridgeDeliveryState, type BridgeDeposit, type BridgeDepositState, type BridgeQuoteAssessment, type BridgeQuoteInput, type BridgeRail, type BridgeRailAttestation, type BridgeRailProblem, type BridgeRailQuoteOption, type BridgeRailQuoteRequest, type BridgeRailQuoteResponse, type BridgeRailStatusResult, type BuildRecipientDeliveryNotesParams, CHAIN_NOTE_SALT_BITS, CLEANUP_FEE_BUDGET, CLOAK_PRODUCTION_RELAY_URL, CLOAK_PROGRAM_ID, type ChainNoteTxType, type CircuitVerificationResult, type CleanupResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, type CloakRpc, type CommitmentEntry, type CommitmentsResponse, type CompactChainNote, type ComplianceReport, type ComplianceTxType, type ConfirmSettlementParams, type CreateRecoverableDepositUtxoParams, DEFAULT_CIRCUITS_URL, DEFAULT_TRANSACTION_CIRCUITS_URL, DELIVERY_MEMO_TAG, DELIVERY_REGISTRY_SEED, type DeliveredNote, DepositError, type DepositInstructionParams, type DepositNoteSecrets, type DepositOptions, type DepositOutcome, type DepositRef, type DepositResult, type DepositStatus, type DiscoverOptions, type DiscoverSwapRefundsOptions, type DiscoveredSwapRefund, DoNotRetry, ECONOMIC_MINIMUM, EXPECTED_CIRCUIT_HASHES, type EncodeNoteIndexPageParams, type EncryptedMetadataBundle, type EncryptedNote$1 as EncryptedNote, type ErrorCategory, type ExpandedSpendKey, type ExternalFeePayerAdapter, FEE_BUDGET, FIXED_FEE_LAMPORTS, type FundingPlan, type Groth16Proof, type IndexedRecoveredNote, type IndexedRecoveredNoteKind, InsecureRandomnessError, LAMPORTS_PER_SOL, type LegacyWalletAdapter, type WalletSigner as LegacyWalletSigner, LocalStorageAdapter, type LogLevel, type Logger, type LookupTable, MAINNET_RENT_0, MAINNET_RENT_1, MAX_RECEIVER_INDEX, MERKLE_TREE_HEIGHT, MIN_DEPOSIT_LAMPORTS, MIN_DEPOSIT_SPL_BASE_UNITS, type MasterKey, type MatchChangeNoteParams, type MatchDepositNoteParams, type MatchSwapRefundLeafParams, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, MerkleTree, type MessageSigner, NATIVE_SOL_MINT, NOTE_INDEX_NO_LEAF, NOTE_INDEX_PAGE_SIZE, type Network, type NoteData, type NoteIndexCursor, type NoteIndexDeliveryItem, type NoteIndexFetchOptions, NoteIndexFormatError, type NoteIndexHead, NoteIndexHeadBehindError, type NoteIndexItem, type NoteIndexPage, type NoteIndexRecoveryStats, type NoteIndexSwapRefundItem, type NoteIndexTxItem, ONECLICK_PUBKEY_B58, type OnchainMerkleProof, type ParseNoteIndexPageOptions, type ParsedDeliveryCarrier, type PaymasterTopUpExpectation, type PaymasterTopUpResult, type PendingDeposit, type PendingWithdrawal, type PostFailureVerdict, RECIPIENT_DELIVERY_CIPHERTEXT_LEN, RECIPIENT_DELIVERY_EPHEMERAL_PK_LEN, RECIPIENT_DELIVERY_NONCE_LEN, RECIPIENT_DELIVERY_NOTE_BYTES, RECIPIENT_DELIVERY_PLAINTEXT_LEN, RECIPIENT_DELIVERY_TAG_LEN, RELAY_BATCH_AUTH_MAX_ITEMS, RELAY_ORIGIN_ALLOWLIST, REQUEST_AUTH_BATCH_DOMAIN, REQUEST_AUTH_BATCH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS, type RecipientDeliveryNote, type RecoverNotesFromIndexParams, type RecoverNotesFromIndexResult, type RecoveredChangeNote, type RecoveredChangeNoteRecord, type RecoveredDepositNote, type RecoveredDepositNoteRecord, type RecoveredSwapRefund, type RelayAuthMode, type RelayAuthPreimage, type RelayAuthSigner, RelayBatchAuthCoordinator, type RelayBatchAuthCoordinatorOptions, type RelayBatchAuthEnvelope, type RelayBatchAuthFields, type RelayBatchAuthItemHandle, RelayInternalError, RelayService, type RelaySubmissionResult, type RentRates, type RetryHooks, type RiskQuoteInstructionResponse, RootNotFoundError, SCANNER_SUPPORTS_TRANSACT_SWAP, SIGN_IN_MESSAGE, SanctionsQuoteError, type ScanOptions, type ScanRecipientDeliveryOptions, type ScanResult, type ScanSummary, type ScannedTransaction, type SettlementConnection, type SettlementContext, type SettlementStatus, type SettlementVerdict, SettlementVerificationError, ShieldPoolErrors, type ShieldPoolPDAs, SimpleWallet, type SpendKey, type SpendOptions, type StorageAdapter, type SubmitTransactToRelayArgs, type SwapOptions, type SwapParams, type SwapRefundAuthorization, type SwapResult, TERMINAL_FAILURE, TRANSACTION_CIRCUITS_VERSION, TRANSACT_AUTH_FIELDS, TRANSACT_SWAP_AUTH_FIELDS, type TransactBatchItem, type TransactBatchItemOutcome, type TransactBatchOptions, type TransactBatchResult, type TransactOptions, type TransactParams, type TransactRequestBodyParams, type TransactResult, TransactionConfirmationError, type TransactionMetadata, type Transfer, type TransferOptions, type TransferResult, type TxStatus, type UserFriendlyError, type Utxo, UtxoAlreadySpentError, type EncryptedNote as UtxoEncryptedNote, type UtxoKeypair, type UtxoSwapParams, type UtxoSwapResult, UtxoWallet, VARIABLE_FEE_DENOMINATOR, VARIABLE_FEE_NUMERATOR, VARIABLE_FEE_RATE, VERSION, type VerifyUtxosResult, type ViewKey, type ViewingKeyPair, WITHDRAW_FEE_BPS, WITHDRAW_FIXED_FEE, type WalletAdapterBridgeOptions, type WalletSigner$1 as WalletSigner, type WalletUtxo, type Web3Module, type WithdrawOptions, type WithdrawSubmissionResult, accountMeta, addressBytes, addressFromBytes, addressFromPublicKey, assertDirectSubmissionLanded, assertInputMints, assertTransactionCircuitIntegrity, assessBridgeQuote, bigintToBytes32$1 as bigintToBytes32, bigintToHex, buildAuthTransactionMessage, buildMerkleTree, buildMerkleTreeFromChain, buildMerkleTreeFromRelay, buildRecipientDeliveryNotes, buildRelayAuthPreimage, buildRelayBatchAuthMessage, buildTransactRequestBody, buildTransactionMessage, bytesToHex, calculateFee, calculateFeeBigint, calculateRelayFee, canRebuildMerkleTreeFromChain, canonicalJson, canonicalPayloadString, chainNoteFromBase64, chainNoteToBase64, classifyPostFailure, classifyRelayError, cleanupReceivingAddress, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, cloakBridgeRail, computeChainNoteHash, computeExtDataHash, computeMerkleRoot, computeNoteIndexChain, computeProofForLatestDeposit, computeProofFromChain, computeSignature, computeSwapRefundCommitment, computeCommitment as computeUtxoCommitment, computeNullifier as computeUtxoNullifier, confirmSignature, confirmTransactSettlement, copyNoteToClipboard, createCloakError, createCloakRpc, createDepositInstruction, createLogger, createRecoverableChangeUtxo, createRecoverableDepositUtxo, createRelayBatchAuthCoordinator, createUtxo, createZeroUtxo, decryptCompactChainNote, decryptComplianceMetadataWithMasterKey, decryptTransactionMetadata, depositFromDerivedKey, deriveBridgeReceiver, deriveChangeNoteBlinding, deriveDepositNoteBlinding, deriveDiversifiedViewingKey, deriveDiversifier, deriveFundingTargets, deriveInputNullifierPdas, deriveLegacyBridgeReceiver, deriveLegacyDepositNoteSecrets, deriveLegacySwapRefundAuthorization, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, deriveSwapRefundBlinding, deriveUserCompliancePublicKey, deriveUserComplianceScalar, deriveUtxoKeypairFromSpendKey, deriveViewKey, deriveViewingKeyFromNk, deriveViewingKeyFromSpendKey, deriveViewingKeyFromUtxoPrivateKey, deserializeUtxo, detectNetworkFromRpcUrl, discoverSwapRefunds, downloadNote, encodeDeliveryCarrierMemo, encodeNoteIndexItem, encodeNoteIndexPage, encodeNoteSimple, encodeRecipientDeliveryNote, encryptCompactChainNote, encryptNoteForRecipient, encryptTransactionMetadata, encryptTransactionMetadataBundle, expandSpendKey, explainRelayAuthRejection, exportKeys, exportNote, exportWalletKeys, fetchAccountBytes, fetchCommitments, fetchLatestBlockhash, fetchLookupTables, fetchNoteIndexHead, fetchNoteIndexPage, fetchRiskQuoteInstruction, fetchRiskQuoteIx, fetchSignaturesForAddress, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, findProgramAddress, formatAmount, formatComplianceCsv, formatErrorForLogging, formatSol, fullWithdraw, fundReceiverViaPaymaster, generateCloakKeys, generateCommitmentAsync, generateMasterSeed, generateNoteFromWallet, generateUtxoKeypair, generateViewingKeyPair, getAddressExplorerUrl, getChainNoteRegistryPDA, getCircuitsPath, getDeliveryRegistryPDA, getDistributableAmount, getExplorerUrl, getNkFromUtxoPrivateKey, getNullifierPDA, getPendingOperationsSummary, getPoolAuthorityConfigPDA, getPublicKey, getPublicViewKey, getRecipientAmount, getRpcUrlForNetwork, getShieldPoolPDAs, getSwapStatePDA, getViewKey, hasPendingOperations, hexToBigint$1 as hexToBigint, hexToBytes, importKeys, importWalletKeys, isBrowser, isBrowserLike, isDebugEnabled, isMessageSigner, isPlausibleSignature, isReactNative, isRootNotFoundError, isSubmissionOutcomeUnknownResponse, isTerminalFailure, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawAmountSufficient, isWithdrawable, listBridgeDeposits, loadPendingDeposits, loadPendingWithdrawals, loadVerifiedCircuitArtifacts, matchChangeNote, matchDepositNote, matchSwapRefundLeaf, mayRetry, messageSignerFromCallback, openRecipientDeliveryNote, parseAmount, parseDeliveryCarrierMemo, parseError, parseNote, parseNoteIndexItem, parseNoteIndexPage, parseRelayErrorResponse, parseRelayErrorSignature, parseTransactionError, partialWithdraw, partiallySignTransaction, poseidonHash, preflightCheck, preflightNullifiers, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, programInstruction, proofToBytes, pubkeyToFieldElement, pubkeyToLimbs, randomBytes, randomChangeNoteSalt, randomDepositNoteSalt, randomFieldElement, readMerkleTreeState, readRent, recipientDeliveryNoteToBase64, recoverNotesFromIndex, registerViewingKey, relayRequestDigestHex, removePendingDeposit, removePendingWithdrawal, renderAssessment, resolveCircuitsBase, retryDelayMs, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, scanRecipientDeliveryNotes, scanTransactions, sdkLogger, selectUtxos, sendInstructions, sendRawTransaction, sendTransaction, serializeAuthTransactionMessage, serializeNote, serializeUtxo, setCircuitsPath, setDebugMode, signCompiledTransaction, signMessageBytes, signRelayAuthPayload, signTransaction, signerFromKeypair, signerFromSecretKey, signerFromWalletAdapter, splitTo2Limbs, submitTransactToRelay, sumUtxoAmounts, swapUtxo, swapWithChange, toAddress, toComplianceReport, transact, transactBatch, transactionBase64, transactionBytes, transactionFromBytes, transactionWireSize, transfer, truncate, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, bigintToBytes32 as utxoBigintToBytes32, utxoEquals, hexToBigint as utxoHexToBigint, validateDepositParams, validateNote, validateOutputsSum, validatePaymasterTopUpTransaction, validateRoot, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity, verifyQuoteSignature, verifyUtxos, waitForRoot, withShieldRetries, withTiming, withdrawFeeFor };
|
package/dist/index.js
CHANGED
|
@@ -1945,6 +1945,14 @@ function isSubmissionOutcomeUnknownResponse(responseText) {
|
|
|
1945
1945
|
return false;
|
|
1946
1946
|
}
|
|
1947
1947
|
}
|
|
1948
|
+
function isRelayRequestInFlightResponse(responseText) {
|
|
1949
|
+
try {
|
|
1950
|
+
const parsed = JSON.parse(responseText);
|
|
1951
|
+
return parsed?.code === "transient_upstream" && typeof parsed.message === "string" && parsed.message.includes("is already processing");
|
|
1952
|
+
} catch {
|
|
1953
|
+
return false;
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1948
1956
|
function classifyRelayError(responseText, httpStatus) {
|
|
1949
1957
|
let inner = "";
|
|
1950
1958
|
try {
|
|
@@ -5966,6 +5974,12 @@ var NEAR_TIP_ONCHAIN_FALLBACK_MAX_DISTANCE_LOCAL_RPC = 8;
|
|
|
5966
5974
|
var DEFAULT_RELAY_REQUEST_TIMEOUT_MS = 45e3;
|
|
5967
5975
|
var DEFAULT_RELAY_NETWORK_RETRIES = 6;
|
|
5968
5976
|
var RETRYABLE_RELAY_STATUSES = /* @__PURE__ */ new Set([408, 409, 425, 429, 500, 502, 503, 504, 522, 524]);
|
|
5977
|
+
var RELAY_SOURCE_LEASE_MS = 18e4;
|
|
5978
|
+
var RELAY_SOURCE_LEASE_MARGIN_MS = 5e3;
|
|
5979
|
+
var MAX_LEASE_EXPIRY_REPLAYS = 2;
|
|
5980
|
+
var RELAY_IN_FLIGHT_POLL_MS = 5e3;
|
|
5981
|
+
var RELAY_LANDED_POLL_MS = 1e3;
|
|
5982
|
+
var MAX_LANDED_POLLS = 5;
|
|
5969
5983
|
function parseMissingRelayIndexError(message) {
|
|
5970
5984
|
const match = message.match(
|
|
5971
5985
|
/Relay tree missing required commitment index\s+(\d+)\s+\(tree length:\s*(\d+)\)/i
|
|
@@ -7550,6 +7564,20 @@ async function reconcileCommitmentIndicesWithRelay(relayUrl, mint, suggestedIndi
|
|
|
7550
7564
|
function sleep2(ms) {
|
|
7551
7565
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7552
7566
|
}
|
|
7567
|
+
function sleepUnlessAborted(ms, signal) {
|
|
7568
|
+
if (signal?.aborted) return Promise.resolve(false);
|
|
7569
|
+
return new Promise((resolve) => {
|
|
7570
|
+
const onAbort = () => {
|
|
7571
|
+
clearTimeout(timer);
|
|
7572
|
+
resolve(false);
|
|
7573
|
+
};
|
|
7574
|
+
const timer = setTimeout(() => {
|
|
7575
|
+
signal?.removeEventListener("abort", onAbort);
|
|
7576
|
+
resolve(true);
|
|
7577
|
+
}, ms);
|
|
7578
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
7579
|
+
});
|
|
7580
|
+
}
|
|
7553
7581
|
function hexToBytes2(hex) {
|
|
7554
7582
|
const bytes = new Uint8Array(hex.length / 2);
|
|
7555
7583
|
for (let i = 0; i < hex.length; i += 2) {
|
|
@@ -7784,6 +7812,9 @@ async function submitTransactToRelay(args) {
|
|
|
7784
7812
|
let unknownOutcomeSignature = null;
|
|
7785
7813
|
let possiblySubmitted = false;
|
|
7786
7814
|
let networkRetry = 0;
|
|
7815
|
+
let leaseReplays = 0;
|
|
7816
|
+
let landedPolls = 0;
|
|
7817
|
+
let leaseBaseMs = null;
|
|
7787
7818
|
const verifySettlement = (signature, timeoutMs) => confirmTransactSettlement({
|
|
7788
7819
|
connection: settlement.connection,
|
|
7789
7820
|
programId: settlement.programId,
|
|
@@ -7839,6 +7870,7 @@ async function submitTransactToRelay(args) {
|
|
|
7839
7870
|
const controller = new AbortController();
|
|
7840
7871
|
const timeoutId = setTimeout(() => controller.abort(), requestTimeoutMs);
|
|
7841
7872
|
let response;
|
|
7873
|
+
leaseBaseMs ?? (leaseBaseMs = Date.now());
|
|
7842
7874
|
try {
|
|
7843
7875
|
response = await doFetch(`${relayUrl}/transact`, {
|
|
7844
7876
|
method: "POST",
|
|
@@ -7857,6 +7889,49 @@ async function submitTransactToRelay(args) {
|
|
|
7857
7889
|
if (isSubmissionOutcomeUnknownResponse(responseText) || isRetryableRelayStatus(response.status)) {
|
|
7858
7890
|
possiblySubmitted = true;
|
|
7859
7891
|
}
|
|
7892
|
+
if ((isRelayRequestInFlightResponse(responseText) || isSubmissionOutcomeUnknownResponse(responseText)) && leaseReplays < MAX_LEASE_EXPIRY_REPLAYS) {
|
|
7893
|
+
networkRetry = 0;
|
|
7894
|
+
const leaseEndsMs = (leaseBaseMs ?? Date.now()) + RELAY_SOURCE_LEASE_MS + RELAY_SOURCE_LEASE_MARGIN_MS;
|
|
7895
|
+
const polling = Date.now() < leaseEndsMs;
|
|
7896
|
+
const probe = await verifySettlement(
|
|
7897
|
+
unknownOutcomeSignature,
|
|
7898
|
+
polling ? 0 : args.failureProbeTimeoutMs ?? Math.min(settlementTimeoutMs(), 1e4)
|
|
7899
|
+
);
|
|
7900
|
+
if (probe.status === "landed") {
|
|
7901
|
+
landedPolls++;
|
|
7902
|
+
if (!polling || landedPolls > MAX_LANDED_POLLS) {
|
|
7903
|
+
return await resolveFailure(
|
|
7904
|
+
new Error(relayFailureMessage("Relay error", responseText, requestBody))
|
|
7905
|
+
);
|
|
7906
|
+
}
|
|
7907
|
+
if (!await sleepUnlessAborted(RELAY_LANDED_POLL_MS, args.signal)) {
|
|
7908
|
+
return await resolveFailure(new Error("Relay lease-expiry replay aborted by caller"));
|
|
7909
|
+
}
|
|
7910
|
+
continue;
|
|
7911
|
+
}
|
|
7912
|
+
if (polling) {
|
|
7913
|
+
onProgress?.("Relay is still processing this request; checking again shortly...");
|
|
7914
|
+
const pollMs = Math.min(RELAY_IN_FLIGHT_POLL_MS, leaseEndsMs - Date.now());
|
|
7915
|
+
if (!await sleepUnlessAborted(pollMs, args.signal)) {
|
|
7916
|
+
return await resolveFailure(new Error("Relay lease-expiry replay aborted by caller"));
|
|
7917
|
+
}
|
|
7918
|
+
continue;
|
|
7919
|
+
}
|
|
7920
|
+
leaseReplays++;
|
|
7921
|
+
const waitMs = Math.max(
|
|
7922
|
+
0,
|
|
7923
|
+
(leaseBaseMs ?? Date.now()) + RELAY_SOURCE_LEASE_MS + RELAY_SOURCE_LEASE_MARGIN_MS - Date.now()
|
|
7924
|
+
);
|
|
7925
|
+
onProgress?.(
|
|
7926
|
+
`Relay has not confirmed the outcome. Waiting ${Math.ceil(waitMs / 1e3)}s for its request lease to expire, then replaying the identical signed request (${leaseReplays}/${MAX_LEASE_EXPIRY_REPLAYS})...`
|
|
7927
|
+
);
|
|
7928
|
+
if (!await sleepUnlessAborted(waitMs, args.signal)) {
|
|
7929
|
+
return await resolveFailure(new Error("Relay lease-expiry replay aborted by caller"));
|
|
7930
|
+
}
|
|
7931
|
+
networkRetry = 0;
|
|
7932
|
+
leaseBaseMs = null;
|
|
7933
|
+
continue;
|
|
7934
|
+
}
|
|
7860
7935
|
if (isRetryableRelayStatus(response.status) && networkRetry < maxNetworkRetries) {
|
|
7861
7936
|
networkRetry++;
|
|
7862
7937
|
const delay = relayBackoffMs(networkRetry);
|
|
@@ -11979,7 +12054,7 @@ function parseSwapRefund(r) {
|
|
|
11979
12054
|
checkLeafPair(commitment, leaf, "SWAP_REFUND");
|
|
11980
12055
|
return { kind: 3, mint, slot, commitment, leaf, amountAfterFee, nullifier0, signature };
|
|
11981
12056
|
}
|
|
11982
|
-
function parseNoteIndexPage(bytes, expect) {
|
|
12057
|
+
function parseNoteIndexPage(bytes, expect, options = {}) {
|
|
11983
12058
|
if (!(bytes instanceof Uint8Array)) throw new NoteIndexFormatError("page must be a Uint8Array");
|
|
11984
12059
|
if (bytes.length > NOTE_INDEX_MAX_PAGE_BYTES) {
|
|
11985
12060
|
throw new NoteIndexFormatError(`page is ${bytes.length} bytes, over the ${NOTE_INDEX_MAX_PAGE_BYTES}-byte bound`);
|
|
@@ -12011,7 +12086,9 @@ function parseNoteIndexPage(bytes, expect) {
|
|
|
12011
12086
|
}
|
|
12012
12087
|
const items = [];
|
|
12013
12088
|
const rawItems = [];
|
|
12089
|
+
const itemPositions = [];
|
|
12014
12090
|
let skippedUnknown = 0;
|
|
12091
|
+
let skippedMalformed = 0;
|
|
12015
12092
|
let offset = NOTE_INDEX_HEADER_LEN;
|
|
12016
12093
|
for (let i = 0; i < count; i++) {
|
|
12017
12094
|
if (offset + ITEM_HEADER_LEN > bytes.length) throw new NoteIndexFormatError(`truncated item ${i} header`);
|
|
@@ -12020,34 +12097,45 @@ function parseNoteIndexPage(bytes, expect) {
|
|
|
12020
12097
|
const bodyStart = offset + ITEM_HEADER_LEN;
|
|
12021
12098
|
const bodyEnd = bodyStart + bodyLen;
|
|
12022
12099
|
if (bodyEnd > bytes.length) throw new NoteIndexFormatError(`truncated item ${i} body`);
|
|
12023
|
-
|
|
12100
|
+
if (kind !== NOTE_INDEX_KIND_TX && kind !== NOTE_INDEX_KIND_DELIVERY && kind !== NOTE_INDEX_KIND_SWAP_REFUND) {
|
|
12101
|
+
if (bodyLen > MAX_UNKNOWN_BODY_LEN) throw new NoteIndexFormatError(`unknown kind ${kind} with body_len ${bodyLen}`);
|
|
12102
|
+
skippedUnknown++;
|
|
12103
|
+
offset = bodyEnd;
|
|
12104
|
+
continue;
|
|
12105
|
+
}
|
|
12024
12106
|
let item;
|
|
12025
|
-
|
|
12026
|
-
|
|
12027
|
-
|
|
12028
|
-
|
|
12029
|
-
|
|
12030
|
-
|
|
12031
|
-
|
|
12032
|
-
item = parseDelivery(r);
|
|
12033
|
-
break;
|
|
12034
|
-
case NOTE_INDEX_KIND_SWAP_REFUND:
|
|
12035
|
-
if (bodyLen !== SWAP_REFUND_BODY_LEN) throw new NoteIndexFormatError(`SWAP_REFUND: body_len ${bodyLen}`);
|
|
12036
|
-
item = parseSwapRefund(r);
|
|
12037
|
-
break;
|
|
12038
|
-
default:
|
|
12039
|
-
if (bodyLen > MAX_UNKNOWN_BODY_LEN) throw new NoteIndexFormatError(`unknown kind ${kind} with body_len ${bodyLen}`);
|
|
12040
|
-
skippedUnknown++;
|
|
12041
|
-
offset = bodyEnd;
|
|
12042
|
-
continue;
|
|
12107
|
+
try {
|
|
12108
|
+
item = parseKnownBody(bytes, kind, bodyStart, bodyEnd, i);
|
|
12109
|
+
} catch (error) {
|
|
12110
|
+
if (!options.skipMalformedItems || !(error instanceof NoteIndexFormatError)) throw error;
|
|
12111
|
+
skippedMalformed++;
|
|
12112
|
+
offset = bodyEnd;
|
|
12113
|
+
continue;
|
|
12043
12114
|
}
|
|
12044
|
-
if (r.position !== bodyEnd) throw new NoteIndexFormatError(`item ${i} body has unread bytes`);
|
|
12045
12115
|
items.push(item);
|
|
12046
12116
|
rawItems.push(bytes.slice(offset, bodyEnd));
|
|
12117
|
+
itemPositions.push(i);
|
|
12047
12118
|
offset = bodyEnd;
|
|
12048
12119
|
}
|
|
12049
12120
|
if (offset !== bytes.length) throw new NoteIndexFormatError(`${bytes.length - offset} trailing bytes after ${count} items`);
|
|
12050
|
-
return { epoch, page, firstSeq, complete, count, prevChain, items, rawItems, skippedUnknown };
|
|
12121
|
+
return { epoch, page, firstSeq, complete, count, prevChain, items, rawItems, skippedUnknown, itemPositions, skippedMalformed };
|
|
12122
|
+
}
|
|
12123
|
+
function parseKnownBody(bytes, kind, bodyStart, bodyEnd, i) {
|
|
12124
|
+
const bodyLen = bodyEnd - bodyStart;
|
|
12125
|
+
const r = new Reader(bytes, bodyStart, bodyEnd);
|
|
12126
|
+
let item;
|
|
12127
|
+
if (kind === NOTE_INDEX_KIND_TX) {
|
|
12128
|
+
if (bodyLen < TX_FIXED_LEN) throw new NoteIndexFormatError(`TX: body_len ${bodyLen}`);
|
|
12129
|
+
item = parseTx(r, bodyLen);
|
|
12130
|
+
} else if (kind === NOTE_INDEX_KIND_DELIVERY) {
|
|
12131
|
+
if (bodyLen !== DELIVERY_BODY_LEN) throw new NoteIndexFormatError(`DELIVERY: body_len ${bodyLen}`);
|
|
12132
|
+
item = parseDelivery(r);
|
|
12133
|
+
} else {
|
|
12134
|
+
if (bodyLen !== SWAP_REFUND_BODY_LEN) throw new NoteIndexFormatError(`SWAP_REFUND: body_len ${bodyLen}`);
|
|
12135
|
+
item = parseSwapRefund(r);
|
|
12136
|
+
}
|
|
12137
|
+
if (r.position !== bodyEnd) throw new NoteIndexFormatError(`item ${i} body has unread bytes`);
|
|
12138
|
+
return item;
|
|
12051
12139
|
}
|
|
12052
12140
|
function parseNoteIndexItem(raw) {
|
|
12053
12141
|
if (!(raw instanceof Uint8Array) || raw.length < ITEM_HEADER_LEN) throw new NoteIndexFormatError("truncated item");
|
|
@@ -12477,6 +12565,14 @@ async function trialItem(item, trials) {
|
|
|
12477
12565
|
}
|
|
12478
12566
|
return null;
|
|
12479
12567
|
}
|
|
12568
|
+
async function trialItemIsolated(item, trials, stats) {
|
|
12569
|
+
try {
|
|
12570
|
+
return await trialItem(item, trials);
|
|
12571
|
+
} catch {
|
|
12572
|
+
stats.skipped++;
|
|
12573
|
+
return null;
|
|
12574
|
+
}
|
|
12575
|
+
}
|
|
12480
12576
|
async function trialItemWith(item, trial) {
|
|
12481
12577
|
if (item.kind === 1) {
|
|
12482
12578
|
if (item.note.length === 0) return null;
|
|
@@ -12508,7 +12604,14 @@ function leafOfTxOutput(item, commitment) {
|
|
|
12508
12604
|
if (!isAllZero3(item.comm1) && commitment === bytesToBigint2(item.comm1)) return Number(item.leaf1);
|
|
12509
12605
|
return null;
|
|
12510
12606
|
}
|
|
12511
|
-
|
|
12607
|
+
function changeBlindingOrNull(nk, noteSalt, outputIndex) {
|
|
12608
|
+
try {
|
|
12609
|
+
return deriveChangeNoteBlinding(nk, noteSalt, outputIndex);
|
|
12610
|
+
} catch {
|
|
12611
|
+
return null;
|
|
12612
|
+
}
|
|
12613
|
+
}
|
|
12614
|
+
async function matchOwnItems(own, owner, onReject, onSkip) {
|
|
12512
12615
|
const candidates = [];
|
|
12513
12616
|
const claimed = /* @__PURE__ */ new Set();
|
|
12514
12617
|
const byNullifier = /* @__PURE__ */ new Map();
|
|
@@ -12598,7 +12701,7 @@ async function matchOwnItems(own, owner, onReject) {
|
|
|
12598
12701
|
});
|
|
12599
12702
|
return true;
|
|
12600
12703
|
};
|
|
12601
|
-
|
|
12704
|
+
const direct = async (o) => {
|
|
12602
12705
|
const item = o.item;
|
|
12603
12706
|
if (item.kind === 1 && o.note?.noteSalt !== void 0) {
|
|
12604
12707
|
const note = o.note;
|
|
@@ -12612,7 +12715,7 @@ async function matchOwnItems(own, owner, onReject) {
|
|
|
12612
12715
|
const mint = addressFromBytes(item.mint);
|
|
12613
12716
|
if (o.delivery.amount <= 0n || o.delivery.blinding === 0n) {
|
|
12614
12717
|
onReject(o);
|
|
12615
|
-
|
|
12718
|
+
return;
|
|
12616
12719
|
}
|
|
12617
12720
|
const commitment = await computeCommitment({
|
|
12618
12721
|
amount: o.delivery.amount,
|
|
@@ -12622,7 +12725,7 @@ async function matchOwnItems(own, owner, onReject) {
|
|
|
12622
12725
|
});
|
|
12623
12726
|
if (commitment !== bytesToBigint2(item.commitment)) {
|
|
12624
12727
|
onReject(o);
|
|
12625
|
-
|
|
12728
|
+
return;
|
|
12626
12729
|
}
|
|
12627
12730
|
await add(o, {
|
|
12628
12731
|
kind: "received",
|
|
@@ -12646,6 +12749,13 @@ async function matchOwnItems(own, owner, onReject) {
|
|
|
12646
12749
|
leaf: Number(item.leaf)
|
|
12647
12750
|
});
|
|
12648
12751
|
}
|
|
12752
|
+
};
|
|
12753
|
+
for (const o of own) {
|
|
12754
|
+
try {
|
|
12755
|
+
await direct(o);
|
|
12756
|
+
} catch {
|
|
12757
|
+
onSkip(o);
|
|
12758
|
+
}
|
|
12649
12759
|
}
|
|
12650
12760
|
const processTx = async (o) => {
|
|
12651
12761
|
const item = o.item;
|
|
@@ -12660,8 +12770,9 @@ async function matchOwnItems(own, owner, onReject) {
|
|
|
12660
12770
|
const sumIn = inputs.reduce((acc, c) => acc + c.amount, 0n);
|
|
12661
12771
|
if (!claimed.has(`${o.seq}:1`) && note.outAmount0 !== void 0 && !isAllZero3(item.comm1)) {
|
|
12662
12772
|
const out1 = sumIn + item.publicAmount - note.outAmount0;
|
|
12663
|
-
|
|
12664
|
-
|
|
12773
|
+
const blinding = out1 > 0n ? changeBlindingOrNull(o.trial.nk, note.noteSalt, 1) : null;
|
|
12774
|
+
if (out1 > 0n && blinding === null) onSkip(o);
|
|
12775
|
+
else if (blinding !== null) {
|
|
12665
12776
|
const owners = [{ keypair: owner, atRisk: false }];
|
|
12666
12777
|
const legacyInput = legacyKeys.get(inputs[0].keypair.publicKey);
|
|
12667
12778
|
if (legacyInput && legacyInput.publicKey !== owner.publicKey) owners.push({ keypair: legacyInput, atRisk: true });
|
|
@@ -12682,7 +12793,11 @@ async function matchOwnItems(own, owner, onReject) {
|
|
|
12682
12793
|
for (let i = 0; i < queue.length; i++) {
|
|
12683
12794
|
const o = queue[i];
|
|
12684
12795
|
queued.delete(o);
|
|
12685
|
-
|
|
12796
|
+
try {
|
|
12797
|
+
await processTx(o);
|
|
12798
|
+
} catch {
|
|
12799
|
+
onSkip(o);
|
|
12800
|
+
}
|
|
12686
12801
|
}
|
|
12687
12802
|
return candidates;
|
|
12688
12803
|
}
|
|
@@ -12929,7 +13044,8 @@ async function recoverNotesFromIndex(params) {
|
|
|
12929
13044
|
candidates: 0,
|
|
12930
13045
|
spent: 0,
|
|
12931
13046
|
conflicts: 0,
|
|
12932
|
-
pendingDropped: 0
|
|
13047
|
+
pendingDropped: 0,
|
|
13048
|
+
skipped: 0
|
|
12933
13049
|
};
|
|
12934
13050
|
const rpc = new Proxy(connection, {
|
|
12935
13051
|
get(target, prop, receiver) {
|
|
@@ -12996,10 +13112,11 @@ async function recoverNotesFromIndex(params) {
|
|
|
12996
13112
|
let outcome = await runOnce(ctx, cursor);
|
|
12997
13113
|
if (outcome instanceof FullPassSignal) {
|
|
12998
13114
|
warnings.push(`${outcome.reason}; re-syncing from page 0`);
|
|
12999
|
-
Object.assign(stats, { dropped: 0, decrypted: 0, candidates: 0, spent: 0, conflicts: 0, pendingDropped: 0 });
|
|
13115
|
+
Object.assign(stats, { dropped: 0, decrypted: 0, candidates: 0, spent: 0, conflicts: 0, pendingDropped: 0, skipped: 0 });
|
|
13000
13116
|
outcome = await runOnce(ctx, void 0);
|
|
13001
13117
|
if (outcome instanceof FullPassSignal) throw new Error(`note index recovery failed: ${outcome.reason}`);
|
|
13002
13118
|
}
|
|
13119
|
+
if (stats.skipped > 0) warnings.push(`${stats.skipped} note index entries could not be processed and were skipped`);
|
|
13003
13120
|
stats.ms = Date.now() - startedAt;
|
|
13004
13121
|
return { ...outcome, stats, warnings };
|
|
13005
13122
|
}
|
|
@@ -13076,11 +13193,13 @@ async function runOnce(ctx, cursor) {
|
|
|
13076
13193
|
if (signal.aborted) throw abortError2();
|
|
13077
13194
|
const bytes = await fetchNoteIndexPage(relayUrl, head.epoch, pageNo, { signal });
|
|
13078
13195
|
stats.bytes += bytes.length;
|
|
13079
|
-
const page2 = parseNoteIndexPage(bytes, { epoch: head.epoch, page: pageNo });
|
|
13196
|
+
const page2 = parseNoteIndexPage(bytes, { epoch: head.epoch, page: pageNo }, { skipMalformedItems: true });
|
|
13080
13197
|
if (pageNo < head.completePages && !page2.complete) {
|
|
13081
13198
|
throw new NoteIndexFormatError(`page ${pageNo} is below complete_pages but not complete`);
|
|
13082
13199
|
}
|
|
13083
13200
|
stats.pages++;
|
|
13201
|
+
stats.skipped += page2.skippedMalformed;
|
|
13202
|
+
const seqOf = (i) => pageNo * NOTE_INDEX_PAGE_SIZE + page2.itemPositions[i];
|
|
13084
13203
|
waiting.set(pageNo, { bytes: page2.complete ? bytes : new Uint8Array(0), prevChain: toHex2(page2.prevChain), complete: page2.complete });
|
|
13085
13204
|
advanceChain();
|
|
13086
13205
|
const data = { complete: page2.complete, leaves: /* @__PURE__ */ new Map() };
|
|
@@ -13101,7 +13220,7 @@ async function runOnce(ctx, cursor) {
|
|
|
13101
13220
|
else data.leaves.set(mint, [entry]);
|
|
13102
13221
|
};
|
|
13103
13222
|
page2.items.forEach((item, i) => {
|
|
13104
|
-
const seq =
|
|
13223
|
+
const seq = seqOf(i);
|
|
13105
13224
|
if (item.kind === 1) {
|
|
13106
13225
|
addLeaf(item.mint, item.comm0, item.leaf0, seq);
|
|
13107
13226
|
addLeaf(item.mint, item.comm1, item.leaf1, seq);
|
|
@@ -13118,7 +13237,7 @@ async function runOnce(ctx, cursor) {
|
|
|
13118
13237
|
for (let i = 0; i < page2.items.length; i += ITEM_BATCH) {
|
|
13119
13238
|
if (signal.aborted) throw abortError2();
|
|
13120
13239
|
const batch = page2.items.slice(i, i + ITEM_BATCH);
|
|
13121
|
-
const opened = await Promise.all(batch.map((item) =>
|
|
13240
|
+
const opened = await Promise.all(batch.map((item) => trialItemIsolated(item, trials, stats)));
|
|
13122
13241
|
opened.forEach((o, k) => {
|
|
13123
13242
|
if (!o) return;
|
|
13124
13243
|
stats.decrypted++;
|
|
@@ -13128,7 +13247,7 @@ async function runOnce(ctx, cursor) {
|
|
|
13128
13247
|
stats.dropped++;
|
|
13129
13248
|
return;
|
|
13130
13249
|
}
|
|
13131
|
-
ownItems.push({ page: pageNo, seq:
|
|
13250
|
+
ownItems.push({ page: pageNo, seq: seqOf(i + k), raw, id, item: batch[k], fromCursor: false, ...o, trial: o.trial });
|
|
13132
13251
|
});
|
|
13133
13252
|
stats.items += batch.length;
|
|
13134
13253
|
}
|
|
@@ -13161,7 +13280,7 @@ async function runOnce(ctx, cursor) {
|
|
|
13161
13280
|
throw new NoteIndexFormatError("hash chain does not reach the head's chain_tip");
|
|
13162
13281
|
}
|
|
13163
13282
|
for (const entry of cursor?.items ?? []) {
|
|
13164
|
-
const o = await
|
|
13283
|
+
const o = await trialItemIsolated(entry.item, trials, stats);
|
|
13165
13284
|
if (!o) continue;
|
|
13166
13285
|
const page2 = Math.floor(entry.seq / NOTE_INDEX_PAGE_SIZE);
|
|
13167
13286
|
ownItems.push({ page: page2, seq: entry.seq, raw: entry.raw, id: itemIdentity(entry.raw), item: entry.item, fromCursor: true, ...o, trial: o.trial });
|
|
@@ -13173,10 +13292,20 @@ async function runOnce(ctx, cursor) {
|
|
|
13173
13292
|
const knownSpent = cursor?.spent ?? /* @__PURE__ */ new Set();
|
|
13174
13293
|
ownItems.sort((a, b) => a.seq - b.seq);
|
|
13175
13294
|
const rejectedNow = /* @__PURE__ */ new Set();
|
|
13176
|
-
const
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
13295
|
+
const skippedNow = /* @__PURE__ */ new Set();
|
|
13296
|
+
const allCandidates = await matchOwnItems(
|
|
13297
|
+
ownItems,
|
|
13298
|
+
owner,
|
|
13299
|
+
(o) => {
|
|
13300
|
+
stats.dropped++;
|
|
13301
|
+
rejectedNow.add(o.id);
|
|
13302
|
+
},
|
|
13303
|
+
(o) => {
|
|
13304
|
+
if (skippedNow.has(o)) return;
|
|
13305
|
+
skippedNow.add(o);
|
|
13306
|
+
stats.skipped++;
|
|
13307
|
+
}
|
|
13308
|
+
);
|
|
13180
13309
|
stats.candidates = allCandidates.length;
|
|
13181
13310
|
const cutoff = params.legacyCutoffLeaf ?? {};
|
|
13182
13311
|
const candidates = allCandidates.filter((c) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloak.dev/sdk",
|
|
3
3
|
"description": "Shield, send, and swap on Solana privately — TypeScript SDK with UTXO-based zero-knowledge transactions",
|
|
4
|
-
"version": "0.2.6-staging.
|
|
4
|
+
"version": "0.2.6-staging.abb3ae6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|