client

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: Apache-2.0 Imports: 20 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHttpError

func NewHttpError(r *http.Response) error

func SignTransaction added in v1.3.9

func SignTransaction(w module.Wallet, param *v3.TransactionParam) error

func TimestampFromTime added in v1.3.9

func TimestampFromTime(tm time.Time) jsonrpc.HexInt

func TimestampNow added in v1.3.9

func TimestampNow() jsonrpc.HexInt

Types

type BTPNetworkInfo added in v1.3.0

type BTPNetworkInfo struct {
	StartHeight             jsonrpc.HexInt   `json:"startHeight"`
	NetworkTypeID           jsonrpc.HexInt   `json:"networkTypeID"`
	NetworkName             string           `json:"networkName"`
	Open                    jsonrpc.HexInt   `json:"open"`
	Owner                   jsonrpc.Address  `json:"owner"`
	NextMessageSN           jsonrpc.HexInt   `json:"nextMessageSN"`
	NextProofContextChanged jsonrpc.HexInt   `json:"nextProofContextChanged"`
	PrevNSHash              jsonrpc.HexBytes `json:"prevNSHash"`
	LastNSHash              jsonrpc.HexBytes `json:"lastNSHash"`
	NetworkID               jsonrpc.HexInt   `json:"networkID"`
	NetworkTypeName         string           `json:"networkTypeName"`
}

refer service/state/btp.go:887 network.ToJSON refer server/v3/api_v3.go:692 getBTPNetworkInfo

type BTPNetworkTypeInfo added in v1.3.0

type BTPNetworkTypeInfo struct {
	NetworkTypeName  string           `json:"networkTypeName"`
	NextProofContext jsonrpc.HexBytes `json:"nextProofContext"`
	OpenNetworkIDs   []jsonrpc.HexInt `json:"openNetworkIDs"`
	NetworkTypeID    jsonrpc.HexInt   `json:"networkTypeID"`
}

refer service/state/btp.go:752 networkType.ToJSON refer server/v3/api_v3.go:743 getBTPNetworkTypeInfo

type BTPSourceInformation added in v1.3.0

type BTPSourceInformation struct {
	SrcNetworkUID  string           `json:"srcNetworkUID"`
	NetworkTypeIDs []jsonrpc.HexInt `json:"networkTypeIDs"`
}

refer server/v3/api_v3.go:953 getBTPSourceInformation

type Block

type Block struct {
	BlockHash              jsonrpc.HexBytes  `json:"block_hash" validate:"required,t_hash"`
	Version                jsonrpc.HexInt    `json:"version" validate:"required,t_int"`
	Height                 int64             `json:"height" validate:"required,t_int"`
	Timestamp              int64             `json:"time_stamp" validate:"required,t_int"`
	Proposer               jsonrpc.HexBytes  `json:"peer_id" validate:"optional,t_addr_eoa"`
	PrevID                 jsonrpc.HexBytes  `json:"prev_block_hash" validate:"required,t_hash"`
	NormalTransactionsHash jsonrpc.HexBytes  `json:"merkle_tree_root_hash" validate:"required,t_hash"`
	Signature              jsonrpc.HexBytes  `json:"signature" validate:"optional,t_hash"`
	NormalTransactions     []json.RawMessage `json:"confirmed_transaction_list" `
}

refer block/blockv2.go blockv2.ToJSON

type BlockNotification added in v1.3.13

type BlockNotification struct {
	Hash    jsonrpc.HexBytes     `json:"hash"`
	Height  jsonrpc.HexInt       `json:"height"`
	Indexes [][]jsonrpc.HexInt   `json:"indexes,omitempty"`
	Events  [][][]jsonrpc.HexInt `json:"events,omitempty"`
	Logs    [][][]EventLog       `json:"logs,omitempty"`
}

type ClientV3

type ClientV3 struct {
	*JsonRpcClient
	DebugEndPoint string
	// contains filtered or unexported fields
}

jsonrpc client using echo commands reference server/v3/api_v3.go params reference server/v3/schema_v3.go response schema Block, ConfirmedTransaction, TransactionResult{EventLog, Failure}, ScoreApi,

func NewClientV3

func NewClientV3(endpoint string) *ClientV3

func (*ClientV3) Call

func (c *ClientV3) Call(param *v3.CallParam) (interface{}, error)

func (*ClientV3) Cleanup

func (c *ClientV3) Cleanup()

func (*ClientV3) EstimateStep

func (c *ClientV3) EstimateStep(param *v3.TransactionParamForEstimate) (*common.HexInt, error)

func (*ClientV3) GetBTPHeader added in v1.3.0

func (c *ClientV3) GetBTPHeader(param *v3.BTPMessagesParam) (string, error)

func (*ClientV3) GetBTPMessages added in v1.3.0

func (c *ClientV3) GetBTPMessages(param *v3.BTPMessagesParam) ([]string, error)

