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

Allow contract Info query from the contract #584

Closed
alpe opened this issue Aug 5, 2021 · 6 comments · Fixed by #622
Closed

Allow contract Info query from the contract #584

alpe opened this issue Aug 5, 2021 · 6 comments · Fixed by #622
Milestone

Comments

@alpe
Copy link
Contributor

alpe commented Aug 5, 2021

This idea comes originally from https://github.com/terra-money/core/issues/519

@alpe alpe added this to the v1.0.0 milestone Aug 5, 2021
@ethanfrey ethanfrey modified the milestones: v1.0.0, 0.19.0 Aug 16, 2021
@ethanfrey
Copy link
Member

Let's discuss if we want to do this.
If so, I would push it to a 0.19.0 release and only have gas adjustments before the final 1.0

@alpe
Copy link
Contributor Author

alpe commented Aug 16, 2021

IMHO it makes sense to provide this information via query. I don't have a concrete use case but contracts would be compatible between chains. It is not hard to build and this data may enable some exotic workflows where the some other contract's creator/admin could be used for authZ. 🤷‍♀️

This would have been nice contribution by terra devs

@husio
Copy link
Contributor

husio commented Aug 23, 2021

I will take this task if that is ok. I think this is a great first issue, because I will write my first VM interaction code and a contract that validates introduced modification.

Please let me know if I understand the task correctly: wasmd (keeper->query) must be modified to support an additional call that returns "self" info. In other words, a contract can query information about itself only (not other contracts). Query call is done via JSON encoded message. Is this correct?

To test it, I should write a contract that executes a new query call. Contracts are currently implemented only in rust. Should I modify the existing hackatom and add another switch to it?

@alpe
Copy link
Contributor Author

alpe commented Aug 23, 2021

In wasmd new "native" queries can be added to the query_plugins.go. This new one can go into the
"wasm" section. You will notice that the wasmvm queries do not support this query type yet. For local testing you can use a branch and add the object

a contract can query information about itself only (not other contracts)

Let's not limit this and query any ContractInfo

To test it, I should write a contract that executes a new query call

That would give us most confidence but is too complex to start with. Especially as the bindings are not done yet.
When the request/ response types are defined (by you), let's have some unit tests to cover the wasmd (only) parts

@ethanfrey
Copy link
Member

ethanfrey commented Aug 23, 2021

I would honestly wait until there was agreement with cosmwasm team as to if and how the QueryRequest object would be modified.

You can write something, but it is hard to integrate or even do full testing until there is clear spec

@assafmo
Copy link
Contributor

assafmo commented Sep 21, 2021

This would be very useful for us! on Secret Network when contract A sends a message to contract B, for security reasons A must know B's data hash.

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 a pull request may close this issue.

4 participants