@b3dotfun/sdk 0.1.70-alpha.2 → 0.1.70-alpha.21
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/README.md +3 -3
- package/constants/chains/b3Chain.js +3 -1
- package/dist/cjs/anyspend/constants/rpc.d.ts +3 -1
- package/dist/cjs/anyspend/constants/rpc.js +6 -2
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +9 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +123 -46
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +8 -10
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +15 -3
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +78 -25
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +32 -13
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +32 -10
- package/dist/cjs/anyspend/react/components/QRDeposit.d.ts +22 -3
- package/dist/cjs/anyspend/react/components/QRDeposit.js +25 -16
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +18 -11
- package/dist/cjs/anyspend/react/components/common/PureTransferView.d.ts +30 -0
- package/dist/cjs/anyspend/react/components/common/PureTransferView.js +64 -0
- package/dist/cjs/anyspend/react/components/common/TokenBalance.js +4 -5
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +3 -3
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/cjs/anyspend/utils/address.d.ts +2 -1
- package/dist/cjs/anyspend/utils/address.js +12 -9
- package/dist/cjs/anyspend/utils/chain.d.ts +84 -1
- package/dist/cjs/anyspend/utils/chain.js +73 -3
- package/dist/cjs/anyspend/utils/token.d.ts +2 -0
- package/dist/cjs/anyspend/utils/token.js +15 -1
- package/dist/cjs/app.shared.d.ts +9 -1
- package/dist/cjs/app.shared.js +19 -0
- package/dist/cjs/global-account/app.native.d.ts +1 -1
- package/dist/cjs/global-account/better-auth-client.d.ts +3314 -36
- package/dist/cjs/global-account/better-auth-client.js +28 -3
- package/dist/cjs/global-account/bsmnt.d.ts +2 -2
- package/dist/cjs/global-account/bsmnt.native.d.ts +1 -1
- package/dist/cjs/global-account/client-manager.d.ts +7 -5
- package/dist/cjs/global-account/client-manager.js +51 -4
- package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +6 -11
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +11 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +12 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +12 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +25 -3
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.js +45 -4
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +11 -5
- package/dist/cjs/global-account/react/components/ManageAccount/ContentTokens.js +23 -15
- package/dist/cjs/global-account/react/components/ManageAccount/NFTContent.js +2 -2
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +8 -6
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/TokenContent.js +17 -8
- package/dist/cjs/global-account/react/components/Send/Send.js +15 -11
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +3 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +1 -5
- package/dist/cjs/global-account/react/components/SignInWithB3/components/AuthButton.js +2 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +1 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.js +3 -3
- package/dist/cjs/global-account/react/components/index.d.ts +1 -1
- package/dist/cjs/global-account/react/components/index.js +3 -3
- package/dist/cjs/global-account/react/hooks/index.d.ts +2 -3
- package/dist/cjs/global-account/react/hooks/index.js +7 -10
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +5 -4
- package/dist/cjs/global-account/react/hooks/useAuth.js +1 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +3 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +2 -1
- package/dist/cjs/global-account/react/hooks/useBetterAuth.d.ts +1657 -22
- package/dist/cjs/global-account/react/hooks/useBetterAuth.js +7 -7
- package/dist/cjs/global-account/react/hooks/useClient.d.ts +3 -3
- package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +4 -7666
- package/dist/cjs/global-account/react/hooks/useFirstEOA.js +1 -0
- package/dist/cjs/global-account/react/hooks/useNativeBalance.js +2 -2
- package/dist/cjs/global-account/react/hooks/usePortfolioBalance.d.ts +15 -0
- package/dist/cjs/global-account/react/hooks/usePortfolioBalance.js +76 -0
- package/dist/cjs/global-account/react/hooks/usePortfolioCollectibles.d.ts +12 -0
- package/dist/cjs/global-account/react/hooks/usePortfolioCollectibles.js +178 -0
- package/dist/cjs/global-account/react/hooks/useSiwe.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useSiwe.native.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useTWAuth.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +37 -27
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +14 -2
- package/dist/cjs/global-account/types/b3-api.types.d.ts +5 -0
- package/dist/cjs/global-account/types/feature-flags.d.ts +5 -5
- package/dist/cjs/notifications/services/api.js +1 -0
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +30 -54
- package/dist/cjs/shared/constants/chains/b3Chain.js +5 -41
- package/dist/cjs/shared/constants/chains/supported.d.ts +1 -49
- package/dist/cjs/shared/constants/chains/supported.js +8 -36
- package/dist/cjs/shared/constants/index.d.ts +4 -0
- package/dist/cjs/shared/utils/chain-transformers.d.ts +4 -4
- package/dist/cjs/shared/utils/chain-transformers.js +38 -37
- package/dist/cjs/shared/utils/thirdweb-insights.js +2 -2
- package/dist/cjs/shared/utils/upload.d.ts +9 -0
- package/dist/cjs/shared/utils/upload.js +34 -0
- package/dist/cjs/shared/utils/zerionPositions.d.ts +96 -0
- package/dist/cjs/shared/utils/zerionPositions.js +188 -0
- package/dist/esm/anyspend/constants/rpc.d.ts +3 -1
- package/dist/esm/anyspend/constants/rpc.js +5 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +9 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +124 -47
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +9 -11
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +15 -3
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +80 -27
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +33 -14
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +33 -11
- package/dist/esm/anyspend/react/components/QRDeposit.d.ts +22 -3
- package/dist/esm/anyspend/react/components/QRDeposit.js +27 -18
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +21 -14
- package/dist/esm/anyspend/react/components/common/PureTransferView.d.ts +30 -0
- package/dist/esm/anyspend/react/components/common/PureTransferView.js +61 -0
- package/dist/esm/anyspend/react/components/common/TokenBalance.js +6 -7
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +3 -3
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/esm/anyspend/utils/address.d.ts +2 -1
- package/dist/esm/anyspend/utils/address.js +9 -6
- package/dist/esm/anyspend/utils/chain.d.ts +84 -1
- package/dist/esm/anyspend/utils/chain.js +73 -5
- package/dist/esm/anyspend/utils/token.d.ts +2 -0
- package/dist/esm/anyspend/utils/token.js +13 -0
- package/dist/esm/app.shared.d.ts +9 -1
- package/dist/esm/app.shared.js +17 -0
- package/dist/esm/global-account/app.native.d.ts +1 -1
- package/dist/esm/global-account/better-auth-client.d.ts +3314 -36
- package/dist/esm/global-account/better-auth-client.js +27 -4
- package/dist/esm/global-account/bsmnt.d.ts +2 -2
- package/dist/esm/global-account/bsmnt.native.d.ts +1 -1
- package/dist/esm/global-account/client-manager.d.ts +7 -5
- package/dist/esm/global-account/client-manager.js +51 -5
- package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +6 -11
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +11 -0
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +11 -0
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +12 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +26 -4
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.js +46 -5
- package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
- package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +11 -5
- package/dist/esm/global-account/react/components/ManageAccount/ContentTokens.js +24 -16
- package/dist/esm/global-account/react/components/ManageAccount/NFTContent.js +3 -3
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +9 -7
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +1 -1
- package/dist/esm/global-account/react/components/ManageAccount/TokenContent.js +18 -9
- package/dist/esm/global-account/react/components/Send/Send.js +16 -12
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +3 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +1 -5
- package/dist/esm/global-account/react/components/SignInWithB3/components/AuthButton.js +2 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +1 -0
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.js +3 -3
- package/dist/esm/global-account/react/components/index.d.ts +1 -1
- package/dist/esm/global-account/react/components/index.js +1 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +2 -3
- package/dist/esm/global-account/react/hooks/index.js +2 -3
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +5 -4
- package/dist/esm/global-account/react/hooks/useAuth.js +1 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +3 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +2 -1
- package/dist/esm/global-account/react/hooks/useBetterAuth.d.ts +1657 -22
- package/dist/esm/global-account/react/hooks/useBetterAuth.js +8 -8
- package/dist/esm/global-account/react/hooks/useClient.d.ts +3 -3
- package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +4 -7666
- package/dist/esm/global-account/react/hooks/useFirstEOA.js +1 -0
- package/dist/esm/global-account/react/hooks/useNativeBalance.js +1 -1
- package/dist/esm/global-account/react/hooks/usePortfolioBalance.d.ts +15 -0
- package/dist/esm/global-account/react/hooks/usePortfolioBalance.js +72 -0
- package/dist/esm/global-account/react/hooks/usePortfolioCollectibles.d.ts +12 -0
- package/dist/esm/global-account/react/hooks/usePortfolioCollectibles.js +175 -0
- package/dist/esm/global-account/react/hooks/useSiwe.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useSiwe.native.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useTWAuth.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +37 -27
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +14 -2
- package/dist/esm/global-account/types/b3-api.types.d.ts +5 -0
- package/dist/esm/global-account/types/feature-flags.d.ts +5 -5
- package/dist/esm/notifications/services/api.js +1 -0
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +30 -54
- package/dist/esm/shared/constants/chains/b3Chain.js +4 -38
- package/dist/esm/shared/constants/chains/supported.d.ts +1 -49
- package/dist/esm/shared/constants/chains/supported.js +7 -35
- package/dist/esm/shared/constants/index.d.ts +4 -0
- package/dist/esm/shared/utils/chain-transformers.d.ts +4 -4
- package/dist/esm/shared/utils/chain-transformers.js +38 -37
- package/dist/esm/shared/utils/thirdweb-insights.js +2 -2
- package/dist/esm/shared/utils/upload.d.ts +9 -0
- package/dist/esm/shared/utils/upload.js +31 -0
- package/dist/esm/shared/utils/zerionPositions.d.ts +96 -0
- package/dist/esm/shared/utils/zerionPositions.js +180 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/rpc.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +9 -1
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +15 -3
- package/dist/types/anyspend/react/components/QRDeposit.d.ts +22 -3
- package/dist/types/anyspend/react/components/common/PureTransferView.d.ts +30 -0
- package/dist/types/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +3 -3
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/types/anyspend/utils/address.d.ts +2 -1
- package/dist/types/anyspend/utils/chain.d.ts +84 -1
- package/dist/types/anyspend/utils/token.d.ts +2 -0
- package/dist/types/app.shared.d.ts +9 -1
- package/dist/types/global-account/app.native.d.ts +1 -1
- package/dist/types/global-account/better-auth-client.d.ts +3314 -36
- package/dist/types/global-account/bsmnt.d.ts +2 -2
- package/dist/types/global-account/bsmnt.native.d.ts +1 -1
- package/dist/types/global-account/client-manager.d.ts +7 -5
- package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +11 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +12 -2
- package/dist/types/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
- package/dist/types/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +3 -2
- package/dist/types/global-account/react/components/index.d.ts +1 -1
- package/dist/types/global-account/react/hooks/index.d.ts +2 -3
- package/dist/types/global-account/react/hooks/useAuth.d.ts +5 -4
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +3 -2
- package/dist/types/global-account/react/hooks/useBetterAuth.d.ts +1657 -22
- package/dist/types/global-account/react/hooks/useClient.d.ts +3 -3
- package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +4 -7666
- package/dist/types/global-account/react/hooks/usePortfolioBalance.d.ts +15 -0
- package/dist/types/global-account/react/hooks/usePortfolioCollectibles.d.ts +12 -0
- package/dist/types/global-account/react/hooks/useSiwe.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useSiwe.native.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useTWAuth.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +14 -2
- package/dist/types/global-account/types/b3-api.types.d.ts +5 -0
- package/dist/types/global-account/types/feature-flags.d.ts +5 -5
- package/dist/types/shared/constants/chains/b3Chain.d.ts +30 -54
- package/dist/types/shared/constants/chains/supported.d.ts +1 -49
- package/dist/types/shared/constants/index.d.ts +4 -0
- package/dist/types/shared/utils/chain-transformers.d.ts +4 -4
- package/dist/types/shared/utils/upload.d.ts +9 -0
- package/dist/types/shared/utils/zerionPositions.d.ts +96 -0
- package/node_modules/@b3/chain-registry/chains.json +1225 -0
- package/node_modules/@b3/chain-registry/dist/chains.json +1225 -0
- package/node_modules/@b3/chain-registry/dist/index.cjs +1676 -0
- package/node_modules/@b3/chain-registry/dist/index.d.cts +195 -0
- package/node_modules/@b3/chain-registry/dist/index.d.ts +195 -0
- package/node_modules/@b3/chain-registry/dist/index.mjs +1604 -0
- package/node_modules/@b3/chain-registry/dist/src/index.d.ts +193 -0
- package/node_modules/@b3/chain-registry/dist/src/index.js +408 -0
- package/node_modules/@b3/chain-registry/package.json +66 -0
- package/node_modules/@b3/chain-registry/src/index.test.ts +432 -0
- package/node_modules/@b3/chain-registry/src/index.ts +672 -0
- package/package.json +81 -30
- package/src/anyspend/README.md +2 -2
- package/src/anyspend/constants/rpc.ts +5 -2
- package/src/anyspend/docs/components.md +6 -6
- package/src/anyspend/docs/contributing.md +1 -1
- package/src/anyspend/docs/hooks.md +3 -3
- package/src/anyspend/docs/installation.md +2 -2
- package/src/anyspend/react/components/AnySpend.tsx +163 -47
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +10 -11
- package/src/anyspend/react/components/AnySpendDeposit.tsx +130 -31
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +55 -14
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +55 -11
- package/src/anyspend/react/components/QRDeposit.tsx +101 -22
- package/src/anyspend/react/components/__tests__/QRDeposit.test.tsx +331 -0
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +38 -16
- package/src/anyspend/react/components/common/PureTransferView.tsx +212 -0
- package/src/anyspend/react/components/common/TokenBalance.tsx +10 -7
- package/src/anyspend/react/hooks/useAnyspendQuote.ts +13 -13
- package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +4 -4
- package/src/anyspend/services/gas.test.ts +95 -18
- package/src/anyspend/types/api_req_res.ts +10 -5
- package/src/anyspend/utils/__tests__/address.test.ts +39 -0
- package/src/anyspend/utils/__tests__/deprecatedChains.test.ts +44 -0
- package/src/anyspend/utils/__tests__/toRegistryChainId.test.ts +17 -0
- package/src/anyspend/utils/address.ts +8 -6
- package/src/anyspend/utils/chain.ts +79 -3
- package/src/anyspend/utils/token.ts +14 -0
- package/src/app.shared.ts +21 -1
- package/src/global-account/app.native.ts +5 -1
- package/src/global-account/better-auth-client.ts +30 -4
- package/src/global-account/bsmnt.native.ts +5 -1
- package/src/global-account/bsmnt.ts +9 -2
- package/src/global-account/client-manager.ts +74 -9
- package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +6 -11
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +12 -0
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +40 -4
- package/src/global-account/react/components/B3Provider/BetterAuthProvider.tsx +51 -5
- package/src/global-account/react/components/B3Provider/RelayKitProviderWrapper.tsx +11 -11
- package/src/global-account/react/components/ManageAccount/ContentTokens.tsx +50 -21
- package/src/global-account/react/components/ManageAccount/NFTContent.tsx +5 -3
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +10 -6
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +1 -1
- package/src/global-account/react/components/ManageAccount/TokenContent.tsx +22 -9
- package/src/global-account/react/components/Send/Send.tsx +39 -15
- package/src/global-account/react/components/SignInWithB3/BetterAuthSignIn.tsx +12 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +1 -4
- package/src/global-account/react/components/SignInWithB3/components/AuthButton.tsx +9 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.tsx +1 -0
- package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +4 -4
- package/src/global-account/react/components/index.ts +1 -1
- package/src/global-account/react/components/ui/button.tsx +1 -2
- package/src/global-account/react/hooks/__tests__/useUnifiedChainSwitchAndExecute.test.tsx +156 -0
- package/src/global-account/react/hooks/index.ts +2 -3
- package/src/global-account/react/hooks/useAuth.ts +5 -4
- package/src/global-account/react/hooks/useAuthentication.ts +5 -4
- package/src/global-account/react/hooks/useBetterAuth.ts +10 -10
- package/src/global-account/react/hooks/useClient.ts +11 -2
- package/src/global-account/react/hooks/useFirstEOA.tsx +9 -2
- package/src/global-account/react/hooks/useNativeBalance.tsx +1 -1
- package/src/global-account/react/hooks/usePortfolioBalance.ts +89 -0
- package/src/global-account/react/hooks/usePortfolioCollectibles.ts +212 -0
- package/src/global-account/react/hooks/useSiwe.native.tsx +1 -1
- package/src/global-account/react/hooks/useSiwe.tsx +1 -1
- package/src/global-account/react/hooks/useTWAuth.tsx +1 -1
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +47 -31
- package/src/global-account/react/stores/useModalStore.ts +14 -2
- package/src/global-account/types/b3-api.types.ts +5 -1
- package/src/notifications/services/api.ts +1 -0
- package/src/shared/constants/chains/b3Chain.ts +4 -43
- package/src/shared/constants/chains/supported.ts +9 -48
- package/src/shared/constants/index.ts +8 -0
- package/src/shared/react/hooks/__tests__/useCurrencyConversion.test.ts +54 -43
- package/src/shared/utils/__tests__/zerionPositions.test.ts +248 -0
- package/src/shared/utils/chain-transformers.ts +41 -39
- package/src/shared/utils/thirdweb-insights.ts +2 -2
- package/src/shared/utils/upload.ts +48 -0
- package/src/shared/utils/zerionPositions.ts +247 -0
- package/src/styles/index.css +27 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +0 -46
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +0 -70
- package/dist/cjs/global-account/react/hooks/useSimBalance.d.ts +0 -59
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +0 -98
- package/dist/cjs/global-account/react/hooks/useSimCollectibles.d.ts +0 -45
- package/dist/cjs/global-account/react/hooks/useSimCollectibles.js +0 -190
- package/dist/cjs/global-account/react/utils/simdune.d.ts +0 -7
- package/dist/cjs/global-account/react/utils/simdune.js +0 -21
- package/dist/cjs/global-account/types/chain-networks.d.ts +0 -44
- package/dist/cjs/global-account/types/chain-networks.js +0 -48
- package/dist/cjs/shared/generated/chain-networks.json +0 -684
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +0 -43
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +0 -67
- package/dist/esm/global-account/react/hooks/useSimBalance.d.ts +0 -59
- package/dist/esm/global-account/react/hooks/useSimBalance.js +0 -93
- package/dist/esm/global-account/react/hooks/useSimCollectibles.d.ts +0 -45
- package/dist/esm/global-account/react/hooks/useSimCollectibles.js +0 -187
- package/dist/esm/global-account/react/utils/simdune.d.ts +0 -7
- package/dist/esm/global-account/react/utils/simdune.js +0 -17
- package/dist/esm/global-account/types/chain-networks.d.ts +0 -44
- package/dist/esm/global-account/types/chain-networks.js +0 -45
- package/dist/esm/shared/generated/chain-networks.json +0 -684
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +0 -10
- package/dist/types/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +0 -11
- package/dist/types/global-account/react/hooks/useSimBalance.d.ts +0 -59
- package/dist/types/global-account/react/hooks/useSimCollectibles.d.ts +0 -45
- package/dist/types/global-account/react/utils/simdune.d.ts +0 -7
- package/dist/types/global-account/types/chain-networks.d.ts +0 -44
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +0 -63
- package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +0 -79
- package/src/global-account/react/hooks/useSimBalance.ts +0 -164
- package/src/global-account/react/hooks/useSimCollectibles.ts +0 -238
- package/src/global-account/react/utils/simdune.ts +0 -20
- package/src/global-account/types/chain-networks.ts +0 -54
- package/src/shared/generated/chain-networks.json +0 -684
|
@@ -7,6 +7,7 @@ export { RelayKitProviderWrapper } from "./B3Provider/RelayKitProviderWrapper";
|
|
|
7
7
|
export { useB3 } from "./B3Provider/useB3";
|
|
8
8
|
export { useB3Account } from "./B3Provider/useB3Account";
|
|
9
9
|
export { useB3Config } from "./B3Provider/useB3Config";
|
|
10
|
+
export { B3ConfigPartnerOverride } from "./B3Provider/B3ConfigProvider";
|
|
10
11
|
export { StyleRoot } from "./StyleRoot";
|
|
11
12
|
|
|
12
13
|
// SignInWithB3 Components
|
|
@@ -22,7 +23,6 @@ export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
|
|
|
22
23
|
export { WalletRow } from "./SignInWithB3/components/WalletRow";
|
|
23
24
|
export { SignInWithB3 } from "./SignInWithB3/SignInWithB3";
|
|
24
25
|
export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
25
|
-
export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy";
|
|
26
26
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep";
|
|
27
27
|
export { getConnectOptionsFromStrategy, isWalletType, type AllowedStrategy } from "./SignInWithB3/utils/signInUtils";
|
|
28
28
|
|
|
@@ -32,8 +32,7 @@ const buttonVariants = cva(
|
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
export interface ButtonProps
|
|
35
|
-
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
36
|
-
VariantProps<typeof buttonVariants> {
|
|
35
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
37
36
|
asChild?: boolean;
|
|
38
37
|
}
|
|
39
38
|
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { act, renderHook } from "@testing-library/react";
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { useUnifiedChainSwitchAndExecute } from "../useUnifiedChainSwitchAndExecute";
|
|
4
|
+
|
|
5
|
+
const mocks = vi.hoisted(() => ({
|
|
6
|
+
eoaGetAccount: vi.fn(),
|
|
7
|
+
globalAccountGetAccount: vi.fn(),
|
|
8
|
+
intentCreate: vi.fn(),
|
|
9
|
+
prepareTransaction: vi.fn(),
|
|
10
|
+
sendTransaction: vi.fn(),
|
|
11
|
+
toastError: vi.fn(),
|
|
12
|
+
toastInfo: vi.fn(),
|
|
13
|
+
toastSuccess: vi.fn(),
|
|
14
|
+
useAccountWallet: vi.fn(),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
vi.mock("@b3dotfun/sdk/anyspend", () => ({
|
|
18
|
+
getChainName: (chainId: number) => `Chain ${chainId}`,
|
|
19
|
+
getNativeToken: () => ({ name: "Ether", symbol: "ETH", decimals: 18 }),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
vi.mock("@b3dotfun/sdk/global-account/app", () => ({
|
|
23
|
+
default: {
|
|
24
|
+
service: () => ({ create: mocks.intentCreate }),
|
|
25
|
+
},
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
vi.mock("@b3dotfun/sdk/global-account/react", () => ({
|
|
29
|
+
toast: {
|
|
30
|
+
dismiss: vi.fn(),
|
|
31
|
+
error: mocks.toastError,
|
|
32
|
+
info: mocks.toastInfo,
|
|
33
|
+
success: mocks.toastSuccess,
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
vi.mock("@b3dotfun/sdk/shared/constants/chains/supported", () => ({
|
|
38
|
+
getThirdwebChain: (chainId: number) => ({ id: chainId }),
|
|
39
|
+
supportedChains: [],
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
vi.mock("@b3dotfun/sdk/shared/utils/thirdweb", () => ({ client: {} }));
|
|
43
|
+
|
|
44
|
+
vi.mock("thirdweb", () => ({
|
|
45
|
+
prepareTransaction: mocks.prepareTransaction,
|
|
46
|
+
sendTransaction: mocks.sendTransaction,
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
vi.mock("viem", () => ({ isAddress: () => true }));
|
|
50
|
+
|
|
51
|
+
vi.mock("wagmi", () => ({
|
|
52
|
+
useSwitchChain: () => ({ switchChainAsync: vi.fn() }),
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
vi.mock("../../components/B3Provider/B3ConfigProvider", () => ({
|
|
56
|
+
useB3Config: () => ({ partnerId: "test-partner" }),
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
vi.mock("../useAccountWallet", () => ({
|
|
60
|
+
useAccountWallet: mocks.useAccountWallet,
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
const GLOBAL_ACCOUNT_ADDRESS = "0x1111111111111111111111111111111111111111";
|
|
64
|
+
const OTHER_GLOBAL_ACCOUNT_ADDRESS = "0x2222222222222222222222222222222222222222";
|
|
65
|
+
const EOA_ADDRESS = "0x3333333333333333333333333333333333333333";
|
|
66
|
+
const TRANSACTION_HASH = `0x${"a".repeat(64)}`;
|
|
67
|
+
|
|
68
|
+
const globalAccount = { address: GLOBAL_ACCOUNT_ADDRESS };
|
|
69
|
+
const preparedTransaction = { prepared: true };
|
|
70
|
+
const transactionParams = {
|
|
71
|
+
to: "0x4444444444444444444444444444444444444444",
|
|
72
|
+
data: "0x1234",
|
|
73
|
+
value: BigInt(0),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
describe("useUnifiedChainSwitchAndExecute", () => {
|
|
77
|
+
beforeEach(() => {
|
|
78
|
+
vi.clearAllMocks();
|
|
79
|
+
|
|
80
|
+
mocks.globalAccountGetAccount.mockReturnValue(globalAccount);
|
|
81
|
+
mocks.eoaGetAccount.mockReturnValue({ address: EOA_ADDRESS });
|
|
82
|
+
mocks.intentCreate.mockResolvedValue({});
|
|
83
|
+
mocks.prepareTransaction.mockReturnValue(preparedTransaction);
|
|
84
|
+
mocks.sendTransaction.mockResolvedValue({ transactionHash: TRANSACTION_HASH });
|
|
85
|
+
mocks.useAccountWallet.mockReturnValue({
|
|
86
|
+
connectedSmartWallet: { getAccount: mocks.globalAccountGetAccount },
|
|
87
|
+
connectedEOAWallet: { getAccount: mocks.eoaGetAccount },
|
|
88
|
+
isActiveSmartWallet: false,
|
|
89
|
+
isActiveEOAWallet: true,
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("uses the connected Global Account even when the EOA wallet is active", async () => {
|
|
94
|
+
const { result } = renderHook(() => useUnifiedChainSwitchAndExecute());
|
|
95
|
+
|
|
96
|
+
let transactionHash: string | undefined;
|
|
97
|
+
await act(async () => {
|
|
98
|
+
transactionHash = await result.current.switchChainAndExecuteWithGlobalAccount(
|
|
99
|
+
8453,
|
|
100
|
+
transactionParams,
|
|
101
|
+
GLOBAL_ACCOUNT_ADDRESS,
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
expect(transactionHash).toBe(TRANSACTION_HASH);
|
|
106
|
+
expect(mocks.globalAccountGetAccount).toHaveBeenCalledOnce();
|
|
107
|
+
expect(mocks.eoaGetAccount).not.toHaveBeenCalled();
|
|
108
|
+
expect(mocks.sendTransaction).toHaveBeenCalledWith({
|
|
109
|
+
account: globalAccount,
|
|
110
|
+
transaction: preparedTransaction,
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("rejects a signer that does not match the authenticated Global Account", async () => {
|
|
115
|
+
const { result } = renderHook(() => useUnifiedChainSwitchAndExecute());
|
|
116
|
+
|
|
117
|
+
let transactionHash: string | undefined;
|
|
118
|
+
await act(async () => {
|
|
119
|
+
transactionHash = await result.current.switchChainAndExecuteWithGlobalAccount(
|
|
120
|
+
8453,
|
|
121
|
+
transactionParams,
|
|
122
|
+
OTHER_GLOBAL_ACCOUNT_ADDRESS,
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
expect(transactionHash).toBeUndefined();
|
|
127
|
+
expect(mocks.toastError).toHaveBeenCalledWith("Connected Global Account does not match the authenticated account");
|
|
128
|
+
expect(mocks.prepareTransaction).not.toHaveBeenCalled();
|
|
129
|
+
expect(mocks.sendTransaction).not.toHaveBeenCalled();
|
|
130
|
+
expect(mocks.eoaGetAccount).not.toHaveBeenCalled();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("fails closed when no Global Account signer is connected", async () => {
|
|
134
|
+
mocks.useAccountWallet.mockReturnValue({
|
|
135
|
+
connectedSmartWallet: undefined,
|
|
136
|
+
connectedEOAWallet: { getAccount: mocks.eoaGetAccount },
|
|
137
|
+
isActiveSmartWallet: false,
|
|
138
|
+
isActiveEOAWallet: true,
|
|
139
|
+
});
|
|
140
|
+
const { result } = renderHook(() => useUnifiedChainSwitchAndExecute());
|
|
141
|
+
|
|
142
|
+
let transactionHash: string | undefined;
|
|
143
|
+
await act(async () => {
|
|
144
|
+
transactionHash = await result.current.switchChainAndExecuteWithGlobalAccount(
|
|
145
|
+
8453,
|
|
146
|
+
transactionParams,
|
|
147
|
+
GLOBAL_ACCOUNT_ADDRESS,
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
expect(transactionHash).toBeUndefined();
|
|
152
|
+
expect(mocks.toastError).toHaveBeenCalledWith("Global Account not connected");
|
|
153
|
+
expect(mocks.sendTransaction).not.toHaveBeenCalled();
|
|
154
|
+
expect(mocks.eoaGetAccount).not.toHaveBeenCalled();
|
|
155
|
+
});
|
|
156
|
+
});
|
|
@@ -17,7 +17,6 @@ export { useFirstEOA } from "./useFirstEOA";
|
|
|
17
17
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
18
18
|
export { useGetGeo } from "./useGetGeo";
|
|
19
19
|
export { useGlobalAccount } from "./useGlobalAccount";
|
|
20
|
-
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
|
|
21
20
|
export { useHasMounted } from "./useHasMounted";
|
|
22
21
|
export { useIsMobile } from "./useIsMobile";
|
|
23
22
|
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
|
@@ -40,8 +39,8 @@ export { useQueryBSMNT } from "./useQueryBSMNT";
|
|
|
40
39
|
export { useRemoveSessionKey } from "./useRemoveSessionKey";
|
|
41
40
|
export { useRouter } from "./useRouter";
|
|
42
41
|
export { useSearchParamsSSR } from "./useSearchParamsSSR";
|
|
43
|
-
export {
|
|
44
|
-
export {
|
|
42
|
+
export { usePortfolioBalance, usePortfolioTokenBalance } from "./usePortfolioBalance";
|
|
43
|
+
export { usePortfolioCollectibles } from "./usePortfolioCollectibles";
|
|
45
44
|
export { useSiwe } from "./useSiwe";
|
|
46
45
|
export { useTokenBalance } from "./useTokenBalance";
|
|
47
46
|
export { useTokenBalanceDirect } from "./useTokenBalanceDirect";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import app from "@b3dotfun/sdk/global-account/app";
|
|
2
2
|
import { authenticateWithB3JWT } from "@b3dotfun/sdk/global-account/bsmnt";
|
|
3
3
|
import { useAuthStore, useB3Config } from "@b3dotfun/sdk/global-account/react";
|
|
4
|
-
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
4
|
+
import { ecosystemWalletId, type EcosystemWallet } from "@b3dotfun/sdk/shared/constants";
|
|
5
5
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
6
6
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
7
7
|
import { ConnectionOptions } from "@thirdweb-dev/wagmi-adapter";
|
|
@@ -54,7 +54,8 @@ export function useAuth() {
|
|
|
54
54
|
const { user, setUser } = useUserQuery();
|
|
55
55
|
debug("@@activeWagmiAccount", activeWagmiAccount);
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
// Explicit annotation keeps the hook's declaration portable (TS2742).
|
|
58
|
+
const wallet: EcosystemWallet = ecosystemWallet(ecosystemWalletId, {
|
|
58
59
|
partnerId: partnerId,
|
|
59
60
|
});
|
|
60
61
|
|
|
@@ -62,7 +63,7 @@ export function useAuth() {
|
|
|
62
63
|
* Re-authenticate using existing session
|
|
63
64
|
* Also updates user state and authenticates with BSMNT
|
|
64
65
|
*/
|
|
65
|
-
const reAuthenticate = useCallback(async () => {
|
|
66
|
+
const reAuthenticate = useCallback(async (): Promise<Record<string, any>> => {
|
|
66
67
|
debug("Re-authenticating...");
|
|
67
68
|
try {
|
|
68
69
|
const response = await app.reAuthenticate();
|
|
@@ -191,7 +192,7 @@ export function useAuth() {
|
|
|
191
192
|
* 3. Authenticates with BSMNT for basement integration
|
|
192
193
|
*/
|
|
193
194
|
const authenticate = useCallback(
|
|
194
|
-
async (accessToken: string, partnerId: string, strategy = "thirdweb-jwt") => {
|
|
195
|
+
async (accessToken: string, partnerId: string, strategy = "thirdweb-jwt"): Promise<Record<string, any>> => {
|
|
195
196
|
if (!accessToken) {
|
|
196
197
|
throw new Error("Access token is required");
|
|
197
198
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import app from "@b3dotfun/sdk/global-account/app";
|
|
2
2
|
import { authenticateWithB3JWT } from "@b3dotfun/sdk/global-account/bsmnt";
|
|
3
3
|
import { useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
4
|
-
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
4
|
+
import { ecosystemWalletId, type EcosystemWallet } from "@b3dotfun/sdk/shared/constants";
|
|
5
5
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
6
6
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
7
7
|
import { ConnectionOptions } from "@thirdweb-dev/wagmi-adapter";
|
|
@@ -63,7 +63,8 @@ export function useAuthentication(partnerId: string, { skipAutoConnect = false }
|
|
|
63
63
|
const { switchAccount } = useSwitchAccount();
|
|
64
64
|
debug("@@activeWagmiAccount", activeWagmiAccount);
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
// Explicit annotation keeps the hook's declaration portable (TS2742).
|
|
67
|
+
const wallet: EcosystemWallet = ecosystemWallet(ecosystemWalletId, {
|
|
67
68
|
partnerId: partnerId,
|
|
68
69
|
});
|
|
69
70
|
|
|
@@ -120,7 +121,7 @@ export function useAuthentication(partnerId: string, { skipAutoConnect = false }
|
|
|
120
121
|
}, [wallets, syncWagmi]);
|
|
121
122
|
|
|
122
123
|
const authenticateUser = useCallback(
|
|
123
|
-
async (wallet?: Wallet) => {
|
|
124
|
+
async (wallet?: Wallet): Promise<Record<string, any>> => {
|
|
124
125
|
setHasStartedConnecting(true);
|
|
125
126
|
|
|
126
127
|
if (!wallet) {
|
|
@@ -216,7 +217,7 @@ export function useAuthentication(partnerId: string, { skipAutoConnect = false }
|
|
|
216
217
|
localStorage.removeItem("b3-user");
|
|
217
218
|
}
|
|
218
219
|
|
|
219
|
-
app.logout();
|
|
220
|
+
await app.logout();
|
|
220
221
|
debug("@@logout:loggedOut");
|
|
221
222
|
|
|
222
223
|
setIsAuthenticated(false);
|
|
@@ -2,12 +2,12 @@ import app from "@b3dotfun/sdk/global-account/app";
|
|
|
2
2
|
import { useAuthStore, useB3Config } from "@b3dotfun/sdk/global-account/react";
|
|
3
3
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
4
4
|
import { useCallback } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { getBetterAuthClient } from "../../better-auth-client";
|
|
6
6
|
import { useUserQuery } from "./useUserQuery";
|
|
7
7
|
|
|
8
8
|
const debug = debugB3React("useBetterAuth");
|
|
9
9
|
|
|
10
|
-
export type BetterAuthSocialProvider = "google" | "discord" | "apple" | "github" | "slack" | "microsoft";
|
|
10
|
+
export type BetterAuthSocialProvider = "google" | "discord" | "apple" | "github" | "slack" | "microsoft" | "twitter";
|
|
11
11
|
|
|
12
12
|
/** Thrown when email verification is required before the user can sign in. */
|
|
13
13
|
export class EmailVerificationRequiredError extends Error {
|
|
@@ -34,7 +34,7 @@ export function useBetterAuth() {
|
|
|
34
34
|
const setHasStartedConnecting = useAuthStore(state => state.setHasStartedConnecting);
|
|
35
35
|
|
|
36
36
|
const exchangeForFeathersJWT = useCallback(
|
|
37
|
-
async (sessionToken: string) => {
|
|
37
|
+
async (sessionToken: string): Promise<Record<string, any>> => {
|
|
38
38
|
debug("Exchanging Better Auth token for Feathers JWT");
|
|
39
39
|
|
|
40
40
|
const response = await app.authenticate({
|
|
@@ -65,7 +65,7 @@ export function useBetterAuth() {
|
|
|
65
65
|
setIsAuthenticating(true);
|
|
66
66
|
|
|
67
67
|
try {
|
|
68
|
-
const result = await
|
|
68
|
+
const result = await getBetterAuthClient().signIn.email({ email, password });
|
|
69
69
|
|
|
70
70
|
if (result.error) {
|
|
71
71
|
throw new Error(result.error.message || "Sign in failed");
|
|
@@ -93,7 +93,7 @@ export function useBetterAuth() {
|
|
|
93
93
|
setIsAuthenticating(true);
|
|
94
94
|
|
|
95
95
|
try {
|
|
96
|
-
const result = await
|
|
96
|
+
const result = await getBetterAuthClient().signUp.email({ email, password, name });
|
|
97
97
|
|
|
98
98
|
if (result.error) {
|
|
99
99
|
throw new Error(result.error.message || "Sign up failed");
|
|
@@ -104,7 +104,7 @@ export function useBetterAuth() {
|
|
|
104
104
|
// requireEmailVerification is enabled — send verification email with
|
|
105
105
|
// a callbackURL Better Auth redirects to after server-side verify.
|
|
106
106
|
// Pass verifyCallbackURL to land on a dedicated confirmation page.
|
|
107
|
-
await
|
|
107
|
+
await getBetterAuthClient().sendVerificationEmail({
|
|
108
108
|
email,
|
|
109
109
|
callbackURL: verifyCallbackURL || `${window.location.origin}?authStrategy=better-auth`,
|
|
110
110
|
});
|
|
@@ -128,7 +128,7 @@ export function useBetterAuth() {
|
|
|
128
128
|
setIsAuthenticating(true);
|
|
129
129
|
|
|
130
130
|
try {
|
|
131
|
-
const result = await
|
|
131
|
+
const result = await getBetterAuthClient().signIn.social({
|
|
132
132
|
provider,
|
|
133
133
|
callbackURL: window.location.href,
|
|
134
134
|
});
|
|
@@ -151,7 +151,7 @@ export function useBetterAuth() {
|
|
|
151
151
|
const requestPasswordReset = useCallback(async (email: string, redirectTo?: string) => {
|
|
152
152
|
debug("Requesting password reset", { email });
|
|
153
153
|
|
|
154
|
-
const result = await
|
|
154
|
+
const result = await getBetterAuthClient().requestPasswordReset({
|
|
155
155
|
email,
|
|
156
156
|
redirectTo,
|
|
157
157
|
});
|
|
@@ -167,7 +167,7 @@ export function useBetterAuth() {
|
|
|
167
167
|
const resetPassword = useCallback(async (newPassword: string, token: string) => {
|
|
168
168
|
debug("Resetting password");
|
|
169
169
|
|
|
170
|
-
const result = await
|
|
170
|
+
const result = await getBetterAuthClient().resetPassword({
|
|
171
171
|
newPassword,
|
|
172
172
|
token,
|
|
173
173
|
});
|
|
@@ -187,6 +187,6 @@ export function useBetterAuth() {
|
|
|
187
187
|
requestPasswordReset,
|
|
188
188
|
resetPassword,
|
|
189
189
|
exchangeForFeathersJWT,
|
|
190
|
-
betterAuthClient,
|
|
190
|
+
betterAuthClient: getBetterAuthClient(),
|
|
191
191
|
};
|
|
192
192
|
}
|
|
@@ -28,14 +28,23 @@ export function useClient() {
|
|
|
28
28
|
}, []);
|
|
29
29
|
|
|
30
30
|
const authenticateWithType = useCallback(
|
|
31
|
-
async (
|
|
31
|
+
async (
|
|
32
|
+
type: ClientType,
|
|
33
|
+
accessToken: string,
|
|
34
|
+
identityToken: string,
|
|
35
|
+
params?: Record<string, any>,
|
|
36
|
+
): Promise<Record<string, any> | null> => {
|
|
32
37
|
return authenticateWithClient(type, accessToken, identityToken, params);
|
|
33
38
|
},
|
|
34
39
|
[],
|
|
35
40
|
);
|
|
36
41
|
|
|
37
42
|
const authenticateWithBoth = useCallback(
|
|
38
|
-
async (
|
|
43
|
+
async (
|
|
44
|
+
accessToken: string,
|
|
45
|
+
identityToken: string,
|
|
46
|
+
params?: Record<string, any>,
|
|
47
|
+
): Promise<{ socket: Record<string, any> | null; rest: Record<string, any> | null; success: boolean }> => {
|
|
39
48
|
return authenticateBoth(accessToken, identityToken, params);
|
|
40
49
|
},
|
|
41
50
|
[],
|
|
@@ -5,10 +5,17 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
5
5
|
import { viemAdapter } from "thirdweb/adapters/viem";
|
|
6
6
|
import { useConnectedWallets, useWalletInfo } from "thirdweb/react";
|
|
7
7
|
import { Wallet } from "thirdweb/wallets";
|
|
8
|
+
import type { WalletClient } from "viem";
|
|
8
9
|
|
|
9
10
|
const debug = debugB3React("useFirstEOA");
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
// Explicit return annotation keeps the hook's declaration portable (TS2742).
|
|
13
|
+
export function useFirstEOA(chain?: { id: number; name: string; rpc: string }): {
|
|
14
|
+
account: Wallet | undefined;
|
|
15
|
+
address: string | undefined;
|
|
16
|
+
info: ReturnType<typeof useWalletInfo>;
|
|
17
|
+
walletClient: WalletClient | undefined;
|
|
18
|
+
} {
|
|
12
19
|
const wallets = useConnectedWallets();
|
|
13
20
|
const isConnected = useAuthStore(state => state.isConnected);
|
|
14
21
|
const [firstEOA, setFirstEOA] = useState<Wallet | undefined>(undefined);
|
|
@@ -41,7 +48,7 @@ export function useFirstEOA(chain?: { id: number; name: string; rpc: string }) {
|
|
|
41
48
|
autoSelectFirstEOAWallet();
|
|
42
49
|
}, [isConnected, wallets]);
|
|
43
50
|
|
|
44
|
-
const walletClient = useMemo(() => {
|
|
51
|
+
const walletClient = useMemo<WalletClient | undefined>(() => {
|
|
45
52
|
if (!firstEOA) return undefined;
|
|
46
53
|
if (!chain) return undefined;
|
|
47
54
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toast } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { PUBLIC_BASE_RPC_URL } from "@b3dotfun/sdk/shared/constants";
|
|
3
|
-
import { b3Mainnet, b3Testnet } from "@b3dotfun/sdk/shared/constants/chains/
|
|
3
|
+
import { b3Mainnet, b3Testnet } from "@b3dotfun/sdk/shared/constants/chains/b3Chain";
|
|
4
4
|
import { formatNumber } from "@b3dotfun/sdk/shared/utils/formatNumber";
|
|
5
5
|
import { useQuery } from "@tanstack/react-query";
|
|
6
6
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import {
|
|
3
|
+
adaptZerionPositions,
|
|
4
|
+
balanceMatchesToken,
|
|
5
|
+
type B3TokenBalance,
|
|
6
|
+
type ZerionPositionLike,
|
|
7
|
+
} from "@b3dotfun/sdk/shared/utils/zerionPositions";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Wallet holdings, read through the b3 portfolio proxy.
|
|
11
|
+
*
|
|
12
|
+
* The proxy holds the upstream API key server-side and authorizes browsers by Origin allowlist, so
|
|
13
|
+
* nothing secret ships to the client and no key is accepted from it. A consumer served from an
|
|
14
|
+
* origin the proxy does not know will be refused — adding an origin is a proxy config change, not
|
|
15
|
+
* an SDK change.
|
|
16
|
+
*/
|
|
17
|
+
const PORTFOLIO_API_BASE_URL = "https://portfolio-api.b3.fun";
|
|
18
|
+
|
|
19
|
+
interface ZerionPositionsResponse {
|
|
20
|
+
data?: ZerionPositionLike[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Fetch every spendable holding for a wallet in one request.
|
|
25
|
+
*
|
|
26
|
+
* Deliberately unpaginated and unfiltered by chain. The positions endpoint returns a wallet's full
|
|
27
|
+
* simple-position list in a single response, and passing a chain filter is actively harmful: the
|
|
28
|
+
* upstream rejects a handful of otherwise-valid chain slugs and fails the WHOLE request when one
|
|
29
|
+
* appears, so a caller asking for five chains can lose all five. Callers narrow the result instead.
|
|
30
|
+
*/
|
|
31
|
+
async function fetchWalletPositions(address: string): Promise<B3TokenBalance[]> {
|
|
32
|
+
const url = `${PORTFOLIO_API_BASE_URL}/v1/wallets/${encodeURIComponent(address)}/positions/?filter[positions]=only_simple`;
|
|
33
|
+
const response = await fetch(url, { headers: { Accept: "application/json" } });
|
|
34
|
+
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
throw new Error(`Failed to fetch wallet balances: ${response.status} ${response.statusText}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const body = (await response.json()) as ZerionPositionsResponse;
|
|
40
|
+
return adaptZerionPositions(body.data ?? []);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Keyed by wallet alone so every consumer of the same wallet shares one fetch and one cache entry.
|
|
45
|
+
* Keying by the requested chain subset instead would refetch per caller and share nothing.
|
|
46
|
+
*/
|
|
47
|
+
function walletPositionsQueryKey(address?: string) {
|
|
48
|
+
return ["walletPositions", address] as const;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Holdings for a wallet, optionally narrowed to specific chains.
|
|
53
|
+
*
|
|
54
|
+
* Read `isError` before reading `data`: a failed read and an empty wallet are different facts, and
|
|
55
|
+
* rendering the first as the second tells the user they hold nothing when nobody knows.
|
|
56
|
+
*/
|
|
57
|
+
export function usePortfolioBalance(address?: string, chainIds?: number[]) {
|
|
58
|
+
const wantedChainIds = chainIds && chainIds.length > 0 ? chainIds : undefined;
|
|
59
|
+
|
|
60
|
+
return useQuery({
|
|
61
|
+
queryKey: walletPositionsQueryKey(address),
|
|
62
|
+
queryFn: () => {
|
|
63
|
+
if (!address) throw new Error("Address is required");
|
|
64
|
+
return fetchWalletPositions(address);
|
|
65
|
+
},
|
|
66
|
+
enabled: Boolean(address),
|
|
67
|
+
select: (balances: B3TokenBalance[]) =>
|
|
68
|
+
wantedChainIds ? balances.filter(balance => wantedChainIds.includes(balance.chain_id)) : balances,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* One token's balance for a wallet, served from the same per-wallet fetch as {@link usePortfolioBalance}.
|
|
74
|
+
*
|
|
75
|
+
* `tokenAddress` may be a contract address or the chain's native sentinel; matching is
|
|
76
|
+
* case-insensitive because callers pass addresses in whatever casing their source used.
|
|
77
|
+
*/
|
|
78
|
+
export function usePortfolioTokenBalance(walletAddress?: string, tokenAddress?: string, chainId?: number) {
|
|
79
|
+
return useQuery({
|
|
80
|
+
queryKey: walletPositionsQueryKey(walletAddress),
|
|
81
|
+
queryFn: () => {
|
|
82
|
+
if (!walletAddress) throw new Error("Address is required");
|
|
83
|
+
return fetchWalletPositions(walletAddress);
|
|
84
|
+
},
|
|
85
|
+
enabled: Boolean(walletAddress) && Boolean(tokenAddress) && Boolean(chainId),
|
|
86
|
+
select: (balances: B3TokenBalance[]) =>
|
|
87
|
+
balances.find(balance => balance.chain_id === chainId && balanceMatchesToken(balance, tokenAddress ?? "")),
|
|
88
|
+
});
|
|
89
|
+
}
|