encode method
Implementation
@override
Uint8List encode(Object value) {
if (value is Hash) {
return value.bytes;
}
if (value is Uint8List) {
return rightPadBytes(value, SolidityType.int32Size);
}
if (value is num) {
final bigInt = BigInt.from(value);
return IntType.encodeFromBigInt(bigInt);
}
if (value is String) {
var hex = value.toLowerCase().trim();
if (hex.startsWith('0x')) {
hex = hex.substring(2);
}
final bytes = hexToBytes(hex);
return rightPadBytes(bytes, SolidityType.int32Size);
}
throw Exception('Can\'t encode type ${value.runtimeType} to $name');
}