chains

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const ETHAddressLen = 42

Variables

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 (
	DeadAddress = eth.HexToAddress("0xdEAD000000000000000042069420694206942069")
)
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:  "PELL",
	2:  "BTC",
	3:  "POLYGON",
	4:  "BSC",
	5:  "GOERLI",
	6:  "MUMBAI",
	7:  "GANACHE",
	8:  "BAOBAB",
	9:  "SEPOLIA",
	10: "AMOY",
	11: "OPTIMISM",
	12: "BASE",
	13: "CORE",
	14: "MANTLE",
	15: "ARBITRUM",
	16: "BITLAYER",
}
View Source
var NetWork_value = map[string]int32{
	"ETH":      0,
	"PELL":     1,
	"BTC":      2,
	"POLYGON":  3,
	"BSC":      4,
	"GOERLI":   5,
	"MUMBAI":   6,
	"GANACHE":  7,
	"BAOBAB":   8,
	"SEPOLIA":  9,
	"AMOY":     10,
	"OPTIMISM": 11,
	"BASE":     12,
	"CORE":     13,
	"MANTLE":   14,
	"ARBITRUM": 15,
	"BITLAYER": 16,
}
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 VMType_name = map[int32]string{
	0: "NO_VM",
	1: "EVM",
	2: "SVM",
}
View Source
var VMType_value = map[string]int32{
	"NO_VM": 0,
	"EVM":   1,
	"SVM":   2,
}

Functions

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) ([]byte, error)

DecodeAddressFromChainID decode the address string to bytes

func FilterExternalChains

func FilterExternalChains(c *Chain) bool

FilterExternalChains filters chains that are external

func HashToString

func HashToString(chainID int64, blockHash []byte) (string, error)

HashToString convert hash bytes to string

func IsEVMChain

func IsEVMChain(chainID int64) bool

IsEVMChain returns true if the chain is an EVM chain

func IsEthereumChain

func IsEthereumChain(chainID int64) bool

// IsEthereumChain returns true if the chain is an Ethereum chain // TODO: put this information directly in chain object

func IsHeaderSupportedEvmChain

func IsHeaderSupportedEvmChain(chainID int64) bool

IsHeaderSupportedEvmChain returns true if the chain is an EVM chain supporting block header-based verification TODO: put this information directly in chain object

func IsPellChain

func IsPellChain(chainID int64) bool

func ParseAddressAndData

func ParseAddressAndData(message string) (ethcommon.Address, []byte, error)

ParseAddressAndData parses the message string into an address and data message is hex encoded byte array [ contractAddress calldata ] [ 20B, variable]

func PayToWitnessTaprootScript

func PayToWitnessTaprootScript(rawKey []byte) ([]byte, error)

PayToWitnessTaprootScript creates a new script to pay to a version 1 (taproot) witness program. The passed hash is expected to be valid.

func StringToHash

