getCollectionData method

Future getCollectionData(
  1. String creator,
  2. String collectionName
)

Queries collection data.

Collection data in below format

 Collection {
   String description;
   String name;
   String uri;
   int count;
   int maximum;
 }

Implementation

Future<dynamic> getCollectionData(String creator, String collectionName) async {
  final resources = await aptosClient.getAccountResources(creator);
  final accountResource = (resources as List).firstWhere((r) => r["type"] == "0x3::token::Collections");
  final handle = accountResource["data"]["collection_data"]["handle"];
  final tableItem = TableItem("0x1::string::String", "0x3::token::CollectionData", collectionName);
  final collectionTable = await aptosClient.queryTableItem(handle, tableItem);
  return collectionTable;
}