@ar.io/sdk 2.4.0-alpha.1 → 2.4.0-alpha.10
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 +250 -11
- package/bundles/web.bundle.min.js +63 -63
- package/lib/cjs/common/ant.js +80 -1
- package/lib/cjs/common/io.js +198 -56
- package/lib/cjs/types/ant.js +11 -1
- package/lib/cjs/utils/arweave.js +5 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant.js +80 -1
- package/lib/esm/common/io.js +196 -54
- package/lib/esm/types/ant.js +10 -0
- package/lib/esm/utils/arweave.js +3 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant.d.ts +52 -1
- package/lib/types/common/io.d.ts +84 -12
- package/lib/types/types/ant.d.ts +29 -0
- package/lib/types/types/io.d.ts +66 -16
- package/lib/types/utils/arweave.d.ts +7 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -33,6 +33,9 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
33
33
|
- [`getGateways({ cursor, limit, sortBy, sortOrder })`](#getgateways-cursor-limit-sortby-sortorder-)
|
|
34
34
|
- [`getArNSRecord({ name })`](#getarnsrecord-name-)
|
|
35
35
|
- [`getArNSRecords({ cursor, limit, sortBy, sortOrder })`](#getarnsrecords-cursor-limit-sortby-sortorder-)
|
|
36
|
+
- [`getArNSAuctions({ cursor, limit, sortBy, sortOrder })`](#getarnsauctions-cursor-limit-sortby-sortorder-)
|
|
37
|
+
- [`getArNSAuction({ name })`](#getarnsauction-name-)
|
|
38
|
+
- [`getArNSAuctionPrices({ name, type, years, intervalMs })`](#getarnsauctionprices-name-type-years-intervalms-)
|
|
36
39
|
- [`getDemandFactor()`](#getdemandfactor)
|
|
37
40
|
- [`getObservations({ epochIndex })`](#getobservations-epochindex-)
|
|
38
41
|
- [`getDistributions({ epochIndex })`](#getdistributions-epochindex-)
|
|
@@ -45,14 +48,15 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
45
48
|
- [`updateGatewaySettings(gatewaySettings)`](#updategatewaysettingsgatewaysettings)
|
|
46
49
|
- [`increaseDelegateStake({ target, qty })`](#increasedelegatestake-target-qty-)
|
|
47
50
|
- [`decreaseDelegateStake({ target, qty, instant })`](#decreasedelegatestake-target-qty-instant-)
|
|
48
|
-
- [`
|
|
51
|
+
- [`instantWithdrawal({ gatewayAddress, vaultId })`](#instantwithdrawal-gatewayaddress-vaultid-)
|
|
49
52
|
- [`increaseOperatorStake({ qty })`](#increaseoperatorstake-qty-)
|
|
50
53
|
- [`decreaseOperatorStake({ qty })`](#decreaseoperatorstake-qty-)
|
|
51
54
|
- [`saveObservations({ reportTxId, failedGateways })`](#saveobservations-reporttxid-failedgateways-)
|
|
52
55
|
- [`transfer({ target, qty })`](#transfer-target-qty-)
|
|
53
56
|
- [`increaseUndernameLimit({ name, qty })`](#increaseundernamelimit-name-qty-)
|
|
54
57
|
- [`extendLease({ name, years })`](#extendlease-name-years-)
|
|
55
|
-
- [`
|
|
58
|
+
- [`cancelWithdrawal({ gatewayAddress, vaultId })`](#cancelwithdrawal-gatewayaddress-vaultid-)
|
|
59
|
+
- [`submitAuctionBid({ name, type, years, processId })`](#submitauctionbid-name-type-years-processid-)
|
|
56
60
|
- [Configuration](#configuration)
|
|
57
61
|
- [Arweave Name Tokens (ANT's)](#arweave-name-tokens-ants)
|
|
58
62
|
- [ANT APIs](#ant-apis)
|
|
@@ -69,6 +73,10 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
69
73
|
- [`removeRecord({ undername })`](#removerecord-undername-)
|
|
70
74
|
- [`setName({ name })`](#setname-name-)
|
|
71
75
|
- [`setTicker({ ticker })`](#setticker-ticker-)
|
|
76
|
+
- [`setDescription({ description })`](#setdescription-description-)
|
|
77
|
+
- [`setKeywords({ keywords })`](#setkeywords-keywords-)
|
|
78
|
+
- [`releaseName({ name, ioProcessId })`](#releasename-name-ioprocessid-)
|
|
79
|
+
- [`reassignName({ name, ioProcessId, antProcessId })`](#reassignname-name-ioprocessid-antprocessid-)
|
|
72
80
|
- [Configuration](#configuration-1)
|
|
73
81
|
- [Logging](#logging)
|
|
74
82
|
- [Configuration](#configuration-2)
|
|
@@ -598,6 +606,136 @@ Available `sortBy` options are any of the keys on the record object, e.g. `name`
|
|
|
598
606
|
|
|
599
607
|
</details>
|
|
600
608
|
|
|
609
|
+
#### `getArNSAuctions({ cursor, limit, sortBy, sortOrder })`
|
|
610
|
+
|
|
611
|
+
Retrieves all active auctions of the IO process, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last auction name from the previous request.
|
|
612
|
+
|
|
613
|
+
```typescript
|
|
614
|
+
const io = IO.init();
|
|
615
|
+
const auctions = await io.getArNSAuctions({
|
|
616
|
+
limit: 100,
|
|
617
|
+
sortBy: 'endTimestamp',
|
|
618
|
+
sortOrder: 'asc', // return the auctions ending soonest first
|
|
619
|
+
});
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
<details>
|
|
623
|
+
<summary>Output</summary>
|
|
624
|
+
|
|
625
|
+
```json
|
|
626
|
+
{
|
|
627
|
+
"items": [
|
|
628
|
+
{
|
|
629
|
+
"name": "permalink",
|
|
630
|
+
"endTimestamp": 1730985241349,
|
|
631
|
+
"startTimestamp": 1729775641349,
|
|
632
|
+
"baseFee": 250000000,
|
|
633
|
+
"demandFactor": 1.05256,
|
|
634
|
+
"initiator": "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc",
|
|
635
|
+
"settings": {
|
|
636
|
+
"durationMs": 1209600000,
|
|
637
|
+
"decayRate": 0.000000000016847809193121693,
|
|
638
|
+
"scalingExponent": 190,
|
|
639
|
+
"startPriceMultiplier": 50
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
],
|
|
643
|
+
"hasMore": false,
|
|
644
|
+
"totalItems": 1,
|
|
645
|
+
"sortBy": "endTimestamp",
|
|
646
|
+
"sortOrder": "asc"
|
|
647
|
+
}
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
</details>
|
|
651
|
+
|
|
652
|
+
#### `getArNSAuction({ name })`
|
|
653
|
+
|
|
654
|
+
Retrieves the auction data for the specified auction name.
|
|
655
|
+
|
|
656
|
+
```typescript
|
|
657
|
+
const io = IO.init();
|
|
658
|
+
const auction = await io.getArNSAuction({ name: 'permalink' });
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
<details>
|
|
662
|
+
<summary>Output</summary>
|
|
663
|
+
|
|
664
|
+
```json
|
|
665
|
+
{
|
|
666
|
+
"name": "permalink",
|
|
667
|
+
"endTimestamp": 1730985241349,
|
|
668
|
+
"startTimestamp": 1729775641349,
|
|
669
|
+
"baseFee": 250000000,
|
|
670
|
+
"demandFactor": 1.05256,
|
|
671
|
+
"initiator": "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc",
|
|
672
|
+
"settings": {
|
|
673
|
+
"durationMs": 1209600000,
|
|
674
|
+
"decayRate": 0.000000000016847809193121693,
|
|
675
|
+
"scalingExponent": 190,
|
|
676
|
+
"startPriceMultiplier": 50
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
</details>
|
|
682
|
+
|
|
683
|
+
#### `getArNSAuctionPrices({ name, type, years, intervalMs })`
|
|
684
|
+
|
|
685
|
+
Retrieves the auction price curve of the specified auction name for the specified type, duration, and interval. The `intervalMs` is the number of milliseconds between price points on the curve. The default interval is 15 minutes.
|
|
686
|
+
|
|
687
|
+
```typescript
|
|
688
|
+
const io = IO.init();
|
|
689
|
+
const priceCurve = await io.getArNSAuctionPrices({
|
|
690
|
+
name: 'permalink',
|
|
691
|
+
type: 'lease',
|
|
692
|
+
years: 1,
|
|
693
|
+
intervalMs: 3600000, // 1 hour price intervals (default is 15 minutes)
|
|
694
|
+
});
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
<details>
|
|
698
|
+
<summary>Output</summary>
|
|
699
|
+
|
|
700
|
+
```json
|
|
701
|
+
{
|
|
702
|
+
"name": "permalink",
|
|
703
|
+
"type": "lease",
|
|
704
|
+
"currentPrice": 12582015000,
|
|
705
|
+
"years": 1,
|
|
706
|
+
"prices": {
|
|
707
|
+
"1730412841349": 1618516789,
|
|
708
|
+
"1729908841349": 8210426826,
|
|
709
|
+
"1730722441349": 592768907,
|
|
710
|
+
"1730859241349": 379659914,
|
|
711
|
+
"1730866441349": 370850139,
|
|
712
|
+
"1730884441349": 349705277,
|
|
713
|
+
"1730150041349": 3780993370,
|
|
714
|
+
"1730031241349": 5541718397,
|
|
715
|
+
"1730603641349": 872066253,
|
|
716
|
+
"1730715241349": 606815377,
|
|
717
|
+
"1730942041349": 289775172,
|
|
718
|
+
"1730916841349": 314621977,
|
|
719
|
+
"1730484841349": 1281957300,
|
|
720
|
+
"1730585641349": 924535164,
|
|
721
|
+
"1730232841349": 2895237473,
|
|
722
|
+
"1730675641349": 690200977,
|
|
723
|
+
"1730420041349": 1581242331,
|
|
724
|
+
"1729786441349": 12154428186,
|
|
725
|
+
"1730308441349": 2268298483,
|
|
726
|
+
"1730564041349": 991657913,
|
|
727
|
+
"1730081641349": 4712427282,
|
|
728
|
+
"1730909641349": 322102563,
|
|
729
|
+
"1730945641349": 286388732,
|
|
730
|
+
"1730024041349": 5671483398,
|
|
731
|
+
"1729937641349": 7485620175
|
|
732
|
+
// ...
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
</details>
|
|
738
|
+
|
|
601
739
|
#### `getDemandFactor()`
|
|
602
740
|
|
|
603
741
|
Retrieves the current demand factor of the network. The demand factor is a multiplier applied to the cost of ArNS interactions based on the current network demand.
|
|
@@ -972,18 +1110,19 @@ const { id: txId } = await io.decreaseDelegateStake({
|
|
|
972
1110
|
});
|
|
973
1111
|
```
|
|
974
1112
|
|
|
975
|
-
#### `
|
|
1113
|
+
#### `instantWithdrawal({ gatewayAddress, vaultId })`
|
|
976
1114
|
|
|
977
|
-
Instantly withdraws
|
|
1115
|
+
Instantly withdraws an existing vault on a gateway. If no `gatewayAddress` is provided, the signer's address will be used.
|
|
978
1116
|
|
|
979
1117
|
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
980
1118
|
|
|
981
1119
|
```typescript
|
|
982
1120
|
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
983
|
-
|
|
1121
|
+
// removes a delegated vault from a gateway
|
|
1122
|
+
const { id: txId } = await io.instantWithdrawal(
|
|
984
1123
|
{
|
|
985
1124
|
// gateway address where delegate vault exists
|
|
986
|
-
|
|
1125
|
+
gatewayAddress: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
|
|
987
1126
|
// delegated vault id to cancel
|
|
988
1127
|
vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
|
|
989
1128
|
},
|
|
@@ -992,6 +1131,12 @@ const { id: txId } = await io.instantDelegateWithdrawal(
|
|
|
992
1131
|
tags: [{ name: 'App-Name', value: 'My-Awesome-App' }],
|
|
993
1132
|
},
|
|
994
1133
|
);
|
|
1134
|
+
// removes an operator vault from a gateway
|
|
1135
|
+
const { id: txId } = await io.instantWithdrawal(
|
|
1136
|
+
{
|
|
1137
|
+
vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
|
|
1138
|
+
},
|
|
1139
|
+
);
|
|
995
1140
|
```
|
|
996
1141
|
|
|
997
1142
|
#### `increaseOperatorStake({ qty })`
|
|
@@ -1101,24 +1246,58 @@ const { id: txId } = await io.extendLease(
|
|
|
1101
1246
|
);
|
|
1102
1247
|
```
|
|
1103
1248
|
|
|
1104
|
-
#### `
|
|
1249
|
+
#### `cancelWithdrawal({ gatewayAddress, vaultId })`
|
|
1105
1250
|
|
|
1106
|
-
Cancels a
|
|
1251
|
+
Cancels an existing vault on a gateway. The vaulted stake will be returned to the callers stake. If no `gatewayAddress` is provided, the signer's address will be used.
|
|
1107
1252
|
|
|
1108
1253
|
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
1109
1254
|
|
|
1110
1255
|
```typescript
|
|
1111
1256
|
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
1112
|
-
|
|
1257
|
+
// cancels a delegated vault from a gateway
|
|
1258
|
+
const { id: txId } = await io.cancelWithdrawal(
|
|
1113
1259
|
{
|
|
1114
1260
|
// gateway address where vault exists
|
|
1115
|
-
|
|
1261
|
+
gatewayAddress: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
|
|
1116
1262
|
// vault id to cancel
|
|
1117
1263
|
vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
|
|
1118
1264
|
},
|
|
1119
1265
|
// optional additional tags
|
|
1120
1266
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1121
1267
|
);
|
|
1268
|
+
// cancels an operator vault from a gateway
|
|
1269
|
+
const { id: txId } = await io.cancelWithdrawal(
|
|
1270
|
+
{
|
|
1271
|
+
// operator vault id to cancel
|
|
1272
|
+
vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
|
|
1273
|
+
},
|
|
1274
|
+
);
|
|
1275
|
+
```
|
|
1276
|
+
|
|
1277
|
+
#### `submitAuctionBid({ name, type, years, processId })`
|
|
1278
|
+
|
|
1279
|
+
Submit a bid for the current auction. If the bid is accepted, the name will be leased for the specified duration and assigned the specified type and processId.
|
|
1280
|
+
|
|
1281
|
+
_Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
|
|
1282
|
+
|
|
1283
|
+
```typescript
|
|
1284
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
1285
|
+
|
|
1286
|
+
const auction = await io.getArNSAuction({ name: 'permalink' });
|
|
1287
|
+
|
|
1288
|
+
// check the current price is under some threshold
|
|
1289
|
+
if (auction && auction.currentPrice <= new IOToken(20_000).toMIO().valueOf()) {
|
|
1290
|
+
const { id: txId } = await io.submitAuctionBid(
|
|
1291
|
+
{
|
|
1292
|
+
name: 'permalink',
|
|
1293
|
+
type: 'lease',
|
|
1294
|
+
years: 1,
|
|
1295
|
+
processId: 'bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM',
|
|
1296
|
+
},
|
|
1297
|
+
// optional additional tags
|
|
1298
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1299
|
+
);
|
|
1300
|
+
}
|
|
1122
1301
|
```
|
|
1123
1302
|
|
|
1124
1303
|
### Configuration
|
|
@@ -1178,8 +1357,10 @@ const info = await ant.getInfo();
|
|
|
1178
1357
|
|
|
1179
1358
|
```json
|
|
1180
1359
|
{
|
|
1181
|
-
"name": "
|
|
1360
|
+
"name": "ArDrive",
|
|
1182
1361
|
"ticker": "ANT-ARDRIVE",
|
|
1362
|
+
"description": "This is the ANT for the ArDrive decentralized web app.",
|
|
1363
|
+
"keywords": ["File-sharing", "Publishing", "dApp"],
|
|
1183
1364
|
"owner": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ"
|
|
1184
1365
|
}
|
|
1185
1366
|
```
|
|
@@ -1220,6 +1401,8 @@ const state = await ant.getState();
|
|
|
1220
1401
|
},
|
|
1221
1402
|
"Initialized": true,
|
|
1222
1403
|
"Ticker": "ANT-AR-IO",
|
|
1404
|
+
"Description": "A friendly description for this ANT.",
|
|
1405
|
+
"Keywords": ["keyword1", "keyword2", "keyword3"],
|
|
1223
1406
|
"Logo": "Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A",
|
|
1224
1407
|
"Denomination": 0,
|
|
1225
1408
|
"Name": "AR.IO Foundation",
|
|
@@ -1413,6 +1596,61 @@ const { id: txId } = await ant.setTicker(
|
|
|
1413
1596
|
);
|
|
1414
1597
|
```
|
|
1415
1598
|
|
|
1599
|
+
#### `setDescription({ description })`
|
|
1600
|
+
|
|
1601
|
+
Sets the description of the ANT process.
|
|
1602
|
+
|
|
1603
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1604
|
+
|
|
1605
|
+
```typescript
|
|
1606
|
+
const { id: txId } = await ant.setDescription(
|
|
1607
|
+
{ description: 'A friendly description of this ANT' },
|
|
1608
|
+
// optional tags
|
|
1609
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1610
|
+
);
|
|
1611
|
+
```
|
|
1612
|
+
|
|
1613
|
+
#### `setKeywords({ keywords })`
|
|
1614
|
+
|
|
1615
|
+
Sets the keywords of the ANT process.
|
|
1616
|
+
|
|
1617
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1618
|
+
|
|
1619
|
+
```typescript
|
|
1620
|
+
const { id: txId } = await ant.setDescription(
|
|
1621
|
+
{ keywords: ['Game', 'FPS', 'AO'] },
|
|
1622
|
+
// optional tags
|
|
1623
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
1624
|
+
);
|
|
1625
|
+
```
|
|
1626
|
+
|
|
1627
|
+
#### `releaseName({ name, ioProcessId })`
|
|
1628
|
+
|
|
1629
|
+
Releases a name from the auction and makes it available for auction on the IO contract. The name must be permanently owned by the releasing wallet. 50% of the winning bid will be distributed to the ANT owner at the time of release. If no bids, the name will be released and can be reregistered by anyone.
|
|
1630
|
+
|
|
1631
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1632
|
+
|
|
1633
|
+
```typescript
|
|
1634
|
+
const { id: txId } = await ant.releaseName({
|
|
1635
|
+
name: 'permalink',
|
|
1636
|
+
ioProcessId: IO_TESTNET_PROCESS_ID, // releases the name owned by the ANT and sends it to auction on the IO contract
|
|
1637
|
+
});
|
|
1638
|
+
```
|
|
1639
|
+
|
|
1640
|
+
#### `reassignName({ name, ioProcessId, antProcessId })`
|
|
1641
|
+
|
|
1642
|
+
Reassigns a name to a new ANT. This can only be done by the current owner of the ANT.
|
|
1643
|
+
|
|
1644
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
1645
|
+
|
|
1646
|
+
```typescript
|
|
1647
|
+
const { id: txId } = await ant.reassignName({
|
|
1648
|
+
name: 'ardrive',
|
|
1649
|
+
ioProcessId: IO_TESTNET_PROCESS_ID,
|
|
1650
|
+
antProcessId: NEW_ANT_PROCESS_ID, // the new ANT process id that will take over ownership of the name
|
|
1651
|
+
});
|
|
1652
|
+
```
|
|
1653
|
+
|
|
1416
1654
|
### Configuration
|
|
1417
1655
|
|
|
1418
1656
|
ANT clients can be configured to use custom AO process. Refer to [AO Connect] for more information on how to configure the AO process to use specific AO infrastructure.
|
|
@@ -1520,6 +1758,7 @@ For more information on how to use AO and AO Connect within this library, please
|
|
|
1520
1758
|
- `yarn example:web` - opens up the example web page
|
|
1521
1759
|
- `yarn example:cjs` - runs example CJS node script
|
|
1522
1760
|
- `yarn example:esm` - runs example ESM node script
|
|
1761
|
+
- `yarn example:vite` - runs example Vite web page
|
|
1523
1762
|
|
|
1524
1763
|
### Linting & Formatting
|
|
1525
1764
|
|