Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into add-nervos-dao
  • Loading branch information
Keith-CY committed Nov 9, 2019
2 parents 2178f62 + d5ba396 commit 5845ca8
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions packages/neuron-wallet/src/services/cells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,33 @@ export default class CellsService {
.getRepository(OutputEntity)
.createQueryBuilder('output')
.leftJoinAndSelect('output.transaction', 'tx')
.where(`output.status = :status AND output.daoData IS NOT NULL AND output.lockHash in (:...lockHashes) AND tx.blockNumber IS NOT NULL`, {
.where(`output.status <> :deadStatus AND output.daoData IS NOT NULL AND output.lockHash in (:...lockHashes) AND tx.blockNumber IS NOT NULL`, {
lockHashes,
status: OutputStatus.Live,
deadStatus: OutputStatus.Dead,
})
.orderBy(`CASE output.daoData WHEN '0x0000000000000000' THEN 1 ELSE 0 END`, 'ASC')
.addOrderBy('tx.timestamp', 'ASC')
.getMany()

const cells = outputs.map(o => o.toInterface())
for (const o of cells) {
const output = await getConnection()
.getRepository(OutputEntity)
.createQueryBuilder('output')
.leftJoinAndSelect('output.transaction', 'tx')
.where(`(output.outPointTxHash, output.outPointIndex) IN (select outPointTxHash, outPointIndex from input where input.transactionHash = :transactionHash)`, {
transactionHash: o.outPoint!.txHash,
})
.getOne()

if (output) {
o.depositOutPoint = output.outPoint()
if (o.daoData !== '0x0000000000000000') {
const output = await getConnection()
.getRepository(OutputEntity)
.createQueryBuilder('output')
.leftJoinAndSelect('output.transaction', 'tx')
.where(`(output.outPointTxHash, output.outPointIndex) IN (select outPointTxHash, outPointIndex from input where input.transactionHash = :transactionHash)`, {
transactionHash: o.outPoint!.txHash,
})
.getOne()

if (output) {
o.depositOutPoint = output.outPoint()
}
}
}

return outputs.map(o => o.toInterface())
return cells
}

public static getLiveCell = async (outPoint: OutPoint): Promise<Cell | undefined> => {
Expand Down

0 comments on commit 5845ca8

Please sign in to comment.