create method

  1. @override
Future<PairingCreated> create()
override

Implementation

@override
Future<PairingCreated> create() async {
  _isInitialized();
  final symKey = generateRandomBytes32();
  final topic = await core.crypto.setSymKey(symKey: symKey);
  final expiry = calcExpiry(ttl: FIVE_MINUTES);
  final relay = RelayerProtocolOptions(protocol: RELAYER_DEFAULT_PROTOCOL);
  final pairing = PairingStruct(
    topic: topic,
    expiry: expiry,
    relay: relay,
    active: false,
  );
  final uri = formatUri(EngineUriParameters(
    protocol: core.protocol,
    version: core.version,
    topic: topic,
    symKey: symKey,
    relay: relay,
  ));
  await pairings.set(topic, pairing);
  await core.relayer.subscribe(topic: topic);
  core.expirer.set(topic, expiry);

  return PairingCreated(topic: topic, uri: uri);
}