mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
Merge pull request #107 from cake-tech/CAKE-305-next-address-bug-for-btc-wallet
Cake 305 next address bug for btc wallet
This commit is contained in:
commit
6fe6d2aebb
4 changed files with 15 additions and 18 deletions
|
@ -174,7 +174,7 @@ abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {
|
|||
}
|
||||
|
||||
@action
|
||||
void nextAddress() {
|
||||
Future<void> nextAddress() async {
|
||||
_accountIndex += 1;
|
||||
|
||||
if (_accountIndex >= addresses.length) {
|
||||
|
@ -182,6 +182,8 @@ abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {
|
|||
}
|
||||
|
||||
address = addresses[_accountIndex].address;
|
||||
|
||||
await save();
|
||||
}
|
||||
|
||||
Future<BitcoinAddressRecord> generateNewAddress() async {
|
||||
|
|
|
@ -534,13 +534,11 @@ Future setup(
|
|||
|
||||
getIt.registerFactory(() {
|
||||
final wallet = getIt.get<AppStore>().wallet;
|
||||
return WyreService(walletType: wallet.type, walletAddress: wallet.address);
|
||||
return WyreService(wallet: wallet);
|
||||
});
|
||||
|
||||
getIt.registerFactory(() {
|
||||
final wallet = getIt.get<AppStore>().wallet;
|
||||
return WyreViewModel(ordersSource, getIt.get<OrdersStore>(),
|
||||
walletId: wallet.id, address: wallet.address, type: wallet.type,
|
||||
wyreService: getIt.get<WyreService>());
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:convert';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
import 'package:cake_wallet/entities/wyre_exception.dart';
|
||||
import 'package:cake_wallet/exchange/trade_state.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
@ -9,8 +10,7 @@ import 'package:cake_wallet/entities/wallet_type.dart';
|
|||
|
||||
class WyreService {
|
||||
WyreService({
|
||||
@required this.walletType,
|
||||
@required this.walletAddress,
|
||||
@required this.wallet,
|
||||
this.isTestEnvironment = false}) {
|
||||
baseApiUrl = isTestEnvironment
|
||||
? _baseTestApiUrl
|
||||
|
@ -31,8 +31,11 @@ class WyreService {
|
|||
static const _trackSuffix = '/track';
|
||||
|
||||
final bool isTestEnvironment;
|
||||
final WalletType walletType;
|
||||
final String walletAddress;
|
||||
final WalletBase wallet;
|
||||
|
||||
WalletType get walletType => wallet.type;
|
||||
String get walletAddress => wallet.address;
|
||||
String get walletId => wallet.id;
|
||||
|
||||
String baseApiUrl;
|
||||
String trackUrl;
|
||||
|
@ -105,7 +108,9 @@ class WyreService {
|
|||
to: to,
|
||||
state: state,
|
||||
createdAt: createdAt,
|
||||
amount: amount.toString()
|
||||
amount: amount.toString(),
|
||||
receiveAddress: walletAddress,
|
||||
walletId: walletId
|
||||
);
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ import 'package:cake_wallet/entities/wyre_service.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:cake_wallet/entities/order.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/store/dashboard/orders_store.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
|
@ -12,8 +11,7 @@ class WyreViewModel = WyreViewModelBase with _$WyreViewModel;
|
|||
|
||||
abstract class WyreViewModelBase with Store {
|
||||
WyreViewModelBase(this.ordersSource, this.ordersStore,
|
||||
{@required this.walletId, @required this.address, @required this.type,
|
||||
@required this.wyreService});
|
||||
{@required this.wyreService});
|
||||
|
||||
Future<String> get wyreUrl => wyreService.getWyreUrl();
|
||||
|
||||
|
@ -22,17 +20,11 @@ abstract class WyreViewModelBase with Store {
|
|||
final Box<Order> ordersSource;
|
||||
final OrdersStore ordersStore;
|
||||
|
||||
final String walletId;
|
||||
final WalletType type;
|
||||
final String address;
|
||||
|
||||
final WyreService wyreService;
|
||||
|
||||
Future<void> saveOrder(String orderId) async {
|
||||
try {
|
||||
final order = await wyreService.findOrderById(orderId);
|
||||
order.receiveAddress = address;
|
||||
order.walletId = walletId;
|
||||
await ordersSource.add(order);
|
||||
ordersStore.setOrder(order);
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in a new issue