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

Instantiate DAO with existing staking contract #189

Merged
merged 1 commit into from
Mar 17, 2022

Conversation

Callum-A
Copy link
Collaborator

@Callum-A Callum-A commented Mar 6, 2022

We now have an added enum in instantiate to create a DAO with an existing staking contract.

  • Similar to how we handle CW20s.
  • If we instantiate a new CW20 the contract will error if the user specifies to use an existing staking contract. As this action is invalid
  • Existing CW20s can use both a new staking contract or an older one
  • Test cases cover all possible combinations

Feedback appreciated.

@Callum-A Callum-A requested review from JakeHartnell and 0xekez March 6, 2022 12:29
Validate the existing staking contract is a staking contract
@Callum-A Callum-A force-pushed the callum/existing_staking_contract branch from 5c84989 to 0dba0a6 Compare March 7, 2022 23:26
Copy link
Contributor

@0xekez 0xekez left a comment

Choose a reason for hiding this comment

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

This is great, as always. :) Thanks for the tests.

One thought: right now we're doing a check to make sure we're not using an existing staking contract with a new cw20 in reply. We could avoid needing to do that by making that configuration an invalid instantiate message.

For example, we could combine the cw20 and staking information into an enum which enumerates the valid configurations. Invalid messages would then fail to deserialize and mean we wouldn't have to make those checks.

I'm happy with this current setup, but if you're feeling fancy that would be nice.

@Callum-A
Copy link
Collaborator Author

Callum-A commented Mar 9, 2022

This is great, as always. :) Thanks for the tests.

One thought: right now we're doing a check to make sure we're not using an existing staking contract with a new cw20 in reply. We could avoid needing to do that by making that configuration an invalid instantiate message.

For example, we could combine the cw20 and staking information into an enum which enumerates the valid configurations. Invalid messages would then fail to deserialize and mean we wouldn't have to make those checks.

I'm happy with this current setup, but if you're feeling fancy that would be nice.

Just to clarify what you mean by this.

Would this mean replacing the two enums we currently have in the instantiate method with one with three valid possibilities which are:

  • New Staking - New Token
  • New Staking - Existing Token
  • Existing Staking - Existing Token

@0xekez
Copy link
Contributor

0xekez commented Mar 9, 2022

New Staking - New Token
New Staking - Existing Token
Existing Staking - Existing Token

This is what I was imagining. Happy to just merge this as is though. Having it written out seems like the size of that enum might make it a little cumbersome. I can think more about this with the new contracts. :)

@Callum-A
Copy link
Collaborator Author

Callum-A commented Mar 9, 2022

This is what I was imagining. Happy to just merge this as is though. Having it written out seems like the size of that enum might make it a little cumbersome. I can think more about this with the new contracts. :)

I agree the enum names might become unwieldly. Happy for other inputs on this however.

@Callum-A Callum-A requested a review from JakeHartnell March 16, 2022 23:46
Copy link
Member

@JakeHartnell JakeHartnell left a comment

Choose a reason for hiding this comment

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

LGTM

@JakeHartnell JakeHartnell merged commit 4a65c56 into main Mar 17, 2022
@JakeHartnell JakeHartnell deleted the callum/existing_staking_contract branch March 17, 2022 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants