text stringlengths 12 786k |
|---|
let token_and_amount ctxt ex_ticket = Gas . consume ctxt Ticket_costs . Constants . cost_token_and_amount_of_ticket >|? fun ctxt -> let ( token , amount ) = Ticket_token . token_and_amount_of_ex_ticket ex_ticket in ( ( token , Script_int . to_zint amount ) , ctxt ) |
let neg_token_and_amount ctxt ex_ticket = token_and_amount ctxt ex_ticket >>? fun ( ( token , amount ) , ctxt ) -> Gas . consume ctxt ( Ticket_costs . negate_cost amount ) >|? fun ctxt -> ( ( token , Z . neg amount ) , ctxt ) |
let parse_value_type ctxt value_type = Script_ir_translator . parse_big_map_value_ty ctxt ~ legacy : true ( Micheline . root value_type ) |
let collect_token_diffs_of_node ctxt has_tickets node ~ get_token_and_amount acc = Ticket_scanner . tickets_of_node ctxt ~ include_lazy : true has_tickets ( Micheline . root node ) >>=? fun ( ex_tickets , ctxt ) -> List . fold_left_e ( fun ( acc , ctxt ) ticket -> get_token_and_amount ctx... |
module Key_hash_map = Carbonated_map . Make ( struct type t = Script_expr_hash . t let compare = Script_expr_hash . compare let compare_cost _ = Ticket_costs . Constants . cost_compare_ticket_hash end ) |
let collect_token_diffs_of_big_map_update ctxt ~ big_map_id has_tickets { Lazy_storage_kind . Big_map . key = _ ; key_hash ; value } already_updated acc = let collect_token_diffs_of_node_option ctxt ~ get_token_and_amount expr_opt acc = match expr_opt with | Some expr -> collect_token_diffs_of_node ... |
let collect_token_diffs_of_big_map_updates ctxt big_map_id ~ value_type updates acc = parse_value_type ctxt value_type >>?= fun ( Script_ir_translator . Ex_ty value_type , ctxt ) -> Ticket_scanner . type_has_tickets ctxt value_type >>?= fun ( has_tickets , ctxt ) -> List . fold_left_es ( fun (... |
let collect_token_diffs_of_big_map ctxt ~ get_token_and_amount big_map_id acc = Gas . consume ctxt Ticket_costs . Constants . cost_collect_tickets_step >>?= fun ctxt -> Big_map . exists ctxt big_map_id >>=? fun ( ctxt , key_val_tys ) -> match key_val_tys with | Some ( _key_ty , value_ty ) -... |
let collect_token_diffs_of_big_map_and_updates ctxt big_map_id updates acc = Gas . consume ctxt Ticket_costs . Constants . cost_collect_tickets_step >>?= fun ctxt -> Big_map . exists ctxt big_map_id >>=? fun ( ctxt , key_val_opt ) -> match key_val_opt with | Some ( _val , value_type ) -> col... |
let collect_token_diffs_of_big_map_diff ctxt diff_item acc = Gas . consume ctxt Ticket_costs . Constants . cost_collect_tickets_step >>?= fun ctxt -> match diff_item with | Lazy_storage . Item ( Lazy_storage_kind . Big_map , big_map_id , Remove ) -> collect_token_diffs_of_big_map ctxt ~ get_toke... |
let ticket_diffs_of_lazy_storage_diff ctxt diffs_items = List . fold_left_es ( fun ( acc , ctxt ) diff_item -> collect_token_diffs_of_big_map_diff ctxt diff_item acc ) ( [ ] , ctxt ) diffs_items |
type ticket_transfer = { destination : Contract . t ; tickets : Ticket_scanner . ex_ticket list ; } |
type ticket_token_diff = { ticket_token : Ticket_token . ex_token ; total_amount : Script_int . n Script_int . num ; destinations : ( Contract . t * Script_int . n Script_int . num ) list ; } |
type error += Failed_to_get_script of Contract . t | Contract_not_originated |
let ( ) = let open Data_encoding in register_error_kind ` Permanent ~ id " : Failed_to_get_script " ~ title " : Failed to get script for contract " ~ description : " Failed to get script for contract when scanning operations for tickets " ~ pp ( : fun ppf contract -> Format . fprintf ppf... |
module Contract_map = Carbonated_map . Make ( struct type t = Contract . t let compare = Contract . compare let compare_cost _ = Ticket_costs . Constants . cost_compare_key_contract end ) |
module Ticket_token_map = struct include Ticket_token_map let add ctxt ~ ticket_token ~ destination ~ amount map = Ticket_token_map . update ctxt ticket_token ( fun ctxt old_val -> match old_val with | None -> let map = Contract_map . singleton destination amount in ok ( Some map , ctxt ) | Some d... |
let parse_and_cache_script ctxt ~ destination ~ get_non_cached_script = Script_cache . find ctxt destination >>=? fun ( ctxt , _cache_key , cached ) -> match cached with | Some ( _script , ex_script ) -> return ( ex_script , ctxt ) | None -> get_non_cached_script ctxt >>=? fun ( scri... |
let tickets_of_transaction ctxt ~ destination ~ parameters = match Contract . is_implicit destination with | Some _ -> return ( None , ctxt ) | None -> parse_and_cache_script ctxt ~ destination ~ get_non_cached_script ( : fun ctxt -> Contract . get_script ctxt destination >>=? fun ( ctxt , ... |
let tickets_of_origination ctxt ~ preorigination script = match preorigination with | None -> fail Contract_not_originated | Some destination -> parse_and_cache_script ctxt ~ destination ~ get_non_cached_script ( : fun ctxt -> return ( script , ctxt ) ) >>=? fun ( Script_ir_translator . Ex_scri... |
let tickets_of_operation ctxt ( Internal_operation { source = _ ; operation ; nonce = _ } ) = match operation with | Reveal _ -> return ( None , ctxt ) | Transaction { amount = _ ; parameters ; entrypoint = _ ; destination = Destination . Contract destination ; } -> ticket... |
let add_transfer_to_token_map ctxt token_map { destination ; tickets } = List . fold_left_es ( fun ( token_map , ctxt ) ticket -> let ( ticket_token , amount ) = Ticket_token . token_and_amount_of_ex_ticket ticket in Ticket_token_map . add ctxt ~ ticket_token ~ destination ~ amount token... |
let ticket_token_map_of_operations ctxt ops = List . fold_left_es ( fun ( token_map , ctxt ) op -> tickets_of_operation ctxt op >>=? fun ( res , ctxt ) -> match res with | Some ticket_trans -> add_transfer_to_token_map ctxt token_map ticket_trans | None -> return ( token_map , ctxt ) ) (... |
let ticket_diffs_of_operations ctxt { Script_typed_ir . elements ; length = _ } = ticket_token_map_of_operations ctxt elements >>=? fun ( token_map , ctxt ) -> Ticket_token_map . fold ctxt ( fun ctxt acc ticket_token destination_map -> Contract_map . fold ctxt ( fun ctxt total_amount _destin... |
type error += Unsupported_non_empty_overlay | Unsupported_type_operation |
let ( ) = register_error_kind ` Branch ~ id " : Unsupported_non_empty_overlay " ~ title " : Unsupported non empty overlay " ~ description " : Unsupported big - map value with non - empty overlay " ~ pp ( : fun ppf ( ) -> Format . fprintf ppf " Unsupported big - map value with no... |
type ex_ticket = | Ex_ticket : ' a Script_typed_ir . comparable_ty * ' a Script_typed_ir . ticket -> ex_ticket |
module Ticket_inspection = struct type ' a has_tickets = | True_ht : _ Script_typed_ir . ticket has_tickets | False_ht : _ has_tickets | Pair_ht : ' a has_tickets * ' b has_tickets -> ( ' a , ' b ) Script_typed_ir . pair has_tickets | Union_ht : ' a has_tickets * ' b has_tickets ... |
module Ticket_collection = struct let consume_gas_steps = Ticket_costs . consume_gas_steps ~ step_cost : Ticket_costs . Constants . cost_collect_tickets_step type accumulator = ex_ticket list type ' a continuation = Alpha_context . context -> accumulator -> ' a tzresult Lwt . t let tickets_of_comp... |
type ' a has_tickets = ' a Ticket_inspection . has_tickets * ' a Script_typed_ir . ty |
let type_has_tickets ctxt ty = Ticket_inspection . has_tickets_of_ty ctxt ty >|? fun ( has_tickets , ctxt ) -> ( ( has_tickets , ty ) , ctxt ) |
let tickets_of_value ctxt ~ include_lazy ( ht , ty ) = Ticket_collection . tickets_of_value ctxt ~ include_lazy ht ty |
let tickets_of_node ctxt ~ include_lazy ( ht , ty ) expr = match ht with | Ticket_inspection . False_ht -> return ( [ ] , ctxt ) | _ -> Script_ir_translator . parse_data ctxt ~ legacy : true ~ allow_forged : true ty expr >>=? fun ( value , ctxt ) -> tickets_of_value ctxt ~ includ... |
type error += | Negative_ticket_balance of { key : Ticket_hash_repr . t ; balance : Z . t } |
let ( ) = let open Data_encoding in register_error_kind ` Permanent ~ id " : Negative_ticket_balance " ~ title " : Negative ticket balance " ~ description " : Attempted to set a negative ticket balance value " ~ pp ( : fun ppf ( key , balance ) -> Format . fprintf ppf " Attempted... |
let get_balance ctxt key = Storage . Ticket_balance . Table . find ctxt key >|=? fun ( ctxt , res ) -> ( res , ctxt ) |
let set_balance ctxt key balance = let cost_of_key = Z . of_int 65 in fail_when Compare . Z . ( balance < Z . zero ) ( Negative_ticket_balance { key ; balance } ) >>=? fun ( ) -> if Compare . Z . ( balance = Z . zero ) then Storage . Ticket_balance . Table . remove ctxt ... |
let adjust_balance ctxt key ~ delta = get_balance ctxt key >>=? fun ( res , ctxt ) -> let old_balance = Option . value ~ default : Z . zero res in set_balance ctxt key ( Z . add old_balance delta ) |
module Ticket_token_map = Carbonated_map . Make ( struct type t = Ticket_hash . t let compare = Ticket_hash . compare let compare_cost _ = Ticket_costs . Constants . cost_compare_ticket_hash end ) |
type ' a t = ( Ticket_token . ex_token * ' a ) Ticket_token_map . t |
let key_of_ticket_token ctxt ( Ticket_token . Ex_token { ticketer ; _ } as token ) = Ticket_balance_key . ticket_balance_key ctxt ~ owner : ticketer token |
let update ctxt key f m = key_of_ticket_token ctxt key >>=? fun ( key_hash , ctxt ) -> let f ctxt val_opt = ( match val_opt with | Some ( _tkn , value ) -> f ctxt ( Some value ) | None -> f ctxt None ) >|? fun ( val_opt , ctxt ) -> ( Option . map ( fun v -> ( key , v ) ... |
let fold ctxt f = Ticket_token_map . fold ctxt ( fun ctxt acc _key_hash ( tkn , value ) -> f ctxt acc tkn value ) |
let tick_stories f conf save_progress_bar ( init , last , counter , n_stories ) = let ( ) = if not init then let c = ref conf . Configuration . progressSize in let ( ) = Loggers . print_newline f in while ! c > 0 do Loggers . fprintf f " _ " ; c :=! c - 1 done ; Loggers . ... |
type area = Area1 | Area0 |
type t = { tiles : Color_id . t array array array ; start_addr : uint16 ; end_addr : uint16 ; } |
let create ~ start_addr ~ end_addr = let tiles = Array . init 384 ( fun _ -> Array . make_matrix 8 8 Color_id . ID_00 ) in { tiles ; start_addr ; end_addr ; } |
let get_row_pixels t ~ area ( ~ index : uint8 ) ~ row = let index = match area with | Area1 -> Uint8 . to_int index | Area0 -> let signed_index = index |> Int8 . of_byte |> Int8 . to_int in signed_index + 256 in if row >= 8 then t . tiles . ( index + 1 ) . ( row - 8 ) else t... |
let get_pixel t ~ area ( ~ index : uint8 ) ~ row ~ col = let row = get_row_pixels t ~ area ~ index ~ row in row . ( col ) |
let get_full_pixels t ~ area ~ index = [ | 0 ; 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ] | |> Array . map ( fun row -> get_row_pixels t ~ area ~ index ~ row ) |
let print_full_pixels t ~ area ~ index = get_full_pixels t ~ area ~ index |> Array . iter ( fun color_ids -> color_ids |> Array . map ( Color_id . to_int ) |> Array . iter ( print_int ) ; print_newline ( ) ) |
let accepts t addr = Uint16 . ( t . start_addr <= addr && addr <= t . end_addr ) |
let read_byte t addr = let offset = Uint16 . ( addr - t . start_addr ) |> Uint16 . to_int in let index = offset / 16 in let row = ( offset mod 16 ) / 2 in let hi_or_lo = if offset mod 2 = 0 then ` Lo else ` Hi in t . tiles . ( index ) . ( row ) |> Array . map ( fun id... |
let write_byte t ~ addr ~ data = let data_bits = Bit_util . bitarray_of_byte data in let offset = Uint16 . ( addr - t . start_addr ) |> Uint16 . to_int in let index = offset / 16 in let row = ( offset mod 16 ) / 2 in let colors_in_row = t . tiles . ( index ) . ( row ) in let... |
type t = { area0_map : uint8 array array ; area1_map : uint8 array array ; area0_start_addr : uint16 ; area0_end_addr : uint16 ; area1_start_addr : uint16 ; area1_end_addr : uint16 ; } |
type area = | Area0 | Area1 |
let create ~ area0_start_addr ~ area0_end_addr ~ area1_start_addr ~ area1_end_addr = { area0_map = Array . make_matrix 32 32 Uint8 . zero ; area1_map = Array . make_matrix 32 32 Uint8 . zero ; area0_start_addr ; area0_end_addr ; area1_start_addr ; area1_end_addr ; } |
let get_tile_index t ~ area ~ y ~ x = match area with | Area0 -> t . area0_map . ( y / 8 ) . ( x / 8 ) | Area1 -> t . area1_map . ( y / 8 ) . ( x / 8 ) |
let accepts t addr = Uint16 . ( t . area0_start_addr <= addr && addr <= t . area0_end_addr || t . area1_start_addr <= addr && addr <= t . area1_end_addr ) |
let read_byte t addr = if Uint16 . ( t . area0_start_addr <= addr && addr <= t . area0_end_addr ) then let offset = Uint16 . ( to_int ( addr - t . area0_start_addr ) ) in t . area0_map . ( offset / 32 ) . ( offset mod 32 ) else if Uint16 . ( t . area1_start_addr <= ad... |
let write_byte t ~ addr ~ data = if Uint16 . ( t . area0_start_addr <= addr && addr <= t . area0_end_addr ) then let offset = Uint16 . ( to_int ( addr - t . area0_start_addr ) ) in t . area0_map . ( offset / 32 ) . ( offset mod 32 ) <- data else if Uint16 . ( t . ar... |
let var i = mk_var ( 1 + i ) |
let m = Array . make_matrix n 64 false |
let ( ) = let v = ref 0 in for l = 0 to 7 do for c = 0 to 7 do let j = 8 * l + c in if c < 7 then begin m . ( ! v ) . ( j ) <- true ; m . ( ! v ) . ( j + 1 ) <- true ; incr v ; end ; if l < 7 then begin m . ( ! v ) . ( j ) <- true ; m . ( !... |
let col j = let rec make acc i = if i = n then acc else make ( if m . ( i ) . ( j ) then i :: acc else acc ) ( i + 1 ) in make [ ] 0 |
let bdd = let rec make bdd j = if j = 64 then bdd else let cell_j = List . fold_left in make ( mk_and bdd cell_j ) ( j + 1 ) in make one 0 |
let ( ) = printf " % Ld solutions . " @ ( count_sat bdd ) |
let ( ) = let s = random_sat bdd in List . iter ( fun ( v , b ) -> let i = v - 1 in if b then begin end ) s |
} | tm_sec : int ; tm_min : int ; tm_hour : int ; tm_mday : int ; tm_mon : int ; tm_year : int ; tm_wday : int ; tm_yday : int ; tm_isdst : int } [ @@ as_record ] |
let _EOVERFLOW = [ % c constant " EOVERFLOW " sint ] |
let ( ) = let timep = allocate_n ~ count : 1 time_t in let time = time timep in assert ( time = !@ timep ) ; let ptm = match localtime timep with | None -> prerr_endline " localtime failure " ; exit 1 | Some s -> s in let tm = !@ ptm in Printf . printf " tm . tm_mon = % d \ n " ... |
module Protocol = struct type t = int64 include ( Compare . Int64 : Compare . S with type t := int64 ) let epoch = 0L let diff = Int64 . sub let add = Int64 . add let of_ptime t = let ( days , ps ) = Ptime . Span . to_d_ps ( Ptime . to_span t ) in let s_days = Int64 . mul ( In... |
module System = struct let frac_s = 3 type t = Ptime . t include Compare . Make ( Ptime ) let epoch = Ptime . epoch module Span = struct type t = Ptime . Span . t let multiply_exn f s = let open Ptime . Span in WithExceptions . Option . to_exn ~ none ( : Failure " Time . System . S... |
let ( ) = Data_encoding . Registration . register ~ pp : Protocol . pp_hum Protocol . encoding ; Data_encoding . Registration . register ~ pp : System . pp_hum System . encoding ; Data_encoding . Registration . register System . Span . encoding |
module type Basic = sig module Span : Span_intf . S type t module Replace_polymorphic_compare : Comparable . Polymorphic_compare with type t := t include Comparable . Polymorphic_compare with type t := t include Robustly_comparable with type t := t val add : t -> Span . t -> t val sub : t -> Span . ... |
module type S = sig type underlying type t = private underlying [ @@ deriving bin_io , compare , hash , typerep ] module Span : Span_intf . S with type underlying = underlying module Ofday : Ofday_intf . S with type underlying := underlying and module Span := Span include Basic with type t := t a... |
let of_iso8601_exn ' of_iso8601 s = match of_iso8601 s with | Ok x -> x | Error msg -> raise ( ISO8601_parse_exn msg ) |
let str_of_pp pp x = Fmt . str " % a " pp x |
module Ym = struct include Ym let pp_iso8601 = ISO8601_printers . pp_ym let to_iso8601 x = str_of_pp pp_iso8601 x let of_iso8601 = ISO8601_parsers . ym_of_str let of_iso8601_exn s = of_iso8601_exn ' of_iso8601 s end |
module ISO_week = struct include ISO_week let pp_iso8601 = ISO8601_printers . pp_iso_week let to_iso8601 x = str_of_pp pp_iso8601 x let of_iso8601 = ISO8601_parsers . iso_week_of_str let of_iso8601_exn s = of_iso8601_exn ' of_iso8601 s end |
module Date = struct include Date let pp_rfc3339 = RFC3339 . pp_date let to_rfc3339 x = str_of_pp pp_rfc3339 x let of_iso8601 = ISO8601_parsers . date_of_str let of_iso8601_exn s = of_iso8601_exn ' of_iso8601 s let to_sexp = To_sexp . sexp_of_date let to_sexp_string x = CCSexp . to_string ( To_sexp .... |
module Time = struct include Time let pp_rfc3339 = RFC3339 . pp_time let pp_rfc3339_milli = pp_rfc3339 ~ frac_s : frac_s_milli ( ) let pp_rfc3339_micro = pp_rfc3339 ~ frac_s : frac_s_micro ( ) let pp_rfc3339_nano = pp_rfc3339 ~ frac_s : frac_s_nano ( ) let to_rfc3339 = RFC3339 . of_time let ... |
module Span = struct include Span module For_human = struct include For_human ' let to_string = Printers . string_of_span_for_human let pp = Printers . pp_span_for_human end let to_string = Printers . string_of_span let pp = Printers . pp_span let to_sexp = To_sexp . sexp_of_span let to_sexp_string x... |
module Timestamp = struct include Span let min_val = timestamp_min let max_val = timestamp_max let now = timestamp_now let pp = Printers . pp_timestamp let to_string = Printers . string_of_timestamp let pp_rfc3339 = RFC3339 . pp_timestamp let pp_rfc3339_milli = pp_rfc3339 ~ frac_s : frac_s_milli ( ) ... |
let to_string = Printers . string_of_date_time Printers . Date_time_cannot_deduce_offset_from_utc |
let pp_rfc3339_milli = pp_rfc3339 ~ frac_s : frac_s_milli ( ) |
let pp_rfc3339_micro = pp_rfc3339 ~ frac_s : frac_s_micro ( ) |
let pp_rfc3339_nano = pp_rfc3339 ~ frac_s : frac_s_nano ( ) |
let to_rfc3339_milli = to_rfc3339 ~ frac_s : frac_s_milli |
let to_rfc3339_micro = to_rfc3339 ~ frac_s : frac_s_micro |
let to_rfc3339_nano = to_rfc3339 ~ frac_s : frac_s_nano |
let of_iso8601_exn = of_iso8601_exn ' of_iso8601 |
let to_sexp_string x = CCSexp . to_string ( To_sexp . sexp_of_date_time x ) |
let of_sexp = Of_sexp_utils . wrap_of_sexp Of_sexp . date_time_of_sexp |
let of_sexp_string = Of_sexp_utils . wrap_of_sexp_into_of_sexp_string Of_sexp . date_time_of_sexp |
let pp_sexp = Printers . wrap_to_sexp_into_pp_sexp To_sexp . sexp_of_date_time |
module ISO_week_date_time = struct include ISO_week_date_time ' let pp_iso8601 = ISO8601_printers . pp_iso_week_date_time let pp_iso8601_milli = pp_iso8601 ~ frac_s : frac_s_milli ( ) let pp_iso8601_micro = pp_iso8601 ~ frac_s : frac_s_micro ( ) let pp_iso8601_nano = pp_iso8601 ~ frac_s : frac_s_... |
module ISO_ord_date_time = struct include ISO_ord_date_time ' let pp_iso8601 = ISO8601_printers . pp_iso_ord_date_time let pp_iso8601_milli = pp_iso8601 ~ frac_s : frac_s_milli ( ) let pp_iso8601_micro = pp_iso8601 ~ frac_s : frac_s_micro ( ) let pp_iso8601_nano = pp_iso8601 ~ frac_s : frac_s_nan... |
module Interval = struct type t = timestamp * timestamp let lt ( x1 , y1 ) ( x2 , y2 ) = Span . ( x1 < x2 || ( x1 = x2 && y1 < y2 ) ) let le x y = lt x y || x = y let gt x y = lt y x let ge x y = le y x let equal ( x1 , y1 ) ( x2 , y2 ) = Span . ( x1 = x2 && y1 = ... |
module Zoneless = struct include Zoneless ' let of_iso8601 = ISO8601_parsers . zoneless_of_str let of_iso8601_exn = of_iso8601_exn ' of_iso8601 let maybe_zoneless_of_iso8601 = ISO8601_parsers . maybe_zoneless_of_str let maybe_zoneless_of_iso8601_exn = of_iso8601_exn ' maybe_zoneless_of_iso8601 let to_sex... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.