Fix missing Sourcify decoration on token transfers

This commit is contained in:
Willian Mitsuda 2021-11-11 15:51:03 -03:00
parent 8e29326ff5
commit 36b5437643
2 changed files with 18 additions and 1 deletions

View File

@ -4,13 +4,20 @@ import { faCaretRight } from "@fortawesome/free-solid-svg-icons/faCaretRight";
import TransactionAddress from "./components/TransactionAddress"; import TransactionAddress from "./components/TransactionAddress";
import ValueHighlighter from "./components/ValueHighlighter"; import ValueHighlighter from "./components/ValueHighlighter";
import FormattedBalance from "./components/FormattedBalance"; import FormattedBalance from "./components/FormattedBalance";
import { AddressContext, TokenMeta, TokenTransfer } from "./types"; import {
AddressContext,
ChecksummedAddress,
TokenMeta,
TokenTransfer,
} from "./types";
import { ResolvedAddresses } from "./api/address-resolver"; import { ResolvedAddresses } from "./api/address-resolver";
import { Metadata } from "./useSourcify";
type TokenTransferItemProps = { type TokenTransferItemProps = {
t: TokenTransfer; t: TokenTransfer;
tokenMeta?: TokenMeta | undefined; tokenMeta?: TokenMeta | undefined;
resolvedAddresses: ResolvedAddresses | undefined; resolvedAddresses: ResolvedAddresses | undefined;
metadatas: Record<ChecksummedAddress, Metadata | null | undefined>;
}; };
// TODO: handle partial // TODO: handle partial
@ -18,6 +25,7 @@ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
t, t,
tokenMeta, tokenMeta,
resolvedAddresses, resolvedAddresses,
metadatas,
}) => ( }) => (
<div className="flex items-baseline space-x-2 px-2 py-1 truncate hover:bg-gray-100"> <div className="flex items-baseline space-x-2 px-2 py-1 truncate hover:bg-gray-100">
<span className="text-gray-500"> <span className="text-gray-500">
@ -30,6 +38,7 @@ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
address={t.from} address={t.from}
addressCtx={AddressContext.FROM} addressCtx={AddressContext.FROM}
resolvedAddresses={resolvedAddresses} resolvedAddresses={resolvedAddresses}
metadata={metadatas[t.from]}
/> />
</div> </div>
<div className="flex space-x-1"> <div className="flex space-x-1">
@ -38,6 +47,7 @@ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
address={t.to} address={t.to}
addressCtx={AddressContext.TO} addressCtx={AddressContext.TO}
resolvedAddresses={resolvedAddresses} resolvedAddresses={resolvedAddresses}
metadata={metadatas[t.to]}
/> />
</div> </div>
<div className="col-span-3 flex space-x-1"> <div className="col-span-3 flex space-x-1">
@ -53,6 +63,7 @@ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
<TransactionAddress <TransactionAddress
address={t.token} address={t.token}
resolvedAddresses={resolvedAddresses} resolvedAddresses={resolvedAddresses}
metadata={metadatas[t.token]}
/> />
</div> </div>
</div> </div>

View File

@ -95,6 +95,11 @@ const Details: React.FC<DetailsProps> = ({
if (txData.confirmedData?.createdContractAddress) { if (txData.confirmedData?.createdContractAddress) {
_addresses.push(txData.confirmedData.createdContractAddress); _addresses.push(txData.confirmedData.createdContractAddress);
} }
for (const t of txData.tokenTransfers) {
_addresses.push(t.from);
_addresses.push(t.to);
_addresses.push(t.token);
}
return _addresses; return _addresses;
}, [txData]); }, [txData]);
const { sourcifySource } = useAppConfigContext(); const { sourcifySource } = useAppConfigContext();
@ -227,6 +232,7 @@ const Details: React.FC<DetailsProps> = ({
t={t} t={t}
tokenMeta={txData.tokenMetas[t.token]} tokenMeta={txData.tokenMetas[t.token]}
resolvedAddresses={resolvedAddresses} resolvedAddresses={resolvedAddresses}
metadatas={metadatas}
/> />
))} ))}
</div> </div>