func StringToHash(chainID int64, hash string) ([]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 AddressSegWit

type AddressSegWit struct {
	// contains filtered or unexported fields
}

func (AddressSegWit) EncodeAddress

func (a AddressSegWit) EncodeAddress() string

EncodeAddress returns the bech32 (or bech32m for SegWit v1) string encoding of an AddressSegWit.

NOTE: This method is part of the Address interface.

func (*AddressSegWit) IsForNet

func (a *AddressSegWit) IsForNet(net *chaincfg.Params) bool

IsForNet returns whether the AddressSegWit is associated with the passed bitcoin network.

NOTE: This method is part of the Address interface.

func (*AddressSegWit) ScriptAddress

func (a *AddressSegWit) ScriptAddress() []byte

ScriptAddress returns the witness program for this address.

NOTE: This method is part of the Address interface.

func (*AddressSegWit) String

func (a *AddressSegWit) String() string

String returns a human-readable string for the AddressWitnessPubKeyHash. This is equivalent to calling EncodeAddress, but is provided so the type can be used as a fmt.Stringer.

NOTE: This method is part of the Address interface.

type AddressTaproot

type AddressTaproot struct {
	AddressSegWit
}

func DecodeTaprootAddress

func DecodeTaprootAddress(addr string) (*AddressTaproot, error)

DecodeTaprootAddress decodes taproot address only and returns error on non-taproot address

func NewAddressTaproot

func NewAddressTaproot(witnessProg []byte,
	net *chaincfg.Params) (*AddressTaproot, error)

NewAddressTaproot returns a new AddressTaproot.

type Chain

type Chain struct {
	Id          int64       `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Network     NetWork     `protobuf:"varint,2,opt,name=network,proto3,enum=pkg.chains.NetWork" json:"network,omitempty"`
	NetworkType NetWorkType `protobuf:"varint,3,opt,name=network_type,json=networkType,proto3,enum=pkg.chains.NetWorkType" json:"network_type,omitempty"`
	VmType      VMType      `protobuf:"varint,4,opt,name=vm_type,json=vmType,proto3,enum=pkg.chains.VMType" json:"vm_type,omitempty"`
}

Chain represent a chain

func BscMainnetChain

func BscMainnetChain() Chain

func BscTestnetChain

func BscTestnetChain() Chain

func ChainsList

func ChainsList() []Chain

ChainsList returns a list of default chains

func CombineFilterChains

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

CombineFilterChains combines multiple lists of chains into a single list

func CoreTestNetChain

func CoreTestNetChain() Chain

func EthChain

func EthChain() Chain

func ExternalChainList

func ExternalChainList() []Chain

func FilterChains

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

FilterChains applies a list of filters to a list of chains

func FindChain

func FindChain(filter func(Chain) bool) (Chain, bool)

func FindChains

func FindChains(filter func(Chain) bool) []Chain

func GetChainByChainId

func GetChainByChainId(id int64) (Chain, bool)

func GoerliChain

func GoerliChain() Chain

chain simple define

func GoerliLocalnetChain

func GoerliLocalnetChain() Chain

func MumbaiChain

func MumbaiChain() Chain

func PellChainFromChainID

func PellChainFromChainID(chainID string) (Chain, error)

PellChainFromChainID returns a PellChain chainobject from a Cosmos chain ID

func PellChainMainnet

func PellChainMainnet() Chain

func PellPrivnetChain

func PellPrivnetChain() Chain

func PellTestnetChain

func PellTestnetChain() Chain

func PrivnetChainList

func PrivnetChainList() []Chain

func SepoliaChain

func SepoliaChain() Chain

func (Chain) ChainName

func (c Chain) ChainName() string

func (Chain) DecodeAddress

func (chain Chain) DecodeAddress(addr string) ([]byte, error)

DecodeAddress decode the address string to bytes

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) GetId

func (m *Chain) GetId() int64

func (*Chain) GetNetwork

func (m *Chain) GetNetwork() NetWork

func (*Chain) GetNetworkType

func (m *Chain) GetNetworkType() NetWorkType

func (*Chain) GetVmType

func (m *Chain) GetVmType() VMType

func (Chain) InChainList

func (chain Chain) InChainList(chainList []*Chain) bool

InChainList checks whether the chain is in the chain list

func (Chain) IsEmpty

func (chain Chain) IsEmpty() bool

IsEmpty is to determinate whether the chain is empty

func (Chain) IsEqual

func (chain Chain) IsEqual(c Chain) bool

IsEqual compare two chain to see whether they represent the same chain

func (Chain) IsExternalChain

func (chain Chain) IsExternalChain() bool

func (Chain) IsPellChain

func (chain Chain) IsPellChain() bool

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) SupportMerkleProof

func (chain Chain) SupportMerkleProof() bool

SupportMerkleProof returns true if the chain supports block header-based verification

func (*Chain) Unmarshal

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

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

type Chains

type Chains []Chain

Chains represent a slice of Chain

func (Chains) Distinct

func (chains Chains) Distinct() Chains

Distinct return a distinct set of chains, no duplicates

func (Chains) Has

func (chains Chains) Has(c Chain) bool

Has check whether chain c is in the list

func (Chains) Strings

func (chains Chains) Strings() []string

type NetWork

type NetWork int32

NetWork represent chain type

const (
	// ethereum
	NetWork_ETH NetWork = 0
	// pell
	NetWork_PELL NetWork = 1
	// bitcoin
	NetWork_BTC NetWork = 2
	// polygon
	NetWork_POLYGON NetWork = 3
	// bsc
	NetWork_BSC NetWork = 4
	// goerli
	NetWork_GOERLI NetWork = 5
	// mumbai
	NetWork_MUMBAI NetWork = 6
	// ganache
	NetWork_GANACHE NetWork = 7
	// baobab
	NetWork_BAOBAB NetWork = 8
	// sepolia
	NetWork_SEPOLIA NetWork = 9
	// amoy
	NetWork_AMOY NetWork = 10
	// optimism
	NetWork_OPTIMISM NetWork = 11
	// base
	NetWork_BASE NetWork = 12
	// core
	NetWork_CORE NetWork = 13
	// mantle
	NetWork_MANTLE NetWork = 14
	// arbitrum
	NetWork_ARBITRUM NetWork = 15
	// bitlayer
	NetWork_BITLAYER NetWork = 16
)

func (NetWork) EnumDescriptor

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

func (NetWork) String

func (x NetWork) String() string

type NetWorkType

type NetWorkType int32

network represent chain network type

const (
	// mainnet
	NetWorkType_MAINNET NetWorkType = 0
	// testnet
	NetWorkType_TESTNET NetWorkType = 1
	// privnet
	NetWorkType_PRIVNET NetWorkType = 2
	// devnet
	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 represent the status of a received transaction

const (
	// some observer sees inbound tx
	ReceiveStatus_CREATED ReceiveStatus = 0
	// success
	ReceiveStatus_SUCCESS ReceiveStatus = 1
	// failed
	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

func (ReceiveStatus) EnumDescriptor

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

func (ReceiveStatus) String

func (x ReceiveStatus) String() string

type SigninAlgo

type SigninAlgo string

type VMType

type VMType int32

VMType represent the type of vm

const (
	// no vm
	VMType_NO_VM VMType = 0
	// ethereum vm
	VMType_EVM VMType = 1
	// solana vm
	VMType_SVM VMType = 2
)

func (VMType) EnumDescriptor

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

func (VMType) String

func (x VMType) String() string

Jump to

Keyboard shortcuts

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