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

feat: Initialize blockchain interface by default #450

Merged
merged 2 commits into from
Jun 28, 2021

Conversation

austinabell
Copy link
Contributor

@austinabell austinabell commented Jun 25, 2021

Made changes based on #417 because it removes BLOCKCHAIN_INTERFACE from non-wasm32 environments, and this default only makes sense outside anyway.

One part of #440, going to split up changes because other ideas I have are more opinionated/breaking.

This change is completely backwards compatible from #417 and I changed only some of the examples to show this.

Ideally, in the future, it would be possible to modify the context of the mocked blockchain in place instead of still rigidly constructing a new context and replacing the current one, which will come with more QOL improvements.

Comment on lines -90 to -93
use near_sdk::MockedBlockchain;
use near_sdk::{testing_env, VMContext};

fn get_context(input: Vec<u8>, is_view: bool) -> VMContext {
Copy link
Member

Choose a reason for hiding this comment

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

So by having a default mocked blockchain, we don't have to go thru the shenanigans of setting up the context here and also explicitly using testing_env! right? This is pretty nice for setting up new tests 👍.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, you still need it if you need to configure anything, but if not this saves some boilerplate.

Ideally, I think it might be nice to just be able to modify the context in place rather than replacing it, but there are a lot of connected pieces rn.

Copy link
Member

@ChaoticTempest ChaoticTempest left a comment

Choose a reason for hiding this comment

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

👍

@mikedotexe mikedotexe merged commit 3830cd2 into austin/extract_vmlogic Jun 28, 2021
@mikedotexe mikedotexe deleted the austin/default_bcinterface branch June 28, 2021 20:24
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