getPrincipal method

  1. @override
Future<Principal> getPrincipal()
override

Returns the principal ID associated with this agent (by default). It only shows the principal of the default identity in the agent, which is the principal used when calls don't specify it.

Implementation

@override
Future<Principal> getPrincipal() async {
  return _sendAndWait(
    ProxyMessageGetPrincipal.fromJson({
      'id': _nextId++,
      'type': ProxyMessageKind.getPrincipal,
    }),
  ).then((principal) {
    if (principal is! String) {
      throw ArgumentError.value(
        principal,
        'Principal',
        'Invalid principal received',
      );
    }
    return Principal.fromText(principal);
  });
}