fix: update DFX Buy provider currency support and parsing logic (#2516)

* fix: update DFX Buy provider currency support and parsing logic

* fix: adjust Monero node URI handling for consistency with query parameters

* fix: correct German translations for wallet-related text and terminology
This commit is contained in:
Konstantin Ullrich
2025-09-12 15:44:50 +03:00
committed by GitHub
parent 4aac641f04
commit e1747f41b8
3 changed files with 66 additions and 39 deletions
+17 -3
View File
@@ -41,8 +41,22 @@ class DFXBuyProvider extends BuyProvider {
static const _authPath = '/v1/auth';
static const walletName = 'CakeWallet';
static const List<CryptoCurrency> _notSupportedCrypto = [];
static const List<FiatCurrency> _notSupportedFiat = [];
static final List<CryptoCurrency> _supportedCrypto = [
CryptoCurrency.xmr,
CryptoCurrency.btc,
CryptoCurrency.eth,
CryptoCurrency.maticpoly,
CryptoCurrency.sol,
CryptoCurrency.zano,
CryptoCurrency.trx,
];
static final List<CryptoCurrency> _notSupportedCrypto = CryptoCurrency.all
.where((crypto) => !_supportedCrypto.contains(crypto) || ["ETH", "POL"].contains(crypto.tag))
.toList();
static final List<FiatCurrency> _supportedFiat = [FiatCurrency.chf, FiatCurrency.eur];
static final List<FiatCurrency> _notSupportedFiat =
FiatCurrency.all.where((fiat) => !_supportedFiat.contains(fiat)).toList();
@override
String get title => 'DFX.swiss';
@@ -406,7 +420,7 @@ class DFXBuyProvider extends BuyProvider {
final responseBody = jsonDecode(body) as Map<String, dynamic>;
final message = responseBody['message']?.toString() ?? '';
if (message.contains("address must match")) {
if (message.contains("address must match") || message.contains("signature must match")) {
return "The wallet type must match the selected currency";
}
@@ -236,6 +236,7 @@ abstract class NodeCreateOrEditViewModelBase with Store {
throw Exception('Unexpected scan QR code value: value is empty');
}
if (code.startsWith("monero_node:")) code = code.replaceFirst("monero_node:", "tcp://");
if (!code.contains('://')) code = 'tcp://$code';
final uri = Uri.tryParse(code);
@@ -243,19 +244,31 @@ abstract class NodeCreateOrEditViewModelBase with Store {
throw Exception('Invalid QR code: Unable to parse or missing host.');
}
final queryParams = uri.queryParameters;
final ipAddress = uri.host;
final port = uri.hasPort ? uri.port.toString() : '';
final path = uri.path;
final userInfo = uri.userInfo;
var port = uri.hasPort ? uri.port.toString() : '';
var rpcUser = userInfo.length == 2 ? userInfo[0] : '';
var rpcPassword = userInfo.length == 2 ? userInfo[1] : '';
if (uri.scheme == "monero_node" && rpcUser.isEmpty && rpcPassword.isEmpty) {
final queryParams = uri.queryParameters;
if (rpcUser.isEmpty && rpcPassword.isEmpty) {
rpcUser = queryParams['username'] ?? '';
rpcPassword = queryParams['password'] ?? '';
}
if (port.isEmpty) {
port = queryParams['port'] ?? '';
}
if (queryParams['protocol'] == 'https') {
setSSL(true);
}
if (queryParams['trusted'] == 'true') {
setTrusted(true);
}
await Future.delayed(Duration(milliseconds: 345));
setAddress(ipAddress);