diff --git a/cw_core/lib/wallet_info.dart b/cw_core/lib/wallet_info.dart index 4892f6d1d..2768fdc6e 100644 --- a/cw_core/lib/wallet_info.dart +++ b/cw_core/lib/wallet_info.dart @@ -154,9 +154,11 @@ class WalletInfo extends HiveObject { @HiveField(15) List? usedAddresses; + @deprecated @HiveField(16) DerivationType? derivationType; // no longer used + @deprecated @HiveField(17) String? derivationPath; // no longer used diff --git a/lib/src/screens/root/root.dart b/lib/src/screens/root/root.dart index 8a75b78bb..e3472f510 100644 --- a/lib/src/screens/root/root.dart +++ b/lib/src/screens/root/root.dart @@ -52,6 +52,7 @@ class RootState extends State with WidgetsBindingObserver { StreamSubscription? stream; ReactionDisposer? _walletReactionDisposer; + ReactionDisposer? _deepLinksReactionDisposer; Uri? launchUri; @override @@ -76,6 +77,7 @@ class RootState extends State with WidgetsBindingObserver { void dispose() { stream?.cancel(); _walletReactionDisposer?.call(); + _deepLinksReactionDisposer?.call(); super.dispose(); } @@ -93,10 +95,32 @@ class RootState extends State with WidgetsBindingObserver { } } - void handleDeepLinking(Uri? uri) { + void handleDeepLinking(Uri? uri) async { if (uri == null || !mounted) return; launchUri = uri; + + bool requireAuth = await widget.authService.requireAuth(); + + if (!requireAuth && widget.authenticationStore.state == AuthenticationState.allowed) { + _navigateToDeepLinkScreen(); + return; + } + + _deepLinksReactionDisposer = reaction( + (_) => widget.authenticationStore.state, + (AuthenticationState state) { + if (state == AuthenticationState.allowed) { + if (widget.appStore.wallet == null) { + waitForWalletInstance(context, launchUri!); + } else { + _navigateToDeepLinkScreen(); + } + _deepLinksReactionDisposer?.call(); + _deepLinksReactionDisposer = null; + } + }, + ); } @override @@ -172,35 +196,8 @@ class RootState extends State with WidgetsBindingObserver { }, ); }); - } else if (_isValidPaymentUri()) { - if (widget.authenticationStore.state == AuthenticationState.uninitialized) { - launchUri = null; - } else { - if (widget.appStore.wallet == null) { - waitForWalletInstance(context, launchUri!); - launchUri = null; - } else { - widget.navigatorKey.currentState?.pushNamed( - Routes.send, - arguments: PaymentRequest.fromUri(launchUri), - ); - launchUri = null; - } - } - launchUri = null; - } else if (isWalletConnectLink) { - if (isEVMCompatibleChain(widget.appStore.wallet!.type)) { - widget.navigatorKey.currentState?.pushNamed( - Routes.walletConnectConnectionsListing, - arguments: launchUri, - ); - launchUri = null; - } else { - _nonETHWalletErrorToast(S.current.switchToEVMCompatibleWallet); - } } - launchUri = null; return WillPopScope( onWillPop: () async => false, child: widget.child, @@ -252,13 +249,10 @@ class RootState extends State with WidgetsBindingObserver { WidgetsBinding.instance.addPostFrameCallback((_) { if (context.mounted) { _walletReactionDisposer = reaction( - (_) => widget.appStore.wallet, - (WalletBase? wallet) { + (_) => widget.appStore.wallet, + (WalletBase? wallet) { if (wallet != null) { - widget.navigatorKey.currentState?.pushNamed( - Routes.send, - arguments: PaymentRequest.fromUri(tempLaunchUri), - ); + _navigateToDeepLinkScreen(); _walletReactionDisposer?.call(); _walletReactionDisposer = null; } @@ -267,4 +261,16 @@ class RootState extends State with WidgetsBindingObserver { } }); } + + void _navigateToDeepLinkScreen() { + if (_getRouteToGo() != null) { + WidgetsBinding.instance.addPostFrameCallback((_) { + widget.navigatorKey.currentState?.pushNamed( + _getRouteToGo()!, + arguments: isWalletConnectLink ? launchUri : PaymentRequest.fromUri(launchUri), + ); + launchUri = null; + }); + } + } }