ChainSwitchRequest class
Every network switch comes through this single request type —
whether the dApp explicitly asked for a specific chain
(wallet_switchEthereumChain) or triggered it implicitly by
calling an action method on a chain family that doesn't match
the wallet's current network.
Two shapes distinguished by which fields are populated:
Pre-specified target (dApp named a chain): targetNetwork is non-null. Render a simple confirm sheet ("Switch to Polygon?"). When isNewNetwork is true, the target isn't in the wallet yet and approval implies Add + Switch — render "Add and switch to Polygon?" with appropriate warning copy. candidateNetworks is empty in this shape.
Picker (cross-family action method): targetNetwork null, candidateNetworks populated. Render a picker so the user chooses one.
candidateAccounts is always populated (accounts whose curve is compatible with requestedFamily); the user always picks an account to bind to the dApp on the chosen chain.
Approve:
// Pre-specified target — Network can be omitted:
await client.requests.approve(
req.id,
accounts: [accountId],
);
// Picker — Network is required:
await client.requests.approve(
req.id,
network: pickedNetwork.id,
accounts: [pickedAccount.id],
);
On approval, libwallet atomically: saves the network if new,
calls SetCurrent, and connects the dApp to the chosen account.
Hosts do NOT need to call client.networks.setCurrent(...)
separately.
- Inheritance
-
- Object
- PendingRequest
- ChainSwitchRequest
Properties
- account → String?
-
Account ID the dApp is signing as, if specified.
finalinherited
-
candidateAccounts
→ List<
Account> -
Accounts whose key curve is compatible with requestedFamily
(secp256k1 for EVM/Bitcoin, ed25519 for Solana). Always
populated; the user picks one.
no setter
-
candidateNetworks
→ List<
Network> -
Networks of requestedFamily the user can choose from when
targetNetwork is null (picker mode). Empty in confirm mode.
no setter
- created → DateTime?
-
Timestamp when the request was created.
finalinherited
- currentNetwork → Network?
-
The wallet's currently active network (context for the UI).
Null when the request payload is malformed.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- host → String
-
Hostname of the dApp that initiated the request.
finalinherited
- id → String
-
Unique request identifier.
finalinherited
- isAccepted → bool
-
no setterinherited
- isNewNetwork → bool
-
True when targetNetwork is set and not yet saved in the
wallet — approval implies Add + Switch. Render with
appropriate warning copy (user is agreeing to both persist
AND switch to a brand-new chain).
no setter
- isPending → bool
-
no setterinherited
- isRejected → bool
-
no setterinherited
- isTimedOut → bool
-
no setterinherited
- rawValue → dynamic
-
Raw value payload as delivered by Go. Kept untyped on the base class
because each request type has its own shape; concrete subtypes expose
typed accessors. Consumers generally don't need to touch this.
finalinherited
- requestedFamily → String
-
Which chain family the dApp's method requires:
"evm"/"solana"/"bitcoin".no setter - requestedMethod → String
-
The Web3 method that triggered the prompt (e.g.
"eth_sendTransaction","wallet_switchEthereumChain","solana_signTransaction"). Useful for UI copy.no setter - result → dynamic
-
Result payload once the request has been approved (e.g. signature,
tx hash). Null while pending. Shape depends on the request type;
subtypes may expose typed getters.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → String
-
Current status:
pending,accepted,rejected, ortimedout.finalinherited - targetNetwork → Network?
-
Set when the dApp named a specific chain
(
wallet_switchEthereumChain). UI shows a single-option confirm sheet against this network. Null in picker mode.no setter - transaction → Transaction?
-
EVM transaction attached to the request, if this is a
sign-type request representingeth_sendTransaction. Null for other types.finalinherited - type → String
-
Wire-level type discriminator (e.g.
connect,personal_sign,solana_sign_transaction). Exposed for logging / telemetry; for behaviour, pattern-match on the subtype instead.no setteroverride - updated → DateTime?
-
Timestamp when the request was last updated.
finalinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited