diff --git a/src/core/managers/PendingTransactionsStateManager/PendingTransactionsStateManagement.ts b/src/core/managers/PendingTransactionsStateManager/PendingTransactionsStateManagement.ts index 3d24845..c6abb54 100644 --- a/src/core/managers/PendingTransactionsStateManager/PendingTransactionsStateManagement.ts +++ b/src/core/managers/PendingTransactionsStateManager/PendingTransactionsStateManagement.ts @@ -1,15 +1,16 @@ +import { IEventBus } from 'types/manager.types'; import { IPendingTransactionsModalData, PendingTransactionsEventsEnum } from './types'; -interface IEventBus { - publish(event: string, data: any): void; -} - -export class PendingTransactionsStateManager { - private static instance: PendingTransactionsStateManager | null = - null; +export class PendingTransactionsStateManager< + T extends + IEventBus = IEventBus +> { + private static instance: PendingTransactionsStateManager< + IEventBus + > | null = null; private eventBus: T; private initialData: IPendingTransactionsModalData = { @@ -25,7 +26,7 @@ export class PendingTransactionsStateManager { this.eventBus = eventBus; } - public static getInstance( + public static getInstance>( eventBus: U ): PendingTransactionsStateManager { if (!PendingTransactionsStateManager.instance) { diff --git a/src/core/managers/WalletConnectStateManager/WalletConnectStateManager.ts b/src/core/managers/WalletConnectStateManager/WalletConnectStateManager.ts index 6468f6e..a33d9cf 100644 --- a/src/core/managers/WalletConnectStateManager/WalletConnectStateManager.ts +++ b/src/core/managers/WalletConnectStateManager/WalletConnectStateManager.ts @@ -2,13 +2,15 @@ import { IWalletConnectModalData, WalletConnectEventsEnum } from 'core/providers/strategies/WalletConnectProviderStrategy/types'; - -interface IEventBus { - publish(event: string, data: any): void; -} - -export class WalletConnectStateManager { - private static instance: WalletConnectStateManager | null = null; +import { IEventBus } from 'types/manager.types'; + +export class WalletConnectStateManager< + T extends + IEventBus = IEventBus +> { + private static instance: WalletConnectStateManager< + IEventBus + > | null = null; private eventBus: T; private initialData: IWalletConnectModalData = { @@ -22,7 +24,7 @@ export class WalletConnectStateManager { this.eventBus = eventBus; } - public static getInstance( + public static getInstance>( eventBus: U ): WalletConnectStateManager { if (!WalletConnectStateManager.instance) { diff --git a/src/types/manager.types.ts b/src/types/manager.types.ts new file mode 100644 index 0000000..5f6cedf --- /dev/null +++ b/src/types/manager.types.ts @@ -0,0 +1,3 @@ +export interface IEventBus { + publish(event: string, data: T): void; +}