mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-30 08:09:15 +01:00
69 lines
2.0 KiB
JavaScript
69 lines
2.0 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import {
|
|
getAddressBook,
|
|
getAddressBookEntry,
|
|
getMetaMaskAccountsOrdered,
|
|
} from '../../../../selectors';
|
|
|
|
import {
|
|
updateRecipient,
|
|
updateRecipientUserInput,
|
|
useMyAccountsForRecipientSearch,
|
|
useContactListForRecipientSearch,
|
|
getIsUsingMyAccountForRecipientSearch,
|
|
getRecipientUserInput,
|
|
getRecipient,
|
|
addHistoryEntry,
|
|
} from '../../../../ducks/send';
|
|
import {
|
|
getEnsResolution,
|
|
getEnsError,
|
|
getEnsWarning,
|
|
} from '../../../../ducks/ens';
|
|
import AddRecipient from './add-recipient.component';
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AddRecipient);
|
|
|
|
function mapStateToProps(state) {
|
|
const ensResolution = getEnsResolution(state);
|
|
|
|
let addressBookEntryName = '';
|
|
if (ensResolution) {
|
|
const addressBookEntry = getAddressBookEntry(state, ensResolution) || {};
|
|
addressBookEntryName = addressBookEntry.name;
|
|
}
|
|
|
|
const addressBook = getAddressBook(state);
|
|
|
|
const ownedAccounts = getMetaMaskAccountsOrdered(state);
|
|
|
|
return {
|
|
addressBook,
|
|
addressBookEntryName,
|
|
contacts: addressBook.filter(({ name }) => Boolean(name)),
|
|
ensResolution,
|
|
ensError: getEnsError(state),
|
|
ensWarning: getEnsWarning(state),
|
|
nonContacts: addressBook.filter(({ name }) => !name),
|
|
ownedAccounts,
|
|
isUsingMyAccountsForRecipientSearch:
|
|
getIsUsingMyAccountForRecipientSearch(state),
|
|
userInput: getRecipientUserInput(state),
|
|
recipient: getRecipient(state),
|
|
};
|
|
}
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
return {
|
|
addHistoryEntry: (entry) => dispatch(addHistoryEntry(entry)),
|
|
updateRecipient: ({ address, nickname }) =>
|
|
dispatch(updateRecipient({ address, nickname })),
|
|
updateRecipientUserInput: (newInput) =>
|
|
dispatch(updateRecipientUserInput(newInput)),
|
|
useMyAccountsForRecipientSearch: () =>
|
|
dispatch(useMyAccountsForRecipientSearch()),
|
|
useContactListForRecipientSearch: () =>
|
|
dispatch(useContactListForRecipientSearch()),
|
|
};
|
|
}
|