trident_assistant 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f164a9116aa89a445553f7af742157ac0da7670dc436c8235508ff5e4a8030be
4
- data.tar.gz: e0602539c1087780a03b543c90da70afbae5aced33373eb50339575a733f97e7
3
+ metadata.gz: f4acb50cc313a7bb9bde2830d586acd3264ad6342d19db8f33c3771c2bc50960
4
+ data.tar.gz: f1929e1fd73134237592eb08d8bc8297fb15ed5b44201deb411499880f4360d4
5
5
  SHA512:
6
- metadata.gz: 8c3292e2f06b569a50357d64e0d8811218cdb1911e0c2eb544560c25e64a698f02b758f59a149cad1c5b9d0705bc952b73aaff1c77360ef83379a9217a69f6f2
7
- data.tar.gz: ed3f043aa8ec27ee9931d41f2becaa031588d208c7a7b142c29db028380939d4a220319b5768a4cb2a912c0051bbae2c1e9ff4601d5f87cec1a4a1d5d1f25bcd
6
+ metadata.gz: 92abe8ed87e80f6a0b5733b31ebdc5393d615b3f8de846d5a68194c4e767faf9d516b57452d2733e3c068ba6b49e7e5513144a888a4bfa5ce2429f4780957636
7
+ data.tar.gz: f3a8d65af73524216b60970cf98add0c2035bb8fc9c9f2d10d12e16719c8623fb243a1486ffc5e4925d8bfec4c77f39d2186126e148a40fab0bdd7ae9a302892
@@ -7,10 +7,26 @@ module TridentAssistant
7
7
  EXCHANGE_ASSET_ID = "965e5c6e-434c-3fa9-b780-c50f43cd955c"
8
8
  MINIMUM_AMOUNT = 0.000_000_01
9
9
 
10
+ def collectibles(**kwargs)
11
+ client
12
+ .get(
13
+ "api/collectibles",
14
+ headers: {
15
+ Authorization: "Bearer #{mixin_bot.access_token("GET", "/me")}"
16
+ },
17
+ params: {
18
+ collection_id: kwargs[:collection_id],
19
+ type: kwargs[:type],
20
+ page: kwargs[:page],
21
+ query: kwargs[:query]
22
+ }
23
+ )
24
+ end
25
+
10
26
  def deposit(collection, token)
11
27
  token_id = MixinBot::Utils::Nfo.new(collection: collection, token: token).unique_token_id
12
28
  collectible = find_collectible(:unspent, token_id)
13
- raise "Unauthorized" if collectible.blank?
29
+ raise ForbiddenError, "Cannot find collectible" if collectible.blank?
14
30
 
15
31
  nfo = MixinBot::Utils::Nfo.new(extra: "deposit".unpack1("H*")).encode.hex
