Skip to content

Commit e59058c

Browse files
danielisaacgeslinWormholeBot
and
WormholeBot
authored
Vite build process improvements (#926)
* wip * wip * fixed testing * fix in megreDeep util * run prettier * changed default to testnet * run gen logos script in token-list * run gen script in token-list * token-list specified numpy version * token-list ci fix | attmpt 2 * [automated] update content --------- Co-authored-by: WormholeBot <[email protected]>
1 parent dd1e7ba commit e59058c

Some content is hidden

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

64 files changed

+1224
-880
lines changed

.github/workflows/update-token-list.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v2
2020
- uses: actions/setup-node@v1
2121
with:
22-
node-version: 12
22+
node-version: 18.17.1
2323

2424
- name: Install python dependencies
2525
run: python -m pip install -r requirements.txt

apps/connect/jest.config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ export default {
1010
transform: {
1111
".(ts|tsx)": "ts-jest",
1212
},
13+
moduleNameMapper: {
14+
"@env": "<rootDir>/src/env/index.ts"
15+
},
1316
} as Config;

apps/connect/jest.setup.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import { TextEncoder, TextDecoder } from "util";
55
Object.assign(global, {
66
TextDecoder,
77
TextEncoder,
8-
navBar: [],
9-
wormholeConnectConfig: {},
108
});
9+
10+
jest.mock("./src/env/env-vars.ts", () => ({ envVars: process.env }));

apps/connect/package-lock.json

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/connect/package.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@
55
"type": "module",
66
"scripts": {
77
"dev:usdc-bridge": "vite --config ./vite.usdc-bridge.config.ts",
8+
"dev:usdc-bridge:mainnet": "cross-env VITE_APP_CLUSTER=mainnet npm run dev:usdc-bridge",
9+
"dev:usdc-bridge:testnet": "cross-env VITE_APP_CLUSTER=testnet npm run dev:usdc-bridge",
810
"build:usdc-bridge": "tsc && vite build --config ./vite.usdc-bridge.config.ts",
911
"dev:token-bridge": "vite --config ./vite.token-bridge.config.ts",
12+
"dev:token-bridge:mainnet": "cross-env VITE_APP_CLUSTER=mainnet npm run dev:token-bridge",
13+
"dev:token-bridge:testnet": "cross-env VITE_APP_CLUSTER=testnet npm run dev:token-bridge",
1014
"build:token-bridge": "tsc && vite build --config ./vite.token-bridge.config.ts",
11-
"dev": "vite",
15+
"dev": "npm run dev:token-bridge:testnet",
16+
"start": "npm run dev",
1217
"build": "tsc && vite build",
1318
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1419
"prettier": "prettier --check ./src",
15-
"preview": "vite preview",
16-
"format": "yarn prettier --write ./src",
20+
"preview": "cross-env VITE_APP_CLUSTER=mainnet vite preview",
21+
"format": "npm run prettier -- --write ./src",
1722
"ts:check": "tsc --project ./tsconfig.json --noEmit --skipLibCheck",
18-
"test": "jest",
19-
"test:watch": "jest --watch"
23+
"test": "cross-env VITE_APP_CLUSTER=testnet jest",
24+
"test:watch": "npm run test -- --watch"
2025
},
2126
"dependencies": {
2227
"@certusone/wormhole-sdk": "^0.10.10",
@@ -45,6 +50,7 @@
4550
"@typescript-eslint/eslint-plugin": "^6.0.0",
4651
"@typescript-eslint/parser": "^6.0.0",
4752
"@vitejs/plugin-react-swc": "^3.6.0",
53+
"cross-env": "^7.0.3",
4854
"eslint": "^8.45.0",
4955
"eslint-plugin-react-hooks": "^4.6.0",
5056
"eslint-plugin-react-refresh": "^0.4.3",

apps/connect/src/App.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import { useRoutes } from "react-router-dom";
1515
import PrivacyPolicy from "./components/pages/PrivacyPolicy";
1616
import { PrivacyPolicyPath, isPreview, isProduction } from "./utils/constants";
1717
import Banner from "./components/atoms/Banner";
18+
import { ENV } from "@env";
1819

1920
const defaultConfig: WormholeConnectConfig = {
20-
...wormholeConnectConfig,
21+
...ENV.wormholeConnectConfig,
2122
...((isPreview || isProduction) && {
2223
eventHandler: eventHandler,
2324
}),
@@ -78,7 +79,7 @@ export default function Root() {
7879
]);
7980
return (
8081
<>
81-
{versions.map(({ appName, version }, idx) => (
82+
{ENV.versions.map(({ appName, version }, idx) => (
8283
<meta
8384
name={appName}
8485
content={version}

apps/connect/src/components/atoms/NavBar.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import ListItemButton from "@mui/material/ListItemButton";
1212
import ListItemText from "@mui/material/ListItemText";
1313

1414
import { useState } from "react";
15+
import { ENV } from "@env";
1516

1617
const AppBar = styled(MuiAppBar)(({ theme }) => ({
1718
background: "transparent",
@@ -85,7 +86,7 @@ const Spacer = styled("div")(() => ({
8586
const womrholescanButton = (
8687
<Box>
8788
<Link
88-
href={`https://wormholescan.io${wormholeConnectConfig.env === "testnet" ? "/#/?network=TESTNET" : ""}`}
89+
href={`https://wormholescan.io${ENV.wormholeConnectConfig.env === "testnet" ? "/#/?network=TESTNET" : ""}`}
8990
target="_blank"
9091
color="inherit"
9192
>
@@ -105,7 +106,7 @@ export default function NavBar() {
105106
<Spacer />
106107
<Hidden implementation="css" smDown>
107108
<div style={{ display: "flex", alignItems: "center" }}>
108-
{navBar.map(({ label, active, href, isBlank }, idx) => (
109+
{ENV.navBar.map(({ label, active, href, isBlank }, idx) => (
109110
<Link
110111
key={`${label}_${idx}`}
111112
href={href}
@@ -130,7 +131,7 @@ export default function NavBar() {
130131
{openMenu && (
131132
<Hidden implementation="css" smUp>
132133
<List>
133-
{navBar.map(({ label, href }, idx) => (
134+
{ENV.navBar.map(({ label, href }, idx) => (
134135
<ListItem key={`${label}_${idx}`}>
135136
<ListItemButton component="a" href={href}>
136137
<ListItemText primary={label} />

apps/connect/src/components/atoms/Version.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React from "react";
22
import Footer from "./Footer";
3+
import { ENV } from "@env";
34

45
export default function Version() {
56
return (
67
<Footer left="120px">
7-
{versions.map(({ appName, version }, idx) => (
8+
{ENV.versions.map(({ appName, version }, idx) => (
89
<React.Fragment key={`${appName}-${version}-${idx}`}>
910
{appName}: {version}
10-
{idx < versions.length - 1 && <br />}
11+
{idx < ENV.versions.length - 1 && <br />}
1112
</React.Fragment>
1213
))}
1314
</Footer>

apps/connect/src/env/common.ts

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import type { WormholeConnectConfig } from "@wormhole-foundation/wormhole-connect";
2+
import packageJson from "../../package.json";
3+
import { envVars } from "./env-vars";
4+
5+
const rpcs = (chains: string[], template: (chain: string) => string) =>
6+
chains
7+
.map((chain: string) => ({ [chain]: template(chain) }))
8+
.reduce((acc, cur) => ({ ...acc, ...cur }), {});
9+
const asRpcHost = (chain: string) =>
10+
`https://and76cjzpa.execute-api.us-east-2.amazonaws.com/${chain}/`;
11+
export const chains = [
12+
"wormchain",
13+
"osmosis",
14+
"ethereum",
15+
"sui",
16+
"aptos",
17+
"kujira",
18+
"evmos",
19+
"bsc",
20+
"polygon",
21+
"avalanche",
22+
"fantom",
23+
"celo",
24+
"moonbeam",
25+
"base",
26+
"arbitrum",
27+
"optimism",
28+
"scroll",
29+
"xlayer",
30+
"mantle",
31+
];
32+
33+
export const MAINNET_RPCS = {
34+
...rpcs(chains, asRpcHost),
35+
solana: "https://wormhole.rpcpool.com/",
36+
};
37+
38+
export const PUBLIC_URL = envVars.PUBLIC_URL || "";
39+
40+
export const versions: Env["versions"] = [
41+
{
42+
appName: "Portal Bridge",
43+
version: `v${envVars.VITE_APP_VERSION || "0.0.0"}`,
44+
},
45+
{
46+
appName: "Wormhole Connect",
47+
version: `v${packageJson.version}`,
48+
},
49+
];
50+
51+
export const wormholeConnectConfigCommon: Partial<WormholeConnectConfig> = {
52+
walletConnectProjectId: envVars.VITE_APP_WALLET_CONNECT_PROJECT_ID || "",
53+
54+
env: envVars.VITE_APP_CLUSTER || "testnet",
55+
rpcs: {},
56+
showHamburgerMenu: false,
57+
explorer: {
58+
href: `https://wormholescan.io/#/txs?address={:address}&network=${envVars.VITE_APP_CLUSTER || "testnet"}`,
59+
},
60+
menu: [
61+
{
62+
label: "Advanced Tools",
63+
href: `${envVars.PUBLIC_URL}/advanced-tools/`,
64+
order: 1,
65+
},
66+
{
67+
label: "Privacy Policy",
68+
href: `${envVars.PUBLIC_URL}/#/privacy-policy/`,
69+
},
70+
],
71+
};
72+
73+
export interface Env {
74+
wormholeConnectConfig: WormholeConnectConfig;
75+
navBar: {
76+
label: string;
77+
active?: boolean;
78+
href: string;
79+
isBlank?: boolean;
80+
}[];
81+
redirects?: { source: string[]; target: string };
82+
versions: { version: string; appName: string }[];
83+
}

apps/connect/src/env/env-vars.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const envVars = import.meta.env;

apps/connect/src/env/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ENV } from "./token-bridge";

0 commit comments

Comments
 (0)