Skip to content

RealUnit Admin: getAdminTransactions misses transactions without requestId #3191

@TaprootFreak

Description

@TaprootFreak

Bug

getAdminTransactions in RealUnitService returns only 3 of 32 actual REALU transactions on dev because it queries via transaction_request join.

Root Cause

TransactionService.getByAssetId() (src/subdomains/supporting/payment/services/transaction.service.ts:259) joins transactiontransaction_request and filters by request.targetId / request.sourceId:

.leftJoinAndSelect('transaction.request', 'request')
.where('transaction.type IS NOT NULL')
.andWhere(
  new Brackets((qb) =>
    qb
      .where('request.type = :buyType AND request.targetId = :assetId', { buyType: 'Buy', assetId })
      .orWhere('request.type = :sellType AND request.sourceId = :assetId', { sellType: 'Sell', assetId }),
  ),
)

However, most BuyCrypto transactions have requestId = NULL in the transaction table (21 of 22 on dev). These transactions are linked to REALU only via buy_crypto.transactionIdbuy.assetId, a path the current query doesn't follow.

Dev DB Analysis

Total Found by current query
BuyCrypto (Buy) 22 1
BuyFiat (Sell) 10 2
Total 32 3

Expected Behavior

All completed REALU transactions should appear in the admin "Received Transactions" view, regardless of whether they have a transaction_request linked.

Suggested Fix

Extend getByAssetId() to also find transactions via buy_crypto.transactionId / buy_fiat.transactionId when requestId is NULL, e.g.:

-- Current path (works for 3)
transaction → transaction_request (targetId/sourceId = assetId)

-- Missing path (needed for the other 29)
transaction ← buy_crypto.transactionIdbuy.assetId = assetId
transaction ← buy_fiat.transactionIdcrypto_input.assetId = assetId

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions