mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 01:37:40 +00:00
Fixes for haven dependencies
This commit is contained in:
parent
a4feab8e3d
commit
3e43ef9a0e
4 changed files with 34 additions and 15 deletions
|
@ -1,15 +1,15 @@
|
|||
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/monero_amount_format.dart';
|
||||
import 'package:cw_haven/api/balance_list.dart';
|
||||
import 'package:cake_wallet/haven/haven.dart';
|
||||
|
||||
Future<void> updateHavenRate(FiatConversionStore fiatConversionStore) async {
|
||||
final rate = getRate();
|
||||
final base = rate.firstWhere((row) => row.getAssetType() == 'XUSD', orElse: () => null);
|
||||
final rate = haven.getAssetRate();
|
||||
final base = rate.firstWhere((row) => row.asset == 'XUSD', orElse: () => null);
|
||||
rate.forEach((row) {
|
||||
final cur = CryptoCurrency.fromString(row.getAssetType());
|
||||
final baseRate = moneroAmountToDouble(amount: base.getRate());
|
||||
final rowRate = moneroAmountToDouble(amount: row.getRate());
|
||||
final cur = CryptoCurrency.fromString(row.asset);
|
||||
final baseRate = moneroAmountToDouble(amount: base.rate);
|
||||
final rowRate = moneroAmountToDouble(amount: row.rate);
|
||||
|
||||
if (cur == CryptoCurrency.xusd) {
|
||||
fiatConversionStore.prices[cur] = 1.0;
|
||||
|
|
|
@ -295,4 +295,15 @@ class CWHaven extends Haven {
|
|||
final havenWallet = wallet as HavenWallet;
|
||||
return havenWallet.getTransactionAddress(accountIndex, addressIndex);
|
||||
}
|
||||
|
||||
CryptoCurrency assetOfTransaction(TransactionInfo tx) {
|
||||
final tx = transaction as HavenTransactionInfo;
|
||||
final asset = CryptoCurrency.fromString(tx.assetType);
|
||||
return asset;
|
||||
}
|
||||
|
||||
List<AssetRate> getAssetRate()
|
||||
=> getRate()
|
||||
.map((HavenRate rate) => AssetRate(rate.getAssetType(), rate.getRate()))
|
||||
.toList();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/transaction_info.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/utils/mobx.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
|
||||
import 'package:cake_wallet/monero/monero.dart';
|
||||
import 'package:cake_wallet/haven/haven.dart';
|
||||
|
@ -12,7 +10,6 @@ import 'package:cake_wallet/entities/calculate_fiat_amount_raw.dart';
|
|||
import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
|
||||
import 'package:cw_core/keyable.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cw_haven/haven_transaction_info.dart';
|
||||
|
||||
class TransactionListItem extends ActionListItem with Keyable {
|
||||
TransactionListItem(
|
||||
|
@ -53,8 +50,7 @@ class TransactionListItem extends ActionListItem with Keyable {
|
|||
price: price);
|
||||
break;
|
||||
case WalletType.haven:
|
||||
final tx = transaction as HavenTransactionInfo;
|
||||
final asset = CryptoCurrency.fromString(tx.assetType);
|
||||
final asset = haven.assetOfTransaction(transaction);
|
||||
final price = balanceViewModel.fiatConvertationStore.prices[asset];
|
||||
amount = calculateFiatAmountRaw(
|
||||
cryptoAmount: haven.formatterMoneroAmountToDouble(amount: transaction.amount),
|
||||
|
|
|
@ -275,7 +275,8 @@ abstract class MoneroAccountList {
|
|||
}
|
||||
|
||||
Future<void> generateHaven(bool hasImplementation) async {
|
||||
final outputFile = File(moneroOutputPath);
|
||||
|
||||
final outputFile = File(havenOutputPath);
|
||||
const havenCommonHeaders = """
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
@ -288,7 +289,8 @@ import 'package:cw_core/balance.dart';
|
|||
import 'package:cw_core/output_info.dart';
|
||||
import 'package:cake_wallet/view_model/send/output.dart';
|
||||
import 'package:cw_core/wallet_service.dart';
|
||||
import 'package:hive/hive.dart';""";
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';""";
|
||||
const havenCWHeaders = """
|
||||
import 'package:cw_core/get_height_by_date.dart';
|
||||
import 'package:cw_core/monero_amount_format.dart';
|
||||
|
@ -310,6 +312,7 @@ import 'package:cw_haven/mnemonics/portuguese.dart';
|
|||
import 'package:cw_haven/mnemonics/french.dart';
|
||||
import 'package:cw_haven/mnemonics/italian.dart';
|
||||
import 'package:cw_haven/haven_transaction_creation_credentials.dart';
|
||||
import 'package:cw_haven/api/balance_list.dart';
|
||||
""";
|
||||
const havenCwPart = "part 'cw_haven.dart';";
|
||||
const havenContent = """
|
||||
|
@ -354,6 +357,13 @@ class HavenBalance extends Balance {
|
|||
String get formattedAdditionalBalance => formattedFullBalance;
|
||||
}
|
||||
|
||||
class AssetRate {
|
||||
final String asset;
|
||||
final int rate;
|
||||
|
||||
AssetRate(this.asset, this.rate);
|
||||
}
|
||||
|
||||
abstract class HavenWalletDetails {
|
||||
@observable
|
||||
Account account;
|
||||
|
@ -399,6 +409,8 @@ abstract class Haven {
|
|||
void onStartup();
|
||||
int getTransactionInfoAccountId(TransactionInfo tx);
|
||||
WalletService createHavenWalletService(Box<WalletInfo> walletInfoSource);
|
||||
CryptoCurrency assetOfTransaction(TransactionInfo tx);
|
||||
List<AssetRate> getAssetRate();
|
||||
}
|
||||
|
||||
abstract class MoneroSubaddressList {
|
||||
|
@ -421,8 +433,8 @@ abstract class HavenAccountList {
|
|||
}
|
||||
""";
|
||||
|
||||
const havenEmptyDefinition = 'Monero monero;\n';
|
||||
const havenCWDefinition = 'Monero monero = CWMonero();\n';
|
||||
const havenEmptyDefinition = 'Haven haven;\n';
|
||||
const havenCWDefinition = 'Haven haven = CWHaven();\n';
|
||||
|
||||
final output = '$havenCommonHeaders\n'
|
||||
+ (hasImplementation ? '$havenCWHeaders\n' : '\n')
|
||||
|
|
Loading…
Reference in a new issue