Skip to content

Commit

Permalink
Merge pull request #1786 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
Deploy to testnet
  • Loading branch information
zmcNotafraid authored Apr 15, 2024
2 parents 066c98e + fdb16bf commit 1cba925
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v2/nft/holders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2/nft/items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions app/models/ckb_sync/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ 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

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

Expand Down
2 changes: 2 additions & 0 deletions config/settings.testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 16 additions & 3 deletions test/controllers/api/v2/nft/holders_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,38 @@ 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),
params: { sort: "quantity" }

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
Expand Down
3 changes: 2 additions & 1 deletion test/controllers/api/v2/nft/items_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/models/ckb_sync/node_data_processor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1cba925

Please sign in to comment.