@gala-chain/connect ∙ API
API > TrustWalletConnectClient
Class: TrustWalletConnectClient
Browser-based client for connecting to wallets like MetaMask. Handles wallet connection, account management, and transaction signing.
Contents
- Extends
- Constructors
- new TrustWalletConnectClient()
- Properties
- address
- isInitialized
- options
- provider
- Accessors
- ethereumAddress
- galaChainAddress
- Methods
- calculatePersonalSignPrefix()
- connect()
- disconnect()
- emit()
- getPublicKey()
- initializeListeners()
- off()
- on()
- onAccountsChanged()
- sign()
- signMessage()
- submit()
Extends
Constructors
new TrustWalletConnectClient()
new TrustWalletConnectClient():
TrustWalletConnectClient
Overrides
BrowserConnectClient.constructor
Source
chain-connect/src/customClients/TrustWalletConnectClient.ts:93
Properties
address
protectedaddress:string
Inherited from
Source
chain-connect/src/GalaChainClient.ts:219
isInitialized
protectedisInitialized:boolean=false
Inherited from
BrowserConnectClient.isInitialized
Source
chain-connect/src/customClients/BrowserConnectClient.ts:34
options
protectedoptions?:GalaChainProviderOptions
Configuration options for the provider
Inherited from
Source
chain-connect/src/GalaChainClient.ts:58
provider
protectedprovider:undefined|BrowserProvider
Inherited from
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
BrowserConnectClient.calculatePersonalSignPrefix
Source
chain-connect/src/GalaChainClient.ts:200
connect()
connect():
Promise\<string>
Connects to the wallet and requests account access.
Returns
Promise resolving to the connected GalaChain address
Overrides
Throws
If no provider is found or connection fails
Source
chain-connect/src/customClients/TrustWalletConnectClient.ts:98
disconnect()
disconnect():
void
Disconnects from the wallet and cleans up event listeners.
Inherited from
BrowserConnectClient.disconnect
Source
chain-connect/src/customClients/BrowserConnectClient.ts:108
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
Inherited from
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
Inherited from
BrowserConnectClient.getPublicKey
Source
chain-connect/src/GalaChainClient.ts:298
initializeListeners()
protectedinitializeListeners():void
Initializes the listeners to watch for events from the provider. Not all providers may support every event
Inherited from
BrowserConnectClient.initializeListeners
Source
chain-connect/src/customClients/BrowserConnectClient.ts:58
off()
off(
event,listener):TrustWalletConnectClient
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
Inherited from
Source
chain-connect/src/GalaChainClient.ts:279
on()
on(
event,listener):TrustWalletConnectClient
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
Inherited from
Source
chain-connect/src/GalaChainClient.ts:268
onAccountsChanged()
protectedonAccountsChanged(accounts):void
Handles account changes from the wallet provider.
Parameters
▪ accounts: string[]
Array of account addresses from the wallet
Inherited from
BrowserConnectClient.onAccountsChanged
Source
chain-connect/src/customClients/BrowserConnectClient.ts:72
sign()
sign\<
T>(method,payload,signingType):Promise\<T&object>
Signs a payload using the connected wallet.
Type parameters
▪ T extends object
The type of the payload to sign
Parameters
▪ method: string
The method name for EIP-712 signing
▪ payload: T
The data to sign
▪ signingType: SigningType= SigningType.SIGN_TYPED_DATA
The type of signing to use (defaults to signTypedData)
Returns
Promise resolving to the signed payload with signature
Inherited from
Throws
If no provider/account is connected or signing fails
Source
chain-connect/src/customClients/BrowserConnectClient.ts:125
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
Inherited from
BrowserConnectClient.signMessage
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