types

package
v0.0.0-...-3ea6778 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

nolint noalias

Index

Constants

View Source
const (
	// module name
	ModuleName = "auth"

	// StoreKey is string representation of the store key for auth
	StoreKey = "acc"

	// FeeCollectorName the root string for the fee collector account address
	FeeCollectorName = "fee_collector"

	// QuerierRoute is the querier route for acc
	QuerierRoute = StoreKey
)
View Source
const (
	DefaultMaxMemoCharacters uint64 = 256
	DefaultTxSigLimit        uint64 = 7
	DefaultTxSizeCostPerByte uint64 = 10
)

Default parameter values

View Source
const DefaultParamspace = ModuleName

DefaultParamspace defines the default auth module parameter subspace

View Source
const (
	QueryAccount = "account"
)

query endpoints supported by the auth Querier

Variables

View Source
var (
	KeyMaxMemoCharacters = []byte("MaxMemoCharacters")
	KeyTxSigLimit        = []byte("TxSigLimit")
	KeyTxSizeCostPerByte = []byte("TxSizeCostPerByte")
)

Parameter keys

View Source
var (
	// AddressStoreKeyPrefix prefix for account-by-address store
	AddressStoreKeyPrefix = []byte{0x01}
)
View Source
var ModuleCdc *codec.Codec

module wide codec

Functions

func AddressStoreKey

func AddressStoreKey(addr sdk.Address) []byte

AddressStoreKey turn an address to key used to get it from the account store

func CountSubKeys

func CountSubKeys(pub crypto.PubKey) int

CountSubKeys counts the total number of keys for a multi-sig public key.

func DefaultTxDecoder

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

DefaultTxDecoder logic for standard transaction decoding

func DefaultTxEncoder

func DefaultTxEncoder(cdc *codec.Codec) sdk.TxEncoder

DefaultTxEncoder logic for standard transaction encoding

func NewTestTx

func NewTestTx(ctx sdk.Ctx, msgs []sdk.Msg, privs []crypto.PrivateKey, entropy int64, fee sdk.Coins) sdk.Tx

func ParamKeyTable

func ParamKeyTable() sdk.KeyTable

ParamKeyTable for auth module

func ProtoBaseAccount

func ProtoBaseAccount() exported.Account

ProtoBaseAccount - a prototype function for BaseAccount

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the codec

func StdSignBytes

func StdSignBytes(chainID string, entropy int64, fee sdk.Coins, 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 AccountRetriever

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

AccountRetriever defines the properties of a type that can be used to retrieve accounts.

func NewAccountRetriever

func NewAccountRetriever(querier NodeQuerier) AccountRetriever

NewAccountRetriever initialises a new AccountRetriever instance.

func (AccountRetriever) EnsureExists

func (ar AccountRetriever) EnsureExists(addr sdk.Address) error

EnsureExists returns an error if no account exists for the given address else nil.

func (AccountRetriever) GetAccount

func (ar AccountRetriever) GetAccount(addr sdk.Address) (exported.Account, error)

GetAccount queries for an account given an address and a block height. An error is returned if the query or decoding fails.

func (AccountRetriever) GetAccountWithHeight

func (ar AccountRetriever) GetAccountWithHeight(addr sdk.Address) (exported.Account, int64, error)

GetAccountWithHeight queries for an account given an address. Returns the height of the query with the account. An error is returned if the query or decoding fails.

type Accounts

type Accounts []exported.Account

type BaseAccount

type BaseAccount struct {
	Address sdk.Address      `json:"address" yaml:"address"`
	Coins   sdk.Coins        `json:"coins" yaml:"coins"`
	PubKey  crypto.PublicKey `json:"public_key" yaml:"public_key"`
}

BaseAccount - a base account structure. This can be extended by embedding within in your AppAccount. However one doesn't have to use BaseAccount as long as your struct implements Account.

func NewBaseAccount

func NewBaseAccount(address sdk.Address, coins sdk.Coins,
	pubKey crypto.PublicKey) *BaseAccount

NewBaseAccount creates a new BaseAccount object

func NewBaseAccountWithAddress

func NewBaseAccountWithAddress(addr sdk.Address) BaseAccount

NewBaseAccountWithAddress - returns a new base account with a given address

func (BaseAccount) GetAddress

func (acc BaseAccount) GetAddress() sdk.Address

GetAddress - Implements sdk.Account.

func (*BaseAccount) GetCoins

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

GetCoins - Implements sdk.Account.

func (BaseAccount) GetPubKey

func (acc BaseAccount) GetPubKey() crypto.PublicKey

GetPubKey - Implements sdk.Account.

func (BaseAccount) MarshalYAML

func (acc BaseAccount) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of an account.

func (*BaseAccount) SetAddress

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

SetAddress - Implements sdk.Account.

func (*BaseAccount) SetCoins

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

SetCoins - Implements sdk.Account.

func (*BaseAccount) SetPubKey

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

SetPubKey - Implements sdk.Account.

func (*BaseAccount) SpendableCoins

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

func (acc BaseAccount) String() string

String implements fmt.Stringer

type GenesisState

type GenesisState struct {
	Params   Params `json:"params" yaml:"params"`
	Accounts Accounts
}

GenesisState - all auth state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState - Return a default genesis state

func NewGenesisState

func NewGenesisState(params Params, accounts Accounts) GenesisState

NewGenesisState - Create a new genesis state

type MultiSigAccount

type MultiSigAccount struct {
	Address   sdk.Address              `json:"address"`
	PublicKey crypto.PublicKeyMultiSig `json:"public_key_multi_sig"`
	Coins     sdk.Coins                `json:"coins"`
}

func NewMultiSigAccount

func NewMultiSigAccount(publicKey crypto.PublicKeyMultiSig, coins sdk.Coins) *MultiSigAccount

func (MultiSigAccount) GetAddress

func (m MultiSigAccount) GetAddress() sdk.Address

func (MultiSigAccount) GetCoins

func (m MultiSigAccount) GetCoins() sdk.Coins

func (MultiSigAccount) GetMultiPubKey

func (m MultiSigAccount) GetMultiPubKey() crypto.PublicKeyMultiSig

func (MultiSigAccount) GetPubKey

func (m MultiSigAccount) GetPubKey() crypto.PublicKey

func (*MultiSigAccount) SetAddress

func (m *MultiSigAccount) SetAddress(_ sdk.Address) error

func (*MultiSigAccount) SetCoins

func (m *MultiSigAccount) SetCoins(c sdk.Coins) error

func (MultiSigAccount) SetPubKey

func (m MultiSigAccount) SetPubKey(pk crypto.PublicKey) error

func (MultiSigAccount) SpendableCoins

func (m MultiSigAccount) SpendableCoins(blockTime time.Time) sdk.Coins

func (MultiSigAccount) String

func (m MultiSigAccount) String() string

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 Params

type Params struct {
	MaxMemoCharacters uint64 `json:"max_memo_characters" yaml:"max_memo_characters"`
	TxSigLimit        uint64 `json:"tx_sig_limit" yaml:"tx_sig_limit"`
	TxSizeCostPerByte uint64 `json:"tx_size_cost_per_byte" yaml:"tx_size_cost_per_byte"`
}

Params defines the parameters for the auth module.

func DefaultParams

func DefaultParams() Params

DefaultParams returns a default set of parameters.

func NewParams

func NewParams(maxMemoCharacters, txSigLimit, txSizeCostPerByte,
	sigVerifyCostED25519, sigVerifyCostSecp256k1 uint64) Params

NewParams creates a new Params object

func (Params) Equal

func (p Params) Equal(p2 Params) bool

Equal returns a boolean determining if two Params types are identical.

func (*Params) ParamSetPairs

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

ParamSetPairs implements the ParamSet interface and returns all the key/value pairs pairs of auth module's parameters. nolint

func (Params) String

func (p Params) String() string

String implements the stringer interface.

type QueryAccountParams

type QueryAccountParams struct {
	Address sdk.Address
}

QueryAccountParams defines the params for querying accounts.

func NewQueryAccountParams

func NewQueryAccountParams(addr sdk.Address) QueryAccountParams

NewQueryAccountParams creates a new instance of QueryAccountParams.

type StdSignDoc

type StdSignDoc struct {
	ChainID string            `json:"chain_id" yaml:"chain_id"`
	Fee     json.RawMessage   `json:"fee" yaml:"fee"`
	Memo    string            `json:"memo" yaml:"memo"`
	Msgs    []json.RawMessage `json:"msgs" yaml:"msgs"`
	Entropy int64             `json:"entropy" yaml:"entropy"`
}

StdSignDoc is replay-prevention structure. It includes the result of msg.GetSignBytes(), as well as the ChainID (prevent cross chain replay) and the Entropy numbers for each signature (prevent inchain replay and enforce tx ordering per account).

type StdSignature

type StdSignature struct {
	posCrypto.PublicKey `json:"pub_key" yaml:"pub_key"` // optional
	Signature           []byte                          `json:"signature" yaml:"signature"`
}

StdSignature represents a sig

func (StdSignature) MarshalYAML

func (ss StdSignature) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of the signature.

type StdTx

type StdTx struct {
	Msgs       []sdk.Msg      `json:"msg" yaml:"msg"`
	Fee        sdk.Coins      `json:"fee" yaml:"fee"`
	Signatures []StdSignature `json:"signatures" yaml:"signatures"`
	Memo       string         `json:"memo" yaml:"memo"`
	Entropy    int64          `json:"entropy" yaml:"entropy"`
}

StdTx is a standard way to wrap a Msg with Fee and Sigs. NOTE: the first signature is the fee payer (Sigs must not be nil).

func NewStdTx

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

func (StdTx) GetMemo

func (tx StdTx) GetMemo() string

GetMemo returns the memo

func (StdTx) GetMsgs

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

GetMsgs returns the all the transaction's messages.

func (StdTx) GetSignatures

func (tx StdTx) GetSignatures() []StdSignature

GetSignatures 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.Address

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

func (tx StdTx) ValidateBasic() sdk.Error

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

type SupplyKeeper

type SupplyKeeper interface {
	SendCoinsFromAccountToModule(ctx sdk.Ctx, senderAddr sdk.Address, recipientModule string, amt sdk.Coins) sdk.Error
	GetModuleAccount(ctx sdk.Ctx, moduleName string) exported.ModuleAccountI
	GetModuleAddress(moduleName string) sdk.Address
}

SupplyKeeper defines the expected supply Keeper (noalias)

type TxBuilder

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

TxBuilder implements a transaction context created in SDK modules.

func NewTxBuilder

func NewTxBuilder(txEncoder sdk.TxEncoder, txDecoder sdk.TxDecoder, chainID, memo string, fees sdk.Coins) TxBuilder

NewTxBuilder returns a new initialized TxBuilder.

func (TxBuilder) BuildAndSign

func (bldr TxBuilder) BuildAndSign(address sdk.Address, privateKey crypto.PrivateKey, msgs []sdk.Msg) ([]byte, error)

BuildAndSign builds a single message to be signed, and signs a transaction with the built message given a address, private key, and a set of messages.

func (TxBuilder) BuildAndSignMultisigTransaction

func (bldr TxBuilder) BuildAndSignMultisigTransaction(address sdk.Address, publicKey crypto.PublicKeyMultiSig, m sdk.Msg, passphrase string) (signedTx []byte, err error)

func (TxBuilder) BuildAndSignWithKeyBase

func (bldr TxBuilder) BuildAndSignWithKeyBase(address sdk.Address, passphrase string, msgs []sdk.Msg) ([]byte, error)

BuildAndSignWithKeyBase builds a single message to be signed, and signs a transaction with the built message given a address, passphrase, and a set of messages.

func (TxBuilder) ChainID

func (bldr TxBuilder) ChainID() string

ChainID returns the chain id

func (TxBuilder) Fees

func (bldr TxBuilder) Fees() sdk.Coins

Fees returns the fees for the transaction

func (TxBuilder) Keybase

func (bldr TxBuilder) Keybase() crkeys.Keybase

Keybase returns the keybase

func (TxBuilder) Memo

func (bldr TxBuilder) Memo() string

Memo returns the memo message

func (TxBuilder) SignMultisigTransaction

func (bldr TxBuilder) SignMultisigTransaction(address sdk.Address, keys []crypto.PublicKey, passphrase string, txBytes []byte) (signedTx []byte, err error)

func (TxBuilder) TxDecoder

func (bldr TxBuilder) TxDecoder() sdk.TxDecoder

TxEncoder returns the transaction encoder

func (TxBuilder) TxEncoder

func (bldr TxBuilder) TxEncoder() sdk.TxEncoder

TxEncoder returns the transaction encoder

func (TxBuilder) WithChainID

func (bldr TxBuilder) WithChainID(chainID string) TxBuilder

WithChainID returns a copy of the context with an updated chainID.

func (TxBuilder) WithFees

func (bldr TxBuilder) WithFees(fees string) TxBuilder

WithFees returns a copy of the context with an updated fee.

func (TxBuilder) WithKeybase

func (bldr TxBuilder) WithKeybase(keybase crkeys.Keybase) TxBuilder

WithKeybase returns a copy of the context with updated keybase.

func (TxBuilder) WithMemo

func (bldr TxBuilder) WithMemo(memo string) TxBuilder

WithMemo returns a copy of the context with an updated memo.

func (TxBuilder) WithTxEncoder

func (bldr TxBuilder) WithTxEncoder(txEncoder sdk.TxEncoder) TxBuilder

WithTxEncoder returns a copy of the context with an updated codec.

Jump to

Keyboard shortcuts

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