CW-1099-Add-Doge-coin-to-Cake-Wallet (#2396)

* add wallet create, restore and server integration

* update transaction fee calculation

* Updated tool/configure.dart

* Add dogecoin support to app_config

* minor fix [skip ci]

* Update model_generator.sh

* remove cw_bitcoin import from  lib/ directory

* update bitcoin base

* update default node

* add passphrase an QR restore option

* add Dogecoin support for message signing

* add Dogecoin support across wallet features

* fix edit subaddress

Updated the isElectrum getter to include WalletType.dogecoin, ensuring Dogecoin wallets are correctly identified as Electrum-compatible.

* Update configure.dart

* fix: address label not saved

* remove unused derivationPath

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>

* address review comments

* fix generateInitialAddresses type

* enable auto switching for Dogecoin nodes

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
Serhii
2025-08-07 22:07:20 +03:00
committed by GitHub
co-authored by Omar Hatem
parent 9053a3d726
commit b6244cdd44
70 changed files with 1088 additions and 38 deletions
+74
View File
@@ -11,6 +11,7 @@ const tronOutputPath = 'lib/tron/tron.dart';
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 walletTypesPath = 'lib/wallet_types.g.dart';
const secureStoragePath = 'lib/core/secure_storage.dart';
const pubspecDefaultPath = 'pubspec_default.yaml';
@@ -30,6 +31,7 @@ Future<void> main(List<String> args) async {
final hasWownero = args.contains('${prefix}wownero');
final hasZano = args.contains('${prefix}zano');
final hasDecred = args.contains('${prefix}decred');
final hasDogecoin = args.contains('${prefix}dogecoin');
final excludeFlutterSecureStorage = args.contains('${prefix}excludeFlutterSecureStorage');
await generateBitcoin(hasBitcoin);
@@ -44,6 +46,7 @@ Future<void> main(List<String> args) async {
await generateZano(hasZano);
// await generateBanano(hasEthereum);
await generateDecred(hasDecred);
await generateDogecoin(hasDogecoin);
await generatePubspec(
hasMonero: hasMonero,
@@ -59,6 +62,7 @@ Future<void> main(List<String> args) async {
hasWownero: hasWownero,
hasZano: hasZano,
hasDecred: hasDecred,
hasDogecoin: hasDogecoin,
);
await generateWalletTypes(
hasMonero: hasMonero,
@@ -73,6 +77,7 @@ Future<void> main(List<String> args) async {
hasWownero: hasWownero,
hasZano: hasZano,
hasDecred: hasDecred,
hasDogecoin: hasDogecoin,
);
await injectSecureStorage(!excludeFlutterSecureStorage);
}
@@ -1414,6 +1419,61 @@ abstract class Decred {
await outputFile.writeAsString(output);
}
Future<void> generateDogecoin(bool hasImplementation) async {
final outputFile = File(dogecoinOutputPath);
const dogecoinCommonHeaders = """
import 'package:cw_core/transaction_priority.dart';
import 'package:cw_core/unspent_coins_info.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';
""";
const dogecoinCWHeaders = """
import 'package:cw_dogecoin/cw_dogecoin.dart';
""";
const dogecoinCwPart = "part 'cw_dogecoin.dart';";
const dogecoinContent = """
abstract class DogeCoin {
WalletService createDogeCoinWalletService(
Box<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> unspentCoinSource, bool isDirect);
WalletCredentials createDogeCoinNewWalletCredentials(
{required String name, WalletInfo? walletInfo, String? password, String? passphrase, String? mnemonic});
WalletCredentials createDogeCoinRestoreWalletFromSeedCredentials(
{required String name, required String mnemonic, required String password, String? passphrase});
TransactionPriority deserializeDogeCoinTransactionPriority(int raw);
TransactionPriority getDefaultTransactionPriority();
List<TransactionPriority> getTransactionPriorities();
TransactionPriority getDogeCoinTransactionPrioritySlow();
}
""";
const dogecoinEmptyDefinition = 'DogeCoin? dogecoin;\n';
const dogecoinCWDefinition = 'DogeCoin? dogecoin = CWDogeCoin();\n';
final output = '$dogecoinCommonHeaders\n' +
(hasImplementation ? '$dogecoinCWHeaders\n' : '\n') +
(hasImplementation ? '$dogecoinCwPart\n\n' : '\n') +
(hasImplementation
? dogecoinCWDefinition
: dogecoinEmptyDefinition) +
'\n' +
dogecoinContent;
if (outputFile.existsSync()) {
await outputFile.delete();
}
await outputFile.writeAsString(output);
}
Future<void> generatePubspec({
required bool hasMonero,
required bool hasBitcoin,
@@ -1428,6 +1488,7 @@ Future<void> generatePubspec({
required bool hasWownero,
required bool hasZano,
required bool hasDecred,
required bool hasDogecoin,
}) async {
const cwCore = """
cw_core:
@@ -1492,6 +1553,10 @@ Future<void> generatePubspec({
cw_decred:
path: ./cw_decred
""";
const cwDogecoin = """
cw_dogecoin:
path: ./cw_dogecoin
""";
final inputFile = File(pubspecOutputPath);
final inputText = await inputFile.readAsString();
final inputLines = inputText.split('\n');
@@ -1557,6 +1622,10 @@ Future<void> generatePubspec({
output += '\n$cwZano';
}
if (hasDogecoin) {
output += '\n$cwDogecoin';
}
final outputLines = output.split('\n');
inputLines.insertAll(dependenciesIndex + 1, outputLines);
final outputContent = inputLines.join('\n');
@@ -1582,6 +1651,7 @@ Future<void> generateWalletTypes({
required bool hasWownero,
required bool hasZano,
required bool hasDecred,
required bool hasDogecoin,
}) async {
final walletTypesFile = File(walletTypesPath);
@@ -1609,6 +1679,10 @@ Future<void> generateWalletTypes({
outputContent += '\tWalletType.litecoin,\n';
}
if (hasDogecoin) {
outputContent += '\tWalletType.dogecoin,\n';
}
if (hasBitcoinCash) {
outputContent += '\tWalletType.bitcoinCash,\n';
}