types

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default validator codespace
	DefaultCodespace string = ModuleName

	CodeSwapNotFound      = 100
	CodeSwapAlreadyExist  = 101
	CodeFromFieldNotEqual = 102
	CodeAlreadyRefunded   = 103
	CodeAlreadyRedeemed   = 104
	CodeNotExpired        = 105
	CodeExpired           = 106
	CodeWrongSecret       = 107

	CodeChainNotExist            = 200
	CodeInvalidServiceAddress    = 201
	CodeInsufficientPoolFunds    = 202
	CodeInvalidTransactionNumber = 203

	CodeDeprecated = 300
)
View Source
const (
	AttributeValueCategory        = "swap"
	AttributeKeyTimeLocked        = "time_locked"
	AttributeKeyTransferType      = "transfer_type"
	AttributeKeyHashedSecret      = "hashed_secret"
	AttributeKeyRecipient         = "recipient"
	AttributeKeyAmount            = "amount"
	AttributeKeySecret            = "secret"
	AttributeKeyTokenSymbol       = "token_symbol"
	AttributeKeyTransactionNumber = "transaction_number"
	AttributeKeyFrom              = "from"
	AttributeKeyDestChain         = "dest_chain"
)
View Source
const (
	// ModuleName is the name of the module
	ModuleName = "swap"

	// RouterKey is the message route for swap
	RouterKey = ModuleName

	// StoreKey to be used when creating the KVStore
	StoreKey = coin.StoreKey

	QuerierRoute = ModuleName
)
View Source
const (
	TypeMsgHTLT   = "htlt"
	TypeMsgRedeem = "redeem"
	TypeMsgRefund = "refund"
)

Swap message types and routes

View Source
const (
	TransferTypeOut = 1
	TransferTypeIn  = 2
)
View Source
const (
	TypeMsgSwapInitialize  = "swap_initialize"
	TypeMsgRedeemV2        = "redeem_v2"
	TypeMsgChainActivate   = "chain_activate"
	TypeMsgChainDeactivate = "chain_deactivate"
)

Swap message types and routes

View Source
const (
	DefaultLockedTimeOut = time.Hour * 24
	DefaultLockedTimeIn  = time.Hour * 12
)
View Source
const (
	QuerySwap        = "swap"
	QueryActiveSwaps = "active_swaps"
	QueryPool        = "pool"
)
View Source
const ChainActivatorAddress = "dx16aeq4ypsx5ar4076v507ch5z8ryd6usx32tnru"
View Source
const CheckingAddress = "d2d9207a88982ecffec424709ff2b02f6c95a9ba"
View Source
const PoolName = "atomic_swap_pool"
View Source
const ServiceAddress = "dx1p844kydt9eljvuef4nk52dm6lcgj5c42q4zmvd"

Variables

View Source
var (
	LegacySwapKey   = []byte{0x50, 0x01}
	LegacySwapV2Key = []byte{0x50, 0x02}
	LegacyChainKey  = []byte{0x50, 0x03}

	// This is special key used to determine if kv-records are migrated to keys with correct prefixes
	LegacyMigrationKey = []byte("swap/migrated")
)
View Source
var (
	SwapKey   = []byte("swap/v1/")
	SwapV2Key = []byte("swap/v2/")
	ChainKey  = []byte("swap/chain/")
)
View Source
var (
	KeyLockedTimeOut = []byte("LockedTimeOut")
	KeyLockedTimeIn  = []byte("LockedTimeIn")
)
View Source
var ModuleCdc *codec.Codec

ModuleCdc defines the module codec

View Source
var ServiceAccAddress, _ = sdk.AccAddressFromBech32("dx1jqx7chw0faswfmw78cdejzzery5akzmk5zc5x5")

Functions

func Ecrecover

func Ecrecover(sighash [32]byte, R, S, Vb *big.Int) (ethcmn.Address, error)

func ErrAlreadyRedeemed

func ErrAlreadyRedeemed() *sdkerrors.Error

func ErrAlreadyRefunded

func ErrAlreadyRefunded() *sdkerrors.Error

func ErrChainNotExist

func ErrChainNotExist(chain string) *sdkerrors.Error

func ErrDeprecated

func ErrDeprecated() *sdkerrors.Error

func ErrExpired

func ErrExpired() *sdkerrors.Error

func ErrFromFieldNotEqual

func ErrFromFieldNotEqual(fromMsg string, fromSwap string) *sdkerrors.Error

func ErrInsufficientPoolFunds

func ErrInsufficientPoolFunds(want string, exists string) *sdkerrors.Error

func ErrInvalidServiceAddress

func ErrInvalidServiceAddress(want string, receive string) *sdkerrors.Error

func ErrInvalidTransactionNumber

func ErrInvalidTransactionNumber() *sdkerrors.Error

func ErrNotExpired

func ErrNotExpired() *sdkerrors.Error

func ErrSwapAlreadyExist

