mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +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
@@ -12,6 +12,7 @@ const wowneroOutputPath = 'lib/wownero/wownero.dart';
|
||||
const zanoOutputPath = 'lib/zano/zano.dart';
|
||||
const decredOutputPath = 'lib/decred/decred.dart';
|
||||
const dogecoinOutputPath = 'lib/dogecoin/dogecoin.dart';
|
||||
const baseOutputPath = 'lib/base/base.dart';
|
||||
const walletTypesPath = 'lib/wallet_types.g.dart';
|
||||
const secureStoragePath = 'lib/core/secure_storage.dart';
|
||||
const pubspecDefaultPath = 'pubspec_default.yaml';
|
||||
@@ -32,6 +33,7 @@ Future<void> main(List<String> args) async {
|
||||
final hasZano = args.contains('${prefix}zano');
|
||||
final hasDecred = args.contains('${prefix}decred');
|
||||
final hasDogecoin = args.contains('${prefix}dogecoin');
|
||||
final hasBase = args.contains('${prefix}base');
|
||||
final excludeFlutterSecureStorage = args.contains('${prefix}excludeFlutterSecureStorage');
|
||||
|
||||
await generateBitcoin(hasBitcoin);
|
||||
@@ -47,6 +49,7 @@ Future<void> main(List<String> args) async {
|
||||
// await generateBanano(hasEthereum);
|
||||
await generateDecred(hasDecred);
|
||||
await generateDogecoin(hasDogecoin);
|
||||
await generateBase(hasBase);
|
||||
|
||||
await generatePubspec(
|
||||
hasMonero: hasMonero,
|
||||
@@ -63,6 +66,7 @@ Future<void> main(List<String> args) async {
|
||||
hasZano: hasZano,
|
||||
hasDecred: hasDecred,
|
||||
hasDogecoin: hasDogecoin,
|
||||
hasBase: hasBase,
|
||||
);
|
||||
await generateWalletTypes(
|
||||
hasMonero: hasMonero,
|
||||
@@ -78,6 +82,7 @@ Future<void> main(List<String> args) async {
|
||||
hasZano: hasZano,
|
||||
hasDecred: hasDecred,
|
||||
hasDogecoin: hasDogecoin,
|
||||
hasBase: hasBase,
|
||||
);
|
||||
await injectSecureStorage(!excludeFlutterSecureStorage);
|
||||
}
|
||||
@@ -1497,6 +1502,132 @@ abstract class DogeCoin {
|
||||
await outputFile.writeAsString(output);
|
||||
}
|
||||
|
||||
Future<void> generateBase(bool hasImplementation) async {
|
||||
final outputFile = File(baseOutputPath);
|
||||
const baseCommonHeaders = """
|
||||
import 'package:cake_wallet/view_model/send/output.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/erc20_token.dart';
|
||||
import 'package:cw_core/hardware/hardware_account_data.dart';
|
||||
import 'package:cw_core/hardware/hardware_wallet_service.dart';
|
||||
import 'package:cw_core/output_info.dart';
|
||||
import 'package:cw_core/pending_transaction.dart';
|
||||
import 'package:cw_core/transaction_info.dart';
|
||||
import 'package:cw_core/transaction_priority.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_credentials.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/wallet_service.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:ledger_flutter_plus/ledger_flutter_plus.dart' as ledger;
|
||||
import 'package:bitbox_flutter/bitbox_flutter.dart' as bitbox;
|
||||
import 'package:web3dart/web3dart.dart';
|
||||
|
||||
""";
|
||||
const baseCWHeaders = """
|
||||
import 'package:cw_evm/evm_chain_formatter.dart';
|
||||
import 'package:cw_evm/evm_chain_mnemonics.dart';
|
||||
import 'package:cw_evm/evm_chain_transaction_credentials.dart';
|
||||
import 'package:cw_evm/evm_chain_transaction_info.dart';
|
||||
import 'package:cw_evm/evm_chain_transaction_priority.dart';
|
||||
import 'package:cw_evm/evm_chain_wallet_creation_credentials.dart';
|
||||
import 'package:cw_evm/hardware/evm_chain_ledger_credentials.dart';
|
||||
import 'package:cw_evm/hardware/evm_chain_bitbox_credentials.dart';
|
||||
import 'package:cw_evm/evm_chain_wallet.dart';
|
||||
import 'package:cw_evm/hardware/evm_chain_bitbox_service.dart';
|
||||
import 'package:cw_evm/hardware/evm_chain_ledger_service.dart';
|
||||
|
||||
import 'package:cw_base/base_client.dart';
|
||||
import 'package:cw_base/base_wallet.dart';
|
||||
import 'package:cw_base/base_wallet_service.dart';
|
||||
import 'package:cw_base/default_base_erc20_tokens.dart';
|
||||
import 'package:eth_sig_util/util/utils.dart';
|
||||
|
||||
""";
|
||||
const baseCwPart = "part 'cw_base.dart';";
|
||||
const baseContent = """
|
||||
abstract class Base {
|
||||
List<String> getBaseWordList(String language);
|
||||
WalletService createBaseWalletService(Box<WalletInfo> walletInfoSource, bool isDirect);
|
||||
WalletCredentials createBaseNewWalletCredentials(
|
||||
{required String name,
|
||||
WalletInfo? walletInfo,
|
||||
String? password,
|
||||
String? mnemonic,
|
||||
String? passphrase});
|
||||
WalletCredentials createBaseRestoreWalletFromSeedCredentials(
|
||||
{required String name,
|
||||
required String mnemonic,
|
||||
required String password,
|
||||
String? passphrase});
|
||||
WalletCredentials createBaseRestoreWalletFromPrivateKey(
|
||||
{required String name, required String privateKey, required String password});
|
||||
WalletCredentials createBaseHardwareWalletCredentials(
|
||||
{required String name, required HardwareAccountData hwAccountData, WalletInfo? walletInfo});
|
||||
String getAddress(WalletBase wallet);
|
||||
String getPrivateKey(WalletBase wallet);
|
||||
String getPublicKey(WalletBase wallet);
|
||||
TransactionPriority getDefaultTransactionPriority();
|
||||
TransactionPriority getBaseTransactionPrioritySlow();
|
||||
List<TransactionPriority> getTransactionPriorities();
|
||||
TransactionPriority deserializeBaseTransactionPriority(int raw);
|
||||
|
||||
Object createBaseTransactionCredentials(
|
||||
List<Output> outputs, {
|
||||
required TransactionPriority priority,
|
||||
required CryptoCurrency currency,
|
||||
int? feeRate,
|
||||
});
|
||||
|
||||
Object createBaseTransactionCredentialsRaw(
|
||||
List<OutputInfo> outputs, {
|
||||
TransactionPriority? priority,
|
||||
required CryptoCurrency currency,
|
||||
required int feeRate,
|
||||
});
|
||||
|
||||
int formatterBaseParseAmount(String amount);
|
||||
double formatterBaseAmountToDouble(
|
||||
{TransactionInfo? transaction, BigInt? amount, int exponent = 18});
|
||||
List<Erc20Token> getERC20Currencies(WalletBase wallet);
|
||||
Future<void> addErc20Token(WalletBase wallet, CryptoCurrency token);
|
||||
Future<void> deleteErc20Token(WalletBase wallet, CryptoCurrency token);
|
||||
Future<void> removeTokenTransactionsInHistory(WalletBase wallet, CryptoCurrency token);
|
||||
Future<Erc20Token?> getErc20Token(WalletBase wallet, String contractAddress);
|
||||
|
||||
Future<PendingTransaction> createTokenApproval(WalletBase wallet, BigInt amount, String spender,
|
||||
CryptoCurrency token, TransactionPriority priority);
|
||||
|
||||
CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo transaction);
|
||||
void updateBaseScanUsageState(WalletBase wallet, bool isEnabled);
|
||||
Web3Client? getWeb3Client(WalletBase wallet);
|
||||
String getTokenAddress(CryptoCurrency asset);
|
||||
|
||||
void setHardwareWalletService(WalletBase wallet, HardwareWalletService service);
|
||||
HardwareWalletService getLedgerHardwareWalletService(ledger.LedgerConnection connection);
|
||||
HardwareWalletService getBitboxHardwareWalletService(bitbox.BitboxManager manager);
|
||||
List<String> getDefaultTokenContractAddresses();
|
||||
bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress);
|
||||
}
|
||||
""";
|
||||
|
||||
const baseEmptyDefinition = 'Base? base;\n';
|
||||
const baseCWDefinition = 'Base? base = CWBase();\n';
|
||||
|
||||
final output = '$baseCommonHeaders\n' +
|
||||
(hasImplementation ? '$baseCWHeaders\n' : '\n') +
|
||||
(hasImplementation ? '$baseCwPart\n\n' : '\n') +
|
||||
(hasImplementation ? baseCWDefinition : baseEmptyDefinition) +
|
||||
'\n' +
|
||||
baseContent;
|
||||
|
||||
if (outputFile.existsSync()) {
|
||||
await outputFile.delete();
|
||||
}
|
||||
|
||||
await outputFile.writeAsString(output);
|
||||
}
|
||||
|
||||
Future<void> generatePubspec({
|
||||
required bool hasMonero,
|
||||
required bool hasBitcoin,
|
||||
@@ -1512,6 +1643,7 @@ Future<void> generatePubspec({
|
||||
required bool hasZano,
|
||||
required bool hasDecred,
|
||||
required bool hasDogecoin,
|
||||
required bool hasBase,
|
||||
}) async {
|
||||
const cwCore = """
|
||||
cw_core:
|
||||
@@ -1580,6 +1712,11 @@ Future<void> generatePubspec({
|
||||
cw_dogecoin:
|
||||
path: ./cw_dogecoin
|
||||
""";
|
||||
const cwBase = """
|
||||
cw_base:
|
||||
path: ./cw_base
|
||||
""";
|
||||
|
||||
final inputFile = File(pubspecOutputPath);
|
||||
final inputText = await inputFile.readAsString();
|
||||
final inputLines = inputText.split('\n');
|
||||
@@ -1649,6 +1786,10 @@ Future<void> generatePubspec({
|
||||
output += '\n$cwDogecoin';
|
||||
}
|
||||
|
||||
if (hasBase) {
|
||||
output += '\n$cwBase';
|
||||
}
|
||||
|
||||
final outputLines = output.split('\n');
|
||||
inputLines.insertAll(dependenciesIndex + 1, outputLines);
|
||||
final outputContent = inputLines.join('\n');
|
||||
@@ -1675,6 +1816,7 @@ Future<void> generateWalletTypes({
|
||||
required bool hasZano,
|
||||
required bool hasDecred,
|
||||
required bool hasDogecoin,
|
||||
required bool hasBase,
|
||||
}) async {
|
||||
final walletTypesFile = File(walletTypesPath);
|
||||
|
||||
@@ -1706,6 +1848,10 @@ Future<void> generateWalletTypes({
|
||||
outputContent += '\tWalletType.dogecoin,\n';
|
||||
}
|
||||
|
||||
if (hasBase) {
|
||||
outputContent += '\tWalletType.base,\n';
|
||||
}
|
||||
|
||||
if (hasBitcoinCash) {
|
||||
outputContent += '\tWalletType.bitcoinCash,\n';
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ class SecretKey {
|
||||
SecretKey('litecoinTestWalletSeeds', () => ''),
|
||||
SecretKey('bitcoinCashTestWalletSeeds', () => ''),
|
||||
SecretKey('polygonTestWalletSeeds', () => ''),
|
||||
SecretKey('baseTestWalletSeeds', () => ''),
|
||||
SecretKey('solanaTestWalletSeeds', () => ''),
|
||||
SecretKey('polygonTestWalletSeeds', () => ''),
|
||||
SecretKey('tronTestWalletSeeds', () => ''),
|
||||
SecretKey('nanoTestWalletSeeds', () => ''),
|
||||
SecretKey('wowneroTestWalletSeeds', () => ''),
|
||||
@@ -66,6 +66,7 @@ class SecretKey {
|
||||
SecretKey('litecoinTestWalletReceiveAddress', () => ''),
|
||||
SecretKey('bitcoinCashTestWalletReceiveAddress', () => ''),
|
||||
SecretKey('polygonTestWalletReceiveAddress', () => ''),
|
||||
SecretKey('baseTestWalletReceiveAddress', () => ''),
|
||||
SecretKey('solanaTestWalletReceiveAddress', () => ''),
|
||||
SecretKey('tronTestWalletReceiveAddress', () => ''),
|
||||
SecretKey('nanoTestWalletReceiveAddress', () => ''),
|
||||
|
||||
Reference in New Issue
Block a user