fix getNameFromAddressBook selector & selector calls
This commit is contained in:
parent
171528d418
commit
0e9b6d2cc1
|
@ -35,15 +35,18 @@ export const getAddressBookListSelector: Selector<GlobalState, {}, List<AddressB
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
export const getNameFromAddressBook = (userAddress: string): string | null =>
|
export const getNameFromAddressBook = createSelector(
|
||||||
createSelector(getAddressBook, (addressBook: AddressBook, address: string) => {
|
getAddressBookListSelector,
|
||||||
|
(_, address) => address,
|
||||||
|
(addressBook: Map<string, AddressBook>, address: string) => {
|
||||||
if (!address) {
|
if (!address) {
|
||||||
return 'UNKNOWN'
|
return 'UNKNOWN'
|
||||||
}
|
}
|
||||||
|
|
||||||
const adbkEntry = addressBook.find((addressBookItem) => addressBookItem.address === userAddress)
|
const adbkEntry = addressBook.find((addressBookItem) => addressBookItem.address === address)
|
||||||
if (adbkEntry) {
|
if (adbkEntry) {
|
||||||
return adbkEntry.name
|
return adbkEntry.name
|
||||||
}
|
}
|
||||||
return 'UNKNOWN'
|
return 'UNKNOWN'
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
|
@ -47,7 +47,7 @@ const TransferDescription = ({ from, txFromName, value = '' }: TransferDescProps
|
||||||
|
|
||||||
const IncomingTxDescription = ({ tx }: Props) => {
|
const IncomingTxDescription = ({ tx }: Props) => {
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
const txFromName = useSelector(getNameFromAddressBook(tx.from))
|
const txFromName = useSelector((state) => getNameFromAddressBook(state, tx.from))
|
||||||
return (
|
return (
|
||||||
<Block className={classes.txDataContainer}>
|
<Block className={classes.txDataContainer}>
|
||||||
<TransferDescription from={tx.from} txFromName={txFromName} value={getIncomingTxAmount(tx)} />
|
<TransferDescription from={tx.from} txFromName={txFromName} value={getIncomingTxAmount(tx)} />
|
||||||
|
|
|
@ -57,8 +57,7 @@ const OwnerComponent = ({
|
||||||
thresholdReached,
|
thresholdReached,
|
||||||
userAddress,
|
userAddress,
|
||||||
}: OwnerProps) => {
|
}: OwnerProps) => {
|
||||||
const nameInAdbk = useSelector(getNameFromAddressBook(owner))
|
const nameInAdbk = useSelector((state) => getNameFromAddressBook(state, owner))
|
||||||
const ownerName = nameInAdbk || 'UNKNOWN'
|
|
||||||
const [imgCircle, setImgCircle] = React.useState(ConfirmSmallGreyCircle)
|
const [imgCircle, setImgCircle] = React.useState(ConfirmSmallGreyCircle)
|
||||||
|
|
||||||
React.useMemo(() => {
|
React.useMemo(() => {
|
||||||
|
@ -80,7 +79,7 @@ const OwnerComponent = ({
|
||||||
<Identicon address={owner} className={classes.icon} diameter={32} />
|
<Identicon address={owner} className={classes.icon} diameter={32} />
|
||||||
<Block>
|
<Block>
|
||||||
<Paragraph className={classes.name} noMargin>
|
<Paragraph className={classes.name} noMargin>
|
||||||
{ownerName}
|
{nameInAdbk}
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<EtherscanLink className={classes.address} cut={4} type="address" value={owner} />
|
<EtherscanLink className={classes.address} cut={4} type="address" value={owner} />
|
||||||
</Block>
|
</Block>
|
||||||
|
@ -140,7 +139,7 @@ const OwnerComponent = ({
|
||||||
)}
|
)}
|
||||||
</Block>
|
</Block>
|
||||||
)}
|
)}
|
||||||
{owner.address === executor && <Block className={classes.executor}>Executor</Block>}
|
{owner === executor && <Block className={classes.executor}>Executor</Block>}
|
||||||
</Block>
|
</Block>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ type CustomDescProps = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const TransferDescription = ({ amount = '', recipient }: TransferDescProps) => {
|
const TransferDescription = ({ amount = '', recipient }: TransferDescProps) => {
|
||||||
const recipientName = useSelector(getNameFromAddressBook(recipient))
|
const recipientName = useSelector((state) => getNameFromAddressBook(state, recipient))
|
||||||
return (
|
return (
|
||||||
<Block data-testid={TRANSACTIONS_DESC_SEND_TEST_ID}>
|
<Block data-testid={TRANSACTIONS_DESC_SEND_TEST_ID}>
|
||||||
<Bold>Send {amount} to:</Bold>
|
<Bold>Send {amount} to:</Bold>
|
||||||
|
@ -83,7 +83,7 @@ const TransferDescription = ({ amount = '', recipient }: TransferDescProps) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const RemovedOwner = ({ removedOwner }: { removedOwner: string }) => {
|
const RemovedOwner = ({ removedOwner }: { removedOwner: string }) => {
|
||||||
const ownerChangedName = useSelector(getNameFromAddressBook(removedOwner))
|
const ownerChangedName = useSelector((state) => getNameFromAddressBook(state, removedOwner))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Block data-testid={TRANSACTIONS_DESC_REMOVE_OWNER_TEST_ID}>
|
<Block data-testid={TRANSACTIONS_DESC_REMOVE_OWNER_TEST_ID}>
|
||||||
|
@ -98,7 +98,7 @@ const RemovedOwner = ({ removedOwner }: { removedOwner: string }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const AddedOwner = ({ addedOwner }: { addedOwner: string }) => {
|
const AddedOwner = ({ addedOwner }: { addedOwner: string }) => {
|
||||||
const ownerChangedName = useSelector(getNameFromAddressBook(addedOwner))
|
const ownerChangedName = useSelector((state) => getNameFromAddressBook(state, addedOwner))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Block data-testid={TRANSACTIONS_DESC_ADD_OWNER_TEST_ID}>
|
<Block data-testid={TRANSACTIONS_DESC_ADD_OWNER_TEST_ID}>
|
||||||
|
@ -162,7 +162,7 @@ const SettingsDescription = ({ action, addedOwner, newThreshold, removedOwner }:
|
||||||
|
|
||||||
const CustomDescription = ({ amount = 0, classes, data, recipient }: CustomDescProps) => {
|
const CustomDescription = ({ amount = 0, classes, data, recipient }: CustomDescProps) => {
|
||||||
const [showTxData, setShowTxData] = useState(false)
|
const [showTxData, setShowTxData] = useState(false)
|
||||||
const recipientName = useSelector(getNameFromAddressBook(recipient))
|
const recipientName = useSelector((state) => getNameFromAddressBook(state, recipient))
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Block data-testid={TRANSACTIONS_DESC_CUSTOM_VALUE_TEST_ID}>
|
<Block data-testid={TRANSACTIONS_DESC_CUSTOM_VALUE_TEST_ID}>
|
||||||
|
|
Loading…
Reference in New Issue