Skip to content

Commit

Permalink
chore: clean tori
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <norman@samourai.coop>
  • Loading branch information
n0izn0iz committed Apr 10, 2024
1 parent 9e37291 commit 215068d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
11 changes: 6 additions & 5 deletions examples/gno.land/r/demo/teritori/tori/gno.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module gno.land/r/demo/teritori/tori

require (
"gno.land/p/demo/ufmt" v0.0.0-latest
"gno.land/p/demo/grc/grc20" v0.0.0-latest
"gno.land/r/demo/users" v0.0.0-latest
"gno.land/p/demo/teritori/ujson" v0.0.0-latest
"gno.land/p/demo/teritori/dao_interfaces" v0.0.0-latest
gno.land/p/demo/grc/grc20 v0.0.0-latest
gno.land/p/demo/teritori/dao_interfaces v0.0.0-latest
gno.land/p/demo/teritori/ujson v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/users v0.0.0-latest
gno.land/r/demo/users v0.0.0-latest
)
2 changes: 1 addition & 1 deletion examples/gno.land/r/demo/teritori/tori/messages.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"gno.land/p/demo/teritori/dao_interfaces"
"gno.land/p/demo/teritori/ujson"
"gno.land/r/demo/users"
"gno.land/p/demo/users"
)

type ExecutableMessageMintTori struct {
Expand Down
19 changes: 10 additions & 9 deletions examples/gno.land/r/demo/teritori/tori/tori.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (

"gno.land/p/demo/grc/grc20"
"gno.land/p/demo/ufmt"
"gno.land/r/demo/users"
"gno.land/p/demo/users"
rusers "gno.land/r/demo/users"
)

var (
Expand All @@ -31,15 +32,15 @@ func TotalSupply() uint64 {
}

func BalanceOf(owner users.AddressOrName) uint64 {
balance, err := tori.BalanceOf(owner.Resolve())
balance, err := tori.BalanceOf(rusers.Resolve(owner))
if err != nil {
panic(err)
}
return balance
}

func Allowance(owner, spender users.AddressOrName) uint64 {
allowance, err := tori.Allowance(owner.Resolve(), spender.Resolve())
allowance, err := tori.Allowance(rusers.Resolve(owner), rusers.Resolve(spender))
if err != nil {
panic(err)
}
Expand All @@ -50,17 +51,17 @@ func Allowance(owner, spender users.AddressOrName) uint64 {

func Transfer(to users.AddressOrName, amount uint64) {
caller := std.PrevRealm().Addr()
tori.Transfer(caller, to.Resolve(), amount)
tori.Transfer(caller, rusers.Resolve(to), amount)
}

func Approve(spender users.AddressOrName, amount uint64) {
caller := std.PrevRealm().Addr()
tori.Approve(caller, spender.Resolve(), amount)
tori.Approve(caller, rusers.Resolve(spender), amount)
}

func TransferFrom(from, to users.AddressOrName, amount uint64) {
caller := std.PrevRealm().Addr()
tori.TransferFrom(caller, from.Resolve(), to.Resolve(), amount)
tori.TransferFrom(caller, rusers.Resolve(from), rusers.Resolve(to), amount)
}

// faucet.
Expand All @@ -77,13 +78,13 @@ func Faucet() {
func Mint(address users.AddressOrName, amount uint64) {
caller := std.PrevRealm().Addr()
assertIsAdmin(caller)
tori.Mint(address.Resolve(), amount)
tori.Mint(rusers.Resolve(address), amount)
}

func Burn(address users.AddressOrName, amount uint64) {
caller := std.PrevRealm().Addr()
assertIsAdmin(caller)
tori.Burn(address.Resolve(), amount)
tori.Burn(rusers.Resolve(address), amount)
}

// render.
Expand All @@ -98,7 +99,7 @@ func Render(path string) string {
return tori.RenderHome()
case c == 2 && parts[0] == "balance":
owner := users.AddressOrName(parts[1])
balance, _ := tori.BalanceOf(owner.Resolve())
balance, _ := tori.BalanceOf(rusers.Resolve(owner))
return ufmt.Sprintf("%d\n", balance)
default:
return "404\n"
Expand Down

0 comments on commit 215068d

Please sign in to comment.