1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-04 23:14:56 +01:00
metamask-extension/ui/components/app/modals/export-private-key-modal/export-private-key-modal.container.js

49 lines
1.6 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
2020-11-03 00:41:28 +01:00
import {
exportAccount,
hideWarning,
showModal,
hideModal,
clearAccountDetails,
} from '../../../../store/actions';
import { getSelectedIdentity } from '../../../../selectors';
import ExportPrivateKeyModal from './export-private-key-modal.component';
2020-11-03 00:41:28 +01:00
function mapStateToPropsFactory() {
let selectedIdentity = null;
2020-11-03 00:41:28 +01:00
return function mapStateToProps(state) {
// We should **not** change the identity displayed here even if it changes from underneath us.
// If we do, we will be showing the user one private key and a **different** address and name.
// Note that the selected identity **will** change from underneath us when we unlock the keyring
// which is the expected behavior that we are side-stepping.
selectedIdentity = selectedIdentity || getSelectedIdentity(state);
return {
warning: state.appState.warning,
privateKey: state.appState.accountDetail.privateKey,
selectedIdentity,
previousModalState: state.appState.modal.previousModalState.name,
};
};
}
2020-11-03 00:41:28 +01:00
function mapDispatchToProps(dispatch) {
return {
exportAccount: (password, address) => {
2020-11-03 00:41:28 +01:00
return dispatch(exportAccount(password, address)).then((res) => {
dispatch(hideWarning());
return res;
});
},
2020-11-03 00:41:28 +01:00
showAccountDetailModal: () =>
dispatch(showModal({ name: 'ACCOUNT_DETAILS' })),
hideModal: () => dispatch(hideModal()),
hideWarning: () => dispatch(hideWarning()),
clearAccountDetails: () => dispatch(clearAccountDetails()),
};
}
2020-11-03 00:41:28 +01:00
export default connect(
mapStateToPropsFactory,
mapDispatchToProps,
)(ExportPrivateKeyModal);