encode method
ABI-encode value as a 32-byte-aligned Uint8List.
For dynamic types, returns the tail; the caller places the offset in the head.
Implementation
@override
Uint8List encode(dynamic value) {
Uint8List bytes;
if (value is Uint8List) {
bytes = value;
} else if (value is String) {
bytes = hexDecode(value);
} else {
throw ArgumentError('Expected Uint8List or hex String, got ${value.runtimeType}');
}
if (bytes.length != length) {
throw ArgumentError('bytes$length expects $length bytes, got ${bytes.length}');
}
// Right-padded to 32 bytes (per ABI spec, unlike address which is left-padded).
final out = Uint8List(32);
out.setRange(0, length, bytes);
return out;
}