rpc

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PopInvokeStack

func PopInvokeStack(response InvokeResultResponse) (*models.InvokeStack, error)

Types

type CalculateNetworkFeeResponse

type CalculateNetworkFeeResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcNetworkFee `json:"result"`
}

type CloseWalletResponse

type CloseWalletResponse struct {
	RpcResponse
	ErrorResponse
	Result bool `json:"result"`
}

type DumpPrivKeyResponse

type DumpPrivKeyResponse struct {
	RpcResponse
	ErrorResponse
	Result string `json:"result"`
}

type ErrorResponse

type ErrorResponse struct {
	Error    RpcError `json:"error"`
	NetError error
}

func (*ErrorResponse) GetErrorInfo

func (r *ErrorResponse) GetErrorInfo() string

func (*ErrorResponse) HasError

func (r *ErrorResponse) HasError() bool

type GetApplicationLogResponse

type GetApplicationLogResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcApplicationLog `json:"result"`
}

type GetBestBlockHashResponse

type GetBestBlockHashResponse struct {
	RpcResponse
	ErrorResponse
	Result string `json:"result"`
}

type GetBlockCountResponse

type GetBlockCountResponse struct {
	RpcResponse
	ErrorResponse
	Result int `json:"result"`
}

type GetBlockHashResponse

type GetBlockHashResponse struct {
	RpcResponse
	ErrorResponse
	Result string `json:"result"`
}

type GetBlockHeaderResponse

type GetBlockHeaderResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcBlockHeader `json:"result"`
}

type GetBlockResponse

type GetBlockResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcBlock `json:"result"`
}

type GetBlockSysFeeResponse

type GetBlockSysFeeResponse struct {
	RpcResponse
	ErrorResponse
	Result string `json:"result"`
}

type GetCommitteeResponse

type GetCommitteeResponse struct {
	RpcResponse
	ErrorResponse
	Result []string `json:"result"`
}

type GetConnectionCountResponse

type GetConnectionCountResponse struct {
	RpcResponse
	ErrorResponse
	Result int `json:"result"`
}

type GetContractStateResponse

type GetContractStateResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcContractState `json:"result"`
}

type GetCrossChainProofResponse

type GetCrossChainProofResponse struct {
	RpcResponse
	ErrorResponse
	CrossChainProof string `json:"result"`
}

type GetNativeContractsResponse

type GetNativeContractsResponse struct {
	RpcResponse
	ErrorResponse
	Result []models.RpcNativeContract `json:"result"`
}

type GetNep17BalancesResponse

type GetNep17BalancesResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcNep17Balances `json:"result"`
}

type GetNep17TransfersResponse

type GetNep17TransfersResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcNep17Transfers `json:"result"`
}

type GetNewAddressResponse

type GetNewAddressResponse struct {
	RpcResponse
	ErrorResponse
	Result string `json:"result"`
}

type GetNextBlockValidatorsResponse

type GetNextBlockValidatorsResponse struct {
	RpcResponse
	ErrorResponse
	Result []models.RpcValidator `json:"result"`
}

type GetPeersResponse

type GetPeersResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcPeers `json:"result"`
}

type GetProofResponse

type GetProofResponse struct {
	RpcResponse
	ErrorResponse
	Result string `json:"result"`
}

type GetRawMemPoolResponse

type GetRawMemPoolResponse struct {
	RpcResponse
	ErrorResponse
	Result []string `json:"result"`
}

type GetRawTransactionResponse

type GetRawTransactionResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcTransaction `json:"result"`
}

type GetStateHeightResponse

type GetStateHeightResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcStateHeight `json:"result"`
}

type GetStateRootResponse

type GetStateRootResponse struct {
	RpcResponse
	ErrorResponse
	Result mpt.StateRoot `json:"result"`
}

type GetStorageResponse

type GetStorageResponse struct {
	RpcResponse
	ErrorResponse
	Result string `json:"result"`
}

type GetTransactionHeightResponse

type GetTransactionHeightResponse struct {
	RpcResponse
	ErrorResponse
	Result int `json:"result"`
}

type GetUnclaimedGasResponse

type GetUnclaimedGasResponse struct {
	RpcResponse
	ErrorResponse
	Result models.UnclaimedGas `json:"result"`
}

type GetVersionResponse

type GetVersionResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcVersion `json:"result"`
}

type GetWalletBalanceResponse

type GetWalletBalanceResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcWalletBalance `json:"result"`
}

type GetWalletUnclaimedGasResponse

type GetWalletUnclaimedGasResponse struct {
	RpcResponse
	ErrorResponse
	Result string `json:"result"`
}

type IHttpClient

type IHttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

IHttpClient for mock unit test

type IRpcClient

type IRpcClient interface {
	GetUrl() string
	// block chain
	GetBestBlockHash() GetBestBlockHashResponse
	GetBlock(hashOrIndex string) GetBlockResponse
	GetBlockCount() GetBlockCountResponse
	GetBlockHash(index uint32) GetBlockHashResponse
	GetBlockHeader(hashOrIndex string) GetBlockHeaderResponse
	GetContractState(hash string) GetContractStateResponse
	GetRawMemPool() GetRawMemPoolResponse
	GetRawTransaction(hash string) GetRawTransactionResponse
	GetStorage(scriptHash string, key string) GetStorageResponse
	GetTransactionHeight(hash string) GetTransactionHeightResponse
	GetNextBlockValidators() GetNextBlockValidatorsResponse
	GetCommittee() GetCommitteeResponse
	GetNativeContracts() GetNativeContractsResponse

	// node
	GetConnectionCount() GetConnectionCountResponse
	GetPeers() GetPeersResponse
	GetVersion() GetVersionResponse
	SendRawTransaction(tx string) SendRawTransactionResponse
	SubmitBlock(block string) SubmitBlockResponse

	// plugins
	GetApplicationLog(txId string) GetApplicationLogResponse
	GetNep17Balances(address string) GetNep17BalancesResponse
	GetNep17Transfers(address string, startTimestamp *int, endTimestamp *int) GetNep17TransfersResponse

	// smart contract
	InvokeFunction(scriptHash string, function string, args []models.RpcContractParameter, signers []models.RpcSigner) InvokeResultResponse
	InvokeScript(script string, signers []models.RpcSigner) InvokeResultResponse
	GetUnclaimedGas(address string) GetUnclaimedGasResponse

	// state
	GetProof(rootHash, contractScriptHash, storeKey string) GetProofResponse
	GetStateHeight() GetStateHeightResponse
	GetStateRoot(blockHeight uint32) GetStateRootResponse
	VerifyProof(rootHash string, proofInBase64 string) VerifyProofResponse

	// utilities
	ListPlugins() ListPluginsResponse
	ValidateAddress(address string) ValidateAddressResponse

	// wallet
	CloseWallet() CloseWalletResponse
	DumpPrivKey(address string) DumpPrivKeyResponse
	GetNewAddress() GetNewAddressResponse
	GetWalletBalance(assetId string) GetWalletBalanceResponse
	GetWalletUnclaimedGas() GetWalletUnclaimedGasResponse
	ImportPrivKey(wif string) ImportPrivKeyResponse
	CalculateNetworkFee(tx string) CalculateNetworkFeeResponse
	ListAddress() ListAddressResponse
	OpenWallet(path string, password string) OpenWalletResponse
	SendFrom(assetId string, from string, to string, amount string) SendFromResponse
	SendMany(fromAddress string, outputs []models.RpcTransferOut, signers ...models.RpcSigner) SendManyResponse
	SendToAddress(assetId string, to string, amount string) SendToAddressResponse
	InvokeContractVerify(scriptHash string, args []models.RpcContractParameter, signers []models.RpcSigner) InvokeResultResponse
}

add IRpcClient for mock UT

type ImportPrivKeyResponse

type ImportPrivKeyResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcAddress `json:"result"`
}

type InvokeResultResponse

type InvokeResultResponse struct {
	RpcResponse
	ErrorResponse
	Result models.InvokeResult `json:"result"`
}

type ListAddressResponse

type ListAddressResponse struct {
	RpcResponse
	ErrorResponse
	Result []models.RpcAddress `json:"result"`
}

type ListPluginsResponse

type ListPluginsResponse struct {
	RpcResponse
	ErrorResponse
	Result []models.RpcListPlugin `json:"result"`
}

type OpenWalletResponse

type OpenWalletResponse struct {
	RpcResponse
	ErrorResponse
	Result bool `json:"result"`
}

type RpcClient

type RpcClient struct {
	Endpoint *url.URL
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string) *RpcClient

func (*RpcClient) CalculateNetworkFee

func (n *RpcClient) CalculateNetworkFee(tx string) CalculateNetworkFeeResponse

func (*RpcClient) CloseWallet

func (n *RpcClient) CloseWallet() CloseWalletResponse

func (*RpcClient) DumpPrivKey

func (n *RpcClient) DumpPrivKey(address string) DumpPrivKeyResponse

func (*RpcClient) GetApplicationLog

