Skip to content

Commit

Permalink
refactor: wallet connect bug fix #1834
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Aug 25, 2023
1 parent b66f916 commit 936d2ab
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
11 changes: 3 additions & 8 deletions lib/dashboard/connection/operation/cubit/operation_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ class OperationCubit extends Cubit<OperationState> {
final publicKey = walletConnectState.parameters[0]['from'].toString();

final CryptoAccountData? currentAccount =
walletCubit.state.cryptoAccount.data.firstWhereOrNull(
(element) => element.walletAddress == publicKey,
);
walletCubit.getCryptoAccountData(publicKey);

log.i('currentAccount -$currentAccount');
if (currentAccount == null) {
Expand Down Expand Up @@ -467,11 +465,8 @@ class OperationCubit extends Cubit<OperationState> {

final BeaconRequest beaconRequest = beaconCubit.state.beaconRequest!;

final CryptoAccountData? currentAccount =
walletCubit.state.cryptoAccount.data.firstWhereOrNull(
(element) =>
element.walletAddress == beaconRequest.request!.sourceAddress!,
);
final CryptoAccountData? currentAccount = walletCubit
.getCryptoAccountData(beaconRequest.request!.sourceAddress!);

if (currentAccount == null) {
throw ResponseMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,8 @@ class SignPayloadCubit extends Cubit<SignPayloadState> {
case ConnectionBridgeType.beacon:
final BeaconRequest beaconRequest = beaconCubit.state.beaconRequest!;

final CryptoAccountData? currentAccount =
walletCubit.state.cryptoAccount.data.firstWhereOrNull(
(element) =>
element.walletAddress == beaconRequest.request!.sourceAddress!,
);
final CryptoAccountData? currentAccount = walletCubit
.getCryptoAccountData(beaconRequest.request!.sourceAddress!);

if (currentAccount == null) {
throw ResponseMessage(
Expand Down Expand Up @@ -224,9 +221,7 @@ class SignPayloadCubit extends Cubit<SignPayloadState> {
}

final CryptoAccountData? currentAccount =
walletCubit.state.cryptoAccount.data.firstWhereOrNull(
(element) => element.walletAddress == publicKey,
);
walletCubit.getCryptoAccountData(publicKey);

log.i('currentAccount -$currentAccount');
if (currentAccount == null) {
Expand Down
9 changes: 9 additions & 0 deletions lib/wallet/cubit/wallet_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -507,4 +507,13 @@ class WalletCubit extends Cubit<WalletState> {
);
emit(state.copyWith(status: WalletStatus.init));
}

CryptoAccountData? getCryptoAccountData(String publicKey) {
final CryptoAccountData? currentAccount =
state.cryptoAccount.data.firstWhereOrNull(
(element) =>
element.walletAddress.toUpperCase() == publicKey.toUpperCase(),
);
return currentAccount;
}
}

0 comments on commit 936d2ab

Please sign in to comment.