func (*ClientV3) GetBTPNetworkInfo added in v1.3.0

func (c *ClientV3) GetBTPNetworkInfo(param *v3.BTPQueryParam) (*BTPNetworkInfo, error)

func (*ClientV3) GetBTPNetworkTypeInfo added in v1.3.0

func (c *ClientV3) GetBTPNetworkTypeInfo(param *v3.BTPQueryParam) (*BTPNetworkTypeInfo, error)

func (*ClientV3) GetBTPProof added in v1.3.0

func (c *ClientV3) GetBTPProof(param *v3.BTPMessagesParam) (string, error)

func (*ClientV3) GetBTPSourceInformation added in v1.3.0

func (c *ClientV3) GetBTPSourceInformation() (*BTPSourceInformation, error)

func (*ClientV3) GetBalance

func (c *ClientV3) GetBalance(param *v3.AddressParam) (*jsonrpc.HexInt, error)

func (*ClientV3) GetBlockByHash

func (c *ClientV3) GetBlockByHash(param *v3.BlockHashParam) (*Block, error)

func (*ClientV3) GetBlockByHeight

func (c *ClientV3) GetBlockByHeight(param *v3.BlockHeightParam) (*Block, error)

func (*ClientV3) GetBlockHeaderByHeight

func (c *ClientV3) GetBlockHeaderByHeight(param *v3.BlockHeightParam) ([]byte, error)

func (*ClientV3) GetDataByHash

func (c *ClientV3) GetDataByHash(param *v3.DataHashParam) ([]byte, error)

using blockHeader.NextValidatorsHash

func (*ClientV3) GetLastBlock

func (c *ClientV3) GetLastBlock() (*Block, error)

func (*ClientV3) GetNetworkInfo added in v1.3.8

func (c *ClientV3) GetNetworkInfo() (*NetworkInfo, error)

func (*ClientV3) GetProofForEvents

func (c *ClientV3) GetProofForEvents(param *v3.ProofEventsParam) ([][][]byte, error)

func (*ClientV3) GetProofForResult

func (c *ClientV3) GetProofForResult(param *v3.ProofResultParam) ([][]byte, error)

refer common/trie/ompt/mtp.go mpt.GetProof(index)

func (*ClientV3) GetScoreApi

func (c *ClientV3) GetScoreApi(param *v3.ScoreAddressParam) ([]interface{}, error)

refer servicce/scoreapi/info.go Info.ToJSON

func (*ClientV3) GetScoreStatus added in v1.2.11

func (c *ClientV3) GetScoreStatus(param *v3.ScoreAddressParam) (interface{}, error)

func (*ClientV3) GetTotalSupply

func (c *ClientV3) GetTotalSupply(param *v3.HeightParam) (*jsonrpc.HexInt, error)

func (*ClientV3) GetTransactionByHash

func (c *ClientV3) GetTransactionByHash(param *v3.TransactionHashParam) (*Transaction, error)

func (*ClientV3) GetTransactionResult

func (c *ClientV3) GetTransactionResult(param *v3.TransactionHashParam) (*TransactionResult, error)

func (*ClientV3) GetVotesByHeight

func (c *ClientV3) GetVotesByHeight(param *v3.BlockHeightParam) ([]byte, error)

func (*ClientV3) Monitor

func (c *ClientV3) Monitor(reqUrl string, reqPtr, respPtr interface{},
	cb func(v interface{}), cancelCh <-chan bool) error

func (*ClientV3) MonitorBlock

func (c *ClientV3) MonitorBlock(param *server.BlockRequest, cb func(v *BlockNotification), cancelCh <-chan bool) error

func (*ClientV3) MonitorBtp added in v1.3.0

func (c *ClientV3) MonitorBtp(param *server.BTPRequest, cb func(v *server.BTPNotification), cancelCh <-chan bool) error

func (*ClientV3) MonitorEvent

func (c *ClientV3) MonitorEvent(param *server.EventRequest, cb func(v *EventNotification), cancelCh <-chan bool) error

func (*ClientV3) SendRawTransaction added in v0.9.6

func (c *ClientV3) SendRawTransaction(w module.Wallet, param map[string]interface{}) (*jsonrpc.HexBytes, error)

func (*ClientV3) SendSignedTransaction added in v1.3.9

func (c *ClientV3) SendSignedTransaction(param *v3.TransactionParam) (*jsonrpc.HexBytes, error)

func (*ClientV3) SendTransaction

func (c *ClientV3) SendTransaction(w module.Wallet, param *v3.TransactionParam) (*jsonrpc.HexBytes, error)

func (*ClientV3) WaitTransactionResult

func (c *ClientV3) WaitTransactionResult(param *v3.TransactionHashParam) (*TransactionResult, error)

type EventLog

type EventLog struct {
	Addr    jsonrpc.Address `json:"scoreAddress"`
	Indexed []*string       `json:"indexed"`
	Data    []*string       `json:"data"`
}

