import 'dart:ffi'; import 'dart:typed_data'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:frostdart/frostdart_bindings_generated.dart'; import '../../services/frost.dart'; import '../../wallets/models/incomplete_frost_wallet.dart'; import '../../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? resharerRConfig; ({ int newThreshold, Map resharers, List newParticipants, })? get configData => resharerRConfig != null ? Frost.extractResharerConfigData(rConfig: resharerRConfig!) : 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() { resharerRConfig = null; startResharerData = null; startResharedData = null; resharerComplete = null; newWalletData = null; incompleteWallet = null; } }