func (n *RpcClient) GetApplicationLog(txId string) GetApplicationLogResponse

the endpoint needs to use ApplicationLogs plugin

func (*RpcClient) GetBestBlockHash

func (n *RpcClient) GetBestBlockHash() GetBestBlockHashResponse

func (*RpcClient) GetBlock

func (n *RpcClient) GetBlock(hashOrIndex string) GetBlockResponse

func (*RpcClient) GetBlockCount

func (n *RpcClient) GetBlockCount() GetBlockCountResponse

func (*RpcClient) GetBlockHash

func (n *RpcClient) GetBlockHash(index uint32) GetBlockHashResponse

func (*RpcClient) GetBlockHeader

func (n *RpcClient) GetBlockHeader(hashOrIndex string) GetBlockHeaderResponse

func (*RpcClient) GetCommittee

func (n *RpcClient) GetCommittee() GetCommitteeResponse

func (*RpcClient) GetConnectionCount

func (n *RpcClient) GetConnectionCount() GetConnectionCountResponse

func (*RpcClient) GetContractState

func (n *RpcClient) GetContractState(scriptHash string) GetContractStateResponse

func (*RpcClient) GetCrossChainProof

func (n *RpcClient) GetCrossChainProof(blockIndex int, txID string) GetCrossChainProofResponse

func (*RpcClient) GetNativeContracts

func (n *RpcClient) GetNativeContracts() GetNativeContractsResponse

func (*RpcClient) GetNep17Balances

func (n *RpcClient) GetNep17Balances(address string) GetNep17BalancesResponse

this endpoint needs RpcNep17Tracker plugin

func (*RpcClient) GetNep17Transfers

func (n *RpcClient) GetNep17Transfers(address string, startTime *int, endTime *int) GetNep17TransfersResponse

this endpoint needs RpcNep17Tracker plugin

func (*RpcClient) GetNewAddress

func (n *RpcClient) GetNewAddress() GetNewAddressResponse

func (*RpcClient) GetNextBlockValidators

func (n *RpcClient) GetNextBlockValidators() GetNextBlockValidatorsResponse

func (*RpcClient) GetPeers

func (n *RpcClient) GetPeers() GetPeersResponse

func (*RpcClient) GetProof

func (n *RpcClient) GetProof(rootHash, contractScriptHash, storeKey string) GetProofResponse

func (*RpcClient) GetRawMemPool

func (n *RpcClient) GetRawMemPool() GetRawMemPoolResponse

func (*RpcClient) GetRawTransaction

func (n *RpcClient) GetRawTransaction(txid string) GetRawTransactionResponse

func (*RpcClient) GetStateHeight

func (n *RpcClient) GetStateHeight() GetStateHeightResponse

func (*RpcClient) GetStateRoot

func (n *RpcClient) GetStateRoot(blockHeight uint32) GetStateRootResponse

func (*RpcClient) GetStorage

func (n *RpcClient) GetStorage(scripthash string, key string) GetStorageResponse

func (*RpcClient) GetTransactionHeight

func (n *RpcClient) GetTransactionHeight(txid string) GetTransactionHeightResponse

func (*RpcClient) GetUnclaimedGas

func (n *RpcClient) GetUnclaimedGas(address string) GetUnclaimedGasResponse

func (*RpcClient) GetUrl

func (n *RpcClient) GetUrl() string

func (*RpcClient) GetVersion

func (n *RpcClient) GetVersion() GetVersionResponse

func (*RpcClient) GetWalletBalance

func (n *RpcClient) GetWalletBalance(assetId string) GetWalletBalanceResponse

func (*RpcClient) GetWalletUnclaimedGas

func (n *RpcClient) GetWalletUnclaimedGas() GetWalletUnclaimedGasResponse

func (*RpcClient) ImportPrivKey

func (n *RpcClient) ImportPrivKey(wif string) ImportPrivKeyResponse

func (*RpcClient) InvokeContractVerify

func (n *RpcClient) InvokeContractVerify(scriptHash string, args []models.RpcContractParameter, signers []models.RpcSigner) InvokeResultResponse

func (*RpcClient) InvokeFunction

func (n *RpcClient) InvokeFunction(scriptHash string, method string, args []models.RpcContractParameter, signers []models.RpcSigner) InvokeResultResponse

func (*RpcClient) InvokeScript

func (n *RpcClient) InvokeScript(scriptInBase64 string, signers []models.RpcSigner) InvokeResultResponse

if there is no need to pass "signers", just pass nil

func (*RpcClient) ListAddress

func (n *RpcClient) ListAddress() ListAddressResponse

func (*RpcClient) ListPlugins

func (n *RpcClient) ListPlugins() ListPluginsResponse

func (*RpcClient) OpenWallet

func (n *RpcClient) OpenWallet(path string, password string) OpenWalletResponse

func (*RpcClient) SendFrom

func (n *RpcClient) SendFrom(assetId string, from string, to string, amount string) SendFromResponse

func (*RpcClient) SendMany

func (n *RpcClient) SendMany(fromAddress string, outputs []models.RpcTransferOut, signers ...models.RpcSigner) SendManyResponse

func (*RpcClient) SendRawTransaction

func (n *RpcClient) SendRawTransaction(rawTransactionInHex string) SendRawTransactionResponse

func (*RpcClient) SendToAddress

func (n *RpcClient) SendToAddress(assetId string, to string, amount string) SendToAddressResponse

func (*RpcClient) SetBasicAuth

func (n *RpcClient) SetBasicAuth(user string, pass string)

func (*RpcClient) SubmitBlock

func (n *RpcClient) SubmitBlock(blockHex string) SubmitBlockResponse

func (*RpcClient) ValidateAddress

func (n *RpcClient) ValidateAddress(address string) ValidateAddressResponse

func (*RpcClient) VerifyProof

func (n *RpcClient) VerifyProof(rootHash string, proofInBase64 string) VerifyProofResponse

type RpcClientMock

type RpcClientMock struct {
	mock.Mock
}

func (*RpcClientMock) CalculateNetworkFee

func (r *RpcClientMock) CalculateNetworkFee(s string) CalculateNetworkFeeResponse

func (*RpcClientMock) CloseWallet

func (r *RpcClientMock) CloseWallet() CloseWalletResponse

wallet

func (*RpcClientMock) DumpPrivKey

func (r *RpcClientMock) DumpPrivKey(s string) DumpPrivKeyResponse

func (*RpcClientMock) GetApplicationLog

func (r *RpcClientMock) GetApplicationLog(s string) GetApplicationLogResponse

plugins

func (*RpcClientMock) GetBestBlockHash

func (r *RpcClientMock) GetBestBlockHash() GetBestBlockHashResponse

block chain

func (*RpcClientMock) GetBlock

func (r *RpcClientMock) GetBlock(hashOrIndex string) GetBlockResponse

func (*RpcClientMock) GetBlockCount

func (r *RpcClientMock) GetBlockCount() GetBlockCountResponse

func (*RpcClientMock) GetBlockHash

func (r *RpcClientMock) GetBlockHash(n uint32) GetBlockHashResponse

func (*RpcClientMock) GetBlockHeader

func (r *RpcClientMock) GetBlockHeader(hashOrIndex string) GetBlockHeaderResponse

func (*RpcClientMock) GetBlockSysFee

func (r *RpcClientMock) GetBlockSysFee(height int) GetBlockSysFeeResponse

func (*RpcClientMock) GetCommittee

func (r *RpcClientMock) GetCommittee() GetCommitteeResponse

func (*RpcClientMock) GetConnectionCount

func (r *RpcClientMock) GetConnectionCount() GetConnectionCountResponse

node

func (*RpcClientMock) GetContractState

func (r *RpcClientMock) GetContractState(s string) GetContractStateResponse

func (*RpcClientMock) GetNativeContracts

func (r *RpcClientMock) GetNativeContracts() GetNativeContractsResponse

func (*RpcClientMock) GetNep17Balances

func (r *RpcClientMock) GetNep17Balances(s string) GetNep17BalancesResponse

func (*RpcClientMock) GetNep17Transfers

func (r *RpcClientMock) GetNep17Transfers(s string, t1 *int, t2 *int) GetNep17TransfersResponse

func (*RpcClientMock) GetNewAddress

func (r *RpcClientMock) GetNewAddress() GetNewAddressResponse

func (*RpcClientMock) GetNextBlockValidators

func (r *RpcClientMock) GetNextBlockValidators() GetNextBlockValidatorsResponse

func (*RpcClientMock) GetPeers

func (r *RpcClientMock) GetPeers() GetPeersResponse

func (*RpcClientMock) GetProof

func (r *RpcClientMock) GetProof(s1, s2, s3 string) GetProofResponse

state

func (*RpcClientMock) GetRawMemPool

func (r *RpcClientMock) GetRawMemPool() GetRawMemPoolResponse

func (*RpcClientMock) GetRawTransaction

func (r *RpcClientMock) GetRawTransaction(s string) GetRawTransactionResponse

func (*RpcClientMock) GetStateHeight

