From 699ebc7d533f9ad0e64b6cf46a348ac6ecb61b97 Mon Sep 17 00:00:00 2001 From: Gavrila Andrei Date: Tue, 17 Dec 2024 11:40:08 +0200 Subject: [PATCH] Organize project structure (#49) * Update project structure * Move accountProvider * Update import * Update type imports * Add missing index --- .../LedgerConnectStateManager.ts | 2 +- .../LedgerConnectStateManager/index.ts | 1 + .../SignTransactionsStateManager.ts | 4 ++-- .../SignTransactionsStateManager/index.ts | 1 + .../types/index.ts | 1 + .../types}/signTransactionsModal.types.ts | 0 .../TransactionManager.ts | 0 src/core/managers/TransactionManager/index.ts | 1 + .../WalletConnectStateManager.ts} | 4 ++-- .../WalletConnectStateManager/index.ts | 1 + src/core/managers/index.ts | 4 ++++ src/core/methods/initApp/initApp.types.ts | 4 ++-- src/core/providers/ProviderFactory.ts | 14 ++++++++------ .../{ => helpers}/accountProvider.ts | 4 ++-- src/core/providers/helpers/restoreProvider.ts | 2 +- src/core/providers/index.ts | 3 ++- .../CrossWindowProviderStrategy.ts | 0 .../CrossWindowProviderStrategy/index.ts | 1 + .../types/crossWindow.types.ts} | 0 .../types/index.ts | 1 + .../ExtensionProviderStrategy.ts | 0 .../ExtensionProviderStrategy/index.ts | 1 + .../IFrameProviderStrategy.ts | 5 +---- .../IFrameProviderStrategy/index.ts | 1 + .../types/iframe.types.ts | 6 ++++++ .../IFrameProviderStrategy/types/index.ts | 1 + .../LedgerProviderStrategy.ts | 19 +++++++++---------- .../helpers/getAuthTokenText.ts | 0 .../helpers}/getLedgerConfiguration.ts | 0 .../helpers/getLedgerErrorCodes.ts | 0 .../helpers/getLedgerProvider.ts | 4 ++-- .../helpers/getLedgerVersionOptions.ts | 0 .../LedgerProviderStrategy/helpers/index.ts | 6 ++++++ .../helpers/secondsToTimeString.ts | 0 .../LedgerProviderStrategy/index.ts | 1 + .../tests/getLedgerVersionOptions.test.ts | 2 +- .../tests/secondsToTimeString.test.ts | 2 +- .../LedgerProviderStrategy/types/index.ts | 1 + .../types}/ledger.types.ts | 0 .../WalletConnectProviderStrategy.ts | 14 +++++++------- .../WalletConnectProviderStrategy/index.ts | 1 + .../types/index.ts | 1 + .../types}/walletConnect.types.ts | 0 src/core/providers/strategies/index.ts | 5 +++++ src/store/actions/config/configActions.ts | 4 ++-- src/store/slices/config/config.types.ts | 4 ++-- src/utils/account/refreshAccount.ts | 2 +- 47 files changed, 81 insertions(+), 47 deletions(-) rename src/core/{providers/helpers/ledger/helpers => managers/LedgerConnectStateManager}/LedgerConnectStateManager.ts (98%) create mode 100644 src/core/managers/LedgerConnectStateManager/index.ts rename src/core/{providers/helpers/components/SignTransactionsModal => managers/SignTransactionsStateManager}/SignTransactionsStateManager.ts (96%) create mode 100644 src/core/managers/SignTransactionsStateManager/index.ts create mode 100644 src/core/managers/SignTransactionsStateManager/types/index.ts rename src/core/{providers/helpers/components/SignTransactionsModal => managers/SignTransactionsStateManager/types}/signTransactionsModal.types.ts (100%) rename src/core/managers/{ => TransactionManager}/TransactionManager.ts (100%) create mode 100644 src/core/managers/TransactionManager/index.ts rename src/core/{providers/helpers/walletConnect/WalletConnectStateManagement.ts => managers/WalletConnectStateManager/WalletConnectStateManager.ts} (93%) create mode 100644 src/core/managers/WalletConnectStateManager/index.ts create mode 100644 src/core/managers/index.ts rename src/core/providers/{ => helpers}/accountProvider.ts (80%) rename src/core/{providers-strategy => providers/strategies/CrossWindowProviderStrategy}/CrossWindowProviderStrategy.ts (100%) create mode 100644 src/core/providers/strategies/CrossWindowProviderStrategy/index.ts rename src/core/providers/{helpers/crossWindow/crossWindow.type.ts => strategies/CrossWindowProviderStrategy/types/crossWindow.types.ts} (100%) create mode 100644 src/core/providers/strategies/CrossWindowProviderStrategy/types/index.ts rename src/core/{providers-strategy => providers/strategies/ExtensionProviderStrategy}/ExtensionProviderStrategy.ts (100%) create mode 100644 src/core/providers/strategies/ExtensionProviderStrategy/index.ts rename src/core/{providers-strategy => providers/strategies/IFrameProviderStrategy}/IFrameProviderStrategy.ts (95%) create mode 100644 src/core/providers/strategies/IFrameProviderStrategy/index.ts create mode 100644 src/core/providers/strategies/IFrameProviderStrategy/types/iframe.types.ts create mode 100644 src/core/providers/strategies/IFrameProviderStrategy/types/index.ts rename src/core/{providers-strategy => providers/strategies/LedgerProviderStrategy}/LedgerProviderStrategy.ts (95%) rename src/core/providers/{helpers/ledger => strategies/LedgerProviderStrategy}/helpers/getAuthTokenText.ts (100%) rename src/core/providers/{helpers/ledger => strategies/LedgerProviderStrategy/helpers}/getLedgerConfiguration.ts (100%) rename src/core/providers/{helpers/ledger => strategies/LedgerProviderStrategy}/helpers/getLedgerErrorCodes.ts (100%) rename src/core/providers/{helpers/ledger => strategies/LedgerProviderStrategy}/helpers/getLedgerProvider.ts (90%) rename src/core/providers/{helpers/ledger => strategies/LedgerProviderStrategy}/helpers/getLedgerVersionOptions.ts (100%) create mode 100644 src/core/providers/strategies/LedgerProviderStrategy/helpers/index.ts rename src/core/providers/{helpers/ledger => strategies/LedgerProviderStrategy}/helpers/secondsToTimeString.ts (100%) create mode 100644 src/core/providers/strategies/LedgerProviderStrategy/index.ts rename src/core/providers/{helpers/ledger/helpers => strategies/LedgerProviderStrategy}/tests/getLedgerVersionOptions.test.ts (97%) rename src/core/providers/{helpers/ledger/helpers => strategies/LedgerProviderStrategy}/tests/secondsToTimeString.test.ts (96%) create mode 100644 src/core/providers/strategies/LedgerProviderStrategy/types/index.ts rename src/core/providers/{helpers/ledger => strategies/LedgerProviderStrategy/types}/ledger.types.ts (100%) rename src/core/{providers-strategy => providers/strategies/WalletConnectProviderStrategy}/WalletConnectProviderStrategy.ts (96%) create mode 100644 src/core/providers/strategies/WalletConnectProviderStrategy/index.ts create mode 100644 src/core/providers/strategies/WalletConnectProviderStrategy/types/index.ts rename src/core/providers/{helpers/walletConnect => strategies/WalletConnectProviderStrategy/types}/walletConnect.types.ts (100%) create mode 100644 src/core/providers/strategies/index.ts diff --git a/src/core/providers/helpers/ledger/helpers/LedgerConnectStateManager.ts b/src/core/managers/LedgerConnectStateManager/LedgerConnectStateManager.ts similarity index 98% rename from src/core/providers/helpers/ledger/helpers/LedgerConnectStateManager.ts rename to src/core/managers/LedgerConnectStateManager/LedgerConnectStateManager.ts index 1fefdad..0b73062 100644 --- a/src/core/providers/helpers/ledger/helpers/LedgerConnectStateManager.ts +++ b/src/core/managers/LedgerConnectStateManager/LedgerConnectStateManager.ts @@ -5,7 +5,7 @@ import { ILedgerAccount, ILedgerConnectModalData, LedgerConnectEventsEnum -} from '../ledger.types'; +} from 'core/providers/strategies/LedgerProviderStrategy/types'; export interface IEventBus { publish(event: string, data: any): void; diff --git a/src/core/managers/LedgerConnectStateManager/index.ts b/src/core/managers/LedgerConnectStateManager/index.ts new file mode 100644 index 0000000..6827f07 --- /dev/null +++ b/src/core/managers/LedgerConnectStateManager/index.ts @@ -0,0 +1 @@ +export * from './LedgerConnectStateManager'; diff --git a/src/core/providers/helpers/components/SignTransactionsModal/SignTransactionsStateManager.ts b/src/core/managers/SignTransactionsStateManager/SignTransactionsStateManager.ts similarity index 96% rename from src/core/providers/helpers/components/SignTransactionsModal/SignTransactionsStateManager.ts rename to src/core/managers/SignTransactionsStateManager/SignTransactionsStateManager.ts index 1a30b34..41fb895 100644 --- a/src/core/providers/helpers/components/SignTransactionsModal/SignTransactionsStateManager.ts +++ b/src/core/managers/SignTransactionsStateManager/SignTransactionsStateManager.ts @@ -1,9 +1,9 @@ import { ISignTransactionsModalData, SignEventsEnum -} from './signTransactionsModal.types'; +} from './types/signTransactionsModal.types'; -export interface IEventBus { +interface IEventBus { publish(event: string, data: any): void; } diff --git a/src/core/managers/SignTransactionsStateManager/index.ts b/src/core/managers/SignTransactionsStateManager/index.ts new file mode 100644 index 0000000..34b447a --- /dev/null +++ b/src/core/managers/SignTransactionsStateManager/index.ts @@ -0,0 +1 @@ +export * from './SignTransactionsStateManager'; diff --git a/src/core/managers/SignTransactionsStateManager/types/index.ts b/src/core/managers/SignTransactionsStateManager/types/index.ts new file mode 100644 index 0000000..6f89536 --- /dev/null +++ b/src/core/managers/SignTransactionsStateManager/types/index.ts @@ -0,0 +1 @@ +export * from './signTransactionsModal.types'; diff --git a/src/core/providers/helpers/components/SignTransactionsModal/signTransactionsModal.types.ts b/src/core/managers/SignTransactionsStateManager/types/signTransactionsModal.types.ts similarity index 100% rename from src/core/providers/helpers/components/SignTransactionsModal/signTransactionsModal.types.ts rename to src/core/managers/SignTransactionsStateManager/types/signTransactionsModal.types.ts diff --git a/src/core/managers/TransactionManager.ts b/src/core/managers/TransactionManager/TransactionManager.ts similarity index 100% rename from src/core/managers/TransactionManager.ts rename to src/core/managers/TransactionManager/TransactionManager.ts diff --git a/src/core/managers/TransactionManager/index.ts b/src/core/managers/TransactionManager/index.ts new file mode 100644 index 0000000..e6dcdcf --- /dev/null +++ b/src/core/managers/TransactionManager/index.ts @@ -0,0 +1 @@ +export * from './TransactionManager'; diff --git a/src/core/providers/helpers/walletConnect/WalletConnectStateManagement.ts b/src/core/managers/WalletConnectStateManager/WalletConnectStateManager.ts similarity index 93% rename from src/core/providers/helpers/walletConnect/WalletConnectStateManagement.ts rename to src/core/managers/WalletConnectStateManager/WalletConnectStateManager.ts index 3eebf42..6468f6e 100644 --- a/src/core/providers/helpers/walletConnect/WalletConnectStateManagement.ts +++ b/src/core/managers/WalletConnectStateManager/WalletConnectStateManager.ts @@ -1,9 +1,9 @@ import { IWalletConnectModalData, WalletConnectEventsEnum -} from './walletConnect.types'; +} from 'core/providers/strategies/WalletConnectProviderStrategy/types'; -export interface IEventBus { +interface IEventBus { publish(event: string, data: any): void; } diff --git a/src/core/managers/WalletConnectStateManager/index.ts b/src/core/managers/WalletConnectStateManager/index.ts new file mode 100644 index 0000000..efc4043 --- /dev/null +++ b/src/core/managers/WalletConnectStateManager/index.ts @@ -0,0 +1 @@ +export * from './WalletConnectStateManager'; diff --git a/src/core/managers/index.ts b/src/core/managers/index.ts new file mode 100644 index 0000000..b561b76 --- /dev/null +++ b/src/core/managers/index.ts @@ -0,0 +1,4 @@ +export * from './LedgerConnectStateManager'; +export * from './SignTransactionsStateManager'; +export * from './TransactionManager'; +export * from './WalletConnectStateManager'; diff --git a/src/core/methods/initApp/initApp.types.ts b/src/core/methods/initApp/initApp.types.ts index d6bbd32..0b8ad73 100644 --- a/src/core/methods/initApp/initApp.types.ts +++ b/src/core/methods/initApp/initApp.types.ts @@ -1,5 +1,5 @@ -import { CrossWindowConfig } from 'core/providers/helpers/crossWindow/crossWindow.type'; -import { WalletConnectConfig } from 'core/providers/helpers/walletConnect/walletConnect.types'; +import { CrossWindowConfig } from 'core/providers/strategies/CrossWindowProviderStrategy/types'; +import { WalletConnectConfig } from 'core/providers/strategies/WalletConnectProviderStrategy/types'; import { ICustomProvider } from 'core/providers/types/providerFactory.types'; import { NativeAuthConfigType } from 'services/nativeAuth/nativeAuth.types'; import { StorageCallback } from 'store/storage'; diff --git a/src/core/providers/ProviderFactory.ts b/src/core/providers/ProviderFactory.ts index 08b4b98..fc518bd 100644 --- a/src/core/providers/ProviderFactory.ts +++ b/src/core/providers/ProviderFactory.ts @@ -1,13 +1,15 @@ import { IframeLoginTypes } from '@multiversx/sdk-web-wallet-iframe-provider/out/constants'; import { getAddress } from 'core/methods/account/getAddress'; -import { CrossWindowProviderStrategy } from 'core/providers-strategy/CrossWindowProviderStrategy'; -import { ExtensionProviderStrategy } from 'core/providers-strategy/ExtensionProviderStrategy'; -import { IFrameProviderStrategy } from 'core/providers-strategy/IFrameProviderStrategy'; -import { LedgerProviderStrategy } from 'core/providers-strategy/LedgerProviderStrategy'; -import { WalletConnectProviderStrategy } from 'core/providers-strategy/WalletConnectProviderStrategy'; +import { + CrossWindowProviderStrategy, + ExtensionProviderStrategy, + IFrameProviderStrategy, + LedgerProviderStrategy, + WalletConnectProviderStrategy +} from 'core/providers/strategies'; import { setProviderType } from 'store/actions/loginInfo/loginInfoActions'; -import { setAccountProvider } from './accountProvider'; import { DappProvider } from './DappProvider/DappProvider'; +import { setAccountProvider } from './helpers/accountProvider'; import { ICustomProvider, IProvider, diff --git a/src/core/providers/accountProvider.ts b/src/core/providers/helpers/accountProvider.ts similarity index 80% rename from src/core/providers/accountProvider.ts rename to src/core/providers/helpers/accountProvider.ts index 669d697..d1c4a1d 100644 --- a/src/core/providers/accountProvider.ts +++ b/src/core/providers/helpers/accountProvider.ts @@ -1,6 +1,6 @@ import { IProvider } from 'core/providers/types/providerFactory.types'; -import { DappProvider } from './DappProvider'; -import { emptyProvider } from './helpers/emptyProvider'; +import { DappProvider } from '../DappProvider'; +import { emptyProvider } from './emptyProvider'; export type ProvidersType = IProvider; diff --git a/src/core/providers/helpers/restoreProvider.ts b/src/core/providers/helpers/restoreProvider.ts index 4ec08fa..b7d7609 100644 --- a/src/core/providers/helpers/restoreProvider.ts +++ b/src/core/providers/helpers/restoreProvider.ts @@ -1,6 +1,6 @@ import { providerTypeSelector } from 'store/selectors'; import { getState } from 'store/store'; -import { setAccountProvider } from '../accountProvider'; +import { setAccountProvider } from './accountProvider'; import { ProviderFactory } from '../ProviderFactory'; export async function restoreProvider() { diff --git a/src/core/providers/index.ts b/src/core/providers/index.ts index dcdb1f3..ceb373e 100644 --- a/src/core/providers/index.ts +++ b/src/core/providers/index.ts @@ -1,4 +1,5 @@ -export { getAccountProvider } from './accountProvider'; +export { getAccountProvider } from './helpers/accountProvider'; +export * from './strategies'; /* // TODO: create detectProvider function diff --git a/src/core/providers-strategy/CrossWindowProviderStrategy.ts b/src/core/providers/strategies/CrossWindowProviderStrategy/CrossWindowProviderStrategy.ts similarity index 100% rename from src/core/providers-strategy/CrossWindowProviderStrategy.ts rename to src/core/providers/strategies/CrossWindowProviderStrategy/CrossWindowProviderStrategy.ts diff --git a/src/core/providers/strategies/CrossWindowProviderStrategy/index.ts b/src/core/providers/strategies/CrossWindowProviderStrategy/index.ts new file mode 100644 index 0000000..abcd7d7 --- /dev/null +++ b/src/core/providers/strategies/CrossWindowProviderStrategy/index.ts @@ -0,0 +1 @@ +export * from './CrossWindowProviderStrategy'; diff --git a/src/core/providers/helpers/crossWindow/crossWindow.type.ts b/src/core/providers/strategies/CrossWindowProviderStrategy/types/crossWindow.types.ts similarity index 100% rename from src/core/providers/helpers/crossWindow/crossWindow.type.ts rename to src/core/providers/strategies/CrossWindowProviderStrategy/types/crossWindow.types.ts diff --git a/src/core/providers/strategies/CrossWindowProviderStrategy/types/index.ts b/src/core/providers/strategies/CrossWindowProviderStrategy/types/index.ts new file mode 100644 index 0000000..a49e6ba --- /dev/null +++ b/src/core/providers/strategies/CrossWindowProviderStrategy/types/index.ts @@ -0,0 +1 @@ +export * from './crossWindow.types'; diff --git a/src/core/providers-strategy/ExtensionProviderStrategy.ts b/src/core/providers/strategies/ExtensionProviderStrategy/ExtensionProviderStrategy.ts similarity index 100% rename from src/core/providers-strategy/ExtensionProviderStrategy.ts rename to src/core/providers/strategies/ExtensionProviderStrategy/ExtensionProviderStrategy.ts diff --git a/src/core/providers/strategies/ExtensionProviderStrategy/index.ts b/src/core/providers/strategies/ExtensionProviderStrategy/index.ts new file mode 100644 index 0000000..cd40205 --- /dev/null +++ b/src/core/providers/strategies/ExtensionProviderStrategy/index.ts @@ -0,0 +1 @@ +export * from './ExtensionProviderStrategy'; diff --git a/src/core/providers-strategy/IFrameProviderStrategy.ts b/src/core/providers/strategies/IFrameProviderStrategy/IFrameProviderStrategy.ts similarity index 95% rename from src/core/providers-strategy/IFrameProviderStrategy.ts rename to src/core/providers/strategies/IFrameProviderStrategy/IFrameProviderStrategy.ts index dd7fbfd..1560c1e 100644 --- a/src/core/providers-strategy/IFrameProviderStrategy.ts +++ b/src/core/providers/strategies/IFrameProviderStrategy/IFrameProviderStrategy.ts @@ -6,11 +6,8 @@ import { IProvider } from 'core/providers/types/providerFactory.types'; import { networkSelector } from 'store/selectors/networkSelectors'; import { getState } from 'store/store'; import { ProviderErrorsEnum } from 'types'; +import { IFrameProviderType } from './types'; -type IFrameProviderType = { - type: IframeLoginTypes; - address?: string; -}; export class IFrameProviderStrategy { private provider: IframeProvider | null = null; private address?: string; diff --git a/src/core/providers/strategies/IFrameProviderStrategy/index.ts b/src/core/providers/strategies/IFrameProviderStrategy/index.ts new file mode 100644 index 0000000..8d565bb --- /dev/null +++ b/src/core/providers/strategies/IFrameProviderStrategy/index.ts @@ -0,0 +1 @@ +export * from './IFrameProviderStrategy'; diff --git a/src/core/providers/strategies/IFrameProviderStrategy/types/iframe.types.ts b/src/core/providers/strategies/IFrameProviderStrategy/types/iframe.types.ts new file mode 100644 index 0000000..d07fee0 --- /dev/null +++ b/src/core/providers/strategies/IFrameProviderStrategy/types/iframe.types.ts @@ -0,0 +1,6 @@ +import { IframeLoginTypes } from '@multiversx/sdk-web-wallet-iframe-provider/out/constants'; + +export type IFrameProviderType = { + type: IframeLoginTypes; + address?: string; +}; diff --git a/src/core/providers/strategies/IFrameProviderStrategy/types/index.ts b/src/core/providers/strategies/IFrameProviderStrategy/types/index.ts new file mode 100644 index 0000000..48c2b23 --- /dev/null +++ b/src/core/providers/strategies/IFrameProviderStrategy/types/index.ts @@ -0,0 +1 @@ +export * from './iframe.types'; diff --git a/src/core/providers-strategy/LedgerProviderStrategy.ts b/src/core/providers/strategies/LedgerProviderStrategy/LedgerProviderStrategy.ts similarity index 95% rename from src/core/providers-strategy/LedgerProviderStrategy.ts rename to src/core/providers/strategies/LedgerProviderStrategy/LedgerProviderStrategy.ts index 7419fbf..53a3fbf 100644 --- a/src/core/providers-strategy/LedgerProviderStrategy.ts +++ b/src/core/providers/strategies/LedgerProviderStrategy/LedgerProviderStrategy.ts @@ -3,18 +3,11 @@ import { IDAppProviderOptions } from '@multiversx/sdk-dapp-utils/out'; import { HWProvider, IProviderAccount } from '@multiversx/sdk-hw-provider'; import BigNumber from 'bignumber.js'; import { safeWindow } from 'constants/index'; +import { LedgerConnectStateManager } from 'core/managers'; +import { SignTransactionsStateManager } from 'core/managers'; +import { SignEventsEnum } from 'core/managers/SignTransactionsStateManager/types/signTransactionsModal.types'; import { getAddress } from 'core/methods/account/getAddress'; import { getIsLoggedIn } from 'core/methods/account/getIsLoggedIn'; -import { SignEventsEnum } from 'core/providers/helpers/components/SignTransactionsModal/signTransactionsModal.types'; -import { SignTransactionsStateManager } from 'core/providers/helpers/components/SignTransactionsModal/SignTransactionsStateManager'; -import { getAuthTokenText } from 'core/providers/helpers/ledger/helpers/getAuthTokenText'; -import { getLedgerErrorCodes } from 'core/providers/helpers/ledger/helpers/getLedgerErrorCodes'; -import { getLedgerProvider } from 'core/providers/helpers/ledger/helpers/getLedgerProvider'; -import { LedgerConnectStateManager } from 'core/providers/helpers/ledger/helpers/LedgerConnectStateManager'; -import { - ILedgerAccount, - LedgerConnectEventsEnum -} from 'core/providers/helpers/ledger/ledger.types'; import { IEventBus, IProvider, @@ -30,6 +23,12 @@ import { setLedgerLogin } from 'store/actions/loginInfo/loginInfoActions'; import { ProviderErrorsEnum } from 'types'; import { fetchAccount } from 'utils/account/fetchAccount'; import { createModalElement } from 'utils/createModalElement'; +import { + getLedgerProvider, + getLedgerErrorCodes, + getAuthTokenText +} from './helpers'; +import { ILedgerAccount, LedgerConnectEventsEnum } from './types'; const failInitializeErrorText = 'Check if the MultiversX App is open on Ledger'; diff --git a/src/core/providers/helpers/ledger/helpers/getAuthTokenText.ts b/src/core/providers/strategies/LedgerProviderStrategy/helpers/getAuthTokenText.ts similarity index 100% rename from src/core/providers/helpers/ledger/helpers/getAuthTokenText.ts rename to src/core/providers/strategies/LedgerProviderStrategy/helpers/getAuthTokenText.ts diff --git a/src/core/providers/helpers/ledger/getLedgerConfiguration.ts b/src/core/providers/strategies/LedgerProviderStrategy/helpers/getLedgerConfiguration.ts similarity index 100% rename from src/core/providers/helpers/ledger/getLedgerConfiguration.ts rename to src/core/providers/strategies/LedgerProviderStrategy/helpers/getLedgerConfiguration.ts diff --git a/src/core/providers/helpers/ledger/helpers/getLedgerErrorCodes.ts b/src/core/providers/strategies/LedgerProviderStrategy/helpers/getLedgerErrorCodes.ts similarity index 100% rename from src/core/providers/helpers/ledger/helpers/getLedgerErrorCodes.ts rename to src/core/providers/strategies/LedgerProviderStrategy/helpers/getLedgerErrorCodes.ts diff --git a/src/core/providers/helpers/ledger/helpers/getLedgerProvider.ts b/src/core/providers/strategies/LedgerProviderStrategy/helpers/getLedgerProvider.ts similarity index 90% rename from src/core/providers/helpers/ledger/helpers/getLedgerProvider.ts rename to src/core/providers/strategies/LedgerProviderStrategy/helpers/getLedgerProvider.ts index cd8fb3f..6b50e4f 100644 --- a/src/core/providers/helpers/ledger/helpers/getLedgerProvider.ts +++ b/src/core/providers/strategies/LedgerProviderStrategy/helpers/getLedgerProvider.ts @@ -1,9 +1,9 @@ import { HWProvider } from '@multiversx/sdk-hw-provider'; import { getIsLoggedIn } from 'core/methods/account/getIsLoggedIn'; +import { getAccountProvider } from 'core/providers/helpers/accountProvider'; import { ledgerLoginSelector } from 'store/selectors/loginInfoSelectors'; import { getState } from 'store/store'; -import { getAccountProvider } from '../../../accountProvider'; -import { getLedgerConfiguration } from '../getLedgerConfiguration'; +import { getLedgerConfiguration } from './getLedgerConfiguration'; export async function getLedgerProvider() { const isLoggedIn = getIsLoggedIn(); diff --git a/src/core/providers/helpers/ledger/helpers/getLedgerVersionOptions.ts b/src/core/providers/strategies/LedgerProviderStrategy/helpers/getLedgerVersionOptions.ts similarity index 100% rename from src/core/providers/helpers/ledger/helpers/getLedgerVersionOptions.ts rename to src/core/providers/strategies/LedgerProviderStrategy/helpers/getLedgerVersionOptions.ts diff --git a/src/core/providers/strategies/LedgerProviderStrategy/helpers/index.ts b/src/core/providers/strategies/LedgerProviderStrategy/helpers/index.ts new file mode 100644 index 0000000..68fd2a1 --- /dev/null +++ b/src/core/providers/strategies/LedgerProviderStrategy/helpers/index.ts @@ -0,0 +1,6 @@ +export * from './getAuthTokenText'; +export * from './getLedgerConfiguration'; +export * from './getLedgerErrorCodes'; +export * from './getLedgerProvider'; +export * from './getLedgerVersionOptions'; +export * from './secondsToTimeString'; diff --git a/src/core/providers/helpers/ledger/helpers/secondsToTimeString.ts b/src/core/providers/strategies/LedgerProviderStrategy/helpers/secondsToTimeString.ts similarity index 100% rename from src/core/providers/helpers/ledger/helpers/secondsToTimeString.ts rename to src/core/providers/strategies/LedgerProviderStrategy/helpers/secondsToTimeString.ts diff --git a/src/core/providers/strategies/LedgerProviderStrategy/index.ts b/src/core/providers/strategies/LedgerProviderStrategy/index.ts new file mode 100644 index 0000000..e385951 --- /dev/null +++ b/src/core/providers/strategies/LedgerProviderStrategy/index.ts @@ -0,0 +1 @@ +export * from './LedgerProviderStrategy'; diff --git a/src/core/providers/helpers/ledger/helpers/tests/getLedgerVersionOptions.test.ts b/src/core/providers/strategies/LedgerProviderStrategy/tests/getLedgerVersionOptions.test.ts similarity index 97% rename from src/core/providers/helpers/ledger/helpers/tests/getLedgerVersionOptions.test.ts rename to src/core/providers/strategies/LedgerProviderStrategy/tests/getLedgerVersionOptions.test.ts index 9c5310d..e242514 100644 --- a/src/core/providers/helpers/ledger/helpers/tests/getLedgerVersionOptions.test.ts +++ b/src/core/providers/strategies/LedgerProviderStrategy/tests/getLedgerVersionOptions.test.ts @@ -1,4 +1,4 @@ -import ledgerVersionOptions from '../getLedgerVersionOptions'; +import ledgerVersionOptions from '../helpers/getLedgerVersionOptions'; describe('ledgerOptions tests', () => { test('detects ledger without multiAccount', () => { diff --git a/src/core/providers/helpers/ledger/helpers/tests/secondsToTimeString.test.ts b/src/core/providers/strategies/LedgerProviderStrategy/tests/secondsToTimeString.test.ts similarity index 96% rename from src/core/providers/helpers/ledger/helpers/tests/secondsToTimeString.test.ts rename to src/core/providers/strategies/LedgerProviderStrategy/tests/secondsToTimeString.test.ts index 5353153..a1bd883 100644 --- a/src/core/providers/helpers/ledger/helpers/tests/secondsToTimeString.test.ts +++ b/src/core/providers/strategies/LedgerProviderStrategy/tests/secondsToTimeString.test.ts @@ -1,4 +1,4 @@ -import { secondsToTimeString } from '../secondsToTimeString'; +import { secondsToTimeString } from '../helpers/secondsToTimeString'; describe('secondsToTimeString tests', () => { it('converts 0 seconds to "N/A time"', () => { diff --git a/src/core/providers/strategies/LedgerProviderStrategy/types/index.ts b/src/core/providers/strategies/LedgerProviderStrategy/types/index.ts new file mode 100644 index 0000000..b997314 --- /dev/null +++ b/src/core/providers/strategies/LedgerProviderStrategy/types/index.ts @@ -0,0 +1 @@ +export * from './ledger.types'; diff --git a/src/core/providers/helpers/ledger/ledger.types.ts b/src/core/providers/strategies/LedgerProviderStrategy/types/ledger.types.ts similarity index 100% rename from src/core/providers/helpers/ledger/ledger.types.ts rename to src/core/providers/strategies/LedgerProviderStrategy/types/ledger.types.ts diff --git a/src/core/providers-strategy/WalletConnectProviderStrategy.ts b/src/core/providers/strategies/WalletConnectProviderStrategy/WalletConnectProviderStrategy.ts similarity index 96% rename from src/core/providers-strategy/WalletConnectProviderStrategy.ts rename to src/core/providers/strategies/WalletConnectProviderStrategy/WalletConnectProviderStrategy.ts index 968ae73..5fb4072 100644 --- a/src/core/providers-strategy/WalletConnectProviderStrategy.ts +++ b/src/core/providers/strategies/WalletConnectProviderStrategy/WalletConnectProviderStrategy.ts @@ -4,14 +4,9 @@ import { SessionTypes } from '@multiversx/sdk-wallet-connect-provider/out'; import { safeWindow } from 'constants/window.constants'; +import { WalletConnectStateManager } from 'core/managers/WalletConnectStateManager/WalletConnectStateManager'; import { getIsLoggedIn } from 'core/methods/account/getIsLoggedIn'; -import { getAccountProvider } from 'core/providers/accountProvider'; -import { - WalletConnectEventsEnum, - WalletConnectV2Error, - WalletConnectConfig -} from 'core/providers/helpers/walletConnect/walletConnect.types'; -import { WalletConnectStateManager } from 'core/providers/helpers/walletConnect/WalletConnectStateManagement'; +import { getAccountProvider } from 'core/providers/helpers/accountProvider'; import { IEventBus, IProvider @@ -30,6 +25,11 @@ import { WalletConnectOptionalMethodsEnum, WalletConnectV2Provider } from 'utils/walletconnect/__sdkWalletconnectProvider'; +import { + WalletConnectEventsEnum, + WalletConnectV2Error, + WalletConnectConfig +} from './types'; const dappMethods: string[] = [ WalletConnectOptionalMethodsEnum.CANCEL_ACTION, diff --git a/src/core/providers/strategies/WalletConnectProviderStrategy/index.ts b/src/core/providers/strategies/WalletConnectProviderStrategy/index.ts new file mode 100644 index 0000000..8cd6870 --- /dev/null +++ b/src/core/providers/strategies/WalletConnectProviderStrategy/index.ts @@ -0,0 +1 @@ +export * from './WalletConnectProviderStrategy'; diff --git a/src/core/providers/strategies/WalletConnectProviderStrategy/types/index.ts b/src/core/providers/strategies/WalletConnectProviderStrategy/types/index.ts new file mode 100644 index 0000000..de7f71d --- /dev/null +++ b/src/core/providers/strategies/WalletConnectProviderStrategy/types/index.ts @@ -0,0 +1 @@ +export * from './walletConnect.types'; diff --git a/src/core/providers/helpers/walletConnect/walletConnect.types.ts b/src/core/providers/strategies/WalletConnectProviderStrategy/types/walletConnect.types.ts similarity index 100% rename from src/core/providers/helpers/walletConnect/walletConnect.types.ts rename to src/core/providers/strategies/WalletConnectProviderStrategy/types/walletConnect.types.ts diff --git a/src/core/providers/strategies/index.ts b/src/core/providers/strategies/index.ts new file mode 100644 index 0000000..bc64baf --- /dev/null +++ b/src/core/providers/strategies/index.ts @@ -0,0 +1,5 @@ +export * from './CrossWindowProviderStrategy'; +export * from './ExtensionProviderStrategy'; +export * from './IFrameProviderStrategy'; +export * from './LedgerProviderStrategy'; +export * from './WalletConnectProviderStrategy'; diff --git a/src/store/actions/config/configActions.ts b/src/store/actions/config/configActions.ts index 8816ef1..bfcc425 100644 --- a/src/store/actions/config/configActions.ts +++ b/src/store/actions/config/configActions.ts @@ -1,5 +1,5 @@ -import { CrossWindowConfig } from 'core/providers/helpers/crossWindow/crossWindow.type'; -import { WalletConnectConfig } from 'core/providers/helpers/walletConnect/walletConnect.types'; +import { CrossWindowConfig } from 'core/providers/strategies/CrossWindowProviderStrategy/types'; +import { WalletConnectConfig } from 'core/providers/strategies/WalletConnectProviderStrategy/types'; import { NativeAuthConfigType } from 'services/nativeAuth/nativeAuth.types'; import { getStore } from 'store/store'; diff --git a/src/store/slices/config/config.types.ts b/src/store/slices/config/config.types.ts index 8fbeb4a..cc765bc 100644 --- a/src/store/slices/config/config.types.ts +++ b/src/store/slices/config/config.types.ts @@ -1,5 +1,5 @@ -import { CrossWindowConfig } from 'core/providers/helpers/crossWindow/crossWindow.type'; -import { WalletConnectConfig } from 'core/providers/helpers/walletConnect/walletConnect.types'; +import { CrossWindowConfig } from 'core/providers/strategies/CrossWindowProviderStrategy/types'; +import { WalletConnectConfig } from 'core/providers/strategies/WalletConnectProviderStrategy/types'; import { NativeAuthConfigType } from 'services/nativeAuth/nativeAuth.types'; export interface ConfigSliceType { diff --git a/src/utils/account/refreshAccount.ts b/src/utils/account/refreshAccount.ts index 42f2503..85d0c16 100644 --- a/src/utils/account/refreshAccount.ts +++ b/src/utils/account/refreshAccount.ts @@ -1,6 +1,6 @@ import { getAddress } from 'core/methods/account/getAddress'; import { getLatestNonce } from 'core/methods/account/getLatestNonce'; -import { getAccountProvider } from 'core/providers/accountProvider'; +import { getAccountProvider } from 'core/providers/helpers/accountProvider'; import { setAccount } from 'store/actions'; import { fetchAccount } from './fetchAccount';