types

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: Apache-2.0 Imports: 4 Imported by: 453

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllBalancesQuery

type AllBalancesQuery struct {
	Address string `json:"address"`
}

type AllBalancesResponse

type AllBalancesResponse struct {
	Amount Coins `json:"amount"`
}

AllBalancesResponse is the expected response to AllBalancesQuery

type AllDelegationsQuery

type AllDelegationsQuery struct {
	Delegator string `json:"delegator"`
}

type AllDelegationsResponse

type AllDelegationsResponse struct {
	Delegations Delegations `json:"delegations"`
}

AllDelegationsResponse is the expected response to AllDelegationsQuery

type BalanceQuery

type BalanceQuery struct {
	Address string `json:"address"`
	Denom   string `json:"denom"`
}

type BalanceResponse

type BalanceResponse struct {
	Amount Coin `json:"amount"`
}

BalanceResponse is the expected response to BalanceQuery

type BankMsg

type BankMsg struct {
	Send *SendMsg `json:"send,omitempty"`
}

type BankQuery

type BankQuery struct {
	Balance     *BalanceQuery     `json:"balance,omitempty"`
	AllBalances *AllBalancesQuery `json:"all_balances,omitempty"`
}

type BlockInfo

type BlockInfo struct {
	// block height this transaction is executed
	Height uint64 `json:"height"`
	// time in seconds since unix epoch (since CosmWasm 0.3)
	Time uint64 `json:"time"`
	// Nanoseconds of the block time (since CosmWasm 0.11)
	TimeNanos uint64 `json:"time_nanos"`
	ChainID   string `json:"chain_id"`
}

type BondedDenomResponse

type BondedDenomResponse struct {
	Denom string `json:"denom"`
}

type CanonicalAddress

type CanonicalAddress = []byte

CanonicalAddress uses standard base64 encoding, just use it as a label for developers

type Coin

type Coin struct {
	Denom  string `json:"denom"`  // type, eg. "ATOM"
	Amount string `json:"amount"` // string encoing of decimal value, eg. "12.3456"
}

Coin is a string representation of the sdk.Coin type (more portable than sdk.Int)

func NewCoin

func NewCoin(amount uint64, denom string) Coin

type Coins

type Coins []Coin

Coins handles properly serializing empty amounts

func (Coins) MarshalJSON

func (c Coins) MarshalJSON() ([]byte, error)

MarshalJSON ensures that we get [] for empty arrays

func (*Coins) UnmarshalJSON

func (c *Coins) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that we get [] for empty arrays

type ContractInfo

type ContractInfo struct {
	// binary encoding of sdk.AccAddress of the contract, to be used when sending messages
	Address HumanAddress `json:"address"`
}

type CosmosMsg

type CosmosMsg struct {
	Bank    *BankMsg        `json:"bank,omitempty"`
	Custom  json.RawMessage `json:"custom,omitempty"`
	Staking *StakingMsg     `json:"staking,omitempty"`
	Wasm    *WasmMsg        `json:"wasm,omitempty"`
}

CosmosMsg is an rust enum and only (exactly) one of the fields should be set Should we do a cleaner approach in Go? (type/data?)

type DelegateMsg

type DelegateMsg struct {
	Validator string `json:"validator"`
	Amount    Coin   `json:"amount"`
}

type Delegation

type Delegation struct {
	Delegator string `json:"delegator"`
	Validator string `json:"validator"`
	Amount    Coin   `json:"amount"`
}

type DelegationQuery

type DelegationQuery struct {
	Delegator string `json:"delegator"`
	Validator string `json:"validator"`
}

type DelegationResponse

type DelegationResponse struct {
	Delegation *FullDelegation `json:"delegation,omitempty"`
}

DelegationResponse is the expected response to DelegationsQuery

type Delegations

type Delegations []Delegation

func (Delegations) MarshalJSON

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

MarshalJSON ensures that we get [] for empty arrays

func (*Delegations) UnmarshalJSON

func (d *Delegations) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that we get [] for empty arrays

type Env

type Env struct {
	Block    BlockInfo    `json:"block"`
	Contract ContractInfo `json:"contract"`
}

Env defines the state of the blockchain environment this contract is running in. This must contain only trusted data - nothing from the Tx itself that has not been verfied (like Signer).

Env are json encoded to a byte slice before passing to the wasm contract.

type EventAttribute

type EventAttribute struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

EventAttribute

type ExecuteMsg

type ExecuteMsg struct {
	// ContractAddr is the sdk.AccAddress of the contract, which uniquely defines
	// the contract ID and instance ID. The sdk module should maintain a reverse lookup table.
	ContractAddr string `json:"contract_addr"`
	// Msg is assumed to be a json-encoded message, which will be passed directly
	// as `userMsg` when calling `Handle` on the above-defined contract
	Msg []byte `json:"msg"`
	// Send is an optional amount of coins this contract sends to the called contract
	Send Coins `json:"send"`
}

