types

package
v0.10.24 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MPL-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	BSCBNBDecimals int8 = 18

	BindChannel        = "bind"
	TransferOutChannel = "transferOut"
	TransferInChannel  = "transferIn"
	MirrorChannel      = "mirror"
	MirrorSyncChannel  = "mirrorSync"

	BindChannelID        sdk.ChannelID = 1
	TransferOutChannelID sdk.ChannelID = 2
	TransferInChannelID  sdk.ChannelID = 3
	MirrorChannelID      sdk.ChannelID = 4
	MirrorSyncChannelID  sdk.ChannelID = 5

	MinTransferOutExpireTimeGap = 60 * time.Second
	MinBindExpireTimeGap        = 600 * time.Second

	BNBContractAddr     = "0x0000000000000000000000000000000000000000"
	BNBContractDecimals = 18
)
View Source
const (
	DefaultCodespace sdk.CodespaceType = 12

	CodeInvalidAmount            sdk.CodeType = 1
	CodeInvalidEthereumAddress   sdk.CodeType = 2
	CodeInvalidDecimals          sdk.CodeType = 3
	CodeInvalidContractAddress   sdk.CodeType = 4
	CodeTokenNotBound            sdk.CodeType = 5
	CodeInvalidSymbol            sdk.CodeType = 6
	CodeInvalidExpireTime        sdk.CodeType = 7
	CodeBindRequestExists        sdk.CodeType = 8
	CodeBindRequestNotExists     sdk.CodeType = 9
	CodeTokenBound               sdk.CodeType = 10
	CodeInvalidLength            sdk.CodeType = 11
	CodeFeeNotFound              sdk.CodeType = 12
	CodeInvalidClaim             sdk.CodeType = 13
	CodeDeserializePackageFailed sdk.CodeType = 14
	CodeTokenBindRelationChanged sdk.CodeType = 15
	CodeTransferInExpire         sdk.CodeType = 16
	CodeScriptsExecutionError    sdk.CodeType = 17
	CodeInvalidMirror            sdk.CodeType = 18
	CodeMirrorSymbolExists       sdk.CodeType = 19
	CodeInvalidMirrorSync        sdk.CodeType = 20
	CodeNotBoundByMirror         sdk.CodeType = 21
	CodeMirrorSyncInvalidSupply  sdk.CodeType = 22
)
View Source
const (
	BindRelayFeeName        = "crossBindRelayFee"
	UnbindRelayFeeName      = "crossUnbindRelayFee"
	TransferOutRelayFeeName = "crossTransferOutRelayFee"
)
View Source
const (
	RouteBridge = "bridge"

	BindMsgType        = "crossBind"
	UnbindMsgType      = "crossUnbind"
	TransferOutMsgType = "crossTransferOut"
)
View Source
const (
	MirrorErrCodeExpired          uint8 = 1
	MirrorErrCodeBEP2SymbolExists uint8 = 2
	MirrorErrCodeDecimalOverflow  uint8 = 3
	MirrorErrCodeInvalidSymbol    uint8 = 4
	MirrorErrCodeInvalidSupply    uint8 = 5
)
View Source
const (
	MirrorSyncErrCodeExpired      uint8 = 1
	MirrorSyncErrNotBoundByMirror uint8 = 2
	MirrorSyncErrInvalidSupply    uint8 = 3
)
View Source
const (
	TagSendSequence = "SendSequence"
	TagChannel      = "Channel"
	TagRelayerFee   = "relayerFee"

	TagMirrorContract  = "contract"
	TagMirrorSymbol    = "symbol"
	TagMirrorSupply    = "supply"
	TagMirrorErrorCode = "errCode"
)
View Source
const (
	MaxSymbolLength = 32
)

Variables

View Source
var (
	// bnb prefix address:  bnb1v8vkkymvhe2sf7gd2092ujc6hweta38xadu2pj
	// tbnb prefix address: tbnb1v8vkkymvhe2sf7gd2092ujc6hweta38xnc4wpr
	PegAccount = sdk.AccAddress(crypto.AddressHash([]byte("BinanceChainPegAccount")))
)

