mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
CW-1194-Add-Arbitrum-Wallet (#2587)
* feat: initialize cw_arbitrum package with essential files - Implement ArbitrumClient for transaction handling - Add ArbitrumWallet and related classes for wallet management - Establish transaction history and info classes for Arbitrum transactions - Add ArbitrumWalletService for wallet operations and management * feat: Add arbitrum related secrets to workflow * feat: Add nodes for arbitrum * feat: Add Arbitrum support to cryptocurrency handling * refactor: Update Arbitrum currency references from 'ARB' to 'ETH' * feat: Add Arbitrum support to wallet type and transaction handling * feat: Add Arbitrum URL schemes to Android and iOS configurations * feat: Add Arbitrum SVG icons and a WebP image * feat: Setup Arbitrum proxy * fix: Add localization * feat: Integrate Arbitrum support across various configurations and files - Updated cakewallet.bat to include Arbitrum in app configuration. - Added Arbitrum node list to pubspec_base.yaml. - Modified Android, iOS, Linux, and macOS app configuration scripts to support Arbitrum. - Introduced Arbitrum output path and generation logic in configure.dart. - Enhanced wallet type and pubspec generation to include Arbitrum. - Added Arbitrum-related secrets in secret_key.dart. * feat: Enhance Arbitrum integration with new URI class and updates across various components - Introduced ArbitrumURI class for handling Arbitrum payment URIs. - Updated seed validator, wallet creation service, and other components to support Arbitrum. - Added Arbitrum node handling in default settings migration and node list management. - Enhanced preferences and settings store to include Arbitrum-specific configurations. - Updated QR utility and token utilities to accommodate Arbitrum functionalities. * feat: Add Arbitrum support to various buy providers - Updated DFXBuyProvider, KryptonimBuyProvider, OnRamperBuyProvider, and RobinhoodBuyProvider to include Arbitrum wallet type and blockchain references. - Enhanced integration for Arbitrum across multiple components to ensure consistent support. * feat: Implement Arbitrum support in wallet selection and settings - Added Arbitrum wallet type handling in common test flows and wallet services. - Integrated Arbitrum icons in desktop wallet selection and menu widgets. - Updated privacy settings to include ArbiScan options. - Enhanced key service to support Arbitrum private and public key retrieval. * feat: Expand Arbitrum support across various view models and components - Integrated Arbitrum wallet type handling in advanced privacy settings, transaction details, and wallet management. - Added Arbitrum-specific methods for transaction and wallet creation, restoration, and fee management. - Updated dashboard and home settings to accommodate Arbitrum functionalities, including token management and transaction display. - Enhanced exchange and send view models to support Arbitrum transactions and currency handling. - Included Arbitrum in wallet address list and privacy settings for improved user experience. * refactor: Simplify token initialization in Arbitrum wallet service - Removed the migration flag from the addInitialTokens method in ArbitrumWalletService. - Updated addInitialTokens method in ArbitrumWallet to handle existing tokens more efficiently. - Enhanced initial token retrieval logic in DefaultArbitrumErc20Tokens to prioritize iconPath assignment. - Improved token update logic in BaseWallet for consistency across wallet services. * chore: Update Dart SDK constraints in pubspec.yaml * fix: Update file paths for arbitrum assets * fix: Correct box name formatting in Arbitrum wallet initialization * Update .github/workflows/pr_test_build_android.yml [skip ci * Update .github/workflows/pr_test_build_android.yml * fix: Add missing evm params * fix: Remove duplicate method declaration * refactor: simplify isSwapsXyzSendingEVMTokenSwap check * fix: Update arbitrum configs with sql storage update * feat: Add estimated fee retrieval for Arbitrum and revamp priority fee handling for EVMChainWallet * refactor: Update transaction priority handling and estimated fee calculations across EVMChain chains, also remove priority fee levels for Arbitrum --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
co-authored by
Omar Hatem
parent
569ee04449
commit
2da3ba5730
+151
-4
@@ -13,6 +13,7 @@ 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 arbitrumOutputPath = 'lib/arbitrum/arbitrum.dart';
|
||||
const walletTypesPath = 'lib/wallet_types.g.dart';
|
||||
const secureStoragePath = 'lib/core/secure_storage.dart';
|
||||
const pubspecDefaultPath = 'pubspec_default.yaml';
|
||||
@@ -34,6 +35,7 @@ Future<void> main(List<String> args) async {
|
||||
final hasDecred = args.contains('${prefix}decred');
|
||||
final hasDogecoin = args.contains('${prefix}dogecoin');
|
||||
final hasBase = args.contains('${prefix}base');
|
||||
final hasArbitrum = args.contains('${prefix}arbitrum');
|
||||
final excludeFlutterSecureStorage = args.contains('${prefix}excludeFlutterSecureStorage');
|
||||
|
||||
await generateBitcoin(hasBitcoin);
|
||||
@@ -50,6 +52,7 @@ Future<void> main(List<String> args) async {
|
||||
await generateDecred(hasDecred);
|
||||
await generateDogecoin(hasDogecoin);
|
||||
await generateBase(hasBase);
|
||||
await generateArbitrum(hasArbitrum);
|
||||
|
||||
await generatePubspec(
|
||||
hasMonero: hasMonero,
|
||||
@@ -67,6 +70,7 @@ Future<void> main(List<String> args) async {
|
||||
hasDecred: hasDecred,
|
||||
hasDogecoin: hasDogecoin,
|
||||
hasBase: hasBase,
|
||||
hasArbitrum: hasArbitrum,
|
||||
);
|
||||
await generateWalletTypes(
|
||||
hasMonero: hasMonero,
|
||||
@@ -83,6 +87,7 @@ Future<void> main(List<String> args) async {
|
||||
hasDecred: hasDecred,
|
||||
hasDogecoin: hasDogecoin,
|
||||
hasBase: hasBase,
|
||||
hasArbitrum: hasArbitrum,
|
||||
);
|
||||
await injectSecureStorage(!excludeFlutterSecureStorage);
|
||||
}
|
||||
@@ -795,6 +800,8 @@ abstract class Ethereum {
|
||||
HardwareWalletService getTrezorHardwareWalletService(trezor.TrezorConnect connect);
|
||||
List<String> getDefaultTokenContractAddresses();
|
||||
bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress);
|
||||
String? getEthereumNativeEstimatedFee(WalletBase wallet);
|
||||
String? getEthereumERC20EstimatedFee(WalletBase wallet);
|
||||
}
|
||||
""";
|
||||
|
||||
@@ -916,6 +923,8 @@ abstract class Polygon {
|
||||
HardwareWalletService getTrezorHardwareWalletService(trezor.TrezorConnect connect);
|
||||
List<String> getDefaultTokenContractAddresses();
|
||||
bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress);
|
||||
String? getPolygonNativeEstimatedFee(WalletBase wallet);
|
||||
String? getPolygonERC20EstimatedFee(WalletBase wallet);
|
||||
}
|
||||
""";
|
||||
|
||||
@@ -1491,9 +1500,7 @@ abstract class DogeCoin {
|
||||
final output = '$dogecoinCommonHeaders\n' +
|
||||
(hasImplementation ? '$dogecoinCWHeaders\n' : '\n') +
|
||||
(hasImplementation ? '$dogecoinCwPart\n\n' : '\n') +
|
||||
(hasImplementation
|
||||
? dogecoinCWDefinition
|
||||
: dogecoinEmptyDefinition) +
|
||||
(hasImplementation ? dogecoinCWDefinition : dogecoinEmptyDefinition) +
|
||||
'\n' +
|
||||
dogecoinContent;
|
||||
|
||||
@@ -1612,6 +1619,8 @@ abstract class Base {
|
||||
HardwareWalletService getBitboxHardwareWalletService(bitbox.BitboxManager manager);
|
||||
List<String> getDefaultTokenContractAddresses();
|
||||
bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress);
|
||||
String? getBaseNativeEstimatedFee(WalletBase wallet);
|
||||
String? getBaseERC20EstimatedFee(WalletBase wallet);
|
||||
}
|
||||
""";
|
||||
|
||||
@@ -1632,6 +1641,131 @@ abstract class Base {
|
||||
await outputFile.writeAsString(output);
|
||||
}
|
||||
|
||||
Future<void> generateArbitrum(bool hasImplementation) async {
|
||||
final outputFile = File(arbitrumOutputPath);
|
||||
const arbitrumCommonHeaders = """
|
||||
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 arbitrumCWHeaders = """
|
||||
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_arbitrum/arbitrum_client.dart';
|
||||
import 'package:cw_arbitrum/arbitrum_wallet.dart';
|
||||
import 'package:cw_arbitrum/arbitrum_wallet_service.dart';
|
||||
import 'package:cw_arbitrum/default_arbitrum_erc20_tokens.dart';
|
||||
import 'package:eth_sig_util/util/utils.dart';
|
||||
|
||||
""";
|
||||
const arbitrumCwPart = "part 'cw_arbitrum.dart';";
|
||||
const arbitrumContent = """
|
||||
abstract class Arbitrum {
|
||||
List<String> getArbitrumWordList(String language);
|
||||
WalletService createArbitrumWalletService(bool isDirect);
|
||||
WalletCredentials createArbitrumNewWalletCredentials(
|
||||
{required String name,
|
||||
WalletInfo? walletInfo,
|
||||
String? password,
|
||||
String? mnemonic,
|
||||
String? passphrase});
|
||||
WalletCredentials createArbitrumRestoreWalletFromSeedCredentials(
|
||||
{required String name,
|
||||
required String mnemonic,
|
||||
required String password,
|
||||
String? passphrase});
|
||||
WalletCredentials createArbitrumRestoreWalletFromPrivateKey(
|
||||
{required String name, required String privateKey, required String password});
|
||||
WalletCredentials createArbitrumHardwareWalletCredentials(
|
||||
{required String name, required HardwareAccountData hwAccountData, WalletInfo? walletInfo});
|
||||
String getAddress(WalletBase wallet);
|
||||
String getPrivateKey(WalletBase wallet);
|
||||
String getPublicKey(WalletBase wallet);
|
||||
|
||||
Object createArbitrumTransactionCredentials(
|
||||
List<Output> outputs, {
|
||||
required CryptoCurrency currency,
|
||||
int? feeRate,
|
||||
});
|
||||
|
||||
Object createArbitrumTransactionCredentialsRaw(
|
||||
List<OutputInfo> outputs, {
|
||||
required CryptoCurrency currency,
|
||||
required int feeRate,
|
||||
});
|
||||
|
||||
int formatterArbitrumParseAmount(String amount);
|
||||
double formatterArbitrumAmountToDouble(
|
||||
{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);
|
||||
|
||||
CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo transaction);
|
||||
void updateArbitrumScanUsageState(WalletBase wallet, bool isEnabled);
|
||||
Web3Client? getWeb3Client(WalletBase wallet);
|
||||
String getTokenAddress(CryptoCurrency asset);
|
||||
|
||||
Future<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);
|
||||
Future<bool> isApprovalRequired(WalletBase wallet, String tokenContract, String spender, BigInt requiredAmount);
|
||||
Future<PendingTransaction> createRawCallDataTransaction(WalletBase wallet, String to, String dataHex, BigInt valueWei);
|
||||
String? getArbitrumNativeEstimatedFee(WalletBase wallet);
|
||||
String? getArbitrumERC20EstimatedFee(WalletBase wallet);
|
||||
}
|
||||
|
||||
""";
|
||||
|
||||
const arbitrumEmptyDefinition = 'Arbitrum? arbitrum;\n';
|
||||
const arbitrumCWDefinition = 'Arbitrum? arbitrum = CWArbitrum();\n';
|
||||
|
||||
final output = '$arbitrumCommonHeaders\n' +
|
||||
(hasImplementation ? '$arbitrumCWHeaders\n' : '\n') +
|
||||
(hasImplementation ? '$arbitrumCwPart\n\n' : '\n') +
|
||||
(hasImplementation ? arbitrumCWDefinition : arbitrumEmptyDefinition) +
|
||||
'\n' +
|
||||
arbitrumContent;
|
||||
|
||||
if (outputFile.existsSync()) {
|
||||
await outputFile.delete();
|
||||
}
|
||||
|
||||
await outputFile.writeAsString(output);
|
||||
}
|
||||
|
||||
Future<void> generatePubspec({
|
||||
required bool hasMonero,
|
||||
required bool hasBitcoin,
|
||||
@@ -1648,6 +1782,7 @@ Future<void> generatePubspec({
|
||||
required bool hasDecred,
|
||||
required bool hasDogecoin,
|
||||
required bool hasBase,
|
||||
required bool hasArbitrum,
|
||||
}) async {
|
||||
const cwCore = """
|
||||
cw_core:
|
||||
@@ -1720,7 +1855,10 @@ Future<void> generatePubspec({
|
||||
cw_base:
|
||||
path: ./cw_base
|
||||
""";
|
||||
|
||||
const cwArbitrum = """
|
||||
cw_arbitrum:
|
||||
path: ./cw_arbitrum
|
||||
""";
|
||||
final inputFile = File(pubspecOutputPath);
|
||||
final inputText = await inputFile.readAsString();
|
||||
final inputLines = inputText.split('\n');
|
||||
@@ -1794,6 +1932,10 @@ Future<void> generatePubspec({
|
||||
output += '\n$cwBase';
|
||||
}
|
||||
|
||||
if (hasArbitrum) {
|
||||
output += '\n$cwArbitrum';
|
||||
}
|
||||
|
||||
final outputLines = output.split('\n');
|
||||
inputLines.insertAll(dependenciesIndex + 1, outputLines);
|
||||
final outputContent = inputLines.join('\n');
|
||||
@@ -1821,6 +1963,7 @@ Future<void> generateWalletTypes({
|
||||
required bool hasDecred,
|
||||
required bool hasDogecoin,
|
||||
required bool hasBase,
|
||||
required bool hasArbitrum,
|
||||
}) async {
|
||||
final walletTypesFile = File(walletTypesPath);
|
||||
|
||||
@@ -1856,6 +1999,10 @@ Future<void> generateWalletTypes({
|
||||
outputContent += '\tWalletType.base,\n';
|
||||
}
|
||||
|
||||
if (hasArbitrum) {
|
||||
outputContent += '\tWalletType.arbitrum,\n';
|
||||
}
|
||||
|
||||
if (hasBitcoinCash) {
|
||||
outputContent += '\tWalletType.bitcoinCash,\n';
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ class SecretKey {
|
||||
SecretKey('bitcoinCashTestWalletSeeds', () => ''),
|
||||
SecretKey('polygonTestWalletSeeds', () => ''),
|
||||
SecretKey('baseTestWalletSeeds', () => ''),
|
||||
SecretKey('arbitrumTestWalletSeeds', () => ''),
|
||||
SecretKey('solanaTestWalletSeeds', () => ''),
|
||||
SecretKey('tronTestWalletSeeds', () => ''),
|
||||
SecretKey('nanoTestWalletSeeds', () => ''),
|
||||
@@ -67,6 +68,7 @@ class SecretKey {
|
||||
SecretKey('bitcoinCashTestWalletReceiveAddress', () => ''),
|
||||
SecretKey('polygonTestWalletReceiveAddress', () => ''),
|
||||
SecretKey('baseTestWalletReceiveAddress', () => ''),
|
||||
SecretKey('arbitrumTestWalletReceiveAddress', () => ''),
|
||||
SecretKey('solanaTestWalletReceiveAddress', () => ''),
|
||||
SecretKey('tronTestWalletReceiveAddress', () => ''),
|
||||
SecretKey('nanoTestWalletReceiveAddress', () => ''),
|
||||
|
||||
Reference in New Issue
Block a user