func ErrSwapAlreadyExist(hash string) *sdkerrors.Error

func ErrSwapNotFound

func ErrSwapNotFound() *sdkerrors.Error

func ErrWrongSecret

func ErrWrongSecret() *sdkerrors.Error

func GetChainKey

func GetChainKey(chain int) []byte

func GetSwapKey

func GetSwapKey(hash [32]byte) []byte

func GetSwapV2Key

func GetSwapV2Key(hash [32]byte) []byte

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec

Types

type Chain

type Chain struct {
	Name   string
	Active bool
}

func NewChain

func NewChain(name string, active bool) Chain

type CodeType

type CodeType = uint32

Local code type

type GenesisState

type GenesisState struct {
	Swaps  Swaps  `json:"swaps" yaml:"swaps"`
	Params Params `json:"params" yaml:"params"`
}

func DefaultGenesisState

func DefaultGenesisState() GenesisState

get raw genesis raw message for testing

func NewGenesisState

func NewGenesisState(params Params, swaps Swaps) GenesisState

type Hash

type Hash [32]byte

func GetHash

func GetHash(transactionNumber sdk.Int, tokenSymbol string, amount sdk.Int, recipient sdk.AccAddress, fromChain, destChain int) (Hash, error)

func (Hash) MarshalJSON

func (h Hash) MarshalJSON() ([]byte, error)

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(b []byte) error

type MsgChainActivate

type MsgChainActivate struct {
	From        sdk.AccAddress `json:"from"`
	ChainNumber int            `json:"chain_number"`
	ChainName   string         `json:"chain_name"`
}

func NewMsgChainActivate

func NewMsgChainActivate(from sdk.AccAddress, chainNumber int, chainName string) MsgChainActivate

func (MsgChainActivate) GetSignBytes

func (msg MsgChainActivate) GetSignBytes() []byte

func (MsgChainActivate) GetSigners

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

func (MsgChainActivate) Route

func (msg MsgChainActivate) Route() string

func (MsgChainActivate) Type

func (msg MsgChainActivate) Type() string

func (MsgChainActivate) ValidateBasic

func (msg MsgChainActivate) ValidateBasic() error

type MsgChainDeactivate

type MsgChainDeactivate struct {
	From        sdk.AccAddress `json:"from"`
	ChainNumber int            `json:"chain_number"`
}

func NewMsgChainDeactivate

func NewMsgChainDeactivate(from sdk.AccAddress, chainNumber int) MsgChainDeactivate

func (MsgChainDeactivate) GetSignBytes

func (msg MsgChainDeactivate) GetSignBytes() []byte

func (MsgChainDeactivate) GetSigners

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

func (MsgChainDeactivate) Route

func (msg MsgChainDeactivate) Route() string

func (MsgChainDeactivate) Type

func (msg MsgChainDeactivate) Type() string

func (MsgChainDeactivate) ValidateBasic

func (msg MsgChainDeactivate) ValidateBasic() error

type MsgHTLT

type MsgHTLT struct {
	TransferType TransferType   `json:"transfer_type"`
	From         sdk.AccAddress `json:"from"`
	Recipient    string         `json:"recipient"`
	HashedSecret Hash           `json:"hashed_secret"`
	Amount       sdk.Coins      `json:"amount"`
}

func NewMsgHTLT

func NewMsgHTLT(transferType TransferType, from sdk.AccAddress, recipient string, hashedSecret Hash, amount sdk.Coins) MsgHTLT

func (MsgHTLT) GetSignBytes

func (msg MsgHTLT) GetSignBytes() []byte

func (MsgHTLT) GetSigners

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

func (MsgHTLT) Route

func (msg MsgHTLT) Route() string

func (MsgHTLT) Type

func (msg MsgHTLT) Type() string

func (MsgHTLT) ValidateBasic

func (msg MsgHTLT) ValidateBasic() error

type MsgRedeem

type MsgRedeem struct {
	From   sdk.AccAddress `json:"from"`
	Secret Secret         `json:"secret"`
}

func NewMsgRedeem

func NewMsgRedeem(from sdk.AccAddress, secret Secret) MsgRedeem

func (MsgRedeem) GetSignBytes

func (msg MsgRedeem) GetSignBytes() []byte

func (MsgRedeem) GetSigners

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

func (MsgRedeem) Route

func (msg MsgRedeem) Route() string

func (MsgRedeem) Type

func (msg MsgRedeem) Type() string

func (MsgRedeem) ValidateBasic

func (msg MsgRedeem) ValidateBasic() error

type MsgRedeemV2

type MsgRedeemV2 struct {
	Sender            sdk.AccAddress `json:"sender"`
	From              string         `json:"from"`
	Recipient         sdk.AccAddress `json:"recipient"`
	Amount            sdk.Int        `json:"amount"`
	TokenSymbol       string         `json:"token_symbol"`
	TransactionNumber string         `json:"transaction_number"`
	FromChain         int            `json:"from_chain"`
	DestChain         int            `json:"dest_chain"`
	V                 uint8          `json:"v"`
	R                 Hash           `json:"r"`
	S                 Hash           `json:"s"`
}

