Skip to content

Commit

Permalink
feat: add missing attribute for cell output
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <mingchang555@hotmail.com>
  • Loading branch information
zmcNotafraid committed Feb 7, 2024
1 parent 11621ff commit 22ff6cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
16 changes: 10 additions & 6 deletions app/serializers/cell_output_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ class CellOutputSerializer

attributes :cell_type, :tx_hash, :cell_index, :type_hash, :data

attribute :block_number do |object|
object.block.number.to_s
end

attribute :capacity do |object|
object.capacity.to_s
end
Expand All @@ -26,17 +30,17 @@ class CellOutputSerializer
attribute :extra_info do |object|
case object.cell_type
when "udt"
object.udt_info
object.udt_info.merge!(type: "udt")
when "cota_registry"
object.cota_registry_info
object.cota_registry_info.merge!(type: "cota")
when "cota_regular"
object.cota_regular_info
object.cota_regular_info.merge!(type: "cota")
when "m_nft_issuer", "m_nft_class", "m_nft_token"
object.m_nft_info
object.m_nft_info.merge!(type: "m_nft")
when "nrc_721_token", "nrc_721_factory"
object.nrc_721_nft_info
object.nrc_721_nft_info.merge!(type: "nrc_721")
when "omiga_inscription_info", "omiga_inscription"
object.omiga_inscription_info
object.omiga_inscription_info.merge!(type: "omiga_inscription")
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class AddressLiveCellsControllerTest < ActionDispatch::IntegrationTest
valid_get api_v1_address_live_cell_url(address.address_hash)
assert_equal ({ "cell_type" => "omiga_inscription_info",
"tx_hash" => transaction.tx_hash,
"block_number" => block.number.to_s,
"cell_index" => 0,
"type_hash" => info.type_hash,
"data" => "0x0814434b42204669737420496e736372697074696f6e04434b4249a69f54bf339dd121febe64cb0be3a2cf366a8b13ec1a5ae4bebdccb9039c7efa0040075af0750700000000000000000000e8764817000000000000000000000002",
Expand All @@ -65,7 +66,7 @@ class AddressLiveCellsControllerTest < ActionDispatch::IntegrationTest
"hash_type" => "type" },
"lock_script" => { "args" => address_lock.args, "code_hash" => address_lock.code_hash,
"hash_type" => "type" },
"extra_info" => { "symbol" => "CKBI", "name" => "CKB Fist Inscription", "decimal" => "8.0", "amount" => "0" } }),
"extra_info" => { "type" => "omiga_inscription", "symbol" => "CKBI", "name" => "CKB Fist Inscription", "decimal" => "8.0", "amount" => "0" } }),
json["data"].first["attributes"]
end

Expand Down

0 comments on commit 22ff6cc

Please sign in to comment.