mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-06 08:44:35 +00:00
fix api calls in async transaction creation
This commit is contained in:
parent
2df5e8e6e5
commit
b04d250c67
1 changed files with 8 additions and 8 deletions
|
@ -154,12 +154,12 @@ mixin ZanoWalletApi {
|
||||||
_json('assets_whitelist_add $assetId', json);
|
_json('assets_whitelist_add $assetId', json);
|
||||||
final map = jsonDecode(json) as Map<String, dynamic>?;
|
final map = jsonDecode(json) as Map<String, dynamic>?;
|
||||||
_checkForErrors(map);
|
_checkForErrors(map);
|
||||||
if (map!['result']!['result']!['status']! == 'OK') {
|
if (map!['result']!['status']! == 'OK') {
|
||||||
final assetDescriptor = ZanoAsset.fromJson(map['result']!['result']!['asset_descriptor']! as Map<String, dynamic>);
|
final assetDescriptor = ZanoAsset.fromJson(map['result']!['asset_descriptor']! as Map<String, dynamic>);
|
||||||
info('assets_whitelist_add added ${assetDescriptor.fullName} ${assetDescriptor.ticker}');
|
info('assets_whitelist_add added ${assetDescriptor.fullName} ${assetDescriptor.ticker}');
|
||||||
return assetDescriptor;
|
return assetDescriptor;
|
||||||
} else {
|
} else {
|
||||||
info('assets_whitelist_add status ${map['result']!['result']!['status']!}');
|
info('assets_whitelist_add status ${map['result']!['status']!}');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -174,8 +174,8 @@ mixin ZanoWalletApi {
|
||||||
_json('assets_whitelist_remove $assetId', json);
|
_json('assets_whitelist_remove $assetId', json);
|
||||||
final map = jsonDecode(json) as Map<String, dynamic>?;
|
final map = jsonDecode(json) as Map<String, dynamic>?;
|
||||||
_checkForErrors(map);
|
_checkForErrors(map);
|
||||||
info('assets_whitelist_remove status ${map!['result']!['result']!['status']!}');
|
info('assets_whitelist_remove status ${map!['result']!['status']!}');
|
||||||
return (map['result']!['result']!['status']! == 'OK');
|
return (map['result']!['status']! == 'OK');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error('assets_whitelist_remove $e');
|
error('assets_whitelist_remove $e');
|
||||||
return false;
|
return false;
|
||||||
|
@ -342,7 +342,7 @@ mixin ZanoWalletApi {
|
||||||
final json = await invokeMethod('transfer', params);
|
final json = await invokeMethod('transfer', params);
|
||||||
_json('transfer', json);
|
_json('transfer', json);
|
||||||
final map = jsonDecode(json);
|
final map = jsonDecode(json);
|
||||||
final resultMap = map['result'] as Map<String, dynamic>?;
|
final resultMap = map as Map<String, dynamic>?;
|
||||||
if (resultMap != null) {
|
if (resultMap != null) {
|
||||||
final transferResultMap = resultMap['result'] as Map<String, dynamic>?;
|
final transferResultMap = resultMap['result'] as Map<String, dynamic>?;
|
||||||
if (transferResultMap != null) {
|
if (transferResultMap != null) {
|
||||||
|
@ -350,9 +350,9 @@ mixin ZanoWalletApi {
|
||||||
info('transfer success hash ${transferResult.txHash}');
|
info('transfer success hash ${transferResult.txHash}');
|
||||||
return transferResult;
|
return transferResult;
|
||||||
} else {
|
} else {
|
||||||
final errorCode = resultMap['error']['code'];
|
final errorCode = resultMap['error']?['code'];
|
||||||
final code = errorCode is int ? errorCode.toString() : errorCode as String? ?? '';
|
final code = errorCode is int ? errorCode.toString() : errorCode as String? ?? '';
|
||||||
final message = resultMap['error']['message'] as String? ?? '';
|
final message = resultMap['error']?['message'] as String? ?? '';
|
||||||
error('transfer error $code $message');
|
error('transfer error $code $message');
|
||||||
throw TransferException('Transfer error, $message ($code)');
|
throw TransferException('Transfer error, $message ($code)');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue