mixin_bot 0.6.2 → 0.6.6
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 +4 -4
- data/lib/mixin_bot/api/collectible.rb +6 -4
- data/lib/mixin_bot/api/conversation.rb +1 -0
- data/lib/mixin_bot/api/multisig.rb +46 -47
- data/lib/mixin_bot/utils.rb +3 -4
- data/lib/mixin_bot/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1c0fbeabe6a358600bd80d72f66d5c6b80e821cfe6f825d5ca1fea0a760b21f
|
4
|
+
data.tar.gz: f6145d9b52a375c483d2e9245de73af120ff8f799c3385e63ca8c4351576bf7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b5a1d53e447d0a69ab2d6e7eb4d0f326605ef69b08cbefa4f9e4161aac3b52f74db91fc3da009110c1314050c484d5d6abd89a611717a85720e1a347d760c1a
|
7
|
+
data.tar.gz: 9ccc513bea19199e6070d04fc95f0c29cdc4371dc167a3990b7645c31cc855eea93a3bac061fac4280c9b36b869b7cae8cc80e999472e36562cfd5a35b8ea8c4
|
@@ -101,7 +101,7 @@ module MixinBot
|
|
101
101
|
# receivers_threshold: 1,
|
102
102
|
# state: 'unspent'
|
103
103
|
# }
|
104
|
-
COLLECTIBLE_TRANSACTION_ARGUMENTS = %i[collectible nfo receivers
|
104
|
+
COLLECTIBLE_TRANSACTION_ARGUMENTS = %i[collectible nfo receivers receivers_threshold].freeze
|
105
105
|
def build_collectible_transaction(**kwargs)
|
106
106
|
raise ArgumentError, "#{COLLECTIBLE_TRANSACTION_ARGUMENTS.join(', ')} are needed for build collectible transaction" unless COLLECTIBLE_TRANSACTION_ARGUMENTS.all? { |param| kwargs.keys.include? param }
|
107
107
|
|
@@ -112,11 +112,13 @@ module MixinBot
|
|
112
112
|
build_raw_transaction(
|
113
113
|
utxos: [collectible],
|
114
114
|
senders: collectible['receivers'],
|
115
|
+
senders_threshold: collectible['receivers_threshold'],
|
115
116
|
receivers: kwargs['receivers'],
|
116
|
-
|
117
|
-
extra: kwargs[
|
117
|
+
receivers_threshold: kwargs['receivers_threshold'],
|
118
|
+
extra: kwargs['nfo'],
|
118
119
|
amount: 1,
|
119
|
-
asset_mixin_id: NFT_ASSET_MIXIN_ID
|
120
|
+
asset_mixin_id: NFT_ASSET_MIXIN_ID,
|
121
|
+
access_token: kwargs['access_token'],
|
120
122
|
)
|
121
123
|
end
|
122
124
|
|
@@ -146,26 +146,30 @@ module MixinBot
|
|
146
146
|
# kwargs:
|
147
147
|
# {
|
148
148
|
# senders: [ uuid ],
|
149
|
+
# senders_threshold: integer,
|
149
150
|
# receivers: [ uuid ],
|
150
|
-
#
|
151
|
+
# receivers_threshold: integer,
|
151
152
|
# asset_id: uuid,
|
152
153
|
# amount: string / float,
|
153
154
|
# memo: string,
|
154
155
|
# }
|
155
|
-
RAW_TRANSACTION_ARGUMENTS = %i[utxos senders receivers amount
|
156
|
+
RAW_TRANSACTION_ARGUMENTS = %i[utxos senders senders_threshold receivers receivers_threshold amount].freeze
|
156
157
|
def build_raw_transaction(**kwargs)
|
157
158
|
raise ArgumentError, "#{RAW_TRANSACTION_ARGUMENTS.join(', ')} are needed for build raw transaction" unless RAW_TRANSACTION_ARGUMENTS.all? { |param| kwargs.keys.include? param }
|
158
159
|
|
159
|
-
senders
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
160
|
+
senders = kwargs[:senders]
|
161
|
+
senders_threshold = kwargs[:senders_threshold]
|
162
|
+
receivers = kwargs[:receivers]
|
163
|
+
receivers_threshold = kwargs[:receivers_threshold]
|
164
|
+
amount = kwargs[:amount]
|
165
|
+
asset_id = kwargs[:asset_id]
|
166
|
+
asset_mixin_id = kwargs[:asset_mixin_id]
|
167
|
+
utxos = kwargs[:utxos]
|
168
|
+
memo = kwargs[:memo]
|
169
|
+
extra = kwargs[:extra]
|
170
|
+
access_token = kwargs[:access_token]
|
171
|
+
outputs = kwargs[:outputs] || []
|
172
|
+
hint = kwargs[:hint]
|
169
173
|
|
170
174
|
raise 'access_token required!' if access_token.nil? && !senders.include?(client_id)
|
171
175
|
|
@@ -193,23 +197,27 @@ module MixinBot
|
|
193
197
|
}
|
194
198
|
)
|
195
199
|
|
196
|
-
outputs
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
200
|
+
if outputs.empty?
|
201
|
+
receivers_threshold = 1 if receivers.size == 1
|
202
|
+
output0 = build_output(
|
203
|
+
receivers: receivers,
|
204
|
+
index: 0,
|
205
|
+
amount: amount,
|
206
|
+
threshold: receivers_threshold,
|
207
|
+
hint: hint
|
208
|
+
)
|
209
|
+
outputs.push output0
|
204
210
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
211
|
+
if input_amount > amount
|
212
|
+
output1 = build_output(
|
213
|
+
receivers: senders,
|
214
|
+
index: 1,
|
215
|
+
amount: (input_amount - amount),
|
216
|
+
threshold: senders_threshold,
|
217
|
+
hint: hint
|
218
|
+
)
|
219
|
+
outputs.push output1
|
220
|
+
end
|
213
221
|
end
|
214
222
|
|
215
223
|
extra = extra || Digest.hexencode(memo.to_s.slice(0, 140))
|
@@ -225,31 +233,22 @@ module MixinBot
|
|
225
233
|
tx.to_json
|
226
234
|
end
|
227
235
|
|
236
|
+
def build_output(receivers:, index:, amount:, threshold:, hint: nil)
|
237
|
+
_output = create_output receivers: receivers, index: index, hint: hint
|
238
|
+
{
|
239
|
+
amount: format('%.8f', amount.to_f),
|
240
|
+
script: build_threshold_script(threshold),
|
241
|
+
mask: _output['mask'],
|
242
|
+
keys: _output['keys']
|
243
|
+
}
|
244
|
+
end
|
245
|
+
|
228
246
|
def str_to_bin(str)
|
229
247
|
return if str.nil?
|
230
248
|
|
231
249
|
str.scan(/../).map(&:hex).pack('c*')
|
232
250
|
end
|
233
251
|
|
234
|
-
def build_inputs(inputs)
|
235
|
-
res = []
|
236
|
-
prototype = {
|
237
|
-
'Hash' => nil,
|
238
|
-
'Index' => nil,
|
239
|
-
'Genesis' => nil,
|
240
|
-
'Deposit' => nil,
|
241
|
-
'Mint' => nil
|
242
|
-
}
|
243
|
-
inputs.each do |input|
|
244
|
-
struc = prototype.dup
|
245
|
-
struc['Hash'] = str_to_bin input['hash']
|
246
|
-
struc['Index'] = input['index']
|
247
|
-
res << struc
|
248
|
-
end
|
249
|
-
|
250
|
-
res
|
251
|
-
end
|
252
|
-
|
253
252
|
def generate_trace_from_hash(hash, output_index = 0)
|
254
253
|
MixinBot::Utils.generate_trace_from_hash hash, output_index
|
255
254
|
end
|
data/lib/mixin_bot/utils.rb
CHANGED
@@ -17,11 +17,10 @@ module MixinBot
|
|
17
17
|
NFT_MASK = 0x00
|
18
18
|
NULL_UUID = '00000000-0000-0000-0000-000000000000'
|
19
19
|
|
20
|
-
def unique_uuid(
|
21
|
-
opponent_id ||= client_id
|
20
|
+
def unique_uuid(uuid_1, uuid_2)
|
22
21
|
md5 = Digest::MD5.new
|
23
|
-
md5 << [
|
24
|
-
md5 << [
|
22
|
+
md5 << [uuid_1, uuid_2].min
|
23
|
+
md5 << [uuid_1, uuid_2].max
|
25
24
|
digest = md5.digest
|
26
25
|
digest6 = (digest[6].ord & 0x0f | 0x30).chr
|
27
26
|
digest8 = (digest[8].ord & 0x3f | 0x80).chr
|
data/lib/mixin_bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixin_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
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
|
+
date: 2021-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: awesome_print
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|