From 1301626ba0e76048339a2d29ca7d775e23ec19f1 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Fri, 21 Apr 2023 19:02:57 -0500 Subject: [PATCH] add instructions for linking --- README.md | 42 ++++++++++++++++++----------------- justfile | 10 +++++++++ src/components/BalanceBox.tsx | 1 + vite.config.ts | 5 +++++ 4 files changed, 38 insertions(+), 20 deletions(-) create mode 100644 justfile diff --git a/README.md b/README.md index 01282bf..a1c7d7c 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,32 @@ -# SolidStart +### Running Mutiny Web -Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com); - -## Creating a project - -```bash -# create a new project in the current directory -npm init solid@latest - -# create a new project in my-app -npm init solid@latest my-app +``` +pnpm install +pnpm run dev ``` -## Developing +### Local -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: +To make local development easier with a latest local version of [the node manager](https://github.com/MutinyWallet/mutiny-node), you may want to `pnpm link` it. -```bash -npm run dev +Due to how [Vite's dev server works](https://vitejs.dev/config/server-options.html#server-fs-allow), the linked `mutiny-node` project folder should be a sibling of this `mutiny-web` folder. Alternatively you can change the allow path in `vite.config.ts`. -# or start the server and open the app in a new browser tab -npm run dev -- --open +In your `mutiny-node` local repo: + +``` +just link ``` -## Building +(on a Mac you might need to prefix `just link` with these flags: `AR=/opt/homebrew/opt/llvm/bin/llvm-ar CC=/opt/homebrew/opt/llvm/bin/clang`) -Solid apps are built with _adapters_, which optimise your project for deployment to different environments. +Now in this repo, link them. -By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different adapter, add it to the `devDependencies` in `package.json` and specify in your `vite.config.js`. +``` +just local +``` + +To revert back and use the remote version of mutiny-wasm: + +``` +just remote +``` diff --git a/justfile b/justfile new file mode 100644 index 0000000..7628d12 --- /dev/null +++ b/justfile @@ -0,0 +1,10 @@ +set dotenv-load := false + +dev: + pnpm run dev + +local: + pnpm link --global "@mutinywallet/mutiny-wasm" + +remote: + pnpm unlink "@mutinywallet/mutiny-wasm" && pnpm install diff --git a/src/components/BalanceBox.tsx b/src/components/BalanceBox.tsx index c1190eb..d0856c8 100644 --- a/src/components/BalanceBox.tsx +++ b/src/components/BalanceBox.tsx @@ -21,6 +21,7 @@ export default function BalanceBox() { const fetchOnchainBalance = async () => { console.log("Refetching onchain balance"); + await state.node_manager?.sync(); const balance = await state.node_manager?.get_balance(); return balance }; diff --git a/vite.config.ts b/vite.config.ts index b81f61a..f3ae82e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -41,6 +41,10 @@ const pwaOptions: Partial = { export default defineConfig({ server: { port: 3420, + fs: { + // Allow serving files from one level up (so that if mutiny-node is a sibling folder we can use it locally) + allow: [".."] + } }, plugins: [wasm(), solid({ ssr: false }), VitePWA(pwaOptions)], resolve: { @@ -50,4 +54,5 @@ export default defineConfig({ // This is necessary because otherwise `vite dev` can't find the wasm exclude: ["@mutinywallet/mutiny-wasm"], }, + });