@ar.io/sdk 3.8.0 → 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 +97 -22
- package/bundles/web.bundle.min.js +55 -55
- package/lib/cjs/cli/utils.js +2 -5
- package/lib/cjs/common/ant.js +4 -4
- package/lib/cjs/common/contracts/ao-process.js +86 -79
- package/lib/cjs/common/io.js +2 -2
- package/lib/cjs/utils/arweave.js +3 -3
- package/lib/cjs/utils/processes.js +2 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/utils.js +2 -5
- package/lib/esm/common/ant.js +4 -4
- package/lib/esm/common/contracts/ao-process.js +86 -79
- package/lib/esm/common/io.js +3 -3
- package/lib/esm/utils/arweave.js +4 -4
- package/lib/esm/utils/processes.js +3 -3
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/utils.d.ts +1 -1
- package/lib/types/common/ant.d.ts +4 -4
- package/lib/types/types/common.d.ts +12 -0
- package/lib/types/utils/arweave.d.ts +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +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
|
+
- [Networks (Mainnet, Testnet, etc.)](#networks-mainnet-testnet-etc)
|
|
16
17
|
- [Web](#web)
|
|
17
18
|
- [Bundlers (Webpack, Rollup, ESbuild, etc.)](#bundlers-webpack-rollup-esbuild-etc)
|
|
18
19
|
- [Browser](#browser)
|
|
@@ -152,7 +153,7 @@ yarn add @ar.io/sdk --ignore-engines
|
|
|
152
153
|
```typescript
|
|
153
154
|
import { ARIO } from '@ar.io/sdk';
|
|
154
155
|
|
|
155
|
-
const ario = ARIO.init();
|
|
156
|
+
const ario = ARIO.init(); // defaults to mainnet
|
|
156
157
|
const gateways = await ario.getGateways();
|
|
157
158
|
```
|
|
158
159
|
|
|
@@ -208,6 +209,29 @@ const gateways = await ario.getGateways();
|
|
|
208
209
|
|
|
209
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.
|
|
210
211
|
|
|
212
|
+
### Networks (Mainnet, Testnet, etc.)
|
|
213
|
+
|
|
214
|
+
The SDK provides the following process IDs for the mainnet and testnet environments:
|
|
215
|
+
|
|
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.
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
import {
|
|
224
|
+
ARIO,
|
|
225
|
+
ARIO_DEVNET_PROCESS_ID,
|
|
226
|
+
ARIO_MAINNET_PROCESS_ID,
|
|
227
|
+
ARIO_TESTNET_PROCESS_ID,
|
|
228
|
+
} from '@ar.io/sdk';
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
const ario = ARIO.init({ processId: ARIO_TESTNET_PROCESS_ID }); // use the testnet contract
|
|
233
|
+
```
|
|
234
|
+
|
|
211
235
|
### Web
|
|
212
236
|
|
|
213
237
|
#### Bundlers (Webpack, Rollup, ESbuild, etc.)
|
|
@@ -296,7 +320,7 @@ Factory function to that creates a read-only or writeable client. By providing a
|
|
|
296
320
|
|
|
297
321
|
```typescript
|
|
298
322
|
// read-only client
|
|
299
|
-
const ario = ARIO.init()
|
|
323
|
+
const ario = ARIO.init();
|
|
300
324
|
|
|
301
325
|
// read-write client for browser environments
|
|
302
326
|
const ario = ARIO.init({ signer: new ArConnectSigner(window.arweaveWallet, Arweave.init({}))});
|
|
@@ -436,7 +460,10 @@ Transfers `mARIO` to the designated `target` recipient address. Requires `signer
|
|
|
436
460
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
437
461
|
|
|
438
462
|
```typescript
|
|
439
|
-
const ario = ARIO.init({
|
|
463
|
+
const ario = ARIO.init({
|
|
464
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
465
|
+
signer: new ArweaveSigner(jwk),
|
|
466
|
+
});
|
|
440
467
|
const { id: txId } = await ario.transfer(
|
|
441
468
|
{
|
|
442
469
|
target: '-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5',
|
|
@@ -547,7 +574,10 @@ Revokes a vaulted transfer by the recipient address and vault ID. Only the sende
|
|
|
547
574
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
548
575
|
|
|
549
576
|
```typescript
|
|
550
|
-
const ario = ARIO.init({
|
|
577
|
+
const ario = ARIO.init({
|
|
578
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
579
|
+
signer: new ArweaveSigner(jwk),
|
|
580
|
+
});
|
|
551
581
|
const { id: txId } = await ario.revokeVault({
|
|
552
582
|
recipient: '-5dV7nk7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5',
|
|
553
583
|
vaultId: 'IPdwa3Mb_9pDD8c2IaJx6aad51Ss-_TfStVwBuhtXMs',
|
|
@@ -559,7 +589,10 @@ const { id: txId } = await ario.revokeVault({
|
|
|
559
589
|
Creates a vault for the specified `quantity` of mARIO from the signer's balance and locks it for the specified `lockLengthMs` milliseconds.
|
|
560
590
|
|
|
561
591
|
```typescript
|
|
562
|
-
const ario = ARIO.init({
|
|
592
|
+
const ario = ARIO.init({
|
|
593
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
594
|
+
signer: new ArweaveSigner(jwk),
|
|
595
|
+
});
|
|
563
596
|
|
|
564
597
|
const { id: txId } = await ario.createVault({
|
|
565
598
|
lockLengthMs: 1000 * 60 * 60 * 24 * 365, // 1 year
|
|
@@ -572,7 +605,10 @@ const { id: txId } = await ario.createVault({
|
|
|
572
605
|
Extends the lock length of a signer's vault by the specified `extendLengthMs` milliseconds.
|
|
573
606
|
|
|
574
607
|
```typescript
|
|
575
|
-
const ario = ARIO.init({
|
|
608
|
+
const ario = ARIO.init({
|
|
609
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
610
|
+
signer: new ArweaveSigner(jwk),
|
|
611
|
+
});
|
|
576
612
|
|
|
577
613
|
const { id: txId } = await ario.extendVault({
|
|
578
614
|
vaultId: 'vaultIdOne',
|
|
@@ -585,7 +621,10 @@ const { id: txId } = await ario.extendVault({
|
|
|
585
621
|
Increases the balance of a signer's vault by the specified `quantity` of mARIO.
|
|
586
622
|
|
|
587
623
|
```typescript
|
|
588
|
-
const ario = ARIO.init({
|
|
624
|
+
const ario = ARIO.init({
|
|
625
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
626
|
+
signer: new ArweaveSigner(jwk),
|
|
627
|
+
});
|
|
589
628
|
|
|
590
629
|
const { id: txId } = await ario.increaseVault({
|
|
591
630
|
vaultId: 'vaultIdOne',
|
|
@@ -761,7 +800,10 @@ Joins a gateway to the ar.io network via its associated wallet.
|
|
|
761
800
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
762
801
|
|
|
763
802
|
```typescript
|
|
764
|
-
const ario = ARIO.init({
|
|
803
|
+
const ario = ARIO.init({
|
|
804
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
805
|
+
signer: new ArweaveSigner(jwk),
|
|
806
|
+
});
|
|
765
807
|
const { id: txId } = await ario.joinNetwork(
|
|
766
808
|
{
|
|
767
809
|
qty: new ARIOToken(10_000).toMARIO(), // minimum operator stake allowed
|
|
@@ -789,7 +831,10 @@ Sets the gateway as `leaving` on the ar.io network. Requires `signer` to be prov
|
|
|
789
831
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
790
832
|
|
|
791
833
|
```typescript
|
|
792
|
-
const ario = ARIO.init({
|
|
834
|
+
const ario = ARIO.init({
|
|
835
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
836
|
+
signer: new ArweaveSigner(jwk),
|
|
837
|
+
});
|
|
793
838
|
|
|
794
839
|
const { id: txId } = await ario.leaveNetwork(
|
|
795
840
|
// optional additional tags
|
|
@@ -804,7 +849,10 @@ Writes new gateway settings to the callers gateway configuration.
|
|
|
804
849
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
805
850
|
|
|
806
851
|
```typescript
|
|
807
|
-
const ario = ARIO.init({
|
|
852
|
+
const ario = ARIO.init({
|
|
853
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
854
|
+
signer: new ArweaveSigner(jwk),
|
|
855
|
+
});
|
|
808
856
|
const { id: txId } = await ario.updateGatewaySettings(
|
|
809
857
|
{
|
|
810
858
|
// any other settings you want to update
|
|
@@ -822,7 +870,10 @@ Increases the callers stake on the target gateway.
|
|
|
822
870
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
823
871
|
|
|
824
872
|
```typescript
|
|
825
|
-
const ario = ARIO.init({
|
|
873
|
+
const ario = ARIO.init({
|
|
874
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
875
|
+
signer: new ArweaveSigner(jwk),
|
|
876
|
+
});
|
|
826
877
|
const { id: txId } = await ario.increaseDelegateStake(
|
|
827
878
|
{
|
|
828
879
|
target: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
|
|
@@ -840,7 +891,10 @@ Decreases the callers stake on the target gateway. Can instantly decrease stake
|
|
|
840
891
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
841
892
|
|
|
842
893
|
```typescript
|
|
843
|
-
const ario = ARIO.init({
|
|
894
|
+
const ario = ARIO.init({
|
|
895
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
896
|
+
signer: new ArweaveSigner(jwk),
|
|
897
|
+
});
|
|
844
898
|
const { id: txId } = await ario.decreaseDelegateStake(
|
|
845
899
|
{
|
|
846
900
|
target: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
|
|
@@ -855,7 +909,10 @@ const { id: txId } = await ario.decreaseDelegateStake(
|
|
|
855
909
|
Pay the early withdrawal fee and withdraw instantly.
|
|
856
910
|
|
|
857
911
|
```typescript
|
|
858
|
-
const ario = ARIO.init({
|
|
912
|
+
const ario = ARIO.init({
|
|
913
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
914
|
+
signer: new ArweaveSigner(jwk),
|
|
915
|
+
});
|
|
859
916
|
const { id: txId } = await ario.decreaseDelegateStake({
|
|
860
917
|
target: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
|
|
861
918
|
qty: new ARIOToken(100).toMARIO(),
|
|
@@ -1081,7 +1138,10 @@ Increases the callers operator stake. Must be executed with a wallet registered
|
|
|
1081
1138
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1082
1139
|
|
|
1083
1140
|
```typescript
|
|
1084
|
-
const ario = ARIO.init({
|
|
1141
|
+
const ario = ARIO.init({
|
|
1142
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
1143
|
+
signer: new ArweaveSigner(jwk),
|
|
1144
|
+
});
|
|
1085
1145
|
const { id: txId } = await ario.increaseOperatorStake(
|
|
1086
1146
|
{
|
|
1087
1147
|
qty: new ARIOToken(100).toMARIO(),
|
|
@@ -1099,7 +1159,10 @@ Decreases the callers operator stake. Must be executed with a wallet registered
|
|
|
1099
1159
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1100
1160
|
|
|
1101
1161
|
```typescript
|
|
1102
|
-
const ario = ARIO.init({
|
|
1162
|
+
const ario = ARIO.init({
|
|
1163
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
1164
|
+
signer: new ArweaveSigner(jwk),
|
|
1165
|
+
});
|
|
1103
1166
|
const { id: txId } = await ario.decreaseOperatorStake(
|
|
1104
1167
|
{
|
|
1105
1168
|
qty: new ARIOToken(100).toMARIO(),
|
|
@@ -1117,7 +1180,10 @@ Redelegates the stake of a specific address to a new gateway. Vault ID may be op
|
|
|
1117
1180
|
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.
|
|
1118
1181
|
|
|
1119
1182
|
```typescript
|
|
1120
|
-
const ario = ARIO.init({
|
|
1183
|
+
const ario = ARIO.init({
|
|
1184
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
1185
|
+
signer: new ArweaveSigner(jwk),
|
|
1186
|
+
});
|
|
1121
1187
|
|
|
1122
1188
|
const { id: txId } = await ario.redelegateStake({
|
|
1123
1189
|
target: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
|
|
@@ -1327,7 +1393,10 @@ Increases the undername support of a domain up to a maximum of 10k. Domains, by
|
|
|
1327
1393
|
_Note: Requires `signer` to be provided on `ARIO.init` to sign the transaction._
|
|
1328
1394
|
|
|
1329
1395
|
```typescript
|
|
1330
|
-
const ario = ARIO.init({
|
|
1396
|
+
const ario = ARIO.init({
|
|
1397
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
1398
|
+
signer: new ArweaveSigner(jwk),
|
|
1399
|
+
});
|
|
1331
1400
|
const { id: txId } = await ario.increaseUndernameLimit(
|
|
1332
1401
|
{
|
|
1333
1402
|
name: 'ar-io',
|
|
@@ -1343,7 +1412,10 @@ const { id: txId } = await ario.increaseUndernameLimit(
|
|
|
1343
1412
|
Extends the lease of a registered ArNS domain, with an extension of 1-5 years depending on grace period status. Permanently registered domains cannot be extended.
|
|
1344
1413
|
|
|
1345
1414
|
```typescript
|
|
1346
|
-
const ario = ARIO.init({
|
|
1415
|
+
const ario = ARIO.init({
|
|
1416
|
+
processId: ARIO_MAINNET_PROCESS_ID,
|
|
1417
|
+
signer: new ArweaveSigner(jwk),
|
|
1418
|
+
});
|
|
1347
1419
|
const { id: txId } = await ario.extendLease(
|
|
1348
1420
|
{
|
|
1349
1421
|
name: 'ar-io',
|
|
@@ -1888,6 +1960,9 @@ const request = await ario.getPrimaryNameRequest({
|
|
|
1888
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.
|
|
1889
1961
|
|
|
1890
1962
|
```typescript
|
|
1963
|
+
import { ARIO } from '@ar.io/sdk';
|
|
1964
|
+
import { connect } from '@permaweb/aoconnect';
|
|
1965
|
+
|
|
1891
1966
|
// provide a custom ao infrastructure and process id
|
|
1892
1967
|
const ario = ARIO.init({
|
|
1893
1968
|
process: new AoProcess({
|
|
@@ -2327,7 +2402,7 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2327
2402
|
```typescript
|
|
2328
2403
|
const { id: txId } = await ant.releaseName({
|
|
2329
2404
|
name: 'permalink',
|
|
2330
|
-
arioProcessId:
|
|
2405
|
+
arioProcessId: ARIO_MAINNET_PROCESS_ID, // releases the name owned by the ANT and sends it to recently returned names on the ARIO contract
|
|
2331
2406
|
});
|
|
2332
2407
|
```
|
|
2333
2408
|
|
|
@@ -2340,7 +2415,7 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2340
2415
|
```typescript
|
|
2341
2416
|
const { id: txId } = await ant.reassignName({
|
|
2342
2417
|
name: 'ardrive',
|
|
2343
|
-
arioProcessId:
|
|
2418
|
+
arioProcessId: ARIO_MAINNET_PROCESS_ID,
|
|
2344
2419
|
antProcessId: NEW_ANT_PROCESS_ID, // the new ANT process id that will take over ownership of the name
|
|
2345
2420
|
});
|
|
2346
2421
|
```
|
|
@@ -2355,7 +2430,7 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2355
2430
|
const { id: txId } = await ant.approvePrimaryNameRequest({
|
|
2356
2431
|
name: 'arns',
|
|
2357
2432
|
address: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3', // must match the request initiator address
|
|
2358
|
-
arioProcessId:
|
|
2433
|
+
arioProcessId: ARIO_MAINNET_PROCESS_ID, // the ARIO process id to use for the request
|
|
2359
2434
|
});
|
|
2360
2435
|
```
|
|
2361
2436
|
|
|
@@ -2368,7 +2443,7 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2368
2443
|
```typescript
|
|
2369
2444
|
const { id: txId } = await ant.removePrimaryNames({
|
|
2370
2445
|
names: ['arns', 'test_arns'], // any primary names associated with a base name controlled by this ANT will be removed
|
|
2371
|
-
arioProcessId:
|
|
2446
|
+
arioProcessId: ARIO_MAINNET_PROCESS_ID,
|
|
2372
2447
|
notifyOwners: true, // if true, the owners of the removed names will be send AO messages to notify them of the removal
|
|
2373
2448
|
});
|
|
2374
2449
|
```
|