Skip to content

Commit

Permalink
Merge pull request #1496 from gnosis/gh-1493-fix-error-message
Browse files Browse the repository at this point in the history
gh-1493 improve message for user
Mouaz Alzahabi authored Oct 5, 2021
2 parents 6b22626 + d4ff2fe commit 313ad2d
Showing 4 changed files with 19 additions and 14 deletions.
14 changes: 9 additions & 5 deletions Multisig/Logic/Ledger/LedgerController.swift
Original file line number Diff line number Diff line change
@@ -50,11 +50,11 @@ class LedgerController {
}
}

typealias SignatureCompletion = (_ signature: String?) -> Void
typealias SignatureCompletion = (_ signature: String?, _ errorMessage: String?) -> Void

func sign(safeTxHash: String, deviceId: UUID, path: String, completion: @escaping SignatureCompletion) {
guard let device = bluetoothController.deviceFor(deviceId: deviceId) else {
completion(nil)
completion(nil, "Device not found")
return
}
let command = signMessageCommand(path: path, messageHash: safeTxHash)
@@ -67,17 +67,21 @@ class LedgerController {

// we are interested in the first 65 bytes only
guard data.count >= 65 else {
switch data.toHexString() {
case "6985": completion(nil, "The operation was canceled on the Ledger device.")
default: completion(nil, "Please check that Ethereum App is running on the Ledger device.")
}
// canceled on the device
completion(nil)

return
}
let dataString = data.toHexString()
let v = String(Int(dataString.substr(0, 2)!, radix: 16)! + 4, radix: 16)
let rs = dataString.substr(2, 128)!
completion(rs + v)
completion(rs + v, nil)

case .failure(_):
completion(nil)
completion(nil, "Please check that Ethereum App is running on the Ledger device.")
}
}
}
Original file line number Diff line number Diff line change
@@ -216,6 +216,7 @@ extension RejectionConfirmationViewController: SelectLedgerDeviceDelegate {
let ledgerKeyMetadata = KeyInfo.LedgerKeyMetadata.from(data: metadata) else { return }

let pendingConfirmationVC = LedgerPendingConfirmationViewController(ledgerHash: rejectionTransaction.hardwareWalletHash)
pendingConfirmationVC.headerText = "Reject Transaction"
pendingConfirmationVC.modalPresentationStyle = .popover
pendingConfirmationVC.onClose = { [weak self] in
self?.ledgerController = nil
@@ -227,11 +228,11 @@ extension RejectionConfirmationViewController: SelectLedgerDeviceDelegate {
ledgerController = LedgerController(bluetoothController: bluetoothController)
ledgerController!.sign(safeTxHash: safeTxHash,
deviceId: deviceId,
path: ledgerKeyMetadata.path) { [weak self] signature in
path: ledgerKeyMetadata.path) { [weak self] weakSignature, weakErrorMessage in
// dismiss Ledger Pending Confirmation overlay
controller.presentedViewController?.dismiss(animated: true, completion: nil)
guard let signature = signature else {
App.shared.snackbar.show(message: "The operation was canceled on the Ledger device.")
guard let signature = weakSignature else {
App.shared.snackbar.show(message: weakErrorMessage!)
controller.reloadData()
return
}
Original file line number Diff line number Diff line change
@@ -538,11 +538,11 @@ extension TransactionDetailsViewController: SelectLedgerDeviceDelegate {
ledgerController = LedgerController(bluetoothController: bluetoothController)
ledgerController!.sign(safeTxHash: safeTxHash,
deviceId: deviceId,
path: ledgerKeyMetadata.path) { [weak self] signature in
path: ledgerKeyMetadata.path) { [weak self] weakSignature, weakErrorMessage in
// dismiss Ledger Pending Confirmation overlay
controller.presentedViewController?.dismiss(animated: true, completion: nil)
guard let signature = signature else {
App.shared.snackbar.show(message: "The operation was canceled on the Ledger device.")
guard let signature = weakSignature else {
App.shared.snackbar.show(message: weakErrorMessage!)
controller.reloadData()
return
}
Original file line number Diff line number Diff line change
@@ -431,11 +431,11 @@ extension WCTransactionConfirmationViewController: SelectLedgerDeviceDelegate {
ledgerController = LedgerController(bluetoothController: bluetoothController)
ledgerController!.sign(safeTxHash: safeTxHash,
deviceId: deviceId,
path: ledgerKeyMetadata.path) { [weak self] signature in
path: ledgerKeyMetadata.path) { [weak self] weakSignature, weakErrorMessage in
// dismiss Ledger Pending Confirmation overlay
self?.presentedViewController?.dismiss(animated: true, completion: nil)
guard let signature = signature else {
App.shared.snackbar.show(message: "The operation was canceled on the Ledger device.")
guard let signature = weakSignature else {
App.shared.snackbar.show(message: weakErrorMessage!)
return
}
DispatchQueue.global().async {

0 comments on commit 313ad2d

Please sign in to comment.