Rename debug logging functions to have a postfix so it's easier to search for them

pull/3876/head
Hwee-Boon Yar 3 years ago
parent d84ac70065
commit 312d2a54b0
  1. 4
      AlphaWallet/Browser/Types/DappAction.swift
  2. 12
      AlphaWallet/Browser/ViewControllers/BrowserViewController.swift
  3. 10
      AlphaWallet/Core/Coordinators/WalletBalance/PrivateBalanceFetcher.swift
  4. 10
      AlphaWallet/Core/Helpers/RemoteLogger.swift
  5. 4
      AlphaWallet/Core/Initializers/MigrationInitializer.swift
  6. 8
      AlphaWallet/Core/Views/WebImageView.swift
  7. 4
      AlphaWallet/Donations/WalletQrCodeDonation.swift
  8. 4
      AlphaWallet/EtherClient/OpenSea.swift
  9. 4
      AlphaWallet/Extensions/Session+PromiseKit.swift
  10. 2
      AlphaWallet/Settings/ViewControllers/SaveCustomRpcBrowseViewController.swift
  11. 4
      AlphaWallet/TokenScriptClient/Coordinators/AssetDefinitionStoreCoordinator.swift
  12. 12
      AlphaWallet/Tokens/Coordinators/DASNameLookupCoordinator.swift
  13. 2
      AlphaWallet/Tokens/Coordinators/GetENSOwnerCoordinator.swift
  14. 4
      AlphaWallet/Transactions/Coordinators/SingleChainTransactionEtherscanDataCoordinator.swift
  15. 4
      AlphaWallet/Transactions/Storage/TransactionsStorage.swift
  16. 6
      AlphaWallet/Transfer/Controllers/TransactionConfigurator.swift
  17. 4
      AlphaWallet/Transfer/Coordinators/SendTransactionCoordinator.swift
  18. 4
      AlphaWallet/Transfer/Coordinators/TransactionConfirmationCoordinator.swift
  19. 6
      AlphaWallet/UI/TokenObject+UI.swift
  20. 28
      AlphaWallet/WalletConnect/Coordinator/WalletConnectCoordinator.swift
  21. 16
      AlphaWallet/WalletConnect/Providers/v1/WalletConnectV1Provider.swift
  22. 32
      AlphaWallet/WalletConnect/Providers/v2/WalletConnectV2Provider.swift
  23. 2
      AlphaWallet/WalletConnect/Types/WalletConnectRequestConverter.swift
  24. 6
      AlphaWalletTests/Redeem/CreateRedeemTests.swift

@ -89,7 +89,7 @@ extension DappAction {
static func fromMessage(_ message: WKScriptMessage) -> DappOrWalletCommand? {
let decoder = JSONDecoder()
guard var body = message.body as? [String: AnyObject] else {
debug("[Browser] Invalid body in message: \(message.body)")
debugLog("[Browser] Invalid body in message: \(message.body)")
return nil
}
if var object = body["object"] as? [String: AnyObject], object["gasLimit"] is [String: AnyObject] {
@ -98,7 +98,7 @@ extension DappAction {
body["object"] = object as AnyObject
}
guard let jsonString = body.jsonString else {
debug("[Browser] Invalid jsonString. body: \(body)")
debugLog("[Browser] Invalid jsonString. body: \(body)")
return nil
}
let data = jsonString.data(using: .utf8)!

@ -147,7 +147,7 @@ final class BrowserViewController: UIViewController {
func goTo(url: URL) {
hideErrorView()
verbose("Loading URL: \(url.absoluteString)")
verboseLog("Loading URL: \(url.absoluteString)")
webView.load(URLRequest(url: url))
}
@ -209,12 +209,12 @@ extension BrowserViewController: WKNavigationDelegate {
}
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
info("[Browser] navigation with error: \(error)")
infoLog("[Browser] navigation with error: \(error)")
handleError(error: error)
}
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
info("[Browser] provisional navigation with error: \(error)")
infoLog("[Browser] provisional navigation with error: \(error)")
handleError(error: error)
}
@ -233,7 +233,7 @@ extension BrowserViewController: WKNavigationDelegate {
delegate?.handleUniversalLink(url, inBrowserViewController: self)
decisionHandler(.cancel)
return
}
}
decisionHandler(.allow)
}
@ -247,12 +247,12 @@ extension BrowserViewController: WKScriptMessageHandler {
}
return
}
info("[Browser] dapp command: \(command)")
infoLog("[Browser] dapp command: \(command)")
let requester = DAppRequester(title: webView.title, url: webView.url)
let token = TokensDataStore.token(forServer: server)
let action = DappAction.fromCommand(command, server: server, transactionType: .dapp(token, requester))
info("[Browser] dapp action: \(action)")
infoLog("[Browser] dapp action: \(action)")
delegate?.didCall(action: action, callbackID: command.id, inBrowserViewController: self)
}
}

