@b3dotfun/sdk 0.0.47 → 0.0.48-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.
Files changed (158) hide show
  1. package/README.md +225 -6
  2. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +5 -3
  3. package/dist/cjs/anyspend/types/chain.d.ts +2 -1
  4. package/dist/cjs/anyspend/utils/chain.js +4 -0
  5. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
  6. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +15 -64
  7. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
  8. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +26 -21
  9. package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +2 -0
  10. package/dist/cjs/global-account/react/components/B3Provider/types.js +2 -0
  11. package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
  12. package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
  13. package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
  14. package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +2 -2
  15. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +1 -1
  16. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
  17. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +6 -22
  18. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
  19. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +3 -2
  20. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
  21. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +10 -45
  22. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
  23. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -1
  24. package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +2 -1
  25. package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +51 -2
  26. package/dist/cjs/global-account/react/hooks/useAuthentication.js +141 -81
  27. package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
  28. package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -1
  29. package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +58 -0
  30. package/dist/cjs/global-account/react/hooks/useUserQuery.js +86 -0
  31. package/dist/cjs/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
  32. package/dist/cjs/global-account/react/hooks/useWagmiConfig.js +42 -0
  33. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -2
  34. package/dist/cjs/notifications/index.d.ts +3 -0
  35. package/dist/cjs/notifications/index.js +25 -0
  36. package/dist/cjs/notifications/react/hooks/index.d.ts +1 -0
  37. package/dist/cjs/notifications/react/hooks/index.js +17 -0
  38. package/dist/cjs/notifications/react/hooks/useNotifications.d.ts +42 -0
  39. package/dist/cjs/notifications/react/hooks/useNotifications.js +148 -0
  40. package/dist/cjs/notifications/react/index.d.ts +1 -0
  41. package/dist/cjs/notifications/react/index.js +17 -0
  42. package/dist/cjs/notifications/services/api.d.ts +67 -0
  43. package/dist/cjs/notifications/services/api.js +184 -0
  44. package/dist/cjs/notifications/services/index.d.ts +1 -0
  45. package/dist/cjs/notifications/services/index.js +17 -0
  46. package/dist/cjs/notifications/types/index.d.ts +51 -0
  47. package/dist/cjs/notifications/types/index.js +2 -0
  48. package/dist/cjs/shared/utils/auth-token.d.ts +7 -0
  49. package/dist/cjs/shared/utils/auth-token.js +17 -0
  50. package/dist/cjs/shared/utils/index.d.ts +1 -0
  51. package/dist/cjs/shared/utils/index.js +1 -0
  52. package/dist/esm/anyspend/react/components/AnySpendCustom.js +5 -3
  53. package/dist/esm/anyspend/types/chain.d.ts +2 -1
  54. package/dist/esm/anyspend/utils/chain.js +4 -0
  55. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
  56. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +19 -68
  57. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
  58. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +24 -19
  59. package/dist/esm/global-account/react/components/B3Provider/types.d.ts +2 -0
  60. package/dist/esm/global-account/react/components/B3Provider/types.js +2 -0
  61. package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
  62. package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
  63. package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
  64. package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
  65. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
  66. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
  67. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +7 -23
  68. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
  69. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +4 -3
  70. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
  71. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +11 -46
  72. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
  73. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
  74. package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +3 -2
  75. package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +51 -2
  76. package/dist/esm/global-account/react/hooks/useAuthentication.js +144 -84
  77. package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
  78. package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +3 -2
  79. package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +58 -0
  80. package/dist/esm/global-account/react/hooks/useUserQuery.js +83 -0
  81. package/dist/esm/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
  82. package/dist/esm/global-account/react/hooks/useWagmiConfig.js +39 -0
  83. package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -2
  84. package/dist/esm/notifications/index.d.ts +3 -0
  85. package/dist/esm/notifications/index.js +7 -0
  86. package/dist/esm/notifications/react/hooks/index.d.ts +1 -0
  87. package/dist/esm/notifications/react/hooks/index.js +1 -0
  88. package/dist/esm/notifications/react/hooks/useNotifications.d.ts +42 -0
  89. package/dist/esm/notifications/react/hooks/useNotifications.js +145 -0
  90. package/dist/esm/notifications/react/index.d.ts +1 -0
  91. package/dist/esm/notifications/react/index.js +1 -0
  92. package/dist/esm/notifications/services/api.d.ts +67 -0
  93. package/dist/esm/notifications/services/api.js +179 -0
  94. package/dist/esm/notifications/services/index.d.ts +1 -0
  95. package/dist/esm/notifications/services/index.js +1 -0
  96. package/dist/esm/notifications/types/index.d.ts +51 -0
  97. package/dist/esm/shared/utils/auth-token.d.ts +7 -0
  98. package/dist/esm/shared/utils/auth-token.js +11 -0
  99. package/dist/esm/shared/utils/index.d.ts +1 -0
  100. package/dist/esm/shared/utils/index.js +1 -0
  101. package/dist/types/anyspend/types/chain.d.ts +2 -1
  102. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
  103. package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
  104. package/dist/types/global-account/react/components/B3Provider/types.d.ts +2 -0
  105. package/dist/types/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
  106. package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
  107. package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
  108. package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
  109. package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
  110. package/dist/types/global-account/react/hooks/useAuthentication.d.ts +51 -2
  111. package/dist/types/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
  112. package/dist/types/global-account/react/hooks/useUserQuery.d.ts +58 -0
  113. package/dist/types/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
  114. package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -2
  115. package/dist/types/notifications/index.d.ts +3 -0
  116. package/dist/types/notifications/react/hooks/index.d.ts +1 -0
  117. package/dist/types/notifications/react/hooks/useNotifications.d.ts +42 -0
  118. package/dist/types/notifications/react/index.d.ts +1 -0
  119. package/dist/types/notifications/services/api.d.ts +67 -0
  120. package/dist/types/notifications/services/index.d.ts +1 -0
  121. package/dist/types/notifications/types/index.d.ts +51 -0
  122. package/dist/types/shared/utils/auth-token.d.ts +7 -0
  123. package/dist/types/shared/utils/index.d.ts +1 -0
  124. package/package.json +23 -3
  125. package/src/anyspend/react/components/AnySpendCustom.tsx +5 -3
  126. package/src/anyspend/types/chain.ts +2 -1
  127. package/src/anyspend/utils/chain.ts +4 -0
  128. package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +51 -35
  129. package/src/global-account/react/components/B3Provider/B3Provider.tsx +28 -72
  130. package/src/global-account/react/components/B3Provider/types.ts +4 -0
  131. package/src/global-account/react/components/ManageAccount/BalanceContent.tsx +2 -3
  132. package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +1 -1
  133. package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
  134. package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +2 -2
  135. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +4 -23
  136. package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +4 -3
  137. package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +8 -46
  138. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
  139. package/src/global-account/react/components/custom/ManageAccountButton.tsx +3 -2
  140. package/src/global-account/react/hooks/useAuthentication.ts +170 -89
  141. package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +3 -2
  142. package/src/global-account/react/hooks/useUserQuery.ts +95 -0
  143. package/src/global-account/react/hooks/useWagmiConfig.tsx +44 -0
  144. package/src/global-account/react/stores/useModalStore.ts +0 -2
  145. package/src/notifications/index.ts +9 -0
  146. package/src/notifications/react/hooks/index.ts +1 -0
  147. package/src/notifications/react/hooks/useNotifications.ts +153 -0
  148. package/src/notifications/react/index.ts +1 -0
  149. package/src/notifications/services/api.ts +217 -0
  150. package/src/notifications/services/index.ts +1 -0
  151. package/src/notifications/types/index.ts +58 -0
  152. package/src/shared/utils/auth-token.ts +13 -0
  153. package/src/shared/utils/index.ts +1 -0
  154. package/dist/cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.js +0 -245
  155. package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +0 -1
  156. package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.js +0 -243
  157. package/dist/types/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +0 -1
  158. /package/dist/{cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts → esm/notifications/types/index.js} +0 -0
