Skip to content

feat: govdao v3 better rendering #4164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion examples/gno.land/r/gnoland/users/v1/admin.gno
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package users
import (
"std"

"gno.land/p/demo/ufmt"
"gno.land/r/gov/dao"
susers "gno.land/r/sys/users"
)
Expand All @@ -18,7 +19,15 @@ func NewSetPausedExecutor(newPausedValue bool) dao.ProposalRequest {

e := dao.NewSimpleExecutor(cb, "")

return dao.NewProposalRequest("Pause users/v1 realm", "", e)
title := ""
if newPausedValue {
title = "Pause `/r/gnoland/users/v1`"
} else {
title = "Unpause `/r/gnoland/users/v1`"
}

desc := ufmt.Sprintf("Proposal to set the users/v1 realm to `paused=%v`.", newPausedValue)
return dao.NewProposalRequest(title, desc, e)
}

// ProposeNewName allows GovDAO to propose a new name for an existing user
Expand Down
83 changes: 41 additions & 42 deletions examples/gno.land/r/gnoland/users/v1/z_0_prop1_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -59,78 +59,77 @@ func main() {

// Output:
// --
// # Active Proposals:
// ## Proposal with id: 0
// ### Title: Propose a new name using users/v1 realm
// # GovDAO Proposals
// ### [Prop #0 - Propose a new name using users/v1 realm](/r/gov/dao:0)
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
//
// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
// Status: ACTIVE
//
// Tiers eligible to vote: T1, T2, T3
//
//
//
// ### Proposal Status:
//
// - **Proposal open for votes**
// - Allowed tiers to vote: T1 T2 T3
// - YES PERCENT: 0%
// - NO PERCENT: 0%
// - [Go to votes list](/r/gov/dao:0/votes).
// ---
//
//
// --
// ## Proposal with id: 0
// ### Title: Propose a new name using users/v1 realm
// ## Prop #0 - Propose a new name using users/v1 realm
//
// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
//
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
//
//
//
// ### Proposal Status:
//
// - **Proposal open for votes**
// - Allowed tiers to vote: T1 T2 T3
// ### Stats
// - **Proposal is open for votes**
// - Tiers eligible to vote: T1, T2, T3
// - YES PERCENT: 0%
// - NO PERCENT: 0%
// - [Go to votes list](/r/gov/dao:0/votes).
//
// [Detailed voting list](/r/gov/dao:0/votes)
//
// --
// --
// ## Proposal with id: 0
// ### Title: Propose a new name using users/v1 realm
//
// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
// ---
//
// ### Actions
// [Vote YES](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=YES&pid=0) | [Vote NO](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=NO&pid=0) | [Vote ABSTAIN](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=ABSTAIN&pid=0)
//
// WARN: Please double check transaction data before voting.
// --
// --
// ## Prop #0 - Propose a new name using users/v1 realm
//
//
// ### Proposal Status:
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
//
// - **Proposal open for votes**
// - Allowed tiers to vote: T1 T2 T3
// ### Stats
// - **Proposal is open for votes**
// - Tiers eligible to vote: T1, T2, T3
// - YES PERCENT: 100%
// - NO PERCENT: 0%
// - [Go to votes list](/r/gov/dao:0/votes).
//
// [Detailed voting list](/r/gov/dao:0/votes)
//
// --
// --
// ## Proposal with id: 0
// ### Title: Propose a new name using users/v1 realm
//
// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
// ---
//
// ### Actions
// [Vote YES](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=YES&pid=0) | [Vote NO](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=NO&pid=0) | [Vote ABSTAIN](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=ABSTAIN&pid=0)
//
// WARN: Please double check transaction data before voting.
// --
// --
// ## Prop #0 - Propose a new name using users/v1 realm
//
//
// ### Proposal Status:
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
//
// ### Stats
// - **PROPOSAL HAS BEEN ACCEPTED**
// - Allowed tiers to vote: T1 T2 T3
// - Tiers eligible to vote: T1, T2, T3
// - YES PERCENT: 100%
// - NO PERCENT: 0%
// - [Go to votes list](/r/gov/dao:0/votes).
//
// [Detailed voting list](/r/gov/dao:0/votes)
//
// ---
//
// ### Actions
// [Vote YES](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=YES&pid=0) | [Vote NO](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=NO&pid=0) | [Vote ABSTAIN](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=ABSTAIN&pid=0)
//
// WARN: Please double check transaction data before voting.
// g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh
83 changes: 41 additions & 42 deletions examples/gno.land/r/gnoland/users/v1/z_1_prop2_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -65,78 +65,77 @@ func main() {

// Output:
// --
// # Active Proposals:
// ## Proposal with id: 0
// ### Title: Propose deleting a name using users/v1 realm
// # GovDAO Proposals
// ### [Prop #0 - Propose deleting a name using users/v1 realm](/r/gov/dao:0)
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
//
// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
// Status: ACTIVE
//
// Change alice's name!
//
//
// ### Proposal Status:
// Tiers eligible to vote: T1, T2, T3
//
// - **Proposal open for votes**
// - Allowed tiers to vote: T1 T2 T3
// - YES PERCENT: 0%
// - NO PERCENT: 0%
// - [Go to votes list](/r/gov/dao:0/votes).
// ---
//
//
// --
// ## Proposal with id: 0
// ### Title: Propose deleting a name using users/v1 realm
//
// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
//
// ## Prop #0 - Propose deleting a name using users/v1 realm
// Change alice's name!
//
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
//
// ### Proposal Status:
//
// - **Proposal open for votes**
// - Allowed tiers to vote: T1 T2 T3
// ### Stats
// - **Proposal is open for votes**
// - Tiers eligible to vote: T1, T2, T3
// - YES PERCENT: 0%
// - NO PERCENT: 0%
// - [Go to votes list](/r/gov/dao:0/votes).
//
// [Detailed voting list](/r/gov/dao:0/votes)
//
// --
// --
// ## Proposal with id: 0
// ### Title: Propose deleting a name using users/v1 realm
// ---
//
// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
// ### Actions
// [Vote YES](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=YES&pid=0) | [Vote NO](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=NO&pid=0) | [Vote ABSTAIN](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=ABSTAIN&pid=0)
//
// WARN: Please double check transaction data before voting.
// --
// --
// ## Prop #0 - Propose deleting a name using users/v1 realm
// Change alice's name!
//
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
//
// ### Proposal Status:
//
// - **Proposal open for votes**
// - Allowed tiers to vote: T1 T2 T3
// ### Stats
// - **Proposal is open for votes**
// - Tiers eligible to vote: T1, T2, T3
// - YES PERCENT: 100%
// - NO PERCENT: 0%
// - [Go to votes list](/r/gov/dao:0/votes).
//
// [Detailed voting list](/r/gov/dao:0/votes)
//
// --
// --
// ## Proposal with id: 0
// ### Title: Propose deleting a name using users/v1 realm
// ---
//
// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
// ### Actions
// [Vote YES](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=YES&pid=0) | [Vote NO](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=NO&pid=0) | [Vote ABSTAIN](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=ABSTAIN&pid=0)
//
// WARN: Please double check transaction data before voting.
// --
// --
// ## Prop #0 - Propose deleting a name using users/v1 realm
// Change alice's name!
//
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
//
// ### Proposal Status:
//
// ### Stats
// - **PROPOSAL HAS BEEN ACCEPTED**
// - Allowed tiers to vote: T1 T2 T3
// - Tiers eligible to vote: T1, T2, T3
// - YES PERCENT: 100%
// - NO PERCENT: 0%
// - [Go to votes list](/r/gov/dao:0/votes).
//
// [Detailed voting list](/r/gov/dao:0/votes)
//
// ---
//
// ### Actions
// [Vote YES](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=YES&pid=0) | [Vote NO](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=NO&pid=0) | [Vote ABSTAIN](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=ABSTAIN&pid=0)
//
// WARN: Please double check transaction data before voting.
// Successfully deleted alice
28 changes: 6 additions & 22 deletions examples/gno.land/r/gnoland/valopers_proposal/z_1_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,14 @@ func main() {
}

// Output:
// # Active Proposals:
// ## Proposal with id: 0
// ### Title: Add valoper test-1 to the valset
// # GovDAO Proposals
// ### [Prop #0 - Add valoper test-1 to the valset](/r/gov/dao:0)
// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
//
// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
// Status: ACTIVE
//
// Valoper profile: [test-1](/r/gnoland/valopers:g1sp8v98h2gadm5jggtzz9w5ksexqn68ympsd68h)
// Tiers eligible to vote: T1, T2, T3
//
// ## test-1
// test-1's description
//
// - Address: g1sp8v98h2gadm5jggtzz9w5ksexqn68ympsd68h
// - PubKey: gpub1pggj7ard9eg82cjtv4u52epjx56nzwgjyg9zqwpdwpd0f9fvqla089ndw5g9hcsufad77fml2vlu73fk8q8sh8v72cza5p
//
// [Profile link](/r/demo/profile:u/g1sp8v98h2gadm5jggtzz9w5ksexqn68ympsd68h)
//
//
//
// ### Proposal Status:
//
// - **Proposal open for votes**
// - Allowed tiers to vote: T1 T2 T3
// - YES PERCENT: 0%
// - NO PERCENT: 0%
// - [Go to votes list](/r/gov/dao:0/votes).
// ---
//
//
54 changes: 4 additions & 50 deletions examples/gno.land/r/gov/dao/v3/impl/govdao_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,8 @@ func TestCreateProposalAndVote(t *testing.T) {
// })
dao.MustVoteOnProposalSimple(0, "NO")

urequire.Equal(t, true, contains(dao.Render(""), "Proposal open for votes"))
urequire.Equal(t, true, contains(dao.Render(""), "15.789473684210526%"))
urequire.Equal(t, true, contains(dao.Render(""), "52.63157894736842%"))
urequire.Equal(t, true, strings.Contains(dao.Render(""), "Prop #0 - New T2 Member Proposal"))
//urequire.Equal(t, true, strings.Contains(dao.Render(""), "Author: "+m1.String()))

urequire.PanicsWithMessage(t, "proposal didn't reach supermajority yet: 66", func() {
dao.ExecuteProposal(dao.ProposalID(0))
Expand All @@ -138,52 +137,7 @@ func TestCreateProposalAndVote(t *testing.T) {
})

accepted := dao.ExecuteProposal(dao.ProposalID(0))
urequire.Equal(t, false, accepted)

urequire.Equal(t, true, contains(dao.Render(""), "**PROPOSAL HAS BEEN DENIED**"))
urequire.Equal(t, true, contains(dao.Render(""), "NO PERCENT: 68.42105263157895%"))
}

func TestProposalPagination(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to test this, its tested in p/demo/avl/pager already

loadMembers()
portfolio := "### This is my portfolio:\n\n- THINGS"

testing.SetOriginCaller(m1)

nm1 := testutils.TestAddress("nm1")

var pid dao.ProposalID

pid = dao.MustCreateProposal(NewAddMemberRequest(nm1, memberstore.T2, portfolio))
// TODO: tests keep the same vm state: https://github.com/gnolang/gno/issues/1982
urequire.Equal(t, 1, int(pid))

pid = dao.MustCreateProposal(NewAddMemberRequest(nm1, memberstore.T2, portfolio))
urequire.Equal(t, 2, int(pid))

pid = dao.MustCreateProposal(NewAddMemberRequest(nm1, memberstore.T2, portfolio))
urequire.Equal(t, 3, int(pid))

pid = dao.MustCreateProposal(NewAddMemberRequest(nm1, memberstore.T2, portfolio))
urequire.Equal(t, 4, int(pid))

pid = dao.MustCreateProposal(NewAddMemberRequest(nm1, memberstore.T2, portfolio))
urequire.Equal(t, 5, int(pid))

pid = dao.MustCreateProposal(NewAddMemberRequest(nm1, memberstore.T2, portfolio))
urequire.Equal(t, 6, int(pid))

urequire.Equal(t, true, contains(dao.Render(""), "## Proposal with id: 6"))
urequire.Equal(t, true, contains(dao.Render(""), "## Proposal with id: 5"))
urequire.Equal(t, true, contains(dao.Render(""), "## Proposal with id: 4"))

urequire.Equal(t, true, contains(dao.Render("/?page=2"), "## Proposal with id: 3"))
urequire.Equal(t, true, contains(dao.Render("/?page=2"), "## Proposal with id: 2"))
urequire.Equal(t, true, contains(dao.Render("/?page=2"), "## Proposal with id: 1"))

urequire.Equal(t, true, contains(dao.Render("/?page=3"), "## Proposal with id: 0"))
}

func contains(s, substr string) bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also strings.Contains exists

return strings.Index(s, substr) >= 0
urequire.Equal(t, false, accepted)
urequire.Equal(t, true, strings.Contains(dao.Render(""), "Status: REJECTED"))
}
Loading
Loading