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

	CodeWrkChainDoesNotExist         = 201
	CodeWrkChainAlreadyRegistered    = 202
	CodeWrkChainBlockAlreadyRecorded = 203
	CodeNotWrkChainOwner             = 204
	CodeMissingData                  = 205
	CodeInvalidData                  = 206

	CodeWrkChainInsufficientFee   = 301
	CodeWrkChainTooMuchFee        = 302
	CodeWrkChainIncorrectFeeDenom = 303

	CodeWrkChainFeePayerNotOwner = 401
)
View Source
const (
	// module name
	ModuleName = "wrkchain"

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

	DefaultParamspace = ModuleName

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

	RegisterAction = "register_wrkchain"
	RecordAction   = "record_wrkchain_hash"
)
View Source
const (
	// WRKChain 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

	DefaultStartingWrkChainID uint64 = 1 // used in init genesis
)

Variables

View Source
var (
	ErrInvalidGenesis               = sdkerrors.Register(ModuleName, CodeInvalidGenesis, "invalid genesis")
	ErrWrkChainDoesNotExist         = sdkerrors.Register(ModuleName, CodeWrkChainDoesNotExist, "wrkchain does not exist")
	ErrNotWrkChainOwner             = sdkerrors.Register(ModuleName, CodeNotWrkChainOwner, "not wrkchain owner")
	ErrWrkChainAlreadyRegistered    = sdkerrors.Register(ModuleName, CodeWrkChainAlreadyRegistered, "wrkchain already registered")
	ErrMissingData                  = sdkerrors.Register(ModuleName, CodeMissingData, "missing data")
	ErrInvalidData                  = sdkerrors.Register(ModuleName, CodeInvalidData, "invalid data")
	ErrWrkChainBlockAlreadyRecorded = sdkerrors.Register(ModuleName, CodeWrkChainBlockAlreadyRecorded, "wrkchain hashes already recorded")
	ErrInsufficientWrkChainFee      = sdkerrors.Register(ModuleName, CodeWrkChainInsufficientFee, "insufficient wrkchain fee")
	ErrTooMuchWrkChainFee           = sdkerrors.Register(ModuleName, CodeWrkChainTooMuchFee, "too much wrkchain fee")
	ErrFeePayerNotOwner             = sdkerrors.Register(ModuleName, CodeWrkChainFeePayerNotOwner, "fee payer not wrkchain owner")
	ErrIncorrectFeeDenomination     = sdkerrors.Register(ModuleName, CodeWrkChainIncorrectFeeDenom, "incorrect wrkchain fee doenomination")
)
View Source
var (
	EventTypeRegisterWrkChain    = "register_wrkchain"
	EventTypeRecordWrkChainBlock = "record_wrkchain_block"

	AttributeValueCategory = ModuleName

	AttributeKeyOwner               = "wrkchain_owner"
	AttributeKeyWrkChainId          = "wrkchain_id"
	AttributeKeyWrkChainMoniker     = "wrkchain_moniker"
	AttributeKeyWrkChainName        = "wrkchain_name"
	AttributeKeyWrkChainGenesisHash = "wrkchain_genesis_hash"
	AttributeKeyBaseType            = "wrkchain_base_type"
	AttributeKeyBlockHash           = "wrkchain_block_hash"
	AttributeKeyBlockHeight         = "wrkchain_block_height"
	AttributeKeyParentHash          = "wrkchain_parent_hash"
	AttributeKeyHash1               = "wrkchain_hash1"
	AttributeKeyHash2               = "wrkchain_hash2"
	AttributeKeyHash3               = "wrkchain_hash3"
)
View Source
var (

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

	// RegisteredWrkChainPrefix prefix for registered WRKChain store
	RegisteredWrkChainPrefix = []byte{0x01}

	// RegisteredWrkChainPrefix prefix for WRKChain Hashes store
	RecordedWrkChainBlockHashPrefix = []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 GetWrkChainIDBytes

func GetWrkChainIDBytes(wrkChainID uint64) (wrkChainIDBz []byte)

GetWrkChainIDBytes returns the byte representation of the wrkChainID used for getting the highest WRKChain ID from the database

func GetWrkChainIDFromBytes

func GetWrkChainIDFromBytes(bz []byte) (wrkChainID uint64)

GetWrkChainIDFromBytes returns wrkChainID in uint64 format from a byte array used for getting the highest WRKChain ID from the database

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamTable for wrkchain 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.

func WrkChainAllBlocksKey

func WrkChainAllBlocksKey(wrkChainID uint64) []byte

func WrkChainBlockKey

func WrkChainBlockKey(wrkChainID, height uint64) []byte

func WrkChainKey

func WrkChainKey(wrkChainID uint64) []byte

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

Types

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"`                             // wrkchain params
	StartingWrkChainID uint64           `json:"starting_wrkchain_id" yaml:"starting_wrkchain_id"` // should be 1
	WrkChains          []WrkChainExport `json:"registered_wrkchains" yaml:"registered_wrkchains"`
}