Functions

func BytesToSymbol

func BytesToSymbol(symbolBytes [32]byte) string

func ConvertBCAmountToBSCAmount

func ConvertBCAmountToBSCAmount(contractDecimals int8, bcAmount int64) (sdk.Int, sdk.Error)

func ConvertBSCAmountToBCAmount

func ConvertBSCAmountToBCAmount(contractDecimals int8, bscAmount sdk.Int) (int64, sdk.Error)

func ConvertBSCAmountToBCAmountBigInt

func ConvertBSCAmountToBCAmountBigInt(contractDecimals int8, bscAmount sdk.Int) (sdk.Int, sdk.Error)

func ErrBindRequestExists

func ErrBindRequestExists(msg string) sdk.Error

func ErrBindRequestNotExists

func ErrBindRequestNotExists(msg string) sdk.Error

func ErrDeserializePackageFailed

func ErrDeserializePackageFailed(msg string) sdk.Error

func ErrFeeNotFound

func ErrFeeNotFound(msg string) sdk.Error

func ErrInvalidAmount

func ErrInvalidAmount(msg string) sdk.Error

func ErrInvalidClaim

func ErrInvalidClaim(msg string) sdk.Error

func ErrInvalidContractAddress

func ErrInvalidContractAddress(msg string) sdk.Error

func ErrInvalidDecimals

func ErrInvalidDecimals(msg string) sdk.Error

func ErrInvalidEthereumAddress

func ErrInvalidEthereumAddress(msg string) sdk.Error

func ErrInvalidExpireTime

func ErrInvalidExpireTime(msg string) sdk.Error

func ErrInvalidLength

func ErrInvalidLength(msg string) sdk.Error

func ErrInvalidMirror

func ErrInvalidMirror(msg string) sdk.Error

func ErrInvalidMirrorSync

func ErrInvalidMirrorSync(msg string) sdk.Error

func ErrInvalidSymbol

func ErrInvalidSymbol(msg string) sdk.Error

func ErrMirrorSymbolExists

func ErrMirrorSymbolExists(msg string) sdk.Error

func ErrMirrorSyncInvalidSupply

func ErrMirrorSyncInvalidSupply(msg string) sdk.Error

func ErrNotBoundByMirror

func ErrNotBoundByMirror(msg string) sdk.Error

func ErrScriptsExecutionError

func ErrScriptsExecutionError(msg string) sdk.Error

func ErrTokenBindRelationChanged

func ErrTokenBindRelationChanged(msg string) sdk.Error

func ErrTokenBound

func ErrTokenBound(msg string) sdk.Error

func ErrTokenNotBound

func ErrTokenNotBound(msg string) sdk.Error

func ErrTransferInExpire

func ErrTransferInExpire(msg string) sdk.Error

func GenerateTransferInTags

func GenerateTransferInTags(receiverAddresses []sdk.AccAddress, symbol string, amounts []*big.Int, isRefund bool) sdk.Tags

func GetBindRequestKey

func GetBindRequestKey(symbol string) []byte

func GetContractDecimalsKey

func GetContractDecimalsKey(contractAddr []byte) []byte

func GetFee

func GetFee(feeName string) (sdk.Fee, sdk.Error)

func SymbolToBytes

func SymbolToBytes(symbol string) [32]byte

Types

type ApproveBindAckPackage

type ApproveBindAckPackage struct {
	TokenSymbol [32]byte
}

type ApproveBindSynPackage

type ApproveBindSynPackage struct {
	Status      BindStatus
	TokenSymbol [32]byte
}

func DeserializeApproveBindSynPackage

func DeserializeApproveBindSynPackage(serializedPackage []byte) (*ApproveBindSynPackage, sdk.Error)

type BindAckPackage

type BindAckPackage struct {
	TokenSymbol [32]byte
}

type BindMsg

type BindMsg struct {
	From             sdk.AccAddress        `json:"from"`
	Symbol           string                `json:"symbol"`
	Amount           int64                 `json:"amount"`
	ContractAddress  sdk.SmartChainAddress `json:"contract_address"`
	ContractDecimals int8                  `json:"contract_decimals"`
	ExpireTime       int64                 `json:"expire_time"`
}

func NewBindMsg

func NewBindMsg(from sdk.AccAddress, symbol string, amount int64, contractAddress sdk.SmartChainAddress, contractDecimals int8, expireTime int64) BindMsg

func (BindMsg) GetInvolvedAddresses

func (msg BindMsg) GetInvolvedAddresses() []sdk.AccAddress

func (BindMsg) GetSignBytes

func (msg BindMsg) GetSignBytes() []byte

func (BindMsg) GetSigners

func (msg BindMsg) GetSigners() []sdk.AccAddress

func (BindMsg) Route

func (msg BindMsg) Route() string

func (BindMsg) String

func (msg BindMsg) String() string

func (BindMsg) Type

func (msg BindMsg) Type() string

func (BindMsg) ValidateBasic

func (msg BindMsg) ValidateBasic() sdk.Error

type BindPackageType

type BindPackageType uint8
const (
	BindTypeBind   BindPackageType = 0
	BindTypeUnbind BindPackageType = 1
)

type BindRequest

type BindRequest struct {
	From             sdk.AccAddress        `json:"from"`
	Symbol           string                `json:"symbol"`
	Amount           int64                 `json:"amount"`
	DeductedAmount   int64                 `json:"deducted_amount"`
	ContractAddress  sdk.SmartChainAddress `json:"contract_address"`
	ContractDecimals int8                  `json:"contract_decimals"`
	ExpireTime       int64                 `json:"expire_time"`
}

type BindStatus

type BindStatus uint32
const (
	BindStatusSuccess          BindStatus = 0
	BindStatusRejected         BindStatus = 1
	BindStatusTimeout          BindStatus = 2
	BindStatusInvalidParameter BindStatus = 3
)

func ParseBindStatus

func ParseBindStatus(input string) (BindStatus, error)

func (BindStatus) String

func (status BindStatus) String() string

type BindSynPackage

type BindSynPackage struct {
	PackageType  BindPackageType
	TokenSymbol  [32]byte
	ContractAddr sdk.SmartChainAddress
	TotalSupply  *big.Int
	PeggyAmount  *big.Int
	Decimals     uint8
	ExpireTime   uint64
}

func DeserializeBindSynPackage

func DeserializeBindSynPackage(serializedPackage []byte) (*BindSynPackage, sdk.Error)

type MirrorAckPackage

type MirrorAckPackage struct {
	MirrorSender sdk.SmartChainAddress
	ContractAddr sdk.SmartChainAddress
	Decimals     uint8
	BEP2Symbol   [32]byte
	MirrorFee    *big.Int
	ErrorCode    uint8
}

type MirrorSynPackage

type MirrorSynPackage struct {
	MirrorSender     sdk.SmartChainAddress
	ContractAddr     sdk.SmartChainAddress
	BEP20Name        [32]byte
	BEP20Symbol      [32]byte
	BEP20TotalSupply *big.Int
	BEP20Decimals    uint8
	MirrorFee        *big.Int
	ExpireTime       uint64
}

func DeserializeMirrorSynPackage

func DeserializeMirrorSynPackage(serializedPackage []byte) (*MirrorSynPackage, sdk.Error)

type MirrorSyncAckPackage

type MirrorSyncAckPackage struct {
	SyncSender   sdk.SmartChainAddress
	ContractAddr sdk.SmartChainAddress
	SyncFee      *big.Int
	ErrorCode    uint8
}

type MirrorSyncSynPackage

type MirrorSyncSynPackage struct {
	SyncSender       sdk.SmartChainAddress
	ContractAddr     sdk.SmartChainAddress
	BEP2Symbol       [32]byte
	BEP20TotalSupply *big.Int
	SyncFee          *big.Int
	ExpireTime       uint64
}

func DeserializeMirrorSyncSynPackage

func DeserializeMirrorSyncSynPackage(serializedPackage []byte) (*MirrorSyncSynPackage, sdk.Error)

type RefundReason

