From 249e4564d3e71d4383c8830869dd6632d8e62950 Mon Sep 17 00:00:00 2001 From: Benjamin Canou Date: Tue, 27 Feb 2018 17:52:49 +0100 Subject: [PATCH] Alpha: fix spend_from_script --- src/proto_alpha/lib_protocol/src/contract_storage.ml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/proto_alpha/lib_protocol/src/contract_storage.ml b/src/proto_alpha/lib_protocol/src/contract_storage.ml index 5ed859dd7..bbd71ba2c 100644 --- a/src/proto_alpha/lib_protocol/src/contract_storage.ml +++ b/src/proto_alpha/lib_protocol/src/contract_storage.ml @@ -327,12 +327,12 @@ let spend_from_script c contract amount = | Error _ -> fail (Balance_too_low (contract, balance, amount)) | Ok new_balance -> + Storage.Contract.Balance.set c contract new_balance >>=? fun c -> + Roll_storage.Contract.remove_amount c contract amount >>=? fun c -> if Tez_repr.(new_balance > Tez_repr.zero) then - Storage.Contract.Balance.set c contract new_balance >>=? fun c -> - Roll_storage.Contract.remove_amount c contract amount - else - match Contract_repr.is_implicit contract with - | None -> return c (* don't delete originated contract. *) + return c + else match Contract_repr.is_implicit contract with + | None -> return c (* Never delete originated contracts *) | Some pkh -> Storage.Contract.Delegate.get_option c contract >>=? function | Some pkh' ->