@b3dotfun/sdk 0.0.40 → 0.0.41-test.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +10 -1
  2. package/dist/cjs/anyspend/react/components/AnySpend.js +7 -3
  3. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
  4. package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +6 -3
  5. package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +5 -3
  6. package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
  7. package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +9 -9
  8. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
  9. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
  10. package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +39 -37
  11. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +8 -11
  12. package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
  13. package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
  14. package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
  15. package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +7 -6
  16. package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
  17. package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +14 -0
  18. package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
  19. package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
  20. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
  21. package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +13 -5
  22. package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
  23. package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
  24. package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
  25. package/dist/cjs/anyspend/react/providers/index.js +3 -0
  26. package/dist/cjs/anyspend/types/api.d.ts +10 -0
  27. package/dist/cjs/anyspend/utils/chain.js +1 -1
  28. package/dist/cjs/bondkit/bondkitToken.d.ts +37 -2
  29. package/dist/cjs/bondkit/bondkitToken.js +268 -2
  30. package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +1 -1
  31. package/dist/cjs/bondkit/bondkitTokenFactory.js +2 -2
  32. package/dist/cjs/bondkit/config.d.ts +1 -1
  33. package/dist/cjs/bondkit/config.js +5 -2
  34. package/dist/cjs/bondkit/constants.d.ts +4 -0
  35. package/dist/cjs/bondkit/constants.js +6 -1
  36. package/dist/cjs/bondkit/index.d.ts +1 -0
  37. package/dist/cjs/bondkit/index.js +4 -1
  38. package/dist/cjs/bondkit/swapService.d.ts +43 -0
  39. package/dist/cjs/bondkit/swapService.js +373 -0
  40. package/dist/cjs/bondkit/types.d.ts +10 -4
  41. package/dist/cjs/bondkit/types.js +4 -5
  42. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
  43. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +37 -9
  44. package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +63 -3
  45. package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
  46. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
  47. package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -2
  48. package/dist/cjs/global-account/react/hooks/useSimBalance.js +2 -2
  49. package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +27 -22
  50. package/dist/esm/anyspend/react/components/AnySpend.d.ts +10 -1
  51. package/dist/esm/anyspend/react/components/AnySpend.js +7 -3
  52. package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
  53. package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +6 -3
  54. package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -4
  55. package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
  56. package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +9 -9
  57. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
  58. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
  59. package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +39 -37
  60. package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -11
  61. package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
  62. package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
  63. package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
  64. package/dist/esm/anyspend/react/components/common/PanelOnramp.js +7 -6
  65. package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
  66. package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +8 -0
  67. package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
  68. package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
  69. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
  70. package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +13 -5
  71. package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
  72. package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
  73. package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
  74. package/dist/esm/anyspend/react/providers/index.js +1 -0
  75. package/dist/esm/anyspend/types/api.d.ts +10 -0
  76. package/dist/esm/anyspend/utils/chain.js +1 -1
  77. package/dist/esm/bondkit/bondkitToken.d.ts +37 -2
  78. package/dist/esm/bondkit/bondkitToken.js +268 -2
  79. package/dist/esm/bondkit/bondkitTokenFactory.d.ts +1 -1
  80. package/dist/esm/bondkit/bondkitTokenFactory.js +2 -2
  81. package/dist/esm/bondkit/config.d.ts +1 -1
  82. package/dist/esm/bondkit/config.js +5 -2
  83. package/dist/esm/bondkit/constants.d.ts +4 -0
  84. package/dist/esm/bondkit/constants.js +5 -0
  85. package/dist/esm/bondkit/index.d.ts +1 -0
  86. package/dist/esm/bondkit/index.js +2 -0
  87. package/dist/esm/bondkit/swapService.d.ts +43 -0
  88. package/dist/esm/bondkit/swapService.js +369 -0
  89. package/dist/esm/bondkit/types.d.ts +10 -4
  90. package/dist/esm/bondkit/types.js +4 -5
  91. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
  92. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +38 -9
  93. package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +65 -5
  94. package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
  95. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
  96. package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -2
  97. package/dist/esm/global-account/react/hooks/useSimBalance.js +2 -2
  98. package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +27 -22
  99. package/dist/styles/index.css +1 -1
  100. package/dist/types/anyspend/react/components/AnySpend.d.ts +10 -1
  101. package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +8 -0
  102. package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
  103. package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
  104. package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
  105. package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
  106. package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
  107. package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
  108. package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
  109. package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
  110. package/dist/types/anyspend/react/providers/index.d.ts +1 -0
  111. package/dist/types/anyspend/types/api.d.ts +10 -0
  112. package/dist/types/bondkit/bondkitToken.d.ts +37 -2
  113. package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
  114. package/dist/types/bondkit/config.d.ts +1 -1
  115. package/dist/types/bondkit/constants.d.ts +4 -0
  116. package/dist/types/bondkit/index.d.ts +1 -0
  117. package/dist/types/bondkit/swapService.d.ts +43 -0
  118. package/dist/types/bondkit/types.d.ts +10 -4
  119. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -3
  120. package/package.json +7 -5
  121. package/src/anyspend/react/components/AnySpend.tsx +23 -0
  122. package/src/anyspend/react/components/AnyspendDepositHype.tsx +22 -0
  123. package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +7 -4
  124. package/src/anyspend/react/components/common/CryptoPaySection.tsx +13 -8
  125. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +170 -44
  126. package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +63 -45
  127. package/src/anyspend/react/components/common/OrderDetails.tsx +10 -14
  128. package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
  129. package/src/anyspend/react/components/common/PanelOnramp.tsx +28 -15
  130. package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
  131. package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
  132. package/src/anyspend/react/hooks/useAnyspendFlow.ts +13 -5
  133. package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
  134. package/src/anyspend/react/providers/index.ts +1 -0
  135. package/src/anyspend/types/api.ts +10 -0
  136. package/src/anyspend/types/api_req_res.ts +6 -10
  137. package/src/anyspend/utils/chain.ts +1 -1
  138. package/src/bondkit/bondkitToken.ts +323 -3
  139. package/src/bondkit/bondkitTokenFactory.ts +2 -2
  140. package/src/bondkit/config.ts +5 -2
  141. package/src/bondkit/constants.ts +7 -0
  142. package/src/bondkit/index.ts +3 -0
  143. package/src/bondkit/swapService.ts +461 -0
  144. package/src/bondkit/types.ts +12 -5
  145. package/src/global-account/react/components/B3Provider/B3Provider.tsx +54 -15
  146. package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +106 -32
  147. package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +60 -5
  148. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
  149. package/src/global-account/react/hooks/useAuthentication.ts +1 -2
  150. package/src/global-account/react/hooks/useSimBalance.ts +2 -2
  151. package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +28 -23
