Skip to content

Commit

Permalink
refactor: remove dependency of blockchain type for beacon and wallet …
Browse files Browse the repository at this point in the history
…connect
  • Loading branch information
bibash28 committed Jul 4, 2023
1 parent 04076ac commit 5dbef6e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 14 deletions.
3 changes: 0 additions & 3 deletions lib/connection_bridge/model/saved_dapp_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class SavedDappData extends Equatable {
const SavedDappData({
this.peer,
this.walletAddress,
this.blockchainType,
this.wcSessionStore,

//v2
Expand All @@ -24,7 +23,6 @@ class SavedDappData extends Equatable {

final P2PPeer? peer;
final String? walletAddress;
final BlockchainType? blockchainType;
final WCSessionStore? wcSessionStore;

//v2
Expand All @@ -36,7 +34,6 @@ class SavedDappData extends Equatable {
List<Object?> get props => [
peer,
walletAddress,
blockchainType,
wcSessionStore,
sessionData,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ class ConnectedDappRepository {
Future<bool> delete(SavedDappData savedDappData) async {
late String id;

if (savedDappData.blockchainType != null &&
savedDappData.blockchainType == BlockchainType.tezos) {
if (savedDappData.walletAddress != null) {
id = savedDappData.peer!.publicKey;
} else {
id = savedDappData.sessionData!.pairingTopic;
Expand Down Expand Up @@ -113,8 +112,7 @@ class ConnectedDappRepository {
// /// Note: Assumption - name is always unique
// );

if (savedDappData.blockchainType != null &&
savedDappData.blockchainType == BlockchainType.tezos) {
if (savedDappData.walletAddress != null) {
final SavedDappData? matchedData = savedPeerDatas.firstWhereOrNull(
(SavedDappData savedData) =>
savedData.walletAddress == savedDappData.walletAddress &&
Expand All @@ -141,8 +139,7 @@ class ConnectedDappRepository {
// break;
// }

if (savedDappData.blockchainType != null &&
savedDappData.blockchainType == BlockchainType.tezos) {
if (savedDappData.walletAddress != null) {
id = savedDappData.peer!.publicKey;
} else {
id = savedDappData.sessionData!.pairingTopic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class ConfirmConnectionCubit extends Cubit<ConfirmConnectionState> {
final savedPeerData = SavedDappData(
peer: beaconCubit.state.beaconRequest!.peer,
walletAddress: currentAccount.walletAddress,
blockchainType: BlockchainType.tezos,
);
await connectedDappRepository.insert(savedPeerData);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ class _ConnectedDappsViewState extends State<ConnectedDappsView> {
children: [
Expanded(
child: Text(
savedDappData.blockchainType ==
BlockchainType.tezos
savedDappData.walletAddress != null
? savedDappData.peer!.name
: savedDappData.sessionData!
.peer.metadata.name,
Expand Down
3 changes: 1 addition & 2 deletions lib/dashboard/connection/rights/cubit/rights_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class RightsCubit extends Cubit<RightsState> {
);
}

if (savedDappData.blockchainType != null &&
savedDappData.blockchainType == BlockchainType.tezos) {
if (savedDappData.walletAddress != null) {
final Map<dynamic, dynamic> response =
await beacon.removePeerUsingPublicKey(
publicKey: savedDappData.peer!.publicKey,
Expand Down

0 comments on commit 5dbef6e

Please sign in to comment.