on master help sign in
api: add Ropsten Roller support to useRoller
6c2f22ftomholford
src/lib/constants.ts+8
@@ -97,6 +97,13 @@ const NONCUSTODIAL_WALLETS = new Set([
97 WALLET_TYPES.WALLET_CONNECT,
97 WALLET_TYPES.WALLET_CONNECT,
98]);
98]);
99
99
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+
100export {
107export {
101 CHECK_BLOCK_EVERY_MS,
108 CHECK_BLOCK_EVERY_MS,
102 DEFAULT_GAS_PRICE_GWEI,
109 DEFAULT_GAS_PRICE_GWEI,
@@ -122,4 +129,5 @@ export {
122 WALLET_TYPES,
129 WALLET_TYPES,
123 ZOD,
130 ZOD,
124 PROGRESS_ANIMATION_DELAY_MS,
131 PROGRESS_ANIMATION_DELAY_MS,
132+ ROLLER_HOSTS,
125};
133};
src/lib/useRoller.ts+9−4
@@ -1,16 +1,21 @@
1import { useCallback, useEffect, useMemo, useState } from 'react';
1import { useCallback, useEffect, useMemo, useState } from 'react';
2import { Config, RollerRPCAPI, Options } from '@urbit/roller-api';
2import { Config, RollerRPCAPI, Options } from '@urbit/roller-api';
3−import { isDevelopment } from './flags';
3+import { isDevelopment, isRopsten } from './flags';
4+import { ROLLER_HOSTS } from './constants';
4
5
5export default function useRoller() {
6export default function useRoller() {
6 const [config, setConfig] = useState<Config | null>(null);
7 const [config, setConfig] = useState<Config | null>(null);
7
8
8 const options: Options = useMemo(() => {
9 const options: Options = useMemo(() => {
9− const type = isDevelopment ? 'http' : 'https';
10+ const type = isRopsten || !isDevelopment ? 'https' : 'http';
10− // TODO: What is the prod host?
11+ const host = isRopsten
11− const host = isDevelopment ? 'localhost' : 'bridge.urbit.org';
12+ ? ROLLER_HOSTS.ROPSTEN
13+ : isDevelopment
14+ ? ROLLER_HOSTS.LOCAL
15+ : ROLLER_HOSTS.MAINNET;
12 const port = 80;
16 const port = 80;
13 const path = '/v1/roller';
17 const path = '/v1/roller';
18+
14 return {
19 return {
15 transport: {
20 transport: {
16 type,
21 type,