@@ -17,14 +17,14 @@ function centerTruncate(str, length = 4) {
17
17
  return str;
18
18
  return `${str.slice(0, length)}...${str.slice(-length)}`;
19
19
  }
20
- export function BalanceContent({ onLogout, partnerId, showDeposit = true, showSwap = true }) {
20
+ export function BalanceContent({ onLogout, showDeposit = true, showSwap = true }) {
21
21
  const account = useActiveAccount();
22
22
  const { address: eoaAddress, info: eoaInfo } = useFirstEOA();
23
23
  const { data: profile } = useProfile({
24
24
  address: eoaAddress || account?.address,
25
25
  fresh: true,
26
26
  });
27
- const { user } = useB3();
27
+ const { user, partnerId } = useB3();
28
28
  const { setB3ModalOpen, setB3ModalContentType, navigateBack } = useModalStore();
29
29
  const { logout } = useAuthentication(partnerId);
30
30
  const [logoutLoading, setLogoutLoading] = useState(false);
@@ -196,5 +196,5 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
196
196
  if (["overview", "tokens", "nfts", "apps", "settings"].includes(tab)) {
197
197
  setActiveTab?.(tab);
198
198
  }
199
- }, children: [_jsx("div", { className: "px-4", children: _jsxs(TabsListPrimitive, { className: "grid h-auto grid-cols-2 grid-rows-2 gap-3 rounded-none border-none bg-transparent", children: [_jsxs(TabTriggerPrimitive, { value: "overview", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(BarChart3, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Overview" })] }), _jsxs(TabTriggerPrimitive, { value: "tokens", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Coins, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Tokens" })] }), _jsxs(TabTriggerPrimitive, { value: "nfts", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Image, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "NFTs" })] }), _jsxs(TabTriggerPrimitive, { value: "settings", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Settings, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Settings" })] })] }) }), _jsx(TabsContentPrimitive, { value: "overview", className: "px-4 pb-4 pt-2", children: _jsx(BalanceContent, { onLogout: onLogout, partnerId: partnerId, showDeposit: showDeposit, showSwap: showSwap }) }), _jsx(TabsContentPrimitive, { value: "tokens", className: "px-4 pb-4 pt-2", children: _jsx(ContentTokens, { activeTab: activeTab }) }), _jsx(TabsContentPrimitive, { value: "nfts", className: "px-4 pb-4 pt-2", children: _jsx("div", { className: "grid grid-cols-3 gap-4", children: nfts?.nftResponse ? (_jsx(AccountAssets, { nfts: nfts.nftResponse, isLoading: isLoading })) : (_jsx("div", { className: "col-span-3 py-12 text-center text-gray-500", children: "No NFTs found" })) }) }), _jsx(TabsContentPrimitive, { value: "apps", className: "px-4 pb-4 pt-2", children: _jsx(AppsContent, {}) }), _jsx(TabsContentPrimitive, { value: "settings", className: "px-4 pb-4 pt-2", children: _jsx(SettingsContent, {}) })] }) }) }));
199
+ }, children: [_jsx("div", { className: "px-4", children: _jsxs(TabsListPrimitive, { className: "grid h-auto grid-cols-2 grid-rows-2 gap-3 rounded-none border-none bg-transparent", children: [_jsxs(TabTriggerPrimitive, { value: "overview", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(BarChart3, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Overview" })] }), _jsxs(TabTriggerPrimitive, { value: "tokens", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Coins, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Tokens" })] }), _jsxs(TabTriggerPrimitive, { value: "nfts", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Image, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "NFTs" })] }), _jsxs(TabTriggerPrimitive, { value: "settings", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Settings, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Settings" })] })] }) }), _jsx(TabsContentPrimitive, { value: "overview", className: "px-4 pb-4 pt-2", children: _jsx(BalanceContent, { onLogout: onLogout, showDeposit: showDeposit, showSwap: showSwap }) }), _jsx(TabsContentPrimitive, { value: "tokens", className: "px-4 pb-4 pt-2", children: _jsx(ContentTokens, { activeTab: activeTab }) }), _jsx(TabsContentPrimitive, { value: "nfts", className: "px-4 pb-4 pt-2", children: _jsx("div", { className: "grid grid-cols-3 gap-4", children: nfts?.nftResponse ? (_jsx(AccountAssets, { nfts: nfts.nftResponse, isLoading: isLoading })) : (_jsx("div", { className: "col-span-3 py-12 text-center text-gray-500", children: "No NFTs found" })) }) }), _jsx(TabsContentPrimitive, { value: "apps", className: "px-4 pb-4 pt-2", children: _jsx(AppsContent, {}) }), _jsx(TabsContentPrimitive, { value: "settings", className: "px-4 pb-4 pt-2", children: _jsx(SettingsContent, {}) })] }) }) }));
200
200
  }
@@ -9,10 +9,10 @@ import { useConnectedWallets, useSetActiveWallet, useWalletInfo } from "thirdweb
9
9
  import { ManageAccountButton } from "../custom/ManageAccountButton.js";
10
10
  export function SignIn(props) {
11
11
  const { className } = props;
12
- const { automaticallySetFirstEoa } = useB3();
12
+ const { automaticallySetFirstEoa, partnerId } = useB3();
13
13
  const { wallet, address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon, eoaWalletIcon, } = useAccountWallet();
14
14
  const isMobile = useIsMobile();
15
- const { logout } = useAuthentication(String(process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID));
15
+ const { logout } = useAuthentication(partnerId);
16
16
  const onDisconnect = async () => {
17
17
  await logout();
18
18
  };
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Button, StyleRoot, useAuthentication, useB3, useIsMobile, useModalStore, } from "../../../../global-account/react/index.js";
2
+ import { Button, StyleRoot, useAuthStore, useB3, useIsMobile, useModalStore, } from "../../../../global-account/react/index.js";
3
3
  import { useEffect } from "react";
4
4
  import { ManageAccountButton } from "../custom/ManageAccountButton.js";
5
5
  import { Loading } from "../ui/Loading.js";
6
6
  export function SignInWithB3(props) {
7
7
  const { setB3ModalOpen, setB3ModalContentType, setEcoSystemAccountAddress } = useModalStore();
8
8
  const { account } = useB3();
9
- const { isAuthenticating, isAuthenticated } = useAuthentication(props.partnerId, props.loginWithSiwe);
9
+ const { isAuthenticating, isAuthenticated } = useAuthStore();
10
10
  const isMobile = useIsMobile();
11
11
  useEffect(() => {
12
12
  if (account) {
@@ -3,4 +3,4 @@ import { SignInWithB3ModalProps } from "../../../../global-account/react";
3
3
  * Component that manages the authentication flow for Sign In With B3
4
4
  * Handles different login providers, authentication steps, and session key management
5
5
  */
6
- export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, loginWithSiwe, source, signersEnabled, }: SignInWithB3ModalProps): import("react/jsx-runtime").JSX.Element | null;
6
+ export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, source, signersEnabled, }: SignInWithB3ModalProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Loading, useAuthStore, useB3, useGetAllTWSigners, useModalStore, useSiwe, } from "../../../../global-account/react/index.js";
2
+ import { Loading, useAuthStore, useB3, useGetAllTWSigners, useModalStore, } from "../../../../global-account/react/index.js";
3
3
  import { debugB3React } from "../../../../shared/utils/debug.js";
4
4
  import { useCallback, useEffect, useState } from "react";
5
5
  import { useActiveAccount } from "thirdweb/react";
@@ -12,16 +12,14 @@ const MAX_REFETCH_ATTEMPTS = 20;
12
12
  * Component that manages the authentication flow for Sign In With B3
13
13
  * Handles different login providers, authentication steps, and session key management
14
14
  */
15
- export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false, loginWithSiwe = false, source = "signInWithB3Button", signersEnabled = false, }) {
16
- const { setUser, automaticallySetFirstEoa } = useB3();
15
+ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false, source = "signInWithB3Button", signersEnabled = false, }) {
16
+ const { automaticallySetFirstEoa } = useB3();
17
17
  const [step, setStep] = useState(source === "requestPermissions" ? null : "login");
18
18
  const [sessionKeyAdded, setSessionKeyAdded] = useState(source === "requestPermissions" ? true : false);
19
19
  const { setB3ModalContentType, setB3ModalOpen, isOpen } = useModalStore();
20
20
  const account = useActiveAccount();
21
- const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
22
21
  const isAuthenticating = useAuthStore(state => state.isAuthenticating);
23
22
  const isConnected = useAuthStore(state => state.isConnected);
24
- const setIsConnected = useAuthStore(state => state.setIsConnected);
25
23
  const [refetchCount, setRefetchCount] = useState(0);
26
24
  const [refetchError, setRefetchError] = useState(null);
27
25
  const { data: signers, refetch: refetchSigners, isFetching: isFetchingSigners, } = useGetAllTWSigners({
@@ -31,7 +29,6 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
31
29
  enabled: signersEnabled,
32
30
  },
33
31
  });
34
- const { authenticate } = useSiwe();
35
32
  const [refetchQueued, setRefetchQueued] = useState(false);
36
33
  // Enhanced refetchSigners function that tracks number of attempts
37
34
  const handleRefetchSigners = useCallback(() => {
@@ -142,13 +139,11 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
142
139
  sessionKeyAddress,
143
140
  partnerId,
144
141
  closeAfterLogin,
145
- loginWithSiwe,
146
142
  source: "requestPermissions",
147
143
  });
148
144
  }, [
149
145
  chain,
150
146
  closeAfterLogin,
151
- loginWithSiwe,
152
147
  onError,
153
148
  onLoginSuccess,
154
149
  onSessionKeySuccess,
@@ -158,19 +153,8 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
158
153
  strategies,
159
154
  ]);
