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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/abi_coder_rb/version.rb +1 -1
- data/lib/periphery/event_decoder.rb +7 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35ffe301040ab5e55279be3bb020ba62d5ba3488f94217b055aeca82a403f229
|
4
|
+
data.tar.gz: 5a2926ad367ec5fb5e4c9600dd67fd9a9550148bfdd53beb7b3d85e8b960ebff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40b222a5fbebb49b769f49ce10c0d1ec808d6c966a42338374e1a5faae5bd27378d15498f09e87de8ba3db12b724748524deba3ca02bedb5e2c6fd58a1ad724b
|
7
|
+
data.tar.gz: 05b4d4f66357980d6cef05c187790374ee4c8f23b7479c90faa3c2ac84c9cf5bb5833867e2cf8ebd8cfefaceff260e042e7fdacbf81d6cd8997e738c9794d793
|
data/Gemfile.lock
CHANGED
data/lib/abi_coder_rb/version.rb
CHANGED
@@ -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
|
-
|
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
|
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}
|
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}
|
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.
|
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
|
+
date: 2023-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|