@lerna-labs/hydra-sdk 1.0.0-beta.18 → 1.0.0-beta.19
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.
|
@@ -80,7 +80,9 @@ export class HydraWebSocket extends EventEmitter {
|
|
|
80
80
|
async waitForGreetings(timeoutMs = 30_000) {
|
|
81
81
|
if (this._connectionState === 'CONNECTED')
|
|
82
82
|
return true;
|
|
83
|
-
|
|
83
|
+
// Register the listener BEFORE connecting so the Greetings message
|
|
84
|
+
// (which the Hydra node sends immediately after the socket opens)
|
|
85
|
+
// cannot arrive before we're listening for it.
|
|
84
86
|
return new Promise((resolve, reject) => {
|
|
85
87
|
const timer = setTimeout(() => {
|
|
86
88
|
this.removeListener('message', onMsg);
|
|
@@ -96,6 +98,11 @@ export class HydraWebSocket extends EventEmitter {
|
|
|
96
98
|
}
|
|
97
99
|
};
|
|
98
100
|
this.on('message', onMsg);
|
|
101
|
+
this.connect().catch((err) => {
|
|
102
|
+
clearTimeout(timer);
|
|
103
|
+
this.removeListener('message', onMsg);
|
|
104
|
+
reject(err);
|
|
105
|
+
});
|
|
99
106
|
});
|
|
100
107
|
}
|
|
101
108
|
/** Close the WebSocket. */
|
package/dist/hydra/utxo.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
1
|
import { requireEnv } from '../config.js';
|
|
3
2
|
/**
|
|
4
3
|
* Fetch the full UTxO set from the Hydra head snapshot.
|
|
@@ -11,8 +10,11 @@ export async function getUtxoSet() {
|
|
|
11
10
|
const baseUrl = requireEnv('HYDRA_API_URL');
|
|
12
11
|
const url = `${baseUrl}/snapshot/utxo`;
|
|
13
12
|
try {
|
|
14
|
-
const response = await
|
|
15
|
-
|
|
13
|
+
const response = await fetch(url);
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
throw new Error(`HTTP ${response.status} fetching ${url}`);
|
|
16
|
+
}
|
|
17
|
+
const data = await response.json();
|
|
16
18
|
const UtxoSet = [];
|
|
17
19
|
for (const [txKey, utxo] of Object.entries(data)) {
|
|
18
20
|
const [tx_hash, index_str] = txKey.split('#');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lerna-labs/hydra-sdk",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.19",
|
|
4
4
|
"description": "TypeScript SDK for managing Cardano Hydra Heads — lifecycle, UTxO queries, wallet management, transaction submission, and signature verification",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cardano",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"@emurgo/cardano-serialization-lib-nodejs": "^15.0.3",
|
|
44
44
|
"@meshsdk/core": "1.9.0-beta.99",
|
|
45
45
|
"@meshsdk/core-cst": "1.9.0-beta.99",
|
|
46
|
-
"axios": "^1.11.0",
|
|
47
46
|
"ws": "^8.18.3"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|