mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-26 21:50:27 +00:00
0c77b23ecb
* feat: Implement NFT Listing and Importing of new NFTs, also display NFTs linked to the wallet address * Adjust UI based on wallet type, display nfts only when an ethereum wallet * fix: Prevent tab bar from scrolling * feat:Add NFT tab: adjust models and add localization * feat:Add NFT tab: adjust models and add localization * chore: Remove unused widget * fix: Adjust UI to reflect more data, display image based on type, either png or svg, adjust theme-a * fix: Update viewmodel * fix: Add missing dependency to fix failing CI * fix: Revert change in inject app script * Delete cw_polygon/pubspec.lock * - Code enhancements - UI fixes - Removing unrelated files --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
95 lines
2.5 KiB
Dart
95 lines
2.5 KiB
Dart
class WalletNFTsResponseModel {
|
|
final int? page;
|
|
final int? pageSize;
|
|
|
|
final List<NFTAssetModel>? result;
|
|
final String? status;
|
|
|
|
WalletNFTsResponseModel({this.page, this.pageSize, this.result, this.status});
|
|
|
|
factory WalletNFTsResponseModel.fromJson(Map<String, dynamic> json) {
|
|
return WalletNFTsResponseModel(
|
|
page: json['page'] as int?,
|
|
pageSize: json['page_size'] as int?,
|
|
result: (json['result'] as List?)
|
|
?.map((x) => NFTAssetModel.fromJson(x as Map<String, dynamic>))
|
|
.toList(),
|
|
status: json['status'] as String?,
|
|
);
|
|
}
|
|
}
|
|
|
|
class NFTAssetModel {
|
|
final String? tokenAddress;
|
|
final String? tokenId;
|
|
final String? contractType;
|
|
final String? name;
|
|
final String? symbol;
|
|
NormalizedMetadata? normalizedMetadata;
|
|
|
|
NFTAssetModel(
|
|
{this.tokenAddress,
|
|
this.tokenId,
|
|
this.contractType,
|
|
this.name,
|
|
this.symbol,
|
|
this.normalizedMetadata});
|
|
|
|
factory NFTAssetModel.fromJson(Map<String, dynamic> json) {
|
|
return NFTAssetModel(
|
|
tokenAddress: json['token_address'] as String?,
|
|
tokenId: json['token_id'] as String?,
|
|
contractType: json['contract_type'] as String?,
|
|
name: json['name'] as String?,
|
|
symbol: json['symbol'] as String?,
|
|
normalizedMetadata: json['normalized_metadata'] != null
|
|
? new NormalizedMetadata.fromJson(
|
|
json['normalized_metadata'] as Map<String, dynamic>)
|
|
: null,
|
|
);
|
|
}
|
|
}
|
|
|
|
class NormalizedMetadata {
|
|
final String? name;
|
|
final String? description;
|
|
final String? image;
|
|
NormalizedMetadata({
|
|
this.name,
|
|
this.description,
|
|
this.image,
|
|
});
|
|
|
|
factory NormalizedMetadata.fromJson(Map<String, dynamic> json) {
|
|
return NormalizedMetadata(
|
|
name: json['name'] as String?,
|
|
description: json['description'] as String?,
|
|
image: json['image'] as String?,
|
|
);
|
|
|
|
}
|
|
|
|
String? get imageUrl {
|
|
if (image == null) return image;
|
|
|
|
if (image!.contains('ipfs.io')) return image;
|
|
|
|
if (!image!.contains('ipfs')) return image;
|
|
|
|
// IPFS public gateway provided by Cloudflare is https://cloudflare-ipfs.com/ipfs/
|
|
//
|
|
// Here is an example of an ipfs image link:
|
|
//
|
|
// [ipfs://bafkreia2i2ctfexpovgzfff66wqhbmwwpvqjvozan7ioifzcnq76jharwu]
|
|
|
|
//https://ipfs.io/ipfs/QmTRcRXo6cXByjHYHTVxGpag6vpocrG3rxjPC9PxKAArR9/1620.png
|
|
|
|
const String ipfsPublicGateway = 'https://cloudflare-ipfs.com/ipfs/';
|
|
|
|
final ipfsPath = image?.split('//')[1];
|
|
|
|
final imageLink = '$ipfsPublicGateway$ipfsPath';
|
|
|
|
return imageLink;
|
|
}
|
|
}
|