Skip to content

refreshBalances

Re-sync and persist an account's shielded balances.

Owns the state-store + event-emitter choreography: flip state.scan, emit balance-refresh-*, and guard re-entrancy with a per-accountId lock. The actual work delegates to syncNotes, which folds the notes-tree delta, discovers owned notes locally (WASM-Core ECDH), reconciles spends, and writes balance entries + tx history through config.storage for every active aggregator network. A wallet with no such network is a graceful no-op.

Import

ts
import { refreshBalances } from "@0xcurvy/curvy-sdk/actions";

Usage

ts
await refreshBalances();               // active account
await refreshBalances({ accountId });   // explicit account

Signature

ts
function refreshBalances(parameters?: RefreshBalancesParameters): Promise<void>

Returns

Promise<void>

The action resolves or returns the value shown in the signature.

Parameters

signal

  • Type: AbortSignal
  • Required: no

An abort signal used to cancel the refresh between network and paging operations.

ts
await refreshBalances({
  signal, 
});

silent

  • Type: boolean
  • Required: no

Whether to suppress balance-refresh lifecycle events for this refresh.

ts
await refreshBalances({
  silent: true, 
});

accountId

  • Type: string
  • Required: no

The account whose shielded balances should be refreshed. Defaults to the active account.

ts
await refreshBalances({
  accountId, 
});

config

  • Type: CurvyConfig
  • Required: no

Curvy config to use. Defaults to the ambient config.

ts
await refreshBalances({
  config, 
});

Errors

Errors from config resolution and the underlying SDK operation are propagated to the caller.

  • Querying balances guide
  • getBalances — Get an account's shielded balances from storage, optionally refreshing first.
  • getScanProgress — Read the current balance-scan progress from 0 to 100.
  • pauseBalanceRefresh — Pause new balance refreshes for an account.
  • resumeBalanceRefresh — Allow balance refreshes for an account after a matching pause.
  • syncNotes — Run one notes-tree sync pass per network: pull the indexer delta, discover owned notes, reconcile spends, verify the assembled root against a DIRECT chain read, persist, and apply the account-facing effects (balance entries + tx history).

Source

packages/@0xcurvy/sdk/src/actions/balances/refreshBalances.ts