Skip to content

Commit

Permalink
fix: make social feed and moderation work with latest dao packages
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <norman@berty.tech>
  • Loading branch information
n0izn0iz committed Sep 19, 2023
1 parent 1eea98f commit bb9753f
Show file tree
Hide file tree
Showing 40 changed files with 204 additions and 122 deletions.
7 changes: 0 additions & 7 deletions examples/gno.land/p/demo/daodao/core/gno.mod

This file was deleted.

7 changes: 0 additions & 7 deletions examples/gno.land/p/demo/daodao/proposal_single/gno.mod

This file was deleted.

7 changes: 0 additions & 7 deletions examples/gno.land/p/demo/daodao/voting_group/gno.mod

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions examples/gno.land/p/demo/teritori/daodao/core/gno.mod
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
@@ -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"
)

Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions examples/gno.land/p/demo/teritori/daodao/voting_group/gno.mod
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
8 changes: 4 additions & 4 deletions examples/gno.land/r/demo/dao_realm/dao_realm.gno
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions examples/gno.land/r/demo/dao_realm/dao_realm_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions examples/gno.land/r/demo/dao_realm/gno.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/gno.land/r/demo/groups/gno.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
2 changes: 1 addition & 1 deletion examples/gno.land/r/demo/groups/messages.gno
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion examples/gno.land/r/demo/modboards/gno.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
2 changes: 1 addition & 1 deletion examples/gno.land/r/demo/modboards/messages.gno
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
12 changes: 12 additions & 0 deletions examples/gno.land/r/demo/social_feeds/feed.gno
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions examples/gno.land/r/demo/social_feeds/messages.gno
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions examples/gno.land/r/demo/social_feeds/post.gno
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/gno.land/r/demo/social_feeds_dao/gno.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Loading

0 comments on commit bb9753f

Please sign in to comment.