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

Add support for saving debugging messages, generic queriers #55

Merged
merged 3 commits into from
Oct 31, 2022

Conversation

ouiliame
Copy link
Contributor

We add a new property debugMsgs: string[] to VMInstance, to which contract calls to deps.api.debug(...) will append. Previously, we simply printed the string out to console (which matches the behavior of cosmwasm-vm-js); however this is harder to work with for consuming applications like CWSimulate.

The old implementation for BasicQuerier was temporary and designed to only handle 1 case (in the tests), this adds generic support for query_chain. You must now subclass BasicQuerier and supply your own handleQuery() function, which will get passed the decoded query request. BasicQuerier.query_raw() will delegate and handle the proper encoding of BasicQuerier.handleQuery(), which is toUint8Array({ ok: { ok: toBase64(response) } }), where response is a JSON object containing the query response.

In the future, we will need to provide support for Rust errors, because the Ok(Ok(response)) corresponds to SystemResult<ContractResult<Binary>> (Binary is a CosmWasm Rust type that encodes a struct to Base64 strings in JSON).

@lukedawilson lukedawilson merged commit 3cf396f into main Oct 31, 2022
@lukedawilson lukedawilson deleted the feat/debug-msgs branch October 31, 2022 11: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.

2 participants