import 'dart:ffi'; import 'dart:typed_data'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:frostdart/frostdart_bindings_generated.dart'; import 'package:stackwallet/services/frost.dart'; import 'package:stackwallet/wallets/models/incomplete_frost_wallet.dart'; import 'package:stackwallet/wallets/models/tx_data.dart'; // =================== wallet creation ========================================= final pFrostMultisigConfig = StateProvider((ref) => null); final pFrostMyName = StateProvider((ref) => null); final pFrostStartKeyGenData = StateProvider< ({ String seed, String commitments, Pointer multisigConfigWithNamePtr, Pointer secretShareMachineWrapperPtr, })?>((_) => null); final pFrostSecretSharesData = StateProvider< ({ String share, Pointer secretSharesResPtr, })?>((ref) => null); final pFrostCompletedKeyGenData = StateProvider< ({ Uint8List multisigId, String recoveryString, String serializedKeys, })?>((ref) => null); // ================= transaction creation ====================================== final pFrostTxData = StateProvider((ref) => null); final pFrostAttemptSignData = StateProvider< ({ Pointer machinePtr, String preprocess, })?>((ref) => null); final pFrostContinueSignData = StateProvider< ({ Pointer machinePtr, String share, })?>((ref) => null); // ===================== shared/util =========================================== final pFrostSelectParticipantsUnordered = StateProvider?>((ref) => null); // ========================= resharing ========================================= final pFrostResharingData = Provider((ref) => _ResharingData()); class _ResharingData { String? myName; IncompleteFrostWallet? incompleteWallet; // resharer encoded config string String? resharerConfig; ({ int newThreshold, List resharers, List newParticipants, })? get configData => resharerConfig != null ? Frost.extractResharerConfigData(resharerConfig: resharerConfig!) : null; // resharer start string (for sharing) and machine ({ String resharerStart, Pointer machine, })? startResharerData; // reshared start string (for sharing) and machine ({ String resharedStart, Pointer prior, })? startResharedData; // resharer complete string (for sharing) String? resharerComplete; // new keys and config with an ID ({ String multisigConfig, String serializedKeys, String resharedId, })? newWalletData; // reset/clear all data void reset() { resharerConfig = null; startResharerData = null; startResharedData = null; resharerComplete = null; newWalletData = null; incompleteWallet = null; } }