Skip to content

Commit

Permalink
Merge pull request #129 from gnoswap-labs/GSW-692-test-minimize-init-…
Browse files Browse the repository at this point in the history
…process

GSW-692 test: minimize init process
  • Loading branch information
r3v4s authored Dec 15, 2023
2 parents b2f05c3 + 0467942 commit e9226d5
Show file tree
Hide file tree
Showing 27 changed files with 343 additions and 136 deletions.
2 changes: 2 additions & 0 deletions _setup/gns/gns.gno
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func init() {
stakerAddr := std.DerivePkgAddr("gno.land/r/demo/staker")
admins = append(admins, string(stakerAddr))
admins = append(admins, string(admin))

gns.Approve(ira, stakerAddr, 9_223_372_036_854_775_807) // max uint64
}

// method proxies as public functions.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions _setup/grc20_wrapper_test/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/r/demo/grc20_wrapper
37 changes: 37 additions & 0 deletions _setup/grc20_wrapper_test/grc20wrapper.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package grc20wrapper

import (
pRegistry "gno.land/r/demo/pool"
rRegistry "gno.land/r/demo/router"
sRegistry "gno.land/r/demo/staker"
)

func init() {
pRegistry.RegisterGRC20Interface("gno.land/r/demo/wugnot", WugnotTokenInterface{})
rRegistry.RegisterGRC20Interface("gno.land/r/demo/wugnot", WugnotTokenInterface{})
sRegistry.RegisterGRC20Interface("gno.land/r/demo/wugnot", WugnotTokenInterface{})

pRegistry.RegisterGRC20Interface("gno.land/r/demo/bar", BarTokenInterface{})
rRegistry.RegisterGRC20Interface("gno.land/r/demo/bar", BarTokenInterface{})
sRegistry.RegisterGRC20Interface("gno.land/r/demo/bar", BarTokenInterface{})

pRegistry.RegisterGRC20Interface("gno.land/r/demo/baz", BazTokenInterface{})
rRegistry.RegisterGRC20Interface("gno.land/r/demo/baz", BazTokenInterface{})
sRegistry.RegisterGRC20Interface("gno.land/r/demo/baz", BazTokenInterface{})

pRegistry.RegisterGRC20Interface("gno.land/r/demo/foo", FooTokenInterface{})
rRegistry.RegisterGRC20Interface("gno.land/r/demo/foo", FooTokenInterface{})
sRegistry.RegisterGRC20Interface("gno.land/r/demo/foo", FooTokenInterface{})

pRegistry.RegisterGRC20Interface("gno.land/r/demo/gns", GnsTokenInterface{})
rRegistry.RegisterGRC20Interface("gno.land/r/demo/gns", GnsTokenInterface{})
sRegistry.RegisterGRC20Interface("gno.land/r/demo/gns", GnsTokenInterface{})

pRegistry.RegisterGRC20Interface("gno.land/r/demo/obl", OblTokenInterface{})
rRegistry.RegisterGRC20Interface("gno.land/r/demo/obl", OblTokenInterface{})
sRegistry.RegisterGRC20Interface("gno.land/r/demo/obl", OblTokenInterface{})

pRegistry.RegisterGRC20Interface("gno.land/r/demo/qux", QuxTokenInterface{})
rRegistry.RegisterGRC20Interface("gno.land/r/demo/qux", QuxTokenInterface{})
sRegistry.RegisterGRC20Interface("gno.land/r/demo/qux", QuxTokenInterface{})
}
33 changes: 33 additions & 0 deletions _setup/grc20_wrapper_test/wrapper_bar.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package grc20wrapper

import (
"gno.land/r/demo/users"

"gno.land/r/demo/bar"

pRegistry "gno.land/r/demo/pool"
rRegistry "gno.land/r/demo/router"
sRegistry "gno.land/r/demo/staker"
)

type BarTokenInterface struct{}

func (BarTokenInterface) Transfer() func(to users.AddressOrName, amount uint64) {
return bar.Transfer
}

