Use ResolvedAddresses table instead of pre-resolved name parameter
This commit is contained in:
parent
9da41d0a2e
commit
a0675c6377
|
@ -165,7 +165,7 @@ const AddressTransactions: React.FC = () => {
|
||||||
}, [provider, checksummedAddress, params.direction, hash, controller]);
|
}, [provider, checksummedAddress, params.direction, hash, controller]);
|
||||||
|
|
||||||
const page = useMemo(() => controller?.getPage(), [controller]);
|
const page = useMemo(() => controller?.getPage(), [controller]);
|
||||||
const reverseCache = useENSCache(provider, page);
|
const resolvedAddresses = useENSCache(provider, page);
|
||||||
|
|
||||||
const blockTags: BlockTag[] = useMemo(() => {
|
const blockTags: BlockTag[] = useMemo(() => {
|
||||||
if (!page) {
|
if (!page) {
|
||||||
|
@ -283,7 +283,7 @@ const AddressTransactions: React.FC = () => {
|
||||||
<TransactionItem
|
<TransactionItem
|
||||||
key={tx.hash}
|
key={tx.hash}
|
||||||
tx={tx}
|
tx={tx}
|
||||||
ensCache={reverseCache}
|
resolvedAddresses={resolvedAddresses}
|
||||||
selectedAddress={checksummedAddress}
|
selectedAddress={checksummedAddress}
|
||||||
feeDisplay={feeDisplay}
|
feeDisplay={feeDisplay}
|
||||||
priceMap={priceMap}
|
priceMap={priceMap}
|
||||||
|
|
|
@ -29,7 +29,7 @@ const BlockTransactionResults: React.FC<BlockTransactionResultsProps> = ({
|
||||||
const selectionCtx = useSelection();
|
const selectionCtx = useSelection();
|
||||||
const [feeDisplay, feeDisplayToggler] = useFeeToggler();
|
const [feeDisplay, feeDisplayToggler] = useFeeToggler();
|
||||||
const { provider } = useContext(RuntimeContext);
|
const { provider } = useContext(RuntimeContext);
|
||||||
const reverseCache = useENSCache(provider, page);
|
const resolvedAddresses = useENSCache(provider, page);
|
||||||
const blockTags = useMemo(() => [blockTag], [blockTag]);
|
const blockTags = useMemo(() => [blockTag], [blockTag]);
|
||||||
const priceMap = useMultipleETHUSDOracle(provider, blockTags);
|
const priceMap = useMultipleETHUSDOracle(provider, blockTags);
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ const BlockTransactionResults: React.FC<BlockTransactionResultsProps> = ({
|
||||||
<TransactionItem
|
<TransactionItem
|
||||||
key={tx.hash}
|
key={tx.hash}
|
||||||
tx={tx}
|
tx={tx}
|
||||||
ensCache={reverseCache}
|
resolvedAddresses={resolvedAddresses}
|
||||||
feeDisplay={feeDisplay}
|
feeDisplay={feeDisplay}
|
||||||
priceMap={priceMap}
|
priceMap={priceMap}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -3,36 +3,39 @@ import Address from "./Address";
|
||||||
import AddressLink from "./AddressLink";
|
import AddressLink from "./AddressLink";
|
||||||
import ENSName from "./ENSName";
|
import ENSName from "./ENSName";
|
||||||
import ENSNameLink from "./ENSNameLink";
|
import ENSNameLink from "./ENSNameLink";
|
||||||
|
import { ResolvedAddresses } from "../api/address-resolver";
|
||||||
|
|
||||||
type AddressOrENSNameProps = {
|
type AddressOrENSNameProps = {
|
||||||
address: string;
|
address: string;
|
||||||
ensName?: string;
|
|
||||||
selectedAddress?: string;
|
selectedAddress?: string;
|
||||||
text?: string;
|
text?: string;
|
||||||
dontOverrideColors?: boolean;
|
dontOverrideColors?: boolean;
|
||||||
|
resolvedAddresses?: ResolvedAddresses | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const AddressOrENSName: React.FC<AddressOrENSNameProps> = ({
|
const AddressOrENSName: React.FC<AddressOrENSNameProps> = ({
|
||||||
address,
|
address,
|
||||||
ensName,
|
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
text,
|
text,
|
||||||
dontOverrideColors,
|
dontOverrideColors,
|
||||||
}) => (
|
resolvedAddresses,
|
||||||
|
}) => {
|
||||||
|
const name = resolvedAddresses?.[address];
|
||||||
|
return (
|
||||||
<>
|
<>
|
||||||
{address === selectedAddress ? (
|
{address === selectedAddress ? (
|
||||||
<>
|
<>
|
||||||
{ensName ? (
|
{name ? (
|
||||||
<ENSName name={ensName} address={address} />
|
<ENSName name={name} address={address} />
|
||||||
) : (
|
) : (
|
||||||
<Address address={address} />
|
<Address address={address} />
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{ensName ? (
|
{name ? (
|
||||||
<ENSNameLink
|
<ENSNameLink
|
||||||
name={ensName}
|
name={name}
|
||||||
address={address}
|
address={address}
|
||||||
dontOverrideColors={dontOverrideColors}
|
dontOverrideColors={dontOverrideColors}
|
||||||
/>
|
/>
|
||||||
|
@ -47,5 +50,6 @@ const AddressOrENSName: React.FC<AddressOrENSNameProps> = ({
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default React.memo(AddressOrENSName);
|
export default React.memo(AddressOrENSName);
|
||||||
|
|
|
@ -8,10 +8,10 @@ import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins";
|
||||||
import TokenLogo from "./TokenLogo";
|
import TokenLogo from "./TokenLogo";
|
||||||
import AddressOrENSName from "./AddressOrENSName";
|
import AddressOrENSName from "./AddressOrENSName";
|
||||||
import { AddressContext, TokenMeta, ZERO_ADDRESS } from "../types";
|
import { AddressContext, TokenMeta, ZERO_ADDRESS } from "../types";
|
||||||
|
import { ResolvedAddresses } from "../api/address-resolver";
|
||||||
|
|
||||||
type DecoratedAddressLinkProps = {
|
type DecoratedAddressLinkProps = {
|
||||||
address: string;
|
address: string;
|
||||||
ensName?: string;
|
|
||||||
selectedAddress?: string;
|
selectedAddress?: string;
|
||||||
text?: string;
|
text?: string;
|
||||||
addressCtx?: AddressContext;
|
addressCtx?: AddressContext;
|
||||||
|
@ -21,11 +21,11 @@ type DecoratedAddressLinkProps = {
|
||||||
txFrom?: boolean;
|
txFrom?: boolean;
|
||||||
txTo?: boolean;
|
txTo?: boolean;
|
||||||
tokenMeta?: TokenMeta;
|
tokenMeta?: TokenMeta;
|
||||||
|
resolvedAddresses?: ResolvedAddresses | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const DecoratedAddressLink: React.FC<DecoratedAddressLinkProps> = ({
|
const DecoratedAddressLink: React.FC<DecoratedAddressLinkProps> = ({
|
||||||
address,
|
address,
|
||||||
ensName,
|
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
text,
|
text,
|
||||||
addressCtx,
|
addressCtx,
|
||||||
|
@ -35,6 +35,7 @@ const DecoratedAddressLink: React.FC<DecoratedAddressLinkProps> = ({
|
||||||
txFrom,
|
txFrom,
|
||||||
txTo,
|
txTo,
|
||||||
tokenMeta,
|
tokenMeta,
|
||||||
|
resolvedAddresses,
|
||||||
}) => {
|
}) => {
|
||||||
const mint = addressCtx === AddressContext.FROM && address === ZERO_ADDRESS;
|
const mint = addressCtx === AddressContext.FROM && address === ZERO_ADDRESS;
|
||||||
const burn = addressCtx === AddressContext.TO && address === ZERO_ADDRESS;
|
const burn = addressCtx === AddressContext.TO && address === ZERO_ADDRESS;
|
||||||
|
@ -81,10 +82,10 @@ const DecoratedAddressLink: React.FC<DecoratedAddressLinkProps> = ({
|
||||||
)}
|
)}
|
||||||
<AddressOrENSName
|
<AddressOrENSName
|
||||||
address={address}
|
address={address}
|
||||||
ensName={ensName}
|
|
||||||
selectedAddress={selectedAddress}
|
selectedAddress={selectedAddress}
|
||||||
text={text}
|
text={text}
|
||||||
dontOverrideColors={mint || burn}
|
dontOverrideColors={mint || burn}
|
||||||
|
resolvedAddresses={resolvedAddresses}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { ResolvedAddresses } from "../api/address-resolver";
|
||||||
|
|
||||||
type TransactionItemProps = {
|
type TransactionItemProps = {
|
||||||
tx: ProcessedTransaction;
|
tx: ProcessedTransaction;
|
||||||
ensCache?: ResolvedAddresses;
|
resolvedAddresses?: ResolvedAddresses;
|
||||||
selectedAddress?: string;
|
selectedAddress?: string;
|
||||||
feeDisplay: FeeDisplay;
|
feeDisplay: FeeDisplay;
|
||||||
priceMap: Record<BlockTag, BigNumber>;
|
priceMap: Record<BlockTag, BigNumber>;
|
||||||
|
@ -30,7 +30,7 @@ type TransactionItemProps = {
|
||||||
|
|
||||||
const TransactionItem: React.FC<TransactionItemProps> = ({
|
const TransactionItem: React.FC<TransactionItemProps> = ({
|
||||||
tx,
|
tx,
|
||||||
ensCache,
|
resolvedAddresses,
|
||||||
selectedAddress,
|
selectedAddress,
|
||||||
feeDisplay,
|
feeDisplay,
|
||||||
priceMap,
|
priceMap,
|
||||||
|
@ -51,12 +51,6 @@ const TransactionItem: React.FC<TransactionItemProps> = ({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ensFrom = ensCache && tx.from && ensCache[tx.from];
|
|
||||||
const ensTo = ensCache && tx.to && ensCache[tx.to];
|
|
||||||
const ensCreated =
|
|
||||||
ensCache &&
|
|
||||||
tx.createdContractAddress &&
|
|
||||||
ensCache[tx.createdContractAddress];
|
|
||||||
const flash = tx.gasPrice.isZero() && tx.internalMinerInteraction;
|
const flash = tx.gasPrice.isZero() && tx.internalMinerInteraction;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -88,9 +82,9 @@ const TransactionItem: React.FC<TransactionItemProps> = ({
|
||||||
<AddressHighlighter address={tx.from}>
|
<AddressHighlighter address={tx.from}>
|
||||||
<DecoratedAddressLink
|
<DecoratedAddressLink
|
||||||
address={tx.from}
|
address={tx.from}
|
||||||
ensName={ensFrom}
|
|
||||||
selectedAddress={selectedAddress}
|
selectedAddress={selectedAddress}
|
||||||
miner={tx.miner === tx.from}
|
miner={tx.miner === tx.from}
|
||||||
|
resolvedAddresses={resolvedAddresses}
|
||||||
/>
|
/>
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
)}
|
)}
|
||||||
|
@ -108,18 +102,18 @@ const TransactionItem: React.FC<TransactionItemProps> = ({
|
||||||
<AddressHighlighter address={tx.to}>
|
<AddressHighlighter address={tx.to}>
|
||||||
<DecoratedAddressLink
|
<DecoratedAddressLink
|
||||||
address={tx.to}
|
address={tx.to}
|
||||||
ensName={ensTo}
|
|
||||||
selectedAddress={selectedAddress}
|
selectedAddress={selectedAddress}
|
||||||
miner={tx.miner === tx.to}
|
miner={tx.miner === tx.to}
|
||||||
|
resolvedAddresses={resolvedAddresses}
|
||||||
/>
|
/>
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
) : (
|
) : (
|
||||||
<AddressHighlighter address={tx.createdContractAddress!}>
|
<AddressHighlighter address={tx.createdContractAddress!}>
|
||||||
<DecoratedAddressLink
|
<DecoratedAddressLink
|
||||||
address={tx.createdContractAddress!}
|
address={tx.createdContractAddress!}
|
||||||
ensName={ensCreated}
|
|
||||||
selectedAddress={selectedAddress}
|
selectedAddress={selectedAddress}
|
||||||
creation
|
creation
|
||||||
|
resolvedAddresses={resolvedAddresses}
|
||||||
/>
|
/>
|
||||||
</AddressHighlighter>
|
</AddressHighlighter>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in New Issue