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: 21 Imported by: 0

Documentation

Index

Constants

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

	// Create coin
	CodeInvalidCRR                      CodeType = 100
	CodeCoinDoesNotExist                CodeType = 101
	CodeInvalidCoinSymbol               CodeType = 102
	CodeForbiddenCoinSymbol             CodeType = 103
	CodeRetrievedAnotherCoin            CodeType = 104
	CodeCoinAlreadyExists               CodeType = 105
	CodeInvalidCoinTitle                CodeType = 106
	CodeInvalidCoinInitialVolume        CodeType = 107
	CodeInvalidCoinInitialReserve       CodeType = 108
	CodeInternal                        CodeType = 109
	CodeInsufficientCoinReserve         CodeType = 110
	CodeInsufficientCoinToPayCommission CodeType = 111
	CodeInsufficientFunds               CodeType = 112
	CodeCalculateCommission             CodeType = 113
	CodeForbiddenUpdate                 CodeType = 114

	// Buy/Sell coin
	CodeSameCoins                  CodeType = 200
	CodeInsufficientFundsToSellAll CodeType = 201
	CodeTxBreaksVolumeLimit        CodeType = 202
	CodeTxBreaksMinReserveLimit    CodeType = 203
	CodeMaximumValueToSellReached  CodeType = 204
	CodeMinimumValueToBuyReached   CodeType = 205
	CodeUpdateBalance              CodeType = 206
	CodeLimitVolumeBroken          CodeType = 207
	CodeTxBreaksMinVolumeLimit     CodeType = 208

	// Send coin
	CodeInvalidAmount          CodeType = 300
	CodeInvalidReceiverAddress CodeType = 301

	// Redeem check
	CodeInvalidCheck          CodeType = 400
	CodeInvalidProof          CodeType = 401
	CodeInvalidPassphrase     CodeType = 402
	CodeInvalidChainID        CodeType = 403
	CodeInvalidNonce          CodeType = 404
	CodeCheckExpired          CodeType = 405
	CodeCheckRedeemed         CodeType = 406
	CodeUnableDecodeCheck     CodeType = 407
	CodeUnableRPLEncodeCheck  CodeType = 408
	CodeUnableSignCheck       CodeType = 409
	CodeUnableDecodeProof     CodeType = 410
	CodeUnableRecoverAddress  CodeType = 411
	CodeUnableRecoverLockPkey CodeType = 412

	// AccountKeys
	CodeInvalidPkey              CodeType = 500
	CodeUnableRetriveArmoredPkey CodeType = 501
	CodeUnableRetrivePkey        CodeType = 502
	CodeUnableRetriveSECPPkey    CodeType = 503
)
View Source
const (
	EventTypeCreateCoin    = "create_coin"
	EventTypeBuyCoin       = "buy_coin"
	EventTypeSellCoin      = "sell_coin"
	EventTypeSellAllCoin   = "sell_all_coin"
	EventTypeSendCoin      = "send_coin"
	EventTypeMultiSendCoin = "multi_send_coin"
	EventTypeRedeemCheck   = "redeem_check"
	EventTypeUpdateCoin    = "update_coin"
	// Create Coin
	AttributeTitle                 = "title"
	AttributeSymbol                = "symbol"
	AttributeCRR                   = "crr"
	AttributeVolume                = "volume"
	AttributeReserve               = "reserve"
	AttributeInitVolume            = "initial_volume"
	AttributeInitReserve           = "initial_reserve"
	AttributeLimitVolume           = "limit_volume"
	AttributeCommissionCreateCoin  = "commission_create_coin"
	AttributeCommissionRedeemCheck = "commission_redeem_check"

	// Buy/Sell Coin
	AttributeCoinToBuy        = "coin_to_buy"
	AttributeCoinToSell       = "coin_to_sell"
	AttributeAmountToBuy      = "amount_to_buy"
	AttributeAmountToSell     = "amount_to_sell"
	AttributeAmountInBaseCoin = "amount_in_base_coin"

	// Send/MultiSend Coin
	AttributeCoin     = "coin"
	AttributeAmount   = "amount"
	AttributeReceiver = "receiver"

	// Redeem Check
	AttributeIssuer   = "issuer"
	AttributeNonce    = "nonce"
	AttributeDueBlock = "due_block"

	AttributeValueCategory = ModuleName
)

