@ar.io/sdk 2.0.0-alpha.8 → 2.0.0
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 +211 -128
- package/bundles/web.bundle.min.js +79 -79
- package/lib/cjs/common/io.js +78 -14
- package/lib/cjs/utils/index.js +1 -1
- package/lib/cjs/utils/{graphql/processes.js → processes.js} +40 -10
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/io.js +78 -14
- package/lib/esm/utils/index.js +1 -1
- package/lib/esm/utils/{graphql/processes.js → processes.js} +38 -9
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant.d.ts +0 -24
- package/lib/types/common/io.d.ts +4 -4
- package/lib/types/io.d.ts +27 -3
- package/lib/types/utils/index.d.ts +1 -1
- package/lib/types/utils/{graphql/processes.d.ts → processes.d.ts} +6 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/lib/cjs/utils/graphql/index.js +0 -33
- package/lib/esm/utils/graphql/index.js +0 -17
- package/lib/types/utils/graphql/index.d.ts +0 -17
package/README.md
CHANGED
|
@@ -21,11 +21,11 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
21
21
|
- [`init({ signer })`](#init-signer-)
|
|
22
22
|
- [`getInfo()`](#getinfo)
|
|
23
23
|
- [`getBalance({ address })`](#getbalance-address-)
|
|
24
|
-
- [`getBalances()`](#getbalances)
|
|
24
|
+
- [`getBalances({ cursor, limit, sortBy, sortOrder })`](#getbalances-cursor-limit-sortby-sortorder-)
|
|
25
25
|
- [`getGateway({ address })`](#getgateway-address-)
|
|
26
|
-
- [`getGateways()`](#getgateways)
|
|
26
|
+
- [`getGateways({ cursor, limit, sortBy, sortOrder })`](#getgateways-cursor-limit-sortby-sortorder-)
|
|
27
27
|
- [`getArNSRecord({ name })`](#getarnsrecord-name-)
|
|
28
|
-
- [`getArNSRecords()`](#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-)
|
|
@@ -39,7 +39,7 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
39
39
|
- [`increaseOperatorStake({ qty })`](#increaseoperatorstake-qty-)
|
|
40
40
|
- [`decreaseOperatorStake({ qty })`](#decreaseoperatorstake-qty-)
|
|
41
41
|
- [`saveObservations({ reportTxId, failedGateways })`](#saveobservations-reporttxid-failedgateways-)
|
|
42
|
-
- [`transfer({ target, qty
|
|
42
|
+
- [`transfer({ target, qty })`](#transfer-target-qty-)
|
|
43
43
|
- [`increaseUndernameLimit({ name, qty })`](#increaseundernamelimit-name-qty-)
|
|
44
44
|
- [`extendLease({ name, years })`](#extendlease-name-years-)
|
|
45
45
|
- [Configuration](#custom-configuration)
|
|
@@ -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
|
|
@@ -260,7 +259,7 @@ const info = await io.getInfo();
|
|
|
260
259
|
"name": "Testnet IO",
|
|
261
260
|
"ticker": "tIO",
|
|
262
261
|
"owner": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ",
|
|
263
|
-
"denomination": "
|
|
262
|
+
"denomination": "6"
|
|
264
263
|
}
|
|
265
264
|
```
|
|
266
265
|
|
|
@@ -275,36 +274,32 @@ 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
|
-
.then((balance) => new mIOToken().toIO());
|
|
281
|
-
|
|
282
|
-
console.log(balance.valueOf());
|
|
279
|
+
.then((balance) => new mIOToken().toIO()); // convert it to IO for readability
|
|
283
280
|
```
|
|
284
281
|
|
|
285
282
|
<details>
|
|
286
283
|
<summary>Output</summary>
|
|
287
284
|
|
|
288
285
|
```json
|
|
289
|
-
|
|
290
|
-
1_000_000
|
|
286
|
+
100000
|
|
291
287
|
```
|
|
292
288
|
|
|
293
289
|
</details>
|
|
294
290
|
|
|
295
|
-
#### `getBalances()`
|
|
291
|
+
#### `getBalances({ cursor, limit, sortBy, sortOrder })`
|
|
296
292
|
|
|
297
|
-
Retrieves the balances of the IO process in `mIO`
|
|
298
|
-
|
|
299
|
-
<!--
|
|
300
|
-
// ALM - A part of me wonders whether streaming JSON might be beneficial in the future
|
|
301
|
-
// and if providing streaming versions of these APIs will scale nicely longer term, e.g.
|
|
302
|
-
// io.streamBalances({ sortingCriteria: BALANCE_DESC });
|
|
303
|
-
-->
|
|
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.
|
|
304
294
|
|
|
305
295
|
```typescript
|
|
306
296
|
const io = IO.init();
|
|
307
|
-
const balances = await io.getBalances(
|
|
297
|
+
const balances = await io.getBalances({
|
|
298
|
+
cursor: '-4xgjroXENKYhTWqrBo57HQwvDL51mMdfsdsxJy6Y2Z_sA',
|
|
299
|
+
limit: 1,
|
|
300
|
+
sortBy: 'balance',
|
|
301
|
+
sortOrder: 'desc',
|
|
302
|
+
});
|
|
308
303
|
```
|
|
309
304
|
|
|
310
305
|
<details>
|
|
@@ -312,9 +307,17 @@ const balances = await io.getBalances();
|
|
|
312
307
|
|
|
313
308
|
```json
|
|
314
309
|
{
|
|
315
|
-
"
|
|
316
|
-
|
|
317
|
-
|
|
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"
|
|
318
321
|
}
|
|
319
322
|
```
|
|
320
323
|
|
|
@@ -327,7 +330,7 @@ Retrieves a gateway's info by its staking wallet address.
|
|
|
327
330
|
```typescript
|
|
328
331
|
const io = IO.init();
|
|
329
332
|
const gateway = await io.getGateway({
|
|
330
|
-
address: '
|
|
333
|
+
address: '-7vXsQZQDk8TMDlpiSLy3CnLi5PDPlAaN2DaynORpck',
|
|
331
334
|
});
|
|
332
335
|
```
|
|
333
336
|
|
|
@@ -336,9 +339,8 @@ const gateway = await io.getGateway({
|
|
|
336
339
|
|
|
337
340
|
```json
|
|
338
341
|
{
|
|
339
|
-
"
|
|
340
|
-
"
|
|
341
|
-
"operatorStake": 250000000000, // value in mIO
|
|
342
|
+
"observerAddress": "IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs",
|
|
343
|
+
"operatorStake": 250000000000,
|
|
342
344
|
"settings": {
|
|
343
345
|
"fqdn": "ar-io.dev",
|
|
344
346
|
"label": "AR.IO Test",
|
|
@@ -347,7 +349,7 @@ const gateway = await io.getGateway({
|
|
|
347
349
|
"properties": "raJgvbFU-YAnku-WsupIdbTsqqGLQiYpGzoqk9SCVgY",
|
|
348
350
|
"protocol": "https"
|
|
349
351
|
},
|
|
350
|
-
"
|
|
352
|
+
"startTimestamp": 1720720620813,
|
|
351
353
|
"stats": {
|
|
352
354
|
"failedConsecutiveEpochs": 0,
|
|
353
355
|
"passedEpochCount": 30,
|
|
@@ -362,43 +364,56 @@ const gateway = await io.getGateway({
|
|
|
362
364
|
|
|
363
365
|
</details>
|
|
364
366
|
|
|
365
|
-
#### `getGateways()`
|
|
367
|
+
#### `getGateways({ cursor, limit, sortBy, sortOrder })`
|
|
366
368
|
|
|
367
|
-
Retrieves
|
|
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.
|
|
368
370
|
|
|
369
371
|
```typescript
|
|
370
372
|
const io = IO.init();
|
|
371
|
-
const gateways = await io.getGateways(
|
|
373
|
+
const gateways = await io.getGateways({
|
|
374
|
+
limit: 1,
|
|
375
|
+
sortOrder: 'desc',
|
|
376
|
+
sortBy: 'operatorStake',
|
|
377
|
+
});
|
|
372
378
|
```
|
|
373
379
|
|
|
380
|
+
Available `sortBy` options are any of the keys on the gateway object, e.g. `operatorStake`, `start`, `status`, `settings.fqdn`, `settings.label`, `settings.note`, `settings.port`, `settings.protocol`, `stats.failedConsecutiveEpochs`, `stats.passedConsecutiveEpochs`, etc.
|
|
381
|
+
|
|
374
382
|
<details>
|
|
375
383
|
<summary>Output</summary>
|
|
376
384
|
|
|
377
385
|
```json
|
|
378
386
|
{
|
|
379
|
-
"
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
"
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
"
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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"
|
|
402
417
|
}
|
|
403
418
|
```
|
|
404
419
|
|
|
@@ -419,8 +434,8 @@ const record = await io.getArNSRecord({ name: 'ardrive' });
|
|
|
419
434
|
```json
|
|
420
435
|
{
|
|
421
436
|
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
|
|
422
|
-
"endTimestamp":
|
|
423
|
-
"startTimestamp":
|
|
437
|
+
"endTimestamp": 1752256702026,
|
|
438
|
+
"startTimestamp": 1720720819969,
|
|
424
439
|
"type": "lease",
|
|
425
440
|
"undernames": 100
|
|
426
441
|
}
|
|
@@ -428,34 +443,74 @@ const record = await io.getArNSRecord({ name: 'ardrive' });
|
|
|
428
443
|
|
|
429
444
|
</details>
|
|
430
445
|
|
|
431
|
-
#### `getArNSRecords()`
|
|
446
|
+
#### `getArNSRecords({ cursor, limit, sortBy, sortOrder })`
|
|
432
447
|
|
|
433
|
-
Retrieves all registered ArNS records of the IO process.
|
|
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.
|
|
434
449
|
|
|
435
450
|
```typescript
|
|
436
451
|
const io = IO.init();
|
|
437
|
-
|
|
452
|
+
// get the 5 newest names
|
|
453
|
+
const records = await io.getArNSRecords({
|
|
454
|
+
limit: 5,
|
|
455
|
+
sortBy: 'startTimestamp',
|
|
456
|
+
sortOrder: 'desc',
|
|
457
|
+
});
|
|
438
458
|
```
|
|
439
459
|
|
|
460
|
+
Available `sortBy` options are any of the keys on the record object, e.g. `name`, `processId`, `endTimestamp`, `startTimestamp`, `type`, `undernames`.
|
|
461
|
+
|
|
440
462
|
<details>
|
|
441
463
|
<summary>Output</summary>
|
|
442
464
|
|
|
443
465
|
```json
|
|
444
466
|
{
|
|
445
|
-
"
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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"
|
|
459
514
|
}
|
|
460
515
|
```
|
|
461
516
|
|
|
@@ -508,11 +563,12 @@ const distributions = await io.getDistributions();
|
|
|
508
563
|
|
|
509
564
|
```json
|
|
510
565
|
{
|
|
511
|
-
"
|
|
512
|
-
"
|
|
513
|
-
"
|
|
514
|
-
"
|
|
515
|
-
|
|
566
|
+
"totalEligibleRewards": 100000000,
|
|
567
|
+
"totalDistributedRewards": 100000000,
|
|
568
|
+
"distributedTimestamp": 1720720621424,
|
|
569
|
+
"rewards": {
|
|
570
|
+
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": 100000000
|
|
571
|
+
}
|
|
516
572
|
}
|
|
517
573
|
```
|
|
518
574
|
|
|
@@ -533,10 +589,10 @@ const epoch = await io.getEpoch({ epochIndex: 0 });
|
|
|
533
589
|
```json
|
|
534
590
|
{
|
|
535
591
|
"epochIndex": 0,
|
|
536
|
-
"startTimestamp":
|
|
537
|
-
"endTimestamp":
|
|
592
|
+
"startTimestamp": 1720720620813,
|
|
593
|
+
"endTimestamp": 1752256702026,
|
|
538
594
|
"startHeight": 1350700,
|
|
539
|
-
"distributionTimestamp":
|
|
595
|
+
"distributionTimestamp": 1752256702026,
|
|
540
596
|
"observations": {
|
|
541
597
|
"failureSummaries": {
|
|
542
598
|
"-Tk2DDk8k4zkwtppp_XFKKI5oUgh6IEHygAoN7mD-w8": [
|
|
@@ -553,7 +609,7 @@ const epoch = await io.getEpoch({ epochIndex: 0 });
|
|
|
553
609
|
"gatewayAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
554
610
|
"observerAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
555
611
|
"stake": 10000000000, // value in mIO
|
|
556
|
-
"
|
|
612
|
+
"startTimestamp": 1720720620813,
|
|
557
613
|
"stakeWeight": 1,
|
|
558
614
|
"tenureWeight": 0.4494598765432099,
|
|
559
615
|
"gatewayRewardRatioWeight": 1,
|
|
@@ -563,8 +619,9 @@ const epoch = await io.getEpoch({ epochIndex: 0 });
|
|
|
563
619
|
}
|
|
564
620
|
],
|
|
565
621
|
"distributions": {
|
|
566
|
-
"distributedTimestamp":
|
|
622
|
+
"distributedTimestamp": 1752256702026,
|
|
567
623
|
"totalEligibleRewards": 100000000,
|
|
624
|
+
"totoalDistributedRewards": 100000000,
|
|
568
625
|
"rewards": {
|
|
569
626
|
"IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs": 100000000
|
|
570
627
|
}
|
|
@@ -589,8 +646,8 @@ const epoch = await io.getCurrentEpoch();
|
|
|
589
646
|
```json
|
|
590
647
|
{
|
|
591
648
|
"epochIndex": 0,
|
|
592
|
-
"startTimestamp":
|
|
593
|
-
"endTimestamp":
|
|
649
|
+
"startTimestamp": 1720720621424,
|
|
650
|
+
"endTimestamp": 1752256702026,
|
|
594
651
|
"startHeight": 1350700,
|
|
595
652
|
"distributionTimestamp": 1711122739,
|
|
596
653
|
"observations": {
|
|
@@ -608,7 +665,7 @@ const epoch = await io.getCurrentEpoch();
|
|
|
608
665
|
{
|
|
609
666
|
"gatewayAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
610
667
|
"observerAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
611
|
-
"stake": 10000000000,
|
|
668
|
+
"stake": 10000000000,
|
|
612
669
|
"start": 1292450,
|
|
613
670
|
"stakeWeight": 1,
|
|
614
671
|
"tenureWeight": 0.4494598765432099,
|
|
@@ -672,16 +729,14 @@ const price = await io
|
|
|
672
729
|
name: 'ar-io',
|
|
673
730
|
type: 'permabuy',
|
|
674
731
|
})
|
|
675
|
-
.then((p) => new mIOToken(p).toIO());
|
|
676
|
-
// Price is returned as mio, convert to IO and log it out
|
|
677
|
-
console.log({ price: price.valueOf() });
|
|
732
|
+
.then((p) => new mIOToken(p).toIO()); // convert to IO for readability
|
|
678
733
|
```
|
|
679
734
|
|
|
680
735
|
<details>
|
|
681
736
|
<summary>Output</summary>
|
|
682
737
|
|
|
683
738
|
```json
|
|
684
|
-
|
|
739
|
+
1642.34
|
|
685
740
|
```
|
|
686
741
|
|
|
687
742
|
</details>
|
|
@@ -839,9 +894,9 @@ const { id: txId } = await io.saveObservations(
|
|
|
839
894
|
);
|
|
840
895
|
```
|
|
841
896
|
|
|
842
|
-
#### `transfer({ target, qty
|
|
897
|
+
#### `transfer({ target, qty })`
|
|
843
898
|
|
|
844
|
-
Transfers `
|
|
899
|
+
Transfers `mIO` to the designated `target` recipient address. Requires `signer` to be provided on `IO.init` to sign the transaction.
|
|
845
900
|
|
|
846
901
|
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
847
902
|
|
|
@@ -851,7 +906,6 @@ const { id: txId } = await io.transfer(
|
|
|
851
906
|
{
|
|
852
907
|
target: '-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5',
|
|
853
908
|
qty: new IOToken(1000).toMIO(),
|
|
854
|
-
denomination: 'IO',
|
|
855
909
|
},
|
|
856
910
|
// optional additional tags
|
|
857
911
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
@@ -917,7 +971,7 @@ The ANT client class exposes APIs relevant to compliant Arweave Name Token proce
|
|
|
917
971
|
|
|
918
972
|
### ANT APIs
|
|
919
973
|
|
|
920
|
-
#### `init({ signer )`
|
|
974
|
+
#### `init({ processId, signer )`
|
|
921
975
|
|
|
922
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.
|
|
923
977
|
|
|
@@ -1176,6 +1230,33 @@ Logger.default.setLogLevel('debug');
|
|
|
1176
1230
|
Logger.default = winston.createLogger({ ...loggerConfigs }); // or some other logger that satisifes ILogger interface
|
|
1177
1231
|
```
|
|
1178
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
|
+
|
|
1179
1260
|
## Developers
|
|
1180
1261
|
|
|
1181
1262
|
### Requirements
|
|
@@ -1192,7 +1273,9 @@ Logger.default = winston.createLogger({ ...loggerConfigs }); // or some other lo
|
|
|
1192
1273
|
|
|
1193
1274
|
### Testing
|
|
1194
1275
|
|
|
1195
|
-
- `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
|
|
1196
1279
|
- `yarn example:web` - opens up the example web page
|
|
1197
1280
|
- `yarn example:cjs` - runs example CJS node script
|
|
1198
1281
|
- `yarn example:esm` - runs example ESM node script
|