lbd_sdk 0.1.2 → 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/.gitignore +2 -1
- data/.rubocop.yml +3 -0
- data/.vscode/settings.json +7 -1
- data/CHANGELOG.md +7 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +3 -1
- data/README.md +60 -36
- data/lib/lbd_sdk/client.rb +514 -151
- data/lib/lbd_sdk/hash_converter.rb +17 -0
- data/lib/lbd_sdk/http_client.rb +3 -7
- data/lib/lbd_sdk/request.rb +267 -190
- 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/package-lock.json +53 -0
- data/package.json +5 -0
- metadata +6 -2
data/lib/lbd_sdk/client.rb
CHANGED
@@ -18,9 +18,7 @@ module LbdSdk
|
|
18
18
|
DEFAULT_ENDPOINT = 'https://test-api.blockchain.line.me/'
|
19
19
|
|
20
20
|
def initialize(options = {})
|
21
|
-
options.each
|
22
|
-
instance_variable_set("@#{key}", value)
|
23
|
-
end
|
21
|
+
options.each { |key, value| instance_variable_set("@#{key}", value) }
|
24
22
|
yield(self) if block_given?
|
25
23
|
|
26
24
|
@endpoint ||= DEFAULT_ENDPOINT
|
@@ -35,7 +33,10 @@ module LbdSdk
|
|
35
33
|
end
|
36
34
|
|
37
35
|
def user_transactions(user_id, query_params = {})
|
38
|
-
get(
|
36
|
+
get(
|
37
|
+
"/v1/users/#{user_id}/transactions",
|
38
|
+
query_params: transaction_page_request(query_params),
|
39
|
+
)
|
39
40
|
end
|
40
41
|
|
41
42
|
def base_coin_balance_of_user(user_id)
|
@@ -43,7 +44,10 @@ module LbdSdk
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def service_token_balances_of_user(user_id, query_params = {})
|
46
|
-
get(
|
47
|
+
get(
|
48
|
+
"/v1/users/#{user_id}/service-tokens",
|
49
|
+
query_params: page_request(query_params),
|
50
|
+
)
|
47
51
|
end
|
48
52
|
|
49
53
|
def service_token_balance_of_user(user_id, contract_id)
|
@@ -51,47 +55,124 @@ module LbdSdk
|
|
51
55
|
end
|
52
56
|
|
53
57
|
def fungible_token_balances_of_user(user_id, contractId, query_params = {})
|
54
|
-
get(
|
58
|
+
get(
|
59
|
+
"/v1/users/#{user_id}/item-tokens/#{contractId}/fungibles",
|
60
|
+
query_params: page_request(query_params),
|
61
|
+
)
|
55
62
|
end
|
56
63
|
|
57
64
|
def fungible_token_balance_of_user(user_id, contractId, token_type)
|
58
|
-
get(
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
65
|
+
get(
|
66
|
+
"/v1/users/#{user_id}/item-tokens/#{contractId}/fungibles/#{token_type}",
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
def non_fungible_token_balances_of_user(
|
71
|
+
user_id,
|
72
|
+
contractId,
|
73
|
+
query_params = {}
|
74
|
+
)
|
75
|
+
get(
|
76
|
+
"/v1/users/#{user_id}/item-tokens/#{contractId}/non-fungibles",
|
77
|
+
query_params: page_request(query_params),
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
def non_fungible_token_balances_with_type_of_user(
|
82
|
+
user_id,
|
83
|
+
contractId,
|
84
|
+
query_params = {}
|
85
|
+
)
|
86
|
+
get(
|
87
|
+
"/v1/users/#{user_id}/item-tokens/#{contractId}/non-fungibles/with-type",
|
88
|
+
query_params: cursor_page_request(query_params),
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
92
|
+
def non_fungible_token_balances_by_type_of_user(
|
93
|
+
user_id,
|
94
|
+
contractId,
|
95
|
+
token_type,
|
96
|
+
query_params = {}
|
97
|
+
)
|
98
|
+
get(
|
99
|
+
"/v1/users/#{user_id}/item-tokens/#{contractId}/non-fungibles/#{token_type}",
|
100
|
+
query_params: page_request(query_params),
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
def non_fungible_token_balance_of_user(
|
105
|
+
user_id,
|
106
|
+
contractId,
|
107
|
+
token_type,
|
108
|
+
token_index
|
109
|
+
)
|
110
|
+
get(
|
111
|
+
"/v1/users/#{user_id}/item-tokens/#{contractId}/non-fungibles/#{token_type}/#{token_index}",
|
112
|
+
)
|
75
113
|
end
|
76
114
|
|
77
115
|
def retrieve_session_token_status(request_session_token)
|
78
116
|
get("/v1/user-requests/#{request_session_token}")
|
79
117
|
end
|
80
118
|
|
81
|
-
def issue_session_token_for_base_coin_transfer(
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
post(
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
119
|
+
def issue_session_token_for_base_coin_transfer(
|
120
|
+
user_id,
|
121
|
+
request_type,
|
122
|
+
payload = {}
|
123
|
+
)
|
124
|
+
post(
|
125
|
+
"/v1/users/#{user_id}/base-coin/request-transfer",
|
126
|
+
query_params: {
|
127
|
+
requestType: request_type,
|
128
|
+
},
|
129
|
+
payload: issue_transfer_session_token_request(payload),
|
130
|
+
)
|
131
|
+
end
|
132
|
+
|
133
|
+
def issue_session_token_for_service_token_transfer(
|
134
|
+
user_id,
|
135
|
+
contract_id,
|
136
|
+
request_type,
|
137
|
+
payload = {}
|
138
|
+
)
|
139
|
+
post(
|
140
|
+
"/v1/users/#{user_id}/service-tokens/#{contract_id}/request-transfer",
|
141
|
+
query_params: {
|
142
|
+
requestType: request_type,
|
143
|
+
},
|
144
|
+
payload: issue_transfer_session_token_request(payload),
|
145
|
+
)
|
146
|
+
end
|
147
|
+
|
148
|
+
def issue_service_token_proxy_request(
|
149
|
+
user_id,
|
150
|
+
contract_id,
|
151
|
+
request_type,
|
152
|
+
payload = {}
|
153
|
+
)
|
154
|
+
post(
|
155
|
+
"/v1/users/#{user_id}/service-tokens/#{contract_id}/request-proxy",
|
156
|
+
query_params: {
|
157
|
+
requestType: request_type,
|
158
|
+
},
|
159
|
+
payload: user_proxy_request(payload),
|
160
|
+
)
|
161
|
+
end
|
162
|
+
|
163
|
+
def issue_item_token_proxy_request(
|
164
|
+
user_id,
|
165
|
+
contract_id,
|
166
|
+
request_type,
|
167
|
+
payload = {}
|
168
|
+
)
|
169
|
+
post(
|
170
|
+
"/v1/users/#{user_id}/item-tokens/#{contract_id}/request-proxy",
|
171
|
+
query_params: {
|
172
|
+
requestType: request_type,
|
173
|
+
},
|
174
|
+
payload: user_proxy_request(payload),
|
175
|
+
)
|
95
176
|
end
|
96
177
|
|
97
178
|
def commit_proxy_request(request_session_token)
|
@@ -99,19 +180,46 @@ module LbdSdk
|
|
99
180
|
end
|
100
181
|
|
101
182
|
def transfer_service_token_of_user(user_id, contract_id, payload = {})
|
102
|
-
post(
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
post(
|
183
|
+
post(
|
184
|
+
"/v1/users/#{user_id}/service-tokens/#{contract_id}/transfer",
|
185
|
+
payload: transfer_service_token_proxy_request(payload),
|
186
|
+
)
|
187
|
+
end
|
188
|
+
|
189
|
+
def transfer_fungible_token_of_user(
|
190
|
+
user_id,
|
191
|
+
contract_id,
|
192
|
+
token_type,
|
193
|
+
payload = {}
|
194
|
+
)
|
195
|
+
post(
|
196
|
+
"/v1/users/#{user_id}/item-tokens/#{contract_id}/fungibles/#{token_type}/transfer",
|
197
|
+
payload: transfer_fungible_token_proxy_request(payload),
|
198
|
+
)
|
199
|
+
end
|
200
|
+
|
201
|
+
def transfer_non_fungible_token_of_user(
|
202
|
+
user_id,
|
203
|
+
contract_id,
|
204
|
+
token_type,
|
205
|
+
token_index,
|
206
|
+
payload = {}
|
207
|
+
)
|
208
|
+
post(
|
209
|
+
"/v1/users/#{user_id}/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}/transfer",
|
210
|
+
payload: transfer_non_fungible_token_proxy_request(payload),
|
211
|
+
)
|
212
|
+
end
|
213
|
+
|
214
|
+
def batch_transfer_non_fungible_token_of_user(
|
215
|
+
user_id,
|
216
|
+
contract_id,
|
217
|
+
payload = {}
|
218
|
+
)
|
219
|
+
post(
|
220
|
+
"/v1/users/#{user_id}/item-tokens/#{contract_id}/non-fungibles/batch-transfer",
|
221
|
+
payload: batch_transfer_non_fungible_token_proxy_request(payload),
|
222
|
+
)
|
115
223
|
end
|
116
224
|
|
117
225
|
def service_token_proxy_status_of_user(user_id, contract_id)
|
@@ -131,7 +239,10 @@ module LbdSdk
|
|
131
239
|
end
|
132
240
|
|
133
241
|
def wallet_transactions(wallet_address, query_params = {})
|
134
|
-
get(
|
242
|
+
get(
|
243
|
+
"/v1/wallets/#{wallet_address}/transactions",
|
244
|
+
query_params: transaction_page_request(query_params),
|
245
|
+
)
|
135
246
|
end
|
136
247
|
|
137
248
|
def base_coin_balance_of_wallet(wallet_address)
|
@@ -139,51 +250,123 @@ module LbdSdk
|
|
139
250
|
end
|
140
251
|
|
141
252
|
def service_token_balances_of_wallet(wallet_address, query_params = {})
|
142
|
-
get(
|
253
|
+
get(
|
254
|
+
"/v1/wallets/#{wallet_address}/service-tokens",
|
255
|
+
query_params: page_request(query_params),
|
256
|
+
)
|
143
257
|
end
|
144
258
|
|
145
259
|
def service_token_balance_of_wallet(wallet_address, contract_id)
|
146
260
|
get("/v1/wallets/#{wallet_address}/service-tokens/#{contract_id}")
|
147
261
|
end
|
148
262
|
|
149
|
-
def fungible_token_balances_of_wallet(
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
get(
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
263
|
+
def fungible_token_balances_of_wallet(
|
264
|
+
wallet_address,
|
265
|
+
contract_id,
|
266
|
+
query_params = {}
|
267
|
+
)
|
268
|
+
get(
|
269
|
+
"/v1/wallets/#{wallet_address}/item-tokens/#{contract_id}/fungibles",
|
270
|
+
query_params: page_request(query_params),
|
271
|
+
)
|
272
|
+
end
|
273
|
+
|
274
|
+
def fungible_token_balance_of_wallet(
|
275
|
+
wallet_address,
|
276
|
+
contract_id,
|
277
|
+
token_type
|
278
|
+
)
|
279
|
+
get(
|
280
|
+
"/v1/wallets/#{wallet_address}/item-tokens/#{contract_id}/fungibles/#{token_type}",
|
281
|
+
)
|
282
|
+
end
|
283
|
+
|
284
|
+
def non_fungible_token_balances_of_wallet(
|
285
|
+
wallet_address,
|
286
|
+
contract_id,
|
287
|
+
query_params = {}
|
288
|
+
)
|
289
|
+
get(
|
290
|
+
"/v1/wallets/#{wallet_address}/item-tokens/#{contract_id}/non-fungibles",
|
291
|
+
query_params: page_request(query_params),
|
292
|
+
)
|
293
|
+
end
|
294
|
+
|
295
|
+
def non_fungible_token_balances_by_type_of_wallet(
|
296
|
+
wallet_address,
|
297
|
+
contract_id,
|
298
|
+
token_type,
|
299
|
+
query_params = {}
|
300
|
+
)
|
301
|
+
get(
|
302
|
+
"/v1/wallets/#{wallet_address}/item-tokens/#{contract_id}/non-fungibles/#{token_type}",
|
303
|
+
query_params: page_request(query_params),
|
304
|
+
)
|
305
|
+
end
|
306
|
+
|
307
|
+
def non_fungible_token_balance_of_wallet(
|
308
|
+
wallet_address,
|
309
|
+
contract_id,
|
310
|
+
token_type,
|
311
|
+
token_index
|
312
|
+
)
|
313
|
+
get(
|
314
|
+
"/v1/wallets/#{wallet_address}/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}",
|
315
|
+
)
|
167
316
|
end
|
168
317
|
|
169
318
|
def transfer_base_coin_of_wallet(wallet_address, payload = {})
|
170
|
-
post(
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
319
|
+
post(
|
320
|
+
"/v1/wallets/#{wallet_address}/base-coin/transfer",
|
321
|
+
payload: transfer_base_coin_request(payload),
|
322
|
+
)
|
323
|
+
end
|
324
|
+
|
325
|
+
def transfer_service_token_of_wallet(
|
326
|
+
wallet_address,
|
327
|
+
contract_id,
|
328
|
+
payload = {}
|
329
|
+
)
|
330
|
+
post(
|
331
|
+
"/v1/wallets/#{wallet_address}/service-tokens/#{contract_id}/transfer",
|
332
|
+
payload: transfer_service_token_request(payload),
|
333
|
+
)
|
334
|
+
end
|
335
|
+
|
336
|
+
def transfer_fungible_token_of_wallet(
|
337
|
+
wallet_address,
|
338
|
+
contract_id,
|
339
|
+
token_type,
|
340
|
+
payload = {}
|
341
|
+
)
|
342
|
+
post(
|
343
|
+
"/v1/wallets/#{wallet_address}/item-tokens/#{contract_id}/fungibles/#{token_type}/transfer",
|
344
|
+
payload: transfer_fungible_token_request(payload),
|
345
|
+
)
|
346
|
+
end
|
347
|
+
|
348
|
+
def transfer_non_fungible_token_of_wallet(
|
349
|
+
wallet_address,
|
350
|
+
contract_id,
|
351
|
+
token_type,
|
352
|
+
token_index,
|
353
|
+
payload = {}
|
354
|
+
)
|
355
|
+
post(
|
356
|
+
"/v1/wallets/#{wallet_address}/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}/transfer",
|
357
|
+
payload: transfer_non_fungible_token_request(payload),
|
358
|
+
)
|
359
|
+
end
|
360
|
+
|
361
|
+
def batch_transfer_non_fungible_token_of_wallet(
|
362
|
+
wallet_address,
|
363
|
+
contract_id,
|
364
|
+
payload = {}
|
365
|
+
)
|
366
|
+
post(
|
367
|
+
"/v1/wallets/#{wallet_address}/item-tokens/#{contract_id}/non-fungibles/batch-transfer",
|
368
|
+
payload: batch_transfer_non_fungible_token_request(payload),
|
369
|
+
)
|
187
370
|
end
|
188
371
|
|
189
372
|
def service_detail(service_id)
|
@@ -198,20 +381,57 @@ module LbdSdk
|
|
198
381
|
get("/v1/service-tokens/#{contract_id}")
|
199
382
|
end
|
200
383
|
|
384
|
+
def issue_service_token(payload)
|
385
|
+
post('/v1/service-tokens', payload: issue_service_token_request(payload))
|
386
|
+
end
|
387
|
+
|
388
|
+
def issued_service_token_by_tx_hash(tx_hash, query_params = {})
|
389
|
+
get(
|
390
|
+
"/v1/service-tokens/by-txHash/#{tx_hash}",
|
391
|
+
query_params: issued_service_token_by_tx_hash_request(query_params),
|
392
|
+
)
|
393
|
+
end
|
394
|
+
|
201
395
|
def update_service_token(contract_id, payload = {})
|
202
|
-
put(
|
396
|
+
put(
|
397
|
+
"/v1/service-tokens/#{contract_id}",
|
398
|
+
payload: update_service_token_request(payload),
|
399
|
+
)
|
203
400
|
end
|
204
401
|
|
205
402
|
def mint_service_token(contract_id, payload = {})
|
206
|
-
post(
|
403
|
+
post(
|
404
|
+
"/v1/service-tokens/#{contract_id}/mint",
|
405
|
+
payload: mint_service_token_request(payload),
|
406
|
+
)
|
207
407
|
end
|
208
408
|
|
209
409
|
def burn_from_service_token(contract_id, payload = {})
|
210
|
-
post(
|
410
|
+
post(
|
411
|
+
"/v1/service-tokens/#{contract_id}/burn-from",
|
412
|
+
payload: burn_from_service_token_request(payload),
|
413
|
+
)
|
211
414
|
end
|
212
415
|
|
213
416
|
def service_token_holders(contract_id, query_params = {})
|
214
|
-
get(
|
417
|
+
get(
|
418
|
+
"/v1/service-tokens/#{contract_id}/holders",
|
419
|
+
query_params: page_request(query_params),
|
420
|
+
)
|
421
|
+
end
|
422
|
+
|
423
|
+
def create_item_token_contract(payload)
|
424
|
+
post(
|
425
|
+
'/v1/item-tokens',
|
426
|
+
payload: create_item_token_contract_request(payload),
|
427
|
+
)
|
428
|
+
end
|
429
|
+
|
430
|
+
def created_item_token_contract(query_params = {})
|
431
|
+
get(
|
432
|
+
'/v1/item-tokens',
|
433
|
+
query_params: created_item_token_contract_request(query_params),
|
434
|
+
)
|
215
435
|
end
|
216
436
|
|
217
437
|
def item_token(contract_id)
|
@@ -219,19 +439,31 @@ module LbdSdk
|
|
219
439
|
end
|
220
440
|
|
221
441
|
def fungible_tokens(contract_id, query_params = {})
|
222
|
-
get(
|
442
|
+
get(
|
443
|
+
"/v1/item-tokens/#{contract_id}/fungibles",
|
444
|
+
query_params: page_request(query_params),
|
445
|
+
)
|
223
446
|
end
|
224
447
|
|
225
448
|
def create_fungible_token(contract_id, payload = {})
|
226
|
-
post(
|
449
|
+
post(
|
450
|
+
"/v1/item-tokens/#{contract_id}/fungibles",
|
451
|
+
payload: fungible_token_create_update_request(payload),
|
452
|
+
)
|
227
453
|
end
|
228
454
|
|
229
455
|
def mint_fungible_token(contract_id, token_type, payload = {})
|
230
|
-
post(
|
456
|
+
post(
|
457
|
+
"/v1/item-tokens/#{contract_id}/fungibles/#{token_type}/mint",
|
458
|
+
payload: fungible_token_mint_request(payload),
|
459
|
+
)
|
231
460
|
end
|
232
461
|
|
233
462
|
def burn_fungible_token(contract_id, token_type, payload = {})
|
234
|
-
post(
|
463
|
+
post(
|
464
|
+
"/v1/item-tokens/#{contract_id}/fungibles/#{token_type}/burn",
|
465
|
+
payload: fungible_token_burn_request(payload),
|
466
|
+
)
|
235
467
|
end
|
236
468
|
|
237
469
|
def fungible_token(contract_id, token_type)
|
@@ -239,80 +471,166 @@ module LbdSdk
|
|
239
471
|
end
|
240
472
|
|
241
473
|
def update_fungible_token(contract_id, token_type, payload = {})
|
242
|
-
put(
|
474
|
+
put(
|
475
|
+
"/v1/item-tokens/#{contract_id}/fungibles/#{token_type}",
|
476
|
+
payload: fungible_token_create_update_request(payload),
|
477
|
+
)
|
243
478
|
end
|
244
479
|
|
245
480
|
def fungible_token_holders(contract_id, token_type, query_params = {})
|
246
|
-
get(
|
481
|
+
get(
|
482
|
+
"/v1/item-tokens/#{contract_id}/fungibles/#{token_type}/holders",
|
483
|
+
query_params: page_request(query_params),
|
484
|
+
)
|
247
485
|
end
|
248
486
|
|
249
487
|
def non_fungible_tokens(contract_id, query_params = {})
|
250
|
-
get(
|
488
|
+
get(
|
489
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles",
|
490
|
+
query_params: page_request(query_params),
|
491
|
+
)
|
251
492
|
end
|
252
493
|
|
253
494
|
def non_fungible_token_type(contract_id, token_type, query_params = {})
|
254
|
-
get(
|
495
|
+
get(
|
496
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}",
|
497
|
+
query_params: page_request(query_params),
|
498
|
+
)
|
255
499
|
end
|
256
500
|
|
257
501
|
def create_non_fungible_token(contract_id, payload = {})
|
258
|
-
post(
|
502
|
+
post(
|
503
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles",
|
504
|
+
payload: non_fungible_token_create_update_request(payload),
|
505
|
+
)
|
259
506
|
end
|
260
507
|
|
261
508
|
def mint_non_fungible_token(contract_id, token_type, payload = {})
|
262
|
-
post(
|
509
|
+
post(
|
510
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/mint",
|
511
|
+
payload: non_fungible_token_mint_request(payload),
|
512
|
+
)
|
263
513
|
end
|
264
514
|
|
265
515
|
def multi_mint_non_fungible_token(contract_id, payload = {})
|
266
|
-
post(
|
516
|
+
post(
|
517
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/multi-mint",
|
518
|
+
payload: non_fungible_token_multi_mint_request(payload),
|
519
|
+
)
|
267
520
|
end
|
268
521
|
|
269
|
-
def multi_mint_non_fungible_token_for_multi_recipients(
|
522
|
+
def multi_mint_non_fungible_token_for_multi_recipients(
|
523
|
+
contract_id,
|
524
|
+
payload = {}
|
525
|
+
)
|
270
526
|
warn('Not Implemented yet')
|
271
|
-
post(
|
527
|
+
post(
|
528
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/multi-recipients/multi-mint",
|
529
|
+
payload:
|
530
|
+
non_fungible_token_multi_mint_multi_recipients_request(payload),
|
531
|
+
)
|
272
532
|
end
|
273
533
|
|
274
|
-
def burn_non_fungible_token(
|
275
|
-
|
534
|
+
def burn_non_fungible_token(
|
535
|
+
contract_id,
|
536
|
+
token_type,
|
537
|
+
token_index,
|
538
|
+
payload = {}
|
539
|
+
)
|
540
|
+
post(
|
541
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}/burn",
|
542
|
+
payload: non_fungible_token_burn_request(payload),
|
543
|
+
)
|
276
544
|
end
|
277
545
|
|
278
546
|
def non_fungible_token(contract_id, token_type, token_index)
|
279
|
-
get(
|
547
|
+
get(
|
548
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}",
|
549
|
+
)
|
280
550
|
end
|
281
551
|
|
282
552
|
def update_non_fungible_token_type(contract_id, token_type, payload = {})
|
283
|
-
put(
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
553
|
+
put(
|
554
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}",
|
555
|
+
payload: non_fungible_token_create_update_request(payload),
|
556
|
+
)
|
557
|
+
end
|
558
|
+
|
559
|
+
def update_non_fungible_token(
|
560
|
+
contract_id,
|
561
|
+
token_type,
|
562
|
+
token_index,
|
563
|
+
payload = {}
|
564
|
+
)
|
565
|
+
put(
|
566
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}",
|
567
|
+
payload: non_fungible_token_create_update_request(payload),
|
568
|
+
)
|
569
|
+
end
|
570
|
+
|
571
|
+
def non_fungible_token_type_holders(
|
572
|
+
contract_id,
|
573
|
+
token_type,
|
574
|
+
query_params = {}
|
575
|
+
)
|
576
|
+
get(
|
577
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/holders",
|
578
|
+
query_params: page_request(query_params),
|
579
|
+
)
|
292
580
|
end
|
293
581
|
|
294
582
|
def non_fungible_token_holder(contract_id, token_type, token_index)
|
295
|
-
get(
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
583
|
+
get(
|
584
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}/holder",
|
585
|
+
)
|
586
|
+
end
|
587
|
+
|
588
|
+
def attach_non_fungible_token(
|
589
|
+
contract_id,
|
590
|
+
token_type,
|
591
|
+
token_index,
|
592
|
+
payload = {}
|
593
|
+
)
|
594
|
+
post(
|
595
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}/parent",
|
596
|
+
payload: non_fungible_token_attach_request(payload),
|
597
|
+
)
|
598
|
+
end
|
599
|
+
|
600
|
+
def detach_non_fungible_token(
|
601
|
+
contract_id,
|
602
|
+
token_type,
|
603
|
+
token_index,
|
604
|
+
payload = {}
|
605
|
+
)
|
606
|
+
delete(
|
607
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}/parent",
|
608
|
+
payload: non_fungible_token_detach_request(payload),
|
609
|
+
)
|
610
|
+
end
|
611
|
+
|
612
|
+
def children_of_non_fungible_token(
|
613
|
+
contract_id,
|
614
|
+
token_type,
|
615
|
+
token_index,
|
616
|
+
query_params = {}
|
617
|
+
)
|
618
|
+
get(
|
619
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}/children",
|
620
|
+
query_params: page_request(query_params),
|
621
|
+
)
|
308
622
|
end
|
309
623
|
|
310
624
|
def parent_of_non_fungible_token(contract_id, token_type, token_index)
|
311
|
-
get(
|
625
|
+
get(
|
626
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}/parent",
|
627
|
+
)
|
312
628
|
end
|
313
629
|
|
314
630
|
def root_of_non_fungible_token(contract_id, token_type, token_index)
|
315
|
-
get(
|
631
|
+
get(
|
632
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}/root",
|
633
|
+
)
|
316
634
|
end
|
317
635
|
|
318
636
|
def fungible_token_media_resources_update_status(contract_id, request_id)
|
@@ -320,15 +638,26 @@ module LbdSdk
|
|
320
638
|
end
|
321
639
|
|
322
640
|
def update_fungible_token_media_resources(contract_id, token_types)
|
323
|
-
put(
|
641
|
+
put(
|
642
|
+
"/v1/item-tokens/#{contract_id}/fungibles/icon",
|
643
|
+
payload: fungible_token_media_resources_request(token_types),
|
644
|
+
)
|
324
645
|
end
|
325
646
|
|
326
|
-
def non_fungible_token_media_resources_update_status(
|
327
|
-
|
647
|
+
def non_fungible_token_media_resources_update_status(
|
648
|
+
contract_id,
|
649
|
+
request_id
|
650
|
+
)
|
651
|
+
get(
|
652
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/icon/#{request_id}/status",
|
653
|
+
)
|
328
654
|
end
|
329
655
|
|
330
656
|
def update_non_fungible_token_media_resources(contract_id, token_ids)
|
331
|
-
put(
|
657
|
+
put(
|
658
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/icon",
|
659
|
+
payload: non_fungible_token_media_resources_request(token_ids),
|
660
|
+
)
|
332
661
|
end
|
333
662
|
|
334
663
|
def memos(tx_hash)
|
@@ -348,7 +677,12 @@ module LbdSdk
|
|
348
677
|
end
|
349
678
|
|
350
679
|
def get(endpoint_path, query_params: {})
|
351
|
-
headers =
|
680
|
+
headers =
|
681
|
+
request_headers(
|
682
|
+
endpoint_path: endpoint_path,
|
683
|
+
method: 'GET',
|
684
|
+
query_params: query_params,
|
685
|
+
)
|
352
686
|
query_params = RequestParamFlattener.new.flatten(query_params)
|
353
687
|
if query_params.empty?
|
354
688
|
httpclient.get("#{@endpoint}#{endpoint_path}", headers)
|
@@ -358,23 +692,51 @@ module LbdSdk
|
|
358
692
|
end
|
359
693
|
|
360
694
|
def post(endpoint_path, query_params: {}, payload: {})
|
361
|
-
headers =
|
695
|
+
headers =
|
696
|
+
request_headers(
|
697
|
+
endpoint_path: endpoint_path,
|
698
|
+
method: 'POST',
|
699
|
+
query_params: query_params,
|
700
|
+
payload: payload,
|
701
|
+
)
|
362
702
|
query_params = RequestParamFlattener.new.flatten(query_params)
|
363
703
|
if query_params.empty?
|
364
|
-
httpclient.post(
|
704
|
+
httpclient.post(
|
705
|
+
"#{@endpoint}#{endpoint_path}",
|
706
|
+
payload.to_json,
|
707
|
+
headers,
|
708
|
+
)
|
365
709
|
else
|
366
|
-
httpclient.post(
|
710
|
+
httpclient.post(
|
711
|
+
"#{@endpoint}#{endpoint_path}?#{query_params}",
|
712
|
+
payload.to_json,
|
713
|
+
headers,
|
714
|
+
)
|
367
715
|
end
|
368
716
|
end
|
369
717
|
|
370
718
|
def put(endpoint_path, payload: {})
|
371
|
-
headers =
|
719
|
+
headers =
|
720
|
+
request_headers(
|
721
|
+
endpoint_path: endpoint_path,
|
722
|
+
method: 'PUT',
|
723
|
+
payload: payload,
|
724
|
+
)
|
372
725
|
httpclient.put("#{@endpoint}#{endpoint_path}", payload.to_json, headers)
|
373
726
|
end
|
374
727
|
|
375
728
|
def delete(endpoint_path, payload: {})
|
376
|
-
headers =
|
377
|
-
|
729
|
+
headers =
|
730
|
+
request_headers(
|
731
|
+
endpoint_path: endpoint_path,
|
732
|
+
method: 'DELETE',
|
733
|
+
payload: payload,
|
734
|
+
)
|
735
|
+
httpclient.delete(
|
736
|
+
"#{@endpoint}#{endpoint_path}",
|
737
|
+
payload.to_json,
|
738
|
+
headers,
|
739
|
+
)
|
378
740
|
end
|
379
741
|
|
380
742
|
def request_headers(endpoint_path:, method:, query_params: {}, payload: {})
|
@@ -386,15 +748,16 @@ module LbdSdk
|
|
386
748
|
'Content-Type': 'application/json',
|
387
749
|
Nonce: "#{nonce}",
|
388
750
|
Timestamp: "#{timestamp}",
|
389
|
-
Signature:
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
751
|
+
Signature:
|
752
|
+
SignatureGenerator.new.generate(
|
753
|
+
secret: @api_secret_key,
|
754
|
+
method: method,
|
755
|
+
endpoint_path: endpoint_path,
|
756
|
+
timestamp: timestamp,
|
757
|
+
nonce: nonce,
|
758
|
+
query_params: query_params,
|
759
|
+
body: payload,
|
760
|
+
),
|
398
761
|
}
|
399
762
|
end
|
400
763
|
end
|