fix(useragent): upgraded to new protocol changes

This commit is contained in:
hdbg
2026-04-03 22:03:02 +02:00
parent bc45b9b9ce
commit e47ccc3108
74 changed files with 7446 additions and 4904 deletions

View File

@@ -1,19 +1,27 @@
import 'package:arbiter/features/connection/connection.dart';
import 'package:arbiter/proto/evm.pb.dart';
import 'package:arbiter/proto/user_agent/evm.pb.dart' as ua_evm;
import 'package:arbiter/proto/user_agent.pb.dart';
import 'package:protobuf/well_known_types/google/protobuf/empty.pb.dart';
Future<List<WalletEntry>> listEvmWallets(Connection connection) async {
final response = await connection.ask(
UserAgentRequest(evmWalletList: Empty()),
UserAgentRequest(evm: ua_evm.Request(walletList: Empty())),
);
if (!response.hasEvmWalletList()) {
if (!response.hasEvm()) {
throw Exception(
'Expected EVM wallet list response, got ${response.whichPayload()}',
'Expected EVM response, got ${response.whichPayload()}',
);
}
final result = response.evmWalletList;
final evmResponse = response.evm;
if (!evmResponse.hasWalletList()) {
throw Exception(
'Expected EVM wallet list response, got ${evmResponse.whichPayload()}',
);
}
final result = evmResponse.walletList;
switch (result.whichResult()) {
case WalletListResponse_Result.wallets:
return result.wallets.wallets.toList(growable: false);
@@ -26,15 +34,22 @@ Future<List<WalletEntry>> listEvmWallets(Connection connection) async {
Future<void> createEvmWallet(Connection connection) async {
final response = await connection.ask(
UserAgentRequest(evmWalletCreate: Empty()),
UserAgentRequest(evm: ua_evm.Request(walletCreate: Empty())),
);
if (!response.hasEvmWalletCreate()) {
if (!response.hasEvm()) {
throw Exception(
'Expected EVM wallet create response, got ${response.whichPayload()}',
'Expected EVM response, got ${response.whichPayload()}',
);
}
final result = response.evmWalletCreate;
final evmResponse = response.evm;
if (!evmResponse.hasWalletCreate()) {
throw Exception(
'Expected EVM wallet create response, got ${evmResponse.whichPayload()}',
);
}
final result = evmResponse.walletCreate;
switch (result.whichResult()) {
case WalletCreateResponse_Result.wallet:
return;