From 1541e313ce59328946dfedbab022005ac81fa9da Mon Sep 17 00:00:00 2001 From: mike-dydx Date: Fri, 17 May 2024 14:25:23 -0400 Subject: [PATCH] remove view(...) functions --- .../_Tracking/AppsFlyerTracking.swift | 4 - .../_Tracking/FirebaseTracking.swift | 2 +- .../_Tracking/TransformerTracker.swift | 12 - .../_Tracker/_Shared/DebugTracking.swift | 12 - .../Utilities/_Tracker/_Shared/Tracking.swift | 16 - .../Pods/Local Podspecs/MagicSDK.podspec.json | 41 --- dydx/Pods/MagicSDK/LICENSE | 177 ----------- dydx/Pods/MagicSDK/README.md | 41 --- .../Sources/MagicSDK/Core/Magic.swift | 101 ------ .../Core/Provider/NetworkClient.swift | 109 ------- .../MagicSDK/Core/Provider/RpcProvider.swift | 91 ------ .../Core/Relayer/Types/AnyValue.swift | 264 ---------------- .../Relayer/Types/AnyValueConvertible.swift | 76 ----- .../Core/Relayer/Types/BasicTypes.swift | 33 -- .../MagicSDK/Core/Relayer/URLBuilder.swift | 117 ------- .../Core/Relayer/WebViewController.swift | 299 ------------------ .../Modules/Auth/AuthConfiguration.swift | 42 --- .../MagicSDK/Modules/Auth/AuthMethod.swift | 17 - .../MagicSDK/Modules/Auth/AuthModule.swift | 62 ---- .../MagicSDK/Modules/BaseConfiguration.swift | 11 - .../Sources/MagicSDK/Modules/BaseModule.swift | 32 -- .../Connect/ConnectConfiguration.swift | 18 -- .../Modules/Connect/ConnectMethod.swift | 17 - .../Modules/Connect/ConnectModule.swift | 53 ---- .../Modules/Connect/ConnectResponse.swift | 17 - .../MagicSDK/Modules/Event/EventCenter.swift | 44 --- .../MagicSDK/Modules/Event/EventPromise.swift | 33 -- .../Modules/Event/EventResponse.swift | 43 --- .../Modules/User/UserConfiguration.swift | 49 --- .../MagicSDK/Modules/User/UserMethod.swift | 23 -- .../MagicSDK/Modules/User/UserModule.swift | 153 --------- .../MagicSDK/Modules/User/UserResponse.swift | 20 -- .../Modules/Web3/EIP712TypedData.swift | 108 ------- .../MagicSDK/Modules/Web3/JSONValue.swift | 144 --------- .../MagicSDK/Modules/Web3/Web3Extension.swift | 136 -------- .../Sources/MagicSDK/Utilities/Number.swift | 12 - .../Sources/MagicSDK/Utilities/Query.swift | 25 -- .../xcshareddata/xcschemes/Abacus.xcscheme | 67 ---- .../xcshareddata/swiftpm/Package.resolved | 11 +- .../dydxAnalytics.xcodeproj/project.pbxproj | 264 ++++++++++++++++ .../dydxAnalytics/AnalyticsEvent.swift | 10 +- .../MarketInfo/dydxSelectedMarketStore.swift | 6 +- .../HostingViewController.swift | 2 +- dydxV4/dydxV4.xcodeproj/project.pbxproj | 94 +++++- .../TrackingViewController+Ext.swift | 13 +- .../_Tracking/dydxAmplitudeTracking.swift | 3 - .../_Tracking/dydxCompositeTracking.swift | 32 -- 47 files changed, 374 insertions(+), 2582 deletions(-) delete mode 100644 dydx/Pods/Local Podspecs/MagicSDK.podspec.json delete mode 100644 dydx/Pods/MagicSDK/LICENSE delete mode 100644 dydx/Pods/MagicSDK/README.md delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Magic.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Provider/NetworkClient.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Provider/RpcProvider.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/Types/AnyValue.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/Types/AnyValueConvertible.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/Types/BasicTypes.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/URLBuilder.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/WebViewController.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Auth/AuthConfiguration.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Auth/AuthMethod.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Auth/AuthModule.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/BaseConfiguration.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/BaseModule.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectConfiguration.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectMethod.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectModule.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectResponse.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Event/EventCenter.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Event/EventPromise.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Event/EventResponse.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserConfiguration.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserMethod.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserModule.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserResponse.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Web3/EIP712TypedData.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Web3/JSONValue.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Web3/Web3Extension.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Utilities/Number.swift delete mode 100644 dydx/Pods/MagicSDK/Sources/MagicSDK/Utilities/Query.swift delete mode 100644 dydx/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Abacus.xcscheme diff --git a/AppsFlyerStaticInjections/AppsFlyerStaticInjections/_Tracking/AppsFlyerTracking.swift b/AppsFlyerStaticInjections/AppsFlyerStaticInjections/_Tracking/AppsFlyerTracking.swift index 8e7b89c53..f12d2eded 100644 --- a/AppsFlyerStaticInjections/AppsFlyerStaticInjections/_Tracking/AppsFlyerTracking.swift +++ b/AppsFlyerStaticInjections/AppsFlyerStaticInjections/_Tracking/AppsFlyerTracking.swift @@ -30,10 +30,6 @@ public class AppsFlyerTracking: TransformerTracker { } } - override open func view(_ path: String?, action: String?, data: [String: Any]?, from: String?, time: Date?, revenue: NSNumber?, contextViewController: UIViewController?) { - // Only track the ones required by growth - } - override public func log(event: String, data: [String: Any]?, revenue: NSNumber?) { if !excluded { var data = data diff --git a/FirebaseStaticInjections/FirebaseStaticInjections/_Tracking/FirebaseTracking.swift b/FirebaseStaticInjections/FirebaseStaticInjections/_Tracking/FirebaseTracking.swift index 220133d5c..3b3bbb1fa 100644 --- a/FirebaseStaticInjections/FirebaseStaticInjections/_Tracking/FirebaseTracking.swift +++ b/FirebaseStaticInjections/FirebaseStaticInjections/_Tracking/FirebaseTracking.swift @@ -24,7 +24,7 @@ public class FirebaseTracking: TransformerTracker { override public init() { super.init() - FirebaseConfiguration.shared.setLoggerLevel(.min) + FirebaseConfiguration.shared.setLoggerLevel(.max) Analytics.setUserProperty(String(format: "%.4f", UIDevice.current.systemVersionAsFloat), forName: "os_version") } diff --git a/PlatformParticles/PlatformParticles/_Tracking/TransformerTracker.swift b/PlatformParticles/PlatformParticles/_Tracking/TransformerTracker.swift index 4d8ba66a1..e49dcb6dc 100644 --- a/PlatformParticles/PlatformParticles/_Tracking/TransformerTracker.swift +++ b/PlatformParticles/PlatformParticles/_Tracking/TransformerTracker.swift @@ -26,18 +26,6 @@ open class TransformerTracker: NSObject & TrackingProtocol { } } - open func view(_ path: String?, action: String?, data: [String: Any]?, from: String?, time: Date?, revenue: NSNumber?, contextViewController: UIViewController?) { - if !excluded { - if let path = transform(path: path)?.trim() { - if let action = action { - log(event: "\(path)_\(action)", data: data, revenue: revenue) - } else { - log(event: path, data: data, revenue: revenue) - } - } - } - } - open func leave(_ path: String?) { } diff --git a/Utilities/Utilities/_Tracker/_Shared/DebugTracking.swift b/Utilities/Utilities/_Tracker/_Shared/DebugTracking.swift index ec6a3c64b..f633252ff 100644 --- a/Utilities/Utilities/_Tracker/_Shared/DebugTracking.swift +++ b/Utilities/Utilities/_Tracker/_Shared/DebugTracking.swift @@ -12,18 +12,6 @@ public class DebugTracking: NSObject & TrackingProtocol { public var userInfo: [String: String?]? public var excluded: Bool = false - - public func view(_ path: String?, action: String?, data: [String: Any]?, from: String?, time: Date?, revenue: NSNumber?, contextViewController: UIViewController?) { - if let path = path { - let action = action ?? "" - let from = from ?? "" - if excluded { - Console.shared.log("Debug Tracking: View Excluded Path:\(path) Action:\(action) From:\(from)", data ?? "") - } else { - Console.shared.log("Debug Tracking: View Path:\(path) Action:\(action) From:\(from)", data ?? "") - } - } - } public func leave(_ path: String?) { if let path = path { diff --git a/Utilities/Utilities/_Tracker/_Shared/Tracking.swift b/Utilities/Utilities/_Tracker/_Shared/Tracking.swift index 2a8d6fa11..574e67c9b 100644 --- a/Utilities/Utilities/_Tracker/_Shared/Tracking.swift +++ b/Utilities/Utilities/_Tracker/_Shared/Tracking.swift @@ -11,27 +11,11 @@ import Foundation public protocol TrackingProtocol: NSObjectProtocol { var userInfo: [String: String?]? { get set } var excluded: Bool { get set } -// func view(_ path: String?, action: String?, data: [String: Any]?, from: String?, time: Date?, revenue: NSNumber?, contextViewController: UIViewController?) func leave(_ path: String?) func log(event: String, data: [String: Any]?, revenue: NSNumber?) } public extension TrackingProtocol { -// func view(_ path: String?, data: [String: Any]?, from: String?, time: Date?, revenue: NSNumber?, contextViewController: UIViewController?) { -// view(path, action: nil, data: data, from: from, time: time, revenue: revenue, contextViewController: contextViewController) -// } -// func view(_ path: String?, data: [String: Any]?, from: String?, time: Date?, revenue: NSNumber?) { -// view(path, action: nil, data: data, from: from, time: time, revenue: revenue, contextViewController: nil) -// } -// func view(_ path: String?, data: [String: Any]?, from: String?, time: Date?) { -// view(path, action: nil, data: data, from: from, time: time, revenue: nil, contextViewController: nil) -// } -// func view(_ path: String?, data: [String: Any]?, from: String?, contextViewController: UIViewController?) { -// view(path, action: nil, data: data, from: from, time: nil, revenue: nil, contextViewController: nil) -// } -// func view(_ path: String?, data: [String: Any]?) { -// view(path, action: nil, data: data, from: nil, time: nil, revenue: nil, contextViewController: nil) -// } func log(event: String, data: [String: Any]?) { log(event: event, data: data, revenue: nil) } diff --git a/dydx/Pods/Local Podspecs/MagicSDK.podspec.json b/dydx/Pods/Local Podspecs/MagicSDK.podspec.json deleted file mode 100644 index 773979e73..000000000 --- a/dydx/Pods/Local Podspecs/MagicSDK.podspec.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "MagicSDK", - "version": "6.2.0", - "summary": "Magic IOS SDK", - "description": "TODO: Add long description of the pod here.", - "homepage": "https://github.com/magiclabs/magic-ios", - "license": { - "type": "MIT", - "file": "LICENSE" - }, - "authors": { - "Jerry Liu": "jerry@magic.link" - }, - "source": { - "git": "https://github.com/magiclabs/magic-ios.git", - "tag": "6.2.0" - }, - "swift_versions": "5.0", - "platforms": { - "ios": "10.0" - }, - "source_files": "Sources/MagicSDK/**/*", - "dependencies": { - "MagicSDK-Web3": [ - "~> 1.0" - ], - "MagicSDK-Web3/ContractABI": [ - "~> 1.0" - ], - "MagicSDK-Web3/PromiseKit": [ - "~> 1.0" - ], - "PromiseKit/CorePromise": [ - "~> 6.15" - ] - }, - "pod_target_xcconfig": { - "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "arm64" - }, - "swift_version": "5.0" -} diff --git a/dydx/Pods/MagicSDK/LICENSE b/dydx/Pods/MagicSDK/LICENSE deleted file mode 100644 index 7335bc897..000000000 --- a/dydx/Pods/MagicSDK/LICENSE +++ /dev/null @@ -1,177 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - diff --git a/dydx/Pods/MagicSDK/README.md b/dydx/Pods/MagicSDK/README.md deleted file mode 100644 index f90421cb9..000000000 --- a/dydx/Pods/MagicSDK/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# MagicSDK -[![CI Status](https://img.shields.io/travis/Ethella/MagicSDK.svg?style=flat)](https://travis-ci.org/Ethella/MagicSDK) -[![Version](https://img.shields.io/cocoapods/v/MagicSDK.svg?style=flat)](https://cocoapods.org/pods/MagicSDK) -[![License](https://img.shields.io/cocoapods/l/MagicSDK.svg?style=flat)](https://cocoapods.org/pods/MagicSDK) -[![Platform](https://img.shields.io/cocoapods/p/MagicSDK.svg?style=flat)](https://cocoapods.org/pods/MagicSDK) - -Cocoapods ---- -## Set up the local development env -1. To start the demo app with local development SDK, download following projects -```bash -# demo app -$ git clone https://github.com/magiclabs/magic-ios-demo -# ios SDK -$ git clone https://github.com/magiclabs/magic-ios -``` - -2. To enable the demo use the local development SDK. Navigate to `magic-ios-demo/Podfile` and edit the following lines. -This will make pod file install local dependencies instead of the ones distributed. - -```ruby -# Distributed Library on Cocoapods -# pod 'MagicSDK', '~> 4.0' -# pod 'MagicExt-OAuth', '~> 1.0' - -# Local development library -pod 'MagicSDK', :path => '../magic-ios/MagicSDK.podspec' -pod 'MagicExt-OAuth', :path => '../magic-ios-ext/MagicExt-OAuth.podspec' -``` - -```bash -$ cd /YOUR/PATH/TO/magic-ios-demo - -# Install dependencies -$ pod install -``` - -3. Open `/YOUR/PATH/TO/magic-ios-demo/magic-ios-demo.xcworkspace` with XCode and try it out! - ---- - diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Magic.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Magic.swift deleted file mode 100644 index 56e60760c..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Magic.swift +++ /dev/null @@ -1,101 +0,0 @@ -// -// Magic.swift -// Magic ios SDK -// -// Created by Jerry Liu on 1/20/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// -import MagicSDK_Web3 -import WebKit - - -internal enum ProductType{ - case MA - case MC -} - -/// An instance of the Magic SDK -public class Magic: MagicCore { - - // MARK: - Module - public let user: UserModule - public let auth: AuthModule - - /// Shared instance of `Magic` - public static var shared: Magic! - - // MARK: - Initialization - - /// Initialize an instance of `Magic` - /// - /// - Parameters: - /// - apiKey: Your client ID. From https://dashboard.Magic.com - /// - ethNetwork: Network setting - public convenience init(apiKey: String, network: EthNetwork, locale: String = Locale.current.identifier) { - self.init(urlBuilder: URLBuilder(apiKey: apiKey, locale: locale, productType: .MA)) - } - - public convenience init(apiKey: String, customNode: CustomNodeConfiguration, locale: String = Locale.current.identifier) { - let urlBuilder = URLBuilder(apiKey: apiKey, customNode: customNode, locale: locale, productType: ProductType.MA) - self.init(urlBuilder: urlBuilder) - } - - public convenience init(apiKey: String, locale: String = Locale.current.identifier) { - self.init(urlBuilder: URLBuilder(apiKey: apiKey, locale: locale, productType: .MA)) - } - - /// Core constructor - private init(urlBuilder: URLBuilder) { - let rpcProvider = RpcProvider(urlBuilder: urlBuilder) - self.user = UserModule(rpcProvider: rpcProvider) - self.auth = AuthModule(rpcProvider: rpcProvider) - super.init(rpcProvider: rpcProvider) - } -} - -/// An instance of the Magic SDK -public class MagicConnect: MagicCore { - - public let connect: ConnectModule - - /// Shared instance of `Magic` - public static var shared: MagicConnect! - - public convenience init(apiKey: String) { - let urlBuilder = URLBuilder(apiKey: apiKey, ethNetwork: EthNetwork.mainnet, locale: "en_US", productType: ProductType.MC) - self.init(urlBuilder: urlBuilder) - } - - public convenience init(apiKey: String, network: EthNetwork) { - let urlBuilder = URLBuilder(apiKey: apiKey, ethNetwork: network, locale: "en_US", productType: ProductType.MC) - self.init(urlBuilder: urlBuilder) - } - - private init(urlBuilder: URLBuilder) { - let rpcProvider = RpcProvider(urlBuilder: urlBuilder) - self.connect = ConnectModule(rpcProvider: rpcProvider) - super.init(rpcProvider: rpcProvider) - } -} - -public class MagicCore: NSObject { - - public var rpcProvider: RpcProvider - - internal init(rpcProvider: RpcProvider) { - self.rpcProvider = rpcProvider - } -} - - -// Handles Specific RpcError -extension Web3Response { - public var magicAuthError: RpcProvider.ProviderError? { - switch self.status { - case .failure(let error): - return error as? RpcProvider.ProviderError - case .success: - return nil - } - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Provider/NetworkClient.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Provider/NetworkClient.swift deleted file mode 100644 index eb7c5ed4d..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Provider/NetworkClient.swift +++ /dev/null @@ -1,109 +0,0 @@ -// -// NetworkClient.swift -// Magic -// -// Created by Jerry Liu on 2/09/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation -import PromiseKit - -/// A base networking class that can send http requests -public class NetworkClient { - - /// Various errors that may occur while processing Web3 requests - public enum Error: Swift.Error { - /// The response did not include expected results - case unexpectedResponse(Swift.Error?) - /// The server returned an unexpected response code - case invalidResponseCode - } - - /// Internal queue for handling requests - let queue: DispatchQueue - - /// Internal URLSession for this Web3Provider's RPC requests - let session: URLSession = URLSession(configuration: .default) - - /// JSONEncoder for encoding RPCRequests - let encoder = JSONEncoder() - - /// JSONDecoder for parsing RPCResponses - let decoder = JSONDecoder() - - /// HTTP headers to add to all requests - public var headers = [ - "Content-Type": "application/json" - ] - - init() { - self.queue = DispatchQueue(label: "MagicHttpProvider", attributes: .concurrent) - } - - /// Encode an object with or without a prefix into data - /// - /// - Parameters: - /// - body: Object to encode. Must be Encodable. - /// - prefix: Optional string to prefix the body with - /// - Returns: Promise resolving with the encoded Data - func encode(body: T, withPrefix prefix: String? = nil) -> Promise { - return Promise { resolver in - queue.async { - do { - let encoded: Data - if let prefix = prefix { - encoded = try self.encoder.encode([prefix: body]) - } else { - encoded = try self.encoder.encode(body) - } - resolver.fulfill(encoded) - } catch { - resolver.reject(error) - } - } - } - } - - /// Sends a basic http request. - /// This method will create a URLRequest, and then run a URLSessionDataTask with the URLRequest. - /// Once a response is received, the response will be validated for data and a valid status code - /// before calling the callback with the resulting data or error. - /// - /// - Parameters: - /// - url: url for the request - /// - method: HTTP method to use - /// - body: Optional request body to include - /// - Returns: Promise resolving with Data from the response if it's successful - func postRequest(url: URL, method: String, body: Data?) -> Promise { - return Promise { resolver in - queue.async { - var req = URLRequest(url: url) - req.httpMethod = method - req.httpBody = body - - // Add default headers - for (k, v) in self.headers { - req.addValue(v, forHTTPHeaderField: k) - } - - // Create the URLSessionTask - let task = self.session.dataTask(with: req) { data, urlResponse, error in - guard let urlResponse = urlResponse as? HTTPURLResponse, let data = data, error == nil else { - resolver.reject(Error.unexpectedResponse(error)) - return - } - - guard urlResponse.statusCode >= 200 && urlResponse.statusCode < 300 else { - resolver.reject(Error.invalidResponseCode) - return - } - - resolver.fulfill(data) - } - task.resume() - } - } - } - -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Provider/RpcProvider.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Provider/RpcProvider.swift deleted file mode 100644 index a75ee57c9..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Provider/RpcProvider.swift +++ /dev/null @@ -1,91 +0,0 @@ -// -// RpcProvider.swift -// MagicSDK -// -// Created by Jerry Liu on 1/20/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import MagicSDK_Web3 -import WebKit -import PromiseKit - -/// A custom Web3 HttpProvider that is specifically configured for use with Magic Links. -public class RpcProvider: NetworkClient, Web3Provider { - - /// Various errors that may occur while processing Web3 requests - public enum ProviderError: Swift.Error { - /// The provider is not configured with an authDelegate - case encodingFailed(Swift.Error?) - /// Decoding the JSON-RPC request failed - case decodingFailed(json: String) - /// Convert string failed - case invalidJsonResponse(json: String) - /// Missing callback - case missingPayloadCallback(json: String) - } - - let overlay: WebViewController - public let urlBuilder: URLBuilder - - required init(urlBuilder: URLBuilder) { - self.overlay = WebViewController(url: urlBuilder) - self.urlBuilder = urlBuilder - super.init() - } - - // MARK: - Sending Requests - - /// Sends an RPCRequest and parses the result - /// Web3 Provider protocal conformed - /// - /// - Parameters: - /// - request: RPCRequest to send - /// - response: A completion handler for the response. Includes either the result or an error. - public func send(request: RPCRequest, response: @escaping Web3ResponseCompletion) { - let msgType = OutboundMessageType.MAGIC_HANDLE_REQUEST - - // Re-assign ID to the payload - let newRequest = RPCRequest(method: request.method, params: request.params) - - // construct message data - let eventMessage = RequestData(msgType: "\(msgType.rawValue)-\(urlBuilder.encodedParams)", payload: newRequest) - - // encode to JSON - firstly { - encode(body: eventMessage) - }.done {body throws -> Void in - - let str = try String(body) - - // enqueue and send to webview - try self.overlay.enqueue(message: str, id: newRequest.id) { ( responseString: String) in - guard let jsonData = responseString.data(using: .utf8) else { - throw ProviderError.invalidJsonResponse(json: str) - } - - // Decode JSON string into string - do { - let rpcResponse = try self.decoder.decode(ResponseData>.self, from: jsonData) - let result = Web3Response(rpcResponse: rpcResponse.response) - response(result) - } catch { - throw ProviderError.decodingFailed(json: responseString) - } - } - }.catch { error in - let errResponse = Web3Response(error: ProviderError.encodingFailed(error)) - response(errResponse) -// handleRollbarError(error, log: false) - } - } -} - -public typealias Web3ResponseCompletion = (_ resp: Web3Response) -> Void - -internal extension Web3BytesInitializable { - init(_ bytes: Web3BytesRepresentable) throws { - let bytes = try bytes.makeBytes() - try self.init(bytes) - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/Types/AnyValue.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/Types/AnyValue.swift deleted file mode 100644 index b925e7ba3..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/Types/AnyValue.swift +++ /dev/null @@ -1,264 +0,0 @@ -// -// AnyValue.swift -// MagicSDK -// -// Created by Jerry Liu on 7/13/20. -// - -import Foundation - -/** - * A `Codable`, Ethereum representable value. - */ -public struct AnyValue: Codable { - - /// The internal type of this value - public let valueType: ValueType - - public enum ValueType { - - /// A string value - case string(String) - - /// An int value - case int(Int) - - /// A bool value - case bool(Bool) - - /// An array value - case array([AnyValue]) - - /// A special case nil value - case `nil` - } - - public init(valueType: ValueType) { - self.valueType = valueType - } - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - - if let str = try? container.decode(String.self) { - valueType = .string(str) - } else if let bool = try? container.decode(Bool.self) { - valueType = .bool(bool) - } else if let int = try? container.decode(Int.self) { - valueType = .int(int) - } else if let array = try? container.decode([AnyValue].self) { - valueType = .array(array) - } else if container.decodeNil() { - valueType = .nil - } else { - throw Error.unsupportedType - } - } - - /// Encoding and Decoding errors specific to AnyValue - public enum Error: Swift.Error { - - /// The type set is not convertible to AnyValue - case unsupportedType - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - - switch valueType { - case .string(let string): - try container.encode(string) - case .int(let int): - try container.encode(int) - case .bool(let bool): - try container.encode(bool) - case .array(let array): - try container.encode(array) - case .nil: - try container.encodeNil() - } - } -} - -// MARK: - Convenient Initializers - -extension AnyValue: ExpressibleByStringLiteral { - - public typealias StringLiteralType = String - - public init(stringLiteral value: StringLiteralType) { - valueType = .string(value) - } -} - -extension AnyValue: ExpressibleByIntegerLiteral { - - public typealias IntegerLiteralType = Int - - public init(integerLiteral value: IntegerLiteralType) { - valueType = .int(value) - } -} - -extension AnyValue: ExpressibleByBooleanLiteral { - - public typealias BooleanLiteralType = Bool - - public init(booleanLiteral value: BooleanLiteralType) { - valueType = .bool(value) - } -} - -extension AnyValue: ExpressibleByArrayLiteral { - - public typealias ArrayLiteralElement = AnyValueRepresentable - - public init(array: [AnyValueRepresentable]) { - let values = array.map({ $0.anyValue() }) - valueType = .array(values) - } - - public init(arrayLiteral elements: ArrayLiteralElement...) { - self.init(array: elements) - } -} - -// MARK: - Convenient Setters - -public extension AnyValue { - - static func string(_ string: String) -> AnyValue { - return self.init(stringLiteral: string) - } - - static func int(_ int: Int) -> AnyValue { - return self.init(integerLiteral: int) - } - - static func bool(_ bool: Bool) -> AnyValue { - return self.init(booleanLiteral: bool) - } - - static func array(_ array: [AnyValueRepresentable]) -> AnyValue { - return self.init(array: array) - } -} - -// MARK: - Convenient Getters - -public extension AnyValue { - - var string: String? { - if case .string(let string) = valueType { - return string - } - - return nil - } - - var int: Int? { - if case .int(let int) = valueType { - return int - } - - return nil - } - - var bool: Bool? { - if case .bool(let bool) = valueType { - return bool - } - - return nil - } - - var array: [AnyValue]? { - if case .array(let array) = valueType { - return array - } - - return nil - } -} - -// MARK: - AnyValueConvertible - -extension AnyValue: AnyValueConvertible { - - public init(anyValue: AnyValue) { - self = anyValue - } - - public func anyValue() -> AnyValue { - return self - } -} - -// MARK: - Equatable - -extension AnyValue.ValueType: Equatable { - - public static func ==(_ lhs: AnyValue.ValueType, _ rhs: AnyValue.ValueType) -> Bool { - switch lhs { - case .string(let str): - if case .string(let rStr) = rhs { - return str == rStr - } - return false - case .int(let int): - if case .int(let rInt) = rhs { - return int == rInt - } - return false - case .bool(let bool): - if case .bool(let rBool) = rhs { - return bool == rBool - } - return false - case .array(let array): - if case .array(let rArray) = rhs { - return array == rArray - } - return false - case .nil: - if case .nil = rhs { - return true - } - return false - } - } -} - -extension AnyValue: Equatable { - - public static func ==(_ lhs: AnyValue, _ rhs: AnyValue) -> Bool { - return lhs.valueType == rhs.valueType - } -} - -// MARK: - Hashable - -extension AnyValue.ValueType: Hashable { - - public func hash(into hasher: inout Hasher) { - switch self { - case .string(let str): - hasher.combine(str) - case .int(let int): - hasher.combine(int) - case .bool(let bool): - hasher.combine(bool) - case .array(let array): - hasher.combine(array) - case .nil: - hasher.combine(0x00) - } - } -} - -extension AnyValue: Hashable { - - public func hash(into hasher: inout Hasher) { - hasher.combine(valueType) - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/Types/AnyValueConvertible.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/Types/AnyValueConvertible.swift deleted file mode 100644 index ad097dbf7..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/Types/AnyValueConvertible.swift +++ /dev/null @@ -1,76 +0,0 @@ -// -// AnyValueConvertible.swift -// MagicSDK -// -// Created by Jerry Liu on 07/13/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation - -/** - * Objects which can be converted to `AnyValue` can implement this. - */ -public protocol AnyValueRepresentable: Encodable { - - /** - * Converts `self` to `AnyValue`. - * - * - returns: The generated `AnyValue`. - */ - func anyValue() -> AnyValue -} - -/** - * Objects which can be initialized with `AnyValue`'s can implement this. - */ -public protocol AnyValueInitializable: Decodable { - - /** - * Initializes `self` with the given `AnyValue` if possible. Throws otherwise. - * - * - parameter AnyValue: The `AnyValue` to be converted to `self`. - */ - init(anyValue: AnyValue) throws -} - -/** - * Objects which are both representable and initializable by and with `AnyValue`'s. - */ -public typealias AnyValueConvertible = AnyValueRepresentable & AnyValueInitializable - -extension AnyValueInitializable { - - public init(anyValue: AnyValueRepresentable) throws { - let e = anyValue.anyValue() - try self.init(anyValue: e) - } -} - -// MARK: - Default Codable - -extension AnyValueRepresentable { - - public func encode(to encoder: Encoder) throws { - try anyValue().encode(to: encoder) - } -} - -extension AnyValueInitializable { - - public init(from decoder: Decoder) throws { - try self.init(anyValue: AnyValue(from: decoder)) - } -} - -// MARK: - Errors - -public enum AnyValueRepresentableError: Swift.Error { - - case notRepresentable -} - -public enum AnyValueInitializableError: Swift.Error { - - case notInitializable -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/Types/BasicTypes.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/Types/BasicTypes.swift deleted file mode 100644 index baacf0fba..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/Types/BasicTypes.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// Type.swift -// Magic -// -// Created by Jerry Liu on 2/6/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation - -enum InboundMessageType: String, CaseIterable { - case MAGIC_HANDLE_RESPONSE - case MAGIC_OVERLAY_READY - case MAGIC_SHOW_OVERLAY - case MAGIC_HIDE_OVERLAY - case MAGIC_HANDLE_EVENT -} - -enum OutboundMessageType: String, CaseIterable { - case MAGIC_HANDLE_REQUEST -} - -struct RequestData: Codable { - - let msgType: String - let payload: T -} - -struct ResponseData: Codable { - - let msgType: String - let response: T -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/URLBuilder.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/URLBuilder.swift deleted file mode 100644 index 19c0e7209..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/URLBuilder.swift +++ /dev/null @@ -1,117 +0,0 @@ -// -// URLBuilder.swift -// Magic -// -// Created by Jerry Liu on 3/16/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation - -// MARK: - URLBuilder init -// -// Construct a URI with options encoded -// -public struct URLBuilder { - - let encodedParams, url: String - static let host = "https://box.magic.link" - - public let apiKey: String - - init(apiKey: String, customNode: CustomNodeConfiguration? = nil, ethNetwork: EthNetwork? = nil, locale: String, productType: ProductType) { - - let data = try! JSONEncoder().encode(paramsEncodable(apiKey: apiKey, ethNetwork: ethNetwork, customNode: customNode, locale: locale, productType: productType)) - self.init(data: data, host: URLBuilder.host, apiKey: apiKey, productType: productType) - } - - private init(data: Data, host: String, apiKey: String, productType: ProductType) { - let jsonString = String(data: data, encoding: .utf8)! - let string = jsonString.replacingOccurrences(of: "\\", with: "") - // Encode instantiate option to params - self.apiKey = apiKey - self.encodedParams = btoa(jsonString: string) - self.url = "\(host)/send/?params=\(self.encodedParams)" - } - - // MARK: - Options structs - struct paramsEncodable: Encodable { - let API_KEY: String - let locale: String - let customNode: CustomNodeConfiguration? - let ethNetwork: EthNetwork? - let productType: ProductType - init(apiKey: String, ethNetwork: EthNetwork?, customNode: CustomNodeConfiguration?, locale: String, productType: ProductType) { - self.productType = productType - self.customNode = customNode - self.ethNetwork = ethNetwork - self.API_KEY = apiKey - self.locale = locale - } - - enum CodingKeys: String, CodingKey { - case sdk, bundleId, API_KEY, host, ETH_NETWORK, ext - } - - func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode("magic-sdk-ios", forKey: .sdk) - try container.encode(Bundle.main.bundleIdentifier, forKey: .bundleId) - try container.encode(self.API_KEY, forKey: .API_KEY) - try container.encode(URLBuilder.host, forKey: .host) - - /// Network - if (customNode != nil) { - try container.encode(customNode, forKey: .ETH_NETWORK) - } - if (ethNetwork != nil) { - try container.encode(ethNetwork?.rawValue, forKey: .ETH_NETWORK) - } - - try container.encode(ExtensionObject(productType: productType), forKey: .ext) - } - } -} - -// MARK: -- Network -public struct CustomNodeConfiguration: Encodable { - let rpcUrl: String - let chainId: Int? - - public init (rpcUrl: String, chainId: Int? = nil) { - self.rpcUrl = rpcUrl - self.chainId = chainId - } -} - - -// MARK: -- Extension -struct ExtensionObject: Encodable { - - let productType: ProductType - - init(productType: ProductType) { - self.productType = productType - } - - enum CodingKeys: String, CodingKey { - case connect - } - - func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - - switch productType { - case .MC: - try container.encode(MCConfig(), forKey: .connect) - break - default: - break - } - - } -} - -internal struct MCConfig: Encodable { - let mc = true -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/WebViewController.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/WebViewController.swift deleted file mode 100644 index 712c5b195..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Core/Relayer/WebViewController.swift +++ /dev/null @@ -1,299 +0,0 @@ -// -// WebViewController.swift -// Magic -// -// Created by Jerry Liu on 2/1/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import WebKit -import UIKit - -/// An instance of the Fortmatc Phantom WebView -class WebViewController: UIViewController, WKUIDelegate, WKScriptMessageHandler, WKNavigationDelegate, UIScrollViewDelegate { - - /// Various errors that may occur while processing Web3 requests - public enum AuthRelayerError: Error { - - ///Message encode fail - case messageEncodeFailed(message: String) - - case webviewAttachedFailed - case topMostWindowNotFound - } - - /// This name is reserved for internal use - let messageName = "fortmaticIOS" - - var webView: WKWebView! - - /// X source url - var urlBuilder: URLBuilder! - - /// Overlay Ready - var overlayReady = false - var webViewFinishLoading = false - - /// Queue and callbackss - var queue: [String] = [] - var messageHandlers: Dictionary = [:] - - typealias MessageHandler = (String) throws -> Void - - // MARK: - init - init(url: URLBuilder) { - self.urlBuilder = url - super.init(nibName: nil, bundle: nil) - } - - // Required provided by subclass of 'UIViewController' - required init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - } - - // MARK: - Message Queue - func enqueue(message: String, id: Int, closure: @escaping MessageHandler) throws -> Void { - queue.append(message) - messageHandlers[id] = closure - try self.dequeue() - } - - private func dequeue() throws -> Void { - - // Check if UI is appeneded properly to current screen before dequeue - guard let window = UIApplication.shared.keyWindow else { return try attachWebView() } - - if self.view.isDescendant(of: window) { - - if !queue.isEmpty && overlayReady && webViewFinishLoading { - let message = queue.removeFirst() - try self.postMessage(message: message) - - // Recursive calls till queue is Empty - try self.dequeue() - } - } else { - try attachWebView() - } - } - - - // MARK: - Receive Messages - - /// handler for received messages - /// conforming WKScriptMessageHandler - func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { - - do { - if message.name == messageName { - guard let payloadStr = message.body as? String else { return } - - if payloadStr.contains(InboundMessageType.MAGIC_OVERLAY_READY.rawValue) { - overlayReady = true - try? self.dequeue() - } else if payloadStr.contains(InboundMessageType.MAGIC_SHOW_OVERLAY.rawValue) { - try bringWebViewToFront() - } else if payloadStr.contains(InboundMessageType.MAGIC_HIDE_OVERLAY.rawValue) { - try sendSubviewToBack() - } else if payloadStr.contains(InboundMessageType.MAGIC_HANDLE_EVENT.rawValue) { - try handleEvent(payloadStr: payloadStr) - } else if payloadStr.contains(InboundMessageType.MAGIC_HANDLE_RESPONSE.rawValue) { - try handleResponse(payloadStr: payloadStr) - } - } - try self.dequeue() - }catch let error { - print("Magic internal error: \(error.localizedDescription)") - } - } - - private func handleEvent(payloadStr: String) throws -> Void { - - // Decode here to get the event name - let eventData = payloadStr.data(using: .utf8)! - let eventResponse = try JSONDecoder().decode(ResponseData>.self, from: eventData) - - // post event to the obeserver - let event = eventResponse.response - let eventName = event.result.event - NotificationCenter.default.post(name: Notification.Name.init(eventName), object: nil, userInfo: ["event": event.result]) - } - - private func handleResponse(payloadStr: String) throws -> Void { - - /// Take id out from JSON string - if let range = payloadStr.range(of: "(?<=\"id\":)(.*?)(?=,)", options: .regularExpression) { - - guard let id = Int(payloadStr[range]) else { - - /// throws when response has no matching id - throw RpcProvider.ProviderError.invalidJsonResponse(json: payloadStr) - } - - // Call callback stored - if let callback = self.messageHandlers[id] { - try callback(payloadStr) - self.messageHandlers[id] = nil - } else { - - /// throws when response couldn't match a callback - throw RpcProvider.ProviderError.missingPayloadCallback(json: payloadStr) - } - } else { - throw RpcProvider.ProviderError.invalidJsonResponse(json: payloadStr) - } - } - - - // MARK: - Post Messages - - - /// post Message to HTML via evaluateJavaScript - /// - internal func postMessage(message: String) throws -> Void { - - let data: [String: String] = ["data": message] - - guard let json = try? JSONEncoder().encode(data), - let jsonString = String(data: json, encoding: .utf8) else { - throw AuthRelayerError.messageEncodeFailed(message: message) - } - - let execString = String(format: "window.dispatchEvent(new MessageEvent('message', \(jsonString)));") - webView.evaluateJavaScript(execString) - } - - - - - // MARK: - view loading - /// loadView will be triggered when addsubview is called. It will create a webview to post messages to auth relayer - override func loadView() { - - // Display Full screen - let cgRect = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) - let webView: WKWebView = { - - let webCfg:WKWebViewConfiguration = WKWebViewConfiguration() - let userController:WKUserContentController = WKUserContentController() - - // Add a script message handler for receiving messages over `fortmatic` messageHandler. The controller needs to conform - // with WKScriptMessageHandler protocol - userController.add(self, name: messageName) - webCfg.userContentController = userController; - - let webView = WKWebView(frame: cgRect, configuration: webCfg) - - // Transparent background - webView.backgroundColor = UIColor.clear - webView.scrollView.backgroundColor = UIColor.clear - webView.isOpaque = false - - webView.uiDelegate = self - - // conforming WKNavigationDelegate - webView.navigationDelegate = self - - return webView - }() - self.webView = webView - view = webView - } - - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - let myURL = URL(string: urlBuilder.url) - let myRequest = URLRequest(url: myURL!) - webView.load(myRequest) - } - - override func viewDidLoad() { - super.viewDidLoad() - webView.scrollView.delegate = self // disable zoom - } - - /// Check did finished navigating, conforming WKNavigationDelegate - func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { - webViewFinishLoading = true - do { - try self.dequeue() - } catch {} - } - - // handle external link clicked events - func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { - // Check for links. - if navigationAction.navigationType == .linkActivated { - // Make sure the URL is set. - guard let url = navigationAction.request.url else { - decisionHandler(.allow) - return - } - - // Check for the scheme component. - let components = URLComponents(url: url, resolvingAgainstBaseURL: false) - if components?.scheme == "http" || components?.scheme == "https" { - // Open the link in the external browser. - UIApplication.shared.open(url) - // Cancel the decisionHandler because we managed the navigationAction. - decisionHandler(.cancel) - } else { - decisionHandler(.allow) - } - } else { - decisionHandler(.allow) - } - } - - - - // MARK: - View - - /// Disable zooming for webview - func viewForZooming(in: UIScrollView) -> UIView? { - return nil; - } - - private func sendSubviewToBack() throws -> Void { - - let keyWindow = try getKeyWindow() - keyWindow.sendSubviewToBack(self.view) - } - - private func bringWebViewToFront() throws -> Void { - - let keyWindow = try getKeyWindow() - keyWindow.bringSubviewToFront(self.view) - } - - private func getKeyWindow() throws -> UIWindow { - - guard let keyWindow = UIApplication.shared.windows.filter({$0.isKeyWindow}).first else { - throw AuthRelayerError.topMostWindowNotFound - } - - return keyWindow - } - - private func attachWebView() throws -> Void { - - let keyWindow = try getKeyWindow() - - keyWindow.addSubview(self.view) - keyWindow.sendSubviewToBack(self.view) - - // find topmost view controller from the hierarchy and move webview to it - if var topController = keyWindow.rootViewController { - while let presentedViewController = topController.presentedViewController { - topController = presentedViewController - } - - self.didMove(toParent: topController) - - } else { - throw AuthRelayerError.webviewAttachedFailed - } - } -} - - diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Auth/AuthConfiguration.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Auth/AuthConfiguration.swift deleted file mode 100644 index b60fdf88e..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Auth/AuthConfiguration.swift +++ /dev/null @@ -1,42 +0,0 @@ -// -// Configuration.swift -// MagicSDK -// -// Created by Jerry Liu on 5/14/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation - -/// LoginWithMagicLink configuration -public struct LoginWithMagicLinkConfiguration: BaseConfiguration { - - /// Shows UI if sets to true - public var showUI: Bool - public var email: String - - public init(showUI: Bool = true, email: String) { - self.showUI = showUI - self.email = email - } -} - -public struct LoginWithSmsConfiguration: BaseConfiguration { - - /// - public var phoneNumber: String - var showUI = true - - public init(phoneNumber: String) { - self.phoneNumber = phoneNumber - } -} - -public struct LoginWithEmailOTPConfiguration: BaseConfiguration { - - public var email: String - - public init(email: String) { - self.email = email - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Auth/AuthMethod.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Auth/AuthMethod.swift deleted file mode 100644 index b2941f906..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Auth/AuthMethod.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// AuthMessage.swift -// MagicSDK -// -// Created by Jerry Liu on 5/17/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation - -internal enum AuthMethod: String, CaseIterable { - - // Auth - case magic_auth_login_with_magic_link - case magic_auth_login_with_sms - case magic_auth_login_with_email_otp -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Auth/AuthModule.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Auth/AuthModule.swift deleted file mode 100644 index ffd85f658..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Auth/AuthModule.swift +++ /dev/null @@ -1,62 +0,0 @@ -// -// AuthModule.swift -// Magic -// -// Created by Jerry Liu on 3/3/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation -import MagicSDK_Web3 -import PromiseKit - -public class AuthModule: BaseModule { - - // MARK: - Login with magic link - public func loginWithMagicLink (_ configuration: LoginWithMagicLinkConfiguration, response: @escaping Web3ResponseCompletion ) { - let request = RPCRequest<[LoginWithMagicLinkConfiguration]>(method: AuthMethod.magic_auth_login_with_magic_link.rawValue, params: [configuration]) - self.provider.send(request: request, response: response) - } - - public func loginWithMagicLink (_ configuration: LoginWithMagicLinkConfiguration) -> Promise { - return Promise { resolver in - loginWithMagicLink(configuration, response: promiseResolver(resolver)) - } - } - - public func loginWithMagicLink (_ configuration: LoginWithMagicLinkConfiguration, eventLog: Bool) -> MagicEventPromise { - return MagicEventPromise (eventCenter: self.magicEventCenter, eventLog: eventLog) { resolver in - self.loginWithMagicLink(configuration, response: promiseResolver(resolver)) - } - } - - // MARK: - Login with SMS - public func loginWithSMS (_ configuration: LoginWithSmsConfiguration, response: @escaping Web3ResponseCompletion ) { - let request = RPCRequest<[LoginWithSmsConfiguration]>(method: AuthMethod.magic_auth_login_with_sms.rawValue, params: [configuration]) - self.provider.send(request: request, response: response) - } - - public func loginWithSMS (_ configuration: LoginWithSmsConfiguration) -> Promise { - return Promise { resolver in - loginWithSMS(configuration, response: promiseResolver(resolver)) - } - } - - // MARK: - Login with EmailOTP - public func loginWithEmailOTP (_ configuration: LoginWithEmailOTPConfiguration, response: @escaping Web3ResponseCompletion ) { - let request = RPCRequest<[LoginWithEmailOTPConfiguration]>(method: AuthMethod.magic_auth_login_with_email_otp.rawValue, params: [configuration]) - self.provider.send(request: request, response: response) - } - - public func loginWithEmailOTP (_ configuration: LoginWithEmailOTPConfiguration) -> Promise { - return Promise { resolver in - loginWithEmailOTP(configuration, response: promiseResolver(resolver)) - } - } - - public enum LoginWithMagicLinkEvent: String { - case emailNotDeliverable = "email-not-deliverable" - case emailSent = "email-sent" - case retry = "retry" - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/BaseConfiguration.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/BaseConfiguration.swift deleted file mode 100644 index d4d96f2a6..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/BaseConfiguration.swift +++ /dev/null @@ -1,11 +0,0 @@ -// -// BaseConfiguration.swift -// Magic Labs -// -// Created by Jerry Liu on 5/15/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation - -public protocol BaseConfiguration: Codable {} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/BaseModule.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/BaseModule.swift deleted file mode 100644 index 9c71f4acc..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/BaseModule.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// BaseModule.swift -// Magic Labs -// -// Created by Jerry Liu on 3/3/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation -import MagicSDK_Web3 -import PromiseKit - -open class BaseModule { - - public let provider: RpcProvider - public let magicEventCenter = EventCenter() - - public init(rpcProvider: RpcProvider) { - self.provider = rpcProvider - } -} - -public func promiseResolver(_ resolver: Resolver) -> (_ result: Web3Response) -> Void { - return { result in - switch result.status { - case let .success(value): - resolver.fulfill(value) - case let .failure(error): - resolver.reject(error) - } - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectConfiguration.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectConfiguration.swift deleted file mode 100644 index 804f9577e..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectConfiguration.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// ConnectConfiguration.swift -// -// -// Created by Jerry Liu on 9/16/22. -// - -import Foundation - -public struct RequestUserInfoConfiguration: BaseConfiguration { - - /// - public var isResponseRequired = false - - public init(isResponseRequired: Bool = false) { - self.isResponseRequired = isResponseRequired - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectMethod.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectMethod.swift deleted file mode 100644 index db03efd70..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectMethod.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// ConnectMethod.swift -// -// -// Created by Jerry Liu on 9/6/22. -// - -import Foundation - -internal enum ConnectMethod: String, CaseIterable { - - // MC - case mc_get_wallet_info - case mc_wallet - case mc_request_user_info - case mc_disconnect -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectModule.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectModule.swift deleted file mode 100644 index 5f65b27af..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectModule.swift +++ /dev/null @@ -1,53 +0,0 @@ -// -// ConnectModule.swift -// -// -// Created by Jerry Liu on 9/6/22. -// - -import Foundation -import MagicSDK_Web3 - -public class ConnectModule: BaseModule { - - /** - getWalletInfo - */ - public func getWalletInfo(response: @escaping Web3ResponseCompletion) { - - let request = BasicRPCRequest(method: ConnectMethod.mc_get_wallet_info.rawValue, params: []) - - return self.provider.send(request: request, response: response) - } - - - /** - showWallet - */ - public func showWallet(response: @escaping Web3ResponseCompletion) { - - let request = BasicRPCRequest(method: ConnectMethod.mc_wallet.rawValue, params: []) - - return self.provider.send(request: request, response: response) - } - - /** - requestUserInfo - */ - public func requestUserInfo(_ configuration: RequestUserInfoConfiguration = RequestUserInfoConfiguration(), response: @escaping Web3ResponseCompletion) { - - let request = RPCRequest<[RequestUserInfoConfiguration]>(method: ConnectMethod.mc_request_user_info.rawValue, params: [configuration]) - - return self.provider.send(request: request, response: response) - } - - /** - disconnect - */ - public func disconnect(response: @escaping Web3ResponseCompletion) { - - let request = BasicRPCRequest(method: ConnectMethod.mc_disconnect.rawValue, params: []) - - return self.provider.send(request: request, response: response) - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectResponse.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectResponse.swift deleted file mode 100644 index 95006fe78..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Connect/ConnectResponse.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// ConnectResponse.swift -// -// -// Created by Wentao Liu on 9/22/22. -// - -import Foundation - -public struct UserInfoResponse: MagicResponse { - - public let email: String? -} - -public struct WalletInfoResponse: MagicResponse { - public let walletType: String? -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Event/EventCenter.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Event/EventCenter.swift deleted file mode 100644 index ebd552f07..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Event/EventCenter.swift +++ /dev/null @@ -1,44 +0,0 @@ -// -// PromiEvent.swift -// MagicSDK -// -// Created by Jerry Liu on 7/10/20. -// - -import Foundation -import PromiseKit - -public class EventCenter { - - enum Error: Swift.Error{ - case eventCallbackMissing - } - private var eventLog = false - - private typealias EventCompletion = () -> Void - private var eventHandlerDict: Dictionary = [:] - - func addOnceObserver (eventName: String, eventLog: Bool, completion: @escaping () -> Void) -> Void { - NotificationCenter.default.addObserver(self, selector: #selector(self.onDidReceiveEventOnce(_:)), name: Notification.Name.init(eventName), object: nil) - self.eventLog = eventLog - eventHandlerDict[eventName] = completion - } - - /// Recieve events - @objc func onDidReceiveEventOnce(_ notification: Notification) { - - if let eventResult = (notification.userInfo?["event"]) as? MagicEventResult<[AnyValue]>, let handler = eventHandlerDict[eventResult.event] { - - if (eventLog) { - print("MagicSDK Event: \(eventResult)") - } - - NotificationCenter.default.removeObserver(self, name: Notification.Name(eventResult.event), object: nil) - handler() - } else { -// handleRollbarError(Error.eventCallbackMissing) - } - } - - init (){} -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Event/EventPromise.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Event/EventPromise.swift deleted file mode 100644 index 5216aeb4a..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Event/EventPromise.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// PromiEvent.swift -// MagicSDK -// -// Created by Jerry Liu on 7/10/20. -// - -import Foundation -import PromiseKit - -public class MagicEventPromise { - - private var donePromise: Promise - private var eventCenter: EventCenter - private var eventLog = false - - typealias EventCompletion = () -> Void - - public func once(eventName: String, completion: @escaping () -> Void) -> MagicEventPromise { - eventCenter.addOnceObserver(eventName: eventName, eventLog: eventLog, completion: completion) - return self - } - - public func done(on: DispatchQueue? = conf.Q.return, flags: DispatchWorkItemFlags? = nil, _ body: @escaping(T) throws -> Void) -> Promise { - return self.donePromise.done(on: on, flags: flags, body) - } - - init (eventCenter: EventCenter, eventLog: Bool, _ resolver: @escaping (_ resolver: Resolver) -> Void) { - self.donePromise = Promise(resolver: resolver) - self.eventCenter = eventCenter - self.eventLog = eventLog - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Event/EventResponse.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Event/EventResponse.swift deleted file mode 100644 index a6249516b..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Event/EventResponse.swift +++ /dev/null @@ -1,43 +0,0 @@ -// -// PromiEvents.swift -// MagicSDK -// -// Created by Jerry Liu on 7/10/20. -// - -import Foundation - - -internal struct MagicEventResponse: Codable { - - /// The rpc id - public let id: Int - - /// The jsonrpc version. Typically 2.0 - public let jsonrpc: String - - /// The result - public let result: MagicEventResult - - /// The error - public let error: Error? - - public struct Error: Swift.Error, Codable { - - /// The error code - public let code: Int - - /// The error message - public let message: String - - /// Description - public var localizedDescription: String { - return "Magic Event Error (\(code)) \(message)" - } - } -} - -internal struct MagicEventResult: Codable { - let event: String - let params: Params -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserConfiguration.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserConfiguration.swift deleted file mode 100644 index c4f822a02..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserConfiguration.swift +++ /dev/null @@ -1,49 +0,0 @@ -// -// UserConfiguration.swift -// Magic -// -// Created by Jerry Liu on 3/4/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation -import MagicSDK_Web3 - -/// Get Id Token configuration -public class GetIdTokenConfiguration: BaseConfiguration { - - var lifespan: Int - - public init(lifespan: Int = 900) { - self.lifespan = lifespan - } -} - - -public class GenerateIdTokenConfiguration: BaseConfiguration { - var attachment: String - var lifespan: Int - - public init(lifespan: Int = 900, attachment: String = "none") { - self.lifespan = lifespan - self.attachment = attachment - } -} - -public class UpdateEmailConfiguration: BaseConfiguration { - var email: String - var showUI: Bool - - public init(email: String, showUI: Bool = true){ - self.email = email - self.showUI = showUI - } -} - -public class RecoverAccountConfiguration: BaseConfiguration { - var email: String - - public init(email: String){ - self.email = email - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserMethod.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserMethod.swift deleted file mode 100644 index 34f5ca7d3..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserMethod.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// UserMessage.swift -// MagicSDK -// -// Created by Jerry Liu on 5/17/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation - -internal enum UserMethod: String, CaseIterable { - - // Auth - case magic_auth_get_id_token - case magic_auth_generate_id_token - case magic_auth_get_metadata - case magic_auth_logout - case magic_auth_settings - case magic_auth_update_email - case magic_auth_is_logged_in - case magic_auth_update_phone_number - case magic_auth_recover_account -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserModule.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserModule.swift deleted file mode 100644 index bdfd1fb8a..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserModule.swift +++ /dev/null @@ -1,153 +0,0 @@ -// -// PhantomUser.swift -// -// Created by Jerry Liu on 3/2/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation -import MagicSDK_Web3 -import PromiseKit - -public class UserModule: BaseModule { - - /** - GetIdToken - */ - public func getIdToken(_ configuration: GetIdTokenConfiguration? = nil, response: @escaping Web3ResponseCompletion) { - - let request = RPCRequest<[GetIdTokenConfiguration?]>(method: UserMethod.magic_auth_get_id_token.rawValue, params: [configuration]) - - return self.provider.send(request: request, response: response) - } - - public func getIdToken(_ configuration: GetIdTokenConfiguration? = nil) -> Promise { - return Promise { resolver in - getIdToken(configuration, response: promiseResolver(resolver)) - } - } - - /** - Generate Id Token - */ - public func generateIdToken(_ configuration: GenerateIdTokenConfiguration? = nil, response: @escaping Web3ResponseCompletion) { - - let request = RPCRequest<[GenerateIdTokenConfiguration?]>(method: UserMethod.magic_auth_generate_id_token.rawValue, params: [configuration]) - - return self.provider.send(request: request, response: response) - } - - public func generateIdToken(_ configuration: GenerateIdTokenConfiguration? = nil) -> Promise { - return Promise { resolver in - generateIdToken(configuration, response: promiseResolver(resolver)) - } - } - - - /** - Get Metadata - */ - public func getMetadata(response: @escaping Web3ResponseCompletion) { - let request = BasicRPCRequest(method: UserMethod.magic_auth_get_metadata.rawValue, params: []) - return self.provider.send(request: request, response: response) - } - - public func getMetadata() -> Promise { - return Promise { resolver in - getMetadata(response: promiseResolver(resolver)) - } - } - - /** - IsLogged In - */ - public func isLoggedIn(response: @escaping Web3ResponseCompletion) { - let request = BasicRPCRequest(method: UserMethod.magic_auth_is_logged_in.rawValue, params: []) - self.provider.send(request: request, response: response) - } - - public func isLoggedIn() -> Promise { - return Promise { resolver in - isLoggedIn(response: promiseResolver(resolver)) - } - } - - /** - * Update Email - */ - public func updateEmail(_ configuration: UpdateEmailConfiguration, response: @escaping Web3ResponseCompletion) { - - let request = RPCRequest<[UpdateEmailConfiguration]>(method: UserMethod.magic_auth_update_email.rawValue, params: [configuration]) - - return self.provider.send(request: request, response: response) - } - - public func updateEmail(_ configuration: UpdateEmailConfiguration) -> Promise { - return Promise { resolver in - updateEmail(configuration, response: promiseResolver(resolver)) - } - } - - public func updateEmail(_ configuration: UpdateEmailConfiguration, eventLog: Bool) -> MagicEventPromise { - return MagicEventPromise (eventCenter: self.magicEventCenter, eventLog: eventLog){ resolver in - self.updateEmail(configuration, response: promiseResolver(resolver)) - } - } - - /** - Logout - */ - public func logout (response: @escaping Web3ResponseCompletion) { - let request = BasicRPCRequest(method: UserMethod.magic_auth_logout.rawValue, params: []) - self.provider.send(request: request, response: response) - } - - public func logout() -> Promise { - return Promise { resolver in - logout(response: promiseResolver(resolver)) - } - } - /** - showSettings - */ - public func showSettings(response: @escaping Web3ResponseCompletion) { - let request = BasicRPCRequest(method: UserMethod.magic_auth_settings.rawValue, params: []) - self.provider.send(request: request, response: response) - } - - public func showSettings() -> Promise { - return Promise { resolver in - showSettings(response: promiseResolver(resolver)) - } - } - - /** - updatePhoneNumber - */ - public func updatePhoneNumber(response: @escaping Web3ResponseCompletion) { - let request = BasicRPCRequest(method: UserMethod.magic_auth_update_phone_number.rawValue, params: []) - self.provider.send(request: request, response: response) - } - - public func updatePhoneNumber() -> Promise { - return Promise { resolver in - updatePhoneNumber(response: promiseResolver(resolver)) - } - } - - /** - recoverAccount - */ - public func recoverAccount(_ configuration: RecoverAccountConfiguration, response: @escaping Web3ResponseCompletion) { - - let request = RPCRequest<[RecoverAccountConfiguration]>(method: UserMethod.magic_auth_recover_account.rawValue, params: [configuration]) - - return self.provider.send(request: request, response: response) - } - - public func recoverAccount(_ configuration: RecoverAccountConfiguration) -> Promise { - return Promise { resolver in - recoverAccount(configuration, response: promiseResolver(resolver)) - } - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserResponse.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserResponse.swift deleted file mode 100644 index a6324842e..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/User/UserResponse.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// UserResponse.swift -// Magic -// -// Created by Jerry Liu on 3/16/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation -import MagicSDK_Web3 - -public protocol MagicResponse: Codable {} - -/// Get Id Token configuration -public struct UserMetadata: MagicResponse { - - public let issuer: String? - public let publicAddress: String? - public let email: String? -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Web3/EIP712TypedData.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Web3/EIP712TypedData.swift deleted file mode 100644 index 616fbb7b6..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Web3/EIP712TypedData.swift +++ /dev/null @@ -1,108 +0,0 @@ -// -// EthereumTypedData.swift -// Web3 -// -// Created by Yehor Popovych on 3/19/19. -// From: https://github.com/Boilertalk/Web3.swift/pull/75/commits/24c556f970115d15d38a4497952767fc4582b2b2 -import Foundation -import MagicSDK_Web3 - - -// MARK: - EIP 712 -public struct EIP712TypedData: Codable, Equatable { - public struct `Type`: Codable, Equatable { - let name: String - let type: String - } - - public struct Domain: Codable, Equatable { - let name: String? - let version: String? - let chainId: Int? - let verifyingContract: String? - let salt: UInt32? - } - - public let types: Dictionary> - public let primaryType: String - public let domain: Domain - public let message: Dictionary - - public init( - primaryType: String, - domain: Domain, - types: Dictionary>, - message: Dictionary - ) { - self.primaryType = primaryType - self.domain = domain - self.types = types - self.message = message - } -} - -public struct SignTypedDataCallParams: Codable, Equatable { - public let account: EthereumAddress - public let data: EIP712TypedData - - public init(account: EthereumAddress, data: EIP712TypedData) { - self.account = account - self.data = data - } - - public init(from decoder: Decoder) throws { - var container = try decoder.unkeyedContainer() - let account = try container.decode(EthereumAddress.self) - let data = try container.decode(EIP712TypedData.self) - self.init(account: account, data: data) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.unkeyedContainer() - try container.encode(account) - try container.encode(data) - } -} - - -// MARK: - EIP 712 legacy -public struct EIP712TypedDataLegacyFields: Codable, Equatable { - - public let type: String - public let name: String - public let value: String - - public init( - type: String, - name: String, - value: String - ) { - self.type = type - self.name = name - self.value = value - } -} - - -public struct SignTypedDataLegacyCallParams: Codable, Equatable { - public let data: [EIP712TypedDataLegacyFields] - public let account: EthereumAddress - - public init(data: [EIP712TypedDataLegacyFields], account: EthereumAddress) { - self.data = data - self.account = account - } - - public init(from decoder: Decoder) throws { - var container = try decoder.unkeyedContainer() - let data = try container.decode(EIP712TypedDataLegacyFields.self) - let account = try container.decode(EthereumAddress.self) - self.init(data: [data], account: account) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.unkeyedContainer() - try container.encode(data) - try container.encode(account) - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Web3/JSONValue.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Web3/JSONValue.swift deleted file mode 100644 index 8070c33e6..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Web3/JSONValue.swift +++ /dev/null @@ -1,144 +0,0 @@ -// -// JSONValue.swift -// Web3 -// -// Created by Yehor Popovych on 3/19/19. -// from https://github.com/Boilertalk/Web3.swift/pull/75/commits/24c556f970115d15d38a4497952767fc4582b2b2 -import Foundation - -public enum JSONValue: Equatable { - case null - case bool(Bool) - case number(Double) - case string(String) - case array(Array) - case object(Dictionary) -} - -extension JSONValue: Codable { - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - switch self { - case let .array(array): - try container.encode(array) - case let .object(object): - try container.encode(object) - case let .string(string): - try container.encode(string) - case let .number(number): - try container.encode(number) - case let .bool(bool): - try container.encode(bool) - case .null: - try container.encodeNil() - } - } - - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - if let object = try? container.decode([String: JSONValue].self) { - self = .object(object) - } else if let array = try? container.decode([JSONValue].self) { - self = .array(array) - } else if let string = try? container.decode(String.self) { - self = .string(string) - } else if let bool = try? container.decode(Bool.self) { - self = .bool(bool) - } else if let number = try? container.decode(Double.self) { - self = .number(number) - } else if container.decodeNil() { - self = .null - } else { - throw DecodingError.dataCorrupted( - .init(codingPath: decoder.codingPath, debugDescription: "Invalid JSON value.") - ) - } - } -} - -extension JSONValue: CustomDebugStringConvertible { - public var debugDescription: String { - switch self { - case .string(let str): - return str.debugDescription - case .number(let num): - return num.debugDescription - case .bool(let bool): - return bool.description - case .null: - return "null" - default: - let encoder = JSONEncoder() - encoder.outputFormatting = [.prettyPrinted] - return try! String(data: encoder.encode(self), encoding: .utf8)! - } - } -} - -public extension JSONValue { - /// Return the string value if this is a `.string`, otherwise `nil` - var string: String? { - if case .string(let value) = self { - return value - } - return nil - } - - /// Return the double value if this is a `.number`, otherwise `nil` - var number: Double? { - if case .number(let value) = self { - return value - } - return nil - } - - /// Return the bool value if this is a `.bool`, otherwise `nil` - var bool: Bool? { - if case .bool(let value) = self { - return value - } - return nil - } - - /// Return the object value if this is an `.object`, otherwise `nil` - var objec: Dictionary? { - if case .object(let value) = self { - return value - } - return nil - } - - /// Return the array value if this is an `.array`, otherwise `nil` - var array: Array? { - if case .array(let value) = self { - return value - } - return nil - } - - /// Return `true` if this is `.null` - var isNull: Bool { - if case .null = self { - return true - } - return false - } - - /// If this is an `.array`, return item at index - /// - /// If this is not an `.array` or the index is out of bounds, returns `nil`. - subscript(index: Int) -> JSONValue? { - if case .array(let arr) = self, arr.indices.contains(index) { - return arr[index] - } - return nil - } - - /// If this is an `.object`, return item at key - subscript(key: String) -> JSONValue? { - if case .object(let dict) = self { - return dict[key] - } - return nil - } -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Web3/Web3Extension.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Web3/Web3Extension.swift deleted file mode 100644 index f63e733ed..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Modules/Web3/Web3Extension.swift +++ /dev/null @@ -1,136 +0,0 @@ -// -// Web3Extension.swift -// Magic -// -// Created by Jerry Liu on 2/9/20. -// Copyright © 2020 Magic Labs Inc. All rights reserved. -// - -import Foundation -import MagicSDK_Web3 -import PromiseKit - -// MARK: - web3 extension with closure -public extension Web3.Eth { - - func getCoinbase(response: @escaping Web3.Web3ResponseCompletion) { - let req = BasicRPCRequest( - id: properties.rpcId, - jsonrpc: Web3.jsonrpc, - method: "eth_coinbase", - params: [] - ) - properties.provider.send(request: req, response: response) - } - - func sign(from: EthereumAddress, message: EthereumData, response: @escaping Web3.Web3ResponseCompletion) { - let req = RPCRequest( - id: properties.rpcId, - jsonrpc: Web3.jsonrpc, - method: "eth_sign", - params: [from, message] - ) - properties.provider.send(request: req, response: response) - } - - func signTypedDataV1( - data: [EIP712TypedDataLegacyFields], - account: EthereumAddress, - response: @escaping Web3ResponseCompletion - ) { - let req = RPCRequest( - id: properties.rpcId, - jsonrpc: Web3.jsonrpc, - method: "eth_signTypedData", - params: SignTypedDataLegacyCallParams( - data: data, account: account - ) - ) - properties.provider.send(request: req, response: response) - } - - func signTypedDataV3( - account: EthereumAddress, - data: EIP712TypedData, - response: @escaping Web3ResponseCompletion - ) { - let req = RPCRequest( - id: properties.rpcId, - jsonrpc: Web3.jsonrpc, - method: "eth_signTypedData_v3", - params: SignTypedDataCallParams( - account: account, data: data - ) - ) - properties.provider.send(request: req, response: response) - } - - func signTypedDataV4( - account: EthereumAddress, - data: EIP712TypedData, - response: @escaping Web3ResponseCompletion - ) { - let req = RPCRequest( - id: properties.rpcId, - jsonrpc: Web3.jsonrpc, - method: "eth_signTypedData_v4", - params: SignTypedDataCallParams( - account: account, data: data - ) - ) - properties.provider.send(request: req, response: response) - } -} - -// MARK: - web3 extension Promises -/// -public extension Web3.Eth { - - func getCoinbase() -> Promise { - return Promise { resolver in - getCoinbase(response: promiseResolver(resolver)) - } - } - - func sign(from: EthereumAddress, message: EthereumData) -> Promise { - return Promise { resolver in - sign(from: from, message: message, response: promiseResolver(resolver)) - } - } - - func signTypedDataLegacy( - account: EthereumAddress, data: [EIP712TypedDataLegacyFields]) -> Promise { - return Promise { resolver in - signTypedDataV1(data: data, account: account, response: promiseResolver(resolver)) - } - } - - func signTypedData( - account: EthereumAddress, data: EIP712TypedData) -> Promise { - return Promise { resolver in - signTypedDataV3(account: account, data: data, response: promiseResolver(resolver)) - } - } - - func signTypedDataV4( - account: EthereumAddress, data: EIP712TypedData) -> Promise { - return Promise { resolver in - signTypedDataV4(account: account, data: data, response: promiseResolver(resolver)) - } - } -} - -public extension RPCRequest { - - init(method: String, params: Params) { - self = RPCRequest(id: generateRandomId(), jsonrpc: "2.0", method: method, params: params) - } -} - -/// Represents distinct Ethereum Networks -/// -/// Note: Conforms to Hashable so that we can use these as a Dictionary key -public enum EthNetwork: String { - case mainnet - case goerli -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Utilities/Number.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Utilities/Number.swift deleted file mode 100644 index 04cd8dd59..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Utilities/Number.swift +++ /dev/null @@ -1,12 +0,0 @@ -// -// Number.swift -// Magic -// -// Created by Jerry Liu on 3/11/20. -// - -import Foundation - -public func generateRandomId() -> Int{ - return Int.random(in: 1000..<100000) -} diff --git a/dydx/Pods/MagicSDK/Sources/MagicSDK/Utilities/Query.swift b/dydx/Pods/MagicSDK/Sources/MagicSDK/Utilities/Query.swift deleted file mode 100644 index 09f7aa14c..000000000 --- a/dydx/Pods/MagicSDK/Sources/MagicSDK/Utilities/Query.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// Query.swift -// Magic -// -// Created by Jerry Liu on 2/5/20. -// - -import Foundation - -enum QueryConstructError: Error { - case generationFailed(code: String) -} - -public func btoa(jsonString: String) -> String { - if let utf8str = jsonString.data(using: String.Encoding.utf8) { - let base64 = utf8str.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)) - return base64 - } - return "" -} - -func atob(encodedString: String) -> String { - let decodedData = Data(base64Encoded: encodedString)! - return String(data: decodedData, encoding: .utf8)! -} diff --git a/dydx/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Abacus.xcscheme b/dydx/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Abacus.xcscheme deleted file mode 100644 index 6a75e0d76..000000000 --- a/dydx/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Abacus.xcscheme +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dydx/dydx.xcworkspace/xcshareddata/swiftpm/Package.resolved b/dydx/dydx.xcworkspace/xcshareddata/swiftpm/Package.resolved index 44030d6e4..7d9595b53 100644 --- a/dydx/dydx.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/dydx/dydx.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "1c0055be4aba3ed4d97a2f62f05486877839310f65e2cbdd18b067bef06a04a3", + "originHash" : "975d00e29efb8d2ca017c5e61df90418ac01f7d7143e85a3f9ddb4eb982154e4", "pins" : [ { "identity" : "bigint", @@ -46,6 +46,15 @@ "revision" : "48134b5460435cc9d048223ad7560ee2e40f3d4a" } }, + { + "identity" : "percy-xcui-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/percy/percy-xcui-swift", + "state" : { + "revision" : "a2e9a86dfc3f5b69ef53cbda28a0ea71098c9f77", + "version" : "1.0.0" + } + }, { "identity" : "qrcode", "kind" : "remoteSourceControl", diff --git a/dydx/dydxAnalytics/dydxAnalytics.xcodeproj/project.pbxproj b/dydx/dydxAnalytics/dydxAnalytics.xcodeproj/project.pbxproj index d4699d474..e76c999db 100644 --- a/dydx/dydxAnalytics/dydxAnalytics.xcodeproj/project.pbxproj +++ b/dydx/dydxAnalytics/dydxAnalytics.xcodeproj/project.pbxproj @@ -28,6 +28,104 @@ remoteGlobalIDString = 2742BEAC2BF6860100E13C09; remoteInfo = dydxAnalytics; }; + 275C16D62BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16CC2BF7D723009313EC /* PlatformParticles.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 31ACB72921B0EE2D00391ADF; + remoteInfo = PlatformParticles; + }; + 275C16D82BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16CC2BF7D723009313EC /* PlatformParticles.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 313EB7C621BB592E00BEF926; + remoteInfo = PlatformParticlesAppleWatch; + }; + 275C16DA2BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16CC2BF7D723009313EC /* PlatformParticles.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 313EBB4321BB7A4B00BEF926; + remoteInfo = PlatformParticlesAppleTV; + }; + 275C16DC2BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16CC2BF7D723009313EC /* PlatformParticles.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 31CFF7C121D7D1F200DE7A79; + remoteInfo = MessageParticles; + }; + 275C16DE2BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16CC2BF7D723009313EC /* PlatformParticles.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 31ACB73221B0EE2D00391ADF; + remoteInfo = PlatformParticlesTests; + }; + 275C16E02BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16CC2BF7D723009313EC /* PlatformParticles.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 313EBB4B21BB7A4B00BEF926; + remoteInfo = PlatformParticlesAppleTVTests; + }; + 275C16E22BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16CC2BF7D723009313EC /* PlatformParticles.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 31CFF7C921D7D1F300DE7A79; + remoteInfo = MessageParticlesTests; + }; + 275C16EC2BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16E42BF7D723009313EC /* Utilities.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 31E65AB9216BC9C9008ABEE9; + remoteInfo = Utilities; + }; + 275C16EE2BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16E42BF7D723009313EC /* Utilities.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3196823721B791CF00AE0F28; + remoteInfo = UtilitiesAppleWatch; + }; + 275C16F02BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16E42BF7D723009313EC /* Utilities.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 313A536521B9805F00A92D62; + remoteInfo = UtilitiesAppleTV; + }; + 275C16F22BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16E42BF7D723009313EC /* Utilities.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 31E65AC2216BC9C9008ABEE9; + remoteInfo = UtilitiesTests; + }; + 275C16F42BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16E42BF7D723009313EC /* Utilities.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 313A536D21B9805F00A92D62; + remoteInfo = UtilitiesAppleTVTests; + }; + 275C16FB2BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16F62BF7D723009313EC /* dydxStateManager.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 02E7DC5E28CFAF5C00727949; + remoteInfo = dydxStateManager; + }; + 275C16FD2BF7D723009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16F62BF7D723009313EC /* dydxStateManager.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 02E7DC6828CFAF5C00727949; + remoteInfo = dydxStateManagerTests; + }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -43,6 +141,9 @@ 2742C03A2BF688B400E13C09 /* OnboardingAnalytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingAnalytics.swift; sourceTree = ""; }; 2742C03B2BF688B400E13C09 /* TransferAnalytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransferAnalytics.swift; sourceTree = ""; }; 2742C03C2BF688B400E13C09 /* AnalyticsEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsEvent.swift; sourceTree = ""; }; + 275C16CC2BF7D723009313EC /* PlatformParticles.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PlatformParticles.xcodeproj; path = ../../../PlatformParticles/PlatformParticles.xcodeproj; sourceTree = ""; }; + 275C16E42BF7D723009313EC /* Utilities.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Utilities.xcodeproj; path = ../../../Utilities/Utilities.xcodeproj; sourceTree = ""; }; + 275C16F62BF7D723009313EC /* dydxStateManager.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = dydxStateManager.xcodeproj; path = ../../dydxStateManager/dydxStateManager.xcodeproj; sourceTree = ""; }; 2FCEC9737902553D7EB58EF0 /* Pods_iOS_dydxAnalytics.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iOS_dydxAnalytics.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7D0A5DAA1E87EA50A32BE597 /* Pods-iOS-dydxAnalytics.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOS-dydxAnalytics.debug.xcconfig"; path = "Target Support Files/Pods-iOS-dydxAnalytics/Pods-iOS-dydxAnalytics.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -94,6 +195,7 @@ 2742BEA32BF6860100E13C09 = { isa = PBXGroup; children = ( + 275C16CB2BF7D70C009313EC /* Dependencies */, 2742BEAF2BF6860100E13C09 /* dydxAnalytics */, 2742BEBB2BF6860100E13C09 /* dydxAnalyticsTests */, 2742BEAE2BF6860100E13C09 /* Products */, @@ -131,6 +233,51 @@ path = dydxAnalyticsTests; sourceTree = ""; }; + 275C16CB2BF7D70C009313EC /* Dependencies */ = { + isa = PBXGroup; + children = ( + 275C16CC2BF7D723009313EC /* PlatformParticles.xcodeproj */, + 275C16E42BF7D723009313EC /* Utilities.xcodeproj */, + 275C16F62BF7D723009313EC /* dydxStateManager.xcodeproj */, + ); + path = Dependencies; + sourceTree = ""; + }; + 275C16CD2BF7D723009313EC /* Products */ = { + isa = PBXGroup; + children = ( + 275C16D72BF7D723009313EC /* PlatformParticles.framework */, + 275C16D92BF7D723009313EC /* PlatformParticles.framework */, + 275C16DB2BF7D723009313EC /* PlatformParticles.framework */, + 275C16DD2BF7D723009313EC /* MessageParticles.framework */, + 275C16DF2BF7D723009313EC /* PlatformParticlesTests.xctest */, + 275C16E12BF7D723009313EC /* PlatformParticlesAppleTVTests.xctest */, + 275C16E32BF7D723009313EC /* MessageParticlesTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 275C16E52BF7D723009313EC /* Products */ = { + isa = PBXGroup; + children = ( + 275C16ED2BF7D723009313EC /* Utilities.framework */, + 275C16EF2BF7D723009313EC /* Utilities.framework */, + 275C16F12BF7D723009313EC /* Utilities.framework */, + 275C16F32BF7D723009313EC /* UtilitiesTests.xctest */, + 275C16F52BF7D723009313EC /* UtilitiesAppleTVTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 275C16F72BF7D723009313EC /* Products */ = { + isa = PBXGroup; + children = ( + 275C16FC2BF7D723009313EC /* dydxStateManager.framework */, + 275C16FE2BF7D723009313EC /* dydxStateManagerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -211,6 +358,20 @@ mainGroup = 2742BEA32BF6860100E13C09; productRefGroup = 2742BEAE2BF6860100E13C09 /* Products */; projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 275C16F72BF7D723009313EC /* Products */; + ProjectRef = 275C16F62BF7D723009313EC /* dydxStateManager.xcodeproj */; + }, + { + ProductGroup = 275C16CD2BF7D723009313EC /* Products */; + ProjectRef = 275C16CC2BF7D723009313EC /* PlatformParticles.xcodeproj */; + }, + { + ProductGroup = 275C16E52BF7D723009313EC /* Products */; + ProjectRef = 275C16E42BF7D723009313EC /* Utilities.xcodeproj */; + }, + ); projectRoot = ""; targets = ( 2742BEAC2BF6860100E13C09 /* dydxAnalytics */, @@ -219,6 +380,107 @@ }; /* End PBXProject section */ +/* Begin PBXReferenceProxy section */ + 275C16D72BF7D723009313EC /* PlatformParticles.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = PlatformParticles.framework; + remoteRef = 275C16D62BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16D92BF7D723009313EC /* PlatformParticles.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = PlatformParticles.framework; + remoteRef = 275C16D82BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16DB2BF7D723009313EC /* PlatformParticles.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = PlatformParticles.framework; + remoteRef = 275C16DA2BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16DD2BF7D723009313EC /* MessageParticles.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = MessageParticles.framework; + remoteRef = 275C16DC2BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16DF2BF7D723009313EC /* PlatformParticlesTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = PlatformParticlesTests.xctest; + remoteRef = 275C16DE2BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16E12BF7D723009313EC /* PlatformParticlesAppleTVTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = PlatformParticlesAppleTVTests.xctest; + remoteRef = 275C16E02BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16E32BF7D723009313EC /* MessageParticlesTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = MessageParticlesTests.xctest; + remoteRef = 275C16E22BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16ED2BF7D723009313EC /* Utilities.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = Utilities.framework; + remoteRef = 275C16EC2BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16EF2BF7D723009313EC /* Utilities.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = Utilities.framework; + remoteRef = 275C16EE2BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16F12BF7D723009313EC /* Utilities.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = Utilities.framework; + remoteRef = 275C16F02BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16F32BF7D723009313EC /* UtilitiesTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = UtilitiesTests.xctest; + remoteRef = 275C16F22BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16F52BF7D723009313EC /* UtilitiesAppleTVTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = UtilitiesAppleTVTests.xctest; + remoteRef = 275C16F42BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16FC2BF7D723009313EC /* dydxStateManager.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = dydxStateManager.framework; + remoteRef = 275C16FB2BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C16FE2BF7D723009313EC /* dydxStateManagerTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = dydxStateManagerTests.xctest; + remoteRef = 275C16FD2BF7D723009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + /* Begin PBXResourcesBuildPhase section */ 2742BEAB2BF6860100E13C09 /* Resources */ = { isa = PBXResourcesBuildPhase; @@ -438,6 +700,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + LOCALIZATION_PREFERS_STRING_CATALOGS = NO; MARKETING_VERSION = 1.0; MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; @@ -472,6 +735,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); + LOCALIZATION_PREFERS_STRING_CATALOGS = NO; MARKETING_VERSION = 1.0; MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++"; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; diff --git a/dydx/dydxAnalytics/dydxAnalytics/AnalyticsEvent.swift b/dydx/dydxAnalytics/dydxAnalytics/AnalyticsEvent.swift index 6ad84529c..38c922ab3 100644 --- a/dydx/dydxAnalytics/dydxAnalytics/AnalyticsEvent.swift +++ b/dydx/dydxAnalytics/dydxAnalytics/AnalyticsEvent.swift @@ -66,7 +66,7 @@ public extension AnalyticsEventV2 { } } -public enum AnalyticsEventV2: TrackableEvent { +public enum AnalyticsEventV2: TrackableEvent, CustomDebugStringConvertible { case appStart case navigatePage(screen: ScreenIdentifiable) case deepLinkHandled(url: String, succeeded: Bool) @@ -116,6 +116,11 @@ public enum AnalyticsEventV2: TrackableEvent { ] } } + + public var debugDescription: String { + let sorted = customParameters.sorted { $0.key < $1.key } + return "dydxAnalytics event \(name) with data: \(sorted)" + } } public extension TrackingProtocol { @@ -128,5 +133,8 @@ public extension TrackingProtocol { default: break } + #if DEBUG + Console.shared.log(event.debugDescription) + #endif } } diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/MarketInfo/dydxSelectedMarketStore.swift b/dydx/dydxPresenters/dydxPresenters/_v4/MarketInfo/dydxSelectedMarketStore.swift index 380cd25a4..db8d9b31f 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/MarketInfo/dydxSelectedMarketStore.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/MarketInfo/dydxSelectedMarketStore.swift @@ -8,11 +8,11 @@ import Foundation import Utilities -final class dydxSelectedMarketsStore { +public final class dydxSelectedMarketsStore { private let storeKey = "last_selected_market" - static let shared = dydxSelectedMarketsStore() + public static let shared = dydxSelectedMarketsStore() - var lastSelectedMarket: String { + public var lastSelectedMarket: String { get { SettingsStore.shared?.value(forKey: storeKey) as? String ?? "ETH-USD" } set { SettingsStore.shared?.setValue(newValue, forKey: storeKey) } } diff --git a/dydx/dydxViews/dydxViews/SwiftUIHosting/HostingViewController.swift b/dydx/dydxViews/dydxViews/SwiftUIHosting/HostingViewController.swift index 40059174a..6e6475d98 100644 --- a/dydx/dydxViews/dydxViews/SwiftUIHosting/HostingViewController.swift +++ b/dydx/dydxViews/dydxViews/SwiftUIHosting/HostingViewController.swift @@ -16,7 +16,7 @@ import UIToolkits import PlatformRouting import FloatingPanel import Utilities - import dydxAnalytics +import dydxAnalytics public struct HostingViewControllerConfiguration { public init(ignoreSafeArea: Bool = true, fixedHeight: CGFloat? = nil, gradientTabbar: Bool = false, disableNavigationController: Bool = false) { diff --git a/dydxV4/dydxV4.xcodeproj/project.pbxproj b/dydxV4/dydxV4.xcodeproj/project.pbxproj index 0ac6ba442..4041a9843 100644 --- a/dydxV4/dydxV4.xcodeproj/project.pbxproj +++ b/dydxV4/dydxV4.xcodeproj/project.pbxproj @@ -33,6 +33,8 @@ 274F43062BA4C0B400645059 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 274F43052BA4C0B400645059 /* PrivacyInfo.xcprivacy */; }; 27968BA92BF7AC7A002F2C34 /* TrackingViewController+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27968BA82BF7AC7A002F2C34 /* TrackingViewController+Ext.swift */; }; 27ADEE6C2BC4A23400B8F1DB /* dydxSettingsStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27ADEE6B2BC4A23400B8F1DB /* dydxSettingsStore.swift */; }; + 27B7B9882BF7C6DC00BB0114 /* dydxAnalytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27B7B9872BF7C6DC00BB0114 /* dydxAnalytics.framework */; }; + 27B7B9892BF7C6DC00BB0114 /* dydxAnalytics.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 27B7B9872BF7C6DC00BB0114 /* dydxAnalytics.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 27D41AF12A8E9214009A2F37 /* UIApplication+URLHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27D41AF02A8E9214009A2F37 /* UIApplication+URLHandler.swift */; }; 27DBDD222A8FF5B2002383C6 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 27DBDCED2A8FF5B2002383C6 /* GoogleService-Info.plist */; }; 27DBDD232A8FF5B2002383C6 /* GoogleService-Info-Staging.plist in Resources */ = {isa = PBXBuildFile; fileRef = 27DBDD202A8FF5B2002383C6 /* GoogleService-Info-Staging.plist */; }; @@ -255,6 +257,34 @@ remoteGlobalIDString = 02E7DC5D28CFAF5C00727949; remoteInfo = dydxStateManager; }; + 275956052BF7D1FD008C77EE /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 31B77A0122DAD020004F9B21 /* Utilities.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 31E65AB8216BC9C9008ABEE9; + remoteInfo = Utilities; + }; + 275C17042BF7D730009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16FF2BF7D730009313EC /* dydxAnalytics.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2742BEAD2BF6860100E13C09; + remoteInfo = dydxAnalytics; + }; + 275C17062BF7D730009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16FF2BF7D730009313EC /* dydxAnalytics.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 2742BEB72BF6860100E13C09; + remoteInfo = dydxAnalyticsTests; + }; + 275C17082BF7D737009313EC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 275C16FF2BF7D730009313EC /* dydxAnalytics.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 2742BEAC2BF6860100E13C09; + remoteInfo = dydxAnalytics; + }; 3112F476216BBF8600708927 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 3112F457216BBF8400708927 /* Project object */; @@ -640,13 +670,6 @@ remoteGlobalIDString = 31E65B00216BCA10008ABEE9; remoteInfo = RoutingKit; }; - 31B77BB722DAD077004F9B21 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 31B77A0122DAD020004F9B21 /* Utilities.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = 31E65AB8216BC9C9008ABEE9; - remoteInfo = Utilities; - }; 31B77BBB22DAD077004F9B21 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 31B77AEB22DAD023004F9B21 /* ParticlesCommonModels.xcodeproj */; @@ -757,6 +780,7 @@ 022F35CD28D39304000BCA41 /* dydxPresenters.framework in Embed Frameworks */, 02E7DDDF28CFB33B00727949 /* dydxStateManager.framework in Embed Frameworks */, 025B83FF28AAAB270037FF7C /* PlatformUI.framework in Embed Frameworks */, + 27B7B9892BF7C6DC00BB0114 /* dydxAnalytics.framework in Embed Frameworks */, 31B77C2722DAD0B3004F9B21 /* JedioKit.framework in Embed Frameworks */, 31B77C4922DAD0B4004F9B21 /* Utilities.framework in Embed Frameworks */, 31B77C4322DAD0B4004F9B21 /* UIToolkits.framework in Embed Frameworks */, @@ -798,9 +822,12 @@ 02DA0B022B57622B00BFA975 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 02E7DD9A28CFB31000727949 /* dydxStateManager.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = dydxStateManager.xcodeproj; path = ../dydx/dydxStateManager/dydxStateManager.xcodeproj; sourceTree = ""; }; 171807B0CCAE5C86B5D65793 /* Pods_iOS_dydxV4.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iOS_dydxV4.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 2729BA102BF7C93100729A85 /* dydxAnalytics.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = dydxAnalytics.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 274F43052BA4C0B400645059 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = ""; }; + 275C16FF2BF7D730009313EC /* dydxAnalytics.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = dydxAnalytics.xcodeproj; path = ../dydx/dydxAnalytics/dydxAnalytics.xcodeproj; sourceTree = ""; }; 27968BA82BF7AC7A002F2C34 /* TrackingViewController+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TrackingViewController+Ext.swift"; sourceTree = ""; }; 27ADEE6B2BC4A23400B8F1DB /* dydxSettingsStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxSettingsStore.swift; sourceTree = ""; }; + 27B7B9872BF7C6DC00BB0114 /* dydxAnalytics.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = dydxAnalytics.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 27D41AF02A8E9214009A2F37 /* UIApplication+URLHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+URLHandler.swift"; sourceTree = ""; }; 27DBDCED2A8FF5B2002383C6 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; 27DBDD202A8FF5B2002383C6 /* GoogleService-Info-Staging.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info-Staging.plist"; sourceTree = ""; }; @@ -878,6 +905,7 @@ 6466E116280F664900B8791B /* AmplitudeInjections.framework in Frameworks */, 31B77C2622DAD0B3004F9B21 /* JedioKit.framework in Frameworks */, 31B77C2522DAD0B3004F9B21 /* libFirebaseStaticInjections.a in Frameworks */, + 27B7B9882BF7C6DC00BB0114 /* dydxAnalytics.framework in Frameworks */, 024B7A9528B7F6CC00F7C386 /* dydxViews.framework in Frameworks */, 31F761C924BA3E98001EA293 /* WebParticles.framework in Frameworks */, 31B77C3422DAD0B3004F9B21 /* PlatformRouting.framework in Frameworks */, @@ -942,6 +970,7 @@ 02684D6028BD40830007CEFF /* Dependencies */ = { isa = PBXGroup; children = ( + 275C16FF2BF7D730009313EC /* dydxAnalytics.xcodeproj */, 027E1DCD29C912510098666F /* PlatformUIJedio.xcodeproj */, 02439CCC29B03F4C00A083FE /* dydxCartera.xcodeproj */, 029E11E529ADB9BC00FE271C /* dydxChart.xcodeproj */, @@ -1041,6 +1070,8 @@ 0904864F08DCEDE87F5B4956 /* Frameworks */ = { isa = PBXGroup; children = ( + 2729BA102BF7C93100729A85 /* dydxAnalytics.framework */, + 27B7B9872BF7C6DC00BB0114 /* dydxAnalytics.framework */, 02DA0B022B57622B00BFA975 /* XCTest.framework */, 646D73AB2A4F434300EDF2E5 /* dydxAbacusBridging.framework */, 31B77C2422DAD0B3004F9B21 /* dydxUI.framework */, @@ -1054,6 +1085,15 @@ name = Frameworks; sourceTree = ""; }; + 275C17002BF7D730009313EC /* Products */ = { + isa = PBXGroup; + children = ( + 275C17052BF7D730009313EC /* dydxAnalytics.framework */, + 275C17072BF7D730009313EC /* dydxAnalyticsTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; 27ADEE6D2BC4A23B00B8F1DB /* _Settings */ = { isa = PBXGroup; children = ( @@ -1356,13 +1396,16 @@ buildRules = ( ); dependencies = ( - 027E1E1229C9125C0098666F /* PBXTargetDependency */, + 275956062BF7D1FD008C77EE /* PBXTargetDependency */, + 31B77BC422DAD077004F9B21 /* PBXTargetDependency */, 02439D1029B03F5D00A083FE /* PBXTargetDependency */, 029E11EF29ADB9BF00FE271C /* PBXTargetDependency */, 0284210829AD77FF00C0E7CC /* PBXTargetDependency */, + 275C17092BF7D737009313EC /* PBXTargetDependency */, 022F358F28D392CF000BCA41 /* PBXTargetDependency */, 022F35CB28D392D6000BCA41 /* PBXTargetDependency */, 02E7DDDE28CFB32D00727949 /* PBXTargetDependency */, + 027E1E1229C9125C0098666F /* PBXTargetDependency */, 025B83FE28AAAB1F0037FF7C /* PBXTargetDependency */, 6466E115280F663000B8791B /* PBXTargetDependency */, 31AB94D226DEE82A00DB42B9 /* PBXTargetDependency */, @@ -1371,12 +1414,10 @@ 31B77BB222DAD077004F9B21 /* PBXTargetDependency */, 31B77BB422DAD077004F9B21 /* PBXTargetDependency */, 31B77BB622DAD077004F9B21 /* PBXTargetDependency */, - 31B77BB822DAD077004F9B21 /* PBXTargetDependency */, 31B77BBC22DAD077004F9B21 /* PBXTargetDependency */, 31B77BBE22DAD077004F9B21 /* PBXTargetDependency */, 31B77BC022DAD077004F9B21 /* PBXTargetDependency */, 31B77BC222DAD077004F9B21 /* PBXTargetDependency */, - 31B77BC422DAD077004F9B21 /* PBXTargetDependency */, 31B77BCA22DAD077004F9B21 /* PBXTargetDependency */, ); name = dydxV4; @@ -1480,6 +1521,10 @@ ProductGroup = 31AB94C926DEE81000DB42B9 /* Products */; ProjectRef = 31AB94C826DEE81000DB42B9 /* CameraParticles.xcodeproj */; }, + { + ProductGroup = 275C17002BF7D730009313EC /* Products */; + ProjectRef = 275C16FF2BF7D730009313EC /* dydxAnalytics.xcodeproj */; + }, { ProductGroup = 02439CCD29B03F4C00A083FE /* Products */; ProjectRef = 02439CCC29B03F4C00A083FE /* dydxCartera.xcodeproj */; @@ -1675,6 +1720,20 @@ remoteRef = 02E7DDA928CFB31000727949 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 275C17052BF7D730009313EC /* dydxAnalytics.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = dydxAnalytics.framework; + remoteRef = 275C17042BF7D730009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 275C17072BF7D730009313EC /* dydxAnalyticsTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = dydxAnalyticsTests.xctest; + remoteRef = 275C17062BF7D730009313EC /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 314B726A23DD124E00139EB3 /* libAppsFlyerStaticInjections.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -2385,6 +2444,16 @@ name = dydxStateManager; targetProxy = 02E7DDDD28CFB32D00727949 /* PBXContainerItemProxy */; }; + 275956062BF7D1FD008C77EE /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = Utilities; + targetProxy = 275956052BF7D1FD008C77EE /* PBXContainerItemProxy */; + }; + 275C17092BF7D737009313EC /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = dydxAnalytics; + targetProxy = 275C17082BF7D737009313EC /* PBXContainerItemProxy */; + }; 3112F477216BBF8600708927 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 3112F45E216BBF8400708927 /* dydxV4 */; @@ -2415,11 +2484,6 @@ name = RoutingKit; targetProxy = 31B77BB522DAD077004F9B21 /* PBXContainerItemProxy */; }; - 31B77BB822DAD077004F9B21 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = Utilities; - targetProxy = 31B77BB722DAD077004F9B21 /* PBXContainerItemProxy */; - }; 31B77BBC22DAD077004F9B21 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = ParticlesCommonModels; diff --git a/dydxV4/dydxV4/_Tracking/TrackingViewController+Ext.swift b/dydxV4/dydxV4/_Tracking/TrackingViewController+Ext.swift index 4346e08dd..1b61a534d 100644 --- a/dydxV4/dydxV4/_Tracking/TrackingViewController+Ext.swift +++ b/dydxV4/dydxV4/_Tracking/TrackingViewController+Ext.swift @@ -8,8 +8,9 @@ import Utilities import PlatformParticles +import dydxPresenters -extension TrackingViewController: ScreenIdentifiable { +extension TrackingViewController: ScreenIdentifiable, TrackingViewProtocol { public var mobilePath: String { switch path { case "/market", "/trade": @@ -35,6 +36,10 @@ extension TrackingViewController: ScreenIdentifiable { public var screenClass: String { String(describing: type(of: self)) } + + public func logScreenView() { + Tracking.shared?.log(event: .navigatePage(screen: self)) + } } @@ -49,10 +54,6 @@ private extension TrackingViewController { } private var marketId: String { - guard let marketId = history?.params?["market"] as? String else { - assertionFailure("no marketId for \(screenClass)") - return "" - } - return marketId + history?.params?["market"] as? String ?? dydxSelectedMarketsStore.shared.lastSelectedMarket } } diff --git a/dydxV4/dydxV4/_Tracking/dydxAmplitudeTracking.swift b/dydxV4/dydxV4/_Tracking/dydxAmplitudeTracking.swift index 1c840bc48..d7a3f27e2 100644 --- a/dydxV4/dydxV4/_Tracking/dydxAmplitudeTracking.swift +++ b/dydxV4/dydxV4/_Tracking/dydxAmplitudeTracking.swift @@ -10,9 +10,6 @@ import AmplitudeInjections import UIKit public class dydxAmplitudeTracking: AmplitudeTracking { - override open func view(_ path: String?, action: String?, data: [String: Any]?, from: String?, time: Date?, revenue: NSNumber?, contextViewController: UIViewController?) { - // Only track the ones required by growth - } override open func log(event: String, data: [String: Any]?, revenue: NSNumber?) { if event.first?.isUppercase ?? false { diff --git a/dydxV4/dydxV4/_Tracking/dydxCompositeTracking.swift b/dydxV4/dydxV4/_Tracking/dydxCompositeTracking.swift index 03941fb39..cdf4d0e4f 100644 --- a/dydxV4/dydxV4/_Tracking/dydxCompositeTracking.swift +++ b/dydxV4/dydxV4/_Tracking/dydxCompositeTracking.swift @@ -85,38 +85,6 @@ public class dydxCompositeTracking: CompositeTracking { .store(in: &subscriptions) } - - - -// override public func view(_ path: String?, action: String?, data: [String: Any]?, from: String?, time: Date?, revenue: NSNumber?, contextViewController: UIViewController?) { -// if let transformed = transform(events: viewEvents, path: path), let event = parser.asString(transformed["event"]) { -// super.view(path, action: action, data: data, from: from, time: time, revenue: nil, contextViewController: contextViewController) -// let info = parser.asDictionary(transformed["info"]) ?? data ?? [String: Any]() -// log(event: event, data: info, revenue: revenue) -// } else { -// super.view(path, action: action, data: data, from: from, time: time, revenue: revenue, contextViewController: contextViewController) -// } -// if let contextViewController { -// -// log(event: AnalyticsEventScreenView, -// data: [ -// AnalyticsParameterScreenName: path as Any, -// AnalyticsParameterScreenClass: String(describing: type(of: contextViewController)) -// ]) -// } -// if let transformed = transform(events: onboardingEvents, path: path), let event = parser.asString(transformed["event"]) { -// var info = parser.asDictionary(transformed["info"]) ?? data ?? [String: Any]() -// if event == "OnboardingStepChanged" { -// if let time = time, let previous = transform(events: onboardingEvents, path: from), parser.asString(transformed["event"]) == "OnboardingStepChanged" { -// let seconds = Int(Date().timeIntervalSince(time)) -// info["secondsOnPreviousStep"] = NSNumber(value: seconds) -// info["previousStep"] = (previous["info"] as? [String: Any])?["currentStep"] -// } -// } -// log(event: event, data: info, revenue: revenue) -// } -// } - override public func leave(_ path: String?) { super.leave(path) if let transformed = transform(events: viewEvents, path: path), let event = parser.asString(transformed["event"]) {