Skip to content

Commit

Permalink
[token] fix collection supply underflow
Browse files Browse the repository at this point in the history
  • Loading branch information
areshand committed Oct 31, 2022
1 parent a44d043 commit c9ff6b6
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions aptos-move/framework/aptos-token/sources/token.move
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,12 @@ module aptos_token::token {
&mut collections.collection_data,
token_id.token_data_id.collection
);
collection_data.supply = collection_data.supply - 1;
// delete the collection data if the collection supply equals 0
if (collection_data.supply == 0) {
destroy_collection_data(table::remove(&mut collections.collection_data, collection_data.name));
if (collection_data.maximum > 0) {
collection_data.supply = collection_data.supply - 1;
// delete the collection data if the collection supply equals 0
if (collection_data.supply == 0) {
destroy_collection_data(table::remove(&mut collections.collection_data, collection_data.name));
};
};
};
};
Expand Down Expand Up @@ -617,10 +619,14 @@ module aptos_token::token {
&mut collections.collection_data,
token_id.token_data_id.collection
);
collection_data.supply = collection_data.supply - 1;
// delete the collection data if the collection supply equals 0
if (collection_data.supply == 0) {
destroy_collection_data(table::remove(&mut collections.collection_data, collection_data.name));

// only update and check the supply for unlimited collection
if (collection_data.maximum > 0){
collection_data.supply = collection_data.supply - 1;
// delete the collection data if the collection supply equals 0
if (collection_data.supply == 0) {
destroy_collection_data(table::remove(&mut collections.collection_data, collection_data.name));
};
};
};
};
Expand Down

0 comments on commit c9ff6b6

Please sign in to comment.