package tezos-protocol-015-PtLimaPt

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Low-level handlers of raw contexts for base operations on contracts.

allocated ctxt contract returns true if and only if the contract is stored in Storage.Contract.Spendable_balance.

exists ctxt contract returns true if and only if either the contract is originated or it is (implicit and) "allocated".

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.

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.

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.

Return the balance of spendable tez owned by the Implicit contract of the given public_key_hash.

module Legacy_big_map_diff : sig ... end

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.

Enable a payer to increase the paid storage of a contract by some amount.

Increases the balance of a contract. Calling this function directly may break important invariants. Consider calling credit instead.

Decreases the balance of a contract. Calling this function directly may break important invariants. Consider calling spend instead.

get_balance_and_frozen_bonds ctxt contract returns the sum of the (spendable) balance and the frozen bonds associated to contract.

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.

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.

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.

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.

  • raises a

    Storage_Error Missing_key error when there is no bond associated to contract and bond_id.

  • raises a

    Frozen_bonds_must_be_spent_at_once (contract, bond_id) error when the amount is different from the bond associated to contract and bond_id.

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.

  • raises a

    Addition_overflow error when (find ctxt contract bond_id) + amount > Int64.max_int.

has_frozen_bonds ctxt contract returns true if there are frozen bonds associated to contract, and returns false otherwise.

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_015_PtLimaPt.Lwt.t) -> 'a Tezos_protocol_environment_015_PtLimaPt.Lwt.t

fold_on_bond_ids ctxt contract order init f folds f on all bond identifiers associated to contract.

ensure_deallocated_if_empty ctxt contract de-allocates contract if its full balance is zero, and it does not delegate.

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.

  • returns

    Error Balance_too_low if balance is smaller than amount.

  • returns

    Error Empty_implicit_delegated_contract if new_balance would be zero and the contract has a delegate that is not the contract's own manager.

OCaml

Innovation. Community. Security.