Session
Session Module
This module provides session management functionalities for the Ethereum network, such as logging in, logging out, and watching/unwatching services.
Variables
ZERO_ADDRESS
: A constant representing the zero address in the Ethereum network.state
: A Signal representing the current service state.wallet
: A Signal representing the user's wallet address.vault
: A Signal representing the user's vault address.status
: A Signal representing the user's session status.signatures
: A record object storing network-specific signatures.
Functions
login(params?: { signature?: string; useSigner?: boolean })
Logs in the user by signing a message from the Ethereum network using their private key. The function accepts an optional params
object with the following properties:
signature
(optional): A pre-signed message signature.useSigner
(optional, default istrue
): A boolean indicating whether to use the signer for message signing.
This function watches tokens, NFTs, fuel, and active services upon successful login. Returns the login response.
Example:
logout()
Logs out the user and unwatch all services (tokens, NFTs, fuel, and active services).
Example:
unwatchServices()
Unwatches all services (tokens, NFTs, fuel, and active services) and resets the wallet and vault addresses to the zero address.
Example:
Exported Object
The exported session
object provides the following properties and methods:
login
: The login function.logout
: The logout function.status
: The session status Signal.wallet
: The wallet address Signal.vault
: The vault address Signal.autoLogin
: The auto-login Signal.state
: The service state Signal.getSigner
: The function to get the signer instance.
Last updated