@ar.io/sdk 2.0.0-alpha.10 → 2.0.0-alpha.11
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.
- package/README.md +178 -138
- package/bundles/web.bundle.min.js +2 -2
- package/lib/cjs/utils/processes.js +8 -3
- package/lib/cjs/version.js +1 -1
- package/lib/esm/utils/processes.js +8 -3
- package/lib/esm/version.js +1 -1
- package/lib/types/utils/processes.d.ts +3 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
25
25
|
- [`getGateway({ address })`](#getgateway-address-)
|
|
26
26
|
- [`getGateways({ cursor, limit, sortBy, sortOrder })`](#getgateways-cursor-limit-sortby-sortorder-)
|
|
27
27
|
- [`getArNSRecord({ name })`](#getarnsrecord-name-)
|
|
28
|
-
- [`getArNSRecords({
|
|
28
|
+
- [`getArNSRecords({ cursor, limit, sortBy, sortOrder })`](#getarnsrecords-cursor-limit-sortby-sortorder-)
|
|
29
29
|
- [`getObservations({ epochIndex })`](#getobservations-epochindex-)
|
|
30
30
|
- [`getDistributions({ epochIndex })`](#getdistributions-epochindex-)
|
|
31
31
|
- [`getEpoch({ epochIndex })`](#getepoch-epochindex-)
|
|
@@ -47,7 +47,7 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
47
47
|
- [Arweave Name Tokens (ANT's)](#arweave-name-tokens-ants)
|
|
48
48
|
|
|
49
49
|
- [ANT APIs](#ant-apis)
|
|
50
|
-
- [`init({ signer})`](#init-signer-)
|
|
50
|
+
- [`init({ processId, signer })`](#init-processid-signer-)
|
|
51
51
|
- [`getInfo()`](#getinfo)
|
|
52
52
|
- [`getOwner()`](#getowner)
|
|
53
53
|
- [`getControllers()`](#getcontrollers)
|
|
@@ -65,6 +65,8 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
65
65
|
|
|
66
66
|
- [Configuration](#configuration)
|
|
67
67
|
|
|
68
|
+
- [Pagination](#pagination)
|
|
69
|
+
|
|
68
70
|
- [Developers](#developers)
|
|
69
71
|
- [Requirements](#requirements)
|
|
70
72
|
- [Setup \& Build](#setup--build)
|
|
@@ -103,37 +105,36 @@ const gateways = await io.getGateways();
|
|
|
103
105
|
|
|
104
106
|
```json
|
|
105
107
|
{
|
|
106
|
-
"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
"stakeWeight": 25,
|
|
130
|
-
"tenureWeight": 0.9031327160493827,
|
|
131
|
-
"gatewayRewardRatioWeight": 0.96875,
|
|
132
|
-
"observerRewardRatioWeight": 0.96875,
|
|
133
|
-
"compositeWeight": 21.189222170982834,
|
|
134
|
-
"normalizedCompositeWeight": 0.27485583057217183
|
|
108
|
+
"items": [
|
|
109
|
+
{
|
|
110
|
+
"gatewayAddress": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
111
|
+
"observerAddress": "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
|
|
112
|
+
"operatorStake": 250000000000,
|
|
113
|
+
"settings": {
|
|
114
|
+
"fqdn": "ar-io.dev",
|
|
115
|
+
"label": "AR.IO Test",
|
|
116
|
+
"note": "Test Gateway operated by PDS for the AR.IO ecosystem.",
|
|
117
|
+
"port": 443,
|
|
118
|
+
"properties": "raJgvbFU-YAnku-WsupIdbTsqqGLQiYpGzoqk9SCVgY",
|
|
119
|
+
"protocol": "https"
|
|
120
|
+
},
|
|
121
|
+
"startTimestamp": 1720720621424,
|
|
122
|
+
"stats": {
|
|
123
|
+
"failedConsecutiveEpochs": 0,
|
|
124
|
+
"passedEpochCount": 30,
|
|
125
|
+
"submittedEpochCount": 30,
|
|
126
|
+
"totalEpochParticipationCount": 31,
|
|
127
|
+
"totalEpochsPrescribedCount": 31
|
|
128
|
+
},
|
|
129
|
+
"status": "joined",
|
|
130
|
+
"vaults": {}
|
|
135
131
|
}
|
|
136
|
-
|
|
132
|
+
],
|
|
133
|
+
"hasMore": true,
|
|
134
|
+
"nextCursor": "-4xgjroXENKYhTWqrBo57HQwvDL51mMdfsdsxJy6Y2Z_sA",
|
|
135
|
+
"totalItems": 316,
|
|
136
|
+
"sortBy": "startTimestamp",
|
|
137
|
+
"sortOrder": "desc"
|
|
137
138
|
}
|
|
138
139
|
```
|
|
139
140
|
|
|
@@ -216,11 +217,9 @@ import { IOToken, mIOToken } from '@ar.io/sdk';
|
|
|
216
217
|
|
|
217
218
|
const ioValue = 1;
|
|
218
219
|
const mIOValue = new IOToken(ioValue).toMIO();
|
|
219
|
-
console.log(mIOValue); // 1000000 (mIO)
|
|
220
220
|
|
|
221
221
|
const mIOValue = 1_000_000;
|
|
222
222
|
const ioValue = new mIOToken(mIOValue).toIO();
|
|
223
|
-
console.log(ioValue); // 1 (IO)
|
|
224
223
|
```
|
|
225
224
|
|
|
226
225
|
## IO Process
|
|
@@ -275,7 +274,7 @@ const io = IO.init();
|
|
|
275
274
|
// the balance will be returned in mIO as a value
|
|
276
275
|
const balance = await io
|
|
277
276
|
.getBalance({
|
|
278
|
-
address: '
|
|
277
|
+
address: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ',
|
|
279
278
|
})
|
|
280
279
|
.then((balance) => new mIOToken().toIO()); // convert it to IO for readability
|
|
281
280
|
```
|
|
@@ -291,7 +290,7 @@ const balance = await io
|
|
|
291
290
|
|
|
292
291
|
#### `getBalances({ cursor, limit, sortBy, sortOrder })`
|
|
293
292
|
|
|
294
|
-
Retrieves the balances of the IO process in `mIO`, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last wallet address from the previous
|
|
293
|
+
Retrieves the balances of the IO process in `mIO`, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last wallet address from the previous request.
|
|
295
294
|
|
|
296
295
|
```typescript
|
|
297
296
|
const io = IO.init();
|
|
@@ -307,20 +306,19 @@ const balances = await io.getBalances({
|
|
|
307
306
|
<summary>Output</summary>
|
|
308
307
|
|
|
309
308
|
```json
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
]
|
|
309
|
+
{
|
|
310
|
+
"items": [
|
|
311
|
+
{
|
|
312
|
+
"address": "-4xgjroXENKYhTWqrBo57HQwvDL51mMvSxJy6Y2Z_sA",
|
|
313
|
+
"balance": 1000000
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
"hasMore": true,
|
|
317
|
+
"nextCursor": "-7vXsQZQDk8TMDlpiSLy3CnLi5PDPlAaN2DaynORpck",
|
|
318
|
+
"totalItems": 1789,
|
|
319
|
+
"sortBy": "balance",
|
|
320
|
+
"sortOrder": "desc"
|
|
321
|
+
}
|
|
324
322
|
```
|
|
325
323
|
|
|
326
324
|
</details>
|
|
@@ -332,7 +330,7 @@ Retrieves a gateway's info by its staking wallet address.
|
|
|
332
330
|
```typescript
|
|
333
331
|
const io = IO.init();
|
|
334
332
|
const gateway = await io.getGateway({
|
|
335
|
-
address: '
|
|
333
|
+
address: '-7vXsQZQDk8TMDlpiSLy3CnLi5PDPlAaN2DaynORpck',
|
|
336
334
|
});
|
|
337
335
|
```
|
|
338
336
|
|
|
@@ -341,8 +339,7 @@ const gateway = await io.getGateway({
|
|
|
341
339
|
|
|
342
340
|
```json
|
|
343
341
|
{
|
|
344
|
-
"
|
|
345
|
-
"observerWallet": "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
|
|
342
|
+
"observerAddress": "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
|
|
346
343
|
"operatorStake": 250000000000,
|
|
347
344
|
"settings": {
|
|
348
345
|
"fqdn": "ar-io.dev",
|
|
@@ -352,7 +349,7 @@ const gateway = await io.getGateway({
|
|
|
352
349
|
"properties": "raJgvbFU-YAnku-WsupIdbTsqqGLQiYpGzoqk9SCVgY",
|
|
353
350
|
"protocol": "https"
|
|
354
351
|
},
|
|
355
|
-
"
|
|
352
|
+
"startTimestamp": 1720720620813,
|
|
356
353
|
"stats": {
|
|
357
354
|
"failedConsecutiveEpochs": 0,
|
|
358
355
|
"passedEpochCount": 30,
|
|
@@ -369,12 +366,12 @@ const gateway = await io.getGateway({
|
|
|
369
366
|
|
|
370
367
|
#### `getGateways({ cursor, limit, sortBy, sortOrder })`
|
|
371
368
|
|
|
372
|
-
Retrieves registered gateways of the IO process, using pagination and sorting by the specified criteria. The `cursor` used for pagination is the last gateway address from the previous
|
|
369
|
+
Retrieves registered gateways of the IO process, using pagination and sorting by the specified criteria. The `cursor` used for pagination is the last gateway address from the previous request.
|
|
373
370
|
|
|
374
371
|
```typescript
|
|
375
372
|
const io = IO.init();
|
|
376
373
|
const gateways = await io.getGateways({
|
|
377
|
-
limit:
|
|
374
|
+
limit: 1,
|
|
378
375
|
sortOrder: 'desc',
|
|
379
376
|
sortBy: 'operatorStake',
|
|
380
377
|
});
|
|
@@ -386,54 +383,38 @@ Available `sortBy` options are any of the keys on the gateway object, e.g. `oper
|
|
|
386
383
|
<summary>Output</summary>
|
|
387
384
|
|
|
388
385
|
```json
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
"
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
"
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
"port": 443,
|
|
422
|
-
"properties": "raJgvbFU-YAnku-WsupIdbTsqqGLQiYpGzoqk9SCVgY",
|
|
423
|
-
"protocol": "https"
|
|
424
|
-
},
|
|
425
|
-
"start": 1256694,
|
|
426
|
-
"stats": {
|
|
427
|
-
"failedConsecutiveEpochs": 0,
|
|
428
|
-
"passedEpochCount": 30,
|
|
429
|
-
"submittedEpochCount": 30,
|
|
430
|
-
"totalEpochParticipationCount": 31,
|
|
431
|
-
"totalEpochsPrescribedCount": 31
|
|
432
|
-
},
|
|
433
|
-
"status": "joined",
|
|
434
|
-
"vaults": {}
|
|
435
|
-
}
|
|
436
|
-
]
|
|
386
|
+
{
|
|
387
|
+
"items": [
|
|
388
|
+
{
|
|
389
|
+
"gatewayAddress": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
390
|
+
"observerAddress": "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
|
|
391
|
+
"operatorStake": 250000000000,
|
|
392
|
+
"settings": {
|
|
393
|
+
"fqdn": "ar-io.dev",
|
|
394
|
+
"label": "AR.IO Test",
|
|
395
|
+
"note": "Test Gateway operated by PDS for the AR.IO ecosystem.",
|
|
396
|
+
"port": 443,
|
|
397
|
+
"properties": "raJgvbFU-YAnku-WsupIdbTsqqGLQiYpGzoqk9SCVgY",
|
|
398
|
+
"protocol": "https"
|
|
399
|
+
},
|
|
400
|
+
"startTimestamp": 1720720620813,
|
|
401
|
+
"stats": {
|
|
402
|
+
"failedConsecutiveEpochs": 0,
|
|
403
|
+
"passedEpochCount": 30,
|
|
404
|
+
"submittedEpochCount": 30,
|
|
405
|
+
"totalEpochParticipationCount": 31,
|
|
406
|
+
"totalEpochsPrescribedCount": 31
|
|
407
|
+
},
|
|
408
|
+
"status": "joined",
|
|
409
|
+
"vaults": {}
|
|
410
|
+
}
|
|
411
|
+
],
|
|
412
|
+
"hasMore": true,
|
|
413
|
+
"nextCursor": "-4xgjroXENKYhTWqrBo57HQwvDL51mMdfsdsxJy6Y2Z_sA",
|
|
414
|
+
"totalItems": 316,
|
|
415
|
+
"sortBy": "operatorStake",
|
|
416
|
+
"sortOrder": "desc"
|
|
417
|
+
}
|
|
437
418
|
```
|
|
438
419
|
|
|
439
420
|
</details>
|
|
@@ -453,8 +434,8 @@ const record = await io.getArNSRecord({ name: 'ardrive' });
|
|
|
453
434
|
```json
|
|
454
435
|
{
|
|
455
436
|
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
456
|
-
"endTimestamp":
|
|
457
|
-
"startTimestamp":
|
|
437
|
+
"endTimestamp": 1752256702026,
|
|
438
|
+
"startTimestamp": 1720720819969,
|
|
458
439
|
"type": "lease",
|
|
459
440
|
"undernames": 100
|
|
460
441
|
}
|
|
@@ -464,13 +445,13 @@ const record = await io.getArNSRecord({ name: 'ardrive' });
|
|
|
464
445
|
|
|
465
446
|
#### `getArNSRecords({ cursor, limit, sortBy, sortOrder })`
|
|
466
447
|
|
|
467
|
-
Retrieves all registered ArNS records of the IO process, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last ArNS name from the previous
|
|
448
|
+
Retrieves all registered ArNS records of the IO process, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last ArNS name from the previous request.
|
|
468
449
|
|
|
469
450
|
```typescript
|
|
470
451
|
const io = IO.init();
|
|
452
|
+
// get the 5 newest names
|
|
471
453
|
const records = await io.getArNSRecords({
|
|
472
|
-
|
|
473
|
-
pageSize: 10,
|
|
454
|
+
limit: 5,
|
|
474
455
|
sortBy: 'startTimestamp',
|
|
475
456
|
sortOrder: 'desc',
|
|
476
457
|
});
|
|
@@ -482,24 +463,55 @@ Available `sortBy` options are any of the keys on the record object, e.g. `name`
|
|
|
482
463
|
<summary>Output</summary>
|
|
483
464
|
|
|
484
465
|
```json
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
466
|
+
{
|
|
467
|
+
"items": [
|
|
468
|
+
{
|
|
469
|
+
"name": "ao",
|
|
470
|
+
"processId": "eNey-H9RB9uCdoJUvPULb35qhZVXZcEXv8xds4aHhkQ",
|
|
471
|
+
"purchasePrice": 75541282285,
|
|
472
|
+
"startTimestamp": 1720720621424,
|
|
473
|
+
"type": "permabuy",
|
|
474
|
+
"undernames": 10
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
"name": "ardrive",
|
|
478
|
+
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
479
|
+
"endTimestamp": 1720720819969,
|
|
480
|
+
"startTimestamp": 1720720620813,
|
|
481
|
+
"type": "lease",
|
|
482
|
+
"undernames": 100
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
"name": "arweave",
|
|
486
|
+
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
487
|
+
"endTimestamp": 1720720819969,
|
|
488
|
+
"startTimestamp": 1720720620800,
|
|
489
|
+
"type": "lease",
|
|
490
|
+
"undernames": 100
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
"name": "ar-io",
|
|
494
|
+
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
495
|
+
"endTimestamp": 1720720819969,
|
|
496
|
+
"startTimestamp": 1720720619000,
|
|
497
|
+
"type": "lease",
|
|
498
|
+
"undernames": 100
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
"name": "fwd",
|
|
502
|
+
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
503
|
+
"endTimestamp": 1720720819969,
|
|
504
|
+
"startTimestamp": 1720720220811,
|
|
505
|
+
"type": "lease",
|
|
506
|
+
"undernames": 100
|
|
507
|
+
}
|
|
508
|
+
],
|
|
509
|
+
"hasMore": true,
|
|
510
|
+
"nextCursor": "fwdresearch",
|
|
511
|
+
"totalItems": 21740,
|
|
512
|
+
"sortBy": "startTimestamp",
|
|
513
|
+
"sortOrder": "desc"
|
|
514
|
+
}
|
|
503
515
|
```
|
|
504
516
|
|
|
505
517
|
</details>
|
|
@@ -553,7 +565,7 @@ const distributions = await io.getDistributions();
|
|
|
553
565
|
{
|
|
554
566
|
"totalEligibleRewards": 100000000,
|
|
555
567
|
"totalDistributedRewards": 100000000,
|
|
556
|
-
"distributedTimestamp":
|
|
568
|
+
"distributedTimestamp": 1720720621424,
|
|
557
569
|
"rewards": {
|
|
558
570
|
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": 100000000
|
|
559
571
|
}
|
|
@@ -577,10 +589,10 @@ const epoch = await io.getEpoch({ epochIndex: 0 });
|
|
|
577
589
|
```json
|
|
578
590
|
{
|
|
579
591
|
"epochIndex": 0,
|
|
580
|
-
"startTimestamp":
|
|
581
|
-
"endTimestamp":
|
|
592
|
+
"startTimestamp": 1720720620813,
|
|
593
|
+
"endTimestamp": 1752256702026,
|
|
582
594
|
"startHeight": 1350700,
|
|
583
|
-
"distributionTimestamp":
|
|
595
|
+
"distributionTimestamp": 1752256702026,
|
|
584
596
|
"observations": {
|
|
585
597
|
"failureSummaries": {
|
|
586
598
|
"-Tk2DDk8k4zkwtppp_XFKKI5oUgh6IEHygAoN7mD-w8": [
|
|
@@ -597,7 +609,7 @@ const epoch = await io.getEpoch({ epochIndex: 0 });
|
|
|
597
609
|
"gatewayAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
598
610
|
"observerAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
599
611
|
"stake": 10000000000, // value in mIO
|
|
600
|
-
"
|
|
612
|
+
"startTimestamp": 1720720620813,
|
|
601
613
|
"stakeWeight": 1,
|
|
602
614
|
"tenureWeight": 0.4494598765432099,
|
|
603
615
|
"gatewayRewardRatioWeight": 1,
|
|
@@ -607,7 +619,7 @@ const epoch = await io.getEpoch({ epochIndex: 0 });
|
|
|
607
619
|
}
|
|
608
620
|
],
|
|
609
621
|
"distributions": {
|
|
610
|
-
"distributedTimestamp":
|
|
622
|
+
"distributedTimestamp": 1752256702026,
|
|
611
623
|
"totalEligibleRewards": 100000000,
|
|
612
624
|
"totoalDistributedRewards": 100000000,
|
|
613
625
|
"rewards": {
|
|
@@ -634,8 +646,8 @@ const epoch = await io.getCurrentEpoch();
|
|
|
634
646
|
```json
|
|
635
647
|
{
|
|
636
648
|
"epochIndex": 0,
|
|
637
|
-
"startTimestamp":
|
|
638
|
-
"endTimestamp":
|
|
649
|
+
"startTimestamp": 1720720621424,
|
|
650
|
+
"endTimestamp": 1752256702026,
|
|
639
651
|
"startHeight": 1350700,
|
|
640
652
|
"distributionTimestamp": 1711122739,
|
|
641
653
|
"observations": {
|
|
@@ -894,7 +906,6 @@ const { id: txId } = await io.transfer(
|
|
|
894
906
|
{
|
|
895
907
|
target: '-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5',
|
|
896
908
|
qty: new IOToken(1000).toMIO(),
|
|
897
|
-
denomination: 'IO',
|
|
898
909
|
},
|
|
899
910
|
// optional additional tags
|
|
900
911
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
@@ -960,7 +971,7 @@ The ANT client class exposes APIs relevant to compliant Arweave Name Token proce
|
|
|
960
971
|
|
|
961
972
|
### ANT APIs
|
|
962
973
|
|
|
963
|
-
#### `init({ signer )`
|
|
974
|
+
#### `init({ processId, signer )`
|
|
964
975
|
|
|
965
976
|
Factory function to that creates a read-only or writeable client. By providing a `signer` additional write APIs that require signing, like `setRecord` and `transfer` are available. By default, a read-only client is returned and no write APIs are available.
|
|
966
977
|
|
|
@@ -1219,6 +1230,33 @@ Logger.default.setLogLevel('debug');
|
|
|
1219
1230
|
Logger.default = winston.createLogger({ ...loggerConfigs }); // or some other logger that satisifes ILogger interface
|
|
1220
1231
|
```
|
|
1221
1232
|
|
|
1233
|
+
## Pagination
|
|
1234
|
+
|
|
1235
|
+
Certain APIs that could return a large amount of data are paginated using cursors. The SDK uses the `cursor` pattern (as opposed to pages) to better protect against changing data while paginating through a list of items. For more information on pagination strategies refer to [this article](https://www.getknit.dev/blog/api-pagination-best-practices#api-pagination-techniques-).
|
|
1236
|
+
|
|
1237
|
+
Paginated results include the following properties:
|
|
1238
|
+
|
|
1239
|
+
- `items`: the list of items on the current request, defaulted to 100 items.
|
|
1240
|
+
- `nextCursor`: the cursor to use for the next batch of items. This is `undefined` if there are no more items to fetch.
|
|
1241
|
+
- `hasMore`: a boolean indicating if there are more items to fetch. This is `false` if there are no more items to fetch.
|
|
1242
|
+
- `totalItems`: the total number of items available. This may change as new items are added to the list, only use this for informational purposes.
|
|
1243
|
+
- `sortBy`: the field used to sort the items, by default this is `startTimestamp`.
|
|
1244
|
+
- `sortOrder`: the order used to sort the items, by default this is `desc`.
|
|
1245
|
+
|
|
1246
|
+
To request all the items in a list, you can iterate through the list using the `nextCursor` until `hasMore` is `false`.
|
|
1247
|
+
|
|
1248
|
+
```typescript
|
|
1249
|
+
let hasMore = true;
|
|
1250
|
+
let cursor: string | undefined;
|
|
1251
|
+
const gateaways = [];
|
|
1252
|
+
while (hasMore) {
|
|
1253
|
+
const page = await io.getGateways({ limit: 10, cursor });
|
|
1254
|
+
gateaways.push(...items);
|
|
1255
|
+
cursor = page.nextCursor;
|
|
1256
|
+
hasMore = page.hasMore;
|
|
1257
|
+
}
|
|
1258
|
+
```
|
|
1259
|
+
|
|
1222
1260
|
## Developers
|
|
1223
1261
|
|
|
1224
1262
|
### Requirements
|
|
@@ -1235,7 +1273,9 @@ Logger.default = winston.createLogger({ ...loggerConfigs }); // or some other lo
|
|
|
1235
1273
|
|
|
1236
1274
|
### Testing
|
|
1237
1275
|
|
|
1238
|
-
- `yarn test
|
|
1276
|
+
- `yarn test` - runs e2e tests and unit tests
|
|
1277
|
+
- `yarn test:e2e` - runs e2e tests
|
|
1278
|
+
- `yarn test:unit` - runs unit tests
|
|
1239
1279
|
- `yarn example:web` - opens up the example web page
|
|
1240
1280
|
- `yarn example:cjs` - runs example CJS node script
|
|
1241
1281
|
- `yarn example:esm` - runs example ESM node script
|