Alpha: check delegatable flag before removing the delegate

This commit is contained in:
Benjamin Canou 2018-04-20 22:50:38 +02:00 committed by Grégoire Henry
parent af5a8939cf
commit b669632075

View File

@ -128,10 +128,14 @@ let set c contract delegate =
| Some pkh -> | Some pkh ->
fail (No_deletion pkh) fail (No_deletion pkh)
| None -> | None ->
Storage.Contract.Balance.get c contract >>=? fun balance -> is_delegatable c contract >>=? fun delegatable ->
unlink c contract balance >>=? fun c -> if delegatable then
Storage.Contract.Delegate.remove c contract >>= fun c -> Storage.Contract.Balance.get c contract >>=? fun balance ->
return c unlink c contract balance >>=? fun c ->
Storage.Contract.Delegate.remove c contract >>= fun c ->
return c
else
fail (Non_delegatable_contract contract)
end end
| Some delegate -> | Some delegate ->
known c delegate >>=? fun known_delegate -> known c delegate >>=? fun known_delegate ->