-
Notifications
You must be signed in to change notification settings - Fork 44
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!: implement new treasury account #1067
Conversation
Codecov ReportBase: 80.23% // Head: 80.38% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #1067 +/- ##
==========================================
+ Coverage 80.23% 80.38% +0.14%
==========================================
Files 176 179 +3
Lines 15427 15604 +177
==========================================
+ Hits 12378 12543 +165
- Misses 2508 2516 +8
- Partials 541 545 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
} | ||
|
||
// getStakeAuthorization returns a send authorization from the given command flags | ||
func getSendAuthorization(flags *pflag.FlagSet) (*banktypes.SendAuthorization, error) { |
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.
I guess this method and the other ones are all copy/pasted from the Cosmos SDK. Do you think we should make them public inside our fork instead? This way we don't need to re-write them here but we can simply rely on those. We could also upstreami this change to the Cosmos SDK repo so that they are by default public for everyone to use
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.
Yes, it is better that we make it public in our Cosmos-SDK fork. I created a pull request in that repo:
desmos-labs/cosmos-sdk#148
After the authz change merged into our fork and is released, we can apply the feature in this PR.
require.Equal(t, types.NewSubspace( | ||
1, | ||
"name", | ||
"description", | ||
"cosmos1cyjzgj9j7d2gdqk78pa0fgvfnlzradat97aek9", | ||
"cosmos10ya9y35qkf4puaklx5fs07sxfxqncx9usgsnz6", | ||
"cosmos10ya9y35qkf4puaklx5fs07sxfxqncx9usgsnz6", | ||
time.Date(2023, 1, 11, 1, 1, 1, 1, time.UTC), | ||
), newSubspace) |
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.
Can we use types.SubspaceTreasuryAddress
here instead of a text value? This way we can make sure the address is generated properly inside the migration code by calling the same function
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.
We should remain text generated by current method, it would detect the change and make sure the migration always working properly if types.GetTreasuryAddress
or authtypes.NewModuleAddress
are changed.
x/subspaces/types/models_test.go
Outdated
@@ -583,3 +581,7 @@ func TestUserGroup_Update(t *testing.T) { | |||
}) | |||
} | |||
} | |||
|
|||
func TestGetTreasuryAddress(t *testing.T) { | |||
require.Equal(t, "cosmos1cyjzgj9j7d2gdqk78pa0fgvfnlzradat97aek9", types.GetTreasuryAddress(1).String()) |
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.
I believe we should test this method more properly. Ideally, what we could do is:
- Generate a list of subspace ids
- For each subspace id, generate the treasury address
- Check that the generated addresses are all different from one another
This will make sure that we are not only always testing one case (SubspaceID: 1
) but we are actually proving the generation method works for every subspace id
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.
Applied
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
Co-authored-by: Riccardo <riccardo.montagnin@gmail.com>
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.
Looks good to me! Great job 💯
@dadamu Can you just add a changelog entry for this change please? |
Description
Closes: #XXXX
This PR implements ADR-018 to apply the new treasury account structure and its methods.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change