WalletConnect / Web3ModalFlutter

The Web3Modal for WalletConnect built using Flutter.
https://pub.dev/packages/web3modal_flutter
Apache License 2.0
27 stars 30 forks source link

fix: deeplink url format #111

Closed MuckT closed 1 month ago

MuckT commented 1 month ago

Description

We've received several reports of users unable to link to Valora using Web3ModalFlutter in our discord.

After investigation it appears the URL format is missing an / character and parsing incorrectly. This should fix that integration and match the deeplinks created by other WalletConnect Web3Modal implementations.

Before: celo://walletwc?uri=wc... After: celo://wallet/wc?uri=wc...

quetool commented 1 month ago

Hello @MuckT! Thanks for bringing this to my attention and I apologize for any inconvenience this may have caused! Indeed I was making some changes on core_utils lately in regards of this. However the fix should be done on createSafeUrl() function as follow:

  @override
  String createSafeUrl(String url) {
    if (url.isEmpty) return url;

    String safeUrl = url;
    if (!safeUrl.contains('://')) {
      safeUrl = url.replaceAll('/', '').replaceAll(':', '');
      safeUrl = '$safeUrl://';
    } else {
      final parts = safeUrl.split('://');
      if (parts.last.isNotEmpty && parts.last != 'wc') {
        if (!safeUrl.endsWith('/')) {
          return '$safeUrl/';
        }
        return safeUrl;
      } else {
        safeUrl = url.replaceFirst('://wc', '://');
      }
    }
    return safeUrl;
  }

If you are willing to change your code into this one I will totally merge it and deploy it in following version. That being said, it may take some time for every dapp to adopt the new version so wouldn't be fair that you pass celo://wallet/ instead of celo://wallet in your metadata's redirect object? You can leverage CodePush and will be much faster.

MuckT commented 1 month ago

@quetool adjusted the PR in 34674336c9a25b51d2e12fb6635a60c33165bf18.

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud