From c3c9225c478247079a23eb60c5c4d6b64602eae9 Mon Sep 17 00:00:00 2001 From: Dmitry Bespalov Date: Wed, 16 Aug 2023 19:05:57 +0200 Subject: [PATCH 1/5] GH-3096 addOwner link update - Changed the link format - Refactored the link generation --- Multisig.xcodeproj/project.pbxproj | 17 ++++ .../xcshareddata/swiftpm/Package.resolved | 9 +++ Multisig/App/SceneDelegate.swift | 4 +- .../AddOwnerRequestUrlValidator.swift | 28 ++++++- .../ShareAddOwnerLinkViewController.swift | 6 +- .../Logic/AddOwnerRequestValidatorTests.swift | 81 +++++++++++-------- 6 files changed, 105 insertions(+), 40 deletions(-) diff --git a/Multisig.xcodeproj/project.pbxproj b/Multisig.xcodeproj/project.pbxproj index e35502d88..f5ae6c024 100644 --- a/Multisig.xcodeproj/project.pbxproj +++ b/Multisig.xcodeproj/project.pbxproj @@ -999,6 +999,7 @@ B0D61F54F176906A7C5A65CB /* SendTransactionRequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D61BDFEADB74805D9221DB /* SendTransactionRequestViewController.swift */; }; B0D61FFF1935AA2484BD940A /* WebConnectionRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D617C60F3081A3A923005D /* WebConnectionRepository.swift */; }; B343BEB32A77DDA1006BF46B /* DMSans-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0491067C28F99246005A4A99 /* DMSans-Bold.ttf */; }; + B3B5A4B82A8D008400D1EB71 /* PasswordChecker in Frameworks */ = {isa = PBXBuildFile; productRef = B3B5A4B72A8D008400D1EB71 /* PasswordChecker */; }; B3B6044F2A850F5E007BDAC0 /* UIAlertControllerStyle+Multiplatform.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B6044E2A850F5E007BDAC0 /* UIAlertControllerStyle+Multiplatform.swift */; }; D80B5A032769CEAD00D6E024 /* Tooltip.swift in Sources */ = {isa = PBXBuildFile; fileRef = D80B5A022769CEAD00D6E024 /* Tooltip.swift */; }; D80B5A052769CF1B00D6E024 /* TooltipSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = D80B5A042769CF1B00D6E024 /* TooltipSource.swift */; }; @@ -2054,6 +2055,7 @@ 55D3FF65260B2551008ABD2B /* Kingfisher in Frameworks */, 0497B2B929A641C9007109ED /* WalletConnectPush in Frameworks */, 0497B2B529A641C9007109ED /* WalletConnectNetworking in Frameworks */, + B3B5A4B82A8D008400D1EB71 /* PasswordChecker in Frameworks */, 0497B2B729A641C9007109ED /* WalletConnectPairing in Frameworks */, 0A0C094C287D7D48000CEB4F /* WalletConnectSwift in Frameworks */, 55DA0663269C9411006C9AA5 /* Version in Frameworks */, @@ -4700,6 +4702,7 @@ 04C22B312A36807500F58A15 /* Web3ContractABI */, 04C22B332A36807500F58A15 /* Web3PromiseKit */, 04AECBB62A744B21008D5A35 /* MoonpaySDK */, + B3B5A4B72A8D008400D1EB71 /* PasswordChecker */, ); productName = Multisig; productReference = 0A93DD532445CC8A00688050 /* Multisig_PROD.app */; @@ -4824,6 +4827,7 @@ 04C22B2B2A367FF800F58A15 /* XCRemoteSwiftPackageReference "customauth-swift-sdk" */, 04C22B2E2A36807500F58A15 /* XCRemoteSwiftPackageReference "SafeWeb3" */, 04AECBB52A744B21008D5A35 /* XCRemoteSwiftPackageReference "mobile-sdk-ios" */, + B3B5A4B62A8D008400D1EB71 /* XCRemoteSwiftPackageReference "wallet-passwordchecker-ios" */, ); productRefGroup = 0A93DD542445CC8A00688050 /* Products */; projectDirPath = ""; @@ -7379,6 +7383,14 @@ minimumVersion = 14.0.0; }; }; + B3B5A4B62A8D008400D1EB71 /* XCRemoteSwiftPackageReference "wallet-passwordchecker-ios" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/5afe/wallet-passwordchecker-ios.git"; + requirement = { + branch = main; + kind = branch; + }; + }; D80B5A11276B5FAD00D6E024 /* XCRemoteSwiftPackageReference "SkeletonView" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Juanpe/SkeletonView.git"; @@ -7579,6 +7591,11 @@ package = 93EE3F732760F49700111F17 /* XCRemoteSwiftPackageReference "intercom-ios" */; productName = Intercom; }; + B3B5A4B72A8D008400D1EB71 /* PasswordChecker */ = { + isa = XCSwiftPackageProductDependency; + package = B3B5A4B62A8D008400D1EB71 /* XCRemoteSwiftPackageReference "wallet-passwordchecker-ios" */; + productName = PasswordChecker; + }; D80B5A12276B5FAD00D6E024 /* SkeletonView */ = { isa = XCSwiftPackageProductDependency; package = D80B5A11276B5FAD00D6E024 /* XCRemoteSwiftPackageReference "SkeletonView" */; diff --git a/Multisig.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Multisig.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index e454df2c6..b69994365 100644 --- a/Multisig.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Multisig.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -370,6 +370,15 @@ "version": "2.0.1" } }, + { + "package": "PasswordChecker", + "repositoryURL": "https://github.com/5afe/wallet-passwordchecker-ios.git", + "state": { + "branch": "main", + "revision": "1e8bc8b2e44edea6ff1b0ee6125e402f78a00477", + "version": null + } + }, { "package": "WalletConnectSwift", "repositoryURL": "https://github.com/WalletConnect/WalletConnectSwift", diff --git a/Multisig/App/SceneDelegate.swift b/Multisig/App/SceneDelegate.swift index 5ff54596c..854b1c7a8 100644 --- a/Multisig/App/SceneDelegate.swift +++ b/Multisig/App/SceneDelegate.swift @@ -149,8 +149,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // - WalletConnect links from dapps to connect to the safe // - 'connect' link to establish new connection // - 'open' link to move the app to foreground so that it is able to process WalletConnect request or response. - // - Request To Add Owner - // - //addOwner?address= + // - Request To Add Owner + // - /addOwner?safe=&address= // - Web3auth // - handled by CustomAuth.handle() private func handleUserActivity(_ userActivity: NSUserActivity) { diff --git a/Multisig/UI/Settings/OwnerKeyManagement/AddKeyAsNewOwner/AddOwnerRequestUrlValidator.swift b/Multisig/UI/Settings/OwnerKeyManagement/AddKeyAsNewOwner/AddOwnerRequestUrlValidator.swift index a80a1124c..5523e98a9 100644 --- a/Multisig/UI/Settings/OwnerKeyManagement/AddKeyAsNewOwner/AddOwnerRequestUrlValidator.swift +++ b/Multisig/UI/Settings/OwnerKeyManagement/AddKeyAsNewOwner/AddOwnerRequestUrlValidator.swift @@ -12,6 +12,29 @@ struct AddOwnerRequestParameters { var chain: Chain var safeAddress: Address var ownerAddress: Address + + func link() -> String { + var url = App.configuration.services.webAppURL + .appendingPathComponent("addOwner") + + let result: String + + let queryItems = [ + URLQueryItem(name: "safe", value: "\(chain.shortName!):\(safeAddress.checksummed)"), + URLQueryItem(name: "address", value: ownerAddress.checksummed) + ] + + if #available(iOS 16, *) { + url.append(queryItems: queryItems) + result = url.absoluteString + } else { + var comps = URLComponents(url: url, resolvingAgainstBaseURL: false)! + comps.queryItems = queryItems + result = comps.url!.absoluteString + } + + return result + } } struct AddOwnerRequestValidator { @@ -23,11 +46,10 @@ struct AddOwnerRequestValidator { } set { _webAppURL = newValue - pattern = "^\(newValue)([-a-zA-Z0-9]{1,20}):(0x[a-fA-F0-9]{40})/addOwner\\?address=(0x[a-fA-F0-9]{40})$" + pattern = "^\(newValue)addOwner\\?safe=([-a-zA-Z0-9]{1,20}):(0x[a-fA-F0-9]{40})&address=(0x[a-fA-F0-9]{40})$" } } - - private static var pattern = "^\(webAppURL)([-a-zA-Z0-9]{1,20}):(0x[a-fA-F0-9]{40})/addOwner\\?address=(0x[a-fA-F0-9]{40})$" + private static var pattern = "^\(webAppURL)addOwner\\?safe=([-a-zA-Z0-9]{1,20}):(0x[a-fA-F0-9]{40})&address=(0x[a-fA-F0-9]{40})$" static func isValid(url: URL) -> Bool { guard url.absoluteString.matches(pattern: pattern) else { return false } diff --git a/Multisig/UI/Settings/OwnerKeyManagement/GenerateOwnerKey/ShareAddOwnerLinkViewController.swift b/Multisig/UI/Settings/OwnerKeyManagement/GenerateOwnerKey/ShareAddOwnerLinkViewController.swift index 73bf892c2..dbc84dbf3 100644 --- a/Multisig/UI/Settings/OwnerKeyManagement/GenerateOwnerKey/ShareAddOwnerLinkViewController.swift +++ b/Multisig/UI/Settings/OwnerKeyManagement/GenerateOwnerKey/ShareAddOwnerLinkViewController.swift @@ -45,7 +45,11 @@ class ShareAddOwnerLinkViewController: UIViewController { tableView.rowHeight = UITableView.automaticDimension tableView.estimatedRowHeight = 100 - shareLinkView.set(text: App.configuration.services.webAppURL.appendingPathComponent("\(safe.chain!.shortName!):\(safe.displayAddress)/addOwner?address=\(owner.checksummed)").absoluteString) + + let params = AddOwnerRequestParameters(chain: safe.chain!, safeAddress: safe.addressValue, ownerAddress: owner) + let text = params.link() + + shareLinkView.set(text: text) shareLinkView.onShare = { [weak self] text in let vc = UIActivityViewController(activityItems: [text], applicationActivities: nil) vc.completionWithItemsHandler = { _, success, _, _ in diff --git a/MultisigTests/Logic/AddOwnerRequestValidatorTests.swift b/MultisigTests/Logic/AddOwnerRequestValidatorTests.swift index b334441e5..e23f2c57b 100644 --- a/MultisigTests/Logic/AddOwnerRequestValidatorTests.swift +++ b/MultisigTests/Logic/AddOwnerRequestValidatorTests.swift @@ -9,61 +9,74 @@ import XCTest @testable import Multisig +// Format change needs tests updated class AddOwnerRequestValidatorTests: XCTestCase { + let domain = "app.safe.global" override func setUp() async throws { - AddOwnerRequestValidator.webAppURL = URL(string: "https://app.safe.global/")! + AddOwnerRequestValidator.webAppURL = URL(string: "https://\(domain)/")! } func testAddOwnerRequestUrls() { - assertInvalid("https://safe.global", "missing path and query") - assertInvalid("ftp://url?query=https://safe.global/", "must start with the correct link") - assertInvalid("https://app.safe.global/", "missing rest of the path and query") - assertInvalid("https://app.safe.global/something/addOwner?address=else", "wrong format of path and query parameters") - assertInvalid("https://app.safe.global/eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner", "missing owner address query parameter") + + assertInvalid("https://\(domain)", "missing path and query") + assertInvalid("ftp://url?query=https://\(domain)/", "must start with the correct link") + assertInvalid("https://\(domain)/", "missing rest of the path and query") + assertInvalid("https://\(domain)/addOwner?safe=something&address=else", "wrong format of path and query parameters") + assertInvalid("https://\(domain)/eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner", "missing owner address query parameter") // shortname with dash - assertValid("https://app.safe.global/eth-weth:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "must support dash in shortname") + assertValid("https://\(domain)/addOwner?safe=eth-weth:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "must support dash in shortname") // shortname empty, 1, 20, 21 - assertValid("https://app.safe.global/a:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "must support one-char shortname") - assertValid("https://app.safe.global/abcde12345abcde12345:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "must support 20-char shortname") - assertInvalid("https://app.safe.global/abcde12345abcde12345e:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "shortname too long") - assertInvalid("https://app.safe.global/:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "shortname empty") + assertValid("https://\(domain)/addOwner?safe=a:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "must support one-char shortname") + assertValid("https://\(domain)/addOwner?safe=abcde12345abcde12345:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "must support 20-char shortname") + assertInvalid("https://\(domain)/addOwner?safe=abcde12345abcde12345e:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "shortname too long") + assertInvalid("https://\(domain)/addOwner?safe=:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "shortname empty") // safe address: empty, 39, 40, 41, hex, checksum wrong - assertInvalid("https://app.safe.global/eth:/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "safe address empty") - assertInvalid("https://app.safe.global/eth:0x71592E6Cbe7779D480C1D029e70904041F8f602/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "safe address too short") - assertInvalid("https://app.safe.global/eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A1/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "safe address too long") - assertValid("https://app.safe.global/eth:0x71592e6cbe7779d480c1d029e70904041f8f602a/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "must support hex safe address") - assertInvalid("https://app.safe.global/eth:0x71592E6Cbe7779D480C1D029e70904041f8f602A/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "must detect wrong checksum in safe address") + assertInvalid("https://\(domain)/addOwner?safe=eth:&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "safe address empty") + assertInvalid("https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "safe address too short") + assertInvalid("https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A1&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "safe address too long") + assertValid("https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "must support hex safe address") + assertInvalid("https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041f8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "must detect wrong checksum in safe address") // owner address: empty, 39, 40, 41, hex, checksum wrong - assertInvalid("https://app.safe.global/eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=", "owner address empty") - assertInvalid("https://app.safe.global/eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b6", "owner address too short") - assertInvalid("https://app.safe.global/eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66a", "owner address too long") - assertValid("https://app.safe.global/eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=0x8e6a5adb2b88257a3dac7a76a7b4ecacda090b66", "must support hex owner address") - assertInvalid("https://app.safe.global/eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090B66", "must detect wrong checksum in owner address") + assertInvalid("https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=", "owner address empty") + assertInvalid("https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b6", "owner address too short") + assertInvalid("https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66a", "owner address too long") + assertValid("https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6a5adb2b88257a3dac7a76a7b4ecacda090b66", "must support hex owner address") + assertInvalid("https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090B66", "must detect wrong checksum in owner address") // additional params - assertInvalid("https://app.safe.global/eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66&some=value", "happy case not working") + assertInvalid("https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66&some=value", "happy case not working") // happy case - assertValid("https://app.safe.global/eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "happy case not working") + assertValid("https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66", "happy case not working") } -// func testExtractsParameters() { -// let url = URL(string: "https://app.safe.global/eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A/addOwner?address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66")! -// guard let parameters = AddOwnerRequestValidator.parameters(from: url) else { -// XCTFail("Parameters not found in correct link") -// return -// } -// -// XCTAssertEqual(parameters.chain.shortName, "eth") -// XCTAssertEqual(parameters.safeAddress, "0x71592E6Cbe7779D480C1D029e70904041F8f602A") -// XCTAssertEqual(parameters.ownerAddress, "0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66") -// } + func testExtractsParameters() { + let url = URL(string: "https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66")! + guard let parameters = AddOwnerRequestValidator.parameters(from: url) else { + XCTFail("Parameters not found in correct link") + return + } + + XCTAssertEqual(parameters.chain.shortName, "eth") + XCTAssertEqual(parameters.safeAddress, "0x71592E6Cbe7779D480C1D029e70904041F8f602A") + XCTAssertEqual(parameters.ownerAddress, "0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66") + } + + func testLink() { + let str = AddOwnerRequestParameters( + chain: .mainnetChain(), + safeAddress: "0x71592E6Cbe7779D480C1D029e70904041F8f602A", + ownerAddress: "0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66" + ).link() + + XCTAssertEqual(str, "https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66") + } func assertInvalid(_ str: String, _ message: String, line: UInt = #line) { guard let url = URL(string: str) else { From 5a334ca445b82d457a729c73f544f49efe03293c Mon Sep 17 00:00:00 2001 From: Dmitry Bespalov Date: Mon, 21 Aug 2023 10:55:51 +0200 Subject: [PATCH 2/5] GH-3096 repair the generated key flow --- .../Settings/OwnerKeyManagement/Backup/UIFlow.swift | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Multisig/UI/Settings/OwnerKeyManagement/Backup/UIFlow.swift b/Multisig/UI/Settings/OwnerKeyManagement/Backup/UIFlow.swift index c34a35c0b..ac6a75c46 100644 --- a/Multisig/UI/Settings/OwnerKeyManagement/Backup/UIFlow.swift +++ b/Multisig/UI/Settings/OwnerKeyManagement/Backup/UIFlow.swift @@ -50,9 +50,13 @@ class UIFlow: NSObject { if let presentedViewController = presenter.presentedViewController { presentedViewController.dismiss(animated: true) { [weak self] in self?.presenter.present(nav, animated: true) + // the actual presenting view controller might be different from the `presenter` + self?.presenter = nav.presentingViewController } } else { presenter.present(nav, animated: true) + // the actual presenting view controller might be different from the `presenter` + presenter = nav.presentingViewController } } @@ -71,13 +75,8 @@ class UIFlow: NSObject { } func stop(success: Bool) { - if let presenter = presenter, presenter.presentedViewController != nil { - presenter.dismiss(animated: true) { [unowned self] in - completion(success) - } - } else if let presenter = navigationController.presentingViewController { - // in this case, the presenting view controller is not a direct ancestor of the - // currently opened view controller + if let presenter = presenter { + assert(presenter.presentedViewController != nil) presenter.dismiss(animated: true) { [unowned self] in completion(success) } From 07936d38fc9c93ea7be94b1968248939e1a88b98 Mon Sep 17 00:00:00 2001 From: Dmitry Bespalov Date: Mon, 21 Aug 2023 11:21:26 +0200 Subject: [PATCH 3/5] GH-3096 Fix fragile test --- .../AddKeyAsNewOwner/AddOwnerRequestUrlValidator.swift | 4 ++-- MultisigTests/Logic/AddOwnerRequestValidatorTests.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Multisig/UI/Settings/OwnerKeyManagement/AddKeyAsNewOwner/AddOwnerRequestUrlValidator.swift b/Multisig/UI/Settings/OwnerKeyManagement/AddKeyAsNewOwner/AddOwnerRequestUrlValidator.swift index 5523e98a9..a71a30460 100644 --- a/Multisig/UI/Settings/OwnerKeyManagement/AddKeyAsNewOwner/AddOwnerRequestUrlValidator.swift +++ b/Multisig/UI/Settings/OwnerKeyManagement/AddKeyAsNewOwner/AddOwnerRequestUrlValidator.swift @@ -13,8 +13,8 @@ struct AddOwnerRequestParameters { var safeAddress: Address var ownerAddress: Address - func link() -> String { - var url = App.configuration.services.webAppURL + func link(base: URL = App.configuration.services.webAppURL) -> String { + var url = base .appendingPathComponent("addOwner") let result: String diff --git a/MultisigTests/Logic/AddOwnerRequestValidatorTests.swift b/MultisigTests/Logic/AddOwnerRequestValidatorTests.swift index e23f2c57b..4bfa0ad38 100644 --- a/MultisigTests/Logic/AddOwnerRequestValidatorTests.swift +++ b/MultisigTests/Logic/AddOwnerRequestValidatorTests.swift @@ -73,7 +73,7 @@ class AddOwnerRequestValidatorTests: XCTestCase { chain: .mainnetChain(), safeAddress: "0x71592E6Cbe7779D480C1D029e70904041F8f602A", ownerAddress: "0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66" - ).link() + ).link(base: AddOwnerRequestValidator.webAppURL) XCTAssertEqual(str, "https://\(domain)/addOwner?safe=eth:0x71592E6Cbe7779D480C1D029e70904041F8f602A&address=0x8e6A5aDb2B88257A3DAc7A76A7B4EcaCdA090b66") } From 9cef121a63d4fa0e034e3d0670c1d8eb34db08ba Mon Sep 17 00:00:00 2001 From: Dmitry Bespalov Date: Mon, 21 Aug 2023 14:25:42 +0200 Subject: [PATCH 4/5] GH-3096 remove unused dependency --- Multisig.xcodeproj/project.pbxproj | 17 ----------------- .../xcshareddata/swiftpm/Package.resolved | 9 --------- 2 files changed, 26 deletions(-) diff --git a/Multisig.xcodeproj/project.pbxproj b/Multisig.xcodeproj/project.pbxproj index f5ae6c024..e35502d88 100644 --- a/Multisig.xcodeproj/project.pbxproj +++ b/Multisig.xcodeproj/project.pbxproj @@ -999,7 +999,6 @@ B0D61F54F176906A7C5A65CB /* SendTransactionRequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D61BDFEADB74805D9221DB /* SendTransactionRequestViewController.swift */; }; B0D61FFF1935AA2484BD940A /* WebConnectionRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0D617C60F3081A3A923005D /* WebConnectionRepository.swift */; }; B343BEB32A77DDA1006BF46B /* DMSans-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0491067C28F99246005A4A99 /* DMSans-Bold.ttf */; }; - B3B5A4B82A8D008400D1EB71 /* PasswordChecker in Frameworks */ = {isa = PBXBuildFile; productRef = B3B5A4B72A8D008400D1EB71 /* PasswordChecker */; }; B3B6044F2A850F5E007BDAC0 /* UIAlertControllerStyle+Multiplatform.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B6044E2A850F5E007BDAC0 /* UIAlertControllerStyle+Multiplatform.swift */; }; D80B5A032769CEAD00D6E024 /* Tooltip.swift in Sources */ = {isa = PBXBuildFile; fileRef = D80B5A022769CEAD00D6E024 /* Tooltip.swift */; }; D80B5A052769CF1B00D6E024 /* TooltipSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = D80B5A042769CF1B00D6E024 /* TooltipSource.swift */; }; @@ -2055,7 +2054,6 @@ 55D3FF65260B2551008ABD2B /* Kingfisher in Frameworks */, 0497B2B929A641C9007109ED /* WalletConnectPush in Frameworks */, 0497B2B529A641C9007109ED /* WalletConnectNetworking in Frameworks */, - B3B5A4B82A8D008400D1EB71 /* PasswordChecker in Frameworks */, 0497B2B729A641C9007109ED /* WalletConnectPairing in Frameworks */, 0A0C094C287D7D48000CEB4F /* WalletConnectSwift in Frameworks */, 55DA0663269C9411006C9AA5 /* Version in Frameworks */, @@ -4702,7 +4700,6 @@ 04C22B312A36807500F58A15 /* Web3ContractABI */, 04C22B332A36807500F58A15 /* Web3PromiseKit */, 04AECBB62A744B21008D5A35 /* MoonpaySDK */, - B3B5A4B72A8D008400D1EB71 /* PasswordChecker */, ); productName = Multisig; productReference = 0A93DD532445CC8A00688050 /* Multisig_PROD.app */; @@ -4827,7 +4824,6 @@ 04C22B2B2A367FF800F58A15 /* XCRemoteSwiftPackageReference "customauth-swift-sdk" */, 04C22B2E2A36807500F58A15 /* XCRemoteSwiftPackageReference "SafeWeb3" */, 04AECBB52A744B21008D5A35 /* XCRemoteSwiftPackageReference "mobile-sdk-ios" */, - B3B5A4B62A8D008400D1EB71 /* XCRemoteSwiftPackageReference "wallet-passwordchecker-ios" */, ); productRefGroup = 0A93DD542445CC8A00688050 /* Products */; projectDirPath = ""; @@ -7383,14 +7379,6 @@ minimumVersion = 14.0.0; }; }; - B3B5A4B62A8D008400D1EB71 /* XCRemoteSwiftPackageReference "wallet-passwordchecker-ios" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/5afe/wallet-passwordchecker-ios.git"; - requirement = { - branch = main; - kind = branch; - }; - }; D80B5A11276B5FAD00D6E024 /* XCRemoteSwiftPackageReference "SkeletonView" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Juanpe/SkeletonView.git"; @@ -7591,11 +7579,6 @@ package = 93EE3F732760F49700111F17 /* XCRemoteSwiftPackageReference "intercom-ios" */; productName = Intercom; }; - B3B5A4B72A8D008400D1EB71 /* PasswordChecker */ = { - isa = XCSwiftPackageProductDependency; - package = B3B5A4B62A8D008400D1EB71 /* XCRemoteSwiftPackageReference "wallet-passwordchecker-ios" */; - productName = PasswordChecker; - }; D80B5A12276B5FAD00D6E024 /* SkeletonView */ = { isa = XCSwiftPackageProductDependency; package = D80B5A11276B5FAD00D6E024 /* XCRemoteSwiftPackageReference "SkeletonView" */; diff --git a/Multisig.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Multisig.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index b69994365..e454df2c6 100644 --- a/Multisig.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Multisig.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -370,15 +370,6 @@ "version": "2.0.1" } }, - { - "package": "PasswordChecker", - "repositoryURL": "https://github.com/5afe/wallet-passwordchecker-ios.git", - "state": { - "branch": "main", - "revision": "1e8bc8b2e44edea6ff1b0ee6125e402f78a00477", - "version": null - } - }, { "package": "WalletConnectSwift", "repositoryURL": "https://github.com/WalletConnect/WalletConnectSwift", From e39563c564a4ba452af20c9838d3565a0ac74114 Mon Sep 17 00:00:00 2001 From: Dmitry Bespalov Date: Mon, 21 Aug 2023 14:29:11 +0200 Subject: [PATCH 5/5] GH-3096 replaced assert with optional unwrap --- Multisig/UI/Settings/OwnerKeyManagement/Backup/UIFlow.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Multisig/UI/Settings/OwnerKeyManagement/Backup/UIFlow.swift b/Multisig/UI/Settings/OwnerKeyManagement/Backup/UIFlow.swift index ac6a75c46..727ccbb01 100644 --- a/Multisig/UI/Settings/OwnerKeyManagement/Backup/UIFlow.swift +++ b/Multisig/UI/Settings/OwnerKeyManagement/Backup/UIFlow.swift @@ -75,8 +75,7 @@ class UIFlow: NSObject { } func stop(success: Bool) { - if let presenter = presenter { - assert(presenter.presentedViewController != nil) + if let presenter = presenter, presenter.presentedViewController != nil { presenter.dismiss(animated: true) { [unowned self] in completion(success) }