mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-03 06:34:27 +01:00
88ae10418b
The `getProviderConfig` selector is now used anywhere the `provider` state was previously referenced directly. This was done to simplify renaming this state from `provider` to `providerConfig` in a later PR. Note that there are many opportunities left to use more-specific selectors (e.g. `getChainId()` over `getProviderConfig().chainId`), but that was intentionally omitted from this PR to reduce the size. I started going down this path and it quickly exploded in scope. Relates to #18902
23 lines
715 B
JavaScript
23 lines
715 B
JavaScript
import { useSelector } from 'react-redux';
|
|
import { getProviderConfig } from '../ducks/metamask/metamask';
|
|
import { hexToDecimal } from '../../shared/modules/conversion.utils';
|
|
|
|
import { isEqualCaseInsensitive } from '../../shared/modules/string-utils';
|
|
|
|
export const useTransactionInfo = (txData = {}) => {
|
|
const { allNftContracts, selectedAddress } = useSelector(
|
|
(state) => state.metamask,
|
|
);
|
|
const { chainId } = useSelector(getProviderConfig);
|
|
|
|
const isNftTransfer = Boolean(
|
|
allNftContracts?.[selectedAddress]?.[hexToDecimal(chainId)]?.find(
|
|
(contract) => {
|
|
return isEqualCaseInsensitive(contract.address, txData.txParams.to);
|
|
},
|
|
),
|
|
);
|
|
|
|
return { isNftTransfer };
|
|
};
|