trident_assistant 0.1.2 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/lib/trident_assistant/api/collectible.rb +55 -24
- data/lib/trident_assistant/api/collection.rb +7 -6
- data/lib/trident_assistant/api/mixin_asset.rb +12 -0
- data/lib/trident_assistant/api/order.rb +96 -6
- data/lib/trident_assistant/api.rb +6 -0
- data/lib/trident_assistant/cli/collectible.rb +13 -2
- data/lib/trident_assistant/cli/nfo.rb +32 -26
- data/lib/trident_assistant/cli/order.rb +27 -5
- data/lib/trident_assistant/client.rb +1 -1
- data/lib/trident_assistant/utils/memo.rb +1 -1
- data/lib/trident_assistant/utils.rb +8 -0
- data/lib/trident_assistant/version.rb +1 -1
- metadata +3 -3
- data/Gemfile.lock +0 -106
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4acb50cc313a7bb9bde2830d586acd3264ad6342d19db8f33c3771c2bc50960
|
4
|
+
data.tar.gz: f1929e1fd73134237592eb08d8bc8297fb15ed5b44201deb411499880f4360d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92abe8ed87e80f6a0b5733b31ebdc5393d615b3f8de846d5a68194c4e767faf9d516b57452d2733e3c068ba6b49e7e5513144a888a4bfa5ce2429f4780957636
|
7
|
+
data.tar.gz: f3a8d65af73524216b60970cf98add0c2035bb8fc9c9f2d10d12e16719c8623fb243a1486ffc5e4925d8bfec4c77f39d2186126e148a40fab0bdd7ae9a302892
|
data/.rubocop.yml
CHANGED
@@ -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
|
-
collectible =
|
13
|
-
raise "
|
28
|
+
collectible = find_collectible(:unspent, token_id)
|
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(
|
@@ -36,9 +52,9 @@ module TridentAssistant
|
|
36
52
|
|
37
53
|
def airdrop(collection, token, **kwargs)
|
38
54
|
token_id = MixinBot::Utils::Nfo.new(collection: collection, token: token).unique_token_id
|
39
|
-
collectible =
|
40
|
-
collectible ||=
|
41
|
-
raise "Cannot find collectible in wallet" if collectible.blank?
|
55
|
+
collectible = find_collectible(:unspent, token_id)
|
56
|
+
collectible ||= find_collectible(:signed, token_id)
|
57
|
+
raise ForbiddenError, "Cannot find collectible in wallet" if collectible.blank?
|
42
58
|
|
43
59
|
memo =
|
44
60
|
TridentAssistant::Utils::Memo.new(
|
@@ -58,9 +74,9 @@ module TridentAssistant
|
|
58
74
|
|
59
75
|
def transfer(collection, token, recipient, **_kwargs)
|
60
76
|
token_id = MixinBot::Utils::Nfo.new(collection: collection, token: token).unique_token_id
|
61
|
-
collectible =
|
62
|
-
collectible ||=
|
63
|
-
raise "Cannot find collectible in wallet" if collectible.blank?
|
77
|
+
collectible = find_collectible(:unspent, token_id)
|
78
|
+
collectible ||= find_collectible(:signed, token_id)
|
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
|
@@ -75,23 +91,38 @@ module TridentAssistant
|
|
75
91
|
|
76
92
|
private
|
77
93
|
|
94
|
+
def find_collectible(state, token_id)
|
95
|
+
limit = 500
|
96
|
+
offset = ""
|
97
|
+
|
98
|
+
loop do
|
99
|
+
r = mixin_bot.collectibles(state: state, limit: limit, offset: offset)["data"]
|
100
|
+
puts "offset: #{offset}, loaded #{r.size} collectibles"
|
101
|
+
collectible = r.find(&->(c) { c["token_id"] == token_id })
|
102
|
+
break collectible if collectible.present?
|
103
|
+
|
104
|
+
break if r.size < 500
|
105
|
+
|
106
|
+
offset = r.last["updated_at"]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
78
110
|
def _transfer_nft(collectible, nfo, **kwargs)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
mixin_bot.send_raw_transaction sign["raw_transaction"]
|
111
|
+
if collectible["state"] == "signed"
|
112
|
+
mixin_bot.send_raw_transaction collectible["signed_tx"]
|
113
|
+
else
|
114
|
+
raw = mixin_bot.build_collectible_transaction(
|
115
|
+
collectible: collectible,
|
116
|
+
receivers: kwargs[:receivers],
|
117
|
+
receivers_threshold: kwargs[:threshold],
|
118
|
+
nfo: nfo
|
119
|
+
)
|
120
|
+
tx = mixin_bot.sign_raw_transaction raw
|
121
|
+
|
122
|
+
request = mixin_bot.create_sign_collectible_request tx
|
123
|
+
sign = mixin_bot.sign_collectible_request request["request_id"], keystore[:pin]
|
124
|
+
mixin_bot.send_raw_transaction sign["raw_transaction"]
|
125
|
+
end
|
95
126
|
end
|
96
127
|
end
|
97
128
|
end
|
@@ -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
|
@@ -34,6 +34,96 @@ module TridentAssistant
|
|
34
34
|
)
|
35
35
|
end
|
36
36
|
|
37
|
+
def ask_order(collection, token, **kwargs)
|
38
|
+
raise ArgumentError, "price cannot be blank" if kwargs[:price].blank?
|
39
|
+
raise ArgumentError, "asset_id cannot be blank" if kwargs[:asset_id].blank?
|
40
|
+
|
41
|
+
trace_id = SecureRandom.uuid
|
42
|
+
token_id = MixinBot::Utils::Nfo.new(collection: collection, token: token).unique_token_id
|
43
|
+
memo =
|
44
|
+
TridentAssistant::Utils::Memo
|
45
|
+
.new(
|
46
|
+
type: "A",
|
47
|
+
order_id: trace_id,
|
48
|
+
token_id: token_id,
|
49
|
+
price: kwargs[:price],
|
50
|
+
asset_id: kwargs[:asset_id],
|
51
|
+
expire_at: kwargs[:expire_at]
|
52
|
+
)
|
53
|
+
|
54
|
+
mixin_bot.create_multisig_transaction(
|
55
|
+
keystore[:pin],
|
56
|
+
{
|
57
|
+
asset_id: EXCHANGE_ASSET_ID,
|
58
|
+
trace_id: trace_id,
|
59
|
+
amount: MINIMUM_AMOUNT,
|
60
|
+
memo: memo.encode,
|
61
|
+
receivers: TridentAssistant::Utils::TRIDENT_MTG[:members],
|
62
|
+
threshold: TridentAssistant::Utils::TRIDENT_MTG[:threshold]
|
63
|
+
}
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
def auction_order(collection, token, **kwargs)
|
68
|
+
raise ArgumentError, "price cannot be blank" if kwargs[:price].blank?
|
69
|
+
raise ArgumentError, "asset_id cannot be blank" if kwargs[:asset_id].blank?
|
70
|
+
|
71
|
+
trace_id = SecureRandom.uuid
|
72
|
+
token_id = MixinBot::Utils::Nfo.new(collection: collection, token: token).unique_token_id
|
73
|
+
memo =
|
74
|
+
TridentAssistant::Utils::Memo
|
75
|
+
.new(
|
76
|
+
type: "AU",
|
77
|
+
order_id: trace_id,
|
78
|
+
token_id: token_id,
|
79
|
+
price: kwargs[:price],
|
80
|
+
reserve_price: kwargs[:reserve_price],
|
81
|
+
asset_id: kwargs[:asset_id],
|
82
|
+
expire_at: kwargs[:expire_at]
|
83
|
+
)
|
84
|
+
|
85
|
+
mixin_bot.create_multisig_transaction(
|
86
|
+
keystore[:pin],
|
87
|
+
{
|
88
|
+
asset_id: EXCHANGE_ASSET_ID,
|
89
|
+
trace_id: trace_id,
|
90
|
+
amount: MINIMUM_AMOUNT,
|
91
|
+
memo: memo.encode,
|
92
|
+
receivers: TridentAssistant::Utils::TRIDENT_MTG[:members],
|
93
|
+
threshold: TridentAssistant::Utils::TRIDENT_MTG[:threshold]
|
94
|
+
}
|
95
|
+
)
|
96
|
+
end
|
97
|
+
|
98
|
+
def bid_order(collection, token, **kwargs)
|
99
|
+
raise ArgumentError, "price cannot be blank" if kwargs[:price].blank?
|
100
|
+
raise ArgumentError, "asset_id cannot be blank" if kwargs[:asset_id].blank?
|
101
|
+
|
102
|
+
trace_id = SecureRandom.uuid
|
103
|
+
token_id = MixinBot::Utils::Nfo.new(collection: collection, token: token).unique_token_id
|
104
|
+
memo =
|
105
|
+
TridentAssistant::Utils::Memo
|
106
|
+
.new(
|
107
|
+
type: "B",
|
108
|
+
order_id: trace_id,
|
109
|
+
token_id: token_id,
|
110
|
+
asset_id: kwargs[:asset_id],
|
111
|
+
expire_at: kwargs[:expire_at]
|
112
|
+
)
|
113
|
+
|
114
|
+
mixin_bot.create_multisig_transaction(
|
115
|
+
keystore[:pin],
|
116
|
+
{
|
117
|
+
asset_id: kwargs[:asset_id],
|
118
|
+
trace_id: trace_id,
|
119
|
+
amount: kwargs[:price],
|
120
|
+
memo: memo.encode,
|
121
|
+
receivers: TridentAssistant::Utils::TRIDENT_MTG[:members],
|
122
|
+
threshold: TridentAssistant::Utils::TRIDENT_MTG[:threshold]
|
123
|
+
}
|
124
|
+
)
|
125
|
+
end
|
126
|
+
|
37
127
|
def fill_order(order_id)
|
38
128
|
info = order order_id
|
39
129
|
raise "Order state: #{info["state"]}" if info["state"] != "open"
|
@@ -44,9 +134,9 @@ module TridentAssistant
|
|
44
134
|
mixin_bot.create_multisig_transaction(
|
45
135
|
keystore[:pin],
|
46
136
|
{
|
47
|
-
asset_id: info["asset_id"],
|
137
|
+
asset_id: info["type"] == "BidOrder" ? EXCHANGE_ASSET_ID : info["asset_id"],
|
48
138
|
trace_id: trace_id,
|
49
|
-
amount: info["price"],
|
139
|
+
amount: info["type"] == "BidOrder" ? MINIMUM_AMOUNT : info["price"],
|
50
140
|
memo: memo.encode,
|
51
141
|
receivers: TridentAssistant::Utils::TRIDENT_MTG[:members],
|
52
142
|
threshold: TridentAssistant::Utils::TRIDENT_MTG[:threshold]
|
@@ -56,8 +146,8 @@ module TridentAssistant
|
|
56
146
|
|
57
147
|
def cancel_order(order_id)
|
58
148
|
info = order order_id
|
59
|
-
raise "Order maker: #{info["maker"]["id"]}" if info.dig("maker", "id") != mixin_bot.client_id
|
60
|
-
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"
|
61
151
|
|
62
152
|
memo = TridentAssistant::Utils::Memo.new(type: "C", order_id: order_id, token_id: info["token_id"])
|
63
153
|
|
@@ -65,9 +155,9 @@ module TridentAssistant
|
|
65
155
|
mixin_bot.create_multisig_transaction(
|
66
156
|
keystore[:pin],
|
67
157
|
{
|
68
|
-
asset_id:
|
158
|
+
asset_id: EXCHANGE_ASSET_ID,
|
69
159
|
trace_id: trace_id,
|
70
|
-
amount:
|
160
|
+
amount: MINIMUM_AMOUNT,
|
71
161
|
memo: memo.encode,
|
72
162
|
receivers: TridentAssistant::Utils::TRIDENT_MTG[:members],
|
73
163
|
threshold: TridentAssistant::Utils::TRIDENT_MTG[:threshold]
|
@@ -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
|
@@ -11,7 +11,7 @@ module TridentAssistant
|
|
11
11
|
desc: "keystore or keystore.json file of Mixin bot"
|
12
12
|
option :keystore, type: :string, aliases: "k", required: true, desc: "keystore or keystore.json file of Mixin bot"
|
13
13
|
def index
|
14
|
-
r = api.mixin_bot.collectibles state: options[:state]
|
14
|
+
r = api.mixin_bot.collectibles state: options[:state], limit: 500
|
15
15
|
|
16
16
|
log r["data"]
|
17
17
|
end
|
@@ -87,7 +87,18 @@ module TridentAssistant
|
|
87
87
|
log UI.fmt("{{v}} airdrop receiver_id: #{receiver_id}")
|
88
88
|
log UI.fmt("{{v}} airdrop start_at: #{start_at}")
|
89
89
|
|
90
|
-
|
90
|
+
attempt = 0
|
91
|
+
r =
|
92
|
+
begin
|
93
|
+
attempt += 1
|
94
|
+
api.airdrop metadata.collection["id"], metadata.token["id"], receiver_id: receiver_id, start_at: start_at
|
95
|
+
rescue Errno::ECONNRESET, OpenSSL::SSL::SSLError, MixinBot::HttpError => e
|
96
|
+
log UI.fmt("{{x}} #{e.inspect}")
|
97
|
+
log UI.fmt("Retrying #{attempt} times...")
|
98
|
+
sleep 0.5
|
99
|
+
retry
|
100
|
+
end
|
101
|
+
|
91
102
|
log r["data"]
|
92
103
|
data["_airdrop"] ||= {}
|
93
104
|
data["_airdrop"]["hash"] = r["data"]["hash"]
|
@@ -26,9 +26,20 @@ module TridentAssistant
|
|
26
26
|
files.each do |file|
|
27
27
|
log "-" * 80
|
28
28
|
log UI.fmt("{{v}} found #{file}")
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
attempt = 0
|
30
|
+
success =
|
31
|
+
begin
|
32
|
+
attempt += 1
|
33
|
+
_mint file
|
34
|
+
rescue Errno::ECONNRESET, OpenSSL::SSL::SSLError, MixinBot::HttpError, TridentAssistant::Client::HttpError,
|
35
|
+
TridentAssistant::Client::RequestError, MixinBot::RequestError => e
|
36
|
+
log UI.fmt("{{x}} #{e.inspect}")
|
37
|
+
log UI.fmt("Retrying #{attempt} times...")
|
38
|
+
sleep 0.5
|
39
|
+
retry
|
40
|
+
end
|
41
|
+
minted.push(file) if success
|
42
|
+
rescue TridentAssistant::Utils::Metadata::InvalidFormatError, JSON::ParserError, RuntimeError => e
|
32
43
|
log UI.fmt("{{x}} #{file} failed: #{e.inspect}")
|
33
44
|
next
|
34
45
|
end
|
@@ -55,8 +66,8 @@ module TridentAssistant
|
|
55
66
|
api.upload_metadata metadata: metadata.json, metahash: metadata.metahash
|
56
67
|
data["_mint"] ||= {}
|
57
68
|
data["_mint"]["metahash"] = metadata.metahash
|
69
|
+
log UI.fmt("{{v}} metadata uploaded: #{options[:endpoint]}/api/collectibles/#{metadata.metahash}")
|
58
70
|
end
|
59
|
-
log UI.fmt("{{v}} metadata uploaded: #{options[:endpoint]}/api/collectibles/#{metadata.metahash}")
|
60
71
|
|
61
72
|
token_id = MixinBot::Utils::Nfo.new(collection: metadata.collection[:id],
|
62
73
|
token: metadata.token[:id]).unique_token_id
|
@@ -76,33 +87,28 @@ module TridentAssistant
|
|
76
87
|
memo = api.mixin_bot.nft_memo metadata.collection[:id], metadata.token[:id].to_i, metadata.metahash
|
77
88
|
|
78
89
|
data["_mint"]["trace_id"] = trace_id
|
79
|
-
|
90
|
+
begin
|
80
91
|
payment =
|
81
|
-
|
82
|
-
api.
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
)
|
93
|
-
rescue MixinBot::InsufficientPoolError, MixinBot::HttpError => e
|
94
|
-
log UI.fmt("{{x}} #{e.inspect}")
|
95
|
-
log "Retrying to pay..."
|
96
|
-
sleep 1
|
97
|
-
nil
|
98
|
-
end
|
99
|
-
|
100
|
-
next if payment.blank? || payment["errors"].present?
|
92
|
+
api.mixin_bot.create_multisig_transaction(
|
93
|
+
api.keystore[:pin],
|
94
|
+
{
|
95
|
+
asset_id: TridentAssistant::Utils::MINT_ASSET_ID,
|
96
|
+
trace_id: trace_id,
|
97
|
+
amount: TridentAssistant::Utils::MINT_AMOUNT,
|
98
|
+
memo: memo,
|
99
|
+
receivers: TridentAssistant::Utils::NFO_MTG[:members],
|
100
|
+
threshold: TridentAssistant::Utils::NFO_MTG[:threshold]
|
101
|
+
}
|
102
|
+
)
|
101
103
|
|
102
104
|
log UI.fmt("{{v}} NFT mint payment paid: #{payment["data"]}")
|
103
105
|
data["_mint"]["token_id"] = token_id
|
104
106
|
log UI.fmt("{{v}} NFT successfully minted")
|
105
|
-
|
107
|
+
rescue MixinBot::InsufficientPoolError, MixinBot::HttpError => e
|
108
|
+
log UI.fmt("{{x}} #{e.inspect}")
|
109
|
+
log "Retrying to pay..."
|
110
|
+
sleep 1
|
111
|
+
retry
|
106
112
|
end
|
107
113
|
|
108
114
|
data.dig("_mint", "token_id").present?
|
@@ -33,14 +33,36 @@ module TridentAssistant
|
|
33
33
|
log api.order id
|
34
34
|
end
|
35
35
|
|
36
|
-
desc "
|
37
|
-
|
36
|
+
desc "ask COLECTION TOKEN", "sell NFT at fixed price"
|
37
|
+
option :asset, type: :string, aliases: "a", required: true, desc: "Order asset ID"
|
38
|
+
option :price, type: :numeric, aliases: "p", required: true, desc: "Order price"
|
39
|
+
option :expiration, type: :string, aliases: "e", required: false, desc: "Order expiration"
|
40
|
+
option :keystore, type: :string, aliases: "k", required: true, desc: "keystore or keystore.json file of Mixin bot"
|
41
|
+
def ask(collection, token)
|
42
|
+
log api.ask_order collection, token, asset_id: options[:asset], price: options[:price],
|
43
|
+
expire_at: options[:expiration]
|
44
|
+
end
|
38
45
|
|
39
46
|
desc "auction", "auction NFT"
|
40
|
-
|
47
|
+
option :asset, type: :string, aliases: "a", required: true, desc: "Order asset ID"
|
48
|
+
option :price, type: :numeric, aliases: "p", required: true, desc: "Order price"
|
49
|
+
option :reserve_price, type: :numeric, aliases: "r", required: true, desc: "Order reserve price"
|
50
|
+
option :expiration, type: :string, aliases: "e", required: false, desc: "Order expiration"
|
51
|
+
option :keystore, type: :string, aliases: "k", required: true, desc: "keystore or keystore.json file of Mixin bot"
|
52
|
+
def auction(collection, token)
|
53
|
+
log api.auction_order collection, token, asset_id: options[:asset], price: options[:price],
|
54
|
+
reserve_price: options[:reserve_price], expire_at: options[:expiration]
|
55
|
+
end
|
41
56
|
|
42
|
-
desc "bid", "bid NFT"
|
43
|
-
|
57
|
+
desc "bid COLECTION TOKEN", "bid NFT"
|
58
|
+
option :asset, type: :string, aliases: "a", required: true, desc: "Order asset ID"
|
59
|
+
option :price, type: :numeric, aliases: "p", required: true, desc: "Order price"
|
60
|
+
option :expiration, type: :string, aliases: "e", required: false, desc: "Order expiration"
|
61
|
+
option :keystore, type: :string, aliases: "k", required: true, desc: "keystore or keystore.json file of Mixin bot"
|
62
|
+
def bid(collection, token)
|
63
|
+
log api.bid_order collection, token, asset_id: options[:asset], price: options[:price],
|
64
|
+
expire_at: options[:expiration]
|
65
|
+
end
|
44
66
|
|
45
67
|
desc "fill ID", "fill order"
|
46
68
|
option :keystore, type: :string, aliases: "k", required: true, desc: "keystore or keystore.json file of Mixin bot"
|
@@ -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
|
@@ -44,7 +44,7 @@ module TridentAssistant
|
|
44
44
|
R: reserve_price && format("%.8f", reserve_price.to_f).gsub(/(0)+\z/, ""),
|
45
45
|
RC: receiver_id && MixinBot::Utils::UUID.new(hex: receiver_id).packed,
|
46
46
|
S: start_at && Time.parse(start_at).to_i,
|
47
|
-
E: expire_at && Time.parse(
|
47
|
+
E: expire_at && Time.parse(expire_at).to_i
|
48
48
|
}.compact
|
49
49
|
|
50
50
|
@encoded =
|
@@ -30,6 +30,14 @@ module TridentAssistant
|
|
30
30
|
].sort,
|
31
31
|
threshold: 3
|
32
32
|
}.freeze
|
33
|
+
# TRIDENT_MTG = {
|
34
|
+
# members: %w[
|
35
|
+
# 28d390c7-a31b-4c46-bec2-871c86aaec53
|
36
|
+
# 0508a116-1239-4e28-b150-85a8e3e6b400
|
37
|
+
# 7ed9292d-7c95-4333-aa48-a8c640064186
|
38
|
+
# ].sort,
|
39
|
+
# threshold: 2
|
40
|
+
# }.freeze
|
33
41
|
|
34
42
|
class << self
|
35
43
|
def hash_from_url(url)
|
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
|
+
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-
|
11
|
+
date: 2022-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixin_bot
|
@@ -36,7 +36,6 @@ files:
|
|
36
36
|
- CHANGELOG.md
|
37
37
|
- CODE_OF_CONDUCT.md
|
38
38
|
- Gemfile
|
39
|
-
- Gemfile.lock
|
40
39
|
- LICENSE.txt
|
41
40
|
- README.md
|
42
41
|
- Rakefile
|
@@ -48,6 +47,7 @@ files:
|
|
48
47
|
- lib/trident_assistant/api/collectible.rb
|
49
48
|
- lib/trident_assistant/api/collection.rb
|
50
49
|
- lib/trident_assistant/api/metadata.rb
|
50
|
+
- lib/trident_assistant/api/mixin_asset.rb
|
51
51
|
- lib/trident_assistant/api/order.rb
|
52
52
|
- lib/trident_assistant/cli.rb
|
53
53
|
- lib/trident_assistant/cli/base.rb
|
data/Gemfile.lock
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
trident_assistant (0.1.0)
|
5
|
-
mixin_bot (~> 0.8)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activesupport (7.0.2.3)
|
11
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (>= 1.6, < 2)
|
13
|
-
minitest (>= 5.1)
|
14
|
-
tzinfo (~> 2.0)
|
15
|
-
addressable (2.8.0)
|
16
|
-
public_suffix (>= 2.0.2, < 5.0)
|
17
|
-
ast (2.4.2)
|
18
|
-
awesome_print (1.9.2)
|
19
|
-
bcrypt (3.1.17)
|
20
|
-
cli-ui (1.5.1)
|
21
|
-
concurrent-ruby (1.1.10)
|
22
|
-
domain_name (0.5.20190701)
|
23
|
-
unf (>= 0.0.5, < 1.0.0)
|
24
|
-
eventmachine (1.2.7)
|
25
|
-
faye-websocket (0.11.1)
|
26
|
-
eventmachine (>= 0.12.0)
|
27
|
-
websocket-driver (>= 0.5.1)
|
28
|
-
ffi (1.15.5)
|
29
|
-
ffi-compiler (1.0.1)
|
30
|
-
ffi (>= 1.0.0)
|
31
|
-
rake
|
32
|
-
hamster (3.0.0)
|
33
|
-
concurrent-ruby (~> 1.0)
|
34
|
-
http (4.4.1)
|
35
|
-
addressable (~> 2.3)
|
36
|
-
http-cookie (~> 1.0)
|
37
|
-
http-form_data (~> 2.2)
|
38
|
-
http-parser (~> 1.2.0)
|
39
|
-
http-cookie (1.0.4)
|
40
|
-
domain_name (~> 0.5)
|
41
|
-
http-form_data (2.3.0)
|
42
|
-
http-parser (1.2.3)
|
43
|
-
ffi-compiler (>= 1.0, < 2.0)
|
44
|
-
i18n (1.10.0)
|
45
|
-
concurrent-ruby (~> 1.0)
|
46
|
-
jose (1.1.3)
|
47
|
-
hamster
|
48
|
-
minitest (5.15.0)
|
49
|
-
mixin_bot (0.8.4)
|
50
|
-
activesupport (>= 5)
|
51
|
-
awesome_print (~> 1.8)
|
52
|
-
bcrypt (~> 3.1)
|
53
|
-
cli-ui (~> 1.3)
|
54
|
-
faye-websocket (>= 0.11)
|
55
|
-
http (~> 4.1)
|
56
|
-
jose (~> 1.1)
|
57
|
-
msgpack (~> 1.3)
|
58
|
-
rbnacl (~> 7.1)
|
59
|
-
sha3 (~> 1.0)
|
60
|
-
thor (~> 1.0)
|
61
|
-
msgpack (1.5.1)
|
62
|
-
parallel (1.22.1)
|
63
|
-
parser (3.1.1.0)
|
64
|
-
ast (~> 2.4.1)
|
65
|
-
public_suffix (4.0.6)
|
66
|
-
rainbow (3.1.1)
|
67
|
-
rake (13.0.6)
|
68
|
-
rbnacl (7.1.1)
|
69
|
-
ffi
|
70
|
-
regexp_parser (2.2.1)
|
71
|
-
rexml (3.2.5)
|
72
|
-
rubocop (1.26.1)
|
73
|
-
parallel (~> 1.10)
|
74
|
-
parser (>= 3.1.0.0)
|
75
|
-
rainbow (>= 2.2.2, < 4.0)
|
76
|
-
regexp_parser (>= 1.8, < 3.0)
|
77
|
-
rexml
|
78
|
-
rubocop-ast (>= 1.16.0, < 2.0)
|
79
|
-
ruby-progressbar (~> 1.7)
|
80
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
81
|
-
rubocop-ast (1.16.0)
|
82
|
-
parser (>= 3.1.1.0)
|
83
|
-
ruby-progressbar (1.11.0)
|
84
|
-
sha3 (1.0.4)
|
85
|
-
thor (1.2.1)
|
86
|
-
tzinfo (2.0.4)
|
87
|
-
concurrent-ruby (~> 1.0)
|
88
|
-
unf (0.1.4)
|
89
|
-
unf_ext
|
90
|
-
unf_ext (0.0.8.1)
|
91
|
-
unicode-display_width (2.1.0)
|
92
|
-
websocket-driver (0.7.5)
|
93
|
-
websocket-extensions (>= 0.1.0)
|
94
|
-
websocket-extensions (0.1.5)
|
95
|
-
|
96
|
-
PLATFORMS
|
97
|
-
x86_64-linux
|
98
|
-
|
99
|
-
DEPENDENCIES
|
100
|
-
minitest (~> 5.0)
|
101
|
-
rake (~> 13.0)
|
102
|
-
rubocop (~> 1.21)
|
103
|
-
trident_assistant!
|
104
|
-
|
105
|
-
BUNDLED WITH
|
106
|
-
2.2.30
|