coin module event types

View Source
const (
	// ModuleName is the name of the module
	ModuleName = "coin"

	// StoreKey to be used when creating the KVStore
	StoreKey = ModuleName

	// RouterKey to be used for routing msgs
	RouterKey = ModuleName

	QuerierRoute = ModuleName

	CoinPrefix  = "coin-"
	CheckPrefix = "check-"
)
View Source
const (
	QueryListCoins = "list"
	QueryGetCoin   = "get"
)

Query endpoints supported by the coin querier

View Source
const BurnCoinConst = "burn_coin"
View Source
const BuyCoinConst = "buy_coin"
View Source
const CreateCoinConst = "create_coin"
View Source
const (
	DefaultParamspace = ModuleName
)

Default parameter namespace

View Source
const HashLength = 32
View Source
const MultiSendCoinConst = "multi_send_coin"
View Source
const RedeemCheckConst = "redeem_check"
View Source
const SellAllCoinConst = "sell_all_coin"
View Source
const SellCoinConst = "sell_coin"
View Source
const SendCoinConst = "send_coin"
View Source
const UpdateCoinConst = "update_coin"

Variables

View Source
var (
	ErrInvalidSig = errors.New("invalid transaction v, r, s values")
)
View Source
var MinCoinSupply = helpers.BipToPip(sdk.NewInt(1))
View Source
var ModuleCdc *codec.Codec

ModuleCdc defines the module codec

Functions

func ErrCalculateCommission

func ErrCalculateCommission(err string) *sdkerrors.Error

func ErrCheckExpired

func ErrCheckExpired(block string) *sdkerrors.Error

func ErrCheckRedeemed

func ErrCheckRedeemed() *sdkerrors.Error

func ErrCoinAlreadyExist

func ErrCoinAlreadyExist(coin string) *sdkerrors.Error

func ErrCoinDoesNotExist

func ErrCoinDoesNotExist(symbol string) *sdkerrors.Error

func ErrForbiddenCoinSymbol

func ErrForbiddenCoinSymbol(symbol string) *sdkerrors.Error

func ErrInsufficientCoinReserve

func ErrInsufficientCoinReserve() *sdkerrors.Error

func ErrInsufficientFunds

func ErrInsufficientFunds(fundsWant string, fundsExist string) *sdkerrors.Error

func ErrInsufficientFundsToPayCommission

func ErrInsufficientFundsToPayCommission(commission string) *sdkerrors.Error

func ErrInsufficientFundsToSellAll

func ErrInsufficientFundsToSellAll() *sdkerrors.Error

func ErrInternal

func ErrInternal(err string) *sdkerrors.Error

func ErrInvalidAmount

func ErrInvalidAmount() *sdkerrors.Error

func ErrInvalidCRR

func ErrInvalidCRR(crr string) *sdkerrors.Error

func ErrInvalidChainID

func ErrInvalidChainID(wanted string, issued string) *sdkerrors.Error

func ErrInvalidCheck

func ErrInvalidCheck(data string) *sdkerrors.Error

func ErrInvalidCoinInitialReserve

func ErrInvalidCoinInitialReserve(reserve string) *sdkerrors.Error

func ErrInvalidCoinInitialVolume

func ErrInvalidCoinInitialVolume(initialVolume string) *sdkerrors.Error

func ErrInvalidCoinSymbol

func ErrInvalidCoinSymbol(symbol string) *sdkerrors.Error

func ErrInvalidCoinTitle

func ErrInvalidCoinTitle(title string) *sdkerrors.Error

func ErrInvalidNonce

