on master help sign in
dx: add Ropsten mode for local development

`npm run pilot-ropsten` will set `REACT_APP_ROPSTEN` to `true`. This value is consumed in several places to enable Ropsten test net.

commit5cadc4b6e21d4acfa393983a798d679b6535aea4 authortomholford <tomholford@users.noreply.github.com> dateWed 14 Jul 2021, 11:36 (5 years ago) parent55a9664
5 files changed+13−4
package.json+1 src/Bridge.js+4−2 src/lib/flags.js+1 src/lib/inviteMail.js+4−1 src/lib/tank.js+3−1
package.json+1
@@ -107,6 +107,7 @@
107107 "pilot-invites": "WITH_TEST_STATE=INVITES npm run pilot",
108108 "pilot-release": "WITH_TEST_STATE=STAR_RELEASE npm run pilot",
109109 "pilot-residents": "WITH_TEST_STATE=RESIDENTS npm run pilot",
110+ "pilot-ropsten": "REACT_APP_ROPSTEN=true npm run pilot",
110111 "pilot:cleanup": "pkill -f ganache-cli",
111112 "lint:check": "eslint 'src/**/*.js'",
112113 "lint:fix": "eslint --fix 'src/**/*.js'",
src/Bridge.js+4−2
@@ -11,7 +11,7 @@ import { ROUTE_NAMES } from 'lib/routeNames';
1111import { ROUTES } from 'lib/router';
1212import { NETWORK_TYPES } from 'lib/network';
1313import { walletFromMnemonic } from 'lib/wallet';
14−import { isDevelopment } from 'lib/flags';
14+import { isDevelopment, isRopsten } from 'lib/flags';
1515import useImpliedTicket from 'lib/useImpliedTicket';
1616import useHasDisclaimed from 'lib/useHasDisclaimed';
1717
@@ -20,7 +20,9 @@ import WithErrorBoundary from 'components/WithErrorBoundary';
2020import GlobalErrorBoundary from 'components/GlobalErrorBoundary';
2121
2222const INITIAL_NETWORK_TYPE = isDevelopment
23− ? NETWORK_TYPES.LOCAL
23+ ? isRopsten
24+ ? NETWORK_TYPES.ROPSTEN
25+ : NETWORK_TYPES.LOCAL
2426 : NETWORK_TYPES.MAINNET;
2527
2628// NB(shrugs): modify these variables to change the default local state.
src/lib/flags.js+1
@@ -1,2 +1,3 @@
11// are we running bridge in a development build
22export const isDevelopment = process.env.NODE_ENV === 'development';
3+export const isRopsten = process.env.REACT_APP_ROPSTEN === 'true';
src/lib/inviteMail.js+4−1
@@ -2,7 +2,10 @@
22// did not succeed", you might need to visit localhost:3001 or whatever
33// explicitly and tell your browser that's safe to access.
44// https://stackoverflow.com/a/53011185/1334324
5−const baseUrl = 'https://onboarding-emails.urbit.org:3002';
5+import { isRopsten } from './flags';
6+
7+const port = isRopsten ? '3012' : '3002';
8+const baseUrl = `https://onboarding-emails.urbit.org:${port}`;
69
710function sendRequest(where, what) {
811 return new Promise((resolve, reject) => {
src/lib/tank.js+3−1
@@ -4,6 +4,7 @@ import retry from 'async-retry';
44import { toBN } from 'web3-utils';
55import { RETRY_OPTIONS, waitForTransactionConfirm } from './txn';
66import { WALLET_TYPES } from 'lib/constants';
7+import { isRopsten } from './flags';
78
89const TANK_ADDRESS = '0x40f0A6db85f8D7A54fF3eA915b040dE8Cd4A0Eb5';
910
@@ -11,7 +12,8 @@ const TANK_ADDRESS = '0x40f0A6db85f8D7A54fF3eA915b040dE8Cd4A0Eb5';
1112// did not succeed", you might need to visit localhost:3001 or whatever
1213// explicitly and tell your browser that's safe to access.
1314// https://stackoverflow.com/a/53011185/1334324
14−const baseUrl = 'https://gas-tank.urbit.org:3001';
15+const port = isRopsten ? '3011' : '3001';
16+const baseUrl = `https://gas-tank.urbit.org:${port}`;
1517
1618function sendRequest(where, what) {
1719 return new Promise((resolve, reject) => {