Merge branch 'CW-438-add-nano' of https://github.com/cake-tech/cake_wallet into CW-459-12-words-btc

This commit is contained in:
fosse 2023-08-21 11:03:28 -04:00
commit d2c50afe8f
7 changed files with 64 additions and 32 deletions

View file

@ -28,7 +28,6 @@ import 'dart:async';
import 'package:cw_nano/nano_wallet_addresses.dart';
import 'package:cw_core/wallet_base.dart';
import 'package:nanodart/nanodart.dart';
import 'package:web3dart/web3dart.dart';
import 'package:bip39/bip39.dart' as bip39;
part 'nano_wallet.g.dart';
@ -364,7 +363,11 @@ abstract class NanoWalletBase
}
Future<void> _updateBalance() async {
balance[currency] = await _client.getBalance(_publicAddress!);
try {
balance[currency] = await _client.getBalance(_publicAddress!);
} catch (e) {
throw Exception("Failed to get balance $e");
}
await save();
}
@ -410,10 +413,6 @@ abstract class NanoWalletBase
Future<void>? updateBalance() async => await _updateBalance();
void _onNewTransaction(FilterEvent event) {
throw UnimplementedError();
}
@override
Future<void> renameWalletFiles(String newWalletName) async {
final currentWalletPath = await pathForWallet(name: walletInfo.name, type: type);

View file

@ -182,6 +182,8 @@ class AnonPayApi {
switch (currency) {
case CryptoCurrency.usdt:
return CryptoCurrency.btc.title.toLowerCase();
case CryptoCurrency.eth:
return 'ERC20';
default:
return currency.tag != null ? _normalizeTag(currency.tag!) : 'Mainnet';
}

View file

@ -22,6 +22,8 @@ class OnRamperBuyProvider {
return "LTC_LITECOIN";
case CryptoCurrency.xmr:
return "XMR_MONERO";
case CryptoCurrency.nano:
return "XNO_NANO";
default:
return _wallet.currency.title;
}

View file

@ -154,6 +154,7 @@ class AnonPayInvoicePage extends BasePage {
? S.of(context).create_invoice
: S.of(context).create_donation_link,
onPressed: () {
FocusScope.of(context).unfocus();
anonInvoicePageViewModel.setRequestParams(
inputAmount: _amountController.text,
inputName: _nameController.text,

View file

@ -1,6 +1,7 @@
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:cake_wallet/view_model/wallet_restore_choose_derivation_view_model.dart';
import 'package:cw_core/wallet_info.dart';
@ -62,10 +63,11 @@ class WalletRestoreChooseDerivationPage extends BasePage {
title: Center(
child: Text(
"${derivation.derivationType.toString().split('.').last}",
style: Theme.of(context)
.primaryTextTheme
.labelMedium!
.copyWith(fontSize: 18),
style: Theme.of(context).primaryTextTheme.labelMedium!.copyWith(
fontSize: 18,
fontWeight: FontWeight.w800,
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
),
),
),
subtitle: Column(
@ -73,24 +75,33 @@ class WalletRestoreChooseDerivationPage extends BasePage {
children: [
Text(
derivation.address,
style: Theme.of(context)
.primaryTextTheme
.labelMedium!
.copyWith(fontSize: 16),
style: Theme.of(context).primaryTextTheme.labelMedium!.copyWith(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.extension<CakeTextTheme>()!
.secondaryTextColor,
),
),
Text(
"${S.current.confirmed}: ${derivation.balance}",
style: Theme.of(context)
.primaryTextTheme
.labelMedium!
.copyWith(fontSize: 16),
style: Theme.of(context).primaryTextTheme.labelMedium!.copyWith(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.extension<CakeTextTheme>()!
.secondaryTextColor,
),
),
Text(
"${S.current.transactions}: ${derivation.height}",
style: Theme.of(context)
.primaryTextTheme
.labelMedium!
.copyWith(fontSize: 16),
style: Theme.of(context).primaryTextTheme.labelMedium!.copyWith(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.extension<CakeTextTheme>()!
.secondaryTextColor,
),
),
],
),

View file

@ -47,6 +47,9 @@ abstract class TransactionDetailsViewModelBase with Store {
case WalletType.ethereum:
_addEthereumListItems(tx, dateFormat);
break;
case WalletType.nano:
_addNanoListItems(tx, dateFormat);
break;
default:
break;
}
@ -227,4 +230,18 @@ abstract class TransactionDetailsViewModelBase with Store {
items.addAll(_items);
}
void _addNanoListItems(TransactionInfo tx, DateFormat dateFormat) {
final _items = [
StandartListItem(title: S.current.transaction_details_transaction_id, value: tx.id),
StandartListItem(
title: S.current.transaction_details_date, value: dateFormat.format(tx.date)),
// StandartListItem(title: S.current.confirmed, value: (tx.confirmations > 0).toString()),
StandartListItem(title: S.current.transaction_details_height, value: '${tx.height}'),
StandartListItem(title: S.current.transaction_details_amount, value: tx.amountFormatted()),
];
items.addAll(_items);
}
}

View file

@ -716,12 +716,6 @@ Future<void> generatePubspec({
output += '\n$cwBitcoin';
}
if (hasHaven && !hasMonero) {
output += '\n$cwSharedExternal\n$cwHaven';
} else if (hasHaven) {
output += '\n$cwHaven';
}
if (hasEthereum) {
output += '\n$cwEthereum';
}
@ -734,6 +728,12 @@ Future<void> generatePubspec({
output += '\n$cwBanano';
}
if (hasHaven && !hasMonero) {
output += '\n$cwSharedExternal\n$cwHaven';
} else if (hasHaven) {
output += '\n$cwHaven';
}
final outputLines = output.split('\n');
inputLines.insertAll(dependenciesIndex + 1, outputLines);
final outputContent = inputLines.join('\n');
@ -780,10 +780,6 @@ Future<void> generateWalletTypes({
outputContent += '\tWalletType.litecoin,\n';
}
if (hasHaven) {
outputContent += '\tWalletType.haven,\n';
}
if (hasNano) {
outputContent += '\tWalletType.nano,\n';
}
@ -792,6 +788,10 @@ Future<void> generateWalletTypes({
outputContent += '\tWalletType.banano,\n';
}
if (hasHaven) {
outputContent += '\tWalletType.haven,\n';
}
outputContent += '];\n';
await walletTypesFile.writeAsString(outputContent);
}