Interface: WalletProvider
GalaChain core SDK 1.0.0-rc.8 / providers / WalletProvider
Interface: WalletProvider
Defined in: packages/gala-core-sdk/dist/providers.d.ts:41
One wallet, however it signs: PrivateKeyProvider, ExternalWalletProvider (EIP-1193 browser wallets) or GalaWalletProvider.
signMessage / signTypedData sign ARBITRARY messages and typed data (logins, permits);
getSigner gives the core GalaChainSigner for GalaChain DTOs, bound to the account the
provider is connected to when it is called. After the account changes, get a new signer: a
signer keeps the identity it was made for, so a write never silently signs as someone else.
Example
const provider = new ExternalWalletProvider(window.ethereum);
await provider.connect();
const signature = await provider.signMessage('Hello');
const signer = provider.getSigner(); // for GatewayWrites, GSwap, ...
Properties
providerType
readonlyproviderType:WalletProviderType
Defined in: packages/gala-core-sdk/dist/providers.d.ts:43
Whether the provider holds a raw key (privateKey) or signs in a wallet (external).
Methods
connect()
connect():
Promise<string>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:82
Asks the wallet for account access (a private-key provider is always ready).
Returns
Promise<string>
The connected account (0x, checksummed).
Throws
GalaSDKError WALLET_CONNECTION_FAILED.
disconnect()
disconnect():
Promise<void>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:92
Forgets the account and stops listening to the wallet's events.
Returns
Promise<void>
getAddress()
getAddress():
Promise<string>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:63
The connected account: 0x plus its EIP-55 checksummed digits.
Returns
Promise<string>
Throws
GalaSDKError WALLET_NOT_CONNECTED.
getGalaAddress()
getGalaAddress():
Promise<string>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:69
The connected account as GalaChain spells it: eth| plus the checksummed digits.
Returns
Promise<string>
Throws
GalaSDKError WALLET_NOT_CONNECTED.
getPrivateKey()?
optionalgetPrivateKey():Promise<string>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:109
The raw private key (0x plus 64 lower-case hex digits). Only a PrivateKeyProvider
has one.
Returns
Promise<string>
Throws
GalaSDKError PRIVATE_KEY_NOT_ACCESSIBLE for a wallet-backed provider.
getSigner()
getSigner():
GalaChainSigner
Defined in: packages/gala-core-sdk/dist/providers.d.ts:75
The core signer for GalaChain DTOs, bound to the account connected NOW.
Returns
Throws
GalaSDKError WALLET_NOT_CONNECTED.
isConnected()
isConnected():
boolean
Defined in: packages/gala-core-sdk/dist/providers.d.ts:94
True while the provider has an account to sign for.
Returns
boolean
onAccountChanged()?
optionalonAccountChanged(listener): () =>void
Defined in: packages/gala-core-sdk/dist/providers.d.ts:102
Calls listener with the new account whenever it changes (the wallet switched accounts, or
connect()), and with null once disconnected. Every provider in this package has it; a
custom provider may leave it out.
Parameters
listener
(address) => void
Returns
The function that stops the calls.
() => void
restore()?
optionalrestore():Promise<string|null>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:90
Reconnects to the account the wallet already lets this site use, without a wallet prompt
(eth_accounts, never eth_requestAccounts). Every wallet-backed provider in this package has
it; a private-key provider and a custom provider may leave it out. Never throws.
Returns
Promise<string | null>
The connected account (0x, checksummed), or null when the wallet reports none.
signMessage()
signMessage(
message):Promise<string>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:50
Signs message the way personal_sign does (EIP-191).
Parameters
message
string
Returns
Promise<string>
Throws
GalaSDKError WALLET_NOT_CONNECTED, or SIGNING_FAILED (user_rejected when the
person declined).
signTypedData()
signTypedData(
domain,types,value):Promise<string>
Defined in: packages/gala-core-sdk/dist/providers.d.ts:57
Signs EIP-712 typed data (eth_signTypedData_v4). types excludes EIP712Domain; the primary
type is the FIRST key of types.
Parameters
domain
types
Record<string, TypedDataField[]>
value
Record<string, unknown>
Returns
Promise<string>
Throws
GalaSDKError WALLET_NOT_CONNECTED, or SIGNING_FAILED.