Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadai2010 committed Sep 20, 2024
1 parent 84b1965 commit 62a3aca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/snfoundry/contracts/src/YourCollectible.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ mod YourCollectible {
enumerable_component.all_tokens_length.write(length + 1);
} else if (token_id < token_id_counter
+ 1) { // `Transfer Token` Case: Remove token from owner and update enumerable component
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
// To prevent a gap in from's tokens array, we store the last token in the index of
// the token to delete, and then delete the last slot (swap and pop).
let owner = self.owner_of(token_id);
if owner != to {
let last_token_index = self.balance_of(owner) - 1;
Expand All @@ -179,7 +179,9 @@ mod YourCollectible {
.owned_tokens
.read((owner, last_token_index));
// Move the last token to the slot of the to-delete token
enumerable_component.owned_tokens.write((owner, token_index), last_token_id);
enumerable_component
.owned_tokens
.write((owner, token_index), last_token_id);
// Update the moved token's index
enumerable_component.owned_tokens_index.write(last_token_id, token_index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub mod ERC721EnumerableComponent {
owned_tokens: LegacyMap<(ContractAddress, u256), u256>,
// Mapping from token ID to index of the owner tokens list
owned_tokens_index: LegacyMap<u256, u256>,
// Mapping with all token ids,
// Mapping with all token ids,
all_tokens: LegacyMap<u256, u256>,
// Helper to get the length of `all_tokens`
all_tokens_length: u256,
Expand Down

0 comments on commit 62a3aca

Please sign in to comment.