aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/containers
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-11-13 05:30:47 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-11-13 05:30:47 +0800
commit79f0324abc6e59d5595770e44d620e6d0cccd6bc (patch)
treecab441568b4362b90f2626257576ebab60b7ecbb /packages/instant/src/containers
parenta8a1ea92a614181ebdf6c738139723f0d5c6da69 (diff)
downloaddexon-0x-contracts-79f0324abc6e59d5595770e44d620e6d0cccd6bc.tar.gz
dexon-0x-contracts-79f0324abc6e59d5595770e44d620e6d0cccd6bc.tar.zst
dexon-0x-contracts-79f0324abc6e59d5595770e44d620e6d0cccd6bc.zip
feat: integrate wallet flow with heartbeat and other branches
Diffstat (limited to 'packages/instant/src/containers')
-rw-r--r--packages/instant/src/containers/connected_account_payment_method.ts39
1 files changed, 33 insertions, 6 deletions
diff --git a/packages/instant/src/containers/connected_account_payment_method.ts b/packages/instant/src/containers/connected_account_payment_method.ts
index ee57d1829..c20af67cc 100644
--- a/packages/instant/src/containers/connected_account_payment_method.ts
+++ b/packages/instant/src/containers/connected_account_payment_method.ts
@@ -4,34 +4,61 @@ import { Dispatch } from 'redux';
import { PaymentMethod } from '../components/payment_method';
import { Action, actions } from '../redux/actions';
+import { asyncData } from '../redux/async_data';
import { State } from '../redux/reducer';
-import { Account, Network, StandardSlidingPanelContent } from '../types';
+import { Account, Network, ProviderState, StandardSlidingPanelContent } from '../types';
export interface ConnectedAccountPaymentMethodProps {}
interface ConnectedState {
- account: Account;
network: Network;
+ providerState: ProviderState;
}
interface ConnectedDispatch {
- openStandardSlidingPanel: (content: StandardSlidingPanelContent) => void;
+ onInstallWalletClick: () => void;
+ unlockWalletAndDispatchToStore: (providerState: ProviderState) => void;
+}
+
+interface ConnectedProps {
+ onInstallWalletClick: () => void;
+ onUnlockWalletClick: () => void;
+ account: Account;
+ network: Network;
}
+type FinalProps = ConnectedProps & ConnectedAccountPaymentMethodProps;
+
const mapStateToProps = (state: State, _ownProps: ConnectedAccountPaymentMethodProps): ConnectedState => ({
- account: state.providerState.account,
network: state.network,
+ providerState: state.providerState,
});
const mapDispatchToProps = (
dispatch: Dispatch<Action>,
ownProps: ConnectedAccountPaymentMethodProps,
): ConnectedDispatch => ({
- openStandardSlidingPanel: (content: StandardSlidingPanelContent) =>
- dispatch(actions.openStandardSlidingPanel(content)),
+ onInstallWalletClick: () => dispatch(actions.openStandardSlidingPanel(StandardSlidingPanelContent.InstallWallet)),
+ unlockWalletAndDispatchToStore: async (providerState: ProviderState) =>
+ asyncData.fetchAccountInfoAndDispatchToStore(providerState, dispatch, true),
+});
+
+const mergeProps = (
+ connectedState: ConnectedState,
+ connectedDispatch: ConnectedDispatch,
+ ownProps: ConnectedAccountPaymentMethodProps,
+): FinalProps => ({
+ ...ownProps,
+ network: connectedState.network,
+ account: connectedState.providerState.account,
+ onInstallWalletClick: connectedDispatch.onInstallWalletClick,
+ onUnlockWalletClick: () => {
+ connectedDispatch.unlockWalletAndDispatchToStore(connectedState.providerState);
+ },
});
export const ConnectedAccountPaymentMethod: React.ComponentClass<ConnectedAccountPaymentMethodProps> = connect(
mapStateToProps,
mapDispatchToProps,
+ mergeProps,
)(PaymentMethod);