auth

package
v0.16.4 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

nolint

Index

Constants

View Source
const (
	QueryAccount    = "account"
	QueryTokenStats = "tokenStats"
)

query endpoints supported by the auth Querier

View Source
const (
	BlockStoreCostPerByte = 10
)
View Source
const (
	DefaultParamSpace = "auth"
)

Variables

View Source
var (
	TotalLoosenTokenKey = []byte("totalLoosenToken")

	BurnedTokenKey = []byte("burnedToken")
)
View Source
var (
	MinimumGasPrice    = sdk.ZeroInt()
	MaximumGasPrice    = sdk.NewIntWithDecimal(1, 18) //1iris, 10^18iris-atto
	MinimumTxSizeLimit = uint64(500)
	MaximumTxSizeLimit = uint64(1500)
)
View Source
var (
	TxSizeLimitKey = []byte("txSizeLimit")
)

Parameter store key

Functions

func AddressStoreKey

func AddressStoreKey(addr sdk.AccAddress) []byte

Turn an address to key used to get it from the account store

func DefaultTxDecoder

func DefaultTxDecoder(cdc *codec.Codec) sdk.TxDecoder

logic for standard transaction decoding

func InitGenesis

func InitGenesis(ctx sdk.Context, keeper FeeKeeper, accountKeeper AccountKeeper, data GenesisState)

Init store state from genesis data

func NewAnteHandler

func NewAnteHandler(am AccountKeeper, fck FeeKeeper) sdk.AnteHandler

NewAnteHandler returns an AnteHandler that checks and increments sequence numbers, checks signatures & account numbers, and deducts fees from the first signer.

func NewFeePreprocessHandler added in v0.9.0

func NewFeePreprocessHandler(fk FeeKeeper) types.FeePreprocessHandler

NewFeePreprocessHandler creates a fee token preprocesser

func NewFeeRefundHandler added in v0.9.0

func NewFeeRefundHandler(am AccountKeeper, fk FeeKeeper) types.FeeRefundHandler

NewFeePreprocessHandler creates a fee token refund handler

func NewQuerier added in v0.14.0

func NewQuerier(keeper AccountKeeper) sdk.Querier

creates a querier for auth REST endpoints

func ParamTypeTable added in v0.9.0

func ParamTypeTable() params.TypeTable

ParamTable for auth module

func RegisterBaseAccount

func RegisterBaseAccount(cdc *codec.Codec)

Most users shouldn't use this, but this comes in handy for tests.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

Register concrete types on codec codec for default AppAccount

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 ValidateFee added in v0.10.0

func ValidateFee(auth FeeAuth, collectedFee sdk.Coins) error

func ValidateGenesis added in v0.10.0

func ValidateGenesis(data GenesisState) error

func WithSigners

func WithSigners(ctx types.Context, accounts []Account) types.Context

add the signers to the context

Types

type Account

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
}

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 GetSigners

func GetSigners(ctx types.Context) []Account

get the signers from the context

func ProtoBaseAccount

func ProtoBaseAccount() Account

Prototype function for BaseAccount

type AccountDecoder

type AccountDecoder func(accountBytes []byte) (Account, error)

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, 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) DecreaseTotalLoosenToken added in v0.10.0

func (am AccountKeeper) DecreaseTotalLoosenToken(ctx sdk.Context, coins sdk.Coins)

func (AccountKeeper) GetAccount

func (am AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) Account

Implements sdk.AccountKeeper.

func (AccountKeeper) GetAllAccounts added in v0.11.0

func (am AccountKeeper) GetAllAccounts(ctx sdk.Context) []Account

func (AccountKeeper) GetBurnedToken added in v0.10.0

func (am AccountKeeper) GetBurnedToken(ctx sdk.Context) sdk.Coins

func (AccountKeeper) GetNextAccountNumber

func (am AccountKeeper) GetNextAccountNumber(ctx sdk.Context) uint64

Returns and increments the global account number counter

func (AccountKeeper) GetPubKey

