lbd_sdk 0.1.1 → 0.1.4
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 -0
- data/.rubocop.yml +3 -0
- data/.vscode/settings.json +7 -1
- data/CHANGELOG.md +31 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +3 -1
- data/README.md +69 -40
- data/lib/lbd_sdk/client.rb +547 -146
- data/lib/lbd_sdk/hash_converter.rb +17 -0
- data/lib/lbd_sdk/http_client.rb +3 -7
- data/lib/lbd_sdk/request.rb +275 -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,43 +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
|
-
|
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
|
+
)
|
71
113
|
end
|
72
114
|
|
73
115
|
def retrieve_session_token_status(request_session_token)
|
74
116
|
get("/v1/user-requests/#{request_session_token}")
|
75
117
|
end
|
76
118
|
|
77
|
-
def issue_session_token_for_base_coin_transfer(
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
post(
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
+
)
|
91
176
|
end
|
92
177
|
|
93
178
|
def commit_proxy_request(request_session_token)
|
@@ -95,19 +180,46 @@ module LbdSdk
|
|
95
180
|
end
|
96
181
|
|
97
182
|
def transfer_service_token_of_user(user_id, contract_id, payload = {})
|
98
|
-
post(
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
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
|
+
)
|
111
223
|
end
|
112
224
|
|
113
225
|
def service_token_proxy_status_of_user(user_id, contract_id)
|
@@ -127,7 +239,10 @@ module LbdSdk
|
|
127
239
|
end
|
128
240
|
|
129
241
|
def wallet_transactions(wallet_address, query_params = {})
|
130
|
-
get(
|
242
|
+
get(
|
243
|
+
"/v1/wallets/#{wallet_address}/transactions",
|
244
|
+
query_params: transaction_page_request(query_params),
|
245
|
+
)
|
131
246
|
end
|
132
247
|
|
133
248
|
def base_coin_balance_of_wallet(wallet_address)
|
@@ -135,51 +250,123 @@ module LbdSdk
|
|
135
250
|
end
|
136
251
|
|
137
252
|
def service_token_balances_of_wallet(wallet_address, query_params = {})
|
138
|
-
get(
|
253
|
+
get(
|
254
|
+
"/v1/wallets/#{wallet_address}/service-tokens",
|
255
|
+
query_params: page_request(query_params),
|
256
|
+
)
|
139
257
|
end
|
140
258
|
|
141
259
|
def service_token_balance_of_wallet(wallet_address, contract_id)
|
142
260
|
get("/v1/wallets/#{wallet_address}/service-tokens/#{contract_id}")
|
143
261
|
end
|
144
262
|
|
145
|
-
def fungible_token_balances_of_wallet(
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
get(
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
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
|
+
)
|
163
316
|
end
|
164
317
|
|
165
318
|
def transfer_base_coin_of_wallet(wallet_address, payload = {})
|
166
|
-
post(
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
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
|
+
)
|
183
370
|
end
|
184
371
|
|
185
372
|
def service_detail(service_id)
|
@@ -194,20 +381,57 @@ module LbdSdk
|
|
194
381
|
get("/v1/service-tokens/#{contract_id}")
|
195
382
|
end
|
196
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
|
+
|
197
395
|
def update_service_token(contract_id, payload = {})
|
198
|
-
put(
|
396
|
+
put(
|
397
|
+
"/v1/service-tokens/#{contract_id}",
|
398
|
+
payload: update_service_token_request(payload),
|
399
|
+
)
|
199
400
|
end
|
200
401
|
|
201
402
|
def mint_service_token(contract_id, payload = {})
|
202
|
-
post(
|
403
|
+
post(
|
404
|
+
"/v1/service-tokens/#{contract_id}/mint",
|
405
|
+
payload: mint_service_token_request(payload),
|
406
|
+
)
|
203
407
|
end
|
204
408
|
|
205
409
|
def burn_from_service_token(contract_id, payload = {})
|
206
|
-
post(
|
410
|
+
post(
|
411
|
+
"/v1/service-tokens/#{contract_id}/burn-from",
|
412
|
+
payload: burn_from_service_token_request(payload),
|
413
|
+
)
|
207
414
|
end
|
208
415
|
|
209
416
|
def service_token_holders(contract_id, query_params = {})
|
210
|
-
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
|
+
)
|
211
435
|
end
|
212
436
|
|
213
437
|
def item_token(contract_id)
|
@@ -215,19 +439,31 @@ module LbdSdk
|
|
215
439
|
end
|
216
440
|
|
217
441
|
def fungible_tokens(contract_id, query_params = {})
|
218
|
-
get(
|
442
|
+
get(
|
443
|
+
"/v1/item-tokens/#{contract_id}/fungibles",
|
444
|
+
query_params: page_request(query_params),
|
445
|
+
)
|
219
446
|
end
|
220
447
|
|
221
448
|
def create_fungible_token(contract_id, payload = {})
|
222
|
-
post(
|
449
|
+
post(
|
450
|
+
"/v1/item-tokens/#{contract_id}/fungibles",
|
451
|
+
payload: fungible_token_create_update_request(payload),
|
452
|
+
)
|
223
453
|
end
|
224
454
|
|
225
455
|
def mint_fungible_token(contract_id, token_type, payload = {})
|
226
|
-
post(
|
456
|
+
post(
|
457
|
+
"/v1/item-tokens/#{contract_id}/fungibles/#{token_type}/mint",
|
458
|
+
payload: fungible_token_mint_request(payload),
|
459
|
+
)
|
227
460
|
end
|
228
461
|
|
229
462
|
def burn_fungible_token(contract_id, token_type, payload = {})
|
230
|
-
post(
|
463
|
+
post(
|
464
|
+
"/v1/item-tokens/#{contract_id}/fungibles/#{token_type}/burn",
|
465
|
+
payload: fungible_token_burn_request(payload),
|
466
|
+
)
|
231
467
|
end
|
232
468
|
|
233
469
|
def fungible_token(contract_id, token_type)
|
@@ -235,96 +471,227 @@ module LbdSdk
|
|
235
471
|
end
|
236
472
|
|
237
473
|
def update_fungible_token(contract_id, token_type, payload = {})
|
238
|
-
put(
|
474
|
+
put(
|
475
|
+
"/v1/item-tokens/#{contract_id}/fungibles/#{token_type}",
|
476
|
+
payload: fungible_token_create_update_request(payload),
|
477
|
+
)
|
239
478
|
end
|
240
479
|
|
241
480
|
def fungible_token_holders(contract_id, token_type, query_params = {})
|
242
|
-
get(
|
481
|
+
get(
|
482
|
+
"/v1/item-tokens/#{contract_id}/fungibles/#{token_type}/holders",
|
483
|
+
query_params: page_request(query_params),
|
484
|
+
)
|
243
485
|
end
|
244
486
|
|
245
487
|
def non_fungible_tokens(contract_id, query_params = {})
|
246
|
-
get(
|
488
|
+
get(
|
489
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles",
|
490
|
+
query_params: page_request(query_params),
|
491
|
+
)
|
247
492
|
end
|
248
493
|
|
249
494
|
def non_fungible_token_type(contract_id, token_type, query_params = {})
|
250
|
-
get(
|
495
|
+
get(
|
496
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}",
|
497
|
+
query_params: page_request(query_params),
|
498
|
+
)
|
251
499
|
end
|
252
500
|
|
253
501
|
def create_non_fungible_token(contract_id, payload = {})
|
254
|
-
post(
|
502
|
+
post(
|
503
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles",
|
504
|
+
payload: non_fungible_token_create_update_request(payload),
|
505
|
+
)
|
255
506
|
end
|
256
507
|
|
257
508
|
def mint_non_fungible_token(contract_id, token_type, payload = {})
|
258
|
-
post(
|
509
|
+
post(
|
510
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/mint",
|
511
|
+
payload: non_fungible_token_mint_request(payload),
|
512
|
+
)
|
259
513
|
end
|
260
514
|
|
261
515
|
def multi_mint_non_fungible_token(contract_id, payload = {})
|
262
|
-
post(
|
516
|
+
post(
|
517
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/multi-mint",
|
518
|
+
payload: non_fungible_token_multi_mint_request(payload),
|
519
|
+
)
|
263
520
|
end
|
264
521
|
|
265
|
-
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
|
+
)
|
266
526
|
warn('Not Implemented yet')
|
267
|
-
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
|
+
)
|
268
532
|
end
|
269
533
|
|
270
|
-
def burn_non_fungible_token(
|
271
|
-
|
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
|
+
)
|
272
544
|
end
|
273
545
|
|
274
546
|
def non_fungible_token(contract_id, token_type, token_index)
|
275
|
-
get(
|
547
|
+
get(
|
548
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}",
|
549
|
+
)
|
276
550
|
end
|
277
551
|
|
278
552
|
def update_non_fungible_token_type(contract_id, token_type, payload = {})
|
279
|
-
put(
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
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
|
+
)
|
284
580
|
end
|
285
581
|
|
286
|
-
def
|
287
|
-
get(
|
582
|
+
def non_fungible_token_holder(contract_id, token_type, token_index)
|
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
|
+
)
|
288
622
|
end
|
289
623
|
|
290
|
-
def
|
291
|
-
get(
|
624
|
+
def parent_of_non_fungible_token(contract_id, token_type, token_index)
|
625
|
+
get(
|
626
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}/parent",
|
627
|
+
)
|
292
628
|
end
|
293
629
|
|
294
|
-
def
|
295
|
-
|
630
|
+
def root_of_non_fungible_token(contract_id, token_type, token_index)
|
631
|
+
get(
|
632
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/#{token_type}/#{token_index}/root",
|
633
|
+
)
|
296
634
|
end
|
297
635
|
|
298
|
-
def
|
299
|
-
|
636
|
+
def fungible_token_media_resources_update_status(contract_id, request_id)
|
637
|
+
get(
|
638
|
+
"/v1/item-tokens/#{contract_id}/fungibles/media-resources/#{request_id}/status",
|
639
|
+
)
|
300
640
|
end
|
301
641
|
|
302
|
-
def
|
303
|
-
|
642
|
+
def update_fungible_token_media_resources(contract_id, token_types)
|
643
|
+
put(
|
644
|
+
"/v1/item-tokens/#{contract_id}/fungibles/media-resources",
|
645
|
+
payload: fungible_token_media_resources_request(token_types),
|
646
|
+
)
|
304
647
|
end
|
305
648
|
|
306
|
-
def
|
307
|
-
|
649
|
+
def fungible_token_thumbnail_resources_update_statuses(
|
650
|
+
contract_id,
|
651
|
+
request_id
|
652
|
+
)
|
653
|
+
get(
|
654
|
+
"/v1/item-tokens/#{contract_id}/fungibles/thumbnails/#{request_id}/status",
|
655
|
+
)
|
308
656
|
end
|
309
657
|
|
310
|
-
def
|
311
|
-
|
658
|
+
def update_fungible_token_thumbnail_resources(contract_id, token_types)
|
659
|
+
put(
|
660
|
+
"/v1/item-tokens/#{contract_id}/fungibles/thumbnails",
|
661
|
+
payload: fungible_token_media_resources_request(token_types),
|
662
|
+
)
|
312
663
|
end
|
313
664
|
|
314
|
-
def
|
315
|
-
|
665
|
+
def non_fungible_token_media_resources_update_status(
|
666
|
+
contract_id,
|
667
|
+
request_id
|
668
|
+
)
|
669
|
+
get(
|
670
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/media-resources/#{request_id}/status",
|
671
|
+
)
|
316
672
|
end
|
317
673
|
|
318
|
-
def
|
319
|
-
put(
|
674
|
+
def update_non_fungible_token_media_resources(contract_id, token_ids)
|
675
|
+
put(
|
676
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/media-resources",
|
677
|
+
payload: non_fungible_token_media_resources_request(token_ids),
|
678
|
+
)
|
320
679
|
end
|
321
680
|
|
322
|
-
def
|
323
|
-
|
681
|
+
def non_fungible_token_thumbnail_resources_update_statuses(
|
682
|
+
contract_id,
|
683
|
+
request_id
|
684
|
+
)
|
685
|
+
get(
|
686
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/thumbnails/#{request_id}/status",
|
687
|
+
)
|
324
688
|
end
|
325
689
|
|
326
|
-
def
|
327
|
-
put(
|
690
|
+
def update_non_fungible_token_thumbnail_resources(contract_id, token_ids)
|
691
|
+
put(
|
692
|
+
"/v1/item-tokens/#{contract_id}/non-fungibles/thumbnails",
|
693
|
+
payload: non_fungible_token_media_resources_request(token_ids),
|
694
|
+
)
|
328
695
|
end
|
329
696
|
|
330
697
|
def memos(tx_hash)
|
@@ -344,7 +711,12 @@ module LbdSdk
|
|
344
711
|
end
|
345
712
|
|
346
713
|
def get(endpoint_path, query_params: {})
|
347
|
-
headers =
|
714
|
+
headers =
|
715
|
+
request_headers(
|
716
|
+
endpoint_path: endpoint_path,
|
717
|
+
method: 'GET',
|
718
|
+
query_params: query_params,
|
719
|
+
)
|
348
720
|
query_params = RequestParamFlattener.new.flatten(query_params)
|
349
721
|
if query_params.empty?
|
350
722
|
httpclient.get("#{@endpoint}#{endpoint_path}", headers)
|
@@ -354,23 +726,51 @@ module LbdSdk
|
|
354
726
|
end
|
355
727
|
|
356
728
|
def post(endpoint_path, query_params: {}, payload: {})
|
357
|
-
headers =
|
729
|
+
headers =
|
730
|
+
request_headers(
|
731
|
+
endpoint_path: endpoint_path,
|
732
|
+
method: 'POST',
|
733
|
+
query_params: query_params,
|
734
|
+
payload: payload,
|
735
|
+
)
|
358
736
|
query_params = RequestParamFlattener.new.flatten(query_params)
|
359
737
|
if query_params.empty?
|
360
|
-
httpclient.post(
|
738
|
+
httpclient.post(
|
739
|
+
"#{@endpoint}#{endpoint_path}",
|
740
|
+
payload.to_json,
|
741
|
+
headers,
|
742
|
+
)
|
361
743
|
else
|
362
|
-
httpclient.post(
|
744
|
+
httpclient.post(
|
745
|
+
"#{@endpoint}#{endpoint_path}?#{query_params}",
|
746
|
+
payload.to_json,
|
747
|
+
headers,
|
748
|
+
)
|
363
749
|
end
|
364
750
|
end
|
365
751
|
|
366
752
|
def put(endpoint_path, payload: {})
|
367
|
-
headers =
|
753
|
+
headers =
|
754
|
+
request_headers(
|
755
|
+
endpoint_path: endpoint_path,
|
756
|
+
method: 'PUT',
|
757
|
+
payload: payload,
|
758
|
+
)
|
368
759
|
httpclient.put("#{@endpoint}#{endpoint_path}", payload.to_json, headers)
|
369
760
|
end
|
370
761
|
|
371
762
|
def delete(endpoint_path, payload: {})
|
372
|
-
headers =
|
373
|
-
|
763
|
+
headers =
|
764
|
+
request_headers(
|
765
|
+
endpoint_path: endpoint_path,
|
766
|
+
method: 'DELETE',
|
767
|
+
payload: payload,
|
768
|
+
)
|
769
|
+
httpclient.delete(
|
770
|
+
"#{@endpoint}#{endpoint_path}",
|
771
|
+
payload.to_json,
|
772
|
+
headers,
|
773
|
+
)
|
374
774
|
end
|
375
775
|
|
376
776
|
def request_headers(endpoint_path:, method:, query_params: {}, payload: {})
|
@@ -382,15 +782,16 @@ module LbdSdk
|
|
382
782
|
'Content-Type': 'application/json',
|
383
783
|
Nonce: "#{nonce}",
|
384
784
|
Timestamp: "#{timestamp}",
|
385
|
-
Signature:
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
785
|
+
Signature:
|
786
|
+
SignatureGenerator.new.generate(
|
787
|
+
secret: @api_secret_key,
|
788
|
+
method: method,
|
789
|
+
endpoint_path: endpoint_path,
|
790
|
+
timestamp: timestamp,
|
791
|
+
nonce: nonce,
|
792
|
+
query_params: query_params,
|
793
|
+
body: payload,
|
794
|
+
),
|
394
795
|
}
|
395
796
|
end
|
396
797
|
end
|