@ar.io/sdk 2.4.0-alpha.11 → 2.4.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,6 +44,7 @@ class AOProcess {
44
44
  tags,
45
45
  });
46
46
  if (result.Messages === undefined || result.Messages.length === 0) {
47
+ this.logger.debug(`Process ${this.processId} does not support provided action.`, result, tags);
47
48
  throw new Error(`Process ${this.processId} does not support provided action.`);
48
49
  }
49
50
  const tagsOutput = result.Messages[0].Tags;
@@ -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
  },
@@ -59,14 +59,7 @@ class IOReadable {
59
59
  {
60
60
  name: 'Timestamp',
61
61
  value: params?.timestamp?.toString() ??
62
- (await this.arweave.blocks
63
- .getCurrent()
64
- .then((block) => {
65
- return { timestamp: block.timestamp * 1000 };
66
- })
67
- .catch(() => {
68
- return { timestamp: Date.now() }; // fallback to current time
69
- })).timestamp.toString(),
62
+ (await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
70
63
  },
71
64
  {
72
65
  name: 'Epoch-Index',
@@ -83,14 +76,7 @@ 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',
@@ -224,14 +210,7 @@ class IOReadable {
224
210
  {
225
211
  name: 'Timestamp',
226
212
  value: epoch?.timestamp?.toString() ??
227
- (await this.arweave.blocks
228
- .getCurrent()
229
- .then((block) => {
230
- return { timestamp: block.timestamp * 1000 };
231
- })
232
- .catch(() => {
233
- return { timestamp: Date.now() }; // fallback to current time
234
- })).timestamp.toString(),
213
+ (await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
235
214
  },
236
215
  {
237
216
  name: 'Epoch-Index',
@@ -248,14 +227,7 @@ class IOReadable {
248
227
  {
249
228
  name: 'Timestamp',
250
229
  value: epoch?.timestamp?.toString() ??
251
- (await this.arweave.blocks
252
- .getCurrent()
253
- .then((block) => {
254
- return { timestamp: block.timestamp * 1000 };
255
- })
256
- .catch(() => {
257
- return { timestamp: Date.now() }; // fallback to current time
258
- })).timestamp.toString(),
230
+ (await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
259
231
  },
260
232
  {
261
233
  name: 'Epoch-Index',
@@ -296,14 +268,7 @@ class IOReadable {
296
268
  {
297
269
  name: 'Timestamp',
298
270
  value: epoch?.timestamp?.toString() ??
299
- (await this.arweave.blocks
300
- .getCurrent()
301
- .then((block) => {
302
- return { timestamp: block.timestamp * 1000 };
303
- })
304
- .catch(() => {
305
- return { timestamp: Date.now() }; // fallback to current time
306
- })).timestamp.toString(),
271
+ (await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
307
272
  },
308
273
  {
309
274
  name: 'Epoch-Index',
@@ -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.pruneTags = 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);
@@ -29,3 +14,14 @@ const pruneTags = (tags) => {
29
14
  return tags.filter((tag) => tag.value !== undefined);
30
15
  };
31
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);
@@ -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.11';
20
+ exports.version = '2.4.0-alpha.13';
@@ -41,6 +41,7 @@ export class AOProcess {
41
41
  tags,
42
42
  });
43
43
  if (result.Messages === undefined || result.Messages.length === 0) {
44
+ this.logger.debug(`Process ${this.processId} does not support provided action.`, result, tags);
44
45
  throw new Error(`Process ${this.processId} does not support provided action.`);
45
46
  }
46
47
  const tagsOutput = result.Messages[0].Tags;
@@ -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 {
@@ -1,7 +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 { pruneTags } from '../utils/arweave.js';
4
+ import { getCurrentBlockUnixTimestampMs, pruneTags } from '../utils/arweave.js';
5
5
  import { defaultArweave } from './arweave.js';
6
6
  import { AOProcess } from './contracts/ao-process.js';
7
7
  import { InvalidContractConfigurationError } from './error.js';
@@ -55,14 +55,7 @@ export class IOReadable {
55
55
  {
56
56
  name: 'Timestamp',
57
57
  value: params?.timestamp?.toString() ??
58
- (await this.arweave.blocks
59
- .getCurrent()
60
- .then((block) => {
61
- return { timestamp: block.timestamp * 1000 };
62
- })
63
- .catch(() => {
64
- return { timestamp: Date.now() }; // fallback to current time
65
- })).timestamp.toString(),
58
+ (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
66
59
  },
67
60
  {
68
61
  name: 'Epoch-Index',
@@ -79,14 +72,7 @@ export class IOReadable {
79
72
  {
80
73
  name: 'Timestamp',
81
74
  value: epoch?.timestamp?.toString() ??
82
- (await this.arweave.blocks
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',
@@ -220,14 +206,7 @@ export class IOReadable {
220
206
  {
221
207
  name: 'Timestamp',
222
208
  value: epoch?.timestamp?.toString() ??
223
- (await this.arweave.blocks
224
- .getCurrent()
225
- .then((block) => {
226
- return { timestamp: block.timestamp * 1000 };
227
- })
228
- .catch(() => {
229
- return { timestamp: Date.now() }; // fallback to current time
230
- })).timestamp.toString(),
209
+ (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
231
210
  },
232
211
  {
233
212
  name: 'Epoch-Index',
@@ -244,14 +223,7 @@ export class IOReadable {
244
223
  {
245
224
  name: 'Timestamp',
246
225
  value: epoch?.timestamp?.toString() ??
247
- (await this.arweave.blocks
248
- .getCurrent()
249
- .then((block) => {
250
- return { timestamp: block.timestamp * 1000 };
251
- })
252
- .catch(() => {
253
- return { timestamp: Date.now() }; // fallback to current time
254
- })).timestamp.toString(),
226
+ (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
255
227
  },
256
228
  {
257
229
  name: 'Epoch-Index',
@@ -292,14 +264,7 @@ export class IOReadable {
292
264
  {
293
265
  name: 'Timestamp',
294
266
  value: epoch?.timestamp?.toString() ??
295
- (await this.arweave.blocks
296
- .getCurrent()
297
- .then((block) => {
298
- return { timestamp: block.timestamp * 1000 };
299
- })
300
- .catch(() => {
301
- return { timestamp: Date.now() }; // fallback to current time
302
- })).timestamp.toString(),
267
+ (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
303
268
  },
304
269
  {
305
270
  name: 'Epoch-Index',
@@ -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';
@@ -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);
@@ -23,3 +8,13 @@ export function isBlockHeight(height) {
23
8
  export const pruneTags = (tags) => {
24
9
  return tags.filter((tag) => tag.value !== undefined);
25
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
+ };
@@ -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';
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '2.4.0-alpha.11';
17
+ export const version = '2.4.0-alpha.13';
@@ -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';
@@ -65,7 +65,7 @@ export type AoEpochObservationData = {
65
65
  };
66
66
  export type AoVaultData = {
67
67
  balance: number;
68
- locked: number;
68
+ startTimestamp: number;
69
69
  endTimestamp: Timestamp;
70
70
  };
71
71
  export type AoEpochDistributionRewards = {
@@ -1,4 +1,20 @@
1
- import { BlockHeight } from '../types/common.js';
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
+ import Arweave from 'arweave';
17
+ import { BlockHeight, Timestamp } from '../types/common.js';
2
18
  export declare const validateArweaveId: (id: string) => boolean;
3
19
  export declare function isBlockHeight(height: string | number): height is BlockHeight;
4
20
  export declare const pruneTags: (tags: {
@@ -8,3 +24,4 @@ export declare const pruneTags: (tags: {
8
24
  name: string;
9
25
  value: string;
10
26
  }[];
27
+ export declare const getCurrentBlockUnixTimestampMs: (arweave: Arweave) => Promise<Timestamp>;
@@ -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';
@@ -13,4 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "2.4.0-alpha.10";
16
+ export declare const version = "2.4.0-alpha.12";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "2.4.0-alpha.11",
3
+ "version": "2.4.0-alpha.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"
@@ -109,6 +109,7 @@
109
109
  "husky": "^8.0.3",
110
110
  "lint-staged": "^15.2.2",
111
111
  "markdown-toc-gen": "^1.0.1",
112
+ "nock": "^13.5.5",
112
113
  "prettier": "^3.0.2",
113
114
  "rimraf": "^5.0.1",
114
115
  "semantic-release": "^21.0.7",