feat(useragent::evm): basic list & creation
This commit is contained in:
@@ -1,23 +1,40 @@
|
||||
import 'package:arbiter/features/connection/connection.dart';
|
||||
import 'package:arbiter/proto/evm.pb.dart';
|
||||
import 'package:arbiter/proto/user_agent.pb.dart';
|
||||
import 'package:arbiter/providers/connection/connection_manager.dart';
|
||||
import 'package:protobuf/well_known_types/google/protobuf/empty.pb.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
part 'evm.g.dart';
|
||||
|
||||
@riverpod
|
||||
class Evm extends _$Evm {
|
||||
@override
|
||||
Future<List<WalletEntry>?> build() async {
|
||||
final connection = await ref.watch(connectionManagerProvider.future);
|
||||
if (connection == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
await connection.send(UserAgentRequest(
|
||||
evmWalletList: Empty()
|
||||
));
|
||||
return listEvmWallets(connection);
|
||||
}
|
||||
|
||||
final response = await connection.receive();
|
||||
Future<void> refreshWallets() async {
|
||||
final connection = await ref.read(connectionManagerProvider.future);
|
||||
if (connection == null) {
|
||||
state = const AsyncData(null);
|
||||
return;
|
||||
}
|
||||
|
||||
state = const AsyncLoading();
|
||||
state = await AsyncValue.guard(() => listEvmWallets(connection));
|
||||
}
|
||||
|
||||
Future<void> createWallet() async {
|
||||
final connection = await ref.read(connectionManagerProvider.future);
|
||||
if (connection == null) {
|
||||
throw Exception('Not connected to the server.');
|
||||
}
|
||||
|
||||
await createEvmWallet(connection);
|
||||
state = await AsyncValue.guard(() => listEvmWallets(connection));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ final class EvmProvider
|
||||
Evm create() => Evm();
|
||||
}
|
||||
|
||||
String _$evmHash() => r'6d2e0baf7b78a0850d7b99b0be7abde206e088c7';
|
||||
String _$evmHash() => r'f5d05bfa7b820d0b96026a47ca47702a3793af5d';
|
||||
|
||||
abstract class _$Evm extends $AsyncNotifier<List<WalletEntry>?> {
|
||||
FutureOr<List<WalletEntry>?> build();
|
||||
|
||||
Reference in New Issue
Block a user