@ar.io/sdk 3.14.0-alpha.2 → 3.14.0-alpha.4
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.
- package/bundles/web.bundle.min.js +26 -26
- package/lib/cjs/common/ant.js +2 -2
- package/lib/cjs/utils/ao.js +17 -5
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant.js +2 -2
- package/lib/esm/utils/ao.js +17 -5
- package/lib/esm/version.js +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/cjs/common/ant.js
CHANGED
|
@@ -79,7 +79,7 @@ class AoANTReadable {
|
|
|
79
79
|
}
|
|
80
80
|
async getState({ strict } = { strict: this.strict }) {
|
|
81
81
|
if (await this.checkHyperBeamCompatibility()) {
|
|
82
|
-
const res = await fetch(`${this.hyperbeamUrl}
|
|
82
|
+
const res = await fetch(`${this.hyperbeamUrl}${this.processId}~process@1.0/now/cache/serialize~json@1.0`, {
|
|
83
83
|
method: 'GET',
|
|
84
84
|
redirect: 'follow',
|
|
85
85
|
mode: 'cors',
|
|
@@ -265,7 +265,7 @@ class AoANTReadable {
|
|
|
265
265
|
*/
|
|
266
266
|
async getBalances({ strict } = { strict: this.strict }) {
|
|
267
267
|
if (await this.checkHyperBeamCompatibility()) {
|
|
268
|
-
const res = await fetch(`${this.hyperbeamUrl}
|
|
268
|
+
const res = await fetch(`${this.hyperbeamUrl}${this.processId}~process@1.0/now/cache/balances/serialize~json@1.0`, {
|
|
269
269
|
method: 'GET',
|
|
270
270
|
redirect: 'follow',
|
|
271
271
|
mode: 'cors',
|
package/lib/cjs/utils/ao.js
CHANGED
|
@@ -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
|
|
64
|
-
|
|
65
|
-
|
|
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,
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/common/ant.js
CHANGED
|
@@ -75,7 +75,7 @@ export class AoANTReadable {
|
|
|
75
75
|
}
|
|
76
76
|
async getState({ strict } = { strict: this.strict }) {
|
|
77
77
|
if (await this.checkHyperBeamCompatibility()) {
|
|
78
|
-
const res = await fetch(`${this.hyperbeamUrl}
|
|
78
|
+
const res = await fetch(`${this.hyperbeamUrl}${this.processId}~process@1.0/now/cache/serialize~json@1.0`, {
|
|
79
79
|
method: 'GET',
|
|
80
80
|
redirect: 'follow',
|
|
81
81
|
mode: 'cors',
|
|
@@ -261,7 +261,7 @@ export class AoANTReadable {
|
|
|
261
261
|
*/
|
|
262
262
|
async getBalances({ strict } = { strict: this.strict }) {
|
|
263
263
|
if (await this.checkHyperBeamCompatibility()) {
|
|
264
|
-
const res = await fetch(`${this.hyperbeamUrl}
|
|
264
|
+
const res = await fetch(`${this.hyperbeamUrl}${this.processId}~process@1.0/now/cache/balances/serialize~json@1.0`, {
|
|
265
265
|
method: 'GET',
|
|
266
266
|
redirect: 'follow',
|
|
267
267
|
mode: 'cors',
|
package/lib/esm/utils/ao.js
CHANGED
|
@@ -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
|
|
53
|
-
|
|
54
|
-
|
|
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,
|
package/lib/esm/version.js
CHANGED
package/lib/types/version.d.ts
CHANGED