mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
Add initial setup for firo wallet
This commit is contained in:
parent
b3c8be4ba8
commit
8e39df21c9
5 changed files with 95 additions and 16 deletions
|
@ -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');
|
||||
|
|
1
cw_firo
Submodule
1
cw_firo
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 9cd241b5ea142e21c01dd7639b42603281c43287
|
|
@ -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 [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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<void> main(List<String> 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<void> main(List<String> args) async {
|
|||
await generateBitcoinCash(hasBitcoinCash);
|
||||
await generateNano(hasNano);
|
||||
await generatePolygon(hasPolygon);
|
||||
await generateFiro(hasFiro);
|
||||
// await generateBanano(hasEthereum);
|
||||
|
||||
await generatePubspec(
|
||||
|
@ -40,6 +43,7 @@ Future<void> main(List<String> args) async {
|
|||
hasBanano: hasBanano,
|
||||
hasBitcoinCash: hasBitcoinCash,
|
||||
hasPolygon: hasPolygon,
|
||||
hasFiro: hasFiro,
|
||||
);
|
||||
await generateWalletTypes(
|
||||
hasMonero: hasMonero,
|
||||
|
@ -50,6 +54,7 @@ Future<void> main(List<String> args) async {
|
|||
hasBanano: hasBanano,
|
||||
hasBitcoinCash: hasBitcoinCash,
|
||||
hasPolygon: hasPolygon,
|
||||
hasFiro: hasFiro,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -726,6 +731,57 @@ abstract class BitcoinCash {
|
|||
await outputFile.writeAsString(output);
|
||||
}
|
||||
|
||||
Future<void> 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<WalletInfo> walletInfoSource, Box<UnspentCoinsInfo> 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<TransactionPriority> 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<void> generateNano(bool hasImplementation) async {
|
||||
final outputFile = File(nanoOutputPath);
|
||||
const nanoCommonHeaders = """
|
||||
|
@ -876,7 +932,8 @@ Future<void> 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<void> 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<void> 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<void> 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<void> generateWalletTypes(
|
|||
outputContent += '\tWalletType.banano,\n';
|
||||
}
|
||||
|
||||
if (hasFiro) {
|
||||
outputContent += '\tWalletType.firo,\n';
|
||||
}
|
||||
|
||||
if (hasHaven) {
|
||||
outputContent += '\tWalletType.haven,\n';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue