@lerna-labs/hydra-sdk 1.0.0-beta.28 → 1.0.0-beta.29

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.
@@ -30,6 +30,7 @@ export declare class HydraMonitor extends EventEmitter {
30
30
  readonly ws: HydraWebSocket;
31
31
  private _headStatus;
32
32
  private _previousStatus;
33
+ private _headId;
33
34
  private _events;
34
35
  private _stopped;
35
36
  private _reconnecting;
@@ -54,7 +55,14 @@ export declare class HydraMonitor extends EventEmitter {
54
55
  /** The full Greetings message from the most recent connection. */
55
56
  get greetings(): GreetingsMessage | null;
56
57
  /**
57
- * Summary of Hydra head info extracted from the last Greetings.
58
+ * Summary of Hydra head info derived from live state plus the last Greetings.
59
+ *
60
+ * `headStatus` and `headId` reflect the current state tracked from transition
61
+ * messages (`HeadIsInitializing`, `HeadIsOpen`, etc.), not the snapshot taken
62
+ * at connection time. The remaining fields (node version, participants,
63
+ * contestation period, network info) come from the cached Greetings since
64
+ * they are static for the life of the head.
65
+ *
58
66
  * Excludes the full UTxO snapshot to keep payloads small.
59
67
  * Returns `null` if no Greetings has been received yet.
60
68
  */
@@ -37,6 +37,7 @@ export class HydraMonitor extends EventEmitter {
37
37
  ws;
38
38
  _headStatus = 'IDLE';
39
39
  _previousStatus = 'IDLE';
40
+ _headId = null;
40
41
  _events = [];
41
42
  _stopped = true;
42
43
  _reconnecting = false;
@@ -93,7 +94,14 @@ export class HydraMonitor extends EventEmitter {
93
94
  return this.ws.lastGreetings;
94
95
  }
95
96
  /**
96
- * Summary of Hydra head info extracted from the last Greetings.
97
+ * Summary of Hydra head info derived from live state plus the last Greetings.
98
+ *
99
+ * `headStatus` and `headId` reflect the current state tracked from transition
100
+ * messages (`HeadIsInitializing`, `HeadIsOpen`, etc.), not the snapshot taken
101
+ * at connection time. The remaining fields (node version, participants,
102
+ * contestation period, network info) come from the cached Greetings since
103
+ * they are static for the life of the head.
104
+ *
97
105
  * Excludes the full UTxO snapshot to keep payloads small.
98
106
  * Returns `null` if no Greetings has been received yet.
99
107
  */
@@ -104,8 +112,8 @@ export class HydraMonitor extends EventEmitter {
104
112
  const peers = g.env?.configuredPeers;
105
113
  const peerCount = peers ? peers.split(',').filter(Boolean).length : 0;
106
114
  return {
107
- headStatus: g.headStatus,
108
- headId: g.hydraHeadId ?? null,
115
+ headStatus: HYDRA_TO_HEAD_STATUS[this._headStatus],
116
+ headId: this._headId,
109
117
  nodeVersion: g.hydraNodeVersion ?? null,
110
118
  me: g.me.vkey,
111
119
  contestationPeriod: g.env?.contestationPeriod ?? null,
@@ -178,14 +186,25 @@ export class HydraMonitor extends EventEmitter {
178
186
  const mapped = HEAD_STATUS_TO_HYDRA[msg.headStatus];
179
187
  if (mapped)
180
188
  this.updateStatus(mapped);
189
+ const greetingHeadId = msg.hydraHeadId;
190
+ if (greetingHeadId)
191
+ this._headId = greetingHeadId;
181
192
  }
182
193
  else if (msg.tag === 'HeadIsAborted') {
183
194
  this.updateStatus('IDLE');
195
+ this._headId = null;
184
196
  }
185
197
  else {
186
198
  const mapped = TAG_TO_HYDRA[msg.tag];
187
199
  if (mapped)
188
200
  this.updateStatus(mapped);
201
+ // Track headId from transition messages (Greetings may not include
202
+ // it for a fresh node — HeadIsInitializing is the first place it
203
+ // reliably appears). Skipped for HeadIsAborted, which clears it above.
204
+ const msgHeadId = msg.headId;
205
+ if (typeof msgHeadId === 'string' && msgHeadId) {
206
+ this._headId = msgHeadId;
207
+ }
189
208
  }
190
209
  // Error routing
191
210
  if (msg.tag === 'PostTxOnChainFailed' || msg.tag === 'TxInvalid') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lerna-labs/hydra-sdk",
3
- "version": "1.0.0-beta.28",
3
+ "version": "1.0.0-beta.29",
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",