Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit e3f824a

Browse files
committed
Adapt env var with .env.development and .env.production
1 parent e6c9394 commit e3f824a

File tree

7 files changed

+44
-26
lines changed

7 files changed

+44
-26
lines changed

frontend/.env.development

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
NEXT_PUBLIC_DEVELOPER_DAO_CONTRACT=0xbf114c4cbb4e70e6098589a918c84292cb40602a
2+
NEXT_PUBLIC_DEVELOPER_DAO_CONTRACT_NETWORK=rinkeby
3+
NEXT_PUBLIC_DEVELOPER_DAO_CONTRACT_NETWORK_PROVIDER=rinkeby
4+
NEXT_PUBLIC_NETWORK_ID=4
5+
NEXT_PUBLIC_OPENSEA_DIRECT_LINK_PREFIX=https://testnets.opensea.io/assets/$DEVELOPER_DAO_CONTRACT
6+
NEXT_PUBLIC_OPENSEA_COLLECTION_LINK=https://testnets.opensea.io/collection/devs-for-revolution-kexfxbcvp8
7+
NEXT_PUBLIC_ETHER_SCAN_LINK_PREFIX=https://rinkeby.etherscan.io/address
8+
NEXT_PUBLIC_ETHERSCAN_TX_URL=https://rinkeby.etherscan.io/tx/
9+
NEXT_PUBLIC_INFURA_ID=

frontend/.env.production

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
NEXT_PUBLIC_DEVELOPER_DAO_CONTRACT=0x25ed58c027921E14D86380eA2646E3a1B5C55A8b
2+
NEXT_PUBLIC_DEVELOPER_DAO_CONTRACT_NETWORK=mainnet
3+
NEXT_PUBLIC_DEVELOPER_DAO_CONTRACT_NETWORK_PROVIDER=homestead
4+
NEXT_PUBLIC_NETWORK_ID=1
5+
NEXT_PUBLIC_OPENSEA_DIRECT_LINK_PREFIX=https://testnets.opensea.io/assets/$DEVELOPER_DAO_CONTRACT
6+
NEXT_PUBLIC_OPENSEA_COLLECTION_LINK=https://testnets.opensea.io/collection/devs-for-revolution-kexfxbcvp8
7+
NEXT_PUBLIC_ETHER_SCAN_LINK_PREFIX=https://rinkeby.etherscan.io/address
8+
NEXT_PUBLIC_ETHERSCAN_TX_URL=https://rinkeby.etherscan.io/tx/
9+
NEXT_PUBLIC_INFURA_ID=

frontend/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ nvm install; # to install the version in .nvmrc
8484
2. Install dependencies by running `yarn`
8585
3. Start the development server with `yarn dev`
8686
4. Open development site by going to `http:localhost:3000`
87+
5. To test Walletconnect functionality, copy `.env.development` to `.env.local` and fill in your `INFURA_ID`.
8788

8889
## Contributing
8990

frontend/src/components/DirectMint/DirectMint.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import WalletConnectProvider from '@walletconnect/web3-provider';
2626
import Web3Modal from 'web3modal';
2727
import { useTranslation } from 'next-i18next';
2828
import {
29-
NODE_ENV,
3029
DEVELOPER_DAO_CONTRACT,
3130
DEVELOPER_DAO_CONTRACT_NETWORK,
3231
ERROR_CODE_TX_REJECTED_BY_USER,
3332
NETWORK_ID,
3433
ETHERSCAN_TX_URL,
34+
INFURA_ID,
3535
} from '../../utils/DeveloperDaoConstants';
3636

