@funkit/connect 5.5.11 → 5.5.13-next.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 (35) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/components/Dialog/Dialog.d.ts +1 -1
  3. package/dist/components/Dialog/hooks.d.ts +7 -2
  4. package/dist/components/Dropdown/BaseDropdown.css.d.ts +1 -0
  5. package/dist/components/Dropdown/BaseDropdown.d.ts +7 -1
  6. package/dist/components/Dropdown/ChainDropdown.d.ts +3 -1
  7. package/dist/components/Dropdown/TokenAndChainDropdown.d.ts +25 -0
  8. package/dist/components/Dropdown/TokenDropdown.d.ts +3 -1
  9. package/dist/components/FunButton/FunButton.d.ts +1 -1
  10. package/dist/components/FunInput/FunInput.d.ts +9 -4
  11. package/dist/components/FunTransactionSummary/PaymentFeesSummary.d.ts +5 -1
  12. package/dist/components/Icons/New/BlueCircularWalletIcon.d.ts +4 -0
  13. package/dist/components/NewTokenDepositAlert/NewTokenDepositAlert.d.ts +1 -1
  14. package/dist/components/Withdraw/WithdrawContent.d.ts +17 -0
  15. package/dist/components/Withdraw/WithdrawSuccess.d.ts +13 -0
  16. package/dist/domains/quote.d.ts +6 -2
  17. package/dist/domains/relay.d.ts +12 -0
  18. package/dist/hooks/queries/useErc20Asset.d.ts +4 -0
  19. package/dist/hooks/queries/useWithdrawalQuote.d.ts +20 -0
  20. package/dist/hooks/useCheckoutDirectExecution.d.ts +2 -0
  21. package/dist/hooks/useTokenChain.d.ts +18 -0
  22. package/dist/index.css +173 -163
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +20365 -19340
  25. package/dist/modals/CheckoutModal/ConfirmationStep/KatanaBridgeAlert.d.ts +2 -0
  26. package/dist/modals/CheckoutModal/InputAmount/useAmountInput.d.ts +2 -1
  27. package/dist/modals/CheckoutModal/InputAmount/useAssetPrice.d.ts +16 -4
  28. package/dist/modals/CheckoutModal/SelectAsset.d.ts +1 -1
  29. package/dist/modals/CheckoutModal/TransferToken/TransferToken.d.ts +1 -4
  30. package/dist/modals/WithdrwalModal/WithdrawalModal.d.ts +13 -0
  31. package/dist/providers/FunkitCheckoutContext.d.ts +36 -2
  32. package/dist/providers/ModalContext.d.ts +6 -0
  33. package/dist/wallets/Wallet.d.ts +13 -0
  34. package/dist/wallets/walletConnectors/index.js +47 -47
  35. package/package.json +7 -7
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare function KatanaBridgeAlert(): React.JSX.Element;
@@ -1,7 +1,8 @@
1
+ import type { FunInputChangeEvent } from '~/components/FunInput/FunInput';
1
2
  import { type AmountInputDerivedState, type AmountInputInitOptions } from './state';
2
3
  import { type InputAmountSuggestion } from './utils';
3
4
  interface UseAmountInputResult extends AmountInputDerivedState {
4
- onChange(event: React.ChangeEvent<HTMLInputElement>): void;
5
+ onChange(event: FunInputChangeEvent): void;
5
6
  placeholder: string;
6
7
  setFiatAmount(usdAmount: number): AmountInputDerivedState;
7
8
  /** Possible user action to recover from the current error */
@@ -1,9 +1,21 @@
1
+ import { type Erc20AssetInfo } from '@funkit/api-base';
1
2
  import type { Address } from 'viem';
2
- export declare function useAssetPrice({ chainId, assetTokenAddress, }: {
3
- chainId: string | undefined;
4
- assetTokenAddress: Address | undefined;
5
- }): {
3
+ type AssetPriceResult = {
6
4
  error: Error | null;
7
5
  isLoading: boolean;
8
6
  unitPrice: number | undefined;
9
7
  };
8
+ export declare function useAssetAddressPrice({ chainId, assetTokenAddress, refetchInterval, }: {
9
+ chainId: string | undefined;
10
+ assetTokenAddress: Address | undefined;
11
+ refetchInterval?: number;
12
+ }): AssetPriceResult;
13
+ type AssetSymbolPriceParams = {
14
+ chainId: string | undefined;
15
+ symbol: string | undefined;
16
+ refetchInterval?: number;
17
+ };
18
+ export declare const useAssetSymbolPrice: ({ chainId, symbol, refetchInterval, }: AssetSymbolPriceParams) => AssetPriceResult & {
19
+ asset?: Erc20AssetInfo | null;
20
+ };
21
+ export {};
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
+ import type { TransferTokenDefault } from '~/hooks/useTokenChain';
2
3
  import { type PaymentMethodAccountInfo, type PaymentMethodBrokerageInfo } from '../../domains/paymentMethods';
3
- import type { TransferTokenDefault } from './TransferToken/TransferToken';
4
4
  import { type CheckoutModalCommonState, FunCheckoutStep, type ModalStepComponentProps, type ModalStepInfo } from './stepTransition';
5
5
  export type SelectAssetState = CheckoutModalCommonState & {
6
6
  paymentMethodInfo: PaymentMethodBrokerageInfo | PaymentMethodAccountInfo;
@@ -1,9 +1,6 @@
1
1
  import React from 'react';
2
+ import { type TransferTokenDefault } from '~/hooks/useTokenChain';
2
3
  import { type CheckoutModalCommonState, FunCheckoutStep, type ModalStepComponentProps, type ModalStepInfo } from '../stepTransition';
3
- export type TransferTokenDefault = {
4
- token: string;
5
- chainId: number;
6
- };
7
4
  export type TransferTokenState = CheckoutModalCommonState & {
8
5
  transferToken?: TransferTokenDefault;
9
6
  };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { FunkitWithdrawalConfig } from '~/providers/FunkitCheckoutContext';
3
+ export declare const WITHDRAWAL_MODAL_CONTENT_ID = "withdrawal-modal-content";
4
+ export interface WithdrawalModalProps {
5
+ open: boolean;
6
+ onClose: () => void;
7
+ config: FunkitWithdrawalConfig;
8
+ }
9
+ export declare enum WithdrawalModalStep {
10
+ ENTER_AMOUNT = "ENTER_AMOUNT",
11
+ SUCCESS = "SUCCESS"
12
+ }
13
+ export declare function WithdrawalModal({ onClose, open, config, }: WithdrawalModalProps): React.JSX.Element;
@@ -3,6 +3,7 @@ import type { ApiCheckoutClientMetadata, ApiFunkitCheckoutActionParams, ApiFunki
3
3
  import React, { type ReactNode } from 'react';
4
4
  import type { Address } from 'viem';
5
5
  import type { AssetHoldingsItem } from '~/utils/assets';
6
+ import type { WithdrawalClient } from '~/wallets/Wallet';
6
7
  import { type PaymentMethodInfo } from '../domains/paymentMethods';
7
8
  import { type FunkitCheckoutQuoteResult } from './FunkitHistoryContext';
8
9
  export type FunkitCheckoutActionParams = ApiFunkitCheckoutActionParams;
@@ -46,6 +47,25 @@ export interface FunkitCheckoutConfig extends Omit<ApiFunkitCheckoutConfig, 'gen
46
47
  /** minimal toAmount needed to proceed checkout. Checked after quote */
47
48
  targetAssetMinAmount?: number;
48
49
  }
50
+ export interface FunkitWithdrawalConfig {
51
+ /** Title to show in the checkout modal. Defaults to "Checkout" **/
52
+ modalTitle?: string;
53
+ /** Additional information to show in the title of the checkout modal. Blank by default **/
54
+ modalTitleMeta?: string;
55
+ /** Icon to show in the checkout modal (50px x 50px). If not specified, no icon will be shown. **/
56
+ iconSrc?: null | string;
57
+ sourceTokenSymbol: string;
58
+ /** source chain id to withdraw **/
59
+ sourceChainId: string;
60
+ /** source token id to withdraw **/
61
+ sourceTokenAddress: Address;
62
+ /** amount of source token. it is not baseUnit **/
63
+ sourceTokenBalance: number;
64
+ /** whether to show connected as preferred withdrawal destination*/
65
+ showConnectedWalletAsPreferredRecipient?: boolean;
66
+ /** Wallet instance used to execute the quote */
67
+ wallet: WithdrawalClient;
68
+ }
49
69
  export interface FunkitCheckoutValidationResult {
50
70
  isValid: boolean;
51
71
  message: string;
@@ -69,11 +89,11 @@ export interface UseFunkitCheckoutProps {
69
89
  onValidation?: (result: FunkitCheckoutValidationResult) => void;
70
90
  /** @optional fires when a checkout quote is received **/
71
91
  onEstimation?: (result: FunkitCheckoutQuoteResult) => void;
72
- /** @optional fires when a checkout if confirmed with the funkit server. Returns the newly created checkoutId. **/
92
+ /** @optional fires when a checkout is confirmed with the funkit server. Returns the newly created checkoutId. **/
73
93
  onConfirmation?: (checkoutId: string) => void;
74
94
  /** @optional fires if the checkout fails at any point **/
75
95
  onError?: (result: FunkitCheckoutResult) => void;
76
- /** @optional fires if the checkout fails at any point **/
96
+ /** @optional fires after the checkout steps are completed **/
77
97
  onSuccess?: (result: FunkitCheckoutResult) => void;
78
98
  /**
79
99
  * @optional
@@ -84,6 +104,10 @@ export interface UseFunkitCheckoutProps {
84
104
  onLoginRequired?: ({ onLoginFinished, }: {
85
105
  onLoginFinished?: () => void;
86
106
  }) => void;
107
+ /** @optional fires when a withdrawal is confirmed with the funkit server. Returns the newly created withdrawalId. **/
108
+ onWithdrawalConfirmation?: (withdrawalId: string) => void;
109
+ /** @optional fires if the withdrawal fails at any point **/
110
+ onWithdrawalError?: (result: FunkitCheckoutResult) => void;
87
111
  }
88
112
  /** Ensures that config is defined */
89
113
  export interface UseFunkitCheckoutPropsWithFullConfig extends UseFunkitCheckoutProps {
@@ -109,6 +133,12 @@ export interface FunkitActiveCheckoutItem extends Omit<ApiCheckoutClientMetadata
109
133
  /** Time of completion of the active checkout item. For frontend use only. **/
110
134
  completedTimestampMs: number | null;
111
135
  }
136
+ export interface FunkitActiveWithdrawalItem {
137
+ /** Unique identifier for frontend use only. */
138
+ id: string;
139
+ /** Final settings the withdrawal was init-ed with **/
140
+ initSettings: Partial<UseFunkitCheckoutPropsWithFullConfig>;
141
+ }
112
142
  interface FunkitCheckoutContextInterface {
113
143
  checkoutItem: FunkitActiveCheckoutItem | null;
114
144
  initNewCheckout(initSettings: UseFunkitCheckoutPropsWithFullConfig): string;
@@ -128,6 +158,8 @@ interface FunkitCheckoutContextInterface {
128
158
  /** @deprecated to be removed after quote migration is finished (historically named setCheckoutQuote) */
129
159
  setCheckout: (checkout: FunkitActiveCheckoutItem) => void;
130
160
  setCompletedTimestamp(timestampMs: number): void;
161
+ withdrawalItem: FunkitActiveWithdrawalItem | null;
162
+ initNewWithdrawal(initSettings: Partial<UseFunkitCheckoutPropsWithFullConfig>): string;
131
163
  }
132
164
  export declare function FunkitCheckoutProvider({ children }: {
133
165
  children: ReactNode;
@@ -140,10 +172,12 @@ export declare function useFunkitCheckout(props: UseFunkitCheckoutPropsWithFullC
140
172
  beginCheckout: (config?: Partial<FunkitCheckoutConfig>) => Promise<{
141
173
  isActivated: boolean;
142
174
  }>;
175
+ beginWithdrawal: (config: FunkitWithdrawalConfig) => void;
143
176
  };
144
177
  export declare function useFunkitCheckout(props: UseFunkitCheckoutProps): {
145
178
  beginCheckout: (config: FunkitCheckoutConfig) => Promise<{
146
179
  isActivated: boolean;
147
180
  }>;
181
+ beginWithdrawal: (config: FunkitWithdrawalConfig) => void;
148
182
  };
149
183
  export {};
@@ -1,5 +1,6 @@
1
1
  import React, { type ReactNode } from 'react';
2
2
  import type { SelectedHomeTab } from '../modals/ProfileDetails/FunProfileViews/Home';
3
+ import type { FunkitWithdrawalConfig } from './FunkitCheckoutContext';
3
4
  interface ModalProviderProps {
4
5
  children: ReactNode;
5
6
  }
@@ -29,4 +30,9 @@ export declare function useFunCheckoutModal(): {
29
30
  funCheckoutModalOpen: boolean;
30
31
  openFunCheckoutModal: ((checkoutId: string) => void) | undefined;
31
32
  };
33
+ export declare function useWithdrawalModal(): {
34
+ openWithdrawalModal: ((config: FunkitWithdrawalConfig & {
35
+ withdrawalId: string;
36
+ }) => void) | undefined;
37
+ };
32
38
  export {};
@@ -1,5 +1,6 @@
1
1
  import type { Connector, CreateConnectorFn } from 'wagmi';
2
2
  import type { WalletConnectParameters } from 'wagmi/connectors';
3
+ import type { TransactionReceipt } from 'viem';
3
4
  import type { CoinbaseWalletOptions } from './walletConnectors/coinbaseWallet/coinbaseWallet';
4
5
  import type { WalletConnectWalletOptions } from './walletConnectors/walletConnectWallet/walletConnectWallet';
5
6
  export type InstructionStepName = 'install' | 'create' | 'scan' | 'connect' | 'refresh';
@@ -97,4 +98,16 @@ export type WagmiConnectorInstance = Connector & {
97
98
  fkcDetails?: FunkitConnectDetails;
98
99
  };
99
100
  export type WalletInstance = Connector & FunkitConnectDetails;
101
+ export type WithdrawalTransaction = {
102
+ to: string;
103
+ data: string;
104
+ value: string;
105
+ };
106
+ export interface WithdrawalClient {
107
+ getChainId: () => Promise<number>;
108
+ switchChain: (chainId: number) => Promise<void>;
109
+ sendTransaction: (chainId: number, transaction: WithdrawalTransaction) => Promise<string>;
110
+ confirmTransaction: (txHash: string, chainId: number) => Promise<TransactionReceipt>;
111
+ address: () => string;
112
+ }
100
113
  export {};
@@ -1,22 +1,16 @@
1
1
  "use client";
2
- import {
3
- xdefiWallet
4
- } from "./chunk-NO7XMBB5.js";
5
2
  import {
6
3
  zealWallet
7
4
  } from "./chunk-JROWU5BP.js";
5
+ import {
6
+ walletConnectWallet
7
+ } from "./chunk-NP5QGWNL.js";
8
8
  import {
9
9
  zerionWallet
10
10
  } from "./chunk-AXWP3GD4.js";
11
11
  import {
12
12
  subWallet
13
13
  } from "./chunk-AD2KIJB6.js";
14
- import {
15
- tahoWallet
16
- } from "./chunk-6P2EMPZI.js";
17
- import {
18
- talismanWallet
19
- } from "./chunk-ABFSXBE6.js";
20
14
  import {
21
15
  tokenPocketWallet
22
16
  } from "./chunk-IDKVN5CF.js";
@@ -24,20 +18,23 @@ import {
24
18
  tokenaryWallet
25
19
  } from "./chunk-SLOIIJGP.js";
26
20
  import {
27
- uniswapWallet
28
- } from "./chunk-LH7BMNFZ.js";
21
+ tahoWallet
22
+ } from "./chunk-6P2EMPZI.js";
23
+ import {
24
+ talismanWallet
25
+ } from "./chunk-ABFSXBE6.js";
29
26
  import {
30
27
  trustWallet
31
28
  } from "./chunk-ISIBREBO.js";
32
29
  import {
33
- walletConnectWallet
34
- } from "./chunk-NP5QGWNL.js";
30
+ uniswapWallet
31
+ } from "./chunk-LH7BMNFZ.js";
35
32
  import {
36
- rabbyWallet
37
- } from "./chunk-BVX4XGNP.js";
33
+ xdefiWallet
34
+ } from "./chunk-NO7XMBB5.js";
38
35
  import {
39
- ramperWallet
40
- } from "./chunk-PIUNLQJG.js";
36
+ oneKeyWallet
37
+ } from "./chunk-4AD7VI2P.js";
41
38
  import {
42
39
  rainbowWallet
43
40
  } from "./chunk-2UCNRD7H.js";
@@ -47,6 +44,9 @@ import {
47
44
  import {
48
45
  roninWallet
49
46
  } from "./chunk-63YLN6R5.js";
47
+ import {
48
+ ramperWallet
49
+ } from "./chunk-PIUNLQJG.js";
50
50
  import {
51
51
  safeWallet
52
52
  } from "./chunk-BQQQL6UD.js";
@@ -56,18 +56,15 @@ import {
56
56
  import {
57
57
  safepalWallet
58
58
  } from "./chunk-MSFKSQBY.js";
59
- import {
60
- kresusWallet
61
- } from "./chunk-MJXPRJZT.js";
62
59
  import {
63
60
  metaMaskWallet
64
61
  } from "./chunk-G73C6P5P.js";
62
+ import {
63
+ ledgerWallet
64
+ } from "./chunk-BRBKM4PW.js";
65
65
  import {
66
66
  mewWallet
67
67
  } from "./chunk-V57WLZEE.js";
68
- import {
69
- oktoWallet
70
- } from "./chunk-ADIXAKUL.js";
71
68
  import {
72
69
  okxWallet
73
70
  } from "./chunk-4WEHDI4Y.js";
@@ -75,23 +72,26 @@ import {
75
72
  omniWallet
76
73
  } from "./chunk-7CUY5G6R.js";
77
74
  import {
78
- oneKeyWallet
79
- } from "./chunk-4AD7VI2P.js";
75
+ oktoWallet
76
+ } from "./chunk-ADIXAKUL.js";
80
77
  import {
81
78
  oneInchWallet
82
79
  } from "./chunk-OESTDX6I.js";
83
80
  import {
84
- foxWallet
85
- } from "./chunk-LMZMXEXL.js";
81
+ rabbyWallet
82
+ } from "./chunk-BVX4XGNP.js";
86
83
  import {
87
- frameWallet
88
- } from "./chunk-ZMYVTWDF.js";
84
+ enkryptWallet
85
+ } from "./chunk-SJTXS4ZW.js";
89
86
  import {
90
87
  frontierWallet
91
88
  } from "./chunk-3S2U24BJ.js";
92
89
  import {
93
90
  gateWallet
94
91
  } from "./chunk-GSOYKKIS.js";
92
+ import {
93
+ frameWallet
94
+ } from "./chunk-ZMYVTWDF.js";
95
95
  import {
96
96
  imTokenWallet
97
97
  } from "./chunk-COZ7MIQS.js";
@@ -99,54 +99,54 @@ import {
99
99
  injectedWallet
100
100
  } from "./chunk-VCVVV2K7.js";
101
101
  import {
102
- ledgerWallet
103
- } from "./chunk-BRBKM4PW.js";
104
- import {
105
- clvWallet
106
- } from "./chunk-KR6JBW5E.js";
102
+ kresusWallet
103
+ } from "./chunk-MJXPRJZT.js";
107
104
  import {
108
- bitgetWallet
109
- } from "./chunk-A5APNTGL.js";
105
+ bybitWallet
106
+ } from "./chunk-6ONTSPEY.js";
110
107
  import {
111
108
  coin98Wallet
112
109
  } from "./chunk-DTRYS3MO.js";