16
32
  _transfer_nft(
@@ -38,7 +54,7 @@ module TridentAssistant
38
54
  token_id = MixinBot::Utils::Nfo.new(collection: collection, token: token).unique_token_id
39
55
  collectible = find_collectible(:unspent, token_id)
40
56
  collectible ||= find_collectible(:signed, token_id)
41
- raise "Cannot find collectible in wallet" if collectible.blank?
57
+ raise ForbiddenError, "Cannot find collectible in wallet" if collectible.blank?
42
58
 
43
59
  memo =
44
60
  TridentAssistant::Utils::Memo.new(
@@ -60,7 +76,7 @@ module TridentAssistant
60
76
  token_id = MixinBot::Utils::Nfo.new(collection: collection, token: token).unique_token_id
61
77
  collectible = find_collectible(:unspent, token_id)
62
78
  collectible ||= find_collectible(:signed, token_id)
63
- raise "Cannot find collectible in wallet" if collectible.blank?
79
+ raise ForbiddenError, "Cannot find collectible in wallet" if collectible.blank?
64
80
 
65
81
  memo = "TRANSFER"
66
82
  nfo = MixinBot::Utils::Nfo.new(extra: memo.unpack1("H*")).encode.hex
@@ -6,18 +6,18 @@ module TridentAssistant
6
6
  module Collection
7
7
  def collection(id)
8
8
  client.get(
9
- "api/collections/#{id}",
10
- headers: {
11
- Authorization: "Bearer #{mixin_bot.access_token("GET", "/me")}"
12
- }
9
+ "api/collections/#{id}"
13
10
  )
14
11
  end
15
12
 
16
- def collections
13
+ def collections(**kwargs)
17
14
  client.get(
18
15
  "api/collections",
19
16
  headers: {
20
17
  Authorization: "Bearer #{mixin_bot.access_token("GET", "/me")}"
18
+ },
19
+ params: {
20
+ page: kwargs[:page]
21
21
  }
22
22
  )
23
23
  end
@@ -52,7 +52,8 @@ module TridentAssistant
52
52
  json: {
53
53
  description: kwargs[:description],
54
54
  external_url: kwargs[:external_url],
55
- icon_base64: kwargs[:icon_base64]
55
+ icon_base64: kwargs[:icon_base64],
56
+ icon_url: kwargs[:icon_url]
56
57
  }.compact
57
58
  )
58
59
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TridentAssistant
4
+ class API
5
+ # api for supported assets
6
+ module MixinAsset
7
+ def assets
8
+ client.get "api/assets"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -146,8 +146,8 @@ module TridentAssistant
146
146
 
147
147
  def cancel_order(order_id)
148
148
  info = order order_id
149
- raise "Order maker: #{info["maker"]["id"]}" if info.dig("maker", "id") != mixin_bot.client_id
150
- raise "Order state: #{info["state"]}" if info["state"] != "open"
149
+ raise ForbiddenError, "Order maker: #{info["maker"]["id"]}" if info.dig("maker", "id") != mixin_bot.client_id
150
+ raise ForbiddenError, "Order state: #{info["state"]}" if info["state"] != "open"
151
151
 
152
152
  memo = TridentAssistant::Utils::Memo.new(type: "C", order_id: order_id, token_id: info["token_id"])
153
153
 
@@ -4,11 +4,16 @@ require_relative "./client"
4
4
  require_relative "./api/collection"
5
5
  require_relative "./api/collectible"
6
6
  require_relative "./api/metadata"
7
+ require_relative "./api/mixin_asset"
7
8
  require_relative "./api/order"
8
9
 
9
10
  module TridentAssistant
10
11
  # APIs of Trident server
11
12
  class API
13
+ class UnauthorizedError < TridentAssistant::Error; end
14
+ class ArgumentError < TridentAssistant::Error; end
15
+ class ForbiddenError < TridentAssistant::Error; end
16
+
12
17
  attr_reader :mixin_bot, :client, :keystore
13
18
 
14
19
  def initialize(**args)
@@ -22,6 +27,7 @@ module TridentAssistant
22
27
  include TridentAssistant::API::Collectible
23
28
  include TridentAssistant::API::Collection
24
29
  include TridentAssistant::API::Metadata
30
+ include TridentAssistant::API::MixinAsset
25
31
  include TridentAssistant::API::Order
26
32
  end
27
33
  end
@@ -66,8 +66,8 @@ module TridentAssistant
66
66
  api.upload_metadata metadata: metadata.json, metahash: metadata.metahash
67
67
  data["_mint"] ||= {}
68
68
  data["_mint"]["metahash"] = metadata.metahash
69
+ log UI.fmt("{{v}} metadata uploaded: #{options[:endpoint]}/api/collectibles/#{metadata.metahash}")
69
70
  end
70
- log UI.fmt("{{v}} metadata uploaded: #{options[:endpoint]}/api/collectibles/#{metadata.metahash}")
71
71
 
72
72
  token_id = MixinBot::Utils::Nfo.new(collection: metadata.collection[:id],
73
73
  token: metadata.token[:id]).unique_token_id
@@ -45,7 +45,7 @@ module TridentAssistant
45
45
  parse_response(response) do |parse_as, result|
46
46
  case parse_as
47
47
  when :json
48
- break result if result["message"].blank?
48
+ break result if result.is_a?(Array) || (result.is_a?(Hash) && result["message"].blank?)
49
49
 
50
50
  raise result["message"]
51
51
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TridentAssistant
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trident_assistant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - an-lee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-03 00:00:00.000000000 Z
11
+ date: 2022-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixin_bot
@@ -47,6 +47,7 @@ files:
47
47
  - lib/trident_assistant/api/collectible.rb
48
48
  - lib/trident_assistant/api/collection.rb
49
49
  - lib/trident_assistant/api/metadata.rb
50
+ - lib/trident_assistant/api/mixin_asset.rb
50
51
  - lib/trident_assistant/api/order.rb
51
52
  - lib/trident_assistant/cli.rb
52
53
  - lib/trident_assistant/cli/base.rb