types

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Precision = 10

	// bytes required to represent the above precision
	// ceil(log2(9999999999))
	DecimalPrecisionBits = 34

	Separator = '.'
)

number of decimal places

View Source
const (
	// ABCI error codes
	ABCICodeOK ABCICodeType = 0

	// Base error codes
	CodeOK                CodeType = 0
	CodeInternal          CodeType = 1
	CodeTxDecode          CodeType = 2
	CodeInvalidSequence   CodeType = 3
	CodeUnauthorized      CodeType = 4
	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

View Source
const (
	ADDRESSLENGTH = 20 //byte length
)

Variables

View Source
var (
	BITS = 256
)

Functions

func AddSeparator

func AddSeparator(input []byte, precision int64, sep byte) []byte

func AddZero

func AddZero(input []byte, precision int64, sep byte) []byte

func BondStatusToString

func BondStatusToString(b BondStatus) string

BondStatusToString for pretty prints of Bond Status

func CodeToDefaultMsg

func CodeToDefaultMsg(code CodeType) string

NOTE: Don't stringer this, we'll put better messages in later.

func DecEq

func DecEq(t *testing.T, exp, got Dec) (*testing.T, bool, string, Dec, Dec)

intended to be used with require/assert: require.True(DecEq(...))

func DecsEqual

func DecsEqual(d1s, d2s []Dec) bool

test if two decimal arrays are equal

func FromBig

func FromBig(input []byte, sep byte, precision int64) []byte

func GenerateKeyPair

func GenerateKeyPair() (PubKeySecp256k1, PrivKeySecp256k1)

func GetCryptoPrivKey

func GetCryptoPrivKey(input string) crypto.PrivKeySecp256k1

func GetTxDecoder

func GetTxDecoder(cdc *wire.Codec) func([]byte) (sdk.Tx, sdk.Error)

JSON decode MsgSend.

func IsValidDec

func IsValidDec(input []byte, sep byte, precision int64) (bool, error)

func IsValidDenom

func IsValidDenom(denom string) bool

func NewDecFromStr

func NewDecFromStr(str string) (d Dec, err Error)

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

func RemoveSeparator(input []byte, sep byte) []byte

func SeparatorIndex

func SeparatorIndex(input []byte, sep byte) (int64, error)

func ToBig

func ToBig(input []byte, sep byte, precision int64) []byte

func TrimZero

func TrimZero(input []byte, sep byte) []byte

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

func (ABCICodeType) IsOK

func (code ABCICodeType) IsOK() bool

IsOK - is everything okay?

type Account

type Account interface {
	GetCoins() Coins
	SetCoins(Coins)
}

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

func NewAsset

func NewAsset(uuid string, creator sdk.Address, hash []byte, status bool, fee int64) Asset

Asset defines basic information of Assets in ShareRing Platform

func (Asset) String

func (a Asset) String() string

type BasicSig

type BasicSig struct {
	PubKey    `json:"pub_key"`
	Signature `json:"signature"`
}

Signature without Nonce

func NewBasicSig

func NewBasicSig(key PubKey, sig Signature) BasicSig

func (BasicSig) String

func (sig BasicSig) String() string

func (BasicSig) Verify

func (sig BasicSig) Verify(msg []byte) bool

type BasicTx

type BasicTx struct {
	sdk.Msg   `json:"message"`
	Signature BasicSig `json:"signature"`
}

Simple tx to wrap the Msg.

func NewBasicTx

func NewBasicTx(msg sdk.Msg, sig BasicSig) BasicTx

func (BasicTx) GetMsg

func (tx BasicTx) GetMsg() sdk.Msg

GetMsg returns the message of this transaction

func (BasicTx) GetMsgs

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

GetMsgs returns multiple messages

func (BasicTx) GetSignBytes

func (tx BasicTx) GetSignBytes() []byte

GetSignBytes returns Bytes to be signed

func (BasicTx) GetSignature

func (tx BasicTx) GetSignature() SHRSignature

GetSignature returns the signature with this transaction

func (BasicTx) VerifySignature

func (tx BasicTx) VerifySignature() bool

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

func NewBooking(_bid string, _acc sdk.Address, _uuid string, _dur int64, _isCompleted bool) Booking

func (Booking) String

func (b Booking) String() string

type CodeType

type CodeType uint16

CodeType - code identifier within codespace

type CodespaceType

type CodespaceType uint16

CodespaceType - codespace identifier

type Coin

type Coin struct {
	Denom  string `json:"denom"`
	Amount Dec    `json:"amount"`
}

func NewCoin

func NewCoin(denom string, amount int64) Coin

func NewCoinFromDec

func NewCoinFromDec(denom string, amount Dec) Coin

func NewDefaultCoin

func NewDefaultCoin() Coin

func NewPOSCoin

func NewPOSCoin(amount int64) Coin

func NewPOSCoinFromDec

func NewPOSCoinFromDec(amount Dec) Coin

func NewZeroPOSCoin

func NewZeroPOSCoin() Coin

func (Coin) Abs

func (c Coin) Abs() Coin

func (Coin) Equal

func (c Coin) Equal(o Coin) bool

func (Coin) GT

func (c Coin) GT(o Coin) bool

func (Coin) GTE

func (c Coin) GTE(o Coin) bool

func (Coin) HasDenom

func (coin Coin) HasDenom(denom string) bool

func (Coin) HasValidDenom

func (coin Coin) HasValidDenom() bool

func (Coin) IsNil

func (c Coin) IsNil() bool

func (Coin) IsNotNegative

func (c Coin) IsNotNegative() bool

func (Coin) IsPositive

func (c Coin) IsPositive() bool

func (Coin) IsSameDenom

func (coin Coin) IsSameDenom(other Coin) bool

func (Coin) IsZero

func (c Coin) IsZero() bool

func (Coin) LT

func (c Coin) LT(o Coin) bool

func (Coin) LTE

func (c Coin) LTE(o Coin) bool

func (Coin) Minus

func (coin Coin) Minus(other Coin) Coin

func (Coin) Mul

func (coin Coin) Mul(factor Dec) Coin

func (Coin) Neg

func (c Coin) Neg() Coin

func (Coin) Plus

func (coin Coin) Plus(other Coin) Coin

func (Coin) Quo

func (coin Coin) Quo(factor Dec) Coin

func (Coin) String

func (coin Coin) String() string

type Coins

type Coins []Coin

func NewDefaultCoins

func NewDefaultCoins() Coins

func (Coins) Abs

func (coins Coins) Abs() Coins

func (Coins) AllCoins

func (coins Coins) AllCoins(method string) bool

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

func (c Coins) Equal(o Coin) bool

func (Coins) GT

func (c Coins) GT(o Coin) bool

func (Coins) GTE

func (c Coins) GTE(o Coin) bool

func (Coins) GetCoin

func (coins Coins) GetCoin(denom string) Coin

GetCoin - Get a single coin from coin

func (Coins) GetCoins

func (coins Coins) GetCoins() Coins

func (Coins) HasCoin

func (coins Coins) HasCoin(o Coin, method string) bool

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 Coins) HasValidDenoms() bool