func (am AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (crypto.PubKey, sdk.Error)

Returns the PubKey of the account at address

func (AccountKeeper) GetSequence

func (am AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint64, sdk.Error)

Returns the Sequence of the account at address

func (AccountKeeper) GetTotalLoosenToken added in v0.10.0

func (am AccountKeeper) GetTotalLoosenToken(ctx sdk.Context) sdk.Coins

func (AccountKeeper) IncreaseBurnedToken added in v0.10.0

func (am AccountKeeper) IncreaseBurnedToken(ctx sdk.Context, coins sdk.Coins)

func (AccountKeeper) IncreaseTotalLoosenToken added in v0.10.0

func (am AccountKeeper) IncreaseTotalLoosenToken(ctx sdk.Context, coins sdk.Coins)

func (AccountKeeper) IterateAccounts

func (am AccountKeeper) IterateAccounts(ctx sdk.Context, process func(Account) (stop bool))

Implements sdk.AccountKeeper.

func (AccountKeeper) NewAccountWithAddress

func (am AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) Account

Implaements sdk.AccountKeeper.

func (AccountKeeper) RemoveAccount

func (am AccountKeeper) RemoveAccount(ctx sdk.Context, acc Account)

RemoveAccount removes an account for the account mapper store.

func (AccountKeeper) SetAccount

func (am AccountKeeper) SetAccount(ctx sdk.Context, acc Account)

Implements sdk.AccountKeeper.

func (AccountKeeper) SetGenesisAccount added in v0.10.0

func (am AccountKeeper) SetGenesisAccount(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

func (acc *BaseAccount) GetAccountNumber() uint64

Implements Account

func (BaseAccount) GetAddress

func (acc BaseAccount) GetAddress() sdk.AccAddress

Implements sdk.Account.

func (*BaseAccount) GetCoins

func (acc *BaseAccount) GetCoins() sdk.Coins

Implements sdk.Account.

func (BaseAccount) GetPubKey

func (acc BaseAccount) GetPubKey() crypto.PubKey

Implements sdk.Account.

func (*BaseAccount) GetSequence

func (acc *BaseAccount) GetSequence() uint64

Implements sdk.Account.

func (*BaseAccount) SetAccountNumber

func (acc *BaseAccount) SetAccountNumber(accNumber uint64) error

Implements Account

func (*BaseAccount) SetAddress

func (acc *BaseAccount) SetAddress(addr sdk.AccAddress) error

Implements sdk.Account.

func (*BaseAccount) SetCoins

func (acc *BaseAccount) SetCoins(coins sdk.Coins) error

Implements sdk.Account.

func (*BaseAccount) SetPubKey

func (acc *BaseAccount) SetPubKey(pubKey crypto.PubKey) error

Implements sdk.Account.

func (*BaseAccount) SetSequence

func (acc *BaseAccount) SetSequence(seq uint64) error

Implements sdk.Account.

func (BaseAccount) String added in v0.14.0

func (acc BaseAccount) String() string

String implements fmt.Stringer

type FeeAuth added in v0.10.0

type FeeAuth struct {
	NativeFeeDenom string `json:"native_fee_denom"`
}

func InitialFeeAuth added in v0.10.0

func InitialFeeAuth() FeeAuth

func NewFeeAuth added in v0.10.0

func NewFeeAuth(nativeFeeDenom string) FeeAuth

type FeeKeeper added in v0.10.0

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

This FeeKeeper handles collection of fees in the anteHandler and setting of MinFees for different fee tokens

func NewFeeKeeper added in v0.10.0

func NewFeeKeeper(cdc *codec.Codec, key sdk.StoreKey, paramSpace params.Subspace) FeeKeeper

func (FeeKeeper) AddCollectedFees added in v0.10.0

func (fk FeeKeeper) AddCollectedFees(ctx sdk.Context, coins sdk.Coins) sdk.Coins

add to the fee pool

func (FeeKeeper) ClearCollectedFees added in v0.10.0

func (fk FeeKeeper) ClearCollectedFees(ctx sdk.Context)

func (FeeKeeper) GetCollectedFees added in v0.10.0

func (fk FeeKeeper) GetCollectedFees(ctx sdk.Context) sdk.Coins

retrieves the collected fee pool

func (FeeKeeper) GetFeeAuth added in v0.10.0

func (fk FeeKeeper) GetFeeAuth(ctx sdk.Context) (feeAuth FeeAuth)

func (FeeKeeper) GetParamSet added in v0.10.0

func (fk FeeKeeper) GetParamSet(ctx sdk.Context) Params

func (FeeKeeper) RefundCollectedFees added in v0.10.0

func (fk FeeKeeper) RefundCollectedFees(ctx sdk.Context, coins sdk.Coins) sdk.Coins

RefundCollectedFees deducts fees from fee collector

func (FeeKeeper) SetFeeAuth added in v0.10.0

func (fk FeeKeeper) SetFeeAuth(ctx sdk.Context, feeAuth FeeAuth)

func (FeeKeeper) SetParamSet added in v0.10.0

func (fk FeeKeeper) SetParamSet(ctx sdk.Context, feeParams Params)

type GenesisState

type GenesisState struct {
	CollectedFees sdk.Coins `json:"collected_fee"`
	FeeAuth       FeeAuth   `json:"data"`
	Params        Params    `json:"params"`
}

GenesisState - all auth state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

Return a default genesis state

func ExportGenesis

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

ExportGenesis returns a GenesisState for a given context and keeper

func NewGenesisState

func NewGenesisState(collectedFees sdk.Coins, feeAuth FeeAuth, params Params) GenesisState

Create a new genesis state

type Params added in v0.10.0

type Params struct {
	GasPriceThreshold sdk.Int `json:"gas_price_threshold"` // gas price threshold
	TxSizeLimit       uint64  `json:"tx_size"`             // tx size limit
}

auth parameters

func DefaultParams added in v0.10.0

func DefaultParams() Params

default auth module parameters

func (*Params) GetParamSpace added in v0.10.0

func (p *Params) GetParamSpace() string

Implements params.ParamStruct

func (*Params) KeyValuePairs added in v0.10.0

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

func (Params) String added in v0.14.0

func (p Params) String() string

func (*Params) StringFromBytes added in v0.10.0

func (p *Params) StringFromBytes(cdc *codec.Codec, key string, bytes []byte) (string, error)

func (*Params) Validate added in v0.10.0

func (p *Params) Validate(key string, value string) (interface{}, sdk.Error)

type QueryAccountParams added in v0.14.0

type QueryAccountParams struct {
	Address sdk.AccAddress
}

defines the params for query: "custom/acc/account"

func NewQueryAccountParams added in v0.14.0

func NewQueryAccountParams(addr sdk.AccAddress) QueryAccountParams

type StdFee

type StdFee struct {
	Amount sdk.Coins `json:"amount"`
	Gas    uint64    `json:"gas"`
}

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.

func NewStdFee

func NewStdFee(gas uint64, amount ...sdk.Coin) StdFee

func (StdFee) Bytes

func (fee StdFee) Bytes() []byte

fee bytes for signing later

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"`
	AccountNumber uint64           `json:"account_number"`
	Sequence      uint64           `json:"sequence"`
}

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 NewStdTx

func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, memo string) StdTx

func (StdTx) GetMemo

func (tx StdTx) GetMemo() string

nolint

func (StdTx) GetMsgs

func (tx StdTx) GetMsgs() []sdk.Msg

nolint GetMsgs returns the all the transaction's messages.

func (StdTx) GetSignatures

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

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.9.0

func (tx StdTx) ValidateBasic() sdk.Error

ValidateBasic does a simple and lightweight validation check that doesn't require access to any other information.

type TokenStats added in v0.14.0

type TokenStats struct {
	LooseTokens  sdk.Coins `json:"loose_tokens"`
	BurnedTokens sdk.Coins `json:"burned_tokens"`
}

Jump to

Keyboard shortcuts

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