types

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeInvalidGenesis = 101

	CodeBeaconDoesNotExist             = 201
	CodeBeaconAlreadyRegistered        = 202
	CodeBeaconTimestampAlreadyRecorded = 203
	CodeNotBeaconOwner                 = 204
	CodeMissingData                    = 205

	CodeBeaconInsufficientFee   = 301
	CodeBeaconTooMuchFee        = 302
	CodeBeaconIncorrectFeeDenom = 303

	CodeBeaconFeePayerNotOwner = 401
)
View Source
const (
	// module name
	ModuleName = "beacon"

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

	DefaultParamspace = ModuleName

	// QuerierRoute is the querier route for the BEACON store.
	QuerierRoute = StoreKey
)
View Source
const (
	RouterKey = ModuleName // defined in keys.go file

	RegisterAction = "register_beacon"
	RecordAction   = "record_beacon_timestamp"
)
View Source
const (
	// BEACON fees, in nano UND
	RegFee    = 1000000000000                // 1000 UND - used in init genesis
	RecordFee = 1000000000                   // 1 UND - used in init genesis
	FeeDenom  = undtypes.DefaultDenomination // used in init genesis

	DefaultStartingBeaconID uint64 = 1 // used in init genesis
)

Variables

View Source
var (
	// ErrInvalidGenesis error for an invalid beacon GenesisState
	ErrInvalidGenesis                 = sdkerrors.Register(ModuleName, CodeInvalidGenesis, "invalid genesis")
	ErrBeaconDoesNotExist             = sdkerrors.Register(ModuleName, CodeBeaconDoesNotExist, "beacon does not exist")
	ErrNotBeaconOwner                 = sdkerrors.Register(ModuleName, CodeNotBeaconOwner, "not beacon owner")
	ErrBeaconAlreadyRegistered        = sdkerrors.Register(ModuleName, CodeBeaconAlreadyRegistered, "beacon already registered")
	ErrBeaconTimestampAlreadyRecorded = sdkerrors.Register(ModuleName, CodeBeaconTimestampAlreadyRecorded, "beacon timestamp already recorded")
	ErrMissingData                    = sdkerrors.Register(ModuleName, CodeMissingData, "missing data")
	ErrInsufficientBeaconFee          = sdkerrors.Register(ModuleName, CodeBeaconInsufficientFee, "insufficient beacon fee")
	ErrTooMuchBeaconFee               = sdkerrors.Register(ModuleName, CodeBeaconTooMuchFee, "too much beacon fee")
	ErrFeePayerNotOwner               = sdkerrors.Register(ModuleName, CodeBeaconFeePayerNotOwner, "fee payer is not beacon owner")
	ErrIncorrectFeeDenomination       = sdkerrors.Register(ModuleName, CodeBeaconIncorrectFeeDenom, "incorrect beacon fee denomination")
)
View Source
var (
	EventTypeRegisterBeacon        = "register_beacon"
	EventTypeRecordBeaconTimestamp = "record_beacon_timestamp"

	AttributeValueCategory = ModuleName

	AttributeKeyOwner               = "beacon_owner"
	AttributeKeyBeaconId            = "beacon_id"
	AttributeKeyBeaconMoniker       = "beacon_moniker"
	AttributeKeyBeaconName          = "beacon_name"
	AttributeKeyTimestampID         = "beacon_timestamp_id"
	AttributeKeyTimestampHash       = "beacon_timestamp_hash"
	AttributeKeyTimestampSubmitTime = "beacon_timestamp_submit_time"
)
View Source
var (

	// key used to store the current highest BEACON ID
	HighestBeaconIDKey = []byte{0x20}

	// RegisteredBeaconPrefix prefix for registered BEACON store
	RegisteredBeaconPrefix = []byte{0x01}

	// RecordedBeaconTimestampPrefix prefix for BEACON Timestamps store
	RecordedBeaconTimestampPrefix = []byte{0x02}
)
View Source
var (
	KeyFeeRegister = []byte("FeeRegister")
	KeyFeeRecord   = []byte("FeeRecord")
	KeyDenom       = []byte("Denom")
)

Parameter store keys

View Source
var ModuleCdc = codec.New()

Functions

func BeaconAllTimestampsKey

func BeaconAllTimestampsKey(beaconID uint64) []byte

BeaconAllTimestampsKey gets the key for a specific BEACON's timestamps