refer service/txresult/receipt.go:29 eventLogJSON

type EventNotification added in v1.3.13

type EventNotification struct {
	Hash   jsonrpc.HexBytes `json:"hash"`
	Height jsonrpc.HexInt   `json:"height"`
	Index  jsonrpc.HexInt   `json:"index"`
	Events []jsonrpc.HexInt `json:"events"`
	Logs   []EventLog       `json:"logs,omitempty"`
}

type FailureReason

type FailureReason struct {
	CodeValue    jsonrpc.HexInt `json:"code"`
	MessageValue string         `json:"message"`
}

refer service/txresult/receipt.go:193 failureReason

type HttpError

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

func (*HttpError) Error

func (e *HttpError) Error() string

func (*HttpError) Response

func (e *HttpError) Response() string

type JsonRpcClient

type JsonRpcClient struct {
	Endpoint     string
	CustomHeader map[string]string
	Pre          func(req *http.Request) error
	// contains filtered or unexported fields
}

func NewJsonRpcClient

func NewJsonRpcClient(hc *http.Client, endpoint string) *JsonRpcClient

func (*JsonRpcClient) Do

func (c *JsonRpcClient) Do(method string, reqPtr, respPtr interface{}) (jrResp *Response, err error)

func (*JsonRpcClient) DoURL added in v0.9.3

func (c *JsonRpcClient) DoURL(url string, method string, reqPtr, respPtr interface{}) (jrResp *Response, err error)

func (*JsonRpcClient) Raw

func (c *JsonRpcClient) Raw(reqB []byte) (resp *http.Response, err error)

type NetworkInfo added in v1.3.8

type NetworkInfo struct {
	Platform  string         `json:"platform"`
	NID       jsonrpc.HexInt `json:"nid"`
	Channel   string         `json:"channel"`
	Earliest  jsonrpc.HexInt `json:"earliest"`
	Latest    jsonrpc.HexInt `json:"latest"`
	StepPrice jsonrpc.HexInt `json:"stepPrice"`
}

type NormalTransaction

type NormalTransaction struct {
	TxHash    jsonrpc.HexBytes `json:"txHash"`
	Version   jsonrpc.HexInt   `json:"version"`
	From      jsonrpc.Address  `json:"from"`
	To        jsonrpc.Address  `json:"to"`
	Value     jsonrpc.HexInt   `json:"value,omitempty" `
	StepLimit jsonrpc.HexInt   `json:"stepLimit"`
	TimeStamp jsonrpc.HexInt   `json:"timestamp"`
	NID       jsonrpc.HexInt   `json:"nid,omitempty"`
	Nonce     jsonrpc.HexInt   `json:"nonce,omitempty"`
	Signature jsonrpc.HexBytes `json:"signature"`
	DataType  string           `json:"dataType,omitempty"`
	Data      json.RawMessage  `json:"data,omitempty"`
}

refer service/transaction/transaction_v3.go:24 transactionV3Data, transactionV3.ToJSON

type Response

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

type Transaction

type Transaction struct {
	NormalTransaction
	BlockHash   jsonrpc.HexBytes `json:"blockHash" validate:"required,t_hash"`
	BlockHeight jsonrpc.HexInt   `json:"blockHeight" validate:"required,t_int"`
	TxIndex     jsonrpc.HexInt   `json:"txIndex" validate:"required,t_int"`
}

refer server/v3/api_v3.go:307 getTransactionByHash

type TransactionResult

type TransactionResult struct {
	To                 jsonrpc.Address  `json:"to"`
	CumulativeStepUsed jsonrpc.HexInt   `json:"cumulativeStepUsed"`
	StepUsed           jsonrpc.HexInt   `json:"stepUsed"`
	StepPrice          jsonrpc.HexInt   `json:"stepPrice"`
	EventLogs          []EventLog       `json:"eventLogs"`
	LogsBloom          jsonrpc.HexBytes `json:"logsBloom"`
	Status             jsonrpc.HexInt   `json:"status"`
	Failure            *FailureReason   `json:"failure,omitempty"`
	SCOREAddress       jsonrpc.Address  `json:"scoreAddress,omitempty"`
	BlockHash          jsonrpc.HexBytes `json:"blockHash" validate:"required,t_hash"`
	BlockHeight        jsonrpc.HexInt   `json:"blockHeight" validate:"required,t_int"`
	TxIndex            jsonrpc.HexInt   `json:"txIndex" validate:"required,t_int"`
	TxHash             jsonrpc.HexBytes `json:"txHash" validate:"required,t_int"`
	StepDetails        interface{}      `json:"stepUsedDetails,omitempty"`
}

refer service/txresult/receipt.go:220 receiptJSON, receipt.ToJSON refer server/v3/api_v3.go:260 getTransactionResult

Jump to

Keyboard shortcuts

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