@cloak.dev/sdk 0.2.2-staging.33f11a2 → 0.2.2-staging.5dffa29

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/dist/index.d.ts CHANGED
@@ -4668,6 +4668,683 @@ declare class SimpleWallet {
4668
4668
  sync(): Promise<void>;
4669
4669
  }
4670
4670
 
4671
+ /**
4672
+ * What a quote option attests, which is NOT the same question as whether the rail worked.
4673
+ *
4674
+ * Mirrors the service's `rails::Attestation` enum field-for-field (`services/api/bridge/src/rails/
4675
+ * mod.rs`) rather than collapsing it into a boolean: 1Click signs the deposit address AND the
4676
+ * recipient, so a substituted address is detectable by the client even if the service substituted
4677
+ * it. Jupiter signs nothing, so on that rail the user is trusting Cloak — and a UI reading this
4678
+ * union is forced to say so, where a UI reading a boolean could quietly treat both the same.
4679
+ */
4680
+ type BridgeRailAttestation = {
4681
+ kind: "ed25519";
4682
+ verified: boolean;
4683
+ signer: string;
4684
+ } | {
4685
+ kind: "none";
4686
+ checks: string[];
4687
+ note: string;
4688
+ };
4689
+ interface BridgeRailQuoteOption {
4690
+ /** `"oneclick" | "jupiter"` today; typed as `string` so a new rail the service adds is not a
4691
+ * compile error here — the attestation union is what a caller must actually branch on. */
4692
+ rail: string;
4693
+ /** False means a mis-sent or under-filled transfer has NO automated recovery on this rail. */
4694
+ refunds: boolean;
4695
+ /** Whether `depositAddress` is reusable, or fresh per order and expiring. */
4696
+ addressLifetime: string;
4697
+ /** What the rail expects to deliver. NOT a promise — never display this alone. */
4698
+ amountOut: bigint;
4699
+ /** The floor the rail commits to. This is the number a UI should lead with. */
4700
+ minAmountOut: bigint;
4701
+ timeEstimateSeconds?: number;
4702
+ /** The rail's own expiry, when it returns one. Do not invent a value it attests to. */
4703
+ expiresAt?: string;
4704
+ /** Where the user sends funds on the origin chain. Absent on a dry quote (`allocate: false`),
4705
+ * where nothing has been reserved and there is nothing to send to yet. */
4706
+ depositAddress?: string;
4707
+ attestation: BridgeRailAttestation;
4708
+ }
4709
+ interface BridgeRailProblem {
4710
+ rail: string;
4711
+ reason: string;
4712
+ }
4713
+ interface BridgeRailQuoteRequest {
4714
+ /** The derived receiving address R. Base58, on Solana. */
4715
+ recipient: string;
4716
+ originChain: string;
4717
+ /** Base units on the origin chain, as a bigint — a JS `number` loses precision above 2^53 and
4718
+ * this can be an arbitrary token amount. */
4719
+ amountBaseUnits: bigint;
4720
+ /** Origin-chain address an unfillable 1Click order refunds to. Required for that rail. */
4721
+ refundTo?: string;
4722
+ rails?: string[];
4723
+ /** False (the default) sends `dry: true` to 1Click and skips GUM's allocation probes: nothing is
4724
+ * reserved and no `depositAddress` comes back. Requesting an allocation for a deposit the quote
4725
+ * gate might still refuse is the wrong order of operations — leave this false until the caller
4726
+ * has already decided to proceed. */
4727
+ allocate?: boolean;
4728
+ }
4729
+ interface BridgeRailQuoteResponse {
4730
+ options: BridgeRailQuoteOption[];
4731
+ /** Errors from rails that failed, so one rail being down does not hide the other's answer. */
4732
+ unavailable: BridgeRailProblem[];
4733
+ }
4734
+ /**
4735
+ * Mirrors the service's `api::status::DeliveryState` (`services/api/bridge/src/api/status.rs`),
4736
+ * `snake_case` on the wire and identical here. `"unknown"` is a real answer, not a parse failure:
4737
+ * Jupiter/GUM hands out permanent deposit addresses and has no per-transfer status API, so on
4738
+ * that rail the service ALWAYS answers `"unknown"` and says so in `detail` — poll the recipient's
4739
+ * on-chain balance instead. `"expired"` is derived by the service from the order deadline, not a
4740
+ * value 1Click returns.
4741
+ */
4742
+ type BridgeDeliveryState = "pending" | "delivered" | "refunded" | "expired" | "unknown";
4743
+ interface BridgeRailStatusResult {
4744
+ /** The rail that answered, echoed from the service. */
4745
+ rail: string;
4746
+ state: BridgeDeliveryState;
4747
+ /** The service's own explanation of `state`, e.g. why a `"jupiter"` query is `"unknown"`. */
4748
+ detail: string;
4749
+ }
4750
+ interface BridgeRail {
4751
+ readonly id: string;
4752
+ quote(req: BridgeRailQuoteRequest): Promise<BridgeRailQuoteResponse>;
4753
+ /**
4754
+ * `rail` is the `rail` of the quote option whose `depositAddress` this is: the service keys its
4755
+ * status lookup on (address, rail) because the two rails have unrelated status surfaces.
4756
+ */
4757
+ status(depositAddress: string, rail: string): Promise<BridgeRailStatusResult>;
4758
+ }
4759
+ /**
4760
+ * The one constructor this package exposes for talking to the bridge rails — always through
4761
+ * Cloak's own service, never through a rail's API or Kora.
4762
+ *
4763
+ * `relayUrl` is checked HERE, at construction, in addition to the check `relayFetch` repeats on
4764
+ * every call: a caller who mistypes a rail's own base URL (or Kora's) finds out immediately rather
4765
+ * than on first use, and `assertAllowedRelayOrigin` in this function's own body is what lets
4766
+ * `relay-origin-lock.test.ts` enumerate this door the same way it enumerates `RelayService`'s
4767
+ * constructor.
4768
+ */
4769
+ declare function cloakBridgeRail(relayUrl: string): BridgeRail;
4770
+
4771
+ /**
4772
+ * The paymaster client — the SOL top-up that lets a bridge receiver R (which arrives holding only
4773
+ * bridged tokens, no SOL) shield without the user's own wallet ever appearing on chain.
4774
+ *
4775
+ * Talks ONLY to Cloak's own bridge service (`api.cloak.ag/bridge/paymaster/*`), never to Kora
4776
+ * directly: under fixed pricing (docs/00-DECISION-STATE.md, PAYMASTER ECONOMICS) the Kora API key is
4777
+ * worth real money to whoever holds it, and a browser bundle is not a place that can keep a secret.
4778
+ *
4779
+ * ── The two-round-trip shape, and why it is not one call ─────────────────────────────────────
4780
+ * `prepare` returns an UNSIGNED transaction the service built and priced, plus a voucher that MACs
4781
+ * the exact message bytes. The client's receiving key R signs it — R never leaves the client, and
4782
+ * this is the only place it signs anything for the paymaster flow — and hands the bytes back
4783
+ * unchanged to `cosign`, which recognises them via the voucher and only THEN asks Kora to co-sign as
4784
+ * fee payer. The paymaster's key never leaves the server; R's key never leaves the client; neither
4785
+ * round trip needs the other's secret. See `services/api/bridge/src/api/paymaster.rs` for the
4786
+ * server half of this contract.
4787
+ *
4788
+ * ── Why the shape check below is not optional ────────────────────────────────────────────────
4789
+ * `cosign` answers exactly one question — "is this the message I built?" — and answers it by MAC,
4790
+ * not by re-deriving policy from an arbitrary transaction. That makes `prepare`'s response the ONLY
4791
+ * point where an unexpected instruction could sneak in (a compromised service, a MITM'd response, a
4792
+ * bug that built the wrong thing), because nothing downstream re-checks it. `validate
4793
+ * PaymasterTopUpTransaction` is that one check, and it runs BEFORE R signs anything: signing is the
4794
+ * one irreversible step in this flow from the client's point of view, so the check that matters has
4795
+ * to sit in front of it, not after.
4796
+ */
4797
+
4798
+ /** What `prepare`'s response is checked against before R ever signs it. */
4799
+ interface PaymasterTopUpExpectation {
4800
+ /** R — the only account this transaction may fund or spend from. */
4801
+ recipient: PublicKey;
4802
+ /** The lamports we asked for. `ix0.lamports` may come in at or under this, never over. */
4803
+ maxGrantLamports: bigint;
4804
+ feeMint: PublicKey;
4805
+ /** The fee Kora actually quoted at `prepare` time. `ix1.amount`, if `ix1` exists, must equal this
4806
+ * exactly — not "at most", because the fee is a quote the service already committed to, not a
4807
+ * ceiling. */
4808
+ feeTokenAmount: bigint;
4809
+ /** The paymaster's own token account owner, from `prepare`'s `payment_address`. `ix1`'s
4810
+ * destination must be exactly THIS address's ATA for `feeMint` — nothing else, and never an ATA
4811
+ * derived from `recipient` or from an address the caller does not already trust. */
4812
+ paymentAddress: PublicKey;
4813
+ }
4814
+ /**
4815
+ * The one check standing between `prepare`'s response and R's signature.
4816
+ *
4817
+ * Two instructions, and the shape IS the security story (`paymaster/topup.rs`'s own words, mirrored
4818
+ * here on the verifying side):
4819
+ *
4820
+ * ix0 System transfer, paymaster -> recipient, <= the lamports we asked for
4821
+ * ix1 (optional) SPL transfer, recipient's fee-mint ATA -> paymaster's fee-mint ATA, authority
4822
+ * = recipient, amount == the quoted fee
4823
+ *
4824
+ * Anything else — a third instruction, a different destination, a different authority, an amount
4825
+ * that does not match the quote — is refused. This function throws rather than returning a verdict:
4826
+ * there is no partial-trust path here, and a caller that wants to keep going after a refusal is a
4827
+ * caller papering over a corrupted or hostile response.
4828
+ */
4829
+ declare function validatePaymasterTopUpTransaction(tx: Transaction, expect: PaymasterTopUpExpectation): void;
4830
+ interface PaymasterTopUpResult {
4831
+ /** Fully signed by both R and the paymaster. The caller submits it — Kora's own
4832
+ * `signAndSendTransaction` is disabled service-side, and the broadcast should not carry the
4833
+ * service's IP any more than the deposit itself should carry R's. */
4834
+ transaction: Transaction;
4835
+ feeTokenAmount: bigint;
4836
+ feeMint: string;
4837
+ paymentAddress: string;
4838
+ }
4839
+ /**
4840
+ * The whole paymaster flow: prepare, verify the shape, sign as R, cosign, return the fully-signed
4841
+ * transaction for the caller to submit.
4842
+ *
4843
+ * `receiver` is the derived bridge receiving key (`deriveBridgeReceiver`). It signs here and only
4844
+ * here in this file's flow, and its secret never leaves this function — nothing above needs it, and
4845
+ * nothing here sends it anywhere.
4846
+ */
4847
+ declare function fundReceiverViaPaymaster(relayUrl: string, receiver: Keypair, grantLamports: bigint): Promise<PaymasterTopUpResult>;
4848
+
4849
+ /**
4850
+ * Deriving a bridge receiving address.
4851
+ *
4852
+ * One single-use address per deposit, from the wallet's own key material. Deterministic, offline,
4853
+ * and stateless — which is what lets every other function here work on a device that has never
4854
+ * seen this deposit before.
4855
+ */
4856
+
4857
+ declare const BRIDGE_ESCROW_LABEL = "cloak_bridge_escrow";
4858
+ /**
4859
+ * The index MUST be a small sequential counter (0, 1, 2, …), never a timestamp.
4860
+ *
4861
+ * This is not a style preference: discovery works by deriving indices 0…N and reading each on
4862
+ * chain. A timestamp index is unreachable by any scan, so a deposit made under one is invisible to
4863
+ * every device except the one that made it — which is precisely the failure that made a resume
4864
+ * link look necessary. The prototype harness used `Date.now()` for test hermeticity and those
4865
+ * deposits are, correctly, undiscoverable.
4866
+ */
4867
+ /**
4868
+ * The largest index discovery could plausibly reach. A scan is one round of on-chain reads per
4869
+ * index, so anything past a few thousand is not recoverable in practice — and a timestamp (~1.8e12)
4870
+ * is not recoverable even in principle. Rejecting it here is the difference between the constraint
4871
+ * being documented and it being enforced.
4872
+ */
4873
+ declare const MAX_RECEIVER_INDEX = 10000;
4874
+ declare function deriveBridgeReceiver(nk: Uint8Array | Buffer, index: number): Keypair;
4875
+
4876
+ /**
4877
+ * Finding a user's bridge deposits from their key material alone.
4878
+ *
4879
+ * THIS IS THE FUNCTION THAT MAKES THE BRIDGE AN SDK CAPABILITY RATHER THAN A WEB FEATURE.
4880
+ *
4881
+ * Derive receivers for index 0…N and read each on chain. No stored state, no link to carry, no
4882
+ * localStorage. It works on a device that has never seen the app, in a CLI, on mobile, after a
4883
+ * browser wipe. An earlier design proposed a shareable URL to carry the deposit index to a second
4884
+ * device; the index does not need carrying, it needs scanning, and the link it replaced was a
4885
+ * packaged correlation between an origin payment and a Solana address about to enter the pool.
4886
+ */
4887
+
4888
+ type BridgeDepositState =
4889
+ /** Nothing ever happened at this index. */
4890
+ "unused"
4891
+ /** Funded for a deposit, but no tokens have arrived. */
4892
+ | "awaiting"
4893
+ /** Tokens are sitting at the receiver, in the open, not yet shielded. */
4894
+ | "arrived"
4895
+ /** Shielded, and the receiver's token account has been closed. */
4896
+ | "complete"
4897
+ /** Shielded, but the token account is still open and holding its rent. */
4898
+ | "needs-cleanup"
4899
+ /**
4900
+ * An RPC read failed while checking this index. This is NOT evidence of absence — it is the
4901
+ * opposite of "unused" in every way that matters to a caller: a rate-limited or dropped read
4902
+ * used to fall back to a zero/empty default, which reported a real deposit's index as nothing-
4903
+ * here, indistinguishable from the index truly never having been touched. A user reading that
4904
+ * concludes their money is gone. `error` on the deposit explains what failed; the fix is to
4905
+ * retry, not to trust this entry's tokenBalance/lamports, which are placeholders.
4906
+ */
4907
+ | "unknown";
4908
+ interface BridgeDeposit {
4909
+ index: number;
4910
+ receiver: PublicKey;
4911
+ tokenAccount: PublicKey;
4912
+ state: BridgeDepositState;
4913
+ /** Placeholder 0n when state is "unknown" — the read that would have set this failed. */
4914
+ tokenBalance: bigint;
4915
+ /** Placeholder 0 when state is "unknown" — the read that would have set this failed. */
4916
+ lamports: number;
4917
+ /** Signature of the shield-pool transaction, when one was found. Most recent, if more than one — see indexReused. */
4918
+ shieldSignature?: string;
4919
+ /**
4920
+ * True when this receiver's own history holds more than one shield-pool transaction: this index
4921
+ * was used for more than one deposit. Two deposits at the same index share one on-chain address,
4922
+ * which links them to each other, and `shieldSignature` alone would silently pick one and hide
4923
+ * that a second one exists. A caller MUST warn the user instead of treating this as a single
4924
+ * ordinary deposit.
4925
+ */
4926
+ indexReused?: boolean;
4927
+ /** Every shield-pool signature found at this receiver, most recent first. Present only when indexReused. */
4928
+ shieldSignatures?: string[];
4929
+ /** Set only when state is "unknown": the failure that made this index's status unconfirmable. */
4930
+ error?: string;
4931
+ }
4932
+ interface DiscoverOptions {
4933
+ /**
4934
+ * How many indices to derive, starting at 0. Discovery is one to a few on-chain reads per index,
4935
+ * so this bounds the cost of a scan — it is NOT a claim about where deposits can live. An index
4936
+ * can be as large as MAX_RECEIVER_INDEX (10,000, see ./derive), and the default of 20 only covers
4937
+ * indices allocated sequentially with the stopAfterUnused gap tolerance below. A caller with
4938
+ * reason to believe a deposit landed further out (a CLI --index flag, a resumed session that
4939
+ * knows its own counter) MUST pass a larger scanDepth explicitly — anything past the configured
4940
+ * depth is simply never read, and reports as neither found nor absent, because it was not looked
4941
+ * at. Clamped to MAX_RECEIVER_INDEX + 1 (the count of valid indices, 0 through MAX_RECEIVER_INDEX
4942
+ * inclusive): deriveBridgeReceiver throws past that ceiling, and without the clamp a caller who
4943
+ * over-estimates scanDepth turns that into a mid-scan crash that discards every deposit already
4944
+ * found in the same call.
4945
+ */
4946
+ scanDepth?: number;
4947
+ /** Stop after this many consecutive unused indices. An "unknown" index (RPC failure) neither
4948
+ * counts toward nor resets this run — it carries no information about presence or absence, so
4949
+ * letting it break a real run of unused indices early would reintroduce the same false-absence
4950
+ * failure this file exists to prevent. */
4951
+ stopAfterUnused?: number;
4952
+ programId: PublicKey;
4953
+ mint: PublicKey;
4954
+ }
4955
+ /**
4956
+ * A terminal state needs TWO conjuncts, never one.
4957
+ *
4958
+ * After the rent cleanup runs, "the receiver's token balance is zero" is indistinguishable from
4959
+ * "nothing ever happened at this address". Deriving completion from balance alone overwrites a
4960
+ * real completion record with an empty one — observed live, and it crashed the view that read it.
4961
+ * Completion therefore requires the shield-pool transaction to be present in the receiver's own
4962
+ * history as well.
4963
+ */
4964
+ declare function listBridgeDeposits(conn: Connection, nk: Uint8Array | Buffer, opts: DiscoverOptions): Promise<BridgeDeposit[]>;
4965
+
4966
+ /**
4967
+ * The client half of a bridge deposit, from "tokens have arrived at R" onwards.
4968
+ *
4969
+ * This module is deliberately RAIL-AGNOSTIC. It is imported unchanged by:
4970
+ * - phase1-deposit.ts, where a seeded account plays the rail with a direct SPL transfer
4971
+ * - phase2-e2e.ts, where the rail stand-in delivers over HTTP
4972
+ * - phase3-e2e.ts, where a real Polygon fork drives the whole thing
4973
+ *
4974
+ * That import graph IS the proof of 11-E2E-PLAN.md Phase 2's pass criterion — "the client code
4975
+ * from Phase 1 runs unchanged against the stand-in" — enforced structurally rather than by
4976
+ * eyeballing two copies.
4977
+ *
4978
+ * It was NOT true when first written: phase1-deposit.ts kept its own inline copy, and so never
4979
+ * received the CLEANUP_FEE_BUDGET fix that landed here and in funder.ts. A reviewer caught both
4980
+ * the stale copy and the false claim. Keep every phase importing this file; do not fork it.
4981
+ */
4982
+
4983
+ interface DepositOutcome {
4984
+ signature: string;
4985
+ noteIndex: number;
4986
+ amount: bigint;
4987
+ txSize: number;
4988
+ rBefore: number;
4989
+ rAfter: number;
4990
+ rentExempt: boolean;
4991
+ /** The proof's two input nullifiers (zero-value padding for a pure deposit, but each one is a
4992
+ * genuine Poseidon hash over a random salt — NOT the literal zero sentinel the program treats
4993
+ * as "no PDA needed". See phase4-adversarial.ts case (c). */
4994
+ inputNullifiers: bigint[];
4995
+ /** The three program accounts the funding seam read off the built tx, and what it sent each —
4996
+ * 0 if the account already held enough. Exposed so a caller can independently verify their
4997
+ * on-chain state afterward, including after a thrown error (see `DepositError` below). */
4998
+ fundedAccounts: {
4999
+ name: string;
5000
+ address: string;
5001
+ lamportsSent: number;
5002
+ }[];
5003
+ }
5004
+ /** Thrown by `depositFromDerivedKey` in place of a bare `Error` whenever the funding seam ran
5005
+ * before the failure, so a caller can see exactly what already landed on chain despite the
5006
+ * overall deposit failing. `fundedAccounts` / `measuredSize` are `undefined` only if the seam
5007
+ * never ran at all (failure before signTransaction was called). */
5008
+ declare class DepositError extends Error {
5009
+ readonly fundedAccounts: DepositOutcome["fundedAccounts"];
5010
+ readonly measuredTxSize: number;
5011
+ constructor(message: string, fundedAccounts: DepositOutcome["fundedAccounts"], measuredTxSize: number);
5012
+ }
5013
+ /**
5014
+ * Fund R minimally, then deposit with R as the only signer.
5015
+ *
5016
+ * The funding seam is the SDK's `signTransaction`: by the time it is called the proof and the
5017
+ * relay's risk quote both exist, so the three program accounts are READ OFF the built
5018
+ * transaction rather than re-derived, and cannot drift from what the program will touch.
5019
+ *
5020
+ * `grantOverride` replaces the computed grant (rent floor + deposit fee + cleanup fee) with an
5021
+ * arbitrary lamport amount. Only phase4-adversarial.ts case (a) passes it, to reproduce the
5022
+ * "funded R with just its fee, not its floor" mistake deliberately; every other caller omits it
5023
+ * and gets the same grant this function has always sent.
5024
+ */
5025
+ declare function depositFromDerivedKey(conn: Connection, R: Keypair, funder: Keypair, amount: bigint, log: ((s: string) => void) | undefined, grantOverride: number | undefined,
5026
+ /**
5027
+ * relayUrl, programId and mint are all REQUIRED — no default, for any of the three, on any
5028
+ * environment. They used to fall back to the module-level RELAY/PROGRAM/MINT constants above,
5029
+ * each evaluated once at import time, and that is exactly how a live mainnet deposit got built
5030
+ * against the local program id while the banner said api.cloak.ag: the default filled the hole
5031
+ * silently instead of the caller having to say so. There is nothing left to fall into.
5032
+ */
5033
+ opts: {
5034
+ relayUrl: string;
5035
+ programId: PublicKey;
5036
+ mint: PublicKey;
5037
+ noteSpendKey: Uint8Array;
5038
+ }): Promise<DepositOutcome>;
5039
+
5040
+ /**
5041
+ * Recover the receiving address's token-account rent, even when someone has dusted it.
5042
+ *
5043
+ * THE PROBLEM (found by testing, docs/11-E2E-PLAN.md Phase 4): the rail creates R's token account
5044
+ * and pays its 2,039,280 rent. After the deposit that account is empty and closing it returns the
5045
+ * rent TO THE USER. But SPL Token refuses to close a non-empty account, and dust below the
5046
+ * program's 1,000,000-base-unit deposit minimum cannot be swept by re-depositing it — the program
5047
+ * correctly rejects it with DepositTooSmall. So one base unit from anyone permanently strands
5048
+ * about forty cents of somebody else's money, for free.
5049
+ *
5050
+ * THE FIX, in two parts. Dust that arrives BEFORE the deposit is not a problem at all: the deposit
5051
+ * shields R's whole balance, so it goes into the pool with everything else. The griefing only bites
5052
+ * when dust lands AFTER the deposit, and then the honest answer is to leave it.
5053
+ *
5054
+ * WHY LEAVE IT — this reverses an earlier decision, deliberately. Sweeping the dust to the user's
5055
+ * own wallet publishes `R -> user` on a public ledger, and R has just deposited into the shielded
5056
+ * pool. Anyone can join those two facts and learn that this user made that deposit. That is the
5057
+ * precise inference the pool exists to prevent, and it is the same leak that funding R from the
5058
+ * user's wallet used to cause at the other end of the flow — moved to the end, not removed. It is
5059
+ * not worth about twenty-two cents of rent. Sweeping to Cloak instead is not an option either:
5060
+ * capturing user funds off-chain is an off-chain fee, which the team rule forbids.
5061
+ *
5062
+ * So the default is privacy-first: close when empty, and when dusted, leave the account open and
5063
+ * say so. `dustDestination` lets a caller sweep anyway, with the linkage stated in its doc comment.
5064
+ * Burning stays out: dust can be up to 999,999 base units, and destroying a dollar to recover
5065
+ * twenty-two cents is a worse outcome than the griefing it answers.
5066
+ */
5067
+
5068
+ interface CleanupResult {
5069
+ closed: boolean;
5070
+ dustSwept: bigint;
5071
+ rentReturned: number;
5072
+ destination: string | null;
5073
+ signature: string | null;
5074
+ note: string;
5075
+ }
5076
+ /**
5077
+ * @param dustDestination where post-deposit dust goes, if the caller wants it swept at all.
5078
+ * LEAVE IT UNDEFINED unless the user has been told the cost: any destination they control
5079
+ * publishes `R -> them` and deanonymises the deposit R just made. It is never Cloak's, because
5080
+ * capturing user funds off-chain would be an off-chain fee, which the team rule forbids.
5081
+ * Undefined means "close if empty, otherwise leave it alone and report it".
5082
+ * @param mint the shielded asset R was funded for. Defaults to mainnet USDC so a caller written
5083
+ * before this parameter existed keeps compiling and keeps recovering the same account it always
5084
+ * has; a bridge for any other asset MUST pass its own mint, since R's token account and the
5085
+ * dust sitting in it both belong to whatever mint the rail actually delivered, not to this
5086
+ * default.
5087
+ */
5088
+ declare function cleanupReceivingAddress(conn: Connection, R: Keypair, dustDestination?: PublicKey, mint?: PublicKey): Promise<CleanupResult>;
5089
+
5090
+ /**
5091
+ * Local deposit funder for the bridge testbed.
5092
+ *
5093
+ * The bridge pays a derived address R that arrives with zero SOL, and the deposit takes its
5094
+ * account rent from R (`transact_spl/mod.rs:92` passes `payer_info` into `create_nullifier_pdas`).
5095
+ * But `create_pda_account_safe` (`utils/pda.rs:30-61`) ADOPTS an already-funded, System-owned,
5096
+ * zero-data account and transfers only the shortfall — so the rent can be paid straight to the
5097
+ * three PDAs in an earlier transaction, and R never touches it.
5098
+ *
5099
+ * That split is the whole point. Lamports parked at the nullifier and risk-nonce PDAs are
5100
+ * unrecoverable by ANYONE (no instruction in the program closes them), so flooding this funder
5101
+ * burns Cloak's SOL and earns an attacker nothing. Sending the same total to R instead would put
5102
+ * all of it in an account the requester can sweep in one instruction.
5103
+ *
5104
+ * WHAT SURVIVED THE PORT: the rent constants, the funding-target derivation, and the live rent
5105
+ * read. Everything that SUBMITTED a transaction stayed behind in the prototype — see the note at
5106
+ * the bottom of this file. The production funder is the paymaster, and it runs on a server.
5107
+ */
5108
+
5109
+ /** Rent for a 0-byte System account. `utils/pda.rs:99` -> `minimum_balance(0)`. */
5110
+ declare const MAINNET_RENT_0 = 890880;
5111
+ /** Rent for a 1-byte account. `state/nullifier.rs:18` says `SIZE = 1`. */
5112
+ declare const MAINNET_RENT_1 = 897840;
5113
+ /**
5114
+ * R must be able to pay its own transaction fee. The SDK hard-codes
5115
+ * setComputeUnitPrice(100_000) over setComputeUnitLimit(1_200_000) with no caller lever
5116
+ * (`sdk/src/flows/transact.ts:2598-2599`), so a deposit that fits costs 5,000 + 120,000.
5117
+ * Funding R with the 20,000 an earlier draft assumed leaves it 105,000 short and every
5118
+ * deposit fails under load.
5119
+ */
5120
+ declare const FEE_BUDGET = 130000;
5121
+ /**
5122
+ * A SECOND fee, for the cleanup transaction in which R closes its own token account and the
5123
+ * rail-paid 2,039,280 goes back to the user.
5124
+ *
5125
+ * MEASURED 2026-09-05: without it the close is impossible. Solana checks the fee payer's
5126
+ * rent-exemption after deducting the fee and BEFORE executing, so an R funded to exactly the
5127
+ * floor fails with "insufficient funds for rent" — even though the very transaction being
5128
+ * rejected would have credited it 2,039,280. Budgeting only the deposit's fee strands the
5129
+ * largest recoverable line in the whole flow.
5130
+ */
5131
+ declare const CLEANUP_FEE_BUDGET = 5000;
5132
+ interface DepositRef {
5133
+ programId: PublicKey;
5134
+ mint: PublicKey;
5135
+ /** The two input nullifiers from the proof's public inputs. */
5136
+ nullifiers: [Uint8Array, Uint8Array];
5137
+ /** bind0 from the relay's signed risk quote; the risk-nonce PDA is derived from it. */
5138
+ bind0: Uint8Array;
5139
+ /** R — the derived receiving address that will sign the deposit. */
5140
+ depositor: PublicKey;
5141
+ }
5142
+ /** Mirrors relay `derive_addresses` (supplemental_alt.rs) and the program's own derivations. */
5143
+ declare function deriveFundingTargets(d: DepositRef): {
5144
+ pool: PublicKey;
5145
+ nullifier0: PublicKey;
5146
+ nullifier1: PublicKey;
5147
+ riskNonce: PublicKey;
5148
+ depositorAta: PublicKey;
5149
+ };
5150
+ interface RentRates {
5151
+ zero: number;
5152
+ one: number;
5153
+ }
5154
+ /** Read rent live. Never hard-code it: a local validator's rent sysvar is not authoritative. */
5155
+ declare function readRent(conn: Connection): Promise<RentRates>;
5156
+ interface FundingPlan {
5157
+ transfers: {
5158
+ to: PublicKey;
5159
+ lamports: number;
5160
+ why: string;
5161
+ }[];
5162
+ total: number;
5163
+ alreadyFunded: string[];
5164
+ rent: RentRates;
5165
+ warnings: string[];
5166
+ }
5167
+
5168
+ declare const ONECLICK_PUBKEY_B58 = "reYaWhvwu8Jzo3WUM3zhn6VrhuMEF4eADL17qtRVifc";
5169
+ /**
5170
+ * The exact string this rail signs over, exported so a second implementation can be checked against
5171
+ * it rather than reasoned about.
5172
+ *
5173
+ * A Rust twin of `stable()` has to reproduce JavaScript's key ordering and number formatting byte
5174
+ * for byte, and the two languages do not agree by default: `Object.keys().sort()` orders by UTF-16
5175
+ * code unit while Rust's `sort()` orders by UTF-8 byte. They coincide for ASCII and diverge above
5176
+ * it. This is the same class of bug as `canonicalJson` versus Rust's `keys.sort_unstable()` in the
5177
+ * relay-auth payload, and it fails in the worst direction: a verifier that rejects HONEST quotes
5178
+ * looks like a rail outage, and teaches whoever is on call to ignore it.
5179
+ *
5180
+ * So the cross-language test compares THIS string, not just the boolean verdict. Two verifiers can
5181
+ * agree on a signature by both being wrong in the same place; they cannot agree on the bytes by
5182
+ * accident.
5183
+ */
5184
+ declare function canonicalPayloadString(resp: any): string;
5185
+ declare function verifyQuoteSignature(resp: any): {
5186
+ valid: boolean;
5187
+ reason?: string;
5188
+ };
5189
+
5190
+ /**
5191
+ * Deciding whether a bridge deposit can be honoured — BEFORE the user sends anything.
5192
+ *
5193
+ * WHY THIS EXISTS. Shielding on arrival is mandatory, not a choice: a user who bridges and then
5194
+ * sweeps unshielded has manufactured exactly the `receiver -> them` link the whole design removes.
5195
+ * But "mandatory" moves every failure from the user's account to ours. If someone sends 3 USDC and
5196
+ * the paymaster fee leaves less than the program's 1,000,000-base-unit floor, the shield CANNOT
5197
+ * happen — and under a mandatory model that is the product breaking its own promise, with the money
5198
+ * stranded unshielded at an address the user has never heard of.
5199
+ *
5200
+ * So the check belongs at quote time. The rule is the one the rail-signature check already
5201
+ * established: NEVER SHOW AN ADDRESS YOU CANNOT HONOUR. An unviable deposit is refused before the
5202
+ * deposit address is displayed, not diagnosed after the money has landed.
5203
+ *
5204
+ * All figures are worst-case, taken from the rail's guaranteed floor (`minAmountOut`), never its
5205
+ * target. A quote that only works at the target is a quote that fails on a bad day.
5206
+ */
5207
+ /** programs/shield-pool/src/constants.rs:126 — enforced at transact_spl/deposit.rs:69. */
5208
+ declare const MIN_DEPOSIT_SPL_BASE_UNITS = 1000000n;
5209
+ /**
5210
+ * Live mainnet USDC PoolConfig at deploy time: a flat fee plus a proportional part, charged on
5211
+ * WITHDRAWAL. These are the program's DEFAULTS, not a live read — quote.ts has no RPC client, so it
5212
+ * cannot see a PoolConfig an admin has since changed. Treat this pair as a fallback only: it is
5213
+ * shown to a user as what it will cost to get their money out, and if the live config has moved,
5214
+ * this UNDERSTATES that cost. A caller that has already fetched PoolConfig should pass the real
5215
+ * figures through `BridgeQuoteInput.liveWithdrawFixedFee` / `liveWithdrawFeeBps` instead.
5216
+ */
5217
+ declare const WITHDRAW_FIXED_FEE = 450000n;
5218
+ declare const WITHDRAW_FEE_BPS = 30n;
5219
+ /**
5220
+ * Below this, the fixed costs dominate: a deposit works, but most of it goes to fees.
5221
+ *
5222
+ * It is ADVISORY. `viable` is the hard gate; this only warns and asks for a second confirmation,
5223
+ * because it is the user's money and their call.
5224
+ *
5225
+ * WAS 20 USDC, derived from a 1.21 round trip when the paymaster charged $0.458 for something that
5226
+ * cost it $0.104. Fixed pricing took that to $0.150 on 2026-09-07 (docs/17-PAYMASTER-ECONOMICS.md),
5227
+ * the round trip fell to ~0.90, and leaving the constant alone would have warned people off
5228
+ * deposits that had become perfectly reasonable. If the paymaster fee moves again, recompute
5229
+ * FIXED_ROUND_TRIP rather than editing this number.
5230
+ *
5231
+ * 0.903 / a + 0.003 = 0.063 -> a = 15.05
5232
+ */
5233
+ declare const ECONOMIC_MINIMUM: bigint;
5234
+ interface BridgeQuoteInput {
5235
+ /** What the user sends on the origin chain, in the destination asset's base units. */
5236
+ sent: bigint;
5237
+ /** The rail's GUARANTEED floor. Assess against this, never `amountOut`. */
5238
+ arrivesMin: bigint;
5239
+ /** The rail's target, for display only. */
5240
+ arrivesTarget: bigint;
5241
+ /** What the paymaster will charge to fund the receiver, buffered, in the same units. */
5242
+ paymasterFee: bigint;
5243
+ /**
5244
+ * Live PoolConfig withdraw-fee figures, when the caller has already fetched them on-chain.
5245
+ * Optional: omitting either falls back to the compile-time WITHDRAW_FIXED_FEE / WITHDRAW_FEE_BPS
5246
+ * constants above, which can be stale. quote.ts never fetches these itself — no RPC call belongs
5247
+ * in a pure quote assessment — so the live figures can only arrive this way.
5248
+ */
5249
+ liveWithdrawFixedFee?: bigint;
5250
+ liveWithdrawFeeBps?: bigint;
5251
+ }
5252
+ interface BridgeQuoteAssessment extends BridgeQuoteInput {
5253
+ /** What actually lands shielded, worst case. This is the number to show the user. */
5254
+ shieldedMin: bigint;
5255
+ shieldedTarget: bigint;
5256
+ /** False means REFUSE: the shield is impossible, so the deposit must not be offered. */
5257
+ viable: boolean;
5258
+ /** False means warn: it will work, but the fixed costs dominate. */
5259
+ economic: boolean;
5260
+ /** What it would cost to take it out again, so "shielded" is not mistaken for "free to exit". */
5261
+ withdrawFee: bigint;
5262
+ /** Origin-to-recipient loss if they shielded and immediately withdrew, worst case. */
5263
+ roundTripCost: bigint;
5264
+ roundTripFraction: number;
5265
+ /** Human-readable, ordered most important first. Empty when everything is fine. */
5266
+ reasons: string[];
5267
+ }
5268
+ declare function withdrawFeeFor(amount: bigint): bigint;
5269
+ declare function assessBridgeQuote(q: BridgeQuoteInput): BridgeQuoteAssessment;
5270
+ /** The quote screen, as the user must see it BEFORE any address is shown. */
5271
+ declare function renderAssessment(a: BridgeQuoteAssessment): string;
5272
+
5273
+ /**
5274
+ * Deciding whether a failed shield attempt may be retried.
5275
+ *
5276
+ * This is the most dangerous decision in the flow and the least observable, because it only runs
5277
+ * when something has already gone wrong. Getting it wrong in either direction costs money:
5278
+ *
5279
+ * retry when the deposit actually landed -> a second proof and a second deposit fee, for a
5280
+ * deposit that already happened
5281
+ * refuse when it did not land -> the user is told their funds are unshielded and has
5282
+ * to re-run, which costs a re-run and nothing else
5283
+ *
5284
+ * The asymmetry is the whole design: an unnecessary stop is cheap, a wrongful retry is not. So
5285
+ * anything the evidence cannot explain resolves to "do not retry".
5286
+ *
5287
+ * It lives in the SDK rather than in a CLI script because the shield service will need exactly this
5288
+ * decision, and a second implementation of it would be a second way to lose track of the same money.
5289
+ * It is pure — no chain, no clock — so it can be tested exhaustively, which the CLI version never was.
5290
+ */
5291
+ /**
5292
+ * Failures where retrying only burns another proof: the deposit cannot succeed as constructed, so
5293
+ * a second attempt fails identically and costs another fee to find out.
5294
+ */
5295
+ declare const TERMINAL_FAILURE: RegExp;
5296
+ declare function isTerminalFailure(message: string): boolean;
5297
+ type PostFailureVerdict =
5298
+ /** The receiver's tokens are gone: the deposit transaction landed despite the error. */
5299
+ "landed"
5300
+ /** The balance is untouched: the deposit demonstrably did not consume it. Safe to retry. */
5301
+ | "did-not-land"
5302
+ /** The balance moved by an amount nothing here explains, or could not be read at all. */
5303
+ | "unknown";
5304
+ /**
5305
+ * What the receiver's token balance says about a deposit attempt that threw.
5306
+ *
5307
+ * The deposit transaction moves the receiver's ENTIRE `attempted` balance atomically with the rest
5308
+ * of its instructions, so the balance is a reliable witness: drained to zero means it landed,
5309
+ * unchanged means it did not. Anything else — a partial move, a fresh delivery mid-flight, an
5310
+ * unreadable account — is not something this can interpret, and guessing is exactly the mistake
5311
+ * this function exists to prevent.
5312
+ *
5313
+ * @param attempted what the receiver held when the attempt started
5314
+ * @param after what it holds now, or null if the balance could not be read
5315
+ */
5316
+ declare function classifyPostFailure(attempted: bigint, after: bigint | null): PostFailureVerdict;
5317
+ /** Whether the loop may go again, given what the evidence says. */
5318
+ declare function mayRetry(verdict: PostFailureVerdict, message: string): boolean;
5319
+ /** Linear backoff. Deliberately not exponential: the failures seen here are relay and blockhash
5320
+ * timing, which clear in seconds, and a long tail just strands the user watching a terminal. */
5321
+ declare function retryDelayMs(attempt: number): number;
5322
+ /** Raised in place of the underlying error when the evidence says the deposit landed, or says
5323
+ * nothing this can interpret. The loop stops on it without claiming the funds are unshielded. */
5324
+ declare class DoNotRetry extends Error {
5325
+ constructor(message: string);
5326
+ }
5327
+ interface RetryHooks {
5328
+ /** Called before each wait, so a CLI can say what it is doing and a service can log it. */
5329
+ onRetry?: (attempt: number, delayMs: number, lastError: string) => void;
5330
+ /** Injectable so tests do not actually wait, and a service can use its own scheduler. */
5331
+ sleep?: (ms: number) => Promise<void>;
5332
+ attempts?: number;
5333
+ }
5334
+ /**
5335
+ * Run `attempt` until it succeeds or the evidence says stop.
5336
+ *
5337
+ * The loop is separated from what it runs so it can be tested against injected failures. Its
5338
+ * previous form lived inside a CLI script wired to mainnet constants, which meant the only way to
5339
+ * exercise it was to cause a real failure during a real deposit — so it never was exercised, across
5340
+ * two rounds of changes to it.
5341
+ *
5342
+ * `attempt` is expected to throw `DoNotRetry` when it has already checked chain state and found the
5343
+ * deposit landed, or found something it cannot explain. Everything else is judged by
5344
+ * `isTerminalFailure`.
5345
+ */
5346
+ declare function withShieldRetries<T>(attempt: (attemptNo: number) => Promise<T>, hooks?: RetryHooks): Promise<T>;
5347
+
4671
5348
  /**
4672
5349
  * Cloak SDK - TypeScript SDK for Private Transactions on Solana
4673
5350
  *
@@ -4678,4 +5355,4 @@ declare const VERSION = "0.2.1";
4678
5355
  /** True when scanner supports TransactSwap (tag 1). Check this to verify the correct SDK bundle is loaded. */
