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: gnoxchange - simple dex #3793

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/gno.land/p/demo/grc/grc1155/basic_grc1155_token.gno
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,9 @@ func (s *basicGRC1155Token) RenderHome() (str string) {

return
}

func (mt *basicGRC1155Token) Getter() MultiTokenGetter {
return func() IGRC1155 {
return mt
}
}
2 changes: 2 additions & 0 deletions examples/gno.land/p/demo/grc/grc1155/igrc1155.gno
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ type ApprovalForAllEvent struct {
type UpdateURIEvent struct {
URI string
}

type MultiTokenGetter func() IGRC1155
7 changes: 7 additions & 0 deletions examples/gno.land/p/demo/grc/grc721/basic_nft.gno
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,10 @@ func (s *basicNFT) RenderHome() (str string) {

return
}

// Then add the Getter method to your NFT types
func (n *basicNFT) Getter() NFTGetter {
return func() IGRC721 {
return n
}
}
2 changes: 2 additions & 0 deletions examples/gno.land/p/demo/grc/grc721/igrc721.gno
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ const (
ApprovalEvent = "Approval"
ApprovalForAllEvent = "ApprovalForAll"
)

type NFTGetter func() IGRC721
21 changes: 21 additions & 0 deletions examples/gno.land/r/demo/grc20reg/grc20reg.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"std"

"gno.land/p/demo/avl"
"gno.land/p/demo/avl/rotree"
"gno.land/p/demo/fqname"
"gno.land/p/demo/grc/grc20"
"gno.land/p/demo/ufmt"
Expand All @@ -22,6 +23,22 @@ func Register(tokenGetter grc20.TokenGetter, slug string) {
)
}

func RegisterWithTokenhub(tokenGetter grc20.TokenGetter, key string) {
prevRealmPath := std.PreviousRealm().PkgPath()
if prevRealmPath != "gno.land/r/matijamarjanovic/tokenhub" {
return
}

registry.Set(key, tokenGetter)

rlmPath, slug := fqname.Parse(key)
std.Emit(
registerEvent,
"pkgpath", rlmPath,
"slug", slug,
)
}

func Get(key string) grc20.TokenGetter {
tokenGetter, ok := registry.Get(key)
if !ok {
Expand Down Expand Up @@ -74,3 +91,7 @@ func Render(path string) string {
}

const registerEvent = "register"

func GetRegistry() *rotree.ReadOnlyTree {
return rotree.Wrap(registry, nil)
}
Loading
Loading