Module Delegate_storage.Contract

This module ensures the following invariants:

init ctxt contract delegate registers a delegate when creating a contract.

This functions assumes that contract is allocated.

This function returns the Unregistered_delegate error if contract already has a delegate or if delegate is not a registered delegate.

set ctxt contract delegate_opt allows to set the delegate of a contract to delegate when delegate_opt = Some delegate or to unset the delegate when delegate_opt = None. When delegate_opt = Some contract (aka self-delegation), the function also registers the contract as a delegate and sets the delegate as active.

It returns the Unregistered_delegate error when self-delegating and when the public key is not yet revealed. It returns the Empty_delegate_account error when self-delegating and the implicit account is not allocated. It returns the Active_delegate error when self-delegating and the delegate is already active. It returns the Unregistered_delegate error when trying to set the delegate to an unregistered delegate. It returns the Current_delegate error when contract is already delegated to the same delegate. It returns the No_deletion error when trying to unset or change the delegate of a registered delegate.