on master help sign in
api: add Ropsten Roller support to useRoller
commit6c2f22fd6542cd2df0d83a94003de003f1737b91 authortomholford <tomholford@users.noreply.github.com> dateTue 24 Aug 2021, 11:53 (5 years ago) parentcad6569
2 files changed+17−4
src/lib/constants.ts+8 src/lib/useRoller.ts+9−4
src/lib/constants.ts+8
@@ -97,6 +97,13 @@ const NONCUSTODIAL_WALLETS = new Set([
9797 WALLET_TYPES.WALLET_CONNECT,
9898]);
9999
100+// TODO: update Ropsten to use URI, ensure correct Prod host
101+const ROLLER_HOSTS = {
102+ LOCAL: 'localhost',
103+ ROPSTEN: '34.105.35.120',
104+ MAINNET: 'bridge.urbit.org',
105+};
106+
100107export {
101108 CHECK_BLOCK_EVERY_MS,
102109 DEFAULT_GAS_PRICE_GWEI,
@@ -122,4 +129,5 @@ export {
122129 WALLET_TYPES,
123130 ZOD,
124131 PROGRESS_ANIMATION_DELAY_MS,
132+ ROLLER_HOSTS,
125133};
src/lib/useRoller.ts+9−4
@@ -1,16 +1,21 @@
11import { useCallback, useEffect, useMemo, useState } from 'react';
22import { Config, RollerRPCAPI, Options } from '@urbit/roller-api';
3−import { isDevelopment } from './flags';
3+import { isDevelopment, isRopsten } from './flags';
4+import { ROLLER_HOSTS } from './constants';
45
56export default function useRoller() {
67 const [config, setConfig] = useState<Config | null>(null);
78
89 const options: Options = useMemo(() => {
9− const type = isDevelopment ? 'http' : 'https';
10− // TODO: What is the prod host?
11− const host = isDevelopment ? 'localhost' : 'bridge.urbit.org';
10+ const type = isRopsten || !isDevelopment ? 'https' : 'http';
11+ const host = isRopsten
12+ ? ROLLER_HOSTS.ROPSTEN
13+ : isDevelopment
14+ ? ROLLER_HOSTS.LOCAL
15+ : ROLLER_HOSTS.MAINNET;
1216 const port = 80;
1317 const path = '/v1/roller';
18+
1419 return {
1520 transport: {
1621 type,