mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-12 09:32:33 +00:00
CWA-169 | removed setup_locator and got the box as parameter in MorphTokenExchangeProvider
This commit is contained in:
parent
163d1c48a4
commit
fdeb66e643
7 changed files with 10 additions and 25 deletions
|
@ -35,7 +35,6 @@ import 'package:cake_wallet/src/domain/common/wallet_type.dart';
|
|||
import 'package:cake_wallet/src/domain/services/wallet_service.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/language.dart';
|
||||
import 'package:cake_wallet/src/domain/common/setup_locator.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
@ -66,8 +65,6 @@ void main() async {
|
|||
await Hive.openBox<Trade>(Trade.boxName, encryptionKey: tradesBoxKey);
|
||||
final walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
|
||||
|
||||
setupLocator(trades);
|
||||
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
final walletService = WalletService();
|
||||
final walletListService = WalletListService(
|
||||
|
|
|
@ -395,7 +395,8 @@ class Router {
|
|||
ProxyProvider<SettingsStore, ExchangeTradeStore>(
|
||||
update: (_, settingsStore, __) => ExchangeTradeStore(
|
||||
trade: settings.arguments as Trade,
|
||||
walletStore: walletStore),
|
||||
walletStore: walletStore,
|
||||
trades: trades),
|
||||
),
|
||||
ProxyProvider<SettingsStore, SendStore>(
|
||||
update: (_, settingsStore, __) => SendStore(
|
||||
|
@ -455,7 +456,7 @@ class Router {
|
|||
providerList: [
|
||||
xmrtoprovider,
|
||||
ChangeNowExchangeProvider(),
|
||||
MorphTokenExchangeProvider()
|
||||
MorphTokenExchangeProvider(trades: trades)
|
||||
],
|
||||
walletStore: walletStore);
|
||||
}),
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
import 'package:get_it/get_it.dart';
|
||||
|
||||
GetIt locator = GetIt.instance;
|
||||
|
||||
void setupLocator<T>(T instance) {
|
||||
locator.registerSingleton<T>(instance);
|
||||
}
|
|
@ -19,10 +19,9 @@ import 'package:cake_wallet/src/domain/bitcoin_cash/bitcoin_cash_amount_format.d
|
|||
import 'package:cake_wallet/src/domain/dash/dash_amount_format.dart';
|
||||
import 'package:cake_wallet/src/domain/ethereum/ethereum_amount_format.dart';
|
||||
import 'package:cake_wallet/src/domain/litecoin/litecoin_amount_format.dart';
|
||||
import 'package:cake_wallet/src/domain/common/setup_locator.dart';
|
||||
|
||||
class MorphTokenExchangeProvider extends ExchangeProvider {
|
||||
MorphTokenExchangeProvider()
|
||||
MorphTokenExchangeProvider({@required this.trades})
|
||||
: super(
|
||||
pairList: [
|
||||
ExchangePair(from: CryptoCurrency.xmr, to: CryptoCurrency.eth),
|
||||
|
@ -61,7 +60,7 @@ class MorphTokenExchangeProvider extends ExchangeProvider {
|
|||
ExchangePair(from: CryptoCurrency.btc, to: CryptoCurrency.xmr)
|
||||
]);
|
||||
|
||||
final trades = locator.get<Box<Trade>>();
|
||||
Box<Trade> trades;
|
||||
|
||||
static const apiUri = 'https://api.morphtoken.com';
|
||||
static const _morphURISuffix = '/morph';
|
||||
|
|
|
@ -8,6 +8,7 @@ import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.da
|
|||
import 'package:cake_wallet/src/domain/exchange/xmrto/xmrto_exchange_provider.dart';
|
||||
import 'package:cake_wallet/src/domain/exchange/morphtoken/morphtoken_exchange_provider.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'exchange_trade_store.g.dart';
|
||||
|
||||
|
@ -15,7 +16,7 @@ class ExchangeTradeStore = ExchangeTradeStoreBase with _$ExchangeTradeStore;
|
|||
|
||||
abstract class ExchangeTradeStoreBase with Store {
|
||||
ExchangeTradeStoreBase(
|
||||
{@required this.trade, @required WalletStore walletStore}) {
|
||||
{@required this.trade, @required WalletStore walletStore, @required this.trades}) {
|
||||
isSendable = trade.from == walletStore.type ||
|
||||
trade.provider == ExchangeProviderDescription.xmrto;
|
||||
|
||||
|
@ -27,7 +28,7 @@ abstract class ExchangeTradeStoreBase with Store {
|
|||
_provider = ChangeNowExchangeProvider();
|
||||
break;
|
||||
case ExchangeProviderDescription.morphToken:
|
||||
_provider = MorphTokenExchangeProvider();
|
||||
_provider = MorphTokenExchangeProvider(trades: trades);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -45,6 +46,8 @@ abstract class ExchangeTradeStoreBase with Store {
|
|||
|
||||
Timer _timer;
|
||||
|
||||
Box<Trade> trades;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
|
|
|
@ -301,13 +301,6 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.19"
|
||||
get_it:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: get_it
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -46,7 +46,6 @@ dependencies:
|
|||
hive: ^1.2.0
|
||||
hive_flutter: ^0.2.1
|
||||
package_info: ^0.4.0+13
|
||||
get_it: ^3.1.0
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
|
|
Loading…
Reference in a new issue