decode method
Decodes a tuple of dynamic values from the given ABI-encoded bytes.
Implementation
@override
DecoderResult<List<dynamic>> decode(AbiParameter params, List<int> bytes) {
int consumed = 0;
if (params.components.isEmpty) {
return DecoderResult(result: [], consumed: consumed);
}
int dynamicConsumed = 0;
List<dynamic> result = [];
for (int index = 0; index < params.components.length; index++) {
AbiParameter childParam = params.components[index];
DecoderResult<dynamic> decodedResult;
if (childParam.isDynamic) {
DecoderResult<BigInt> offsetResult = const NumbersCoder().decode(
AbiParameter.uint32,
bytes.sublist(consumed),
);
decodedResult = _ABIUtils.decodeParamFromAbiParameter(
childParam,
bytes.sublist(offsetResult.result.toInt()),
);
consumed += offsetResult.consumed;
dynamicConsumed += decodedResult.consumed;
} else {
decodedResult = _ABIUtils.decodeParamFromAbiParameter(
childParam, bytes.sublist(consumed));
consumed += decodedResult.consumed;
}
result.add(decodedResult.result);
}
return DecoderResult(result: result, consumed: consumed + dynamicConsumed);
}