contracts: Allow () -> (i32) for backwards compatibility (#8656)

This commit is contained in:
Alexander Theißen
2021-04-22 12:44:35 +02:00
committed by GitHub
parent 70f008b9f1
commit 166568b029
@@ -273,13 +273,17 @@ impl<'a, T: Config> ContractModule<'a, T> {
// Then check the signature.
// Both "call" and "deploy" has a () -> () function type.
// We still support () -> (i32) for backwards compatibility.
let func_ty_idx = func_entries.get(fn_idx as usize)
.ok_or_else(|| "export refers to non-existent function")?
.type_ref();
let Type::Function(ref func_ty) = types
.get(func_ty_idx as usize)
.ok_or_else(|| "function has a non-existent type")?;
if !(func_ty.params().is_empty() && func_ty.results().is_empty()) {
if !(
func_ty.params().is_empty() &&
(func_ty.results().is_empty() || func_ty.results() == [ValueType::I32])
) {
return Err("entry point has wrong signature");
}
}