mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2026-10-05 14:38:23 +00:00
feat(nip46): add skipSwitchRelays option to BunkerSignerParams
Adds a skipSwitchRelays option that prevents automatic switchRelays() call in fromURI. This is useful when users want to call switchRelays manually at their own pace, avoiding race conditions when making immediate RPC calls after connection. Fixes #526
This commit is contained in:
@@ -115,6 +115,8 @@ export function createNostrConnectURI(params: NostrConnectParams): string {
|
||||
export type BunkerSignerParams = {
|
||||
pool?: AbstractSimplePool
|
||||
onauth?: (url: string) => void
|
||||
/** Skip automatic switchRelays() call in fromURI. Useful when you want to call it manually at your own pace. */
|
||||
skipSwitchRelays?: boolean
|
||||
}
|
||||
|
||||
export class BunkerSigner implements Signer {
|
||||
@@ -220,7 +222,9 @@ export class BunkerSigner implements Signer {
|
||||
signer.setupSubscription()
|
||||
|
||||
success = true
|
||||
await Promise.race([new Promise(resolve => setTimeout(resolve, 1000)), signer.switchRelays()])
|
||||
if (!bunkerParams.skipSwitchRelays) {
|
||||
await Promise.race([new Promise(resolve => setTimeout(resolve, 1000)), signer.switchRelays()])
|
||||
}
|
||||
resolve(signer)
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user