Skip to content

Commit 5aeae54

Browse files
Merge pull request #5751 from BitGo/DX-1125-remove-bluebird-from-abstract-utxo
refactor(abstract-utxo): replace bluebird with native promises
2 parents b5b9427 + a20cd9f commit 5aeae54

File tree

3 files changed

+659
-635
lines changed

3 files changed

+659
-635
lines changed

modules/abstract-utxo/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@
4949
"@bitgo/utxo-core": "^1.5.0",
5050
"@bitgo/utxo-lib": "^11.2.4",
5151
"@bitgo/wasm-miniscript": "2.0.0-beta.7",
52-
"@types/bluebird": "^3.5.25",
5352
"@types/lodash": "^4.14.121",
5453
"@types/superagent": "4.1.15",
5554
"bignumber.js": "^9.0.2",
5655
"bitcoinjs-message": "npm:@bitgo-forks/[email protected]",
57-
"bluebird": "^3.5.3",
5856
"debug": "^3.1.0",
5957
"io-ts": "npm:@bitgo-forks/[email protected]",
6058
"lodash": "^4.17.14",

modules/abstract-utxo/src/recovery/crossChainRecovery.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Bluebird from 'bluebird';
21
import * as utxolib from '@bitgo/utxo-lib';
32
import { bip32, BIP32Interface } from '@bitgo/utxo-lib';
43
import { Dimensions } from '@bitgo/unspents';
@@ -199,23 +198,26 @@ async function toWalletUnspents<TNumber extends number | bigint = number>(
199198
wallet: IWallet | WalletV1
200199
): Promise<WalletUnspent<TNumber>[]> {
201200
const addresses = new Set(unspents.map((u) => u.address));
202-
return (
203-
await Bluebird.mapSeries(addresses, async (address): Promise<WalletUnspent<TNumber>[]> => {
204-
let scriptId;
205-
try {
206-
scriptId = await getScriptId(recoveryCoin, wallet, utxolib.address.toOutputScript(address, sourceCoin.network));
207-
} catch (e) {
208-
console.error(`error getting scriptId for ${address}:`, e);
209-
return [];
210-
}
211-
return unspents
212-
.filter((u) => u.address === address)
213-
.map((u) => ({
214-
...u,
215-
...scriptId,
216-
}));
217-
})
218-
).flat();
201+
const walletUnspents: WalletUnspent<TNumber>[] = [];
202+
203+
for (const address of addresses) {
204+
let scriptId;
205+
try {
206+
scriptId = await getScriptId(recoveryCoin, wallet, utxolib.address.toOutputScript(address, sourceCoin.network));
207+
} catch (e) {
208+
console.error(`error getting scriptId for ${address}:`, e);
209+
continue;
210+
}
211+
const filteredUnspents = unspents
212+
.filter((u) => u.address === address)
213+
.map((u) => ({
214+
...u,
215+
...scriptId,
216+
}));
217+
walletUnspents.push(...filteredUnspents);
218+
}
219+
220+
return walletUnspents;
219221
}
220222

221223
/**

0 commit comments

Comments
 (0)