mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
Remove Wyre buy-provider integration (shut down 2023)
Delete the WyreBuyProvider + WyreOrderProviderAdapter source files, strip imports and call sites from buy/order view models and the buy webview, force isBitcoinBuyEnabled = false in di.dart, and drop the three wyreSecretKey/wyreApiKey/wyreAccountId entries from tool/utils/secret_key.dart. BuyProviderDescription.wyre (raw: 0) is kept as a no-op legacy entry so any old Hive-persisted order with that raw value still deserializes without throwing. Don't wire it back to UI/services.
This commit is contained in:
@@ -6,6 +6,8 @@ class BuyProviderDescription extends EnumerableItem<int> with Serializable<int>
|
||||
|
||||
final String image;
|
||||
|
||||
// raw: 0 was Wyre, removed (provider shut down 2023). Kept the constant
|
||||
// for legacy Hive deserialization; do not wire it back into UI/services.
|
||||
static const wyre = BuyProviderDescription(title: 'Wyre', raw: 0, image: '');
|
||||
static const moonPay = BuyProviderDescription(title: 'MoonPay', raw: 1, image: '');
|
||||
|
||||
|
||||
@@ -1,173 +0,0 @@
|
||||
import 'dart:convert';
|
||||
import 'package:hash_wallet/buy/buy_exception.dart';
|
||||
import 'package:hash_wallet/order/order_source_description.dart';
|
||||
import 'package:hash_wallet/buy/pairs_utils.dart';
|
||||
import 'package:hash_wallet/entities/fiat_currency.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:cw_core/utils/proxy_wrapper.dart';
|
||||
import 'package:hash_wallet/buy/buy_amount.dart';
|
||||
import 'package:hash_wallet/buy/buy_provider.dart';
|
||||
import 'package:hash_wallet/buy/buy_provider_description.dart';
|
||||
import 'package:hash_wallet/order/order.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:hash_wallet/exchange/trade_state.dart';
|
||||
import 'package:hash_wallet/.secrets.g.dart' as secrets;
|
||||
|
||||
class WyreBuyProvider extends BuyProvider {
|
||||
WyreBuyProvider({required WalletBase wallet, bool isTestEnvironment = false})
|
||||
: baseApiUrl = isTestEnvironment ? _baseTestApiUrl : _baseProductApiUrl,
|
||||
super(
|
||||
wallet: wallet,
|
||||
isTestEnvironment: isTestEnvironment,
|
||||
hardwareWalletVM: null,
|
||||
supportedCryptoList: supportedCryptoToFiatPairs(
|
||||
notSupportedCrypto: _notSupportedCrypto, notSupportedFiat: _notSupportedFiat),
|
||||
supportedFiatList: supportedFiatToCryptoPairs(
|
||||
notSupportedFiat: _notSupportedFiat, notSupportedCrypto: _notSupportedCrypto));
|
||||
|
||||
static const _baseTestApiUrl = 'https://api.testwyre.com';
|
||||
static const _baseProductApiUrl = 'https://api.sendwyre.com';
|
||||
static const _trackTestUrl = 'https://dash.testwyre.com/track/';
|
||||
static const _trackProductUrl = 'https://dash.sendwyre.com/track/';
|
||||
static const _ordersSuffix = '/v3/orders';
|
||||
static const _reserveSuffix = '/reserve';
|
||||
static const _quoteSuffix = '/quote/partner';
|
||||
static const _timeStampSuffix = '?timestamp=';
|
||||
static const _transferSuffix = '/v2/transfer/';
|
||||
static const _trackSuffix = '/track';
|
||||
static const _countryCode = 'US';
|
||||
static const _secretKey = secrets.wyreSecretKey;
|
||||
static const _accountId = secrets.wyreAccountId;
|
||||
|
||||
static const List<CryptoCurrency> _notSupportedCrypto = [];
|
||||
static const List<FiatCurrency> _notSupportedFiat = [];
|
||||
|
||||
@override
|
||||
String get title => 'Wyre';
|
||||
|
||||
@override
|
||||
String get providerDescription => '';
|
||||
|
||||
@override
|
||||
String get lightIcon => 'assets/images/robinhood_light.png';
|
||||
|
||||
@override
|
||||
String get darkIcon => 'assets/images/robinhood_dark.png';
|
||||
|
||||
@override
|
||||
bool get isAggregator => false;
|
||||
|
||||
String get trackUrl => isTestEnvironment ? _trackTestUrl : _trackProductUrl;
|
||||
|
||||
String baseApiUrl;
|
||||
|
||||
Future<String> requestUrl(String amount, String sourceCurrency) async {
|
||||
final timestamp = DateTime.now().millisecondsSinceEpoch.toString();
|
||||
final url = baseApiUrl + _ordersSuffix + _reserveSuffix + _timeStampSuffix + timestamp;
|
||||
final uri = Uri.parse(url);
|
||||
final body = {
|
||||
'amount': amount,
|
||||
'sourceCurrency': sourceCurrency,
|
||||
'destCurrency': walletTypeToCryptoCurrency(wallet.type, chainId: wallet.chainId).title,
|
||||
'dest': walletTypeToString(wallet.type).toLowerCase() + ':' + wallet.walletAddresses.address,
|
||||
'referrerAccountId': _accountId,
|
||||
'lockFields': ['amount', 'sourceCurrency', 'destCurrency', 'dest']
|
||||
};
|
||||
final response = await ProxyWrapper().post(
|
||||
clearnetUri: uri,
|
||||
headers: {
|
||||
'Authorization': 'Bearer $_secretKey',
|
||||
'Content-Type': 'application/json',
|
||||
'cache-control': 'no-cache'
|
||||
},
|
||||
body: json.encode(body),
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw BuyException(title: providerDescription, content: 'Url $url is not found!');
|
||||
}
|
||||
|
||||
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final urlFromResponse = responseJSON['url'] as String;
|
||||
return urlFromResponse;
|
||||
}
|
||||
|
||||
Future<BuyAmount> calculateAmount(String amount, String sourceCurrency) async {
|
||||
final quoteUrl = _baseProductApiUrl + _ordersSuffix + _quoteSuffix;
|
||||
final body = {
|
||||
'amount': amount,
|
||||
'sourceCurrency': sourceCurrency,
|
||||
'destCurrency': walletTypeToCryptoCurrency(wallet.type, chainId: wallet.chainId).title,
|
||||
'dest': walletTypeToString(wallet.type).toLowerCase() + ':' + wallet.walletAddresses.address,
|
||||
'accountId': _accountId,
|
||||
'country': _countryCode
|
||||
};
|
||||
final uri = Uri.parse(quoteUrl);
|
||||
final response = await ProxyWrapper().post(
|
||||
clearnetUri: uri,
|
||||
headers: {
|
||||
'Authorization': 'Bearer $_secretKey',
|
||||
'Content-Type': 'application/json',
|
||||
'cache-control': 'no-cache'
|
||||
},
|
||||
body: json.encode(body),
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw BuyException(title: providerDescription, content: 'Quote is not found!');
|
||||
}
|
||||
|
||||
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final sourceAmount = responseJSON['sourceAmount'] as double;
|
||||
final destAmount = responseJSON['destAmount'] as double;
|
||||
final achAmount = responseJSON['sourceAmountWithoutFees'] as double;
|
||||
|
||||
return BuyAmount(
|
||||
sourceAmount: sourceAmount, destAmount: destAmount, achSourceAmount: achAmount);
|
||||
}
|
||||
|
||||
Future<Order> findOrderById(String id) async {
|
||||
final orderUrl = baseApiUrl + _ordersSuffix + '/$id';
|
||||
final orderUri = Uri.parse(orderUrl);
|
||||
final orderResponse = await ProxyWrapper().get(clearnetUri: orderUri);
|
||||
if (orderResponse.statusCode != 200) {
|
||||
throw BuyException(title: providerDescription, content: 'Order $id is not found!');
|
||||
}
|
||||
|
||||
final orderResponseJSON = json.decode(orderResponse.body) as Map<String, dynamic>;
|
||||
final transferId = orderResponseJSON['transferId'] as String;
|
||||
final from = orderResponseJSON['sourceCurrency'] as String;
|
||||
final to = orderResponseJSON['destCurrency'] as String;
|
||||
final status = orderResponseJSON['status'] as String;
|
||||
final state = TradeState.deserialize(raw: status.toLowerCase());
|
||||
final createdAtRaw = orderResponseJSON['createdAt'] as int;
|
||||
final createdAt = DateTime.fromMillisecondsSinceEpoch(createdAtRaw).toLocal();
|
||||
|
||||
final transferUrl = baseApiUrl + _transferSuffix + transferId + _trackSuffix;
|
||||
final transferUri = Uri.parse(transferUrl);
|
||||
final transferResponse = await ProxyWrapper().get(clearnetUri: transferUri);
|
||||
if (transferResponse.statusCode != 200) {
|
||||
throw BuyException(title: providerDescription, content: 'Transfer $transferId is not found!');
|
||||
}
|
||||
|
||||
final transferResponseJSON = json.decode(transferResponse.body) as Map<String, dynamic>;
|
||||
final amount = transferResponseJSON['destAmount'] as double;
|
||||
|
||||
return Order(
|
||||
id: id,
|
||||
source: OrderSourceDescription.buy,
|
||||
buyProvider: BuyProviderDescription.wyre,
|
||||
transferId: transferId,
|
||||
from: from,
|
||||
to: to,
|
||||
state: state,
|
||||
createdAt: createdAt,
|
||||
amount: amount.toString(),
|
||||
receiveAddress: wallet.walletAddresses.address,
|
||||
walletId: wallet.id);
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -371,9 +371,7 @@ Future<void> setup({
|
||||
});
|
||||
}
|
||||
|
||||
final isBitcoinBuyEnabled = (secrets.wyreSecretKey.isNotEmpty) &&
|
||||
(secrets.wyreApiKey.isNotEmpty) &&
|
||||
(secrets.wyreAccountId.isNotEmpty);
|
||||
const isBitcoinBuyEnabled = false;
|
||||
|
||||
final settingsStore = await SettingsStoreBase.load(
|
||||
nodeSource: _nodeSource,
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import 'package:hash_wallet/buy/wyre/wyre_buy_provider.dart';
|
||||
import 'package:hash_wallet/order/order.dart';
|
||||
import 'package:hash_wallet/order/order_provider.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
|
||||
class WyreOrderProviderAdapter implements OrderProvider {
|
||||
WyreOrderProviderAdapter({required WalletBase wallet})
|
||||
: _wyreProvider = WyreBuyProvider(wallet: wallet);
|
||||
|
||||
final WyreBuyProvider _wyreProvider;
|
||||
|
||||
@override
|
||||
Future<(Order, Object?)> findOrderById(String id) async {
|
||||
final order = await _wyreProvider.findOrderById(id);
|
||||
return (order, null);
|
||||
}
|
||||
|
||||
@override
|
||||
String get title => _wyreProvider.title;
|
||||
|
||||
@override
|
||||
String get trackUrl => _wyreProvider.trackUrl;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'package:hash_wallet/buy/moonpay/moonpay_provider.dart';
|
||||
import 'package:hash_wallet/buy/wyre/wyre_buy_provider.dart';
|
||||
import 'package:hash_wallet/generated/i18n.dart';
|
||||
import 'package:hash_wallet/src/screens/base_page.dart';
|
||||
import 'package:hash_wallet/store/dashboard/orders_store.dart';
|
||||
@@ -54,10 +53,6 @@ class BuyWebViewPageBodyState extends State<BuyWebViewPageBody> {
|
||||
_isSaving = false;
|
||||
widget.ordersStore.orderId = '';
|
||||
|
||||
if (widget.buyViewModel.selectedProvider is WyreBuyProvider) {
|
||||
_saveOrder(keyword: 'completed', splitSymbol: '/');
|
||||
}
|
||||
|
||||
if (widget.buyViewModel.selectedProvider is MoonPayProvider) {
|
||||
_saveOrder(keyword: 'transactionId', splitSymbol: '=');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:hash_wallet/buy/buy_provider.dart';
|
||||
import 'package:hash_wallet/buy/wyre/wyre_buy_provider.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:hash_wallet/entities/fiat_currency.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
@@ -87,14 +86,6 @@ abstract class BuyViewModelBase with Store {
|
||||
}
|
||||
|
||||
Future<void> _fetchBuyItems() async {
|
||||
final List<BuyProvider> _providerList = [];
|
||||
|
||||
if (wallet.type == WalletType.bitcoin) {
|
||||
_providerList.add(WyreBuyProvider(wallet: wallet));
|
||||
}
|
||||
|
||||
items = _providerList
|
||||
.map((provider) => BuyItem(provider: provider, buyAmountViewModel: buyAmountViewModel))
|
||||
.toList();
|
||||
items = const <BuyItem>[];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:hash_wallet/generated/i18n.dart';
|
||||
import 'package:hash_wallet/order/order.dart';
|
||||
import 'package:hash_wallet/order/order_provider.dart';
|
||||
import 'package:hash_wallet/order/order_provider_adapter/cake_pay_order_provider_adapter.dart';
|
||||
import 'package:hash_wallet/order/order_provider_adapter/wyre_order_provider_adapter.dart';
|
||||
import 'package:hash_wallet/order/order_provider_description.dart';
|
||||
import 'package:hash_wallet/order/order_source_description.dart';
|
||||
import 'package:hash_wallet/src/screens/order_details/cake_pay_detail_list_card_item.dart';
|
||||
@@ -39,9 +38,7 @@ abstract class OrderDetailsViewModelBase with Store {
|
||||
order = orderForDetails {
|
||||
switch (order.source) {
|
||||
case OrderSourceDescription.buy:
|
||||
if (order.buyProvider == BuyProviderDescription.wyre) {
|
||||
_provider = WyreOrderProviderAdapter(wallet: wallet);
|
||||
} else if (order.buyProvider == BuyProviderDescription.moonPay) {
|
||||
if (order.buyProvider == BuyProviderDescription.moonPay) {
|
||||
//_provider = MoonPayOrderProviderAdapter(appStore: null /* provide if needed */, wallet: wallet);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -14,9 +14,6 @@ class SecretKey {
|
||||
SecretKey('backupKeychainSalt', () => hex.encode(encrypt.Key.fromSecureRandom(12).bytes)),
|
||||
SecretKey('changeNowCakeWalletApiKey', () => ''),
|
||||
SecretKey('changeNowMoneroApiKey', () => ''),
|
||||
SecretKey('wyreSecretKey', () => ''),
|
||||
SecretKey('wyreApiKey', () => ''),
|
||||
SecretKey('wyreAccountId', () => ''),
|
||||
SecretKey('moonPayApiKey', () => ''),
|
||||
SecretKey('moonPaySecretKey', () => ''),
|
||||
SecretKey('sideShiftAffiliateId', () => ''),
|
||||
|
||||
Reference in New Issue
Block a user