GenesisState - wrkchain state

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState creates a default GenesisState object

func NewGenesisState

func NewGenesisState(params Params, startingWrkChainID uint64) GenesisState

NewGenesisState creates a new GenesisState object

func (GenesisState) Equal

func (data GenesisState) Equal(data2 GenesisState) bool

Equal checks whether two wrkchain GenesisState structs are equivalent

func (GenesisState) IsEmpty

func (data GenesisState) IsEmpty() bool

IsEmpty returns true if a GenesisState is empty

type MsgRecordWrkChainBlock

type MsgRecordWrkChainBlock struct {
	WrkChainID uint64         `json:"wrkchain_id"`
	Height     uint64         `json:"height"`
	BlockHash  string         `json:"blockhash"`
	ParentHash string         `json:"parenthash"`
	Hash1      string         `json:"hash1"`
	Hash2      string         `json:"hash2"`
	Hash3      string         `json:"hash3"`
	Owner      sdk.AccAddress `json:"owner"`
}

MsgRecordWrkChainBlock defines a RecordWrkChainBlock message

func NewMsgRecordWrkChainBlock

func NewMsgRecordWrkChainBlock(
	wrkchainId uint64,
	height uint64,
	blockHash string,
	parentHash string,
	hash1 string,
	hash2 string,
	hash3 string,
	owner sdk.AccAddress) MsgRecordWrkChainBlock

NewMsgRecordWrkChainBlock is a constructor function for MsgRecordWrkChainBlock

func (MsgRecordWrkChainBlock) GetSignBytes

func (msg MsgRecordWrkChainBlock) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgRecordWrkChainBlock) GetSigners

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

GetSigners defines whose signature is required

func (MsgRecordWrkChainBlock) Route

func (msg MsgRecordWrkChainBlock) Route() string

Route should return the name of the module

func (MsgRecordWrkChainBlock) Type

func (msg MsgRecordWrkChainBlock) Type() string

Type should return the action

func (MsgRecordWrkChainBlock) ValidateBasic

func (msg MsgRecordWrkChainBlock) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type MsgRegisterWrkChain

type MsgRegisterWrkChain struct {
	Moniker      string         `json:"moniker"`
	WrkChainName string         `json:"name"`
	GenesisHash  string         `json:"genesis"`
	BaseType     string         `json:"type"`
	Owner        sdk.AccAddress `json:"owner"`
}

MsgRegisterWrkChain defines a RegisterWrkChain message

func NewMsgRegisterWrkChain

func NewMsgRegisterWrkChain(moniker string, genesisHash string, wrkchainName string, baseType string, owner sdk.AccAddress) MsgRegisterWrkChain

NewMsgRegisterWrkChain is a constructor function for MsgRegisterWrkChain

func (MsgRegisterWrkChain) GetSignBytes

func (msg MsgRegisterWrkChain) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgRegisterWrkChain) GetSigners

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

GetSigners defines whose signature is required

func (MsgRegisterWrkChain) Route

func (msg MsgRegisterWrkChain) Route() string

Route should return the name of the module

func (MsgRegisterWrkChain) Type

func (msg MsgRegisterWrkChain) Type() string

Type should return the action

func (MsgRegisterWrkChain) ValidateBasic

func (msg MsgRegisterWrkChain) 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 WRKChain
	FeeRecord   uint64 `json:"fee_record" yaml:"fee_record"`     // Fee for recording hashes for a WRKChain
	Denom       string `json:"denom" yaml:"denom"`               // Fee denomination
}

wrkchain parameters

func DefaultParams

func DefaultParams() Params

default wrkchain 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 QueryResWrkChainBlockHashes

type QueryResWrkChainBlockHashes []WrkChainBlock

QueryResWrkChainBlockHashes Queries Result Payload for a WRKChain Block Hashes query

func (QueryResWrkChainBlockHashes) String

func (h QueryResWrkChainBlockHashes) String() (out string)

implement fmt.Stringer

type QueryResWrkChains

type QueryResWrkChains []WrkChain

QueryResWrkChains Queries wrkchains

func (QueryResWrkChains) String

func (wc QueryResWrkChains) String() (out string)

implement fmt.Stringer

type QueryWrkChainBlockParams

type QueryWrkChainBlockParams struct {
	Page      int
	Limit     int
	MinHeight uint64
	MaxHeight uint64
	MinDate   uint64
	MaxDate   uint64
	BlockHash string
}

QueryWrkChainBlockParams Params for filtering a WRKChain's block hashes

func NewQueryWrkChainBlockParams

func NewQueryWrkChainBlockParams(page, limit int, minHeight, maxHeight, minDate, maxDate uint64, hash string) QueryWrkChainBlockParams

type QueryWrkChainParams

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

QueryWrkChainParams Params for query 'custom/wrkchain/registered'

func NewQueryWrkChainParams

func NewQueryWrkChainParams(page, limit int, moniker string, owner sdk.AccAddress) QueryWrkChainParams

NewQueryWrkChainParams creates a new instance of QueryWrkChainParams

type WrkChain

type WrkChain struct {
	WrkChainID   uint64         `json:"wrkchain_id"`
	Moniker      string         `json:"moniker"`
	Name         string         `json:"name"`
	GenesisHash  string         `json:"genesis"`
	BaseType     string         `json:"type"`
	LastBlock    uint64         `json:"lastblock"`
	NumberBlocks uint64         `json:"num_blocks"`
	RegisterTime int64          `json:"reg_time"`
	Owner        sdk.AccAddress `json:"owner"`
}

Wrkchain is a struct that contains all the metadata of a registered WRKChain

func NewWrkChain

func NewWrkChain() WrkChain

NewWrkChain returns a new WrkChain struct

func (WrkChain) String

func (w WrkChain) String() string

implement fmt.Stringer

type WrkChainBlock

type WrkChainBlock struct {
	WrkChainID uint64         `json:"wrkchain_id"`
	Height     uint64         `json:"height"`
	BlockHash  string         `json:"blockhash"`
	ParentHash string         `json:"parenthash"`
	Hash1      string         `json:"hash1"`
	Hash2      string         `json:"hash2"`
	Hash3      string         `json:"hash3"`
	SubmitTime int64          `json:"sub_time"`
	Owner      sdk.AccAddress `json:"owner"`
}

WrkChainBlock is a struct that contains a wrkchain's recorded block

func NewWrkChainBlock

func NewWrkChainBlock() WrkChainBlock

NewWrkChainBlock returns a new WrkChainBlock struct

func (WrkChainBlock) String

func (w WrkChainBlock) String() string

implement fmt.Stringer

type WrkChainBlocks

type WrkChainBlocks []WrkChainBlock

WrkChainBlocks is an array of WrkChainBlock

func (WrkChainBlocks) String

func (wcb WrkChainBlocks) String() string

String implements stringer interface

type WrkChainExport

type WrkChainExport struct {
	WrkChain       WrkChain        `json:"wrkchain" yaml:"wrkchain"`
	WrkChainBlocks []WrkChainBlock `json:"blocks" yaml:"blocks"`
}

type WrkChains

type WrkChains []WrkChain

WrkChains is an array of WrkChain

func (WrkChains) String

func (w WrkChains) String() string

String implements stringer interface

Jump to

Keyboard shortcuts

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