Network
Networks Module
This module is responsible for watching and updating the Ethereum network data. It uses signals to maintain a reactive state of network data.
Import
This module imports the following dependencies:
signal
from@preact/signals-react
KiroboService
from@kiroboio/fct-service
endpoints
from./endpoints
validator
,validateFind
,validateItem
,ServiceFind
from./validator
EthNetworkPatchDto
,EthNetworkResponseDto
from./types/eth-network.dto
Constants
ENDPOINT
: contains the endpoint of the Ethereum network service.defaultNetworkData
: a default object representing the network data.
Functions
networkName(netId: string | number)
This function returns the network name based on the provided network ID.
Example:
unwatchNetworks()
This function removes all listeners for the Ethereum network service and resets the network state.
Example:
watchNetwork(netId: number)
This function watches for network updates in the specified network ID. It updates the network state accordingly when there are changes in the network data.
Example:
updateNetwork(net: EthNetworkResponseDto | EthNetworkPatchDto)
This function updates the network data with the provided network object.
Example:
watchNetworks()
This function watches for network updates and sets up listeners for the Ethereum network service to respond to events like network data changes.
Example:
Exports
networkName
: a function to get the network name from a network ID.network
: the signal object containing the network data.unwatchNetworks
: a function to stop watching network updates.watchNetwork
: a function to start watching network updates for a specific network ID.watchNetworks
: a function to start watching network updates for all networks.
Last updated