types

package
v0.0.0-...-cc252f9 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ModuleName is the name of the module
	ModuleName = "coinpricebet"
	// StoreKey to be used when creating the KVStore
	StoreKey = ModuleName
)
View Source
const RouterKey = ModuleName

RouterKey is they name of the coin_price_bet module

Variables

View Source
var (
	ErrInvalidBasicMsg        = sdkerrors.Register(ModuleName, 1, "InvalidBasicMsg")
	ErrBadDataValue           = sdkerrors.Register(ModuleName, 2, "BadDataValue")
	ErrUnauthorizedPermission = sdkerrors.Register(ModuleName, 3, "UnauthorizedPermission")
	ErrItemDuplication        = sdkerrors.Register(ModuleName, 4, "ItemDuplication")
	ErrItemNotFound           = sdkerrors.Register(ModuleName, 5, "ItemNotFound")
	ErrInvalidState           = sdkerrors.Register(ModuleName, 6, "InvalidState")
	ErrBadWasmExecution       = sdkerrors.Register(ModuleName, 7, "BadWasmExecution")
	ErrOnlyOneDenomAllowed    = sdkerrors.Register(ModuleName, 8, "OnlyOneDenomAllowed")
	ErrInvalidDenom           = sdkerrors.Register(ModuleName, 9, "InvalidDenom")
	ErrUnknownClientID        = sdkerrors.Register(ModuleName, 10, "UnknownClientID")
	Error                     = sdkerrors.Register(ModuleName, 11, "Error")
)
View Source
var (
	// GlobalStoreKeyPrefix is a prefix for versioning store
	GlobalStoreKeyPrefix = []byte{0x00}
	// ChannelStoreKeyPrefix is a prefix for storing channel
	ChannelStoreKeyPrefix = append(GlobalStoreKeyPrefix, []byte("Channel")...)

	// Prefix to store prices of a coin in a particular day
	DayCoinPricesStoreKeyPrefix = append(GlobalStoreKeyPrefix, []byte("DayCoinPrices")...)

	// LastCoinPriceStoreKeyPrefix is a prefix for storing last price of a coin: coinId => price
	LastCoinPriceStoreKeyPrefix = append(GlobalStoreKeyPrefix, []byte("LastCoinPrice")...)

	// BetDaysStoreKey is a prefix for storing block times array [time, ...]
	BetDaysStoreKeyPrefix = append(GlobalStoreKeyPrefix, []byte("BetDays")...)

	// DayInfoStoreKey is a prefix for storing day infos dayId => {state, ...}
	DayInfoStoreKeyPrefix = append(GlobalStoreKeyPrefix, []byte("DayInfo")...)

	// DayCoinInfoStoreKey is a prefix for storing day+coin infos: dayId+coinId => {bets, ...}
	DayCoinInfoStoreKeyPrefix = append(GlobalStoreKeyPrefix, []byte("DayCoinInfo")...)

	// Prefix for day+coin+bettor => total amount
	DayCoinBettorAmountStoreKeyPrefix = append(GlobalStoreKeyPrefix, []byte("DayCoinBettorAmount")...)

	// Prefix for day+coin+bettor => paid
	DayCoinBettorPaidStoreKeyPrefix = append(GlobalStoreKeyPrefix, []byte("DayCoinBettorPaid")...)

	// All bets amount
	TotalBetsAmountStoreKey = append(GlobalStoreKeyPrefix, []byte("TotalBetsAmount")...)

	// All wins amount
	TotalWinsAmountStoreKey = append(GlobalStoreKeyPrefix, []byte("TotalWinsAmount")...)
)
View Source
var BAND_CHAIN_ID string = "ibc-bandchain"
View Source
var COMPLETE_COIN_PRICE_UPDATE_ORACLE_PACKET_CLIENT_ID_PREFIX string = "COIN_PRICE_UPDATE_REQUEST"
View Source
var GAIA_CHAIN_ID string = "band-cosmoshub"
View Source
var MULTIPLIER int64 = 1000000
View Source
var ModuleCdc = codec.New()

ModuleCdc is the codec for the module.

View Source
var ORACLE_PORT string = "coinpricebet"
View Source
var TRANSFER_PORT string = "transfer"
View Source
var VB_CHAIN_ID string = "band-consumer"

Functions

func BytesToInt64

func BytesToInt64(b []byte) int64

func ChannelStoreKey

func ChannelStoreKey(chainName, channelPort string) []byte

