Documentation ¶
Overview ¶
nolint
Index ¶
- Constants
- Variables
- func AddressStoreKey(addr sdk.AccAddress) []byte
- func DefaultTxDecoder(cdc *codec.Codec) sdk.TxDecoder
- func DefaultTxEncoder(cdc *codec.Codec) sdk.TxEncoder
- func EnsureSufficientMempoolFees(ctx sdk.Context, stdFee StdFee) sdk.Result
- func GetSignBytes(chainID string, stdTx StdTx, acc Account, genesis bool) []byte
- func InitGenesis(ctx sdk.Context, ak AccountKeeper, fck FeeCollectionKeeper, data GenesisState)
- func NewAnteHandler(ak AccountKeeper, fck FeeCollectionKeeper) sdk.AnteHandler
- func ParamTypeTable() params.TypeTable
- func ProcessPubKey(acc Account, sig StdSignature, simulate bool) (crypto.PubKey, sdk.Result)
- func RegisterBaseAccount(cdc *codec.Codec)
- func RegisterCodec(cdc *codec.Codec)
- func SetGasMeter(simulate bool, ctx sdk.Context, gasLimit uint64) sdk.Context
- func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, msgs []sdk.Msg, ...) []byte
- func ValidateGenesis(data GenesisState) error
- func ValidateMemo(gasMeter sdk.GasMeter, stdTx StdTx, params Params) sdk.Result
- type Account
- type AccountDecoder
- type AccountKeeper
- func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) Account
- func (ak AccountKeeper) GetNextAccountNumber(ctx sdk.Context) uint64
- func (ak AccountKeeper) GetParams(ctx sdk.Context) (params Params)
- func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (crypto.PubKey, sdk.Error)
- func (ak AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint64, sdk.Error)
- func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, process func(Account) (stop bool))
- func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc Account) Account
- func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) Account
- func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc Account)
- func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc Account)
- func (ak AccountKeeper) SetParams(ctx sdk.Context, params Params)
- type BaseAccount
- func (acc *BaseAccount) GetAccountNumber() uint64
- func (acc BaseAccount) GetAddress() sdk.AccAddress
- func (acc *BaseAccount) GetCoins() sdk.Coins
- func (acc BaseAccount) GetPubKey() crypto.PubKey
- func (acc *BaseAccount) GetSequence() uint64
- func (acc *BaseAccount) SetAccountNumber(accNumber uint64) error
- func (acc *BaseAccount) SetAddress(addr sdk.AccAddress) error
- func (acc *BaseAccount) SetCoins(coins sdk.Coins) error
- func (acc *BaseAccount) SetPubKey(pubKey crypto.PubKey) error
- func (acc *BaseAccount) SetSequence(seq uint64) error
- func (acc *BaseAccount) SpendableCoins(_ time.Time) sdk.Coins
- func (acc BaseAccount) String() string
- type BaseVestingAccount
- type ContinuousVestingAccount
- func (cva *ContinuousVestingAccount) GetEndTime() int64
- func (cva *ContinuousVestingAccount) GetStartTime() int64
- func (cva ContinuousVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins
- func (cva ContinuousVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins
- func (cva ContinuousVestingAccount) SpendableCoins(blockTime time.Time) sdk.Coins
- func (cva ContinuousVestingAccount) String() string
- func (cva *ContinuousVestingAccount) TrackDelegation(blockTime time.Time, amount sdk.Coins)
- type DelayedVestingAccount
- func (dva *DelayedVestingAccount) GetEndTime() int64
- func (dva *DelayedVestingAccount) GetStartTime() int64
- func (dva DelayedVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins
- func (dva DelayedVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins
- func (dva DelayedVestingAccount) SpendableCoins(blockTime time.Time) sdk.Coins
- func (dva *DelayedVestingAccount) TrackDelegation(blockTime time.Time, amount sdk.Coins)
- type FeeCollectionKeeper
- type GenesisState
- type Params
- type StdFee
- type StdSignDoc
- type StdSignature
- type StdTx
- type VestingAccount
Constants ¶
const ( DefaultMemoCostPerByte sdk.Gas = 3 DefaultMaxMemoCharacters uint64 = 256 DefaultTxSigLimit uint64 = 7 DefaultSigVerifyCostED25519 uint64 = 590 DefaultSigVerifyCostSecp256k1 uint64 = 1000 )
Default parameter values
const DefaultParamspace = "auth"
DefaultParamspace defines the default auth module parameter subspace
Variables ¶
var ( // Prefix for account-by-address store AddressStoreKeyPrefix = []byte{0x01} // StoreKey is string representation of the store key for auth StoreKey = "acc" // FeeStoreKey is a string representation of the store key for fees FeeStoreKey = "fee" )
var ( KeyMemoCostPerByte = []byte("MemoCostPerByte") KeyMaxMemoCharacters = []byte("MaxMemoCharacters") KeyTxSigLimit = []byte("TxSigLimit") KeySigVerifyCostED25519 = []byte("SigVerifyCostED25519") KeySigVerifyCostSecp256k1 = []byte("SigVerifyCostSecp256k1") )
Parameter keys
Functions ¶
func AddressStoreKey ¶
func AddressStoreKey(addr sdk.AccAddress) []byte
Turn an address to key used to get it from the account store
func DefaultTxDecoder ¶
logic for standard transaction decoding
func DefaultTxEncoder ¶
logic for standard transaction encoding
func EnsureSufficientMempoolFees ¶ added in v0.30.0
EnsureSufficientMempoolFees verifies that the given transaction has supplied enough fees to cover a proposer's minimum fees. An result object is returned indicating success or failure.
TODO: Account for transaction size.
Contract: This should only be called during CheckTx as it cannot be part of consensus.
func GetSignBytes ¶ added in v0.30.0
GetSignBytes returns a slice of bytes to sign over for a given transaction and an account.
func InitGenesis ¶
func InitGenesis(ctx sdk.Context, ak AccountKeeper, fck FeeCollectionKeeper, data GenesisState)
Init store state from genesis data
func NewAnteHandler ¶
func NewAnteHandler(ak AccountKeeper, fck FeeCollectionKeeper) sdk.AnteHandler
NewAnteHandler returns an AnteHandler that checks and increments sequence numbers, checks signatures & account numbers, and deducts fees from the first signer.
func ParamTypeTable ¶ added in v0.30.0
ParamTable for staking module
func ProcessPubKey ¶ added in v0.30.0
ProcessPubKey verifies that the given account address matches that of the StdSignature. In addition, it will set the public key of the account if it has not been set.
func RegisterBaseAccount ¶ added in v0.15.0
Most users shouldn't use this, but this comes in handy for tests.
func RegisterCodec ¶
Register concrete types on codec codec for default AppAccount
func SetGasMeter ¶
SetGasMeter returns a new context with a gas meter set from a given context.
func StdSignBytes ¶
func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, msgs []sdk.Msg, memo string) []byte
StdSignBytes returns the bytes to sign for a transaction.
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis performs basic validation of auth genesis data returning an error for any failed validation criteria.
Types ¶
type Account ¶ added in v0.18.0
type Account interface { GetAddress() sdk.AccAddress SetAddress(sdk.AccAddress) error // errors if already set. GetPubKey() crypto.PubKey // can return nil. SetPubKey(crypto.PubKey) error GetAccountNumber() uint64 SetAccountNumber(uint64) error GetSequence() uint64 SetSequence(uint64) error GetCoins() sdk.Coins SetCoins(sdk.Coins) error // Calculates the amount of coins that can be sent to other accounts given // the current time. SpendableCoins(blockTime time.Time) sdk.Coins // Ensure that account implements stringer String() string }
Account is an interface used to store coins at a given address within state. It presumes a notion of sequence numbers for replay protection, a notion of account numbers for replay protection for previously pruned accounts, and a pubkey for authentication purposes.
Many complex conditions can be used in the concrete struct which implements Account.
func DeductFees ¶
DeductFees deducts fees from the given account.
NOTE: We could use the CoinKeeper (in addition to the AccountKeeper, because the CoinKeeper doesn't give us accounts), but it seems easier to do this.
func GetSignerAcc ¶
func GetSignerAcc(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress) (Account, sdk.Result)
GetSignerAcc returns an account for a given address that is expected to sign a transaction.
type AccountDecoder ¶ added in v0.18.0
AccountDecoder unmarshals account bytes
type AccountKeeper ¶
type AccountKeeper struct {
// contains filtered or unexported fields
}
This AccountKeeper encodes/decodes accounts using the go-amino (binary) encoding/decoding library.
func NewAccountKeeper ¶
func NewAccountKeeper( cdc *codec.Codec, key sdk.StoreKey, paramstore params.Subspace, proto func() Account, ) AccountKeeper
NewAccountKeeper returns a new sdk.AccountKeeper that uses go-amino to (binary) encode and decode concrete sdk.Accounts. nolint
func (AccountKeeper) GetAccount ¶ added in v0.25.0
func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) Account
Implements sdk.AccountKeeper.
func (AccountKeeper) GetNextAccountNumber ¶ added in v0.25.0
func (ak AccountKeeper) GetNextAccountNumber(ctx sdk.Context) uint64
Returns and increments the global account number counter
func (AccountKeeper) GetParams ¶ added in v0.30.0
func (ak AccountKeeper) GetParams(ctx sdk.Context) (params Params)
GetParams gets the auth module's parameters.
func (AccountKeeper) GetPubKey ¶ added in v0.25.0
func (ak AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (crypto.PubKey, sdk.Error)
Returns the PubKey of the account at address
func (AccountKeeper) GetSequence ¶ added in v0.25.0
func (ak AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint64, sdk.Error)
Returns the Sequence of the account at address
func (AccountKeeper) IterateAccounts ¶ added in v0.25.0
func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, process func(Account) (stop bool))
Implements sdk.AccountKeeper.
func (AccountKeeper) NewAccount ¶ added in v0.25.0
func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc Account) Account
New Account
func (AccountKeeper) NewAccountWithAddress ¶ added in v0.25.0
func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) Account
Implaements sdk.AccountKeeper.
func (AccountKeeper) RemoveAccount ¶ added in v0.25.0
func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc Account)
RemoveAccount removes an account for the account mapper store.
func (AccountKeeper) SetAccount ¶ added in v0.25.0
func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc Account)
Implements sdk.AccountKeeper.
type BaseAccount ¶
type BaseAccount struct { Address sdk.AccAddress `json:"address"` Coins sdk.Coins `json:"coins"` PubKey crypto.PubKey `json:"public_key"` AccountNumber uint64 `json:"account_number"` Sequence uint64 `json:"sequence"` }
BaseAccount - a base account structure. This can be extended by embedding within in your AppAccount. There are examples of this in: examples/basecoin/types/account.go. However one doesn't have to use BaseAccount as long as your struct implements Account.
func NewBaseAccountWithAddress ¶
func NewBaseAccountWithAddress(addr sdk.AccAddress) BaseAccount
func (*BaseAccount) GetAccountNumber ¶ added in v0.19.0
func (acc *BaseAccount) GetAccountNumber() uint64
Implements Account
func (BaseAccount) GetAddress ¶ added in v0.2.0
func (acc BaseAccount) GetAddress() sdk.AccAddress
Implements sdk.Account.
func (*BaseAccount) GetCoins ¶ added in v0.2.0
func (acc *BaseAccount) GetCoins() sdk.Coins
Implements sdk.Account.
func (BaseAccount) GetPubKey ¶ added in v0.2.0
func (acc BaseAccount) GetPubKey() crypto.PubKey
Implements sdk.Account.
func (*BaseAccount) GetSequence ¶ added in v0.2.0
func (acc *BaseAccount) GetSequence() uint64
Implements sdk.Account.
func (*BaseAccount) SetAccountNumber ¶ added in v0.19.0
func (acc *BaseAccount) SetAccountNumber(accNumber uint64) error
Implements Account
func (*BaseAccount) SetAddress ¶ added in v0.2.0
func (acc *BaseAccount) SetAddress(addr sdk.AccAddress) error
Implements sdk.Account.
func (*BaseAccount) SetCoins ¶ added in v0.2.0
func (acc *BaseAccount) SetCoins(coins sdk.Coins) error
Implements sdk.Account.
func (*BaseAccount) SetPubKey ¶ added in v0.2.0
func (acc *BaseAccount) SetPubKey(pubKey crypto.PubKey) error
Implements sdk.Account.
func (*BaseAccount) SetSequence ¶ added in v0.2.0
func (acc *BaseAccount) SetSequence(seq uint64) error
Implements sdk.Account.
func (*BaseAccount) SpendableCoins ¶ added in v0.30.0
func (acc *BaseAccount) SpendableCoins(_ time.Time) sdk.Coins
SpendableCoins returns the total set of spendable coins. For a base account, this is simply the base coins.
func (BaseAccount) String ¶ added in v0.30.0
func (acc BaseAccount) String() string
String implements fmt.Stringer
type BaseVestingAccount ¶ added in v0.30.0
type BaseVestingAccount struct { *BaseAccount OriginalVesting sdk.Coins // coins in account upon initialization DelegatedFree sdk.Coins // coins that are vested and delegated DelegatedVesting sdk.Coins // coins that vesting and delegated EndTime int64 // when the coins become unlocked }
BaseVestingAccount implements the VestingAccount interface. It contains all the necessary fields needed for any vesting account implementation.
func (BaseVestingAccount) String ¶ added in v0.30.0
func (bva BaseVestingAccount) String() string
String implements fmt.Stringer
func (*BaseVestingAccount) TrackUndelegation ¶ added in v0.30.0
func (bva *BaseVestingAccount) TrackUndelegation(amount sdk.Coins)
TrackUndelegation tracks an undelegation amount by setting the necessary values by which delegated vesting and delegated vesting need to decrease and by which amount the base coins need to increase. The resulting base coins are returned.
CONTRACT: The account's coins and undelegation coins must be sorted.
type ContinuousVestingAccount ¶ added in v0.30.0
type ContinuousVestingAccount struct { *BaseVestingAccount StartTime int64 // when the coins start to vest }
ContinuousVestingAccount implements the VestingAccount interface. It continuously vests by unlocking coins linearly with respect to time.
func NewContinuousVestingAccount ¶ added in v0.30.0
func NewContinuousVestingAccount( baseAcc *BaseAccount, StartTime, EndTime int64, ) *ContinuousVestingAccount
func (*ContinuousVestingAccount) GetEndTime ¶ added in v0.30.0
func (cva *ContinuousVestingAccount) GetEndTime() int64
GetEndTime returns the time when vesting ends for a continuous vesting account.
func (*ContinuousVestingAccount) GetStartTime ¶ added in v0.30.0
func (cva *ContinuousVestingAccount) GetStartTime() int64
GetStartTime returns the time when vesting starts for a continuous vesting account.
func (ContinuousVestingAccount) GetVestedCoins ¶ added in v0.30.0
func (cva ContinuousVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins
GetVestedCoins returns the total number of vested coins. If no coins are vested, nil is returned.
func (ContinuousVestingAccount) GetVestingCoins ¶ added in v0.30.0
func (cva ContinuousVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins
GetVestingCoins returns the total number of vesting coins. If no coins are vesting, nil is returned.
func (ContinuousVestingAccount) SpendableCoins ¶ added in v0.30.0
func (cva ContinuousVestingAccount) SpendableCoins(blockTime time.Time) sdk.Coins
SpendableCoins returns the total number of spendable coins per denom for a continuous vesting account.
func (ContinuousVestingAccount) String ¶ added in v0.30.0
func (cva ContinuousVestingAccount) String() string
func (*ContinuousVestingAccount) TrackDelegation ¶ added in v0.30.0
func (cva *ContinuousVestingAccount) TrackDelegation(blockTime time.Time, amount sdk.Coins)
TrackDelegation tracks a desired delegation amount by setting the appropriate values for the amount of delegated vesting, delegated free, and reducing the overall amount of base coins.
type DelayedVestingAccount ¶ added in v0.30.0
type DelayedVestingAccount struct {
*BaseVestingAccount
}
DelayedVestingAccount implements the VestingAccount interface. It vests all coins after a specific time, but non prior. In other words, it keeps them locked until a specified time.
func NewDelayedVestingAccount ¶ added in v0.30.0
func NewDelayedVestingAccount(baseAcc *BaseAccount, EndTime int64) *DelayedVestingAccount
func (*DelayedVestingAccount) GetEndTime ¶ added in v0.30.0
func (dva *DelayedVestingAccount) GetEndTime() int64
GetEndTime returns the time when vesting ends for a delayed vesting account.
func (*DelayedVestingAccount) GetStartTime ¶ added in v0.30.0
func (dva *DelayedVestingAccount) GetStartTime() int64
GetStartTime returns zero since a delayed vesting account has no start time.
func (DelayedVestingAccount) GetVestedCoins ¶ added in v0.30.0
func (dva DelayedVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins
GetVestedCoins returns the total amount of vested coins for a delayed vesting account. All coins are only vested once the schedule has elapsed.
func (DelayedVestingAccount) GetVestingCoins ¶ added in v0.30.0
func (dva DelayedVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins
GetVestingCoins returns the total number of vesting coins for a delayed vesting account.
func (DelayedVestingAccount) SpendableCoins ¶ added in v0.30.0
func (dva DelayedVestingAccount) SpendableCoins(blockTime time.Time) sdk.Coins
SpendableCoins returns the total number of spendable coins for a delayed vesting account.
func (*DelayedVestingAccount) TrackDelegation ¶ added in v0.30.0
func (dva *DelayedVestingAccount) TrackDelegation(blockTime time.Time, amount sdk.Coins)
TrackDelegation tracks a desired delegation amount by setting the appropriate values for the amount of delegated vesting, delegated free, and reducing the overall amount of base coins.
type FeeCollectionKeeper ¶ added in v0.18.0
type FeeCollectionKeeper struct {
// contains filtered or unexported fields
}
This FeeCollectionKeeper handles collection of fees in the anteHandler and setting of MinFees for different fee tokens
func NewFeeCollectionKeeper ¶ added in v0.18.0
func NewFeeCollectionKeeper(cdc *codec.Codec, key sdk.StoreKey) FeeCollectionKeeper
func (FeeCollectionKeeper) AddCollectedFees ¶ added in v0.25.0
add to the fee pool
func (FeeCollectionKeeper) ClearCollectedFees ¶ added in v0.18.0
func (fck FeeCollectionKeeper) ClearCollectedFees(ctx sdk.Context)
clear the fee pool
func (FeeCollectionKeeper) GetCollectedFees ¶ added in v0.18.0
func (fck FeeCollectionKeeper) GetCollectedFees(ctx sdk.Context) sdk.Coins
retrieves the collected fee pool
type GenesisState ¶
type GenesisState struct { CollectedFees sdk.Coins `json:"collected_fees"` // collected fees Params Params `json:"params"` }
GenesisState - all auth state that must be provided at genesis
func ExportGenesis ¶
func ExportGenesis(ctx sdk.Context, ak AccountKeeper, fck FeeCollectionKeeper) GenesisState
ExportGenesis returns a GenesisState for a given context and keeper
func NewGenesisState ¶
func NewGenesisState(collectedFees sdk.Coins, params Params) GenesisState
Create a new genesis state
type Params ¶
type Params struct { MemoCostPerByte sdk.Gas MaxMemoCharacters uint64 TxSigLimit uint64 // max total number of signatures per tx SigVerifyCostED25519 uint64 SigVerifyCostSecp256k1 uint64 }
Params defines the parameters for the auth module.
func MustUnmarshalParams ¶ added in v0.30.0
MustUnmarshalParams deserializes raw Params bytes into a Params structure. It will panic upon failure.
func UnmarshalParams ¶ added in v0.30.0
UnmarshalParams deserializes raw Params bytes into a Params structure. It will return an error upon failure.
func (Params) Equal ¶ added in v0.30.0
Equal returns a boolean determining if two Params types are identical.
func (*Params) KeyValuePairs ¶ added in v0.30.0
func (p *Params) KeyValuePairs() params.KeyValuePairs
KeyValuePairs implements the ParamSet interface and returns all the key/value pairs of auth module's parameters. nolint
type StdFee ¶
StdFee includes the amount of coins paid in fees and the maximum gas to be used by the transaction. The ratio yields an effective "gasprice", which must be above some miminum to be accepted into the mempool.
type StdSignDoc ¶
type StdSignDoc struct { AccountNumber uint64 `json:"account_number"` ChainID string `json:"chain_id"` Fee json.RawMessage `json:"fee"` Memo string `json:"memo"` Msgs []json.RawMessage `json:"msgs"` Sequence uint64 `json:"sequence"` }
StdSignDoc is replay-prevention structure. It includes the result of msg.GetSignBytes(), as well as the ChainID (prevent cross chain replay) and the Sequence numbers for each signature (prevent inchain replay and enforce tx ordering per account).
type StdSignature ¶
type StdSignature struct { crypto.PubKey `json:"pub_key"` // optional Signature []byte `json:"signature"` }
Standard Signature
type StdTx ¶
type StdTx struct { Msgs []sdk.Msg `json:"msg"` Fee StdFee `json:"fee"` Signatures []StdSignature `json:"signatures"` Memo string `json:"memo"` }
StdTx is a standard way to wrap a Msg with Fee and Signatures. NOTE: the first signature is the fee payer (Signatures must not be nil).
func (StdTx) GetSignatures ¶ added in v0.18.0
func (tx StdTx) GetSignatures() []StdSignature
Signatures returns the signature of signers who signed the Msg. GetSignatures returns the signature of signers who signed the Msg. CONTRACT: Length returned is same as length of pubkeys returned from MsgKeySigners, and the order matches. CONTRACT: If the signature is missing (ie the Msg is invalid), then the corresponding signature is .Empty().
func (StdTx) GetSigners ¶ added in v0.20.0
func (tx StdTx) GetSigners() []sdk.AccAddress
GetSigners returns the addresses that must sign the transaction. Addresses are returned in a deterministic order. They are accumulated from the GetSigners method for each Msg in the order they appear in tx.GetMsgs(). Duplicate addresses will be omitted.
func (StdTx) ValidateBasic ¶ added in v0.27.0
ValidateBasic does a simple and lightweight validation check that doesn't require access to any other information.
type VestingAccount ¶ added in v0.30.0
type VestingAccount interface { Account // Delegation and undelegation accounting that returns the resulting base // coins amount. TrackDelegation(blockTime time.Time, amount sdk.Coins) TrackUndelegation(amount sdk.Coins) GetVestedCoins(blockTime time.Time) sdk.Coins GetVestingCoins(blockTime time.Time) sdk.Coins GetStartTime() int64 GetEndTime() int64 }
VestingAccount defines an account type that vests coins via a vesting schedule.