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

Fix trait to be compatible for custom modules #77

Closed
wants to merge 15 commits into from
Closed

Fix trait to be compatible for custom modules #77

wants to merge 15 commits into from

Conversation

dadamu
Copy link

@dadamu dadamu commented Aug 5, 2022

Currently, CustomMsg isn't the cosmwasm-std version and CustomQuery is not imported, it makes the current version is not compatible for custom modules, like x/profiles in Desmos chain. In addition, any messages to the contract should not be CustomMsg since they are not for the custom modules, they should be DeserializeOwned, instead.
This PR intends to fix the issues mentioned above.

Comment on lines 22 to 23
E1: DeserializeOwned,
E2: DeserializeOwned,
Copy link
Author

@dadamu dadamu Aug 5, 2022

Choose a reason for hiding this comment

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

E1 is the execution message and E2 is the execution query message to the contract. They are the messages to the contract but not to the chain custom modules, so they are set as DeserializeOwned.

{
pub fn instantiate(
&self,
deps: DepsMut,
deps: DepsMut<Q>,
Copy link
Author

Choose a reason for hiding this comment

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

Assigning CustomQuery to all the Deps in order to make communication to the custom modules available.

@JakeHartnell JakeHartnell requested review from orkunkl, JakeHartnell, Callum-A, cypherape, 0xekez, shanev and yubrew and removed request for orkunkl August 18, 2022 00:34
Copy link
Collaborator

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

Great idea to include this! Just a comment about giving the new generics proper names and setting them to the same defaults cosmwasm_std does.

Comment on lines 21 to 25
T: Serialize + DeserializeOwned + Clone,
E1: DeserializeOwned,
E2: DeserializeOwned,
C: CustomMsg,
E: CustomMsg,
Q: CustomMsg,
Q: CustomQuery,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is going to need to get rebased on this change which also changes these generic names: #75

How would you feel about giving Q here a more descriptive name? DepsQueryExt?

Copy link
Author

Choose a reason for hiding this comment

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

I would name Q into ModuleQuery and C into ModuleMsg. What do you think?

@@ -77,16 +80,16 @@ where
}

// TODO pull this into some sort of trait extension??
impl<'a, T, C, E, Q> Cw721Contract<'a, T, C, E, Q>
impl<'a, T, E1, E2, C, Q> Cw721Contract<'a, T, E1, E2, C, Q>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
impl<'a, T, E1, E2, C, Q> Cw721Contract<'a, T, E1, E2, C, Q>
impl<'a, T, E1, E2, C, Q> Cw721Contract<'a, T, E1, E2, C, Q = Empty>

How about giving this the same default value as CosmWasm does?

Copy link
Author

@dadamu dadamu Aug 23, 2022

Choose a reason for hiding this comment

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

Yeah, it would be great adding default on its struct.

Comment on lines 18 to 19
C: CustomMsg,
Q: CustomQuery,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
C: CustomMsg,
Q: CustomQuery,
ModuleLevelCustomMsg: CustomMsg = Empty,
ModuleLevelCustomQuery: CustomQuery = Empty,

@dadamu dadamu requested review from 0xekez and removed request for orkunkl, JakeHartnell, Callum-A, cypherape, shanev and yubrew August 23, 2022 10:56
@dadamu
Copy link
Author

dadamu commented Sep 27, 2022

Rebased.

@dadamu
Copy link
Author

dadamu commented Nov 25, 2022

Updated to main branch, any updates for it? @0xekez

@dadamu
Copy link
Author

dadamu commented Dec 9, 2022

Updated to main branch, any updates for it? @0xekez

@desmos-labs desmos-labs closed this by deleting the head repository Feb 23, 2024
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