From c6a26cac165dcb74181542161322fa1af45f363a Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Fri, 14 Apr 2023 14:05:24 +0200 Subject: [PATCH] - Fix balance display - Fix parsing of Ethereum amount - Add more Ethereum Nodes [skip ci] --- assets/ethereum_server_list.yml | 10 ++++++++++ cw_ethereum/lib/ethereum_balance.dart | 11 +++++++++-- cw_ethereum/lib/ethereum_formatter.dart | 6 +++--- ios/Podfile.lock | 6 ++++++ lib/src/screens/dashboard/widgets/balance_page.dart | 3 --- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/assets/ethereum_server_list.yml b/assets/ethereum_server_list.yml index c7e23ad0e..47b975c12 100644 --- a/assets/ethereum_server_list.yml +++ b/assets/ethereum_server_list.yml @@ -1,2 +1,12 @@ +- + uri: ethereum.publicnode.com +- + uri: eth.llamarpc.com +- + uri: rpc.ankr.com/eth +- + uri: rpc.flashbots.net +- + uri: eth-mainnet.public.blastapi.io - uri: ethereum.publicnode.com \ No newline at end of file diff --git a/cw_ethereum/lib/ethereum_balance.dart b/cw_ethereum/lib/ethereum_balance.dart index 4f0be6e3d..1a992093e 100644 --- a/cw_ethereum/lib/ethereum_balance.dart +++ b/cw_ethereum/lib/ethereum_balance.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:math'; import 'package:cw_core/balance.dart'; import 'package:web3dart/web3dart.dart'; @@ -11,10 +12,16 @@ class EthereumBalance extends Balance { final EtherAmount balance; @override - String get formattedAdditionalBalance => balance.getValueInUnit(EtherUnit.ether).toString(); + String get formattedAdditionalBalance { + final String formattedBalance = balance.getValueInUnit(EtherUnit.ether).toString(); + return formattedBalance.substring(0, min(12, formattedBalance.length)); + } @override - String get formattedAvailableBalance => balance.getValueInUnit(EtherUnit.ether).toString(); + String get formattedAvailableBalance { + final String formattedBalance = balance.getValueInUnit(EtherUnit.ether).toString(); + return formattedBalance.substring(0, min(12, formattedBalance.length)); + } String toJSON() => json.encode({'balanceInWei': balance.getInWei.toString()}); diff --git a/cw_ethereum/lib/ethereum_formatter.dart b/cw_ethereum/lib/ethereum_formatter.dart index a8d6292ce..87991f3ee 100644 --- a/cw_ethereum/lib/ethereum_formatter.dart +++ b/cw_ethereum/lib/ethereum_formatter.dart @@ -1,6 +1,6 @@ -import 'package:web3dart/web3dart.dart'; +import 'dart:math'; class EthereumFormatter { static int parseEthereumAmount(String amount) => - EtherAmount.fromUnitAndValue(EtherUnit.ether, amount).getInWei.toInt(); -} \ No newline at end of file + BigInt.from(double.parse(amount) * (pow(10, 18))).toInt(); +} diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 658d55509..5d57216c4 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -115,6 +115,8 @@ PODS: - Flutter - flutter_secure_storage (3.3.1): - Flutter + - in_app_review (0.2.0): + - Flutter - local_auth_ios (0.0.1): - Flutter - MTBBarcodeScanner (5.0.11) @@ -163,6 +165,7 @@ DEPENDENCIES: - flutter_inappwebview (from `.symlinks/plugins/flutter_inappwebview/ios`) - flutter_mailer (from `.symlinks/plugins/flutter_mailer/ios`) - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) + - in_app_review (from `.symlinks/plugins/in_app_review/ios`) - local_auth_ios (from `.symlinks/plugins/local_auth_ios/ios`) - package_info (from `.symlinks/plugins/package_info/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`) @@ -217,6 +220,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_mailer/ios" flutter_secure_storage: :path: ".symlinks/plugins/flutter_secure_storage/ios" + in_app_review: + :path: ".symlinks/plugins/in_app_review/ios" local_auth_ios: :path: ".symlinks/plugins/local_auth_ios/ios" package_info: @@ -255,6 +260,7 @@ SPEC CHECKSUMS: flutter_inappwebview: bfd58618f49dc62f2676de690fc6dcda1d6c3721 flutter_mailer: 2ef5a67087bc8c6c4cefd04a178bf1ae2c94cd83 flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec + in_app_review: 318597b3a06c22bb46dc454d56828c85f444f99d local_auth_ios: c6cf091ded637a88f24f86a8875d8b0f526e2605 MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c diff --git a/lib/src/screens/dashboard/widgets/balance_page.dart b/lib/src/screens/dashboard/widgets/balance_page.dart index 48eaa0a3e..c27d179b3 100644 --- a/lib/src/screens/dashboard/widgets/balance_page.dart +++ b/lib/src/screens/dashboard/widgets/balance_page.dart @@ -1,10 +1,7 @@ -import 'package:cake_wallet/di.dart'; -import 'package:cake_wallet/src/widgets/standard_list.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/themes/theme_base.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; -import 'package:flutter/scheduler.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:cake_wallet/src/widgets/introducing_card.dart';