113
110
  import {
114
111
  coreWallet
115
112
  } from "./chunk-HBA36GW3.js";
113
+ import {
114
+ clvWallet
115
+ } from "./chunk-KR6JBW5E.js";
116
116
  import {
117
117
  coinbaseWallet
118
118
  } from "./chunk-H4IRCEZN.js";
119
+ import {
120
+ desigWallet
121
+ } from "./chunk-CTU6JCOK.js";
119
122
  import {
120
123
  dawnWallet
121
124
  } from "./chunk-LN7OD5EC.js";
122
125
  import {
123
- enkryptWallet
124
- } from "./chunk-SJTXS4ZW.js";
126
+ foxWallet
127
+ } from "./chunk-LMZMXEXL.js";
125
128
  import {
126
- desigWallet
127
- } from "./chunk-CTU6JCOK.js";
129
+ bifrostWallet
130
+ } from "./chunk-W6N74MS3.js";
128
131
  import {
129
132
  argentWallet
130
133
  } from "./chunk-WSQ2YJO2.js";
134
+ import {
135
+ bitgetWallet
136
+ } from "./chunk-A5APNTGL.js";
131
137
  import {
132
138
  bitskiWallet
133
139
  } from "./chunk-P74YPRF6.js";
134
- import {
135
- bifrostWallet
136
- } from "./chunk-W6N74MS3.js";
137
140
  import {
138
141
  bitverseWallet
139
142
  } from "./chunk-3HZRRP4Y.js";
