Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ABW-3575] Dismiss signing sheet only when rejecting transaction on Ledger #1222

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extension LedgerHardwareWalletClient: DependencyKey {
loggerGlobal.warning("Error from CE? \(errorFromConnectorExtension)")

switch errorFromConnectorExtension.code {
case .generic: break
case .generic, .userRejectedSigningOfTransaction: break
case .blindSigningNotEnabledButRequired:
overlayWindowClient.scheduleAlertAndIgnoreAction(
.init(
Expand Down Expand Up @@ -136,8 +136,8 @@ extension LedgerHardwareWalletClient: DependencyKey {
}
},
signTransaction: { request in
let hashedMsg = try request.transactionIntent.hash()
let compiledTransactionIntent = try request.transactionIntent.compile()
let hashedMsg = request.transactionIntent.hash()
let compiledTransactionIntent = request.transactionIntent.compile()
return try await sign(
signers: request.signers,
expectedHashedMessage: hashedMsg.hash.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ extension P2P.ConnectorExtension.Response.LedgerHardwareWallet {
public enum Reason: Int, Sendable, Hashable, Decodable {
case generic = 0
case blindSigningNotEnabledButRequired = 1
case userRejectedSigningOfTransaction = 2

public var userFacingErrorDescription: String {
switch self {
case .generic:
case .generic, .userRejectedSigningOfTransaction:
L10n.Error.TransactionFailure.unknown
case .blindSigningNotEnabledButRequired:
L10n.Error.TransactionFailure.blindSigningNotEnabledButRequired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ public struct SignWithFactorSource: Sendable, FeatureReducer {
try await sign(signers: signingFactor.signers, factor: signingFactor.factorSource.extract(as: LedgerHardwareWalletFactorSource.self), state: state)
}
allSignatures.append(contentsOf: signatures)
} catch {
} catch let error as P2P.ConnectorExtension.Response.LedgerHardwareWallet.Failure where error.code == .userRejectedSigningOfTransaction {
// If user rejected transaction on ledger device, we will inform the delegate to dismiss the signing sheet.
await send(.delegate(.failedToSign(signingFactor)))
break
return
} catch {
// In any other type of error, we will just allow them to retry.
return
}
}
await send(.delegate(.done(signingFactors: signingFactors, signatures: allSignatures)))
Expand Down
Loading