@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,11 +0,0 @@
|
|
|
1
|
-
import { Chain } from "thirdweb";
|
|
2
|
-
import { Account } from "thirdweb/wallets";
|
|
3
|
-
/**
|
|
4
|
-
* This essentially wraps our useConnect hook to handle the Privy auth flow.
|
|
5
|
-
* Currently, this is for the basement-privy strategy
|
|
6
|
-
*/
|
|
7
|
-
export declare function useHandleConnectWithPrivy(chain?: Chain, onSuccess?: (account: Account) => void): {
|
|
8
|
-
connectTw: () => Promise<import("thirdweb/wallets").Wallet | null | undefined>;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
fullToken: string | null;
|
|
11
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export interface SimTokenMetadata {
|
|
2
|
-
logo?: string;
|
|
3
|
-
}
|
|
4
|
-
export interface SimBalanceItem {
|
|
5
|
-
chain: string;
|
|
6
|
-
chain_id: number;
|
|
7
|
-
address: string;
|
|
8
|
-
amount: string;
|
|
9
|
-
symbol: string;
|
|
10
|
-
decimals: number;
|
|
11
|
-
price_usd?: number;
|
|
12
|
-
value_usd?: number;
|
|
13
|
-
name?: string;
|
|
14
|
-
token_metadata?: SimTokenMetadata;
|
|
15
|
-
pool_size?: number;
|
|
16
|
-
low_liquidity?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export interface SimBalanceResponse {
|
|
19
|
-
request_time: string;
|
|
20
|
-
response_time: string;
|
|
21
|
-
wallet_address: string;
|
|
22
|
-
balances: SimBalanceItem[];
|
|
23
|
-
}
|
|
24
|
-
export interface SvmBalanceItem {
|
|
25
|
-
chain: string;
|
|
26
|
-
address: string;
|
|
27
|
-
amount: string;
|
|
28
|
-
balance: string;
|
|
29
|
-
raw_balance: string;
|
|
30
|
-
value_usd?: number;
|
|
31
|
-
program_id: string | null;
|
|
32
|
-
decimals: number;
|
|
33
|
-
total_supply: string;
|
|
34
|
-
metadata_address?: string;
|
|
35
|
-
name?: string;
|
|
36
|
-
symbol: string;
|
|
37
|
-
uri?: string | null;
|
|
38
|
-
price_usd?: number;
|
|
39
|
-
liquidity_usd?: number;
|
|
40
|
-
pool_type?: string | null;
|
|
41
|
-
pool_address?: string | null;
|
|
42
|
-
mint_authority?: string | null;
|
|
43
|
-
}
|
|
44
|
-
export interface SvmBalanceResponse {
|
|
45
|
-
processing_time_ms?: number;
|
|
46
|
-
wallet_address: string;
|
|
47
|
-
next_offset?: string;
|
|
48
|
-
balances_count?: number;
|
|
49
|
-
balances: SvmBalanceItem[];
|
|
50
|
-
}
|
|
51
|
-
export declare function useSimBalance(address?: string, chainIdsParam?: number[]): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
|
|
52
|
-
export declare function useSimSvmBalance(address?: string, chains?: ("solana" | "eclipse")[], limit?: number): import("@tanstack/react-query").UseQueryResult<SvmBalanceResponse, Error>;
|
|
53
|
-
/**
|
|
54
|
-
* Hook to fetch a single token balance for a wallet.
|
|
55
|
-
* @param walletAddress - The wallet address to fetch balance for
|
|
56
|
-
* @param tokenAddress - The token contract address, or "native" for native token (ETH, etc.)
|
|
57
|
-
* @param chainId - Chain ID to query (defaults to 1 for Ethereum mainnet)
|
|
58
|
-
*/
|
|
59
|
-
export declare function useSimTokenBalance(walletAddress?: string, tokenAddress?: string, chainId?: number): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { SimpleHashNFTResponse } from "@b3dotfun/sdk/global-account/types/simplehash.types";
|
|
2
|
-
export interface SimCollectibleMetadata {
|
|
3
|
-
uri: string;
|
|
4
|
-
attributes?: Array<{
|
|
5
|
-
trait_type: string;
|
|
6
|
-
value: string;
|
|
7
|
-
display_type?: string | null;
|
|
8
|
-
}>;
|
|
9
|
-
}
|
|
10
|
-
export interface SimCollectibleEntry {
|
|
11
|
-
contract_address: string;
|
|
12
|
-
token_standard: "ERC721" | "ERC1155";
|
|
13
|
-
token_id: string;
|
|
14
|
-
chain: string;
|
|
15
|
-
chain_id: number;
|
|
16
|
-
name?: string;
|
|
17
|
-
description?: string;
|
|
18
|
-
symbol?: string;
|
|
19
|
-
image_url?: string;
|
|
20
|
-
last_sale_price?: string;
|
|
21
|
-
metadata?: SimCollectibleMetadata;
|
|
22
|
-
is_spam?: boolean;
|
|
23
|
-
spam_score?: number;
|
|
24
|
-
explanations?: string[];
|
|
25
|
-
balance?: string;
|
|
26
|
-
last_acquired?: string;
|
|
27
|
-
}
|
|
28
|
-
export interface SimCollectiblesResponse {
|
|
29
|
-
address: string;
|
|
30
|
-
entries: SimCollectibleEntry[];
|
|
31
|
-
next_offset?: string;
|
|
32
|
-
request_time: string;
|
|
33
|
-
response_time: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Hook to fetch NFT collectibles from Simdune API.
|
|
37
|
-
* Returns data in SimpleHash format for compatibility with AccountAssets component.
|
|
38
|
-
* @param address - Wallet address to fetch collectibles for
|
|
39
|
-
* @param chainIdsParam - Optional array of chain IDs to filter by
|
|
40
|
-
* @param options - Optional parameters (limit, filterSpam)
|
|
41
|
-
*/
|
|
42
|
-
export declare function useSimCollectibles(address?: string, chainIdsParam?: number[], options?: {
|
|
43
|
-
limit?: number;
|
|
44
|
-
filterSpam?: boolean;
|
|
45
|
-
}): import("@tanstack/react-query").UseQueryResult<SimpleHashNFTResponse, Error>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const SIMDUNE_API_HOST = "https://simdune-api.sean-430.workers.dev";
|
|
2
|
-
/**
|
|
3
|
-
* Builds a Simdune API URL with the proxy wrapper and optional dev mode key.
|
|
4
|
-
* @param endpoint - The Simdune API endpoint (e.g., "/v1/evm/balances/0x...")
|
|
5
|
-
* @param queryParams - Optional URLSearchParams to append
|
|
6
|
-
*/
|
|
7
|
-
export declare function buildSimduneUrl(endpoint: string, queryParams?: URLSearchParams): string;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Static } from "@feathersjs/typebox";
|
|
2
|
-
export declare const chainNetworksSchema: import("@feathersjs/typebox").TObject<{
|
|
3
|
-
_id: import("@feathersjs/typebox").TUnion<[import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TObject<{}>]>;
|
|
4
|
-
id: import("@feathersjs/typebox").TInteger;
|
|
5
|
-
name: import("@feathersjs/typebox").TString<string>;
|
|
6
|
-
rpcUrls: import("@feathersjs/typebox").TObject<{
|
|
7
|
-
default: import("@feathersjs/typebox").TObject<{
|
|
8
|
-
http: import("@feathersjs/typebox").TString<"uri">;
|
|
9
|
-
ws: import("@feathersjs/typebox").TString<"uri">;
|
|
10
|
-
}>;
|
|
11
|
-
backups: import("@feathersjs/typebox").TArray<import("@feathersjs/typebox").TObject<{
|
|
12
|
-
type: import("@feathersjs/typebox").TUnion<[import("@feathersjs/typebox").TLiteral<"http">, import("@feathersjs/typebox").TLiteral<"ws">]>;
|
|
13
|
-
uri: import("@feathersjs/typebox").TString<string>;
|
|
14
|
-
}>>;
|
|
15
|
-
}>;
|
|
16
|
-
icon: import("@feathersjs/typebox").TObject<{
|
|
17
|
-
url: import("@feathersjs/typebox").TString<"uri">;
|
|
18
|
-
width: import("@feathersjs/typebox").TInteger;
|
|
19
|
-
height: import("@feathersjs/typebox").TInteger;
|
|
20
|
-
format: import("@feathersjs/typebox").TString<string>;
|
|
21
|
-
}>;
|
|
22
|
-
blockExplorers: import("@feathersjs/typebox").TObject<{
|
|
23
|
-
explorerTitle: import("@feathersjs/typebox").TString<string>;
|
|
24
|
-
default: import("@feathersjs/typebox").TString<"uri">;
|
|
25
|
-
}>;
|
|
26
|
-
nativeCurrency: import("@feathersjs/typebox").TObject<{
|
|
27
|
-
name: import("@feathersjs/typebox").TString<string>;
|
|
28
|
-
symbol: import("@feathersjs/typebox").TString<string>;
|
|
29
|
-
decimals: import("@feathersjs/typebox").TInteger;
|
|
30
|
-
}>;
|
|
31
|
-
testnet: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TBoolean>;
|
|
32
|
-
testnetConfigID: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TInteger>;
|
|
33
|
-
sourceId: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TInteger>;
|
|
34
|
-
contracts: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TRecord<import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TObject<{
|
|
35
|
-
address: import("@feathersjs/typebox").TString<string>;
|
|
36
|
-
blockCreated: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TInteger>;
|
|
37
|
-
}>>>;
|
|
38
|
-
formatters: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TRecord<import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TAny>>;
|
|
39
|
-
fees: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TRecord<import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TAny>>;
|
|
40
|
-
badge: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TString<"uri">>;
|
|
41
|
-
color: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TString<string>>;
|
|
42
|
-
enabledFeatures: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TArray<import("@feathersjs/typebox").TString<string>>>;
|
|
43
|
-
}>;
|
|
44
|
-
export type ChainNetworks = Static<typeof chainNetworksSchema>;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Loading,
|
|
3
|
-
useAuthentication,
|
|
4
|
-
useAuthStore,
|
|
5
|
-
useB3Config,
|
|
6
|
-
useHandleConnectWithPrivy,
|
|
7
|
-
} from "@b3dotfun/sdk/global-account/react";
|
|
8
|
-
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
9
|
-
import { useEffect } from "react";
|
|
10
|
-
import type { Chain } from "thirdweb";
|
|
11
|
-
import { Account } from "thirdweb/wallets";
|
|
12
|
-
|
|
13
|
-
const debug = debugB3React("SignInWithB3Privy");
|
|
14
|
-
interface SignInWithB3PrivyProps {
|
|
15
|
-
onError?: (error: Error) => Promise<void>;
|
|
16
|
-
onSuccess: (account: Account) => Promise<void>;
|
|
17
|
-
accessToken?: string;
|
|
18
|
-
chain: Chain;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function SignInWithB3Privy({ onSuccess, onError, chain }: SignInWithB3PrivyProps) {
|
|
22
|
-
const { partnerId } = useB3Config();
|
|
23
|
-
const { isLoading, connectTw, fullToken } = useHandleConnectWithPrivy(chain, onSuccess);
|
|
24
|
-
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
25
|
-
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
26
|
-
const { logout } = useAuthentication(partnerId, { skipAutoConnect: true });
|
|
27
|
-
|
|
28
|
-
debug("@@SignInWithB3Privy", {
|
|
29
|
-
isLoading,
|
|
30
|
-
fullToken,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
async function autoConnect() {
|
|
35
|
-
try {
|
|
36
|
-
const connectResult = await connectTw();
|
|
37
|
-
const account = connectResult?.getAccount();
|
|
38
|
-
if (!account) {
|
|
39
|
-
setIsAuthenticated(false);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
await onSuccess(account);
|
|
43
|
-
setIsAuthenticated(true);
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error("Failed to connect:", error);
|
|
46
|
-
await onError?.(error as Error);
|
|
47
|
-
await logout();
|
|
48
|
-
setIsAuthenticated(false);
|
|
49
|
-
} finally {
|
|
50
|
-
debug("setIsAuthenticating:false:7");
|
|
51
|
-
setIsAuthenticating(false);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
autoConnect();
|
|
55
|
-
}, [connectTw, onSuccess, onError, setIsAuthenticated, logout, setIsAuthenticating]);
|
|
56
|
-
|
|
57
|
-
// Currently we auto login, so we can show loading immediately and the onSuccess will proceed to the next modal
|
|
58
|
-
return (
|
|
59
|
-
<div className="flex aspect-square items-center justify-center p-6">
|
|
60
|
-
<Loading variant="white" size="lg" />
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { useB3Config, useConnect } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
-
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
|
-
import { useIdentityToken, usePrivy } from "@privy-io/react-auth";
|
|
4
|
-
import { useCallback, useRef, useState } from "react";
|
|
5
|
-
import { Chain } from "thirdweb";
|
|
6
|
-
import { Account } from "thirdweb/wallets";
|
|
7
|
-
const debug = debugB3React("@@b3:useHandleConnectWithPrivy");
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* This essentially wraps our useConnect hook to handle the Privy auth flow.
|
|
11
|
-
* Currently, this is for the basement-privy strategy
|
|
12
|
-
*/
|
|
13
|
-
export function useHandleConnectWithPrivy(chain?: Chain, onSuccess?: (account: Account) => void) {
|
|
14
|
-
const { partnerId } = useB3Config();
|
|
15
|
-
if (!chain) {
|
|
16
|
-
throw new Error("Chain is required");
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const { connect } = useConnect(partnerId, chain);
|
|
20
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
21
|
-
const isConnecting = useRef(false);
|
|
22
|
-
const { identityToken } = useIdentityToken();
|
|
23
|
-
const { getAccessToken } = usePrivy();
|
|
24
|
-
const [fullToken, setFullToken] = useState<string | null>(null);
|
|
25
|
-
|
|
26
|
-
const connectTw = useCallback(async () => {
|
|
27
|
-
if (isConnecting.current) {
|
|
28
|
-
debug("@@connectTw:skipping:isConnecting", isConnecting.current);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
setIsLoading(true);
|
|
32
|
-
isConnecting.current = true;
|
|
33
|
-
|
|
34
|
-
// Form token
|
|
35
|
-
const accessToken = await getAccessToken();
|
|
36
|
-
const fullToken = `${accessToken}+${identityToken}`;
|
|
37
|
-
setFullToken(fullToken);
|
|
38
|
-
debug("@@connectTw:fullToken", fullToken);
|
|
39
|
-
if (!fullToken) throw new Error("Token is not set");
|
|
40
|
-
|
|
41
|
-
// Connect to TW via privy
|
|
42
|
-
const wallet = await connect({
|
|
43
|
-
strategy: "auth_endpoint",
|
|
44
|
-
payload: JSON.stringify({
|
|
45
|
-
strategy: "basement",
|
|
46
|
-
accessToken: fullToken,
|
|
47
|
-
}),
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
debug("@@useHandleConnectWithPrivy:connect:return", wallet);
|
|
51
|
-
setIsLoading(false);
|
|
52
|
-
|
|
53
|
-
// Handle onsuccess & more
|
|
54
|
-
try {
|
|
55
|
-
debug("@@autoLogin:starting", fullToken);
|
|
56
|
-
|
|
57
|
-
const account = wallet?.getAccount();
|
|
58
|
-
|
|
59
|
-
if (!account) {
|
|
60
|
-
throw new Error("Failed to connect");
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
onSuccess?.(account);
|
|
64
|
-
|
|
65
|
-
if (!account) {
|
|
66
|
-
throw new Error("Failed to connect");
|
|
67
|
-
}
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error("@@Error signing in with Privy", error);
|
|
70
|
-
} finally {
|
|
71
|
-
isConnecting.current = false;
|
|
72
|
-
setIsLoading(false);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return wallet;
|
|
76
|
-
}, [connect, getAccessToken, identityToken, onSuccess]);
|
|
77
|
-
|
|
78
|
-
return { connectTw, isLoading, fullToken };
|
|
79
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { useQuery } from "@tanstack/react-query";
|
|
2
|
-
import { buildSimduneUrl } from "../utils/simdune";
|
|
3
|
-
|
|
4
|
-
export interface SimTokenMetadata {
|
|
5
|
-
logo?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface SimBalanceItem {
|
|
9
|
-
chain: string;
|
|
10
|
-
chain_id: number;
|
|
11
|
-
address: string;
|
|
12
|
-
amount: string;
|
|
13
|
-
symbol: string;
|
|
14
|
-
decimals: number;
|
|
15
|
-
price_usd?: number;
|
|
16
|
-
value_usd?: number;
|
|
17
|
-
name?: string;
|
|
18
|
-
token_metadata?: SimTokenMetadata;
|
|
19
|
-
pool_size?: number;
|
|
20
|
-
low_liquidity?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface SimBalanceResponse {
|
|
24
|
-
request_time: string;
|
|
25
|
-
response_time: string;
|
|
26
|
-
wallet_address: string;
|
|
27
|
-
balances: SimBalanceItem[];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// SVM-specific types
|
|
31
|
-
export interface SvmBalanceItem {
|
|
32
|
-
chain: string;
|
|
33
|
-
address: string;
|
|
34
|
-
amount: string;
|
|
35
|
-
balance: string;
|
|
36
|
-
raw_balance: string;
|
|
37
|
-
value_usd?: number;
|
|
38
|
-
program_id: string | null;
|
|
39
|
-
decimals: number;
|
|
40
|
-
total_supply: string;
|
|
41
|
-
metadata_address?: string;
|
|
42
|
-
name?: string;
|
|
43
|
-
symbol: string;
|
|
44
|
-
uri?: string | null;
|
|
45
|
-
price_usd?: number;
|
|
46
|
-
liquidity_usd?: number;
|
|
47
|
-
pool_type?: string | null;
|
|
48
|
-
pool_address?: string | null;
|
|
49
|
-
mint_authority?: string | null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface SvmBalanceResponse {
|
|
53
|
-
processing_time_ms?: number;
|
|
54
|
-
wallet_address: string;
|
|
55
|
-
next_offset?: string;
|
|
56
|
-
balances_count?: number;
|
|
57
|
-
balances: SvmBalanceItem[];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async function fetchSimBalance(address: string, chainIdsParam: number[]): Promise<SimBalanceResponse> {
|
|
61
|
-
if (!address) throw new Error("Address is required");
|
|
62
|
-
|
|
63
|
-
const chainIds = chainIdsParam.length === 0 ? "mainnet" : chainIdsParam.join(",");
|
|
64
|
-
const queryParams = new URLSearchParams();
|
|
65
|
-
queryParams.append("metadata", "logo");
|
|
66
|
-
queryParams.append("chain_ids", chainIds);
|
|
67
|
-
queryParams.append("exclude_spam_tokens", "true");
|
|
68
|
-
|
|
69
|
-
const url = buildSimduneUrl(`/v1/evm/balances/${address}`, queryParams);
|
|
70
|
-
const response = await fetch(url);
|
|
71
|
-
|
|
72
|
-
if (!response.ok) {
|
|
73
|
-
throw new Error(`Failed to fetch balance: ${response.statusText}`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const balanceData: SimBalanceResponse = await response.json();
|
|
77
|
-
return balanceData;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async function fetchSimTokenBalance(
|
|
81
|
-
walletAddress: string,
|
|
82
|
-
tokenAddress: string,
|
|
83
|
-
chainId: number,
|
|
84
|
-
): Promise<SimBalanceResponse> {
|
|
85
|
-
if (!walletAddress) throw new Error("Wallet address is required");
|
|
86
|
-
if (!tokenAddress) throw new Error("Token address is required");
|
|
87
|
-
if (!chainId) throw new Error("Chain ID is required");
|
|
88
|
-
|
|
89
|
-
const queryParams = new URLSearchParams();
|
|
90
|
-
queryParams.append("chain_ids", chainId.toString());
|
|
91
|
-
|
|
92
|
-
const url = buildSimduneUrl(`/v1/evm/balances/${walletAddress}/token/${tokenAddress}`, queryParams);
|
|
93
|
-
const response = await fetch(url);
|
|
94
|
-
|
|
95
|
-
if (!response.ok) {
|
|
96
|
-
throw new Error(`Failed to fetch token balance: ${response.statusText}`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const balanceData: SimBalanceResponse = await response.json();
|
|
100
|
-
return balanceData;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async function fetchSimSvmBalance(address: string, chains?: string[], limit?: number): Promise<SvmBalanceResponse> {
|
|
104
|
-
if (!address) throw new Error("Address is required");
|
|
105
|
-
|
|
106
|
-
const queryParams = new URLSearchParams();
|
|
107
|
-
if (chains && chains.length > 0) {
|
|
108
|
-
queryParams.append("chains", chains.join(","));
|
|
109
|
-
}
|
|
110
|
-
if (limit) {
|
|
111
|
-
queryParams.append("limit", limit.toString());
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const url = buildSimduneUrl(`/beta/svm/balances/${address}`, queryParams.toString() ? queryParams : undefined);
|
|
115
|
-
const response = await fetch(url);
|
|
116
|
-
|
|
117
|
-
if (!response.ok) {
|
|
118
|
-
throw new Error(`Failed to fetch SVM balance: ${response.statusText}`);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const balanceData: SvmBalanceResponse = await response.json();
|
|
122
|
-
return balanceData;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function useSimBalance(address?: string, chainIdsParam?: number[]) {
|
|
126
|
-
return useQuery({
|
|
127
|
-
queryKey: ["simBalance", address, chainIdsParam],
|
|
128
|
-
queryFn: () => {
|
|
129
|
-
if (!address) throw new Error("Address is required");
|
|
130
|
-
return fetchSimBalance(address, chainIdsParam || []);
|
|
131
|
-
},
|
|
132
|
-
enabled: Boolean(address),
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function useSimSvmBalance(address?: string, chains?: ("solana" | "eclipse")[], limit?: number) {
|
|
137
|
-
return useQuery({
|
|
138
|
-
queryKey: ["svmBalance", address, chains, limit],
|
|
139
|
-
queryFn: () => {
|
|
140
|
-
if (!address) throw new Error("Address is required");
|
|
141
|
-
return fetchSimSvmBalance(address, chains, limit);
|
|
142
|
-
},
|
|
143
|
-
enabled: Boolean(address),
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Hook to fetch a single token balance for a wallet.
|
|
149
|
-
* @param walletAddress - The wallet address to fetch balance for
|
|
150
|
-
* @param tokenAddress - The token contract address, or "native" for native token (ETH, etc.)
|
|
151
|
-
* @param chainId - Chain ID to query (defaults to 1 for Ethereum mainnet)
|
|
152
|
-
*/
|
|
153
|
-
export function useSimTokenBalance(walletAddress?: string, tokenAddress?: string, chainId?: number) {
|
|
154
|
-
return useQuery({
|
|
155
|
-
queryKey: ["simTokenBalance", walletAddress, tokenAddress, chainId],
|
|
156
|
-
queryFn: () => {
|
|
157
|
-
if (!walletAddress || !tokenAddress || !chainId) {
|
|
158
|
-
throw new Error("Missing required parameters");
|
|
159
|
-
}
|
|
160
|
-
return fetchSimTokenBalance(walletAddress, tokenAddress, chainId);
|
|
161
|
-
},
|
|
162
|
-
enabled: Boolean(walletAddress) && Boolean(tokenAddress),
|
|
163
|
-
});
|
|
164
|
-
}
|