2021-09-06 05:09:12 +00:00
|
|
|
import React from "react";
|
2021-10-20 22:23:10 +00:00
|
|
|
import { SyntaxHighlighter, docco } from "../highlight-init";
|
2021-11-25 18:50:59 +00:00
|
|
|
import { useContract } from "../sourcify/useSourcify";
|
2021-09-23 21:25:52 +00:00
|
|
|
import { useAppConfigContext } from "../useAppConfig";
|
2021-07-23 18:10:08 +00:00
|
|
|
|
|
|
|
type ContractProps = {
|
|
|
|
checksummedAddress: string;
|
2021-07-24 23:33:45 +00:00
|
|
|
networkId: number;
|
|
|
|
filename: string;
|
|
|
|
source: any;
|
2021-07-23 18:10:08 +00:00
|
|
|
};
|
|
|
|
|
2021-07-24 23:33:45 +00:00
|
|
|
const Contract: React.FC<ContractProps> = ({
|
|
|
|
checksummedAddress,
|
|
|
|
networkId,
|
|
|
|
filename,
|
|
|
|
source,
|
|
|
|
}) => {
|
2021-09-23 21:25:52 +00:00
|
|
|
const { sourcifySource } = useAppConfigContext();
|
2021-09-06 21:32:11 +00:00
|
|
|
const content = useContract(
|
|
|
|
checksummedAddress,
|
|
|
|
networkId,
|
|
|
|
filename,
|
|
|
|
source,
|
2021-09-10 21:27:42 +00:00
|
|
|
sourcifySource
|
2021-09-06 21:32:11 +00:00
|
|
|
);
|
2021-07-23 18:36:31 +00:00
|
|
|
|
2021-07-23 18:10:08 +00:00
|
|
|
return (
|
2021-07-25 07:10:42 +00:00
|
|
|
<SyntaxHighlighter
|
|
|
|
className="w-full h-full border font-code text-base"
|
|
|
|
language="solidity"
|
|
|
|
style={docco}
|
|
|
|
showLineNumbers
|
|
|
|
>
|
2021-07-25 07:03:27 +00:00
|
|
|
{content ?? ""}
|
|
|
|
</SyntaxHighlighter>
|
2021-07-23 18:10:08 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default React.memo(Contract);
|