Fix dapp deployment (#36)

This commit is contained in:
Felicio Mununga 2023-05-12 11:50:59 +02:00 committed by GitHub
parent 50a79d0ca9
commit 91daa7f782
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 14 deletions

View File

@ -13,6 +13,6 @@ Note: Use node `v18.15.0`
1. Install dependencies: Run `yarn` to install the necessary packages and dependencies.
2. Run local hardhat node: Navigate to the `packages/contract` directory and run `yarn dev`.
3. Deploy contracts: Navigate to the `packages/contracts` directory and run `yarn dev:deploy` to deploy the contracts needed for the project.
4. Start the app: Run `ENV=localhost VOTING_CONTRACT=hex_addr DIRECTORY_CONTRACT=hex_addr MULTICALL_CONTRACT=hex_addr TOKEN_CONTRACT=hex_addr yarn dev` to start the application. Make sure to replace `hex_addr` with the actual addresses of the contracts you deployed in step 3.
4. Start the app: Run `VOTING_CONTRACT=hex_addr DIRECTORY_CONTRACT=hex_addr MULTICALL_CONTRACT=hex_addr TOKEN_CONTRACT=hex_addr yarn dev` to start the application. Make sure to replace `hex_addr` with the actual addresses of the contracts you deployed in step 3.
Once the app is run, connect to the wallet. NOTE: in 'production' mode it has to be Status wallet.

View File

@ -8,6 +8,5 @@
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

View File

@ -7,8 +7,8 @@
"license": "MIT",
"type": "module",
"scripts": {
"dev": "NODE_OPTIONS=--openssl-legacy-provider webpack serve --mode=development --env ENV=localhost --https",
"build": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode=production --env ENV=production",
"dev": "NODE_OPTIONS=--openssl-legacy-provider webpack serve --mode=development --https",
"build": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode=production",
"test": "mocha",
"lint": "yarn lint:prettier --check && yarn lint:eslint",
"lint:fix": "yarn lint:prettier --write && yarn lint:eslint --fix",

View File

@ -13,8 +13,14 @@ export interface Config {
statusWalletRequired: boolean
}
/**
* @see https://vercel.com/docs/concepts/projects/environment-variables#environments for environment descriptions
*/
const configs: Record<typeof process.env.ENV, Config> = {
localhost: {
/**
* Localhost/Development.
*/
development: {
statusWalletRequired: false,
wakuConfig: {
environment: 'test',
@ -38,12 +44,17 @@ const configs: Record<typeof process.env.ENV, Config> = {
},
},
},
development: {
/**
* Preview/Stage.
*
* All preview deployments (from pull requests) will share voting history.
*/
preview: {
statusWalletRequired: false,
wakuConfig: {
environment: 'production',
wakuTopic: `/communitiesCuration/development/${version}/directory/proto/`,
wakuFeatureTopic: `/communitiesCuration/development/${version}/featured/proto/`,
environment: 'test',
wakuTopic: `/communitiesCuration/preview/${version}/directory/proto/`,
wakuFeatureTopic: `/communitiesCuration/preview/${version}/featured/proto/`,
},
daapConfig: {
readOnlyChainId: ChainId.OptimismGoerli,
@ -54,6 +65,9 @@ const configs: Record<typeof process.env.ENV, Config> = {
},
},
},
/**
* Production.
*/
production: {
statusWalletRequired: true,
wakuConfig: {

View File

@ -1,5 +1,6 @@
import { ChainId } from '@usedapp/core'
// todo?: move to config.ts
export const contracts = {
[ChainId.Optimism]: {
// TO BE PROVIDED

View File

@ -1,5 +1,5 @@
declare namespace NodeJS {
export interface ProcessEnv {
ENV: 'localhost' | 'development' | 'production'
ENV: 'development' | 'preview' | 'production'
}
}

View File

@ -5,10 +5,11 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const webpack = require('webpack')
module.exports = (env) => {
let environment = 'development'
if (env.ENV) {
environment = env.ENV
module.exports = () => {
const environment = process.env.ENV ?? 'development'
if (!['development', 'preview', 'production'].includes(environment)) {
throw new Error('Unsupported environment')
}
return {

20
vercel.json Normal file
View File

@ -0,0 +1,20 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"git": {
"deploymentEnabled": {
"main": false,
"master": false
}
},
"github": {
"silent": false,
"autoJobCancelation": true
},
"ignoreCommand": "git diff --quiet HEAD^ HEAD vercel.json ./package.json ./packages/contracts/package.json ./packages/contracts/contracts ./packages/DApp",
"rewrites": [
{
"source": "/(.*)",
"destination": "/index.html"
}
]
}