auth

package
v0.23.0-iris Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2018 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressStoreKey added in v0.19.0

func AddressStoreKey(addr sdk.AccAddress) []byte

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

func BurnFeeHandler added in v0.15.0

func BurnFeeHandler(_ sdk.Context, _ sdk.Tx, _ sdk.Coins)

BurnFeeHandler burns all fees (decreasing total supply)

func FeePayer added in v0.18.0

func FeePayer(tx sdk.Tx) sdk.AccAddress

FeePayer returns the address responsible for paying the fees for the transactions. It's the first address returned by msg.GetSigners(). If GetSigners() is empty, this panics.

func NewAnteHandler

func NewAnteHandler(am AccountMapper, 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 RegisterBaseAccount added in v0.15.0

func RegisterBaseAccount(cdc *wire.Codec)

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

func RegisterWire added in v0.16.0

func RegisterWire(cdc *wire.Codec)

Register concrete types on wire codec for default AppAccount

func StdSignBytes added in v0.18.0

func StdSignBytes(chainID string, accnum int64, sequence int64, fee StdFee, msgs []sdk.Msg, memo string) []byte

StdSignBytes returns the bytes to sign for a transaction.

func WithSigners

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

add the signers to the context

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() int64
	SetAccountNumber(int64) error

	GetSequence() int64
	SetSequence(int64) error

	GetCoins() sdk.Coins
	SetCoins(sdk.Coins) error
}

Account is a standard account using a sequence number for replay protection and a pubkey for authentication.

func GetSigners

func GetSigners(ctx types.Context) []Account

get the signers from the context

func ProtoBaseAccount added in v0.21.0

func ProtoBaseAccount() Account

Prototype function for BaseAccount

type AccountDecoder added in v0.18.0

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

AccountDecoder unmarshals account bytes

type AccountMapper added in v0.18.0

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

This AccountMapper encodes/decodes accounts using the go-amino (binary) encoding/decoding library.

func NewAccountMapper

func NewAccountMapper(cdc *wire.Codec, key sdk.StoreKey, proto func() Account) AccountMapper

NewAccountMapper returns a new sdk.AccountMapper that uses go-amino to (binary) encode and decode concrete sdk.Accounts. nolint

func (AccountMapper) GetAccount added in v0.18.0

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

Implements sdk.AccountMapper.

func (AccountMapper) GetNextAccountNumber added in v0.19.0

func (am AccountMapper) GetNextAccountNumber(ctx sdk.Context) int64

Returns and increments the global account number counter

func (AccountMapper) GetPubKey added in v0.18.0

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

Returns the PubKey of the account at address

func (AccountMapper) GetSequence added in v0.18.0

func (am AccountMapper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (int64, sdk.Error)

Returns the Sequence of the account at address

func (AccountMapper) IterateAccounts added in v0.18.0

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

Implements sdk.AccountMapper.

func (AccountMapper) NewAccount added in v0.19.0

func (am AccountMapper) NewAccount(ctx sdk.Context, acc Account) Account

New Account

func (AccountMapper) NewAccountWithAddress added in v0.18.0

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

Implaements sdk.AccountMapper.

func (AccountMapper) SetAccount added in v0.18.0

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

Implements sdk.AccountMapper.

type BaseAccount

type BaseAccount struct {
	Address       sdk.AccAddress `json:"address"`
	Coins         sdk.Coins      `json:"coins"`
	PubKey        crypto.PubKey  `json:"public_key"`
	AccountNumber int64          `json:"account_number"`
	Sequence      int64          `json:"sequence"`
}

BaseAccount - base account structure. Extend this by embedding this in your AppAccount. See the examples/basecoin/types/account.go for an example.

func NewBaseAccountWithAddress

func NewBaseAccountWithAddress(addr sdk.AccAddress) BaseAccount

func (*BaseAccount) GetAccountNumber added in v0.19.0

func (acc *BaseAccount) GetAccountNumber() int64

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() int64

Implements sdk.Account.

func (*BaseAccount) SetAccountNumber added in v0.19.0

func (acc *BaseAccount) SetAccountNumber(accNumber int64) 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 int64) error

Implements sdk.Account.

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 *wire.Codec, key sdk.StoreKey) FeeCollectionKeeper

NewFeeKeeper returns a new FeeKeeper

func (FeeCollectionKeeper) ClearCollectedFees added in v0.18.0

func (fck FeeCollectionKeeper) ClearCollectedFees(ctx sdk.Context)

Clears the collected Fee Pool

func (FeeCollectionKeeper) GetCollectedFees added in v0.18.0

func (fck FeeCollectionKeeper) GetCollectedFees(ctx sdk.Context) sdk.Coins

Adds to Collected Fee Pool

type StdFee added in v0.18.0

type StdFee struct {
	Amount sdk.Coins `json:"amount"`
	Gas    int64     `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 added in v0.18.0

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

func (StdFee) Bytes added in v0.18.0

func (fee StdFee) Bytes() []byte

fee bytes for signing later

type StdSignDoc added in v0.18.0

type StdSignDoc struct {
	AccountNumber int64             `json:"account_number"`
	ChainID       string            `json:"chain_id"`
	Fee           json.RawMessage   `json:"fee"`
	Memo          string            `json:"memo"`
	Msgs          []json.RawMessage `json:"msgs"`
	Sequence      int64             `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 StdSignMsg added in v0.18.0

type StdSignMsg struct {
	ChainID       string
	AccountNumber int64
	Sequence      int64
	Fee           StdFee
	Msgs          []sdk.Msg
	Memo          string
}

StdSignMsg is a convenience structure for passing along a Msg with the other requirements for a StdSignDoc before it is signed. For use in the CLI.

func (StdSignMsg) Bytes added in v0.18.0

func (msg StdSignMsg) Bytes() []byte

get message bytes

type StdSignature added in v0.18.0

type StdSignature struct {
	crypto.PubKey    `json:"pub_key"` // optional
	crypto.Signature `json:"signature"`
	AccountNumber    int64 `json:"account_number"`
	Sequence         int64 `json:"sequence"`
}

Standard Signature

type StdTx added in v0.18.0

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 FeePayer (Signatures must not be nil).

func NewStdTx added in v0.18.0

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

func (StdTx) GetMemo added in v0.20.0

func (tx StdTx) GetMemo() string

nolint

func (StdTx) GetMsgs added in v0.20.0

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

nolint

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 determistic order. They are accumulated from the GetSigners method for each Msg in the order they appear in tx.GetMsgs(). Duplicate addresses will be omitted.

Directories

Path Synopsis
client
cli

Jump to

Keyboard shortcuts

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