UNPKG

@azuro-org/sdk

Version:

One-stop solution for building betting dApps on the Azuro Protocol.

38 lines (37 loc) 1.78 kB
import { ConditionState } from '@azuro-org/toolkit'; export type UseConditionStateProps = { conditionId: string; initialState?: ConditionState; isInitiallyHidden?: boolean; }; /** * Watch real-time condition state updates for a single condition. * Subscribes to condition updates via websocket and tracks state changes (Active, Stopped, Resolved, etc.). * Requires `FeedSocketProvider` and `ConditionUpdatesProvider` (both are included in `AzuroSDKProvider`). * * Returns `isLocked` helper to check if the condition is not Active. * Returns `isHidden` helper to check if the condition may be hidden from the list of game markets. * * The `isHidden` field indicates whether a condition may be hidden from the game markets list. * It starts as `true` for stopped secondary conditions in `ConditionDetailedData`. * When a socket update arrives for a hidden condition, it is set back to `false` — * meaning the condition is still alive and was only temporarily stopped by the provider. * * - Docs: https://gem.azuro.org/hub/apps/sdk/watch/useConditionState * * @example * import { useConditionState } from '@azuro-org/sdk' * import { ConditionState, type ConditionDetailedData } from '@azuro-org/toolkit' * * const { data: state, isLocked, isFetching } = useConditionState({ * conditionId: condition.conditionId, * initialState: condition.state, // ConditionState.Active, ConditionState.Stopped, etc. * isInitiallyHidden: condition.hidden, // boolean, comes from API ConditionDetailedData['hidden'] * }) * */ export declare const useConditionState: ({ conditionId, initialState, isInitiallyHidden }: UseConditionStateProps) => { data: ConditionState; isHidden: boolean | undefined; isLocked: boolean; isFetching: boolean; };