api

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TagAction       = "action"
	TagCategory     = "category"
	TagSender       = "sender"
	TagSrcValidator = "source-validator"
	TagDstValidator = "destination-validator"
	TagDelegator    = "delegator"
)

common tags

Functions

func ParseCoin

func ParseCoin(coinStr string) (minCoin sdk.Coin, err error)

func ParseCoins

func ParseCoins(coinsStr string) (coins sdk.Coins, err error)

Types

type ABCIMessageLog

type ABCIMessageLog struct {
	MsgIndex uint16 `json:"msg_index"`
	Success  bool   `json:"success"`
	Log      string `json:"log"`
}

ABCIMessageLog defines a structure containing an indexed tx ABCI message log.

type ABCIMessageLogs

type ABCIMessageLogs []ABCIMessageLog

ABCIMessageLogs represents a slice of ABCIMessageLog.

func ParseABCILogs

func ParseABCILogs(logs string) (res ABCIMessageLogs, err error)

ParseABCILogs attempts to parse a stringified ABCI tx log into a slice of ABCIMessageLog types. It returns an error upon JSON decoding failure.

func (ABCIMessageLogs) String

func (logs ABCIMessageLogs) String() (str string)

String implements the fmt.Stringer interface for the ABCIMessageLogs type.

type AddNewKey

type AddNewKey struct {
	Name     string `json:"name"`
	Password string `json:"password"`
	Mnemonic string `json:"mnemonic,omitempty"`
	Account  int    `json:"account,string,omitempty"`
	Index    int    `json:"index,string,omitempty"`
}

AddNewKey is the necessary data for adding a new key

func (AddNewKey) Marshal

func (ak AddNewKey) Marshal() []byte

type BankSendBody

type BankSendBody struct {
	Sender        sdk.AccAddress `json:"sender"`
	Reciever      sdk.AccAddress `json:"reciever"`
	Amount        string         `json:"amount"`
	ChainID       string         `json:"chain_id"`
	Memo          string         `json:"memo,omitempty"`
	Fees          string         `json:"fees,omitempty"`
	GasAdjustment string         `json:"gas_adjustment,omitempty"`
}

BankSendBody contains the necessary data to make a send transaction

func (BankSendBody) Marshal

func (sb BankSendBody) Marshal() []byte

type DeleteKeyBody

type DeleteKeyBody struct {
	Password string `json:"password"`
}

DeleteKeyBody request

func (DeleteKeyBody) Marshal

func (u DeleteKeyBody) Marshal() []byte

type Result

type Result struct {
	// Code is the response code, is stored back on the chain.
	Code sdk.CodeType

	// Codespace is the string referring to the domain of an error
	Codespace sdk.CodespaceType

	// Data is any data returned from the app.
	// Data has to be length prefixed in order to separate
	// results from multiple msgs executions
	Data []byte

	// Log contains the txs log 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

	// Tags are used for transaction indexing and pubsub.
	Tags Tags
}

Result is the union of ResponseFormat and ResponseCheckTx.

func (Result) IsOK

func (res Result) IsOK() bool

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

type SearchTxsResult

type SearchTxsResult struct {
	TotalCount int          `json:"total_count"` // Count of all txs
	Count      int          `json:"count"`       // Count of txs in current page
	PageNumber int          `json:"page_number"` // Index of current page, start from 1
	PageTotal  int          `json:"page_total"`  // Count of total pages
	Limit      int          `json:"limit"`       // Max count txs per page
	Txs        []TxResponse `json:"txs"`         // List of txs in current page
}

SearchTxsResult defines a structure for querying txs pageable

func NewSearchTxsResult

func NewSearchTxsResult(totalCount, count, page, limit int, txs []TxResponse) SearchTxsResult

type Server

type Server struct {
	Port   int    `json:"port"`
	KeyDir string `json:"key_dir"`
	Node   string `json:"node"`

	Version string `yaml:"version,omitempty"`
	Commit  string `yaml:"commit,omitempty"`
	Branch  string `yaml:"branch,omitempty"`
}

Server represents the API server

func (*Server) BankSend

func (s *Server) BankSend(w http.ResponseWriter, r *http.Request)

BankSend handles the /tx/bank/send route

func (*Server) Broadcast

func (s *Server) Broadcast(w http.ResponseWriter, r *http.Request)

func (*Server) DeleteKey

func (s *Server) DeleteKey(w http.ResponseWriter, r *http.Request)

DeleteKey is the handler for the DELETE /keys/{name}

func (*Server) GetKey

func (s *Server) GetKey(w http.ResponseWriter, r *http.Request)

GetKey is the handler for the GET /keys/{name}

func (*Server) GetKeys

func (s *Server) GetKeys(w http.ResponseWriter, r *http.Request)

GetKeys is the handler for the GET /keys

func (*Server) PostKeys

func (s *Server) PostKeys(w http.ResponseWriter, r *http.Request)

