Create a runtime API UniversalDividendApi_account_balances to retrieve total and transferable account balances
The “balance” of an account is more complex than it first appears.
In Duniter, for example, there may be unclaimed UDs that aren’t included in the “free” balance but are spendable if wrapped in a batched call [claim_uds, transfer]
. Substrate itself adds further complexity with concepts like the “existential deposit” and “reserved” balance.
All of this makes it difficult for wallets and other applications to display a single, clear balance to the user.
I propose adding a new runtime API, UniversalDividendApi_account_balances
, which returns an object containing:
{
/// The total amount of funds for which the user is the ultimate beneficial owner.
/// Includes funds that may not be transferable (e.g., reserved balance, existential deposit).
total: number,
/// The maximum amount of funds that can be successfully withdrawn or transferred
/// (includes unclaimed UDs).
transferable: number,
/// The total amount of unclaimed UDs (accounts for any re-evaluations of UDs).
unclaim_amount: number
}
Presentation to the User
- Default view: show the
total
balance, since it represents what the user owns. - On-demand detail: reveal
transferable
only when explicitly requested (for example, via a long-press on the balance component). - Advanced users: expose
unclaim_amount
in a technical or developer mode; it should remain hidden from regular users.