@funkit/connect 10.1.0-next.0 → 10.1.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/clients/{chunk-ETB2YYFT.js → chunk-2NBYHUIW.js} +1 -1
  3. package/dist/clients/{chunk-JNZY3GAA.js → chunk-E3USJY7A.js} +1 -1
  4. package/dist/clients/{chunk-HD4Y4NKC.js → chunk-ZAXSDMDU.js} +2 -2
  5. package/dist/clients/fanatics.css +1 -1
  6. package/dist/clients/fanatics.js +2 -2
  7. package/dist/clients/lighter.css +11 -11
  8. package/dist/clients/lighter.js +3 -3
  9. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +11 -11
  10. package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +3 -3
  11. package/dist/clients/polymarket/index.css +11 -11
  12. package/dist/clients/polymarket/index.js +3 -3
  13. package/dist/index.css +11 -11
  14. package/dist/index.js +73 -86
  15. package/dist/utils/checkout.d.ts +1 -1
  16. package/dist/wallets/walletConnectors/index.js +46 -46
  17. package/package.json +4 -4
  18. package/dist/clients/chunk-42XZD2Y3.js +0 -1112
  19. package/dist/clients/chunk-5UIZBNLC.js +0 -1175
  20. package/dist/clients/chunk-BO7AZVPG.js +0 -1112
  21. package/dist/clients/chunk-BUCJRBW7.js +0 -1472
  22. package/dist/clients/chunk-ME4OAQIY.js +0 -696
  23. package/dist/clients/chunk-PEVDOGEA.js +0 -109
  24. package/dist/clients/chunk-QIWGVVAW.js +0 -1113
  25. package/dist/clients/chunk-VJZW3MA3.js +0 -94
  26. package/dist/clients/chunk-WEETVC7U.js +0 -1113
  27. package/dist/clients/chunk-Y2KXVS36.js +0 -230
  28. package/dist/clients/polymarket/usePolymarketAccountBalances.d.ts +0 -66
  29. package/dist/hooks/useIsTokenWhitelisted.d.ts +0 -30
  30. package/dist/modals/CheckoutModal/buildRelayChains.d.ts +0 -12
  31. package/dist/providers/FunkitFlagsProvider.d.ts +0 -26
  32. package/dist/utils/flags/config.d.ts +0 -333
  33. package/dist/utils/flags/endpoint.d.ts +0 -22
  34. package/dist/utils/flags/hash.d.ts +0 -13
  35. package/dist/utils/flags/impl.d.ts +0 -10
  36. package/dist/utils/flags/types.d.ts +0 -49
  37. package/dist/wallets/walletConnectors/chunk-2VP2F6EK.js +0 -70
  38. package/dist/wallets/walletConnectors/chunk-4T6ZSRJF.js +0 -69
  39. package/dist/wallets/walletConnectors/chunk-6BW3HLBG.js +0 -96
  40. package/dist/wallets/walletConnectors/chunk-CCQV2ZET.js +0 -218
  41. package/dist/wallets/walletConnectors/chunk-CPI4TD43.js +0 -99
  42. package/dist/wallets/walletConnectors/chunk-F5XEEVG6.js +0 -98
  43. package/dist/wallets/walletConnectors/chunk-HNRB7KJU.js +0 -92
  44. package/dist/wallets/walletConnectors/chunk-HTHAK6XB.js +0 -93
  45. package/dist/wallets/walletConnectors/chunk-MIQTHJ6X.js +0 -66
  46. package/dist/wallets/walletConnectors/chunk-RB3HR4R2.js +0 -95
  47. package/dist/wallets/walletConnectors/chunk-RVOY537T.js +0 -100
  48. package/dist/wallets/walletConnectors/chunk-STVVP43G.js +0 -94
  49. package/dist/wallets/walletConnectors/chunk-UK7C2JXW.js +0 -87
  50. package/dist/wallets/walletConnectors/chunk-VAPGUPHO.js +0 -92
  51. package/dist/wallets/walletConnectors/chunk-VTM6EECM.js +0 -110
  52. package/dist/wallets/walletConnectors/chunk-X6CGV36L.js +0 -103
  53. package/dist/wallets/walletConnectors/chunk-YEZM4CK4.js +0 -96
  54. package/dist/wallets/walletConnectors/chunk-ZNX4EMPB.js +0 -106
  55. /package/dist/clients/{chunk-HMP3LHMW.js → chunk-LUHEVXPD.js} +0 -0
