Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added File extension on Chain (Easel & Wallet) #1532

Merged
merged 5 commits into from
Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions easel/lib/easel_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ class EaselProvider extends ChangeNotifier {
StringParam(key: kNFTURL, value: nft.url),
StringParam(key: kThumbnailUrl, value: nft.thumbnailUrl),
StringParam(key: kCreator, value: nft.creator.trim()),
StringParam(key: kFileExtension, value: nft.fileExtension.trim()),
StringParam(key: kCID, value: nft.cid),
StringParam(key: kFileSize, value: nft.fileSize),
StringParam(key: kRealWorld, value: "false"),
Expand Down Expand Up @@ -972,6 +973,7 @@ class EaselProvider extends ChangeNotifier {
tradePercentage: royaltyController.text,
height: fileHeight.toString(),
duration: fileDuration.toString(),
fileExtension: _fileExtension,
description: descriptionController.text,
fileSize: _fileSize,
recipeID: recipeId,
Expand Down Expand Up @@ -1009,6 +1011,7 @@ class EaselProvider extends ChangeNotifier {
recipeID: recipeId,
step: step.name,
fileName: _file!.path.split("/").last,
fileExtension: fileExtension,
cid: fileUploadResponse.value?.cid ?? "",
thumbnailUrl: (isThumbnailPresent()) ? "$ipfsDomain/${uploadThumbnailResponse.value?.cid}" : "",
name: artistNameController.text,
Expand Down
4 changes: 4 additions & 0 deletions easel/lib/models/nft.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class NFT extends Equatable {

final bool isEnabled;

final String fileExtension;

const NFT({
this.id,
this.url = "",
Expand Down Expand Up @@ -108,6 +110,7 @@ class NFT extends Equatable {
this.isDialogShown = false,
this.dateTime = 0,
this.ownerAddress = "",
this.fileExtension = "",
});

factory NFT.fromRecipe(Recipe recipe) {
Expand All @@ -122,6 +125,7 @@ class NFT extends Equatable {
description: recipe.entries.itemOutputs.firstOrNull?.strings.firstWhere((strKeyValue) => strKeyValue.key == kDescription, orElse: () => StringParam()).value ?? "",
appType: recipe.entries.itemOutputs.firstOrNull?.strings.firstWhere((strKeyValue) => strKeyValue.key == kAppType, orElse: () => StringParam()).value ?? "",
creator: recipe.entries.itemOutputs.firstOrNull?.strings.firstWhere((strKeyValue) => strKeyValue.key == kCreator, orElse: () => StringParam()).value ?? "",
fileExtension: recipe.entries.itemOutputs.firstOrNull?.strings.firstWhere((strKeyValue) => strKeyValue.key == kFileExtension, orElse: () => StringParam()).value ?? "",
cid: recipe.entries.itemOutputs.firstOrNull?.strings.firstWhere((strKeyValue) => strKeyValue.key == kCID, orElse: () => StringParam()).value ?? "",
width: recipe.entries.itemOutputs.firstOrNull?.longs.firstWhere((longKeyValue) => longKeyValue.key == kWidth, orElse: () => LongParam()).weightRanges.firstOrNull?.upper.toString() ?? "0",
height: recipe.entries.itemOutputs.firstOrNull?.longs.firstWhere((longKeyValue) => longKeyValue.key == kHeight, orElse: () => LongParam()).weightRanges.firstOrNull?.upper.toString() ?? "0",
Expand Down
63 changes: 46 additions & 17 deletions easel/lib/services/third_party_services/database.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions easel/lib/utils/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const kHashtags = "Hashtags";
const kNFTFormat = "NFT_Format";
const kNFTURL = "NFT_URL";
const kCreator = "Creator";
const kFileExtension = "file_extension";
const kCID = "cid";
const kThumbnailUrl = "Thumbnail_URL";
const kEasel = "Easel";
Expand Down
8 changes: 6 additions & 2 deletions wallet/lib/model/nft.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class NFT extends Equatable {
AssetType assetType = AssetType.Image;
String duration = "";
String fileSize = "";
String fileExtension = "";
String hashtags = "";
String cid = "";
String createdAt = "";
Expand Down Expand Up @@ -71,6 +72,7 @@ class NFT extends Equatable {
this.assetType = AssetType.Image,
this.duration = "",
this.fileSize = "",
this.fileExtension = "",
this.hashtags = "",
this.createdAt = "",
this.realWorld = false,
Expand Down Expand Up @@ -103,6 +105,7 @@ class NFT extends Equatable {
description: item.strings.firstWhere((strKeyValue) => strKeyValue.key == kDescription).value,
fileSize: getFileSize(item),
creator: item.strings.firstWhere((strKeyValue) => strKeyValue.key == kCreator, orElse: () => StringKeyValue(key: kCreator, value: "")).value,
fileExtension: item.strings.firstWhere((strKeyValue) => strKeyValue.key == kCreator, orElse: () => StringKeyValue(key: kFileExtension, value: "")).value,
cid: item.strings.firstWhere((strKeyValue) => strKeyValue.key == kCID, orElse: () => StringKeyValue(key: kCID, value: "")).value,
appType: item.strings.firstWhere((strKeyValue) => strKeyValue.key == kAppType, orElse: () => StringKeyValue(key: kAppType, value: "")).value,
width: item.longs.firstWhere((longKeyValue) => longKeyValue.key == kWidth, orElse: () => LongKeyValue(key: kWidth, value: Int64())).value.toString(),
Expand Down Expand Up @@ -137,6 +140,7 @@ class NFT extends Equatable {
description: item.strings.firstWhere((strKeyValue) => strKeyValue.key == kDescription).value,
fileSize: getFileSize(item),
creator: item.strings.firstWhere((strKeyValue) => strKeyValue.key == kCreator, orElse: () => StringKeyValue(key: kCreator, value: "")).value,
fileExtension: item.strings.firstWhere((strKeyValue) => strKeyValue.key == kFileExtension, orElse: () => StringKeyValue(key: kCreator, value: "")).value,
cid: item.strings.firstWhere((strKeyValue) => strKeyValue.key == kCID, orElse: () => StringKeyValue(key: kCID, value: "")).value,
appType: item.strings.firstWhere((strKeyValue) => strKeyValue.key == kAppType, orElse: () => StringKeyValue(key: kAppType, value: "")).value,
width: item.longs.firstWhere((longKeyValue) => longKeyValue.key == kWidth, orElse: () => LongKeyValue(key: kWidth, value: Int64())).value.toString(),
Expand Down Expand Up @@ -171,6 +175,7 @@ class NFT extends Equatable {
cid: recipe.entries.itemOutputs.firstOrNull?.strings.firstWhere((strKeyValue) => strKeyValue.key == kCID, orElse: () => StringParam()).value ?? "",
appType: recipe.entries.itemOutputs.firstOrNull?.strings.firstWhere((strKeyValue) => strKeyValue.key == kAppType, orElse: () => StringParam()).value ?? "",
creator: recipe.entries.itemOutputs.firstOrNull?.strings.firstWhere((strKeyValue) => strKeyValue.key == kCreator, orElse: () => StringParam()).value ?? "",
fileExtension: recipe.entries.itemOutputs.firstOrNull?.strings.firstWhere((strKeyValue) => strKeyValue.key == kFileExtension, orElse: () => StringParam()).value ?? "",
width: recipe.entries.itemOutputs.firstOrNull?.longs.firstWhere((longKeyValue) => longKeyValue.key == kWidth, orElse: () => LongParam()).weightRanges.firstOrNull?.upper.toString() ?? "0",
height: recipe.entries.itemOutputs.firstOrNull?.longs.firstWhere((longKeyValue) => longKeyValue.key == kHeight, orElse: () => LongParam()).weightRanges.firstOrNull?.upper.toString() ?? "0",
amountMinted: int.parse(recipe.entries.itemOutputs.firstOrNull?.amountMinted.toString() ?? "0"),
Expand All @@ -189,8 +194,6 @@ class NFT extends Equatable {
);
}



static Future<NFT> fromTradeByID(Int64 tradeID) async {
final walletsStore = GetIt.I.get<WalletsStore>();
final trade = await walletsStore.getTradeByID(tradeID);
Expand Down Expand Up @@ -234,6 +237,7 @@ class NFT extends Equatable {
assetType,
duration,
fileSize,
fileExtension,
hashtags,
createdAt,
realWorld,
Expand Down
19 changes: 9 additions & 10 deletions wallet/lib/pages/detailed_asset_view/widgets/tab_fields.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,20 @@ class _TabFieldState extends State<TabField> {
case NftType.TYPE_RECIPE:
return {
LocaleKeys.recipe_id.tr(): widget.nft.recipeID,
LocaleKeys.resolution.tr(): "${widget.nft.width}x${widget.nft.height}",
LocaleKeys.resolution.tr(): "${widget.nft.width}x${widget.nft.height} ${widget.nft.fileExtension.toUpperCase()}",
LocaleKeys.ipfs_cid.tr(): widget.nft.cid
};
case NftType.TYPE_ITEM:
return {
LocaleKeys.recipe_id.tr(): widget.nft.recipeID
};
return {LocaleKeys.recipe_id.tr(): widget.nft.recipeID};
case NftType.TYPE_TRADE:
break;
}

return {
LocaleKeys.recipe_id.tr(): widget.nft.recipeID,
LocaleKeys.resolution.tr(): "${widget.nft.width}x${widget.nft.height}",
LocaleKeys.ipfs_cid.tr(): widget.nft.cid};
LocaleKeys.resolution.tr(): "${widget.nft.width}x${widget.nft.height} ${widget.nft.fileExtension}",
LocaleKeys.ipfs_cid.tr(): widget.nft.cid
};
}

@override
Expand All @@ -90,10 +89,10 @@ class _TabFieldState extends State<TabField> {

final listDetails = nftDetail.entries
.map(
(element) => _tabDetails(
field: element.key,
value: element.value,
customWidget: (element.key == LocaleKeys.recipe_id.tr() || element.key == LocaleKeys.ipfs_cid.tr()) && element.value.isNotEmpty ? _tabDetailsWithIcon(value: element.value) : null),
(element) => _tabDetails(
field: element.key,
value: element.value,
customWidget: (element.key == LocaleKeys.recipe_id.tr() || element.key == LocaleKeys.ipfs_cid.tr()) && element.value.isNotEmpty ? _tabDetailsWithIcon(value: element.value) : null),
)
.toList();

Expand Down
2 changes: 2 additions & 0 deletions wallet/lib/utils/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,5 @@ const String kShareNftButtonExpandedKey = "share_nft_expanded";

const String kGetFirebaseAppCheckTokenMethodChannelKey = "getFirebaseAppCheckTokenMethodChannel";
const String kGetFirebaseAppCheckDebugTokenKey = "getFirebaseAppCheckDebugToken";

const kFileExtension = "file_extension";
44 changes: 44 additions & 0 deletions wallet/test/mocks/mock_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ NFT MOCK_NFT_FREE_IMAGE = NFT(
fileSize: "90.12KB",
itemID: "DtnxAS8L4pf",
owner: "abd",
type: NftType.TYPE_RECIPE,
fileExtension: 'jpg',
ibcCoins: IBCCoins.upylon,
);

Expand All @@ -279,6 +281,8 @@ NFT MOCK_NFT_FREE_VIDEO = NFT(
owner: "abd",
ibcCoins: IBCCoins.upylon,
assetType: AssetType.Video,
fileExtension: 'mp4',
type: NftType.TYPE_RECIPE,
);

NFT MOCK_NFT_FREE_AUDIO = NFT(
Expand All @@ -297,6 +301,46 @@ NFT MOCK_NFT_FREE_AUDIO = NFT(
owner: "abd",
ibcCoins: IBCCoins.upylon,
assetType: AssetType.Audio,
fileExtension: 'mp3',
type: NftType.TYPE_RECIPE,
);
NFT MOCK_NFT_FREE_3D = NFT(
name: "This is my Image NFT",
height: "2400",
description: "Please Buy my Image NFT",
width: "1080",
url: "https://proxy.pylons.tech/ipfs/bafkreihzxrk7rpxmih3wr6o5kccxpfyjneg7rbgkpmdflvwyd63geaiaby",
recipeID: "Easel_Recipe_auto_recipe_2022_08_31_154526_206",
duration: "0:0",
cookbookID: "Easel_CookBook_auto_cookbook_2022_08_31_152836_312",
appType: "easel",
creator: "Ahmad",
fileSize: "90.12KB",
itemID: "DtnxAS8L4pf",
owner: "abd",
ibcCoins: IBCCoins.upylon,
assetType: AssetType.ThreeD,
fileExtension: 'glb',
type: NftType.TYPE_RECIPE,
);
NFT MOCK_NFT_FREE_PDF = NFT(
name: "This is my Image NFT",
height: "2400",
description: "Please Buy my Image NFT",
width: "1080",
url: "https://proxy.pylons.tech/ipfs/bafkreihzxrk7rpxmih3wr6o5kccxpfyjneg7rbgkpmdflvwyd63geaiaby",
recipeID: "Easel_Recipe_auto_recipe_2022_08_31_154526_206",
duration: "0:0",
cookbookID: "Easel_CookBook_auto_cookbook_2022_08_31_152836_312",
appType: "easel",
creator: "Ahmad",
fileSize: "90.12KB",
itemID: "DtnxAS8L4pf",
owner: "abd",
ibcCoins: IBCCoins.upylon,
assetType: AssetType.ThreeD,
fileExtension: 'pdf',
type: NftType.TYPE_RECIPE,
);

NftOwnershipHistory MOCK_NFT_OWNERSHIP_HISTORY = NftOwnershipHistory(
Expand Down
Loading