diff --git a/app/controllers/api/v1/xudts_controller.rb b/app/controllers/api/v1/xudts_controller.rb index 707a1e02c..7b0e7c601 100644 --- a/app/controllers/api/v1/xudts_controller.rb +++ b/app/controllers/api/v1/xudts_controller.rb @@ -7,7 +7,7 @@ class XudtsController < ApplicationController before_action :validate_pagination_params, :pagination_params, only: :index def index - scope = Udt.xudt.includes(:xudt_tag) + scope = Udt.includes(:xudt_tag).where(udt_type: xudt_type_params) if params[:symbol].present? scope = scope.where("LOWER(symbol) = ?", params[:symbol].downcase) @@ -104,6 +104,10 @@ def parse_tags tags = params[:tags].split(",") tags & XudtTag::VALID_TAGS end + + def xudt_type_params + params[:type].blank? ? "xudt" : "xudt_compatible" + end end end end diff --git a/config/settings.mainnet.yml b/config/settings.mainnet.yml index 27576bacd..596b2c769 100644 --- a/config/settings.mainnet.yml +++ b/config/settings.mainnet.yml @@ -32,7 +32,7 @@ omiga_inscription_code_hash: "0x7490970e6af9b9fe63fc19fc523a12b2ec69027e6ae484ed xudt_code_hash: "0x50bd8d6680b8b9cf98b73f3c08faf8b2a21914311954118ad6609be6e78a1b95" # xudt compatible -xudt_compatible_code_hash: "0x74f8fd146cca83d5fa2acd8a2b0bc7f0408a38b79a173c1e8ca1fbdfc95122ff" +xudt_compatible_code_hash: "0x092c2c4a26ea475a8e860c29cf00502103add677705e2ccd8d6fe5af3caa5ae3" unique_cell_code_hash: "0x2c8c11c985da60b0a330c61a85507416d6382c130ba67f0c47ab071e00aec628" diff --git a/config/settings.testnet.yml b/config/settings.testnet.yml index 251898c99..8ea7fe3d8 100644 --- a/config/settings.testnet.yml +++ b/config/settings.testnet.yml @@ -35,6 +35,9 @@ omiga_inscription_code_hash: "0x3a241ceceede72a5f55c8fb985652690f09a517d6c9070f0 xudt_code_hash: "0x25c29dc317811a6f6f3985a7a9ebc4838bd388d19d0feeecf0bcd60f6c0975bb" unique_cell_code_hash: "0x8e341bcfec6393dcd41e635733ff2dca00a6af546949f70c57a706c0f344df8b" +# xudt compatible +xudt_compatible_code_hash: "0x98701eaf939113606a8a70013fd2e8f27b8f1e234acdc329f3d71f9e9d3d3233" + # hash length of an attribute(especially which comes from bytea column), # e.g. Block.uncle_block_hashes: "0x587f354162afd133b4a4f7a4b621d11e043c3c08b0af2801f1686b5403b14953", which has a length of 66 ( 2 + 64) default_hash_length: "64" @@ -82,4 +85,3 @@ proposal_window: 10 rgbpp_code_hash: "0x61ca7a4796a4eb19ca4f0d065cb9b10ddcf002f10f7cbb810c706cb6bb5c3248" # btc time code hash btc_time_code_hash: "0x00cdf8fab0f8ac638758ebf5ea5e4052b1d71e8a77b9f43139718621f6849326" - diff --git a/test/controllers/api/v1/xudts_controller_test.rb b/test/controllers/api/v1/xudts_controller_test.rb index 7aea9c8fe..9563208eb 100644 --- a/test/controllers/api/v1/xudts_controller_test.rb +++ b/test/controllers/api/v1/xudts_controller_test.rb @@ -19,6 +19,16 @@ class XudtsControllerTest < ActionDispatch::IntegrationTest assert_response :success end + test "should get success code when call xudt_compatible index " do + create(:udt, :xudt_compatible, published: true) + + valid_get api_v1_xudts_url, params: {type: "xudt_compatible"} + + assert_response :success + assert_equal 1, json["data"].length + end + + test "filter xudt by symbol and tags" do udt = create(:udt, :xudt, symbol: "CKBB") create(:xudt_tag, udt:, tags: ["duplicate", "layer-1-asset", "supply-limited"]) diff --git a/test/factories/udt.rb b/test/factories/udt.rb index 350a65486..094165fdc 100644 --- a/test/factories/udt.rb +++ b/test/factories/udt.rb @@ -63,5 +63,14 @@ symbol { "BBQ" } decimal { 8 } end + + trait :xudt_compatible do + udt_type { "xudt_compatible" } + published { true } + full_name { "XUDTCompatible" } + symbol { "XC" } + decimal { 8 } + end + end end