Skip to content

Commit

Permalink
Pod update TrustWalletSDK (error codes) and refine error handling (tr…
Browse files Browse the repository at this point in the history
  • Loading branch information
hewigovens authored and vikmeup committed Jun 16, 2018
1 parent 12c5158 commit 8e9774a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ CHECKOUT OPTIONS:
:commit: 80bd79cbeede842949b229f81bc6328f53701c5a
:git: https://github.com/yannickl/QRCodeReaderViewController.git
TrustWalletSDK:
:commit: 57de048f020f27907b3896417589252e43b931a6
:commit: 82c06558df5e6a75bd9c195a4e76536618e76a9a
:git: https://github.com/TrustWallet/TrustSDK-iOS
TrustWeb3Provider:
:commit: f4e0ebb1b8fa4812637babe85ef975d116543dfd
Expand Down
22 changes: 15 additions & 7 deletions Trust/Core/Coordinators/LocalSchemeCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ class LocalSchemeCoordinator: Coordinator {
switch result {
case .success(let data):
completion(.success(data))
case .failure:
completion(.failure(WalletError.cancelled))
case .failure(let error):
if let dappError = error.error as? DAppError, dappError == .cancelled {
completion(.failure(WalletError.cancelled))
} else {
completion(.failure(WalletError.unknown))
}
}
coordinator.didComplete = nil
self.removeCoordinator(coordinator)
Expand Down Expand Up @@ -79,8 +83,12 @@ class LocalSchemeCoordinator: Coordinator {
case .sentTransaction(let transaction):
completion(.success(transaction.data))
}
case .failure:
completion(.failure(WalletError.cancelled))
case .failure(let error):
if let dappError = error.error as? DAppError, dappError == .cancelled {
completion(.failure(WalletError.cancelled))
} else {
completion(.failure(WalletError.unknown))
}
}
coordinator.didCompleted = nil
self.removeCoordinator(coordinator)
Expand Down Expand Up @@ -109,14 +117,14 @@ extension LocalSchemeCoordinator: SignMessageCoordinatorDelegate {
extension LocalSchemeCoordinator: WalletDelegate {
func signMessage(_ message: Data, address: Address?, completion: @escaping (Result<Data, WalletError>) -> Void) {
guard let account = account(for: session) else {
return completion(.failure(WalletError.cancelled))
return completion(.failure(WalletError.watchOnly))
}
signMessage(for: account, signMessage: .message(message), completion: completion)
}

func signPersonalMessage(_ message: Data, address: Address?, completion: @escaping (Result<Data, WalletError>) -> Void) {
guard let account = account(for: session) else {
return completion(.failure(WalletError.cancelled))
return completion(.failure(WalletError.watchOnly))
}
signMessage(for: account, signMessage: .personalMessage(message), completion: completion)
}
Expand All @@ -133,7 +141,7 @@ extension LocalSchemeCoordinator: WalletDelegate {
)

guard let account = account(for: session) else {
return completion(.failure(WalletError.cancelled))
return completion(.failure(WalletError.watchOnly))
}
signTransaction(account: account, transaction: transaction, type: .sign, completion: completion)
}
Expand Down

0 comments on commit 8e9774a

Please sign in to comment.