Generate key for each verified channel in store

func DayCoinBettorAmountStoreKey

func DayCoinBettorAmountStoreKey(dayId int64, coinId int64, bettor string) []byte

Generate key for each day+coin+bettor => total amount in store

func DayCoinBettorPaidStoreKey

func DayCoinBettorPaidStoreKey(dayId int64, coinId int64, bettor string) []byte

Generate key for each day+coin+bettor => paid in store

func DayCoinInfoStoreKey

func DayCoinInfoStoreKey(dayId int64, coinId int64) []byte

Generate key for each day+coin info in store

func DayCoinPricesStoreKey

func DayCoinPricesStoreKey(dayId int64, coinId int64) []byte

Generate key for each day+coin prices in store

func DayInfoStoreKey

func DayInfoStoreKey(dayId int64) []byte

Generate key for each day info struct

func GetCoins

func GetCoins() []string

These should probably be set in the genesis state

func GetDayCoinId

func GetDayCoinId(dayId int64, coinId int64) int64

Generate dayId+coinId

func GetDayId

func GetDayId(blockTime int64) int64

Get days since epoch

func GetEscrowAddress

func GetEscrowAddress() sdk.AccAddress

func GetFirstDayId

func GetFirstDayId() int64

func GetGenesisBlockTime

func GetGenesisBlockTime() int64

func Int64ToBytes

func Int64ToBytes(num int64) []byte

func LastCoinPriceStoreKey

func LastCoinPriceStoreKey(coinId int64) []byte

Generate key for each coin last price store key

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the Amino codec.

func UInt64ToBytes

func UInt64ToBytes(num uint64) []byte

Types

type BankKeeper

type BankKeeper interface {
	AddCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, error)
	SendCoins(ctx sdk.Context, from sdk.AccAddress, to sdk.AccAddress, amt sdk.Coins) error
}

BankKeeper defines the expected bank keeper

type BetDay

type BetDay struct {
	GrandPrize uint64 // total prize for a day
}

Structure with all the current bets information in a contest period (e.g. day)

type BetDayCoin

type BetDayCoin struct {
	TotalAmount uint64
}

Structure with coin bets in a contest period (e.g. day)

type Block

type Block struct {
	Time   int64   `json:"times"`
	Prices []int64 `json:"prices"`
}

type BorshDecoder

type BorshDecoder struct {
	// contains filtered or unexported fields
}

func NewBorshDecoder

func NewBorshDecoder(data []byte) BorshDecoder

func (*BorshDecoder) DecodeString

func (decoder *BorshDecoder) DecodeString() (string, error)

func (*BorshDecoder) DecodeU32

func (decoder *BorshDecoder) DecodeU32() (uint32, error)

func (*BorshDecoder) DecodeU64

func (decoder *BorshDecoder) DecodeU64() (uint64, error)

func (*BorshDecoder) DecodeU8

func (decoder *BorshDecoder) DecodeU8() (uint8, error)

func (*BorshDecoder) Finished

func (decoder *BorshDecoder) Finished() bool

type ChannelKeeper

type ChannelKeeper interface {
	GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channel.Channel, found bool)
	GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool)
	SendPacket(ctx sdk.Context, packet channelexported.PacketI) error
	PacketExecuted(ctx sdk.Context, packet channelexported.PacketI, acknowledgement []byte) error
	ChanCloseInit(ctx sdk.Context, portID, channelID string) error
	TimeoutExecuted(ctx sdk.Context, packet channelexported.PacketI) error
}

ChannelKeeper defines the expected IBC channel keeper

type DayState

type DayState uint8
const (
	BET DayState = iota
	DRAWING
	PAYOUT
	INVALID
)

type MsgBuyGold

type MsgBuyGold struct {
	Buyer  sdk.AccAddress `json:"buyer"`
	Amount sdk.Coins      `json:"amount"`
}

MsgBuyGold is a message for creating order to buy gold

func NewMsgBuyGold

func NewMsgBuyGold(
	buyer sdk.AccAddress,
	amount sdk.Coins,
) MsgBuyGold

NewMsgBuyGold creates a new MsgBuyGold instance.

func (MsgBuyGold) GetSignBytes

func (msg MsgBuyGold) GetSignBytes() []byte

GetSignBytes implements the sdk.Msg interface for MsgBuyGold.

func (MsgBuyGold) GetSigners

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

GetSigners implements the sdk.Msg interface for MsgBuyGold.

func (MsgBuyGold) Route

