From 5dde1fff486f13b68ae05ad425721c60194b126c Mon Sep 17 00:00:00 2001 From: Tony Giorgio Date: Thu, 25 Jan 2024 09:13:08 -0600 Subject: [PATCH] Changes for v0.5.6 --- src/components/SyncContactsForm.tsx | 5 +---- src/logic/mutinyWalletSetup.ts | 18 ++++++++++++++++-- src/routes/settings/SyncNostrContacts.tsx | 12 ++---------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/components/SyncContactsForm.tsx b/src/components/SyncContactsForm.tsx index 2dc13f9..dfa506d 100644 --- a/src/components/SyncContactsForm.tsx +++ b/src/components/SyncContactsForm.tsx @@ -12,8 +12,6 @@ type NostrContactsForm = { npub: string; }; -const PRIMAL_API = import.meta.env.VITE_PRIMAL; - export function SyncContactsForm() { const i18n = useI18n(); const [state, actions] = useMegaStore(); @@ -30,8 +28,7 @@ export function SyncContactsForm() { ) => { try { const npub = f.npub.trim(); - if (!PRIMAL_API) throw new Error("PRIMAL_API not set"); - await state.mutiny_wallet?.sync_nostr_contacts(PRIMAL_API, npub); + await state.mutiny_wallet?.sync_nostr_contacts(npub); actions.saveNpub(npub); } catch (e) { console.error(e); diff --git a/src/logic/mutinyWalletSetup.ts b/src/logic/mutinyWalletSetup.ts index 7ba1ba8..4b0f9ed 100644 --- a/src/logic/mutinyWalletSetup.ts +++ b/src/logic/mutinyWalletSetup.ts @@ -17,6 +17,7 @@ export type MutinyWalletSettingStrings = { storage?: string; scorer?: string; selfhosted?: string; + primal_api?: string; }; const SETTINGS_KEYS = [ @@ -79,6 +80,11 @@ const SETTINGS_KEYS = [ name: "selfhosted", storageKey: "USER_SETTINGS_selfhosted", default: import.meta.env.VITE_SELFHOSTED + }, + { + name: "primal_api", + storageKey: "USER_SETTINGS_primal_api", + default: import.meta.env.VITE_PRIMAL } ]; @@ -246,7 +252,8 @@ export async function setupMutinyWallet( auth, subscriptions, storage, - scorer + scorer, + primal_api } = settings; console.log("Initializing Mutiny Manager"); @@ -261,6 +268,7 @@ export async function setupMutinyWallet( console.log("Using subscriptions address", subscriptions); console.log("Using storage address", storage); console.log("Using scorer address", scorer); + console.log("Using primal api", primal_api); console.log(safeMode ? "Safe mode enabled" : "Safe mode disabled"); console.log(shouldZapHodl ? "Hodl zaps enabled" : "Hodl zaps disabled"); @@ -290,7 +298,13 @@ export async function setupMutinyWallet( // Safe mode safeMode || undefined, // Skip hodl invoices? (defaults to true, so if shouldZapHodl is true that's when we pass false) - shouldZapHodl ? false : undefined + shouldZapHodl ? false : undefined, + // Nsec override + undefined, + // Nip7 + undefined, + // primal URL + primal_api || "https://primal-cache.mutinywallet.com/api" ); sessionStorage.setItem("MUTINY_WALLET_INITIALIZED", Date.now().toString()); diff --git a/src/routes/settings/SyncNostrContacts.tsx b/src/routes/settings/SyncNostrContacts.tsx index c5847f0..fb938d6 100644 --- a/src/routes/settings/SyncNostrContacts.tsx +++ b/src/routes/settings/SyncNostrContacts.tsx @@ -24,8 +24,6 @@ type NostrContactsForm = { npub: string; }; -const PRIMAL_API = import.meta.env.VITE_PRIMAL; - function SyncContactsForm() { const i18n = useI18n(); const [state, actions] = useMegaStore(); @@ -42,8 +40,7 @@ function SyncContactsForm() { ) => { try { const npub = f.npub.trim(); - if (!PRIMAL_API) throw new Error("PRIMAL_API not set"); - await state.mutiny_wallet?.sync_nostr_contacts(PRIMAL_API, npub); + await state.mutiny_wallet?.sync_nostr_contacts(npub); actions.saveNpub(npub); } catch (e) { console.error(e); @@ -105,12 +102,7 @@ export function SyncNostrContacts() { setError(undefined); setLoading(true); try { - if (!PRIMAL_API) throw new Error("PRIMAL_API not set"); - await state.mutiny_wallet?.sync_nostr_contacts( - PRIMAL_API, - // We can only see the resync button if there's an npub set - state.npub! - ); + await state.mutiny_wallet?.sync_nostr_contacts(state.npub!); } catch (e) { console.error(e); }