tron.rb 1.1.6 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tron/abi/type.rb +6 -6
- data/lib/tron/abi.rb +35 -1
- data/lib/tron/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 232c93f724a0aeb89150ec237af9c4a6d504b3635aabff7c833e9b71660a8752
|
|
4
|
+
data.tar.gz: 4403e025c9d31a49e26da6cde92cfeb184df9626d97d76d662eb43ae3644728b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8032ab96d92f191b7a3c6923104d656a5edb451a0498b57d339fc823084d3041b3da618ed106d015d60d17c99fb50d11a1b0228d8c1ee61ab80876feaf535a43
|
|
7
|
+
data.tar.gz: a4bdca985bb3cf4389fd045711a2f7a3bcea9f15ddc4902a3ccb4c5e1e624d50140ae2ee1b0438fb23eb95f5e9e98e39c3316b060c877d6b22a27a45cb093df4
|
data/lib/tron/abi/type.rb
CHANGED
|
@@ -233,24 +233,24 @@ module Tron
|
|
|
233
233
|
def split_tuple_types(str)
|
|
234
234
|
types = []
|
|
235
235
|
depth = 0
|
|
236
|
-
current =
|
|
236
|
+
current = String.new
|
|
237
237
|
str.each_char do |ch|
|
|
238
238
|
case ch
|
|
239
239
|
when "("
|
|
240
240
|
depth += 1
|
|
241
|
-
current
|
|
241
|
+
current << ch
|
|
242
242
|
when ")"
|
|
243
243
|
depth -= 1
|
|
244
|
-
current
|
|
244
|
+
current << ch
|
|
245
245
|
when ","
|
|
246
246
|
if depth.zero?
|
|
247
247
|
types << current
|
|
248
|
-
current =
|
|
248
|
+
current = String.new
|
|
249
249
|
else
|
|
250
|
-
current
|
|
250
|
+
current << ch
|
|
251
251
|
end
|
|
252
252
|
else
|
|
253
|
-
current
|
|
253
|
+
current << ch
|
|
254
254
|
end
|
|
255
255
|
end
|
|
256
256
|
types << current unless current.empty?
|
data/lib/tron/abi.rb
CHANGED
|
@@ -89,7 +89,7 @@ module Tron
|
|
|
89
89
|
|
|
90
90
|
function_name = match[1]
|
|
91
91
|
param_types_str = match[2]
|
|
92
|
-
param_types = param_types_str.empty? ? [] : param_types_str
|
|
92
|
+
param_types = param_types_str.empty? ? [] : split_function_params(param_types_str)
|
|
93
93
|
|
|
94
94
|
# Get function selector (first 4 bytes of keccak256 hash)
|
|
95
95
|
require_relative 'utils/crypto'
|
|
@@ -105,6 +105,40 @@ module Tron
|
|
|
105
105
|
selector + encoded_params
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
+
# Splits function parameter types on commas, handling nested tuples.
|
|
109
|
+
# Based on eth.rb's split_tuple_types implementation.
|
|
110
|
+
#
|
|
111
|
+
# @param params_str [String] parameter types string
|
|
112
|
+
# @return [Array<String>] array of parameter type strings
|
|
113
|
+
def self.split_function_params(params_str)
|
|
114
|
+
types = []
|
|
115
|
+
depth = 0
|
|
116
|
+
current = String.new
|
|
117
|
+
|
|
118
|
+
params_str.each_char do |ch|
|
|
119
|
+
case ch
|
|
120
|
+
when "("
|
|
121
|
+
depth += 1
|
|
122
|
+
current << ch
|
|
123
|
+
when ")"
|
|
124
|
+
depth -= 1
|
|
125
|
+
current << ch
|
|
126
|
+
when ","
|
|
127
|
+
if depth.zero?
|
|
128
|
+
types << current.strip
|
|
129
|
+
current = String.new
|
|
130
|
+
else
|
|
131
|
+
current << ch
|
|
132
|
+
end
|
|
133
|
+
else
|
|
134
|
+
current << ch
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
types << current.strip unless current.empty?
|
|
139
|
+
types
|
|
140
|
+
end
|
|
141
|
+
|
|
108
142
|
# Decode output from a contract call
|
|
109
143
|
#
|
|
110
144
|
# @param type_str [String] the output type
|
data/lib/tron/version.rb
CHANGED