diff --git a/CHANGELOG.md b/CHANGELOG.md index 625565ddb..30f3fee82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [[v3.0.7](https://github.com/multiversx/mx-sdk-dapp/pull/1296)] - 2024-11-01 +- [Fixed Iframe provider reload](https://github.com/multiversx/mx-sdk-dapp/pull/1295) ## [[v3.0.6](https://github.com/multiversx/mx-sdk-dapp/pull/1294)] - 2024-11-01 - [Fixed `location.assign` in extension context](https://github.com/multiversx/mx-sdk-dapp/pull/1293) diff --git a/package.json b/package.json index eb199215c..3640ba027 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@multiversx/sdk-dapp", - "version": "3.0.6", + "version": "3.0.7", "description": "A library to hold the main logic for a dapp on the MultiversX blockchain", "author": "MultiversX", "license": "GPL-3.0-or-later", diff --git a/src/components/ProviderInitializer/ProviderInitializer.tsx b/src/components/ProviderInitializer/ProviderInitializer.tsx index 0844237e1..7d25fbdd7 100644 --- a/src/components/ProviderInitializer/ProviderInitializer.tsx +++ b/src/components/ProviderInitializer/ProviderInitializer.tsx @@ -14,12 +14,12 @@ import { ledgerAccountSelector } from 'reduxStore/selectors/accountInfoSelectors'; import { - loginMethodSelector, walletConnectLoginSelector, walletLoginSelector, ledgerLoginSelector, isLoggedInSelector, - tokenLoginSelector + tokenLoginSelector, + loginInfoSelector } from 'reduxStore/selectors/loginInfoSelectors'; import { chainIDSelector, @@ -67,7 +67,7 @@ export function ProviderInitializer() { const network = useSelector(networkSelector); const walletAddress = useSelector(walletAddressSelector); const walletConnectLogin = useSelector(walletConnectLoginSelector); - const loginMethod = useSelector(loginMethodSelector); + const { loginMethod, iframeLoginType } = useSelector(loginInfoSelector); const walletLogin = useSelector(walletLoginSelector); const address = useSelector(addressSelector); const ledgerAccount = useSelector(ledgerAccountSelector); @@ -326,7 +326,8 @@ export function ProviderInitializer() { } const provider = await getIframeProvider({ address, - walletUrl: network.metamaskSnapWalletAddress + walletUrl: network.metamaskSnapWalletAddress, + loginType: iframeLoginType }); if (provider) { setAccountProvider(provider); diff --git a/src/components/ProviderInitializer/helpers/getIframeProvider.ts b/src/components/ProviderInitializer/helpers/getIframeProvider.ts index 00cec88d7..c31ce115a 100644 --- a/src/components/ProviderInitializer/helpers/getIframeProvider.ts +++ b/src/components/ProviderInitializer/helpers/getIframeProvider.ts @@ -1,11 +1,14 @@ import { IframeProvider } from '@multiversx/sdk-web-wallet-iframe-provider/out'; +import { IframeLoginTypes } from '@multiversx/sdk-web-wallet-iframe-provider/out/constants'; export async function getIframeProvider({ address, - walletUrl + walletUrl, + loginType }: { address: string; walletUrl: string; + loginType?: IframeLoginTypes; }) { try { const provider = IframeProvider.getInstance(); @@ -14,6 +17,17 @@ export async function getIframeProvider({ return provider; } + switch (loginType) { + case IframeLoginTypes.passkey: + provider.setLoginType(IframeLoginTypes.passkey); + break; + case IframeLoginTypes.metamask: + provider.setLoginType(IframeLoginTypes.metamask); + break; + default: + break; + } + provider.setAddress(address).setWalletUrl(walletUrl); const success = await provider.init(); diff --git a/src/hooks/login/useIframeLogin.ts b/src/hooks/login/useIframeLogin.ts index ca806f20c..b899b4276 100644 --- a/src/hooks/login/useIframeLogin.ts +++ b/src/hooks/login/useIframeLogin.ts @@ -124,7 +124,8 @@ export const useIframeLogin = ({ dispatch( loginAction({ address: account.address, - loginMethod: LoginMethodsEnum.iframe + loginMethod: LoginMethodsEnum.iframe, + iframeLoginType: loginType }) ); diff --git a/src/reduxStore/commonActions.ts b/src/reduxStore/commonActions.ts index 867e42e78..abb9b7be5 100644 --- a/src/reduxStore/commonActions.ts +++ b/src/reduxStore/commonActions.ts @@ -1,3 +1,4 @@ +import { IframeLoginTypes } from '@multiversx/sdk-web-wallet-iframe-provider/out/constants'; import { createAction } from '@reduxjs/toolkit'; import { LOGIN_ACTION_NAME, LOGOUT_ACTION_NAME } from 'constants/index'; import { LoginMethodsEnum } from 'types/enums.types'; @@ -5,6 +6,7 @@ import { LoginMethodsEnum } from 'types/enums.types'; export interface LoginActionPayloadType { address: string; loginMethod: LoginMethodsEnum; + iframeLoginType?: IframeLoginTypes; } export const logoutAction = createAction(LOGOUT_ACTION_NAME); diff --git a/src/reduxStore/slices/loginInfoSlice.ts b/src/reduxStore/slices/loginInfoSlice.ts index ff41aa8c7..8ae0023d3 100644 --- a/src/reduxStore/slices/loginInfoSlice.ts +++ b/src/reduxStore/slices/loginInfoSlice.ts @@ -1,3 +1,4 @@ +import { IframeLoginTypes } from '@multiversx/sdk-web-wallet-iframe-provider/out/constants'; import { createSlice, PayloadAction } from '@reduxjs/toolkit'; import { setLoginExpiresAt, getNewLoginExpiresTimestamp } from 'storage/local'; import { LoginMethodsEnum } from 'types/enums.types'; @@ -26,6 +27,7 @@ export interface LoginInfoType { export interface LoginInfoStateType { loginMethod: LoginMethodsEnum; + iframeLoginType?: IframeLoginTypes; walletConnectLogin: WalletConnectLoginType | null; ledgerLogin: LedgerLoginType | null; tokenLogin: TokenLoginType | null; @@ -132,6 +134,7 @@ export const loginInfoSlice = createSlice({ ) => { state.isLoginSessionInvalid = false; state.loginMethod = action.payload.loginMethod; + state.iframeLoginType = action.payload.iframeLoginType; setLoginExpiresAt(getNewLoginExpiresTimestamp()); } );