diff --git a/cw_core/lib/wallet_type.dart b/cw_core/lib/wallet_type.dart index 20f0bdb19..990ba66a7 100644 --- a/cw_core/lib/wallet_type.dart +++ b/cw_core/lib/wallet_type.dart @@ -4,18 +4,6 @@ import 'package:hive/hive.dart'; part 'wallet_type.g.dart'; -const walletTypes = [ - WalletType.monero, - WalletType.bitcoin, - WalletType.litecoin, - WalletType.haven, - WalletType.ethereum, - WalletType.bitcoinCash, - WalletType.nano, - WalletType.banano, - WalletType.polygon, -]; - @HiveType(typeId: WALLET_TYPE_TYPE_ID) enum WalletType { @HiveField(0) @@ -46,7 +34,10 @@ enum WalletType { bitcoinCash, @HiveField(9) - polygon + polygon, + + @HiveField(10) + firo, } int serializeToInt(WalletType type) { @@ -69,6 +60,8 @@ int serializeToInt(WalletType type) { return 7; case WalletType.polygon: return 8; + case WalletType.firo: + return 9; default: return -1; } @@ -94,6 +87,8 @@ WalletType deserializeFromInt(int raw) { return WalletType.bitcoinCash; case 8: return WalletType.polygon; + case 9: + return WalletType.firo; default: throw Exception('Unexpected token: $raw for WalletType deserializeFromInt'); } @@ -119,6 +114,8 @@ String walletTypeToString(WalletType type) { return 'Banano'; case WalletType.polygon: return 'Polygon'; + case WalletType.firo: + return 'Firo'; default: return ''; } @@ -144,6 +141,8 @@ String walletTypeToDisplayName(WalletType type) { return 'Banano (BAN)'; case WalletType.polygon: return 'Polygon (MATIC)'; + case WalletType.firo: + return 'Firo'; default: return ''; } @@ -169,6 +168,8 @@ CryptoCurrency walletTypeToCryptoCurrency(WalletType type) { return CryptoCurrency.banano; case WalletType.polygon: return CryptoCurrency.maticpoly; + case WalletType.firo: + return CryptoCurrency.firo; default: throw Exception( 'Unexpected wallet type: ${type.toString()} for CryptoCurrency walletTypeToCryptoCurrency'); diff --git a/cw_firo b/cw_firo new file mode 160000 index 000000000..9cd241b5e --- /dev/null +++ b/cw_firo @@ -0,0 +1 @@ +Subproject commit 9cd241b5ea142e21c01dd7639b42603281c43287 diff --git a/lib/entities/provider_types.dart b/lib/entities/provider_types.dart index ced79eae7..cb62e3eea 100644 --- a/lib/entities/provider_types.dart +++ b/lib/entities/provider_types.dart @@ -68,6 +68,7 @@ class ProvidersHelper { case WalletType.none: case WalletType.haven: case WalletType.polygon: + case WalletType.firo: return []; } } @@ -88,6 +89,7 @@ class ProvidersHelper { case WalletType.none: case WalletType.haven: case WalletType.polygon: + case WalletType.firo: return []; } } diff --git a/scripts/android/pubspec_gen.sh b/scripts/android/pubspec_gen.sh index 4b89c4afa..74474283f 100755 --- a/scripts/android/pubspec_gen.sh +++ b/scripts/android/pubspec_gen.sh @@ -10,7 +10,7 @@ case $APP_ANDROID_TYPE in CONFIG_ARGS="--monero" ;; $CAKEWALLET) - CONFIG_ARGS="--monero --bitcoin --haven --ethereum --polygon --nano --bitcoinCash" + CONFIG_ARGS="--monero --bitcoin --haven --ethereum --polygon --nano --bitcoinCash --firo" ;; $HAVEN) CONFIG_ARGS="--haven" diff --git a/tool/configure.dart b/tool/configure.dart index 67732faa9..c09dc27eb 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -7,6 +7,7 @@ const ethereumOutputPath = 'lib/ethereum/ethereum.dart'; const bitcoinCashOutputPath = 'lib/bitcoin_cash/bitcoin_cash.dart'; const nanoOutputPath = 'lib/nano/nano.dart'; const polygonOutputPath = 'lib/polygon/polygon.dart'; +const FiroOutputPath = 'lib/firo/firo.dart'; const walletTypesPath = 'lib/wallet_types.g.dart'; const pubspecDefaultPath = 'pubspec_default.yaml'; const pubspecOutputPath = 'pubspec.yaml'; @@ -21,6 +22,7 @@ Future main(List args) async { final hasNano = args.contains('${prefix}nano'); final hasBanano = args.contains('${prefix}banano'); final hasPolygon = args.contains('${prefix}polygon'); + final hasFiro = args.contains('${prefix}firo'); await generateBitcoin(hasBitcoin); await generateMonero(hasMonero); @@ -29,6 +31,7 @@ Future main(List args) async { await generateBitcoinCash(hasBitcoinCash); await generateNano(hasNano); await generatePolygon(hasPolygon); + await generateFiro(hasFiro); // await generateBanano(hasEthereum); await generatePubspec( @@ -40,6 +43,7 @@ Future main(List args) async { hasBanano: hasBanano, hasBitcoinCash: hasBitcoinCash, hasPolygon: hasPolygon, + hasFiro: hasFiro, ); await generateWalletTypes( hasMonero: hasMonero, @@ -50,6 +54,7 @@ Future main(List args) async { hasBanano: hasBanano, hasBitcoinCash: hasBitcoinCash, hasPolygon: hasPolygon, + hasFiro: hasFiro, ); } @@ -726,6 +731,57 @@ abstract class BitcoinCash { await outputFile.writeAsString(output); } +Future generateFiro(bool hasImplementation) async { + final outputFile = File(FiroOutputPath); + const firoCommonHeaders = """ +"""; + const firoCWHeaders = """ +"""; + const firoCwPart = "part 'cw_firo.dart';"; + const firoContent = """ +abstract class Firo { + String getMnemonic(int? strength); + + Uint8List getSeedFromMnemonic(String seed); + + String getCashAddrFormat(String address); + + WalletService createFiroWalletService( + Box walletInfoSource, Box unspentCoinSource); + + WalletCredentials createFiroNewWalletCredentials( + {required String name, WalletInfo? walletInfo}); + + WalletCredentials createFiroRestoreWalletFromSeedCredentials( + {required String name, required String mnemonic, required String password}); + + TransactionPriority deserializeFiroTransactionPriority(int raw); + + TransactionPriority getDefaultTransactionPriority(); + + List getTransactionPriorities(); + + TransactionPriority getFiroTransactionPrioritySlow(); +} + """; + + const firoEmptyDefinition = 'Firo? firo;\n'; + const firoCWDefinition = 'Firo? firo = CWFiro();\n'; + + final output = '$firoCommonHeaders\n' + + (hasImplementation ? '$firoCWHeaders\n' : '\n') + + (hasImplementation ? '$firoCwPart\n\n' : '\n') + + (hasImplementation ? firoCWDefinition : firoEmptyDefinition) + + '\n' + + firoContent; + + if (outputFile.existsSync()) { + await outputFile.delete(); + } + + await outputFile.writeAsString(output); +} + Future generateNano(bool hasImplementation) async { final outputFile = File(nanoOutputPath); const nanoCommonHeaders = """ @@ -876,7 +932,8 @@ Future generatePubspec( required bool hasNano, required bool hasBanano, required bool hasBitcoinCash, - required bool hasPolygon}) async { + required bool hasPolygon, + required bool hasFiro}) async { const cwCore = """ cw_core: path: ./cw_core @@ -917,6 +974,15 @@ Future generatePubspec( cw_polygon: path: ./cw_polygon """; + const cwFiro = """ + cw_firo: + path: ./cw_firo + + flutter_libsparkmobile: + git: + url: https://github.com/cypherstack/flutter_libsparkmobile.git + ref: ac6424658191047b14cbd95bee61388397ae94a7 + """; final inputFile = File(pubspecOutputPath); final inputText = await inputFile.readAsString(); final inputLines = inputText.split('\n'); @@ -951,6 +1017,10 @@ Future generatePubspec( output += '\n$cwPolygon'; } + if (hasFiro) { + output += '\n$cwFiro'; + } + if (hasHaven && !hasMonero) { output += '\n$cwSharedExternal\n$cwHaven'; } else if (hasHaven) { @@ -977,7 +1047,8 @@ Future generateWalletTypes( required bool hasNano, required bool hasBanano, required bool hasBitcoinCash, - required bool hasPolygon}) async { + required bool hasPolygon, + required bool hasFiro}) async { final walletTypesFile = File(walletTypesPath); if (walletTypesFile.existsSync()) { @@ -1020,6 +1091,10 @@ Future generateWalletTypes( outputContent += '\tWalletType.banano,\n'; } + if (hasFiro) { + outputContent += '\tWalletType.firo,\n'; + } + if (hasHaven) { outputContent += '\tWalletType.haven,\n'; }