Skip to content

Commit

Permalink
refactor: rename wallet meta class
Browse files Browse the repository at this point in the history
  • Loading branch information
damian-molinski committed Oct 15, 2024
1 parent 8e7b8c9 commit 8520342
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:flutter/material.dart';
import 'package:result_type/result_type.dart';

/// Callback called when a [wallet] is selected.
typedef _OnSelectWallet = Future<void> Function(WalletMeta wallet);
typedef _OnSelectWallet = Future<void> Function(WalletMetadata wallet);

class SelectWalletPanel extends StatefulWidget {
const SelectWalletPanel({
Expand Down Expand Up @@ -67,7 +67,7 @@ class _SelectWalletPanelState extends State<SelectWalletPanel> {
unawaited(RegistrationCubit.of(context).walletLink.refreshWallets());
}

Future<void> _onSelectWallet(WalletMeta wallet) async {
Future<void> _onSelectWallet(WalletMetadata wallet) async {
final registration = RegistrationCubit.of(context);

final success = await registration.walletLink.selectWallet(wallet);
Expand All @@ -88,7 +88,7 @@ class _BlocWallets extends StatelessWidget {

@override
Widget build(BuildContext context) {
return BlocWalletLinkBuilder<Result<List<WalletMeta>, Exception>?>(
return BlocWalletLinkBuilder<Result<List<WalletMetadata>, Exception>?>(
selector: (state) => state.wallets,
builder: (context, state) {
return _Wallets(
Expand All @@ -102,7 +102,7 @@ class _BlocWallets extends StatelessWidget {
}

class _Wallets extends StatelessWidget {
final Result<List<WalletMeta>, Exception>? result;
final Result<List<WalletMetadata>, Exception>? result;
final _OnSelectWallet onSelectWallet;
final VoidCallback onRefreshTap;

Expand All @@ -127,7 +127,7 @@ class _Wallets extends StatelessWidget {
}

class _WalletsList extends StatelessWidget {
final List<WalletMeta> wallets;
final List<WalletMetadata> wallets;
final _OnSelectWallet onSelectWallet;

const _WalletsList({
Expand All @@ -150,7 +150,7 @@ class _WalletsList extends StatelessWidget {
}

class _WalletTile extends StatefulWidget {
final WalletMeta wallet;
final WalletMetadata wallet;
final _OnSelectWallet onSelectWallet;

const _WalletTile({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final _logger = Logger('WalletLinkCubit');
abstract interface class WalletLinkManager {
Future<void> refreshWallets();

Future<bool> selectWallet(WalletMeta mete);
Future<bool> selectWallet(WalletMetadata mete);

void selectRoles(Set<AccountRole> roles);
}
Expand Down Expand Up @@ -47,7 +47,7 @@ final class WalletLinkCubit extends Cubit<WalletLinkStateData>
..addAll(wallets);

final walletsMetaList =
wallets.map(WalletMeta.fromCardanoWallet).toList();
wallets.map(WalletMetadata.fromCardanoWallet).toList();

emit(state.copyWith(wallets: Optional(Success(walletsMetaList))));
} on Exception catch (error, stackTrace) {
Expand All @@ -60,7 +60,7 @@ final class WalletLinkCubit extends Cubit<WalletLinkStateData>
}

@override
Future<bool> selectWallet(WalletMeta meta) async {
Future<bool> selectWallet(WalletMetadata meta) async {
try {
final wallet =
_wallets.firstWhereOrNull((wallet) => wallet.name == meta.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:equatable/equatable.dart';
import 'package:result_type/result_type.dart';

final class WalletLinkStateData extends Equatable {
final Result<List<WalletMeta>, Exception>? wallets;
final Result<List<WalletMetadata>, Exception>? wallets;
final WalletHeader? selectedWallet;
final bool hasEnoughBalance;
final WalletConnectionData? walletConnection;
Expand All @@ -28,7 +28,7 @@ final class WalletLinkStateData extends Equatable {
Set<AccountRole> get defaultRoles => {AccountRole.voter};

WalletLinkStateData copyWith({
Optional<Result<List<WalletMeta>, Exception>>? wallets,
Optional<Result<List<WalletMetadata>, Exception>>? wallets,
Optional<WalletHeader>? selectedWallet,
bool? hasEnoughBalance,
Optional<WalletConnectionData>? walletConnection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ final class SessionBloc extends Bloc<SessionEvent, SessionState> {
return User(
profile: Profile(
walletHeader: WalletHeader(
meta: const WalletMeta(
meta: const WalletMetadata(
name: 'Dummy Wallet',
icon: null,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export 'user/profile.dart';
export 'user/user.dart';
export 'wallet/cardano_wallet_details.dart';
export 'wallet/wallet_header.dart';
export 'wallet/wallet_meta.dart';
export 'wallet/wallet_metadata.dart';
export 'workspace/workspace_proposal_navigation.dart';
export 'workspace/workspace_proposal_segment.dart';
export 'workspace/workspace_proposal_segment_step.dart';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:catalyst_cardano/catalyst_cardano.dart';
import 'package:catalyst_cardano_serialization/catalyst_cardano_serialization.dart';
import 'package:catalyst_voices_models/src/wallet/wallet_meta.dart';
import 'package:catalyst_voices_models/src/wallet/wallet_metadata.dart';
import 'package:equatable/equatable.dart';

/// This class represents basic information's about Wallet,
Expand All @@ -10,7 +10,7 @@ import 'package:equatable/equatable.dart';
/// Instance of this class can come from different places like backend
/// or user interacting with wallet extension.
final class WalletHeader extends Equatable {
final WalletMeta meta;
final WalletMetadata meta;
final Coin balance;
final ShelleyAddress address;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import 'package:catalyst_cardano/catalyst_cardano.dart';
import 'package:equatable/equatable.dart';

final class WalletMeta extends Equatable {
/// Basic information about wallet without any details.
final class WalletMetadata extends Equatable {
final String name;
final String? icon;

const WalletMeta({
const WalletMetadata({
required this.name,
this.icon,
});

WalletMeta.fromCardanoWallet(CardanoWallet wallet)
WalletMetadata.fromCardanoWallet(CardanoWallet wallet)
: this(
name: wallet.name,
icon: wallet.icon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ final class RegistrationService {
final address = await enabledWallet.getChangeAddress();

return WalletHeader(
meta: WalletMeta.fromCardanoWallet(wallet),
meta: WalletMetadata.fromCardanoWallet(wallet),
balance: balance.coin,
address: address,
);
Expand All @@ -77,7 +77,7 @@ final class RegistrationService {
}

return WalletHeader(
meta: const WalletMeta(name: 'Dummy Wallet'),
meta: const WalletMetadata(name: 'Dummy Wallet'),
balance: Coin.fromAda(10),
address: _testNetAddress,
);
Expand Down

0 comments on commit 8520342

Please sign in to comment.