package tezos-protocol-020-PsParisC
Low-level handlers of raw contexts for base operations on contracts.
type Tezos_protocol_environment_020_PsParisC.Error_monad.error +=
| Balance_too_low of Contract_repr.t * Tez_repr.t * Tez_repr.t
| Counter_in_the_past of {
contract : Contract_repr.t;
expected : Manager_counter_repr.t;
found : Manager_counter_repr.t;
}
| Counter_in_the_future of {
contract : Contract_repr.t;
expected : Manager_counter_repr.t;
found : Manager_counter_repr.t;
}
| Non_existing_contract of Contract_repr.t
| Inconsistent_public_key of Tezos_protocol_environment_020_PsParisC.Signature.Public_key.t * Tezos_protocol_environment_020_PsParisC.Signature.Public_key.t
| Failure of string
| Empty_implicit_contract of Tezos_protocol_environment_020_PsParisC.Signature.Public_key_hash.t
| Empty_implicit_delegated_contract of Tezos_protocol_environment_020_PsParisC.Signature.Public_key_hash.t
val allocated :
Raw_context.t ->
Contract_repr.t ->
bool Tezos_protocol_environment_020_PsParisC.Lwt.t
allocated ctxt contract
returns true
if and only if the contract is stored in Storage.Contract.Spendable_balance
.
val exists :
Raw_context.t ->
Contract_repr.t ->
bool Tezos_protocol_environment_020_PsParisC.Lwt.t
exists ctxt contract
returns true
if and only if either the contract is implicit or it is (originated and) allocated
.
val must_exist :
Raw_context.t ->
Contract_repr.t ->
unit Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
must_exist ctxt contract
fails with the Non_existing_contract
error if exists ctxt contract
returns false
. Even though this function is gas-free, it is always called in a context where some gas consumption is guaranteed whenever necessary. The first context is that of a transfer operation, and in that case the base cost of a manager operation (Micheclson_v1_gas.Cost_of.manager_operation
) is consumed. The second context is that of an activation operation, and in that case no gas needs to be consumed since that operation is not a manager operation.
val must_be_allocated :
Raw_context.t ->
Contract_repr.t ->
unit Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
must_be_allocated ctxt contract
fails when the contract is not allocated. It fails with Non_existing_contract
if the contract is originated, and it fails with Empty_implicit_contract
if the contract is implicit.
val list :
Raw_context.t ->
Contract_repr.t list Tezos_protocol_environment_020_PsParisC.Lwt.t
val get_balance :
Raw_context.t ->
Contract_repr.t ->
Tez_repr.t Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
get_balance ctxt contract
returns the balance of spendable tez owned by contract
given raw context ctxt
. This does not include the contract's frozen balances.
val get_balance_carbonated :
Raw_context.t ->
Contract_repr.t ->
(Raw_context.t * Tez_repr.t)
Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
val check_allocated_and_get_balance :
Raw_context.t ->
Tezos_protocol_environment_020_PsParisC.Signature.public_key_hash ->
Tez_repr.t Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
Return the balance of spendable tez owned by the Implicit contract of the given public_key_hash
.
val get_script_code :
Raw_context.t ->
Contract_hash.t ->
(Raw_context.t * Script_repr.lazy_expr option)
Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
module Legacy_big_map_diff : sig ... end
val update_script_storage :
Raw_context.t ->
Contract_hash.t ->
Script_repr.expr ->
Lazy_storage_diff.diffs option ->
Raw_context.t Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
val credit_only_call_from_token :
Raw_context.t ->
Contract_repr.t ->
Tez_repr.t ->
Raw_context.t Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
val spend_only_call_from_token :
Raw_context.t ->
Contract_repr.t ->
Tez_repr.t ->
Raw_context.t Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
val raw_originate :
Raw_context.t ->
prepaid_bootstrap_storage:bool ->
Contract_hash.t ->
script:(Script_repr.t * Lazy_storage_diff.diffs option) ->
Raw_context.t Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
raw_originate ctxt ~prepaid_bootstrap_storage contract ~script
originates the contract
parameter. The storage
space allocated by this origination is considered to be free of charge or to have been already paid for by the user, if and only if prepaid_bootstrap_storage
is true
. In particular, the amount of space allocated by this origination will be part of the consumed space to pay for returned by the next call to Fees_storage.record_paid_storage_space ctxt contract
, if and only if prepaid_bootstrap_storage
is false
.
val fresh_contract_from_current_nonce :
Raw_context.t ->
(Raw_context.t * Contract_hash.t)
Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
val originated_from_current_nonce :
since:Raw_context.t ->
until:Raw_context.t ->
Contract_hash.t list
Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
val set_paid_storage_space_and_return_fees_to_pay :
Raw_context.t ->
Contract_repr.t ->
Tezos_protocol_environment_020_PsParisC.Z.t ->
(Tezos_protocol_environment_020_PsParisC.Z.t * Raw_context.t)
Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
val increase_paid_storage :
Raw_context.t ->
Contract_hash.t ->
amount_in_bytes:Tezos_protocol_environment_020_PsParisC.Z.t ->
Raw_context.t Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
Enable a payer to increase the paid storage of a contract by some amount.
val get_balance_and_frozen_bonds :
Raw_context.t ->
Contract_repr.t ->
Tez_repr.t Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
get_balance_and_frozen_bonds ctxt contract
returns the sum of the (spendable) balance and the frozen bonds associated to contract
.
type Tezos_protocol_environment_020_PsParisC.Error_monad.error +=
| Frozen_bonds_must_be_spent_at_once of Contract_repr.t * Bond_id_repr.t
This error is raised when spend_bond_only_call_from_token
is called with an amount that is not equal to the deposit associated to the given contract and bond id.
val bond_allocated :
Raw_context.t ->
Contract_repr.t ->
Bond_id_repr.t ->
(Raw_context.t * bool)
Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
bond_allocated ctxt contract bond_id
returns a new context because of an access to carbonated data, and true
if there is a bond associated to contract
and bond_id
, or false
otherwise.
val find_bond :
Raw_context.t ->
Contract_repr.t ->
Bond_id_repr.t ->
(Raw_context.t * Tez_repr.t option)
Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
find_bond ctxt contract bond_id
returns a new context because of an access to carbonated data, and the bond associated to (contract, bond_id)
if there is one, or None
otherwise.
val spend_bond_only_call_from_token :
Raw_context.t ->
Contract_repr.t ->
Bond_id_repr.t ->
Tez_repr.t ->
Raw_context.t Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
spend_bond ctxt contract bond_id amount
withdraws the given amount
from the value of the bond associated to contract
and bond_id
.
The argument amount
is required to be strictly positive.
val credit_bond_only_call_from_token :
Raw_context.t ->
Contract_repr.t ->
Bond_id_repr.t ->
Tez_repr.t ->
Raw_context.t Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
credit_bond ctxt contract bond_id amount
adds the given amount
to the bond associated to contract
and bond_id
. If no bond exists, one whose value is amount
is created.
The argument amount
is required to be strictly positive.
val has_frozen_bonds :
Raw_context.t ->
Contract_repr.t ->
bool Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
has_frozen_bonds ctxt contract
returns true
if there are frozen bonds associated to contract
, and returns false
otherwise.
val get_frozen_bonds :
Raw_context.t ->
Contract_repr.t ->
Tez_repr.t Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
get_frozen_bonds ctxt contract
returns the total amount of bonds associated to contract
.
val fold_on_bond_ids :
Raw_context.t ->
Contract_repr.t ->
order:[ `Sorted | `Undefined ] ->
init:'a ->
f:(Bond_id_repr.t -> 'a -> 'a Tezos_protocol_environment_020_PsParisC.Lwt.t) ->
'a Tezos_protocol_environment_020_PsParisC.Lwt.t
fold_on_bond_ids ctxt contract order init f
folds f
on all bond identifiers associated to contract
.
val ensure_deallocated_if_empty :
Raw_context.t ->
Contract_repr.t ->
Raw_context.t Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
ensure_deallocated_if_empty ctxt contract
de-allocates contract
if its full balance is zero, and it does not delegate.
val simulate_spending :
Raw_context.t ->
balance:Tez_repr.t ->
amount:Tez_repr.t ->
Tezos_protocol_environment_020_PsParisC.Signature.public_key_hash ->
(Tez_repr.t * bool)
Tezos_protocol_environment_020_PsParisC.Error_monad.tzresult
Tezos_protocol_environment_020_PsParisC.Lwt.t
simulate_spending ctxt ~balance ~amount source
removes amount
from balance
as if it were the balance of the implicit contract associated with source
. It returns the resulting new_balance
, and a boolean still_allocated
that indicates whether this contract would still exist.
still_allocated
is always true
when new_balance
is positive. When new_balance
is zero, it depends on the contract's delegated status and frozen bonds (cf spend_only_call_from_token
and ensure_deallocated_if_empty
).
Note that this function does not retrieve the actual balance of the contract, nor does it update or delete it. Indeed, its purpose is to simulate the spending of fees when validating operations, without actually spending them.
module For_RPC : sig ... end