From bb9753f1b4e7850f58defb59fecdcae114399a64 Mon Sep 17 00:00:00 2001 From: Norman Meier Date: Tue, 19 Sep 2023 01:40:15 +0200 Subject: [PATCH] fix: make social feed and moderation work with latest dao packages Signed-off-by: Norman Meier --- examples/gno.land/p/demo/daodao/core/gno.mod | 7 - .../p/demo/daodao/proposal_single/gno.mod | 7 - .../p/demo/daodao/voting_group/gno.mod | 7 - .../{ => teritori}/daodao/core/dao_core.gno | 2 +- .../daodao/core/dao_core_test.gno | 2 +- .../{ => teritori}/daodao/core/errors.gno | 0 .../{ => teritori}/daodao/core/expiration.gno | 0 .../daodao/core/expiration_test.gno | 0 .../p/demo/teritori/daodao/core/gno.mod | 7 + .../{ => teritori}/daodao/core/messages.gno | 6 +- .../{ => teritori}/daodao/interfaces/core.gno | 0 .../{ => teritori}/daodao/interfaces/gno.mod | 2 +- .../daodao/interfaces/messages.gno | 0 .../daodao/interfaces/messages_registry.gno | 4 +- .../interfaces/messages_registry_test.gno | 0 .../daodao/interfaces/messages_testing.gno | 0 .../daodao/interfaces/modules.gno | 0 .../proposal_single/dao_proposal_single.gno | 2 +- .../teritori/daodao/proposal_single/gno.mod | 7 + .../daodao/proposal_single/proposal_test.gno | 2 +- .../daodao/proposal_single/threshold.gno | 0 .../daodao/proposal_single/types.gno | 2 +- .../proposal_single/update_settings.gno | 4 +- .../demo/teritori/daodao/voting_group/gno.mod | 7 + .../daodao/voting_group/voting_group.gno | 2 +- .../daodao/voting_group/voting_group_test.gno | 2 +- .../gno.land/r/demo/dao_realm/dao_realm.gno | 8 +- .../r/demo/dao_realm/dao_realm_test.gno | 10 +- examples/gno.land/r/demo/dao_realm/gno.mod | 8 +- examples/gno.land/r/demo/groups/gno.mod | 2 +- examples/gno.land/r/demo/groups/messages.gno | 2 +- examples/gno.land/r/demo/modboards/gno.mod | 2 +- .../gno.land/r/demo/modboards/messages.gno | 2 +- .../gno.land/r/demo/social_feeds/feed.gno | 12 ++ .../gno.land/r/demo/social_feeds/messages.gno | 12 +- .../gno.land/r/demo/social_feeds/post.gno | 12 ++ .../gno.land/r/demo/social_feeds_dao/gno.mod | 2 +- .../social_feeds_dao/social_feeds_dao.gno | 137 +++++++++--------- .../social_feeds_dao_test.gno | 43 ++++++ examples/gno.land/r/demo/tori/messages.gno | 2 +- 40 files changed, 204 insertions(+), 122 deletions(-) delete mode 100644 examples/gno.land/p/demo/daodao/core/gno.mod delete mode 100644 examples/gno.land/p/demo/daodao/proposal_single/gno.mod delete mode 100644 examples/gno.land/p/demo/daodao/voting_group/gno.mod rename examples/gno.land/p/demo/{ => teritori}/daodao/core/dao_core.gno (98%) rename examples/gno.land/p/demo/{ => teritori}/daodao/core/dao_core_test.gno (98%) rename examples/gno.land/p/demo/{ => teritori}/daodao/core/errors.gno (100%) rename examples/gno.land/p/demo/{ => teritori}/daodao/core/expiration.gno (100%) rename examples/gno.land/p/demo/{ => teritori}/daodao/core/expiration_test.gno (100%) create mode 100644 examples/gno.land/p/demo/teritori/daodao/core/gno.mod rename examples/gno.land/p/demo/{ => teritori}/daodao/core/messages.gno (92%) rename examples/gno.land/p/demo/{ => teritori}/daodao/interfaces/core.gno (100%) rename examples/gno.land/p/demo/{ => teritori}/daodao/interfaces/gno.mod (67%) rename examples/gno.land/p/demo/{ => teritori}/daodao/interfaces/messages.gno (100%) rename examples/gno.land/p/demo/{ => teritori}/daodao/interfaces/messages_registry.gno (96%) rename examples/gno.land/p/demo/{ => teritori}/daodao/interfaces/messages_registry_test.gno (100%) rename examples/gno.land/p/demo/{ => teritori}/daodao/interfaces/messages_testing.gno (100%) rename examples/gno.land/p/demo/{ => teritori}/daodao/interfaces/modules.gno (100%) rename examples/gno.land/p/demo/{ => teritori}/daodao/proposal_single/dao_proposal_single.gno (99%) create mode 100644 examples/gno.land/p/demo/teritori/daodao/proposal_single/gno.mod rename examples/gno.land/p/demo/{ => teritori}/daodao/proposal_single/proposal_test.gno (96%) rename examples/gno.land/p/demo/{ => teritori}/daodao/proposal_single/threshold.gno (100%) rename examples/gno.land/p/demo/{ => teritori}/daodao/proposal_single/types.gno (98%) rename examples/gno.land/p/demo/{ => teritori}/daodao/proposal_single/update_settings.gno (94%) create mode 100644 examples/gno.land/p/demo/teritori/daodao/voting_group/gno.mod rename examples/gno.land/p/demo/{ => teritori}/daodao/voting_group/voting_group.gno (94%) rename examples/gno.land/p/demo/{ => teritori}/daodao/voting_group/voting_group_test.gno (85%) create mode 100644 examples/gno.land/r/demo/social_feeds_dao/social_feeds_dao_test.gno diff --git a/examples/gno.land/p/demo/daodao/core/gno.mod b/examples/gno.land/p/demo/daodao/core/gno.mod deleted file mode 100644 index 245c217ce07b..000000000000 --- a/examples/gno.land/p/demo/daodao/core/gno.mod +++ /dev/null @@ -1,7 +0,0 @@ -module gno.land/p/demo/daodao/core - -require ( - "gno.land/p/demo/daodao/interfaces" v0.0.0-latest - "gno.land/p/demo/ujson" v0.0.0-latest - "gno.land/p/demo/markdown_utils" v0.0.0-latest -) \ No newline at end of file diff --git a/examples/gno.land/p/demo/daodao/proposal_single/gno.mod b/examples/gno.land/p/demo/daodao/proposal_single/gno.mod deleted file mode 100644 index a064d1595faf..000000000000 --- a/examples/gno.land/p/demo/daodao/proposal_single/gno.mod +++ /dev/null @@ -1,7 +0,0 @@ -module gno.land/p/demo/daodao/proposal_single - -require ( - "gno.land/p/demo/avl" v0.0.0-latest - "gno.land/p/demo/daodao/interfaces" v0.0.0-latest - "gno.land/p/demo/ujson" v0.0.0-latest -) \ No newline at end of file diff --git a/examples/gno.land/p/demo/daodao/voting_group/gno.mod b/examples/gno.land/p/demo/daodao/voting_group/gno.mod deleted file mode 100644 index c3525f6b8499..000000000000 --- a/examples/gno.land/p/demo/daodao/voting_group/gno.mod +++ /dev/null @@ -1,7 +0,0 @@ -module gno.land/p/demo/daodao/voting_group - -require ( - "gno.land/p/demo/daodao/interfaces" v0.0.0-latest - "gno.land/p/demo/markdown_utils" v0.0.0-latest - "gno.land/r/demo/groups" v0.0.0-latest -) \ No newline at end of file diff --git a/examples/gno.land/p/demo/daodao/core/dao_core.gno b/examples/gno.land/p/demo/teritori/daodao/core/dao_core.gno similarity index 98% rename from examples/gno.land/p/demo/daodao/core/dao_core.gno rename to examples/gno.land/p/demo/teritori/daodao/core/dao_core.gno index 8a8160cfc9cf..2cc23b4282b3 100644 --- a/examples/gno.land/p/demo/daodao/core/dao_core.gno +++ b/examples/gno.land/p/demo/teritori/daodao/core/dao_core.gno @@ -5,7 +5,7 @@ import ( "strings" "time" - dao_interfaces "gno.land/p/demo/daodao/interfaces" + dao_interfaces "gno.land/p/demo/teritori/daodao/interfaces" "gno.land/p/demo/markdown_utils" ) diff --git a/examples/gno.land/p/demo/daodao/core/dao_core_test.gno b/examples/gno.land/p/demo/teritori/daodao/core/dao_core_test.gno similarity index 98% rename from examples/gno.land/p/demo/daodao/core/dao_core_test.gno rename to examples/gno.land/p/demo/teritori/daodao/core/dao_core_test.gno index 7ca53b09180c..9a7fb17f20b0 100644 --- a/examples/gno.land/p/demo/daodao/core/dao_core_test.gno +++ b/examples/gno.land/p/demo/teritori/daodao/core/dao_core_test.gno @@ -4,7 +4,7 @@ import ( "std" "testing" - dao_interfaces "gno.land/p/demo/daodao/interfaces" + dao_interfaces "gno.land/p/demo/teritori/daodao/interfaces" ) type votingModule struct { diff --git a/examples/gno.land/p/demo/daodao/core/errors.gno b/examples/gno.land/p/demo/teritori/daodao/core/errors.gno similarity index 100% rename from examples/gno.land/p/demo/daodao/core/errors.gno rename to examples/gno.land/p/demo/teritori/daodao/core/errors.gno diff --git a/examples/gno.land/p/demo/daodao/core/expiration.gno b/examples/gno.land/p/demo/teritori/daodao/core/expiration.gno similarity index 100% rename from examples/gno.land/p/demo/daodao/core/expiration.gno rename to examples/gno.land/p/demo/teritori/daodao/core/expiration.gno diff --git a/examples/gno.land/p/demo/daodao/core/expiration_test.gno b/examples/gno.land/p/demo/teritori/daodao/core/expiration_test.gno similarity index 100% rename from examples/gno.land/p/demo/daodao/core/expiration_test.gno rename to examples/gno.land/p/demo/teritori/daodao/core/expiration_test.gno diff --git a/examples/gno.land/p/demo/teritori/daodao/core/gno.mod b/examples/gno.land/p/demo/teritori/daodao/core/gno.mod new file mode 100644 index 000000000000..2f9995689070 --- /dev/null +++ b/examples/gno.land/p/demo/teritori/daodao/core/gno.mod @@ -0,0 +1,7 @@ +module gno.land/p/demo/teritori/daodao/core + +require ( + "gno.land/p/demo/teritori/daodao/interfaces" v0.0.0-latest + "gno.land/p/demo/ujson" v0.0.0-latest + "gno.land/p/demo/markdown_utils" v0.0.0-latest +) \ No newline at end of file diff --git a/examples/gno.land/p/demo/daodao/core/messages.gno b/examples/gno.land/p/demo/teritori/daodao/core/messages.gno similarity index 92% rename from examples/gno.land/p/demo/daodao/core/messages.gno rename to examples/gno.land/p/demo/teritori/daodao/core/messages.gno index 14af900e0d20..cf3f63714888 100644 --- a/examples/gno.land/p/demo/daodao/core/messages.gno +++ b/examples/gno.land/p/demo/teritori/daodao/core/messages.gno @@ -1,7 +1,7 @@ package core import ( - dao_interfaces "gno.land/p/demo/daodao/interfaces" + dao_interfaces "gno.land/p/demo/teritori/daodao/interfaces" "gno.land/p/demo/ujson" ) @@ -13,7 +13,7 @@ type UpdateProposalModulesExecutableMessage struct { } func (msg *UpdateProposalModulesExecutableMessage) Type() string { - return "gno.land/p/demo/daodao/core.UpdateProposalModules" + return "gno.land/p/demo/teritori/daodao/core.UpdateProposalModules" } func (msg *UpdateProposalModulesExecutableMessage) String() string { @@ -56,7 +56,7 @@ type UpdateVotingModuleExecutableMessage struct { } func (msg *UpdateVotingModuleExecutableMessage) Type() string { - return "gno.land/p/demo/daodao/core.UpdateVotingModule" + return "gno.land/p/demo/teritori/daodao/core.UpdateVotingModule" } func (msg *UpdateVotingModuleExecutableMessage) String() string { diff --git a/examples/gno.land/p/demo/daodao/interfaces/core.gno b/examples/gno.land/p/demo/teritori/daodao/interfaces/core.gno similarity index 100% rename from examples/gno.land/p/demo/daodao/interfaces/core.gno rename to examples/gno.land/p/demo/teritori/daodao/interfaces/core.gno diff --git a/examples/gno.land/p/demo/daodao/interfaces/gno.mod b/examples/gno.land/p/demo/teritori/daodao/interfaces/gno.mod similarity index 67% rename from examples/gno.land/p/demo/daodao/interfaces/gno.mod rename to examples/gno.land/p/demo/teritori/daodao/interfaces/gno.mod index 034cffbd413c..68f6e1747183 100644 --- a/examples/gno.land/p/demo/daodao/interfaces/gno.mod +++ b/examples/gno.land/p/demo/teritori/daodao/interfaces/gno.mod @@ -1,4 +1,4 @@ -module gno.land/p/demo/daodao/interfaces +module gno.land/p/demo/teritori/daodao/interfaces require ( "gno.land/p/demo/ujson" v0.0.0-latest diff --git a/examples/gno.land/p/demo/daodao/interfaces/messages.gno b/examples/gno.land/p/demo/teritori/daodao/interfaces/messages.gno similarity index 100% rename from examples/gno.land/p/demo/daodao/interfaces/messages.gno rename to examples/gno.land/p/demo/teritori/daodao/interfaces/messages.gno diff --git a/examples/gno.land/p/demo/daodao/interfaces/messages_registry.gno b/examples/gno.land/p/demo/teritori/daodao/interfaces/messages_registry.gno similarity index 96% rename from examples/gno.land/p/demo/daodao/interfaces/messages_registry.gno rename to examples/gno.land/p/demo/teritori/daodao/interfaces/messages_registry.gno index 62ece26b3efe..c7764e234f41 100644 --- a/examples/gno.land/p/demo/daodao/interfaces/messages_registry.gno +++ b/examples/gno.land/p/demo/teritori/daodao/interfaces/messages_registry.gno @@ -65,7 +65,7 @@ type RegisterHandlerExecutableMessage struct { } func (m *RegisterHandlerExecutableMessage) Type() string { - return "gno.land/p/demo/daodao/interfaces.RegisterHandler" + return "gno.land/p/demo/teritori/daodao/interfaces.RegisterHandler" } func (m *RegisterHandlerExecutableMessage) FromJSON(ast *ujson.JSONASTNode) { @@ -105,7 +105,7 @@ type RemoveHandlerExecutableMessage struct { } func (m *RemoveHandlerExecutableMessage) Type() string { - return "gno.land/p/demo/daodao/interfaces.RemoveHandler" + return "gno.land/p/demo/teritori/daodao/interfaces.RemoveHandler" } func (m *RemoveHandlerExecutableMessage) FromJSON(ast *ujson.JSONASTNode) { diff --git a/examples/gno.land/p/demo/daodao/interfaces/messages_registry_test.gno b/examples/gno.land/p/demo/teritori/daodao/interfaces/messages_registry_test.gno similarity index 100% rename from examples/gno.land/p/demo/daodao/interfaces/messages_registry_test.gno rename to examples/gno.land/p/demo/teritori/daodao/interfaces/messages_registry_test.gno diff --git a/examples/gno.land/p/demo/daodao/interfaces/messages_testing.gno b/examples/gno.land/p/demo/teritori/daodao/interfaces/messages_testing.gno similarity index 100% rename from examples/gno.land/p/demo/daodao/interfaces/messages_testing.gno rename to examples/gno.land/p/demo/teritori/daodao/interfaces/messages_testing.gno diff --git a/examples/gno.land/p/demo/daodao/interfaces/modules.gno b/examples/gno.land/p/demo/teritori/daodao/interfaces/modules.gno similarity index 100% rename from examples/gno.land/p/demo/daodao/interfaces/modules.gno rename to examples/gno.land/p/demo/teritori/daodao/interfaces/modules.gno diff --git a/examples/gno.land/p/demo/daodao/proposal_single/dao_proposal_single.gno b/examples/gno.land/p/demo/teritori/daodao/proposal_single/dao_proposal_single.gno similarity index 99% rename from examples/gno.land/p/demo/daodao/proposal_single/dao_proposal_single.gno rename to examples/gno.land/p/demo/teritori/daodao/proposal_single/dao_proposal_single.gno index 81d1dad9ef6d..0a0df3e904f2 100644 --- a/examples/gno.land/p/demo/daodao/proposal_single/dao_proposal_single.gno +++ b/examples/gno.land/p/demo/teritori/daodao/proposal_single/dao_proposal_single.gno @@ -6,7 +6,7 @@ import ( "time" "gno.land/p/demo/avl" - dao_interfaces "gno.land/p/demo/daodao/interfaces" + dao_interfaces "gno.land/p/demo/teritori/daodao/interfaces" "gno.land/p/demo/ujson" ) diff --git a/examples/gno.land/p/demo/teritori/daodao/proposal_single/gno.mod b/examples/gno.land/p/demo/teritori/daodao/proposal_single/gno.mod new file mode 100644 index 000000000000..070afcdbae2d --- /dev/null +++ b/examples/gno.land/p/demo/teritori/daodao/proposal_single/gno.mod @@ -0,0 +1,7 @@ +module gno.land/p/demo/teritori/daodao/proposal_single + +require ( + "gno.land/p/demo/avl" v0.0.0-latest + "gno.land/p/demo/teritori/daodao/interfaces" v0.0.0-latest + "gno.land/p/demo/ujson" v0.0.0-latest +) \ No newline at end of file diff --git a/examples/gno.land/p/demo/daodao/proposal_single/proposal_test.gno b/examples/gno.land/p/demo/teritori/daodao/proposal_single/proposal_test.gno similarity index 96% rename from examples/gno.land/p/demo/daodao/proposal_single/proposal_test.gno rename to examples/gno.land/p/demo/teritori/daodao/proposal_single/proposal_test.gno index 4cca0efe63d0..25646b93c7c0 100644 --- a/examples/gno.land/p/demo/daodao/proposal_single/proposal_test.gno +++ b/examples/gno.land/p/demo/teritori/daodao/proposal_single/proposal_test.gno @@ -4,7 +4,7 @@ import ( "testing" "gno.land/p/demo/avl" - dao_interfaces "gno.land/p/demo/daodao/interfaces" + dao_interfaces "gno.land/p/demo/teritori/daodao/interfaces" "gno.land/p/demo/ujson" ) diff --git a/examples/gno.land/p/demo/daodao/proposal_single/threshold.gno b/examples/gno.land/p/demo/teritori/daodao/proposal_single/threshold.gno similarity index 100% rename from examples/gno.land/p/demo/daodao/proposal_single/threshold.gno rename to examples/gno.land/p/demo/teritori/daodao/proposal_single/threshold.gno diff --git a/examples/gno.land/p/demo/daodao/proposal_single/types.gno b/examples/gno.land/p/demo/teritori/daodao/proposal_single/types.gno similarity index 98% rename from examples/gno.land/p/demo/daodao/proposal_single/types.gno rename to examples/gno.land/p/demo/teritori/daodao/proposal_single/types.gno index b8460b89fce7..7af199e44281 100644 --- a/examples/gno.land/p/demo/daodao/proposal_single/types.gno +++ b/examples/gno.land/p/demo/teritori/daodao/proposal_single/types.gno @@ -5,7 +5,7 @@ import ( "strconv" "gno.land/p/demo/avl" - dao_interfaces "gno.land/p/demo/daodao/interfaces" + dao_interfaces "gno.land/p/demo/teritori/daodao/interfaces" "gno.land/p/demo/ujson" ) diff --git a/examples/gno.land/p/demo/daodao/proposal_single/update_settings.gno b/examples/gno.land/p/demo/teritori/daodao/proposal_single/update_settings.gno similarity index 94% rename from examples/gno.land/p/demo/daodao/proposal_single/update_settings.gno rename to examples/gno.land/p/demo/teritori/daodao/proposal_single/update_settings.gno index b6236d18f2b1..9b99a3d48e57 100644 --- a/examples/gno.land/p/demo/daodao/proposal_single/update_settings.gno +++ b/examples/gno.land/p/demo/teritori/daodao/proposal_single/update_settings.gno @@ -5,7 +5,7 @@ import ( "std" "strings" - "gno.land/p/demo/daodao/interfaces" + "gno.land/p/demo/teritori/daodao/interfaces" "gno.land/p/demo/ujson" ) @@ -18,7 +18,7 @@ type UpdateSettingsMessage struct { } func (usm *UpdateSettingsMessage) Type() string { - return "gno.land/p/demo/daodao/proposal_single.UpdateSettings" + return "gno.land/p/demo/teritori/daodao/proposal_single.UpdateSettings" } func (usm *UpdateSettingsMessage) String() string { diff --git a/examples/gno.land/p/demo/teritori/daodao/voting_group/gno.mod b/examples/gno.land/p/demo/teritori/daodao/voting_group/gno.mod new file mode 100644 index 000000000000..3ffe7e4565fb --- /dev/null +++ b/examples/gno.land/p/demo/teritori/daodao/voting_group/gno.mod @@ -0,0 +1,7 @@ +module gno.land/p/demo/teritori/daodao/voting_group + +require ( + "gno.land/p/demo/teritori/daodao/interfaces" v0.0.0-latest + "gno.land/p/demo/markdown_utils" v0.0.0-latest + "gno.land/r/demo/groups" v0.0.0-latest +) \ No newline at end of file diff --git a/examples/gno.land/p/demo/daodao/voting_group/voting_group.gno b/examples/gno.land/p/demo/teritori/daodao/voting_group/voting_group.gno similarity index 94% rename from examples/gno.land/p/demo/daodao/voting_group/voting_group.gno rename to examples/gno.land/p/demo/teritori/daodao/voting_group/voting_group.gno index 5b8050b01556..2f651bf0e7da 100644 --- a/examples/gno.land/p/demo/daodao/voting_group/voting_group.gno +++ b/examples/gno.land/p/demo/teritori/daodao/voting_group/voting_group.gno @@ -3,7 +3,7 @@ package dao_voting_group import ( "std" - dao_interfaces "gno.land/p/demo/daodao/interfaces" + dao_interfaces "gno.land/p/demo/teritori/daodao/interfaces" "gno.land/p/demo/markdown_utils" "gno.land/r/demo/groups" ) diff --git a/examples/gno.land/p/demo/daodao/voting_group/voting_group_test.gno b/examples/gno.land/p/demo/teritori/daodao/voting_group/voting_group_test.gno similarity index 85% rename from examples/gno.land/p/demo/daodao/voting_group/voting_group_test.gno rename to examples/gno.land/p/demo/teritori/daodao/voting_group/voting_group_test.gno index 910cf77a2683..8d308a1eb680 100644 --- a/examples/gno.land/p/demo/daodao/voting_group/voting_group_test.gno +++ b/examples/gno.land/p/demo/teritori/daodao/voting_group/voting_group_test.gno @@ -4,7 +4,7 @@ import ( "std" "testing" - dao_interfaces "gno.land/p/demo/daodao/interfaces" + dao_interfaces "gno.land/p/demo/teritori/daodao/interfaces" "gno.land/r/demo/groups" ) diff --git a/examples/gno.land/r/demo/dao_realm/dao_realm.gno b/examples/gno.land/r/demo/dao_realm/dao_realm.gno index 3ec3d40cc04b..5e41c00e8bd2 100644 --- a/examples/gno.land/r/demo/dao_realm/dao_realm.gno +++ b/examples/gno.land/r/demo/dao_realm/dao_realm.gno @@ -6,10 +6,10 @@ import ( "strings" "time" - dao_core "gno.land/p/demo/daodao/core" - dao_interfaces "gno.land/p/demo/daodao/interfaces" - proposal_single "gno.land/p/demo/daodao/proposal_single" - voting_group "gno.land/p/demo/daodao/voting_group" + dao_core "gno.land/p/demo/teritori/daodao/core" + dao_interfaces "gno.land/p/demo/teritori/daodao/interfaces" + proposal_single "gno.land/p/demo/teritori/daodao/proposal_single" + voting_group "gno.land/p/demo/teritori/daodao/voting_group" "gno.land/p/demo/ujson" registry "gno.land/r/demo/dao_registry" "gno.land/r/demo/groups" diff --git a/examples/gno.land/r/demo/dao_realm/dao_realm_test.gno b/examples/gno.land/r/demo/dao_realm/dao_realm_test.gno index b94933bdb9ce..60cc24b2a96a 100644 --- a/examples/gno.land/r/demo/dao_realm/dao_realm_test.gno +++ b/examples/gno.land/r/demo/dao_realm/dao_realm_test.gno @@ -5,9 +5,9 @@ import ( "std" "testing" - dao_core "gno.land/p/demo/daodao/core" - dao_interfaces "gno.land/p/demo/daodao/interfaces" - proposal_single "gno.land/p/demo/daodao/proposal_single" + dao_core "gno.land/p/demo/teritori/daodao/core" + dao_interfaces "gno.land/p/demo/teritori/daodao/interfaces" + proposal_single "gno.land/p/demo/teritori/daodao/proposal_single" "gno.land/p/demo/ujson" "gno.land/r/demo/groups" modboards "gno.land/r/demo/modboards" @@ -118,11 +118,11 @@ Offensive stuff func TestUpdateSettings(t *testing.T) { // why is state preversed between tests?? { - id := ProposeJSON(0, fmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": [{"type": "gno.land/p/demo/daodao/proposal_single.UpdateSettings", "payload": {"threshold": {"thresholdQuorum": {"threshold": {"percent": 200}, "quorum": {"percent": 200}}}}}]}`)) + id := ProposeJSON(0, fmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": [{"type": "gno.land/p/demo/teritori/daodao/proposal_single.UpdateSettings", "payload": {"threshold": {"thresholdQuorum": {"threshold": {"percent": 200}, "quorum": {"percent": 200}}}}}]}`)) VoteJSON(0, id, fmt.Sprintf(`{"vote": %d, "rationale": "%s"}`, proposal_single.VoteYes, "testing")) Execute(0, id) proposalJSON := getProposalJSON(0, id) - expected := `{"id":3,"title":"Test prop","description":"A description","proposer":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","startHeight":123,"threshold":{"thresholdQuorum":{"threshold":{"percent":100},"quorum":{"percent":100}}},"totalPower":5,"messages":[{"type":"gno.land/p/demo/daodao/proposal_single.UpdateSettings","payload":{"threshold":{"thresholdQuorum":{"threshold":{"percent":200},"quorum":{"percent":200}}}}}],"status":"Executed","votes":{"yes":1,"no":0,"abstain":0},"allowRevoting":false,"ballots":{"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm":{"power":1,"vote":"Yes","rationale":"testing"}}}` + expected := `{"id":3,"title":"Test prop","description":"A description","proposer":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","startHeight":123,"threshold":{"thresholdQuorum":{"threshold":{"percent":100},"quorum":{"percent":100}}},"totalPower":5,"messages":[{"type":"gno.land/p/demo/teritori/daodao/proposal_single.UpdateSettings","payload":{"threshold":{"thresholdQuorum":{"threshold":{"percent":200},"quorum":{"percent":200}}}}}],"status":"Executed","votes":{"yes":1,"no":0,"abstain":0},"allowRevoting":false,"ballots":{"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm":{"power":1,"vote":"Yes","rationale":"testing"}}}` if proposalJSON != expected { t.Fatalf("Expected:\n%s\nGot:\n%s", expected, proposalJSON) } diff --git a/examples/gno.land/r/demo/dao_realm/gno.mod b/examples/gno.land/r/demo/dao_realm/gno.mod index 62edf1a2f685..1b244b6e901b 100644 --- a/examples/gno.land/r/demo/dao_realm/gno.mod +++ b/examples/gno.land/r/demo/dao_realm/gno.mod @@ -1,10 +1,10 @@ module gno.land/r/demo/dao_realm require ( - "gno.land/p/demo/daodao/core" v0.0.0-latest - "gno.land/p/demo/daodao/interfaces" v0.0.0-latest - "gno.land/p/demo/daodao/proposal_single" v0.0.0-latest - "gno.land/p/demo/daodao/voting_group" v0.0.0-latest + "gno.land/p/demo/teritori/daodao/core" v0.0.0-latest + "gno.land/p/demo/teritori/daodao/interfaces" v0.0.0-latest + "gno.land/p/demo/teritori/daodao/proposal_single" v0.0.0-latest + "gno.land/p/demo/teritori/daodao/voting_group" v0.0.0-latest "gno.land/r/demo/groups" v0.0.0-latest "gno.land/r/demo/modboards" v0.0.0-latest "gno.land/r/demo/tori" v0.0.0-latest diff --git a/examples/gno.land/r/demo/groups/gno.mod b/examples/gno.land/r/demo/groups/gno.mod index 32da50ae9426..a97dda2b365b 100644 --- a/examples/gno.land/r/demo/groups/gno.mod +++ b/examples/gno.land/r/demo/groups/gno.mod @@ -5,6 +5,6 @@ require ( "gno.land/p/demo/havl" v0.0.0-latest "gno.land/r/demo/users" v0.0.0-latest "gno.land/p/demo/ujson" v0.0.0-latest - "gno.land/p/demo/daodao/interfaces" v0.0.0-latest + "gno.land/p/demo/teritori/daodao/interfaces" v0.0.0-latest "gno.land/r/demo/modboards" v0.0.0-latest ) diff --git a/examples/gno.land/r/demo/groups/messages.gno b/examples/gno.land/r/demo/groups/messages.gno index 6b8336a179b1..ccd242b24afc 100644 --- a/examples/gno.land/r/demo/groups/messages.gno +++ b/examples/gno.land/r/demo/groups/messages.gno @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "gno.land/p/demo/daodao/interfaces" + "gno.land/p/demo/teritori/daodao/interfaces" "gno.land/p/demo/ujson" ) diff --git a/examples/gno.land/r/demo/modboards/gno.mod b/examples/gno.land/r/demo/modboards/gno.mod index ec17304bf75e..fda4640dc92b 100644 --- a/examples/gno.land/r/demo/modboards/gno.mod +++ b/examples/gno.land/r/demo/modboards/gno.mod @@ -3,7 +3,7 @@ module gno.land/r/demo/modboards require ( "gno.land/p/demo/avl" v0.0.0-latest "gno.land/r/demo/users" v0.0.0-latest - "gno.land/p/demo/daodao/interfaces" v0.0.0-latest + "gno.land/p/demo/teritori/daodao/interfaces" v0.0.0-latest "gno.land/p/demo/ujson" v0.0.0-latest "gno.land/p/demo/flags_index" v0.0.0-latest ) diff --git a/examples/gno.land/r/demo/modboards/messages.gno b/examples/gno.land/r/demo/modboards/messages.gno index 9565ebc9c7f2..b3e34809bedf 100644 --- a/examples/gno.land/r/demo/modboards/messages.gno +++ b/examples/gno.land/r/demo/modboards/messages.gno @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "gno.land/p/demo/daodao/interfaces" + "gno.land/p/demo/teritori/daodao/interfaces" "gno.land/p/demo/ujson" ) diff --git a/examples/gno.land/r/demo/social_feeds/feed.gno b/examples/gno.land/r/demo/social_feeds/feed.gno index afb93f8b0c2e..d74e249852e9 100644 --- a/examples/gno.land/r/demo/social_feeds/feed.gno +++ b/examples/gno.land/r/demo/social_feeds/feed.gno @@ -18,6 +18,18 @@ func (fid FeedID) String() string { return strconv.Itoa(int(fid)) } +func (fid *FeedID) FromJSON(ast *ujson.JSONASTNode) { + val, err := strconv.Atoi(ast.Value) + if err != nil { + panic(err) + } + *fid = FeedID(val) +} + +func (fid FeedID) ToJSON() string { + return strconv.Itoa(int(fid)) +} + type Feed struct { id FeedID url string diff --git a/examples/gno.land/r/demo/social_feeds/messages.gno b/examples/gno.land/r/demo/social_feeds/messages.gno index dfaf5fc851a9..db7fd8634ada 100644 --- a/examples/gno.land/r/demo/social_feeds/messages.gno +++ b/examples/gno.land/r/demo/social_feeds/messages.gno @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "gno.land/p/demo/daodao/interfaces" + "gno.land/p/demo/teritori/daodao/interfaces" "gno.land/p/demo/ujson" ) @@ -22,7 +22,15 @@ type ExecutableMessageBanPost struct { } func (msg *ExecutableMessageBanPost) Type() string { - return "BanPost" + return "gno.land/r/demo/social_feeds.BanPost" +} + +func (msg *ExecutableMessageBanPost) ToJSON() string { + return ujson.FormatObject([]ujson.FormatKV{ + {Key: "feedId", Value: msg.FeedID}, + {Key: "postId", Value: msg.PostID}, + {Key: "reason", Value: msg.Reason}, + }) } func (msg *ExecutableMessageBanPost) String() string { diff --git a/examples/gno.land/r/demo/social_feeds/post.gno b/examples/gno.land/r/demo/social_feeds/post.gno index ce840618c792..1bd644f0a39d 100644 --- a/examples/gno.land/r/demo/social_feeds/post.gno +++ b/examples/gno.land/r/demo/social_feeds/post.gno @@ -19,6 +19,18 @@ func (pid PostID) String() string { return strconv.Itoa(int(pid)) } +func (pid *PostID) FromJSON(ast *ujson.JSONASTNode) { + val, err := strconv.Atoi(ast.Value) + if err != nil { + panic(err) + } + *pid = PostID(val) +} + +func (pid PostID) ToJSON() string { + return strconv.Itoa(int(pid)) +} + type Reaction struct { icon string count uint64 diff --git a/examples/gno.land/r/demo/social_feeds_dao/gno.mod b/examples/gno.land/r/demo/social_feeds_dao/gno.mod index 76afe2c30e9e..b7a72c28fe6e 100644 --- a/examples/gno.land/r/demo/social_feeds_dao/gno.mod +++ b/examples/gno.land/r/demo/social_feeds_dao/gno.mod @@ -2,5 +2,5 @@ module gno.land/r/demo/social_feeds_dao require ( "gno.land/r/demo/social_feeds" v0.0.0-latest - "gno.land/r/demo/groups_v9" v0.0.0-latest + "gno.land/r/demo/groups" v0.0.0-latest ) diff --git a/examples/gno.land/r/demo/social_feeds_dao/social_feeds_dao.gno b/examples/gno.land/r/demo/social_feeds_dao/social_feeds_dao.gno index 8a3120b1d77f..2d73001b8b2a 100644 --- a/examples/gno.land/r/demo/social_feeds_dao/social_feeds_dao.gno +++ b/examples/gno.land/r/demo/social_feeds_dao/social_feeds_dao.gno @@ -6,99 +6,106 @@ import ( "strings" "time" - dao_core "gno.land/p/demo/daodao/core_v6" - dao_interfaces "gno.land/p/demo/daodao/interfaces" - "gno.land/p/demo/daodao/proposal_single_v7" - "gno.land/p/demo/daodao/voting_group_v8" + dao_core "gno.land/p/demo/teritori/daodao/core" + dao_interfaces "gno.land/p/demo/teritori/daodao/interfaces" + "gno.land/p/demo/teritori/daodao/proposal_single" + "gno.land/p/demo/teritori/daodao/voting_group" "gno.land/p/demo/ujson" - "gno.land/r/demo/dao_registry_v5" - "gno.land/r/demo/groups_v9" + "gno.land/r/demo/dao_registry" + "gno.land/r/demo/groups" social_feeds "gno.land/r/demo/social_feeds" ) var ( - daoCore dao_core.IDAOCore - registry = dao_interfaces.NewMessagesRegistry() - mainFeedName = "teritori9" + daoCore dao_interfaces.IDAOCore + mainFeedName = "teritori" + groupName = "social_feeds_dao_voting_group" groupID groups.GroupID + feedID social_feeds.FeedID ) func init() { - // NOTE: why creator is: g16lcthjkpr9emfj2yemnsfmyc563jw98p4wwvgg ?????? - groupID = groups.CreateGroup(mainFeedName) + feedID = social_feeds.CreateFeed(mainFeedName) - // Create Feed - currentRealm := std.CurrentRealm() - feedID := social_feeds.CreateFeed(mainFeedName) - - // For testing purpose we add 2 users - groups.AddMember(groupID, "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5", 1, "") - - registry.Register(groups.NewAddMemberHandler()) - registry.Register(groups.NewDeleteMemberHandler()) + votingModuleFactory := func(core dao_interfaces.IDAOCore) dao_interfaces.IVotingModule { + groupID = groups.CreateGroup(groupName) + groups.AddMember(groupID, "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5", 1, "") + groups.AddMember(groupID, "g108cszmcvs4r3k67k7h5zuhm4el3qhlrxzhshtv", 1, "") + return dao_voting_group.NewVotingGroup(groupID) + } - daoCore = dao_core.NewDAOCore(dao_voting_group.NewGRC4Voting(groupID), nil) + proposalModulesFactories := []dao_interfaces.ProposalModuleFactory{ + func(core dao_interfaces.IDAOCore) dao_interfaces.IProposalModule { + tt := dao_proposal_single.PercentageThresholdPercent(1500) + tq := dao_proposal_single.PercentageThresholdPercent(5000) + return dao_proposal_single.NewDAOProposalSingle(core, &dao_proposal_single.DAOProposalSingleOpts{ + MaxVotingPeriod: time.Second * 86400, + Threshold: &dao_proposal_single.ThresholdThresholdQuorum{ + Threshold: &tt, // 15% + Quorum: &tq, // 50% + }, + }) + }, + } - tt := dao_interfaces.Percent(1500) // 15% - tq := dao_interfaces.Percent(5000) // 50% - proposalMod := dao_proposal_single.NewDAOProposalSingle(daoCore, &dao_proposal_single.DAOProposalSingleOpts{ - MaxVotingPeriod: time.Second * 86400, - Threshold: dao_interfaces.Threshold{ThresholdQuorum: &dao_interfaces.ThresholdQuorum{ - Threshold: dao_interfaces.PercentageThreshold{Percent: &tt}, - Quorum: dao_interfaces.PercentageThreshold{Percent: &tq}, - }}, - Registry: registry, - }) - // TODO: add a router to support multiple proposal modules - registry.Register(dao_proposal_single.NewUpdateSettingsHandler(proposalMod)) - daoCore.AddProposalModule(proposalMod) + messagesHandlersFactories := []dao_interfaces.MessageHandlerFactory{ + func(core dao_interfaces.IDAOCore) dao_interfaces.MessageHandler { + return social_feeds.NewBanPostHandler() + }, + func(core dao_interfaces.IDAOCore) dao_interfaces.MessageHandler { + return dao_proposal_single.NewUpdateSettingsHandler(core.ProposalModules()[0].Module.(*dao_proposal_single.DAOProposalSingle)) + }, + func(core dao_interfaces.IDAOCore) dao_interfaces.MessageHandler { + return groups.NewAddMemberHandler() + }, + func(core dao_interfaces.IDAOCore) dao_interfaces.MessageHandler { + return groups.NewDeleteMemberHandler() + }, + } - registry.Register(social_feeds.NewBanPostHandler()) - dao_registry.Register("social_feeds_dao", "Teritori Feed DAO", "https://avatars.githubusercontent.com/u/108656591?s=200&v=4") + daoCore = dao_core.NewDAOCore(votingModuleFactory, proposalModulesFactories, messagesHandlersFactories) + dao_registry.Register("Social Feed Moderation", "DAO responsible for Teritori social feed moderation", "ipfs://bafkreieqcwmjcb64r42ygs6a4dswz63djzgayjn3rhzjber3e42cknawlm") } func Render(path string) string { return "[[feed](/r/demo/social_feeds:" + mainFeedName + ")]\n\n" + daoCore.Render(path) } -func GetCore() dao_core.IDAOCore { - return daoCore -} - -func Vote(moduleIndex int, proposalID int, vote dao_interfaces.Vote, rationale string) { - dao_core.GetProposalModule(daoCore, moduleIndex).Vote(proposalID, vote, rationale) +func VoteJSON(moduleIndex int, proposalID int, voteJSON string) { + // move check in dao core + module := dao_core.GetProposalModule(daoCore, moduleIndex) + if !module.Enabled { + panic("proposal module is not enabled") + } + module.Module.VoteJSON(proposalID, voteJSON) } func Execute(moduleIndex int, proposalID int) { - dao_core.GetProposalModule(daoCore, moduleIndex).Execute(proposalID) -} - -func Propose(moduleIndex int, title string, description string, b64Messages string) { - mod := dao_core.GetProposalModule(daoCore, moduleIndex) - var messages []dao_interfaces.ExecutableMessage - if len(b64Messages) != 0 { - rawMessages := strings.Split(b64Messages, ",") - for _, rawMessage := range rawMessages { - message := registry.FromBase64String(rawMessage) - messages = append(messages, message) - } + // move check in dao core + module := dao_core.GetProposalModule(daoCore, moduleIndex) + if !module.Enabled { + panic("proposal module is not enabled") } - mod.Propose(title, description, messages) + module.Module.Execute(proposalID) } -func GetBinaryMembers() string { - members := groups.GetMembers(groupID) - ss := []string{} - for _, member := range members { - ss = append(ss, base64.RawURLEncoding.EncodeToString(member.Bytes())) +func ProposeJSON(moduleIndex int, proposalJSON string) int { + // move check in dao core + module := dao_core.GetProposalModule(daoCore, moduleIndex) + if !module.Enabled { + panic("proposal module is not enabled") } - return strings.Join(ss, ",") + return module.Module.ProposeJSON(proposalJSON) } -func GetProposalsJSON(moduleIndex int) string { - return ujson.FormatSlice(dao_core.GetProposalModule(daoCore, moduleIndex).Proposals()) +func getProposalsJSON(moduleIndex int, limit int, startAfter string, reverse bool) string { + // move logic in dao core + module := dao_core.GetProposalModule(daoCore, moduleIndex) + return module.Module.ProposalsJSON(limit, startAfter, reverse) } -func GetGroupID() uint64 { - return uint64(groupID) +func getProposalJSON(moduleIndex int, proposalIndex int) string { + // move logic in dao core + module := dao_core.GetProposalModule(daoCore, moduleIndex) + return module.Module.ProposalJSON(proposalIndex) } diff --git a/examples/gno.land/r/demo/social_feeds_dao/social_feeds_dao_test.gno b/examples/gno.land/r/demo/social_feeds_dao/social_feeds_dao_test.gno new file mode 100644 index 000000000000..889955e7711a --- /dev/null +++ b/examples/gno.land/r/demo/social_feeds_dao/social_feeds_dao_test.gno @@ -0,0 +1,43 @@ +package social_feeds_dao + +import ( + "fmt" + "std" + "testing" + + proposal_single "gno.land/p/demo/teritori/daodao/proposal_single" + social_feeds "gno.land/r/demo/social_feeds" +) + +func TestSocialFeedsDAO(t *testing.T) { + std.TestSetOrigCaller("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") + + // create a post + postID := social_feeds.CreatePost(feedID, social_feeds.PostID(0), 0, "Hello, world!") + _ = social_feeds.GetPost(feedID, postID) + + // ban the post + proposalID := ProposeJSON(0, fmt.Sprintf(`{"title": "Ban post", "description": "", "messages": [{"type":"gno.land/r/demo/social_feeds.BanPost","payload":{"feedId":%d,"postId":%d,"reason":"spam"}}]}`, feedID, postID)) + VoteJSON(0, proposalID, fmt.Sprintf(`{"vote": %d, "rationale": "%s"}`, proposal_single.VoteYes, "testing")) + Execute(0, proposalID) + + // check that the post is deleted + func() { + defer func() { + r := recover() + expected := "Unable to get post" + if r == nil { + t.Errorf("Expected panic while getting post after ban") + } else if r != expected { + t.Errorf("Expected panic with message '%s', got '%s'", expected, r) + } + }() + _ = social_feeds.GetPost(feedID, postID) + }() + + // check that the proposal has the correct shape + expected := `{"id":0,"title":"Ban post","description":"","proposer":"g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5","startHeight":123,"threshold":{"thresholdQuorum":{"threshold":{"percent":1500},"quorum":{"percent":5000}}},"totalPower":2,"messages":[{"type":"gno.land/r/demo/social_feeds.BanPost","payload":{"feedId":1,"postId":1,"reason":"spam"}}],"status":"Executed","votes":{"yes":1,"no":0,"abstain":0},"allowRevoting":false,"ballots":{"g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5":{"power":1,"vote":"Yes","rationale":"testing"}}}` + if proposal := getProposalJSON(0, proposalID); proposal != expected { + t.Errorf("Expected proposal to be:\n%s\nGot:\n%s", expected, proposal) + } +} diff --git a/examples/gno.land/r/demo/tori/messages.gno b/examples/gno.land/r/demo/tori/messages.gno index 81677f8ca01c..217f8f150930 100644 --- a/examples/gno.land/r/demo/tori/messages.gno +++ b/examples/gno.land/r/demo/tori/messages.gno @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "gno.land/p/demo/daodao/interfaces" + "gno.land/p/demo/teritori/daodao/interfaces" "gno.land/p/demo/ujson" "gno.land/r/demo/users" )