4679
5356
  declare const SCANNER_SUPPORTS_TRANSACT_SWAP = true;
4680
5357
 
4681
- export { BUILD_ALLOWS_LOCAL_ENDPOINTS, type BuildRecipientDeliveryNotesParams, CHAIN_NOTE_SALT_BITS, CLOAK_PRODUCTION_RELAY_URL, CLOAK_PROGRAM_ID, type ChainNoteTxType, type CircuitVerificationResult, type CloakConfig, CloakError, type CloakKeyPair, type CloakNote, type CommitmentEntry, type CommitmentsResponse, type CompactChainNote, type ComplianceReport, type ComplianceTxType, type ConfirmSettlementParams, DEFAULT_CIRCUITS_URL, DEFAULT_TRANSACTION_CIRCUITS_URL, DELIVERY_MEMO_TAG, DELIVERY_REGISTRY_SEED, type DeliveredNote, type DepositInstructionParams, type DepositNoteSecrets, type DepositOptions, type DepositResult, type DepositStatus, type DiscoverSwapRefundsOptions, type DiscoveredSwapRefund, EXPECTED_CIRCUIT_HASHES, type EncryptedMetadataBundle, type EncryptedNote$1 as EncryptedNote, type ErrorCategory, type ExpandedSpendKey, type ExternalFeePayerAdapter, FIXED_FEE_LAMPORTS, type Groth16Proof, InsecureRandomnessError, LAMPORTS_PER_SOL, LocalStorageAdapter, type LogLevel, type Logger, MERKLE_TREE_HEIGHT, MIN_DEPOSIT_LAMPORTS, type MasterKey, type MatchChangeNoteParams, type MatchDepositNoteParams, type MatchSwapRefundLeafParams, type MaxLengthArray, MemoryStorageAdapter, type MerkleProof, type MerkleRootResponse, MerkleTree, NATIVE_SOL_MINT, type Network, type NoteData, type OnchainMerkleProof, type ParsedDeliveryCarrier, type PendingDeposit, type PendingWithdrawal, 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_ORIGIN_ALLOWLIST, REQUEST_AUTH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS, type RecipientDeliveryNote, type RecoveredChangeNote, type RecoveredChangeNoteRecord, type RecoveredDepositNote, type RecoveredDepositNoteRecord, type RecoveredSwapRefund, type RelayAuthPreimage, type RelayAuthSigner, RelayInternalError, RelayService, type RelaySubmissionResult, 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 StorageAdapter, type SubmitTransactToRelayArgs, type SwapOptions, type SwapParams, type SwapRefundAuthorization, type SwapResult, TRANSACTION_CIRCUITS_VERSION, TRANSACT_AUTH_FIELDS, TRANSACT_SWAP_AUTH_FIELDS, type TransactOptions, type TransactParams, type TransactRequestBodyParams, type TransactResult, 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, type WalletAdapter, type WalletUtxo, type WithdrawOptions, type WithdrawSubmissionResult, assertDirectSubmissionLanded, assertTransactionCircuitIntegrity, bigintToBytes32$1 as bigintToBytes32, bigintToHex, buildMerkleTree, buildMerkleTreeFromChain, buildMerkleTreeFromRelay, buildRecipientDeliveryNotes, buildRelayAuthPreimage, buildTransactRequestBody, bytesToHex, calculateFee, calculateFeeBigint, calculateRelayFee, canRebuildMerkleTreeFromChain, canonicalJson, chainNoteFromBase64, chainNoteToBase64, classifyRelayError, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, computeChainNoteHash, computeExtDataHash, computeMerkleRoot, computeProofForLatestDeposit, computeProofFromChain, computeSignature, computeSwapRefundCommitment, computeCommitment as computeUtxoCommitment, computeNullifier as computeUtxoNullifier, confirmTransactSettlement, copyNoteToClipboard, createCloakError, createDepositInstruction, createLogger, createRecoverableChangeUtxo, createRecoverableDepositUtxo, createUtxo, createZeroUtxo, decryptCompactChainNote, decryptComplianceMetadataWithMasterKey, decryptTransactionMetadata, deriveChangeNoteBlinding, deriveDepositNoteSecrets, deriveDiversifiedViewingKey, deriveDiversifier, deriveInputNullifierPdas, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, deriveUserCompliancePublicKey, deriveUserComplianceScalar, deriveUtxoKeypairFromSpendKey, deriveViewKey, deriveViewingKeyFromNk, deriveViewingKeyFromSpendKey, deriveViewingKeyFromUtxoPrivateKey, deserializeUtxo, detectNetworkFromRpcUrl, discoverSwapRefunds, downloadNote, encodeDeliveryCarrierMemo, encodeNoteSimple, encodeRecipientDeliveryNote, encryptCompactChainNote, encryptNoteForRecipient, encryptTransactionMetadata, encryptTransactionMetadataBundle, expandSpendKey, explainRelayAuthRejection, exportKeys, exportNote, exportWalletKeys, fetchCommitments, fetchRiskQuoteInstruction, fetchRiskQuoteIx, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, formatAmount, formatComplianceCsv, formatErrorForLogging, formatSol, fullWithdraw, 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, isPlausibleSignature, isReactNative, isRootNotFoundError, isSubmissionOutcomeUnknownResponse, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawAmountSufficient, isWithdrawable, keypairToAdapter, loadPendingDeposits, loadPendingWithdrawals, loadVerifiedCircuitArtifacts, matchChangeNote, matchDepositNote, matchSwapRefundLeaf, openRecipientDeliveryNote, parseAmount, parseDeliveryCarrierMemo, parseError, parseNote, parseRelayErrorResponse, parseRelayErrorSignature, parseTransactionError, partialWithdraw, poseidonHash, preflightCheck, preflightNullifiers, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, proofToBytes, pubkeyToFieldElement, pubkeyToLimbs, randomBytes, randomChangeNoteSalt, randomDepositNoteSalt, randomFieldElement, readMerkleTreeState, recipientDeliveryNoteToBase64, registerViewingKey, removePendingDeposit, removePendingWithdrawal, resolveCircuitsBase, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, scanRecipientDeliveryNotes, scanTransactions, sdkLogger, selectUtxos, sendTransaction, serializeNote, serializeUtxo, setCircuitsPath, setDebugMode, signTransaction, splitTo2Limbs, submitTransactToRelay, sumUtxoAmounts, swapUtxo, swapWithChange, toComplianceReport, transact, transfer, truncate, tryDecryptNote, updateNoteWithDeposit, updatePendingDeposit, updatePendingWithdrawal, bigintToBytes32 as utxoBigintToBytes32, utxoEquals, hexToBigint as utxoHexToBigint, validateDepositParams, validateNote, validateOutputsSum, validateRoot, validateTransfers, validateWalletConnected, validateWithdrawableNote, verifyAllCircuits, verifyCircuitIntegrity, verifyUtxos, waitForRoot, withTiming };
5358
+ export { BRIDGE_ESCROW_LABEL, 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 CommitmentEntry, type CommitmentsResponse, type CompactChainNote, type ComplianceReport, type ComplianceTxType, type ConfirmSettlementParams, 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 EncryptedMetadataBundle, type EncryptedNote$1 as EncryptedNote, type ErrorCategory, type ExpandedSpendKey, type ExternalFeePayerAdapter, FEE_BUDGET, FIXED_FEE_LAMPORTS, type FundingPlan, type Groth16Proof, InsecureRandomnessError, LAMPORTS_PER_SOL, LocalStorageAdapter, type LogLevel, type Logger, 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, NATIVE_SOL_MINT, type Network, type NoteData, 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_ORIGIN_ALLOWLIST, REQUEST_AUTH_MAX_AGE_SECONDS, REQUEST_AUTH_MAX_FUTURE_SKEW_SECONDS, type RecipientDeliveryNote, type RecoveredChangeNote, type RecoveredChangeNoteRecord, type RecoveredDepositNote, type RecoveredDepositNoteRecord, type RecoveredSwapRefund, type RelayAuthPreimage, type RelayAuthSigner, 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 StorageAdapter, type SubmitTransactToRelayArgs, type SwapOptions, type SwapParams, type SwapRefundAuthorization, type SwapResult, TERMINAL_FAILURE, TRANSACTION_CIRCUITS_VERSION, TRANSACT_AUTH_FIELDS, TRANSACT_SWAP_AUTH_FIELDS, type TransactOptions, type TransactParams, type TransactRequestBodyParams, type TransactResult, 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 WalletAdapter, type WalletUtxo, type WithdrawOptions, type WithdrawSubmissionResult, assertDirectSubmissionLanded, assertTransactionCircuitIntegrity, assessBridgeQuote, bigintToBytes32$1 as bigintToBytes32, bigintToHex, buildMerkleTree, buildMerkleTreeFromChain, buildMerkleTreeFromRelay, buildRecipientDeliveryNotes, buildRelayAuthPreimage, buildTransactRequestBody, bytesToHex, calculateFee, calculateFeeBigint, calculateRelayFee, canRebuildMerkleTreeFromChain, canonicalJson, canonicalPayloadString, chainNoteFromBase64, chainNoteToBase64, classifyPostFailure, classifyRelayError, cleanupReceivingAddress, cleanupStalePendingOperations, clearPendingDeposits, clearPendingWithdrawals, cloakBridgeRail, computeChainNoteHash, computeExtDataHash, computeMerkleRoot, computeProofForLatestDeposit, computeProofFromChain, computeSignature, computeSwapRefundCommitment, computeCommitment as computeUtxoCommitment, computeNullifier as computeUtxoNullifier, confirmTransactSettlement, copyNoteToClipboard, createCloakError, createDepositInstruction, createLogger, createRecoverableChangeUtxo, createRecoverableDepositUtxo, createUtxo, createZeroUtxo, decryptCompactChainNote, decryptComplianceMetadataWithMasterKey, decryptTransactionMetadata, depositFromDerivedKey, deriveBridgeReceiver, deriveChangeNoteBlinding, deriveDepositNoteSecrets, deriveDiversifiedViewingKey, deriveDiversifier, deriveFundingTargets, deriveInputNullifierPdas, derivePublicKey, deriveSpendKey, deriveSwapRefundAuthorization, deriveUserCompliancePublicKey, deriveUserComplianceScalar, deriveUtxoKeypairFromSpendKey, deriveViewKey, deriveViewingKeyFromNk, deriveViewingKeyFromSpendKey, deriveViewingKeyFromUtxoPrivateKey, deserializeUtxo, detectNetworkFromRpcUrl, discoverSwapRefunds, downloadNote, encodeDeliveryCarrierMemo, encodeNoteSimple, encodeRecipientDeliveryNote, encryptCompactChainNote, encryptNoteForRecipient, encryptTransactionMetadata, encryptTransactionMetadataBundle, expandSpendKey, explainRelayAuthRejection, exportKeys, exportNote, exportWalletKeys, fetchCommitments, fetchRiskQuoteInstruction, fetchRiskQuoteIx, filterNotesByNetwork, filterWithdrawableNotes, findNoteByCommitment, 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, isPlausibleSignature, isReactNative, isRootNotFoundError, isSubmissionOutcomeUnknownResponse, isTerminalFailure, isValidHex, isValidRpcUrl, isValidSolanaAddress, isWithdrawAmountSufficient, isWithdrawable, keypairToAdapter, listBridgeDeposits, loadPendingDeposits, loadPendingWithdrawals, loadVerifiedCircuitArtifacts, matchChangeNote, matchDepositNote, matchSwapRefundLeaf, mayRetry, openRecipientDeliveryNote, parseAmount, parseDeliveryCarrierMemo, parseError, parseNote, parseRelayErrorResponse, parseRelayErrorSignature, parseTransactionError, partialWithdraw, poseidonHash, preflightCheck, preflightNullifiers, prepareEncryptedOutput, prepareEncryptedOutputForRecipient, proofToBytes, pubkeyToFieldElement, pubkeyToLimbs, randomBytes, randomChangeNoteSalt, randomDepositNoteSalt, randomFieldElement, readMerkleTreeState, readRent, recipientDeliveryNoteToBase64, registerViewingKey, removePendingDeposit, removePendingWithdrawal, renderAssessment, resolveCircuitsBase, retryDelayMs, savePendingDeposit, savePendingWithdrawal, scanNotesForWallet, scanRecipientDeliveryNotes, scanTransactions, sdkLogger, selectUtxos, sendTransaction, serializeNote, serializeUtxo, setCircuitsPath, setDebugMode, signTransaction, splitTo2Limbs, submitTransactToRelay, sumUtxoAmounts, swapUtxo, swapWithChange, toComplianceReport, transact, 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 };