diff --git a/.github/workflows/jsCodePush-TEST.yaml b/.github/workflows/jsCodePush-TEST.yaml index c30c73f9..0f4aaf71 100644 --- a/.github/workflows/jsCodePush-TEST.yaml +++ b/.github/workflows/jsCodePush-TEST.yaml @@ -33,7 +33,13 @@ jobs: # Codepush build will continue only if version changed from previous commit - name: Detect version change run: | - echo "IS_VERSION_CHANGED=true" >> $GITHUB_ENV + if [ "${{ env.PREV_JS_VERSION }}" != "${{ env.CURRENT_JS_VERSION }}" ]; then + echo "IS_VERSION_CHANGED=true" >> $GITHUB_ENV + echo "Detected version change" + else + echo "IS_VERSION_CHANGED=false" >> $GITHUB_ENV + echo "No version change, skipping further processing" + fi # Fetch native app versionName and versionCode from app/build.gradle - name: Get Android native version diff --git a/package.json b/package.json index 3f2b3a65..d14a166c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minibits_wallet", - "version": "0.0.8-alpha.5", + "version": "0.0.8-alpha.6", "private": true, "scripts": { "android:clean": "cd android && ./gradlew clean", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 7341307b..e05dc2c9 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -77,6 +77,7 @@ const en = { lightningFee: "Lightning network fee", memoFromSender: "Memo from sender", sentFrom: "Sent from", + sentTo: "Sent to", type: "Type", status: "Status", balanceAfter: "Balance after this transaction", diff --git a/src/models/ContactsStore.ts b/src/models/ContactsStore.ts index 817a46f9..815e469a 100644 --- a/src/models/ContactsStore.ts +++ b/src/models/ContactsStore.ts @@ -95,8 +95,10 @@ import { self.publicRelay = publicRelay log.info('setPublicRelay', publicRelay) }, - setLastPendingReceivedCheck() { - self.lastPendingReceivedCheck = Math.floor(Date.now() / 1000) + setLastPendingReceivedCheck() { + const ts: number = Math.floor(Date.now() / 1000) + log.trace('Timestamp', {ts}, 'setLastPendingReceivedCheck') + self.lastPendingReceivedCheck = ts }, addReceivedEventId(id: string) { self.receivedEventIds.push(id) diff --git a/src/models/Transaction.ts b/src/models/Transaction.ts index ca4175c4..7126e786 100644 --- a/src/models/Transaction.ts +++ b/src/models/Transaction.ts @@ -49,6 +49,7 @@ export const TransactionModel = types fee: types.maybe(types.maybeNull(types.integer)), data: types.string, sentFrom: types.maybe(types.maybeNull(types.string)), + sentTo: types.maybe(types.maybeNull(types.string)), memo: types.maybe(types.maybeNull(types.string)), balanceAfter: types.maybe(types.maybeNull(types.integer)), noteToSelf: types.maybe(types.maybeNull(types.string)), diff --git a/src/models/TransactionsStore.ts b/src/models/TransactionsStore.ts index 3bc78751..05a52085 100644 --- a/src/models/TransactionsStore.ts +++ b/src/models/TransactionsStore.ts @@ -220,6 +220,15 @@ export const TransactionsStoreModel = types log.trace('Transaction sentFrom updated in TransactionsStore') } }), + updateSentTo: flow(function* updateSentTo(id: number, sentTo: string) { // + + yield Database.updateSentToAsync(id, sentTo) + const transactionInstance = self.findById(id) + if (transactionInstance) { + transactionInstance.sentTo = sentTo + log.trace('Transaction sentTo updated in TransactionsStore') + } + }), removeAllTransactions() { self.transactions.clear() log.info('Removed all transactions from TransactionsStore') diff --git a/src/screens/SendScreen.tsx b/src/screens/SendScreen.tsx index 2193bd99..aad0d51a 100644 --- a/src/screens/SendScreen.tsx +++ b/src/screens/SendScreen.tsx @@ -526,11 +526,18 @@ export const SendScreen: FC> = observer( updated[2].sentToRelays = relaysToShareTo updated[2].sentEvent = sentEvent - await transactionsStore.updateStatus( + await transactionsStore.updateStatus( // status does not change, just add event and relay info to tx.data transactionId, TransactionStatus.PENDING, JSON.stringify(updated) ) + + const txupdate = await transactionsStore.updateSentTo( // set contact to send to to the tx, could be elsewhere // + transactionId, + contactToSendTo?.name+MINIBITS_NIP05_DOMAIN + ) + + log.trace('sentTo tx', txupdate, 'sendAsNostrDM') } else { setInfo('Relay could not confirm that the message has been published') } diff --git a/src/screens/TranDetailScreen.tsx b/src/screens/TranDetailScreen.tsx index 59d5c740..5bb48301 100644 --- a/src/screens/TranDetailScreen.tsx +++ b/src/screens/TranDetailScreen.tsx @@ -417,10 +417,12 @@ const ReceiveInfoBlock = function (props: { label="tranDetailScreen.memoFromSender" value={transaction.memo as string} /> - + {transaction.sentFrom && ( + + )} + {transaction.sentTo && ( + + )} 4`) + } + + // Update db version as a part of migration sqls migrationQueries.push([ `INSERT OR REPLACE INTO dbversion (id, version, createdAt) @@ -591,7 +602,7 @@ const updateSentFromAsync = async function (id: number, sentFrom: string) { const db = getInstance() await db.executeAsync(query, params) - // DO NOT log to Sentry + log.trace('Transaction sentFrom updated', {sentFrom}, 'updateSentFromAsync') const updatedTx = getTransactionById(id as number) @@ -604,7 +615,34 @@ const updateSentFromAsync = async function (id: number, sentFrom: string) { e.message, ) } - } +} + + +const updateSentToAsync = async function (id: number, sentTo: string) { + try { + const query = ` + UPDATE transactions + SET sentTo = ? + WHERE id = ? + ` + const params = [sentTo, id] + + const db = getInstance() + await db.executeAsync(query, params) + + log.trace('Transaction sentTo updated', {sentTo}, 'updateSentToAsync') + + const updatedTx = getTransactionById(id as number) + + return updatedTx as TransactionRecord + } catch (e: any) { + throw new AppError( + Err.DATABASE_ERROR, + 'Could not update transaction sentTo in database', + e.message, + ) + } +} /* const cleanTransactionData = async function (transactionIds: number[]) { try { @@ -891,6 +929,7 @@ export const Database = { updateReceivedAmountAsync, updateNoteAsync, updateSentFromAsync, + updateSentToAsync, getTransactionsAsync, getPendingAmount, addOrUpdateProof, diff --git a/src/services/walletService.ts b/src/services/walletService.ts index 4b46f5ae..bde55f19 100644 --- a/src/services/walletService.ts +++ b/src/services/walletService.ts @@ -124,7 +124,7 @@ const checkPendingReceived = async function () { since: lastPendingReceivedCheck || 0 }] - log.trace('Starting subscription...', filter, 'checkPendingReceived') + log.trace('Creating subscription...', filter, 'checkPendingReceived') const pool = NostrClient.getRelayPool() const sub = pool.sub(NostrClient.getMinibitsRelays(), filter) @@ -132,14 +132,17 @@ const checkPendingReceived = async function () { let events: NostrEvent[] = [] let result: {status: TransactionStatus, message: string} | undefined = undefined - sub.on('event', (event: NostrEvent) => { - contactsStore.setLastPendingReceivedCheck() // conservative choice where to put it + sub.on('event', (event: NostrEvent) => { events.push(event) }) sub.on('eose', async () => { log.trace(`Got ${events.length} receive events`, [], 'checkPendingReceived') + if(events.length > 0) { + contactsStore.setLastPendingReceivedCheck() // listen for changes from last tx to get potentially lost events during past checks + } + let receivedTxCount: number = 0 let errorTxCount: number = 0 let errors: string[] = [] @@ -208,7 +211,7 @@ const checkPendingReceived = async function () { } } - sub.unsub() + // sub.unsub() if(receivedTxCount > 0) { result = {