@ar.io/sdk 3.8.1 → 3.8.2-alpha.1

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
@@ -13,7 +13,7 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
13
13
  - [Installation](#installation)
14
14
  - [Quick Start](#quick-start)
15
15
  - [Usage](#usage)
16
- - [Mainnet and Testnet Process IDs](#mainnet-and-testnet-process-ids)
16
+ - [Networks (Mainnet, Testnet, etc.)](#networks-mainnet-testnet-etc)
17
17
  - [Web](#web)
18
18
  - [Bundlers (Webpack, Rollup, ESbuild, etc.)](#bundlers-webpack-rollup-esbuild-etc)
19
19
  - [Browser](#browser)
@@ -151,9 +151,9 @@ yarn add @ar.io/sdk --ignore-engines
151
151
  ## Quick Start
152
152
 
153
153
  ```typescript
154
- import { ARIO, ARIO_MAINNET_PROCESS_ID } from '@ar.io/sdk';
154
+ import { ARIO } from '@ar.io/sdk';
155
155
 
156
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
156
+ const ario = ARIO.init(); // defaults to mainnet
157
157
  const gateways = await ario.getGateways();
158
158
  ```
159
159
 
@@ -209,25 +209,27 @@ const gateways = await ario.getGateways();
209
209
 
210
210
  The SDK is provided in both CommonJS and ESM formats and is compatible with bundlers such as Webpack, Rollup, and ESbuild. Utilize the appropriately named exports provided by this SDK's [package.json] based on your project's configuration. Refer to the [examples] directory to see how to use the SDK in various environments.
211
211
 
212
- ### Mainnet and Testnet Process IDs
212
+ ### Networks (Mainnet, Testnet, etc.)
213
213
 
214
214
  The SDK provides the following process IDs for the mainnet and testnet environments:
215
215
 
216
- - `ARIO_MAINNET_PROCESS_ID` - Mainnet ARIO process ID
217
- - `ARIO_TESTNET_PROCESS_ID` - Testnet ARIO process ID
216
+ - `ARIO_MAINNET_PROCESS_ID` - Mainnet ARIO process ID (production)
217
+ - `ARIO_TESTNET_PROCESS_ID` - Testnet ARIO process ID (testing and development)
218
+ - `ARIO_DEVNET_PROCESS_ID` - Devnet ARIO process ID (for development purposes)
219
+
220
+ As of `v3.8.1` the SDK defaults all API interactions to **mainnet**. To use the **testnet** or **devnet** provide the appropriate `ARIO_TESTNET_PROCESS_ID` or `ARIO_DEVNET_PROCESS_ID` when initializing the client.
218
221
 
219
222
  ```typescript
220
223
  import {
221
224
  ARIO,
225
+ ARIO_DEVNET_PROCESS_ID,
222
226
  ARIO_MAINNET_PROCESS_ID,
223
227
  ARIO_TESTNET_PROCESS_ID,
224
228
  } from '@ar.io/sdk';
225
229
  ```
226
230
 
227
- By default, the SDK will use the mainnet process ID. To use the testnet process ID, provide the `ARIO_TESTNET_PROCESS_ID` when initializing the client.
228
-
229
231
  ```typescript
230
- const ario = ARIO.init({ processId: ARIO_TESTNET_PROCESS_ID });
232
+ const ario = ARIO.init({ processId: ARIO_TESTNET_PROCESS_ID }); // use the testnet contract
231
233
  ```
232
234
 
233
235
  ### Web
@@ -235,10 +237,10 @@ const ario = ARIO.init({ processId: ARIO_TESTNET_PROCESS_ID });
235
237
  #### Bundlers (Webpack, Rollup, ESbuild, etc.)
236
238
 
237
239
  ```javascript
238
- import { ARIO, ARIO_MAINNET_PROCESS_ID } from '@ar.io/sdk/web';
240
+ import { ARIO } from '@ar.io/sdk/web';
239
241
 
240
242
  // set up client
241
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
243
+ const ario = ARIO.init();
242
244
  // fetch gateways
243
245
  const gateways = await ario.getGateways();
244
246
  ```
@@ -250,10 +252,10 @@ const gateways = await ario.getGateways();
250
252
 
251
253
  ```html
252
254
  <script type="module">
253
- import { ARIO, ARIO_MAINNET_PROCESS_ID } from 'https://unpkg.com/@ar.io/sdk';
255
+ import { ARIO } from 'https://unpkg.com/@ar.io/sdk';
254
256
 
255
257
  // set up client
256
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
258
+ const ario = ARIO.init();
257
259
  // fetch gateways
258
260
  const gateways = await ario.getGateways();
259
261
  </script>
@@ -264,10 +266,10 @@ const gateways = await ario.getGateways();
264
266
  #### ESM (NodeNext)
265
267
 
266
268
  ```javascript
267
- import { ARIO, ARIO_MAINNET_PROCESS_ID } from '@ar.io/sdk/node';
269
+ import { ARIO } from '@ar.io/sdk/node';
268
270
 
269
271
  // set up client
270
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
272
+ const ario = ARIO.init();
271
273
  // fetch gateways
272
274
  const gateways = await ario.getGateways();
273
275
  ```
@@ -275,10 +277,10 @@ const gateways = await ario.getGateways();
275
277
  #### CJS
276
278
 
277
279
  ```javascript
278
- import { ARIO, ARIO_MAINNET_PROCESS_ID } from '@ar.io/sdk';
280
+ import { ARIO } from '@ar.io/sdk';
279
281
 
280
282
  // set up client
281
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
283
+ const ario = ARIO.init();
282
284
  // fetch gateways
283
285
  const gateways = await ario.getGateways();
284
286
  ```
@@ -318,13 +320,13 @@ Factory function to that creates a read-only or writeable client. By providing a
318
320
 
319
321
  ```typescript
320
322
  // read-only client
321
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
323
+ const ario = ARIO.init();
322
324
 
323
325
  // read-write client for browser environments
324
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID, signer: new ArConnectSigner(window.arweaveWallet, Arweave.init({}))});
326
+ const ario = ARIO.init({ signer: new ArConnectSigner(window.arweaveWallet, Arweave.init({}))});
325
327
 
326
328
  // read-write client for node environments
327
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID, signer: new ArweaveSigner(JWK) });
329
+ const ario = ARIO.init({ signer: new ArweaveSigner(JWK) });
328
330
 
329
331
  ```
330
332
 
@@ -333,7 +335,7 @@ const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID, signer: new Arweave
333
335
  Retrieves the information of the ARIO process.
334
336
 
335
337
  ```typescript
336
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
338
+ const ario = ARIO.init();
337
339
  const info = await ario.getInfo();
338
340
  ```
339
341
 
@@ -367,7 +369,7 @@ Retrieves the total supply of tokens, returned in mARIO. The total supply includ
367
369
  - `protocolBalance` - tokens that are held in the protocol's treasury. This is included in the circulating supply.
368
370
 
369
371
  ```typescript
370
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
372
+ const ario = ARIO.init();
371
373
  const supply = await ario.getTokenSupply();
372
374
  ```
373
375
 
@@ -393,7 +395,7 @@ const supply = await ario.getTokenSupply();
393
395
  Retrieves the balance of the specified wallet address.
394
396
 
395
397
  ```typescript
396
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
398
+ const ario = ARIO.init();
397
399
  // the balance will be returned in mARIO as a value
398
400
  const balance = await ario
399
401
  .getBalance({
@@ -416,7 +418,7 @@ const balance = await ario
416
418
  Retrieves the balances of the ARIO process in `mARIO`, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last wallet address from the previous request.
417
419
 
418
420
  ```typescript
419
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
421
+ const ario = ARIO.init();
420
422
  const balances = await ario.getBalances({
421
423
  cursor: '-4xgjroXENKYhTWqrBo57HQwvDL51mMdfsdsxJy6Y2Z_sA',
422
424
  limit: 100,
@@ -479,7 +481,7 @@ const { id: txId } = await ario.transfer(
479
481
  Retrieves the locked-balance user vault of the ARIO process by the specified wallet address and vault ID.
480
482
 
481
483
  ```typescript
482
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
484
+ const ario = ARIO.init();
483
485
  const vault = await ario.getVault({
484
486
  address: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ',
485
487
  vaultId: 'vaultIdOne',
@@ -504,7 +506,7 @@ const vault = await ario.getVault({
504
506
  Retrieves all locked-balance user vaults of the ARIO process, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last wallet address from the previous request.
505
507
 
506
508
  ```typescript
507
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
509
+ const ario = ARIO.init();
508
510
  const vaults = await ario.getVaults({
509
511
  cursor: '0',
510
512
  limit: 100,
@@ -637,7 +639,7 @@ const { id: txId } = await ario.increaseVault({
637
639
  Retrieves a gateway's info by its staking wallet address.
638
640
 
639
641
  ```typescript
640
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
642
+ const ario = ARIO.init();
641
643
  const gateway = await ario.getGateway({
642
644
  address: '-7vXsQZQDk8TMDlpiSLy3CnLi5PDPlAaN2DaynORpck',
643
645
  });
@@ -686,7 +688,7 @@ const gateway = await ario.getGateway({
686
688
  Retrieves registered gateways of the ARIO process, using pagination and sorting by the specified criteria. The `cursor` used for pagination is the last gateway address from the previous request.
687
689
 
688
690
  ```typescript
689
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
691
+ const ario = ARIO.init();
690
692
  const gateways = await ario.getGateways({
691
693
  limit: 100,
692
694
  sortOrder: 'desc',
@@ -749,7 +751,7 @@ Available `sortBy` options are any of the keys on the gateway object, e.g. `oper
749
751
  Retrieves all delegates for a specific gateway, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last delegate address from the previous request.
750
752
 
751
753
  ```typescript
752
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
754
+ const ario = ARIO.init();
753
755
  const delegates = await ario.getGatewayDelegates({
754
756
  address: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ',
755
757
  limit: 3,
@@ -923,7 +925,7 @@ const { id: txId } = await ario.decreaseDelegateStake({
923
925
  Retrieves all active and vaulted stakes across all gateways for a specific address, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last delegationId (concatenated gateway and startTimestamp of the delgation) from the previous request.
924
926
 
925
927
  ```typescript
926
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
928
+ const ario = ARIO.init();
927
929
  const vaults = await ario.getDelegations({
928
930
  address: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
929
931
  cursor: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ_123456789',
@@ -974,7 +976,7 @@ Instantly withdraws an existing vault on a gateway. If no `gatewayAddress` is pr
974
976
  _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
975
977
 
976
978
  ```typescript
977
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID, signer: new ArweaveSigner(jwk) });
979
+ const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
978
980
  // removes a delegated vault from a gateway
979
981
  const { id: txId } = await ario.instantWithdrawal(
980
982
  {
@@ -1003,7 +1005,7 @@ Cancels an existing vault on a gateway. The vaulted stake will be returned to th
1003
1005
  _Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
1004
1006
 
1005
1007
  ```typescript
1006
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID, signer: new ArweaveSigner(jwk) });
1008
+ const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
1007
1009
  // cancels a delegated vault from a gateway
1008
1010
  const { id: txId } = await ario.cancelWithdrawal(
1009
1011
  {
@@ -1029,7 +1031,7 @@ const { id: txId } = await ario.cancelWithdrawal(
1029
1031
  Retrieves all allowed delegates for a specific address. The `cursor` used for pagination is the last address from the previous request.
1030
1032
 
1031
1033
  ```typescript
1032
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1034
+ const ario = ARIO.init();
1033
1035
  const allowedDelegates = await ario.getAllowedDelegates({
1034
1036
  address: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ',
1035
1037
  });
@@ -1060,7 +1062,7 @@ const allowedDelegates = await ario.getAllowedDelegates({
1060
1062
  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.
1061
1063
 
1062
1064
  ```typescript
1063
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1065
+ const ario = ARIO.init();
1064
1066
  const vaults = await ario.getGatewayVaults({
1065
1067
  address: '"PZ5vIhHf8VY969TxBPQN-rYY9CNFP9ggNsMBqlWUzWM',
1066
1068
  });
@@ -1095,7 +1097,7 @@ const vaults = await ario.getGatewayVaults({
1095
1097
  Retrieves all vaults across all gateways, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last vaultId from the previous request.
1096
1098
 
1097
1099
  ```typescript
1098
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1100
+ const ario = ARIO.init();
1099
1101
  const vaults = await ario.getAllGatewayVaults({
1100
1102
  limit: 1,
1101
1103
  sortBy: 'endTimestamp',
@@ -1196,7 +1198,7 @@ const { id: txId } = await ario.redelegateStake({
1196
1198
  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.
1197
1199
 
1198
1200
  ```typescript
1199
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1201
+ const ario = ARIO.init();
1200
1202
 
1201
1203
  const fee = await ario.getRedelegationFee({
1202
1204
  address: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
@@ -1220,7 +1222,7 @@ const fee = await ario.getRedelegationFee({
1220
1222
  Retrieves all delegates across all gateways, paginated and sorted by the specified criteria. The `cursor` used for pagination is a `cursorId` derived from delegate address and the gatewayAddress from the previous request. e.g `address_gatewayAddress`.
1221
1223
 
1222
1224
  ```typescript
1223
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1225
+ const ario = ARIO.init();
1224
1226
  const delegates = await ario.getAllDelegates({
1225
1227
  limit: 2,
1226
1228
  sortBy: 'startTimestamp',
@@ -1286,7 +1288,7 @@ const record = await ario.buyRecord(
1286
1288
  Retrieves the record info of the specified ArNS name.
1287
1289
 
1288
1290
  ```typescript
1289
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1291
+ const ario = ARIO.init();
1290
1292
  const record = await ario.getArNSRecord({ name: 'ardrive' });
1291
1293
  ```
1292
1294
 
@@ -1310,7 +1312,7 @@ const record = await ario.getArNSRecord({ name: 'ardrive' });
1310
1312
  Retrieves all registered ArNS records of the ARIO process, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last ArNS name from the previous request.
1311
1313
 
1312
1314
  ```typescript
1313
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1315
+ const ario = ARIO.init();
1314
1316
  // get the newest 100 names
1315
1317
  const records = await ario.getArNSRecords({
1316
1318
  limit: 100,
@@ -1507,7 +1509,7 @@ const demandFactor = await ario.getDemandFactor();
1507
1509
  Retrieves all active returned names of the ARIO process, paginated and sorted by the specified criteria. The `cursor` used for pagination is the last returned name from the previous request.
1508
1510
 
1509
1511
  ```typescript
1510
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1512
+ const ario = ARIO.init();
1511
1513
  const returnedNames = await ario.getArNSReturnedNames({
1512
1514
  limit: 100,
1513
1515
  sortBy: 'endTimestamp',
@@ -1550,7 +1552,7 @@ const returnedNames = await ario.getArNSReturnedNames({
1550
1552
  Retrieves the returned name data for the specified returned name.
1551
1553
 
1552
1554
  ```typescript
1553
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1555
+ const ario = ARIO.init();
1554
1556
  const returnedName = await ario.getArNSReturnedName({ name: 'permalink' });
1555
1557
  ```
1556
1558
 
@@ -1583,7 +1585,7 @@ const returnedName = await ario.getArNSReturnedName({ name: 'permalink' });
1583
1585
  Returns the current epoch data.
1584
1586
 
1585
1587
  ```typescript
1586
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1588
+ const ario = ARIO.init();
1587
1589
  const epoch = await ario.getCurrentEpoch();
1588
1590
  ```
1589
1591
 
@@ -1639,7 +1641,7 @@ const epoch = await ario.getCurrentEpoch();
1639
1641
  Returns the epoch data for the specified block height. If no epoch index is provided, the current epoch is used.
1640
1642
 
1641
1643
  ```typescript
1642
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1644
+ const ario = ARIO.init();
1643
1645
  const epoch = await ario.getEpoch({ epochIndex: 0 });
1644
1646
  ```
1645
1647
 
@@ -1701,7 +1703,7 @@ const epoch = await ario.getEpoch({ epochIndex: 0 });
1701
1703
  Returns the eligible epoch rewards for the specified block height. If no epoch index is provided, the current epoch is used.
1702
1704
 
1703
1705
  ```typescript
1704
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1706
+ const ario = ARIO.init();
1705
1707
  const rewards = await ario.getEligibleEpochRewards({ epochIndex: 0 });
1706
1708
  ```
1707
1709
 
@@ -1734,7 +1736,7 @@ const rewards = await ario.getEligibleEpochRewards({ epochIndex: 0 });
1734
1736
  Returns the epoch-indexed observation list. If no epoch index is provided, the current epoch is used.
1735
1737
 
1736
1738
  ```typescript
1737
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1739
+ const ario = ARIO.init();
1738
1740
  const observations = await ario.getObservations();
1739
1741
  ```
1740
1742
 
@@ -1767,7 +1769,7 @@ const observations = await ario.getObservations();
1767
1769
  Returns the current rewards distribution information. If no epoch index is provided, the current epoch is used.
1768
1770
 
1769
1771
  ```typescript
1770
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1772
+ const ario = ARIO.init();
1771
1773
  const distributions = await ario.getDistributions({ epochIndex: 0 });
1772
1774
  ```
1773
1775
 
@@ -1822,7 +1824,7 @@ const { id: txId } = await ario.saveObservations(
1822
1824
  Retrieves the prescribed observers of the ARIO process. To fetch prescribed observers for a previous epoch set the `epochIndex` to the desired epoch index.
1823
1825
 
1824
1826
  ```typescript
1825
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1827
+ const ario = ARIO.init();
1826
1828
  const observers = await ario.getPrescribedObservers({ epochIndex: 0 });
1827
1829
  ```
1828
1830
 
@@ -1855,7 +1857,7 @@ const observers = await ario.getPrescribedObservers({ epochIndex: 0 });
1855
1857
  Retrieves all primary names paginated and sorted by the specified criteria. The `cursor` used for pagination is the last name from the previous request.
1856
1858
 
1857
1859
  ```typescript
1858
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1860
+ const ario = ARIO.init();
1859
1861
  const names = await ario.getPrimaryNames({
1860
1862
  cursor: 'ao', // this is the last name from the previous request
1861
1863
  limit: 1,
@@ -1892,7 +1894,7 @@ const names = await ario.getPrimaryNames({
1892
1894
  Retrieves the primary name for a given name or address.
1893
1895
 
1894
1896
  ```typescript
1895
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1897
+ const ario = ARIO.init();
1896
1898
  const name = await ario.getPrimaryName({
1897
1899
  name: 'arns',
1898
1900
  });
@@ -1933,7 +1935,7 @@ const { id: txId } = await ario.requestPrimaryName({
1933
1935
  Retrieves the primary name request for a a wallet address.
1934
1936
 
1935
1937
  ```typescript
1936
- const ario = ARIO.init({ processId: ARIO_MAINNET_PROCESS_ID });
1938
+ const ario = ARIO.init();
1937
1939
  const request = await ario.getPrimaryNameRequest({
1938
1940
  initiator: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
1939
1941
  });
@@ -1958,6 +1960,9 @@ const request = await ario.getPrimaryNameRequest({
1958
1960
  The ARIO client class exposes APIs relevant to the ar.io process. It can be configured to use any AO Process ID that adheres to the [ARIO Network Spec]. By default, it will use the current [ARIO Testnet Process]. Refer to [AO Connect] for more information on how to configure an ARIO process to use specific AO infrastructure.
1959
1961
 
1960
1962
  ```typescript
1963
+ import { ARIO } from '@ar.io/sdk';
1964
+ import { connect } from '@permaweb/aoconnect';
1965
+
1961
1966
  // provide a custom ao infrastructure and process id
1962
1967
  const ario = ARIO.init({
1963
1968
  process: new AoProcess({