PreferredUnit impl, fixing

This commit is contained in:
minibits-cash
2024-05-03 01:47:06 +02:00
parent 40f4b1e9b2
commit 832e22e465
21 changed files with 136 additions and 68 deletions
+2 -2
View File
@@ -162,7 +162,7 @@ export function Card(props: CardProps) {
const Wrapper: ComponentType<TouchableOpacityProps> = isPressable ? TouchableOpacity : View
const HeaderContentWrapper = verticalAlignment === "force-footer-bottom" ? View : Fragment
const $containerStyle = [$containerPresets[preset], $containerStyleOverride]
const $containerStyle = [$containerPresets[preset], { backgroundColor }, $containerStyleOverride]
const $headingStyle = [
$headingPresets[preset],
(isFooterPresent || isContentPresent) && { marginBottom: spacing.micro },
@@ -191,7 +191,7 @@ export function Card(props: CardProps) {
return (
<Wrapper
style={[$containerStyle, { backgroundColor }]}
style={$containerStyle}
activeOpacity={0.8}
accessibilityRole={isPressable ? "button" : undefined}
{...WrapperProps}
+1
View File
@@ -230,6 +230,7 @@ const en = {
settingsScreen: {
title: "Settings",
manageMints: "Manage mints",
preferredUnit: "Preferred unit",
mintsCount: {
one: "{{count}} mint",
other: "{{count}} mints",
+15 -4
View File
@@ -2,10 +2,12 @@ import {Instance, SnapshotOut, types, flow} from 'mobx-state-tree'
import {Database} from '../services'
import {MMKVStorage} from '../services'
import {LogLevel} from '../services/log/logTypes'
import { MintUnit } from '../services/wallet/currency'
export type UserSettings = {
id?: number
walletId: string | null
walletId: string | null
preferredUnit: MintUnit | null
isOnboarded: boolean | 0 | 1
isStorageEncrypted: boolean | 0 | 1
isLocalBackupOn: boolean | 0 | 1
@@ -18,7 +20,8 @@ export type UserSettings = {
export const UserSettingsStoreModel = types
.model('UserSettingsStore')
.props({
walletId: types.maybeNull(types.string),
walletId: types.maybeNull(types.string),
preferredUnit: types.optional(types.frozen<MintUnit>(), 'sat'),
isOnboarded: types.optional(types.boolean, false),
isStorageEncrypted: types.optional(types.boolean, false),
isLocalBackupOn: types.optional(types.boolean, true),
@@ -30,7 +33,8 @@ export const UserSettingsStoreModel = types
.actions(self => ({
loadUserSettings: () => {
const {
walletId,
walletId,
preferredUnit,
isOnboarded,
isStorageEncrypted,
isLocalBackupOn,
@@ -47,7 +51,8 @@ export const UserSettingsStoreModel = types
const booleanIsLoggerOn = isLoggerOn === 1
const booleanIsStorageMigrated = isStorageMigrated === 1
self.walletId = walletId as string
self.walletId = walletId as string
self.preferredUnit = preferredUnit as MintUnit
self.isOnboarded = booleanIsOnboarded as boolean
self.isStorageEncrypted = booleanIsStorageEncrypted as boolean
self.isLocalBackupOn = booleanIsLocalBackupOn as boolean
@@ -62,6 +67,12 @@ export const UserSettingsStoreModel = types
return walletId
},
setPreferredUnit: (preferredUnit: MintUnit) => {
Database.updateUserSettings({...self, preferredUnit})
self.preferredUnit = preferredUnit
return preferredUnit
},
setIsOnboarded: (isOnboarded: boolean) => {
Database.updateUserSettings({...self, isOnboarded})
self.isOnboarded = isOnboarded
+2
View File
@@ -242,6 +242,8 @@ async function _runMigrations(rootStore: RootStore) {
if(currentVersion < 12) {
log.trace(`Starting rootStore migrations from version v${currentVersion} -> v12`)
userSettingsStore.setPreferredUnit('sat')
for (const mint of mintsStore.allMints) {
try {
mint.addUnit('sat')
-2
View File
@@ -43,10 +43,8 @@ import {
import { Contact } from "../models/Contact"
import { colors, useThemeColor, spacing, typography } from "../theme"
import { AppStackParamList, AppStackScreenProps } from "./AppNavigator"
import { MintBalance } from "../models/Mint"
import { PaymentRequest } from "../models/PaymentRequest"
import { LNURLPayParams, LNURLWithdrawParams } from "js-lnurl"
import { IncomingDataType } from "../services/incomingParser"
import { MintUnit } from "../services/wallet/currency"
+6 -3
View File
@@ -22,7 +22,7 @@ interface ContactDetailScreenProps extends ContactsStackScreenProps<'ContactDeta
export const ContactDetailScreen: FC<ContactDetailScreenProps> = observer(
function ContactScreen({route, navigation}) {
const {contact} = route.params
const {contactsStore} = useStores()
const {contactsStore, userSettingsStore} = useStores()
const noteInputRef = useRef<TextInput>(null)
useHeader({
@@ -77,8 +77,11 @@ export const ContactDetailScreen: FC<ContactDetailScreenProps> = observer(
try {
await IncomingParser.navigateWithIncomingData({
type: IncomingDataType.LNURL_ADDRESS,
encoded: contact.lud16
}, navigation)
encoded: contact.lud16
},
navigation,
userSettingsStore.preferredUnit
)
return
} catch (e: any) {
+2 -2
View File
@@ -26,7 +26,7 @@ export const PrivateContacts = observer(function (props: {
navigation: StackNavigationProp<ContactsStackParamList, "Contacts", undefined>,
paymentOption: ReceiveOption | SendOption | undefined},
) {
const {contactsStore, relaysStore} = useStores()
const {contactsStore, relaysStore, userSettingsStore} = useStores()
const {navigation} = props
const contactNameInputRef = useRef<TextInput>(null)
@@ -211,7 +211,7 @@ export const PrivateContacts = observer(function (props: {
await IncomingParser.navigateWithIncomingData({
type: IncomingDataType.LNURL_ADDRESS,
encoded: contact.lud16
}, navigation)
}, navigation, userSettingsStore.preferredUnit)
//reset
navigation.setParams({
+2 -2
View File
@@ -34,7 +34,7 @@ export const PublicContacts = observer(function (props: {
navigation: StackNavigationProp<ContactsStackParamList, "Contacts", undefined>,
paymentOption: ReceiveOption | SendOption |undefined}
) {
const {contactsStore, relaysStore} = useStores()
const {contactsStore, relaysStore, userSettingsStore} = useStores()
const {navigation} = props
const npubInputRef = useRef<TextInput>(null)
@@ -392,7 +392,7 @@ export const PublicContacts = observer(function (props: {
await IncomingParser.navigateWithIncomingData({
type: IncomingDataType.LNURL_ADDRESS,
encoded: contact.lud16
}, navigation)
}, navigation, userSettingsStore.preferredUnit)
setIsLoading(false)
//reset
+3 -3
View File
@@ -105,7 +105,7 @@ export const LightningPayScreen: FC<WalletStackScreenProps<'LightningPay'>> = fu
try {
const invoiceResult = IncomingParser.findAndExtract(lightningData as string, IncomingDataType.INVOICE)
return IncomingParser.navigateWithIncomingData(invoiceResult, navigation, mint && unit && {mintUrl: mint.mintUrl, unit})
return IncomingParser.navigateWithIncomingData(invoiceResult, navigation, unit, mint && mint.mintUrl)
} catch (e: any) {
const maybeLnurlAddress = LnurlUtils.findEncodedLnurlAddress(lightningData as string)
@@ -119,7 +119,7 @@ export const LightningPayScreen: FC<WalletStackScreenProps<'LightningPay'>> = fu
await IncomingParser.navigateWithIncomingData({
type: IncomingDataType.LNURL_ADDRESS,
encoded: validAddress,
}, navigation, mint && unit && {mintUrl: mint.mintUrl, unit})
}, navigation, unit, mint && mint.mintUrl)
}
return
} catch (e3: any) {
@@ -139,7 +139,7 @@ export const LightningPayScreen: FC<WalletStackScreenProps<'LightningPay'>> = fu
await IncomingParser.navigateWithIncomingData({
type: IncomingDataType.LNURL,
encoded: encodedLnurl
}, navigation, mint && unit && {mintUrl: mint.mintUrl, unit})
}, navigation, unit, mint && mint.mintUrl)
}
return
} catch (e2: any) {
+11 -7
View File
@@ -19,6 +19,7 @@ import { BottomModal, Button, ErrorModal, Icon, Text } from '../components'
import { LnurlUtils } from '../services/lnurl/lnurlUtils'
import { infoMessage } from '../utils/utils'
import Clipboard from '@react-native-clipboard/clipboard'
import { useStores } from '../models'
const hasAndroidCameraPermission = async () => {
const cameraPermission = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA)
@@ -36,6 +37,7 @@ export const ScanScreen: FC<WalletStackScreenProps<'Scan'>> = function ScanScree
})
const addressInputRef = useRef<TextInput>(null)
const {userSettingsStore} = useStores()
const [shouldLoad, setShouldLoad] = useState<boolean>(false)
const [isScanned, setIsScanned] = useState<boolean>(false)
@@ -78,14 +80,16 @@ export const ScanScreen: FC<WalletStackScreenProps<'Scan'>> = function ScanScree
}
const onIncomingData = async function(incoming: any) {
const onIncomingData = async function(incoming: any) {
const {preferredUnit: unit} = userSettingsStore
switch (prevRouteName) {
case 'ReceiveOptions':
log.trace('ReceiveOptions')
try {
const tokenResult = IncomingParser.findAndExtract(incoming, IncomingDataType.CASHU)
return IncomingParser.navigateWithIncomingData(tokenResult, navigation)
return IncomingParser.navigateWithIncomingData(tokenResult, navigation, unit)
} catch (e: any) {
const maybeLnurl = LnurlUtils.findEncodedLnurl(incoming)
@@ -99,7 +103,7 @@ export const ScanScreen: FC<WalletStackScreenProps<'Scan'>> = function ScanScree
await IncomingParser.navigateWithIncomingData({
type: IncomingDataType.LNURL,
encoded: encodedLnurl
}, navigation)
}, navigation, unit)
}
return
} catch (e2: any) {
@@ -116,7 +120,7 @@ export const ScanScreen: FC<WalletStackScreenProps<'Scan'>> = function ScanScree
case 'LightningPay':
try {
const invoiceResult = IncomingParser.findAndExtract(incoming, IncomingDataType.INVOICE)
return IncomingParser.navigateWithIncomingData(invoiceResult, navigation)
return IncomingParser.navigateWithIncomingData(invoiceResult, navigation, unit)
} catch (e: any) {
const maybeLnurlAddress = LnurlUtils.findEncodedLnurlAddress(incoming)
@@ -130,7 +134,7 @@ export const ScanScreen: FC<WalletStackScreenProps<'Scan'>> = function ScanScree
await IncomingParser.navigateWithIncomingData({
type: IncomingDataType.LNURL_ADDRESS,
encoded: validAddress
}, navigation)
}, navigation, unit)
}
return
} catch (e3: any) {
@@ -150,7 +154,7 @@ export const ScanScreen: FC<WalletStackScreenProps<'Scan'>> = function ScanScree
await IncomingParser.navigateWithIncomingData({
type: IncomingDataType.LNURL,
encoded: encodedLnurl
}, navigation)
}, navigation, unit)
}
return
} catch (e2: any) {
@@ -167,7 +171,7 @@ export const ScanScreen: FC<WalletStackScreenProps<'Scan'>> = function ScanScree
try {
// generic scan button on wallet screen
const incomingData = IncomingParser.findAndExtract(incoming)
return IncomingParser.navigateWithIncomingData(incomingData, navigation)
return IncomingParser.navigateWithIncomingData(incomingData, navigation, unit)
} catch (e: any) {
e.name = Err.VALIDATION_ERROR
e.params = {caller: 'onIncomingData', clipboard: incoming.slice(0, 100)}
+2 -1
View File
@@ -989,7 +989,8 @@ const SendAsQRCodeBlock = observer(function (props: {
return (
<Card
heading='Token to share'
headingStyle={{textAlign: 'center'}}
headingStyle={qrError ? {textAlign: 'center'} : {textAlign: 'center', color: colors.light.text}}
style={!qrError && {backgroundColor: 'white'}}
ContentComponent={qrError ? (
<ListItem
text='Could not display QR code, copy token instead.'
+21 -3
View File
@@ -16,6 +16,7 @@ import {translate} from '../i18n'
import { log } from '../services'
import {Env} from '../utils/envtypes'
import { round } from '../utils/number'
import { MintUnitCurrencyPairs } from '../services/wallet/currency'
interface SettingsScreenProps extends SettingsStackScreenProps<'Settings'> {}
@@ -26,7 +27,7 @@ export const SettingsScreen: FC<SettingsScreenProps> = observer(
function SettingsScreen(_props) {
const {navigation} = _props
useHeader({}) // default header component
const {mintsStore, relaysStore} = useStores()
const {mintsStore, relaysStore, userSettingsStore} = useStores()
const [isUpdateAvailable, setIsUpdateAvailable] = useState<boolean>(false)
const [updateDescription, setUpdateDescription] = useState<string>('')
@@ -124,10 +125,27 @@ export const SettingsScreen: FC<SettingsScreenProps> = observer(
bottomSeparator={true}
onPress={gotoMints}
/>
<ListItem
tx='settingsScreen.preferredUnit'
leftIcon='faMoneyBill1'
leftIconColor={userSettingsStore.preferredUnit === 'usd' ? colors.palette.green400 : colors.palette.orange400}
leftIconInverse={true}
style={$item}
RightComponent={
<View style={$rightContainer}>
<Text
style={$itemRight}
text={MintUnitCurrencyPairs[userSettingsStore.preferredUnit]}
/>
</View>
}
bottomSeparator={true}
onPress={gotoBackupRestore}
/>
<ListItem
tx='settingsScreen.backupRecovery'
leftIcon='faCloudArrowUp'
leftIconColor={colors.palette.success300}
leftIconColor={colors.palette.angry300}
leftIconInverse={true}
style={$item}
bottomSeparator={true}
@@ -171,7 +189,7 @@ export const SettingsScreen: FC<SettingsScreenProps> = observer(
<ListItem
tx='settingsScreen.devOptions'
leftIcon='faCode'
leftIconColor={colors.palette.accent300}
leftIconColor={colors.palette.neutral600}
leftIconInverse={true}
style={$item}
onPress={gotoDevOptions}
+2 -1
View File
@@ -885,7 +885,8 @@ const ShareAsQRCodeBlock = observer(function (props: {
return (
<Card
heading='Invoice to pay'
headingStyle={{textAlign: 'center'}}
headingStyle={{textAlign: 'center', color: colors.light.text}}
style={{backgroundColor: 'white'}}
ContentComponent={
<View style={$qrCodeContainer}>
<QRCode
+4 -4
View File
@@ -10,7 +10,7 @@ import {
import Clipboard from '@react-native-clipboard/clipboard'
import JSONTree from 'react-native-json-tree'
import {colors, spacing, useThemeColor} from '../theme'
import {WalletStackScreenProps} from '../navigation'
import {TransactionsStackScreenProps} from '../navigation'
import EventEmitter from '../utils/eventEmitter'
import {
Button,
@@ -41,12 +41,12 @@ import useColorScheme from '../theme/useThemeColor'
import useIsInternetReachable from '../utils/useIsInternetReachable'
import { ResultModalInfo } from './Wallet/ResultModalInfo'
import QRCode from 'react-native-qrcode-svg'
import { getDecodedToken, getEncodedToken, Token as CashuToken } from '@cashu/cashu-ts'
import { getDecodedToken, Token as CashuToken } from '@cashu/cashu-ts'
import { CashuUtils } from '../services/cashu/cashuUtils'
import { MintStatus } from '../models/Mint'
import { moderateVerticalScale } from '@gocodingnow/rn-size-matters'
import { CurrencySign } from './Wallet/CurrencySign'
import { CurrencyCode, MintUnit, MintUnitCurrencyPairs, MintUnits } from "../services/wallet/currency"
import { MintUnit, MintUnitCurrencyPairs, MintUnits } from "../services/wallet/currency"
import { Token } from '../models/Token'
import { PaymentRequest } from '../models/PaymentRequest'
import { pollerExists } from '../utils/poller'
@@ -58,7 +58,7 @@ type ProofsByStatus = {
isReceived: Proof[]
}
export const TranDetailScreen: FC<WalletStackScreenProps<'TranDetail'>> =
export const TranDetailScreen: FC<TransactionsStackScreenProps<'TranDetail'>> =
observer(function TranDetailScreen(_props) {
const {navigation, route} = _props
const {transactionsStore, userSettingsStore} = useStores()
+2 -6
View File
@@ -24,7 +24,7 @@ import {
Loading,
BottomModal,
} from '../components'
import {WalletStackScreenProps} from '../navigation'
import {TransactionsStackScreenProps, WalletStackScreenProps} from '../navigation'
import {useHeader} from '../utils/useHeader'
import {useStores} from '../models'
import {GroupedByTimeAgo, maxTransactionsInModel} from '../models/TransactionsStore'
@@ -34,10 +34,6 @@ import {TransactionListItem} from './Transactions/TransactionListItem'
import { Transaction, TransactionStatus } from '../models/Transaction'
import { height } from '@fortawesome/free-solid-svg-icons/faWallet'
interface TranHistoryScreenProps
extends WalletStackScreenProps<'TranHistory'> {}
if (Platform.OS === 'android' &&
UIManager.setLayoutAnimationEnabledExperimental) {
UIManager.setLayoutAnimationEnabledExperimental(true)
@@ -45,7 +41,7 @@ if (Platform.OS === 'android' &&
// Number of transactions held in TransactionsStore model
const limit = maxTransactionsInModel
export const TranHistoryScreen: FC<TranHistoryScreenProps> = observer(function TranHistoryScreen(_props) {
export const TranHistoryScreen: FC<TransactionsStackScreenProps<'TranHistory'>> = observer(function TranHistoryScreen(_props) {
const {navigation} = _props
const {transactionsStore, proofsStore, mintsStore} = useStores()
useHeader({
@@ -1,4 +1,4 @@
import formatDistance from 'date-fns/formatDistance'
import {formatDistance} from 'date-fns/formatDistance'
import {observer} from 'mobx-react-lite'
import React from 'react'
import {ScrollView, TextStyle, View, ViewStyle} from 'react-native'
+25 -8
View File
@@ -83,9 +83,9 @@ export const WalletScreen: FC<WalletScreenProps> = observer(
transactionsStore,
paymentRequestsStore,
userSettingsStore,
walletProfileStore
} = useStores()
const pagerRef = useRef<PagerView>(null)
const appState = useRef(AppState.currentState)
const isInternetReachable = useIsInternetReachable()
const returnWithNavigationReset = route.params?.returnWithNavigationReset
@@ -158,7 +158,10 @@ export const WalletScreen: FC<WalletScreenProps> = observer(
WalletTask.handleInFlight().catch(e => false)
// Create websocket subscriptions to receive tokens or payment requests by NOSTR DMs
WalletTask.receiveEventsFromRelays().catch(e => false)
// log.trace('[getInitialData]', 'walletProfile', walletProfileStore)
// log.trace('[getInitialData]', 'walletProfile', walletProfileStore)
const preferredUnit: MintUnit = userSettingsStore.preferredUnit
const pageIndex = groupedMints.findIndex(m => m.unit === preferredUnit)
pagerRef.current && pagerRef.current.setPage(pageIndex)
}
Linking.addEventListener('url', handleDeeplink)
@@ -172,7 +175,11 @@ export const WalletScreen: FC<WalletScreenProps> = observer(
try {
const incomingData = IncomingParser.findAndExtract(url)
await IncomingParser.navigateWithIncomingData(incomingData, navigation)
await IncomingParser.navigateWithIncomingData(
incomingData,
navigation,
currentUnit
)
} catch (e: any) {
handleError(e)
@@ -335,8 +342,7 @@ export const WalletScreen: FC<WalletScreenProps> = observer(
/* Mints pager */
const width = spacing.screenWidth
const pagerRef = useRef<PagerView>(null)
const width = spacing.screenWidth
const scrollOffsetAnimatedValue = React.useRef(new Animated.Value(0)).current
const positionAnimatedValue = React.useRef(new Animated.Value(0)).current
const inputRange = [0, groupedMints.length]
@@ -369,10 +375,21 @@ export const WalletScreen: FC<WalletScreenProps> = observer(
)
const onPageSelected = (e: any) => {
const currentUnit = groupedMints[e.nativeEvent.position].unit
const onPageSelected = (e: any) => {
if(groupedMints.length === 0) {
return
}
const currentUnit = groupedMints[e.nativeEvent.position]?.unit
log.trace('[onPageSelected] currentUnit', currentUnit)
setCurrentUnit(currentUnit)
const preferredUnit = userSettingsStore.preferredUnit
if(currentUnit !== preferredUnit) { // prevents db write on first load
userSettingsStore.setPreferredUnit(currentUnit)
}
}
const handleError = function (e: AppError) {
@@ -442,7 +459,7 @@ export const WalletScreen: FC<WalletScreenProps> = observer(
ref={pagerRef}
style={{flexGrow: 1}}
onPageScroll={onPageScroll}
onPageSelected={onPageSelected}
onPageSelected={onPageSelected}
>
{groupedMints.map((mints) => (
<View key={mints.unit}>
+12 -9
View File
@@ -136,24 +136,24 @@ const navigateWithIncomingData = async function (
encoded: any
},
navigation: StackNavigationProp<any>,
mintAndUnit?: {
mintUrl: string,
unit: MintUnit
}
unit: MintUnit,
mintUrl?: string
) {
switch (incoming.type) {
case IncomingDataType.CASHU:
return navigation.navigate('Receive', {
encodedToken: incoming.encoded,
...mintAndUnit
unit,
mintUrl
})
case IncomingDataType.INVOICE:
return navigation.navigate('Transfer', {
encodedInvoice: incoming.encoded,
paymentOption: SendOption.PASTE_OR_SCAN_INVOICE,
...mintAndUnit
unit,
mintUrl
})
case (IncomingDataType.LNURL):
@@ -165,7 +165,8 @@ const navigateWithIncomingData = async function (
return navigation.navigate('Topup', {
lnurlParams,
paymentOption: ReceiveOption.LNURL_WITHDRAW,
...mintAndUnit
unit,
mintUrl
})
}
@@ -173,7 +174,8 @@ const navigateWithIncomingData = async function (
return navigation.navigate('Transfer', {
lnurlParams,
paymentOption: SendOption.LNURL_PAY,
...mintAndUnit
unit,
mintUrl
})
}
@@ -192,7 +194,8 @@ const navigateWithIncomingData = async function (
return navigation.navigate('Transfer', {
lnurlParams: addressParamsResult.lnurlParams,
paymentOption: SendOption.LNURL_PAY,
...mintAndUnit
unit,
mintUrl
})
} catch (e: any) {
throw new AppError(Err.SERVER_ERROR, 'Could not get Lightning address details from the server.', {
-2
View File
@@ -23,7 +23,6 @@ import AppError, { Err } from '../utils/AppError'
import { MinibitsClient } from './minibitsService'
import { rootStoreInstance } from '../models'
import { WalletTask } from './walletService'
import { WalletTask } from './walletService'
export {
NostrEvent,
@@ -204,7 +203,6 @@ const decryptNip04 = async function(
const publish = async function (
event: NostrUnsignedEvent,
relays: string[],
): Promise<NostrEvent | undefined> {
): Promise<NostrEvent | undefined> {
const keys: KeyPair = await getOrCreateKeyPair()
+22 -7
View File
@@ -16,7 +16,6 @@ import {log} from './logService'
import {LogLevel} from './log/logTypes'
import {BackupProof} from '../models/Proof'
import { CashuUtils } from './cashu/cashuUtils'
import { Contact, ContactType } from '../models/Contact'
let _db: QuickSQLiteConnection
@@ -71,7 +70,8 @@ const _createOrUpdateSchema = function (db: QuickSQLiteConnection) {
[
`CREATE TABLE IF NOT EXISTS usersettings (
id INTEGER PRIMARY KEY NOT NULL,
walletId TEXT,
walletId TEXT,
preferredUnit TEXT,
isOnboarded BOOLEAN,
isStorageEncrypted BOOLEAN,
isLocalBackupOn BOOLEAN,
@@ -211,6 +211,9 @@ const _runMigrations = function (db: QuickSQLiteConnection) {
], [
`ALTER TABLE proofs
ADD COLUMN unit TEXT`,
],[
`ALTER TABLE usersettings
ADD COLUMN preferredUnit TEXT`,
])
log.info(`Prepared database migrations from ${currentVersion} -> 9`)
@@ -332,7 +335,8 @@ const getUserSettings = function (): UserSettings {
if (!rows?.item(0)) {
const walletId = _generateWalletId()
const defaultSettings = updateUserSettings({
walletId,
walletId,
preferredUnit: 'sat',
isOnboarded: 0,
isStorageEncrypted: 0,
isLocalBackupOn: 1,
@@ -358,15 +362,26 @@ const getUserSettings = function (): UserSettings {
const updateUserSettings = function (settings: UserSettings): UserSettings {
try {
const now = new Date()
const {walletId, isOnboarded, isStorageEncrypted, isLocalBackupOn, isTorDaemonOn, isLoggerOn, isStorageMigrated, logLevel} = settings
const {
walletId,
preferredUnit,
isOnboarded,
isStorageEncrypted,
isLocalBackupOn,
isTorDaemonOn,
isLoggerOn,
isStorageMigrated,
logLevel
} = settings
const query = `
INSERT OR REPLACE INTO usersettings (id, walletId, isOnboarded, isStorageEncrypted, isLocalBackupOn, isTorDaemonOn, isLoggerOn, isStorageMigrated, logLevel, createdAt)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
INSERT OR REPLACE INTO usersettings (id, walletId, preferredUnit, isOnboarded, isStorageEncrypted, isLocalBackupOn, isTorDaemonOn, isLoggerOn, isStorageMigrated, logLevel, createdAt)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`
const params = [
1,
walletId,
walletId,
preferredUnit,
isOnboarded,
isStorageEncrypted,
isLocalBackupOn,
+1 -1
View File
@@ -137,7 +137,7 @@ export const sendTask = async function (
WalletTask.handleSpentByMint,
{
interval: 6 * 1000,
maxPolls: 1, // TODO 10
maxPolls: 10,
maxErrors: 2
},
{mintUrl, isPending: true}