Upgrade to RN077

This commit is contained in:
minibits-cash
2025-02-04 08:35:31 +01:00
parent 9e057ba698
commit 6fd930e851
6 changed files with 391 additions and 393 deletions
+1 -1
View File
@@ -7,4 +7,4 @@ insert_final_newline = true
[*.{js,json,yml}] [*.{js,json,yml}]
charset = utf-8 charset = utf-8
indent_style = space indent_style = space
indent_size = 2 indent_size = 4
@@ -1,13 +0,0 @@
diff --git a/node_modules/react-native-nitro-sqlite/cpp/operations.cpp b/node_modules/react-native-nitro-sqlite/cpp/operations.cpp
index 0655754..88e80cd 100644
--- a/node_modules/react-native-nitro-sqlite/cpp/operations.cpp
+++ b/node_modules/react-native-nitro-sqlite/cpp/operations.cpp
@@ -165,7 +165,7 @@ SQLiteExecuteQueryResult sqliteExecute(const std::string& dbName, const std::str
switch (column_type) {
case SQLITE_INTEGER: {
- auto column_value = sqlite3_column_int64(statement, i);
+ auto column_value = sqlite3_column_double(statement, i);
row[column_name] = column_value;
break;
}
+22 -22
View File
@@ -11,18 +11,18 @@ export interface TransactionRecord {
fee: number fee: number
unit: MintUnit unit: MintUnit
data: string data: string
sentFrom?: string sentFrom?: string | null
sentTo?: string sentTo?: string | null
profile?: string profile?: string | null
memo?: string memo?: string | null
zapRequest?: string zapRequest?: string | null
inputToken?: string inputToken?: string | null
outputToken?: string outputToken?: string | null
proof?: string proof?: string | null
mint: string mint: string
balanceAfter?: number balanceAfter?: number | null
noteToSelf?: string noteToSelf?: string | null
tags?: Array<string> tags?: Array<string> | null
status: TransactionStatus status: TransactionStatus
createdAt: Date createdAt: Date
} }
@@ -63,18 +63,18 @@ export const TransactionModel = types
fee: types.optional(types.integer, 0), fee: types.optional(types.integer, 0),
unit: types.frozen<MintUnit>(), unit: types.frozen<MintUnit>(),
data: types.string, data: types.string,
sentFrom: types.maybe(types.string), sentFrom: types.maybe(types.maybeNull(types.string)),
sentTo: types.maybe(types.string), sentTo: types.maybe(types.maybeNull(types.string)),
profile: types.maybe(types.string), profile: types.maybe(types.maybeNull(types.string)),
memo: types.maybe(types.string), memo: types.maybe(types.maybeNull(types.string)),
mint: types.string, mint: types.string,
zapRequest: types.maybe(types.string), zapRequest: types.maybe(types.maybeNull(types.string)),
inputToken: types.maybe(types.string), inputToken: types.maybe(types.maybeNull(types.string)),
outputToken: types.maybe(types.string), outputToken: types.maybe(types.maybeNull(types.string)),
proof: types.maybe(types.string), proof: types.maybe(types.maybeNull(types.string)),
balanceAfter: types.maybe(types.integer), balanceAfter: types.maybe(types.maybeNull(types.integer)),
noteToSelf: types.maybe(types.string), noteToSelf: types.maybe(types.maybeNull(types.string)),
tags: types.maybe(types.array(types.string)), tags: types.maybe(types.maybeNull(types.array(types.string))),
status: types.frozen<TransactionStatus>(), status: types.frozen<TransactionStatus>(),
createdAt: types.optional(types.Date, new Date()), createdAt: types.optional(types.Date, new Date()),
}) })
+289 -289
View File
@@ -1,340 +1,340 @@
import { import {
Instance, Instance,
SnapshotOut, SnapshotOut,
types, types,
flow, flow,
detach, detach,
} from 'mobx-state-tree' } from 'mobx-state-tree'
import {withSetPropAction} from './helpers/withSetPropAction' import {withSetPropAction} from './helpers/withSetPropAction'
import { import {
TransactionModel, TransactionModel,
Transaction, Transaction,
TransactionStatus, TransactionStatus,
TransactionRecord, TransactionRecord,
} from './Transaction' } from './Transaction'
import {Database} from '../services' import {Database} from '../services'
import {log} from '../services/logService' import {log} from '../services/logService'
import { getRootStore } from './helpers/getRootStore' import { getRootStore } from './helpers/getRootStore'
import { formatDistance } from 'date-fns' import { formatDistance } from 'date-fns'
import { MintUnit } from '../services/wallet/currency' import { MintUnit } from '../services/wallet/currency'
import { Mint } from './Mint' import { Mint } from './Mint'
export const maxTransactionsInHistory = 10 export const maxTransactionsInHistory = 10
export const maxTransactionsByUnit = 3 export const maxTransactionsByUnit = 3
export type GroupedByTimeAgo = { export type GroupedByTimeAgo = {
[timeAgo: string]: Transaction[]; [timeAgo: string]: Transaction[];
} }
export const TransactionsStoreModel = types export const TransactionsStoreModel = types
.model('TransactionsStore', { .model('TransactionsStore', {
transactionsMap: types.map(TransactionModel), transactionsMap: types.map(TransactionModel),
history: types.array(types.safeReference(TransactionModel, { acceptsUndefined: false })), history: types.array(types.safeReference(TransactionModel, { acceptsUndefined: false })),
recentByUnit: types.array(types.safeReference(TransactionModel, { acceptsUndefined: false })), recentByUnit: types.array(types.safeReference(TransactionModel, { acceptsUndefined: false })),
}) })
.actions(withSetPropAction) .actions(withSetPropAction)
.views(self => ({ .views(self => ({
get pendingHistory() { get pendingHistory() {
return self.history return self.history
.slice() .slice()
.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime()) .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
.filter(t => t.status === TransactionStatus.PENDING) .filter(t => t.status === TransactionStatus.PENDING)
}, },
get historyByTimeAgo() { get historyByTimeAgo() {
return self.history return self.history
.slice() .slice()
.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime()) .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
.reduce((groups: GroupedByTimeAgo, transaction: Transaction) => { .reduce((groups: GroupedByTimeAgo, transaction: Transaction) => {
const timeAgo = formatDistance(transaction.createdAt as Date, new Date(), {addSuffix: true}) const timeAgo = formatDistance(transaction.createdAt as Date, new Date(), {addSuffix: true})
if (!groups[timeAgo]) { if (!groups[timeAgo]) {
groups[timeAgo] = [] groups[timeAgo] = []
} }
groups[timeAgo].push(transaction) groups[timeAgo].push(transaction)
return groups return groups
}, {}) }, {})
}, },
get historyPendingByTimeAgo() { get historyPendingByTimeAgo() {
return this.pendingHistory.reduce((groups: GroupedByTimeAgo, transaction: Transaction) => { return this.pendingHistory.reduce((groups: GroupedByTimeAgo, transaction: Transaction) => {
const timeAgo = formatDistance(transaction.createdAt as Date, new Date(), {addSuffix: true}) const timeAgo = formatDistance(transaction.createdAt as Date, new Date(), {addSuffix: true})
if (!groups[timeAgo]) { if (!groups[timeAgo]) {
groups[timeAgo] = [] groups[timeAgo] = []
} }
groups[timeAgo].push(transaction) groups[timeAgo].push(transaction)
return groups return groups
}, {}) }, {})
}, },
get historyCount() { get historyCount() {
return self.history.length return self.history.length
}, },
get pendingHistoryCount() { get pendingHistoryCount() {
return this.pendingHistory.length return this.pendingHistory.length
}, },
getRecentByUnit(unit: MintUnit) { getRecentByUnit(unit: MintUnit) {
return self.recentByUnit return self.recentByUnit
.slice() .slice()
.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime()) .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
.filter(t => t.unit === unit) .filter(t => t.unit === unit)
}, },
countRecentByUnit(unit: MintUnit) { countRecentByUnit(unit: MintUnit) {
return this.getRecentByUnit(unit).length return this.getRecentByUnit(unit).length
} }
})) }))
.actions(self => ({ .actions(self => ({
findById(id: number, loadTokens?: boolean) { findById(id: number, loadTokens?: boolean) {
let transaction = self.transactionsMap.get(id) let transaction = self.transactionsMap.get(id)
// Search the db and add if tx is not in the state // Search the db and add if tx is not in the state
// Search always to retrieve full tokens in tx detail screen // Search always to retrieve full tokens in tx detail screen
if(!transaction || loadTokens === true) { if(!transaction || loadTokens === true) {
const dbTransaction = Database.getTransactionById(id) const dbTransaction = Database.getTransactionById(id)
if(dbTransaction) { if(dbTransaction) {
const createdAt = new Date(dbTransaction.createdAt) const createdAt = new Date(dbTransaction.createdAt)
const inStoreTransaction = {...dbTransaction, createdAt} const inStoreTransaction = {...dbTransaction, createdAt}
const {id} = dbTransaction const {id} = dbTransaction
if(!loadTokens) { if(!loadTokens) {
// Shorten for performance reasons // Shorten for performance reasons
if(inStoreTransaction.inputToken && inStoreTransaction.inputToken.length > 0) { if(inStoreTransaction.inputToken && inStoreTransaction.inputToken.length > 0) {
inStoreTransaction.inputToken = inStoreTransaction.inputToken?.slice(0, 40) inStoreTransaction.inputToken = inStoreTransaction.inputToken?.slice(0, 40)
} }
if(inStoreTransaction.outputToken && inStoreTransaction.outputToken.length > 0) { if(inStoreTransaction.outputToken && inStoreTransaction.outputToken.length > 0) {
inStoreTransaction.outputToken = inStoreTransaction.outputToken?.slice(0, 40) inStoreTransaction.outputToken = inStoreTransaction.outputToken?.slice(0, 40)
} }
} }
self.transactionsMap.set(id, inStoreTransaction) self.transactionsMap.set(id, inStoreTransaction)
transaction = self.transactionsMap.get(id) transaction = self.transactionsMap.get(id)
} }
} }
return transaction return transaction
}, },
pruneRecentByUnit(unit: MintUnit) { pruneRecentByUnit(unit: MintUnit) {
const unitCount = self.countRecentByUnit(unit) const unitCount = self.countRecentByUnit(unit)
log.trace('[pruneRecentByUnit]', {unit, unitCount}) log.trace('[pruneRecentByUnit]', {unit, unitCount})
if (unitCount > maxTransactionsByUnit) { if (unitCount > maxTransactionsByUnit) {
const transactionsToRemove = self.getRecentByUnit(unit) const transactionsToRemove = self.getRecentByUnit(unit)
.slice() .slice()
.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime()) .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
.splice(maxTransactionsByUnit) .splice(maxTransactionsByUnit)
self.recentByUnit.replace(self.recentByUnit.filter(t => !transactionsToRemove.some(removed => removed.id === t.id))) self.recentByUnit.replace(self.recentByUnit.filter(t => !transactionsToRemove.some(removed => removed.id === t.id)))
log.trace('[pruneRecentByUnit]', `${transactionsToRemove.length} pruned from recentByUnit`) log.trace('[pruneRecentByUnit]', `${transactionsToRemove.length} pruned from recentByUnit`)
} }
}, },
pruneRecentWithoutCurrentMint() { pruneRecentWithoutCurrentMint() {
const rootStore = getRootStore(self) const rootStore = getRootStore(self)
const {mintsStore} = rootStore const {mintsStore} = rootStore
const transactionsToRemove = self.recentByUnit.filter(transaction => { const transactionsToRemove = self.recentByUnit.filter(transaction => {
// Check if the mint property of the transaction does not exist in the mints array // Check if the mint property of the transaction does not exist in the mints array
return !mintsStore.allMints.some((mint: Mint) => mint.mintUrl === transaction.mint); return !mintsStore.allMints.some((mint: Mint) => mint.mintUrl === transaction.mint);
}) })
self.recentByUnit.replace(self.recentByUnit.filter(t => !transactionsToRemove.some(removed => removed.id === t.id))) self.recentByUnit.replace(self.recentByUnit.filter(t => !transactionsToRemove.some(removed => removed.id === t.id)))
log.trace('[pruneRecentWithoutCurrentMint]', `${transactionsToRemove.length} pruned from recentByUnit`) log.trace('[pruneRecentWithoutCurrentMint]', `${transactionsToRemove.length} pruned from recentByUnit`)
}, },
pruneHistory() { pruneHistory() {
// Step 1: Trim history to keep only the MAX_HISTORY_TRANSACTIONS most recent // Step 1: Trim history to keep only the MAX_HISTORY_TRANSACTIONS most recent
if (self.history.length > maxTransactionsInHistory) { if (self.history.length > maxTransactionsInHistory) {
const transactionsToRemove = self.history const transactionsToRemove = self.history
.slice() .slice()
.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime()) .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
.splice(maxTransactionsInHistory) .splice(maxTransactionsInHistory)
self.history.replace(self.history.filter(t => !transactionsToRemove.some(removed => removed.id === t.id))) self.history.replace(self.history.filter(t => !transactionsToRemove.some(removed => removed.id === t.id)))
log.trace('[pruneHistory]', `${transactionsToRemove.length} pruned from history`) log.trace('[pruneHistory]', `${transactionsToRemove.length} pruned from history`)
} }
}, },
removeAllHistory() { removeAllHistory() {
self.history.clear() self.history.clear()
log.debug('[removeAllHistory]', 'Removed all transactions from history') log.debug('[removeAllHistory]', 'Removed all transactions from history')
}, },
removeAllRecentByUnit() { removeAllRecentByUnit() {
self.recentByUnit.clear() self.recentByUnit.clear()
log.debug('[removeAllRecentByUnit]', 'Removed all transactions from recentByUnit') log.debug('[removeAllRecentByUnit]', 'Removed all transactions from recentByUnit')
}, },
removeAllTransactions() { removeAllTransactions() {
self.recentByUnit.clear() self.recentByUnit.clear()
self.history.clear() self.history.clear()
self.transactionsMap.clear() self.transactionsMap.clear()
log.debug('[removeAllTransactions]', 'Removed all transactions from TransactionsStore') log.debug('[removeAllTransactions]', 'Removed all transactions from TransactionsStore')
}, },
})) }))
.actions(self => ({ .actions(self => ({
addTransaction: flow(function* addTransaction(newTransaction){ addTransaction: flow(function* addTransaction(newTransaction){
// First let's store the transaction into the database // First let's store the transaction into the database
const dbTransaction: TransactionRecord = yield Database.addTransactionAsync(newTransaction) const dbTransaction: TransactionRecord = yield Database.addTransactionAsync(newTransaction)
// Add the new transaction to the transactions store // Add the new transaction to the transactions store
const createdAt = new Date(dbTransaction.createdAt) const createdAt = new Date(dbTransaction.createdAt)
const inStoreTransaction = {...dbTransaction, createdAt} const inStoreTransaction = {...dbTransaction, createdAt}
const {id} = dbTransaction const {id} = dbTransaction
if (!self.transactionsMap.has(id)) { if (!self.transactionsMap.has(id)) {
self.transactionsMap.set(id, inStoreTransaction) self.transactionsMap.set(id, inStoreTransaction)
} }
const reference = self.transactionsMap.get(id) const reference = self.transactionsMap.get(id)
self.history.unshift(reference!) self.history.unshift(reference!)
self.recentByUnit.unshift(reference!) self.recentByUnit.unshift(reference!)
// log.trace('[addTransaction]', 'New transaction added to the TransactionsStore', {id}) // log.trace('[addTransaction]', 'New transaction added to the TransactionsStore', {id})
// Purge the oldest references from cache, but keep some for each mint // Purge the oldest references from cache, but keep some for each mint
self.pruneRecentByUnit(newTransaction.unit) self.pruneRecentByUnit(newTransaction.unit)
self.pruneHistory() self.pruneHistory()
return reference as Transaction return reference as Transaction
}), }),
addToHistory(limit: number, offset: number, onlyPending: boolean){ addToHistory(limit: number, offset: number, onlyPending: boolean){
// Appends transaction to the map and adds reference to history from database. // Appends transaction to the map and adds reference to history from database.
const dbTransactions = Database.getTransactions(limit, offset, onlyPending) const result = Database.getTransactions(limit, offset, onlyPending)
log.trace('[addToHistory] dbResult ids', {ids: dbTransactions.map(t => t.id)}) log.trace('[addToHistory] dbResult ids', {ids: result?._array.map(t => t.id)})
if (dbTransactions && dbTransactions.length > 0) { if (result && result.length > 0) {
for (const dbTransaction of dbTransactions) { for (const dbTransaction of result._array) {
const createdAt = new Date(dbTransaction.createdAt) const createdAt = new Date(dbTransaction.createdAt)
const inStoreTransaction = {...dbTransaction, createdAt} const inStoreTransaction = {...dbTransaction, createdAt}
// Shorten for performance reasons // Shorten for performance reasons
if(inStoreTransaction.inputToken && inStoreTransaction.inputToken.length > 0) { if(inStoreTransaction.inputToken && inStoreTransaction.inputToken.length > 0) {
inStoreTransaction.inputToken = inStoreTransaction.inputToken?.slice(0, 40) inStoreTransaction.inputToken = inStoreTransaction.inputToken?.slice(0, 40)
} }
if(inStoreTransaction.outputToken && inStoreTransaction.outputToken.length > 0) { if(inStoreTransaction.outputToken && inStoreTransaction.outputToken.length > 0) {
inStoreTransaction.outputToken = inStoreTransaction.outputToken?.slice(0, 40) inStoreTransaction.outputToken = inStoreTransaction.outputToken?.slice(0, 40)
} }
const {id} = dbTransaction const {id} = dbTransaction
if (!self.transactionsMap.has(id)) { if (!self.transactionsMap.has(id)) {
self.transactionsMap.set(id, inStoreTransaction) self.transactionsMap.set(id, inStoreTransaction)
log.trace('[addToHistory]', `${id} added to transactionsMap`) log.trace('[addToHistory]', `${id} added to transactionsMap`)
} }
const reference = self.transactionsMap.get(id) const reference = self.transactionsMap.get(id)
if (!self.history.find(t => t.id === id)) { if (!self.history.find(t => t.id === id)) {
self.history.push(reference!) self.history.push(reference!)
log.trace('[addToHistory]', `${onlyPending ? 'Pending reference' : 'Reference'} ${id} added to history`) log.trace('[addToHistory]', `${onlyPending ? 'Pending reference' : 'Reference'} ${id} added to history`)
} }
} }
} }
}, },
addRecentByUnit() { addRecentByUnit() {
// Rehydrates recent from database. // Rehydrates recent from database.
const dbTransactions = Database.getRecentTransactionsByUnit(maxTransactionsByUnit) const dbTransactions = Database.getRecentTransactionsByUnit(maxTransactionsByUnit)
if (dbTransactions && dbTransactions.length > 0) { if (dbTransactions && dbTransactions.length > 0) {
for (const dbTransaction of dbTransactions) { for (const dbTransaction of dbTransactions) {
const createdAt = new Date(dbTransaction.createdAt) const createdAt = new Date(dbTransaction.createdAt)
const inStoreTransaction = {...dbTransaction, createdAt} as Transaction const inStoreTransaction = {...dbTransaction, createdAt} as Transaction
// Shorten for performance reasons // Shorten for performance reasons
if(inStoreTransaction.inputToken && inStoreTransaction.inputToken.length > 0) { if(inStoreTransaction.inputToken && inStoreTransaction.inputToken.length > 0) {
inStoreTransaction.inputToken = inStoreTransaction.inputToken?.slice(0, 40) inStoreTransaction.inputToken = inStoreTransaction.inputToken?.slice(0, 40)
} }
if(inStoreTransaction.outputToken && inStoreTransaction.outputToken.length > 0) { if(inStoreTransaction.outputToken && inStoreTransaction.outputToken.length > 0) {
inStoreTransaction.outputToken = inStoreTransaction.outputToken?.slice(0, 40) inStoreTransaction.outputToken = inStoreTransaction.outputToken?.slice(0, 40)
} }
const {id} = dbTransaction const {id} = dbTransaction
if (!self.transactionsMap.has(id)) { if (!self.transactionsMap.has(id)) {
self.transactionsMap.set(id, inStoreTransaction) self.transactionsMap.set(id, inStoreTransaction)
} }
const reference = self.transactionsMap.get(id) const reference = self.transactionsMap.get(id)
if (!self.recentByUnit.find(t => t.id === id)) { if (!self.recentByUnit.find(t => t.id === id)) {
self.recentByUnit.push(reference!) self.recentByUnit.push(reference!)
log.trace('[addRecentByUnit]', `Transaction ${inStoreTransaction.id} added to recentByUnit`) log.trace('[addRecentByUnit]', `Transaction ${inStoreTransaction.id} added to recentByUnit`)
} }
} }
} }
}, },
updateStatuses: flow(function* updateStatuses( updateStatuses: flow(function* updateStatuses(
ids: number[], ids: number[],
status: TransactionStatus, status: TransactionStatus,
data: string, data: string,
) { ) {
// Update status and amend to existing data in database // Update status and amend to existing data in database
yield Database.updateStatusesAsync(ids, status, data) yield Database.updateStatusesAsync(ids, status, data)
// Update the model status and amend related tx data // Update the model status and amend related tx data
for (const id of ids) { for (const id of ids) {
const transactionInstance = self.transactionsMap.get(id) const transactionInstance = self.transactionsMap.get(id)
if (transactionInstance) { if (transactionInstance) {
transactionInstance.status = status transactionInstance.status = status
// Awkward but I want to keep function signature aligned with single status update // Awkward but I want to keep function signature aligned with single status update
const updatedData = JSON.parse(transactionInstance.data) const updatedData = JSON.parse(transactionInstance.data)
updatedData.push(JSON.parse(data)) updatedData.push(JSON.parse(data))
transactionInstance.data = JSON.stringify(updatedData) transactionInstance.data = JSON.stringify(updatedData)
} }
log.trace('[updateStatuses]', 'Transaction statuses and data updated in TransactionsStore', {ids, status}) log.trace('[updateStatuses]', 'Transaction statuses and data updated in TransactionsStore', {ids, status})
} }
}), }),
deleteByStatus(status: TransactionStatus){ deleteByStatus(status: TransactionStatus){
self.transactionsMap.forEach((transaction, transactionId) => { self.transactionsMap.forEach((transaction, transactionId) => {
if (transaction.status === status) { if (transaction.status === status) {
self.transactionsMap.delete(transactionId as string) self.transactionsMap.delete(transactionId as string)
} }
}) })
return Database.deleteTransactionsByStatus(status) return Database.deleteTransactionsByStatus(status)
} }
})).postProcessSnapshot((snapshot) => { })).postProcessSnapshot((snapshot) => {
// Trim history if it exceeds the limit // Trim history if it exceeds the limit
let prunedHistory = snapshot.history let prunedHistory = snapshot.history
if (snapshot.history.length > maxTransactionsInHistory) { if (snapshot.history.length > maxTransactionsInHistory) {
// Keep only the most recent transactions within the limit // Keep only the most recent transactions within the limit
const orderedHistory = [...snapshot.history].sort((a, b) => (b as number) - (a as number)) const orderedHistory = [...snapshot.history].sort((a, b) => (b as number) - (a as number))
prunedHistory = orderedHistory.slice(0, maxTransactionsInHistory) prunedHistory = orderedHistory.slice(0, maxTransactionsInHistory)
} }
// Clean up transactionMap: remove transactions not in history or recentByUnit // Clean up transactionMap: remove transactions not in history or recentByUnit
const prunedTransactionsMap = Object.fromEntries( const prunedTransactionsMap = Object.fromEntries(
Object.entries(snapshot.transactionsMap).filter(([transactionId]) => Object.entries(snapshot.transactionsMap).filter(([transactionId]) =>
prunedHistory.includes(parseInt(transactionId)) || prunedHistory.includes(parseInt(transactionId)) ||
snapshot.recentByUnit.includes(parseInt(transactionId)) snapshot.recentByUnit.includes(parseInt(transactionId))
) )
) )
// Return the new snapshot with the trimmed history and filtered transactionMap // Return the new snapshot with the trimmed history and filtered transactionMap
const prunedSnapshot = { const prunedSnapshot = {
...snapshot, ...snapshot,
history: prunedHistory, history: prunedHistory,
transactionsMap: prunedTransactionsMap transactionsMap: prunedTransactionsMap
} }
// console.log('[postProcessSnapshot]', {prunedSnapshot}) // console.log('[postProcessSnapshot]', {prunedSnapshot})
return prunedSnapshot return prunedSnapshot
}) })
const getHostname = function (mintUrl: string) { const getHostname = function (mintUrl: string) {
try { try {
return new URL(mintUrl).hostname return new URL(mintUrl).hostname
} catch (e) { } catch (e) {
return false return false
} }
} }
// refresh // refresh
export interface TransactionsStore export interface TransactionsStore
extends Instance<typeof TransactionsStoreModel> {} extends Instance<typeof TransactionsStoreModel> {}
export interface TransactionsStoreSnapshot export interface TransactionsStoreSnapshot
extends SnapshotOut<typeof TransactionsStoreModel> {} extends SnapshotOut<typeof TransactionsStoreModel> {}
+26 -13
View File
@@ -4,7 +4,7 @@ import { isObj } from '@cashu/cashu-ts/src/utils'
import Clipboard from '@react-native-clipboard/clipboard' import Clipboard from '@react-native-clipboard/clipboard'
import { observer } from 'mobx-react-lite' import { observer } from 'mobx-react-lite'
import { getSnapshot } from 'mobx-state-tree' import { getSnapshot } from 'mobx-state-tree'
import { DimensionValue, LayoutAnimation, Platform, TextStyle, UIManager, View, ViewStyle } from 'react-native' import { DimensionValue, Image, LayoutAnimation, Platform, TextStyle, UIManager, View, ViewStyle } from 'react-native'
import JSONTree from 'react-native-json-tree' import JSONTree from 'react-native-json-tree'
import { import {
$sizeStyles, $sizeStyles,
@@ -157,22 +157,35 @@ export const MintInfoScreen: FC<SettingsStackScreenProps<'MintInfo'>> = observer
return ( return (
<Screen contentContainerStyle={$screen} preset="scroll"> <Screen contentContainerStyle={$screen} preset="scroll">
<View style={[$headerContainer, {backgroundColor: headerBg, justifyContent: 'space-around', paddingBottom: spacing.huge}]}> <View style={[$headerContainer, {backgroundColor: headerBg, justifyContent: 'space-around', paddingBottom: spacing.huge}]}>
<View {mintInfo && mintInfo.icon_url ? (
style={{ <Image
marginEnd: spacing.small, style={
flex: 0, {
borderRadius: spacing.small, width: spacing.extraLarge,
padding: spacing.extraSmall, height: spacing.extraLarge,
backgroundColor: colors.palette.orange600 borderRadius: spacing.small,
}} }
> }
<SvgXml source={{uri: mintInfo.icon_url}}
/>
):(
<View
style={{
marginEnd: spacing.small,
flex: 0,
borderRadius: spacing.small,
padding: spacing.extraSmall,
backgroundColor: colors.palette.orange600
}}
>
<SvgXml
width={spacing.medium} width={spacing.medium}
height={spacing.medium} height={spacing.medium}
xml={MintIcon} xml={MintIcon}
fill='white' fill='white'
/> />
</View> </View>
)}
<Text preset='subheading' text={mintInfo?.name ?? mint?.shortname} style={{color: headerTitle}}/> <Text preset='subheading' text={mintInfo?.name ?? mint?.shortname} style={{color: headerTitle}}/>
{mint?.units && ( {mint?.units && (
<View style={{flexDirection: 'row'}}> <View style={{flexDirection: 'row'}}>
@@ -494,7 +507,7 @@ function ContactCard(props: { info: GetInfoResponse, popupMessage: (msg: string)
} }
/** don't render these because they're rendered in separate components */ /** don't render these because they're rendered in separate components */
const detailsHiddenKeys = new Set(['name', 'motd', 'description', 'description_long', 'nuts', 'contact']) const detailsHiddenKeys = new Set(['name', 'motd', 'description', 'description_long', 'nuts', 'contact', 'icon_url', 'time'])
/** key-value pairs of details about the mint */ /** key-value pairs of details about the mint */
function MintInfoDetails(props: { info: GetInfoResponse, popupMessage: (msg: string) => void }) { function MintInfoDetails(props: { info: GetInfoResponse, popupMessage: (msg: string) => void }) {
-2
View File
@@ -18,9 +18,7 @@ import {
import codePush, { RemotePackage } from 'react-native-code-push' import codePush, { RemotePackage } from 'react-native-code-push'
import {moderateScale, verticalScale} from '@gocodingnow/rn-size-matters' import {moderateScale, verticalScale} from '@gocodingnow/rn-size-matters'
import { SvgXml } from 'react-native-svg' import { SvgXml } from 'react-native-svg'
import notifee, { AndroidImportance } from '@notifee/react-native'
import { NavigationState, Route, TabBar, TabView } from 'react-native-tab-view' import { NavigationState, Route, TabBar, TabView } from 'react-native-tab-view'
import { NotificationService, TASK_QUEUE_CHANNEL_ID, TASK_QUEUE_CHANNEL_NAME } from '../services/notificationService'
import {useThemeColor, spacing, colors, typography} from '../theme' import {useThemeColor, spacing, colors, typography} from '../theme'
import { import {
Button, Button,