@@ -1,230 +0,0 @@
1
- "use client";
2
- import {
3
- Box
4
- } from "./chunk-PEVDOGEA.js";
5
- import {
6
- logger
7
- } from "./chunk-AHYOV7AV.js";
8
-
9
- // src/components/AsyncImage/useAsyncImage.ts
10
- import { useEffect, useReducer } from "react";
11
- var cachedUrls = /* @__PURE__ */ new Map();
12
- var cachedRequestPromises = /* @__PURE__ */ new Map();
13
- async function loadAsyncImage(asyncImage) {
14
- const cachedRequestPromise = cachedRequestPromises.get(asyncImage);
15
- if (cachedRequestPromise) {
16
- return cachedRequestPromise;
17
- }
18
- const load = async () => asyncImage().then(async (url) => {
19
- cachedUrls.set(asyncImage, url);
20
- return url;
21
- });
22
- const requestPromise = load().catch(async () => {
23
- return load().catch(() => {
24
- cachedRequestPromises.delete(asyncImage);
25
- return void 0;
26
- });
27
- });
28
- cachedRequestPromises.set(asyncImage, requestPromise);
29
- return requestPromise;
30
- }
31
- function useForceUpdate() {
32
- const [, forceUpdate] = useReducer((x) => x + 1, 0);
33
- return forceUpdate;
34
- }
35
- function useAsyncImage(url) {
36
- const cachedUrl = typeof url === "function" ? cachedUrls.get(url) : void 0;
37
- const forceUpdate = useForceUpdate();
38
- useEffect(() => {
39
- if (typeof url === "function" && !cachedUrl) {
40
- loadAsyncImage(url).then(forceUpdate);
41
- }
42
- }, [url, cachedUrl, forceUpdate]);
43
- return typeof url === "function" ? cachedUrl : url;
44
- }
45
- var REMOTE_IMG_CACHE = /* @__PURE__ */ new Set();
46
- function preloadRemoteImages(...imageUrls) {
47
- for (const imageUrl of imageUrls) {
48
- try {
49
- const { protocol } = new URL(imageUrl);
50
- if (protocol !== "https:" && protocol !== "http:") {
51
- logger.warn("preloadRemoteImages:invalidUrl", {
52
- message: "Invalid protocol",
53
- imageUrl
54
- });
55
- continue;
56
- }
57
- if (!REMOTE_IMG_CACHE.has(imageUrl)) {
58
- REMOTE_IMG_CACHE.add(imageUrl);
59
- const preloadImage = new Image();
60
- preloadImage.src = imageUrl;
61
- }
62
- } catch (error) {
63
- logger.warn("preloadRemoteImages:error", {
64
- message: "Unable to preload image",
65
- imageUrl,
66
- error
67
- });
68
- }
69
- }
70
- }
71
-
72
- // src/components/AsyncImage/AsyncImage.tsx
73
- import React, { useMemo, useReducer as useReducer2, useState } from "react";
74
-
75
- // src/utils/sanitizeUrl.ts
76
- var SAFE_URL_PROTOCOLS = /* @__PURE__ */ new Set(["https:", "http:"]);
77
- function sanitizeUrl(url) {
78
- if (!url) {
79
- return void 0;
80
- }
81
- try {
82
- const parsed = new URL(url);
83
- if (SAFE_URL_PROTOCOLS.has(parsed.protocol)) {
84
- return parsed.href;
85
- }
86
- return void 0;
87
- } catch {
88
- return void 0;
89
- }
90
- }
91
- function sanitizeCssUrl(url) {
92
- const safeUrl = sanitizeUrl(url);
93
- if (!safeUrl) {
94
- return void 0;
95
- }
96
- return safeUrl.replace(/['()\\]/g, (char) => {
97
- return `%${char.charCodeAt(0).toString(16).padStart(2, "0")}`;
98
- });
99
- }
100
-
101
- // src/components/AsyncImage/AsyncImage.tsx
102
- function useTriggeredOnce() {
103
- return useReducer2(() => true, false);
104
- }
105
- function AsyncImage({
106
- alt,
107
- background,
108
- borderColor,
109
- borderRadius,
110
- boxShadow,
111
- height,
112
- useAsImage,
113
- src: srcProp,
114
- fallbackSrc,
115
- fallbackElement,
116
- width,
117
- testId
118
- }) {
119
- const src = useAsyncImage(srcProp || fallbackSrc);
120
- const isRemoteImage = src !== void 0 && /^(https?|data):/.test(src);
121
- const [isRemoteImageLoaded, setRemoteImageLoaded] = useTriggeredOnce();
122
- const [hasError, setHasError] = useState(
123
- srcProp === void 0 && fallbackSrc === void 0
124
- );
125
- const { asyncStyle, imgProps } = useMemo(() => {
126
- const asyncStyle2 = !useAsImage ? getRemoteImageStyles(isRemoteImage, isRemoteImageLoaded, src) : {};
127
- if (useAsImage || isRemoteImage) {
128
- const imgProps2 = {
129
- as: "img",
130
- src,
131
- "aria-hidden": true,
132
- onError: ({
133
- currentTarget
134
- }) => {
135
- currentTarget.onerror = null;
136
- if (fallbackSrc !== void 0) {
137
- currentTarget.src = fallbackSrc;
138
- } else {
139
- setHasError(true);
140
- }
141
- },
142
- onLoad: isRemoteImage ? setRemoteImageLoaded : void 0
143
- };
144
- return { imgProps: imgProps2, asyncStyle: asyncStyle2 };
145
- }
146
- return {
147
- imgProps: {
148
- backgroundSize: "cover"
149
- },
150
- asyncStyle: {
151
- ...asyncStyle2,
152
- // has to be added as a inline style because vanilla-extract doesn't recognize this as a valid style
153
- backgroundPosition: "center"
154
- }
155
- };
156
- }, [
157
- fallbackSrc,
158
- isRemoteImage,
159
- isRemoteImageLoaded,
160
- src,
161
- useAsImage,
162
- setRemoteImageLoaded
163
- ]);
164
- const mainElement = hasError && fallbackElement || /* @__PURE__ */ React.createElement(
165
- Box,
166
- {
167
- ...imgProps,
168
- height: "full",
169
- position: "absolute",
170
- style: {
171
- WebkitTouchCallout: "none",
172
- transition: "opacity .15s linear",
173
- userSelect: "none",
174
- ...asyncStyle
175
- },
176
- width: "full"
177
- }
178
- );
179
- return /* @__PURE__ */ React.createElement(
180
- Box,
181
- {
182
- "aria-label": alt,
183
- borderRadius,
184
- boxShadow,
185
- height: typeof height === "string" ? height : void 0,
186
- overflow: "hidden",
187
- position: "relative",
188
- role: "img",
189
- style: {
190
- background,
191
- height: typeof height === "number" ? height : void 0,
192
- width: typeof width === "number" ? width : void 0
193
- },
194
- width: typeof width === "string" ? width : void 0,
195
- testId
196
- },
197
- mainElement,
198
- borderColor ? /* @__PURE__ */ React.createElement(
199
- Box,
200
- {
201
- ...typeof borderColor === "object" && "custom" in borderColor ? { style: { borderColor: borderColor.custom } } : { borderColor },
202
- borderRadius,
203
- borderStyle: "solid",
204
- borderWidth: "1",
205
- height: "full",
206
- position: "relative",
207
- width: "full"
208
- }
209
- ) : null
210
- );
211
- }
212
- var getRemoteImageStyles = (isRemoteImage, isRemoteImageLoaded, src) => {
213
- if (isRemoteImage) {
214
- return {
215
- opacity: isRemoteImageLoaded ? 1 : 0
216
- };
217
- }
218
- const safeSrc = sanitizeCssUrl(src);
219
- return {
220
- // note the url must have quotation, see https://github.com/evanw/esbuild/issues/1843#issuecomment-1370108070
221
- backgroundImage: safeSrc ? `url('${safeSrc}')` : void 0,
222
- backgroundRepeat: "no-repeat",
223
- opacity: src ? 1 : 0
224
- };
225
- };
226
-
227
- export {
228
- preloadRemoteImages,
229
- AsyncImage
230
- };
@@ -1,66 +0,0 @@
1
- import { type QueryClient } from '@tanstack/react-query';
2
- import type { Address } from 'viem';
3
- /**
4
- * Shared query key for a Polymarket account's USD balance, keyed by address.
5
- * Keying by address (not by the opaque getter fn) is what lets the "Deposit to"
6
- * dropdown and the in-modal transfer step dedupe into a single cache entry — so
7
- * navigating between them reuses the already-loaded balance instead of
8
- * refetching from scratch (no loading flash on entry).
9
- */
10
- export declare const polymarketAccountBalanceQueryKey: (address: Address | undefined) => readonly ["polymarket", "accountBalanceUsd", `0x${string}` | null];
11
- /**
12
- * Optimistically moves a transfer's amount between the two accounts' displayed
13
- * balances — call right after the integrator accepts the transfer. `amountUsd`
14
- * is the exact string the user entered (validated numeric, ≤6 decimals), the
15
- * same string handed to `transfer` — the math runs in 6-decimal fixed point,
16
- * never through a float round-trip.
17
- *
18
- * This is the standard TanStack optimistic-update sequence: cancel in-flight
19
- * fetches, write the new values with `setQueryData` so every reader (deposit
20
- * picker, transfer step) updates immediately, and let the server win again
21
- * later. "Later" is a settlement window rather than the next poll because the
22
- * integrator's backend is eventually consistent — it keeps reporting the
23
- * pre-transfer balances for a few seconds after accepting the transfer, so
24
- * polls inside the window keep the displayed value instead of flashing back.
25
- */
26
- export declare function applyOptimisticTransferBalances(queryClient: QueryClient, transfer: {
27
- fromAddress: Address;
28
- toAddress: Address;
29
- /** Exact entered amount (validated numeric string, ≤6 decimals). */
30
- amountUsd: string;
31
- }): void;
32
- /** The fields a balance reader needs from a Polymarket account. */
33
- export interface PolymarketBalanceAccount {
34
- address: Address;
35
- /** Integrator-owned live balance fetcher (USD). */
36
- getBalanceUsd: () => Promise<number>;
37
- }
38
- export interface PolymarketAccountBalance {
39
- /** Latest polled balance, or `undefined` until the first fetch resolves. */
40
- balanceUsd: number | undefined;
41
- }
42
- export interface UsePolymarketAccountBalancesOptions {
43
- /**
44
- * How often (ms) to poll each account's balance. Defaults to
45
- * {@link DEFAULT_BALANCE_REFETCH_MS}. A short interval reconciles the
46
- * displayed balance with the server soon after a transfer settles.
47
- */
48
- refetchIntervalMs?: number;
49
- }
50
- /**
51
- * Live USD balances for the Polymarket Predictions and Perps accounts, backed
52
- * by a single TanStack Query cache keyed by account address. Both the "Deposit
53
- * to" dropdown and the in-modal transfer step read through this hook, so they
54
- * share one store: whichever screen loads first populates the balance, and the
55
- * other reads it instantly on navigation. After a transfer,
56
- * {@link applyOptimisticTransferBalances} shifts the cached values immediately
57
- * and the short poll reconciles them with the server once the settlement
58
- * window closes.
59
- */
60
- export declare function usePolymarketAccountBalances(accounts: {
61
- predictions: PolymarketBalanceAccount | undefined;
62
- perps: PolymarketBalanceAccount | undefined;
63
- }, options?: UsePolymarketAccountBalancesOptions): {
64
- predictions: PolymarketAccountBalance;
65
- perps: PolymarketAccountBalance;
66
- };
@@ -1,30 +0,0 @@
1
- import { type FlagKey } from '@funkit/utils';
2
- export declare const MATCH_ALL = "*";
3
- export type MatchAll = typeof MATCH_ALL;
4
- export interface TokenWhitelist {
5
- [chainId: string | MatchAll]: string[] | [MatchAll] | MatchAll;
6
- }
7
- /**
8
- * Helper to check if a token is whitelisted for a given flag
9
- * Expects a flag value to be a JSON string of the following format (see {@link TokenWhitelist}):
10
- * ```json
11
- * {
12
- * "137": ["0xaf88d065e77c8cC2239327C5EDb3A432268e5831"],
13
- * "8453": ["0xaf88d065e77c8cC2239327C5EDb3A432268e5831"]
14
- * }
15
- * ```
16
- * Does also support wildcard entries, for example:
17
- * ```json
18
- * {
19
- * "137": ["*"],
20
- * "8453": "*",
21
- * }
22
- * ```
23
- * or even:
24
- * ```json
25
- * {
26
- * "*": "*"
27
- * }
28
- * ```
29
- */
30
- export declare const useIsTokenWhitelisted: <T extends FlagKey>(flagKey: T) => (chainId: string, tokenAddress: string) => boolean;
@@ -1,12 +0,0 @@
1
- import type { Chain } from 'viem';
2
- /**
3
- * Returns the chain list for the relay client, applying per-chain RPC overrides
4
- * (keyed by chain id) onto each chain's `rpcUrls.default.http`.
5
- *
6
- * The relay-sdk derives the RPC it polls for transaction receipts from each
7
- * chain's `rpcUrls.default`, so this points that receipt-wait at a reachable
8
- * endpoint for chains whose default RPC isn't (e.g. an early-access chain like
9
- * Robinhood). Only chains listed in `rpcOverrides` are changed; everything else
10
- * is returned unchanged. See {@link FunkitConfig.relayRpcOverrides}.
11
- */
12
- export declare function buildRelayChains(chains: readonly Chain[], rpcOverrides?: Record<number, string>): Chain[];
@@ -1,26 +0,0 @@
1
- import React, { type ReactNode } from 'react';
2
- import type { FlagKey } from '@funkit/utils';
3
- import { flagConfig as offlineConfig } from '../utils/flags/config';
4
- import type { InferFlagType } from '../utils/flags/types';
5
- export type FlagValue<K extends FlagKey> = InferFlagType<(typeof offlineConfig)[K]>;
6
- export type FlagValues = {
7
- [K in FlagKey]?: FlagValue<K>;
8
- };
9
- export type GetFlagFunction = <K extends FlagKey>(flagKey: K, fallback?: FlagValue<K>) => FlagValue<K>;
10
- export interface FunkitFlagsContextValue {
11
- /** Error fetching flag config from server */
12
- error: Error | null;
13
- /** Loaded flags - each flag may be undefined if configuration from server was missing or invalid */
14
- flags: FlagValues;
15
- /** Synchronously reads a single flag (derived for current user) - returns fallback while loading */
16
- getFlag: GetFlagFunction;
17
- /** Whether flags are currently loading */
18
- isLoading: boolean;
19
- }
20
- export declare const FunkitFlagsContext: React.Context<FunkitFlagsContextValue>;
21
- export declare function FunkitFlagsProvider({ children }: {
22
- children: ReactNode;
23
- }): React.JSX.Element;
24
- export declare function useFlags(): FunkitFlagsContextValue;
25
- export type FlagMiddleware<K extends FlagKey> = (flagValue: FlagValue<K>) => FlagValue<K>;
26
- export declare function useFlag<K extends FlagKey>(flagKey: K, fallback?: FlagValue<K>, middleware?: FlagMiddleware<K>): FlagValue<K>;