Skip to content

Commit

Permalink
feat(examples): grc20 refactor (#2983)
Browse files Browse the repository at this point in the history
This PR extracts the grc20 refactor from #2551, which is a meta PR
containing several contract improvements and additions that depend on
new Gnovm features that haven't been merged yet.

Please review this grc20 refactor with a focus on its API. Several
valuable comments can be found in #2551. Additionally, you can discover
new contracts using grc20 in #2551, such as `minidex`, `atomicswap`,
`grc20reg`, `test20`, and `vault`.

Addresses #1832

---------

Signed-off-by: moul <[email protected]>
Co-authored-by: Morgan <[email protected]>
Co-authored-by: Morgan Bazalgette <[email protected]>
Co-authored-by: Leon Hudak <[email protected]>
  • Loading branch information
4 people authored Nov 12, 2024
1 parent 36cdadb commit 3bb666c
Show file tree
Hide file tree
Showing 20 changed files with 780 additions and 450 deletions.
4 changes: 2 additions & 2 deletions examples/gno.land/p/demo/fqname/fqname.gno
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func Parse(fqname string) (pkgpath, name string) {

// Construct a qualified identifier.
//
// fqName := fqname.Construct("gno.land/r/demo/foo20", "GRC20")
// fqName := fqname.Construct("gno.land/r/demo/foo20", "Token")
// fmt.Println("Fully Qualified Name:", fqName)
// // Output: gno.land/r/demo/foo20.GRC20
// // Output: gno.land/r/demo/foo20.Token
func Construct(pkgpath, name string) string {
// TODO: ensure pkgpath is valid - and as such last part does not contain a dot.
if name == "" {
Expand Down
4 changes: 2 additions & 2 deletions examples/gno.land/p/demo/fqname/fqname_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestConstruct(t *testing.T) {
name string
expected string
}{
{"gno.land/r/demo/foo20", "GRC20", "gno.land/r/demo/foo20.GRC20"},
{"gno.land/r/demo/foo20", "Token", "gno.land/r/demo/foo20.Token"},
{"gno.land/r/demo/foo20", "", "gno.land/r/demo/foo20"},
{"path", "", "path"},
{"path", "Split", "path.Split"},
Expand All @@ -62,7 +62,7 @@ func TestRenderLink(t *testing.T) {
{"gno.land/p/demo/avl", "", "[gno.land/p/demo/avl](/p/demo/avl)"},
{"github.com/a/b", "C", "github.com/a/b.C"},
{"example.com/pkg", "Func", "example.com/pkg.Func"},
{"gno.land/r/demo/foo20", "GRC20", "[gno.land/r/demo/foo20](/r/demo/foo20).GRC20"},
{"gno.land/r/demo/foo20", "Token", "[gno.land/r/demo/foo20](/r/demo/foo20).Token"},
{"gno.land/r/demo/foo20", "", "[gno.land/r/demo/foo20](/r/demo/foo20)"},
{"", "", ""},
}
Expand Down
215 changes: 0 additions & 215 deletions examples/gno.land/p/demo/grc/grc20/banker.gno

This file was deleted.

51 changes: 0 additions & 51 deletions examples/gno.land/p/demo/grc/grc20/banker_test.gno

This file was deleted.

18 changes: 18 additions & 0 deletions examples/gno.land/p/demo/grc/grc20/examples_test.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package grc20

// XXX: write Examples

func ExampleInit() {}
func ExampleExposeBankForMaketxRunOrImports() {}
func ExampleCustomTellerImpl() {}
func ExampleAllowance() {}
func ExampleRealmBanker() {}
func ExamplePrevRealmBanker() {}
func ExampleAccountBanker() {}
func ExampleTransfer() {}
func ExampleApprove() {}
func ExampleTransferFrom() {}
func ExampleMint() {}
func ExampleBurn() {}

// ...
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/grc/grc20/gno.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/grc/exts v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/urequire v0.0.0-latest
)
3 changes: 3 additions & 0 deletions examples/gno.land/p/demo/grc/grc20/mock.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package grc20

// XXX: func Mock(t *Token)
Loading

0 comments on commit 3bb666c

Please sign in to comment.