request

package
v0.0.0-...-f94ef0f Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JSONRPCVersion is the only JSON-RPC protocol version supported.
	JSONRPCVersion = "2.0"
)

Variables

This section is empty.

Functions

func CreateFunctionInvocationScript

func CreateFunctionInvocationScript(contract common.Address, method string, param *Param) ([]byte, error)

CreateFunctionInvocationScript creates a script to invoke given contract with given parameters.

func ExpandArrayIntoScript

func ExpandArrayIntoScript(script *io.BinWriter, slice []Param) error

ExpandArrayIntoScript pushes all FuncParam parameters from the given array into the given buffer in reverse order.

Types

type Batch

type Batch []In

Batch represents a standard JSON-RPC 2.0 batch: https://www.jsonrpc.org/specification#batch.

type BlockFilter

type BlockFilter struct {
	Primary int `json:"primary"`
}

BlockFilter is a wrapper structure for block event filter. The only allowed filter is primary index.

type ExecutionFilter

type ExecutionFilter struct {
	State uint64 `json:"state"`
}

ExecutionFilter is a wrapper structure used for transaction execution events. It allows to choose failing or successful transactions based on their VM state.

type In

type In struct {
	JSONRPC   string          `json:"jsonrpc"`
	Method    string          `json:"method"`
	RawParams []Param         `json:"params,omitempty"`
	RawID     json.RawMessage `json:"id,omitempty"`
}

In represents a standard JSON-RPC 2.0 request: http://www.jsonrpc.org/specification#request_object.

func NewIn

func NewIn() *In

NewIn creates a new In struct.

type NotificationFilter

type NotificationFilter struct {
	Contract *common.Address `json:"contract,omitempty"`
}

NotificationFilter is a wrapper structure representing filter used for notifications generated during transaction execution. Notifications can be filtered by contract hash and by name.

type Param

type Param struct {
	json.RawMessage
	// contains filtered or unexported fields
}

Param represents a param either passed to the server or to send to a server using the client.

func (*Param) GetAddressFromHex

func (p *Param) GetAddressFromHex() (common.Address, error)

GetUint160FromHex returns Uint160 value of the parameter encoded in hex.

func (*Param) GetArray

func (p *Param) GetArray() ([]Param, error)

GetArray returns a slice of Params stored in the parameter.

func (*Param) GetBigInt

func (p *Param) GetBigInt() (*big.Int, error)

GetBigInt returns big-interer value of the parameter.

func (*Param) GetBoolean

func (p *Param) GetBoolean() (bool, error)

GetBoolean returns boolean value of the parameter or tries to cast parameter to a bool value.

func (*Param) GetBooleanStrict

func (p *Param) GetBooleanStrict() (bool, error)

GetBooleanStrict returns boolean value of the parameter.

func (*Param) GetBytesBase64

func (p *Param) GetBytesBase64() ([]byte, error)

func (*Param) GetBytesHex

func (p *Param) GetBytesHex() ([]byte, error)

GetBytesHex returns []byte value of the parameter if it is a hex-encoded string.

func (*Param) GetHash

func (p *Param) GetHash() (common.Hash, error)

GetUint256 returns Uint256 value of the parameter.

func (*Param) GetInt

func (p *Param) GetInt() (int, error)

GetInt returns int value of the parameter or tries to cast parameter to an int value.

func (*Param) GetIntStrict

func (p *Param) GetIntStrict() (int, error)

GetIntStrict returns int value of the parameter if the parameter is integer.

func (*Param) GetString

func (p *Param) GetString() (string, error)

GetString returns string value of the parameter or tries to cast parameter to a string value.

func (*Param) GetStringStrict

func (p *Param) GetStringStrict() (string, error)

GetStringStrict returns string value of the parameter.

func (*Param) IsNull

func (p *Param) IsNull() bool

IsNull returns whether parameter represents JSON nil value.

func (Param) String

func (p Param) String() string

type Params

type Params []Param

Params represents the JSON-RPC params.

func (Params) String

func (p Params) String() string

func (Params) Value

func (p Params) Value(index int) *Param

Value returns the param struct for the given index if it exists.

type Raw

type Raw struct {
	JSONRPC   string        `json:"jsonrpc"`
	Method    string        `json:"method"`
	RawParams []interface{} `json:"params"`
	ID        uint64        `json:"id"`
}

Raw represents JSON-RPC request on the Client side.

type RawParams

type RawParams struct {
	Values []interface{}
}

RawParams is just a slice of abstract values, used to represent parameters passed from client to server.

func NewRawParams

func NewRawParams(vals ...interface{}) RawParams

NewRawParams creates RawParams from its parameters.

type Request

type Request struct {
	In    *In
	Batch Batch
}

Request contains standard JSON-RPC 2.0 request and batch of requests: http://www.jsonrpc.org/specification. It's used in server to represent incoming queries.

func NewRequest

func NewRequest() *Request

NewRequest creates a new Request struct.

func (*Request) DecodeData

func (r *Request) DecodeData(data io.ReadCloser) error

DecodeData decodes the given reader into the the request struct.

func (Request) MarshalJSON

func (r Request) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Request) UnmarshalJSON

func (r *Request) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface.

type SignerWithWitness

type SignerWithWitness struct {
	Signer common.Address
	transaction.Witness
}

SignerWithWitness represents transaction's signer with the corresponding witness.

type TxFilter

type TxFilter struct {
	Sender *common.Address `json:"sender,omitempty"`
}

TxFilter is a wrapper structure for transaction event filter. It allows to filter transactions by senders and signers.

Jump to

Keyboard shortcuts

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