types

package
v0.0.0-...-25b3476 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

nolint noalias

Index

Constants

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

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

	// RouterKey is the message route for Module
	RouterKey = ModuleName

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

	// QuerierRoute is the querier route for cu
	QuerierRoute = StoreKey
)
View Source
const (
	DefaultMaxMemoCharacters      uint64 = 256
	DefaultTxSigLimit             uint64 = 7
	DefaultTxSizeCostPerByte      uint64 = 10
	DefaultSigVerifyCostED25519   uint64 = 590
	DefaultSigVerifyCostSecp256k1 uint64 = 1000
)

Default parameter values

View Source
const (
	QueryCU                 = "CU"
	QueryCUWithChainAddr    = "CUChainAddr"
	QueryMultiChainAddrInfo = "MultiChainAddrInfo"
	QueryMinimumGasPrice    = "QueryMinimumGasPrice"
)

query endpoints supported by the auth Querier

View Source
const DefaultParamspace = ModuleName

DefaultParamspace defines the default auth module parameter subspace

Variables

View Source
var (
	// AddressStoreKeyPrefix prefix for CU-by-address store
	AddressStoreKeyPrefix = []byte{0x01}

	OpCUPrefix = []byte{0x02}

	Sep = []byte{0x01}

	ExtAddressPrefix = []byte("extAddress")

	// param key for global CU number
	GlobalCUNumberKey = []byte("globalCUNumber")
)
View Source
var (
	KeyMaxMemoCharacters      = []byte("MaxMemoCharacters")
	KeyTxSigLimit             = []byte("TxSigLimit")
	KeyTxSizeCostPerByte      = []byte("TxSizeCostPerByte")
	KeySigVerifyCostED25519   = []byte("SigVerifyCostED25519")
	KeySigVerifyCostSecp256k1 = []byte("SigVerifyCostSecp256k1")
)

Parameter keys

View Source
var ModuleCdc *codec.Codec

module wide codec

Functions

func AddressFromOpCUKey

func AddressFromOpCUKey(OpCUKey []byte) []byte

func AddressStoreKey

func AddressStoreKey(addr sdk.CUAddress) []byte

AddressStoreKey turn an address to key used to get it from the CU store key = prefix + cuaddress

func CountSubKeys

func CountSubKeys(pub crypto.PubKey) int

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

func DecodeSymbolFromDepositListKey

func DecodeSymbolFromDepositListKey(key []byte) string

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 DepositStoreKey

func DepositStoreKey(symbol string, addr sdk.CUAddress, hash string, index uint64) []byte

key = prefix + symbol + cuaddress

func DepositStorePrefixKey

func DepositStorePrefixKey(symbol string, addr sdk.CUAddress) []byte

func DepositStorePrefixKeyWithAddr

func DepositStorePrefixKeyWithAddr(addr sdk.CUAddress) []byte

func ExtAddressKey

func ExtAddressKey(chain, extAddress string) []byte

key = prefix + chain + ExtAddress

func KeyTestPubAddr

func KeyTestPubAddr() (crypto.PrivKey, crypto.PubKey, sdk.CUAddress)

func NewTestCoins

func NewTestCoins() sdk.Coins

coins to more than cover the fee

func NewTestMsg

func NewTestMsg(addrs ...sdk.CUAddress) *sdk.TestMsg

func NewTestTx

func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, seqs []uint64, fee StdFee) sdk.Tx

func NewTestTxWithMemo

func NewTestTxWithMemo(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, seqs []uint64, fee StdFee, memo string) sdk.Tx

func NewTestTxWithSignBytes

func NewTestTxWithSignBytes(msgs []sdk.Msg, privs []crypto.PrivKey, seqs []uint64, fee StdFee, signBytes []byte, memo string) sdk.Tx

func OpCUKey

func OpCUKey(symbol string, addr sdk.CUAddress) []byte

key = prefix + symbol + cuaddress

func OpCUKeyPrefix

func OpCUKeyPrefix(symbol string) []byte

func ParamKeyTable

func ParamKeyTable() subspace.KeyTable

ParamKeyTable for auth module

func ProtoBaseCU

func ProtoBaseCU() exported.CustodianUnit

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the codec

func StdSignBytes

func StdSignBytes(chainID string, 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 BaseCU

type BaseCU struct {
	Type     sdk.CUType    `json:"cu_type" yaml:"type"`
	Address  sdk.CUAddress `json:"address" yaml:"address"`
	PubKey   crypto.PubKey `json:"public_key" yaml:"public_key"`
	Sequence uint64        `json:"sequence" yaml:"sequence"`
	Symbol   string        `json:"symbol" yaml:"symbol"`
}

func NewBaseCU

func NewBaseCU(cutype sdk.CUType, address sdk.CUAddress, pubKey crypto.PubKey, sequence uint64) *BaseCU

NewBaseCU creates a new BaseCU object

func NewBaseCUWithAddress

func NewBaseCUWithAddress(cuaddr sdk.CUAddress, cuType sdk.CUType) BaseCU

Keeper independent constructor, only for genesis

func NewBaseCUWithPubkey

func NewBaseCUWithPubkey(pub crypto.PubKey, cuType sdk.CUType) BaseCU

func (*BaseCU) GetAddress

func (bcu *BaseCU) GetAddress() sdk.CUAddress

func (*BaseCU) GetCUType

func (bcu *BaseCU) GetCUType() sdk.CUType

func (*BaseCU) GetPubKey

func (bcu *BaseCU) GetPubKey() crypto.PubKey

func (*BaseCU) GetSequence

func (bcu *BaseCU) GetSequence() uint64

func (*BaseCU) GetSymbol

func (bcu *BaseCU) GetSymbol() string

GetSymbol for operation CU . return first asset.symbol

func (*BaseCU) MarshalYAML

func (bcu *BaseCU) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML representation of an custodianunit.

func (*BaseCU) SetAddress

func (bcu *BaseCU) SetAddress(cuaddress sdk.CUAddress) error

func (*BaseCU) SetCUType

func (bcu *BaseCU) SetCUType(cuType sdk.CUType) error

SetCUType set the custodian unit type if the type of custodian unit already defined return error

func (*BaseCU) SetPubKey

func (bcu *BaseCU) SetPubKey(pub crypto.PubKey) error

func (*BaseCU) SetSequence

func (bcu *BaseCU) SetSequence(seq uint64) error

func (*BaseCU) SetSymbol

func (bcu *BaseCU) SetSymbol(symbol string) error

SetSymbol for operation CU . set first asset.symbol

func (*BaseCU) String

func (bcu *BaseCU) String() string

String implements fmt.Stringer

func (*BaseCU) Validate

func (bcu *BaseCU) Validate() error

Validate checks for errors on the account fields

type BaseCUs

type BaseCUs []BaseCU

func (BaseCUs) String

func (bs BaseCUs) String() string

type CURetriever

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

CURetriever defines the properties of a type that can be used to retrieve CUs.

func NewCURetriever

func NewCURetriever(querier NodeQuerier) CURetriever

NewCURetriever initialises a new CURetriever instance.

func (CURetriever) EnsureExists

func (cr CURetriever) EnsureExists(addr sdk.CUAddress) error

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

func (CURetriever) GetCU

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

func (CURetriever) GetCUWithHeight

func (cr CURetriever) GetCUWithHeight(addr sdk.CUAddress) (exported.CustodianUnit, int64, error)

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

func (CURetriever) GetOpCUWithHeight

func (cr CURetriever) GetOpCUWithHeight(symbol string) (sdk.OpCUsAstInfo, int64, error)

func (CURetriever) GetSequence

func (cr CURetriever) GetSequence(addr sdk.CUAddress) (uint64, error)

GetSequence returns sequence for the given address. It returns an error if the CustodianUnit couldn't be retrieved from the state.

type GenesisCUIterator

type GenesisCUIterator struct{}

GenesisAccountIterator implements genesis account iteration.

func (GenesisCUIterator) IterateGenesisAccounts

func (GenesisCUIterator) IterateGenesisAccounts(
	cdc *codec.Codec, appGenesis map[string]json.RawMessage, cb func(unit exported.CustodianUnit) (stop bool),
)

IterateGenesisCUs iterates over all the genesis accounts found in appGenesis and invokes a callback on each genesis account. If any call returns true, iteration stops.

type GenesisState

type GenesisState struct {
	Cus    []exported.CustodianUnit `json:"custodianunits"`
	Params Params                   `json:"params" yaml:"params"`
}

GenesisState - all auth state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState - Return a default genesis state

func GetGenesisStateFromAppState

func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawMessage) GenesisState

func NewGenesisState

func NewGenesisState(params Params, cus []exported.CustodianUnit) GenesisState

NewGenesisState - Create a new genesis state

func (*GenesisState) AddCUIntoGenesisState

func (g *GenesisState) AddCUIntoGenesisState(new exported.CustodianUnit) error

type MultiQueryChainAddrInfoParams

type MultiQueryChainAddrInfoParams struct {
	ChainInfos []QueryCUChainAddressParams
}

func NewMultiQueryChanAddrInfoParams

func NewMultiQueryChanAddrInfoParams(chaininfos []QueryCUChainAddressParams) MultiQueryChainAddrInfoParams

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"`
	SigVerifyCostED25519   uint64 `json:"sig_verify_cost_ed25519" yaml:"sig_verify_cost_ed25519"`
	SigVerifyCostSecp256k1 uint64 `json:"sig_verify_cost_secp256k1" yaml:"sig_verify_cost_secp256k1"`
}

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() subspace.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 QueryCUChainAddressParams

type QueryCUChainAddressParams struct {
	Chain   string
	Address string
}

func NewQueryCUChainAddressParams

func NewQueryCUChainAddressParams(chain string, address string) QueryCUChainAddressParams

type QueryCUParams

type QueryCUParams struct {
	Address sdk.CUAddress
}

QueryCUParams defines the params for querying cu.

func NewQueryCUParams

func NewQueryCUParams(addr sdk.CUAddress) QueryCUParams

