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

Move ScVal<>RawVal conversion to common #81

Merged
merged 17 commits into from
Jul 22, 2022
Merged

Conversation

leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented May 24, 2022

What

Move ScVal<>RawVal conversion out of the host and into common.

Why

The host does not need to own conversion between these types as conversion between these types is mostly independent of the host. The host does need to be able to map objects into object handles though and the Host can provide an implementation of the trait for doing that.

While I was working on the CLI I need to be able to convert between these values, and so I at least need to make public the functions for doing the conversions. Moving them out into common felt natural.

Close #106

Known limitations

N/A

@leighmcculloch leighmcculloch marked this pull request as draft May 24, 2022 19:09
@leighmcculloch leighmcculloch marked this pull request as ready for review May 24, 2022 19:25
@leighmcculloch leighmcculloch marked this pull request as draft May 24, 2022 19:36
@leighmcculloch
Copy link
Member Author

Ugh, I got pretty lost doing this and turns out I don't need it. But maybe it is still useful for some other reason to get the RawVal <> ScVal conversion outside the Host? Thoughts @graydon?

@leighmcculloch leighmcculloch deleted the scval-rawval-conv branch May 24, 2022 20:14
@leighmcculloch leighmcculloch restored the scval-rawval-conv branch May 24, 2022 20:14
@leighmcculloch leighmcculloch deleted the scval-rawval-conv branch May 24, 2022 20:16
@leighmcculloch leighmcculloch restored the scval-rawval-conv branch June 9, 2022 02:50
@leighmcculloch leighmcculloch reopened this Jun 9, 2022
@graydon
Copy link
Contributor

graydon commented Jun 9, 2022

I think I'm ok with this .. need to study in a little more detail tomorrow, too wiped out tonight.

@leighmcculloch leighmcculloch marked this pull request as ready for review July 21, 2022 22:14
} else if tag_static.is_type(ScStatic::LedgerKeyContractCodeWasm) {
Ok(ScVal::Static(ScStatic::LedgerKeyContractCodeWasm))
} else {
Err(ConversionError)
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately because these conversion can be used outside the host they can no longer return nice meaningful host errors. I don't see a way around this, so I'm going to press ahead with this, and maybe we can improve it somehow. Lmk if you see a way.

cc @graydon

Copy link
Contributor

Choose a reason for hiding this comment

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

I put a lot of machinery for richer errors in EnvBase over in #243, maybe it's usable here?

@leighmcculloch leighmcculloch marked this pull request as draft July 21, 2022 22:32
@leighmcculloch leighmcculloch marked this pull request as ready for review July 22, 2022 00:15
Copy link
Contributor

@graydon graydon left a comment

Choose a reason for hiding this comment

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

LGTM

@leighmcculloch leighmcculloch merged commit 71d23e4 into main Jul 22, 2022
@leighmcculloch leighmcculloch deleted the scval-rawval-conv branch July 22, 2022 00:39
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.

Test Fwk: Add conversions for ScVal<=>Into<RawVal>
2 participants