Skip to main content

index/classes/GalaWalletSigner.md

A Gala Wallet signer with the launchpad frontend's eth_signTypedData shape.

Example​

const signer = new GalaWalletSigner('0x1234');
const body = await signer.signTypedData('BuyWithNative', { amount: '1' });
console.log(body.signature);

Extends​

  • GalaWalletSigner

Implements​

Constructors​

Constructor​

new GalaWalletSigner(walletAddress, options?): GalaWalletSigner

Same arguments as gala-core-sdk's GalaWalletSigner (scheme, selectAddress, wallet), and:

  • verifyActiveAccount (default false): before every typed-data signature, refuse unless the wallet's active account is this signer's key. See GalaWalletSigner.signTypedData. The key is walletAddress when that is an Ethereum account (0x... / eth|...), else selectAddress when that is one; a signer that names no key cannot be verified and is refused at construction (INVALID_SIGNER_OPTIONS).

Parameters​

ParameterType
walletAddressstring
options?object & object

Returns​

GalaWalletSigner

Since​

9.0.0

Overrides​

CoreGalaWalletSigner.constructor

Properties​

PropertyModifierTypeDescriptionInherited from
schemereadonlyGalaWalletSchemeThe signing scheme used for every request; it never changes after construction.CoreGalaWalletSigner.scheme
selectAddressreadonlystring | undefinedThe identity Gala Wallet is switched to before each signature, if one was given.CoreGalaWalletSigner.selectAddress
walletAddressreadonlystringThe wallet address supplied to Gala Wallet for each signing request.CoreGalaWalletSigner.walletAddress

Methods​

signObject()​

signObject<T>(methodName, dto): Promise<SignedDto<T>>

Signs a DTO through gala_signChainDto.

Type Parameters​

Type Parameter
T extends Record<string, unknown>

Parameters​

ParameterType
methodNamestring
dtoT

Returns​

Promise<SignedDto<T>>

Example​

const signed = await signer.signObject('AddLiquidity', {
token0: 'GALA',
token1: 'GUSDC',
tickLower: -60,
tickUpper: 60,
});

Implementation of​

LaunchpadSigner.signObject

Inherited from​

CoreGalaWalletSigner.signObject


signTypedData()​

signTypedData(method, rawDto): Promise<SignedTypedDataBody>

With verifyActiveAccount, the first step is the active-account check (below); the RPC order is then the check (window.gala.address, else eth_accounts when the wallet has not reported an account yet), setAddress, eth_signTypedData. A mismatch, or a wallet reporting no account, is WALLET_ACCOUNT_CHANGED and nothing is signed. The check runs before this signer's own setAddress, so it sees the account the person has active, not one this signer just selected; another signer's select on the same wallet object in flight at that moment is not observable.

Sign a launchpad DTO through Gala Wallet. Gala Wallet holds one current account, so the account is selected first (setAddress, where the wallet offers it, with selectAddress or else the Ethereum account the request names) and the select-then-sign pair is serialized per wallet object with every other signer and provider that signs through it (gala-core-sdk's withGalaWalletIdentity). The wallet is the wallet option, else window.gala.

Parameters​

ParameterType
methodstring
rawDtoRecord<string, unknown>

Returns​

Promise<SignedTypedDataBody>

Example​

const body = await signer.signTypedData('BuyWithNative', { amount: '1' });
console.log(body.types.BuyWithNative);

Implementation of​

LaunchpadSigner.signTypedData