Deposit
The four functions a deposit uses, from creating its context to refunding what an older wallet left behind.
A deposit runs in a context made from the session. Deposit walks through the flow, and Pending and stranded deposits covers what can be left over.
createDepositContext
Create one from the session before you deposit. resolvePendingDeposit and refundStrandedDeposit
take the same kind of context.
function createDepositContext(
session: NimbusSession,
options?: NimbusContextOptions,
): Promise<DepositContext>;Types used: NimbusSession, NimbusContextOptions, DepositContext
Example
import { } from "@umbra/nimbus-solana-web";
import type { NimbusSession } from "@umbra/nimbus-solana-web";
declare const : NimbusSession;
const = await (, { : 1 });Parameters
Prop
Type
Returns
Promise<DepositContext>
The context.
NimbusSdkError with reason "misconfigured" when an option is out of range or no
pool is open; "service-unavailable" or "unreadable" when the RPC cannot be read.
Creates the context a session deposits, refunds a stranded deposit and resolves a pending deposit in.
Without options.poolIndex the pools' accounts are read from the RPC once, and the highest open
pool is chosen; the nodes and guardian cluster default to the cluster's preset.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/contexts.ts.
deposit
Use it to move tokens from the connected wallet into a private balance, the user's own or another registered user's.
function deposit(
context: DepositContext,
args: {
readonly mint: Address;
readonly amount: bigint;
readonly recipient: Address;
},
options?: DepositOptions,
): Promise<DepositResult>;Types used: DepositContext, DepositOptions, DepositResult
Example
import { , } from "@umbra/nimbus-solana-web";
import type { NimbusSession } from "@umbra/nimbus-solana-web";
import type { } from "@solana/kit";
declare const : NimbusSession;
declare const : ;
const = await (await (), {
: 1_000_000n,
,
: .,
});Parameters
Prop
Type
Returns
Promise<DepositResult>
submitted with how the deposit was funded and where its transaction ended up, which
resolvePendingDeposit follows when that is unknown; declined when the wallet
declined to sign; store-refused, intent-refused or attempt-refused when the note store
would not take the deposit; and, at version 0 only, funding-failed, funding-unknown or
deposit-unsendable when the funding transaction did not land or the deposit could not follow
it. Nothing was deposited unless a submitted result's transaction landed.
NimbusSdkError with reason "misconfigured" when an address is not base58 or
no prover worker or committee endpoint was configured; "service-unavailable" or
"unreadable" when a service or the RPC cannot answer, and "unreadable" too when the note
store cannot be synced before it starts; "unauthorized" when a gateway service
refuses the session's gateway token or the session has none; "dependency-nonconforming" when
a proving key or the prover breaks its contract; "wallet-unsupported" when the wallet fails;
"recipient-unregistered" when the context API answers that recipient has no registration
in the pool, and "account-unregistered" when it answers that the session's identity has
none, each before the wallet is asked to sign; NimbusSolanaFlowError when the protocol
refuses the deposit, with reason "fee-payer-unfunded" when the connected wallet has no
account or too few lamports for the transaction it pays for (at version 0, the funding):
its fee, the SOL it moves, the rent of the token account it creates and its own rent-exempt
minimum, raised before any proving key is downloaded or the committee is asked.
Deposits amount of mint from the connected wallet into the context's pool, as a note for
recipient, a registered identity's wallet address: the session's own, or another's.
First syncs the note store until it is caught up, unless sync: false. The context API resolves
the recipient to its identity and the key the note is sealed to. The committee endorses, the
deposit is proved, the wallet signs once (twice at version 0) and the transaction is sent and
followed to commitment.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/flows.ts.
resolvePendingDeposit
Use it when a deposit's submission came back unknown, to learn whether it landed.
function resolvePendingDeposit(
context: DepositContext,
args: { readonly submission: DepositSubmission },
_options?: Readonly<Record<string, never>>,
): Promise<PendingDepositResolutionResult>;Types used: DepositContext, DepositSubmission, PendingDepositResolutionResult
Example
import { } from "@umbra/nimbus-solana-web";
import type { DepositContext, } from "@umbra/nimbus-solana-web";
declare const : DepositContext;
declare const : ;
if (. === "submitted" && ... === "unknown") {
await (, { : . });
}Parameters
Prop
Type
Returns
Promise<PendingDepositResolutionResult>
landed with its slot; failed or expired, nothing deposited, with the store's
answers to the failure and to abandoning the deposit's intent; unknown when the wait ended
first, its notes still held; or store-refused when the note store would not open.
NimbusSdkError with reason "misconfigured" when the submission's outcome was
not unknown, before anything is fetched: one that landed, failed, expired or was refused is
settled already; "service-unavailable" or "unreadable" when the RPC or the store cannot
answer.
Waits for a deposit whose outcome was unknown to land, fail or expire at the note store's
finality, confirmed, and tells the note store, which releases a failed or expired deposit's
notes.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/flows.ts.
refundStrandedDeposit
Use it to return funds a version 0 deposit left halfway, once every deposit of that token has settled.
function refundStrandedDeposit(
context: DepositContext,
args: { readonly mint: Address },
options?: StrandedDepositRefundOptions,
): Promise<StrandedDepositRefundResult>;Types used: DepositContext, StrandedDepositRefundOptions, StrandedDepositRefundResult
Example
import { , } from "@umbra/nimbus-solana-web";
import type { NimbusSession } from "@umbra/nimbus-solana-web";
import type { } from "@solana/kit";
declare const : NimbusSession;
declare const : ;
const = await (await (), { });Parameters
Prop
Type
Returns
Promise<StrandedDepositRefundResult>
nothing-held when the platform wallet holds nothing of the mint and no lamports;
declined when the wallet declined to sign; or submitted with where the transaction ended
up, which returned the value only when it landed.
NimbusSdkError with reason "misconfigured" when the mint is not base58;
"service-unavailable" or "unreadable" when the RPC cannot answer; "wallet-unsupported"
when the wallet fails; NimbusSolanaFlowError with reason "mint-unsupported" when the
mint is not one, "fee-payer-unfunded" when the connected wallet has no account or too few
lamports to pay the refund's fee, before the wallet is asked to sign, or
"transaction-unsendable" or "transaction-altered" when the refund cannot be sent or the
wallet alters it.
Returns what the session's platform wallet holds of mint to the connected wallet: value a
version 0 deposit's funding left there when the deposit did not land.
Run it only once every deposit of the mint has settled: it returns what the platform wallet holds when it is prepared. The connected wallet signs and pays; the platform wallet signs as the owner of what moves.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/flows.ts.
Last updated