mixin_bot 0.7.8 → 0.7.11

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: 9d053efb8425d1b2d144834961e60bae9abac2dbd877c0dea1a2aa8bb9bc4541
4
- data.tar.gz: e830b155aa0b4bfd509732f7126cfc676b41bfc5425fb5646178ceabbed64c86
3
+ metadata.gz: 3b4b77d94221e1120da8c18fadd70bcf5898d083e2bd95c469cee8c96084c76f
4
+ data.tar.gz: '039f44131a984c10b1f527b6c45766a3660af6efc40e2e66e132b46e1cbc8428'
5
5
  SHA512:
6
- metadata.gz: 901ea75a36eeda0343230b00f9e478f6c2fbe8dd03d9209f78fe7da65e3b09d4a266ca8a08d979c490153e51d761ed2cf47824b485c25d8d7a4e7485efeb0aab
7
- data.tar.gz: 44a8d64a5aead528b0949ee6ac33acdd6f7d16f56aaec4ee45f7ef964b8646f5e4baabcada13968bc48468cb3de03babfb1fb47ef19566fe519b6fae10cd4a4f
6
+ metadata.gz: 22470467c1b5955e2e2352788fecbf14bf307abdba0283796a2b86525660a8f479670135bd9d594b59462a2058956214036025f9881833b57b21f59f28644876
7
+ data.tar.gz: e88226bd6042e3ff224ff5805d1982df1ee4a6b17186440d3edeae820c9f804e1952b3da83dc2b29258a97f5be7685b6d3e163bbab242d83752e468a0d1a4908
@@ -18,7 +18,7 @@ module MixinBot
18
18
 
19
19
  $ mixinbot api /payments -k ~/.mixinbot/keystore.json -m POST -d '{"asset_id":"965e5c6e-434c-3fa9-b780-c50f43cd955c", "amount":"1", "trace_id": "37f16abb-0640-4d01-9423-a06121732d35", "memo":"test", "opponent_multisig":{"receivers":["0508a116-1239-4e28-b150-85a8e3e6b400", "7ed9292d-7c95-4333-aa48-a8c640064186", "a67c6e87-1c9e-4a1c-b81c-47a9f4f1bff1"], "threshold":2}}'
20
20
  LONGDESC
21
- option :keystore, type: :string, aliases: '-k', required: true, default: '~/.mixinbot/keystore.json', desc: 'Specify keystore.json file path'
21
+ option :keystore, type: :string, aliases: '-k', required: true, desc: 'keystore or keystore.json file path'
22
22
  option :method, type: :string, aliases: '-m', default: 'GET', desc: 'HTTP method, GET or POST'
23
23
  option :params, type: :hash, aliases: '-p', desc: 'HTTP GET params'
24
24
  option :data, type: :string, aliases: '-d', default: '{}', desc: 'HTTP POST data'
@@ -3,7 +3,7 @@
3
3
  module MixinBot
4
4
  class CLI < Thor
5
5
  desc 'encrypt PIN', 'encrypt PIN using private key'
6
- option :keystore, type: :string, aliases: '-k', required: true, default: '~/.mixinbot/keystore.json', desc: 'Specify keystore.json file path'
6
+ option :keystore, type: :string, aliases: '-k', required: true, desc: 'keystore or keystore.json file path'
7
7
  option :iterator, type: :string, aliases: '-i', desc: 'Iterator'
8
8
  def encrypt(pin)
9
9
  log api_instance.encrypt_pin options[:pin].to_s, iterator: options[:iterator]
data/lib/mixin_bot/cli.rb CHANGED
@@ -24,7 +24,7 @@ module MixinBot
24
24
  return if options[:keystore].blank?
25
25
 
26
26
  keystore =
27
- if File.exist? options[:keystore].to_s
27
+ if File.file? options[:keystore]
28
28
  File.read options[:keystore]
29
29
  else
