Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
oshikawatkm committed May 19, 2021
1 parent 005f2e6 commit fefb27a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/glueby/contract/active_record/reissuable_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ module Contract
module AR
class ReissuableToken < ::ActiveRecord::Base

# Get the script_pubkey corresponding to the color_id in Tapyrus::Script format
# @param [String] color_id
# @return [Tapyrus::Script]
def self.script_pubkey(color_id)
Glueby::Contract::AR::ReissuableToken.where(color_id: color_id).pluck(:script_pubkey).first
script_pubkey_hex = Glueby::Contract::AR::ReissuableToken.where(color_id: color_id).pluck(:script_pubkey).first
Tapyrus::Script.parse_from_payload(script_pubkey_hex.htb)
end

# Check if the color_id is already stored
# @param [String] color_id
# @return [Boolean]
def self.saved?(color_id)
Glueby::Contract::AR::ReissuableToken.where(color_id: color_id).exists?
end
Expand Down

0 comments on commit fefb27a

Please sign in to comment.