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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e552bde0f9721d76aee5ee554e0f565dcda21275d977e675085c110e4b7cba9
4
- data.tar.gz: 74b56a49ceca14c4e15efd5fd278e6b6bc0cbb579a68df9c48f219a7531b4979
3
+ metadata.gz: 37ac7f6b47ec227db52fcd1b884eaad186126dcba3ddf7ec88f4f9ab489ccf15
4
+ data.tar.gz: 12d9366aec9a7e1325c6dd4d229136d4364e88b69f1f2619fad581a17b613e4f
5
5
  SHA512:
6
- metadata.gz: abd8889661b18e91a9283b4f8f533794c2bdeb06c1f470c29702a2e174d0d8eae4e154d79b37d1864710e14214555cfe52655ff83199a52baa94528c2b73b8d2
7
- data.tar.gz: 369051da2a2179f2aafc7e61f74b3c5b259b4301741ba794afa3bc3ff5ea83986687214bf70105a2c0d413613a467f954116814d818c11ca30e2154f7cc6b518
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'].to_f,
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  # lib/tron/version.rb
4
4
  module Tron
5
- VERSION = "1.0.6".freeze
5
+ VERSION = "1.0.7".freeze
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tron.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Your Name