type RefundReason uint32
const (
	UnboundToken              RefundReason = 1
	Timeout                   RefundReason = 2
	InsufficientBalance       RefundReason = 3
	Unknown                   RefundReason = 4
	ForbidTransferToBPE12Addr RefundReason = 5
)

type TransferInRefundPackage

type TransferInRefundPackage struct {
	ContractAddr    sdk.SmartChainAddress
	RefundAmounts   []*big.Int
	RefundAddresses []sdk.SmartChainAddress
	RefundReason    RefundReason
}

type TransferInSynPackage

type TransferInSynPackage struct {
	TokenSymbol       [32]byte
	ContractAddress   sdk.SmartChainAddress
	Amounts           []*big.Int
	ReceiverAddresses []sdk.AccAddress
	RefundAddresses   []sdk.SmartChainAddress
	ExpireTime        uint64
}

func DeserializeTransferInSynPackage

func DeserializeTransferInSynPackage(serializedPackage []byte) (*TransferInSynPackage, sdk.Error)

type TransferOutMsg

type TransferOutMsg struct {
	From       sdk.AccAddress        `json:"from"`
	To         sdk.SmartChainAddress `json:"to"`
	Amount     sdk.Coin              `json:"amount"`
	ExpireTime int64                 `json:"expire_time"`
}

func NewTransferOutMsg

func NewTransferOutMsg(from sdk.AccAddress, to sdk.SmartChainAddress, amount sdk.Coin, expireTime int64) TransferOutMsg

func (TransferOutMsg) GetInvolvedAddresses

func (msg TransferOutMsg) GetInvolvedAddresses() []sdk.AccAddress

func (TransferOutMsg) GetSignBytes

func (msg TransferOutMsg) GetSignBytes() []byte

func (TransferOutMsg) GetSigners

func (msg TransferOutMsg) GetSigners() []sdk.AccAddress

func (TransferOutMsg) Route

func (msg TransferOutMsg) Route() string

func (TransferOutMsg) String

func (msg TransferOutMsg) String() string

func (TransferOutMsg) Type

func (msg TransferOutMsg) Type() string

func (TransferOutMsg) ValidateBasic

func (msg TransferOutMsg) ValidateBasic() sdk.Error

type TransferOutRefundPackage

type TransferOutRefundPackage struct {
	TokenSymbol  [32]byte
	RefundAmount *big.Int
	RefundAddr   sdk.AccAddress
	RefundReason RefundReason
}

func DeserializeTransferOutRefundPackage

func DeserializeTransferOutRefundPackage(serializedPackage []byte) (*TransferOutRefundPackage, sdk.Error)

type TransferOutSynPackage

type TransferOutSynPackage struct {
	TokenSymbol     [32]byte
	ContractAddress sdk.SmartChainAddress
	Amount          *big.Int
	Recipient       sdk.SmartChainAddress
	RefundAddress   sdk.AccAddress
	ExpireTime      uint64
}

func DeserializeTransferOutSynPackage

func DeserializeTransferOutSynPackage(serializedPackage []byte) (*TransferOutSynPackage, sdk.Error)

type UnbindMsg

type UnbindMsg struct {
	From   sdk.AccAddress `json:"from"`
	Symbol string         `json:"symbol"`
}

func NewUnbindMsg

func NewUnbindMsg(from sdk.AccAddress, symbol string) UnbindMsg

func (UnbindMsg) GetInvolvedAddresses

func (msg UnbindMsg) GetInvolvedAddresses() []sdk.AccAddress

func (UnbindMsg) GetSignBytes

func (msg UnbindMsg) GetSignBytes() []byte

func (UnbindMsg) GetSigners

func (msg UnbindMsg) GetSigners() []sdk.AccAddress

func (UnbindMsg) Route

func (msg UnbindMsg) Route() string

func (UnbindMsg) String

func (msg UnbindMsg) String() string

func (UnbindMsg) Type

func (msg UnbindMsg) Type() string

func (UnbindMsg) ValidateBasic

func (msg UnbindMsg) ValidateBasic() sdk.Error

Jump to

Keyboard shortcuts

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