-
Notifications
You must be signed in to change notification settings - Fork 254
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
Call a contract #165
Call a contract #165
Conversation
# Conflicts: # src/frame/contracts.rs
This looks interesting. I get |
Yeah the contracts module is not included in the test runtime at the moment. We could consider adding it, at the cost of increasing complexity of the test node. But it does beg the question as to whether we should add all modules to that, in which case it would just become |
Agreed. I'm fine with a heavy-handed interim solution. Can you spell out the pros/cons to using the whole |
Well now that there exists tagged releases of So pros: don't need a dependency, or to compile the maintain the whole node runtime. Cons: some CI setup. I think it could work: #169. |
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.
Good stuff. I think the account generation and nonce handling stuff is useful enough to warrant making it available to other code as well; can be done in a diff PR though.
src/frame/contracts.rs
Outdated
@@ -115,44 +116,164 @@ pub struct InstantiatedEvent<T: Contracts> { | |||
pub contract: <T as System>::AccountId, | |||
} | |||
|
|||
/// Contract execution event. | |||
/// | |||
/// Raised upon successful executionFailing of a contract call |
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.
/// Raised upon successful executionFailing of a contract call | |
/// Emitted upon successful execution/failure of a contract call |
src/frame/contracts.rs
Outdated
pub struct ContractExecutionEvent<T: Contracts> { | ||
/// Caller of the contract. | ||
pub caller: <T as System>::AccountId, | ||
/// Raw contract event data |
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.
Is this SCALE encoded data that is runtime dependent or can we say anything at all about the content?
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.
The data is the encoded contract event, I will update the comment
src/frame/contracts.rs
Outdated
.unwrap() | ||
.nonce; | ||
let local_nonce = STASH_NONCE | ||
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(x + 1)) |
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.
Why not fetch_add()
?
} | ||
|
||
impl TestContext { | ||
async fn init() -> Self { |
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 this is useful enough that it might be worth making it generic over the runtime and put it in a test-utils.rs
for use in other places.
} | ||
|
||
/// generate a new keypair for an account, and fund it so it can perform smart contract operations | ||
async fn generate_account( |
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.
Same as above: consider making this available to other code.
|
* master: Call a contract (#165)
* Upgrade to substrate 2.0.0 * WIP implement Subcommand manually (see paritytech/substrate#6894 (comment)) * Add pallet-staking/std to the std feature * Sort out the subcommand impl * Sort out the module index (ty @ascjones) Sort out the RefCount type (ty @dvc94ch) Random tweaks to make test-node more similar to the vanilla node-template * obey the fmt * Add changelog and bump versions * Merge #165 and update CHANGELOG * Update test-node/runtime/src/lib.rs Co-authored-by: Demi Marie Obenour <demiobenour@gmail.com> * Update CHANGELOG.md Co-authored-by: Demi Marie Obenour <demiobenour@gmail.com> Co-authored-by: Demi Marie Obenour <demiobenour@gmail.com>
Make the contract call extrinsic work, and update the contracts tests so they can run in parallel and all succeed.
Note: the contracts tests require a node-template based runtime with contracts enabled running.