diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxRestrictionsWorker.swift b/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxRestrictionsWorker.swift index 9c8308f43..d54100804 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxRestrictionsWorker.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/GlobalWorkers/Workers/dydxRestrictionsWorker.swift @@ -17,13 +17,55 @@ public final class dydxRestrictionsWorker: BaseWorker { public override func start() { super.start() + // used in protocol 4.0 AbacusStateManager.shared.state.restriction - .compactMap { $0 } - .removeDuplicates() .sink { restriction in Self.handle(restriction: restriction) } .store(in: &subscriptions) + + // used in protocol 4.0 + AbacusStateManager.shared.state.complianceStatus + .sink { complianceStatus in + Self.handle(complianceStatus: complianceStatus) + } + .store(in: &subscriptions) + } + + public static func handle(complianceStatus: ComplianceStatus) { + let title: String? + let body: String? + switch complianceStatus { + case .compliant: + return + case .firstStrike, .firstStrikeCloseOnly, .closeOnly: + // TODO: add DATE & EMAIL + // [MOB-478 : update copy params for new compliance status strings](https://linear.app/dydx/issue/MOB-478/update-copy-params-for-new-compliance-status-strings) + title = DataLocalizer.shared?.localize( + path: "APP.COMPLIANCE.CLOSE_ONLY_TITLE", + params: nil) ?? "" + body = DataLocalizer.shared?.localize( + path: "APP.COMPLIANCE.CLOSE_ONLY_BODY", + params: [ + "DATE": "--", + "EMAIL": "--" + ]) ?? "" + case .blocked: + // TODO: add DATE & EMAIL + // [MOB-478 : update copy params for new compliance status strings](https://linear.app/dydx/issue/MOB-478/update-copy-params-for-new-compliance-status-strings) + title = DataLocalizer.shared?.localize( + path: "APP.COMPLIANCE.PERMANENTLY_BLOCKED_TITLE", + params: nil) ?? "" + body = DataLocalizer.shared?.localize( + path: "APP.COMPLIANCE.PERMANENTLY_BLOCKED_BODY", + params: [ + "EMAIL": "--" + ]) ?? "" + default: + return + } + ErrorInfo.shared?.info(title: title, message: body, type: .error, error: nil, time: 30.0) + AbacusStateManager.shared.disconnectAndReplaceCurrentWallet() } public static func handle(restriction: Restriction) { @@ -40,7 +82,7 @@ public final class dydxRestrictionsWorker: BaseWorker { case .userRestrictionUnknown: let title = DataLocalizer.shared?.localize(path: "ERRORS.GENERAL.RATE_LIMIT_REACHED_ERROR_TITLE", params: nil) ?? "" let body = DataLocalizer.shared?.localize(path: "ERRORS.GENERAL.RATE_LIMIT_REACHED_ERROR_MESSAGE", params: nil) ?? "" - ErrorInfo.shared?.info(title: title, message: body, type: .error, error: nil) + ErrorInfo.shared?.info(title: title, message: body, type: .error, error: nil, time: 10.0) default: assertionFailure("unknown restriction error, please add support for restriction \(restriction)") } diff --git a/dydx/dydxStateManager/dydxStateManager/AbacusState+Combine.swift b/dydx/dydxStateManager/dydxStateManager/AbacusState+Combine.swift index 48b82828f..d062c00ff 100644 --- a/dydx/dydxStateManager/dydxStateManager/AbacusState+Combine.swift +++ b/dydx/dydxStateManager/dydxStateManager/AbacusState+Combine.swift @@ -100,6 +100,7 @@ public final class AbacusState { .eraseToAnyPublisher() } + /// protocol pre v5.0 public var restriction: AnyPublisher { statePublisher .compactMap { $0?.restriction?.restriction ?? .noRestriction } @@ -108,6 +109,15 @@ public final class AbacusState { .eraseToAnyPublisher() } + // protocol v5.0 and up + public var complianceStatus: AnyPublisher { + statePublisher + .compactMap { $0?.compliance?.status } + .removeDuplicates() + .share() + .eraseToAnyPublisher() + } + public func accountBalance(of tokenDenom: String?) -> AnyPublisher { account .map { account in