Skip to content

Commit 7baae82

Browse files
committed
chore: parallellize keychain and queryPromise
Ticket: CAAS-7
1 parent c904a16 commit 7baae82

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,15 +2176,15 @@ export class Wallet implements IWallet {
21762176
}
21772177

21782178
// Doing a sanity check for password here to avoid doing further work if we know it's wrong
2179-
const keychains = await this.getKeychainsAndValidatePassphrase({
2179+
// Doing a sanity check for password here to avoid doing further work if we know it's wrong
2180+
const keychainPromise = this.getKeychainsAndValidatePassphrase({
21802181
reqId: params.reqId,
21812182
walletPassphrase: params.walletPassphrase,
21822183
customSigningFunction: params.customSigningFunction,
21832184
});
21842185

21852186
let txPrebuildQuery: Promise<PrebuildTransactionResult | string>;
21862187
if (isPrebuildTransactionResult(params.prebuildTx) && params.prebuildTx.buildParams?.preview) {
2187-
// If we prebuilt the txRequest with preview=true, then we should rebuild with preview=false to persist the request
21882188
txPrebuildQuery = this.prebuildTransaction({
21892189
...params,
21902190
...{ ...params.prebuildTx.buildParams, preview: false },
@@ -2193,8 +2193,10 @@ export class Wallet implements IWallet {
21932193
txPrebuildQuery = params.prebuildTx ? Promise.resolve(params.prebuildTx) : this.prebuildTransaction(params);
21942194
}
21952195

2196-
// the prebuild can be overridden by providing an explicit tx
2197-
const txPrebuild = (await txPrebuildQuery) as PrebuildTransactionResult;
2196+
const [keychains, txPrebuild] = (await Promise.all([keychainPromise, txPrebuildQuery])) as [
2197+
any,
2198+
PrebuildTransactionResult
2199+
];
21982200

21992201
try {
22002202
await this.baseCoin.verifyTransaction({

0 commit comments

Comments
 (0)