func (Coins) IsNil

func (c Coins) IsNil() bool

func (Coins) IsNotNegative

func (c Coins) IsNotNegative() bool

func (Coins) IsPositive

func (c Coins) IsPositive() bool

func (Coins) IsZero

func (c Coins) IsZero() bool

func (Coins) LT

func (c Coins) LT(o Coin) bool

func (Coins) LTE

func (c Coins) LTE(o Coin) bool

func (*Coins) Minus

func (coins *Coins) Minus(other Coin) Coins

Minus - ensure *coins* and *co* have valid denoms

func (Coins) MinusMany

func (coins Coins) MinusMany(coinsB Coins) Coins

Minus subtracts a set of coins from another (adds the inverse)

func (Coins) Negative

func (coins Coins) Negative() Coins

Negative returns a set of coins with all amount negative

func (*Coins) Plus

func (coins *Coins) Plus(other Coin) Coins

func (Coins) PlusMany

func (coins Coins) PlusMany(coinsB Coins) Coins

Plus combines two sets of coins CONTRACT: Plus will never return Coins where one Coin has a 0 amount.

func (*Coins) SetCoins

func (coins *Coins) SetCoins(co Coins)

func (Coins) String

func (coins Coins) String() string

type Dec

type Dec struct {
	*big.Int `json:"int"`
}

NOTE: never use new(Dec) or else we will panic unmarshalling into the nil embedded big.Int

func MaxDec

func MaxDec(d1, d2 Dec) Dec

maximum decimal between two

func MinDec

func MinDec(d1, d2 Dec) Dec

minimum decimal between two

func NewDec

func NewDec(i int64) Dec

create a new Dec from integer assuming whole number

func NewDecFromBigInt

func NewDecFromBigInt(i *big.Int) Dec

create a new Dec from big integer assuming whole numbers CONTRACT: prec <= Precision

func NewDecFromBigIntWithPrec

func NewDecFromBigIntWithPrec(i *big.Int, prec int64) Dec

create a new Dec from big integer assuming whole numbers CONTRACT: prec <= Precision

func NewDecFromInt

func NewDecFromInt(i Int) Dec

create a new Dec from big integer assuming whole numbers CONTRACT: prec <= Precision

func NewDecFromIntWithPrec

func NewDecFromIntWithPrec(i Int, prec int64) Dec

create a new Dec from big integer with decimal place at prec CONTRACT: prec <= Precision

func NewDecWithPrec

func NewDecWithPrec(i, prec int64) Dec

create a new Dec from integer with decimal place at prec CONTRACT: prec <= Precision

func OneDec

func OneDec() Dec

func ZeroDec

func ZeroDec() Dec

nolint - common values

func (Dec) Abs

func (d Dec) Abs() Dec

func (Dec) Add

func (d Dec) Add(d2 Dec) Dec

addition

func (Dec) Equal

func (d Dec) Equal(d2 Dec) bool

func (Dec) GT

func (d Dec) GT(d2 Dec) bool

func (Dec) GTE

func (d Dec) GTE(d2 Dec) bool

func (Dec) IsNil

func (d Dec) IsNil() bool

______________________________________________________________________________________________ nolint

func (Dec) IsNotNegative

func (d Dec) IsNotNegative() bool

func (Dec) IsPositive

func (d Dec) IsPositive() bool

func (Dec) IsZero

func (d Dec) IsZero() bool

func (Dec) LT

func (d Dec) LT(d2 Dec) bool

func (Dec) LTE

func (d Dec) LTE(d2 Dec) bool

func (Dec) MarshalAmino

func (d Dec) MarshalAmino() (string, error)

wraps d.MarshalText()

func (Dec) MarshalJSON

func (d Dec) MarshalJSON() ([]byte, error)

MarshalJSON defines custom encoding scheme

func (Dec) Mul

func (d Dec) Mul(d2 Dec) Dec

multiplication

func (Dec) MulInt

func (d Dec) MulInt(i Int) Dec

multiplication

func (Dec) Neg

func (d Dec) Neg() Dec

func (Dec) Quo

func (d Dec) Quo(d2 Dec) Dec

quotient

func (Dec) RoundInt

func (d Dec) RoundInt() Int

RoundInt round the decimal using bankers rounding

func (Dec) RoundInt64

func (d Dec) RoundInt64() int64

RoundInt64 rounds the decimal using bankers rounding

func (Dec) String

func (d Dec) String() string

String - replace cosmos String() as Cosmos doesn't discard unneccessary trailling zero

func (Dec) Sub

func (d Dec) Sub(d2 Dec) Dec

subtraction

func (Dec) ToLeftPadded

func (d Dec) ToLeftPadded(totalDigits int8) string

TODO panic if negative or if totalDigits < len(initStr)??? evaluate as an integer and return left padded string

func (Dec) ToLeftPaddedWithDecimals

func (d Dec) ToLeftPaddedWithDecimals(totalDigits int8) string

TODO panic if negative or if totalDigits < len(initStr)??? evaluate as an integer and return left padded string

func (Dec) TruncateInt

func (d Dec) TruncateInt() Int

TruncateInt truncates the decimals from the number and returns an Int

func (Dec) TruncateInt64

func (d Dec) TruncateInt64() int64

TruncateInt64 truncates the decimals from the number and returns an int64

func (*Dec) UnmarshalAmino

func (d *Dec) UnmarshalAmino(text string) (err error)

requires a valid JSON string - strings quotes and calls UnmarshalText

func (*Dec) UnmarshalJSON

func (d *Dec) UnmarshalJSON(bz []byte) error

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
	GetBondShares() Dec        // amount of validator's shares
}

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 ErrInsufficientCoins(msg string) Error

func ErrInsufficientFunds

func ErrInsufficientFunds(msg string) Error

func ErrInternal

func ErrInternal(msg string) Error

nolint

func ErrInvalidAddress

func ErrInvalidAddress(msg string) Error

func ErrInvalidCoins

func ErrInvalidCoins(msg string) Error

func ErrInvalidPubKey

func ErrInvalidPubKey(msg string) Error

func ErrInvalidSequence

func ErrInvalidSequence(msg string) Error

func ErrMemoTooLarge

func ErrMemoTooLarge(msg string) Error

func ErrOutOfGas

func ErrOutOfGas(msg string) Error

func ErrTxDecode

func ErrTxDecode(msg string) Error

func ErrUnauthorized

func ErrUnauthorized(msg string) Error

