@agg-build/ui 2.1.0 → 2.1.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/dist/{chunk-C5M2OOM3.mjs → chunk-5RBHMMY3.mjs} +1 -1
- package/dist/{chunk-YMVD6Q2A.mjs → chunk-75AMJAWR.mjs} +1 -1
- package/dist/{chunk-Y6PVXAUQ.mjs → chunk-7ZR5JYB3.mjs} +423 -488
- package/dist/{chunk-R6FBYAY5.mjs → chunk-JJDYOBVG.mjs} +117 -48
- package/dist/{chunk-3OI2ZLLT.mjs → chunk-NRNBJPYK.mjs} +1 -1
- package/dist/{chunk-DXF2LMNN.mjs → chunk-TBD3N4T4.mjs} +849 -759
- package/dist/{chunk-YAEA6EDG.mjs → chunk-ZOECARZW.mjs} +364 -17
- package/dist/events.js +1115 -972
- package/dist/events.mjs +3 -3
- package/dist/index.js +3705 -3278
- package/dist/index.mjs +16 -8
- package/dist/modals.js +851 -824
- package/dist/modals.mjs +3 -3
- package/dist/pages.js +2778 -2357
- package/dist/pages.mjs +8 -6
- package/dist/primitives.js +849 -759
- package/dist/primitives.mjs +3 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1 -1
- package/dist/trading.js +970 -599
- package/dist/trading.mjs +10 -6
- package/dist/types/events/shared/format-event-title.d.mts +25 -0
- package/dist/types/events/shared/format-event-title.d.ts +25 -0
- package/dist/types/events/shared/select-best-outcome.d.mts +88 -0
- package/dist/types/events/shared/select-best-outcome.d.ts +88 -0
- package/dist/types/pages/event-market/event-market.types.d.mts +7 -0
- package/dist/types/pages/event-market/event-market.types.d.ts +7 -0
- package/dist/types/pages/user-profile/index.d.mts +1 -0
- package/dist/types/pages/user-profile/index.d.ts +1 -0
- package/dist/types/pages/user-profile/transaction-explorer.d.mts +1 -0
- package/dist/types/pages/user-profile/transaction-explorer.d.ts +1 -0
- package/dist/types/pages/user-profile/user-profile.types.d.mts +8 -2
- package/dist/types/pages/user-profile/user-profile.types.d.ts +8 -2
- package/dist/types/primitives/icon/index.d.mts +2 -1
- package/dist/types/primitives/icon/index.d.ts +2 -1
- package/dist/types/primitives/icon/registry.d.mts +4 -0
- package/dist/types/primitives/icon/registry.d.ts +4 -0
- package/dist/types/primitives/icon/svg/paper-mode.d.mts +5 -0
- package/dist/types/primitives/icon/svg/paper-mode.d.ts +5 -0
- package/dist/types/primitives/search/search.utils.d.mts +3 -1
- package/dist/types/primitives/search/search.utils.d.ts +3 -1
- package/dist/types/trading/index.d.mts +2 -0
- package/dist/types/trading/index.d.ts +2 -0
- package/dist/types/trading/place-order/index.d.mts +1 -1
- package/dist/types/trading/place-order/index.d.ts +1 -1
- package/dist/types/trading/place-order/index.place-order.types.d.mts +23 -1
- package/dist/types/trading/place-order/index.place-order.types.d.ts +23 -1
- package/dist/types/trading/use-claim-winnings.d.mts +84 -0
- package/dist/types/trading/use-claim-winnings.d.ts +84 -0
- package/dist/types/trading/use-resolved-market-claim.d.mts +26 -0
- package/dist/types/trading/use-resolved-market-claim.d.ts +26 -0
- package/package.json +3 -3
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape of the `notifications.claim` label block consumed by the claim flow.
|
|
3
|
+
* Mirrors the typed labels so callers can reason about the toast copy.
|
|
4
|
+
*/
|
|
5
|
+
export type ClaimNotificationLabels = {
|
|
6
|
+
pendingTitle: string;
|
|
7
|
+
pendingMessage: string;
|
|
8
|
+
submittedTitle: string;
|
|
9
|
+
submittedMessage: string;
|
|
10
|
+
successTitle: string;
|
|
11
|
+
successMessage: string;
|
|
12
|
+
partialTitle: string;
|
|
13
|
+
partialMessage: (errorReason?: string) => string;
|
|
14
|
+
failedTitle: string;
|
|
15
|
+
failedMessage: (errorReason?: string) => string;
|
|
16
|
+
missingOutcomeMessage: string;
|
|
17
|
+
};
|
|
18
|
+
/** Terminal lifecycle summary forwarded to `onClaimResult`. */
|
|
19
|
+
export type ClaimLifecycleResult = {
|
|
20
|
+
allConfirmed: boolean;
|
|
21
|
+
anyFailed: boolean;
|
|
22
|
+
errorMessage: string | null;
|
|
23
|
+
};
|
|
24
|
+
/** A single claim request keyed by `claimKey`. */
|
|
25
|
+
export type ClaimWinningsInput<TPayload = void> = {
|
|
26
|
+
/** Stable identifier for the position being claimed (e.g. `marketId`). */
|
|
27
|
+
claimKey: string;
|
|
28
|
+
/** Winning venue-market-outcome ids to redeem. */
|
|
29
|
+
winningOutcomeIds: string[];
|
|
30
|
+
/** Opaque payload forwarded verbatim to a caller-provided `onClaim`. */
|
|
31
|
+
payload?: TPayload;
|
|
32
|
+
};
|
|
33
|
+
export type UseClaimWinningsOptions<TPayload = void> = {
|
|
34
|
+
/**
|
|
35
|
+
* Caller-owned claim handler. When provided, the hook delegates the actual
|
|
36
|
+
* redeem to this callback and toasts a simple pending → success/failure
|
|
37
|
+
* lifecycle (no WS lifecycle tracking). Partners who own the claim flow pass
|
|
38
|
+
* this; omit it to let the hook drive the internal redeem mutation.
|
|
39
|
+
*/
|
|
40
|
+
onClaim?: (payload: TPayload) => Promise<void> | void;
|
|
41
|
+
/**
|
|
42
|
+
* Fired once per redeem when its WS lifecycle reaches terminal. Only fired on
|
|
43
|
+
* the internal claim path (i.e. when `onClaim` is omitted).
|
|
44
|
+
*/
|
|
45
|
+
onClaimResult?: (claimKey: string, lifecycle: ClaimLifecycleResult) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Fired when the redeem mutation itself rejects (transport error, validation
|
|
48
|
+
* error, or all legs ineligible/rejected at submit time). The redeem never
|
|
49
|
+
* enters the WS lifecycle in these cases, so `onClaimResult` does NOT fire.
|
|
50
|
+
*/
|
|
51
|
+
onClaimSubmitError?: (claimKey: string, error: Error) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Caller-owned spinner map. When provided, it fully replaces the hook's
|
|
54
|
+
* lifecycle-derived spinner state for display purposes (mirrors the legacy
|
|
55
|
+
* `claimingPositionKeys ?? internal` behavior).
|
|
56
|
+
*/
|
|
57
|
+
externalClaimingKeys?: Record<string, boolean>;
|
|
58
|
+
};
|
|
59
|
+
export type UseClaimWinningsResult<TPayload = void> = {
|
|
60
|
+
/** Start a claim for a single position. Resolves once the submit settles. */
|
|
61
|
+
claim: (input: ClaimWinningsInput<TPayload>) => Promise<void>;
|
|
62
|
+
/** Map of claim key → in-flight flag, suitable to pass to a row renderer. */
|
|
63
|
+
claimingKeys: Record<string, boolean>;
|
|
64
|
+
/** Whether a given claim key is currently in-flight (submit or lifecycle). */
|
|
65
|
+
isClaiming: (claimKey: string) => boolean;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Encapsulates the full "claim winnings" (redeem) lifecycle so multiple
|
|
69
|
+
* surfaces (the profile positions list, the resolved market trade panel) can
|
|
70
|
+
* share one implementation instead of duplicating the redeem → WS lifecycle →
|
|
71
|
+
* toast → cache-invalidation orchestration.
|
|
72
|
+
*
|
|
73
|
+
* The flow has two paths:
|
|
74
|
+
* - **Internal** (`onClaim` omitted): submit via the redeem mutation, bucket
|
|
75
|
+
* the response legs (submitted / confirmed / ineligible / rejected), track
|
|
76
|
+
* EVM async legs through their WS lifecycle, and toast pending → submitted →
|
|
77
|
+
* success/partial/failed.
|
|
78
|
+
* - **Delegated** (`onClaim` provided): the caller performs the redeem; the
|
|
79
|
+
* hook only toasts pending → success/failure.
|
|
80
|
+
*
|
|
81
|
+
* Both paths invalidate balances, positions, the claimable count, the activity
|
|
82
|
+
* feed, and the current-user query so dependent UI refreshes.
|
|
83
|
+
*/
|
|
84
|
+
export declare function useClaimWinnings<TPayload = void>(options?: UseClaimWinningsOptions<TPayload>): UseClaimWinningsResult<TPayload>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape of the `notifications.claim` label block consumed by the claim flow.
|
|
3
|
+
* Mirrors the typed labels so callers can reason about the toast copy.
|
|
4
|
+
*/
|
|
5
|
+
export type ClaimNotificationLabels = {
|
|
6
|
+
pendingTitle: string;
|
|
7
|
+
pendingMessage: string;
|
|
8
|
+
submittedTitle: string;
|
|
9
|
+
submittedMessage: string;
|
|
10
|
+
successTitle: string;
|
|
11
|
+
successMessage: string;
|
|
12
|
+
partialTitle: string;
|
|
13
|
+
partialMessage: (errorReason?: string) => string;
|
|
14
|
+
failedTitle: string;
|
|
15
|
+
failedMessage: (errorReason?: string) => string;
|
|
16
|
+
missingOutcomeMessage: string;
|
|
17
|
+
};
|
|
18
|
+
/** Terminal lifecycle summary forwarded to `onClaimResult`. */
|
|
19
|
+
export type ClaimLifecycleResult = {
|
|
20
|
+
allConfirmed: boolean;
|
|
21
|
+
anyFailed: boolean;
|
|
22
|
+
errorMessage: string | null;
|
|
23
|
+
};
|
|
24
|
+
/** A single claim request keyed by `claimKey`. */
|
|
25
|
+
export type ClaimWinningsInput<TPayload = void> = {
|
|
26
|
+
/** Stable identifier for the position being claimed (e.g. `marketId`). */
|
|
27
|
+
claimKey: string;
|
|
28
|
+
/** Winning venue-market-outcome ids to redeem. */
|
|
29
|
+
winningOutcomeIds: string[];
|
|
30
|
+
/** Opaque payload forwarded verbatim to a caller-provided `onClaim`. */
|
|
31
|
+
payload?: TPayload;
|
|
32
|
+
};
|
|
33
|
+
export type UseClaimWinningsOptions<TPayload = void> = {
|
|
34
|
+
/**
|
|
35
|
+
* Caller-owned claim handler. When provided, the hook delegates the actual
|
|
36
|
+
* redeem to this callback and toasts a simple pending → success/failure
|
|
37
|
+
* lifecycle (no WS lifecycle tracking). Partners who own the claim flow pass
|
|
38
|
+
* this; omit it to let the hook drive the internal redeem mutation.
|
|
39
|
+
*/
|
|
40
|
+
onClaim?: (payload: TPayload) => Promise<void> | void;
|
|
41
|
+
/**
|
|
42
|
+
* Fired once per redeem when its WS lifecycle reaches terminal. Only fired on
|
|
43
|
+
* the internal claim path (i.e. when `onClaim` is omitted).
|
|
44
|
+
*/
|
|
45
|
+
onClaimResult?: (claimKey: string, lifecycle: ClaimLifecycleResult) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Fired when the redeem mutation itself rejects (transport error, validation
|
|
48
|
+
* error, or all legs ineligible/rejected at submit time). The redeem never
|
|
49
|
+
* enters the WS lifecycle in these cases, so `onClaimResult` does NOT fire.
|
|
50
|
+
*/
|
|
51
|
+
onClaimSubmitError?: (claimKey: string, error: Error) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Caller-owned spinner map. When provided, it fully replaces the hook's
|
|
54
|
+
* lifecycle-derived spinner state for display purposes (mirrors the legacy
|
|
55
|
+
* `claimingPositionKeys ?? internal` behavior).
|
|
56
|
+
*/
|
|
57
|
+
externalClaimingKeys?: Record<string, boolean>;
|
|
58
|
+
};
|
|
59
|
+
export type UseClaimWinningsResult<TPayload = void> = {
|
|
60
|
+
/** Start a claim for a single position. Resolves once the submit settles. */
|
|
61
|
+
claim: (input: ClaimWinningsInput<TPayload>) => Promise<void>;
|
|
62
|
+
/** Map of claim key → in-flight flag, suitable to pass to a row renderer. */
|
|
63
|
+
claimingKeys: Record<string, boolean>;
|
|
64
|
+
/** Whether a given claim key is currently in-flight (submit or lifecycle). */
|
|
65
|
+
isClaiming: (claimKey: string) => boolean;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Encapsulates the full "claim winnings" (redeem) lifecycle so multiple
|
|
69
|
+
* surfaces (the profile positions list, the resolved market trade panel) can
|
|
70
|
+
* share one implementation instead of duplicating the redeem → WS lifecycle →
|
|
71
|
+
* toast → cache-invalidation orchestration.
|
|
72
|
+
*
|
|
73
|
+
* The flow has two paths:
|
|
74
|
+
* - **Internal** (`onClaim` omitted): submit via the redeem mutation, bucket
|
|
75
|
+
* the response legs (submitted / confirmed / ineligible / rejected), track
|
|
76
|
+
* EVM async legs through their WS lifecycle, and toast pending → submitted →
|
|
77
|
+
* success/partial/failed.
|
|
78
|
+
* - **Delegated** (`onClaim` provided): the caller performs the redeem; the
|
|
79
|
+
* hook only toasts pending → success/failure.
|
|
80
|
+
*
|
|
81
|
+
* Both paths invalidate balances, positions, the claimable count, the activity
|
|
82
|
+
* feed, and the current-user query so dependent UI refreshes.
|
|
83
|
+
*/
|
|
84
|
+
export declare function useClaimWinnings<TPayload = void>(options?: UseClaimWinningsOptions<TPayload>): UseClaimWinningsResult<TPayload>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type VenueMarket } from "@agg-build/hooks";
|
|
2
|
+
import type { PlaceOrderResolvedClaimSummary } from "./place-order";
|
|
3
|
+
export type UseResolvedMarketClaimOptions = {
|
|
4
|
+
/** The resolved market whose claimable winnings should be summarized. */
|
|
5
|
+
market?: VenueMarket | null;
|
|
6
|
+
/** Gate fetching/computation (e.g. only when the trade panel is resolved). */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
/** Execution mode — paper positions are fetched from the paper bucket. */
|
|
9
|
+
executionMode?: "live" | "paper";
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Derives the resolved-market claim summary (resolution date, winning shares,
|
|
13
|
+
* total payout, and a wired claim action) for the position the current user
|
|
14
|
+
* holds in `market`, reusing the same redeem flow as the profile positions
|
|
15
|
+
* list via {@link useClaimWinnings}.
|
|
16
|
+
*
|
|
17
|
+
* Returns `undefined` (so the caller renders the plain resolved view) when:
|
|
18
|
+
* - fetching is disabled, the user is unauthenticated, or the market is open;
|
|
19
|
+
* - the user holds no position in this market;
|
|
20
|
+
* - the user's position lost (no winning outcome with shares).
|
|
21
|
+
*
|
|
22
|
+
* When the user won but the position is already redeemed / pending / ineligible
|
|
23
|
+
* (i.e. not `eligible`), the summary is returned WITHOUT an `onClaim` action so
|
|
24
|
+
* the earnings show without a duplicate claim CTA.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useResolvedMarketClaim(options?: UseResolvedMarketClaimOptions): PlaceOrderResolvedClaimSummary | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type VenueMarket } from "@agg-build/hooks";
|
|
2
|
+
import type { PlaceOrderResolvedClaimSummary } from "./place-order";
|
|
3
|
+
export type UseResolvedMarketClaimOptions = {
|
|
4
|
+
/** The resolved market whose claimable winnings should be summarized. */
|
|
5
|
+
market?: VenueMarket | null;
|
|
6
|
+
/** Gate fetching/computation (e.g. only when the trade panel is resolved). */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
/** Execution mode — paper positions are fetched from the paper bucket. */
|
|
9
|
+
executionMode?: "live" | "paper";
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Derives the resolved-market claim summary (resolution date, winning shares,
|
|
13
|
+
* total payout, and a wired claim action) for the position the current user
|
|
14
|
+
* holds in `market`, reusing the same redeem flow as the profile positions
|
|
15
|
+
* list via {@link useClaimWinnings}.
|
|
16
|
+
*
|
|
17
|
+
* Returns `undefined` (so the caller renders the plain resolved view) when:
|
|
18
|
+
* - fetching is disabled, the user is unauthenticated, or the market is open;
|
|
19
|
+
* - the user holds no position in this market;
|
|
20
|
+
* - the user's position lost (no winning outcome with shares).
|
|
21
|
+
*
|
|
22
|
+
* When the user won but the position is already redeemed / pending / ineligible
|
|
23
|
+
* (i.e. not `eligible`), the summary is returned WITHOUT an `onClaim` action so
|
|
24
|
+
* the earnings show without a duplicate claim CTA.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useResolvedMarketClaim(options?: UseResolvedMarketClaimOptions): PlaceOrderResolvedClaimSummary | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agg-build/ui",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Pre-built React component library for the AGG prediction market aggregator. Tailwind-based, themeable, with primitives, event surfaces, trading flows, full pages, and modals.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|
|
@@ -100,8 +100,8 @@
|
|
|
100
100
|
"liveline": "^0.0.7",
|
|
101
101
|
"react": "^18.0.0 || ^19.0.0",
|
|
102
102
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
103
|
-
"@agg-build/hooks": "^2.1.
|
|
104
|
-
"@agg-build/sdk": "^2.1.
|
|
103
|
+
"@agg-build/hooks": "^2.1.2",
|
|
104
|
+
"@agg-build/sdk": "^2.1.2"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
107
|
"@number-flow/react": "^0.6.0",
|