160
155
  const handleLoginSuccess = useCallback(async (account) => {
161
- debug("Authenticating with B3 via SIWE");
162
- setIsConnected(true);
163
- if (loginWithSiwe) {
164
- debug("setIsAuthenticating:true:1");
165
- setIsAuthenticating(true);
166
- const userAuth = await authenticate(account, partnerId);
167
- setUser(userAuth.user);
168
- }
169
- debug("handleLoginSuccess:account", account);
170
156
  onLoginSuccess?.(account);
171
- debug("setIsAuthenticating:false:1");
172
- setIsAuthenticating(false);
173
- }, [loginWithSiwe, onLoginSuccess, authenticate, partnerId, setUser, setIsConnected, setIsAuthenticating]);
157
+ }, [onLoginSuccess]);
174
158
  useEffect(() => {
175
159
  if (step === "permissions") {
176
160
  setB3ModalContentType({
@@ -192,14 +176,14 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
192
176
  if (step === "login") {
193
177
  // Custom strategy
194
178
  if (strategies?.[0] === "privy") {
195
- return _jsx(SignInWithB3Privy, { onSuccess: handleLoginSuccess, partnerId: partnerId, chain: chain });
179
+ return _jsx(SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
196
180
  }
197
181
  // Strategies are explicitly provided
198
182
  if (strategies) {
199
- return (_jsx(LoginStepCustom, { strategies: strategies, partnerId: partnerId, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
183
+ return (_jsx(LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
200
184
  }
201
185
  // Default to handle all strategies we support
202
- return _jsx(LoginStep, { partnerId: partnerId, chain: chain, onSuccess: handleLoginSuccess, onError: onError });
186
+ return _jsx(LoginStep, { chain: chain, onSuccess: handleLoginSuccess, onError: onError });
203
187
  }
204
188
  return null;
205
189
  }
@@ -4,8 +4,7 @@ interface SignInWithB3PrivyProps {
4
4
  onError?: (error: Error) => Promise<void>;
5
5
  onSuccess: (account: Account) => Promise<void>;
6
6
  accessToken?: string;
7
- partnerId: string;
8
7
  chain: Chain;
9
8
  }
10
- export declare function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }: SignInWithB3PrivyProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function SignInWithB3Privy({ onSuccess, onError, chain }: SignInWithB3PrivyProps): import("react/jsx-runtime").JSX.Element;
11
10
  export {};
@@ -1,10 +1,11 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Loading, useAuthentication, useAuthStore, useHandleConnectWithPrivy, } from "../../../../global-account/react/index.js";
2
+ import { Loading, useAuthentication, useAuthStore, useB3, useHandleConnectWithPrivy, } from "../../../../global-account/react/index.js";
3
3
  import { debugB3React } from "../../../../shared/utils/debug.js";
4
4
  import { useEffect } from "react";
5
5
  const debug = debugB3React("SignInWithB3Privy");
6
- export function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }) {
7
- const { isLoading, connectTw, fullToken } = useHandleConnectWithPrivy(partnerId, chain, onSuccess);
6
+ export function SignInWithB3Privy({ onSuccess, onError, chain }) {
7
+ const { partnerId } = useB3();
8
+ const { isLoading, connectTw, fullToken } = useHandleConnectWithPrivy(chain, onSuccess);
8
9
  const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
9
10
  const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
10
11
  const { logout } = useAuthentication(partnerId);
@@ -9,7 +9,6 @@ interface LoginStepProps {
9
9
  /** Optional callback function called when an error occurs */
10
10
  onError?: (error: Error) => Promise<void>;
11
11
  /** Partner ID used for authentication */
12
- partnerId: string;
13
12
  /** Blockchain chain information */
14
13
  chain: Chain;
15
14
  /** Optional authentication strategy options */
@@ -20,5 +19,5 @@ interface LoginStepContainerProps {
20
19
  partnerId?: string;
21
20
  }
22
21
  export declare function LoginStepContainer({ children, partnerId }: LoginStepContainerProps): import("react/jsx-runtime").JSX.Element;
23
- export declare function LoginStep({ onSuccess, onError, partnerId, chain }: LoginStepProps): import("react/jsx-runtime").JSX.Element;
22
+ export declare function LoginStep({ onSuccess, chain }: LoginStepProps): import("react/jsx-runtime").JSX.Element;
24
23
  export {};
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useAuthentication, useAuthStore, useB3, useQueryB3 } from "../../../../../global-account/react/index.js";
2
+ import { useAuthentication, useB3, useQueryB3 } from "../../../../../global-account/react/index.js";
3
3
  import { ecosystemWalletId } from "../../../../../shared/constants/index.js";
4
- import { debug } from "../../../../../shared/utils/debug.js";
5
4
  import { client } from "../../../../../shared/utils/thirdweb.js";
6
5
  import { ConnectEmbed, darkTheme, lightTheme } from "thirdweb/react";
7
6
  import { ecosystemWallet } from "thirdweb/wallets";
@@ -15,14 +14,12 @@ export function LoginStepContainer({ children, partnerId }) {
15
14
  const partnerLogo = partner?.data?.[0]?.loginCustomization?.logoUrl;
16
15
  return (_jsxs("div", { className: "flex flex-col items-center justify-center pt-6", children: [partnerLogo && (_jsx("img", { src: partnerLogo, alt: "Partner Logo", className: "partner-logo mb-6 h-12 w-auto object-contain" })), children, _jsxs("h2", { className: "mt-6 flex items-center gap-2 text-lg font-bold", children: ["Powered by", _jsx("img", { alt: "B3 Logo", className: "h-5", src: "https://cdn.b3.fun/b3_logo.svg" }), "Connect"] })] }));
17
16
  }
18
- export function LoginStep({ onSuccess, onError, partnerId, chain }) {
17
+ export function LoginStep({ onSuccess, chain }) {
18
+ const { partnerId, theme } = useB3();
19
19
  const wallet = ecosystemWallet(ecosystemWalletId, {
20
20
  partnerId: partnerId,
21
21
  });
22
- const { theme } = useB3();
23
- const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
24
- const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
25
- const { logout } = useAuthentication(partnerId);
22
+ const { onConnect } = useAuthentication(partnerId);
26
23
  return (_jsx(LoginStepContainer, { partnerId: partnerId, children: _jsx(ConnectEmbed, { showThirdwebBranding: false, client: client, chain: chain, wallets: [wallet], theme: theme === "light"
27
24
  ? lightTheme({
28
25
  colors: {
@@ -33,50 +30,18 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }) {
33
30
  colors: {
34
31
  modalBg: "hsl(var(--b3-react-background))",
35
32
  },
36
- }), autoConnect: true, style: {
33
+ }), style: {
37
34
  width: "100%",
38
35
  height: "100%",
39
36
  border: 0,
40
- },
41
- // TODO: Integrate with SIWE in useSIWE
42
- // auth={{
43
- // isLoggedIn: async (address) => {
44
- // console.log("checking if logged in!", { address });
45
- // return await isLoggedIn();
46
- // },
47
- // doLogin: async (params) => {
48
- // console.log("logging in!");
49
- // await login(params);
50
- // },
51
- // getLoginPayload: async ({ address }) =>
52
- // generatePayload({ address }),
53
- // doLogout: async () => {
54
- // console.log("logging out!");
55
- // await logout();
56
- // },
57
- // }}
58
- header: {
37
+ }, header: {
59
38
  title: "Sign in with B3",
60
39
  titleIcon: "https://cdn.b3.fun/b3_logo.svg",
61
40
  }, className: "b3-login-step", onConnect: async (wallet) => {
62
- try {
63
- setIsAuthenticating(true);
64
- debug("setIsAuthenticating:true:6");
65
- const account = wallet.getAccount();
66
- if (!account)
67
- throw new Error("No account found");
68
- await onSuccess(account);
69
- setIsAuthenticated(true);
70
- console.log("connected!", wallet.id);
71
- }
72
- catch (error) {
73
- await onError?.(error);
74
- await logout();
75
- setIsAuthenticated(false);
76
- }
77
- finally {
78
- debug("setIsAuthenticating:false:6");
79
- setIsAuthenticating(false);
80
- }
41
+ await onConnect(wallet);
42
+ const account = wallet.getAccount();
43
+ if (!account)
44
+ throw new Error("No account found");
45
+ await onSuccess(account);
81
46
  } }) }));
82
47
  }
@@ -5,10 +5,9 @@ interface LoginStepCustomProps {
5
5
  automaticallySetFirstEoa: boolean;
6
6
  onSuccess: (account: Account) => Promise<void>;
7
7
  onError?: (error: Error) => Promise<void>;
8
- partnerId: string;
9
8
  chain: Chain;
10
9
  strategies: AllowedStrategy[];
11
10
  maxInitialWallets?: number;
12
11
  }
13
- export declare function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, maxInitialWallets, automaticallySetFirstEoa, }: LoginStepCustomProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function LoginStepCustom({ onSuccess, onError, chain, strategies, maxInitialWallets, automaticallySetFirstEoa, }: LoginStepCustomProps): import("react/jsx-runtime").JSX.Element;
14
13
  export {};
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { AuthButton, Button, getConnectOptionsFromStrategy, isWalletType, LoginStepContainer, useAuthentication, useAuthStore, useConnect, WalletRow, } from "../../../../../global-account/react/index.js";
2
+ import { AuthButton, Button, getConnectOptionsFromStrategy, isWalletType, LoginStepContainer, useAuthentication, useAuthStore, useB3, useConnect, WalletRow, } from "../../../../../global-account/react/index.js";
3
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
8
  const debug = debugB3React("LoginStepCustom");
9
- export function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
9
+ export function LoginStepCustom({ onSuccess, onError, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
10
+ const { partnerId } = useB3();
10
11
  const [isLoading, setIsLoading] = useState(false);
11
12
  const [showAllWallets, setShowAllWallets] = useState(false);
12
13
  const { connect } = useConnect(partnerId, chain);
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button, StyleRoot, useAuthentication, useModalStore } from "../../../../global-account/react/index.js";
2
+ import { Button, StyleRoot, useAuthentication, useB3, useModalStore } from "../../../../global-account/react/index.js";
3
3
  import { cn } from "../../../../shared/utils/index.js";
4
4
  export function ManageAccountButton(props) {
5
+ const { partnerId } = useB3();
5
6
  const { setB3ModalOpen, setB3ModalContentType } = useModalStore();
6
- const { isConnected } = useAuthentication(props.partnerId, props.loginWithSiwe);
7
+ const { isConnected } = useAuthentication(partnerId);
7
8
  const handleClickManageAccount = () => {
8
9
  setB3ModalContentType({
9
10
  ...props,
@@ -1,5 +1,6 @@
1
+ import { Wallet } from "thirdweb/wallets";
1
2
  import { preAuthenticate } from "thirdweb/wallets/in-app";
2
- export declare function useAuthentication(partnerId: string, loginWithSiwe?: boolean): {
3
+ export declare function useAuthentication(partnerId: string): {
3
4
  logout: (callback?: () => void) => Promise<void>;
4
5
  isAuthenticated: boolean;
5
6
  isReady: boolean;
@@ -7,6 +8,54 @@ export declare function useAuthentication(partnerId: string, loginWithSiwe?: boo
7
8
  isConnected: boolean;
8
9
  wallet: import("thirdweb/dist/types/wallets/in-app/core/wallet/types").EcosystemWallet;
9
10
  preAuthenticate: typeof preAuthenticate;
10
- connect: (strategyOptions?: import("thirdweb/wallets").SingleStepAuthArgsType) => Promise<import("thirdweb/wallets").Wallet | null>;
11
+ connect: (wallet: Wallet) => Promise<void>;
11
12
  isAuthenticating: boolean;
13
+ onConnect: (wallet: Wallet) => Promise<void>;
14
+ user: {
15
+ email?: string | undefined;
16
+ username?: string | undefined;
17
+ telNumber?: string | undefined;
18
+ ens?: string | undefined;
19
+ avatar?: string | undefined;
20
+ preferences?: {} | undefined;
21
+ referredBy?: string | {} | undefined;
22
+ sourceApp?: string | undefined;
23
+ referralCode?: string | undefined;
24
+ userGroups?: number[] | undefined;
25
+ isMigratedFromBSMNT?: boolean | undefined;
26
+ privyLinkedAccounts?: {
27
+ name?: string | undefined;
28
+ address?: string | undefined;
29
+ email?: string | undefined;
30
+ chain_type?: string | undefined;
31
+ lv?: number | undefined;
32
+ wallet_client_type?: string | undefined;
33
+ smart_wallet_type?: string | undefined;
34
+ subject?: string | undefined;
35
+ type: string;
36
+ }[] | undefined;
37
+ twProfiles?: {
38
+ type: string;
39
+ details: {
40
+ id?: string | undefined;
41
+ name?: string | undefined;
42
+ address?: string | undefined;
43
+ email?: string | undefined;
44
+ phone?: string | undefined;
45
+ username?: string | undefined;
46
+ fid?: string | undefined;
47
+ };
48
+ }[] | undefined;
49
+ _id: string | {};
50
+ userId: string;
51
+ smartAccountAddress: string;
52
+ createdAt: number;
53
+ updatedAt: number;
54
+ partnerIds: {
55
+ privyId?: string | undefined;
56
+ thirdwebId?: string | undefined;
57
+ };
58
+ } | undefined;
59
+ refetchUser: (wallet?: Wallet) => Promise<void>;
60
+ setUser: (newUser?: import("@b3dotfun/b3-api").Users) => void;
12
61
  };