chains

package
v0.0.0-...-a7498df Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ETHAddressLen = 42

Variables

View Source
var (

	// ZetaChainMainnet is the mainnet chain for Zeta
	ZetaChainMainnet = Chain{
		ChainName:   ChainName_zeta_mainnet,
		ChainId:     7000,
		Network:     Network_zeta,
		NetworkType: NetworkType_mainnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_tendermint,
		IsExternal:  false,
		CctxGateway: CCTXGateway_zevm,
		Name:        "zeta_mainnet",
	}

	// Ethereum is Ethereum mainnet
	Ethereum = Chain{
		ChainName:   ChainName_eth_mainnet,
		ChainId:     1,
		Network:     Network_eth,
		NetworkType: NetworkType_mainnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_ethereum,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "eth_mainnet",
	}

	// BscMainnet is Binance Smart Chain mainnet
	BscMainnet = Chain{
		ChainName:   ChainName_bsc_mainnet,
		ChainId:     56,
		Network:     Network_bsc,
		NetworkType: NetworkType_mainnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_ethereum,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "bsc_mainnet",
	}

	// BitcoinMainnet is Bitcoin mainnet
	BitcoinMainnet = Chain{
		ChainName:   ChainName_btc_mainnet,
		ChainId:     8332,
		Network:     Network_btc,
		NetworkType: NetworkType_mainnet,
		Vm:          Vm_no_vm,
		Consensus:   Consensus_bitcoin,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "btc_mainnet",
	}

	// Polygon is Polygon mainnet
	Polygon = Chain{
		ChainName:   ChainName_polygon_mainnet,
		ChainId:     137,
		Network:     Network_polygon,
		NetworkType: NetworkType_mainnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_ethereum,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "polygon_mainnet",
	}

	// OptimismMainnet is Optimism mainnet
	OptimismMainnet = Chain{
		ChainName:   ChainName_optimism_mainnet,
		ChainId:     10,
		Network:     Network_optimism,
		NetworkType: NetworkType_mainnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_op_stack,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "optimism_mainnet",
	}

	// BaseMainnet is Base mainnet
	BaseMainnet = Chain{
		ChainName:   ChainName_base_mainnet,
		ChainId:     8453,
		Network:     Network_base,
		NetworkType: NetworkType_mainnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_op_stack,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "base_mainnet",
	}

	// SolanaMainnet is Solana mainnet
	// TODO: define final chain ID
	// https://github.com/zeta-chain/node/issues/2421
	SolanaMainnet = Chain{
		ChainName:   ChainName_solana_mainnet,
		ChainId:     900,
		Network:     Network_solana,
		NetworkType: NetworkType_mainnet,
		Vm:          Vm_svm,
		Consensus:   Consensus_solana_consensus,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "solana_mainnet",
	}

	TONMainnet = Chain{

		ChainId:     2015140,
		Network:     Network_ton,
		NetworkType: NetworkType_mainnet,
		Vm:          Vm_tvm,
		Consensus:   Consensus_catchain_consensus,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "ton_mainnet",
	}

	// ZetaChainTestnet is the testnet chain for Zeta
	ZetaChainTestnet = Chain{
		ChainName:   ChainName_zeta_testnet,
		ChainId:     7001,
		Network:     Network_zeta,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_tendermint,
		IsExternal:  false,
		CctxGateway: CCTXGateway_zevm,
		Name:        "zeta_testnet",
	}

	// Sepolia is Ethereum sepolia testnet
	Sepolia = Chain{
		ChainName:   ChainName_sepolia_testnet,
		ChainId:     11155111,
		Network:     Network_eth,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_ethereum,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "sepolia_testnet",
	}

	// BscTestnet is Binance Smart Chain testnet
	BscTestnet = Chain{
		ChainName:   ChainName_bsc_testnet,
		ChainId:     97,
		Network:     Network_bsc,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_ethereum,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "bsc_testnet",
	}

	// BitcoinTestnet is Bitcoin testnet3
	BitcoinTestnet = Chain{
		ChainName:   ChainName_btc_testnet,
		ChainId:     18332,
		Network:     Network_btc,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_no_vm,
		Consensus:   Consensus_bitcoin,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "btc_testnet",
	}

	// BitcoinSignetTestnet is Bitcoin Signet testnet
	BitcoinSignetTestnet = Chain{
		ChainId:     18333,
		Network:     Network_btc,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_no_vm,
		Consensus:   Consensus_bitcoin,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "btc_signet_testnet",
	}

	// BitcoinTestnet4 is Bitcoin testnet4
	BitcoinTestnet4 = Chain{
		ChainId:     18334,
		Network:     Network_btc,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_no_vm,
		Consensus:   Consensus_bitcoin,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "btc_testnet4",
	}

	// Amoy is Polygon amoy testnet
	Amoy = Chain{
		ChainName:   ChainName_amoy_testnet,
		ChainId:     80002,
		Network:     Network_polygon,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_ethereum,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "amoy_testnet",
	}

	// OptimismSepolia is Optimism sepolia testnet
	OptimismSepolia = Chain{
		ChainName:   ChainName_optimism_sepolia,
		ChainId:     11155420,
		Network:     Network_optimism,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_op_stack,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "optimism_sepolia",
	}

	// BaseSepolia is Base sepolia testnet
	BaseSepolia = Chain{
		ChainName:   ChainName_base_sepolia,
		ChainId:     84532,
		Network:     Network_base,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_op_stack,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "base_sepolia",
	}

	// SolanaDevnet is Solana devnet
	// NOTE: Solana devnet refers to Solana testnet in our terminology
	// Solana uses devnet denomitation for network for development
	// TODO: define final chain ID
	// https://github.com/zeta-chain/node/issues/2421
	SolanaDevnet = Chain{
		ChainName:   ChainName_solana_devnet,
		ChainId:     901,
		Network:     Network_solana,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_svm,
		Consensus:   Consensus_solana_consensus,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "solana_devnet",
	}

	TONTestnet = Chain{
		ChainId:     2015141,
		Network:     Network_ton,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_tvm,
		Consensus:   Consensus_catchain_consensus,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "ton_testnet",
	}

	// ZetaChainDevnet is the devnet chain for Zeta
	// used as live testing environment
	ZetaChainDevnet = Chain{
		ChainName:   ChainName_zeta_mainnet,
		ChainId:     70000,
		Network:     Network_zeta,
		NetworkType: NetworkType_devnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_tendermint,
		IsExternal:  false,
		CctxGateway: CCTXGateway_zevm,
		Name:        "zeta_mainnet",
	}

	// ZetaChainPrivnet is the privnet chain for Zeta (localnet)
	ZetaChainPrivnet = Chain{
		ChainName:   ChainName_zeta_mainnet,
		ChainId:     101,
		Network:     Network_zeta,
		NetworkType: NetworkType_privnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_tendermint,
		IsExternal:  false,
		CctxGateway: CCTXGateway_zevm,
		Name:        "zeta_mainnet",
	}

	// BitcoinRegtest is Bitcoin regtest (localnet)
	BitcoinRegtest = Chain{
		ChainName:   ChainName_btc_regtest,
		ChainId:     18444,
		Network:     Network_btc,
		NetworkType: NetworkType_privnet,
		Vm:          Vm_no_vm,
		Consensus:   Consensus_bitcoin,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "btc_regtest",
	}

	// GoerliLocalnet is Ethereum local goerli (localnet)
	GoerliLocalnet = Chain{
		ChainName:   ChainName_goerli_localnet,
		ChainId:     1337,
		Network:     Network_eth,
		NetworkType: NetworkType_privnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_ethereum,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "goerli_localnet",
	}

	// SolanaLocalnet is Solana localnet
	// TODO: define final chain ID
	// https://github.com/zeta-chain/node/issues/2421
	SolanaLocalnet = Chain{
		ChainName:   ChainName_solana_localnet,
		ChainId:     902,
		Network:     Network_solana,
		NetworkType: NetworkType_privnet,
		Vm:          Vm_svm,
		Consensus:   Consensus_solana_consensus,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "solana_localnet",
	}

	TONLocalnet = Chain{
		ChainId:     2015142,
		Network:     Network_ton,
		NetworkType: NetworkType_privnet,
		Vm:          Vm_tvm,
		Consensus:   Consensus_catchain_consensus,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "ton_localnet",
	}

	// Goerli is Ethereum goerli testnet (deprecated for sepolia)
	Goerli = Chain{
		ChainName:   ChainName_goerli_testnet,
		ChainId:     5,
		Network:     Network_eth,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_ethereum,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "goerli_testnet",
	}

	// Mumbai is Polygon mumbai testnet (deprecated for amoy)
	Mumbai = Chain{
		ChainName:   ChainName_mumbai_testnet,
		ChainId:     80001,
		Network:     Network_polygon,
		NetworkType: NetworkType_testnet,
		Vm:          Vm_evm,
		Consensus:   Consensus_ethereum,
		IsExternal:  true,
		CctxGateway: CCTXGateway_observers,
		Name:        "mumbai_testnet",
	}
)
View Source
var (
	ErrInvalidLengthChains        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowChains          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupChains = fmt.Errorf("proto: unexpected end of group")
)
View Source
var CCTXGateway_name = map[int32]string{
	0: "zevm",
	1: "observers",
}
View Source
var CCTXGateway_value = map[string]int32{
	"zevm":      0,
	"observers": 1,
}
View Source
var ChainName_name = map[int32]string{
	0:  "empty",
	1:  "eth_mainnet",
	2:  "zeta_mainnet",
	3:  "btc_mainnet",
	4:  "polygon_mainnet",
	5:  "bsc_mainnet",
	6:  "goerli_testnet",
	7:  "mumbai_testnet",
	10: "bsc_testnet",
	11: "zeta_testnet",
	12: "btc_testnet",
	13: "sepolia_testnet",
	14: "goerli_localnet",
	15: "btc_regtest",
	16: "amoy_testnet",
	17: "optimism_mainnet",
	18: "optimism_sepolia",
	19: "base_mainnet",
	20: "base_sepolia",
	21: "solana_mainnet",
	22: "solana_devnet",
	23: "solana_localnet",
}
View Source
var ChainName_value = map[string]int32{
	"empty":            0,
	"eth_mainnet":      1,
	"zeta_mainnet":     2,
	"btc_mainnet":      3,
	"polygon_mainnet":  4,
	"bsc_mainnet":      5,
	"goerli_testnet":   6,
	"mumbai_testnet":   7,
	"bsc_testnet":      10,
	"zeta_testnet":     11,
	"btc_testnet":      12,
	"sepolia_testnet":  13,
	"goerli_localnet":  14,
	"btc_regtest":      15,
	"amoy_testnet":     16,
	"optimism_mainnet": 17,
	"optimism_sepolia": 18,
	"base_mainnet":     19,
	"base_sepolia":     20,
	"solana_mainnet":   21,
	"solana_devnet":    22,
	"solana_localnet":  23,
}
View Source
var Consensus_name = map[int32]string{
	0: "ethereum",
	1: "tendermint",
	2: "bitcoin",
	3: "op_stack",
	4: "solana_consensus",
	5: "catchain_consensus",
}
View Source
var Consensus_value = map[string]int32{
	"ethereum":           0,
	"tendermint":         1,
	"bitcoin":            2,
	"op_stack":           3,
	"solana_consensus":   4,
	"catchain_consensus": 5,
}
View Source
var (
	DeadAddress = eth.HexToAddress("0xdEAD000000000000000042069420694206942069")
)
View Source
var ErrNotZetaChain = fmt.Errorf("chain is not a ZetaChain chain")

