@valve-tech/chain-source 0.7.0 → 0.9.2

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/CHANGELOG.md CHANGED
@@ -6,6 +6,41 @@ this file.
6
6
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
7
7
  and this project adheres to [Semantic Versioning](https://semver.org/).
8
8
 
9
+ ## [0.9.2] — 2026-05-08
10
+
11
+ Synchronized release — no changes to this package. Companion fix
12
+ to v0.9.1: the root `build` script now uses `--topological-dev`
13
+ so workspace `devDependencies` (added to `tx-flight-react` in
14
+ v0.9.1) actually drive build ordering. v0.9.2 is the first version
15
+ of the v0.9.x line to land on npm for this package.
16
+
17
+ ## [0.9.1] — 2026-05-08
18
+
19
+ *Not published — the Release workflow's Build step failed for the
20
+ same reason as v0.9.0. Superseded by v0.9.2.* Synchronized release;
21
+ no changes to this package itself.
22
+
23
+ ## [0.9.0] — 2026-05-08
24
+
25
+ Synchronized release — no changes to this package. Bumped in lockstep
26
+ with the rest of the toolkit, alongside the new
27
+ `@valve-tech/tx-flight-react` package. *Not published — the Release
28
+ workflow's build step failed before publish; superseded by v0.9.1.*
29
+
30
+ ## [0.8.1] — 2026-05-07
31
+
32
+ Synchronized release — no changes to this package. Bumped in lockstep with the rest of the toolkit.
33
+
34
+ ## [0.8.0] — 2026-05-06
35
+
36
+ ### Added
37
+ - WS subscribe path for `subscribeBlocks`. When `capabilities.newHeads === 'subscription'`, the source opens `eth_subscribe('newHeads')` lazily on `start()` and pipes head events through the existing fetchBlock + dedup-by-hash machinery. Push and poll coexist safely.
38
+ - WS subscribe path for `subscribeMempool` with hash-only normalization. Push delivers a hash; the source fetches the full tx via `getTransaction` and emits a single-tx `NormalizedMempool` snapshot so consumers see one shape regardless of source.
39
+ - Live-probe at capability-detection time. `probeCapabilities` now performs one opportunistic `eth_subscribe('newHeads')` round-trip to confirm the transport actually supports subscribe, returning `'subscription' | 'poll-only' | 'unavailable'` truthfully. Failure downgrades to `'poll-only'` and surfaces via `onError`.
40
+
41
+ ### Changed
42
+ - Internal: extracted shared `wsTransport` cast; consolidated WS-subscribe error method names to `'eth_subscribe.<channel>'` for both setup-failure and stream-error paths.
43
+
9
44
  ## [0.7.0] — 2026-05-06
10
45
 
11
46
  ### Notes
@@ -12,19 +12,14 @@
12
12
  * (`subscription` / `poll-only` / `available` / `gated` /
13
13
  * `unavailable`) lives in the per-method spec table (§7).
14
14
  *
15
- * **What this probe deliberately does NOT do:** issue a real
16
- * `eth_subscribe` against the upstream. The viem transport's
17
- * `subscribe` API surface varies across versions and engaging it just
18
- * to immediately tear it down is wasteful + can leak handles on
19
- * misbehaving providers. We detect WS-subscribe capability
20
- * structurally (`typeof transport.subscribe === 'function'`) and let
21
- * the actual subscribe attempt happen lazily when a consumer calls
22
- * `source.subscribeBlocks` / `subscribeMempool`. If the runtime
23
- * subscribe fails, the source emits a `signal-degraded`-shaped fact
24
- * (or downstream consumers do — chain-source itself doesn't author
25
- * editorial events). This is the v0.3.x posture; future revisions
26
- * may upgrade to live-probing if a provider is found that lies
27
- * structurally.
15
+ * **WS subscribe live-probe (v0.8.0+):** at probe time we issue one
16
+ * opportunistic `eth_subscribe('newHeads')` round-trip and immediately
17
+ * unsubscribe. This upgrades the v0.3.x structural check
18
+ * (`typeof transport.subscribe === 'function'`) to a truthful answer
19
+ * some transports wrap but can't actually open a subscription, and the
20
+ * downstream wiring added in v0.8.0 needs the probe's answer to be
21
+ * accurate before attempting to wire a live subscription. A failure
22
+ * downgrades to `'poll-only'` and surfaces via `onError`.
28
23
  */
29
24
  import type { PublicClient } from 'viem';
30
25
  import type { Capabilities } from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAGxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,UAAU,YAAY;IACpB,kEAAkE;IAClE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CACjD;AAsBD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,YAAY,EACpB,UAAS,YAAiB,KACzB,OAAO,CAAC,YAAY,CAoDtB,CAAA"}
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAGxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,UAAU,YAAY;IACpB,kEAAkE;IAClE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CACjD;AA6CD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,YAAY,EACpB,UAAS,YAAiB,KACzB,OAAO,CAAC,YAAY,CAoDtB,CAAA"}
@@ -12,37 +12,55 @@
12
12
  * (`subscription` / `poll-only` / `available` / `gated` /
13
13
  * `unavailable`) lives in the per-method spec table (§7).
14
14
  *
15
- * **What this probe deliberately does NOT do:** issue a real
16
- * `eth_subscribe` against the upstream. The viem transport's
17
- * `subscribe` API surface varies across versions and engaging it just
18
- * to immediately tear it down is wasteful + can leak handles on
19
- * misbehaving providers. We detect WS-subscribe capability
20
- * structurally (`typeof transport.subscribe === 'function'`) and let
21
- * the actual subscribe attempt happen lazily when a consumer calls
22
- * `source.subscribeBlocks` / `subscribeMempool`. If the runtime
23
- * subscribe fails, the source emits a `signal-degraded`-shaped fact
24
- * (or downstream consumers do — chain-source itself doesn't author
25
- * editorial events). This is the v0.3.x posture; future revisions
26
- * may upgrade to live-probing if a provider is found that lies
27
- * structurally.
15
+ * **WS subscribe live-probe (v0.8.0+):** at probe time we issue one
16
+ * opportunistic `eth_subscribe('newHeads')` round-trip and immediately
17
+ * unsubscribe. This upgrades the v0.3.x structural check
18
+ * (`typeof transport.subscribe === 'function'`) to a truthful answer
19
+ * some transports wrap but can't actually open a subscription, and the
20
+ * downstream wiring added in v0.8.0 needs the probe's answer to be
21
+ * accurate before attempting to wire a live subscription. A failure
22
+ * downgrades to `'poll-only'` and surfaces via `onError`.
28
23
  */
29
24
  import { safeRequest, zeroHash } from './transport.js';
30
25
  /**
31
- * Inspect the client's transport surface to decide whether push
32
- * subscriptions are possible. The capability is structural the
33
- * subscribe attempt itself is deferred to the actual subscribeBlocks /
34
- * subscribeMempool call so we don't pay an early eth_subscribe just
35
- * to learn the answer.
26
+ * Inspect the client's transport surface and perform one opportunistic
27
+ * `newHeads` round-trip to confirm the transport can actually open a
28
+ * subscription. A structural check alone (`typeof subscribe === 'function'`)
29
+ * is insufficient some transports wrap-but-can't-subscribe.
36
30
  *
37
- * Returns `'subscription'` when the transport exposes a `subscribe`
38
- * function (canonical viem WS shape), `'unavailable'` otherwise.
39
- * `'poll-only'` is reserved for the future live-probe variant where
40
- * we can distinguish "transport supports subscribe but upstream
41
- * rejected this method" from "transport doesn't subscribe at all."
31
+ * - `'subscription'` transport exposes `subscribe` **and** the probe call
32
+ * succeeded; push-based event flow is available.
33
+ * - `'poll-only'` transport exposes `subscribe` but the probe threw; the
34
+ * upstream rejected `eth_subscribe`, so we fall back to polling.
35
+ * - `'unavailable'` transport has no `subscribe` function at all; HTTP-only.
42
36
  */
43
- const probeSubscribeShape = (client) => {
37
+ const probeSubscribeShape = async (client, onError) => {
44
38
  const transport = client.transport;
45
- return typeof transport.subscribe === 'function' ? 'subscription' : 'unavailable';
39
+ if (typeof transport.subscribe !== 'function')
40
+ return 'unavailable';
41
+ // Live probe: open and immediately close a newHeads subscription. Cheap;
42
+ // the upstream sees one eth_subscribe + one eth_unsubscribe and we get a
43
+ // truthful answer to "does this transport.subscribe actually work?"
44
+ try {
45
+ const sub = await transport.subscribe({
46
+ params: ['newHeads'],
47
+ // No-op stubs: the transport.subscribe contract requires both
48
+ // callbacks. The probe unsubscribes immediately, so on most
49
+ // upstreams these never fire — but some viem transports invoke
50
+ // onData / onError synchronously during subscribe (queued head
51
+ // event or setup error). Both paths must be a safe no-op so the
52
+ // probe's only signal is the resolved/rejected outer promise.
53
+ onData: () => { },
54
+ onError: () => { },
55
+ });
56
+ sub.unsubscribe();
57
+ return 'subscription';
58
+ }
59
+ catch (err) {
60
+ if (onError)
61
+ onError('eth_subscribe', err);
62
+ return 'poll-only';
63
+ }
46
64
  };
47
65
  /**
48
66
  * Probe the upstream client's per-method capability. The result is a
@@ -50,7 +68,7 @@ const probeSubscribeShape = (client) => {
50
68
  * `source.capabilities()`.
51
69
  */
52
70
  export const probeCapabilities = async (client, options = {}) => {
53
- const subscribeShape = probeSubscribeShape(client);
71
+ const subscribeShape = await probeSubscribeShape(client, options.onError);
54
72
  // 1. txpool_content — distinguishes 'available' / 'gated'. Many
55
73
  // public RPCs return 405 / method-not-found for this method.
56
74
  const txpoolResult = await safeRequest(client, 'txpool_content', [], options.onError ? (err) => options.onError('txpool_content', err) : undefined);
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAQtD;;;;;;;;;;;;GAYG;AACH,MAAM,mBAAmB,GAAG,CAC1B,MAAoB,EACY,EAAE;IAClC,MAAM,SAAS,GAAG,MAAM,CAAC,SAAoC,CAAA;IAC7D,OAAO,OAAO,SAAS,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,aAAa,CAAA;AACnF,CAAC,CAA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AAA"}
package/dist/source.d.ts CHANGED
@@ -27,12 +27,23 @@
27
27
  * Callers that need a guaranteed-fresh result can `await
28
28
  * source.ready()` before reading `capabilities()`.
29
29
  *
30
- * Push subscriptions (eth_subscribe) are not yet wired in v0.3.x —
31
- * the `Capabilities.newHeads` / `newPendingTransactions` fields
32
- * disclose what *would* be available structurally, but the source
33
- * always falls back to its interval poll cycle in this revision.
34
- * Future revisions add WS push without changing the consumer-facing
35
- * `subscribeBlocks` / `subscribeMempool` shape.
30
+ * Push subscriptions (eth_subscribe):
31
+ *
32
+ * - As of v0.8.0, when capabilities.newHeads === 'subscription' (probed at
33
+ * construction via probeCapabilities), the source opens a live
34
+ * eth_subscribe('newHeads') lazily on the first start(). Head events
35
+ * are piped through the existing fetchBlock + dedup-by-hash machinery
36
+ * so push and poll coexist safely. On subscribe failure, the cached
37
+ * capability downgrades to 'poll-only', surfaces via onError, and the
38
+ * poll cycle continues unchanged.
39
+ * - When capabilities.newPendingTransactions === 'subscription', the source
40
+ * opens a live eth_subscribe('newPendingTransactions') lazily on the first
41
+ * start(). Push notifications carry a hash only — the source fetches the
42
+ * full tx via eth_getTransactionByHash and emits a single-tx
43
+ * NormalizedMempool snapshot. On subscribe failure, the cached capability
44
+ * downgrades to poll-only (or unavailable when txpool_content is also
45
+ * gated). Push and poll coexist — mempool snapshots are intentionally
46
+ * not deduped (txs come and go between blocks even on a static head).
36
47
  */
37
48
  import type { PublicClient } from 'viem';
38
49
  import type { BlockResult, Capabilities, FeeHistoryResult, NormalizedMempool, PollOptions, RawTx, TransactionReceipt } from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAaxC,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,iBAA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IACnE,eAAe,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,KAAK,MAAM,IAAI,CAAA;IACjE,oEAAoE;IACpE,gBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,KAAK,MAAM,IAAI,CAAA;IAC3E,2DAA2D;IAC3D,QAAQ,EAAE,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACjE,8BAA8B;IAC9B,aAAa,EAAE,CACb,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EAAE,KAClB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAA;IACrC;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;IAC3D,qCAAqC;IACrC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAA;IAChE,4EAA4E;IAC5E,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;IACvD,yCAAyC;IACzC,YAAY,EAAE,MAAM,YAAY,CAAA;CACjC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,wBAAwB,KAChC,WAgUF,CAAA"}
package/dist/source.js CHANGED
@@ -27,12 +27,23 @@
27
27
  * Callers that need a guaranteed-fresh result can `await
28
28
  * source.ready()` before reading `capabilities()`.
29
29
  *
30
- * Push subscriptions (eth_subscribe) are not yet wired in v0.3.x —
31
- * the `Capabilities.newHeads` / `newPendingTransactions` fields
32
- * disclose what *would* be available structurally, but the source
33
- * always falls back to its interval poll cycle in this revision.
34
- * Future revisions add WS push without changing the consumer-facing
35
- * `subscribeBlocks` / `subscribeMempool` shape.
30
+ * Push subscriptions (eth_subscribe):
31
+ *
32
+ * - As of v0.8.0, when capabilities.newHeads === 'subscription' (probed at
33
+ * construction via probeCapabilities), the source opens a live
34
+ * eth_subscribe('newHeads') lazily on the first start(). Head events
35
+ * are piped through the existing fetchBlock + dedup-by-hash machinery
36
+ * so push and poll coexist safely. On subscribe failure, the cached
37
+ * capability downgrades to 'poll-only', surfaces via onError, and the
38
+ * poll cycle continues unchanged.
39
+ * - When capabilities.newPendingTransactions === 'subscription', the source
40
+ * opens a live eth_subscribe('newPendingTransactions') lazily on the first
41
+ * start(). Push notifications carry a hash only — the source fetches the
42
+ * full tx via eth_getTransactionByHash and emits a single-tx
43
+ * NormalizedMempool snapshot. On subscribe failure, the cached capability
44
+ * downgrades to poll-only (or unavailable when txpool_content is also
45
+ * gated). Push and poll coexist — mempool snapshots are intentionally
46
+ * not deduped (txs come and go between blocks even on a static head).
36
47
  */
37
48
  import { probeCapabilities } from './capabilities.js';
38
49
  import { normalizeMempool } from './mempool.js';
@@ -80,6 +91,15 @@ export const createChainSource = (options) => {
80
91
  let timer = null;
81
92
  let started = false;
82
93
  let cachedCapabilities = PROBING_DEFAULT;
94
+ /**
95
+ * Narrow the viem transport to its WebSocket-specific `subscribe` shape once.
96
+ * viem's `Transport` type does not model this method; we structurally narrow
97
+ * through `unknown` here and reuse the result in both `tryOpen*Subscription`
98
+ * functions rather than redeclaring the cast in each.
99
+ */
100
+ const wsTransport = options.client.transport;
101
+ let blockSubscriptionHandle = null;
102
+ let mempoolSubscriptionHandle = null;
83
103
  // Dedup key for the block stream — by hash, not number, so that a
84
104
  // same-height reorg (different hash, same number) still surfaces as
85
105
  // a fresh observation. Reset on stop() so a paused-then-resumed
@@ -96,6 +116,135 @@ export const createChainSource = (options) => {
96
116
  // re-fetches even at the same height.
97
117
  let lastSeenBlockNumber;
98
118
  const errSink = (method) => options.onError ? (err) => options.onError(method, err) : undefined;
119
+ /**
120
+ * Fetch the full block at 'latest' and pipe it through the existing
121
+ * dedup machinery. Called from the WS `newHeads` subscription's
122
+ * `onData` handler whenever a head notification arrives.
123
+ */
124
+ const handleHeadNotification = async () => {
125
+ const block = await fetchBlock(options.client, 'latest', errSink('eth_getBlockByNumber'));
126
+ if (!block)
127
+ return;
128
+ if (block.hash !== lastEmittedBlockHash) {
129
+ lastEmittedBlockHash = block.hash;
130
+ try {
131
+ lastSeenBlockNumber = BigInt(block.number);
132
+ }
133
+ catch {
134
+ // Unparseable block number — leave gate state untouched so the
135
+ // next poll tick re-fetches rather than skipping on garbage state.
136
+ }
137
+ blockSubs.emit(block);
138
+ }
139
+ };
140
+ /**
141
+ * Open one `eth_subscribe('newHeads')` lazily — called once the probe
142
+ * has resolved and confirmed `newHeads === 'subscription'`. Head
143
+ * notifications are piped through `handleHeadNotification` + the
144
+ * existing dedup machinery so push and poll coexist safely. Failure
145
+ * downgrades the cached capability to `'poll-only'` and surfaces via
146
+ * `onError`; the existing poll cycle continues unchanged.
147
+ *
148
+ * No idempotency flag is needed here: start() is already gated by the
149
+ * outer `started` flag (preventing double-subscription within one start
150
+ * cycle), and stop()/start() resume legitimately requires this function
151
+ * to run again — stop() sets blockSubscriptionHandle = null so the next
152
+ * call opens a fresh subscription cleanly.
153
+ */
154
+ const tryOpenBlockSubscription = async () => {
155
+ if (cachedCapabilities.newHeads !== 'subscription')
156
+ return;
157
+ try {
158
+ blockSubscriptionHandle = await wsTransport.subscribe({
159
+ params: ['newHeads'],
160
+ // Head notifications: fetch the full block at the tip and emit
161
+ // through the existing dedup machinery. Hash dedup in blockSubs
162
+ // already handles WS-vs-poll race and same-height reorgs.
163
+ onData: () => void handleHeadNotification(),
164
+ onError: (err) => options.onError?.('eth_subscribe.newHeads', err),
165
+ });
166
+ }
167
+ catch (err) {
168
+ options.onError?.('eth_subscribe.newHeads', err);
169
+ cachedCapabilities = { ...cachedCapabilities, newHeads: 'poll-only' };
170
+ }
171
+ };
172
+ /**
173
+ * Fetch the full transaction by hash and emit a single-tx
174
+ * NormalizedMempool snapshot into mempoolSubs. Called from the WS
175
+ * `newPendingTransactions` subscription's `onData` handler for each
176
+ * hash-only push notification.
177
+ *
178
+ * Hash-only normalization: the WS payload carries only a hash; this
179
+ * function fetches the full tx and wraps it in the canonical
180
+ * NormalizedMempool shape so consumers see one consistent type
181
+ * regardless of whether the data arrived via push or poll.
182
+ */
183
+ const handleMempoolNotification = async (hash) => {
184
+ const tx = await fetchTransaction(options.client, hash, errSink('eth_getTransactionByHash'));
185
+ if (!tx?.from || !tx.nonce)
186
+ return;
187
+ const sender = tx.from.toLowerCase();
188
+ let nonceKey;
189
+ try {
190
+ nonceKey = BigInt(tx.nonce).toString(10);
191
+ }
192
+ catch {
193
+ // Unparseable nonce — use the raw value rather than dropping the
194
+ // tx entirely; downstream lookup helpers handle unexpected keys.
195
+ nonceKey = tx.nonce;
196
+ }
197
+ const snapshot = {
198
+ pending: { [sender]: { [nonceKey]: tx } },
199
+ queued: {},
200
+ };
201
+ mempoolSubs.emit(snapshot);
202
+ };
203
+ /**
204
+ * Open one `eth_subscribe('newPendingTransactions')` lazily — called
205
+ * once the probe has resolved and confirmed
206
+ * `newPendingTransactions === 'subscription'`. Push notifications carry
207
+ * a hash only; each hash is piped through `handleMempoolNotification`
208
+ * which fetches the full tx and emits a single-tx NormalizedMempool
209
+ * snapshot. Push and poll coexist — mempool snapshots are
210
+ * intentionally not deduped. Failure downgrades the cached capability
211
+ * and surfaces via `onError`; the poll cycle continues unchanged.
212
+ *
213
+ * No idempotency flag is needed here: start() is already gated by the
214
+ * outer `started` flag (preventing double-subscription within one
215
+ * start cycle), and stop()/start() resume legitimately requires this
216
+ * function to run again — stop() sets mempoolSubscriptionHandle = null
217
+ * so the next call opens a fresh subscription cleanly.
218
+ */
219
+ const tryOpenMempoolSubscription = async () => {
220
+ if (!fetchMempool)
221
+ return;
222
+ if (cachedCapabilities.newPendingTransactions !== 'subscription')
223
+ return;
224
+ try {
225
+ mempoolSubscriptionHandle = await wsTransport.subscribe({
226
+ params: ['newPendingTransactions'],
227
+ // Push notifications carry a hash (string) on most providers;
228
+ // some send full-tx objects — extract .hash as a fallback.
229
+ onData: (data) => {
230
+ const hash = typeof data === 'string' ? data : data.hash;
231
+ if (!hash)
232
+ return;
233
+ void handleMempoolNotification(hash);
234
+ },
235
+ onError: (err) => options.onError?.('eth_subscribe.newPendingTransactions', err),
236
+ });
237
+ }
238
+ catch (err) {
239
+ options.onError?.('eth_subscribe.newPendingTransactions', err);
240
+ cachedCapabilities = {
241
+ ...cachedCapabilities,
242
+ newPendingTransactions: cachedCapabilities.txpoolContent === 'available'
243
+ ? 'poll-only'
244
+ : 'unavailable',
245
+ };
246
+ }
247
+ };
99
248
  // Eager capability probe. Fire-and-forget; consumers that need a
100
249
  // guaranteed-completed probe await source.ready().
101
250
  const readyPromise = probeCapabilities(options.client, {
@@ -162,8 +311,30 @@ export const createChainSource = (options) => {
162
311
  timer = setInterval(() => {
163
312
  void tick();
164
313
  }, pollIntervalMs);
314
+ // Open WS subscribes lazily once the probe has landed. Fire-and-
315
+ // forget; failures fall through to the existing poll loop.
316
+ void readyPromise.then(() => tryOpenBlockSubscription());
317
+ void readyPromise.then(() => tryOpenMempoolSubscription());
165
318
  },
166
319
  stop: () => {
320
+ if (blockSubscriptionHandle) {
321
+ try {
322
+ blockSubscriptionHandle.unsubscribe();
323
+ }
324
+ catch (err) {
325
+ options.onError?.('eth_unsubscribe', err);
326
+ }
327
+ blockSubscriptionHandle = null;
328
+ }
329
+ if (mempoolSubscriptionHandle) {
330
+ try {
331
+ mempoolSubscriptionHandle.unsubscribe();
332
+ }
333
+ catch (err) {
334
+ options.onError?.('eth_unsubscribe', err);
335
+ }
336
+ mempoolSubscriptionHandle = null;
337
+ }
167
338
  if (timer !== null) {
168
339
  clearInterval(timer);
169
340
  timer = null;
@@ -1 +1 @@
1
- {"version":3,"file":"source.js","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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AAI,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;QAE7E,YAAY,EAAE,GAAG,EAAE,CAAC,kBAAkB;KACvC,CAAA;AACH,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valve-tech/chain-source",
3
- "version": "0.7.0",
3
+ "version": "0.9.2",
4
4
  "description": "Canonical EVM chain-observation primitive: a unified push-or-poll source for new blocks, mempool snapshots, on-demand receipt + tx lookups, and capability disclosure (HTTP / WS / per-method gating). Used as the shared foundation by @valve-tech/gas-oracle and @valve-tech/tx-tracker; consumable directly by anyone building their own derived view on chain state. viem-native. Part of the valve-tech/evm-toolkit synchronized release line — implementation lands in subsequent 0.3.x releases per docs/tx-tracker-spec.md.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/valve-tech/evm-toolkit/tree/main/packages/chain-source#readme",