func (BarTokenInterface) TransferFrom() func(from, to users.AddressOrName, amount uint64) {
return bar.TransferFrom
}

func (BarTokenInterface) BalanceOf() func(owner users.AddressOrName) uint64 {
return bar.BalanceOf
}

func (BarTokenInterface) Approve() func(spender users.AddressOrName, amount uint64) {
return bar.Approve
}

var _ pRegistry.GRC20Interface = BarTokenInterface{}
var _ rRegistry.GRC20Interface = BarTokenInterface{}
var _ sRegistry.GRC20Interface = BarTokenInterface{}
33 changes: 33 additions & 0 deletions _setup/grc20_wrapper_test/wrapper_baz.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package grc20wrapper

import (
"gno.land/r/demo/users"

"gno.land/r/demo/baz"

pRegistry "gno.land/r/demo/pool"
rRegistry "gno.land/r/demo/router"
sRegistry "gno.land/r/demo/staker"
)

type BazTokenInterface struct{}

func (BazTokenInterface) Transfer() func(to users.AddressOrName, amount uint64) {
return baz.Transfer
}

func (BazTokenInterface) TransferFrom() func(from, to users.AddressOrName, amount uint64) {
return baz.TransferFrom
}

func (BazTokenInterface) BalanceOf() func(owner users.AddressOrName) uint64 {
return baz.BalanceOf
}

func (BazTokenInterface) Approve() func(spender users.AddressOrName, amount uint64) {
return baz.Approve
}

var _ pRegistry.GRC20Interface = BazTokenInterface{}
var _ rRegistry.GRC20Interface = BazTokenInterface{}
var _ sRegistry.GRC20Interface = BazTokenInterface{}
33 changes: 33 additions & 0 deletions _setup/grc20_wrapper_test/wrapper_foo.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package grc20wrapper

import (
"gno.land/r/demo/users"

"gno.land/r/demo/foo"

pRegistry "gno.land/r/demo/pool"
rRegistry "gno.land/r/demo/router"
sRegistry "gno.land/r/demo/staker"
)

type FooTokenInterface struct{}

func (FooTokenInterface) Transfer() func(to users.AddressOrName, amount uint64) {
return foo.Transfer
}

func (FooTokenInterface) TransferFrom() func(from, to users.AddressOrName, amount uint64) {
return foo.TransferFrom
}

func (FooTokenInterface) BalanceOf() func(owner users.AddressOrName) uint64 {
return foo.BalanceOf
}

func (FooTokenInterface) Approve() func(spender users.AddressOrName, amount uint64) {
return foo.Approve
}

var _ pRegistry.GRC20Interface = FooTokenInterface{}
var _ rRegistry.GRC20Interface = FooTokenInterface{}
var _ sRegistry.GRC20Interface = FooTokenInterface{}
33 changes: 33 additions & 0 deletions _setup/grc20_wrapper_test/wrapper_gns.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package grc20wrapper

import (
"gno.land/r/demo/users"

"gno.land/r/demo/gns"

pRegistry "gno.land/r/demo/pool"
rRegistry "gno.land/r/demo/router"
sRegistry "gno.land/r/demo/staker"
)

type GnsTokenInterface struct{}

func (GnsTokenInterface) Transfer() func(to users.AddressOrName, amount uint64) {
return gns.Transfer
}

func (GnsTokenInterface) TransferFrom() func(from, to users.AddressOrName, amount uint64) {
return gns.TransferFrom
}

func (GnsTokenInterface) BalanceOf() func(owner users.AddressOrName) uint64 {
return gns.BalanceOf
}

func (GnsTokenInterface) Approve() func(spender users.AddressOrName, amount uint64) {
return gns.Approve
}

var _ pRegistry.GRC20Interface = GnsTokenInterface{}
var _ rRegistry.GRC20Interface = GnsTokenInterface{}
var _ sRegistry.GRC20Interface = GnsTokenInterface{}
33 changes: 33 additions & 0 deletions _setup/grc20_wrapper_test/wrapper_obl.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package grc20wrapper

import (
"gno.land/r/demo/users"

"gno.land/r/demo/obl"

pRegistry "gno.land/r/demo/pool"
rRegistry "gno.land/r/demo/router"
sRegistry "gno.land/r/demo/staker"
)

type OblTokenInterface struct{}

func (OblTokenInterface) Transfer() func(to users.AddressOrName, amount uint64) {
return obl.Transfer
}

func (OblTokenInterface) TransferFrom() func(from, to users.AddressOrName, amount uint64) {
return obl.TransferFrom
}

func (OblTokenInterface) BalanceOf() func(owner users.AddressOrName) uint64 {
return obl.BalanceOf
}

func (OblTokenInterface) Approve() func(spender users.AddressOrName, amount uint64) {
return obl.Approve
}

var _ pRegistry.GRC20Interface = OblTokenInterface{}
var _ rRegistry.GRC20Interface = OblTokenInterface{}
var _ sRegistry.GRC20Interface = OblTokenInterface{}
33 changes: 33 additions & 0 deletions _setup/grc20_wrapper_test/wrapper_qux.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package grc20wrapper

import (
"gno.land/r/demo/users"

"gno.land/r/demo/qux"

pRegistry "gno.land/r/demo/pool"
rRegistry "gno.land/r/demo/router"
sRegistry "gno.land/r/demo/staker"
)

type QuxTokenInterface struct{}

func (QuxTokenInterface) Transfer() func(to users.AddressOrName, amount uint64) {
return qux.Transfer
}

func (QuxTokenInterface) TransferFrom() func(from, to users.AddressOrName, amount uint64) {
return qux.TransferFrom
}

func (QuxTokenInterface) BalanceOf() func(owner users.AddressOrName) uint64 {
return qux.BalanceOf
}

func (QuxTokenInterface) Approve() func(spender users.AddressOrName, amount uint64) {
return qux.Approve
}

var _ pRegistry.GRC20Interface = QuxTokenInterface{}
var _ rRegistry.GRC20Interface = QuxTokenInterface{}
var _ sRegistry.GRC20Interface = QuxTokenInterface{}
33 changes: 33 additions & 0 deletions _setup/grc20_wrapper_test/wrapper_wugnot.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package grc20wrapper

import (
"gno.land/r/demo/users"

"gno.land/r/demo/wugnot"

pRegistry "gno.land/r/demo/pool"
rRegistry "gno.land/r/demo/router"
sRegistry "gno.land/r/demo/staker"
)

type WugnotTokenInterface struct{}

func (WugnotTokenInterface) Transfer() func(to users.AddressOrName, amount uint64) {
return wugnot.Transfer
}

func (WugnotTokenInterface) TransferFrom() func(from, to users.AddressOrName, amount uint64) {
return wugnot.TransferFrom
}

func (WugnotTokenInterface) BalanceOf() func(owner users.AddressOrName) uint64 {
return wugnot.BalanceOf
}

func (WugnotTokenInterface) Approve() func(spender users.AddressOrName, amount uint64) {
return wugnot.Approve
}

var _ pRegistry.GRC20Interface = WugnotTokenInterface{}
var _ rRegistry.GRC20Interface = WugnotTokenInterface{}
var _ sRegistry.GRC20Interface = WugnotTokenInterface{}
4 changes: 1 addition & 3 deletions _setup/wugnot/wugnot.gno
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import (

var (
// wugnot is the admin token, able to mint and burn.
// wugnot *grc20.AdminToken = grc20.NewAdminToken("wrapped GNOT", "wugnot", 0) // orig
wugnot *grc20.AdminToken = grc20.NewAdminToken("Wrapped GNOT", "wugnot", 6)
wugnot *grc20.AdminToken = grc20.NewAdminToken("WrappedGNOT", "WGNOT", 6)

// WUGNOT is the banker usable by users directly.
WUGNOT = wugnot.GRC20()
)


const (
ugnotMinDeposit uint64 = 1
wugnotMinDeposit uint64 = 1
Expand Down
Loading

0 comments on commit e9226d5

Please sign in to comment.