Class: BrowserWalletSigner
Gala Launchpad SDK 9.0.0-rc.5 / index / BrowserWalletSigner
Class: BrowserWalletSigner
Defined in: packages/launchpad-sdk/dist/signing/signers.d.ts:110
An EIP-1193 signer for MetaMask, Trust Wallet, and compatible wallets.
Example
const signer = new BrowserWalletSigner(window.ethereum, 'eth|1234');
const body = await signer.signTypedData('BuyWithNative', { amount: '1' });
console.log(body.signature);
Extends
BrowserWalletSigner
Implements
Constructors
Constructor
new BrowserWalletSigner(
provider,walletAddress,options?):BrowserWalletSigner
Defined in: packages/launchpad-sdk/dist/signing/signers.d.ts:117
Parameters
provider
walletAddress
string
options?
{ scheme: 'eip712' } selects eth_signTypedData_v4 for the DEX methods
that support it, which resolves a registered client| alias; the default personal-sign
resolves the bare eth| identity.
scheme?
"personal-sign" | "eip712"
Returns
BrowserWalletSigner
Overrides
CoreBrowserWalletSigner.constructor
Properties
walletAddress
readonlywalletAddress:string
Defined in: packages/gala-core-sdk/dist/index.d.ts:1497
The selected 0x Ethereum account every signature is requested for.
Inherited from
CoreBrowserWalletSigner.walletAddress
Methods
signObject()
signObject<
T>(methodName,dto):Promise<SignedDto<T>>
Defined in: packages/gala-core-sdk/dist/index.d.ts:1513
Signs the DTO with eth_signTypedData_v4 (when constructed with { scheme: 'eip712' } and
methodName is in EIP712_CAPABLE_METHODS) or the EIP-1193 personal_sign method
(otherwise — the default).
Type Parameters
T
T extends Record<string, unknown>
Parameters
methodName
string
dto
T
Returns
Promise<SignedDto<T>>
Example
const signed = await signer.signObject('RequestTrade', {
token0: 'GALA',
token1: 'GUSDC',
fee: 3000,
});
Implementation of
Inherited from
CoreBrowserWalletSigner.signObject
signTypedData()
signTypedData(
method,rawDto):Promise<SignedTypedDataBody>
Defined in: packages/launchpad-sdk/dist/signing/signers.d.ts:125
Sign typed data with the connected wallet's network domain.
Parameters
method
string
rawDto
Record<string, unknown>
Returns
Promise<SignedTypedDataBody>
Example
const body = await signer.signTypedData('BuyWithNative', { amount: '1' });
console.log(body.domain.chainId);
Implementation of
fromEip1193()
staticfromEip1193(provider,keyAddress,options?):BrowserWalletSigner
Defined in: packages/launchpad-sdk/dist/signing/signers.d.ts:148
A signer for a browser app that holds the wallet's raw EIP-1193 provider (window.ethereum,
an EIP-6963 announcement's provider) rather than an ethers provider. It builds the ethers
BrowserProvider the typed-data path reads the network and the account from, and keeps the raw
request for the DEX signatures (signObject). The bytes signed are exactly those of
new BrowserWalletSigner({ request, getNetwork, getSigner }, key) over that BrowserProvider:
domain { name: network.name, chainId: Number(network.chainId) }, signed by the account the
wallet has selected (getSigner()), refused with WALLET_ACCOUNT_CHANGED when that is not
keyAddress.
Parameters
provider
Eip1193Provider
The wallet's EIP-1193 provider.
keyAddress
string
The account of the KEY that signs: 0x plus 40 hex digits, or eth| plus
40 hex digits (with or without 0x). Not a client| alias: an alias names no key (it is the
walletAddress the SDK declares beside this signer).
options?
As the constructor's ({ scheme: 'eip712' } for the DEX methods).
scheme?
"personal-sign" | "eip712"
Returns
BrowserWalletSigner
Throws
GalaSDKError INVALID_WALLET_ADDRESS when keyAddress names no Ethereum account.
Since
9.0.0
Example
const signer = BrowserWalletSigner.fromEip1193(window.ethereum, '0x70997970C51812dc3A010C7d01b50e0d17dc79C8');
const sdk = new LaunchpadSDK({ signer, walletAddress: 'client|618ae395c1c653111d3315be' });