@ -424,7 +424,7 @@ class PrivateBalanceFetcher: PrivateBalanceFetcherType {
}
let uri = originalUri.rewrittenIfIpfs
//TODO check this doesn't print duplicates, including unnecessary fetches
verbose("Fetching token URI: \(originalUri.absoluteString)… with: \(uri.absoluteString)")
verboseLog("Fetching token URI: \(originalUri.absoluteString)… with: \(uri.absoluteString)")
return firstly {
//Must not use `SessionManager.default.request` or `Alamofire.request` which uses the former. See comment in var
@ -432,12 +432,12 @@ class PrivateBalanceFetcher: PrivateBalanceFetcherType {
}.map(on: queue, { (data, _) -> String in
if let json = try? JSON(data: data) {
if let errorMessage = json["error"].string {
verbose("Fetched token URI: \(originalUri.absoluteString) error: \(errorMessage)")
verboseLog("Fetched token URI: \(originalUri.absoluteString) error: \(errorMessage)")
}
if json["error"] == "Internal Server Error" {
throw Error()
} else {
verbose("Fetched token URI: \(originalUri.absoluteString)")
verboseLog("Fetched token URI: \(originalUri.absoluteString)")
var jsonDictionary = json
if let tokenObject = tokens.first(where: { $0.contractAddress.sameContract(as: address) }) {
jsonDictionary["tokenType"] = JSON(tokenType.rawValue)
@ -464,11 +464,11 @@ class PrivateBalanceFetcher: PrivateBalanceFetcherType {
}
}
} else {
verbose("Fetched token URI: \(originalUri.absoluteString) failed")
verboseLog("Fetched token URI: \(originalUri.absoluteString) failed")
throw Error()
}
}).recover { error -> Promise<String> in
verbose("Fetching token URI: \(originalUri) error: \(error)")
verboseLog("Fetching token URI: \(originalUri) error: \(error)")
throw error
}
}

@ -4,23 +4,23 @@ import Foundation
import PaperTrailLumberjack
import CocoaLumberjack
func debug(_ message: Any, _ logger: Logger = DDLogger.instance, callerFunctionName: String = #function) {
func debugLog(_ message: Any, _ logger: Logger = DDLogger.instance, callerFunctionName: String = #function) {
logger.debug("\(message) from: \(callerFunctionName)")
}
func info(_ message: Any, _ logger: Logger = DDLogger.instance, callerFunctionName: String = #function) {
func infoLog(_ message: Any, _ logger: Logger = DDLogger.instance, callerFunctionName: String = #function) {
logger.info("\(message) from: \(callerFunctionName)")
}
func warn(_ message: Any, _ logger: Logger = DDLogger.instance, callerFunctionName: String = #function) {
func warnLog(_ message: Any, _ logger: Logger = DDLogger.instance, callerFunctionName: String = #function) {
logger.warn("\(message) from: \(callerFunctionName)")
}
func verbose(_ message: Any, _ logger: Logger = DDLogger.instance, callerFunctionName: String = #function) {
func verboseLog(_ message: Any, _ logger: Logger = DDLogger.instance, callerFunctionName: String = #function) {
logger.verbose("\(message) from: \(callerFunctionName)")
}
func error(_ message: Any, _ logger: Logger = DDLogger.instance, callerFunctionName: String = #function) {
func errorLog(_ message: Any, _ logger: Logger = DDLogger.instance, callerFunctionName: String = #function) {
logger.error("\(message) from: \(callerFunctionName)")
}

@ -120,8 +120,8 @@ extension MigrationInitializer {
func oneTimeCreationOfOneDatabaseToHoldAllChains(assetDefinitionStore: AssetDefinitionStore) {
let migration = self
debug("Database filepath: \(migration.config.fileURL!)")
debug("Database directory: \(migration.config.fileURL!.deletingLastPathComponent())")
debugLog("Database filepath: \(migration.config.fileURL!)")
debugLog("Database directory: \(migration.config.fileURL!.deletingLastPathComponent())")
let exists: Bool
if let path = migration.config.fileURL?.path {

@ -115,14 +115,14 @@ class WebImageView: UIView {
self?.setIsLoadingImageFromURL(true)
case .imageLoadFailure:
resetToDisplayPlaceholder()
verbose("Loading token icon URL: \(url) error")
verboseLog("Loading token icon URL: \(url) error")
}
})
}
guard let imageURL = url.flatMap({ $0.rewrittenIfIpfs }).flatMap({ $0.absoluteString }) else {
return resetToDisplayPlaceholder()
}
}
loadHtmlForImage(url: imageURL)
}
@ -208,7 +208,7 @@ private class _WebImageView: UIView {
case .pageDidLoad:
guard !strongSelf.pageDidLoad else { return }
strongSelf.pageDidLoad = true
strongSelf.subscribeForFrameChange(completion: {
if let url = strongSelf.pendingToLoadURL {
strongSelf.pendingToLoadURL = .none
@ -279,7 +279,7 @@ private class _WebImageView: UIView {
guard var html = try? String(contentsOfFile: filePath, encoding: .utf8) else { return "" }
html = html.replacingOccurrences(of: "<scale>", with: scale.rawValue)
html = html.replacingOccurrences(of: "<align>", with: align.rawValue)
return html
}

@ -40,10 +40,10 @@ class WalletQrCodeDonation {
}
func delete() {
info("Deleting donated shortcut: \(Self.persistentIdentifier)")
infoLog("Deleting donated shortcut: \(Self.persistentIdentifier)")
CSSearchableIndex.default().deleteSearchableItems(withDomainIdentifiers: [Self.persistentIdentifier])
NSUserActivity.deleteSavedUserActivities(withPersistentIdentifiers: [Self.persistentIdentifier]) {
info("Deleted donated shortcut: \(Self.persistentIdentifier)")
infoLog("Deleted donated shortcut: \(Self.persistentIdentifier)")
}
}
}

@ -88,7 +88,7 @@ class OpenSea {
seal.fulfill(result)
case .failure(let error):
verbose("[OpenSea] fetch failed: \(error) owner: \(owner.eip55String) offset: \(offset)")
verboseLog("[OpenSea] fetch failed: \(error) owner: \(owner.eip55String) offset: \(offset)")
seal.reject(error)
}
}
@ -202,7 +202,7 @@ class OpenSea {
}
let fetchedCount = json["assets"].count
verbose("[OpenSea] fetch page count: \(fetchedCount) owner: \(owner.eip55String) offset: \(offset)")
verboseLog("[OpenSea] fetch page count: \(fetchedCount) owner: \(owner.eip55String) offset: \(offset)")
if fetchedCount > 0 {
strongSelf.fetchPage(forOwner: owner, offset: offset + fetchedCount, sum: results) { results in
completion(results)

@ -37,7 +37,7 @@ extension Session {
}
private static func convertToUserFriendlyError(error: SessionTaskError, baseUrl: URL) -> Error? {
info("convertToUserFriendlyError URL: \(baseUrl.absoluteString) error: \(error)")
infoLog("convertToUserFriendlyError URL: \(baseUrl.absoluteString) error: \(error)")
switch error {
case .connectionError(let e):
let message = e.localizedDescription
@ -105,7 +105,7 @@ extension Session {
RemoteLogger.instance.logRpcOrOtherWebError("APIKit.ResponseError.nonHTTPURLResponse", url: baseUrl.absoluteString)
case .unacceptableStatusCode(let statusCode):
if statusCode == 429 {
warn("[API] Rate limited by baseURL: \(baseUrl.absoluteString)")
warnLog("[API] Rate limited by baseURL: \(baseUrl.absoluteString)")
return SendTransactionRetryableError.rateLimited
} else {
RemoteLogger.instance.logRpcOrOtherWebError("APIKit.ResponseError.unacceptableStatusCode | status: \(statusCode)", url: baseUrl.absoluteString)

@ -256,7 +256,7 @@ extension SaveCustomRpcBrowseViewController: HandleAddMultipleCustomRpcViewContr
private func reportFailures(customRpcs: [CustomRPC]) {
customRpcs.forEach { customRpc in
info("[Custom chains] Failed to add: \(customRpc.chainName) chainID: \(customRpc.chainID) endPoint: \(customRpc.rpcEndpoint)")
infoLog("[Custom chains] Failed to add: \(customRpc.chainName) chainID: \(customRpc.chainID) endPoint: \(customRpc.rpcEndpoint)")
}
}

@ -114,9 +114,9 @@ class AssetDefinitionStoreCoordinator: Coordinator {
///For development
private func printInboxContents() {
guard let contents = inboxContents else { return }
verbose("Contents of inbox:")
verboseLog("Contents of inbox:")
for each in contents {
verbose(" In inbox: \(each)")
verboseLog(" In inbox: \(each)")
}
}

@ -23,22 +23,22 @@ public final class DASNameLookupCoordinator {
func resolve(rpcURL: URL, value: String) -> Promise<AlphaWallet.Address> {
guard DASNameLookupCoordinator.isValid(value: value) else {
debug("[DAS] Invalid lookup: \(value)")
debugLog("[DAS] Invalid lookup: \(value)")
return .init(error: DASNameLookupError.invalidInput)
}
let request = EtherServiceRequest(rpcURL: rpcURL, batch: BatchFactory().create(DASLookupRequest(value: value)))
debug("[DAS] Looking up value \(value)")
debugLog("[DAS] Looking up value \(value)")
return Session.send(request).map { response -> AlphaWallet.Address in
debug("[DAS] response for value: \(value) response : \(response)")
debugLog("[DAS] response for value: \(value) response : \(response)")
if let record = response.records.first(where: { $0.key == DASNameLookupCoordinator.ethAddressKey }), let address = AlphaWallet.Address(string: record.value) {
info("[DAS] resolve value: \(value) to address: \(address)")
infoLog("[DAS] resolve value: \(value) to address: \(address)")
return address
} else if response.records.isEmpty, let ownerAddress = response.ownerAddress {
info("[DAS] No records fallback value: \(value) to ownerAddress: \(ownerAddress)")
infoLog("[DAS] No records fallback value: \(value) to ownerAddress: \(ownerAddress)")
return ownerAddress
} else {
info("[DAS] Can't resolve value: \(value)")
infoLog("[DAS] Can't resolve value: \(value)")
}
throw DASNameLookupError.ethRecordNotFound
}

@ -57,7 +57,7 @@ class GetENSAddressCoordinator: CachebleAddressResolutionServiceType {
//if null address is returned (as 0) we count it as invalid
//this is because it is not assigned to an ENS and puts the user in danger of sending funds to null
if let resolver = result["0"] as? EthereumAddress {
verbose("[ENS] fetched resolver: \(resolver) for: \(input) arg: \(node)")
verboseLog("[ENS] fetched resolver: \(resolver) for: \(input) arg: \(node)")
if Constants.nullAddress.sameContract(as: resolver) {
return .init(error: AnyError(Web3Error(description: "Null address returned")))
} else {

@ -60,7 +60,7 @@ class SingleChainTransactionEtherscanDataCoordinator: SingleChainTransactionData
}
deinit {
debug("\(self).deinit")
debugLog("\(self).deinit")
}
func stopTimers() {
@ -550,5 +550,5 @@ func error(value e: Error, pref: String = "", function f: String = #function, rp
description += rpcServer.flatMap { " server: \($0)" } ?? ""
description += address.flatMap { " address: \($0.eip55String)" } ?? ""
description += " \(e)"
error(description, callerFunctionName: f)
errorLog(description, callerFunctionName: f)
}

@ -312,9 +312,9 @@ class TransactionsStorage: Hashable {
do {
let data = try functional.generateJsonForTransactions(transactionStorage: self, toUrl: url)
try data.write(to: url)
verbose("Written transactions for \(server) to JSON to: \(url.absoluteString)")
verboseLog("Written transactions for \(server) to JSON to: \(url.absoluteString)")
} catch {
verbose("Error writing transactions for \(server) to JSON: \(url.absoluteString) error: \(error)")
verboseLog("Error writing transactions for \(server) to JSON: \(url.absoluteString) error: \(error)")
}
}

@ -152,7 +152,7 @@ class TransactionConfigurator {
firstly {
Session.send(EtherServiceRequest(server: session.server, batch: BatchFactory().create(request)))
}.done { gasLimit in
info("Estimated gas limit with eth_estimateGas: \(gasLimit)")
infoLog("Estimated gas limit with eth_estimateGas: \(gasLimit)")
let gasLimit: BigInt = {
let limit = BigInt(gasLimit.drop0x, radix: 16) ?? BigInt()
if limit == GasLimitConfiguration.minGasLimit {
@ -160,7 +160,7 @@ class TransactionConfigurator {
}
return min(limit + (limit * 20 / 100), GasLimitConfiguration.maxGasLimit)
}()
info("Using gas limit: \(gasLimit)")
infoLog("Using gas limit: \(gasLimit)")
var customConfig = self.configurations.custom
customConfig.setEstimated(gasLimit: gasLimit)
self.configurations.custom = customConfig
@ -178,7 +178,7 @@ class TransactionConfigurator {
self.delegate?.gasLimitEstimateUpdated(to: gasLimit, in: self)
}.catch { e in
info("Error estimating gas limit: \(e)")
infoLog("Error estimating gas limit: \(e)")
error(value: e, rpcServer: self.session.server)
}
}

@ -40,7 +40,7 @@ class SendTransactionCoordinator {
}.map { transactionID in
.sentRawTransaction(id: transactionID, original: rawTransaction)
}.get {
info("Sent rawTransaction with transactionId: \($0)")
infoLog("Sent rawTransaction with transactionId: \($0)")
}
}
@ -104,7 +104,7 @@ class SendTransactionCoordinator {
}.map { transactionID in
.sentTransaction(SentTransaction(id: transactionID, original: transaction))
}.get {
info("Sent transaction with transactionId: \($0)")
infoLog("Sent transaction with transactionId: \($0)")
}
}

@ -332,10 +332,10 @@ extension TransactionConfirmationCoordinator {
]
if let provider = privateNetworkProvider {
analyticsProperties[Analytics.Properties.sendPrivateTransactionsProvider.rawValue] = provider.rawValue
info("Sent transaction with send private transactions provider: \(provider.rawValue)")
infoLog("Sent transaction with send private transactions provider: \(provider.rawValue)")
} else {
//no-op
info("Sent transaction publicly")
infoLog("Sent transaction publicly")
}
switch configuration {
case .sendFungiblesTransaction(_, _, _, amount: let amount, _):

@ -258,9 +258,9 @@ class TokenImageFetcher {
}.recover { error -> Promise<UIImage> in
//This is expected. Some tokens will not have icons
if let url = request.url?.absoluteString {
verbose("Loading token icon URL: \(url) error")
verboseLog("Loading token icon URL: \(url) error")
} else {
verbose("Loading token icon URL: nil error")
verboseLog("Loading token icon URL: nil error")
}
throw error
}
@ -285,7 +285,7 @@ class GithubAssetsURLResolver {
let value = githubAssetsSource.rawValue + contractAddress.eip55String + "/" + GithubAssetsURLResolver.file
guard let url = URL(string: value) else {
verbose("Loading token icon URL: \(value) error")
verboseLog("Loading token icon URL: \(value) error")
return .init(error: AnyError.case1)
}
let request = URLRequest(url: url)

@ -8,7 +8,7 @@
import UIKit
import WalletConnectSwift
import PromiseKit
import Result
import Result
protocol WalletConnectCoordinatorDelegate: CanOpenURL, SendTransactionAndFiatOnRampDelegate {
func universalScannerSelected(in coordinator: WalletConnectCoordinator)
@ -221,12 +221,12 @@ extension WalletConnectCoordinator: WalletConnectServerDelegate {
}
func server(_ server: WalletConnectServerType, didConnect walletConnectSession: AlphaWallet.WalletConnect.Session) {
info("WalletConnect didConnect session: \(walletConnectSession.identifier)")
infoLog("WalletConnect didConnect session: \(walletConnectSession.identifier)")
resetSessionsToRemoveLoadingIfNeeded()
}
func server(_ server: WalletConnectServerType, action: AlphaWallet.WalletConnect.Action, request: AlphaWallet.WalletConnect.Session.Request, session walletConnectSession: AlphaWallet.WalletConnect.Session) {
info("WalletConnect action: \(action)")
infoLog("WalletConnect action: \(action)")
guard let walletSession = request.server.flatMap({ sessions[$0] }) else { return }
let dappRequesterViewModel = WalletConnectDappRequesterViewModel(walletConnectSession: walletConnectSession, request: request)
@ -266,7 +266,7 @@ extension WalletConnectCoordinator: WalletConnectServerDelegate {
}
private func signMessage(with type: SignMessageType, account: AlphaWallet.Address, dappRequesterViewModel: WalletConnectDappRequesterViewModel) -> Promise<AlphaWallet.WalletConnect.Callback> {
info("WalletConnect signMessage: \(type)")
infoLog("WalletConnect signMessage: \(type)")
return firstly {
SignMessageCoordinator.promise(analyticsCoordinator: analyticsCoordinator, navigationController: navigationController, keystore: keystore, coordinator: self, signType: type, account: account, source: .walletConnect, walletConnectDappRequesterViewModel: dappRequesterViewModel)
@ -279,7 +279,7 @@ extension WalletConnectCoordinator: WalletConnectServerDelegate {
let ethPrice = nativeCryptoCurrencyPrices[session.server]
let configuration: TransactionConfirmationConfiguration = .walletConnect(confirmType: type, keystore: keystore, ethPrice: ethPrice, dappRequesterViewModel: dappRequesterViewModel)
info("WalletConnect executeTransaction: \(transaction) type: \(type)")
infoLog("WalletConnect executeTransaction: \(transaction) type: \(type)")
return firstly {
TransactionConfirmationCoordinator.promise(navigationController, session: session, coordinator: self, transaction: transaction, configuration: configuration, analyticsCoordinator: analyticsCoordinator, source: .walletConnect, delegate: self.delegate)
}.map { data -> AlphaWallet.WalletConnect.Callback in
@ -325,26 +325,26 @@ extension WalletConnectCoordinator: WalletConnectServerDelegate {
}
func server(_ server: WalletConnectServerType, didFail error: Error) {
info("WalletConnect didFail error: \(error)")
infoLog("WalletConnect didFail error: \(error)")
let errorMessage = R.string.localizable.walletConnectFailureTitle()
displayErrorMessage(errorMessage)
}
func server(_ server: WalletConnectServerType, tookTooLongToConnectToUrl url: AlphaWallet.WalletConnect.ConnectionUrl) {
if Features.isUsingAppEnforcedTimeoutForMakingWalletConnectConnections {
info("WalletConnect app-enforced timeout for waiting for new connection")
infoLog("WalletConnect app-enforced timeout for waiting for new connection")
analyticsCoordinator.log(action: Analytics.Action.walletConnectConnectionTimeout, properties: [
Analytics.WalletConnectAction.connectionUrl.rawValue: url.absoluteString
])
let errorMessage = R.string.localizable.walletConnectErrorConnectionTimeoutErrorMessage()
displayConnectionTimeout(errorMessage)
} else {
info("WalletConnect app-enforced timeout for waiting for new connection. Disabled")
infoLog("WalletConnect app-enforced timeout for waiting for new connection. Disabled")
}
}
func server(_ server: WalletConnectServerType, shouldConnectFor sessionProposal: AlphaWallet.WalletConnect.SessionProposal, completion: @escaping (AlphaWallet.WalletConnect.SessionProposalResponse) -> Void) {
info("WalletConnect shouldConnectFor connection: \(sessionProposal)")
infoLog("WalletConnect shouldConnectFor connection: \(sessionProposal)")
firstly {
WalletConnectToSessionCoordinator.promise(navigationController, coordinator: self, sessionProposal: sessionProposal, serverChoices: serverChoices, analyticsCoordinator: analyticsCoordinator, config: config)
}.done { choise in
@ -357,7 +357,7 @@ extension WalletConnectCoordinator: WalletConnectServerDelegate {
}
private func sendRawTransaction(session: WalletSession, rawTransaction: String) -> Promise<AlphaWallet.WalletConnect.Callback> {
info("WalletConnect sendRawTransaction: \(rawTransaction)")
infoLog("WalletConnect sendRawTransaction: \(rawTransaction)")
return firstly {
showSignRawTransaction(title: R.string.localizable.walletConnectSendRawTransactionTitle(), message: rawTransaction)
}.then { shouldSend -> Promise<ConfirmResult> in
@ -390,7 +390,7 @@ extension WalletConnectCoordinator: WalletConnectServerDelegate {
}
private func showSignRawTransaction(title: String, message: String) -> Promise<Bool> {
info("WalletConnect showSignRawTransaction title: \(title) message: \(message)")
infoLog("WalletConnect showSignRawTransaction title: \(title) message: \(message)")
return Promise { seal in
let style: UIAlertController.Style = UIDevice.current.userInterfaceIdiom == .pad ? .alert : .actionSheet
@ -421,7 +421,7 @@ extension WalletConnectCoordinator: WalletConnectSessionsViewControllerDelegate
}
func didClose(in viewController: WalletConnectSessionsViewController) {
info("WalletConnect didClose")
infoLog("WalletConnect didClose")
//NOTE: even if we haven't sessions view controller pushed to navigation stack, we need to make sure that root NavigationBar will be hidden
navigationController.setNavigationBarHidden(true, animated: false)
@ -430,7 +430,7 @@ extension WalletConnectCoordinator: WalletConnectSessionsViewControllerDelegate
}
func didDisconnectSelected(session: AlphaWallet.WalletConnect.Session, in viewController: WalletConnectSessionsViewController) {
info("WalletConnect didDisconnect session: \(session.identifier.description)")
infoLog("WalletConnect didDisconnect session: \(session.identifier.description)")
analyticsCoordinator.log(action: Analytics.Action.walletConnectDisconnect)
do {
try provider.disconnectSession(session: session)
@ -441,7 +441,7 @@ extension WalletConnectCoordinator: WalletConnectSessionsViewControllerDelegate
}
func didSessionSelected(session: AlphaWallet.WalletConnect.Session, in viewController: WalletConnectSessionsViewController) {
info("WalletConnect didSelect session: \(session)")
infoLog("WalletConnect didSelect session: \(session)")
guard let navigationController = viewController.navigationController else { return }
display(session: session, in: navigationController)

@ -82,7 +82,7 @@ class WalletConnectV1Provider: WalletConnectServerType {
}
deinit {
debug("[WalletConnect] WalletConnectServer.deinit")
debugLog("[WalletConnect] WalletConnectServer.deinit")
server.unregister(handler: requestHandler)
}
@ -91,7 +91,7 @@ class WalletConnectV1Provider: WalletConnectServerType {
case .v1(let wcUrl):
let timer = Timer.scheduledTimer(withTimeInterval: Self.connectionTimeout, repeats: false) { _ in
let isStillWatching = self.connectionTimeoutTimers[wcUrl] != nil
debug("WalletConnect app-enforced connection timer is up for: \(wcUrl.absoluteString) isStillWatching: \(isStillWatching)")
debugLog("WalletConnect app-enforced connection timer is up for: \(wcUrl.absoluteString) isStillWatching: \(isStillWatching)")
if isStillWatching {
//TODO be good if we can do `server.communicator.disconnect(from: url)` here on in the delegate. But `communicator` is not accessible
self.delegate?.server(self, tookTooLongToConnectToUrl: url)
@ -108,7 +108,7 @@ class WalletConnectV1Provider: WalletConnectServerType {
}
func session(forIdentifier identifier: AlphaWallet.WalletConnect.SessionIdentifier) -> AlphaWallet.WalletConnect.Session? {
return storage.value.first(where: { $0.identifier == identifier }).flatMap { .init(session: $0) }
return storage.value.first(where: { $0.identifier == identifier }).flatMap { .init(session: $0) }
}
func updateSession(session: AlphaWallet.WalletConnect.Session, servers: [RPCServer]) throws {
@ -187,7 +187,7 @@ class WalletConnectV1Provider: WalletConnectServerType {
extension WalletConnectV1Provider: WalletConnectV1ServerRequestHandlerDelegate {
func handler(_ handler: RequestHandlerToAvoidMemoryLeak, request: WalletConnectV1Request) {
debug("WalletConnect handler request: \(request.method) url: \(request.url.absoluteString)")
debugLog("WalletConnect handler request: \(request.method) url: \(request.url.absoluteString)")
DispatchQueue.main.async { [weak self] in
guard let strongSelf = self else { return }
@ -209,7 +209,7 @@ extension WalletConnectV1Provider: WalletConnectV1ServerRequestHandlerDelegate {
}
func handler(_ handler: RequestHandlerToAvoidMemoryLeak, canHandle request: WalletConnectV1Request) -> Bool {
debug("WalletConnect canHandle: \(request.method) url: \(request.url.absoluteString)")
debugLog("WalletConnect canHandle: \(request.method) url: \(request.url.absoluteString)")
return true
}
}
@ -221,7 +221,7 @@ extension WalletConnectV1Provider: ServerDelegate {
}
func server(_ server: Server, didFailToConnect url: WalletConnectV1URL) {
debug("WalletConnect didFailToConnect: \(url)")
debugLog("WalletConnect didFailToConnect: \(url)")
DispatchQueue.main.async {
self.connectionTimeoutTimers[url] = nil
self.removeSession(for: url)
@ -272,14 +272,14 @@ extension WalletConnectV1Provider: ServerDelegate {
}
func server(_ server: Server, didUpdate session: Session) {
debug("WalletConnect didUpdate: \(session.url.absoluteString)")
debugLog("WalletConnect didUpdate: \(session.url.absoluteString)")
DispatchQueue.main.async {
self.addOrUpdateSession(session: session)
}
}
func server(_ server: Server, didConnect session: Session) {
debug("WalletConnect didConnect: \(session.url.absoluteString)")
debugLog("WalletConnect didConnect: \(session.url.absoluteString)")
DispatchQueue.main.async {
let nativeSession: SingleServerWalletConnectSession = self.addOrUpdateSession(session: session)
if let delegate = self.delegate {

@ -58,7 +58,7 @@ class WalletConnectV2Provider: WalletConnectServerType {
func connect(url: AlphaWallet.WalletConnect.ConnectionUrl) throws {
switch url {
case .v2(let uri):
debug("[RESPONDER] Pairing to: \(uri.absoluteString)")
debugLog("[RESPONDER] Pairing to: \(uri.absoluteString)")
try client.pair(uri: uri.absoluteString)
case .v1:
@ -68,7 +68,7 @@ class WalletConnectV2Provider: WalletConnectServerType {
func updateSession(session: AlphaWallet.WalletConnect.Session, servers: [RPCServer]) throws {
guard let index = storage.value.firstIndex(where: { $0.identifier == session.identifier }) else { return }
var session = storage.value[index]
let topic = session.identifier.description
session.servers = servers
@ -152,15 +152,15 @@ extension AlphaWallet.WalletConnect.SessionProposal {
extension WalletConnectV2Provider: WalletConnectClientDelegate {
func didReceive(notification: SessionNotification, sessionTopic: String) {
debug("[RESPONDER] WC: Did receive notification")
debugLog("[RESPONDER] WC: Did receive notification")
}
func didSettle(pairing: Pairing) {
debug("[RESPONDER] WC: Did sattle pairing topic")
debugLog("[RESPONDER] WC: Did sattle pairing topic")
}
func didUpdate(pairingTopic: String, appMetadata: AppMetadata) {
debug("[RESPONDER] WC: Did update pairing topic")
debugLog("[RESPONDER] WC: Did update pairing topic")
}
func didReceive(sessionProposal: SessionProposal) {
@ -178,10 +178,10 @@ extension WalletConnectV2Provider: WalletConnectClientDelegate {
}
private func _didReceive(sessionProposal: SessionProposal, completion: @escaping () -> Void) {
debug("[RESPONDER] WC: Did receive session proposal")
debugLog("[RESPONDER] WC: Did receive session proposal")
func reject(sessionProposal: SessionProposal) {
debug("[RESPONDER] WC: Did reject session proposal: \(sessionProposal)")
debugLog("[RESPONDER] WC: Did reject session proposal: \(sessionProposal)")
client.reject(proposal: sessionProposal, reason: SessionType.Reason(code: 0, message: "reject"))
completion()
}
@ -211,7 +211,7 @@ extension WalletConnectV2Provider: WalletConnectClientDelegate {
eip155URLCoder.encode(rpcServer: $0.server, address: $0.account.address)
}
debug("[RESPONDER] WC: Did accept session proposal: \(sessionProposal) accounts: \(Set(accounts))")
debugLog("[RESPONDER] WC: Did accept session proposal: \(sessionProposal) accounts: \(Set(accounts))")
strongSelf.client.approve(proposal: sessionProposal, accounts: Set(accounts), completion: { response in
DispatchQueue.main.async {
strongSelf.pendingSessionProposal = .none
@ -254,10 +254,10 @@ extension WalletConnectV2Provider: WalletConnectClientDelegate {
}
func didReceive(sessionRequest: SessionRequest) {
debug("[RESPONDER] WC: Did receive session request")
debugLog("[RESPONDER] WC: Did receive session request")
func reject(sessionRequest: SessionRequest) {
debug("[RESPONDER] WC: Did reject session proposal: \(sessionRequest)")
debugLog("[RESPONDER] WC: Did reject session proposal: \(sessionRequest)")
client.respond(topic: sessionRequest.topic, response: sessionRequest.rejected(error: .requestRejected))
}
//NOTE: guard check to avoid passing unacceptable rpc server,(when requested server is disabled)
@ -287,15 +287,15 @@ extension WalletConnectV2Provider: WalletConnectClientDelegate {
}
func didSettle(pairing: PairingType.Settled) {
debug("[RESPONDER] WC: Did settle pairing")
debugLog("[RESPONDER] WC: Did settle pairing")
}
func didReject(sessionPendingTopic: String, reason: SessionType.Reason) {
debug("[RESPONDER] WC: Did reject session reason: \(reason)")
debugLog("[RESPONDER] WC: Did reject session reason: \(reason)")
}
func didSettle(session: Session) {
debug("[RESPONDER] WC: Did settle session")
debugLog("[RESPONDER] WC: Did settle session")
DispatchQueue.main.async { [weak self] in
guard let strongSelf = self else { return }
@ -311,7 +311,7 @@ extension WalletConnectV2Provider: WalletConnectClientDelegate {
}
func didUpgrade(sessionTopic: String, permissions: SessionType.Permissions) {
debug("[RESPONDER] WC: Did receive session upgrate")
debugLog("[RESPONDER] WC: Did receive session upgrate")
DispatchQueue.main.async { [weak self] in
guard let strongSelf = self else { return }
@ -323,11 +323,11 @@ extension WalletConnectV2Provider: WalletConnectClientDelegate {
}
func didUpdate(sessionTopic: String, accounts: Set<String>) {
debug("[RESPONDER] WC: Did receive session update")
debugLog("[RESPONDER] WC: Did receive session update")
}
func didDelete(sessionTopic: String, reason: SessionType.Reason) {
debug("[RESPONDER] WC: Did receive session delete")
debugLog("[RESPONDER] WC: Did receive session delete")
DispatchQueue.main.async { [weak self] in
guard let strongSelf = self else { return }

@ -15,7 +15,7 @@ struct WalletConnectRequestConverter {
guard let rpcServer: RPCServer = request.server else {
return .init(error: WalletConnectRequestConverter.sessionRequestRPCServerMissing)
}
debug("WalletConnect convert request: \(request.method) url: \(request.topicOrURLString)")
debugLog("WalletConnect convert request: \(request.method) url: \(request.topicOrURLString)")
let token = TokensDataStore.token(forServer: rpcServer)
let data: AlphaWallet.WalletConnect.Request

@ -21,11 +21,11 @@ class CreateRedeemTests: XCTestCase {
do {
let signature = try keyStore.signMessageData(data!, for: account.dematerialize())
//message and signature is to go in qr code
debug("message: " + message)
debug(try "signature: " + signature.dematerialize().hexString)
debugLog("message: " + message)
debugLog(try "signature: " + signature.dematerialize().hexString)
//TODO no test?
} catch {
debug(error)
debugLog(error)
}
}
}

Loading…
Cancel
Save