fix: parse double to int in initCurrencyParameters for iPhone
This commit is contained in:
parent
532a004fd9
commit
c8933fd5be
|
@ -96,10 +96,19 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _getStorageConst(String call) async {
|
Future<int> _getStorageConst(String call) async {
|
||||||
return (await sdk.webView!
|
final result = (await sdk.webView!
|
||||||
.evalJavascript('api.consts.$call', wrapPromise: false) ??
|
.evalJavascript('api.consts.$call', wrapPromise: false) ??
|
||||||
[null])[0];
|
[null])[0];
|
||||||
|
|
||||||
|
return checkInt(result) ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int? checkInt(dynamic value) {
|
||||||
|
if (value is int) return value;
|
||||||
|
if (value is double) return value.toInt();
|
||||||
|
if (value is String) return int.tryParse(value);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<TxSenderData> _setSender(String address) async {
|
Future<TxSenderData> _setSender(String address) async {
|
||||||
|
@ -396,7 +405,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
currencyParameters['certValidityPeriod'] =
|
currencyParameters['certValidityPeriod'] =
|
||||||
await _getStorageConst('cert.validityPeriod.words');
|
await _getStorageConst('cert.validityPeriod.words');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.i('error while getting storageVals (network?)');
|
log.i('error while getting storageVals (network?) :: $e');
|
||||||
}
|
}
|
||||||
log.i('currencyParameters: $currencyParameters');
|
log.i('currencyParameters: $currencyParameters');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue