@ar.io/sdk 3.14.0-alpha.1 → 3.14.0-alpha.3

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.
@@ -55,7 +55,7 @@ class AoANTReadable {
55
55
  throw new index_js_2.InvalidContractConfigurationError();
56
56
  }
57
57
  this.processId = this.process.processId;
58
- this.hyperbeamUrl = config.hyperbeamUrl || 'https://permanode.xyz'; // TODO: replace this with hyperbeam.ario.permaweb.services once deployed
58
+ this.hyperbeamUrl = new URL(config.hyperbeamUrl || 'https://hyperbeam.ario.permaweb.services').toString();
59
59
  this.checkHyperBeamPromise = this.checkHyperBeamCompatibility();
60
60
  }
61
61
  /**
@@ -67,7 +67,7 @@ class AoANTReadable {
67
67
  if (this.checkHyperBeamPromise !== undefined) {
68
68
  return this.checkHyperBeamPromise;
69
69
  }
70
- const res = await fetch(`https://permanode.xyz/${this.processId}~process@1.0/now/cache`, {
70
+ const res = await fetch(`${this.hyperbeamUrl.toString()}${this.processId}~process@1.0/now/cache`, {
71
71
  method: 'HEAD',
72
72
  });
73
73
  let isHyperBeamCompatible = false;
@@ -35,7 +35,6 @@ const schema_js_1 = require("./schema.js");
35
35
  async function spawnANT({ signer, module = constants_js_1.AOS_MODULE_ID, ao = (0, aoconnect_1.connect)({
36
36
  MODE: 'legacy',
37
37
  }), scheduler = constants_js_1.DEFAULT_SCHEDULER_ID, state, antRegistryId = constants_js_1.ANT_REGISTRY_ID, logger = index_js_1.Logger.default, authority = constants_js_1.AO_AUTHORITY, }) {
38
- // TODO: use On-Boot data handler for bootstrapping state instead of initialize-state
39
38
  if (state) {
40
39
  (0, schema_js_1.parseSchemaResult)(ant_js_1.SpawnANTStateSchema, state);
41
40
  }
@@ -60,10 +59,12 @@ async function spawnANT({ signer, module = constants_js_1.AOS_MODULE_ID, ao = (0
60
59
  let attempts = 0;
61
60
  while (attempts < 5 && bootRes === undefined) {
62
61
  try {
63
- bootRes = await ao.result({
64
- process: processId,
65
- message: processId,
66
- });
62
+ if (bootRes === undefined) {
63
+ bootRes = await ao.result({
64
+ process: processId,
65
+ message: processId,
66
+ });
67
+ }
67
68
  break;
68
69
  }
69
70
  catch (error) {
@@ -94,6 +95,17 @@ async function spawnANT({ signer, module = constants_js_1.AOS_MODULE_ID, ao = (0
94
95
  });
95
96
  throw new Error(`ANT failed to boot correctly: ${bootError}`);
96
97
  }
98
+ // for hyperbeam caching, due to a SU issue, we need to send a second message to the ANT to cache the state
99
+ // We wait for the first message to be processed before sending the second one to ensure this is the second message
100
+ const processApi = new index_js_1.AOProcess({
101
+ processId,
102
+ ao,
103
+ logger,
104
+ });
105
+ await processApi.send({
106
+ tags: [{ name: 'Action', value: 'State' }],
107
+ signer,
108
+ });
97
109
  logger.debug(`Spawned ANT`, {
98
110
  processId,
99
111
  module,
@@ -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.14.0-alpha.1';
20
+ exports.version = '3.14.0-alpha.3';
@@ -51,7 +51,7 @@ export class AoANTReadable {
51
51
  throw new InvalidContractConfigurationError();
52
52
  }
53
53
  this.processId = this.process.processId;
54
- this.hyperbeamUrl = config.hyperbeamUrl || 'https://permanode.xyz'; // TODO: replace this with hyperbeam.ario.permaweb.services once deployed
54
+ this.hyperbeamUrl = new URL(config.hyperbeamUrl || 'https://hyperbeam.ario.permaweb.services').toString();
55
55
  this.checkHyperBeamPromise = this.checkHyperBeamCompatibility();
56
56
  }
57
57
  /**
@@ -63,7 +63,7 @@ export class AoANTReadable {
63
63
  if (this.checkHyperBeamPromise !== undefined) {
64
64
  return this.checkHyperBeamPromise;
65
65
  }
66
- const res = await fetch(`https://permanode.xyz/${this.processId}~process@1.0/now/cache`, {
66
+ const res = await fetch(`${this.hyperbeamUrl.toString()}${this.processId}~process@1.0/now/cache`, {
67
67
  method: 'HEAD',
68
68
  });
69
69
  let isHyperBeamCompatible = false;
@@ -24,7 +24,6 @@ import { parseSchemaResult } from './schema.js';
24
24
  export async function spawnANT({ signer, module = AOS_MODULE_ID, ao = connect({
25
25
  MODE: 'legacy',
26
26
  }), scheduler = DEFAULT_SCHEDULER_ID, state, antRegistryId = ANT_REGISTRY_ID, logger = Logger.default, authority = AO_AUTHORITY, }) {
27
- // TODO: use On-Boot data handler for bootstrapping state instead of initialize-state
28
27
  if (state) {
29
28
  parseSchemaResult(SpawnANTStateSchema, state);
30
29
  }
@@ -49,10 +48,12 @@ export async function spawnANT({ signer, module = AOS_MODULE_ID, ao = connect({
49
48
  let attempts = 0;
50
49
  while (attempts < 5 && bootRes === undefined) {
51
50
  try {
52
- bootRes = await ao.result({
53
- process: processId,
54
- message: processId,
55
- });
51
+ if (bootRes === undefined) {
52
+ bootRes = await ao.result({
53
+ process: processId,
54
+ message: processId,
55
+ });
56
+ }
56
57
  break;
57
58
  }
58
59
  catch (error) {
@@ -83,6 +84,17 @@ export async function spawnANT({ signer, module = AOS_MODULE_ID, ao = connect({
83
84
  });
84
85
  throw new Error(`ANT failed to boot correctly: ${bootError}`);
85
86
  }
87
+ // for hyperbeam caching, due to a SU issue, we need to send a second message to the ANT to cache the state
88
+ // We wait for the first message to be processed before sending the second one to ensure this is the second message
89
+ const processApi = new AOProcess({
90
+ processId,
91
+ ao,
92
+ logger,
93
+ });
94
+ await processApi.send({
95
+ tags: [{ name: 'Action', value: 'State' }],
96
+ signer,
97
+ });
86
98
  logger.debug(`Spawned ANT`, {
87
99
  processId,
88
100
  module,
@@ -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.14.0-alpha.1';
17
+ export const version = '3.14.0-alpha.3';
@@ -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.13.0";
16
+ export declare const version = "3.14.0-alpha.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.14.0-alpha.1",
3
+ "version": "3.14.0-alpha.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"