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';
|
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)
|
@HiveType(typeId: WALLET_TYPE_TYPE_ID)
|
||||||
enum WalletType {
|
enum WalletType {
|
||||||
@HiveField(0)
|
@HiveField(0)
|
||||||
|
@ -46,7 +34,10 @@ enum WalletType {
|
||||||
bitcoinCash,
|
bitcoinCash,
|
||||||
|
|
||||||
@HiveField(9)
|
@HiveField(9)
|
||||||
polygon
|
polygon,
|
||||||
|
|
||||||
|
@HiveField(10)
|
||||||
|
firo,
|
||||||
}
|
}
|
||||||
|
|
||||||
int serializeToInt(WalletType type) {
|
int serializeToInt(WalletType type) {
|
||||||
|
@ -69,6 +60,8 @@ int serializeToInt(WalletType type) {
|
||||||
return 7;
|
return 7;
|
||||||
case WalletType.polygon:
|
case WalletType.polygon:
|
||||||
return 8;
|
return 8;
|
||||||
|
case WalletType.firo:
|
||||||
|
return 9;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -94,6 +87,8 @@ WalletType deserializeFromInt(int raw) {
|
||||||
return WalletType.bitcoinCash;
|
return WalletType.bitcoinCash;
|
||||||
case 8:
|
case 8:
|
||||||
return WalletType.polygon;
|
return WalletType.polygon;
|
||||||
|
case 9:
|
||||||
|
return WalletType.firo;
|
||||||
default:
|
default:
|
||||||
throw Exception('Unexpected token: $raw for WalletType deserializeFromInt');
|
throw Exception('Unexpected token: $raw for WalletType deserializeFromInt');
|
||||||
}
|
}
|
||||||
|
@ -119,6 +114,8 @@ String walletTypeToString(WalletType type) {
|
||||||
return 'Banano';
|
return 'Banano';
|
||||||
case WalletType.polygon:
|
case WalletType.polygon:
|
||||||
return 'Polygon';
|
return 'Polygon';
|
||||||
|
case WalletType.firo:
|
||||||
|
return 'Firo';
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -144,6 +141,8 @@ String walletTypeToDisplayName(WalletType type) {
|
||||||
return 'Banano (BAN)';
|
return 'Banano (BAN)';
|
||||||
case WalletType.polygon:
|
case WalletType.polygon:
|
||||||
return 'Polygon (MATIC)';
|
return 'Polygon (MATIC)';
|
||||||
|
case WalletType.firo:
|
||||||
|
return 'Firo';
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -169,6 +168,8 @@ CryptoCurrency walletTypeToCryptoCurrency(WalletType type) {
|
||||||
return CryptoCurrency.banano;
|
return CryptoCurrency.banano;
|
||||||
case WalletType.polygon:
|
case WalletType.polygon:
|
||||||
return CryptoCurrency.maticpoly;
|
return CryptoCurrency.maticpoly;
|
||||||
|
case WalletType.firo:
|
||||||
|
return CryptoCurrency.firo;
|
||||||
default:
|
default:
|
||||||
throw Exception(
|
throw Exception(
|
||||||
'Unexpected wallet type: ${type.toString()} for CryptoCurrency walletTypeToCryptoCurrency');
|
'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.none:
|
||||||
case WalletType.haven:
|
case WalletType.haven:
|
||||||
case WalletType.polygon:
|
case WalletType.polygon:
|
||||||
|
case WalletType.firo:
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +89,7 @@ class ProvidersHelper {
|
||||||
case WalletType.none:
|
case WalletType.none:
|
||||||
case WalletType.haven:
|
case WalletType.haven:
|
||||||
case WalletType.polygon:
|
case WalletType.polygon:
|
||||||
|
case WalletType.firo:
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ case $APP_ANDROID_TYPE in
|
||||||
CONFIG_ARGS="--monero"
|
CONFIG_ARGS="--monero"
|
||||||
;;
|
;;
|
||||||
$CAKEWALLET)
|
$CAKEWALLET)
|
||||||
CONFIG_ARGS="--monero --bitcoin --haven --ethereum --polygon --nano --bitcoinCash"
|
CONFIG_ARGS="--monero --bitcoin --haven --ethereum --polygon --nano --bitcoinCash --firo"
|
||||||
;;
|
;;
|
||||||
$HAVEN)
|
$HAVEN)
|
||||||
CONFIG_ARGS="--haven"
|
CONFIG_ARGS="--haven"
|
||||||
|
|
|
@ -7,6 +7,7 @@ const ethereumOutputPath = 'lib/ethereum/ethereum.dart';
|
||||||
const bitcoinCashOutputPath = 'lib/bitcoin_cash/bitcoin_cash.dart';
|
const bitcoinCashOutputPath = 'lib/bitcoin_cash/bitcoin_cash.dart';
|
||||||
const nanoOutputPath = 'lib/nano/nano.dart';
|
const nanoOutputPath = 'lib/nano/nano.dart';
|
||||||
const polygonOutputPath = 'lib/polygon/polygon.dart';
|
const polygonOutputPath = 'lib/polygon/polygon.dart';
|
||||||
|
const FiroOutputPath = 'lib/firo/firo.dart';
|
||||||
const walletTypesPath = 'lib/wallet_types.g.dart';
|
const walletTypesPath = 'lib/wallet_types.g.dart';
|
||||||
const pubspecDefaultPath = 'pubspec_default.yaml';
|
const pubspecDefaultPath = 'pubspec_default.yaml';
|
||||||
const pubspecOutputPath = 'pubspec.yaml';
|
const pubspecOutputPath = 'pubspec.yaml';
|
||||||
|
@ -21,6 +22,7 @@ Future<void> main(List<String> args) async {
|
||||||
final hasNano = args.contains('${prefix}nano');
|
final hasNano = args.contains('${prefix}nano');
|
||||||
final hasBanano = args.contains('${prefix}banano');
|
final hasBanano = args.contains('${prefix}banano');
|
||||||
final hasPolygon = args.contains('${prefix}polygon');
|
final hasPolygon = args.contains('${prefix}polygon');
|
||||||
|
final hasFiro = args.contains('${prefix}firo');
|
||||||
|
|
||||||
await generateBitcoin(hasBitcoin);
|
await generateBitcoin(hasBitcoin);
|
||||||
await generateMonero(hasMonero);
|
await generateMonero(hasMonero);
|
||||||
|
@ -29,6 +31,7 @@ Future<void> main(List<String> args) async {
|
||||||
await generateBitcoinCash(hasBitcoinCash);
|
await generateBitcoinCash(hasBitcoinCash);
|
||||||
await generateNano(hasNano);
|
await generateNano(hasNano);
|
||||||
await generatePolygon(hasPolygon);
|
await generatePolygon(hasPolygon);
|
||||||
|
await generateFiro(hasFiro);
|
||||||
// await generateBanano(hasEthereum);
|
// await generateBanano(hasEthereum);
|
||||||
|
|
||||||
await generatePubspec(
|
await generatePubspec(
|
||||||
|
@ -40,6 +43,7 @@ Future<void> main(List<String> args) async {
|
||||||
hasBanano: hasBanano,
|
hasBanano: hasBanano,
|
||||||
hasBitcoinCash: hasBitcoinCash,
|
hasBitcoinCash: hasBitcoinCash,
|
||||||
hasPolygon: hasPolygon,
|
hasPolygon: hasPolygon,
|
||||||
|
hasFiro: hasFiro,
|
||||||
);
|
);
|
||||||
await generateWalletTypes(
|
await generateWalletTypes(
|
||||||
hasMonero: hasMonero,
|
hasMonero: hasMonero,
|
||||||
|
@ -50,6 +54,7 @@ Future<void> main(List<String> args) async {
|
||||||
hasBanano: hasBanano,
|
hasBanano: hasBanano,
|
||||||
hasBitcoinCash: hasBitcoinCash,
|
hasBitcoinCash: hasBitcoinCash,
|
||||||
hasPolygon: hasPolygon,
|
hasPolygon: hasPolygon,
|
||||||
|
hasFiro: hasFiro,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -726,6 +731,57 @@ abstract class BitcoinCash {
|
||||||
await outputFile.writeAsString(output);
|
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 {
|
Future<void> generateNano(bool hasImplementation) async {
|
||||||
final outputFile = File(nanoOutputPath);
|
final outputFile = File(nanoOutputPath);
|
||||||
const nanoCommonHeaders = """
|
const nanoCommonHeaders = """
|
||||||
|
@ -876,7 +932,8 @@ Future<void> generatePubspec(
|
||||||
required bool hasNano,
|
required bool hasNano,
|
||||||
required bool hasBanano,
|
required bool hasBanano,
|
||||||
required bool hasBitcoinCash,
|
required bool hasBitcoinCash,
|
||||||
required bool hasPolygon}) async {
|
required bool hasPolygon,
|
||||||
|
required bool hasFiro}) async {
|
||||||
const cwCore = """
|
const cwCore = """
|
||||||
cw_core:
|
cw_core:
|
||||||
path: ./cw_core
|
path: ./cw_core
|
||||||
|
@ -917,6 +974,15 @@ Future<void> generatePubspec(
|
||||||
cw_polygon:
|
cw_polygon:
|
||||||
path: ./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 inputFile = File(pubspecOutputPath);
|
||||||
final inputText = await inputFile.readAsString();
|
final inputText = await inputFile.readAsString();
|
||||||
final inputLines = inputText.split('\n');
|
final inputLines = inputText.split('\n');
|
||||||
|
@ -951,6 +1017,10 @@ Future<void> generatePubspec(
|
||||||
output += '\n$cwPolygon';
|
output += '\n$cwPolygon';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasFiro) {
|
||||||
|
output += '\n$cwFiro';
|
||||||
|
}
|
||||||
|
|
||||||
if (hasHaven && !hasMonero) {
|
if (hasHaven && !hasMonero) {
|
||||||
output += '\n$cwSharedExternal\n$cwHaven';
|
output += '\n$cwSharedExternal\n$cwHaven';
|
||||||
} else if (hasHaven) {
|
} else if (hasHaven) {
|
||||||
|
@ -977,7 +1047,8 @@ Future<void> generateWalletTypes(
|
||||||
required bool hasNano,
|
required bool hasNano,
|
||||||
required bool hasBanano,
|
required bool hasBanano,
|
||||||
required bool hasBitcoinCash,
|
required bool hasBitcoinCash,
|
||||||
required bool hasPolygon}) async {
|
required bool hasPolygon,
|
||||||
|
required bool hasFiro}) async {
|
||||||
final walletTypesFile = File(walletTypesPath);
|
final walletTypesFile = File(walletTypesPath);
|
||||||
|
|
||||||
if (walletTypesFile.existsSync()) {
|
if (walletTypesFile.existsSync()) {
|
||||||
|
@ -1020,6 +1091,10 @@ Future<void> generateWalletTypes(
|
||||||
outputContent += '\tWalletType.banano,\n';
|
outputContent += '\tWalletType.banano,\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasFiro) {
|
||||||
|
outputContent += '\tWalletType.firo,\n';
|
||||||
|
}
|
||||||
|
|
||||||
if (hasHaven) {
|
if (hasHaven) {
|
||||||
outputContent += '\tWalletType.haven,\n';
|
outputContent += '\tWalletType.haven,\n';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue