abiEncode method
Encodes a byte array to ABI-encoded bytes.
Implementation
@override
EncoderResult abiEncode(AbiParameter params, List<int> input) {
if (params.isDynamic) {
final parseLength = (input.length / ABIConst.uintBytesLength).ceil();
final encoded = List<int>.filled(
ABIConst.uintBytesLength + parseLength * ABIConst.uintBytesLength, 0);
final number = const NumbersCoder()
.abiEncode(AbiParameter.uint32, BigInt.from(input.length))
.encoded;
encoded.setAll(0, number);
encoded.setAll(ABIConst.uintBytesLength, input);
return EncoderResult(
isDynamic: true, encoded: encoded, name: params.name);
}
final size = _ABIUtils.bytesSize(params.type);
_ABIValidator.validateBytes(params.type,
bytes: input, minLength: size!, maxLength: size);
final bytes = List<int>.filled(ABIConst.uintBytesLength, 0);
bytes.setAll(0, input);
return EncoderResult(isDynamic: false, encoded: bytes, name: params.name);
}