func ErrInvalidNonce() *sdkerrors.Error

func ErrInvalidPassphrase

func ErrInvalidPassphrase(error string) *sdkerrors.Error

func ErrInvalidPkey

func ErrInvalidPkey() *sdkerrors.Error

func ErrInvalidProof

func ErrInvalidProof(error string) *sdkerrors.Error

func ErrLimitVolumeBroken

func ErrLimitVolumeBroken(volume string, limit string) *sdkerrors.Error

func ErrMaximumValueToSellReached

func ErrMaximumValueToSellReached(amount string, max string) *sdkerrors.Error

func ErrMinimumValueToBuyReached

func ErrMinimumValueToBuyReached(amount string, min string) *sdkerrors.Error

func ErrReceiverEmpty added in v1.2.4

func ErrReceiverEmpty() *sdkerrors.Error

func ErrRetrievedAnotherCoin

func ErrRetrievedAnotherCoin(symbolWant string, symbolRetrieved string) *sdkerrors.Error

func ErrSameCoin

func ErrSameCoin() *sdkerrors.Error

func ErrTxBreaksMinReserveRule

func ErrTxBreaksMinReserveRule(minCoinReserve string, reserve string) *sdkerrors.Error

func ErrTxBreaksMinVolumeRule added in v1.3.0

func ErrTxBreaksMinVolumeRule(volume string) *sdkerrors.Error

func ErrTxBreaksVolumeLimit

func ErrTxBreaksVolumeLimit(volume string, limitVolume string) *sdkerrors.Error

func ErrUnableDecodeCheck

func ErrUnableDecodeCheck(check string) *sdkerrors.Error

func ErrUnableDecodeProof

func ErrUnableDecodeProof() *sdkerrors.Error

func ErrUnableRPLEncodeCheck

func ErrUnableRPLEncodeCheck(error string) *sdkerrors.Error

func ErrUnableRecoverAddress

func ErrUnableRecoverAddress(error string) *sdkerrors.Error

func ErrUnableRecoverLockPkey

func ErrUnableRecoverLockPkey(error string) *sdkerrors.Error

func ErrUnableRetrieveArmoredPkey

func ErrUnableRetrieveArmoredPkey(name string, error string) *sdkerrors.Error

func ErrUnableRetrievePkey

func ErrUnableRetrievePkey(name string, error string) *sdkerrors.Error

func ErrUnableRetrieveSECPPkey

func ErrUnableRetrieveSECPPkey(name string, algo string) *sdkerrors.Error

func ErrUnableSignCheck

func ErrUnableSignCheck(error string) *sdkerrors.Error

func ErrUpdateBalance

func ErrUpdateBalance(account string, err string) *sdkerrors.Error

func ErrUpdateOnlyForCreator

func ErrUpdateOnlyForCreator() *sdkerrors.Error

func MinCoinReserve

func MinCoinReserve(ctx sdk.Context) sdk.Int

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable for coin module

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec

func ValidateBurn added in v1.3.0

func ValidateBurn(msg MsgBurnCoin) error

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the coin genesis parameters

func ValidateRedeemCheck

func ValidateRedeemCheck(msg MsgRedeemCheck) error

func ValidateSend

func ValidateSend(msg MsgSendCoin) error

Types

type Check

type Check struct {
	ChainID  string
	Coin     string
	Amount   *big.Int
	Nonce    []byte
	DueBlock uint64
	Lock     *big.Int
	V        *big.Int
	R        *big.Int
	S        *big.Int
}

func ParseCheck

func ParseCheck(buf []byte) (*Check, error)

func (*Check) Hash

func (check *Check) Hash() Hash

func (*Check) HashFull

func (check *Check) HashFull() Hash

func (*Check) HashWithoutLock

func (check *Check) HashWithoutLock() Hash

func (*Check) LockPubKey

func (check *Check) LockPubKey() ([]byte, error)

func (*Check) Sender

func (check *Check) Sender() (sdk.AccAddress, error)

func (*Check) SetSignature

func (check *Check) SetSignature(sig []byte)

func (*Check) Sign

func (check *Check) Sign(prv *ecdsa.PrivateKey) error

func (*Check) String

func (check *Check) String() string

type CodeType

type CodeType = uint32

Local code type

type Coin

type Coin struct {
	Title       string         `json:"title" yaml:"title"`                                   // Full coin title (Bitcoin)
	CRR         uint           `json:"constant_reserve_ratio" yaml:"constant_reserve_ratio"` // between 10 and 100
	Symbol      string         `json:"symbol" yaml:"symbol"`                                 // Short coin title (BTC)
	Reserve     sdk.Int        `json:"reserve" yaml:"reserve"`
	LimitVolume sdk.Int        `json:"limit_volume" yaml:"limit_volume"` // How many coins can be issued
	Volume      sdk.Int        `json:"volume" yaml:"volume"`
	Creator     sdk.AccAddress `json:"creator" yaml:"creator"`
	Identity    string         `json:"identity" yaml:"identity"`
}

func (Coin) IsBase

func (c Coin) IsBase() bool

func (Coin) String

func (c Coin) String() string

type GenesisState

type GenesisState struct {
	Title         string  `json:"title" yaml:"title"`   // Full coin title (Bitcoin)
	Symbol        string  `json:"symbol" yaml:"symbol"` // Short coin title (BTC)
	InitialVolume sdk.Int `json:"initial_volume" yaml:"initial_volume"`
}

GenesisState - all coin state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState - default GenesisState used by Cosmos Hub

func NewGenesisState

func NewGenesisState(title string, symbol string, initVolume sdk.Int) GenesisState

NewGenesisState creates a new GenesisState object

type Hash

type Hash [HashLength]byte

Hash represents the 32 byte Keccak256 hash of arbitrary data.

type MsgBurnCoin added in v1.3.0

type MsgBurnCoin struct {
	Sender sdk.AccAddress `json:"sender" yaml:"sender"`
	Coin   sdk.Coin       `json:"coin" yaml:"coin"`
}

func NewMsgBurnCoin added in v1.3.0

func NewMsgBurnCoin(sender sdk.AccAddress, coin sdk.Coin) MsgBurnCoin

func (MsgBurnCoin) GetSignBytes added in v1.3.0

func (msg MsgBurnCoin) GetSignBytes() []byte

func (MsgBurnCoin) GetSigners added in v1.3.0

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

func (MsgBurnCoin) Route added in v1.3.0

func (msg MsgBurnCoin) Route() string

func (MsgBurnCoin) Type added in v1.3.0

func (msg MsgBurnCoin) Type() string

func (MsgBurnCoin) ValidateBasic added in v1.3.0

func (msg MsgBurnCoin) ValidateBasic() error

type MsgBuyCoin

type MsgBuyCoin struct {
	Sender        sdk.AccAddress `json:"sender" yaml:"sender"`
	CoinToBuy     sdk.Coin       `json:"coin_to_buy" yaml:"coin_to_buy"`
	MaxCoinToSell sdk.Coin       `json:"max_coin_to_sell" yaml:"max_coin_to_sell"`
}

func NewMsgBuyCoin

func NewMsgBuyCoin(sender sdk.AccAddress, coinToBuy sdk.Coin, maxCoinToSell sdk.Coin) MsgBuyCoin

func (MsgBuyCoin) GetSignBytes

func (msg MsgBuyCoin) GetSignBytes() []byte

func (MsgBuyCoin) GetSigners

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

func (MsgBuyCoin) Route

func (msg MsgBuyCoin) Route() string

func (MsgBuyCoin) Type

func (msg MsgBuyCoin) Type() string

func (MsgBuyCoin) ValidateBasic

func (msg MsgBuyCoin) ValidateBasic() error

type MsgCreateCoin