140
143
  import {
141
144
  bloomWallet
142
145
  } from "./chunk-S27IADFU.js";
146
+ import "./chunk-23WIEY36.js";
143
147
  import {
144
148
  braveWallet
145
149
  } from "./chunk-PB254NQ4.js";
146
- import {
147
- bybitWallet
148
- } from "./chunk-6ONTSPEY.js";
149
- import "./chunk-23WIEY36.js";
150
150
  import "./chunk-WRA2DVJ7.js";
151
151
  export {
152
152
  argentWallet,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funkit/connect",
3
- "version": "5.5.11",
3
+ "version": "5.5.13-next.0",
4
4
  "description": "Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.",
5
5
  "files": [
6
6
  "dist",
@@ -88,12 +88,12 @@
88
88
  "ua-parser-js": "^1.0.37",
89
89
  "use-debounce": "^10.0.5",
90
90
  "uuid": "^9.0.1",
91
- "@funkit/api-base": "1.9.4",
92
- "@funkit/chains": "0.3.1",
93
- "@funkit/utils": "1.1.3",
94
- "@funkit/wagmi-tools": "3.0.48",
95
- "@funkit/core": "2.3.26",
96
- "@funkit/fun-relay": "0.1.8"
91
+ "@funkit/api-base": "1.9.5-next.0",
92
+ "@funkit/chains": "0.3.2-next.0",
93
+ "@funkit/core": "2.3.27-next.0",
94
+ "@funkit/wagmi-tools": "3.0.49-next.0",
95
+ "@funkit/fun-relay": "0.1.9-next.0",
96
+ "@funkit/utils": "1.1.4-next.0"
97
97
  },
98
98
  "repository": {
99
99
  "type": "git",