@ar.io/sdk 2.5.0-alpha.8 → 2.5.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 +139 -35
- package/bundles/web.bundle.min.js +51 -51
- package/lib/cjs/common/ant.js +29 -4
- package/lib/cjs/common/io.js +59 -0
- package/lib/cjs/constants.js +1 -1
- package/lib/cjs/types/ant.js +1 -3
- package/lib/cjs/utils/ao.js +1 -27
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant.js +31 -6
- package/lib/esm/common/io.js +59 -0
- package/lib/esm/constants.js +1 -1
- package/lib/esm/types/ant.js +0 -2
- package/lib/esm/utils/ao.js +0 -25
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant.d.ts +15 -3
- package/lib/types/common/io.d.ts +35 -2
- package/lib/types/constants.d.ts +1 -1
- package/lib/types/types/ant.d.ts +10 -34
- package/lib/types/types/common.d.ts +10 -0
- package/lib/types/types/io.d.ts +23 -3
- package/lib/types/utils/ao.d.ts +1 -6
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,8 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
52
52
|
- [`increaseDelegateStake({ target, qty })`](#increasedelegatestake-target-qty-)
|
|
53
53
|
- [`decreaseDelegateStake({ target, qty, instant })`](#decreasedelegatestake-target-qty-instant-)
|
|
54
54
|
- [`getDelegations({ address, cursor, limit, sortBy, sortOrder })`](#getdelegations-address-cursor-limit-sortby-sortorder-)
|
|
55
|
+
- [`getAllowedDelegates({ address, cursor, limit, sortBy, sortOrder })`](#getalloweddelegates-address-cursor-limit-sortby-sortorder-)
|
|
56
|
+
- [`getGatewayVaults({ address, cursor, limit, sortBy, sortOrder })`](#getgatewayvaults-address-cursor-limit-sortby-sortorder-)
|
|
55
57
|
- [`instantWithdrawal({ gatewayAddress, vaultId })`](#instantwithdrawal-gatewayaddress-vaultid-)
|
|
56
58
|
- [`increaseOperatorStake({ qty })`](#increaseoperatorstake-qty-)
|
|
57
59
|
- [`decreaseOperatorStake({ qty })`](#decreaseoperatorstake-qty-)
|
|
@@ -64,6 +66,8 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
64
66
|
- [`getPrimaryNames({ cursor, limit, sortBy, sortOrder })`](#getprimarynames-cursor-limit-sortby-sortorder-)
|
|
65
67
|
- [`getPrimaryName({ name, address })`](#getprimaryname-name-address-)
|
|
66
68
|
- [`requestPrimaryName({ name, address })`](#requestprimaryname-name-address-)
|
|
69
|
+
- [`redelegateStake({ target, source, stakeQty, vaultId })`](#redelegatestake-target-source-stakeqty-vaultid-)
|
|
70
|
+
- [`getRedelegationFee({ address })`](#getredelegationfee-address-)
|
|
67
71
|
- [Configuration](#configuration)
|
|
68
72
|
- [Arweave Name Tokens (ANT's)](#arweave-name-tokens-ants)
|
|
69
73
|
- [ANT APIs](#ant-apis)
|
|
@@ -86,7 +90,8 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
86
90
|
- [`setLogo({ txId })`](#setlogo-txid-)
|
|
87
91
|
- [`releaseName({ name, ioProcessId })`](#releasename-name-ioprocessid-)
|
|
88
92
|
- [`reassignName({ name, ioProcessId, antProcessId })`](#reassignname-name-ioprocessid-antprocessid-)
|
|
89
|
-
- [`approvePrimaryNameRequest({ name, address })`](#approveprimarynamerequest-name-address-)
|
|
93
|
+
- [`approvePrimaryNameRequest({ name, address, ioProcessId })`](#approveprimarynamerequest-name-address-ioprocessid-)
|
|
94
|
+
- [`removePrimaryNames({ names, ioProcessId })`](#removeprimarynames-names-ioprocessid-)
|
|
90
95
|
- [Configuration](#configuration-1)
|
|
91
96
|
- [Logging](#logging)
|
|
92
97
|
- [Configuration](#configuration-2)
|
|
@@ -1257,6 +1262,72 @@ const vaults = await io.getDelegations({
|
|
|
1257
1262
|
|
|
1258
1263
|
</details>
|
|
1259
1264
|
|
|
1265
|
+
#### `getAllowedDelegates({ address, cursor, limit, sortBy, sortOrder })`
|
|
1266
|
+
|
|
1267
|
+
Retrieves all allowed delegates for a specific address. The `cursor` used for pagination is the last address from the previous request.
|
|
1268
|
+
|
|
1269
|
+
```typescript
|
|
1270
|
+
const io = IO.init();
|
|
1271
|
+
const allowedDelegates = await io.getAllowedDelegates({
|
|
1272
|
+
address: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ',
|
|
1273
|
+
});
|
|
1274
|
+
```
|
|
1275
|
+
|
|
1276
|
+
<details>
|
|
1277
|
+
<summary>Output</summary>
|
|
1278
|
+
|
|
1279
|
+
```json
|
|
1280
|
+
{
|
|
1281
|
+
"sortOrder": "desc",
|
|
1282
|
+
"hasMore": false,
|
|
1283
|
+
"totalItems": 4,
|
|
1284
|
+
"limit": 100,
|
|
1285
|
+
"items": [
|
|
1286
|
+
"PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM",
|
|
1287
|
+
"N4h8M9A9hasa3tF47qQyNvcKjm4APBKuFs7vqUVm-SI",
|
|
1288
|
+
"JcC4ZLUY76vmWha5y6RwKsFqYTrMZhbockl8iM9p5lQ",
|
|
1289
|
+
"31LPFYoow2G7j-eSSsrIh8OlNaARZ84-80J-8ba68d8"
|
|
1290
|
+
]
|
|
1291
|
+
}
|
|
1292
|
+
```
|
|
1293
|
+
|
|
1294
|
+
</details>
|
|
1295
|
+
|
|
1296
|
+
#### `getGatewayVaults({ address, cursor, limit, sortBy, sortOrder })`
|
|
1297
|
+
|
|
1298
|
+
Retrieves all vaults across all gateways for a specific address, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last vaultId from the previous request.
|
|
1299
|
+
|
|
1300
|
+
```typescript
|
|
1301
|
+
const io = IO.init();
|
|
1302
|
+
const vaults = await io.getGatewayVaults({
|
|
1303
|
+
address: '"PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM',
|
|
1304
|
+
});
|
|
1305
|
+
```
|
|
1306
|
+
|
|
1307
|
+
<details>
|
|
1308
|
+
<summary>Output</summary>
|
|
1309
|
+
|
|
1310
|
+
```json
|
|
1311
|
+
{
|
|
1312
|
+
"sortOrder": "desc",
|
|
1313
|
+
"hasMore": false,
|
|
1314
|
+
"totalItems": 1,
|
|
1315
|
+
"limit": 100,
|
|
1316
|
+
"sortBy": "endTimestamp",
|
|
1317
|
+
"items": [
|
|
1318
|
+
{
|
|
1319
|
+
"cursorId": "PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM_1728067635857",
|
|
1320
|
+
"startTimestamp": 1728067635857,
|
|
1321
|
+
"balance": 50000000000,
|
|
1322
|
+
"vaultId": "PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM",
|
|
1323
|
+
"endTimestamp": 1735843635857
|
|
1324
|
+
}
|
|
1325
|
+
]
|
|
1326
|
+
}
|
|
1327
|
+
```
|
|
1328
|
+
|
|
1329
|
+
</details>
|
|
1330
|
+
|
|
1260
1331
|
#### `instantWithdrawal({ gatewayAddress, vaultId })`
|
|
1261
1332
|
|
|
1262
1333
|
Instantly withdraws an existing vault on a gateway. If no `gatewayAddress` is provided, the signer's address will be used.
|
|
@@ -1522,6 +1593,47 @@ const { id: txId } = await io.requestPrimaryName({
|
|
|
1522
1593
|
});
|
|
1523
1594
|
```
|
|
1524
1595
|
|
|
1596
|
+
#### `redelegateStake({ target, source, stakeQty, vaultId })`
|
|
1597
|
+
|
|
1598
|
+
Redelegates the stake of a specific address to a new gateway. Vault ID may be optionally included in order to redelegate from an existing withdrawal vault. The redelegation fee is calculated based on the fee rate and the stake amount. Users are allowed one free redelegation every seven epochs. Each additional redelegation beyond the free redelegation will increase the fee by 10%, capping at a 60% redelegation fee.
|
|
1599
|
+
|
|
1600
|
+
e.g: If 1000 mIO is redelegated and the fee rate is 10%, the fee will be 100 mIO. Resulting in 900 mIO being redelegated to the new gateway and 100 mIO being deducted back to the protocol balance.
|
|
1601
|
+
|
|
1602
|
+
```typescript
|
|
1603
|
+
const io = IO.init({ signer: new ArweaveSigner(jwk) });
|
|
1604
|
+
|
|
1605
|
+
const { id: txId } = await io.redelegateStake({
|
|
1606
|
+
target: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
|
|
1607
|
+
source: 'HwFceQaMQnOBgKDpnFqCqgwKwEU5LBme1oXRuQOWSRA',
|
|
1608
|
+
stakeQty: new IOToken(1000).toMIO(),
|
|
1609
|
+
vaultId: 'fDrr0_J4Iurt7caNST02cMotaz2FIbWQ4Kcj616RHl3',
|
|
1610
|
+
});
|
|
1611
|
+
```
|
|
1612
|
+
|
|
1613
|
+
#### `getRedelegationFee({ address })`
|
|
1614
|
+
|
|
1615
|
+
Retrieves the fee rate as percentage required to redelegate the stake of a specific address. Fee rate ranges from 0% to 60% based on the number of redelegations since the last fee reset.
|
|
1616
|
+
|
|
1617
|
+
```typescript
|
|
1618
|
+
const io = IO.init();
|
|
1619
|
+
|
|
1620
|
+
const fee = await io.getRedelegationFee({
|
|
1621
|
+
address: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
|
|
1622
|
+
});
|
|
1623
|
+
```
|
|
1624
|
+
|
|
1625
|
+
<details>
|
|
1626
|
+
<summary>Output</summary>
|
|
1627
|
+
|
|
1628
|
+
```json
|
|
1629
|
+
{
|
|
1630
|
+
"redelegationFeeRate": 10,
|
|
1631
|
+
"feeResetTimestamp": 1730996691117
|
|
1632
|
+
}
|
|
1633
|
+
```
|
|
1634
|
+
|
|
1635
|
+
</details>
|
|
1636
|
+
|
|
1525
1637
|
### Configuration
|
|
1526
1638
|
|
|
1527
1639
|
The IO client class exposes APIs relevant to the ar.io process. It can be configured to use any AO Process ID that adheres to the [IO Network Spec]. By default, it will use the current [IO Testnet Process]. Refer to [AO Connect] for more information on how to configure an IO process to use specific AO infrastructure.
|
|
@@ -1717,43 +1829,21 @@ const records = await ant.getRecords();
|
|
|
1717
1829
|
<summary>Output</summary>
|
|
1718
1830
|
|
|
1719
1831
|
```json
|
|
1720
|
-
|
|
1721
|
-
{
|
|
1722
|
-
"
|
|
1723
|
-
"transactionId": "nOXJjj_vk0Dc1yCgdWD8kti_1iHruGzLQLNNBHVpN0Y",
|
|
1724
|
-
"ttlSeconds": 3600
|
|
1725
|
-
},
|
|
1726
|
-
{
|
|
1727
|
-
"name": "cn",
|
|
1728
|
-
"transactionId": "_HquerT6pfGFXrVxRxQTkJ7PV5RciZCqvMjLtUY0C1k",
|
|
1729
|
-
"ttlSeconds": 3300
|
|
1730
|
-
},
|
|
1731
|
-
{
|
|
1732
|
-
"name": "dapp",
|
|
1733
|
-
"transactionId": "hxlxVgAG0K4o3fVD9T6Q4VBWpPmMZwMWgRh1kcuh3WU",
|
|
1734
|
-
"ttlSeconds": 3600
|
|
1735
|
-
},
|
|
1736
|
-
{
|
|
1737
|
-
"name": "logo",
|
|
1738
|
-
"transactionId": "KKmRbIfrc7wiLcG0zvY1etlO0NBx1926dSCksxCIN3A",
|
|
1832
|
+
{
|
|
1833
|
+
"@": {
|
|
1834
|
+
"transactionId": "UyC5P5qKPZaltMmmZAWdakhlDXsBF6qmyrbWYFchRTk",
|
|
1739
1835
|
"ttlSeconds": 3600
|
|
1740
1836
|
},
|
|
1741
|
-
{
|
|
1742
|
-
"
|
|
1743
|
-
"
|
|
1744
|
-
"ttlSeconds": 3600
|
|
1837
|
+
"zed": {
|
|
1838
|
+
"transactionId": "-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI",
|
|
1839
|
+
"ttlSeconds": 900
|
|
1745
1840
|
},
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
"transactionId": "
|
|
1749
|
-
"ttlSeconds":
|
|
1750
|
-
},
|
|
1751
|
-
{
|
|
1752
|
-
"name": "og_logo",
|
|
1753
|
-
"transactionId": "TB2wJyKrPnkAW79DAwlJYwpgdHKpijEJWQfcwX715Co",
|
|
1754
|
-
"ttlSeconds": 3600
|
|
1841
|
+
|
|
1842
|
+
"ardrive": {
|
|
1843
|
+
"transactionId": "-cucucachoodwedwedoiwepodiwpodiwpoidpwoiedp",
|
|
1844
|
+
"ttlSeconds": 900
|
|
1755
1845
|
}
|
|
1756
|
-
|
|
1846
|
+
}
|
|
1757
1847
|
```
|
|
1758
1848
|
|
|
1759
1849
|
</details>
|
|
@@ -1931,7 +2021,7 @@ const { id: txId } = await ant.reassignName({
|
|
|
1931
2021
|
});
|
|
1932
2022
|
```
|
|
1933
2023
|
|
|
1934
|
-
#### `approvePrimaryNameRequest({ name, address })`
|
|
2024
|
+
#### `approvePrimaryNameRequest({ name, address, ioProcessId })`
|
|
1935
2025
|
|
|
1936
2026
|
Approves a primary name request for a given name or address.
|
|
1937
2027
|
|
|
@@ -1941,6 +2031,20 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
1941
2031
|
const { id: txId } = await ant.approvePrimaryNameRequest({
|
|
1942
2032
|
name: 'arns',
|
|
1943
2033
|
owner: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3', // must match the request initiator address
|
|
2034
|
+
ioProcessId: IO_TESTNET_PROCESS_ID, // the IO process id to use for the request
|
|
2035
|
+
});
|
|
2036
|
+
```
|
|
2037
|
+
|
|
2038
|
+
#### `removePrimaryNames({ names, ioProcessId })`
|
|
2039
|
+
|
|
2040
|
+
Removes primary names from the ANT process.
|
|
2041
|
+
|
|
2042
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2043
|
+
|
|
2044
|
+
```typescript
|
|
2045
|
+
const { id: txId } = await ant.removePrimaryNames({
|
|
2046
|
+
names: ['arns', 'test_arns'], // any primary names associated with a base name controlled by this ANT will be removed
|
|
2047
|
+
ioProcessId: IO_TESTNET_PROCESS_ID,
|
|
1944
2048
|
});
|
|
1945
2049
|
```
|
|
1946
2050
|
|