@ar.io/sdk 3.1.0-alpha.8 → 3.1.0-alpha.9

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.
@@ -1,11 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ARIOWriteable = exports.ARIOReadable = exports.ARIO = 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
+ */
4
19
  const constants_js_1 = require("../constants.js");
5
20
  const io_js_1 = require("../types/io.js");
6
21
  const ao_js_1 = require("../utils/ao.js");
7
22
  const arweave_js_1 = require("../utils/arweave.js");
8
- const arweave_js_2 = require("./arweave.js");
9
23
  const ao_process_js_1 = require("./contracts/ao-process.js");
10
24
  const error_js_1 = require("./error.js");
11
25
  class ARIO {
@@ -23,8 +37,7 @@ class ARIO {
23
37
  exports.ARIO = ARIO;
24
38
  class ARIOReadable {
25
39
  process;
26
- arweave;
27
- constructor(config, arweave = arweave_js_2.defaultArweave) {
40
+ constructor(config) {
28
41
  if (!config) {
29
42
  this.process = new ao_process_js_1.AOProcess({
30
43
  processId: constants_js_1.ARIO_TESTNET_PROCESS_ID,
@@ -41,7 +54,6 @@ class ARIOReadable {
41
54
  else {
42
55
  throw new error_js_1.InvalidContractConfigurationError();
43
56
  }
44
- this.arweave = arweave;
45
57
  }
46
58
  async getInfo() {
47
59
  return this.process.read({
@@ -59,7 +71,7 @@ class ARIOReadable {
59
71
  {
60
72
  name: 'Timestamp',
61
73
  value: params?.timestamp?.toString() ??
62
- (await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
74
+ Date.now().toString(),
63
75
  },
64
76
  {
65
77
  name: 'Epoch-Index',
@@ -76,7 +88,7 @@ class ARIOReadable {
76
88
  {
77
89
  name: 'Timestamp',
78
90
  value: epoch?.timestamp?.toString() ??
79
- (await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
91
+ Date.now().toString(),
80
92
  },
81
93
  {
82
94
  name: 'Epoch-Index',
@@ -188,13 +200,7 @@ class ARIOReadable {
188
200
  }
189
201
  async getCurrentEpoch() {
190
202
  return this.process.read({
191
- tags: [
192
- { name: 'Action', value: 'Epoch' },
193
- {
194
- name: 'Timestamp',
195
- value: (await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
196
- },
197
- ],
203
+ tags: [{ name: 'Action', value: 'Epoch' }],
198
204
  });
199
205
  }
200
206
  async getPrescribedObservers(epoch) {
@@ -203,7 +209,7 @@ class ARIOReadable {
203
209
  {
204
210
  name: 'Timestamp',
205
211
  value: epoch?.timestamp?.toString() ??
206
- (await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
212
+ Date.now().toString(),
207
213
  },
208
214
  {
209
215
  name: 'Epoch-Index',
@@ -220,7 +226,7 @@ class ARIOReadable {
220
226
  {
221
227
  name: 'Timestamp',
222
228
  value: epoch?.timestamp?.toString() ??
223
- (await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
229
+ Date.now().toString(),
224
230
  },
225
231
  {
226
232
  name: 'Epoch-Index',
@@ -237,7 +243,7 @@ class ARIOReadable {
237
243
  {
238
244
  name: 'Timestamp',
239
245
  value: epoch?.timestamp?.toString() ??
240
- (await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
246
+ Date.now().toString(),
241
247
  },
242
248
  {
243
249
  name: 'Epoch-Index',
@@ -254,7 +260,7 @@ class ARIOReadable {
254
260
  {
255
261
  name: 'Timestamp',
256
262
  value: epoch?.timestamp?.toString() ??
257
- (await (0, arweave_js_1.getCurrentBlockUnixTimestampMs)(this.arweave)).toString(),
263
+ Date.now().toString(),
258
264
  },
259
265
  {
260
266
  name: 'Epoch-Index',
@@ -288,17 +294,6 @@ class ARIOReadable {
288
294
  name: 'Purchase-Type',
289
295
  value: type,
290
296
  },
291
- {
292
- name: 'Timestamp',
293
- value: (await this.arweave.blocks
294
- .getCurrent()
295
- .then((block) => {
296
- return { timestamp: block.timestamp * 1000 };
297
- })
298
- .catch(() => {
299
- return { timestamp: Date.now() }; // fallback to current time
300
- })).timestamp.toString(),
301
- },
302
297
  ];
303
298
  return this.process.read({
304
299
  tags: (0, arweave_js_1.pruneTags)(allTags),
@@ -333,17 +328,6 @@ class ARIOReadable {
333
328
  name: 'Fund-From',
334
329
  value: fundFrom,
335
330
  },
336
- {
337
- name: 'Timestamp',
338
- value: (await this.arweave.blocks
339
- .getCurrent()
340
- .then((block) => {
341
- return { timestamp: block.timestamp * 1000 };
342
- })
343
- .catch(() => {
344
- return { timestamp: Date.now() }; // fallback to current time
345
- })).timestamp.toString(),
346
- },
347
331
  ];
348
332
  return this.process.read({
349
333
  tags: (0, arweave_js_1.pruneTags)(allTags),
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.paginationParamsToTags = exports.getCurrentBlockUnixTimestampMs = exports.pruneTags = exports.isBlockHeight = exports.validateArweaveId = void 0;
3
+ exports.paginationParamsToTags = 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
+ */
4
19
  const constants_js_1 = require("../constants.js");
5
20
  const validateArweaveId = (id) => {
6
21
  return constants_js_1.ARWEAVE_TX_REGEX.test(id);
@@ -19,17 +34,6 @@ const pruneTags = (tags) => {
19
34
  return tags.filter((tag) => tag.value !== undefined && tag.value !== '');
20
35
  };
21
36
  exports.pruneTags = pruneTags;
22
- const getCurrentBlockUnixTimestampMs = async (arweave) => {
23
- return await arweave.blocks
24
- .getCurrent()
25
- .then((block) => {
26
- return block.timestamp * 1000;
27
- })
28
- .catch(() => {
29
- return Date.now(); // fallback to current time
30
- });
31
- };
32
- exports.getCurrentBlockUnixTimestampMs = getCurrentBlockUnixTimestampMs;
33
37
  const paginationParamsToTags = (params) => {
34
38
  const tags = [
35
39
  { name: 'Cursor', value: params?.cursor?.toString() },
@@ -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 = '3.1.0-alpha.8';
20
+ exports.version = '3.1.0-alpha.9';
@@ -1,8 +1,22 @@
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
+ */
1
16
  import { ARIO_TESTNET_PROCESS_ID } from '../constants.js';
2
17
  import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/io.js';
3
18
  import { createAoSigner } from '../utils/ao.js';
4
- import { getCurrentBlockUnixTimestampMs, paginationParamsToTags, pruneTags, } from '../utils/arweave.js';
5
- import { defaultArweave } from './arweave.js';
19
+ import { paginationParamsToTags, pruneTags } from '../utils/arweave.js';
6
20
  import { AOProcess } from './contracts/ao-process.js';
7
21
  import { InvalidContractConfigurationError } from './error.js';
8
22
  export class ARIO {
@@ -19,8 +33,7 @@ export class ARIO {
19
33
  }
20
34
  export class ARIOReadable {
21
35
  process;
22
- arweave;
23
- constructor(config, arweave = defaultArweave) {
36
+ constructor(config) {
24
37
  if (!config) {
25
38
  this.process = new AOProcess({
26
39
  processId: ARIO_TESTNET_PROCESS_ID,
@@ -37,7 +50,6 @@ export class ARIOReadable {
37
50
  else {
38
51
  throw new InvalidContractConfigurationError();
39
52
  }
40
- this.arweave = arweave;
41
53
  }
42
54
  async getInfo() {
43
55
  return this.process.read({
@@ -55,7 +67,7 @@ export class ARIOReadable {
55
67
  {
56
68
  name: 'Timestamp',
57
69
  value: params?.timestamp?.toString() ??
58
- (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
70
+ Date.now().toString(),
59
71
  },
60
72
  {
61
73
  name: 'Epoch-Index',
@@ -72,7 +84,7 @@ export class ARIOReadable {
72
84
  {
73
85
  name: 'Timestamp',
74
86
  value: epoch?.timestamp?.toString() ??
75
- (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
87
+ Date.now().toString(),
76
88
  },
77
89
  {
78
90
  name: 'Epoch-Index',
@@ -184,13 +196,7 @@ export class ARIOReadable {
184
196
  }
185
197
  async getCurrentEpoch() {
186
198
  return this.process.read({
187
- tags: [
188
- { name: 'Action', value: 'Epoch' },
189
- {
190
- name: 'Timestamp',
191
- value: (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
192
- },
193
- ],
199
+ tags: [{ name: 'Action', value: 'Epoch' }],
194
200
  });
195
201
  }
196
202
  async getPrescribedObservers(epoch) {
@@ -199,7 +205,7 @@ export class ARIOReadable {
199
205
  {
200
206
  name: 'Timestamp',
201
207
  value: epoch?.timestamp?.toString() ??
202
- (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
208
+ Date.now().toString(),
203
209
  },
204
210
  {
205
211
  name: 'Epoch-Index',
@@ -216,7 +222,7 @@ export class ARIOReadable {
216
222
  {
217
223
  name: 'Timestamp',
218
224
  value: epoch?.timestamp?.toString() ??
219
- (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
225
+ Date.now().toString(),
220
226
  },
221
227
  {
222
228
  name: 'Epoch-Index',
@@ -233,7 +239,7 @@ export class ARIOReadable {
233
239
  {
234
240
  name: 'Timestamp',
235
241
  value: epoch?.timestamp?.toString() ??
236
- (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
242
+ Date.now().toString(),
237
243
  },
238
244
  {
239
245
  name: 'Epoch-Index',
@@ -250,7 +256,7 @@ export class ARIOReadable {
250
256
  {
251
257
  name: 'Timestamp',
252
258
  value: epoch?.timestamp?.toString() ??
253
- (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(),
259
+ Date.now().toString(),
254
260
  },
255
261
  {
256
262
  name: 'Epoch-Index',
@@ -284,17 +290,6 @@ export class ARIOReadable {
284
290
  name: 'Purchase-Type',
285
291
  value: type,
286
292
  },
287
- {
288
- name: 'Timestamp',
289
- value: (await this.arweave.blocks
290
- .getCurrent()
291
- .then((block) => {
292
- return { timestamp: block.timestamp * 1000 };
293
- })
294
- .catch(() => {
295
- return { timestamp: Date.now() }; // fallback to current time
296
- })).timestamp.toString(),
297
- },
298
293
  ];
299
294
  return this.process.read({
300
295
  tags: pruneTags(allTags),
@@ -329,17 +324,6 @@ export class ARIOReadable {
329
324
  name: 'Fund-From',
330
325
  value: fundFrom,
331
326
  },
332
- {
333
- name: 'Timestamp',
334
- value: (await this.arweave.blocks
335
- .getCurrent()
336
- .then((block) => {
337
- return { timestamp: block.timestamp * 1000 };
338
- })
339
- .catch(() => {
340
- return { timestamp: Date.now() }; // fallback to current time
341
- })).timestamp.toString(),
342
- },
343
327
  ];
344
328
  return this.process.read({
345
329
  tags: pruneTags(allTags),
@@ -1,3 +1,18 @@
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
+ */
1
16
  import { ARWEAVE_TX_REGEX } from '../constants.js';
2
17
  export const validateArweaveId = (id) => {
3
18
  return ARWEAVE_TX_REGEX.test(id);
@@ -13,16 +28,6 @@ export function isBlockHeight(height) {
13
28
  export const pruneTags = (tags) => {
14
29
  return tags.filter((tag) => tag.value !== undefined && tag.value !== '');
15
30
  };
16
- export const getCurrentBlockUnixTimestampMs = async (arweave) => {
17
- return await arweave.blocks
18
- .getCurrent()
19
- .then((block) => {
20
- return block.timestamp * 1000;
21
- })
22
- .catch(() => {
23
- return Date.now(); // fallback to current time
24
- });
25
- };
26
31
  export const paginationParamsToTags = (params) => {
27
32
  const tags = [
28
33
  { name: 'Cursor', value: params?.cursor?.toString() },
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '3.1.0-alpha.8';
17
+ export const version = '3.1.0-alpha.9';
@@ -1,19 +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
- import Arweave from 'arweave';
17
1
  import { AoArNSNameDataWithName, AoArNSReservedNameData, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoReturnedName, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, ContractSigner, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
18
2
  import { AoARIORead, AoARIOWrite, AoArNSNameData, AoArNSPurchaseParams, AoArNSReservedNameDataWithName, AoBuyRecordParams, AoDelegation, AoEpochData, AoEpochSettings, AoExtendLeaseParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoPaginatedAddressParams, AoRegistrationFees, AoVaultData, AoWalletVault, CostDetailsResult, DemandFactorSettings, EpochInput } from '../types/io.js';
19
3
  import { mARIOToken } from '../types/token.js';
@@ -39,8 +23,7 @@ export declare class ARIO {
39
23
  }
40
24
  export declare class ARIOReadable implements AoARIORead {
41
25
  protected process: AOProcess;
42
- private arweave;
43
- constructor(config?: ProcessConfiguration, arweave?: Arweave);
26
+ constructor(config?: ProcessConfiguration);
44
27
  getInfo(): Promise<{
45
28
  Name: string;
46
29
  Ticker: string;
@@ -1,20 +1,4 @@
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';
1
+ import { BlockHeight } from '../types/common.js';
18
2
  import { PaginationParams } from '../types/io.js';
19
3
  export declare const validateArweaveId: (id: string) => boolean;
20
4
  export declare function isBlockHeight(height: string | number): height is BlockHeight;
@@ -30,7 +14,6 @@ export declare const pruneTags: (tags: {
30
14
  name: string;
31
15
  value: string;
32
16
  }[];
33
- export declare const getCurrentBlockUnixTimestampMs: (arweave: Arweave) => Promise<Timestamp>;
34
17
  export declare const paginationParamsToTags: <T>(params?: PaginationParams<T>) => {
35
18
  name: string;
36
19
  value: string;
@@ -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 = "3.1.0-alpha.7";
16
+ export declare const version = "3.1.0-alpha.8";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.1.0-alpha.8",
3
+ "version": "3.1.0-alpha.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"