@valve-tech/tx-tracker 0.14.0 → 0.16.0
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 +116 -0
- package/dist/events.d.ts +22 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +6 -0
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/local-storage-store.d.ts +98 -0
- package/dist/local-storage-store.d.ts.map +1 -0
- package/dist/local-storage-store.js +208 -0
- package/dist/local-storage-store.js.map +1 -0
- package/dist/observations.d.ts +9 -0
- package/dist/observations.d.ts.map +1 -1
- package/dist/observations.js +53 -17
- package/dist/observations.js.map +1 -1
- package/dist/store.d.ts +12 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js.map +1 -1
- package/dist/tracker.d.ts +50 -1
- package/dist/tracker.d.ts.map +1 -1
- package/dist/tracker.js +126 -12
- package/dist/tracker.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,122 @@ 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.16.0] — 2026-05-15
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **`CreateTxTrackerOptions.logger`** — optional
|
|
14
|
+
`(level, message, meta?) => void` callback for non-fatal
|
|
15
|
+
observability events. Same shape as the v0.16 chain-source logger;
|
|
16
|
+
consumers wire one callback for both. The tracker calls it at
|
|
17
|
+
narrowly-chosen decision points: rehydration count on
|
|
18
|
+
`tracker.start()`, dedup-migration writes (when v0.15 self-healing
|
|
19
|
+
collapsed historical persisted-subscription duplicates), retention
|
|
20
|
+
expiry firings. Errors continue to flow through `onError`; the
|
|
21
|
+
logger covers the "what did the tracker decide" question.
|
|
22
|
+
|
|
23
|
+
### Notes
|
|
24
|
+
|
|
25
|
+
- 4 new tests covering logger plumbing: rehydration count emitted at
|
|
26
|
+
`info`, dedup migration logged on legacy stores, retention expiry
|
|
27
|
+
surfaced when records cross the terminal+retentionBlocks window,
|
|
28
|
+
missing-logger default doesn't crash the dispatch path. 338 total
|
|
29
|
+
tx-tracker tests (was 334). Coverage remains 100/100/100/100.
|
|
30
|
+
- The chain-source v0.16 adaptive scheduler propagates naturally to
|
|
31
|
+
tx-tracker consumers via the shared source — tracker dispatch ran
|
|
32
|
+
per-block-tick before and continues to do so, but those ticks now
|
|
33
|
+
fire around the actual block cadence rather than on a fixed
|
|
34
|
+
`pollIntervalMs` interval. The downstream effect: fewer wasted
|
|
35
|
+
per-record status polls / receipt polls / probe-Mined / probe-
|
|
36
|
+
Transaction dispatches when the chain is idle.
|
|
37
|
+
|
|
38
|
+
## [0.15.0] — 2026-05-14
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- **`CreateTxTrackerOptions.confirmationsForTerminal: number | null`**
|
|
43
|
+
(default `null`). When set to a positive integer, a record
|
|
44
|
+
transitions to terminal (`terminalAtBlockNumber` set to the current
|
|
45
|
+
block) the first block its `lastSeenInBlock.confirmations` reaches
|
|
46
|
+
the threshold. Closes the long-standing gap where a normally-mined
|
|
47
|
+
tx never went terminal — retention enforcement only fired on
|
|
48
|
+
replacement and unseen-for-N-blocks paths, so successful txs
|
|
49
|
+
accumulated in long-lived stores forever. Records with 5,000+
|
|
50
|
+
confirmations were observed in production localStorage dumps; the
|
|
51
|
+
new option lets consumers opt in to retire them via the normal
|
|
52
|
+
retention pipeline. Recommended value: `≥ reorgDepthBlocks` (default
|
|
53
|
+
12) so a same-height reorg can't briefly unmine a "terminal" tx.
|
|
54
|
+
Validation: must be a positive integer or null/undefined; zero,
|
|
55
|
+
negative, and non-integer values throw at construction.
|
|
56
|
+
- **`TxEventConfirmedTerminal` event kind** — `{ kind: 'confirmed-terminal',
|
|
57
|
+
confirmations }` fires once when the threshold is reached. Consumer-
|
|
58
|
+
facing signal that the record is now safe to forget. Carries the
|
|
59
|
+
triggering confirmations count for downstream gating.
|
|
60
|
+
- **`TrackOptions.subscriptionId?: string`** — caller-provided stable
|
|
61
|
+
identifier for the persisted subscription (only meaningful when
|
|
62
|
+
`durable: true`). Repeated calls with the same id are idempotent.
|
|
63
|
+
Without an explicit id, the tracker auto-dedups by `(durable,
|
|
64
|
+
selector)`: a second subscribe on the same hash with `durable: true`
|
|
65
|
+
reuses the prior persisted entry rather than appending. Closes the
|
|
66
|
+
bug where React component remounts and page reloads accumulated
|
|
67
|
+
structurally-identical persisted entries across reloads, each
|
|
68
|
+
driving the same downstream fan-out N times.
|
|
69
|
+
- **`createLocalStorageTrackerStore({ keyPrefix, storage?, eventLogCapacity?,
|
|
70
|
+
cleanupLegacyPrefixes? })`** — first-party TxTrackerStore implementation
|
|
71
|
+
backed by `localStorage` (or any `Storage`-shaped object). Records
|
|
72
|
+
stored under `{keyPrefix}:{chainId}:{hash}`; eventlogs under
|
|
73
|
+
`{keyPrefix}:eventlog:{chainId}:{hash}`. Bigint fields round-trip
|
|
74
|
+
losslessly via a sentinel-tagged JSON replacer/reviver.
|
|
75
|
+
**`delete()` clears BOTH the record AND the eventlog** — the
|
|
76
|
+
canonical bug class consumer-side localStorage stores routinely got
|
|
77
|
+
wrong, leaving orphaned eventlogs that never expired.
|
|
78
|
+
`cleanupLegacyPrefixes` deletes prior-prefix keys on construction for
|
|
79
|
+
prefix-bump migrations. Defensive against `setItem` failures (quota
|
|
80
|
+
exceeded, browser disabled storage) — surfaces as a rejected promise
|
|
81
|
+
so the tracker's `onError` can route it cleanly.
|
|
82
|
+
- **`deleteKeysStartingWith(storage, prefix)`** — standalone helper for
|
|
83
|
+
prefix cleanup without instantiating the full store.
|
|
84
|
+
- **Self-healing rehydration dedup.** On `tracker.start()`,
|
|
85
|
+
`dedupPersistedSubscriptions` runs on the rehydrated record's
|
|
86
|
+
subscription list; when the count shrinks (legacy duplicates
|
|
87
|
+
collapsed), the cleaned record is immediately written back via
|
|
88
|
+
`store.put`. Defensive against legacy flat-shape entries (pre-current
|
|
89
|
+
`selector` nesting) — those pass through untouched rather than
|
|
90
|
+
crashing the dedup helper.
|
|
91
|
+
|
|
92
|
+
### Changed
|
|
93
|
+
|
|
94
|
+
- **`runReceiptPollFallback` skips silently when `caps.ready === false`**.
|
|
95
|
+
Pre-v0.15, the conservative pre-probe `receiptByHash: 'unavailable'`
|
|
96
|
+
default tripped the "permanently unavailable" warning gate, firing
|
|
97
|
+
once per tracker instance even when the RPC ultimately supported the
|
|
98
|
+
method. The warning now waits for probe completion (`caps.ready === true`)
|
|
99
|
+
before deciding; pre-probe ticks no-op.
|
|
100
|
+
- **`TxTrackerStore.delete` docstring tightened** to make explicit that
|
|
101
|
+
implementations must clear ALL state associated with the hash — the
|
|
102
|
+
record, the eventlog, any other per-hash keys. The first-party
|
|
103
|
+
`createInMemoryStore` and `createLocalStorageTrackerStore` already
|
|
104
|
+
enforce this; consumer implementations must do the same to avoid the
|
|
105
|
+
orphan-eventlog leak class.
|
|
106
|
+
|
|
107
|
+
### Notes
|
|
108
|
+
|
|
109
|
+
- The `confirmationsForTerminal` transition fires from both Path 1
|
|
110
|
+
(fresh inclusion at confirmations=1, relevant only when threshold=1)
|
|
111
|
+
and Path 2 (confirmation bump from prior block) in
|
|
112
|
+
`decideBlockObservation`. Terminal is anchored on the current block
|
|
113
|
+
(matching the existing terminal arms which all anchor on
|
|
114
|
+
detection-block, not origin-block) — retention math is consistent
|
|
115
|
+
across all four arms.
|
|
116
|
+
- The status-poll path's mined emit (added in v0.14) hardcodes
|
|
117
|
+
`confirmations: 1` and doesn't participate in the new transition.
|
|
118
|
+
This is correct: status-poll mined observations are one-shot per
|
|
119
|
+
inclusion-block; confirmation accrual happens via block-poll's
|
|
120
|
+
Path 2, which is where the threshold is checked.
|
|
121
|
+
- 40 new tests across `tracker.test.ts`, `local-storage-store.test.ts`,
|
|
122
|
+
and `events.test.ts`. 334 total tx-tracker tests (was 294). Coverage
|
|
123
|
+
remains 100/100/100/100.
|
|
124
|
+
|
|
9
125
|
## [0.14.0] — 2026-05-14
|
|
10
126
|
|
|
11
127
|
### Added
|
package/dist/events.d.ts
CHANGED
|
@@ -153,6 +153,23 @@ export interface TxEventUnseenForNBlocks extends Envelope {
|
|
|
153
153
|
kind: 'unseen-for-N-blocks';
|
|
154
154
|
blocks: number;
|
|
155
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Mined-and-confirmed terminal — fires when an included tx's
|
|
158
|
+
* `confirmations` reaches the `confirmationsForTerminal` threshold
|
|
159
|
+
* configured on the tracker. Marks the record as terminal for
|
|
160
|
+
* retention purposes (the existing terminal anchors are
|
|
161
|
+
* replacement and unseen-for-N-blocks; v0.15 closes the gap where a
|
|
162
|
+
* normally-mined tx never goes terminal and leaks records in
|
|
163
|
+
* long-lived stores). Carries the confirmations count that triggered
|
|
164
|
+
* the transition so consumers can gate downstream UI cleanup off the
|
|
165
|
+
* same event. Fires exactly once per record — the
|
|
166
|
+
* `terminalAtBlockNumber == null` gate on the decision arm dedups
|
|
167
|
+
* subsequent confirmation bumps.
|
|
168
|
+
*/
|
|
169
|
+
export interface TxEventConfirmedTerminal extends Envelope {
|
|
170
|
+
kind: 'confirmed-terminal';
|
|
171
|
+
confirmations: number;
|
|
172
|
+
}
|
|
156
173
|
/**
|
|
157
174
|
* A capability the tracker had been relying on for this hash is
|
|
158
175
|
* no longer authoritative — typically because the WS subscription
|
|
@@ -192,7 +209,7 @@ export interface TxEventStopped extends Envelope {
|
|
|
192
209
|
* Discriminated union of every event variant. Narrow on `kind` to
|
|
193
210
|
* access variant-specific fields.
|
|
194
211
|
*/
|
|
195
|
-
export type TxEvent = TxEventStarted | TxEventSeenInMempool | TxEventLeftMempool | TxEventSeenInBlock | TxEventVanishedFromBlock | TxEventReplacedBy | TxEventUnseenForNBlocks | TxEventSignalDegraded | TxEventSignalRecovered | TxEventStopped;
|
|
212
|
+
export type TxEvent = TxEventStarted | TxEventSeenInMempool | TxEventLeftMempool | TxEventSeenInBlock | TxEventVanishedFromBlock | TxEventReplacedBy | TxEventUnseenForNBlocks | TxEventConfirmedTerminal | TxEventSignalDegraded | TxEventSignalRecovered | TxEventStopped;
|
|
196
213
|
/**
|
|
197
214
|
* `TxStatus` — cached snapshot the state machine maintains per
|
|
198
215
|
* tracked hash. `getTxStatus(hash)` returns this; the iterator and
|
|
@@ -292,6 +309,10 @@ export declare const buildReplacedBy: (input: Envelope & {
|
|
|
292
309
|
export declare const buildUnseenForNBlocks: (input: Envelope & {
|
|
293
310
|
blocks: number;
|
|
294
311
|
}) => TxEventUnseenForNBlocks;
|
|
312
|
+
/** Build a `confirmed-terminal` event. */
|
|
313
|
+
export declare const buildConfirmedTerminal: (input: Envelope & {
|
|
314
|
+
confirmations: number;
|
|
315
|
+
}) => TxEventConfirmedTerminal;
|
|
295
316
|
/** Build a `signal-degraded` event. */
|
|
296
317
|
export declare const buildSignalDegraded: (input: Envelope & {
|
|
297
318
|
capabilityLost: keyof Capabilities;
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAEpG;;;;;;GAMG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAA;AAEzB;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAE5B;;;;;;GAMG;AACH,MAAM,WAAW,EAAE;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IAC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,mBAAmB,GAAG,iBAAiB,CAAA;CACjE,KACA,cAID,CAAA;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO;IACxC,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,QAYF,CAAA"}
|
package/dist/events.js
CHANGED
|
@@ -91,6 +91,12 @@ export const buildUnseenForNBlocks = (input) => ({
|
|
|
91
91
|
kind: 'unseen-for-N-blocks',
|
|
92
92
|
blocks: input.blocks,
|
|
93
93
|
});
|
|
94
|
+
/** Build a `confirmed-terminal` event. */
|
|
95
|
+
export const buildConfirmedTerminal = (input) => ({
|
|
96
|
+
...makeEnvelope(input),
|
|
97
|
+
kind: 'confirmed-terminal',
|
|
98
|
+
confirmations: input.confirmations,
|
|
99
|
+
});
|
|
94
100
|
/** Build a `signal-degraded` event. */
|
|
95
101
|
export const buildSignalDegraded = (input) => ({
|
|
96
102
|
...makeEnvelope(input),
|
package/dist/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA0RH;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,KAAe,EAAY,EAAE,CAAC,CAAC;IACnD,IAAI,EAAE,KAAK,CAAC,IAAI;IAChB,OAAO,EAAE,KAAK,CAAC,OAAO;IACtB,MAAM,EAAE,KAAK,CAAC,MAAM;IACpB,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE;CACzE,CAAC,CAAA;AAEF,+BAA+B;AAC/B,MAA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,CAAC,CAAC;IAC5B,GAAG,YAAY,CAAC,KAAK,CAAC;IACtB,IAAI,EAAE,kBAAkB;IACxB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;CAC7C,CAAC,CAAA;AAEF,+BAA+B;AAC/B,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAEC,EACe,EAAE,CAAC,CAAC;IACpB,GAAG,YAAY,CAAC,KAAK,CAAC;IACtB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,KAAK,CAAC,MAAM;CACrB,CAAC,CAAA;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAIlC,EAAY,EAAE,CAAC,CAAC;IACf,IAAI,EAAE,KAAK,CAAC,IAAI;IAChB,OAAO,EAAE,KAAK,CAAC,OAAO;IACtB,eAAe,EAAE,IAAI;IACrB,iBAAiB,EAAE,IAAI;IACvB,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,CAAC;IACf,oBAAoB,EAAE,IAAI;IAC1B,mBAAmB,EAAE,IAAI;IACzB,qBAAqB,EAAE,IAAI;IAC3B,YAAY,EAAE,KAAK,CAAC,YAAY;CACjC,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -40,9 +40,11 @@
|
|
|
40
40
|
* source.stop()
|
|
41
41
|
*/
|
|
42
42
|
export { createTxTracker } from './tracker.js';
|
|
43
|
-
export type { CreateTxTrackerOptions, TxTracker, TrackOptions, BulkTrackOptions, TxMatchEvent, TxSubscription, LostSignalPolicy, GroupOptions, TxGroupSubscription, } from './tracker.js';
|
|
44
|
-
export {
|
|
45
|
-
export type {
|
|
43
|
+
export type { CreateTxTrackerOptions, TxTracker, TrackOptions, BulkTrackOptions, TxMatchEvent, TxSubscription, LostSignalPolicy, ProbeMined, ProbeMinedResult, ProbeTransaction, GroupOptions, TxGroupSubscription, } from './tracker.js';
|
|
44
|
+
export { createLocalStorageTrackerStore, deleteKeysStartingWith, } from './local-storage-store.js';
|
|
45
|
+
export type { LocalStorageLike, LocalStorageTrackerStoreOptions, } from './local-storage-store.js';
|
|
46
|
+
export { buildStarted, buildSeenInMempool, buildLeftMempool, buildSeenInBlock, buildVanishedFromBlock, buildReplacedBy, buildUnseenForNBlocks, buildConfirmedTerminal, buildSignalDegraded, buildSignalRecovered, buildStopped, buildInitialStatus, } from './events.js';
|
|
47
|
+
export type { Address, At, Envelope, Hash, TxEvent, TxEventStarted, TxEventSeenInMempool, TxEventLeftMempool, TxEventSeenInBlock, TxEventVanishedFromBlock, TxEventReplacedBy, TxEventUnseenForNBlocks, TxEventConfirmedTerminal, TxEventSignalDegraded, TxEventSignalRecovered, TxEventStopped, TxStatus, } from './events.js';
|
|
46
48
|
export { createInMemoryStore, computeRetentionExpiry, defaultRetentionBlocks, } from './store.js';
|
|
47
49
|
export type { BulkSelector, HashSelector, InMemoryStoreOptions, PersistedSubscription, TrackedTxRecord, TxTrackerStore, } from './store.js';
|
|
48
50
|
export { appendBlock, defaultReorgDepthBlocks, detectDivergences, } from './reorg.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,YAAY,EACV,sBAAsB,EACtB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,GACpB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,GACnB,MAAM,aAAa,CAAA;AAC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oB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,YAAY,EACV,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,0BAA0B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,YAAY,EACV,sBAAsB,EACtB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,GACpB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,8BAA8B,EAC9B,sBAAsB,GACvB,MAAM,0BAA0B,CAAA;AACjC,YAAY,EACV,gBAAgB,EAChB,+BAA+B,GAChC,MAAM,0BAA0B,CAAA;AAEjC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,GACnB,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,OAAO,EACP,EAAE,EACF,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACd,QAAQ,GACT,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EAC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|
* source.stop()
|
|
41
41
|
*/
|
|
42
42
|
export { createTxTracker } from './tracker.js';
|
|
43
|
-
export {
|
|
43
|
+
export { createLocalStorageTrackerStore, deleteKeysStartingWith, } from './local-storage-store.js';
|
|
44
|
+
export { buildStarted, buildSeenInMempool, buildLeftMempool, buildSeenInBlock, buildVanishedFromBlock, buildReplacedBy, buildUnseenForNBlocks, buildConfirmedTerminal, buildSignalDegraded, buildSignalRecovered, buildStopped, buildInitialStatus, } from './events.js';
|
|
44
45
|
export { createInMemoryStore, computeRetentionExpiry, defaultRetentionBlocks, } from './store.js';
|
|
45
46
|
export { appendBlock, defaultReorgDepthBlocks, detectDivergences, } from './reorg.js';
|
|
46
47
|
export { compileSelector, defaultMaxBulkSubscriptions, matchAll, } from './selectors.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAgB9C,OAAO,EACL,8BAA8B,EAC9B,sBAAsB,GACvB,MAAM,0BAA0B,CAAA;AAMjC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,GACnB,MAAM,aAAa,CAAA;AAqBpB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,YAAY,CAAA;AAUnB,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,YAAY,CAAA;AAGnB,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,QAAQ,GACT,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAGzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAM9D,OAAO,EACL,cAAc,EACd,0BAA0B,GAC3B,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAU1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createLocalStorageTrackerStore` — first-party `TxTrackerStore`
|
|
3
|
+
* implementation backed by `localStorage` (or any `Storage`-shaped
|
|
4
|
+
* object). Targeted at browser dApps that need durable per-hash
|
|
5
|
+
* subscriptions surviving page reloads but don't want to maintain
|
|
6
|
+
* their own custom store.
|
|
7
|
+
*
|
|
8
|
+
* Key layout (under the consumer-supplied `keyPrefix`):
|
|
9
|
+
*
|
|
10
|
+
* {keyPrefix}:{chainId}:{hash} → the TrackedTxRecord JSON
|
|
11
|
+
* {keyPrefix}:eventlog:{chainId}:{hash} → the per-hash event log JSON
|
|
12
|
+
*
|
|
13
|
+
* The eventlog is a separate key from the record so put/get can avoid
|
|
14
|
+
* paying read-and-rewrite for the (potentially-large) log on every
|
|
15
|
+
* status update.
|
|
16
|
+
*
|
|
17
|
+
* **`delete()` clears BOTH keys.** This is the contract the
|
|
18
|
+
* `TxTrackerStore.delete` docstring requires; we lock it in here so
|
|
19
|
+
* consumers don't accumulate orphan eventlogs when records expire
|
|
20
|
+
* (the canonical bug that motivated this first-party store —
|
|
21
|
+
* consumer-implemented localStorage stores routinely forgot to clear
|
|
22
|
+
* the eventlog key).
|
|
23
|
+
*
|
|
24
|
+
* Browser-safety: `localStorage` is browser-only. The factory accepts
|
|
25
|
+
* a `storage` override (defaults to `globalThis.localStorage`) so
|
|
26
|
+
* (a) tests can inject a fake and (b) consumers running in
|
|
27
|
+
* server-rendered contexts can supply a no-op implementation rather
|
|
28
|
+
* than throwing at construction.
|
|
29
|
+
*/
|
|
30
|
+
import type { PersistedSubscription, TxTrackerStore } from './store.js';
|
|
31
|
+
/**
|
|
32
|
+
* Storage-shaped interface — the subset of the DOM `Storage` API the
|
|
33
|
+
* store needs. `localStorage` and `sessionStorage` both satisfy this;
|
|
34
|
+
* consumers can supply any object with the same shape (in-memory fake,
|
|
35
|
+
* server-rendered no-op, IndexedDB-backed polyfill, etc.).
|
|
36
|
+
*/
|
|
37
|
+
export interface LocalStorageLike {
|
|
38
|
+
getItem(key: string): string | null;
|
|
39
|
+
setItem(key: string, value: string): void;
|
|
40
|
+
removeItem(key: string): void;
|
|
41
|
+
readonly length: number;
|
|
42
|
+
key(index: number): string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface LocalStorageTrackerStoreOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Namespace prefix for all keys this store writes. Required. Use
|
|
47
|
+
* a versioned prefix (e.g. `'myapp.tx-tracker.v1'`) and bump the
|
|
48
|
+
* version suffix when the persisted shape changes — the prior-
|
|
49
|
+
* prefix keys can then be cleaned up via `cleanupLegacyPrefixes`.
|
|
50
|
+
*/
|
|
51
|
+
keyPrefix: string;
|
|
52
|
+
/**
|
|
53
|
+
* Storage backend. Defaults to `globalThis.localStorage` when
|
|
54
|
+
* available; throws at construction otherwise (server-rendered or
|
|
55
|
+
* Node contexts must supply an explicit `storage` parameter, even
|
|
56
|
+
* if it's a no-op).
|
|
57
|
+
*/
|
|
58
|
+
storage?: LocalStorageLike;
|
|
59
|
+
/**
|
|
60
|
+
* Cap on the per-hash event log. When `appendEvent` would push the
|
|
61
|
+
* log past this length, the oldest entries are dropped. Default 256
|
|
62
|
+
* (matches `InMemoryStoreOptions.eventLogCapacity`).
|
|
63
|
+
*/
|
|
64
|
+
eventLogCapacity?: number;
|
|
65
|
+
/**
|
|
66
|
+
* On construction, delete every key in `storage` that starts with
|
|
67
|
+
* any of these prefixes followed by `:`. Use to clean up records
|
|
68
|
+
* orphaned by a prior `keyPrefix` bump. Pass the OLD prefix (or
|
|
69
|
+
* prefixes), not the current one — passing the current one would
|
|
70
|
+
* wipe live state.
|
|
71
|
+
*/
|
|
72
|
+
cleanupLegacyPrefixes?: string[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Build a localStorage-backed `TxTrackerStore`. See module docstring
|
|
76
|
+
* for the key layout and serialization details.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* import {
|
|
80
|
+
* createTxTracker,
|
|
81
|
+
* createLocalStorageTrackerStore,
|
|
82
|
+
* } from '@valve-tech/tx-tracker'
|
|
83
|
+
*
|
|
84
|
+
* const store = createLocalStorageTrackerStore({
|
|
85
|
+
* keyPrefix: 'myapp.tx-tracker.v1',
|
|
86
|
+
* cleanupLegacyPrefixes: ['myapp.tx-tracker.v0'],
|
|
87
|
+
* })
|
|
88
|
+
* const tracker = createTxTracker({ source, chainId: 1, store })
|
|
89
|
+
*/
|
|
90
|
+
export declare const createLocalStorageTrackerStore: (options: LocalStorageTrackerStoreOptions) => TxTrackerStore;
|
|
91
|
+
/**
|
|
92
|
+
* Delete every key in `storage` whose name starts with `prefix`.
|
|
93
|
+
* Exported so consumers can run prefix cleanup without instantiating
|
|
94
|
+
* the full store — e.g., on app boot before constructing the tracker.
|
|
95
|
+
*/
|
|
96
|
+
export declare const deleteKeysStartingWith: (storage: LocalStorageLike, prefix: string) => void;
|
|
97
|
+
export type { PersistedSubscription };
|
|
98
|
+
//# sourceMappingURL=local-storage-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-storage-store.d.ts","sourceRoot":"","sources":["../src/local-storage-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,KAAK,EACV,qBAAqB,EAErB,cAAc,EACf,MAAM,YAAY,CAAA;AAEnB;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACzC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;CAClC;AAED,MAAM,WAAW,+BAA+B;IAC9C;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAA;IAEjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAA;IAE1B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAA;CACjC;AAwDD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B,GACzC,SAAS,+BAA+B,KACvC,cA2GF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,gBAAgB,EACzB,QAAQ,MAAM,KACb,IASF,CAAA;AAMD,YAAY,EAAE,qBAAqB,EAAE,CAAA"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createLocalStorageTrackerStore` — first-party `TxTrackerStore`
|
|
3
|
+
* implementation backed by `localStorage` (or any `Storage`-shaped
|
|
4
|
+
* object). Targeted at browser dApps that need durable per-hash
|
|
5
|
+
* subscriptions surviving page reloads but don't want to maintain
|
|
6
|
+
* their own custom store.
|
|
7
|
+
*
|
|
8
|
+
* Key layout (under the consumer-supplied `keyPrefix`):
|
|
9
|
+
*
|
|
10
|
+
* {keyPrefix}:{chainId}:{hash} → the TrackedTxRecord JSON
|
|
11
|
+
* {keyPrefix}:eventlog:{chainId}:{hash} → the per-hash event log JSON
|
|
12
|
+
*
|
|
13
|
+
* The eventlog is a separate key from the record so put/get can avoid
|
|
14
|
+
* paying read-and-rewrite for the (potentially-large) log on every
|
|
15
|
+
* status update.
|
|
16
|
+
*
|
|
17
|
+
* **`delete()` clears BOTH keys.** This is the contract the
|
|
18
|
+
* `TxTrackerStore.delete` docstring requires; we lock it in here so
|
|
19
|
+
* consumers don't accumulate orphan eventlogs when records expire
|
|
20
|
+
* (the canonical bug that motivated this first-party store —
|
|
21
|
+
* consumer-implemented localStorage stores routinely forgot to clear
|
|
22
|
+
* the eventlog key).
|
|
23
|
+
*
|
|
24
|
+
* Browser-safety: `localStorage` is browser-only. The factory accepts
|
|
25
|
+
* a `storage` override (defaults to `globalThis.localStorage`) so
|
|
26
|
+
* (a) tests can inject a fake and (b) consumers running in
|
|
27
|
+
* server-rendered contexts can supply a no-op implementation rather
|
|
28
|
+
* than throwing at construction.
|
|
29
|
+
*/
|
|
30
|
+
const DEFAULT_EVENT_LOG_CAPACITY = 256;
|
|
31
|
+
const recordKey = (prefix, chainId, hash) => `${prefix}:${chainId}:${hash}`;
|
|
32
|
+
const eventLogKey = (prefix, chainId, hash) => `${prefix}:eventlog:${chainId}:${hash}`;
|
|
33
|
+
/**
|
|
34
|
+
* JSON replacer that round-trips `bigint` losslessly. The toolkit's
|
|
35
|
+
* persisted shapes carry block numbers and other on-chain quantities
|
|
36
|
+
* as bigint; native `JSON.stringify` throws on them. We tag with a
|
|
37
|
+
* sentinel discriminator so the reviver can rehydrate to bigint
|
|
38
|
+
* without ambiguity against arbitrary user strings.
|
|
39
|
+
*/
|
|
40
|
+
const SENTINEL = '$tx-tracker:bigint';
|
|
41
|
+
const bigintReplacer = (_key, value) => {
|
|
42
|
+
if (typeof value === 'bigint') {
|
|
43
|
+
return { [SENTINEL]: value.toString() };
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
};
|
|
47
|
+
const bigintReviver = (_key, value) => {
|
|
48
|
+
if (value !== null &&
|
|
49
|
+
typeof value === 'object' &&
|
|
50
|
+
SENTINEL in value &&
|
|
51
|
+
typeof value[SENTINEL] === 'string') {
|
|
52
|
+
try {
|
|
53
|
+
return BigInt(value[SENTINEL]);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Malformed sentinel — fall back to the raw object; downstream
|
|
57
|
+
// type guards (typeof === 'bigint') will treat as missing.
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return value;
|
|
62
|
+
};
|
|
63
|
+
const stringifyRecord = (value) => JSON.stringify(value, bigintReplacer);
|
|
64
|
+
const parseRecord = (raw) => {
|
|
65
|
+
if (raw === null)
|
|
66
|
+
return null;
|
|
67
|
+
try {
|
|
68
|
+
return JSON.parse(raw, bigintReviver);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Build a localStorage-backed `TxTrackerStore`. See module docstring
|
|
76
|
+
* for the key layout and serialization details.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* import {
|
|
80
|
+
* createTxTracker,
|
|
81
|
+
* createLocalStorageTrackerStore,
|
|
82
|
+
* } from '@valve-tech/tx-tracker'
|
|
83
|
+
*
|
|
84
|
+
* const store = createLocalStorageTrackerStore({
|
|
85
|
+
* keyPrefix: 'myapp.tx-tracker.v1',
|
|
86
|
+
* cleanupLegacyPrefixes: ['myapp.tx-tracker.v0'],
|
|
87
|
+
* })
|
|
88
|
+
* const tracker = createTxTracker({ source, chainId: 1, store })
|
|
89
|
+
*/
|
|
90
|
+
export const createLocalStorageTrackerStore = (options) => {
|
|
91
|
+
const storage = options.storage ??
|
|
92
|
+
(typeof globalThis !== 'undefined' &&
|
|
93
|
+
'localStorage' in globalThis &&
|
|
94
|
+
globalThis.localStorage
|
|
95
|
+
? globalThis.localStorage
|
|
96
|
+
: null);
|
|
97
|
+
if (!storage) {
|
|
98
|
+
throw new Error('createLocalStorageTrackerStore: no `storage` supplied and globalThis.localStorage is unavailable. Pass `storage: ...` explicitly when running in a non-browser environment.');
|
|
99
|
+
}
|
|
100
|
+
if (!options.keyPrefix) {
|
|
101
|
+
throw new Error('createLocalStorageTrackerStore: keyPrefix is required');
|
|
102
|
+
}
|
|
103
|
+
const keyPrefix = options.keyPrefix;
|
|
104
|
+
const eventLogCapacity = options.eventLogCapacity ?? DEFAULT_EVENT_LOG_CAPACITY;
|
|
105
|
+
// Cleanup pass on construction. Skip the current prefix even if a
|
|
106
|
+
// consumer accidentally lists it — wiping live state mid-session
|
|
107
|
+
// would be the most-surprising-thing possible.
|
|
108
|
+
for (const legacy of options.cleanupLegacyPrefixes ?? []) {
|
|
109
|
+
if (!legacy || legacy === keyPrefix)
|
|
110
|
+
continue;
|
|
111
|
+
deleteKeysStartingWith(storage, `${legacy}:`);
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
put: async (record) => {
|
|
115
|
+
storage.setItem(recordKey(keyPrefix, record.chainId, record.hash), stringifyRecord(record));
|
|
116
|
+
},
|
|
117
|
+
get: async (chainId, hash) => {
|
|
118
|
+
const raw = storage.getItem(recordKey(keyPrefix, chainId, hash));
|
|
119
|
+
return parseRecord(raw);
|
|
120
|
+
},
|
|
121
|
+
delete: async (chainId, hash) => {
|
|
122
|
+
// Critically: clear BOTH the record AND the eventlog. The bug
|
|
123
|
+
// class this fixes is the consumer-side localStorage store that
|
|
124
|
+
// remembered only the record key on delete, leaving the eventlog
|
|
125
|
+
// as a permanent orphan.
|
|
126
|
+
storage.removeItem(recordKey(keyPrefix, chainId, hash));
|
|
127
|
+
storage.removeItem(eventLogKey(keyPrefix, chainId, hash));
|
|
128
|
+
},
|
|
129
|
+
listDurable: async (chainId) => {
|
|
130
|
+
const prefix = `${keyPrefix}:${chainId}:`;
|
|
131
|
+
const result = [];
|
|
132
|
+
// Snapshot the keys first — mutations during iteration would
|
|
133
|
+
// shift the `key(i)` indexing. Browser localStorage is
|
|
134
|
+
// synchronous, but defensive against any Storage-shaped object
|
|
135
|
+
// that mutates during the iteration.
|
|
136
|
+
//
|
|
137
|
+
// Filter: record keys are `{keyPrefix}:{chainId}:{hash}`, eventlog
|
|
138
|
+
// keys are `{keyPrefix}:eventlog:{chainId}:{hash}`. With a numeric
|
|
139
|
+
// chainId the two prefixes don't overlap (`p:1:` vs `p:eventlog:`),
|
|
140
|
+
// so a single `startsWith(prefix)` check is enough — eventlog keys
|
|
141
|
+
// can never match the record prefix.
|
|
142
|
+
const keys = [];
|
|
143
|
+
for (let i = 0; i < storage.length; i++) {
|
|
144
|
+
const k = storage.key(i);
|
|
145
|
+
if (k === null)
|
|
146
|
+
continue;
|
|
147
|
+
if (!k.startsWith(prefix))
|
|
148
|
+
continue;
|
|
149
|
+
keys.push(k);
|
|
150
|
+
}
|
|
151
|
+
for (const k of keys) {
|
|
152
|
+
const record = parseRecord(storage.getItem(k));
|
|
153
|
+
if (!record)
|
|
154
|
+
continue;
|
|
155
|
+
if (record.chainId !== chainId)
|
|
156
|
+
continue;
|
|
157
|
+
if (record.subscriptions.some((sub) => sub.durable)) {
|
|
158
|
+
result.push(record);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
},
|
|
163
|
+
appendEvent: async (chainId, hash, event) => {
|
|
164
|
+
// Async so a `storage.setItem` throw (quota exceeded, browser
|
|
165
|
+
// disabled storage, private-mode constraints) surfaces as a
|
|
166
|
+
// rejected promise rather than a synchronous throw — the tracker
|
|
167
|
+
// routes store errors through `onError` and never lets them
|
|
168
|
+
// halt the live emit fanout (spec Appendix A).
|
|
169
|
+
const key = eventLogKey(keyPrefix, chainId, hash);
|
|
170
|
+
const existing = parseRecord(storage.getItem(key)) ?? [];
|
|
171
|
+
existing.push(event);
|
|
172
|
+
// Drop oldest entries when the log exceeds the cap. Slicing
|
|
173
|
+
// from the tail keeps the most-recent window — the audit-trail
|
|
174
|
+
// pattern indexers expect.
|
|
175
|
+
const trimmed = existing.length > eventLogCapacity
|
|
176
|
+
? existing.slice(existing.length - eventLogCapacity)
|
|
177
|
+
: existing;
|
|
178
|
+
storage.setItem(key, stringifyRecord(trimmed));
|
|
179
|
+
},
|
|
180
|
+
readEventLog: async (chainId, hash, since) => {
|
|
181
|
+
const key = eventLogKey(keyPrefix, chainId, hash);
|
|
182
|
+
const raw = storage.getItem(key);
|
|
183
|
+
const events = parseRecord(raw) ?? [];
|
|
184
|
+
if (since === undefined)
|
|
185
|
+
return events;
|
|
186
|
+
return events.filter((e) => e.at.blockNumber >= since);
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Delete every key in `storage` whose name starts with `prefix`.
|
|
192
|
+
* Exported so consumers can run prefix cleanup without instantiating
|
|
193
|
+
* the full store — e.g., on app boot before constructing the tracker.
|
|
194
|
+
*/
|
|
195
|
+
export const deleteKeysStartingWith = (storage, prefix) => {
|
|
196
|
+
if (!prefix)
|
|
197
|
+
return;
|
|
198
|
+
// Snapshot keys first; removing during iteration shifts indexing.
|
|
199
|
+
const matched = [];
|
|
200
|
+
for (let i = 0; i < storage.length; i++) {
|
|
201
|
+
const k = storage.key(i);
|
|
202
|
+
if (k !== null && k.startsWith(prefix))
|
|
203
|
+
matched.push(k);
|
|
204
|
+
}
|
|
205
|
+
for (const k of matched)
|
|
206
|
+
storage.removeItem(k);
|
|
207
|
+
};
|
|
208
|
+
//# sourceMappingURL=local-storage-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-storage-store.js","sourceRoot":"","sources":["../src/local-storage-store.ts"],"names":[],"mappings":"A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,EAAE,KAAK,EAAE,EAAE;YAC3C,MAAM,GAAG,GAAG,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;YACjD,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YAChC,MAAM,MAAM,GAAG,WAAW,CAAY,GAAG,CAAC,IAAI,EAAE,CAAA;YAChD,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAA;YACtC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,IAAI,KAAK,CAAC,CAAA;QACxD,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,OAAyB,EACzB,MAAc,EACR,EAAE;IACR,IAAI,CAAC,MAAM;QAAE,OAAM;IACnB,kEAAkE;IAClE,MAAM,OAAO,GAAa,EAAE,CAAA;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QACxB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACzD,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,OAAO;QAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;AAChD,CAAC,CAAA"}
|
package/dist/observations.d.ts
CHANGED
|
@@ -86,6 +86,15 @@ export interface BlockObservationInput {
|
|
|
86
86
|
* receipt without a follow-up re-emit.
|
|
87
87
|
*/
|
|
88
88
|
prefetchedReceipts?: ReadonlyMap<Hash, TransactionReceipt>;
|
|
89
|
+
/**
|
|
90
|
+
* Threshold for the mined-and-confirmed terminal transition. When
|
|
91
|
+
* non-null and the record's confirmations reach this value, the
|
|
92
|
+
* record is marked terminal (anchored on the current block, same
|
|
93
|
+
* pattern as the other terminal arms) and `confirmed-terminal`
|
|
94
|
+
* fires exactly once. `null` preserves the v0.14 behavior of never
|
|
95
|
+
* setting terminal via the mined path.
|
|
96
|
+
*/
|
|
97
|
+
confirmationsForTerminal: number | null;
|
|
89
98
|
}
|
|
90
99
|
/**
|
|
91
100
|
* Per-record decision for one new canonical block. Returns the events
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observations.d.ts","sourceRoot":"","sources":["../src/observations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAEtF,OAAO,
|
|
1
|
+
{"version":3,"file":"observations.d.ts","sourceRoot":"","sources":["../src/observations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAEtF,OAAO,EAOL,KAAK,EAAE,EACP,KAAK,IAAI,EACT,KAAK,OAAO,EACZ,KAAK,QAAQ,EACd,MAAM,aAAa,CAAA;AAEpB;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,QAAQ,CAAA;IAChB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAChD,qBAAqB,EAAE,OAAO,CAAA;IAC9B,qBAAqB,EAAE,MAAM,CAAA;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;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