bank

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: Apache-2.0 Imports: 19 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ModuleName        = types.ModuleName
	StoreKey          = types.StoreKey
	QuerierRoute      = types.QuerierRoute
	DefaultParamspace = types.DefaultParamspace

	TransactionGift                            = exported.TransactionGift
	TransactionBacking                         = exported.TransactionBacking
	TransactionBackingReturned                 = exported.TransactionBackingReturned
	TransactionChallenge                       = exported.TransactionChallenge
	TransactionChallengeReturned               = exported.TransactionChallengeReturned
	TransactionUpvote                          = exported.TransactionUpvote
	TransactionUpvoteReturned                  = exported.TransactionUpvoteReturned
	TransactionInterestArgumentCreation        = exported.TransactionInterestArgumentCreation
	TransactionInterestUpvoteReceived          = exported.TransactionInterestUpvoteReceived
	TransactionInterestUpvoteGiven             = exported.TransactionInterestUpvoteGiven
	TransactionRewardPayout                    = exported.TransactionRewardPayout
	TransactionInterestArgumentCreationSlashed = exported.TransactionInterestArgumentCreationSlashed
	TransactionInterestUpvoteReceivedSlashed   = exported.TransactionInterestUpvoteReceivedSlashed
	TransactionInterestUpvoteGivenSlashed      = exported.TransactionInterestUpvoteGivenSlashed
	TransactionStakeCreatorSlashed             = exported.TransactionStakeCreatorSlashed
	TransactionStakeCuratorSlashed             = exported.TransactionStakeCuratorSlashed

	TransactionCuratorReward = exported.TransactionCuratorReward

	SortAsc                    = exported.SortAsc
	SortDesc                   = exported.SortDesc
	QueryTransactionsByAddress = exported.QueryTransactionsByAddress
	QueryParams                = exported.QueryParams
	RouterKey                  = exported.RouterKey
)
View Source
const (
	DefaultCodespace sdk.CodespaceType = ModuleName

	ErrorCodeInvalidTransactionType     sdk.CodeType = 401
	ErrorCodeInvalidRewardBrokerAddress sdk.CodeType = 402
	ErrorCodeInvalidQueryParams         sdk.CodeType = 403
	ErrorCodeUnknownTransaction         sdk.CodeType = 404
)

Bank errors reserve 400 ~ 499.

View Source
const (
	TypeMsgSendGift     = "send_gift"
	TypeMsgUpdateParams = "update_params"
)

Variables

View Source
var (
	GetFilters              = exported.GetFilters
	FilterByTransactionType = exported.FilterByTransactionType
	SortOrder               = exported.SortOrder
	Limit                   = exported.Limit
	Offset                  = exported.Offset
	FromModuleAccount       = exported.FromModuleAccount
	ToModuleAccount         = exported.ToModuleAccount
	ModuleCodec             = types.ModuleCodec
)
View Source
var (
	TransactionsKeyPrefix = []byte{0x00}

	// ID Keys
	TransactionIDKey = []byte{0x10}

	// AssociationKeys
	UserTransactionKeyPrefix = []byte{0x20}
)

Define keys

View Source
var (
	ParamKeyRewardBrokerAddress = []byte("rewardBrokerAddress")
)

Functions

func ErrCodeUnknownTransaction

func ErrCodeUnknownTransaction(transactionID uint64) sdk.Error

ErrCodeUnknownTransaction throws an error when an invalid transaction id

func ErrInvalidQueryParams

func ErrInvalidQueryParams(err error) sdk.Error

ErrInvalidQueryParams throws an error when the transaction type is invalid.

func ErrInvalidRewardBrokerAddress

func ErrInvalidRewardBrokerAddress(address sdk.AccAddress) sdk.Error

ErrInvalidRewardBrokerAddress throws an error when the address doesn't match with genesis param address.

func ErrInvalidTransactionType

func ErrInvalidTransactionType(txType TransactionType) sdk.Error

ErrInvalidTransactionType throws an error when the transaction type is invalid.

func InitGenesis

func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState)

InitGenesis initializes story state from genesis file

func NewHandler

func NewHandler(keeper Keeper) sdk.Handler

NewHandler creates a new handler for bank module

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier creates a new querier

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable for bank module

func RegisterCodec

func RegisterCodec(c *codec.Codec)

RegisterCodec registers all the necessary types and interfaces for the module

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the genesis state data

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

AppModule defines external data for the module ----------------------------------------------------------------------------

func NewAppModule

func NewAppModule(keeper Keeper) AppModule

NewAppModule creates a NewAppModule object

func (AppModule) BeginBlock

func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock)

BeginBlock returns the begin blocker for the supply module.

func (AppModule) EndBlock

EndBlock returns the end blocker for the supply module. It returns no validator updates.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage

ExportGenesis enforces exporting this module's data to a genesis file

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate

InitGenesis enforces the creation of the genesis state for the bank module

func (AppModule) NewHandler

func (am AppModule) NewHandler() sdk.Handler

NewHandler creates the handler for the bank module

func (AppModule) NewQuerierHandler

func (am AppModule) NewQuerierHandler() sdk.Querier

NewQuerierHandler creates a new querier handler

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute defines the querier route

func (AppModule) RegisterInvariants

func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry)

RegisterInvariants enforces registering of invariants

func (AppModule) Route

func (AppModule) Route() string

Route defines the key for the route

type AppModuleBasic

type AppModuleBasic struct{}

AppModuleBasic defines the internal data for the module ----------------------------------------------------------------------------

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis() json.RawMessage

DefaultGenesis creates the default genesis state for testing

func (AppModuleBasic) GetQueryCmd

func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command