ErrNotZetaChain is the error for chain not being a ZetaChain chain

View Source
var NetworkType_name = map[int32]string{
	0: "mainnet",
	1: "testnet",
	2: "privnet",
	3: "devnet",
}
View Source
var NetworkType_value = map[string]int32{
	"mainnet": 0,
	"testnet": 1,
	"privnet": 2,
	"devnet":  3,
}
View Source
var Network_name = map[int32]string{
	0: "eth",
	1: "zeta",
	2: "btc",
	3: "polygon",
	4: "bsc",
	5: "optimism",
	6: "base",
	7: "solana",
	8: "ton",
}
View Source
var Network_value = map[string]int32{
	"eth":      0,
	"zeta":     1,
	"btc":      2,
	"polygon":  3,
	"bsc":      4,
	"optimism": 5,
	"base":     6,
	"solana":   7,
	"ton":      8,
}
View Source
var ReceiveStatus_name = map[int32]string{
	0: "created",
	1: "success",
	2: "failed",
}
View Source
var ReceiveStatus_value = map[string]int32{
	"created": 0,
	"success": 1,
	"failed":  2,
}
View Source
var Vm_name = map[int32]string{
	0: "no_vm",
	1: "evm",
	2: "svm",
	3: "tvm",
}
View Source
var Vm_value = map[string]int32{
	"no_vm": 0,
	"evm":   1,
	"svm":   2,
	"tvm":   3,
}

