-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add txStatuses to BridgeStatusController
- Loading branch information
1 parent
dcdd07a
commit d79e23d
Showing
6 changed files
with
75 additions
and
25 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import BridgeStatusController from '../../../app/scripts/controllers/bridge-status/bridge-status-controller'; | ||
import { | ||
BridgeStatusAction, | ||
StatusRequest, | ||
} from '../../../app/scripts/controllers/bridge-status/types'; | ||
import { forceUpdateMetamaskState } from '../../store/actions'; | ||
import { submitRequestToBackground } from '../../store/background-connection'; | ||
import { MetaMaskReduxDispatch } from '../../store/store'; | ||
|
||
const callBridgeStatusControllerMethod = <T extends any[]>( | ||
bridgeAction: BridgeStatusAction, | ||
args?: T, | ||
) => { | ||
return async (dispatch: MetaMaskReduxDispatch) => { | ||
await submitRequestToBackground(bridgeAction, args); | ||
await forceUpdateMetamaskState(dispatch); | ||
}; | ||
}; | ||
|
||
export const getBridgeTxStatus = (statusRequest: StatusRequest) => { | ||
return async (dispatch: MetaMaskReduxDispatch) => { | ||
return dispatch( | ||
callBridgeStatusControllerMethod< | ||
Parameters<BridgeStatusController['getBridgeTxStatus']> | ||
>(BridgeStatusAction.GET_BRIDGE_TX_STATUS, [statusRequest]), | ||
); | ||
}; | ||
}; |
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,19 @@ | ||
import { createSelector } from 'reselect'; | ||
import { BridgeStatusControllerState } from '../../../app/scripts/controllers/bridge-status/types'; | ||
|
||
export type BridgeStatusAppState = { | ||
metamask: { | ||
bridgeStatusState: BridgeStatusControllerState; | ||
}; | ||
}; | ||
|
||
export const selectBridgeStatusState = (state: BridgeStatusAppState) => | ||
state.metamask.bridgeStatusState; | ||
|
||
export const selectBridgeTxStatuses = createSelector( | ||
[ | ||
selectBridgeStatusState, | ||
(_: BridgeStatusAppState, txHash: string) => txHash, | ||
], | ||
(bridgeStatusState) => bridgeStatusState.txStatuses, | ||
); |