mixin_bot 0.6.6 → 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: c1c0fbeabe6a358600bd80d72f66d5c6b80e821cfe6f825d5ca1fea0a760b21f
4
- data.tar.gz: f6145d9b52a375c483d2e9245de73af120ff8f799c3385e63ca8c4351576bf7f
3
+ metadata.gz: fcc69721b226d0b558be21473b00ad31c5ddff688b81742167b58db6989b55a7
4
+ data.tar.gz: a4384317d625df14c6a015da3203cf23f840955691b3908ea81fab4a806e55bf
5
5
  SHA512:
6
- metadata.gz: 3b5a1d53e447d0a69ab2d6e7eb4d0f326605ef69b08cbefa4f9e4161aac3b52f74db91fc3da009110c1314050c484d5d6abd89a611717a85720e1a347d760c1a
7
- data.tar.gz: 9ccc513bea19199e6070d04fc95f0c29cdc4371dc167a3990b7645c31cc855eea93a3bac061fac4280c9b36b869b7cae8cc80e999472e36562cfd5a35b8ea8c4
6
+ metadata.gz: 0c782580d7a5c7e3e4f52d1523890ba9a336c5459bf3c4841ab81b692335957db1eed78c1cb5ac2b03f7b190df2fb7d6c216833be38054e606efc9130d514963
7
+ data.tar.gz: 7b63815549077772b357e4d43d4b05d16d6a8bf6efc7899960878f1a75b12bf7320949b8806c80ea6b3ddf09ac4451eadc52b600475f056dd5c3be616203fd7c
@@ -107,7 +107,7 @@ module MixinBot
107
107
 
108
108
  kwargs = kwargs.with_indifferent_access
109
109
  collectible = kwargs['collectible']
110
- raise "collectible is #{collectible['state']}" unless collectible['state'] == 'unspent'
110
+ raise "collectible is spent" if collectible['state'] == 'spent'
111
111
 
112
112
  build_raw_transaction(
113
113
  utxos: [collectible],
@@ -119,6 +119,7 @@ module MixinBot
119
119
  amount: 1,
120
120
  asset_mixin_id: NFT_ASSET_MIXIN_ID,
121
121
  access_token: kwargs['access_token'],
122
+ hint: kwargs['hint']
122
123
  )
123
124
  end
124
125
 
@@ -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
@@ -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.6'
4
+ VERSION = '0.7.0'
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.6
4
+ version: 0.7.0
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-01 00:00:00.000000000 Z
11
+ date: 2021-11-17 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