Functions

func BitcoinChainIDFromNetworkName

func BitcoinChainIDFromNetworkName(name string) (int64, error)

BitcoinChainIDFromNetworkName returns the chain id for the given bitcoin network name

func BitcoinNetParamsFromChainID

func BitcoinNetParamsFromChainID(chainID int64) (*chaincfg.Params, error)

BitcoinNetParamsFromChainID returns the bitcoin net params to be used from the chain id

func BtcNonceMarkOffset

func BtcNonceMarkOffset() int64

BtcNonceMarkOffset is the offset satoshi amount to calculate the nonce mark output

func ChainIDInChainList

func ChainIDInChainList(chainID int64, chainList []Chain) bool

ChainIDInChainList checks whether the chainID is in the chain list

func ConvertRecoverToError

func ConvertRecoverToError(r interface{}) error

func CosmosToEthChainID

func CosmosToEthChainID(chainID string) (int64, error)

CosmosToEthChainID converts a Cosmos chain ID to an Ethereum chain ID parse value between _ and - e.g. cosmoshub_400-1 -> 400

func DecodeAddressFromChainID

func DecodeAddressFromChainID(chainID int64, addr string, additionalChains []Chain) ([]byte, error)

DecodeAddressFromChainID decode the address string to bytes additionalChains is a list of additional chains to search from in practice, it is used in the protocol to dynamically support new chains without doing an upgrade

