Skip to content

Commit

Permalink
feat: add depositTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
classicalliu committed Nov 14, 2019
1 parent 98ba68d commit 108d5b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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

0 comments on commit 108d5b1

Please sign in to comment.