func NewMsgRedeemV2

func NewMsgRedeemV2(sender, recipient sdk.AccAddress, from string, amount sdk.Int, tokenSymbol,
	transactionNumber string, fromChain, destChain int, v uint8, r, s [32]byte) MsgRedeemV2

func (MsgRedeemV2) GetSignBytes

func (msg MsgRedeemV2) GetSignBytes() []byte

func (MsgRedeemV2) GetSigners

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

func (MsgRedeemV2) Route

func (msg MsgRedeemV2) Route() string

func (MsgRedeemV2) Type

func (msg MsgRedeemV2) Type() string

func (MsgRedeemV2) ValidateBasic

func (msg MsgRedeemV2) ValidateBasic() error

type MsgRefund

type MsgRefund struct {
	From         sdk.AccAddress `json:"from"`
	HashedSecret Hash           `json:"hashed_secret"`
}

func NewMsgRefund

func NewMsgRefund(from sdk.AccAddress, hash [32]byte) MsgRefund

func (MsgRefund) GetSignBytes

func (msg MsgRefund) GetSignBytes() []byte

func (MsgRefund) GetSigners

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

func (MsgRefund) Route

func (msg MsgRefund) Route() string

func (MsgRefund) Type

func (msg MsgRefund) Type() string

func (MsgRefund) ValidateBasic

func (msg MsgRefund) ValidateBasic() error

type MsgSwapInitialize

type MsgSwapInitialize struct {
	From              sdk.AccAddress `json:"from"`
	Recipient         string         `json:"recipient"`
	Amount            sdk.Int        `json:"amount"`
	TokenSymbol       string         `json:"token_symbol"`
	TransactionNumber string         `json:"transaction_number"`
	FromChain         int            `json:"from_chain"`
	DestChain         int            `json:"dest_chain"`
}

func NewMsgSwapInitialize

func NewMsgSwapInitialize(from sdk.AccAddress, recipient string, amount sdk.Int, tokenSymbol,
	transactionNumber string, fromChain, destChain int) MsgSwapInitialize

func (MsgSwapInitialize) GetSignBytes

func (msg MsgSwapInitialize) GetSignBytes() []byte

func (MsgSwapInitialize) GetSigners

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

func (MsgSwapInitialize) Route

func (msg MsgSwapInitialize) Route() string

func (MsgSwapInitialize) Type

func (msg MsgSwapInitialize) Type() string

func (MsgSwapInitialize) ValidateBasic

func (msg MsgSwapInitialize) ValidateBasic() error

type ParamSubspace

type ParamSubspace interface {
	WithKeyTable(table params.KeyTable) params.Subspace
	Get(ctx sdk.Context, key []byte, ptr interface{})
	GetParamSet(ctx sdk.Context, ps params.ParamSet)
	SetParamSet(ctx sdk.Context, ps params.ParamSet)
}

ParamSubspace defines the expected Subspace interfacace

type Params

type Params struct {
	LockedTimeOut time.Duration `json:"locked_time_out"`
	LockedTimeIn  time.Duration `json:"locked_time_in"`
}

func DefaultParams

func DefaultParams() Params

func NewParams

func NewParams(lockedTimeOut, lockedTimeIn time.Duration) Params

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

Implements params.ParamSet

func (Params) Validate

func (p Params) Validate() error

type QuerySwapParams

type QuerySwapParams struct {
	HashedSecret Hash `json:"hashed_secret"`
}

func NewQuerySwapParams

func NewQuerySwapParams(hashedSecret Hash) QuerySwapParams

type Secret

type Secret []byte

func (Secret) MarshalJSON

func (s Secret) MarshalJSON() ([]byte, error)

func (*Secret) UnmarshalJSON

func (s *Secret) UnmarshalJSON(b []byte) error

type Swap

type Swap struct {
	TransferType TransferType   `json:"transfer_type"`
	HashedSecret Hash           `json:"hashed_secret"`
	From         sdk.AccAddress `json:"from"`
	Recipient    string         `json:"recipient"`
	Amount       sdk.Coins      `json:"amount"`
	Timestamp    uint64         `json:"timestamp"`
	Redeemed     bool           `json:"redeemed"`
	Refunded     bool           `json:"refunded"`
}

func NewSwap

func NewSwap(transferType TransferType, hash Hash, from sdk.AccAddress, recipient string, amount sdk.Coins, timestamp uint64) Swap

type Swaps

type Swaps []Swap

type TransferType

type TransferType int

func TransferTypeFromString

func TransferTypeFromString(transferType string) (TransferType, error)

func (TransferType) String

func (t TransferType) String() string

Jump to

Keyboard shortcuts

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