mixin_bot 0.6.7 → 0.7.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: 17929bbd632d70e05fe080d38552653e6844d0e4e9294c07d98ff14dc75bd8b2
4
- data.tar.gz: 63716dfffefe9e71b383fec03751cdae325e0ea892c80897e1573c22b5c74a01
3
+ metadata.gz: 8c1313d5bfb3552add5f8e54e5427695755dbc6a13b72c9aca7b43379d85b6d3
4
+ data.tar.gz: 57029bdfe6ef1af87e81a20a9c063e0955927c5be235e29154b5c6cf88d56fd7
5
5
  SHA512:
6
- metadata.gz: 12b4b297af48990eb6ecf0fe5d591287dcdab307d2aea5b4fef51ea408c208d029f1bc60105f9332c7561a9564d2a11d3c0e3f0787d21cc11035f5fc2f04d27d
7
- data.tar.gz: 6ed7696fc217f4d8297110be1e3eda0a25384615ecfac3ba1799179da280d1fccc7dc394547787301b5c0cf89568650cd27114b29a04426e5275395a8825a14b
6
+ metadata.gz: 3e8fe5f71267fde3c18ac2b2e8bd45736c7a6efd61bb3f0459d59526149b96fa923db7b913ab76eb507605c738e9b271afb19d57442692c13b7163010332aa9e
7
+ data.tar.gz: 733748278679ba56508454da2ecc452d695235a879cef2a400738cff40c4e44e60025ed5468f51cd30af4277f0f420cca75e70f3f4ca0ad09cb3711c465ee907
@@ -107,7 +107,7 @@ module MixinBot
107
107
 
108
108
  kwargs = kwargs.with_indifferent_access
109
109
  collectible = kwargs['collectible']
110
- raise "collectible is spent" unless collectible['state'] == 'spent'
110
+ raise "collectible is spent" if collectible['state'] == 'spent'
111
111
 
112
112
  build_raw_transaction(
113
113
  utxos: [collectible],
@@ -122,19 +122,6 @@ module MixinBot
122
122
  client.get(path, headers: { 'Authorization': authorization })
123
123
  end
124
124
 
125
- # send a signed transaction to main net
126
- def send_raw_transaction(raw, access_token: nil)
127
- path = '/external/proxy'
128
- payload = {
129
- method: 'sendrawtransaction',
130
- params: [raw]
131
- }
132
-
133
- access_token ||= access_token('POST', path, payload.to_json)
134
- authorization = format('Bearer %<access_token>s', access_token: access_token)
135
- client.post(path, headers: { 'Authorization': authorization }, json: payload)
136
- end
137
-
138
125
  def build_threshold_script(threshold)
139
126
  s = threshold.to_s(16)
140
127
  s = s.length == 1 ? "0#{s}" : s
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MixinBot
4
+ class API
5
+ module Rpc
6
+ def rpc_proxy(method, params = [], access_token: nil)
7
+ path = '/external/proxy'
8
+ payload = {
9
+ method: method,
10
+ params: params
11
+ }
12
+
13
+ access_token ||= access_token('POST', path, payload.to_json)
14
+ authorization = format('Bearer %<access_token>s', access_token: access_token)
15
+ client.post(path, headers: { 'Authorization': authorization }, json: payload)
16
+ end
17
+
18
+ # send a signed transaction to main net
19
+ def send_raw_transaction(raw, access_token: nil)
20
+ rpc_proxy('sendrawtransaction', [raw], access_token: access_token)
21
+ end
22
+
23
+ def get_transaction(hash, access_token: nil)
24
+ rpc_proxy('gettransaction', [hash], access_token: nil)
25
+ end
26
+
27
+ def get_utxo(hash, index = 0, access_token: nil)
28
+ rpc_proxy 'getutxo', [hash, index], access_token: access_token
29
+ end
30
+
31
+ def get_snapshot(hash, access_token: nil)
32
+ rpc_proxy 'getsnapshot', [hash], access_token: access_token
33
+ end
34
+
35
+ def list_snapshots(offset = 0, count = 10, sig = false, tx = false, access_token: nil)
36
+ rpc_proxy 'listsnapshots', [offset, count, sig, tx], access_token: access_token
37
+ end
38
+
39
+ def list_mint_works(offset = 0, access_token: nil)
40
+ rpc_proxy 'listmintworks', [offset], access_token: access_token
41
+ end
42
+
43
+ def list_mint_distributions(offset = 0, count = 10, tx = false, access_token: nil)
44
+ rpc_proxy 'listmintdistributions', [offset, count, tx], access_token: access_token
45
+ end
46
+ end
47
+ end
48
+ end
data/lib/mixin_bot/api.rb CHANGED
@@ -13,6 +13,7 @@ require_relative './api/message'
13
13
  require_relative './api/multisig'
14
14
  require_relative './api/payment'
15
15
  require_relative './api/pin'
16
+ require_relative './api/rpc'
16
17
  require_relative './api/snapshot'
17
18
  require_relative './api/transaction'
18
19
  require_relative './api/transfer'
@@ -86,6 +87,7 @@ module MixinBot
86
87
  include MixinBot::API::Multisig
87
88
  include MixinBot::API::Payment
88
89
  include MixinBot::API::Pin
90
+ include MixinBot::API::Rpc
89
91
  include MixinBot::API::Snapshot
90
92
  include MixinBot::API::Transaction
91
93
  include MixinBot::API::Transfer
@@ -358,7 +358,7 @@ module MixinBot
358
358
  bytes += [0x00, type]
359
359
 
360
360
  # amount
361
- amount_bytes = bytes_of (output['amount'].to_f * 1e8).to_i
361
+ amount_bytes = bytes_of (output['amount'].to_f * 1e8).round
362
362
  bytes += encode_int amount_bytes.size
363
363
  bytes += amount_bytes
364
364
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MixinBot
4
- VERSION = '0.6.7'
4
+ VERSION = '0.7.1'
5
5
  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.6.7
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - an-lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-02 00:00:00.000000000 Z
11
+ date: 2021-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -286,6 +286,7 @@ files:
286
286
  - lib/mixin_bot/api/multisig.rb
287
287
  - lib/mixin_bot/api/payment.rb
288
288
  - lib/mixin_bot/api/pin.rb
289
+ - lib/mixin_bot/api/rpc.rb
289
290
  - lib/mixin_bot/api/snapshot.rb
290
291
  - lib/mixin_bot/api/transaction.rb
291
292
  - lib/mixin_bot/api/transfer.rb