@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.
@@ -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.Value}: ${result.Messages[0].Data}`);
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 (result.Messages[0].Data === undefined) {
60
+ if (messageData === undefined) {
59
61
  return {};
60
62
  }
61
63
  const response = (0, json_js_1.safeDecode)(result.Messages[0].Data);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AxiosHTTPService = void 0;
4
- const index_js_1 = require("../utils/index.js");
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, index_js_1.createAxiosInstance)({
12
+ this.axios = (0, http_client_js_1.createAxiosInstance)({
13
13
  axiosConfig: {
14
14
  baseURL: url,
15
15
  },
@@ -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("./arweave.js");
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 = arweave_js_1.defaultArweave) {
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.blocks
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: prunedTags,
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.blocks
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: prunedTags,
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(pageParams) {
98
+ async getArNSRecords(params) {
114
99
  const allTags = [
115
100
  { name: 'Action', value: 'Paginated-Records' },
116
- { name: 'Cursor', value: pageParams?.cursor?.toString() },
117
- { name: 'Limit', value: pageParams?.limit?.toString() },
118
- { name: 'Sort-By', value: pageParams?.sortBy },
119
- { name: 'Sort-Order', value: pageParams?.sortOrder },
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: prunedTags,
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(pageParams) {
131
+ async getBalances(params) {
148
132
  const allTags = [
149
133
  { name: 'Action', value: 'Paginated-Balances' },
150
- { name: 'Cursor', value: pageParams?.cursor?.toString() },
151
- { name: 'Limit', value: pageParams?.limit?.toString() },
152
- { name: 'Sort-By', value: pageParams?.sortBy },
153
- { name: 'Sort-Order', value: pageParams?.sortOrder },
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: prunedTags,
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: prunedTags,
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.blocks
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: prunedTags,
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.blocks
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: prunedTags,
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: prunedTags,
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.blocks
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: prunedTags,
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: prunedTags,
339
+ tags: (0, arweave_js_1.pruneTags)(allTags),
337
340
  });
338
341
  }
339
342
  async getRegistrationFees() {
@@ -355,9 +358,8 @@ 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: prunedTags,
362
+ tags: (0, arweave_js_1.pruneTags)(allTags),
361
363
  });
362
364
  }
363
365
  async getArNSAuction({ name, }) {
@@ -404,6 +406,19 @@ class IOReadable {
404
406
  tags: prunedPriceTags,
405
407
  });
406
408
  }
409
+ async getDelegations(params) {
410
+ const allTags = [
411
+ { name: 'Action', value: 'Paginated-Delegations' },
412
+ { name: 'Cursor', value: params.cursor?.toString() },
413
+ { name: 'Limit', value: params.limit?.toString() },
414
+ { name: 'Sort-By', value: params.sortBy },
415
+ { name: 'Sort-Order', value: params.sortOrder },
416
+ { name: 'Address', value: params.address },
417
+ ];
418
+ return this.process.read({
419
+ tags: (0, arweave_js_1.pruneTags)(allTags),
420
+ });
421
+ }
407
422
  }
408
423
  exports.IOReadable = IOReadable;
409
424
  class IOWriteable extends IOReadable {
@@ -451,7 +466,7 @@ class IOWriteable extends IOReadable {
451
466
  signer: this.signer,
452
467
  });
453
468
  }
454
- async joinNetwork({ operatorStake, allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
469
+ async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
455
470
  const { tags = [] } = options || {};
456
471
  const allTags = [
457
472
  ...tags,
@@ -464,6 +479,10 @@ class IOWriteable extends IOReadable {
464
479
  name: 'Allow-Delegated-Staking',
465
480
  value: allowDelegatedStaking?.toString(),
466
481
  },
482
+ {
483
+ name: 'Allowed-Delegates',
484
+ value: allowedDelegates?.join(','),
485
+ },
467
486
  {
468
487
  name: 'Delegate-Reward-Share-Ratio',
469
488
  value: delegateRewardShareRatio?.toString(),
@@ -505,10 +524,9 @@ class IOWriteable extends IOReadable {
505
524
  value: observerAddress,
506
525
  },
507
526
  ];
508
- const prunedTags = allTags.filter((tag) => tag.value !== undefined);
509
527
  return this.process.send({
510
528
  signer: this.signer,
511
- tags: prunedTags,
529
+ tags: (0, arweave_js_1.pruneTags)(allTags),
512
530
  });
513
531
  }
514
532
  async leaveNetwork(options) {
@@ -518,7 +536,7 @@ class IOWriteable extends IOReadable {
518
536
  tags: [...tags, { name: 'Action', value: 'Leave-Network' }],
519
537
  });
520
538
  }
521
- async updateGatewaySettings({ allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
539
+ async updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
522
540
  const { tags = [] } = options || {};
523
541
  const allTags = [
524
542
  ...tags,
@@ -534,6 +552,10 @@ class IOWriteable extends IOReadable {
534
552
  name: 'Allow-Delegated-Staking',
535
553
  value: allowDelegatedStaking?.toString(),
536
554
  },
555
+ {
556
+ name: 'Allowed-Delegates',
557
+ value: allowedDelegates?.join(','),
558
+ },
537
559
  {
538
560
  name: 'Delegate-Reward-Share-Ratio',
539
561
  value: delegateRewardShareRatio?.toString(),
@@ -544,10 +566,9 @@ class IOWriteable extends IOReadable {
544
566
  },
545
567
  { name: 'Auto-Stake', value: autoStake?.toString() },
546
568
  ];
547
- const prunedTags = allTags.filter((tag) => tag.value !== undefined);
548
569
  return this.process.send({
549
570
  signer: this.signer,
550
- tags: prunedTags,
571
+ tags: (0, arweave_js_1.pruneTags)(allTags),
551
572
  });
552
573
  }
553
574
  async delegateStake(params, options) {
@@ -591,10 +612,9 @@ class IOWriteable extends IOReadable {
591
612
  { name: 'Vault-Id', value: params.vaultId },
592
613
  { name: 'Address', value: params.gatewayAddress },
593
614
  ];
594
- const prunedTags = allTags.filter((tag) => tag.value !== undefined);
595
615
  return this.process.send({
596
616
  signer: this.signer,
597
- tags: prunedTags,
617
+ tags: (0, arweave_js_1.pruneTags)(allTags),
598
618
  });
599
619
  }
600
620
  async increaseOperatorStake(params, options) {
@@ -647,10 +667,9 @@ class IOWriteable extends IOReadable {
647
667
  { name: 'Process-Id', value: params.processId },
648
668
  { name: 'Purchase-Type', value: params.type || 'lease' },
649
669
  ];
650
- const prunedTags = allTags.filter((tag) => tag.value !== undefined);
651
670
  return this.process.send({
652
671
  signer: this.signer,
653
- tags: prunedTags,
672
+ tags: (0, arweave_js_1.pruneTags)(allTags),
654
673
  });
655
674
  }
656
675
  /**
@@ -722,10 +741,9 @@ class IOWriteable extends IOReadable {
722
741
  { name: 'Vault-Id', value: params.vaultId },
723
742
  { name: 'Address', value: params.gatewayAddress },
724
743
  ];
725
- const prunedTags = allTags.filter((tag) => tag.value !== undefined);
726
744
  return this.process.send({
727
745
  signer: this.signer,
728
- tags: prunedTags,
746
+ tags: (0, arweave_js_1.pruneTags)(allTags),
729
747
  });
730
748
  }
731
749
  async submitAuctionBid(params, options) {
@@ -739,10 +757,9 @@ class IOWriteable extends IOReadable {
739
757
  { name: 'Purchase-Type', value: params.type || 'lease' },
740
758
  { name: 'Years', value: params.years?.toString() ?? undefined },
741
759
  ];
742
- const prunedTags = allTags.filter((tag) => tag.value !== undefined);
743
760
  return this.process.send({
744
761
  signer: this.signer,
745
- tags: prunedTags,
762
+ tags: (0, arweave_js_1.pruneTags)(allTags),
746
763
  });
747
764
  }
748
765
  }
@@ -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);
@@ -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;
@@ -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: true,
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}`);
@@ -17,4 +17,4 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.version = void 0;
19
19
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
20
- exports.version = '2.4.0-alpha.9';
20
+ exports.version = '2.5.0-alpha.1';
@@ -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.Value}: ${result.Messages[0].Data}`);
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 (result.Messages[0].Data === undefined) {
57
+ if (messageData === undefined) {
56
58
  return {};
57
59
  }
58
60
  const response = safeDecode(result.Messages[0].Data);
@@ -1,4 +1,4 @@
1
- import { createAxiosInstance } from '../utils/index.js';
1
+ import { createAxiosInstance } from '../utils/http-client.js';
2
2
  import { FailedRequestError, NotFound, UnknownError } from './error.js';
3
3
  import { Logger } from './logger.js';
4
4
  export class AxiosHTTPService {