Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/neuron-wallet/src/services/cells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CapacityNotEnough, CapacityNotEnoughForChange } from 'exceptions'
import { OutputStatus } from './tx/params'
import FeeMode from 'models/fee-mode'
import { TransactionStatus } from 'types/cell-types'
import TransactionEntity from 'database/chain/entities/transaction'

export const MIN_CELL_CAPACITY = '6100000000'

Expand Down Expand Up @@ -55,6 +56,25 @@ export default class CellsService {

const cells = outputs.map(o => o.toInterface())

const txHashes = outputs.map(output => output.depositTxHash).filter(hash => !!hash)

const txs = await getConnection()
.getRepository(TransactionEntity)
.createQueryBuilder('tx')
.where({
hash: In(txHashes)
})
.getMany()

for (const output of cells) {
if (output.depositOutPoint) {
const tx = txs.filter(t => t.hash === output.depositOutPoint!.txHash)[0]
if (tx) {
output.depositTimestamp = tx.timestamp
}
}
}

return cells
}

Expand Down
1 change: 1 addition & 0 deletions packages/neuron-wallet/src/types/cell-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface Cell {
blockNumber?: string | null
blockHash?: string | null
depositOutPoint?: OutPoint
depositTimestamp?: string
}

export interface OutPoint {
Expand Down