trident_assistant 0.1.0 → 0.1.1

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: 8dc10e88acd41b1155e43177a48f310d7c7e56ea7a316cf79f24a039c73eb1fa
4
- data.tar.gz: 2a2764a29a51a7b4f0806fa54c1eb00430133b235b322ae528a199110bbcf274
3
+ metadata.gz: 83a47a5a2a8383565a259f1fb9017d257f0eb2c4d52c2dfb80e7d46fab64ed70
4
+ data.tar.gz: 631300add4c04e26e00c235e8c9157c7d95334cb264432caac0c3edcf05873b0
5
5
  SHA512:
6
- metadata.gz: 78e76d0f250fc3447e546d3886e1bc7d5643d49f06cbd375de5d02fd39df718a10c4e1261923322bfe502778ead6f194e2cf392670228b073c45bc834a26827f
7
- data.tar.gz: 72677e15222934ad2eaae5c96bf56d2d0c413a25e67bb34ba7f9d82db72b9640e6f102552683c80654ae33100a6e93698e1e48cbfa4c46979fd1f064973f4016
6
+ metadata.gz: a082212e1eecb460dad1baa94f7fe48c7795f6e9631b8cefae1b8053970f2afc09b2386ad607e3cf1d7991641e1360534a5c7274820e9538f9d43dc143adc17a
7
+ data.tar.gz: b87d7fa6949c0532a74cf9a0ecdcd4eb492eeae15fffe466e1c0acf00c48aff776c65bdbf0b405cb4681a7ec8adbf44ed6df726ae7f597fda588d25e09118be1
data/README.md CHANGED
@@ -21,11 +21,76 @@ Commands:
21
21
  ta version # Display TridentAssistant version
22
22
 
23
23
  Options:
