Documentation
¶
Index ¶
- Constants
- Variables
- func AddUint64Overflow(a, b uint64) (uint64, bool)
- func AppendMsgToErr(msg string, err string) string
- func Bool2Byte(in bool) []byte
- func CheckQscName(qscName string) bool
- func CodeToDefaultMsg(code CodeType) string
- func DecoderTx(cdc *go_amino.Codec, txBytes []byte) (Tx, Error)
- func FormatTimeBytes(t time.Time) []byte
- func GetAddrFromBech32(bech32Addr string) (address []byte, err error)
- func GetChainID(rootDir string) (string, error)
- func GetGenesisDoc(rootDir string) (*tmtypes.GenesisDoc, error)
- func Int2Byte(in int64) []byte
- func IntEq(t *testing.T, exp, got BigInt) (*testing.T, bool, string, string, string)
- func MustSortJSON(toSortJSON []byte) []byte
- func ParseTimeBytes(bz []byte) (time.Time, error)
- func SortJSON(toSortJSON []byte) ([]byte, error)
- func UintOverflow(x Uint) bool
- type Address
- func (add Address) Bytes() []byte
- func (add Address) Empty() bool
- func (add Address) EqualsTo(anotherAdd Address) bool
- func (add Address) Marshal() ([]byte, error)
- func (add Address) MarshalJSON() ([]byte, error)
- func (add Address) String() string
- func (add *Address) Unmarshal(data []byte) error
- func (add *Address) UnmarshalJSON(bech32Addr []byte) error
- type BaseCoin
- func (coin *BaseCoin) GetAmount() BigInt
- func (coin *BaseCoin) GetName() string
- func (coin *BaseCoin) IsEqual(another Coin) bool
- func (coin *BaseCoin) IsGreaterThan(another Coin) bool
- func (coin *BaseCoin) IsLessThan(another Coin) bool
- func (coin *BaseCoin) IsNegative() bool
- func (coin *BaseCoin) IsNotNegative() bool
- func (coin *BaseCoin) IsPositive() bool
- func (coin *BaseCoin) IsZero() bool
- func (coin *BaseCoin) Minus(coinB Coin) Coin
- func (coin *BaseCoin) MinusByAmount(amountminus BigInt)
- func (coin *BaseCoin) Plus(coinB Coin) Coin
- func (coin *BaseCoin) PlusByAmount(amountplus BigInt)
- func (coin *BaseCoin) SameNameAs(another Coin) bool
- func (coin *BaseCoin) SetAmount(amount BigInt)
- func (coin *BaseCoin) String() string
- type BaseCoins
- func (coins BaseCoins) AmountOf(name string) BigInt
- func (coins BaseCoins) IsEqual(coinsB BaseCoins) bool
- func (coins BaseCoins) IsGTE(coinsB BaseCoins) bool
- func (coins BaseCoins) IsLT(coinsB BaseCoins) bool
- func (coins BaseCoins) IsNotNegative() bool
- func (coins BaseCoins) IsPositive() bool
- func (coins BaseCoins) IsValid() bool
- func (coins BaseCoins) IsZero() bool
- func (coins BaseCoins) Len() int
- func (coins BaseCoins) Less(i, j int) bool
- func (coins BaseCoins) Minus(coinsB BaseCoins) BaseCoins
- func (coins BaseCoins) Negative() BaseCoins
- func (coins BaseCoins) Plus(coinsB BaseCoins) BaseCoins
- func (coins BaseCoins) Sort() BaseCoins
- func (coins BaseCoins) String() string
- func (coins BaseCoins) Swap(i, j int)
- type BigInt
- func (i BigInt) Add(i2 BigInt) (res BigInt)
- func (i BigInt) AddRaw(i2 int64) BigInt
- func (i BigInt) BigInt() *big.Int
- func (i BigInt) Div(i2 BigInt) (res BigInt)
- func (i BigInt) DivRaw(i2 int64) BigInt
- func (i BigInt) Equal(i2 BigInt) bool
- func (i BigInt) GT(i2 BigInt) bool
- func (i BigInt) Int64() int64
- func (i BigInt) IsInt64() bool
- func (bi BigInt) IsNil() bool
- func (i BigInt) IsZero() bool
- func (i BigInt) LT(i2 BigInt) bool
- func (i BigInt) MarshalAmino() (string, error)
- func (i BigInt) MarshalJSON() ([]byte, error)
- func (i BigInt) Mod(i2 BigInt) BigInt
- func (i BigInt) ModRaw(i2 int64) BigInt
- func (i BigInt) Mul(i2 BigInt) (res BigInt)
- func (i BigInt) MulRaw(i2 int64) BigInt
- func (i BigInt) Neg() (res BigInt)
- func (i BigInt) NilToZero() BigInt
- func (i BigInt) Sign() int
- func (i BigInt) String() string
- func (i BigInt) Sub(i2 BigInt) (res BigInt)
- func (i BigInt) SubRaw(i2 int64) BigInt
- func (i *BigInt) UnmarshalAmino(text string) error
- func (i *BigInt) UnmarshalJSON(bz []byte) error
- type CodeType
- type CodespaceType
- type Coin
- type Error
- func ErrInsufficientCoins(msg string) Error
- func ErrInsufficientFee(msg string) Error
- func ErrInsufficientFunds(msg string) Error
- func ErrInternal(msg string) Error
- func ErrInvalidAddress(msg string) Error
- func ErrInvalidCoins(msg string) Error
- func ErrInvalidPubKey(msg string) Error
- func ErrInvalidSequence(msg string) Error
- func ErrMemoTooLarge(msg string) Error
- func ErrOutOfGas(msg string) Error
- func ErrTooManySignatures(msg string) Error
- func ErrTxDecode(msg string) Error
- func ErrUnauthorized(msg string) Error
- func ErrUnknownAddress(msg string) Error
- func ErrUnknownRequest(msg string) Error
- func NewError(codespace CodespaceType, code CodeType, format string, args ...interface{}) Error
- type ErrorGasOverflow
- type ErrorOutOfGas
- type Gas
- type GasConfig
- type GasMeter
- type GenesisState
- type QCPConfig
- type Result
- type Tag
- type Tags
- type Tx
- type Uint
- func (i Uint) Add(i2 Uint) (res Uint)
- func (i Uint) AddRaw(i2 uint64) Uint
- func (i Uint) BigInt() *big.Int
- func (i Uint) Div(i2 Uint) (res Uint)
- func (i Uint) DivRaw(i2 uint64) Uint
- func (i Uint) Equal(i2 Uint) bool
- func (i Uint) GT(i2 Uint) bool
- func (i Uint) IsNil() bool
- func (i Uint) IsUint64() bool
- func (i Uint) IsZero() bool
- func (i Uint) LT(i2 Uint) bool
- func (i Uint) MarshalAmino() (string, error)
- func (i Uint) MarshalJSON() ([]byte, error)
- func (i Uint) Mod(i2 Uint) Uint
- func (i Uint) ModRaw(i2 uint64) Uint
- func (i Uint) Mul(i2 Uint) (res Uint)
- func (i Uint) MulRaw(i2 uint64) Uint
- func (i Uint) NilToZero() Uint
- func (i Uint) Sign() int
- func (i Uint) String() string
- func (i Uint) Sub(i2 Uint) (res Uint)
- func (i Uint) SubRaw(i2 uint64) Uint
- func (i Uint) Uint64() uint64
- func (i *Uint) UnmarshalAmino(text string) error
- func (i *Uint) UnmarshalJSON(bz []byte) error
Constants ¶
const ( // Base error codes CodeOK CodeType = 0 CodeInternal CodeType = 1 CodeTxDecode CodeType = 2 CodeInvalidSequence CodeType = 3 CodeInsufficientFunds CodeType = 5 CodeUnknownRequest CodeType = 6 CodeInvalidAddress CodeType = 7 CodeInvalidPubKey CodeType = 8 CodeUnknownAddress CodeType = 9 CodeInsufficientCoins CodeType = 10 CodeInvalidCoins CodeType = 11 CodeOutOfGas CodeType = 12 CodeMemoTooLarge CodeType = 13 CodeInsufficientFee CodeType = 14 CodeTooManySignatures CodeType = 15 // CodespaceRoot is a codespace for error codes in this file only. // Notice that 0 is an "unset" codespace, which can be overridden with // Error.WithDefaultCodespace(). CodespaceUndefined CodespaceType = "" CodespaceRoot CodespaceType = "sdk" )
SDK error codes
const ( GasIterNextCostFlatDesc = "IterNextFlat" GasValuePerByteDesc = "ValuePerByte" GasWritePerByteDesc = "WritePerByte" GasReadPerByteDesc = "ReadPerByte" GasWriteCostFlatDesc = "WriteFlat" GasReadCostFlatDesc = "ReadFlat" GasHasDesc = "Has" GasDeleteDesc = "Delete" )
Gas consumption descriptors.
const (
PREF_ADD = "address" // 地址前缀
)
const SortableTimeFormat = "2006-01-02T15:04:05.000000000"
Slight modification of the RFC3339Nano but it right pads all zeros and drops the time zone info
Variables ¶
var ( TagAction = "action" TagSrcValidator = "source-validator" TagDstValidator = "destination-validator" TagDelegator = "delegator" )
common tags
Functions ¶
func AddUint64Overflow ¶ added in v0.0.10
AddUint64Overflow performs the addition operation on two uint64 integers and returns a boolean on whether or not the result overflows.
func AppendMsgToErr ¶ added in v0.0.10
appends a message to the head of the given error
func CheckQscName ¶ added in v0.0.2
功能:检查 QscName 的合法性 备注:合法(3-10个字符,数字-字母-下划线)
func CodeToDefaultMsg ¶
NOTE: Don't stringer this, we'll put better messages in later.
func FormatTimeBytes ¶ added in v0.0.10
Formats a time.Time into a []byte that can be sorted
func GetAddrFromBech32 ¶
由Bech32编码的地址解码为byte数组 prefix_type 验证类型是否相符
func GetChainID ¶ added in v0.0.7
func GetGenesisDoc ¶ added in v0.0.7
func GetGenesisDoc(rootDir string) (*tmtypes.GenesisDoc, error)
func MustSortJSON ¶
MustSortJSON is like SortJSON but panic if an error occurs, e.g., if the passed JSON isn't valid.
func ParseTimeBytes ¶ added in v0.0.10
Parses a []byte encoded using FormatTimeKey back into a time.Time
func SortJSON ¶
SortedJSON takes any JSON and returns it sorted by keys. Also, all white-spaces are removed. This method can be used to canonicalize JSON to be returned by GetSignBytes, e.g. for the ledger integration. If the passed JSON isn't valid it will return an error.
func UintOverflow ¶ added in v0.0.10
UintOverflow returns true if a given unsigned integer overflows and false otherwise.
Types ¶
type Address ¶
地址,类型byte数组
func (Address) MarshalJSON ¶
用Bech32编码将地址marshal为Json
func (*Address) UnmarshalJSON ¶
将Bech32编码的地址Json进行UnMarshal
type BaseCoin ¶ added in v0.0.2
func NewBaseCoin ¶ added in v0.0.2
func NewInt64BaseCoin ¶ added in v0.0.7
func ParseCoins ¶ added in v0.0.10
func (*BaseCoin) IsGreaterThan ¶ added in v0.0.2
同名币,判断数量是否更大
func (*BaseCoin) IsLessThan ¶ added in v0.0.2
同名币,判断数量是否更小
func (*BaseCoin) IsNotNegative ¶ added in v0.0.4
判断币的数量是否为非负值
func (*BaseCoin) MinusByAmount ¶ added in v0.0.2
减掉一定数量的币
func (*BaseCoin) PlusByAmount ¶ added in v0.0.2
增加一定数量的币
func (*BaseCoin) SameNameAs ¶ added in v0.0.2
判断是否与另一币同名
type BaseCoins ¶ added in v0.0.4
type BaseCoins []*BaseCoin
BaseCoin集合
func (BaseCoins) IsNotNegative ¶ added in v0.0.4
返回coins内币种币值是否均大于等于0
func (BaseCoins) IsPositive ¶ added in v0.0.4
返回coins内币种币值是否均大于0
type BigInt ¶
type BigInt struct {
// contains filtered or unexported fields
}
BigInt wraps integer with 256 bit range bound Checks overflow, underflow and division by zero Exists in range from -(2^255-1) to 2^255-1
func NewIntFromBigInt ¶
NewIntFromBigInt constructs BigInt from big.BigInt
func NewIntFromString ¶
NewIntFromString constructs BigInt from string
func NewIntWithDecimal ¶
NewIntWithDecimal constructs BigInt with decimal Result value is n*10^dec
func (BigInt) MarshalAmino ¶
MarshalAmino defines custom encoding scheme
func (BigInt) MarshalJSON ¶
MarshalJSON defines custom encoding scheme
func (*BigInt) UnmarshalAmino ¶
UnmarshalAmino defines custom decoding scheme
func (*BigInt) UnmarshalJSON ¶
UnmarshalJSON defines custom decoding scheme
type Coin ¶
type Coin interface { // getters and setters GetName() string GetAmount() BigInt SetAmount(amount BigInt) // 判断是否同种币 SameNameAs(Coin) bool String() string // 判断币的数量 IsZero() bool IsPositive() bool IsNotNegative() bool IsNegative() bool IsGreaterThan(Coin) bool IsLessThan(Coin) bool IsEqual(Coin) bool // 币的数量运算 Plus(coinB Coin) Coin Minus(coinB Coin) Coin }
币的通用接口
type Error ¶
type Error interface { // convenience TraceSDK(format string, args ...interface{}) Error // set codespace WithDefaultCodespace(CodespaceType) Error Code() CodeType Codespace() CodespaceType ABCILog() string Result() Result QueryResult() abci.ResponseQuery // contains filtered or unexported methods }
sdk Error type
func ErrInsufficientCoins ¶
func ErrInsufficientFee ¶ added in v0.0.10
func ErrInsufficientFunds ¶
func ErrInvalidAddress ¶
func ErrInvalidCoins ¶
func ErrInvalidPubKey ¶
func ErrInvalidSequence ¶
func ErrMemoTooLarge ¶
func ErrOutOfGas ¶
func ErrTooManySignatures ¶ added in v0.0.10
func ErrTxDecode ¶
func ErrUnauthorized ¶
func ErrUnknownAddress ¶
func ErrUnknownRequest ¶
type ErrorGasOverflow ¶ added in v0.0.10
type ErrorGasOverflow struct {
Descriptor string
}
ErrorGasOverflow defines an error thrown when an action results gas consumption unsigned integer overflow.
type ErrorOutOfGas ¶
type ErrorOutOfGas struct {
Descriptor string
}
ErrorOutOfGas defines an error thrown when an action results in out of gas.
type GasConfig ¶
type GasConfig struct { HasCost Gas DeleteCost Gas ReadCostFlat Gas ReadCostPerByte Gas WriteCostFlat Gas WriteCostPerByte Gas ValueCostPerByte Gas IterNextCostFlat Gas }
GasConfig defines gas cost for each operation on KVStores
func KVGasConfig ¶ added in v0.0.10
func KVGasConfig() GasConfig
KVGasConfig returns a default gas config for KVStores.
func TransientGasConfig ¶
func TransientGasConfig() GasConfig
TransientGasConfig returns a default gas config for TransientStores.
type GasMeter ¶
type GasMeter interface { GasConsumed() Gas GasConsumedToLimit() Gas Limit() Gas ConsumeGas(amount Gas, descriptor string) IsPastLimit() bool IsOutOfGas() bool }
GasMeter interface to track gas consumption
func NewGasMeter ¶
NewGasMeter returns a reference to a new basicGasMeter.
func NewInfiniteGasMeter ¶
func NewInfiniteGasMeter() GasMeter
NewInfiniteGasMeter returns a reference to a new infiniteGasMeter.
type GenesisState ¶ added in v0.0.5
type GenesisState struct {
QCPs []*QCPConfig `json:"qcps"`
}
app_state in genesis.json
type QCPConfig ¶ added in v0.0.5
type QCPConfig struct { Name string `json:"name"` ChainId string `json:"chain_id"` PubKey crypto.PubKey `json:"pub_key"` }
QCP配置
type Result ¶
type Result struct { // Code is the response code, is stored back on the chain. Code CodeType // Codespace is the string referring to the domain of an error Codespace CodespaceType // Data is any data returned from the app. Data []byte // Log is just debug information. NOTE: nondeterministic. Log string // GasWanted is the maximum units of work we allow this tx to perform. GasWanted uint64 // GasUsed is the amount of gas actually consumed. NOTE: unimplemented GasUsed uint64 // Tx fee amount and denom. FeeAmount int64 FeeDenom string // Tags are used for transaction indexing and pubsub. Tags Tags }
Result is the union of ResponseDeliverTx and ResponseCheckTx.
type Tags ¶
Type synonym for convenience
type Uint ¶
type Uint struct {
// contains filtered or unexported fields
}
BigInt wraps integer with 256 bit range bound Checks overflow, underflow and division by zero Exists in range from 0 to 2^256-1
func NewUintFromBigInt ¶
NewUintFromBigUint constructs Uint from big.Uint
func NewUintFromString ¶
NewUintFromString constructs Uint from string
func NewUintWithDecimal ¶
NewUintWithDecimal constructs Uint with decimal Result value is n*10^dec
func (Uint) MarshalAmino ¶
MarshalAmino defines custom encoding scheme
func (Uint) MarshalJSON ¶
MarshalJSON defines custom encoding scheme
func (*Uint) UnmarshalAmino ¶
UnmarshalAmino defines custom decoding scheme
func (*Uint) UnmarshalJSON ¶
UnmarshalJSON defines custom decoding scheme