PortfolioBackend
@totemsdk/realtime / PortfolioBackend
Interface: PortfolioBackend
Plug-in interface for the portfolio data source.
Implement this to use any chain provider — LookupNode, a raw Minima RPC, a custom indexer — instead of the default Axia hosted API.
Examples
— sovereign LookupNode
import { LookupBackend } from '@totemsdk/realtime';
import { connectLookupNode } from '@totemsdk/lookup-client';
const client = await connectLookupNode({ hyperswarmTopic: 'abc...' });
const manager = createPortfolioStreamManager(deps, {
backend: new LookupBackend(client),
});
— direct Minima node (polling)
import { MinimaRpcBackend } from '@totemsdk/realtime';
import { createMinimaRpcClient } from '@totemsdk/minima-rpc';
const rpc = createMinimaRpcClient({ host: 'localhost', port: 9005 });
const manager = createPortfolioStreamManager(deps, {
backend: new MinimaRpcBackend(rpc),
});
Properties
supportsPush?
readonlyoptionalsupportsPush?:boolean
Whether this backend delivers push updates via subscribe().
If false or absent the manager will call getPortfolio() on a timer.
Methods
getPortfolio()
getPortfolio(
address):Promise<PortfolioEntry[]>
Fetch the current portfolio for one address. Called for the initial snapshot and for poll cycles on non-push backends.
Parameters
address
string
Returns
Promise<PortfolioEntry[]>
subscribe()?
optionalsubscribe(addresses,onUpdate):Promise<BackendUnsubscribe>
(Optional) Subscribe to real-time updates for a set of addresses.
Only called when supportsPush is true.
Must call onUpdate(address, entries) whenever the portfolio changes.
Returns an unsubscribe function to clean up listeners and watches.
Parameters
addresses
string[]
onUpdate
(address, entries) => void
Returns
Promise<BackendUnsubscribe>