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

Commit 48b0261

Browse files
author
Narb
authored
Merge pull request #162 from kavimaluskam/feature/testnet-local-environment
Feature: Testnet local environment
2 parents 20e833f + b6d96b7 commit 48b0261

File tree

10 files changed

+94
-21
lines changed

10 files changed

+94
-21
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/0xbf114c4cbb4e70e6098589a918c84292cb40602a
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://opensea.io/assets/0x25ed58c027921E14D86380eA2646E3a1B5C55A8b
6+
NEXT_PUBLIC_OPENSEA_COLLECTION_LINK=https://opensea.io/collection/devs-for-revolution
7+
NEXT_PUBLIC_ETHER_SCAN_LINK_PREFIX=https://etherscan.io/address
8+
NEXT_PUBLIC_ETHERSCAN_TX_URL=https://etherscan.io/tx/
9+
NEXT_PUBLIC_INFURA_ID=

frontend/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ 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`.
88+
`INFURA_ID` can be easily obtained by register at <https://infura.io/>, then create a new Ethereum project for free.
8789

8890
## Contributing
8991

frontend/public/locales/en/common.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"tokenIDPlaceholder": "Enter Token ID",
2929
"mintTokenText" : "Mint your Token",
3030
"connectWalletText": "Connect Wallet",
31+
"ethereumDevNetworkPrompt": "Please Connect to the Ethereum Rinkeby Testnet",
3132
"ethereumNetworkPrompt": "Please Connect to the Ethereum Mainnet",
3233
"availableTokensText": "View the available Token IDs",
3334
"remainingTokensText": "{{remainingTokens}} tokens left / {{uniqueAddressCount}} devs joined",
@@ -44,5 +45,6 @@
4445
"here": "here",
4546
"errorMinting": "Unable to Mint NFT",
4647
"disconnectWallet": "Disconnect Wallet",
47-
"etherscanMessage": "View your TX on Etherscan"
48+
"etherscanMessage": "View your TX on Etherscan",
49+
"testnet": "Testnet"
4850
}

frontend/src/components/DirectMint/DirectMint.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ import Web3Modal from 'web3modal';
2727
import { useTranslation } from 'next-i18next';
2828
import {
2929
DEVELOPER_DAO_CONTRACT,
30+
DEVELOPER_DAO_CONTRACT_NETWORK,
3031
ERROR_CODE_TX_REJECTED_BY_USER,
31-
MAINNET_NETWORK_ID,
32+
NETWORK_ID,
3233
ETHERSCAN_TX_URL,
34+
INFURA_ID,
3335
} from '../../utils/DeveloperDaoConstants';
3436

3537
import MINT_CONTRACT from '../../artifacts/ddao.json';
@@ -45,7 +47,7 @@ const providerOptions = {
4547
walletconnect: {
4648
package: WalletConnectProvider,
4749
options: {
48-
infuraId: process.env.NEXT_PUBLIC_INFURA_ID,
50+
infuraId: INFURA_ID,
4951
},
5052
},
5153
};
@@ -65,7 +67,7 @@ const DirectMint = ({ developerId }: DirectMintProps) => {
6567

6668
useEffect(() => {
6769
const web3Modal = new Web3Modal({
68-
network: 'mainnet',
70+
network: DEVELOPER_DAO_CONTRACT_NETWORK,
6971
cacheProvider: false,
7072
providerOptions,
7173
});
@@ -91,7 +93,7 @@ const DirectMint = ({ developerId }: DirectMintProps) => {
9193
};
9294

9395
const _checkNetwork = (chainId: number) => {
94-
if (chainId === MAINNET_NETWORK_ID) {
96+
if (chainId === Number(NETWORK_ID)) {
9597
return true;
9698
}
9799
setNetworkError(true);
@@ -267,8 +269,15 @@ const DirectMint = ({ developerId }: DirectMintProps) => {
267269
</ModalContent>
268270
</Modal>
269271
)}
270-
271-
{networkError && <Text color="red">{t('ethereumNetworkPrompt')}</Text>}
272+
{networkError && (
273+
<Text color="red">
274+
{t(
275+
DEVELOPER_DAO_CONTRACT_NETWORK === 'rinkeby'
276+
? 'ethereumDevNetworkPrompt'
277+
: 'ethereumNetworkPrompt',
278+
)}
279+
</Text>
280+
)}
272281
</>
273282
);
274283
};

frontend/src/components/DirectMint/DirectMintBox.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import DirectMint from './DirectMint';
33
import Logo from '../../components/Logo';
44
import {
5+
Badge,
56
Box,
67
Container,
78
Flex,
@@ -11,7 +12,10 @@ import {
1112
Link,
1213
} from '@chakra-ui/react';
1314
import { useTranslation } from 'next-i18next';
14-
import { TOKEN_FINDER_URL } from '../../utils/DeveloperDaoConstants';
15+
import {
16+
DEVELOPER_DAO_CONTRACT_NETWORK,
17+
TOKEN_FINDER_URL,
18+
} from '../../utils/DeveloperDaoConstants';
1519
import { useDevNFTSupply } from '../../hooks/useDevNFTSupply';
1620

1721
// Layout for the Direct Mint Box
@@ -32,6 +36,9 @@ const DirectMintBox = () => {
3236
>
3337
<Stack spacing={6} align="center">
3438
<Logo w={52} h={52} />
39+
{DEVELOPER_DAO_CONTRACT_NETWORK === 'rinkeby' && (
40+
<Badge colorScheme="orange">{t('testnet')}</Badge>
41+
)}
3542
<Heading fontSize={{ base: '1.25rem', sm: '2rem' }}>
3643
{t('mintPageHeader')}
3744
</Heading>

frontend/src/components/Footer/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import {
99
IconGitHub,
1010
IconDiscourse,
1111
} from '../Icons';
12+
import {
13+
DEVELOPER_DAO_CONTRACT,
14+
ETHER_SCAN_LINK_PREFIX,
15+
OPENSEA_COLLECTION_LINK,
16+
} from '../../utils/DeveloperDaoConstants';
1217

1318
function Footer() {
1419
const { t } = useTranslation();
@@ -24,7 +29,7 @@ function Footer() {
2429
<a
2530
title="OpenSea"
2631
className="mx-2 block"
27-
href="https://opensea.io/collection/devs-for-revolution"
32+
href={OPENSEA_COLLECTION_LINK}
2833
target="_blank"
2934
rel="noreferrer"
3035
>
@@ -35,7 +40,7 @@ function Footer() {
3540
<a
3641
title="Etherscan"
3742
className="mx-2 block"
38-
href="https://etherscan.io/address/0x25ed58c027921e14d86380ea2646e3a1b5c55a8b"
43+
href={`${ETHER_SCAN_LINK_PREFIX}/${DEVELOPER_DAO_CONTRACT}`}
3944
target="_blank"
4045
rel="noreferrer"
4146
>

frontend/src/hooks/useDevNFTSupply.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import {
66
InfuraProvider,
77
} from '@ethersproject/providers';
88

9-
import { DEVELOPER_DAO_CONTRACT } from '../utils/DeveloperDaoConstants';
9+
import {
10+
DEVELOPER_DAO_CONTRACT,
11+
DEVELOPER_DAO_CONTRACT_NETWORK_PROVIDER,
12+
} from '../utils/DeveloperDaoConstants';
1013
import { Ddao__factory } from '../../types/ethers-contracts/factories/Ddao__factory';
1114

1215
// TokenIDs start at 1. Tokens 1-7777 (supply of 7777) are open to mint by anyone. 7778-8000 are locked to mint by contract owner
@@ -24,8 +27,16 @@ export function useDevNFTSupply() {
2427
const contract = Ddao__factory.connect(
2528
DEVELOPER_DAO_CONTRACT,
2629
new FallbackProvider([
27-
{ provider: new InfuraProvider() },
28-
{ provider: new AlchemyProvider() },
30+
{
31+
provider: new InfuraProvider(
32+
DEVELOPER_DAO_CONTRACT_NETWORK_PROVIDER,
33+
),
34+
},
35+
{
36+
provider: new AlchemyProvider(
37+
DEVELOPER_DAO_CONTRACT_NETWORK_PROVIDER,
38+
),
39+
},
2940
]),
3041
);
3142

frontend/src/pages/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import { useTranslation } from 'next-i18next';
77
import {
88
DEVELOPER_DAO_CONTRACT,
99
DEVELOPER_DAO_CONTRACT_ABI,
10+
DEVELOPER_DAO_CONTRACT_NETWORK,
11+
DEVELOPER_DAO_CONTRACT_NETWORK_PROVIDER,
1012
ETHER_SCAN_LINK_PREFIX,
1113
SITE_URL,
1214
} from '../utils/DeveloperDaoConstants';
1315
import {
1416
chakra,
17+
Badge,
1518
Input,
1619
Text,
1720
Button,
@@ -33,7 +36,7 @@ function App() {
3336

3437
const ethersConfig = {
3538
ethers: { Contract },
36-
provider: getDefaultProvider('homestead'),
39+
provider: getDefaultProvider(DEVELOPER_DAO_CONTRACT_NETWORK_PROVIDER),
3740
};
3841

3942
const updateDeveloperId = useCallback(
@@ -60,6 +63,9 @@ function App() {
6063
<VStack mx="auto" px={4} spacing={5} w="full" maxW="lg">
6164
<Logo w={32} h={32} />
6265
<VStack w="full">
66+
{DEVELOPER_DAO_CONTRACT_NETWORK === 'rinkeby' && (
67+
<Badge colorScheme="orange">{t('testnet')}</Badge>
68+
)}
6369
<Text fontSize="xl">{t('searchId')}</Text>
6470
<Input
6571
aria-label="Search by developer ID"
@@ -148,7 +154,7 @@ function Nft({ developerId }: { developerId: string }) {
148154
new ethers.Contract(
149155
DEVELOPER_DAO_CONTRACT,
150156
DEVELOPER_DAO_CONTRACT_ABI,
151-
getDefaultProvider('homestead'),
157+
getDefaultProvider(DEVELOPER_DAO_CONTRACT_NETWORK_PROVIDER),
152158
)
153159
}
154160
></OtherDevsByOwnerContainer>

frontend/src/utils/DeveloperDaoConstants.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1-
export const DEVELOPER_DAO_CONTRACT =
2-
'0x25ed58c027921E14D86380eA2646E3a1B5C55A8b';
1+
export const DEVELOPER_DAO_CONTRACT = process.env
2+
.NEXT_PUBLIC_DEVELOPER_DAO_CONTRACT as string;
3+
export const DEVELOPER_DAO_CONTRACT_NETWORK = process.env
4+
.NEXT_PUBLIC_DEVELOPER_DAO_CONTRACT_NETWORK as string;
5+
export const DEVELOPER_DAO_CONTRACT_NETWORK_PROVIDER = process.env
6+
.NEXT_PUBLIC_DEVELOPER_DAO_CONTRACT_NETWORK as string;
7+
export const NETWORK_ID = process.env.NEXT_PUBLIC_NETWORK_ID;
38
export const DEVELOPER_DAO_WEBSITE = 'https://www.developerdao.com';
4-
export const OPENSEA_DIRECT_LINK_PREFIX = `https://opensea.io/assets/${DEVELOPER_DAO_CONTRACT}`;
5-
export const ETHER_SCAN_LINK_PREFIX = 'https://etherscan.io/address';
9+
export const OPENSEA_DIRECT_LINK_PREFIX = process.env
10+
.NEXT_PUBLIC_OPENSEA_DIRECT_LINK_PREFIX as string;
11+
export const OPENSEA_COLLECTION_LINK = process.env
12+
.NEXT_PUBLIC_OPENSEA_COLLECTION_LINK as string;
13+
export const ETHER_SCAN_LINK_PREFIX = process.env
14+
.NEXT_PUBLIC_ETHER_SCAN_LINK_PREFIX as string;
15+
616
export const SITE_URL = 'https://developerdao.com';
717
export const ERROR_CODE_TX_REJECTED_BY_USER = 4001;
8-
export const MAINNET_NETWORK_ID = 1;
18+
919
export const TOKEN_FINDER_URL = 'https://developerdao.vercel.app/';
10-
export const ETHERSCAN_TX_URL = 'https://etherscan.io/tx/';
20+
export const ETHERSCAN_TX_URL = process.env
21+
.NEXT_PUBLIC_ETHERSCAN_TX_URL as string;
22+
23+
export const INFURA_ID = process.env.NEXT_PUBLIC_INFURA_ID as string;
1124

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

0 commit comments

Comments
 (0)