@ar.io/sdk 3.14.0-alpha.9 → 3.14.1-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.
@@ -56,15 +56,25 @@ class AoANTReadable {
56
56
  throw new index_js_2.InvalidContractConfigurationError();
57
57
  }
58
58
  this.processId = this.process.processId;
59
- this.hyperbeamUrl = new URL(config.hyperbeamUrl || 'https://hyperbeam.ario.permaweb.services').toString();
60
- this.checkHyperBeamPromise = this.checkHyperBeamCompatibility();
59
+ // only use hyperbeam if the client has provided a hyperbeamUrl
60
+ // this will avoid overwhelming the HyperBeam node with requests
61
+ // as we shift using HyperBEAM for all ANT operations
62
+ if (config.hyperbeamUrl !== undefined) {
63
+ this.hyperbeamUrl = new URL(config.hyperbeamUrl);
64
+ this.logger.debug(`Using HyperBEAM node for process ${this.processId}`, {
65
+ hyperbeamUrl: this.hyperbeamUrl,
66
+ });
67
+ }
61
68
  }
62
69
  /**
63
70
  * Check if the process is HyperBeam compatible. If so, we'll use the HyperBeam node to fetch the state.
64
71
  *
65
72
  * @returns {Promise<boolean>} True if the process is HyperBeam compatible, false otherwise.
66
73
  */
67
- async checkHyperBeamCompatibility() {
74
+ checkHyperBeamCompatibility() {
75
+ if (this.hyperbeamUrl === undefined) {
76
+ return Promise.resolve(false);
77
+ }
68
78
  if (this.checkHyperBeamPromise !== undefined) {
69
79
  return this.checkHyperBeamPromise;
70
80
  }
@@ -96,9 +106,8 @@ class AoANTReadable {
96
106
  }
97
107
  const unnormalizedState = (await res.json());
98
108
  if (!(0, ant_js_2.isHyperBeamANTState)(unnormalizedState)) {
99
- throw new Error('Invalid HyperBeam ANT state', {
100
- cause: { state: unnormalizedState },
101
- });
109
+ // don't retry if the state is bad, fallback to the CU
110
+ break;
102
111
  }
103
112
  // normalize and return the state
104
113
  return (0, ant_js_2.convertHyperBeamStateToAoANTState)(unnormalizedState);
@@ -77,7 +77,9 @@ class AOProcess {
77
77
  processId: this.processId,
78
78
  ao: JSON.stringify(this.ao),
79
79
  });
80
- throw new Error(`Failed to evaluate a dry-run on process ${this.processId}.`);
80
+ throw new Error(`Failed to evaluate dry-run on process ${this.processId}.`, {
81
+ cause: error,
82
+ });
81
83
  }
82
84
  // exponential backoff
83
85
  await new Promise((resolve) => setTimeout(resolve, 2 ** attempts * 1000));
@@ -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.8';
20
+ exports.version = '3.14.1-alpha.1';
@@ -52,15 +52,25 @@ export class AoANTReadable {
52
52
  throw new InvalidContractConfigurationError();
53
53
  }
54
54
  this.processId = this.process.processId;
55
- this.hyperbeamUrl = new URL(config.hyperbeamUrl || 'https://hyperbeam.ario.permaweb.services').toString();
56
- this.checkHyperBeamPromise = this.checkHyperBeamCompatibility();
55
+ // only use hyperbeam if the client has provided a hyperbeamUrl
56
+ // this will avoid overwhelming the HyperBeam node with requests
57
+ // as we shift using HyperBEAM for all ANT operations
58
+ if (config.hyperbeamUrl !== undefined) {
59
+ this.hyperbeamUrl = new URL(config.hyperbeamUrl);
60
+ this.logger.debug(`Using HyperBEAM node for process ${this.processId}`, {
61
+ hyperbeamUrl: this.hyperbeamUrl,
62
+ });
63
+ }
57
64
  }
58
65
  /**
59
66
  * Check if the process is HyperBeam compatible. If so, we'll use the HyperBeam node to fetch the state.
60
67
  *
61
68
  * @returns {Promise<boolean>} True if the process is HyperBeam compatible, false otherwise.
62
69
  */
63
- async checkHyperBeamCompatibility() {
70
+ checkHyperBeamCompatibility() {
71
+ if (this.hyperbeamUrl === undefined) {
72
+ return Promise.resolve(false);
73
+ }
64
74
  if (this.checkHyperBeamPromise !== undefined) {
65
75
  return this.checkHyperBeamPromise;
66
76
  }
@@ -92,9 +102,8 @@ export class AoANTReadable {
92
102
  }
93
103
  const unnormalizedState = (await res.json());
94
104
  if (!isHyperBeamANTState(unnormalizedState)) {
95
- throw new Error('Invalid HyperBeam ANT state', {
96
- cause: { state: unnormalizedState },
97
- });
105
+ // don't retry if the state is bad, fallback to the CU
106
+ break;
98
107
  }
99
108
  // normalize and return the state
100
109
  return convertHyperBeamStateToAoANTState(unnormalizedState);
@@ -74,7 +74,9 @@ export class AOProcess {
74
74
  processId: this.processId,
75
75
  ao: JSON.stringify(this.ao),
76
76
  });
77
- throw new Error(`Failed to evaluate a dry-run on process ${this.processId}.`);
77
+ throw new Error(`Failed to evaluate dry-run on process ${this.processId}.`, {
78
+ cause: error,
79
+ });
78
80
  }
79
81
  // exponential backoff
80
82
  await new Promise((resolve) => setTimeout(resolve, 2 ** attempts * 1000));
@@ -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.8';
17
+ export const version = '3.14.1-alpha.1';
@@ -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.14.0-alpha.8";
16
+ export declare const version = "3.14.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.14.0-alpha.9",
3
+ "version": "3.14.1-alpha.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"