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

fix(standards): nft enumeration & storage measurement #843

Merged
merged 8 commits into from
Aug 15, 2022
Merged

fix(standards): nft enumeration & storage measurement #843

merged 8 commits into from
Aug 15, 2022

Conversation

hanakannzashi
Copy link
Contributor

In case of panic when TokenMetadata Extension and Approval Extension are not implemented

…on and Approval Extension are not implemented
1.Calculated twice tokens_per_owner, confusing
2.Did not remove tmp_token_id in u UnorderedSet when roll back

after:
1.Calculate once tokens_per_owner and remove StorageKey::TokenPerOwnerInner
2.Remove tmp_token_id in UnorderedSet when roll back
@hanakannzashi hanakannzashi changed the title change unwrap to and_then nft enumeration & measure storage Jun 17, 2022
.as_ref()
.and_then(|token_metadata_by_id| token_metadata_by_id.get(&token_id));
let approved_account_ids = self.approvals_by_id.as_ref().and_then(|approvals_by_id| {
approvals_by_id.get(&token_id.to_string()).or_else(|| Some(HashMap::new()))
Copy link
Contributor

@austinabell austinabell Jun 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

            self.approvals_by_id.as_ref().then(|a| a.get(&token_id));

I think that if approval standard isn't implemented this should be None on the token. @BenKurrek can you confirm?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the approval management or metadata standards are not implemented, the token object that is serialized and sent back through the enumeration methods should include just the information as outlined in the core standard:

// The base structure that will be returned for a token. If contract is using
// extensions such as Approval Management, Metadata, or other
// attributes may be included in this structure.
type Token = {
   token_id: string,
   owner_id: string,
 }

The approval and metadata standards are just additive.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, that's not how the standards are currently returning the data, it would be a breaking change to skip serializing if None right now, but can come in a standards re-write.

@austinabell
Copy link
Contributor

tagging related issues to connect (I missed the connection)

#842 #844

@austinabell
Copy link
Contributor

@BenKurrek do you mind having another quick look to make sure things are correct? Need to make sure this is correct when translating to JS SDK.

cc @ailisp was there anything you think should be changed to be in sync with the JS NFT impl?

@ailisp
Copy link
Member

ailisp commented Aug 15, 2022

@austinabell I don't have any so far, this specific PR looks good

@austinabell
Copy link
Contributor

going to wait for another approval since I was the last to make a change

Copy link
Contributor

@BenKurrek BenKurrek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@austinabell austinabell changed the title nft enumeration & measure storage fix(standards): nft enumeration & storage measurement Aug 15, 2022
@austinabell austinabell merged commit e83a758 into near:master Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants