accounts
Version:
Tempo Accounts SDK
53 lines • 1.92 kB
TypeScript
import type { Address } from 'viem';
import type * as Kv from '../Kv.js';
/** A single tokenlist entry. */
export type Token = {
/** Token address. */
address: Address;
/** Token decimals. */
decimals: number;
/** Token logo URI. */
logoUri?: string | undefined;
/** Token name. */
name: string;
/** Token symbol. */
symbol: string;
};
/**
* Fetches the verified tokenlist for `chainId`. Reads through `kv` so
* concurrent callers in the same scope share a single upstream request,
* and so independent handlers (e.g. `Handler.relay` + `Handler.exchange`)
* reuse the same KV cache key.
*
* Returns an empty list on any non-OK response — callers should fall back
* to chain-supplied behavior rather than treating an empty list as fatal.
*
* @param chainId - Chain id to fetch the tokenlist for.
* @param kv - Kv used to cache responses across requests.
* @param options - Options.
* @returns Tokens for the chain.
*/
export declare function fetch(chainId: number, kv: Kv.Kv, options?: fetch.Options): Promise<readonly Token[]>;
export declare namespace fetch {
/** Options for `fetch()`. */
type Options = {
/**
* Base URL of the tokenlist service.
* @default 'https://tokenlist.tempo.xyz'
*/
baseUrl?: string | undefined;
/**
* TTL in seconds for the cached response.
* @default 600 (10 minutes)
*/
cacheTtl?: number | undefined;
/**
* Override resolver. When provided, the cache hit path is unchanged but
* cache misses route through this function instead of fetching the
* default `tokenlist.tempo.xyz` URL. Useful for tests or for vendoring
* a curated list per app.
*/
resolver?: ((chainId: number) => readonly Token[] | Promise<readonly Token[]>) | undefined;
};
}
//# sourceMappingURL=tokenlist.d.ts.map