mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-21 14:48:53 +00:00
fixes
This commit is contained in:
parent
1742534994
commit
c6d937ca4e
11 changed files with 82 additions and 77 deletions
|
@ -1,14 +1,15 @@
|
||||||
const CONTACT_TYPE_ID = 0;
|
const CONTACT_TYPE_ID = 0;
|
||||||
const NODE_TYPE_ID = 1;
|
const NODE_TYPE_ID = 1;
|
||||||
const TRANSACTION_TYPE_ID = 2;
|
const TRANSACTION_TYPE_ID = 2;
|
||||||
const TRADE_TYPE_ID = 3;
|
const TRADE_TYPE_ID = 3;
|
||||||
const WALLET_INFO_TYPE_ID = 4;
|
const WALLET_INFO_TYPE_ID = 4;
|
||||||
const WALLET_TYPE_TYPE_ID = 5;
|
const WALLET_TYPE_TYPE_ID = 5;
|
||||||
const TEMPLATE_TYPE_ID = 6;
|
const TEMPLATE_TYPE_ID = 6;
|
||||||
const EXCHANGE_TEMPLATE_TYPE_ID = 7;
|
const EXCHANGE_TEMPLATE_TYPE_ID = 7;
|
||||||
const ORDER_TYPE_ID = 8;
|
const ORDER_TYPE_ID = 8;
|
||||||
const UNSPENT_COINS_INFO_TYPE_ID = 9;
|
const UNSPENT_COINS_INFO_TYPE_ID = 9;
|
||||||
const ANONPAY_INVOICE_INFO_TYPE_ID = 10;
|
const ANONPAY_INVOICE_INFO_TYPE_ID = 10;
|
||||||
const DERIVATION_TYPE_TYPE_ID = 15;
|
const DERIVATION_TYPE_TYPE_ID = 15;
|
||||||
|
|
||||||
const ERC20_TOKEN_TYPE_ID = 12;
|
const ERC20_TOKEN_TYPE_ID = 12;
|
||||||
|
const NANO_ACCOUNT_TYPE_ID = 13;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cw_core/hive_type_ids.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
|
||||||
part 'nano_account.g.dart';
|
part 'nano_account.g.dart';
|
||||||
|
@ -6,7 +7,7 @@ part 'nano_account.g.dart';
|
||||||
class NanoAccount extends HiveObject {
|
class NanoAccount extends HiveObject {
|
||||||
NanoAccount({required this.label, required this.id, this.balance, this.isSelected = false});
|
NanoAccount({required this.label, required this.id, this.balance, this.isSelected = false});
|
||||||
|
|
||||||
static const typeId = 13;
|
static const typeId = NANO_ACCOUNT_TYPE_ID;
|
||||||
|
|
||||||
@HiveField(0)
|
@HiveField(0)
|
||||||
String label;
|
String label;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cw_core/cake_hive.dart';
|
||||||
import 'package:cw_core/nano_account.dart';
|
import 'package:cw_core/nano_account.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
@ -44,21 +45,21 @@ abstract class NanoAccountListBase with Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<NanoAccount>> getAll({String? address}) async {
|
Future<List<NanoAccount>> getAll({String? address}) async {
|
||||||
final box = await Hive.openBox<NanoAccount>(address ?? this.address);
|
final box = await CakeHive.openBox<NanoAccount>(address ?? this.address);
|
||||||
|
|
||||||
// get all accounts in box:
|
// get all accounts in box:
|
||||||
return box.values.toList();
|
return box.values.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addAccount({required String label}) async {
|
Future<void> addAccount({required String label}) async {
|
||||||
final box = await Hive.openBox<NanoAccount>(address);
|
final box = await CakeHive.openBox<NanoAccount>(address);
|
||||||
final account = NanoAccount(id: box.length, label: label, balance: "0.00", isSelected: false);
|
final account = NanoAccount(id: box.length, label: label, balance: "0.00", isSelected: false);
|
||||||
await box.add(account);
|
await box.add(account);
|
||||||
await account.save();
|
await account.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setLabelAccount({required int accountIndex, required String label}) async {
|
Future<void> setLabelAccount({required int accountIndex, required String label}) async {
|
||||||
final box = await Hive.openBox<NanoAccount>(address);
|
final box = await CakeHive.openBox<NanoAccount>(address);
|
||||||
final account = box.getAt(accountIndex);
|
final account = box.getAt(accountIndex);
|
||||||
account!.label = label;
|
account!.label = label;
|
||||||
await account.save();
|
await account.save();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:cw_core/cake_hive.dart';
|
||||||
import 'package:cw_core/crypto_currency.dart';
|
import 'package:cw_core/crypto_currency.dart';
|
||||||
import 'package:cw_core/node.dart';
|
import 'package:cw_core/node.dart';
|
||||||
import 'package:cw_core/pathForWallet.dart';
|
import 'package:cw_core/pathForWallet.dart';
|
||||||
|
@ -54,8 +55,8 @@ abstract class NanoWalletBase
|
||||||
super(walletInfo) {
|
super(walletInfo) {
|
||||||
this.walletInfo = walletInfo;
|
this.walletInfo = walletInfo;
|
||||||
transactionHistory = NanoTransactionHistory(walletInfo: walletInfo, password: password);
|
transactionHistory = NanoTransactionHistory(walletInfo: walletInfo, password: password);
|
||||||
if (!Hive.isAdapterRegistered(NanoAccount.typeId)) {
|
if (!CakeHive.isAdapterRegistered(NanoAccount.typeId)) {
|
||||||
Hive.registerAdapter(NanoAccountAdapter());
|
CakeHive.registerAdapter(NanoAccountAdapter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cw_core/cake_hive.dart';
|
||||||
import 'package:cw_core/wallet_addresses.dart';
|
import 'package:cw_core/wallet_addresses.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
import 'package:cw_core/nano_account.dart';
|
import 'package:cw_core/nano_account.dart';
|
||||||
|
@ -27,7 +28,7 @@ abstract class NanoWalletAddressesBase extends WalletAddresses with Store {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
var box = await Hive.openBox<NanoAccount>(walletInfo.address);
|
var box = await CakeHive.openBox<NanoAccount>(walletInfo.address);
|
||||||
try {
|
try {
|
||||||
box.getAt(0);
|
box.getAt(0);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -851,14 +851,13 @@ Future setup({
|
||||||
(type, _) => WalletRestorePage(getIt.get<WalletRestoreViewModel>(param1: type)));
|
(type, _) => WalletRestorePage(getIt.get<WalletRestoreViewModel>(param1: type)));
|
||||||
|
|
||||||
getIt.registerFactoryParam<WalletRestoreChooseDerivationViewModel, WalletType, dynamic>(
|
getIt.registerFactoryParam<WalletRestoreChooseDerivationViewModel, WalletType, dynamic>(
|
||||||
(type, credentials) =>
|
(credentials, _) =>
|
||||||
WalletRestoreChooseDerivationViewModel(type: type, credentials: credentials));
|
WalletRestoreChooseDerivationViewModel(credentials: credentials));
|
||||||
|
|
||||||
getIt.registerFactoryParam<WalletRestoreChooseDerivationPage, WalletType, dynamic>(
|
getIt.registerFactoryParam<WalletRestoreChooseDerivationPage, WalletType, dynamic>(
|
||||||
(type, credentials) =>
|
(credentials, _) =>
|
||||||
WalletRestoreChooseDerivationPage(getIt.get<WalletRestoreChooseDerivationViewModel>(
|
WalletRestoreChooseDerivationPage(getIt.get<WalletRestoreChooseDerivationViewModel>(
|
||||||
param1: type,
|
param1: credentials,
|
||||||
param2: credentials,
|
|
||||||
)));
|
)));
|
||||||
|
|
||||||
getIt.registerFactoryParam<TransactionDetailsViewModel, TransactionInfo, void>(
|
getIt.registerFactoryParam<TransactionDetailsViewModel, TransactionInfo, void>(
|
||||||
|
|
|
@ -94,7 +94,7 @@ Future<void> initializeAppConfigs() async {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Hive.isAdapterRegistered(DERIVATION_TYPE_TYPE_ID)) {
|
if (!Hive.isAdapterRegistered(DERIVATION_TYPE_TYPE_ID)) {
|
||||||
Hive.registerAdapter(DerivationTypeAdapter());
|
CakeHive.registerAdapter(DerivationTypeAdapter());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CakeHive.isAdapterRegistered(WALLET_TYPE_TYPE_ID)) {
|
if (!CakeHive.isAdapterRegistered(WALLET_TYPE_TYPE_ID)) {
|
||||||
|
|
|
@ -201,9 +201,8 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
||||||
|
|
||||||
case Routes.restoreWalletChooseDerivation:
|
case Routes.restoreWalletChooseDerivation:
|
||||||
return MaterialPageRoute<void>(
|
return MaterialPageRoute<void>(
|
||||||
builder: (_) => getIt.get<WalletRestoreChooseDerivationPage>(
|
builder: (_) =>
|
||||||
param1: (settings.arguments as dynamic)!["walletType"] as WalletType,
|
getIt.get<WalletRestoreChooseDerivationPage>(param1: settings.arguments as dynamic));
|
||||||
param2: (settings.arguments as dynamic)!["credentials"]));
|
|
||||||
|
|
||||||
case Routes.sweepingWalletPage:
|
case Routes.sweepingWalletPage:
|
||||||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<SweepingWalletPage>());
|
return CupertinoPageRoute<void>(builder: (_) => getIt.get<SweepingWalletPage>());
|
||||||
|
@ -420,17 +419,14 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
||||||
fullscreenDialog: true, builder: (_) => getIt.get<RestoreFromBackupPage>());
|
fullscreenDialog: true, builder: (_) => getIt.get<RestoreFromBackupPage>());
|
||||||
|
|
||||||
case Routes.support:
|
case Routes.support:
|
||||||
return CupertinoPageRoute<void>(
|
return CupertinoPageRoute<void>(builder: (_) => getIt.get<SupportPage>());
|
||||||
builder: (_) => getIt.get<SupportPage>());
|
|
||||||
|
|
||||||
case Routes.supportLiveChat:
|
case Routes.supportLiveChat:
|
||||||
return CupertinoPageRoute<void>(
|
return CupertinoPageRoute<void>(builder: (_) => getIt.get<SupportChatPage>());
|
||||||
builder: (_) => getIt.get<SupportChatPage>());
|
|
||||||
|
|
||||||
case Routes.supportOtherLinks:
|
case Routes.supportOtherLinks:
|
||||||
return CupertinoPageRoute<void>(
|
return CupertinoPageRoute<void>(
|
||||||
fullscreenDialog: true,
|
fullscreenDialog: true, builder: (_) => getIt.get<SupportOtherLinksPage>());
|
||||||
builder: (_) => getIt.get<SupportOtherLinksPage>());
|
|
||||||
|
|
||||||
case Routes.unspentCoinsList:
|
case Routes.unspentCoinsList:
|
||||||
return MaterialPageRoute<void>(builder: (_) => getIt.get<UnspentCoinsListPage>());
|
return MaterialPageRoute<void>(builder: (_) => getIt.get<UnspentCoinsListPage>());
|
||||||
|
|
|
@ -45,46 +45,51 @@ class WalletRestoreChooseDerivationPage extends BasePage {
|
||||||
itemCount: snapshot.data!.length,
|
itemCount: snapshot.data!.length,
|
||||||
itemBuilder: (__, index) {
|
itemBuilder: (__, index) {
|
||||||
final derivation = snapshot.data![index];
|
final derivation = snapshot.data![index];
|
||||||
return Container(
|
return InkWell(
|
||||||
margin: const EdgeInsets.only(left: 16, right: 16),
|
onTap: () async {
|
||||||
decoration: BoxDecoration(
|
Navigator.pop(context, derivation.derivationType);
|
||||||
borderRadius: BorderRadius.circular(30.0),
|
},
|
||||||
border: Border.all(
|
|
||||||
color: getIt.get<SettingsStore>().currentTheme.type == ThemeType.bright
|
|
||||||
? Color.fromRGBO(255, 255, 255, 0.2)
|
|
||||||
: Colors.transparent,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
color: Theme.of(context).textTheme.titleLarge!.backgroundColor!,
|
|
||||||
),
|
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: const EdgeInsets.only(top: 16, left: 24, right: 24, bottom: 24),
|
margin: const EdgeInsets.only(left: 16, right: 16),
|
||||||
child: Column(
|
decoration: BoxDecoration(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
borderRadius: BorderRadius.circular(30.0),
|
||||||
children: [
|
border: Border.all(
|
||||||
Text(
|
color: getIt.get<SettingsStore>().currentTheme.type == ThemeType.bright
|
||||||
derivation.address,
|
? Color.fromRGBO(255, 255, 255, 0.2)
|
||||||
style: TextStyle(
|
: Colors.transparent,
|
||||||
fontSize: 16,
|
width: 1,
|
||||||
fontFamily: 'Lato',
|
),
|
||||||
fontWeight: FontWeight.w400,
|
color: Theme.of(context).textTheme.titleLarge!.backgroundColor!,
|
||||||
color:
|
),
|
||||||
Theme.of(context).accentTextTheme.displayMedium!.backgroundColor!,
|
child: Container(
|
||||||
height: 1,
|
margin: const EdgeInsets.only(top: 16, left: 24, right: 24, bottom: 24),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
derivation.address,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontFamily: 'Lato',
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color:
|
||||||
|
Theme.of(context).accentTextTheme.displayMedium!.backgroundColor!,
|
||||||
|
height: 1,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
Text(
|
"${S.current.confirmed}: ${derivation.balance}",
|
||||||
"${S.current.confirmed}: ${derivation.balance}",
|
style: TextStyle(
|
||||||
style: TextStyle(
|
fontSize: 18,
|
||||||
fontSize: 18,
|
fontFamily: 'Lato',
|
||||||
fontFamily: 'Lato',
|
fontWeight: FontWeight.w400,
|
||||||
fontWeight: FontWeight.w400,
|
color:
|
||||||
color:
|
Theme.of(context).accentTextTheme.displayMedium!.backgroundColor!,
|
||||||
Theme.of(context).accentTextTheme.displayMedium!.backgroundColor!,
|
height: 2,
|
||||||
height: 2,
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'package:cake_wallet/di.dart';
|
||||||
|
import 'package:cake_wallet/store/app_store.dart';
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
import 'package:cw_nano/nano_balance.dart';
|
import 'package:cw_nano/nano_balance.dart';
|
||||||
import 'package:cw_nano/nano_util.dart';
|
import 'package:cw_nano/nano_util.dart';
|
||||||
|
@ -21,20 +23,19 @@ class Derivation {
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class WalletRestoreChooseDerivationViewModelBase with Store {
|
abstract class WalletRestoreChooseDerivationViewModelBase with Store {
|
||||||
WalletRestoreChooseDerivationViewModelBase({required this.credentials, required this.type})
|
WalletRestoreChooseDerivationViewModelBase({required this.credentials})
|
||||||
: mode = WalletRestoreMode.seed {}
|
: mode = WalletRestoreMode.seed {}
|
||||||
|
|
||||||
WalletType type;
|
|
||||||
dynamic credentials;
|
dynamic credentials;
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
WalletRestoreMode mode;
|
WalletRestoreMode mode;
|
||||||
|
|
||||||
@observable
|
|
||||||
Future<List<Derivation>> get derivations async {
|
Future<List<Derivation>> get derivations async {
|
||||||
var list = <Derivation>[];
|
var list = <Derivation>[];
|
||||||
|
|
||||||
switch (type) {
|
switch (getIt.get<AppStore>().wallet!.type) {
|
||||||
case WalletType.nano:
|
case WalletType.nano:
|
||||||
var seed = credentials['seed'] as String;
|
var seed = credentials['seed'] as String;
|
||||||
var bip39Info =
|
var bip39Info =
|
||||||
|
|
|
@ -587,7 +587,6 @@ import 'package:cake_wallet/view_model/send/output.dart';
|
||||||
import 'package:cw_core/account.dart';
|
import 'package:cw_core/account.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:cw_core/wallet_credentials.dart';
|
import 'package:cw_core/wallet_credentials.dart';
|
||||||
import 'package:cw_nano/nano_wallet_info.dart';
|
|
||||||
import 'package:cw_core/wallet_info.dart';
|
import 'package:cw_core/wallet_info.dart';
|
||||||
import 'package:cw_core/transaction_history.dart';
|
import 'package:cw_core/transaction_history.dart';
|
||||||
import 'package:cw_core/wallet_service.dart';
|
import 'package:cw_core/wallet_service.dart';
|
||||||
|
|
Loading…
Reference in a new issue