3737
import MINT_CONTRACT from '../../artifacts/ddao.json';
@@ -47,7 +47,7 @@ const providerOptions = {
4747
walletconnect: {
4848
package: WalletConnectProvider,
4949
options: {
50-
infuraId: process.env.NEXT_PUBLIC_INFURA_ID,
50+
infuraId: INFURA_ID,
5151
},
5252
},
5353
};
@@ -272,7 +272,7 @@ const DirectMint = ({ developerId }: DirectMintProps) => {
272272
{networkError && (
273273
<Text color="red">
274274
{t(
275-
NODE_ENV === 'development'
275+
DEVELOPER_DAO_CONTRACT_NETWORK === 'rinkeby'
276276
? 'ethereumDevNetworkPrompt'
277277
: 'ethereumNetworkPrompt',
278278
)}

frontend/src/components/DirectMint/DirectMintBox.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import {
1212
Link,
1313
} from '@chakra-ui/react';
1414
import { useTranslation } from 'next-i18next';
15-
import { NODE_ENV, TOKEN_FINDER_URL } from '../../utils/DeveloperDaoConstants';
15+
import {
16+
DEVELOPER_DAO_CONTRACT_NETWORK,
17+
TOKEN_FINDER_URL,
18+
} from '../../utils/DeveloperDaoConstants';
1619

1720
// Layout for the Direct Mint Box
1821
// used on the minting page
@@ -29,7 +32,7 @@ const DirectMintBox = () => {
2932
>
3033
<Stack spacing={6} align="center">
3134
<Logo w={52} h={52} />
32-
{NODE_ENV === 'development' && (
35+
{DEVELOPER_DAO_CONTRACT_NETWORK === 'rinkeby' && (
3336
<Badge colorScheme="orange">{t('testnet')}</Badge>
3437
)}
3538
<Heading fontSize={{ base: '1.25rem', sm: '2rem' }}>

frontend/src/pages/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { useRouter } from 'next/router';
55
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
66
import { useTranslation } from 'next-i18next';
77
import {
8-
NODE_ENV,
98
DEVELOPER_DAO_CONTRACT,
109
DEVELOPER_DAO_CONTRACT_ABI,
10+
DEVELOPER_DAO_CONTRACT_NETWORK,
1111
DEVELOPER_DAO_CONTRACT_NETWORK_PROVIDER,
1212
ETHER_SCAN_LINK_PREFIX,
1313
SITE_URL,
@@ -63,7 +63,7 @@ function App() {
6363
<VStack mx="auto" px={4} spacing={5} w="full" maxW="lg">
6464
<Logo w={32} h={32} />
6565
<VStack w="full">
66-
{NODE_ENV === 'development' && (
66+
{DEVELOPER_DAO_CONTRACT_NETWORK === 'rinkeby' && (
6767
<Badge colorScheme="orange">{t('testnet')}</Badge>
6868
)}
6969
<Text fontSize="xl">{t('searchId')}</Text>

frontend/src/utils/DeveloperDaoConstants.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
1-
export const NODE_ENV = process.env.NODE_ENV || 'development';
21
export const DEVELOPER_DAO_CONTRACT =
3-
NODE_ENV === 'production'
4-
? '0x25ed58c027921E14D86380eA2646E3a1B5C55A8b'
5-
: '0xbf114c4cbb4e70e6098589a918c84292cb40602a';
2+
process.env.NEXT_PUBLIC_DEVELOPER_DAO_CONTRACT ||
3+
'0xbf114c4cbb4e70e6098589a918c84292cb40602a';
64
export const DEVELOPER_DAO_CONTRACT_NETWORK =
7-
NODE_ENV === 'production' ? 'mainnet' : 'rinkeby';
5+
process.env.NEXT_PUBLIC_DEVELOPER_DAO_CONTRACT_NETWORK || 'rinkeby';
86
export const DEVELOPER_DAO_CONTRACT_NETWORK_PROVIDER =
9-
NODE_ENV === 'production' ? 'homestead' : 'rinkeby';
10-
export const NETWORK_ID = NODE_ENV === 'production' ? 1 : 4;
7+
process.env.NEXT_PUBLIC_DEVELOPER_DAO_CONTRACT_NETWORK || 'rinkeby';
8+
export const NETWORK_ID = process.env.NEXT_PUBLIC_NETWORK_ID || 4;
119
export const DEVELOPER_DAO_WEBSITE = 'https://www.developerdao.com';
1210
export const OPENSEA_DIRECT_LINK_PREFIX =
13-
NODE_ENV === 'production'
14-
? `https://opensea.io/assets/${DEVELOPER_DAO_CONTRACT}`
15-
: `https://testnets.opensea.io/assets/${DEVELOPER_DAO_CONTRACT}`;
11+
process.env.NEXT_PUBLIC_OPENSEA_DIRECT_LINK_PREFIX ||
12+
`https://testnets.opensea.io/assets/${DEVELOPER_DAO_CONTRACT}`;
1613
export const OPENSEA_COLLECTION_LINK =
17-
NODE_ENV === 'production'
18-
? `https://opensea.io/collection/devs-for-revolution`
19-
: `https://testnets.opensea.io/collection/devs-for-revolution-kexfxbcvp8`;
14+
process.env.NEXT_PUBLIC_OPENSEA_COLLECTION_LINK ||
15+
`https://testnets.opensea.io/collection/devs-for-revolution-kexfxbcvp8`;
2016
export const ETHER_SCAN_LINK_PREFIX =
21-
NODE_ENV === 'production'
22-
? 'https://etherscan.io/address'
23-
: 'https://rinkeby.etherscan.io/address';
17+
process.env.NEXT_PUBLIC_ETHER_SCAN_LINK_PREFIX ||
18+
'https://rinkeby.etherscan.io/address';
2419

2520
export const SITE_URL = 'https://developerdao.com';
2621
export const ERROR_CODE_TX_REJECTED_BY_USER = 4001;
2722

2823
export const TOKEN_FINDER_URL = 'https://developerdao.vercel.app/';
2924
export const ETHERSCAN_TX_URL =
30-
NODE_ENV === 'production'
31-
? 'https://etherscan.io/tx/'
32-
: 'https://rinkeby.etherscan.io/tx/';
25+
process.env.NEXT_PUBLIC_ETHERSCAN_TX_URL ||
26+
'https://rinkeby.etherscan.io/tx/';
27+
28+
export const INFURA_ID = process.env.NEXT_PUBLIC_INFURA_ID;
3329

3430
export const DEVELOPER_DAO_CONTRACT_ABI = [
3531
{ inputs: [], stateMutability: 'nonpayable', type: 'constructor' },

0 commit comments

Comments
 (0)