From 150c0fad3a129b4889536d673d47be062cdd683d Mon Sep 17 00:00:00 2001 From: d-reader-luka <125265091+d-reader-luka@users.noreply.github.com> Date: Fri, 10 May 2024 12:33:59 +0200 Subject: [PATCH] chore: rename nft to digital asset (#90) --- Makefile | 4 +- android/app/src/main/AndroidManifest.xml | 8 +- ...-mint-bg.mp4 => digital_asset-mint-bg.mp4} | Bin assets/icons/{used_nft.svg => used_asset.svg} | 0 lib/constants/enums.dart | 6 +- lib/constants/routes.dart | 4 +- .../auction_house/domain/models/listing.dart | 16 +-- .../candy_machine/domain/models/receipt.dart | 14 +-- .../providers/candy_machine_providers.g.dart | 2 +- .../domain/models/owned_issue.dart | 39 ------- .../controller/comic_issue_controller.dart | 4 +- .../controller/comic_issue_controller.g.dart | 2 +- .../widgets/tabs/about/rarities.dart | 5 +- .../tabs/listings/listed_item_row.dart | 8 +- .../widgets/tabs/listings/listed_items.dart | 6 +- .../digital_asset_remote_data_source.dart | 73 ++++++++++++ .../digital_asset_repository_impl.dart | 22 ++++ .../domain/models/buy_digital_asset.dart} | 4 +- .../domain/models/digital_asset.dart} | 22 ++-- .../providers/digital_asset_provider.dart | 23 ++++ .../digital_asset_repository.dart | 10 ++ .../providers/digital_asset_controller.dart} | 66 +++++------ .../digital_asset_controller.g.dart} | 21 ++-- .../providers/digital_asset_providers.dart} | 24 ++-- .../animations/mint_animation_screen.dart | 81 +++++++------- .../open_asset_animation_screen.dart} | 13 ++- .../screens/digital_asset_details.dart} | 104 ++++++++++-------- .../presentation/utils/extensions.dart | 40 +++++++ .../presentation/utils/utils.dart | 2 + .../widgets/digital_asset_card.dart} | 4 +- .../widgets/modal_bottom_sheet.dart | 37 ++++--- .../presentation/screens/e_reader.dart | 29 ++--- .../providers/owned/owned_controller.dart | 40 ++++--- .../providers/owned/owned_controller.g.dart | 2 +- ...ard.dart => owned_digital_asset_card.dart} | 28 ++--- .../widgets/cards/owned_issue_card.dart | 32 +----- ...=> owned_digital_assets_bottom_sheet.dart} | 44 ++++---- .../widgets/tabs/owned/owned.dart | 5 +- ...s.dart => owned_digital_assets_items.dart} | 12 +- .../datasource/nft_remote_data_source.dart | 64 ----------- .../repositories/nft_repository_impl.dart | 20 ---- .../nft/domain/providers/nft_provider.dart | 21 ---- .../domain/repositories/nft_repository.dart | 8 -- .../nft/presentation/utils/extensions.dart | 39 ------- .../nft/presentation/utils/utils.dart | 1 - .../providers/change_network.g.dart | 2 +- .../transaction_remote_data_source.dart | 18 +-- .../transaction_repository_impl.dart | 14 ++- .../repositories/transaction_repository.dart | 6 +- .../providers/wallet_providers.dart | 10 +- lib/routing/router.dart | 20 ++-- .../data/remote/notification_service.dart | 9 +- lib/shared/domain/models/enums.dart | 2 +- .../environment/environment_notifier.g.dart | 2 +- .../providers/solana/solana_notifier.g.dart | 2 +- .../solana/solana_transaction_notifier.dart | 49 +++++---- .../solana/solana_transaction_notifier.g.dart | 2 +- .../providers/global/global_notifier.g.dart | 2 +- lib/shared/utils/formatter.dart | 10 +- lib/shared/widgets/buttons/unwrap_button.dart | 6 +- lib/shared/widgets/unsorted/rarity.dart | 6 +- publishing/package.json | 2 +- pubspec.lock | 2 +- pubspec.yaml | 3 +- 64 files changed, 590 insertions(+), 586 deletions(-) rename assets/animation_files/{nft-mint-bg.mp4 => digital_asset-mint-bg.mp4} (100%) rename assets/icons/{used_nft.svg => used_asset.svg} (100%) create mode 100644 lib/features/digital_asset/data/datasource/digital_asset_remote_data_source.dart create mode 100644 lib/features/digital_asset/data/repositories/digital_asset_repository_impl.dart rename lib/features/{nft/domain/models/buy_nft.dart => digital_asset/domain/models/buy_digital_asset.dart} (91%) rename lib/features/{nft/domain/models/nft.dart => digital_asset/domain/models/digital_asset.dart} (80%) create mode 100644 lib/features/digital_asset/domain/providers/digital_asset_provider.dart create mode 100644 lib/features/digital_asset/domain/repositories/digital_asset_repository.dart rename lib/features/{nft/presentation/providers/nft_controller.dart => digital_asset/presentation/providers/digital_asset_controller.dart} (79%) rename lib/features/{nft/presentation/providers/nft_controller.g.dart => digital_asset/presentation/providers/digital_asset_controller.g.dart} (51%) rename lib/features/{nft/presentation/providers/nft_providers.dart => digital_asset/presentation/providers/digital_asset_providers.dart} (78%) rename lib/features/{nft => digital_asset}/presentation/screens/animations/mint_animation_screen.dart (85%) rename lib/features/{nft/presentation/screens/animations/open_nft_animation_screen.dart => digital_asset/presentation/screens/animations/open_asset_animation_screen.dart} (88%) rename lib/features/{nft/presentation/screens/nft_details.dart => digital_asset/presentation/screens/digital_asset_details.dart} (86%) create mode 100644 lib/features/digital_asset/presentation/utils/extensions.dart create mode 100644 lib/features/digital_asset/presentation/utils/utils.dart rename lib/features/{nft/presentation/widgets/nft_card.dart => digital_asset/presentation/widgets/digital_asset_card.dart} (93%) rename lib/features/{nft => digital_asset}/presentation/widgets/modal_bottom_sheet.dart (81%) rename lib/features/library/presentation/widgets/cards/{owned_nft_card.dart => owned_digital_asset_card.dart} (81%) rename lib/features/library/presentation/widgets/modals/{owned_nfts_bottom_sheet.dart => owned_digital_assets_bottom_sheet.dart} (86%) rename lib/features/library/presentation/widgets/tabs/owned/{owned_nfts_items.dart => owned_digital_assets_items.dart} (94%) delete mode 100644 lib/features/nft/data/datasource/nft_remote_data_source.dart delete mode 100644 lib/features/nft/data/repositories/nft_repository_impl.dart delete mode 100644 lib/features/nft/domain/providers/nft_provider.dart delete mode 100644 lib/features/nft/domain/repositories/nft_repository.dart delete mode 100644 lib/features/nft/presentation/utils/extensions.dart delete mode 100644 lib/features/nft/presentation/utils/utils.dart diff --git a/Makefile b/Makefile index 1aef7a69..e17ca4cc 100644 --- a/Makefile +++ b/Makefile @@ -36,12 +36,12 @@ build-dev: build-prod: flutter clean && \ - flutter build appbundle --release --dart-define=apiUrl=$(API_URL_PROD) --dart-define=apiUrlDevnet=$(API_URL_PROD_DEVNET) --dart-define=sentryDsn=${sentryDsn} --flavor prod --target lib/main_prod.dart && \ + flutter build appbundle --release --dart-define=apiUrl=$(API_URL_PROD) --dart-define=apiUrlDevnet=$(API_URL_PROD) --dart-define=sentryDsn=${sentryDsn} --flavor prod --target lib/main_prod.dart && \ mv ./build/app/outputs/bundle/prodRelease/app-prod-release.aab ./apks/dReader.aab build-prod-apk: flutter clean && \ - flutter build apk --split-per-abi --release --dart-define=apiUrl=$(API_URL_PROD) --dart-define=apiUrlDevnet=$(API_URL_PROD_DEVNET) --dart-define=sentryDsn=${sentryDsn} --flavor prod --target lib/main_prod.dart && \ + flutter build apk --split-per-abi --release --dart-define=apiUrl=$(API_URL_PROD) --dart-define=apiUrlDevnet=$(API_URL_PROD) --dart-define=sentryDsn=${sentryDsn} --flavor prod --target lib/main_prod.dart && \ mv ./build/app/outputs/flutter-apk/app-armeabi-v7a-prod-release.apk ./apks/dReader.apk start-saga-release: diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 48a6693a..952f26ef 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -42,7 +42,13 @@ - + + diff --git a/assets/animation_files/nft-mint-bg.mp4 b/assets/animation_files/digital_asset-mint-bg.mp4 similarity index 100% rename from assets/animation_files/nft-mint-bg.mp4 rename to assets/animation_files/digital_asset-mint-bg.mp4 diff --git a/assets/icons/used_nft.svg b/assets/icons/used_asset.svg similarity index 100% rename from assets/icons/used_nft.svg rename to assets/icons/used_asset.svg diff --git a/lib/constants/enums.dart b/lib/constants/enums.dart index a6e39345..f1e7cfd4 100644 --- a/lib/constants/enums.dart +++ b/lib/constants/enums.dart @@ -2,10 +2,8 @@ enum WalkthroughKeys { connectWallet, connectWalletTutorial, issueDetails, - openNft, library, secondarySale, - nftDetails, changeNetwork, lowPowerMode, verifyEmail, @@ -18,7 +16,7 @@ enum NotificationDataKey { comicIssueId, comicSlug, creatorSlug, - nftAddress, + digitalAssetAddress, externalUrl, } @@ -27,7 +25,7 @@ extension NotificationDataKeyString on NotificationDataKey { NotificationDataKey.comicIssueId: 'comicIssueId', NotificationDataKey.comicSlug: 'comicSlug', NotificationDataKey.creatorSlug: 'creatorSlug', - NotificationDataKey.nftAddress: 'nftAddress', + NotificationDataKey.digitalAssetAddress: 'digitalAssetAddress', NotificationDataKey.externalUrl: 'externalUrl' }; diff --git a/lib/constants/routes.dart b/lib/constants/routes.dart index 0641b5db..fc3af98b 100644 --- a/lib/constants/routes.dart +++ b/lib/constants/routes.dart @@ -9,7 +9,7 @@ class RoutePath { // Authorized Routes static const home = '/'; - static const nftDetails = 'nft-details'; + static const digitalAssetDetails = 'digital-asset-details'; static const comicDetails = 'comic-details'; static const comicDetailsInfo = 'comic-details-info'; static const comicIssueDetails = 'comic-issue'; @@ -30,6 +30,6 @@ class RoutePath { static const transactionStatusTimeout = 'status-timeout'; static const doneMinting = 'animation/done-minting'; - static const openNftAnimation = 'animation/open-nft'; + static const openDigitalAssetAnimation = 'animation/open-digital-asset'; static const mintLoadingAnimation = 'animation/mint-loading'; } diff --git a/lib/features/auction_house/domain/models/listing.dart b/lib/features/auction_house/domain/models/listing.dart index 12d08024..7a5efd47 100644 --- a/lib/features/auction_house/domain/models/listing.dart +++ b/lib/features/auction_house/domain/models/listing.dart @@ -1,9 +1,9 @@ -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; class ListingModel { final int id; - final String nftAddress, name, cover, rarity; - final List attributes; + final String assetAddress, name, cover, rarity; + final List attributes; final Seller seller; final String tokenAddress; final int price; @@ -12,7 +12,7 @@ class ListingModel { ListingModel({ required this.id, - required this.nftAddress, + required this.assetAddress, required this.name, required this.cover, required this.attributes, @@ -27,11 +27,11 @@ class ListingModel { factory ListingModel.fromJson(Map json) { return ListingModel( id: json['id'], - nftAddress: json['nftAddress'], + assetAddress: json['assetAddress'], name: json['name'], cover: json['cover'], - attributes: List.from( - json['attributes'].map((x) => NftAttribute.fromJson(x)), + attributes: List.from( + json['attributes'].map((x) => DigitalAssetAttribute.fromJson(x)), ), seller: Seller.fromJson(json['seller']), tokenAddress: json['tokenAddress'], @@ -44,7 +44,7 @@ class ListingModel { Map toJson() { final Map data = {}; data['id'] = id; - data['nftAddress'] = nftAddress; + data['assetAddress'] = assetAddress; data['name'] = name; data['cover'] = cover; data['attributes'] = List.from(attributes.map((x) => x.toJson())); diff --git a/lib/features/candy_machine/domain/models/receipt.dart b/lib/features/candy_machine/domain/models/receipt.dart index 01223f92..9e9dd7c1 100644 --- a/lib/features/candy_machine/domain/models/receipt.dart +++ b/lib/features/candy_machine/domain/models/receipt.dart @@ -1,12 +1,12 @@ class Receipt { - final ReceiptNft nft; + final AssetReceipt partialAsset; final ReceiptBuyer buyer; final int price; final String timestamp; final String candyMachineAddress; Receipt({ - required this.nft, + required this.partialAsset, required this.buyer, required this.price, required this.timestamp, @@ -15,7 +15,7 @@ class Receipt { factory Receipt.fromJson(dynamic json) { return Receipt( - nft: ReceiptNft.fromJson(json['nft']), + partialAsset: AssetReceipt.fromJson(json['asset']), buyer: ReceiptBuyer.fromJson(json['buyer']), price: json['price'], timestamp: json['timestamp'], @@ -24,17 +24,17 @@ class Receipt { } } -class ReceiptNft { +class AssetReceipt { final String address; final String name; - ReceiptNft({ + AssetReceipt({ required this.address, required this.name, }); - factory ReceiptNft.fromJson(dynamic json) { - return ReceiptNft( + factory AssetReceipt.fromJson(dynamic json) { + return AssetReceipt( address: json['address'], name: json['name'], ); diff --git a/lib/features/candy_machine/presentations/providers/candy_machine_providers.g.dart b/lib/features/candy_machine/presentations/providers/candy_machine_providers.g.dart index ef953ae9..54e2fdd7 100644 --- a/lib/features/candy_machine/presentations/providers/candy_machine_providers.g.dart +++ b/lib/features/candy_machine/presentations/providers/candy_machine_providers.g.dart @@ -6,7 +6,7 @@ part of 'candy_machine_providers.dart'; // RiverpodGenerator // ************************************************************************** -String _$candyMachineHash() => r'd04fbc85f2ef6ca88178814682d237cfed855939'; +String _$candyMachineHash() => r'e4d5dd23ef8e66c169facf8a85e505e5f9b6b253'; /// Copied from Dart SDK class _SystemHash { diff --git a/lib/features/comic_issue/domain/models/owned_issue.dart b/lib/features/comic_issue/domain/models/owned_issue.dart index 1ffb9020..f6045465 100644 --- a/lib/features/comic_issue/domain/models/owned_issue.dart +++ b/lib/features/comic_issue/domain/models/owned_issue.dart @@ -1,9 +1,6 @@ -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; - class OwnedComicIssue { final int id, number, ownedCopiesCount; final String title, slug, cover; - final PartialNftModel? ownedNft; OwnedComicIssue({ required this.id, @@ -12,7 +9,6 @@ class OwnedComicIssue { required this.title, required this.slug, required this.cover, - this.ownedNft, }); factory OwnedComicIssue.fromJson(dynamic json) { @@ -23,41 +19,6 @@ class OwnedComicIssue { title: json['title'], slug: json['slug'], cover: json['cover'], - ownedNft: json['ownedNft'] != null - ? PartialNftModel.fromJson(json['ownedNft']) - : null, - ); - } -} - -class PartialNftModel { - final String address, rarity; - final bool isUsed, isSigned; - final List attributes; - - PartialNftModel({ - required this.address, - required this.rarity, - required this.isSigned, - required this.isUsed, - required this.attributes, - }); - - factory PartialNftModel.fromJson(dynamic json) { - return PartialNftModel( - address: json['address'], - rarity: json['rarity'], - isSigned: json['isSigned'], - isUsed: json['isUsed'], - attributes: json['attributes'] != null - ? List.from( - json['attributes'].map( - (item) => NftAttribute.fromJson( - item, - ), - ), - ) - : [], ); } } diff --git a/lib/features/comic_issue/presentation/providers/controller/comic_issue_controller.dart b/lib/features/comic_issue/presentation/providers/controller/comic_issue_controller.dart index 7ec3e273..2ce888a4 100644 --- a/lib/features/comic_issue/presentation/providers/controller/comic_issue_controller.dart +++ b/lib/features/comic_issue/presentation/providers/controller/comic_issue_controller.dart @@ -4,7 +4,7 @@ import 'package:d_reader_flutter/features/auction_house/presentation/providers/a import 'package:d_reader_flutter/features/auction_house/presentation/providers/listings_provider.dart'; import 'package:d_reader_flutter/features/candy_machine/domain/models/candy_machine.dart'; import 'package:d_reader_flutter/features/candy_machine/presentations/providers/candy_machine_providers.dart'; -import 'package:d_reader_flutter/features/nft/presentation/providers/nft_providers.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/providers/digital_asset_providers.dart'; import 'package:d_reader_flutter/shared/domain/providers/environment/environment_notifier.dart'; import 'package:d_reader_flutter/shared/domain/providers/solana/solana_transaction_notifier.dart'; import 'package:d_reader_flutter/shared/presentations/providers/global/global_notifier.dart'; @@ -69,7 +69,7 @@ class ComicIssueController extends _$ComicIssueController { if (result != successResult) { return displaySnackbar(text: result, isError: true); } - ref.invalidate(nftsProvider); + ref.invalidate(digitalAssetsProvider); onSuccessMint(); }); } catch (exception) { diff --git a/lib/features/comic_issue/presentation/providers/controller/comic_issue_controller.g.dart b/lib/features/comic_issue/presentation/providers/controller/comic_issue_controller.g.dart index 3b100d89..c9b66126 100644 --- a/lib/features/comic_issue/presentation/providers/controller/comic_issue_controller.g.dart +++ b/lib/features/comic_issue/presentation/providers/controller/comic_issue_controller.g.dart @@ -7,7 +7,7 @@ part of 'comic_issue_controller.dart'; // ************************************************************************** String _$comicIssueControllerHash() => - r'a80eeee74b09695a987182f68b600a8e9d476342'; + r'02f18d7f77a8811e934f4100694f4f116bd052ed'; /// See also [ComicIssueController]. @ProviderFor(ComicIssueController) diff --git a/lib/features/comic_issue/presentation/widgets/tabs/about/rarities.dart b/lib/features/comic_issue/presentation/widgets/tabs/about/rarities.dart index ab2ccacb..db4fc1bc 100644 --- a/lib/features/comic_issue/presentation/widgets/tabs/about/rarities.dart +++ b/lib/features/comic_issue/presentation/widgets/tabs/about/rarities.dart @@ -1,7 +1,7 @@ import 'package:d_reader_flutter/constants/routes.dart'; import 'package:d_reader_flutter/shared/domain/models/enums.dart'; import 'package:d_reader_flutter/shared/domain/models/stateless_cover.dart'; -import 'package:d_reader_flutter/features/nft/presentation/utils/extensions.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/utils/extensions.dart'; import 'package:d_reader_flutter/shared/utils/screen_navigation.dart'; import 'package:d_reader_flutter/shared/widgets/image_widgets/cached_image_bg_placeholder.dart'; import 'package:d_reader_flutter/shared/widgets/unsorted/rarity.dart'; @@ -46,7 +46,8 @@ class RaritiesWidget extends StatelessWidget { height: 16, ), RarityWidget( - rarity: covers[index].rarity?.rarityEnum ?? NftRarity.none, + rarity: covers[index].rarity?.rarityEnum ?? + DigitalAssetRarity.none, iconPath: 'assets/icons/rarity.svg', ), ], diff --git a/lib/features/comic_issue/presentation/widgets/tabs/listings/listed_item_row.dart b/lib/features/comic_issue/presentation/widgets/tabs/listings/listed_item_row.dart index 5c248fa2..3a88fe24 100644 --- a/lib/features/comic_issue/presentation/widgets/tabs/listings/listed_item_row.dart +++ b/lib/features/comic_issue/presentation/widgets/tabs/listings/listed_item_row.dart @@ -1,11 +1,11 @@ -import 'package:d_reader_flutter/features/nft/presentation/utils/extensions.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/utils/extensions.dart'; import 'package:d_reader_flutter/features/user/presentation/providers/user_providers.dart'; import 'package:d_reader_flutter/features/auction_house/domain/models/listing.dart'; import 'package:d_reader_flutter/features/auction_house/presentation/providers/auction_house_providers.dart'; import 'package:d_reader_flutter/shared/domain/providers/environment/environment_notifier.dart'; import 'package:d_reader_flutter/shared/theme/app_colors.dart'; import 'package:d_reader_flutter/shared/utils/formatter.dart'; -import 'package:d_reader_flutter/features/nft/presentation/utils/utils.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/utils/utils.dart'; import 'package:d_reader_flutter/shared/widgets/image_widgets/common_cached_image.dart'; import 'package:d_reader_flutter/shared/widgets/unsorted/rarity.dart'; import 'package:d_reader_flutter/shared/widgets/unsorted/solana_price.dart'; @@ -73,7 +73,7 @@ class ListingItem extends ConsumerWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - shortenNftName(listing.name), + shortenDigitalAssetName(listing.name), style: textTheme.bodySmall, ), const SizedBox( @@ -134,7 +134,7 @@ class ListingItem extends ConsumerWidget { ? ColorPalette.lightblue : ColorPalette.dReaderGreen, icon: listing.isUsed - ? 'assets/icons/used_nft.svg' + ? 'assets/icons/used_asset.svg' : 'assets/icons/mint_icon.svg', ), const SizedBox( diff --git a/lib/features/comic_issue/presentation/widgets/tabs/listings/listed_items.dart b/lib/features/comic_issue/presentation/widgets/tabs/listings/listed_items.dart index 2708133a..53f9d691 100644 --- a/lib/features/comic_issue/presentation/widgets/tabs/listings/listed_items.dart +++ b/lib/features/comic_issue/presentation/widgets/tabs/listings/listed_items.dart @@ -3,6 +3,7 @@ import 'package:d_reader_flutter/features/auction_house/presentation/providers/l import 'package:d_reader_flutter/features/comic_issue/domain/models/comic_issue.dart'; import 'package:d_reader_flutter/shared/theme/app_colors.dart'; import 'package:d_reader_flutter/features/comic_issue/presentation/widgets/tabs/listings/listed_item_row.dart'; +import 'package:d_reader_flutter/shared/widgets/unsorted/carrot_error_widget.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; @@ -27,7 +28,10 @@ class ListedItems extends ConsumerWidget { return ListedItemsBuilder(listings: listings); }, error: (error, stackTrace) { - return const Text('Failed to fetch data'); + return const CarrotErrorWidget( + mainErrorText: 'We ran into some issues', + adviceText: 'We are working on a fix. Thanks for your patience!', + ); }, loading: () { return const Center( diff --git a/lib/features/digital_asset/data/datasource/digital_asset_remote_data_source.dart b/lib/features/digital_asset/data/datasource/digital_asset_remote_data_source.dart new file mode 100644 index 00000000..66037538 --- /dev/null +++ b/lib/features/digital_asset/data/datasource/digital_asset_remote_data_source.dart @@ -0,0 +1,73 @@ +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; +import 'package:d_reader_flutter/shared/data/remote/network_service.dart'; +import 'package:d_reader_flutter/shared/domain/models/either.dart'; +import 'package:d_reader_flutter/shared/exceptions/exceptions.dart'; + +const String _controllerPath = 'asset'; + +abstract class DigitalAssetDataSource { + Future> getDigitalAsset( + String address); + Future>> getDigitalAssets( + String query); +} + +class DigitalAssetRemoteDataSource implements DigitalAssetDataSource { + final NetworkService networkService; + + DigitalAssetRemoteDataSource(this.networkService); + + @override + Future> getDigitalAsset( + String address) async { + try { + final response = + await networkService.get('/$_controllerPath/get/$address'); + return response.fold((exception) => Left(exception), (result) { + return Right( + DigitalAssetModel.fromJson( + result.data, + ), + ); + }); + } catch (exception) { + return Left( + AppException( + message: 'Unknown exception occurred', + statusCode: 500, + identifier: + '${exception.toString()}DigitalAssetRemoteDataSource.getDigitalAsset', + ), + ); + } + } + + @override + Future>> getDigitalAssets( + String query) async { + try { + final response = await networkService.get('/$_controllerPath/get?$query'); + + return response.fold((exception) => Left(exception), (result) { + return Right( + List.from( + result.data.map( + (item) => DigitalAssetModel.fromJson( + item, + ), + ), + ), + ); + }); + } catch (exception) { + return Left( + AppException( + message: 'Unknown exception occurred', + statusCode: 500, + identifier: + '${exception.toString()}DigitalAssetRemoteDataSource.getDigitalAssets', + ), + ); + } + } +} diff --git a/lib/features/digital_asset/data/repositories/digital_asset_repository_impl.dart b/lib/features/digital_asset/data/repositories/digital_asset_repository_impl.dart new file mode 100644 index 00000000..9b27f412 --- /dev/null +++ b/lib/features/digital_asset/data/repositories/digital_asset_repository_impl.dart @@ -0,0 +1,22 @@ +import 'package:d_reader_flutter/features/digital_asset/data/datasource/digital_asset_remote_data_source.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/repositories/digital_asset_repository.dart'; +import 'package:d_reader_flutter/shared/domain/models/either.dart'; +import 'package:d_reader_flutter/shared/exceptions/exceptions.dart'; + +class DigitalAssetRepositoryImpl implements DigitalAssetRepository { + final DigitalAssetDataSource dataSource; + + DigitalAssetRepositoryImpl(this.dataSource); + @override + Future> getDigitalAsset( + String address) { + return dataSource.getDigitalAsset(address); + } + + @override + Future>> getDigitalAssets( + String query) { + return dataSource.getDigitalAssets(query); + } +} diff --git a/lib/features/nft/domain/models/buy_nft.dart b/lib/features/digital_asset/domain/models/buy_digital_asset.dart similarity index 91% rename from lib/features/nft/domain/models/buy_nft.dart rename to lib/features/digital_asset/domain/models/buy_digital_asset.dart index c23ece94..d0145488 100644 --- a/lib/features/nft/domain/models/buy_nft.dart +++ b/lib/features/digital_asset/domain/models/buy_digital_asset.dart @@ -1,8 +1,8 @@ -class BuyNftInput { +class BuyDigitalAsset { final String mintAccount, sellerAddress, buyerAddress; final int price; - BuyNftInput({ + BuyDigitalAsset({ required this.mintAccount, required this.price, required this.sellerAddress, diff --git a/lib/features/nft/domain/models/nft.dart b/lib/features/digital_asset/domain/models/digital_asset.dart similarity index 80% rename from lib/features/nft/domain/models/nft.dart rename to lib/features/digital_asset/domain/models/digital_asset.dart index 53fa4085..c01c48e7 100644 --- a/lib/features/nft/domain/models/nft.dart +++ b/lib/features/digital_asset/domain/models/digital_asset.dart @@ -1,5 +1,5 @@ -class NftModel { - final List attributes; +class DigitalAssetModel { + final List attributes; final String address, comicName, comicIssueName, @@ -13,7 +13,7 @@ class NftModel { final bool isUsed, isSigned, isListed; final int comicIssueId; - NftModel({ + DigitalAssetModel({ required this.attributes, required this.address, required this.uri, @@ -31,12 +31,12 @@ class NftModel { required this.rarity, }); - factory NftModel.fromJson(dynamic json) { - return NftModel( + factory DigitalAssetModel.fromJson(dynamic json) { + return DigitalAssetModel( attributes: json['attributes'] != null - ? List.from( + ? List.from( json['attributes'].map( - (item) => NftAttribute.fromJson( + (item) => DigitalAssetAttribute.fromJson( item, ), ), @@ -62,17 +62,17 @@ class NftModel { } } -class NftAttribute { +class DigitalAssetAttribute { final String trait; final String value; - NftAttribute({ + DigitalAssetAttribute({ required this.trait, required this.value, }); - factory NftAttribute.fromJson(dynamic json) { - return NftAttribute( + factory DigitalAssetAttribute.fromJson(dynamic json) { + return DigitalAssetAttribute( trait: json['trait'], value: json['value'], ); diff --git a/lib/features/digital_asset/domain/providers/digital_asset_provider.dart b/lib/features/digital_asset/domain/providers/digital_asset_provider.dart new file mode 100644 index 00000000..dd0b7b03 --- /dev/null +++ b/lib/features/digital_asset/domain/providers/digital_asset_provider.dart @@ -0,0 +1,23 @@ +import 'package:d_reader_flutter/features/digital_asset/data/datasource/digital_asset_remote_data_source.dart'; +import 'package:d_reader_flutter/features/digital_asset/data/repositories/digital_asset_repository_impl.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/repositories/digital_asset_repository.dart'; +import 'package:d_reader_flutter/shared/data/remote/network_service.dart'; +import 'package:d_reader_flutter/shared/domain/providers/dio_network_service_provider.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; + +final digitalAssetDataSourceProvider = + Provider.family( + (ref, networkService) { + return DigitalAssetRemoteDataSource(networkService); + }, +); + +final digitalAssetRepositoryProvider = Provider( + (ref) { + final networkService = ref.watch(networkServiceProvider); + final dataSource = + ref.watch(digitalAssetDataSourceProvider(networkService)); + + return DigitalAssetRepositoryImpl(dataSource); + }, +); diff --git a/lib/features/digital_asset/domain/repositories/digital_asset_repository.dart b/lib/features/digital_asset/domain/repositories/digital_asset_repository.dart new file mode 100644 index 00000000..3aaf5b38 --- /dev/null +++ b/lib/features/digital_asset/domain/repositories/digital_asset_repository.dart @@ -0,0 +1,10 @@ +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; +import 'package:d_reader_flutter/shared/domain/models/either.dart'; +import 'package:d_reader_flutter/shared/exceptions/exceptions.dart'; + +abstract class DigitalAssetRepository { + Future> getDigitalAsset( + String address); + Future>> getDigitalAssets( + String query); +} diff --git a/lib/features/nft/presentation/providers/nft_controller.dart b/lib/features/digital_asset/presentation/providers/digital_asset_controller.dart similarity index 79% rename from lib/features/nft/presentation/providers/nft_controller.dart rename to lib/features/digital_asset/presentation/providers/digital_asset_controller.dart index b2066079..71478299 100644 --- a/lib/features/nft/presentation/providers/nft_controller.dart +++ b/lib/features/digital_asset/presentation/providers/digital_asset_controller.dart @@ -2,8 +2,8 @@ import 'package:d_reader_flutter/constants/constants.dart'; import 'package:d_reader_flutter/features/comic_issue/presentation/providers/comic_issue_providers.dart'; import 'package:d_reader_flutter/features/comic_issue/presentation/providers/owned_issues_notifier.dart'; import 'package:d_reader_flutter/features/library/presentation/providers/owned/owned_providers.dart'; -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; -import 'package:d_reader_flutter/features/nft/presentation/providers/nft_providers.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/providers/digital_asset_providers.dart'; import 'package:d_reader_flutter/shared/domain/models/enums.dart'; import 'package:d_reader_flutter/shared/domain/providers/solana/solana_transaction_notifier.dart'; import 'package:d_reader_flutter/shared/exceptions/exceptions.dart'; @@ -14,22 +14,22 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:solana/solana.dart' show lamportsPerSol; import 'package:video_player/video_player.dart'; -part 'nft_controller.g.dart'; +part 'digital_asset_controller.g.dart'; @riverpod -class NftController extends _$NftController { +class DigitalAssetController extends _$DigitalAssetController { @override void build() {} Future delist({ - required String nftAddress, + required String digitalAssetAddress, required void Function() callback, required void Function(Object exception) onException, }) async { try { final delistResult = await ref .read(solanaTransactionNotifierProvider.notifier) - .delist(nftAddress: nftAddress); + .delist(digitalAssetAddress: digitalAssetAddress); delistResult.fold((exception) { ref.read(privateLoadingProvider.notifier).update((state) => false); @@ -41,14 +41,14 @@ class NftController extends _$NftController { AppException( message: result, statusCode: 500, - identifier: 'nftController.delist', + identifier: 'DigitalAssetController.delist', ), ); } await Future.delayed( const Duration(milliseconds: 1200), () { - ref.invalidate(nftProvider); + ref.invalidate(digitalAssetProvider); ref.read(privateLoadingProvider.notifier).update((state) => false); callback(); }, @@ -60,16 +60,16 @@ class NftController extends _$NftController { } } - Future openNft({ - required NftModel nft, + Future openDigitalAsset({ + required DigitalAssetModel digitalAsset, required void Function(String result) onOpen, required void Function(Object exception) onException, }) async { try { final useMintResult = await ref.read(solanaTransactionNotifierProvider.notifier).useMint( - nftAddress: nft.address, - ownerAddress: nft.ownerAddress, + digitalAssetAddress: digitalAsset.address, + ownerAddress: digitalAsset.ownerAddress, ); useMintResult.fold( (exception) => onException(exception), (result) => onOpen(result)); @@ -78,7 +78,7 @@ class NftController extends _$NftController { } } - Future listNft({ + Future listDigitalAsset({ required String sellerAddress, required String mintAccount, required double price, @@ -100,7 +100,7 @@ class NftController extends _$NftController { await Future.delayed( const Duration(milliseconds: 1200), () { - ref.invalidate(nftProvider); + ref.invalidate(digitalAssetProvider); ref .read(privateLoadingProvider.notifier) .update((state) => false); @@ -118,14 +118,14 @@ class NftController extends _$NftController { mintLoadingListener({ required VideoPlayerController videoPlayerController, required AnimationController animationController, - required Future Function(NftModel nft) onSuccess, + required Future Function(DigitalAssetModel digitalAsset) onSuccess, required Function() onTimeout, required Function([String message]) onFail, }) async { final transactionMessage = ref.watch(globalNotifierProvider).signatureMessage; - final bool isMinted = ref.watch(lastProcessedNftProvider) != null; + final bool isMinted = ref.watch(lastProcessedAssetProvider) != null; if (videoPlayerController.value.isPlaying) { if (isMinted) { await _handleMintedCase( @@ -155,30 +155,30 @@ class NftController extends _$NftController { _handleMintedCase({ required VideoPlayerController videoPlayerController, required AnimationController animationController, - required Future Function(NftModel nft) onSuccess, + required Future Function(DigitalAssetModel digitalAsset) onSuccess, }) async { videoPlayerController.pause(); animationController.reverse( from: 1, ); - if (ref.watch(lastProcessedNftProvider) == null) { + if (ref.watch(lastProcessedAssetProvider) == null) { return; } - final nft = await ref - .read(nftProvider(ref.watch(lastProcessedNftProvider)!).future); + final digitalAsset = await ref.read( + digitalAssetProvider(ref.watch(lastProcessedAssetProvider)!).future); - if (nft == null) { + if (digitalAsset == null) { return; } - ref.invalidate(lastProcessedNftProvider); + ref.invalidate(lastProcessedAssetProvider); ref.invalidate(ownedComicsProvider); ref.invalidate(ownedIssuesAsyncProvider); - ref.invalidate(nftsProvider); + ref.invalidate(digitalAssetsProvider); ref .read(globalNotifierProvider.notifier) .update(isLoading: false, newMessage: ''); - await onSuccess(nft); + await onSuccess(digitalAsset); } mintOpenListener({ @@ -187,7 +187,7 @@ class NftController extends _$NftController { required Function(int comicIssueId) onSuccess, required Function() onFail, }) { - final bool isMinted = ref.watch(lastProcessedNftProvider) != null; + final bool isMinted = ref.watch(lastProcessedAssetProvider) != null; if (videoPlayerController.value.isPlaying) { if (isMinted) { @@ -212,12 +212,12 @@ class NftController extends _$NftController { animationController.reverse( from: 1, ); - final String? nftAddress = ref.read(lastProcessedNftProvider); - if (nftAddress == null) { + final String? digitalAssetAddress = ref.read(lastProcessedAssetProvider); + if (digitalAssetAddress == null) { return; } - ref.invalidate(lastProcessedNftProvider); - ref.invalidate(nftsProvider); + ref.invalidate(lastProcessedAssetProvider); + ref.invalidate(digitalAssetsProvider); ref.invalidate(ownedComicsProvider); ref.invalidate(ownedIssuesAsyncProvider); ref.invalidate(comicIssuePagesProvider); @@ -225,7 +225,7 @@ class NftController extends _$NftController { ref .read(globalNotifierProvider.notifier) .update(isLoading: false, newMessage: ''); - ref.read(nftProvider(nftAddress).future).then( + ref.read(digitalAssetProvider(digitalAssetAddress).future).then( (value) { if (value != null) { onSuccess(value.comicIssueId); @@ -234,15 +234,15 @@ class NftController extends _$NftController { ); } - handleNftUnwrap({ - required String nftAddress, + handleDigitalAssetUnwrap({ + required String digitalAssetAddress, required String ownerAddress, required Function() onSuccess, required Function(String message) onFail, }) async { final useMintResult = await ref.read(solanaTransactionNotifierProvider.notifier).useMint( - nftAddress: nftAddress, + digitalAssetAddress: digitalAssetAddress, ownerAddress: ownerAddress, ); useMintResult.fold((exception) => onFail(exception.message), (result) { diff --git a/lib/features/nft/presentation/providers/nft_controller.g.dart b/lib/features/digital_asset/presentation/providers/digital_asset_controller.g.dart similarity index 51% rename from lib/features/nft/presentation/providers/nft_controller.g.dart rename to lib/features/digital_asset/presentation/providers/digital_asset_controller.g.dart index d90feff2..8ccecf7b 100644 --- a/lib/features/nft/presentation/providers/nft_controller.g.dart +++ b/lib/features/digital_asset/presentation/providers/digital_asset_controller.g.dart @@ -1,26 +1,27 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'nft_controller.dart'; +part of 'digital_asset_controller.dart'; // ************************************************************************** // RiverpodGenerator // ************************************************************************** -String _$nftControllerHash() => r'8cdfd85ac5d2e6a45467ee50ce7b38a4bb2bd40f'; +String _$digitalAssetControllerHash() => + r'1f465fca7d8709e3edf319b46d8744b68c14c78c'; -/// See also [NftController]. -@ProviderFor(NftController) -final nftControllerProvider = - AutoDisposeNotifierProvider.internal( - NftController.new, - name: r'nftControllerProvider', +/// See also [DigitalAssetController]. +@ProviderFor(DigitalAssetController) +final digitalAssetControllerProvider = + AutoDisposeNotifierProvider.internal( + DigitalAssetController.new, + name: r'digitalAssetControllerProvider', debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') ? null - : _$nftControllerHash, + : _$digitalAssetControllerHash, dependencies: null, allTransitiveDependencies: null, ); -typedef _$NftController = AutoDisposeNotifier; +typedef _$DigitalAssetController = AutoDisposeNotifier; // ignore_for_file: type=lint // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member diff --git a/lib/features/nft/presentation/providers/nft_providers.dart b/lib/features/digital_asset/presentation/providers/digital_asset_providers.dart similarity index 78% rename from lib/features/nft/presentation/providers/nft_providers.dart rename to lib/features/digital_asset/presentation/providers/digital_asset_providers.dart index b48553e9..adf68968 100644 --- a/lib/features/nft/presentation/providers/nft_providers.dart +++ b/lib/features/digital_asset/presentation/providers/digital_asset_providers.dart @@ -2,8 +2,8 @@ import 'dart:async' show TimeoutException, Timer; import 'package:d_reader_flutter/config/config.dart'; import 'package:d_reader_flutter/constants/constants.dart'; -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; -import 'package:d_reader_flutter/features/nft/domain/providers/nft_provider.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/providers/digital_asset_provider.dart'; import 'package:d_reader_flutter/shared/domain/models/enums.dart'; import 'package:d_reader_flutter/shared/domain/providers/environment/environment_notifier.dart'; import 'package:d_reader_flutter/shared/presentations/providers/global/global_notifier.dart'; @@ -12,17 +12,18 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:solana/solana.dart'; -final nftProvider = - FutureProvider.autoDispose.family((ref, address) async { - final response = await ref.read(nftRepositoryProvider).getNft(address); +final digitalAssetProvider = FutureProvider.autoDispose + .family((ref, address) async { + final response = + await ref.read(digitalAssetRepositoryProvider).getDigitalAsset(address); return response.fold((exception) { return null; - }, (nft) => nft); + }, (digitalAsset) => digitalAsset); }); -final nftsProvider = - FutureProvider.family, String>((ref, query) async { +final digitalAssetsProvider = + FutureProvider.family, String>((ref, query) async { Timer? timer; ref.onDispose(() { @@ -38,11 +39,12 @@ final nftsProvider = ref.onResume(() { timer?.cancel(); }); - final response = await ref.read(nftRepositoryProvider).getNfts(query); - return response.fold((exception) => [], (nfts) => nfts); + final response = + await ref.read(digitalAssetRepositoryProvider).getDigitalAssets(query); + return response.fold((exception) => [], (digitalAssets) => digitalAssets); }); -final lastProcessedNftProvider = StateProvider( +final lastProcessedAssetProvider = StateProvider( (ref) { return null; }, diff --git a/lib/features/nft/presentation/screens/animations/mint_animation_screen.dart b/lib/features/digital_asset/presentation/screens/animations/mint_animation_screen.dart similarity index 85% rename from lib/features/nft/presentation/screens/animations/mint_animation_screen.dart rename to lib/features/digital_asset/presentation/screens/animations/mint_animation_screen.dart index 72a81d55..d371f9bb 100644 --- a/lib/features/nft/presentation/screens/animations/mint_animation_screen.dart +++ b/lib/features/digital_asset/presentation/screens/animations/mint_animation_screen.dart @@ -2,10 +2,10 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:d_reader_flutter/config/config.dart'; import 'package:d_reader_flutter/constants/routes.dart'; import 'package:d_reader_flutter/features/comic_issue/presentation/providers/comic_issue_providers.dart'; -import 'package:d_reader_flutter/features/nft/presentation/providers/nft_controller.dart'; -import 'package:d_reader_flutter/features/nft/presentation/utils/extensions.dart'; -import 'package:d_reader_flutter/features/nft/presentation/utils/utils.dart'; -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/providers/digital_asset_controller.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/utils/extensions.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/utils/utils.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; import 'package:d_reader_flutter/shared/domain/providers/environment/environment_notifier.dart'; import 'package:d_reader_flutter/shared/presentations/providers/global/global_notifier.dart'; import 'package:d_reader_flutter/shared/theme/app_colors.dart'; @@ -52,10 +52,12 @@ class _MintLoadingAnimationState extends ConsumerState _controller.setLooping(true); _controller.play(); _controller.addListener(() async { - await ref.read(nftControllerProvider.notifier).mintLoadingListener( + await ref + .read(digitalAssetControllerProvider.notifier) + .mintLoadingListener( videoPlayerController: _controller, animationController: _animationController, - onSuccess: (NftModel nft) async { + onSuccess: (DigitalAssetModel digitalAsset) async { await Future.delayed( const Duration(milliseconds: 1000), () { @@ -63,7 +65,7 @@ class _MintLoadingAnimationState extends ConsumerState context: context, path: RoutePath.doneMinting, homeSubRoute: true, - extra: nft, + extra: digitalAsset, ); }, ); @@ -133,10 +135,10 @@ class _MintLoadingAnimationState extends ConsumerState } class DoneMintingAnimation extends StatefulWidget { - final NftModel nft; + final DigitalAssetModel digitalAsset; const DoneMintingAnimation({ super.key, - required this.nft, + required this.digitalAsset, }); @override @@ -153,8 +155,8 @@ class _DoneMintingAnimationState extends State @override void initState() { super.initState(); - _controller = - VideoPlayerController.asset('assets/animation_files/nft-mint-bg.mp4'); + _controller = VideoPlayerController.asset( + 'assets/animation_files/digital_asset-mint-bg.mp4'); _fadeAnimationController = AnimationController( vsync: this, duration: const Duration(milliseconds: 1500), @@ -191,23 +193,25 @@ class _DoneMintingAnimationState extends State } _handleUnwrap({required WidgetRef ref}) async { - await ref.read(nftControllerProvider.notifier).handleNftUnwrap( - nftAddress: widget.nft.address, - ownerAddress: widget.nft.ownerAddress, - onSuccess: () { - nextScreenReplace( - context: context, - path: RoutePath.openNftAnimation, - homeSubRoute: true, - ); - }, - onFail: (String message) { - showSnackBar( - context: context, - text: message, - backgroundColor: ColorPalette.dReaderRed, - ); - }); + await ref + .read(digitalAssetControllerProvider.notifier) + .handleDigitalAssetUnwrap( + digitalAssetAddress: widget.digitalAsset.address, + ownerAddress: widget.digitalAsset.ownerAddress, + onSuccess: () { + nextScreenReplace( + context: context, + path: RoutePath.openDigitalAssetAnimation, + homeSubRoute: true, + ); + }, + onFail: (String message) { + showSnackBar( + context: context, + text: message, + backgroundColor: ColorPalette.dReaderRed, + ); + }); } @override @@ -238,7 +242,8 @@ class _DoneMintingAnimationState extends State onTap: () { nextScreenReplace( context: context, - path: '${RoutePath.nftDetails}/${widget.nft.address}', + path: + '${RoutePath.digitalAssetDetails}/${widget.digitalAsset.address}', homeSubRoute: true, ); }, @@ -248,14 +253,14 @@ class _DoneMintingAnimationState extends State AspectRatio( aspectRatio: 276 / 220, child: CachedNetworkImage( - imageUrl: widget.nft.image, + imageUrl: widget.digitalAsset.image, ), ), const SizedBox( height: 8, ), Text( - widget.nft.comicName, + widget.digitalAsset.comicName, style: const TextStyle( fontSize: 14, fontWeight: FontWeight.w500, @@ -266,7 +271,7 @@ class _DoneMintingAnimationState extends State height: 8, ), Text( - 'Congrats! You own ${shortenNftName(widget.nft.name)}', + 'Congrats! You own ${shortenDigitalAssetName(widget.digitalAsset.name)}', style: const TextStyle( fontSize: 18, fontWeight: FontWeight.w700, @@ -283,7 +288,7 @@ class _DoneMintingAnimationState extends State text: 'Mint', color: ColorPalette.dReaderGreen, ), - widget.nft.isSigned + widget.digitalAsset.isSigned ? const RoyaltyWidget( iconPath: 'assets/icons/signed_icon.svg', text: 'Signed', @@ -291,7 +296,7 @@ class _DoneMintingAnimationState extends State ) : const SizedBox(), RarityWidget( - rarity: widget.nft.rarity.rarityEnum, + rarity: widget.digitalAsset.rarity.rarityEnum, iconPath: 'assets/icons/rarity.svg', ), ], @@ -303,10 +308,10 @@ class _DoneMintingAnimationState extends State builder: (context, ref, child) { return GestureDetector( onTap: () async { - final nft = widget.nft; + final digitalAsset = widget.digitalAsset; final comicIssue = await ref.read( comicIssueDetailsProvider( - nft.comicIssueId.toString()) + digitalAsset.comicIssueId.toString()) .future, ); final dReaderWebUrl = ref @@ -316,7 +321,7 @@ class _DoneMintingAnimationState extends State ? 'https://dev-devnet.dreader.app/mint/${comicIssue.comicSlug}_${comicIssue.slug}?utm_source=mobile' : 'https://dreader.app/mint/${comicIssue.comicSlug}_${comicIssue.slug}?utm_source=mobile'; final uri = Uri.encodeFull( - 'https://twitter.com/intent/tweet?text=I just minted a ${nft.rarity} ${comicIssue.comic?.title}: ${comicIssue.title} comic on @dReaderApp! 📚\n\nMint yours here while the supply lasts.👇\n\n$dReaderWebUrl', + 'https://twitter.com/intent/tweet?text=I just minted a ${digitalAsset.rarity} ${comicIssue.comic?.title}: ${comicIssue.title} comic on @dReaderApp! 📚\n\nMint yours here while the supply lasts.👇\n\n$dReaderWebUrl', ); await openUrl(uri); }, @@ -393,7 +398,7 @@ class _DoneMintingAnimationState extends State ref.watch(globalNotifierProvider).isLoading; return UnwrapButton( isLoading: isLoading, - nft: widget.nft, + digitalAsset: widget.digitalAsset, onPressed: () async { await _handleUnwrap(ref: ref); }, diff --git a/lib/features/nft/presentation/screens/animations/open_nft_animation_screen.dart b/lib/features/digital_asset/presentation/screens/animations/open_asset_animation_screen.dart similarity index 88% rename from lib/features/nft/presentation/screens/animations/open_nft_animation_screen.dart rename to lib/features/digital_asset/presentation/screens/animations/open_asset_animation_screen.dart index ade9f73f..5fea4dd2 100644 --- a/lib/features/nft/presentation/screens/animations/open_nft_animation_screen.dart +++ b/lib/features/digital_asset/presentation/screens/animations/open_asset_animation_screen.dart @@ -1,5 +1,5 @@ import 'package:d_reader_flutter/constants/routes.dart'; -import 'package:d_reader_flutter/features/nft/presentation/providers/nft_controller.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/providers/digital_asset_controller.dart'; import 'package:d_reader_flutter/features/wallet/presentation/providers/wallet_providers.dart'; import 'package:d_reader_flutter/shared/theme/app_colors.dart'; import 'package:d_reader_flutter/shared/utils/screen_navigation.dart'; @@ -9,17 +9,18 @@ import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:video_player/video_player.dart'; -class OpenNftAnimation extends ConsumerStatefulWidget { - const OpenNftAnimation({ +class OpenDigitalAssetAnimation extends ConsumerStatefulWidget { + const OpenDigitalAssetAnimation({ super.key, }); @override ConsumerState createState() => - _OpenNftAnimationState(); + _OpenDigitalAssetAnimation(); } -class _OpenNftAnimationState extends ConsumerState +class _OpenDigitalAssetAnimation + extends ConsumerState with SingleTickerProviderStateMixin { late VideoPlayerController _controller; late Future _initializeVideoPlayerFuture; @@ -41,7 +42,7 @@ class _OpenNftAnimationState extends ConsumerState _controller.play(); _controller.addListener(() { - ref.read(nftControllerProvider.notifier).mintOpenListener( + ref.read(digitalAssetControllerProvider.notifier).mintOpenListener( videoPlayerController: _controller, animationController: _animationController, onSuccess: (int comicIssueId) { diff --git a/lib/features/nft/presentation/screens/nft_details.dart b/lib/features/digital_asset/presentation/screens/digital_asset_details.dart similarity index 86% rename from lib/features/nft/presentation/screens/nft_details.dart rename to lib/features/digital_asset/presentation/screens/digital_asset_details.dart index a8bc3048..189f8fcb 100644 --- a/lib/features/nft/presentation/screens/nft_details.dart +++ b/lib/features/digital_asset/presentation/screens/digital_asset_details.dart @@ -3,9 +3,9 @@ import 'package:d_reader_flutter/constants/routes.dart'; import 'package:d_reader_flutter/features/comic_issue/presentation/providers/comic_issue_providers.dart'; import 'package:d_reader_flutter/features/comic_issue/presentation/providers/owned_issues_notifier.dart'; import 'package:d_reader_flutter/features/library/presentation/providers/owned/owned_providers.dart'; -import 'package:d_reader_flutter/features/nft/presentation/providers/nft_controller.dart'; -import 'package:d_reader_flutter/features/nft/presentation/providers/nft_providers.dart'; -import 'package:d_reader_flutter/features/nft/presentation/utils/extensions.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/providers/digital_asset_controller.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/providers/digital_asset_providers.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/utils/extensions.dart'; import 'package:d_reader_flutter/shared/domain/providers/solana/solana_providers.dart'; import 'package:d_reader_flutter/shared/exceptions/exceptions.dart'; import 'package:d_reader_flutter/shared/presentations/providers/global/global_notifier.dart'; @@ -14,17 +14,18 @@ import 'package:d_reader_flutter/shared/theme/app_colors.dart'; import 'package:d_reader_flutter/shared/utils/dialog_triggers.dart'; import 'package:d_reader_flutter/shared/utils/formatter.dart'; import 'package:d_reader_flutter/shared/utils/screen_navigation.dart'; -import 'package:d_reader_flutter/features/nft/presentation/utils/utils.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/utils/utils.dart'; import 'package:d_reader_flutter/shared/utils/show_snackbar.dart'; import 'package:d_reader_flutter/shared/widgets/buttons/custom_text_button.dart'; -import 'package:d_reader_flutter/features/nft/presentation/widgets/nft_card.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/widgets/digital_asset_card.dart'; import 'package:d_reader_flutter/shared/widgets/buttons/unwrap_button.dart'; import 'package:d_reader_flutter/shared/widgets/cards/skeleton_card.dart'; +import 'package:d_reader_flutter/shared/widgets/unsorted/carrot_error_widget.dart'; import 'package:d_reader_flutter/shared/widgets/unsorted/rarity.dart'; import 'package:d_reader_flutter/shared/widgets/unsorted/royalty.dart'; import 'package:d_reader_flutter/shared/widgets/unsorted/skeleton_row.dart'; import 'package:d_reader_flutter/shared/widgets/texts/text_with_view_more.dart'; -import 'package:d_reader_flutter/features/nft/presentation/widgets/modal_bottom_sheet.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/widgets/modal_bottom_sheet.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; @@ -35,14 +36,14 @@ const sectionHeadingStyle = TextStyle( fontWeight: FontWeight.w700, ); -class NftDetails extends ConsumerWidget { +class DigitalAssetDetails extends ConsumerWidget { final String address; - const NftDetails({ + const DigitalAssetDetails({ super.key, required this.address, }); - _handleNftOpen({ + _handleDigitalAssetOpen({ required BuildContext context, required WidgetRef ref, required String openResponse, @@ -54,9 +55,9 @@ class NftDetails extends ConsumerWidget { text: openResponse, ); } - ref.invalidate(lastProcessedNftProvider); - ref.invalidate(nftsProvider); - ref.invalidate(nftProvider); + ref.invalidate(lastProcessedAssetProvider); + ref.invalidate(digitalAssetsProvider); + ref.invalidate(digitalAssetProvider); ref.invalidate(ownedComicsProvider); ref.invalidate(ownedIssuesAsyncProvider); ref.invalidate(comicIssuePagesProvider); @@ -70,11 +71,11 @@ class NftDetails extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final provider = ref.watch(nftProvider(address)); + final provider = ref.watch(digitalAssetProvider(address)); final textTheme = Theme.of(context).textTheme; return provider.when( - data: (nft) { - if (nft == null) { + data: (digitalAsset) { + if (digitalAsset == null) { return const Text('Something went wrong.'); } return Scaffold( @@ -83,14 +84,14 @@ class NftDetails extends ConsumerWidget { backgroundColor: ColorPalette.dReaderYellow100, color: ColorPalette.appBackgroundColor, onRefresh: () async { - ref.invalidate(nftProvider); + ref.invalidate(digitalAssetProvider); }, child: CustomScrollView( slivers: [ SliverAppBar( backgroundColor: Colors.transparent, title: Text( - shortenNftName(nft.name), + shortenDigitalAssetName(digitalAsset.name), style: Theme.of(context).textTheme.headlineMedium, ), ), @@ -98,10 +99,10 @@ class NftDetails extends ConsumerWidget { padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), sliver: SliverToBoxAdapter( - child: NftCard( - comicName: nft.comicName, - imageUrl: nft.image, - issueName: nft.comicIssueName, + child: DigitalAssetCard( + comicName: digitalAsset.comicName, + imageUrl: digitalAsset.image, + issueName: digitalAsset.comicIssueName, ), ), ), @@ -121,11 +122,13 @@ class NftDetails extends ConsumerWidget { isLoading: ref.watch(privateLoadingProvider), loadingColor: ColorPalette.greyscale200, onPressed: () async { - if (nft.isListed) { + if (digitalAsset.isListed) { return await ref - .read(nftControllerProvider.notifier) + .read(digitalAssetControllerProvider + .notifier) .delist( - nftAddress: nft.address, + digitalAssetAddress: + digitalAsset.address, callback: () { showSnackBar( context: context, @@ -153,12 +156,13 @@ class NftDetails extends ConsumerWidget { MediaQuery.viewInsetsOf(context) .bottom, ), - child: NftModalBottomSheet(nft: nft), + child: DigitalAssetModalBottomSheet( + digitalAsset: digitalAsset), ); }, ); }, - child: nft.isListed + child: digitalAsset.isListed ? Text( 'Delist', style: textTheme.titleMedium?.copyWith( @@ -177,7 +181,7 @@ class NftDetails extends ConsumerWidget { width: 16, ), Expanded( - child: nft.isUsed + child: digitalAsset.isUsed ? Button( borderColor: ColorPalette.dReaderYellow100, @@ -190,7 +194,7 @@ class NftDetails extends ConsumerWidget { return nextScreenPush( context: context, path: - '${RoutePath.eReader}/${nft.comicIssueId}', + '${RoutePath.eReader}/${digitalAsset.comicIssueId}', ); }, child: Text( @@ -201,15 +205,15 @@ class NftDetails extends ConsumerWidget { ), ) : UnwrapButton( - nft: nft, + digitalAsset: digitalAsset, onPressed: () async { await ref - .read( - nftControllerProvider.notifier) - .openNft( - nft: nft, + .read(digitalAssetControllerProvider + .notifier) + .openDigitalAsset( + digitalAsset: digitalAsset, onOpen: (String result) { - _handleNftOpen( + _handleDigitalAssetOpen( context: context, ref: ref, openResponse: result, @@ -266,7 +270,7 @@ class NftDetails extends ConsumerWidget { height: 8, ), TextWithViewMore( - text: nft.description, + text: digitalAsset.description, ), const SizedBox( height: 16, @@ -300,7 +304,7 @@ class NftDetails extends ConsumerWidget { child: Row( children: [ Text( - '${Formatter.formatPrice(nft.royalties)}%', + '${Formatter.formatPrice(digitalAsset.royalties)}%', style: textTheme.bodySmall?.copyWith( color: ColorPalette.dReaderBlue, @@ -320,15 +324,15 @@ class NftDetails extends ConsumerWidget { ), RoyaltyWidget( isLarge: true, - iconPath: nft.isUsed - ? 'assets/icons/used_nft.svg' + iconPath: digitalAsset.isUsed + ? 'assets/icons/used_asset.svg' : 'assets/icons/mint_icon.svg', - text: nft.isUsed ? 'Used' : 'Mint', - color: nft.isUsed + text: digitalAsset.isUsed ? 'Used' : 'Mint', + color: digitalAsset.isUsed ? ColorPalette.lightblue : ColorPalette.dReaderGreen, ), - nft.isSigned + digitalAsset.isSigned ? const RoyaltyWidget( iconPath: 'assets/icons/signed_icon.svg', @@ -338,7 +342,7 @@ class NftDetails extends ConsumerWidget { ) : const SizedBox(), RarityWidget( - rarity: nft.rarity.rarityEnum, + rarity: digitalAsset.rarity.rarityEnum, iconPath: 'assets/icons/rarity.svg', isLarge: true, ), @@ -359,7 +363,8 @@ class NftDetails extends ConsumerWidget { Row( children: [ Text( - Formatter.formatAddress(nft.ownerAddress, 12), + Formatter.formatAddress( + digitalAsset.ownerAddress, 12), style: textTheme.bodySmall, ), const SizedBox( @@ -374,7 +379,7 @@ class NftDetails extends ConsumerWidget { onTap: () { Clipboard.setData( ClipboardData( - text: nft.ownerAddress, + text: digitalAsset.ownerAddress, ), ).then( (value) => ScaffoldMessenger.of(context) @@ -403,7 +408,7 @@ class NftDetails extends ConsumerWidget { Row( children: [ Text( - Formatter.formatAddress(nft.address, 12), + Formatter.formatAddress(digitalAsset.address, 12), style: textTheme.bodySmall, ), const SizedBox( @@ -418,7 +423,7 @@ class NftDetails extends ConsumerWidget { onTap: () { Clipboard.setData( ClipboardData( - text: nft.address, + text: digitalAsset.address, ), ).then( (value) => ScaffoldMessenger.of(context) @@ -447,7 +452,7 @@ class NftDetails extends ConsumerWidget { nextScreenPush( context: context, path: - '${RoutePath.comicIssueDetails}/${nft.comicIssueId}', + '${RoutePath.comicIssueDetails}/${digitalAsset.comicIssueId}', ); }, child: Text( @@ -465,7 +470,10 @@ class NftDetails extends ConsumerWidget { ); }, error: (Object error, StackTrace stackTrace) { - return const Text('Something went wrong in nft details.'); + return const CarrotErrorWidget( + mainErrorText: 'We ran into some issues', + adviceText: 'We are working on a fix. Thanks for your patience!', + ); }, loading: () { return Scaffold( diff --git a/lib/features/digital_asset/presentation/utils/extensions.dart b/lib/features/digital_asset/presentation/utils/extensions.dart new file mode 100644 index 00000000..7dbddd0c --- /dev/null +++ b/lib/features/digital_asset/presentation/utils/extensions.dart @@ -0,0 +1,40 @@ +import 'package:d_reader_flutter/shared/domain/models/enums.dart'; +import 'package:d_reader_flutter/shared/theme/app_colors.dart'; +import 'package:flutter/material.dart' show Colors, Color; + +extension RarityExtension on DigitalAssetRarity { + static const rarityNames = { + DigitalAssetRarity.none: 'None', + DigitalAssetRarity.common: 'Common', + DigitalAssetRarity.uncommon: 'Uncommon', + DigitalAssetRarity.rare: 'Rare', + DigitalAssetRarity.epic: 'Epic', + DigitalAssetRarity.legendary: 'Legendary', + }; + + String get name => rarityNames[this] ?? 'None'; + + static const rarityColors = { + DigitalAssetRarity.none: Colors.transparent, + DigitalAssetRarity.common: Colors.white, + DigitalAssetRarity.uncommon: ColorPalette.dReaderYellow200, + DigitalAssetRarity.rare: ColorPalette.dReaderLightGreen, + DigitalAssetRarity.epic: ColorPalette.dReaderPink, + DigitalAssetRarity.legendary: Color(0xFF8377F2), + }; + + Color get color => rarityColors[this] ?? Colors.white; +} + +extension RarityFromString on String { + static const rarities = { + 'None': DigitalAssetRarity.none, + 'Common': DigitalAssetRarity.common, + 'Uncommon': DigitalAssetRarity.uncommon, + 'Rare': DigitalAssetRarity.rare, + 'Epic': DigitalAssetRarity.epic, + 'Legendary': DigitalAssetRarity.legendary, + }; + DigitalAssetRarity get rarityEnum => + rarities[this] ?? DigitalAssetRarity.none; +} diff --git a/lib/features/digital_asset/presentation/utils/utils.dart b/lib/features/digital_asset/presentation/utils/utils.dart new file mode 100644 index 00000000..a08ad4ac --- /dev/null +++ b/lib/features/digital_asset/presentation/utils/utils.dart @@ -0,0 +1,2 @@ +String shortenDigitalAssetName(String digitalAssetName) => + '#${digitalAssetName.split('#').last}'; diff --git a/lib/features/nft/presentation/widgets/nft_card.dart b/lib/features/digital_asset/presentation/widgets/digital_asset_card.dart similarity index 93% rename from lib/features/nft/presentation/widgets/nft_card.dart rename to lib/features/digital_asset/presentation/widgets/digital_asset_card.dart index 9db8ae10..e1524857 100644 --- a/lib/features/nft/presentation/widgets/nft_card.dart +++ b/lib/features/digital_asset/presentation/widgets/digital_asset_card.dart @@ -4,11 +4,11 @@ import 'package:d_reader_flutter/shared/utils/screen_navigation.dart'; import 'package:d_reader_flutter/shared/widgets/image_widgets/cached_image_bg_placeholder.dart'; import 'package:flutter/material.dart'; -class NftCard extends StatelessWidget { +class DigitalAssetCard extends StatelessWidget { final String imageUrl; final String comicName; final String issueName; - const NftCard({ + const DigitalAssetCard({ super.key, required this.imageUrl, required this.comicName, diff --git a/lib/features/nft/presentation/widgets/modal_bottom_sheet.dart b/lib/features/digital_asset/presentation/widgets/modal_bottom_sheet.dart similarity index 81% rename from lib/features/nft/presentation/widgets/modal_bottom_sheet.dart rename to lib/features/digital_asset/presentation/widgets/modal_bottom_sheet.dart index 556b4850..2a73ca6e 100644 --- a/lib/features/nft/presentation/widgets/modal_bottom_sheet.dart +++ b/lib/features/digital_asset/presentation/widgets/modal_bottom_sheet.dart @@ -1,7 +1,7 @@ import 'package:d_reader_flutter/config/config.dart'; import 'package:d_reader_flutter/constants/constants.dart'; -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; -import 'package:d_reader_flutter/features/nft/presentation/providers/nft_controller.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/providers/digital_asset_controller.dart'; import 'package:d_reader_flutter/shared/presentations/providers/global/global_notifier.dart'; import 'package:d_reader_flutter/shared/theme/app_colors.dart'; import 'package:d_reader_flutter/shared/utils/show_snackbar.dart'; @@ -10,19 +10,20 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class NftModalBottomSheet extends ConsumerStatefulWidget { - final NftModel nft; - const NftModalBottomSheet({ +class DigitalAssetModalBottomSheet extends ConsumerStatefulWidget { + final DigitalAssetModel digitalAsset; + const DigitalAssetModalBottomSheet({ super.key, - required this.nft, + required this.digitalAsset, }); @override ConsumerState createState() => - _NftModalBottomSheetState(); + _DigitalAssetModalBottomSheetState(); } -class _NftModalBottomSheetState extends ConsumerState { +class _DigitalAssetModalBottomSheetState + extends ConsumerState { String priceInputValue = ''; @override void dispose() { @@ -49,11 +50,11 @@ class _NftModalBottomSheetState extends ConsumerState { padding: const EdgeInsets.all(8.0), child: ListTile( title: Text( - widget.nft.name, + widget.digitalAsset.name, style: Theme.of(context).textTheme.titleMedium, ), subtitle: Text( - widget.nft.comicName, + widget.digitalAsset.comicName, style: Theme.of(context).textTheme.bodySmall, ), leading: Container( @@ -64,7 +65,7 @@ class _NftModalBottomSheetState extends ConsumerState { image: DecorationImage( fit: BoxFit.cover, image: NetworkImage( - widget.nft.image, + widget.digitalAsset.image, ), ), ), @@ -101,7 +102,7 @@ class _NftModalBottomSheetState extends ConsumerState { ], ), SubmitButton( - nft: widget.nft, + digitalAsset: widget.digitalAsset, price: priceInputValue.isNotEmpty ? double.tryParse( priceInputValue, @@ -115,11 +116,11 @@ class _NftModalBottomSheetState extends ConsumerState { } class SubmitButton extends ConsumerWidget { - final NftModel nft; + final DigitalAssetModel digitalAsset; final double? price; const SubmitButton({ super.key, - required this.nft, + required this.digitalAsset, this.price, }); @@ -130,9 +131,11 @@ class SubmitButton extends ConsumerWidget { onPressed: price != null ? () async { try { - await ref.read(nftControllerProvider.notifier).listNft( - sellerAddress: nft.ownerAddress, - mintAccount: nft.address, + await ref + .read(digitalAssetControllerProvider.notifier) + .listDigitalAsset( + sellerAddress: digitalAsset.ownerAddress, + mintAccount: digitalAsset.address, price: price!, callback: (result) { context.pop(); diff --git a/lib/features/e_reader/presentation/screens/e_reader.dart b/lib/features/e_reader/presentation/screens/e_reader.dart index 443e088b..28cf2e24 100644 --- a/lib/features/e_reader/presentation/screens/e_reader.dart +++ b/lib/features/e_reader/presentation/screens/e_reader.dart @@ -1,8 +1,8 @@ import 'package:d_reader_flutter/features/comic_issue/domain/models/comic_issue.dart'; import 'package:d_reader_flutter/features/comic_issue/presentation/providers/comic_issue_providers.dart'; import 'package:d_reader_flutter/features/e_reader/presentation/providers/e_reader_providers.dart'; -import 'package:d_reader_flutter/features/nft/presentation/providers/nft_providers.dart'; -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/providers/digital_asset_providers.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; import 'package:d_reader_flutter/shared/domain/models/comic_page.dart'; import 'package:d_reader_flutter/shared/domain/providers/environment/environment_notifier.dart'; import 'package:d_reader_flutter/shared/presentations/providers/global/global_providers.dart'; @@ -13,7 +13,7 @@ import 'package:d_reader_flutter/shared/widgets/cards/skeleton_card.dart'; import 'package:d_reader_flutter/shared/widgets/image_widgets/common_cached_image.dart'; import 'package:d_reader_flutter/features/e_reader/presentation/widgets/bottom_navigation.dart'; import 'package:d_reader_flutter/features/e_reader/presentation/widgets/page_number_widget.dart'; -import 'package:d_reader_flutter/features/library/presentation/widgets/modals/owned_nfts_bottom_sheet.dart'; +import 'package:d_reader_flutter/features/library/presentation/widgets/modals/owned_digital_assets_bottom_sheet.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -321,19 +321,20 @@ class PreviewImage extends StatelessWidget { required this.issueNumber, }); - openModalBottomSheet(BuildContext context, List ownedNfts) { + openModalBottomSheet( + BuildContext context, List ownedDigitalAssets) { showModalBottomSheet( context: context, isScrollControlled: true, builder: (context) { return DraggableScrollableSheet( - initialChildSize: ownedNfts.length > 1 ? 0.65 : 0.5, - minChildSize: ownedNfts.length > 1 ? 0.65 : 0.5, + initialChildSize: ownedDigitalAssets.length > 1 ? 0.65 : 0.5, + minChildSize: ownedDigitalAssets.length > 1 ? 0.65 : 0.5, maxChildSize: 0.8, expand: false, builder: (context, scrollController) { - return OwnedNftsBottomSheet( - ownedNfts: ownedNfts, + return OwnedDigitalAssetsBottomSheet( + ownedDigitalAssets: ownedDigitalAssets, episodeNumber: issueNumber, ); }, @@ -379,19 +380,20 @@ class PreviewImage extends StatelessWidget { ), Consumer( builder: (context, ref, child) { - final ownedNfts = ref.watch( - nftsProvider( + final ownedDigitalAssets = ref.watch( + digitalAssetsProvider( 'comicIssueId=$issueId&userId=${ref.read(environmentProvider).user?.id}', ), ); - return ownedNfts.when( + return ownedDigitalAssets.when( data: (data) { if (data.isEmpty) { return const SizedBox(); } - final isAtLeastOneUsed = data.any((nft) => nft.isUsed); + final isAtLeastOneUsed = + data.any((digitalAsset) => digitalAsset.isUsed); return isAtLeastOneUsed && canRead ? const SizedBox() : CustomTextButton( @@ -416,7 +418,8 @@ class PreviewImage extends StatelessWidget { error: (error, stackTrace) { Sentry.captureException( error, - stackTrace: 'eReader owned Nfts: $stackTrace', + stackTrace: + 'eReader owned DigitalAssets: $stackTrace', ); return const SizedBox(); }, diff --git a/lib/features/library/presentation/providers/owned/owned_controller.dart b/lib/features/library/presentation/providers/owned/owned_controller.dart index 52b5104b..8f01e40c 100644 --- a/lib/features/library/presentation/providers/owned/owned_controller.dart +++ b/lib/features/library/presentation/providers/owned/owned_controller.dart @@ -1,9 +1,9 @@ import 'package:d_reader_flutter/constants/constants.dart'; import 'package:d_reader_flutter/features/comic_issue/presentation/providers/comic_issue_providers.dart'; import 'package:d_reader_flutter/features/library/presentation/providers/owned/owned_providers.dart'; -import 'package:d_reader_flutter/features/nft/presentation/providers/nft_providers.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/providers/digital_asset_providers.dart'; import 'package:d_reader_flutter/features/comic_issue/domain/models/comic_issue.dart'; -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; import 'package:d_reader_flutter/shared/domain/providers/environment/environment_notifier.dart'; import 'package:d_reader_flutter/shared/domain/providers/solana/solana_transaction_notifier.dart'; import 'package:d_reader_flutter/shared/presentations/providers/global/global_notifier.dart'; @@ -15,27 +15,32 @@ class OwnedController extends _$OwnedController { @override void build() {} - Future> _fetchOwnedNfts(int comicIssueId) async { + Future> _fetchOwnedDigitalAssets( + int comicIssueId) async { ref.read(globalNotifierProvider.notifier).updateLoading(true); - final ownedNfts = await ref.read(nftsProvider( + final ownedDigitalAssets = await ref.read(digitalAssetsProvider( 'comicIssueId=$comicIssueId&userId=${ref.read(environmentProvider).user?.id}', ).future); ref.read(globalNotifierProvider.notifier).updateLoading(false); - return ownedNfts; + return ownedDigitalAssets; } Future handleIssueInfoTap({ required int comicIssueId, - required void Function(String nftAddress) goToNftDetails, + required void Function(String digitalAssetAddress) goToDigitalAssetDetails, }) async { - final List ownedNfts = await _fetchOwnedNfts(comicIssueId); + final List ownedDigitalAssets = + await _fetchOwnedDigitalAssets(comicIssueId); - final int usedNftIndex = ownedNfts.indexWhere((element) => element.isUsed); + final int usedDigitalAssetIndex = + ownedDigitalAssets.indexWhere((element) => element.isUsed); - if (ownedNfts.length == 1) { - final properIndex = usedNftIndex > -1 ? usedNftIndex : 0; - goToNftDetails(ownedNfts.elementAt(properIndex).address); + if (ownedDigitalAssets.length == 1) { + final properIndex = + usedDigitalAssetIndex > -1 ? usedDigitalAssetIndex : 0; + goToDigitalAssetDetails( + ownedDigitalAssets.elementAt(properIndex).address); } final ComicIssueModel? comicIssue = await ref.read( comicIssueDetailsProvider('$comicIssueId').future, @@ -43,19 +48,20 @@ class OwnedController extends _$OwnedController { ref.read(selectedIssueInfoProvider.notifier).update((state) => comicIssue); } - Future handleOpenNft({ - required NftModel ownedNft, + Future handleOpenDigitalAsset({ + required DigitalAssetModel ownedDigitalAsset, required void Function() onSuccess, required void Function(String message) onFail, }) async { try { - final openNftResult = + final openDigitalAssetResult = await ref.read(solanaTransactionNotifierProvider.notifier).useMint( - nftAddress: ownedNft.address, - ownerAddress: ownedNft.ownerAddress, + digitalAssetAddress: ownedDigitalAsset.address, + ownerAddress: ownedDigitalAsset.ownerAddress, ); - openNftResult.fold((exception) => onFail(exception.message), (result) { + openDigitalAssetResult.fold((exception) => onFail(exception.message), + (result) { if (result == successResult) { return onSuccess(); } diff --git a/lib/features/library/presentation/providers/owned/owned_controller.g.dart b/lib/features/library/presentation/providers/owned/owned_controller.g.dart index 5f75e589..0a7682c6 100644 --- a/lib/features/library/presentation/providers/owned/owned_controller.g.dart +++ b/lib/features/library/presentation/providers/owned/owned_controller.g.dart @@ -6,7 +6,7 @@ part of 'owned_controller.dart'; // RiverpodGenerator // ************************************************************************** -String _$ownedControllerHash() => r'244d108bab9c6ccb6ecd5f3fce2f01618c2fcf11'; +String _$ownedControllerHash() => r'934235499f061fb59171cc35418835138235f42f'; /// See also [OwnedController]. @ProviderFor(OwnedController) diff --git a/lib/features/library/presentation/widgets/cards/owned_nft_card.dart b/lib/features/library/presentation/widgets/cards/owned_digital_asset_card.dart similarity index 81% rename from lib/features/library/presentation/widgets/cards/owned_nft_card.dart rename to lib/features/library/presentation/widgets/cards/owned_digital_asset_card.dart index f6689070..0eee42b1 100644 --- a/lib/features/library/presentation/widgets/cards/owned_nft_card.dart +++ b/lib/features/library/presentation/widgets/cards/owned_digital_asset_card.dart @@ -1,11 +1,11 @@ import 'package:d_reader_flutter/constants/constants.dart'; import 'package:d_reader_flutter/constants/routes.dart'; import 'package:d_reader_flutter/features/library/presentation/providers/owned/owned_providers.dart'; -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; -import 'package:d_reader_flutter/features/nft/presentation/utils/extensions.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/utils/extensions.dart'; import 'package:d_reader_flutter/shared/theme/app_colors.dart'; import 'package:d_reader_flutter/shared/utils/screen_navigation.dart'; -import 'package:d_reader_flutter/features/nft/presentation/utils/utils.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/utils/utils.dart'; import 'package:d_reader_flutter/shared/widgets/image_widgets/cached_image_bg_placeholder.dart'; import 'package:d_reader_flutter/shared/widgets/unsorted/rarity.dart'; import 'package:d_reader_flutter/shared/widgets/unsorted/royalty.dart'; @@ -13,12 +13,12 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class OwnedNftCard extends ConsumerWidget { - final NftModel nft; +class OwnedDigitalAssetCard extends ConsumerWidget { + final DigitalAssetModel digitalAsset; - const OwnedNftCard({ + const OwnedDigitalAssetCard({ super.key, - required this.nft, + required this.digitalAsset, }); @override @@ -27,7 +27,7 @@ class OwnedNftCard extends ConsumerWidget { onTap: () { nextScreenPush( context: context, - path: '${RoutePath.nftDetails}/${nft.address}', + path: '${RoutePath.digitalAssetDetails}/${digitalAsset.address}', ); }, behavior: HitTestBehavior.opaque, @@ -42,7 +42,7 @@ class OwnedNftCard extends ConsumerWidget { AspectRatio( aspectRatio: comicIssueAspectRatio, child: CachedImageBgPlaceholder( - imageUrl: nft.image, + imageUrl: digitalAsset.image, ), ), const SizedBox( @@ -57,7 +57,7 @@ class OwnedNftCard extends ConsumerWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - shortenNftName(nft.name), + shortenDigitalAssetName(digitalAsset.name), maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle( @@ -81,9 +81,9 @@ class OwnedNftCard extends ConsumerWidget { Wrap( runSpacing: 8, children: [ - nft.isUsed + digitalAsset.isUsed ? const RoyaltyWidget( - iconPath: 'assets/icons/used_nft.svg', + iconPath: 'assets/icons/used_asset.svg', text: 'Used', color: ColorPalette.lightblue, ) @@ -92,7 +92,7 @@ class OwnedNftCard extends ConsumerWidget { text: 'Mint', color: ColorPalette.dReaderGreen, ), - nft.isSigned + digitalAsset.isSigned ? const RoyaltyWidget( iconPath: 'assets/icons/signed_icon.svg', text: 'Signed', @@ -100,7 +100,7 @@ class OwnedNftCard extends ConsumerWidget { ) : const SizedBox(), RarityWidget( - rarity: nft.rarity.rarityEnum, + rarity: digitalAsset.rarity.rarityEnum, iconPath: 'assets/icons/rarity.svg', ), ], diff --git a/lib/features/library/presentation/widgets/cards/owned_issue_card.dart b/lib/features/library/presentation/widgets/cards/owned_issue_card.dart index 1223b5c0..f146055d 100644 --- a/lib/features/library/presentation/widgets/cards/owned_issue_card.dart +++ b/lib/features/library/presentation/widgets/cards/owned_issue_card.dart @@ -2,13 +2,10 @@ import 'package:d_reader_flutter/constants/constants.dart'; import 'package:d_reader_flutter/constants/routes.dart'; import 'package:d_reader_flutter/features/comic_issue/domain/models/owned_issue.dart'; import 'package:d_reader_flutter/features/library/presentation/providers/owned/owned_controller.dart'; -import 'package:d_reader_flutter/features/nft/presentation/utils/extensions.dart'; import 'package:d_reader_flutter/shared/presentations/providers/global/global_notifier.dart'; import 'package:d_reader_flutter/shared/theme/app_colors.dart'; import 'package:d_reader_flutter/shared/utils/screen_navigation.dart'; import 'package:d_reader_flutter/shared/widgets/image_widgets/cached_image_bg_placeholder.dart'; -import 'package:d_reader_flutter/shared/widgets/unsorted/rarity.dart'; -import 'package:d_reader_flutter/shared/widgets/unsorted/royalty.dart'; import 'package:d_reader_flutter/features/library/presentation/widgets/buttons/info_button.dart'; import 'package:d_reader_flutter/features/library/presentation/widgets/tabs/owned/owned_copies.dart'; import 'package:flutter/material.dart'; @@ -77,29 +74,7 @@ class OwnedIssueCard extends ConsumerWidget { ), ], ), - issue.ownedNft != null - ? Row( - children: [ - const RoyaltyWidget( - iconPath: 'assets/icons/mint_icon.svg', - text: 'Mint', - color: ColorPalette.dReaderGreen, - ), - issue.ownedNft!.isSigned - ? const RoyaltyWidget( - iconPath: 'assets/icons/signed_icon.svg', - text: 'Signed', - color: ColorPalette.dReaderOrange, - ) - : const SizedBox(), - RarityWidget( - rarity: issue.ownedNft!.rarity.rarityEnum, - iconPath: 'assets/icons/rarity.svg', - ), - OwnedCopies(copiesCount: issue.ownedCopiesCount) - ], - ) - : OwnedCopies(copiesCount: issue.ownedCopiesCount), + OwnedCopies(copiesCount: issue.ownedCopiesCount), const SizedBox(), InfoButton( isLoading: ref.watch(globalNotifierProvider).isLoading, @@ -108,10 +83,11 @@ class OwnedIssueCard extends ConsumerWidget { .read(ownedControllerProvider.notifier) .handleIssueInfoTap( comicIssueId: issue.id, - goToNftDetails: (nftAddress) { + goToDigitalAssetDetails: (digitalAssetAddress) { return nextScreenPush( context: context, - path: '${RoutePath.nftDetails}/$nftAddress', + path: + '${RoutePath.digitalAssetDetails}/$digitalAssetAddress', ); }, ); diff --git a/lib/features/library/presentation/widgets/modals/owned_nfts_bottom_sheet.dart b/lib/features/library/presentation/widgets/modals/owned_digital_assets_bottom_sheet.dart similarity index 86% rename from lib/features/library/presentation/widgets/modals/owned_nfts_bottom_sheet.dart rename to lib/features/library/presentation/widgets/modals/owned_digital_assets_bottom_sheet.dart index 9c5c309e..86f7116c 100644 --- a/lib/features/library/presentation/widgets/modals/owned_nfts_bottom_sheet.dart +++ b/lib/features/library/presentation/widgets/modals/owned_digital_assets_bottom_sheet.dart @@ -1,11 +1,11 @@ import 'package:d_reader_flutter/constants/routes.dart'; import 'package:d_reader_flutter/features/library/presentation/providers/owned/owned_controller.dart'; -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; -import 'package:d_reader_flutter/features/nft/presentation/utils/extensions.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/utils/extensions.dart'; import 'package:d_reader_flutter/shared/theme/app_colors.dart'; import 'package:d_reader_flutter/shared/utils/dialog_triggers.dart'; import 'package:d_reader_flutter/shared/utils/screen_navigation.dart'; -import 'package:d_reader_flutter/features/nft/presentation/utils/utils.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/utils/utils.dart'; import 'package:d_reader_flutter/shared/utils/show_snackbar.dart'; import 'package:d_reader_flutter/shared/widgets/buttons/custom_text_button.dart'; import 'package:d_reader_flutter/shared/widgets/unsorted/rarity.dart'; @@ -14,12 +14,12 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class OwnedNftsBottomSheet extends StatelessWidget { - final List ownedNfts; +class OwnedDigitalAssetsBottomSheet extends StatelessWidget { + final List ownedDigitalAssets; final int episodeNumber; - const OwnedNftsBottomSheet({ + const OwnedDigitalAssetsBottomSheet({ super.key, - required this.ownedNfts, + required this.ownedDigitalAssets, required this.episodeNumber, }); @@ -65,7 +65,7 @@ class OwnedNftsBottomSheet extends StatelessWidget { child: ListView.separated( physics: const AlwaysScrollableScrollPhysics(), itemBuilder: (context, index) { - final ownedNft = ownedNfts[index]; + final ownedDigitalAsset = ownedDigitalAssets[index]; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -81,8 +81,8 @@ class OwnedNftsBottomSheet extends StatelessWidget { height: 4, ), Text( - shortenNftName( - ownedNft.name, + shortenDigitalAssetName( + ownedDigitalAsset.name, ), style: const TextStyle( fontSize: 16, @@ -101,15 +101,16 @@ class OwnedNftsBottomSheet extends StatelessWidget { runSpacing: 8, children: [ RoyaltyWidget( - iconPath: ownedNft.isUsed - ? 'assets/icons/used_nft.svg' + iconPath: ownedDigitalAsset.isUsed + ? 'assets/icons/used_asset.svg' : 'assets/icons/mint_icon.svg', - text: ownedNft.isUsed ? 'Used' : 'Mint', - color: ownedNft.isUsed + text: + ownedDigitalAsset.isUsed ? 'Used' : 'Mint', + color: ownedDigitalAsset.isUsed ? ColorPalette.lightblue : ColorPalette.dReaderGreen, ), - ownedNft.isSigned + ownedDigitalAsset.isSigned ? const RoyaltyWidget( iconPath: 'assets/icons/signed_icon.svg', text: 'Signed', @@ -117,7 +118,7 @@ class OwnedNftsBottomSheet extends StatelessWidget { ) : const SizedBox(), RarityWidget( - rarity: ownedNft.rarity.rarityEnum, + rarity: ownedDigitalAsset.rarity.rarityEnum, iconPath: 'assets/icons/rarity.svg', ), ], @@ -131,13 +132,14 @@ class OwnedNftsBottomSheet extends StatelessWidget { try { await ref .read(ownedControllerProvider.notifier) - .handleOpenNft( - ownedNft: ownedNft, + .handleOpenDigitalAsset( + ownedDigitalAsset: ownedDigitalAsset, onSuccess: () { context.pop(); return nextScreenPush( context: context, - path: RoutePath.openNftAnimation, + path: RoutePath + .openDigitalAssetAnimation, ); }, onFail: (message) { @@ -200,7 +202,7 @@ class OwnedNftsBottomSheet extends StatelessWidget { color: ColorPalette.greyscale300, ); }, - itemCount: ownedNfts.length, + itemCount: ownedDigitalAssets.length, ), ), const Divider( @@ -235,7 +237,7 @@ class OwnedNftsBottomSheet extends StatelessWidget { nextScreenPush( context: context, path: - '${RoutePath.nftDetails}/${ownedNfts.first.address}', + '${RoutePath.digitalAssetDetails}/${ownedDigitalAssets.first.address}', ); }, padding: const EdgeInsets.only( diff --git a/lib/features/library/presentation/widgets/tabs/owned/owned.dart b/lib/features/library/presentation/widgets/tabs/owned/owned.dart index 046dfb11..fed1e920 100644 --- a/lib/features/library/presentation/widgets/tabs/owned/owned.dart +++ b/lib/features/library/presentation/widgets/tabs/owned/owned.dart @@ -6,7 +6,7 @@ import 'package:d_reader_flutter/shared/domain/providers/environment/environment import 'package:d_reader_flutter/shared/theme/app_colors.dart'; import 'package:d_reader_flutter/features/library/presentation/widgets/common/library_comic_items.dart'; import 'package:d_reader_flutter/features/library/presentation/widgets/tabs/owned/owned_issues_items.dart'; -import 'package:d_reader_flutter/features/library/presentation/widgets/tabs/owned/owned_nfts_items.dart'; +import 'package:d_reader_flutter/features/library/presentation/widgets/tabs/owned/owned_digital_assets_items.dart'; import 'package:d_reader_flutter/shared/widgets/unsorted/carrot_error_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -20,7 +20,8 @@ class OwnedTab extends ConsumerWidget { final provider = ref.watch(ownedComicsProvider); return ref.watch(selectedOwnedComicProvider) != null ? ref.watch(selectedIssueInfoProvider) != null - ? OwnedNftsItems(issue: ref.read(selectedIssueInfoProvider)!) + ? OwnedDigitalAssetsItems( + issue: ref.read(selectedIssueInfoProvider)!) : OwnedIssuesItems(comic: ref.read(selectedOwnedComicProvider)!) : provider.when( data: (data) { diff --git a/lib/features/library/presentation/widgets/tabs/owned/owned_nfts_items.dart b/lib/features/library/presentation/widgets/tabs/owned/owned_digital_assets_items.dart similarity index 94% rename from lib/features/library/presentation/widgets/tabs/owned/owned_nfts_items.dart rename to lib/features/library/presentation/widgets/tabs/owned/owned_digital_assets_items.dart index d5c34e84..53a5a3b7 100644 --- a/lib/features/library/presentation/widgets/tabs/owned/owned_nfts_items.dart +++ b/lib/features/library/presentation/widgets/tabs/owned/owned_digital_assets_items.dart @@ -1,16 +1,16 @@ import 'package:d_reader_flutter/features/library/presentation/providers/owned/owned_providers.dart'; -import 'package:d_reader_flutter/features/nft/presentation/providers/nft_providers.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/providers/digital_asset_providers.dart'; import 'package:d_reader_flutter/features/comic_issue/domain/models/comic_issue.dart'; import 'package:d_reader_flutter/shared/domain/providers/environment/environment_notifier.dart'; import 'package:d_reader_flutter/shared/theme/app_colors.dart'; import 'package:d_reader_flutter/shared/widgets/cards/skeleton_card.dart'; -import 'package:d_reader_flutter/features/library/presentation/widgets/cards/owned_nft_card.dart'; +import 'package:d_reader_flutter/features/library/presentation/widgets/cards/owned_digital_asset_card.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -class OwnedNftsItems extends ConsumerWidget { +class OwnedDigitalAssetsItems extends ConsumerWidget { final ComicIssueModel issue; - const OwnedNftsItems({ + const OwnedDigitalAssetsItems({ super.key, required this.issue, }); @@ -18,7 +18,7 @@ class OwnedNftsItems extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final provider = ref.watch( - nftsProvider( + digitalAssetsProvider( 'comicIssueId=${issue.id}&userId=${ref.watch(environmentProvider).user?.id}', ), ); @@ -75,7 +75,7 @@ class OwnedNftsItems extends ConsumerWidget { shrinkWrap: true, physics: const PageScrollPhysics(), itemBuilder: (context, index) { - return OwnedNftCard(nft: data[index]); + return OwnedDigitalAssetCard(digitalAsset: data[index]); }, separatorBuilder: (context, index) { return const Divider( diff --git a/lib/features/nft/data/datasource/nft_remote_data_source.dart b/lib/features/nft/data/datasource/nft_remote_data_source.dart deleted file mode 100644 index c66dc89a..00000000 --- a/lib/features/nft/data/datasource/nft_remote_data_source.dart +++ /dev/null @@ -1,64 +0,0 @@ -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; -import 'package:d_reader_flutter/shared/data/remote/network_service.dart'; -import 'package:d_reader_flutter/shared/domain/models/either.dart'; -import 'package:d_reader_flutter/shared/exceptions/exceptions.dart'; - -abstract class NftDataSource { - Future> getNft(String address); - Future>> getNfts(String query); -} - -class NftRemoteDataSource implements NftDataSource { - final NetworkService networkService; - - NftRemoteDataSource(this.networkService); - - @override - Future> getNft(String address) async { - try { - final response = await networkService.get('/nft/get/$address'); - return response.fold((exception) => Left(exception), (result) { - return Right( - NftModel.fromJson( - result.data, - ), - ); - }); - } catch (exception) { - return Left( - AppException( - message: 'Unknown exception occurred', - statusCode: 500, - identifier: '${exception.toString()}NftRemoteDataSource.getNft', - ), - ); - } - } - - @override - Future>> getNfts(String query) async { - try { - final response = await networkService.get('/nft/get?$query'); - - return response.fold((exception) => Left(exception), (result) { - return Right( - List.from( - result.data.map( - (item) => NftModel.fromJson( - item, - ), - ), - ), - ); - }); - } catch (exception) { - return Left( - AppException( - message: 'Unknown exception occurred', - statusCode: 500, - identifier: '${exception.toString()}NftRemoteDataSource.getNfts', - ), - ); - } - } -} diff --git a/lib/features/nft/data/repositories/nft_repository_impl.dart b/lib/features/nft/data/repositories/nft_repository_impl.dart deleted file mode 100644 index 5119ec64..00000000 --- a/lib/features/nft/data/repositories/nft_repository_impl.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:d_reader_flutter/features/nft/data/datasource/nft_remote_data_source.dart'; -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; -import 'package:d_reader_flutter/features/nft/domain/repositories/nft_repository.dart'; -import 'package:d_reader_flutter/shared/domain/models/either.dart'; -import 'package:d_reader_flutter/shared/exceptions/exceptions.dart'; - -class NftRepositoryImpl implements NftRepository { - final NftDataSource dataSource; - - NftRepositoryImpl(this.dataSource); - @override - Future> getNft(String address) { - return dataSource.getNft(address); - } - - @override - Future>> getNfts(String query) { - return dataSource.getNfts(query); - } -} diff --git a/lib/features/nft/domain/providers/nft_provider.dart b/lib/features/nft/domain/providers/nft_provider.dart deleted file mode 100644 index 266ab67b..00000000 --- a/lib/features/nft/domain/providers/nft_provider.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:d_reader_flutter/features/nft/data/datasource/nft_remote_data_source.dart'; -import 'package:d_reader_flutter/features/nft/data/repositories/nft_repository_impl.dart'; -import 'package:d_reader_flutter/features/nft/domain/repositories/nft_repository.dart'; -import 'package:d_reader_flutter/shared/data/remote/network_service.dart'; -import 'package:d_reader_flutter/shared/domain/providers/dio_network_service_provider.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; - -final nftDataSourceProvider = Provider.family( - (ref, networkService) { - return NftRemoteDataSource(networkService); - }, -); - -final nftRepositoryProvider = Provider( - (ref) { - final networkService = ref.watch(networkServiceProvider); - final dataSource = ref.watch(nftDataSourceProvider(networkService)); - - return NftRepositoryImpl(dataSource); - }, -); diff --git a/lib/features/nft/domain/repositories/nft_repository.dart b/lib/features/nft/domain/repositories/nft_repository.dart deleted file mode 100644 index 17d99478..00000000 --- a/lib/features/nft/domain/repositories/nft_repository.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; -import 'package:d_reader_flutter/shared/domain/models/either.dart'; -import 'package:d_reader_flutter/shared/exceptions/exceptions.dart'; - -abstract class NftRepository { - Future> getNft(String address); - Future>> getNfts(String query); -} diff --git a/lib/features/nft/presentation/utils/extensions.dart b/lib/features/nft/presentation/utils/extensions.dart deleted file mode 100644 index 0f60ee6e..00000000 --- a/lib/features/nft/presentation/utils/extensions.dart +++ /dev/null @@ -1,39 +0,0 @@ -import 'package:d_reader_flutter/shared/domain/models/enums.dart'; -import 'package:d_reader_flutter/shared/theme/app_colors.dart'; -import 'package:flutter/material.dart' show Colors, Color; - -extension RarityExtension on NftRarity { - static const rarityNames = { - NftRarity.none: 'None', - NftRarity.common: 'Common', - NftRarity.uncommon: 'Uncommon', - NftRarity.rare: 'Rare', - NftRarity.epic: 'Epic', - NftRarity.legendary: 'Legendary', - }; - - String get name => rarityNames[this] ?? 'None'; - - static const rarityColors = { - NftRarity.none: Colors.transparent, - NftRarity.common: Colors.white, - NftRarity.uncommon: ColorPalette.dReaderYellow200, - NftRarity.rare: ColorPalette.dReaderLightGreen, - NftRarity.epic: ColorPalette.dReaderPink, - NftRarity.legendary: Color(0xFF8377F2), - }; - - Color get color => rarityColors[this] ?? Colors.white; -} - -extension RarityFromString on String { - static const rarities = { - 'None': NftRarity.none, - 'Common': NftRarity.common, - 'Uncommon': NftRarity.uncommon, - 'Rare': NftRarity.rare, - 'Epic': NftRarity.epic, - 'Legendary': NftRarity.legendary, - }; - NftRarity get rarityEnum => rarities[this] ?? NftRarity.none; -} diff --git a/lib/features/nft/presentation/utils/utils.dart b/lib/features/nft/presentation/utils/utils.dart deleted file mode 100644 index d6529a2c..00000000 --- a/lib/features/nft/presentation/utils/utils.dart +++ /dev/null @@ -1 +0,0 @@ -String shortenNftName(String nftName) => '#${nftName.split('#').last}'; diff --git a/lib/features/settings/presentation/providers/change_network.g.dart b/lib/features/settings/presentation/providers/change_network.g.dart index a3776e79..8a54d833 100644 --- a/lib/features/settings/presentation/providers/change_network.g.dart +++ b/lib/features/settings/presentation/providers/change_network.g.dart @@ -7,7 +7,7 @@ part of 'change_network.dart'; // ************************************************************************** String _$changeNetworkControllerHash() => - r'ff62d7ea95d5b8268c597a092c9c9d2aeb036e6f'; + r'3b8089240aaad78e34d78adf70e29aad491539d2'; /// See also [ChangeNetworkController]. @ProviderFor(ChangeNetworkController) diff --git a/lib/features/transaction/data/datasource/transaction_remote_data_source.dart b/lib/features/transaction/data/datasource/transaction_remote_data_source.dart index 876c77a3..5a3d6ac8 100644 --- a/lib/features/transaction/data/datasource/transaction_remote_data_source.dart +++ b/lib/features/transaction/data/datasource/transaction_remote_data_source.dart @@ -8,8 +8,8 @@ abstract class TransactionDataSource { required String minterAddress, String? label, }); - Future> useComicIssueNftTransaction({ - required String nftAddress, + Future> useComicIssueAssetTransaction({ + required String digitalAssetAddress, required String ownerAddress, }); Future> listTransaction({ @@ -20,7 +20,7 @@ abstract class TransactionDataSource { Future>> buyMultipleItems( Map query); Future> cancelListingTransaction({ - required String nftAddress, + required String digitalAssetAddress, }); } @@ -55,11 +55,11 @@ class TransactionRemoteDataSource implements TransactionDataSource { @override Future> cancelListingTransaction({ - required String nftAddress, + required String digitalAssetAddress, }) async { try { final response = await networkService - .get('/transaction/cancel-listing?nftAddress=$nftAddress'); + .get('/transaction/cancel-listing?assetAddress=$digitalAssetAddress'); return response.fold( (exception) => Left(exception), (result) => Right(result.data.toString()), @@ -132,13 +132,13 @@ class TransactionRemoteDataSource implements TransactionDataSource { } @override - Future> useComicIssueNftTransaction({ - required String nftAddress, + Future> useComicIssueAssetTransaction({ + required String digitalAssetAddress, required String ownerAddress, }) async { try { final response = await networkService.get( - '/transaction/use-comic-issue-nft?nftAddress=$nftAddress&ownerAddress=$ownerAddress', + '/transaction/use-comic-issue-asset?assetAddress=$digitalAssetAddress&ownerAddress=$ownerAddress', ); return response.fold( (exception) => Left(exception), @@ -152,7 +152,7 @@ class TransactionRemoteDataSource implements TransactionDataSource { message: 'Unknown exception occured', statusCode: 500, identifier: - '${exception.toString()}-TransactionRemoteDataSource.useComicIssueNftTransaction', + '${exception.toString()}-TransactionRemoteDataSource.useComicIssueAssetTransaction', ), ); } diff --git a/lib/features/transaction/data/repositories/transaction_repository_impl.dart b/lib/features/transaction/data/repositories/transaction_repository_impl.dart index fe7d0ab9..7d888645 100644 --- a/lib/features/transaction/data/repositories/transaction_repository_impl.dart +++ b/lib/features/transaction/data/repositories/transaction_repository_impl.dart @@ -17,9 +17,11 @@ class TransactionRepositoryImpl implements TransactionRepository { @override Future> cancelListingTransaction({ - required String nftAddress, + required String digitalAssetAddress, }) { - return dataSource.cancelListingTransaction(nftAddress: nftAddress); + return dataSource.cancelListingTransaction( + digitalAssetAddress: digitalAssetAddress, + ); } @override @@ -49,11 +51,11 @@ class TransactionRepositoryImpl implements TransactionRepository { } @override - Future> useComicIssueNftTransaction({ - required String nftAddress, + Future> useComicIssueAssetTransaction({ + required String digitalAssetAddress, required String ownerAddress, }) { - return dataSource.useComicIssueNftTransaction( - nftAddress: nftAddress, ownerAddress: ownerAddress); + return dataSource.useComicIssueAssetTransaction( + digitalAssetAddress: digitalAssetAddress, ownerAddress: ownerAddress); } } diff --git a/lib/features/transaction/domain/repositories/transaction_repository.dart b/lib/features/transaction/domain/repositories/transaction_repository.dart index df8893bd..d40c24b9 100644 --- a/lib/features/transaction/domain/repositories/transaction_repository.dart +++ b/lib/features/transaction/domain/repositories/transaction_repository.dart @@ -7,8 +7,8 @@ abstract class TransactionRepository { required String minterAddress, String? label, }); - Future> useComicIssueNftTransaction({ - required String nftAddress, + Future> useComicIssueAssetTransaction({ + required String digitalAssetAddress, required String ownerAddress, }); Future> listTransaction({ @@ -19,6 +19,6 @@ abstract class TransactionRepository { Future>> buyMultipleItems( Map query); Future> cancelListingTransaction({ - required String nftAddress, + required String digitalAssetAddress, }); } diff --git a/lib/features/wallet/presentation/providers/wallet_providers.dart b/lib/features/wallet/presentation/providers/wallet_providers.dart index 0ec7267b..a426abc9 100644 --- a/lib/features/wallet/presentation/providers/wallet_providers.dart +++ b/lib/features/wallet/presentation/providers/wallet_providers.dart @@ -1,6 +1,6 @@ import 'package:d_reader_flutter/config/config.dart'; import 'package:d_reader_flutter/features/comic_issue/presentation/providers/comic_issue_providers.dart'; -import 'package:d_reader_flutter/features/nft/presentation/providers/nft_providers.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/providers/digital_asset_providers.dart'; import 'package:d_reader_flutter/features/candy_machine/domain/models/receipt.dart'; import 'package:d_reader_flutter/features/candy_machine/presentations/providers/candy_machine_providers.dart'; import 'package:d_reader_flutter/shared/domain/providers/environment/environment_notifier.dart'; @@ -32,17 +32,17 @@ final registerWalletToSocketEvents = Provider( } socket.on('wallet/$address/item-used', (data) { ref.invalidate(ownedIssuesProvider); - ref.invalidate(nftProvider); + ref.invalidate(digitalAssetProvider); return ref - .read(lastProcessedNftProvider.notifier) + .read(lastProcessedAssetProvider.notifier) .update((state) => data['address']); }); socket.on('wallet/$address/item-minted', (data) async { final newReceipt = Receipt.fromJson(data); ref.invalidate(candyMachineProvider); ref - .read(lastProcessedNftProvider.notifier) - .update((state) => newReceipt.nft.address); + .read(lastProcessedAssetProvider.notifier) + .update((state) => newReceipt.partialAsset.address); ref.invalidate(comicIssueDetailsProvider); }); }, diff --git a/lib/routing/router.dart b/lib/routing/router.dart index 54fa374a..72993b8b 100644 --- a/lib/routing/router.dart +++ b/lib/routing/router.dart @@ -3,7 +3,7 @@ import 'package:d_reader_flutter/features/authentication/presentation/screens/si import 'package:d_reader_flutter/features/authentication/presentation/screens/verify_email.dart'; import 'package:d_reader_flutter/features/comic_issue/presentation/screens/comic_issue_cover.dart'; import 'package:d_reader_flutter/features/library/presentation/providers/owned/owned_providers.dart'; -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; import 'package:d_reader_flutter/features/settings/presentation/screens/security_and_privacy.dart'; import 'package:d_reader_flutter/features/transaction/presentation/screens/transaction_timeout.dart'; import 'package:d_reader_flutter/shared/domain/providers/environment/environment_notifier.dart'; @@ -11,8 +11,8 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:d_reader_flutter/constants/routes.dart'; import 'package:d_reader_flutter/features/comic/domain/models/comic_model.dart'; -import 'package:d_reader_flutter/features/nft/presentation/screens/animations/mint_animation_screen.dart'; -import 'package:d_reader_flutter/features/nft/presentation/screens/animations/open_nft_animation_screen.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/screens/animations/mint_animation_screen.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/screens/animations/open_asset_animation_screen.dart'; import 'package:d_reader_flutter/features/comic/presentation/screens/comic_details.dart'; import 'package:d_reader_flutter/features/comic/presentation/screens/comic_info.dart'; import 'package:d_reader_flutter/features/comic_issue/presentation/screens/comic_issue_details.dart'; @@ -20,7 +20,7 @@ import 'package:d_reader_flutter/features/creator/presentation/screens/creator_d import 'package:d_reader_flutter/features/e_reader/presentation/screens/e_reader.dart'; import 'package:d_reader_flutter/features/home/presentation/screens/initial.dart'; import 'package:d_reader_flutter/features/authentication/presentation/screens/request_reset_password.dart'; -import 'package:d_reader_flutter/features/nft/presentation/screens/nft_details.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/screens/digital_asset_details.dart'; import 'package:d_reader_flutter/features/settings/presentation/screens/about.dart'; import 'package:d_reader_flutter/features/settings/presentation/screens/change_network.dart'; import 'package:d_reader_flutter/features/settings/presentation/screens/profile/change_email.dart'; @@ -179,10 +179,10 @@ List generateHomeRoutes(ProviderRef ref) { }, ), GoRoute( - path: '${RoutePath.nftDetails}/:address', + path: '${RoutePath.digitalAssetDetails}/:address', builder: (context, state) { final address = state.pathParameters['address'] ?? ''; - return NftDetails(address: address); + return DigitalAssetDetails(address: address); }, ), GoRoute( @@ -304,14 +304,14 @@ final List animationRoutes = [ GoRoute( path: RoutePath.doneMinting, builder: (context, state) { - final nft = state.extra as NftModel; - return DoneMintingAnimation(nft: nft); + final digitalAsset = state.extra as DigitalAssetModel; + return DoneMintingAnimation(digitalAsset: digitalAsset); }, ), GoRoute( - path: RoutePath.openNftAnimation, + path: RoutePath.openDigitalAssetAnimation, builder: (context, state) { - return const OpenNftAnimation(); + return const OpenDigitalAssetAnimation(); }, ), GoRoute( diff --git a/lib/shared/data/remote/notification_service.dart b/lib/shared/data/remote/notification_service.dart index 04257517..b284dec6 100644 --- a/lib/shared/data/remote/notification_service.dart +++ b/lib/shared/data/remote/notification_service.dart @@ -7,7 +7,7 @@ import 'package:d_reader_flutter/shared/utils/url_utils.dart'; import 'package:d_reader_flutter/features/comic/presentation/screens/comic_details.dart'; import 'package:d_reader_flutter/features/comic_issue/presentation/screens/comic_issue_details.dart'; import 'package:d_reader_flutter/features/creator/presentation/screens/creator_details.dart'; -import 'package:d_reader_flutter/features/nft/presentation/screens/nft_details.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/screens/digital_asset_details.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; @@ -39,11 +39,12 @@ handleNotificationAction(Map payload) { ), ), ); - } else if (payload.containsKey(NotificationDataKey.nftAddress.stringValue)) { + } else if (payload + .containsKey(NotificationDataKey.digitalAssetAddress.stringValue)) { return routerNavigatorKey.currentState!.push( MaterialPageRoute( - builder: (context) => NftDetails( - address: payload[NotificationDataKey.nftAddress.stringValue], + builder: (context) => DigitalAssetDetails( + address: payload[NotificationDataKey.digitalAssetAddress.stringValue], ), ), ); diff --git a/lib/shared/domain/models/enums.dart b/lib/shared/domain/models/enums.dart index 5a569bec..944bbbb7 100644 --- a/lib/shared/domain/models/enums.dart +++ b/lib/shared/domain/models/enums.dart @@ -28,7 +28,7 @@ enum ScrollListType { collectiblesList, } -enum NftRarity { +enum DigitalAssetRarity { none, common, uncommon, diff --git a/lib/shared/domain/providers/environment/environment_notifier.g.dart b/lib/shared/domain/providers/environment/environment_notifier.g.dart index 1f745af3..151cce47 100644 --- a/lib/shared/domain/providers/environment/environment_notifier.g.dart +++ b/lib/shared/domain/providers/environment/environment_notifier.g.dart @@ -6,7 +6,7 @@ part of 'environment_notifier.dart'; // RiverpodGenerator // ************************************************************************** -String _$environmentHash() => r'ee44082b181b2aea8900718d361d4590857a5719'; +String _$environmentHash() => r'24e34ed83fb44ad64ab133a5aee8494ef54845a6'; /// See also [Environment]. @ProviderFor(Environment) diff --git a/lib/shared/domain/providers/solana/solana_notifier.g.dart b/lib/shared/domain/providers/solana/solana_notifier.g.dart index 91d553cc..66ba3923 100644 --- a/lib/shared/domain/providers/solana/solana_notifier.g.dart +++ b/lib/shared/domain/providers/solana/solana_notifier.g.dart @@ -6,7 +6,7 @@ part of 'solana_notifier.dart'; // RiverpodGenerator // ************************************************************************** -String _$solanaNotifierHash() => r'685acc9d82bc0040024a006a281897bf2ed46147'; +String _$solanaNotifierHash() => r'296f37bbb7c74ee01a50c732b772517c12644927'; /// See also [SolanaNotifier]. @ProviderFor(SolanaNotifier) diff --git a/lib/shared/domain/providers/solana/solana_transaction_notifier.dart b/lib/shared/domain/providers/solana/solana_transaction_notifier.dart index c3c63576..bc1b5461 100644 --- a/lib/shared/domain/providers/solana/solana_transaction_notifier.dart +++ b/lib/shared/domain/providers/solana/solana_transaction_notifier.dart @@ -5,8 +5,8 @@ import 'package:d_reader_flutter/constants/constants.dart'; import 'package:d_reader_flutter/features/auction_house/presentation/providers/auction_house_providers.dart'; import 'package:d_reader_flutter/features/candy_machine/domain/models/candy_machine_group.dart'; import 'package:d_reader_flutter/features/candy_machine/presentations/providers/candy_machine_providers.dart'; -import 'package:d_reader_flutter/features/nft/domain/models/buy_nft.dart'; -import 'package:d_reader_flutter/features/nft/presentation/providers/nft_providers.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/buy_digital_asset.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/providers/digital_asset_providers.dart'; import 'package:d_reader_flutter/features/settings/presentation/providers/spl_tokens.dart'; import 'package:d_reader_flutter/features/transaction/domain/providers/transaction_provider.dart'; import 'package:d_reader_flutter/shared/domain/models/either.dart'; @@ -63,13 +63,13 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier { } Future> _signAndSendMint({ - required List encodedNftTransactions, + required List encodedDigitalAssetTransactions, required MobileWalletAdapterClient client, required LocalAssociationScenario session, }) async { try { final response = await client.signTransactions( - transactions: encodedNftTransactions.map((transaction) { + transactions: encodedDigitalAssetTransactions.map((transaction) { return base64Decode(transaction); }).toList(), ); @@ -201,8 +201,8 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier { return response.fold((exception) async { await session.close(); return Left(exception); - }, (encodedNftTransactions) async { - if (encodedNftTransactions.isEmpty) { + }, (encodedDigitalAssetTransactions) async { + if (encodedDigitalAssetTransactions.isEmpty) { await session.close(); return Left( AppException( @@ -213,7 +213,7 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier { ); } final signAndSendMintResult = await _signAndSendMint( - encodedNftTransactions: encodedNftTransactions, + encodedDigitalAssetTransactions: encodedDigitalAssetTransactions, client: client, session: session, ); @@ -351,7 +351,7 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier { } Future> delist({ - required String nftAddress, + required String digitalAssetAddress, }) async { final solanaNotifier = ref.read(solanaNotifierProvider.notifier); try { @@ -360,7 +360,8 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier { ref.read(privateLoadingProvider.notifier).update((state) => true); final response = await ref .read(transactionRepositoryProvider) - .cancelListingTransaction(nftAddress: nftAddress); + .cancelListingTransaction( + digitalAssetAddress: digitalAssetAddress); return response.fold((exception) async { await session.close(); @@ -392,7 +393,7 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier { AppException( identifier: 'SolanaTransactionNotifier.list', statusCode: 500, - message: 'Failed to delist nft.', + message: 'Failed to delist digital asset.', ), ); } @@ -414,11 +415,11 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier { ), ); } - List selectedNftsInput = ref + List selectedDigitalAssetsInput = ref .read(selectedListingsProvider) .map( - (e) => BuyNftInput( - mintAccount: e.nftAddress, + (e) => BuyDigitalAsset( + mintAccount: e.assetAddress, price: e.price, sellerAddress: e.seller.address, buyerAddress: activeWallet, @@ -426,9 +427,9 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier { ) .toList(); Map query = {}; - for (int i = 0; i < selectedNftsInput.length; ++i) { + for (int i = 0; i < selectedDigitalAssetsInput.length; ++i) { query["instantBuyParams[$i]"] = - jsonEncode(selectedNftsInput[i].toJson()); + jsonEncode(selectedDigitalAssetsInput[i].toJson()); } final response = await ref .read(transactionRepositoryProvider) @@ -470,14 +471,14 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier { AppException( identifier: 'SolanaTransactionNotifier.list', statusCode: 500, - message: 'Failed to delist nft.', + message: 'Failed to delist digital asset.', ), ); } } Future> useMint({ - required String nftAddress, + required String digitalAssetAddress, required String ownerAddress, }) async { final solanaNotifier = ref.read(solanaNotifierProvider.notifier); @@ -486,8 +487,8 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier { try { final response = await ref .read(transactionRepositoryProvider) - .useComicIssueNftTransaction( - nftAddress: nftAddress, + .useComicIssueAssetTransaction( + digitalAssetAddress: digitalAssetAddress, ownerAddress: ownerAddress, ); @@ -497,11 +498,11 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier { return Left(exception); }, (transaction) async { - // if there is no transaction, that means it's Core NFT which means it's unwrapped + // if there is no transaction, that means it's Core Digital Asset which means it's unwrapped if (transaction == null || transaction.isEmpty) { ref - .read(lastProcessedNftProvider.notifier) - .update((state) => nftAddress); + .read(lastProcessedAssetProvider.notifier) + .update((state) => digitalAssetAddress); ref.read(globalNotifierProvider.notifier).updateLoading(false); return const Right(successResult); } @@ -527,12 +528,12 @@ class SolanaTransactionNotifier extends _$SolanaTransactionNotifier { Sentry.captureException(exception, stackTrace: - 'Failed to use mint: nftAddress $nftAddress, owner: $ownerAddress. User: ${ref.read(environmentProvider).user?.email}'); + 'Failed to use mint: digitalAssetAddress $digitalAssetAddress, owner: $ownerAddress. User: ${ref.read(environmentProvider).user?.email}'); return Left( AppException( identifier: 'SolanaTransactionNotifier.list', statusCode: 500, - message: 'Failed to unwrap nft', + message: 'Failed to unwrap digitalAssetAddress', ), ); } diff --git a/lib/shared/domain/providers/solana/solana_transaction_notifier.g.dart b/lib/shared/domain/providers/solana/solana_transaction_notifier.g.dart index 3c6becff..8ff98457 100644 --- a/lib/shared/domain/providers/solana/solana_transaction_notifier.g.dart +++ b/lib/shared/domain/providers/solana/solana_transaction_notifier.g.dart @@ -7,7 +7,7 @@ part of 'solana_transaction_notifier.dart'; // ************************************************************************** String _$solanaTransactionNotifierHash() => - r'3a9235eb7a03fc64c870318f09d5c3d6d42076ff'; + r'd5a5294f581012fe722cd5462cde0010d5958885'; /// See also [SolanaTransactionNotifier]. @ProviderFor(SolanaTransactionNotifier) diff --git a/lib/shared/presentations/providers/global/global_notifier.g.dart b/lib/shared/presentations/providers/global/global_notifier.g.dart index ebf38854..aaa3a045 100644 --- a/lib/shared/presentations/providers/global/global_notifier.g.dart +++ b/lib/shared/presentations/providers/global/global_notifier.g.dart @@ -6,7 +6,7 @@ part of 'global_notifier.dart'; // RiverpodGenerator // ************************************************************************** -String _$globalNotifierHash() => r'148175c87fab83037eec3ece239593af2748891e'; +String _$globalNotifierHash() => r'd51238bb69499c1997d9f18221a6c96fab826b79'; /// See also [GlobalNotifier]. @ProviderFor(GlobalNotifier) diff --git a/lib/shared/utils/formatter.dart b/lib/shared/utils/formatter.dart index 6994f4e5..66f33cb4 100644 --- a/lib/shared/utils/formatter.dart +++ b/lib/shared/utils/formatter.dart @@ -85,8 +85,12 @@ class Formatter { } } - static String formatCount(dynamic count) { - return count == 0 ? 'Free' : NumberFormat.compact().format(count); + static String formatCount(dynamic count, [bool isPrice = false]) { + return count == 0 + ? isPrice + ? 'Free' + : '0' + : NumberFormat.compact().format(count); } static String formatPriceByCurrency( @@ -95,6 +99,6 @@ class Formatter { return formatPriceWithSignificant(mintPrice); } final divideResult = mintPrice / pow(10, splToken.decimals); - return formatCount(divideResult); + return formatCount(divideResult, true); } } diff --git a/lib/shared/widgets/buttons/unwrap_button.dart b/lib/shared/widgets/buttons/unwrap_button.dart index 3724cec6..45bd71e3 100644 --- a/lib/shared/widgets/buttons/unwrap_button.dart +++ b/lib/shared/widgets/buttons/unwrap_button.dart @@ -1,5 +1,5 @@ import 'package:d_reader_flutter/constants/enums.dart'; -import 'package:d_reader_flutter/features/nft/domain/models/nft.dart'; +import 'package:d_reader_flutter/features/digital_asset/domain/models/digital_asset.dart'; import 'package:d_reader_flutter/shared/data/local/local_store.dart'; import 'package:d_reader_flutter/shared/theme/app_colors.dart'; import 'package:d_reader_flutter/shared/utils/dialog_triggers.dart'; @@ -11,7 +11,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; class UnwrapButton extends ConsumerWidget { final bool isLoading; - final NftModel nft; + final DigitalAssetModel digitalAsset; final Color backgroundColor, borderColor, loadingColor, textColor; final Size? size; final EdgeInsets padding; @@ -19,7 +19,7 @@ class UnwrapButton extends ConsumerWidget { const UnwrapButton({ super.key, required this.isLoading, - required this.nft, + required this.digitalAsset, required this.onPressed, this.backgroundColor = ColorPalette.dReaderYellow100, this.borderColor = Colors.transparent, diff --git a/lib/shared/widgets/unsorted/rarity.dart b/lib/shared/widgets/unsorted/rarity.dart index f3858300..0377e735 100644 --- a/lib/shared/widgets/unsorted/rarity.dart +++ b/lib/shared/widgets/unsorted/rarity.dart @@ -1,4 +1,4 @@ -import 'package:d_reader_flutter/features/nft/presentation/utils/extensions.dart'; +import 'package:d_reader_flutter/features/digital_asset/presentation/utils/extensions.dart'; import 'package:d_reader_flutter/shared/domain/models/enums.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -6,7 +6,7 @@ import 'package:flutter_svg/flutter_svg.dart'; class RarityWidget extends StatelessWidget { final bool isLarge; final String iconPath; - final NftRarity rarity; + final DigitalAssetRarity rarity; const RarityWidget({ super.key, required this.rarity, @@ -16,7 +16,7 @@ class RarityWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return rarity == NftRarity.none + return rarity == DigitalAssetRarity.none ? const SizedBox() : Container( padding: EdgeInsets.symmetric( diff --git a/publishing/package.json b/publishing/package.json index 2d09e0a4..5ae9588b 100644 --- a/publishing/package.json +++ b/publishing/package.json @@ -4,6 +4,6 @@ "main": "index.js", "license": "MIT", "dependencies": { - "@solana-mobile/dapp-store-cli": "^0.8.1" + "@solana-mobile/dapp-store-cli": "^0.9.0" } } diff --git a/pubspec.lock b/pubspec.lock index d9330c33..5c36be3b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1590,7 +1590,7 @@ packages: source: hosted version: "1.1.11+1" vector_math: - dependency: transitive + dependency: "direct main" description: name: vector_math sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" diff --git a/pubspec.yaml b/pubspec.yaml index e26230b4..faf88f12 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: dReader Flutter app. publish_to: 'none' -version: 1.3.3+72 # dappStore: 1.3.2+45 (next release: 1.3.3+46) google play: 1.3.3+72 (next release: 1.3.4+73) +version: 1.3.4+46 # # dappStore: 1.3.2+45 (next release: 1.3.4+46)) google play: 1.3.4+73 (next release: 1.3.5+74) environment: sdk: '>=3.0.0 <4.0.0' @@ -58,6 +58,7 @@ dependencies: go_router: ^13.1.0 json_annotation: ^4.8.1 google_sign_in: ^6.2.1 + vector_math: ^2.1.4 dev_dependencies: flutter_test: