CW-1146-Enable-Zano-buy-sell-for-DFX (#2458)

* feat(CW-1148): Add Zano wallet support for message

* refactor(CW-1148): Simplify `signMessage` logic in Zano wallet API

* fix: remove unsupported wallet types from DFX Buy provider

* fix: correct DFX Buy provider parameter name from `amount` to `amount-in`
This commit is contained in:
Konstantin Ullrich
2025-08-19 18:28:37 +03:00
committed by GitHub
parent c8dca29f68
commit cb53840332
3 changed files with 36 additions and 7 deletions
+2 -3
View File
@@ -59,9 +59,8 @@ abstract class ZanoWalletBase
String get password => _password;
@override
Future<String> signMessage(String message, {String? address = null}) {
throw UnimplementedError();
}
Future<String> signMessage(String message, {String? address = null}) =>
super.signMessage(message, address: address);
@override
Future<bool> verifyMessage(String message, String signature, {String? address = null}) {
+30 -1
View File
@@ -401,6 +401,35 @@ mixin ZanoWalletApi {
throw TransferException('Transfer error, empty result');
}
Future<String> signMessage(String message, {String? address = null}) async {
try {
final messageBase64 = convert.base64.encode(convert.utf8.encode(message));
final response = await invokeMethod('sign_message', {'buff': messageBase64});
final responseData = convert.jsonDecode(response) as Map<String, dynamic>;
if (responseData['error'] != null) {
printV('ZANO sign_message error: ${responseData['error']}');
throw Exception('Zano sign_message failed: ${responseData['error']}');
}
final result = responseData['result'] as Map<String, dynamic>?;
if (result == null) {
throw Exception('Invalid response from sign_message');
}
final signature = result['sig'] as String?;
if (signature == null) {
throw Exception('No signature in response');
}
return signature;
} catch (e) {
printV('ZANO signMessage error: $e');
rethrow;
}
}
void _checkForErrors(Map<String, dynamic>? map) {
if (map == null) {
throw ZanoWalletException('Empty response');
@@ -510,4 +539,4 @@ Future<String> _closeWallet(int hWallet) async {
return str;
}
Map<String, List<int>> debugCallLength() => zano.debugCallLength;
Map<String, List<int>> debugCallLength() => zano.debugCallLength;
+4 -3
View File
@@ -62,9 +62,9 @@ class DFXBuyProvider extends BuyProvider {
String get blockchain {
switch (wallet.type) {
case WalletType.bitcoin:
case WalletType.bitcoinCash:
case WalletType.litecoin:
return 'Bitcoin';
case WalletType.zano:
return 'Zano';
default:
return walletTypeToString(wallet.type);
}
@@ -131,6 +131,7 @@ class DFXBuyProvider extends BuyProvider {
case WalletType.litecoin:
case WalletType.bitcoin:
case WalletType.bitcoinCash:
case WalletType.zano:
return await wallet.signMessage(message, address: walletAddress);
default:
throw Exception("WalletType is not available for DFX ${wallet.type}");
@@ -345,7 +346,7 @@ class DFXBuyProvider extends BuyProvider {
'asset-out': isBuyAction ? quote.cryptoCurrency.toString() : quote.fiatCurrency.toString(),
'blockchain': blockchain,
'asset-in': isBuyAction ? quote.fiatCurrency.toString() : quote.cryptoCurrency.toString(),
'amount': amount.toString() //TODO: Amount does not work
'amount-in': amount.toString()
});
if (await canLaunchUrl(uri)) {