Skip to content

Commit

Permalink
fix: fix filterOutputs for async filter
Browse files Browse the repository at this point in the history
  • Loading branch information
classicalliu committed Aug 28, 2019
1 parent 19c6673 commit c851963
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/neuron-wallet/src/services/sync/check-and-save/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class CheckTx {
}

public check = async (lockHashes: string[]): Promise<string[]> => {
const outputs: Cell[] = this.filterOutputs(lockHashes)
const outputs: Cell[] = await this.filterOutputs(lockHashes)
const inputAddresses = await this.filterInputs(lockHashes)

const outputAddresses: string[] = outputs.map(output => {
Expand All @@ -39,12 +39,17 @@ export default class CheckTx {
return false
}

public filterOutputs = (lockHashes: string[]) => {
const cells: Cell[] = this.tx.outputs!.filter(async output => {
const checkOutput = new CheckOutput(output)
const result = await checkOutput.checkLockHash(lockHashes)
return result
})
public filterOutputs = async (lockHashes: string[]) => {
const cells: Cell[] = (await Promise.all(
this.tx.outputs!.map(async output => {
const checkOutput = new CheckOutput(output)
const result = await checkOutput.checkLockHash(lockHashes)
if (result) {
return output
}
return false
})
)).filter(cell => !!cell) as Cell[]
return cells
}

Expand Down

0 comments on commit c851963

Please sign in to comment.