func (msg MsgBuyGold) Route() string

Route implements the sdk.Msg interface for MsgBuyGold.

func (MsgBuyGold) Type

func (msg MsgBuyGold) Type() string

Type implements the sdk.Msg interface for MsgBuyGold.

func (MsgBuyGold) ValidateBasic

func (msg MsgBuyGold) ValidateBasic() error

ValidateBasic implements the sdk.Msg interface for MsgBuyGold.

type MsgPayout

type MsgPayout struct {
	Bettor sdk.AccAddress `json:"bettor"`
	DayId  int64          `json:"dayId"`
}

MsgPayout is a message for placing a bet

func NewMsgPayout

func NewMsgPayout(
	bettor sdk.AccAddress,
	dayId int64,
) MsgPayout

NewMsgPayout creates a new MsgPayout instance.

func (MsgPayout) GetSignBytes

func (msg MsgPayout) GetSignBytes() []byte

GetSignBytes implements the sdk.Msg interface for MsgPayout.

func (MsgPayout) GetSigners

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

GetSigners implements the sdk.Msg interface for MsgPayout.

func (MsgPayout) Route

func (msg MsgPayout) Route() string

Route implements the sdk.Msg interface for MsgPayout.

func (MsgPayout) Type

func (msg MsgPayout) Type() string

Type implements the sdk.Msg interface for MsgPayout.

func (MsgPayout) ValidateBasic

func (msg MsgPayout) ValidateBasic() error

ValidateBasic implements the sdk.Msg interface for MsgPayout.

type MsgPlaceBet

type MsgPlaceBet struct {
	Bettor sdk.AccAddress `json:"bettor"`
	Amount sdk.Coins      `json:"amount"`
	CoinId uint8          `json:"coinId"`
}

MsgPlaceBet is a message for placing a bet

func NewMsgPlaceBet

func NewMsgPlaceBet(
	bettor sdk.AccAddress,
	amount sdk.Coins,
	coinId uint8,
) MsgPlaceBet

NewMsgPlaceBet creates a new MsgPlaceBet instance.

func (MsgPlaceBet) GetSignBytes

func (msg MsgPlaceBet) GetSignBytes() []byte

GetSignBytes implements the sdk.Msg interface for MsgPlaceBet.

func (MsgPlaceBet) GetSigners

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

GetSigners implements the sdk.Msg interface for MsgPlaceBet.

func (MsgPlaceBet) Route

func (msg MsgPlaceBet) Route() string

Route implements the sdk.Msg interface for MsgPlaceBet.

func (MsgPlaceBet) Type

func (msg MsgPlaceBet) Type() string

Type implements the sdk.Msg interface for MsgPlaceBet.

func (MsgPlaceBet) ValidateBasic

func (msg MsgPlaceBet) ValidateBasic() error

ValidateBasic implements the sdk.Msg interface for MsgPlaceBet.

type MsgSetSourceChannel

type MsgSetSourceChannel struct {
	ChainName     string         `json:"chain_name"`
	SourcePort    string         `json:"source_port"`
	SourceChannel string         `json:"source_channel"`
	Signer        sdk.AccAddress `json:"signer"`
}

MsgSetSourceChannel is a message for setting source channel to other chain

func NewMsgSetSourceChannel

func NewMsgSetSourceChannel(
	chainName, sourcePort, sourceChannel string,
	signer sdk.AccAddress,
) MsgSetSourceChannel

func (MsgSetSourceChannel) GetSignBytes

func (msg MsgSetSourceChannel) GetSignBytes() []byte

GetSignBytes implements the sdk.Msg interface for MsgSetSourceChannel.

func (MsgSetSourceChannel) GetSigners

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

GetSigners implements the sdk.Msg interface for MsgSetSourceChannel.

func (MsgSetSourceChannel) Route

func (msg MsgSetSourceChannel) Route() string

Route implements the sdk.Msg interface for MsgSetSourceChannel.

func (MsgSetSourceChannel) Type

func (msg MsgSetSourceChannel) Type() string

Type implements the sdk.Msg interface for MsgSetSourceChannel.

func (MsgSetSourceChannel) ValidateBasic

func (msg MsgSetSourceChannel) ValidateBasic() error

ValidateBasic implements the sdk.Msg interface for MsgSetSourceChannel.

type Result

type Result struct {
	Px uint64
}

func DecodeResult

func DecodeResult(data []byte) (Result, error)

Jump to

Keyboard shortcuts

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