chainset

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 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 BridgeCore

type BridgeCore struct {
	ChainName string
	ChainInfo *ChainInfo
}

func NewBridgeCore

func NewBridgeCore(name string) *BridgeCore

func (*BridgeCore) AssetIdToResourceId

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

func (*BridgeCore) CalculateAmountToEth

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

func (*BridgeCore) CalculateAmountToSub

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

func (*BridgeCore) ConvertResourceIdToAssetId

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

func (*BridgeCore) ConvertStringToResourceId

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

func (*BridgeCore) GetAmountToEth

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

func (*BridgeCore) GetAmountToSub

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

func (*BridgeCore) GetCurrencyByAssetId

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

func (*BridgeCore) GetCurrencyByResourceId

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

func (*BridgeCore) GetSubChainRecipient

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

func (*BridgeCore) InitializeClientPrefix

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

func (*BridgeCore) MakeBalanceTransferCall

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

func (*BridgeCore) MakeCrossChainTansferCall

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

func (*BridgeCore) MakeXAssetTransferCall

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

func (*BridgeCore) ResourceIdToAssetId

func (bc *BridgeCore) 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