chainset

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoneLike = iota
	EthLike
	PlatonLike

	SubLike
	PolkadotLike
	KusamaLike

	// ChainXV1Like ChainX V1 use Address Type
	ChainXV1Like
	ChainXAssetV1Like

	ChainXLike
	ChainXAssetLike
)
View Source
const (
	NameUnimplemented string = "unimplemented"

	NamePlaton string = "platon"
	NameAlaya  string = "alaya"

	NameKusama   string = "kusama"
	NamePolkadot string = "polkadot"
)

/ Chain name constants

View Source
const (
	TokenATP string = "ATP"
	TokenLAT string = "LAT"

	TokenDOT string = "DOT"
	TokenKSM string = "KSM"
	TokenPCX string = "PCX"

	TokenXBTC   string = "XBTC"
	TokenXAsset string = "XASSET"
)
View Source
const (
	IdBSC   msg.ChainId = 22
	IdKovan msg.ChainId = 23
	IdHeco  msg.ChainId = 24

	IdKusama   msg.ChainId = 11
	IdPolkadot msg.ChainId = 12

	IdChainXPCXV1 msg.ChainId = 6
	IdChainXPCXV2 msg.ChainId = 7
	IdChainXBTCV1 msg.ChainId = 8
	IdChainXBTCV2 msg.ChainId = 9
)

/ ChainId Type

View Source
const (
	SingleKSM int64 = 1e12
	SingleDOT int64 = 1e10
	SinglePCX int64 = 1e8
)

The currency of Sub-Like

View Source
const (
	DiffKSM    = 1000000     /// KSM    is 12 digits
	DiffDOT    = 100000000   /// DOT    is 10 digits
	DiffXBTC   = 10000000000 /// XBTC   is 8  digits
	DiffPCX    = 10000000000 /// PCX	   is 8  digits
	DiffXAsset = 10000000000 /// XAsset is 8  digits
)

The precision-difference constant between Eth-Like and Sub-Like

View Source
const (
	FixedKSMFee = SingleKSM * 3 / 100 /// 0.03KSM
	FixedDOTFee = SingleDOT * 5 / 10  /// 0.5DOT
	FixedPCXFee = SinglePCX * 1 / 10  /// 0.1PCX
)

/ Fixed handling fee for cross-chain transactions

View Source
const (
	ExtraFeeRate     int64 = 1000
	ExtraNoneFeeRate int64 = 0
)

ExtraFeeRate Additional formalities rate excluding fixed handling fee

View Source
const (
	OriginAsset xevents.AssetId = 0
	AssetXBTC   xevents.AssetId = 1
	XAssetId    xevents.AssetId = 999
)

/ AssetId Type

View Source
const (
	ResourceIdOrigin string = ResourceIdPrefix + "000"
	ResourceIdXBTC   string = ResourceIdPrefix + "001"
	ResourceIdXAsset string = ResourceIdPrefix + "999"
)
View Source
const ResourceIdPrefix = "0000000000000000000000000000000000000000000000000000000000000"
View Source
const XParameter uint8 = 255

Variables

View Source
var MultiSigLimit msg.ChainId = 100

Functions

func EncodeToBytes

func EncodeToBytes(value interface{}) ([]byte, error)

func GetChainPrefix

func GetChainPrefix(name string) string

func IsMultiSigTransfer

func IsMultiSigTransfer(id msg.ChainId) bool

IsNativeTransfer Chain id distinguishes Tx types(Native, Fungible...)

Types

type ChainCore added in v1.0.2

type ChainCore struct {
	ChainName string
	ChainInfo *ChainInfo
}

func NewChainCore added in v1.0.2

func NewChainCore(name string) *ChainCore

func (*ChainCore) AssetIdToResourceId added in v1.0.2

func (bc *ChainCore) AssetIdToResourceId(api *gsrpc.SubstrateAPI, meta *types.Metadata, assetId xevents.AssetId) ([]byte, error)

func (*ChainCore) CalculateAmountToEth added in v1.0.2

func (bc *ChainCore) CalculateAmountToEth(origin []byte, singleToken int64, fixedTokenFee int64, extraFeeRate int64, token string) (*big.Int, error)

func (*ChainCore) CalculateAmountToSub added in v1.0.2

func (bc *ChainCore) CalculateAmountToSub(origin []byte, singleToken int64, fixedTokenFee int64, extraFeeRate int64, token string) (*big.Int, error)

func (*ChainCore) ConvertResourceIdToAssetId added in v1.0.2

func (bc *ChainCore) ConvertResourceIdToAssetId(rId msg.ResourceId) (xevents.AssetId, error)

func (*ChainCore) ConvertStringToResourceId added in v1.0.2

func (bc *ChainCore) ConvertStringToResourceId(rId string) msg.ResourceId

func (*ChainCore) GetAmountToEth added in v1.0.2

func (bc *ChainCore) GetAmountToEth(origin []byte, assetId xevents.AssetId) (*big.Int, error)

func (*ChainCore) GetAmountToSub added in v1.0.2

func (bc *ChainCore) GetAmountToSub(origin []byte, assetId xevents.AssetId) (*big.Int, error)

func (*ChainCore) GetCurrencyByAssetId added in v1.0.2

func (bc *ChainCore) GetCurrencyByAssetId(assetId xevents.AssetId) (*Currency, error)

func (*ChainCore) GetCurrencyByResourceId added in v1.0.2

func (bc *ChainCore) GetCurrencyByResourceId(rId msg.ResourceId) (*Currency, error)

func (*ChainCore) GetSubChainRecipient added in v1.0.2

func (bc *ChainCore) GetSubChainRecipient(m msg.Message) interface{}

func (*ChainCore) InitializeClientPrefix added in v1.0.2

func (bc *ChainCore) InitializeClientPrefix(cli *client.Client)

func (*ChainCore) MakeBalanceTransferCall added in v1.0.2

func (bc *ChainCore) MakeBalanceTransferCall(m msg.Message, meta *types.Metadata, assetId xevents.AssetId) (types.Call, error)

func (*ChainCore) MakeCrossChainTansferCall added in v1.0.2

func (bc *ChainCore) MakeCrossChainTansferCall(m msg.Message, meta *types.Metadata, assetId xevents.AssetId) (types.Call, error)

func (*ChainCore) MakeXAssetTransferCall added in v1.0.2

func (bc *ChainCore) MakeXAssetTransferCall(m msg.Message, meta *types.Metadata, assetId xevents.AssetId) (types.Call, error)

func (*ChainCore) ResourceIdToAssetId added in v1.0.2

func (bc *ChainCore) ResourceIdToAssetId(api *gsrpc.SubstrateAPI, meta *types.Metadata, rId [32]byte) ([]byte, error)

type ChainInfo

type ChainInfo struct {
	Prefix      string
	NativeToken string
	Type        ChainType
}

func GetChainInfo

func GetChainInfo(prefix string) *ChainInfo

type ChainType

type ChainType int

type Currency

type Currency struct {
	/// Set the token of the native token to zero
	AssetId      xevents.AssetId
	ResourceId   string
	Name         string
	Difference   int64
	FixedFee     int64
	ExtraFeeRate int64
}

type OptionAssetId

type OptionAssetId struct {
	Option option
	Value  xevents.AssetId
}

func NewOptionAssetId

func NewOptionAssetId(assetId xevents.AssetId) OptionAssetId

Jump to

Keyboard shortcuts

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