tron.rb 1.0.6 → 1.0.7
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 +13 -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: 37ac7f6b47ec227db52fcd1b884eaad186126dcba3ddf7ec88f4f9ab489ccf15
|
|
4
|
+
data.tar.gz: 12d9366aec9a7e1325c6dd4d229136d4364e88b69f1f2619fad581a17b613e4f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d546d2261d6be7e39452fca60141c5f1a65db6422161b07dc11a6db64349c2c2211aa655c6c40be710cfbc5e58f3d63b9f8748d8fd890f55d83f2ea0c0e39765
|
|
7
|
+
data.tar.gz: b420d85ca3009e5b8ad0f49b4d6b7fe37cff4ff1b0e84756ee65486939a25b4499da2b47383a6d082c846843f1ccc724e83cb0539278180c574081e27d19f4d8
|
|
@@ -87,7 +87,7 @@ module Tron
|
|
|
87
87
|
{
|
|
88
88
|
symbol: token['token_abbr'] || token['token_name'],
|
|
89
89
|
name: token['token_name'],
|
|
90
|
-
balance: token['balance'].
|
|
90
|
+
balance: format_trc20_balance(token['balance'], (token['token_decimal'] || 6).to_i),
|
|
91
91
|
decimals: (token['token_decimal'] || 6).to_i,
|
|
92
92
|
address: token['token_id']
|
|
93
93
|
}
|
|
@@ -154,6 +154,18 @@ module Tron
|
|
|
154
154
|
"#{whole}.#{fraction.to_s.rjust(decimals, '0')}"
|
|
155
155
|
end
|
|
156
156
|
|
|
157
|
+
def format_trc20_balance(balance_str, decimals)
|
|
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
|
|
168
|
+
|
|
157
169
|
def api_headers
|
|
158
170
|
headers = { 'accept' => 'application/json' }
|
|
159
171
|
headers['TRON-PRO-API-KEY'] = @config.api_key if @config.api_key
|
data/lib/tron/version.rb
CHANGED