Skip to content

Commit 66b8c6e

Browse files
authored
Merge pull request #77 from kleros/feat/escrow-v2-migration-to-vite-and-wagmiv2
Feat/escrow v2 migration to vite and wagmiv2
2 parents ab1f6f4 + bc1b359 commit 66b8c6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3407
-2809
lines changed

contracts/deploy/00-escrow.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const disputeTemplate = `{
2323
"uri": "{{{extraDescriptionUri}}}"
2424
},
2525
"frontendUrl": "https://escrow-v2.kleros.builders/#/transactions/{{externalDisputeID}}",
26-
"arbitrableChainID": "421614",
27-
"arbitrableAddress": "0xFromContext",
2826
"arbitratorChainID": "421614",
2927
"arbitratorAddress": "0xA54e7A16d7460e38a8F324eF46782FB520d58CE8",
3028
"metadata": {

contracts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@types/chai": "^4.2.0",
6464
"@types/mocha": "^10.0.0",
6565
"@types/node": "^16.0.0",
66-
"@wagmi/cli": "^1.5.2",
66+
"@wagmi/cli": "^2.0.3",
6767
"abitype": "^0.10.3",
6868
"chai": "^4.2.0",
6969
"dotenv": "^16.3.1",

web/.parcelrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

web/netlify.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@ YARN_ENABLE_GLOBAL_CACHE = "true"
99

1010
[functions]
1111
directory = "web/netlify/functions/"
12-
13-
[dev]
14-
framework = "parcel"

web/netlify/functions/authUser.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import middy from "@middy/core";
22
import jsonBodyParser from "@middy/http-json-body-parser";
33
import { createClient } from "@supabase/supabase-js";
4+
import { ethers } from "ethers";
45
import * as jwt from "jose";
56
import { SiweMessage } from "siwe";
67

7-
import { DEFAULT_CHAIN } from "consts/chains";
8-
import { ETH_SIGNATURE_REGEX } from "consts/index";
8+
import { ETH_SIGNATURE_REGEX, DEFAULT_CHAIN, isProductionDeployment } from "consts/processEnvConsts";
99

1010
import { netlifyUri, netlifyDeployUri, netlifyDeployPrimeUri } from "src/generatedNetlifyInfo.json";
1111
import { Database } from "src/types/supabase-notification";
@@ -79,9 +79,14 @@ const authUser = async (event) => {
7979
}
8080

8181
try {
82-
await siweMessage.verify({ signature, nonce: nonceData.nonce, time: new Date().toISOString() });
82+
// If the main Alchemy API key is permissioned, it won't work in a Netlify Function so we use a dedicated API key
83+
const alchemyApiKey = process.env.ALCHEMY_FUNCTIONS_API_KEY ?? process.env.ALCHEMY_API_KEY;
84+
const alchemyChain = isProductionDeployment() ? "arb-mainnet" : "arb-sepolia";
85+
const alchemyRpcURL = `https://${alchemyChain}.g.alchemy.com/v2/${alchemyApiKey}`;
86+
const provider = new ethers.providers.JsonRpcProvider(alchemyRpcURL);
87+
await siweMessage.verify({ signature, nonce: nonceData.nonce, time: new Date().toISOString() }, { provider });
8388
} catch (err) {
84-
throw new Error("Invalid signer");
89+
throw new Error("Invalid signer: " + JSON.stringify(err));
8590
}
8691

8792
const { error } = await supabase.from("user-nonce").delete().match({ address: lowerCaseAddress });

web/netlify/functions/getNonce.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import middy from "@middy/core";
22
import { createClient } from "@supabase/supabase-js";
33
import { generateNonce } from "siwe";
44

5-
import { ETH_ADDRESS_REGEX } from "src/consts";
5+
import { ETH_ADDRESS_REGEX } from "src/consts/processEnvConsts";
66

7-
import { Database } from "../../src/types/supabase-notification";
7+
import { Database } from "src/types/supabase-notification";
88

