@gala-chain/connect ∙ API
API > WebSigner
Class: abstract WebSigner
Abstract web signer that provides browser-based signing capabilities. Handles connection to web wallets and manages Ethereum addresses.
Contents
- Extends
- Constructors
- new WebSigner(options)
- Properties
- address
- eventEmitter
- options
- provider
- Accessors
- ethereumAddress
- galaChainAddress
- Methods
- calculatePersonalSignPrefix()
abstractconnect()- emit()
- getPublicKey()
- off()
- on()
abstractsign()- signMessage()
- submit()
Extends
Constructors
new WebSigner(options)
new WebSigner(
options?):WebSigner
Creates a new web signer instance.
Parameters
▪ options?: GalaChainProviderOptions
Configuration options for the provider
Overrides
Source
chain-connect/src/GalaChainClient.ts:226
Properties
address
protectedaddress:string
Source
chain-connect/src/GalaChainClient.ts:219
eventEmitter
privateeventEmitter:EventEmitter\<MetaMaskEvents>
Source
chain-connect/src/GalaChainClient.ts:260
options
protectedoptions?:GalaChainProviderOptions
Configuration options for the provider
Inherited from
Source
chain-connect/src/GalaChainClient.ts:58
provider
protectedprovider:undefined|BrowserProvider
Source
chain-connect/src/GalaChainClient.ts:220
Accessors
ethereumAddress
getethereumAddress():string
Gets the current Ethereum address.
setethereumAddress(val):void
Sets the Ethereum address, converting from GalaChain format if needed.
Parameters
▪ val: string
The address to set
Returns
The Ethereum address
Source
chain-connect/src/GalaChainClient.ts:248
galaChainAddress
getgalaChainAddress():string
Gets the GalaChain address derived from the Ethereum address.
Returns
The GalaChain address
Source
chain-connect/src/GalaChainClient.ts:256
Methods
calculatePersonalSignPrefix()
calculatePersonalSignPrefix(
payload):string
Calculates the personal sign prefix for a given payload. This is used for Ethereum personal_sign compatibility.
Parameters
▪ payload: object
The payload to calculate prefix for
Returns
The calculated prefix string
Inherited from
CustomClient.calculatePersonalSignPrefix
Source
chain-connect/src/GalaChainClient.ts:200
abstract connect()
abstractconnect():Promise\<string>
Connects to the web wallet and returns the connected address.
Returns
Promise resolving to the connected Ethereum address
Source
chain-connect/src/GalaChainClient.ts:234
emit()
emit(
event,data):boolean
Emits a MetaMask event to all registered listeners.
Parameters
▪ event: keyof MetaMaskEvents
The event type to emit
▪ data: null | string | string[]
The data to pass to listeners
Returns
True if the event had listeners, false otherwise
Source
chain-connect/src/GalaChainClient.ts:290
getPublicKey()
getPublicKey():
Promise\<object>
Retrieves the public key by signing a message and recovering it from the signature.
Returns
Promise resolving to the public key and recovered address
Overrides
Source
chain-connect/src/GalaChainClient.ts:298
off()
off(
event,listener):WebSigner
Removes an event listener for MetaMask events.
Parameters
▪ event: keyof MetaMaskEvents
The event type to stop listening for
▪ listener: Listener\<null | string | string[]>
The callback function to remove
Returns
This instance for method chaining
Source
chain-connect/src/GalaChainClient.ts:279
on()
on(
event,listener):WebSigner
Adds an event listener for MetaMask events.
Parameters
▪ event: keyof MetaMaskEvents
The event type to listen for
▪ listener: Listener\<null | string | string[]>
The callback function to execute
Returns
This instance for method chaining
Source
chain-connect/src/GalaChainClient.ts:268
abstract sign()
abstractsign\<T>(method,dto,signingType?):Promise\<T&object>
Signs a payload using the provider's signing mechanism.
Type parameters
▪ T extends object
Parameters
▪ method: string
The method name being called
▪ dto: T
The data transfer object to sign
▪ signingType?: SigningType
Optional signing type override
Returns
The signed payload with signature and optional prefix
Inherited from
Source
chain-connect/src/GalaChainClient.ts:74
signMessage()
signMessage(
message):Promise\<string>
Signs a message using the connected wallet.
Parameters
▪ message: string
The message to sign
Returns
Promise resolving to the signature
Throws
If no provider is found or no account is connected
Source
chain-connect/src/GalaChainClient.ts:318
submit()
submit\<
T,U>(params):Promise\<GalaChainResponseSuccess\<T>>
Submits a request to the GalaChain network.
Type parameters
▪ T
▪ U extends object
Parameters
▪ params: object
The submission parameters
▪ params.headers?: Record\<string, string>
Additional HTTP headers
▪ params.method: string
The method name to call
▪ params.payload: ConstructorArgs\<U>
The request payload
▪ params.requestConstructor?: ClassConstructor\<ChainCallDTO>
Constructor for request validation
▪ params.responseConstructor?: NonArrayClassConstructor\<T>
Constructor for response transformation
▪ params.sign?: boolean
Whether to sign the request
▪ params.signingType?: SigningType
Type of signing to use
▪ params.url: string
The base URL for the request
Returns
Promise resolving to a successful response
Inherited from
Throws
When the request fails