params

package
v0.106.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFunctionInvocationScript

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

CreateFunctionInvocationScript creates a script to invoke the given contract with the 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 the reverse order.

func ExpandArrayIntoScriptAndPack

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

ExpandArrayIntoScriptAndPack expands provided array into script and packs the resulting items in the array.

func ExpandFuncParameterIntoScript added in v0.106.0

func ExpandFuncParameterIntoScript(script *io.BinWriter, fp FuncParam) error

ExpandFuncParameterIntoScript pushes provided FuncParam parameter into the given buffer.

func ExpandMapIntoScriptAndPack added in v0.106.0

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

ExpandMapIntoScriptAndPack expands provided array of key-value items into script and packs the resulting pairs in the [stackitem.Map].

Types

type Batch

type Batch []In

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

type FuncParam

type FuncParam struct {
	Type  smartcontract.ParamType `json:"type"`
	Value Param                   `json:"value"`
}

FuncParam represents a function argument parameter used in the invokefunction RPC method.

type FuncParamKV added in v0.106.0

type FuncParamKV struct {
	Key   FuncParam `json:"key"`
	Value FuncParam `json:"value"`
}

FuncParamKV represents a pair of function argument parameters a slice of which is stored in FuncParam of smartcontract.MapType type.

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 Param

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

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

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 a big-integer value of the parameter.

func (*Param) GetBoolean

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

GetBoolean returns a boolean value of the parameter or tries to cast the 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)

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

func (*Param) GetBytesHex

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

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

func (*Param) GetFuncParam

func (p *Param) GetFuncParam() (FuncParam, error)

GetFuncParam returns the current parameter as a function call parameter.

func (*Param) GetFuncParamPair added in v0.106.0

func (p *Param) GetFuncParamPair() (FuncParamKV, error)

GetFuncParamPair returns a pair of function call parameters.

func (*Param) GetInt

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

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

func (*Param) GetIntStrict

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

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

func (*Param) GetSignerWithWitness

func (p *Param) GetSignerWithWitness() (neorpc.SignerWithWitness, error)

GetSignerWithWitness returns a neorpc.SignerWithWitness value of the parameter.

func (*Param) GetSignersWithWitnesses

func (p *Param) GetSignersWithWitnesses() ([]transaction.Signer, []transaction.Witness, error)

GetSignersWithWitnesses returns a slice of SignerWithWitness with CalledByEntry scope from an array of Uint160 or an array of serialized transaction.Signer stored in the parameter.

func (*Param) GetString

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

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

func (*Param) GetStringStrict

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

GetStringStrict returns a string value of the parameter.

func (*Param) GetUUID

func (p *Param) GetUUID() (uuid.UUID, error)

GetUUID returns UUID from parameter.

func (*Param) GetUint160FromAddress

func (p *Param) GetUint160FromAddress() (util.Uint160, error)

GetUint160FromAddress returns a Uint160 value of the parameter that was supplied as an address.

func (*Param) GetUint160FromAddressOrHex

func (p *Param) GetUint160FromAddressOrHex() (util.Uint160, error)

GetUint160FromAddressOrHex returns a Uint160 value of the parameter that was supplied either as raw hex or as an address.

func (*Param) GetUint160FromHex

func (p *Param) GetUint160FromHex() (util.Uint160, error)

GetUint160FromHex returns a Uint160 value of the parameter encoded in hex.

func (*Param) GetUint256

func (p *Param) GetUint256() (util.Uint256, error)

GetUint256 returns a Uint256 value of the parameter.

func (*Param) IsNull

func (p *Param) IsNull() bool

IsNull returns whether the 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 FromAny added in v0.101.1

func FromAny(arr []any) (Params, error)

FromAny allows to create Params for a slice of abstract values (by JSON-marshaling them).

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 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 the json.Marshaler interface.

func (*Request) UnmarshalJSON

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

UnmarshalJSON implements the json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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