tron.rb 1.0.7 → 1.0.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/services/balance.rb +9 -13
- data/lib/tron/version.rb +1 -1
- 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: 530fde2195467fe3316fced5499bb3d4a82823b47ee0032fca7c676f89cf3b6c
|
|
4
|
+
data.tar.gz: 518fa7e74e09d85694f00aee805e10debd469798969d7eff715bc73bfb0be7ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62e0177fdab3c7046b2b3db15745ac01b4ae7db31acae4b3f0b1cf570dde96d3c4e56f6e80185ad323b3a2de6378b4b9f9fbc6536d9590b705c361d2ed95f01f
|
|
7
|
+
data.tar.gz: 14caf1ed3a549c8423db2562416ec0cc894b4fd8398acbc69d2c646f008c6cff7240c86ed2b811fdfb1ec3e204516d49c1cefa324de0f43a4d70d1c9c7cae1c7
|
|
@@ -40,7 +40,13 @@ module Tron
|
|
|
40
40
|
raise "Unexpected API response format" unless response.is_a?(Hash)
|
|
41
41
|
raise "Missing 'data' field in response" unless response.key?('data')
|
|
42
42
|
raise "Invalid 'data' format in response" unless response['data'].is_a?(Array)
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
# Handle empty data array (new/inactive accounts) - return 0 balance
|
|
45
|
+
if response['data'].empty?
|
|
46
|
+
result = "0.000000"
|
|
47
|
+
@cache.set(cache_key, result) if @config.cache_enabled
|
|
48
|
+
return result
|
|
49
|
+
end
|
|
44
50
|
|
|
45
51
|
account_data = response['data'].first
|
|
46
52
|
raise "Invalid account data format" unless account_data.is_a?(Hash)
|
|
@@ -87,7 +93,7 @@ module Tron
|
|
|
87
93
|
{
|
|
88
94
|
symbol: token['token_abbr'] || token['token_name'],
|
|
89
95
|
name: token['token_name'],
|
|
90
|
-
balance:
|
|
96
|
+
balance: token['balance'].to_f,
|
|
91
97
|
decimals: (token['token_decimal'] || 6).to_i,
|
|
92
98
|
address: token['token_id']
|
|
93
99
|
}
|
|
@@ -154,17 +160,7 @@ module Tron
|
|
|
154
160
|
"#{whole}.#{fraction.to_s.rjust(decimals, '0')}"
|
|
155
161
|
end
|
|
156
162
|
|
|
157
|
-
|
|
158
|
-
# Convert to float while avoiding scientific notation for small numbers
|
|
159
|
-
balance = balance_str.to_f
|
|
160
|
-
|
|
161
|
-
# Format to avoid scientific notation for small numbers
|
|
162
|
-
if balance.abs < 1e-4 && balance != 0
|
|
163
|
-
format("%.#{decimals}f", balance).gsub(/0+$/, '')
|
|
164
|
-
else
|
|
165
|
-
balance
|
|
166
|
-
end
|
|
167
|
-
end
|
|
163
|
+
|
|
168
164
|
|
|
169
165
|
def api_headers
|
|
170
166
|
headers = { 'accept' => 'application/json' }
|
data/lib/tron/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tron.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Your Name
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-10-
|
|
11
|
+
date: 2025-10-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base58
|