@funkit/connect 9.0.3 → 9.2.1

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 (54) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/__generated__/default_configs.d.ts +6 -0
  3. package/dist/{chunk-SC53AFEE.js → chunk-3U6TWV25.js} +14 -4
  4. package/dist/{chunk-XCM74QX2.js → chunk-P6FYL3PM.js} +5 -1
  5. package/dist/{chunk-WSCXOKCX.js → chunk-VLXKSNSJ.js} +5 -1
  6. package/dist/clients/chunk-SBQ2UUPK.js +214 -0
  7. package/dist/clients/fanatics.css +4075 -3817
  8. package/dist/clients/fanatics.js +5 -213
  9. package/dist/clients/polymarket.d.ts +41 -0
  10. package/dist/clients/polymarket.js +345 -0
  11. package/dist/components/Box/Box.d.ts +22 -22
  12. package/dist/components/Dropdown/ReceiveTokenDropdown.d.ts +3 -1
  13. package/dist/components/FunCheckoutHistory/PendingSuccessScreen.d.ts +13 -0
  14. package/dist/components/FunDivider/FunDivider.d.ts +3 -1
  15. package/dist/consts/bluvo.d.ts +5 -1
  16. package/dist/consts/customers.d.ts +0 -1
  17. package/dist/css/sprinkles.css.d.ts +34 -22
  18. package/dist/domains/swapped.d.ts +5 -1
  19. package/dist/hooks/queries/useFops.d.ts +4 -198
  20. package/dist/hooks/statsig/useDynamicConfig.d.ts +3 -1
  21. package/dist/hooks/track/CheckoutModalEvent.d.ts +2 -1
  22. package/dist/hooks/useCheckoutDirectExecution.d.ts +1 -1
  23. package/dist/hooks/useCheckoutTransferInit.d.ts +5 -1
  24. package/dist/hooks/useFrogAccount.d.ts +1 -1
  25. package/dist/hooks/useFunkitMaxCheckoutUsdInfo.d.ts +5 -5
  26. package/dist/hooks/useIsUsUser.d.ts +0 -1
  27. package/dist/hooks/usePaymentSources.d.ts +6 -2
  28. package/dist/hooks/useScrollDivider.d.ts +1 -0
  29. package/dist/index.css +4260 -3951
  30. package/dist/index.js +14274 -13956
  31. package/dist/modals/CheckoutModal/Brokerage/components/BrokerageSuccess.d.ts +1 -1
  32. package/dist/modals/CheckoutModal/FunCheckoutStep.d.ts +0 -1
  33. package/dist/modals/CheckoutModal/InputAmount/InputAmountLoaded.d.ts +1 -4
  34. package/dist/modals/CheckoutModal/InputAmount/state.d.ts +1 -5
  35. package/dist/modals/CheckoutModal/SourceChange/FormOfPaymentsList.d.ts +4 -3
  36. package/dist/modals/CheckoutModal/SourceChange/SourceList.d.ts +4 -3
  37. package/dist/modals/CheckoutModal/SourceChange/sourceChange.css.d.ts +5 -0
  38. package/dist/modals/CheckoutModal/stepTransition.d.ts +1 -7
  39. package/dist/modals/WithdrwalModal/WithdrawalCallbackSuccess.d.ts +10 -0
  40. package/dist/providers/FunkitCheckoutContext/index.d.ts +1 -1
  41. package/dist/providers/FunkitCheckoutContext/types.d.ts +6 -4
  42. package/dist/providers/FunkitConfigContext.d.ts +2 -0
  43. package/dist/providers/FunkitThemeProvider.d.ts +18 -0
  44. package/dist/themes/baseTheme.js +1 -1
  45. package/dist/themes/darkTheme.js +2 -2
  46. package/dist/themes/lightTheme.js +2 -2
  47. package/dist/utils/flags/config.d.ts +15 -1
  48. package/dist/utils/withdrawal.d.ts +13 -0
  49. package/dist/wallets/walletConnectors/index.js +30 -30
  50. package/package.json +3 -3
  51. package/dist/modals/CheckoutModal/DirectExecutionNotifCenter/DirectExecutionNotifCenter.d.ts +0 -12
  52. package/dist/modals/CheckoutModal/DirectExecutionNotifCenter/DirectExecutionNotifCenterContent.d.ts +0 -10
  53. package/dist/modals/CheckoutModal/SourceChange/DefiPurchaseSection.d.ts +0 -7
  54. package/dist/modals/WithdrwalModal/WithdrawalNotification.d.ts +0 -12
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Polymarket V2 PMCT withdrawal.
3
+ *
4
+ * Withdrawal flow:
5
+ * 1. Generate a UDA (User Deposit Address) for the withdrawal via api-base
6
+ * 2. Transfer PMCT from user's Polymarket proxy to the UDA
7
+ * 3. Backend handles: unwrap PMCT → USDC via PermissionedRamp + route to user
8
+ *
9
+ * The callback conforms to CustomWithdrawalConfig.withdrawCallback.
10
+ */
11
+ import type { Address } from 'viem';
12
+ import type { CustomWithdrawalConfig } from '../providers/FunkitCheckoutContext/types';
13
+ export declare const PMCT_WITHDRAW_ACTION_TYPE = "PMCT_WITHDRAW";
14
+ export interface PolymarketWithdrawalCallbackConfig {
15
+ userId: string;
16
+ modalTitle?: string;
17
+ disableConnectedWallet?: boolean;
18
+ /**
19
+ * Execute the ERC-20 transfer of PMCT from the user's proxy to the UDA.
20
+ * Called after the UDA address is generated.
21
+ * Should return when the transaction has been submitted (not necessarily confirmed).
22
+ */
23
+ sendPmctTransfer: (params: {
24
+ /** The UDA address to send PMCT to */
25
+ udaAddress: Address;
26
+ /** Amount in base units (from the quote) */
27
+ amountBaseUnit: bigint;
28
+ }) => Promise<void>;
29
+ }
30
+ /**
31
+ * Creates a full CustomWithdrawalConfig for Polymarket V2 PMCT withdrawals.
32
+ *
33
+ * Usage:
34
+ * ```ts
35
+ * const withdrawalConfig = createPolymarketWithdrawalConfig({
36
+ * userId: walletAddress,
37
+ * sendPmctTransfer: async ({ udaAddress, amountBaseUnit }) => { ... },
38
+ * })
39
+ * ```
40
+ */
41
+ export declare function createPolymarketWithdrawalConfig(config: PolymarketWithdrawalCallbackConfig): CustomWithdrawalConfig;
@@ -0,0 +1,345 @@
1
+ "use client";
2
+ import {
3
+ logger
4
+ } from "./chunk-SBQ2UUPK.js";
5
+
6
+ // src/clients/polymarket.tsx
7
+ import {
8
+ POLYMARKET_API_KEY,
9
+ initializeCheckoutTokenTransferAddress
10
+ } from "@funkit/api-base";
11
+ import { polygon } from "viem/chains";
12
+
13
+ // src/domains/paymentMethods.ts
14
+ import { exhaustiveCheck, formatAddress } from "@funkit/utils";
15
+
16
+ // src/consts/bluvo.tsx
17
+ import { ETHEREAL_API_KEY } from "@funkit/api-base";
18
+ import React6 from "react";
19
+
20
+ // src/components/Icons/BinanceIcon.tsx
21
+ import React from "react";
22
+ var BinanceIcon = ({ size = 24 }) => {
23
+ return /* @__PURE__ */ React.createElement(
24
+ "svg",
25
+ {
26
+ width: size,
27
+ height: size,
28
+ viewBox: "0 0 20 20",
29
+ fill: "none",
30
+ xmlns: "http://www.w3.org/2000/svg"
31
+ },
32
+ /* @__PURE__ */ React.createElement("rect", { width: "20", height: "20", rx: "4", fill: "#F3BA2F" }),
33
+ /* @__PURE__ */ React.createElement(
34
+ "path",
35
+ {
36
+ d: "M7.67 9.04 10 6.71l2.33 2.34 1.36-1.36L10 4 6.31 7.69zM4 10l1.36-1.36L6.7 10l-1.35 1.36zm3.67.96L10 13.29l2.33-2.33 1.36 1.35-3.69 3.7-3.69-3.7zm5.62-.96 1.35-1.35L16 10l-1.36 1.36z",
37
+ fill: "#fff"
38
+ }
39
+ ),
40
+ /* @__PURE__ */ React.createElement(
41
+ "path",
42
+ {
43
+ d: "M11.38 10 10 8.62 8.98 9.64l-.11.12-.25.24L10 11.38z",
44
+ fill: "#fff"
45
+ }
46
+ )
47
+ );
48
+ };
49
+
50
+ // src/components/Icons/CoinbaseIcon.tsx
51
+ import React2 from "react";
52
+ var CoinbaseIcon = ({ size = 24 }) => {
53
+ return /* @__PURE__ */ React2.createElement(
54
+ "svg",
55
+ {
56
+ xmlns: "http://www.w3.org/2000/svg",
57
+ width: size,
58
+ height: size,
59
+ viewBox: "0 0 20 20",
60
+ fill: "none"
61
+ },
62
+ /* @__PURE__ */ React2.createElement("rect", { width: "20", height: "20", rx: "4", fill: "#2C5FF6" }),
63
+ /* @__PURE__ */ React2.createElement(
64
+ "path",
65
+ {
66
+ d: "M9.99 13.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5c1.76 0 3.22 1.305 3.46 3h3.52A7.005 7.005 0 0 0 9.99 3c-3.86 0-7 3.14-7 7s3.14 7 7 7c3.69 0 6.725-2.87 6.98-6.5h-3.52c-.24 1.695-1.7 3-3.46 3Z",
67
+ fill: "#fff"
68
+ }
69
+ )
70
+ );
71
+ };
72
+
73
+ // src/components/Icons/GateIoIcon.tsx
74
+ import React3 from "react";
75
+ var GateIoIcon = ({ size = 24 }) => {
76
+ return /* @__PURE__ */ React3.createElement(
77
+ "svg",
78
+ {
79
+ width: size,
80
+ height: size,
81
+ viewBox: "0 0 25 25",
82
+ fill: "none",
83
+ xmlns: "http://www.w3.org/2000/svg"
84
+ },
85
+ /* @__PURE__ */ React3.createElement("rect", { width: "25", height: "25", rx: "5.357", fill: "#fff" }),
86
+ /* @__PURE__ */ React3.createElement("g", { clipPath: "url(#a)" }, /* @__PURE__ */ React3.createElement(
87
+ "mask",
88
+ {
89
+ id: "b",
90
+ maskUnits: "userSpaceOnUse",
91
+ x: "5",
92
+ y: "5",
93
+ width: "15",
94
+ height: "15",
95
+ style: { maskType: "luminance" }
96
+ },
97
+ /* @__PURE__ */ React3.createElement("path", { d: "M5 5h15v15H5V5Z", fill: "#fff" })
98
+ ), /* @__PURE__ */ React3.createElement("g", { mask: "url(#b)" }, /* @__PURE__ */ React3.createElement(
99
+ "path",
100
+ {
101
+ fillRule: "evenodd",
102
+ clipRule: "evenodd",
103
+ d: "M12.5 16.625a4.125 4.125 0 0 1 0-8.25V5a7.5 7.5 0 1 0 7.5 7.5h-3.375a4.125 4.125 0 0 1-4.125 4.125Z",
104
+ fill: "#2354E6"
105
+ }
106
+ )), /* @__PURE__ */ React3.createElement(
107
+ "path",
108
+ {
109
+ fillRule: "evenodd",
110
+ clipRule: "evenodd",
111
+ d: "M12.5 12.5h4.125V8.375H12.5V12.5Z",
112
+ fill: "#17E6A1"
113
+ }
114
+ )),
115
+ /* @__PURE__ */ React3.createElement("defs", null, /* @__PURE__ */ React3.createElement("clipPath", { id: "a" }, /* @__PURE__ */ React3.createElement("path", { fill: "#fff", transform: "translate(5 5)", d: "M0 0h15v15H0z" })))
116
+ );
117
+ };
118
+
119
+ // src/components/Icons/GeminiIcon.tsx
120
+ import React4 from "react";
121
+ var GeminiIcon = ({ size = 24 }) => {
122
+ return /* @__PURE__ */ React4.createElement(
123
+ "svg",
124
+ {
125
+ width: size,
126
+ height: size,
127
+ viewBox: "0 0 20 20",
128
+ fill: "none",
129
+ xmlns: "http://www.w3.org/2000/svg"
130
+ },
131
+ /* @__PURE__ */ React4.createElement(
132
+ "path",
133
+ {
134
+ d: "M16 0H4a4 4 0 0 0-4 4v12a4 4 0 0 0 4 4h12a4 4 0 0 0 4-4V4a4 4 0 0 0-4-4",
135
+ fill: "#58C8E6"
136
+ }
137
+ ),
138
+ /* @__PURE__ */ React4.createElement(
139
+ "path",
140
+ {
141
+ d: "M15.025 7.686H8.661a3.21 3.21 0 0 1 3.182-2.746 3.21 3.21 0 0 1 3.182 2.746m-3.653.94v2.746H8.626V8.626zm-.035 3.686a3.21 3.21 0 0 1-3.182 2.746 3.21 3.21 0 0 1-3.183-2.746zm-6.365-.94A3.23 3.23 0 0 1 7.686 8.66v2.71zm10.053-2.746a3.23 3.23 0 0 1-2.711 2.71v-2.71zM11.843 4C9.734 4 7.937 5.624 7.712 7.712A4.18 4.18 0 0 0 4 11.843 4.16 4.16 0 0 0 8.157 16c2.109 0 3.909-1.624 4.131-3.712C14.376 12.063 16 10.266 16 8.157A4.16 4.16 0 0 0 11.843 4",
142
+ fill: "#fff"
143
+ }
144
+ )
145
+ );
146
+ };
147
+
148
+ // src/components/Icons/KrakenIcon.tsx
149
+ import React5 from "react";
150
+ var KrakenIcon = ({ size = 24 }) => {
151
+ return /* @__PURE__ */ React5.createElement(
152
+ "svg",
153
+ {
154
+ width: size,
155
+ height: size,
156
+ viewBox: "0 0 20 20",
157
+ fill: "none",
158
+ xmlns: "http://www.w3.org/2000/svg"
159
+ },
160
+ /* @__PURE__ */ React5.createElement(
161
+ "path",
162
+ {
163
+ d: "M16 0H4a4 4 0 0 0-4 4v12a4 4 0 0 0 4 4h12a4 4 0 0 0 4-4V4a4 4 0 0 0-4-4",
164
+ fill: "#5741D9"
165
+ }
166
+ ),
167
+ /* @__PURE__ */ React5.createElement(
168
+ "path",
169
+ {
170
+ d: "M4 11.78v-.67a6.4 6.4 0 0 1 .83-3.26 6 6 0 0 1 2.64-2.3A6 6 0 0 1 9.89 5q1.84-.02 3.4.96a5.6 5.6 0 0 1 2.64 4.18q.1.9.07 1.82l-.01.98q0 .22-.05.43c-.15.54-.8.8-1.27.49a.8.8 0 0 1-.35-.57l-.04-.48v-1.98q0-.4-.26-.68a.83.83 0 0 0-1.17-.04 1 1 0 0 0-.32.65v.28l-.01 2.19c0 .41-.33.73-.76.76a1 1 0 0 1-.56-.17.8.8 0 0 1-.3-.48l-.03-.33v-2.2a1 1 0 0 0-.26-.65.84.84 0 0 0-1.25.02 1 1 0 0 0-.24.64V13q0 .28-.1.54a1 1 0 0 1-.32.34.8.8 0 0 1-1.17-.4 1 1 0 0 1-.07-.38V11q.01-.24-.05-.47a.9.9 0 0 0-.72-.62c-.37-.06-.65.11-.85.4q-.14.22-.14.46v2q.02.3-.04.59a.84.84 0 0 1-.87.63.9.9 0 0 1-.74-.63A1 1 0 0 1 4 13z",
171
+ fill: "#fff"
172
+ }
173
+ )
174
+ );
175
+ };
176
+
177
+ // src/consts/bluvo.tsx
178
+ var BLUVO_MIN_DEPOSIT_BY_CUSTOMER = {
179
+ [ETHEREAL_API_KEY]: 15
180
+ };
181
+ var BLUVO_EXCHANGES = {
182
+ coinbase: {
183
+ icon: (size) => /* @__PURE__ */ React6.createElement(CoinbaseIcon, { size }),
184
+ name: "Coinbase"
185
+ },
186
+ binance: {
187
+ icon: (size) => /* @__PURE__ */ React6.createElement(BinanceIcon, { size }),
188
+ name: "Binance"
189
+ },
190
+ gemini: {
191
+ icon: (size) => /* @__PURE__ */ React6.createElement(GeminiIcon, { size }),
192
+ name: "Gemini"
193
+ },
194
+ kraken: {
195
+ icon: (size) => /* @__PURE__ */ React6.createElement(KrakenIcon, { size }),
196
+ name: "Kraken"
197
+ },
198
+ gate: {
199
+ icon: (size) => /* @__PURE__ */ React6.createElement(GateIoIcon, { size }),
200
+ name: "Gate"
201
+ }
202
+ };
203
+ function getExchangeName(brokerType) {
204
+ return BLUVO_EXCHANGES[brokerType].name;
205
+ }
206
+
207
+ // src/domains/paymentMethods.ts
208
+ function createPaymentMethodInfo(params) {
209
+ switch (params.paymentMethod) {
210
+ case "card" /* CARD */:
211
+ return {
212
+ paymentMethod: "card" /* CARD */,
213
+ title: params.titleCustomization,
214
+ description: ""
215
+ };
216
+ case "balance" /* ACCOUNT_BALANCE */:
217
+ return {
218
+ paymentMethod: "balance" /* ACCOUNT_BALANCE */,
219
+ title: "Your Wallet",
220
+ description: formatAddress(params.walletAddress || "")
221
+ };
222
+ case "brokerage" /* BROKERAGE */:
223
+ return {
224
+ paymentMethod: "brokerage" /* BROKERAGE */,
225
+ title: getExchangeName(params.exchange),
226
+ description: "",
227
+ deviceId: params.deviceId,
228
+ exchange: params.exchange
229
+ };
230
+ case "token_transfer" /* TOKEN_TRANSFER */:
231
+ return {
232
+ // this is an arbitrary value for Polymarket.
233
+ paymentMethod: "token_transfer" /* TOKEN_TRANSFER */,
234
+ title: "QR Code Transfer",
235
+ description: ""
236
+ };
237
+ case "virtual_bank" /* VIRTUAL_BANK */:
238
+ return {
239
+ paymentMethod: "virtual_bank" /* VIRTUAL_BANK */,
240
+ title: "Fiat Account",
241
+ description: "",
242
+ matchingFiatAccount: params.matchingFiatAccount,
243
+ bridgeCustomer: params.bridgeCustomer
244
+ };
245
+ default:
246
+ exhaustiveCheck(params);
247
+ return {};
248
+ }
249
+ }
250
+
251
+ // src/domains/clientMetadata.ts
252
+ function generateClientMetadataForTokenTransfer() {
253
+ return {
254
+ id: "",
255
+ startTimestampMs: 0,
256
+ finalDollarValue: 0,
257
+ latestQuote: null,
258
+ depositAddress: null,
259
+ initSettings: {
260
+ config: {
261
+ targetAsset: "0x",
262
+ targetChain: "",
263
+ targetAssetTicker: "",
264
+ checkoutItemTitle: ""
265
+ }
266
+ },
267
+ selectedSourceAssetInfo: {
268
+ address: "0x",
269
+ symbol: "",
270
+ chainId: "",
271
+ iconSrc: null
272
+ },
273
+ selectedPaymentMethodInfo: createPaymentMethodInfo({
274
+ paymentMethod: "token_transfer" /* TOKEN_TRANSFER */
275
+ })
276
+ };
277
+ }
278
+
279
+ // src/clients/polymarket.tsx
280
+ var PMCT_WITHDRAW_ACTION_TYPE = "PMCT_WITHDRAW";
281
+ var POLYGON_USDCE = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
282
+ function createPolymarketWithdrawalCallback(config) {
283
+ const { userId, sendPmctTransfer } = config;
284
+ return async (param) => {
285
+ const { targetAssetAddress, targetChainId, destinationAddress, funQuote } = param;
286
+ logger.info("polymarket:withdrawal:start", {
287
+ targetChainId,
288
+ targetAssetAddress,
289
+ destinationAddress,
290
+ quoteId: param.quoteId
291
+ });
292
+ const transferInit = await initializeCheckoutTokenTransferAddress({
293
+ apiKey: POLYMARKET_API_KEY,
294
+ userId,
295
+ recipientAddr: destinationAddress,
296
+ toChainId: targetChainId.toString(),
297
+ toTokenAddress: targetAssetAddress,
298
+ logger,
299
+ clientMetadata: {
300
+ ...generateClientMetadataForTokenTransfer(),
301
+ isWithdrawal: true
302
+ }
303
+ // TODO: add this actionType back
304
+ // we need a backend release to pass the actual actionType for it.
305
+ // otherwise the current checkout will fail due to UDA creation
306
+ // actionType: PMCT_WITHDRAW_ACTION_TYPE,
307
+ });
308
+ const udaAddress = transferInit.depositAddr;
309
+ logger.info("polymarket:withdrawal:udaGenerated", { udaAddress });
310
+ const quote = funQuote;
311
+ const amountStr = quote?.baseQuote?.estTotalFromAmountBaseUnit;
312
+ if (!amountStr) {
313
+ logger.error("polymarket:withdrawal:missingAmountInQuote", { quote });
314
+ throw new Error("Missing withdrawal amount in quote");
315
+ }
316
+ const amount = BigInt(amountStr);
317
+ await sendPmctTransfer({
318
+ udaAddress,
319
+ amountBaseUnit: amount
320
+ });
321
+ logger.info("polymarket:withdrawal:transferSubmitted", {
322
+ udaAddress,
323
+ amountBaseUnit: amountStr
324
+ });
325
+ };
326
+ }
327
+ function createPolymarketWithdrawalConfig(config) {
328
+ return {
329
+ modalTitle: config.modalTitle ?? "Withdraw",
330
+ sourceChainId: polygon.id.toString(),
331
+ sourceTokenSymbol: "PMCT",
332
+ defaultReceiveToken: "USDC",
333
+ // TODO: PMCT is not deployed yet. we need to update this later
334
+ sourceTokenAddress: POLYGON_USDCE,
335
+ iconSrc: "https://sdk-cdn.fun.xyz/images/pmct.png",
336
+ disableConnectedWallet: config.disableConnectedWallet,
337
+ // sending $3 is enough to trigger Fun's UDA flow
338
+ getMinWithdrawalUSD: () => 3,
339
+ withdrawCallback: createPolymarketWithdrawalCallback(config)
340
+ };
341
+ }
342
+ export {
343
+ PMCT_WITHDRAW_ACTION_TYPE,
344
+ createPolymarketWithdrawalConfig
345
+ };