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

Make it possible to get raw bytes back from dynamic constant/storage queries #680

Merged
merged 1 commit into from
Oct 6, 2022

Conversation

jsdw
Copy link
Collaborator

@jsdw jsdw commented Oct 3, 2022

When you make a dynamic storage or constant query at the moment, you get back a Value. In some cases, you might just want the raw SCALE bytes back to do as you wish with (eg here: https://github.com/paritytech/staking-miner-v2/pull/387/files#diff-6e448cdd99756118d32afe57b3d7d260cb1626cdbdbace46a91f1f9d20aabd4eR118.).

This PR makes dynamic things decode into this intermediate DecodedValueThunk type, from which you can either finish decoding into a value with .to_value() or access the bytes with .to_encoded() to do as you wish with instead.

@jsdw jsdw changed the title Add DecodedValueThunk to allow getting bytes back from dynamic queries Make it possible to get raw bytes back from dynamic queries Oct 3, 2022
@jsdw jsdw changed the title Make it possible to get raw bytes back from dynamic queries Make it possible to get raw bytes back from dynamic constant/storage queries Oct 3, 2022
@jsdw
Copy link
Collaborator Author

jsdw commented Oct 3, 2022

@niklasad1 perhaps this helps avoid a case of having to SCALE encode the storage thing to bytes in staking-miner; it makes sense to me that you can just retrieve the bytes directly anyway for these calls (you already can get the bytes for events and transactions at each stage afterall).

Copy link
Member

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

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

nice, LGTM

I don't understand why full-md.scale and stripped-md.scale were committed though

@jsdw
Copy link
Collaborator Author

jsdw commented Oct 4, 2022

Ah whoops; I didn't notice those! I'll reset and get rid of them!

Copy link
Contributor

@ascjones ascjones left a comment

Choose a reason for hiding this comment

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

Good stuff, I was missing something like this when experimenting with it.

@jsdw jsdw merged commit 98af356 into master Oct 6, 2022
@jsdw jsdw deleted the jsdw-dynamic-value-thunk branch October 6, 2022 08:58
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.

None yet

3 participants