Proto/Michelson: find_big_map rather than list_of_big_map_ids

parent f58a83c4
......@@ -309,20 +309,13 @@ let register () =
let open Script_ir_translator in
parse_script ctxt ~legacy:true script
>>=? fun (Ex_script script, ctxt) ->
Script_ir_translator.collect_lazy_storage
Script_ir_translator.find_big_map_unaccounted
ctxt
script.storage_type
script.storage
>>=? fun (ids, _ctxt) ->
let ids = Script_ir_translator.list_of_big_map_ids ids in
let rec find = function
| [] ->
return_none
| (id : Z.t) :: ids -> (
~f:(fun id ->
try do_big_map_get ctxt id key >>=? return_some
with Not_found -> find ids )
in
find ids) ;
with Not_found -> return_none)) ;
register2 S.big_map_get (fun ctxt id key () () -> do_big_map_get ctxt id key) ;
register_field S.info (fun ctxt contract ->
Contract.get_balance ctxt contract
......
......@@ -5832,9 +5832,18 @@ let extract_lazy_storage_diff ctxt mode ~temporary ~to_duplicate ~to_update ty
| diffs ->
return (v, Some diffs (* do not reverse *), ctxt)
let list_of_big_map_ids kids =
Ids.fold
(fun (Lazy_storage.KId.E (kind, id)) acc ->
match kind with Lazy_storage.Kind.Big_map -> id :: acc)
kids
[]
let find_big_map_unaccounted ctxt ty x ~f =
let ctxt = Gas.set_unlimited ctxt in
collect_lazy_storage ctxt ty x
>>=? fun (lazy_storage_ids, _ctxt) ->
let rec find_in_ids = function
| [] ->
return_none
| Lazy_storage.KId.E (Big_map, id) :: kids -> (
f id
>>=? function
| None -> find_in_ids kids | Some _ as found -> return found )
(*| _ ->
find_in_ids kids *)
in
find_in_ids @@ Ids.elements lazy_storage_ids
......@@ -313,7 +313,12 @@ val collect_lazy_storage :
'a ->
(lazy_storage_ids * context) tzresult Lwt.t
val list_of_big_map_ids : lazy_storage_ids -> Z.t list
val find_big_map_unaccounted :
context ->
'a Script_typed_ir.ty ->
'a ->
f:(Z.t -> 'b option tzresult Lwt.t) ->
'b option tzresult Lwt.t
val extract_lazy_storage_diff :
context ->
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment