mixin_bot 0.7.9 → 0.7.10

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: c89684bcccabf1621b82773b9d017e8ec47faac2402ddc6b7238d591c9099705
4
- data.tar.gz: 05d1e90439562b61ba03b3874945168fa4f838f5d48b57fbacb1738cf648a9ff
3
+ metadata.gz: 222522068617e93a42e0b59a81d8afc8908ed3569217c643d781ba4b721f639a
4
+ data.tar.gz: 8d15656e77f7176c91b3daf7d6fc4901c257db8005d1adf27d526913c1646286
5
5
  SHA512:
6
- metadata.gz: f689d32c959651bbf71426f1c68942bc1ad0d17147885f42cfa5606e5a1ffecbf02416e57f8c8aa13cac214e2124bc207f6c51adb91e3962adc474d2e251e029
7
- data.tar.gz: 3d99fd38161f4c1d326b7a32d63400270df4a3c7128070ed7d8abe8bb6f9947c31522963fb967ca4ae30b86d0a38882f911da79e639d7184ded9e36ce31df5a5
6
+ metadata.gz: 5fb562d8867fb8b06723367e9d1a38d4d7bd6c9d6d7c1af7444283855b316d2f18b5aae365f27eb14be85a1630541c81e790cc7aae94bbf2ac21591e029e7f76
7
+ data.tar.gz: b722aa66007d94077ef6b963b260066cfd02074469f58f70f2959f4cf6e1c4c8aaae9c6d18e2bf45af2903a0443f76a3989b172250e4a8c958cea2fcffdc42b8
@@ -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.9'
4
+ VERSION = '0.7.10'
5
5
  end
data/lib/mixin_bot.rb CHANGED
@@ -31,6 +31,7 @@ module MixinBot
31
31
  end
32
32
 
33
33
  class Error < StandardError; end
34
+ class ArgumentError < StandardError; end
34
35
  class HttpError < Error; end
35
36
  class RequestError < Error; end
36
37
  class ResponseError < Error; 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.9
4
+ version: 0.7.10
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-22 00:00:00.000000000 Z
11
+ date: 2022-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport