@b3dotfun/sdk 0.1.2 → 0.1.5
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/cjs/anyspend/react/components/AnySpend.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +66 -15
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +6 -2
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +4 -4
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +185 -50
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +6 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +19 -4
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/QRDeposit.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/QRDeposit.js +12 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +7 -5
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +4 -3
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +7 -6
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.js +15 -6
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +10 -6
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +3 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +11 -10
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +9 -9
- package/dist/cjs/anyspend/react/components/common/OrderHistory.js +2 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +20 -7
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +3 -2
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.d.ts +6 -1
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +5 -2
- package/dist/cjs/anyspend/react/components/common/TabSection.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/TabSection.js +16 -7
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +3 -2
- package/dist/cjs/anyspend/react/components/common/WarningText.d.ts +8 -7
- package/dist/cjs/anyspend/react/components/common/WarningText.js +5 -6
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/types/classes.d.ts +390 -0
- package/dist/cjs/anyspend/react/components/types/classes.js +6 -0
- package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/index.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +22 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +119 -15
- package/dist/cjs/anyspend/react/hooks/useDirectTransfer.d.ts +17 -0
- package/dist/cjs/anyspend/react/hooks/useDirectTransfer.js +46 -0
- package/dist/cjs/anyspend/react/hooks/useRecipientAddressState.js +1 -1
- package/dist/cjs/anyspend/utils/format.js +12 -2
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +1 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +1 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +1 -4
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +1 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +1 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +1 -4
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +1 -3
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +1 -3
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsContent.js +17 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +19 -152
- package/dist/cjs/global-account/react/components/index.d.ts +0 -1
- package/dist/cjs/global-account/react/components/index.js +3 -6
- package/dist/cjs/global-account/react/hooks/index.d.ts +0 -1
- package/dist/cjs/global-account/react/hooks/index.js +2 -4
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +2 -3
- package/dist/cjs/global-account/react/hooks/useAuth.js +14 -31
- package/dist/cjs/global-account/react/hooks/useTWAuth.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useTWAuth.js +3 -3
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +8 -19
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +68 -17
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +6 -2
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +4 -4
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +189 -54
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +6 -1
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +19 -4
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/QRDeposit.d.ts +4 -1
- package/dist/esm/anyspend/react/components/QRDeposit.js +12 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +7 -5
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +4 -3
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +7 -6
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.js +15 -6
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +10 -6
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +3 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +11 -10
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +9 -9
- package/dist/esm/anyspend/react/components/common/OrderHistory.js +2 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +20 -7
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +3 -2
- package/dist/esm/anyspend/react/components/common/RecipientSelection.d.ts +6 -1
- package/dist/esm/anyspend/react/components/common/RecipientSelection.js +5 -2
- package/dist/esm/anyspend/react/components/common/TabSection.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/TabSection.js +16 -7
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +3 -2
- package/dist/esm/anyspend/react/components/common/WarningText.d.ts +8 -7
- package/dist/esm/anyspend/react/components/common/WarningText.js +5 -6
- package/dist/esm/anyspend/react/components/index.d.ts +1 -0
- package/dist/esm/anyspend/react/components/types/classes.d.ts +390 -0
- package/dist/esm/anyspend/react/components/types/classes.js +5 -0
- package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +22 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +119 -16
- package/dist/esm/anyspend/react/hooks/useDirectTransfer.d.ts +17 -0
- package/dist/esm/anyspend/react/hooks/useDirectTransfer.js +43 -0
- package/dist/esm/anyspend/react/hooks/useRecipientAddressState.js +1 -1
- package/dist/esm/anyspend/utils/format.js +12 -2
- package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -5
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +1 -3
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +1 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +1 -4
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +1 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +1 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +1 -4
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +1 -3
- package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +1 -3
- package/dist/esm/global-account/react/components/ManageAccount/SettingsContent.js +16 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +20 -153
- package/dist/esm/global-account/react/components/index.d.ts +0 -1
- package/dist/esm/global-account/react/components/index.js +0 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +0 -1
- package/dist/esm/global-account/react/hooks/index.js +0 -1
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +2 -3
- package/dist/esm/global-account/react/hooks/useAuth.js +14 -31
- package/dist/esm/global-account/react/hooks/useTWAuth.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useTWAuth.js +3 -3
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +8 -19
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +6 -2
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +6 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/types/anyspend/react/components/QRDeposit.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/FeeDetailPanel.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/FiatPaymentMethod.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +3 -0
- package/dist/types/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/PanelOnrampPayment.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/RecipientSelection.d.ts +6 -1
- package/dist/types/anyspend/react/components/common/TabSection.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/WarningText.d.ts +8 -7
- package/dist/types/anyspend/react/components/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/types/classes.d.ts +390 -0
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +22 -2
- package/dist/types/anyspend/react/hooks/useDirectTransfer.d.ts +17 -0
- package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +1 -3
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +1 -4
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +1 -1
- package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +1 -4
- package/dist/types/global-account/react/components/index.d.ts +0 -1
- package/dist/types/global-account/react/hooks/index.d.ts +0 -1
- package/dist/types/global-account/react/hooks/useAuth.d.ts +2 -3
- package/dist/types/global-account/react/hooks/useTWAuth.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +8 -19
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +164 -36
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +11 -6
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +278 -69
- package/src/anyspend/react/components/AnySpendDeposit.tsx +176 -52
- package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +3 -0
- package/src/anyspend/react/components/QRDeposit.tsx +91 -35
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +31 -19
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +14 -4
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +43 -23
- package/src/anyspend/react/components/common/FeeDetailPanel.tsx +53 -32
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +26 -13
- package/src/anyspend/react/components/common/OrderDetails.tsx +20 -9
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +12 -7
- package/src/anyspend/react/components/common/OrderHistory.tsx +2 -1
- package/src/anyspend/react/components/common/PanelOnramp.tsx +4 -1
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +118 -40
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +28 -14
- package/src/anyspend/react/components/common/RecipientSelection.tsx +20 -5
- package/src/anyspend/react/components/common/TabSection.tsx +21 -12
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +12 -4
- package/src/anyspend/react/components/common/WarningText.tsx +10 -10
- package/src/anyspend/react/components/index.ts +16 -0
- package/src/anyspend/react/components/types/classes.ts +476 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +141 -17
- package/src/anyspend/react/hooks/useDirectTransfer.ts +67 -0
- package/src/anyspend/react/hooks/useRecipientAddressState.ts +1 -1
- package/src/anyspend/utils/format.ts +13 -2
- package/src/global-account/react/components/B3DynamicModal.tsx +0 -5
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +0 -4
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +1 -1
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +1 -11
- package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +0 -6
- package/src/global-account/react/components/B3Provider/RelayKitProviderWrapper.tsx +1 -4
- package/src/global-account/react/components/ManageAccount/SettingsContent.tsx +33 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +27 -184
- package/src/global-account/react/components/index.ts +0 -3
- package/src/global-account/react/hooks/index.ts +0 -1
- package/src/global-account/react/hooks/useAuth.ts +14 -31
- package/src/global-account/react/hooks/useTWAuth.tsx +3 -5
- package/src/global-account/react/stores/useModalStore.ts +7 -20
- package/dist/cjs/global-account/react/components/TurnkeyAuthModal.d.ts +0 -8
- package/dist/cjs/global-account/react/components/TurnkeyAuthModal.js +0 -86
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.d.ts +0 -20
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +0 -142
- package/dist/esm/global-account/react/components/TurnkeyAuthModal.d.ts +0 -8
- package/dist/esm/global-account/react/components/TurnkeyAuthModal.js +0 -83
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.d.ts +0 -20
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +0 -136
- package/dist/types/global-account/react/components/TurnkeyAuthModal.d.ts +0 -8
- package/dist/types/global-account/react/hooks/useTurnkeyAuth.d.ts +0 -20
- package/src/global-account/react/components/TurnkeyAuthModal.tsx +0 -243
- package/src/global-account/react/hooks/useTurnkeyAuth.ts +0 -171
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classes prop types for AnySpend components customization.
|
|
3
|
+
* Use these to override default styling of specific elements.
|
|
4
|
+
*/
|
|
5
|
+
/** Classes for AnySpendDeposit component */
|
|
6
|
+
export interface AnySpendDepositClasses {
|
|
7
|
+
root?: string;
|
|
8
|
+
chainSelection?: string;
|
|
9
|
+
form?: string;
|
|
10
|
+
formContent?: string;
|
|
11
|
+
closeButton?: string;
|
|
12
|
+
balanceContainer?: string;
|
|
13
|
+
balanceLabel?: string;
|
|
14
|
+
balanceValue?: string;
|
|
15
|
+
optionsContainer?: string;
|
|
16
|
+
chainsSkeleton?: string;
|
|
17
|
+
skeletonItem?: string;
|
|
18
|
+
chainsContainer?: string;
|
|
19
|
+
chainButton?: string;
|
|
20
|
+
chainContent?: string;
|
|
21
|
+
chainInfo?: string;
|
|
22
|
+
chainName?: string;
|
|
23
|
+
chainIcon?: string;
|
|
24
|
+
chainBalance?: string;
|
|
25
|
+
chainChevron?: string;
|
|
26
|
+
generalOptions?: string;
|
|
27
|
+
optionButton?: string;
|
|
28
|
+
cryptoButton?: string;
|
|
29
|
+
qrButton?: string;
|
|
30
|
+
fiatButton?: string;
|
|
31
|
+
optionContent?: string;
|
|
32
|
+
optionInfo?: string;
|
|
33
|
+
optionTitle?: string;
|
|
34
|
+
optionDescription?: string;
|
|
35
|
+
optionIcon?: string;
|
|
36
|
+
optionChevron?: string;
|
|
37
|
+
divider?: string;
|
|
38
|
+
dividerLine?: string;
|
|
39
|
+
dividerText?: string;
|
|
40
|
+
backButton?: string;
|
|
41
|
+
backIcon?: string;
|
|
42
|
+
backText?: string;
|
|
43
|
+
header?: string;
|
|
44
|
+
title?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Classes for AnySpend component */
|
|
47
|
+
export interface AnySpendClasses {
|
|
48
|
+
root?: string;
|
|
49
|
+
container?: string;
|
|
50
|
+
header?: string;
|
|
51
|
+
headerLogo?: string;
|
|
52
|
+
headerTitle?: string;
|
|
53
|
+
tabSection?: string;
|
|
54
|
+
tabList?: string;
|
|
55
|
+
tabTrigger?: string;
|
|
56
|
+
tabTriggerActive?: string;
|
|
57
|
+
mainContent?: string;
|
|
58
|
+
inputSection?: string;
|
|
59
|
+
swapDirectionButton?: string;
|
|
60
|
+
mainButton?: string;
|
|
61
|
+
mainButtonDisabled?: string;
|
|
62
|
+
mainButtonError?: string;
|
|
63
|
+
historyButton?: string;
|
|
64
|
+
bottomNavigation?: string;
|
|
65
|
+
gasIndicator?: string;
|
|
66
|
+
}
|
|
67
|
+
/** Classes for AnySpendCustomExactIn component */
|
|
68
|
+
export interface AnySpendCustomExactInClasses {
|
|
69
|
+
root?: string;
|
|
70
|
+
container?: string;
|
|
71
|
+
header?: string;
|
|
72
|
+
headerTitle?: string;
|
|
73
|
+
headerDescription?: string;
|
|
74
|
+
contentArea?: string;
|
|
75
|
+
inputSection?: string;
|
|
76
|
+
swapDirectionButton?: string;
|
|
77
|
+
mainButton?: string;
|
|
78
|
+
mainButtonDisabled?: string;
|
|
79
|
+
mainButtonError?: string;
|
|
80
|
+
footer?: string;
|
|
81
|
+
gasIndicator?: string;
|
|
82
|
+
}
|
|
83
|
+
/** Classes for CryptoPaySection component */
|
|
84
|
+
export interface CryptoPaySectionClasses {
|
|
85
|
+
root?: string;
|
|
86
|
+
container?: string;
|
|
87
|
+
label?: string;
|
|
88
|
+
inputContainer?: string;
|
|
89
|
+
input?: string;
|
|
90
|
+
tokenSelector?: string;
|
|
91
|
+
tokenIcon?: string;
|
|
92
|
+
tokenSymbol?: string;
|
|
93
|
+
chainBadge?: string;
|
|
94
|
+
balanceRow?: string;
|
|
95
|
+
balanceLabel?: string;
|
|
96
|
+
balanceValue?: string;
|
|
97
|
+
maxButton?: string;
|
|
98
|
+
paymentMethodButton?: string;
|
|
99
|
+
feeRow?: string;
|
|
100
|
+
}
|
|
101
|
+
/** Classes for CryptoReceiveSection component */
|
|
102
|
+
export interface CryptoReceiveSectionClasses {
|
|
103
|
+
root?: string;
|
|
104
|
+
container?: string;
|
|
105
|
+
label?: string;
|
|
106
|
+
inputContainer?: string;
|
|
107
|
+
input?: string;
|
|
108
|
+
tokenSelector?: string;
|
|
109
|
+
tokenIcon?: string;
|
|
110
|
+
tokenSymbol?: string;
|
|
111
|
+
chainBadge?: string;
|
|
112
|
+
recipientRow?: string;
|
|
113
|
+
recipientLabel?: string;
|
|
114
|
+
recipientValue?: string;
|
|
115
|
+
recipientButton?: string;
|
|
116
|
+
pointsRow?: string;
|
|
117
|
+
feeRow?: string;
|
|
118
|
+
}
|
|
119
|
+
/** Classes for PanelOnramp component */
|
|
120
|
+
export interface PanelOnrampClasses {
|
|
121
|
+
root?: string;
|
|
122
|
+
container?: string;
|
|
123
|
+
amountInput?: string;
|
|
124
|
+
presetButtons?: string;
|
|
125
|
+
presetButton?: string;
|
|
126
|
+
paymentMethodRow?: string;
|
|
127
|
+
recipientRow?: string;
|
|
128
|
+
destinationRow?: string;
|
|
129
|
+
feeRow?: string;
|
|
130
|
+
pointsRow?: string;
|
|
131
|
+
}
|
|
132
|
+
/** Classes for OrderDetails component */
|
|
133
|
+
export interface OrderDetailsClasses {
|
|
134
|
+
root?: string;
|
|
135
|
+
container?: string;
|
|
136
|
+
header?: string;
|
|
137
|
+
statusBadge?: string;
|
|
138
|
+
statusPending?: string;
|
|
139
|
+
statusSuccess?: string;
|
|
140
|
+
statusFailed?: string;
|
|
141
|
+
amountSection?: string;
|
|
142
|
+
detailsSection?: string;
|
|
143
|
+
detailRow?: string;
|
|
144
|
+
detailLabel?: string;
|
|
145
|
+
detailValue?: string;
|
|
146
|
+
transactionLink?: string;
|
|
147
|
+
actionButton?: string;
|
|
148
|
+
backButton?: string;
|
|
149
|
+
returnButton?: string;
|
|
150
|
+
}
|
|
151
|
+
/** Classes for RecipientSelection component */
|
|
152
|
+
export interface RecipientSelectionClasses {
|
|
153
|
+
root?: string;
|
|
154
|
+
container?: string;
|
|
155
|
+
header?: string;
|
|
156
|
+
searchInput?: string;
|
|
157
|
+
recipientList?: string;
|
|
158
|
+
recipientItem?: string;
|
|
159
|
+
recipientItemActive?: string;
|
|
160
|
+
recipientAvatar?: string;
|
|
161
|
+
recipientName?: string;
|
|
162
|
+
recipientAddress?: string;
|
|
163
|
+
confirmButton?: string;
|
|
164
|
+
backButton?: string;
|
|
165
|
+
}
|
|
166
|
+
/** Classes for CryptoPaymentMethod component */
|
|
167
|
+
export interface CryptoPaymentMethodClasses {
|
|
168
|
+
root?: string;
|
|
169
|
+
container?: string;
|
|
170
|
+
header?: string;
|
|
171
|
+
optionsList?: string;
|
|
172
|
+
optionItem?: string;
|
|
173
|
+
optionItemActive?: string;
|
|
174
|
+
optionIcon?: string;
|
|
175
|
+
optionLabel?: string;
|
|
176
|
+
optionDescription?: string;
|
|
177
|
+
backButton?: string;
|
|
178
|
+
}
|
|
179
|
+
/** Classes for FiatPaymentMethod component */
|
|
180
|
+
export interface FiatPaymentMethodClasses {
|
|
181
|
+
root?: string;
|
|
182
|
+
container?: string;
|
|
183
|
+
header?: string;
|
|
184
|
+
optionsList?: string;
|
|
185
|
+
optionItem?: string;
|
|
186
|
+
optionItemActive?: string;
|
|
187
|
+
optionIcon?: string;
|
|
188
|
+
optionLabel?: string;
|
|
189
|
+
optionDescription?: string;
|
|
190
|
+
backButton?: string;
|
|
191
|
+
}
|
|
192
|
+
/** Classes for WarningText component */
|
|
193
|
+
export interface WarningTextClasses {
|
|
194
|
+
root?: string;
|
|
195
|
+
}
|
|
196
|
+
/** Classes for ChainWarningText component */
|
|
197
|
+
export interface ChainWarningTextClasses {
|
|
198
|
+
root?: string;
|
|
199
|
+
}
|
|
200
|
+
/** Classes for TabSection component */
|
|
201
|
+
export interface TabSectionClasses {
|
|
202
|
+
root?: string;
|
|
203
|
+
container?: string;
|
|
204
|
+
tabIndicator?: string;
|
|
205
|
+
tabButton?: string;
|
|
206
|
+
tabButtonActive?: string;
|
|
207
|
+
}
|
|
208
|
+
/** Classes for FeeDetailPanel component */
|
|
209
|
+
export interface FeeDetailPanelClasses {
|
|
210
|
+
root?: string;
|
|
211
|
+
container?: string;
|
|
212
|
+
title?: string;
|
|
213
|
+
tierCard?: string;
|
|
214
|
+
tierCardTitle?: string;
|
|
215
|
+
tierRow?: string;
|
|
216
|
+
tierRowActive?: string;
|
|
217
|
+
tierLabel?: string;
|
|
218
|
+
tierValue?: string;
|
|
219
|
+
expandButton?: string;
|
|
220
|
+
summaryCard?: string;
|
|
221
|
+
summaryRow?: string;
|
|
222
|
+
summaryLabel?: string;
|
|
223
|
+
summaryValue?: string;
|
|
224
|
+
summaryDivider?: string;
|
|
225
|
+
totalRow?: string;
|
|
226
|
+
totalLabel?: string;
|
|
227
|
+
totalValue?: string;
|
|
228
|
+
backButton?: string;
|
|
229
|
+
}
|
|
230
|
+
/** Classes for PointsDetailPanel component */
|
|
231
|
+
export interface PointsDetailPanelClasses {
|
|
232
|
+
root?: string;
|
|
233
|
+
container?: string;
|
|
234
|
+
title?: string;
|
|
235
|
+
description?: string;
|
|
236
|
+
highlightText?: string;
|
|
237
|
+
link?: string;
|
|
238
|
+
infoCard?: string;
|
|
239
|
+
infoCardTitle?: string;
|
|
240
|
+
infoList?: string;
|
|
241
|
+
infoListItem?: string;
|
|
242
|
+
backButton?: string;
|
|
243
|
+
}
|
|
244
|
+
/** Classes for PanelOnrampPayment component */
|
|
245
|
+
export interface PanelOnrampPaymentClasses {
|
|
246
|
+
root?: string;
|
|
247
|
+
container?: string;
|
|
248
|
+
summaryTitle?: string;
|
|
249
|
+
summaryCard?: string;
|
|
250
|
+
summaryRow?: string;
|
|
251
|
+
summaryLabel?: string;
|
|
252
|
+
summaryValue?: string;
|
|
253
|
+
summaryDivider?: string;
|
|
254
|
+
amountRow?: string;
|
|
255
|
+
amountValue?: string;
|
|
256
|
+
feeText?: string;
|
|
257
|
+
loadingContainer?: string;
|
|
258
|
+
loadingSpinner?: string;
|
|
259
|
+
loadingText?: string;
|
|
260
|
+
paymentMethodTitle?: string;
|
|
261
|
+
paymentMethodIcons?: string;
|
|
262
|
+
paymentOption?: string;
|
|
263
|
+
paymentOptionIcon?: string;
|
|
264
|
+
paymentOptionContent?: string;
|
|
265
|
+
paymentOptionTitle?: string;
|
|
266
|
+
paymentOptionDescription?: string;
|
|
267
|
+
paymentOptionFee?: string;
|
|
268
|
+
paymentOptionChevron?: string;
|
|
269
|
+
backButton?: string;
|
|
270
|
+
}
|
|
271
|
+
/** Classes for OrderDetailsCollapsible component */
|
|
272
|
+
export interface OrderDetailsCollapsibleClasses {
|
|
273
|
+
root?: string;
|
|
274
|
+
container?: string;
|
|
275
|
+
expandedContent?: string;
|
|
276
|
+
recipientSection?: string;
|
|
277
|
+
recipientLabel?: string;
|
|
278
|
+
recipientInfo?: string;
|
|
279
|
+
recipientName?: string;
|
|
280
|
+
recipientAddress?: string;
|
|
281
|
+
recipientCopyIcon?: string;
|
|
282
|
+
divider?: string;
|
|
283
|
+
expectedSection?: string;
|
|
284
|
+
expectedLabel?: string;
|
|
285
|
+
expectedValue?: string;
|
|
286
|
+
expectedAmount?: string;
|
|
287
|
+
chainInfo?: string;
|
|
288
|
+
chainText?: string;
|
|
289
|
+
chainLogo?: string;
|
|
290
|
+
pointsSection?: string;
|
|
291
|
+
pointsLabel?: string;
|
|
292
|
+
pointsValue?: string;
|
|
293
|
+
idSection?: string;
|
|
294
|
+
idLabel?: string;
|
|
295
|
+
idValue?: string;
|
|
296
|
+
collapsedContainer?: string;
|
|
297
|
+
collapsedButton?: string;
|
|
298
|
+
collapsedChevron?: string;
|
|
299
|
+
}
|
|
300
|
+
/** Classes for TransferCryptoDetails component */
|
|
301
|
+
export interface TransferCryptoDetailsClasses {
|
|
302
|
+
root?: string;
|
|
303
|
+
container?: string;
|
|
304
|
+
header?: string;
|
|
305
|
+
backButton?: string;
|
|
306
|
+
title?: string;
|
|
307
|
+
timer?: string;
|
|
308
|
+
timerSvg?: string;
|
|
309
|
+
timerBackground?: string;
|
|
310
|
+
timerProgress?: string;
|
|
311
|
+
timerText?: string;
|
|
312
|
+
cardsContainer?: string;
|
|
313
|
+
amountCard?: string;
|
|
314
|
+
amountLabel?: string;
|
|
315
|
+
amountContainer?: string;
|
|
316
|
+
amountText?: string;
|
|
317
|
+
amountCopyIcon?: string;
|
|
318
|
+
chainCard?: string;
|
|
319
|
+
chainLabel?: string;
|
|
320
|
+
chainContainer?: string;
|
|
321
|
+
chainLogo?: string;
|
|
322
|
+
chainName?: string;
|
|
323
|
+
qrDepositCard?: string;
|
|
324
|
+
qrSection?: string;
|
|
325
|
+
qrWrapper?: string;
|
|
326
|
+
qrContainer?: string;
|
|
327
|
+
qrCode?: string;
|
|
328
|
+
walletHint?: string;
|
|
329
|
+
walletText?: string;
|
|
330
|
+
walletIcon?: string;
|
|
331
|
+
addressSection?: string;
|
|
332
|
+
addressLabel?: string;
|
|
333
|
+
addressCopyContainer?: string;
|
|
334
|
+
addressText?: string;
|
|
335
|
+
addressCopyIcon?: string;
|
|
336
|
+
actionsContainer?: string;
|
|
337
|
+
copyButton?: string;
|
|
338
|
+
}
|
|
339
|
+
/** Classes for QRDeposit component */
|
|
340
|
+
export interface QRDepositClasses {
|
|
341
|
+
root?: string;
|
|
342
|
+
container?: string;
|
|
343
|
+
content?: string;
|
|
344
|
+
header?: string;
|
|
345
|
+
backButton?: string;
|
|
346
|
+
title?: string;
|
|
347
|
+
closeButton?: string;
|
|
348
|
+
tokenSelectorContainer?: string;
|
|
349
|
+
tokenSelectorLabel?: string;
|
|
350
|
+
tokenSelectorTrigger?: string;
|
|
351
|
+
qrContent?: string;
|
|
352
|
+
qrCodeContainer?: string;
|
|
353
|
+
qrCode?: string;
|
|
354
|
+
qrScanHint?: string;
|
|
355
|
+
addressContainer?: string;
|
|
356
|
+
addressLabel?: string;
|
|
357
|
+
addressRow?: string;
|
|
358
|
+
address?: string;
|
|
359
|
+
addressCopyIcon?: string;
|
|
360
|
+
watchingIndicator?: string;
|
|
361
|
+
copyButton?: string;
|
|
362
|
+
loadingContainer?: string;
|
|
363
|
+
loadingContent?: string;
|
|
364
|
+
loadingSpinner?: string;
|
|
365
|
+
loadingText?: string;
|
|
366
|
+
orderDetailsContainer?: string;
|
|
367
|
+
orderDetailsContent?: string;
|
|
368
|
+
}
|
|
369
|
+
/** Combined classes for all AnySpend-related components */
|
|
370
|
+
export interface AnySpendAllClasses {
|
|
371
|
+
deposit?: AnySpendDepositClasses;
|
|
372
|
+
anySpend?: AnySpendClasses;
|
|
373
|
+
customExactIn?: AnySpendCustomExactInClasses;
|
|
374
|
+
cryptoPaySection?: CryptoPaySectionClasses;
|
|
375
|
+
cryptoReceiveSection?: CryptoReceiveSectionClasses;
|
|
376
|
+
panelOnramp?: PanelOnrampClasses;
|
|
377
|
+
orderDetails?: OrderDetailsClasses;
|
|
378
|
+
recipientSelection?: RecipientSelectionClasses;
|
|
379
|
+
cryptoPaymentMethod?: CryptoPaymentMethodClasses;
|
|
380
|
+
fiatPaymentMethod?: FiatPaymentMethodClasses;
|
|
381
|
+
qrDeposit?: QRDepositClasses;
|
|
382
|
+
warningText?: WarningTextClasses;
|
|
383
|
+
chainWarningText?: ChainWarningTextClasses;
|
|
384
|
+
tabSection?: TabSectionClasses;
|
|
385
|
+
feeDetailPanel?: FeeDetailPanelClasses;
|
|
386
|
+
pointsDetailPanel?: PointsDetailPanelClasses;
|
|
387
|
+
panelOnrampPayment?: PanelOnrampPaymentClasses;
|
|
388
|
+
orderDetailsCollapsible?: OrderDetailsCollapsibleClasses;
|
|
389
|
+
transferCryptoDetails?: TransferCryptoDetailsClasses;
|
|
390
|
+
}
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./useAnyspendCreateOnrampOrder"), exports);
|
|
18
|
+
__exportStar(require("./useDirectTransfer"), exports);
|
|
18
19
|
__exportStar(require("./useAnyspendCreateOrder"), exports);
|
|
19
20
|
__exportStar(require("./useCreateDepositFirstOrder"), exports);
|
|
20
21
|
__exportStar(require("./useAnyspendOrderAndTransactions"), exports);
|
|
@@ -9,8 +9,22 @@ export declare enum PanelView {
|
|
|
9
9
|
ORDER_DETAILS = 4,
|
|
10
10
|
LOADING = 5,
|
|
11
11
|
POINTS_DETAIL = 6,
|
|
12
|
-
FEE_DETAIL = 7
|
|
12
|
+
FEE_DETAIL = 7,
|
|
13
|
+
DIRECT_TRANSFER_SUCCESS = 8
|
|
13
14
|
}
|
|
15
|
+
export type CustomExactInConfig = {
|
|
16
|
+
functionAbi: string;
|
|
17
|
+
functionName: string;
|
|
18
|
+
functionArgs: string[];
|
|
19
|
+
to: string;
|
|
20
|
+
spenderAddress?: string;
|
|
21
|
+
action?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Generates encoded function data for custom contract calls.
|
|
25
|
+
* Handles amount placeholder replacement and BigInt conversion.
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateEncodedData(config: CustomExactInConfig | undefined, amountInWei: string): string | undefined;
|
|
14
28
|
interface UseAnyspendFlowProps {
|
|
15
29
|
paymentType?: "crypto" | "fiat";
|
|
16
30
|
recipientAddress?: string;
|
|
@@ -25,8 +39,9 @@ interface UseAnyspendFlowProps {
|
|
|
25
39
|
slippage?: number;
|
|
26
40
|
disableUrlParamManagement?: boolean;
|
|
27
41
|
orderType?: "hype_duel" | "custom_exact_in" | "swap";
|
|
42
|
+
customExactInConfig?: CustomExactInConfig;
|
|
28
43
|
}
|
|
29
|
-
export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrder, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, destinationTokenAddress, destinationTokenChainId, slippage, disableUrlParamManagement, orderType, }: UseAnyspendFlowProps): {
|
|
44
|
+
export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrder, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, destinationTokenAddress, destinationTokenChainId, slippage, disableUrlParamManagement, orderType, customExactInConfig, }: UseAnyspendFlowProps): {
|
|
30
45
|
activePanel: PanelView;
|
|
31
46
|
setActivePanel: import("react").Dispatch<import("react").SetStateAction<PanelView>>;
|
|
32
47
|
orderId: string | undefined;
|
|
@@ -91,8 +106,11 @@ export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrd
|
|
|
91
106
|
setSrcAmount: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
92
107
|
dstAmount: string;
|
|
93
108
|
setDstAmount: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
109
|
+
dstAmountInput: string;
|
|
110
|
+
setDstAmountInput: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
94
111
|
isSrcInputDirty: boolean;
|
|
95
112
|
setIsSrcInputDirty: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
113
|
+
tradeType: string;
|
|
96
114
|
cryptoPaymentMethod: CryptoPaymentMethodType;
|
|
97
115
|
setCryptoPaymentMethod: (method: CryptoPaymentMethodType) => void;
|
|
98
116
|
selectedCryptoPaymentMethod: CryptoPaymentMethodType;
|
|
@@ -176,8 +194,10 @@ export declare function useAnyspendFlow({ paymentType, recipientAddress, loadOrd
|
|
|
176
194
|
statusCode: number;
|
|
177
195
|
} | undefined;
|
|
178
196
|
isLoadingAnyspendQuote: boolean;
|
|
197
|
+
isQuoteLoading: boolean;
|
|
179
198
|
getAnyspendQuoteError: Error | null;
|
|
180
199
|
activeInputAmountInWei: string;
|
|
200
|
+
activeOutputAmountInWei: string;
|
|
181
201
|
geoData: import("../../../anyspend/react").GeoData | undefined;
|
|
182
202
|
coinbaseAvailablePaymentMethods: {
|
|
183
203
|
id?: string;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PanelView = void 0;
|
|
4
|
+
exports.generateEncodedData = generateEncodedData;
|
|
4
5
|
exports.useAnyspendFlow = useAnyspendFlow;
|
|
5
6
|
const anyspend_1 = require("../../../anyspend");
|
|
6
7
|
const react_1 = require("../../../anyspend/react");
|
|
7
8
|
const anyspend_2 = require("../../../anyspend/services/anyspend");
|
|
9
|
+
const utils_1 = require("../../../anyspend/utils");
|
|
8
10
|
const react_2 = require("../../../global-account/react");
|
|
9
11
|
const number_1 = require("../../../shared/utils/number");
|
|
10
12
|
const react_3 = require("react");
|
|
@@ -26,9 +28,52 @@ var PanelView;
|
|
|
26
28
|
PanelView[PanelView["LOADING"] = 5] = "LOADING";
|
|
27
29
|
PanelView[PanelView["POINTS_DETAIL"] = 6] = "POINTS_DETAIL";
|
|
28
30
|
PanelView[PanelView["FEE_DETAIL"] = 7] = "FEE_DETAIL";
|
|
31
|
+
PanelView[PanelView["DIRECT_TRANSFER_SUCCESS"] = 8] = "DIRECT_TRANSFER_SUCCESS";
|
|
29
32
|
})(PanelView || (exports.PanelView = PanelView = {}));
|
|
33
|
+
/**
|
|
34
|
+
* Generates encoded function data for custom contract calls.
|
|
35
|
+
* Handles amount placeholder replacement and BigInt conversion.
|
|
36
|
+
*/
|
|
37
|
+
function generateEncodedData(config, amountInWei) {
|
|
38
|
+
if (!config || !config.functionAbi || !config.functionName || !config.functionArgs) {
|
|
39
|
+
console.warn("customExactInConfig missing required fields for encoding:", {
|
|
40
|
+
hasConfig: !!config,
|
|
41
|
+
hasFunctionAbi: !!config?.functionAbi,
|
|
42
|
+
hasFunctionName: !!config?.functionName,
|
|
43
|
+
hasFunctionArgs: !!config?.functionArgs,
|
|
44
|
+
});
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const abi = JSON.parse(config.functionAbi);
|
|
49
|
+
const processedArgs = config.functionArgs.map(arg => {
|
|
50
|
+
// Replace amount placeholders ({{dstAmount}}, {{amount_out}}, etc.)
|
|
51
|
+
if (arg === "{{dstAmount}}" || arg === "{{amount_out}}") {
|
|
52
|
+
return BigInt(amountInWei);
|
|
53
|
+
}
|
|
54
|
+
// Convert numeric strings to BigInt for uint256 args
|
|
55
|
+
if (/^\d+$/.test(arg)) {
|
|
56
|
+
return BigInt(arg);
|
|
57
|
+
}
|
|
58
|
+
return arg;
|
|
59
|
+
});
|
|
60
|
+
return (0, viem_1.encodeFunctionData)({
|
|
61
|
+
abi,
|
|
62
|
+
functionName: config.functionName,
|
|
63
|
+
args: processedArgs,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
console.error("Failed to encode function data:", e, {
|
|
68
|
+
functionAbi: config.functionAbi,
|
|
69
|
+
functionName: config.functionName,
|
|
70
|
+
functionArgs: config.functionArgs,
|
|
71
|
+
});
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
30
75
|
// This hook serves for order hype_duel and custom_exact_in
|
|
31
|
-
function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, destinationTokenAddress, destinationTokenChainId, slippage = 0, disableUrlParamManagement = false, orderType = "hype_duel", }) {
|
|
76
|
+
function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder, onOrderSuccess, onTransactionSuccess, sourceTokenAddress, sourceTokenChainId, destinationTokenAddress, destinationTokenChainId, slippage = 0, disableUrlParamManagement = false, orderType = "hype_duel", customExactInConfig, }) {
|
|
32
77
|
const searchParams = (0, react_2.useSearchParamsSSR)();
|
|
33
78
|
const router = (0, react_2.useRouter)();
|
|
34
79
|
// Panel and order state
|
|
@@ -43,6 +88,8 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
43
88
|
const [selectedDstToken, setSelectedDstToken] = (0, react_3.useState)(defaultDstToken);
|
|
44
89
|
const [srcAmount, setSrcAmount] = (0, react_3.useState)(paymentType === "fiat" ? "5" : "0");
|
|
45
90
|
const [dstAmount, setDstAmount] = (0, react_3.useState)("");
|
|
91
|
+
const [dstAmountInput, setDstAmountInput] = (0, react_3.useState)(""); // User input for destination amount (EXACT_OUTPUT mode)
|
|
92
|
+
const [debouncedDstAmountInput, setDebouncedDstAmountInput] = (0, react_3.useState)(""); // Debounced version for quote requests
|
|
46
93
|
const [isSrcInputDirty, setIsSrcInputDirty] = (0, react_3.useState)(true);
|
|
47
94
|
// Derive destination chain ID from token or prop (cannot change)
|
|
48
95
|
const selectedDstChainId = destinationTokenChainId || selectedDstToken.chainId;
|
|
@@ -120,6 +167,16 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
120
167
|
};
|
|
121
168
|
fetchDestinationToken();
|
|
122
169
|
}, [destinationTokenAddress, destinationTokenChainId]);
|
|
170
|
+
// Check if destination token is ready (matches the expected address from props)
|
|
171
|
+
// This is important for EXACT_OUTPUT mode where we need correct decimals
|
|
172
|
+
const isDestinationTokenReady = !destinationTokenAddress || selectedDstToken.address.toLowerCase() === destinationTokenAddress.toLowerCase();
|
|
173
|
+
// Debounce destination amount input for quote requests (500ms delay)
|
|
174
|
+
(0, react_3.useEffect)(() => {
|
|
175
|
+
const timer = setTimeout(() => {
|
|
176
|
+
setDebouncedDstAmountInput(dstAmountInput);
|
|
177
|
+
}, 500);
|
|
178
|
+
return () => clearTimeout(timer);
|
|
179
|
+
}, [dstAmountInput]);
|
|
123
180
|
// Helper function for onramp vendor mapping
|
|
124
181
|
const getOnrampVendor = (paymentMethod) => {
|
|
125
182
|
switch (paymentMethod) {
|
|
@@ -133,8 +190,16 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
133
190
|
};
|
|
134
191
|
// Get quote
|
|
135
192
|
// For fiat payments, always use USDC decimals (6) regardless of selectedSrcToken
|
|
136
|
-
const
|
|
137
|
-
const activeInputAmountInWei = (0, viem_1.parseUnits)(srcAmount.replace(/,/g, ""),
|
|
193
|
+
const effectiveSrcDecimals = paymentType === "fiat" ? anyspend_1.USDC_BASE.decimals : selectedSrcToken.decimals;
|
|
194
|
+
const activeInputAmountInWei = (0, viem_1.parseUnits)(srcAmount.replace(/,/g, ""), effectiveSrcDecimals).toString();
|
|
195
|
+
// Calculate output amount in wei for EXACT_OUTPUT mode
|
|
196
|
+
// Only calculate when destination token is ready (has correct decimals)
|
|
197
|
+
// Use debounced value to reduce quote API calls
|
|
198
|
+
const activeOutputAmountInWei = isDestinationTokenReady
|
|
199
|
+
? (0, viem_1.parseUnits)(debouncedDstAmountInput.replace(/,/g, "") || "0", selectedDstToken.decimals).toString()
|
|
200
|
+
: "0";
|
|
201
|
+
// Determine trade type based on which input was last edited
|
|
202
|
+
const tradeType = isSrcInputDirty ? "EXACT_INPUT" : "EXACT_OUTPUT";
|
|
138
203
|
// Build quote request based on order type
|
|
139
204
|
const quoteRequest = (() => {
|
|
140
205
|
const baseParams = {
|
|
@@ -149,8 +214,8 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
149
214
|
return {
|
|
150
215
|
...baseParams,
|
|
151
216
|
type: "swap",
|
|
152
|
-
tradeType:
|
|
153
|
-
amount: activeInputAmountInWei,
|
|
217
|
+
tradeType: tradeType,
|
|
218
|
+
amount: tradeType === "EXACT_INPUT" ? activeInputAmountInWei : activeOutputAmountInWei,
|
|
154
219
|
};
|
|
155
220
|
}
|
|
156
221
|
else if (orderType === "hype_duel") {
|
|
@@ -161,6 +226,22 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
161
226
|
};
|
|
162
227
|
}
|
|
163
228
|
else {
|
|
229
|
+
// custom_exact_in - for EXACT_OUTPUT, use custom type to get the quote
|
|
230
|
+
if (tradeType === "EXACT_OUTPUT") {
|
|
231
|
+
const encodedData = generateEncodedData(customExactInConfig, activeOutputAmountInWei);
|
|
232
|
+
return {
|
|
233
|
+
...baseParams,
|
|
234
|
+
type: "custom",
|
|
235
|
+
payload: {
|
|
236
|
+
amount: activeOutputAmountInWei,
|
|
237
|
+
data: encodedData || "",
|
|
238
|
+
to: customExactInConfig ? (0, utils_1.normalizeAddress)(customExactInConfig.to) : "",
|
|
239
|
+
spenderAddress: customExactInConfig?.spenderAddress
|
|
240
|
+
? (0, utils_1.normalizeAddress)(customExactInConfig.spenderAddress)
|
|
241
|
+
: undefined,
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
}
|
|
164
245
|
return {
|
|
165
246
|
...baseParams,
|
|
166
247
|
type: "custom_exact_in",
|
|
@@ -169,22 +250,40 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
169
250
|
}
|
|
170
251
|
})();
|
|
171
252
|
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = (0, react_1.useAnyspendQuote)(quoteRequest);
|
|
253
|
+
// Combined loading state: includes debounce waiting period and actual quote fetching
|
|
254
|
+
// For EXACT_OUTPUT mode, also check if we're waiting for debounce
|
|
255
|
+
const isDebouncingDstAmount = tradeType === "EXACT_OUTPUT" && dstAmountInput !== debouncedDstAmountInput;
|
|
256
|
+
const isQuoteLoading = isLoadingAnyspendQuote || isDebouncingDstAmount;
|
|
172
257
|
// Get geo options for fiat
|
|
173
258
|
const { geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support } = (0, react_1.useGeoOnrampOptions)(paymentType === "fiat" ? (0, number_1.formatUnits)(activeInputAmountInWei, anyspend_1.USDC_BASE.decimals) : "0");
|
|
174
|
-
// Update
|
|
259
|
+
// Update amounts when quote changes based on trade type
|
|
175
260
|
(0, react_3.useEffect)(() => {
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
261
|
+
if (isSrcInputDirty) {
|
|
262
|
+
// EXACT_INPUT mode: update destination amount from quote
|
|
263
|
+
if (anyspendQuote?.data?.currencyOut?.amount && anyspendQuote.data.currencyOut.currency?.decimals) {
|
|
264
|
+
const amount = anyspendQuote.data.currencyOut.amount;
|
|
265
|
+
const decimals = anyspendQuote.data.currencyOut.currency.decimals;
|
|
266
|
+
// Apply slippage (0-100) - reduce amount by slippage percentage
|
|
267
|
+
const amountWithSlippage = (BigInt(amount) * BigInt(100 - slippage)) / BigInt(100);
|
|
268
|
+
const formattedAmount = (0, number_1.formatTokenAmount)(amountWithSlippage, decimals, 6, false);
|
|
269
|
+
setDstAmount(formattedAmount);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
setDstAmount("");
|
|
273
|
+
}
|
|
183
274
|
}
|
|
184
275
|
else {
|
|
185
|
-
|
|
276
|
+
// EXACT_OUTPUT mode: update source amount from quote
|
|
277
|
+
if (anyspendQuote?.data?.currencyIn?.amount && anyspendQuote.data.currencyIn.currency?.decimals) {
|
|
278
|
+
const amount = anyspendQuote.data.currencyIn.amount;
|
|
279
|
+
const decimals = anyspendQuote.data.currencyIn.currency.decimals;
|
|
280
|
+
const formattedAmount = (0, number_1.formatTokenAmount)(BigInt(amount), decimals, 6, false);
|
|
281
|
+
setSrcAmount(formattedAmount);
|
|
282
|
+
}
|
|
283
|
+
// Also set the display destination amount from the user input
|
|
284
|
+
setDstAmount(dstAmountInput);
|
|
186
285
|
}
|
|
187
|
-
}, [anyspendQuote, slippage]);
|
|
286
|
+
}, [anyspendQuote, slippage, isSrcInputDirty, dstAmountInput]);
|
|
188
287
|
// Update useEffect for URL parameter to not override loadOrder
|
|
189
288
|
(0, react_3.useEffect)(() => {
|
|
190
289
|
if (loadOrder || disableUrlParamManagement)
|
|
@@ -269,8 +368,11 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
269
368
|
setSrcAmount,
|
|
270
369
|
dstAmount,
|
|
271
370
|
setDstAmount,
|
|
371
|
+
dstAmountInput,
|
|
372
|
+
setDstAmountInput,
|
|
272
373
|
isSrcInputDirty,
|
|
273
374
|
setIsSrcInputDirty,
|
|
375
|
+
tradeType,
|
|
274
376
|
// Payment methods
|
|
275
377
|
cryptoPaymentMethod,
|
|
276
378
|
setCryptoPaymentMethod,
|
|
@@ -291,8 +393,10 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
|
|
|
291
393
|
// Quote data
|
|
292
394
|
anyspendQuote,
|
|
293
395
|
isLoadingAnyspendQuote,
|
|
396
|
+
isQuoteLoading, // Combined loading state (includes debounce + quote fetching)
|
|
294
397
|
getAnyspendQuoteError,
|
|
295
398
|
activeInputAmountInWei,
|
|
399
|
+
activeOutputAmountInWei, // User's destination amount input in wei (for EXACT_OUTPUT mode)
|
|
296
400
|
// Geo/onramp data
|
|
297
401
|
geoData,
|
|
298
402
|
coinbaseAvailablePaymentMethods,
|