pair method

  1. @override
Future<PairingStruct> pair({
  1. required String uri,
  2. bool activatePairing = false,
})
override

Implementation

@override
Future<PairingStruct> pair({
  required String uri,
  bool activatePairing = false,
}) async {
  _isInitialized();
  _isValidPair(uri);
  final uriParams = parseUri(uri);
  final expiry = calcExpiry(ttl: FIVE_MINUTES);
  final pairing = PairingStruct(
    topic: uriParams.topic,
    expiry: expiry,
    relay: uriParams.relay,
    active: false,
  );
  await pairings.set(uriParams.topic, pairing);
  await core.crypto
      .setSymKey(symKey: uriParams.symKey, overrideTopic: uriParams.topic);
  await core.relayer.subscribe(
    topic: uriParams.topic,
    opts: RelayerSubscribeOptions(relay: uriParams.relay),
  );
  core.expirer.set(uriParams.topic, expiry);

  if (activatePairing) {
    await activate(topic: uriParams.topic);
  }

  return pairing;
}