lbd_sdk 0.1.0 → 0.1.3
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/.github/workflows/push.yml +27 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +3 -0
- data/.vscode/settings.json +7 -1
- data/CHANGELOG.md +15 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +3 -1
- data/README.md +62 -36
- data/lib/lbd_sdk/client.rb +517 -605
- data/lib/lbd_sdk/hash_converter.rb +17 -0
- data/lib/lbd_sdk/http_client.rb +3 -7
- data/lib/lbd_sdk/request.rb +717 -0
- data/lib/lbd_sdk/request_body_flattener.rb +10 -6
- data/lib/lbd_sdk/request_param_validator.rb +31 -0
- data/lib/lbd_sdk/signature_generator.rb +36 -16
- data/lib/lbd_sdk/version.rb +1 -1
- data/lib/lbd_sdk.rb +1 -0
- data/package-lock.json +53 -0
- data/package.json +5 -0
- metadata +8 -2
@@ -0,0 +1,717 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lbd_sdk/request_param_validator'
|
4
|
+
require 'lbd_sdk/hash_converter'
|
5
|
+
|
6
|
+
module LbdSdk
|
7
|
+
module Request
|
8
|
+
include RequestParamValidator
|
9
|
+
include HashConverter
|
10
|
+
|
11
|
+
def page_request(options)
|
12
|
+
{
|
13
|
+
limit: options[:limit] || 10,
|
14
|
+
page: options[:page] || 1,
|
15
|
+
orderBy: options[:order_by] || 'desc',
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def cursor_page_request(options)
|
20
|
+
{
|
21
|
+
limit: options[:limit] || 10,
|
22
|
+
orderBy: options[:order_by] || 'desc',
|
23
|
+
pageToken: options[:page_token] || '',
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def transaction_page_request(options)
|
28
|
+
params = {
|
29
|
+
limit: options[:limit] || 10,
|
30
|
+
page: options[:page] || 1,
|
31
|
+
orderBy: options[:order_by] || 'desc',
|
32
|
+
}
|
33
|
+
params[:before] = options[:before] if !options[:before].nil?
|
34
|
+
params[:after] = options[:after] if !options[:after].nil?
|
35
|
+
params[:msgType] = options[:msgType] if !options[:msgType].nil?
|
36
|
+
params
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_item_token_contract_request(options)
|
40
|
+
if options[:service_wallet_address].nil? ||
|
41
|
+
options[:service_wallet_secret].nil?
|
42
|
+
raise ArgumentError,
|
43
|
+
'service_wallet_address and service_wallet_secret are required'
|
44
|
+
end
|
45
|
+
|
46
|
+
if is_valid_wallet_address(options[:service_wallet_address]) == false
|
47
|
+
raise ArgumentError, 'service_wallet_address is invalid'
|
48
|
+
end
|
49
|
+
|
50
|
+
if is_valid_token_name(options[:name]) == false
|
51
|
+
raise ArgumentError, 'name is invalid'
|
52
|
+
end
|
53
|
+
|
54
|
+
if is_valid_base_uri(options[:base_img_uri]) == false
|
55
|
+
raise ArgumentError, 'base_img_uri is invalid'
|
56
|
+
end
|
57
|
+
|
58
|
+
camelize(options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def created_item_token_contract_request(options)
|
62
|
+
options[:is_only_contract_id] =
|
63
|
+
if options[:is_only_contract_id].nil?
|
64
|
+
false
|
65
|
+
else
|
66
|
+
options[:is_only_contract_id]
|
67
|
+
end
|
68
|
+
camelize(options)
|
69
|
+
end
|
70
|
+
|
71
|
+
def issue_service_token_request(options)
|
72
|
+
if options[:service_wallet_address].nil? ||
|
73
|
+
options[:service_wallet_secret].nil?
|
74
|
+
raise ArgumentError,
|
75
|
+
'service_wallet_address and service_wallet_secret are required'
|
76
|
+
end
|
77
|
+
|
78
|
+
if is_valid_wallet_address(options[:service_wallet_address]) == false
|
79
|
+
raise ArgumentError, 'service_wallet_address is invalid'
|
80
|
+
end
|
81
|
+
|
82
|
+
if is_valid_token_name(options[:name]) == false
|
83
|
+
raise ArgumentError, 'name is invalid'
|
84
|
+
end
|
85
|
+
|
86
|
+
if is_valid_symbol(options[:symbol]) == false
|
87
|
+
raise ArgumentError, 'symbol is invalid'
|
88
|
+
end
|
89
|
+
|
90
|
+
if is_valid_initial_supply(options[:initial_supply]) == false
|
91
|
+
raise ArgumentError, 'initial_supply is invalid'
|
92
|
+
end
|
93
|
+
|
94
|
+
if is_valid_wallet_address(options[:recipient_wallet_address]) == false
|
95
|
+
raise ArgumentError, 'recipient_wallet_address is invalid'
|
96
|
+
end
|
97
|
+
|
98
|
+
if is_valid_base_uri(options[:img_uri]) == false
|
99
|
+
raise ArgumentError, 'img_uri is invalid'
|
100
|
+
end
|
101
|
+
|
102
|
+
camelize(options)
|
103
|
+
end
|
104
|
+
|
105
|
+
def issued_service_token_by_tx_hash_request(options)
|
106
|
+
options[:is_only_contract_id] =
|
107
|
+
if options[:is_only_contract_id].nil?
|
108
|
+
false
|
109
|
+
else
|
110
|
+
options[:is_only_contract_id]
|
111
|
+
end
|
112
|
+
camelize(options)
|
113
|
+
end
|
114
|
+
|
115
|
+
def update_service_token_request(options)
|
116
|
+
if options[:owner_address].nil? || options[:owner_secret].nil?
|
117
|
+
raise ArgumentError, 'owner_address and owner_secret are required'
|
118
|
+
end
|
119
|
+
|
120
|
+
params = {
|
121
|
+
ownerAddress: options[:owner_address],
|
122
|
+
ownerSecret: options[:owner_secret],
|
123
|
+
}
|
124
|
+
params[:name] = options[:name] if !options[:name].nil?
|
125
|
+
params[:meta] = options[:meta] if !options[:meta].nil?
|
126
|
+
params
|
127
|
+
end
|
128
|
+
|
129
|
+
def mint_service_token_request(options)
|
130
|
+
if options[:owner_address].nil? || options[:owner_secret].nil? ||
|
131
|
+
options[:amount].nil?
|
132
|
+
raise ArgumentError,
|
133
|
+
'owner_address and owner_secret and amount are required'
|
134
|
+
end
|
135
|
+
|
136
|
+
params = {
|
137
|
+
ownerAddress: options[:owner_address],
|
138
|
+
ownerSecret: options[:owner_secret],
|
139
|
+
amount: options[:amount].to_s,
|
140
|
+
}
|
141
|
+
if !options[:to_user_id].nil?
|
142
|
+
params[:toUserId] = options[:to_user_id]
|
143
|
+
elsif !options[:to_address].nil?
|
144
|
+
params[:toAddress] = options[:to_address]
|
145
|
+
else
|
146
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
147
|
+
end
|
148
|
+
params
|
149
|
+
end
|
150
|
+
|
151
|
+
def burn_from_service_token_request(options)
|
152
|
+
if options[:owner_address].nil? || options[:owner_secret].nil? ||
|
153
|
+
options[:amount].nil?
|
154
|
+
raise ArgumentError,
|
155
|
+
'owner_address and owner_secret and amount are required'
|
156
|
+
end
|
157
|
+
|
158
|
+
params = {
|
159
|
+
ownerAddress: options[:owner_address],
|
160
|
+
ownerSecret: options[:owner_secret],
|
161
|
+
amount: options[:amount].to_s,
|
162
|
+
}
|
163
|
+
if !options[:from_user_id].nil?
|
164
|
+
params[:fromUserId] = options[:from_user_id]
|
165
|
+
elsif !options[:from_address].nil?
|
166
|
+
params[:fromAddress] = options[:from_address]
|
167
|
+
else
|
168
|
+
raise ArgumentError, 'from_user_id or from_address is required'
|
169
|
+
end
|
170
|
+
params
|
171
|
+
end
|
172
|
+
|
173
|
+
def user_proxy_request(options)
|
174
|
+
if options[:owner_address].nil?
|
175
|
+
raise ArgumentError, 'owner_address is required'
|
176
|
+
end
|
177
|
+
|
178
|
+
params = { ownerAddress: options[:owner_address] }
|
179
|
+
params[:landingUri] = options[:landing_uri] if !options[:landing_uri].nil?
|
180
|
+
params
|
181
|
+
end
|
182
|
+
|
183
|
+
def issue_transfer_session_token_request(options)
|
184
|
+
if options[:amount].nil?
|
185
|
+
raise ArgumentError, 'amount is required'
|
186
|
+
elsif options[:amount].to_i <= 0
|
187
|
+
raise ArgumentError, 'Invalid amount - $amount is less than zero'
|
188
|
+
end
|
189
|
+
|
190
|
+
params = { amount: options[:amount].to_s }
|
191
|
+
|
192
|
+
params[:landingUri] = options[:landing_uri] if !options[:landing_uri].nil?
|
193
|
+
|
194
|
+
if !options[:to_user_id].nil?
|
195
|
+
params[:toUserId] = options[:to_user_id]
|
196
|
+
elsif !options[:to_address].nil?
|
197
|
+
params[:toAddress] = options[:to_address]
|
198
|
+
else
|
199
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
200
|
+
end
|
201
|
+
params
|
202
|
+
end
|
203
|
+
|
204
|
+
def transfer_service_token_proxy_request(options)
|
205
|
+
if options[:owner_address].nil? || options[:owner_secret].nil? ||
|
206
|
+
options[:amount].nil?
|
207
|
+
raise ArgumentError,
|
208
|
+
'owner_address and owner_secret and amount are required'
|
209
|
+
end
|
210
|
+
|
211
|
+
params = {
|
212
|
+
ownerAddress: options[:owner_address],
|
213
|
+
ownerSecret: options[:owner_secret],
|
214
|
+
amount: options[:amount].to_s,
|
215
|
+
}
|
216
|
+
if !options[:to_user_id].nil?
|
217
|
+
params[:toUserId] = options[:to_user_id]
|
218
|
+
elsif !options[:to_address].nil?
|
219
|
+
params[:toAddress] = options[:to_address]
|
220
|
+
else
|
221
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
222
|
+
end
|
223
|
+
params
|
224
|
+
end
|
225
|
+
|
226
|
+
def transfer_fungible_token_proxy_request(options)
|
227
|
+
if options[:owner_address].nil? || options[:owner_secret].nil? ||
|
228
|
+
options[:amount].nil?
|
229
|
+
raise ArgumentError,
|
230
|
+
'owner_address and owner_secret and amount are required'
|
231
|
+
end
|
232
|
+
|
233
|
+
params = {
|
234
|
+
ownerAddress: options[:owner_address],
|
235
|
+
ownerSecret: options[:owner_secret],
|
236
|
+
amount: options[:amount].to_s,
|
237
|
+
}
|
238
|
+
if !options[:to_user_id].nil?
|
239
|
+
params[:toUserId] = options[:to_user_id]
|
240
|
+
elsif !options[:to_address].nil?
|
241
|
+
params[:toAddress] = options[:to_address]
|
242
|
+
else
|
243
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
244
|
+
end
|
245
|
+
params
|
246
|
+
end
|
247
|
+
|
248
|
+
def transfer_non_fungible_token_proxy_request(options)
|
249
|
+
if options[:owner_address].nil? || options[:owner_secret].nil?
|
250
|
+
raise ArgumentError, 'owner_address and owner_secret are required'
|
251
|
+
end
|
252
|
+
|
253
|
+
params = {
|
254
|
+
ownerAddress: options[:owner_address],
|
255
|
+
ownerSecret: options[:owner_secret],
|
256
|
+
}
|
257
|
+
if !options[:to_user_id].nil?
|
258
|
+
params[:toUserId] = options[:to_user_id]
|
259
|
+
elsif !options[:to_address].nil?
|
260
|
+
params[:toAddress] = options[:to_address]
|
261
|
+
else
|
262
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
263
|
+
end
|
264
|
+
params
|
265
|
+
end
|
266
|
+
|
267
|
+
def batch_transfer_non_fungible_token_proxy_request(options)
|
268
|
+
if options[:owner_address].nil? || options[:owner_secret].nil?
|
269
|
+
raise ArgumentError, 'owner_address and owner_secret are required'
|
270
|
+
end
|
271
|
+
|
272
|
+
params = {
|
273
|
+
ownerAddress: options[:owner_address],
|
274
|
+
ownerSecret: options[:owner_secret],
|
275
|
+
}
|
276
|
+
|
277
|
+
if !options[:transfer_list].nil? &&
|
278
|
+
options[:transfer_list].is_a?(Array) &&
|
279
|
+
!options[:transfer_list].empty?
|
280
|
+
params[:transferList] =
|
281
|
+
options[:transfer_list].map do |option|
|
282
|
+
{ tokenId: option[:token_id] || option[:tokenId] }
|
283
|
+
end
|
284
|
+
else
|
285
|
+
raise ArgumentError, 'transfer_list is inappropriate'
|
286
|
+
end
|
287
|
+
|
288
|
+
if !options[:to_user_id].nil?
|
289
|
+
params[:toUserId] = options[:to_user_id]
|
290
|
+
elsif !options[:to_address].nil?
|
291
|
+
params[:toAddress] = options[:to_address]
|
292
|
+
else
|
293
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
294
|
+
end
|
295
|
+
params
|
296
|
+
end
|
297
|
+
|
298
|
+
def transfer_base_coin_request(options)
|
299
|
+
if options[:wallet_secret].nil? || options[:amount].nil?
|
300
|
+
raise ArgumentError, 'amount and wallet_secret are required'
|
301
|
+
end
|
302
|
+
|
303
|
+
params = {
|
304
|
+
walletSecret: options[:wallet_secret],
|
305
|
+
amount: options[:amount].to_s,
|
306
|
+
}
|
307
|
+
if !options[:to_user_id].nil?
|
308
|
+
params[:toUserId] = options[:to_user_id]
|
309
|
+
elsif !options[:to_address].nil?
|
310
|
+
params[:toAddress] = options[:to_address]
|
311
|
+
else
|
312
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
313
|
+
end
|
314
|
+
params
|
315
|
+
end
|
316
|
+
|
317
|
+
def transfer_service_token_request(options)
|
318
|
+
if options[:wallet_secret].nil? || options[:amount].nil?
|
319
|
+
raise ArgumentError, 'amount and wallet_secret are required'
|
320
|
+
end
|
321
|
+
|
322
|
+
params = {
|
323
|
+
walletSecret: options[:wallet_secret],
|
324
|
+
amount: options[:amount].to_s,
|
325
|
+
}
|
326
|
+
|
327
|
+
if !options[:to_user_id].nil?
|
328
|
+
params[:toUserId] = options[:to_user_id]
|
329
|
+
elsif !options[:to_address].nil?
|
330
|
+
params[:toAddress] = options[:to_address]
|
331
|
+
else
|
332
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
333
|
+
end
|
334
|
+
params
|
335
|
+
end
|
336
|
+
|
337
|
+
def transfer_fungible_token_request(options)
|
338
|
+
if options[:wallet_secret].nil? || options[:amount].nil?
|
339
|
+
raise ArgumentError, 'amount and wallet_secret are required'
|
340
|
+
end
|
341
|
+
|
342
|
+
params = {
|
343
|
+
walletSecret: options[:wallet_secret],
|
344
|
+
amount: options[:amount].to_s,
|
345
|
+
}
|
346
|
+
|
347
|
+
if !options[:to_user_id].nil?
|
348
|
+
params[:toUserId] = options[:to_user_id]
|
349
|
+
elsif !options[:to_address].nil?
|
350
|
+
params[:toAddress] = options[:to_address]
|
351
|
+
else
|
352
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
353
|
+
end
|
354
|
+
params
|
355
|
+
end
|
356
|
+
|
357
|
+
def transfer_non_fungible_token_request(options)
|
358
|
+
if options[:wallet_secret].nil?
|
359
|
+
raise ArgumentError, 'wallet_secret is required'
|
360
|
+
end
|
361
|
+
|
362
|
+
params = { walletSecret: options[:wallet_secret] }
|
363
|
+
if !options[:to_user_id].nil?
|
364
|
+
params[:toUserId] = options[:to_user_id]
|
365
|
+
elsif !options[:to_address].nil?
|
366
|
+
params[:toAddress] = options[:to_address]
|
367
|
+
else
|
368
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
369
|
+
end
|
370
|
+
params
|
371
|
+
end
|
372
|
+
|
373
|
+
def batch_transfer_non_fungible_token_request(options)
|
374
|
+
if options[:wallet_secret].nil?
|
375
|
+
raise ArgumentError, 'wallet_secret are required'
|
376
|
+
end
|
377
|
+
|
378
|
+
params = { walletSecret: options[:wallet_secret] }
|
379
|
+
|
380
|
+
if !options[:transfer_list].nil? &&
|
381
|
+
options[:transfer_list].is_a?(Array) &&
|
382
|
+
!options[:transfer_list].empty?
|
383
|
+
params[:transferList] =
|
384
|
+
options[:transfer_list].map do |option|
|
385
|
+
{ tokenId: option[:token_id] || option[:tokenId] }
|
386
|
+
end
|
387
|
+
else
|
388
|
+
raise ArgumentError, 'transfer_list is inappropriate'
|
389
|
+
end
|
390
|
+
|
391
|
+
if !options[:to_user_id].nil?
|
392
|
+
params[:toUserId] = options[:to_user_id]
|
393
|
+
elsif !options[:to_address].nil?
|
394
|
+
params[:toAddress] = options[:to_address]
|
395
|
+
else
|
396
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
397
|
+
end
|
398
|
+
params
|
399
|
+
end
|
400
|
+
|
401
|
+
def fungible_token_create_update_request(options)
|
402
|
+
if options[:owner_address].nil? || options[:owner_secret].nil? ||
|
403
|
+
options[:name].nil?
|
404
|
+
raise ArgumentError,
|
405
|
+
'owner_address and owner_secret and name are required'
|
406
|
+
end
|
407
|
+
|
408
|
+
params = {
|
409
|
+
ownerAddress: options[:owner_address],
|
410
|
+
ownerSecret: options[:owner_secret],
|
411
|
+
name: options[:name],
|
412
|
+
}
|
413
|
+
|
414
|
+
params[:meta] = options[:meta] if !options[:meta].nil?
|
415
|
+
params
|
416
|
+
end
|
417
|
+
|
418
|
+
def non_fungible_token_create_update_request(options)
|
419
|
+
if options[:owner_address].nil? || options[:owner_secret].nil? ||
|
420
|
+
options[:name].nil?
|
421
|
+
raise ArgumentError,
|
422
|
+
'owner_address and owner_secret and name are required'
|
423
|
+
end
|
424
|
+
|
425
|
+
params = {
|
426
|
+
ownerAddress: options[:owner_address],
|
427
|
+
ownerSecret: options[:owner_secret],
|
428
|
+
name: options[:name],
|
429
|
+
}
|
430
|
+
|
431
|
+
params[:meta] = options[:meta] if !options[:meta].nil?
|
432
|
+
params
|
433
|
+
end
|
434
|
+
|
435
|
+
def non_fungible_token_attach_request(options)
|
436
|
+
if options[:parent_token_id].nil? ||
|
437
|
+
options[:service_wallet_address].nil? ||
|
438
|
+
options[:service_wallet_secret].nil?
|
439
|
+
raise ArgumentError,
|
440
|
+
'parent_token_id and service_wallet_address and service_wallet_secret are required'
|
441
|
+
end
|
442
|
+
|
443
|
+
params = {
|
444
|
+
parentTokenId: options[:parent_token_id],
|
445
|
+
serviceWalletAddress: options[:service_wallet_address],
|
446
|
+
serviceWalletSecret: options[:service_wallet_secret],
|
447
|
+
}
|
448
|
+
|
449
|
+
if !options[:token_holder_address].nil?
|
450
|
+
params[:tokenHolderAddress] = options[:token_holder_address]
|
451
|
+
elsif !options[:token_holder_user_id].nil?
|
452
|
+
params[:tokenHolderUserId] = options[:token_holder_user_id]
|
453
|
+
else
|
454
|
+
raise ArgumentError,
|
455
|
+
'token_holder_address or token_holder_user_id, one of them is required'
|
456
|
+
end
|
457
|
+
params
|
458
|
+
end
|
459
|
+
|
460
|
+
def non_fungible_token_detach_request(options)
|
461
|
+
if options[:service_wallet_address].nil? ||
|
462
|
+
options[:service_wallet_secret].nil?
|
463
|
+
raise ArgumentError,
|
464
|
+
'service_wallet_address and service_wallet_secret are required'
|
465
|
+
end
|
466
|
+
|
467
|
+
params = {
|
468
|
+
serviceWalletAddress: options[:service_wallet_address],
|
469
|
+
serviceWalletSecret: options[:service_wallet_secret],
|
470
|
+
}
|
471
|
+
|
472
|
+
if !options[:token_holder_address].nil?
|
473
|
+
params[:tokenHolderAddress] = options[:token_holder_address]
|
474
|
+
elsif !options[:token_holder_user_id].nil?
|
475
|
+
params[:tokenHolderUserId] = options[:token_holder_user_id]
|
476
|
+
else
|
477
|
+
raise ArgumentError,
|
478
|
+
'token_holder_address or token_holder_user_id, one of them is required'
|
479
|
+
end
|
480
|
+
params
|
481
|
+
end
|
482
|
+
|
483
|
+
def fungible_token_mint_request(options)
|
484
|
+
if options[:owner_address].nil? || options[:owner_secret].nil? ||
|
485
|
+
options[:amount].nil?
|
486
|
+
raise ArgumentError,
|
487
|
+
'owner_address and owner_secret and amount are required'
|
488
|
+
end
|
489
|
+
|
490
|
+
params = {
|
491
|
+
ownerAddress: options[:owner_address],
|
492
|
+
ownerSecret: options[:owner_secret],
|
493
|
+
amount: options[:amount].to_s,
|
494
|
+
}
|
495
|
+
|
496
|
+
if !options[:to_user_id].nil?
|
497
|
+
params[:toUserId] = options[:to_user_id]
|
498
|
+
elsif !options[:to_address].nil?
|
499
|
+
params[:toAddress] = options[:to_address]
|
500
|
+
else
|
501
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
502
|
+
end
|
503
|
+
params
|
504
|
+
end
|
505
|
+
|
506
|
+
def fungible_token_burn_request(options)
|
507
|
+
if options[:owner_address].nil? || options[:owner_secret].nil? ||
|
508
|
+
options[:amount].nil?
|
509
|
+
raise ArgumentError,
|
510
|
+
'owner_address and owner_secret and amount are required'
|
511
|
+
end
|
512
|
+
|
513
|
+
params = {
|
514
|
+
ownerAddress: options[:owner_address],
|
515
|
+
ownerSecret: options[:owner_secret],
|
516
|
+
amount: options[:amount].to_s,
|
517
|
+
}
|
518
|
+
|
519
|
+
if !options[:from_user_id].nil?
|
520
|
+
params[:fromUserId] = options[:from_user_id]
|
521
|
+
elsif !options[:from_address].nil?
|
522
|
+
params[:fromAddress] = options[:from_address]
|
523
|
+
else
|
524
|
+
raise ArgumentError, 'from_user_id or from_address is required'
|
525
|
+
end
|
526
|
+
params
|
527
|
+
end
|
528
|
+
|
529
|
+
def non_fungible_token_mint_request(options)
|
530
|
+
if options[:owner_address].nil? || options[:owner_secret].nil? ||
|
531
|
+
options[:name].nil?
|
532
|
+
raise ArgumentError,
|
533
|
+
'owner_address and owner_secret and name are required'
|
534
|
+
end
|
535
|
+
|
536
|
+
params = {
|
537
|
+
ownerAddress: options[:owner_address],
|
538
|
+
ownerSecret: options[:owner_secret],
|
539
|
+
name: options[:name],
|
540
|
+
}
|
541
|
+
|
542
|
+
params[:meta] = options[:meta] if !options[:meta].nil?
|
543
|
+
|
544
|
+
if !options[:to_user_id].nil?
|
545
|
+
params[:toUserId] = options[:to_user_id]
|
546
|
+
elsif !options[:to_address].nil?
|
547
|
+
params[:toAddress] = options[:to_address]
|
548
|
+
else
|
549
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
550
|
+
end
|
551
|
+
params
|
552
|
+
end
|
553
|
+
|
554
|
+
def non_fungible_token_multi_mint_request(options)
|
555
|
+
if options[:owner_address].nil? || options[:owner_secret].nil?
|
556
|
+
raise ArgumentError, 'owner_address and owner_secret are required'
|
557
|
+
end
|
558
|
+
|
559
|
+
params = {
|
560
|
+
ownerAddress: options[:owner_address],
|
561
|
+
ownerSecret: options[:owner_secret],
|
562
|
+
mintList: options[:mint_list],
|
563
|
+
}
|
564
|
+
|
565
|
+
if !options[:mint_list].nil? && options[:mint_list].is_a?(Array) &&
|
566
|
+
!options[:mint_list].empty?
|
567
|
+
params[:mintList] =
|
568
|
+
options[:mint_list].map do |option|
|
569
|
+
if option[:token_type].nil? || option[:name].nil?
|
570
|
+
raise ArgumentError, 'token_type and name are required'
|
571
|
+
end
|
572
|
+
|
573
|
+
inner_params = {
|
574
|
+
tokenType: option[:token_type],
|
575
|
+
name: option[:name],
|
576
|
+
}
|
577
|
+
|
578
|
+
inner_params[:meta] = option[:meta] if !option[:meta].nil?
|
579
|
+
|
580
|
+
inner_params
|
581
|
+
end
|
582
|
+
else
|
583
|
+
raise ArgumentError, 'mint_list is required and must be an Array'
|
584
|
+
end
|
585
|
+
|
586
|
+
if !options[:to_user_id].nil?
|
587
|
+
params[:toUserId] = options[:to_user_id]
|
588
|
+
elsif !options[:to_address].nil?
|
589
|
+
params[:toAddress] = options[:to_address]
|
590
|
+
else
|
591
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
592
|
+
end
|
593
|
+
|
594
|
+
params
|
595
|
+
end
|
596
|
+
|
597
|
+
def non_fungible_token_multi_mint_multi_recipients_request(options)
|
598
|
+
if options[:owner_address].nil? || options[:owner_secret].nil?
|
599
|
+
raise ArgumentError, 'owner_address and owner_secret are required'
|
600
|
+
end
|
601
|
+
|
602
|
+
params = {
|
603
|
+
ownerAddress: options[:owner_address],
|
604
|
+
ownerSecret: options[:owner_secret],
|
605
|
+
mintList: options[:mint_list],
|
606
|
+
}
|
607
|
+
|
608
|
+
if !options[:mint_list].nil? && options[:mint_list].is_a?(Array) &&
|
609
|
+
!options[:mint_list].empty?
|
610
|
+
params[:mintList] =
|
611
|
+
options[:mint_list].map do |option|
|
612
|
+
if option[:token_type].nil? || option[:name].nil?
|
613
|
+
raise ArgumentError, 'token_type and name are required'
|
614
|
+
end
|
615
|
+
|
616
|
+
inner_params = {
|
617
|
+
tokenType: option[:token_type],
|
618
|
+
name: option[:name],
|
619
|
+
}
|
620
|
+
|
621
|
+
inner_params[:meta] = option[:meta] if !option[:meta].nil?
|
622
|
+
|
623
|
+
if !option[:to_user_id].nil?
|
624
|
+
inner_params[:toUserId] = option[:to_user_id]
|
625
|
+
elsif !option[:to_address].nil?
|
626
|
+
inner_params[:toAddress] = option[:to_address]
|
627
|
+
else
|
628
|
+
raise ArgumentError, 'to_user_id or to_address is required'
|
629
|
+
end
|
630
|
+
|
631
|
+
inner_params
|
632
|
+
end
|
633
|
+
else
|
634
|
+
raise ArgumentError, 'mint_list is required and must be an Array'
|
635
|
+
end
|
636
|
+
|
637
|
+
params
|
638
|
+
end
|
639
|
+
|
640
|
+
def non_fungible_token_burn_request(options)
|
641
|
+
if options[:owner_address].nil? || options[:owner_secret].nil?
|
642
|
+
raise ArgumentError, 'owner_address and owner_secret are required'
|
643
|
+
end
|
644
|
+
|
645
|
+
params = {
|
646
|
+
ownerAddress: options[:owner_address],
|
647
|
+
ownerSecret: options[:owner_secret],
|
648
|
+
}
|
649
|
+
if !options[:from_user_id].nil?
|
650
|
+
params[:fromUserId] = options[:from_user_id]
|
651
|
+
elsif !options[:from_address].nil?
|
652
|
+
params[:fromAddress] = options[:from_address]
|
653
|
+
else
|
654
|
+
raise ArgumentError, 'from_user_id or from_address is required'
|
655
|
+
end
|
656
|
+
params
|
657
|
+
end
|
658
|
+
|
659
|
+
def fungible_token_media_resources_request(options)
|
660
|
+
params = { updateList: options[:update_list] }
|
661
|
+
|
662
|
+
if !options[:update_list].nil? && options[:update_list].is_a?(Array) &&
|
663
|
+
!options[:update_list].empty?
|
664
|
+
params[:updateList] =
|
665
|
+
options[:update_list].map do |option|
|
666
|
+
if option[:token_type].nil? && option[:tokenType].nil?
|
667
|
+
raise ArgumentError, 'token_type is required'
|
668
|
+
end
|
669
|
+
{ tokenType: option[:token_type] || option[:tokenType] }
|
670
|
+
end
|
671
|
+
else
|
672
|
+
raise ArgumentError, 'update_list is required and must be an Array'
|
673
|
+
end
|
674
|
+
|
675
|
+
params
|
676
|
+
end
|
677
|
+
|
678
|
+
def non_fungible_token_media_resources_request(options)
|
679
|
+
params = { updateList: options[:update_list] }
|
680
|
+
|
681
|
+
if !options[:update_list].nil? && options[:update_list].is_a?(Array) &&
|
682
|
+
!options[:update_list].empty?
|
683
|
+
params[:updateList] =
|
684
|
+
options[:update_list].map do |option|
|
685
|
+
if option[:token_type].nil? && option[:tokenType].nil?
|
686
|
+
raise ArgumentError, 'token_type is required'
|
687
|
+
elsif option[:token_index].nil? && option[:tokenIndex].nil?
|
688
|
+
raise ArgumentError, 'token_index is required'
|
689
|
+
end
|
690
|
+
|
691
|
+
{
|
692
|
+
tokenType: option[:token_type] || option[:tokenType],
|
693
|
+
tokenIndex: option[:token_index] || option[:tokenIndex],
|
694
|
+
}
|
695
|
+
end
|
696
|
+
else
|
697
|
+
raise ArgumentError, 'update_list is required and must be an Array'
|
698
|
+
end
|
699
|
+
|
700
|
+
params
|
701
|
+
end
|
702
|
+
|
703
|
+
def memo_request(options)
|
704
|
+
if options[:wallet_address].nil? || options[:wallet_secret].nil? ||
|
705
|
+
options[:memo].nil?
|
706
|
+
raise ArgumentError,
|
707
|
+
'wallet_address and wallet_secret and memo are required'
|
708
|
+
end
|
709
|
+
|
710
|
+
{
|
711
|
+
walletAddress: options[:wallet_address],
|
712
|
+
walletSecret: options[:wallet_secret],
|
713
|
+
memo: options[:memo],
|
714
|
+
}
|
715
|
+
end
|
716
|
+
end
|
717
|
+
end
|