-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support intent URL to start a new WalletConnect session #271
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d18b3f9
feat(android): add wallet connect deep link
manu0466 e29d1f8
feat: prepared wallet connect pair action logic
manu0466 c8f6c69
fix: props type
manu0466 94881cf
feat: centered text in loading modal
manu0466 7913aa7
feat: init wallet connect session from uri action
manu0466 c4408d9
feat(ios): add dpm url schema
manu0466 9383b98
feat: update walletconnect event parsing
manu0466 f54829b
refactor: remove session acknowledged
manu0466 8b2c952
refactor: renamed the function to parse the uri action received troug…
manu0466 e35d4fd
feat: use a recoil to store the UriAction to handle
manu0466 dee8dbc
refactor: use useRestToHomeScreen in UnlockApplication screen
manu0466 6b37272
feat: handle the returnToApp UriAction param
manu0466 8a60b9b
chore: fix typos
manu0466 7a910c5
feat: reject all the requests on WalletConnectRequest screen close
manu0466 651f54e
feat: improve handling of actions received while the app was in backg…
manu0466 6fd0709
feat: remove WalletConnect requests on error
manu0466 a892612
chore: removed wc intent uri
manu0466 3006a8d
chore(android): re added Web3Auth intent uri
manu0466 0a2538a
docs: fix grammar
manu0466 54cf25b
refactor: removed unsued url filed in WalletConnectSession
manu0466 6b8225e
chore: removed unused function
manu0466 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { setCachedUriAction, parseNativeActionUri } from 'lib/UriActions'; | ||
import React from 'react'; | ||
import { Linking } from 'react-native'; | ||
|
||
/** | ||
* Hook that initialize the logic to handle the | ||
* actions received from the Linking library. | ||
*/ | ||
const useInitLinkingUriActions = () => { | ||
const handleLinkingUrl = React.useCallback((url: string | null) => { | ||
if (url) { | ||
const action = parseNativeActionUri(url); | ||
if (action) { | ||
setCachedUriAction(action); | ||
} | ||
} | ||
}, []); | ||
|
||
React.useEffect(() => { | ||
// Handle the uri that has triggered the app open. | ||
Linking.getInitialURL().then(handleLinkingUrl); | ||
|
||
// Handle the uri received while the app was | ||
// in the background. | ||
const listener = Linking.addEventListener('url', ({ url }) => { | ||
handleLinkingUrl(url); | ||
}); | ||
|
||
return () => listener.remove(); | ||
}, [handleLinkingUrl]); | ||
}; | ||
|
||
export default useInitLinkingUriActions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { useAppState } from '@recoil/appState'; | ||
import { useUriAction } from '@recoil/uriaction'; | ||
import { useAllWalletConnectSessionsRequests } from '@recoil/walletConnectRequests'; | ||
import React from 'react'; | ||
import { useNavigation } from '@react-navigation/native'; | ||
import { RootNavigatorParamList } from 'navigation/RootNavigator'; | ||
import { StackNavigationProp } from '@react-navigation/stack'; | ||
import ROUTES from 'navigation/routes'; | ||
import useHandleUriAction from './uriactions/useHandleUriAction'; | ||
|
||
/** | ||
* Hook that provides the logic to handle the requests received | ||
* while the application was in background. | ||
* The actions that the app can receive while in background are: | ||
* - URIActions triggered by a deep link or from a system intent; | ||
* - WalletConnect session requests. | ||
*/ | ||
export default function useHandleReceivedActions() { | ||
const appState = useAppState(); | ||
|
||
const uriAction = useUriAction(); | ||
const handlingUriAction = React.useRef(false); | ||
const handleUriAction = useHandleUriAction(); | ||
|
||
const walletConnectRequests = useAllWalletConnectSessionsRequests(); | ||
const handlingWalletConnectRequests = React.useRef(false); | ||
const navigation = useNavigation<StackNavigationProp<RootNavigatorParamList>>(); | ||
|
||
React.useEffect(() => { | ||
// Prevent the execution if we are already handling an action. | ||
if (handlingUriAction.current) { | ||
if (uriAction === undefined) { | ||
handlingUriAction.current = false; | ||
} else { | ||
return; | ||
} | ||
} | ||
|
||
// Prevent the execution if we are handling the WalletConnect requests. | ||
if (handlingWalletConnectRequests.current) { | ||
if (walletConnectRequests.length === 0) { | ||
handlingWalletConnectRequests.current = false; | ||
} else { | ||
return; | ||
} | ||
} | ||
|
||
// Ensure that the app is active and unlocked before performing any operation. | ||
if (appState.locked === false && appState.lastObBlur === undefined) { | ||
// We give priority to uri actions received from a deep link | ||
// or a system intent. | ||
if (uriAction !== undefined) { | ||
handleUriAction(uriAction); | ||
handlingUriAction.current = true; | ||
return; | ||
} | ||
|
||
if (walletConnectRequests.length > 0) { | ||
// Navigate to the screen that handle the WalletConnect requests. | ||
navigation.navigate(ROUTES.WALLET_CONNECT_REQUEST); | ||
handlingWalletConnectRequests.current = true; | ||
} | ||
} | ||
}, [ | ||
appState.lastObBlur, | ||
appState.locked, | ||
handleUriAction, | ||
navigation, | ||
uriAction, | ||
walletConnectRequests, | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation of
useHandleWalletConnectPairAction
correctly handles the WalletConnect pairing process, including showing loading and error modals as appropriate. However, consider adding error logging for the case whenpairResult.isErr()
is true, to aid in debugging and monitoring.Committable suggestion