NewQueryCUParams creates a new instance of QueryCUParams.

type StdFee

type StdFee struct {
	Amount sdk.Coins `json:"amount" yaml:"amount"`
	Gas    uint64    `json:"gas" yaml:"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.Coins) StdFee

NewStdFee returns a new instance of StdFee

func NewTestStdFee

func NewTestStdFee() StdFee

func (StdFee) Bytes

func (fee StdFee) Bytes() []byte

Bytes for signing later

func (StdFee) GasPrices

func (fee StdFee) GasPrices() sdk.DecCoins

GasPrices returns the gas prices for a StdFee.

NOTE: The gas prices returned are not the true gas prices that were originally part of the submitted transaction because the fee is computed as fee = ceil(gasWanted * gasPrices).

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"`
	Sequence uint64            `json:"sequence" yaml:"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 CU).

type StdSignMsg

type StdSignMsg struct {
	ChainID  string    `json:"chain_id" yaml:"chain_id"`
	Sequence uint64    `json:"sequence" yaml:"sequence"`
	Fee      StdFee    `json:"fee" yaml:"fee"`
	Msgs     []sdk.Msg `json:"msgs" yaml:"msgs"`
	Memo     string    `json:"memo" yaml:"memo"`
}

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

func (msg StdSignMsg) Bytes() []byte

get message bytes

type StdSignature

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

StdSignature represents a sig

func MakeSignature

func MakeSignature(keybase crkeys.Keybase, name, passphrase string,
	msg StdSignMsg) (sig StdSignature, err error)

MakeSignature builds a StdSignature given keybase, key name, passphrase, and a StdSignMsg.

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        StdFee         `json:"fee" yaml:"fee"`
	Signatures []StdSignature `json:"signatures" yaml:"signatures"`
	Memo       string         `json:"memo" yaml:"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

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

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) IsSettleOnlyTx

func (tx StdTx) IsSettleOnlyTx() bool

Tx is settle only tx iff any of its msg is SettleOnlyMsg

func (StdTx) IsSettleTx

func (tx StdTx) IsSettleTx() bool

Tx is settle tx iff all its msg is SettleMsg

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 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, seq, gas uint64, gasAdj float64,
	simulateAndExecute bool, chainID, memo string, fees sdk.Coins, gasPrices sdk.DecCoins,
) TxBuilder

NewTxBuilder returns a new initialized TxBuilder.

func NewTxBuilderFromCLI

func NewTxBuilderFromCLI() TxBuilder

NewTxBuilderFromCLI returns a new initialized TxBuilder with parameters from the command line using Viper.

func (TxBuilder) BuildAndSign

func (bldr TxBuilder) BuildAndSign(name, passphrase string, msgs []sdk.Msg) ([]byte, error)

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

func (TxBuilder) BuildSignMsg

func (bldr TxBuilder) BuildSignMsg(msgs []sdk.Msg) (StdSignMsg, error)

BuildSignMsg builds a single message to be signed from a TxBuilder given a set of messages. It returns an error if a fee is supplied but cannot be parsed.

func (TxBuilder) BuildTxForSim

func (bldr TxBuilder) BuildTxForSim(msgs []sdk.Msg) ([]byte, error)

BuildTxForSim creates a StdSignMsg and encodes a transaction with the StdSignMsg with a single empty StdSignature for tx simulation.

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) Gas

func (bldr TxBuilder) Gas() uint64

Gas returns the gas for the transaction

func (TxBuilder) GasAdjustment

func (bldr TxBuilder) GasAdjustment() float64

GasAdjustment returns the gas adjustment

func (TxBuilder) GasPrices

func (bldr TxBuilder) GasPrices() sdk.DecCoins

GasPrices returns the gas prices set for the transaction, if any.

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) Sequence

func (bldr TxBuilder) Sequence() uint64

Sequence returns the transaction sequence

func (TxBuilder) Sign

func (bldr TxBuilder) Sign(name, passphrase string, msg StdSignMsg) ([]byte, error)

Sign signs a transaction given a name, passphrase, and a single message to signed. An error is returned if signing fails.

func (TxBuilder) SignStdTx

func (bldr TxBuilder) SignStdTx(name, passphrase string, stdTx StdTx, appendSig bool) (signedStdTx StdTx, err error)

SignStdTx appends a signature to a StdTx and returns a copy of it. If append is false, it replaces the signatures already attached with the new signature.

func (TxBuilder) SimulateAndExecute

func (bldr TxBuilder) SimulateAndExecute() bool

SimulateAndExecute returns the option to simulate and then execute the transaction using the gas from the simulation results

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) WithGas

func (bldr TxBuilder) WithGas(gas uint64) TxBuilder

WithGas returns a copy of the context with an updated gas.

func (TxBuilder) WithGasPrices

func (bldr TxBuilder) WithGasPrices(gasPrices string) TxBuilder

WithGasPrices returns a copy of the context with updated gas prices.

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) WithSequence

func (bldr TxBuilder) WithSequence(sequence uint64) TxBuilder

WithSequence returns a copy of the context with an updated sequence number.

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