From 1cbfc030aee8356512a3ce3f7ac174e4c177473d Mon Sep 17 00:00:00 2001 From: Derek Guenther Date: Fri, 13 Dec 2024 16:22:03 -0500 Subject: [PATCH] Use environment variable to load live data (#92) --- README.md | 2 ++ package-lock.json | 8 -------- packages/mobile-app/.env.template | 1 + packages/mobile-app/data/facades/index.ts | 4 ++-- packages/mobile-app/index.js | 2 +- packages/mobile-app/package.json | 1 - 6 files changed, 6 insertions(+), 12 deletions(-) create mode 100644 packages/mobile-app/.env.template diff --git a/README.md b/README.md index fc0ed29..13a1944 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ This project was generated using [Nx](https://nx.dev). ### Running the Mobile App +1. The app uses demo data by default. To use wallet servers instead, copy `packages/mobile-app/.env.template` to `packages/mobile-app/.env` and set `EXPO_PUBLIC_DEMO_API=false`. + 1. In a terminal, build and run the iOS app: - `nx ios mobile-app` diff --git a/package-lock.json b/package-lock.json index 56743bb..f7278fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18067,13 +18067,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/process": { - "version": "0.11.10", - "license": "MIT", - "engines": { - "node": ">= 0.6.0" - } - }, "node_modules/process-nextick-args": { "version": "2.0.1", "license": "MIT" @@ -22036,7 +22029,6 @@ "kysely": "^0.27.3", "kysely-expo": "2.0.3", "long": "^5.2.3", - "process": "^0.11.10", "protobufjs": "^7.3.0", "react": "18.2.0", "react-native": "0.75.4", diff --git a/packages/mobile-app/.env.template b/packages/mobile-app/.env.template new file mode 100644 index 0000000..1018366 --- /dev/null +++ b/packages/mobile-app/.env.template @@ -0,0 +1 @@ +EXPO_PUBLIC_DEMO_API=true \ No newline at end of file diff --git a/packages/mobile-app/data/facades/index.ts b/packages/mobile-app/data/facades/index.ts index 695dea1..4e9b85b 100644 --- a/packages/mobile-app/data/facades/index.ts +++ b/packages/mobile-app/data/facades/index.ts @@ -7,10 +7,10 @@ import { chainHandlers } from "./chain/oreowalletHandlers"; import { chainDemoHandlers } from "./chain/demoHandlers"; import { contactsDemoHandlers } from "./contacts/demoHandlers"; -const DEMO = true; +const DEMO_API = Boolean(process.env.EXPO_PUBLIC_DEMO_API ?? true); export const facadeContext = createFacadeContext( - DEMO + DEMO_API ? { ...appDemoHandlers, ...chainDemoHandlers, diff --git a/packages/mobile-app/index.js b/packages/mobile-app/index.js index 5a9d8e4..bd9afb8 100644 --- a/packages/mobile-app/index.js +++ b/packages/mobile-app/index.js @@ -1,5 +1,5 @@ global.Buffer = require("buffer").Buffer; -global.process = require("process"); +process.argv = []; require("expo-router/entry"); diff --git a/packages/mobile-app/package.json b/packages/mobile-app/package.json index 24220d1..b08eb33 100644 --- a/packages/mobile-app/package.json +++ b/packages/mobile-app/package.json @@ -28,7 +28,6 @@ "kysely": "^0.27.3", "kysely-expo": "2.0.3", "long": "^5.2.3", - "process": "^0.11.10", "protobufjs": "^7.3.0", "react": "18.2.0", "react-native": "0.75.4",