From 27aee22d73e5edfd250d1a2258473861fbac2cdc Mon Sep 17 00:00:00 2001 From: benthecarman Date: Wed, 27 Sep 2023 19:06:17 -0500 Subject: [PATCH] Fixes for self-hosting --- .dockerignore | 1 + .github/workflows/android-prod.yml | 2 +- Dockerfile | 8 ++++---- package.json | 2 +- pnpm-lock.yaml | 16 ++++++++-------- src/logic/mutinyWalletSetup.ts | 20 +++++++++++++------- 6 files changed, 28 insertions(+), 21 deletions(-) diff --git a/.dockerignore b/.dockerignore index 3503535..5112eb0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,3 +4,4 @@ node_modules *.md dist justfile +.env.local diff --git a/.github/workflows/android-prod.yml b/.github/workflows/android-prod.yml index a956dbe..5c930d5 100644 --- a/.github/workflows/android-prod.yml +++ b/.github/workflows/android-prod.yml @@ -64,7 +64,7 @@ jobs: VITE_RGS: https://scorer.mutinywallet.com/v1/rgs/snapshot/ VITE_AUTH: https://auth.mutinywallet.com VITE_SUBSCRIPTIONS: https://subscriptions.mutinywallet.com - VITE_STORAGE: https://storage.mutinywallet.com + VITE_STORAGE: https://storage.mutinywallet.com/v2 VITE_FEEDBACK: https://feedback.mutinywallet.com VITE_SCORER: https://scorer.mutinywallet.com VITE_PRIMAL: https://primal-cache.mutinywallet.com/api diff --git a/Dockerfile b/Dockerfile index 8827e8f..1776f1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,12 +13,12 @@ RUN apt update && apt install -y git # Add the ARG directives for build-time environment variables ARG VITE_NETWORK="bitcoin" -ARG VITE_PROXY="wss://p.mutinywallet.com" -ARG VITE_ESPLORA="https://mutinynet.com/api" +ARG VITE_PROXY="/_services/proxy" +ARG VITE_ESPLORA ARG VITE_LSP="https://lsp.voltageapi.com" -ARG VITE_RGS="https://rgs.mutinynet.com/snapshot/" +ARG VITE_RGS ARG VITE_AUTH -ARG VITE_STORAGE +ARG VITE_STORAGE="/_services/vss/v2" ARG VITE_SELFHOSTED="true" # Install dependencies diff --git a/package.json b/package.json index 777b42c..116bcd2 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@kobalte/tailwindcss": "^0.5.0", "@modular-forms/solid": "^0.18.1", "@mutinywallet/barcode-scanner": "5.0.0-beta.3", - "@mutinywallet/mutiny-wasm": "0.4.19", + "@mutinywallet/mutiny-wasm": "0.4.20", "@mutinywallet/waila-wasm": "^0.2.1", "@nostr-dev-kit/ndk": "^0.8.11", "@solid-primitives/upload": "^0.0.111", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 82d269e..5f2e478 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,9 +1,5 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - importers: .: @@ -42,8 +38,8 @@ importers: specifier: 5.0.0-beta.3 version: 5.0.0-beta.3(@capacitor/core@5.2.2) '@mutinywallet/mutiny-wasm': - specifier: 0.4.19 - version: 0.4.19 + specifier: 0.4.20 + version: 0.4.20 '@mutinywallet/waila-wasm': specifier: ^0.2.1 version: 0.2.1 @@ -2497,8 +2493,8 @@ packages: '@capacitor/core': 5.2.2 dev: false - /@mutinywallet/mutiny-wasm@0.4.19: - resolution: {integrity: sha512-iDH6JFinOUnJu57tbdJqCMWjN1h5+UDznK8hLga+1l7LJw9ro/wxop+hsvKwGSsX6rvK3xhRKQHsFsb7NkiRfQ==} + /@mutinywallet/mutiny-wasm@0.4.20: + resolution: {integrity: sha512-dygacqfLbWzUeN9iUpWwmZluM5ZfwYpzBXOeTTYSweiWpblTia7x67UqTNgzxh88gkuM4b0GUoo69QO5LppPSQ==} dev: false /@mutinywallet/waila-wasm@0.2.1: @@ -14066,3 +14062,7 @@ packages: /yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false diff --git a/src/logic/mutinyWalletSetup.ts b/src/logic/mutinyWalletSetup.ts index 2118084..1ae65b6 100644 --- a/src/logic/mutinyWalletSetup.ts +++ b/src/logic/mutinyWalletSetup.ts @@ -110,21 +110,27 @@ export async function getSettings() { // Expect urls like /_services/proxy and /_services/storage if (selfhosted) { - const base = window.location.origin; + let base = window.location.origin; console.log("Self-hosted mode enabled, using base URL", base); - const proxy = settings.proxy; const storage = settings.storage; - if (proxy && proxy.startsWith("/")) { - settings.proxy = base + proxy; - } if (storage && storage.startsWith("/")) { settings.storage = base + storage; } + + const proxy = settings.proxy; + if (proxy && proxy.startsWith("/")) { + if (base.startsWith("http://")) { + base = base.replace("http://", "ws://"); + } else if (base.startsWith("https://")) { + base = base.replace("https://", "wss://"); + } + settings.proxy = base + proxy; + } } - if (!settings.network || !settings.proxy || !settings.esplora) { + if (!settings.network || !settings.proxy) { throw new Error( - "Missing a default setting for network, proxy, or esplora. Check your .env file to make sure it looks like .env.sample" + "Missing a default setting for network or proxy. Check your .env file to make sure it looks like .env.sample" ); }