contracts: Change define_env! to expect a Result<T, DispatchError> for every function (#7762)

* Make host functions return TrapReason

This avoids the need to manually store any trap reasons
to the `Runtime` from the host function. This adds the following
benefits:

* It properly composes with the upcoming chain extensions
* Missing to set a trap value is now a compile error

* review: Remove superflous .into()
This commit is contained in:
Alexander Theißen
2020-12-29 13:58:23 +01:00
committed by GitHub
parent dd8e7587cb
commit ab876be9e9
5 changed files with 146 additions and 156 deletions
+2 -2
View File
@@ -1537,7 +1537,7 @@ mod tests {
&mut gas_meter
),
Err(ExecError {
error: Error::<Test>::ContractTrapped.into(),
error: Error::<Test>::TooManyTopics.into(),
origin: ErrorOrigin::Caller,
})
);
@@ -1582,7 +1582,7 @@ mod tests {
&mut gas_meter
),
Err(ExecError {
error: Error::<Test>::ContractTrapped.into(),
error: Error::<Test>::DuplicateTopics.into(),
origin: ErrorOrigin::Caller,
})
);