func DecodeBtcAddress

func DecodeBtcAddress(inputAddress string, chainID int64) (address btcutil.Address, err error)

DecodeBtcAddress decodes a BTC address from a given string and chainID

func DecodeSolanaWalletAddress

func DecodeSolanaWalletAddress(inputAddress string) (pk solana.PublicKey, err error)

DecodeSolanaWalletAddress decodes a Solana wallet address from a given string.

func FilterExternalChains

func FilterExternalChains(c Chain) bool

FilterExternalChains filters chains that are external

func GetBTCChainIDFromChainParams

func GetBTCChainIDFromChainParams(params *chaincfg.Params) (int64, error)

GetBTCChainIDFromChainParams returns the bitcoin chain ID from the chain config params

func GetBTCChainParams

func GetBTCChainParams(chainID int64) (*chaincfg.Params, error)

GetBTCChainParams returns the bitcoin chain config params from the chain ID

func IsBitcoinChain

func IsBitcoinChain(chainID int64, additionalChains []Chain) bool

IsBitcoinChain returns true if the chain is a Bitcoin-based chain or uses the bitcoin consensus mechanism for block finality additionalChains is a list of additional chains to search from in practice, it is used in the protocol to dynamically support new chains without doing an upgrade

func IsBitcoinMainnet

func IsBitcoinMainnet(chainID int64) bool

IsBitcoinMainnet returns true if the chain id is for the mainnet

func IsBitcoinRegnet

func IsBitcoinRegnet(chainID int64) bool

IsBitcoinRegnet returns true if the chain id is for the regnet

func IsBtcAddressSupported

func IsBtcAddressSupported(addr btcutil.Address) bool

IsBtcAddressSupported returns true if the given BTC address is supported

func IsEVMChain

func IsEVMChain(chainID int64, additionalChains []Chain) bool

IsEVMChain returns true if the chain is an EVM chain additionalChains is a list of additional chains to search from in practice, it is used in the protocol to dynamically support new chains without doing an upgrade

func IsEthereumChain

func IsEthereumChain(chainID int64, additionalChains []Chain) bool

IsEthereumChain returns true if the chain is an Ethereum chain additionalChains is a list of additional chains to search from in practice, it is used in the protocol to dynamically support new chains without doing an upgrade

func IsSolanaChain

func IsSolanaChain(chainID int64, additionalChains []Chain) bool

IsSolanaChain returns true if the chain is a Solana chain

func IsTONChain

func IsTONChain(chainID int64, additionalChains []Chain) bool

IsTONChain returns true is the chain is TON chain

func IsZetaChain

func IsZetaChain(chainID int64, additionalChains []Chain) bool

IsZetaChain returns true if the chain is a Zeta chain additionalChains is a list of additional chains to search from in practice, it is used in the protocol to dynamically support new chains without doing an upgrade

func NonceMarkAmount

