NetworksTable
Defined in: table.ts:84
The wallet’s networks and their endpoints: the shipped catalog and testnets plus what the user
and sites added. Storage holds only the changes, so app updates with new endpoints reach every
install. Call load() once at start; the …Sync readers answer from memory after that.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NetworksTable(
storage,builtins?):NetworksTable
Defined in: table.ts:90
Parameters
Section titled “Parameters”storage
Section titled “storage”builtins?
Section titled “builtins?”readonly Network[] = BUILTIN_NETWORKS
Returns
Section titled “Returns”NetworksTable
Properties
Section titled “Properties”builtins
Section titled “builtins”
readonlybuiltins: readonlyNetwork[] =BUILTIN_NETWORKS
Defined in: table.ts:90
Accessors
Section titled “Accessors”loaded
Section titled “loaded”Get Signature
Section titled “Get Signature”get loaded():
boolean
Defined in: table.ts:98
Whether load() has completed — before that listSync / getSync answer builtin-only and the sync endpoint readers throw.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”add(
network):Promise<void>
Defined in: table.ts:188
Add a custom network. Refused for a builtin caip2 (prepend RPCs with addRpc instead) and for RPCs outside the URL policy.
Parameters
Section titled “Parameters”network
Section titled “network”Returns
Section titled “Returns”Promise<void>
addRpc()
Section titled “addRpc()”addRpc(
caip2,url):Promise<void>
Defined in: table.ts:226
Add a user RPC after the existing user RPCs, before the shipped list. Check it with
checkRpcUrl and verifyNetwork first.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”NetworkError unknown-network, or url-policy for a URL the policy refuses.
allowHttpLocal()
Section titled “allowHttpLocal()”allowHttpLocal():
Promise<boolean>
Defined in: table.ts:170
Whether http:// RPCs on private addresses are accepted.
Returns
Section titled “Returns”Promise<boolean>
allowHttpLocalSync()
Section titled “allowHttpLocalSync()”allowHttpLocalSync():
boolean
Defined in: table.ts:175
Same as allowHttpLocal() from memory.
Returns
Section titled “Returns”boolean
enable()
Section titled “enable()”enable(
caip2,enabled):Promise<void>
Defined in: table.ts:249
Switch a network on or off (testnets ship off).
Parameters
Section titled “Parameters”string
enabled
Section titled “enabled”boolean
Returns
Section titled “Returns”Promise<void>
get(
caip2):Promise<NetworkEntry|null>
Defined in: table.ts:126
One network, or null when unknown.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<NetworkEntry | null>
getSync()
Section titled “getSync()”getSync(
caip2):NetworkEntry|null
Defined in: table.ts:131
Same as get() from memory.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”NetworkEntry | null
list()
Section titled “list()”list():
Promise<NetworkEntry[]>
Defined in: table.ts:115
Every network with its effective endpoints and issues.
Returns
Section titled “Returns”Promise<NetworkEntry[]>
listSync()
Section titled “listSync()”listSync():
NetworkEntry[]
Defined in: table.ts:121
Same as list() from memory; builtin table only before load().
Returns
Section titled “Returns”load()
Section titled “load()”load():
Promise<void>
Defined in: table.ts:93
Read the stored state once; later calls answer from memory. Safe to call many times.
Returns
Section titled “Returns”Promise<void>
markRpc()
Section titled “markRpc()”markRpc(
caip2,url,result,now?):Promise<void>
Defined in: table.ts:264
Record a verification result for one user RPC: a failure parks the URL (with the reason), a pass clears it.
Parameters
Section titled “Parameters”string
string
result
Section titled “result”number = ...
Returns
Section titled “Returns”Promise<void>
remove()
Section titled “remove()”remove(
caip2):Promise<void>
Defined in: table.ts:205
Remove a custom network. Builtins cannot be removed (disable them instead).
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<void>
removeRpc()
Section titled “removeRpc()”removeRpc(
caip2,url):Promise<void>
Defined in: table.ts:240
Remove a user RPC.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”NetworkError unknown-network, or last-rpc for the last RPC of a custom
network.
reset()
Section titled “reset()”reset():
Promise<void>
Defined in: table.ts:274
Forget everything the user changed.
Returns
Section titled “Returns”Promise<void>
rpcUrlsFor()
Section titled “rpcUrlsFor()”rpcUrlsFor(
caip2):Promise<string[]>
Defined in: table.ts:136
Endpoints to try, in order: healthy user RPCs, then the builtin list unless onlyOwnRpc. Empty for an unknown network.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<string[]>
rpcUrlsForSync()
Section titled “rpcUrlsForSync()”rpcUrlsForSync(
caip2):string[]
Defined in: table.ts:146
rpcUrlsFor from memory — what a sync consumer (a viem client factory) reads. Throws
NetworkError('not-loaded') before load(): the builtin list would ignore the user’s own RPCs
and their onlyOwnRpc choice.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string[]
setAllowHttpLocal()
Section titled “setAllowHttpLocal()”setAllowHttpLocal(
v):Promise<void>
Defined in: table.ts:183
Turn the http:// on private addresses setting on or off.
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”Promise<void>
setBalancesViaOwnRpc()
Section titled “setBalancesViaOwnRpc()”setBalancesViaOwnRpc(
caip2,balancesViaOwnRpc):Promise<void>
Defined in: table.ts:259
Read balances over the user’s RPC instead of the app’s server.
Parameters
Section titled “Parameters”string
balancesViaOwnRpc
Section titled “balancesViaOwnRpc”boolean
Returns
Section titled “Returns”Promise<void>
setOnlyOwnRpc()
Section titled “setOnlyOwnRpc()”setOnlyOwnRpc(
caip2,onlyOwnRpc):Promise<void>
Defined in: table.ts:254
Use only the user’s RPCs for this network, dropping the shipped fallback.
Parameters
Section titled “Parameters”string
onlyOwnRpc
Section titled “onlyOwnRpc”boolean
Returns
Section titled “Returns”Promise<void>
setRpcs()
Section titled “setRpcs()”setRpcs(
caip2,rpcs):Promise<void>
Defined in: table.ts:216
Replace the user’s RPC list for a network (prepended to the builtin list; the whole list for a custom network).
Parameters
Section titled “Parameters”string
readonly string[]
Returns
Section titled “Returns”Promise<void>
subscribe()
Section titled “subscribe()”subscribe(
fn): () =>void
Defined in: table.ts:107
Fires after every write (UI refresh).
Parameters
Section titled “Parameters”() => void
Returns
Section titled “Returns”() => void
usesUserRpc()
Section titled “usesUserRpc()”usesUserRpc(
caip2):Promise<boolean>
Defined in: table.ts:164
Same as usesUserRpcSync(), after loading.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<boolean>
usesUserRpcSync()
Section titled “usesUserRpcSync()”usesUserRpcSync(
caip2):boolean
Defined in: table.ts:156
Whether the first endpoint a consumer will use is user- or site-supplied (→ “Custom RPC — simulation not trusted”). Throws before load().
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean