Skip to content

Commit 836cdce

Browse files
committed
Reduce calls to wallet.getStatus
1 parent 8d822b8 commit 836cdce

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

packages/wallet/core/src/wallet.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ export class Wallet {
371371
// If the latest configuration does not match the onchain configuration
372372
// then we bundle the update into the transaction envelope
373373
if (!options?.noConfigUpdate) {
374-
const status = await this.getStatus(provider)
375374
if (status.imageHash !== status.onChainImageHash) {
376375
calls.push({
377376
to: this.address,
@@ -402,7 +401,7 @@ export class Wallet {
402401
factory,
403402
factoryData,
404403
},
405-
...(await this.prepareBlankEnvelope(Number(chainId))),
404+
...(await this.prepareBlankEnvelope(Number(chainId), status.configuration)),
406405
}
407406
}
408407

@@ -461,15 +460,15 @@ export class Wallet {
461460
}
462461
}
463462

464-
const [chainId, nonce] = await Promise.all([
463+
const [chainId, nonce, status] = await Promise.all([
465464
provider.request({ method: 'eth_chainId' }),
466465
this.getNonce(provider, space),
466+
this.getStatus(provider),
467467
])
468468

469469
// If the latest configuration does not match the onchain configuration
470470
// then we bundle the update into the transaction envelope
471471
if (!options?.noConfigUpdate) {
472-
const status = await this.getStatus(provider)
473472
if (status.imageHash !== status.onChainImageHash) {
474473
calls.push({
475474
to: this.address,
@@ -490,7 +489,7 @@ export class Wallet {
490489
nonce,
491490
calls,
492491
},
493-
...(await this.prepareBlankEnvelope(Number(chainId))),
492+
...(await this.prepareBlankEnvelope(Number(chainId), status.configuration)),
494493
}
495494
}
496495

@@ -597,13 +596,15 @@ export class Wallet {
597596
return encoded
598597
}
599598

600-
private async prepareBlankEnvelope(chainId: number) {
601-
const status = await this.getStatus()
602-
599+
private async prepareBlankEnvelope(chainId: number, configuration?: Config.Config) {
600+
if (!configuration) {
601+
const status = await this.getStatus()
602+
configuration = status.configuration
603+
}
603604
return {
604605
wallet: this.address,
605-
chainId: chainId,
606-
configuration: status.configuration,
606+
chainId,
607+
configuration,
607608
}
608609
}
609610
}

0 commit comments

Comments
 (0)