func NonceMarkAmount(nonce uint64) int64

NonceMarkAmount uses special value to mark current nonce in UTXO

func StringToHash

func StringToHash(chainID int64, hash string, additionalChains []Chain) ([]byte, error)

StringToHash convert string to hash bytes

Types

type Address

type Address string
var NoAddress Address

func NewAddress

func NewAddress(address string) Address

NewAddress create a new Address. Supports Ethereum, BSC, Polygon

func (Address) Equals

func (addr Address) Equals(addr2 Address) bool

func (Address) IsEmpty

func (addr Address) IsEmpty() bool

func (Address) String

func (addr Address) String() string

type CCTXGateway

type CCTXGateway int32

CCTXGateway describes for the chain the gateway used to handle CCTX outbounds

const (
	// zevm is the internal CCTX gateway to process outbound on the ZEVM and read
	// inbound events from the ZEVM only used for ZetaChain chains
	CCTXGateway_zevm CCTXGateway = 0
	// observers is the CCTX gateway for chains relying on the observer set to
	// observe inbounds and TSS for outbounds
	CCTXGateway_observers CCTXGateway = 1
)

func (CCTXGateway) EnumDescriptor

func (CCTXGateway) EnumDescriptor() ([]byte, []int)

func (CCTXGateway) String

func (x CCTXGateway) String() string

type Chain

type Chain struct {
	// ChainId is the unique identifier of the chain
	ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"`
	// ChainName is the name of the chain
	// Deprecated(v19): replaced with Name
	ChainName ChainName `` // Deprecated: Do not use.
	/* 134-byte string literal not displayed */
	// Network is the network of the chain
	Network Network `protobuf:"varint,3,opt,name=network,proto3,enum=zetachain.zetacore.pkg.chains.Network" json:"network,omitempty"`
	// NetworkType is the network type of the chain: mainnet, testnet, etc..
	NetworkType NetworkType `` /* 142-byte string literal not displayed */
	// Vm is the virtual machine used in the chain
	Vm Vm `protobuf:"varint,5,opt,name=vm,proto3,enum=zetachain.zetacore.pkg.chains.Vm" json:"vm,omitempty"`
	// Consensus is the underlying consensus algorithm used by the chain
	Consensus Consensus `protobuf:"varint,6,opt,name=consensus,proto3,enum=zetachain.zetacore.pkg.chains.Consensus" json:"consensus,omitempty"`
	// IsExternal describe if the chain is ZetaChain or external
	IsExternal bool `protobuf:"varint,7,opt,name=is_external,json=isExternal,proto3" json:"is_external,omitempty"`
	// CCTXGateway is the gateway used to handle CCTX outbounds
	CctxGateway CCTXGateway `` /* 142-byte string literal not displayed */
	// Name is the name of the chain
	Name string `protobuf:"bytes,9,opt,name=name,proto3" json:"name,omitempty"`
}

Chain represents static data about a blockchain network it is identified by a unique chain ID

func ChainListByConsensus

func ChainListByConsensus(consensus Consensus, additionalChains []Chain) []Chain

ChainListByConsensus returns a list of chains by consensus

func ChainListByGateway

func ChainListByGateway(gateway CCTXGateway, additionalChains []Chain) []Chain

func ChainListByNetwork

func ChainListByNetwork(network Network, additionalChains []Chain) []Chain

ChainListByNetwork returns a list of chains by network

func ChainListByNetworkType

func ChainListByNetworkType(networkType NetworkType, additionalChains []Chain) []Chain

ChainListByNetworkType returns a list of chains by network type

func CombineChainList

func CombineChainList(base []Chain, additional []Chain) []Chain

CombineChainList combines a list of chains with a list of chains duplicated chain ID are overwritten by the second list

func CombineDefaultChainsList

func CombineDefaultChainsList(chains []Chain) []Chain

CombineDefaultChainsList combines the default chains list with a list of chains duplicated chain ID are overwritten by the second list

func CombineFilterChains

func CombineFilterChains(chainLists ...[]Chain) []Chain

CombineFilterChains combines multiple lists of chains into a single list

func DefaultChainsList

func DefaultChainsList() []Chain

DefaultChainsList returns a list of default chains

func ExternalChainList

func ExternalChainList(additionalChains []Chain) []Chain

ExternalChainList returns a list chains that are not Zeta

func FilterChains

func FilterChains(chainList []Chain, filters ...ChainFilter) []Chain

FilterChains applies a list of filters to a list of chains

func GetChainFromChainID

func GetChainFromChainID(chainID int64, additionalChains []Chain) (Chain, bool)

GetChainFromChainID returns the chain from the chain ID additionalChains is a list of additional chains to search from in practice, it is used in the protocol to dynamically support new chains without doing an upgrade

func ZetaChainFromChainID

func ZetaChainFromChainID(chainID int64) (Chain, error)

ZetaChainFromChainID returns a ZetaChain chain object from a chain ID

func ZetaChainFromCosmosChainID

func ZetaChainFromCosmosChainID(chainID string) (Chain, error)

ZetaChainFromCosmosChainID returns a ZetaChain chain object from a Cosmos chain ID

func (*Chain) Descriptor

func (*Chain) Descriptor() ([]byte, []int)

func (Chain) EncodeAddress

func (chain Chain) EncodeAddress(b []byte) (string, error)

EncodeAddress bytes representations of address on EVM chain, it is 20Bytes on Bitcoin chain, it is P2WPKH address, []byte(bech32 encoded string)

func (*Chain) GetCctxGateway

func (m *Chain) GetCctxGateway() CCTXGateway

func (*Chain) GetChainId

func (m *Chain) GetChainId() int64

func (*Chain) GetChainName deprecated

func (m *Chain) GetChainName() ChainName

Deprecated: Do not use.

func (*Chain) GetConsensus

func (m *Chain) GetConsensus() Consensus

func (*Chain) GetIsExternal

func (m *Chain) GetIsExternal() bool

func (*Chain) GetName

func (m *Chain) GetName() string

func (*Chain) GetNetwork

func (m *Chain) GetNetwork() Network

func (*Chain) GetNetworkType

func (m *Chain) GetNetworkType() NetworkType

func (*Chain) GetVm

func (m *Chain) GetVm() Vm

func (Chain) IsBitcoinChain

func (chain Chain) IsBitcoinChain() bool

func (Chain) IsEVMChain

func (chain Chain) IsEVMChain() bool

func (Chain) IsEmpty

func (chain Chain) IsEmpty() bool

IsEmpty is to determinate whether the chain is empty

func (Chain) IsExternalChain

func (chain Chain) IsExternalChain() bool

IsExternalChain returns true if the chain is an ExternalChain chain, not ZetaChain

func (Chain) IsTONChain

func (chain Chain) IsTONChain() bool

func (Chain) IsZetaChain

func (chain Chain) IsZetaChain() bool

IsZetaChain returns true if the chain is a ZetaChain chain

func (*Chain) Marshal

func (m *Chain) Marshal() (dAtA []byte, err error)

func (*Chain) MarshalTo

func (m *Chain) MarshalTo(dAtA []byte) (int, error)

func (*Chain) MarshalToSizedBuffer

func (m *Chain) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Chain) ProtoMessage

func (*Chain) ProtoMessage()

func (*Chain) Reset

func (m *Chain) Reset()

func (*Chain) Size

func (m *Chain) Size() (n int)

func (*Chain) String

func (m *Chain) String() string

func (*Chain) Unmarshal

func (m *Chain) Unmarshal(dAtA []byte) error

func (Chain) Validate

func (chain Chain) Validate() error

Validate checks whether the chain is valid The function check the chain ID is positive and all enum fields have a defined value

func (*Chain) XXX_DiscardUnknown

func (m *Chain) XXX_DiscardUnknown()

func (*Chain) XXX_Marshal

func (m *Chain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Chain) XXX_Merge

func (m *Chain) XXX_Merge(src proto.Message)

func (*Chain) XXX_Size

func (m *Chain) XXX_Size() int

func (*Chain) XXX_Unmarshal

func (m *Chain) XXX_Unmarshal(b []byte) error

type ChainFilter

type ChainFilter func(c Chain) bool

ChainFilter is a function that filters chains based on some criteria

func FilterByConsensus

func FilterByConsensus(cs Consensus) ChainFilter

FilterByConsensus filters chains by consensus type

func FilterByGateway

func FilterByGateway(gw CCTXGateway) ChainFilter

FilterByGateway filters chains by gateway

type ChainName

type ChainName int32

ChainName represents the name of the chain Deprecated(v19): replaced with Chain.Name as string

