Class: GalaWalletProvider
GalaChain core SDK 1.0.0-rc.8 / providers / GalaWalletProvider
Class: GalaWalletProvider
Defined in: packages/gala-core-sdk/dist/providers.d.ts:376
Gala Wallet as a wallet provider.
Example
const provider = new GalaWalletProvider(window.gala);
const address = await provider.connect();
const signature = await provider.signMessage('Hello');
Extends
WalletConnection<GalaWalletExtension>
Implements
Constructors
Constructor
new GalaWalletProvider(
provider):GalaWalletProvider
Defined in: packages/gala-core-sdk/dist/providers.d.ts:382
Parameters
provider
Gala Wallet (window.gala, or its EIP-6963 announcement's provider).
Returns
GalaWalletProvider
Throws
GalaSDKError INVALID_WALLET_PROVIDER_CONFIG when no provider is given.
Overrides
WalletConnection<GalaWalletExtension>.constructor
Properties
providerType
readonlyproviderType:WalletProviderType
Defined in: packages/gala-core-sdk/dist/providers.d.ts:377
Whether the provider holds a raw key (privateKey) or signs in a wallet (external).
Implementation of
Methods
connect()
connect():
Promise<string>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:237
Asks the wallet for account access (eth_requestAccounts) and listens to its account and
disconnect events from then on.
Returns
Promise<string>
The connected account (0x, checksummed).
Throws
GalaSDKError WALLET_CONNECTION_FAILED (no_accounts, user_rejected, failed),
WALLET_NOT_CONNECTED (the wallet refused or is disconnected, or disconnect() was called
before the wallet answered).
Implementation of
Inherited from
WalletConnection.connect
disconnect()
disconnect():
Promise<void>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:390
Forgets the account and ends the wallet's session (disconnect, where it offers one).
Returns
Promise<void>
Implementation of
getAddress()
getAddress():
Promise<string>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:262
The connected account (0x, checksummed).
Returns
Promise<string>
Throws
GalaSDKError WALLET_NOT_CONNECTED.
Implementation of
Inherited from
WalletConnection.getAddress
getGalaAddress()
getGalaAddress():
Promise<string>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:268
The connected account as GalaChain spells it (eth| plus the checksummed digits).
Returns
Promise<string>
Throws
GalaSDKError WALLET_NOT_CONNECTED.
Implementation of
Inherited from
WalletConnection.getGalaAddress
getPrivateKey()
getPrivateKey():
Promise<string>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:274
A wallet-backed provider never holds the key.
Returns
Promise<string>
Throws
GalaSDKError PRIVATE_KEY_NOT_ACCESSIBLE, always.
Implementation of
Inherited from
WalletConnection.getPrivateKey
getProvider()
getProvider():
GalaWalletExtension
Defined in: packages/gala-core-sdk/dist/providers.d.ts:282
The wallet object the provider talks to.
Returns
Inherited from
WalletConnection.getProvider
getSigner()
getSigner(
options?):GalaChainSigner
Defined in: packages/gala-core-sdk/dist/providers.d.ts:412
The core GalaWalletSigner for GalaChain DTOs, bound to the account connected now and signing through this provider's wallet object.
Parameters
options?
{ scheme: 'personal-sign' } opts into Gala Wallet's personal-sign scheme
(see GalaWalletSigner); the default is native signing.
scheme?
Returns
Throws
GalaSDKError WALLET_NOT_CONNECTED.
Implementation of
isConnected()
isConnected():
boolean
Defined in: packages/gala-core-sdk/dist/providers.d.ts:256
True while the provider has an account to sign for.
Returns
boolean
Implementation of
Inherited from
WalletConnection.isConnected
onAccountChanged()
onAccountChanged(
listener): () =>void
Defined in: packages/gala-core-sdk/dist/providers.d.ts:280
Calls listener with the new account whenever it changes (null once disconnected).
Parameters
listener
Returns
The function that stops the calls.
() => void
Implementation of
WalletProvider.onAccountChanged
Inherited from
WalletConnection.onAccountChanged
release()
release():
void
Defined in: packages/gala-core-sdk/dist/providers.d.ts:289
Retires this provider object WITHOUT asking the wallet to end its session (unlike
disconnect(), which revokes / disconnects in the wallet): it forgets the account and removes
its listeners from the wallet. For code that drops a provider it created, so the wallet keeps
no listener of a provider nobody uses (the React context does it when it switches wallets).
Returns
void
Inherited from
WalletConnection.release
restore()
restore():
Promise<string|null>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:254
Reconnects to the account the wallet already lets this site use, WITHOUT a wallet prompt (for
the page reload after an earlier connect()): asks eth_accounts only, never
eth_requestAccounts. When the wallet reports an account the provider is connected to it and
listens to the wallet's events, exactly as after connect(); otherwise it stays not connected
and holds no listener.
Nothing here throws. The wallet reporting no account, an account that is not an Ethereum
address, or eth_accounts failing all answer null: a silent restore that cannot happen is
not an error, the user connects with connect(). A disconnect(), a wallet event or a
connect() that lands while the wallet is answering wins over the answer (it may be older than
they are); the provider then answers its state at that moment.
Returns
Promise<string | null>
The connected account (0x, checksummed), or null when not connected. Already
connected: the connected account, with no request.
Implementation of
Inherited from
WalletConnection.restore
signMessage()
signMessage(
message):Promise<string>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:396
Signs message with personal_sign, after switching Gala Wallet to the connected account.
Parameters
message
string
Returns
Promise<string>
Throws
GalaSDKError WALLET_NOT_CONNECTED, SIGNING_FAILED, INVALID_SIGNATURE.
Implementation of
signTypedData()
signTypedData(
domain,types,value):Promise<string>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:403
Signs EIP-712 typed data with eth_signTypedData_v4, after switching Gala Wallet to the
connected account.
Parameters
domain
types
Record<string, TypedDataField[]>
value
Record<string, unknown>
Returns
Promise<string>
Throws
GalaSDKError WALLET_NOT_CONNECTED, SIGNING_FAILED, INVALID_SIGNATURE.