Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 759 #2122

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/ckb_sync/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ def btc_time_code_hash
Settings.btc_time_code_hash
end

def single_use_lock_code_hash
Settings.single_use_lock_code_hash
end

METHOD_NAMES.each do |name|
define_method name do |*params|
call_rpc(name, params:)
Expand Down
2 changes: 1 addition & 1 deletion app/models/token_collection.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class TokenCollection < ApplicationRecord
VALID_TAGS = ["invalid", "suspicious", "out-of-length-range", "rgb++", "layer-1-asset", "layer-2-asset"]
VALID_TAGS = ["invalid", "suspicious", "out-of-length-range", "rgb++", "layer-1-asset", "layer-2-asset", "supply-limited"]

enum standard: { cota: "cota", spore: "spore", m_nft: "m_nft", nrc721: "nrc721" }

Expand Down
11 changes: 9 additions & 2 deletions app/workers/token_collection_tag_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
["suspicious"]
elsif out_of_length?(token_collection.name)
["out-of-length-range"]
elsif single_use_lock?(token_collection.creator.address_hash)
["supply-limited"]

Check warning on line 25 in app/workers/token_collection_tag_worker.rb

View check run for this annotation

Codecov / codecov/patch

app/workers/token_collection_tag_worker.rb#L25

Added line #L25 was not covered by tests
elsif rgbpp_lock?(token_collection.creator.address_hash)
["rgb++", "layer-1-asset"]
else
Expand All @@ -29,11 +31,11 @@
end

def invalid_char?(name)
!name.ascii_only?
!name.ascii_only? && (name =~ /^[\u4E00-\u9FFF]+$/).nil?
end

def invisible_char?(name)
(name =~ /^[\x21-\x7E]+(?:\s[\x21-\x7E]+)?$/).nil?
(name =~ /^[\x21-\x7E\u4E00-\u9FFF]+(?:\s[\x21-\x7E\u4E00-\u9FFF]+)?$/).nil?
end

def out_of_length?(name)
Expand All @@ -48,4 +50,9 @@
address_code_hash = CkbUtils.parse_address(issuer_address).script.code_hash
issuer_address.present? && CkbSync::Api.instance.rgbpp_code_hash.include?(address_code_hash)
end

def single_use_lock?(issuer_address)
address_script = CkbUtils.parse_address(issuer_address).script
issuer_address.present? && CkbSync::Api.instance.single_use_lock_code_hash == address_script.code_hash && address_script.hash_type == "data1"
end
end
7 changes: 7 additions & 0 deletions app/workers/xudt_tag_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
["utility"]
elsif !first_xudt?(udt.symbol, udt.block_timestamp)
["suspicious"]
elsif single_use_lock?(udt.issuer_address)
["supply-limited"]

Check warning on line 32 in app/workers/xudt_tag_worker.rb

View check run for this annotation

Codecov / codecov/patch

app/workers/xudt_tag_worker.rb#L32

Added line #L32 was not covered by tests
elsif rgbpp_lock?(udt.issuer_address)
["rgb++", "layer-1-asset", "supply-limited"]
else
Expand Down Expand Up @@ -56,6 +58,11 @@
issuer_address.present? && CkbSync::Api.instance.rgbpp_code_hash.include?(address_code_hash)
end

def single_use_lock?(issuer_address)
address_script = CkbUtils.parse_address(issuer_address).script
issuer_address.present? && CkbSync::Api.instance.single_use_lock_code_hash == address_script.code_hash && address_script.hash_type == "data1"
end

def utility_lp_token?(args)
args.length == 74
end
Expand Down
2 changes: 2 additions & 0 deletions config/settings.mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@ rgbpp_code_hash:
# btc time code hash
btc_time_code_hash:
- "0x70d64497a075bd651e98ac030455ea200637ee325a12ad08aff03f1a117e5a62"

single_use_lock_code_hash: "0x8290467a512e5b9a6b816469b0edabba1f4ac474e28ffdd604c2a7c76446bbaf"
2 changes: 2 additions & 0 deletions config/settings.testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ rgbpp_code_hash:
btc_time_code_hash:
- "0x00cdf8fab0f8ac638758ebf5ea5e4052b1d71e8a77b9f43139718621f6849326"
- "0x80a09eca26d77cea1f5a69471c59481be7404febf40ee90f886c36a948385b55"

single_use_lock_code_hash: "0x8290467a512e5b9a6b816469b0edabba1f4ac474e28ffdd604c2a7c76446bbaf"
Loading