Alpha: fix spend_from_script

This commit is contained in:
Benjamin Canou 2018-02-27 17:52:49 +01:00
parent b63b333b1a
commit 249e4564d3

View File

@ -327,12 +327,12 @@ let spend_from_script c contract amount =
| Error _ -> | Error _ ->
fail (Balance_too_low (contract, balance, amount)) fail (Balance_too_low (contract, balance, amount))
| Ok new_balance -> | Ok new_balance ->
if Tez_repr.(new_balance > Tez_repr.zero) then
Storage.Contract.Balance.set c contract new_balance >>=? fun c -> Storage.Contract.Balance.set c contract new_balance >>=? fun c ->
Roll_storage.Contract.remove_amount c contract amount Roll_storage.Contract.remove_amount c contract amount >>=? fun c ->
else if Tez_repr.(new_balance > Tez_repr.zero) then
match Contract_repr.is_implicit contract with return c
| None -> return c (* don't delete originated contract. *) else match Contract_repr.is_implicit contract with
| None -> return c (* Never delete originated contracts *)
| Some pkh -> | Some pkh ->
Storage.Contract.Delegate.get_option c contract >>=? function Storage.Contract.Delegate.get_option c contract >>=? function
| Some pkh' -> | Some pkh' ->