tron.rb 1.1.6 → 1.1.8
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.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: 3f65afcef7296fb42344c717853afcaa8e52a1f83e12a69312f81c0a0d3294a5
|
|
4
|
+
data.tar.gz: b01b36dc42d85509e6d66fe14f623faed1361fdbb10a4744365fcece0b0a1e92
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4814d06a4802cd9974a8b82fb51f65d9b4559a73283973daa37f56a4ee189e9c2b2dee91cb711f5120bf5e377388db6079981418153c57ff3ac3a9007044e3e8
|
|
7
|
+
data.tar.gz: 61623d25f36496dd227025c4c415557b1853a83e4e75588b1284484a9149856fb8c4379304c32376dca0fc55cf44b8fb274f1ad692425a7dce1a41efd8a71734
|
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 = ""
|
|
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 = ""
|
|
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