From 92940ebf7f94bd6ed3850f7a297ece155518fd5e Mon Sep 17 00:00:00 2001 From: Aahna Ashina <95955389+aahna-ashina@users.noreply.github.com> Date: Sun, 3 Mar 2024 16:11:48 +0800 Subject: [PATCH 01/10] refactor: improve env variables (#139) close #139 --- .gitignore | 3 ++- packages/web-app/{.env.sample => .env.mainnet} | 3 +-- packages/web-app/.env.sepolia | 4 ++++ packages/web-app/README.md | 16 ++++++++++------ packages/web-app/lib/connectors.tsx | 3 --- packages/web-app/lib/constants/sepolia.tsx | 2 +- 6 files changed, 18 insertions(+), 13 deletions(-) rename packages/web-app/{.env.sample => .env.mainnet} (73%) create mode 100644 packages/web-app/.env.sepolia diff --git a/.gitignore b/.gitignore index edf5db12..c58d02e9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,8 @@ node_modules/ lcov.info coverage -.env** +.env +.env.local # dependencies /node_modules diff --git a/packages/web-app/.env.sample b/packages/web-app/.env.mainnet similarity index 73% rename from packages/web-app/.env.sample rename to packages/web-app/.env.mainnet index 83859178..0a298062 100644 --- a/packages/web-app/.env.sample +++ b/packages/web-app/.env.mainnet @@ -1,5 +1,4 @@ NEXT_PUBLIC_CHAIN="mainnet" NEXT_PUBLIC_NFTSTORAGE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweDI2NmFCZGE3QWNmODc0NTlBRTJEOTg5RjM4OWU1N0I0MmJCNkNkNzYiLCJpc3MiOiJuZnQtc3RvcmFnZSIsImlhdCI6MTcwOTIwOTQwNDM3MiwibmFtZSI6IkRhbyJ9.YsuBC1iXGJ7Ip_VkFjsZSzHQSOkKRMyaCw4eq_j5f-4 NEXT_PUBLIC_GRAPH_API_URL=https://api.thegraph.com/subgraphs/name/nation3/nation3-agreements-mainnet -NEXT_PUBLIC_GRAPH_API_URL_SEPOLIA=https://api.thegraph.com/subgraphs/name/nation3/nation3-agreements-sepolia -NEXT_PUBLIC_ALCHEMY_API_KEY="" +NEXT_PUBLIC_ALCHEMY_API_KEY="6E06msPMRDva4egUiK0j4sNpEbFkXE6w" diff --git a/packages/web-app/.env.sepolia b/packages/web-app/.env.sepolia new file mode 100644 index 00000000..a56fee25 --- /dev/null +++ b/packages/web-app/.env.sepolia @@ -0,0 +1,4 @@ +NEXT_PUBLIC_CHAIN="sepolia" +NEXT_PUBLIC_NFTSTORAGE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweDI2NmFCZGE3QWNmODc0NTlBRTJEOTg5RjM4OWU1N0I0MmJCNkNkNzYiLCJpc3MiOiJuZnQtc3RvcmFnZSIsImlhdCI6MTcwOTIwOTQwNDM3MiwibmFtZSI6IkRhbyJ9.YsuBC1iXGJ7Ip_VkFjsZSzHQSOkKRMyaCw4eq_j5f-4 +NEXT_PUBLIC_GRAPH_API_URL=https://api.thegraph.com/subgraphs/name/nation3/nation3-agreements-sepolia +NEXT_PUBLIC_ALCHEMY_API_KEY="6E06msPMRDva4egUiK0j4sNpEbFkXE6w" diff --git a/packages/web-app/README.md b/packages/web-app/README.md index 403899b4..1960f07b 100644 --- a/packages/web-app/README.md +++ b/packages/web-app/README.md @@ -4,17 +4,23 @@ Human-centric UI to create and manage agreements in the Nation3 Legal system. ## Development -##### 1. Build dependencies. +### Set Environment Variables + +``` +cp .env.mainnet .env +``` + +### Build dependencies. This app depends on the `@nation3/ui-components` package found [here](../ui-components/). (packages/ui-components.) -If you want to see changes to the components reflected in real-time on the web app you should run the builder in the `ui-components` directory using: +If you want to see changes to the components reflected in real-time on the web app you should run the builder in the `ui-components` directory using: ``` yarn build:dependencies ``` -##### 2. Run a local development environment with yarn: +### Run a local development environment with yarn: ``` yarn dev @@ -22,11 +28,9 @@ yarn dev --- -##### Running the app: +### Run the app: ``` yarn start ``` - -If you want to be able to create new agreements, you will need to upload metadata to IPFS, so you will need to add your own `IPFS_API_TOKEN` to your environment. Check [how to generate web3.storage API token](https://web3.storage/docs/how-tos/generate-api-token/). diff --git a/packages/web-app/lib/connectors.tsx b/packages/web-app/lib/connectors.tsx index d34e1c1c..31bbd625 100644 --- a/packages/web-app/lib/connectors.tsx +++ b/packages/web-app/lib/connectors.tsx @@ -9,9 +9,6 @@ type FallbackProviderConfig = Omit const customAlchemyProvider = ({ priority, stallTimeout, weight }: FallbackProviderConfig) => { return (chain: Chain) => { let apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; - if (chain?.id == 11155111) { - apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY_SEPOLIA; - } if (!apiKey || !chain.rpcUrls.alchemy) return null; return { diff --git a/packages/web-app/lib/constants/sepolia.tsx b/packages/web-app/lib/constants/sepolia.tsx index da9c6a97..64aff9a4 100644 --- a/packages/web-app/lib/constants/sepolia.tsx +++ b/packages/web-app/lib/constants/sepolia.tsx @@ -6,5 +6,5 @@ export const frameworkAddress = "0xD96aA6e2568f4e9632D2A5234Bb8410ca7609a27"; export const arbitratorAddress = "0xBe67cEdCD1FE38aac8a5781A51250FDeFB344E6C"; export const cohortAddress = "0x2F957C3D949b4e3967E1ddF646614b77BF46057e"; //GnosisSafeProxy export const safeTxServiceUrl = "https://safe-transaction-sepolia.safe.global"; -export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL_SEPOLIA; +export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL; export const appealCost = BigNumber.from("1000000000000000000"); From 1d22e28d882734f8956a4b06bb3f39cb9793a893 Mon Sep 17 00:00:00 2001 From: Aahna Ashina <95955389+aahna-ashina@users.noreply.github.com> Date: Sun, 3 Mar 2024 16:25:03 +0800 Subject: [PATCH 02/10] lint fix --- packages/web-app/lib/connectors.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web-app/lib/connectors.tsx b/packages/web-app/lib/connectors.tsx index 31bbd625..fce7880a 100644 --- a/packages/web-app/lib/connectors.tsx +++ b/packages/web-app/lib/connectors.tsx @@ -8,7 +8,7 @@ type FallbackProviderConfig = Omit const customAlchemyProvider = ({ priority, stallTimeout, weight }: FallbackProviderConfig) => { return (chain: Chain) => { - let apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; + const apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; if (!apiKey || !chain.rpcUrls.alchemy) return null; return { From 163365331c8fa6dac8299660ae84858e0d351fa7 Mon Sep 17 00:00:00 2001 From: Aahna Ashina <95955389+aahna-ashina@users.noreply.github.com> Date: Sun, 3 Mar 2024 16:42:18 +0800 Subject: [PATCH 03/10] node 18.x --- .github/workflows/web-app-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-app-ci.yml b/.github/workflows/web-app-ci.yml index ee5134e1..04c88245 100644 --- a/.github/workflows/web-app-ci.yml +++ b/.github/workflows/web-app-ci.yml @@ -31,7 +31,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node-version: [16.x] + node-version: [18.x] runs-on: ${{ matrix.os }} defaults: run: From a4012943f62738d919d0587bb52f9b0ae85998ca Mon Sep 17 00:00:00 2001 From: Aahna Ashina <95955389+aahna-ashina@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:02:54 +0800 Subject: [PATCH 04/10] node 20.x --- .github/workflows/web-app-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-app-ci.yml b/.github/workflows/web-app-ci.yml index 04c88245..22ae6d95 100644 --- a/.github/workflows/web-app-ci.yml +++ b/.github/workflows/web-app-ci.yml @@ -31,7 +31,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node-version: [18.x] + node-version: [18.x, 20.x] runs-on: ${{ matrix.os }} defaults: run: From 4acda14d81e09cd37bd3633cf93ffaa250b003a5 Mon Sep 17 00:00:00 2001 From: Aahna Ashina <95955389+aahna-ashina@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:31:57 +0800 Subject: [PATCH 05/10] node 18.x --- .github/workflows/ui-components-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ui-components-ci.yml b/.github/workflows/ui-components-ci.yml index 462a4300..186f23c4 100644 --- a/.github/workflows/ui-components-ci.yml +++ b/.github/workflows/ui-components-ci.yml @@ -31,7 +31,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node-version: [16.x] + node-version: [18.x] runs-on: ${{ matrix.os }} defaults: run: From 85d0044ab822f6b36ec7eb6b3cbfd931fb873dbc Mon Sep 17 00:00:00 2001 From: Aahna Ashina <95955389+aahna-ashina@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:39:35 +0800 Subject: [PATCH 06/10] node 20.x --- .github/workflows/ui-components-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ui-components-ci.yml b/.github/workflows/ui-components-ci.yml index 186f23c4..bbdf1bc4 100644 --- a/.github/workflows/ui-components-ci.yml +++ b/.github/workflows/ui-components-ci.yml @@ -31,7 +31,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node-version: [18.x] + node-version: [18.x, 20.x] runs-on: ${{ matrix.os }} defaults: run: From b28fbda0c0bad93d2076825961fae2f5da9a0b0a Mon Sep 17 00:00:00 2001 From: Aahna Ashina <95955389+aahna-ashina@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:52:37 +0800 Subject: [PATCH 07/10] node 20.x --- .github/workflows/ui-components-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ui-components-ci.yml b/.github/workflows/ui-components-ci.yml index bbdf1bc4..451009a0 100644 --- a/.github/workflows/ui-components-ci.yml +++ b/.github/workflows/ui-components-ci.yml @@ -51,7 +51,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - node-version: [16.x] + node-version: [18.x, 20.x] runs-on: ${{ matrix.os }} defaults: run: From 8069573603fde384bf1a9e90cecbb9e2cb8fdd6f Mon Sep 17 00:00:00 2001 From: Aahna Ashina <95955389+aahna-ashina@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:56:04 +0800 Subject: [PATCH 08/10] windows build --- .github/workflows/ui-components-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ui-components-ci.yml b/.github/workflows/ui-components-ci.yml index 451009a0..6501e775 100644 --- a/.github/workflows/ui-components-ci.yml +++ b/.github/workflows/ui-components-ci.yml @@ -30,7 +30,7 @@ jobs: build: strategy: matrix: - os: [ubuntu-latest] + os: [ubuntu-latest, windows-latest] node-version: [18.x, 20.x] runs-on: ${{ matrix.os }} defaults: From 01e154d1ffe9e30be4d5e2b85107f2b2b5cbf1b1 Mon Sep 17 00:00:00 2001 From: Aahna Ashina <95955389+aahna-ashina@users.noreply.github.com> Date: Sun, 3 Mar 2024 18:04:35 +0800 Subject: [PATCH 09/10] windows test --- .github/workflows/ui-components-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ui-components-ci.yml b/.github/workflows/ui-components-ci.yml index 6501e775..1bbb3aec 100644 --- a/.github/workflows/ui-components-ci.yml +++ b/.github/workflows/ui-components-ci.yml @@ -50,7 +50,7 @@ jobs: test: strategy: matrix: - os: [ubuntu-latest] + os: [ubuntu-latest, windows-latest] node-version: [18.x, 20.x] runs-on: ${{ matrix.os }} defaults: From 44e545a11b6eff4d44f36590a995ef4516767117 Mon Sep 17 00:00:00 2001 From: Aahna Ashina <95955389+aahna-ashina@users.noreply.github.com> Date: Sun, 3 Mar 2024 18:11:26 +0800 Subject: [PATCH 10/10] windows build --- .github/workflows/web-app-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web-app-ci.yml b/.github/workflows/web-app-ci.yml index 22ae6d95..2533bd84 100644 --- a/.github/workflows/web-app-ci.yml +++ b/.github/workflows/web-app-ci.yml @@ -30,7 +30,7 @@ jobs: build: strategy: matrix: - os: [ubuntu-latest] + os: [ubuntu-latest, windows-latest] node-version: [18.x, 20.x] runs-on: ${{ matrix.os }} defaults: