diff --git a/packages/neuron-wallet/src/services/cells.ts b/packages/neuron-wallet/src/services/cells.ts index c57912479f..ee06a46708 100644 --- a/packages/neuron-wallet/src/services/cells.ts +++ b/packages/neuron-wallet/src/services/cells.ts @@ -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' @@ -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 } diff --git a/packages/neuron-wallet/src/types/cell-types.ts b/packages/neuron-wallet/src/types/cell-types.ts index 804b61575a..776b44eca5 100644 --- a/packages/neuron-wallet/src/types/cell-types.ts +++ b/packages/neuron-wallet/src/types/cell-types.ts @@ -105,6 +105,7 @@ export interface Cell { blockNumber?: string | null blockHash?: string | null depositOutPoint?: OutPoint + depositTimestamp?: string } export interface OutPoint {