Skip to content

Commit

Permalink
Fixed: cover the case if user is in the middle of signing
Browse files Browse the repository at this point in the history
  • Loading branch information
superKalo committed Jan 22, 2024
1 parent dd929ab commit d5e8797
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/controllers/signAccountOp/signAccountOp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,27 @@ export class SignAccountOpController extends EventEmitter {
this.#setDefaults()
// Here, we expect to have most of the fields set, so we can safely set GasFeePayment
this.#setGasFeePayment()
// If status is already set, don't override it. Meant to set the status only initially here.
if (!this.status) this.updateStatusToReadyToSign()
this.updateStatusToReadyToSign()
}

updateStatusToReadyToSign() {
const isInTheMiddleOfSigning =
this.status &&
![SigningStatus.InProgress, SigningStatus.InProgressAwaitingUserInput].includes(
this.status?.type
)

if (
this.isInitialized &&
this.#estimation &&
this.accountOp?.signingKeyAddr &&
this.accountOp?.signingKeyType &&
this.accountOp?.gasFeePayment &&
!this.errors.length
!this.errors.length &&
// Update if status is NOT already set (that's the initial state update)
// or in general if the user is not in the middle of signing (otherwise
// it resets the loading state back to ready to sign)
(!this.status || !isInTheMiddleOfSigning)
) {
this.status = { type: SigningStatus.ReadyToSign }
}
Expand Down

0 comments on commit d5e8797

Please sign in to comment.