add lib spark local dep for testing

This commit is contained in:
julian 2023-11-28 10:13:10 -06:00
parent 0cb1e90097
commit 6ddef9f077
8 changed files with 35 additions and 6 deletions

View file

@ -1,8 +1,10 @@
import 'dart:typed_data';
import 'package:flutter_libsparkmobile/flutter_libsparkmobile.dart';
import 'package:isar/isar.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
import 'package:stackwallet/wallets/models/tx_data.dart';
import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart';
import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart';
@ -27,22 +29,28 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
throw UnimplementedError();
}
Future<Address> generateNextSparkAddress() async {
Future<Address> generateNextSparkAddress({int index = 1}) async {
final highestStoredDiversifier =
(await getCurrentReceivingSparkAddress())?.derivationIndex;
// default to starting at 1 if none found
final int diversifier = (highestStoredDiversifier ?? 0) + 1;
// TODO: use real data
final String derivationPath = "";
final Uint8List publicKey = Uint8List(0); // incomingViewKey?
final String addressString = "";
final root = await getRootHDNode();
final derivationPath = "$kSparkBaseDerivationPath$index";
final keys = root.derivePath(derivationPath);
final String addressString = await LibSpark.getAddress(
privateKey: keys.privateKey.data,
index: index,
diversifier: diversifier,
isTestNet: cryptoCurrency.network == CryptoCurrencyNetwork.test,
);
return Address(
walletId: walletId,
value: addressString,
publicKey: publicKey,
publicKey: keys.publicKey.data,
derivationIndex: diversifier,
derivationPath: DerivationPath()..value = derivationPath,
type: AddressType.spark,

View file

@ -10,6 +10,7 @@
#include <devicelocale/devicelocale_plugin.h>
#include <flutter_libepiccash/flutter_libepiccash_plugin.h>
#include <flutter_libmonero/flutter_libmonero_plugin.h>
#include <flutter_libsparkmobile/flutter_libsparkmobile_plugin.h>
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
#include <isar_flutter_libs/isar_flutter_libs_plugin.h>
#include <stack_wallet_backup/stack_wallet_backup_plugin.h>
@ -29,6 +30,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) flutter_libmonero_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterLibmoneroPlugin");
flutter_libmonero_plugin_register_with_registrar(flutter_libmonero_registrar);
g_autoptr(FlPluginRegistrar) flutter_libsparkmobile_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterLibsparkmobilePlugin");
flutter_libsparkmobile_plugin_register_with_registrar(flutter_libsparkmobile_registrar);
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);

View file

@ -7,6 +7,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
devicelocale
flutter_libepiccash
flutter_libmonero
flutter_libsparkmobile
flutter_secure_storage_linux
isar_flutter_libs
stack_wallet_backup

View file

@ -13,6 +13,7 @@ import desktop_drop
import device_info_plus
import devicelocale
import flutter_libepiccash
import flutter_libsparkmobile
import flutter_local_notifications
import flutter_secure_storage_macos
import isar_flutter_libs
@ -34,6 +35,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
DevicelocalePlugin.register(with: registry.registrar(forPlugin: "DevicelocalePlugin"))
FlutterLibepiccashPlugin.register(with: registry.registrar(forPlugin: "FlutterLibepiccashPlugin"))
FlutterLibsparkmobilePlugin.register(with: registry.registrar(forPlugin: "FlutterLibsparkmobilePlugin"))
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
IsarFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "IsarFlutterLibsPlugin"))

View file

@ -659,6 +659,13 @@ packages:
relative: true
source: path
version: "0.0.1"
flutter_libsparkmobile:
dependency: "direct main"
description:
path: "../flutter_libsparkmobile"
relative: true
source: path
version: "0.0.1"
flutter_lints:
dependency: "direct dev"
description:

View file

@ -27,6 +27,9 @@ dependencies:
lelantus:
path: ./crypto_plugins/flutter_liblelantus
flutter_libsparkmobile:
path: ../flutter_libsparkmobile
flutter_libmonero:
path: ./crypto_plugins/flutter_libmonero

View file

@ -9,6 +9,7 @@
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
#include <desktop_drop/desktop_drop_plugin.h>
#include <flutter_libepiccash/flutter_libepiccash_plugin_c_api.h>
#include <flutter_libsparkmobile/flutter_libsparkmobile_plugin_c_api.h>
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <isar_flutter_libs/isar_flutter_libs_plugin.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
@ -24,6 +25,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("DesktopDropPlugin"));
FlutterLibepiccashPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterLibepiccashPluginCApi"));
FlutterLibsparkmobilePluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterLibsparkmobilePluginCApi"));
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
IsarFlutterLibsPluginRegisterWithRegistrar(

View file

@ -6,6 +6,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
connectivity_plus
desktop_drop
flutter_libepiccash
flutter_libsparkmobile
flutter_secure_storage_windows
isar_flutter_libs
permission_handler_windows