const (
	ChainName_empty            ChainName = 0
	ChainName_eth_mainnet      ChainName = 1
	ChainName_zeta_mainnet     ChainName = 2
	ChainName_btc_mainnet      ChainName = 3
	ChainName_polygon_mainnet  ChainName = 4
	ChainName_bsc_mainnet      ChainName = 5
	ChainName_goerli_testnet   ChainName = 6
	ChainName_mumbai_testnet   ChainName = 7
	ChainName_bsc_testnet      ChainName = 10
	ChainName_zeta_testnet     ChainName = 11
	ChainName_btc_testnet      ChainName = 12
	ChainName_sepolia_testnet  ChainName = 13
	ChainName_goerli_localnet  ChainName = 14
	ChainName_btc_regtest      ChainName = 15
	ChainName_amoy_testnet     ChainName = 16
	ChainName_optimism_mainnet ChainName = 17
	ChainName_optimism_sepolia ChainName = 18
	ChainName_base_mainnet     ChainName = 19
	ChainName_base_sepolia     ChainName = 20
	ChainName_solana_mainnet   ChainName = 21
	ChainName_solana_devnet    ChainName = 22
	ChainName_solana_localnet  ChainName = 23
)

func (ChainName) EnumDescriptor

func (ChainName) EnumDescriptor() ([]byte, []int)

func (ChainName) String

func (x ChainName) String() string

type Consensus

type Consensus int32

Consensus represents the consensus algorithm used by the chain this can represent the consensus of a L1 this can also represent the solution of a L2

const (
	Consensus_ethereum           Consensus = 0
	Consensus_tendermint         Consensus = 1
	Consensus_bitcoin            Consensus = 2
	Consensus_op_stack           Consensus = 3
	Consensus_solana_consensus   Consensus = 4
	Consensus_catchain_consensus Consensus = 5
)

func (Consensus) EnumDescriptor

func (Consensus) EnumDescriptor() ([]byte, []int)

func (Consensus) String

func (x Consensus) String() string

type Network

type Network int32

Network represents the network of the chain there is a single instance of the network on mainnet then the network can have eventual testnets or devnets

const (
	Network_eth      Network = 0
	Network_zeta     Network = 1
	Network_btc      Network = 2
	Network_polygon  Network = 3
	Network_bsc      Network = 4
	Network_optimism Network = 5
	Network_base     Network = 6
	Network_solana   Network = 7
	Network_ton      Network = 8
)

func (Network) EnumDescriptor

func (Network) EnumDescriptor() ([]byte, []int)

func (Network) String

func (x Network) String() string

type NetworkType

type NetworkType int32

NetworkType represents the network type of the chain Mainnet, Testnet, Privnet, Devnet

const (
	NetworkType_mainnet NetworkType = 0
	NetworkType_testnet NetworkType = 1
	NetworkType_privnet NetworkType = 2
	NetworkType_devnet  NetworkType = 3
)

func (NetworkType) EnumDescriptor

func (NetworkType) EnumDescriptor() ([]byte, []int)

func (NetworkType) String

func (x NetworkType) String() string

type ReceiveStatus

type ReceiveStatus int32

ReceiveStatus represents the status of an outbound TODO: Rename and move https://github.com/zeta-chain/node/issues/2257

const (
	// Created is used for inbounds
	ReceiveStatus_created ReceiveStatus = 0
	ReceiveStatus_success ReceiveStatus = 1
	ReceiveStatus_failed  ReceiveStatus = 2
)

func ReceiveStatusFromString

func ReceiveStatusFromString(str string) (ReceiveStatus, error)

ReceiveStatusFromString returns a ReceiveStatus from a string using in CLI 0 for success, 1 for failed TODO: remove "receive" naming ans use outbound https://github.com/zeta-chain/node/issues/1797

func (ReceiveStatus) EnumDescriptor

func (ReceiveStatus) EnumDescriptor() ([]byte, []int)

func (ReceiveStatus) String

func (x ReceiveStatus) String() string

type Vm

type Vm int32

Vm represents the virtual machine type of the chain to support smart contracts

const (
	Vm_no_vm Vm = 0
	Vm_evm   Vm = 1
	Vm_svm   Vm = 2
	Vm_tvm   Vm = 3
)

func (Vm) EnumDescriptor

func (Vm) EnumDescriptor() ([]byte, []int)

func (Vm) String

func (x Vm) String() string

Jump to

Keyboard shortcuts

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