decodePrincipalId function

PrincipalId decodePrincipalId(
  1. Pipe b
)

Implementation

PrincipalId decodePrincipalId(Pipe b) {
  final x = Uint8List.fromList(safeRead(b as Pipe<int>, 1)).toHex();
  if (x != '01') {
    throw ArgumentError('Cannot decode principal $x.');
  }
  final len = lebDecode(b).toInt();
  final hex = Uint8List.fromList(safeRead(b, len)).toHex().toUpperCase();
  return PrincipalId.fromHex(hex);
}