@nori-zk/mina-token-bridge
Version:
Nori ethereum state settelment and nETH token bridge zkApp
54 lines • 2.6 kB
JavaScript
import { filter, map, shareReplay } from 'rxjs';
/**
* Returns an observable emitting the bridge's current processing state.
*
* Filters for messages from the `state.bridge` topic, ignoring any with `elapsed_sec`
* set to `'unknown'`, as those do not represent valid state data.
*
* The observable emits objects containing the current stage, slot/block input/output
* positions, elapsed time in seconds, and details about the last finalized job—
* if known.
*
* The stream is shared and replayed to all subscribers using `shareReplay(1)`.
*
* @param bridgeSocket$ WebSocket connection to the bridge service.
* @returns Observable emitting bridge state updates.
*/
export const getBridgeStateTopic$ = (bridgeSocket$) => bridgeSocket$.asObservable().pipe(
// Filter by topic and suppress events when the state is 'unknown'
filter((message) => message.topic === 'state.bridge' &&
message.extension.elapsed_sec !== 'unknown'), map((message) => message.extension)).pipe(shareReplay(1));
/**
* Returns an observable emitting bridge timing data related to transition notices.
*
* Filters for messages from the `timings.notices.transition` topic.
* Emits raw transition timing metadata from the bridge without transformation.
*
* The stream is shared and replayed to all subscribers using `shareReplay(1)`.
*
* @param bridgeSocket$ WebSocket connection to the bridge service.
* @returns Observable emitting transition timing updates.
*/
export const getBridgeTimingsTopic$ = (bridgeSocket$) => bridgeSocket$
.asObservable()
.pipe(
// Filter by topic and suppress events when the state is 'unknown'
filter((message) => message.topic === 'timings.notices.transition'))
.pipe(shareReplay(1));
/**
* Returns an observable emitting the current Ethereum finality state.
*
* Filters for messages from the `state.eth` topic, discarding any with
* `latest_finality_block_number` set to `'unknown'`.
*
* Emits the latest known finality slot and block number from the Ethereum network.
* The stream is shared and replayed to all subscribers using `shareReplay(1)`.
*
* @param bridgeSocket$ WebSocket connection to the bridge service.
* @returns Observable emitting Ethereum finality state updates.
*/
export const getEthStateTopic$ = (bridgeSocket$) => bridgeSocket$.asObservable().pipe(
// Filter by topic and suppress events when the state is 'unknown'
filter((message) => message.topic === 'state.eth' &&
message.extension.latest_finality_block_number !== 'unknown'), map((message) => message.extension)).pipe(shareReplay(1));
//# sourceMappingURL=topics.js.map