Skip to content

Commit c851963

Browse files
committed
fix: fix filterOutputs for async filter
1 parent 19c6673 commit c851963

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

  • packages/neuron-wallet/src/services/sync/check-and-save

packages/neuron-wallet/src/services/sync/check-and-save/tx.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class CheckTx {
1717
}
1818

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

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

42-
public filterOutputs = (lockHashes: string[]) => {
43-
const cells: Cell[] = this.tx.outputs!.filter(async output => {
44-
const checkOutput = new CheckOutput(output)
45-
const result = await checkOutput.checkLockHash(lockHashes)
46-
return result
47-
})
42+
public filterOutputs = async (lockHashes: string[]) => {
43+
const cells: Cell[] = (await Promise.all(
44+
this.tx.outputs!.map(async output => {
45+
const checkOutput = new CheckOutput(output)
46+
const result = await checkOutput.checkLockHash(lockHashes)
47+
if (result) {
48+
return output
49+
}
50+
return false
51+
})
52+
)).filter(cell => !!cell) as Cell[]
4853
return cells
4954
}
5055

0 commit comments

Comments
 (0)