2
3
const bitcoinOutputPath = 'lib/bitcoin/bitcoin.dart';
4
const moneroOutputPath = 'lib/monero/monero.dart';
5
-const ethereumOutputPath = 'lib/ethereum/ethereum.dart';
5
const bitcoinCashOutputPath = 'lib/bitcoin_cash/bitcoin_cash.dart';
6
const nanoOutputPath = 'lib/nano/nano.dart';
8
-const polygonOutputPath = 'lib/polygon/polygon.dart';
7
const solanaOutputPath = 'lib/solana/solana.dart';
8
const tronOutputPath = 'lib/tron/tron.dart';
9
const wowneroOutputPath = 'lib/wownero/wownero.dart';
10
const zanoOutputPath = 'lib/zano/zano.dart';
11
const decredOutputPath = 'lib/decred/decred.dart';
12
const dogecoinOutputPath = 'lib/dogecoin/dogecoin.dart';
15
-const baseOutputPath = 'lib/base/base.dart';
16
-const arbitrumOutputPath = 'lib/arbitrum/arbitrum.dart';
13
+const evmOutputPath = 'lib/evm/evm.dart';
14
const walletTypesPath = 'lib/wallet_types.g.dart';
15
const secureStoragePath = 'lib/core/secure_storage.dart';
16
const pubspecDefaultPath = 'pubspec_default.yaml';
33
final hasDogecoin = args.contains('${prefix}dogecoin');
34
final hasBase = args.contains('${prefix}base');
35
final hasArbitrum = args.contains('${prefix}arbitrum');
36
+ final hasEVM = hasEthereum || hasPolygon || hasBase || hasArbitrum;
37
final excludeFlutterSecureStorage = args.contains('${prefix}excludeFlutterSecureStorage');
38
39
await generateBitcoin(hasBitcoin);
40
await generateMonero(hasMonero);
43
- await generateEthereum(hasEthereum);
41
await generateBitcoinCash(hasBitcoinCash);
42
await generateNano(hasNano);
46
- await generatePolygon(hasPolygon);
43
await generateSolana(hasSolana);
44
await generateTron(hasTron);
45
await generateWownero(hasWownero);
47
// await generateBanano(hasEthereum);
48
await generateDecred(hasDecred);
49
await generateDogecoin(hasDogecoin);
54
- await generateBase(hasBase);
55
- await generateArbitrum(hasArbitrum);
50
+ await generateEVM(hasEVM);
51
52
await generatePubspec(
53
hasMonero: hasMonero,
693
await outputFile.writeAsString(output);
694
}
695
701
-Future<void> generateEthereum(bool hasImplementation) async {
702
- final outputFile = File(ethereumOutputPath);
703
- const ethereumCommonHeaders = """
704
-import 'package:cake_wallet/view_model/send/output.dart';
705
-import 'package:cw_core/crypto_currency.dart';
706
-import 'package:cw_core/erc20_token.dart';
707
-import 'package:cw_core/hardware/hardware_account_data.dart';
708
-import 'package:cw_core/hardware/hardware_wallet_service.dart';
709
-import 'package:cw_core/output_info.dart';
710
-import 'package:cw_core/pending_transaction.dart';
711
-import 'package:cw_core/transaction_info.dart';
712
-import 'package:cw_core/transaction_priority.dart';
713
-import 'package:cw_core/wallet_base.dart';
714
-import 'package:cw_core/wallet_credentials.dart';
715
-import 'package:cw_core/wallet_info.dart';
716
-import 'package:cw_core/wallet_service.dart';
717
-import 'package:cw_core/utils/print_verbose.dart';
718
-import 'package:hive/hive.dart';
719
-import 'package:ledger_flutter_plus/ledger_flutter_plus.dart' as ledger;
720
-import 'package:bitbox_flutter/bitbox_flutter.dart' as bitbox;
721
-import 'package:trezor_connect/trezor_connect.dart' as trezor;
722
-import 'package:web3dart/web3dart.dart';
723
-
724
-""";
725
- const ethereumCWHeaders = """
726
-import 'package:cw_evm/evm_chain_formatter.dart';
727
-import 'package:cw_evm/evm_chain_mnemonics.dart';
728
-import 'package:cw_evm/evm_chain_transaction_credentials.dart';
729
-import 'package:cw_evm/evm_chain_transaction_info.dart';
730
-import 'package:cw_evm/evm_chain_transaction_priority.dart';
731
-import 'package:cw_evm/evm_chain_wallet_creation_credentials.dart';
732
-import 'package:cw_evm/hardware/evm_chain_bitbox_credentials.dart';
733
-import 'package:cw_evm/hardware/evm_chain_ledger_credentials.dart';
734
-import 'package:cw_evm/hardware/evm_chain_trezor_credentials.dart';
735
-import 'package:cw_evm/evm_chain_wallet.dart';
736
-import 'package:cw_evm/hardware/evm_chain_bitbox_service.dart';
737
-import 'package:cw_evm/hardware/evm_chain_ledger_service.dart';
738
-import 'package:cw_evm/hardware/evm_chain_trezor_service.dart';
739
-
740
-import 'package:cw_ethereum/ethereum_client.dart';
741
-import 'package:cw_ethereum/ethereum_wallet.dart';
742
-import 'package:cw_ethereum/ethereum_wallet_service.dart';
743
-import 'package:cw_ethereum/default_ethereum_erc20_tokens.dart';
744
-import 'package:cw_ethereum/deuro/deuro_savings.dart';
745
-
746
-import 'package:eth_sig_util/util/utils.dart';
747
-
748
-""";
749
- const ethereumCwPart = "part 'cw_ethereum.dart';";
750
- const ethereumContent = """
751
-abstract class Ethereum {
752
- List<String> getEthereumWordList(String language);
753
- WalletService createEthereumWalletService(bool isDirect);
754
- WalletCredentials createEthereumNewWalletCredentials({required String name, WalletInfo? walletInfo, String? password, String? mnemonic, String? passphrase});
755
- WalletCredentials createEthereumRestoreWalletFromSeedCredentials({required String name, required String mnemonic, required String password, String? passphrase});
756
- WalletCredentials createEthereumRestoreWalletFromPrivateKey({required String name, required String privateKey, required String password});
757
- WalletCredentials createEthereumHardwareWalletCredentials({required String name, required HardwareAccountData hwAccountData, WalletInfo? walletInfo});
758
- String getAddress(WalletBase wallet);
759
- String getPrivateKey(WalletBase wallet);
760
- String getPublicKey(WalletBase wallet);
761
- TransactionPriority getDefaultTransactionPriority();
762
- TransactionPriority getEthereumTransactionPrioritySlow();
763
- List<TransactionPriority> getTransactionPriorities();
764
- TransactionPriority deserializeEthereumTransactionPriority(int raw);
765
-
766
- Object createEthereumTransactionCredentials(
767
- List<Output> outputs, {
768
- required TransactionPriority priority,
769
- required CryptoCurrency currency,
770
- int? feeRate,
771
- });
772
-
773
- Object createEthereumTransactionCredentialsRaw(
774
- List<OutputInfo> outputs, {
775
- TransactionPriority? priority,
776
- required CryptoCurrency currency,
777
- required int feeRate,
778
- });
779
-
780
- int formatterEthereumParseAmount(String amount);
781
- double formatterEthereumAmountToDouble({TransactionInfo? transaction, BigInt? amount, int exponent = 18});
782
- List<Erc20Token> getERC20Currencies(WalletBase wallet);
783
- Future<void> addErc20Token(WalletBase wallet, CryptoCurrency token);
784
- Future<void> deleteErc20Token(WalletBase wallet, CryptoCurrency token);
785
- Future<void> removeTokenTransactionsInHistory(WalletBase wallet, CryptoCurrency token);
786
- Future<Erc20Token?> getErc20Token(WalletBase wallet, String contractAddress);
787
-
788
- CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo transaction);
789
- void updateEtherscanUsageState(WalletBase wallet, bool isEnabled);
790
- Web3Client? getWeb3Client(WalletBase wallet);
791
- String getTokenAddress(CryptoCurrency asset);
792
-
793
- Future<bool> isApprovalRequired(WalletBase wallet, String tokenContract, String spender, BigInt requiredAmount);
794
- Future<PendingTransaction> createTokenApproval(WalletBase wallet, BigInt amount, String spender, CryptoCurrency token, TransactionPriority priority);
795
- Future<PendingTransaction> createRawCallDataTransaction(WalletBase wallet, String to, String dataHex, BigInt valueWei, TransactionPriority priority);
796
-
797
- Future<BigInt> getDEuroSavingsBalance(WalletBase wallet);
798
- Future<BigInt> getDEuroAccruedInterest(WalletBase wallet);
799
- Future<BigInt> getDEuroInterestRate(WalletBase wallet);
800
- Future<BigInt> getDEuroSavingsApproved(WalletBase wallet);
801
- Future<PendingTransaction> addDEuroSaving(WalletBase wallet, BigInt amount, TransactionPriority priority);
802
- Future<PendingTransaction> removeDEuroSaving(WalletBase wallet, BigInt amount, TransactionPriority priority);
803
- Future<PendingTransaction> reinvestDEuroInterest(WalletBase wallet, TransactionPriority priority);
804
- Future<PendingTransaction> enableDEuroSaving(WalletBase wallet, TransactionPriority priority);
805
-
806
- Future<void> setHardwareWalletService(WalletBase wallet, HardwareWalletService service);
807
- HardwareWalletService getLedgerHardwareWalletService(ledger.LedgerConnection connection);
808
- HardwareWalletService getBitboxHardwareWalletService(bitbox.BitboxManager manager);
809
- HardwareWalletService getTrezorHardwareWalletService(trezor.TrezorConnect connect);
810
- List<String> getDefaultTokenContractAddresses();
811
- bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress);
812
- String? getEthereumNativeEstimatedFee(WalletBase wallet);
813
- String? getEthereumERC20EstimatedFee(WalletBase wallet);
814
-}
815
- """;
816
-
817
- const ethereumEmptyDefinition = 'Ethereum? ethereum;\n';
818
- const ethereumCWDefinition = 'Ethereum? ethereum = CWEthereum();\n';
819
-
820
- final output = '$ethereumCommonHeaders\n' +
821
- (hasImplementation ? '$ethereumCWHeaders\n' : '\n') +
822
- (hasImplementation ? '$ethereumCwPart\n\n' : '\n') +
823
- (hasImplementation ? ethereumCWDefinition : ethereumEmptyDefinition) +
824
- '\n' +
825
- ethereumContent;
826
-
827
- if (outputFile.existsSync()) {
828
- await outputFile.delete();
829
- }
830
-
831
- await outputFile.writeAsString(output);
832
-}
833
-
834
-Future<void> generatePolygon(bool hasImplementation) async {
835
- final outputFile = File(polygonOutputPath);
836
- const polygonCommonHeaders = """
837
-import 'package:cake_wallet/view_model/send/output.dart';
838
-import 'package:cw_core/crypto_currency.dart';
839
-import 'package:cw_core/erc20_token.dart';
840
-import 'package:cw_core/hardware/hardware_account_data.dart';
841
-import 'package:cw_core/hardware/hardware_wallet_service.dart';
842
-import 'package:cw_core/output_info.dart';
843
-import 'package:cw_core/pending_transaction.dart';
844
-import 'package:cw_core/transaction_info.dart';
845
-import 'package:cw_core/transaction_priority.dart';
846
-import 'package:cw_core/wallet_base.dart';
847
-import 'package:cw_core/wallet_credentials.dart';
848
-import 'package:cw_core/wallet_info.dart';
849
-import 'package:cw_core/wallet_service.dart';
850
-import 'package:cw_core/utils/print_verbose.dart';
851
-import 'package:hive/hive.dart';
852
-import 'package:ledger_flutter_plus/ledger_flutter_plus.dart' as ledger;
853
-import 'package:bitbox_flutter/bitbox_flutter.dart' as bitbox;
854
-import 'package:trezor_connect/trezor_connect.dart' as trezor;
855
-import 'package:web3dart/web3dart.dart';
856
-
857
-""";
858
- const polygonCWHeaders = """
859
-import 'package:cw_evm/evm_chain_formatter.dart';
860
-import 'package:cw_evm/evm_chain_mnemonics.dart';
861
-import 'package:cw_evm/evm_chain_transaction_credentials.dart';
862
-import 'package:cw_evm/evm_chain_transaction_info.dart';
863
-import 'package:cw_evm/evm_chain_transaction_priority.dart';
864
-import 'package:cw_evm/evm_chain_wallet_creation_credentials.dart';
865
-import 'package:cw_evm/hardware/evm_chain_bitbox_credentials.dart';
866
-import 'package:cw_evm/hardware/evm_chain_ledger_credentials.dart';
867
-import 'package:cw_evm/hardware/evm_chain_trezor_credentials.dart';
868
-import 'package:cw_evm/evm_chain_wallet.dart';
869
-import 'package:cw_evm/hardware/evm_chain_bitbox_service.dart';
870
-import 'package:cw_evm/hardware/evm_chain_ledger_service.dart';
871
-import 'package:cw_evm/hardware/evm_chain_trezor_service.dart';
872
-
873
-import 'package:cw_polygon/polygon_client.dart';
874
-import 'package:cw_polygon/polygon_wallet.dart';
875
-import 'package:cw_polygon/polygon_wallet_service.dart';
876
-import 'package:cw_polygon/default_polygon_erc20_tokens.dart';
877
-
878
-import 'package:eth_sig_util/util/utils.dart';
879
-
880
-""";
881
- const polygonCwPart = "part 'cw_polygon.dart';";
882
- const polygonContent = """
883
-abstract class Polygon {
884
- List<String> getPolygonWordList(String language);
885
- WalletService createPolygonWalletService(bool isDirect);
886
- WalletCredentials createPolygonNewWalletCredentials({required String name, WalletInfo? walletInfo, String? password, String? mnemonic, String? passphrase});
887
- WalletCredentials createPolygonRestoreWalletFromSeedCredentials({required String name, required String mnemonic, required String password, String? passphrase});
888
- WalletCredentials createPolygonRestoreWalletFromPrivateKey({required String name, required String privateKey, required String password});
889
- WalletCredentials createPolygonHardwareWalletCredentials({required String name, required HardwareAccountData hwAccountData, WalletInfo? walletInfo});
890
- String getAddress(WalletBase wallet);
891
- String getPrivateKey(WalletBase wallet);
892
- String getPublicKey(WalletBase wallet);
893
- TransactionPriority getDefaultTransactionPriority();
894
- TransactionPriority getPolygonTransactionPrioritySlow();
895
- List<TransactionPriority> getTransactionPriorities();
896
- TransactionPriority deserializePolygonTransactionPriority(int raw);
897
-
898
- Object createPolygonTransactionCredentials(
899
- List<Output> outputs, {
900
- required TransactionPriority priority,
901
- required CryptoCurrency currency,
902
- int? feeRate,
903
- });
904
-
905
- Object createPolygonTransactionCredentialsRaw(
906
- List<OutputInfo> outputs, {
907
- TransactionPriority? priority,
908
- required CryptoCurrency currency,
909
- required int feeRate,
910
- });
911
-
912
- int formatterPolygonParseAmount(String amount);
913
- double formatterPolygonAmountToDouble({TransactionInfo? transaction, BigInt? amount, int exponent = 18});
914
- List<Erc20Token> getERC20Currencies(WalletBase wallet);
915
- Future<void> addErc20Token(WalletBase wallet, CryptoCurrency token);
916
- Future<void> deleteErc20Token(WalletBase wallet, CryptoCurrency token);
917
- Future<void> removeTokenTransactionsInHistory(WalletBase wallet, CryptoCurrency token);
918
- Future<Erc20Token?> getErc20Token(WalletBase wallet, String contractAddress);
919
-
920
- Future<bool> isApprovalRequired(WalletBase wallet, String tokenContract, String spender, BigInt requiredAmount);
921
- Future<PendingTransaction> createTokenApproval(WalletBase wallet, BigInt amount, String spender, CryptoCurrency token, TransactionPriority priority);
922
- Future<PendingTransaction> createRawCallDataTransaction(WalletBase wallet, String to, String dataHex, BigInt valueWei, TransactionPriority priority);
923
-
924
- CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo transaction);
925
- void updatePolygonScanUsageState(WalletBase wallet, bool isEnabled);
926
- Web3Client? getWeb3Client(WalletBase wallet);
927
- String getTokenAddress(CryptoCurrency asset);
928
-
929
- Future<void> setHardwareWalletService(WalletBase wallet, HardwareWalletService service);
930
- HardwareWalletService getLedgerHardwareWalletService(ledger.LedgerConnection connection);
931
- HardwareWalletService getBitboxHardwareWalletService(bitbox.BitboxManager manager);
932
- HardwareWalletService getTrezorHardwareWalletService(trezor.TrezorConnect connect);
933
- List<String> getDefaultTokenContractAddresses();
934
- bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress);
935
- String? getPolygonNativeEstimatedFee(WalletBase wallet);
936
- String? getPolygonERC20EstimatedFee(WalletBase wallet);
937
-}
938
- """;
939
-
940
- const polygonEmptyDefinition = 'Polygon? polygon;\n';
941
- const polygonCWDefinition = 'Polygon? polygon = CWPolygon();\n';
942
-
943
- final output = '$polygonCommonHeaders\n' +
944
- (hasImplementation ? '$polygonCWHeaders\n' : '\n') +
945
- (hasImplementation ? '$polygonCwPart\n\n' : '\n') +
946
- (hasImplementation ? polygonCWDefinition : polygonEmptyDefinition) +
947
- '\n' +
948
- polygonContent;
949
-
950
- if (outputFile.existsSync()) {
951
- await outputFile.delete();
952
- }
953
-
954
- await outputFile.writeAsString(output);
955
-}
956
-
696
Future<void> generateBitcoinCash(bool hasImplementation) async {
697
final outputFile = File(bitcoinCashOutputPath);
698
const bitcoinCashCommonHeaders = """
1259
await outputFile.writeAsString(output);
1260
}
1261
1523
-Future<void> generateBase(bool hasImplementation) async {
1524
- final outputFile = File(baseOutputPath);
1525
- const baseCommonHeaders = """
1262
+Future<void> generateEVM(bool hasImplementation) async {
1263
+ final outputFile = File(evmOutputPath);
1264
+ const evmCommonHeaders = """
1265
+import 'package:cake_wallet/core/utilities.dart';
1266
import 'package:cake_wallet/view_model/send/output.dart';
1267
import 'package:cw_core/crypto_currency.dart';
1268
import 'package:cw_core/erc20_token.dart';
1276
import 'package:cw_core/wallet_credentials.dart';
1277
import 'package:cw_core/wallet_info.dart';
1278
import 'package:cw_core/wallet_service.dart';
1539
-import 'package:hive/hive.dart';
1279
+import 'package:cw_core/wallet_type.dart';
1280
+import 'package:cw_core/node.dart';
1281
import 'package:ledger_flutter_plus/ledger_flutter_plus.dart' as ledger;
1282
import 'package:bitbox_flutter/bitbox_flutter.dart' as bitbox;
1283
+import 'package:trezor_connect/trezor_connect.dart' as trezor;
1284
import 'package:web3dart/web3dart.dart';
1285
1286
""";
1545
- const baseCWHeaders = """
1546
-import 'package:cw_evm/evm_chain_formatter.dart';
1287
+ const evmCWHeaders = """
1288
+import 'package:cw_evm/utils/evm_chain_formatter.dart';
1289
import 'package:cw_evm/evm_chain_mnemonics.dart';
1290
+import 'package:cw_evm/evm_chain_registry.dart';
1291
import 'package:cw_evm/evm_chain_transaction_credentials.dart';
1292
import 'package:cw_evm/evm_chain_transaction_info.dart';
1293
import 'package:cw_evm/evm_chain_transaction_priority.dart';
1551
-import 'package:cw_evm/evm_chain_wallet_creation_credentials.dart';
1552
-import 'package:cw_evm/hardware/evm_chain_ledger_credentials.dart';
1294
import 'package:cw_evm/hardware/evm_chain_bitbox_credentials.dart';
1295
+import 'package:cw_evm/hardware/evm_chain_ledger_credentials.dart';
1296
+import 'package:cw_evm/hardware/evm_chain_trezor_credentials.dart';
1297
import 'package:cw_evm/evm_chain_wallet.dart';
1298
import 'package:cw_evm/hardware/evm_chain_bitbox_service.dart';
1299
import 'package:cw_evm/hardware/evm_chain_ledger_service.dart';
1557
-
1558
-import 'package:cw_base/base_client.dart';
1559
-import 'package:cw_base/base_wallet.dart';
1560
-import 'package:cw_base/base_wallet_service.dart';
1561
-import 'package:cw_base/default_base_erc20_tokens.dart';
1300
+import 'package:cw_evm/hardware/evm_chain_trezor_service.dart';
1301
+import 'package:cw_evm/evm_chain_wallet_service.dart';
1302
+import 'package:cw_evm/evm_chain_wallet_creation_credentials.dart';
1303
+import 'package:cw_evm/utils/evm_chain_utils.dart';
1304
+import 'package:cw_evm/evm_chain_default_tokens.dart';
1305
+import 'package:cw_evm/deuro/deuro_savings.dart';
1306
import 'package:eth_sig_util/util/utils.dart';
1307
1308
""";
1565
- const baseCwPart = "part 'cw_base.dart';";
1566
- const baseContent = """
1567
-abstract class Base {
1568
- List<String> getBaseWordList(String language);
1569
- WalletService createBaseWalletService(bool isDirect);
1570
- WalletCredentials createBaseNewWalletCredentials(
1571
- {required String name,
1572
- WalletInfo? walletInfo,
1573
- String? password,
1574
- String? mnemonic,
1575
- String? passphrase});
1576
- WalletCredentials createBaseRestoreWalletFromSeedCredentials(
1577
- {required String name,
1578
- required String mnemonic,
1579
- required String password,
1580
- String? passphrase});
1581
- WalletCredentials createBaseRestoreWalletFromPrivateKey(
1582
- {required String name, required String privateKey, required String password});
1583
- WalletCredentials createBaseHardwareWalletCredentials(
1584
- {required String name, required HardwareAccountData hwAccountData, WalletInfo? walletInfo});
1309
+ const evmCwPart = "part 'cw_evm.dart';";
1310
+ const evmContent = """
1311
+/// Unified abstract class for all EVM chains
1312
+///
1313
+/// This replaces separate proxy classes (Ethereum, Polygon, Base, Arbitrum)
1314
+/// with a single unified interface that works for all EVM chains.
1315
+/// Methods take WalletType parameter to determine chain-specific behavior.
1316
+abstract class EVM {
1317
+ List<String> getEVMWordList(String language);
1318
+
1319
+ /// Create unified wallet service for any EVM chain
1320
+ WalletService createEVMWalletService(WalletType walletType, bool isDirect);
1321
+
1322
+ /// Generic credential creation - uses WalletType
1323
+ WalletCredentials createEVMNewWalletCredentials({
1324
+ required String name,
1325
+ WalletInfo? walletInfo,
1326
+ String? password,
1327
+ String? mnemonic,
1328
+ String? passphrase,
1329
+ });
1330
+
1331
+ WalletCredentials createEVMRestoreWalletFromSeedCredentials({
1332
+ required String name,
1333
+ required String mnemonic,
1334
+ required String password,
1335
+ String? passphrase,
1336
+ });
1337
+
1338
+ WalletCredentials createEVMRestoreWalletFromPrivateKey({
1339
+ required String name,
1340
+ required String privateKey,
1341
+ required String password,
1342
+ });
1343
+
1344
+ WalletCredentials createEVMHardwareWalletCredentials({
1345
+ required String name,
1346
+ required HardwareAccountData hwAccountData,
1347
+ WalletInfo? walletInfo,
1348
+ });
1349
+
1350
+ // Generic methods that work for all EVM chains
1351
String getAddress(WalletBase wallet);
1352
String getPrivateKey(WalletBase wallet);
1353
String getPublicKey(WalletBase wallet);
1354
TransactionPriority getDefaultTransactionPriority();
1589
- TransactionPriority getBaseTransactionPrioritySlow();
1355
+ TransactionPriority getEVMTransactionPrioritySlow();
1356
List<TransactionPriority> getTransactionPriorities();
1591
- TransactionPriority deserializeBaseTransactionPriority(int raw);
1592
-
1593
- Object createBaseTransactionCredentials(
1357
+ TransactionPriority deserializeEVMTransactionPriority(int raw);
1358
+
1359
+ Object createEVMTransactionCredentials(
1360
List<Output> outputs, {
1595
- required TransactionPriority priority,
1361
+ required TransactionPriority? priority,
1362
required CryptoCurrency currency,
1363
int? feeRate,
1364
+ bool useBlinkProtection = true,
1365
});
1599
-
1600
- Object createBaseTransactionCredentialsRaw(
1366
+
1367
+ Object createEVMTransactionCredentialsRaw(
1368
List<OutputInfo> outputs, {
1369
TransactionPriority? priority,
1370
required CryptoCurrency currency,
1371
required int feeRate,
1372
+ bool useBlinkProtection = true,
1373
});
1606
-
1607
- int formatterBaseParseAmount(String amount);
1608
- double formatterBaseAmountToDouble(
1609
- {TransactionInfo? transaction, BigInt? amount, int exponent = 18});
1374
+
1375
+ int formatterEVMParseAmount(String amount);
1376
+ double formatterEVMAmountToDouble({
1377
+ TransactionInfo? transaction,
1378
+ BigInt? amount,
1379
+ int exponent = 18,
1380
+ });
1381
+
1382
List<Erc20Token> getERC20Currencies(WalletBase wallet);
1383
Future<void> addErc20Token(WalletBase wallet, CryptoCurrency token);
1384
Future<void> deleteErc20Token(WalletBase wallet, CryptoCurrency token);
1385
Future<void> removeTokenTransactionsInHistory(WalletBase wallet, CryptoCurrency token);
1386
Future<Erc20Token?> getErc20Token(WalletBase wallet, String contractAddress);
1615
-
1616
- Future<bool> isApprovalRequired(WalletBase wallet, String tokenContract, String spender, BigInt requiredAmount);
1617
- Future<PendingTransaction> createTokenApproval(WalletBase wallet, BigInt amount, String spender,
1618
- CryptoCurrency token, TransactionPriority priority);
1619
- Future<PendingTransaction> createRawCallDataTransaction(WalletBase wallet, String to, String dataHex, BigInt valueWei, TransactionPriority priority);
1620
-
1387
+
1388
CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo transaction);
1622
- void updateBaseScanUsageState(WalletBase wallet, bool isEnabled);
1389
+ void updateScanProviderUsageState(WalletBase wallet, bool isEnabled);
1390
Web3Client? getWeb3Client(WalletBase wallet);
1391
String getTokenAddress(CryptoCurrency asset);
1625
-
1392
+
1393
+ Future<bool> isApprovalRequired(
1394
+ WalletBase wallet,
1395
+ String tokenContract,
1396
+ String spender,
1397
+ BigInt requiredAmount,
1398
+ );
1399
+
1400
+ Future<PendingTransaction> createTokenApproval(
1401
+ WalletBase wallet,
1402
+ BigInt amount,
1403
+ String spender,
1404
+ CryptoCurrency token,
1405
+ TransactionPriority? priority,
1406
+ {bool useBlinkProtection = true}
1407
+ );
1408
+
1409
+ Future<PendingTransaction> createRawCallDataTransaction(
1410
+ WalletBase wallet,
1411
+ String to,
1412
+ String dataHex,
1413
+ BigInt valueWei,
1414
+ TransactionPriority? priority,
1415
+ {bool useBlinkProtection = true}
1416
+ );
1417
+
1418
+ // Hardware wallet methods
1419
Future<void> setHardwareWalletService(WalletBase wallet, HardwareWalletService service);
1420
HardwareWalletService getLedgerHardwareWalletService(ledger.LedgerConnection connection);
1421
HardwareWalletService getBitboxHardwareWalletService(bitbox.BitboxManager manager);
1629
- List<String> getDefaultTokenContractAddresses();
1422
+ HardwareWalletService getTrezorHardwareWalletService(trezor.TrezorConnect connect);
1423
+
1424
+ // Utility methods
1425
+ List<String> getDefaultTokenContractAddresses(WalletBase wallet);
1426
bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress);
1631
- String? getBaseNativeEstimatedFee(WalletBase wallet);
1632
- String? getBaseERC20EstimatedFee(WalletBase wallet);
1633
-}
1634
- """;
1635
-
1636
- const baseEmptyDefinition = 'Base? base;\n';
1637
- const baseCWDefinition = 'Base? base = CWBase();\n';
1638
-
1639
- final output = '$baseCommonHeaders\n' +
1640
- (hasImplementation ? '$baseCWHeaders\n' : '\n') +
1641
- (hasImplementation ? '$baseCwPart\n\n' : '\n') +
1642
- (hasImplementation ? baseCWDefinition : baseEmptyDefinition) +
1643
- '\n' +
1644
- baseContent;
1645
-
1646
- if (outputFile.existsSync()) {
1647
- await outputFile.delete();
1648
- }
1427
+ String? getEVMNativeEstimatedFee(WalletBase wallet);
1428
+ String? getEVMERC20EstimatedFee(WalletBase wallet);
1429
+
1430
+ // Chain-specific integrations (optional, can be null for non-Ethereum chains)
1431
+ Future<BigInt>? getDEuroSavingsBalance(WalletBase wallet) => null;
1432
+ Future<BigInt>? getDEuroAccruedInterest(WalletBase wallet) => null;
1433
+ Future<BigInt>? getDEuroInterestRate(WalletBase wallet) => null;
1434
+ Future<BigInt>? getDEuroSavingsApproved(WalletBase wallet) => null;
1435
+ Future<PendingTransaction>? addDEuroSaving(WalletBase wallet, BigInt amount, TransactionPriority priority) => null;
1436
+ Future<PendingTransaction>? removeDEuroSaving(WalletBase wallet, BigInt amount, TransactionPriority priority) => null;
1437
+ Future<PendingTransaction>? reinvestDEuroInterest(WalletBase wallet, TransactionPriority priority) => null;
1438
+ Future<PendingTransaction>? enableDEuroSaving(WalletBase wallet, TransactionPriority priority) => null;
1439
+
1440
+ // Registry helper methods (for backward compatibility helpers)
1441
+ int getChainIdByWalletType(WalletType walletType);
1442
+ String getChainNameByWalletType(WalletType walletType);
1443
+ String getTokenNameByWalletType(WalletType walletType);
1444
+ String getCaip2ByChainId(int chainId);
1445
+ int? getChainIdByTag(String tag);
1446
+ int? getChainIdByTitle(String title);
1447
+ WalletType? getWalletTypeByChainId(int chainId);
1448
+ String getChainNameByChainId(int chainId);
1449
+ String getTokenNameByChainId(int chainId);
1450
+
1451
+ // Chain selection methods
1452
+ List<ChainInfo> getAllChains();
1453
+ ChainInfo? getCurrentChain(WalletBase wallet);
1454
1650
- await outputFile.writeAsString(output);
1455
+ int? getSelectedChainId(WalletBase wallet);
1456
+ Future<void> selectChain(WalletBase wallet, int chainId, {required Node node});
1457
+
1458
+ String? getExplorerUrlForChainId(int chainId, {bool showProtocol = true});
1459
+
1460
+ bool hasPriorityFee(int chainId);
1461
}
1462
1653
-Future<void> generateArbitrum(bool hasImplementation) async {
1654
- final outputFile = File(arbitrumOutputPath);
1655
- const arbitrumCommonHeaders = """
1656
-import 'package:cake_wallet/view_model/send/output.dart';
1657
-import 'package:cw_core/crypto_currency.dart';
1658
-import 'package:cw_core/erc20_token.dart';
1659
-import 'package:cw_core/hardware/hardware_account_data.dart';
1660
-import 'package:cw_core/hardware/hardware_wallet_service.dart';
1661
-import 'package:cw_core/output_info.dart';
1662
-import 'package:cw_core/pending_transaction.dart';
1663
-import 'package:cw_core/transaction_info.dart';
1664
-import 'package:cw_core/transaction_priority.dart';
1665
-import 'package:cw_core/wallet_base.dart';
1666
-import 'package:cw_core/wallet_credentials.dart';
1667
-import 'package:cw_core/wallet_info.dart';
1668
-import 'package:cw_core/wallet_service.dart';
1669
-import 'package:hive/hive.dart';
1670
-import 'package:ledger_flutter_plus/ledger_flutter_plus.dart' as ledger;
1671
-import 'package:bitbox_flutter/bitbox_flutter.dart' as bitbox;
1672
-import 'package:web3dart/web3dart.dart';
1673
-
1674
-""";
1675
- const arbitrumCWHeaders = """
1676
-import 'package:cw_evm/evm_chain_formatter.dart';
1677
-import 'package:cw_evm/evm_chain_mnemonics.dart';
1678
-import 'package:cw_evm/evm_chain_transaction_credentials.dart';
1679
-import 'package:cw_evm/evm_chain_transaction_info.dart';
1680
-import 'package:cw_evm/evm_chain_transaction_priority.dart';
1681
-import 'package:cw_evm/evm_chain_wallet_creation_credentials.dart';
1682
-import 'package:cw_evm/hardware/evm_chain_ledger_credentials.dart';
1683
-import 'package:cw_evm/hardware/evm_chain_bitbox_credentials.dart';
1684
-import 'package:cw_evm/evm_chain_wallet.dart';
1685
-import 'package:cw_evm/hardware/evm_chain_bitbox_service.dart';
1686
-import 'package:cw_evm/hardware/evm_chain_ledger_service.dart';
1687
-
1688
-import 'package:cw_arbitrum/arbitrum_client.dart';
1689
-import 'package:cw_arbitrum/arbitrum_wallet.dart';
1690
-import 'package:cw_arbitrum/arbitrum_wallet_service.dart';
1691
-import 'package:cw_arbitrum/default_arbitrum_erc20_tokens.dart';
1692
-import 'package:eth_sig_util/util/utils.dart';
1693
-
1694
-""";
1695
- const arbitrumCwPart = "part 'cw_arbitrum.dart';";
1696
- const arbitrumContent = """
1697
-abstract class Arbitrum {
1698
- List<String> getArbitrumWordList(String language);
1699
- WalletService createArbitrumWalletService(bool isDirect);
1700
- WalletCredentials createArbitrumNewWalletCredentials(
1701
- {required String name,
1702
- WalletInfo? walletInfo,
1703
- String? password,
1704
- String? mnemonic,
1705
- String? passphrase});
1706
- WalletCredentials createArbitrumRestoreWalletFromSeedCredentials(
1707
- {required String name,
1708
- required String mnemonic,
1709
- required String password,
1710
- String? passphrase});
1711
- WalletCredentials createArbitrumRestoreWalletFromPrivateKey(
1712
- {required String name, required String privateKey, required String password});
1713
- WalletCredentials createArbitrumHardwareWalletCredentials(
1714
- {required String name, required HardwareAccountData hwAccountData, WalletInfo? walletInfo});
1715
- String getAddress(WalletBase wallet);
1716
- String getPrivateKey(WalletBase wallet);
1717
- String getPublicKey(WalletBase wallet);
1718
-
1719
- Object createArbitrumTransactionCredentials(
1720
- List<Output> outputs, {
1721
- required CryptoCurrency currency,
1722
- int? feeRate,
1723
- });
1724
-
1725
- Object createArbitrumTransactionCredentialsRaw(
1726
- List<OutputInfo> outputs, {
1727
- required CryptoCurrency currency,
1728
- required int feeRate,
1463
+class ChainInfo {
1464
+ const ChainInfo({
1465
+ required this.chainId,
1466
+ required this.name,
1467
+ required this.shortCode,
1468
});
1469
+
1470
+ final int chainId;
1471
+ final String name;
1472
+ final String shortCode;
1473
1731
- int formatterArbitrumParseAmount(String amount);
1732
- double formatterArbitrumAmountToDouble(
1733
- {TransactionInfo? transaction, BigInt? amount, int exponent = 18});
1734
- List<Erc20Token> getERC20Currencies(WalletBase wallet);
1735
- Future<void> addErc20Token(WalletBase wallet, CryptoCurrency token);
1736
- Future<void> deleteErc20Token(WalletBase wallet, CryptoCurrency token);
1737
- Future<void> removeTokenTransactionsInHistory(WalletBase wallet, CryptoCurrency token);
1738
- Future<Erc20Token?> getErc20Token(WalletBase wallet, String contractAddress);
1739
-
1740
- Future<PendingTransaction> createTokenApproval(WalletBase wallet, BigInt amount, String spender,
1741
- CryptoCurrency token);
1742
-
1743
- CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo transaction);
1744
- void updateArbitrumScanUsageState(WalletBase wallet, bool isEnabled);
1745
- Web3Client? getWeb3Client(WalletBase wallet);
1746
- String getTokenAddress(CryptoCurrency asset);
1474
+ @override
1475
+ bool operator ==(Object other) =>
1476
+ identical(this, other) ||
1477
+ other is ChainInfo && runtimeType == other.runtimeType && chainId == other.chainId;
1478
1748
- Future<void> setHardwareWalletService(WalletBase wallet, HardwareWalletService service);
1749
- HardwareWalletService getLedgerHardwareWalletService(ledger.LedgerConnection connection);
1750
- HardwareWalletService getBitboxHardwareWalletService(bitbox.BitboxManager manager);
1751
- List<String> getDefaultTokenContractAddresses();
1752
- bool isTokenAlreadyAdded(WalletBase wallet, String contractAddress);
1753
- Future<bool> isApprovalRequired(WalletBase wallet, String tokenContract, String spender, BigInt requiredAmount);
1754
- Future<PendingTransaction> createRawCallDataTransaction(WalletBase wallet, String to, String dataHex, BigInt valueWei);
1755
- String? getArbitrumNativeEstimatedFee(WalletBase wallet);
1756
- String? getArbitrumERC20EstimatedFee(WalletBase wallet);
1479
+ @override
1480
+ int get hashCode => chainId.hashCode;
1481
}
1758
-
1482
""";
1483
1761
- const arbitrumEmptyDefinition = 'Arbitrum? arbitrum;\n';
1762
- const arbitrumCWDefinition = 'Arbitrum? arbitrum = CWArbitrum();\n';
1484
+ const evmEmptyDefinition = 'EVM? evm;\n';
1485
+ const evmCWDefinition = 'EVM? evm = CWEVM();\n';
1486
1764
- final output = '$arbitrumCommonHeaders\n' +
1765
- (hasImplementation ? '$arbitrumCWHeaders\n' : '\n') +
1766
- (hasImplementation ? '$arbitrumCwPart\n\n' : '\n') +
1767
- (hasImplementation ? arbitrumCWDefinition : arbitrumEmptyDefinition) +
1487
+ final output = '$evmCommonHeaders\n' +
1488
+ (hasImplementation ? '$evmCWHeaders\n' : '\n') +
1489
+ (hasImplementation ? '$evmCwPart\n\n' : '\n') +
1490
+ (hasImplementation ? evmCWDefinition : evmEmptyDefinition) +
1491
'\n' +
1769
- arbitrumContent;
1492
+ evmContent;
1493
1494
if (outputFile.existsSync()) {
1495
await outputFile.delete();
1535
path: flutter_secure_storage
1536
ref: ca897a08677edb443b366352dd7412735e098e7b
1537
""";
1815
- const cwEthereum = """
1816
- cw_ethereum:
1817
- path: ./cw_ethereum
1818
- """;
1538
const cwBitcoinCash = """
1539
cw_bitcoin_cash:
1540
path: ./cw_bitcoin_cash
1547
cw_banano:
1548
path: ./cw_banano
1549
""";
1831
- const cwPolygon = """
1832
- cw_polygon:
1833
- path: ./cw_polygon
1834
- """;
1550
const cwSolana = """
1551
cw_solana:
1552
path: ./cw_solana
1575
cw_dogecoin:
1576
path: ./cw_dogecoin
1577
""";
1863
- const cwBase = """
1864
- cw_base:
1865
- path: ./cw_base
1866
- """;
1867
- const cwArbitrum = """
1868
- cw_arbitrum:
1869
- path: ./cw_arbitrum
1870
- """;
1578
final inputFile = File(pubspecOutputPath);
1579
final inputText = await inputFile.readAsString();
1580
final inputLines = inputText.split('\n');
1592
output += '\n$cwBitcoin';
1593
}
1594
1888
- if (hasEthereum) {
1889
- output += '\n$cwEthereum';
1890
- }
1891
-
1595
if (hasNano) {
1596
output += '\n$cwNano';
1597
}
1604
output += '\n$cwBitcoinCash';
1605
}
1606
1904
- if (hasPolygon) {
1905
- output += '\n$cwPolygon';
1906
- }
1907
-
1607
if (hasSolana) {
1608
output += '\n$cwSolana';
1609
}
1620
output += '\n$flutterSecureStorage\n';
1621
}
1622
1924
- if (hasEthereum || hasPolygon) {
1623
+ if (hasEthereum || hasPolygon || hasBase || hasArbitrum) {
1624
output += '\n$cwEVM';
1625
}
1626
1636
output += '\n$cwDogecoin';
1637
}
1638
1940
- if (hasBase) {
1941
- output += '\n$cwBase';
1942
- }
1943
-
1944
- if (hasArbitrum) {
1945
- output += '\n$cwArbitrum';
1946
- }
1947
-
1639
final outputLines = output.split('\n');
1640
inputLines.insertAll(dependenciesIndex + 1, outputLines);
1641
final outputContent = inputLines.join('\n');