encodeValue method

  1. @override
Uint8List encodeValue(
  1. List x
)
override

Encode the value. This needs to be public because it is used by encodeValue() from different types. @internal

Implementation

@override
Uint8List encodeValue(x) {
  // [PrincipalId, string]
  final hex = (x[0] as PrincipalId).toHex();
  final buf = hex.toU8a();
  final len = lebEncode(buf.length);
  final canister = u8aConcat([
    Uint8List.fromList([1]),
    len,
    buf,
  ]);

  final method = Uint8List.fromList(
    (x[1] as String).plainToU8a(useDartEncode: true),
  );
  final methodLen = lebEncode(method.length);
  return u8aConcat([
    Uint8List.fromList([1]),
    canister,
    methodLen,
    method,
  ]);
}