Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeHex(something []interface{}, fallback string) string
- func DecodeString(something []interface{}, fallback string) string
- func DecodeUint64(something []interface{}, fallback uint64) uint64
- func FetchBasicInformations(chainID uint64, tokens []common.Address) map[string]*TERC20
- func FetchDecimals(chainID uint64, tokens []common.Address) map[string]uint64
- func FetchNames(chainID uint64, tokens []common.Address) map[string]string
- func GetRPC(chainID uint64) *ethclient.Client
- func GetRPCURI(chainID uint64) string
- func Init()
- type Call
- type CallResponse
- type TERC20
- type TEthMultiCaller
Constants ¶
const SHOULD_LOG_WARNINGS = true
Variables ¶
var ERC20ABI, _ = contracts.ERC20MetaData.GetAbi()
var ERC20ALTABI, _ = contracts.Erc20AltMetaData.GetAbi()
var MulticallClientForChainID = make(map[uint64]TEthMultiCaller)
MulticallClientForChainID holds the multicall client for a specific chainID
var RPC = map[uint64]*ethclient.Client{}
RPC contains the ethclient.Client for a specific chainID
var RPC_ENDPOINTS = map[uint64]string{}
RPC_ENDPOINTS contains the node endpoints to connect the blockchains
Functions ¶
func DecodeHex ¶
DecodeHex decodes a hax from a slice of interfaces and try to convert it to a string
func DecodeString ¶
DecodeString decodes a string from a slice of interfaces
func DecodeUint64 ¶
DecodeUint64 decodes a uint64 from a slice of interfaces
func FetchBasicInformations ¶
Types ¶
type Call ¶
type Call struct { Name string `json:"name"` Method string `json:"method"` Version string `json:"version"` Abi *abi.ABI `json:"abi"` Target common.Address `json:"target"` CallData []byte `json:"call_data"` }
func (Call) GetMultiCall ¶
func (call Call) GetMultiCall() contracts.Multicall3Call
type CallResponse ¶
type TERC20 ¶
type TERC20 struct { Address common.Address Name string Symbol string ChainID uint64 Decimals uint64 }
************************************************************************************************* ** fetchBasicInformations will, for a list of addresses, fetch all the relevant basic information ** for the related token. This includes the name, the symbol and the decimals. ** ** Arguments: ** - chainID: the chain ID of the network we are working on ** - tokens: a list of addresses of the tokens we want to fetch the information for ** ** Returns: ** - a list of TERC20Token containing the basic information for the tokens *************************************************************************************************
type TEthMultiCaller ¶
type TEthMultiCaller struct { Signer *bind.TransactOpts Client *ethclient.Client Abi *abi.ABI ContractAddress common.Address }
func NewMulticall ¶
func NewMulticall(rpcURI string, multicallAddress common.Address) TEthMultiCaller
NewMulticall creates a new instance of a TEthMultiCaller. This is the instance we will later use to perform multiple ethereum calls batched in the same transaction. For performance reason, this should be initialized once and then reused.
func (*TEthMultiCaller) ExecuteByBatch ¶
func (caller *TEthMultiCaller) ExecuteByBatch( calls []Call, batchSize uint64, blockNumber *big.Int, ) map[string][]interface{}
ExecuteByBatch will take a group of calls, split them in fixed-size group to avoid the gasLimit error, and execute as many transactions as required to get the results