-
Notifications
You must be signed in to change notification settings - Fork 15
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
Refactor Sandbox #84
Refactor Sandbox #84
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the direction of this changes, that would finally allow to work freely with any runtime, not only for contract purposes, but for general interaction as well
if I understand the intention correctly, the idea is that:
Sandbox
essentially wraps externalities and has a generic argument for a runtime, which can be actually anyhow configured- depending on this generic argument,
Sandbox
enables pallet-specific operations, but not through traits (like ChainApi
andContractApi
), but rather through generic bounds
is that so?
Yes. That's pretty much what Sandbox was doing already (as far as I understand). |
Addressed your comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you very much for this contribution!
examples/mocking/lib.rs
Outdated
@@ -61,7 +61,7 @@ mod tests { | |||
ContractMock::new().with_message(CALLEE_SELECTOR, mock_message(|()| RETURN_VALUE)); | |||
|
|||
// Secondly, we deploy it, similarly to a standard deployment action. | |||
let mock_address = session.mocking_api().deploy(mocked_contract); | |||
let mock_address = session.sandbox().deploy(mocked_contract); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a regression that users now have to even know about the Sandbox
. It was supposed to be a low-level object and developers use high-level session
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah right this is indeed a bit confusing without the "mocking_api" name
will update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not only about the name - name is just a "gate" into the Sandbox
world. Of course, we can't stop users from using it, if they want, but I think the API should lead developer through the path of least resistance and suggest usage of simple constructs.
I'd prefer to leave the previous approach, if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue here is that the mock utilities should not be tied to the Sandbox struct.
I restored the API and moved these props to the session in the last commit.
lmk what you think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks :)
de761ac
to
a8034a1
Compare
@deuszx @pmikolajczyk41 not sure what kind of approval is required to trigger CI here, you mind re-approving so we can merge this asap? |
This PR does the following refactoring, to prepare further update that will make it easier to integrate Drink with a Network of chains connected through XCM:
Specifically it does the following:
For example token APIs only require the Sandbox to be generic over something that implement pallet_contracts