diff --git a/app/models/udt.rb b/app/models/udt.rb index 5f10557e0..136a932e6 100644 --- a/app/models/udt.rb +++ b/app/models/udt.rb @@ -42,6 +42,10 @@ def type_script hash_type:, } end + + def holders_count + udt_holder_allocations.sum("ckb_holder_count + btc_holder_count") + end end # == Schema Information diff --git a/app/serializers/udt_serializer.rb b/app/serializers/udt_serializer.rb index 49ee340d0..3730e68a4 100644 --- a/app/serializers/udt_serializer.rb +++ b/app/serializers/udt_serializer.rb @@ -22,9 +22,12 @@ class UdtSerializer attribute :h24_ckb_transactions_count do |object| object.h24_ckb_transactions_count.to_s end - attributes :created_at do |object| + attribute :created_at do |object| object.block_timestamp.to_s end + attribute :holder do |object| + object.holders_count.to_s + end attribute :mint_status, if: Proc.new { |record, _params| record.udt_type == "omiga_inscription" diff --git a/test/controllers/api/v1/omiga_inscriptions_controller_test.rb b/test/controllers/api/v1/omiga_inscriptions_controller_test.rb index dde4b207e..faf015653 100644 --- a/test/controllers/api/v1/omiga_inscriptions_controller_test.rb +++ b/test/controllers/api/v1/omiga_inscriptions_controller_test.rb @@ -72,7 +72,7 @@ class OmigaInscriptionsControllerTest < ActionDispatch::IntegrationTest assert_equal %w( symbol full_name total_amount addresses_count decimal icon_file h24_ckb_transactions_count created_at description - published type_hash type_script issuer_address mint_status mint_limit expected_supply + published type_hash type_script issuer_address mint_status mint_limit expected_supply holder inscription_info_id udt_type pre_udt_hash info_type_hash operator_website email is_repeated_symbol ).sort, response_udt["attributes"].keys.sort @@ -86,7 +86,7 @@ class OmigaInscriptionsControllerTest < ActionDispatch::IntegrationTest response_udt = json["data"] assert_equal %w( symbol full_name total_amount addresses_count - decimal icon_file h24_ckb_transactions_count created_at description + decimal icon_file h24_ckb_transactions_count created_at description holder published type_hash type_script issuer_address mint_status mint_limit expected_supply inscription_info_id udt_type pre_udt_hash info_type_hash operator_website email is_repeated_symbol ).sort, diff --git a/test/controllers/api/v1/udts_controller_test.rb b/test/controllers/api/v1/udts_controller_test.rb index bd742fa68..c294a9802 100644 --- a/test/controllers/api/v1/udts_controller_test.rb +++ b/test/controllers/api/v1/udts_controller_test.rb @@ -120,7 +120,7 @@ class UdtsControllerTest < ActionDispatch::IntegrationTest response_tx_transaction = json["data"] assert_equal %w( - symbol full_name total_amount addresses_count + symbol full_name total_amount addresses_count holder decimal icon_file h24_ckb_transactions_count created_at description published type_hash type_script issuer_address udt_type operator_website email ).sort,