Skip to content

Commit

Permalink
feat: rename token_collection standard spore_cell to spore (#1408)
Browse files Browse the repository at this point in the history
* feat: rename token_collection standard spore_cell to spore

Signed-off-by: Miles Zhang <mingchang555@hotmail.com>

* fix: type script's cell_outputs use first one

Signed-off-by: Miles Zhang <mingchang555@hotmail.com>

---------

Signed-off-by: Miles Zhang <mingchang555@hotmail.com>
  • Loading branch information
zmcNotafraid committed Aug 25, 2023
1 parent f11be86 commit 11e08a9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/models/ckb_sync/new_node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def build_udts!(local_block, outputs, outputs_data)
spore_cluster_cell = spore_cluster_type.cell_outputs.last
parsed_cluster_data = CkbUtils.parse_spore_cluster_data(spore_cluster_cell.data)
coll = TokenCollection.find_or_create_by(
standard: "spore_cell",
standard: "spore",
name: parsed_cluster_data[:name],
description: parsed_cluster_data[:description],
cell_id: spore_cluster_cell.id,
Expand Down
4 changes: 2 additions & 2 deletions app/serializers/address_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class AddressSerializer
udt_type: udt_account.udt_type
}
elsif udt_account.udt_type == "spore_cell"
ts = TypeScript.find_by script_hash: udt_account.type_hash
data = CellOutput.where(type_script_id: ts.id)&.last&.data
ts = TypeScript.where(script_hash: udt_account.type_hash).first
data = ts.cell_outputs.order("id desc").first.data
if ts
i = TokenItem.includes(collection: :type_script).find_by type_script_id: ts.id
coll = i&.collection
Expand Down
10 changes: 5 additions & 5 deletions app/workers/token_transfer_detect_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def find_or_create_collection(cell, type_script)
when "m_nft_token"
find_or_create_m_nft_collection(cell, type_script)
when "spore_cell"
find_or_create_spore_cell_collection(cell, type_script)
find_or_create_spore_collection(cell, type_script)
end
end

Expand Down Expand Up @@ -141,19 +141,19 @@ def find_or_create_m_nft_collection(cell, type_script)
coll
end

def find_or_create_spore_cell_collection(cell, type_script)
spore_cell = type_script.cell_outputs.last
def find_or_create_spore_collection(cell, type_script)
spore_cell = type_script.cell_outputs.order("id desc").first
parsed_spore_cell = CkbUtils.parse_spore_cell_data(spore_cell.data)
spore_cluster_type = TypeScript.create_with(hash_type: "data1").find_or_create_by!(
code_hash: CkbSync::Api.instance.spore_cluster_code_hash,
args: parsed_spore_cell[:cluster_id]
)
coll = TokenCollection.find_or_create_by(
standard: "spore_cell",
standard: "spore",
type_script_id: spore_cluster_type.id,
sn: spore_cluster_type.script_hash
)
spore_cluster_cell = spore_cluster_type.cell_outputs.last
spore_cluster_cell = spore_cluster_type.cell_outputs.order("id desc").first
if spore_cluster_cell.present? && coll.cell_id.blank?
parsed_cluster_data = CkbUtils.parse_spore_cluster_data(spore_cluster_cell.data)
coll.cell_id = spore_cluster_cell.id
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/api/v1/addresses_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class AddressesControllerTest < ActionDispatch::IntegrationTest
output = create :cell_output, :with_full_transaction, cell_type: "spore_cell"
cell_data = create :cell_datum, cell_output: output
cluster_type = create :type_script
tc = create :token_collection, type_script: cluster_type, standard: "spore_cell"
tc = create :token_collection, type_script: cluster_type, standard: "spore"
create :token_item, collection_id: tc.id, cell_id: output.id
address = create(:address, :with_lock_script)
udt = create(:udt, udt_type: "spore_cell", full_name: "SporeTest")
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/api/v2/nft/items_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def setup
end

test "should return spore cell" do
token_collection = create :token_collection, name: "token1", standard: "spore_cell"
token_collection = create :token_collection, name: "token1", standard: "spore"
address = create :address, is_depositor: true
my_token_id = 100
cell = create :cell_output, :with_full_transaction
Expand All @@ -59,7 +59,7 @@ def setup
get api_v2_nft_collection_item_url(id: my_token_id, collection_id: token_collection.id)

assert_response :success
assert_equal JSON.parse(response.body)["standard"], "spore_cell"
assert_equal JSON.parse(response.body)["standard"], "spore"
assert_not_nil JSON.parse(response.body)["cell"]["data"]
end
end
Expand Down

0 comments on commit 11e08a9

Please sign in to comment.