You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.2 KiB
46 lines
1.2 KiB
4 years ago
|
import { connect } from 'react-redux';
|
||
5 years ago
|
import {
|
||
|
getSendEnsResolution,
|
||
|
getSendEnsResolutionError,
|
||
5 years ago
|
accountsWithSendEtherInfoSelector,
|
||
5 years ago
|
getAddressBook,
|
||
|
getAddressBookEntry,
|
||
4 years ago
|
} from '../../../../selectors';
|
||
5 years ago
|
|
||
4 years ago
|
import { updateSendTo } from '../../../../store/actions';
|
||
|
import AddRecipient from './add-recipient.component';
|
||
5 years ago
|
|
||
4 years ago
|
export default connect(mapStateToProps, mapDispatchToProps)(AddRecipient);
|
||
5 years ago
|
|
||
4 years ago
|
function mapStateToProps(state) {
|
||
4 years ago
|
const ensResolution = getSendEnsResolution(state);
|
||
5 years ago
|
|
||
4 years ago
|
let addressBookEntryName = '';
|
||
5 years ago
|
if (ensResolution) {
|
||
4 years ago
|
const addressBookEntry = getAddressBookEntry(state, ensResolution) || {};
|
||
|
addressBookEntryName = addressBookEntry.name;
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
const addressBook = getAddressBook(state);
|
||
5 years ago
|
|
||
4 years ago
|
const ownedAccounts = accountsWithSendEtherInfoSelector(state).sort((a, b) =>
|
||
|
a.name.localeCompare(b.name),
|
||
4 years ago
|
);
|
||
4 years ago
|
|
||
5 years ago
|
return {
|
||
|
addressBook,
|
||
|
addressBookEntryName,
|
||
4 years ago
|
contacts: addressBook.filter(({ name }) => Boolean(name)),
|
||
4 years ago
|
ensResolution,
|
||
|
ensResolutionError: getSendEnsResolutionError(state),
|
||
5 years ago
|
nonContacts: addressBook.filter(({ name }) => !name),
|
||
4 years ago
|
ownedAccounts,
|
||
4 years ago
|
};
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
function mapDispatchToProps(dispatch) {
|
||
5 years ago
|
return {
|
||
|
updateSendTo: (to, nickname) => dispatch(updateSendTo(to, nickname)),
|
||
4 years ago
|
};
|
||
5 years ago
|
}
|