@b3dotfun/sdk 0.0.62 → 0.0.63-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.js +61 -23
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +3 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +275 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +5 -4
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +9 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +288 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +33 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +4 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +4 -6
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +9 -17
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +6 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +11 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +66 -147
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -3
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +39 -15
- package/dist/cjs/anyspend/react/components/common/PaySection.js +1 -1
- package/dist/cjs/anyspend/react/components/common/TokenBalance.js +1 -1
- package/dist/cjs/anyspend/react/components/index.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/index.js +11 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +25 -3
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +42 -19
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendQuote.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +26 -0
- package/dist/cjs/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.js +56 -0
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +10 -0
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +73 -0
- package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +14 -0
- package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.js +57 -0
- package/dist/cjs/anyspend/react/hooks/usePhantomTransfer.d.ts +36 -0
- package/dist/cjs/anyspend/react/hooks/usePhantomTransfer.js +211 -0
- package/dist/cjs/anyspend/types/api.d.ts +665 -3
- package/dist/cjs/anyspend/utils/orderPayload.js +4 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +17 -4
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.js +3 -3
- package/dist/cjs/global-account/react/components/ProfileEditor/ProfileEditor.d.ts +6 -0
- package/dist/cjs/global-account/react/components/ProfileEditor/ProfileEditor.js +141 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +3 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/cjs/global-account/react/components/index.d.ts +2 -0
- package/dist/cjs/global-account/react/components/index.js +7 -2
- package/dist/cjs/global-account/react/hooks/index.d.ts +2 -1
- package/dist/cjs/global-account/react/hooks/index.js +5 -3
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +7 -2
- package/dist/cjs/global-account/react/hooks/useSimBalance.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +6 -5
- package/dist/cjs/global-account/react/hooks/useTokenBalanceDirect.d.ts +12 -0
- package/dist/cjs/global-account/react/hooks/useTokenBalanceDirect.js +62 -0
- package/dist/cjs/global-account/react/hooks/useTokenFromUrl.js +4 -3
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +37 -1
- package/dist/cjs/global-account/react/utils/profileDisplay.d.ts +6 -0
- package/dist/cjs/global-account/react/utils/profileDisplay.js +60 -4
- package/dist/esm/anyspend/react/components/AnySpend.js +62 -24
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +3 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +269 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +7 -6
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +9 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +285 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +11 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +30 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +4 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +5 -7
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +9 -17
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +6 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +11 -1
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +67 -148
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -3
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +40 -16
- package/dist/esm/anyspend/react/components/common/PaySection.js +1 -1
- package/dist/esm/anyspend/react/components/common/TokenBalance.js +2 -2
- package/dist/esm/anyspend/react/components/index.d.ts +5 -1
- package/dist/esm/anyspend/react/components/index.js +5 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +25 -3
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +42 -19
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendQuote.js +1 -1
- package/dist/esm/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +26 -0
- package/dist/esm/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.js +53 -0
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +10 -0
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +70 -0
- package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +14 -0
- package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.js +54 -0
- package/dist/esm/anyspend/react/hooks/usePhantomTransfer.d.ts +36 -0
- package/dist/esm/anyspend/react/hooks/usePhantomTransfer.js +208 -0
- package/dist/esm/anyspend/types/api.d.ts +665 -3
- package/dist/esm/anyspend/utils/orderPayload.js +4 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +18 -5
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.js +3 -3
- package/dist/esm/global-account/react/components/ProfileEditor/ProfileEditor.d.ts +6 -0
- package/dist/esm/global-account/react/components/ProfileEditor/ProfileEditor.js +135 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +3 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/esm/global-account/react/components/index.d.ts +2 -0
- package/dist/esm/global-account/react/components/index.js +3 -0
- package/dist/esm/global-account/react/hooks/index.d.ts +2 -1
- package/dist/esm/global-account/react/hooks/index.js +2 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +7 -2
- package/dist/esm/global-account/react/hooks/useSimBalance.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useSimBalance.js +6 -5
- package/dist/esm/global-account/react/hooks/useTokenBalanceDirect.d.ts +12 -0
- package/dist/esm/global-account/react/hooks/useTokenBalanceDirect.js +59 -0
- package/dist/esm/global-account/react/hooks/useTokenFromUrl.js +4 -3
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +37 -1
- package/dist/esm/global-account/react/utils/profileDisplay.d.ts +6 -0
- package/dist/esm/global-account/react/utils/profileDisplay.js +59 -4
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +34 -0
- package/dist/types/anyspend/react/components/AnySpendStakeB3ExactIn.d.ts +9 -0
- package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +11 -0
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +6 -1
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +2 -1
- package/dist/types/anyspend/react/components/index.d.ts +5 -1
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +25 -3
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +116 -0
- package/dist/types/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +26 -0
- package/dist/types/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +10 -0
- package/dist/types/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +14 -0
- package/dist/types/anyspend/react/hooks/usePhantomTransfer.d.ts +36 -0
- package/dist/types/anyspend/types/api.d.ts +665 -3
- package/dist/types/global-account/react/components/ProfileEditor/ProfileEditor.d.ts +6 -0
- package/dist/types/global-account/react/components/index.d.ts +2 -0
- package/dist/types/global-account/react/hooks/index.d.ts +2 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useSimBalance.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useTokenBalanceDirect.d.ts +12 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +37 -1
- package/dist/types/global-account/react/utils/profileDisplay.d.ts +6 -0
- package/package.json +4 -3
- package/src/anyspend/react/components/AnySpend.tsx +73 -22
- package/src/anyspend/react/components/AnySpendCustom.tsx +4 -0
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +595 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +8 -11
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +522 -0
- package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +73 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +7 -3
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +5 -7
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +9 -18
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +22 -0
- package/src/anyspend/react/components/common/OrderDetails.tsx +76 -190
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +2 -3
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +48 -17
- package/src/anyspend/react/components/common/PaySection.tsx +1 -0
- package/src/anyspend/react/components/common/TokenBalance.tsx +2 -2
- package/src/anyspend/react/components/index.ts +5 -1
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +51 -18
- package/src/anyspend/react/hooks/useAnyspendQuote.ts +1 -1
- package/src/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.ts +72 -0
- package/src/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.ts +80 -0
- package/src/anyspend/react/hooks/useConnectedWalletDisplay.ts +69 -0
- package/src/anyspend/react/hooks/usePhantomTransfer.ts +301 -0
- package/src/anyspend/types/api.ts +669 -1
- package/src/anyspend/utils/orderPayload.ts +5 -1
- package/src/global-account/react/components/B3DynamicModal.tsx +18 -4
- package/src/global-account/react/components/ManageAccount/BalanceContent.tsx +4 -4
- package/src/global-account/react/components/ProfileEditor/ProfileEditor.tsx +265 -0
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +3 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
- package/src/global-account/react/components/index.ts +4 -0
- package/src/global-account/react/hooks/index.ts +2 -1
- package/src/global-account/react/hooks/useAuthentication.ts +10 -2
- package/src/global-account/react/hooks/useSimBalance.ts +6 -5
- package/src/global-account/react/hooks/useTokenBalanceDirect.tsx +84 -0
- package/src/global-account/react/hooks/useTokenFromUrl.tsx +6 -5
- package/src/global-account/react/stores/useModalStore.ts +43 -1
- package/src/global-account/react/utils/profileDisplay.ts +67 -4
|
@@ -41,6 +41,8 @@ const buildPayload = (orderType, params) => {
|
|
|
41
41
|
};
|
|
42
42
|
case "custom":
|
|
43
43
|
return { ...payload };
|
|
44
|
+
case "custom_exact_in":
|
|
45
|
+
return { ...payload, expectedDstAmount };
|
|
44
46
|
case "hype_duel":
|
|
45
47
|
return {
|
|
46
48
|
expectedDstAmount,
|
|
@@ -66,6 +68,8 @@ const buildMetadata = (orderType, params) => {
|
|
|
66
68
|
return { ...baseMetadata, tournament };
|
|
67
69
|
case "custom":
|
|
68
70
|
return { ...baseMetadata, action: payload.action };
|
|
71
|
+
case "custom_exact_in":
|
|
72
|
+
return { ...baseMetadata, action: payload.action };
|
|
69
73
|
case "hype_duel":
|
|
70
74
|
return { ...baseMetadata };
|
|
71
75
|
default:
|
|
@@ -5,20 +5,22 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("../../../anyspend/react");
|
|
6
6
|
const AnyspendDepositHype_1 = require("../../../anyspend/react/components/AnyspendDepositHype");
|
|
7
7
|
const AnySpendStakeUpside_1 = require("../../../anyspend/react/components/AnySpendStakeUpside");
|
|
8
|
+
const AnySpendStakeUpsideExactIn_1 = require("../../../anyspend/react/components/AnySpendStakeUpsideExactIn");
|
|
8
9
|
const utils_1 = require("../../../anyspend/utils");
|
|
9
10
|
const react_2 = require("../../../global-account/react");
|
|
10
11
|
const cn_1 = require("../../../shared/utils/cn");
|
|
11
12
|
const debug_1 = require("../../../shared/utils/debug");
|
|
12
13
|
const react_3 = require("react");
|
|
14
|
+
const react_4 = require("thirdweb/react");
|
|
13
15
|
const AvatarEditor_1 = require("./AvatarEditor/AvatarEditor");
|
|
14
16
|
const useB3_1 = require("./B3Provider/useB3");
|
|
15
17
|
const LinkAccount_1 = require("./LinkAccount/LinkAccount");
|
|
18
|
+
const ProfileEditor_1 = require("./ProfileEditor/ProfileEditor");
|
|
16
19
|
const ManageAccount_1 = require("./ManageAccount/ManageAccount");
|
|
17
20
|
const RequestPermissions_1 = require("./RequestPermissions/RequestPermissions");
|
|
18
21
|
const SignInWithB3Flow_1 = require("./SignInWithB3/SignInWithB3Flow");
|
|
19
22
|
const dialog_1 = require("./ui/dialog");
|
|
20
23
|
const drawer_1 = require("./ui/drawer");
|
|
21
|
-
const react_4 = require("thirdweb/react");
|
|
22
24
|
const debug = (0, debug_1.debugB3React)("B3DynamicModal");
|
|
23
25
|
function B3DynamicModal() {
|
|
24
26
|
const { isOpen, setB3ModalOpen, contentType, history, navigateBack } = (0, react_2.useModalStore)();
|
|
@@ -45,7 +47,9 @@ function B3DynamicModal() {
|
|
|
45
47
|
"anySpendJoinTournament",
|
|
46
48
|
"anySpendFundTournament",
|
|
47
49
|
"anySpendStakeB3",
|
|
50
|
+
"anySpendStakeB3ExactIn",
|
|
48
51
|
"anySpendStakeUpside",
|
|
52
|
+
"anySpendStakeUpsideExactIn",
|
|
49
53
|
"anySpendBuySpin",
|
|
50
54
|
"anySpendOrderHistory",
|
|
51
55
|
"signInWithB3",
|
|
@@ -53,13 +57,16 @@ function B3DynamicModal() {
|
|
|
53
57
|
"anySpendBondKit",
|
|
54
58
|
"linkAccount",
|
|
55
59
|
"avatarEditor",
|
|
60
|
+
"profileEditor",
|
|
56
61
|
];
|
|
57
62
|
const freestyleTypes = [
|
|
58
63
|
"anySpendNft",
|
|
59
64
|
"anySpendJoinTournament",
|
|
60
65
|
"anySpendFundTournament",
|
|
61
66
|
"anySpendStakeB3",
|
|
67
|
+
"anySpendStakeB3ExactIn",
|
|
62
68
|
"anySpendStakeUpside",
|
|
69
|
+
"anySpendStakeUpsideExactIn",
|
|
63
70
|
"anySpendBuySpin",
|
|
64
71
|
"anySpendSignatureMint",
|
|
65
72
|
"anySpendBondKit",
|
|
@@ -95,8 +102,12 @@ function B3DynamicModal() {
|
|
|
95
102
|
return (0, jsx_runtime_1.jsx)(react_1.OrderHistory, { onBack: () => { }, mode: "modal" });
|
|
96
103
|
case "anySpendStakeB3":
|
|
97
104
|
return (0, jsx_runtime_1.jsx)(react_1.AnySpendStakeB3, { ...contentType, mode: "modal" });
|
|
105
|
+
case "anySpendStakeB3ExactIn":
|
|
106
|
+
return (0, jsx_runtime_1.jsx)(react_1.AnySpendStakeB3ExactIn, { ...contentType, mode: "modal" });
|
|
98
107
|
case "anySpendStakeUpside":
|
|
99
108
|
return (0, jsx_runtime_1.jsx)(AnySpendStakeUpside_1.AnySpendStakeUpside, { ...contentType, mode: "modal" });
|
|
109
|
+
case "anySpendStakeUpsideExactIn":
|
|
110
|
+
return (0, jsx_runtime_1.jsx)(AnySpendStakeUpsideExactIn_1.AnySpendStakeUpsideExactIn, { ...contentType, mode: "modal" });
|
|
100
111
|
case "anySpendBuySpin":
|
|
101
112
|
return (0, jsx_runtime_1.jsx)(react_1.AnySpendBuySpin, { ...contentType, mode: "modal" });
|
|
102
113
|
case "anySpendSignatureMint":
|
|
@@ -109,6 +120,8 @@ function B3DynamicModal() {
|
|
|
109
120
|
return (0, jsx_runtime_1.jsx)(AnyspendDepositHype_1.AnySpendDepositHype, { ...contentType, mode: "modal" });
|
|
110
121
|
case "avatarEditor":
|
|
111
122
|
return (0, jsx_runtime_1.jsx)(AvatarEditor_1.AvatarEditor, { onSetAvatar: contentType.onSuccess });
|
|
123
|
+
case "profileEditor":
|
|
124
|
+
return (0, jsx_runtime_1.jsx)(ProfileEditor_1.ProfileEditor, { onSuccess: contentType.onSuccess });
|
|
112
125
|
// Add other modal types here
|
|
113
126
|
default:
|
|
114
127
|
return null;
|
|
@@ -119,8 +132,8 @@ function B3DynamicModal() {
|
|
|
119
132
|
const ModalTitle = isMobile ? drawer_1.DrawerTitle : dialog_1.DialogTitle;
|
|
120
133
|
const ModalDescription = isMobile ? drawer_1.DrawerDescription : dialog_1.DialogDescription;
|
|
121
134
|
return ((0, jsx_runtime_1.jsxs)(ModalComponent, { open: isOpen, onOpenChange: setB3ModalOpen, children: [(0, jsx_runtime_1.jsxs)(ModalContent, { className: (0, cn_1.cn)(contentClass, "rounded-2xl bg-white shadow-xl dark:bg-gray-900", "border border-gray-200 dark:border-gray-800",
|
|
122
|
-
// Remove default width classes for avatar editor
|
|
123
|
-
contentType?.type === "avatarEditor"
|
|
135
|
+
// Remove default width classes for avatar editor and profile editor
|
|
136
|
+
contentType?.type === "avatarEditor" || contentType?.type === "profileEditor"
|
|
124
137
|
? "!w-[90vw] !max-w-none" // Use !important to override default styles
|
|
125
|
-
: "mx-auto w-full max-w-md sm:max-w-lg"), hideCloseButton: hideCloseButton, children: [(0, jsx_runtime_1.jsx)(ModalTitle, { className: "sr-only hidden", children: contentType?.type || "Modal" }), (0, jsx_runtime_1.jsx)(ModalDescription, { className: "sr-only hidden", children: contentType?.type || "Modal Body" }), (0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("no-scrollbar max-h-[90dvh] overflow-auto sm:max-h-[80dvh]"), children: [history.length > 0 && contentType?.showBackButton && ((0, jsx_runtime_1.jsxs)("button", { onClick: navigateBack, className: "flex items-center gap-2 px-6 py-4 text-gray-600 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-white", children: [(0, jsx_runtime_1.jsxs)("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M15.8337 10H4.16699", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M10.0003 15.8334L4.16699 10L10.0003 4.16669", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] }), (0, jsx_runtime_1.jsx)("span", { className: "text-sm font-medium", children: "Back" })] })), renderContent()] })] }), contentType?.type === "avatarEditor" && ((0, jsx_runtime_1.jsx)("button", { onClick: () => setB3ModalOpen(false), className: "fixed right-5 top-5 z-[100] cursor-pointer text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white", children: (0, jsx_runtime_1.jsx)("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M18 6L6 18M6 6L18 18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }))] }));
|
|
138
|
+
: "mx-auto w-full max-w-md sm:max-w-lg"), hideCloseButton: hideCloseButton, children: [(0, jsx_runtime_1.jsx)(ModalTitle, { className: "sr-only hidden", children: contentType?.type || "Modal" }), (0, jsx_runtime_1.jsx)(ModalDescription, { className: "sr-only hidden", children: contentType?.type || "Modal Body" }), (0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("no-scrollbar max-h-[90dvh] overflow-auto sm:max-h-[80dvh]"), children: [history.length > 0 && contentType?.showBackButton && ((0, jsx_runtime_1.jsxs)("button", { onClick: navigateBack, className: "flex items-center gap-2 px-6 py-4 text-gray-600 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-white", children: [(0, jsx_runtime_1.jsxs)("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M15.8337 10H4.16699", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M10.0003 15.8334L4.16699 10L10.0003 4.16669", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] }), (0, jsx_runtime_1.jsx)("span", { className: "text-sm font-medium", children: "Back" })] })), renderContent()] })] }), (contentType?.type === "avatarEditor" || contentType?.type === "profileEditor") && ((0, jsx_runtime_1.jsx)("button", { onClick: () => setB3ModalOpen(false), className: "fixed right-5 top-5 z-[100] cursor-pointer text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white", children: (0, jsx_runtime_1.jsx)("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M18 6L6 18M6 6L18 18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }))] }));
|
|
126
139
|
}
|
|
@@ -35,10 +35,10 @@ function BalanceContent({ onLogout, showDeposit = true, showSwap = true }) {
|
|
|
35
35
|
const [openAccordions, setOpenAccordions] = (0, react_2.useState)([]);
|
|
36
36
|
const hasExpandedRef = (0, react_2.useRef)(false);
|
|
37
37
|
const avatarUrl = user?.avatar ? (0, ipfs_1.getIpfsUrl)(user?.avatar) : profile?.avatar;
|
|
38
|
-
const
|
|
38
|
+
const handleEditProfile = () => {
|
|
39
39
|
setB3ModalOpen(true);
|
|
40
40
|
setB3ModalContentType({
|
|
41
|
-
type: "
|
|
41
|
+
type: "profileEditor",
|
|
42
42
|
showBackButton: true,
|
|
43
43
|
onSuccess: () => {
|
|
44
44
|
// navigate back on success
|
|
@@ -90,7 +90,7 @@ function BalanceContent({ onLogout, showDeposit = true, showSwap = true }) {
|
|
|
90
90
|
setB3ModalOpen(false);
|
|
91
91
|
setLogoutLoading(false);
|
|
92
92
|
};
|
|
93
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-between", children: (0, jsx_runtime_1.jsxs)("div", { className: "global-account-profile flex items-center gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "global-account-profile-avatar relative", children: [avatarUrl ? ((0, jsx_runtime_1.jsx)("img", { src: avatarUrl, alt: "Profile", className: "size-24 rounded-full" })) : ((0, jsx_runtime_1.jsx)("div", { className: "bg-b3-primary-wash size-24 rounded-full" })), (0, jsx_runtime_1.jsx)("button", { onClick:
|
|
93
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-6", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-between", children: (0, jsx_runtime_1.jsxs)("div", { className: "global-account-profile flex items-center gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "global-account-profile-avatar relative", children: [avatarUrl ? ((0, jsx_runtime_1.jsx)("img", { src: avatarUrl, alt: "Profile", className: "size-24 rounded-full" })) : ((0, jsx_runtime_1.jsx)("div", { className: "bg-b3-primary-wash size-24 rounded-full" })), (0, jsx_runtime_1.jsx)("button", { onClick: handleEditProfile, className: "bg-b3-grey border-b3-background hover:bg-b3-grey/80 absolute -bottom-1 -right-1 flex size-8 items-center justify-center rounded-full border-4 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Pencil, { size: 16, className: "text-b3-background" }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "global-account-profile-info", children: [(0, jsx_runtime_1.jsx)("h2", { className: "text-b3-grey text-xl font-semibold", children: user?.username || profile?.displayName || (0, utils_1.formatUsername)(profile?.name || "") }), (0, jsx_runtime_1.jsxs)("div", { className: "address-button border-b3-line bg-b3-line/20 hover:bg-b3-line/40 flex w-fit items-center gap-2 rounded-full border px-3 py-1 transition-colors", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-b3-foreground-muted font-mono text-xs", children: centerTruncate(account?.address || "", 6) }), (0, jsx_runtime_1.jsx)(react_1.CopyToClipboard, { text: account?.address || "" })] })] })] }) }), (showDeposit || showSwap) && ((0, jsx_runtime_1.jsxs)("div", { className: "grid grid-cols-2 gap-3", children: [showDeposit && ((0, jsx_runtime_1.jsxs)(react_1.Button, { className: "manage-account-deposit bg-b3-primary-wash hover:bg-b3-primary-wash/70 h-[84px] w-full flex-col items-start gap-2 rounded-2xl", onClick: () => {
|
|
94
94
|
setB3ModalOpen(true);
|
|
95
95
|
setB3ModalContentType({
|
|
96
96
|
type: "anySpend",
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ProfileEditor = ProfileEditor;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const app_1 = __importDefault(require("../../../../global-account/app"));
|
|
10
|
+
const react_1 = require("../../../../global-account/react");
|
|
11
|
+
const profileDisplay_1 = require("../../../../global-account/react/utils/profileDisplay");
|
|
12
|
+
const cn_1 = require("../../../../shared/utils/cn");
|
|
13
|
+
const debug_1 = require("../../../../shared/utils/debug");
|
|
14
|
+
const ipfs_1 = require("../../../../shared/utils/ipfs");
|
|
15
|
+
const thirdweb_1 = require("../../../../shared/utils/thirdweb");
|
|
16
|
+
const lucide_react_1 = require("lucide-react");
|
|
17
|
+
const react_2 = require("react");
|
|
18
|
+
const sonner_1 = require("sonner");
|
|
19
|
+
const react_3 = require("thirdweb/react");
|
|
20
|
+
const storage_1 = require("thirdweb/storage");
|
|
21
|
+
const debug = (0, debug_1.debugB3React)("ProfileEditor");
|
|
22
|
+
function ProfileEditor({ onSuccess, className }) {
|
|
23
|
+
const [selectedFile, setSelectedFile] = (0, react_2.useState)(null);
|
|
24
|
+
const [previewUrl, setPreviewUrl] = (0, react_2.useState)(null);
|
|
25
|
+
const [username, setUsername] = (0, react_2.useState)("");
|
|
26
|
+
const [isUploading, setIsUploading] = (0, react_2.useState)(false);
|
|
27
|
+
const [isSaving, setIsSaving] = (0, react_2.useState)(false);
|
|
28
|
+
const fileInputRef = (0, react_2.useRef)(null);
|
|
29
|
+
const { user, setUser } = (0, react_1.useB3)();
|
|
30
|
+
const account = (0, react_3.useActiveAccount)();
|
|
31
|
+
const { data: profile, refetch: refreshProfile } = (0, react_1.useProfile)({
|
|
32
|
+
address: account?.address,
|
|
33
|
+
fresh: true,
|
|
34
|
+
});
|
|
35
|
+
const rawAvatarUrl = user?.avatar ? (0, ipfs_1.getIpfsUrl)(user?.avatar) : profile?.avatar;
|
|
36
|
+
const avatarUrl = (0, profileDisplay_1.validateImageUrl)(rawAvatarUrl);
|
|
37
|
+
const safePreviewUrl = (0, profileDisplay_1.validateImageUrl)(previewUrl);
|
|
38
|
+
const hasAvatar = !!avatarUrl;
|
|
39
|
+
const currentUsername = user?.username || "";
|
|
40
|
+
const handleFileSelect = (event) => {
|
|
41
|
+
const file = event.target.files?.[0];
|
|
42
|
+
if (file) {
|
|
43
|
+
// Validate file type
|
|
44
|
+
if (!file.type.startsWith("image/")) {
|
|
45
|
+
sonner_1.toast.error("Please select an image file");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// Validate file size (max 5MB)
|
|
49
|
+
if (file.size > 5 * 1024 * 1024) {
|
|
50
|
+
sonner_1.toast.error("File size must be less than 5MB");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
setSelectedFile(file);
|
|
54
|
+
// Create preview URL
|
|
55
|
+
const url = URL.createObjectURL(file);
|
|
56
|
+
setPreviewUrl(url);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const handleRemoveFile = () => {
|
|
60
|
+
setSelectedFile(null);
|
|
61
|
+
if (previewUrl) {
|
|
62
|
+
URL.revokeObjectURL(previewUrl);
|
|
63
|
+
setPreviewUrl(null);
|
|
64
|
+
}
|
|
65
|
+
if (fileInputRef.current) {
|
|
66
|
+
fileInputRef.current.value = "";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const handleSave = async () => {
|
|
70
|
+
// Check if there are any changes
|
|
71
|
+
const hasAvatarChange = selectedFile !== null;
|
|
72
|
+
const hasUsernameChange = username.trim() !== "" && username !== currentUsername;
|
|
73
|
+
if (!hasAvatarChange && !hasUsernameChange) {
|
|
74
|
+
sonner_1.toast.error("Please make at least one change");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
setIsSaving(true);
|
|
78
|
+
try {
|
|
79
|
+
let ipfsUrl;
|
|
80
|
+
// Upload avatar if selected
|
|
81
|
+
if (hasAvatarChange && selectedFile) {
|
|
82
|
+
debug("Starting upload to IPFS", selectedFile);
|
|
83
|
+
setIsUploading(true);
|
|
84
|
+
ipfsUrl = await (0, storage_1.upload)({
|
|
85
|
+
client: thirdweb_1.client,
|
|
86
|
+
files: [selectedFile],
|
|
87
|
+
});
|
|
88
|
+
debug("Upload successful", ipfsUrl);
|
|
89
|
+
setIsUploading(false);
|
|
90
|
+
}
|
|
91
|
+
// Update user profile
|
|
92
|
+
let updatedUser = user;
|
|
93
|
+
// If both avatar and username need updating, do them sequentially
|
|
94
|
+
// Update avatar first if uploaded
|
|
95
|
+
if (ipfsUrl) {
|
|
96
|
+
// @ts-expect-error this resolved fine, look into why expect-error needed
|
|
97
|
+
updatedUser = await app_1.default.service("users").setAvatar({
|
|
98
|
+
avatar: ipfsUrl,
|
|
99
|
+
},
|
|
100
|
+
// @ts-expect-error - our typed client is expecting context even though it's set elsewhere
|
|
101
|
+
{});
|
|
102
|
+
}
|
|
103
|
+
// Update username if changed (this will use the updated user from avatar change if both were updated)
|
|
104
|
+
if (hasUsernameChange && user?._id) {
|
|
105
|
+
// @ts-expect-error this resolved fine, look into why expect-error needed
|
|
106
|
+
updatedUser = await app_1.default.service("users").registerUsername({ username: username },
|
|
107
|
+
// @ts-expect-error - our typed client is expecting context even though it's set elsewhere
|
|
108
|
+
{});
|
|
109
|
+
}
|
|
110
|
+
// Update user state
|
|
111
|
+
setUser(updatedUser);
|
|
112
|
+
// Refresh profile to get updated data
|
|
113
|
+
await refreshProfile();
|
|
114
|
+
// Show success message
|
|
115
|
+
const changes = [];
|
|
116
|
+
if (hasAvatarChange)
|
|
117
|
+
changes.push("avatar");
|
|
118
|
+
if (hasUsernameChange)
|
|
119
|
+
changes.push("username");
|
|
120
|
+
sonner_1.toast.success(`Successfully updated ${changes.join(" and ")}!`);
|
|
121
|
+
onSuccess?.();
|
|
122
|
+
// Clean up
|
|
123
|
+
handleRemoveFile();
|
|
124
|
+
setUsername("");
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
debug("Error updating profile:", error);
|
|
128
|
+
sonner_1.toast.error("Failed to update profile. Please try again.");
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
setIsUploading(false);
|
|
132
|
+
setIsSaving(false);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const handleFileInputClick = () => {
|
|
136
|
+
fileInputRef.current?.click();
|
|
137
|
+
};
|
|
138
|
+
const isLoading = isUploading || isSaving;
|
|
139
|
+
const hasChanges = selectedFile !== null || (username.trim() !== "" && username !== currentUsername);
|
|
140
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("flex flex-col items-center justify-center space-y-6 p-8", className), children: [(0, jsx_runtime_1.jsxs)("div", { className: "space-y-2 text-center", children: [(0, jsx_runtime_1.jsx)("h2", { className: "font-neue-montreal-semibold text-b3-grey text-2xl", children: "Edit Your Profile" }), (0, jsx_runtime_1.jsx)("p", { className: "text-b3-foreground-muted font-neue-montreal-medium", children: "Update your avatar and username" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "w-full max-w-md space-y-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "space-y-2", children: [(0, jsx_runtime_1.jsx)("label", { className: "text-b3-grey font-neue-montreal-semibold text-sm", children: "Avatar" }), (0, jsx_runtime_1.jsx)("div", { className: "flex justify-center", children: safePreviewUrl || avatarUrl ? ((0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)("div", { className: "border-b3-primary-blue h-32 w-32 overflow-hidden rounded-full border-4", children: (0, jsx_runtime_1.jsx)("img", { src: safePreviewUrl || avatarUrl || "", alt: safePreviewUrl ? "Preview" : "Current avatar", className: "h-full w-full object-cover" }) }), safePreviewUrl && ((0, jsx_runtime_1.jsx)("button", { onClick: handleRemoveFile, className: "bg-b3-negative absolute -right-2 -top-2 flex h-8 w-8 items-center justify-center rounded-full text-white transition-colors hover:bg-red-600", disabled: isLoading, children: (0, jsx_runtime_1.jsx)(lucide_react_1.X, { size: 16 }) }))] })) : ((0, jsx_runtime_1.jsx)("div", { className: "bg-b3-primary-wash h-32 w-32 rounded-full" })) }), !selectedFile && ((0, jsx_runtime_1.jsxs)(react_1.Button, { variant: "outline", onClick: handleFileInputClick, disabled: isLoading, className: "w-full", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Upload, { className: "mr-2 h-4 w-4" }), hasAvatar ? "Change Avatar" : "Upload Avatar"] })), (0, jsx_runtime_1.jsx)("input", { ref: fileInputRef, type: "file", accept: "image/*", onChange: handleFileSelect, className: "hidden" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "space-y-2", children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "username", className: "text-b3-grey font-neue-montreal-semibold text-sm", children: "Username" }), (0, jsx_runtime_1.jsx)("input", { id: "username", type: "text", value: username, onChange: e => setUsername(e.target.value), placeholder: currentUsername || "Enter username", className: "border-b3-line bg-b3-background text-b3-grey placeholder:text-b3-foreground-muted font-neue-montreal-medium focus:border-b3-primary-blue w-full rounded-lg border px-4 py-3 transition-colors focus:outline-none", disabled: isLoading }), currentUsername && ((0, jsx_runtime_1.jsxs)("p", { className: "text-b3-foreground-muted font-neue-montreal-medium text-xs", children: ["Current: ", currentUsername] }))] })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex w-full max-w-md gap-3", children: (0, jsx_runtime_1.jsx)(react_1.Button, { onClick: handleSave, disabled: isLoading || !hasChanges, className: "bg-b3-primary-blue hover:bg-b3-primary-blue/90 flex-1 text-white disabled:opacity-50", children: isLoading ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), isUploading ? "Uploading..." : "Saving..."] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Check, { className: "mr-2 h-4 w-4" }), "Save Changes"] })) }) }), (0, jsx_runtime_1.jsx)("div", { className: "text-b3-foreground-muted font-neue-montreal-medium max-w-md text-center text-xs", children: (0, jsx_runtime_1.jsx)("p", { children: "Your avatar will be uploaded to IPFS and stored securely. Make sure you have the rights to use this image." }) })] }));
|
|
141
|
+
}
|
|
@@ -22,6 +22,7 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
22
22
|
const { setB3ModalContentType, setB3ModalOpen, isOpen } = (0, react_1.useModalStore)();
|
|
23
23
|
const account = (0, react_3.useActiveAccount)();
|
|
24
24
|
const isAuthenticating = (0, react_1.useAuthStore)(state => state.isAuthenticating);
|
|
25
|
+
const isAuthenticated = (0, react_1.useAuthStore)(state => state.isAuthenticated);
|
|
25
26
|
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
26
27
|
const [refetchCount, setRefetchCount] = (0, react_2.useState)(0);
|
|
27
28
|
const [refetchError, setRefetchError] = (0, react_2.useState)(null);
|
|
@@ -64,7 +65,7 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
64
65
|
isOpen,
|
|
65
66
|
source,
|
|
66
67
|
});
|
|
67
|
-
if (isConnected) {
|
|
68
|
+
if (isConnected && isAuthenticated) {
|
|
68
69
|
// Check if we already have a signer for this partner
|
|
69
70
|
const hasExistingSigner = signers?.some(signer => signer.partner.id === partnerId);
|
|
70
71
|
if (hasExistingSigner) {
|
|
@@ -114,6 +115,7 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
114
115
|
signersEnabled,
|
|
115
116
|
isConnected,
|
|
116
117
|
isAuthenticating,
|
|
118
|
+
isAuthenticated,
|
|
117
119
|
isOpen,
|
|
118
120
|
]);
|
|
119
121
|
debug("render", {
|
|
@@ -41,8 +41,8 @@ function LoginStep({ onSuccess, chain }) {
|
|
|
41
41
|
}, header: {
|
|
42
42
|
title: "Sign in with B3",
|
|
43
43
|
titleIcon: "https://cdn.b3.fun/b3_logo.svg",
|
|
44
|
-
}, className: "b3-login-step", onConnect: async (wallet) => {
|
|
45
|
-
await onConnect(wallet);
|
|
44
|
+
}, className: "b3-login-step", onConnect: async (wallet, allConnectedWallets) => {
|
|
45
|
+
await onConnect(wallet, allConnectedWallets);
|
|
46
46
|
const account = wallet.getAccount();
|
|
47
47
|
if (!account)
|
|
48
48
|
throw new Error("No account found");
|
|
@@ -13,6 +13,8 @@ export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy";
|
|
|
13
13
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep";
|
|
14
14
|
export { getConnectOptionsFromStrategy, isWalletType, type AllowedStrategy } from "./SignInWithB3/utils/signInUtils";
|
|
15
15
|
export { ManageAccount } from "./ManageAccount/ManageAccount";
|
|
16
|
+
export { AvatarEditor } from "./AvatarEditor/AvatarEditor";
|
|
17
|
+
export { ProfileEditor } from "./ProfileEditor/ProfileEditor";
|
|
16
18
|
export { RequestPermissions } from "./RequestPermissions/RequestPermissions";
|
|
17
19
|
export { RequestPermissionsButton } from "./RequestPermissions/RequestPermissionsButton";
|
|
18
20
|
export { AccountAssets } from "./AccountAssets/AccountAssets";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.AnimatedLottie = exports.TransitionPanel = exports.TooltipTrigger = exports.TooltipProvider = exports.TooltipContent = exports.Tooltip = exports.TextShimmer = exports.TextLoop = exports.TabsTransitionWrapper = exports.TabsList = exports.TabsContent = exports.Tabs = exports.TabTrigger = exports.TabsPrimitive = exports.TabsListPrimitive = exports.TabsContentPrimitive = exports.TabTriggerPrimitive = exports.Skeleton = exports.ShinyButton = exports.ScrollBar = exports.ScrollArea = exports.PopoverTrigger = exports.PopoverContent = exports.Popover = exports.Loading = exports.Input = exports.GlareCardRounded = exports.GlareCard = exports.DropdownMenuTrigger = exports.DropdownMenuSeparator = exports.DropdownMenuItem = exports.DropdownMenuContent = exports.DropdownMenu = exports.DrawerTrigger = exports.DrawerTitle = exports.DrawerPortal = exports.DrawerOverlay = exports.DrawerHeader = exports.DrawerFooter = exports.DrawerDescription = exports.DrawerContent = exports.DrawerClose = exports.Drawer = exports.DialogTrigger = exports.DialogTitle = void 0;
|
|
3
|
+
exports.DialogHeader = exports.DialogFooter = exports.DialogDescription = exports.DialogContent = exports.DialogClose = exports.Dialog = exports.CommandShortcut = exports.CommandSeparator = exports.CommandList = exports.CommandItem = exports.CommandInput = exports.CommandGroup = exports.CommandEmpty = exports.CommandDialog = exports.Command = exports.buttonVariants = exports.Button = exports.badgeVariants = exports.Badge = exports.WalletConnectorIcon = exports.StaggeredFadeLoader = exports.CopyToClipboard = exports.ClientOnly = exports.customButtonVariants = exports.CustomButton = exports.SendERC20Button = exports.SendETHButton = exports.MintButton = exports.AccountAssets = exports.RequestPermissionsButton = exports.RequestPermissions = exports.ProfileEditor = exports.AvatarEditor = exports.ManageAccount = exports.isWalletType = exports.getConnectOptionsFromStrategy = exports.LoginStepContainer = exports.SignInWithB3Privy = exports.SignInWithB3Flow = exports.SignInWithB3 = exports.WalletRow = exports.PermissionItem = exports.AuthButton = exports.StyleRoot = exports.useB3 = exports.B3Context = exports.RelayKitProviderWrapper = exports.InnerProvider = exports.B3Provider = exports.B3DynamicModal = void 0;
|
|
4
|
+
exports.AnimatedLottie = exports.TransitionPanel = exports.TooltipTrigger = exports.TooltipProvider = exports.TooltipContent = exports.Tooltip = exports.TextShimmer = exports.TextLoop = exports.TabsTransitionWrapper = exports.TabsList = exports.TabsContent = exports.Tabs = exports.TabTrigger = exports.TabsPrimitive = exports.TabsListPrimitive = exports.TabsContentPrimitive = exports.TabTriggerPrimitive = exports.Skeleton = exports.ShinyButton = exports.ScrollBar = exports.ScrollArea = exports.PopoverTrigger = exports.PopoverContent = exports.Popover = exports.Loading = exports.Input = exports.GlareCardRounded = exports.GlareCard = exports.DropdownMenuTrigger = exports.DropdownMenuSeparator = exports.DropdownMenuItem = exports.DropdownMenuContent = exports.DropdownMenu = exports.DrawerTrigger = exports.DrawerTitle = exports.DrawerPortal = exports.DrawerOverlay = exports.DrawerHeader = exports.DrawerFooter = exports.DrawerDescription = exports.DrawerContent = exports.DrawerClose = exports.Drawer = exports.DialogTrigger = exports.DialogTitle = exports.DialogPortal = exports.DialogOverlay = void 0;
|
|
5
5
|
// Core Components
|
|
6
6
|
var B3DynamicModal_1 = require("./B3DynamicModal");
|
|
7
7
|
Object.defineProperty(exports, "B3DynamicModal", { enumerable: true, get: function () { return B3DynamicModal_1.B3DynamicModal; } });
|
|
@@ -37,6 +37,11 @@ Object.defineProperty(exports, "isWalletType", { enumerable: true, get: function
|
|
|
37
37
|
// ManageAccount Components
|
|
38
38
|
var ManageAccount_1 = require("./ManageAccount/ManageAccount");
|
|
39
39
|
Object.defineProperty(exports, "ManageAccount", { enumerable: true, get: function () { return ManageAccount_1.ManageAccount; } });
|
|
40
|
+
// Profile Components
|
|
41
|
+
var AvatarEditor_1 = require("./AvatarEditor/AvatarEditor");
|
|
42
|
+
Object.defineProperty(exports, "AvatarEditor", { enumerable: true, get: function () { return AvatarEditor_1.AvatarEditor; } });
|
|
43
|
+
var ProfileEditor_1 = require("./ProfileEditor/ProfileEditor");
|
|
44
|
+
Object.defineProperty(exports, "ProfileEditor", { enumerable: true, get: function () { return ProfileEditor_1.ProfileEditor; } });
|
|
40
45
|
// RequestPermissions Components
|
|
41
46
|
var RequestPermissions_1 = require("./RequestPermissions/RequestPermissions");
|
|
42
47
|
Object.defineProperty(exports, "RequestPermissions", { enumerable: true, get: function () { return RequestPermissions_1.RequestPermissions; } });
|
|
@@ -32,11 +32,12 @@ export { useSearchParamsSSR } from "./useSearchParamsSSR";
|
|
|
32
32
|
export { useSimBalance } from "./useSimBalance";
|
|
33
33
|
export { useSiwe } from "./useSiwe";
|
|
34
34
|
export { useTokenBalance } from "./useTokenBalance";
|
|
35
|
+
export { useTokenBalanceDirect } from "./useTokenBalanceDirect";
|
|
35
36
|
export { useTokenBalancesByChain } from "./useTokenBalancesByChain";
|
|
36
37
|
export { useTokenData } from "./useTokenData";
|
|
37
38
|
export { useTokenFromUrl } from "./useTokenFromUrl";
|
|
38
39
|
export { useTokenPrice } from "./useTokenPrice";
|
|
39
40
|
export { useTokenPriceWithFallback } from "./useTokenPriceWithFallback";
|
|
40
41
|
export { useTokensFromAddress } from "./useTokensFromAddress";
|
|
41
|
-
export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute";
|
|
42
42
|
export { useURLParams } from "./useURLParams";
|
|
43
|
+
export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute";
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.useUnifiedChainSwitchAndExecute = exports.useURLParams = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalanceDirect = exports.useTokenBalance = exports.useSiwe = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = exports.createWagmiConfig = void 0;
|
|
18
18
|
var createWagmiConfig_1 = require("../utils/createWagmiConfig");
|
|
19
19
|
Object.defineProperty(exports, "createWagmiConfig", { enumerable: true, get: function () { return createWagmiConfig_1.createWagmiConfig; } });
|
|
20
20
|
var useAccountAssets_1 = require("./useAccountAssets");
|
|
@@ -84,6 +84,8 @@ var useSiwe_1 = require("./useSiwe");
|
|
|
84
84
|
Object.defineProperty(exports, "useSiwe", { enumerable: true, get: function () { return useSiwe_1.useSiwe; } });
|
|
85
85
|
var useTokenBalance_1 = require("./useTokenBalance");
|
|
86
86
|
Object.defineProperty(exports, "useTokenBalance", { enumerable: true, get: function () { return useTokenBalance_1.useTokenBalance; } });
|
|
87
|
+
var useTokenBalanceDirect_1 = require("./useTokenBalanceDirect");
|
|
88
|
+
Object.defineProperty(exports, "useTokenBalanceDirect", { enumerable: true, get: function () { return useTokenBalanceDirect_1.useTokenBalanceDirect; } });
|
|
87
89
|
var useTokenBalancesByChain_1 = require("./useTokenBalancesByChain");
|
|
88
90
|
Object.defineProperty(exports, "useTokenBalancesByChain", { enumerable: true, get: function () { return useTokenBalancesByChain_1.useTokenBalancesByChain; } });
|
|
89
91
|
var useTokenData_1 = require("./useTokenData");
|
|
@@ -96,7 +98,7 @@ var useTokenPriceWithFallback_1 = require("./useTokenPriceWithFallback");
|
|
|
96
98
|
Object.defineProperty(exports, "useTokenPriceWithFallback", { enumerable: true, get: function () { return useTokenPriceWithFallback_1.useTokenPriceWithFallback; } });
|
|
97
99
|
var useTokensFromAddress_1 = require("./useTokensFromAddress");
|
|
98
100
|
Object.defineProperty(exports, "useTokensFromAddress", { enumerable: true, get: function () { return useTokensFromAddress_1.useTokensFromAddress; } });
|
|
99
|
-
var useUnifiedChainSwitchAndExecute_1 = require("./useUnifiedChainSwitchAndExecute");
|
|
100
|
-
Object.defineProperty(exports, "useUnifiedChainSwitchAndExecute", { enumerable: true, get: function () { return useUnifiedChainSwitchAndExecute_1.useUnifiedChainSwitchAndExecute; } });
|
|
101
101
|
var useURLParams_1 = require("./useURLParams");
|
|
102
102
|
Object.defineProperty(exports, "useURLParams", { enumerable: true, get: function () { return useURLParams_1.useURLParams; } });
|
|
103
|
+
var useUnifiedChainSwitchAndExecute_1 = require("./useUnifiedChainSwitchAndExecute");
|
|
104
|
+
Object.defineProperty(exports, "useUnifiedChainSwitchAndExecute", { enumerable: true, get: function () { return useUnifiedChainSwitchAndExecute_1.useUnifiedChainSwitchAndExecute; } });
|
|
@@ -8,9 +8,9 @@ export declare function useAuthentication(partnerId: string): {
|
|
|
8
8
|
isConnected: boolean;
|
|
9
9
|
wallet: import("thirdweb/dist/types/wallets/in-app/core/wallet/types").EcosystemWallet;
|
|
10
10
|
preAuthenticate: typeof preAuthenticate;
|
|
11
|
-
connect: (
|
|
11
|
+
connect: (_walleAutoConnectedWith: Wallet, allConnectedWallets: Wallet[]) => Promise<void>;
|
|
12
12
|
isAuthenticating: boolean;
|
|
13
|
-
onConnect: (
|
|
13
|
+
onConnect: (_walleAutoConnectedWith: Wallet, allConnectedWallets: Wallet[]) => Promise<void>;
|
|
14
14
|
user: {
|
|
15
15
|
email?: string | undefined;
|
|
16
16
|
username?: string | undefined;
|
|
@@ -142,7 +142,12 @@ function useAuthentication(partnerId) {
|
|
|
142
142
|
return userAuth;
|
|
143
143
|
}
|
|
144
144
|
}, [activeWallet, partnerId, authenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
|
|
145
|
-
const onConnect = (0, react_2.useCallback)(async (
|
|
145
|
+
const onConnect = (0, react_2.useCallback)(async (_walleAutoConnectedWith, allConnectedWallets) => {
|
|
146
|
+
debug("@@useAuthentication:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
|
|
147
|
+
const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
148
|
+
if (!wallet) {
|
|
149
|
+
throw new Error("No smart wallet found during auto-connect");
|
|
150
|
+
}
|
|
146
151
|
debug("@@useAuthentication:onConnect", { wallet });
|
|
147
152
|
try {
|
|
148
153
|
setHasStartedConnecting(true);
|
|
@@ -209,7 +214,7 @@ function useAuthentication(partnerId) {
|
|
|
209
214
|
const { isLoading: useAutoConnectLoading } = (0, react_3.useAutoConnect)({
|
|
210
215
|
client: thirdweb_1.client,
|
|
211
216
|
wallets: [wallet],
|
|
212
|
-
onConnect
|
|
217
|
+
onConnect,
|
|
213
218
|
});
|
|
214
219
|
/**
|
|
215
220
|
* useAutoConnectLoading starts as false
|
|
@@ -21,4 +21,4 @@ export interface SimBalanceResponse {
|
|
|
21
21
|
wallet_address: string;
|
|
22
22
|
balances: SimBalanceItem[];
|
|
23
23
|
}
|
|
24
|
-
export declare function useSimBalance(address?: string): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
|
|
24
|
+
export declare function useSimBalance(address?: string, chainIdsParam?: number[]): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSimBalance = useSimBalance;
|
|
4
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
5
|
-
async function fetchSimBalance(address) {
|
|
5
|
+
async function fetchSimBalance(address, chainIdsParam) {
|
|
6
6
|
if (!address)
|
|
7
7
|
throw new Error("Address is required");
|
|
8
|
-
|
|
8
|
+
const chainIds = chainIdsParam.length === 0 ? "mainnet" : chainIdsParam.join(",");
|
|
9
|
+
let url = `https://simdune-api.sean-430.workers.dev/?url=https://api.sim.dune.com/v1/evm/balances/${address}?metadata=logo&chain_ids=${chainIds}`;
|
|
9
10
|
if (process.env.NEXT_PUBLIC_LOCAL_KEY) {
|
|
10
11
|
url += `&localkey=${process.env.NEXT_PUBLIC_LOCAL_KEY}`;
|
|
11
12
|
}
|
|
@@ -16,13 +17,13 @@ async function fetchSimBalance(address) {
|
|
|
16
17
|
const balanceData = await response.json();
|
|
17
18
|
return balanceData;
|
|
18
19
|
}
|
|
19
|
-
function useSimBalance(address) {
|
|
20
|
+
function useSimBalance(address, chainIdsParam) {
|
|
20
21
|
return (0, react_query_1.useQuery)({
|
|
21
|
-
queryKey: ["simBalance", address],
|
|
22
|
+
queryKey: ["simBalance", address, chainIdsParam],
|
|
22
23
|
queryFn: () => {
|
|
23
24
|
if (!address)
|
|
24
25
|
throw new Error("Address is required");
|
|
25
|
-
return fetchSimBalance(address);
|
|
26
|
+
return fetchSimBalance(address, chainIdsParam || []);
|
|
26
27
|
},
|
|
27
28
|
enabled: Boolean(address),
|
|
28
29
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { components } from "../../../anyspend/types/api";
|
|
2
|
+
interface UseTokenBalanceProps {
|
|
3
|
+
token: components["schemas"]["Token"];
|
|
4
|
+
address?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface TokenBalanceResult {
|
|
7
|
+
rawBalance: bigint | null;
|
|
8
|
+
formattedBalance: string;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function useTokenBalanceDirect({ token, address }: UseTokenBalanceProps): TokenBalanceResult;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useTokenBalanceDirect = useTokenBalanceDirect;
|
|
5
|
+
const anyspend_1 = require("../../../anyspend");
|
|
6
|
+
const react_1 = require("../../../global-account/react");
|
|
7
|
+
const number_1 = require("../../../shared/utils/number");
|
|
8
|
+
const thirdweb_insights_1 = require("../../../shared/utils/thirdweb-insights");
|
|
9
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
10
|
+
const react_2 = require("react");
|
|
11
|
+
function useTokenBalanceDirect({ token, address }) {
|
|
12
|
+
const account = (0, react_1.useAccountWallet)();
|
|
13
|
+
const effectiveAddress = address || account?.address;
|
|
14
|
+
const { data: tokenBalance, isLoading, isFetching, refetch, } = (0, react_query_1.useQuery)({
|
|
15
|
+
queryKey: ["tokenBalance", effectiveAddress, token.chainId, token.address],
|
|
16
|
+
queryFn: async () => {
|
|
17
|
+
if (!effectiveAddress)
|
|
18
|
+
return { formatted: "0", raw: null };
|
|
19
|
+
if ((0, anyspend_1.isNativeToken)(token.address)) {
|
|
20
|
+
const nativeToken = await (0, thirdweb_insights_1.getNativeTokenBalance)(effectiveAddress, token.chainId);
|
|
21
|
+
if (nativeToken && nativeToken.balance) {
|
|
22
|
+
const rawBalance = nativeToken.balance;
|
|
23
|
+
return {
|
|
24
|
+
formatted: (0, number_1.formatTokenAmount)(BigInt(rawBalance), Number(nativeToken.decimals || 18)),
|
|
25
|
+
raw: BigInt(rawBalance),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return { formatted: "0", raw: null };
|
|
29
|
+
}
|
|
30
|
+
const response = await (0, thirdweb_insights_1.getERC20Balances)(effectiveAddress, {
|
|
31
|
+
chainIds: [token.chainId],
|
|
32
|
+
includeSpam: false,
|
|
33
|
+
});
|
|
34
|
+
const tokenBalance = response.data?.find(t => t.token_address === token.address);
|
|
35
|
+
if (tokenBalance?.balance) {
|
|
36
|
+
return {
|
|
37
|
+
formatted: (0, number_1.formatTokenAmount)(BigInt(tokenBalance.balance), Number(tokenBalance.decimals || 18)),
|
|
38
|
+
raw: BigInt(tokenBalance.balance),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return { formatted: "0", raw: null };
|
|
42
|
+
},
|
|
43
|
+
enabled: !!effectiveAddress,
|
|
44
|
+
staleTime: 30000,
|
|
45
|
+
gcTime: 5 * 60 * 1000,
|
|
46
|
+
retry: 2,
|
|
47
|
+
structuralSharing: false,
|
|
48
|
+
});
|
|
49
|
+
// Force a refetch when the wallet or token changes
|
|
50
|
+
(0, react_2.useEffect)(() => {
|
|
51
|
+
if (effectiveAddress) {
|
|
52
|
+
refetch();
|
|
53
|
+
}
|
|
54
|
+
}, [effectiveAddress, token.address, token.chainId, token.symbol, refetch]);
|
|
55
|
+
// Determine if we're actually loading
|
|
56
|
+
const isActuallyLoading = !effectiveAddress || isLoading || (isFetching && !tokenBalance);
|
|
57
|
+
return {
|
|
58
|
+
rawBalance: tokenBalance?.raw || BigInt(0),
|
|
59
|
+
formattedBalance: tokenBalance?.formatted || "0",
|
|
60
|
+
isLoading: isActuallyLoading,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -32,10 +32,11 @@ function useTokenFromUrl({ defaultToken, prefix }) {
|
|
|
32
32
|
// Get parameters from URL
|
|
33
33
|
const currencyParam = searchParams.get(`${prefix}Currency`);
|
|
34
34
|
const chainIdParam = searchParams.get(`${prefix}ChainId`);
|
|
35
|
-
// Determine if we should fetch token info
|
|
36
|
-
const shouldFetchToken = Boolean(currencyParam && chainIdParam && currencyParam.toLowerCase() !== defaultToken.address.toLowerCase());
|
|
37
35
|
// Determine network based on chainId
|
|
38
|
-
const
|
|
36
|
+
const chainInfo = chainIdParam ? (0, supported_1.getCoingeckoChainInfo)(Number(chainIdParam)) : null;
|
|
37
|
+
const network = chainInfo?.coingecko_id || "";
|
|
38
|
+
// Determine if we should fetch token info
|
|
39
|
+
const shouldFetchToken = Boolean(currencyParam && chainIdParam && chainInfo && currencyParam.toLowerCase() !== defaultToken.address.toLowerCase());
|
|
39
40
|
const { data: tokenInfo, isError } = (0, react_query_1.useQuery)({
|
|
40
41
|
queryKey: ["tokenInfo", network, currencyParam],
|
|
41
42
|
queryFn: () => fetchTokenInfo(network, currencyParam || ""),
|