Skip to content

Commit

Permalink
Inclusion of import methods and open-in-remix action is now configure…
Browse files Browse the repository at this point in the history
…d in config.json.

Signed-off-by: Simon Viénot <simon.vienot@icloud.com>
  • Loading branch information
svienot committed Oct 11, 2023
1 parent 3b251b2 commit 9ae4716
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 75 deletions.
7 changes: 6 additions & 1 deletion ui/public/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"SERVER_URL": "http://localhost:5002",
"REPOSITORY_SERVER_URL": "http://localhost:10000",
"HASHSCAN_URL": "https://hashscan-latest.hedera-devops.com"
"HASHSCAN_URL": "https://hashscan-latest.hedera-devops.com",
"REMOTE_IMPORT": false,
"GITHUB_IMPORT": false,
"CONTRACT_IMPORT": false,
"JSON_IMPORT": false,
"OPEN_IN_REMIX": false
}
40 changes: 24 additions & 16 deletions ui/src/pages/Lookup/Result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,18 @@ const NetworkRow = ({ address, chainId, status }: NetworkRowProp) => {
View in Sourcify Repository
</a>
</td>
{/*<td className="py-4 pr-4 text-right">*/}
{/* <a*/}
{/* className="underline"*/}
{/* href={generateUrl(URL_TYPE.REMIX, chainId, address, status)}*/}
{/* >*/}
{/* View in Remix*/}
{/* </a>*/}
{/*</td>*/}
{configuration.openInRemix ? (
<td className="py-4 pr-4 text-right">
<a
className="underline"
href={generateUrl(URL_TYPE.REMIX, chainId, address, status)}
>
View in Remix
</a>
</td>
) : (
<td/>
)}
</tr>
) : (
<div className="border-b hover:bg-gray-100 flex flex-col">
Expand All @@ -181,14 +185,18 @@ const NetworkRow = ({ address, chainId, status }: NetworkRowProp) => {
View in Sourcify Repository
</a>
</div>
{/*<div className="pb-4">*/}
{/* <a*/}
{/* className="underline"*/}
{/* href={generateUrl(URL_TYPE.REMIX, chainId, address, status)}*/}
{/* >*/}
{/* View in Remix*/}
{/* </a>*/}
{/*</div>*/}
{configuration.openInRemix ? (
<div className="pb-4">
<a
className="underline"
href={generateUrl(URL_TYPE.REMIX, chainId, address, status)}
>
View in Remix
</a>
</div>
) : (
<div/>
)}
</div>
)}
</>
Expand Down
133 changes: 75 additions & 58 deletions ui/src/pages/Verifier/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import RemoteInput from "./RemoteInput";
import GitHubInput from "./GitHubInput";
import ContractInput from "./ContractInput";
import SolcJsonInput from "./SolcJsonInput";
import {configuration} from "../../utils/Configuration";

