From 97e25a73be14607365c389a8b2c38f8128cd80e5 Mon Sep 17 00:00:00 2001 From: detherminal <76167420+detherminal@users.noreply.github.com> Date: Fri, 26 May 2023 22:25:59 +0300 Subject: [PATCH] docs: explain and comment code --- lib/db/isar/main_db.dart | 5 +++++ lib/route_generator.dart | 5 +++++ lib/services/coins/coin_service.dart | 12 ++++++++++++ lib/utilities/block_explorers.dart | 4 +++- lib/widgets/choose_coin_view.dart | 8 ++++++++ 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/db/isar/main_db.dart b/lib/db/isar/main_db.dart index ce2cd8fa8..5533481c8 100644 --- a/lib/db/isar/main_db.dart +++ b/lib/db/isar/main_db.dart @@ -24,6 +24,11 @@ import 'package:tuple/tuple.dart'; part '../queries/queries.dart'; +/* + * This file includes the functions that are used to interact with the main database. + * To add a new function, add it in the class MainDB. + */ + class MainDB { MainDB._(); static MainDB? _instance; diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 464c1906a..c34071740 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -165,6 +165,11 @@ import 'package:tuple/tuple.dart'; import 'models/isar/models/contact_entry.dart'; +/* + * This file contains all the routes for the app. + * To add a new route, add it to the switch statement in the generateRoute method. + */ + class RouteGenerator { static const bool useMaterialPageRoute = true; diff --git a/lib/services/coins/coin_service.dart b/lib/services/coins/coin_service.dart index 7caadecfb..c3ecbbd32 100644 --- a/lib/services/coins/coin_service.dart +++ b/lib/services/coins/coin_service.dart @@ -34,6 +34,18 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/prefs.dart'; +/* + * This file implements the CoinServiceAPI abstract class that is used by wallet files to implement the coin specific functionality. + * @param coin: The coin type + * @param walletId: The wallet id + * @param walletName: The wallet name + * @param secureStorageInterface: The interface for securely storing data like private keys, mnemonics, passphrases, etc. + * @param node: The node to connect to + * @param tracker: The transaction notification tracker + * @param prefs: The preferences + * @return: The coin service API + */ + abstract class CoinServiceAPI { CoinServiceAPI(); diff --git a/lib/utilities/block_explorers.dart b/lib/utilities/block_explorers.dart index efeb2380d..9a2ab609b 100644 --- a/lib/utilities/block_explorers.dart +++ b/lib/utilities/block_explorers.dart @@ -13,6 +13,7 @@ import 'package:stackwallet/db/isar/main_db.dart'; import 'package:stackwallet/models/isar/models/block_explorer.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; +// Returns the default block explorer URL for the given coin and txid Uri getDefaultBlockExplorerUrlFor({ required Coin coin, required String txid, @@ -59,7 +60,7 @@ Uri getDefaultBlockExplorerUrlFor({ } } -/// returns internal Isar ID for the inserted object/record +// Returns internal Isar ID for the inserted object/record Future setBlockExplorerForCoin({ required Coin coin, required Uri url, @@ -72,6 +73,7 @@ Future setBlockExplorerForCoin({ ); } +// Returns the block explorer URL for the given coin and txid Uri getBlockExplorerTransactionUrlFor({ required Coin coin, required String txid, diff --git a/lib/widgets/choose_coin_view.dart b/lib/widgets/choose_coin_view.dart index bfb5705ee..912407966 100644 --- a/lib/widgets/choose_coin_view.dart +++ b/lib/widgets/choose_coin_view.dart @@ -24,6 +24,14 @@ import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; +/* + * This widget is used to choose a coin from a list of coins. + * @param title: The title of the page. + * @param coinAdditional: Additional text to be displayed after the coin name. + * @param nextRouteName: The name of the route to be pushed when a coin is selected. + * @return A widget that displays a list of coins. + */ + class ChooseCoinView extends ConsumerStatefulWidget { const ChooseCoinView({ Key? key,