type MsgCreateCoin struct {
	Sender               sdk.AccAddress `json:"sender" yaml:"sender"`
	Title                string         `json:"title" yaml:"title"`                                   // Full coin title (Bitcoin)
	Symbol               string         `json:"symbol" yaml:"symbol"`                                 // Short coin title (BTC)
	ConstantReserveRatio uint           `json:"constant_reserve_ratio" yaml:"constant_reserve_ratio"` // between 10 and 100
	InitialVolume        sdk.Int        `json:"initial_volume" yaml:"initial_volume"`
	InitialReserve       sdk.Int        `json:"initial_reserve" yaml:"initial_reserve"`
	LimitVolume          sdk.Int        `json:"limit_volume" yaml:"limit_volume"` // How many coins can be issued
	Identity             string         `json:"identity" yaml:"identity"`
}

func NewMsgCreateCoin

func NewMsgCreateCoin(sender sdk.AccAddress, title string, symbol string, crr uint, initVolume sdk.Int, initReserve sdk.Int, limitVolume sdk.Int, identity string) MsgCreateCoin

func (MsgCreateCoin) GetSignBytes

func (msg MsgCreateCoin) GetSignBytes() []byte

func (MsgCreateCoin) GetSigners

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

func (MsgCreateCoin) Route

func (msg MsgCreateCoin) Route() string

func (MsgCreateCoin) Type

func (msg MsgCreateCoin) Type() string

func (MsgCreateCoin) ValidateBasic

func (msg MsgCreateCoin) ValidateBasic() error

type MsgMultiSendCoin

type MsgMultiSendCoin struct {
	Sender sdk.AccAddress `json:"sender" yaml:"sender"`
	Sends  []Send         `json:"sends"`
}

func NewMsgMultiSendCoin

func NewMsgMultiSendCoin(sender sdk.AccAddress, sends []Send) MsgMultiSendCoin

func (MsgMultiSendCoin) GetSignBytes

func (msg MsgMultiSendCoin) GetSignBytes() []byte

func (MsgMultiSendCoin) GetSigners

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

func (MsgMultiSendCoin) Route

func (msg MsgMultiSendCoin) Route() string

func (MsgMultiSendCoin) Type

func (msg MsgMultiSendCoin) Type() string

func (MsgMultiSendCoin) ValidateBasic

func (msg MsgMultiSendCoin) ValidateBasic() error

type MsgRedeemCheck

type MsgRedeemCheck struct {
	Sender sdk.AccAddress `json:"sender" yaml:"sender"`
	Check  string         `json:"check" yaml:"check"`
	Proof  string         `json:"proof" yaml:"proof"`
}

func NewMsgRedeemCheck

func NewMsgRedeemCheck(sender sdk.AccAddress, check string, proof string) MsgRedeemCheck

func (MsgRedeemCheck) GetSignBytes

func (msg MsgRedeemCheck) GetSignBytes() []byte

func (MsgRedeemCheck) GetSigners

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

func (MsgRedeemCheck) Route

func (msg MsgRedeemCheck) Route() string

func (MsgRedeemCheck) Type

func (msg MsgRedeemCheck) Type() string

func (MsgRedeemCheck) ValidateBasic

func (msg MsgRedeemCheck) ValidateBasic() error

type MsgSellAllCoin

type MsgSellAllCoin struct {
	Sender       sdk.AccAddress `json:"sender" yaml:"sender"`
	CoinToSell   sdk.Coin       `json:"coin_to_sell" yaml:"coin_to_sell"`
	MinCoinToBuy sdk.Coin       `json:"min_coin_to_buy" yaml:"min_coin_to_buy"`
}

func NewMsgSellAllCoin

func NewMsgSellAllCoin(sender sdk.AccAddress, coinToSell sdk.Coin, minCoinToBuy sdk.Coin) MsgSellAllCoin

func (MsgSellAllCoin) GetSignBytes

func (msg MsgSellAllCoin) GetSignBytes() []byte

func (MsgSellAllCoin) GetSigners

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

