@ar.io/sdk 2.3.3-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 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-)
@@ -44,14 +47,16 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
44
47
  - [`leaveNetwork()`](#leavenetwork)
45
48
  - [`updateGatewaySettings(gatewaySettings)`](#updategatewaysettingsgatewaysettings)
46
49
  - [`increaseDelegateStake({ target, qty })`](#increasedelegatestake-target-qty-)
47
- - [`decreaseDelegateStake({ target, qty })`](#decreasedelegatestake-target-qty-)
50
+ - [`decreaseDelegateStake({ target, qty, instant })`](#decreasedelegatestake-target-qty-instant-)
51
+ - [`instantWithdrawal({ gatewayAddress, vaultId })`](#instantwithdrawal-gatewayaddress-vaultid-)
48
52
  - [`increaseOperatorStake({ qty })`](#increaseoperatorstake-qty-)
49
53
  - [`decreaseOperatorStake({ qty })`](#decreaseoperatorstake-qty-)
50
54
  - [`saveObservations({ reportTxId, failedGateways })`](#saveobservations-reporttxid-failedgateways-)
51
55
  - [`transfer({ target, qty })`](#transfer-target-qty-)
52
56
  - [`increaseUndernameLimit({ name, qty })`](#increaseundernamelimit-name-qty-)
53
57
  - [`extendLease({ name, years })`](#extendlease-name-years-)
54
- - [`cancelDelegateWithdrawal({ address, vaultId })`](#canceldelegatewithdrawal-address-vaultid-)
58
+ - [`cancelWithdrawal({ gatewayAddress, vaultId })`](#cancelwithdrawal-gatewayaddress-vaultid-)
59
+ - [`submitAuctionBid({ name, type, years, processId })`](#submitauctionbid-name-type-years-processid-)
55
60
  - [Configuration](#configuration)
56
61
  - [Arweave Name Tokens (ANT's)](#arweave-name-tokens-ants)
57
62
  - [ANT APIs](#ant-apis)
@@ -68,6 +73,10 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
68
73
  - [`removeRecord({ undername })`](#removerecord-undername-)
69
74
  - [`setName({ name })`](#setname-name-)
70
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-)
71
80
  - [Configuration](#configuration-1)
72
81
  - [Logging](#logging)
73
82
  - [Configuration](#configuration-2)
@@ -597,6 +606,136 @@ Available `sortBy` options are any of the keys on the record object, e.g. `name`
597
606
 
598
607
  </details>
599
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
+
600
739
  #### `getDemandFactor()`
601
740
 
602
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.
@@ -941,9 +1080,9 @@ const { id: txId } = await io.increaseDelegateStake(
941
1080
  );
942
1081
  ```
943
1082
 
944
- #### `decreaseDelegateStake({ target, qty })`
1083
+ #### `decreaseDelegateStake({ target, qty, instant })`
945
1084
 
946
- Decreases the callers stake on the target gateway.
1085
+ Decreases the callers stake on the target gateway. Can instantly decrease stake by setting instant to `true`.
947
1086
 
948
1087
  _Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
949
1088
 
@@ -960,6 +1099,46 @@ const { id: txId } = await io.decreaseDelegateStake(
960
1099
  );
961
1100
  ```
962
1101
 
1102
+ Pay the early withdrawal fee and withdraw instantly.
1103
+
1104
+ ```typescript
1105
+ const io = IO.init({ signer: new ArweaveSigner(jwk) });
1106
+ const { id: txId } = await io.decreaseDelegateStake({
1107
+ target: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
1108
+ qty: new IOToken(100).toMIO(),
1109
+ instant: true, // Immediately withdraw this stake and pay the instant withdrawal fee
1110
+ });
1111
+ ```
1112
+
1113
+ #### `instantWithdrawal({ gatewayAddress, vaultId })`
1114
+
1115
+ Instantly withdraws an existing vault on a gateway. If no `gatewayAddress` is provided, the signer's address will be used.
1116
+
1117
+ _Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
1118
+
1119
+ ```typescript
1120
+ const io = IO.init({ signer: new ArweaveSigner(jwk) });
1121
+ // removes a delegated vault from a gateway
1122
+ const { id: txId } = await io.instantWithdrawal(
1123
+ {
1124
+ // gateway address where delegate vault exists
1125
+ gatewayAddress: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
1126
+ // delegated vault id to cancel
1127
+ vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
1128
+ },
1129
+ // optional additional tags
1130
+ {
1131
+ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }],
1132
+ },
1133
+ );
1134
+ // removes an operator vault from a gateway
1135
+ const { id: txId } = await io.instantWithdrawal(
1136
+ {
1137
+ vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
1138
+ },
1139
+ );
1140
+ ```
1141
+
963
1142
  #### `increaseOperatorStake({ qty })`
964
1143
 
965
1144
  Increases the callers operator stake. Must be executed with a wallet registered as a gateway operator.
@@ -1067,24 +1246,58 @@ const { id: txId } = await io.extendLease(
1067
1246
  );
1068
1247
  ```
1069
1248
 
1070
- #### `cancelDelegateWithdrawal({ address, vaultId })`
1249
+ #### `cancelWithdrawal({ gatewayAddress, vaultId })`
1071
1250
 
1072
- Cancels a pending delegate withdrawal.
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.
1073
1252
 
1074
1253
  _Note: Requires `signer` to be provided on `IO.init` to sign the transaction._
1075
1254
 
1076
1255
  ```typescript
1077
1256
  const io = IO.init({ signer: new ArweaveSigner(jwk) });
1078
- const { id: txId } = await io.cancelDelegateWithdrawal(
1257
+ // cancels a delegated vault from a gateway
1258
+ const { id: txId } = await io.cancelWithdrawal(
1079
1259
  {
1080
1260
  // gateway address where vault exists
1081
- address: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
1261
+ gatewayAddress: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
1082
1262
  // vault id to cancel
1083
1263
  vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
1084
1264
  },
1085
1265
  // optional additional tags
1086
1266
  { tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
1087
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
+ }
1088
1301
  ```
1089
1302
 
1090
1303
  ### Configuration
@@ -1144,8 +1357,10 @@ const info = await ant.getInfo();
1144
1357
 
1145
1358
  ```json
1146
1359
  {
1147
- "name": "Ardrive",
1360
+ "name": "ArDrive",
1148
1361
  "ticker": "ANT-ARDRIVE",
1362
+ "description": "This is the ANT for the ArDrive decentralized web app.",
1363
+ "keywords": ["File-sharing", "Publishing", "dApp"],
1149
1364
  "owner": "QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ"
1150
1365
  }
1151
1366
  ```
@@ -1186,6 +1401,8 @@ const state = await ant.getState();
1186
1401
  },
1187
1402
  "Initialized": true,
1188
1403
  "Ticker": "ANT-AR-IO",
1404
+ "Description": "A friendly description for this ANT.",
1405
+ "Keywords": ["keyword1", "keyword2", "keyword3"],
1189
1406
  "Logo": "Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A",
1190
1407
  "Denomination": 0,
1191
1408
  "Name": "AR.IO Foundation",
@@ -1379,6 +1596,61 @@ const { id: txId } = await ant.setTicker(
1379
1596
  );
1380
1597
  ```
1381
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
+
1382
1654
  ### Configuration
1383
1655
 
1384
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.
@@ -1486,6 +1758,7 @@ For more information on how to use AO and AO Connect within this library, please
1486
1758
  - `yarn example:web` - opens up the example web page
1487
1759
  - `yarn example:cjs` - runs example CJS node script
1488
1760
  - `yarn example:esm` - runs example ESM node script
1761
+ - `yarn example:vite` - runs example Vite web page
1489
1762
 
1490
1763
  ### Linting & Formatting
1491
1764