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}');
}
// Length prefix (32 bytes) + data padded to 32-byte boundary.
final paddedLen = _padTo32(bytes.length);
final out = Uint8List(32 + paddedLen);
_writeUint256(out, 0, BigInt.from(bytes.length));
out.setRange(32, 32 + bytes.length, bytes);
return out;
}