BaseWallet
atlas.js / BaseWallet
Abstract Class: BaseWallet
Defined in: src/wallets/base-wallet.ts:23
Abstract base class for wallet implementations.
Manages the lifecycle of a Cosmos-compatible wallet connection: connecting to an RPC endpoint, initialising query and signing clients, and providing transaction signing, simulation, and balance-querying primitives.
Subclasses must implement connect, disconnect, getWalletType, and signArbitrary.
Constructors
Constructor
new BaseWallet(
config):BaseWallet
Defined in: src/wallets/base-wallet.ts:45
Parameters
config
Configuration object containing endpoint, gas price, and any subclass-specific options.
Returns
BaseWallet
Properties
_address
protected_address:string=""
Defined in: src/wallets/base-wallet.ts:28
Active wallet address
config
protectedconfig:AtlasConfig
Defined in: src/wallets/base-wallet.ts:25
Wallet-level configuration (RPC endpoint, gas price, etc.).
queryClient
protectedqueryClient:StargateClient=null
Defined in: src/wallets/base-wallet.ts:34
Read-only Stargate client for queries (balance, account info).
signingClient
protectedsigningClient:SigningStargateClient=null
Defined in: src/wallets/base-wallet.ts:37
Signing Stargate client for broadcasting transactions.
Accessors
address
Get Signature
get address():
string
Defined in: src/wallets/base-wallet.ts:29
Returns
string
Methods
connect()
abstractconnect():Promise<void>
Defined in: src/wallets/base-wallet.ts:56
Establish a wallet connection.
Subclasses should initialize the signer, connect to the RPC endpoint (via initializeClients), and return the resulting connection metadata.
Returns
Promise<void>
disconnect()
abstractdisconnect():Promise<void>
Defined in: src/wallets/base-wallet.ts:59
Tear down the wallet connection and release any held resources.
Returns
Promise<void>
getAccountBalance()
getAccountBalance():
Promise<readonlyCoin[]>
Defined in: src/wallets/base-wallet.ts:110
Fetch all non-zero balance coins for the connected wallet address.
Returns
Promise<readonly Coin[]>
Throws
If the wallet is not connected.
getAccountInfo()
getAccountInfo():
Promise<Account>
Defined in: src/wallets/base-wallet.ts:100
Fetch the on-chain account information for the connected wallet address.
Returns
Promise<Account>
Throws
If the wallet is not connected.
getQueryClient()
getQueryClient():
StargateClient
Defined in: src/wallets/base-wallet.ts:91
Return the active query client, or null if not connected.
Returns
StargateClient
getSigningClient()
getSigningClient():
SigningStargateClient
Defined in: src/wallets/base-wallet.ts:84
Return the active signing client, or null if not connected.
Returns
SigningStargateClient
getWalletType()
abstractgetWalletType():WalletType
Defined in: src/wallets/base-wallet.ts:62
Return the concrete wallet type for this implementation.
Returns
initializeClients()
protectedinitializeClients(offlineSigner,address):Promise<void>
Defined in: src/wallets/base-wallet.ts:188
Initialize the query and signing Stargate clients.
Connects a read-only StargateClient to the configured RPC endpoint,
then creates a SigningStargateClient using the provided offline
signer. The Atlas protobuf type registry (from GlobalDecoderRegistry)
is registered so that the signing client can encode/decode custom
message types.
Parameters
offlineSigner
OfflineSigner
The offline signer (Amino-compatible) to attach.
address
string
The on-chain address corresponding to the signer.
Returns
Promise<void>
Throws
If either client fails to initialize.
isConnected()
isConnected():
boolean
Defined in: src/wallets/base-wallet.ts:77
Check whether the wallet is currently connected and ready for use.
Returns true when a wallet handle, signingClient, and queryClient
are all not null.
Returns
boolean
refreshClients()
refreshClients():
Promise<void>
Defined in: src/wallets/base-wallet.ts:226
Re-initialize the query and signing clients using the existing wallet connection.
Useful after a network interruption or endpoint rotation.
Returns
Promise<void>
Throws
If no wallet connection has been established.
signAndBroadcastTransaction()
signAndBroadcastTransaction(
txBody,options?):Promise<DeliverTxResponse>
Defined in: src/wallets/base-wallet.ts:131
Sign and broadcast a transaction constructed from a TxBody.
Fee resolution order:
options.feeif explicitly provided.- Auto-calculated from
options.gas+config.gasPriceif both are finite. - Fall back to
options.gasAdjustmentorconfig.gasAdjustment, or the literal string'auto'as a last resort.
Parameters
txBody
TxBody
The transaction body containing messages.
options?
Optional overrides for gas, fee, memo, and gas adjustment.
Returns
Promise<DeliverTxResponse>
The on-chain delivery response after broadcast.
Throws
If the wallet is not connected or the transaction fails.
signArbitrary()
abstractsignArbitrary(data):Promise<string>
Defined in: src/wallets/base-wallet.ts:69
Sign an arbitrary piece of data (string or bytes) using the wallet's key.
Parameters
data
string | Uint8Array<ArrayBufferLike>
The data to sign, as a string or Uint8Array.
Returns
Promise<string>
simulateTransaction()
simulateTransaction(
messages,options?):Promise<number>
Defined in: src/wallets/base-wallet.ts:168
Simulate a transaction without broadcasting it.
Uses the signing client's simulate method to dry-run the given
messages and return the estimated gas units.
Parameters
messages
any[]
The array of protobuf messages to simulate.
options?
Optional overrides (currently only memo is used).
Returns
Promise<number>
The estimated gas cost in gas units.
Throws
If the wallet is not connected.