encodePacked method

  1. @override
EncoderResult encodePacked(
  1. AbiParameter params,
  2. Object input
)
override

Legacy EIP-712 encoding for byte arrays. Optionally keeps the size unchanged based on the keepSize parameter.

Implementation

@override
EncoderResult encodePacked(AbiParameter params, Object input) {
  final inputAsBytes = JsonParser.valueAsBytes<List<int>>(
    input,
    allowHex: true,
  );
  final size = ABIUtils._bytesSize(params.type);
  if (size != null && inputAsBytes.length != size) {
    throw const SolidityAbiException('Invalid bytes length');
  }
  return EncoderResult(
    isDynamic: false,
    encoded: inputAsBytes,
    name: params.name,
  );
}