keeper

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryParameters       = "params"
	QueryPurchaseOrders   = "orders"
	QueryGetPurchaseOrder = "order"
	QueryGetLocked        = "locked"
	QueryTotalLocked      = "total-locked"
	QueryTotalUnlocked    = "total-unlocked"
	QueryTotalSupply      = "total-supply"
)
View Source
const TestDenomination = "testc"

Variables

View Source
var (
	EntSignerAddr = sdk.AccAddress(entSignerPk.Address())

	TestAddrs = []sdk.AccAddress{
		entAddr1, entAddr2, entAddr3, entAddr4, entAddr5,
	}
)

dummy addresses used for testing

Functions

func AddressInDecisions

func AddressInDecisions(addr sdk.AccAddress, decisions []types.PurchaseOrderDecision) bool

func AllInvariants

func AllInvariants(keeper Keeper) sdk.Invariant

AllInvariants runs all invariants of the enterprise module

func GenerateRandomAddresses

func GenerateRandomAddresses(num int) []sdk.AccAddress

func LockedUndEqual

func LockedUndEqual(lA, lB types.LockedUnd) bool

func ModuleAccountInvariant

func ModuleAccountInvariant(keeper Keeper) sdk.Invariant

ModuleAccountInvariant checks that the module account coins reflects the sum of locked UND held on store

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier is the module level router for state queries

func ParamsEqual

func ParamsEqual(paramsA, paramsB types.Params) bool

func PurchaseOrderEqual

PurchaseOrderEqual checks if two purchase orders are equal

func RandInBetween

func RandInBetween(min, max int) int

func RandomDecision

func RandomDecision() types.PurchaseOrderStatus

func RandomStatus

func RandomStatus() types.PurchaseOrderStatus

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, keeper Keeper)

RegisterInvariants registers all enterprise invariants

Types

type Keeper

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

Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine

func NewKeeper

func NewKeeper(storeKey sdk.StoreKey, supplyKeeper types.SupplyKeeper, accKeeper auth.AccountKeeper, paramSpace params.Subspace, codespace sdk.CodespaceType, cdc *codec.Codec) Keeper

NewKeeper creates new instances of the enterprise Keeper

func (Keeper) AccountHasLockedUnd

func (k Keeper) AccountHasLockedUnd(ctx sdk.Context, address sdk.AccAddress) bool

Check if a record exists for locked UND given an account address

func (Keeper) Cdc

func (k Keeper) Cdc() *codec.Codec

func (Keeper) Codespace

func (k Keeper) Codespace() sdk.CodespaceType

func (Keeper) DecrementLockedUnd

func (k Keeper) DecrementLockedUnd(ctx sdk.Context, address sdk.AccAddress, amount sdk.Coin) sdk.Error

DecrementLockedUnd decrements the amount of locked UND - used when purchase order is accepted

func (Keeper) DeleteLockedUndForAccount

func (k Keeper) DeleteLockedUndForAccount(ctx sdk.Context, address sdk.AccAddress)

Deletes the accepted purchase order once processed

func (Keeper) GetAllLockedUndAccountsIterator

func (k Keeper) GetAllLockedUndAccountsIterator(ctx sdk.Context) sdk.Iterator

Get an iterator over all accounts with Locked UND

func (Keeper) GetAllLockedUnds

func (k Keeper) GetAllLockedUnds(ctx sdk.Context) types.LockedUnds

func (Keeper) GetAllPurchaseOrders

func (k Keeper) GetAllPurchaseOrders(ctx sdk.Context) (purchaseOrders types.PurchaseOrders)

GetAllPurchaseOrders returns all the purchase orders from store

func (Keeper) GetEnterpriseAccount

func (k Keeper) GetEnterpriseAccount(ctx sdk.Context) exported.ModuleAccountI

GetEnterpriseAccount returns the enterprise ModuleAccount

func (Keeper) GetHighestPurchaseOrderID

func (k Keeper) GetHighestPurchaseOrderID(ctx sdk.Context) (purchaseOrderID uint64, err sdk.Error)

GetHighestPurchaseOrderID gets the highest purchase order ID

func (Keeper) GetLockedUndAmountForAccount

func (k Keeper) GetLockedUndAmountForAccount(ctx sdk.Context, address sdk.AccAddress) sdk.Coin

func (Keeper) GetLockedUndForAccount

func (k Keeper) GetLockedUndForAccount(ctx sdk.Context, address sdk.AccAddress) types.LockedUnd

Gets a record for Locked UND for a given address

func (Keeper) GetParamDenom

func (k Keeper) GetParamDenom(ctx sdk.Context) string

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)

GetParams returns the total set of Enterprise UND parameters.

func (Keeper) GetPurchaseOrder

func (k Keeper) GetPurchaseOrder(ctx sdk.Context, purchaseOrderID uint64) types.EnterpriseUndPurchaseOrder

Gets a purchase order for a given purchaseOrderID

func (Keeper) GetPurchaseOrderAmount

func (k Keeper) GetPurchaseOrderAmount(ctx sdk.Context, purchaseOrderID uint64) sdk.Coin

GetPurchaseOrderAmount - get the Amount of a raised purchase order for a given purchaseOrderID

func (Keeper) GetPurchaseOrderPurchaser

func (k Keeper) GetPurchaseOrderPurchaser(ctx sdk.Context, purchaseOrderID uint64) sdk.AccAddress

GetPurchaseOrderPurchaser - get the Purchaser address of a purchase order should be the same as the search term!

func (Keeper) GetPurchaseOrderStatus

func (k Keeper) GetPurchaseOrderStatus(ctx sdk.Context, purchaseOrderID uint64) types.PurchaseOrderStatus

GetPurchaseOrderStatus - get the Decision of a purchase order for a given purchaseOrderID

func (Keeper) GetPurchaseOrdersFiltered

func (k Keeper) GetPurchaseOrdersFiltered(ctx sdk.Context, params types.QueryPurchaseOrdersParams) []types.EnterpriseUndPurchaseOrder

GetPurchaseOrdersFiltered retrieves purchase orders filtered by a given set of params which include pagination parameters along a purchase order status.

NOTE: If no filters are provided, all proposals will be returned in paginated form.

func (Keeper) GetTotalLockedUnd

func (k Keeper) GetTotalLockedUnd(ctx sdk.Context) sdk.Coin

GetTotalLockedUnd returns the total locked UND

func (Keeper) GetTotalSupplyIncludingLockedUnd

func (k Keeper) GetTotalSupplyIncludingLockedUnd(ctx sdk.Context) types.UndSupply

GetTotalSupplyIncludingLockedUnd returns information including total UND supply, total locked and unlocked

func (Keeper) GetTotalUnLockedUnd

func (k Keeper) GetTotalUnLockedUnd(ctx sdk.Context) sdk.Coin

GetTotalUnLockedUnd returns the amount of unlocked UND - i.e. in active circulation (totalSupply - locked)

func (Keeper) GetTotalUndSupply

func (k Keeper) GetTotalUndSupply(ctx sdk.Context) sdk.Coin

GetTotalUndSupply returns the total UND in supply, obtained from the supply module's keeper

func (Keeper) IsAuthorisedToDecide

func (k Keeper) IsAuthorisedToDecide(ctx sdk.Context, signer sdk.AccAddress) bool

func (Keeper) IsLocked

func (k Keeper) IsLocked(ctx sdk.Context, address sdk.AccAddress) bool

func (Keeper) IteratePurchaseOrders

func (k Keeper) IteratePurchaseOrders(ctx sdk.Context, cb func(purchaseOrder types.EnterpriseUndPurchaseOrder) (stop bool))

IteratePurchaseOrders iterates over the all the purchase orders and performs a callback function

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) MintCoinsAndLock

func (k Keeper) MintCoinsAndLock(ctx sdk.Context, recipient sdk.AccAddress, amount sdk.Coin) sdk.Error

MintCoinsAndLock implements an alias call to the underlying supply keeper's MintCoinsAndLock to be used in BeginBlocker.

func (Keeper) ProcessPurchaseOrderDecision

func (k Keeper) ProcessPurchaseOrderDecision(ctx sdk.Context, purchaseOrderID uint64, decision types.PurchaseOrderStatus, signer sdk.AccAddress) sdk.Error

func (Keeper) PurchaseOrderExists

func (k Keeper) PurchaseOrderExists(ctx sdk.Context, purchaseOrderID uint64) bool

Check if a raised purchase order for a given purchaseOrderID is in the store or not

