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

feat(grc): remake of grc721 nft standard #3973

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

matijamarjanovic
Copy link
Contributor

@matijamarjanovic matijamarjanovic commented Mar 18, 2025

Modeling after grc20

This implementation is completely based on the exiting grc20 with adaptation to the concept of nft (taken from previos grc721 implementation). What I mean to say is, this code introduces the Teller system to the existing grc721. To maintain consistency I have also decided to keep the exact same godoc comments from the grc20 in places where applicable.

Regardless, grc20 may be lacking in some features regarding extensions (#3692) so I have decided to attemt to bypass them in this approach (this also removes the need for having additions like grc721_metadata etc.)

Hooks

Hooks (in context of token standards) are a concept that allows developers creating fungible and non fungible tokens to customize them to their own liking without having to have their own implementation of the token/nft. It encourages the use of the existing basic implementation, or rather Teller interface.
How it works: admin (meaning token creator) just defines a structure that is going to represent a hook which needs to implement a Hook interface (3 funcs):

  • GetHookType() defining which token-native function is going to trigger the hook (mint, transfer, burn, etc)
  • GetHookTime() defining the time of the triggering - before or after the native func
  • last one being the hook itself so OnTransfer() or OnMint() ...

After creating a hook, token admin would just call the method RegisterHook() over the token (nft) instance which would add the hook to the token's hook registry and the hook would automatically be triggered on desired occasion.

Example (from hooks_test.gno):
type PausableHook struct {
	paused bool
}

func (h *PausableHook) GetHookType() HookType {
	return HookTransfer
}

func (h *PausableHook) GetHookTime() HookTime {
	return HookBefore
}

func (h *PausableHook) OnTransfer(nft *NFT, from, to std.Address, tid TokenID) error {
	if h.paused {
		return ufmt.Errorf("transfers are paused")
	}
	return nil
}
pausable := &PausableHook{paused: false}
nft.RegisterHook(pausable)

Batch operations

This implementation also adds a feature where batch operations are implemented such as BatchTransfer, BatchMint, BatchBurn, etc which are implemented through tellers as well. This contributes to easier usage of the nft realms and some gas efficiency.

matijamarjanovic and others added 9 commits March 6, 2025 16:37
…21 (old) and grc20

- currently grc721 is a copy of grc20 adapted for non fungible tokens
- remake impl also contains a new functionality when compared to the old one - batch operations (transfer, transfer from, mint and burn)
- tellers have been updated with these batch operations
- modify tellers so they work how they are supposed to
- fix imports
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Mar 18, 2025
@Gno2D2 Gno2D2 requested a review from a team March 18, 2025 21:41
@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Mar 18, 2025
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Mar 18, 2025

🛠 PR Checks Summary

🔴 Pending initial approval by a review team member, or review from tech-staff

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
  • The pull request description provides enough details
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)
🔴 Pending initial approval by a review team member, or review from tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: matijamarjanovic/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🔴 Requirement not satisfied
└── 🔴 If
    ├── 🔴 Condition
    │   └── 🔴 Or
    │       ├── 🔴 At least 1 user(s) of the organization reviewed the pull request (with state "APPROVED")
    │       ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request
    │       └── 🔴 This pull request is a draft
    └── 🔴 Else
        └── 🔴 And
            ├── 🟢 This label is applied to pull request: review/triage-pending
            └── 🔴 On no pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission
The pull request description provides enough details

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 Not (🔴 Pull request author is a member of the team: core-contributors)
    └── 🟢 Not (🔴 Pull request author is user: dependabot[bot])

Can be checked by

  • team core-contributors

@@ -0,0 +1 @@
module gno.land/p/demo/grc/grc721-remake
Copy link
Member

@notJoon notJoon Mar 19, 2025

Choose a reason for hiding this comment

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

A - character is not allowed in the package name; thus, the CI has failed. You need to change it.

ref: https://go.dev/blog/package-names

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, this was fixed in 4ee51ca

@leohhhn leohhhn requested review from leohhhn and moul March 19, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages. review/triage-pending PRs opened by external contributors that are waiting for the 1st review
Projects
Status: No status
Status: In Review
Status: Triage
Development

Successfully merging this pull request may close these issues.

3 participants