Skip to content

Commit

Permalink
Merge branch 'main' into feat/notifications-onboarding-wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathansoufer authored Apr 19, 2024
2 parents 403c952 + 0922dd2 commit 6a598a3
Show file tree
Hide file tree
Showing 23 changed files with 792 additions and 344 deletions.
32 changes: 20 additions & 12 deletions app/components/Views/AccountConnect/AccountConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import {
import AccountConnectMultiSelector from './AccountConnectMultiSelector';
import AccountConnectSingle from './AccountConnectSingle';
import AccountConnectSingleSelector from './AccountConnectSingleSelector';
import DevLogger from '../../../core/SDKConnect/utils/DevLogger';
const createStyles = () =>
StyleSheet.create({
fullScreenModal: {
Expand Down Expand Up @@ -109,7 +110,9 @@ const AccountConnect = (props: AccountConnectProps) => {
: AvatarAccountType.JazzIcon,
);

const { id: channelId, origin: metadataOrigin } = hostInfo.metadata as {
// on inappBrowser: hostname
// on sdk or walletconnect: channelId
const { origin: channelIdOrHostname } = hostInfo.metadata as {
id: string;
origin: string;
};
Expand All @@ -120,7 +123,9 @@ const AccountConnect = (props: AccountConnectProps) => {
const [hostname, setHostname] = useState<string>(origin);

const urlWithProtocol = prefixUrlWithProtocol(hostname);
const sdkConnection = SDKConnect.getInstance().getConnection({ channelId });
const sdkConnection = SDKConnect.getInstance().getConnection({
channelId: channelIdOrHostname,
});
// Last wallet connect session metadata
const wc2Metadata = useSelector((state: RootState) => state.sdk.wc2Metadata);

Expand Down Expand Up @@ -175,21 +180,24 @@ const AccountConnect = (props: AccountConnectProps) => {
// walletconnect channelId format: 1713357238460272
// sdk channelId format: uuid
// inappbrowser channelId format: app.uniswap.io

DevLogger.log(
`AccountConnect::loadHostname hostname=${hostname} origin=${origin} metadataOrigin=${channelIdOrHostname}`,
sdkConnection,
);
// check if channelId contains dot, it comes from in-app browser and we can use it.
if (channelId.indexOf('.') !== -1) {
if (channelIdOrHostname.indexOf('.') !== -1) {
return origin;
}

if (sdkConnection) {
const _hostname = (
sdkConnection?.originatorInfo?.url ?? metadataOrigin
sdkConnection?.originatorInfo?.url ?? channelIdOrHostname
).replace(AppConstants.MM_SDK.SDK_REMOTE_ORIGIN, '');
return _hostname;
}

return wc2Metadata?.url ?? channelId;
}, [channelId, metadataOrigin, sdkConnection, origin, wc2Metadata]);
return wc2Metadata?.url ?? channelIdOrHostname;
}, [hostname, channelIdOrHostname, sdkConnection, origin, wc2Metadata]);

// Retrieve hostname info based on channelId
useEffect(() => {
Expand All @@ -212,10 +220,10 @@ const AccountConnect = (props: AccountConnectProps) => {
const cancelPermissionRequest = useCallback(
(requestId) => {
Engine.context.PermissionController.rejectPermissionsRequest(requestId);
if (channelId && accountsLength === 0) {
if (channelIdOrHostname && accountsLength === 0) {
// Remove Potential SDK connection
SDKConnect.getInstance().removeChannel({
channelId,
channelId: channelIdOrHostname,
sendTerminate: true,
});
}
Expand All @@ -228,7 +236,7 @@ const AccountConnect = (props: AccountConnectProps) => {
[
Engine.context.PermissionController,
accountsLength,
channelId,
channelIdOrHostname,
trackEvent,
],
);
Expand Down Expand Up @@ -288,7 +296,7 @@ const AccountConnect = (props: AccountConnectProps) => {
...hostInfo,
metadata: {
...hostInfo.metadata,
origin: metadataOrigin,
origin: channelIdOrHostname,
},
approvedAccounts: selectedAccounts,
};
Expand Down Expand Up @@ -351,7 +359,7 @@ const AccountConnect = (props: AccountConnectProps) => {
Engine.context.PermissionController,
toastRef,
accountsLength,
metadataOrigin,
channelIdOrHostname,
triggerDappViewedEvent,
trackEvent,
]);
Expand Down
77 changes: 0 additions & 77 deletions app/core/Encryptor.js

This file was deleted.

Loading

0 comments on commit 6a598a3

Please sign in to comment.