satelliteEVMAdapter()
satelliteEVMAdapter(
config,chains):SatelliteAdapter<ConnectorEVM,EVMConnection>
Defined in: satellite-evm/src/adapters/evmAdapter.ts:87
Creates the EVM adapter for the Satellite Connect store (createSatelliteConnectStore from @tuwaio/satellite-core
or SatelliteConnectProvider from @tuwaio/satellite-react). It implements SatelliteAdapter with @wagmi/core:
getConnectorsreturns the connectors ofconfig. A connector matches aconnectorTypesuch as"evm:metamask"throughformatConnectorNamefrom@tuwaio/orbit-core(for example, theSafeconnector is"evm:safe").watchConnectorscallsonChange(with no arguments) on every change of the connectors ofconfig, through wagmi’swatchConnectors: when wagmi adds the installed EIP-6963 wallets while a config created withssr: trueis hydrated, when a wallet announces itself later, and when other code changes the connectors. It subscribes to the connectors store ofconfiguntil the returned function is called.connectruns wagmi’sconnectwith the requested chain and returns an EVMConnection: the account (the zero address if wagmi reports none), the chain (1if unknown), the first default RPC URL of the chain, the connector icon and asignMessagethat signs with wagmi’ssignMessage. An injected wallet shows its connect prompt (wagmi requestswallet_requestPermissions, theneth_requestAccounts). A wallet that wagmi already holds in this page (an earlier store on the same config connected it, orWagmiProviderrestored it) is taken over without a request: it becomes wagmi’s current connection, and wagmi’sswitchChainasks it to move to the requested chain (when it declines, the connection stays on its chain).reconnectrestores a wallet without a prompt, forinitializeAutoConnect: a wallet that wagmi already holds in this page is taken over as byconnect; otherwise, when the connector reports authorized accounts (eth_accountsfor injected wallets), wagmi’sconnectruns withisReconnecting, so the connector reads those accounts instead of asking for them. It resolves toundefinedwhen the wallet reports no accounts (locked, or the site was disconnected in the wallet). When the wallet is on another chain than the requested one, wagmi’sswitchChainasks it to switch; when it declines, the connection stays on its chain.getLiveConnectionslists, as EVMConnection objects, the live wagmi connections that this adapter object opened or took over (withconnectorreconnect) and has not disconnected. The record of their connectors lives in memory, in the adapter object. Connections that other code opened or restored on the same config (for exampleWagmiProvider, or a store with another adapter object) are not listed.disconnectdisconnects the given connection with wagmi’sdisconnect. Without a connection (or with one that is not connected), it disconnects only the live connections ofgetLiveConnections(of that connection’s connector type), never a connector without a connection or a connection opened by other code: wagmi’s injected connector sendswallet_revokePermissionson every disconnect, and wallets such as MetaMask revoke the site’s permission for every tab of the origin. Two stores on one wagmi config with their own adapter objects do not close each other’s wallets this way (a wallet both of them connected is still one wagmi connection).checkAndSwitchNetworkasks the wallet to switch chains withcheckAndSwitchChainfrom@tuwaio/orbit-evm.getBalancereads the native balance through the wagmi transports and formats it with the chain’s decimals.getExplorerUrl(url?, chainId?)joinsurlto the block explorer ofchainId(looked up inchains, then inconfig), or of the connected chain whenchainIdis omitted. It returnsundefinedwhen the chain has no explorer.getName,getAvatarandgetAddressresolve ENS names on Ethereum Mainnet with@tuwaio/orbit-evm, which caches the results in memory.checkIsContractAddressis checkIsWalletAddressContract;getSafeConnectorChainIdreturns the chain of theSafeconnector;switchConnectionruns wagmi’sswitchConnection.
Parameters
config
Config
The wagmi config of the app.
chains
readonly [Chain, Chain]
The app chains. ENS lookups use the Ethereum Mainnet entry of this list (its default RPC URL), or
viem’s mainnet when it is missing.
Returns
SatelliteAdapter<ConnectorEVM, EVMConnection>
The EVM adapter.
Throws
Satellite EVM adapter requires a wagmi config object. when config is missing.
Example
import { satelliteEVMAdapter } from '@tuwaio/satellite-evm';
import { createConfig, http, injected } from '@wagmi/core';
import { mainnet, sepolia } from 'viem/chains';
const chains = [mainnet, sepolia] as const;
const wagmiConfig = createConfig({
chains,
connectors: [injected()],
transports: { [mainnet.id]: http(), [sepolia.id]: http() },
});
export const evmAdapter = satelliteEVMAdapter(wagmiConfig, chains);Last updated on