From 0b549e514478c9bb5ad3f4980d8aebe263a2c0e7 Mon Sep 17 00:00:00 2001 From: reasje Date: Tue, 5 Nov 2024 23:49:30 +0330 Subject: [PATCH] refactor: rename Wansee models --- logic/lib/src/domain/entities/entities.dart | 2 +- .../moonchain_address_tokens_list}/item.dart | 0 ...onchain_address_tokens_list_response.dart} | 35 ++-- .../moonchain_address_tokens_list}/token.dart | 0 .../moonchain_balance_event_model.dart | 20 ++ .../entities/moonchain/moonchain_models.dart | 8 + .../attribute.dart | 0 .../item.dart | 0 .../metadata.dart | 0 ...chain_nft_collection_detail_response.dart} | 21 ++- .../owner.dart | 0 .../token.dart | 0 .../attribute.dart | 0 .../moonchain_token_meta_data_response.dart} | 20 +- ...nchain_token_transfer_response_model.dart} | 35 ++-- .../item.dart | 0 ...nchain_tokens_balance_response_model.dart} | 34 ++-- .../token.dart | 0 .../decoded_input.dart | 0 .../moonchain_transactions_model}/fee.dart | 0 .../moonchain_transaction_model.dart} | 174 +++++++++--------- .../moonchain_transactions_model.dart} | 42 ++--- .../{wannsee => moonchain}/shared/from.dart | 0 .../{wannsee => moonchain}/shared/shared.dart | 0 .../{wannsee => moonchain}/shared/to.dart | 0 .../{wannsee => moonchain}/shared/token.dart | 0 .../shared/token_transfer.dart | 0 .../{wannsee => moonchain}/shared/total.dart | 0 .../domain/entities/transaction_model.dart | 2 +- .../wannsee/wannsee_balance_model.dart | 20 -- .../entities/wannsee/wannsee_models.dart | 8 - .../repositories/wallet/nft_contract.dart | 11 +- .../repositories/wallet/token_contract.dart | 23 +-- 33 files changed, 231 insertions(+), 224 deletions(-) rename logic/lib/src/domain/entities/{wannsee/wannsee_address_tokens_list => moonchain/moonchain_address_tokens_list}/item.dart (100%) rename logic/lib/src/domain/entities/{wannsee/wannsee_address_tokens_list/wannsee_address_tokens_list.dart => moonchain/moonchain_address_tokens_list/moonchain_address_tokens_list_response.dart} (62%) rename logic/lib/src/domain/entities/{wannsee/wannsee_address_tokens_list => moonchain/moonchain_address_tokens_list}/token.dart (100%) create mode 100644 logic/lib/src/domain/entities/moonchain/moonchain_balance_event_model.dart create mode 100644 logic/lib/src/domain/entities/moonchain/moonchain_models.dart rename logic/lib/src/domain/entities/{wannsee/wannsee_nft_collection_detail => moonchain/moonchain_nft_collection_detail_response}/attribute.dart (100%) rename logic/lib/src/domain/entities/{wannsee/wannsee_nft_collection_detail => moonchain/moonchain_nft_collection_detail_response}/item.dart (100%) rename logic/lib/src/domain/entities/{wannsee/wannsee_nft_collection_detail => moonchain/moonchain_nft_collection_detail_response}/metadata.dart (100%) rename logic/lib/src/domain/entities/{wannsee/wannsee_nft_collection_detail/wannsee_nft_collection_detail.dart => moonchain/moonchain_nft_collection_detail_response/moonchain_nft_collection_detail_response.dart} (62%) rename logic/lib/src/domain/entities/{wannsee/wannsee_nft_collection_detail => moonchain/moonchain_nft_collection_detail_response}/owner.dart (100%) rename logic/lib/src/domain/entities/{wannsee/wannsee_nft_collection_detail => moonchain/moonchain_nft_collection_detail_response}/token.dart (100%) rename logic/lib/src/domain/entities/{wannsee/wannsee_token_meta_data => moonchain/moonchain_token_meta_data_response}/attribute.dart (100%) rename logic/lib/src/domain/entities/{wannsee/wannsee_token_meta_data/wannsee_token_meta_data.dart => moonchain/moonchain_token_meta_data_response/moonchain_token_meta_data_response.dart} (79%) rename logic/lib/src/domain/entities/{wannsee/wannsee_token_transfers_model/wannsee_token_transfer_model.dart => moonchain/moonchain_token_transfers_response_model/moonchain_token_transfer_response_model.dart} (61%) rename logic/lib/src/domain/entities/{wannsee/wannsee_tokens_balance_model => moonchain/moonchain_tokens_balance_response_model}/item.dart (100%) rename logic/lib/src/domain/entities/{wannsee/wannsee_tokens_balance_model/wannsee_tokens_balance_model.dart => moonchain/moonchain_tokens_balance_response_model/moonchain_tokens_balance_response_model.dart} (63%) rename logic/lib/src/domain/entities/{wannsee/wannsee_tokens_balance_model => moonchain/moonchain_tokens_balance_response_model}/token.dart (100%) rename logic/lib/src/domain/entities/{wannsee/wannsee_transactions_model => moonchain/moonchain_transactions_model}/decoded_input.dart (100%) rename logic/lib/src/domain/entities/{wannsee/wannsee_transactions_model => moonchain/moonchain_transactions_model}/fee.dart (100%) rename logic/lib/src/domain/entities/{wannsee/wannsee_transactions_model/wannsee_transaction_model.dart => moonchain/moonchain_transactions_model/moonchain_transaction_model.dart} (92%) rename logic/lib/src/domain/entities/{wannsee/wannsee_transactions_model/wannsee_transactions_model.dart => moonchain/moonchain_transactions_model/moonchain_transactions_model.dart} (53%) rename logic/lib/src/domain/entities/{wannsee => moonchain}/shared/from.dart (100%) rename logic/lib/src/domain/entities/{wannsee => moonchain}/shared/shared.dart (100%) rename logic/lib/src/domain/entities/{wannsee => moonchain}/shared/to.dart (100%) rename logic/lib/src/domain/entities/{wannsee => moonchain}/shared/token.dart (100%) rename logic/lib/src/domain/entities/{wannsee => moonchain}/shared/token_transfer.dart (100%) rename logic/lib/src/domain/entities/{wannsee => moonchain}/shared/total.dart (100%) delete mode 100644 logic/lib/src/domain/entities/wannsee/wannsee_balance_model.dart delete mode 100644 logic/lib/src/domain/entities/wannsee/wannsee_models.dart diff --git a/logic/lib/src/domain/entities/entities.dart b/logic/lib/src/domain/entities/entities.dart index 8b92db4..3e3b7b3 100644 --- a/logic/lib/src/domain/entities/entities.dart +++ b/logic/lib/src/domain/entities/entities.dart @@ -1,5 +1,5 @@ export 'balance_data.dart'; -export 'wannsee/wannsee_models.dart'; +export 'moonchain/moonchain_models.dart'; export 'default_tokens/default_tokens.dart'; export 'default_ipfs_gateways/default_ipfs_gateways.dart'; export 'default_tweets/default_tweets.dart'; diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_address_tokens_list/item.dart b/logic/lib/src/domain/entities/moonchain/moonchain_address_tokens_list/item.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/wannsee_address_tokens_list/item.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_address_tokens_list/item.dart diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_address_tokens_list/wannsee_address_tokens_list.dart b/logic/lib/src/domain/entities/moonchain/moonchain_address_tokens_list/moonchain_address_tokens_list_response.dart similarity index 62% rename from logic/lib/src/domain/entities/wannsee/wannsee_address_tokens_list/wannsee_address_tokens_list.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_address_tokens_list/moonchain_address_tokens_list_response.dart index 63924b9..267c0ca 100644 --- a/logic/lib/src/domain/entities/wannsee/wannsee_address_tokens_list/wannsee_address_tokens_list.dart +++ b/logic/lib/src/domain/entities/moonchain/moonchain_address_tokens_list/moonchain_address_tokens_list_response.dart @@ -4,20 +4,29 @@ import 'package:equatable/equatable.dart'; import 'item.dart'; -class WannseeAddressTokensList extends Equatable { - const WannseeAddressTokensList({this.items, this.nextPageParams}); +class MoonchainAddressTokensListResponse extends Equatable { - final List? items; - final dynamic nextPageParams; + /// `dart:convert` + /// + /// Parses the string and returns the resulting Json object as [MoonchainAddressTokensListResponse]. + factory MoonchainAddressTokensListResponse.fromJson(String data) { + return MoonchainAddressTokensListResponse.fromMap( + json.decode(data) as Map); + } - factory WannseeAddressTokensList.fromMap(Map data) { - return WannseeAddressTokensList( + factory MoonchainAddressTokensListResponse.fromMap( + Map data) { + return MoonchainAddressTokensListResponse( items: (data['items'] as List?) ?.map((dynamic e) => Item.fromMap(e as Map)) .toList(), nextPageParams: data['next_page_params'] as dynamic, ); } + const MoonchainAddressTokensListResponse({this.items, this.nextPageParams}); + + final List? items; + final dynamic nextPageParams; Map toMap() => { 'items': items?.map((e) => e.toMap()).toList(), @@ -26,22 +35,14 @@ class WannseeAddressTokensList extends Equatable { /// `dart:convert` /// - /// Parses the string and returns the resulting Json object as [WannseeAddressTokensList]. - factory WannseeAddressTokensList.fromJson(String data) { - return WannseeAddressTokensList.fromMap( - json.decode(data) as Map); - } - - /// `dart:convert` - /// - /// Converts [WannseeAddressTokensList] to a JSON string. + /// Converts [MoonchainAddressTokensListResponse] to a JSON string. String toJson() => json.encode(toMap()); - WannseeAddressTokensList copyWith({ + MoonchainAddressTokensListResponse copyWith({ List? items, dynamic nextPageParams, }) { - return WannseeAddressTokensList( + return MoonchainAddressTokensListResponse( items: items ?? this.items, nextPageParams: nextPageParams ?? this.nextPageParams, ); diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_address_tokens_list/token.dart b/logic/lib/src/domain/entities/moonchain/moonchain_address_tokens_list/token.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/wannsee_address_tokens_list/token.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_address_tokens_list/token.dart diff --git a/logic/lib/src/domain/entities/moonchain/moonchain_balance_event_model.dart b/logic/lib/src/domain/entities/moonchain/moonchain_balance_event_model.dart new file mode 100644 index 0000000..02a846d --- /dev/null +++ b/logic/lib/src/domain/entities/moonchain/moonchain_balance_event_model.dart @@ -0,0 +1,20 @@ +import 'package:equatable/equatable.dart'; + +class MoonchainBalanceEvenModel extends Equatable { + + factory MoonchainBalanceEvenModel.fromJson(Map json,) { + return MoonchainBalanceEvenModel(balance: json['balance'] as String); + } + + const MoonchainBalanceEvenModel({this.balance}); + final String? balance; + + Map toJson() { + final Map data = {}; + data['balance'] = balance; + return data; + } + + @override + List get props => [balance]; +} diff --git a/logic/lib/src/domain/entities/moonchain/moonchain_models.dart b/logic/lib/src/domain/entities/moonchain/moonchain_models.dart new file mode 100644 index 0000000..377049f --- /dev/null +++ b/logic/lib/src/domain/entities/moonchain/moonchain_models.dart @@ -0,0 +1,8 @@ +export 'moonchain_transactions_model/moonchain_transactions_model.dart'; +export 'moonchain_balance_event_model.dart'; +export 'shared/shared.dart'; +export 'moonchain_token_transfers_response_model/moonchain_token_transfer_response_model.dart'; +export 'moonchain_tokens_balance_response_model/moonchain_tokens_balance_response_model.dart'; +export 'moonchain_token_meta_data_response/moonchain_token_meta_data_response.dart'; +export 'moonchain_address_tokens_list/moonchain_address_tokens_list_response.dart'; +export 'moonchain_nft_collection_detail_response/moonchain_nft_collection_detail_response.dart'; diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/attribute.dart b/logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/attribute.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/attribute.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/attribute.dart diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/item.dart b/logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/item.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/item.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/item.dart diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/metadata.dart b/logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/metadata.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/metadata.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/metadata.dart diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/wannsee_nft_collection_detail.dart b/logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/moonchain_nft_collection_detail_response.dart similarity index 62% rename from logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/wannsee_nft_collection_detail.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/moonchain_nft_collection_detail_response.dart index 6eac47b..86bc1e9 100644 --- a/logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/wannsee_nft_collection_detail.dart +++ b/logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/moonchain_nft_collection_detail_response.dart @@ -4,14 +4,15 @@ import 'package:equatable/equatable.dart'; import 'item.dart'; -class WannseeNftCollectionDetail extends Equatable { +class MoonchainNftCollectionDetailResponse extends Equatable { final List? items; final dynamic nextPageParams; - const WannseeNftCollectionDetail({this.items, this.nextPageParams}); + const MoonchainNftCollectionDetailResponse({this.items, this.nextPageParams}); - factory WannseeNftCollectionDetail.fromMap(Map data) { - return WannseeNftCollectionDetail( + factory MoonchainNftCollectionDetailResponse.fromMap( + Map data) { + return MoonchainNftCollectionDetailResponse( items: (data['items'] as List?) ?.map((dynamic e) => Item.fromMap(e as Map)) .toList(), @@ -26,22 +27,22 @@ class WannseeNftCollectionDetail extends Equatable { /// `dart:convert` /// - /// Parses the string and returns the resulting Json object as [WannseeNftCollectionDetail]. - factory WannseeNftCollectionDetail.fromJson(String data) { - return WannseeNftCollectionDetail.fromMap( + /// Parses the string and returns the resulting Json object as [MoonchainNftCollectionDetailResponse]. + factory MoonchainNftCollectionDetailResponse.fromJson(String data) { + return MoonchainNftCollectionDetailResponse.fromMap( json.decode(data) as Map); } /// `dart:convert` /// - /// Converts [WannseeNftCollectionDetail] to a JSON string. + /// Converts [MoonchainNftCollectionDetailResponse] to a JSON string. String toJson() => json.encode(toMap()); - WannseeNftCollectionDetail copyWith({ + MoonchainNftCollectionDetailResponse copyWith({ List? items, dynamic nextPageParams, }) { - return WannseeNftCollectionDetail( + return MoonchainNftCollectionDetailResponse( items: items ?? this.items, nextPageParams: nextPageParams ?? this.nextPageParams, ); diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/owner.dart b/logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/owner.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/owner.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/owner.dart diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/token.dart b/logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/token.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/wannsee_nft_collection_detail/token.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/token.dart diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_token_meta_data/attribute.dart b/logic/lib/src/domain/entities/moonchain/moonchain_token_meta_data_response/attribute.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/wannsee_token_meta_data/attribute.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_token_meta_data_response/attribute.dart diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_token_meta_data/wannsee_token_meta_data.dart b/logic/lib/src/domain/entities/moonchain/moonchain_token_meta_data_response/moonchain_token_meta_data_response.dart similarity index 79% rename from logic/lib/src/domain/entities/wannsee/wannsee_token_meta_data/wannsee_token_meta_data.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_token_meta_data_response/moonchain_token_meta_data_response.dart index 70f5f75..715043b 100644 --- a/logic/lib/src/domain/entities/wannsee/wannsee_token_meta_data/wannsee_token_meta_data.dart +++ b/logic/lib/src/domain/entities/moonchain/moonchain_token_meta_data_response/moonchain_token_meta_data_response.dart @@ -4,8 +4,8 @@ import 'package:equatable/equatable.dart'; import 'attribute.dart'; -class WannseeTokenMetaData extends Equatable { - const WannseeTokenMetaData({ +class MoonchainTokenMetaDataResponse extends Equatable { + const MoonchainTokenMetaDataResponse({ this.image, this.name, this.externalLink, @@ -21,8 +21,8 @@ class WannseeTokenMetaData extends Equatable { final List? attributes; final bool? isRealWorldNft; - factory WannseeTokenMetaData.fromMap(Map data) { - return WannseeTokenMetaData( + factory MoonchainTokenMetaDataResponse.fromMap(Map data) { + return MoonchainTokenMetaDataResponse( image: data['image'] as String?, name: data['name'] as String?, externalLink: data['external_link'] as String?, @@ -45,18 +45,18 @@ class WannseeTokenMetaData extends Equatable { /// `dart:convert` /// - /// Parses the string and returns the resulting Json object as [WannseeTokenMetaData]. - factory WannseeTokenMetaData.fromJson(String data) { - return WannseeTokenMetaData.fromMap( + /// Parses the string and returns the resulting Json object as [MoonchainTokenMetaDataResponse]. + factory MoonchainTokenMetaDataResponse.fromJson(String data) { + return MoonchainTokenMetaDataResponse.fromMap( json.decode(data) as Map); } /// `dart:convert` /// - /// Converts [WannseeTokenMetaData] to a JSON string. + /// Converts [MoonchainTokenMetaDataResponse] to a JSON string. String toJson() => json.encode(toMap()); - WannseeTokenMetaData copyWith({ + MoonchainTokenMetaDataResponse copyWith({ String? image, String? name, String? externalLink, @@ -64,7 +64,7 @@ class WannseeTokenMetaData extends Equatable { List? attributes, bool? isRealWorldNft, }) { - return WannseeTokenMetaData( + return MoonchainTokenMetaDataResponse( image: image ?? this.image, name: name ?? this.name, externalLink: externalLink ?? this.externalLink, diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_token_transfers_model/wannsee_token_transfer_model.dart b/logic/lib/src/domain/entities/moonchain/moonchain_token_transfers_response_model/moonchain_token_transfer_response_model.dart similarity index 61% rename from logic/lib/src/domain/entities/wannsee/wannsee_token_transfers_model/wannsee_token_transfer_model.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_token_transfers_response_model/moonchain_token_transfer_response_model.dart index b644164..074b72a 100644 --- a/logic/lib/src/domain/entities/wannsee/wannsee_token_transfers_model/wannsee_token_transfer_model.dart +++ b/logic/lib/src/domain/entities/moonchain/moonchain_token_transfers_response_model/moonchain_token_transfer_response_model.dart @@ -4,14 +4,19 @@ import 'package:equatable/equatable.dart'; import '../shared/shared.dart'; -class WannseeTokenTransfersModel extends Equatable { - final List? items; - final dynamic nextPageParams; +class MoonchainTokenTransfersResponseModel extends Equatable { - const WannseeTokenTransfersModel({this.items, this.nextPageParams}); + /// `dart:convert` + /// + /// Parses the string and returns the resulting Json object as [MoonchainTokenTransfersResponseModel]. + factory MoonchainTokenTransfersResponseModel.fromJson(String data) { + return MoonchainTokenTransfersResponseModel.fromMap( + json.decode(data) as Map); + } - factory WannseeTokenTransfersModel.fromMap(Map data) { - return WannseeTokenTransfersModel( + factory MoonchainTokenTransfersResponseModel.fromMap( + Map data) { + return MoonchainTokenTransfersResponseModel( items: (data['items'] as List?) ?.map((dynamic e) => TokenTransfer.fromMap(e as Map)) .toList(), @@ -19,6 +24,10 @@ class WannseeTokenTransfersModel extends Equatable { ); } + const MoonchainTokenTransfersResponseModel({this.items, this.nextPageParams}); + final List? items; + final dynamic nextPageParams; + Map toMap() => { 'items': items?.map((e) => e.toMap()).toList(), 'next_page_params': nextPageParams, @@ -26,22 +35,14 @@ class WannseeTokenTransfersModel extends Equatable { /// `dart:convert` /// - /// Parses the string and returns the resulting Json object as [WannseeTokenTransfersModel]. - factory WannseeTokenTransfersModel.fromJson(String data) { - return WannseeTokenTransfersModel.fromMap( - json.decode(data) as Map); - } - - /// `dart:convert` - /// - /// Converts [WannseeTokenTransfersModel] to a JSON string. + /// Converts [MoonchainTokenTransfersResponseModel] to a JSON string. String toJson() => json.encode(toMap()); - WannseeTokenTransfersModel copyWith({ + MoonchainTokenTransfersResponseModel copyWith({ List? items, dynamic nextPageParams, }) { - return WannseeTokenTransfersModel( + return MoonchainTokenTransfersResponseModel( items: items ?? this.items, nextPageParams: nextPageParams ?? this.nextPageParams, ); diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_tokens_balance_model/item.dart b/logic/lib/src/domain/entities/moonchain/moonchain_tokens_balance_response_model/item.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/wannsee_tokens_balance_model/item.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_tokens_balance_response_model/item.dart diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_tokens_balance_model/wannsee_tokens_balance_model.dart b/logic/lib/src/domain/entities/moonchain/moonchain_tokens_balance_response_model/moonchain_tokens_balance_response_model.dart similarity index 63% rename from logic/lib/src/domain/entities/wannsee/wannsee_tokens_balance_model/wannsee_tokens_balance_model.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_tokens_balance_response_model/moonchain_tokens_balance_response_model.dart index b34353f..54169a4 100644 --- a/logic/lib/src/domain/entities/wannsee/wannsee_tokens_balance_model/wannsee_tokens_balance_model.dart +++ b/logic/lib/src/domain/entities/moonchain/moonchain_tokens_balance_response_model/moonchain_tokens_balance_response_model.dart @@ -4,14 +4,18 @@ import 'package:equatable/equatable.dart'; import 'item.dart'; -class WannseeTokensBalanceModel extends Equatable { - final List? items; - final dynamic nextPageParams; +class MoonchainTokensBalanceResponseModel extends Equatable { - const WannseeTokensBalanceModel({this.items, this.nextPageParams}); + /// `dart:convert` + /// + /// Parses the string and returns the resulting Json object as [MoonchainTokensBalanceResponseModel]. + factory MoonchainTokensBalanceResponseModel.fromJson(String data) { + return MoonchainTokensBalanceResponseModel.fromMap( + json.decode(data) as Map); + } - factory WannseeTokensBalanceModel.fromMap(Map data) { - return WannseeTokensBalanceModel( + factory MoonchainTokensBalanceResponseModel.fromMap(Map data) { + return MoonchainTokensBalanceResponseModel( items: (data['items'] as List?) ?.map((dynamic e) => TokenItem.fromMap(e as Map)) .toList(), @@ -19,6 +23,10 @@ class WannseeTokensBalanceModel extends Equatable { ); } + const MoonchainTokensBalanceResponseModel({this.items, this.nextPageParams}); + final List? items; + final dynamic nextPageParams; + Map toMap() => { 'items': items?.map((e) => e.toMap()).toList(), 'next_page_params': nextPageParams, @@ -26,22 +34,14 @@ class WannseeTokensBalanceModel extends Equatable { /// `dart:convert` /// - /// Parses the string and returns the resulting Json object as [WannseeTokensBalanceModel]. - factory WannseeTokensBalanceModel.fromJson(String data) { - return WannseeTokensBalanceModel.fromMap( - json.decode(data) as Map); - } - - /// `dart:convert` - /// - /// Converts [WannseeTokensBalanceModel] to a JSON string. + /// Converts [MoonchainTokensBalanceResponseModel] to a JSON string. String toJson() => json.encode(toMap()); - WannseeTokensBalanceModel copyWith({ + MoonchainTokensBalanceResponseModel copyWith({ List? items, dynamic nextPageParams, }) { - return WannseeTokensBalanceModel( + return MoonchainTokensBalanceResponseModel( items: items ?? this.items, nextPageParams: nextPageParams ?? this.nextPageParams, ); diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_tokens_balance_model/token.dart b/logic/lib/src/domain/entities/moonchain/moonchain_tokens_balance_response_model/token.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/wannsee_tokens_balance_model/token.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_tokens_balance_response_model/token.dart diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_transactions_model/decoded_input.dart b/logic/lib/src/domain/entities/moonchain/moonchain_transactions_model/decoded_input.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/wannsee_transactions_model/decoded_input.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_transactions_model/decoded_input.dart diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_transactions_model/fee.dart b/logic/lib/src/domain/entities/moonchain/moonchain_transactions_model/fee.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/wannsee_transactions_model/fee.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_transactions_model/fee.dart diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_transactions_model/wannsee_transaction_model.dart b/logic/lib/src/domain/entities/moonchain/moonchain_transactions_model/moonchain_transaction_model.dart similarity index 92% rename from logic/lib/src/domain/entities/wannsee/wannsee_transactions_model/wannsee_transaction_model.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_transactions_model/moonchain_transaction_model.dart index 1532430..92d10ff 100644 --- a/logic/lib/src/domain/entities/wannsee/wannsee_transactions_model/wannsee_transaction_model.dart +++ b/logic/lib/src/domain/entities/moonchain/moonchain_transactions_model/moonchain_transaction_model.dart @@ -2,85 +2,23 @@ import 'dart:convert'; import 'package:equatable/equatable.dart'; import 'package:mxc_logic/mxc_logic.dart'; -import 'package:mxc_logic/src/domain/entities/wannsee/wannsee_transactions_model/decoded_input.dart'; +import 'package:mxc_logic/src/domain/entities/moonchain/moonchain_transactions_model/decoded_input.dart';import 'decoded_input.dart'; + import 'fee.dart'; -class WannseeTransactionModel extends Equatable { - final DateTime? timestamp; - final Fee? fee; - final String? gasLimit; - final int? block; - final String? status; - final String? method; - final int? confirmations; - final int? type; - final dynamic exchangeRate; - final To? to; - final String? txBurntFee; - final String? maxFeePerGas; - final String? result; - final String? hash; - final String? gasPrice; - final String? priorityFee; - final String? baseFeePerGas; - final From? from; - List? tokenTransfers; - final List? txTypes; - final String? gasUsed; - final dynamic createdContract; - final int? position; - final int? nonce; - final bool? hasErrorInInternalTxs; - final List? actions; - final DecodedInput? decodedInput; - final bool? tokenTransfersOverflow; - final String? rawInput; - String? value; - final String? maxPriorityFeePerGas; - final dynamic revertReason; - final List? confirmationDuration; - final dynamic txTag; +class MoonchainTransactionModel extends Equatable { - WannseeTransactionModel({ - this.timestamp, - this.fee, - this.gasLimit, - this.block, - this.status, - this.method, - this.confirmations, - this.type, - this.exchangeRate, - this.to, - this.txBurntFee, - this.maxFeePerGas, - this.result, - this.hash, - this.gasPrice, - this.priorityFee, - this.baseFeePerGas, - this.from, - this.tokenTransfers, - this.txTypes, - this.gasUsed, - this.createdContract, - this.position, - this.nonce, - this.hasErrorInInternalTxs, - this.actions, - this.decodedInput, - this.tokenTransfersOverflow, - this.rawInput, - this.value, - this.maxPriorityFeePerGas, - this.revertReason, - this.confirmationDuration, - this.txTag, - }); + /// `dart:convert` + /// + /// Parses the string and returns the resulting Json object as [MoonchainTransactionModel]. + factory MoonchainTransactionModel.fromJson(String data) { + return MoonchainTransactionModel.fromMap( + json.decode(data) as Map); + } - factory WannseeTransactionModel.fromMap(Map data) { - return WannseeTransactionModel( + factory MoonchainTransactionModel.fromMap(Map data) { + return MoonchainTransactionModel( timestamp: data['timestamp'] == null ? null : DateTime.parse(data['timestamp'] as String), @@ -132,6 +70,77 @@ class WannseeTransactionModel extends Equatable { ); } + MoonchainTransactionModel({ + this.timestamp, + this.fee, + this.gasLimit, + this.block, + this.status, + this.method, + this.confirmations, + this.type, + this.exchangeRate, + this.to, + this.txBurntFee, + this.maxFeePerGas, + this.result, + this.hash, + this.gasPrice, + this.priorityFee, + this.baseFeePerGas, + this.from, + this.tokenTransfers, + this.txTypes, + this.gasUsed, + this.createdContract, + this.position, + this.nonce, + this.hasErrorInInternalTxs, + this.actions, + this.decodedInput, + this.tokenTransfersOverflow, + this.rawInput, + this.value, + this.maxPriorityFeePerGas, + this.revertReason, + this.confirmationDuration, + this.txTag, + }); + final DateTime? timestamp; + final Fee? fee; + final String? gasLimit; + final int? block; + final String? status; + final String? method; + final int? confirmations; + final int? type; + final dynamic exchangeRate; + final To? to; + final String? txBurntFee; + final String? maxFeePerGas; + final String? result; + final String? hash; + final String? gasPrice; + final String? priorityFee; + final String? baseFeePerGas; + final From? from; + final List? tokenTransfers; + final List? txTypes; + final String? gasUsed; + final dynamic createdContract; + final int? position; + final int? nonce; + final bool? hasErrorInInternalTxs; + final List? actions; + final DecodedInput? decodedInput; + final bool? tokenTransfersOverflow; + final String? rawInput; + String? value; + final String? maxPriorityFeePerGas; + final dynamic revertReason; + final List? confirmationDuration; + final dynamic txTag; + Map toMap() => { 'timestamp': timestamp?.toIso8601String(), 'fee': fee?.toMap(), @@ -171,18 +180,10 @@ class WannseeTransactionModel extends Equatable { /// `dart:convert` /// - /// Parses the string and returns the resulting Json object as [WannseeTransactionModel]. - factory WannseeTransactionModel.fromJson(String data) { - return WannseeTransactionModel.fromMap( - json.decode(data) as Map); - } - - /// `dart:convert` - /// - /// Converts [WannseeTransactionModel] to a JSON string. + /// Converts [MoonchainTransactionModel] to a JSON string. String toJson() => json.encode(toMap()); - WannseeTransactionModel copyWith({ + MoonchainTransactionModel copyWith({ DateTime? timestamp, Fee? fee, String? gasLimit, @@ -218,7 +219,7 @@ class WannseeTransactionModel extends Equatable { List? confirmationDuration, dynamic txTag, }) { - return WannseeTransactionModel( + return MoonchainTransactionModel( timestamp: timestamp ?? this.timestamp, fee: fee ?? this.fee, gasLimit: gasLimit ?? this.gasLimit, @@ -262,7 +263,8 @@ class WannseeTransactionModel extends Equatable { String userAddress, String currentTxFromHash, ) { - if (EthereumAddress.fromHex(currentTxFromHash) == EthereumAddress.fromHex(userAddress)) { + if (EthereumAddress.fromHex(currentTxFromHash) == + EthereumAddress.fromHex(userAddress)) { return TransactionType.sent; } else { return TransactionType.received; diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_transactions_model/wannsee_transactions_model.dart b/logic/lib/src/domain/entities/moonchain/moonchain_transactions_model/moonchain_transactions_model.dart similarity index 53% rename from logic/lib/src/domain/entities/wannsee/wannsee_transactions_model/wannsee_transactions_model.dart rename to logic/lib/src/domain/entities/moonchain/moonchain_transactions_model/moonchain_transactions_model.dart index 00fe3a7..a66ff6d 100644 --- a/logic/lib/src/domain/entities/wannsee/wannsee_transactions_model/wannsee_transactions_model.dart +++ b/logic/lib/src/domain/entities/moonchain/moonchain_transactions_model/moonchain_transactions_model.dart @@ -2,28 +2,36 @@ import 'dart:convert'; import 'package:equatable/equatable.dart'; -import 'wannsee_transaction_model.dart'; +import 'moonchain_transaction_model.dart'; -export 'wannsee_transaction_model.dart'; +export 'moonchain_transaction_model.dart'; import '../shared/shared.dart'; -class WannseeTransactionsModel extends Equatable { - List? items; - final dynamic nextPageParams; +class MoonchainTransactionsModel extends Equatable { - WannseeTransactionsModel({this.items, this.nextPageParams}); + /// `dart:convert` + /// + /// Parses the string and returns the resulting Json object as [MoonchainTransactionsModel]. + factory MoonchainTransactionsModel.fromJson(String data) { + return MoonchainTransactionsModel.fromMap( + json.decode(data) as Map); + } - factory WannseeTransactionsModel.fromMap(Map data) { - return WannseeTransactionsModel( + factory MoonchainTransactionsModel.fromMap(Map data) { + return MoonchainTransactionsModel( items: (data['items'] as List?) ?.map((dynamic e) => - WannseeTransactionModel.fromMap(e as Map)) + MoonchainTransactionModel.fromMap(e as Map)) .toList(), nextPageParams: data['next_page_params'] as dynamic, ); } + const MoonchainTransactionsModel({this.items, this.nextPageParams}); + final List? items; + final dynamic nextPageParams; + Map toMap() => { 'items': items?.map((e) => e.toMap()).toList(), 'next_page_params': nextPageParams, @@ -31,22 +39,14 @@ class WannseeTransactionsModel extends Equatable { /// `dart:convert` /// - /// Parses the string and returns the resulting Json object as [WannseeTransactionsModel]. - factory WannseeTransactionsModel.fromJson(String data) { - return WannseeTransactionsModel.fromMap( - json.decode(data) as Map); - } - - /// `dart:convert` - /// - /// Converts [WannseeTransactionsModel] to a JSON string. + /// Converts [MoonchainTransactionsModel] to a JSON string. String toJson() => json.encode(toMap()); - WannseeTransactionsModel copyWith({ - List? items, + MoonchainTransactionsModel copyWith({ + List? items, dynamic nextPageParams, }) { - return WannseeTransactionsModel( + return MoonchainTransactionsModel( items: items ?? this.items, nextPageParams: nextPageParams ?? this.nextPageParams, ); diff --git a/logic/lib/src/domain/entities/wannsee/shared/from.dart b/logic/lib/src/domain/entities/moonchain/shared/from.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/shared/from.dart rename to logic/lib/src/domain/entities/moonchain/shared/from.dart diff --git a/logic/lib/src/domain/entities/wannsee/shared/shared.dart b/logic/lib/src/domain/entities/moonchain/shared/shared.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/shared/shared.dart rename to logic/lib/src/domain/entities/moonchain/shared/shared.dart diff --git a/logic/lib/src/domain/entities/wannsee/shared/to.dart b/logic/lib/src/domain/entities/moonchain/shared/to.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/shared/to.dart rename to logic/lib/src/domain/entities/moonchain/shared/to.dart diff --git a/logic/lib/src/domain/entities/wannsee/shared/token.dart b/logic/lib/src/domain/entities/moonchain/shared/token.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/shared/token.dart rename to logic/lib/src/domain/entities/moonchain/shared/token.dart diff --git a/logic/lib/src/domain/entities/wannsee/shared/token_transfer.dart b/logic/lib/src/domain/entities/moonchain/shared/token_transfer.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/shared/token_transfer.dart rename to logic/lib/src/domain/entities/moonchain/shared/token_transfer.dart diff --git a/logic/lib/src/domain/entities/wannsee/shared/total.dart b/logic/lib/src/domain/entities/moonchain/shared/total.dart similarity index 100% rename from logic/lib/src/domain/entities/wannsee/shared/total.dart rename to logic/lib/src/domain/entities/moonchain/shared/total.dart diff --git a/logic/lib/src/domain/entities/transaction_model.dart b/logic/lib/src/domain/entities/transaction_model.dart index 6ec369e..61202a1 100644 --- a/logic/lib/src/domain/entities/transaction_model.dart +++ b/logic/lib/src/domain/entities/transaction_model.dart @@ -17,7 +17,7 @@ enum TransactionActions { cancel, speedUp, cancelSpeedUp, speedUpCancel } class TransactionModel { factory TransactionModel.fromMXCTransaction( - WannseeTransactionModel mxcTransaction, + MoonchainTransactionModel mxcTransaction, String walletAddress, ) { String? value = '0'; diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_balance_model.dart b/logic/lib/src/domain/entities/wannsee/wannsee_balance_model.dart deleted file mode 100644 index 041e28a..0000000 --- a/logic/lib/src/domain/entities/wannsee/wannsee_balance_model.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:equatable/equatable.dart'; - -class WannseeBalanceModel extends Equatable { - String? balance; - - WannseeBalanceModel({this.balance}); - - WannseeBalanceModel.fromJson(Map json) { - balance = json['balance'] as String; - } - - Map toJson() { - final Map data = new Map(); - data['balance'] = this.balance; - return data; - } - - @override - List get props => [balance]; -} diff --git a/logic/lib/src/domain/entities/wannsee/wannsee_models.dart b/logic/lib/src/domain/entities/wannsee/wannsee_models.dart deleted file mode 100644 index 2cfc028..0000000 --- a/logic/lib/src/domain/entities/wannsee/wannsee_models.dart +++ /dev/null @@ -1,8 +0,0 @@ -export 'wannsee_transactions_model/wannsee_transactions_model.dart'; -export 'wannsee_balance_model.dart'; -export 'shared/shared.dart'; -export 'wannsee_token_transfers_model/wannsee_token_transfer_model.dart'; -export 'wannsee_tokens_balance_model/wannsee_tokens_balance_model.dart'; -export 'wannsee_token_meta_data/wannsee_token_meta_data.dart'; -export 'wannsee_address_tokens_list/wannsee_address_tokens_list.dart'; -export 'wannsee_nft_collection_detail/wannsee_nft_collection_detail.dart'; diff --git a/logic/lib/src/domain/repositories/wallet/nft_contract.dart b/logic/lib/src/domain/repositories/wallet/nft_contract.dart index a07c903..bad596f 100644 --- a/logic/lib/src/domain/repositories/wallet/nft_contract.dart +++ b/logic/lib/src/domain/repositories/wallet/nft_contract.dart @@ -5,7 +5,7 @@ import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:mxc_logic/src/data/api/client/rest_client.dart'; import 'package:mxc_logic/mxc_logic.dart'; import 'package:mxc_logic/src/data/api/client/web3_client.dart'; -import 'package:mxc_logic/src/domain/entities/wannsee/wannsee_nft_collection_detail/item.dart'; +import 'package:mxc_logic/src/domain/entities/moonchain/moonchain_nft_collection_detail_response/item.dart'; import 'package:mxc_logic/src/domain/repositories/wallet/wallet.dart'; import 'package:mxc_logic/src/domain/utils/mxc_urls.dart'; import 'package:web3dart/web3dart.dart'; @@ -68,7 +68,7 @@ class NftContractRepository { if (metaDataResponse.statusCode == 200) { final tokenMetaData = - WannseeTokenMetaData.fromJson(metaDataResponse.body); + MoonchainTokenMetaDataResponse.fromJson(metaDataResponse.body); final name = await ensNft.name(); @@ -138,7 +138,7 @@ class NftContractRepository { if (response.statusCode == 200) { final addressCollections = - WannseeAddressTokensList.fromJson(response.body); + MoonchainAddressTokensListResponse.fromJson(response.body); for (int i = 0; i < addressCollections.items!.length; i++) { final collectionItem = addressCollections.items![i]; @@ -158,7 +158,7 @@ class NftContractRepository { continue; } final collectionDetail = - WannseeNftCollectionDetail.fromJson(response.body); + MoonchainNftCollectionDetailResponse.fromJson(response.body); final currentCollectionNfts = collectionDetail.items! .where( (element) => element.owner!.hash!.toLowerCase() == address, @@ -221,7 +221,8 @@ class NftContractRepository { continue; } - final metaData = WannseeTokenMetaData.fromJson(response.body); + final metaData = + MoonchainTokenMetaDataResponse.fromJson(response.body); // IPFS gateway get metaData // MetaData parse diff --git a/logic/lib/src/domain/repositories/wallet/token_contract.dart b/logic/lib/src/domain/repositories/wallet/token_contract.dart index b8dbc6a..ae326bf 100644 --- a/logic/lib/src/domain/repositories/wallet/token_contract.dart +++ b/logic/lib/src/domain/repositories/wallet/token_contract.dart @@ -33,11 +33,11 @@ class TokenContractRepository { return await _web3Client.getTransactionCount(address, atBlock: atBlock); } - Future getTransactionsByAddress( + Future getTransactionsByAddress( String address, ) async => MXCFunctionHelpers.mxcChainsFutureFuncWrapperNullable< - WannseeTransactionsModel?>( + MoonchainTransactionsModel?>( () async { final selectedNetwork = _web3Client.network!; final apiBaseUrl = Urls.getApiBaseUrl(selectedNetwork.chainId); @@ -49,12 +49,12 @@ class TokenContractRepository { headers: {'accept': 'application/json'}, ); if (response.statusCode == 200) { - final txList = WannseeTransactionsModel.fromJson(response.body); + final txList = MoonchainTransactionsModel.fromJson(response.body); return txList; } if (response.statusCode == 404) { // new wallet and nothing is returned - final txList = WannseeTransactionsModel( + final txList = MoonchainTransactionsModel( items: const [], ); return txList; @@ -77,12 +77,12 @@ class TokenContractRepository { return epochNumber; } - Future getTokenTransfersByAddress( + Future getTokenTransfersByAddress( String address, TokenType tokenType, ) async => MXCFunctionHelpers.mxcChainsFutureFuncWrapperNullable< - WannseeTokenTransfersModel?>( + MoonchainTokenTransfersResponseModel?>( () async { final selectedNetwork = _web3Client.network!; final apiBaseUrl = Urls.getApiBaseUrl(selectedNetwork.chainId); @@ -94,12 +94,13 @@ class TokenContractRepository { headers: {'accept': 'application/json'}, ); if (response.statusCode == 200) { - final txList = WannseeTokenTransfersModel.fromJson(response.body); + final txList = + MoonchainTokenTransfersResponseModel.fromJson(response.body); return txList; } if (response.statusCode == 404) { // new wallet and nothing is returned - const txList = WannseeTokenTransfersModel( + const txList = MoonchainTokenTransfersResponseModel( items: [], ); return txList; @@ -111,11 +112,11 @@ class TokenContractRepository { ); /// If the transaction is successful then not null - Future getTransactionByHash( + Future getTransactionByHash( String hash, ) async => MXCFunctionHelpers.mxcChainsFutureFuncWrapperNullable< - WannseeTransactionModel?>( + MoonchainTransactionModel?>( () async { final selectedNetwork = _web3Client.network!; final apiBaseUrl = Urls.getApiBaseUrl(selectedNetwork.chainId); @@ -129,7 +130,7 @@ class TokenContractRepository { ); if (response.statusCode == 200) { - final txList = WannseeTransactionModel.fromJson(response.body); + final txList = MoonchainTransactionModel.fromJson(response.body); return txList; } else { return null;