create static method

Future<DelegationChain> create(
  1. SignIdentity from,
  2. PublicKey to,
  3. DateTime? expiration, {
  4. DelegationChain? previous,
  5. List<Principal>? targets,
})

Create a delegation chain between two (or more) keys. By default, the expiration time will be very short (15 minutes).

To build a chain of more than 2 identities, this function needs to be called multiple times, passing the previous delegation chain into the options argument.

Implementation

static Future<DelegationChain> create(
  SignIdentity from,
  PublicKey to,
  DateTime? expiration, {
  DelegationChain? previous,
  List<Principal>? targets,
}) async {
  expiration ??= DateTime.now().add(const Duration(minutes: 15));
  final delegation = await _createSingleDelegation(
    from,
    to,
    expiration,
    targets,
  );
  return DelegationChain(
    [...?previous?.delegations, delegation],
    previous?.publicKey ?? from.getPublicKey().toDer(),
  );
}