func BeaconKey

func BeaconKey(beaconID uint64) []byte

BeaconKey gets a specific purchase order ID key for use in the store

func BeaconTimestampKey

func BeaconTimestampKey(beaconID, timestampID uint64) []byte

BeaconTimestampKey gets the key for a single BEACON's specific timestamp ID

func GetBeaconIDBytes

func GetBeaconIDBytes(beaconID uint64) (beaconIDBz []byte)

GetBeaconIDBytes returns the byte representation of the BeaconID used for getting the highest Beacon ID from the database

func GetBeaconIDFromBytes

func GetBeaconIDFromBytes(bz []byte) (beaconID uint64)

GetBeaconIDFromBytes returns BeaconID in uint64 format from a byte array used for getting the highest Beacon ID from the database

func GetTimestampIDBytes

func GetTimestampIDBytes(timestampID uint64) (timestampIDBz []byte)

func GetTimestampIDFromBytes

func GetTimestampIDFromBytes(bz []byte) (timestampID uint64)

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamTable for BEACON module.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the Amino codec

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the provided genesis state to ensure the expected invariants holds.

Types

type Beacon

type Beacon struct {
	BeaconID        uint64         `json:"beacon_id"`
	Moniker         string         `json:"moniker"`
	Name            string         `json:"name"`
	LastTimestampID uint64         `json:"last_timestamp_id"`
	Owner           sdk.AccAddress `json:"owner"`
}

Beacon is a struct that contains all the metadata of a registered BEACON

func NewBeacon

func NewBeacon() Beacon

NewBeacon returns a new Beacon struct

func (Beacon) String

func (b Beacon) String() string

implement fmt.Stringer

type BeaconExport

type BeaconExport struct {
	Beacon           Beacon            `json:"beacon" yaml:"beacon"`
	BeaconTimestamps []BeaconTimestamp `json:"timestamps" yaml:"timestamps"`
}

type BeaconTimestamp

type BeaconTimestamp struct {
	BeaconID    uint64         `json:"beacon_id"`
	TimestampID uint64         `json:"timestamp_id"`
	SubmitTime  uint64         `json:"submit_time"`
	Hash        string         `json:"hash"`
	Owner       sdk.AccAddress `json:"owner"`
}

BeaconTimestamp is a struct that contains a BEACON's recorded timestamp hash

func NewBeaconTimestamp

func NewBeaconTimestamp() BeaconTimestamp

NewBeaconTimestamp returns a new BeaconTimestamp struct

func (BeaconTimestamp) String

func (bts BeaconTimestamp) String() string

implement fmt.Stringer

type BeaconTimestamps

type BeaconTimestamps []BeaconTimestamp

BeaconTimestamps is an array of BeaconTimestamp

func (BeaconTimestamps) String

func (b BeaconTimestamps) String() string

String implements stringer interface

type Beacons

type Beacons []Beacon

Beacons is an array of Beacon

func (Beacons) String

func (b Beacons) String() string

String implements stringer interface

type EnterpriseKeeper

type EnterpriseKeeper interface {
	GetLockedUndAmountForAccount(ctx sdk.Context, address sdk.AccAddress) sdk.Coin
}

EnterpriseKeeper defines the expected enterprise keeper

type GenesisState

type GenesisState struct {
	Params           Params         `json:"params" yaml:"params"`                         // beacon params
	StartingBeaconID uint64         `json:"starting_beacon_id" yaml:"starting_beacon_id"` // should be 1
	Beacons          []BeaconExport `json:"registered_beacons" yaml:"registered_beacons"`
}

GenesisState - beacon state

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState creates a default GenesisState object

func NewGenesisState

func NewGenesisState(params Params, startingBeaconID uint64) GenesisState

NewGenesisState creates a new GenesisState object

func (GenesisState) Equal

func (data GenesisState) Equal(data2 GenesisState) bool

Equal checks whether two beacon GenesisState structs are equivalent

func (GenesisState) IsEmpty

func (data GenesisState) IsEmpty() bool

IsEmpty returns true if a GenesisState is empty

type MsgRecordBeaconTimestamp

type MsgRecordBeaconTimestamp struct {
	BeaconID   uint64         `json:"beacon_id"`
	Hash       string         `json:"hash"`
	SubmitTime uint64         `json:"submit_time"`
	Owner      sdk.AccAddress `json:"owner"`
}

