diff --git a/app/controllers/api/v2/nft/holders_controller.rb b/app/controllers/api/v2/nft/holders_controller.rb index b924febbb..045d7434d 100644 --- a/app/controllers/api/v2/nft/holders_controller.rb +++ b/app/controllers/api/v2/nft/holders_controller.rb @@ -3,7 +3,7 @@ module V2 module NFT class HoldersController < BaseController def index - token_items = find_collection.items.joins(:owner) + token_items = find_collection.items.normal.joins(:owner) if params[:address_hash].present? owner = Address.find_address!(params[:address_hash]) diff --git a/app/controllers/api/v2/nft/items_controller.rb b/app/controllers/api/v2/nft/items_controller.rb index a44cbc223..13ceb8aef 100644 --- a/app/controllers/api/v2/nft/items_controller.rb +++ b/app/controllers/api/v2/nft/items_controller.rb @@ -3,7 +3,7 @@ module V2 class NFT::ItemsController < BaseController before_action :find_collection def index - scope = TokenItem.includes(:collection) + scope = TokenItem.normal.includes(:collection) if params[:owner] @owner = Address.find_address!(params[:owner]) scope = scope.where(owner_id: @owner.id) diff --git a/app/models/ckb_sync/api.rb b/app/models/ckb_sync/api.rb index b7b3e2f7e..cf57e4cf2 100644 --- a/app/models/ckb_sync/api.rb +++ b/app/models/ckb_sync/api.rb @@ -75,7 +75,7 @@ def spore_cluster_code_hashes if mode == CKB::MODE::MAINNET [Settings.spore_cluster1_code_hash] else - [Settings.spore_cluster1_code_hash, Settings.spore_cluster2_code_hash] + [Settings.spore_cluster1_code_hash, Settings.spore_cluster2_code_hash, Settings.spore_cluster3_code_hash] end end @@ -83,7 +83,7 @@ def spore_cell_code_hashes if mode == CKB::MODE::MAINNET [Settings.spore_cell1_code_hash] else - [Settings.spore_cell1_code_hash, Settings.spore_cell2_code_hash] + [Settings.spore_cell1_code_hash, Settings.spore_cell2_code_hash, Settings.spore_cell3_code_hash] end end diff --git a/config/settings.testnet.yml b/config/settings.testnet.yml index 7578ca359..71b0ea890 100644 --- a/config/settings.testnet.yml +++ b/config/settings.testnet.yml @@ -23,8 +23,10 @@ nrc_721_token_output_data_header: "0x0ddeff3e8ee03cbf6a2c6920d05c381e" # spore nft code hash spore_cluster1_code_hash: "0x7366a61534fa7c7e6225ecc0d828ea3b5366adec2b58206f2ee84995fe030075" # tag: v2 preview spore_cluster2_code_hash: "0x598d793defef36e2eeba54a9b45130e4ca92822e1d193671f490950c3b856080" # tag: v1 latest +spore_cluster3_code_hash: "0x0bbe768b519d8ea7b96d58f1182eb7e6ef96c541fbd9526975077ee09f049058" # tag: 0.2.2-beta.2 spore_cell1_code_hash: "0x5e063b4c0e7abeaa6a428df3b693521a3050934cf3b0ae97a800d1bc31449398" # tag: v2 preview spore_cell2_code_hash: "0xbbad126377d45f90a8ee120da988a2d7332c78ba8fd679aab478a19d6c133494" # tag: v1 latest +spore_cell3_code_hash: "0x685a60219309029d01310311dba953d67029170ca4848a4ff638e57002130a0d" # tag: 0.2.2-beta.2 # omiga inscription info omiga_inscription_info_code_hash: "0x50fdea2d0030a8d0b3d69f883b471cab2a29cae6f01923f19cecac0f27fdaaa6" diff --git a/test/controllers/api/v2/nft/holders_controller_test.rb b/test/controllers/api/v2/nft/holders_controller_test.rb index c7ac752f5..d377e295f 100644 --- a/test/controllers/api/v2/nft/holders_controller_test.rb +++ b/test/controllers/api/v2/nft/holders_controller_test.rb @@ -49,17 +49,29 @@ class HoldersControllerTest < ActionDispatch::IntegrationTest assert_equal item.owner.address_hash, json["data"].keys[0] end + test "should not return mint items" do + collection = create(:token_collection, :with_items) + item = collection.items.sample + create(:token_item, collection_id: collection.id, status: :burnt, owner_id: item.owner.id) + + get api_v2_nft_collection_holders_url(collection_id: collection.id), + params: { address_hash: item.owner.address_hash } + + assert_equal 1, json["data"].size + assert_equal item.owner.address_hash, json["data"].keys[0] + end + test "should sorted by quantity asc when sort param is quantity" do collection = create(:token_collection, items_count: 6, holders_count: 2) owner = create(:address) 4.times do |i| - create(:token_item, token_id: i, collection: collection, owner: owner) + create(:token_item, token_id: i, collection:, owner:) end owner = create(:address) 3.times do |i| - create(:token_item, token_id: i + 4, collection: collection, owner: owner) + create(:token_item, token_id: i + 4, collection:, owner:) end get api_v2_nft_collection_holders_url(collection_id: collection.id), @@ -67,7 +79,8 @@ class HoldersControllerTest < ActionDispatch::IntegrationTest response_json = { data: collection.items.joins(:owner). - order("count_all asc").group(:address_hash).count }.as_json + order("count_all asc").group(:address_hash).count, + }.as_json assert_equal response_json, json end diff --git a/test/controllers/api/v2/nft/items_controller_test.rb b/test/controllers/api/v2/nft/items_controller_test.rb index 7d517d2de..93dfd9612 100644 --- a/test/controllers/api/v2/nft/items_controller_test.rb +++ b/test/controllers/api/v2/nft/items_controller_test.rb @@ -7,12 +7,13 @@ def setup super end - test "should get index with collection id" do + test "should get index with collection id without burnt item" do token_collection = create :token_collection, name: "token1" address = create :address, is_depositor: true create :token_item, name: "item1", collection_id: token_collection.id, owner_id: address.id create :token_item, name: "item2", collection_id: token_collection.id, owner_id: address.id + create :token_item, name: "item3", collection_id: token_collection.id, owner_id: address.id, status: :burnt get api_v2_nft_collection_items_url(collection_id: token_collection.id) assert_response :success diff --git a/test/controllers/api/v2/portfolio/sessions_controller_test.rb b/test/controllers/api/v2/portfolio/sessions_controller_test.rb index e42b58b2d..215fb9818 100644 --- a/test/controllers/api/v2/portfolio/sessions_controller_test.rb +++ b/test/controllers/api/v2/portfolio/sessions_controller_test.rb @@ -59,6 +59,7 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest jwt = PortfolioUtils.generate_jwt(payload) assert_equal jwt, json["jwt"] + ENV["CKB_NET_MODE"] = "mainnet" end end end diff --git a/test/models/ckb_sync/node_data_processor_test.rb b/test/models/ckb_sync/node_data_processor_test.rb index 4b272bcb9..225d77a90 100644 --- a/test/models/ckb_sync/node_data_processor_test.rb +++ b/test/models/ckb_sync/node_data_processor_test.rb @@ -4185,6 +4185,7 @@ class NodeDataProcessorTest < ActiveSupport::TestCase assert_equal 8, xudt.decimal assert_equal "xudt", xudt.udt_type assert_equal "ckt1qrfrwcdnvssswdwpn3s9v8fp87emat306ctjwsm3nmlkjg8qyza2cqgqqxsg5hs8ag0uv4rsmtr0940kl850pkuxuugetsnt", xudt.issuer_address + ENV["CKB_NET_MODE"] = "mainnet" end end