@@ -4,6 +4,7 @@ import { Button, TabsContentPrimitive, TabsListPrimitive, TabsPrimitive, TabTrig
4
4
  import { SignOutIcon } from "../../../../global-account/react/components/icons/SignOutIcon.js";
5
5
  import { formatNumber } from "../../../../shared/utils/formatNumber.js";
6
6
  import { client } from "../../../../shared/utils/thirdweb.js";
7
+ import { truncateAddress } from "../../../../shared/utils/truncateAddress.js";
7
8
  import { BarChart3, Coins, Copy, Image, LinkIcon, Loader2, Pencil, Settings, UnlinkIcon } from "lucide-react";
8
9
  import { useRef, useState } from "react";
9
10
  import { toast } from "sonner";
@@ -12,6 +13,21 @@ import { formatUnits } from "viem";
12
13
  import { getProfileDisplayInfo } from "../../utils/profileDisplay.js";
13
14
  import { AccountAssets } from "../AccountAssets/AccountAssets.js";
14
15
  import { ContentTokens } from "./ContentTokens.js";
16
+ // Helper function to check if a string is a wallet address and format it
17
+ const formatProfileTitle = (title) => {
18
+ // Check if title looks like an Ethereum address (0x followed by 40 hex characters)
19
+ const isEthereumAddress = /^0x[a-fA-F0-9]{40}$/.test(title);
20
+ if (isEthereumAddress) {
21
+ return {
22
+ displayTitle: truncateAddress(title),
23
+ isAddress: true,
24
+ };
25
+ }
26
+ return {
27
+ displayTitle: title,
28
+ isAddress: false,
29
+ };
30
+ };
15
31
  import { BalanceContent } from "./BalanceContent.js";
16
32
  export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain, partnerId, showSwap, showDeposit, }) {
17
33
  const [revokingSignerId, setRevokingSignerId] = useState(null);
@@ -111,7 +127,7 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
111
127
  }