func ErrUnknownAddress

func ErrUnknownAddress(msg string) Error

func ErrUnknownRequest

func ErrUnknownRequest(msg string) Error

func NewError

func NewError(codespace CodespaceType, code CodeType, msg string) Error

NewError - create an error

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 MinInt

func MinInt(i1, i2 Int) Int

Return the minimum of the ints

func NewInt

func NewInt(n int64) Int

NewInt constructs Int from int64

func NewIntFromBigInt

func NewIntFromBigInt(i *big.Int) Int

NewIntFromBigInt constructs Int from big.Int

func NewIntFromString

func NewIntFromString(s string) (res Int, ok bool)

NewIntFromString constructs Int from string

func NewIntWithDecimal

func NewIntWithDecimal(n int64, dec int) Int

NewIntWithDecimal constructs Int with decimal Result value is n*10^dec

func OneInt

func OneInt() Int

OneInt returns Int value with one

func ZeroInt

func ZeroInt() Int

ZeroInt returns Int value with zero

func (Int) Add

func (i Int) Add(i2 Int) (res Int)

Add adds Int from another

func (Int) AddRaw

func (i Int) AddRaw(i2 int64) Int

AddRaw adds int64 to Int

func (Int) BigInt

func (i Int) BigInt() *big.Int

BigInt converts Int to big.Int

func (Int) Div

func (i Int) Div(i2 Int) (res Int)

Div divides Int with Int

func (Int) DivRaw

func (i Int) DivRaw(i2 int64) Int

DivRaw divides Int with int64

func (Int) Equal

func (i Int) Equal(i2 Int) bool

Equal compares two Ints

func (Int) GT

func (i Int) GT(i2 Int) bool

GT returns true if first Int is greater than second

func (Int) Int64

func (i Int) Int64() int64

Int64 converts Int to int64 Panics if the value is out of range

func (Int) IsInt64

func (i Int) IsInt64() bool

IsInt64 returns true if Int64() not panics

func (Int) IsZero

func (i Int) IsZero() bool

IsZero returns true if Int is zero

func (Int) LT

func (i Int) LT(i2 Int) bool

LT returns true if first Int is lesser than second

func (Int) MarshalAmino

func (i Int) MarshalAmino() (string, error)

MarshalAmino defines custom encoding scheme

func (Int) MarshalJSON

func (i Int) MarshalJSON() ([]byte, error)

MarshalJSON defines custom encoding scheme

func (Int) Mod

func (i Int) Mod(i2 Int) Int

Mod returns remainder after dividing with Int

func (Int) ModRaw

func (i Int) ModRaw(i2 int64) Int

ModRaw returns remainder after dividing with int64

func (Int) Mul

func (i Int) Mul(i2 Int) (res Int)

Mul multiples two Ints

func (Int) MulRaw

func (i Int) MulRaw(i2 int64) Int

MulRaw multipies Int and int64

func (Int) Neg

func (i Int) Neg() (res Int)

Neg negates Int

func (Int) Sign

func (i Int) Sign() int

Sign returns sign of Int

func (Int) String

func (i Int) String() string

Human readable string

func (Int) Sub

func (i Int) Sub(i2 Int) (res Int)

Sub subtracts Int from another

func (Int) SubRaw

func (i Int) SubRaw(i2 int64) Int

SubRaw subtracts int64 from Int

func (*Int) UnmarshalAmino

func (i *Int) UnmarshalAmino(text string) error

UnmarshalAmino defines custom decoding scheme

func (*Int) UnmarshalJSON

func (i *Int) UnmarshalJSON(bz []byte) error

UnmarshalJSON defines custom decoding scheme

type PrivKey

type PrivKey interface {
	Sign(sdk.Msg) Signature
	SignWithNonce(sdk.Msg, int64) Signature
	String() string
}

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

func (privKey PrivKeySecp256k1) Sign(msg sdk.Msg) Signature

func (PrivKeySecp256k1) SignWithNonce

func (privKey PrivKeySecp256k1) SignWithNonce(msg sdk.Msg, nonce int64) Signature

func (PrivKeySecp256k1) String

func (privKey PrivKeySecp256k1) String() string

type PubKey

