mixin_bot 0.6.9 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c8a71e3aaa9d7cd81d5bd0e6246ca5e00904665b2d9cb8163d0ec69354fc301
4
- data.tar.gz: 446205c2de0bd8a716fbe1a0a9c23d72f0f73f6d2a029502f9971257f776e753
3
+ metadata.gz: fcc69721b226d0b558be21473b00ad31c5ddff688b81742167b58db6989b55a7
4
+ data.tar.gz: a4384317d625df14c6a015da3203cf23f840955691b3908ea81fab4a806e55bf
5
5
  SHA512:
6
- metadata.gz: c1f70ef3b0c626476831cbdb949b660a8b4967f2936c8278ee9b458d32602b33cee02e8b12dbddad4dc9273d37bad20acf77fc0dffe937a2047239d91ab52948
7
- data.tar.gz: a0e27a3702d094804646f9803718aa33244cd654f845c3eefbf570cfbaf7839da619d74aa074d04df2684dd9b426951b2dcea204a6b90aeccc09e543a989d3e8
6
+ metadata.gz: 0c782580d7a5c7e3e4f52d1523890ba9a336c5459bf3c4841ab81b692335957db1eed78c1cb5ac2b03f7b190df2fb7d6c216833be38054e606efc9130d514963
7
+ data.tar.gz: 7b63815549077772b357e4d43d4b05d16d6a8bf6efc7899960878f1a75b12bf7320949b8806c80ea6b3ddf09ac4451eadc52b600475f056dd5c3be616203fd7c
@@ -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,32 @@
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
+ end
31
+ end
32
+ 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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MixinBot
4
- VERSION = '0.6.9'
4
+ VERSION = '0.7.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixin_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - an-lee
@@ -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