router

package
v3.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 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 added in v3.5.1

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 added in v3.6.0

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 added in v3.6.1

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 added in v3.6.0

func GetExtraConfig(key string) (string, error)

GetExtraConfig abi

func GetFeeConfig added in v3.6.0

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 added in v3.5.0

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 added in v3.5.1

func GetPausedChainIDs() []*big.Int

GetPausedChainIDs get paused chainIDs

func GetRouterMPC added in v3.5.0

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

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

func GetSwapConfig added in v3.2.0

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 added in v3.5.0

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

GetTokenRouterContract get token router contract

func InitOnchainCustomConfig added in v3.6.1

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 added in v3.4.0

func IsBigValueSwap(swapInfo *tokens.SwapTxInfo) bool

IsBigValueSwap is big value swap

func IsBlacklistSwap added in v3.4.0

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 added in v3.5.1

func IsChainIDPaused(chainID string) bool

IsChainIDPaused is chainID paused

func IsNonceSupported added in v3.6.1

func IsNonceSupported(chainID string) bool

IsNonceSupported is nonce supported

func IsTokenIDExist

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

IsTokenIDExist abi

func ParseRouterContractConfig added in v3.6.2

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

ParseRouterContractConfig parse router contract config

func PrintMultichainTokens

func PrintMultichainTokens()

PrintMultichainTokens print

func RemovePausedChainIDs added in v3.5.1

func RemovePausedChainIDs(chainIDs []string)

RemovePausedChainIDs remove paused chainIDs

func SetBridge added in v3.5.2

func SetBridge(chainID string, bridge tokens.IBridge)

SetBridge set bridge

func SetMPCPublicKey added in v3.5.0

func SetMPCPublicKey(mpc, pubkey string)

SetMPCPublicKey set router mpc public key

func SetMultichainToken added in v3.5.2

func SetMultichainToken(tokenID, chainID, tokenAddr string)

SetMultichainToken set multichain token

func SetMultichainTokens added in v3.5.2

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

SetMultichainTokens set multichain tokens

func SetRouterInfo added in v3.5.0

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 added in v3.6.0

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

ChainConfigInContract struct

func GetAllChainConfig added in v3.6.0

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

GetAllChainConfig abi

type FeeConfigInContract added in v3.6.0

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

FeeConfigInContract struct

func GetFeeConfigs added in v3.6.0

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 added in v3.6.0

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

SwapConfigInContract struct

func GetSwapConfigs added in v3.6.0

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

GetSwapConfigs get swap configs by tokenID

type SwapRouterInfo added in v3.5.0

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

SwapRouterInfo swap router info

func GetRouterInfo added in v3.5.0

func GetRouterInfo(router, chainID string) *SwapRouterInfo

GetRouterInfo get router info

func GetTokenRouterInfo added in v3.5.0

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

GetTokenRouterInfo get token router info

type TokenConfigInContract added in v3.6.0

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

TokenConfigInContract struct

func GetAllMultichainTokenConfig added in v3.6.0

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