-
Notifications
You must be signed in to change notification settings - Fork 2.7k
contracts: add events to ContractResult #13807
Changes from 23 commits
47200ff
a534758
28a9643
cf43686
08db645
7ca1b4b
5ad0868
dbd8735
1718400
782aba7
74d4b70
45e6eab
4426bbe
0de45b6
8d36e91
02c41d3
5d4fd5c
b9cb4ef
a8b0c8b
160cfb3
dacdc53
e7fa394
337e54e
b9838b1
fca001f
a8da1ff
af6587a
9919fd1
51894be
1e09bdb
eef0f97
3023dfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ use sp_weights::Weight; | |
| /// | ||
| /// It contains the execution result together with some auxiliary information. | ||
| #[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] | ||
| pub struct ContractResult<R, Balance> { | ||
| pub struct ContractResult<R, Balance, EventRecord> { | ||
| /// How much weight was consumed during execution. | ||
| pub gas_consumed: Weight, | ||
| /// How much weight is required as gas limit in order to execute this call. | ||
|
|
@@ -71,15 +71,26 @@ pub struct ContractResult<R, Balance> { | |
| pub debug_message: Vec<u8>, | ||
| /// The execution result of the wasm code. | ||
| pub result: R, | ||
| /// The events that were emitted during execution. It is an options as event collection is | ||
juangirini marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// optional. | ||
| pub events: Option<Vec<EventRecord>>, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has been tested against Contracts UI and it works just fine.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
SCALE is not really well defined by a spec or something. Whether you ignore trailing data or not is up to the implementation. See That said, I suspect the default behavior is to ignore trailing data. Hence we can safely extend the struct in new versions. But if you think about it this means we don't even need a new version in this case because we can just always emit the events since they will be ignored by older code as trailing data. If they ignore a single I suggest we do away with the new version and two type aliases and just extend the struct. Should work the same way.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have removed the new version and implemented it all in the original
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a |
||
| } | ||
|
|
||
| /// Result type of a `bare_call` call. | ||
| /// Result type of a `bare_call` call as well as `ContractsApiV3::call`. | ||
| pub type ContractExecResultWEvents<Balance, EventRecord> = | ||
| ContractResult<Result<ExecReturnValue, DispatchError>, Balance, EventRecord>; | ||
|
|
||
| /// Result type of the `ContractsApi::call` call. | ||
| pub type ContractExecResult<Balance> = | ||
| ContractResult<Result<ExecReturnValue, DispatchError>, Balance>; | ||
| ContractResult<Result<ExecReturnValue, DispatchError>, Balance, ()>; | ||
|
|
||
| /// Result type of a `bare_instantiate` call as well as `ContractsApiV3::instantiate`. | ||
| pub type ContractInstantiateResultWEvents<AccountId, Balance, EventRecord> = | ||
| ContractResult<Result<InstantiateReturnValue<AccountId>, DispatchError>, Balance, EventRecord>; | ||
|
|
||
| /// Result type of a `bare_instantiate` call. | ||
| /// Result type of the `ContractsApi::instantiate` call. | ||
| pub type ContractInstantiateResult<AccountId, Balance> = | ||
| ContractResult<Result<InstantiateReturnValue<AccountId>, DispatchError>, Balance>; | ||
| ContractResult<Result<InstantiateReturnValue<AccountId>, DispatchError>, Balance, ()>; | ||
|
|
||
| /// Result type of a `bare_code_upload` call. | ||
| pub type CodeUploadResult<CodeHash, Balance> = | ||
|
|
||
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.
Was this necessary for CI? I don't think we need to bump in normal PRs.
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 catch, that shouldn't go there