satelliteSolanaAdapter()
satelliteSolanaAdapter(
params):SatelliteAdapter<UiWallet,SolanaConnection>
Defined in: satellite-solana/src/adapters/solanaAdapter.ts:77
Creates the Solana adapter for the Satellite Connect store (createSatelliteConnectStore from
@tuwaio/satellite-core or SatelliteConnectProvider from @tuwaio/satellite-react). It implements
SatelliteAdapter with the Wallet Standard and @solana/kit:
getConnectorsreturns the wallets ofgetAvailableSolanaConnectorsfrom@tuwaio/orbit-solana(registered Wallet Standard wallets with the Solana features Satellite needs). A wallet matches aconnectorTypesuch as"solana:phantom"throughformatConnectorNamefrom@tuwaio/orbit-core.watchConnectorscallsonChange(with no arguments) when a Wallet Standard wallet registers or unregisters, throughwatchAvailableSolanaConnectorsfrom@tuwaio/orbit-solana: an extension that registers its wallet after the page loads, or a wallet enabled while the page is open. It subscribes to theregisterandunregisterevents of the Wallet Standard registry (getWallets()from@wallet-standard/app) until the returned function is called, and to nothing on the server (nowindow). It also runs for wallets thatgetConnectorsleaves out, and does not follow thechangeevents of the wallets themselves.connectasks the wallet to connect (standard:connect) and returns a SolanaConnection: the first account, the cluster moniker of the requested chain (the genesis-hash chain ID"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1","solana:devnet"and"devnet"all become"devnet"), the RPC URL of that cluster fromrpcUrls, the wallet icon, the Wallet Standard handles and asignMessagecreated with createSolanaMessageSigner. WhenrpcUrlshas no URL for the cluster,getRpcUrlForClusterfrom@tuwaio/orbit-solanareturns the public endpoint of that cluster (the mainnet-beta one forlocalnet, and for every cluster with@tuwaio/orbit-solana0.3.1 and earlier).reconnectrestores a wallet without a prompt, forinitializeAutoConnect:standard:connectwithsilent: truereturns the accounts that already authorize the app, and the connection is built as byconnect. It resolves toundefinedwhen the wallet returns no accounts or rejects (Phantom rejects a silent connect when the app is not trusted).getLiveConnectionslists the connections this adapter opened (withconnectorreconnect) and has not disconnected. The record lives in memory, in the adapter object.disconnectdisconnects the wallet of the given connection, or, without a connection, only the wallets ofgetLiveConnections(standard:disconnect). A wallet that has accounts because other code or another store of the page connected it is never disconnected.checkAndSwitchNetworkmakes no wallet request (Solana wallets have no network switch): it sets the connection’schainIdandrpcURLto the new cluster, and does nothing when the requested chain is the current cluster in another form.getBalancereads the balance withgetBalanceover RPC and returns it in SOL.getExplorerUrl(url?, chainId?)builds a Solana Explorer link (explorer.solana.com).getNameandgetAvatarresolve SNS names and avatars with@tuwaio/orbit-solana(Bonfida APIs, cached in memory);getNamereturns the address when there is no name. There is nogetAddressand no contract check.switchConnectionrunsstandard:connectof the wallet again.
Parameters
params
SolanaRPCUrls
Adapter options: rpcUrls, the RPC URL for each cluster moniker (mainnet, devnet, testnet,
localnet). The URLs are kept in memory and exposed as rpcURL of the connection; they are not saved to
localStorage.
Returns
SatelliteAdapter<UiWallet, SolanaConnection>
The Solana adapter.
Example
import { satelliteSolanaAdapter } from '@tuwaio/satellite-solana';
export const solanaAdapter = satelliteSolanaAdapter({
rpcUrls: {
mainnet: 'https://api.mainnet-beta.solana.com',
devnet: 'https://api.devnet.solana.com',
},
});Last updated on