PostKeys is the handler for the POST /keys

func (*Server) PutKey

func (s *Server) PutKey(w http.ResponseWriter, r *http.Request)

PutKey is the handler for the PUT /keys/{name}

func (*Server) Router

func (s *Server) Router() *mux.Router

Router returns the router

func (*Server) Sign

func (s *Server) Sign(w http.ResponseWriter, r *http.Request)

Sign handles the /tx/sign route

func (*Server) SimulateGas

func (s *Server) SimulateGas(txbytes []byte) (res uint64, err error)

SimulateGas simulates gas for a transaction

func (*Server) VersionHandler

func (s *Server) VersionHandler(w http.ResponseWriter, r *http.Request)

VersionHandler handles the /version route

type SignBody

type SignBody struct {
	Tx            json.RawMessage `json:"tx"`
	Name          string          `json:"name"`
	Password      string          `json:"password"`
	ChainID       string          `json:"chain_id"`
	AccountNumber string          `json:"account_number"`
	Sequence      string          `json:"sequence"`
}

SignBody is the body for a sign request

func (SignBody) Marshal

func (sb SignBody) Marshal() []byte

Marshal returns the json byte representation of the sign body

func (SignBody) StdSignMsg

func (sb SignBody) StdSignMsg() (stdSign []byte, stdTx auth.StdTx, err error)

StdSignMsg returns a StdSignMsg from a SignBody request

type StringTag

type StringTag struct {
	Key   string `json:"key"`
	Value string `json:"value,omitempty"`
}

A KVPair where the Key and Value are both strings, rather than []byte

func TagToStringTag

func TagToStringTag(tag Tag) StringTag

Conversion function from a []byte tag to a string tag

func (StringTag) String

func (st StringTag) String() string

type StringTags

type StringTags []StringTag

A slice of StringTag

func TagsToStringTags

func TagsToStringTags(tags Tags) StringTags

Conversion function from Tags to a StringTags

func (StringTags) String

func (st StringTags) String() string

type Tag

type Tag = cmn.KVPair

Type synonym for convenience

func MakeTag

func MakeTag(k string, v string) Tag

Make a tag from a key and a value

type Tags

type Tags cmn.KVPairs

Type synonym for convenience

func EmptyTags

func EmptyTags() Tags

New empty tags

func NewTags

func NewTags(tags ...interface{}) Tags

New variadic tags, must be k string, v []byte repeating

func (Tags) AppendTag

func (t Tags) AppendTag(k string, v string) Tags

Append a single tag

func (Tags) AppendTags

func (t Tags) AppendTags(tags Tags) Tags

Append two lists of tags

func (Tags) ToKVPairs

func (t Tags) ToKVPairs() []cmn.KVPair

Turn tags into KVPair list

type TxResponse

type TxResponse struct {
	Height    int64           `json:"height"`
	TxHash    string          `json:"txhash"`
	Code      uint32          `json:"code,omitempty"`
	Data      string          `json:"data,omitempty"`
	RawLog    string          `json:"raw_log,omitempty"`
	Logs      ABCIMessageLogs `json:"logs,omitempty"`
	Info      string          `json:"info,omitempty"`
	GasWanted int64           `json:"gas_wanted,omitempty"`
	GasUsed   int64           `json:"gas_used,omitempty"`
	Tags      StringTags      `json:"tags,omitempty"`
	Codespace string          `json:"codespace,omitempty"`
	Tx        sdk.Tx          `json:"tx,omitempty"`
	Timestamp string          `json:"timestamp,omitempty"`
}

TxResponse defines a structure containing relevant tx data and metadata. The tags are stringified and the log is JSON decoded.

func NewResponseFormatBroadcastTx

func NewResponseFormatBroadcastTx(res *ctypes.ResultBroadcastTx) TxResponse

NewResponseFormatBroadcastTx returns a TxResponse given a ResultBroadcastTx from tendermint

func NewResponseFormatBroadcastTxCommit

func NewResponseFormatBroadcastTxCommit(res *ctypes.ResultBroadcastTxCommit) TxResponse

NewResponseFormatBroadcastTxCommit returns a TxResponse given a ResultBroadcastTxCommit from tendermint.

func NewResponseResultTx

func NewResponseResultTx(res *ctypes.ResultTx, tx sdk.Tx, timestamp string) TxResponse

NewResponseResultTx returns a TxResponse given a ResultTx from tendermint

func (TxResponse) Empty

func (r TxResponse) Empty() bool

Empty returns true if the response is empty

func (TxResponse) String

func (r TxResponse) String() string

type UpdateKeyBody

type UpdateKeyBody struct {
	NewPassword string `json:"new_password"`
	OldPassword string `json:"old_password"`
}

UpdateKeyBody update key password request REST body

func (UpdateKeyBody) Marshal

func (u UpdateKeyBody) Marshal() []byte

Jump to

Keyboard shortcuts

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