mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 01:27:56 +00:00
Make ExecResult encodable (#1809)
# Description We derive few useful traits on `ErrorOrigin` and `ExecError`, including `codec::Encode` and `codec::Decode`, so that `ExecResult` is en/decodable as well. This is required for a contract mocking feature (already prepared in drink: https://github.com/Cardinal-Cryptography/drink/pull/61). In more detail: `ExecResult` must be passed from runtime extension, through runtime interface, back to the pallet, which requires that it is serializable to bytes in some form (or implements some rare, auxiliary traits). **Impact on runtime size**: Since most of these traits is used directly in the pallet now, compiler should be able to throw it out (and thus we bring no new overhead). However, they are very useful in secondary tools like drink or other testing libraries. # Checklist - [x] My PR includes a detailed description as outlined in the "Description" section above - [ ] My PR follows the [labeling requirements](CONTRIBUTING.md#Process) of this project (at minimum one label for `T` required) - [x] I have made corresponding changes to the documentation (if applicable) - [x] I have added tests that prove my fix is effective or that my feature works (if applicable)
This commit is contained in:
committed by
GitHub
parent
8ff489875b
commit
10857d0b58
@@ -100,7 +100,7 @@ impl<T: Config> Key<T> {
|
||||
/// Call or instantiate both called into other contracts and pass through errors happening
|
||||
/// in those to the caller. This enum is for the caller to distinguish whether the error
|
||||
/// happened during the execution of the callee or in the current execution context.
|
||||
#[cfg_attr(test, derive(Debug, PartialEq))]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, codec::Decode, codec::Encode)]
|
||||
pub enum ErrorOrigin {
|
||||
/// Caller error origin.
|
||||
///
|
||||
@@ -112,7 +112,7 @@ pub enum ErrorOrigin {
|
||||
}
|
||||
|
||||
/// Error returned by contract execution.
|
||||
#[cfg_attr(test, derive(Debug, PartialEq))]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, codec::Decode, codec::Encode)]
|
||||
pub struct ExecError {
|
||||
/// The reason why the execution failed.
|
||||
pub error: DispatchError,
|
||||
|
||||
Reference in New Issue
Block a user