@ar.io/sdk 2.4.0-alpha.9 → 2.5.0-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 +139 -0
- package/bundles/web.bundle.min.js +85 -90
- package/lib/cjs/common/contracts/ao-process.js +7 -5
- package/lib/cjs/common/http.js +2 -2
- package/lib/cjs/common/io.js +105 -88
- package/lib/cjs/types/index.js +3 -1
- package/lib/cjs/utils/arweave.js +16 -16
- package/lib/cjs/utils/index.js +2 -2
- package/lib/cjs/utils/processes.js +4 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/contracts/ao-process.js +7 -5
- package/lib/esm/common/http.js +1 -1
- package/lib/esm/common/io.js +103 -86
- package/lib/esm/types/index.js +3 -1
- package/lib/esm/utils/arweave.js +13 -15
- package/lib/esm/utils/index.js +2 -2
- package/lib/esm/utils/processes.js +4 -2
- package/lib/esm/version.js +1 -1
- package/lib/types/common/io.d.ts +22 -7
- package/lib/types/types/index.d.ts +3 -1
- package/lib/types/types/io.d.ts +44 -12
- package/lib/types/utils/arweave.d.ts +25 -1
- package/lib/types/utils/index.d.ts +2 -2
- package/lib/types/utils/processes.d.ts +3 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +2 -1
package/lib/esm/common/io.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IO_TESTNET_PROCESS_ID } from '../constants.js';
|
|
2
2
|
import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/io.js';
|
|
3
3
|
import { createAoSigner } from '../utils/ao.js';
|
|
4
|
+
import { getCurrentBlockUnixTimestampMs, pruneTags } from '../utils/arweave.js';
|
|
4
5
|
import { defaultArweave } from './arweave.js';
|
|
5
6
|
import { AOProcess } from './contracts/ao-process.js';
|
|
6
7
|
import { InvalidContractConfigurationError } from './error.js';
|
|
@@ -54,23 +55,15 @@ export class IOReadable {
|
|
|
54
55
|
{
|
|
55
56
|
name: 'Timestamp',
|
|
56
57
|
value: params?.timestamp?.toString() ??
|
|
57
|
-
(await this.arweave.
|
|
58
|
-
.getCurrent()
|
|
59
|
-
.then((block) => {
|
|
60
|
-
return { timestamp: block.timestamp * 1000 };
|
|
61
|
-
})
|
|
62
|
-
.catch(() => {
|
|
63
|
-
return { timestamp: Date.now() }; // fallback to current time
|
|
64
|
-
})).timestamp.toString(),
|
|
58
|
+
(await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
|
|
65
59
|
},
|
|
66
60
|
{
|
|
67
61
|
name: 'Epoch-Index',
|
|
68
62
|
value: params?.epochIndex?.toString(),
|
|
69
63
|
},
|
|
70
64
|
];
|
|
71
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
72
65
|
return this.process.read({
|
|
73
|
-
tags:
|
|
66
|
+
tags: pruneTags(allTags),
|
|
74
67
|
});
|
|
75
68
|
}
|
|
76
69
|
async getEpoch(epoch) {
|
|
@@ -79,23 +72,15 @@ export class IOReadable {
|
|
|
79
72
|
{
|
|
80
73
|
name: 'Timestamp',
|
|
81
74
|
value: epoch?.timestamp?.toString() ??
|
|
82
|
-
(await this.arweave.
|
|
83
|
-
.getCurrent()
|
|
84
|
-
.then((block) => {
|
|
85
|
-
return { timestamp: block.timestamp * 1000 };
|
|
86
|
-
})
|
|
87
|
-
.catch(() => {
|
|
88
|
-
return { timestamp: Date.now() }; // fallback to current time
|
|
89
|
-
})).timestamp.toString(),
|
|
75
|
+
(await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
|
|
90
76
|
},
|
|
91
77
|
{
|
|
92
78
|
name: 'Epoch-Index',
|
|
93
79
|
value: epoch?.epochIndex?.toString(),
|
|
94
80
|
},
|
|
95
81
|
];
|
|
96
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
97
82
|
return this.process.read({
|
|
98
|
-
tags:
|
|
83
|
+
tags: pruneTags(allTags),
|
|
99
84
|
});
|
|
100
85
|
}
|
|
101
86
|
async getArNSRecord({ name, }) {
|
|
@@ -106,17 +91,16 @@ export class IOReadable {
|
|
|
106
91
|
],
|
|
107
92
|
});
|
|
108
93
|
}
|
|
109
|
-
async getArNSRecords(
|
|
94
|
+
async getArNSRecords(params) {
|
|
110
95
|
const allTags = [
|
|
111
96
|
{ name: 'Action', value: 'Paginated-Records' },
|
|
112
|
-
{ name: 'Cursor', value:
|
|
113
|
-
{ name: 'Limit', value:
|
|
114
|
-
{ name: 'Sort-By', value:
|
|
115
|
-
{ name: 'Sort-Order', value:
|
|
97
|
+
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
98
|
+
{ name: 'Limit', value: params?.limit?.toString() },
|
|
99
|
+
{ name: 'Sort-By', value: params?.sortBy },
|
|
100
|
+
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
116
101
|
];
|
|
117
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
118
102
|
return this.process.read({
|
|
119
|
-
tags:
|
|
103
|
+
tags: pruneTags(allTags),
|
|
120
104
|
});
|
|
121
105
|
}
|
|
122
106
|
async getArNSReservedNames() {
|
|
@@ -140,17 +124,37 @@ export class IOReadable {
|
|
|
140
124
|
],
|
|
141
125
|
});
|
|
142
126
|
}
|
|
143
|
-
async getBalances(
|
|
127
|
+
async getBalances(params) {
|
|
144
128
|
const allTags = [
|
|
145
129
|
{ name: 'Action', value: 'Paginated-Balances' },
|
|
146
|
-
{ name: 'Cursor', value:
|
|
147
|
-
{ name: 'Limit', value:
|
|
148
|
-
{ name: 'Sort-By', value:
|
|
149
|
-
{ name: 'Sort-Order', value:
|
|
130
|
+
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
131
|
+
{ name: 'Limit', value: params?.limit?.toString() },
|
|
132
|
+
{ name: 'Sort-By', value: params?.sortBy },
|
|
133
|
+
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
134
|
+
];
|
|
135
|
+
return this.process.read({
|
|
136
|
+
tags: pruneTags(allTags),
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
async getVault({ address, vaultId, }) {
|
|
140
|
+
return this.process.read({
|
|
141
|
+
tags: [
|
|
142
|
+
{ name: 'Action', value: 'Vault' },
|
|
143
|
+
{ name: 'Address', value: address },
|
|
144
|
+
{ name: 'Vault-Id', value: vaultId },
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async getVaults(params) {
|
|
149
|
+
const allTags = [
|
|
150
|
+
{ name: 'Action', value: 'Paginated-Vaults' },
|
|
151
|
+
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
152
|
+
{ name: 'Limit', value: params?.limit?.toString() },
|
|
153
|
+
{ name: 'Sort-By', value: params?.sortBy },
|
|
154
|
+
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
150
155
|
];
|
|
151
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
152
156
|
return this.process.read({
|
|
153
|
-
tags:
|
|
157
|
+
tags: pruneTags(allTags),
|
|
154
158
|
});
|
|
155
159
|
}
|
|
156
160
|
async getGateway({ address, }) {
|
|
@@ -161,6 +165,32 @@ export class IOReadable {
|
|
|
161
165
|
],
|
|
162
166
|
});
|
|
163
167
|
}
|
|
168
|
+
async getGatewayDelegates({ address, ...pageParams }) {
|
|
169
|
+
const allTags = [
|
|
170
|
+
{ name: 'Action', value: 'Paginated-Delegates' },
|
|
171
|
+
{ name: 'Address', value: address },
|
|
172
|
+
{ name: 'Cursor', value: pageParams?.cursor?.toString() },
|
|
173
|
+
{ name: 'Limit', value: pageParams?.limit?.toString() },
|
|
174
|
+
{ name: 'Sort-By', value: pageParams?.sortBy },
|
|
175
|
+
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
176
|
+
];
|
|
177
|
+
return this.process.read({
|
|
178
|
+
tags: pruneTags(allTags),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
async getGatewayDelegateAllowList({ address, ...pageParams }) {
|
|
182
|
+
const allTags = [
|
|
183
|
+
{ name: 'Action', value: 'Paginated-Allowed-Delegates' },
|
|
184
|
+
{ name: 'Address', value: address },
|
|
185
|
+
{ name: 'Cursor', value: pageParams?.cursor?.toString() },
|
|
186
|
+
{ name: 'Limit', value: pageParams?.limit?.toString() },
|
|
187
|
+
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
188
|
+
// note: sortBy is omitted because it's not supported for this action as table is an of addresses
|
|
189
|
+
];
|
|
190
|
+
return this.process.read({
|
|
191
|
+
tags: pruneTags(allTags),
|
|
192
|
+
});
|
|
193
|
+
}
|
|
164
194
|
async getGateways(pageParams) {
|
|
165
195
|
const allTags = [
|
|
166
196
|
{ name: 'Action', value: 'Paginated-Gateways' },
|
|
@@ -169,9 +199,8 @@ export class IOReadable {
|
|
|
169
199
|
{ name: 'Sort-By', value: pageParams?.sortBy },
|
|
170
200
|
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
171
201
|
];
|
|
172
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
173
202
|
return this.process.read({
|
|
174
|
-
tags:
|
|
203
|
+
tags: pruneTags(allTags),
|
|
175
204
|
});
|
|
176
205
|
}
|
|
177
206
|
async getCurrentEpoch() {
|
|
@@ -198,23 +227,15 @@ export class IOReadable {
|
|
|
198
227
|
{
|
|
199
228
|
name: 'Timestamp',
|
|
200
229
|
value: epoch?.timestamp?.toString() ??
|
|
201
|
-
(await this.arweave.
|
|
202
|
-
.getCurrent()
|
|
203
|
-
.then((block) => {
|
|
204
|
-
return { timestamp: block.timestamp * 1000 };
|
|
205
|
-
})
|
|
206
|
-
.catch(() => {
|
|
207
|
-
return { timestamp: Date.now() }; // fallback to current time
|
|
208
|
-
})).timestamp.toString(),
|
|
230
|
+
(await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
|
|
209
231
|
},
|
|
210
232
|
{
|
|
211
233
|
name: 'Epoch-Index',
|
|
212
234
|
value: epoch?.epochIndex?.toString(),
|
|
213
235
|
},
|
|
214
236
|
];
|
|
215
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
216
237
|
return this.process.read({
|
|
217
|
-
tags:
|
|
238
|
+
tags: pruneTags(allTags),
|
|
218
239
|
});
|
|
219
240
|
}
|
|
220
241
|
async getPrescribedNames(epoch) {
|
|
@@ -223,23 +244,15 @@ export class IOReadable {
|
|
|
223
244
|
{
|
|
224
245
|
name: 'Timestamp',
|
|
225
246
|
value: epoch?.timestamp?.toString() ??
|
|
226
|
-
(await this.arweave.
|
|
227
|
-
.getCurrent()
|
|
228
|
-
.then((block) => {
|
|
229
|
-
return { timestamp: block.timestamp * 1000 };
|
|
230
|
-
})
|
|
231
|
-
.catch(() => {
|
|
232
|
-
return { timestamp: Date.now() }; // fallback to current time
|
|
233
|
-
})).timestamp.toString(),
|
|
247
|
+
(await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
|
|
234
248
|
},
|
|
235
249
|
{
|
|
236
250
|
name: 'Epoch-Index',
|
|
237
251
|
value: epoch?.epochIndex?.toString(),
|
|
238
252
|
},
|
|
239
253
|
];
|
|
240
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
241
254
|
return this.process.read({
|
|
242
|
-
tags:
|
|
255
|
+
tags: pruneTags(allTags),
|
|
243
256
|
});
|
|
244
257
|
}
|
|
245
258
|
async getObservations(epoch) {
|
|
@@ -262,9 +275,8 @@ export class IOReadable {
|
|
|
262
275
|
value: epoch?.epochIndex?.toString(),
|
|
263
276
|
},
|
|
264
277
|
];
|
|
265
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
266
278
|
return this.process.read({
|
|
267
|
-
tags:
|
|
279
|
+
tags: pruneTags(allTags),
|
|
268
280
|
});
|
|
269
281
|
}
|
|
270
282
|
async getDistributions(epoch) {
|
|
@@ -273,23 +285,15 @@ export class IOReadable {
|
|
|
273
285
|
{
|
|
274
286
|
name: 'Timestamp',
|
|
275
287
|
value: epoch?.timestamp?.toString() ??
|
|
276
|
-
(await this.arweave.
|
|
277
|
-
.getCurrent()
|
|
278
|
-
.then((block) => {
|
|
279
|
-
return { timestamp: block.timestamp * 1000 };
|
|
280
|
-
})
|
|
281
|
-
.catch(() => {
|
|
282
|
-
return { timestamp: Date.now() }; // fallback to current time
|
|
283
|
-
})).timestamp.toString(),
|
|
288
|
+
(await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
|
|
284
289
|
},
|
|
285
290
|
{
|
|
286
291
|
name: 'Epoch-Index',
|
|
287
292
|
value: epoch?.epochIndex?.toString(),
|
|
288
293
|
},
|
|
289
294
|
];
|
|
290
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
291
295
|
return this.process.read({
|
|
292
|
-
tags:
|
|
296
|
+
tags: pruneTags(allTags),
|
|
293
297
|
});
|
|
294
298
|
}
|
|
295
299
|
async getTokenCost({ intent, type, years, name, quantity, }) {
|
|
@@ -327,9 +331,8 @@ export class IOReadable {
|
|
|
327
331
|
})).timestamp.toString(),
|
|
328
332
|
},
|
|
329
333
|
];
|
|
330
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
331
334
|
return this.process.read({
|
|
332
|
-
tags:
|
|
335
|
+
tags: pruneTags(allTags),
|
|
333
336
|
});
|
|
334
337
|
}
|
|
335
338
|
async getRegistrationFees() {
|
|
@@ -351,9 +354,8 @@ export class IOReadable {
|
|
|
351
354
|
{ name: 'Sort-By', value: params?.sortBy },
|
|
352
355
|
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
353
356
|
];
|
|
354
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
355
357
|
return this.process.read({
|
|
356
|
-
tags:
|
|
358
|
+
tags: pruneTags(allTags),
|
|
357
359
|
});
|
|
358
360
|
}
|
|
359
361
|
async getArNSAuction({ name, }) {
|
|
@@ -400,6 +402,19 @@ export class IOReadable {
|
|
|
400
402
|
tags: prunedPriceTags,
|
|
401
403
|
});
|
|
402
404
|
}
|
|
405
|
+
async getDelegations(params) {
|
|
406
|
+
const allTags = [
|
|
407
|
+
{ name: 'Action', value: 'Paginated-Delegations' },
|
|
408
|
+
{ name: 'Cursor', value: params.cursor?.toString() },
|
|
409
|
+
{ name: 'Limit', value: params.limit?.toString() },
|
|
410
|
+
{ name: 'Sort-By', value: params.sortBy },
|
|
411
|
+
{ name: 'Sort-Order', value: params.sortOrder },
|
|
412
|
+
{ name: 'Address', value: params.address },
|
|
413
|
+
];
|
|
414
|
+
return this.process.read({
|
|
415
|
+
tags: pruneTags(allTags),
|
|
416
|
+
});
|
|
417
|
+
}
|
|
403
418
|
}
|
|
404
419
|
export class IOWriteable extends IOReadable {
|
|
405
420
|
signer;
|
|
@@ -446,7 +461,7 @@ export class IOWriteable extends IOReadable {
|
|
|
446
461
|
signer: this.signer,
|
|
447
462
|
});
|
|
448
463
|
}
|
|
449
|
-
async joinNetwork({ operatorStake, allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
464
|
+
async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
450
465
|
const { tags = [] } = options || {};
|
|
451
466
|
const allTags = [
|
|
452
467
|
...tags,
|
|
@@ -459,6 +474,10 @@ export class IOWriteable extends IOReadable {
|
|
|
459
474
|
name: 'Allow-Delegated-Staking',
|
|
460
475
|
value: allowDelegatedStaking?.toString(),
|
|
461
476
|
},
|
|
477
|
+
{
|
|
478
|
+
name: 'Allowed-Delegates',
|
|
479
|
+
value: allowedDelegates?.join(','),
|
|
480
|
+
},
|
|
462
481
|
{
|
|
463
482
|
name: 'Delegate-Reward-Share-Ratio',
|
|
464
483
|
value: delegateRewardShareRatio?.toString(),
|
|
@@ -500,10 +519,9 @@ export class IOWriteable extends IOReadable {
|
|
|
500
519
|
value: observerAddress,
|
|
501
520
|
},
|
|
502
521
|
];
|
|
503
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
504
522
|
return this.process.send({
|
|
505
523
|
signer: this.signer,
|
|
506
|
-
tags:
|
|
524
|
+
tags: pruneTags(allTags),
|
|
507
525
|
});
|
|
508
526
|
}
|
|
509
527
|
async leaveNetwork(options) {
|
|
@@ -513,7 +531,7 @@ export class IOWriteable extends IOReadable {
|
|
|
513
531
|
tags: [...tags, { name: 'Action', value: 'Leave-Network' }],
|
|
514
532
|
});
|
|
515
533
|
}
|
|
516
|
-
async updateGatewaySettings({ allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
534
|
+
async updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
517
535
|
const { tags = [] } = options || {};
|
|
518
536
|
const allTags = [
|
|
519
537
|
...tags,
|
|
@@ -529,6 +547,10 @@ export class IOWriteable extends IOReadable {
|
|
|
529
547
|
name: 'Allow-Delegated-Staking',
|
|
530
548
|
value: allowDelegatedStaking?.toString(),
|
|
531
549
|
},
|
|
550
|
+
{
|
|
551
|
+
name: 'Allowed-Delegates',
|
|
552
|
+
value: allowedDelegates?.join(','),
|
|
553
|
+
},
|
|
532
554
|
{
|
|
533
555
|
name: 'Delegate-Reward-Share-Ratio',
|
|
534
556
|
value: delegateRewardShareRatio?.toString(),
|
|
@@ -539,10 +561,9 @@ export class IOWriteable extends IOReadable {
|
|
|
539
561
|
},
|
|
540
562
|
{ name: 'Auto-Stake', value: autoStake?.toString() },
|
|
541
563
|
];
|
|
542
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
543
564
|
return this.process.send({
|
|
544
565
|
signer: this.signer,
|
|
545
|
-
tags:
|
|
566
|
+
tags: pruneTags(allTags),
|
|
546
567
|
});
|
|
547
568
|
}
|
|
548
569
|
async delegateStake(params, options) {
|
|
@@ -586,10 +607,9 @@ export class IOWriteable extends IOReadable {
|
|
|
586
607
|
{ name: 'Vault-Id', value: params.vaultId },
|
|
587
608
|
{ name: 'Address', value: params.gatewayAddress },
|
|
588
609
|
];
|
|
589
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
590
610
|
return this.process.send({
|
|
591
611
|
signer: this.signer,
|
|
592
|
-
tags:
|
|
612
|
+
tags: pruneTags(allTags),
|
|
593
613
|
});
|
|
594
614
|
}
|
|
595
615
|
async increaseOperatorStake(params, options) {
|
|
@@ -642,10 +662,9 @@ export class IOWriteable extends IOReadable {
|
|
|
642
662
|
{ name: 'Process-Id', value: params.processId },
|
|
643
663
|
{ name: 'Purchase-Type', value: params.type || 'lease' },
|
|
644
664
|
];
|
|
645
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
646
665
|
return this.process.send({
|
|
647
666
|
signer: this.signer,
|
|
648
|
-
tags:
|
|
667
|
+
tags: pruneTags(allTags),
|
|
649
668
|
});
|
|
650
669
|
}
|
|
651
670
|
/**
|
|
@@ -717,10 +736,9 @@ export class IOWriteable extends IOReadable {
|
|
|
717
736
|
{ name: 'Vault-Id', value: params.vaultId },
|
|
718
737
|
{ name: 'Address', value: params.gatewayAddress },
|
|
719
738
|
];
|
|
720
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
721
739
|
return this.process.send({
|
|
722
740
|
signer: this.signer,
|
|
723
|
-
tags:
|
|
741
|
+
tags: pruneTags(allTags),
|
|
724
742
|
});
|
|
725
743
|
}
|
|
726
744
|
async submitAuctionBid(params, options) {
|
|
@@ -734,10 +752,9 @@ export class IOWriteable extends IOReadable {
|
|
|
734
752
|
{ name: 'Purchase-Type', value: params.type || 'lease' },
|
|
735
753
|
{ name: 'Years', value: params.years?.toString() ?? undefined },
|
|
736
754
|
];
|
|
737
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
738
755
|
return this.process.send({
|
|
739
756
|
signer: this.signer,
|
|
740
|
-
tags:
|
|
757
|
+
tags: pruneTags(allTags),
|
|
741
758
|
});
|
|
742
759
|
}
|
|
743
760
|
}
|
package/lib/esm/types/index.js
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
export * from './ant-registry.js';
|
|
17
|
+
export * from './ant.js';
|
|
16
18
|
export * from './common.js';
|
|
17
|
-
export * from './token.js';
|
|
18
19
|
export * from './io.js';
|
|
20
|
+
export * from './token.js';
|
package/lib/esm/utils/arweave.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
1
|
import { ARWEAVE_TX_REGEX } from '../constants.js';
|
|
17
2
|
export const validateArweaveId = (id) => {
|
|
18
3
|
return ARWEAVE_TX_REGEX.test(id);
|
|
@@ -20,3 +5,16 @@ export const validateArweaveId = (id) => {
|
|
|
20
5
|
export function isBlockHeight(height) {
|
|
21
6
|
return height !== undefined && !isNaN(parseInt(height.toString()));
|
|
22
7
|
}
|
|
8
|
+
export const pruneTags = (tags) => {
|
|
9
|
+
return tags.filter((tag) => tag.value !== undefined);
|
|
10
|
+
};
|
|
11
|
+
export const getCurrentBlockUnixTimestampMs = async (arweave) => {
|
|
12
|
+
return await arweave.blocks
|
|
13
|
+
.getCurrent()
|
|
14
|
+
.then((block) => {
|
|
15
|
+
return block.timestamp * 1000;
|
|
16
|
+
})
|
|
17
|
+
.catch(() => {
|
|
18
|
+
return Date.now(); // fallback to current time
|
|
19
|
+
});
|
|
20
|
+
};
|
package/lib/esm/utils/index.js
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
export * from './arweave.js';
|
|
17
|
-
export * from './http-client.js';
|
|
18
16
|
export * from './ao.js';
|
|
17
|
+
export * from './arweave.js';
|
|
18
|
+
export * from './base64.js';
|
|
19
19
|
export * from './json.js';
|
|
20
20
|
export * from './processes.js';
|
|
21
21
|
export * from './schema.js';
|
|
@@ -48,14 +48,16 @@ export class ArNSEventEmitter extends EventEmitter {
|
|
|
48
48
|
timeoutMs; // timeout for each request to 3 seconds
|
|
49
49
|
throttle;
|
|
50
50
|
logger;
|
|
51
|
+
strict;
|
|
51
52
|
constructor({ contract = IO.init({
|
|
52
53
|
processId: IO_TESTNET_PROCESS_ID,
|
|
53
|
-
}), timeoutMs = 60_000, concurrency = 30, logger = Logger.default, } = {}) {
|
|
54
|
+
}), timeoutMs = 60_000, concurrency = 30, logger = Logger.default, strict = false, } = {}) {
|
|
54
55
|
super();
|
|
55
56
|
this.contract = contract;
|
|
56
57
|
this.timeoutMs = timeoutMs;
|
|
57
58
|
this.throttle = pLimit(concurrency);
|
|
58
59
|
this.logger = logger;
|
|
60
|
+
this.strict = strict;
|
|
59
61
|
}
|
|
60
62
|
async fetchProcessesOwnedByWallet({ address, pageSize, antRegistry = ANTRegistry.init(), }) {
|
|
61
63
|
const uniqueContractProcessIds = {};
|
|
@@ -94,7 +96,7 @@ export class ArNSEventEmitter extends EventEmitter {
|
|
|
94
96
|
}
|
|
95
97
|
const ant = ANT.init({
|
|
96
98
|
processId,
|
|
97
|
-
strict:
|
|
99
|
+
strict: this.strict,
|
|
98
100
|
});
|
|
99
101
|
const state = (await timeout(this.timeoutMs, ant.getState()).catch((e) => {
|
|
100
102
|
this.emit('error', `Error getting state for process ${processId}: ${e}`);
|
package/lib/esm/version.js
CHANGED
package/lib/types/common/io.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import Arweave from 'arweave';
|
|
17
17
|
import { AoArNSNameDataWithName, AoArNSReservedNameData, AoAuction, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, ContractSigner, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
18
|
-
import { AoArNSNameData, AoAuctionPriceData, AoEpochData, AoEpochSettings, AoGateway, AoIORead, AoIOWrite, AoRegistrationFees, EpochInput } from '../types/io.js';
|
|
18
|
+
import { AoArNSNameData, AoAuctionPriceData, AoDelegation, AoEpochData, AoEpochSettings, AoGateway, AoGatewayDelegateWithAddress, AoIORead, AoIOWrite, AoRegistrationFees, AoVaultData, AoWalletVault, EpochInput } from '../types/io.js';
|
|
19
19
|
import { mIOToken } from '../types/token.js';
|
|
20
20
|
import { AOProcess } from './contracts/ao-process.js';
|
|
21
21
|
export declare class IO {
|
|
@@ -55,7 +55,7 @@ export declare class IOReadable implements AoIORead {
|
|
|
55
55
|
getArNSRecord({ name, }: {
|
|
56
56
|
name: string;
|
|
57
57
|
}): Promise<AoArNSNameData | undefined>;
|
|
58
|
-
getArNSRecords(
|
|
58
|
+
getArNSRecords(params?: PaginationParams<AoArNSNameDataWithName>): Promise<PaginationResult<AoArNSNameDataWithName>>;
|
|
59
59
|
getArNSReservedNames(): Promise<Record<string, AoArNSReservedNameData> | Record<string, never>>;
|
|
60
60
|
getArNSReservedName({ name, }: {
|
|
61
61
|
name: string;
|
|
@@ -63,11 +63,23 @@ export declare class IOReadable implements AoIORead {
|
|
|
63
63
|
getBalance({ address }: {
|
|
64
64
|
address: WalletAddress;
|
|
65
65
|
}): Promise<number>;
|
|
66
|
-
getBalances(
|
|
66
|
+
getBalances(params?: PaginationParams<AoBalanceWithAddress>): Promise<PaginationResult<AoBalanceWithAddress>>;
|
|
67
|
+
getVault({ address, vaultId, }: {
|
|
68
|
+
address: WalletAddress;
|
|
69
|
+
vaultId: string;
|
|
70
|
+
}): Promise<AoVaultData>;
|
|
71
|
+
getVaults(params?: PaginationParams<AoWalletVault>): Promise<PaginationResult<AoWalletVault>>;
|
|
67
72
|
getGateway({ address, }: {
|
|
68
73
|
address: WalletAddress;
|
|
69
74
|
}): Promise<AoGateway | undefined>;
|
|
70
|
-
|
|
75
|
+
getGatewayDelegates({ address, ...pageParams }: {
|
|
76
|
+
[x: string]: any;
|
|
77
|
+
address: any;
|
|
78
|
+
}): Promise<PaginationResult<AoGatewayDelegateWithAddress>>;
|
|
79
|
+
getGatewayDelegateAllowList({ address, ...pageParams }: {
|
|
80
|
+
address: WalletAddress;
|
|
81
|
+
} & PaginationParams<WalletAddress>): Promise<PaginationResult<WalletAddress>>;
|
|
82
|
+
getGateways(pageParams?: PaginationParams<AoGatewayWithAddress>): Promise<PaginationResult<AoGatewayWithAddress>>;
|
|
71
83
|
getCurrentEpoch(): Promise<AoEpochData>;
|
|
72
84
|
getPrescribedObservers(epoch?: EpochInput): Promise<AoWeightedObserver[]>;
|
|
73
85
|
getPrescribedNames(epoch?: EpochInput): Promise<string[]>;
|
|
@@ -91,7 +103,7 @@ export declare class IOReadable implements AoIORead {
|
|
|
91
103
|
}): Promise<number>;
|
|
92
104
|
getRegistrationFees(): Promise<AoRegistrationFees>;
|
|
93
105
|
getDemandFactor(): Promise<number>;
|
|
94
|
-
getArNSAuctions(params?: PaginationParams): Promise<PaginationResult<AoAuction>>;
|
|
106
|
+
getArNSAuctions(params?: PaginationParams<AoAuction>): Promise<PaginationResult<AoAuction>>;
|
|
95
107
|
getArNSAuction({ name, }: {
|
|
96
108
|
name: string;
|
|
97
109
|
}): Promise<AoAuction | undefined>;
|
|
@@ -113,6 +125,9 @@ export declare class IOReadable implements AoIORead {
|
|
|
113
125
|
timestamp?: number;
|
|
114
126
|
intervalMs?: number;
|
|
115
127
|
}): Promise<AoAuctionPriceData>;
|
|
128
|
+
getDelegations(params: PaginationParams<AoDelegation> & {
|
|
129
|
+
address: WalletAddress;
|
|
130
|
+
}): Promise<PaginationResult<AoDelegation>>;
|
|
116
131
|
}
|
|
117
132
|
export declare class IOWriteable extends IOReadable implements AoIOWrite {
|
|
118
133
|
protected process: AOProcess;
|
|
@@ -126,9 +141,9 @@ export declare class IOWriteable extends IOReadable implements AoIOWrite {
|
|
|
126
141
|
target: string;
|
|
127
142
|
qty: number | mIOToken;
|
|
128
143
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
129
|
-
joinNetwork({ operatorStake, allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoJoinNetworkParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
144
|
+
joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoJoinNetworkParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
130
145
|
leaveNetwork(options?: WriteOptions): Promise<AoMessageResult>;
|
|
131
|
-
updateGatewaySettings({ allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoUpdateGatewaySettingsParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
146
|
+
updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoUpdateGatewaySettingsParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
132
147
|
delegateStake(params: {
|
|
133
148
|
target: string;
|
|
134
149
|
stakeQty: number | mIOToken;
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
export * from './ant-registry.js';
|
|
17
|
+
export * from './ant.js';
|
|
16
18
|
export * from './common.js';
|
|
17
|
-
export * from './token.js';
|
|
18
19
|
export * from './io.js';
|
|
20
|
+
export * from './token.js';
|