on master help sign in
dx: add Ropsten mode for local development
5cadc4btomholford
package.json+1
@@ -107,6 +107,7 @@
107 "pilot-invites": "WITH_TEST_STATE=INVITES npm run pilot",
107 "pilot-invites": "WITH_TEST_STATE=INVITES npm run pilot",
108 "pilot-release": "WITH_TEST_STATE=STAR_RELEASE npm run pilot",
108 "pilot-release": "WITH_TEST_STATE=STAR_RELEASE npm run pilot",
109 "pilot-residents": "WITH_TEST_STATE=RESIDENTS npm run pilot",
109 "pilot-residents": "WITH_TEST_STATE=RESIDENTS npm run pilot",
110+ "pilot-ropsten": "REACT_APP_ROPSTEN=true npm run pilot",
110 "pilot:cleanup": "pkill -f ganache-cli",
111 "pilot:cleanup": "pkill -f ganache-cli",
111 "lint:check": "eslint 'src/**/*.js'",
112 "lint:check": "eslint 'src/**/*.js'",
112 "lint:fix": "eslint --fix 'src/**/*.js'",
113 "lint:fix": "eslint --fix 'src/**/*.js'",
src/Bridge.js+4−2
@@ -11,7 +11,7 @@ import { ROUTE_NAMES } from 'lib/routeNames';
11import { ROUTES } from 'lib/router';
11import { ROUTES } from 'lib/router';
12import { NETWORK_TYPES } from 'lib/network';
12import { NETWORK_TYPES } from 'lib/network';
13import { walletFromMnemonic } from 'lib/wallet';
13import { walletFromMnemonic } from 'lib/wallet';
14−import { isDevelopment } from 'lib/flags';
14+import { isDevelopment, isRopsten } from 'lib/flags';
15import useImpliedTicket from 'lib/useImpliedTicket';
15import useImpliedTicket from 'lib/useImpliedTicket';
16import useHasDisclaimed from 'lib/useHasDisclaimed';
16import useHasDisclaimed from 'lib/useHasDisclaimed';
17
17
@@ -20,7 +20,9 @@ import WithErrorBoundary from 'components/WithErrorBoundary';
20import GlobalErrorBoundary from 'components/GlobalErrorBoundary';
20import GlobalErrorBoundary from 'components/GlobalErrorBoundary';
21
21
22const INITIAL_NETWORK_TYPE = isDevelopment
22const INITIAL_NETWORK_TYPE = isDevelopment
23+ ? isRopsten
24+ ? NETWORK_TYPES.ROPSTEN
23− ? NETWORK_TYPES.LOCAL
25+ : NETWORK_TYPES.LOCAL
24 : NETWORK_TYPES.MAINNET;
26 : NETWORK_TYPES.MAINNET;
25
27
26// NB(shrugs): modify these variables to change the default local state.
28// NB(shrugs): modify these variables to change the default local state.
src/lib/flags.js+1
@@ -1,2 +1,3 @@
1// are we running bridge in a development build
1// are we running bridge in a development build
2export const isDevelopment = process.env.NODE_ENV === 'development';
2export 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 @@
2// did not succeed", you might need to visit localhost:3001 or whatever
2// did not succeed", you might need to visit localhost:3001 or whatever
3// explicitly and tell your browser that's safe to access.
3// explicitly and tell your browser that's safe to access.
4// https://stackoverflow.com/a/53011185/1334324
4// https://stackoverflow.com/a/53011185/1334324
5+import { isRopsten } from './flags';
6+
7+const port = isRopsten ? '3012' : '3002';
5−const baseUrl = 'https://onboarding-emails.urbit.org:3002';
8+const baseUrl = `https://onboarding-emails.urbit.org:${port}`;
6
9
7function sendRequest(where, what) {
10function sendRequest(where, what) {
8 return new Promise((resolve, reject) => {
11 return new Promise((resolve, reject) => {
src/lib/tank.js+3−1
@@ -4,6 +4,7 @@ import retry from 'async-retry';
4import { toBN } from 'web3-utils';
4import { toBN } from 'web3-utils';
5import { RETRY_OPTIONS, waitForTransactionConfirm } from './txn';
5import { RETRY_OPTIONS, waitForTransactionConfirm } from './txn';
6import { WALLET_TYPES } from 'lib/constants';
6import { WALLET_TYPES } from 'lib/constants';
7+import { isRopsten } from './flags';
7
8
8const TANK_ADDRESS = '0x40f0A6db85f8D7A54fF3eA915b040dE8Cd4A0Eb5';
9const TANK_ADDRESS = '0x40f0A6db85f8D7A54fF3eA915b040dE8Cd4A0Eb5';
9
10
@@ -11,7 +12,8 @@ const TANK_ADDRESS = '0x40f0A6db85f8D7A54fF3eA915b040dE8Cd4A0Eb5';
11// did not succeed", you might need to visit localhost:3001 or whatever
12// did not succeed", you might need to visit localhost:3001 or whatever
12// explicitly and tell your browser that's safe to access.
13// explicitly and tell your browser that's safe to access.
13// https://stackoverflow.com/a/53011185/1334324
14// https://stackoverflow.com/a/53011185/1334324
15+const port = isRopsten ? '3011' : '3001';
14−const baseUrl = 'https://gas-tank.urbit.org:3001';
16+const baseUrl = `https://gas-tank.urbit.org:${port}`;
15
17
16function sendRequest(where, what) {
18function sendRequest(where, what) {
17 return new Promise((resolve, reject) => {
19 return new Promise((resolve, reject) => {