n8n-nodes-blockfrost 0.1.3 → 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.
@@ -39,6 +39,17 @@ class Blockfrost {
39
39
  { name: 'Accounts', value: 'accounts' },
40
40
  { name: 'Addresses', value: 'addresses' },
41
41
  { name: 'Assets', value: 'assets' },
42
+ { name: 'Blocks', value: 'blocks' },
43
+ { name: 'Epochs', value: 'epochs' },
44
+ { name: 'Governance', value: 'governance' },
45
+ { name: 'Ledger', value: 'ledger' },
46
+ { name: 'Mempool', value: 'mempool' },
47
+ { name: 'Metadata', value: 'metadata' },
48
+ { name: 'Network', value: 'network' },
49
+ { name: 'Pools', value: 'pools' },
50
+ { name: 'Scripts', value: 'scripts' },
51
+ { name: 'Transactions', value: 'transactions' },
52
+ { name: 'Utilities', value: 'utilities' },
42
53
  ],
43
54
  default: 'health',
44
55
  required: true,
@@ -138,6 +149,133 @@ class Blockfrost {
138
149
  },
139
150
  description: 'Policy ID',
140
151
  },
152
+ {
153
+ displayName: 'Operation',
154
+ name: 'operation',
155
+ type: 'options',
156
+ noDataExpression: true,
157
+ displayOptions: {
158
+ show: {
159
+ category: ['blocks'],
160
+ },
161
+ },
162
+ options: [
163
+ { name: 'Latest Block', value: 'getLatestBlock', description: 'Return the latest block (GET /blocks/latest)' },
164
+ { name: 'Latest Block Transactions', value: 'getLatestBlockTxs', description: 'Return transactions within the latest block (GET /blocks/latest/txs)' },
165
+ { name: 'Latest Block Transactions CBOR', value: 'getLatestBlockTxsCbor', description: 'Return transactions within the latest block with CBOR (GET /blocks/latest/txs/cbor)' },
166
+ { name: 'Specific Block', value: 'getBlock', description: 'Return content of a requested block (GET /blocks/{hash_or_number})' },
167
+ { name: 'Next Blocks', value: 'getNextBlocks', description: 'Return list of blocks following a specific block (GET /blocks/{hash_or_number}/next)' },
168
+ { name: 'Previous Blocks', value: 'getPreviousBlocks', description: 'Return list of blocks preceding a specific block (GET /blocks/{hash_or_number}/previous)' },
169
+ { name: 'Block in Slot', value: 'getBlockInSlot', description: 'Return content of a requested block for a specific slot (GET /blocks/slot/{slot_number})' },
170
+ { name: 'Block in Epoch Slot', value: 'getBlockInEpochSlot', description: 'Return content of a requested block for a specific slot in an epoch (GET /blocks/epoch/{epoch_number}/slot/{slot_number})' },
171
+ { name: 'Block Transactions', value: 'getBlockTxs', description: 'Return transactions within the block (GET /blocks/{hash_or_number}/txs)' },
172
+ { name: 'Block Transactions CBOR', value: 'getBlockTxsCbor', description: 'Return transactions within the block with CBOR (GET /blocks/{hash_or_number}/txs/cbor)' },
173
+ { name: 'Block Addresses', value: 'getBlockAddresses', description: 'Return addresses affected in the specified block (GET /blocks/{hash_or_number}/addresses)' },
174
+ ],
175
+ default: 'getLatestBlock',
176
+ },
177
+ {
178
+ displayName: 'Block Hash or Number',
179
+ name: 'hashOrNumber',
180
+ type: 'string',
181
+ required: true,
182
+ default: '',
183
+ displayOptions: {
184
+ show: {
185
+ category: ['blocks'],
186
+ operation: ['getBlock', 'getNextBlocks', 'getPreviousBlocks', 'getBlockTxs', 'getBlockTxsCbor', 'getBlockAddresses'],
187
+ },
188
+ },
189
+ description: 'Block hash or block number',
190
+ },
191
+ {
192
+ displayName: 'Slot Number',
193
+ name: 'slotNumber',
194
+ type: 'number',
195
+ required: true,
196
+ default: 0,
197
+ displayOptions: {
198
+ show: {
199
+ category: ['blocks'],
200
+ operation: ['getBlockInSlot'],
201
+ },
202
+ },
203
+ description: 'Slot number',
204
+ },
205
+ {
206
+ displayName: 'Epoch Number',
207
+ name: 'epochNumber',
208
+ type: 'number',
209
+ required: true,
210
+ default: 0,
211
+ displayOptions: {
212
+ show: {
213
+ category: ['blocks'],
214
+ operation: ['getBlockInEpochSlot'],
215
+ },
216
+ },
217
+ description: 'Epoch number',
218
+ },
219
+ {
220
+ displayName: 'Slot Number',
221
+ name: 'epochSlotNumber',
222
+ type: 'number',
223
+ required: true,
224
+ default: 0,
225
+ displayOptions: {
226
+ show: {
227
+ category: ['blocks'],
228
+ operation: ['getBlockInEpochSlot'],
229
+ },
230
+ },
231
+ description: 'Slot number within the epoch',
232
+ },
233
+ {
234
+ displayName: 'Count',
235
+ name: 'count',
236
+ type: 'number',
237
+ default: 100,
238
+ required: false,
239
+ displayOptions: {
240
+ show: {
241
+ category: ['blocks'],
242
+ operation: ['getLatestBlockTxs', 'getLatestBlockTxsCbor', 'getNextBlocks', 'getPreviousBlocks', 'getBlockTxs', 'getBlockTxsCbor', 'getBlockAddresses'],
243
+ },
244
+ },
245
+ description: 'Max number of results per page (1-100)',
246
+ },
247
+ {
248
+ displayName: 'Page',
249
+ name: 'page',
250
+ type: 'number',
251
+ default: 1,
252
+ required: false,
253
+ displayOptions: {
254
+ show: {
255
+ category: ['blocks'],
256
+ operation: ['getLatestBlockTxs', 'getLatestBlockTxsCbor', 'getNextBlocks', 'getPreviousBlocks', 'getBlockTxs', 'getBlockTxsCbor', 'getBlockAddresses'],
257
+ },
258
+ },
259
+ description: 'Page number for results',
260
+ },
261
+ {
262
+ displayName: 'Order',
263
+ name: 'order',
264
+ type: 'options',
265
+ options: [
266
+ { name: 'Ascending', value: 'asc' },
267
+ { name: 'Descending', value: 'desc' },
268
+ ],
269
+ default: 'asc',
270
+ required: false,
271
+ displayOptions: {
272
+ show: {
273
+ category: ['blocks'],
274
+ operation: ['getLatestBlockTxs', 'getLatestBlockTxsCbor', 'getNextBlocks', 'getPreviousBlocks', 'getBlockTxs', 'getBlockTxsCbor', 'getBlockAddresses'],
275
+ },
276
+ },
277
+ description: 'Order of results',
278
+ },
141
279
  {
142
280
  displayName: 'Operation',
143
281
  name: 'operation',
@@ -276,199 +414,1457 @@ class Blockfrost {
276
414
  },
277
415
  description: 'Stake address in Bech32 format',
278
416
  },
