router

package
v3.0.0-...-e8b7a4c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2023 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package router inits bridges and loads onchain configs.

Index

Constants

This section is empty.

Variables

View Source
var (
	RouterBridges    = new(sync.Map) // key is chainID
	MultichainTokens = new(sync.Map) // key is tokenID,chainID
	AllChainIDs      []*big.Int      // all chainIDs is retrieved only once
	AllTokenIDs      []string        // all tokenIDs can be reload

	MPCPublicKeys = new(sync.Map) // key is mpc address
	RouterInfos   = new(sync.Map) // key is router contract address

	CachedLatestBlockNumber = new(sync.Map) // key is chainID

	IsIniting              bool
	IsReloading            bool
	RetryRPCCountInInit    = 3
	RetryRPCIntervalInInit = 3 * time.Second
)

router bridges

Functions

func AddPausedChainIDs

func AddPausedChainIDs(chainIDs []string)

AddPausedChainIDs add paused chainIDs

func CallOnchainContract

func CallOnchainContract(data hexutil.Bytes, blockNumber string) (result []byte, err error)

CallOnchainContract call onchain contract

func DontPanicInLoading

func DontPanicInLoading() bool

DontPanicInLoading don't panic in loading

func GetAllChainIDs

func GetAllChainIDs() (chainIDs []*big.Int, err error)

GetAllChainIDs abi

func GetAllTokenIDs

func GetAllTokenIDs() (tokenIDs []string, err error)

GetAllTokenIDs abi

func GetBridgeByChainID

func GetBridgeByChainID(chainID string) tokens.IBridge

GetBridgeByChainID get bridge by chain id

func GetCachedLatestBlockNumber

func GetCachedLatestBlockNumber(chainID string) uint64

GetCachedLatestBlockNumber get cached latest block number

func GetCachedMultichainToken

func GetCachedMultichainToken(tokenID, chainID string) (tokenAddr string)

GetCachedMultichainToken get multichain token address by tokenid and chainid

func GetCachedMultichainTokens

func GetCachedMultichainTokens(tokenID string) *sync.Map

GetCachedMultichainTokens get multichain tokens of `tokenid`

func GetChainConfig

func GetChainConfig(chainID *big.Int) (*tokens.ChainConfig, error)

GetChainConfig abi

func GetCustomConfig

func GetCustomConfig(chainID *big.Int, key string) (string, error)

GetCustomConfig abi

func GetExtraConfig

func GetExtraConfig(key string) (string, error)

GetExtraConfig abi

func GetFeeConfig

func GetFeeConfig(tokenID string, fromChainID, toChainID *big.Int) (*tokens.FeeConfig, error)

GetFeeConfig abi

func GetMPCPubkey

func GetMPCPubkey(mpcAddress string) (pubkey string, err error)

GetMPCPubkey abi

func GetMPCPublicKey

func GetMPCPublicKey(mpc string) string

GetMPCPublicKey get mpc puvlic key

func GetMultichainToken

func GetMultichainToken(tokenID string, chainID *big.Int) (tokenAddr string, err error)

GetMultichainToken abi

func GetPausedChainIDs

func GetPausedChainIDs() []*big.Int

GetPausedChainIDs get paused chainIDs

func GetRouterMPC

func GetRouterMPC(tokenID, chainID string) (string, error)

GetRouterMPC get router mpc on dest chain (to build swapin tx)

func GetSwapConfig

func GetSwapConfig(tokenID string, fromChainID, toChainID *big.Int) (*tokens.SwapConfig, error)

GetSwapConfig abi

func GetTokenConfig

func GetTokenConfig(chainID *big.Int, token string) (tokenCfg *tokens.TokenConfig, err error)

GetTokenConfig abi

func GetTokenRouterContract

func GetTokenRouterContract(tokenID, chainID string) (string, error)

GetTokenRouterContract get token router contract

func InitOnchainCustomConfig

func InitOnchainCustomConfig(chainID *big.Int, tokenID string)

InitOnchainCustomConfig init onchain custom config

func InitRouterConfigClients

func InitRouterConfigClients()

InitRouterConfigClients init router config clients

func InitRouterConfigClientsWithArgs

func InitRouterConfigClientsWithArgs(configContract string, gateways []string)

InitRouterConfigClientsWithArgs init standalone

func InitWebSocketClients

func InitWebSocketClients(wsServers []string) []*ethclient.Client

InitWebSocketClients init

func IsBigValueSwap

func IsBigValueSwap(swapInfo *tokens.SwapTxInfo) bool

IsBigValueSwap is big value swap

func IsBlacklistSwap

func IsBlacklistSwap(swapInfo *tokens.SwapTxInfo) bool

