@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspend/constants";
|
|
2
|
+
import { SOLANA_CHAIN_ID } from "@b3dotfun/sdk/shared/utils/zerionPositions";
|
|
2
3
|
import {
|
|
3
4
|
ABSTRACT_PUBLIC_RPC,
|
|
4
5
|
ARBITRUM_PUBLIC_RPC,
|
|
@@ -8,7 +9,9 @@ import {
|
|
|
8
9
|
ETHEREUM_PUBLIC_RPC,
|
|
9
10
|
HYPEREVM_PUBLIC_RPC,
|
|
10
11
|
OPTIMISM_PUBLIC_RPC,
|
|
12
|
+
PLUME_PUBLIC_RPC,
|
|
11
13
|
POLYGON_PUBLIC_RPC,
|
|
14
|
+
ROBINHOOD_PUBLIC_RPC,
|
|
12
15
|
} from "@b3dotfun/sdk/anyspend/constants/rpc";
|
|
13
16
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
14
17
|
import { b3Viem } from "@b3dotfun/sdk/shared/constants/chains/b3Viem";
|
|
@@ -25,7 +28,7 @@ import {
|
|
|
25
28
|
Transport,
|
|
26
29
|
WalletClient,
|
|
27
30
|
} from "viem";
|
|
28
|
-
import { abstract, arbitrum, avalanche, base, bsc, mainnet, optimism, polygon } from "viem/chains";
|
|
31
|
+
import { abstract, arbitrum, avalanche, base, bsc, mainnet, optimism, polygon, robinhood } from "viem/chains";
|
|
29
32
|
import { ChainType, IBaseChain, IEVMChain, IHyperliquidChain, ISolanaChain } from "../types/chain";
|
|
30
33
|
import {
|
|
31
34
|
getAvaxToken,
|
|
@@ -33,10 +36,12 @@ import {
|
|
|
33
36
|
getEthToken,
|
|
34
37
|
getHyperEVMNativeToken,
|
|
35
38
|
getHyperliquidUSDCToken,
|
|
39
|
+
getPlumeNativeToken,
|
|
36
40
|
getPolToken,
|
|
37
41
|
getSolanaToken,
|
|
38
42
|
HYPEREVM_CHAIN_ID,
|
|
39
43
|
HYPERLIQUID_CHAIN_ID,
|
|
44
|
+
PLUME_CHAIN_ID,
|
|
40
45
|
} from "./token";
|
|
41
46
|
|
|
42
47
|
function getCustomEvmChain(chain: Chain, rpcUrl: string): Chain {
|
|
@@ -84,11 +89,19 @@ export function clearChainRpcOverrides(): void {
|
|
|
84
89
|
export const hyperEVM = defineChain({
|
|
85
90
|
id: HYPEREVM_CHAIN_ID,
|
|
86
91
|
name: "HyperEVM",
|
|
87
|
-
nativeCurrency: { name: "
|
|
92
|
+
nativeCurrency: { name: "Hyperliquid", symbol: "HYPE", decimals: 18 },
|
|
88
93
|
rpcUrls: { default: { http: [HYPEREVM_PUBLIC_RPC] } },
|
|
89
94
|
blockExplorers: { default: { name: "HyperEVM Explorer", url: "https://hyperevmscan.io/" } },
|
|
90
95
|
});
|
|
91
96
|
|
|
97
|
+
export const plume = defineChain({
|
|
98
|
+
id: PLUME_CHAIN_ID,
|
|
99
|
+
name: "Plume",
|
|
100
|
+
nativeCurrency: { name: "Plume", symbol: "PLUME", decimals: 18 },
|
|
101
|
+
rpcUrls: { default: { http: [PLUME_PUBLIC_RPC] } },
|
|
102
|
+
blockExplorers: { default: { name: "Plume Explorer", url: "https://explorer.plume.org" } },
|
|
103
|
+
});
|
|
104
|
+
|
|
92
105
|
// export const b4testnet = defineChain({
|
|
93
106
|
// id: 19934,
|
|
94
107
|
// name: "B4 Testnet",
|
|
@@ -247,6 +260,34 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
247
260
|
coingeckoName: "hyperevm",
|
|
248
261
|
wethAddress: "0x5555555555555555555555555555555555555555",
|
|
249
262
|
},
|
|
263
|
+
[plume.id]: {
|
|
264
|
+
id: plume.id,
|
|
265
|
+
name: plume.name,
|
|
266
|
+
logoUrl: "https://cdn.b3.fun/b3os-icons/plume.svg",
|
|
267
|
+
type: ChainType.EVM,
|
|
268
|
+
nativeRequired: parseEther("5"), // 5 PLUME ≈ $0.06 — gas reserve; Plume gasPrice ~1000 gwei × 2.2M gas (approve+deposit) needs ~2.2 PLUME, +headroom for spikes
|
|
269
|
+
canDepositNative: true,
|
|
270
|
+
defaultToken: getPlumeNativeToken(),
|
|
271
|
+
nativeToken: getPlumeNativeToken(),
|
|
272
|
+
viem: plume,
|
|
273
|
+
pollingInterval: 1000, // 1 second for Plume (L2 fast blocks)
|
|
274
|
+
coingeckoName: "plume-network",
|
|
275
|
+
wethAddress: "0xea237441c92cae6fc17caaf9a7acb3f953be4bd1", // WPLUME (wrapped native)
|
|
276
|
+
},
|
|
277
|
+
[robinhood.id]: {
|
|
278
|
+
id: robinhood.id,
|
|
279
|
+
name: robinhood.name,
|
|
280
|
+
logoUrl: "https://assets.relay.link/icons/square/4663/light.png",
|
|
281
|
+
type: ChainType.EVM,
|
|
282
|
+
nativeRequired: parseEther("0.0001"),
|
|
283
|
+
canDepositNative: true,
|
|
284
|
+
defaultToken: getEthToken(robinhood.id),
|
|
285
|
+
nativeToken: getEthToken(robinhood.id),
|
|
286
|
+
viem: getCustomEvmChain(robinhood, ROBINHOOD_PUBLIC_RPC),
|
|
287
|
+
pollingInterval: 1000, // 1 second for Robinhood Chain (Arbitrum Orbit fast blocks)
|
|
288
|
+
coingeckoName: "robinhood",
|
|
289
|
+
wethAddress: "0x0bd7d308f8e1639fab988df18a8011f41eacad73", // wrapped native ETH (registry wrappedNative)
|
|
290
|
+
},
|
|
250
291
|
};
|
|
251
292
|
|
|
252
293
|
export const EVM_TESTNET: Record<number, IEVMChain> = {
|
|
@@ -331,6 +372,17 @@ export const EVM_CHAINS: Record<number, IEVMChain> = { ...EVM_MAINNET, ...EVM_TE
|
|
|
331
372
|
|
|
332
373
|
export const SOLANA_CHAINS: Record<number, ISolanaChain> = { [RELAY_SOLANA_MAINNET_CHAIN_ID]: SOLANA_MAINNET };
|
|
333
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Translate a Relay-numbered chain id into the id the chain registry uses.
|
|
377
|
+
*
|
|
378
|
+
* Relay numbers Solana 792703809; every other chain shares the universal EVM id. Balance rows are
|
|
379
|
+
* keyed by the registry's id, so handing Relay's number to a balance lookup matches nothing at all
|
|
380
|
+
* — and a funded Solana wallet then reads as empty rather than as unreadable.
|
|
381
|
+
*/
|
|
382
|
+
export function toRegistryChainId(chainId: number): number {
|
|
383
|
+
return chainId === RELAY_SOLANA_MAINNET_CHAIN_ID ? SOLANA_CHAIN_ID : chainId;
|
|
384
|
+
}
|
|
385
|
+
|
|
334
386
|
export const HYPERLIQUID_CHAINS: Record<number, IHyperliquidChain> = {
|
|
335
387
|
[HYPERLIQUID_CHAIN_ID]: HYPERLIQUID_MAINNET,
|
|
336
388
|
};
|
|
@@ -655,6 +707,26 @@ export function getHyperliquidChain(chainId: number): IHyperliquidChain {
|
|
|
655
707
|
return HYPERLIQUID_CHAINS[chainId];
|
|
656
708
|
}
|
|
657
709
|
|
|
710
|
+
/**
|
|
711
|
+
* Chains AnySpend no longer accepts orders on, as either source or destination.
|
|
712
|
+
*
|
|
713
|
+
* They stay in ALL_CHAINS on purpose. That map answers "what is this chain" — name, logo, token,
|
|
714
|
+
* decimals — which every order that ever existed still needs in order to render; removing an entry
|
|
715
|
+
* would make getChainName and friends throw on historical rows. Whether new orders are accepted is
|
|
716
|
+
* this separate question.
|
|
717
|
+
*
|
|
718
|
+
* anyspend-service imports this list rather than keeping its own, so the API and the chain picker
|
|
719
|
+
* can never disagree about what is on offer.
|
|
720
|
+
*/
|
|
721
|
+
export const DEPRECATED_CHAIN_IDS: readonly number[] = [
|
|
722
|
+
8333, // B3
|
|
723
|
+
98866, // Plume
|
|
724
|
+
];
|
|
725
|
+
|
|
726
|
+
export function isDeprecatedChain(chainId?: number): boolean {
|
|
727
|
+
return chainId !== undefined && DEPRECATED_CHAIN_IDS.includes(chainId);
|
|
728
|
+
}
|
|
729
|
+
|
|
658
730
|
/**
|
|
659
731
|
* Get available chain IDs for AnySpend based on context (source or destination).
|
|
660
732
|
* Filters out chains that shouldn't be available for the given context.
|
|
@@ -670,7 +742,11 @@ export function getHyperliquidChain(chainId: number): IHyperliquidChain {
|
|
|
670
742
|
* const destChains = getAvailableChainIds("to") // [1, 8453, 137, ..., 1337]
|
|
671
743
|
*/
|
|
672
744
|
export function getAvailableChainIds(context: "from" | "to"): number[] {
|
|
673
|
-
|
|
745
|
+
// Deprecated chains are excluded from both directions: the API rejects them, so offering them in
|
|
746
|
+
// a picker would let a user select something that then fails at order creation.
|
|
747
|
+
const allChainIds = Object.values(ALL_CHAINS)
|
|
748
|
+
.map(chain => chain.id)
|
|
749
|
+
.filter(chainId => !isDeprecatedChain(chainId));
|
|
674
750
|
|
|
675
751
|
if (context === "from") {
|
|
676
752
|
// Hyperliquid is only supported as destination chain, not source chain
|
|
@@ -4,6 +4,7 @@ import { avalanche, bsc, polygon } from "viem/chains";
|
|
|
4
4
|
|
|
5
5
|
export const HYPERLIQUID_CHAIN_ID = 1337;
|
|
6
6
|
export const HYPEREVM_CHAIN_ID = 999;
|
|
7
|
+
export const PLUME_CHAIN_ID = 98866;
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Hyperliquid uses a special 34-character USDC address format (0x + 32 hex digits)
|
|
@@ -106,3 +107,16 @@ export function getHyperliquidUSDCToken(): components["schemas"]["Token"] {
|
|
|
106
107
|
},
|
|
107
108
|
};
|
|
108
109
|
}
|
|
110
|
+
|
|
111
|
+
export function getPlumeNativeToken(): components["schemas"]["Token"] {
|
|
112
|
+
return {
|
|
113
|
+
chainId: PLUME_CHAIN_ID,
|
|
114
|
+
address: ZERO_ADDRESS,
|
|
115
|
+
symbol: "PLUME",
|
|
116
|
+
name: "Plume",
|
|
117
|
+
decimals: 18,
|
|
118
|
+
metadata: {
|
|
119
|
+
logoURI: "https://cdn.b3.fun/b3os-icons/plume.svg",
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
package/src/app.shared.ts
CHANGED
|
@@ -4,15 +4,35 @@ import Cookies from "js-cookie";
|
|
|
4
4
|
import { B3_AUTH_COOKIE_NAME } from "./shared/constants";
|
|
5
5
|
import { getSessionDurationDays } from "./shared/utils/session-duration";
|
|
6
6
|
|
|
7
|
+
/** Default API URL derived from environment variables. */
|
|
7
8
|
export const B3_API_URL =
|
|
8
9
|
process.env.EXPO_PUBLIC_B3_API || process.env.NEXT_PUBLIC_B3_API || process.env.PUBLIC_B3_API || "https://api.b3.fun";
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Runtime-overridable API URL. Set by `B3Provider` when an `apiUrl` prop
|
|
13
|
+
* is provided. Falls back to the env-var-derived `B3_API_URL`.
|
|
14
|
+
*/
|
|
15
|
+
let _apiUrlOverride: string | null = null;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Override the B3 API URL at runtime. Called by `B3Provider` when an
|
|
19
|
+
* `apiUrl` prop is provided. Pass `null` to revert to the default.
|
|
20
|
+
*/
|
|
21
|
+
export function setB3ApiUrl(url: string | null): void {
|
|
22
|
+
_apiUrlOverride = url;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Get the current B3 API URL (prefers runtime override, then env var). */
|
|
26
|
+
export function getB3ApiUrl(): string {
|
|
27
|
+
return _apiUrlOverride || B3_API_URL;
|
|
28
|
+
}
|
|
29
|
+
|
|
10
30
|
export const authenticate = async (
|
|
11
31
|
app: ClientApplication,
|
|
12
32
|
accessToken: string,
|
|
13
33
|
identityToken: string,
|
|
14
34
|
params?: Record<string, any>,
|
|
15
|
-
) => {
|
|
35
|
+
): Promise<Record<string, any> | null> => {
|
|
16
36
|
const fullToken = `${accessToken}+${identityToken}`;
|
|
17
37
|
|
|
18
38
|
// Do not authenticate if there is no token
|
|
@@ -77,7 +77,11 @@ const app = createClient(socketio(socket), {
|
|
|
77
77
|
storageKey: B3_AUTH_COOKIE_NAME,
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
export const authenticate = async (
|
|
80
|
+
export const authenticate = async (
|
|
81
|
+
accessToken: string,
|
|
82
|
+
identityToken: string,
|
|
83
|
+
params?: Record<string, any>,
|
|
84
|
+
): Promise<Record<string, any> | null> => {
|
|
81
85
|
const fullToken = `${accessToken}+${identityToken}`;
|
|
82
86
|
|
|
83
87
|
// Do not authenticate if there is no token
|
|
@@ -1,17 +1,43 @@
|
|
|
1
1
|
import { createAuthClient } from "better-auth/client";
|
|
2
|
-
import {
|
|
2
|
+
import { twoFactorClient } from "better-auth/client/plugins";
|
|
3
|
+
import { getB3ApiUrl } from "../app.shared";
|
|
3
4
|
|
|
4
5
|
export type B3BetterAuthClient = ReturnType<typeof createB3BetterAuthClient>;
|
|
5
6
|
|
|
6
|
-
export function createB3BetterAuthClient(baseURL
|
|
7
|
+
export function createB3BetterAuthClient(baseURL?: string) {
|
|
7
8
|
return createAuthClient({
|
|
8
|
-
baseURL,
|
|
9
|
+
baseURL: baseURL ?? getB3ApiUrl(),
|
|
9
10
|
basePath: "/auth",
|
|
10
11
|
fetchOptions: {
|
|
11
12
|
credentials: "include",
|
|
12
13
|
},
|
|
14
|
+
plugins: [twoFactorClient()],
|
|
13
15
|
});
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
//
|
|
18
|
+
// Lazily-initialized singleton. Recreated when the API URL changes via
|
|
19
|
+
// `resetBetterAuthClient()` (called by B3Provider when `apiUrl` changes).
|
|
20
|
+
let _client: B3BetterAuthClient | null = null;
|
|
21
|
+
let _clientUrl: string | null = null;
|
|
22
|
+
|
|
23
|
+
/** Get the shared BetterAuth client, creating it if needed. */
|
|
24
|
+
export function getBetterAuthClient(): B3BetterAuthClient {
|
|
25
|
+
const url = getB3ApiUrl();
|
|
26
|
+
if (!_client || _clientUrl !== url) {
|
|
27
|
+
_client = createB3BetterAuthClient(url);
|
|
28
|
+
_clientUrl = url;
|
|
29
|
+
}
|
|
30
|
+
return _client;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Force-recreate the client on next access (e.g. after API URL change). */
|
|
34
|
+
export function resetBetterAuthClient(): void {
|
|
35
|
+
_client = null;
|
|
36
|
+
_clientUrl = null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use `getBetterAuthClient()` instead. This static singleton
|
|
41
|
+
* does not reflect runtime API URL changes via `B3Provider apiUrl` prop.
|
|
42
|
+
*/
|
|
17
43
|
export const betterAuthClient = createB3BetterAuthClient();
|
|
@@ -80,7 +80,11 @@ const app = createClient(socketio(socket), {
|
|
|
80
80
|
storageKey: BSMNT_AUTH_COOKIE_NAME,
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
export const authenticate = async (
|
|
83
|
+
export const authenticate = async (
|
|
84
|
+
accessToken: string,
|
|
85
|
+
identityToken: string,
|
|
86
|
+
params?: Record<string, any>,
|
|
87
|
+
): Promise<Record<string, any> | null> => {
|
|
84
88
|
const fullToken = `${accessToken}+${identityToken}`;
|
|
85
89
|
|
|
86
90
|
// Do not authenticate if there is no token
|
|
@@ -42,7 +42,11 @@ const app = createClient(socketio(socket), {
|
|
|
42
42
|
storageKey: BSMNT_AUTH_COOKIE_NAME,
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
export const authenticate = async (
|
|
45
|
+
export const authenticate = async (
|
|
46
|
+
accessToken: string,
|
|
47
|
+
identityToken: string,
|
|
48
|
+
params?: Record<string, any>,
|
|
49
|
+
): Promise<Record<string, any> | null> => {
|
|
46
50
|
const fullToken = `${accessToken}+${identityToken}`;
|
|
47
51
|
|
|
48
52
|
// Do not authenticate if there is no token
|
|
@@ -73,7 +77,10 @@ export const resetSocket = () => {
|
|
|
73
77
|
// reset the socket connection
|
|
74
78
|
};
|
|
75
79
|
|
|
76
|
-
export const authenticateWithB3JWT = async (
|
|
80
|
+
export const authenticateWithB3JWT = async (
|
|
81
|
+
fullToken: string,
|
|
82
|
+
params?: Record<string, any>,
|
|
83
|
+
): Promise<Record<string, any> | null> => {
|
|
77
84
|
// Do not authenticate if there is no token
|
|
78
85
|
if (!fullToken) {
|
|
79
86
|
console.log("No token found, not authenticating");
|
|
@@ -2,7 +2,7 @@ import { ClientApplication, createClient } from "@b3dotfun/b3-api";
|
|
|
2
2
|
import rest from "@feathersjs/rest-client";
|
|
3
3
|
import socketio from "@feathersjs/socketio-client";
|
|
4
4
|
import io from "socket.io-client";
|
|
5
|
-
import { authenticate as authenticateB3,
|
|
5
|
+
import { authenticate as authenticateB3, getB3ApiUrl, clientOptions } from "../app.shared";
|
|
6
6
|
|
|
7
7
|
export type ClientType = "socket" | "rest";
|
|
8
8
|
|
|
@@ -13,17 +13,53 @@ let currentClient: ClientApplication | null = null;
|
|
|
13
13
|
// Socket client instance
|
|
14
14
|
let socketClient: ClientApplication | null = null;
|
|
15
15
|
let socketInstance: any = null;
|
|
16
|
+
let socketClientUrl: string | null = null;
|
|
16
17
|
|
|
17
18
|
// REST client instance
|
|
18
19
|
let restClient: ClientApplication | null = null;
|
|
20
|
+
let restClientUrl: string | null = null;
|
|
21
|
+
|
|
22
|
+
// The pinned @b3dotfun/b3-api client's generated usersMethods predates `setBio`,
|
|
23
|
+
// so `users.setBio(...)` throws "setBio is not a function". Re-register the users
|
|
24
|
+
// service with the full list (mirrors users.shared.ts). Remove once the
|
|
25
|
+
// @b3dotfun/b3-api pin includes setBio.
|
|
26
|
+
const USERS_METHODS = [
|
|
27
|
+
"find",
|
|
28
|
+
"get",
|
|
29
|
+
"create",
|
|
30
|
+
"patch",
|
|
31
|
+
"remove",
|
|
32
|
+
"setReferralCode",
|
|
33
|
+
"syncTwProfiles",
|
|
34
|
+
"setAvatar",
|
|
35
|
+
"setBio",
|
|
36
|
+
"registerUsername",
|
|
37
|
+
"getMe",
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
// Re-register on every client the manager builds — the active transport
|
|
41
|
+
// (REST/socket) switches at runtime.
|
|
42
|
+
function ensureUsersCustomMethods(client: ClientApplication): void {
|
|
43
|
+
try {
|
|
44
|
+
const connection = (client as any).get("connection");
|
|
45
|
+
if (connection?.service) {
|
|
46
|
+
(client as any).use("users", connection.service("users"), { methods: USERS_METHODS });
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
// Non-fatal: keep whatever methods the generated client already exposes.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
19
52
|
|
|
20
53
|
/**
|
|
21
54
|
* Creates a socket client
|
|
22
55
|
*/
|
|
23
56
|
function createSocketClient(): ClientApplication {
|
|
24
|
-
|
|
25
|
-
|
|
57
|
+
const url = getB3ApiUrl();
|
|
58
|
+
if (!socketClient || socketClientUrl !== url) {
|
|
59
|
+
socketInstance = io(url, { transports: ["websocket"] });
|
|
26
60
|
socketClient = createClient(socketio(socketInstance), clientOptions);
|
|
61
|
+
ensureUsersCustomMethods(socketClient);
|
|
62
|
+
socketClientUrl = url;
|
|
27
63
|
}
|
|
28
64
|
return socketClient;
|
|
29
65
|
}
|
|
@@ -40,13 +76,25 @@ function resolveFetch(): typeof fetch {
|
|
|
40
76
|
}
|
|
41
77
|
|
|
42
78
|
function createRestClient(): ClientApplication {
|
|
43
|
-
|
|
44
|
-
|
|
79
|
+
const url = getB3ApiUrl();
|
|
80
|
+
if (!restClient || restClientUrl !== url) {
|
|
81
|
+
const connection = rest(url).fetch(resolveFetch());
|
|
45
82
|
restClient = createClient(connection, clientOptions);
|
|
83
|
+
ensureUsersCustomMethods(restClient);
|
|
84
|
+
restClientUrl = url;
|
|
46
85
|
}
|
|
47
86
|
return restClient;
|
|
48
87
|
}
|
|
49
88
|
|
|
89
|
+
/** Reset all cached clients (called when API URL changes). */
|
|
90
|
+
export function resetClients(): void {
|
|
91
|
+
socketClient = null;
|
|
92
|
+
socketClientUrl = null;
|
|
93
|
+
restClient = null;
|
|
94
|
+
restClientUrl = null;
|
|
95
|
+
currentClient = null;
|
|
96
|
+
}
|
|
97
|
+
|
|
50
98
|
/**
|
|
51
99
|
* Sets the active client type and creates the appropriate client
|
|
52
100
|
*
|
|
@@ -99,7 +147,11 @@ export function resetSocket(): void {
|
|
|
99
147
|
/**
|
|
100
148
|
* Authenticates with the current active client
|
|
101
149
|
*/
|
|
102
|
-
export const authenticate = async (
|
|
150
|
+
export const authenticate = async (
|
|
151
|
+
accessToken: string,
|
|
152
|
+
identityToken: string,
|
|
153
|
+
params?: Record<string, any>,
|
|
154
|
+
): Promise<Record<string, any> | null> => {
|
|
103
155
|
return authenticateB3(getClient(), accessToken, identityToken, params);
|
|
104
156
|
};
|
|
105
157
|
|
|
@@ -111,7 +163,7 @@ export const authenticateWithClient = async (
|
|
|
111
163
|
accessToken: string,
|
|
112
164
|
identityToken: string,
|
|
113
165
|
params?: Record<string, any>,
|
|
114
|
-
) => {
|
|
166
|
+
): Promise<Record<string, any> | null> => {
|
|
115
167
|
const client = getClientByType(clientType);
|
|
116
168
|
return authenticateB3(client, accessToken, identityToken, params);
|
|
117
169
|
};
|
|
@@ -119,7 +171,15 @@ export const authenticateWithClient = async (
|
|
|
119
171
|
/**
|
|
120
172
|
* Authenticates with both clients in parallel (useful for migration scenarios)
|
|
121
173
|
*/
|
|
122
|
-
export const authenticateBoth = async (
|
|
174
|
+
export const authenticateBoth = async (
|
|
175
|
+
accessToken: string,
|
|
176
|
+
identityToken: string,
|
|
177
|
+
params?: Record<string, any>,
|
|
178
|
+
): Promise<{
|
|
179
|
+
socket: Record<string, any> | null;
|
|
180
|
+
rest: Record<string, any> | null;
|
|
181
|
+
success: boolean;
|
|
182
|
+
}> => {
|
|
123
183
|
const [socketResult, restResult] = await Promise.allSettled([
|
|
124
184
|
authenticateWithClient("socket", accessToken, identityToken, params),
|
|
125
185
|
authenticateWithClient("rest", accessToken, identityToken, params),
|
|
@@ -135,7 +195,12 @@ export const authenticateBoth = async (accessToken: string, identityToken: strin
|
|
|
135
195
|
/**
|
|
136
196
|
* Switches the client type and authenticates
|
|
137
197
|
*/
|
|
138
|
-
export async function switchClientAndAuth(
|
|
198
|
+
export async function switchClientAndAuth(
|
|
199
|
+
type: ClientType,
|
|
200
|
+
access: string,
|
|
201
|
+
id: string,
|
|
202
|
+
params?: any,
|
|
203
|
+
): Promise<Record<string, any> | null> {
|
|
139
204
|
setClientType(type);
|
|
140
205
|
return authenticateWithClient(type, access, id, params);
|
|
141
206
|
}
|
|
@@ -13,7 +13,7 @@ import { validateImageUrl } from "@b3dotfun/sdk/global-account/react/utils/profi
|
|
|
13
13
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
14
14
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
15
15
|
import { getIpfsUrl } from "@b3dotfun/sdk/shared/utils/ipfs";
|
|
16
|
-
import {
|
|
16
|
+
import { uploadFile as uploadToB3 } from "@b3dotfun/sdk/shared/utils/upload";
|
|
17
17
|
import { Loader2, Upload, X } from "lucide-react";
|
|
18
18
|
import { useCallback, useRef, useState } from "react";
|
|
19
19
|
import type { Area } from "react-easy-crop";
|
|
@@ -21,7 +21,6 @@ import Cropper from "react-easy-crop";
|
|
|
21
21
|
import "react-easy-crop/react-easy-crop.css";
|
|
22
22
|
|
|
23
23
|
import { useActiveAccount } from "thirdweb/react";
|
|
24
|
-
import { upload } from "thirdweb/storage";
|
|
25
24
|
import { useModalStore } from "../../stores";
|
|
26
25
|
import ModalHeader from "../ModalHeader/ModalHeader";
|
|
27
26
|
|
|
@@ -243,22 +242,18 @@ export function AvatarEditor({ onSetAvatar, className }: AvatarEditorProps) {
|
|
|
243
242
|
}
|
|
244
243
|
}
|
|
245
244
|
|
|
246
|
-
// Upload
|
|
245
|
+
// Upload file if we have one
|
|
247
246
|
if (fileToUpload) {
|
|
248
|
-
debug("Starting upload
|
|
247
|
+
debug("Starting upload", fileToUpload);
|
|
249
248
|
|
|
250
|
-
|
|
251
|
-
const ipfsUrl = await upload({
|
|
252
|
-
client,
|
|
253
|
-
files: [fileToUpload],
|
|
254
|
-
});
|
|
249
|
+
const avatarUrl = await uploadToB3(fileToUpload);
|
|
255
250
|
|
|
256
|
-
debug("Upload successful",
|
|
251
|
+
debug("Upload successful", avatarUrl);
|
|
257
252
|
|
|
258
253
|
// Save avatar URL using profiles service
|
|
259
254
|
const user = await app.service("users").setAvatar(
|
|
260
255
|
{
|
|
261
|
-
avatar:
|
|
256
|
+
avatar: avatarUrl,
|
|
262
257
|
},
|
|
263
258
|
// @ts-expect-error - our typed client is expecting context even though it's set elsewhere
|
|
264
259
|
{},
|
|
@@ -84,3 +84,15 @@ export function useB3Config(): B3ConfigContextType {
|
|
|
84
84
|
}
|
|
85
85
|
return context;
|
|
86
86
|
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Overrides ONLY `partnerId` for a subtree, inheriting every other config value from the parent
|
|
90
|
+
* B3ConfigProvider. Lets a single route attribute its AnySpend orders/quotes to a different partner
|
|
91
|
+
* (e.g. `/b3os-deposit` → the b3os partner) without standing up a second B3Provider — the config
|
|
92
|
+
* context is separate from the wallet/modal machinery, so nothing re-initializes. Must be rendered
|
|
93
|
+
* inside an existing B3ConfigProvider.
|
|
94
|
+
*/
|
|
95
|
+
export function B3ConfigPartnerOverride({ partnerId, children }: { partnerId: string; children: React.ReactNode }) {
|
|
96
|
+
const parent = useB3Config();
|
|
97
|
+
return <B3ConfigContext.Provider value={{ ...parent, partnerId }}>{children}</B3ConfigContext.Provider>;
|
|
98
|
+
}
|
|
@@ -11,7 +11,10 @@ import { QueryClient } from "@tanstack/react-query";
|
|
|
11
11
|
import { useEffect, useMemo } from "react";
|
|
12
12
|
import { Account, EIP1193, Wallet } from "thirdweb/wallets";
|
|
13
13
|
import { CreateConnectorFn } from "wagmi";
|
|
14
|
-
import { ClientType, setClientType } from "../../../client-manager";
|
|
14
|
+
import { ClientType, resetClients, setClientType } from "../../../client-manager";
|
|
15
|
+
import { setB3ApiUrl } from "../../../../app.shared";
|
|
16
|
+
import { setApiUrl as setNotificationsApiUrl } from "../../../../notifications/services/api";
|
|
17
|
+
import { resetBetterAuthClient } from "../../../better-auth-client";
|
|
15
18
|
import { StyleRoot } from "../StyleRoot";
|
|
16
19
|
import { setToastContext, ToastProvider, useToastContext } from "../Toast/index";
|
|
17
20
|
import AuthenticationProvider from "./AuthenticationProvider";
|
|
@@ -19,6 +22,11 @@ import { B3ConfigProvider } from "./B3ConfigProvider";
|
|
|
19
22
|
import BetterAuthProvider from "./BetterAuthProvider";
|
|
20
23
|
import { LocalSDKProvider } from "./LocalSDKProvider";
|
|
21
24
|
|
|
25
|
+
const NOTIFICATIONS_URL_BY_ENV = {
|
|
26
|
+
development: "https://dev-notifications.b3.fun",
|
|
27
|
+
production: "https://notifications.b3.fun",
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
22
30
|
/**
|
|
23
31
|
* Main B3Provider component
|
|
24
32
|
*/
|
|
@@ -29,7 +37,6 @@ export function B3Provider({
|
|
|
29
37
|
environment,
|
|
30
38
|
automaticallySetFirstEoa,
|
|
31
39
|
defaultEoaProvider,
|
|
32
|
-
simDuneApiKey,
|
|
33
40
|
// deprecated since v0.0.87
|
|
34
41
|
toaster: _toaster,
|
|
35
42
|
clientType = "rest",
|
|
@@ -45,6 +52,8 @@ export function B3Provider({
|
|
|
45
52
|
disableBSMNTAuthentication = false,
|
|
46
53
|
queryClient,
|
|
47
54
|
authStrategy = "thirdweb",
|
|
55
|
+
apiUrl,
|
|
56
|
+
notificationsApiUrl,
|
|
48
57
|
}: {
|
|
49
58
|
theme: "light" | "dark";
|
|
50
59
|
children: React.ReactNode;
|
|
@@ -53,7 +62,6 @@ export function B3Provider({
|
|
|
53
62
|
automaticallySetFirstEoa?: boolean;
|
|
54
63
|
/** EIP-1193 provider to auto-connect as the default EOA wallet (e.g., Farcaster frame wallet) */
|
|
55
64
|
defaultEoaProvider?: EIP1193.EIP1193Provider;
|
|
56
|
-
simDuneApiKey?: string;
|
|
57
65
|
toaster?: {
|
|
58
66
|
position?: "top-center" | "top-right" | "bottom-center" | "bottom-right";
|
|
59
67
|
style?: React.CSSProperties;
|
|
@@ -74,7 +82,35 @@ export function B3Provider({
|
|
|
74
82
|
queryClient?: QueryClient;
|
|
75
83
|
/** Auth strategy: "thirdweb" (default, ecosystem wallet) or "better-auth" (email/password via Better Auth) */
|
|
76
84
|
authStrategy?: AuthStrategy;
|
|
85
|
+
/**
|
|
86
|
+
* Override the B3 API URL. When provided, all SDK requests (auth, Feathers,
|
|
87
|
+
* BetterAuth) will use this URL instead of the `NEXT_PUBLIC_B3_API` env var.
|
|
88
|
+
*
|
|
89
|
+
* Useful for local development: pass `http://localhost:3031` to route
|
|
90
|
+
* OAuth callbacks and session checks through your local B3 API.
|
|
91
|
+
* If omitted, defaults to `NEXT_PUBLIC_B3_API` or `https://api.b3.fun`.
|
|
92
|
+
*/
|
|
93
|
+
apiUrl?: string;
|
|
94
|
+
/** Override the notifications worker URL. Defaults to `https://notifications.b3.fun`. */
|
|
95
|
+
notificationsApiUrl?: string;
|
|
77
96
|
}) {
|
|
97
|
+
// Override the B3 API URL when the `apiUrl` prop is provided.
|
|
98
|
+
// Must run before client initialization and auth providers mount.
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
setB3ApiUrl(apiUrl ?? null);
|
|
101
|
+
if (apiUrl) {
|
|
102
|
+
resetBetterAuthClient();
|
|
103
|
+
resetClients();
|
|
104
|
+
}
|
|
105
|
+
return () => {
|
|
106
|
+
setB3ApiUrl(null);
|
|
107
|
+
};
|
|
108
|
+
}, [apiUrl]);
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
setNotificationsApiUrl(notificationsApiUrl ?? NOTIFICATIONS_URL_BY_ENV[environment ?? "production"]);
|
|
112
|
+
}, [notificationsApiUrl, environment]);
|
|
113
|
+
|
|
78
114
|
// Initialize Google Analytics on mount
|
|
79
115
|
useEffect(() => {
|
|
80
116
|
loadGA4Script();
|
|
@@ -112,7 +148,7 @@ export function B3Provider({
|
|
|
112
148
|
authStrategy={authStrategy}
|
|
113
149
|
>
|
|
114
150
|
<ToastContextConnector />
|
|
115
|
-
<RelayKitProviderWrapper
|
|
151
|
+
<RelayKitProviderWrapper>
|
|
116
152
|
{children}
|
|
117
153
|
{/* For the modal https://github.com/b3-fun/b3/blob/main/packages/sdk/src/global-account/react/components/ui/dialog.tsx#L46 */}
|
|
118
154
|
<StyleRoot id="b3-root" />
|