@funkit/connect 12.21.0 → 12.22.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.
- package/CHANGELOG.md +89 -0
- package/dist/clients/{chunk-FIJU6HZM.js → chunk-5JVG4MS2.js} +1 -1
- package/dist/clients/{chunk-YSQX5Z3F.js → chunk-HGLDKRSQ.js} +40 -8
- package/dist/clients/{chunk-6XJV626L.js → chunk-R7I5OO6C.js} +1 -1
- package/dist/clients/{chunk-DAMICUCH.js → chunk-UBZOARBX.js} +2 -2
- package/dist/clients/{chunk-MTKOZB6U.js → chunk-Y2O77SJO.js} +1 -1
- package/dist/clients/fanatics.js +2 -2
- package/dist/clients/internal/nado/withdrawalCallback.js +3 -3
- package/dist/clients/internal/nado/withdrawalErrors.js +2 -2
- package/dist/clients/internal/nado/withdrawalForm.js +5 -5
- package/dist/clients/internal/nado/withdrawalStatus.js +3 -3
- package/dist/clients/lighter.css +32 -11
- package/dist/clients/lighter.js +5 -5
- package/dist/clients/mallard.d.ts +34 -1
- package/dist/clients/mallard.js +149 -4
- package/dist/clients/nado.js +3 -3
- package/dist/components/CustomSlot/CustomSlot.d.ts +8 -0
- package/dist/components/CustomSlot/CustomSlotBoundary.d.ts +12 -0
- package/dist/components/DestinationSelector/DestinationAssetBalanceLabel.d.ts +6 -0
- package/dist/components/DestinationSelector/DestinationSelector.css.d.ts +3 -0
- package/dist/components/DestinationSelector/DestinationSelector.d.ts +17 -0
- package/dist/components/DestinationSelector/DestinationSelectorSkeleton.d.ts +2 -0
- package/dist/components/Dropdown/AccountSelectDropdown.d.ts +8 -1
- package/dist/components/Dropdown/BaseDropdown.d.ts +3 -1
- package/dist/components/Dropdown/BaseDropdownItem.d.ts +3 -1
- package/dist/components/ErrorBoundary/ErrorBoundary.d.ts +2 -0
- package/dist/components/FunTransactionSummary/DestinationLineItems.d.ts +1 -1
- package/dist/domains/asset.d.ts +6 -0
- package/dist/domains/clientMetadata.d.ts +5 -6
- package/dist/domains/convert/balances.d.ts +4 -2
- package/dist/domains/destinationAccount.d.ts +14 -0
- package/dist/domains/destinationAssetBalance.d.ts +39 -0
- package/dist/domains/fees.d.ts +13 -0
- package/dist/domains/inputAmountComponentContext.d.ts +11 -0
- package/dist/hooks/useConvertBalances.d.ts +3 -1
- package/dist/hooks/useDestinationAccountSelector.d.ts +18 -0
- package/dist/hooks/useDestinationAssetBalances.d.ts +5 -0
- package/dist/hooks/useHighPriceImpactPercent.d.ts +11 -0
- package/dist/index.css +32 -11
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3012 -2305
- package/dist/modals/CheckoutModal/InputAmount/InputAmountLayout.d.ts +2 -1
- package/dist/modals/CheckoutModal/SourceChange/FlatList.d.ts +2 -8
- package/dist/modals/CheckoutModal/SourceChange/SourceList.d.ts +1 -2
- package/dist/modals/CheckoutModal/SourceChange/useSourceChangeLayout.d.ts +5 -1
- package/dist/providers/FunkitCheckoutContext/types.d.ts +52 -11
- package/dist/providers/FunkitConfigContext.d.ts +24 -1
- package/dist/providers/FunkitHistoryContext.d.ts +0 -1
- package/dist/shadow-css.js +1 -1
- package/dist/utils/checkout.d.ts +1 -0
- package/dist/utils/consts.d.ts +1 -0
- package/dist/wallets/walletConnectors/index.js +38 -38
- package/package.json +7 -7
- package/dist/domains/priceImpact.d.ts +0 -14
- package/dist/modals/CheckoutModal/SourceChange/PayPal.d.ts +0 -2
package/dist/clients/mallard.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
useFunkitTranslation
|
|
4
|
-
} from "./chunk-MTKOZB6U.js";
|
|
5
2
|
import {
|
|
6
3
|
getAccount,
|
|
7
4
|
sendTransaction,
|
|
@@ -14,7 +11,10 @@ import {
|
|
|
14
11
|
useAccount,
|
|
15
12
|
useConfig
|
|
16
13
|
} from "./chunk-2W2P3OS6.js";
|
|
17
|
-
import
|
|
14
|
+
import {
|
|
15
|
+
useFunkitTranslation
|
|
16
|
+
} from "./chunk-Y2O77SJO.js";
|
|
17
|
+
import "./chunk-HGLDKRSQ.js";
|
|
18
18
|
import {
|
|
19
19
|
logger
|
|
20
20
|
} from "./chunk-B67ESBGC.js";
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
// src/clients/mallard.tsx
|
|
23
23
|
import { ROBINHOOD_MAINNET_CHAIN_ID } from "@funkit/chains";
|
|
24
24
|
import { VAULT_DEPOSITOR_ABI } from "@funkit/fun-relay";
|
|
25
|
+
import { isAddressEquivalent } from "@funkit/utils";
|
|
25
26
|
import { useMemo } from "react";
|
|
26
27
|
import {
|
|
27
28
|
encodeFunctionData,
|
|
@@ -30,6 +31,48 @@ import {
|
|
|
30
31
|
maxUint256
|
|
31
32
|
} from "viem";
|
|
32
33
|
|
|
34
|
+
// src/domains/destinationAccount.ts
|
|
35
|
+
import { groupBy } from "@funkit/utils";
|
|
36
|
+
function getDestinationAccountConfigIssue(config) {
|
|
37
|
+
const accounts = config.destinationAccountConfig?.accounts;
|
|
38
|
+
if (!accounts) {
|
|
39
|
+
return void 0;
|
|
40
|
+
}
|
|
41
|
+
if (!accounts.length) {
|
|
42
|
+
return "destinationAccountConfig.accounts must contain at least one account.";
|
|
43
|
+
}
|
|
44
|
+
const destinationAccountIds = /* @__PURE__ */ new Set();
|
|
45
|
+
for (const account of accounts) {
|
|
46
|
+
if (!account.id || destinationAccountIds.has(account.id)) {
|
|
47
|
+
return "destinationAccountConfig.accounts must have nonempty, unique account IDs.";
|
|
48
|
+
}
|
|
49
|
+
destinationAccountIds.add(account.id);
|
|
50
|
+
}
|
|
51
|
+
const candidates = config.dynamicTargetAssetCandidates ?? [];
|
|
52
|
+
const routingIds = /* @__PURE__ */ new Set();
|
|
53
|
+
const populatedAccounts = /* @__PURE__ */ new Set();
|
|
54
|
+
for (const candidate of candidates) {
|
|
55
|
+
if (!candidate.destinationAccountId || !destinationAccountIds.has(candidate.destinationAccountId)) {
|
|
56
|
+
return "Each destination candidate must supply a destinationAccountId matching destinationAccountConfig.accounts.";
|
|
57
|
+
}
|
|
58
|
+
if (!candidate.dynamicRoutingId || routingIds.has(candidate.dynamicRoutingId)) {
|
|
59
|
+
return "Destination candidates must supply nonempty, unique dynamicRoutingIds.";
|
|
60
|
+
}
|
|
61
|
+
routingIds.add(candidate.dynamicRoutingId);
|
|
62
|
+
populatedAccounts.add(candidate.destinationAccountId);
|
|
63
|
+
}
|
|
64
|
+
if (accounts.some((account) => !populatedAccounts.has(account.id))) {
|
|
65
|
+
return "Each destination account must have at least one eligible candidate.";
|
|
66
|
+
}
|
|
67
|
+
const withRecipient = candidates.filter(
|
|
68
|
+
(candidate) => candidate.customRecipient
|
|
69
|
+
).length;
|
|
70
|
+
if (withRecipient > 0 && withRecipient < candidates.length) {
|
|
71
|
+
return "Destination candidates must either all supply a customRecipient or all omit it.";
|
|
72
|
+
}
|
|
73
|
+
return void 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
33
76
|
// src/wallets/createConnectedWithdrawalClient.ts
|
|
34
77
|
function createConnectedWithdrawalClient(config, ownerAddress, sourceChainId) {
|
|
35
78
|
const ensureOnChain = async (chainId) => {
|
|
@@ -195,6 +238,107 @@ function useMallardWithdrawalConfig(config) {
|
|
|
195
238
|
};
|
|
196
239
|
}, [config, address, wagmiConfig, sourceChainId, sourceTokenAddress, t]);
|
|
197
240
|
}
|
|
241
|
+
var VAULT_DEPOSITOR_V2_ROBINHOOD = "0xa15cFd1a071aC0285f22CabFa735e7Ed1a92E096";
|
|
242
|
+
var MALLARD_STOCK_DEPOSIT_ADDRESS = "0x14b107cf534239c59571b066cb6497a321da897c";
|
|
243
|
+
function getMallardPerpsDepositActions(recipientAddress, tokenAddress) {
|
|
244
|
+
if (isAddressEquivalent({
|
|
245
|
+
firstAddress: tokenAddress,
|
|
246
|
+
secondAddress: MALLARD_USDG_ADDRESS
|
|
247
|
+
})) {
|
|
248
|
+
return createMallardDepositActions({ recipientAddress, tokenAddress });
|
|
249
|
+
}
|
|
250
|
+
return createMallardDepositActions({
|
|
251
|
+
recipientAddress,
|
|
252
|
+
tokenAddress,
|
|
253
|
+
vaultDepositorAddress: VAULT_DEPOSITOR_V2_ROBINHOOD,
|
|
254
|
+
depositAddress: MALLARD_STOCK_DEPOSIT_ADDRESS
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function getMallardAssets({
|
|
258
|
+
address,
|
|
259
|
+
accounts
|
|
260
|
+
}) {
|
|
261
|
+
return accounts.flatMap((account) => {
|
|
262
|
+
if (account.id !== "perps" && account.id !== "spot") {
|
|
263
|
+
throw new Error("Mallard account IDs must be perps or spot.");
|
|
264
|
+
}
|
|
265
|
+
const candidates = account.assets.map((asset) => {
|
|
266
|
+
const isUsdg = isAddressEquivalent({
|
|
267
|
+
firstAddress: asset.address,
|
|
268
|
+
secondAddress: MALLARD_USDG_ADDRESS
|
|
269
|
+
});
|
|
270
|
+
if (account.id === "spot" && !isUsdg) {
|
|
271
|
+
throw new Error("Mallard Spot only supports USDG.");
|
|
272
|
+
}
|
|
273
|
+
const accountName = account.id === "perps" ? "Perps" : "Spot";
|
|
274
|
+
return {
|
|
275
|
+
tokenSymbol: `${asset.symbol} (${accountName})`,
|
|
276
|
+
destinationAccountId: account.id,
|
|
277
|
+
displayTokenSymbol: asset.symbol,
|
|
278
|
+
groupLabel: asset.groupLabel,
|
|
279
|
+
tokenChainId: ROBINHOOD_MAINNET_CHAIN_ID.toString(),
|
|
280
|
+
tokenAddress: asset.address,
|
|
281
|
+
iconSrc: asset.iconSrc,
|
|
282
|
+
dynamicRoutingId: `MALLARD_${asset.symbol.toUpperCase()}_${account.id.toUpperCase()}`,
|
|
283
|
+
// Explicit undefined clears any incumbent Perps action when switching to Spot.
|
|
284
|
+
generateActionsParams: account.id === "spot" ? void 0 : getMallardPerpsDepositActions(address, asset.address)
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
if (account.id === "perps" && account.assets.length && !account.assets.some(
|
|
288
|
+
(asset) => isAddressEquivalent({
|
|
289
|
+
firstAddress: asset.address,
|
|
290
|
+
secondAddress: MALLARD_USDG_ADDRESS
|
|
291
|
+
})
|
|
292
|
+
)) {
|
|
293
|
+
throw new Error("Mallard Perps must include USDG.");
|
|
294
|
+
}
|
|
295
|
+
return candidates;
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
function createMallardDepositConfig({
|
|
299
|
+
address,
|
|
300
|
+
accounts,
|
|
301
|
+
getAssetBalances
|
|
302
|
+
}) {
|
|
303
|
+
const candidates = getMallardAssets({ address, accounts });
|
|
304
|
+
const destinationAccountConfig = {
|
|
305
|
+
accounts: accounts.map(({ id, label, icon }) => ({ id, label, icon })),
|
|
306
|
+
getAssetBalances
|
|
307
|
+
};
|
|
308
|
+
const issue = getDestinationAccountConfigIssue({
|
|
309
|
+
destinationAccountConfig,
|
|
310
|
+
dynamicTargetAssetCandidates: candidates
|
|
311
|
+
});
|
|
312
|
+
if (issue) {
|
|
313
|
+
throw new Error(issue);
|
|
314
|
+
}
|
|
315
|
+
const initialCandidate = candidates[0];
|
|
316
|
+
if (!initialCandidate) {
|
|
317
|
+
throw new Error("Mallard requires at least one eligible asset.");
|
|
318
|
+
}
|
|
319
|
+
const modalTitles = Object.fromEntries(
|
|
320
|
+
candidates.map((candidate) => [
|
|
321
|
+
candidate.dynamicRoutingId,
|
|
322
|
+
`Deposit ${candidate.tokenSymbol.replace(/[()]/g, "")}`
|
|
323
|
+
])
|
|
324
|
+
);
|
|
325
|
+
const ticker = initialCandidate.displayTokenSymbol ?? initialCandidate.tokenSymbol;
|
|
326
|
+
return {
|
|
327
|
+
modalTitle: ({ dynamicRoutingId }) => (dynamicRoutingId && modalTitles[dynamicRoutingId]) ?? "Deposit (Mallard)",
|
|
328
|
+
targetChain: initialCandidate.tokenChainId,
|
|
329
|
+
targetAsset: initialCandidate.tokenAddress,
|
|
330
|
+
targetAssetAmount: 0,
|
|
331
|
+
targetAssetTicker: ticker,
|
|
332
|
+
checkoutItemTitle: ticker,
|
|
333
|
+
iconSrc: initialCandidate.iconSrc,
|
|
334
|
+
dynamicRoutingId: initialCandidate.dynamicRoutingId,
|
|
335
|
+
destinationAccountConfig,
|
|
336
|
+
dynamicTargetAssetCandidates: candidates,
|
|
337
|
+
// Route-specific UDA settings take precedence, including Spot's absent action.
|
|
338
|
+
qrcodeActionType: "MALLARD_PERPS",
|
|
339
|
+
generateActionsParams: initialCandidate.generateActionsParams
|
|
340
|
+
};
|
|
341
|
+
}
|
|
198
342
|
export {
|
|
199
343
|
AMOUNT_PLACEHOLDER,
|
|
200
344
|
MALLARD_DEPOSIT_ADDRESS,
|
|
@@ -202,5 +346,6 @@ export {
|
|
|
202
346
|
MALLARD_USDG_ICON_SRC,
|
|
203
347
|
VAULT_DEPOSITOR_ZORRO,
|
|
204
348
|
createMallardDepositActions,
|
|
349
|
+
createMallardDepositConfig,
|
|
205
350
|
useMallardWithdrawalConfig
|
|
206
351
|
};
|
package/dist/clients/nado.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
createNadoWithdrawalCallback
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UBZOARBX.js";
|
|
5
5
|
import "./chunk-TKEBGMVW.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-R7I5OO6C.js";
|
|
7
7
|
import "./chunk-LICTGZXW.js";
|
|
8
8
|
import "./chunk-OODIKHYE.js";
|
|
9
9
|
import {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./chunk-2W2P3OS6.js";
|
|
13
13
|
import {
|
|
14
14
|
i18n_default
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-HGLDKRSQ.js";
|
|
16
16
|
import {
|
|
17
17
|
logger
|
|
18
18
|
} from "./chunk-B67ESBGC.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { type CustomSlotBoundaryProps } from './CustomSlotBoundary';
|
|
3
|
+
interface CustomSlotProps<TContext> extends Omit<CustomSlotBoundaryProps, 'children'> {
|
|
4
|
+
render: ((ctx: TContext) => ReactNode) | undefined;
|
|
5
|
+
context: TContext;
|
|
6
|
+
}
|
|
7
|
+
export declare function CustomSlot<TContext>({ name, render, context, fallback, resetKey, }: CustomSlotProps<TContext>): React.JSX.Element | null;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
export interface CustomSlotBoundaryProps {
|
|
3
|
+
/** Used in the failure log, e.g. 'inputAmountScreen.customComponent'. */
|
|
4
|
+
name: string;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** Shown in place of the slot after a failure. Defaults to nothing. */
|
|
7
|
+
fallback?: (error: Error) => ReactNode;
|
|
8
|
+
/** Retry after a failure when this changes. */
|
|
9
|
+
resetKey?: unknown;
|
|
10
|
+
}
|
|
11
|
+
/** Contains integrator-rendered content so a failure hides only that content and logs at WARN. */
|
|
12
|
+
export declare function CustomSlotBoundary({ name, children, fallback, resetKey, }: CustomSlotBoundaryProps): React.JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type DestinationAssetBalanceState } from '../../domains/destinationAssetBalance';
|
|
3
|
+
export declare function DestinationAssetBalanceLabel({ balance, symbol, }: {
|
|
4
|
+
balance: DestinationAssetBalanceState | undefined;
|
|
5
|
+
symbol: string;
|
|
6
|
+
}): React.JSX.Element | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type DestinationAssetGroup } from '../../domains/destinationAccount';
|
|
3
|
+
import type { DestinationAssetBalanceStates } from '../../domains/destinationAssetBalance';
|
|
4
|
+
import type { DestinationAccount, DynamicTargetAssetCandidate } from '../../providers/FunkitCheckoutContext/types';
|
|
5
|
+
interface DestinationSelectorProps {
|
|
6
|
+
accounts: readonly DestinationAccount[];
|
|
7
|
+
selectedAccountId?: string;
|
|
8
|
+
assetGroups: readonly DestinationAssetGroup[];
|
|
9
|
+
selectedRoutingId?: string;
|
|
10
|
+
assetBalances?: DestinationAssetBalanceStates;
|
|
11
|
+
onAssetMenuOpenChange?: (open: boolean) => void;
|
|
12
|
+
onAccountSelect: (account: DestinationAccount) => void;
|
|
13
|
+
onAssetSelect: (candidate: DynamicTargetAssetCandidate) => void;
|
|
14
|
+
}
|
|
15
|
+
/** Presentation only: the caller supplies eligible groups and owns account-switch policy. */
|
|
16
|
+
export declare function DestinationSelector({ accounts, selectedAccountId, assetGroups, selectedRoutingId, assetBalances, onAssetMenuOpenChange, onAccountSelect, onAssetSelect, }: DestinationSelectorProps): React.JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -4,6 +4,7 @@ export interface AccountSelectOption {
|
|
|
4
4
|
/** Stable identifier, also the dropdown's selected value. */
|
|
5
5
|
value: string;
|
|
6
6
|
label: string;
|
|
7
|
+
icon?: React.ReactNode;
|
|
7
8
|
/** Secondary line under the label, e.g. a formatted balance. */
|
|
8
9
|
description?: React.ReactNode;
|
|
9
10
|
}
|
|
@@ -16,6 +17,12 @@ export interface AccountSelectAction {
|
|
|
16
17
|
}
|
|
17
18
|
export interface AccountSelectDropdownProps {
|
|
18
19
|
accounts: AccountSelectOption[];
|
|
20
|
+
triggerClassName?: string;
|
|
21
|
+
/** Defaults to true; disable when the trigger alone identifies the selection. */
|
|
22
|
+
isCheckmarkVisible?: boolean;
|
|
23
|
+
horizontalIconGap?: BaseActiveDropdownItemProps['horizontalIconGap'];
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
maxDropdownHeight?: number;
|
|
19
26
|
selectedValue: string;
|
|
20
27
|
onSelect: (value: string) => void;
|
|
21
28
|
/**
|
|
@@ -42,4 +49,4 @@ export interface AccountSelectDropdownProps {
|
|
|
42
49
|
* divider. Built on {@link BaseDropdown}; selection routes through each
|
|
43
50
|
* {@link BaseDropdownItem} so Radix closes the menu on choose.
|
|
44
51
|
*/
|
|
45
|
-
export declare function AccountSelectDropdown({ accounts, selectedValue, onSelect, action, prefixLabel, label, size, dropdownWidth, testId, }: AccountSelectDropdownProps): React.JSX.Element;
|
|
52
|
+
export declare function AccountSelectDropdown({ accounts, triggerClassName, isCheckmarkVisible, horizontalIconGap, placeholder, maxDropdownHeight, selectedValue, onSelect, action, prefixLabel, label, size, dropdownWidth, testId, }: AccountSelectDropdownProps): React.JSX.Element;
|
|
@@ -10,6 +10,7 @@ export declare const HORIZONTAL_ICON_GAP = "4";
|
|
|
10
10
|
export declare const HORIZONTAL_OUTER_PADDING_X = "12";
|
|
11
11
|
export interface BaseDropdownProps<T = string, G extends string = never> {
|
|
12
12
|
value: string;
|
|
13
|
+
triggerClassName?: string;
|
|
13
14
|
activeItemProps?: Partial<Pick<BaseActiveDropdownItemProps, 'iconComponent' | 'label' | 'color' | 'alwaysVisibleLabel' | 'tagComponent' | 'tagPosition' | 'background' | 'labelStyle' | 'compactIcon'>>;
|
|
14
15
|
/**
|
|
15
16
|
* List of groups to show and the corresponding labels, in the expected order.
|
|
@@ -43,6 +44,7 @@ export interface BaseDropdownProps<T = string, G extends string = never> {
|
|
|
43
44
|
unselectLabel?: string;
|
|
44
45
|
options: BaseDropdownOption<T>[];
|
|
45
46
|
onOpen?: () => void;
|
|
47
|
+
onOpenChange?: (open: boolean) => void;
|
|
46
48
|
onOptionSelected?: (item: BaseDropdownOption<T>) => void;
|
|
47
49
|
renderDropdownOption: (item: BaseDropdownOption<T>, isSelected: boolean) => React.ReactNode;
|
|
48
50
|
searchableOptions?: boolean;
|
|
@@ -68,5 +70,5 @@ export interface BaseDropdownProps<T = string, G extends string = never> {
|
|
|
68
70
|
dropdownAlign?: 'start' | 'center' | 'end';
|
|
69
71
|
testId?: string;
|
|
70
72
|
}
|
|
71
|
-
declare function BaseDropdown<T extends string = string, G extends string = never>({ activeItemProps, value, options, groups, additionalGroup, additionalGroupLabel, allowUnselect, unselectLabel, onOptionSelected, onOpen, renderDropdownOption, searchableOptions, searchPlaceholder, placeholder, resetSearchOnClose, openToTopOnMobile, alwaysOpenToTop, openDropdownFullWidth, isLoading, preloadIconUrls, horizontalIconGap, openDropdownBackgroundColor, size, label, maxDropdownHeight, dropdownWidth, dropdownAlign, testId, }: BaseDropdownProps<T, G>): React.JSX.Element;
|
|
73
|
+
declare function BaseDropdown<T extends string = string, G extends string = never>({ activeItemProps, value, triggerClassName, options, groups, additionalGroup, additionalGroupLabel, allowUnselect, unselectLabel, onOptionSelected, onOpen, onOpenChange, renderDropdownOption, searchableOptions, searchPlaceholder, placeholder, resetSearchOnClose, openToTopOnMobile, alwaysOpenToTop, openDropdownFullWidth, isLoading, preloadIconUrls, horizontalIconGap, openDropdownBackgroundColor, size, label, maxDropdownHeight, dropdownWidth, dropdownAlign, testId, }: BaseDropdownProps<T, G>): React.JSX.Element;
|
|
72
74
|
export default BaseDropdown;
|
|
@@ -8,6 +8,8 @@ interface BaseDropdownItemProps {
|
|
|
8
8
|
id: string;
|
|
9
9
|
onClick?: (id: string) => void;
|
|
10
10
|
isSelected?: boolean;
|
|
11
|
+
/** Hide the checkmark and its reserved space when selection is shown elsewhere. */
|
|
12
|
+
isCheckmarkVisible?: boolean;
|
|
11
13
|
isDisabled?: boolean;
|
|
12
14
|
horizontalIconGap?: BoxProps['gap'];
|
|
13
15
|
tagComponent?: React.ReactNode;
|
|
@@ -18,5 +20,5 @@ interface BaseDropdownItemProps {
|
|
|
18
20
|
/**
|
|
19
21
|
* Represents a single option in a dropdown.
|
|
20
22
|
*/
|
|
21
|
-
declare function BaseDropdownItem({ iconComponent, label, description, id, onClick, isSelected, isDisabled, borderRadius, horizontalIconGap, tagComponent, horizontalPadding, verticalPadding, }: BaseDropdownItemProps): React.JSX.Element;
|
|
23
|
+
declare function BaseDropdownItem({ iconComponent, label, description, id, onClick, isSelected, isCheckmarkVisible, isDisabled, borderRadius, horizontalIconGap, tagComponent, horizontalPadding, verticalPadding, }: BaseDropdownItemProps): React.JSX.Element;
|
|
22
24
|
export default BaseDropdownItem;
|
|
@@ -4,6 +4,8 @@ interface ErrorBoundaryProps {
|
|
|
4
4
|
renderFallback: (error: Error) => ReactNode;
|
|
5
5
|
/** Clears a caught error when it changes, e.g. when a soft-hidden modal reopens */
|
|
6
6
|
resetKey?: unknown;
|
|
7
|
+
/** Optional handler for a boundary that recovers locally from the failure. */
|
|
8
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
7
9
|
}
|
|
8
10
|
interface ErrorBoundaryState {
|
|
9
11
|
error: Error | null;
|
|
@@ -6,7 +6,7 @@ export declare const TX_SUMMARY_VALUE_COLORS: {
|
|
|
6
6
|
caution: string;
|
|
7
7
|
danger: string;
|
|
8
8
|
};
|
|
9
|
-
export declare const MAX_DESTINATION_LINE_ITEMS =
|
|
9
|
+
export declare const MAX_DESTINATION_LINE_ITEMS = 4;
|
|
10
10
|
/** Additional line items provided through `resolveDestinationLineItems`, rendered last in the summary box. */
|
|
11
11
|
export declare function DestinationLineItems({ items, isLoading, }: {
|
|
12
12
|
items: DestinationLineItem[] | null | undefined;
|
package/dist/domains/asset.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ export declare function getMinValueThreshold(config: FunkitCheckoutConfig | unde
|
|
|
12
12
|
export declare function isPreferredChain(chainId: number, additionalChains?: number[]): boolean;
|
|
13
13
|
export { isNativeTokenAddress };
|
|
14
14
|
export declare function isDefaultToken(asset: AssetHoldingsItem, checkoutConfig: FunkitCheckoutConfig): boolean;
|
|
15
|
+
/** The token a checkout delivers, as handed to integrator slots. */
|
|
16
|
+
export declare function getCheckoutTargetAsset(checkoutConfig: Pick<FunkitCheckoutConfig, 'targetAsset' | 'targetChain' | 'targetAssetTicker'>): {
|
|
17
|
+
address: `0x${string}`;
|
|
18
|
+
chainId: string;
|
|
19
|
+
symbol: string;
|
|
20
|
+
};
|
|
15
21
|
export declare const isPolygonEcosystemToken: (chainId: string, tokenAddress: string) => boolean;
|
|
16
22
|
interface AssetUsableToPayParms {
|
|
17
23
|
config: FunkitCheckoutConfig;
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Make sure it is SERIALIZABLE and BACKWARD COMPATIBLE!!
|
|
6
6
|
*/
|
|
7
|
-
import type { DynamicTargetAssetCandidate } from '@funkit/connect-core';
|
|
8
7
|
import type { ApiCheckoutClientMetadata } from '@funkit/utils';
|
|
9
|
-
import type { FunkitActiveCheckoutItem, FunkitCheckoutActionParams, FunkitCheckoutConfig } from '../providers/FunkitCheckoutContext';
|
|
8
|
+
import type { DynamicTargetAssetCandidate, FunkitActiveCheckoutItem, FunkitCheckoutActionParams, FunkitCheckoutConfig } from '../providers/FunkitCheckoutContext';
|
|
10
9
|
import type { FunkitCheckoutQuoteResult } from './quote';
|
|
11
10
|
type Serialize<T> = T extends (...args: never[]) => unknown ? DeepSerialize<ReturnType<T>> : T extends object ? DeepSerialize<T> : T;
|
|
12
11
|
type DeepSerialize<T> = {
|
|
@@ -17,7 +16,7 @@ type SerializedCandidate = Omit<DynamicTargetAssetCandidate, 'generateActionsPar
|
|
|
17
16
|
* Historical Checkout Configuration stored in the server
|
|
18
17
|
* This is similar to FunkitCheckoutConfig but with some fields changed to serializable types
|
|
19
18
|
* */
|
|
20
|
-
export type ServerCheckoutConfig = Omit<DeepSerialize<FunkitCheckoutConfig>, 'dynamicTargetAssetCandidates' | 'headerTabs'> & {
|
|
19
|
+
export type ServerCheckoutConfig = Omit<DeepSerialize<FunkitCheckoutConfig>, 'dynamicTargetAssetCandidates' | 'headerTabs' | 'destinationAccountConfig'> & {
|
|
21
20
|
dynamicTargetAssetCandidates?: SerializedCandidate[];
|
|
22
21
|
};
|
|
23
22
|
type HistoricalCheckoutItemKey = 'id' | 'startTimestampMs' | 'finalDollarValue' | 'latestQuote' | 'depositAddress' | 'selectedSourceAssetInfo' | 'selectedPaymentMethodInfo';
|
|
@@ -44,10 +43,10 @@ export interface HistoricalCheckoutItem extends Pick<FunkitActiveCheckoutItem, H
|
|
|
44
43
|
* stripped candidates;
|
|
45
44
|
* - `modalTitle` is restored whenever a live config exists (falling back to the
|
|
46
45
|
* serializable value) so validation passes;
|
|
47
|
-
* - the remaining live-only
|
|
46
|
+
* - the remaining live-only fields (`getMinDepositUSD`,
|
|
48
47
|
* `generateActionsParams`, `polymarketPerpsTransfer`, `headerTabs`,
|
|
49
|
-
* `resolveHealthFactor`) are carried forward only
|
|
50
|
-
* still-active checkout.
|
|
48
|
+
* `resolveHealthFactor`, `destinationAccountConfig`) are carried forward only
|
|
49
|
+
* when re-starting the still-active checkout.
|
|
51
50
|
*/
|
|
52
51
|
export declare function createNewCheckoutConfig({ serializedConfig, liveConfig, isActiveCheckout, }: {
|
|
53
52
|
serializedConfig: ServerCheckoutConfig;
|
|
@@ -28,9 +28,10 @@ export type ConvertBalances = Record<string, ConvertBalanceState>;
|
|
|
28
28
|
* unavailable; it never becomes 0. Balances for assets that weren't requested
|
|
29
29
|
* are ignored.
|
|
30
30
|
*/
|
|
31
|
-
export declare function parseConvertBalances({ assets, assetBalances, }: {
|
|
31
|
+
export declare function parseConvertBalances({ assets, assetBalances, logPrefix, }: {
|
|
32
32
|
assets: ConvertResolvedAsset[];
|
|
33
33
|
assetBalances: ConvertAssetBalance[];
|
|
34
|
+
logPrefix?: string;
|
|
34
35
|
}): ConvertBalances;
|
|
35
36
|
/** The balance in USD; `undefined` when the balance is unknown. */
|
|
36
37
|
export declare function getConvertUsdAmount(balance: ConvertBalanceState | undefined, decimals: number): number | undefined;
|
|
@@ -51,8 +52,9 @@ export declare function getConvertMaxAmount({ asset, balance, isFeeReserveLoadin
|
|
|
51
52
|
* Calls the host getter and parses its result. A throw or timeout is logged
|
|
52
53
|
* and rethrown so the query keeps the last good read instead of replacing it.
|
|
53
54
|
*/
|
|
54
|
-
export declare function fetchConvertBalances({ assets, getBalances, timeoutMs, }: {
|
|
55
|
+
export declare function fetchConvertBalances({ assets, getBalances, timeoutMs, logPrefix, }: {
|
|
55
56
|
assets: ConvertResolvedAsset[];
|
|
56
57
|
getBalances: GetConvertBalances;
|
|
57
58
|
timeoutMs?: number;
|
|
59
|
+
logPrefix?: string;
|
|
58
60
|
}): Promise<ConvertBalances>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DestinationAccount, DynamicTargetAssetCandidate, FunkitCheckoutConfig } from '../providers/FunkitCheckoutContext/types';
|
|
2
|
+
export interface DestinationAssetGroup {
|
|
3
|
+
label?: string;
|
|
4
|
+
candidates: readonly DynamicTargetAssetCandidate[];
|
|
5
|
+
}
|
|
6
|
+
type RoutedCandidate = DynamicTargetAssetCandidate & {
|
|
7
|
+
dynamicRoutingId: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function hasRoutingId(candidate: DynamicTargetAssetCandidate): candidate is RoutedCandidate;
|
|
10
|
+
export declare function createCandidateByRoutingId(assetGroups: readonly DestinationAssetGroup[]): Map<string, DynamicTargetAssetCandidate>;
|
|
11
|
+
export declare function getDestinationAccountConfigIssue(config: Pick<FunkitCheckoutConfig, 'destinationAccountConfig' | 'dynamicTargetAssetCandidates'>): string | undefined;
|
|
12
|
+
export declare function getActiveDestinationAccount({ destinationAccountConfig, dynamicTargetAssetCandidates, dynamicRoutingId, }: Pick<FunkitCheckoutConfig, 'destinationAccountConfig' | 'dynamicTargetAssetCandidates' | 'dynamicRoutingId'>): DestinationAccount | undefined;
|
|
13
|
+
export declare function groupDestinationAccountCandidates(candidates: readonly DynamicTargetAssetCandidate[]): DestinationAssetGroup[];
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ConvertBalanceState } from './convert/balances';
|
|
2
|
+
import type { ConvertAssetBalance, ConvertResolvedAsset } from './convert/types';
|
|
3
|
+
/**
|
|
4
|
+
* A destination asset the SDK asks the host to read, with the decimals the SDK
|
|
5
|
+
* resolved so the host never has to.
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export type DestinationAsset = ConvertResolvedAsset;
|
|
9
|
+
/**
|
|
10
|
+
* One asset's wallet balance as the host read it: a base-unit integer string in
|
|
11
|
+
* the decimals the SDK passed. `"0"` means a real zero. A missing or invalid
|
|
12
|
+
* `unitPriceUsd` leaves the asset selectable without a balance label.
|
|
13
|
+
* @experimental
|
|
14
|
+
*/
|
|
15
|
+
export type DestinationAssetBalance = ConvertAssetBalance;
|
|
16
|
+
/**
|
|
17
|
+
* Reads wallet balances for the destination asset menu, in one call.
|
|
18
|
+
* - Called when the menu opens, then every 60s while it stays open.
|
|
19
|
+
* - Answer for exactly the assets passed; leave out any you can't read or
|
|
20
|
+
* don't want labelled. Don't throw.
|
|
21
|
+
* @experimental
|
|
22
|
+
*/
|
|
23
|
+
export type GetDestinationAssetBalances = (params: {
|
|
24
|
+
assets: DestinationAsset[];
|
|
25
|
+
}) => Promise<DestinationAssetBalance[]>;
|
|
26
|
+
/** What the asset menu shows for one asset's balance label. */
|
|
27
|
+
export type DestinationAssetBalanceState = {
|
|
28
|
+
status: 'loading';
|
|
29
|
+
} | {
|
|
30
|
+
status: 'unavailable';
|
|
31
|
+
} | {
|
|
32
|
+
status: 'ready';
|
|
33
|
+
tokenAmount: string;
|
|
34
|
+
usdValue: number;
|
|
35
|
+
};
|
|
36
|
+
/** Keyed by `convertAssetKey` (`chainId:address`); a missing key shows no label. */
|
|
37
|
+
export type DestinationAssetBalanceStates = Record<string, DestinationAssetBalanceState>;
|
|
38
|
+
export declare function formatDestinationAssetAmount(tokenAmount: string): string;
|
|
39
|
+
export declare function toDestinationAssetBalanceState(balance: ConvertBalanceState | undefined, decimals: number): DestinationAssetBalanceState | undefined;
|
package/dist/domains/fees.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type FeeBreakdownV2 } from '@funkit/api-base';
|
|
1
2
|
import type { CheckoutQuoteResponse } from '@funkit/utils';
|
|
2
3
|
import type { BluvoBrokerageQuote } from '../hooks/useBluvo';
|
|
3
4
|
import { LoginType } from '../providers/GeneralWalletProvider';
|
|
@@ -50,4 +51,16 @@ export declare function evaluateFeeBreakdown(evalItem: EvaluateFeeBreakdownItem
|
|
|
50
51
|
fees: CheckoutFees;
|
|
51
52
|
brokerage?: BrokerageDetails;
|
|
52
53
|
}>;
|
|
54
|
+
/**
|
|
55
|
+
* The quote's expected loss in percent, when it exceeds `thresholdPercent`;
|
|
56
|
+
* otherwise undefined.
|
|
57
|
+
*
|
|
58
|
+
* - Sums swap impact and max slippage, counting a missing field as 0 as the
|
|
59
|
+
* fee rows do. The app fee and network cost are fees rather than slippage
|
|
60
|
+
* or execution loss, so they stay out.
|
|
61
|
+
* - Leaves out `totalImpact`, which adds up to 1.25% that the backend moves
|
|
62
|
+
* into the displayed exchange rate.
|
|
63
|
+
* - Rounds to the two decimals the warning shows, so it never reads "5.00%".
|
|
64
|
+
*/
|
|
65
|
+
export declare function getHighPriceImpactPercent(feeBreakdown: Partial<Pick<FeeBreakdownV2, 'swapImpact' | 'maxSlippage'>> | undefined, thresholdPercent: number): number | undefined;
|
|
53
66
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FunkitActiveCheckoutItem, FunkitCheckoutConfig } from '../providers/FunkitCheckoutContext';
|
|
2
|
+
import type { InputAmountComponentContext } from '../providers/FunkitConfigContext';
|
|
3
|
+
import type { QuoteBuilder } from './quoteMode';
|
|
4
|
+
export declare function getInputAmountComponentContext({ quoteBuilder, assetAmount, fiatAmount, unitPrice, checkoutConfig, selectedSourceAssetInfo, }: {
|
|
5
|
+
quoteBuilder: Pick<QuoteBuilder, 'getPreQuoteAmounts'>;
|
|
6
|
+
assetAmount: number | undefined;
|
|
7
|
+
fiatAmount: number | undefined;
|
|
8
|
+
unitPrice: number;
|
|
9
|
+
checkoutConfig: Pick<FunkitCheckoutConfig, 'targetAsset' | 'targetChain' | 'targetAssetTicker' | 'destinationAccountConfig' | 'dynamicTargetAssetCandidates' | 'dynamicRoutingId'>;
|
|
10
|
+
selectedSourceAssetInfo: FunkitActiveCheckoutItem['selectedSourceAssetInfo'] | undefined;
|
|
11
|
+
}): InputAmountComponentContext;
|
|
@@ -14,6 +14,8 @@ interface UseConvertBalancesParams {
|
|
|
14
14
|
* each balance was read from (Polygon pUSD is read from the proxy).
|
|
15
15
|
*/
|
|
16
16
|
recipientAddresses: ConvertRecipientAddresses | undefined;
|
|
17
|
+
/** Isolates independent balance readers and identifies their warning logs. */
|
|
18
|
+
queryScope?: string;
|
|
17
19
|
refetchIntervalMs?: number;
|
|
18
20
|
/** Off stops reads and polling; the last read stays readable. */
|
|
19
21
|
enabled?: boolean;
|
|
@@ -46,5 +48,5 @@ export interface UseConvertBalancesResult {
|
|
|
46
48
|
* change to either is a cache miss; a late response for an old key can't
|
|
47
49
|
* replace a newer one.
|
|
48
50
|
*/
|
|
49
|
-
export declare function useConvertBalances({ checkoutId, assets, getBalances, recipientAddresses, refetchIntervalMs, enabled, }: UseConvertBalancesParams): UseConvertBalancesResult;
|
|
51
|
+
export declare function useConvertBalances({ checkoutId, assets, getBalances, recipientAddresses, queryScope, refetchIntervalMs, enabled, }: UseConvertBalancesParams): UseConvertBalancesResult;
|
|
50
52
|
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type DestinationAssetGroup } from '../domains/destinationAccount';
|
|
2
|
+
import type { DestinationAccount, DynamicTargetAssetCandidate } from '../providers/FunkitCheckoutContext/types';
|
|
3
|
+
export interface DestinationAccountSelector {
|
|
4
|
+
accounts: readonly DestinationAccount[];
|
|
5
|
+
selectedAccountId: string;
|
|
6
|
+
selectedRoutingId: string | undefined;
|
|
7
|
+
assetGroups: readonly DestinationAssetGroup[];
|
|
8
|
+
onAccountSelect: (account: DestinationAccount) => void;
|
|
9
|
+
onAssetSelect: (candidate: DynamicTargetAssetCandidate) => void;
|
|
10
|
+
}
|
|
11
|
+
interface UseDestinationAccountSelectorOptions {
|
|
12
|
+
hasHeaderTabs: boolean;
|
|
13
|
+
showTargetAssetSelection: boolean;
|
|
14
|
+
/** Screens mounted alongside another consumer opt out to avoid duplicates. */
|
|
15
|
+
logFallback?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function useDestinationAccountSelector({ hasHeaderTabs, showTargetAssetSelection, logFallback, }: UseDestinationAccountSelectorOptions): DestinationAccountSelector | undefined;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FunkitActiveCheckoutItem } from '../providers/FunkitCheckoutContext/types';
|
|
2
|
+
import { type DestinationAssetBalanceStates } from '../domains/destinationAssetBalance';
|
|
3
|
+
import type { DestinationAccountSelector } from './useDestinationAccountSelector';
|
|
4
|
+
/** Reuses Convert's host contract; unknown holdings hide labels, never deposit options. */
|
|
5
|
+
export declare function useDestinationAssetBalances(selector: Pick<DestinationAccountSelector, 'assetGroups'> | undefined, checkoutItem: FunkitActiveCheckoutItem | undefined | null, enabled: boolean): DestinationAssetBalanceStates | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The percent the large price difference warning shows, or undefined to hide
|
|
3
|
+
* it. The `highpriceimpactwarning` config turns it on per customer in Statsig
|
|
4
|
+
* and sets the threshold; it's off by default.
|
|
5
|
+
*
|
|
6
|
+
* @param feeBreakdown the quote's `baseQuote.metadata.feeBreakdown`, which the
|
|
7
|
+
* quote types leave `unknown`. Pass undefined when the screen shouldn't warn
|
|
8
|
+
* about this quote, such as while it loads or for a payment method that
|
|
9
|
+
* doesn't warn.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useHighPriceImpactPercent(feeBreakdown: unknown): number | undefined;
|