encode method

  1. @override
Uint8List encode(
  1. dynamic value
)
override

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) {
  final List<dynamic> values;
  if (value is List) {
    values = value;
  } else if (value is Map<String, dynamic> && names != null) {
    values = names!.map((n) => value[n]).toList();
  } else {
    throw ArgumentError('Expected List or Map for tuple encoding');
  }

  if (values.length != components.length) {
    throw ArgumentError(
        'Expected ${components.length} values, got ${values.length}');
  }

  return _encodeTuple(components, values);
}