From 69a6e1c03c7d63d64a9262fba07ff52a5daa3905 Mon Sep 17 00:00:00 2001 From: Tony Giorgio Date: Thu, 27 Jul 2023 13:56:57 -0500 Subject: [PATCH] Add scorer api --- .env.example | 1 + .github/workflows/android-build.yml | 1 + .github/workflows/android-prod.yml | 1 + .github/workflows/android-staging.yml | 1 + src/logic/mutinyWalletSetup.ts | 17 +++++++++++++---- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index bd843d0..6df606f 100644 --- a/.env.example +++ b/.env.example @@ -16,3 +16,4 @@ VITE_AUTH="https://auth-staging.mutinywallet.com" VITE_SUBSCRIPTIONS="https://subscriptions-staging.mutinywallet.com" VITE_STORAGE="https://storage-staging.mutinywallet.com" VITE_FEEDBACK="https://feedback-staging.mutinywallet.com" +VITE_SCORER="https://scorer-staging.mutinywallet.com" diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index c815237..7bd577d 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -69,6 +69,7 @@ jobs: VITE_AUTH: https://auth-staging.mutinywallet.com VITE_SUBSCRIPTIONS: https://subscriptions-staging.mutinywallet.com VITE_STORAGE: https://storage-staging.mutinywallet.com + VITE_SCORER: https://scorer-staging.mutinywallet.com run: pnpm build - name: Capacitor sync diff --git a/.github/workflows/android-prod.yml b/.github/workflows/android-prod.yml index 5959414..1ab057a 100644 --- a/.github/workflows/android-prod.yml +++ b/.github/workflows/android-prod.yml @@ -65,6 +65,7 @@ jobs: VITE_AUTH: https://auth.mutinywallet.com VITE_SUBSCRIPTIONS: https://subscriptions.mutinywallet.com VITE_STORAGE: https://storage.mutinywallet.com + VITE_SCORER: https://scorer.mutinywallet.com run: pnpm build - name: Capacitor sync diff --git a/.github/workflows/android-staging.yml b/.github/workflows/android-staging.yml index 546ea1d..457dc10 100644 --- a/.github/workflows/android-staging.yml +++ b/.github/workflows/android-staging.yml @@ -65,6 +65,7 @@ jobs: VITE_AUTH: https://auth-staging.mutinywallet.com VITE_SUBSCRIPTIONS: https://subscriptions-staging.mutinywallet.com VITE_STORAGE: https://storage-staging.mutinywallet.com + VITE_SCORER: https://scorer-staging.mutinywallet.com run: pnpm build - name: Capacitor sync diff --git a/src/logic/mutinyWalletSetup.ts b/src/logic/mutinyWalletSetup.ts index 4fe5996..4f8b754 100644 --- a/src/logic/mutinyWalletSetup.ts +++ b/src/logic/mutinyWalletSetup.ts @@ -12,6 +12,7 @@ export type MutinyWalletSettingStrings = { auth?: string; subscriptions?: string; storage?: string; + scorer?: string; }; export function getExistingSettings(): MutinyWalletSettingStrings { @@ -37,14 +38,17 @@ export function getExistingSettings(): MutinyWalletSettingStrings { const storage = localStorage.getItem("MUTINY_SETTINGS_storage") || import.meta.env.VITE_STORAGE; + const scorer = + localStorage.getItem("MUTINY_SETTINGS_scorer") || + import.meta.env.VITE_SCORER; - return { network, proxy, esplora, rgs, lsp, auth, subscriptions, storage }; + return { network, proxy, esplora, rgs, lsp, auth, subscriptions, storage, scorer }; } export async function setAndGetMutinySettings( settings?: MutinyWalletSettingStrings ): Promise { - let { network, proxy, esplora, rgs, lsp, auth, subscriptions, storage } = + let { network, proxy, esplora, rgs, lsp, auth, subscriptions, storage, scorer } = settings || {}; const existingSettings = getExistingSettings(); @@ -58,6 +62,7 @@ export async function setAndGetMutinySettings( auth = auth || existingSettings.auth; subscriptions = subscriptions || existingSettings.subscriptions; storage = storage || existingSettings.storage; + scorer = scorer || existingSettings.scorer; if (!network || !proxy || !esplora) { throw new Error( @@ -82,6 +87,7 @@ export async function setAndGetMutinySettings( subscriptions ); storage && localStorage.setItem("MUTINY_SETTINGS_storage", storage); + scorer && localStorage.setItem("MUTINY_SETTINGS_scorer", scorer); return { network, @@ -91,7 +97,8 @@ export async function setAndGetMutinySettings( lsp, auth, subscriptions, - storage + storage, + scorer }; } catch (error) { console.error(error); @@ -145,7 +152,7 @@ export async function setupMutinyWallet( password?: string ): Promise { console.log("Starting setup..."); - const { network, proxy, esplora, rgs, lsp, auth, subscriptions, storage } = + const { network, proxy, esplora, rgs, lsp, auth, subscriptions, storage, scorer } = await setAndGetMutinySettings(settings); console.log("Initializing Mutiny Manager"); console.log("Using network", network); @@ -156,6 +163,7 @@ export async function setupMutinyWallet( console.log("Using auth address", auth); console.log("Using subscriptions address", subscriptions); console.log("Using storage address", storage); + console.log("Using scorer address", scorer); const mutinyWallet = await new MutinyWallet( // Password password ? password : undefined, @@ -169,6 +177,7 @@ export async function setupMutinyWallet( auth, subscriptions, storage, + scorer, // Do not connect peers undefined );