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

Add terms of service link and misc changes #33

Merged
merged 9 commits into from
Sep 20, 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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down Expand Up @@ -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).
Expand Down
18 changes: 10 additions & 8 deletions environments/.env.dev.hedera
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
17 changes: 10 additions & 7 deletions environments/.env.docker.hedera
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions environments/.env.poc.hedera
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions environments/hedera-poc-docker-config.json
Original file line number Diff line number Diff line change
@@ -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"
}
35 changes: 25 additions & 10 deletions hedera-patch/h5ai-nginx.patch
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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";
Expand All @@ -16,32 +16,47 @@ 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))
+ }
const getSourcifyChains = async () => {
- 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
<+>UTF-8
===================================================================
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",
Expand All @@ -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
Binary file added ui/src/assets/brand-product-logo-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 4 additions & 9 deletions ui/src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -19,14 +19,9 @@ const Header = () => {
return (
<header className="flex justify-between py-4 md:py-6 w-auto flex-wrap md:flex-nowrap">
<ReactTooltip effect="solid" />
<div className="flex items-center">
<Link to="/" className="flex items-center">
<img src={logoText} alt="Sourcify logo" className="max-h-10" />
<span className="ml-3 text-gray-700 font-vt323 text-2xl">
Hedera
</span>
</Link>
</div>
<Link to="/" className="flex items-center">
<img src={logoText} alt="HashScan logo" style={{minWidth:220,maxWidth:220}}/>
</Link>
<button className="block md:hidden" onClick={toggleNav}>
<HiMenu className="text-gray-700 text-3xl hover:text-ceruleanBlue-500" />
</button>
Expand Down
1 change: 1 addition & 0 deletions ui/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 4 additions & 0 deletions ui/src/pages/Lookup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -84,6 +85,9 @@ const Lookup = () => {
<Field loading={loading} handleRequest={handleRequest} />
)}
</div>
<div className="text-center text-xs italic mx-2 mt-1 text-gray-400">
<a href={TERMS_OF_SERVICE_URL}>See Terms of Service</a>
</div>
</div>
</div>
);
Expand Down
10 changes: 4 additions & 6 deletions ui/src/pages/Verifier/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -245,9 +243,9 @@ const Verifier: React.FC = () => {
verifyCreate2Compile={verifyCreate2Compile}
/>
</div>
<div className="text-xs italic mx-2 mt-1 text-gray-400">
Once a contract is verified it can't be removed from the Sourcify
repository.
<div className="text-center text-xs italic mx-2 mt-1 text-gray-400">
<p>Note: Once a contract is verified it can't be removed from the repository.</p>
<a href={TERMS_OF_SERVICE_URL}>See Terms of Service</a>
</div>
</div>
);
Expand Down
Loading