Skip to content

Commit 4d4fadf

Browse files
authored
fix address balance and balance_occupied to_i (#2912)
1 parent 18b6e11 commit 4d4fadf

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

app/models/address.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def recalc_revalidate_balance!
161161
end
162162

163163
def current_balance
164-
self.cell_outputs.live.sum(:capacity)
164+
self.cell_outputs.live.sum(:capacity).to_i
165165
end
166166

167167
def current_ckb_transactions_count
@@ -173,12 +173,12 @@ def current_live_cells_count
173173
end
174174

175175
def current_balance_occupied
176-
self.cell_outputs.live.occupied.sum(:capacity)
176+
self.cell_outputs.live.occupied.sum(:capacity).to_i
177177
end
178178

179179
def cal_balance
180-
total = cell_outputs.live.sum(:capacity)
181-
occupied = cell_outputs.live.occupied.sum(:capacity)
180+
total = cell_outputs.live.sum(:capacity).to_i
181+
occupied = cell_outputs.live.occupied.sum(:capacity).to_i
182182
[total, occupied]
183183
end
184184

test/controllers/api/v1/addresses_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class AddressesControllerTest < ActionDispatch::IntegrationTest
191191
address_hash: "ckb1qyq0hcfpff4h8w8zvy44uurvlgdrr09tefwqx266dl")
192192

193193
valid_get api_v1_address_url(address.address_hash)
194-
assert_equal "0.0", json.dig("data", 0, "attributes", "balance_occupied")
194+
assert_equal "0", json.dig("data", 0, "attributes", "balance_occupied")
195195
end
196196

197197
test "should return nrc 721 udt accounts with given address hash" do

0 commit comments

Comments
 (0)