24
- -p, [--pretty], [--no-pretty] # Print output in pretty
25
- # Default: true
26
- -e, [--environment=ENVIRONMENT] # prod | test | dev
27
- # Default: prod
28
- -E, [--endpoint=ENDPOINT] # Specify an endpoint
24
+ -E, [--endpoint=ENDPOINT] # Specify an endpoint
25
+ -P, [--pretty], [--no-pretty] # Print output in pretty
26
+ # Default: true
27
+ ```
28
+
29
+ ### Collectible
30
+
31
+ $ ta collectible
32
+
33
+ ```
34
+ Commands:
35
+ ta collectible airdrop COLLECTION, TOKEN k, --keystore=KEYSTORE # airdrop NFT
36
+ ta collectible bulkairdrop DIR k, --keystore=KEYSTORE # Airdrop NFT in bulk
37
+ ta collectible deposit COLLECTION TOKEN k, --keystore=KEYSTORE # deposit NFT
38
+ ta collectible help [COMMAND] # Describe subcommands or one specific subcommand
39
+ ta collectible index k, --keystore=KEYSTORE # query collectibles in wallet
40
+ ta collectible show COLLECTION TOKEN k, --keystore=KEYSTORE # query collectible
41
+ ta collectible withdraw COLLECTION TOKEN k, --keystore=KEYSTORE # withdraw NFT
42
+ ```
43
+
44
+ ### collection
45
+
46
+ $ ta collection
47
+
48
+ ```
49
+ Commands:
50
+ ta collection create k, --keystore=KEYSTORE # create a new collection
51
+ ta collection help [COMMAND] # Describe subcommands or one specific subcommand
52
+ ta collection index k, --keystore=KEYSTORE # query all collections
53
+ ta collection show ID k, --keystore=KEYSTORE # query a collection
54
+ ta collection update ID k, --keystore=KEYSTORE # update collection
55
+ ```
56
+
57
+ ### metadata
58
+
59
+ $ ta metadata
60
+
61
+ ```
62
+ Commands:
63
+ ta metadata help [COMMAND] # Describe subcommands or one specific subcommand
64
+ ta metadata new k, --keystore=KEYSTORE # generate a new metadata
65
+ ta metadata show METAHASH k, --keystore=KEYSTORE # query metadata via metahash
66
+ ta metadata upload k, --keystore=KEYSTORE m, --metadata=METADATA # upload metadata to Trident
67
+ ```
68
+
69
+ ### nfo
70
+
71
+ $ ta nfo
72
+
73
+ ```
74
+ Commands:
75
+ ta nfo bulkmint DIR k, --keystore=KEYSTORE # Mint NFT in bulk
76
+ ta nfo help [COMMAND] # Describe subcommands or one specific subcommand
77
+ ta nfo mint k, --keystore=KEYSTORE m, --metadata=METADATA # Mint NFT from NFO
78
+ ```
79
+
80
+ ### order
81
+
82
+ $ ta order
83
+
84
+ ```
85
+ Commands:
86
+ ta order auction # auction NFT
87
+ ta order bid # bid NFT
88
+ ta order cancel ID k, --keystore=KEYSTORE # cancel order
89
+ ta order fill ID k, --keystore=KEYSTORE # fill order
90
+ ta order help [COMMAND] # Describe subcommands or one specific subcommand
91
+ ta order index k, --keystore=KEYSTORE # list orders
92
+ ta order sell # sell NFT at fixed price
93
+ ta order show ID k, --keystore=KEYSTORE # query order
29
94
  ```
30
95
 
31
96
  ## Development
@@ -8,16 +8,18 @@ module TridentAssistant
8
8
  MINIMUM_AMOUNT = 0.000_000_01
9
9
 
10
10
  def orders(**kwargs)
11
+ authorization = mixin_bot ? mixin_bot.access_token("GET", "/me") : ""
11
12
  client.get(
12
13
  "api/orders",
13
14
  headers: {
14
- Authorization: "Bearer #{mixin_bot.access_token("GET", "/me")}"
15
+ Authorization: "Bearer #{authorization}"
15
16
  },
16
17
  params: {
17
18
  collection_id: kwargs[:collection_id],
18
19
  metahash: kwargs[:metahash],
19
20
  state: kwargs[:state],
20
- type: kwargs[:type]
21
+ type: kwargs[:type],
22
+ page: kwargs[:page]
21
23
  }
22
24
  )
23
25
  end
@@ -14,16 +14,8 @@ module TridentAssistant
14
14
  def initialize(*args)
15
15
  super
16
16
 
17
- endpoint =
18
- if options[:endpoint].present?
19
- options[:endpoint]
20
- else
21
- {
22
- prod: "https://thetrident.one",
23
- test: "https://trident-test.onrender.com",
24
- dev: "http://localhost:3000"
25
- }[options[:environment].to_sym]
26
- end
17
+ endpoint = options[:endpoint] || "https://thetrident.one"
18
+
27
19
  @api =
28
20
  begin
29
21
  TridentAssistant::API.new(
@@ -60,18 +60,19 @@ module TridentAssistant
60
60
  raise "#{dir} is not a directory" unless Dir.exist?(dir)
61
61
 
62
62
  Dir.glob("#{dir}/*.json").each do |file|
63
+ log "-" * 80
63
64
  log UI.fmt("{{v}} found #{file}")
64
65
  data = TridentAssistant::Utils.parse_json file
65
- metadata = TridentAssistant::Utils.parse_metadata data
66
- log UI.fmt("{{v}} metadata parsed")
67
- metadata.validate!
68
- log UI.fmt("{{v}} metadata validated")
69
-
70
66
  if data.dig("_airdrop", "hash").present?
71
67
  log UI.fmt("{{v}} NFT already transferred")
72
68
  next
73
69
  end
74
70
 
71
+ metadata = TridentAssistant::Utils.parse_metadata data
72
+ log UI.fmt("{{v}} metadata parsed")
73
+ metadata.validate!
74
+ log UI.fmt("{{v}} metadata validated")
75
+
75
76
  receiver_id = data.dig("_airdrop", "receiver_id")
76
77
  start_at = data.dig("_airdrop", "start_at")
77
78
  log UI.fmt("{{v}} airdrop receiver_id: #{receiver_id}")
@@ -93,8 +94,7 @@ module TridentAssistant
93
94
 
94
95
  private
95
96
 
96
- def _airdrop
97
- end
97
+ def _airdrop; end
98
98
  end
99
99
  end
100
100
  end
@@ -22,6 +22,7 @@ module TridentAssistant
22
22
  raise "#{dir} is not a directory" unless Dir.exist?(dir)
23
23
 
24
24
  Dir.glob("#{dir}/*.json").each do |file|
25
+ log "-" * 80
25
26
  log UI.fmt("{{v}} found #{file}")
26
27
  _mint file
27
28
  rescue TridentAssistant::Utils::Metadata::InvalidFormatError, JSON::ParserError, Client::RequestError,
@@ -69,23 +70,34 @@ module TridentAssistant
69
70
  # pay to NFO
70
71
  trace_id = data.dig("_mint", "trace_id") || SecureRandom.uuid
71
72
  memo = api.mixin_bot.nft_memo metadata.collection[:id], metadata.token[:id].to_i, metadata.metahash
72
- payment =
73
- api.mixin_bot.create_multisig_transaction(
74
- api.keystore[:pin],
75
- {
76
- asset_id: TridentAssistant::Utils::MINT_ASSET_ID,
77
- trace_id: trace_id,
78
- amount: TridentAssistant::Utils::MINT_AMOUNT,
79
- memo: memo,
80
- receivers: TridentAssistant::Utils::NFO_MTG[:members],
81
- threshold: TridentAssistant::Utils::NFO_MTG[:threshold]
82
- }
83
- )
84
73
 
85
74
  data["_mint"]["trace_id"] = trace_id
86
- if payment["errors"].blank?
75
+ 10.times do
76
+ payment =
77
+ begin
78
+ api.mixin_bot.create_multisig_transaction(
79
+ api.keystore[:pin],
80
+ {
81
+ asset_id: TridentAssistant::Utils::MINT_ASSET_ID,
82
+ trace_id: trace_id,
83
+ amount: TridentAssistant::Utils::MINT_AMOUNT,
84
+ memo: memo,
85
+ receivers: TridentAssistant::Utils::NFO_MTG[:members],
86
+ threshold: TridentAssistant::Utils::NFO_MTG[:threshold]
87
+ }
88
+ )
89
+ rescue MixinBot::InsufficientPoolError => e
90
+ log UI.fmt("{{x}} #{e.inspect}")
91
+ log "Retrying to pay..."
92
+ sleep 0.5
93
+ nil
94
+ end
95
+
96
+ next if payment.blank? || payment["errors"].present?
97
+
87
98
  log UI.fmt("{{v}} NFT mint payment paid: #{payment["data"]}")
88
99
  data["_mint"]["token_id"] = token_id
100
+ break
89
101
  end
90
102
 
91
103
  log UI.fmt("{{v}} NFT successfully minted")
@@ -10,17 +10,20 @@ module TridentAssistant
10
10
  MINIMUM_AMOUNT = 0.000_000_01
11
11
 
12
12
  desc "index", "list orders"
13
- option :keystore, type: :string, aliases: "k", required: true, desc: "keystore or keystore.json file of Mixin bot"
13
+ option :keystore, type: :string, aliases: "k", required: false,
14
+ desc: "keystore or keystore.json file of Mixin bot"
14
15
  option :collection, type: :string, aliases: "c", required: false, desc: "collection ID"
15
16
  option :metahash, type: :string, aliases: "m", required: false, desc: "metahash"
16
17
  option :type, type: :string, aliases: "t", required: false, desc: "ask | bid | auction"
17
18
  option :state, type: :string, aliases: "s", required: false, desc: "open | completed"
19
+ option :page, type: :numeric, aliases: "p", required: false, desc: "page"
18
20
  def index
19
21
  log api.orders(
20
22
  collection_id: options[:collection],
21
23
  metahash: options[:metahash],
22
24
  state: options[:state],
23
- type: options[:type]
25
+ type: options[:type],
26
+ page: options[:page]
24
27
  )
25
28
  end
26
29
 
@@ -50,28 +53,6 @@ module TridentAssistant
50
53
  def cancel(id)
51
54
  log api.cancel_order id
52
55
  end
53
-
54
- desc "deposit TOKEN", "deposit NFT"
55
- def deposit(token)
56
- log api.deposit_nft token
57
- end
58
-
59
- desc "withdraw TOKEN", "withdraw NFT"
60
- option :keystore, type: :string, aliases: "k", required: true, desc: "keystore or keystore.json file of Mixin bot"
61
- def withdraw(token)
62
- payment =
63
- api.mixin_bot.create_multisig_transaction(
64
- keystore[:pin],
65
- asset_id: EXCHANGE_ASSET_ID,
66
- amount: MINIMUM_AMOUNT,
67
- receivers: TridentAssistant::Utils::TRIDENT_MTG[:members],
68
- threshold: TridentAssistant::Utils::TRIDENT_MTG[:threshold],
69
- memo: TridentAssistant::Utils::Memo.new(type: "W", token_id: token).encode,
70
- trace_id: SecureRandom.uuid
71
- )
72
-
73
- log UI.fmt("{{v}} payment: #{payment}")
74
- end
75
56
  end
76
57
  end
77
58
  end
@@ -13,9 +13,8 @@ module TridentAssistant
13
13
  module CLI
14
14
  # Main commands of CLI
15
15
  class Command < TridentAssistant::CLI::Base
16
- class_option :pretty, type: :boolean, aliases: "-p", default: true, desc: "Print output in pretty"
17
- class_option :environment, type: :string, aliases: "-e", default: "prod", desc: "prod | test | dev"
18
16
  class_option :endpoint, type: :string, aliases: "-E", desc: "Specify an endpoint"
17
+ class_option :pretty, type: :boolean, aliases: "-P", default: true, desc: "Print output in pretty"
19
18
 
20
19
  desc "version", "Display TridentAssistant version"
21
20
  def version
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TridentAssistant
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
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.0
4
+ version: 0.1.1
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-07 00:00:00.000000000 Z
11
+ date: 2022-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixin_bot