mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-11 05:14:46 +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 NODE_TYPE_ID = 1;
|
||||
const TRANSACTION_TYPE_ID = 2;
|
||||
const TRADE_TYPE_ID = 3;
|
||||
const WALLET_INFO_TYPE_ID = 4;
|
||||
const WALLET_TYPE_TYPE_ID = 5;
|
||||
const TEMPLATE_TYPE_ID = 6;
|
||||
const EXCHANGE_TEMPLATE_TYPE_ID = 7;
|
||||
const ORDER_TYPE_ID = 8;
|
||||
const UNSPENT_COINS_INFO_TYPE_ID = 9;
|
||||
const ANONPAY_INVOICE_INFO_TYPE_ID = 10;
|
||||
const DERIVATION_TYPE_TYPE_ID = 15;
|
||||
const CONTACT_TYPE_ID = 0;
|
||||
const NODE_TYPE_ID = 1;
|
||||
const TRANSACTION_TYPE_ID = 2;
|
||||
const TRADE_TYPE_ID = 3;
|
||||
const WALLET_INFO_TYPE_ID = 4;
|
||||
const WALLET_TYPE_TYPE_ID = 5;
|
||||
const TEMPLATE_TYPE_ID = 6;
|
||||
const EXCHANGE_TEMPLATE_TYPE_ID = 7;
|
||||
const ORDER_TYPE_ID = 8;
|
||||
const UNSPENT_COINS_INFO_TYPE_ID = 9;
|
||||
const ANONPAY_INVOICE_INFO_TYPE_ID = 10;
|
||||
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';
|
||||
|
||||
part 'nano_account.g.dart';
|
||||
|
@ -6,7 +7,7 @@ part 'nano_account.g.dart';
|
|||
class NanoAccount extends HiveObject {
|
||||
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)
|
||||
String label;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cw_core/cake_hive.dart';
|
||||
import 'package:cw_core/nano_account.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
@ -44,21 +45,21 @@ abstract class NanoAccountListBase with Store {
|
|||
}
|
||||
|
||||
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:
|
||||
return box.values.toList();
|
||||
}
|
||||
|
||||
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);
|
||||
await box.add(account);
|
||||
await account.save();
|
||||
}
|
||||
|
||||
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);
|
||||
account!.label = label;
|
||||
await account.save();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cw_core/cake_hive.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/node.dart';
|
||||
import 'package:cw_core/pathForWallet.dart';
|
||||
|
@ -54,8 +55,8 @@ abstract class NanoWalletBase
|
|||
super(walletInfo) {
|
||||
this.walletInfo = walletInfo;
|
||||
transactionHistory = NanoTransactionHistory(walletInfo: walletInfo, password: password);
|
||||
if (!Hive.isAdapterRegistered(NanoAccount.typeId)) {
|
||||
Hive.registerAdapter(NanoAccountAdapter());
|
||||
if (!CakeHive.isAdapterRegistered(NanoAccount.typeId)) {
|
||||
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_info.dart';
|
||||
import 'package:cw_core/nano_account.dart';
|
||||
|
@ -27,7 +28,7 @@ abstract class NanoWalletAddressesBase extends WalletAddresses with Store {
|
|||
|
||||
@override
|
||||
Future<void> init() async {
|
||||
var box = await Hive.openBox<NanoAccount>(walletInfo.address);
|
||||
var box = await CakeHive.openBox<NanoAccount>(walletInfo.address);
|
||||
try {
|
||||
box.getAt(0);
|
||||
} catch (e) {
|
||||
|
|
|
@ -851,14 +851,13 @@ Future setup({
|
|||
(type, _) => WalletRestorePage(getIt.get<WalletRestoreViewModel>(param1: type)));
|
||||
|
||||
getIt.registerFactoryParam<WalletRestoreChooseDerivationViewModel, WalletType, dynamic>(
|
||||
(type, credentials) =>
|
||||
WalletRestoreChooseDerivationViewModel(type: type, credentials: credentials));
|
||||
(credentials, _) =>
|
||||
WalletRestoreChooseDerivationViewModel(credentials: credentials));
|
||||
|
||||
getIt.registerFactoryParam<WalletRestoreChooseDerivationPage, WalletType, dynamic>(
|
||||
(type, credentials) =>
|
||||
(credentials, _) =>
|
||||
WalletRestoreChooseDerivationPage(getIt.get<WalletRestoreChooseDerivationViewModel>(
|
||||
param1: type,
|
||||
param2: credentials,
|
||||
param1: credentials,
|
||||
)));
|
||||
|
||||
getIt.registerFactoryParam<TransactionDetailsViewModel, TransactionInfo, void>(
|
||||
|
|
|
@ -94,7 +94,7 @@ Future<void> initializeAppConfigs() async {
|
|||
}
|
||||
|
||||
if (!Hive.isAdapterRegistered(DERIVATION_TYPE_TYPE_ID)) {
|
||||
Hive.registerAdapter(DerivationTypeAdapter());
|
||||
CakeHive.registerAdapter(DerivationTypeAdapter());
|
||||
}
|
||||
|
||||
if (!CakeHive.isAdapterRegistered(WALLET_TYPE_TYPE_ID)) {
|
||||
|
|
|
@ -201,9 +201,8 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
|
||||
case Routes.restoreWalletChooseDerivation:
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (_) => getIt.get<WalletRestoreChooseDerivationPage>(
|
||||
param1: (settings.arguments as dynamic)!["walletType"] as WalletType,
|
||||
param2: (settings.arguments as dynamic)!["credentials"]));
|
||||
builder: (_) =>
|
||||
getIt.get<WalletRestoreChooseDerivationPage>(param1: settings.arguments as dynamic));
|
||||
|
||||
case Routes.sweepingWalletPage:
|
||||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<SweepingWalletPage>());
|
||||
|
@ -420,17 +419,14 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
fullscreenDialog: true, builder: (_) => getIt.get<RestoreFromBackupPage>());
|
||||
|
||||
case Routes.support:
|
||||
return CupertinoPageRoute<void>(
|
||||
builder: (_) => getIt.get<SupportPage>());
|
||||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<SupportPage>());
|
||||
|
||||
case Routes.supportLiveChat:
|
||||
return CupertinoPageRoute<void>(
|
||||
builder: (_) => getIt.get<SupportChatPage>());
|
||||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<SupportChatPage>());
|
||||
|
||||
case Routes.supportOtherLinks:
|
||||
return CupertinoPageRoute<void>(
|
||||
fullscreenDialog: true,
|
||||
builder: (_) => getIt.get<SupportOtherLinksPage>());
|
||||
fullscreenDialog: true, builder: (_) => getIt.get<SupportOtherLinksPage>());
|
||||
|
||||
case Routes.unspentCoinsList:
|
||||
return MaterialPageRoute<void>(builder: (_) => getIt.get<UnspentCoinsListPage>());
|
||||
|
|
|
@ -45,46 +45,51 @@ class WalletRestoreChooseDerivationPage extends BasePage {
|
|||
itemCount: snapshot.data!.length,
|
||||
itemBuilder: (__, index) {
|
||||
final derivation = snapshot.data![index];
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(left: 16, right: 16),
|
||||
decoration: BoxDecoration(
|
||||
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!,
|
||||
),
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
Navigator.pop(context, derivation.derivationType);
|
||||
},
|
||||
child: Container(
|
||||
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,
|
||||
margin: const EdgeInsets.only(left: 16, right: 16),
|
||||
decoration: BoxDecoration(
|
||||
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(
|
||||
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(
|
||||
"${S.current.confirmed}: ${derivation.balance}",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.w400,
|
||||
color:
|
||||
Theme.of(context).accentTextTheme.displayMedium!.backgroundColor!,
|
||||
height: 2,
|
||||
Text(
|
||||
"${S.current.confirmed}: ${derivation.balance}",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.w400,
|
||||
color:
|
||||
Theme.of(context).accentTextTheme.displayMedium!.backgroundColor!,
|
||||
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_nano/nano_balance.dart';
|
||||
import 'package:cw_nano/nano_util.dart';
|
||||
|
@ -21,20 +23,19 @@ class Derivation {
|
|||
}
|
||||
|
||||
abstract class WalletRestoreChooseDerivationViewModelBase with Store {
|
||||
WalletRestoreChooseDerivationViewModelBase({required this.credentials, required this.type})
|
||||
WalletRestoreChooseDerivationViewModelBase({required this.credentials})
|
||||
: mode = WalletRestoreMode.seed {}
|
||||
|
||||
WalletType type;
|
||||
|
||||
dynamic credentials;
|
||||
|
||||
@observable
|
||||
WalletRestoreMode mode;
|
||||
|
||||
@observable
|
||||
Future<List<Derivation>> get derivations async {
|
||||
var list = <Derivation>[];
|
||||
|
||||
switch (type) {
|
||||
switch (getIt.get<AppStore>().wallet!.type) {
|
||||
case WalletType.nano:
|
||||
var seed = credentials['seed'] as String;
|
||||
var bip39Info =
|
||||
|
|
|
@ -587,7 +587,6 @@ import 'package:cake_wallet/view_model/send/output.dart';
|
|||
import 'package:cw_core/account.dart';
|
||||
import 'package:mobx/mobx.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/transaction_history.dart';
|
||||
import 'package:cw_core/wallet_service.dart';
|
||||
|
|
Loading…
Reference in a new issue