JsonRpcContextMethod<S, T> class
abstract
JSON RPC Context Method Decoder
An interface for JsonRpcMethods that return a response-context
.
The valueDecoder defines how the value
property of a successful JSON RPC response-context is
mapped from S
to T
.
Example
class GetBalance extends JsonRpcContextMethod<int, int> {
GetBalance(this.pubkey): super('getBalance');
final String pubkey; // base-58 address.
@override int valueDecoder(final int value) => value;
@override Object? params([final Commitment? commitment]) => [pubkey];
}
final client = JsonRpcHttpClient(Cluster.devnet.uri);
final method = GetBalance('83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri');
final response = await client.send(method.request(), method.response);
print(jsonEncode(response)); // {"jsonrpc":"2.0","result":{"context":{"slot":1},"value":0},"id":1}
- Inheritance
-
- Object
- JsonRpcMethod<
Map< String, dynamic> , JsonRpcResponseContext<T> > - JsonRpcContextMethod
- Implementers
Constructors
- JsonRpcContextMethod.new(String method)
-
Creates a JSON RPC response-context decoder.
const
Properties
Methods
-
decoder(
Map< String, dynamic> value) → JsonRpcResponseContext<T> -
Decodes the
result
property of a successful JSON RPC response.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
params(
[Commitment? commitment]) → Object? -
Returns the JSON RPC request's
params
property value.inherited -
request(
[Commitment? commitment]) → JsonRpcRequest -
Creates a JsonRpcRequest to invoke method with params. The
commitment
level is provided as a default value to all methods that query bank state.inherited -
response(
Map< String, dynamic> json) → JsonRpcResponse<JsonRpcResponseContext< T> > -
Parses the
json
RPC response and returns the result.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
valueDecoder(
S value) → T -
Decodes the
value
property of a successful JSON RPC response-context.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited