Move metadata reading one level up

This commit is contained in:
Willian Mitsuda 2021-09-05 21:13:01 -03:00
parent 605302ee64
commit 71e359eb92
2 changed files with 15 additions and 7 deletions

View File

@ -33,6 +33,7 @@ import { useENSCache } from "./useReverseCache";
import { useFeeToggler } from "./search/useFeeToggler"; import { useFeeToggler } from "./search/useFeeToggler";
import { SelectionContext, useSelection } from "./useSelection"; import { SelectionContext, useSelection } from "./useSelection";
import { useMultipleETHUSDOracle } from "./usePriceOracle"; import { useMultipleETHUSDOracle } from "./usePriceOracle";
import { useSourcify } from "./useSourcify";
type BlockParams = { type BlockParams = {
addressOrName: string; addressOrName: string;
@ -180,6 +181,10 @@ const AddressTransactions: React.FC = () => {
const [feeDisplay, feeDisplayToggler] = useFeeToggler(); const [feeDisplay, feeDisplayToggler] = useFeeToggler();
const selectionCtx = useSelection(); const selectionCtx = useSelection();
const rawMetadata = useSourcify(
checksummedAddress,
provider?.network.chainId
);
return ( return (
<StandardFrame> <StandardFrame>
@ -287,7 +292,10 @@ const AddressTransactions: React.FC = () => {
</ContentFrame> </ContentFrame>
</Route> </Route>
<Route path="/address/:addressOrName/contract" exact> <Route path="/address/:addressOrName/contract" exact>
<Contracts checksummedAddress={checksummedAddress} /> <Contracts
checksummedAddress={checksummedAddress}
rawMetadata={rawMetadata}
/>
</Route> </Route>
</Switch> </Switch>
</Tab.Panels> </Tab.Panels>

View File

@ -4,18 +4,18 @@ import ContentFrame from "../ContentFrame";
import InfoRow from "../components/InfoRow"; import InfoRow from "../components/InfoRow";
import Contract from "./Contract"; import Contract from "./Contract";
import { RuntimeContext } from "../useRuntime"; import { RuntimeContext } from "../useRuntime";
import { useSourcify } from "../useSourcify"; import { Metadata } from "../useSourcify";
type ContractsProps = { type ContractsProps = {
checksummedAddress: string; checksummedAddress: string;
rawMetadata: Metadata | null | undefined;
}; };
const Contracts: React.FC<ContractsProps> = ({ checksummedAddress }) => { const Contracts: React.FC<ContractsProps> = ({
const { provider } = useContext(RuntimeContext);
const rawMetadata = useSourcify(
checksummedAddress, checksummedAddress,
provider?.network.chainId rawMetadata,
); }) => {
const { provider } = useContext(RuntimeContext);
const [selected, setSelected] = useState<string>(); const [selected, setSelected] = useState<string>();
useEffect(() => { useEffect(() => {