Skip to Content

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:

  • getConnectors returns the wallets of getAvailableSolanaConnectors from @tuwaio/orbit-solana (registered Wallet Standard wallets with the Solana features Satellite needs). A wallet matches a connectorType such as "solana:phantom" through formatConnectorName from @tuwaio/orbit-core.
  • watchConnectors calls onChange (with no arguments) when a Wallet Standard wallet registers or unregisters, through watchAvailableSolanaConnectors from @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 the register and unregister events of the Wallet Standard registry (getWallets() from @wallet-standard/app) until the returned function is called, and to nothing on the server (no window). It also runs for wallets that getConnectors leaves out, and does not follow the change events of the wallets themselves.
  • connect asks 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 from rpcUrls, the wallet icon, the Wallet Standard handles and a signMessage created with createSolanaMessageSigner. When rpcUrls has no URL for the cluster, getRpcUrlForCluster from @tuwaio/orbit-solana returns the public endpoint of that cluster (the mainnet-beta one for localnet, and for every cluster with @tuwaio/orbit-solana 0.3.1 and earlier).
  • reconnect restores a wallet without a prompt, for initializeAutoConnect: standard:connect with silent: true returns the accounts that already authorize the app, and the connection is built as by connect. It resolves to undefined when the wallet returns no accounts or rejects (Phantom rejects a silent connect when the app is not trusted).
  • getLiveConnections lists the connections this adapter opened (with connect or reconnect) and has not disconnected. The record lives in memory, in the adapter object.
  • disconnect disconnects the wallet of the given connection, or, without a connection, only the wallets of getLiveConnections (standard:disconnect). A wallet that has accounts because other code or another store of the page connected it is never disconnected.
  • checkAndSwitchNetwork makes no wallet request (Solana wallets have no network switch): it sets the connection’s chainId and rpcURL to the new cluster, and does nothing when the requested chain is the current cluster in another form.
  • getBalance reads the balance with getBalance over RPC and returns it in SOL.
  • getExplorerUrl(url?, chainId?) builds a Solana Explorer link (explorer.solana.com).
  • getName and getAvatar resolve SNS names and avatars with @tuwaio/orbit-solana (Bonfida APIs, cached in memory); getName returns the address when there is no name. There is no getAddress and no contract check.
  • switchConnection runs standard:connect of 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