refactor(grc721)!: Token/Ledger split with Teller pattern#5603
Open
notJoon wants to merge 22 commits intognolang:masterfrom
Open
refactor(grc721)!: Token/Ledger split with Teller pattern#5603notJoon wants to merge 22 commits intognolang:masterfrom
notJoon wants to merge 22 commits intognolang:masterfrom
Conversation
Collaborator
🛠 PR Checks Summary🔴 Pending initial approval by a review team member, or review from tech-staff Manual Checks (for Reviewers):
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) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Restructures
gno.land/p/demo/tokens/grc721along the sameToken/Ledger/Telleraxis the GRC20 refactor (#2983) used. Extracts royalty and on-chain metadata into opt-in subpackages. Migrates four downstream realms to the new API.Closes most items in #5546(GRC20/GRC721 spec alignment meta). Refs #3502 (on-chain Metadata fate) by isolating it into a subpackage so the keep/remove decision can land independently.
Timeline
Tellerinterface and establishes a clear separation of permissionsMetadatastruct #3502: Refactoring direction for GRC-721 is proposed and discussedMetadatatypeChanges
Summarized by Opus 4.7 (1M context) agent.
Core —
gno.land/p/demo/tokens/grc721*basicNFT→*NFT(public read view) +*PrivateLedger(admin operations with explicitfrom/ownerarguments). Admin methods on the ledger never inspectruntime.PreviousRealmorruntime.CurrentRealm.Tellerinterface; five factories produce concrete*fnTellerinstances:(*NFT).CallerTeller()—runtime.PreviousRealm()per call; safe to expose publicly.(*NFT).ReadonlyTeller()— write methods returnErrReadonly.(*NFT).RealmTeller()— captures the calling realm at construction.(*NFT).RealmSubTeller(slug)— derived sub-account.(*PrivateLedger).ImpersonateTeller(addr)— admin-grade impersonation.IGRC721Core(transfer/approve),IGRC721CollectionMetadata,IGRC721Metadata(read:TokenURI),IGRC721MetadataWriter(SetTokenURI),IGRC721Enumerable(TotalSupply). Compile-time witnesses pin the type/interface relationships.TotalSupply()added as an alias ofTokenCount()for grc20 parity.SafeTransferFromaliased toTransferFromwith aDeprecated:comment pointing at [META] GRC20 / GRC721 Spec Alignment & Improvement Tasks #5546. The emptycheckOnGRC721ReceivedandErrTransferToNonGRC721Receiverare removed.avl.Tree→bptree.BPTreethroughout, following the precedent set by chore(boards2): usebptreeinstead ofavlpackage #5568.NewBasicNFTbecomesNewNFTand returns(*NFT, *PrivateLedger).Extensions — new subpackages
gno.land/p/demo/tokens/grc721/royalty—RoyaltyNFT, EIP-2981 royalties expressed in basis points (10 000 = 100 %, lets us represent fractional rates like 2.5 % which the legacy integer-percentage representation could not). OwnPrivateLedgerandTeller. (depends on fix(grc721): migrate royalty to basis points per EIP-2981 #5504)gno.land/p/demo/tokens/grc721/metadata—MetadataNFT, the on-chainMetadata/Traittypes preserved verbatim. OwnPrivateLedgerandTeller.Downstream realms
Migrated within this PR:
r/demo/foo721— admin paths useledger.Mint/ledger.Burn; user-facingApprove/SetApprovalForAll/TransferFromroute throughUserTeller := Token.CallerTeller().r/demo/btree_dao— constructor +dao.Mint→daoLedger.Mint.r/jjoptimist/eventix— same pattern; ticket minting usesticketsLedger.Mint.r/matijamarjanovic/tokenhub— drops theNFTGetterclosure indirection.RegisterNFTnow takes*grc721.NFTdirectly. TheIGRC721CollectionMetadataruntime check is no longer needed (the new*NFTalways satisfies it).Migration cheat-sheet
For out-of-repo callers:
nft := grc721.NewBasicNFT(name, symbol)nft, ledger := grc721.NewNFT(name, symbol)nft.Mint(to, tid)/nft.Burn(tid)ledger.Mint(to, tid)/ledger.Burn(tid)nft.Approve(to, tid)(caller-resolved)Token.CallerTeller().Approve(to, tid)nft.TransferFrom(from, to, tid)Token.CallerTeller().TransferFrom(from, to, tid)grc721.NewNFTWithRoyalty(...)royalty.NewRoyaltyNFT(...)grc721.NewNFTWithMetadata(...)metadata.NewMetadataNFT(...)grc721.NFTGetter,nft.Getter()*grc721.NFTdirectlygrc721.IGRC721(monolithic)IGRC721Core/IGRC721Metadata/ etc.