diemclient

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Provides Diem JSON-RPC API client, see https://github.com/diem/diem/blob/master/json-rpc/json-rpc-spec.md for more details.

Index

Constants

View Source
const (
	GetCurrencies          jsonrpc.Method = "get_currencies"
	GetMetadata            jsonrpc.Method = "get_metadata"
	GetAccount             jsonrpc.Method = "get_account"
	GetAccountTransaction  jsonrpc.Method = "get_account_transaction"
	GetAccountTransactions jsonrpc.Method = "get_account_transactions"
	GetTransactions        jsonrpc.Method = "get_transactions"
	GetEvents              jsonrpc.Method = "get_events"
	Submit                 jsonrpc.Method = "submit"

	VmStatusExecuted = "executed"
)

List of supported methods

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account = diemjsonrpctypes.Account

Account is get_account method response

type AccountRole

type AccountRole = diemjsonrpctypes.AccountRole

AccountRole represents role specific data for account

type AccountStateProof

type AccountStateProof = diemjsonrpctypes.AccountStateProof

AccountStateProof represents account state blob proof

type AccountStateWithProof

type AccountStateWithProof = diemjsonrpctypes.AccountStateWithProof

AccountStateWithProof is get_account_state_with_proof response

type Amount

type Amount = diemjsonrpctypes.Amount

Amount represents currency amount

type Client

type Client interface {
	GetCurrencies() ([]*CurrencyInfo, error)
	GetMetadata() (*Metadata, error)
	GetMetadataByVersion(uint64) (*Metadata, error)
	GetAccount(diemtypes.AccountAddress) (*Account, error)
	GetAccountTransaction(diemtypes.AccountAddress, uint64, bool) (*Transaction, error)
	GetAccountTransactions(diemtypes.AccountAddress, uint64, uint64, bool) ([]*Transaction, error)
	GetTransactions(uint64, uint64, bool) ([]*Transaction, error)
	GetEvents(string, uint64, uint64) ([]*Event, error)
	Submit(signedTxnHex string) error
	SubmitTransaction(txn *diemtypes.SignedTransaction) error

	WaitForTransaction(
		address diemtypes.AccountAddress,
		seq uint64,
		hash string,
		expirationTimeSec uint64,
		timeout time.Duration,
	) (*Transaction, error)
	WaitForTransaction2(
		txn *diemtypes.SignedTransaction,
		timeout time.Duration,
	) (*Transaction, error)
	WaitForTransaction3(
		signedTxnHex string,
		timeout time.Duration,
	) (*Transaction, error)

	LastResponseLedgerState() LedgerState
	UpdateLastResponseLedgerState(state LedgerState) error
	WithRetryOptions(opts ...retry.Option) Client
}

Client is Diem client implements high level APIs

func New

func New(chainID byte, url string) Client

New creates a `DiemClient` connect to given server URL. It creates default jsonrpc client `http.Transport` config, if you need to customize `http.Transport` config (for better connection pool production usage), call `NewWithJsonRpcClient` with `jsonrpc.NewClientWithTransport(url, <your http.Transport>)`

func NewWithJsonRpcClient

func NewWithJsonRpcClient(chainID byte, rpc jsonrpc.Client) Client

NewWithJsonRpcClient creates a `DiemClient` with given `jsonrpc.Client`

type CurrencyInfo

type CurrencyInfo = diemjsonrpctypes.CurrencyInfo

CurrencyInfo is get_currencies response

type Event

type Event = diemjsonrpctypes.Event

Event data

type EventData

type EventData = diemjsonrpctypes.EventData

EventData is event type specific data

type InvalidTransactionError

type InvalidTransactionError struct {
	Transaction Transaction
	Msg         string
}

InvalidTransactionError is error for get a transaction with unexpected details (e.g. vm status is failure)

func (*InvalidTransactionError) Error

func (e *InvalidTransactionError) Error() string

Error implements error interface

type LedgerState

type LedgerState struct {
	TimestampUsec uint64
	Version       uint64
}

LedgerState represents response DiemLedgerTimestampusec & DiemLedgerVersion

type Metadata

type Metadata = diemjsonrpctypes.Metadata

Metadata is get_metadata method response

type Script

type Script = diemjsonrpctypes.Script

Script represents decoded transaction script arguments

type StaleResponseError

type StaleResponseError struct {
	Client LedgerState
	Server LedgerState
}

StaleResponseError is error for the case server response latest ledger state is older than client knows

func (*StaleResponseError) Error

func (e *StaleResponseError) Error() string

Error implements error interface

type StateProof

type StateProof = diemjsonrpctypes.StateProof

StateProof is get_state_proof response

type Transaction

type Transaction = diemjsonrpctypes.Transaction

Transaction represents executed / failed transaction

type TransactionData

type TransactionData = diemjsonrpctypes.TransactionData

TransactionData include specific type transaction details

type VmStatus

type VmStatus = diemjsonrpctypes.VMStatus

VmStatus represents transaction execution result and error info

Directories

Path Synopsis
Provides builders for creating JSON-RPC response result in test.
Provides builders for creating JSON-RPC response result in test.

Jump to

Keyboard shortcuts

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