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) {
  if (encoded.length != 1) {
    throw ArgumentError(
        'cannot decode abi bool value, byte length do not match');
  }

  if (encoded[0] == 0x80) {
    return true;
  } else if (encoded[0] == 0x00) {
    return false;
  }

  throw ArgumentError('cannot decode abi bool value, illegal encoding value');
}