launchConnectedWallet method

  1. @override
void launchConnectedWallet()
override

Opens the native wallet selectedWallet after connected

Implementation

@override
void launchConnectedWallet() async {
  _checkInitialized();

  final walletInfo = _explorerService.getConnectedWallet();
  if (walletInfo == null) {
    // if walletInfo is null could mean that either
    // 1. There's no wallet connected (shouldn't happen)
    // 2. Wallet is connected on another device through qr code
    return;
  }

  final isCoinbase = _currentSession!.sessionService.isCoinbase == true;
  if (walletInfo.isCoinbase || isCoinbase) {
    // Coinbase Wallet is getting launched at every request by it's own SDK
    // SO no need to do it here.
    return;
  }

  if (_currentSession!.sessionService.isMagic) {
    // There's no wallet to launch when connected with Email
    return;
  }

  final metadataRedirect = _currentSession!.peer?.metadata.redirect;

  final appLink = (metadataRedirect?.universal ?? '');
  final supportedApps = _appKit.core.getLinkModeSupportedApps();
  final isLinkMode = appLink.isNotEmpty && supportedApps.contains(appLink);
  if (isLinkMode) {
    // Opening peers during Link Mode requests is handled in Sign Engine
    return;
  }

  final walletRedirect = _explorerService.getWalletRedirect(
    walletInfo,
  );

  if (walletRedirect == null) {
    return;
  }

  try {
    final link = metadataRedirect?.native ?? metadataRedirect?.universal;
    _uriService.openRedirect(
      walletRedirect.copyWith(mobile: link),
      pType: PlatformUtils.getPlatformType(),
    );
  } catch (e) {
    onModalError.broadcast(ErrorOpeningWallet());
  }
}