279
- ],
280
- };
281
- }
282
- async execute() {
283
- const credentials = await this.getCredentials('blockfrostApi');
284
- const blockfrost = new blockfrost_js_1.BlockFrostAPI({
285
- projectId: credentials.projectId,
286
- network: credentials.network,
287
- });
288
- const category = this.getNodeParameter('category', 0);
289
- const operation = this.getNodeParameter('operation', 0);
290
- let responseData = [];
291
- try {
292
- if (category === 'assets') {
293
- const count = this.getNodeParameter('count', 0, 100);
294
- const page = this.getNodeParameter('page', 0, 1);
295
- const order = this.getNodeParameter('order', 0, 'asc');
296
- const operation = this.getNodeParameter('operation', 0);
297
- let url = '';
298
- let params = { count, page, order };
299
- let asset = '';
300
- let policyId = '';
301
- switch (operation) {
302
- case 'listAssets':
303
- url = '/assets';
304
- break;
305
- case 'getAsset':
306
- asset = this.getNodeParameter('asset', 0);
307
- url = `/assets/${asset}`;
308
- params = {};
309
- break;
310
- case 'getAssetHistory':
311
- asset = this.getNodeParameter('asset', 0);
312
- url = `/assets/${asset}/history`;
313
- break;
314
- case 'getAssetTransactions':
315
- asset = this.getNodeParameter('asset', 0);
316
- url = `/assets/${asset}/transactions`;
317
- break;
318
- case 'getAssetTxs':
319
- asset = this.getNodeParameter('asset', 0);
320
- url = `/assets/${asset}/txs`;
321
- break;
322
- case 'getAssetAddresses':
323
- asset = this.getNodeParameter('asset', 0);
324
- url = `/assets/${asset}/addresses`;
325
- break;
326
- case 'listPolicyAssets':
327
- policyId = this.getNodeParameter('policyId', 0);
328
- url = `/assets/policy/${policyId}`;
329
- break;
330
- default:
331
- throw new Error(`Unknown operation: ${operation}`);
332
- }
333
- const apiBase = credentials.network === 'mainnet'
334
- ? 'https://cardano-mainnet.blockfrost.io/api/v0'
335
- : credentials.network === 'preprod'
336
- ? 'https://cardano-preprod.blockfrost.io/api/v0'
337
- : 'https://cardano-preview.blockfrost.io/api/v0';
338
- const reqUrl = apiBase + url;
339
- const headers = {
340
- project_id: credentials.projectId,
341
- };
342
- let gotOptions = {
343
- method: 'GET',
344
- headers,
345
- responseType: 'json',
346
- };
347
- if (params && Object.keys(params).length > 0) {
348
- gotOptions.searchParams = params;
349
- }
350
- const response = await (0, got_1.default)(reqUrl, gotOptions);
351
- const body = response.body;
352
- if (Array.isArray(body)) {
353
- responseData = body;
354
- }
355
- else if (typeof body === 'object' && body !== null) {
356
- responseData = [body];
357
- }
358
- else {
359
- responseData = [{ result: body }];
360
- }
361
- }
362
- else if (category === 'health') {
363
- switch (operation) {
364
- case 'root':
365
- responseData = [await blockfrost.root()];
366
- break;
367
- case 'health':
368
- responseData = [await blockfrost.health()];
369
- break;
370
- case 'clock':
371
- responseData = [await blockfrost.healthClock()];
372
- break;
373
- default:
374
- throw new Error(`Unknown operation: ${operation}`);
375
- }
376
- }
377
- else if (category === 'metrics') {
378
- switch (operation) {
379
- case 'usage':
380
- responseData = await blockfrost.metrics();
381
- break;
382
- case 'endpoints':
383
- responseData = await blockfrost.metricsEndpoints();
384
- break;
385
- default:
386
- throw new Error(`Unknown operation: ${operation}`);
387
- }
388
- }
389
- else if (category === 'accounts') {
390
- const stakeAddress = this.getNodeParameter('stakeAddress', 0);
391
- switch (operation) {
392
- case 'getAccount':
393
- responseData = [await blockfrost.accounts(stakeAddress)];
394
- break;
395
- case 'getRewards':
396
- responseData = await blockfrost.accountsRewards(stakeAddress);
397
- break;
398
- case 'getHistory':
399
- responseData = await blockfrost.accountsHistory(stakeAddress);
400
- break;
401
- case 'getDelegations':
402
- responseData = await blockfrost.accountsDelegations(stakeAddress);
403
- break;
404
- case 'getRegistrations':
405
- responseData = await blockfrost.accountsRegistrations(stakeAddress);
406
- break;
407
- case 'getWithdrawals':
408
- responseData = await blockfrost.accountsWithdrawals(stakeAddress);
409
- break;
410
- case 'getMirs':
411
- responseData = await blockfrost.accountsMirs(stakeAddress);
412
- break;
413
- case 'getAddresses':
414
- responseData = await blockfrost.accountsAddresses(stakeAddress);
415
- break;
416
- case 'getAddressesAssets':
417
- responseData = await blockfrost.accountsAddressesAssets(stakeAddress);
418
- break;
419
- case 'getAddressesTotal':
420
- responseData = [await blockfrost.accountsAddressesTotal(stakeAddress)];
421
- break;
422
- case 'getUtxos':
423
- if (typeof blockfrost.request === 'function') {
424
- responseData = await blockfrost.request(`/accounts/${stakeAddress}/utxos`);
425
- }
426
- else if (typeof blockfrost._request === 'function') {
427
- responseData = await blockfrost._request('GET', `/accounts/${stakeAddress}/utxos`);
428
- }
429
- else {
430
- throw new Error('accountsUtxos method not available in Blockfrost SDK.');
431
- }
432
- break;
433
- default:
434
- throw new Error(`Unknown operation: ${operation}`);
435
- }
436
- }
437
- else if (category === 'addresses') {
438
- const address = this.getNodeParameter('address', 0);
439
- switch (operation) {
440
- case 'getAddress':
441
- responseData = [await blockfrost.addresses(address)];
442
- break;
443
- case 'getAddressExtended':
444
- responseData = [await blockfrost.addressesExtended(address)];
445
- break;
446
- case 'getAddressTotal':
447
- responseData = [await blockfrost.addressesTotal(address)];
448
- break;
449
- case 'getAddressUtxos':
417
+ {
418
+ displayName: 'Operation',
419
+ name: 'operation',
420
+ type: 'options',
421
+ noDataExpression: true,
422
+ displayOptions: {
423
+ show: {
424
+ category: ['epochs'],
425
+ },
426
+ },
427
+ options: [
428
+ { name: 'Latest Epoch', value: 'getLatestEpoch', description: 'Return information about the latest epoch (GET /epochs/latest)' },
429
+ { name: 'Latest Epoch Parameters', value: 'getLatestEpochParameters', description: 'Return protocol parameters for the latest epoch (GET /epochs/latest/parameters)' },
430
+ { name: 'Specific Epoch', value: 'getEpoch', description: 'Return content of the requested epoch (GET /epochs/{number})' },
431
+ { name: 'Next Epochs', value: 'getNextEpochs', description: 'Return list of epochs following a specific epoch (GET /epochs/{number}/next)' },
432
+ { name: 'Previous Epochs', value: 'getPreviousEpochs', description: 'Return list of epochs preceding a specific epoch (GET /epochs/{number}/previous)' },
433
+ { name: 'Stake Distribution', value: 'getEpochStakes', description: 'Return active stake distribution for the specified epoch (GET /epochs/{number}/stakes)' },
434
+ { name: 'Stake Distribution by Pool', value: 'getEpochStakesByPool', description: 'Return active stake distribution by stake pool (GET /epochs/{number}/stakes/{pool_id})' },
435
+ { name: 'Block Distribution', value: 'getEpochBlocks', description: 'Return blocks minted for the epoch (GET /epochs/{number}/blocks)' },
436
+ { name: 'Block Distribution by Pool', value: 'getEpochBlocksByPool', description: 'Return blocks minted by stake pool (GET /epochs/{number}/blocks/{pool_id})' },
437
+ { name: 'Protocol Parameters', value: 'getEpochParameters', description: 'Return protocol parameters for the epoch (GET /epochs/{number}/parameters)' },
438
+ ],
439
+ default: 'getLatestEpoch',
440
+ },
441
+ {
442
+ displayName: 'Epoch Number',
443
+ name: 'epochNumber',
444
+ type: 'number',
445
+ required: true,
446
+ default: 0,
447
+ displayOptions: {
448
+ show: {
449
+ category: ['epochs'],
450
+ operation: ['getEpoch', 'getNextEpochs', 'getPreviousEpochs', 'getEpochStakes', 'getEpochStakesByPool', 'getEpochBlocks', 'getEpochBlocksByPool', 'getEpochParameters'],
451
+ },
452
+ },
453
+ description: 'Epoch number',
454
+ },
455
+ {
456
+ displayName: 'Pool ID',
457
+ name: 'poolId',
458
+ type: 'string',
459
+ required: true,
460
+ default: '',
461
+ displayOptions: {
462
+ show: {
463
+ category: ['epochs'],
464
+ operation: ['getEpochStakesByPool', 'getEpochBlocksByPool'],
465
+ },
466
+ },
467
+ description: 'Bech32 encoded pool ID',
468
+ },
469
+ {
470
+ displayName: 'Operation',
471
+ name: 'operation',
472
+ type: 'options',
473
+ noDataExpression: true,
474
+ displayOptions: {
475
+ show: {
476
+ category: ['governance'],
477
+ },
478
+ },
479
+ options: [
480
+ { name: 'List DReps', value: 'listDreps', description: 'Return information about Delegate Representatives (GET /governance/dreps)' },
481
+ { name: 'Specific DRep', value: 'getDrep', description: 'DRep information (GET /governance/dreps/{drep_id})' },
482
+ { name: 'DRep Delegators', value: 'getDrepDelegators', description: 'List of DRep delegators (GET /governance/dreps/{drep_id}/delegators)' },
483
+ { name: 'DRep Metadata', value: 'getDrepMetadata', description: 'DRep metadata information (GET /governance/dreps/{drep_id}/metadata)' },
484
+ { name: 'DRep Updates', value: 'getDrepUpdates', description: 'List of certificate updates to the DRep (GET /governance/dreps/{drep_id}/updates)' },
485
+ { name: 'DRep Votes', value: 'getDrepVotes', description: 'History of DRep votes (GET /governance/dreps/{drep_id}/votes)' },
486
+ { name: 'List Proposals', value: 'listProposals', description: 'Return information about Proposals (GET /governance/proposals)' },
487
+ { name: 'Specific Proposal', value: 'getProposal', description: 'Proposal information (GET /governance/proposals/{tx_hash}/{cert_index})' },
488
+ { name: 'Proposal Parameters', value: 'getProposalParameters', description: 'Parameters proposal details (GET /governance/proposals/{tx_hash}/{cert_index}/parameters)' },
489
+ { name: 'Proposal Withdrawals', value: 'getProposalWithdrawals', description: 'Parameters withdrawals details (GET /governance/proposals/{tx_hash}/{cert_index}/withdrawals)' },
490
+ { name: 'Proposal Votes', value: 'getProposalVotes', description: 'History of Proposal votes (GET /governance/proposals/{tx_hash}/{cert_index}/votes)' },
491
+ { name: 'Proposal Metadata', value: 'getProposalMetadata', description: 'Proposal metadata information (GET /governance/proposals/{tx_hash}/{cert_index}/metadata)' },
492
+ ],
493
+ default: 'listDreps',
494
+ },
495
+ {
496
+ displayName: 'DRep ID',
497
+ name: 'drepId',
498
+ type: 'string',
499
+ required: true,
500
+ default: '',
501
+ displayOptions: {
502
+ show: {
503
+ category: ['governance'],
504
+ operation: ['getDrep', 'getDrepDelegators', 'getDrepMetadata', 'getDrepUpdates', 'getDrepVotes'],
505
+ },
506
+ },
507
+ description: 'DRep ID in Bech32 format',
508
+ },
509
+ {
510
+ displayName: 'Transaction Hash',
511
+ name: 'txHash',
512
+ type: 'string',
513
+ required: true,
514
+ default: '',
515
+ displayOptions: {
516
+ show: {
517
+ category: ['governance'],
518
+ operation: ['getProposal', 'getProposalParameters', 'getProposalWithdrawals', 'getProposalVotes', 'getProposalMetadata'],
519
+ },
520
+ },
521
+ description: 'Transaction hash',
522
+ },
523
+ {
524
+ displayName: 'Certificate Index',
525
+ name: 'certIndex',
526
+ type: 'number',
527
+ required: true,
528
+ default: 0,
529
+ displayOptions: {
530
+ show: {
531
+ category: ['governance'],
532
+ operation: ['getProposal', 'getProposalParameters', 'getProposalWithdrawals', 'getProposalVotes', 'getProposalMetadata'],
533
+ },
534
+ },
535
+ description: 'Certificate index',
536
+ },
537
+ {
538
+ displayName: 'Operation',
539
+ name: 'operation',
540
+ type: 'options',
541
+ noDataExpression: true,
542
+ displayOptions: {
543
+ show: {
544
+ category: ['ledger'],
545
+ },
546
+ },
547
+ options: [
548
+ { name: 'Blockchain Genesis', value: 'getGenesis', description: 'Return information about blockchain genesis (GET /genesis)' },
549
+ ],
550
+ default: 'getGenesis',
551
+ },
552
+ {
553
+ displayName: 'Operation',
554
+ name: 'operation',
555
+ type: 'options',
556
+ noDataExpression: true,
557
+ displayOptions: {
558
+ show: {
559
+ category: ['mempool'],
560
+ },
561
+ },
562
+ options: [
563
+ { name: 'Mempool', value: 'getMempool', description: 'Return transactions in Blockfrost mempool (GET /mempool)' },
564
+ { name: 'Specific Mempool Transaction', value: 'getMempoolTx', description: 'Return content of requested transaction (GET /mempool/{hash})' },
565
+ { name: 'Mempool by Address', value: 'getMempoolByAddress', description: 'List mempool transactions for address (GET /mempool/addresses/{address})' },
566
+ ],
567
+ default: 'getMempool',
568
+ },
569
+ {
570
+ displayName: 'Transaction Hash',
571
+ name: 'txHash',
572
+ type: 'string',
573
+ required: true,
574
+ default: '',
575
+ displayOptions: {
576
+ show: {
577
+ category: ['mempool'],
578
+ operation: ['getMempoolTx'],
579
+ },
580
+ },
581
+ description: 'Transaction hash',
582
+ },
583
+ {
584
+ displayName: 'Address',
585
+ name: 'address',
586
+ type: 'string',
587
+ required: true,
588
+ default: '',
589
+ displayOptions: {
590
+ show: {
591
+ category: ['mempool'],
592
+ operation: ['getMempoolByAddress'],
593
+ },
594
+ },
595
+ description: 'Cardano address in Bech32 format',
596
+ },
597
+ {
598
+ displayName: 'Operation',
599
+ name: 'operation',
600
+ type: 'options',
601
+ noDataExpression: true,
602
+ displayOptions: {
603
+ show: {
604
+ category: ['metadata'],
605
+ },
606
+ },
607
+ options: [
608
+ { name: 'Transaction Metadata Labels', value: 'getTxMetadataLabels', description: 'List all used transaction metadata labels (GET /metadata/txs/labels)' },
609
+ { name: 'Transaction Metadata Content JSON', value: 'getTxMetadataByLabelJson', description: 'Transaction metadata per label JSON (GET /metadata/txs/labels/{label})' },
610
+ { name: 'Transaction Metadata Content CBOR', value: 'getTxMetadataByLabelCbor', description: 'Transaction metadata per label CBOR (GET /metadata/txs/labels/{label}/cbor)' },
611
+ ],
612
+ default: 'getTxMetadataLabels',
613
+ },
614
+ {
615
+ displayName: 'Label',
616
+ name: 'label',
617
+ type: 'string',
618
+ required: true,
619
+ default: '',
620
+ displayOptions: {
621
+ show: {
622
+ category: ['metadata'],
623
+ operation: ['getTxMetadataByLabelJson', 'getTxMetadataByLabelCbor'],
624
+ },
625
+ },
626
+ description: 'Metadata label',
627
+ },
628
+ {
629
+ displayName: 'Operation',
630
+ name: 'operation',
631
+ type: 'options',
632
+ noDataExpression: true,
633
+ displayOptions: {
634
+ show: {
635
+ category: ['network'],
636
+ },
637
+ },
638
+ options: [
639
+ { name: 'Network Information', value: 'getNetworkInfo', description: 'Return detailed network information (GET /network)' },
640
+ { name: 'Network Eras', value: 'getNetworkEras', description: 'Query summary of blockchain eras (GET /network/eras)' },
641
+ ],
642
+ default: 'getNetworkInfo',
643
+ },
644
+ {
645
+ displayName: 'Operation',
646
+ name: 'operation',
647
+ type: 'options',
648
+ noDataExpression: true,
649
+ displayOptions: {
650
+ show: {
651
+ category: ['pools'],
652
+ },
653
+ },
654
+ options: [
655
+ { name: 'List Stake Pools', value: 'listPools', description: 'List registered stake pools (GET /pools)' },
656
+ { name: 'List Stake Pools Extended', value: 'listPoolsExtended', description: 'List registered stake pools with additional information (GET /pools/extended)' },
657
+ { name: 'List Retired Pools', value: 'listRetiredPools', description: 'List already retired pools (GET /pools/retired)' },
658
+ { name: 'List Retiring Pools', value: 'listRetiringPools', description: 'List stake pools retiring in upcoming epochs (GET /pools/retiring)' },
659
+ { name: 'Specific Stake Pool', value: 'getPool', description: 'Pool information (GET /pools/{pool_id})' },
660
+ { name: 'Stake Pool History', value: 'getPoolHistory', description: 'History of stake pool parameters over epochs (GET /pools/{pool_id}/history)' },
661
+ { name: 'Stake Pool Metadata', value: 'getPoolMetadata', description: 'Stake pool registration metadata (GET /pools/{pool_id}/metadata)' },
662
+ { name: 'Stake Pool Relays', value: 'getPoolRelays', description: 'Relays of a stake pool (GET /pools/{pool_id}/relays)' },
663
+ { name: 'Stake Pool Delegators', value: 'getPoolDelegators', description: 'List current stake pool delegators (GET /pools/{pool_id}/delegators)' },
664
+ { name: 'Stake Pool Blocks', value: 'getPoolBlocks', description: 'List stake pool blocks (GET /pools/{pool_id}/blocks)' },
665
+ { name: 'Stake Pool Updates', value: 'getPoolUpdates', description: 'List certificate updates to the stake pool (GET /pools/{pool_id}/updates)' },
666
+ { name: 'Stake Pool Votes', value: 'getPoolVotes', description: 'History of stake pool votes (GET /pools/{pool_id}/votes)' },
667
+ ],
668
+ default: 'listPools',
669
+ },
670
+ {
671
+ displayName: 'Pool ID',
672
+ name: 'poolId',
673
+ type: 'string',
674
+ required: true,
675
+ default: '',
676
+ displayOptions: {
677
+ show: {
678
+ category: ['pools'],
679
+ operation: ['getPool', 'getPoolHistory', 'getPoolMetadata', 'getPoolRelays', 'getPoolDelegators', 'getPoolBlocks', 'getPoolUpdates', 'getPoolVotes'],
680
+ },
681
+ },
682
+ description: 'Bech32 encoded pool ID',
683
+ },
684
+ {
685
+ displayName: 'Operation',
686
+ name: 'operation',
687
+ type: 'options',
688
+ noDataExpression: true,
689
+ displayOptions: {
690
+ show: {
691
+ category: ['scripts'],
692
+ },
693
+ },
694
+ options: [
695
+ { name: 'List Scripts', value: 'listScripts', description: 'List of scripts (GET /scripts)' },
696
+ { name: 'Specific Script', value: 'getScript', description: 'Information about a specific script (GET /scripts/{script_hash})' },
697
+ { name: 'Script JSON', value: 'getScriptJson', description: 'JSON representation of a timelock script (GET /scripts/{script_hash}/json)' },
698
+ { name: 'Script CBOR', value: 'getScriptCbor', description: 'CBOR representation of a plutus script (GET /scripts/{script_hash}/cbor)' },
699
+ { name: 'Script Redeemers', value: 'getScriptRedeemers', description: 'List redeemers of a specific script (GET /scripts/{script_hash}/redeemers)' },
700
+ { name: 'Datum Value', value: 'getDatum', description: 'Query JSON value of a datum by its hash (GET /scripts/datum/{datum_hash})' },
701
+ { name: 'Datum CBOR Value', value: 'getDatumCbor', description: 'Query CBOR serialised datum by its hash (GET /scripts/datum/{datum_hash}/cbor)' },
702
+ ],
703
+ default: 'listScripts',
704
+ },
705
+ {
706
+ displayName: 'Script Hash',
707
+ name: 'scriptHash',
708
+ type: 'string',
709
+ required: true,
710
+ default: '',
711
+ displayOptions: {
712
+ show: {
713
+ category: ['scripts'],
714
+ operation: ['getScript', 'getScriptJson', 'getScriptCbor', 'getScriptRedeemers'],
715
+ },
716
+ },
717
+ description: 'Script hash',
718
+ },
719
+ {
720
+ displayName: 'Datum Hash',
721
+ name: 'datumHash',
722
+ type: 'string',
723
+ required: true,
724
+ default: '',
725
+ displayOptions: {
726
+ show: {
727
+ category: ['scripts'],
728
+ operation: ['getDatum', 'getDatumCbor'],
729
+ },
730
+ },
731
+ description: 'Datum hash',
732
+ },
733
+ {
734
+ displayName: 'Operation',
735
+ name: 'operation',
736
+ type: 'options',
737
+ noDataExpression: true,
738
+ displayOptions: {
739
+ show: {
740
+ category: ['transactions'],
741
+ },
742
+ },
743
+ options: [
744
+ { name: 'Specific Transaction', value: 'getTransaction', description: 'Return content of the requested transaction (GET /txs/{hash})' },
745
+ { name: 'Transaction UTXOs', value: 'getTransactionUtxos', description: 'Return inputs and UTXOs of the specific transaction (GET /txs/{hash}/utxos)' },
746
+ { name: 'Transaction Stakes', value: 'getTransactionStakes', description: 'Obtain information about stake addresses certificates (GET /txs/{hash}/stakes)' },
747
+ { name: 'Transaction Delegations', value: 'getTransactionDelegations', description: 'Obtain information about delegation certificates (GET /txs/{hash}/delegations)' },
748
+ { name: 'Transaction Withdrawals', value: 'getTransactionWithdrawals', description: 'Obtain information about withdrawals (GET /txs/{hash}/withdrawals)' },
749
+ { name: 'Transaction MIRs', value: 'getTransactionMirs', description: 'Obtain information about Move Instantaneous Rewards (GET /txs/{hash}/mirs)' },
750
+ { name: 'Transaction Pool Updates', value: 'getTransactionPoolUpdates', description: 'Obtain information about stake pool registration and update certificates (GET /txs/{hash}/pool_updates)' },
751
+ { name: 'Transaction Pool Retires', value: 'getTransactionPoolRetires', description: 'Obtain information about stake pool retirements (GET /txs/{hash}/pool_retires)' },
752
+ { name: 'Transaction Metadata', value: 'getTransactionMetadata', description: 'Obtain the transaction metadata (GET /txs/{hash}/metadata)' },
753
+ { name: 'Transaction Metadata CBOR', value: 'getTransactionMetadataCbor', description: 'Obtain the transaction metadata in CBOR (GET /txs/{hash}/metadata/cbor)' },
754
+ { name: 'Transaction Redeemers', value: 'getTransactionRedeemers', description: 'Obtain the transaction redeemers (GET /txs/{hash}/redeemers)' },
755
+ { name: 'Transaction Required Signers', value: 'getTransactionRequiredSigners', description: 'Obtain the extra transaction witnesses (GET /txs/{hash}/required_signers)' },
756
+ { name: 'Transaction CBOR', value: 'getTransactionCbor', description: 'Obtain the CBOR serialized transaction (GET /txs/{hash}/cbor)' },
757
+ { name: 'Submit Transaction', value: 'submitTransaction', description: 'Submit an already serialized transaction to the network (POST /tx/submit)' },
758
+ ],
759
+ default: 'getTransaction',
760
+ },
761
+ {
762
+ displayName: 'Transaction Hash',
763
+ name: 'txHash',
764
+ type: 'string',
765
+ required: true,
766
+ default: '',
767
+ displayOptions: {
768
+ show: {
769
+ category: ['transactions'],
770
+ operation: ['getTransaction', 'getTransactionUtxos', 'getTransactionStakes', 'getTransactionDelegations', 'getTransactionWithdrawals', 'getTransactionMirs', 'getTransactionPoolUpdates', 'getTransactionPoolRetires', 'getTransactionMetadata', 'getTransactionMetadataCbor', 'getTransactionRedeemers', 'getTransactionRequiredSigners', 'getTransactionCbor'],
771
+ },
772
+ },
773
+ description: 'Transaction hash',
774
+ },
775
+ {
776
+ displayName: 'Transaction CBOR',
777
+ name: 'transactionCbor',
778
+ type: 'string',
779
+ required: true,
780
+ default: '',
781
+ displayOptions: {
782
+ show: {
783
+ category: ['transactions'],
784
+ operation: ['submitTransaction'],
785
+ },
786
+ },
787
+ description: 'Serialized transaction in CBOR format',
788
+ },
789
+ {
790
+ displayName: 'Operation',
791
+ name: 'operation',
792
+ type: 'options',
793
+ noDataExpression: true,
794
+ displayOptions: {
795
+ show: {
796
+ category: ['utilities'],
797
+ },
798
+ },
799
+ options: [
800
+ { name: 'Derive Address', value: 'deriveAddress', description: 'Derive Shelley address from an xpub (GET /utils/addresses/xpub/{xpub}/{role}/{index})' },
801
+ { name: 'Evaluate Transaction', value: 'evaluateTransaction', description: 'Submit transaction for execution units evaluation (POST /utils/txs/evaluate)' },
802
+ { name: 'Evaluate Transaction with UTXOs', value: 'evaluateTransactionUtxos', description: 'Submit transaction for evaluation with additional UTXO set (POST /utils/txs/evaluate/utxos)' },
803
+ ],
804
+ default: 'deriveAddress',
805
+ },
806
+ {
807
+ displayName: 'XPub',
808
+ name: 'xpub',
809
+ type: 'string',
810
+ required: true,
811
+ default: '',
812
+ displayOptions: {
813
+ show: {
814
+ category: ['utilities'],
815
+ operation: ['deriveAddress'],
816
+ },
817
+ },
818
+ description: 'Extended public key (xpub)',
819
+ },
820
+ {
821
+ displayName: 'Role',
822
+ name: 'role',
823
+ type: 'number',
824
+ required: true,
825
+ default: 0,
826
+ displayOptions: {
827
+ show: {
828
+ category: ['utilities'],
829
+ operation: ['deriveAddress'],
830
+ },
831
+ },
832
+ description: 'Role (0 for external, 1 for internal)',
833
+ },
834
+ {
835
+ displayName: 'Index',
836
+ name: 'index',
837
+ type: 'number',
838
+ required: true,
839
+ default: 0,
840
+ displayOptions: {
841
+ show: {
842
+ category: ['utilities'],
843
+ operation: ['deriveAddress'],
844
+ },
845
+ },
846
+ description: 'Address index',
847
+ },
848
+ {
849
+ displayName: 'Transaction CBOR',
850
+ name: 'transactionCbor',
851
+ type: 'string',
852
+ required: true,
853
+ default: '',
854
+ displayOptions: {
855
+ show: {
856
+ category: ['utilities'],
857
+ operation: ['evaluateTransaction', 'evaluateTransactionUtxos'],
858
+ },
859
+ },
860
+ description: 'Serialized transaction in CBOR format',
861
+ },
862
+ {
863
+ displayName: 'Additional UTXOs',
864
+ name: 'additionalUtxos',
865
+ type: 'json',
866
+ required: false,
867
+ default: '[]',
868
+ displayOptions: {
869
+ show: {
870
+ category: ['utilities'],
871
+ operation: ['evaluateTransactionUtxos'],
872
+ },
873
+ },
874
+ description: 'Additional UTXO set as JSON array',
875
+ },
876
+ {
877
+ displayName: 'Count',
878
+ name: 'count',
879
+ type: 'number',
880
+ default: 100,
881
+ required: false,
882
+ displayOptions: {
883
+ show: {
884
+ category: ['epochs', 'governance', 'mempool', 'metadata', 'pools', 'scripts'],
885
+ },
886
+ },
887
+ description: 'Max number of results per page (1-100)',
888
+ },
889
+ {
890
+ displayName: 'Page',
891
+ name: 'page',
892
+ type: 'number',
893
+ default: 1,
894
+ required: false,
895
+ displayOptions: {
896
+ show: {
897
+ category: ['epochs', 'governance', 'mempool', 'metadata', 'pools', 'scripts'],
898
+ },
899
+ },
900
+ description: 'Page number for results',
901
+ },
902
+ {
903
+ displayName: 'Order',
904
+ name: 'order',
905
+ type: 'options',
906
+ options: [
907
+ { name: 'Ascending', value: 'asc' },
908
+ { name: 'Descending', value: 'desc' },
909
+ ],
910
+ default: 'asc',
911
+ required: false,
912
+ displayOptions: {
913
+ show: {
914
+ category: ['epochs', 'governance', 'mempool', 'metadata', 'pools', 'scripts'],
915
+ },
916
+ },
917
+ description: 'Order of results',
918
+ },
919
+ ],
920
+ };
921
+ }
922
+ async execute() {
923
+ const credentials = await this.getCredentials('blockfrostApi');
924
+ const blockfrost = new blockfrost_js_1.BlockFrostAPI({
925
+ projectId: credentials.projectId,
926
+ network: credentials.network,
927
+ });
928
+ const category = this.getNodeParameter('category', 0);
929
+ const operation = this.getNodeParameter('operation', 0);
930
+ let responseData = [];
931
+ try {
932
+ if (category === 'assets') {
933
+ const count = this.getNodeParameter('count', 0, 100);
934
+ const page = this.getNodeParameter('page', 0, 1);
935
+ const order = this.getNodeParameter('order', 0, 'asc');
936
+ const operation = this.getNodeParameter('operation', 0);
937
+ let url = '';
938
+ let params = { count, page, order };
939
+ let asset = '';
940
+ let policyId = '';
941
+ switch (operation) {
942
+ case 'listAssets':
943
+ url = '/assets';
944
+ break;
945
+ case 'getAsset':
946
+ asset = this.getNodeParameter('asset', 0);
947
+ url = `/assets/${asset}`;
948
+ params = {};
949
+ break;
950
+ case 'getAssetHistory':
951
+ asset = this.getNodeParameter('asset', 0);
952
+ url = `/assets/${asset}/history`;
953
+ break;
954
+ case 'getAssetTransactions':
955
+ asset = this.getNodeParameter('asset', 0);
956
+ url = `/assets/${asset}/transactions`;
957
+ break;
958
+ case 'getAssetTxs':
959
+ asset = this.getNodeParameter('asset', 0);
960
+ url = `/assets/${asset}/txs`;
961
+ break;
962
+ case 'getAssetAddresses':
963
+ asset = this.getNodeParameter('asset', 0);
964
+ url = `/assets/${asset}/addresses`;
965
+ break;
966
+ case 'listPolicyAssets':
967
+ policyId = this.getNodeParameter('policyId', 0);
968
+ url = `/assets/policy/${policyId}`;
969
+ break;
970
+ default:
971
+ throw new Error(`Unknown operation: ${operation}`);
972
+ }
973
+ const apiBase = credentials.network === 'mainnet'
974
+ ? 'https://cardano-mainnet.blockfrost.io/api/v0'
975
+ : credentials.network === 'preprod'
976
+ ? 'https://cardano-preprod.blockfrost.io/api/v0'
977
+ : 'https://cardano-preview.blockfrost.io/api/v0';
978
+ const reqUrl = apiBase + url;
979
+ const headers = {
980
+ project_id: credentials.projectId,
981
+ };
982
+ let gotOptions = {
983
+ method: 'GET',
984
+ headers,
985
+ responseType: 'json',
986
+ };
987
+ if (params && Object.keys(params).length > 0) {
988
+ gotOptions.searchParams = params;
989
+ }
990
+ const response = await (0, got_1.default)(reqUrl, gotOptions);
991
+ const body = response.body;
992
+ if (Array.isArray(body)) {
993
+ responseData = body;
994
+ }
995
+ else if (typeof body === 'object' && body !== null) {
996
+ responseData = [body];
997
+ }
998
+ else {
999
+ responseData = [{ result: body }];
1000
+ }
1001
+ }
1002
+ else if (category === 'health') {
1003
+ switch (operation) {
1004
+ case 'root':
1005
+ responseData = [await blockfrost.root()];
1006
+ break;
1007
+ case 'health':
1008
+ responseData = [await blockfrost.health()];
1009
+ break;
1010
+ case 'clock':
1011
+ responseData = [await blockfrost.healthClock()];
1012
+ break;
1013
+ default:
1014
+ throw new Error(`Unknown operation: ${operation}`);
1015
+ }
1016
+ }
1017
+ else if (category === 'metrics') {
1018
+ switch (operation) {
1019
+ case 'usage':
1020
+ responseData = await blockfrost.metrics();
1021
+ break;
1022
+ case 'endpoints':
1023
+ responseData = await blockfrost.metricsEndpoints();
1024
+ break;
1025
+ default:
1026
+ throw new Error(`Unknown operation: ${operation}`);
1027
+ }
1028
+ }
1029
+ else if (category === 'accounts') {
1030
+ const stakeAddress = this.getNodeParameter('stakeAddress', 0);
1031
+ switch (operation) {
1032
+ case 'getAccount':
1033
+ responseData = [await blockfrost.accounts(stakeAddress)];
1034
+ break;
1035
+ case 'getRewards':
1036
+ responseData = await blockfrost.accountsRewards(stakeAddress);
1037
+ break;
1038
+ case 'getHistory':
1039
+ responseData = await blockfrost.accountsHistory(stakeAddress);
1040
+ break;
1041
+ case 'getDelegations':
1042
+ responseData = await blockfrost.accountsDelegations(stakeAddress);
1043
+ break;
1044
+ case 'getRegistrations':
1045
+ responseData = await blockfrost.accountsRegistrations(stakeAddress);
1046
+ break;
1047
+ case 'getWithdrawals':
1048
+ responseData = await blockfrost.accountsWithdrawals(stakeAddress);
1049
+ break;
1050
+ case 'getMirs':
1051
+ responseData = await blockfrost.accountsMirs(stakeAddress);
1052
+ break;
1053
+ case 'getAddresses':
1054
+ responseData = await blockfrost.accountsAddresses(stakeAddress);
1055
+ break;
1056
+ case 'getAddressesAssets':
1057
+ responseData = await blockfrost.accountsAddressesAssets(stakeAddress);
1058
+ break;
1059
+ case 'getAddressesTotal':
1060
+ responseData = [await blockfrost.accountsAddressesTotal(stakeAddress)];
1061
+ break;
1062
+ case 'getUtxos':
1063
+ if (typeof blockfrost.request === 'function') {
1064
+ responseData = await blockfrost.request(`/accounts/${stakeAddress}/utxos`);
1065
+ }
1066
+ else if (typeof blockfrost._request === 'function') {
1067
+ responseData = await blockfrost._request('GET', `/accounts/${stakeAddress}/utxos`);
1068
+ }
1069
+ else {
1070
+ throw new Error('accountsUtxos method not available in Blockfrost SDK.');
1071
+ }
1072
+ break;
1073
+ default:
1074
+ throw new Error(`Unknown operation: ${operation}`);
1075
+ }
1076
+ }
1077
+ else if (category === 'addresses') {
1078
+ const address = this.getNodeParameter('address', 0);
1079
+ switch (operation) {
1080
+ case 'getAddress':
1081
+ responseData = [await blockfrost.addresses(address)];
1082
+ break;
1083
+ case 'getAddressExtended':
1084
+ responseData = [await blockfrost.addressesExtended(address)];
1085
+ break;
1086
+ case 'getAddressTotal':
1087
+ responseData = [await blockfrost.addressesTotal(address)];
1088
+ break;
1089
+ case 'getAddressUtxos':
450
1090
  responseData = await blockfrost.addressesUtxos(address);
451
1091
  break;
452
- case 'getAddressUtxosAsset': {
453
- const asset = this.getNodeParameter('asset', 0);
454
- if (!asset)
455
- throw new Error('Asset is required for this operation.');
456
- if (typeof blockfrost.request === 'function') {
457
- responseData = await blockfrost.request(`/addresses/${address}/utxos/${asset}`);
458
- }
459
- else if (typeof blockfrost._request === 'function') {
460
- responseData = await blockfrost._request('GET', `/addresses/${address}/utxos/${asset}`);
461
- }
462
- else {
463
- throw new Error('addressesUtxosAsset method not available in Blockfrost SDK.');
464
- }
1092
+ case 'getAddressUtxosAsset': {
1093
+ const asset = this.getNodeParameter('asset', 0);
1094
+ if (!asset)
1095
+ throw new Error('Asset is required for this operation.');
1096
+ if (typeof blockfrost.request === 'function') {
1097
+ responseData = await blockfrost.request(`/addresses/${address}/utxos/${asset}`);
1098
+ }
1099
+ else if (typeof blockfrost._request === 'function') {
1100
+ responseData = await blockfrost._request('GET', `/addresses/${address}/utxos/${asset}`);
1101
+ }
1102
+ else {
1103
+ throw new Error('addressesUtxosAsset method not available in Blockfrost SDK.');
1104
+ }
1105
+ break;
1106
+ }
1107
+ case 'getAddressTransactions':
1108
+ responseData = await blockfrost.addressesTransactions(address);
1109
+ break;
1110
+ default:
1111
+ throw new Error(`Unknown operation: ${operation}`);
1112
+ }
1113
+ }
1114
+ else if (category === 'blocks') {
1115
+ const count = this.getNodeParameter('count', 0, 100);
1116
+ const page = this.getNodeParameter('page', 0, 1);
1117
+ const order = this.getNodeParameter('order', 0, 'asc');
1118
+ let url = '';
1119
+ let params = {};
1120
+ switch (operation) {
1121
+ case 'getLatestBlock':
1122
+ url = '/blocks/latest';
1123
+ break;
1124
+ case 'getLatestBlockTxs':
1125
+ url = '/blocks/latest/txs';
1126
+ params = { count, page, order };
1127
+ break;
1128
+ case 'getLatestBlockTxsCbor':
1129
+ url = '/blocks/latest/txs/cbor';
1130
+ params = { count, page, order };
1131
+ break;
1132
+ case 'getBlock': {
1133
+ const hashOrNumber = this.getNodeParameter('hashOrNumber', 0);
1134
+ url = `/blocks/${hashOrNumber}`;
1135
+ break;
1136
+ }
1137
+ case 'getNextBlocks': {
1138
+ const hashOrNumber = this.getNodeParameter('hashOrNumber', 0);
1139
+ url = `/blocks/${hashOrNumber}/next`;
1140
+ params = { count, page };
1141
+ break;
1142
+ }
1143
+ case 'getPreviousBlocks': {
1144
+ const hashOrNumber = this.getNodeParameter('hashOrNumber', 0);
1145
+ url = `/blocks/${hashOrNumber}/previous`;
1146
+ params = { count, page };
1147
+ break;
1148
+ }
1149
+ case 'getBlockInSlot': {
1150
+ const slotNumber = this.getNodeParameter('slotNumber', 0);
1151
+ if (slotNumber < 0) {
1152
+ throw new Error('Slot number must be non-negative');
1153
+ }
1154
+ url = `/blocks/slot/${slotNumber}`;
1155
+ break;
1156
+ }
1157
+ case 'getBlockInEpochSlot': {
1158
+ const epochNumber = this.getNodeParameter('epochNumber', 0);
1159
+ const slotNumber = this.getNodeParameter('epochSlotNumber', 0);
1160
+ if (epochNumber < 0) {
1161
+ throw new Error('Epoch number must be non-negative');
1162
+ }
1163
+ if (slotNumber < 0) {
1164
+ throw new Error('Slot number must be non-negative');
1165
+ }
1166
+ url = `/blocks/epoch/${epochNumber}/slot/${slotNumber}`;
1167
+ break;
1168
+ }
1169
+ case 'getBlockTxs': {
1170
+ const hashOrNumber = this.getNodeParameter('hashOrNumber', 0);
1171
+ if (!hashOrNumber || hashOrNumber.trim() === '') {
1172
+ throw new Error('Block hash or number is required');
1173
+ }
1174
+ url = `/blocks/${hashOrNumber}/txs`;
1175
+ params = { count, page, order };
1176
+ break;
1177
+ }
1178
+ case 'getBlockTxsCbor': {
1179
+ const hashOrNumber = this.getNodeParameter('hashOrNumber', 0);
1180
+ if (!hashOrNumber || hashOrNumber.trim() === '') {
1181
+ throw new Error('Block hash or number is required');
1182
+ }
1183
+ url = `/blocks/${hashOrNumber}/txs/cbor`;
1184
+ params = { count, page, order };
1185
+ break;
1186
+ }
1187
+ case 'getBlockAddresses': {
1188
+ const hashOrNumber = this.getNodeParameter('hashOrNumber', 0);
1189
+ if (!hashOrNumber || hashOrNumber.trim() === '') {
1190
+ throw new Error('Block hash or number is required');
1191
+ }
1192
+ url = `/blocks/${hashOrNumber}/addresses`;
1193
+ params = { count, page, order };
1194
+ break;
1195
+ }
1196
+ default:
1197
+ throw new Error(`Unknown blocks operation: ${operation}`);
1198
+ }
1199
+ const apiBase = credentials.network === 'mainnet'
1200
+ ? 'https://cardano-mainnet.blockfrost.io/api/v0'
1201
+ : credentials.network === 'preprod'
1202
+ ? 'https://cardano-preprod.blockfrost.io/api/v0'
1203
+ : 'https://cardano-preview.blockfrost.io/api/v0';
1204
+ const reqUrl = apiBase + url;
1205
+ const headers = {
1206
+ project_id: credentials.projectId,
1207
+ };
1208
+ let gotOptions = {
1209
+ method: 'GET',
1210
+ headers,
1211
+ responseType: 'json',
1212
+ };
1213
+ if (params && Object.keys(params).length > 0) {
1214
+ gotOptions.searchParams = params;
1215
+ }
1216
+ const response = await (0, got_1.default)(reqUrl, gotOptions);
1217
+ const body = response.body;
1218
+ if (Array.isArray(body)) {
1219
+ responseData = body;
1220
+ }
1221
+ else if (typeof body === 'object' && body !== null) {
1222
+ responseData = [body];
1223
+ }
1224
+ else {
1225
+ responseData = [{ result: body }];
1226
+ }
1227
+ }
1228
+ else if (category === 'epochs') {
1229
+ const count = this.getNodeParameter('count', 0, 100);
1230
+ const page = this.getNodeParameter('page', 0, 1);
1231
+ const order = this.getNodeParameter('order', 0, 'asc');
1232
+ let url = '';
1233
+ let params = {};
1234
+ switch (operation) {
1235
+ case 'getLatestEpoch':
1236
+ url = '/epochs/latest';
1237
+ break;
1238
+ case 'getLatestEpochParameters':
1239
+ url = '/epochs/latest/parameters';
1240
+ break;
1241
+ case 'getEpoch': {
1242
+ const epochNumber = this.getNodeParameter('epochNumber', 0);
1243
+ url = `/epochs/${epochNumber}`;
1244
+ break;
1245
+ }
1246
+ case 'getNextEpochs': {
1247
+ const epochNumber = this.getNodeParameter('epochNumber', 0);
1248
+ url = `/epochs/${epochNumber}/next`;
1249
+ params = { count, page };
1250
+ break;
1251
+ }
1252
+ case 'getPreviousEpochs': {
1253
+ const epochNumber = this.getNodeParameter('epochNumber', 0);
1254
+ url = `/epochs/${epochNumber}/previous`;
1255
+ params = { count, page };
1256
+ break;
1257
+ }
1258
+ case 'getEpochStakes': {
1259
+ const epochNumber = this.getNodeParameter('epochNumber', 0);
1260
+ url = `/epochs/${epochNumber}/stakes`;
1261
+ params = { count, page };
1262
+ break;
1263
+ }
1264
+ case 'getEpochStakesByPool': {
1265
+ const epochNumber = this.getNodeParameter('epochNumber', 0);
1266
+ const poolId = this.getNodeParameter('poolId', 0);
1267
+ url = `/epochs/${epochNumber}/stakes/${poolId}`;
1268
+ params = { count, page };
1269
+ break;
1270
+ }
1271
+ case 'getEpochBlocks': {
1272
+ const epochNumber = this.getNodeParameter('epochNumber', 0);
1273
+ url = `/epochs/${epochNumber}/blocks`;
1274
+ params = { count, page, order };
1275
+ break;
1276
+ }
1277
+ case 'getEpochBlocksByPool': {
1278
+ const epochNumber = this.getNodeParameter('epochNumber', 0);
1279
+ const poolId = this.getNodeParameter('poolId', 0);
1280
+ url = `/epochs/${epochNumber}/blocks/${poolId}`;
1281
+ params = { count, page, order };
1282
+ break;
1283
+ }
1284
+ case 'getEpochParameters': {
1285
+ const epochNumber = this.getNodeParameter('epochNumber', 0);
1286
+ url = `/epochs/${epochNumber}/parameters`;
1287
+ break;
1288
+ }
1289
+ default:
1290
+ throw new Error(`Unknown epochs operation: ${operation}`);
1291
+ }
1292
+ const apiBase = credentials.network === 'mainnet'
1293
+ ? 'https://cardano-mainnet.blockfrost.io/api/v0'
1294
+ : credentials.network === 'preprod'
1295
+ ? 'https://cardano-preprod.blockfrost.io/api/v0'
1296
+ : 'https://cardano-preview.blockfrost.io/api/v0';
1297
+ const reqUrl = apiBase + url;
1298
+ const headers = { project_id: credentials.projectId };
1299
+ let gotOptions = { method: 'GET', headers, responseType: 'json' };
1300
+ if (params && Object.keys(params).length > 0) {
1301
+ gotOptions.searchParams = params;
1302
+ }
1303
+ const response = await (0, got_1.default)(reqUrl, gotOptions);
1304
+ const body = response.body;
1305
+ if (Array.isArray(body)) {
1306
+ responseData = body;
1307
+ }
1308
+ else if (typeof body === 'object' && body !== null) {
1309
+ responseData = [body];
1310
+ }
1311
+ else {
1312
+ responseData = [{ result: body }];
1313
+ }
1314
+ }
1315
+ else if (category === 'governance') {
1316
+ const count = this.getNodeParameter('count', 0, 100);
1317
+ const page = this.getNodeParameter('page', 0, 1);
1318
+ const order = this.getNodeParameter('order', 0, 'asc');
1319
+ let url = '';
1320
+ let params = {};
1321
+ switch (operation) {
1322
+ case 'listDreps':
1323
+ url = '/governance/dreps';
1324
+ params = { count, page, order };
1325
+ break;
1326
+ case 'getDrep': {
1327
+ const drepId = this.getNodeParameter('drepId', 0);
1328
+ url = `/governance/dreps/${drepId}`;
1329
+ break;
1330
+ }
1331
+ case 'getDrepDelegators': {
1332
+ const drepId = this.getNodeParameter('drepId', 0);
1333
+ url = `/governance/dreps/${drepId}/delegators`;
1334
+ params = { count, page, order };
1335
+ break;
1336
+ }
1337
+ case 'getDrepMetadata': {
1338
+ const drepId = this.getNodeParameter('drepId', 0);
1339
+ url = `/governance/dreps/${drepId}/metadata`;
1340
+ break;
1341
+ }
1342
+ case 'getDrepUpdates': {
1343
+ const drepId = this.getNodeParameter('drepId', 0);
1344
+ url = `/governance/dreps/${drepId}/updates`;
1345
+ params = { count, page, order };
1346
+ break;
1347
+ }
1348
+ case 'getDrepVotes': {
1349
+ const drepId = this.getNodeParameter('drepId', 0);
1350
+ url = `/governance/dreps/${drepId}/votes`;
1351
+ params = { count, page, order };
1352
+ break;
1353
+ }
1354
+ case 'listProposals':
1355
+ url = '/governance/proposals';
1356
+ params = { count, page, order };
1357
+ break;
1358
+ case 'getProposal': {
1359
+ const txHash = this.getNodeParameter('txHash', 0);
1360
+ const certIndex = this.getNodeParameter('certIndex', 0);
1361
+ url = `/governance/proposals/${txHash}/${certIndex}`;
1362
+ break;
1363
+ }
1364
+ case 'getProposalParameters': {
1365
+ const txHash = this.getNodeParameter('txHash', 0);
1366
+ const certIndex = this.getNodeParameter('certIndex', 0);
1367
+ url = `/governance/proposals/${txHash}/${certIndex}/parameters`;
1368
+ break;
1369
+ }
1370
+ case 'getProposalWithdrawals': {
1371
+ const txHash = this.getNodeParameter('txHash', 0);
1372
+ const certIndex = this.getNodeParameter('certIndex', 0);
1373
+ url = `/governance/proposals/${txHash}/${certIndex}/withdrawals`;
1374
+ params = { count, page, order };
1375
+ break;
1376
+ }
1377
+ case 'getProposalVotes': {
1378
+ const txHash = this.getNodeParameter('txHash', 0);
1379
+ const certIndex = this.getNodeParameter('certIndex', 0);
1380
+ url = `/governance/proposals/${txHash}/${certIndex}/votes`;
1381
+ params = { count, page, order };
1382
+ break;
1383
+ }
1384
+ case 'getProposalMetadata': {
1385
+ const txHash = this.getNodeParameter('txHash', 0);
1386
+ const certIndex = this.getNodeParameter('certIndex', 0);
1387
+ url = `/governance/proposals/${txHash}/${certIndex}/metadata`;
1388
+ break;
1389
+ }
1390
+ default:
1391
+ throw new Error(`Unknown governance operation: ${operation}`);
1392
+ }
1393
+ const apiBase = credentials.network === 'mainnet'
1394
+ ? 'https://cardano-mainnet.blockfrost.io/api/v0'
1395
+ : credentials.network === 'preprod'
1396
+ ? 'https://cardano-preprod.blockfrost.io/api/v0'
1397
+ : 'https://cardano-preview.blockfrost.io/api/v0';
1398
+ const reqUrl = apiBase + url;
1399
+ const headers = { project_id: credentials.projectId };
1400
+ let gotOptions = { method: 'GET', headers, responseType: 'json' };
1401
+ if (params && Object.keys(params).length > 0) {
1402
+ gotOptions.searchParams = params;
1403
+ }
1404
+ const response = await (0, got_1.default)(reqUrl, gotOptions);
1405
+ const body = response.body;
1406
+ if (Array.isArray(body)) {
1407
+ responseData = body;
1408
+ }
1409
+ else if (typeof body === 'object' && body !== null) {
1410
+ responseData = [body];
1411
+ }
1412
+ else {
1413
+ responseData = [{ result: body }];
1414
+ }
1415
+ }
1416
+ else if (category === 'ledger') {
1417
+ switch (operation) {
1418
+ case 'getGenesis':
1419
+ responseData = [await blockfrost.genesis()];
1420
+ break;
1421
+ default:
1422
+ throw new Error(`Unknown ledger operation: ${operation}`);
1423
+ }
1424
+ }
1425
+ else if (category === 'mempool') {
1426
+ const count = this.getNodeParameter('count', 0, 100);
1427
+ const page = this.getNodeParameter('page', 0, 1);
1428
+ const order = this.getNodeParameter('order', 0, 'asc');
1429
+ let url = '';
1430
+ let params = {};
1431
+ switch (operation) {
1432
+ case 'getMempool':
1433
+ url = '/mempool';
1434
+ params = { count, page, order };
1435
+ break;
1436
+ case 'getMempoolTx': {
1437
+ const txHash = this.getNodeParameter('txHash', 0);
1438
+ url = `/mempool/${txHash}`;
465
1439
  break;
466
1440
  }
467
- case 'getAddressTransactions':
468
- responseData = await blockfrost.addressesTransactions(address);
1441
+ case 'getMempoolByAddress': {
1442
+ const address = this.getNodeParameter('address', 0);
1443
+ url = `/mempool/addresses/${address}`;
1444
+ params = { count, page, order };
469
1445
  break;
1446
+ }
470
1447
  default:
471
- throw new Error(`Unknown operation: ${operation}`);
1448
+ throw new Error(`Unknown mempool operation: ${operation}`);
1449
+ }
1450
+ const apiBase = credentials.network === 'mainnet'
1451
+ ? 'https://cardano-mainnet.blockfrost.io/api/v0'
1452
+ : credentials.network === 'preprod'
1453
+ ? 'https://cardano-preprod.blockfrost.io/api/v0'
1454
+ : 'https://cardano-preview.blockfrost.io/api/v0';
1455
+ const reqUrl = apiBase + url;
1456
+ const headers = { project_id: credentials.projectId };
1457
+ let gotOptions = { method: 'GET', headers, responseType: 'json' };
1458
+ if (params && Object.keys(params).length > 0) {
1459
+ gotOptions.searchParams = params;
1460
+ }
1461
+ const response = await (0, got_1.default)(reqUrl, gotOptions);
1462
+ const body = response.body;
1463
+ if (Array.isArray(body)) {
1464
+ responseData = body;
1465
+ }
1466
+ else if (typeof body === 'object' && body !== null) {
1467
+ responseData = [body];
1468
+ }
1469
+ else {
1470
+ responseData = [{ result: body }];
1471
+ }
1472
+ }
1473
+ else if (category === 'metadata') {
1474
+ const count = this.getNodeParameter('count', 0, 100);
1475
+ const page = this.getNodeParameter('page', 0, 1);
1476
+ const order = this.getNodeParameter('order', 0, 'asc');
1477
+ let url = '';
1478
+ let params = {};
1479
+ switch (operation) {
1480
+ case 'getTxMetadataLabels':
1481
+ url = '/metadata/txs/labels';
1482
+ params = { count, page, order };
1483
+ break;
1484
+ case 'getTxMetadataByLabelJson': {
1485
+ const label = this.getNodeParameter('label', 0);
1486
+ url = `/metadata/txs/labels/${label}`;
1487
+ params = { count, page, order };
1488
+ break;
1489
+ }
1490
+ case 'getTxMetadataByLabelCbor': {
1491
+ const label = this.getNodeParameter('label', 0);
1492
+ url = `/metadata/txs/labels/${label}/cbor`;
1493
+ params = { count, page, order };
1494
+ break;
1495
+ }
1496
+ default:
1497
+ throw new Error(`Unknown metadata operation: ${operation}`);
1498
+ }
1499
+ const apiBase = credentials.network === 'mainnet'
1500
+ ? 'https://cardano-mainnet.blockfrost.io/api/v0'
1501
+ : credentials.network === 'preprod'
1502
+ ? 'https://cardano-preprod.blockfrost.io/api/v0'
1503
+ : 'https://cardano-preview.blockfrost.io/api/v0';
1504
+ const reqUrl = apiBase + url;
1505
+ const headers = { project_id: credentials.projectId };
1506
+ let gotOptions = { method: 'GET', headers, responseType: 'json' };
1507
+ if (params && Object.keys(params).length > 0) {
1508
+ gotOptions.searchParams = params;
1509
+ }
1510
+ const response = await (0, got_1.default)(reqUrl, gotOptions);
1511
+ const body = response.body;
1512
+ if (Array.isArray(body)) {
1513
+ responseData = body;
1514
+ }
1515
+ else if (typeof body === 'object' && body !== null) {
1516
+ responseData = [body];
1517
+ }
1518
+ else {
1519
+ responseData = [{ result: body }];
1520
+ }
1521
+ }
1522
+ else if (category === 'network') {
1523
+ switch (operation) {
1524
+ case 'getNetworkInfo':
1525
+ responseData = [await blockfrost.network()];
1526
+ break;
1527
+ case 'getNetworkEras':
1528
+ responseData = await blockfrost.networkEras();
1529
+ break;
1530
+ default:
1531
+ throw new Error(`Unknown network operation: ${operation}`);
1532
+ }
1533
+ }
1534
+ else if (category === 'pools') {
1535
+ const count = this.getNodeParameter('count', 0, 100);
1536
+ const page = this.getNodeParameter('page', 0, 1);
1537
+ const order = this.getNodeParameter('order', 0, 'asc');
1538
+ let url = '';
1539
+ let params = {};
1540
+ switch (operation) {
1541
+ case 'listPools':
1542
+ url = '/pools';
1543
+ params = { count, page, order };
1544
+ break;
1545
+ case 'listPoolsExtended':
1546
+ url = '/pools/extended';
1547
+ params = { count, page, order };
1548
+ break;
1549
+ case 'listRetiredPools':
1550
+ url = '/pools/retired';
1551
+ params = { count, page, order };
1552
+ break;
1553
+ case 'listRetiringPools':
1554
+ url = '/pools/retiring';
1555
+ params = { count, page, order };
1556
+ break;
1557
+ case 'getPool': {
1558
+ const poolId = this.getNodeParameter('poolId', 0);
1559
+ url = `/pools/${poolId}`;
1560
+ break;
1561
+ }
1562
+ case 'getPoolHistory': {
1563
+ const poolId = this.getNodeParameter('poolId', 0);
1564
+ url = `/pools/${poolId}/history`;
1565
+ params = { count, page, order };
1566
+ break;
1567
+ }
1568
+ case 'getPoolMetadata': {
1569
+ const poolId = this.getNodeParameter('poolId', 0);
1570
+ url = `/pools/${poolId}/metadata`;
1571
+ break;
1572
+ }
1573
+ case 'getPoolRelays': {
1574
+ const poolId = this.getNodeParameter('poolId', 0);
1575
+ url = `/pools/${poolId}/relays`;
1576
+ break;
1577
+ }
1578
+ case 'getPoolDelegators': {
1579
+ const poolId = this.getNodeParameter('poolId', 0);
1580
+ url = `/pools/${poolId}/delegators`;
1581
+ params = { count, page, order };
1582
+ break;
1583
+ }
1584
+ case 'getPoolBlocks': {
1585
+ const poolId = this.getNodeParameter('poolId', 0);
1586
+ url = `/pools/${poolId}/blocks`;
1587
+ params = { count, page, order };
1588
+ break;
1589
+ }
1590
+ case 'getPoolUpdates': {
1591
+ const poolId = this.getNodeParameter('poolId', 0);
1592
+ url = `/pools/${poolId}/updates`;
1593
+ params = { count, page, order };
1594
+ break;
1595
+ }
1596
+ case 'getPoolVotes': {
1597
+ const poolId = this.getNodeParameter('poolId', 0);
1598
+ url = `/pools/${poolId}/votes`;
1599
+ params = { count, page, order };
1600
+ break;
1601
+ }
1602
+ default:
1603
+ throw new Error(`Unknown pools operation: ${operation}`);
1604
+ }
1605
+ const apiBase = credentials.network === 'mainnet'
1606
+ ? 'https://cardano-mainnet.blockfrost.io/api/v0'
1607
+ : credentials.network === 'preprod'
1608
+ ? 'https://cardano-preprod.blockfrost.io/api/v0'
1609
+ : 'https://cardano-preview.blockfrost.io/api/v0';
1610
+ const reqUrl = apiBase + url;
1611
+ const headers = { project_id: credentials.projectId };
1612
+ let gotOptions = { method: 'GET', headers, responseType: 'json' };
1613
+ if (params && Object.keys(params).length > 0) {
1614
+ gotOptions.searchParams = params;
1615
+ }
1616
+ const response = await (0, got_1.default)(reqUrl, gotOptions);
1617
+ const body = response.body;
1618
+ if (Array.isArray(body)) {
1619
+ responseData = body;
1620
+ }
1621
+ else if (typeof body === 'object' && body !== null) {
1622
+ responseData = [body];
1623
+ }
1624
+ else {
1625
+ responseData = [{ result: body }];
1626
+ }
1627
+ }
1628
+ else if (category === 'scripts') {
1629
+ const count = this.getNodeParameter('count', 0, 100);
1630
+ const page = this.getNodeParameter('page', 0, 1);
1631
+ const order = this.getNodeParameter('order', 0, 'asc');
1632
+ let url = '';
1633
+ let params = {};
1634
+ switch (operation) {
1635
+ case 'listScripts':
1636
+ url = '/scripts';
1637
+ params = { count, page, order };
1638
+ break;
1639
+ case 'getScript': {
1640
+ const scriptHash = this.getNodeParameter('scriptHash', 0);
1641
+ url = `/scripts/${scriptHash}`;
1642
+ break;
1643
+ }
1644
+ case 'getScriptJson': {
1645
+ const scriptHash = this.getNodeParameter('scriptHash', 0);
1646
+ url = `/scripts/${scriptHash}/json`;
1647
+ break;
1648
+ }
1649
+ case 'getScriptCbor': {
1650
+ const scriptHash = this.getNodeParameter('scriptHash', 0);
1651
+ url = `/scripts/${scriptHash}/cbor`;
1652
+ break;
1653
+ }
1654
+ case 'getScriptRedeemers': {
1655
+ const scriptHash = this.getNodeParameter('scriptHash', 0);
1656
+ url = `/scripts/${scriptHash}/redeemers`;
1657
+ params = { count, page, order };
1658
+ break;
1659
+ }
1660
+ case 'getDatum': {
1661
+ const datumHash = this.getNodeParameter('datumHash', 0);
1662
+ url = `/scripts/datum/${datumHash}`;
1663
+ break;
1664
+ }
1665
+ case 'getDatumCbor': {
1666
+ const datumHash = this.getNodeParameter('datumHash', 0);
1667
+ url = `/scripts/datum/${datumHash}/cbor`;
1668
+ break;
1669
+ }
1670
+ default:
1671
+ throw new Error(`Unknown scripts operation: ${operation}`);
1672
+ }
1673
+ const apiBase = credentials.network === 'mainnet'
1674
+ ? 'https://cardano-mainnet.blockfrost.io/api/v0'
1675
+ : credentials.network === 'preprod'
1676
+ ? 'https://cardano-preprod.blockfrost.io/api/v0'
1677
+ : 'https://cardano-preview.blockfrost.io/api/v0';
1678
+ const reqUrl = apiBase + url;
1679
+ const headers = { project_id: credentials.projectId };
1680
+ let gotOptions = { method: 'GET', headers, responseType: 'json' };
1681
+ if (params && Object.keys(params).length > 0) {
1682
+ gotOptions.searchParams = params;
1683
+ }
1684
+ const response = await (0, got_1.default)(reqUrl, gotOptions);
1685
+ const body = response.body;
1686
+ if (Array.isArray(body)) {
1687
+ responseData = body;
1688
+ }
1689
+ else if (typeof body === 'object' && body !== null) {
1690
+ responseData = [body];
1691
+ }
1692
+ else {
1693
+ responseData = [{ result: body }];
1694
+ }
1695
+ }
1696
+ else if (category === 'transactions') {
1697
+ let url = '';
1698
+ let method = 'GET';
1699
+ let requestBody = null;
1700
+ switch (operation) {
1701
+ case 'getTransaction': {
1702
+ const txHash = this.getNodeParameter('txHash', 0);
1703
+ url = `/txs/${txHash}`;
1704
+ break;
1705
+ }
1706
+ case 'getTransactionUtxos': {
1707
+ const txHash = this.getNodeParameter('txHash', 0);
1708
+ url = `/txs/${txHash}/utxos`;
1709
+ break;
1710
+ }
1711
+ case 'getTransactionStakes': {
1712
+ const txHash = this.getNodeParameter('txHash', 0);
1713
+ url = `/txs/${txHash}/stakes`;
1714
+ break;
1715
+ }
1716
+ case 'getTransactionDelegations': {
1717
+ const txHash = this.getNodeParameter('txHash', 0);
1718
+ url = `/txs/${txHash}/delegations`;
1719
+ break;
1720
+ }
1721
+ case 'getTransactionWithdrawals': {
1722
+ const txHash = this.getNodeParameter('txHash', 0);
1723
+ url = `/txs/${txHash}/withdrawals`;
1724
+ break;
1725
+ }
1726
+ case 'getTransactionMirs': {
1727
+ const txHash = this.getNodeParameter('txHash', 0);
1728
+ url = `/txs/${txHash}/mirs`;
1729
+ break;
1730
+ }
1731
+ case 'getTransactionPoolUpdates': {
1732
+ const txHash = this.getNodeParameter('txHash', 0);
1733
+ url = `/txs/${txHash}/pool_updates`;
1734
+ break;
1735
+ }
1736
+ case 'getTransactionPoolRetires': {
1737
+ const txHash = this.getNodeParameter('txHash', 0);
1738
+ url = `/txs/${txHash}/pool_retires`;
1739
+ break;
1740
+ }
1741
+ case 'getTransactionMetadata': {
1742
+ const txHash = this.getNodeParameter('txHash', 0);
1743
+ url = `/txs/${txHash}/metadata`;
1744
+ break;
1745
+ }
1746
+ case 'getTransactionMetadataCbor': {
1747
+ const txHash = this.getNodeParameter('txHash', 0);
1748
+ url = `/txs/${txHash}/metadata/cbor`;
1749
+ break;
1750
+ }
1751
+ case 'getTransactionRedeemers': {
1752
+ const txHash = this.getNodeParameter('txHash', 0);
1753
+ url = `/txs/${txHash}/redeemers`;
1754
+ break;
1755
+ }
1756
+ case 'getTransactionRequiredSigners': {
1757
+ const txHash = this.getNodeParameter('txHash', 0);
1758
+ url = `/txs/${txHash}/required_signers`;
1759
+ break;
1760
+ }
1761
+ case 'getTransactionCbor': {
1762
+ const txHash = this.getNodeParameter('txHash', 0);
1763
+ url = `/txs/${txHash}/cbor`;
1764
+ break;
1765
+ }
1766
+ case 'submitTransaction': {
1767
+ const transactionCbor = this.getNodeParameter('transactionCbor', 0);
1768
+ url = '/tx/submit';
1769
+ method = 'POST';
1770
+ requestBody = transactionCbor;
1771
+ break;
1772
+ }
1773
+ default:
1774
+ throw new Error(`Unknown transactions operation: ${operation}`);
1775
+ }
1776
+ const apiBase = credentials.network === 'mainnet'
1777
+ ? 'https://cardano-mainnet.blockfrost.io/api/v0'
1778
+ : credentials.network === 'preprod'
1779
+ ? 'https://cardano-preprod.blockfrost.io/api/v0'
1780
+ : 'https://cardano-preview.blockfrost.io/api/v0';
1781
+ const reqUrl = apiBase + url;
1782
+ const headers = {
1783
+ project_id: credentials.projectId,
1784
+ };
1785
+ if (method === 'POST') {
1786
+ headers['Content-Type'] = 'application/cbor';
1787
+ }
1788
+ let gotOptions = { method, headers, responseType: 'json' };
1789
+ if (requestBody) {
1790
+ gotOptions.body = requestBody;
1791
+ }
1792
+ const response = await (0, got_1.default)(reqUrl, gotOptions);
1793
+ const body = response.body;
1794
+ if (Array.isArray(body)) {
1795
+ responseData = body;
1796
+ }
1797
+ else if (typeof body === 'object' && body !== null) {
1798
+ responseData = [body];
1799
+ }
1800
+ else {
1801
+ responseData = [{ result: body }];
1802
+ }
1803
+ }
1804
+ else if (category === 'utilities') {
1805
+ let url = '';
1806
+ let method = 'GET';
1807
+ let requestBody = null;
1808
+ switch (operation) {
1809
+ case 'deriveAddress': {
1810
+ const xpub = this.getNodeParameter('xpub', 0);
1811
+ const role = this.getNodeParameter('role', 0);
1812
+ const index = this.getNodeParameter('index', 0);
1813
+ url = `/utils/addresses/xpub/${xpub}/${role}/${index}`;
1814
+ break;
1815
+ }
1816
+ case 'evaluateTransaction': {
1817
+ const transactionCbor = this.getNodeParameter('transactionCbor', 0);
1818
+ url = '/utils/txs/evaluate';
1819
+ method = 'POST';
1820
+ requestBody = transactionCbor;
1821
+ break;
1822
+ }
1823
+ case 'evaluateTransactionUtxos': {
1824
+ const transactionCbor = this.getNodeParameter('transactionCbor', 0);
1825
+ const additionalUtxos = this.getNodeParameter('additionalUtxos', 0, '[]');
1826
+ url = '/utils/txs/evaluate/utxos';
1827
+ method = 'POST';
1828
+ requestBody = JSON.stringify({
1829
+ cbor: transactionCbor,
1830
+ additionalUtxoSet: JSON.parse(additionalUtxos)
1831
+ });
1832
+ break;
1833
+ }
1834
+ default:
1835
+ throw new Error(`Unknown utilities operation: ${operation}`);
1836
+ }
1837
+ const apiBase = credentials.network === 'mainnet'
1838
+ ? 'https://cardano-mainnet.blockfrost.io/api/v0'
1839
+ : credentials.network === 'preprod'
1840
+ ? 'https://cardano-preprod.blockfrost.io/api/v0'
1841
+ : 'https://cardano-preview.blockfrost.io/api/v0';
1842
+ const reqUrl = apiBase + url;
1843
+ const headers = {
1844
+ project_id: credentials.projectId,
1845
+ };
1846
+ if (method === 'POST') {
1847
+ if (operation === 'evaluateTransactionUtxos') {
1848
+ headers['Content-Type'] = 'application/json';
1849
+ }
1850
+ else {
1851
+ headers['Content-Type'] = 'application/cbor';
1852
+ }
1853
+ }
1854
+ let gotOptions = { method, headers, responseType: 'json' };
1855
+ if (requestBody) {
1856
+ gotOptions.body = requestBody;
1857
+ }
1858
+ const response = await (0, got_1.default)(reqUrl, gotOptions);
1859
+ const body = response.body;
1860
+ if (Array.isArray(body)) {
1861
+ responseData = body;
1862
+ }
1863
+ else if (typeof body === 'object' && body !== null) {
1864
+ responseData = [body];
1865
+ }
1866
+ else {
1867
+ responseData = [{ result: body }];
472
1868
  }
473
1869
  }
474
1870
  else {