-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into rt/feature/dapp-template
- Loading branch information
Showing
23 changed files
with
599 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/core/managers/PendingTransactionsStateManager/PendingTransactionsStateManagement.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { IEventBus } from 'types/manager.types'; | ||
import { | ||
IPendingTransactionsModalData, | ||
PendingTransactionsEventsEnum | ||
} from './types'; | ||
|
||
export class PendingTransactionsStateManager< | ||
T extends | ||
IEventBus<IPendingTransactionsModalData> = IEventBus<IPendingTransactionsModalData> | ||
> { | ||
private static instance: PendingTransactionsStateManager< | ||
IEventBus<IPendingTransactionsModalData> | ||
> | null = null; | ||
private eventBus: T; | ||
|
||
private initialData: IPendingTransactionsModalData = { | ||
isPending: false, | ||
title: '', | ||
subtitle: '', | ||
shouldClose: false | ||
}; | ||
|
||
private data: IPendingTransactionsModalData = { ...this.initialData }; | ||
|
||
private constructor(eventBus: T) { | ||
this.eventBus = eventBus; | ||
} | ||
|
||
public static getInstance<U extends IEventBus<IPendingTransactionsModalData>>( | ||
eventBus: U | ||
): PendingTransactionsStateManager<U> { | ||
if (!PendingTransactionsStateManager.instance) { | ||
PendingTransactionsStateManager.instance = | ||
new PendingTransactionsStateManager(eventBus); | ||
} | ||
return PendingTransactionsStateManager.instance as PendingTransactionsStateManager<U>; | ||
} | ||
|
||
public closeAndReset(): void { | ||
this.data.shouldClose = true; | ||
this.notifyDataUpdate(); | ||
this.resetData(); | ||
} | ||
|
||
private resetData(): void { | ||
this.data = { ...this.initialData }; | ||
} | ||
|
||
public updateData(newData: IPendingTransactionsModalData): void { | ||
this.data = { ...this.data, ...newData }; | ||
this.notifyDataUpdate(); | ||
} | ||
|
||
private notifyDataUpdate(): void { | ||
this.eventBus.publish(PendingTransactionsEventsEnum.DATA_UPDATE, this.data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './PendingTransactionsStateManagement'; | ||
export * from './types'; |
1 change: 1 addition & 0 deletions
1
src/core/managers/PendingTransactionsStateManager/types/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './pendingTransactions.types'; |
12 changes: 12 additions & 0 deletions
12
src/core/managers/PendingTransactionsStateManager/types/pendingTransactions.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// types here need to be synced with the types in sdk-dapp-core-ui | ||
export enum PendingTransactionsEventsEnum { | ||
'CLOSE' = 'CLOSE', | ||
'DATA_UPDATE' = 'DATA_UPDATE' | ||
} | ||
|
||
export interface IPendingTransactionsModalData { | ||
isPending: boolean; | ||
title: string; | ||
subtitle?: string; | ||
shouldClose?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/core/providers/strategies/CrossWindowProviderStrategy/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './CrossWindowProviderStrategy'; | ||
export * from './types'; |
Oops, something went wrong.