type PubKey interface {
	Address() sdk.Address
	Bytes() []byte
	VerifyBytes(msg []byte, sig Signature) bool
	Equals(PubKey) bool
	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

type QueryTx struct {
	sdk.Msg `json:"message"`
}

func NewQueryTx

func NewQueryTx(msg sdk.Msg) QueryTx

func (QueryTx) GetMsg

func (tx QueryTx) GetMsg() sdk.Msg

func (QueryTx) GetMsgs

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

func (QueryTx) GetSignBytes

func (tx QueryTx) GetSignBytes() []byte

func (QueryTx) GetSignature

func (tx QueryTx) GetSignature() SHRSignature

func (QueryTx) VerifySignature

func (tx QueryTx) VerifySignature() bool

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.

func (Result) IsOK

func (res Result) IsOK() bool

TODO: In the future, more codes may be OK.

type SHRSignature

type SHRSignature interface {
	String() string
	Verify([]byte) bool
}

type SHRTx

type SHRTx interface {
	sdk.Tx
	GetMsg() sdk.Msg
	GetSignature() SHRSignature
	VerifySignature() bool
	GetSignBytes() []byte
}

----------------------------------------------------------------- Tx Interface

type Signature

type Signature interface {
	Bytes() []byte
	IsZero() bool
	Equals(Signature) bool
}

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 MinUint

func MinUint(i1, i2 Uint) Uint

Return the minimum of the Uints

func NewUint

func NewUint(n uint64) Uint

NewUint constructs Uint from int64

func NewUintFromBigInt

func NewUintFromBigInt(i *big.Int) Uint

NewUintFromBigUint constructs Uint from big.Uint

func NewUintFromString

func NewUintFromString(s string) (res Uint, ok bool)

NewUintFromString constructs Uint from string

func NewUintWithDecimal

func NewUintWithDecimal(n uint64, dec int) Uint

NewUintWithDecimal constructs Uint with decimal Result value is n*10^dec

func OneUint

func OneUint() Uint

OneUint returns Uint value with one

func ZeroUint

func ZeroUint() Uint

ZeroUint returns Uint value with zero

func (Uint) Add

func (i Uint) Add(i2 Uint) (res Uint)

Add adds Uint from another

func (Uint) AddRaw

func (i Uint) AddRaw(i2 uint64) Uint

AddRaw adds uint64 to Uint

func (Uint) BigInt

func (i Uint) BigInt() *big.Int

BigInt converts Uint to big.Unt

func (Uint) Div

func (i Uint) Div(i2 Uint) (res Uint)

Div divides Uint with Uint

func (Uint) DivRaw

func (i Uint) DivRaw(i2 uint64) Uint

Div divides Uint with uint64

func (Uint) Equal

func (i Uint) Equal(i2 Uint) bool

Equal compares two Uints

func (Uint) GT

func (i Uint) GT(i2 Uint) bool

GT returns true if first Uint is greater than second

func (Uint) IsUint64

func (i Uint) IsUint64() bool

IsUint64 returns true if Uint64() not panics

func (Uint) IsZero

func (i Uint) IsZero() bool

IsZero returns true if Uint is zero

func (Uint) LT

func (i Uint) LT(i2 Uint) bool

LT returns true if first Uint is lesser than second

func (Uint) MarshalAmino

func (i Uint) MarshalAmino() (string, error)

MarshalAmino defines custom encoding scheme

func (Uint) MarshalJSON

func (i Uint) MarshalJSON() ([]byte, error)

MarshalJSON defines custom encoding scheme

func (Uint) Mod

func (i Uint) Mod(i2 Uint) Uint

Mod returns remainder after dividing with Uint

func (Uint) ModRaw

func (i Uint) ModRaw(i2 uint64) Uint

ModRaw returns remainder after dividing with uint64

func (Uint) Mul

func (i Uint) Mul(i2 Uint) (res Uint)

Mul multiples two Uints

func (Uint) MulRaw

func (i Uint) MulRaw(i2 uint64) Uint

MulRaw multipies Uint and uint64

func (Uint) Sign

func (i Uint) Sign() int

Sign returns sign of Uint

func (Uint) String

func (i Uint) String() string

Human readable string

func (Uint) Sub

func (i Uint) Sub(i2 Uint) (res Uint)

Sub subtracts Uint from another

func (Uint) SubRaw

func (i Uint) SubRaw(i2 uint64) Uint

SubRaw subtracts uint64 from Uint

func (Uint) Uint64

func (i Uint) Uint64() uint64

Uint64 converts Uint to uint64 Panics if the value is out of range

func (*Uint) UnmarshalAmino

func (i *Uint) UnmarshalAmino(text string) error

UnmarshalAmino defines custom decoding scheme

func (*Uint) UnmarshalJSON

func (i *Uint) UnmarshalJSON(bz []byte) error

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
	GetDelegatorShares() Dec // Total out standing delegator shares
	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

Jump to

Keyboard shortcuts

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