Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature flag for create2 verification support #50

Merged
merged 6 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 27 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,39 +114,42 @@ Example contents for `config.json`:
"GITHUB_IMPORT": false,
"CONTRACT_IMPORT": false,
"JSON_IMPORT": false,
"OPEN_IN_REMIX": false
"OPEN_IN_REMIX": false,
"CREATE2_VERIFICATION": false
}
```
The following properties can be provided in config.json

| Name | Description |
|-------------------------|------------------------------------------------------------------------------|
| `SERVER_URL` | URL of the server (from outside the cluster). |
| `REPOSITORY_SERVER_URL` | HTTP port exposed by container |
| `EXPLORER_URL` | URL of the mirror-node explorer |
| `REMOTE_IMPORT` | Flag to activate mode "Import from remote" |
| `GITHUB_IMPORT` | Flag to activate mode "Import from GitHub" |
| `CONTRACT_IMPORT` | Flag to activate mode "Import from contract's metadata" |
| `JSON_IMPORT` | Flag to activate mode "Import contracts from Solidity's Standard JSON Input" |
| `OPEN_IN_REMIX` | Flag to activate link "Open in Remix" |
| Name | Description |
|----------------------------|------------------------------------------------------------------------------|
| `SERVER_URL` | URL of the server (from outside the cluster). |
| `REPOSITORY_SERVER_URL` | HTTP port exposed by container |
| `EXPLORER_URL` | URL of the mirror-node explorer |
| `REMOTE_IMPORT` | Flag to activate mode "Import from remote" |
| `GITHUB_IMPORT` | Flag to activate mode "Import from GitHub" |
| `CONTRACT_IMPORT` | Flag to activate mode "Import from contract's metadata" |
| `JSON_IMPORT` | Flag to activate mode "Import contracts from Solidity's Standard JSON Input" |
| `OPEN_IN_REMIX` | Flag to activate link "Open in Remix" |
| `CREATE2_VERIFICATION` | Flag to activate create2 verification |

### _server_ module

The following environment variables are needed by the _server_ at runtime:

| Name | Example value | Description |
|-------------------------|-----------------------------------------------------------|-----------------------------------------------------------------------------------------|
| `REPOSITORY_PATH` | ../../data/repository | DO NOT CHANGE - Path of the contract repository, both inside container and on the host. |
| `SOLC_REPO` | /home/data/solc-bin/linux-amd64 | Path where Solidity compiler binaries will be saved (inside container) |
| `SOLJSON_REPO` | /home/data/solc-bin/soljson | Path where Solidity JS compilers will be saved (inside container) |
| `SOLC_REPO_HOST` | ../../data/solc-bin/linux-amd64 | Path for the Solidity compiler binaries downloaded (on host machine) |
| `SOLJSON_REPO_HOST` | ../../data/solc-bin/soljson | Path for the Solidity JS compilers downloaded (on host machine) |
| `SERVER_PORT` | 80 | HTTP port used inside container |
| `SERVER_EXTERNAL_PORT` | 5002 | HTTP port exposed by container |
| `UI_DOMAIN_NAME` | sourcify-integration.hedera-devops.com | Fully qualified domain name of the host running the ui |
| `REPOSITORY_SERVER_URL` | https://repository.sourcify-integration.hedera-devops.com | URL of repository server (from outside the cluster) |
| `TESTING` | false | DO NOT CHANGE |
| `TAG` | latest | DO NOT CHANGE |
| Name | Example value | Description |
|-------------------------------|-----------------------------------------------------------|-----------------------------------------------------------------------------------------|
| `REPOSITORY_PATH` | ../../data/repository | DO NOT CHANGE - Path of the contract repository, both inside container and on the host. |
| `SOLC_REPO` | /home/data/solc-bin/linux-amd64 | Path where Solidity compiler binaries will be saved (inside container) |
| `SOLJSON_REPO` | /home/data/solc-bin/soljson | Path where Solidity JS compilers will be saved (inside container) |
| `SOLC_REPO_HOST` | ../../data/solc-bin/linux-amd64 | Path for the Solidity compiler binaries downloaded (on host machine) |
| `SOLJSON_REPO_HOST` | ../../data/solc-bin/soljson | Path for the Solidity JS compilers downloaded (on host machine) |
| `SERVER_PORT` | 80 | HTTP port used inside container |
| `SERVER_EXTERNAL_PORT` | 5002 | HTTP port exposed by container |
| `UI_DOMAIN_NAME` | sourcify-integration.hedera-devops.com | Fully qualified domain name of the host running the ui |
| `SERVER_CREATE2_VERIFICATION` | false | Flag to activate server API endpoints related to create2 {true, false} |
| `REPOSITORY_SERVER_URL` | https://repository.sourcify-integration.hedera-devops.com | URL of repository server (from outside the cluster) |
| `TESTING` | false | DO NOT CHANGE |
| `TAG` | latest | DO NOT CHANGE |

### _repository_ module

Expand Down
2 changes: 2 additions & 0 deletions environments/.env.dev.hedera
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ SERVER_PORT=5002
## The fully qualified domain name of the host running the ui
## used by Server to configure allowed origins for CORS
UI_DOMAIN_NAME=localhost
## Feature flag for Create2 verification endpoints
SERVER_CREATE2_VERIFICATION=false

## Note:
## - the 'ui' and 'repository' services no longer use the following environment variables
Expand Down
2 changes: 2 additions & 0 deletions environments/.env.docker.hedera
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ SERVER_PORT=80
## The fully qualified domain name of the host running the ui
## used by Server to configure allowed origins for CORS
UI_DOMAIN_NAME=localhost
## Feature flag for Create2 verification endpoints
SERVER_CREATE2_VERIFICATION=false

## Note:
## - the 'ui' and 'repository' services no longer use the following environment variables
Expand Down
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export default {
corsAllowedOrigins: [
new RegExp(`^https?:\/\/(?:.+\\.)?${process.env.UI_DOMAIN_NAME}(?::\d+)?`), // domain defined by UI_DOMAIN_NAME and subdomains
],
features: {
create2: process.env.SERVER_CREATE2_VERIFICATION || "false"
}
};

type EtherscanAPIs = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import create2StatelessRoutes from "./stateless/create2.stateless.routes";
import create2SessionRoutes from "./session/create2.session.routes";

import { Router } from "express";
import config from "../../../../config";

const router = Router();

router.use("/", create2StatelessRoutes);
router.use("/", create2SessionRoutes);
if (config.features.create2 === "true") {
router.use("/", create2StatelessRoutes);
router.use("/", create2SessionRoutes);
}

export default router;
3 changes: 2 additions & 1 deletion ui/public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"GITHUB_IMPORT": false,
"CONTRACT_IMPORT": false,
"JSON_IMPORT": false,
"OPEN_IN_REMIX": false
"OPEN_IN_REMIX": false,
"CREATE2_VERIFICATION": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const Create2Form = ({
verifyCreate2CheckedContract,
setIsLoading,
}: ChainAddressFormProps) => {
const [clientToken, setClientToken] = useState<string>();
const clientToken = "";
const [deployerAddress, setDeployerAddress] = useState<string>();
const [salt, setSalt] = useState<string>();
const [abiEncodedConstructorArguments, setAbiEncodedConstructorArguments] =
Expand Down Expand Up @@ -147,25 +147,6 @@ const Create2Form = ({
</div>
{checkedContract?.creationBytecode ? (
<form className="mt-4" onSubmit={handleSubmit}>
<div>
<div className="flex justify-between">
<label className="block" htmlFor="clientToken">
Client token
<p className="mb-1 text-xs">
This functionality is protected by a client token in order to
prevent spamming. If you are interested please send an email
to <a href="mailto:[email protected]">[email protected]</a>
</p>
</label>
</div>
<Input
id="clientToken"
value={clientToken}
onChange={(e) => setClientToken(e.target.value)}
placeholder="CLIENT_TOKEN"
className="mb-2"
/>
</div>
<div>
<div className="flex justify-between">
<label className="block" htmlFor="address">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Create2Form from "./Create2Form";
import Invalid from "./Invalid";
import Label from "./Label";
import Missing from "./Missing";
import {configuration} from "../../../../utils/Configuration";

type CheckedContractProps = {
checkedContract: SendableContract;
Expand Down Expand Up @@ -112,7 +113,7 @@ const CheckedContract: React.FC<CheckedContractProps> = ({

{/* Collapsed section */}
<div className={`${collapsed ? "hidden" : ""} break-words px-4 p-4`}>
<div className="flex flex-row flex-wrap gap-3 mt-4 justify-center md:justify-start mb-6">
{configuration.create2Verification && <div className="flex flex-row flex-wrap gap-3 mt-4 justify-center md:justify-start mb-6">
svienot marked this conversation as resolved.
Show resolved Hide resolved
<div className="">
<Button
type={
Expand All @@ -139,7 +140,7 @@ const CheckedContract: React.FC<CheckedContractProps> = ({
Verify create2 contract
</Button>
</div>
</div>
</div>}
{verifyMethodSelected === VerifyMethods.DEPLOYED &&
["perfect", "partial", "error"].includes(customStatus) && (
<ChainAddressForm
Expand Down
14 changes: 0 additions & 14 deletions ui/src/pages/Verifier/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,6 @@ const Verifier: React.FC = () => {
Verify smart contracts by recompiling with the Solidity source code
and metadata.
</p>
{
// Show legacy.sourcify.dev URL on production
process.env.REACT_APP_TAG === "stable" && (
<p className="text-xs mt-2 text-gray-500">
Old verifier UI avaiable at{" "}
<a
href="https://legacy.sourcify.dev"
className="hover:underline text-ceruleanBlue-300 hover:text-ceruleanBlue-400"
>
legacy.sourcify.dev
</a>
</p>
)
}
</div>
<div className="flex flex-col md:flex-row flex-grow mt-6">
<FileUpload
Expand Down
5 changes: 5 additions & 0 deletions ui/src/utils/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class Configuration {
private _contractImport: boolean | undefined;
private _jsonImport: boolean | undefined;
private _openInRemix: boolean | undefined;
private _create2Verification: boolean | undefined;
private _repositoryServerUrlPartialMatch: string | undefined;
private _ipfsIpnsGatewayUrl: string | undefined;
private _sessionDataUrl: string | undefined;
Expand Down Expand Up @@ -94,6 +95,9 @@ export class Configuration {
get openInRemix(): boolean {
return this._openInRemix ?? false
}
get create2Verification(): boolean {
return this._create2Verification ?? false
}

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

Expand All @@ -117,6 +121,7 @@ export class Configuration {
this._contractImport = configData.CONTRACT_IMPORT
this._jsonImport = configData.JSON_IMPORT
this._openInRemix = configData.OPEN_IN_REMIX
this._create2Verification = configData.CREATE2_VERIFICATION

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