@ar.io/sdk 2.4.0-alpha.8 → 2.4.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 +98 -10
- 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 +95 -91
- 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 +93 -89
- 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 +21 -9
- package/lib/types/types/index.d.ts +3 -1
- package/lib/types/types/io.d.ts +41 -22
- 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 +8 -6
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() {
|
|
@@ -343,7 +346,7 @@ export class IOReadable {
|
|
|
343
346
|
});
|
|
344
347
|
}
|
|
345
348
|
// Auctions
|
|
346
|
-
async
|
|
349
|
+
async getArNSAuctions(params) {
|
|
347
350
|
const allTags = [
|
|
348
351
|
{ name: 'Action', value: 'Auctions' },
|
|
349
352
|
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
@@ -351,12 +354,11 @@ 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
|
-
async
|
|
361
|
+
async getArNSAuction({ name, }) {
|
|
360
362
|
const allTags = [
|
|
361
363
|
{ name: 'Action', value: 'Auction-Info' },
|
|
362
364
|
{ name: 'Name', value: name },
|
|
@@ -376,7 +378,7 @@ export class IOReadable {
|
|
|
376
378
|
* @param {number} [params.intervalMs=900000] - The interval in milliseconds between price points (default is 15 minutes)
|
|
377
379
|
* @returns {Promise<AoAuctionPriceData>} The auction price data
|
|
378
380
|
*/
|
|
379
|
-
async
|
|
381
|
+
async getArNSAuctionPrices({ name, type, years, timestamp, intervalMs, }) {
|
|
380
382
|
const prunedPriceTags = [
|
|
381
383
|
{ name: 'Action', value: 'Auction-Prices' },
|
|
382
384
|
{ name: 'Name', value: name },
|
|
@@ -446,7 +448,7 @@ export class IOWriteable extends IOReadable {
|
|
|
446
448
|
signer: this.signer,
|
|
447
449
|
});
|
|
448
450
|
}
|
|
449
|
-
async joinNetwork({ operatorStake, allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
451
|
+
async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
450
452
|
const { tags = [] } = options || {};
|
|
451
453
|
const allTags = [
|
|
452
454
|
...tags,
|
|
@@ -459,6 +461,10 @@ export class IOWriteable extends IOReadable {
|
|
|
459
461
|
name: 'Allow-Delegated-Staking',
|
|
460
462
|
value: allowDelegatedStaking?.toString(),
|
|
461
463
|
},
|
|
464
|
+
{
|
|
465
|
+
name: 'Allowed-Delegates',
|
|
466
|
+
value: allowedDelegates?.join(','),
|
|
467
|
+
},
|
|
462
468
|
{
|
|
463
469
|
name: 'Delegate-Reward-Share-Ratio',
|
|
464
470
|
value: delegateRewardShareRatio?.toString(),
|
|
@@ -500,10 +506,9 @@ export class IOWriteable extends IOReadable {
|
|
|
500
506
|
value: observerAddress,
|
|
501
507
|
},
|
|
502
508
|
];
|
|
503
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
504
509
|
return this.process.send({
|
|
505
510
|
signer: this.signer,
|
|
506
|
-
tags:
|
|
511
|
+
tags: pruneTags(allTags),
|
|
507
512
|
});
|
|
508
513
|
}
|
|
509
514
|
async leaveNetwork(options) {
|
|
@@ -513,7 +518,7 @@ export class IOWriteable extends IOReadable {
|
|
|
513
518
|
tags: [...tags, { name: 'Action', value: 'Leave-Network' }],
|
|
514
519
|
});
|
|
515
520
|
}
|
|
516
|
-
async updateGatewaySettings({ allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
521
|
+
async updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
517
522
|
const { tags = [] } = options || {};
|
|
518
523
|
const allTags = [
|
|
519
524
|
...tags,
|
|
@@ -529,6 +534,10 @@ export class IOWriteable extends IOReadable {
|
|
|
529
534
|
name: 'Allow-Delegated-Staking',
|
|
530
535
|
value: allowDelegatedStaking?.toString(),
|
|
531
536
|
},
|
|
537
|
+
{
|
|
538
|
+
name: 'Allowed-Delegates',
|
|
539
|
+
value: allowedDelegates?.join(','),
|
|
540
|
+
},
|
|
532
541
|
{
|
|
533
542
|
name: 'Delegate-Reward-Share-Ratio',
|
|
534
543
|
value: delegateRewardShareRatio?.toString(),
|
|
@@ -539,10 +548,9 @@ export class IOWriteable extends IOReadable {
|
|
|
539
548
|
},
|
|
540
549
|
{ name: 'Auto-Stake', value: autoStake?.toString() },
|
|
541
550
|
];
|
|
542
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
543
551
|
return this.process.send({
|
|
544
552
|
signer: this.signer,
|
|
545
|
-
tags:
|
|
553
|
+
tags: pruneTags(allTags),
|
|
546
554
|
});
|
|
547
555
|
}
|
|
548
556
|
async delegateStake(params, options) {
|
|
@@ -586,10 +594,9 @@ export class IOWriteable extends IOReadable {
|
|
|
586
594
|
{ name: 'Vault-Id', value: params.vaultId },
|
|
587
595
|
{ name: 'Address', value: params.gatewayAddress },
|
|
588
596
|
];
|
|
589
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
590
597
|
return this.process.send({
|
|
591
598
|
signer: this.signer,
|
|
592
|
-
tags:
|
|
599
|
+
tags: pruneTags(allTags),
|
|
593
600
|
});
|
|
594
601
|
}
|
|
595
602
|
async increaseOperatorStake(params, options) {
|
|
@@ -642,10 +649,9 @@ export class IOWriteable extends IOReadable {
|
|
|
642
649
|
{ name: 'Process-Id', value: params.processId },
|
|
643
650
|
{ name: 'Purchase-Type', value: params.type || 'lease' },
|
|
644
651
|
];
|
|
645
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
646
652
|
return this.process.send({
|
|
647
653
|
signer: this.signer,
|
|
648
|
-
tags:
|
|
654
|
+
tags: pruneTags(allTags),
|
|
649
655
|
});
|
|
650
656
|
}
|
|
651
657
|
/**
|
|
@@ -717,10 +723,9 @@ export class IOWriteable extends IOReadable {
|
|
|
717
723
|
{ name: 'Vault-Id', value: params.vaultId },
|
|
718
724
|
{ name: 'Address', value: params.gatewayAddress },
|
|
719
725
|
];
|
|
720
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
721
726
|
return this.process.send({
|
|
722
727
|
signer: this.signer,
|
|
723
|
-
tags:
|
|
728
|
+
tags: pruneTags(allTags),
|
|
724
729
|
});
|
|
725
730
|
}
|
|
726
731
|
async submitAuctionBid(params, options) {
|
|
@@ -734,10 +739,9 @@ export class IOWriteable extends IOReadable {
|
|
|
734
739
|
{ name: 'Purchase-Type', value: params.type || 'lease' },
|
|
735
740
|
{ name: 'Years', value: params.years?.toString() ?? undefined },
|
|
736
741
|
];
|
|
737
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
738
742
|
return this.process.send({
|
|
739
743
|
signer: this.signer,
|
|
740
|
-
tags:
|
|
744
|
+
tags: pruneTags(allTags),
|
|
741
745
|
});
|
|
742
746
|
}
|
|
743
747
|
}
|
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, 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,8 +103,8 @@ export declare class IOReadable implements AoIORead {
|
|
|
91
103
|
}): Promise<number>;
|
|
92
104
|
getRegistrationFees(): Promise<AoRegistrationFees>;
|
|
93
105
|
getDemandFactor(): Promise<number>;
|
|
94
|
-
|
|
95
|
-
|
|
106
|
+
getArNSAuctions(params?: PaginationParams<AoAuction>): Promise<PaginationResult<AoAuction>>;
|
|
107
|
+
getArNSAuction({ name, }: {
|
|
96
108
|
name: string;
|
|
97
109
|
}): Promise<AoAuction | undefined>;
|
|
98
110
|
/**
|
|
@@ -106,7 +118,7 @@ export declare class IOReadable implements AoIORead {
|
|
|
106
118
|
* @param {number} [params.intervalMs=900000] - The interval in milliseconds between price points (default is 15 minutes)
|
|
107
119
|
* @returns {Promise<AoAuctionPriceData>} The auction price data
|
|
108
120
|
*/
|
|
109
|
-
|
|
121
|
+
getArNSAuctionPrices({ name, type, years, timestamp, intervalMs, }: {
|
|
110
122
|
name: string;
|
|
111
123
|
type?: 'permabuy' | 'lease';
|
|
112
124
|
years?: number;
|
|
@@ -126,9 +138,9 @@ export declare class IOWriteable extends IOReadable implements AoIOWrite {
|
|
|
126
138
|
target: string;
|
|
127
139
|
qty: number | mIOToken;
|
|
128
140
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
129
|
-
joinNetwork({ operatorStake, allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoJoinNetworkParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
141
|
+
joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoJoinNetworkParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
130
142
|
leaveNetwork(options?: WriteOptions): Promise<AoMessageResult>;
|
|
131
|
-
updateGatewaySettings({ allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoUpdateGatewaySettingsParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
143
|
+
updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoUpdateGatewaySettingsParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
132
144
|
delegateStake(params: {
|
|
133
145
|
target: string;
|
|
134
146
|
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';
|