Skip to content
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

Merged
merged 37 commits into from
Jan 17, 2023
Merged

feat!: implement new treasury account #1067

merged 37 commits into from
Jan 17, 2023

Conversation

dadamu
Copy link
Contributor

@dadamu dadamu commented Jan 11, 2023

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...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

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...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@github-actions github-actions bot added kind/build Related to the build of the project x/CLI x/subspaces Issue on the x/subspaces module labels Jan 11, 2023
@github-actions github-actions bot added x/profiles Module that allows to create and manage decentralized social profiles x/relationships labels Jan 12, 2023
@codecov
Copy link

codecov bot commented Jan 12, 2023

Codecov Report

Base: 80.23% // Head: 80.38% // Increases project coverage by +0.14% 🎉

Coverage data is based on head (0cd9823) compared to base (8c9058b).
Patch coverage: 93.75% of modified lines in pull request are covered.

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     
Impacted Files Coverage Δ
x/subspaces/types/msgs.go 98.29% <ø> (-0.03%) ⬇️
x/subspaces/types/permissions.go 77.77% <ø> (ø)
x/subspaces/types/codec.go 58.82% <60.00%> (+0.12%) ⬆️
x/subspaces/keeper/alias_functions.go 81.25% <75.00%> (-0.24%) ⬇️
x/subspaces/legacy/v5/store.go 89.28% <89.28%> (ø)
x/subspaces/keeper/msg_server_treasury.go 95.89% <95.89%> (ø)
x/subspaces/types/msgs_treasury.go 96.77% <96.77%> (ø)
app/app.go 88.04% <100.00%> (ø)
x/subspaces/keeper/keeper.go 100.00% <100.00%> (ø)
x/subspaces/keeper/msg_server.go 88.41% <100.00%> (+0.05%) ⬆️
... and 4 more

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dadamu dadamu marked this pull request as ready for review January 12, 2023 14:43
@dadamu dadamu requested a review from a team as a code owner January 12, 2023 14:43
Makefile Show resolved Hide resolved
}

// getStakeAuthorization returns a send authorization from the given command flags
func getSendAuthorization(flags *pflag.FlagSet) (*banktypes.SendAuthorization, error) {
Copy link
Contributor

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

Copy link
Contributor Author

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.

x/subspaces/keeper/alias_functions.go Outdated Show resolved Hide resolved
x/subspaces/keeper/alias_functions.go Outdated Show resolved Hide resolved
x/subspaces/keeper/msg_server_treasury.go Outdated Show resolved Hide resolved
x/subspaces/keeper/msg_server_treasury_test.go Outdated Show resolved Hide resolved
x/subspaces/keeper/msg_server_treasury_test.go Outdated Show resolved Hide resolved
x/subspaces/legacy/v3/store.go Show resolved Hide resolved
Comment on lines +68 to +76
require.Equal(t, types.NewSubspace(
1,
"name",
"description",
"cosmos1cyjzgj9j7d2gdqk78pa0fgvfnlzradat97aek9",
"cosmos10ya9y35qkf4puaklx5fs07sxfxqncx9usgsnz6",
"cosmos10ya9y35qkf4puaklx5fs07sxfxqncx9usgsnz6",
time.Date(2023, 1, 11, 1, 1, 1, 1, time.UTC),
), newSubspace)
Copy link
Contributor

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

Copy link
Contributor Author

@dadamu dadamu Jan 17, 2023

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.

@@ -583,3 +581,7 @@ func TestUserGroup_Update(t *testing.T) {
})
}
}

func TestGetTreasuryAddress(t *testing.T) {
require.Equal(t, "cosmos1cyjzgj9j7d2gdqk78pa0fgvfnlzradat97aek9", types.GetTreasuryAddress(1).String())
Copy link
Contributor

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:

  1. Generate a list of subspace ids
  2. For each subspace id, generate the treasury address
  3. 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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied

dadamu and others added 15 commits January 17, 2023 14:19
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>
Copy link
Contributor

@RiccardoM RiccardoM left a 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 💯

@RiccardoM RiccardoM added the automerge Automatically merge PR once all prerequisites pass label Jan 17, 2023
@RiccardoM
Copy link
Contributor

@dadamu Can you just add a changelog entry for this change please?

@mergify mergify bot merged commit 8981600 into master Jan 17, 2023
@mergify mergify bot deleted the paul/new-treasury-impl branch January 17, 2023 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge PR once all prerequisites pass kind/build Related to the build of the project x/CLI x/profiles Module that allows to create and manage decentralized social profiles x/relationships x/subspaces Issue on the x/subspaces module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants