-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: lock token transfer and parameter module #3176
Open
piux2
wants to merge
10
commits into
gnolang:master
Choose a base branch
from
piux2:feat_lock_transfer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2279644
feat: lock token transfer and parameter module
piux2 c293926
chores: ufmt
piux2 3591b39
addressed comments
piux2 c84c819
merge master
piux2 5cecf36
merge master
piux2 599e64a
fmt
piux2 b7f317a
fix test
piux2 41d1633
lint
piux2 9fd24d5
fix test
piux2 9f05d03
gno tidy
piux2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
module gno.land/r/nemanya/config | ||
module gno.land/r/nemanya/config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
module gno.land/r/nemanya/home | ||
module gno.land/r/nemanya/home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package params | ||
|
||
import ( | ||
"std" | ||
|
||
"gno.land/p/demo/dao" | ||
"gno.land/r/gov/dao/bridge" | ||
) | ||
|
||
const ( | ||
lockSendKey = "lockSend.bool" | ||
UnlockSendTitle = "Proposal to unlock the sending functionality for ugnot." | ||
LockSendTitle = "Proposal to lock the sending functionality for ugnot." | ||
) | ||
|
||
func ProposeUnlockSend() uint64 { | ||
callback := func() error { | ||
std.SetParamBool(lockSendKey, false) | ||
return nil | ||
} | ||
return propose(callback, UnlockSendTitle, "") | ||
} | ||
|
||
func ProposeLockSend() uint64 { | ||
callback := func() error { | ||
std.SetParamBool(lockSendKey, true) | ||
return nil | ||
} | ||
return propose(callback, LockSendTitle, "") | ||
} | ||
|
||
func propose(callback func() error, title, desc string) uint64 { | ||
// The callback function is executed only after the proposal is voted on | ||
// and approved by the GovDAO. | ||
exe := bridge.GovDAO().NewGovDAOExecutor(callback) | ||
prop := dao.ProposalRequest{ | ||
Title: title, | ||
Description: desc, | ||
Executor: exe, | ||
} | ||
return bridge.GovDAO().Propose(prop) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package params | ||
|
||
import ( | ||
"testing" | ||
|
||
"gno.land/p/demo/dao" | ||
"gno.land/p/demo/simpledao" | ||
"gno.land/p/demo/urequire" | ||
"gno.land/r/gov/dao/bridge" | ||
) | ||
|
||
func TestProUnlockSend(t *testing.T) { | ||
govdao := bridge.GovDAO() | ||
id := ProposeUnlockSend() | ||
p, err := govdao.GetPropStore().ProposalByID(id) | ||
urequire.NoError(t, err) | ||
urequire.Equal(t, UnlockSendTitle, p.Title()) | ||
} | ||
|
||
func TestFailUnlockSend(t *testing.T) { | ||
govdao := bridge.GovDAO() | ||
id := ProposeUnlockSend() | ||
urequire.PanicsWithMessage( | ||
t, | ||
simpledao.ErrProposalNotAccepted.Error(), | ||
func() { | ||
govdao.ExecuteProposal(id) | ||
}, | ||
) | ||
} | ||
|
||
func TestExeUnlockSend(t *testing.T) { | ||
govdao := bridge.GovDAO() | ||
id := ProposeUnlockSend() | ||
p, err := govdao.GetPropStore().ProposalByID(id) | ||
urequire.NoError(t, err) | ||
urequire.True(t, dao.Active == p.Status()) | ||
|
||
govdao.VoteOnProposal(id, dao.YesVote) | ||
urequire.True(t, dao.Accepted == p.Status()) | ||
urequire.NotPanics( | ||
t, | ||
func() { | ||
govdao.ExecuteProposal(id) | ||
}, | ||
) | ||
|
||
urequire.True(t, dao.ExecutionSuccessful == p.Status()) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should standardize errors like these, to avoid having to import
simpledao
?It would mean that the dao package would need to know about specific implementation details like errors, so I'm not sure if this is the way to go
cc @moul
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, GovDAO is a wrapper around the SimpleDAO. All voting and proposal functionality are implemented in SimpleDAO. I'm not sure if using the proposal errors defined in SimpleDAO will cause any issues down the line unless we decide to flatten the GovDAO implementation and stop wrapping the SimpleDAO package entirely.
On the other hand, whether GovDAO should be implemented as a SimpleDAO wrapper or not can be a separate topic.