Upgrade cashu-ts and remove InteractionManager

This commit is contained in:
minibits-cash
2026-03-10 12:57:34 +01:00
parent 3cb1444c95
commit 3909660529
7 changed files with 29 additions and 88 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
"machine-translate": "npx @inlang/cli machine translate --project minibits.inlang"
},
"dependencies": {
"@cashu/cashu-ts": "3.3.0",
"@cashu/cashu-ts": "3.5.0",
"@fortawesome/fontawesome-svg-core": "^7.1.0",
"@fortawesome/free-brands-svg-icons": "^7.1.0",
"@fortawesome/free-regular-svg-icons": "^7.1.0",
+9 -50
View File
@@ -28,7 +28,7 @@ import { Proof } from './Proof'
import { InFlightRequest, Mint } from './Mint'
import { getRootStore } from './helpers/getRootStore'
import { Transaction } from './Transaction'
// refresh
// refresh refresh
/*
Not persisted, in-memory only model of the cashu-ts wallet instances and wallet keys persisted in the device secure store.
@@ -1105,58 +1105,17 @@ export const WalletStoreModel = types
// PERF: Time wallet creation
const perfWalletCreate = performance.now()
// Get mint model instance for keysets metadata
const mintInstance = self.getMintModelInstance(mintUrl)
if(!mintInstance) {
throw new AppError(Err.VALIDATION_ERROR, 'Missing mint instance', {mintUrl})
}
// Check if the requested keyset is inactive
const requestedKeyset = mintInstance.keysets?.find(k => k.id === keysetId)
const isInactiveKeyset = requestedKeyset && !requestedKeyset.active
// Create separate CashuMint and CashuWallet instances for restore operation
// to avoid polluting the main wallet state with inactive keyset data
// to avoid polluting the main wallet state with inactive keyset data.
// cashu-ts 3.4.1+ supports restore from inactive keysets natively.
const cashuMint = new CashuMint(mintUrl)
let cashuWallet: CashuWallet
const cashuWallet = new CashuWallet(cashuMint, {
unit,
keysetId,
bip39seed: seed
})
if (isInactiveKeyset) {
// For inactive keysets, create wallet without binding to the inactive keyset
// (which would fail in finishInit), then manually load keys and rebind
log.trace('[WalletStore.restore]', 'Creating wallet for inactive keyset', {keysetId})
// Create wallet WITHOUT keysetId - it will bind to cheapest active keyset
cashuWallet = new CashuWallet(cashuMint, {
unit,
bip39seed: seed
})
// Load mint info - succeeds because wallet is bound to active keyset
yield cashuWallet.loadMint()
// Fetch and set keys for the inactive keyset
log.trace('[WalletStore.restore]', 'Loading keys for inactive keyset', {keysetId})
const {keysets: fetchedKeys} = yield cashuMint.getKeys(keysetId) as Promise<GetKeysResponse>
if (fetchedKeys && fetchedKeys.length > 0) {
const inactiveKeyset = cashuWallet.keyChain.getKeyset(keysetId)
inactiveKeyset.keys = fetchedKeys[0].keys
}
// Rebind to the inactive keyset now that it has keys
cashuWallet.bindKeyset(keysetId)
} else {
// For active keysets, create wallet with keysetId directly
log.trace('[WalletStore.restore]', 'Creating wallet for active keyset', {keysetId})
cashuWallet = new CashuWallet(cashuMint, {
unit,
keysetId,
bip39seed: seed
})
yield cashuWallet.loadMint()
}
yield cashuWallet.loadMint()
log.info('[PERF][WalletStore.restore] CashuWallet created:', { ms: (performance.now() - perfWalletCreate).toFixed(2) })
+5 -12
View File
@@ -1,6 +1,6 @@
import {observer} from 'mobx-react-lite'
import React, {useEffect, useRef, useState} from 'react'
import {FlatList, Image, InteractionManager, LayoutAnimation, Platform, TextInput, TextStyle, UIManager, View, ViewStyle} from 'react-native'
import {FlatList, Image, LayoutAnimation, Platform, TextInput, TextStyle, UIManager, View, ViewStyle} from 'react-native'
import {verticalScale} from '@gocodingnow/rn-size-matters'
import { Metadata, Contacts } from 'nostr-tools/kinds'
import Clipboard from '@react-native-clipboard/clipboard'
@@ -93,9 +93,7 @@ export const PublicContacts = observer(function (props: {
relaysStore.addDefaultRelays()
}
InteractionManager.runAfterInteractions(async () => {
subscribeToOwnProfileAndPubkeys()
})
subscribeToOwnProfileAndPubkeys()
}, [])
@@ -104,10 +102,8 @@ export const PublicContacts = observer(function (props: {
return
}
log.trace('Reloading...')
InteractionManager.runAfterInteractions(async () => {
subscribeToOwnProfileAndPubkeys()
setShouldReload(false)
})
subscribeToOwnProfileAndPubkeys()
setShouldReload(false)
}, [shouldReload])
@@ -205,11 +201,8 @@ export const PublicContacts = observer(function (props: {
setIsLoading(false)
}
InteractionManager.runAfterInteractions(async () => {
loadProfiles()
})
loadProfiles()
}, [followingPubkeys])
+7 -18
View File
@@ -4,7 +4,6 @@ import {
TextStyle,
View,
ViewStyle,
InteractionManager,
FlatList,
} from 'react-native'
import {spacing} from '../../theme'
@@ -36,23 +35,13 @@ export const RandomName = observer(function (props: {pubkey: string}) {
const [error, setError] = useState<AppError | undefined>()
useEffect(() => {
const load = async () => {
setIsLoading(true)
InteractionManager.runAfterInteractions(async () => {
let i = 0
let names = []
while (i < 8) {
const name = getRandomUsername()
names.push(name)
i++
}
setRandomNames(names)
setIsLoading(false)
})
}
load()
return () => {}
setIsLoading(true)
const timer = setTimeout(() => {
const names = Array.from({length: 8}, () => getRandomUsername())
setRandomNames(names)
setIsLoading(false)
}, 0)
return () => clearTimeout(timer)
}, [])
const confirmSelectedName = async function () {
+1 -1
View File
@@ -34,7 +34,7 @@ import RNExitApp from 'react-native-exit-app'
import { TransactionStatus } from '../models/Transaction'
import { maxTransactionsInHistory } from '../models/TransactionsStore'
import { StaticScreenProps, useNavigation } from '@react-navigation/native'
// refresh
// refresh refresh
type Props = StaticScreenProps<undefined>
+1 -1
View File
@@ -18,7 +18,7 @@ import { Platform } from "react-native"
import AppError, { Err } from "../utils/AppError"
const { userSettingsStore } = rootStoreInstance
//
// refresh refresh
if (!__DEV__) {
Sentry.init({
+5 -5
View File
@@ -2869,15 +2869,15 @@ __metadata:
languageName: node
linkType: hard
"@cashu/cashu-ts@npm:3.3.0":
version: 3.3.0
resolution: "@cashu/cashu-ts@npm:3.3.0"
"@cashu/cashu-ts@npm:3.5.0":
version: 3.5.0
resolution: "@cashu/cashu-ts@npm:3.5.0"
dependencies:
"@noble/curves": ^2.0.1
"@noble/hashes": ^2.0.1
"@scure/base": ^2.0.0
"@scure/bip32": ^2.0.1
checksum: beba7c33347dbd86385b071ad0624178645e86f2479dff91a655563ae1f6b8a730a7856d1b09e9df368bbfcc1e9ba1001c19512967787e41f417fc183537ce9e
checksum: 75af4dd2aa7100d85675b83b141d8e0f30c5ea71445bedbe5642d3f2c3d3f712565daa5265a19bf52ca6e51130a3f0c3974663503e98e0373eef0ac5be0f45a6
languageName: node
linkType: hard
@@ -14606,7 +14606,7 @@ __metadata:
"@babel/plugin-proposal-export-namespace-from": ^7.18.9
"@babel/preset-env": ^7.25.3
"@babel/runtime": ^7.25.0
"@cashu/cashu-ts": 3.3.0
"@cashu/cashu-ts": 3.5.0
"@fortawesome/fontawesome-svg-core": ^7.1.0
"@fortawesome/free-brands-svg-icons": ^7.1.0
"@fortawesome/free-regular-svg-icons": ^7.1.0