func (MsgSellAllCoin) Route

func (msg MsgSellAllCoin) Route() string

func (MsgSellAllCoin) Type

func (msg MsgSellAllCoin) Type() string

func (MsgSellAllCoin) ValidateBasic

func (msg MsgSellAllCoin) ValidateBasic() error

type MsgSellCoin

type MsgSellCoin struct {
	Sender       sdk.AccAddress `json:"sender" yaml:"sender"`
	CoinToSell   sdk.Coin       `json:"coin_to_sell" yaml:"coin_to_sell"`
	MinCoinToBuy sdk.Coin       `json:"min_coin_to_buy" yaml:"min_coin_to_buy"`
}

func NewMsgSellCoin

func NewMsgSellCoin(sender sdk.AccAddress, coinToSell sdk.Coin, minCoinToBuy sdk.Coin) MsgSellCoin

func (MsgSellCoin) GetSignBytes

func (msg MsgSellCoin) GetSignBytes() []byte

func (MsgSellCoin) GetSigners

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

func (MsgSellCoin) Route

func (msg MsgSellCoin) Route() string

func (MsgSellCoin) Type

func (msg MsgSellCoin) Type() string

func (MsgSellCoin) ValidateBasic

func (msg MsgSellCoin) ValidateBasic() error

type MsgSendCoin

type MsgSendCoin struct {
	Sender   sdk.AccAddress `json:"sender" yaml:"sender"`
	Coin     sdk.Coin       `json:"coin" yaml:"coin"`
	Receiver sdk.AccAddress `json:"receiver" yaml:"receiver"`
}

func NewMsgSendCoin

func NewMsgSendCoin(sender sdk.AccAddress, coin sdk.Coin, receiver sdk.AccAddress) MsgSendCoin

func (MsgSendCoin) GetSignBytes

func (msg MsgSendCoin) GetSignBytes() []byte

func (MsgSendCoin) GetSigners

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

func (MsgSendCoin) Route

func (msg MsgSendCoin) Route() string

func (MsgSendCoin) Type

func (msg MsgSendCoin) Type() string

func (MsgSendCoin) ValidateBasic

func (msg MsgSendCoin) ValidateBasic() error

type MsgUpdateCoin

type MsgUpdateCoin struct {
	Sender      sdk.AccAddress `json:"sender" yaml:"sender"`
	Symbol      string         `json:"symbol" yaml:"symbol"`
	LimitVolume sdk.Int        `json:"limit_volume" yaml:"limit_volume"`
	Identity    string         `json:"identity" yaml:"identity"`
}

func NewMsgUpdateCoin

func NewMsgUpdateCoin(sender sdk.AccAddress, symbol string, limitVolume sdk.Int, identity string) MsgUpdateCoin

func (MsgUpdateCoin) GetSignBytes

func (msg MsgUpdateCoin) GetSignBytes() []byte

func (MsgUpdateCoin) GetSigners

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

func (MsgUpdateCoin) Route

func (msg MsgUpdateCoin) Route() string

func (MsgUpdateCoin) Type

func (msg MsgUpdateCoin) Type() string

func (MsgUpdateCoin) ValidateBasic

func (msg MsgUpdateCoin) 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)
}

type Params

type Params struct {
}

Params - used for initializing default parameter for coin at genesis

func DefaultParams

func DefaultParams() Params

DefaultParams defines the parameters for this module

func NewParams

func NewParams() Params

NewParams creates a new Params object

func (*Params) ParamSetPairs

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

ParamSetPairs - Implements params.ParamSet

func (Params) String

func (p Params) String() string

String implements the stringer interface for Params

type QueryResCoins

type QueryResCoins []string

func (QueryResCoins) String

func (n QueryResCoins) String() string

type Send

type Send struct {
	Coin     sdk.Coin       `json:"coin" yaml:"coin"`
	Receiver sdk.AccAddress `json:"receiver" yaml:"receiver"`
}

Jump to

Keyboard shortcuts

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