mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-25 12:06:05 +00:00
Fixes for Haven
This commit is contained in:
parent
4fed6fd145
commit
27bdf51101
19 changed files with 131 additions and 59 deletions
|
@ -23,7 +23,8 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
|
|||
CryptoCurrency.usdt,
|
||||
CryptoCurrency.usdterc20,
|
||||
CryptoCurrency.xlm,
|
||||
CryptoCurrency.xrp
|
||||
CryptoCurrency.xrp,
|
||||
CryptoCurrency.xhv
|
||||
];
|
||||
static const xmr = CryptoCurrency(title: 'XMR', raw: 0);
|
||||
static const ada = CryptoCurrency(title: 'ADA', raw: 1);
|
||||
|
|
|
@ -98,7 +98,7 @@ CryptoCurrency walletTypeToCryptoCurrency(WalletType type) {
|
|||
case WalletType.litecoin:
|
||||
return CryptoCurrency.ltc;
|
||||
case WalletType.haven:
|
||||
return CryptoCurrency.xmr;
|
||||
return CryptoCurrency.xhv;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ abstract class HavenWalletBase extends WalletBase<MoneroBalance,
|
|||
walletAddresses.accountList.update();
|
||||
}
|
||||
|
||||
if (blocksLeft < 100) {
|
||||
if (blocksLeft < 1000) {
|
||||
await _askForUpdateTransactionHistory();
|
||||
_askForUpdateBalance();
|
||||
walletAddresses.accountList.update();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/haven/haven.dart';
|
||||
import 'package:cake_wallet/core/validator.dart';
|
||||
import 'package:cake_wallet/entities/mnemonic_item.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
|
@ -21,6 +22,8 @@ class SeedValidator extends Validator<MnemonicItem> {
|
|||
return getBitcoinWordList(language);
|
||||
case WalletType.monero:
|
||||
return monero.getMoneroWordList(language);
|
||||
case WalletType.haven:
|
||||
return haven.getMoneroWordList(language);
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -10,6 +10,12 @@ Future<void> updateHavenRate(FiatConversionStore fiatConversionStore) async {
|
|||
final cur = CryptoCurrency.fromString(row.getAssetType());
|
||||
final baseRate = moneroAmountToDouble(amount: base.getRate());
|
||||
final rowRate = moneroAmountToDouble(amount: row.getRate());
|
||||
|
||||
if (cur == CryptoCurrency.xusd) {
|
||||
fiatConversionStore.prices[cur] = rowRate;
|
||||
return;
|
||||
}
|
||||
|
||||
fiatConversionStore.prices[cur] = baseRate * rowRate;
|
||||
});
|
||||
}
|
|
@ -53,7 +53,7 @@ void startCurrentWalletChangeReaction(AppStore appStore,
|
|||
wallet) async {
|
||||
try {
|
||||
final node = settingsStore.getCurrentNode(wallet.type);
|
||||
startWalletSyncStatusChangeReaction(wallet);
|
||||
startWalletSyncStatusChangeReaction(wallet, fiatConversionStore);
|
||||
startCheckConnectionReaction(wallet, settingsStore);
|
||||
await getIt
|
||||
.get<SharedPreferences>()
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/entities/update_haven_rate.dart';
|
||||
import 'package:cake_wallet/entities/wake_lock.dart';
|
||||
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cw_core/transaction_history.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
|
@ -12,14 +15,18 @@ ReactionDisposer _onWalletSyncStatusChangeReaction;
|
|||
|
||||
void startWalletSyncStatusChangeReaction(
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
||||
TransactionInfo>
|
||||
wallet) {
|
||||
TransactionInfo> wallet,
|
||||
FiatConversionStore fiatConversionStore) {
|
||||
final _wakeLock = getIt.get<WakeLock>();
|
||||
_onWalletSyncStatusChangeReaction?.reaction?.dispose();
|
||||
_onWalletSyncStatusChangeReaction =
|
||||
reaction((_) => wallet.syncStatus, (SyncStatus status) async {
|
||||
if (status is ConnectedSyncStatus) {
|
||||
await wallet.startSync();
|
||||
|
||||
if (wallet.type == WalletType.haven) {
|
||||
await updateHavenRate(fiatConversionStore);
|
||||
}
|
||||
}
|
||||
if (status is SyncingSyncStatus) {
|
||||
await _wakeLock.enableWake();
|
||||
|
|
|
@ -224,6 +224,9 @@ class ContactListPage extends BasePage {
|
|||
case CryptoCurrency.xrp:
|
||||
image = Image.asset('assets/images/xrp.png', height: 24, width: 24);
|
||||
break;
|
||||
case CryptoCurrency.xhv:
|
||||
image = Image.asset('assets/images/haven_logo.png', height: 24, width: 24);
|
||||
break;
|
||||
default:
|
||||
image = null;
|
||||
}
|
||||
|
|
|
@ -146,13 +146,13 @@ class DashboardPage extends BasePage {
|
|||
image: exchangeImage,
|
||||
title: S.of(context).exchange,
|
||||
route: Routes.exchange),
|
||||
if (!isMoneroOnly)
|
||||
if (!isMoneroOnly && !isHaven)
|
||||
ActionButton(
|
||||
image: buyImage,
|
||||
title: S.of(context).buy,
|
||||
onClick: () async => await _onClickBuyButton(context),
|
||||
),
|
||||
if (!isMoneroOnly)
|
||||
if (!isMoneroOnly && !isHaven)
|
||||
ActionButton(
|
||||
image: sellImage,
|
||||
title: S.of(context).sell,
|
||||
|
|
|
@ -130,7 +130,8 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
|
|||
BlockchainHeightWidget(
|
||||
focusNode: widget.blockHeightFocusNode,
|
||||
key: blockchainHeightKey,
|
||||
onHeightOrDateEntered: widget.onHeightOrDateEntered)
|
||||
onHeightOrDateEntered: widget.onHeightOrDateEntered,
|
||||
hasDatePicker: widget.type == WalletType.monero)
|
||||
]));
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ class WalletRestorePage extends BasePage {
|
|||
.text
|
||||
.split(' ');
|
||||
|
||||
if (walletRestoreViewModel.type == WalletType.monero &&
|
||||
if ((walletRestoreViewModel.type == WalletType.monero || walletRestoreViewModel.type == WalletType.haven) &&
|
||||
seedWords.length != WalletRestoreViewModelBase.moneroSeedMnemonicLength) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ class SendPage extends BasePage {
|
|||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () => presentCurrencyPicker(context),
|
||||
text: 'Change currency (${sendViewModel.selectedCryptoCurrency})',
|
||||
text: 'Change your asset (${sendViewModel.selectedCryptoCurrency})',
|
||||
color: Colors.transparent,
|
||||
textColor: Theme.of(context)
|
||||
.accentTextTheme
|
||||
|
|
|
@ -391,7 +391,7 @@ class SendCardState extends State<SendCard>
|
|||
.toString() +
|
||||
' ' +
|
||||
sendViewModel
|
||||
.currency.title,
|
||||
.selectedCryptoCurrency.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight:
|
||||
|
|
|
@ -7,12 +7,13 @@ import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
|||
|
||||
class BlockchainHeightWidget extends StatefulWidget {
|
||||
BlockchainHeightWidget({GlobalKey key, this.onHeightChange, this.focusNode,
|
||||
this.onHeightOrDateEntered})
|
||||
this.onHeightOrDateEntered, this.hasDatePicker})
|
||||
: super(key: key);
|
||||
|
||||
final Function(int) onHeightChange;
|
||||
final Function(bool) onHeightOrDateEntered;
|
||||
final FocusNode focusNode;
|
||||
final bool hasDatePicker;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => BlockchainHeightState();
|
||||
|
@ -67,43 +68,45 @@ class BlockchainHeightState extends State<BlockchainHeightWidget> {
|
|||
)))
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 15, bottom: 15),
|
||||
child: Text(
|
||||
S.of(context).widgets_or,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).primaryTextTheme.title.color),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: Container(
|
||||
child: InkWell(
|
||||
onTap: () => _selectDate(context),
|
||||
child: IgnorePointer(
|
||||
child: BaseTextFormField(
|
||||
controller: dateController,
|
||||
hintText: S.of(context).widgets_restore_from_date,
|
||||
)),
|
||||
),
|
||||
))
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 40, right: 40, top: 24),
|
||||
child: Text(
|
||||
S.of(context).restore_from_date_or_blockheight,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Theme.of(context).hintColor
|
||||
if (widget.hasDatePicker) ...[
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 15, bottom: 15),
|
||||
child: Text(
|
||||
S.of(context).widgets_or,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).primaryTextTheme.title.color),
|
||||
),
|
||||
),
|
||||
)
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: Container(
|
||||
child: InkWell(
|
||||
onTap: () => _selectDate(context),
|
||||
child: IgnorePointer(
|
||||
child: BaseTextFormField(
|
||||
controller: dateController,
|
||||
hintText: S.of(context).widgets_restore_from_date,
|
||||
)),
|
||||
),
|
||||
))
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 40, right: 40, top: 24),
|
||||
child: Text(
|
||||
S.of(context).restore_from_date_or_blockheight,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Theme.of(context).hintColor
|
||||
),
|
||||
),
|
||||
)
|
||||
]
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,8 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
|||
bool get isReady =>
|
||||
(address?.isNotEmpty ?? false) && (port?.isNotEmpty ?? false);
|
||||
|
||||
bool get hasAuthCredentials => _wallet.type == WalletType.monero;
|
||||
bool get hasAuthCredentials => _wallet.type == WalletType.monero ||
|
||||
_wallet.type == WalletType.haven;
|
||||
|
||||
String get uri {
|
||||
var uri = address;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:cake_wallet/entities/calculate_fiat_amount_raw.dart';
|
||||
import 'package:cake_wallet/entities/parse_address_from_domain.dart';
|
||||
import 'package:cake_wallet/entities/parsed_address.dart';
|
||||
import 'package:cake_wallet/haven/haven.dart';
|
||||
import 'package:cake_wallet/src/screens/send/widgets/extract_address_from_parsed.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -77,6 +78,9 @@ abstract class OutputBase with Store {
|
|||
_amount =
|
||||
bitcoin.formatterStringDoubleToBitcoinAmount(_cryptoAmount);
|
||||
break;
|
||||
case WalletType.haven:
|
||||
_amount = haven.formatterMoneroParseAmount(amount: _cryptoAmount);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -106,6 +110,10 @@ abstract class OutputBase with Store {
|
|||
if (_wallet.type == WalletType.monero) {
|
||||
return monero.formatterMoneroAmountToDouble(amount: fee);
|
||||
}
|
||||
|
||||
if (_wallet.type == WalletType.haven) {
|
||||
return haven.formatterMoneroAmountToDouble(amount: fee);
|
||||
}
|
||||
} catch (e) {
|
||||
print(e.toString());
|
||||
}
|
||||
|
@ -208,6 +216,9 @@ abstract class OutputBase with Store {
|
|||
case WalletType.litecoin:
|
||||
maximumFractionDigits = 8;
|
||||
break;
|
||||
case WalletType.haven:
|
||||
maximumFractionDigits = 12;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import 'package:cake_wallet/store/settings_store.dart';
|
|||
import 'package:cake_wallet/view_model/send/send_view_model_state.dart';
|
||||
import 'package:cake_wallet/entities/parsed_address.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/haven/haven.dart';
|
||||
|
||||
part 'send_view_model.g.dart';
|
||||
|
||||
|
@ -225,6 +226,11 @@ abstract class SendViewModelBase with Store {
|
|||
|
||||
return monero.createMoneroTransactionCreationCredentials(
|
||||
outputs: outputs, priority: priority);
|
||||
case WalletType.haven:
|
||||
final priority = _settingsStore.priority[_wallet.type];
|
||||
|
||||
return haven.createHavenTransactionCreationCredentials(
|
||||
outputs: outputs, priority: priority);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:cw_core/wallet_base.dart';
|
|||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart';
|
||||
import 'package:cake_wallet/monero/monero.dart';
|
||||
import 'package:cake_wallet/haven/haven.dart';
|
||||
|
||||
part 'wallet_keys_view_model.g.dart';
|
||||
|
||||
|
@ -29,6 +30,22 @@ abstract class WalletKeysViewModelBase with Store {
|
|||
]);
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.haven) {
|
||||
final keys = haven.getKeys(wallet);
|
||||
|
||||
items.addAll([
|
||||
StandartListItem(
|
||||
title: S.current.spend_key_public, value: keys['publicSpendKey']),
|
||||
StandartListItem(
|
||||
title: S.current.spend_key_private, value: keys['privateSpendKey']),
|
||||
StandartListItem(
|
||||
title: S.current.view_key_public, value: keys['publicViewKey']),
|
||||
StandartListItem(
|
||||
title: S.current.view_key_private, value: keys['privateViewKey']),
|
||||
StandartListItem(title: S.current.wallet_seed, value: wallet.seed),
|
||||
]);
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.bitcoin || wallet.type == WalletType.litecoin) {
|
||||
final keys = bitcoin.getWalletKeys(wallet);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
|||
case WalletType.monero:
|
||||
return monero.createMoneroRestoreWalletFromSeedCredentials(
|
||||
name: name,
|
||||
height: height,
|
||||
height: height ?? 0,
|
||||
mnemonic: seed,
|
||||
password: password);
|
||||
case WalletType.bitcoin:
|
||||
|
@ -81,7 +81,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
|||
case WalletType.haven:
|
||||
return haven.createHavenRestoreWalletFromSeedCredentials(
|
||||
name: name,
|
||||
height: height,
|
||||
height: height ?? 0,
|
||||
mnemonic: seed,
|
||||
password: password);
|
||||
default:
|
||||
|
@ -94,14 +94,27 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
|||
final spendKey = options['spendKey'] as String;
|
||||
final address = options['address'] as String;
|
||||
|
||||
return monero.createMoneroRestoreWalletFromKeysCredentials(
|
||||
name: name,
|
||||
height: height,
|
||||
spendKey: spendKey,
|
||||
viewKey: viewKey,
|
||||
address: address,
|
||||
password: password,
|
||||
language: 'English');
|
||||
if (type == WalletType.monero) {
|
||||
return monero.createMoneroRestoreWalletFromKeysCredentials(
|
||||
name: name,
|
||||
height: height,
|
||||
spendKey: spendKey,
|
||||
viewKey: viewKey,
|
||||
address: address,
|
||||
password: password,
|
||||
language: 'English');
|
||||
}
|
||||
|
||||
if (type == WalletType.haven) {
|
||||
return haven.createHavenRestoreWalletFromKeysCredentials(
|
||||
name: name,
|
||||
height: height,
|
||||
spendKey: spendKey,
|
||||
viewKey: viewKey,
|
||||
address: address,
|
||||
password: password,
|
||||
language: 'English');
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue