Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into amg/waiting-ac…
Browse files Browse the repository at this point in the history
…tion-modal
  • Loading branch information
mgavrila committed Dec 17, 2024
2 parents 3b406ae + 699ebc7 commit 65e8664
Show file tree
Hide file tree
Showing 47 changed files with 83 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/core/managers/LedgerConnectStateManager/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './LedgerConnectStateManager';
Original file line number Diff line number Diff line change
@@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/core/managers/SignTransactionsStateManager/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './SignTransactionsStateManager';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './signTransactionsModal.types';
File renamed without changes.
1 change: 1 addition & 0 deletions src/core/managers/TransactionManager/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './TransactionManager';
Original file line number Diff line number Diff line change
@@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/core/managers/WalletConnectStateManager/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './WalletConnectStateManager';
4 changes: 4 additions & 0 deletions src/core/managers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './LedgerConnectStateManager';
export * from './SignTransactionsStateManager';
export * from './TransactionManager';
export * from './WalletConnectStateManager';
4 changes: 2 additions & 2 deletions src/core/methods/initApp/initApp.types.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
14 changes: 8 additions & 6 deletions src/core/providers/ProviderFactory.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/core/providers/helpers/restoreProvider.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion src/core/providers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { getAccountProvider } from './accountProvider';
export { getAccountProvider } from './helpers/accountProvider';
export * from './strategies';

/*
// TODO: create detectProvider function
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './CrossWindowProviderStrategy';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './crossWindow.types';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ExtensionProviderStrategy';
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ import { networkSelector } from 'store/selectors/networkSelectors';
import { getState } from 'store/store';
import { ProviderErrorsEnum } from 'types';
import { createModalElement } from 'utils/createModalElement';
import { IFrameProviderType } from './types';

type IFrameProviderType = {
type: IframeLoginTypes;
address?: string;
};
export class IFrameProviderStrategy {
private provider: IframeProvider | null = null;
private address?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './IFrameProviderStrategy';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { IframeLoginTypes } from '@multiversx/sdk-web-wallet-iframe-provider/out/constants';

export type IFrameProviderType = {
type: IframeLoginTypes;
address?: string;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './iframe.types';
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './getAuthTokenText';
export * from './getLedgerConfiguration';
export * from './getLedgerErrorCodes';
export * from './getLedgerProvider';
export * from './getLedgerVersionOptions';
export * from './secondsToTimeString';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './LedgerProviderStrategy';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ledgerVersionOptions from '../getLedgerVersionOptions';
import ledgerVersionOptions from '../helpers/getLedgerVersionOptions';

describe('ledgerOptions tests', () => {
test('detects ledger without multiAccount', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { secondsToTimeString } from '../secondsToTimeString';
import { secondsToTimeString } from '../helpers/secondsToTimeString';

describe('secondsToTimeString tests', () => {
it('converts 0 seconds to "N/A time"', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ledger.types';
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@ import {
OptionalOperation
} 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 { PendingTransactionsEventsEnum } from 'core/providers/helpers/pendingTransactions/pendingTransactions.types';
import { PendingTransactionsStateManager } from 'core/providers/helpers/pendingTransactions/PendingTransactionsStateManagement';
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,
Expand All @@ -39,6 +32,13 @@ import {
WalletConnectOptionalMethodsEnum,
WalletConnectV2Provider
} from 'utils/walletconnect/__sdkWalletconnectProvider';
import {
WalletConnectEventsEnum,
WalletConnectV2Error,
WalletConnectConfig
} from './types';
import { PendingTransactionsEventsEnum } from 'core/providers/helpers/pendingTransactions/pendingTransactions.types';
import { PendingTransactionsStateManager } from 'core/providers/helpers/pendingTransactions/PendingTransactionsStateManagement';

const dappMethods: string[] = [
WalletConnectOptionalMethodsEnum.CANCEL_ACTION,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './WalletConnectProviderStrategy';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './walletConnect.types';
5 changes: 5 additions & 0 deletions src/core/providers/strategies/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './CrossWindowProviderStrategy';
export * from './ExtensionProviderStrategy';
export * from './IFrameProviderStrategy';
export * from './LedgerProviderStrategy';
export * from './WalletConnectProviderStrategy';
4 changes: 2 additions & 2 deletions src/store/actions/config/configActions.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
4 changes: 2 additions & 2 deletions src/store/slices/config/config.types.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/account/refreshAccount.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down

0 comments on commit 65e8664

Please sign in to comment.