ExecuteMsg is used to call another defined contract on this chain. The calling contract requires the callee to be defined beforehand, and the address should have been defined in initialization. And we assume the developer tested the ABIs and coded them together.

Since a contract is immutable once it is deployed, we don't need to transform this. If it was properly coded and worked once, it will continue to work throughout upgrades.

type FullDelegation

type FullDelegation struct {
	Delegator          string `json:"delegator"`
	Validator          string `json:"validator"`
	Amount             Coin   `json:"amount"`
	AccumulatedRewards Coins  `json:"accumulated_rewards"`
	CanRedelegate      Coin   `json:"can_redelegate"`
}

type HandleResponse

type HandleResponse struct {
	// Messages comes directly from the contract and is it's request for action
	Messages []CosmosMsg `json:"messages"`
	// base64-encoded bytes to return as ABCI.Data field
	Data []byte `json:"data"`
	// attributes for a log event to return over abci interface
	Attributes []EventAttribute `json:"attributes"`
}

HandleResponse defines the return value on a successful handle

type HandleResult

type HandleResult struct {
	Ok  *HandleResponse `json:"ok,omitempty"`
	Err string          `json:"error,omitempty"`
}

HandleResult is the raw response from the handle call. This is mirrors Rust's ContractResult<HandleResponse>.

type HumanAddress

type HumanAddress = string

HumanAddress is a printable (typically bech32 encoded) address string. Just use it as a label for developers.

type InitResponse

type InitResponse struct {
	// Messages comes directly from the contract and is it's request for action
	Messages []CosmosMsg `json:"messages"`
	// attributes for a log event to return over abci interface
	Attributes []EventAttribute `json:"attributes"`
}

InitResponse defines the return value on a successful handle

type InitResult

type InitResult struct {
	Ok  *InitResponse `json:"ok,omitempty"`
	Err string        `json:"error,omitempty"`
}

InitResult is the raw response from the handle call. This is mirrors Rust's ContractResult<InitResponse>.

type InstantiateMsg

type InstantiateMsg struct {
	// CodeID is the reference to the wasm byte code as used by the Cosmos-SDK
	CodeID uint64 `json:"code_id"`
	// Msg is assumed to be a json-encoded message, which will be passed directly
	// as `userMsg` when calling `Handle` on the above-defined contract
	Msg []byte `json:"msg"`
	// Send is an optional amount of coins this contract sends to the called contract
	Send Coins `json:"send"`
}

type InvalidRequest

type InvalidRequest struct {
	Err     string `json:"error"`
	Request []byte `json:"request"`
}

func (InvalidRequest) Error

func (e InvalidRequest) Error() string

type InvalidResponse

type InvalidResponse struct {
	Err      string `json:"error"`
	Response []byte `json:"response"`
}

func (InvalidResponse) Error

func (e InvalidResponse) Error() string

type MessageInfo

type MessageInfo struct {
	// binary encoding of sdk.AccAddress executing the contract
	Sender HumanAddress `json:"sender"`
	// amount of funds send to the contract along with this message
	SentFunds Coins `json:"sent_funds"`
}

type MigrateResponse

type MigrateResponse struct {
	// Messages comes directly from the contract and is it's request for action
	Messages []CosmosMsg `json:"messages"`
	// base64-encoded bytes to return as ABCI.Data field
	Data []byte `json:"data"`
	// attributes for a log event to return over abci interface
	Attributes []EventAttribute `json:"attributes"`
}

MigrateResponse defines the return value on a successful handle

type MigrateResult

type MigrateResult struct {
	Ok  *MigrateResponse `json:"ok,omitempty"`
	Err string           `json:"error,omitempty"`
}

MigrateResult is the raw response from the migrate call. This is mirrors Rust's ContractResult<MigrateResponse>.

type NoSuchContract

type NoSuchContract struct {
	Addr string `json:"addr,omitempty"`
}

func (NoSuchContract) Error

func (e NoSuchContract) Error() string

type OutOfGasError

type OutOfGasError struct{}

func (OutOfGasError) Error

func (o OutOfGasError) Error() string

type Querier

type Querier interface {
	Query(request QueryRequest, gasLimit uint64) ([]byte, error)
	GasConsumed() uint64
}

type QuerierResult

type QuerierResult struct {
	Ok  *QueryResponse `json:"ok,omitempty"`
	Err *SystemError   `json:"error,omitempty"`
}

This is a 2-level result

func RustQuery

func RustQuery(querier Querier, binRequest []byte, gasLimit uint64) QuerierResult

this is a thin wrapper around the desired Go API to give us types closer to Rust FFI

func ToQuerierResult

func ToQuerierResult(response []byte, err error) QuerierResult

type QueryRequest

type QueryRequest struct {
	Bank    *BankQuery      `json:"bank,omitempty"`
	Custom  json.RawMessage `json:"custom,omitempty"`
	Staking *StakingQuery   `json:"staking,omitempty"`
	Wasm    *WasmQuery      `json:"wasm,omitempty"`
}

QueryRequest is an rust enum and only (exactly) one of the fields should be set Should we do a cleaner approach in Go? (type/data?)