99
import config from "../config";
1010

web/netlify/functions/update-settings.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import middy from "@middy/core";
22
import jsonBodyParser from "@middy/http-json-body-parser";
33
import { createClient } from "@supabase/supabase-js";
44

5-
import { EMAIL_REGEX, TELEGRAM_REGEX, ETH_ADDRESS_REGEX } from "../../src/consts/index";
6-
import { Database } from "../../src/types/supabase-notification";
5+
import { EMAIL_REGEX, TELEGRAM_REGEX, ETH_ADDRESS_REGEX } from "consts/processEnvConsts";
6+
7+
import { Database } from "src/types/supabase-notification";
8+
79
import { authMiddleware } from "../middleware/authMiddleware";
810

911
import config from "../config";

web/package.json

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"repository": "",
77
"author": "",
88
"license": "MIT",
9+
"type": "module",
910
"alias": {
1011
"src": "./src",
1112
"utils": "./src/utils",
@@ -25,16 +26,15 @@
2526
"node": "20.11.0"
2627
},
2728
"scripts": {
28-
"clear": "rm -fr ../.parcel-cache dist/bundle.js",
2929
"start": "yarn start-devnet",
30-
"start-local": "scripts/runEnv.sh local 'yarn generate && parcel'",
31-
"start-devnet": "scripts/runEnv.sh devnet 'yarn generate && parcel'",
32-
"start-testnet": "scripts/runEnv.sh testnet 'yarn generate && parcel'",
30+
"start-local": "scripts/runEnv.sh local 'yarn generate && vite'",
31+
"start-devnet": "scripts/runEnv.sh devnet 'yarn generate && vite'",
32+
"start-testnet": "scripts/runEnv.sh testnet 'yarn generate && vite'",
3333
"build": "yarn build-devnet",
34-
"build-local": "scripts/runEnv.sh local 'yarn generate && parcel build'",
35-
"build-devnet": "scripts/runEnv.sh devnet 'yarn generate && parcel build'",
36-
"build-testnet": "scripts/runEnv.sh testnet 'yarn generate && parcel build'",
37-
"build-netlify": "scripts/runEnv.sh devnet 'scripts/generateBuildInfo.sh && yarn generate && parcel build'",
34+
"build-local": "scripts/runEnv.sh local 'yarn generate && vite build'",
35+
"build-devnet": "scripts/runEnv.sh devnet 'yarn generate && vite build'",
36+
"build-testnet": "scripts/runEnv.sh testnet 'yarn generate && vite build'",
37+
"build-netlify": "scripts/runEnv.sh devnet 'scripts/generateBuildInfo.sh && yarn generate && vite build'",
3838
"check-style": "eslint 'src/**/*.{js,jsx,ts,tsx}'",
3939
"check-types": "tsc --noEmit",
4040
"generate": "yarn generate:gql && yarn generate:hooks",
@@ -47,8 +47,6 @@
4747
"@graphql-codegen/cli": "^4.0.1",
4848
"@graphql-codegen/client-preset": "^4.1.0",
4949
"@netlify/functions": "^1.6.0",
50-
"@parcel/transformer-svg-react": "2.11.0",
51-
"@parcel/watcher": "~2.2.0",
5250
"@types/amqplib": "^0.10.4",
5351
"@types/busboy": "^1.5.3",
5452
"@types/react": "18.2.0",
@@ -58,16 +56,17 @@
5856
"@typescript-eslint/eslint-plugin": "^5.62.0",
5957
"@typescript-eslint/parser": "^5.62.0",
6058
"@typescript-eslint/utils": "^5.62.0",
61-
"@wagmi/cli": "^1.5.2",
59+
"@wagmi/cli": "^2.1.15",
6260
"eslint": "^8.56.0",
6361
"eslint-config-prettier": "^8.10.0",
64-
"eslint-import-resolver-parcel": "^1.10.6",
6562
"eslint-plugin-react": "^7.33.2",
6663
"eslint-plugin-react-hooks": "^4.6.0",
6764
"lru-cache": "^7.18.3",
68-
"parcel": "2.11.0",
6965
"supabase": "^1.133.3",
70-
"typescript": "^5.3.3"
66+
"typescript": "^5.3.3",
67+
"vite-plugin-node-polyfills": "^0.21.0",
68+
"vite-plugin-svgr": "^4.2.0",
69+
"vite-tsconfig-paths": "^4.3.2"
7170
},
7271
"dependencies": {
7372
"@cyntler/react-doc-viewer": "^1.16.3",
@@ -78,9 +77,8 @@
7877
"@sentry/react": "^7.93.0",
7978
"@sentry/tracing": "^7.93.0",
8079
"@supabase/supabase-js": "^2.39.3",
81-
"@tanstack/react-query": "^4.28.0",
82-
"@web3modal/ethereum": "^2.7.1",
83-
"@web3modal/react": "^2.2.2",
80+
"@tanstack/react-query": "^5.40.1",
81+
"@web3modal/wagmi": "^5.1.4",
8482
"@yornaath/batshit": "^0.9.0",
8583
"alchemy-sdk": "^3.3.1",
8684
"amqplib": "^0.10.4",
@@ -109,7 +107,8 @@
109107
"react-use": "^17.4.3",
110108
"siwe": "^2.3.2",
111109
"styled-components": "^5.3.11",
112-
"viem": "^1.21.4",
113-
"wagmi": "^1.4.13"
110+
"viem": "^2.1.0",
111+
"vite": "^5.2.10",
112+
"wagmi": "^2.12.8"
114113
}
115114
}

web/scripts/gitInfo.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* eslint-disable max-len */
2-
const fs = require("fs");
3-
const path = require("path");
4-
const { execSync } = require("child_process");
5-
const packageJson = require("../package.json");
2+
import fs from "fs";
3+
import path from "path";
4+
import { execSync } from "child_process";
5+
6+
import packageJson from "../package.json" with { type: "json" };
67

78
const execSyncWrapper = (command) => {
89
let stdout = null;

web/src/app.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Web3Provider from "context/Web3Provider";
77
import IsListProvider from "context/IsListProvider";
88
import QueryClientProvider from "context/QueryClientProvider";
99
import StyledComponentsProvider from "context/StyledComponentsProvider";
10-
import RefetchOnBlock from "context/RefetchOnBlock";
1110
import GraphqlBatcherProvider from "context/GraphqlBatcher";
1211
import Layout from "layout/index";
1312
import NewTransaction from "./pages/NewTransaction";
@@ -18,10 +17,9 @@ import AttachmentDisplay from "./pages/AttachmentDisplay";
1817
const App: React.FC = () => {
1918
return (
2019
<StyledComponentsProvider>
21-
<QueryClientProvider>
22-
<RefetchOnBlock />
23-
<GraphqlBatcherProvider>
24-
<Web3Provider>
20+
<Web3Provider>
21+
<QueryClientProvider>
22+
<GraphqlBatcherProvider>
2523
<IsListProvider>
2624
<NewTransactionProvider>
2725
<SentryRoutes>
@@ -35,9 +33,9 @@ const App: React.FC = () => {
3533
</SentryRoutes>
3634
</NewTransactionProvider>
3735
</IsListProvider>
38-
</Web3Provider>
39-
</GraphqlBatcherProvider>
40-
</QueryClientProvider>
36+
</GraphqlBatcherProvider>
37+
</QueryClientProvider>
38+
</Web3Provider>
4139
</StyledComponentsProvider>
4240
);
4341
};

web/src/assets/svgs/icons/book.svg

Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 5 additions & 5 deletions
Loading
Lines changed: 2 additions & 9 deletions
Loading

0 commit comments

Comments
 (0)