decode method

  1. @override
Object decode(
  1. Uint8List encoded
)
override

Decode ABI encoded byte array to dart values from ABI type schemes @param encoded byte array of ABI encoding @throws IllegalArgumentException if encoded byte array cannot match with ABI encoding rules

Implementation

@override
Object decode(Uint8List encoded) {
  final encodedLength = AbiType.getLengthEncoded(encoded);
  final encodedString = AbiType.getContentEncoded(encoded);
  if (BigIntEncoder.decodeBytesToUint(encodedLength) !=
      BigInt.from(encodedString.length)) {
    throw ArgumentError(
        'string decode failure: encoded bytes do not match with length header');
  }

  return utf8.decode(encodedString);
}