From 7b5ecb91baadd7e35667dc8d65b0dc46e2616f67 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 6 Sep 2021 04:14:49 -0300 Subject: [PATCH] Open in remix feature #54 --- src/address/Contracts.tsx | 14 ++++++++++++++ src/url.ts | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/src/address/Contracts.tsx b/src/address/Contracts.tsx index 5237320..9e8eaef 100644 --- a/src/address/Contracts.tsx +++ b/src/address/Contracts.tsx @@ -6,6 +6,8 @@ import InfoRow from "../components/InfoRow"; import Contract from "./Contract"; import { RuntimeContext } from "../useRuntime"; import { Metadata } from "../useSourcify"; +import ExternalLink from "../components/ExternalLink"; +import { openInRemixURL } from "../url"; type ContractsProps = { checksummedAddress: string; @@ -57,6 +59,18 @@ const Contracts: React.FC = ({ )} {rawMetadata !== undefined && rawMetadata !== null && (
+ {provider && ( +
+ + Open in Remix + +
+ )} {Object.entries(rawMetadata.sources).map(([k]) => ( diff --git a/src/url.ts b/src/url.ts index 1c01cc9..8aaa6f0 100644 --- a/src/url.ts +++ b/src/url.ts @@ -17,6 +17,7 @@ export const blockTxsURL = (blockNum: BlockTag) => `/block/${blockNum}/txs`; const sourcifyRootHash = "k51qzi5uqu5dll0ocge71eudqnrgnogmbr37gsgl12uubsinphjoknl6bbi41p"; const ipfsGatewayPrefix = `https://ipfs.io/ipns/${sourcifyRootHash}`; +// const ipfsGatewayPrefix = `https://repo.sourcify.dev`; export const sourcifyMetadata = ( checksummedAddress: string, @@ -30,3 +31,6 @@ export const sourcifySourceFile = ( filepath: string ) => `${ipfsGatewayPrefix}/contracts/full_match/${networkId}/${checksummedAddress}/sources/${filepath}`; + +export const openInRemixURL = (checksummedAddress: string, networkId: number) => + `https://remix.ethereum.org/#call=source-verification//fetchAndSave//${checksummedAddress}//${networkId}`;