Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/holder allocation #2285

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/udt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion app/serializers/udt_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/api/v1/omiga_inscriptions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/api/v1/udts_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading