keeper

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2020 License: Apache-2.0 Imports: 27 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"
	QueryWhitelist        = "whitelist"
	QueryWhitelisted      = "whitelisted"
)
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 FUND 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, 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 FUND given an account address

func (Keeper) AddAddressToWhitelist added in v1.4.7

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

AddAddressToWhitelist adds an address to the whitelist

func (Keeper) AddressIsWhitelisted added in v1.4.7

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

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

func (Keeper) Cdc

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

func (Keeper) DecrementLockedUnd

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

DecrementLockedUnd decrements the amount of locked FUND - 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 FUND

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) GetAllWhitelistedAddresses added in v1.4.7

func (k Keeper) GetAllWhitelistedAddresses(ctx sdk.Context) (addresses types.WhitelistAddresses)

GetAllWhitelistedAddresses returns an array of all currently whitelisted addresses

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 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 FUND for a given address

func (Keeper) GetParamDecisionLimit added in v1.2.0

func (k Keeper) GetParamDecisionLimit(ctx sdk.Context) uint64

func (Keeper) GetParamDenom

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

func (Keeper) GetParamEntSigners added in v1.2.0

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

func (Keeper) GetParamEntSignersAsAddressArray added in v1.2.0

func (k Keeper) GetParamEntSignersAsAddressArray(ctx sdk.Context) []sdk.AccAddress

func (Keeper) GetParamMinAccepts added in v1.2.0

func (k Keeper) GetParamMinAccepts(ctx sdk.Context) uint64

func (Keeper) GetParams

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

GetParams returns the total set of Enterprise FUND 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 FUND

func (Keeper) GetTotalSupplyIncludingLockedUnd

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

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

func (Keeper) GetTotalUnLockedUnd

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

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

func (Keeper) GetTotalUndSupply

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

GetTotalUndSupply returns the total FUND 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) IterateWhitelist added in v1.4.7

func (k Keeper) IterateWhitelist(ctx sdk.Context, cb func(addr sdk.AccAddress) (stop bool))

IterateWhitelist iterates over the all the whitelisted addresses 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) error

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

func (Keeper) ProcessAcceptedPurchaseOrders added in v1.2.0

func (k Keeper) ProcessAcceptedPurchaseOrders(ctx sdk.Context)

func (Keeper) ProcessPurchaseOrderDecision

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

func (Keeper) ProcessWhitelistAction added in v1.4.7

func (k Keeper) ProcessWhitelistAction(ctx sdk.Context, address sdk.AccAddress, action types.WhitelistAction, signer sdk.AccAddress) error

ProcessWhitelistAction processes the add/remove whitelist messages

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, error)

func (Keeper) RemoveAddressFromWhitelist added in v1.4.7

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

RemoveAddressFromWhitelist removes an address from the whitelist

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) error

Sets the Locked FUND data

func (Keeper) SetParams

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

SetParams sets the total set of Enterprise FUND parameters.

func (Keeper) SetPurchaseOrder

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

Sets the Purchase Order data

func (Keeper) SetTotalLockedUnd

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

SetTotalLockedUnd sets the total locked FUND

func (Keeper) TallyPurchaseOrderDecisions added in v1.2.0

func (k Keeper) TallyPurchaseOrderDecisions(ctx sdk.Context)

func (Keeper) UnlockCoinsForFees

func (k Keeper) UnlockCoinsForFees(ctx sdk.Context, feePayer sdk.AccAddress, feesToPay sdk.Coins) 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 FUND.

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 FUND 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 FUND 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 FUND 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 FUND 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 FUND 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