trident_assistant 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/lib/trident_assistant/api/order.rb +94 -4
- data/lib/trident_assistant/cli/order.rb +27 -5
- 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 +2 -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: 5ca51a3b40da71d8ead06326ccd1377008aafe793e3881b9c4aaede46df73351
|
4
|
+
data.tar.gz: 9bf39cd480e433eab5443db26c57bec9e7c0445bb57aebdeddc2e2c439de03df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dd9e5df04ccfb3d41bc4c6b2ce1bc3a8b7f48453d692bff4cae9901e3da1c11fd6c2d2cfe9d5cb8dac8e4601b77bdcaea5a75c167b83622027558bd2a57bcb2
|
7
|
+
data.tar.gz: 3791ef7f7ec907f6b0f2a9ce807a1a157b92999291f60c99b24fc27f578af1c33751ac1d86a6c6c0143ddcc2b2cfb75300283cd832dc749e9eeb080af45a0890
|
data/.rubocop.yml
CHANGED
@@ -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]
|
@@ -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]
|
@@ -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"
|
@@ -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.3
|
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-04-
|
11
|
+
date: 2022-04-25 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
|
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
|