30
30
  options[:keystore]
@@ -76,7 +76,9 @@ module MixinBot
76
76
  raise UnauthorizedError, errmsg
77
77
  when 403, 20116, 10002, 429
78
78
  raise ForbiddenError, errmsg
79
- when 400, 404, 10006, 20133, 500, 7000, 7001
79
+ when 404
80
+ raise NotFoundError, errmsg
81
+ when 400, 10006, 20133, 500, 7000, 7001
80
82
  raise ResponseError, errmsg
81
83
  when 20117
82
84
  raise InsufficientBalanceError, errmsg
@@ -57,7 +57,7 @@ module MixinBot
57
57
  if tx.is_a? String
58
58
  tx = JSON.parse tx
59
59
  end
60
- raise "#{tx} is not a valid json" unless tx.is_a? Hash
60
+ raise ArgumentError, "#{tx} is not a valid json" unless tx.is_a? Hash
61
61
 
62
62
  tx = tx.with_indifferent_access
63
63
  bytes = []
@@ -99,7 +99,7 @@ module MixinBot
99
99
  tx = {}
100
100
 
101
101
  magic = bytes.shift(2)
102
- raise 'Not valid raw' unless magic == MAGIC
102
+ raise ArgumentError, 'Not valid raw' unless magic == MAGIC
103
103
 
104
104
  version = bytes.shift(2)
105
105
  tx['version'] = bytes_to_int version
@@ -121,7 +121,7 @@ module MixinBot
121
121
  # aggregated
122
122
  aggregated = {}
123
123
 
124
- raise 'invalid aggregated' unless bytes.shift(2).reverse.pack('C*').unpack1('S*') == AGGREGATED_SIGNATURE_PREFIX
124
+ raise ArgumentError, 'invalid aggregated' unless bytes.shift(2).reverse.pack('C*').unpack1('S*') == AGGREGATED_SIGNATURE_PREFIX
125
125
 
126
126
  aggregated['signature'] = bytes.shift(64).pack('C*').unpack1('H*')
127
127
 
@@ -162,7 +162,7 @@ module MixinBot
162
162
 
163
163
  def nft_memo_hash(collection, token_id, hash)
164
164
  collection = NULL_UUID if collection.empty?
165
- raise 'hash must be 256-bit string' unless hash.is_a?(String) && hash.size == 64
165
+ raise ArgumentError, 'hash must be 256-bit string' unless hash.is_a?(String) && hash.size == 64
166
166
 
167
167
  memo = {
168
168
  prefix: NFT_MEMO_PREFIX,
@@ -171,14 +171,14 @@ module MixinBot
171
171
  chain: NFT_MEMO_DEFAULT_CHAIN,
172
172
  class: NFT_MEMO_DEFAULT_CLASS,
173
173
  collection: collection,
174
- token: token_id.to_s,
174
+ token: token_id.to_i,
175
175
  extra: hash
176
176
  }
177
177
 
178
178
  mark = [0]
179
179
  mark.map do |index|
180
180
  if index >= 64
181
- raise "invalid NFO memo index #{index}"
181
+ raise ArgumentError, "invalid NFO memo index #{index}"
182
182
  end
183
183
  memo[:mask] = memo[:mask] ^ (1 << index)
184
184
  end
@@ -252,8 +252,8 @@ module MixinBot
252
252
  private
253
253
 
254
254
  def encode_int(int)
255
- raise "only support int #{int}" unless int.is_a?(Integer)
256
- raise "int #{int} is larger than MAX_ENCODE_INT #{MAX_ENCODE_INT}" if int > MAX_ENCODE_INT
255
+ raise ArgumentError, "only support int #{int}" unless int.is_a?(Integer)
256
+ raise ArgumentError,"int #{int} is larger than MAX_ENCODE_INT #{MAX_ENCODE_INT}" if int > MAX_ENCODE_INT
257
257
 
258
258
  [int].pack('S*').bytes.reverse
259
259
  end
@@ -263,7 +263,7 @@ module MixinBot
263
263
  end
264
264
 
265
265
  def bytes_of(int)
266
- raise 'not integer' unless int.is_a?(Integer)
266
+ raise ArgumentError, 'not integer' unless int.is_a?(Integer)
267
267
 
268
268
  bytes = []
269
269
  loop do
@@ -427,8 +427,8 @@ module MixinBot
427
427
  bytes += NULL_BYTES
428
428
  else
429
429
  signers.each do |sig, i|
430
- raise 'signers not sorted' if i > 0 && sig <= signers[i - 1]
431
- raise 'signers not sorted' if sig > MAX_ENCODE_INT
430
+ raise ArgumentError, 'signers not sorted' if i > 0 && sig <= signers[i - 1]
431
+ raise ArgumentError, 'signers not sorted' if sig > MAX_ENCODE_INT
432
432
  end
433
433
 
434
434
  max = signers.last
@@ -458,7 +458,7 @@ module MixinBot
458
458
  0
459
459
  end
460
460
 
461
- raise 'signatures overflow' if sl == MAX_ENCODE_INT
461
+ raise ArgumentError, 'signatures overflow' if sl == MAX_ENCODE_INT
462
462
  bytes += encode_int sl
463
463
 
464
464
  if sl > 0
@@ -493,7 +493,7 @@ module MixinBot
493
493
 
494
494
  if bytes[...2] != NULL_BYTES
495
495
  magic = bytes.shift(2)
496
- raise 'Not valid input' unless magic == MAGIC
496
+ raise ArgumentError, 'Not valid input' unless magic == MAGIC
497
497
 
498
498
  deposit = {}
499
499
  deposit['chain'] = bytes.shift(32).pack('C*').unpack1('H*')
@@ -516,7 +516,7 @@ module MixinBot
516
516
 
517
517
  if bytes[...2] != NULL_BYTES
518
518
  magic = bytes.shift(2)
519
- raise 'Not valid input' unless magic == MAGIC
519
+ raise ArgumentError, 'Not valid input' unless magic == MAGIC
520
520
 
521
521
  mint = {}
522
522
  if bytes[...2] != NULL_BYTES
@@ -567,7 +567,7 @@ module MixinBot
567
567
 
568
568
  if bytes[...2] != NULL_BYTES
569
569
  magic = bytes.shift(2)
570
- raise 'Not valid output' unless magic == MAGIC
570
+ raise ArgumentError, 'Not valid output' unless magic == MAGIC
571
571
 
572
572
  withdraw = {}
573
573
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MixinBot
4
- VERSION = '0.7.8'
4
+ VERSION = '0.7.11'
5
5
  end
data/lib/mixin_bot.rb CHANGED
@@ -30,12 +30,15 @@ module MixinBot
30
30
  @api ||= MixinBot::API.new
31
31
  end
32
32
 
33
- class HttpError < StandardError; end
34
- class RequestError < StandardError; end
35
- class ResponseError < StandardError; end
36
- class UnauthorizedError < StandardError; end
37
- class ForbiddenError < StandardError; end
38
- class InsufficientBalanceError < StandardError; end
39
- class InsufficientPoolError < StandardError; end
40
- class PinError < StandardError; end
33
+ class Error < StandardError; end
34
+ class ArgumentError < StandardError; end
35
+ class HttpError < Error; end
36
+ class RequestError < Error; end
37
+ class ResponseError < Error; end
38
+ class NotFoundError < Error; end
39
+ class UnauthorizedError < Error; end
40
+ class ForbiddenError < Error; end
41
+ class InsufficientBalanceError < Error; end
42
+ class InsufficientPoolError < Error; end
43
+ class PinError < Error; end
41
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixin_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - an-lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-20 00:00:00.000000000 Z
11
+ date: 2022-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport