diff --git a/CHANGELOG.md b/CHANGELOG.md index 54710aaea..92ae851ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,21 +4,32 @@ All notable changes will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + ## [Unreleased] +## [[v2.22.5]](https://github.com/multiversx/mx-sdk-dapp/pull/956)] - 2023-10-13 + +- [Prevent "document/window is undefined" issue on Next.js](https://github.com/multiversx/mx-sdk-dapp/pull/955) +- [Update the WalletConnect provider to 4.0.4 (@walletconnect 2.10.2)](https://github.com/multiversx/mx-sdk-dapp/pull/957) + ## [[v2.22.4]](https://github.com/multiversx/mx-sdk-dapp/pull/954)] - 2023-10-13 + - [Integration tests](https://github.com/multiversx/mx-sdk-dapp/pull/953) ## [[v2.22.3]](https://github.com/multiversx/mx-sdk-dapp/pull/949)] - 2023-10-12 + - [Add used indexes to addressTable component](https://github.com/multiversx/mx-sdk-dapp/pull/948) ## [[v2.22.2]](https://github.com/multiversx/mx-sdk-dapp/pull/947)] - 2023-10-12 + - [Added `ESDTNFTBurn` to `getTokenFromData` helper](https://github.com/multiversx/mx-sdk-dapp/pull/946) - [Added page reload on login redirect](https://github.com/multiversx/mx-sdk-dapp/pull/944) - [Fixed `ModalContainer` not working in `StrictMode`](https://github.com/multiversx/mx-sdk-dapp/pull/943) ## [[v2.22.1]](https://github.com/multiversx/mx-sdk-dapp/pull/942)] - 2023-10-02 + - [Fixed `WebWalletLoginButtonPropsType` interface](https://github.com/multiversx/mx-sdk-dapp/pull/942) + ## [[v2.22.0]](https://github.com/multiversx/mx-sdk-dapp/pull/941)] - 2023-10-02 - [Added support for custom Web Wallet address](https://github.com/multiversx/mx-sdk-dapp/pull/940) diff --git a/package.json b/package.json index b4c86d061..20ffaff21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@multiversx/sdk-dapp", - "version": "2.22.4", + "version": "2.22.5", "description": "A library to hold the main logic for a dapp on the MultiversX blockchain", "author": "MultiversX", "license": "GPL-3.0-or-later", @@ -150,7 +150,7 @@ "@multiversx/sdk-network-providers": "1.5.0", "@multiversx/sdk-opera-provider": "1.0.0-alpha.1", "@multiversx/sdk-wallet": "4.2.0", - "@multiversx/sdk-wallet-connect-provider": "4.0.3", + "@multiversx/sdk-wallet-connect-provider": "4.0.4", "@multiversx/sdk-web-wallet-provider": "3.1.0", "@reduxjs/toolkit": "1.8.2", "axios": "0.24.0", diff --git a/src/UI/extension/ExtensionLoginButton/tests/ExtensionLoginButton.test.tsx b/src/UI/extension/ExtensionLoginButton/tests/ExtensionLoginButton.test.tsx index 697f6e5ff..42561afa1 100644 --- a/src/UI/extension/ExtensionLoginButton/tests/ExtensionLoginButton.test.tsx +++ b/src/UI/extension/ExtensionLoginButton/tests/ExtensionLoginButton.test.tsx @@ -67,7 +67,7 @@ describe('ExtensionLoginButton tests', () => { await checkIsLoggedInStore(); await waitFor(() => { - expect(window.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE); + expect(window?.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE); }); }); @@ -83,7 +83,7 @@ describe('ExtensionLoginButton tests', () => { await checkIsLoggedInStore(); await waitFor(() => { - expect(window.location.assign).toHaveBeenCalledWith( + expect(window?.location.assign).toHaveBeenCalledWith( 'https://multivers.com' ); }); @@ -108,7 +108,7 @@ describe('ExtensionLoginButton tests', () => { await checkIsLoggedInStore(); await waitFor(() => { - expect(window.location.assign).toHaveBeenCalledTimes(0); + expect(window?.location.assign).toHaveBeenCalledTimes(0); expect(onLoginRedirect).toHaveBeenCalledTimes(1); expect(onLoginRedirect).toHaveBeenCalledWith(CALLBACK_ROUTE, { address: testAddress, @@ -141,7 +141,7 @@ describe('ExtensionLoginButton tests', () => { tokenLoginWithSignature ); - expect(window.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE); + expect(window?.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE); }); }); @@ -164,7 +164,7 @@ describe('ExtensionLoginButton tests', () => { fireEvent.click(loginButton); await waitFor(() => { - expect(window.location.assign).toHaveBeenCalledTimes(0); + expect(window?.location.assign).toHaveBeenCalledTimes(0); }); }); }); diff --git a/src/UI/ledger/LedgerLoginButton/tests/LedgerLoginButton.test.tsx b/src/UI/ledger/LedgerLoginButton/tests/LedgerLoginButton.test.tsx index 025130a34..c563f28a6 100644 --- a/src/UI/ledger/LedgerLoginButton/tests/LedgerLoginButton.test.tsx +++ b/src/UI/ledger/LedgerLoginButton/tests/LedgerLoginButton.test.tsx @@ -65,7 +65,7 @@ describe('LedgerLoginButton tests', () => { await checkIsLoggedInStore(); await waitFor(() => { - expect(window.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE); + expect(window?.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE); }); }); @@ -78,7 +78,7 @@ describe('LedgerLoginButton tests', () => { await checkIsLoggedInStore(); await waitFor(() => { - expect(window.location.assign).toHaveBeenCalledWith( + expect(window?.location.assign).toHaveBeenCalledWith( 'https://multivers.com' ); }); @@ -101,7 +101,7 @@ describe('LedgerLoginButton tests', () => { await checkIsLoggedInStore(); await waitFor(() => { - expect(window.location.assign).toHaveBeenCalledTimes(0); + expect(window?.location.assign).toHaveBeenCalledTimes(0); expect(onLoginRedirect).toHaveBeenCalledTimes(1); expect(onLoginRedirect).toHaveBeenCalledWith(CALLBACK_ROUTE, { address: testAddress, @@ -137,7 +137,7 @@ describe('LedgerLoginButton tests', () => { tokenLoginWithSignature ); - expect(window.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE); + expect(window?.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE); }); }); @@ -162,7 +162,7 @@ describe('LedgerLoginButton tests', () => { await ledgerLogin(methods); await waitFor(() => { - expect(window.location.assign).toHaveBeenCalledTimes(0); + expect(window?.location.assign).toHaveBeenCalledTimes(0); }); }); }); diff --git a/src/UI/operaWallet/OperaWalletLoginButton/tests/OperaWalletLoginButton.test.tsx b/src/UI/operaWallet/OperaWalletLoginButton/tests/OperaWalletLoginButton.test.tsx index 917429162..fde6bba99 100644 --- a/src/UI/operaWallet/OperaWalletLoginButton/tests/OperaWalletLoginButton.test.tsx +++ b/src/UI/operaWallet/OperaWalletLoginButton/tests/OperaWalletLoginButton.test.tsx @@ -51,7 +51,7 @@ describe.skip('OperaLoginButton tests', () => { await checkIsLoggedInStore(); await waitFor(() => { - expect(window.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE); + expect(window?.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE); }); }); it('should perform simple login and call onLoginRedirect', async () => { @@ -73,7 +73,7 @@ describe.skip('OperaLoginButton tests', () => { await checkIsLoggedInStore(); await waitFor(() => { - expect(window.location.assign).toHaveBeenCalledTimes(0); + expect(window?.location.assign).toHaveBeenCalledTimes(0); expect(onLoginRedirect).toHaveBeenCalledTimes(1); }); }); @@ -92,7 +92,7 @@ describe.skip('OperaLoginButton tests', () => { await waitFor(() => { expect(consoleWarnSpy).toHaveBeenCalledWith(tokenLogin); - expect(window.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE); + expect(window?.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE); }); }); it('should not perform nativeAuth login when block call fails', async () => { diff --git a/src/__mocks__/utils/mockWindowHistory.ts b/src/__mocks__/utils/mockWindowHistory.ts index da0ccf457..71b0e7436 100644 --- a/src/__mocks__/utils/mockWindowHistory.ts +++ b/src/__mocks__/utils/mockWindowHistory.ts @@ -1,4 +1,8 @@ export const mockWindowHistory = () => { + if (!window) { + return; + } + const history = window.history; // eslint-disable-next-line @typescript-eslint/ban-ts-comment diff --git a/src/__mocks__/utils/mockWindowLocation.ts b/src/__mocks__/utils/mockWindowLocation.ts index 1b35da7e5..765ea5158 100644 --- a/src/__mocks__/utils/mockWindowLocation.ts +++ b/src/__mocks__/utils/mockWindowLocation.ts @@ -1,4 +1,8 @@ export const mockWindowLocation = () => { + if (!window) { + return; + } + const location = window.location; // eslint-disable-next-line @typescript-eslint/ban-ts-comment diff --git a/src/hooks/login/useWebWalletLogin.ts b/src/hooks/login/useWebWalletLogin.ts index 497b189c1..55d3b5440 100644 --- a/src/hooks/login/useWebWalletLogin.ts +++ b/src/hooks/login/useWebWalletLogin.ts @@ -91,7 +91,7 @@ export const useWebWalletLogin = ({ const targetUrl = window?.location ? `${origin}${callbackRoute}` : `${callbackRoute}`; - const params = new URLSearchParams(document.location.search); + const params = new URLSearchParams(document?.location.search); // skip login when an address param is prefilled in URL const skipLogin = params.get('address'); diff --git a/yarn.lock b/yarn.lock index a98e93b62..1f441a62b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1971,13 +1971,13 @@ dependencies: bech32 "^2.0.0" -"@multiversx/sdk-wallet-connect-provider@4.0.3": - version "4.0.3" - resolved "https://registry.yarnpkg.com/@multiversx/sdk-wallet-connect-provider/-/sdk-wallet-connect-provider-4.0.3.tgz#98f5dfb6665f58e3affa7c09f281c6ba492d3b3f" - integrity sha512-j48gz0ZBuYAUbEKx3qN2AvwZssNHYASwfng/ek097wgmDEIH8cfeA1ujkN6FF0WMvh8T6bIHtOHKWH3diZ/Fdg== +"@multiversx/sdk-wallet-connect-provider@4.0.4": + version "4.0.4" + resolved "https://registry.yarnpkg.com/@multiversx/sdk-wallet-connect-provider/-/sdk-wallet-connect-provider-4.0.4.tgz#4111bc2c1978e4beffd18f146648fec8c73f6d07" + integrity sha512-k+t/M0U1SnHsdLmcbXkoYgA5+R3KJA+h8N4uC026l1fRz8Vo7g3joQoqLi5qSanuc0S+uiInpDyIoq0fbFLUjA== dependencies: - "@walletconnect/sign-client" "2.9.1" - "@walletconnect/utils" "2.9.1" + "@walletconnect/sign-client" "2.10.2" + "@walletconnect/utils" "2.10.2" bech32 "1.1.4" "@multiversx/sdk-wallet@4.2.0": @@ -3972,9 +3972,9 @@ form-data "^4.0.0" "@types/node@*", "@types/node@>=13.7.0": - version "20.8.4" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.4.tgz#0e9ebb2ff29d5c3302fc84477d066fa7c6b441aa" - integrity sha512-ZVPnqU58giiCjSxjVUESDtdPk4QR5WQhhINbc9UBrKLU68MX5BF6kbQzTrkwbolyr0X8ChBpXfavr5mZFKZQ5A== + version "20.8.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.5.tgz#13352ae1f80032171616910e8aba2e3e52e57d96" + integrity sha512-SPlobFgbidfIeOYlzXiEjSYeIJiOCthv+9tSQVpvk4PAdIIc+2SmjNVzWXk9t0Y7dl73Zdf+OgXKHX9XtkqUpw== dependencies: undici-types "~5.25.1" @@ -4285,10 +4285,10 @@ "@typescript-eslint/types" "5.14.0" eslint-visitor-keys "^3.0.0" -"@walletconnect/core@2.9.1": - version "2.9.1" - resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.9.1.tgz#1a333933750f5f933d9b7788a8dae44ce1173063" - integrity sha512-xyWeP0eLhEEDQAVJSmqs4n/AClKUM+8os2ZFe7BTuw1tFYjeLNVDtKCHziVOSTh8wEChMsKSGKA4zerQoH8mAQ== +"@walletconnect/core@2.10.2": + version "2.10.2" + resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.10.2.tgz#a1bf6e3e87b33f9df795ce0970d8ddd400fdc8a3" + integrity sha512-JQz/xp3SLEpTeRQctdck2ugSBVEpMxoSE+lFi2voJkZop1hv6P+uqr6E4PzjFluAjeAnKlT1xvra0aFWjPWVcw== dependencies: "@walletconnect/heartbeat" "1.2.1" "@walletconnect/jsonrpc-provider" "1.0.13" @@ -4301,8 +4301,8 @@ "@walletconnect/relay-auth" "^1.0.4" "@walletconnect/safe-json" "^1.0.2" "@walletconnect/time" "^1.0.2" - "@walletconnect/types" "2.9.1" - "@walletconnect/utils" "2.9.1" + "@walletconnect/types" "2.10.2" + "@walletconnect/utils" "2.10.2" events "^3.3.0" lodash.isequal "4.5.0" uint8arrays "^3.1.0" @@ -4411,19 +4411,19 @@ dependencies: tslib "1.14.1" -"@walletconnect/sign-client@2.9.1": - version "2.9.1" - resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.9.1.tgz#e4aa9c7b15849f450fdd1b03754a7517cb5c8811" - integrity sha512-Z7tFRrJ9btA1vU427vsjUS6cPlHQVcTWdKH90khEc2lv3dB6mU8FNO0VJsw+I2D7CW7WaMWF3nnj6Z1FfotbDg== +"@walletconnect/sign-client@2.10.2": + version "2.10.2" + resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.10.2.tgz#33300a9cfe42487473f66b73c99535f6b26f8c54" + integrity sha512-vviSLV3f92I0bReX+OLr1HmbH0uIzYEQQFd1MzIfDk9PkfFT/LLAHhUnDaIAMkIdippqDcJia+5QEtT4JihL3Q== dependencies: - "@walletconnect/core" "2.9.1" + "@walletconnect/core" "2.10.2" "@walletconnect/events" "^1.0.1" "@walletconnect/heartbeat" "1.2.1" "@walletconnect/jsonrpc-utils" "1.0.8" "@walletconnect/logger" "^2.0.1" "@walletconnect/time" "^1.0.2" - "@walletconnect/types" "2.9.1" - "@walletconnect/utils" "2.9.1" + "@walletconnect/types" "2.10.2" + "@walletconnect/utils" "2.10.2" events "^3.3.0" "@walletconnect/time@^1.0.2": @@ -4433,10 +4433,10 @@ dependencies: tslib "1.14.1" -"@walletconnect/types@2.9.1": - version "2.9.1" - resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.9.1.tgz#cb32ff396cc8880a7395f28716d1e82f407e1372" - integrity sha512-xbGgTPuD6xsb7YMvCESBIH55cjB86QAnnVL50a/ED42YkQzDsOdJ0VGTbrm0tG5cxUOF933rpxZQjxGdP+ovww== +"@walletconnect/types@2.10.2": + version "2.10.2" + resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.10.2.tgz#68e433a29ec2cf42d79d8b50c77bd5c1d91db721" + integrity sha512-luNV+07Wdla4STi9AejseCQY31tzWKQ5a7C3zZZaRK/di+rFaAAb7YW04OP4klE7tw/mJRGPTlekZElmHxO8kQ== dependencies: "@walletconnect/events" "^1.0.1" "@walletconnect/heartbeat" "1.2.1" @@ -4445,10 +4445,10 @@ "@walletconnect/logger" "^2.0.1" events "^3.3.0" -"@walletconnect/utils@2.9.1": - version "2.9.1" - resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.9.1.tgz#92abc24b3af3ead42a3864e019dbf2f651ab2e47" - integrity sha512-tXeQVebF5oPBvhdmuUyVSkSIBYx/egIi4czav1QrnUpwrUS1LsrFhyWBxSbhN7TXY287ULWkEf6aFpWOHdp5EA== +"@walletconnect/utils@2.10.2": + version "2.10.2" + resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.10.2.tgz#1f2c6a2f1bb95bcc4517b1e94aa7164c9286eb46" + integrity sha512-syxXRpc2yhSknMu3IfiBGobxOY7fLfLTJuw+ppKaeO6WUdZpIit3wfuGOcc0Ms3ZPFCrGfyGOoZsCvgdXtptRg== dependencies: "@stablelib/chacha20poly1305" "1.0.1" "@stablelib/hkdf" "1.0.1" @@ -4458,7 +4458,7 @@ "@walletconnect/relay-api" "^1.0.9" "@walletconnect/safe-json" "^1.0.2" "@walletconnect/time" "^1.0.2" - "@walletconnect/types" "2.9.1" + "@walletconnect/types" "2.10.2" "@walletconnect/window-getters" "^1.0.1" "@walletconnect/window-metadata" "^1.0.1" detect-browser "5.3.0" @@ -6795,9 +6795,9 @@ defaults@^1.0.3: clone "^1.0.2" define-data-property@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.0.tgz#0db13540704e1d8d479a0656cf781267531b9451" - integrity sha512-UzGwzcjyv3OtAvolTj1GoyNYzfFR+iqbGjcnBEENZVCpM4/Ng1yhGNvS3lR/xDS74Tb2wGG9WzNSNIOS9UVb2g== + version "1.1.1" + resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.1.tgz#c35f7cd0ab09883480d12ac5cb213715587800b3" + integrity sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ== dependencies: get-intrinsic "^1.2.1" gopd "^1.0.1" @@ -7139,9 +7139,9 @@ ee-first@1.1.1: integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== electron-to-chromium@^1.4.535: - version "1.4.551" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.551.tgz#14db6660a88f66ce095ea2657abe5653bc7f42ed" - integrity sha512-/Ng/W/kFv7wdEHYzxdK7Cv0BHEGSkSB3M0Ssl8Ndr1eMiYeas/+Mv4cNaDqamqWx6nd2uQZfPz6g25z25M/sdw== + version "1.4.553" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.553.tgz#56fd65afddbd713c52f0e95d0223b3368f520865" + integrity sha512-HiRdtyKS2+VhiXvjhMvvxiMC33FJJqTA5EB2YHgFZW6v7HkK4Q9Ahv2V7O2ZPgAjw+MyCJVMQvigj13H8t+wvA== element-resize-detector@^1.2.2: version "1.2.4" @@ -8590,9 +8590,9 @@ fsevents@^2.1.2, fsevents@^2.3.2, fsevents@~2.3.2: integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== function.prototype.name@^1.1.0, function.prototype.name@^1.1.6: version "1.1.6"