Alpha: Non implicit contracts cannot be removed

This commit is contained in:
Pierre Chambart 2018-06-01 17:36:32 +02:00 committed by Benjamin Canou
parent 64481a198e
commit 2404246fb3

View File

@ -235,6 +235,11 @@ let create_implicit c manager ~balance =
~spendable:true ~delegatable:false ~spendable:true ~delegatable:false
let delete c contract = let delete c contract =
match Contract_repr.is_implicit contract with
| None ->
(* For non implicit contract Big_map should be cleared *)
failwith "Non implicit contracts cannot be removed"
| Some _ ->
Delegate_storage.remove c contract >>=? fun c -> Delegate_storage.remove c contract >>=? fun c ->
Storage.Contract.Balance.delete c contract >>=? fun c -> Storage.Contract.Balance.delete c contract >>=? fun c ->
Storage.Contract.Manager.delete c contract >>=? fun c -> Storage.Contract.Manager.delete c contract >>=? fun c ->
@ -245,7 +250,6 @@ let delete c contract =
Storage.Contract.Storage.remove c contract >>=? fun (c, _) -> Storage.Contract.Storage.remove c contract >>=? fun (c, _) ->
Storage.Contract.Paid_storage_space_fees.remove c contract >>= fun c -> Storage.Contract.Paid_storage_space_fees.remove c contract >>= fun c ->
Storage.Contract.Used_storage_space.remove c contract >>= fun c -> Storage.Contract.Used_storage_space.remove c contract >>= fun c ->
Storage.Contract.Big_map.clear (c, contract) >>=? fun (c, _) ->
return c return c
let allocated c contract = let allocated c contract =