[Flutter (Android)]: When using wallet_connect_v2 to connect with MetaMask, there is a delay before the connection alert is displayed.
Describe the bug When using wallet_connect_v2 flutter package to connect with Metamask, the connect alert is shown after few seconds. This might confuse users if the wallet connect is working or it have failed.
To Reproduce Steps to reproduce the behavior
- Create a flutter app and implement wallet_connect_v2 with the app.
- Try connecting with metamask and you will be able to see the delay before connect alert is shown
Expected behavior The Connect Alert should be shown as soon as the app opens after adding password or scanning fingerprint
Smartphone (please complete the following information):
- Device: [e.g. Samsung Galaxy J6, Samsung Galaxy A12]
Hello, @Rohitbagul003. Thanks for reporting! I will pass this on to the team.
It may be due to slow wc relay server, & may not be related to wallet app, have you tried with any other wc v2 wallet?
Hey @imaksp am using this package - https://pub.dev/packages/walletconnect_flutter_v2
And this is my code, my using the default relay server the package use in there example
Future<void> createWalletConnectV2Instance() async {
try {
debugPrint("intializing");
web3app = await Web3App.createInstance(
relayUrl: 'wss://relay.walletconnect.com',
projectId: '68a8e2955516fa9847a032b3e4b0bdf5',
metadata: const PairingMetadata(
name: "hashmail",
description: "your personal web3 mailbox",
url: "https://www.hashmail.dev/",
icons: ["https://wagmi.sh/icon.png"],
),
);
debugPrint("initialized");
} catch (err, stackTrace) {
debugPrint("catch err $stackTrace");
}
}
_walletConnectV2({String? deepLink}) async {
if (web3app == null) await createWalletConnectV2Instance();
try {
ConnectResponse? resp = await web3app?.connect(requiredNamespaces: {
'eip155': const RequiredNamespace(
chains: ["eip155:1"], // Ethereum chain
methods: ['personal_sign', 'eth_sign', 'eth_sendTransaction'], // Requestable Methods
events: ["chainChanged", "accountsChanged"], // Requestable Events
)
});
uri = resp?.uri;
url = uri.toString();
if (deepLink != null) {
final link = formatNativeUrl(deepLink, uri.toString());
url = link.toString();
}
await launchUrl(Uri.parse(url.toString()), mode: LaunchMode.externalNonBrowserApplication);
debugPrint("returning the wallet response $url");
ses = (await resp?.session.future);
log("SessionData ----> ${ses.toString()}");
final String address = NamespaceUtils.getAccount(
ses?.namespaces.values.first.accounts.first ?? "",
);
// if (resp.session.isCompleted) {
debugPrint("calling onConnected function :- ${resp?.session.isCompleted}");
debugPrint("---> $address");
account = address;
// onConnected != null ? onConnected() : () {};
// }
} catch (err, s) {
debugPrint("error connecting wallet -----> $err, $s");
}
}
Uri? formatNativeUrl(String? deepLink, String wcUri) {
String safeAppUrl = deepLink ?? "";
if (deepLink != null && deepLink.isNotEmpty) {
if (!safeAppUrl.contains('://')) {
safeAppUrl = deepLink.replaceAll('/', '').replaceAll(':', '');
safeAppUrl = '$safeAppUrl://';
}
}
String encodedWcUrl = Uri.encodeComponent(wcUri);
debugPrint('Encoded WC URL: $encodedWcUrl');
return Uri.parse('$safeAppUrl$encodedWcUrl');
}
@imaksp i have tried different wallets like rainbow, zerion, imToken, trustwallet and they show the connect alert instantly when the app opens.., And i used the same above code for this Can you suggest something to fix this?
Ok, not sure about exact cause, have you tried connecting from here (it uses web QR based flow) https://react-app.walletconnect.com/ for me it is fast most of the time using this flow, not checked mobile app deep link based flow yet. but it is possible that in low end devices (like Galaxy J2, A2) Metamask app is taking longer time to finish startup processes (if opened from deeplink) & because of it there might be a delay. & it is possible that other wallet apps might be taking lesser time to start.
I tried scanning with my Samsung J6 device For rainbow it showed the connect dialogue... but for metamask it didn't popped up even after i waited for a significant amount of time
hey @imaksp i also tested qr scan connection on Vivo v1933 with this link:- https://react-app.walletconnect.com/ And it shows the connection alert instantly but if i go through deep link its still takes a delay of 6 7 sec, the speed is better than the Samsung J6 but still need to fix this for low spec devices... As when i worked with wallet_connect_v1 it was instant so....
Hi @Rohitbagul003 ! The current live version of MetaMask (7.21.0) contains fix for WalletConnect popup delays. Can yo please try with that one?
HI all! I'm going to close this issue due to inactivity. Please feel free to open a new issue at any time.