abi_coder_rb 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f20aa23f421459866cdbd1cd485027ec5fec4b52af891adc9c4025f247b42a9
4
- data.tar.gz: 439e3e33e16d8cd9b20267f6e35218adb3c542f7aa6e80482c8d9aafee220bd3
3
+ metadata.gz: 35ffe301040ab5e55279be3bb020ba62d5ba3488f94217b055aeca82a403f229
4
+ data.tar.gz: 5a2926ad367ec5fb5e4c9600dd67fd9a9550148bfdd53beb7b3d85e8b960ebff
5
5
  SHA512:
6
- metadata.gz: 6c423bbce7507e4dc2d79d73355c65b84c8ceff0bc4c9e89045e23a461084898c9b97e35225e6b0b8e0173ddb05d1dfd13c3df5e7071cfe05960254037e2a3f9
7
- data.tar.gz: d2977279469c49bc63d67c360d12b281bb2442856dddc166ef784b1311198afb0dabbe19604160c53edd5c54047b031113a6ae18e5ef60b93611b68fa9f8b657
6
+ metadata.gz: 40b222a5fbebb49b769f49ce10c0d1ec808d6c966a42338374e1a5faae5bd27378d15498f09e87de8ba3db12b724748524deba3ca02bedb5e2c6fd58a1ad724b
7
+ data.tar.gz: 05b4d4f66357980d6cef05c187790374ee4c8f23b7479c90faa3c2ac84c9cf5bb5833867e2cf8ebd8cfefaceff260e042e7fdacbf81d6cd8997e738c9794d793
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- abi_coder_rb (0.2.2)
4
+ abi_coder_rb (0.2.3)
5
5
  activesupport
6
6
 
7
7
  GEM
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AbiCoderRb
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
@@ -10,7 +10,8 @@ class EventDecoder
10
10
  # data_inputs
11
11
  :data_inputs, :data_type_str, :data_field_names, :data_field_names_flattened
12
12
 
13
- def initialize(event_abi)
13
+ # flatten_sep: separator for flattening event name if it is nested
14
+ def initialize(event_abi, flatten_sep = ".")
14
15
  @event_abi = event_abi
15
16
  @indexed_topic_inputs, @data_inputs = event_abi["inputs"].partition { |input| input["indexed"] }
16
17
 
@@ -23,7 +24,7 @@ class EventDecoder
23
24
  @data_type_str = fields_type_str(@data_fields)
24
25
 
25
26
  @data_field_names = fields_names(@data_fields)
26
- @data_field_names_flattened = fields_names_flatten(@data_fields)
27
+ @data_field_names_flattened = fields_names_flatten(@data_fields, sep: flatten_sep)
27
28
 
28
29
  # add after_decoding action
29
30
  after_decoding lambda { |type, value|
@@ -124,16 +125,17 @@ class EventDecoder
124
125
  #
125
126
  # returns:
126
127
  # ["root", "message_channel", "message_index", "message_fromChainId", "message_from", "message_toChainId", "message_to", "message_gasLimit", "message_encoded"]
127
- def fields_names_flatten(fields, prefix = nil)
128
+ def fields_names_flatten(fields, prefix: nil, sep: "_")
128
129
  fields.map do |name, type|
129
130
  name = name.underscore
130
131
  if type.is_a?(::Array)
131
132
  fields_names_flatten(
132
133
  type,
133
- prefix.nil? ? name : "#{prefix}.#{name}"
134
+ prefix: prefix.nil? ? name : "#{prefix}#{sep}#{name}",
135
+ sep: sep
134
136
  )
135
137
  elsif type.is_a?(::String)
136
- prefix.nil? ? name : "#{prefix}.#{name}"
138
+ prefix.nil? ? name : "#{prefix}#{sep}#{name}"
137
139
  end
138
140
  end.flatten
139
141
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abi_coder_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aki Wu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-30 00:00:00.000000000 Z
11
+ date: 2023-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport