@valve-tech/tx-tracker 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 +50 -0
- package/dist/events.d.ts +11 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +1 -0
- package/dist/events.js.map +1 -1
- package/dist/group-events.d.ts +82 -0
- package/dist/group-events.d.ts.map +1 -0
- package/dist/group-events.js +47 -0
- package/dist/group-events.js.map +1 -0
- package/dist/group.d.ts +31 -0
- package/dist/group.d.ts.map +1 -0
- package/dist/group.js +196 -0
- package/dist/group.js.map +1 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/observations.d.ts +11 -1
- package/dist/observations.d.ts.map +1 -1
- package/dist/observations.js +5 -1
- package/dist/observations.js.map +1 -1
- package/dist/reorg.d.ts.map +1 -1
- package/dist/reorg.js +7 -12
- package/dist/reorg.js.map +1 -1
- package/dist/replace-transaction.d.ts +46 -0
- package/dist/replace-transaction.d.ts.map +1 -0
- package/dist/replace-transaction.js +51 -0
- package/dist/replace-transaction.js.map +1 -0
- package/dist/tracker.d.ts +50 -4
- package/dist/tracker.d.ts.map +1 -1
- package/dist/tracker.js +192 -27
- package/dist/tracker.js.map +1 -1
- package/dist/wait-for-pending.d.ts +47 -0
- package/dist/wait-for-pending.d.ts.map +1 -0
- package/dist/wait-for-pending.js +71 -0
- package/dist/wait-for-pending.js.map +1 -0
- package/dist/wait-for-transaction.d.ts +61 -0
- package/dist/wait-for-transaction.d.ts.map +1 -0
- package/dist/wait-for-transaction.js +72 -0
- package/dist/wait-for-transaction.js.map +1 -0
- package/dist/watch-transaction.d.ts +63 -0
- package/dist/watch-transaction.d.ts.map +1 -0
- package/dist/watch-transaction.js +76 -0
- package/dist/watch-transaction.js.map +1 -0
- package/package.json +2 -2
- package/skills/tx-tracker-integration/SKILL.md +30 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,56 @@ 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
|
+
### Added
|
|
33
|
+
- `chainId` option on `watchTransaction` / `waitForTransaction` / `waitForPending`. Echoes through to `event.chainId` so consumers fanning multiple watchers into a single multi-chain stream can disambiguate. Falls back to `client.chain?.id`, then `0`.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- `replaceTransaction` no longer passes `chain: null`, which silently disabled viem's `assertChainId` network-mismatch check. Now defers to `walletClient.chain` (passing `null` only when the wallet has no chain set, the only case viem requires it). `original.chainId` is threaded through as the top-level `chainId` field — the field is now load-bearing for EIP-155 signing and chain assertion. If a caller's wallet client and `original.chainId` disagree, viem throws.
|
|
37
|
+
|
|
38
|
+
### Removed
|
|
39
|
+
- Dead `_eventSource` parameters from internal `runBulkOnBlock` / `runBulkOnMempool`. No effect on public API.
|
|
40
|
+
|
|
41
|
+
### Notes
|
|
42
|
+
- Code-quality cleanup: removed three unreachable defensive guards from `tracker.ts` and `reorg.ts` that were marked with `c8 ignore` annotations. One pre-existing annotation remains (`tracker.ts:1083` invariant throw, kept for TS return-type narrowing). 100/100/100/100 coverage holds.
|
|
43
|
+
|
|
44
|
+
## [0.8.0] — 2026-05-06
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
- `lostSignalPolicy: { strategy: 'receipt-poll-fallback', pollEveryBlocks: N }` runtime. Closes the type-vs-runtime gap from v0.3.x — when a tracked subscription is in a degraded state, the tracker fetches `getReceipt` every N block ticks and emits `seen-in-block` with `source: 'receipt-poll'` on hit. Capability gate: requires `receiptByHash === 'available'`.
|
|
48
|
+
- `withReceipts: true` opt-in receipt enrichment on `TrackOptions`. When set, the tracker pre-fetches the receipt before the per-record block decision and attaches it to `seen-in-block` events via the new `TxEventSeenInBlock.receipt` field. One emit per inclusion — receipt is on the first event, not a follow-up.
|
|
49
|
+
- `tracker.group(hashes, options?)` — cross-tx correlation (spec §18.1). Emits `group-progress` / `group-complete` / `group-failed` / `group-stopped` derived from per-member event streams. Replacement does NOT auto-promote.
|
|
50
|
+
- `watchTransaction({ client, hash, ... })` — one-shot callback convenience export.
|
|
51
|
+
- `waitForTransaction({ client, hash, ... })` — Promise variant of `watchTransaction`. Resolves with discriminated-union outcome (`mined` / `dropped` / `replaced` / `failed`).
|
|
52
|
+
- `waitForPending({ client, hash, timeoutBlocks })` — Promise that resolves on first `seen-in-mempool`; rejects with typed `WaitForPendingTimeoutError` if the hash isn't observed within `timeoutBlocks`.
|
|
53
|
+
- `replaceTransaction({ original, walletClient, newGas })` — same-nonce replacement primitive. Caller-provides-newGas keeps tx-tracker independent of `@valve-tech/gas-oracle`.
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
- `onBlock` is now async to support pre-fetching receipts before the per-record decision. Stale-block guard added against the resulting interleave window so a delayed pre-fetch can't clobber state advanced by a concurrent block tick.
|
|
57
|
+
- `decideBlockObservation` accepts an optional `prefetchedReceipts: ReadonlyMap<Hash, TransactionReceipt>` parameter (backward-compatible — existing callsites omit it).
|
|
58
|
+
|
|
9
59
|
## [0.7.0] — 2026-05-06
|
|
10
60
|
|
|
11
61
|
> **The implementation lands.** This is the first release of
|
package/dist/events.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* No I/O, no wall-clock, no mutation — pure data shape + pure
|
|
20
20
|
* builders. Browser/mobile safe (§2.4).
|
|
21
21
|
*/
|
|
22
|
-
import type { Capabilities, EventSource, RawTx } from '@valve-tech/chain-source';
|
|
22
|
+
import type { Capabilities, EventSource, RawTx, TransactionReceipt } from '@valve-tech/chain-source';
|
|
23
23
|
/**
|
|
24
24
|
* Hash type carried on every event. The chain-source layer keeps
|
|
25
25
|
* hashes as plain `string` rather than viem's `Hash` brand to stay
|
|
@@ -96,6 +96,9 @@ export interface TxEventLeftMempool extends Envelope {
|
|
|
96
96
|
* `confirmations` counts blocks observed since this inclusion
|
|
97
97
|
* inclusive of the inclusion block itself (so the first
|
|
98
98
|
* inclusion event has `confirmations: 1`).
|
|
99
|
+
*
|
|
100
|
+
* `receipt` is present iff the subscription set `withReceipts: true`.
|
|
101
|
+
* Adds one RPC per inclusion (spec §18.2, v0.8.0 design F2).
|
|
99
102
|
*/
|
|
100
103
|
export interface TxEventSeenInBlock extends Envelope {
|
|
101
104
|
kind: 'seen-in-block';
|
|
@@ -103,6 +106,12 @@ export interface TxEventSeenInBlock extends Envelope {
|
|
|
103
106
|
blockNumber: bigint;
|
|
104
107
|
transactionIndex: number;
|
|
105
108
|
confirmations: number;
|
|
109
|
+
/**
|
|
110
|
+
* Transaction receipt — present iff the subscription set
|
|
111
|
+
* `withReceipts: true`. Adds one RPC per inclusion (spec §18.2,
|
|
112
|
+
* v0.8.0 design F2).
|
|
113
|
+
*/
|
|
114
|
+
receipt?: TransactionReceipt;
|
|
106
115
|
}
|
|
107
116
|
/**
|
|
108
117
|
* Tx was previously seen at block `blockNumber` with hash
|
|
@@ -249,6 +258,7 @@ export declare const buildSeenInBlock: (input: Envelope & {
|
|
|
249
258
|
blockNumber: bigint;
|
|
250
259
|
transactionIndex: number;
|
|
251
260
|
confirmations: number;
|
|
261
|
+
receipt?: TransactionReceipt;
|
|
252
262
|
}) => TxEventSeenInBlock;
|
|
253
263
|
/**
|
|
254
264
|
* Build a `vanished-from-block` event. Spec §12.3 forbids
|
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,MAAM,0BAA0B,CAAA;
|
|
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;IACvB,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,WAAW,CAAA;IACnB,EAAE,EAAE,EAAE,CAAA;CACP;AAED;;;;;GAKG;AAE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GAAG,IAAI,CAAA;CACtC,KACA,iBAKD,CAAA;AAEF,4CAA4C;AAC5C,eAAO,MAAM,qBAAqB,GAChC,OAAO,QAAQ,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,KACnC,uBAID,CAAA;AAEF,uCAAuC;AACvC,eAAO,MAAM,mBAAmB,GAC9B,OAAO,QAAQ,GAAG;IAChB,cAAc,EAAE,MAAM,YAAY,CAAA;IAClC,cAAc,EAAE,WAAW,CAAA;CAC5B,KACA,qBAKD,CAAA;AAEF,wCAAwC;AACxC,eAAO,MAAM,oBAAoB,GAC/B,OAAO,QAAQ,GAAG;IAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;CAAE,KAC3D,sBAID,CAAA;AAEF,+BAA+B;AAC/B,eAAO,MAAM,YAAY,GACvB,OAAO,QAAQ,GAAG;IAChB,MAAM,EAAE,cAAc,GAAG,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,QAWF,CAAA"}
|
package/dist/events.js
CHANGED
|
@@ -56,6 +56,7 @@ export const buildSeenInBlock = (input) => ({
|
|
|
56
56
|
blockNumber: input.blockNumber,
|
|
57
57
|
transactionIndex: input.transactionIndex,
|
|
58
58
|
confirmations: input.confirmations,
|
|
59
|
+
...(input.receipt !== undefined ? { receipt: input.receipt } : {}),
|
|
59
60
|
});
|
|
60
61
|
/**
|
|
61
62
|
* Build a `vanished-from-block` event. Spec §12.3 forbids
|
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","sourceR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C,KAAK,CAAC;IACtB,IAAI,EAAE,iBAAiB;IACvB,cAAc,EAAE,KAAK,CAAC,cAAc;IACpC,cAAc,EAAE,KAAK,CAAC,cAAc;CACrC,CAAC,CAAA;AAEF,wCAAwC;AACxC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,KAA4D,EACpC,EAAE,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,YAAY,EAAE,KAAK,CAAC,YAAY;CACjC,CAAC,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `TxGroupEvent` — composite event union for `tracker.group([...hashes])`
|
|
3
|
+
* cross-tx correlation (spec §18.1, v0.8.0 design F3).
|
|
4
|
+
*
|
|
5
|
+
* Group emits its own kinds (group-progress / group-complete /
|
|
6
|
+
* group-failed / group-stopped) derived from the per-member event
|
|
7
|
+
* streams. Per-member events still flow through the underlying
|
|
8
|
+
* tracker.subscribe path; the group is a synthesis layer on top.
|
|
9
|
+
*
|
|
10
|
+
* Pure data shapes + pure builders. No I/O, no mutation.
|
|
11
|
+
*/
|
|
12
|
+
import type { At, Hash } from './events.js';
|
|
13
|
+
/**
|
|
14
|
+
* Common envelope on every group event. Carries the group identifier
|
|
15
|
+
* and the block coordinate the observation was made at.
|
|
16
|
+
*/
|
|
17
|
+
export interface TxGroupEventEnvelope {
|
|
18
|
+
groupId: string;
|
|
19
|
+
at: At;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Emitted when one or more members of the tracked group have reached
|
|
23
|
+
* inclusion in the canonical chain. `confirmed` is the count of members
|
|
24
|
+
* observed in blocks; `total` is the group size; `lastHash` is the most
|
|
25
|
+
* recently-included member's hash.
|
|
26
|
+
*/
|
|
27
|
+
export interface TxGroupEventProgress extends TxGroupEventEnvelope {
|
|
28
|
+
kind: 'group-progress';
|
|
29
|
+
confirmed: number;
|
|
30
|
+
total: number;
|
|
31
|
+
lastHash: Hash;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* All members of the group have reached inclusion in the canonical
|
|
35
|
+
* chain and none have been replaced or reorged. Final progress event
|
|
36
|
+
* before group stream closes (unless a reorg or replacement occurs).
|
|
37
|
+
*/
|
|
38
|
+
export interface TxGroupEventComplete extends TxGroupEventEnvelope {
|
|
39
|
+
kind: 'group-complete';
|
|
40
|
+
total: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* One member of the group was dropped (unseen for the threshold),
|
|
44
|
+
* failed (reverted or invalid), or replaced by a different tx with
|
|
45
|
+
* the same (from, nonce) pair. `reason` disambiguates the failure mode.
|
|
46
|
+
*/
|
|
47
|
+
export interface TxGroupEventFailed extends TxGroupEventEnvelope {
|
|
48
|
+
kind: 'group-failed';
|
|
49
|
+
failedHash: Hash;
|
|
50
|
+
reason: 'dropped' | 'failed' | 'replaced';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Group subscription was stopped before all members reached inclusion.
|
|
54
|
+
* Fires once per group subscription. Always the final event in the
|
|
55
|
+
* stream for that group.
|
|
56
|
+
*/
|
|
57
|
+
export interface TxGroupEventStopped extends TxGroupEventEnvelope {
|
|
58
|
+
kind: 'group-stopped';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Discriminated union of every group event variant. Narrow on `kind`
|
|
62
|
+
* to access variant-specific fields.
|
|
63
|
+
*/
|
|
64
|
+
export type TxGroupEvent = TxGroupEventProgress | TxGroupEventComplete | TxGroupEventFailed | TxGroupEventStopped;
|
|
65
|
+
/** Build a `group-progress` event. */
|
|
66
|
+
export declare const buildGroupProgress: (input: TxGroupEventEnvelope & {
|
|
67
|
+
confirmed: number;
|
|
68
|
+
total: number;
|
|
69
|
+
lastHash: Hash;
|
|
70
|
+
}) => TxGroupEventProgress;
|
|
71
|
+
/** Build a `group-complete` event. */
|
|
72
|
+
export declare const buildGroupComplete: (input: TxGroupEventEnvelope & {
|
|
73
|
+
total: number;
|
|
74
|
+
}) => TxGroupEventComplete;
|
|
75
|
+
/** Build a `group-failed` event. */
|
|
76
|
+
export declare const buildGroupFailed: (input: TxGroupEventEnvelope & {
|
|
77
|
+
failedHash: Hash;
|
|
78
|
+
reason: "dropped" | "failed" | "replaced";
|
|
79
|
+
}) => TxGroupEventFailed;
|
|
80
|
+
/** Build a `group-stopped` event. */
|
|
81
|
+
export declare const buildGroupStopped: (input: TxGroupEventEnvelope) => TxGroupEventStopped;
|
|
82
|
+
//# sourceMappingURL=group-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-events.d.ts","sourceRoot":"","sources":["../src/group-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAE3C;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,EAAE,EAAE,EAAE,CA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oBAAoB,KAC1B,mBAGD,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `TxGroupEvent` — composite event union for `tracker.group([...hashes])`
|
|
3
|
+
* cross-tx correlation (spec §18.1, v0.8.0 design F3).
|
|
4
|
+
*
|
|
5
|
+
* Group emits its own kinds (group-progress / group-complete /
|
|
6
|
+
* group-failed / group-stopped) derived from the per-member event
|
|
7
|
+
* streams. Per-member events still flow through the underlying
|
|
8
|
+
* tracker.subscribe path; the group is a synthesis layer on top.
|
|
9
|
+
*
|
|
10
|
+
* Pure data shapes + pure builders. No I/O, no mutation.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Build an event envelope from the group context. Used by every builder
|
|
14
|
+
* below so the envelope shape is centralized and always produces a fresh
|
|
15
|
+
* copy (no aliasing).
|
|
16
|
+
*/
|
|
17
|
+
const makeEnvelope = (input) => ({
|
|
18
|
+
groupId: input.groupId,
|
|
19
|
+
at: { blockNumber: input.at.blockNumber, timestamp: input.at.timestamp },
|
|
20
|
+
});
|
|
21
|
+
/** Build a `group-progress` event. */
|
|
22
|
+
export const buildGroupProgress = (input) => ({
|
|
23
|
+
...makeEnvelope(input),
|
|
24
|
+
kind: 'group-progress',
|
|
25
|
+
confirmed: input.confirmed,
|
|
26
|
+
total: input.total,
|
|
27
|
+
lastHash: input.lastHash,
|
|
28
|
+
});
|
|
29
|
+
/** Build a `group-complete` event. */
|
|
30
|
+
export const buildGroupComplete = (input) => ({
|
|
31
|
+
...makeEnvelope(input),
|
|
32
|
+
kind: 'group-complete',
|
|
33
|
+
total: input.total,
|
|
34
|
+
});
|
|
35
|
+
/** Build a `group-failed` event. */
|
|
36
|
+
export const buildGroupFailed = (input) => ({
|
|
37
|
+
...makeEnvelope(input),
|
|
38
|
+
kind: 'group-failed',
|
|
39
|
+
failedHash: input.failedHash,
|
|
40
|
+
reason: input.reason,
|
|
41
|
+
});
|
|
42
|
+
/** Build a `group-stopped` event. */
|
|
43
|
+
export const buildGroupStopped = (input) => ({
|
|
44
|
+
...makeEnvelope(input),
|
|
45
|
+
kind: 'group-stopped',
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=group-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-events.js","sourceRoot":"","sources":["../src/group-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAkEH;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,KAA2B,EAAwB,EAAE,CAAC,CAAC;IAC3E,OAAO,EAAE,KAAK,CAAC,OAAO;IACtB,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE;CACzE,CAAC,CAAA;AAEF,sCAAsC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAAkF,EAC5D,EAAE,CAAC,CAAC;IAC1B,GAAG,YAAY,CAAC,KAAK,CAAC;IACtB,IAAI,EAAE,gBAAgB;IACtB,SAAS,EAAE,KAAK,CAAC,SAAS;IAC1B,KAAK,EAAE,KAAK,CAAC,KAAK;IAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ;CACzB,CAAC,CAAA;AAEF,sCAAsC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAA+C,EACzB,EAAE,CAAC,CAAC;IAC1B,GAAG,YAAY,CAAC,KAAK,CAAC;IACtB,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,KAAK,CAAC,KAAK;CACnB,CAAC,CAAA;AAEF,oCAAoC;AACpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,KAGC,EACmB,EAAE,CAAC,CAAC;IACxB,GAAG,YAAY,CAAC,KAAK,CAAC;IACtB,IAAI,EAAE,cAAc;IACpB,UAAU,EAAE,KAAK,CAAC,UAAU;IAC5B,MAAM,EAAE,KAAK,CAAC,MAAM;CACrB,CAAC,CAAA;AAEF,qCAAqC;AACrC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,KAA2B,EACN,EAAE,CAAC,CAAC;IACzB,GAAG,YAAY,CAAC,KAAK,CAAC;IACtB,IAAI,EAAE,eAAe;CACtB,CAAC,CAAA"}
|
package/dist/group.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createTxGroup` — synthesis layer on top of per-hash tracker
|
|
3
|
+
* subscriptions. Spec §18.1, v0.8.0 design F3.
|
|
4
|
+
*
|
|
5
|
+
* Listens to each member hash via the tracker's existing subscribe API,
|
|
6
|
+
* tracks confirmed/failed counters, and emits group-progress /
|
|
7
|
+
* group-complete / group-failed once per terminal transition. Member
|
|
8
|
+
* unsubscribes are torn down on stop().
|
|
9
|
+
*
|
|
10
|
+
* Replacement does NOT auto-promote — if a member is replaced via
|
|
11
|
+
* same-nonce bump, the group emits group-failed with reason
|
|
12
|
+
* 'replaced'. The consumer constructs a new group with the new hash
|
|
13
|
+
* if they want the replacement to count.
|
|
14
|
+
*
|
|
15
|
+
* Edge case: an empty hashes array immediately emits group-complete
|
|
16
|
+
* with total=0 (vacuously all confirmed) and marks the group terminal.
|
|
17
|
+
* This is a safe, predictable default and matches the mathematical
|
|
18
|
+
* sense of "all zero members confirmed."
|
|
19
|
+
*/
|
|
20
|
+
import type { Hash } from './events.js';
|
|
21
|
+
import type { GroupOptions, TxGroupSubscription, TxTracker } from './tracker.js';
|
|
22
|
+
/**
|
|
23
|
+
* Construct a group subscription that synthesises per-member `TxEvent`
|
|
24
|
+
* streams into group-level events.
|
|
25
|
+
*
|
|
26
|
+
* @param tracker - The tracker instance to call `subscribe` on.
|
|
27
|
+
* @param hashes - Member transaction hashes. Order is not significant.
|
|
28
|
+
* @param options - Optional group-level and member-level overrides.
|
|
29
|
+
*/
|
|
30
|
+
export declare const createTxGroup: (tracker: TxTracker, hashes: Hash[], options?: GroupOptions) => TxGroupSubscription;
|
|
31
|
+
//# sourceMappingURL=group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAqB,MAAM,aAAa,CAAA;AAQ1D,OAAO,KAAK,EACV,YAAY,EAEZ,mBAAmB,EACnB,SAAS,EACV,MAAM,cAAc,CAAA;AAErB;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACxB,SAAS,SAAS,EAClB,QAAQ,IAAI,EAAE,EACd,UAAS,YAAiB,KACzB,mBAyLF,CAAA"}
|
package/dist/group.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createTxGroup` — synthesis layer on top of per-hash tracker
|
|
3
|
+
* subscriptions. Spec §18.1, v0.8.0 design F3.
|
|
4
|
+
*
|
|
5
|
+
* Listens to each member hash via the tracker's existing subscribe API,
|
|
6
|
+
* tracks confirmed/failed counters, and emits group-progress /
|
|
7
|
+
* group-complete / group-failed once per terminal transition. Member
|
|
8
|
+
* unsubscribes are torn down on stop().
|
|
9
|
+
*
|
|
10
|
+
* Replacement does NOT auto-promote — if a member is replaced via
|
|
11
|
+
* same-nonce bump, the group emits group-failed with reason
|
|
12
|
+
* 'replaced'. The consumer constructs a new group with the new hash
|
|
13
|
+
* if they want the replacement to count.
|
|
14
|
+
*
|
|
15
|
+
* Edge case: an empty hashes array immediately emits group-complete
|
|
16
|
+
* with total=0 (vacuously all confirmed) and marks the group terminal.
|
|
17
|
+
* This is a safe, predictable default and matches the mathematical
|
|
18
|
+
* sense of "all zero members confirmed."
|
|
19
|
+
*/
|
|
20
|
+
import { Subscriptions } from '@valve-tech/chain-source';
|
|
21
|
+
import { buildGroupComplete, buildGroupFailed, buildGroupProgress, buildGroupStopped, } from './group-events.js';
|
|
22
|
+
/**
|
|
23
|
+
* Construct a group subscription that synthesises per-member `TxEvent`
|
|
24
|
+
* streams into group-level events.
|
|
25
|
+
*
|
|
26
|
+
* @param tracker - The tracker instance to call `subscribe` on.
|
|
27
|
+
* @param hashes - Member transaction hashes. Order is not significant.
|
|
28
|
+
* @param options - Optional group-level and member-level overrides.
|
|
29
|
+
*/
|
|
30
|
+
export const createTxGroup = (tracker, hashes, options = {}) => {
|
|
31
|
+
const groupId = options.groupId ??
|
|
32
|
+
`grp-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
33
|
+
const memberOptions = options.memberOptions ?? {};
|
|
34
|
+
const subs = new Subscriptions();
|
|
35
|
+
const total = hashes.length;
|
|
36
|
+
const confirmedSet = new Set();
|
|
37
|
+
let terminal = false;
|
|
38
|
+
const memberUnsubs = [];
|
|
39
|
+
const emit = (event) => subs.emit(event);
|
|
40
|
+
// Empty group — vacuously all confirmed. Emit complete immediately
|
|
41
|
+
// (synchronously; no member subscriptions to set up).
|
|
42
|
+
if (total === 0) {
|
|
43
|
+
terminal = true;
|
|
44
|
+
const zeroAt = { blockNumber: 0n, timestamp: 0n };
|
|
45
|
+
emit(buildGroupComplete({ groupId, at: zeroAt, total: 0 }));
|
|
46
|
+
}
|
|
47
|
+
const handleMemberEvent = (memberHash, event) => {
|
|
48
|
+
if (terminal)
|
|
49
|
+
return;
|
|
50
|
+
const at = event.at;
|
|
51
|
+
if (event.kind === 'seen-in-block' && event.confirmations >= 1) {
|
|
52
|
+
// Idempotency guard: same hash can emit multiple seen-in-block
|
|
53
|
+
// events (confirmations 1, 2, 3 …) — only count it once.
|
|
54
|
+
if (confirmedSet.has(memberHash))
|
|
55
|
+
return;
|
|
56
|
+
confirmedSet.add(memberHash);
|
|
57
|
+
if (confirmedSet.size < total) {
|
|
58
|
+
emit(buildGroupProgress({
|
|
59
|
+
groupId,
|
|
60
|
+
at,
|
|
61
|
+
confirmed: confirmedSet.size,
|
|
62
|
+
total,
|
|
63
|
+
lastHash: memberHash,
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
terminal = true;
|
|
68
|
+
emit(buildGroupComplete({ groupId, at, total }));
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (event.kind === 'unseen-for-N-blocks') {
|
|
73
|
+
terminal = true;
|
|
74
|
+
emit(buildGroupFailed({
|
|
75
|
+
groupId,
|
|
76
|
+
at,
|
|
77
|
+
failedHash: memberHash,
|
|
78
|
+
reason: 'dropped',
|
|
79
|
+
}));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (event.kind === 'replaced-by') {
|
|
83
|
+
terminal = true;
|
|
84
|
+
emit(buildGroupFailed({
|
|
85
|
+
groupId,
|
|
86
|
+
at,
|
|
87
|
+
failedHash: memberHash,
|
|
88
|
+
reason: 'replaced',
|
|
89
|
+
}));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
for (const hash of hashes) {
|
|
94
|
+
const unsub = tracker.subscribe(hash, (event) => handleMemberEvent(hash, event), { ...memberOptions, emitInitial: false });
|
|
95
|
+
memberUnsubs.push(unsub);
|
|
96
|
+
}
|
|
97
|
+
let stopped = false;
|
|
98
|
+
const stop = () => {
|
|
99
|
+
if (stopped)
|
|
100
|
+
return;
|
|
101
|
+
stopped = true;
|
|
102
|
+
for (const unsub of memberUnsubs) {
|
|
103
|
+
try {
|
|
104
|
+
unsub();
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// Swallow per-sub teardown errors — we always emit group-stopped.
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
emit(buildGroupStopped({ groupId, at: { blockNumber: 0n, timestamp: 0n } }));
|
|
111
|
+
};
|
|
112
|
+
const snapshot = () => {
|
|
113
|
+
const out = {};
|
|
114
|
+
for (const hash of hashes)
|
|
115
|
+
out[hash] = tracker.getTxStatus(hash);
|
|
116
|
+
return out;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Async-iterable surface over the group event stream. Resolves each
|
|
120
|
+
* `next()` call with the next queued event, or parks the caller in a
|
|
121
|
+
* waiter array until one arrives. Terminal events (group-complete /
|
|
122
|
+
* group-failed / group-stopped) flip `done` so subsequent `next()`
|
|
123
|
+
* calls resolve immediately with `done: true`.
|
|
124
|
+
*/
|
|
125
|
+
const events = () => ({
|
|
126
|
+
[Symbol.asyncIterator]: () => {
|
|
127
|
+
const queue = [];
|
|
128
|
+
const waiters = [];
|
|
129
|
+
let done = false;
|
|
130
|
+
const unsub = subs.subscribe((event) => {
|
|
131
|
+
if (event.kind === 'group-stopped' ||
|
|
132
|
+
event.kind === 'group-complete' ||
|
|
133
|
+
event.kind === 'group-failed') {
|
|
134
|
+
done = true;
|
|
135
|
+
}
|
|
136
|
+
const waiter = waiters.shift();
|
|
137
|
+
if (waiter) {
|
|
138
|
+
waiter({ value: event, done: false });
|
|
139
|
+
if (done) {
|
|
140
|
+
// Drain remaining waiters with done after a terminal event.
|
|
141
|
+
// Reachable when a consumer parks multiple `next()` calls
|
|
142
|
+
// concurrently before any event arrives — first waiter gets
|
|
143
|
+
// the terminal event, the rest resolve with done:true here.
|
|
144
|
+
while (waiters.length > 0) {
|
|
145
|
+
waiters.shift()({
|
|
146
|
+
value: undefined,
|
|
147
|
+
done: true,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
queue.push(event);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return {
|
|
157
|
+
next: () => {
|
|
158
|
+
if (queue.length > 0) {
|
|
159
|
+
const value = queue.shift();
|
|
160
|
+
return Promise.resolve({ value, done: false });
|
|
161
|
+
}
|
|
162
|
+
if (done) {
|
|
163
|
+
return Promise.resolve({
|
|
164
|
+
value: undefined,
|
|
165
|
+
done: true,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return new Promise((resolve) => {
|
|
169
|
+
waiters.push(resolve);
|
|
170
|
+
});
|
|
171
|
+
},
|
|
172
|
+
return: () => {
|
|
173
|
+
unsub();
|
|
174
|
+
done = true;
|
|
175
|
+
while (waiters.length > 0) {
|
|
176
|
+
waiters.shift()({
|
|
177
|
+
value: undefined,
|
|
178
|
+
done: true,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
return Promise.resolve({
|
|
182
|
+
value: undefined,
|
|
183
|
+
done: true,
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
return {
|
|
190
|
+
events,
|
|
191
|
+
subscribe: (cb) => subs.subscribe(cb),
|
|
192
|
+
snapshot,
|
|
193
|
+
stop,
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
//# sourceMappingURL=group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.js","sourceRoot":"","sources":["../src/group.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAGxD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GAElB,MAAM,mBAAmB,CAAA;AAQ1B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,OAAkB,EAClB,MAAc,EACd,UAAwB,EAAE,EACL,EAAE;IACvB,MAAM,OAAO,GACX,OAAO,CAAC,OAAO;QACf,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;IAC/D,MAAM,aAAa,GAAiB,OAAO,CAAC,aAAa,IAAI,EAAE,CAAA;IAC/D,MAAM,IAAI,GAAG,IAAI,aAAa,EAAgB,CAAA;IAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAA;IAC3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,CAAA;AACH,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
* source.stop()
|
|
41
41
|
*/
|
|
42
42
|
export { createTxTracker } from './tracker.js';
|
|
43
|
-
export type { CreateTxTrackerOptions, TxTracker, TrackOptions, BulkTrackOptions, TxMatchEvent, TxSubscription, LostSignalPolicy, } from './tracker.js';
|
|
43
|
+
export type { CreateTxTrackerOptions, TxTracker, TrackOptions, BulkTrackOptions, TxMatchEvent, TxSubscription, LostSignalPolicy, GroupOptions, TxGroupSubscription, } from './tracker.js';
|
|
44
44
|
export { buildStarted, buildSeenInMempool, buildLeftMempool, buildSeenInBlock, buildVanishedFromBlock, buildReplacedBy, buildUnseenForNBlocks, buildSignalDegraded, buildSignalRecovered, buildStopped, buildInitialStatus, } from './events.js';
|
|
45
45
|
export type { Address, At, Envelope, Hash, TxEvent, TxEventStarted, TxEventSeenInMempool, TxEventLeftMempool, TxEventSeenInBlock, TxEventVanishedFromBlock, TxEventReplacedBy, TxEventUnseenForNBlocks, TxEventSignalDegraded, TxEventSignalRecovered, TxEventStopped, TxStatus, } from './events.js';
|
|
46
46
|
export { createInMemoryStore, computeRetentionExpiry, defaultRetentionBlocks, } from './store.js';
|
|
@@ -49,4 +49,15 @@ export { appendBlock, defaultReorgDepthBlocks, detectDivergences, } from './reor
|
|
|
49
49
|
export type { BlockDivergence, BlockSample } from './reorg.js';
|
|
50
50
|
export { compileSelector, defaultMaxBulkSubscriptions, matchAll, } from './selectors.js';
|
|
51
51
|
export type { BulkMatchPayload, CompiledSelector } from './selectors.js';
|
|
52
|
+
export { createTxGroup } from './group.js';
|
|
53
|
+
export { watchTransaction } from './watch-transaction.js';
|
|
54
|
+
export type { WatchTransactionOptions } from './watch-transaction.js';
|
|
55
|
+
export { waitForTransaction } from './wait-for-transaction.js';
|
|
56
|
+
export type { WaitForTransactionOptions, WaitForTransactionOutcome, } from './wait-for-transaction.js';
|
|
57
|
+
export { waitForPending, WaitForPendingTimeoutError, } from './wait-for-pending.js';
|
|
58
|
+
export type { WaitForPendingOptions } from './wait-for-pending.js';
|
|
59
|
+
export { buildGroupComplete, buildGroupFailed, buildGroupProgress, buildGroupStopped, } from './group-events.js';
|
|
60
|
+
export type { TxGroupEvent, TxGroupEventComplete, TxGroupEventEnvelope, TxGroupEventFailed, TxGroupEventProgress, TxGroupEventStopped, } from './group-events.js';
|
|
61
|
+
export { replaceTransaction } from './replace-transaction.js';
|
|
62
|
+
export type { ReplaceTransactionNewGas, ReplaceTransactionOptions, ReplaceTransactionOriginal, } from './replace-transaction.js';
|
|
52
63
|
//# sourceMappingURL=index.d.ts.map
|
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,
|
|
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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YAAY,EACV,YAAY,EACZ,oBAAoB,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"}
|
package/dist/index.js
CHANGED
|
@@ -44,4 +44,10 @@ export { buildStarted, buildSeenInMempool, buildLeftMempool, buildSeenInBlock, b
|
|
|
44
44
|
export { createInMemoryStore, computeRetentionExpiry, defaultRetentionBlocks, } from './store.js';
|
|
45
45
|
export { appendBlock, defaultReorgDepthBlocks, detectDivergences, } from './reorg.js';
|
|
46
46
|
export { compileSelector, defaultMaxBulkSubscriptions, matchAll, } from './selectors.js';
|
|
47
|
+
export { createTxGroup } from './group.js';
|
|
48
|
+
export { watchTransaction } from './watch-transaction.js';
|
|
49
|
+
export { waitForTransaction } from './wait-for-transaction.js';
|
|
50
|
+
export { waitForPending, WaitForPendingTimeoutError, } from './wait-for-pending.js';
|
|
51
|
+
export { buildGroupComplete, buildGroupFailed, buildGroupProgress, buildGroupStopped, } from './group-events.js';
|
|
52
|
+
export { replaceTransaction } from './replace-transaction.js';
|
|
47
53
|
//# sourceMappingURL=index.js.map
|
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;AAa9C,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;AAoBpB,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"}
|
package/dist/observations.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* to its mutable `TrackedRecord`, then emits the returned `events`
|
|
18
18
|
* via its event-bus + store-audit-log machinery.
|
|
19
19
|
*/
|
|
20
|
-
import type { EventSource, RawTx } from '@valve-tech/chain-source';
|
|
20
|
+
import type { EventSource, RawTx, TransactionReceipt } from '@valve-tech/chain-source';
|
|
21
21
|
import { type At, type Hash, type TxEvent, type TxStatus } from './events.js';
|
|
22
22
|
/**
|
|
23
23
|
* Read-only projection of `TrackedRecord` that the decision functions
|
|
@@ -76,6 +76,16 @@ export interface BlockObservationInput {
|
|
|
76
76
|
* very first block we observe.
|
|
77
77
|
*/
|
|
78
78
|
previousTipNumber: bigint | null;
|
|
79
|
+
/**
|
|
80
|
+
* Pre-fetched receipts for hashes whose `withReceipts` flag is set.
|
|
81
|
+
* When a hash appears in this map, the receipt is attached to the
|
|
82
|
+
* `seen-in-block` event. Omitted or empty means no enrichment. This
|
|
83
|
+
* is the sole path for F2 eager receipt attachment (spec §18.2) —
|
|
84
|
+
* the orchestrator fetches and populates this map before calling
|
|
85
|
+
* `decideBlockObservation`, so the first emitted event carries the
|
|
86
|
+
* receipt without a follow-up re-emit.
|
|
87
|
+
*/
|
|
88
|
+
prefetchedReceipts?: ReadonlyMap<Hash, TransactionReceipt>;
|
|
79
89
|
}
|
|
80
90
|
/**
|
|
81
91
|
* 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,MAAM,0BAA0B,CAAA;
|
|
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,EAML,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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