@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
|
@@ -52,11 +52,11 @@ export const b3Testnet = defineChain({
|
|
|
52
52
|
export const b3Mainnet = defineChain({
|
|
53
53
|
id: 8333,
|
|
54
54
|
name: "B3",
|
|
55
|
-
rpc: "https://
|
|
55
|
+
rpc: "https://mainnet-rpc.b3.fun",
|
|
56
56
|
rpcUrls: {
|
|
57
57
|
default: {
|
|
58
|
-
http: ["https://
|
|
59
|
-
ws: ["wss://
|
|
58
|
+
http: ["https://mainnet-rpc.b3.fun"],
|
|
59
|
+
ws: ["wss://mainnet-rpc.b3.fun/ws"],
|
|
60
60
|
},
|
|
61
61
|
},
|
|
62
62
|
icon: {
|
|
@@ -77,26 +77,6 @@ export const b3Mainnet = defineChain({
|
|
|
77
77
|
decimals: 18,
|
|
78
78
|
},
|
|
79
79
|
});
|
|
80
|
-
export const getViemChainConfig = (config) => defineChain({
|
|
81
|
-
id: config.id,
|
|
82
|
-
name: config.name,
|
|
83
|
-
rpc: config.rpcUrls.default.http,
|
|
84
|
-
rpcUrls: {
|
|
85
|
-
default: {
|
|
86
|
-
http: [config.rpcUrls.default.http],
|
|
87
|
-
ws: [config.rpcUrls.default.ws],
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
icon: config.icon,
|
|
91
|
-
blockExplorers: {
|
|
92
|
-
default: {
|
|
93
|
-
name: config.blockExplorers.explorerTitle,
|
|
94
|
-
url: config.blockExplorers.default,
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
nativeCurrency: config.nativeCurrency,
|
|
98
|
-
testnet: config.testnet ? true : undefined,
|
|
99
|
-
});
|
|
100
80
|
export const thirdwebB3Testnet = defineThirdwebChain({
|
|
101
81
|
id: 1993,
|
|
102
82
|
name: "B3 Sepolia",
|
|
@@ -123,7 +103,7 @@ export const thirdwebB3Testnet = defineThirdwebChain({
|
|
|
123
103
|
export const thirdwebB3Mainnet = defineThirdwebChain({
|
|
124
104
|
id: 8333,
|
|
125
105
|
name: "B3",
|
|
126
|
-
rpc: "https://
|
|
106
|
+
rpc: "https://mainnet-rpc.b3.fun",
|
|
127
107
|
icon: {
|
|
128
108
|
url: "https://cdn.b3.fun/b3_logo.svg",
|
|
129
109
|
width: 32,
|
|
@@ -142,20 +122,6 @@ export const thirdwebB3Mainnet = defineThirdwebChain({
|
|
|
142
122
|
decimals: 18,
|
|
143
123
|
},
|
|
144
124
|
});
|
|
145
|
-
export const getThirdwebChainConfig = (config) => defineThirdwebChain({
|
|
146
|
-
id: config.id,
|
|
147
|
-
name: config.name,
|
|
148
|
-
rpc: config.rpcUrls.default.http,
|
|
149
|
-
icon: config.icon,
|
|
150
|
-
blockExplorers: [
|
|
151
|
-
{
|
|
152
|
-
name: config.blockExplorers.explorerTitle,
|
|
153
|
-
url: config.blockExplorers.default,
|
|
154
|
-
},
|
|
155
|
-
],
|
|
156
|
-
nativeCurrency: config.nativeCurrency,
|
|
157
|
-
testnet: config.testnet ? true : undefined,
|
|
158
|
-
});
|
|
159
125
|
export const b3Chain = process.env.NEXT_PUBLIC_B3_CHAINID === "8333" ? b3Mainnet : b3Testnet;
|
|
160
126
|
export const thirdwebB3Chain = process.env.NEXT_PUBLIC_B3_CHAINID === "8333" ? thirdwebB3Mainnet : thirdwebB3Testnet;
|
|
161
127
|
export const b3Mask = "polygon( 2.209% 8.111%,2.211% 8.08%,2.212% 8.05%,2.212% 8.05%,2.238% 7.434%,2.295% 6.861%,2.382% 6.331%,2.498% 5.841%,2.644% 5.39%,2.817% 4.976%,3.018% 4.598%,3.247% 4.255%,3.502% 3.943%,3.783% 3.664%,3.783% 3.664%,4.107% 3.401%,4.464% 3.165%,4.857% 2.956%,5.285% 2.774%,5.749% 2.62%,6.249% 2.493%,6.786% 2.394%,7.361% 2.323%,7.974% 2.28%,8.625% 2.266%,8.642% 2.266%,8.66% 2.265%,8.66% 2.265%,16.702% 1.748%,24.751% 1.345%,32.805% 1.053%,40.864% 0.872%,48.924% 0.801%,56.984% 0.836%,65.044% 0.977%,73.101% 1.223%,81.153% 1.571%,89.2% 2.02%,89.2% 2.02%,89.394% 2.037%,89.59% 2.052%,89.789% 2.067%,89.989% 2.08%,90.19% 2.093%,90.393% 2.105%,90.596% 2.117%,90.8% 2.128%,91.004% 2.139%,91.207% 2.15%,91.207% 2.15%,91.357% 2.158%,91.506% 2.166%,91.655% 2.174%,91.803% 2.182%,91.95% 2.19%,92.097% 2.199%,92.242% 2.208%,92.386% 2.217%,92.529% 2.227%,92.67% 2.237%,92.67% 2.237%,93.011% 2.264%,93.347% 2.294%,93.677% 2.329%,94.002% 2.369%,94.321% 2.414%,94.634% 2.466%,94.94% 2.525%,95.239% 2.592%,95.53% 2.667%,95.813% 2.751%,95.813% 2.751%,96.087% 2.844%,96.349% 2.947%,96.6% 3.059%,96.839% 3.181%,97.066% 3.314%,97.282% 3.457%,97.485% 3.612%,97.676% 3.779%,97.855% 3.957%,98.021% 4.148%,98.021% 4.148%,98.172% 4.349%,98.313% 4.567%,98.444% 4.802%,98.563% 5.057%,98.67% 5.332%,98.764% 5.628%,98.845% 5.947%,98.912% 6.289%,98.964% 6.656%,99.001% 7.048%,99.002% 7.052%,99.002% 7.056%,99.002% 7.056%,99.127% 8.717%,99.245% 10.378%,99.355% 12.04%,99.46% 13.703%,99.56% 15.367%,99.654% 17.032%,99.745% 18.697%,99.832% 20.363%,99.917% 22.029%,100% 23.696%,100% 23.696%,100.219% 29.737%,100.382% 35.779%,100.489% 41.822%,100.539% 47.865%,100.534% 53.909%,100.472% 59.953%,100.353% 65.996%,100.179% 72.037%,99.947% 78.077%,99.659% 84.114%,99.659% 84.114%,99.655% 84.186%,99.651% 84.259%,99.646% 84.331%,99.642% 84.404%,99.637% 84.476%,99.633% 84.549%,99.629% 84.621%,99.624% 84.693%,99.615% 84.838%,99.615% 84.838%,99.565% 85.657%,99.515% 86.476%,99.464% 87.294%,99.412% 88.111%,99.36% 88.929%,99.306% 89.746%,99.251% 90.562%,99.194% 91.378%,99.135% 92.194%,99.074% 93.01%,99.072% 93.031%,99.071% 93.052%,99.071% 93.052%,99.049% 93.479%,99.012% 93.894%,98.959% 94.296%,98.89% 94.686%,98.805% 95.062%,98.702% 95.422%,98.582% 95.768%,98.444% 96.096%,98.288% 96.408%,98.113% 96.701%,98.113% 96.701%,97.92% 96.974%,97.703% 97.232%,97.461% 97.475%,97.194% 97.699%,96.898% 97.904%,96.574% 98.088%,96.219% 98.249%,95.833% 98.385%,95.414% 98.495%,94.961% 98.577%,94.961% 98.577%,92.494% 98.801%,90.025% 98.998%,87.553% 99.171%,85.079% 99.324%,82.604% 99.46%,80.126% 99.58%,77.648% 99.689%,75.169% 99.79%,72.689% 99.884%,70.208% 99.975%,69.528% 100%,69.528% 100%,69.528% 100%,69.528% 100%,69.528% 100%,69.528% 100%,69.528% 100%,69.527% 100%,69.527% 100%,69.527% 100%,69.527% 100%,63.379% 100.153%,57.23% 100.245%,51.081% 100.277%,44.931% 100.248%,38.783% 100.158%,32.635% 100.006%,26.489% 99.792%,20.346% 99.515%,14.205% 99.176%,8.068% 98.774%,8.058% 98.773%,8.048% 98.773%,8.048% 98.773%,7.501% 98.746%,6.992% 98.698%,6.518% 98.63%,6.079% 98.545%,5.673% 98.441%,5.299% 98.321%,4.956% 98.186%,4.641% 98.036%,4.354% 97.873%,4.094% 97.697%,4.094% 97.697%,3.862% 97.513%,3.65% 97.317%,3.457% 97.108%,3.281% 96.887%,3.123% 96.654%,2.98% 96.409%,2.852% 96.152%,2.737% 95.884%,2.635% 95.605%,2.545% 95.314%,2.545% 95.314%,2.463% 95.004%,2.391% 94.682%,2.329% 94.349%,2.276% 94.006%,2.23% 93.651%,2.192% 93.286%,2.159% 92.911%,2.131% 92.525%,2.106% 92.129%,2.085% 91.722%,2.085% 91.722%,2.081% 91.635%,2.077% 91.548%,2.073% 91.46%,2.069% 91.371%,2.066% 91.282%,2.062% 91.193%,2.058% 91.103%,2.054% 91.013%,2.051% 90.923%,2.047% 90.832%,2.047% 90.832%,2.033% 90.503%,2.019% 90.171%,2.003% 89.835%,1.986% 89.496%,1.966% 89.156%,1.944% 88.814%,1.918% 88.471%,1.889% 88.127%,1.855% 87.785%,1.817% 87.443%,1.817% 87.443%,1.594% 83.762%,1.403% 80.079%,1.241% 76.394%,1.104% 72.707%,0.99% 69.019%,0.894% 65.329%,0.813% 61.638%,0.744% 57.946%,0.682% 54.254%,0.626% 50.561%,0.626% 50.561%,0.637% 49.992%,0.648% 49.423%,0.659% 48.854%,0.67% 48.286%,0.681% 47.717%,0.692% 47.148%,0.703% 46.58%,0.713% 46.011%,0.724% 45.443%,0.734% 44.874%,0.734% 44.874%,0.782% 42.326%,0.831% 39.779%,0.884% 37.232%,0.941% 34.685%,1.006% 32.14%,1.078% 29.595%,1.161% 27.051%,1.255% 24.508%,1.363% 21.965%,1.485% 19.424%,1.485% 19.424%,1.493% 19.294%,1.5% 19.165%,1.508% 19.035%,1.515% 18.906%,1.523% 18.776%,1.531% 18.647%,1.538% 18.517%,1.546% 18.388%,1.553% 18.258%,1.561% 18.129%,1.561% 18.129%,1.619% 17.124%,1.678% 16.121%,1.737% 15.118%,1.798% 14.116%,1.86% 13.114%,1.925% 12.113%,1.991% 11.112%,2.06% 10.111%,2.133% 9.111%,2.209% 8.111% )";
|
|
@@ -1,48 +1,7 @@
|
|
|
1
1
|
import type { Chain as ThirdwebChain } from "thirdweb";
|
|
2
2
|
export declare const supportedChains: import("viem").Chain[];
|
|
3
3
|
export declare const supportedChainsTW: ThirdwebChain[];
|
|
4
|
-
export declare const supportedChainNetworks:
|
|
5
|
-
formatters?: Record<string, any> | undefined;
|
|
6
|
-
contracts?: Record<string, {
|
|
7
|
-
blockCreated?: number | undefined;
|
|
8
|
-
address: string;
|
|
9
|
-
}> | undefined;
|
|
10
|
-
sourceId?: number | undefined;
|
|
11
|
-
testnet?: boolean | undefined;
|
|
12
|
-
fees?: Record<string, any> | undefined;
|
|
13
|
-
color?: string | undefined;
|
|
14
|
-
testnetConfigID?: number | undefined;
|
|
15
|
-
badge?: string | undefined;
|
|
16
|
-
enabledFeatures?: string[] | undefined;
|
|
17
|
-
blockExplorers: {
|
|
18
|
-
default: string;
|
|
19
|
-
explorerTitle: string;
|
|
20
|
-
};
|
|
21
|
-
id: number;
|
|
22
|
-
name: string;
|
|
23
|
-
nativeCurrency: {
|
|
24
|
-
symbol: string;
|
|
25
|
-
name: string;
|
|
26
|
-
decimals: number;
|
|
27
|
-
};
|
|
28
|
-
rpcUrls: {
|
|
29
|
-
default: {
|
|
30
|
-
http: string;
|
|
31
|
-
ws: string;
|
|
32
|
-
};
|
|
33
|
-
backups: {
|
|
34
|
-
type: "http" | "ws";
|
|
35
|
-
uri: string;
|
|
36
|
-
}[];
|
|
37
|
-
};
|
|
38
|
-
_id: string | {};
|
|
39
|
-
icon: {
|
|
40
|
-
format: string;
|
|
41
|
-
url: string;
|
|
42
|
-
width: number;
|
|
43
|
-
height: number;
|
|
44
|
-
};
|
|
45
|
-
}[];
|
|
4
|
+
export declare const supportedChainNetworks: import("@b3/chain-registry/runtime").ChainDefinition[];
|
|
46
5
|
export declare const coingeckoChains: Record<number, {
|
|
47
6
|
coingecko_id: string;
|
|
48
7
|
name: string;
|
|
@@ -56,14 +15,7 @@ export declare function getCoingeckoChainInfo(chainId: number): {
|
|
|
56
15
|
export declare const b3MainnetThirdWeb: Readonly<import("thirdweb/chains").ChainOptions & {
|
|
57
16
|
rpc: string;
|
|
58
17
|
}>;
|
|
59
|
-
export declare const b3TestnetThirdWeb: Readonly<import("thirdweb/chains").ChainOptions & {
|
|
60
|
-
rpc: string;
|
|
61
|
-
}>;
|
|
62
18
|
export declare const b3Mainnet: import("viem").Chain;
|
|
63
|
-
export declare const b3Testnet: import("viem").Chain;
|
|
64
19
|
export declare const baseMainnet: import("viem").Chain;
|
|
65
|
-
/**
|
|
66
|
-
* Get a Thirdweb chain by chain ID from supportedChainsTW
|
|
67
|
-
*/
|
|
68
20
|
export declare function getThirdwebChain(chainId: number): ThirdwebChain;
|
|
69
21
|
export declare function getChainLogo(chainId: number): string;
|
|
@@ -1,53 +1,25 @@
|
|
|
1
|
+
import { ANYSPEND_EVM_CHAINS } from "@b3/chain-registry/runtime";
|
|
1
2
|
import { toThirdwebChain, toViemChain } from "../../../shared/utils/chain-transformers.js";
|
|
2
3
|
import invariant from "invariant";
|
|
3
|
-
// Import the JSON directly
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
import chainNetworksJSON from "../../generated/chain-networks.json" with { type: "json" };
|
|
7
4
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
5
|
// @ts-ignore
|
|
9
6
|
import coingeckoChainsJSON from "../../generated/coingecko-chains.json" with { type: "json" };
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
// TODO: link to doc explaining why we don't support all chains and how to add more
|
|
14
|
-
// These are the chains that are supported for things such as bridging and fetching balances
|
|
15
|
-
export const supportedChains = [...viemChains];
|
|
16
|
-
// ThirdWeb format chains
|
|
17
|
-
export const supportedChainsTW = [
|
|
18
|
-
...chainNetworks
|
|
19
|
-
.map(chain => {
|
|
20
|
-
const networkData = chainNetworks.find(n => n.id === chain.id);
|
|
21
|
-
return networkData ? toThirdwebChain(networkData) : undefined;
|
|
22
|
-
})
|
|
23
|
-
.filter((chain) => chain !== undefined),
|
|
24
|
-
];
|
|
25
|
-
// Original format from chain-networks.json
|
|
26
|
-
export const supportedChainNetworks = chainNetworks;
|
|
27
|
-
// CoinGecko chain mapping
|
|
7
|
+
export const supportedChains = ANYSPEND_EVM_CHAINS.map(toViemChain);
|
|
8
|
+
export const supportedChainsTW = ANYSPEND_EVM_CHAINS.map(toThirdwebChain);
|
|
9
|
+
export const supportedChainNetworks = ANYSPEND_EVM_CHAINS;
|
|
28
10
|
export const coingeckoChains = coingeckoChainsJSON;
|
|
29
|
-
// Helper function to get CoinGecko chain info
|
|
30
11
|
export function getCoingeckoChainInfo(chainId) {
|
|
31
12
|
return coingeckoChains[chainId];
|
|
32
13
|
}
|
|
33
|
-
const _b3MainnetThirdWeb = supportedChainsTW.find(
|
|
14
|
+
const _b3MainnetThirdWeb = supportedChainsTW.find(c => c.id === 8333);
|
|
34
15
|
invariant(_b3MainnetThirdWeb, "B3 mainnet chain not found in supported chains TW");
|
|
35
16
|
export const b3MainnetThirdWeb = _b3MainnetThirdWeb;
|
|
36
|
-
const
|
|
37
|
-
invariant(_b3TestnetThirdWeb, "B3 testnet chain not found in supported chains TW");
|
|
38
|
-
export const b3TestnetThirdWeb = _b3TestnetThirdWeb;
|
|
39
|
-
const _b3Mainnet = supportedChains.find(chain => chain.id === 8333);
|
|
17
|
+
const _b3Mainnet = supportedChains.find(c => c.id === 8333);
|
|
40
18
|
invariant(_b3Mainnet, "B3 mainnet chain not found in supported chains");
|
|
41
19
|
export const b3Mainnet = _b3Mainnet;
|
|
42
|
-
const
|
|
43
|
-
invariant(_b3Testnet, "B3 testnet chain not found in supported chains");
|
|
44
|
-
export const b3Testnet = _b3Testnet;
|
|
45
|
-
const _baseMainnet = supportedChains.find(chain => chain.id === 8453);
|
|
20
|
+
const _baseMainnet = supportedChains.find(c => c.id === 8453);
|
|
46
21
|
invariant(_baseMainnet, "Base mainnet chain not found in supported chains");
|
|
47
22
|
export const baseMainnet = _baseMainnet;
|
|
48
|
-
/**
|
|
49
|
-
* Get a Thirdweb chain by chain ID from supportedChainsTW
|
|
50
|
-
*/
|
|
51
23
|
export function getThirdwebChain(chainId) {
|
|
52
24
|
const chain = supportedChainsTW.find(c => c.id === chainId);
|
|
53
25
|
if (!chain) {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import type { Wallet } from "thirdweb/wallets";
|
|
1
2
|
export * from "./currency";
|
|
2
3
|
export declare const siteURL = "https://basement.fun";
|
|
3
4
|
export declare const b3CoinIcon = "https://cdn.b3.fun/b3-coin-3d.png";
|
|
4
5
|
export declare const ecosystemWalletId: `ecosystem.${string}`;
|
|
6
|
+
export type EcosystemWallet = Wallet<`ecosystem.${string}`> & {
|
|
7
|
+
getAuthToken: () => string | null;
|
|
8
|
+
};
|
|
5
9
|
export declare const tokenIcons: {
|
|
6
10
|
ETH: string;
|
|
7
11
|
WETH: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChainDefinition } from "@b3/chain-registry";
|
|
2
2
|
import type { Chain as ThirdwebChain } from "thirdweb";
|
|
3
|
-
import { Chain } from "viem";
|
|
4
|
-
export declare function toViemChain(
|
|
5
|
-
export declare function toThirdwebChain(
|
|
3
|
+
import type { Chain } from "viem";
|
|
4
|
+
export declare function toViemChain(chain: ChainDefinition): Chain;
|
|
5
|
+
export declare function toThirdwebChain(chain: ChainDefinition): ThirdwebChain;
|
|
@@ -1,46 +1,47 @@
|
|
|
1
1
|
import { defineChain as defineThirdwebChain } from "thirdweb";
|
|
2
|
-
|
|
2
|
+
// fallbackRpc is validated non-null at chain-registry module init for every
|
|
3
|
+
// anyspend EVM chain (see ANYSPEND_EVM_CHAINS in @b3/chain-registry). Callers
|
|
4
|
+
// outside the anyspend EVM set must ensure their own data shape.
|
|
5
|
+
// Derive icon format from URL extension. Thirdweb chain config carries an
|
|
6
|
+
// explicit `format` field; the old chain-networks.json had per-chain values
|
|
7
|
+
// (svg/png/etc.) but @b3/chain-registry only stores `logoUrl`. URL extension
|
|
8
|
+
// is reliable across our current chain set — 9/11 anyspend chains use .png
|
|
9
|
+
// (trustwallet/relay/coinmarketcap), 2 use .svg (Base, Plume from cdn.b3.fun).
|
|
10
|
+
function inferIconFormat(url) {
|
|
11
|
+
const match = url.toLowerCase().match(/\.([a-z0-9]+)(?:\?|#|$)/);
|
|
12
|
+
const ext = match?.[1];
|
|
13
|
+
if (ext === "png" || ext === "jpg" || ext === "jpeg" || ext === "gif" || ext === "webp")
|
|
14
|
+
return ext;
|
|
15
|
+
return "svg";
|
|
16
|
+
}
|
|
17
|
+
export function toViemChain(chain) {
|
|
18
|
+
if (!chain.fallbackRpc) {
|
|
19
|
+
throw new Error(`toViemChain: chain ${chain.chainId} (${chain.key}) has no fallbackRpc`);
|
|
20
|
+
}
|
|
3
21
|
return {
|
|
4
|
-
id:
|
|
5
|
-
name:
|
|
6
|
-
nativeCurrency:
|
|
7
|
-
rpcUrls: {
|
|
8
|
-
default: {
|
|
9
|
-
http: [network.rpcUrls.default.http],
|
|
10
|
-
webSocket: network.rpcUrls.default.ws ? [network.rpcUrls.default.ws] : undefined,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
22
|
+
id: chain.chainId,
|
|
23
|
+
name: chain.name,
|
|
24
|
+
nativeCurrency: chain.nativeCurrency,
|
|
25
|
+
rpcUrls: { default: { http: [chain.fallbackRpc] } },
|
|
13
26
|
blockExplorers: {
|
|
14
|
-
default: {
|
|
15
|
-
name: network.blockExplorers.explorerTitle,
|
|
16
|
-
url: network.blockExplorers.default,
|
|
17
|
-
},
|
|
27
|
+
default: { name: `${chain.name} Explorer`, url: chain.explorer },
|
|
18
28
|
},
|
|
19
|
-
|
|
20
|
-
testnet: network.testnet,
|
|
21
|
-
sourceId: network.sourceId,
|
|
22
|
-
formatters: network.formatters,
|
|
23
|
-
fees: network.fees,
|
|
29
|
+
testnet: chain.isTestnet,
|
|
24
30
|
};
|
|
25
31
|
}
|
|
26
|
-
export function toThirdwebChain(
|
|
32
|
+
export function toThirdwebChain(chain) {
|
|
33
|
+
if (!chain.fallbackRpc) {
|
|
34
|
+
throw new Error(`toThirdwebChain: chain ${chain.chainId} (${chain.key}) has no fallbackRpc`);
|
|
35
|
+
}
|
|
27
36
|
return defineThirdwebChain({
|
|
28
|
-
id:
|
|
29
|
-
name:
|
|
30
|
-
nativeCurrency:
|
|
31
|
-
rpc:
|
|
32
|
-
icon:
|
|
33
|
-
url:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
blockExplorers: [
|
|
39
|
-
{
|
|
40
|
-
name: network.blockExplorers.explorerTitle,
|
|
41
|
-
url: network.blockExplorers.default,
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
testnet: network.testnet ? true : undefined,
|
|
37
|
+
id: chain.chainId,
|
|
38
|
+
name: chain.name,
|
|
39
|
+
nativeCurrency: chain.nativeCurrency,
|
|
40
|
+
rpc: chain.fallbackRpc,
|
|
41
|
+
icon: chain.logoUrl
|
|
42
|
+
? { url: chain.logoUrl, width: 32, height: 32, format: inferIconFormat(chain.logoUrl) }
|
|
43
|
+
: undefined,
|
|
44
|
+
blockExplorers: [{ name: `${chain.name} Explorer`, url: chain.explorer }],
|
|
45
|
+
testnet: chain.isTestnet ? true : undefined,
|
|
45
46
|
});
|
|
46
47
|
}
|
|
@@ -148,7 +148,7 @@ export async function getNativeTokenBalance(address, chainId) {
|
|
|
148
148
|
}
|
|
149
149
|
try {
|
|
150
150
|
// Find chain info from supported chains
|
|
151
|
-
const chainInfo = supportedChainNetworks.find(chain => chain.
|
|
151
|
+
const chainInfo = supportedChainNetworks.find(chain => chain.chainId === chainId);
|
|
152
152
|
// Create a chain object from the chainId
|
|
153
153
|
const chain = defineChain({
|
|
154
154
|
id: chainId,
|
|
@@ -176,7 +176,7 @@ export async function getNativeTokenBalance(address, chainId) {
|
|
|
176
176
|
decimals: balance.decimals,
|
|
177
177
|
balance: balance.value.toString(),
|
|
178
178
|
metadata: {
|
|
179
|
-
logoURI: chainInfo?.
|
|
179
|
+
logoURI: chainInfo?.logoUrl ||
|
|
180
180
|
"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
|
|
181
181
|
},
|
|
182
182
|
// Add native token info in extra_metadata
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface UploadOptions {
|
|
2
|
+
baseUrl?: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Upload a file to the B3 uploads service (Cloudflare R2).
|
|
6
|
+
* Returns the public URL of the uploaded asset.
|
|
7
|
+
*/
|
|
8
|
+
export declare function uploadFile(file: File, options?: UploadOptions): Promise<string>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const DEFAULT_UPLOADS_URL = "https://uploads.b3.fun";
|
|
2
|
+
const ALLOWED_TYPES = ["image/jpeg", "image/png", "image/gif", "image/webp"];
|
|
3
|
+
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
|
4
|
+
/**
|
|
5
|
+
* Upload a file to the B3 uploads service (Cloudflare R2).
|
|
6
|
+
* Returns the public URL of the uploaded asset.
|
|
7
|
+
*/
|
|
8
|
+
export async function uploadFile(file, options) {
|
|
9
|
+
if (!ALLOWED_TYPES.includes(file.type)) {
|
|
10
|
+
throw new Error(`Invalid file type. Allowed: ${ALLOWED_TYPES.join(", ")}`);
|
|
11
|
+
}
|
|
12
|
+
if (file.size > MAX_FILE_SIZE) {
|
|
13
|
+
throw new Error(`File too large. Maximum size: ${MAX_FILE_SIZE / 1024 / 1024}MB`);
|
|
14
|
+
}
|
|
15
|
+
const uploadsUrl = options?.baseUrl || DEFAULT_UPLOADS_URL;
|
|
16
|
+
const formData = new FormData();
|
|
17
|
+
formData.append("file", file);
|
|
18
|
+
const res = await fetch(`${uploadsUrl}/upload/image`, {
|
|
19
|
+
method: "POST",
|
|
20
|
+
body: formData,
|
|
21
|
+
});
|
|
22
|
+
if (!res.ok) {
|
|
23
|
+
const body = await res.json().catch(() => ({ success: false, error: "Upload failed" }));
|
|
24
|
+
throw new Error(body.error || `Upload failed (${res.status})`);
|
|
25
|
+
}
|
|
26
|
+
const body = await res.json().catch(() => ({ success: false, error: "Invalid response" }));
|
|
27
|
+
if (!body.success || !body.data) {
|
|
28
|
+
throw new Error(body.error || "Upload failed");
|
|
29
|
+
}
|
|
30
|
+
return body.data.url;
|
|
31
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical browser-side translation of Zerion wallet positions into B3 balance rows.
|
|
3
|
+
*
|
|
4
|
+
* This lives in the published SDK because every browser consumer needs it — the apps in this repo
|
|
5
|
+
* and the sites that install `@b3dotfun/sdk` from npm — and the in-repo Zerion client is a private
|
|
6
|
+
* workspace package that a published package cannot depend on. Backend services keep their own
|
|
7
|
+
* translation: pulling a browser SDK into a Node service to share one function is a worse trade
|
|
8
|
+
* than the second copy.
|
|
9
|
+
*
|
|
10
|
+
* Only the HTTP layer differs between callers. The rules below — which row counts as the chain's
|
|
11
|
+
* native coin, and which rows have no usable identity — must not be re-derived anywhere else.
|
|
12
|
+
*/
|
|
13
|
+
/** Address B3 uses for a chain's native coin on EVM. Matches NATIVE_TOKEN_ADDRESSES. */
|
|
14
|
+
export declare const EVM_NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
15
|
+
export declare const SOLANA_NATIVE_TOKEN_ADDRESS: "So11111111111111111111111111111111111111112";
|
|
16
|
+
export declare const SOLANA_ZERION_SLUG: "solana";
|
|
17
|
+
/** Solana's chain id as the chain registry defines it — the id every balance row is keyed by. */
|
|
18
|
+
export declare const SOLANA_CHAIN_ID: 7565164;
|
|
19
|
+
export declare function zerionSlugToChainId(slug: string): number | undefined;
|
|
20
|
+
export declare function chainIdToZerionSlug(chainId: number): string | undefined;
|
|
21
|
+
export interface ZerionPositionQuantity {
|
|
22
|
+
int?: string;
|
|
23
|
+
decimals?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ZerionPositionImplementation {
|
|
26
|
+
chain_id?: string;
|
|
27
|
+
address?: string | null;
|
|
28
|
+
decimals?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ZerionPositionFungibleInfo {
|
|
31
|
+
name?: string;
|
|
32
|
+
symbol?: string;
|
|
33
|
+
icon?: {
|
|
34
|
+
url?: string;
|
|
35
|
+
} | null;
|
|
36
|
+
implementations?: ZerionPositionImplementation[];
|
|
37
|
+
}
|
|
38
|
+
export interface ZerionPositionLike {
|
|
39
|
+
id?: string;
|
|
40
|
+
attributes?: {
|
|
41
|
+
quantity?: ZerionPositionQuantity;
|
|
42
|
+
value?: number | null;
|
|
43
|
+
price?: number | null;
|
|
44
|
+
fungible_info?: ZerionPositionFungibleInfo;
|
|
45
|
+
flags?: {
|
|
46
|
+
displayable?: boolean;
|
|
47
|
+
is_trash?: boolean;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
relationships?: {
|
|
51
|
+
chain?: {
|
|
52
|
+
data?: {
|
|
53
|
+
id?: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** One spendable holding. `amount` is the raw integer; pair it with `decimals` to display. */
|
|
59
|
+
export interface B3TokenBalance {
|
|
60
|
+
chain: string;
|
|
61
|
+
chain_id: number;
|
|
62
|
+
address: string;
|
|
63
|
+
amount: string;
|
|
64
|
+
symbol: string;
|
|
65
|
+
decimals: number;
|
|
66
|
+
/**
|
|
67
|
+
* Whether `address` is the native-coin sentinel rather than a real contract. Callers deciding
|
|
68
|
+
* between a value-bearing send and an ERC-20 `transfer` MUST branch on this, never on the
|
|
69
|
+
* sentinel string: getting it backwards spends gas and moves nothing.
|
|
70
|
+
*/
|
|
71
|
+
is_native: boolean;
|
|
72
|
+
name?: string;
|
|
73
|
+
price_usd?: number;
|
|
74
|
+
value_usd?: number;
|
|
75
|
+
token_metadata?: {
|
|
76
|
+
logo: string;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export declare function nativeTokenAddressForChain(slug: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Whether `balance` is the token identified by `tokenAddress`.
|
|
82
|
+
*
|
|
83
|
+
* Native coins are matched on the row's `is_native` flag rather than its printed address, because
|
|
84
|
+
* the caller and the adapter rarely spell the native coin the same way.
|
|
85
|
+
*/
|
|
86
|
+
export declare function balanceMatchesToken(balance: B3TokenBalance, tokenAddress: string): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Adapt raw Zerion positions into balance rows, dropping any row we cannot describe honestly.
|
|
89
|
+
*
|
|
90
|
+
* A row is dropped when its chain slug is absent or unmapped, or when neither the quantity nor the
|
|
91
|
+
* chain implementation carries decimals — an amount rendered against a guessed scale is a wrong
|
|
92
|
+
* number presented as a real one, which is worse for the reader than a missing row.
|
|
93
|
+
*
|
|
94
|
+
* @param slugToChainId overrides slug resolution; return undefined to skip a chain entirely.
|
|
95
|
+
*/
|
|
96
|
+
export declare function adaptZerionPositions(positions: ZerionPositionLike[], slugToChainId?: (slug: string) => number | undefined): B3TokenBalance[];
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { SOLANA_NATIVE_ASSET } from "@b3/chain-registry/runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Canonical browser-side translation of Zerion wallet positions into B3 balance rows.
|
|
4
|
+
*
|
|
5
|
+
* This lives in the published SDK because every browser consumer needs it — the apps in this repo
|
|
6
|
+
* and the sites that install `@b3dotfun/sdk` from npm — and the in-repo Zerion client is a private
|
|
7
|
+
* workspace package that a published package cannot depend on. Backend services keep their own
|
|
8
|
+
* translation: pulling a browser SDK into a Node service to share one function is a worse trade
|
|
9
|
+
* than the second copy.
|
|
10
|
+
*
|
|
11
|
+
* Only the HTTP layer differs between callers. The rules below — which row counts as the chain's
|
|
12
|
+
* native coin, and which rows have no usable identity — must not be re-derived anywhere else.
|
|
13
|
+
*/
|
|
14
|
+
/** Address B3 uses for a chain's native coin on EVM. Matches NATIVE_TOKEN_ADDRESSES. */
|
|
15
|
+
export const EVM_NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
16
|
+
export const SOLANA_NATIVE_TOKEN_ADDRESS = SOLANA_NATIVE_ASSET.wrapped
|
|
17
|
+
.address;
|
|
18
|
+
export const SOLANA_ZERION_SLUG = SOLANA_NATIVE_ASSET.chain;
|
|
19
|
+
/** What Zerion's `quantity.int` is: a base-10 integer, unbounded in length. */
|
|
20
|
+
const DECIMAL_INTEGER_PATTERN = /^\d+$/;
|
|
21
|
+
/** Solana's chain id as the chain registry defines it — the id every balance row is keyed by. */
|
|
22
|
+
export const SOLANA_CHAIN_ID = SOLANA_NATIVE_ASSET.chainId;
|
|
23
|
+
/**
|
|
24
|
+
* Zerion chain slug → numeric chain id. Slugs are Zerion's own vocabulary and do not always match
|
|
25
|
+
* the chain's common name — Gnosis is `xdai`, Metis is `metis-andromeda` — so an entry invented
|
|
26
|
+
* from the chain name silently drops every position on that chain, because the adapter skips any
|
|
27
|
+
* slug it cannot map. Every entry here is taken from Zerion's `GET /v1/chains/`.
|
|
28
|
+
*/
|
|
29
|
+
const ZERION_CHAIN_IDS = {
|
|
30
|
+
ethereum: 1,
|
|
31
|
+
optimism: 10,
|
|
32
|
+
"binance-smart-chain": 56,
|
|
33
|
+
xdai: 100,
|
|
34
|
+
unichain: 130,
|
|
35
|
+
polygon: 137,
|
|
36
|
+
sonic: 146,
|
|
37
|
+
fantom: 250,
|
|
38
|
+
"zksync-era": 324,
|
|
39
|
+
world: 480,
|
|
40
|
+
hyperevm: 999,
|
|
41
|
+
"metis-andromeda": 1088,
|
|
42
|
+
"polygon-zkevm": 1101,
|
|
43
|
+
soneium: 1868,
|
|
44
|
+
ronin: 2020,
|
|
45
|
+
abstract: 2741,
|
|
46
|
+
robinhood: 4663,
|
|
47
|
+
mantle: 5000,
|
|
48
|
+
base: 8453,
|
|
49
|
+
mode: 34443,
|
|
50
|
+
arbitrum: 42161,
|
|
51
|
+
celo: 42220,
|
|
52
|
+
avalanche: 43114,
|
|
53
|
+
linea: 59144,
|
|
54
|
+
berachain: 80094,
|
|
55
|
+
blast: 81457,
|
|
56
|
+
taiko: 167000,
|
|
57
|
+
scroll: 534352,
|
|
58
|
+
zora: 7777777,
|
|
59
|
+
degen: 666666666,
|
|
60
|
+
aurora: 1313161554,
|
|
61
|
+
[SOLANA_ZERION_SLUG]: SOLANA_CHAIN_ID,
|
|
62
|
+
};
|
|
63
|
+
// Maps rather than objects: a slug arrives straight off the wire, and an object lookup resolves an
|
|
64
|
+
// inherited key like `constructor` or `toString` to something truthy instead of reporting the chain
|
|
65
|
+
// as unknown — which would carry a row past the `=== undefined` guard with a function as its id.
|
|
66
|
+
const CHAIN_ID_BY_ZERION_SLUG = new Map(Object.entries(ZERION_CHAIN_IDS));
|
|
67
|
+
const ZERION_SLUG_BY_CHAIN_ID = new Map(Object.entries(ZERION_CHAIN_IDS).map(([slug, id]) => [id, slug]));
|
|
68
|
+
export function zerionSlugToChainId(slug) {
|
|
69
|
+
return CHAIN_ID_BY_ZERION_SLUG.get(slug);
|
|
70
|
+
}
|
|
71
|
+
export function chainIdToZerionSlug(chainId) {
|
|
72
|
+
return ZERION_SLUG_BY_CHAIN_ID.get(chainId);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Zerion encodes a position's asset in the first hyphen-delimited segment of its resource `id`
|
|
76
|
+
* (`<assetRef>-<chainSlug>-<positionType>-…`). A chain's native coin uses the literal `base`
|
|
77
|
+
* (`base-polygon-asset-asset`); ERC-20s use the contract address
|
|
78
|
+
* (`0x1dd17…-ethereum-asset-asset`).
|
|
79
|
+
*
|
|
80
|
+
* This is the only reliable native signal. A falsy per-chain `implementation.address` looks
|
|
81
|
+
* equivalent and is not: Zerion reports Polygon's native coin at its `0x…1010` system contract and
|
|
82
|
+
* Celo's at a real ERC-20 address, while Polygon simultaneously carries a non-native fungible with
|
|
83
|
+
* the same `POL` symbol. Keying on the address shape misclassifies both.
|
|
84
|
+
*/
|
|
85
|
+
function isNativePosition(id, impl) {
|
|
86
|
+
if (id?.startsWith("base-") === true)
|
|
87
|
+
return true;
|
|
88
|
+
// Second signal, for the chains that spell native as an absent address. It requires the
|
|
89
|
+
// implementation to EXIST: a fungible with no entry for this chain tells us nothing about what
|
|
90
|
+
// the row is, and calling that native would hand a value-bearing send an amount we cannot name.
|
|
91
|
+
return impl !== undefined && !impl.address;
|
|
92
|
+
}
|
|
93
|
+
export function nativeTokenAddressForChain(slug) {
|
|
94
|
+
return slug === SOLANA_ZERION_SLUG ? SOLANA_NATIVE_TOKEN_ADDRESS : EVM_NATIVE_TOKEN_ADDRESS;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Every spelling of "the chain's own coin" a caller might hold.
|
|
98
|
+
*
|
|
99
|
+
* A token record's address depends on where it came from — a quote provider, a token list, a URL
|
|
100
|
+
* parameter — and each source names the native coin differently. Matching a balance row against any
|
|
101
|
+
* single one of these silently fails for the others.
|
|
102
|
+
*/
|
|
103
|
+
const NATIVE_TOKEN_MARKERS = new Set([
|
|
104
|
+
"native",
|
|
105
|
+
"0x0000000000000000000000000000000000000000",
|
|
106
|
+
EVM_NATIVE_TOKEN_ADDRESS,
|
|
107
|
+
SOLANA_NATIVE_TOKEN_ADDRESS.toLowerCase(),
|
|
108
|
+
"11111111111111111111111111111111",
|
|
109
|
+
]);
|
|
110
|
+
/**
|
|
111
|
+
* Whether `balance` is the token identified by `tokenAddress`.
|
|
112
|
+
*
|
|
113
|
+
* Native coins are matched on the row's `is_native` flag rather than its printed address, because
|
|
114
|
+
* the caller and the adapter rarely spell the native coin the same way.
|
|
115
|
+
*/
|
|
116
|
+
export function balanceMatchesToken(balance, tokenAddress) {
|
|
117
|
+
const wanted = tokenAddress.toLowerCase();
|
|
118
|
+
if (NATIVE_TOKEN_MARKERS.has(wanted))
|
|
119
|
+
return balance.is_native;
|
|
120
|
+
// Case-insensitive only for hex contract addresses. Solana mints are base58, where case is
|
|
121
|
+
// significant — lowercasing them would let two distinct mints compare equal.
|
|
122
|
+
if (balance.chain === SOLANA_ZERION_SLUG)
|
|
123
|
+
return balance.address === tokenAddress;
|
|
124
|
+
return balance.address.toLowerCase() === wanted;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Adapt raw Zerion positions into balance rows, dropping any row we cannot describe honestly.
|
|
128
|
+
*
|
|
129
|
+
* A row is dropped when its chain slug is absent or unmapped, or when neither the quantity nor the
|
|
130
|
+
* chain implementation carries decimals — an amount rendered against a guessed scale is a wrong
|
|
131
|
+
* number presented as a real one, which is worse for the reader than a missing row.
|
|
132
|
+
*
|
|
133
|
+
* @param slugToChainId overrides slug resolution; return undefined to skip a chain entirely.
|
|
134
|
+
*/
|
|
135
|
+
export function adaptZerionPositions(positions, slugToChainId = zerionSlugToChainId) {
|
|
136
|
+
const out = [];
|
|
137
|
+
for (const position of positions) {
|
|
138
|
+
const attributes = position.attributes ?? {};
|
|
139
|
+
const flags = attributes.flags;
|
|
140
|
+
if (flags && (flags.displayable === false || flags.is_trash === true))
|
|
141
|
+
continue;
|
|
142
|
+
const slug = position.relationships?.chain?.data?.id;
|
|
143
|
+
if (!slug)
|
|
144
|
+
continue;
|
|
145
|
+
const chainId = slugToChainId(slug);
|
|
146
|
+
if (chainId === undefined)
|
|
147
|
+
continue;
|
|
148
|
+
const fungibleInfo = attributes.fungible_info ?? {};
|
|
149
|
+
const implementation = (fungibleInfo.implementations ?? []).find(entry => entry.chain_id === slug);
|
|
150
|
+
const decimals = attributes.quantity?.decimals ?? implementation?.decimals;
|
|
151
|
+
if (decimals === undefined)
|
|
152
|
+
continue;
|
|
153
|
+
const isNative = isNativePosition(position.id, implementation);
|
|
154
|
+
// A non-native row with no contract address has no on-chain identity — drop it rather than
|
|
155
|
+
// render a holding nothing can name.
|
|
156
|
+
const address = isNative ? nativeTokenAddressForChain(slug) : implementation?.address;
|
|
157
|
+
if (!address)
|
|
158
|
+
continue;
|
|
159
|
+
// A quantity we cannot read is not a zero balance. Must be the base-10 integer `quantity.int`
|
|
160
|
+
// is: `null`, `""`, and any other unusable string all format to NaN, which callers coerce back
|
|
161
|
+
// to 0 and show as "holds none". `"0"` matches, so a real zero balance still comes through.
|
|
162
|
+
const amount = attributes.quantity?.int;
|
|
163
|
+
if (amount === undefined || !DECIMAL_INTEGER_PATTERN.test(amount))
|
|
164
|
+
continue;
|
|
165
|
+
out.push({
|
|
166
|
+
chain: slug,
|
|
167
|
+
chain_id: chainId,
|
|
168
|
+
address,
|
|
169
|
+
amount,
|
|
170
|
+
symbol: fungibleInfo.symbol ?? "",
|
|
171
|
+
decimals,
|
|
172
|
+
is_native: isNative,
|
|
173
|
+
name: fungibleInfo.name,
|
|
174
|
+
price_usd: attributes.price ?? undefined,
|
|
175
|
+
value_usd: attributes.value ?? undefined,
|
|
176
|
+
token_metadata: fungibleInfo.icon?.url ? { logo: fungibleInfo.icon.url } : undefined,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|