mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-02 12:14:09 +01:00
Add Base Wallet (#2558)
* chore: Create Base package template * chore: Update configuration scripts and dependencies to include 'base' coin support * chore: Update pubspec.yaml, adjust SDK constraints, and add new dependencies * feat: Add support for base wallet type and cryptocurrency in related configurations * feat: Implement BaseWallet and DefaultBaseTokens classes for managing base cryptocurrency transactions * feat: Add BaseTransactionHistory and BaseTransactionInfo classes for handling base cryptocurrency transaction data * feat: Implement BaseClient, BaseWalletService, and BaseMnemonicIsIncorrectException * feat: Setup base proxy for main package and adjust token class name * feat: Setup initial base node configuration * feat: Integrate support for base wallet type across various functions and services * feat: Add base support to exchange and outputs * feat: Add base wallet type integration to wallet creation and node management * feat: Add base support to transaction details and transaction list item * feat: Implement BaseURI class and add base support across wallet creation and keys view models * feat: Add support for BaseScan preference in settings store * feat: Integrate Base support into various workflows and documentation * feat: Addingbase config to windows and secret key support * feat: Add base support to settings and address handling * chore: Move walletTypeToCurrency to another file and adjust across codebase * feat: Add 'basescan_history' string localization * feat: Remove Cryptocurrency.base, it doesn't have a base currency * feat: Set eth as native currency * feat: Enhance Base support across various sending, exchange, transaction details, fees, dashboard and balance * feat: Integrate Base wallet support in advanced privacy settings and home settings view models * feat: Add Base wallet support with icon and integration across providers, default settings migration, preferences, wallet connect, settings and token utilities * feat: Update currency handling to use baseEth for Base wallet integration across various components * fix: Update default token symbol to ETH in Base wallet transaction model * refactor: Change default currency references from BASE to ETH across client, transaction info, and wallet components * feat: Introduce normalizedIconPath for CryptoCurrency to standardize icon retrieval across wallet components * fix: Include baseEth as a native token in EVMChainClient for currency handling * chore: Update base_icon.png * feat: Add more nodes to base_node_list.yml * refactor: Update wallet icon retrieval to use normalizedIconPath * chore: Remove unused cases and cleanup impl. * feat: Add base proxy generation to configure * refactor: Update base proxy and generation code in configure.dart * feat: Add missing wallet and mono images * fix: Wrong image path for pr and add missing base qr image * feat: Enhance EVMTransactionErrorFeesHandler to parse new insufficient funds error format and calculate transaction fees in ETH and USD * feat: Add gas price safety buffer for Base chain transactions to improve fee estimation accuracy, also fixes send all not calculating correctly * Update model_generator.sh [skip ci] * Update assets/base_node_list.yml [skip ci] * Update cw_base/lib/default_base_erc20_tokens.dart [skip ci] * Review fixes * fixes --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
This commit is contained in:
co-authored by
OmarHatem
parent
025fc9154c
commit
2a74317aff
@@ -10,6 +10,7 @@ import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_hardware_restore_view_model.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
@@ -148,7 +149,7 @@ class _SelectHardwareWalletAccountFormState extends State<SelectHardwareWalletAc
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: SelectButton(
|
||||
image: Image.asset(
|
||||
walletTypeToCryptoCurrency(_walletHardwareRestoreVM.type).iconPath ??
|
||||
walletTypeToCryptoCurrency(_walletHardwareRestoreVM.type).normalizedIconPath ??
|
||||
'',
|
||||
height: 24,
|
||||
width: 24,
|
||||
|
||||
@@ -38,6 +38,7 @@ class _DesktopWalletSelectionDropDownState extends State<DesktopWalletSelectionD
|
||||
final ethereumIcon = Image.asset('assets/images/crypto/ethereum.png', height: 24, width: 24);
|
||||
final polygonIcon = Image.asset('assets/images/crypto/polygon.png', height: 24, width: 24);
|
||||
final bitcoinCashIcon = Image.asset('assets/images/crypto/bitcoin-cash.png', height: 24, width: 24);
|
||||
final baseIcon = Image.asset('assets/images/base_icon.png', height: 24, width: 24);
|
||||
final nanoIcon = Image.asset('assets/images/crypto/nano.png', height: 24, width: 24);
|
||||
final bananoIcon = Image.asset('assets/images/crypto/nano.png', height: 24, width: 24);
|
||||
final solanaIcon = Image.asset('assets/images/crypto/solana.png', height: 24, width: 24);
|
||||
@@ -184,6 +185,8 @@ class _DesktopWalletSelectionDropDownState extends State<DesktopWalletSelectionD
|
||||
return decredIcon;
|
||||
case WalletType.dogecoin:
|
||||
return dogeIcon;
|
||||
case WalletType.base:
|
||||
return baseIcon;
|
||||
case WalletType.none:
|
||||
return nonWalletTypeIcon;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ class MenuWidgetState extends State<MenuWidget> {
|
||||
this.bananoIcon = Image.asset('assets/images/crypto/nano.png'),
|
||||
this.bitcoinCashIcon = Image.asset('assets/images/crypto/bitcoin-cash.png'),
|
||||
this.polygonIcon = Image.asset('assets/images/crypto/polygon.png'),
|
||||
this.baseIcon = Image.asset('assets/images/base_icon.png'),
|
||||
this.solanaIcon = Image.asset('assets/images/crypto/solana.png'),
|
||||
this.tronIcon = Image.asset('assets/images/crypto/tron.png'),
|
||||
this.wowneroIcon = Image.asset('assets/images/crypto/wownero.png'),
|
||||
@@ -60,6 +61,7 @@ class MenuWidgetState extends State<MenuWidget> {
|
||||
Image nanoIcon;
|
||||
Image bananoIcon;
|
||||
Image polygonIcon;
|
||||
Image baseIcon;
|
||||
Image solanaIcon;
|
||||
Image tronIcon;
|
||||
Image wowneroIcon;
|
||||
@@ -247,6 +249,8 @@ class MenuWidgetState extends State<MenuWidget> {
|
||||
return polygonIcon;
|
||||
case WalletType.solana:
|
||||
return solanaIcon;
|
||||
case WalletType.base:
|
||||
return baseIcon;
|
||||
case WalletType.tron:
|
||||
return tronIcon;
|
||||
case WalletType.wownero:
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/widgets/address_text_field.dart';
|
||||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||
import 'package:cake_wallet/utils/show_bar.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/widgets/address_text_field.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cake_wallet/view_model/new_wallet_type_view_model.dart';
|
||||
import 'package:cake_wallet/wallet_types.g.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:cw_core/hardware/device_connection_type.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
@@ -142,9 +143,9 @@ class WalletTypeFormState extends State<WalletTypeForm> {
|
||||
child: SelectButton(
|
||||
key: ValueKey('new_wallet_type_${type.name}_button_key'),
|
||||
image: Image.asset(
|
||||
walletTypeToCryptoCurrency(type).iconPath ?? '',
|
||||
height: 28,
|
||||
width: 28,
|
||||
walletTypeToCryptoCurrency(type).normalizedIconPath ?? '',
|
||||
height: 24,
|
||||
width: 24,
|
||||
),
|
||||
text: walletTypeToDisplayName(type),
|
||||
showTrailingIcon: false,
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/themes/core/material_base_theme.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_groups_display_view_model.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
|
||||
@@ -95,7 +95,7 @@ class WalletGroupsDisplayBody extends StatelessWidget {
|
||||
isSelected:
|
||||
walletGroupsDisplayViewModel.selectedSingleWallet == wallet,
|
||||
leadingWidget: Image.asset(
|
||||
walletTypeToCryptoCurrency(wallet.type).iconPath!,
|
||||
walletTypeToCryptoCurrency(wallet.type).normalizedIconPath!,
|
||||
width: 32,
|
||||
height: 32,
|
||||
),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
|
||||
|
||||
@@ -99,7 +99,6 @@ class GroupedWalletExpansionTile extends StatelessWidget {
|
||||
final currentColor = item.isCurrent
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.surface;
|
||||
final walletTypeToCrypto = walletTypeToCryptoCurrency(item.type);
|
||||
return ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
key: ValueKey(item.name),
|
||||
@@ -124,7 +123,7 @@ class GroupedWalletExpansionTile extends StatelessWidget {
|
||||
: SizedBox(width: 7),
|
||||
SizedBox(width: 24),
|
||||
Image.asset(
|
||||
walletTypeToCrypto.iconPath!,
|
||||
walletTypeToCryptoCurrency(item.type).normalizedIconPath!,
|
||||
width: 32,
|
||||
height: 32,
|
||||
),
|
||||
|
||||
@@ -118,6 +118,14 @@ class PrivacyPage extends BasePage {
|
||||
_privacySettingsViewModel.setUsePolygonScan(value);
|
||||
},
|
||||
),
|
||||
if (_privacySettingsViewModel.canUseBaseScan)
|
||||
SettingsSwitcherCell(
|
||||
title: S.current.basescan_history,
|
||||
value: _privacySettingsViewModel.useBaseScan,
|
||||
onValueChange: (BuildContext _, bool value) {
|
||||
_privacySettingsViewModel.setUseBaseScan(value);
|
||||
},
|
||||
),
|
||||
if (_privacySettingsViewModel.canUseTronGrid)
|
||||
SettingsSwitcherCell(
|
||||
title: S.current.trongrid_history,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
enum EVMChainId {
|
||||
ethereum,
|
||||
polygon,
|
||||
base,
|
||||
goerli,
|
||||
mumbai,
|
||||
arbitrum,
|
||||
@@ -17,6 +18,9 @@ extension EVMChainIdX on EVMChainId {
|
||||
case EVMChainId.polygon:
|
||||
name = '137';
|
||||
break;
|
||||
case EVMChainId.base:
|
||||
name = '8453';
|
||||
break;
|
||||
case EVMChainId.goerli:
|
||||
name = '5';
|
||||
break;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:cake_wallet/base/base.dart';
|
||||
import 'package:cake_wallet/ethereum/ethereum.dart';
|
||||
import 'package:cake_wallet/polygon/polygon.dart';
|
||||
import 'package:cake_wallet/reactions/wallet_connect.dart';
|
||||
@@ -23,6 +24,8 @@ class KeyServiceImpl implements WalletConnectKeyService {
|
||||
return ethereum!.getPrivateKey(wallet);
|
||||
case WalletType.polygon:
|
||||
return polygon!.getPrivateKey(wallet);
|
||||
case WalletType.base:
|
||||
return base!.getPrivateKey(wallet);
|
||||
case WalletType.solana:
|
||||
return solana!.getPrivateKey(wallet);
|
||||
default:
|
||||
@@ -36,6 +39,8 @@ class KeyServiceImpl implements WalletConnectKeyService {
|
||||
return ethereum!.getPublicKey(wallet);
|
||||
case WalletType.polygon:
|
||||
return polygon!.getPublicKey(wallet);
|
||||
case WalletType.base:
|
||||
return base!.getPublicKey(wallet);
|
||||
case WalletType.solana:
|
||||
return solana!.getPublicKey(wallet);
|
||||
default:
|
||||
@@ -51,6 +56,7 @@ class KeyServiceImpl implements WalletConnectKeyService {
|
||||
'eip155:1',
|
||||
'eip155:5',
|
||||
'eip155:137',
|
||||
'eip155:8453',
|
||||
'eip155:42161',
|
||||
'eip155:80001',
|
||||
],
|
||||
|
||||
@@ -25,6 +25,7 @@ import 'package:cake_wallet/view_model/hardware_wallet/ledger_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart';
|
||||
import 'package:cake_wallet/wallet_type_utils.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/utils/payment_request.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/src/widgets/bottom_sheet/base_bottom_sheet_widget.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:cake_wallet/src/widgets/bottom_sheet/swap_details_bottom_sheet.d
|
||||
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
|
||||
import 'package:cake_wallet/utils/address_formatter.dart';
|
||||
import 'package:cake_wallet/utils/debounce.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:cw_core/crypto_amount_format.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -136,7 +137,7 @@ class SwapConfirmationContentState extends State<SwapConfirmationContent> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final detectedCurrencyName = walletTypeToCryptoCurrency(widget.paymentFlowResult.walletType!);
|
||||
final detectedCurrency = walletTypeToCryptoCurrency(widget.paymentFlowResult.walletType!);
|
||||
|
||||
return Form(
|
||||
key: _formKey,
|
||||
@@ -159,7 +160,7 @@ class SwapConfirmationContentState extends State<SwapConfirmationContent> {
|
||||
const SizedBox(width: 12),
|
||||
CakeImageWidget(
|
||||
imageUrl:
|
||||
walletTypeToCryptoCurrency(widget.paymentFlowResult.walletType!).iconPath!,
|
||||
detectedCurrency.iconPath!,
|
||||
width: 32,
|
||||
height: 32,
|
||||
),
|
||||
@@ -168,7 +169,7 @@ class SwapConfirmationContentState extends State<SwapConfirmationContent> {
|
||||
const SizedBox(height: 16),
|
||||
SwapConfirmationTextfield(
|
||||
key: ValueKey('swap_confirmation_bottomsheet_amount_textfield_key'),
|
||||
hintText: 'Amount (${detectedCurrencyName})',
|
||||
hintText: 'Amount (${detectedCurrency})',
|
||||
focusNode: _amountFocus,
|
||||
controller: _amountController,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true, signed: false),
|
||||
@@ -226,7 +227,7 @@ class SwapConfirmationContentState extends State<SwapConfirmationContent> {
|
||||
min != null
|
||||
? Text(
|
||||
key: ValueKey('min_limit_text_key'),
|
||||
S.of(context).min_value(min, detectedCurrencyName.toString()),
|
||||
S.of(context).min_value(min, detectedCurrency.toString()),
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
fontSize: 10,
|
||||
height: 1.2,
|
||||
@@ -238,7 +239,7 @@ class SwapConfirmationContentState extends State<SwapConfirmationContent> {
|
||||
max != null
|
||||
? Text(
|
||||
key: ValueKey('max_limit_text_key'),
|
||||
S.of(context).max_value(max, detectedCurrencyName.toString()),
|
||||
S.of(context).max_value(max, detectedCurrency.toString()),
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
fontSize: 10,
|
||||
height: 1.2,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/src/widgets/bottom_sheet/base_bottom_sheet_widget.dart';
|
||||
import 'package:cake_wallet/src/widgets/standard_list.dart';
|
||||
@@ -94,7 +95,7 @@ class _WalletSwitcherContent extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
walletTypeToCryptoCurrency(wallet.type).iconPath!,
|
||||
walletTypeToCryptoCurrency(wallet.type).normalizedIconPath!,
|
||||
width: 32,
|
||||
height: 32,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user