@agg-build/hooks 2.1.3 → 2.2.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/dist/index.d.mts +10 -6
- package/dist/index.d.ts +10 -6
- package/dist/index.js +12 -3
- package/dist/index.mjs +12 -3
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -237,7 +237,8 @@ type VenueMarket = {
|
|
|
237
237
|
question: string;
|
|
238
238
|
venueMarketOutcomes: {
|
|
239
239
|
id: string;
|
|
240
|
-
|
|
240
|
+
/** REMOVED — no longer returned; use GET /midpoints for live prices. */
|
|
241
|
+
price?: number | undefined;
|
|
241
242
|
venueMarketId: string;
|
|
242
243
|
label: string;
|
|
243
244
|
title?: string | null | undefined;
|
|
@@ -291,7 +292,8 @@ type VenueMarket = {
|
|
|
291
292
|
conditionId?: string | null | undefined;
|
|
292
293
|
venueMarketOutcomes?: {
|
|
293
294
|
id: string;
|
|
294
|
-
|
|
295
|
+
/** REMOVED — no longer returned; use GET /midpoints for live prices. */
|
|
296
|
+
price?: number | undefined;
|
|
295
297
|
venueMarketId: string;
|
|
296
298
|
label: string;
|
|
297
299
|
winner?: boolean | null | undefined;
|
|
@@ -383,7 +385,12 @@ type MatchedVenueMarketOutcomeRef = {
|
|
|
383
385
|
};
|
|
384
386
|
type VenueMarketOutcome = {
|
|
385
387
|
id: string;
|
|
386
|
-
|
|
388
|
+
/**
|
|
389
|
+
* REMOVED — /venue-events and /venue-markets no longer return outcome
|
|
390
|
+
* prices. Fetch live prices from GET /midpoints (or the live-price hooks),
|
|
391
|
+
* keyed by this outcome's `id`.
|
|
392
|
+
*/
|
|
393
|
+
price?: number | undefined;
|
|
387
394
|
venueMarketId: string;
|
|
388
395
|
label: string;
|
|
389
396
|
title?: string | null | undefined;
|
|
@@ -3416,9 +3423,6 @@ declare function useLiveMarketStores(venueMarketIds: string[]): CandleBuilder[];
|
|
|
3416
3423
|
* on `agg.orderbook.outcome`). The midpoint from each outcome's book is its
|
|
3417
3424
|
* price — no complement derivation needed.
|
|
3418
3425
|
*
|
|
3419
|
-
* Falls back to the static `outcome.price` from the event payload when no
|
|
3420
|
-
* live data is available.
|
|
3421
|
-
*
|
|
3422
3426
|
* Returns a stable Map<outcomeId, price> that updates only when cache entries
|
|
3423
3427
|
* change.
|
|
3424
3428
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -237,7 +237,8 @@ type VenueMarket = {
|
|
|
237
237
|
question: string;
|
|
238
238
|
venueMarketOutcomes: {
|
|
239
239
|
id: string;
|
|
240
|
-
|
|
240
|
+
/** REMOVED — no longer returned; use GET /midpoints for live prices. */
|
|
241
|
+
price?: number | undefined;
|
|
241
242
|
venueMarketId: string;
|
|
242
243
|
label: string;
|
|
243
244
|
title?: string | null | undefined;
|
|
@@ -291,7 +292,8 @@ type VenueMarket = {
|
|
|
291
292
|
conditionId?: string | null | undefined;
|
|
292
293
|
venueMarketOutcomes?: {
|
|
293
294
|
id: string;
|
|
294
|
-
|
|
295
|
+
/** REMOVED — no longer returned; use GET /midpoints for live prices. */
|
|
296
|
+
price?: number | undefined;
|
|
295
297
|
venueMarketId: string;
|
|
296
298
|
label: string;
|
|
297
299
|
winner?: boolean | null | undefined;
|
|
@@ -383,7 +385,12 @@ type MatchedVenueMarketOutcomeRef = {
|
|
|
383
385
|
};
|
|
384
386
|
type VenueMarketOutcome = {
|
|
385
387
|
id: string;
|
|
386
|
-
|
|
388
|
+
/**
|
|
389
|
+
* REMOVED — /venue-events and /venue-markets no longer return outcome
|
|
390
|
+
* prices. Fetch live prices from GET /midpoints (or the live-price hooks),
|
|
391
|
+
* keyed by this outcome's `id`.
|
|
392
|
+
*/
|
|
393
|
+
price?: number | undefined;
|
|
387
394
|
venueMarketId: string;
|
|
388
395
|
label: string;
|
|
389
396
|
title?: string | null | undefined;
|
|
@@ -3416,9 +3423,6 @@ declare function useLiveMarketStores(venueMarketIds: string[]): CandleBuilder[];
|
|
|
3416
3423
|
* on `agg.orderbook.outcome`). The midpoint from each outcome's book is its
|
|
3417
3424
|
* price — no complement derivation needed.
|
|
3418
3425
|
*
|
|
3419
|
-
* Falls back to the static `outcome.price` from the event payload when no
|
|
3420
|
-
* live data is available.
|
|
3421
|
-
*
|
|
3422
3426
|
* Returns a stable Map<outcomeId, price> that updates only when cache entries
|
|
3423
3427
|
* change.
|
|
3424
3428
|
*/
|
package/dist/index.js
CHANGED
|
@@ -6178,7 +6178,6 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
6178
6178
|
for (const vm of venueMarkets) {
|
|
6179
6179
|
for (const outcome of (_d = vm.venueMarketOutcomes) != null ? _d : []) {
|
|
6180
6180
|
if (!enableLiveUpdates) {
|
|
6181
|
-
prices.set(outcome.id, outcome.price);
|
|
6182
6181
|
continue;
|
|
6183
6182
|
}
|
|
6184
6183
|
const liveMidpoint = liveByOutcomeId.get(outcome.id);
|
|
@@ -7665,11 +7664,11 @@ function mergeEventWithFullMarkets(event, fullMarkets) {
|
|
|
7665
7664
|
return __spreadProps(__spreadValues({}, event), { venueMarkets: mergedMarkets });
|
|
7666
7665
|
}
|
|
7667
7666
|
function useEnrichedVenueEvent(options) {
|
|
7668
|
-
var _b;
|
|
7667
|
+
var _b, _c;
|
|
7669
7668
|
const _a = useVenueEvent(options), { event, isLoading, error } = _a, rest = __objRest(_a, ["event", "isLoading", "error"]);
|
|
7670
7669
|
const eventEndedAt = (event == null ? void 0 : event.endDate) && Number.isFinite(Date.parse(event.endDate)) ? Date.parse(event.endDate) : null;
|
|
7671
7670
|
const shouldFetchOnlyOpenMarkets = eventEndedAt == null || eventEndedAt >= Date.now();
|
|
7672
|
-
const { markets, isLoading:
|
|
7671
|
+
const { markets: openMarkets, isLoading: isEnrichingOpenMarkets } = useVenueMarkets({
|
|
7673
7672
|
venueEventId: options.eventId,
|
|
7674
7673
|
enabled: ((_b = options.enabled) != null ? _b : true) && !!event,
|
|
7675
7674
|
status: shouldFetchOnlyOpenMarkets ? "open" /* open */ : void 0
|
|
@@ -7678,6 +7677,16 @@ function useEnrichedVenueEvent(options) {
|
|
|
7678
7677
|
// MarketDetailsList preserves the shared React Query cache key and the
|
|
7679
7678
|
// event-type ordering.
|
|
7680
7679
|
});
|
|
7680
|
+
const shouldFetchAllMarketsFallback = ((_c = options.enabled) != null ? _c : true) && !!event && shouldFetchOnlyOpenMarkets && !isEnrichingOpenMarkets && openMarkets.length === 0;
|
|
7681
|
+
const { markets: fallbackMarkets, isLoading: isEnrichingFallbackMarkets } = useVenueMarkets({
|
|
7682
|
+
venueEventId: options.eventId,
|
|
7683
|
+
enabled: shouldFetchAllMarketsFallback
|
|
7684
|
+
// No status filter on fallback: if an active event temporarily has only
|
|
7685
|
+
// closed/resolved markets, still render the event page instead of the
|
|
7686
|
+
// unavailable state.
|
|
7687
|
+
});
|
|
7688
|
+
const markets = fallbackMarkets.length > 0 ? fallbackMarkets : openMarkets;
|
|
7689
|
+
const isEnriching = isEnrichingOpenMarkets || isEnrichingFallbackMarkets;
|
|
7681
7690
|
const enrichedEvent = (0, import_react34.useMemo)(() => {
|
|
7682
7691
|
if (!event) return void 0;
|
|
7683
7692
|
if (markets.length === 0) return event;
|
package/dist/index.mjs
CHANGED
|
@@ -981,7 +981,6 @@ function useLiveOutcomePrices(venueMarkets) {
|
|
|
981
981
|
for (const vm of venueMarkets) {
|
|
982
982
|
for (const outcome of (_d = vm.venueMarketOutcomes) != null ? _d : []) {
|
|
983
983
|
if (!enableLiveUpdates) {
|
|
984
|
-
prices.set(outcome.id, outcome.price);
|
|
985
984
|
continue;
|
|
986
985
|
}
|
|
987
986
|
const liveMidpoint = liveByOutcomeId.get(outcome.id);
|
|
@@ -2473,11 +2472,11 @@ function mergeEventWithFullMarkets(event, fullMarkets) {
|
|
|
2473
2472
|
return __spreadProps(__spreadValues({}, event), { venueMarkets: mergedMarkets });
|
|
2474
2473
|
}
|
|
2475
2474
|
function useEnrichedVenueEvent(options) {
|
|
2476
|
-
var _b;
|
|
2475
|
+
var _b, _c;
|
|
2477
2476
|
const _a = useVenueEvent(options), { event, isLoading, error } = _a, rest = __objRest(_a, ["event", "isLoading", "error"]);
|
|
2478
2477
|
const eventEndedAt = (event == null ? void 0 : event.endDate) && Number.isFinite(Date.parse(event.endDate)) ? Date.parse(event.endDate) : null;
|
|
2479
2478
|
const shouldFetchOnlyOpenMarkets = eventEndedAt == null || eventEndedAt >= Date.now();
|
|
2480
|
-
const { markets, isLoading:
|
|
2479
|
+
const { markets: openMarkets, isLoading: isEnrichingOpenMarkets } = useVenueMarkets({
|
|
2481
2480
|
venueEventId: options.eventId,
|
|
2482
2481
|
enabled: ((_b = options.enabled) != null ? _b : true) && !!event,
|
|
2483
2482
|
status: shouldFetchOnlyOpenMarkets ? "open" /* open */ : void 0
|
|
@@ -2486,6 +2485,16 @@ function useEnrichedVenueEvent(options) {
|
|
|
2486
2485
|
// MarketDetailsList preserves the shared React Query cache key and the
|
|
2487
2486
|
// event-type ordering.
|
|
2488
2487
|
});
|
|
2488
|
+
const shouldFetchAllMarketsFallback = ((_c = options.enabled) != null ? _c : true) && !!event && shouldFetchOnlyOpenMarkets && !isEnrichingOpenMarkets && openMarkets.length === 0;
|
|
2489
|
+
const { markets: fallbackMarkets, isLoading: isEnrichingFallbackMarkets } = useVenueMarkets({
|
|
2490
|
+
venueEventId: options.eventId,
|
|
2491
|
+
enabled: shouldFetchAllMarketsFallback
|
|
2492
|
+
// No status filter on fallback: if an active event temporarily has only
|
|
2493
|
+
// closed/resolved markets, still render the event page instead of the
|
|
2494
|
+
// unavailable state.
|
|
2495
|
+
});
|
|
2496
|
+
const markets = fallbackMarkets.length > 0 ? fallbackMarkets : openMarkets;
|
|
2497
|
+
const isEnriching = isEnrichingOpenMarkets || isEnrichingFallbackMarkets;
|
|
2489
2498
|
const enrichedEvent = useMemo10(() => {
|
|
2490
2499
|
if (!event) return void 0;
|
|
2491
2500
|
if (markets.length === 0) return event;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agg-build/hooks",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "React hooks and providers for the AGG prediction market aggregator. Wraps @agg-build/sdk with TanStack Query, shared session state, and live WebSocket data.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"react": "^18.0.0 || ^19.0.0",
|
|
84
84
|
"viem": "^2.0.0",
|
|
85
85
|
"wagmi": "^3.0.0 || ^2.0.0",
|
|
86
|
-
"@agg-build/sdk": "^2.
|
|
86
|
+
"@agg-build/sdk": "^2.2.0"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@solana/wallet-adapter-react": {
|