From 40cef48a6d3e86b108e5604ffc66970b32ebdf2b Mon Sep 17 00:00:00 2001 From: leohhhn Date: Fri, 8 Nov 2024 16:27:27 +0100 Subject: [PATCH 01/33] update rendering --- examples/gno.land/p/demo/dao/proposals.gno | 4 +- examples/gno.land/p/demo/simpledao/gno.mod | 1 + .../gno.land/p/demo/simpledao/propstore.gno | 43 +++++--- examples/gno.land/r/gov/dao/v2/dao.gno | 27 +++-- .../gno.land/r/gov/dao/v2/prop1_filetest.gno | 82 +++++++++++--- .../gno.land/r/gov/dao/v2/prop2_filetest.gno | 82 +++++++++++--- .../gno.land/r/gov/dao/v2/prop3_filetest.gno | 100 ++++++++++++++---- examples/gno.land/r/leon/props/prop1.gno | 35 ++++++ 8 files changed, 295 insertions(+), 79 deletions(-) create mode 100644 examples/gno.land/r/leon/props/prop1.gno diff --git a/examples/gno.land/p/demo/dao/proposals.gno b/examples/gno.land/p/demo/dao/proposals.gno index 5cad679d006..a51f1991646 100644 --- a/examples/gno.land/p/demo/dao/proposals.gno +++ b/examples/gno.land/p/demo/dao/proposals.gno @@ -16,7 +16,7 @@ var ( Accepted ProposalStatus = "accepted" // proposal gathered quorum NotAccepted ProposalStatus = "not accepted" // proposal failed to gather quorum ExecutionSuccessful ProposalStatus = "execution successful" // proposal is executed successfully - ExecutionFailed ProposalStatus = "execution failed" // proposal is failed during execution + ExecutionFailed ProposalStatus = "execution failed" // proposal has failed during execution ) func (s ProposalStatus) String() string { @@ -58,5 +58,5 @@ type Proposal interface { IsExpired() bool // Render renders the proposal in a readable format - Render() string + Render(idx int) string } diff --git a/examples/gno.land/p/demo/simpledao/gno.mod b/examples/gno.land/p/demo/simpledao/gno.mod index f6f14f379ec..43924124de6 100644 --- a/examples/gno.land/p/demo/simpledao/gno.mod +++ b/examples/gno.land/p/demo/simpledao/gno.mod @@ -9,4 +9,5 @@ require ( gno.land/p/demo/uassert v0.0.0-latest gno.land/p/demo/ufmt v0.0.0-latest gno.land/p/demo/urequire v0.0.0-latest + gno.land/p/moul/txlink v0.0.0-latest ) diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index 06741d397cb..930a8be1ee8 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -3,10 +3,12 @@ package simpledao import ( "errors" "std" + "strconv" "gno.land/p/demo/dao" "gno.land/p/demo/seqid" "gno.land/p/demo/ufmt" + "gno.land/p/moul/txlink" ) var ErrMissingProposal = errors.New("proposal is missing") @@ -17,8 +19,10 @@ const maxRequestProposals = 10 // proposal is the internal simpledao proposal implementation type proposal struct { - author std.Address // initiator of the proposal - description string // description of the proposal + author std.Address // initiator of the proposal + + title string // title of the proposal + description string // description of the proposal executor dao.Executor // executor for the proposal status dao.ProposalStatus // status of the proposal @@ -31,6 +35,10 @@ func (p *proposal) Author() std.Address { return p.author } +func (p *proposal) Title() string { + return p.title +} + func (p *proposal) Description() string { return p.description } @@ -59,19 +67,18 @@ func (p *proposal) IsExpired() bool { return false // this proposal never expires } -func (p *proposal) Render() string { +func (p *proposal) Render(idx int) string { // Fetch the voting stats stats := p.Stats() - output := "" - output += ufmt.Sprintf("Author: %s", p.Author().String()) - output += "\n\n" - output += p.Description() - output += "\n\n" - output += ufmt.Sprintf("Status: %s", p.Status().String()) - output += "\n\n" + output := ufmt.Sprintf("# Proposal #%d\n\n", idx) + output += ufmt.Sprintf("## Description\n\n%s\n\n", p.description) + + output += "## Proposal information\n\n" + output += ufmt.Sprintf("#### Status: %s\n\n", p.Status().String()) + output += ufmt.Sprintf( - "Voting stats: YES %d (%d%%), NO %d (%d%%), ABSTAIN %d (%d%%), MISSING VOTE %d (%d%%)", + "#### Voting stats:\n- YES %d (%d%%)\n- NO %d (%d%%)\n- ABSTAIN %d (%d%%)\n- MISSING VOTE %d (%d%%)\n", stats.YayVotes, stats.YayPercent(), stats.NayVotes, @@ -82,7 +89,19 @@ func (p *proposal) Render() string { stats.MissingVotesPercent(), ) output += "\n\n" - output += ufmt.Sprintf("Threshold met: %t", stats.YayVotes > (2*stats.TotalVotingPower)/3) + + output += ufmt.Sprintf("#### Threshold met: %t\n\n", stats.YayVotes > (2*stats.TotalVotingPower)/3) + output += ufmt.Sprintf("#### Author: %s\n\n", string(p.author)) + + output += "## Actions\n\n" + if p.status == dao.Active { + output += ufmt.Sprintf("[Vote YES](%s) - [Vote NO](%s)", + txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "YES"), + txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "NO"), + ) + } else { + output += "The voting period for this proposal is over.\n\n" + } return output } diff --git a/examples/gno.land/r/gov/dao/v2/dao.gno b/examples/gno.land/r/gov/dao/v2/dao.gno index c37eda80bff..b4e73708c50 100644 --- a/examples/gno.land/r/gov/dao/v2/dao.gno +++ b/examples/gno.land/r/gov/dao/v2/dao.gno @@ -3,6 +3,7 @@ package govdao import ( "std" "strconv" + "strings" "gno.land/p/demo/dao" "gno.land/p/demo/membstore" @@ -70,14 +71,14 @@ func GetMembStore() membstore.MemberStore { func Render(path string) string { if path == "" { + output := "# GovDAO Proposals\n\n" numProposals := d.Size() if numProposals == 0 { - return "No proposals found :(" // corner case + output += "No proposals found :(" // corner case + return output } - output := "" - offset := uint64(0) if numProposals >= 10 { offset = uint64(numProposals) - 10 @@ -85,14 +86,13 @@ func Render(path string) string { // Fetch the last 10 proposals for idx, prop := range d.Proposals(offset, uint64(10)) { - output += ufmt.Sprintf( - "- [Proposal #%d](%s:%d) - (**%s**)(by %s)\n", - idx, - "/r/gov/dao/v2", - idx, - prop.Status().String(), - prop.Author().String(), - ) + output += ufmt.Sprintf("## [Prop #%d](/r/gov/dao/v2:%d)\n\n", idx, idx) + output += ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(prop.Status().String())) + output += ufmt.Sprintf("#### Author: %s\n\n", prop.Author().String()) + + if idx != len(d.Proposals(offset, uint64(10)))-1 { + output += "---\n\n" + } } return output @@ -111,10 +111,7 @@ func Render(path string) string { } // Render the proposal - output := "" - output += ufmt.Sprintf("# Prop #%d", idx) - output += "\n\n" - output += prop.Render() + output := prop.Render(idx) output += "\n\n" return output diff --git a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno index 07d06bfe74d..3f5daf8f708 100644 --- a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno @@ -73,52 +73,102 @@ func main() { // Output: // -- -// - [Proposal #0](/r/gov/dao/v2:0) - (**active**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm) +// # GovDAO Proposals +// +// ## [Prop #0](/r/gov/dao/v2:0) +// +// #### Status: ACTIVE +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// // // -- -// # Prop #0 +// # Proposal #0 // -// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// ## Description // // manual valset changes proposal example // -// Status: active +// ## Proposal information +// +// #### Status: active +// +// #### Voting stats: +// - YES 0 (0%) +// - NO 0 (0%) +// - ABSTAIN 0 (0%) +// - MISSING VOTE 10 (100%) // -// Voting stats: YES 0 (0%), NO 0 (0%), ABSTAIN 0 (0%), MISSING VOTE 10 (100%) // -// Threshold met: false +// #### Threshold met: false +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// +// ## Actions +// +// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) // // // -- // -- -// # Prop #0 +// # Proposal #0 // -// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// ## Description // // manual valset changes proposal example // -// Status: accepted +// ## Proposal information +// +// #### Status: accepted +// +// #### Voting stats: +// - YES 10 (100%) +// - NO 0 (0%) +// - ABSTAIN 0 (0%) +// - MISSING VOTE 0 (0%) +// +// +// #### Threshold met: true +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// +// ## Actions +// +// The voting period for this proposal is over. // -// Voting stats: YES 10 (100%), NO 0 (0%), ABSTAIN 0 (0%), MISSING VOTE 0 (0%) // -// Threshold met: true // // // -- // No valset changes to apply. // -- // -- -// # Prop #0 +// # Proposal #0 // -// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// ## Description // // manual valset changes proposal example // -// Status: execution successful +// ## Proposal information +// +// #### Status: execution successful +// +// #### Voting stats: +// - YES 10 (100%) +// - NO 0 (0%) +// - ABSTAIN 0 (0%) +// - MISSING VOTE 0 (0%) +// +// +// #### Threshold met: true +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// +// ## Actions +// +// The voting period for this proposal is over. // -// Voting stats: YES 10 (100%), NO 0 (0%), ABSTAIN 0 (0%), MISSING VOTE 0 (0%) // -// Threshold met: true // // // -- diff --git a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno index 76e744a6fc8..0a9f96755e6 100644 --- a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno @@ -50,35 +50,70 @@ func main() { // Output: // -- -// - [Proposal #0](/r/gov/dao/v2:0) - (**active**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm) +// # GovDAO Proposals +// +// ## [Prop #0](/r/gov/dao/v2:0) +// +// #### Status: ACTIVE +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// // // -- -// # Prop #0 +// # Proposal #0 // -// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// ## Description // // post a new blogpost about govdao // -// Status: active +// ## Proposal information +// +// #### Status: active +// +// #### Voting stats: +// - YES 0 (0%) +// - NO 0 (0%) +// - ABSTAIN 0 (0%) +// - MISSING VOTE 10 (100%) // -// Voting stats: YES 0 (0%), NO 0 (0%), ABSTAIN 0 (0%), MISSING VOTE 10 (100%) // -// Threshold met: false +// #### Threshold met: false +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// +// ## Actions +// +// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) // // // -- // -- -// # Prop #0 +// # Proposal #0 // -// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// ## Description // // post a new blogpost about govdao // -// Status: accepted +// ## Proposal information +// +// #### Status: accepted +// +// #### Voting stats: +// - YES 10 (100%) +// - NO 0 (0%) +// - ABSTAIN 0 (0%) +// - MISSING VOTE 0 (0%) +// +// +// #### Threshold met: true +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// +// ## Actions +// +// The voting period for this proposal is over. // -// Voting stats: YES 10 (100%), NO 0 (0%), ABSTAIN 0 (0%), MISSING VOTE 0 (0%) // -// Threshold met: true // // // -- @@ -87,17 +122,32 @@ func main() { // No posts. // -- // -- -// # Prop #0 +// # Proposal #0 // -// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// ## Description // // post a new blogpost about govdao // -// Status: execution successful +// ## Proposal information +// +// #### Status: execution successful +// +// #### Voting stats: +// - YES 10 (100%) +// - NO 0 (0%) +// - ABSTAIN 0 (0%) +// - MISSING VOTE 0 (0%) +// +// +// #### Threshold met: true +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// +// ## Actions +// +// The voting period for this proposal is over. // -// Voting stats: YES 10 (100%), NO 0 (0%), ABSTAIN 0 (0%), MISSING VOTE 0 (0%) // -// Threshold met: true // // // -- diff --git a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno index 0cd3bce6f83..5c369ab0ac9 100644 --- a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno @@ -64,57 +64,121 @@ func main() { // -- // 1 // -- -// - [Proposal #0](/r/gov/dao/v2:0) - (**active**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm) +// # GovDAO Proposals +// +// ## [Prop #0](/r/gov/dao/v2:0) +// +// #### Status: ACTIVE +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// // // -- -// # Prop #0 +// # Proposal #0 // -// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// ## Description // // add new members to the govdao // -// Status: active +// ## Proposal information +// +// #### Status: active +// +// #### Voting stats: +// - YES 0 (0%) +// - NO 0 (0%) +// - ABSTAIN 0 (0%) +// - MISSING VOTE 10 (100%) +// +// +// #### Threshold met: false // -// Voting stats: YES 0 (0%), NO 0 (0%), ABSTAIN 0 (0%), MISSING VOTE 10 (100%) +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm // -// Threshold met: false +// ## Actions +// +// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) // // // -- // -- -// # Prop #0 +// # Proposal #0 // -// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// ## Description // // add new members to the govdao // -// Status: accepted +// ## Proposal information +// +// #### Status: accepted +// +// #### Voting stats: +// - YES 10 (100%) +// - NO 0 (0%) +// - ABSTAIN 0 (0%) +// - MISSING VOTE 0 (0%) +// +// +// #### Threshold met: true +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// +// ## Actions +// +// The voting period for this proposal is over. // -// Voting stats: YES 10 (100%), NO 0 (0%), ABSTAIN 0 (0%), MISSING VOTE 0 (0%) // -// Threshold met: true // // // -- -// - [Proposal #0](/r/gov/dao/v2:0) - (**accepted**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm) +// # GovDAO Proposals +// +// ## [Prop #0](/r/gov/dao/v2:0) +// +// #### Status: ACCEPTED +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// // // -- // -- -// # Prop #0 +// # Proposal #0 // -// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// ## Description // // add new members to the govdao // -// Status: execution successful +// ## Proposal information +// +// #### Status: execution successful +// +// #### Voting stats: +// - YES 10 (25%) +// - NO 0 (0%) +// - ABSTAIN 0 (0%) +// - MISSING VOTE 30 (75%) +// +// +// #### Threshold met: false +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// +// ## Actions +// +// The voting period for this proposal is over. // -// Voting stats: YES 10 (25%), NO 0 (0%), ABSTAIN 0 (0%), MISSING VOTE 30 (75%) // -// Threshold met: false // // // -- -// - [Proposal #0](/r/gov/dao/v2:0) - (**execution successful**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm) +// # GovDAO Proposals +// +// ## [Prop #0](/r/gov/dao/v2:0) +// +// #### Status: EXECUTION SUCCESSFUL +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// // // -- // 4 diff --git a/examples/gno.land/r/leon/props/prop1.gno b/examples/gno.land/r/leon/props/prop1.gno new file mode 100644 index 00000000000..d2d869b3a71 --- /dev/null +++ b/examples/gno.land/r/leon/props/prop1.gno @@ -0,0 +1,35 @@ +package proposal + +import ( + "std" + + "gno.land/p/demo/dao" + pVals "gno.land/p/sys/validators" + govdao "gno.land/r/gov/dao/v2" + validators "gno.land/r/sys/validators/v2" +) + +func init() { + changesFn := func() []pVals.Validator { + return []pVals.Validator{ + { + Address: std.Address("g1x482v9p3hwetx2ayt2km7yntj4wsmqnd5at0lf"), // change with your address + PubKey: "gpub1pggj7ard9eg82cjtv4u52epjx56nzwgjyg9zpk9kmexf83hesgs0glzmtnpvc356h8vvrru209dmcxfghujzzzrrknpxl8", // change with your public key + VotingPower: 1, // leave this at 1 + }, + } + } + + // Grab the executor for the valset changes + executor := validators.NewPropExecutor(changesFn) + + // Create a description + description := "NEW PROP #####!!!!" + + prop := dao.ProposalRequest{ + Description: description, + Executor: executor, + } + + govdao.Propose(prop) +} From 19352be5bb3fbc1a09dc784d8b1dd2abc7521769 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Fri, 8 Nov 2024 16:28:48 +0100 Subject: [PATCH 02/33] rm title --- examples/gno.land/p/demo/simpledao/propstore.gno | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index 930a8be1ee8..86ff5e975fe 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -21,7 +21,6 @@ const maxRequestProposals = 10 type proposal struct { author std.Address // initiator of the proposal - title string // title of the proposal description string // description of the proposal executor dao.Executor // executor for the proposal From 80bf25463be96f5d7fa6fd3f35f81b5f47bdf4fe Mon Sep 17 00:00:00 2001 From: leohhhn Date: Fri, 8 Nov 2024 16:29:08 +0100 Subject: [PATCH 03/33] rm newline --- examples/gno.land/p/demo/simpledao/propstore.gno | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index 86ff5e975fe..bb04c5a2faf 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -19,9 +19,8 @@ const maxRequestProposals = 10 // proposal is the internal simpledao proposal implementation type proposal struct { - author std.Address // initiator of the proposal - - description string // description of the proposal + author std.Address // initiator of the proposal + description string // description of the proposal executor dao.Executor // executor for the proposal status dao.ProposalStatus // status of the proposal From c236aee1f87818f9c5209f3203b265478ae1f27e Mon Sep 17 00:00:00 2001 From: leohhhn Date: Fri, 8 Nov 2024 16:29:19 +0100 Subject: [PATCH 04/33] rm Title --- examples/gno.land/p/demo/simpledao/propstore.gno | 4 ---- 1 file changed, 4 deletions(-) diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index bb04c5a2faf..2fe960172cb 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -33,10 +33,6 @@ func (p *proposal) Author() std.Address { return p.author } -func (p *proposal) Title() string { - return p.title -} - func (p *proposal) Description() string { return p.description } From 97fe8fda7a9d32966e7eaa8843896b7b53dc08b3 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Fri, 8 Nov 2024 20:35:57 +0100 Subject: [PATCH 05/33] add abstain --- examples/gno.land/p/demo/simpledao/propstore.gno | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index 2fe960172cb..e5e2007df79 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -89,9 +89,10 @@ func (p *proposal) Render(idx int) string { output += "## Actions\n\n" if p.status == dao.Active { - output += ufmt.Sprintf("[Vote YES](%s) - [Vote NO](%s)", + output += ufmt.Sprintf("[Vote YES](%s) - [Vote NO](%s) - [Vote ABSTAIN](%s)", txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "YES"), txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "NO"), + txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "ABSTAIN"), ) } else { output += "The voting period for this proposal is over.\n\n" From c6c0e9bac394dee89679715a9fa593577fc8ccba Mon Sep 17 00:00:00 2001 From: leohhhn Date: Fri, 8 Nov 2024 20:59:15 +0100 Subject: [PATCH 06/33] fix tests --- examples/gno.land/r/gov/dao/v2/prop1_filetest.gno | 2 +- examples/gno.land/r/gov/dao/v2/prop2_filetest.gno | 2 +- examples/gno.land/r/gov/dao/v2/prop3_filetest.gno | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno index 3f5daf8f708..9e55a16e5ab 100644 --- a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno @@ -106,7 +106,7 @@ func main() { // // ## Actions // -// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) +// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) - [Vote ABSTAIN](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=ABSTAIN) // // // -- diff --git a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno index 0a9f96755e6..fa286322992 100644 --- a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno @@ -83,7 +83,7 @@ func main() { // // ## Actions // -// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) +// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) - [Vote ABSTAIN](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=ABSTAIN) // // // -- diff --git a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno index 5c369ab0ac9..620c2248f1e 100644 --- a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno @@ -97,7 +97,7 @@ func main() { // // ## Actions // -// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) +// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) - [Vote ABSTAIN](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=ABSTAIN) // // // -- From 84d94e0624e8f8a2240f32335ba810766d0294ec Mon Sep 17 00:00:00 2001 From: leohhhn Date: Sat, 9 Nov 2024 11:02:53 +0100 Subject: [PATCH 07/33] add title to propos --- examples/gno.land/p/demo/dao/dao.gno | 1 + examples/gno.land/p/demo/dao/proposals.gno | 3 +++ examples/gno.land/p/demo/simpledao/dao.gno | 18 ++++++++++++------ .../gno.land/p/demo/simpledao/propstore.gno | 18 +++++++++++------- examples/gno.land/r/gov/dao/v2/dao.gno | 11 +++++------ examples/gno.land/r/leon/props/prop1.gno | 6 ++---- 6 files changed, 34 insertions(+), 23 deletions(-) diff --git a/examples/gno.land/p/demo/dao/dao.gno b/examples/gno.land/p/demo/dao/dao.gno index f8ea433192f..e3a2ba72c5b 100644 --- a/examples/gno.land/p/demo/dao/dao.gno +++ b/examples/gno.land/p/demo/dao/dao.gno @@ -15,6 +15,7 @@ const ( // that contains the necessary information to // log and generate a valid proposal type ProposalRequest struct { + Title string // the title associated with the proposal Description string // the description associated with the proposal Executor Executor // the proposal executor } diff --git a/examples/gno.land/p/demo/dao/proposals.gno b/examples/gno.land/p/demo/dao/proposals.gno index a51f1991646..e62b3bd55d8 100644 --- a/examples/gno.land/p/demo/dao/proposals.gno +++ b/examples/gno.land/p/demo/dao/proposals.gno @@ -42,6 +42,9 @@ type Proposal interface { // Author returns the author of the proposal Author() std.Address + // Title returns the title of the proposal + Title() string + // Description returns the description of the proposal Description() string diff --git a/examples/gno.land/p/demo/simpledao/dao.gno b/examples/gno.land/p/demo/simpledao/dao.gno index 7a20237ec3f..b550571b504 100644 --- a/examples/gno.land/p/demo/simpledao/dao.gno +++ b/examples/gno.land/p/demo/simpledao/dao.gno @@ -2,16 +2,17 @@ package simpledao import ( "errors" - "std" - - "gno.land/p/demo/avl" - "gno.land/p/demo/dao" - "gno.land/p/demo/membstore" - "gno.land/p/demo/ufmt" + "github.com/gnolang/gno/examples/gno.land/p/demo/avl" + "github.com/gnolang/gno/examples/gno.land/p/demo/dao" + "github.com/gnolang/gno/examples/gno.land/p/demo/membstore" + "github.com/gnolang/gno/examples/gno.land/p/demo/ufmt" + "github.com/gnolang/gno/gnovm/stdlibs/std" + "strings" ) var ( ErrInvalidExecutor = errors.New("invalid executor provided") + ErrInvalidTitle = errors.New("invalid proposal title provided") ErrInsufficientProposalFunds = errors.New("insufficient funds for proposal") ErrInsufficientExecuteFunds = errors.New("insufficient funds for executing proposal") ErrProposalExecuted = errors.New("proposal already executed") @@ -47,6 +48,11 @@ func (s *SimpleDAO) Propose(request dao.ProposalRequest) (uint64, error) { return 0, ErrInvalidExecutor } + // Make sure the title is set + if strings.TrimSpace(request.Title) == "" { + return 0, ErrInvalidTitle + } + var ( caller = getDAOCaller() sentCoins = std.GetOrigSend() // Get the sent coins, if any diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index e5e2007df79..30524f3182a 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -2,13 +2,12 @@ package simpledao import ( "errors" - "std" + "github.com/gnolang/gno/examples/gno.land/p/demo/dao" + "github.com/gnolang/gno/examples/gno.land/p/demo/seqid" + "github.com/gnolang/gno/examples/gno.land/p/demo/ufmt" + "github.com/gnolang/gno/examples/gno.land/p/moul/txlink" + "github.com/gnolang/gno/gnovm/stdlibs/std" "strconv" - - "gno.land/p/demo/dao" - "gno.land/p/demo/seqid" - "gno.land/p/demo/ufmt" - "gno.land/p/moul/txlink" ) var ErrMissingProposal = errors.New("proposal is missing") @@ -20,6 +19,7 @@ const maxRequestProposals = 10 // proposal is the internal simpledao proposal implementation type proposal struct { author std.Address // initiator of the proposal + title string // title of the proposal description string // description of the proposal executor dao.Executor // executor for the proposal @@ -33,6 +33,10 @@ func (p *proposal) Author() std.Address { return p.author } +func (p *proposal) Title() string { + return p.title +} + func (p *proposal) Description() string { return p.description } @@ -65,7 +69,7 @@ func (p *proposal) Render(idx int) string { // Fetch the voting stats stats := p.Stats() - output := ufmt.Sprintf("# Proposal #%d\n\n", idx) + output := ufmt.Sprintf("# Proposal #%d - %s\n\n", idx, p.title) output += ufmt.Sprintf("## Description\n\n%s\n\n", p.description) output += "## Proposal information\n\n" diff --git a/examples/gno.land/r/gov/dao/v2/dao.gno b/examples/gno.land/r/gov/dao/v2/dao.gno index b4e73708c50..e221cdd6aa5 100644 --- a/examples/gno.land/r/gov/dao/v2/dao.gno +++ b/examples/gno.land/r/gov/dao/v2/dao.gno @@ -1,14 +1,13 @@ package govdao import ( - "std" + "github.com/gnolang/gno/examples/gno.land/p/demo/dao" + "github.com/gnolang/gno/examples/gno.land/p/demo/membstore" + "github.com/gnolang/gno/examples/gno.land/p/demo/simpledao" + "github.com/gnolang/gno/examples/gno.land/p/demo/ufmt" + "github.com/gnolang/gno/gnovm/stdlibs/std" "strconv" "strings" - - "gno.land/p/demo/dao" - "gno.land/p/demo/membstore" - "gno.land/p/demo/simpledao" - "gno.land/p/demo/ufmt" ) var ( diff --git a/examples/gno.land/r/leon/props/prop1.gno b/examples/gno.land/r/leon/props/prop1.gno index d2d869b3a71..8a6b434e846 100644 --- a/examples/gno.land/r/leon/props/prop1.gno +++ b/examples/gno.land/r/leon/props/prop1.gno @@ -23,11 +23,9 @@ func init() { // Grab the executor for the valset changes executor := validators.NewPropExecutor(changesFn) - // Create a description - description := "NEW PROP #####!!!!" - prop := dao.ProposalRequest{ - Description: description, + Title: "Add Leon to ValSet", + Description: "Proposing to add Leon to the valset!", Executor: executor, } From 841c1eb9ab77b18aae34ac0d91ac97711cfb6037 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Sat, 9 Nov 2024 11:08:56 +0100 Subject: [PATCH 08/33] fix simpledao tests --- examples/gno.land/p/demo/simpledao/dao.gno | 11 ++-- .../gno.land/p/demo/simpledao/dao_test.gno | 50 +++++++++++++++++++ .../gno.land/p/demo/simpledao/propstore.gno | 11 ++-- 3 files changed, 62 insertions(+), 10 deletions(-) diff --git a/examples/gno.land/p/demo/simpledao/dao.gno b/examples/gno.land/p/demo/simpledao/dao.gno index b550571b504..60edf300bf0 100644 --- a/examples/gno.land/p/demo/simpledao/dao.gno +++ b/examples/gno.land/p/demo/simpledao/dao.gno @@ -2,12 +2,13 @@ package simpledao import ( "errors" - "github.com/gnolang/gno/examples/gno.land/p/demo/avl" - "github.com/gnolang/gno/examples/gno.land/p/demo/dao" - "github.com/gnolang/gno/examples/gno.land/p/demo/membstore" - "github.com/gnolang/gno/examples/gno.land/p/demo/ufmt" - "github.com/gnolang/gno/gnovm/stdlibs/std" + "std" "strings" + + "gno.land/p/demo/avl" + "gno.land/p/demo/dao" + "gno.land/p/demo/membstore" + "gno.land/p/demo/ufmt" ) var ( diff --git a/examples/gno.land/p/demo/simpledao/dao_test.gno b/examples/gno.land/p/demo/simpledao/dao_test.gno index fb32895e72f..4ea077f8f6b 100644 --- a/examples/gno.land/p/demo/simpledao/dao_test.gno +++ b/examples/gno.land/p/demo/simpledao/dao_test.gno @@ -45,6 +45,52 @@ func TestSimpleDAO_Propose(t *testing.T) { ) }) + t.Run("invalid title", func(t *testing.T) { + t.Parallel() + + var ( + called = false + cb = func() error { + called = true + + return nil + } + ex = &mockExecutor{ + executeFn: cb, + } + + sentCoins = std.NewCoins( + std.NewCoin( + "ugnot", + minProposalFeeValue, + ), + ) + + ms = &mockMemberStore{ + isMemberFn: func(_ std.Address) bool { + return false + }, + } + s = New(ms) + ) + + // Set the sent coins to be lower + // than the proposal fee + std.TestSetOrigSend(sentCoins, std.Coins{}) + + _, err := s.Propose(dao.ProposalRequest{ + Executor: ex, + Title: "", + }) + uassert.ErrorIs( + t, + err, + ErrInvalidTitle, + ) + + uassert.False(t, called) + }) + t.Run("caller cannot cover fee", func(t *testing.T) { t.Parallel() @@ -58,6 +104,7 @@ func TestSimpleDAO_Propose(t *testing.T) { ex = &mockExecutor{ executeFn: cb, } + title = "Proposal title" sentCoins = std.NewCoins( std.NewCoin( @@ -80,6 +127,7 @@ func TestSimpleDAO_Propose(t *testing.T) { _, err := s.Propose(dao.ProposalRequest{ Executor: ex, + Title: title, }) uassert.ErrorIs( t, @@ -105,6 +153,7 @@ func TestSimpleDAO_Propose(t *testing.T) { executeFn: cb, } description = "Proposal description" + title = "Proposal title" proposer = testutils.TestAddress("proposer") sentCoins = std.NewCoins( @@ -129,6 +178,7 @@ func TestSimpleDAO_Propose(t *testing.T) { // Make sure the proposal was added id, err := s.Propose(dao.ProposalRequest{ + Title: title, Description: description, Executor: ex, }) diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index 30524f3182a..6c80eae7c62 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -2,12 +2,13 @@ package simpledao import ( "errors" - "github.com/gnolang/gno/examples/gno.land/p/demo/dao" - "github.com/gnolang/gno/examples/gno.land/p/demo/seqid" - "github.com/gnolang/gno/examples/gno.land/p/demo/ufmt" - "github.com/gnolang/gno/examples/gno.land/p/moul/txlink" - "github.com/gnolang/gno/gnovm/stdlibs/std" + "std" "strconv" + + "gno.land/p/demo/dao" + "gno.land/p/demo/seqid" + "gno.land/p/demo/ufmt" + "gno.land/p/moul/txlink" ) var ErrMissingProposal = errors.New("proposal is missing") From e163dddc690267ad704d7ecf7a1b5ffa3d56092d Mon Sep 17 00:00:00 2001 From: leohhhn Date: Sat, 9 Nov 2024 11:11:37 +0100 Subject: [PATCH 09/33] fix tests --- examples/gno.land/p/demo/simpledao/dao_test.gno | 4 +--- examples/gno.land/r/gov/dao/v2/dao.gno | 11 ++++++----- examples/gno.land/r/gov/dao/v2/prop1_filetest.gno | 8 +++++--- examples/gno.land/r/gov/dao/v2/prop2_filetest.gno | 8 +++++--- examples/gno.land/r/gov/dao/v2/prop3_filetest.gno | 8 +++++--- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/examples/gno.land/p/demo/simpledao/dao_test.gno b/examples/gno.land/p/demo/simpledao/dao_test.gno index 4ea077f8f6b..d1242d1e431 100644 --- a/examples/gno.land/p/demo/simpledao/dao_test.gno +++ b/examples/gno.land/p/demo/simpledao/dao_test.gno @@ -74,13 +74,11 @@ func TestSimpleDAO_Propose(t *testing.T) { s = New(ms) ) - // Set the sent coins to be lower - // than the proposal fee std.TestSetOrigSend(sentCoins, std.Coins{}) _, err := s.Propose(dao.ProposalRequest{ Executor: ex, - Title: "", + Title: "", // Set invalid title }) uassert.ErrorIs( t, diff --git a/examples/gno.land/r/gov/dao/v2/dao.gno b/examples/gno.land/r/gov/dao/v2/dao.gno index e221cdd6aa5..b4e73708c50 100644 --- a/examples/gno.land/r/gov/dao/v2/dao.gno +++ b/examples/gno.land/r/gov/dao/v2/dao.gno @@ -1,13 +1,14 @@ package govdao import ( - "github.com/gnolang/gno/examples/gno.land/p/demo/dao" - "github.com/gnolang/gno/examples/gno.land/p/demo/membstore" - "github.com/gnolang/gno/examples/gno.land/p/demo/simpledao" - "github.com/gnolang/gno/examples/gno.land/p/demo/ufmt" - "github.com/gnolang/gno/gnovm/stdlibs/std" + "std" "strconv" "strings" + + "gno.land/p/demo/dao" + "gno.land/p/demo/membstore" + "gno.land/p/demo/simpledao" + "gno.land/p/demo/ufmt" ) var ( diff --git a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno index 9e55a16e5ab..4857c85546a 100644 --- a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno @@ -42,9 +42,11 @@ func init() { executor := validators.NewPropExecutor(changesFn) // Create a proposal + title := "Valset change" description := "manual valset changes proposal example" prop := dao.ProposalRequest{ + Title: title, Description: description, Executor: executor, } @@ -83,7 +85,7 @@ func main() { // // // -- -// # Proposal #0 +// # Proposal #0 - // // ## Description // @@ -111,7 +113,7 @@ func main() { // // -- // -- -// # Proposal #0 +// # Proposal #0 - // // ## Description // @@ -143,7 +145,7 @@ func main() { // No valset changes to apply. // -- // -- -// # Proposal #0 +// # Proposal #0 - // // ## Description // diff --git a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno index fa286322992..8a302b5f041 100644 --- a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno @@ -19,9 +19,11 @@ func init() { ) // Create a proposal + title := "govdao blog post title" description := "post a new blogpost about govdao" prop := dao.ProposalRequest{ + Title: title, Description: description, Executor: ex, } @@ -60,7 +62,7 @@ func main() { // // // -- -// # Proposal #0 +// # Proposal #0 - // // ## Description // @@ -88,7 +90,7 @@ func main() { // // -- // -- -// # Proposal #0 +// # Proposal #0 - // // ## Description // @@ -122,7 +124,7 @@ func main() { // No posts. // -- // -- -// # Proposal #0 +// # Proposal #0 - // // ## Description // diff --git a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno index 620c2248f1e..e6eb3b66049 100644 --- a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno @@ -27,9 +27,11 @@ func init() { } // Create a proposal + title := "new govdao member addition" description := "add new members to the govdao" prop := dao.ProposalRequest{ + Title: title, Description: description, Executor: govdao.NewMemberPropExecutor(memberFn), } @@ -74,7 +76,7 @@ func main() { // // // -- -// # Proposal #0 +// # Proposal #0 - // // ## Description // @@ -102,7 +104,7 @@ func main() { // // -- // -- -// # Proposal #0 +// # Proposal #0 - // // ## Description // @@ -142,7 +144,7 @@ func main() { // // -- // -- -// # Proposal #0 +// # Proposal #0 - // // ## Description // From 5396eb45561f3c647e1ec74c8a17e33cc010596b Mon Sep 17 00:00:00 2001 From: leohhhn Date: Sat, 9 Nov 2024 11:43:09 +0100 Subject: [PATCH 10/33] set title, add test check --- examples/gno.land/p/demo/simpledao/dao.gno | 1 + examples/gno.land/p/demo/simpledao/dao_test.gno | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/gno.land/p/demo/simpledao/dao.gno b/examples/gno.land/p/demo/simpledao/dao.gno index 60edf300bf0..837f64a41d6 100644 --- a/examples/gno.land/p/demo/simpledao/dao.gno +++ b/examples/gno.land/p/demo/simpledao/dao.gno @@ -68,6 +68,7 @@ func (s *SimpleDAO) Propose(request dao.ProposalRequest) (uint64, error) { // Create the wrapped proposal prop := &proposal{ author: caller, + title: request.Title, description: request.Description, executor: request.Executor, status: dao.Active, diff --git a/examples/gno.land/p/demo/simpledao/dao_test.gno b/examples/gno.land/p/demo/simpledao/dao_test.gno index d1242d1e431..46251e24dad 100644 --- a/examples/gno.land/p/demo/simpledao/dao_test.gno +++ b/examples/gno.land/p/demo/simpledao/dao_test.gno @@ -189,6 +189,7 @@ func TestSimpleDAO_Propose(t *testing.T) { uassert.Equal(t, proposer.String(), prop.Author().String()) uassert.Equal(t, description, prop.Description()) + uassert.Equal(t, title, prop.Title()) uassert.Equal(t, dao.Active.String(), prop.Status().String()) stats := prop.Stats() From 62946d32f94a3189dab8781caf85aa6df27c7d87 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Sat, 9 Nov 2024 12:22:56 +0100 Subject: [PATCH 11/33] add username resolving --- examples/gno.land/p/demo/dao/proposals.gno | 2 +- .../gno.land/p/demo/simpledao/propstore.gno | 21 +++++++++++---- examples/gno.land/r/gov/dao/v2/dao.gno | 26 ++++++++++++++++--- examples/gno.land/r/leon/props/prop1.gno | 5 ++-- 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/examples/gno.land/p/demo/dao/proposals.gno b/examples/gno.land/p/demo/dao/proposals.gno index e62b3bd55d8..efe73efa4b9 100644 --- a/examples/gno.land/p/demo/dao/proposals.gno +++ b/examples/gno.land/p/demo/dao/proposals.gno @@ -61,5 +61,5 @@ type Proposal interface { IsExpired() bool // Render renders the proposal in a readable format - Render(idx int) string + Render(idx int, authorUsername string) string } diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index 6c80eae7c62..e5d485ca53a 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -4,6 +4,7 @@ import ( "errors" "std" "strconv" + "strings" "gno.land/p/demo/dao" "gno.land/p/demo/seqid" @@ -66,15 +67,21 @@ func (p *proposal) IsExpired() bool { return false // this proposal never expires } -func (p *proposal) Render(idx int) string { +func (p *proposal) Render(idx int, authorUsername string) string { // Fetch the voting stats stats := p.Stats() output := ufmt.Sprintf("# Proposal #%d - %s\n\n", idx, p.title) - output += ufmt.Sprintf("## Description\n\n%s\n\n", p.description) + + output += "## Description\n\n" + if strings.TrimSpace(p.description) != "" { + output += ufmt.Sprintf("%s\n\n", p.description) + } else { + output += "No description provided.\n\n" + } output += "## Proposal information\n\n" - output += ufmt.Sprintf("#### Status: %s\n\n", p.Status().String()) + output += ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(p.Status().String())) output += ufmt.Sprintf( "#### Voting stats:\n- YES %d (%d%%)\n- NO %d (%d%%)\n- ABSTAIN %d (%d%%)\n- MISSING VOTE %d (%d%%)\n", @@ -88,9 +95,13 @@ func (p *proposal) Render(idx int) string { stats.MissingVotesPercent(), ) output += "\n\n" + output += ufmt.Sprintf("#### Threshold met: %s\n\n", strings.ToUpper(ufmt.Sprintf("%t", stats.YayVotes > (2*stats.TotalVotingPower)/3))) - output += ufmt.Sprintf("#### Threshold met: %t\n\n", stats.YayVotes > (2*stats.TotalVotingPower)/3) - output += ufmt.Sprintf("#### Author: %s\n\n", string(p.author)) + if authorUsername != "" { + output += ufmt.Sprintf("#### Author: [%s](/r/demo/users:%s)\n\n", authorUsername, authorUsername) + } else { + output += ufmt.Sprintf("#### Author: %s\n\n", p.author.String()) + } output += "## Actions\n\n" if p.status == dao.Active { diff --git a/examples/gno.land/r/gov/dao/v2/dao.gno b/examples/gno.land/r/gov/dao/v2/dao.gno index b4e73708c50..3c8f78be44f 100644 --- a/examples/gno.land/r/gov/dao/v2/dao.gno +++ b/examples/gno.land/r/gov/dao/v2/dao.gno @@ -9,6 +9,8 @@ import ( "gno.land/p/demo/membstore" "gno.land/p/demo/simpledao" "gno.land/p/demo/ufmt" + + "gno.land/r/demo/users" ) var ( @@ -86,9 +88,21 @@ func Render(path string) string { // Fetch the last 10 proposals for idx, prop := range d.Proposals(offset, uint64(10)) { - output += ufmt.Sprintf("## [Prop #%d](/r/gov/dao/v2:%d)\n\n", idx, idx) + title := prop.Title() + if len(title) > 40 { + title = title[:40] + "..." + } + + output += ufmt.Sprintf("## [Prop #%d - %s](/r/gov/dao/v2:%d)\n\n", idx, title, idx) output += ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(prop.Status().String())) - output += ufmt.Sprintf("#### Author: %s\n\n", prop.Author().String()) + + user := users.GetUserByAddress(prop.Author()) + authorUsername := prop.Author().String() + if user != nil { + authorUsername = ufmt.Sprintf("[%s](/r/demo/users:%s)", user.Name, user.Name) + } + + output += ufmt.Sprintf("#### Author: %s\n\n", authorUsername) if idx != len(d.Proposals(offset, uint64(10)))-1 { output += "---\n\n" @@ -110,8 +124,14 @@ func Render(path string) string { return ufmt.Sprintf("unable to fetch proposal, %s", err.Error()) } + authorUsername := "" + user := users.GetUserByAddress(prop.Author()) + if user != nil { + authorUsername = user.Name + } + // Render the proposal - output := prop.Render(idx) + output := prop.Render(idx, authorUsername) output += "\n\n" return output diff --git a/examples/gno.land/r/leon/props/prop1.gno b/examples/gno.land/r/leon/props/prop1.gno index 8a6b434e846..c43de6054f1 100644 --- a/examples/gno.land/r/leon/props/prop1.gno +++ b/examples/gno.land/r/leon/props/prop1.gno @@ -24,9 +24,8 @@ func init() { executor := validators.NewPropExecutor(changesFn) prop := dao.ProposalRequest{ - Title: "Add Leon to ValSet", - Description: "Proposing to add Leon to the valset!", - Executor: executor, + Title: "Add Leon to to valset but be careful that he is a cool guy!", + Executor: executor, } govdao.Propose(prop) From 4dc4f8e37f1de00c7689880d1728589ccdf9afb5 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Sat, 9 Nov 2024 13:17:06 +0100 Subject: [PATCH 12/33] update rendering --- examples/gno.land/r/gov/dao/v2/dao.gno | 10 +++++--- examples/gno.land/r/gov/dao/v2/gno.mod | 1 + .../gno.land/r/gov/dao/v2/prop1_filetest.gno | 20 ++++++++-------- .../gno.land/r/gov/dao/v2/prop2_filetest.gno | 20 ++++++++-------- .../gno.land/r/gov/dao/v2/prop3_filetest.gno | 24 +++++++++---------- examples/gno.land/r/leon/props/prop1.gno | 2 +- 6 files changed, 41 insertions(+), 36 deletions(-) diff --git a/examples/gno.land/r/gov/dao/v2/dao.gno b/examples/gno.land/r/gov/dao/v2/dao.gno index 3c8f78be44f..5f63a856ab4 100644 --- a/examples/gno.land/r/gov/dao/v2/dao.gno +++ b/examples/gno.land/r/gov/dao/v2/dao.gno @@ -87,13 +87,17 @@ func Render(path string) string { } // Fetch the last 10 proposals - for idx, prop := range d.Proposals(offset, uint64(10)) { + proposals := d.Proposals(offset, uint64(10)) + for i := len(proposals) - 1; i >= 0; i-- { + prop := proposals[i] + title := prop.Title() if len(title) > 40 { title = title[:40] + "..." } - output += ufmt.Sprintf("## [Prop #%d - %s](/r/gov/dao/v2:%d)\n\n", idx, title, idx) + propID := offset + uint64(i) + output += ufmt.Sprintf("## [Prop #%d - %s](/r/gov/dao/v2:%d)\n\n", propID, title, propID) output += ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(prop.Status().String())) user := users.GetUserByAddress(prop.Author()) @@ -104,7 +108,7 @@ func Render(path string) string { output += ufmt.Sprintf("#### Author: %s\n\n", authorUsername) - if idx != len(d.Proposals(offset, uint64(10)))-1 { + if i != 0 { output += "---\n\n" } } diff --git a/examples/gno.land/r/gov/dao/v2/gno.mod b/examples/gno.land/r/gov/dao/v2/gno.mod index bc379bf18df..5093c7f0f7b 100644 --- a/examples/gno.land/r/gov/dao/v2/gno.mod +++ b/examples/gno.land/r/gov/dao/v2/gno.mod @@ -7,4 +7,5 @@ require ( gno.land/p/demo/simpledao v0.0.0-latest gno.land/p/demo/ufmt v0.0.0-latest gno.land/p/gov/executor v0.0.0-latest + gno.land/r/demo/users v0.0.0-latest ) diff --git a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno index 4857c85546a..5b28fddbc63 100644 --- a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno @@ -77,7 +77,7 @@ func main() { // -- // # GovDAO Proposals // -// ## [Prop #0](/r/gov/dao/v2:0) +// ## [Prop #0 - Valset change](/r/gov/dao/v2:0) // // #### Status: ACTIVE // @@ -85,7 +85,7 @@ func main() { // // // -- -// # Proposal #0 - +// # Proposal #0 - Valset change // // ## Description // @@ -93,7 +93,7 @@ func main() { // // ## Proposal information // -// #### Status: active +// #### Status: ACTIVE // // #### Voting stats: // - YES 0 (0%) @@ -102,7 +102,7 @@ func main() { // - MISSING VOTE 10 (100%) // // -// #### Threshold met: false +// #### Threshold met: FALSE // // #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm // @@ -113,7 +113,7 @@ func main() { // // -- // -- -// # Proposal #0 - +// # Proposal #0 - Valset change // // ## Description // @@ -121,7 +121,7 @@ func main() { // // ## Proposal information // -// #### Status: accepted +// #### Status: ACCEPTED // // #### Voting stats: // - YES 10 (100%) @@ -130,7 +130,7 @@ func main() { // - MISSING VOTE 0 (0%) // // -// #### Threshold met: true +// #### Threshold met: TRUE // // #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm // @@ -145,7 +145,7 @@ func main() { // No valset changes to apply. // -- // -- -// # Proposal #0 - +// # Proposal #0 - Valset change // // ## Description // @@ -153,7 +153,7 @@ func main() { // // ## Proposal information // -// #### Status: execution successful +// #### Status: EXECUTION SUCCESSFUL // // #### Voting stats: // - YES 10 (100%) @@ -162,7 +162,7 @@ func main() { // - MISSING VOTE 0 (0%) // // -// #### Threshold met: true +// #### Threshold met: TRUE // // #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm // diff --git a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno index 8a302b5f041..a68d0597ed4 100644 --- a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno @@ -54,7 +54,7 @@ func main() { // -- // # GovDAO Proposals // -// ## [Prop #0](/r/gov/dao/v2:0) +// ## [Prop #0 - govdao blog post title](/r/gov/dao/v2:0) // // #### Status: ACTIVE // @@ -62,7 +62,7 @@ func main() { // // // -- -// # Proposal #0 - +// # Proposal #0 - govdao blog post title // // ## Description // @@ -70,7 +70,7 @@ func main() { // // ## Proposal information // -// #### Status: active +// #### Status: ACTIVE // // #### Voting stats: // - YES 0 (0%) @@ -79,7 +79,7 @@ func main() { // - MISSING VOTE 10 (100%) // // -// #### Threshold met: false +// #### Threshold met: FALSE // // #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm // @@ -90,7 +90,7 @@ func main() { // // -- // -- -// # Proposal #0 - +// # Proposal #0 - govdao blog post title // // ## Description // @@ -98,7 +98,7 @@ func main() { // // ## Proposal information // -// #### Status: accepted +// #### Status: ACCEPTED // // #### Voting stats: // - YES 10 (100%) @@ -107,7 +107,7 @@ func main() { // - MISSING VOTE 0 (0%) // // -// #### Threshold met: true +// #### Threshold met: TRUE // // #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm // @@ -124,7 +124,7 @@ func main() { // No posts. // -- // -- -// # Proposal #0 - +// # Proposal #0 - govdao blog post title // // ## Description // @@ -132,7 +132,7 @@ func main() { // // ## Proposal information // -// #### Status: execution successful +// #### Status: EXECUTION SUCCESSFUL // // #### Voting stats: // - YES 10 (100%) @@ -141,7 +141,7 @@ func main() { // - MISSING VOTE 0 (0%) // // -// #### Threshold met: true +// #### Threshold met: TRUE // // #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm // diff --git a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno index e6eb3b66049..e055d3e35ea 100644 --- a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno @@ -68,7 +68,7 @@ func main() { // -- // # GovDAO Proposals // -// ## [Prop #0](/r/gov/dao/v2:0) +// ## [Prop #0 - new govdao member addition](/r/gov/dao/v2:0) // // #### Status: ACTIVE // @@ -76,7 +76,7 @@ func main() { // // // -- -// # Proposal #0 - +// # Proposal #0 - new govdao member addition // // ## Description // @@ -84,7 +84,7 @@ func main() { // // ## Proposal information // -// #### Status: active +// #### Status: ACTIVE // // #### Voting stats: // - YES 0 (0%) @@ -93,7 +93,7 @@ func main() { // - MISSING VOTE 10 (100%) // // -// #### Threshold met: false +// #### Threshold met: FALSE // // #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm // @@ -104,7 +104,7 @@ func main() { // // -- // -- -// # Proposal #0 - +// # Proposal #0 - new govdao member addition // // ## Description // @@ -112,7 +112,7 @@ func main() { // // ## Proposal information // -// #### Status: accepted +// #### Status: ACCEPTED // // #### Voting stats: // - YES 10 (100%) @@ -121,7 +121,7 @@ func main() { // - MISSING VOTE 0 (0%) // // -// #### Threshold met: true +// #### Threshold met: TRUE // // #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm // @@ -135,7 +135,7 @@ func main() { // -- // # GovDAO Proposals // -// ## [Prop #0](/r/gov/dao/v2:0) +// ## [Prop #0 - new govdao member addition](/r/gov/dao/v2:0) // // #### Status: ACCEPTED // @@ -144,7 +144,7 @@ func main() { // // -- // -- -// # Proposal #0 - +// # Proposal #0 - new govdao member addition // // ## Description // @@ -152,7 +152,7 @@ func main() { // // ## Proposal information // -// #### Status: execution successful +// #### Status: EXECUTION SUCCESSFUL // // #### Voting stats: // - YES 10 (25%) @@ -161,7 +161,7 @@ func main() { // - MISSING VOTE 30 (75%) // // -// #### Threshold met: false +// #### Threshold met: FALSE // // #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm // @@ -175,7 +175,7 @@ func main() { // -- // # GovDAO Proposals // -// ## [Prop #0](/r/gov/dao/v2:0) +// ## [Prop #0 - new govdao member addition](/r/gov/dao/v2:0) // // #### Status: EXECUTION SUCCESSFUL // diff --git a/examples/gno.land/r/leon/props/prop1.gno b/examples/gno.land/r/leon/props/prop1.gno index c43de6054f1..408d8ec70bc 100644 --- a/examples/gno.land/r/leon/props/prop1.gno +++ b/examples/gno.land/r/leon/props/prop1.gno @@ -24,7 +24,7 @@ func init() { executor := validators.NewPropExecutor(changesFn) prop := dao.ProposalRequest{ - Title: "Add Leon to to valset but be careful that he is a cool guy!", + Title: "Leon prop 3", Executor: executor, } From c6f6515103dbe1d5011061e6cdc2d4d96f8ccdb5 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Sat, 9 Nov 2024 13:22:37 +0100 Subject: [PATCH 13/33] rm leon/props --- examples/gno.land/r/leon/props/prop1.gno | 32 ------------------------ 1 file changed, 32 deletions(-) delete mode 100644 examples/gno.land/r/leon/props/prop1.gno diff --git a/examples/gno.land/r/leon/props/prop1.gno b/examples/gno.land/r/leon/props/prop1.gno deleted file mode 100644 index 408d8ec70bc..00000000000 --- a/examples/gno.land/r/leon/props/prop1.gno +++ /dev/null @@ -1,32 +0,0 @@ -package proposal - -import ( - "std" - - "gno.land/p/demo/dao" - pVals "gno.land/p/sys/validators" - govdao "gno.land/r/gov/dao/v2" - validators "gno.land/r/sys/validators/v2" -) - -func init() { - changesFn := func() []pVals.Validator { - return []pVals.Validator{ - { - Address: std.Address("g1x482v9p3hwetx2ayt2km7yntj4wsmqnd5at0lf"), // change with your address - PubKey: "gpub1pggj7ard9eg82cjtv4u52epjx56nzwgjyg9zpk9kmexf83hesgs0glzmtnpvc356h8vvrru209dmcxfghujzzzrrknpxl8", // change with your public key - VotingPower: 1, // leave this at 1 - }, - } - } - - // Grab the executor for the valset changes - executor := validators.NewPropExecutor(changesFn) - - prop := dao.ProposalRequest{ - Title: "Leon prop 3", - Executor: executor, - } - - govdao.Propose(prop) -} From 090966a56814973e8b890b8792e1825d552e1de1 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Sun, 10 Nov 2024 20:49:28 +0100 Subject: [PATCH 14/33] add bytes.Buffer --- .../gno.land/p/demo/simpledao/propstore.gno | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index e5d485ca53a..93b3b37ac23 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -1,6 +1,7 @@ package simpledao import ( + "bytes" "errors" "std" "strconv" @@ -71,19 +72,21 @@ func (p *proposal) Render(idx int, authorUsername string) string { // Fetch the voting stats stats := p.Stats() - output := ufmt.Sprintf("# Proposal #%d - %s\n\n", idx, p.title) + var out bytes.Buffer - output += "## Description\n\n" + out.WriteString(ufmt.Sprintf("# Proposal #%d - %s\n\n", idx, p.title)) + + out.WriteString("## Description\n\n") if strings.TrimSpace(p.description) != "" { - output += ufmt.Sprintf("%s\n\n", p.description) + out.WriteString(ufmt.Sprintf("%s\n\n", p.description)) } else { - output += "No description provided.\n\n" + out.WriteString("No description provided.\n\n") } - output += "## Proposal information\n\n" - output += ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(p.Status().String())) + out.WriteString("## Proposal information\n\n") + out.WriteString(ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(p.Status().String()))) - output += ufmt.Sprintf( + out.WriteString(ufmt.Sprintf( "#### Voting stats:\n- YES %d (%d%%)\n- NO %d (%d%%)\n- ABSTAIN %d (%d%%)\n- MISSING VOTE %d (%d%%)\n", stats.YayVotes, stats.YayPercent(), @@ -93,28 +96,30 @@ func (p *proposal) Render(idx int, authorUsername string) string { stats.AbstainPercent(), stats.MissingVotes(), stats.MissingVotesPercent(), - ) - output += "\n\n" - output += ufmt.Sprintf("#### Threshold met: %s\n\n", strings.ToUpper(ufmt.Sprintf("%t", stats.YayVotes > (2*stats.TotalVotingPower)/3))) + )) + out.WriteString("\n\n") + thresholdOut := strings.ToUpper(ufmt.Sprintf("%t", stats.YayVotes > (2*stats.TotalVotingPower)/3)) + + out.WriteString(ufmt.Sprintf("#### Threshold met: %s\n\n", thresholdOut)) if authorUsername != "" { - output += ufmt.Sprintf("#### Author: [%s](/r/demo/users:%s)\n\n", authorUsername, authorUsername) + out.WriteString(ufmt.Sprintf("#### Author: [%s](/r/demo/users:%s)\n\n", authorUsername, authorUsername)) } else { - output += ufmt.Sprintf("#### Author: %s\n\n", p.author.String()) + out.WriteString(ufmt.Sprintf("#### Author: %s\n\n", p.author.String())) } - output += "## Actions\n\n" + out.WriteString("## Actions\n\n") if p.status == dao.Active { - output += ufmt.Sprintf("[Vote YES](%s) - [Vote NO](%s) - [Vote ABSTAIN](%s)", + out.WriteString(ufmt.Sprintf("[Vote YES](%s) - [Vote NO](%s) - [Vote ABSTAIN](%s)", txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "YES"), txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "NO"), txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "ABSTAIN"), - ) + )) } else { - output += "The voting period for this proposal is over.\n\n" + out.WriteString("The voting period for this proposal is over.\n\n") } - return output + return out.String() } // addProposal adds a new simpledao proposal to the store From 7dca49871ae5acfeaf7f5016a78800249c3990ed Mon Sep 17 00:00:00 2001 From: leohhhn Date: Sun, 10 Nov 2024 20:53:01 +0100 Subject: [PATCH 15/33] add bytes.Buffer --- examples/gno.land/r/gov/dao/v2/dao.gno | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/examples/gno.land/r/gov/dao/v2/dao.gno b/examples/gno.land/r/gov/dao/v2/dao.gno index 5f63a856ab4..6521ac72772 100644 --- a/examples/gno.land/r/gov/dao/v2/dao.gno +++ b/examples/gno.land/r/gov/dao/v2/dao.gno @@ -1,6 +1,7 @@ package govdao import ( + "bytes" "std" "strconv" "strings" @@ -72,13 +73,15 @@ func GetMembStore() membstore.MemberStore { } func Render(path string) string { + var out bytes.Buffer + if path == "" { - output := "# GovDAO Proposals\n\n" + out.WriteString("# GovDAO Proposals\n\n") numProposals := d.Size() if numProposals == 0 { - output += "No proposals found :(" // corner case - return output + out.WriteString("No proposals found :(") // corner case + return out.String() } offset := uint64(0) @@ -97,8 +100,8 @@ func Render(path string) string { } propID := offset + uint64(i) - output += ufmt.Sprintf("## [Prop #%d - %s](/r/gov/dao/v2:%d)\n\n", propID, title, propID) - output += ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(prop.Status().String())) + out.WriteString(ufmt.Sprintf("## [Prop #%d - %s](/r/gov/dao/v2:%d)\n\n", propID, title, propID)) + out.WriteString(ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(prop.Status().String()))) user := users.GetUserByAddress(prop.Author()) authorUsername := prop.Author().String() @@ -106,14 +109,14 @@ func Render(path string) string { authorUsername = ufmt.Sprintf("[%s](/r/demo/users:%s)", user.Name, user.Name) } - output += ufmt.Sprintf("#### Author: %s\n\n", authorUsername) + out.WriteString(ufmt.Sprintf("#### Author: %s\n\n", authorUsername)) if i != 0 { - output += "---\n\n" + out.WriteString("---\n\n") } } - return output + return out.String() } // Display the detailed proposal @@ -135,8 +138,8 @@ func Render(path string) string { } // Render the proposal - output := prop.Render(idx, authorUsername) - output += "\n\n" + out.WriteString(prop.Render(idx, authorUsername)) + out.WriteString("\n\n") - return output + return out.String() } From 1a9c7ed19b2e76fa31488538c2eb15841fbbcc68 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Tue, 12 Nov 2024 14:00:51 +0900 Subject: [PATCH 16/33] typo --- examples/gno.land/p/demo/simpledao/propstore.gno | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index 93b3b37ac23..90d5a516a82 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -87,7 +87,7 @@ func (p *proposal) Render(idx int, authorUsername string) string { out.WriteString(ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(p.Status().String()))) out.WriteString(ufmt.Sprintf( - "#### Voting stats:\n- YES %d (%d%%)\n- NO %d (%d%%)\n- ABSTAIN %d (%d%%)\n- MISSING VOTE %d (%d%%)\n", + "#### Voting stats:\n- YES %d (%d%%)\n- NO %d (%d%%)\n- ABSTAIN %d (%d%%)\n- MISSING VOTES %d (%d%%)\n", stats.YayVotes, stats.YayPercent(), stats.NayVotes, From 05253fc5425412207ab4a0b025cf4337f4448ba8 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Tue, 12 Nov 2024 15:41:47 +0900 Subject: [PATCH 17/33] separete rendering --- examples/gno.land/r/gov/dao/v2/dao.gno | 81 +----------- .../gno.land/r/gov/dao/v2/prop1_filetest.gno | 12 +- .../gno.land/r/gov/dao/v2/prop2_filetest.gno | 12 +- .../gno.land/r/gov/dao/v2/prop3_filetest.gno | 12 +- examples/gno.land/r/gov/dao/v2/rendering.gno | 115 ++++++++++++++++++ 5 files changed, 125 insertions(+), 107 deletions(-) create mode 100644 examples/gno.land/r/gov/dao/v2/rendering.gno diff --git a/examples/gno.land/r/gov/dao/v2/dao.gno b/examples/gno.land/r/gov/dao/v2/dao.gno index 6521ac72772..cc6e5babc68 100644 --- a/examples/gno.land/r/gov/dao/v2/dao.gno +++ b/examples/gno.land/r/gov/dao/v2/dao.gno @@ -1,17 +1,10 @@ package govdao import ( - "bytes" - "std" - "strconv" - "strings" - "gno.land/p/demo/dao" "gno.land/p/demo/membstore" "gno.land/p/demo/simpledao" - "gno.land/p/demo/ufmt" - - "gno.land/r/demo/users" + "std" ) var ( @@ -71,75 +64,3 @@ func GetPropStore() dao.PropStore { func GetMembStore() membstore.MemberStore { return members } - -func Render(path string) string { - var out bytes.Buffer - - if path == "" { - out.WriteString("# GovDAO Proposals\n\n") - numProposals := d.Size() - - if numProposals == 0 { - out.WriteString("No proposals found :(") // corner case - return out.String() - } - - offset := uint64(0) - if numProposals >= 10 { - offset = uint64(numProposals) - 10 - } - - // Fetch the last 10 proposals - proposals := d.Proposals(offset, uint64(10)) - for i := len(proposals) - 1; i >= 0; i-- { - prop := proposals[i] - - title := prop.Title() - if len(title) > 40 { - title = title[:40] + "..." - } - - propID := offset + uint64(i) - out.WriteString(ufmt.Sprintf("## [Prop #%d - %s](/r/gov/dao/v2:%d)\n\n", propID, title, propID)) - out.WriteString(ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(prop.Status().String()))) - - user := users.GetUserByAddress(prop.Author()) - authorUsername := prop.Author().String() - if user != nil { - authorUsername = ufmt.Sprintf("[%s](/r/demo/users:%s)", user.Name, user.Name) - } - - out.WriteString(ufmt.Sprintf("#### Author: %s\n\n", authorUsername)) - - if i != 0 { - out.WriteString("---\n\n") - } - } - - return out.String() - } - - // Display the detailed proposal - idx, err := strconv.Atoi(path) - if err != nil { - return "404: Invalid proposal ID" - } - - // Fetch the proposal - prop, err := d.ProposalByID(uint64(idx)) - if err != nil { - return ufmt.Sprintf("unable to fetch proposal, %s", err.Error()) - } - - authorUsername := "" - user := users.GetUserByAddress(prop.Author()) - if user != nil { - authorUsername = user.Name - } - - // Render the proposal - out.WriteString(prop.Render(idx, authorUsername)) - out.WriteString("\n\n") - - return out.String() -} diff --git a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno index 5b28fddbc63..c5e99e49f17 100644 --- a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno @@ -85,8 +85,6 @@ func main() { // // // -- -// # Proposal #0 - Valset change -// // ## Description // // manual valset changes proposal example @@ -99,7 +97,7 @@ func main() { // - YES 0 (0%) // - NO 0 (0%) // - ABSTAIN 0 (0%) -// - MISSING VOTE 10 (100%) +// - MISSING VOTES 10 (100%) // // // #### Threshold met: FALSE @@ -113,8 +111,6 @@ func main() { // // -- // -- -// # Proposal #0 - Valset change -// // ## Description // // manual valset changes proposal example @@ -127,7 +123,7 @@ func main() { // - YES 10 (100%) // - NO 0 (0%) // - ABSTAIN 0 (0%) -// - MISSING VOTE 0 (0%) +// - MISSING VOTES 0 (0%) // // // #### Threshold met: TRUE @@ -145,8 +141,6 @@ func main() { // No valset changes to apply. // -- // -- -// # Proposal #0 - Valset change -// // ## Description // // manual valset changes proposal example @@ -159,7 +153,7 @@ func main() { // - YES 10 (100%) // - NO 0 (0%) // - ABSTAIN 0 (0%) -// - MISSING VOTE 0 (0%) +// - MISSING VOTES 0 (0%) // // // #### Threshold met: TRUE diff --git a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno index a68d0597ed4..0f1d6f6dc59 100644 --- a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno @@ -62,8 +62,6 @@ func main() { // // // -- -// # Proposal #0 - govdao blog post title -// // ## Description // // post a new blogpost about govdao @@ -76,7 +74,7 @@ func main() { // - YES 0 (0%) // - NO 0 (0%) // - ABSTAIN 0 (0%) -// - MISSING VOTE 10 (100%) +// - MISSING VOTES 10 (100%) // // // #### Threshold met: FALSE @@ -90,8 +88,6 @@ func main() { // // -- // -- -// # Proposal #0 - govdao blog post title -// // ## Description // // post a new blogpost about govdao @@ -104,7 +100,7 @@ func main() { // - YES 10 (100%) // - NO 0 (0%) // - ABSTAIN 0 (0%) -// - MISSING VOTE 0 (0%) +// - MISSING VOTES 0 (0%) // // // #### Threshold met: TRUE @@ -124,8 +120,6 @@ func main() { // No posts. // -- // -- -// # Proposal #0 - govdao blog post title -// // ## Description // // post a new blogpost about govdao @@ -138,7 +132,7 @@ func main() { // - YES 10 (100%) // - NO 0 (0%) // - ABSTAIN 0 (0%) -// - MISSING VOTE 0 (0%) +// - MISSING VOTES 0 (0%) // // // #### Threshold met: TRUE diff --git a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno index e055d3e35ea..049b161f89f 100644 --- a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno @@ -76,8 +76,6 @@ func main() { // // // -- -// # Proposal #0 - new govdao member addition -// // ## Description // // add new members to the govdao @@ -90,7 +88,7 @@ func main() { // - YES 0 (0%) // - NO 0 (0%) // - ABSTAIN 0 (0%) -// - MISSING VOTE 10 (100%) +// - MISSING VOTES 10 (100%) // // // #### Threshold met: FALSE @@ -104,8 +102,6 @@ func main() { // // -- // -- -// # Proposal #0 - new govdao member addition -// // ## Description // // add new members to the govdao @@ -118,7 +114,7 @@ func main() { // - YES 10 (100%) // - NO 0 (0%) // - ABSTAIN 0 (0%) -// - MISSING VOTE 0 (0%) +// - MISSING VOTES 0 (0%) // // // #### Threshold met: TRUE @@ -144,8 +140,6 @@ func main() { // // -- // -- -// # Proposal #0 - new govdao member addition -// // ## Description // // add new members to the govdao @@ -158,7 +152,7 @@ func main() { // - YES 10 (25%) // - NO 0 (0%) // - ABSTAIN 0 (0%) -// - MISSING VOTE 30 (75%) +// - MISSING VOTES 30 (75%) // // // #### Threshold met: FALSE diff --git a/examples/gno.land/r/gov/dao/v2/rendering.gno b/examples/gno.land/r/gov/dao/v2/rendering.gno new file mode 100644 index 00000000000..62ea4b29524 --- /dev/null +++ b/examples/gno.land/r/gov/dao/v2/rendering.gno @@ -0,0 +1,115 @@ +package govdao + +import ( + "bytes" + "strconv" + "strings" + + "gno.land/p/demo/dao" + "gno.land/p/demo/ufmt" + "gno.land/p/moul/txlink" + "gno.land/r/demo/users" +) + +func Render(path string) string { + var out bytes.Buffer + + if path == "" { + out.WriteString("# GovDAO Proposals\n\n") + numProposals := d.Size() + + if numProposals == 0 { + out.WriteString("No proposals found :(") // corner case + return out.String() + } + + offset := uint64(0) + if numProposals >= 10 { + offset = uint64(numProposals) - 10 + } + + // Fetch the last 10 proposals + proposals := d.Proposals(offset, uint64(10)) + for i := len(proposals) - 1; i >= 0; i-- { + prop := proposals[i] + + title := prop.Title() + if len(title) > 40 { + title = title[:40] + "..." + } + + propID := offset + uint64(i) + out.WriteString(ufmt.Sprintf("## [Prop #%d - %s](/r/gov/dao/v2:%d)\n\n", propID, title, propID)) + out.WriteString(ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(prop.Status().String()))) + + user := users.GetUserByAddress(prop.Author()) + authorUsername := prop.Author().String() + if user != nil { + authorUsername = ufmt.Sprintf("[%s](/r/demo/users:%s)", user.Name, user.Name) + } + + out.WriteString(ufmt.Sprintf("#### Author: %s\n\n", authorUsername)) + + if i != 0 { + out.WriteString("---\n\n") + } + } + + return out.String() + } + + // Display the detailed proposal + idx, err := strconv.Atoi(path) + if err != nil { + return "404: Invalid proposal ID" + } + + // Fetch the proposal + prop, err := d.ProposalByID(uint64(idx)) + if err != nil { + return ufmt.Sprintf("unable to fetch proposal, %s", err.Error()) + } + + // Render the proposal + out.WriteString(prop.Render()) + out.WriteString(renderAuthor(prop)) + out.WriteString(renderActionBar(prop, idx)) + out.WriteString("\n\n") + + return out.String() +} + +func renderAuthor(p dao.Proposal) string { + var out bytes.Buffer + + authorUsername := "" + user := users.GetUserByAddress(p.Author()) + if user != nil { + authorUsername = user.Name + } + + if authorUsername != "" { + out.WriteString(ufmt.Sprintf("#### Author: [%s](/r/demo/users:%s)\n\n", authorUsername, authorUsername)) + } else { + out.WriteString(ufmt.Sprintf("#### Author: %s\n\n", p.Author().String())) + } + + return out.String() +} + +func renderActionBar(p dao.Proposal, idx int) string { + var out bytes.Buffer + + out.WriteString("## Actions\n\n") + if p.Status() == dao.Active { + out.WriteString(ufmt.Sprintf("[Vote YES](%s) - [Vote NO](%s) - [Vote ABSTAIN](%s)", + txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "YES"), + txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "NO"), + txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "ABSTAIN"), + )) + } else { + out.WriteString("The voting period for this proposal is over.\n\n") + } + + return out.String() +} From 6ed08b0677237696b863a8323464919b6aa6cf97 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Tue, 12 Nov 2024 15:42:03 +0900 Subject: [PATCH 18/33] rm Render args --- examples/gno.land/p/demo/dao/proposals.gno | 2 +- .../gno.land/p/demo/simpledao/propstore.gno | 23 +------------------ 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/examples/gno.land/p/demo/dao/proposals.gno b/examples/gno.land/p/demo/dao/proposals.gno index efe73efa4b9..66abcb248c5 100644 --- a/examples/gno.land/p/demo/dao/proposals.gno +++ b/examples/gno.land/p/demo/dao/proposals.gno @@ -61,5 +61,5 @@ type Proposal interface { IsExpired() bool // Render renders the proposal in a readable format - Render(idx int, authorUsername string) string + Render() string } diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index 90d5a516a82..98170810507 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -4,13 +4,11 @@ import ( "bytes" "errors" "std" - "strconv" "strings" "gno.land/p/demo/dao" "gno.land/p/demo/seqid" "gno.land/p/demo/ufmt" - "gno.land/p/moul/txlink" ) var ErrMissingProposal = errors.New("proposal is missing") @@ -68,14 +66,12 @@ func (p *proposal) IsExpired() bool { return false // this proposal never expires } -func (p *proposal) Render(idx int, authorUsername string) string { +func (p *proposal) Render() string { // Fetch the voting stats stats := p.Stats() var out bytes.Buffer - out.WriteString(ufmt.Sprintf("# Proposal #%d - %s\n\n", idx, p.title)) - out.WriteString("## Description\n\n") if strings.TrimSpace(p.description) != "" { out.WriteString(ufmt.Sprintf("%s\n\n", p.description)) @@ -102,23 +98,6 @@ func (p *proposal) Render(idx int, authorUsername string) string { out.WriteString(ufmt.Sprintf("#### Threshold met: %s\n\n", thresholdOut)) - if authorUsername != "" { - out.WriteString(ufmt.Sprintf("#### Author: [%s](/r/demo/users:%s)\n\n", authorUsername, authorUsername)) - } else { - out.WriteString(ufmt.Sprintf("#### Author: %s\n\n", p.author.String())) - } - - out.WriteString("## Actions\n\n") - if p.status == dao.Active { - out.WriteString(ufmt.Sprintf("[Vote YES](%s) - [Vote NO](%s) - [Vote ABSTAIN](%s)", - txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "YES"), - txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "NO"), - txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "ABSTAIN"), - )) - } else { - out.WriteString("The voting period for this proposal is over.\n\n") - } - return out.String() } From 0ae3f23a00e992721578c6bc33b87526bc334c2a Mon Sep 17 00:00:00 2001 From: leohhhn Date: Tue, 12 Nov 2024 15:42:45 +0900 Subject: [PATCH 19/33] order imports --- examples/gno.land/r/gov/dao/v2/dao.gno | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/gno.land/r/gov/dao/v2/dao.gno b/examples/gno.land/r/gov/dao/v2/dao.gno index cc6e5babc68..9674a03807d 100644 --- a/examples/gno.land/r/gov/dao/v2/dao.gno +++ b/examples/gno.land/r/gov/dao/v2/dao.gno @@ -1,10 +1,11 @@ package govdao import ( + "std" + "gno.land/p/demo/dao" "gno.land/p/demo/membstore" "gno.land/p/demo/simpledao" - "std" ) var ( From 3d6ca754122e7c69a43342f974d8bdc45a0462ca Mon Sep 17 00:00:00 2001 From: leohhhn Date: Tue, 12 Nov 2024 15:48:27 +0900 Subject: [PATCH 20/33] mod tidy --- examples/gno.land/r/gov/dao/v2/gno.mod | 1 + examples/gno.land/r/gov/dao/v2/rendering.gno | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/gno.land/r/gov/dao/v2/gno.mod b/examples/gno.land/r/gov/dao/v2/gno.mod index 5093c7f0f7b..4da6e0a2484 100644 --- a/examples/gno.land/r/gov/dao/v2/gno.mod +++ b/examples/gno.land/r/gov/dao/v2/gno.mod @@ -7,5 +7,6 @@ require ( gno.land/p/demo/simpledao v0.0.0-latest gno.land/p/demo/ufmt v0.0.0-latest gno.land/p/gov/executor v0.0.0-latest + gno.land/p/moul/txlink v0.0.0-latest gno.land/r/demo/users v0.0.0-latest ) diff --git a/examples/gno.land/r/gov/dao/v2/rendering.gno b/examples/gno.land/r/gov/dao/v2/rendering.gno index 62ea4b29524..96a12e0e915 100644 --- a/examples/gno.land/r/gov/dao/v2/rendering.gno +++ b/examples/gno.land/r/gov/dao/v2/rendering.gno @@ -71,6 +71,7 @@ func Render(path string) string { } // Render the proposal + out.WriteString(ufmt.Sprintf("# Proposal #%d - %s\n\n", idx, prop.Title())) out.WriteString(prop.Render()) out.WriteString(renderAuthor(prop)) out.WriteString(renderActionBar(prop, idx)) From 54d37cd567ef496afc59ef554dfa087acc5895b9 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Tue, 12 Nov 2024 15:48:42 +0900 Subject: [PATCH 21/33] update tests --- examples/gno.land/r/gov/dao/v2/prop1_filetest.gno | 6 ++++++ examples/gno.land/r/gov/dao/v2/prop2_filetest.gno | 6 ++++++ examples/gno.land/r/gov/dao/v2/prop3_filetest.gno | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno index c5e99e49f17..bd375c24154 100644 --- a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno @@ -85,6 +85,8 @@ func main() { // // // -- +// # Proposal #0 - Valset change +// // ## Description // // manual valset changes proposal example @@ -111,6 +113,8 @@ func main() { // // -- // -- +// # Proposal #0 - Valset change +// // ## Description // // manual valset changes proposal example @@ -141,6 +145,8 @@ func main() { // No valset changes to apply. // -- // -- +// # Proposal #0 - Valset change +// // ## Description // // manual valset changes proposal example diff --git a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno index 0f1d6f6dc59..f0fa905a9db 100644 --- a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno @@ -62,6 +62,8 @@ func main() { // // // -- +// # Proposal #0 - govdao blog post title +// // ## Description // // post a new blogpost about govdao @@ -88,6 +90,8 @@ func main() { // // -- // -- +// # Proposal #0 - govdao blog post title +// // ## Description // // post a new blogpost about govdao @@ -120,6 +124,8 @@ func main() { // No posts. // -- // -- +// # Proposal #0 - govdao blog post title +// // ## Description // // post a new blogpost about govdao diff --git a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno index 049b161f89f..e2da80ddc5b 100644 --- a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno @@ -76,6 +76,8 @@ func main() { // // // -- +// # Proposal #0 - new govdao member addition +// // ## Description // // add new members to the govdao @@ -102,6 +104,8 @@ func main() { // // -- // -- +// # Proposal #0 - new govdao member addition +// // ## Description // // add new members to the govdao @@ -140,6 +144,8 @@ func main() { // // -- // -- +// # Proposal #0 - new govdao member addition +// // ## Description // // add new members to the govdao From cc445c3a04f1d905a1e515c0621617834a5265a5 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Tue, 12 Nov 2024 15:53:17 +0900 Subject: [PATCH 22/33] fix tests --- examples/gno.land/r/gov/dao/v2/rendering.gno | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gno.land/r/gov/dao/v2/rendering.gno b/examples/gno.land/r/gov/dao/v2/rendering.gno index 96a12e0e915..1d20631e644 100644 --- a/examples/gno.land/r/gov/dao/v2/rendering.gno +++ b/examples/gno.land/r/gov/dao/v2/rendering.gno @@ -43,12 +43,12 @@ func Render(path string) string { out.WriteString(ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(prop.Status().String()))) user := users.GetUserByAddress(prop.Author()) - authorUsername := prop.Author().String() + authorDisplayText := prop.Author().String() if user != nil { - authorUsername = ufmt.Sprintf("[%s](/r/demo/users:%s)", user.Name, user.Name) + authorDisplayText = ufmt.Sprintf("[%s](/r/demo/users:%s)", user.Name, user.Name) } - out.WriteString(ufmt.Sprintf("#### Author: %s\n\n", authorUsername)) + out.WriteString(ufmt.Sprintf("#### Author: %s\n\n", authorDisplayText)) if i != 0 { out.WriteString("---\n\n") From 7961e92c92ccbf9ef2b842e0f14f83889e075783 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Tue, 12 Nov 2024 16:17:37 +0900 Subject: [PATCH 23/33] mod tidy --- examples/gno.land/p/demo/simpledao/gno.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/gno.land/p/demo/simpledao/gno.mod b/examples/gno.land/p/demo/simpledao/gno.mod index 43924124de6..f6f14f379ec 100644 --- a/examples/gno.land/p/demo/simpledao/gno.mod +++ b/examples/gno.land/p/demo/simpledao/gno.mod @@ -9,5 +9,4 @@ require ( gno.land/p/demo/uassert v0.0.0-latest gno.land/p/demo/ufmt v0.0.0-latest gno.land/p/demo/urequire v0.0.0-latest - gno.land/p/moul/txlink v0.0.0-latest ) From 218efbf1aac2a83155930123da8bd296ffd49f6e Mon Sep 17 00:00:00 2001 From: leohhhn Date: Tue, 12 Nov 2024 16:19:54 +0900 Subject: [PATCH 24/33] organize --- examples/gno.land/r/gov/dao/v2/rendering.gno | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/gno.land/r/gov/dao/v2/rendering.gno b/examples/gno.land/r/gov/dao/v2/rendering.gno index 1d20631e644..c94eef77fd2 100644 --- a/examples/gno.land/r/gov/dao/v2/rendering.gno +++ b/examples/gno.land/r/gov/dao/v2/rendering.gno @@ -70,7 +70,15 @@ func Render(path string) string { return ufmt.Sprintf("unable to fetch proposal, %s", err.Error()) } - // Render the proposal + // Render the proposal page + out.WriteString(renderPropPage(prop, idx)) + + return out.String() +} + +func renderPropPage(prop d.Proposal, idx int) string { + var out bytes.Buffer + out.WriteString(ufmt.Sprintf("# Proposal #%d - %s\n\n", idx, prop.Title())) out.WriteString(prop.Render()) out.WriteString(renderAuthor(prop)) From ac7ee1df7662834cc3d55274adac2bcf46b89d64 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Tue, 12 Nov 2024 16:28:16 +0900 Subject: [PATCH 25/33] fix --- examples/gno.land/r/gov/dao/v2/rendering.gno | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gno.land/r/gov/dao/v2/rendering.gno b/examples/gno.land/r/gov/dao/v2/rendering.gno index c94eef77fd2..58b5913405d 100644 --- a/examples/gno.land/r/gov/dao/v2/rendering.gno +++ b/examples/gno.land/r/gov/dao/v2/rendering.gno @@ -76,7 +76,7 @@ func Render(path string) string { return out.String() } -func renderPropPage(prop d.Proposal, idx int) string { +func renderPropPage(prop dao.Proposal, idx int) string { var out bytes.Buffer out.WriteString(ufmt.Sprintf("# Proposal #%d - %s\n\n", idx, prop.Title())) From 50a948f667fc2a70d0ba6c1f9752bee585766877 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Mon, 18 Nov 2024 12:28:06 +0900 Subject: [PATCH 26/33] rename file --- examples/gno.land/r/gov/dao/v2/{rendering.gno => render.gno} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/gno.land/r/gov/dao/v2/{rendering.gno => render.gno} (100%) diff --git a/examples/gno.land/r/gov/dao/v2/rendering.gno b/examples/gno.land/r/gov/dao/v2/render.gno similarity index 100% rename from examples/gno.land/r/gov/dao/v2/rendering.gno rename to examples/gno.land/r/gov/dao/v2/render.gno From dd53283c9527fe8e1c1eba80aa989d5724064369 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Mon, 18 Nov 2024 18:27:49 +0900 Subject: [PATCH 27/33] fix test --- examples/gno.land/r/gov/dao/v2/prop4_filetest.gno | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno index c90e76727da..7362fe86201 100644 --- a/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno @@ -9,8 +9,10 @@ import ( func init() { mExec := params.NewStringPropExecutor("prop1.string", "value1") + title := "Setting prop1.string param" comment := "setting prop1.string param" prop := dao.ProposalRequest{ + Title: title, Description: comment, Executor: mExec, } From 15818dd42aee8ea82fef69debc6d530a0b2c5e83 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Mon, 18 Nov 2024 18:40:20 +0900 Subject: [PATCH 28/33] fix test --- .../gno.land/r/gov/dao/v2/prop4_filetest.gno | 80 +++++++++++++++---- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno index 7362fe86201..95a44cab1d1 100644 --- a/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno @@ -38,50 +38,98 @@ func main() { // Output: // new prop 0 // -- -// - [Proposal #0](/r/gov/dao/v2:0) - (**active**)(by g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm) +// # GovDAO Proposals +// +// ## [Prop #0 - Setting prop1.string param](/r/gov/dao/v2:0) +// +// #### Status: ACTIVE +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// // // -- -// # Prop #0 +// # Proposal #0 - Setting prop1.string param // -// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// ## Description // // setting prop1.string param // -// Status: active +// ## Proposal information +// +// #### Status: ACTIVE +// +// #### Voting stats: +// - YES 0 (0%) +// - NO 0 (0%) +// - ABSTAIN 0 (0%) +// - MISSING VOTES 10 (100%) // -// Voting stats: YES 0 (0%), NO 0 (0%), ABSTAIN 0 (0%), MISSING VOTE 10 (100%) // -// Threshold met: false +// #### Threshold met: FALSE +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// +// ## Actions +// +// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) - [Vote ABSTAIN](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=ABSTAIN) // // // -- // -- -// # Prop #0 +// # Proposal #0 - Setting prop1.string param // -// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// ## Description // // setting prop1.string param // -// Status: accepted +// ## Proposal information +// +// #### Status: ACCEPTED +// +// #### Voting stats: +// - YES 10 (100%) +// - NO 0 (0%) +// - ABSTAIN 0 (0%) +// - MISSING VOTES 0 (0%) +// +// +// #### Threshold met: TRUE +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// +// ## Actions +// +// The voting period for this proposal is over. // -// Voting stats: YES 10 (100%), NO 0 (0%), ABSTAIN 0 (0%), MISSING VOTE 0 (0%) // -// Threshold met: true // // // -- // -- -// # Prop #0 +// # Proposal #0 - Setting prop1.string param // -// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// ## Description // // setting prop1.string param // -// Status: execution successful +// ## Proposal information +// +// #### Status: EXECUTION SUCCESSFUL +// +// #### Voting stats: +// - YES 10 (100%) +// - NO 0 (0%) +// - ABSTAIN 0 (0%) +// - MISSING VOTES 0 (0%) +// +// +// #### Threshold met: TRUE +// +// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm // -// Voting stats: YES 10 (100%), NO 0 (0%), ABSTAIN 0 (0%), MISSING VOTE 0 (0%) +// ## Actions // -// Threshold met: true +// The voting period for this proposal is over. // Events: // [ From 82e301f55170d11e29a2b387af3bfc783f719e98 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Thu, 21 Nov 2024 11:54:35 +0900 Subject: [PATCH 29/33] buffer>builder --- examples/gno.land/p/demo/simpledao/propstore.gno | 4 +--- examples/gno.land/r/gov/dao/v2/prop1_filetest.gno | 6 ------ examples/gno.land/r/gov/dao/v2/prop2_filetest.gno | 6 ------ examples/gno.land/r/gov/dao/v2/prop3_filetest.gno | 6 ------ examples/gno.land/r/gov/dao/v2/prop4_filetest.gno | 6 ------ examples/gno.land/r/gov/dao/v2/render.gno | 6 +++--- 6 files changed, 4 insertions(+), 30 deletions(-) diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index 98170810507..ae47e454c27 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -1,7 +1,6 @@ package simpledao import ( - "bytes" "errors" "std" "strings" @@ -70,9 +69,8 @@ func (p *proposal) Render() string { // Fetch the voting stats stats := p.Stats() - var out bytes.Buffer + var out strings.Builder - out.WriteString("## Description\n\n") if strings.TrimSpace(p.description) != "" { out.WriteString(ufmt.Sprintf("%s\n\n", p.description)) } else { diff --git a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno index b27b3c1d552..702181fc9c3 100644 --- a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno @@ -87,8 +87,6 @@ func main() { // -- // # Proposal #0 - Valset change // -// ## Description -// // manual valset changes proposal example // // ## Proposal information @@ -115,8 +113,6 @@ func main() { // -- // # Proposal #0 - Valset change // -// ## Description -// // manual valset changes proposal example // // ## Proposal information @@ -147,8 +143,6 @@ func main() { // -- // # Proposal #0 - Valset change // -// ## Description -// // manual valset changes proposal example // // ## Proposal information diff --git a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno index ebb97a3a957..088081d9d90 100644 --- a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno @@ -64,8 +64,6 @@ func main() { // -- // # Proposal #0 - govdao blog post title // -// ## Description -// // post a new blogpost about govdao // // ## Proposal information @@ -92,8 +90,6 @@ func main() { // -- // # Proposal #0 - govdao blog post title // -// ## Description -// // post a new blogpost about govdao // // ## Proposal information @@ -126,8 +122,6 @@ func main() { // -- // # Proposal #0 - govdao blog post title // -// ## Description -// // post a new blogpost about govdao // // ## Proposal information diff --git a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno index 0cab83a18fa..0ac381a00dc 100644 --- a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno @@ -79,8 +79,6 @@ func main() { // -- // # Proposal #0 - new govdao member addition // -// ## Description -// // add new members to the govdao // // ## Proposal information @@ -107,8 +105,6 @@ func main() { // -- // # Proposal #0 - new govdao member addition // -// ## Description -// // add new members to the govdao // // ## Proposal information @@ -147,8 +143,6 @@ func main() { // -- // # Proposal #0 - new govdao member addition // -// ## Description -// // add new members to the govdao // // ## Proposal information diff --git a/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno index 95a44cab1d1..3f39b12798a 100644 --- a/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno @@ -50,8 +50,6 @@ func main() { // -- // # Proposal #0 - Setting prop1.string param // -// ## Description -// // setting prop1.string param // // ## Proposal information @@ -78,8 +76,6 @@ func main() { // -- // # Proposal #0 - Setting prop1.string param // -// ## Description -// // setting prop1.string param // // ## Proposal information @@ -108,8 +104,6 @@ func main() { // -- // # Proposal #0 - Setting prop1.string param // -// ## Description -// // setting prop1.string param // // ## Proposal information diff --git a/examples/gno.land/r/gov/dao/v2/render.gno b/examples/gno.land/r/gov/dao/v2/render.gno index 58b5913405d..93caf143750 100644 --- a/examples/gno.land/r/gov/dao/v2/render.gno +++ b/examples/gno.land/r/gov/dao/v2/render.gno @@ -12,7 +12,7 @@ import ( ) func Render(path string) string { - var out bytes.Buffer + var out strings.Builder if path == "" { out.WriteString("# GovDAO Proposals\n\n") @@ -77,7 +77,7 @@ func Render(path string) string { } func renderPropPage(prop dao.Proposal, idx int) string { - var out bytes.Buffer + var out strings.Builder out.WriteString(ufmt.Sprintf("# Proposal #%d - %s\n\n", idx, prop.Title())) out.WriteString(prop.Render()) @@ -89,7 +89,7 @@ func renderPropPage(prop dao.Proposal, idx int) string { } func renderAuthor(p dao.Proposal) string { - var out bytes.Buffer + var out strings.Builder authorUsername := "" user := users.GetUserByAddress(p.Author()) From 9bd9cd9f76bd3ab2079f495699ffb2f5c7958e4d Mon Sep 17 00:00:00 2001 From: leohhhn Date: Thu, 21 Nov 2024 12:06:35 +0900 Subject: [PATCH 30/33] replace with simple string --- .../gno.land/p/demo/simpledao/propstore.gno | 21 ++++---- examples/gno.land/r/gov/dao/v2/render.gno | 54 +++++++++---------- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index ae47e454c27..18e7dcb10ca 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -69,18 +69,18 @@ func (p *proposal) Render() string { // Fetch the voting stats stats := p.Stats() - var out strings.Builder + var out string if strings.TrimSpace(p.description) != "" { - out.WriteString(ufmt.Sprintf("%s\n\n", p.description)) + out += ufmt.Sprintf("%s\n\n", p.description) } else { - out.WriteString("No description provided.\n\n") + out += "No description provided.\n\n" } - out.WriteString("## Proposal information\n\n") - out.WriteString(ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(p.Status().String()))) + out += "## Proposal information\n\n" + out += ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(p.Status().String())) - out.WriteString(ufmt.Sprintf( + out += ufmt.Sprintf( "#### Voting stats:\n- YES %d (%d%%)\n- NO %d (%d%%)\n- ABSTAIN %d (%d%%)\n- MISSING VOTES %d (%d%%)\n", stats.YayVotes, stats.YayPercent(), @@ -90,13 +90,14 @@ func (p *proposal) Render() string { stats.AbstainPercent(), stats.MissingVotes(), stats.MissingVotesPercent(), - )) - out.WriteString("\n\n") + ) + + out += "\n\n" thresholdOut := strings.ToUpper(ufmt.Sprintf("%t", stats.YayVotes > (2*stats.TotalVotingPower)/3)) - out.WriteString(ufmt.Sprintf("#### Threshold met: %s\n\n", thresholdOut)) + out += ufmt.Sprintf("#### Threshold met: %s\n\n", thresholdOut) - return out.String() + return out } // addProposal adds a new simpledao proposal to the store diff --git a/examples/gno.land/r/gov/dao/v2/render.gno b/examples/gno.land/r/gov/dao/v2/render.gno index 93caf143750..43077191632 100644 --- a/examples/gno.land/r/gov/dao/v2/render.gno +++ b/examples/gno.land/r/gov/dao/v2/render.gno @@ -1,7 +1,6 @@ package govdao import ( - "bytes" "strconv" "strings" @@ -12,15 +11,15 @@ import ( ) func Render(path string) string { - var out strings.Builder + var out string if path == "" { - out.WriteString("# GovDAO Proposals\n\n") + out += "# GovDAO Proposals\n\n" numProposals := d.Size() if numProposals == 0 { - out.WriteString("No proposals found :(") // corner case - return out.String() + out += "No proposals found :(" // corner case + return out } offset := uint64(0) @@ -39,8 +38,8 @@ func Render(path string) string { } propID := offset + uint64(i) - out.WriteString(ufmt.Sprintf("## [Prop #%d - %s](/r/gov/dao/v2:%d)\n\n", propID, title, propID)) - out.WriteString(ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(prop.Status().String()))) + out += ufmt.Sprintf("## [Prop #%d - %s](/r/gov/dao/v2:%d)\n\n", propID, title, propID) + out += ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(prop.Status().String())) user := users.GetUserByAddress(prop.Author()) authorDisplayText := prop.Author().String() @@ -48,14 +47,14 @@ func Render(path string) string { authorDisplayText = ufmt.Sprintf("[%s](/r/demo/users:%s)", user.Name, user.Name) } - out.WriteString(ufmt.Sprintf("#### Author: %s\n\n", authorDisplayText)) + out += ufmt.Sprintf("#### Author: %s\n\n", authorDisplayText) if i != 0 { - out.WriteString("---\n\n") + out += "---\n\n" } } - return out.String() + return out } // Display the detailed proposal @@ -71,25 +70,24 @@ func Render(path string) string { } // Render the proposal page - out.WriteString(renderPropPage(prop, idx)) + out += renderPropPage(prop, idx) return out.String() } func renderPropPage(prop dao.Proposal, idx int) string { - var out strings.Builder + var out string - out.WriteString(ufmt.Sprintf("# Proposal #%d - %s\n\n", idx, prop.Title())) - out.WriteString(prop.Render()) - out.WriteString(renderAuthor(prop)) - out.WriteString(renderActionBar(prop, idx)) - out.WriteString("\n\n") + out += ufmt.Sprintf("# Proposal #%d - %s\n\n", idx, prop.Title()) + out += prop.Render() + out += renderAuthor(prop) + out += renderActionBar(prop, idx) + out += "\n\n" - return out.String() + return out } func renderAuthor(p dao.Proposal) string { - var out strings.Builder authorUsername := "" user := users.GetUserByAddress(p.Author()) @@ -98,27 +96,27 @@ func renderAuthor(p dao.Proposal) string { } if authorUsername != "" { - out.WriteString(ufmt.Sprintf("#### Author: [%s](/r/demo/users:%s)\n\n", authorUsername, authorUsername)) + out += ufmt.Sprintf("#### Author: [%s](/r/demo/users:%s)\n\n", authorUsername, authorUsername) } else { - out.WriteString(ufmt.Sprintf("#### Author: %s\n\n", p.Author().String())) + out += ufmt.Sprintf("#### Author: %s\n\n", p.Author().String()) } - return out.String() + return out } func renderActionBar(p dao.Proposal, idx int) string { - var out bytes.Buffer + var out string - out.WriteString("## Actions\n\n") + out += "## Actions\n\n" if p.Status() == dao.Active { - out.WriteString(ufmt.Sprintf("[Vote YES](%s) - [Vote NO](%s) - [Vote ABSTAIN](%s)", + out += ufmt.Sprintf("[Vote YES](%s) - [Vote NO](%s) - [Vote ABSTAIN](%s)", txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "YES"), txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "NO"), txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "ABSTAIN"), - )) + ) } else { - out.WriteString("The voting period for this proposal is over.\n\n") + out += "The voting period for this proposal is over.\n\n" } - return out.String() + return out } From 715a77889bd1bdc465399e1f13080a924919ab26 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Thu, 21 Nov 2024 12:42:57 +0900 Subject: [PATCH 31/33] bold --- examples/gno.land/p/demo/simpledao/propstore.gno | 6 +++--- examples/gno.land/r/gov/dao/v2/dao.gno | 2 +- examples/gno.land/r/gov/dao/v2/render.gno | 11 ++++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index 18e7dcb10ca..c520cdaca2d 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -78,10 +78,10 @@ func (p *proposal) Render() string { } out += "## Proposal information\n\n" - out += ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(p.Status().String())) + out += ufmt.Sprintf("**Status: %s**\n\n", strings.ToUpper(p.Status().String())) out += ufmt.Sprintf( - "#### Voting stats:\n- YES %d (%d%%)\n- NO %d (%d%%)\n- ABSTAIN %d (%d%%)\n- MISSING VOTES %d (%d%%)\n", + "**Voting stats:**\n- YES %d (%d%%)\n- NO %d (%d%%)\n- ABSTAIN %d (%d%%)\n- MISSING VOTES %d (%d%%)\n", stats.YayVotes, stats.YayPercent(), stats.NayVotes, @@ -95,7 +95,7 @@ func (p *proposal) Render() string { out += "\n\n" thresholdOut := strings.ToUpper(ufmt.Sprintf("%t", stats.YayVotes > (2*stats.TotalVotingPower)/3)) - out += ufmt.Sprintf("#### Threshold met: %s\n\n", thresholdOut) + out += ufmt.Sprintf("**Threshold met: %s**\n\n", thresholdOut) return out } diff --git a/examples/gno.land/r/gov/dao/v2/dao.gno b/examples/gno.land/r/gov/dao/v2/dao.gno index 9263d8d440b..43d7a8c8c29 100644 --- a/examples/gno.land/r/gov/dao/v2/dao.gno +++ b/examples/gno.land/r/gov/dao/v2/dao.gno @@ -17,7 +17,7 @@ func init() { // Example initial member set (just test addresses) set := []membstore.Member{ { - Address: std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"), + Address: std.Address("g125em6arxsnj49vx35f0n0z34putv5ty3376fg5"), VotingPower: 10, }, } diff --git a/examples/gno.land/r/gov/dao/v2/render.gno b/examples/gno.land/r/gov/dao/v2/render.gno index 43077191632..d11a39289f7 100644 --- a/examples/gno.land/r/gov/dao/v2/render.gno +++ b/examples/gno.land/r/gov/dao/v2/render.gno @@ -39,7 +39,7 @@ func Render(path string) string { propID := offset + uint64(i) out += ufmt.Sprintf("## [Prop #%d - %s](/r/gov/dao/v2:%d)\n\n", propID, title, propID) - out += ufmt.Sprintf("#### Status: %s\n\n", strings.ToUpper(prop.Status().String())) + out += ufmt.Sprintf("**Status: %s**\n\n", strings.ToUpper(prop.Status().String())) user := users.GetUserByAddress(prop.Author()) authorDisplayText := prop.Author().String() @@ -47,7 +47,7 @@ func Render(path string) string { authorDisplayText = ufmt.Sprintf("[%s](/r/demo/users:%s)", user.Name, user.Name) } - out += ufmt.Sprintf("#### Author: %s\n\n", authorDisplayText) + out += ufmt.Sprintf("**Author: %s**\n\n", authorDisplayText) if i != 0 { out += "---\n\n" @@ -72,7 +72,7 @@ func Render(path string) string { // Render the proposal page out += renderPropPage(prop, idx) - return out.String() + return out } func renderPropPage(prop dao.Proposal, idx int) string { @@ -88,6 +88,7 @@ func renderPropPage(prop dao.Proposal, idx int) string { } func renderAuthor(p dao.Proposal) string { + var out string authorUsername := "" user := users.GetUserByAddress(p.Author()) @@ -96,9 +97,9 @@ func renderAuthor(p dao.Proposal) string { } if authorUsername != "" { - out += ufmt.Sprintf("#### Author: [%s](/r/demo/users:%s)\n\n", authorUsername, authorUsername) + out += ufmt.Sprintf("**Author: [%s](/r/demo/users:%s)**\n\n", authorUsername, authorUsername) } else { - out += ufmt.Sprintf("#### Author: %s\n\n", p.Author().String()) + out += ufmt.Sprintf("**Author: %s**\n\n", p.Author().String()) } return out From 00081ed925e2ed0c2e924bc69abad1e3fdb04131 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Thu, 21 Nov 2024 13:07:20 +0900 Subject: [PATCH 32/33] update --- .../gno.land/p/demo/simpledao/propstore.gno | 1 + examples/gno.land/r/gov/dao/v2/dao.gno | 2 +- .../gno.land/r/gov/dao/v2/prop1_filetest.gno | 42 +++++++++------- .../gno.land/r/gov/dao/v2/prop2_filetest.gno | 42 +++++++++------- .../gno.land/r/gov/dao/v2/prop3_filetest.gno | 50 +++++++++++-------- .../gno.land/r/gov/dao/v2/prop4_filetest.gno | 42 +++++++++------- examples/gno.land/r/gov/dao/v2/render.gno | 4 +- 7 files changed, 104 insertions(+), 79 deletions(-) diff --git a/examples/gno.land/p/demo/simpledao/propstore.gno b/examples/gno.land/p/demo/simpledao/propstore.gno index c520cdaca2d..91f2a883047 100644 --- a/examples/gno.land/p/demo/simpledao/propstore.gno +++ b/examples/gno.land/p/demo/simpledao/propstore.gno @@ -71,6 +71,7 @@ func (p *proposal) Render() string { var out string + out += "## Description\n\n" if strings.TrimSpace(p.description) != "" { out += ufmt.Sprintf("%s\n\n", p.description) } else { diff --git a/examples/gno.land/r/gov/dao/v2/dao.gno b/examples/gno.land/r/gov/dao/v2/dao.gno index 43d7a8c8c29..9263d8d440b 100644 --- a/examples/gno.land/r/gov/dao/v2/dao.gno +++ b/examples/gno.land/r/gov/dao/v2/dao.gno @@ -17,7 +17,7 @@ func init() { // Example initial member set (just test addresses) set := []membstore.Member{ { - Address: std.Address("g125em6arxsnj49vx35f0n0z34putv5ty3376fg5"), + Address: std.Address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm"), VotingPower: 10, }, } diff --git a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno index 702181fc9c3..8e102aac81b 100644 --- a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno @@ -79,58 +79,62 @@ func main() { // // ## [Prop #0 - Valset change](/r/gov/dao/v2:0) // -// #### Status: ACTIVE +// **Status: ACTIVE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // // // -- // # Proposal #0 - Valset change // +// ## Description +// // manual valset changes proposal example // // ## Proposal information // -// #### Status: ACTIVE +// **Status: ACTIVE** // -// #### Voting stats: +// **Voting stats:** // - YES 0 (0%) // - NO 0 (0%) // - ABSTAIN 0 (0%) // - MISSING VOTES 10 (100%) // // -// #### Threshold met: FALSE +// **Threshold met: FALSE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // -// ## Actions +// ### Actions // -// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) - [Vote ABSTAIN](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=ABSTAIN) +// #### [[Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES)] - [[Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO)] - [[Vote ABSTAIN](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=ABSTAIN)] // // // -- // -- // # Proposal #0 - Valset change // +// ## Description +// // manual valset changes proposal example // // ## Proposal information // -// #### Status: ACCEPTED +// **Status: ACCEPTED** // -// #### Voting stats: +// **Voting stats:** // - YES 10 (100%) // - NO 0 (0%) // - ABSTAIN 0 (0%) // - MISSING VOTES 0 (0%) // // -// #### Threshold met: TRUE +// **Threshold met: TRUE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // -// ## Actions +// ### Actions // // The voting period for this proposal is over. // @@ -143,24 +147,26 @@ func main() { // -- // # Proposal #0 - Valset change // +// ## Description +// // manual valset changes proposal example // // ## Proposal information // -// #### Status: EXECUTION SUCCESSFUL +// **Status: EXECUTION SUCCESSFUL** // -// #### Voting stats: +// **Voting stats:** // - YES 10 (100%) // - NO 0 (0%) // - ABSTAIN 0 (0%) // - MISSING VOTES 0 (0%) // // -// #### Threshold met: TRUE +// **Threshold met: TRUE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // -// ## Actions +// ### Actions // // The voting period for this proposal is over. // diff --git a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno index 088081d9d90..ef885ddba33 100644 --- a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno @@ -56,58 +56,62 @@ func main() { // // ## [Prop #0 - govdao blog post title](/r/gov/dao/v2:0) // -// #### Status: ACTIVE +// **Status: ACTIVE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // // // -- // # Proposal #0 - govdao blog post title // +// ## Description +// // post a new blogpost about govdao // // ## Proposal information // -// #### Status: ACTIVE +// **Status: ACTIVE** // -// #### Voting stats: +// **Voting stats:** // - YES 0 (0%) // - NO 0 (0%) // - ABSTAIN 0 (0%) // - MISSING VOTES 10 (100%) // // -// #### Threshold met: FALSE +// **Threshold met: FALSE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // -// ## Actions +// ### Actions // -// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) - [Vote ABSTAIN](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=ABSTAIN) +// #### [[Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES)] - [[Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO)] - [[Vote ABSTAIN](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=ABSTAIN)] // // // -- // -- // # Proposal #0 - govdao blog post title // +// ## Description +// // post a new blogpost about govdao // // ## Proposal information // -// #### Status: ACCEPTED +// **Status: ACCEPTED** // -// #### Voting stats: +// **Voting stats:** // - YES 10 (100%) // - NO 0 (0%) // - ABSTAIN 0 (0%) // - MISSING VOTES 0 (0%) // // -// #### Threshold met: TRUE +// **Threshold met: TRUE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // -// ## Actions +// ### Actions // // The voting period for this proposal is over. // @@ -122,24 +126,26 @@ func main() { // -- // # Proposal #0 - govdao blog post title // +// ## Description +// // post a new blogpost about govdao // // ## Proposal information // -// #### Status: EXECUTION SUCCESSFUL +// **Status: EXECUTION SUCCESSFUL** // -// #### Voting stats: +// **Voting stats:** // - YES 10 (100%) // - NO 0 (0%) // - ABSTAIN 0 (0%) // - MISSING VOTES 0 (0%) // // -// #### Threshold met: TRUE +// **Threshold met: TRUE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // -// ## Actions +// ### Actions // // The voting period for this proposal is over. // diff --git a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno index 0ac381a00dc..248ac87b6e7 100644 --- a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno @@ -71,58 +71,62 @@ func main() { // // ## [Prop #0 - new govdao member addition](/r/gov/dao/v2:0) // -// #### Status: ACTIVE +// **Status: ACTIVE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // // // -- // # Proposal #0 - new govdao member addition // +// ## Description +// // add new members to the govdao // // ## Proposal information // -// #### Status: ACTIVE +// **Status: ACTIVE** // -// #### Voting stats: +// **Voting stats:** // - YES 0 (0%) // - NO 0 (0%) // - ABSTAIN 0 (0%) // - MISSING VOTES 10 (100%) // // -// #### Threshold met: FALSE +// **Threshold met: FALSE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // -// ## Actions +// ### Actions // -// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) - [Vote ABSTAIN](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=ABSTAIN) +// #### [[Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES)] - [[Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO)] - [[Vote ABSTAIN](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=ABSTAIN)] // // // -- // -- // # Proposal #0 - new govdao member addition // +// ## Description +// // add new members to the govdao // // ## Proposal information // -// #### Status: ACCEPTED +// **Status: ACCEPTED** // -// #### Voting stats: +// **Voting stats:** // - YES 10 (100%) // - NO 0 (0%) // - ABSTAIN 0 (0%) // - MISSING VOTES 0 (0%) // // -// #### Threshold met: TRUE +// **Threshold met: TRUE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // -// ## Actions +// ### Actions // // The voting period for this proposal is over. // @@ -134,33 +138,35 @@ func main() { // // ## [Prop #0 - new govdao member addition](/r/gov/dao/v2:0) // -// #### Status: ACCEPTED +// **Status: ACCEPTED** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // // // -- // -- // # Proposal #0 - new govdao member addition // +// ## Description +// // add new members to the govdao // // ## Proposal information // -// #### Status: EXECUTION SUCCESSFUL +// **Status: EXECUTION SUCCESSFUL** // -// #### Voting stats: +// **Voting stats:** // - YES 10 (25%) // - NO 0 (0%) // - ABSTAIN 0 (0%) // - MISSING VOTES 30 (75%) // // -// #### Threshold met: FALSE +// **Threshold met: FALSE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // -// ## Actions +// ### Actions // // The voting period for this proposal is over. // @@ -172,9 +178,9 @@ func main() { // // ## [Prop #0 - new govdao member addition](/r/gov/dao/v2:0) // -// #### Status: EXECUTION SUCCESSFUL +// **Status: EXECUTION SUCCESSFUL** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // // // -- diff --git a/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno index 3f39b12798a..5f5e96463df 100644 --- a/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno @@ -42,58 +42,62 @@ func main() { // // ## [Prop #0 - Setting prop1.string param](/r/gov/dao/v2:0) // -// #### Status: ACTIVE +// **Status: ACTIVE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // // // -- // # Proposal #0 - Setting prop1.string param // +// ## Description +// // setting prop1.string param // // ## Proposal information // -// #### Status: ACTIVE +// **Status: ACTIVE** // -// #### Voting stats: +// **Voting stats:** // - YES 0 (0%) // - NO 0 (0%) // - ABSTAIN 0 (0%) // - MISSING VOTES 10 (100%) // // -// #### Threshold met: FALSE +// **Threshold met: FALSE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // -// ## Actions +// ### Actions // -// [Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES) - [Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO) - [Vote ABSTAIN](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=ABSTAIN) +// #### [[Vote YES](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=YES)] - [[Vote NO](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=NO)] - [[Vote ABSTAIN](/r/gov/dao/v2$help&func=VoteOnProposal&id=0&option=ABSTAIN)] // // // -- // -- // # Proposal #0 - Setting prop1.string param // +// ## Description +// // setting prop1.string param // // ## Proposal information // -// #### Status: ACCEPTED +// **Status: ACCEPTED** // -// #### Voting stats: +// **Voting stats:** // - YES 10 (100%) // - NO 0 (0%) // - ABSTAIN 0 (0%) // - MISSING VOTES 0 (0%) // // -// #### Threshold met: TRUE +// **Threshold met: TRUE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // -// ## Actions +// ### Actions // // The voting period for this proposal is over. // @@ -104,24 +108,26 @@ func main() { // -- // # Proposal #0 - Setting prop1.string param // +// ## Description +// // setting prop1.string param // // ## Proposal information // -// #### Status: EXECUTION SUCCESSFUL +// **Status: EXECUTION SUCCESSFUL** // -// #### Voting stats: +// **Voting stats:** // - YES 10 (100%) // - NO 0 (0%) // - ABSTAIN 0 (0%) // - MISSING VOTES 0 (0%) // // -// #### Threshold met: TRUE +// **Threshold met: TRUE** // -// #### Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm +// **Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm** // -// ## Actions +// ### Actions // // The voting period for this proposal is over. diff --git a/examples/gno.land/r/gov/dao/v2/render.gno b/examples/gno.land/r/gov/dao/v2/render.gno index d11a39289f7..02681adaf80 100644 --- a/examples/gno.land/r/gov/dao/v2/render.gno +++ b/examples/gno.land/r/gov/dao/v2/render.gno @@ -108,9 +108,9 @@ func renderAuthor(p dao.Proposal) string { func renderActionBar(p dao.Proposal, idx int) string { var out string - out += "## Actions\n\n" + out += "### Actions\n\n" if p.Status() == dao.Active { - out += ufmt.Sprintf("[Vote YES](%s) - [Vote NO](%s) - [Vote ABSTAIN](%s)", + out += ufmt.Sprintf("#### [[Vote YES](%s)] - [[Vote NO](%s)] - [[Vote ABSTAIN](%s)]", txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "YES"), txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "NO"), txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "ABSTAIN"), From fad63ca9b639e653fd0bdadcf633d8315b03a047 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Fri, 29 Nov 2024 10:47:51 +0100 Subject: [PATCH 33/33] fix tests --- .../gno.land/r/gov/dao/v2/prop1_filetest.gno | 4 - .../gno.land/r/gov/dao/v2/prop2_filetest.gno | 4 - .../gno.land/r/gov/dao/v2/prop3_filetest.gno | 4 - .../gno.land/r/gov/dao/v2/prop4_filetest.gno | 79 +------------------ examples/gno.land/r/gov/dao/v2/render.gno | 2 +- 5 files changed, 3 insertions(+), 90 deletions(-) diff --git a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno index c09a04bd494..7d8975e1fe8 100644 --- a/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop1_filetest.gno @@ -139,8 +139,6 @@ func main() { // The voting period for this proposal is over. // // -// -// // -- // No valset changes to apply. // -- @@ -171,8 +169,6 @@ func main() { // The voting period for this proposal is over. // // -// -// // -- // Valset changes: // - #123: g12345678 (10) diff --git a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno index d5be8b619f2..84a64bc4ee2 100644 --- a/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop2_filetest.gno @@ -116,8 +116,6 @@ func main() { // The voting period for this proposal is over. // // -// -// // -- // # gno.land's blog // @@ -150,8 +148,6 @@ func main() { // The voting period for this proposal is over. // // -// -// // -- // # gno.land's blog // diff --git a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno index 248ac87b6e7..068f520e7e2 100644 --- a/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop3_filetest.gno @@ -131,8 +131,6 @@ func main() { // The voting period for this proposal is over. // // -// -// // -- // # GovDAO Proposals // @@ -171,8 +169,6 @@ func main() { // The voting period for this proposal is over. // // -// -// // -- // # GovDAO Proposals // diff --git a/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno b/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno index 5f5e96463df..13ca572c512 100644 --- a/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno +++ b/examples/gno.land/r/gov/dao/v2/prop4_filetest.gno @@ -102,8 +102,6 @@ func main() { // The voting period for this proposal is over. // // -// -// // -- // -- // # Proposal #0 - Setting prop1.string param @@ -130,78 +128,5 @@ func main() { // ### Actions // // The voting period for this proposal is over. - -// Events: -// [ -// { -// "type": "ProposalAdded", -// "attrs": [ -// { -// "key": "proposal-id", -// "value": "0" -// }, -// { -// "key": "proposal-author", -// "value": "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" -// } -// ], -// "pkg_path": "gno.land/r/gov/dao/v2", -// "func": "EmitProposalAdded" -// }, -// { -// "type": "VoteAdded", -// "attrs": [ -// { -// "key": "proposal-id", -// "value": "0" -// }, -// { -// "key": "author", -// "value": "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm" -// }, -// { -// "key": "option", -// "value": "YES" -// } -// ], -// "pkg_path": "gno.land/r/gov/dao/v2", -// "func": "EmitVoteAdded" -// }, -// { -// "type": "ProposalAccepted", -// "attrs": [ -// { -// "key": "proposal-id", -// "value": "0" -// } -// ], -// "pkg_path": "gno.land/r/gov/dao/v2", -// "func": "EmitProposalAccepted" -// }, -// { -// "type": "set", -// "attrs": [ -// { -// "key": "k", -// "value": "prop1.string" -// } -// ], -// "pkg_path": "gno.land/r/sys/params", -// "func": "" -// }, -// { -// "type": "ProposalExecuted", -// "attrs": [ -// { -// "key": "proposal-id", -// "value": "0" -// }, -// { -// "key": "exec-status", -// "value": "accepted" -// } -// ], -// "pkg_path": "gno.land/r/gov/dao/v2", -// "func": "ExecuteProposal" -// } -// ] +// +// diff --git a/examples/gno.land/r/gov/dao/v2/render.gno b/examples/gno.land/r/gov/dao/v2/render.gno index 02681adaf80..4cca397e851 100644 --- a/examples/gno.land/r/gov/dao/v2/render.gno +++ b/examples/gno.land/r/gov/dao/v2/render.gno @@ -116,7 +116,7 @@ func renderActionBar(p dao.Proposal, idx int) string { txlink.URL("VoteOnProposal", "id", strconv.Itoa(idx), "option", "ABSTAIN"), ) } else { - out += "The voting period for this proposal is over.\n\n" + out += "The voting period for this proposal is over." } return out