@ar.io/sdk 2.0.3-alpha.1 → 2.1.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 +103 -22
- package/bundles/web.bundle.min.js +104 -104
- package/lib/cjs/common/ant-registry.js +87 -0
- package/lib/cjs/common/ant.js +3 -9
- package/lib/cjs/common/contracts/ao-process.js +2 -19
- package/lib/cjs/common/index.js +1 -0
- package/lib/cjs/common/io.js +14 -12
- package/lib/cjs/constants.js +3 -2
- package/lib/cjs/io.js +2 -1
- package/lib/cjs/types.js +0 -1
- package/lib/cjs/utils/ao.js +53 -3
- package/lib/cjs/utils/json.js +3 -2
- package/lib/cjs/utils/processes.js +24 -43
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant-registry.js +81 -0
- package/lib/esm/common/ant.js +3 -9
- package/lib/esm/common/contracts/ao-process.js +2 -19
- package/lib/esm/common/index.js +1 -0
- package/lib/esm/common/io.js +14 -12
- package/lib/esm/constants.js +2 -1
- package/lib/esm/io.js +2 -1
- package/lib/esm/types.js +0 -1
- package/lib/esm/utils/ao.js +52 -4
- package/lib/esm/utils/json.js +1 -0
- package/lib/esm/utils/processes.js +24 -43
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant-registry.d.ts +26 -0
- package/lib/types/common/ant.d.ts +5 -4
- package/lib/types/common/contracts/ao-process.d.ts +4 -17
- package/lib/types/common/index.d.ts +1 -0
- package/lib/types/common/io.d.ts +9 -12
- package/lib/types/common.d.ts +2 -25
- package/lib/types/constants.d.ts +2 -1
- package/lib/types/io.d.ts +181 -116
- package/lib/types/token.d.ts +13 -0
- package/lib/types/types.d.ts +0 -1
- package/lib/types/utils/ao.d.ts +19 -5
- package/lib/types/utils/processes.d.ts +11 -5
- package/lib/types/version.d.ts +1 -1
- package/package.json +7 -2
- package/lib/cjs/contract-state.js +0 -68
- package/lib/esm/contract-state.js +0 -65
- package/lib/types/contract-state.d.ts +0 -201
package/README.md
CHANGED
|
@@ -6,20 +6,27 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
6
6
|
|
|
7
7
|
## Table of Contents
|
|
8
8
|
|
|
9
|
+
<!-- toc -->
|
|
10
|
+
|
|
11
|
+
- [Table of Contents](#table-of-contents)
|
|
9
12
|
- [Prerequisites](#prerequisites)
|
|
10
13
|
- [Installation](#installation)
|
|
11
14
|
- [Quick Start](#quick-start)
|
|
12
15
|
- [Usage](#usage)
|
|
13
16
|
- [Web](#web)
|
|
17
|
+
- [Bundlers (Webpack, Rollup, ESbuild, etc.)](#bundlers-webpack-rollup-esbuild-etc)
|
|
18
|
+
- [Browser](#browser)
|
|
14
19
|
- [Node](#node)
|
|
20
|
+
- [ESM (NodeNext)](#esm-nodenext)
|
|
21
|
+
- [CJS](#cjs)
|
|
15
22
|
- [Typescript](#typescript)
|
|
16
23
|
- [IOToken & mIOToken](#iotoken--miotoken)
|
|
17
24
|
- [Converting IO to mIO](#converting-io-to-mio)
|
|
18
25
|
- [IO Process](#io-process)
|
|
19
|
-
|
|
20
|
-
- [IO APIs](#apis)
|
|
26
|
+
- [APIs](#apis)
|
|
21
27
|
- [`init({ signer })`](#init-signer-)
|
|
22
28
|
- [`getInfo()`](#getinfo)
|
|
29
|
+
- [`getTokenSupply()`](#gettokensupply)
|
|
23
30
|
- [`getBalance({ address })`](#getbalance-address-)
|
|
24
31
|
- [`getBalances({ cursor, limit, sortBy, sortOrder })`](#getbalances-cursor-limit-sortby-sortorder-)
|
|
25
32
|
- [`getGateway({ address })`](#getgateway-address-)
|
|
@@ -31,6 +38,7 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
31
38
|
- [`getEpoch({ epochIndex })`](#getepoch-epochindex-)
|
|
32
39
|
- [`getCurrentEpoch()`](#getcurrentepoch)
|
|
33
40
|
- [`getPrescribedObservers({ epochIndex })`](#getprescribedobservers-epochindex-)
|
|
41
|
+
- [`getTokenCost({ intent, ...args })`](#gettokencost-intent-args-)
|
|
34
42
|
- [`joinNetwork(params)`](#joinnetworkparams)
|
|
35
43
|
- [`leaveNetwork()`](#leavenetwork)
|
|
36
44
|
- [`updateGatewaySettings(gatewaySettings)`](#updategatewaysettingsgatewaysettings)
|
|
@@ -42,13 +50,12 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
42
50
|
- [`transfer({ target, qty })`](#transfer-target-qty-)
|
|
43
51
|
- [`increaseUndernameLimit({ name, qty })`](#increaseundernamelimit-name-qty-)
|
|
44
52
|
- [`extendLease({ name, years })`](#extendlease-name-years-)
|
|
45
|
-
- [Configuration](#
|
|
46
|
-
|
|
53
|
+
- [Configuration](#configuration)
|
|
47
54
|
- [Arweave Name Tokens (ANT's)](#arweave-name-tokens-ants)
|
|
48
|
-
|
|
49
55
|
- [ANT APIs](#ant-apis)
|
|
50
56
|
- [`init({ processId, signer })`](#init-processid-signer-)
|
|
51
|
-
- [`getInfo()`](#getinfo)
|
|
57
|
+
- [`getInfo()`](#getinfo-1)
|
|
58
|
+
- [`getState()`](#getstate)
|
|
52
59
|
- [`getOwner()`](#getowner)
|
|
53
60
|
- [`getControllers()`](#getcontrollers)
|
|
54
61
|
- [`getRecords()`](#getrecords)
|
|
@@ -59,21 +66,19 @@ This is the home of [ar.io] SDK. This SDK provides functionality for interacting
|
|
|
59
66
|
- [`removeRecord({ undername })`](#removerecord-undername-)
|
|
60
67
|
- [`setName({ name })`](#setname-name-)
|
|
61
68
|
- [`setTicker({ ticker })`](#setticker-ticker-)
|
|
62
|
-
- [Configuration](#configuration)
|
|
63
|
-
|
|
69
|
+
- [Configuration](#configuration-1)
|
|
64
70
|
- [Logging](#logging)
|
|
65
|
-
|
|
66
|
-
- [Configuration](#configuration)
|
|
67
|
-
|
|
71
|
+
- [Configuration](#configuration-2)
|
|
68
72
|
- [Pagination](#pagination)
|
|
69
|
-
|
|
70
73
|
- [Developers](#developers)
|
|
71
74
|
- [Requirements](#requirements)
|
|
72
|
-
- [Setup
|
|
75
|
+
- [Setup & Build](#setup--build)
|
|
73
76
|
- [Testing](#testing)
|
|
74
|
-
- [Linting
|
|
77
|
+
- [Linting & Formatting](#linting--formatting)
|
|
75
78
|
- [Architecture](#architecture)
|
|
76
79
|
|
|
80
|
+
<!-- tocstop -->
|
|
81
|
+
|
|
77
82
|
## Prerequisites
|
|
78
83
|
|
|
79
84
|
- `node>=v18.0.0`
|
|
@@ -123,11 +128,19 @@ const gateways = await io.getGateways();
|
|
|
123
128
|
"failedConsecutiveEpochs": 0,
|
|
124
129
|
"passedEpochCount": 30,
|
|
125
130
|
"submittedEpochCount": 30,
|
|
126
|
-
"
|
|
131
|
+
"totalEpochCount": 31,
|
|
127
132
|
"totalEpochsPrescribedCount": 31
|
|
128
133
|
},
|
|
129
134
|
"status": "joined",
|
|
130
|
-
"vaults": {}
|
|
135
|
+
"vaults": {},
|
|
136
|
+
"weights": {
|
|
137
|
+
"compositeWeight": 0.97688888893556,
|
|
138
|
+
"gatewayRewardRatioWeight": 1,
|
|
139
|
+
"tenureWeight": 0.19444444444444,
|
|
140
|
+
"observerRewardRatioWeight": 1,
|
|
141
|
+
"normalizedCompositeWeight": 0.19247316211083,
|
|
142
|
+
"stakeWeight": 5.02400000024
|
|
143
|
+
}
|
|
131
144
|
}
|
|
132
145
|
],
|
|
133
146
|
"hasMore": true,
|
|
@@ -265,6 +278,15 @@ const info = await io.getInfo();
|
|
|
265
278
|
|
|
266
279
|
</details>
|
|
267
280
|
|
|
281
|
+
#### `getTokenSupply()`
|
|
282
|
+
|
|
283
|
+
Retrieves the total supply of tokens, returned in mIO.
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
const io = IO.init();
|
|
287
|
+
const supply = await io.getTokenSupply().then((s) => new mIOToken(s).toIO()); // convert it to IO for readability
|
|
288
|
+
```
|
|
289
|
+
|
|
268
290
|
#### `getBalance({ address })`
|
|
269
291
|
|
|
270
292
|
Retrieves the balance of the specified wallet address.
|
|
@@ -276,7 +298,7 @@ const balance = await io
|
|
|
276
298
|
.getBalance({
|
|
277
299
|
address: 'QGWqtJdLLgm2ehFWiiPzMaoFLD50CnGuzZIPEdoDRGQ',
|
|
278
300
|
})
|
|
279
|
-
.then((balance) => new mIOToken().toIO()); // convert it to IO for readability
|
|
301
|
+
.then((balance: number) => new mIOToken(balance).toIO()); // convert it to IO for readability
|
|
280
302
|
```
|
|
281
303
|
|
|
282
304
|
<details>
|
|
@@ -354,11 +376,19 @@ const gateway = await io.getGateway({
|
|
|
354
376
|
"failedConsecutiveEpochs": 0,
|
|
355
377
|
"passedEpochCount": 30,
|
|
356
378
|
"submittedEpochCount": 30,
|
|
357
|
-
"
|
|
379
|
+
"totalEpochCount": 31,
|
|
358
380
|
"totalEpochsPrescribedCount": 31
|
|
359
381
|
},
|
|
360
382
|
"status": "joined",
|
|
361
|
-
"vaults": {}
|
|
383
|
+
"vaults": {},
|
|
384
|
+
"weights": {
|
|
385
|
+
"compositeWeight": 0.97688888893556,
|
|
386
|
+
"gatewayRewardRatioWeight": 1,
|
|
387
|
+
"tenureWeight": 0.19444444444444,
|
|
388
|
+
"observerRewardRatioWeight": 1,
|
|
389
|
+
"normalizedCompositeWeight": 0.19247316211083,
|
|
390
|
+
"stakeWeight": 5.02400000024
|
|
391
|
+
}
|
|
362
392
|
}
|
|
363
393
|
```
|
|
364
394
|
|
|
@@ -402,11 +432,19 @@ Available `sortBy` options are any of the keys on the gateway object, e.g. `oper
|
|
|
402
432
|
"failedConsecutiveEpochs": 0,
|
|
403
433
|
"passedEpochCount": 30,
|
|
404
434
|
"submittedEpochCount": 30,
|
|
405
|
-
"
|
|
435
|
+
"totalEpochCount": 31,
|
|
406
436
|
"totalEpochsPrescribedCount": 31
|
|
407
437
|
},
|
|
408
438
|
"status": "joined",
|
|
409
|
-
"vaults": {}
|
|
439
|
+
"vaults": {},
|
|
440
|
+
"weights": {
|
|
441
|
+
"compositeWeight": 0.97688888893556,
|
|
442
|
+
"gatewayRewardRatioWeight": 1,
|
|
443
|
+
"tenureWeight": 0.19444444444444,
|
|
444
|
+
"observerRewardRatioWeight": 1,
|
|
445
|
+
"normalizedCompositeWeight": 0.19247316211083,
|
|
446
|
+
"stakeWeight": 5.02400000024
|
|
447
|
+
}
|
|
410
448
|
}
|
|
411
449
|
],
|
|
412
450
|
"hasMore": true,
|
|
@@ -971,7 +1009,7 @@ The ANT client class exposes APIs relevant to compliant Arweave Name Token proce
|
|
|
971
1009
|
|
|
972
1010
|
### ANT APIs
|
|
973
1011
|
|
|
974
|
-
#### `init({ processId, signer )`
|
|
1012
|
+
#### `init({ processId, signer })`
|
|
975
1013
|
|
|
976
1014
|
Factory function to that creates a read-only or writeable client. By providing a `signer` additional write APIs that require signing, like `setRecord` and `transfer` are available. By default, a read-only client is returned and no write APIs are available.
|
|
977
1015
|
|
|
@@ -1011,6 +1049,49 @@ const info = await ant.getInfo();
|
|
|
1011
1049
|
|
|
1012
1050
|
</details>
|
|
1013
1051
|
|
|
1052
|
+
#### `getState()`
|
|
1053
|
+
|
|
1054
|
+
Retrieves the state of the ANT process.
|
|
1055
|
+
|
|
1056
|
+
```typescript
|
|
1057
|
+
const state = await ant.getState();
|
|
1058
|
+
```
|
|
1059
|
+
|
|
1060
|
+
<details>
|
|
1061
|
+
<summary>Output</summary>
|
|
1062
|
+
|
|
1063
|
+
```json
|
|
1064
|
+
{
|
|
1065
|
+
"TotalSupply": 1,
|
|
1066
|
+
"Balances": {
|
|
1067
|
+
"98O1_xqDLrBKRfQPWjF5p7xZ4Jx6GM8P5PeJn26xwUY": 1
|
|
1068
|
+
},
|
|
1069
|
+
"Controllers": [],
|
|
1070
|
+
"Records": {
|
|
1071
|
+
"v1-0-0_whitepaper": {
|
|
1072
|
+
"transactionId": "lNjWn3LpyhKC95Kqe-x8X2qgju0j98MhucdDKK85vc4",
|
|
1073
|
+
"ttlSeconds": 900
|
|
1074
|
+
},
|
|
1075
|
+
"@": {
|
|
1076
|
+
"transactionId": "2rMLb2uHAyEt7jSu6bXtKx8e-jOfIf7E-DOgQnm8EtU",
|
|
1077
|
+
"ttlSeconds": 3600
|
|
1078
|
+
},
|
|
1079
|
+
"whitepaper": {
|
|
1080
|
+
"transactionId": "lNjWn3LpyhKC95Kqe-x8X2qgju0j98MhucdDKK85vc4",
|
|
1081
|
+
"ttlSeconds": 900
|
|
1082
|
+
}
|
|
1083
|
+
},
|
|
1084
|
+
"Initialized": true,
|
|
1085
|
+
"Ticker": "ANT-AR-IO",
|
|
1086
|
+
"Logo": "Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A",
|
|
1087
|
+
"Denomination": 0,
|
|
1088
|
+
"Name": "AR.IO Foundation",
|
|
1089
|
+
"Owner": "98O1_xqDLrBKRfQPWjF5p7xZ4Jx6GM8P5PeJn26xwUY"
|
|
1090
|
+
}
|
|
1091
|
+
```
|
|
1092
|
+
|
|
1093
|
+
</details>
|
|
1094
|
+
|
|
1014
1095
|
#### `getOwner()`
|
|
1015
1096
|
|
|
1016
1097
|
Returns the owner of the configured ANT process.
|