diff --git a/src/proto/alpha/apply.ml b/src/proto/alpha/apply.ml index 0dfdbcee3..870b157b7 100644 --- a/src/proto/alpha/apply.ml +++ b/src/proto/alpha/apply.ml @@ -12,7 +12,6 @@ open Tezos_context type error += Bad_endorsement (* TODO: doc *) -type error += Contract_not_delegatable (* TODO: doc *) type error += Unimplemented type error += Invalid_voting_period @@ -99,8 +98,6 @@ let apply_manager_operation_content ctxt origination_nonce accept_failing_script return (ctxt, origination_nonce) (* TODO: pay for the storage diff *) | Delegation delegate -> - Contract.is_delegatable ctxt source >>=? fun delegatable -> - fail_unless delegatable Contract_not_delegatable >>=? fun () -> Contract.set_delegate ctxt source delegate >>=? fun ctxt -> return (ctxt, origination_nonce) diff --git a/src/proto/alpha/contract_storage.ml b/src/proto/alpha/contract_storage.ml index ffd84dd74..13ebd4713 100644 --- a/src/proto/alpha/contract_storage.ml +++ b/src/proto/alpha/contract_storage.ml @@ -15,7 +15,7 @@ type error += | Counter_in_the_future of Contract_repr.contract * int32 * int32 (* `Temporary *) | Unspendable_contract of Contract_repr.contract (* `Permanent *) | Non_existing_contract of Contract_repr.contract (* `Temporary *) - | Undelagatable_contract of Contract_repr.contract (* `Permanent *) + | Non_delegatable_contract of Contract_repr.contract (* `Permanent *) | Failure of string (* `Permanent *) let () = @@ -127,8 +127,8 @@ let () = Format.fprintf ppf "Contract %a is not delegatable" Contract_repr.pp contract) Data_encoding.(obj1 (req "contract" Contract_repr.encoding)) - (function Non_existing_contract c -> Some c | _ -> None) - (fun c -> Non_existing_contract c) ; + (function Non_delegatable_contract c -> Some c | _ -> None) + (fun c -> Non_delegatable_contract c) ; register_error_kind `Permanent ~id:"contract.failure" @@ -295,16 +295,15 @@ let is_spendable c contract = let set_delegate c contract delegate = (* A contract delegate can be set only if the contract is delegatable *) - Storage.Contract.Delegatable.get c contract >>=? fun delegatable -> - if not delegatable - then fail (Undelagatable_contract contract) - else - match delegate with - | None -> - Storage.Contract.Delegate.remove c contract >>= fun c -> - return c - | Some delegate -> - Storage.Contract.Delegate.init_set c contract delegate + is_delegatable c contract >>=? function + | false -> fail (Non_delegatable_contract contract) + | true -> + match delegate with + | None -> + Storage.Contract.Delegate.remove c contract >>= fun c -> + return c + | Some delegate -> + Storage.Contract.Delegate.init_set c contract delegate let contract_fee c contract = Storage.Contract.Code_fees.get_option c contract >>=? fun code_fees -> diff --git a/src/proto/alpha/contract_storage.mli b/src/proto/alpha/contract_storage.mli index a46394e55..7e4101345 100644 --- a/src/proto/alpha/contract_storage.mli +++ b/src/proto/alpha/contract_storage.mli @@ -15,7 +15,7 @@ type error += | Counter_in_the_future of Contract_repr.contract * int32 * int32 (* `Temporary *) | Unspendable_contract of Contract_repr.contract (* `Permanent *) | Non_existing_contract of Contract_repr.contract (* `Temporary *) - | Undelagatable_contract of Contract_repr.contract (* `Permanent *) + | Non_delegatable_contract of Contract_repr.contract (* `Permanent *) | Failure of string (* `Permanent *) val delete : Storage.t -> Contract_repr.t -> Storage.t tzresult Lwt.t