Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <[email protected]>
  • Loading branch information
n0izn0iz committed Dec 6, 2024
1 parent dd33718 commit 128c677
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 31 deletions.
6 changes: 3 additions & 3 deletions gno/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
KEY = teritori
KEY = teritori-test4-seed
BASE = teritori
REMOTE = https://rpc.test5.gno.land
CHAIN_ID = test5
REMOTE = https://rpc.gno.land
CHAIN_ID = portal-loop

.PHONY: add_social_feeds_realm add_utf16_pkg add_ujson_pkg add_flags_index_pkg add_dao_interfaces_pkg add_social_feed all

Expand Down
16 changes: 0 additions & 16 deletions gno/p/jsonutil/jsonutil.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (

"gno.land/p/demo/avl"
"gno.land/p/demo/json"
"gno.land/p/demo/users"
rusers "gno.land/r/demo/users"
)

func UnionNode(variant string, value *json.Node) *json.Node {
Expand Down Expand Up @@ -129,17 +127,3 @@ func MustAddress(value *json.Node) std.Address {

return addr
}

func AddressOrNameNode(aon users.AddressOrName) *json.Node {
return json.StringNode("", string(aon))
}

func MustAddressOrName(value *json.Node) users.AddressOrName {
aon := users.AddressOrName(value.MustString())
address := rusers.Resolve(aon)
if !address.IsValid() {
panic("invalid address or name")
}

return aon
}
25 changes: 13 additions & 12 deletions gno/r/tori/messages.gno
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tori

import (
"std"
"strconv"
"strings"

Expand All @@ -13,7 +14,7 @@ import (
type ExecutableMessageMintTori struct {
dao_interfaces.ExecutableMessage

Recipient users.AddressOrName
Recipient std.Address
Amount uint64
}

Expand All @@ -37,13 +38,13 @@ func (msg *ExecutableMessageMintTori) String() string {

func (msg *ExecutableMessageMintTori) FromJSON(ast *json.Node) {
obj := ast.MustObject()
msg.Recipient = jsonutil.MustAddressOrName(obj["recipient"])
msg.Recipient = jsonutil.MustAddress(obj["recipient"])
msg.Amount = jsonutil.MustUint64(obj["amount"])
}

func (msg *ExecutableMessageMintTori) ToJSON() *json.Node {
return json.ObjectNode("", map[string]*json.Node{
"recipient": jsonutil.AddressOrNameNode(msg.Recipient),
"recipient": jsonutil.AddressNode(msg.Recipient),
"amount": jsonutil.Uint64Node(msg.Amount),
})
}
Expand All @@ -60,7 +61,7 @@ func NewMintToriHandler() *MintToriHandler {

func (h *MintToriHandler) Execute(imsg dao_interfaces.ExecutableMessage) {
msg := imsg.(*ExecutableMessageMintTori)
Mint(msg.Recipient, msg.Amount)
Mint(users.AddressOrName(msg.Recipient), msg.Amount)
}

func (h MintToriHandler) Type() string {
Expand All @@ -74,7 +75,7 @@ func (h *MintToriHandler) Instantiate() dao_interfaces.ExecutableMessage {
type ExecutableMessageBurnTori struct {
dao_interfaces.ExecutableMessage

Target users.AddressOrName
Target std.Address
Amount uint64
}

Expand All @@ -98,13 +99,13 @@ func (msg *ExecutableMessageBurnTori) String() string {

func (msg *ExecutableMessageBurnTori) FromJSON(ast *json.Node) {
obj := ast.MustObject()
msg.Target = jsonutil.MustAddressOrName(obj["target"])
msg.Target = jsonutil.MustAddress(obj["target"])
msg.Amount = jsonutil.MustUint64(obj["amount"])
}

func (msg *ExecutableMessageBurnTori) ToJSON() *json.Node {
return json.ObjectNode("", map[string]*json.Node{
"target": jsonutil.AddressOrNameNode(msg.Target),
"target": jsonutil.AddressNode(msg.Target),
"amount": jsonutil.Uint64Node(msg.Amount),
})
}
Expand All @@ -121,7 +122,7 @@ func NewBurnToriHandler() *BurnToriHandler {

func (h *BurnToriHandler) Execute(imsg dao_interfaces.ExecutableMessage) {
msg := imsg.(*ExecutableMessageBurnTori)
Burn(msg.Target, msg.Amount)
Burn(users.AddressOrName(msg.Target), msg.Amount)
}

func (h BurnToriHandler) Type() string {
Expand All @@ -135,7 +136,7 @@ func (h *BurnToriHandler) Instantiate() dao_interfaces.ExecutableMessage {
type ExecutableMessageChangeAdmin struct {
dao_interfaces.ExecutableMessage

NewAdmin users.AddressOrName
NewAdmin std.Address
}

var _ dao_interfaces.ExecutableMessage = &ExecutableMessageChangeAdmin{}
Expand All @@ -154,12 +155,12 @@ func (msg *ExecutableMessageChangeAdmin) String() string {

func (msg *ExecutableMessageChangeAdmin) FromJSON(ast *json.Node) {
obj := ast.MustObject()
msg.NewAdmin = jsonutil.MustAddressOrName(obj["newAdmin"])
msg.NewAdmin = jsonutil.MustAddress(obj["newAdmin"])
}

func (msg *ExecutableMessageChangeAdmin) ToJSON() *json.Node {
return json.ObjectNode("", map[string]*json.Node{
"newAdmin": jsonutil.AddressOrNameNode(msg.NewAdmin),
"newAdmin": jsonutil.AddressNode(msg.NewAdmin),
})
}

Expand All @@ -175,7 +176,7 @@ func NewChangeAdminHandler() *ChangeAdminHandler {

func (h *ChangeAdminHandler) Execute(imsg dao_interfaces.ExecutableMessage) {
msg := imsg.(*ExecutableMessageChangeAdmin)
ChangeAdmin(msg.NewAdmin)
ChangeAdmin(users.AddressOrName(msg.NewAdmin))
}

func (h ChangeAdminHandler) Type() string {
Expand Down

0 comments on commit 128c677

Please sign in to comment.