diff --git a/src/proto_alpha/lib_protocol/src/delegate_storage.ml b/src/proto_alpha/lib_protocol/src/delegate_storage.ml index bc618f02d..c696fcf9b 100644 --- a/src/proto_alpha/lib_protocol/src/delegate_storage.ml +++ b/src/proto_alpha/lib_protocol/src/delegate_storage.ml @@ -128,10 +128,14 @@ let set c contract delegate = | Some pkh -> fail (No_deletion pkh) | None -> - Storage.Contract.Balance.get c contract >>=? fun balance -> - unlink c contract balance >>=? fun c -> - Storage.Contract.Delegate.remove c contract >>= fun c -> - return c + is_delegatable c contract >>=? fun delegatable -> + if delegatable then + Storage.Contract.Balance.get c contract >>=? fun balance -> + unlink c contract balance >>=? fun c -> + Storage.Contract.Delegate.remove c contract >>= fun c -> + return c + else + fail (Non_delegatable_contract contract) end | Some delegate -> known c delegate >>=? fun known_delegate ->