Skip to content

Commit

Permalink
Merge pull request #503 from dashpay/develop
Browse files Browse the repository at this point in the history
chore: Merge develop into master
  • Loading branch information
tikhop authored Feb 10, 2023
2 parents 5476c8d + 572dfca commit 83562ad
Show file tree
Hide file tree
Showing 256 changed files with 6,205 additions and 5,751 deletions.
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
--wrapreturntype preserve #wrapArguments
--closingparen same-line # wrapArguments
--wraptypealiases before-first # wrapArguments
--funcattributes same-line # wrapAttributes
--funcattributes prev-line # wrapAttributes
--typeattributes prev-line # wrapAttributes
--wrapternary before-operators # wraprations
--extensionacl on-declarations # extensionAccessControl
Expand Down
2 changes: 1 addition & 1 deletion DashSyncCurrentCommit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
736b94749509a0326caf576f977dacd53f16a0e1
8037e915353a7c10e03dd7069bbc33fb1cc3e918
520 changes: 334 additions & 186 deletions DashWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion DashWallet/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[DSLogger sharedInstance];
[FIRApp configure];
[ExploreDashObjcWrapper configure];

[CurrencyExchangerObjcWrapper startExchangeRateFetching];
[CoinbaseObjcWrapper start];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(dsApplicationTerminationRequestNotification:)
name:DSApplicationTerminationRequestNotification
Expand Down
2 changes: 0 additions & 2 deletions DashWallet/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<key>UTImportedTypeDeclarations</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,50 @@
{
"images" : [
{
"filename" : "shortcut_scanToPay.png",
"filename" : "Light-M.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "Light-M 1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "Light-M@2x 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "Light-M@3x 1.png",
"idiom" : "universal",
"scale" : "3x"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Created by Andrew Podkovyrin
// Copyright © 2020 Dash Core Group. All rights reserved.
// Created by tkhp
// Copyright © 2023 Dash Core Group. All rights reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,8 +15,10 @@
// limitations under the License.
//

#import "DWAmountDescriptionViewModel.h"
import Foundation

@implementation DWAmountDescriptionViewModel
class App {
static func initialize() { }

@end
static let shared = App()
}
39 changes: 39 additions & 0 deletions DashWallet/Sources/Application/Preferences.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Created by tkhp
// Copyright © 2023 Dash Core Group. All rights reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

private let kDefaultCurrencyCode = "USD"
private let kFiatCurrencyCodeKey = "LOCAL_CURRENCY_CODE"

extension App {
var fiatCurrency: String {
guard let currency = UserDefaults.standard.value(forKey: kFiatCurrencyCodeKey) as? String else {
if #available(iOS 16, *) {
return Locale.current.currency?.identifier ?? kDefaultCurrencyCode
} else {
return NSLocale.current.currencyCode ?? kDefaultCurrencyCode
}
}

return currency
}
}

extension App {
static var fiatCurrency: String { shared.fiatCurrency }
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,48 +96,56 @@ class SyncingActivityMonitor: NSObject, NetworkReachabilityHandling {
startSyncingIfNeeded()
}

@objc public func forceStartSyncingActivity() {
@objc
public func forceStartSyncingActivity() {
startSyncingActivity()
}

@objc(addObserver:) public func add(observer: SyncingActivityMonitorObserver) {
@objc(addObserver:)
public func add(observer: SyncingActivityMonitorObserver) {
observers.append(observer)
}

@objc(removeObserver:) public func remove(observer: SyncingActivityMonitorObserver) {
@objc(removeObserver:)
public func remove(observer: SyncingActivityMonitorObserver) {
if let idx = observers.firstIndex(where: { $0 === observer }) {
observers.remove(at: idx)
}
}

// MARK: Notifications

@objc func chainManagerSyncStartedNotification(notification: Notification) {
@objc
func chainManagerSyncStartedNotification(notification: Notification) {
guard shouldAcceptSyncNotification(notification) else { return }

startSyncingActivity()
}

@objc func chainManagerParametersUpdatedNotification(notification: Notification) {
@objc
func chainManagerParametersUpdatedNotification(notification: Notification) {
guard shouldAcceptSyncNotification(notification) else { return }

startSyncingActivity()
}

@objc func chainManagerSyncFinishedNotification(notification: Notification) {
@objc
func chainManagerSyncFinishedNotification(notification: Notification) {
guard shouldAcceptSyncNotification(notification) else { return }
guard shouldStopSyncing else { return }

stopSyncingActivity(failed: false)
}

@objc func chainManagerSyncFailedNotification(notification: Notification) {
@objc
func chainManagerSyncFailedNotification(notification: Notification) {
guard shouldAcceptSyncNotification(notification) else { return }

stopSyncingActivity(failed: true)
}

@objc func chainManagerChainBlocksDidChangeNotification(notification: Notification) {
@objc
func chainManagerChainBlocksDidChangeNotification(notification: Notification) {
guard !isSyncing, chainSyncProgress < kSyncingCompleteProgress else { return }

startSyncingActivity()
Expand Down Expand Up @@ -181,7 +189,8 @@ extension SyncingActivityMonitor {
state = failed ? .syncFailed : .syncDone
}

@objc private func syncLoop() {
@objc
private func syncLoop() {
guard reachability.networkReachabilityStatus != .notReachable else {
state = .noConnection
return
Expand Down
104 changes: 92 additions & 12 deletions DashWallet/Sources/Application/Tools.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,109 @@

import Foundation

private var _decimalFormatter: NumberFormatter!
private var _fiatFormatter: NumberFormatter!
private var _dashFormatter: NumberFormatter = {
let maximumFractionDigits = 8

var dashFormat = NumberFormatter()
dashFormat.isLenient = true
dashFormat.numberStyle = .currency
dashFormat.generatesDecimalNumbers = true
if let range = dashFormat.positiveFormat.range(of: "#") {
dashFormat.negativeFormat = dashFormat.positiveFormat.replacingCharacters(in: range, with: "-#")
}

dashFormat.currencyCode = "DASH"
dashFormat.currencySymbol = DASH
dashFormat.maximumFractionDigits = maximumFractionDigits
dashFormat.minimumFractionDigits = 0
var dashFormat = NumberFormatter.cryptoFormatter(currencyCode: DASH, exponent: maximumFractionDigits)
dashFormat.locale = Locale.current
dashFormat.maximum = (Decimal(MAX_MONEY)/pow(10, maximumFractionDigits)) as NSNumber

return dashFormat
}()

private var _dashDecimalFormatter: NumberFormatter = {
let formatter = NumberFormatter()
formatter.isLenient = true
formatter.numberStyle = .none
formatter.generatesDecimalNumbers = true
formatter.locale = Locale.current
formatter.minimumIntegerDigits = 1
formatter.minimumFractionDigits = 0
formatter.maximumFractionDigits = 8
return formatter
}()

extension NumberFormatter {

static var decimalFormatter: NumberFormatter {
guard let formatter = _decimalFormatter else {
let formatter = NumberFormatter()
formatter.isLenient = true
formatter.numberStyle = .none
formatter.generatesDecimalNumbers = true
formatter.locale = Locale.current
formatter.minimumFractionDigits = 0
formatter.maximumFractionDigits = 20
_decimalFormatter = formatter
return formatter
}

return formatter
}

static func dashDecimalFormatter(for locale: Locale) -> NumberFormatter {
let formatter = dashDecimalFormatter.copy() as! NumberFormatter
formatter.locale = locale
return formatter
}

/// Returns `NumberFormatter` that formats a number into a currency string using selected currency
///
/// - Returns:`NumberFormatter`
///
static var fiatFormatter: NumberFormatter {
if let fiatFormatter = _fiatFormatter, fiatFormatter.currencyCode == App.fiatCurrency {
return fiatFormatter
}

let formatter = fiatFormatter(currencyCode: App.fiatCurrency)
formatter.locale = Locale.current
_fiatFormatter = formatter
return formatter
}

static var dashFormatter: NumberFormatter {
_dashFormatter
}

/// Returns `NumberFormatter` that formats a number into dash format, but without currency symbol
///
/// - Returns:`NumberFormatter`
///
static var dashDecimalFormatter: NumberFormatter {
_dashDecimalFormatter
}

static func cryptoFormatter(currencyCode: String, exponent: Int) -> NumberFormatter {
let formatter = NumberFormatter()
formatter.isLenient = true
formatter.numberStyle = .currency
formatter.generatesDecimalNumbers = true
if let range = formatter.positiveFormat.range(of: "#") {
formatter.negativeFormat = formatter.positiveFormat.replacingCharacters(in: range, with: "-#")
}

formatter.currencyCode = currencyCode

if currencyCode == "DASH" {
formatter.currencySymbol = currencyCode
}

formatter.maximumFractionDigits = exponent
formatter.minimumFractionDigits = 0

return formatter
}

static func fiatFormatter(currencyCode: String) -> NumberFormatter {
let formatter = NumberFormatter()
formatter.isLenient = true
formatter.numberStyle = .currency
formatter.generatesDecimalNumbers = true
formatter.currencyCode = currencyCode
return formatter
}
}

2 changes: 2 additions & 0 deletions DashWallet/Sources/Categories/DSTransaction+DashWallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly) NSData *txHashData;
@property (readonly) NSString *txHashHexString;

+ (uint64_t)txMinOutputAmount;

@end

NS_ASSUME_NONNULL_END
3 changes: 3 additions & 0 deletions DashWallet/Sources/Categories/DSTransaction+DashWallet.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ - (NSString *)txHashHexString {
return uint256_reverse_data(self.txHash).hexString;
}

+ (uint64_t)txMinOutputAmount {
return TX_MIN_OUTPUT_AMOUNT;
}
@end
6 changes: 5 additions & 1 deletion DashWallet/Sources/Categories/ErrorPresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ protocol ErrorPresentable: MessagePresentable {
}

extension ErrorPresentable where Self: UIViewController {
func present(error: Error) {
present(message: error.localizedDescription, level: .error)
}

func present(message: MessageDataProvider) {
present(message: message.message, level: message.level)
}

func present(message: String, level: MessageLevel) {
showAlert(with: "Error", message: message)
showAlert(with: NSLocalizedString("Error", comment: ""), message: message)
}
}
Loading

0 comments on commit 83562ad

Please sign in to comment.