mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-05 11:18:24 +00:00
The fork existed only to strip the package's `exports` map so metro would bundle the TS source; upstream now ships a build that react-native consumes directly (README documents the polyfills, all of which the app already installs), so the fork has no reason to exist. Fallout of the upgrade: - `subscribeMany` now takes a single filter rather than an array. - `SimplePool` drops a relay from its map when it gives up on it, so an empty map - not a `false` status - is what "everything is down" looks like now. Opt into `enableReconnect` so the pool restores dropped connections and refires their subscriptions with an advanced `since`. - `message-port-polyfill` was there for the old nostr-tools; nothing in the tree references MessagePort any more. - The published build is plain CJS/ESM, so jest can load the real library and the mock that stood in for it is gone. Nested @noble copies need babel, hence the transformIgnorePatterns tweak. Covered by a NIP-06 derivation test against the standard vector, so the identity the wallet derives from a seed phrase is provably unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
101 lines
3.5 KiB
JavaScript
101 lines
3.5 KiB
JavaScript
import 'react-native-reanimated' // needed for qrcode reader
|
|
import { install } from 'react-native-quick-crypto' // needed for secp256k1, conf in babel.config
|
|
install()
|
|
import 'react-native-url-polyfill/auto' // URL.host etc
|
|
import 'text-encoding-polyfill' // cashu-ts
|
|
import notifee from '@notifee/react-native'
|
|
import messaging from '@react-native-firebase/messaging'
|
|
import {AppRegistry} from 'react-native'
|
|
import { rootStoreInstance } from './src/models'
|
|
import {
|
|
WalletTask,
|
|
NotificationService,
|
|
SWAP_ALL_TASK,
|
|
SWAP_DENOMINATION_TASK,
|
|
TEST_TASK,
|
|
SYNC_STATE_WITH_ALL_MINTS_TASK,
|
|
} from './src/services'
|
|
import {
|
|
LISTEN_FOR_NWC_EVENTS
|
|
} from './src/models/NwcStore'
|
|
import { log } from './src/services/logService'
|
|
import App from './src/App'
|
|
import {name as appName} from './app.json'
|
|
|
|
function BootstrapApp() {
|
|
return <App appName={appName} />
|
|
}
|
|
|
|
// long running tasks
|
|
notifee.registerForegroundService(async (notification) => {
|
|
return new Promise(async (resolve) => {
|
|
log.trace('[registerForegroundService] Foreground service starting for task:', notification.data.task)
|
|
|
|
try {
|
|
|
|
// Listen for NWC commands over ws (started by the push handler AFTER it has
|
|
// processed the pushed command directly; this catches any follow-ups that
|
|
// arrive in the window without their own push).
|
|
if(notification.data.task === LISTEN_FOR_NWC_EVENTS) {
|
|
const {nwcStore} = rootStoreInstance
|
|
nwcStore.listenForNwcEvents()
|
|
}
|
|
|
|
if(notification.data.task === SYNC_STATE_WITH_ALL_MINTS_TASK) {
|
|
log.debug(`[registerForegroundService] Submitting task ${SYNC_STATE_WITH_ALL_MINTS_TASK} to the queue.`)
|
|
|
|
await WalletTask.syncStateWithAllMintsQueueAwaitable({isPending: false})
|
|
}
|
|
|
|
|
|
if(notification.data.task === SWAP_ALL_TASK) {
|
|
log.debug(`[registerForegroundService] Submitting task ${SWAP_ALL_TASK} to the queue.`)
|
|
|
|
WalletTask.swapAllQueue()
|
|
}
|
|
|
|
if(notification.data.task === SWAP_DENOMINATION_TASK) {
|
|
log.debug(`[registerForegroundService] Submitting task ${SWAP_DENOMINATION_TASK} to the queue.`)
|
|
|
|
const payload = notification.data.data || {}
|
|
WalletTask.swapByDenominationQueue(payload.denomination, payload.mintUrl)
|
|
}
|
|
|
|
|
|
if(notification.data.task === TEST_TASK) {
|
|
log.debug(`[registerForegroundService] Submitting task ${TEST_TASK} to the queue.`)
|
|
|
|
WalletTask.testQueue()
|
|
}
|
|
|
|
} catch(e) {
|
|
log.error('[registerForegroundService]', e.message)
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
notifee.onForegroundEvent(async ({ type, detail }) => {
|
|
//log.trace('[onForegroundEvent]', {type, detail})
|
|
|
|
if (detail.pressAction && detail.pressAction.id === 'stop') {
|
|
log.trace('[onForegroundEvent] Stopping foreground service')
|
|
// Route through closeNwcListener (not raw stopForegroundService) so pressing
|
|
// Stop also tears down the adaptive poll and releases any in-flight NWC
|
|
// pay_invoice immediately. It's a superset of stopping the service, and is
|
|
// harmless for non-NWC task foreground services (which share the one service).
|
|
await NotificationService.closeNwcListener()
|
|
}
|
|
})
|
|
|
|
notifee.onBackgroundEvent(async ({ type, detail }) => {
|
|
return true
|
|
})
|
|
|
|
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true
|
|
messaging().onMessage(NotificationService.onForegroundNotification)
|
|
messaging().setBackgroundMessageHandler(NotificationService.onBackgroundNotification)
|
|
NotificationService.initNotifications()
|
|
|
|
AppRegistry.registerComponent(appName, () => BootstrapApp)
|