GetQueryCmd returns no root query command for the trubank module.

func (AppModuleBasic) GetTxCmd

func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command

GetTxCmd returns the root tx command for the bank module.

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

Name define the name of the module

func (AppModuleBasic) RegisterCodec

func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)

RegisterCodec registers the types needed for amino encoding/decoding

func (AppModuleBasic) RegisterRESTRoutes

func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router)

RegisterRESTRoutes registers the REST routes for the bank module.

func (AppModuleBasic) ValidateGenesis

func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error

ValidateGenesis validates the genesis state

type Filter

type Filter = exported.Filter

type GenesisState

type GenesisState struct {
	Transactions []Transaction `json:"transactions"`
	Params       Params        `json:"params"`
}

GenesisState defines genesis data for the module

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState returns a default genesis state

func ExportGenesis

func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState

ExportGenesis exports the genesis state

func NewGenesisState

func NewGenesisState(params Params, transactions []Transaction) GenesisState

NewGenesisState creates a new genesis state.

type Keeper

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

Keeper is the model object for the package bank module

func NewKeeper

func NewKeeper(codec *codec.Codec, storeKey sdk.StoreKey, bankKeeper bank.Keeper,
	paramStore params.Subspace, codespace sdk.CodespaceType, supplyKeeper supply.Keeper) Keeper

NewKeeper creates a bank keeper.

func (Keeper) AddCoin

func (k Keeper) AddCoin(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coin,
	referenceID uint64, txType TransactionType, txSetters ...TransactionSetter) (sdk.Coins, sdk.Error)

AddCoin adds a coin to an address and adds the transaction to the association list.

func (Keeper) Codespace

func (k Keeper) Codespace() sdk.CodespaceType

Codespace returns the codespace

func (Keeper) GetCoins

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

func (Keeper) GetParams

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

GetParams gets the genesis params for the bank module

func (Keeper) IterateUserTransactions

func (k Keeper) IterateUserTransactions(ctx sdk.Context, creator sdk.AccAddress, reverse bool, cb func(transaction Transaction) (stop bool))

func (Keeper) SafeSubtractCoin

func (k Keeper) SafeSubtractCoin(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coin,
	referenceID uint64, txType TransactionType, txSetters ...TransactionSetter) (sdk.Coins, sdk.Coin, sdk.Error)

SafeSubtractCoin subtracts a coin without going below zero

func (Keeper) SetParams

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

SetParams sets the params for bank module

func (Keeper) SubtractCoin

func (k Keeper) SubtractCoin(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coin,
	referenceID uint64, txType TransactionType, txSetters ...TransactionSetter) (sdk.Coins, sdk.Error)

SubtractCoin subtracts a coin from an address and adds the transaction to the association list.

func (Keeper) Transactions

func (k Keeper) Transactions(ctx sdk.Context) []Transaction

Transactions gets all the transactions

func (Keeper) TransactionsByAddress

func (k Keeper) TransactionsByAddress(ctx sdk.Context, address sdk.AccAddress, filterSetters ...Filter) []Transaction

TransactionsByAddress gets transactions for a given address and applies sent filters.

func (Keeper) UpdateParams

func (k Keeper) UpdateParams(ctx sdk.Context, updates Params, updatedFields []string) sdk.Error

UpdateParams updates the required params

type MsgSendGift

type MsgSendGift struct {
	Sender    sdk.AccAddress
	Recipient sdk.AccAddress
	Reward    sdk.Coin
}

func NewMsgSendGift

func NewMsgSendGift(sender, recipient sdk.AccAddress, reward sdk.Coin) MsgSendGift

func (MsgSendGift) GetSignBytes

func (msg MsgSendGift) GetSignBytes() []byte

func (MsgSendGift) GetSigners

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

func (MsgSendGift) Route

func (msg MsgSendGift) Route() string

func (MsgSendGift) Type

func (msg MsgSendGift) Type() string

func (MsgSendGift) ValidateBasic

func (msg MsgSendGift) ValidateBasic() sdk.Error

type MsgUpdateParams

type MsgUpdateParams struct {
	Updates       Params         `json:"updates"`
	UpdatedFields []string       `json:"updated_fields"`
	Updater       sdk.AccAddress `json:"updater"`
}

MsgUpdateParams defines the message to remove an admin

func NewMsgUpdateParams

func NewMsgUpdateParams(updates Params, updatedFields []string, updater sdk.AccAddress) MsgUpdateParams

NewMsgUpdateParams returns the message to update the params

func (MsgUpdateParams) GetSignBytes

func (msg MsgUpdateParams) GetSignBytes() []byte

GetSignBytes implements Msg

func (MsgUpdateParams) GetSigners

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

GetSigners implements Msg. Returns the remover as the signer.

func (MsgUpdateParams) Route

func (msg MsgUpdateParams) Route() string

Route implements Msg

func (MsgUpdateParams) Type

func (msg MsgUpdateParams) Type() string

Type implements Msg

func (MsgUpdateParams) ValidateBasic

func (msg MsgUpdateParams) ValidateBasic() sdk.Error

ValidateBasic implements Msg

type Params

type Params struct {
	RewardBrokerAddress sdk.AccAddress `json:"reward_broker_address"`
}

func DefaultParams

func DefaultParams() Params

func (*Params) ParamSetPairs

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

type QueryTransactionsByAddressParams

type QueryTransactionsByAddressParams = exported.QueryTransactionsByAddressParams

type SortOrderType

type SortOrderType = exported.SortOrderType

type Transaction

type Transaction = exported.Transaction

type TransactionSetter

type TransactionSetter = exported.TransactionSetter

type TransactionType

type TransactionType = exported.TransactionType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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