Skip to content

Commit

Permalink
chore: Merge pull request #519 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 22, 2023
2 parents 83562ad + 0d2ccaa commit 6be4d19
Show file tree
Hide file tree
Showing 93 changed files with 678 additions and 427 deletions.
51 changes: 26 additions & 25 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
[main]
host = https://www.transifex.com

[dash-mobile-wallets.app-localizable-strings]
file_filter = DashWallet/<lang>.lproj/Localizable.strings
[o:dash:p:dash-mobile-wallets:r:app-localizable-strings]
file_filter = DashWallet/<lang>.lproj/Localizable.strings
source_file = DashWallet/en.lproj/Localizable.strings
source_lang = en
type = STRINGS
minimum_perc = 0
source_file = DashWallet/en.lproj/Localizable.strings
source_lang = en
type = STRINGS

[dash-mobile-wallets.app-localizable-strings-dict]
file_filter = DashWallet/<lang>.lproj/Localizable.stringsdict
[o:dash:p:dash-mobile-wallets:r:app-localizable-strings-dict]
file_filter = DashWallet/<lang>.lproj/Localizable.stringsdict
source_file = DashWallet/en.lproj/Localizable.stringsdict
source_lang = en
type = STRINGSDICT
minimum_perc = 0
source_file = DashWallet/en.lproj/Localizable.stringsdict
source_lang = en
type = STRINGSDICT

[dash-mobile-wallets.watch-interface-strings]
file_filter = WatchApp/<lang>.lproj/Interface.strings
[o:dash:p:dash-mobile-wallets:r:appstore-description]
file_filter = fastlane/metadata/<lang>/description.txt
source_file = fastlane/metadata/en-US/description.txt
source_lang = en
type = TXT
minimum_perc = 0
source_file = WatchApp/en.lproj/Interface.strings
source_lang = en
type = STRINGS

[dash-mobile-wallets.appstore-description]
file_filter = fastlane/metadata/<lang>/description.txt
[o:dash:p:dash-mobile-wallets:r:appstore-release_notes]
file_filter = fastlane/metadata/<lang>/release_notes.txt
source_file = fastlane/metadata/en-US/release_notes.txt
source_lang = en
type = TXT
minimum_perc = 0
source_file = fastlane/metadata/en-US/description.txt
source_lang = en
type = TXT

[dash-mobile-wallets.appstore-release_notes]
file_filter = fastlane/metadata/<lang>/release_notes.txt
[o:dash:p:dash-mobile-wallets:r:watch-interface-strings]
file_filter = WatchApp/<lang>.lproj/Interface.strings
source_file = WatchApp/en.lproj/Interface.strings
source_lang = en
type = STRINGS
minimum_perc = 0
source_file = fastlane/metadata/en-US/release_notes.txt
source_lang = en
type = TXT

98 changes: 56 additions & 42 deletions DashWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions DashWallet/Sources/Application/Tools.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import Foundation

private var _cachedFormatters: [String: NumberFormatter] = [:]

private var _decimalFormatter: NumberFormatter!
private var _fiatFormatter: NumberFormatter!
private var _dashFormatter: NumberFormatter = {
Expand Down Expand Up @@ -93,6 +95,10 @@ extension NumberFormatter {
}

static func cryptoFormatter(currencyCode: String, exponent: Int) -> NumberFormatter {
if let formatter = _cachedFormatters[currencyCode] {
return formatter
}

let formatter = NumberFormatter()
formatter.isLenient = true
formatter.numberStyle = .currency
Expand All @@ -109,16 +115,23 @@ extension NumberFormatter {

formatter.maximumFractionDigits = exponent
formatter.minimumFractionDigits = 0
_cachedFormatters[currencyCode] = formatter

return formatter
}

static func fiatFormatter(currencyCode: String) -> NumberFormatter {
if let formatter = _cachedFormatters[currencyCode] {
return formatter
}

let formatter = NumberFormatter()
formatter.isLenient = true
formatter.numberStyle = .currency
formatter.generatesDecimalNumbers = true
formatter.currencyCode = currencyCode
_cachedFormatters[currencyCode] = formatter

return formatter
}
}
Expand Down
1 change: 1 addition & 0 deletions DashWallet/Sources/Categories/DSTransaction+DashWallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN

@property (readonly) NSData *txHashData;
@property (readonly) NSString *txHashHexString;
@property (readonly) NSDate *date;

+ (uint64_t)txMinOutputAmount;

Expand Down
9 changes: 9 additions & 0 deletions DashWallet/Sources/Categories/DSTransaction+DashWallet.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@

@implementation DSTransaction (DashWallet)

- (NSDate *)date {
DSChain *chain = self.chain;
NSTimeInterval now = [chain timestampForBlockHeight:TX_UNCONFIRMED];
NSTimeInterval txTime = (self.timestamp > 1) ? self.timestamp : now;
NSDate *txDate = [NSDate dateWithTimeIntervalSince1970:txTime];

return txDate;
}

- (NSData *)txHashData {
return [NSData dataWithBytes:self.txHash.u8 length:sizeof(UInt256)];
}
Expand Down
4 changes: 4 additions & 0 deletions DashWallet/Sources/Categories/Numbers+Dash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ extension Decimal {
rounded(sign == .minus ? .up : .down)
}

var fractionDigits: Int {
max(-exponent, 0)
}

/// Converts `Decimal` to plain dash amount in duffs
///
/// - Returns: Plain dash amount in duffs
Expand Down
1 change: 0 additions & 1 deletion DashWallet/Sources/Categories/String+DashWallet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ extension String {
}

let isCurrencySymbolAtTheBeginning = currencySymbolRange.lowerBound == format.startIndex
let isCurrencySymbolAtTheEnd = currencySymbolRange.upperBound == format.endIndex

// special case to deal with RTL languages
if format.hasPrefix("\u{0000200e}") || format.hasPrefix("\u{0000200f}") {
Expand Down
181 changes: 0 additions & 181 deletions DashWallet/Sources/Categories/UIViewController+Payments.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public final class CurrencyExchanger {
if amount.isZero { return 0 }

let rate = try rate(for: currency)
return try convertDash(amount: amount, to: currency, rate: rate)
}

public func convertDash(amount: Decimal, to currency: String, rate: Decimal) throws -> Decimal {
if amount.isZero { return 0 }

let result = rate*amount

let formatter = NumberFormatter.fiatFormatter(currencyCode: currency)
Expand All @@ -83,22 +89,28 @@ public final class CurrencyExchanger {
if amount.isZero { return 0 }

let rate = try rate(for: currency)
return try convertToDash(amount: amount, currency: currency, rate: rate)
}

public func convertToDash(amount: Decimal, currency: String, rate: Decimal) throws -> Decimal {
if amount.isZero { return 0 }

return amount/rate
}

public func convert(to currency: String, amount: Decimal, amountCurrency: String) throws -> Decimal {
if amount.isZero { return 0 }

if amountCurrency == kDashCurrency {
let rate = try rate(for: currency)
return amount/rate
return try convertToDash(amount: amount, currency: currency)
}

let dashAmount = try convertToDash(amount: amount, currency: amountCurrency)
let result = try convertDash(amount: dashAmount, to: currency)
return result
}


static let shared = CurrencyExchanger(dataProvider: RatesProviderFactory.base)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE TABLE backup_tx_userinfo AS SELECT * FROM tx_userinfo;
ALTER TABLE tx_userinfo ADD rate INT NULL;
ALTER TABLE tx_userinfo ADD rateCurrencyCode VARCHAR(3) NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE tx_userinfo ADD rateMaximumFractionDigits INT NULL;
7 changes: 5 additions & 2 deletions DashWallet/Sources/Models/Coinbase/Coinbase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ class Coinbase {
paymentMethodsService = PaymentMethods(authInterop: auth)
currencyExchanger.startExchangeRateFetching()

// Pre-fetch data
prefetchData()
}

private func prefetchData() {
Task {
try await accountService.refreshAccount(kDashAccount)
try await paymentMethodsService.fetchPaymentMethods()
_ = try await paymentMethodsService.fetchPaymentMethods()
}
}

Expand Down
Loading

0 comments on commit 6be4d19

Please sign in to comment.