112
128
  };
113
129
  const profiles = profilesRaw
114
- .filter((profile) => !["custom_auth_endpoint", "siwe"].includes(profile.type))
130
+ .filter((profile) => !["custom_auth_endpoint"].includes(profile.type))
115
131
  .map((profile) => ({
116
132
  ...getProfileDisplayInfo(profile),
117
133
  originalProfile: profile,
@@ -146,7 +162,24 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
146
162
  },
147
163
  });
148
164
  };
149
- return (_jsxs("div", { className: "linked-accounts-settings space-y-8", children: [_jsxs("div", { className: "linked-accounts-section space-y-4", children: [_jsxs("div", { className: "linked-accounts-header flex items-center justify-between", children: [_jsx("h3", { className: "text-b3-grey font-neue-montreal-semibold linked-accounts-settings-title text-xl", children: "Linked Accounts" }), _jsxs(Button, { className: "linked-accounts-settings-button linked-accounts-link-button bg-b3-primary-wash hover:bg-b3-primary-wash/70 flex items-center gap-2 rounded-full px-4 py-2", onClick: handleOpenLinkModal, disabled: isLinking, children: [isLinking ? (_jsx(Loader2, { className: "linked-accounts-link-loading text-b3-primary-blue animate-spin", size: 16 })) : (_jsx(LinkIcon, { size: 16, className: "linked-accounts-link-icon text-b3-primary-blue" })), _jsx("span", { className: "linked-accounts-link-text text-b3-grey font-neue-montreal-semibold", children: isLinking ? "Linking..." : "Link New Account" })] })] }), isLoadingProfiles ? (_jsx("div", { className: "linked-accounts-loading flex justify-center py-8", children: _jsx(Loader2, { className: "text-b3-grey animate-spin" }) })) : profiles.length > 0 ? (_jsx("div", { className: "linked-accounts-list space-y-4", children: profiles.map(profile => (_jsxs("div", { className: "linked-account-item bg-b3-line flex items-center justify-between rounded-xl p-4", children: [_jsxs("div", { className: "linked-account-info flex items-center gap-3", children: [profile.imageUrl ? (_jsx("img", { src: profile.imageUrl, alt: profile.title, className: "linked-account-avatar linked-account-avatar-image size-10 rounded-full" })) : (_jsx("div", { className: "linked-account-avatar linked-account-avatar-placeholder bg-b3-primary-wash flex h-10 w-10 items-center justify-center rounded-full", children: _jsx("span", { className: "linked-account-initial text-b3-grey font-neue-montreal-semibold text-sm uppercase", children: profile.initial }) })), _jsxs("div", { className: "linked-account-details", children: [_jsxs("div", { className: "linked-account-title-row flex items-center gap-2", children: [_jsx("span", { className: "linked-account-title text-b3-grey font-neue-montreal-semibold", children: profile.title }), _jsx("span", { className: "linked-account-type text-b3-foreground-muted font-neue-montreal-medium bg-b3-primary-wash rounded px-2 py-0.5 text-xs", children: profile.type.toUpperCase() })] }), _jsx("div", { className: "linked-account-subtitle text-b3-foreground-muted font-neue-montreal-medium text-sm", children: profile.subtitle })] })] }), _jsx(Button, { variant: "ghost", size: "icon", className: "linked-account-unlink-button text-b3-grey hover:text-b3-negative", onClick: () => handleUnlink(profile), disabled: unlinkingAccountId === profile.title || isUnlinking, children: unlinkingAccountId === profile.title || isUnlinking ? (_jsx(Loader2, { className: "linked-account-unlink-loading animate-spin" })) : (_jsx(UnlinkIcon, { size: 16, className: "linked-account-unlink-icon" })) })] }, profile.title))) })) : (_jsx("div", { className: "linked-accounts-empty text-b3-foreground-muted py-8 text-center", children: "No linked accounts found" }))] }), showReferralInfo && (
165
+ console.log("@@profiles", profiles);
166
+ return (_jsxs("div", { className: "linked-accounts-settings space-y-8", children: [_jsxs("div", { className: "linked-accounts-section space-y-4", children: [_jsxs("div", { className: "linked-accounts-header flex items-center justify-between", children: [_jsx("h3", { className: "text-b3-grey font-neue-montreal-semibold linked-accounts-settings-title text-xl", children: "Linked Accounts" }), _jsxs(Button, { className: "linked-accounts-settings-button linked-accounts-link-button bg-b3-primary-wash hover:bg-b3-primary-wash/70 flex items-center gap-2 rounded-full px-4 py-2", onClick: handleOpenLinkModal, disabled: isLinking, children: [isLinking ? (_jsx(Loader2, { className: "linked-accounts-link-loading text-b3-primary-blue animate-spin", size: 16 })) : (_jsx(LinkIcon, { size: 16, className: "linked-accounts-link-icon text-b3-primary-blue" })), _jsx("span", { className: "linked-accounts-link-text text-b3-grey font-neue-montreal-semibold", children: isLinking ? "Linking..." : "Link New Account" })] })] }), isLoadingProfiles ? (_jsx("div", { className: "linked-accounts-loading flex justify-center py-8", children: _jsx(Loader2, { className: "text-b3-grey animate-spin" }) })) : profiles.length > 0 ? (_jsx("div", { className: "linked-accounts-list space-y-4", children: profiles.map(profile => (_jsxs("div", { className: "linked-account-item bg-b3-line group flex items-center justify-between rounded-xl p-4", children: [_jsxs("div", { className: "linked-account-info flex items-center gap-3", children: [profile.imageUrl ? (_jsx("img", { src: profile.imageUrl, alt: profile.title, className: "linked-account-avatar linked-account-avatar-image size-10 rounded-full" })) : (_jsx("div", { className: "linked-account-avatar linked-account-avatar-placeholder bg-b3-primary-wash flex h-10 w-10 items-center justify-center rounded-full", children: _jsx("span", { className: "linked-account-initial text-b3-grey font-neue-montreal-semibold text-sm uppercase", children: profile.initial }) })), _jsxs("div", { className: "linked-account-details", children: [_jsxs("div", { className: "linked-account-title-row flex items-center gap-2", children: [(() => {
167
+ const { displayTitle, isAddress } = formatProfileTitle(profile.title);
168
+ const handleCopyAddress = async (e) => {
169
+ e.stopPropagation();
170
+ try {
171
+ await navigator.clipboard.writeText(profile.title);
172
+ toast.success("Address copied to clipboard!");
173
+ }
174
+ catch (error) {
175
+ toast.error("Failed to copy address");
176
+ }
177
+ };
178
+ return (_jsxs("div", { className: "flex items-center gap-1", children: [_jsx("span", { className: `linked-account-title text-b3-grey font-neue-montreal-semibold ${isAddress
179
+ ? "font-mono text-sm" // Use monospace font for addresses
180
+ : "break-words" // Use break-words for emails/names (better than break-all)
181
+ }`, title: isAddress ? profile.title : undefined, children: displayTitle }), isAddress && (_jsx("button", { onClick: handleCopyAddress, className: "linked-account-copy-button ml-1 rounded p-1 opacity-0 transition-opacity hover:bg-gray-100 group-hover:opacity-100", title: "Copy full address", children: _jsx(Copy, { size: 12, className: "text-gray-500 hover:text-gray-700" }) }))] }));
182
+ })(), _jsx("span", { className: "linked-account-type text-b3-foreground-muted font-neue-montreal-medium bg-b3-primary-wash rounded px-2 py-0.5 text-xs", children: profile.type.toUpperCase() })] }), _jsx("div", { className: "linked-account-subtitle text-b3-foreground-muted font-neue-montreal-medium text-sm", children: profile.subtitle })] })] }), _jsx(Button, { variant: "ghost", size: "icon", className: "linked-account-unlink-button text-b3-grey hover:text-b3-negative", onClick: () => handleUnlink(profile), disabled: unlinkingAccountId === profile.title || isUnlinking, children: unlinkingAccountId === profile.title || isUnlinking ? (_jsx(Loader2, { className: "linked-account-unlink-loading animate-spin" })) : (_jsx(UnlinkIcon, { size: 16, className: "linked-account-unlink-icon" })) })] }, profile.title))) })) : (_jsx("div", { className: "linked-accounts-empty text-b3-foreground-muted py-8 text-center", children: "No linked accounts found" }))] }), showReferralInfo && (
150
183
  /* Referral Section */
151
184
  _jsxs("div", { className: "referrals-section space-y-4", children: [_jsx("h3", { className: "referrals-title text-b3-grey font-neue-montreal-semibold text-xl", children: "Referrals" }), _jsxs("div", { className: "referral-code-container bg-b3-line rounded-xl p-4", children: [isEditingCode && (_jsxs("div", { className: "referral-code-header-editing", children: [_jsx("div", { className: "referral-code-title text-b3-grey font-neue-montreal-semibold", children: "Your Referral Code" }), _jsx("div", { className: "referral-code-description text-b3-foreground-muted font-neue-montreal-medium text-sm", children: "Share this code with friends to earn rewards" })] })), _jsxs("div", { className: "referral-code-content flex items-center justify-between", children: [!isEditingCode && (_jsxs("div", { className: "referral-code-header", children: [_jsx("div", { className: "referral-code-title text-b3-grey font-neue-montreal-semibold", children: "Your Referral Code" }), _jsx("div", { className: "referral-code-description text-b3-foreground-muted font-neue-montreal-medium text-sm", children: "Share this code with friends to earn rewards" })] })), _jsx("div", { className: "referral-code-actions flex items-center gap-2", children: isEditingCode ? (_jsxs("div", { className: "referral-code-edit-form flex items-center gap-2", children: [_jsx("input", { type: "text", value: newReferralCode, onChange: e => setNewReferralCode(e.target.value), className: "referral-code-input rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm", placeholder: "Enter new code", ref: referallCodeRef }), _jsx(Button, { size: "sm", className: "referral-code-save-button", onClick: handleUpdateReferralCode, disabled: isUpdatingCode || !newReferralCode, children: isUpdatingCode ? (_jsx(Loader2, { className: "referral-code-save-loading h-4 w-4 animate-spin" })) : ("Save") }), _jsx(Button, { size: "sm", variant: "ghost", className: "referral-code-cancel-button", onClick: () => {
152
185
  setIsEditingCode(false);
@@ -1,10 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AuthButton, Button, getConnectOptionsFromStrategy, isWalletType, LoginStepContainer, useAuthentication, useAuthStore, useConnect, WalletRow, } from "../../../../../global-account/react/index.js";
3
- import { debug } from "../../../../../shared/utils/debug.js";
3
+ import { debugB3React } from "../../../../../shared/utils/debug.js";
4
4
  import { client } from "../../../../../shared/utils/thirdweb.js";
5
5
  import { useState } from "react";
6
6
  import { useConnect as useConnectTW } from "thirdweb/react";
7
7
  import { createWallet } from "thirdweb/wallets";
8
+ const debug = debugB3React("LoginStepCustom");
8
9
  export function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
9
10
  const [isLoading, setIsLoading] = useState(false);
10
11
  const [showAllWallets, setShowAllWallets] = useState(false);
@@ -42,7 +43,7 @@ export function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategi
42
43
  connectResult = await connect(options);
43
44
  }
44
45
  const account = connectResult?.getAccount();
45
- console.log("@@gio:connectResult", { connectResult, account, options });
46
+ debug("@@connectResult", { connectResult, account, options });
46
47
  if (!account)
47
48
  throw new Error("Failed to connect");
48
49
  await onSuccess(account);
@@ -116,8 +116,7 @@ export function useAuthentication(partnerId, loginWithSiwe) {
116
116
  if (activeWallet) {
117
117
  debug("@@logout:activeWallet", activeWallet);
118
118
  disconnect(activeWallet);
119
- debug("@@logout:disconnected");
120
- console.log("@@gio:logout:activeWallet", activeWallet);
119
+ debug("@@logout:activeWallet", activeWallet);
121
120
  }
122
121
  // Log out of each wallet
123
122
  wallets.forEach(wallet => {
@@ -3,8 +3,8 @@ async function fetchSimBalance(address) {
3
3
  if (!address)
4
4
  throw new Error("Address is required");
5
5
  let url = `https://simdune-api.sean-430.workers.dev/?url=https://api.sim.dune.com/v1/evm/balances/${address}?metadata=logo&chain_ids=mainnet`;
6
- if (process.env.PUBLIC_LOCAL_KEY) {
7
- url += `&localkey=${process.env.PUBLIC_LOCAL_KEY}`;
6
+ if (process.env.NEXT_PUBLIC_LOCAL_KEY) {
7
+ url += `&localkey=${process.env.NEXT_PUBLIC_LOCAL_KEY}`;
8
8
  }
9
9
  const response = await fetch(url);
10
10
  if (!response.ok) {
@@ -6,10 +6,11 @@ import invariant from "invariant";
6
6
  import { useCallback, useState } from "react";
7
7
  import { toast } from "sonner";
8
8
  import { prepareTransaction, sendTransaction as twSendTransaction } from "thirdweb";
9
+ import { useActiveWallet } from "thirdweb/react";
10
+ import { isAddress } from "viem";
9
11
  import { useSwitchChain, useWalletClient } from "wagmi";
10
12
  import { useB3 } from "../components/index.js";
11
13
  import { useAccountWallet } from "./useAccountWallet.js";
12
- import { isAddress } from "viem";
13
14
  const partnerId = String(process.env.PUBLIC_THIRDWEB_PARTNER_ID ||
14
15
  process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID ||
15
16
  process.env.PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID ||
@@ -19,37 +20,43 @@ export function useUnifiedChainSwitchAndExecute() {
19
20
  const { data: walletClient } = useWalletClient();
20
21
  const { switchChainAsync } = useSwitchChain();
21
22
  const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = useState(false);
22
- const { isActiveSmartWallet, isActiveEOAWallet } = useAccountWallet();
23
+ const activeWallet = useActiveWallet();
24
+ const { isActiveSmartWallet, isActiveEOAWallet, connectedEOAWallet } = useAccountWallet();
23
25
  const { account: aaAccount } = useB3();
24
26
  // Handle EOA wallet chain switch and execute transaction
25
27
  const handleEOASwitchChainAndSendTransaction = useCallback(async (targetChainId, params) => {
26
- if (!walletClient) {
28
+ if (!connectedEOAWallet) {
27
29
  toast.error("Please connect your wallet");
28
30
  return;
29
31
  }
30
- const providerId = walletClient.chain.id;
31
- const onCorrectChain = providerId === targetChainId;
32
+ // Get target chain configuration once
33
+ const targetChain = supportedChains.find(chain => chain.id === targetChainId);
34
+ if (!targetChain) {
35
+ toast.error(`Chain ${targetChainId} is not supported`);
36
+ return;
37
+ }
38
+ const currentChainId = activeWallet?.getChain()?.id;
39
+ const onCorrectChain = currentChainId === targetChainId;
32
40
  // Helper function to execute the transaction
33
41
  const executeTransaction = async () => {
34
- const signer = walletClient.account;
42
+ const signer = activeWallet?.getAccount();
35
43
  if (!signer) {
36
44
  throw new Error("No account connected");
37
45
  }
38
- // Get the target chain configuration instead of using potentially stale walletClient.chain
39
- const targetChain = supportedChains.find(chain => chain.id === targetChainId);
40
- if (!targetChain) {
41
- throw new Error(`Chain ${targetChainId} is not supported`);
46
+ // Coinbase Smart Wallet specific chain switching (different behavior from other wallets)
47
+ const walletChain = connectedEOAWallet.getChain();
48
+ if (walletChain?.id !== targetChainId) {
49
+ activeWallet?.switchChain(getThirdwebChain(targetChainId));
42
50
  }
43
51
  invariant(isAddress(params.to), "params.to is not a valid address");
44
- const hash = await walletClient.sendTransaction({
45
- account: signer,
46
- chain: targetChain,
52
+ const result = await signer.sendTransaction({
53
+ chainId: targetChainId,
47
54
  to: params.to,
48
55
  data: params.data,
49
56
  value: params.value,
50
57
  });
51
- toast.success(`Transaction sent: ${hash.slice(0, 10)}...`);
52
- return hash;
58
+ toast.success(`Transaction sent: ${result.transactionHash.slice(0, 10)}...`);
59
+ return result.transactionHash;
53
60
  };
54
61
  try {
55
62
  setIsSwitchingOrExecuting(true);
@@ -57,11 +64,6 @@ export function useUnifiedChainSwitchAndExecute() {
57
64
  return await executeTransaction();
58
65
  }
59
66
  const switchingToastId = toast.info(`Switching to ${getChainName(targetChainId)}…`);
60
- const targetChain = supportedChains.find(chain => chain.id === targetChainId);
61
- if (!targetChain) {
62
- toast.error(`Chain ${targetChainId} is not supported`);
63
- return;
64
- }
65
67
  const blockExplorerUrl = targetChain.blockExplorers?.default.url;
66
68
  invariant(blockExplorerUrl, "Block explorer URL is required");
67
69
  const nativeCurrency = getNativeToken(targetChainId);
@@ -124,18 +126,21 @@ export function useUnifiedChainSwitchAndExecute() {
124
126
  });
125
127
  }
126
128
  catch (err) {
127
- console.error(err);
129
+ console.error("Create global-accounts-intents error", err);
128
130
  }
129
131
  toast.info("Sending transaction…");
132
+ const start = performance.now();
130
133
  const sendTxResponse = await twSendTransaction({
131
134
  account: aaAccount,
132
135
  transaction,
133
136
  });
137
+ const end = performance.now();
138
+ console.log("Time taken to send transaction", end - start);
134
139
  toast.success("Transaction sent successfully");
135
140
  return sendTxResponse.transactionHash;
136
141
  }
137
142
  catch (err) {
138
- console.error(err);
143
+ console.error("Send transaction error", err);
139
144
  toast.error(err?.message ?? "Transaction failed");
140
145
  return undefined;
141
146
  }