Skip to content

Commit 7bacc8d

Browse files
rohit-nairjamaljsr
authored andcommitted
Standalone LiT client development
This implements a new script (`yarn develop`) that lets developers to do LiT frontend client development without having to setup an `lnd` backend. This script uses the mock responses configured in `sampleData` to resolve API requests. Limitations: * The implementation depends on `sampleData` to be up-to-date as the APIs evolve. * Currently it only supports `GET` requests. Alternatives considered: * Use `REACT_APP_DEV_HOST` to point to a `testnet` public server so as to avoid configuring and running `lnd`. * Set up a webpack devserver to proxy responses to a node server running locally that in-turn reads mock responses configured as `<endpoint>.json` files, ex `GetInfo.json`, and sends it as response.
1 parent e8448a8 commit 7bacc8d

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"private": true,
77
"scripts": {
88
"start": "BROWSER=none react-scripts start",
9+
"develop": "REACT_APP_USE_SAMPLE_DATA=true yarn start",
910
"build": "react-scripts build",
1011
"test": "react-scripts test --env=jest-environment-jsdom",
1112
"test:ci": "cross-env CI=true yarn test --coverage",

app/src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ const { protocol, hostname, port } = window.location;
1414
const host = `${protocol}//${hostname}:${port}`;
1515
// the GRPC server to make requests to
1616
export const DEV_HOST = process.env.REACT_APP_DEV_HOST || host;
17+
18+
export const USE_SAMPLE_DATA = process.env.REACT_APP_USE_SAMPLE_DATA === 'true';

app/src/store/store.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { autorun, makeAutoObservable, runInAction } from 'mobx';
2-
import { IS_DEV, IS_TEST } from 'config';
2+
import { IS_DEV, IS_TEST, USE_SAMPLE_DATA } from 'config';
33
import { createBrowserHistory, History } from 'history';
44
import AppStorage from 'util/appStorage';
55
import CsvExporter from 'util/csv';
@@ -200,6 +200,9 @@ export class Store {
200200
*/
201201
export const createStore = (grpcClient?: GrpcClient, appStorage?: AppStorage) => {
202202
const grpc = grpcClient || new GrpcClient();
203+
// Resolve api requests with sample data when running client in develop mode.
204+
grpc.useSampleData = USE_SAMPLE_DATA;
205+
203206
const storage = appStorage || new AppStorage();
204207
const lndApi = new LndApi(grpc);
205208
const loopApi = new LoopApi(grpc);

0 commit comments

Comments
 (0)