From b1678c5af72547a209511f67e7837d6357ca9579 Mon Sep 17 00:00:00 2001 From: Trung-Tin Pham <60747384+AtelyPham@users.noreply.github.com> Date: Thu, 27 Jul 2023 00:42:05 +0700 Subject: [PATCH 1/2] Fix Environment Variables Issue (#1465) --- .env.example | 31 +++++++++++++++++++ .github/workflows/check-build.yml | 16 +++++----- .github/workflows/deploy-bridge-dapp-dev.yml | 18 ++++++----- .github/workflows/deploy-faucet.yml | 4 ++- .github/workflows/deploy-hubble-stats.yml | 2 ++ .github/workflows/deploy-stats-dapp-dev.yml | 4 ++- .github/workflows/deploy-tangle-website.yml | 4 ++- .github/workflows/deploy-webbsite-dev.yml | 4 ++- .github/workflows/release.yml | 14 ++++----- apps/bridge-dapp/.env.example | 23 -------------- apps/bridge-dapp/scripts/localSubstrate.ts | 2 +- apps/bridge-dapp/scripts/localTangle.ts | 2 +- apps/bridge-dapp/src/constants/signIn.ts | 2 +- apps/bridge-dapp/webpack.base.js | 16 +++++----- apps/faucet/.env.local.example | 4 --- libs/dapp-config/src/anchors/anchor-config.ts | 4 +-- libs/dapp-config/src/chains/evm/index.tsx | 29 ++++++++--------- libs/dapp-config/src/wagmi-config.ts | 4 +-- .../src/wallets/wallets-config.tsx | 8 +++-- 19 files changed, 105 insertions(+), 86 deletions(-) delete mode 100644 apps/bridge-dapp/.env.example delete mode 100644 apps/faucet/.env.local.example diff --git a/.env.example b/.env.example index e44cf4d326..55012b5a6e 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ +# For marketing sites SENDINBLUE_API_KEY="" PRIVACY_POLICY_PAGE_ID="" @@ -10,3 +11,33 @@ NOTION_BLOG_INTEGRATION_POSTS_DATABASE_ID="> .env echo TERMS_AND_CONDITIONS_PAGE_ID=${{ secrets.TERMS_AND_CONDITIONS_PAGE_ID }} >> .env + echo NOTION_TOKEN_V2=${{ secrets.NOTION_TOKEN_V2 }} >> .env echo NOTION_ACTIVE_USER=${{ secrets.NOTION_ACTIVE_USER }} >> .env echo NOTION_BLOG_INTEGRATION_POSTS_DATABASE_ID=${{ secrets.NOTION_BLOG_INTEGRATION_POSTS_DATABASE_ID }} >> .env echo NOTION_BLOG_INTEGRATION_TOKEN=${{ secrets.NOTION_BLOG_INTEGRATION_TOKEN }} >> .env echo NOTION_BLOG_INTEGRATION_VIDEOS_DATABASE_ID=${{ secrets.NOTION_BLOG_INTEGRATION_VIDEOS_DATABASE_ID }} >> .env + echo NEXT_PUBLIC_FAUCET_BACKEND_URL=${{ secrets.NEXT_PUBLIC_FAUCET_BACKEND_URL }} >> .env echo NEXT_PUBLIC_TWITTER_CLIENT_ID=${{ secrets.NEXT_PUBLIC_TWITTER_CLIENT_ID }} >> .env echo TWITTER_CLIENT_SECRET=${{ secrets.TWITTER_CLIENT_SECRET }} >> .env - touch apps/bridge-dapp/.env - echo NX_BRIDGE_APP_DOMAIN=${{ secrets.NX_BRIDGE_APP_DOMAIN }} >> apps/bridge-dapp/.env - echo WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }} >> apps/bridge-dapp/.env - echo HOSTED_ORBIT_MULTLICALL3_ADDRESS=${{ secrets.HOSTED_ORBIT_MULTLICALL3_ADDRESS }} >> apps/bridge-dapp/.env - echo ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env - echo HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env - echo DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env + + echo BRIDGE_DAPP_DOMAIN=${{ secrets.BRIDGE_DAPP_DOMAIN }} >> .env + echo BRIDGE_DAPP_WALLET_CONNECT_PROJECT_ID=${{ secrets.BRIDGE_DAPP_WALLET_CONNECT_PROJECT_ID }} >> .env + echo BRIDGE_DAPP_HOSTED_ORBIT_MULTLICALL3_ADDRESS=${{ secrets.BRIDGE_DAPP_HOSTED_ORBIT_MULTLICALL3_ADDRESS }} >> .env + echo BRIDGE_DAPP_ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.BRIDGE_DAPP_ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> .env + echo BRIDGE_DAPP_HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.BRIDGE_DAPP_HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> .env + echo BRIDGE_DAPP_DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.BRIDGE_DAPP_DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> .env - name: Install deps run: yarn install diff --git a/.github/workflows/deploy-bridge-dapp-dev.yml b/.github/workflows/deploy-bridge-dapp-dev.yml index 8e0dd34f8e..93b4fe8bc5 100644 --- a/.github/workflows/deploy-bridge-dapp-dev.yml +++ b/.github/workflows/deploy-bridge-dapp-dev.yml @@ -35,13 +35,13 @@ jobs: - name: create env file run: | - touch apps/bridge-dapp/.env - echo NX_BRIDGE_APP_DOMAIN=${{ secrets.NX_BRIDGE_APP_DOMAIN }} >> apps/bridge-dapp/.env - echo WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }} >> apps/bridge-dapp/.env - echo HOSTED_ORBIT_MULTLICALL3_ADDRESS=${{ secrets.HOSTED_ORBIT_MULTLICALL3_ADDRESS }} >> apps/bridge-dapp/.env - echo ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env - echo HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env - echo DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env + touch .env + echo BRIDGE_DAPP_DOMAIN=${{ secrets.BRIDGE_DAPP_DOMAIN }} >> .env + echo BRIDGE_DAPP_WALLET_CONNECT_PROJECT_ID=${{ secrets.BRIDGE_DAPP_WALLET_CONNECT_PROJECT_ID }} >> .env + echo BRIDGE_DAPP_HOSTED_ORBIT_MULTLICALL3_ADDRESS=${{ secrets.BRIDGE_DAPP_HOSTED_ORBIT_MULTLICALL3_ADDRESS }} >> .env + echo BRIDGE_DAPP_ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.BRIDGE_DAPP_ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> .env + echo BRIDGE_DAPP_HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.BRIDGE_DAPP_HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> .env + echo BRIDGE_DAPP_DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.BRIDGE_DAPP_DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> .env - name: Build project run: yarn build:bridge @@ -56,7 +56,9 @@ jobs: args: deploy context=deploy-preview site=$NETLIFY_BRIDGE_SITE_ID --dir=./dist/apps/bridge-dapp/ - name: Netlify Preview URL - uses: unsplash/comment-on-pr@v1.3.1 + # Use master branch to fix issue with entrypoint.sh script + # https://github.com/unsplash/comment-on-pr/issues/51 + uses: unsplash/comment-on-pr@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} OUTPUT: | diff --git a/.github/workflows/deploy-faucet.yml b/.github/workflows/deploy-faucet.yml index ec67fecebd..4acdd34154 100644 --- a/.github/workflows/deploy-faucet.yml +++ b/.github/workflows/deploy-faucet.yml @@ -75,7 +75,9 @@ jobs: echo "NETLIFY_LOGS_URL=$LOGS_URL" >> $GITHUB_OUTPUT - name: Netlify Preview URL - uses: unsplash/comment-on-pr@v1.3.1 + # Use master branch to fix issue with entrypoint.sh script + # https://github.com/unsplash/comment-on-pr/issues/51 + uses: unsplash/comment-on-pr@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MSG: | diff --git a/.github/workflows/deploy-hubble-stats.yml b/.github/workflows/deploy-hubble-stats.yml index df6feee0c6..36e9c30d66 100644 --- a/.github/workflows/deploy-hubble-stats.yml +++ b/.github/workflows/deploy-hubble-stats.yml @@ -68,6 +68,8 @@ jobs: echo "NETLIFY_LOGS_URL=$LOGS_URL" >> $GITHUB_OUTPUT - name: Netlify Preview URL + # Use master branch to fix issue with entrypoint.sh script + # https://github.com/unsplash/comment-on-pr/issues/51 uses: unsplash/comment-on-pr@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/deploy-stats-dapp-dev.yml b/.github/workflows/deploy-stats-dapp-dev.yml index 53692ba9e3..afae2866fd 100644 --- a/.github/workflows/deploy-stats-dapp-dev.yml +++ b/.github/workflows/deploy-stats-dapp-dev.yml @@ -46,7 +46,9 @@ jobs: args: deploy context=deploy-preview site=$NETLIFY_SITE_ID --dir=./dist/apps/stats-dapp/ - name: Netlify Preview URL - uses: unsplash/comment-on-pr@v1.3.1 + # Use master branch to fix issue with entrypoint.sh script + # https://github.com/unsplash/comment-on-pr/issues/51 + uses: unsplash/comment-on-pr@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} OUTPUT: | diff --git a/.github/workflows/deploy-tangle-website.yml b/.github/workflows/deploy-tangle-website.yml index c63d94fd19..e1d521bc89 100644 --- a/.github/workflows/deploy-tangle-website.yml +++ b/.github/workflows/deploy-tangle-website.yml @@ -76,7 +76,9 @@ jobs: echo "NETLIFY_LOGS_URL=$LOGS_URL" >> $GITHUB_OUTPUT - name: Netlify Preview URL - uses: unsplash/comment-on-pr@v1.3.1 + # Use master branch to fix issue with entrypoint.sh script + # https://github.com/unsplash/comment-on-pr/issues/51 + uses: unsplash/comment-on-pr@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MSG: | diff --git a/.github/workflows/deploy-webbsite-dev.yml b/.github/workflows/deploy-webbsite-dev.yml index fbb9366a67..df924e3445 100644 --- a/.github/workflows/deploy-webbsite-dev.yml +++ b/.github/workflows/deploy-webbsite-dev.yml @@ -83,7 +83,9 @@ jobs: echo "NETLIFY_LOGS_URL=$LOGS_URL" >> $GITHUB_OUTPUT - name: Netlify Preview URL - uses: unsplash/comment-on-pr@v1.3.1 + # Use master branch to fix issue with entrypoint.sh script + # https://github.com/unsplash/comment-on-pr/issues/51 + uses: unsplash/comment-on-pr@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MSG: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65ac1c7782..60b1bcdbe3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,13 +80,13 @@ jobs: echo NEXT_PUBLIC_TWITTER_CLIENT_ID=${{ secrets.NEXT_PUBLIC_TWITTER_CLIENT_ID }} >> .env echo TWITTER_CLIENT_SECRET=${{ secrets.TWITTER_CLIENT_SECRET }} >> .env - touch apps/bridge-dapp/.env - echo NX_BRIDGE_APP_DOMAIN=${{ secrets.NX_BRIDGE_APP_DOMAIN }} >> apps/bridge-dapp/.env - echo WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }} >> apps/bridge-dapp/.env - echo HOSTED_ORBIT_MULTLICALL3_ADDRESS=${{ secrets.HOSTED_ORBIT_MULTLICALL3_ADDRESS }} >> apps/bridge-dapp/.env - echo ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env - echo HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env - echo DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> apps/bridge-dapp/.env + touch .env + echo BRIDGE_DAPP_DOMAIN=${{ secrets.BRIDGE_DAPP_DOMAIN }} >> .env + echo BRIDGE_DAPP_WALLET_CONNECT_PROJECT_ID=${{ secrets.BRIDGE_DAPP_WALLET_CONNECT_PROJECT_ID }} >> .env + echo BRIDGE_DAPP_HOSTED_ORBIT_MULTLICALL3_ADDRESS=${{ secrets.BRIDGE_DAPP_HOSTED_ORBIT_MULTLICALL3_ADDRESS }} >> .env + echo BRIDGE_DAPP_ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.BRIDGE_DAPP_ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> .env + echo BRIDGE_DAPP_HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.BRIDGE_DAPP_HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> .env + echo BRIDGE_DAPP_DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=${{ secrets.BRIDGE_DAPP_DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK }} >> .env - name: Install deps run: yarn install diff --git a/apps/bridge-dapp/.env.example b/apps/bridge-dapp/.env.example deleted file mode 100644 index f74420f0d5..0000000000 --- a/apps/bridge-dapp/.env.example +++ /dev/null @@ -1,23 +0,0 @@ -# WARNING: THIS FILE WILL BE PUBLICLY AVAILABLE -# SO DO NOT PUT ANY SENSITIVE INFORMATION HERE - -NX_BRIDGE_APP_DOMAIN=http:localhost:3000 - -POLKADOT_TEST_ACCOUNT_ADDRESS="" - -WALLET_CONNECT_PROJECT_ID="" - -# If you want to enable the local orbit integration, -# you need to set the local anchor addresses of the local orbit instance -LOCAL_ORBIT_ANCHOR_ADDRESS="" - -# If you want to support Multicall3 contract for Orbit chains -LOCAL_ORBIT_MULTICALL3_ADDRESS="" -LOCAL_ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=0 -LOCAL_HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=0 -LOCAL_DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=0 - -HOSTED_ORBIT_MULTLICALL3_ADDRESS="" -ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=0 -HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=0 -DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK=0 diff --git a/apps/bridge-dapp/scripts/localSubstrate.ts b/apps/bridge-dapp/scripts/localSubstrate.ts index 5d67f5a468..051ef67c84 100644 --- a/apps/bridge-dapp/scripts/localSubstrate.ts +++ b/apps/bridge-dapp/scripts/localSubstrate.ts @@ -35,7 +35,7 @@ const NATIVE_ASSET = 'tTNT'; const FUNGIBLE_ASSET = 'webbtTNT'; -const TEST_ACCOUNT = process.env.POLKADOT_TEST_ACCOUNT_ADDRESS; +const TEST_ACCOUNT = process.env.BRIDGE_DAPP_POLKADOT_TEST_ACCOUNT_ADDRESS; const AMOUNT = 1_000_000; diff --git a/apps/bridge-dapp/scripts/localTangle.ts b/apps/bridge-dapp/scripts/localTangle.ts index d1a3c6dc02..3d91c67d53 100644 --- a/apps/bridge-dapp/scripts/localTangle.ts +++ b/apps/bridge-dapp/scripts/localTangle.ts @@ -33,7 +33,7 @@ const NATIVE_ASSET = 'tTNT'; const FUNGIBLE_ASSET = 'webbtTNT'; -const TEST_ACCOUNT = process.env.POLKADOT_TEST_ACCOUNT_ADDRESS; +const TEST_ACCOUNT = process.env.BRIDGE_DAPP_POLKADOT_TEST_ACCOUNT_ADDRESS; const AMOUNT = 1_000_000; diff --git a/apps/bridge-dapp/src/constants/signIn.ts b/apps/bridge-dapp/src/constants/signIn.ts index f272884bfd..7372360307 100644 --- a/apps/bridge-dapp/src/constants/signIn.ts +++ b/apps/bridge-dapp/src/constants/signIn.ts @@ -1,4 +1,4 @@ -const domain = process.env.NX_BRIDGE_APP_DOMAIN ?? 'localhost'; +const domain = process.env.BRIDGE_DAPP_DOMAIN ?? 'localhost'; const origin = `http${domain === 'localhost' ? '' : 's'}://${domain}/login`; diff --git a/apps/bridge-dapp/webpack.base.js b/apps/bridge-dapp/webpack.base.js index bdb18ce0ca..ecd62dd73d 100644 --- a/apps/bridge-dapp/webpack.base.js +++ b/apps/bridge-dapp/webpack.base.js @@ -63,15 +63,13 @@ function createWebpack(env, mode = 'production') { ] : []; - const envPath = path.resolve( - workspaceRoot, - 'apps', - process.env.NX_TASK_TARGET_PROJECT, - '.env' - ); - - const bridgeEnvVars = - require('dotenv').config({ path: envPath }).parsed || {}; + // Load bridge dapp specific env vars by prefixing with BRIDGE_DAPP_ + const bridgeEnvVars = Object.keys(process.env) + .filter((key) => key.startsWith('BRIDGE_DAPP_')) + .reduce((envVars, key) => { + envVars[key] = JSON.stringify(process.env[key]); + return envVars; + }, {}); return { experiments: { diff --git a/apps/faucet/.env.local.example b/apps/faucet/.env.local.example deleted file mode 100644 index 81b224bbfc..0000000000 --- a/apps/faucet/.env.local.example +++ /dev/null @@ -1,4 +0,0 @@ -NEXT_PUBLIC_AMOUNT="20" -NEXT_PUBLIC_FAUCET_BACKEND_URL="https://faucet-backend.webb.tools" -NEXT_PUBLIC_TWITTER_CLIENT_ID="" -TWITTER_CLIENT_SECRET="" diff --git a/libs/dapp-config/src/anchors/anchor-config.ts b/libs/dapp-config/src/anchors/anchor-config.ts index a0ee7c791e..31585d779c 100644 --- a/libs/dapp-config/src/anchors/anchor-config.ts +++ b/libs/dapp-config/src/anchors/anchor-config.ts @@ -5,12 +5,12 @@ import { } from '@webb-tools/sdk-core/typed-chain-id'; import { LOCALNET_CHAIN_IDS } from '../chains'; -const localAnchorRecord = process.env.LOCAL_ORBIT_ANCHOR_ADDRESS +const localAnchorRecord = process.env.BRIDGE_DAPP_LOCAL_ORBIT_ANCHOR_ADDRESS ? LOCALNET_CHAIN_IDS.reduce>>( (acc, chainId) => { const typedChainId = calculateTypedChainId(ChainType.EVM, chainId); const anchorAddress: string = process.env - .LOCAL_ORBIT_ANCHOR_ADDRESS as string; + .BRIDGE_DAPP_LOCAL_ORBIT_ANCHOR_ADDRESS as string; acc[typedChainId] = { [anchorAddress]: 0, diff --git a/libs/dapp-config/src/chains/evm/index.tsx b/libs/dapp-config/src/chains/evm/index.tsx index 4ba0ef0b74..196328e619 100644 --- a/libs/dapp-config/src/chains/evm/index.tsx +++ b/libs/dapp-config/src/chains/evm/index.tsx @@ -19,38 +19,39 @@ import { DEFAULT_EVM_CURRENCY } from '../../currencies'; import { ChainConfig, WebbExtendedChain } from '../chain-config.interface'; const hostedOrbitMulticall3Address = - process.env.HOSTED_ORBIT_MULTLICALL3_ADDRESS; + process.env.BRIDGE_DAPP_HOSTED_ORBIT_MULTLICALL3_ADDRESS; const athenaOrbitMulticall3DeploymentBlock = process.env - .ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK - ? parseInt(process.env.ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK) + .BRIDGE_DAPP_ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK + ? parseInt(process.env.BRIDGE_DAPP_ATHENA_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK) : 0; const hermesOrbitMulticall3DeploymentBlock = process.env - .HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK - ? parseInt(process.env.HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK) + .BRIDGE_DAPP_HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK + ? parseInt(process.env.BRIDGE_DAPP_HERMES_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK) : 0; const demeterOrbitMulticall3DeploymentBlock = process.env - .DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK - ? parseInt(process.env.DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK) + .BRIDGE_DAPP_DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK + ? parseInt(process.env.BRIDGE_DAPP_DEMETER_ORBIT_MULTICALL3_DEPLOYMENT_BLOCK) : 0; -const localOrbitMulticall3Address = process.env.LOCAL_ORBIT_MULTICALL3_ADDRESS; +const localOrbitMulticall3Address = + process.env.BRIDGE_DAPP_LOCAL_ORBIT_MULTICALL3_ADDRESS; const localAthenaMulticall3DeploymentBlock = process.env - .LOCAL_ATHENA_MULTICALL3_DEPLOYMENT_BLOCK - ? parseInt(process.env.LOCAL_ATHENA_MULTICALL3_DEPLOYMENT_BLOCK) + .BRIDGE_DAPP_LOCAL_ATHENA_MULTICALL3_DEPLOYMENT_BLOCK + ? parseInt(process.env.BRIDGE_DAPP_LOCAL_ATHENA_MULTICALL3_DEPLOYMENT_BLOCK) : 0; const localHermesMulticall3DeploymentBlock = process.env - .LOCAL_HERMES_MULTICALL3_DEPLOYMENT_BLOCK - ? parseInt(process.env.LOCAL_HERMES_MULTICALL3_DEPLOYMENT_BLOCK) + .BRIDGE_DAPP_LOCAL_HERMES_MULTICALL3_DEPLOYMENT_BLOCK + ? parseInt(process.env.BRIDGE_DAPP_LOCAL_HERMES_MULTICALL3_DEPLOYMENT_BLOCK) : 0; const localDemeterMulticall3DeploymentBlock = process.env - .LOCAL_DEMETER_MULTICALL3_DEPLOYMENT_BLOCK - ? parseInt(process.env.LOCAL_DEMETER_MULTICALL3_DEPLOYMENT_BLOCK) + .BRIDGE_DAPP_LOCAL_DEMETER_MULTICALL3_DEPLOYMENT_BLOCK + ? parseInt(process.env.BRIDGE_DAPP_LOCAL_DEMETER_MULTICALL3_DEPLOYMENT_BLOCK) : 0; export const chainsConfig: Record = { diff --git a/libs/dapp-config/src/wagmi-config.ts b/libs/dapp-config/src/wagmi-config.ts index a5b172801b..87bafd7c09 100644 --- a/libs/dapp-config/src/wagmi-config.ts +++ b/libs/dapp-config/src/wagmi-config.ts @@ -4,8 +4,8 @@ import { chainsConfig } from './chains/evm'; import { SupportedConnector } from './wallets/wallet-config.interface'; import { walletsConfig } from './wallets/wallets-config'; -if (!process.env['WALLET_CONNECT_PROJECT_ID']) { - throw new Error('Missing WALLET_CONNECT_PROJECT_ID'); +if (!process.env['BRIDGE_DAPP_WALLET_CONNECT_PROJECT_ID']) { + throw new Error('Missing BRIDGE_DAPP_WALLET_CONNECT_PROJECT_ID'); } const { publicClient, webSocketPublicClient } = configureChains( diff --git a/libs/dapp-config/src/wallets/wallets-config.tsx b/libs/dapp-config/src/wallets/wallets-config.tsx index 694a612ef4..f10acf11ea 100644 --- a/libs/dapp-config/src/wallets/wallets-config.tsx +++ b/libs/dapp-config/src/wallets/wallets-config.tsx @@ -49,8 +49,10 @@ const ANY_SUBSTRATE = [ PresetTypedChainId.Polkadot, ]; -if (!process.env['WALLET_CONNECT_PROJECT_ID']) { - throw new Error('Missing WALLET_CONNECT_PROJECT_ID env variable.'); +if (!process.env['BRIDGE_DAPP_WALLET_CONNECT_PROJECT_ID']) { + throw new Error( + 'Missing BRIDGE_DAPP_WALLET_CONNECT_PROJECT_ID env variable.' + ); } export const walletsConfig: Record = { @@ -115,7 +117,7 @@ export const walletsConfig: Record = { homeLink: 'https://walletconnect.com/', connector: new WalletConnectConnector({ options: { - projectId: process.env['WALLET_CONNECT_PROJECT_ID'], + projectId: process.env['BRIDGE_DAPP_WALLET_CONNECT_PROJECT_ID'], }, }), }, From 7047e1112a8e0a292a222e6bda2f5038e7d5286b Mon Sep 17 00:00:00 2001 From: Trung-Tin Pham <60747384+AtelyPham@users.noreply.github.com> Date: Thu, 27 Jul 2023 15:05:21 +0700 Subject: [PATCH 2/2] fix: parse and set the bridge env vars in webpack --- apps/bridge-dapp/webpack.base.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/bridge-dapp/webpack.base.js b/apps/bridge-dapp/webpack.base.js index ecd62dd73d..2dc167e553 100644 --- a/apps/bridge-dapp/webpack.base.js +++ b/apps/bridge-dapp/webpack.base.js @@ -67,7 +67,7 @@ function createWebpack(env, mode = 'production') { const bridgeEnvVars = Object.keys(process.env) .filter((key) => key.startsWith('BRIDGE_DAPP_')) .reduce((envVars, key) => { - envVars[key] = JSON.stringify(process.env[key]); + envVars[`process.env.${key}`] = JSON.stringify(process.env[key]); return envVars; }, {}); @@ -257,9 +257,9 @@ function createWebpack(env, mode = 'production') { resourceRegExp: /^\.\/locale$/, }), new webpack.DefinePlugin({ - 'process.env': JSON.stringify(bridgeEnvVars), 'process.env.BRIDGE_VERSION': JSON.stringify(packageVersion), 'process.env.NODE_ENV': JSON.stringify(mode), + ...bridgeEnvVars, }), new webpack.optimize.SplitChunksPlugin(), new MiniCssExtractPlugin({