diff options
Diffstat (limited to 'src/features/sync.js')
| -rw-r--r-- | src/features/sync.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/features/sync.js b/src/features/sync.js index f927aef..8349b5d 100644 --- a/src/features/sync.js +++ b/src/features/sync.js @@ -22,6 +22,22 @@ export function installSyncWallet(wallet) { return this.nostr && this.nostr.sk ? this.nostr.sendDM(recipientPkHex, text) : false; }, + // Generic event publish/fetch on the configured sync relays — the seam + // other features (ark zaps) use to speak their own kinds. No-ops when + // sync is disabled or the wallet is offline. + async nostrPublish(partial) { + const sync = getSyncConfig(); + if (this.offline || !sync.enabled || !this.nostr.sk) return null; + this.nostr.setRelays(sync.relays); + return this.nostr.publishEvent(partial); + }, + async nostrFetch(filter, maxWait) { + const sync = getSyncConfig(); + if (this.offline || !sync.enabled) return []; + this.nostr.setRelays(sync.relays); + return this.nostr.fetchEvents(filter, maxWait); + }, + // Pull the latest state from Nostr; apply it if it's newer than what we have. // Returns true if state was applied (so the caller can skip a full scan). async syncFromNostr() { |
