Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToInt64(b []byte) int64
- func ChannelStoreKey(chainName, channelPort string) []byte
- func DayCoinBettorAmountStoreKey(dayId int64, coinId int64, bettor string) []byte
- func DayCoinBettorPaidStoreKey(dayId int64, coinId int64, bettor string) []byte
- func DayCoinInfoStoreKey(dayId int64, coinId int64) []byte
- func DayCoinPricesStoreKey(dayId int64, coinId int64) []byte
- func DayInfoStoreKey(dayId int64) []byte
- func GetCoins() []string
- func GetDayCoinId(dayId int64, coinId int64) int64
- func GetDayId(blockTime int64) int64
- func GetEscrowAddress() sdk.AccAddress
- func GetFirstDayId() int64
- func GetGenesisBlockTime() int64
- func Int64ToBytes(num int64) []byte
- func LastCoinPriceStoreKey(coinId int64) []byte
- func RegisterCodec(cdc *codec.Codec)
- func UInt64ToBytes(num uint64) []byte
- type BankKeeper
- type BetDay
- type BetDayCoin
- type Block
- type BorshDecoder
- type ChannelKeeper
- type DayState
- type MsgBuyGold
- type MsgPayout
- type MsgPlaceBet
- type MsgSetSourceChannel
- type Result
Constants ¶
const ( // ModuleName is the name of the module ModuleName = "coinpricebet" // StoreKey to be used when creating the KVStore StoreKey = ModuleName )
const RouterKey = ModuleName
RouterKey is they name of the coin_price_bet module
Variables ¶
var ( ErrInvalidBasicMsg = sdkerrors.Register(ModuleName, 1, "InvalidBasicMsg") ErrBadDataValue = sdkerrors.Register(ModuleName, 2, "BadDataValue") 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") )
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")...) )
var BAND_CHAIN_ID string = "ibc-bandchain"
var COMPLETE_COIN_PRICE_UPDATE_ORACLE_PACKET_CLIENT_ID_PREFIX string = "COIN_PRICE_UPDATE_REQUEST"
var GAIA_CHAIN_ID string = "band-cosmoshub"
var Logger log.Logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout))
var MULTIPLIER int64 = 1000000
var ModuleCdc = codec.New()
ModuleCdc is the codec for the module.
var ORACLE_PORT string = "coinpricebet"
var TRANSFER_PORT string = "transfer"
var VB_CHAIN_ID string = "band-consumer"
Functions ¶
func BytesToInt64 ¶
func ChannelStoreKey ¶
Generate key for each verified channel in store
func DayCoinBettorAmountStoreKey ¶
Generate key for each day+coin+bettor => total amount in store
func DayCoinBettorPaidStoreKey ¶
Generate key for each day+coin+bettor => paid in store
func DayCoinInfoStoreKey ¶
Generate key for each day+coin info in store
func DayCoinPricesStoreKey ¶
Generate key for each day+coin prices in store
func DayInfoStoreKey ¶
Generate key for each day info struct
func GetEscrowAddress ¶
func GetEscrowAddress() sdk.AccAddress
func GetFirstDayId ¶
func GetFirstDayId() int64
func GetGenesisBlockTime ¶
func GetGenesisBlockTime() int64
func Int64ToBytes ¶
func LastCoinPriceStoreKey ¶
Generate key for each coin last price store key
func RegisterCodec ¶
RegisterCodec registers concrete types on the Amino codec.
func UInt64ToBytes ¶
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 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 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 ¶
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) ValidateBasic ¶
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.