Balances, history and sync
The three functions that bring the device up to date and read the private balance and past payments from it.
The private balance and its history live on the user's device. A sync brings them up to date, and the reads return what it left. Balances, History and Sync walk through each.
readBalances
Use it whenever you show the private balance. It is cheap enough to call after every sync.
function readBalances(
session: NimbusSession,
_args?: Readonly<Record<string, never>>,
options?: { readonly zone?: number },
): Promise<readonly Balance[]>;Types used: NimbusSession, Balance
Example
import { } from "@umbra/nimbus-solana-web";
import type { NimbusSession } from "@umbra/nimbus-solana-web";
declare const : NimbusSession;
const = await (, {});
const = .(() => . === "available");Parameters
Prop
Type
Returns
Promise<readonly Balance[]>
The balances.
NimbusSdkError with reason "unreadable" when the store was replaced while it was
read or cannot be read back; "unsupported-browser" when the browser refuses it.
Reads the session's balances in one zone from its note store: one entry per mint and state, in the order of the mints' identifiers.
Reads only what syncNoteStore has synced; nothing is fetched. A session whose
store holds nothing yet reads as no balances.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/reads.ts.
readHistory
Use it to show the user's past payments, one page at a time.
function readHistory(
session: NimbusSession,
_args?: Readonly<Record<string, never>>,
options?: { readonly limit?: number; readonly after?: HistoryPosition },
): Promise<HistoryPage>;Types used: NimbusSession, HistoryPosition, HistoryPage
Example
import { } from "@umbra/nimbus-solana-web";
import type { NimbusSession } from "@umbra/nimbus-solana-web";
declare const : NimbusSession;
const = await (, {}, { : 10 });
if (.. === "more") {
await (, {}, { : .., : 10 });
}Parameters
Prop
Type
Returns
Promise<HistoryPage>
The page.
NimbusSdkError with reason "misconfigured" when limit is not a whole number
from 1 to 100, before the store is opened; "unreadable" when the store was replaced while it
was read or cannot be read back; "unsupported-browser" when the browser refuses it.
Reads one page of the session's history from its note store, newest first: each transaction with the identity's notes it created and spent, and its record when it is the session's.
Reads only what syncNoteStore has synced; nothing is fetched. A page's
coverage names, per pool, the slot its history is complete through: nothing above it is shown
as nothing having happened. A session whose store holds nothing yet reads as an empty page.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/reads.ts.
syncNoteStore
Use it before you read the balance or history, and on a timer while your app is open.
function syncNoteStore(
session: NimbusSession,
_args?: Readonly<Record<string, never>>,
options?: SyncNoteStoreOptions,
): Promise<NoteStoreSyncResult>;Types used: NimbusSession, SyncNoteStoreOptions, NoteStoreSyncResult
Example
import { } from "@umbra/nimbus-solana-web";
import type { NimbusSession } from "@umbra/nimbus-solana-web";
declare const : NimbusSession;
const = await (, {}, {
: () => {
.(., .);
},
});Parameters
Prop
Type
Returns
Promise<NoteStoreSyncResult>
ingested, unregistered, or unavailable with the step the store could not finish.
ingested is caughtUp unless maxRounds ran out first.
NimbusSdkError with reason "misconfigured" when maxRounds is not a whole
number of at least 1 or pageRows is not a whole number from 1 to 1000, before anything is
fetched or read; "service-unavailable" when the indexer or the RPC cannot be reached;
"unreadable" when either answers what cannot be read, or the store was replaced while it was
read; "unsupported-browser" when the browser refuses the store.
signal's reason once it aborts, between rounds.
Syncs the session's note store: the pools' accounts and counters at the confirmed slot, then
each followed pool's notes, spends, records and registrations from the indexer, a page of each
per round, until every stream is caught up, or maxRounds rounds when given.
Notes sealed to the identity become its balance; spends retire its notes; records become its history; its registration row in a pool lets it spend from that pool. Every row is checked against its stream before it is taken. A store with no birthday, which an identity that has not registered through it has, is left untouched. Last, a spend whose tab stopped before sending anything, its lock no longer held by any tab of this origin, is released, so its notes are available again; a browser that cannot list its locks skips that step.
Generated from the TSDoc in sdks/typescript/nimbus-solana-web/src/reads.ts.
Last updated