@ar.io/sdk 3.0.0-alpha.1 → 3.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 +43 -43
- package/bundles/web.bundle.min.js +1 -1
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +4 -4
- package/lib/cjs/cli/options.js +1 -1
- package/lib/cjs/cli/utils.js +5 -5
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/commands/gatewayWriteCommands.js +4 -4
- package/lib/esm/cli/options.js +1 -1
- package/lib/esm/cli/utils.js +5 -5
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/utils.d.ts +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -201,7 +201,7 @@ The SDK is provided in both CommonJS and ESM formats and is compatible with bund
|
|
|
201
201
|
#### Bundlers (Webpack, Rollup, ESbuild, etc.)
|
|
202
202
|
|
|
203
203
|
```javascript
|
|
204
|
-
import {
|
|
204
|
+
import { ARIO } from '@ar.io/sdk/web';
|
|
205
205
|
|
|
206
206
|
// set up client
|
|
207
207
|
const ario = ARIO.init();
|
|
@@ -216,7 +216,7 @@ const gateways = await ario.getGateways();
|
|
|
216
216
|
|
|
217
217
|
```html
|
|
218
218
|
<script type="module">
|
|
219
|
-
import {
|
|
219
|
+
import { ARIO } from 'https://unpkg.com/@ar.io/sdk';
|
|
220
220
|
|
|
221
221
|
// set up client
|
|
222
222
|
const ario = ARIO.init();
|
|
@@ -230,7 +230,7 @@ const gateways = await ario.getGateways();
|
|
|
230
230
|
#### ESM (NodeNext)
|
|
231
231
|
|
|
232
232
|
```javascript
|
|
233
|
-
import {
|
|
233
|
+
import { ARIO } from '@ar.io/sdk/node';
|
|
234
234
|
|
|
235
235
|
// set up client
|
|
236
236
|
const ario = ARIO.init();
|
|
@@ -321,7 +321,7 @@ const info = await ario.getInfo();
|
|
|
321
321
|
|
|
322
322
|
#### `getTokenSupply()`
|
|
323
323
|
|
|
324
|
-
Retrieves the total supply of tokens, returned in
|
|
324
|
+
Retrieves the total supply of tokens, returned in mARIO. The total supply includes the following:
|
|
325
325
|
|
|
326
326
|
- `total` - the total supply of all tokens
|
|
327
327
|
- `circulating` - the total supply minus locked, withdrawn, delegated, and staked
|
|
@@ -359,12 +359,12 @@ Retrieves the balance of the specified wallet address.
|
|
|
359
359
|
|
|
360
360
|
```typescript
|
|
361
361
|
const ario = ARIO.init();
|
|
362
|
-
// the balance will be returned in
|
|
362
|
+
// the balance will be returned in mARIO as a value
|
|
363
363
|
const balance = await ario
|
|
364
364
|
.getBalance({
|
|
365
365
|
address: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ',
|
|
366
366
|
})
|
|
367
|
-
.then((balance: number) => new mARIOToken(balance).toARIO()); // convert it to
|
|
367
|
+
.then((balance: number) => new mARIOToken(balance).toARIO()); // convert it to ARIO for readability
|
|
368
368
|
```
|
|
369
369
|
|
|
370
370
|
<details>
|
|
@@ -378,7 +378,7 @@ const balance = await ario
|
|
|
378
378
|
|
|
379
379
|
#### `getBalances({ cursor, limit, sortBy, sortOrder })`
|
|
380
380
|
|
|
381
|
-
Retrieves the balances of the
|
|
381
|
+
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.
|
|
382
382
|
|
|
383
383
|
```typescript
|
|
384
384
|
const ario = ARIO.init();
|
|
@@ -418,9 +418,9 @@ const balances = await ario.getBalances({
|
|
|
418
418
|
|
|
419
419
|
#### `transfer({ target, qty })`
|
|
420
420
|
|
|
421
|
-
Transfers `
|
|
421
|
+
Transfers `mARIO` to the designated `target` recipient address. Requires `signer` to be provided on `ARIO.init` to sign the transaction.
|
|
422
422
|
|
|
423
|
-
_Note: Requires `signer` to be provided on `
|
|
423
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
424
424
|
|
|
425
425
|
```typescript
|
|
426
426
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -438,7 +438,7 @@ const { id: txId } = await ario.transfer(
|
|
|
438
438
|
|
|
439
439
|
#### `getVault({ address, vaultId })`
|
|
440
440
|
|
|
441
|
-
Retrieves the locked-balance user vault of the
|
|
441
|
+
Retrieves the locked-balance user vault of the ARIO process by the specified wallet address and vault ID.
|
|
442
442
|
|
|
443
443
|
```typescript
|
|
444
444
|
const ario = ARIO.init();
|
|
@@ -463,7 +463,7 @@ const vault = await ario.getVault({
|
|
|
463
463
|
|
|
464
464
|
#### `getVaults({ cursor, limit, sortBy, sortOrder })`
|
|
465
465
|
|
|
466
|
-
Retrieves all locked-balance user vaults of the
|
|
466
|
+
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.
|
|
467
467
|
|
|
468
468
|
```typescript
|
|
469
469
|
const ario = ARIO.init();
|
|
@@ -560,7 +560,7 @@ const gateway = await ario.getGateway({
|
|
|
560
560
|
|
|
561
561
|
#### `getGateways({ cursor, limit, sortBy, sortOrder })`
|
|
562
562
|
|
|
563
|
-
Retrieves registered gateways of the
|
|
563
|
+
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.
|
|
564
564
|
|
|
565
565
|
```typescript
|
|
566
566
|
const ario = ARIO.init();
|
|
@@ -672,7 +672,7 @@ const delegates = await ario.getGatewayDelegates({
|
|
|
672
672
|
|
|
673
673
|
Joins a gateway to the ar.io network via its associated wallet.
|
|
674
674
|
|
|
675
|
-
_Note: Requires `signer` to be provided on `
|
|
675
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
676
676
|
|
|
677
677
|
```typescript
|
|
678
678
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -698,9 +698,9 @@ const { id: txId } = await ario.joinNetwork(
|
|
|
698
698
|
|
|
699
699
|
#### `leaveNetwork()`
|
|
700
700
|
|
|
701
|
-
Sets the gateway as `leaving` on the ar.io network. Requires `signer` to be provided on `
|
|
701
|
+
Sets the gateway as `leaving` on the ar.io network. Requires `signer` to be provided on `ARIO.init` to sign the transaction. The gateways operator and delegate stakes are vaulted and will be returned after leave periods. The gateway will be removed from the network after the leave period.
|
|
702
702
|
|
|
703
|
-
_Note: Requires `signer` to be provided on `
|
|
703
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
704
704
|
|
|
705
705
|
```typescript
|
|
706
706
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -715,7 +715,7 @@ const { id: txId } = await ario.leaveNetwork(
|
|
|
715
715
|
|
|
716
716
|
Writes new gateway settings to the callers gateway configuration.
|
|
717
717
|
|
|
718
|
-
_Note: Requires `signer` to be provided on `
|
|
718
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
719
719
|
|
|
720
720
|
```typescript
|
|
721
721
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -733,7 +733,7 @@ const { id: txId } = await ario.updateGatewaySettings(
|
|
|
733
733
|
|
|
734
734
|
Increases the callers stake on the target gateway.
|
|
735
735
|
|
|
736
|
-
_Note: Requires `signer` to be provided on `
|
|
736
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
737
737
|
|
|
738
738
|
```typescript
|
|
739
739
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -751,7 +751,7 @@ const { id: txId } = await ario.increaseDelegateStake(
|
|
|
751
751
|
|
|
752
752
|
Decreases the callers stake on the target gateway. Can instantly decrease stake by setting instant to `true`.
|
|
753
753
|
|
|
754
|
-
_Note: Requires `signer` to be provided on `
|
|
754
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
755
755
|
|
|
756
756
|
```typescript
|
|
757
757
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -830,7 +830,7 @@ const vaults = await ario.getDelegations({
|
|
|
830
830
|
|
|
831
831
|
Instantly withdraws an existing vault on a gateway. If no `gatewayAddress` is provided, the signer's address will be used.
|
|
832
832
|
|
|
833
|
-
_Note: Requires `signer` to be provided on `
|
|
833
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
834
834
|
|
|
835
835
|
```typescript
|
|
836
836
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -859,7 +859,7 @@ const { id: txId } = await ario.instantWithdrawal(
|
|
|
859
859
|
|
|
860
860
|
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.
|
|
861
861
|
|
|
862
|
-
_Note: Requires `signer` to be provided on `
|
|
862
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
863
863
|
|
|
864
864
|
```typescript
|
|
865
865
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -953,7 +953,7 @@ const vaults = await ario.getGatewayVaults({
|
|
|
953
953
|
|
|
954
954
|
Increases the callers operator stake. Must be executed with a wallet registered as a gateway operator.
|
|
955
955
|
|
|
956
|
-
_Note: Requires `signer` to be provided on `
|
|
956
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
957
957
|
|
|
958
958
|
```typescript
|
|
959
959
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -969,9 +969,9 @@ const { id: txId } = await ario.increaseOperatorStake(
|
|
|
969
969
|
|
|
970
970
|
#### `decreaseOperatorStake({ qty })`
|
|
971
971
|
|
|
972
|
-
Decreases the callers operator stake. Must be executed with a wallet registered as a gateway operator. Requires `signer` to be provided on `
|
|
972
|
+
Decreases the callers operator stake. Must be executed with a wallet registered as a gateway operator. Requires `signer` to be provided on `ARIO.init` to sign the transaction.
|
|
973
973
|
|
|
974
|
-
_Note: Requires `signer` to be provided on `
|
|
974
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
975
975
|
|
|
976
976
|
```typescript
|
|
977
977
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -989,7 +989,7 @@ const { id: txId } = await ario.decreaseOperatorStake(
|
|
|
989
989
|
|
|
990
990
|
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.
|
|
991
991
|
|
|
992
|
-
e.g: If 1000
|
|
992
|
+
e.g: If 1000 mARIO is redelegated and the fee rate is 10%, the fee will be 100 mARIO. Resulting in 900 mARIO being redelegated to the new gateway and 100 mARIO being deducted back to the protocol balance.
|
|
993
993
|
|
|
994
994
|
```typescript
|
|
995
995
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -1032,10 +1032,10 @@ const fee = await ario.getRedelegationFee({
|
|
|
1032
1032
|
|
|
1033
1033
|
Purchases a new ArNS record with the specified name, type, and duration.
|
|
1034
1034
|
|
|
1035
|
-
_Note: Requires `signer` to be provided on `
|
|
1035
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1036
1036
|
|
|
1037
1037
|
```typescript
|
|
1038
|
-
const ario = ARIO.init({ processId:
|
|
1038
|
+
const ario = ARIO.init({ processId: ARIO_DEVNET_PROCESS_ID, signer });
|
|
1039
1039
|
const record = await ario.buyRecord(
|
|
1040
1040
|
{ name: 'ardrive', type: 'lease', years: 1 },
|
|
1041
1041
|
{
|
|
@@ -1071,7 +1071,7 @@ const record = await ario.getArNSRecord({ name: 'ardrive' });
|
|
|
1071
1071
|
|
|
1072
1072
|
#### `getArNSRecords({ cursor, limit, sortBy, sortOrder })`
|
|
1073
1073
|
|
|
1074
|
-
Retrieves all registered ArNS records of the
|
|
1074
|
+
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.
|
|
1075
1075
|
|
|
1076
1076
|
```typescript
|
|
1077
1077
|
const ario = ARIO.init();
|
|
@@ -1147,7 +1147,7 @@ Available `sortBy` options are any of the keys on the record object, e.g. `name`
|
|
|
1147
1147
|
|
|
1148
1148
|
Increases the undername support of a domain up to a maximum of 10k. Domains, by default, support up to 10 undernames.
|
|
1149
1149
|
|
|
1150
|
-
_Note: Requires `signer` to be provided on `
|
|
1150
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1151
1151
|
|
|
1152
1152
|
```typescript
|
|
1153
1153
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -1179,7 +1179,7 @@ const { id: txId } = await ario.extendLease(
|
|
|
1179
1179
|
|
|
1180
1180
|
#### `getTokenCost({ intent, ...args })`
|
|
1181
1181
|
|
|
1182
|
-
Calculates the price in
|
|
1182
|
+
Calculates the price in mARIO to perform the interaction in question, eg a 'Buy-record' interaction, where args are the specific params for that interaction.
|
|
1183
1183
|
|
|
1184
1184
|
```typescript
|
|
1185
1185
|
const price = await ario
|
|
@@ -1188,7 +1188,7 @@ const price = await ario
|
|
|
1188
1188
|
name: 'ar-io',
|
|
1189
1189
|
type: 'permabuy',
|
|
1190
1190
|
})
|
|
1191
|
-
.then((p) => new mARIOToken(p).toARIO()); // convert to
|
|
1191
|
+
.then((p) => new mARIOToken(p).toARIO()); // convert to ARIO for readability
|
|
1192
1192
|
```
|
|
1193
1193
|
|
|
1194
1194
|
<details>
|
|
@@ -1220,7 +1220,7 @@ const demandFactor = await ario.getDemandFactor();
|
|
|
1220
1220
|
|
|
1221
1221
|
#### `getArNSReturnedNames({ cursor, limit, sortBy, sortOrder })`
|
|
1222
1222
|
|
|
1223
|
-
Retrieves all active returned names of the
|
|
1223
|
+
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.
|
|
1224
1224
|
|
|
1225
1225
|
```typescript
|
|
1226
1226
|
const ario = ARIO.init();
|
|
@@ -1384,7 +1384,7 @@ const epoch = await ario.getEpoch({ epochIndex: 0 });
|
|
|
1384
1384
|
{
|
|
1385
1385
|
"gatewayAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
1386
1386
|
"observerAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
1387
|
-
"stake": 10000000000, // value in
|
|
1387
|
+
"stake": 10000000000, // value in mARIO
|
|
1388
1388
|
"startTimestamp": 1720720620813,
|
|
1389
1389
|
"stakeWeight": 1,
|
|
1390
1390
|
"tenureWeight": 0.4494598765432099,
|
|
@@ -1487,9 +1487,9 @@ const distributions = await ario.getDistributions({ epochIndex: 0 });
|
|
|
1487
1487
|
|
|
1488
1488
|
#### `saveObservations({ reportTxId, failedGateways })`
|
|
1489
1489
|
|
|
1490
|
-
Saves the observations of the current epoch. Requires `signer` to be provided on `
|
|
1490
|
+
Saves the observations of the current epoch. Requires `signer` to be provided on `ARIO.init` to sign the transaction.
|
|
1491
1491
|
|
|
1492
|
-
_Note: Requires `signer` to be provided on `
|
|
1492
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1493
1493
|
|
|
1494
1494
|
```typescript
|
|
1495
1495
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -1508,7 +1508,7 @@ const { id: txId } = await ario.saveObservations(
|
|
|
1508
1508
|
|
|
1509
1509
|
#### `getPrescribedObservers({ epochIndex })`
|
|
1510
1510
|
|
|
1511
|
-
Retrieves the prescribed observers of the
|
|
1511
|
+
Retrieves the prescribed observers of the ARIO process. To fetch prescribed observers for a previous epoch set the `epochIndex` to the desired epoch index.
|
|
1512
1512
|
|
|
1513
1513
|
```typescript
|
|
1514
1514
|
const ario = ARIO.init();
|
|
@@ -1523,7 +1523,7 @@ const observers = await ario.getPrescribedObservers({ epochIndex: 0 });
|
|
|
1523
1523
|
{
|
|
1524
1524
|
"gatewayAddress": "BpQlyhREz4lNGS-y3rSS1WxADfxPpAuing9Lgfdrj2U",
|
|
1525
1525
|
"observerAddress": "2Fk8lCmDegPg6jjprl57-UCpKmNgYiKwyhkU4vMNDnE",
|
|
1526
|
-
"stake": 10000000000, // value in
|
|
1526
|
+
"stake": 10000000000, // value in mARIO
|
|
1527
1527
|
"start": 1296976,
|
|
1528
1528
|
"stakeWeight": 1,
|
|
1529
1529
|
"tenureWeight": 0.41453703703703704,
|
|
@@ -1608,7 +1608,7 @@ const name = await ario.getPrimaryName({
|
|
|
1608
1608
|
|
|
1609
1609
|
Requests a primary name for the caller's address. The request must be approved by the new owner of the requested name via the `approvePrimaryNameRequest`[#approveprimarynamerequest-name-address-] API.
|
|
1610
1610
|
|
|
1611
|
-
_Note: Requires `signer` to be provided on `
|
|
1611
|
+
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1612
1612
|
|
|
1613
1613
|
```typescript
|
|
1614
1614
|
const ario = ARIO.init({ signer: new ArweaveSigner(jwk) });
|
|
@@ -1644,13 +1644,13 @@ const request = await ario.getPrimaryNameRequest({
|
|
|
1644
1644
|
|
|
1645
1645
|
### Configuration
|
|
1646
1646
|
|
|
1647
|
-
The
|
|
1647
|
+
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.
|
|
1648
1648
|
|
|
1649
1649
|
```typescript
|
|
1650
1650
|
// provide a custom ao infrastructure and process id
|
|
1651
1651
|
const ario = ARIO.init({
|
|
1652
1652
|
process: new AoProcess({
|
|
1653
|
-
processId: '
|
|
1653
|
+
processId: 'ARIO_PROCESS_ID'
|
|
1654
1654
|
ao: connect({
|
|
1655
1655
|
MU_URL: 'https://mu-testnet.xyz',
|
|
1656
1656
|
CU_URL: 'https://cu-testnet.xyz',
|
|
@@ -2003,14 +2003,14 @@ const { id: txId } = await ant.setLogo(
|
|
|
2003
2003
|
|
|
2004
2004
|
#### `releaseName({ name, arioProcessId })`
|
|
2005
2005
|
|
|
2006
|
-
Releases a name from the current owner and makes it available for purchase on the
|
|
2006
|
+
Releases a name from the current owner and makes it available for purchase on the ARIO contract. The name must be permanently owned by the releasing wallet. If purchased within the recently returned name period (14 epochs), 50% of the purchase amount will be distributed to the ANT owner at the time of release. If no purchases in the recently returned name period, the name can be reregistered by anyone for the normal fee.
|
|
2007
2007
|
|
|
2008
2008
|
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2009
2009
|
|
|
2010
2010
|
```typescript
|
|
2011
2011
|
const { id: txId } = await ant.releaseName({
|
|
2012
2012
|
name: 'permalink',
|
|
2013
|
-
arioProcessId: ARIO_TESTNET_PROCESS_ID, // releases the name owned by the ANT and sends it to recently returned names on the
|
|
2013
|
+
arioProcessId: ARIO_TESTNET_PROCESS_ID, // releases the name owned by the ANT and sends it to recently returned names on the ARIO contract
|
|
2014
2014
|
});
|
|
2015
2015
|
```
|
|
2016
2016
|
|
|
@@ -2190,8 +2190,8 @@ For more information on how to contribute, please see [CONTRIBUTING.md].
|
|
|
2190
2190
|
[examples/vite]: ./examples/vite
|
|
2191
2191
|
[CONTRIBUTING.md]: ./CONTRIBUTING.md
|
|
2192
2192
|
[AO Connect]: https://github.com/permaweb/ao/tree/main/connect
|
|
2193
|
-
[
|
|
2194
|
-
[
|
|
2193
|
+
[ARIO Testnet Process]: https://www.ao.link/#/entity/agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA
|
|
2194
|
+
[ARIO Network Spec]: https://github.com/ar-io/ar-io-network-process?tab=readme-ov-file#contract-spec
|
|
2195
2195
|
[Winston]: https://www.npmjs.com/package/winston
|
|
2196
2196
|
[AO]: https://github.com/permaweb/ao
|
|
2197
2197
|
[ar-io-node repository]: https://github.com/ar-io/ar-io-node
|