Module: MixinBot::API::LegacyCollectible
- Included in:
- MixinBot::API
- Defined in:
- lib/mixin_bot/api/legacy_collectible.rb
Constant Summary collapse
- NFT_ASSET_MIXIN_ID =
'1700941284a95f31b25ec8c546008f208f88eee4419ccdcdbe6e3195e60128ca'
- COLLECTABLE_REQUEST_ACTIONS =
%i[sign unlock].freeze
Instance Method Summary collapse
- #create_collectible_request(action, raw, access_token: nil) ⇒ Object
- #create_sign_collectible_request(raw, access_token: nil) ⇒ Object
- #create_unlock_collectible_request(raw, access_token: nil) ⇒ Object
- #legacy_collectible(id, access_token: nil) ⇒ Object
- #legacy_collectibles(**kwargs) ⇒ Object
- #legacy_collection(id, access_token: nil) ⇒ Object
- #sign_collectible_request(request_id, pin = nil) ⇒ Object
- #unlock_collectible_request(request_id, pin = nil) ⇒ Object
Instance Method Details
#create_collectible_request(action, raw, access_token: nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mixin_bot/api/legacy_collectible.rb', line 43 def create_collectible_request(action, raw, access_token: nil) raise ArgumentError, "request action is limited in #{COLLECTABLE_REQUEST_ACTIONS.join(', ')}" unless COLLECTABLE_REQUEST_ACTIONS.include? action.to_sym path = '/collectibles/requests' payload = { action:, raw: } client.post path, **payload, access_token: end |
#create_sign_collectible_request(raw, access_token: nil) ⇒ Object
54 55 56 |
# File 'lib/mixin_bot/api/legacy_collectible.rb', line 54 def create_sign_collectible_request(raw, access_token: nil) create_collectible_request 'sign', raw, access_token: end |
#create_unlock_collectible_request(raw, access_token: nil) ⇒ Object
58 59 60 |
# File 'lib/mixin_bot/api/legacy_collectible.rb', line 58 def create_unlock_collectible_request(raw, access_token: nil) create_collectible_request 'unlock', raw, access_token: end |
#legacy_collectible(id, access_token: nil) ⇒ Object
8 9 10 11 |
# File 'lib/mixin_bot/api/legacy_collectible.rb', line 8 def legacy_collectible(id, access_token: nil) path = "/collectibles/tokens/#{id}" client.get path, access_token: end |
#legacy_collectibles(**kwargs) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mixin_bot/api/legacy_collectible.rb', line 18 def legacy_collectibles(**kwargs) limit = kwargs[:limit] || 100 offset = kwargs[:offset] || '' state = kwargs[:state] || '' members = kwargs[:members] || [config.app_id] threshold = kwargs[:threshold] || members.length members = SHA3::Digest::SHA256.hexdigest(members&.sort&.join) access_token = kwargs[:access_token] path = '/collectibles/outputs' params = { limit:, offset:, state:, members:, threshold: } client.get path, **params, access_token: end |
#legacy_collection(id, access_token: nil) ⇒ Object
13 14 15 16 |
# File 'lib/mixin_bot/api/legacy_collectible.rb', line 13 def legacy_collection(id, access_token: nil) path = "/collectibles/collections/#{id}" client.get path, access_token: end |
#sign_collectible_request(request_id, pin = nil) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/mixin_bot/api/legacy_collectible.rb', line 62 def sign_collectible_request(request_id, pin = nil) pin ||= config.pin raise ArgumentError, 'pin is needed for sign collectible request' if pin.blank? path = format('/collectibles/requests/%<request_id>s/sign', request_id:) payload = if pin.length > 6 pin_base64 = encrypt_tip_pin(pin, 'TIP:COLLECTIBLE:REQUEST:SIGN:', request_id) { pin_base64: } else { pin: encrypt_pin(pin) } end client.post path, **payload end |
#unlock_collectible_request(request_id, pin = nil) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/mixin_bot/api/legacy_collectible.rb', line 81 def unlock_collectible_request(request_id, pin = nil) pin ||= config.pin raise ArgumentError, 'pin is needed for sign collectible request' if pin.blank? path = format('/collectibles/requests/%<request_id>s/unlock', request_id:) payload = if pin.length > 6 { pin_base64: encrypt_tip_pin(pin, 'TIP:COLLECTIBLE:REQUEST:UNLOCK:', request_id) } else { pin: encrypt_pin(pin) } end client.post path, **payload end |