From 9e7b3e31a104ab10a649dabcfe4b06ed58587d5e Mon Sep 17 00:00:00 2001 From: Mikael Lindlof Date: Sun, 6 Dec 2020 01:26:10 +0000 Subject: [PATCH] Add prod building with no local wallet --- script/react.sh | 2 +- web/.env.development | 2 + web/.env.production | 8 ++ web/{.env => .env.testnet} | 1 + web/README.md | 11 ++ web/docker-build.yaml | 14 -- ...r-compose.yaml => docker-development.yaml} | 0 web/docker-production.yaml | 8 ++ web/docker-testnet.yaml | 8 ++ web/package-lock.json | 129 ++++++++++++++++++ web/package.json | 2 + web/src/config.ts | 2 + web/src/wallet/SelectWalletModal.tsx | 8 +- 13 files changed, 177 insertions(+), 18 deletions(-) create mode 100644 web/.env.development create mode 100644 web/.env.production rename web/{.env => .env.testnet} (90%) create mode 100644 web/README.md delete mode 100644 web/docker-build.yaml rename web/{docker-compose.yaml => docker-development.yaml} (100%) create mode 100644 web/docker-production.yaml create mode 100644 web/docker-testnet.yaml diff --git a/script/react.sh b/script/react.sh index 5d595f8..c0bf6f3 100755 --- a/script/react.sh +++ b/script/react.sh @@ -21,4 +21,4 @@ export REACT_APP_CHAIN_NAME="Secret localhost" export REACT_APP_LCD_URL=http://localhost:1338 export REACT_APP_RPC_URL=http://localhost:26657 export REACT_APP_CONTRACT="$CONTRACT" -docker-compose up --build +docker-compose up -f docker-development.yaml --build diff --git a/web/.env.development b/web/.env.development new file mode 100644 index 0000000..cc2b65f --- /dev/null +++ b/web/.env.development @@ -0,0 +1,2 @@ +REACT_APP_FAUCET=https://faucet.secrettestnet.io/ +REACT_APP_ENABLE_LOCAL_WALLET=true diff --git a/web/.env.production b/web/.env.production new file mode 100644 index 0000000..32ce851 --- /dev/null +++ b/web/.env.production @@ -0,0 +1,8 @@ +REACT_APP_CHAIN_ID=secret-2 +REACT_APP_SUGGEST_CHAIN=false +REACT_APP_CHAIN_NAME=Secret Network +REACT_APP_LCD_URL=https://secretapi.io +REACT_APP_RPC_URL=http://secretapi.io:26657 +REACT_APP_CONTRACT=secret17c7j5xgylhty8jq5lqnuaqd68ndazs022mqcuu +REACT_APP_FAUCET= +REACT_APP_ENABLE_LOCAL_WALLET=false diff --git a/web/.env b/web/.env.testnet similarity index 90% rename from web/.env rename to web/.env.testnet index 32e103c..f3500c9 100644 --- a/web/.env +++ b/web/.env.testnet @@ -5,3 +5,4 @@ REACT_APP_LCD_URL=https://bootstrap.secrettestnet.io REACT_APP_RPC_URL=http://bootstrap.secrettestnet.io:26657 REACT_APP_CONTRACT=secret17c7j5xgylhty8jq5lqnuaqd68ndazs022mqcuu REACT_APP_FAUCET=https://faucet.secrettestnet.io/ +REACT_APP_ENABLE_LOCAL_WALLET=true diff --git a/web/README.md b/web/README.md new file mode 100644 index 0000000..0432c82 --- /dev/null +++ b/web/README.md @@ -0,0 +1,11 @@ +# Secret Rock Paper Scissors Frontend + +Rock paper scissors game secret frontend for Secret Network. + +## Testnet build + +docker-compose -f docker-testnet.yaml up --build + +## Production build + +docker-compose -f docker-production.yaml up --build diff --git a/web/docker-build.yaml b/web/docker-build.yaml deleted file mode 100644 index 968295f..0000000 --- a/web/docker-build.yaml +++ /dev/null @@ -1,14 +0,0 @@ -version: '3.8' -services: - web: - build: - context: . - command: ['npm', 'run', 'build'] - environment: - - 'REACT_APP_CHAIN_ID=${REACT_APP_CHAIN_ID}' - - 'REACT_APP_CHAIN_NAME=${REACT_APP_CHAIN_NAME}' - - 'REACT_APP_LCD_URL=${REACT_APP_LCD_URL}' - - 'REACT_APP_RPC_URL=${REACT_APP_RPC_URL}' - - 'REACT_APP_CONTRACT=${REACT_APP_CONTRACT}' - volumes: - - './build/:/app/build' diff --git a/web/docker-compose.yaml b/web/docker-development.yaml similarity index 100% rename from web/docker-compose.yaml rename to web/docker-development.yaml diff --git a/web/docker-production.yaml b/web/docker-production.yaml new file mode 100644 index 0000000..ed62123 --- /dev/null +++ b/web/docker-production.yaml @@ -0,0 +1,8 @@ +version: '3.8' +services: + web: + build: + context: . + command: ['npm', 'run', 'build:production'] + volumes: + - './build/:/app/build' diff --git a/web/docker-testnet.yaml b/web/docker-testnet.yaml new file mode 100644 index 0000000..a62531c --- /dev/null +++ b/web/docker-testnet.yaml @@ -0,0 +1,8 @@ +version: '3.8' +services: + web: + build: + context: . + command: ['npm', 'run', 'build:testnet'] + volumes: + - './build/:/app/build' diff --git a/web/package-lock.json b/web/package-lock.json index 7c70e98..db93d13 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -23,6 +23,7 @@ "@types/node": "^14.14.0", "@types/react": "^16.9.53", "@types/react-dom": "^16.9.8", + "env-cmd": "^10.1.0", "prettier": "^2.1.2" } }, @@ -6539,6 +6540,81 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/env-cmd": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/env-cmd/-/env-cmd-10.1.0.tgz", + "integrity": "sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA==", + "dev": true, + "dependencies": { + "commander": "^4.0.0", + "cross-spawn": "^7.0.0" + }, + "bin": { + "env-cmd": "bin/env-cmd.js" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/env-cmd/node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/env-cmd/node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/env-cmd/node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/env-cmd/node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/env-cmd/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/errno": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", @@ -25661,6 +25737,59 @@ "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==" }, + "env-cmd": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/env-cmd/-/env-cmd-10.1.0.tgz", + "integrity": "sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA==", + "dev": true, + "requires": { + "commander": "^4.0.0", + "cross-spawn": "^7.0.0" + }, + "dependencies": { + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, "errno": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", diff --git a/web/package.json b/web/package.json index daf4460..d6ed2a5 100644 --- a/web/package.json +++ b/web/package.json @@ -13,6 +13,7 @@ }, "scripts": { "start": "react-scripts start", + "build:testnet": "env-cmd -f .env.testnet react-scripts build", "build": "react-scripts build", "test": "react-scripts test" }, @@ -39,6 +40,7 @@ "@types/node": "^14.14.0", "@types/react": "^16.9.53", "@types/react-dom": "^16.9.8", + "env-cmd": "^10.1.0", "prettier": "^2.1.2" } } diff --git a/web/src/config.ts b/web/src/config.ts index cf0ed34..c9db549 100644 --- a/web/src/config.ts +++ b/web/src/config.ts @@ -6,6 +6,7 @@ interface Config { readonly rpcUrl: string; readonly contract: string; readonly faucetUrl: string | undefined; + readonly enableLocalWallet: boolean; } const envConfig = (): Config => { @@ -17,6 +18,7 @@ const envConfig = (): Config => { rpcUrl: requiredEnv('REACT_APP_RPC_URL'), contract: requiredEnv('REACT_APP_CONTRACT'), faucetUrl: process.env.REACT_APP_FAUCET, + enableLocalWallet: requiredBoolean('REACT_APP_ENABLE_LOCAL_WALLET'), }; }; diff --git a/web/src/wallet/SelectWalletModal.tsx b/web/src/wallet/SelectWalletModal.tsx index d5eb20e..5bc54db 100644 --- a/web/src/wallet/SelectWalletModal.tsx +++ b/web/src/wallet/SelectWalletModal.tsx @@ -55,9 +55,11 @@ export default (props: Props) => { > Use Keplr - + {config.enableLocalWallet && ( + + )} )} {walletType && (