enum ImportMethods {
UPLOAD,
Expand Down Expand Up @@ -75,64 +76,80 @@ const FileUpload: React.FC<FileUploadProps> = ({
to verify.
</p>
</div>
{/*<div className="flex flex-row flex-wrap gap-3 mt-4 justify-center md:justify-start">*/}
{/* <Button*/}
{/* type={*/}
{/* importMethodSelected === ImportMethods.REMOTE*/}
{/* ? "primary"*/}
{/* : "secondary"*/}
{/* }*/}
{/* onClick={() => selectImportMethod(ImportMethods.REMOTE)}*/}
{/* className="text-sm"*/}
{/* >*/}
{/* <>*/}
{/* <AiOutlinePlus className="inline align-middle mr-1" />*/}
{/* Import from remote*/}
{/* </>*/}
{/* </Button>*/}
{/* <Button*/}
{/* type={*/}
{/* importMethodSelected === ImportMethods.GITHUB*/}
{/* ? "primary"*/}
{/* : "secondary"*/}
{/* }*/}
{/* onClick={() => selectImportMethod(ImportMethods.GITHUB)}*/}
{/* className="text-sm"*/}
{/* >*/}
{/* <>*/}
{/* <AiOutlineGithub className="inline align-middle mr-1" />*/}
{/* Import from GitHub*/}
{/* </>*/}
{/* </Button>*/}
{/* <Button*/}
{/* type={*/}
{/* importMethodSelected === ImportMethods.CONTRACT*/}
{/* ? "primary"*/}
{/* : "secondary"*/}
{/* }*/}
{/* onClick={() => selectImportMethod(ImportMethods.CONTRACT)}*/}
{/* className="text-sm"*/}
{/* >*/}
{/* <>*/}
{/* <AiOutlineFileSearch className="inline align-middle mr-1" />*/}
{/* Import from Contract*/}
{/* </>*/}
{/* </Button>*/}
{/* <Button*/}
{/* type={*/}
{/* importMethodSelected === ImportMethods.SOLIDITY_JSON*/}
{/* ? "primary"*/}
{/* : "secondary"*/}
{/* }*/}
{/* onClick={() => selectImportMethod(ImportMethods.SOLIDITY_JSON)}*/}
{/* className="text-sm"*/}
{/* >*/}
{/* <>*/}
{/* <SiSolidity className="inline align-middle mr-1" />*/}
{/* Import from Solidity JSON*/}
{/* </>*/}
{/* </Button>*/}
{/*</div>*/}
<div className="flex flex-row flex-wrap gap-3 mt-4 justify-center md:justify-start">
{configuration.remoteImport ? (
<Button
type={
importMethodSelected === ImportMethods.REMOTE
? "primary"
: "secondary"
}
onClick={() => selectImportMethod(ImportMethods.REMOTE)}
className="text-sm"
>
<>
<AiOutlinePlus className="inline align-middle mr-1" />
Import from remote
</>
</Button>
) : (
<div/>
)}
{configuration.githubImport ? (
<Button
type={
importMethodSelected === ImportMethods.GITHUB
? "primary"
: "secondary"
}
onClick={() => selectImportMethod(ImportMethods.GITHUB)}
className="text-sm"
>
<>
<AiOutlineGithub className="inline align-middle mr-1"/>
Import from GitHub
</>
</Button>
) : (
<div/>
)}
{configuration.contractImport ? (
<Button
type={
importMethodSelected === ImportMethods.CONTRACT
? "primary"
: "secondary"
}
onClick={() => selectImportMethod(ImportMethods.CONTRACT)}
className="text-sm"
>
<>
<AiOutlineFileSearch className="inline align-middle mr-1"/>
Import from Contract
</>
</Button>
) : (
<div/>
)}
{configuration.jsonImport ? (
<Button
type={
importMethodSelected === ImportMethods.SOLIDITY_JSON
? "primary"
: "secondary"
}
onClick={() => selectImportMethod(ImportMethods.SOLIDITY_JSON)}
className="text-sm"
>
<>
<SiSolidity className="inline align-middle mr-1"/>
Import from Solidity JSON
</>
</Button>
) : (
<div/>
)}
</div>
<div className="flex flex-grow flex-col pb-8">
{importMethodSelected === ImportMethods.REMOTE && (
<div className="mt-4">
Expand Down
25 changes: 25 additions & 0 deletions ui/src/utils/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export class Configuration {
private _repositoryServerUrl: string | undefined;
private _repositoryServerUrlFullMatch: string | undefined;
private _hashScanUrl: string | undefined;
private _remoteImport: boolean | undefined;
private _githubImport: boolean | undefined;
private _contractImport: boolean | undefined;
private _jsonImport: boolean | undefined;
private _openInRemix: boolean | undefined;
private _repositoryServerUrlPartialMatch: string | undefined;
private _ipfsIpnsGatewayUrl: string | undefined;
private _sessionDataUrl: string | undefined;
Expand Down Expand Up @@ -66,6 +71,21 @@ export class Configuration {
get serverUrl(): string {
return this._serverUrl ?? ""
}
get remoteImport(): boolean {
return this._remoteImport ?? false
}
get githubImport(): boolean {
return this._githubImport ?? false
}
get contractImport(): boolean {
return this._contractImport ?? false
}
get jsonImport(): boolean {
return this._jsonImport ?? false
}
get openInRemix(): boolean {
return this._openInRemix ?? false
}

public readConfig = async (): Promise<void> => {

Expand All @@ -82,6 +102,11 @@ export class Configuration {
this._serverUrl = configData.SERVER_URL
this._repositoryServerUrl = configData.REPOSITORY_SERVER_URL
this._hashScanUrl = configData.HASHSCAN_URL
this._remoteImport = configData.REMOTE_IMPORT
this._githubImport = configData.GITHUB_IMPORT
this._contractImport = configData.CONTRACT_IMPORT
this._jsonImport = configData.JSON_IMPORT
this._openInRemix = configData.OPEN_IN_REMIX

this._repositoryServerUrlFullMatch = `${this._repositoryServerUrl}/contracts/full_match`
this._repositoryServerUrlPartialMatch = `${this._repositoryServerUrl}/contracts/partial_match`
Expand Down

0 comments on commit 9ae4716

Please sign in to comment.