Skip to content

Commit 7300cc0

Browse files
committed
fix(sdk-core): use Promise.all for concurrent processing for transaction verifying, linting fixes
Ticket: WP-5945
1 parent 4f377a8 commit 7300cc0

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

modules/sdk-coin-btc/test/unit/btc.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ describe('BTC:', () => {
118118
});
119119

120120
it('should detect hex spoofing in BUILD_SIGN_SEND', async (): Promise<void> => {
121-
const { getDefaultWalletKeys, toKeychainObjects } = require('../../../bitgo/test/v2/unit/coins/utxo/util/keychains');
121+
const {
122+
getDefaultWalletKeys,
123+
toKeychainObjects,
124+
} = require('../../../bitgo/test/v2/unit/coins/utxo/util/keychains');
122125
const rootWalletKey = getDefaultWalletKeys();
123126
const keysObj = toKeychainObjects(rootWalletKey, 'pass');
124127

@@ -164,9 +167,7 @@ describe('BTC:', () => {
164167
return [200, { txid: 'test-txid-123', status: 'signed' }];
165168
});
166169

167-
keysObj.forEach((k, i) =>
168-
nock(bgUrl).get(`/api/v2/${wallet.coin()}/key/${wallet.keyIds()[i]}`).reply(200, k)
169-
);
170+
keysObj.forEach((k, i) => nock(bgUrl).get(`/api/v2/${wallet.coin()}/key/${wallet.keyIds()[i]}`).reply(200, k));
170171

171172
await assert.rejects(
172173
wallet.consolidateUnspents({ walletPassphrase: 'pass' }),

modules/sdk-core/src/bitgo/wallet/wallet.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -737,15 +737,17 @@ export class Wallet implements IWallet {
737737

738738
// Validate that the platform-built transaction matches user parameters
739739
const txPrebuilds = Array.isArray(buildResponse) ? buildResponse : [buildResponse];
740-
for (const txPrebuild of txPrebuilds) {
741-
await this.baseCoin.verifyTransaction({
742-
txParams: params,
743-
txPrebuild,
744-
wallet: this,
745-
verification: params.verification ?? {},
746-
reqId,
747-
});
748-
}
740+
await Promise.all(
741+
txPrebuilds.map((txPrebuild) =>
742+
this.baseCoin.verifyTransaction({
743+
txParams: params,
744+
txPrebuild,
745+
wallet: this,
746+
verification: params.verification ?? {},
747+
reqId,
748+
})
749+
)
750+
);
749751

750752
const keychains = (await this.baseCoin
751753
.keychains()

0 commit comments

Comments
 (0)