client

package
v0.0.0-...-0b06f50 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: BSD-3-Clause Imports: 23 Imported by: 5

Documentation

Index

Constants

View Source
const (
	ShortPollLimit = 10
	ShortPollDelay = 1 * time.Second

	CodeTypeOK = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BoradcastTxSyncResult

type BoradcastTxSyncResult struct {
	Code  int32  `json:"code"`
	Data  []byte `json:"data"`
	Hash  string `json:"hash"`
	Error string `json:"log"`
}

type BroadcastTxCommitResult

type BroadcastTxCommitResult struct {
	CheckTx   TxHandlerResult `json:"check_tx"`
	DeliverTx TxHandlerResult `json:"deliver_tx"`
	Hash      string          `json:"hash"`
	Height    string          `json:"height"`
}

type Contract

type Contract struct {
	Address diadem.Address
	Name    string
	// contains filtered or unexported fields
}

Contract provides a thin abstraction over DAppChainClient that makes it easier to perform read & write operations on a contract running on a diadem DAppChain.

func NewContract

func NewContract(client *DAppChainRPCClient, contractAddr diadem.LocalAddress) *Contract

func (*Contract) Call

func (c *Contract) Call(method string, args proto.Message, signer auth.Signer, result interface{}) (interface{}, error)

func (*Contract) StaticCall

func (c *Contract) StaticCall(method string, args proto.Message, caller diadem.Address, result interface{}) (interface{}, error)

type DAppChainRPCClient

type DAppChainRPCClient struct {
	// contains filtered or unexported fields
}

Implements the DAppChainClient interface

func NewDAppChainRPCClient

func NewDAppChainRPCClient(chainID, writeURI, readURI string) *DAppChainRPCClient

NewDAppChainRPCClient creates a new dumb client that can be used to commit txs and query contract state via RPC. URI parameters should be specified as "tcp://<host>:<port>", writeURI the host that txs will be submitted to (port 46657 by default), readURI is the host that will be queried for current app state (47000 by default).

func NewDAppChainRPCClientShareTransport

func NewDAppChainRPCClientShareTransport(chainID, writeURI, readURI string, transport *http.Transport) *DAppChainRPCClient

func (*DAppChainRPCClient) CloseIdleConnections

func (c *DAppChainRPCClient) CloseIdleConnections()

func (*DAppChainRPCClient) CommitCallTx

func (c *DAppChainRPCClient) CommitCallTx(
	caller diadem.Address,
	contract diadem.Address,
	signer auth.Signer,
	vmType vm.VMType,
	input []byte,
) ([]byte, error)

func (*DAppChainRPCClient) CommitCallTxWithValue

func (c *DAppChainRPCClient) CommitCallTxWithValue(
	caller diadem.Address,
	contract diadem.Address,
	signer auth.Signer,
	vmType vm.VMType,
	input []byte,
	value *big.Int,
) ([]byte, error)

func (*DAppChainRPCClient) CommitDeployTx

func (c *DAppChainRPCClient) CommitDeployTx(
	from diadem.Address,
	signer auth.Signer,
	vmType vm.VMType,
	code []byte,
	name string,
) ([]byte, error)

func (*DAppChainRPCClient) CommitDeployTxWithValue

func (c *DAppChainRPCClient) CommitDeployTxWithValue(
	from diadem.Address,
	signer auth.Signer,
	vmType vm.VMType,
	code []byte,
	name string,
	value *big.Int,
) ([]byte, error)

func (*DAppChainRPCClient) CommitMigrationTx

func (c *DAppChainRPCClient) CommitMigrationTx(
	from diadem.Address,
	signer auth.Signer,
	id uint32,
	input []byte,
) ([]byte, error)

func (*DAppChainRPCClient) CommitTx

func (c *DAppChainRPCClient) CommitTx(signer auth.Signer, tx proto.Message) ([]byte, error)

CommitTx signs a tx with the given signer and sends it to the chain.

func (*DAppChainRPCClient) CommitTx2

func (c *DAppChainRPCClient) CommitTx2(from diadem.Address, signer auth.Signer, tx proto.Message) ([]byte, error)

CommitTx2 signs a tx with the given signer and sends it to the chain, the from address is used to query the chain for a tx nonce (this address may have a different chain ID to the client).

func (*DAppChainRPCClient) GetBlockHeight

func (c *DAppChainRPCClient) GetBlockHeight() (uint64, error)

func (*DAppChainRPCClient) GetChainID

func (c *DAppChainRPCClient) GetChainID() string

func (*DAppChainRPCClient) GetContractEvents

func (c *DAppChainRPCClient) GetContractEvents(fromBlock, toBlock uint64, contractName string) (ptypes.ContractEventsResult, error)

func (*DAppChainRPCClient) GetContractRecord

func (c *DAppChainRPCClient) GetContractRecord(contract diadem.Address) (ptypes.ContractRecordResponse, error)

func (*DAppChainRPCClient) GetEvmBlockByHash

func (c *DAppChainRPCClient) GetEvmBlockByHash(hash []byte, full bool) (ptypes.EthBlockInfo, error)

func (*DAppChainRPCClient) GetEvmBlockByNumber

func (c *DAppChainRPCClient) GetEvmBlockByNumber(number string, full bool) (ptypes.EthBlockInfo, error)

func (*DAppChainRPCClient) GetEvmCode

func (c *DAppChainRPCClient) GetEvmCode(contract string) ([]byte, error)

GetCode returns the runtime byte-code of a contract running on a DAppChain's EVM. Gives an error for non-EVM contracts. contract - address of the contract in the form of a string. (Use diadem.Address.String() to convert) return []byte - runtime bytecode of the contract.

func (*DAppChainRPCClient) GetEvmFilterChanges

func (c *DAppChainRPCClient) GetEvmFilterChanges(id string) ([]byte, error)

Get logs since last poll https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getfilterchanges could return protbuf of EthFilterLogList, EthBlockHashList or EthTxHashList

func (*DAppChainRPCClient) GetEvmLogs

func (c *DAppChainRPCClient) GetEvmLogs(filter string) (ptypes.EthFilterLogList, error)

func (*DAppChainRPCClient) GetEvmTransactionByHash

func (c *DAppChainRPCClient) GetEvmTransactionByHash(hash []byte) (ptypes.EvmTxObject, error)

func (*DAppChainRPCClient) GetEvmTxReceipt

func (c *DAppChainRPCClient) GetEvmTxReceipt(txHash []byte) (ptypes.EvmTxReceipt, error)

func (*DAppChainRPCClient) GetNonce

func (c *DAppChainRPCClient) GetNonce(signer auth.Signer) (uint64, error)

GetNonce queries the chain for the nonce of the last commited tx signed by the the given signer.

func (*DAppChainRPCClient) GetNonce2

func (c *DAppChainRPCClient) GetNonce2(caller diadem.Address, signer auth.Signer) (uint64, error)

GetNonce2 queries the chain for the nonce of the last commited tx sent by the given account.

func (*DAppChainRPCClient) NewEvmFilter

func (c *DAppChainRPCClient) NewEvmFilter(filter string) (string, error)

Sets up new filter for polling https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newfilter

func (*DAppChainRPCClient) Query

func (c *DAppChainRPCClient) Query(caller diadem.Address, contractAddr diadem.LocalAddress, query proto.Message) ([]byte, error)

func (*DAppChainRPCClient) QueryEvm

func (c *DAppChainRPCClient) QueryEvm(caller diadem.Address, contractAddr diadem.LocalAddress, query []byte) ([]byte, error)

func (*DAppChainRPCClient) Resolve

func (c *DAppChainRPCClient) Resolve(name string) (diadem.Address, error)

func (*DAppChainRPCClient) UninstallEvmFilter

func (c *DAppChainRPCClient) UninstallEvmFilter(id string) (bool, error)

Forget filter https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_uninstallfilter

type EvmContract

type EvmContract struct {
	Address diadem.Address
	Name    string
	// contains filtered or unexported fields
}

Contract provides a thin abstraction over DAppChainClient that makes it easier to perform read & write operations on a contract running the EVM of a diadem DAppChain.

func DeployContract

func DeployContract(client *DAppChainRPCClient, byteCode []byte, signer auth.Signer, name string) (*EvmContract, []byte, error)

func NewEvmContract

func NewEvmContract(client *DAppChainRPCClient, contractAddr diadem.LocalAddress) *EvmContract

func (*EvmContract) Call

func (c *EvmContract) Call(input []byte, signer auth.Signer) ([]byte, error)

func (*EvmContract) StaticCall

func (c *EvmContract) StaticCall(input []byte, caller diadem.Address) ([]byte, error)

type JSONRPCClient

type JSONRPCClient struct {
	// contains filtered or unexported fields
}

func NewJSONRPCClient

func NewJSONRPCClient(host string) *JSONRPCClient

func NewJSONRPCClientShareTransport

func NewJSONRPCClientShareTransport(host string, transport *http.Transport) *JSONRPCClient

func (*JSONRPCClient) Call

func (c *JSONRPCClient) Call(method string, params map[string]interface{}, id string, result interface{}) error

type RPCError

type RPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    string `json:"data,omitempty"`
}

func (RPCError) Error

func (err RPCError) Error() string

type RPCRequest

type RPCRequest struct {
	Version string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params"` // map[string]interface{} or []interface{}
	ID      string          `json:"id"`
}

func NewRPCRequest

func NewRPCRequest(method string, params json.RawMessage, id string) RPCRequest

type RPCResponse

type RPCResponse struct {
	Version string          `json:"jsonrpc"`
	ID      string          `json:"id"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *RPCError       `json:"error,omitempty"`
}

type TxHandlerResult

type TxHandlerResult struct {
	Code  int32  `json:"code"`
	Error string `json:"log"`
	Data  []byte `json:"data"`
}

type TxQueryResult

type TxQueryResult struct {
	TxResult TxHandlerResult `json:"tx_result"`
}

Directories

Path Synopsis
eth

Jump to

Keyboard shortcuts

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