Documentation ¶
Index ¶
- Constants
- Variables
- func AddSeparator(input []byte, precision int64, sep byte) []byte
- func AddZero(input []byte, precision int64, sep byte) []byte
- func BondStatusToString(b BondStatus) string
- func CodeToDefaultMsg(code CodeType) string
- func DecEq(t *testing.T, exp, got Dec) (*testing.T, bool, string, Dec, Dec)
- func DecsEqual(d1s, d2s []Dec) bool
- func FromBig(input []byte, sep byte, precision int64) []byte
- func GenerateKeyPair() (PubKeySecp256k1, PrivKeySecp256k1)
- func GetCryptoPrivKey(input string) crypto.PrivKeySecp256k1
- func GetTxDecoder(cdc *wire.Codec) func([]byte) (sdk.Tx, sdk.Error)
- func IsValidDec(input []byte, sep byte, precision int64) (bool, error)
- func IsValidDenom(denom string) bool
- func NewDecFromStr(str string) (d Dec, err Error)
- func RemoveSeparator(input []byte, sep byte) []byte
- func SeparatorIndex(input []byte, sep byte) (int64, error)
- func ToBig(input []byte, sep byte, precision int64) []byte
- func TrimZero(input []byte, sep byte) []byte
- type ABCICodeType
- type Account
- type AppAccount
- type Asset
- type BasicSig
- type BasicTx
- type BondStatus
- type Booking
- type CodeType
- type CodespaceType
- type Coin
- func (c Coin) Abs() Coin
- func (c Coin) Equal(o Coin) bool
- func (c Coin) GT(o Coin) bool
- func (c Coin) GTE(o Coin) bool
- func (coin Coin) HasDenom(denom string) bool
- func (coin Coin) HasValidDenom() bool
- func (c Coin) IsNil() bool
- func (c Coin) IsNotNegative() bool
- func (c Coin) IsPositive() bool
- func (coin Coin) IsSameDenom(other Coin) bool
- func (c Coin) IsZero() bool
- func (c Coin) LT(o Coin) bool
- func (c Coin) LTE(o Coin) bool
- func (coin Coin) Minus(other Coin) Coin
- func (coin Coin) Mul(factor Dec) Coin
- func (c Coin) Neg() Coin
- func (coin Coin) Plus(other Coin) Coin
- func (coin Coin) Quo(factor Dec) Coin
- func (coin Coin) String() string
- type Coins
- func (coins Coins) Abs() Coins
- func (coins Coins) AllCoins(method string) bool
- func (c Coins) Equal(o Coin) bool
- func (c Coins) GT(o Coin) bool
- func (c Coins) GTE(o Coin) bool
- func (coins Coins) GetCoin(denom string) Coin
- func (coins Coins) GetCoins() Coins
- func (coins Coins) HasCoin(o Coin, method string) bool
- func (coins Coins) HasValidDenoms() bool
- func (c Coins) IsNil() bool
- func (c Coins) IsNotNegative() bool
- func (c Coins) IsPositive() bool
- func (c Coins) IsZero() bool
- func (c Coins) LT(o Coin) bool
- func (c Coins) LTE(o Coin) bool
- func (coins *Coins) Minus(other Coin) Coins
- func (coins Coins) MinusMany(coinsB Coins) Coins
- func (coins Coins) Negative() Coins
- func (coins *Coins) Plus(other Coin) Coins
- func (coins Coins) PlusMany(coinsB Coins) Coins
- func (coins *Coins) SetCoins(co Coins)
- func (coins Coins) String() string
- type Dec
- func MaxDec(d1, d2 Dec) Dec
- func MinDec(d1, d2 Dec) Dec
- func NewDec(i int64) Dec
- func NewDecFromBigInt(i *big.Int) Dec
- func NewDecFromBigIntWithPrec(i *big.Int, prec int64) Dec
- func NewDecFromInt(i Int) Dec
- func NewDecFromIntWithPrec(i Int, prec int64) Dec
- func NewDecWithPrec(i, prec int64) Dec
- func OneDec() Dec
- func ZeroDec() Dec
- func (d Dec) Abs() Dec
- func (d Dec) Add(d2 Dec) Dec
- func (d Dec) Equal(d2 Dec) bool
- func (d Dec) GT(d2 Dec) bool
- func (d Dec) GTE(d2 Dec) bool
- func (d Dec) IsNil() bool
- func (d Dec) IsNotNegative() bool
- func (d Dec) IsPositive() bool
- func (d Dec) IsZero() bool
- func (d Dec) LT(d2 Dec) bool
- func (d Dec) LTE(d2 Dec) bool
- func (d Dec) MarshalAmino() (string, error)
- func (d Dec) MarshalJSON() ([]byte, error)
- func (d Dec) Mul(d2 Dec) Dec
- func (d Dec) MulInt(i Int) Dec
- func (d Dec) Neg() Dec
- func (d Dec) Quo(d2 Dec) Dec
- func (d Dec) RoundInt() Int
- func (d Dec) RoundInt64() int64
- func (d Dec) String() string
- func (d Dec) Sub(d2 Dec) Dec
- func (d Dec) ToLeftPadded(totalDigits int8) string
- func (d Dec) ToLeftPaddedWithDecimals(totalDigits int8) string
- func (d Dec) TruncateInt() Int
- func (d Dec) TruncateInt64() int64
- func (d *Dec) UnmarshalAmino(text string) (err error)
- func (d *Dec) UnmarshalJSON(bz []byte) error
- type Delegation
- type DelegationSet
- type Error
- func ErrInsufficientCoins(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 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, msg string) Error
- type Int
- func (i Int) Add(i2 Int) (res Int)
- func (i Int) AddRaw(i2 int64) Int
- func (i Int) BigInt() *big.Int
- func (i Int) Div(i2 Int) (res Int)
- func (i Int) DivRaw(i2 int64) Int
- func (i Int) Equal(i2 Int) bool
- func (i Int) GT(i2 Int) bool
- func (i Int) Int64() int64
- func (i Int) IsInt64() bool
- func (i Int) IsZero() bool
- func (i Int) LT(i2 Int) bool
- func (i Int) MarshalAmino() (string, error)
- func (i Int) MarshalJSON() ([]byte, error)
- func (i Int) Mod(i2 Int) Int
- func (i Int) ModRaw(i2 int64) Int
- func (i Int) Mul(i2 Int) (res Int)
- func (i Int) MulRaw(i2 int64) Int
- func (i Int) Neg() (res Int)
- func (i Int) Sign() int
- func (i Int) String() string
- func (i Int) Sub(i2 Int) (res Int)
- func (i Int) SubRaw(i2 int64) Int
- func (i *Int) UnmarshalAmino(text string) error
- func (i *Int) UnmarshalJSON(bz []byte) error
- type PrivKey
- type PrivKeySecp256k1
- type PubKey
- type PubKeySecp256k1
- func (pubKey PubKeySecp256k1) Address() sdk.Address
- func (pubKey PubKeySecp256k1) Bytes() []byte
- func (pubKey PubKeySecp256k1) Equals(other PubKey) bool
- func (pubKey PubKeySecp256k1) String() string
- func (pubKey PubKeySecp256k1) ToABCIPubKey() crypto.PubKeySecp256k1
- func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sig_ Signature) bool
- type QueryTx
- type Result
- type SHRSignature
- type SHRTx
- type Signature
- type SignatureSecp256k1
- 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) 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) 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
- type Validator
- type ValidatorSet
Constants ¶
const ( Precision = 10 // bytes required to represent the above precision // ceil(log2(9999999999)) DecimalPrecisionBits = 34 Separator = '.' )
number of decimal places
const ( // ABCI error codes ABCICodeOK ABCICodeType = 0 // 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 // 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 = 0 CodespaceRoot CodespaceType = 1 // Maximum reservable codespace (2^16 - 1) MaximumCodespace CodespaceType = 65535 )
SDK error codes
const (
ADDRESSLENGTH = 20 //byte length
)
Variables ¶
var (
BITS = 256
)
Functions ¶
func BondStatusToString ¶
func BondStatusToString(b BondStatus) string
BondStatusToString for pretty prints of Bond Status
func CodeToDefaultMsg ¶
NOTE: Don't stringer this, we'll put better messages in later.
func GenerateKeyPair ¶
func GenerateKeyPair() (PubKeySecp256k1, PrivKeySecp256k1)
func GetCryptoPrivKey ¶
func GetCryptoPrivKey(input string) crypto.PrivKeySecp256k1
func GetTxDecoder ¶
JSON decode MsgSend.
func IsValidDenom ¶
func NewDecFromStr ¶
create a decimal from an input decimal string. valid must come in the form:
(-) whole integers (.) decimal integers
examples of acceptable input include:
-123.456 456.7890 345 -456789
NOTE - An error will return if more decimal places are provided in the string than the constant Precision.
CONTRACT - This function does not mutate the input str.
func RemoveSeparator ¶
Types ¶
type ABCICodeType ¶
type ABCICodeType uint32
ABCICodeType - combined codetype / codespace
func ToABCICode ¶
func ToABCICode(space CodespaceType, code CodeType) ABCICodeType
get the abci code from the local code and codespace
type AppAccount ¶
type AppAccount struct {
Coins Coin `json:"coins"`
}
Simple account struct
func NewDefaultAccount ¶
func NewDefaultAccount() AppAccount
func (AppAccount) GetCoins ¶
func (acc AppAccount) GetCoins() Coins
func (*AppAccount) SetCoins ¶
func (acc *AppAccount) SetCoins(coins Coins)
type Asset ¶
type Asset struct { UUID string `json:"uuid"` Hash []byte `json:"hash"` Creator sdk.Address `json:"creator"` Status bool `json:"status"` Fee int64 `json:"fee"` }
Asset asset infomation
type BasicTx ¶
Simple tx to wrap the Msg.
func (BasicTx) GetSignBytes ¶
GetSignBytes returns Bytes to be signed
func (BasicTx) GetSignature ¶
func (tx BasicTx) GetSignature() SHRSignature
GetSignature returns the signature with this transaction
func (BasicTx) VerifySignature ¶
VerifySignature to verify signature
type BondStatus ¶
type BondStatus byte
status of a validator
const ( Unbonded BondStatus = 0x00 Unbonding BondStatus = 0x01 Bonded BondStatus = 0x02 )
nolint
type Booking ¶
type Booking struct { BookingID string `json:"bookingId"` Renter sdk.Address `json:"renter"` UUID string `json:"uuid"` Duration int64 `json:"duration"` IsCompleted bool `json:"is_completed"` }
Simple Booking struct
func NewBooking ¶
type Coin ¶
func NewCoinFromDec ¶
func NewDefaultCoin ¶
func NewDefaultCoin() Coin
func NewPOSCoin ¶
func NewPOSCoinFromDec ¶
func NewZeroPOSCoin ¶
func NewZeroPOSCoin() Coin
func (Coin) HasValidDenom ¶
func (Coin) IsNotNegative ¶
func (Coin) IsPositive ¶
func (Coin) IsSameDenom ¶
type Coins ¶
type Coins []Coin
func NewDefaultCoins ¶
func NewDefaultCoins() Coins
func (Coins) AllCoins ¶
AllCoins - ensure all coins has a field which has a method return true Example: coins.IsNil() == AllCoins("Amount", "IsNil") meaning Coins IsNil() if all coins of Coins IsNil
func (Coins) HasCoin ¶
HasCoin - has a coin whose method satisfies the method Example: coins.GT(*other*) if coins has a single coin which is GT than *other*
func (Coins) HasValidDenoms ¶
func (Coins) IsNotNegative ¶
func (Coins) IsPositive ¶
type Dec ¶
NOTE: never use new(Dec) or else we will panic unmarshalling into the nil embedded big.Int
func NewDecFromBigInt ¶
create a new Dec from big integer assuming whole numbers CONTRACT: prec <= Precision
func NewDecFromBigIntWithPrec ¶
create a new Dec from big integer assuming whole numbers CONTRACT: prec <= Precision
func NewDecFromInt ¶
create a new Dec from big integer assuming whole numbers CONTRACT: prec <= Precision
func NewDecFromIntWithPrec ¶
create a new Dec from big integer with decimal place at prec CONTRACT: prec <= Precision
func NewDecWithPrec ¶
create a new Dec from integer with decimal place at prec CONTRACT: prec <= Precision
func (Dec) IsNil ¶
______________________________________________________________________________________________ nolint
func (Dec) IsNotNegative ¶
func (Dec) IsPositive ¶
func (Dec) MarshalJSON ¶
MarshalJSON defines custom encoding scheme
func (Dec) RoundInt64 ¶
RoundInt64 rounds the decimal using bankers rounding
func (Dec) String ¶
String - replace cosmos String() as Cosmos doesn't discard unneccessary trailling zero
func (Dec) ToLeftPadded ¶
TODO panic if negative or if totalDigits < len(initStr)??? evaluate as an integer and return left padded string
func (Dec) ToLeftPaddedWithDecimals ¶
TODO panic if negative or if totalDigits < len(initStr)??? evaluate as an integer and return left padded string
func (Dec) TruncateInt ¶
TruncateInt truncates the decimals from the number and returns an Int
func (Dec) TruncateInt64 ¶
TruncateInt64 truncates the decimals from the number and returns an int64
func (*Dec) UnmarshalAmino ¶
requires a valid JSON string - strings quotes and calls UnmarshalText
func (*Dec) UnmarshalJSON ¶
UnmarshalJSON defines custom decoding scheme
type Delegation ¶
type Delegation interface { GetDelegator() sdk.Address // delegator address for the bond GetValidator() sdk.Address // validator owner address for the bond }
delegation bond for a delegated proof of stake system
type DelegationSet ¶
type DelegationSet interface { GetValidatorSet() ValidatorSet // validator set for which delegation set is based upon // iterate through all delegations from one delegator by validator-address, // execute func for each validator IterateDelegations(ctx sdk.Context, delegator sdk.Address, fn func(index int64, delegation Delegation) (stop bool)) }
properties for the set of all delegations for a particular
type Error ¶
type Error interface { Error() string Code() CodeType Codespace() CodespaceType ABCILog() string ABCICode() ABCICodeType WithDefaultCodespace(codespace CodespaceType) Error Trace(msg string) Error T() interface{} Result() Result QueryResult() abci.ResponseQuery }
sdk Error type
func ErrInsufficientCoins ¶
func ErrInsufficientFunds ¶
func ErrInvalidAddress ¶
func ErrInvalidCoins ¶
func ErrInvalidPubKey ¶
func ErrInvalidSequence ¶
func ErrMemoTooLarge ¶
func ErrOutOfGas ¶
func ErrTxDecode ¶
func ErrUnauthorized ¶
func ErrUnknownAddress ¶
func ErrUnknownRequest ¶
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int 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 Int from big.Int
func NewIntFromString ¶
NewIntFromString constructs Int from string
func NewIntWithDecimal ¶
NewIntWithDecimal constructs Int with decimal Result value is n*10^dec
func (Int) MarshalAmino ¶
MarshalAmino defines custom encoding scheme
func (Int) MarshalJSON ¶
MarshalJSON defines custom encoding scheme
func (*Int) UnmarshalAmino ¶
UnmarshalAmino defines custom decoding scheme
func (*Int) UnmarshalJSON ¶
UnmarshalJSON defines custom decoding scheme
type PrivKeySecp256k1 ¶
type PrivKeySecp256k1 [32]byte
func ConvertToPrivKey ¶
func ConvertToPrivKey(privKey crypto.PrivKey) PrivKeySecp256k1
func NewPrivKeySecp256k1 ¶
func NewPrivKeySecp256k1(b []byte) PrivKeySecp256k1
func (PrivKeySecp256k1) PubKey ¶
func (privKey PrivKeySecp256k1) PubKey() PubKeySecp256k1
func (PrivKeySecp256k1) SignWithNonce ¶
func (privKey PrivKeySecp256k1) SignWithNonce(msg sdk.Msg, nonce int64) Signature
func (PrivKeySecp256k1) String ¶
func (privKey PrivKeySecp256k1) String() string
type PubKeySecp256k1 ¶
type PubKeySecp256k1 [65]byte
Normal key 65 byte
func ConvertToPubKey ¶
func ConvertToPubKey(pubKey []byte) PubKeySecp256k1
convert from Tendermint PubKey to ShareLedger PubKey
func GetTestPubKey ¶
func GetTestPubKey() PubKeySecp256k1
func NewPubKeySecp256k1 ¶
func NewPubKeySecp256k1(b []byte) PubKeySecp256k1
func NilPubKeySecp256k1 ¶
func NilPubKeySecp256k1() PubKeySecp256k1
func (PubKeySecp256k1) Address ¶
func (pubKey PubKeySecp256k1) Address() sdk.Address
Implements Bitcoin style addresses: RIPEMD160(SHA256(pubkey))
func (PubKeySecp256k1) Bytes ¶
func (pubKey PubKeySecp256k1) Bytes() []byte
func (PubKeySecp256k1) Equals ¶
func (pubKey PubKeySecp256k1) Equals(other PubKey) bool
func (PubKeySecp256k1) String ¶
func (pubKey PubKeySecp256k1) String() string
func (PubKeySecp256k1) ToABCIPubKey ¶
func (pubKey PubKeySecp256k1) ToABCIPubKey() crypto.PubKeySecp256k1
func (PubKeySecp256k1) VerifyBytes ¶
func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sig_ Signature) bool
type QueryTx ¶
func NewQueryTx ¶
func (QueryTx) GetSignBytes ¶
func (QueryTx) GetSignature ¶
func (tx QueryTx) GetSignature() SHRSignature
func (QueryTx) VerifySignature ¶
type Result ¶
type Result struct { // Code is the response code, is stored back on the chain. Code ABCICodeType // 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 int64 // GasUsed is the amount of gas actually consumed. NOTE: unimplemented GasUsed int64 // Tx fee amount and denom. FeeAmount int64 FeeDenom string // Tags are used for transaction indexing and pubsub. Tags sdk.Tags }
Result is the union of ResponseDeliverTx and ResponseCheckTx.
type SHRSignature ¶
type SHRTx ¶
type SHRTx interface { sdk.Tx GetMsg() sdk.Msg GetSignature() SHRSignature VerifySignature() bool GetSignBytes() []byte }
----------------------------------------------------------------- Tx Interface
type SignatureSecp256k1 ¶
type SignatureSecp256k1 []byte
Implements Signature
func Sign ¶
func Sign(privKey *PrivKeySecp256k1, msg sdk.Msg) SignatureSecp256k1
func SignWithNonce ¶
func SignWithNonce(privKey *PrivKeySecp256k1, msg sdk.Msg, nonce int64) SignatureSecp256k1
func (SignatureSecp256k1) Bytes ¶
func (sig SignatureSecp256k1) Bytes() []byte
func (SignatureSecp256k1) Equals ¶
func (sig SignatureSecp256k1) Equals(other Signature) bool
func (SignatureSecp256k1) IsZero ¶
func (sig SignatureSecp256k1) IsZero() bool
func (SignatureSecp256k1) String ¶
func (sig SignatureSecp256k1) String() string
type Uint ¶
type Uint struct {
// contains filtered or unexported fields
}
Int 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
type Validator ¶
type Validator interface { GetMoniker() string // moniker of the validator GetStatus() BondStatus // status of the validator GetOwner() sdk.Address // owner address to receive/return validators coins GetPubKey() PubKey // validation pubkey GetPower() Dec // validation power GetBondHeight() int64 // height in which the validator became active }
validator for a delegated proof of stake system
type ValidatorSet ¶
type ValidatorSet interface { // iterate through validator by owner-address, execute func for each validator IterateValidators(sdk.Context, func(index int64, validator Validator) (stop bool)) // iterate through bonded validator by pubkey-address, execute func for each validator IterateValidatorsBonded(sdk.Context, func(index int64, validator Validator) (stop bool)) Validator(sdk.Context, sdk.Address) Validator // get a particular validator by owner address TotalPower(sdk.Context) Dec // total power of the validator set Slash(sdk.Context, PubKey, int64, Dec) // slash the validator and delegators of the validator, specifying offence height & slash fraction Revoke(sdk.Context, PubKey) // revoke a validator Unrevoke(sdk.Context, PubKey) // unrevoke a validator }
properties for the set of all validators