sendResult method

  1. @override
Future sendResult(
  1. int id,
  2. String topic,
  3. String method,
  4. dynamic result, {
  5. EncodeOptions? encodeOptions,
  6. String? appLink,
})
override

Implementation

@override
Future<dynamic> sendResult(
  int id,
  String topic,
  String method,
  dynamic result, {
  EncodeOptions? encodeOptions,
  String? appLink,
}) async {
  final payload = JsonRpcUtils.formatJsonRpcResponse<dynamic>(
    id,
    result,
  );

  final String? message = await core.crypto.encode(
    topic,
    payload,
    options: encodeOptions,
  );

  if (message == null) {
    return;
  }

  core.logger.d(
    '[$runtimeType] sendRequest appLink: $appLink, '
    'id: $id topic: $topic, method: $method, result: $result',
  );
  if ((appLink ?? '').isNotEmpty) {
    final redirectURL = ReownCoreUtils.getLinkModeURL(
      appLink!,
      topic,
      message,
    );
    await ReownCoreUtils.openURL(redirectURL);
  } else {
    final RpcOptions opts = MethodConstants.RPC_OPTS[method]!['res']!;
    await core.relayClient.publish(
      topic: topic,
      message: message,
      ttl: opts.ttl,
      tag: opts.tag,
    );
  }
}