func (Keeper) RaiseNewPurchaseOrder

func (k Keeper) RaiseNewPurchaseOrder(ctx sdk.Context, purchaser sdk.AccAddress, amount sdk.Coin) (uint64, sdk.Error)

func (Keeper) SetHighestPurchaseOrderID

func (k Keeper) SetHighestPurchaseOrderID(ctx sdk.Context, purchaseOrderID uint64)

SetHighestPurchaseOrderID sets the new proposal ID to the store

func (Keeper) SetLockedUndForAccount

func (k Keeper) SetLockedUndForAccount(ctx sdk.Context, lockedUnd types.LockedUnd) sdk.Error

Sets the Locked UND data

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

SetParams sets the total set of Enterprise UND parameters.

func (Keeper) SetPurchaseOrder

func (k Keeper) SetPurchaseOrder(ctx sdk.Context, purchaseOrder types.EnterpriseUndPurchaseOrder) sdk.Error

Sets the Purchase Order data

func (Keeper) SetTotalLockedUnd

func (k Keeper) SetTotalLockedUnd(ctx sdk.Context, totalLocked sdk.Coin) sdk.Error

SetTotalLockedUnd sets the total locked UND

func (Keeper) UnlockCoinsForFees

func (k Keeper) UnlockCoinsForFees(ctx sdk.Context, feePayer sdk.AccAddress, feesToPay sdk.Coins) sdk.Error

type LockedUndRetriever

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

LockedUndRetriever defines the properties of a type that can be used to retrieve locked UND.

func NewLockedUndRetriever

func NewLockedUndRetriever(querier NodeQuerier) LockedUndRetriever

NewLockedUndRetriever initialises a new LockedUndRetriever instance.

func (LockedUndRetriever) GetLockedUnd

func (ar LockedUndRetriever) GetLockedUnd(addr sdk.AccAddress) (types.LockedUnd, error)

GetLockedUndForAccount queries for locked UND given an address. An error is returned if the query or decoding fails.

func (LockedUndRetriever) GetLockedUndHeight

func (ar LockedUndRetriever) GetLockedUndHeight(addr sdk.AccAddress) (types.LockedUnd, int64, error)

GetLockedUndHeight queries for locked UND given an address. Returns the height of the query with the account. An error is returned if the query or decoding fails.

type NodeQuerier

type NodeQuerier interface {
	// QueryWithData performs a query to a Tendermint node with the provided path
	// and a data payload. It returns the result and height of the query upon success
	// or an error if the query fails.
	QueryWithData(path string, data []byte) ([]byte, int64, error)
}

NodeQuerier is an interface that is satisfied by types that provide the QueryWithData method

type ParamsRetriever

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

ParamsRetriever defines the properties of a type that can be used to retrieve enterprise params.

func NewParamsRetriever

func NewParamsRetriever(querier NodeQuerier) ParamsRetriever

NewParamsRetriever initialises a new ParamsRetriever instance.

func (ParamsRetriever) GetParams

func (ar ParamsRetriever) GetParams() (types.Params, error)

GetParams queries for parameters. An error is returned if the query or decoding fails.

func (ParamsRetriever) GetParamsHeight

func (ar ParamsRetriever) GetParamsHeight() (types.Params, int64, error)

GetParamsHeight queries for parameters. Returns the height of the query with the params. An error is returned if the query or decoding fails.

type TotalSupplyRetriever

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

TotalSupplyRetriever defines the properties of a type that can be used to retrieve total UND supply.

func NewTotalSupplyRetriever

func NewTotalSupplyRetriever(querier NodeQuerier) TotalSupplyRetriever

NewTotalSupplyRetriever initialises a new TotalSupplyRetriever instance.

func (TotalSupplyRetriever) GetTotalSupply

func (ar TotalSupplyRetriever) GetTotalSupply() (types.UndSupply, error)

GetLockedUndForAccount queries for locked UND given an address. An error is returned if the query or decoding fails.

func (TotalSupplyRetriever) GetTotalSupplyHeight

func (ar TotalSupplyRetriever) GetTotalSupplyHeight() (types.UndSupply, int64, error)

GetLockedUndHeight queries for locked UND given an address. Returns the height of the query with the account. An error is returned if the query or decoding fails.

Jump to

Keyboard shortcuts

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