diff --git a/README.md b/README.md index 10dc2edb..75f565c7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Make sure the repository submodule h5ai-nginx is present: - `git submodule update --init --recursive` Apply the Hedera patch to the `h5ai-nginx` submodule (execute this only once). -- `./scripts/hedera-apply-patch.sh`. +- `./scripts/hedera-apply-patch.sh` ## Local build for development @@ -29,7 +29,8 @@ From the root of the project workspace: 1. Run `npm ci`. This will create populate and link `node_modules`. 2. `cp environments/.env.dev.hedera environments/.env` - * Adjust `environments/.env` to use port 5555 instead of 5000 if running on a Mac + * Adjust SERVER_PORT variable in `environments/.env` to use 5555 instead of 5000 if running on a Mac + * Adjust the value of the port in the SERVER_URL field in ui/public/config.json accordingly 3. Make sure the following variables defined in `.env` point to directories which exist on the file system: `REPOSITORY_PATH, SOLC_REPO, SOLJSON_REPO` (paths relative to the environments/ directory) 4. Run `npx lerna bootstrap && npx lerna run build`. This will build the server and ui as well as needed libraries. 5. Run `docker-compose -f environments/build-repository.yaml build`. This will build the docker image for the repository service. @@ -59,7 +60,7 @@ or build the images locally. 1. `cp environments/.env.docker.hedera environments/.env` 2. Adjust the configuration in `environments/.env` as follows: * Replace all occurrences of `localhost` by the fully qualified hostname if not running locally - * Use port 5555 instead of 5000 if running on a Mac + * Adjust SERVER_EXTERNAL_PORT variable in `environments/.env` to use 5555 instead of 5000 if running on a Mac 3. `cp environments/example-docker-config.json environments/docker-config.json` * Adjust the URLs in `docker-config.json` as needed 4. You may need to authenticate to the GitHub container registry at `ghcr.io` using a personal access token [as described here](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry). diff --git a/environments/.env.dev.hedera b/environments/.env.dev.hedera index f0447bdf..20782a2e 100644 --- a/environments/.env.dev.hedera +++ b/environments/.env.dev.hedera @@ -1,6 +1,8 @@ ### ### USE THIS IN DEVELOPMENT TO RUN FROM LOCAL BUILD OF UI AND SERVER ### NOTE THE REPOSITORY ALWAYS RUNS AS A DOCKER CONTAINER +### NOTE: +### - to run on a Mac, use 5555 instead of 5000 for the server port ### # Server config @@ -15,20 +17,20 @@ SERVER_PORT=5000 ## used by Server to configure allowed origins for CORS UI_DOMAIN_NAME=localhost -# Repository web server config -REPOSITORY_SERVER_PORT=10000 - -# UI config -## The URL used by the UI service to contact the server -SERVER_URL=http://localhost:5000 -## The URL used by the UI service to coontact the repository +## Note: +## - the 'ui' and 'repository' services no longer use the following environment variables +## but instead read their runtime config from their config.json file +## (resp. ui/public/config.json and h5ai-nginx/select-contract-form/public/config.json) +## - the 'server' uses the REPOSITORY_SERVER_URL env variable to return links to the various +## contract files. +#SERVER_URL=http://localhost:5000 REPOSITORY_SERVER_URL=http://localhost:10000 # Docker config (only used for repository service in dev mode) ## Where to mount the downloaded compilers directory on the host machine SOLC_REPO_HOST=../../data/solc-bin/linux-amd64 SOLJSON_REPO_HOST=../../data/solc-bin/soljson -## Ports to access containers from the host +## Port to access repository container from the host REPOSITORY_SERVER_EXTERNAL_PORT=10000 # Other config diff --git a/environments/.env.docker.hedera b/environments/.env.docker.hedera index a2f0496a..19df73f0 100644 --- a/environments/.env.docker.hedera +++ b/environments/.env.docker.hedera @@ -14,18 +14,21 @@ REPOSITORY_PATH=../../data/repository SOLC_REPO=/home/data/solc-bin/linux-amd64 ## Path where Solidity JS (solc-js) compilers will be saved (inside container) SOLJSON_REPO=/home/data/solc-bin/soljson +## Server port inside the docker container 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 -# Repository web server config -REPOSITORY_SERVER_PORT=10000 - -# UI config -## The URL used by the UI service to contact the server -SERVER_URL=http://localhost:5000 -## The URL used by the UI service to coontact the repository +## Note: +## - the 'ui' and 'repository' services no longer use the following environment variables +## but instead read their runtime config from their config.json file. This can be a mount point +## provided to the docker container (see environments/docker-compose-hedera.yaml for example) +## and defaults to the file statically included at build time (resp. ui/public/config.json and +## h5ai-nginx/select-contract-form/public/config.json) +## - the 'server' uses the REPOSITORY_SERVER_URL env variable to return links to the various +## contract files. +#SERVER_URL=http://localhost:5000 REPOSITORY_SERVER_URL=http://localhost:10000 # Docker config diff --git a/environments/.env.poc.hedera b/environments/.env.poc.hedera index d496db0e..617baac9 100644 --- a/environments/.env.poc.hedera +++ b/environments/.env.poc.hedera @@ -11,18 +11,21 @@ REPOSITORY_PATH=../../data/repository SOLC_REPO=/home/data/solc-bin/linux-amd64 ## Path where Solidity JS (solc-js) compilers will be saved (inside container) SOLJSON_REPO=/home/data/solc-bin/soljson +## Server port inside the docker container 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=verify.simonvienot.fr -# Repository web server config -REPOSITORY_SERVER_PORT=10000 - -# UI config -## The URL used by the UI service to contact the server -SERVER_URL=https://verify.simonvienot.fr/server -## The URL used by the UI service to coontact the repository +## Note: +## - the 'ui' and 'repository' services no longer use the following environment variables +## but instead read their runtime config from their config.json file. This can be a mount point +## provided to the docker container (see environments/docker-compose-hedera.yaml for example) +## and defaults to the file statically included at build time (resp. ui/public/config.json and +## h5ai-nginx/select-contract-form/public/config.json) +## - the 'server' uses the REPOSITORY_SERVER_URL env variable to return links to the various +## contract files. +#SERVER_URL=https://verify.simonvienot.fr/server REPOSITORY_SERVER_URL=https://repo.verify.simonvienot.fr # Docker config diff --git a/environments/hedera-poc-docker-config.json b/environments/hedera-poc-docker-config.json new file mode 100644 index 00000000..285993a3 --- /dev/null +++ b/environments/hedera-poc-docker-config.json @@ -0,0 +1,5 @@ + { + "SERVER_URL": "https://verify.simonvienot.fr/server", + "REPOSITORY_SERVER_URL": "https://repo.verify.simonvienot.fr", + "HASHSCAN_URL": "https://hashscan-latest.hedera-devops.com" + } \ No newline at end of file diff --git a/hedera-patch/h5ai-nginx.patch b/hedera-patch/h5ai-nginx.patch index 631a3942..852f51f2 100644 --- a/hedera-patch/h5ai-nginx.patch +++ b/hedera-patch/h5ai-nginx.patch @@ -1,4 +1,4 @@ -Subject: [PATCH] h5ai-nginx patch +Subject: [PATCH] h5ai-nginx gets value of SERVER_URL from config.json file. --- Index: select-contract-form/src/App.js IDEA additional info: @@ -7,7 +7,7 @@ Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP =================================================================== diff --git a/select-contract-form/src/App.js b/select-contract-form/src/App.js --- a/select-contract-form/src/App.js (revision 453a6681ef93a7a43ee339b5301743e27d7a3b62) -+++ b/select-contract-form/src/App.js (date 1693490213100) ++++ b/select-contract-form/src/App.js (date 1695221204280) @@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from "react"; import { Alert, Button, Card, Form, Spinner } from "react-bootstrap"; @@ -16,12 +16,13 @@ diff --git a/select-contract-form/src/App.js b/select-contract-form/src/App.js function App() { const [selectedMatch, setSelectedMatch] = useState("full_match"); -@@ -20,10 +21,14 @@ +@@ -20,13 +21,26 @@ ]; useEffect(() => { + const getConfig = async () => { + const configUrl = `${window.location.origin}/select-contract/config.json` ++ console.log(`Trying to read config from: ${configUrl}`) + const response = await axios.get(configUrl) + return JSON.parse(JSON.stringify(response.data)) + } @@ -29,11 +30,25 @@ diff --git a/select-contract-form/src/App.js b/select-contract-form/src/App.js - const serverUrl = window.configs?.SERVER_URL?.length > 0 - ? window.configs.SERVER_URL - : "https://sourcify.dev/server" +- const chainsArray = await ( +- await fetch(`${serverUrl}/chains`) +- ).json(); + const config = await (await getConfig()) + const serverUrl = config.SERVER_URL - const chainsArray = await ( - await fetch(`${serverUrl}/chains`) - ).json(); ++ let chainsArray ++ if (serverUrl !== undefined && serverUrl.toString().length > 0) { ++ console.log(`Using SERVER_URL: ${serverUrl}`) ++ console.log(`Trying to retrieve supported chains from: ${serverUrl}/chains`) ++ chainsArray = await ( ++ await fetch(`${serverUrl}/chains`) ++ ).json(); ++ } else { ++ console.warn(`SERVER_URL is not defined in config.json`) ++ chainsArray = [] ++ } + return chainsArray; + }; + getSourcifyChains() Index: select-contract-form/package.json IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP @@ -41,7 +56,7 @@ Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP =================================================================== diff --git a/select-contract-form/package.json b/select-contract-form/package.json --- a/select-contract-form/package.json (revision 453a6681ef93a7a43ee339b5301743e27d7a3b62) -+++ b/select-contract-form/package.json (date 1693489764150) ++++ b/select-contract-form/package.json (date 1695221204280) @@ -6,6 +6,7 @@ "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", @@ -57,10 +72,10 @@ Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP =================================================================== diff --git a/select-contract-form/public/config.json b/select-contract-form/public/config.json new file mode 100644 ---- /dev/null (date 1693489764154) -+++ b/select-contract-form/public/config.json (date 1693489764154) +--- /dev/null (date 1695221304211) ++++ b/select-contract-form/public/config.json (date 1695221304211) @@ -0,0 +1,3 @@ + { -+ "SERVER_URL": "https://sourcify.dev/server" ++ "SERVER_URL": "http://localhost:5555" + } \ No newline at end of file diff --git a/ui/src/assets/brand-product-logo-black.png b/ui/src/assets/brand-product-logo-black.png new file mode 100644 index 00000000..b83f8be6 Binary files /dev/null and b/ui/src/assets/brand-product-logo-black.png differ diff --git a/ui/src/components/Header/index.tsx b/ui/src/components/Header/index.tsx index 229acd2b..5c390e34 100644 --- a/ui/src/components/Header/index.tsx +++ b/ui/src/components/Header/index.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import { HiMenu } from "react-icons/hi"; import { Link } from "react-router-dom"; import ReactTooltip from "react-tooltip"; -import logoText from "../../assets/logo-rounded.svg"; +import logoText from "../../assets/brand-product-logo-black.png"; import { DOCS_URL } from "../../constants"; import {configuration} from "../../utils/Configuration"; @@ -19,14 +19,9 @@ const Header = () => { return (
-
- - Sourcify logo - - Hedera - - -
+ + HashScan logo + diff --git a/ui/src/constants.ts b/ui/src/constants.ts index 4935292d..f905c819 100644 --- a/ui/src/constants.ts +++ b/ui/src/constants.ts @@ -5,3 +5,4 @@ export const GITTER_URL = `https://gitter.im/ethereum/source-verify`; export const GITHUB_URL = `https://github.com/ethereum/sourcify`; export const TWITTER_URL = `https://twitter.com/sourcifyeth`; export const SOLIDITY_ETHEREUM_URL = `https://solidity.ethereum.org/2020/06/25/sourcify-faq/`; +export const TERMS_OF_SERVICE_URL = "https://swirldslabs.com/terms-of-service" \ No newline at end of file diff --git a/ui/src/pages/Lookup/index.tsx b/ui/src/pages/Lookup/index.tsx index 01f5c243..8df8c75b 100644 --- a/ui/src/pages/Lookup/index.tsx +++ b/ui/src/pages/Lookup/index.tsx @@ -8,6 +8,7 @@ import Field from "./Field"; import Result from "./Result"; import { useParams, useNavigate } from "react-router-dom"; import { isAddress, getAddress } from "@ethersproject/address"; +import {TERMS_OF_SERVICE_URL} from "../../constants"; const Lookup = () => { const navigate = useNavigate(); @@ -84,6 +85,9 @@ const Lookup = () => { )} +
+ See Terms of Service +
); diff --git a/ui/src/pages/Verifier/index.tsx b/ui/src/pages/Verifier/index.tsx index 87256cf9..c07dc8a9 100644 --- a/ui/src/pages/Verifier/index.tsx +++ b/ui/src/pages/Verifier/index.tsx @@ -2,9 +2,7 @@ import bytes from "bytes"; import { useCallback, useContext, useEffect, useState } from "react"; import Header from "../../components/Header"; import Toast from "../../components/Toast"; -import { - DOCS_URL, -} from "../../constants"; +import { DOCS_URL, TERMS_OF_SERVICE_URL } from "../../constants"; import { Context } from "../../Context"; import { Create2VerificationInput, @@ -245,9 +243,9 @@ const Verifier: React.FC = () => { verifyCreate2Compile={verifyCreate2Compile} /> -
- Once a contract is verified it can't be removed from the Sourcify - repository. +
+

Note: Once a contract is verified it can't be removed from the repository.

+ See Terms of Service
);