IsBlacklistSwap is swap blacked

func IsChainIDExist

func IsChainIDExist(chainID *big.Int) (exist bool, err error)

IsChainIDExist abi

func IsChainIDPaused

func IsChainIDPaused(chainID string) bool

IsChainIDPaused is chainID paused

func IsNonceSupported

func IsNonceSupported(chainID string) bool

IsNonceSupported is nonce supported

func IsReswapSupported

func IsReswapSupported(chainID string) bool

IsReswapSupported is reswap supported

func IsTokenIDExist

func IsTokenIDExist(tokenID string) (exist bool, err error)

IsTokenIDExist abi

func ParseRouterContractConfig

func ParseRouterContractConfig(routerContractCfg string) (routerContract, routerVersion string)

ParseRouterContractConfig parse router contract config

func PrintMultichainTokens

func PrintMultichainTokens()

PrintMultichainTokens print

func RemovePausedChainIDs

func RemovePausedChainIDs(chainIDs []string)

RemovePausedChainIDs remove paused chainIDs

func SetBridge

func SetBridge(chainID string, bridge tokens.IBridge)

SetBridge set bridge

func SetMPCPublicKey

func SetMPCPublicKey(mpc, pubkey string)

SetMPCPublicKey set router mpc public key

func SetMultichainToken

func SetMultichainToken(tokenID, chainID, tokenAddr string)

SetMultichainToken set multichain token

func SetMultichainTokens

func SetMultichainTokens(tokenID string, tokensMap *sync.Map)

SetMultichainTokens set multichain tokens

func SetRouterInfo

func SetRouterInfo(router, chainID string, routerInfo *SwapRouterInfo)

SetRouterInfo set router info

func SubscribeRouterConfig

func SubscribeRouterConfig(topics []ethcommon.Hash)

SubscribeRouterConfig subscribe router config

func SubscribeUpdateConfig

func SubscribeUpdateConfig(callback func() bool)

SubscribeUpdateConfig subscribe update ID and reload configs

Types

type ChainConfigInContract

type ChainConfigInContract struct {
	ChainID        string
	BlockChain     string
	RouterContract string
	Confirmations  uint64
	InitialHeight  uint64
	Extra          string
}

ChainConfigInContract struct

func GetAllChainConfig

func GetAllChainConfig() ([]*ChainConfigInContract, error)

GetAllChainConfig abi

type FeeConfigInContract

type FeeConfigInContract struct {
	FromChainID           *big.Int
	ToChainID             *big.Int
	MaximumSwapFee        *big.Int
	MinimumSwapFee        *big.Int
	SwapFeeRatePerMillion uint64
}

FeeConfigInContract struct

func GetFeeConfigs

func GetFeeConfigs(tokenID string) ([]FeeConfigInContract, error)

GetFeeConfigs get fee configs by tokenID

type MultichainToken

type MultichainToken struct {
	ChainID      *big.Int
	TokenAddress string
}

MultichainToken struct

func GetAllMultichainTokens

func GetAllMultichainTokens(tokenID string) ([]MultichainToken, error)

GetAllMultichainTokens abi

type SwapConfigInContract

type SwapConfigInContract struct {
	FromChainID       *big.Int
	ToChainID         *big.Int
	MaximumSwap       *big.Int
	MinimumSwap       *big.Int
	BigValueThreshold *big.Int
}

SwapConfigInContract struct

func GetSwapConfigs

func GetSwapConfigs(tokenID string) ([]SwapConfigInContract, error)

GetSwapConfigs get swap configs by tokenID

type SwapRouterInfo

type SwapRouterInfo struct {
	RouterMPC      string
	RouterPDA      string `json:",omitempty"`
	RouterWNative  string `json:",omitempty"`
	RouterSecurity string `json:",omitempty"`
}

SwapRouterInfo swap router info

func GetRouterInfo

func GetRouterInfo(router, chainID string) *SwapRouterInfo

GetRouterInfo get router info

func GetTokenRouterInfo

func GetTokenRouterInfo(tokenID, chainID string) (*SwapRouterInfo, error)

GetTokenRouterInfo get token router info

type TokenConfigInContract

type TokenConfigInContract struct {
	ChainID         string
	Decimals        uint8
	ContractAddress string
	ContractVersion uint64
	RouterContract  string
	Extra           string
}

TokenConfigInContract struct

func GetAllMultichainTokenConfig

func GetAllMultichainTokenConfig(tokenID string) ([]*TokenConfigInContract, error)

GetAllMultichainTokenConfig abi

Directories

Path Synopsis
Package bridge init router bridge and load / reload configs.
Package bridge init router bridge and load / reload configs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL