From 128c6773a1d206ca2b32e8d7e004245c7f064bb2 Mon Sep 17 00:00:00 2001 From: Norman Meier Date: Fri, 6 Dec 2024 12:47:56 +0100 Subject: [PATCH] tmp Signed-off-by: Norman Meier --- gno/Makefile | 6 +++--- gno/p/jsonutil/jsonutil.gno | 16 ---------------- gno/r/tori/messages.gno | 25 +++++++++++++------------ 3 files changed, 16 insertions(+), 31 deletions(-) diff --git a/gno/Makefile b/gno/Makefile index b5b29d6e4c..ad66035ca6 100644 --- a/gno/Makefile +++ b/gno/Makefile @@ -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 diff --git a/gno/p/jsonutil/jsonutil.gno b/gno/p/jsonutil/jsonutil.gno index 34af5de049..04d08d5c0b 100644 --- a/gno/p/jsonutil/jsonutil.gno +++ b/gno/p/jsonutil/jsonutil.gno @@ -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 { @@ -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 -} diff --git a/gno/r/tori/messages.gno b/gno/r/tori/messages.gno index a583af5517..d8f0b873e2 100644 --- a/gno/r/tori/messages.gno +++ b/gno/r/tori/messages.gno @@ -1,6 +1,7 @@ package tori import ( + "std" "strconv" "strings" @@ -13,7 +14,7 @@ import ( type ExecutableMessageMintTori struct { dao_interfaces.ExecutableMessage - Recipient users.AddressOrName + Recipient std.Address Amount uint64 } @@ -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), }) } @@ -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 { @@ -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 } @@ -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), }) } @@ -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 { @@ -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{} @@ -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), }) } @@ -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 {