Skip to content

Commit

Permalink
Use NIP-07 extension
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jan 19, 2024
1 parent d54147b commit 5d2c221
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 12 additions & 1 deletion src/logic/mutinyWalletSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,16 @@ export async function setupMutinyWallet(
}
}

// if we didn't get an nsec from storage, try to use extension
let extension_key;
if (!nsec) {
try {
extension_key = await window.nostr.getPublicKey();

Check failure on line 269 in src/logic/mutinyWalletSetup.ts

View workflow job for this annotation

GitHub Actions / Build APK

Property 'nostr' does not exist on type 'Window & typeof globalThis'.

Check failure on line 269 in src/logic/mutinyWalletSetup.ts

View workflow job for this annotation

GitHub Actions / Build iOS

Property 'nostr' does not exist on type 'Window & typeof globalThis'.
} catch (_) {
console.log("No NIP-07 extension")
}
}

console.log("Initializing Mutiny Manager");
console.log("Using network", network);
console.log("Using proxy", proxy);
Expand Down Expand Up @@ -304,7 +314,8 @@ export async function setupMutinyWallet(
safeMode || undefined,
// Skip hodl invoices? (defaults to true, so if shouldZapHodl is true that's when we pass false)
shouldZapHodl ? false : undefined,
nsec
nsec,

Check failure on line 317 in src/logic/mutinyWalletSetup.ts

View workflow job for this annotation

GitHub Actions / Build APK

Expected 0-17 arguments, but got 19.

Check failure on line 317 in src/logic/mutinyWalletSetup.ts

View workflow job for this annotation

GitHub Actions / Build iOS

Expected 0-17 arguments, but got 19.
extension_key ? extension_key : undefined
);

sessionStorage.setItem("MUTINY_WALLET_INITIALIZED", Date.now().toString());
Expand Down
13 changes: 0 additions & 13 deletions src/routes/settings/SyncNostrContacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,6 @@ export function SyncNostrContacts() {
}
}

const [hasNsec] = createResource(async () => {
if (Capacitor.isNativePlatform()) {
try {
await SecureStoragePlugin.get({ key: "nsec" });
return true;
} catch (_e) {
return false;
}
} else {
return false;
}
});

async function resync() {
setError(undefined);
setLoading(true);
Expand Down

0 comments on commit 5d2c221

Please sign in to comment.