func (r *RpcClientMock) GetStateHeight() GetStateHeightResponse

func (*RpcClientMock) GetStateRoot

func (r *RpcClientMock) GetStateRoot(u uint32) GetStateRootResponse

func (*RpcClientMock) GetStorage

func (r *RpcClientMock) GetStorage(s1 string, s2 string) GetStorageResponse

func (*RpcClientMock) GetTransactionHeight

func (r *RpcClientMock) GetTransactionHeight(s string) GetTransactionHeightResponse

func (*RpcClientMock) GetUnclaimedGas

func (r *RpcClientMock) GetUnclaimedGas(s string) GetUnclaimedGasResponse

func (*RpcClientMock) GetUrl

func (r *RpcClientMock) GetUrl() string

func (*RpcClientMock) GetVersion

func (r *RpcClientMock) GetVersion() GetVersionResponse

func (*RpcClientMock) GetWalletBalance

func (r *RpcClientMock) GetWalletBalance(s string) GetWalletBalanceResponse

func (*RpcClientMock) GetWalletUnclaimedGas

func (r *RpcClientMock) GetWalletUnclaimedGas() GetWalletUnclaimedGasResponse

func (*RpcClientMock) ImportPrivKey

func (r *RpcClientMock) ImportPrivKey(s string) ImportPrivKeyResponse

func (*RpcClientMock) InvokeContractVerify

func (r *RpcClientMock) InvokeContractVerify(s string, a []models.RpcContractParameter, signers []models.RpcSigner) InvokeResultResponse

func (*RpcClientMock) InvokeFunction

func (r *RpcClientMock) InvokeFunction(s1 string, s2 string, a []models.RpcContractParameter, signers []models.RpcSigner) InvokeResultResponse

smart contract

func (*RpcClientMock) InvokeScript

func (r *RpcClientMock) InvokeScript(s string, signers []models.RpcSigner) InvokeResultResponse

func (*RpcClientMock) ListAddress

func (r *RpcClientMock) ListAddress() ListAddressResponse

func (*RpcClientMock) ListPlugins

func (r *RpcClientMock) ListPlugins() ListPluginsResponse

utilities

func (*RpcClientMock) OpenWallet

func (r *RpcClientMock) OpenWallet(s1 string, s2 string) OpenWalletResponse

func (*RpcClientMock) SendFrom

func (r *RpcClientMock) SendFrom(s1, s2, s3, s4 string) SendFromResponse

func (*RpcClientMock) SendMany

func (*RpcClientMock) SendRawTransaction

func (r *RpcClientMock) SendRawTransaction(s string) SendRawTransactionResponse

func (*RpcClientMock) SendToAddress

func (r *RpcClientMock) SendToAddress(s1, s2, s3 string) SendToAddressResponse

func (*RpcClientMock) SubmitBlock

func (r *RpcClientMock) SubmitBlock(s string) SubmitBlockResponse

func (*RpcClientMock) ValidateAddress

func (r *RpcClientMock) ValidateAddress(s string) ValidateAddressResponse

func (*RpcClientMock) VerifyProof

func (r *RpcClientMock) VerifyProof(s string, p string) VerifyProofResponse

type RpcError

type RpcError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type RpcRequest

type RpcRequest struct {
	JsonRpc string        `json:"jsonrpc"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
	ID      int           `json:"id"`
}

func NewRequest

func NewRequest(method string, params []interface{}) RpcRequest

type RpcResponse

type RpcResponse struct {
	JsonRpc string `json:"jsonrpc"`
	ID      int    `json:"id"`
}

type SendFromResponse

type SendFromResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcTransaction `json:"result"`
}

type SendManyResponse

type SendManyResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcTransaction `json:"result"`
}

type SendRawTransactionResponse

type SendRawTransactionResponse struct {
	RpcResponse
	ErrorResponse
	Result struct {
		Hash string `json:"hash"`
	} `json:"result"`
}

type SendToAddressResponse

type SendToAddressResponse struct {
	RpcResponse
	ErrorResponse
	Result models.RpcTransaction `json:"result"`
}

type SubmitBlockResponse

type SubmitBlockResponse struct {
	RpcResponse
	ErrorResponse
	Result struct {
		Hash string `json:"hash"`
	} `json:"result"`
}

type ValidateAddressResponse

type ValidateAddressResponse struct {
	RpcResponse
	ErrorResponse
	Result models.ValidateAddress `json:"result"`
}

type VerifyProofResponse

type VerifyProofResponse struct {
	RpcResponse
	ErrorResponse
	Result string `json:"result"` // base64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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