Class: TezosClient::Tools::FindBigMapsInStorage
- Inherits:
-
ActiveInteraction::Base
- Object
- ActiveInteraction::Base
- TezosClient::Tools::FindBigMapsInStorage
- Defined in:
- lib/tezos_client/tools/find_big_maps_in_storage.rb
Instance Method Summary collapse
- #big_map_type(data:, type:) ⇒ Object
- #execute ⇒ Object
- #list_type(data:, type:) ⇒ Object
- #pair_type(data:, type:) ⇒ Object
- #var_name(type) ⇒ Object
Instance Method Details
#big_map_type(data:, type:) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/tezos_client/tools/find_big_maps_in_storage.rb', line 44 def big_map_type(data:, type:) { name: var_name(type), id: data[:int], value_type: type[:args].second, key_type: type[:args].first }.with_indifferent_access end |
#execute ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/tezos_client/tools/find_big_maps_in_storage.rb', line 9 def execute case storage_type[:prim] when "pair" pair_type(data: storage, type: storage_type) when "list" list_type(data: storage, type: storage_type) when "big_map" big_map_type(data: storage, type: storage_type) end end |
#list_type(data:, type:) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tezos_client/tools/find_big_maps_in_storage.rb', line 33 def list_type(data:, type:) element_type = type[:args].first data.map do |elem| compose( TezosClient::Tools::ConvertToHash, data: elem, type: element_type ) end end |
#pair_type(data:, type:) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tezos_client/tools/find_big_maps_in_storage.rb', line 20 def pair_type(data:, type:) raise "Not a 'Pair' type" unless data[:prim] == "Pair" raise "Difference detected between data and type \nDATA: #{data} \nTYPE:#{type} " unless data[:args].size == type[:args].size (0 .. data[:args].size - 1).map do |iter| compose( TezosClient::Tools::FindBigMapsInStorage, storage: data[:args][iter], storage_type: type[:args][iter] ) end.compact.flatten end |
#var_name(type) ⇒ Object
53 54 55 |
# File 'lib/tezos_client/tools/find_big_maps_in_storage.rb', line 53 def var_name(type) "#{type[:annots].first[1..-1]}".to_sym end |