type QueryResponse

type QueryResponse queryResponseImpl

QueryResponse is the Go counterpart of `ContractResult<Binary>`. The JSON annotations are used for deserializing directly. There is a custom serializer below.

func (QueryResponse) MarshalJSON

func (q QueryResponse) MarshalJSON() ([]byte, error)

A custom serializer that allows us to map QueryResponse instances to the Rust enum `ContractResult<Binary>`

type RawQuery

type RawQuery struct {
	ContractAddr string `json:"contract_addr"`
	Key          []byte `json:"key"`
}

RawQuery response is raw bytes ([]byte)

type RedelegateMsg

type RedelegateMsg struct {
	SrcValidator string `json:"src_validator"`
	DstValidator string `json:"dst_validator"`
	Amount       Coin   `json:"amount"`
}

type SendMsg

type SendMsg struct {
	FromAddress string `json:"from_address"`
	ToAddress   string `json:"to_address"`
	Amount      Coins  `json:"amount"`
}

SendMsg contains instructions for a Cosmos-SDK/SendMsg It has a fixed interface here and should be converted into the proper SDK format before dispatching

type SmartQuery

type SmartQuery struct {
	ContractAddr string `json:"contract_addr"`
	Msg          []byte `json:"msg"`
}

SmartQuery respone is raw bytes ([]byte)

type StakingMsg

type StakingMsg struct {
	Delegate   *DelegateMsg   `json:"delegate,omitempty"`
	Undelegate *UndelegateMsg `json:"undelegate,omitempty"`
	Redelegate *RedelegateMsg `json:"redelegate,omitempty"`
	Withdraw   *WithdrawMsg   `json:"withdraw,omitempty"`
}

type StakingQuery

type StakingQuery struct {
	Validators     *ValidatorsQuery     `json:"validators,omitempty"`
	AllDelegations *AllDelegationsQuery `json:"all_delegations,omitempty"`
	Delegation     *DelegationQuery     `json:"delegation,omitempty"`
	BondedDenom    *struct{}            `json:"bonded_denom,omitempty"`
}

type SystemError

type SystemError struct {
	InvalidRequest     *InvalidRequest     `json:"invalid_request,omitempty"`
	InvalidResponse    *InvalidResponse    `json:"invalid_response,omitempty"`
	NoSuchContract     *NoSuchContract     `json:"no_such_contract,omitempty"`
	Unknown            *Unknown            `json:"unknown,omitempty"`
	UnsupportedRequest *UnsupportedRequest `json:"unsupported_request,omitempty"`
}

SystemError captures all errors returned from the Rust code as SystemError. Exactly one of the fields should be set.

func ToSystemError

func ToSystemError(err error) *SystemError

ToSystemError will try to convert the given error to an SystemError. This is important to returning any Go error back to Rust.

If it is already StdError, return self. If it is an error, which could be a sub-field of StdError, embed it. If it is anything else, **return nil**

This may return nil on an unknown error, whereas ToStdError will always create a valid error type.

func (SystemError) Error

func (a SystemError) Error() string

type UndelegateMsg

type UndelegateMsg struct {
	Validator string `json:"validator"`
	Amount    Coin   `json:"amount"`
}

type Unknown

type Unknown struct{}

func (Unknown) Error

func (e Unknown) Error() string

type UnsupportedRequest

type UnsupportedRequest struct {
	Kind string `json:"kind,omitempty"`
}

func (UnsupportedRequest) Error

func (e UnsupportedRequest) Error() string

type Validator

type Validator struct {
	Address string `json:"address"`
	// decimal string, eg "0.02"
	Commission string `json:"commission"`
	// decimal string, eg "0.02"
	MaxCommission string `json:"max_commission"`
	// decimal string, eg "0.02"
	MaxChangeRate string `json:"max_change_rate"`
}

type Validators

type Validators []Validator

TODO: Validators must JSON encode empty array as []

func (Validators) MarshalJSON

func (v Validators) MarshalJSON() ([]byte, error)

MarshalJSON ensures that we get [] for empty arrays

func (*Validators) UnmarshalJSON

func (v *Validators) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that we get [] for empty arrays

type ValidatorsQuery

type ValidatorsQuery struct{}

type ValidatorsResponse

type ValidatorsResponse struct {
	Validators Validators `json:"validators"`
}

ValidatorsResponse is the expected response to ValidatorsQuery

type WasmMsg

type WasmMsg struct {
	Execute     *ExecuteMsg     `json:"execute,omitempty"`
	Instantiate *InstantiateMsg `json:"instantiate,omitempty"`
}

type WasmQuery

type WasmQuery struct {
	Smart *SmartQuery `json:"smart,omitempty"`
	Raw   *RawQuery   `json:"raw,omitempty"`
}

type WithdrawMsg

type WithdrawMsg struct {
	Validator string `json:"validator"`
	// this is optional
	Recipient string `json:"recipient,omitempty"`
}

Jump to

Keyboard shortcuts

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