rpc

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package rpc is a Tendermint RPC wrapper package to broadcast transaction and query ABCI query.

Simply create, sign and broadcast transaction via functions in tx.go

// Get KeyEntry
key := keys.ImportKey(...)

rpc.Transfer(0, "<TO ADDRESS>", "<AMOUNT>", key, fee, lastHeight) // Send AMO Coin
rpc.Transfer(144, ...) // Send UDC 144

rpc.Stake("<VALIDATOR ADDRESS>", "<AMOUNT>", key, fee, lastHeight)
rpc.Propose("<DRAFT ID>", "<CONFIG>", "<DESCRIPTION>")

Query AMO Blockchain ABCI query via functions in query.go Return types of ABCI Query are defined in https://github.com/amolabs/docs/blob/master/rpc.md

rpc.Balance(0, "<ADDRESS>") // Query AMO coin balance of address
rpc.Balance(144, "<ADDRESS>") // Query UDC 144 balance of address
rpc.Parcel("<PARCEL ID>") // Query parcel meta data

Index

Constants

This section is empty.

Variables

View Source
var (
	RpcRemote       = "http://0.0.0.0:26657"
	DryRun          = false
	AddressByteSize = 20

	TxBroadcastOption string
)

Functions

func ABCIQuery

func ABCIQuery(path string, queryData interface{}) ([]byte, error)

func QueryAppConfig added in v1.3.0

func QueryAppConfig() ([]byte, error)

func QueryAppVersion added in v1.8.1

func QueryAppVersion() ([]byte, error)

func QueryBalance

func QueryBalance(udc uint32, address string) ([]byte, error)

func QueryDID added in v1.9.0

func QueryDID(did string) ([]byte, error)

func QueryDelegate

func QueryDelegate(address string) ([]byte, error)

func QueryDraft added in v1.4.1

func QueryDraft(draftID string) ([]byte, error)

func QueryParcel

func QueryParcel(parcelID string) ([]byte, error)

func QueryRequest

func QueryRequest(target, recipient string) ([]byte, error)

func QueryStake

func QueryStake(address string) ([]byte, error)

func QueryStorage added in v1.4.1

func QueryStorage(storageID string) ([]byte, error)

func QueryUDC added in v1.4.2

func QueryUDC(udcID string) ([]byte, error)

func QueryUDCLock added in v1.4.2

func QueryUDCLock(udcID, address string) ([]byte, error)

func QueryUsage

func QueryUsage(target, recipient string) ([]byte, error)

func QueryVC added in v1.9.0

func QueryVC(vcid string) ([]byte, error)

func QueryVote added in v1.4.1

func QueryVote(draftID, address string) ([]byte, error)

Types

type ABCIQueryParams

type ABCIQueryParams struct {
	Path   string `json:"path"`
	Data   string `json:"data"`
	Height string `json:"height"`
	Prove  bool   `json:"prove"`
}

type ABCIQueryResponse

type ABCIQueryResponse struct {
	Log   string `json:"log"`
	Key   string `json:"key"`
	Value string `json:"value"`
}

type BroadcastParams

type BroadcastParams struct {
	Tx []byte `json:"tx"`
}

type TmQueryResult

type TmQueryResult struct {
	Response ABCIQueryResponse `json:"response"`
}

XXX: Weired, but tendermint does this anyway

type TmStatusResult

type TmStatusResult struct {
	NodeInfo      json.RawMessage `json:"node_info"`
	SyncInfo      json.RawMessage `json:"sync_info"`
	ValidatorInfo json.RawMessage `json:"validator_info"`
}

func NodeStatus

func NodeStatus() (TmStatusResult, error)

type TmTxResult

type TmTxResult struct {
	CheckTx struct {
		Code int64  `json:"code,omitempty"`
		Info string `json:"info,omitempty"`
	} `json:"check_tx"`
	DeliverTx struct {
		Code int64  `json:"code,omitempty"`
		Info string `json:"info,omitempty"`
	} `json:"deliver_tx"`
	Hash   string `json:"hash"`
	Height string `json:"height"` // number as a string
}

func BroadcastTx

func BroadcastTx(tx []byte) (TmTxResult, error)

func Burn added in v1.4.2

func Burn(udcID, amount string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Cancel

func Cancel(target, recipient string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Close added in v1.4.1

func Close(storageID string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func DIDClaim added in v1.9.0

func DIDClaim(target, docFile string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func DIDDismiss added in v1.9.0

func DIDDismiss(target string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func DIDIssue added in v1.9.0

func DIDIssue(target, docFile string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func DIDRevoke added in v1.9.0

func DIDRevoke(target string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Delegate

func Delegate(to, amount string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Discard

func Discard(target string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Grant

func Grant(target, recipient, custody, extra string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Issue added in v1.4.2

func Issue(udcID, amount string, desc string, operators []string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Lock added in v1.4.2

func Lock(udcID, holder, amount string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Propose added in v1.4.1

func Propose(draftID, config, desc string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Register

func Register(target, custody, proxy, extra string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Request

func Request(target, payment, recipient, dealer, dealerFee, extra string,
	key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Retract

func Retract(amount string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Revoke

func Revoke(target, recipient string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Setup added in v1.4.1

func Setup(storageID, url, regFee, hostFee string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func SignSendTx

func SignSendTx(txType string, payload interface{}, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Stake

func Stake(validator, amount string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Transfer

func Transfer(udc uint32, to, asset string, isParcel bool, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Vote added in v1.4.1

func Vote(draftID string, approve bool, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

func Withdraw

func Withdraw(amount string, key keys.KeyEntry, fee, lastHeight string) (TmTxResult, error)

type TxSig

type TxSig struct {
	Pubkey   string `json:"pubkey"`
	SigBytes string `json:"sig_bytes"`
}

type TxToSend

type TxToSend struct {
	Type       string          `json:"type"`
	Sender     string          `json:"sender"`
	Fee        string          `json:"fee"`
	LastHeight string          `json:"last_height"`
	Payload    json.RawMessage `json:"payload"`
	Signature  TxSig           `json:"signature"`
}

type TxToSign

type TxToSign struct {
	Type       string          `json:"type"`
	Sender     string          `json:"sender"`
	Fee        string          `json:"fee"`
	LastHeight string          `json:"last_height"`
	Payload    json.RawMessage `json:"payload"`
}

Jump to

Keyboard shortcuts

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