@ar.io/sdk 1.2.0-alpha.11 → 1.2.0-alpha.13
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/bundles/web.bundle.min.js +2 -2
- package/lib/cjs/common/ant-ao.js +11 -4
- package/lib/cjs/common/contracts/ao-process.js +5 -5
- package/lib/cjs/common/io.js +43 -43
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant-ao.js +11 -4
- package/lib/esm/common/contracts/ao-process.js +5 -5
- package/lib/esm/common/io.js +43 -43
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant-ao.d.ts +2 -1
- package/lib/types/common/io.d.ts +3 -3
- package/lib/types/io.d.ts +13 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -60,18 +60,18 @@ class AOProcess {
|
|
|
60
60
|
process: this.processId,
|
|
61
61
|
tags,
|
|
62
62
|
});
|
|
63
|
+
if (result.Messages.length === 0) {
|
|
64
|
+
throw new Error(`Process ${this.processId} does not support provided action.`);
|
|
65
|
+
}
|
|
63
66
|
const tagsOutput = result.Messages[0].Tags;
|
|
64
67
|
const error = tagsOutput.find((tag) => tag.name === 'Error');
|
|
65
68
|
if (error) {
|
|
66
69
|
throw new Error(`${error.Value}: ${result.Messages[0].Data}`);
|
|
67
70
|
}
|
|
68
|
-
if (result.Messages.length === 0) {
|
|
69
|
-
throw new Error('Process does not support provided action.');
|
|
70
|
-
}
|
|
71
71
|
this.logger.debug(`Read interaction result`, {
|
|
72
|
-
result: result.Messages[0]
|
|
72
|
+
result: result.Messages[0]?.Data,
|
|
73
73
|
});
|
|
74
|
-
const response = JSON.parse(result.Messages[0]
|
|
74
|
+
const response = JSON.parse(result.Messages[0]?.Data);
|
|
75
75
|
return response;
|
|
76
76
|
}
|
|
77
77
|
catch (e) {
|
package/lib/cjs/common/io.js
CHANGED
|
@@ -73,11 +73,11 @@ class IOReadable {
|
|
|
73
73
|
value: epoch.timestamp?.toString() ?? '',
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
|
-
name: '
|
|
76
|
+
name: 'Block-Height',
|
|
77
77
|
value: epoch?.blockHeight?.toString(),
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
|
-
name: '
|
|
80
|
+
name: 'Epoch-Index',
|
|
81
81
|
value: epoch?.epochIndex?.toString(),
|
|
82
82
|
},
|
|
83
83
|
];
|
|
@@ -108,13 +108,13 @@ class IOReadable {
|
|
|
108
108
|
}
|
|
109
109
|
async getArNSReservedNames() {
|
|
110
110
|
return this.process.read({
|
|
111
|
-
tags: [{ name: 'Action', value: '
|
|
111
|
+
tags: [{ name: 'Action', value: 'Reserved-Names' }],
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
async getArNSReservedName({ name, }) {
|
|
115
115
|
return this.process.read({
|
|
116
116
|
tags: [
|
|
117
|
-
{ name: 'Action', value: '
|
|
117
|
+
{ name: 'Action', value: 'Reserved-Name' },
|
|
118
118
|
{ name: 'Name', value: name },
|
|
119
119
|
],
|
|
120
120
|
});
|
|
@@ -155,17 +155,17 @@ class IOReadable {
|
|
|
155
155
|
}
|
|
156
156
|
async getPrescribedObservers(epoch) {
|
|
157
157
|
const allTags = [
|
|
158
|
-
{ name: 'Action', value: '
|
|
158
|
+
{ name: 'Action', value: 'Epoch-Prescribed-Observers' },
|
|
159
159
|
{
|
|
160
160
|
name: 'Timestamp',
|
|
161
161
|
value: epoch.timestamp?.toString(),
|
|
162
162
|
},
|
|
163
163
|
{
|
|
164
|
-
name: '
|
|
164
|
+
name: 'Block-Height',
|
|
165
165
|
value: epoch?.blockHeight?.toString(),
|
|
166
166
|
},
|
|
167
167
|
{
|
|
168
|
-
name: '
|
|
168
|
+
name: 'Epoch-Index',
|
|
169
169
|
value: epoch?.epochIndex?.toString(),
|
|
170
170
|
},
|
|
171
171
|
];
|
|
@@ -183,17 +183,17 @@ class IOReadable {
|
|
|
183
183
|
}
|
|
184
184
|
async getPrescribedNames(epoch) {
|
|
185
185
|
const allTags = [
|
|
186
|
-
{ name: 'Action', value: '
|
|
186
|
+
{ name: 'Action', value: 'Epoch-Prescribed-Names' },
|
|
187
187
|
{
|
|
188
188
|
name: 'Timestamp',
|
|
189
189
|
value: epoch.timestamp?.toString(),
|
|
190
190
|
},
|
|
191
191
|
{
|
|
192
|
-
name: '
|
|
192
|
+
name: 'Block-Height',
|
|
193
193
|
value: epoch?.blockHeight?.toString(),
|
|
194
194
|
},
|
|
195
195
|
{
|
|
196
|
-
name: '
|
|
196
|
+
name: 'Epoch-Index',
|
|
197
197
|
value: epoch?.epochIndex?.toString(),
|
|
198
198
|
},
|
|
199
199
|
];
|
|
@@ -211,17 +211,17 @@ class IOReadable {
|
|
|
211
211
|
}
|
|
212
212
|
async getObservations(epoch) {
|
|
213
213
|
const allTags = [
|
|
214
|
-
{ name: 'Action', value: '
|
|
214
|
+
{ name: 'Action', value: 'Epoch-Observations' },
|
|
215
215
|
{
|
|
216
216
|
name: 'Timestamp',
|
|
217
217
|
value: epoch.timestamp?.toString(),
|
|
218
218
|
},
|
|
219
219
|
{
|
|
220
|
-
name: '
|
|
220
|
+
name: 'Block-Height',
|
|
221
221
|
value: epoch?.blockHeight?.toString(),
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
|
-
name: '
|
|
224
|
+
name: 'Epoch-Index',
|
|
225
225
|
value: epoch?.epochIndex?.toString(),
|
|
226
226
|
},
|
|
227
227
|
];
|
|
@@ -239,17 +239,17 @@ class IOReadable {
|
|
|
239
239
|
}
|
|
240
240
|
async getDistributions(epoch) {
|
|
241
241
|
const allTags = [
|
|
242
|
-
{ name: 'Action', value: '
|
|
242
|
+
{ name: 'Action', value: 'Epoch-Distributions' },
|
|
243
243
|
{
|
|
244
244
|
name: 'Timestamp',
|
|
245
245
|
value: epoch.timestamp?.toString() ?? '',
|
|
246
246
|
},
|
|
247
247
|
{
|
|
248
|
-
name: '
|
|
248
|
+
name: 'Block-Height',
|
|
249
249
|
value: epoch?.blockHeight?.toString(),
|
|
250
250
|
},
|
|
251
251
|
{
|
|
252
|
-
name: '
|
|
252
|
+
name: 'Epoch-Index',
|
|
253
253
|
value: epoch?.epochIndex?.toString(),
|
|
254
254
|
},
|
|
255
255
|
];
|
|
@@ -267,7 +267,7 @@ class IOReadable {
|
|
|
267
267
|
}
|
|
268
268
|
async getTokenCost({ intent, purchaseType, years, name, quantity, }) {
|
|
269
269
|
const allTags = [
|
|
270
|
-
{ name: 'Action', value: '
|
|
270
|
+
{ name: 'Action', value: 'Token-Cost' },
|
|
271
271
|
{
|
|
272
272
|
name: 'Intent',
|
|
273
273
|
value: intent,
|
|
@@ -285,7 +285,7 @@ class IOReadable {
|
|
|
285
285
|
value: quantity?.toString(),
|
|
286
286
|
},
|
|
287
287
|
{
|
|
288
|
-
name: '
|
|
288
|
+
name: 'Purchase-Type',
|
|
289
289
|
value: purchaseType,
|
|
290
290
|
},
|
|
291
291
|
];
|
|
@@ -345,17 +345,17 @@ class IOWriteable extends IOReadable {
|
|
|
345
345
|
const { tags = [] } = options || {};
|
|
346
346
|
const allTags = [
|
|
347
347
|
...tags,
|
|
348
|
-
{ name: 'Action', value: '
|
|
348
|
+
{ name: 'Action', value: 'Join-Network' },
|
|
349
349
|
{
|
|
350
|
-
name: '
|
|
350
|
+
name: 'Operator-Stake',
|
|
351
351
|
value: operatorStake.valueOf().toString(),
|
|
352
352
|
},
|
|
353
353
|
{
|
|
354
|
-
name: '
|
|
354
|
+
name: 'Allow-Delegated-Staking',
|
|
355
355
|
value: allowDelegatedStaking.toString(),
|
|
356
356
|
},
|
|
357
357
|
{
|
|
358
|
-
name: '
|
|
358
|
+
name: 'Delegate-Reward-Share-Ratio',
|
|
359
359
|
value: delegateRewardShareRatio.toString(),
|
|
360
360
|
},
|
|
361
361
|
{
|
|
@@ -367,7 +367,7 @@ class IOWriteable extends IOReadable {
|
|
|
367
367
|
value: label,
|
|
368
368
|
},
|
|
369
369
|
{
|
|
370
|
-
name: '
|
|
370
|
+
name: 'Min-Delegated-Stake',
|
|
371
371
|
value: minDelegatedStake.valueOf().toString(),
|
|
372
372
|
},
|
|
373
373
|
{
|
|
@@ -387,11 +387,11 @@ class IOWriteable extends IOReadable {
|
|
|
387
387
|
value: protocol,
|
|
388
388
|
},
|
|
389
389
|
{
|
|
390
|
-
name: '
|
|
390
|
+
name: 'Auto-Stake',
|
|
391
391
|
value: autoStake.toString(),
|
|
392
392
|
},
|
|
393
393
|
{
|
|
394
|
-
name: '
|
|
394
|
+
name: 'Observer-Address',
|
|
395
395
|
value: observerAddress,
|
|
396
396
|
},
|
|
397
397
|
];
|
|
@@ -405,27 +405,27 @@ class IOWriteable extends IOReadable {
|
|
|
405
405
|
const { tags = [] } = options || {};
|
|
406
406
|
const allTags = [
|
|
407
407
|
...tags,
|
|
408
|
-
{ name: 'Action', value: '
|
|
408
|
+
{ name: 'Action', value: 'Update-Gateway-Settings' },
|
|
409
409
|
{ name: 'Label', value: label },
|
|
410
410
|
{ name: 'Note', value: note },
|
|
411
411
|
{ name: 'FQDN', value: fqdn },
|
|
412
412
|
{ name: 'Port', value: port?.toString() },
|
|
413
413
|
{ name: 'Properties', value: properties },
|
|
414
414
|
{ name: 'Protocol', value: protocol },
|
|
415
|
-
{ name: '
|
|
415
|
+
{ name: 'Observer-Address', value: observerAddress },
|
|
416
416
|
{
|
|
417
|
-
name: '
|
|
417
|
+
name: 'Allow-Delegated-Staking',
|
|
418
418
|
value: allowDelegatedStaking?.toString(),
|
|
419
419
|
},
|
|
420
420
|
{
|
|
421
|
-
name: '
|
|
421
|
+
name: 'Delegate-Reward-Share-Ratio',
|
|
422
422
|
value: delegateRewardShareRatio?.toString(),
|
|
423
423
|
},
|
|
424
424
|
{
|
|
425
|
-
name: '
|
|
425
|
+
name: 'Min-Delegated-Stake',
|
|
426
426
|
value: minDelegatedStake?.valueOf().toString(),
|
|
427
427
|
},
|
|
428
|
-
{ name: '
|
|
428
|
+
{ name: 'Auto-Stake', value: autoStake?.toString() },
|
|
429
429
|
];
|
|
430
430
|
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
431
431
|
return this.process.send({
|
|
@@ -439,7 +439,7 @@ class IOWriteable extends IOReadable {
|
|
|
439
439
|
signer: this.signer,
|
|
440
440
|
tags: [
|
|
441
441
|
...tags,
|
|
442
|
-
{ name: 'Action', value: '
|
|
442
|
+
{ name: 'Action', value: 'Delegate-Stake' },
|
|
443
443
|
{ name: 'Target', value: params.target },
|
|
444
444
|
{ name: 'Quantity', value: params.stakeQty.valueOf().toString() },
|
|
445
445
|
],
|
|
@@ -451,7 +451,7 @@ class IOWriteable extends IOReadable {
|
|
|
451
451
|
signer: this.signer,
|
|
452
452
|
tags: [
|
|
453
453
|
...tags,
|
|
454
|
-
{ name: 'Action', value: '
|
|
454
|
+
{ name: 'Action', value: 'Decrease-Delegate-Stake' },
|
|
455
455
|
{ name: 'Target', value: params.target },
|
|
456
456
|
{ name: 'Quantity', value: params.decreaseQty.valueOf().toString() },
|
|
457
457
|
],
|
|
@@ -463,7 +463,7 @@ class IOWriteable extends IOReadable {
|
|
|
463
463
|
signer: this.signer,
|
|
464
464
|
tags: [
|
|
465
465
|
...tags,
|
|
466
|
-
{ name: 'Action', value: '
|
|
466
|
+
{ name: 'Action', value: 'Increase-Operator-Stake' },
|
|
467
467
|
{ name: 'Quantity', value: params.increaseQty.valueOf().toString() },
|
|
468
468
|
],
|
|
469
469
|
});
|
|
@@ -474,7 +474,7 @@ class IOWriteable extends IOReadable {
|
|
|
474
474
|
signer: this.signer,
|
|
475
475
|
tags: [
|
|
476
476
|
...tags,
|
|
477
|
-
{ name: 'Action', value: '
|
|
477
|
+
{ name: 'Action', value: 'Decrease-Operator-Stake' },
|
|
478
478
|
{ name: 'Quantity', value: params.decreaseQty.valueOf().toString() },
|
|
479
479
|
],
|
|
480
480
|
});
|
|
@@ -485,13 +485,13 @@ class IOWriteable extends IOReadable {
|
|
|
485
485
|
signer: this.signer,
|
|
486
486
|
tags: [
|
|
487
487
|
...tags,
|
|
488
|
-
{ name: 'Action', value: '
|
|
488
|
+
{ name: 'Action', value: 'Save-Observations' },
|
|
489
489
|
{
|
|
490
|
-
name: '
|
|
490
|
+
name: 'Report-Tx-Id',
|
|
491
491
|
value: params.reportTxId,
|
|
492
492
|
},
|
|
493
493
|
{
|
|
494
|
-
name: '
|
|
494
|
+
name: 'Failed-Gateways',
|
|
495
495
|
value: params.failedGateways.join(','),
|
|
496
496
|
},
|
|
497
497
|
],
|
|
@@ -505,11 +505,11 @@ class IOWriteable extends IOReadable {
|
|
|
505
505
|
const { tags = [] } = options || {};
|
|
506
506
|
const allTags = [
|
|
507
507
|
...tags,
|
|
508
|
-
{ name: 'Action', value: '
|
|
508
|
+
{ name: 'Action', value: 'Buy-Record' },
|
|
509
509
|
{ name: 'Name', value: params.name },
|
|
510
510
|
{ name: 'Years', value: params.years?.toString() ?? '1' },
|
|
511
|
-
{ name: '
|
|
512
|
-
{ name: '
|
|
511
|
+
{ name: 'Process-Id', value: params.processId },
|
|
512
|
+
{ name: 'Purchase-Type', value: params.type || 'lease' },
|
|
513
513
|
];
|
|
514
514
|
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
515
515
|
return this.process.send({
|
|
@@ -523,7 +523,7 @@ class IOWriteable extends IOReadable {
|
|
|
523
523
|
signer: this.signer,
|
|
524
524
|
tags: [
|
|
525
525
|
...tags,
|
|
526
|
-
{ name: 'Action', value: '
|
|
526
|
+
{ name: 'Action', value: 'Extend-Lease' },
|
|
527
527
|
{ name: 'Name', value: params.name },
|
|
528
528
|
{ name: 'Years', value: params.years.toString() },
|
|
529
529
|
],
|
|
@@ -535,7 +535,7 @@ class IOWriteable extends IOReadable {
|
|
|
535
535
|
signer: this.signer,
|
|
536
536
|
tags: [
|
|
537
537
|
...tags,
|
|
538
|
-
{ name: 'Action', value: '
|
|
538
|
+
{ name: 'Action', value: 'Increase-Undername-Limit' },
|
|
539
539
|
{ name: 'Name', value: params.name },
|
|
540
540
|
{ name: 'Quantity', value: params.increaseCount.toString() },
|
|
541
541
|
],
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/common/ant-ao.js
CHANGED
|
@@ -16,6 +16,13 @@ export class AoANTReadable {
|
|
|
16
16
|
throw new InvalidContractConfigurationError();
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
async getState() {
|
|
20
|
+
const tags = [{ name: 'Action', value: 'State' }];
|
|
21
|
+
const res = await this.process.read({
|
|
22
|
+
tags,
|
|
23
|
+
});
|
|
24
|
+
return res;
|
|
25
|
+
}
|
|
19
26
|
async getInfo() {
|
|
20
27
|
const tags = [{ name: 'Action', value: 'Info' }];
|
|
21
28
|
const info = await this.process.read({
|
|
@@ -35,7 +42,7 @@ export class AoANTReadable {
|
|
|
35
42
|
async getRecord({ undername }) {
|
|
36
43
|
const tags = [
|
|
37
44
|
{ name: 'Sub-Domain', value: undername },
|
|
38
|
-
{ name: 'Action', value: '
|
|
45
|
+
{ name: 'Action', value: 'Record' },
|
|
39
46
|
];
|
|
40
47
|
const record = await this.process.read({
|
|
41
48
|
tags,
|
|
@@ -51,7 +58,7 @@ export class AoANTReadable {
|
|
|
51
58
|
* ````
|
|
52
59
|
*/
|
|
53
60
|
async getRecords() {
|
|
54
|
-
const tags = [{ name: 'Action', value: '
|
|
61
|
+
const tags = [{ name: 'Action', value: 'Records' }];
|
|
55
62
|
const records = await this.process.read({
|
|
56
63
|
tags,
|
|
57
64
|
});
|
|
@@ -78,7 +85,7 @@ export class AoANTReadable {
|
|
|
78
85
|
* ```
|
|
79
86
|
*/
|
|
80
87
|
async getControllers() {
|
|
81
|
-
const tags = [{ name: 'Action', value: '
|
|
88
|
+
const tags = [{ name: 'Action', value: 'Controllers' }];
|
|
82
89
|
const controllers = await this.process.read({
|
|
83
90
|
tags,
|
|
84
91
|
});
|
|
@@ -178,7 +185,7 @@ export class AoANTWriteable extends AoANTReadable {
|
|
|
178
185
|
*/
|
|
179
186
|
async addController({ controller, }) {
|
|
180
187
|
const tags = [
|
|
181
|
-
{ name: 'Action', value: '
|
|
188
|
+
{ name: 'Action', value: 'Add-Controller' },
|
|
182
189
|
{ name: 'Controller', value: controller },
|
|
183
190
|
];
|
|
184
191
|
return this.process.send({
|
|
@@ -57,18 +57,18 @@ export class AOProcess {
|
|
|
57
57
|
process: this.processId,
|
|
58
58
|
tags,
|
|
59
59
|
});
|
|
60
|
+
if (result.Messages.length === 0) {
|
|
61
|
+
throw new Error(`Process ${this.processId} does not support provided action.`);
|
|
62
|
+
}
|
|
60
63
|
const tagsOutput = result.Messages[0].Tags;
|
|
61
64
|
const error = tagsOutput.find((tag) => tag.name === 'Error');
|
|
62
65
|
if (error) {
|
|
63
66
|
throw new Error(`${error.Value}: ${result.Messages[0].Data}`);
|
|
64
67
|
}
|
|
65
|
-
if (result.Messages.length === 0) {
|
|
66
|
-
throw new Error('Process does not support provided action.');
|
|
67
|
-
}
|
|
68
68
|
this.logger.debug(`Read interaction result`, {
|
|
69
|
-
result: result.Messages[0]
|
|
69
|
+
result: result.Messages[0]?.Data,
|
|
70
70
|
});
|
|
71
|
-
const response = JSON.parse(result.Messages[0]
|
|
71
|
+
const response = JSON.parse(result.Messages[0]?.Data);
|
|
72
72
|
return response;
|
|
73
73
|
}
|
|
74
74
|
catch (e) {
|