parseQueryResponse method
List
parseQueryResponse({
- required SmartContractQueryResponse response,
- required String endpointName,
Decodes a raw SmartContractQueryResponse into native ABI values.
Requires ABI: the endpoint's declared output types drive the decoding.
Parameters
response- Raw query response fromnetworkProvider.queryContractendpointName- Endpoint name for output-type lookup
Returns
List of decoded native Dart values matching endpoint outputs.
Throws
- StateError if controller has no ABI
- EndpointNotFoundException if the endpoint is not in the ABI
Example
final raw = await provider.queryContract(query);
final values = controller.parseQueryResponse(
response: raw,
endpointName: 'getTotal',
);
Implementation
List<dynamic> parseQueryResponse({
required SmartContractQueryResponse response,
required String endpointName,
}) {
_requireAbiForEndpoints();
final AbiEndpoint? endpoint = abi.endpoints.getByName(endpointName);
if (endpoint == null) {
throw EndpointNotFoundException.withSuggestions(
endpointName: endpointName,
abi: abi,
);
}
final ResponseParser parser = ResponseParser(serializer: ArgSerializer());
final List<TypedValue> typed = parser.parseForEndpoint(
endpoint: endpoint,
returnData: response.returnDataParts,
);
return typed.map((TypedValue tv) => tv.nativeValue).toList();
}