MsgRecordBeaconTimestamp defines a RecordBeaconTimestamp message

func NewMsgRecordBeaconTimestamp

func NewMsgRecordBeaconTimestamp(
	beaconId uint64,
	hash string,
	subTime uint64,
	owner sdk.AccAddress) MsgRecordBeaconTimestamp

NewMsgRecordBeaconTimestamp is a constructor function for MsgRecordBeaconTimestamp

func (MsgRecordBeaconTimestamp) GetSignBytes

func (msg MsgRecordBeaconTimestamp) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgRecordBeaconTimestamp) GetSigners

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

GetSigners defines whose signature is required

func (MsgRecordBeaconTimestamp) Route

func (msg MsgRecordBeaconTimestamp) Route() string

Route should return the name of the module

func (MsgRecordBeaconTimestamp) Type

func (msg MsgRecordBeaconTimestamp) Type() string

Type should return the action

func (MsgRecordBeaconTimestamp) ValidateBasic

func (msg MsgRecordBeaconTimestamp) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type MsgRegisterBeacon

type MsgRegisterBeacon struct {
	Moniker    string         `json:"moniker"`
	BeaconName string         `json:"name"`
	Owner      sdk.AccAddress `json:"owner"`
}

MsgRegisterBeacon defines a RegisterBeacon message

func NewMsgRegisterBeacon

func NewMsgRegisterBeacon(moniker string, beaconName string, owner sdk.AccAddress) MsgRegisterBeacon

NewMsgRegisterBeacon is a constructor function for MsgRegisterBeacon

func (MsgRegisterBeacon) GetSignBytes

func (msg MsgRegisterBeacon) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgRegisterBeacon) GetSigners

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

GetSigners defines whose signature is required

func (MsgRegisterBeacon) Route

func (msg MsgRegisterBeacon) Route() string

Route should return the name of the module

func (MsgRegisterBeacon) Type

func (msg MsgRegisterBeacon) Type() string

Type should return the action

func (MsgRegisterBeacon) ValidateBasic

func (msg MsgRegisterBeacon) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type Params

type Params struct {
	FeeRegister uint64 `json:"fee_register" yaml:"fee_register"` // Fee for registering a BEACON
	FeeRecord   uint64 `json:"fee_record" yaml:"fee_record"`     // Fee for recording timestamps for a BEACON
	Denom       string `json:"denom" yaml:"denom"`               // Fee denomination
}

beacon parameters

func DefaultParams

func DefaultParams() Params

default BEACON module parameters

func NewParams

func NewParams(feeReg, feeRec uint64, denom string) Params

func (*Params) ParamSetPairs

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

Implements params.ParamSet

func (Params) String

func (p Params) String() string

func (Params) Validate added in v1.2.0

func (p Params) Validate() error

validate params

type QueryBeaconParams

type QueryBeaconParams struct {
	Page    int
	Limit   int
	Moniker string
	Owner   sdk.AccAddress
}

QueryBeaconParams Params for query 'custom/beacon/registered'

func NewQueryBeaconParams

func NewQueryBeaconParams(page, limit int, monkker string, owner sdk.AccAddress) QueryBeaconParams

NewQueryBeaconParams creates a new instance of QueryBeaconParams

type QueryBeaconTimestampParams

type QueryBeaconTimestampParams struct {
	BeaconID   uint64
	Page       int
	Limit      int
	SubmitTime uint64
	Hash       string
}

QueryBeaconTimestampParams Params for query 'custom/beacon/timestamps'

func NewQueryBeaconTimestampParams

func NewQueryBeaconTimestampParams(page, limit int, beaconID uint64, hash string, submitTime uint64) QueryBeaconTimestampParams

NewQueryBeaconTimestampParams creates a new instance of QueryBeaconTimestampParams

type QueryResBeaconTimestampHashes

type QueryResBeaconTimestampHashes []BeaconTimestamp

QueryResBeaconTimestampHashes Queries Result Payload for a Beacon timestamp Hashes query

func (QueryResBeaconTimestampHashes) String

func (h QueryResBeaconTimestampHashes) String() (out string)

implement fmt.Stringer

type QueryResBeacons

type QueryResBeacons []Beacon

QueryResBeacons Queries BEACONs

func (QueryResBeacons) String

func (wc QueryResBeacons) String() (out string)

implement fmt.Stringer

Jump to

Keyboard shortcuts

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