Module: TridentAssistant::Utils
- Defined in:
- lib/trident_assistant/utils.rb,
lib/trident_assistant/utils/memo.rb,
lib/trident_assistant/utils/metadata.rb
Overview
Some useful methods
Defined Under Namespace
Constant Summary collapse
- MINT_ASSET_ID =
"c94ac88f-4671-3976-b60a-09064f1811e8"
- MINT_AMOUNT =
0.001
- NFO_MTG =
{ members: %w[ 047061e6-496d-4c35-b06b-b0424a8a400d 4b188942-9fb0-4b99-b4be-e741a06d1ebf 50115496-7247-4e2c-857b-ec8680756bee a51006d0-146b-4b32-a2ce-7defbf0d7735 acf65344-c778-41ee-bacb-eb546bacfb9f cf4abd9c-2cfa-4b5a-b1bd-e2b61a83fabd dd655520-c919-4349-822f-af92fabdbdf4 ].sort, threshold: 5 }.freeze
- TRIDENT_MTG =
{ members: %w[ 6f5a84ce-d663-451e-b413-2d0c84b7629d 99216bb5-9787-49b6-b251-537362ce23eb fcc1e3ec-97f1-41a7-89a3-20a0ec30a31f 1a361145-66a7-48cd-ab6c-db9a42da4074 9ba50819-159c-45e6-9bed-1eb2dded3360 ].sort, threshold: 3 }.freeze
Class Method Summary collapse
- .hash_from_url(url) ⇒ Object
- .mixin_bot_from_keystore(keystore) ⇒ Object
- .parse_json(input) ⇒ Object
- .parse_metadata(input) ⇒ Object
Class Method Details
.hash_from_url(url) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/trident_assistant/utils.rb', line 43 def hash_from_url(url) return if url.to_s.blank? content = begin URI.parse(url).open(&:read) rescue OpenURI::HTTPError "" end SHA3::Digest::SHA256.hexdigest content end |
.mixin_bot_from_keystore(keystore) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/trident_assistant/utils.rb', line 56 def mixin_bot_from_keystore(keystore) keystore = parse_json keystore if keystore.is_a?(String) keystore = keystore.with_indifferent_access MixinBot::API.new **keystore end |
.parse_json(input) ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/trident_assistant/utils.rb', line 81 def parse_json(input) input = if File.file? input File.read input else input end JSON.parse(input).with_indifferent_access end |
.parse_metadata(input) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/trident_assistant/utils.rb', line 63 def (input) = case input when String TridentAssistant::Utils.parse_json input when Hash input else {} end TridentAssistant::Utils::Metadata.new( creator: ["creator"], collection: ["collection"], token: ["token"], checksum: ["checksum"] ) end |