@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
|
@@ -43,19 +43,21 @@ class AOProcess {
|
|
|
43
43
|
process: this.processId,
|
|
44
44
|
tags,
|
|
45
45
|
});
|
|
46
|
+
this.logger.debug(`Read interaction result`, {
|
|
47
|
+
result,
|
|
48
|
+
});
|
|
46
49
|
if (result.Messages === undefined || result.Messages.length === 0) {
|
|
50
|
+
this.logger.debug(`Process ${this.processId} does not support provided action.`, result, tags);
|
|
47
51
|
throw new Error(`Process ${this.processId} does not support provided action.`);
|
|
48
52
|
}
|
|
49
53
|
const tagsOutput = result.Messages[0].Tags;
|
|
54
|
+
const messageData = result.Messages[0].Data;
|
|
50
55
|
const error = tagsOutput.find((tag) => tag.name === 'Error');
|
|
51
56
|
if (error) {
|
|
52
|
-
throw new Error(`${error.
|
|
57
|
+
throw new Error(`${error.value}${messageData ? `: ${messageData}` : ''}`);
|
|
53
58
|
}
|
|
54
|
-
this.logger.debug(`Read interaction result`, {
|
|
55
|
-
result: result.Messages[0].Data,
|
|
56
|
-
});
|
|
57
59
|
// return empty object if no data is returned
|
|
58
|
-
if (
|
|
60
|
+
if (messageData === undefined) {
|
|
59
61
|
return {};
|
|
60
62
|
}
|
|
61
63
|
const response = (0, json_js_1.safeDecode)(result.Messages[0].Data);
|
package/lib/cjs/common/http.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AxiosHTTPService = void 0;
|
|
4
|
-
const
|
|
4
|
+
const http_client_js_1 = require("../utils/http-client.js");
|
|
5
5
|
const error_js_1 = require("./error.js");
|
|
6
6
|
const logger_js_1 = require("./logger.js");
|
|
7
7
|
class AxiosHTTPService {
|
|
@@ -9,7 +9,7 @@ class AxiosHTTPService {
|
|
|
9
9
|
logger;
|
|
10
10
|
constructor({ url, logger = logger_js_1.Logger.default, }) {
|
|
11
11
|
this.logger = logger;
|
|
12
|
-
this.axios = (0,
|
|
12
|
+
this.axios = (0, http_client_js_1.createAxiosInstance)({
|
|
13
13
|
axiosConfig: {
|
|
14
14
|
baseURL: url,
|
|
15
15
|
},
|
package/lib/cjs/common/io.js
CHANGED
|
@@ -4,7 +4,8 @@ exports.IOWriteable = exports.IOReadable = exports.IO = void 0;
|
|
|
4
4
|
const constants_js_1 = require("../constants.js");
|
|
5
5
|
const io_js_1 = require("../types/io.js");
|
|
6
6
|
const ao_js_1 = require("../utils/ao.js");
|
|
7
|
-
const arweave_js_1 = require("
|
|
7
|
+
const arweave_js_1 = require("../utils/arweave.js");
|
|
8
|
+
const arweave_js_2 = require("./arweave.js");
|
|
8
9
|
const ao_process_js_1 = require("./contracts/ao-process.js");
|
|
9
10
|
const error_js_1 = require("./error.js");
|
|
10
11
|
class IO {
|
|
@@ -23,7 +24,7 @@ exports.IO = IO;
|
|
|
23
24
|
class IOReadable {
|
|
24
25
|
process;
|
|
25
26
|
arweave;
|
|
26
|
-
constructor(config, arweave =
|
|
27
|
+
constructor(config, arweave = arweave_js_2.defaultArweave) {
|
|
27
28
|
if (!config) {
|
|
28
29
|
this.process = new ao_process_js_1.AOProcess({
|
|
29
30
|
processId: constants_js_1.IO_TESTNET_PROCESS_ID,
|
|
@@ -58,23 +59,15 @@ class IOReadable {
|
|
|
58
59
|
{
|
|
59
60
|
name: 'Timestamp',
|
|
60
61
|
value: params?.timestamp?.toString() ??
|
|
61
|
-
(await this.arweave.
|
|
62
|
-
.getCurrent()
|
|
63
|
-
.then((block) => {
|
|
64
|
-
return { timestamp: block.timestamp * 1000 };
|
|
65
|
-
})
|
|
66
|
-
.catch(() => {
|
|
67
|
-
return { timestamp: Date.now() }; // fallback to current time
|
|
68
|
-
})).timestamp.toString(),
|
|
62
|
+
(await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
|
|
69
63
|
},
|
|
70
64
|
{
|
|
71
65
|
name: 'Epoch-Index',
|
|
72
66
|
value: params?.epochIndex?.toString(),
|
|
73
67
|
},
|
|
74
68
|
];
|
|
75
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
76
69
|
return this.process.read({
|
|
77
|
-
tags:
|
|
70
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
78
71
|
});
|
|
79
72
|
}
|
|
80
73
|
async getEpoch(epoch) {
|
|
@@ -83,23 +76,15 @@ class IOReadable {
|
|
|
83
76
|
{
|
|
84
77
|
name: 'Timestamp',
|
|
85
78
|
value: epoch?.timestamp?.toString() ??
|
|
86
|
-
(await this.arweave.
|
|
87
|
-
.getCurrent()
|
|
88
|
-
.then((block) => {
|
|
89
|
-
return { timestamp: block.timestamp * 1000 };
|
|
90
|
-
})
|
|
91
|
-
.catch(() => {
|
|
92
|
-
return { timestamp: Date.now() }; // fallback to current time
|
|
93
|
-
})).timestamp.toString(),
|
|
79
|
+
(await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
|
|
94
80
|
},
|
|
95
81
|
{
|
|
96
82
|
name: 'Epoch-Index',
|
|
97
83
|
value: epoch?.epochIndex?.toString(),
|
|
98
84
|
},
|
|
99
85
|
];
|
|
100
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
101
86
|
return this.process.read({
|
|
102
|
-
tags:
|
|
87
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
103
88
|
});
|
|
104
89
|
}
|
|
105
90
|
async getArNSRecord({ name, }) {
|
|
@@ -110,17 +95,16 @@ class IOReadable {
|
|
|
110
95
|
],
|
|
111
96
|
});
|
|
112
97
|
}
|
|
113
|
-
async getArNSRecords(
|
|
98
|
+
async getArNSRecords(params) {
|
|
114
99
|
const allTags = [
|
|
115
100
|
{ name: 'Action', value: 'Paginated-Records' },
|
|
116
|
-
{ name: 'Cursor', value:
|
|
117
|
-
{ name: 'Limit', value:
|
|
118
|
-
{ name: 'Sort-By', value:
|
|
119
|
-
{ name: 'Sort-Order', value:
|
|
101
|
+
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
102
|
+
{ name: 'Limit', value: params?.limit?.toString() },
|
|
103
|
+
{ name: 'Sort-By', value: params?.sortBy },
|
|
104
|
+
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
120
105
|
];
|
|
121
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
122
106
|
return this.process.read({
|
|
123
|
-
tags:
|
|
107
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
124
108
|
});
|
|
125
109
|
}
|
|
126
110
|
async getArNSReservedNames() {
|
|
@@ -144,17 +128,37 @@ class IOReadable {
|
|
|
144
128
|
],
|
|
145
129
|
});
|
|
146
130
|
}
|
|
147
|
-
async getBalances(
|
|
131
|
+
async getBalances(params) {
|
|
148
132
|
const allTags = [
|
|
149
133
|
{ name: 'Action', value: 'Paginated-Balances' },
|
|
150
|
-
{ name: 'Cursor', value:
|
|
151
|
-
{ name: 'Limit', value:
|
|
152
|
-
{ name: 'Sort-By', value:
|
|
153
|
-
{ name: 'Sort-Order', value:
|
|
134
|
+
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
135
|
+
{ name: 'Limit', value: params?.limit?.toString() },
|
|
136
|
+
{ name: 'Sort-By', value: params?.sortBy },
|
|
137
|
+
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
138
|
+
];
|
|
139
|
+
return this.process.read({
|
|
140
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async getVault({ address, vaultId, }) {
|
|
144
|
+
return this.process.read({
|
|
145
|
+
tags: [
|
|
146
|
+
{ name: 'Action', value: 'Vault' },
|
|
147
|
+
{ name: 'Address', value: address },
|
|
148
|
+
{ name: 'Vault-Id', value: vaultId },
|
|
149
|
+
],
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
async getVaults(params) {
|
|
153
|
+
const allTags = [
|
|
154
|
+
{ name: 'Action', value: 'Paginated-Vaults' },
|
|
155
|
+
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
156
|
+
{ name: 'Limit', value: params?.limit?.toString() },
|
|
157
|
+
{ name: 'Sort-By', value: params?.sortBy },
|
|
158
|
+
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
154
159
|
];
|
|
155
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
156
160
|
return this.process.read({
|
|
157
|
-
tags:
|
|
161
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
158
162
|
});
|
|
159
163
|
}
|
|
160
164
|
async getGateway({ address, }) {
|
|
@@ -165,6 +169,32 @@ class IOReadable {
|
|
|
165
169
|
],
|
|
166
170
|
});
|
|
167
171
|
}
|
|
172
|
+
async getGatewayDelegates({ address, ...pageParams }) {
|
|
173
|
+
const allTags = [
|
|
174
|
+
{ name: 'Action', value: 'Paginated-Delegates' },
|
|
175
|
+
{ name: 'Address', value: address },
|
|
176
|
+
{ name: 'Cursor', value: pageParams?.cursor?.toString() },
|
|
177
|
+
{ name: 'Limit', value: pageParams?.limit?.toString() },
|
|
178
|
+
{ name: 'Sort-By', value: pageParams?.sortBy },
|
|
179
|
+
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
180
|
+
];
|
|
181
|
+
return this.process.read({
|
|
182
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
async getGatewayDelegateAllowList({ address, ...pageParams }) {
|
|
186
|
+
const allTags = [
|
|
187
|
+
{ name: 'Action', value: 'Paginated-Allowed-Delegates' },
|
|
188
|
+
{ name: 'Address', value: address },
|
|
189
|
+
{ name: 'Cursor', value: pageParams?.cursor?.toString() },
|
|
190
|
+
{ name: 'Limit', value: pageParams?.limit?.toString() },
|
|
191
|
+
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
192
|
+
// note: sortBy is omitted because it's not supported for this action as table is an of addresses
|
|
193
|
+
];
|
|
194
|
+
return this.process.read({
|
|
195
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
196
|
+
});
|
|
197
|
+
}
|
|
168
198
|
async getGateways(pageParams) {
|
|
169
199
|
const allTags = [
|
|
170
200
|
{ name: 'Action', value: 'Paginated-Gateways' },
|
|
@@ -173,9 +203,8 @@ class IOReadable {
|
|
|
173
203
|
{ name: 'Sort-By', value: pageParams?.sortBy },
|
|
174
204
|
{ name: 'Sort-Order', value: pageParams?.sortOrder },
|
|
175
205
|
];
|
|
176
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
177
206
|
return this.process.read({
|
|
178
|
-
tags:
|
|
207
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
179
208
|
});
|
|
180
209
|
}
|
|
181
210
|
async getCurrentEpoch() {
|
|
@@ -202,23 +231,15 @@ class IOReadable {
|
|
|
202
231
|
{
|
|
203
232
|
name: 'Timestamp',
|
|
204
233
|
value: epoch?.timestamp?.toString() ??
|
|
205
|
-
(await this.arweave.
|
|
206
|
-
.getCurrent()
|
|
207
|
-
.then((block) => {
|
|
208
|
-
return { timestamp: block.timestamp * 1000 };
|
|
209
|
-
})
|
|
210
|
-
.catch(() => {
|
|
211
|
-
return { timestamp: Date.now() }; // fallback to current time
|
|
212
|
-
})).timestamp.toString(),
|
|
234
|
+
(await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
|
|
213
235
|
},
|
|
214
236
|
{
|
|
215
237
|
name: 'Epoch-Index',
|
|
216
238
|
value: epoch?.epochIndex?.toString(),
|
|
217
239
|
},
|
|
218
240
|
];
|
|
219
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
220
241
|
return this.process.read({
|
|
221
|
-
tags:
|
|
242
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
222
243
|
});
|
|
223
244
|
}
|
|
224
245
|
async getPrescribedNames(epoch) {
|
|
@@ -227,23 +248,15 @@ class IOReadable {
|
|
|
227
248
|
{
|
|
228
249
|
name: 'Timestamp',
|
|
229
250
|
value: epoch?.timestamp?.toString() ??
|
|
230
|
-
(await this.arweave.
|
|
231
|
-
.getCurrent()
|
|
232
|
-
.then((block) => {
|
|
233
|
-
return { timestamp: block.timestamp * 1000 };
|
|
234
|
-
})
|
|
235
|
-
.catch(() => {
|
|
236
|
-
return { timestamp: Date.now() }; // fallback to current time
|
|
237
|
-
})).timestamp.toString(),
|
|
251
|
+
(await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
|
|
238
252
|
},
|
|
239
253
|
{
|
|
240
254
|
name: 'Epoch-Index',
|
|
241
255
|
value: epoch?.epochIndex?.toString(),
|
|
242
256
|
},
|
|
243
257
|
];
|
|
244
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
245
258
|
return this.process.read({
|
|
246
|
-
tags:
|
|
259
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
247
260
|
});
|
|
248
261
|
}
|
|
249
262
|
async getObservations(epoch) {
|
|
@@ -266,9 +279,8 @@ class IOReadable {
|
|
|
266
279
|
value: epoch?.epochIndex?.toString(),
|
|
267
280
|
},
|
|
268
281
|
];
|
|
269
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
270
282
|
return this.process.read({
|
|
271
|
-
tags:
|
|
283
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
272
284
|
});
|
|
273
285
|
}
|
|
274
286
|
async getDistributions(epoch) {
|
|
@@ -277,23 +289,15 @@ class IOReadable {
|
|
|
277
289
|
{
|
|
278
290
|
name: 'Timestamp',
|
|
279
291
|
value: epoch?.timestamp?.toString() ??
|
|
280
|
-
(await this.arweave.
|
|
281
|
-
.getCurrent()
|
|
282
|
-
.then((block) => {
|
|
283
|
-
return { timestamp: block.timestamp * 1000 };
|
|
284
|
-
})
|
|
285
|
-
.catch(() => {
|
|
286
|
-
return { timestamp: Date.now() }; // fallback to current time
|
|
287
|
-
})).timestamp.toString(),
|
|
292
|
+
(await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
|
|
288
293
|
},
|
|
289
294
|
{
|
|
290
295
|
name: 'Epoch-Index',
|
|
291
296
|
value: epoch?.epochIndex?.toString(),
|
|
292
297
|
},
|
|
293
298
|
];
|
|
294
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
295
299
|
return this.process.read({
|
|
296
|
-
tags:
|
|
300
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
297
301
|
});
|
|
298
302
|
}
|
|
299
303
|
async getTokenCost({ intent, type, years, name, quantity, }) {
|
|
@@ -331,9 +335,8 @@ class IOReadable {
|
|
|
331
335
|
})).timestamp.toString(),
|
|
332
336
|
},
|
|
333
337
|
];
|
|
334
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
335
338
|
return this.process.read({
|
|
336
|
-
tags:
|
|
339
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
337
340
|
});
|
|
338
341
|
}
|
|
339
342
|
async getRegistrationFees() {
|
|
@@ -347,7 +350,7 @@ class IOReadable {
|
|
|
347
350
|
});
|
|
348
351
|
}
|
|
349
352
|
// Auctions
|
|
350
|
-
async
|
|
353
|
+
async getArNSAuctions(params) {
|
|
351
354
|
const allTags = [
|
|
352
355
|
{ name: 'Action', value: 'Auctions' },
|
|
353
356
|
{ name: 'Cursor', value: params?.cursor?.toString() },
|
|
@@ -355,12 +358,11 @@ class IOReadable {
|
|
|
355
358
|
{ name: 'Sort-By', value: params?.sortBy },
|
|
356
359
|
{ name: 'Sort-Order', value: params?.sortOrder },
|
|
357
360
|
];
|
|
358
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
359
361
|
return this.process.read({
|
|
360
|
-
tags:
|
|
362
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
361
363
|
});
|
|
362
364
|
}
|
|
363
|
-
async
|
|
365
|
+
async getArNSAuction({ name, }) {
|
|
364
366
|
const allTags = [
|
|
365
367
|
{ name: 'Action', value: 'Auction-Info' },
|
|
366
368
|
{ name: 'Name', value: name },
|
|
@@ -380,7 +382,7 @@ class IOReadable {
|
|
|
380
382
|
* @param {number} [params.intervalMs=900000] - The interval in milliseconds between price points (default is 15 minutes)
|
|
381
383
|
* @returns {Promise<AoAuctionPriceData>} The auction price data
|
|
382
384
|
*/
|
|
383
|
-
async
|
|
385
|
+
async getArNSAuctionPrices({ name, type, years, timestamp, intervalMs, }) {
|
|
384
386
|
const prunedPriceTags = [
|
|
385
387
|
{ name: 'Action', value: 'Auction-Prices' },
|
|
386
388
|
{ name: 'Name', value: name },
|
|
@@ -451,7 +453,7 @@ class IOWriteable extends IOReadable {
|
|
|
451
453
|
signer: this.signer,
|
|
452
454
|
});
|
|
453
455
|
}
|
|
454
|
-
async joinNetwork({ operatorStake, allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
456
|
+
async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
455
457
|
const { tags = [] } = options || {};
|
|
456
458
|
const allTags = [
|
|
457
459
|
...tags,
|
|
@@ -464,6 +466,10 @@ class IOWriteable extends IOReadable {
|
|
|
464
466
|
name: 'Allow-Delegated-Staking',
|
|
465
467
|
value: allowDelegatedStaking?.toString(),
|
|
466
468
|
},
|
|
469
|
+
{
|
|
470
|
+
name: 'Allowed-Delegates',
|
|
471
|
+
value: allowedDelegates?.join(','),
|
|
472
|
+
},
|
|
467
473
|
{
|
|
468
474
|
name: 'Delegate-Reward-Share-Ratio',
|
|
469
475
|
value: delegateRewardShareRatio?.toString(),
|
|
@@ -505,10 +511,9 @@ class IOWriteable extends IOReadable {
|
|
|
505
511
|
value: observerAddress,
|
|
506
512
|
},
|
|
507
513
|
];
|
|
508
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
509
514
|
return this.process.send({
|
|
510
515
|
signer: this.signer,
|
|
511
|
-
tags:
|
|
516
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
512
517
|
});
|
|
513
518
|
}
|
|
514
519
|
async leaveNetwork(options) {
|
|
@@ -518,7 +523,7 @@ class IOWriteable extends IOReadable {
|
|
|
518
523
|
tags: [...tags, { name: 'Action', value: 'Leave-Network' }],
|
|
519
524
|
});
|
|
520
525
|
}
|
|
521
|
-
async updateGatewaySettings({ allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
526
|
+
async updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
|
|
522
527
|
const { tags = [] } = options || {};
|
|
523
528
|
const allTags = [
|
|
524
529
|
...tags,
|
|
@@ -534,6 +539,10 @@ class IOWriteable extends IOReadable {
|
|
|
534
539
|
name: 'Allow-Delegated-Staking',
|
|
535
540
|
value: allowDelegatedStaking?.toString(),
|
|
536
541
|
},
|
|
542
|
+
{
|
|
543
|
+
name: 'Allowed-Delegates',
|
|
544
|
+
value: allowedDelegates?.join(','),
|
|
545
|
+
},
|
|
537
546
|
{
|
|
538
547
|
name: 'Delegate-Reward-Share-Ratio',
|
|
539
548
|
value: delegateRewardShareRatio?.toString(),
|
|
@@ -544,10 +553,9 @@ class IOWriteable extends IOReadable {
|
|
|
544
553
|
},
|
|
545
554
|
{ name: 'Auto-Stake', value: autoStake?.toString() },
|
|
546
555
|
];
|
|
547
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
548
556
|
return this.process.send({
|
|
549
557
|
signer: this.signer,
|
|
550
|
-
tags:
|
|
558
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
551
559
|
});
|
|
552
560
|
}
|
|
553
561
|
async delegateStake(params, options) {
|
|
@@ -591,10 +599,9 @@ class IOWriteable extends IOReadable {
|
|
|
591
599
|
{ name: 'Vault-Id', value: params.vaultId },
|
|
592
600
|
{ name: 'Address', value: params.gatewayAddress },
|
|
593
601
|
];
|
|
594
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
595
602
|
return this.process.send({
|
|
596
603
|
signer: this.signer,
|
|
597
|
-
tags:
|
|
604
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
598
605
|
});
|
|
599
606
|
}
|
|
600
607
|
async increaseOperatorStake(params, options) {
|
|
@@ -647,10 +654,9 @@ class IOWriteable extends IOReadable {
|
|
|
647
654
|
{ name: 'Process-Id', value: params.processId },
|
|
648
655
|
{ name: 'Purchase-Type', value: params.type || 'lease' },
|
|
649
656
|
];
|
|
650
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
651
657
|
return this.process.send({
|
|
652
658
|
signer: this.signer,
|
|
653
|
-
tags:
|
|
659
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
654
660
|
});
|
|
655
661
|
}
|
|
656
662
|
/**
|
|
@@ -722,10 +728,9 @@ class IOWriteable extends IOReadable {
|
|
|
722
728
|
{ name: 'Vault-Id', value: params.vaultId },
|
|
723
729
|
{ name: 'Address', value: params.gatewayAddress },
|
|
724
730
|
];
|
|
725
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
726
731
|
return this.process.send({
|
|
727
732
|
signer: this.signer,
|
|
728
|
-
tags:
|
|
733
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
729
734
|
});
|
|
730
735
|
}
|
|
731
736
|
async submitAuctionBid(params, options) {
|
|
@@ -739,10 +744,9 @@ class IOWriteable extends IOReadable {
|
|
|
739
744
|
{ name: 'Purchase-Type', value: params.type || 'lease' },
|
|
740
745
|
{ name: 'Years', value: params.years?.toString() ?? undefined },
|
|
741
746
|
];
|
|
742
|
-
const prunedTags = allTags.filter((tag) => tag.value !== undefined);
|
|
743
747
|
return this.process.send({
|
|
744
748
|
signer: this.signer,
|
|
745
|
-
tags:
|
|
749
|
+
tags: (0, arweave_js_1.pruneTags)(allTags),
|
|
746
750
|
});
|
|
747
751
|
}
|
|
748
752
|
}
|
package/lib/cjs/types/index.js
CHANGED
|
@@ -29,6 +29,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
* See the License for the specific language governing permissions and
|
|
30
30
|
* limitations under the License.
|
|
31
31
|
*/
|
|
32
|
+
__exportStar(require("./ant-registry.js"), exports);
|
|
33
|
+
__exportStar(require("./ant.js"), exports);
|
|
32
34
|
__exportStar(require("./common.js"), exports);
|
|
33
|
-
__exportStar(require("./token.js"), exports);
|
|
34
35
|
__exportStar(require("./io.js"), exports);
|
|
36
|
+
__exportStar(require("./token.js"), exports);
|
package/lib/cjs/utils/arweave.js
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isBlockHeight = exports.validateArweaveId = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
3
|
+
exports.getCurrentBlockUnixTimestampMs = exports.pruneTags = exports.isBlockHeight = exports.validateArweaveId = void 0;
|
|
19
4
|
const constants_js_1 = require("../constants.js");
|
|
20
5
|
const validateArweaveId = (id) => {
|
|
21
6
|
return constants_js_1.ARWEAVE_TX_REGEX.test(id);
|
|
@@ -25,3 +10,18 @@ function isBlockHeight(height) {
|
|
|
25
10
|
return height !== undefined && !isNaN(parseInt(height.toString()));
|
|
26
11
|
}
|
|
27
12
|
exports.isBlockHeight = isBlockHeight;
|
|
13
|
+
const pruneTags = (tags) => {
|
|
14
|
+
return tags.filter((tag) => tag.value !== undefined);
|
|
15
|
+
};
|
|
16
|
+
exports.pruneTags = pruneTags;
|
|
17
|
+
const getCurrentBlockUnixTimestampMs = async (arweave) => {
|
|
18
|
+
return await arweave.blocks
|
|
19
|
+
.getCurrent()
|
|
20
|
+
.then((block) => {
|
|
21
|
+
return block.timestamp * 1000;
|
|
22
|
+
})
|
|
23
|
+
.catch(() => {
|
|
24
|
+
return Date.now(); // fallback to current time
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
exports.getCurrentBlockUnixTimestampMs = getCurrentBlockUnixTimestampMs;
|
package/lib/cjs/utils/index.js
CHANGED
|
@@ -29,9 +29,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
* See the License for the specific language governing permissions and
|
|
30
30
|
* limitations under the License.
|
|
31
31
|
*/
|
|
32
|
-
__exportStar(require("./arweave.js"), exports);
|
|
33
|
-
__exportStar(require("./http-client.js"), exports);
|
|
34
32
|
__exportStar(require("./ao.js"), exports);
|
|
33
|
+
__exportStar(require("./arweave.js"), exports);
|
|
34
|
+
__exportStar(require("./base64.js"), exports);
|
|
35
35
|
__exportStar(require("./json.js"), exports);
|
|
36
36
|
__exportStar(require("./processes.js"), exports);
|
|
37
37
|
__exportStar(require("./schema.js"), exports);
|
|
@@ -52,14 +52,16 @@ class ArNSEventEmitter extends eventemitter3_1.EventEmitter {
|
|
|
52
52
|
timeoutMs; // timeout for each request to 3 seconds
|
|
53
53
|
throttle;
|
|
54
54
|
logger;
|
|
55
|
+
strict;
|
|
55
56
|
constructor({ contract = io_js_1.IO.init({
|
|
56
57
|
processId: constants_js_1.IO_TESTNET_PROCESS_ID,
|
|
57
|
-
}), timeoutMs = 60_000, concurrency = 30, logger = logger_js_1.Logger.default, } = {}) {
|
|
58
|
+
}), timeoutMs = 60_000, concurrency = 30, logger = logger_js_1.Logger.default, strict = false, } = {}) {
|
|
58
59
|
super();
|
|
59
60
|
this.contract = contract;
|
|
60
61
|
this.timeoutMs = timeoutMs;
|
|
61
62
|
this.throttle = (0, plimit_lit_1.pLimit)(concurrency);
|
|
62
63
|
this.logger = logger;
|
|
64
|
+
this.strict = strict;
|
|
63
65
|
}
|
|
64
66
|
async fetchProcessesOwnedByWallet({ address, pageSize, antRegistry = ant_registry_js_1.ANTRegistry.init(), }) {
|
|
65
67
|
const uniqueContractProcessIds = {};
|
|
@@ -98,7 +100,7 @@ class ArNSEventEmitter extends eventemitter3_1.EventEmitter {
|
|
|
98
100
|
}
|
|
99
101
|
const ant = ant_js_1.ANT.init({
|
|
100
102
|
processId,
|
|
101
|
-
strict:
|
|
103
|
+
strict: this.strict,
|
|
102
104
|
});
|
|
103
105
|
const state = (await timeout(this.timeoutMs, ant.getState()).catch((e) => {
|
|
104
106
|
this.emit('error', `Error getting state for process ${processId}: ${e}`);
|
package/lib/cjs/version.js
CHANGED
|
@@ -40,19 +40,21 @@ export class AOProcess {
|
|
|
40
40
|
process: this.processId,
|
|
41
41
|
tags,
|
|
42
42
|
});
|
|
43
|
+
this.logger.debug(`Read interaction result`, {
|
|
44
|
+
result,
|
|
45
|
+
});
|
|
43
46
|
if (result.Messages === undefined || result.Messages.length === 0) {
|
|
47
|
+
this.logger.debug(`Process ${this.processId} does not support provided action.`, result, tags);
|
|
44
48
|
throw new Error(`Process ${this.processId} does not support provided action.`);
|
|
45
49
|
}
|
|
46
50
|
const tagsOutput = result.Messages[0].Tags;
|
|
51
|
+
const messageData = result.Messages[0].Data;
|
|
47
52
|
const error = tagsOutput.find((tag) => tag.name === 'Error');
|
|
48
53
|
if (error) {
|
|
49
|
-
throw new Error(`${error.
|
|
54
|
+
throw new Error(`${error.value}${messageData ? `: ${messageData}` : ''}`);
|
|
50
55
|
}
|
|
51
|
-
this.logger.debug(`Read interaction result`, {
|
|
52
|
-
result: result.Messages[0].Data,
|
|
53
|
-
});
|
|
54
56
|
// return empty object if no data is returned
|
|
55
|
-
if (
|
|
57
|
+
if (messageData === undefined) {
|
|
56
58
|
return {};
|
|
57
59
|
}
|
|
58
60
|
const response = safeDecode(result.Messages[0].Data);
|
package/lib/esm/common/http.js
CHANGED