From 3f83d0165da65a3c363834feba68eed438446b35 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:29:02 -0700 Subject: [PATCH] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- examples/gno.land/r/demo/bar20/bar20.gno | 2 + examples/gno.land/r/demo/bar20/gno.mod | 1 + examples/gno.land/r/demo/foo20/foo20.gno | 4 +- .../r/demo/grc20factory/grc20factory.gno | 2 + .../gno.land/r/demo/grc20reg/grc20reg.gno | 8 +-- .../gno.land/r/demo/grc20reg/tmp_proxy.gno | 57 ------------------- 6 files changed, 8 insertions(+), 66 deletions(-) delete mode 100644 examples/gno.land/r/demo/grc20reg/tmp_proxy.gno diff --git a/examples/gno.land/r/demo/bar20/bar20.gno b/examples/gno.land/r/demo/bar20/bar20.gno index 7388d87d24d..d33fd266727 100644 --- a/examples/gno.land/r/demo/bar20/bar20.gno +++ b/examples/gno.land/r/demo/bar20/bar20.gno @@ -9,6 +9,7 @@ import ( "gno.land/p/demo/grc/grc20" "gno.land/p/demo/ufmt" + "gno.land/r/demo/grc20reg" ) var ( @@ -19,6 +20,7 @@ var ( func init() { banker = grc20.NewAdminToken("Bar", "BAR", 4) Token = banker.GRC20() + grc20reg.Register(token, "") } func Faucet() string { diff --git a/examples/gno.land/r/demo/bar20/gno.mod b/examples/gno.land/r/demo/bar20/gno.mod index fd804beb4c4..15f50259d74 100644 --- a/examples/gno.land/r/demo/bar20/gno.mod +++ b/examples/gno.land/r/demo/bar20/gno.mod @@ -4,4 +4,5 @@ require ( gno.land/p/demo/grc/grc20 v0.0.0-latest gno.land/p/demo/testutils v0.0.0-latest gno.land/p/demo/ufmt v0.0.0-latest + gno.land/r/demo/grc20reg v0.0.0-latest ) diff --git a/examples/gno.land/r/demo/foo20/foo20.gno b/examples/gno.land/r/demo/foo20/foo20.gno index 5907fe197f6..45139ff33cf 100644 --- a/examples/gno.land/r/demo/foo20/foo20.gno +++ b/examples/gno.land/r/demo/foo20/foo20.gno @@ -18,11 +18,9 @@ var ( func init() { foo = grc20.NewAdminToken("Foo", "FOO", 4) - pub := foo.GRC20() - proxy := grc20reg.Proxify(pub) - grc20reg.Register(proxy.GetName, "") foo.Mint(admin, 1000000*10000) // @administrator (1M) foo.Mint("g1u7y667z64x2h7vc6fmpcprgey4ck233jaww9zq", 10000*10000) // @manfred (10k) + grc20reg.Register(foo.GRC20(), "") } // method proxies as public functions. diff --git a/examples/gno.land/r/demo/grc20factory/grc20factory.gno b/examples/gno.land/r/demo/grc20factory/grc20factory.gno index 0146d945f0d..09262e78d1f 100644 --- a/examples/gno.land/r/demo/grc20factory/grc20factory.gno +++ b/examples/gno.land/r/demo/grc20factory/grc20factory.gno @@ -7,6 +7,7 @@ import ( "gno.land/p/demo/avl" "gno.land/p/demo/grc/grc20" + "gno.land/r/demo/grc20reg" ) // XXX: the p/grc20 library needs a refactor to change names (i.e., adminToken) @@ -36,6 +37,7 @@ func NewTokenWithAdmin(name, symbol string, decimals uint, initialMint uint64, a admin: admin, } tokens.Set(symbol, &t) + grc20reg.Register(newToken.GRC20(), symbol) } // method proxies as public functions. diff --git a/examples/gno.land/r/demo/grc20reg/grc20reg.gno b/examples/gno.land/r/demo/grc20reg/grc20reg.gno index b1572ce2c77..44f028f1081 100644 --- a/examples/gno.land/r/demo/grc20reg/grc20reg.gno +++ b/examples/gno.land/r/demo/grc20reg/grc20reg.gno @@ -9,16 +9,12 @@ import ( "gno.land/p/demo/ufmt" ) -var registry = avl.NewTree() // pkg path -> IGRC20 - -// func Register(getName func() string, slug string) { +var registry = avl.NewTree() // rlmPath[.slug] -> IGRC20 func Register(token grc20.IGRC20, slug string) { - // proxy := tmpproxy{getName: getName} - proxy := Proxify(token) rlmPath := std.PrevRealm().PkgPath() key := fqname.Construct(rlmPath, slug) - registry.Set(key, proxy) + registry.Set(key, token) std.Emit( registerEvent, "pkgpath", rlmPath, diff --git a/examples/gno.land/r/demo/grc20reg/tmp_proxy.gno b/examples/gno.land/r/demo/grc20reg/tmp_proxy.gno deleted file mode 100644 index 1b18b9064b8..00000000000 --- a/examples/gno.land/r/demo/grc20reg/tmp_proxy.gno +++ /dev/null @@ -1,57 +0,0 @@ -package grc20reg - -import ( - "std" - - "gno.land/p/demo/grc/grc20" -) - -// FIXME; delete this file. -// we currently have a gnovm limitation: -// -// panic: cannot modify external-realm or non-realm object -type tmpproxy struct { - getName func() string - getSymbol func() string - getDecimals func() uint - totalSupply func() uint64 - balanceOf func(std.Address) (uint64, error) - transfer func(std.Address, uint64) error - allowance func(owner, spender std.Address) (uint64, error) - approve func(std.Address, uint64) error - transferFrom func(from, to std.Address, amount uint64) error -} - -func Proxify(input grc20.IGRC20) *tmpproxy { - return &tmpproxy{ - getName: input.GetName, - getSymbol: input.GetSymbol, - getDecimals: input.GetDecimals, - totalSupply: input.TotalSupply, - balanceOf: input.BalanceOf, - transfer: input.Transfer, - allowance: input.Allowance, - approve: input.Approve, - transferFrom: input.TransferFrom, - } -} - -var _ grc20.IGRC20 = (*tmpproxy)(nil) - -func (impl *tmpproxy) GetName() string { return impl.getName() } -func (impl *tmpproxy) GetSymbol() string { return impl.getSymbol() } -func (impl *tmpproxy) GetDecimals() uint { return impl.getDecimals() } -func (impl *tmpproxy) TotalSupply() uint64 { return impl.totalSupply() } -func (impl *tmpproxy) BalanceOf(account std.Address) (uint64, error) { return impl.balanceOf(account) } -func (impl *tmpproxy) Transfer(to std.Address, amount uint64) error { return impl.transfer(to, amount) } -func (impl *tmpproxy) Allowance(owner, spender std.Address) (uint64, error) { - return impl.allowance(owner, spender) -} - -func (impl *tmpproxy) Approve(spender std.Address, amount uint64) error { - return impl.approve(spender, amount) -} - -func (impl *tmpproxy) TransferFrom(from, to std.Address, amount uint64) error { - return impl.transferFrom(from, to, amount) -}