@coinbase/cdp-react 0.0.98 → 0.0.99
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/components/AuthButton/index.d.ts +102 -0
- package/dist/components/CDPReactProvider/index.d.ts +114 -0
- package/dist/components/CopyAddress/index.d.ts +29 -0
- package/dist/components/CopyEvmKeyButton/index.d.ts +77 -0
- package/dist/components/CopySolanaKeyButton/index.d.ts +73 -0
- package/dist/components/EnrollMfa/EnrollMfaDescription.d.ts +21 -0
- package/dist/components/EnrollMfa/EnrollMfaFlow.d.ts +27 -0
- package/dist/components/EnrollMfa/EnrollMfaFlowBackButton.d.ts +19 -0
- package/dist/components/EnrollMfa/EnrollMfaFlowProvider.d.ts +52 -0
- package/dist/components/EnrollMfa/EnrollMfaFooter.d.ts +18 -0
- package/dist/components/EnrollMfa/EnrollMfaImage.d.ts +24 -0
- package/dist/components/EnrollMfa/EnrollMfaItem.d.ts +21 -0
- package/dist/components/EnrollMfa/EnrollMfaItems.d.ts +17 -0
- package/dist/components/EnrollMfa/EnrollMfaProvider.d.ts +35 -0
- package/dist/components/EnrollMfa/EnrollMfaTitle.d.ts +21 -0
- package/dist/components/EnrollMfa/index.d.ts +65 -0
- package/dist/components/EnrollMfa/methods/sms.d.ts +25 -0
- package/dist/components/EnrollMfa/methods/totp.d.ts +25 -0
- package/dist/components/EnrollMfa/types.d.ts +48 -0
- package/dist/components/EnrollMfa/useEnrollMfaReducer.d.ts +6 -0
- package/dist/components/EnrollMfaModal/index.d.ts +111 -0
- package/dist/components/ExportWallet/index.d.ts +163 -0
- package/dist/components/ExportWalletModal/index.d.ts +173 -0
- package/dist/components/Fund/FundForm.d.ts +18 -0
- package/dist/components/Fund/FundProvider.d.ts +17 -0
- package/dist/components/Fund/FundTitle.d.ts +12 -0
- package/dist/components/Fund/components/FundAmountInput.d.ts +13 -0
- package/dist/components/Fund/components/FundErrorScreen.d.ts +7 -0
- package/dist/components/Fund/components/FundPaymentMethods.d.ts +7 -0
- package/dist/components/Fund/components/FundPresetAmountInputs.d.ts +7 -0
- package/dist/components/Fund/components/FundTransactionStatus.d.ts +6 -0
- package/dist/components/Fund/hooks/useBuyUrl.d.ts +23 -0
- package/dist/components/Fund/hooks/useEmitLifecycleStatus.d.ts +12 -0
- package/dist/components/Fund/hooks/useExchangeRate.d.ts +17 -0
- package/dist/components/Fund/hooks/usePaymentMethods.d.ts +16 -0
- package/dist/components/Fund/hooks/usePopupMonitor.d.ts +9 -0
- package/dist/components/Fund/hooks/useSetupOnrampEventListeners.d.ts +6 -0
- package/dist/components/Fund/index.d.ts +87 -0
- package/dist/components/Fund/types.d.ts +137 -0
- package/dist/components/Fund/useFundReducer.d.ts +15 -0
- package/dist/components/Fund/utils/buildPaymentMethods.d.ts +15 -0
- package/dist/components/Fund/utils/setupOnrampEventListeners.d.ts +10 -0
- package/dist/components/Fund/utils/subscribeToWindowMessage.d.ts +27 -0
- package/dist/components/FundModal/index.d.ts +106 -0
- package/dist/components/LinkAuth/LinkAuthFlow.d.ts +25 -0
- package/dist/components/LinkAuth/LinkAuthFlowBackButton.d.ts +19 -0
- package/dist/components/LinkAuth/LinkAuthFlowProvider.d.ts +60 -0
- package/dist/components/LinkAuth/LinkAuthItem.d.ts +23 -0
- package/dist/components/LinkAuth/LinkAuthItems.d.ts +17 -0
- package/dist/components/LinkAuth/LinkAuthProvider.d.ts +31 -0
- package/dist/components/LinkAuth/LinkAuthTitle.d.ts +17 -0
- package/dist/components/LinkAuth/index.d.ts +170 -0
- package/dist/components/LinkAuth/types.d.ts +31 -0
- package/dist/components/LinkAuth/utils.d.ts +12 -0
- package/dist/components/LinkAuthModal/index.d.ts +112 -0
- package/dist/components/OAuthStatusModal/index.d.ts +24 -0
- package/dist/components/SendEvmTransactionButton/index.d.ts +27 -0
- package/dist/components/SendSolanaTransactionButton/index.d.ts +27 -0
- package/dist/components/SignIn/SignInAuthMethodButtons.d.ts +26 -0
- package/dist/components/SignIn/SignInBackButton.d.ts +40 -0
- package/dist/components/SignIn/SignInCredentials.d.ts +13 -0
- package/dist/components/SignIn/SignInDescription.d.ts +35 -0
- package/dist/components/SignIn/SignInFooter.d.ts +27 -0
- package/dist/components/SignIn/SignInForm.d.ts +39 -0
- package/dist/components/SignIn/SignInImage.d.ts +38 -0
- package/dist/components/SignIn/SignInProvider.d.ts +54 -0
- package/dist/components/SignIn/SignInTitle.d.ts +35 -0
- package/dist/components/SignIn/flows/SignInWithEmail.d.ts +26 -0
- package/dist/components/SignIn/flows/SignInWithOAuth.d.ts +19 -0
- package/dist/components/SignIn/flows/SignInWithSms.d.ts +26 -0
- package/dist/components/SignIn/hooks/useEmailForm.d.ts +7 -0
- package/dist/components/SignIn/hooks/useOTPForm.d.ts +8 -0
- package/dist/components/SignIn/hooks/usePhoneNumberForm.d.ts +7 -0
- package/dist/components/SignIn/hooks/useSignInWithOAuth.d.ts +8 -0
- package/dist/components/SignIn/index.d.ts +124 -0
- package/dist/components/SignIn/types.d.ts +37 -0
- package/dist/components/SignIn/useSignInReducer.d.ts +9 -0
- package/dist/components/SignInModal/index.d.ts +123 -0
- package/dist/components/SignOutButton/index.d.ts +39 -0
- package/dist/components/ThemeProvider/index.d.ts +70 -0
- package/dist/components/VerifyMfa/VerifyMfaDescription.d.ts +24 -0
- package/dist/components/VerifyMfa/VerifyMfaFlow.d.ts +30 -0
- package/dist/components/VerifyMfa/VerifyMfaFlowBackButton.d.ts +19 -0
- package/dist/components/VerifyMfa/VerifyMfaFlowProvider.d.ts +51 -0
- package/dist/components/VerifyMfa/VerifyMfaFooter.d.ts +18 -0
- package/dist/components/VerifyMfa/VerifyMfaImage.d.ts +23 -0
- package/dist/components/VerifyMfa/VerifyMfaItem.d.ts +20 -0
- package/dist/components/VerifyMfa/VerifyMfaItems.d.ts +18 -0
- package/dist/components/VerifyMfa/VerifyMfaProvider.d.ts +40 -0
- package/dist/components/VerifyMfa/VerifyMfaTitle.d.ts +24 -0
- package/dist/components/VerifyMfa/index.d.ts +55 -0
- package/dist/components/VerifyMfa/methods/sms.d.ts +29 -0
- package/dist/components/VerifyMfa/methods/totp.d.ts +29 -0
- package/dist/components/VerifyMfa/types.d.ts +33 -0
- package/dist/components/VerifyMfa/useVerifyMfaReducer.d.ts +7 -0
- package/dist/components/VerifyMfaInline/index.d.ts +212 -0
- package/dist/components/VerifyMfaModal/index.d.ts +114 -0
- package/dist/components/forms/AmountInput/index.d.ts +16 -0
- package/dist/components/forms/AmountInput/types.d.ts +9 -0
- package/dist/components/forms/AmountInput/useAmountInput.d.ts +14 -0
- package/dist/components/forms/AmountInput/useInputScale.d.ts +12 -0
- package/dist/components/forms/AmountInput/useNumberParseAndFormat.d.ts +20 -0
- package/dist/components/forms/CountrySelect/index.d.ts +9 -0
- package/dist/components/forms/EmailForm/index.d.ts +17 -0
- package/dist/components/forms/ExchangeAmountInput/index.d.ts +19 -0
- package/dist/components/forms/ExchangeAmountInput/types.d.ts +12 -0
- package/dist/components/forms/ExchangeAmountInput/useExchangeAmountInput.d.ts +17 -0
- package/dist/components/forms/Field/index.d.ts +15 -0
- package/dist/components/forms/Input/index.d.ts +15 -0
- package/dist/components/forms/Label/index.d.ts +8 -0
- package/dist/components/forms/OTP/index.d.ts +6 -0
- package/dist/components/forms/OTPForm/index.d.ts +20 -0
- package/dist/components/forms/PhoneNumberForm/index.d.ts +27 -0
- package/dist/components/forms/PhoneNumberInput/index.d.ts +16 -0
- package/dist/components/forms/PhoneNumberInput/maskOverride.d.ts +6 -0
- package/dist/components/forms/PhoneNumberInput/usePhoneNumberFormatter.d.ts +7 -0
- package/dist/components/forms/Select/index.d.ts +30 -0
- package/dist/components/ui/Badge/index.d.ts +19 -0
- package/dist/components/ui/Banner/index.d.ts +25 -0
- package/dist/components/ui/Button/index.d.ts +50 -0
- package/dist/components/ui/ButtonBase/index.d.ts +20 -0
- package/dist/components/ui/CoinbaseFooter/index.d.ts +16 -0
- package/dist/components/ui/CopyTextField/index.d.ts +35 -0
- package/dist/components/ui/Error/index.d.ts +14 -0
- package/dist/components/ui/IframeButton/index.d.ts +17 -0
- package/dist/components/ui/LoadingSkeleton/index.d.ts +22 -0
- package/dist/components/ui/LoadingSpinner/index.d.ts +11 -0
- package/dist/components/ui/Modal/index.d.ts +82 -0
- package/dist/components/ui/QRCode/QRCodeSvg.d.ts +35 -0
- package/dist/components/ui/QRCode/index.d.ts +7 -0
- package/dist/components/ui/QRCode/useCorners.d.ts +9 -0
- package/dist/components/ui/QRCode/useDotsPath.d.ts +18 -0
- package/dist/components/ui/QRCode/useLogo.d.ts +18 -0
- package/dist/components/ui/QRCode/useMatrix.d.ts +7 -0
- package/dist/components/ui/ServerError/index.d.ts +6 -0
- package/dist/components/ui/SuccessMessage/index.d.ts +14 -0
- package/dist/components/ui/SwitchFadeTransition/index.d.ts +15 -0
- package/dist/components/ui/SwitchSlideTransition/index.d.ts +16 -0
- package/dist/components/ui/SwitchTransition/index.d.ts +42 -0
- package/dist/components/ui/ToggleListItem/index.d.ts +31 -0
- package/dist/components/ui/VisuallyHidden/index.d.ts +18 -0
- package/dist/data/countries.d.ts +15 -0
- package/dist/data/countryNames.d.ts +4 -0
- package/dist/hooks/useKeyExportPostMessage.d.ts +25 -0
- package/dist/hooks/usePhoneNumberState.d.ts +47 -0
- package/dist/hooks/usePhoneNumberValidators.d.ts +8 -0
- package/dist/hooks/useTimeout.d.ts +18 -0
- package/dist/hooks/useTimer.d.ts +6 -0
- package/dist/hooks/useTransitionMap.d.ts +22 -0
- package/dist/hooks/useVerifyMfaModal.d.ts +78 -0
- package/dist/icons/IconAppleLogo.d.ts +22 -0
- package/dist/icons/IconArrowLeft.d.ts +22 -0
- package/dist/icons/IconArrowsUpDown.d.ts +22 -0
- package/dist/icons/IconCheck.d.ts +22 -0
- package/dist/icons/IconCheckCircle.d.ts +21 -0
- package/dist/icons/IconChevronDown.d.ts +22 -0
- package/dist/icons/IconCoinbaseMark.d.ts +22 -0
- package/dist/icons/IconCoinbaseWordmark.d.ts +22 -0
- package/dist/icons/IconCopy.d.ts +22 -0
- package/dist/icons/IconCreditCard.d.ts +22 -0
- package/dist/icons/IconCurrencies.d.ts +22 -0
- package/dist/icons/IconEnvelope.d.ts +22 -0
- package/dist/icons/IconExclamationCircle.d.ts +22 -0
- package/dist/icons/IconExclamationTriangle.d.ts +22 -0
- package/dist/icons/IconGoogleColorLogo.d.ts +22 -0
- package/dist/icons/IconGoogleLogo.d.ts +22 -0
- package/dist/icons/IconLock.d.ts +22 -0
- package/dist/icons/IconMinus.d.ts +21 -0
- package/dist/icons/IconPhone.d.ts +22 -0
- package/dist/icons/IconPinCode.d.ts +22 -0
- package/dist/icons/IconPlus.d.ts +21 -0
- package/dist/icons/IconShield.d.ts +22 -0
- package/dist/icons/IconSmartPhone.d.ts +22 -0
- package/dist/icons/IconTelegramLogo.d.ts +22 -0
- package/dist/icons/IconXLogo.d.ts +22 -0
- package/dist/icons/IconXMark.d.ts +22 -0
- package/dist/icons/SvgIcon.d.ts +6 -0
- package/dist/theme/cssVariables.d.ts +10 -0
- package/dist/theme/theme.d.ts +246 -0
- package/dist/theme/tokens.d.ts +54 -0
- package/dist/theme/utils.d.ts +63 -0
- package/dist/types/secureIframe.d.ts +3 -0
- package/dist/utils/capitalize.d.ts +8 -0
- package/dist/utils/childrenHasComponent.d.ts +10 -0
- package/dist/utils/clamp.d.ts +10 -0
- package/dist/utils/formatFiat.d.ts +11 -0
- package/dist/utils/formatPhoneNumber.d.ts +8 -0
- package/dist/utils/getMessageFromUnknownError.d.ts +9 -0
- package/dist/utils/isApiError.d.ts +21 -0
- package/dist/utils/isEmailInvalid.d.ts +15 -0
- package/dist/utils/openPopup.d.ts +15 -0
- package/dist/utils/parseValuesFromPhoneNumber.d.ts +16 -0
- package/dist/utils/sendIframeMessage.d.ts +8 -0
- package/dist/utils/toOAuthProviderType.d.ts +8 -0
- package/dist/utils/transition.d.ts +41 -0
- package/dist/version.d.ts +5 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
|
@@ -5,6 +5,93 @@ import { useFundContext } from './FundProvider';
|
|
|
5
5
|
import { FundTitle, FundTitleProps } from './FundTitle';
|
|
6
6
|
import { FetchBuyUrlParams } from './hooks/useBuyUrl';
|
|
7
7
|
import { CamelToSnakeCase, CamelToSnakeCaseNested, FundAction, FetchBuyOptions, FetchBuyQuote, FundPaymentMethod, FundPresetAmountInputs, FundProps, FundState, FundStateError, FundStateProps, FundContextType, FundLifecycleStatus, OnrampAmount, OnrampBuyQuoteResponse, OnrampBuyOptionsResponse, OnrampBuyOptionsSnakeCaseResponse, OnrampBuyQuoteSnakeCaseResponse, OnrampError, OnrampNetwork, OnrampPaymentCurrency, OnrampPaymentMethodLimit, OnrampPurchaseCurrency, OnrampSuccessEventData } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* The Fund component.
|
|
10
|
+
*
|
|
11
|
+
* @param {FundProps} props - The props of the Fund component.
|
|
12
|
+
* @param {ReactNode | ((state: FundState) => ReactNode)} props.children - The children of the Fund component. If a function is provided, it will be called with the current state of the Fund component.
|
|
13
|
+
* @param {string} [props.className] - The class name of the Fund component.
|
|
14
|
+
* @returns {JSX.Element} The Fund component.
|
|
15
|
+
*
|
|
16
|
+
* @group Components
|
|
17
|
+
*
|
|
18
|
+
* @document ./README.md
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx lines
|
|
22
|
+
* // Basic usage
|
|
23
|
+
* const App = () => {
|
|
24
|
+
* const fetchBuyQuote: FundProps["fetchBuyQuote"] = async (params) => {
|
|
25
|
+
* // call the buy quote API
|
|
26
|
+
* }
|
|
27
|
+
* const fetchBuyOptions: FundProps["fetchBuyOptions"] = async params => {
|
|
28
|
+
* // call the buy options API
|
|
29
|
+
* }
|
|
30
|
+
* return (
|
|
31
|
+
* <Fund
|
|
32
|
+
* country="US"
|
|
33
|
+
* subdivision="NY"
|
|
34
|
+
* cryptoCurrency="eth"
|
|
35
|
+
* fiatCurrency="usd"
|
|
36
|
+
* fetchBuyQuote={fetchBuyQuote}
|
|
37
|
+
* fetchBuyOptions={fetchBuyOptions}
|
|
38
|
+
* network="base"
|
|
39
|
+
* presetAmountInputs={[10, 25, 50]}
|
|
40
|
+
* />
|
|
41
|
+
* )
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx lines
|
|
47
|
+
* // Example customizing the children to render the title as a page title
|
|
48
|
+
* // and add a custom error message
|
|
49
|
+
* const App = () => {
|
|
50
|
+
* const fetchBuyQuote: FundProps["fetchBuyQuote"] = async (params) => {
|
|
51
|
+
* // call the buy quote API
|
|
52
|
+
* }
|
|
53
|
+
* const fetchBuyOptions: FundProps["fetchBuyOptions"] = async params => {
|
|
54
|
+
* // call the buy options API
|
|
55
|
+
* }
|
|
56
|
+
* const title = "Buy ETH";
|
|
57
|
+
* const titleId = useId();
|
|
58
|
+
* const submitLabel = "Purchase now";
|
|
59
|
+
* return (
|
|
60
|
+
* <Fund
|
|
61
|
+
* country="US"
|
|
62
|
+
* subdivision="NY"
|
|
63
|
+
* cryptoCurrency="eth"
|
|
64
|
+
* fiatCurrency="usd"
|
|
65
|
+
* fetchBuyQuote={fetchBuyQuote}
|
|
66
|
+
* fetchBuyOptions={fetchBuyOptions}
|
|
67
|
+
* network="base"
|
|
68
|
+
* presetAmountInputs={[10, 25, 50]}
|
|
69
|
+
* submitLabel={submitLabel}
|
|
70
|
+
* title={title}
|
|
71
|
+
* >
|
|
72
|
+
* <FundTitle as="h1" id={titleId}>{title}</FundTitle>
|
|
73
|
+
* <FundForm aria-labelledby={titleId} submitLabel={submitLabel}>
|
|
74
|
+
* {({ view, Content }) => (
|
|
75
|
+
* <>
|
|
76
|
+
* {Content}
|
|
77
|
+
* {view === "error" && <p>Contact support at support@example.com</p>}
|
|
78
|
+
* </>
|
|
79
|
+
* )}
|
|
80
|
+
* </FundForm>
|
|
81
|
+
* <FundFooter />
|
|
82
|
+
* </Fund>
|
|
83
|
+
* )
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
8
87
|
declare const Fund: ({ className, children, openIn, style, submitLabel, title, ...props }: FundProps) => import("react/jsx-runtime").JSX.Element;
|
|
88
|
+
/**
|
|
89
|
+
* The FundFooter component.
|
|
90
|
+
*
|
|
91
|
+
* @param {HTMLAttributes<HTMLDivElement>} props - The props of the FundFooter component.
|
|
92
|
+
* @returns {JSX.Element} The FundFooter component.
|
|
93
|
+
*
|
|
94
|
+
* @group Components
|
|
95
|
+
*/
|
|
9
96
|
declare const FundFooter: (props: HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
|
|
10
97
|
export { Fund, FundFooter, FundForm, FundTitle, useFundContext, type CamelToSnakeCase, type CamelToSnakeCaseNested, type FundAction, type FetchBuyOptions, type FetchBuyQuote, type FetchBuyUrlParams, type FundContextType, type FundFormProps, type FundLifecycleStatus, type FundPaymentMethod, type FundPresetAmountInputs, type FundProps, type FundState, type FundStateError, type FundStateProps, type FundTitleProps, type InputType, type OnrampAmount, type OnrampBuyQuoteResponse, type OnrampBuyOptionsResponse, type OnrampBuyOptionsSnakeCaseResponse, type OnrampBuyQuoteSnakeCaseResponse, type OnrampError, type OnrampNetwork, type OnrampPaymentCurrency, type OnrampPaymentMethodLimit, type OnrampPurchaseCurrency, type OnrampSuccessEventData, };
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { CSSProperties, Dispatch, ReactNode } from 'react';
|
|
2
2
|
import { InputType } from '../forms/ExchangeAmountInput/types';
|
|
3
3
|
import { FetchBuyUrlParams } from './hooks/useBuyUrl';
|
|
4
|
+
/**
|
|
5
|
+
* Convert a camel case string to a snake case string
|
|
6
|
+
*/
|
|
4
7
|
export type CamelToSnakeCase<T extends string> = T extends `${infer A}${infer B}` ? B extends Uncapitalize<B> ? `${A}${CamelToSnakeCase<B>}` : `${Uncapitalize<A>}_${CamelToSnakeCase<Uncapitalize<B>>}` : T;
|
|
8
|
+
/**
|
|
9
|
+
* Convert a camel case object to a snake case object
|
|
10
|
+
*/
|
|
5
11
|
export type CamelToSnakeCaseNested<T> = T extends readonly any[] ? T : T extends object ? {
|
|
6
12
|
[K in keyof T as K extends string ? CamelToSnakeCase<K> : K]: CamelToSnakeCaseNested<T[K]>;
|
|
7
13
|
} : T;
|
|
14
|
+
/**
|
|
15
|
+
* Present amounts for the fund component.
|
|
16
|
+
*/
|
|
8
17
|
export type FundPresetAmountInputs = readonly [number, number, number];
|
|
18
|
+
/**
|
|
19
|
+
* A payment method for the fund component.
|
|
20
|
+
*/
|
|
9
21
|
export interface FundPaymentMethod {
|
|
10
22
|
id: string;
|
|
11
23
|
name: string;
|
|
@@ -14,42 +26,72 @@ export interface FundPaymentMethod {
|
|
|
14
26
|
minAmount?: number;
|
|
15
27
|
maxAmount?: number;
|
|
16
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The event that is emitted when the onramp widget is opened.
|
|
31
|
+
*/
|
|
17
32
|
export type OnrampOpenEvent = {
|
|
18
33
|
eventName: "open";
|
|
19
34
|
widgetName: string;
|
|
20
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* The event that is emitted when the onramp widget transitions to a new view.
|
|
38
|
+
*/
|
|
21
39
|
export type OnrampTransitionViewEvent = {
|
|
22
40
|
eventName: "transition_view";
|
|
23
41
|
pageRoute: string;
|
|
24
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* The event that is emitted when an error occurs in the onramp widget.
|
|
45
|
+
*/
|
|
25
46
|
export type OnrampPublicErrorEvent = {
|
|
26
47
|
eventName: "error";
|
|
27
48
|
error: OnrampError;
|
|
28
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* The event that is emitted when the onramp widget is exited.
|
|
52
|
+
*/
|
|
29
53
|
export type OnrampExitEvent = {
|
|
30
54
|
eventName: "exit";
|
|
31
55
|
error?: OnrampError;
|
|
32
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* The event that is emitted when the transaction inside the onramp widget is successful.
|
|
59
|
+
*/
|
|
33
60
|
export type OnrampSuccessEvent = {
|
|
34
61
|
eventName: "success";
|
|
35
62
|
data?: OnrampSuccessEventData;
|
|
36
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* Data that is emitted with the onramp transaction success event.
|
|
66
|
+
*/
|
|
37
67
|
export type OnrampSuccessEventData = {
|
|
38
68
|
assetImageUrl: string;
|
|
39
69
|
assetName: string;
|
|
40
70
|
assetSymbol: string;
|
|
41
71
|
chainId: string;
|
|
42
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Todo: figure out when this is emitted
|
|
75
|
+
*/
|
|
43
76
|
export type RequestOpenUrlEvent = {
|
|
44
77
|
eventName: "request_open_url";
|
|
45
78
|
url: string;
|
|
46
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* Union type of all events that can be emitted by the onramp widget.
|
|
82
|
+
*/
|
|
47
83
|
export type EventMetadata = OnrampOpenEvent | OnrampTransitionViewEvent | OnrampPublicErrorEvent | OnrampExitEvent | OnrampSuccessEvent | RequestOpenUrlEvent;
|
|
84
|
+
/**
|
|
85
|
+
* An error that occurred during the onramp process.
|
|
86
|
+
*/
|
|
48
87
|
export interface OnrampError {
|
|
49
88
|
errorType: "internal_error" | "handled_error" | "network_error" | "unknown_error";
|
|
50
89
|
code?: string;
|
|
51
90
|
debugMessage?: string;
|
|
52
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* The lifecycle statuses of the Fund component.
|
|
94
|
+
*/
|
|
53
95
|
export type FundLifecycleStatus = {
|
|
54
96
|
statusName: "init";
|
|
55
97
|
statusData: null;
|
|
@@ -69,16 +111,26 @@ export type FundLifecycleStatus = {
|
|
|
69
111
|
statusName: "transactionPending";
|
|
70
112
|
statusData: null;
|
|
71
113
|
};
|
|
114
|
+
/** Lifecycle statuses that indicate a transaction resolution. */
|
|
72
115
|
export type FundTxResolution = Extract<FundLifecycleStatus["statusName"], "transactionSubmitted" | "transactionSuccess" | "error"> | null;
|
|
116
|
+
/**
|
|
117
|
+
* The events that can be emitted by the Fund component.
|
|
118
|
+
*/
|
|
73
119
|
export type FundLifecycleEvents = {
|
|
74
120
|
onError?: (e: OnrampError | undefined) => void;
|
|
75
121
|
onStatus?: (lifecycleStatus: FundLifecycleStatus) => void;
|
|
76
122
|
onSuccess?: (result?: OnrampSuccessEventData) => void;
|
|
77
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* The type for an error that may get displayed in the UI.
|
|
126
|
+
*/
|
|
78
127
|
export type FundStateError = {
|
|
79
128
|
code: string;
|
|
80
129
|
message: string;
|
|
81
130
|
};
|
|
131
|
+
/**
|
|
132
|
+
* The state of the Fund component.
|
|
133
|
+
*/
|
|
82
134
|
export interface FundState {
|
|
83
135
|
country: string;
|
|
84
136
|
cryptoAmount?: number;
|
|
@@ -102,7 +154,13 @@ export interface FundState {
|
|
|
102
154
|
transactionStatus: FundLifecycleStatus;
|
|
103
155
|
destinationAddress: string;
|
|
104
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Props from the Fund component that are used in the FundState.
|
|
159
|
+
*/
|
|
105
160
|
export type FundStateProps = Pick<FundState, "country" | "cryptoCurrency" | "cryptoDecimalPlaces" | "fiatCurrency" | "fiatDecimalPlaces" | "locale" | "network" | "presetAmountInputs" | "subdivision" | "destinationAddress">;
|
|
161
|
+
/**
|
|
162
|
+
* All the props for the Fund component.
|
|
163
|
+
*/
|
|
106
164
|
export interface FundProps extends FundStateProps, FundLifecycleEvents {
|
|
107
165
|
children?: ReactNode | ((state: FundState) => ReactNode);
|
|
108
166
|
className?: string;
|
|
@@ -115,6 +173,9 @@ export interface FundProps extends FundStateProps, FundLifecycleEvents {
|
|
|
115
173
|
submitLabel?: ReactNode;
|
|
116
174
|
title?: ReactNode;
|
|
117
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* The actions that can be dispatched to the Fund component.
|
|
178
|
+
*/
|
|
118
179
|
export type FundAction = {
|
|
119
180
|
type: "SET_FIELD";
|
|
120
181
|
payload: {
|
|
@@ -162,20 +223,36 @@ export type FundAction = {
|
|
|
162
223
|
type: "SYNC_WITH_PROPS";
|
|
163
224
|
payload: FundStateProps;
|
|
164
225
|
};
|
|
226
|
+
/**
|
|
227
|
+
* The context type for the Fund component.
|
|
228
|
+
*/
|
|
165
229
|
export type FundContextType = {
|
|
166
230
|
state: FundState;
|
|
167
231
|
dispatch: Dispatch<FundAction>;
|
|
168
232
|
fetchBuyUrl: (params: FetchBuyUrlParams, onError?: (e: OnrampError | undefined) => void) => Promise<string>;
|
|
169
233
|
};
|
|
234
|
+
/**
|
|
235
|
+
* Onramp API types
|
|
236
|
+
* We define the types in camel case and derive snake case types for backwards compatibility with the old version of the API.
|
|
237
|
+
*/
|
|
238
|
+
/**
|
|
239
|
+
* Payment method limit data
|
|
240
|
+
*/
|
|
170
241
|
export type OnrampPaymentMethodLimit = {
|
|
171
242
|
id: string;
|
|
172
243
|
min: string;
|
|
173
244
|
max: string;
|
|
174
245
|
};
|
|
246
|
+
/**
|
|
247
|
+
* Payment currency data
|
|
248
|
+
*/
|
|
175
249
|
export type OnrampPaymentCurrency = {
|
|
176
250
|
id: string;
|
|
177
251
|
limits: OnrampPaymentMethodLimit[];
|
|
178
252
|
};
|
|
253
|
+
/**
|
|
254
|
+
* Network data
|
|
255
|
+
*/
|
|
179
256
|
export type OnrampNetwork = {
|
|
180
257
|
name: string;
|
|
181
258
|
displayName: string;
|
|
@@ -183,6 +260,9 @@ export type OnrampNetwork = {
|
|
|
183
260
|
contractAddress: string;
|
|
184
261
|
iconUrl: string;
|
|
185
262
|
};
|
|
263
|
+
/**
|
|
264
|
+
* Purchase currency data
|
|
265
|
+
*/
|
|
186
266
|
export type OnrampPurchaseCurrency = {
|
|
187
267
|
id: string;
|
|
188
268
|
name: string;
|
|
@@ -190,29 +270,86 @@ export type OnrampPurchaseCurrency = {
|
|
|
190
270
|
iconUrl: string;
|
|
191
271
|
networks: OnrampNetwork[];
|
|
192
272
|
};
|
|
273
|
+
/**
|
|
274
|
+
* Onramp Amount
|
|
275
|
+
*/
|
|
193
276
|
export type OnrampAmount = {
|
|
194
277
|
value: string;
|
|
195
278
|
currency: string;
|
|
196
279
|
};
|
|
280
|
+
/**
|
|
281
|
+
* The response from the Onramp Buy Options API
|
|
282
|
+
*/
|
|
197
283
|
export type OnrampBuyOptionsResponse = {
|
|
284
|
+
/**
|
|
285
|
+
* List of supported fiat currencies that can be exchanged for crypto on Onramp in the given location.
|
|
286
|
+
* Each currency contains a list of available payment methods, with min and max transaction limits for that currency.
|
|
287
|
+
*/
|
|
198
288
|
paymentCurrencies: OnrampPaymentCurrency[];
|
|
289
|
+
/**
|
|
290
|
+
* List of available crypto assets that can be bought on Onramp in the given location.
|
|
291
|
+
*/
|
|
199
292
|
purchaseCurrencies: OnrampPurchaseCurrency[];
|
|
200
293
|
};
|
|
294
|
+
/**
|
|
295
|
+
* The response from the Onramp Buy Options API in snake case.
|
|
296
|
+
* For the v1 API, the response is in snake case.
|
|
297
|
+
*/
|
|
201
298
|
export type OnrampBuyOptionsSnakeCaseResponse = CamelToSnakeCaseNested<OnrampBuyOptionsResponse>;
|
|
299
|
+
/**
|
|
300
|
+
* The response from the Onramp Buy Quote API
|
|
301
|
+
*/
|
|
202
302
|
export type OnrampBuyQuoteResponse = {
|
|
303
|
+
/**
|
|
304
|
+
* Object with amount and currency of the total fiat payment required to complete the purchase, inclusive of any fees.
|
|
305
|
+
* The currency will match the `paymentCurrency` in the request if it is supported, otherwise it falls back to USD.
|
|
306
|
+
*/
|
|
203
307
|
paymentTotal: OnrampAmount;
|
|
308
|
+
/**
|
|
309
|
+
* Object with amount and currency of the fiat cost of the crypto asset to be purchased, exclusive of any fees.
|
|
310
|
+
* The currency will match the `paymentCurrency`.
|
|
311
|
+
*/
|
|
204
312
|
paymentSubtotal: OnrampAmount;
|
|
313
|
+
/**
|
|
314
|
+
* Object with amount and currency of the crypto that to be purchased.
|
|
315
|
+
* The currency will match the `purchaseCurrency` in the request.
|
|
316
|
+
* The number of decimals will be based on the crypto asset.
|
|
317
|
+
*/
|
|
205
318
|
purchaseAmount: OnrampAmount;
|
|
319
|
+
/**
|
|
320
|
+
* Object with amount and currency of the fee changed by the Coinbase exchange to complete the transaction.
|
|
321
|
+
* The currency will match the `paymentCurrency`.
|
|
322
|
+
*/
|
|
206
323
|
coinbaseFee: OnrampAmount;
|
|
324
|
+
/**
|
|
325
|
+
* Object with amount and currency of the network fee required to send the purchased crypto to the user's wallet.
|
|
326
|
+
* The currency will match the `paymentCurrency`.
|
|
327
|
+
*/
|
|
207
328
|
networkFee: OnrampAmount;
|
|
329
|
+
/**
|
|
330
|
+
* Reference to the quote that should be passed into the initialization parameters when launching the Coinbase Onramp widget via the SDK or URL generator.
|
|
331
|
+
*/
|
|
208
332
|
quoteId: string;
|
|
333
|
+
/**
|
|
334
|
+
* Ready-to-use one-click-buy URL. Only returned when destination_address is provided in the request.
|
|
335
|
+
*/
|
|
209
336
|
onrampUrl?: string;
|
|
210
337
|
};
|
|
338
|
+
/**
|
|
339
|
+
* The response from the Onramp Buy Quote API in snake case.
|
|
340
|
+
* For the v1 API, the response is in snake case.
|
|
341
|
+
*/
|
|
211
342
|
export type OnrampBuyQuoteSnakeCaseResponse = CamelToSnakeCaseNested<OnrampBuyQuoteResponse>;
|
|
343
|
+
/**
|
|
344
|
+
* Get Buy Options function (used for building list of payment methods)
|
|
345
|
+
*/
|
|
212
346
|
export type FetchBuyOptions = (params: {
|
|
213
347
|
country: string;
|
|
214
348
|
subdivision?: string;
|
|
215
349
|
}) => Promise<OnrampBuyOptionsResponse>;
|
|
350
|
+
/**
|
|
351
|
+
* Get Buy Quote function (used for fetching the exchange rate and building the buy url)
|
|
352
|
+
*/
|
|
216
353
|
export type FetchBuyQuote = (params: {
|
|
217
354
|
destinationAddress: string;
|
|
218
355
|
purchaseCurrency: string;
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { FundAction, FundState } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A reducer hook for the Fund component.
|
|
4
|
+
*
|
|
5
|
+
* @param {FundState} initialState - The initial state of the component.
|
|
6
|
+
*
|
|
7
|
+
* @returns {[FundState, FundAction]} The current state and dispatcher to perform actions on the state.
|
|
8
|
+
*/
|
|
2
9
|
export declare const useFundReducer: (initialState: FundState) => [FundState, import('react').ActionDispatch<[action: FundAction]>];
|
|
10
|
+
/**
|
|
11
|
+
* A generic function to build a SET_FIELD action.
|
|
12
|
+
*
|
|
13
|
+
* @param field - The field from the FundState to set.
|
|
14
|
+
* @param value - The value to set for the field.
|
|
15
|
+
*
|
|
16
|
+
* @returns {FundAction} The action to perform on the state.
|
|
17
|
+
*/
|
|
3
18
|
export declare const createSetFieldAction: <K extends keyof FundState>(field: K, value: FundState[K]) => {
|
|
4
19
|
type: "SET_FIELD";
|
|
5
20
|
payload: {
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { OnrampBuyOptionsResponse, FundPaymentMethod } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Coinbase payment method description is built using the available payment methods and adding Crypto Balance to the end of the array.
|
|
4
|
+
* i.e. If the API returns Card, ACH, and Fiat, the description will be "Card, ACH, Cash, Crypto Balance".
|
|
5
|
+
*
|
|
6
|
+
* @param paymentMethodLimits - The limits for the payment methods.
|
|
7
|
+
* @returns The description of the payment methods.
|
|
8
|
+
*/
|
|
2
9
|
export declare const buildCoinbasePaymentMethodDescription: (paymentMethodLimits: Array<{
|
|
3
10
|
id: string;
|
|
4
11
|
}>) => string;
|
|
12
|
+
/**
|
|
13
|
+
* Builds the payment methods for the given payment options.
|
|
14
|
+
*
|
|
15
|
+
* @param paymentOptions - The payment options from the Buy Options API.
|
|
16
|
+
* @param currency - The currency.
|
|
17
|
+
* @param country - The country.
|
|
18
|
+
* @returns The payment methods.
|
|
19
|
+
*/
|
|
5
20
|
export declare const buildPaymentMethods: (paymentOptions: OnrampBuyOptionsResponse, currency: string, country: string) => FundPaymentMethod[];
|
|
@@ -4,5 +4,15 @@ type SetupOnrampEventListenersParams = {
|
|
|
4
4
|
onExit?: (error?: OnrampError) => void;
|
|
5
5
|
onSuccess?: (data?: OnrampSuccessEventData) => void;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Subscribes to events from the Coinbase Onramp widget.
|
|
9
|
+
*
|
|
10
|
+
* @param {SetupOnrampEventListenersParams} params - The function params
|
|
11
|
+
* @param {string} [params.host] - The host to subscribe to.
|
|
12
|
+
* @param {(event: EventMetadata) => void} params.onEvent - Callback for when any event is received.
|
|
13
|
+
* @param {(error?: OnrampError) => void} params.onExit - Callback for when an exit event is received.
|
|
14
|
+
* @param {(data?: SuccessEventData) => void} params.onSuccess - Callback for when a success event is received.
|
|
15
|
+
* @returns a function to unsubscribe from the event listener.
|
|
16
|
+
*/
|
|
7
17
|
export declare function setupOnrampEventListeners({ onEvent, onExit, onSuccess, }: SetupOnrampEventListenersParams): () => void;
|
|
8
18
|
export {};
|
|
@@ -1,11 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was copied and adapted from Coinbase Onchainkit (fund/utils/subscribeToWindowMessage.ts)
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Matches a JSON object.
|
|
6
|
+
* This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
|
|
7
|
+
*/
|
|
1
8
|
export type JsonObject = {
|
|
2
9
|
[Key in string]?: JsonValue;
|
|
3
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Matches a JSON array.
|
|
13
|
+
*/
|
|
4
14
|
export type JsonArray = JsonValue[];
|
|
15
|
+
/**
|
|
16
|
+
* Matches any valid JSON primitive value.
|
|
17
|
+
*/
|
|
5
18
|
export type JsonPrimitive = string | number | boolean | null;
|
|
19
|
+
/**
|
|
20
|
+
* Matches any valid JSON value.
|
|
21
|
+
*
|
|
22
|
+
* @see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
|
|
23
|
+
*/
|
|
6
24
|
export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
7
25
|
export declare const DEFAULT_ONRAMP_URL: string[];
|
|
8
26
|
type MessageData = JsonObject;
|
|
27
|
+
/**
|
|
28
|
+
* Subscribes to a message from the parent window.
|
|
29
|
+
*
|
|
30
|
+
* @param {object} params - The function params
|
|
31
|
+
* @param {(data?: MessageData) => void} params.onMessage - Callback for when the message is received.
|
|
32
|
+
* @param {string} params.allowedOrigin - The origin to allow messages from.
|
|
33
|
+
* @param {(origin: string) => Promise<boolean>} [params.onValidateOrigin] - Callback to validate the origin of the message.
|
|
34
|
+
* @returns A function to unsubscribe from the event listener.
|
|
35
|
+
*/
|
|
9
36
|
export declare function subscribeToWindowMessage({ onMessage, allowedOrigin, onValidateOrigin, }: {
|
|
10
37
|
onMessage: (data?: MessageData) => void;
|
|
11
38
|
allowedOrigin?: string | string[];
|
|
@@ -2,18 +2,124 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { FundProps } from '../Fund';
|
|
3
3
|
import { ButtonProps } from '../ui/Button';
|
|
4
4
|
import { ModalContentProps } from '../ui/Modal';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the fund modal trigger button
|
|
7
|
+
*/
|
|
5
8
|
interface FundModalTriggerProps extends Partial<Pick<ButtonProps, "className" | "fullWidth" | "size" | "style" | "variant">> {
|
|
9
|
+
/** If provided, will render the children instead of the default trigger button. */
|
|
6
10
|
children?: ReactNode;
|
|
11
|
+
/** The label to display on the trigger button. */
|
|
7
12
|
label?: ReactNode;
|
|
8
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Props for the fund modal content
|
|
16
|
+
*/
|
|
9
17
|
interface FundModalContentProps extends ModalContentProps {
|
|
10
18
|
}
|
|
11
19
|
interface FundModalProps extends Omit<FundProps, "children"> {
|
|
20
|
+
/** The children to render inside the modal. */
|
|
12
21
|
children?: ReactNode;
|
|
22
|
+
/** Whether the modal is open. Note: if you set this, you must also set `setIsOpen`. */
|
|
13
23
|
open?: boolean;
|
|
24
|
+
/** A function to set the modal's open state. Note: if you set this, you must also set `open`. */
|
|
14
25
|
setIsOpen?: (value: boolean) => void;
|
|
15
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* A trigger button that opens the fund modal.
|
|
29
|
+
*
|
|
30
|
+
* @see {@link FundModal} for the fund modal component.
|
|
31
|
+
*
|
|
32
|
+
* @param {FundModalTriggerProps} props - The props for the FundModalTrigger component.
|
|
33
|
+
* @param {ReactNode} [props.children] - The children to render inside the modal trigger instead of the default Button component.
|
|
34
|
+
* @param {ReactNode} [props.label] - The label to display on the trigger button.
|
|
35
|
+
* @returns {JSX.Element} The FundModalTrigger component.
|
|
36
|
+
*
|
|
37
|
+
* @group Components
|
|
38
|
+
*/
|
|
16
39
|
declare const FundModalTrigger: ({ children, className, label, ...props }: FundModalTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
/**
|
|
41
|
+
* The fund modal content.
|
|
42
|
+
*
|
|
43
|
+
* @see {@link FundModal} for the fund modal component.
|
|
44
|
+
*
|
|
45
|
+
* @augments ModalContentProps
|
|
46
|
+
* @param {FundModalContentProps} props - The props for the FundModalContent component.
|
|
47
|
+
* @returns {JSX.Element} The FundModalContent component.
|
|
48
|
+
*
|
|
49
|
+
* @group Components
|
|
50
|
+
*/
|
|
17
51
|
declare const FundModalContent: (props: FundModalContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
/**
|
|
53
|
+
* A fund modal component that wraps the {@link Fund} component.
|
|
54
|
+
*
|
|
55
|
+
* @param {FundModalProps} props - The props for the FundModal component.
|
|
56
|
+
* @param {ReactNode} [props.children] - The children to render inside the modal.
|
|
57
|
+
* @param {boolean} [props.open] - Whether the modal is open.
|
|
58
|
+
* @param {() => void} [props.setIsOpen] - A function to set the modal's open state.
|
|
59
|
+
* @returns {JSX.Element} The FundModal component.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link FundModalTrigger} for the trigger button.
|
|
62
|
+
* @see {@link FundModalContent} for the modal content.
|
|
63
|
+
*
|
|
64
|
+
* @group Components
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```tsx lines
|
|
68
|
+
* // Render the FundModal component
|
|
69
|
+
* function App() {
|
|
70
|
+
* const fetchBuyQuote: FundProps["fetchBuyQuote"] = async (params) => {
|
|
71
|
+
* // call the buy quote API
|
|
72
|
+
* }
|
|
73
|
+
* const fetchBuyOptions: FundProps["fetchBuyOptions"] = async params => {
|
|
74
|
+
* // call the buy options API
|
|
75
|
+
* }
|
|
76
|
+
* return (
|
|
77
|
+
* <CDPReactProvider config={config} theme={themeOverrides}>
|
|
78
|
+
* <FundModal
|
|
79
|
+
* country="US"
|
|
80
|
+
* subdivision="NY"
|
|
81
|
+
* cryptoCurrency="eth"
|
|
82
|
+
* fiatCurrency="usd"
|
|
83
|
+
* fetchBuyQuote={fetchBuyQuote}
|
|
84
|
+
* fetchBuyOptions={fetchBuyOptions}
|
|
85
|
+
* network="base"
|
|
86
|
+
* presetAmountInputs={[10, 25, 50]}
|
|
87
|
+
* />
|
|
88
|
+
* </CDPReactProvider>
|
|
89
|
+
* );
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```tsx lines
|
|
95
|
+
* // Render the FundModal component with a custom trigger button
|
|
96
|
+
* function App() {
|
|
97
|
+
* const fetchBuyQuote: FundProps["fetchBuyQuote"] = async (params) => {
|
|
98
|
+
* // call the buy quote API
|
|
99
|
+
* }
|
|
100
|
+
* const fetchBuyOptions: FundProps["fetchBuyOptions"] = async params => {
|
|
101
|
+
* // call the buy options API
|
|
102
|
+
* }
|
|
103
|
+
* return (
|
|
104
|
+
* <CDPReactProvider config={config} theme={themeOverrides}>
|
|
105
|
+
* <FundModal
|
|
106
|
+
* country="US"
|
|
107
|
+
* subdivision="NY"
|
|
108
|
+
* cryptoCurrency="eth"
|
|
109
|
+
* fiatCurrency="usd"
|
|
110
|
+
* fetchBuyQuote={fetchBuyQuote}
|
|
111
|
+
* fetchBuyOptions={fetchBuyOptions}
|
|
112
|
+
* network="base"
|
|
113
|
+
* presetAmountInputs={[10, 25, 50]}
|
|
114
|
+
* >
|
|
115
|
+
* <button className="fund-button">
|
|
116
|
+
* Get ETH
|
|
117
|
+
* </button>
|
|
118
|
+
* </FundModal>
|
|
119
|
+
* </CDPReactProvider>
|
|
120
|
+
* );
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
18
124
|
declare const FundModal: ({ children, open, setIsOpen, ...fundProps }: FundModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
125
|
export { FundModal, FundModalContent, FundModalTrigger, type FundModalProps, type FundModalContentProps, type FundModalTriggerProps, };
|
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { LinkAuthFlowView } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* A ref to the sign in content.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link LinkAuthFlowProps}
|
|
7
|
+
*/
|
|
3
8
|
export interface SignInContentRef {
|
|
9
|
+
/** Whether the user can go back to the previous step of the sign in flow. */
|
|
4
10
|
canGoBack: boolean;
|
|
11
|
+
/** A function to go back to the previous step of the sign in flow. */
|
|
5
12
|
goBack: () => void;
|
|
6
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Props for the LinkAuthFlow component.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link LinkAuthFlow}
|
|
18
|
+
*/
|
|
7
19
|
export interface LinkAuthFlowProps {
|
|
20
|
+
/** A render function for the children of the component. The render function provides the current view and the rendered content for the view. */
|
|
8
21
|
children?: ((props: {
|
|
9
22
|
view: LinkAuthFlowView;
|
|
10
23
|
Content: ReactNode;
|
|
11
24
|
}) => ReactNode) | undefined;
|
|
12
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* A component for the flow of the link auth component.
|
|
28
|
+
*
|
|
29
|
+
* LinkAuthFlow renders the LinkAuthItems component when the view is "list" and the SignIn component when the view is "email" or "sms". It also handles the transition between the views.
|
|
30
|
+
*
|
|
31
|
+
* @param {LinkAuthFlowProps} props - The props for the LinkAuthFlow component.
|
|
32
|
+
* @returns {JSX.Element} The LinkAuthFlow component.
|
|
33
|
+
*
|
|
34
|
+
* @see {@link LinkAuth}
|
|
35
|
+
*
|
|
36
|
+
* @group Components
|
|
37
|
+
*/
|
|
13
38
|
export declare const LinkAuthFlow: ({ children }: LinkAuthFlowProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes } from 'react';
|
|
2
2
|
import { ButtonProps } from '../ui/Button/Button';
|
|
3
3
|
import { LinkAuthFlowView } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the LinkAuthFlowBackButton component.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link LinkAuthFlowBackButton}
|
|
8
|
+
*/
|
|
4
9
|
export interface LinkAuthFlowBackButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
10
|
+
/** If set, will render the back button for this view of the flow, regardless of the context value. */
|
|
5
11
|
view?: LinkAuthFlowView;
|
|
12
|
+
/** The size of the button. */
|
|
6
13
|
size?: ButtonProps["size"];
|
|
14
|
+
/** The variant of the button. */
|
|
7
15
|
variant?: ButtonProps["variant"];
|
|
8
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* A button to go back to the previous step of the link auth flow.
|
|
19
|
+
*
|
|
20
|
+
* @param {LinkAuthFlowBackButtonProps} props - The props for the component.
|
|
21
|
+
* @returns {JSX.Element} The LinkAuthBackButton component.
|
|
22
|
+
*
|
|
23
|
+
* @see {@link LinkAuthFlow}
|
|
24
|
+
* @see {@link LinkAuth}
|
|
25
|
+
*
|
|
26
|
+
* @group Components
|
|
27
|
+
*/
|
|
9
28
|
export declare const LinkAuthFlowBackButton: ({ ["aria-label"]: ariaLabel, children, className, size, onClick, variant, view: viewFromProps, ...props }: LinkAuthFlowBackButtonProps) => import("react/jsx-runtime").JSX.Element | null;
|