Skip to content

fix: [#266] add null checking and default value based on iOS since getCurrency can produce null #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/src/main/java/com/breadwallet/tools/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,17 @@ else if (name == PartnerNames.PUSHERSTAGING) {
/// Description: 1715876807
public static long tieredOpsFee(Context app, long sendAmount) {

/**
* current solution, add default rate based on iOS: https://github.com/litecoin-foundation/litewallet-ios/blob/9ef6ba8f9cf8ef57f3c6056c31304c6197cafa7a/litewallet/Constants/Functions.swift#L44
* and add null checking after `CurrencyDataSource.getInstance(app).getCurrencyByIso(usIso);`
*/
double doubleRate = 83.000;
double sendAmountDouble = new Double(String.valueOf(sendAmount));
String usIso = Currency.getInstance(new Locale("en", "US")).getCurrencyCode();
CurrencyEntity currency = CurrencyDataSource.getInstance(app).getCurrencyByIso(usIso);
double doubleRate = currency.rate;
if (currency != null) {
doubleRate = currency.rate;
}
double usdInLTC = sendAmountDouble * doubleRate / 100_000_000.0;
usdInLTC = Math.floor(usdInLTC * 100) / 100;

Expand Down