Class: Glueby::Contract::AR::ReissuableToken

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/glueby/contract/active_record/reissuable_token.rb

Class Method Summary collapse

Class Method Details

.saved?(color_id) ⇒ Boolean

Check if the color_id is already stored

Parameters:

  • color_id (String)

Returns:

  • (Boolean)


19
20
21
# File 'lib/glueby/contract/active_record/reissuable_token.rb', line 19

def self.saved?(color_id)
  Glueby::Contract::AR::ReissuableToken.where(color_id: color_id).exists?
end

.script_pubkey(color_id) ⇒ Tapyrus::Script

Get the script_pubkey corresponding to the color_id in Tapyrus::Script format

Parameters:

  • color_id (String)

Returns:

  • (Tapyrus::Script)


9
10
11
12
13
14
# File 'lib/glueby/contract/active_record/reissuable_token.rb', line 9

def self.script_pubkey(color_id)
  script_pubkey = Glueby::Contract::AR::ReissuableToken.where(color_id: color_id).pluck(:script_pubkey).first
  if script_pubkey
    Tapyrus::Script.parse_from_payload(script_pubkey.htb)
  end
end