Class: TridentAssistant::Utils::Memo
- Inherits:
-
Object
- Object
- TridentAssistant::Utils::Memo
- Defined in:
- lib/trident_assistant/utils/memo.rb
Overview
build metadata of NFT
Instance Attribute Summary collapse
-
#asset_id ⇒ Object
Returns the value of attribute asset_id.
-
#decoded ⇒ Object
Returns the value of attribute decoded.
-
#encoded ⇒ Object
Returns the value of attribute encoded.
-
#expire_at ⇒ Object
Returns the value of attribute expire_at.
-
#order_id ⇒ Object
Returns the value of attribute order_id.
-
#price ⇒ Object
Returns the value of attribute price.
-
#receiver_id ⇒ Object
Returns the value of attribute receiver_id.
-
#reserve_price ⇒ Object
Returns the value of attribute reserve_price.
-
#start_at ⇒ Object
Returns the value of attribute start_at.
-
#token_id ⇒ Object
Returns the value of attribute token_id.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #decode ⇒ Object
- #encode ⇒ Object
-
#initialize(**kwargs) ⇒ Memo
constructor
A new instance of Memo.
- #json ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ Memo
Returns a new instance of Memo.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/trident_assistant/utils/memo.rb', line 10 def initialize(**kwargs) @type = kwargs[:type] @token_id = kwargs[:token_id] @asset_id = kwargs[:asset_id] @order_id = kwargs[:order_id] @price = kwargs[:price] @reserve_price = kwargs[:reserve_price] @receiver_id = kwargs[:receiver_id] @start_at = kwargs[:start_at] @expire_at = kwargs[:expire_at] @encoded = kwargs[:encoded] end |
Instance Attribute Details
#asset_id ⇒ Object
Returns the value of attribute asset_id.
7 8 9 |
# File 'lib/trident_assistant/utils/memo.rb', line 7 def asset_id @asset_id end |
#decoded ⇒ Object
Returns the value of attribute decoded.
7 8 9 |
# File 'lib/trident_assistant/utils/memo.rb', line 7 def decoded @decoded end |
#encoded ⇒ Object
Returns the value of attribute encoded.
7 8 9 |
# File 'lib/trident_assistant/utils/memo.rb', line 7 def encoded @encoded end |
#expire_at ⇒ Object
Returns the value of attribute expire_at.
7 8 9 |
# File 'lib/trident_assistant/utils/memo.rb', line 7 def expire_at @expire_at end |
#order_id ⇒ Object
Returns the value of attribute order_id.
7 8 9 |
# File 'lib/trident_assistant/utils/memo.rb', line 7 def order_id @order_id end |
#price ⇒ Object
Returns the value of attribute price.
7 8 9 |
# File 'lib/trident_assistant/utils/memo.rb', line 7 def price @price end |
#receiver_id ⇒ Object
Returns the value of attribute receiver_id.
7 8 9 |
# File 'lib/trident_assistant/utils/memo.rb', line 7 def receiver_id @receiver_id end |
#reserve_price ⇒ Object
Returns the value of attribute reserve_price.
7 8 9 |
# File 'lib/trident_assistant/utils/memo.rb', line 7 def reserve_price @reserve_price end |
#start_at ⇒ Object
Returns the value of attribute start_at.
7 8 9 |
# File 'lib/trident_assistant/utils/memo.rb', line 7 def start_at @start_at end |
#token_id ⇒ Object
Returns the value of attribute token_id.
7 8 9 |
# File 'lib/trident_assistant/utils/memo.rb', line 7 def token_id @token_id end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/trident_assistant/utils/memo.rb', line 7 def type @type end |
Instance Method Details
#decode ⇒ Object
57 58 59 |
# File 'lib/trident_assistant/utils/memo.rb', line 57 def decode json end |
#encode ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/trident_assistant/utils/memo.rb', line 37 def encode hash = { T: type, N: token_id && MixinBot::Utils::UUID.new(hex: token_id).packed, A: asset_id && MixinBot::Utils::UUID.new(hex: asset_id).packed, O: order_id && MixinBot::Utils::UUID.new(hex: order_id).packed, P: price && format("%.8f", price.to_f).gsub(/(0)+\z/, ""), R: reserve_price && format("%.8f", reserve_price.to_f).gsub(/(0)+\z/, ""), RC: receiver_id && MixinBot::Utils::UUID.new(hex: receiver_id).packed, S: start_at && Time.parse(start_at).to_i, E: expire_at && Time.parse(expire_at).to_i }.compact @encoded = Base64.urlsafe_encode64( MessagePack.pack(hash), padding: false ) end |
#json ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/trident_assistant/utils/memo.rb', line 23 def json { T: type, N: token_id, A: asset_id, O: order_id, P: price, R: reserve_price, RC: receiver_id, S: start_at, E: expire_at }.compact end |