@b3dotfun/sdk 0.0.23 → 0.0.24-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.js +6 -9
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +35 -28
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +5 -5
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +35 -28
- package/dist/cjs/anyspend/react/components/common/Accordion.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/Accordion.js +53 -0
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +3 -22
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +76 -83
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +4 -3
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +1 -5
- package/dist/cjs/anyspend/react/components/common/StepProgress.js +2 -2
- package/dist/cjs/anyspend/react/components/common/TokenBalance.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.d.ts +0 -1
- package/dist/cjs/anyspend/react/hooks/useGeoOnrampOptions.js +2 -4
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.d.ts +0 -1
- package/dist/cjs/anyspend/react/hooks/useStripeSupport.js +0 -1
- package/dist/cjs/anyspend/utils/chain.js +1 -1
- package/dist/cjs/bondkit/abis/BondkitTokenABI.d.ts +1020 -0
- package/dist/cjs/bondkit/abis/BondkitTokenABI.js +1332 -0
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.d.ts +391 -0
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.js +514 -0
- package/dist/cjs/bondkit/abis/index.d.ts +2 -0
- package/dist/cjs/bondkit/abis/index.js +18 -0
- package/dist/cjs/bondkit/bondkitToken.d.ts +68 -0
- package/dist/cjs/bondkit/bondkitToken.js +456 -0
- package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +60 -0
- package/dist/cjs/bondkit/bondkitTokenFactory.js +274 -0
- package/dist/cjs/bondkit/components/TradingView.d.ts +3 -0
- package/dist/cjs/bondkit/components/TradingView.js +296 -0
- package/dist/cjs/bondkit/components/config/cdn.d.ts +42 -0
- package/dist/cjs/bondkit/components/config/cdn.js +63 -0
- package/dist/cjs/bondkit/components/index.d.ts +5 -0
- package/dist/cjs/bondkit/components/index.js +25 -0
- package/dist/cjs/bondkit/components/types.d.ts +8 -0
- package/dist/cjs/bondkit/components/types.js +5 -0
- package/dist/cjs/bondkit/components/utils/cdn-loader.d.ts +24 -0
- package/dist/cjs/bondkit/components/utils/cdn-loader.js +73 -0
- package/dist/cjs/bondkit/components/utils/format.d.ts +4 -0
- package/dist/cjs/bondkit/components/utils/format.js +31 -0
- package/dist/cjs/bondkit/config.d.ts +10 -0
- package/dist/cjs/bondkit/config.js +18 -0
- package/dist/cjs/bondkit/constants.d.ts +3 -0
- package/dist/cjs/bondkit/constants.js +5 -0
- package/dist/cjs/bondkit/index.d.ts +7 -0
- package/dist/cjs/bondkit/index.js +33 -0
- package/dist/cjs/bondkit/json_abis/BondkitABI.json +1329 -0
- package/dist/cjs/bondkit/json_abis/BondkitFactoryABI.json +511 -0
- package/dist/cjs/bondkit/json_abis/index.d.ts +3 -0
- package/dist/cjs/bondkit/json_abis/index.js +10 -0
- package/dist/cjs/bondkit/json_abis/index.ts +4 -0
- package/dist/cjs/bondkit/types.d.ts +77 -0
- package/dist/cjs/bondkit/types.js +11 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +14 -16
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +31 -20
- package/dist/cjs/global-account/react/components/MintButton/MintButton.js +0 -1
- package/dist/cjs/global-account/react/components/SendERC20Button/SendERC20Button.d.ts +13 -0
- package/dist/cjs/global-account/react/components/SendERC20Button/SendERC20Button.js +33 -0
- package/dist/cjs/global-account/react/components/SendETHButton/SendETHButton.d.ts +12 -0
- package/dist/cjs/global-account/react/components/SendETHButton/SendETHButton.js +23 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +4 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +4 -4
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
- package/dist/cjs/global-account/react/components/custom/CopyToClipboard.d.ts +2 -1
- package/dist/cjs/global-account/react/components/custom/CopyToClipboard.js +3 -2
- package/dist/cjs/global-account/react/components/icons/BankIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/BankIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/EditIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/EditIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/SignOutIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/SignOutIcon.js +8 -0
- package/dist/cjs/global-account/react/components/icons/SwapIcon.d.ts +9 -0
- package/dist/cjs/global-account/react/components/icons/SwapIcon.js +8 -0
- package/dist/cjs/global-account/react/components/index.d.ts +2 -0
- package/dist/cjs/global-account/react/components/index.js +8 -2
- package/dist/cjs/global-account/react/components/ui/scroll-area.js +1 -1
- package/dist/cjs/global-account/react/components/ui/tooltip.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/index.d.ts +2 -1
- package/dist/cjs/global-account/react/hooks/index.js +18 -3
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +8 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +4 -4
- package/dist/cjs/global-account/react/hooks/useB3BalanceFromAddresses.d.ts +6 -0
- package/dist/cjs/global-account/react/hooks/useB3BalanceFromAddresses.js +11 -0
- package/dist/cjs/global-account/react/hooks/useChainSwitchWithAction.d.ts +1 -2
- package/dist/cjs/global-account/react/hooks/useChainSwitchWithAction.js +2 -2
- package/dist/cjs/global-account/react/hooks/useFirstEOA.js +9 -7
- package/dist/cjs/global-account/react/hooks/useNativeBalance.d.ts +6 -0
- package/dist/cjs/global-account/react/hooks/useNativeBalance.js +39 -6
- package/dist/cjs/global-account/react/hooks/useTokenPrice.d.ts +10 -0
- package/dist/cjs/global-account/react/hooks/useTokenPrice.js +81 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +11 -0
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +160 -0
- package/dist/cjs/shared/constants/chains/supported.d.ts +4 -0
- package/dist/cjs/shared/constants/chains/supported.js +11 -0
- package/dist/cjs/shared/generated/chain-networks.json +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +6 -9
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +37 -30
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +5 -5
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +37 -30
- package/dist/esm/anyspend/react/components/common/Accordion.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/Accordion.js +14 -0
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +3 -22
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +79 -86
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +1 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +5 -4
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +1 -5
- package/dist/esm/anyspend/react/components/common/StepProgress.js +2 -2
- package/dist/esm/anyspend/react/components/common/TokenBalance.js +1 -1
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.d.ts +0 -1
- package/dist/esm/anyspend/react/hooks/useGeoOnrampOptions.js +2 -4
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/esm/anyspend/react/hooks/useStripeSupport.d.ts +0 -1
- package/dist/esm/anyspend/react/hooks/useStripeSupport.js +0 -1
- package/dist/esm/anyspend/utils/chain.js +1 -1
- package/dist/esm/bondkit/abis/BondkitTokenABI.d.ts +1020 -0
- package/dist/esm/bondkit/abis/BondkitTokenABI.js +1329 -0
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.d.ts +391 -0
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.js +511 -0
- package/dist/esm/bondkit/abis/index.d.ts +2 -0
- package/dist/esm/bondkit/abis/index.js +2 -0
- package/dist/esm/bondkit/bondkitToken.d.ts +68 -0
- package/dist/esm/bondkit/bondkitToken.js +452 -0
- package/dist/esm/bondkit/bondkitTokenFactory.d.ts +60 -0
- package/dist/esm/bondkit/bondkitTokenFactory.js +270 -0
- package/dist/esm/bondkit/components/TradingView.d.ts +3 -0
- package/dist/esm/bondkit/components/TradingView.js +294 -0
- package/dist/esm/bondkit/components/config/cdn.d.ts +42 -0
- package/dist/esm/bondkit/components/config/cdn.js +55 -0
- package/dist/esm/bondkit/components/index.d.ts +5 -0
- package/dist/esm/bondkit/components/index.js +4 -0
- package/dist/esm/bondkit/components/types.d.ts +8 -0
- package/dist/esm/bondkit/components/types.js +4 -0
- package/dist/esm/bondkit/components/utils/cdn-loader.d.ts +24 -0
- package/dist/esm/bondkit/components/utils/cdn-loader.js +66 -0
- package/dist/esm/bondkit/components/utils/format.d.ts +4 -0
- package/dist/esm/bondkit/components/utils/format.js +28 -0
- package/dist/esm/bondkit/config.d.ts +10 -0
- package/dist/esm/bondkit/config.js +14 -0
- package/dist/esm/bondkit/constants.d.ts +3 -0
- package/dist/esm/bondkit/constants.js +2 -0
- package/dist/esm/bondkit/index.d.ts +7 -0
- package/dist/esm/bondkit/index.js +12 -0
- package/dist/esm/bondkit/json_abis/BondkitABI.json +1329 -0
- package/dist/esm/bondkit/json_abis/BondkitFactoryABI.json +511 -0
- package/dist/esm/bondkit/json_abis/index.d.ts +3 -0
- package/dist/esm/bondkit/json_abis/index.js +3 -0
- package/dist/esm/bondkit/json_abis/index.ts +4 -0
- package/dist/esm/bondkit/types.d.ts +77 -0
- package/dist/esm/bondkit/types.js +8 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +14 -16
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +33 -22
- package/dist/esm/global-account/react/components/MintButton/MintButton.js +0 -1
- package/dist/esm/global-account/react/components/SendERC20Button/SendERC20Button.d.ts +13 -0
- package/dist/esm/global-account/react/components/SendERC20Button/SendERC20Button.js +30 -0
- package/dist/esm/global-account/react/components/SendETHButton/SendETHButton.d.ts +12 -0
- package/dist/esm/global-account/react/components/SendETHButton/SendETHButton.js +20 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +4 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +4 -4
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
- package/dist/esm/global-account/react/components/custom/CopyToClipboard.d.ts +2 -1
- package/dist/esm/global-account/react/components/custom/CopyToClipboard.js +4 -3
- package/dist/esm/global-account/react/components/icons/BankIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/BankIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/EditIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/EditIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/SignOutIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/SignOutIcon.js +5 -0
- package/dist/esm/global-account/react/components/icons/SwapIcon.d.ts +9 -0
- package/dist/esm/global-account/react/components/icons/SwapIcon.js +5 -0
- package/dist/esm/global-account/react/components/index.d.ts +2 -0
- package/dist/esm/global-account/react/components/index.js +4 -0
- package/dist/esm/global-account/react/components/ui/scroll-area.js +1 -1
- package/dist/esm/global-account/react/components/ui/tooltip.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +2 -1
- package/dist/esm/global-account/react/hooks/index.js +2 -1
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +8 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.js +4 -4
- package/dist/esm/global-account/react/hooks/useB3BalanceFromAddresses.d.ts +6 -0
- package/dist/esm/global-account/react/hooks/useB3BalanceFromAddresses.js +11 -0
- package/dist/esm/global-account/react/hooks/useChainSwitchWithAction.d.ts +1 -2
- package/dist/esm/global-account/react/hooks/useChainSwitchWithAction.js +2 -2
- package/dist/esm/global-account/react/hooks/useFirstEOA.js +9 -7
- package/dist/esm/global-account/react/hooks/useNativeBalance.d.ts +6 -0
- package/dist/esm/global-account/react/hooks/useNativeBalance.js +39 -6
- package/dist/esm/global-account/react/hooks/useTokenPrice.d.ts +10 -0
- package/dist/esm/global-account/react/hooks/useTokenPrice.js +78 -3
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +11 -0
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +154 -0
- package/dist/esm/shared/constants/chains/supported.d.ts +4 -0
- package/dist/esm/shared/constants/chains/supported.js +10 -0
- package/dist/esm/shared/generated/chain-networks.json +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/common/Accordion.d.ts +7 -0
- package/dist/types/anyspend/react/hooks/useGeoOnrampOptions.d.ts +0 -1
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +2 -2
- package/dist/types/anyspend/react/hooks/useStripeSupport.d.ts +0 -1
- package/dist/types/bondkit/abis/BondkitTokenABI.d.ts +1020 -0
- package/dist/types/bondkit/abis/BondkitTokenFactoryABI.d.ts +391 -0
- package/dist/types/bondkit/abis/index.d.ts +2 -0
- package/dist/types/bondkit/bondkitToken.d.ts +68 -0
- package/dist/types/bondkit/bondkitTokenFactory.d.ts +60 -0
- package/dist/types/bondkit/components/TradingView.d.ts +3 -0
- package/dist/types/bondkit/components/config/cdn.d.ts +42 -0
- package/dist/types/bondkit/components/index.d.ts +5 -0
- package/dist/types/bondkit/components/types.d.ts +8 -0
- package/dist/types/bondkit/components/utils/cdn-loader.d.ts +24 -0
- package/dist/types/bondkit/components/utils/format.d.ts +4 -0
- package/dist/types/bondkit/config.d.ts +10 -0
- package/dist/types/bondkit/constants.d.ts +3 -0
- package/dist/types/bondkit/index.d.ts +7 -0
- package/dist/types/bondkit/json_abis/index.d.ts +3 -0
- package/dist/types/bondkit/types.d.ts +77 -0
- package/dist/types/global-account/react/components/SendERC20Button/SendERC20Button.d.ts +13 -0
- package/dist/types/global-account/react/components/SendETHButton/SendETHButton.d.ts +12 -0
- package/dist/types/global-account/react/components/custom/CopyToClipboard.d.ts +2 -1
- package/dist/types/global-account/react/components/icons/BankIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/icons/EditIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/icons/SignOutIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/icons/SwapIcon.d.ts +9 -0
- package/dist/types/global-account/react/components/index.d.ts +2 -0
- package/dist/types/global-account/react/components/ui/tooltip.d.ts +1 -1
- package/dist/types/global-account/react/hooks/index.d.ts +2 -1
- package/dist/types/global-account/react/hooks/useB3BalanceFromAddresses.d.ts +6 -0
- package/dist/types/global-account/react/hooks/useChainSwitchWithAction.d.ts +1 -2
- package/dist/types/global-account/react/hooks/useNativeBalance.d.ts +6 -0
- package/dist/types/global-account/react/hooks/useTokenPrice.d.ts +10 -0
- package/dist/types/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +11 -0
- package/dist/types/shared/constants/chains/supported.d.ts +4 -0
- package/package.json +43 -7
- package/src/anyspend/react/components/AnySpend.tsx +6 -24
- package/src/anyspend/react/components/AnySpendBondKit.tsx +2 -2
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +42 -32
- package/src/anyspend/react/components/AnySpendCustom.tsx +8 -14
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +44 -34
- package/src/anyspend/react/components/common/Accordion.tsx +56 -0
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +0 -25
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +1 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +292 -260
- package/src/anyspend/react/components/common/OrderStatus.tsx +1 -1
- package/src/anyspend/react/components/common/PanelOnramp.tsx +7 -7
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +0 -6
- package/src/anyspend/react/components/common/StepProgress.tsx +2 -2
- package/src/anyspend/react/components/common/TokenBalance.tsx +3 -3
- package/src/anyspend/react/hooks/useGeoOnrampOptions.ts +2 -4
- package/src/anyspend/react/hooks/useStripeSupport.ts +0 -1
- package/src/anyspend/utils/chain.ts +1 -1
- package/src/bondkit/abis/BondkitTokenABI.ts +1329 -0
- package/src/bondkit/abis/BondkitTokenFactoryABI.ts +511 -0
- package/src/bondkit/abis/index.ts +2 -0
- package/src/bondkit/bondkitToken.ts +539 -0
- package/src/bondkit/bondkitTokenFactory.ts +336 -0
- package/src/bondkit/components/TradingView.tsx +341 -0
- package/src/bondkit/components/config/cdn.ts +63 -0
- package/src/bondkit/components/index.ts +5 -0
- package/src/bondkit/components/types.ts +9 -0
- package/src/bondkit/components/utils/cdn-loader.ts +77 -0
- package/src/bondkit/components/utils/format.ts +36 -0
- package/src/bondkit/config.ts +26 -0
- package/src/bondkit/constants.ts +5 -0
- package/src/bondkit/index.ts +16 -0
- package/src/bondkit/json_abis/BondkitABI.json +1329 -0
- package/src/bondkit/json_abis/BondkitFactoryABI.json +511 -0
- package/src/bondkit/json_abis/index.ts +4 -0
- package/src/bondkit/types.ts +98 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +68 -40
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +308 -137
- package/src/global-account/react/components/MintButton/MintButton.tsx +0 -1
- package/src/global-account/react/components/SendERC20Button/SendERC20Button.tsx +57 -0
- package/src/global-account/react/components/SendETHButton/SendETHButton.tsx +37 -0
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +21 -22
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +4 -3
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
- package/src/global-account/react/components/custom/CopyToClipboard.tsx +7 -4
- package/src/global-account/react/components/icons/BankIcon.tsx +38 -0
- package/src/global-account/react/components/icons/EditIcon.tsx +33 -0
- package/src/global-account/react/components/icons/SignOutIcon.tsx +28 -0
- package/src/global-account/react/components/icons/SwapIcon.tsx +41 -0
- package/src/global-account/react/components/index.ts +6 -0
- package/src/global-account/react/components/ui/scroll-area.tsx +2 -2
- package/src/global-account/react/components/ui/tooltip.tsx +1 -1
- package/src/global-account/react/hooks/index.ts +2 -1
- package/src/global-account/react/hooks/useAccountWallet.tsx +10 -1
- package/src/global-account/react/hooks/useAuthentication.ts +4 -4
- package/src/global-account/react/hooks/useB3BalanceFromAddresses.ts +18 -0
- package/src/global-account/react/hooks/useChainSwitchWithAction.ts +3 -4
- package/src/global-account/react/hooks/useFirstEOA.tsx +10 -7
- package/src/global-account/react/hooks/useNativeBalance.tsx +51 -6
- package/src/global-account/react/hooks/useTokenPrice.tsx +138 -3
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +186 -0
- package/src/shared/constants/chains/supported.ts +11 -0
- package/src/shared/generated/chain-networks.json +1 -1
- package/src/styles/index.css +345 -0
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useURLParams = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGetGeo = exports.useGetAllTWSigners = exports.useExchangeRate = exports.useConnect = exports.
|
|
17
|
+
exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGetGeo = exports.useGetAllTWSigners = exports.useExchangeRate = exports.useConnect = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
|
|
4
18
|
var useAccountAssets_1 = require("./useAccountAssets");
|
|
5
19
|
Object.defineProperty(exports, "useAccountAssets", { enumerable: true, get: function () { return useAccountAssets_1.useAccountAssets; } });
|
|
6
20
|
var useAccountWallet_1 = require("./useAccountWallet");
|
|
@@ -17,8 +31,7 @@ var useBestTransactionPath_1 = require("./useBestTransactionPath");
|
|
|
17
31
|
Object.defineProperty(exports, "useBestTransactionPath", { enumerable: true, get: function () { return useBestTransactionPath_1.useBestTransactionPath; } });
|
|
18
32
|
var useChainSwitchWithAction_1 = require("./useChainSwitchWithAction");
|
|
19
33
|
Object.defineProperty(exports, "useChainSwitchWithAction", { enumerable: true, get: function () { return useChainSwitchWithAction_1.useChainSwitchWithAction; } });
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(exports, "useClaim", { enumerable: true, get: function () { return useClaim_1.useClaim; } });
|
|
34
|
+
__exportStar(require("./useClaim"), exports);
|
|
22
35
|
var useConnect_1 = require("./useConnect");
|
|
23
36
|
Object.defineProperty(exports, "useConnect", { enumerable: true, get: function () { return useConnect_1.useConnect; } });
|
|
24
37
|
var useExchangeRate_1 = require("./useExchangeRate");
|
|
@@ -71,5 +84,7 @@ var useTokenPriceWithFallback_1 = require("./useTokenPriceWithFallback");
|
|
|
71
84
|
Object.defineProperty(exports, "useTokenPriceWithFallback", { enumerable: true, get: function () { return useTokenPriceWithFallback_1.useTokenPriceWithFallback; } });
|
|
72
85
|
var useTokensFromAddress_1 = require("./useTokensFromAddress");
|
|
73
86
|
Object.defineProperty(exports, "useTokensFromAddress", { enumerable: true, get: function () { return useTokensFromAddress_1.useTokensFromAddress; } });
|
|
87
|
+
var useUnifiedChainSwitchAndExecute_1 = require("./useUnifiedChainSwitchAndExecute");
|
|
88
|
+
Object.defineProperty(exports, "useUnifiedChainSwitchAndExecute", { enumerable: true, get: function () { return useUnifiedChainSwitchAndExecute_1.useUnifiedChainSwitchAndExecute; } });
|
|
74
89
|
var useURLParams_1 = require("./useURLParams");
|
|
75
90
|
Object.defineProperty(exports, "useURLParams", { enumerable: true, get: function () { return useURLParams_1.useURLParams; } });
|
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useAccountWallet = useAccountWallet;
|
|
4
4
|
const react_1 = require("../../../global-account/react");
|
|
5
5
|
const constants_1 = require("../../../shared/constants");
|
|
6
|
+
const debug_1 = require("../../../shared/utils/debug");
|
|
6
7
|
const react_2 = require("react");
|
|
7
8
|
const react_3 = require("thirdweb/react");
|
|
8
9
|
const in_app_1 = require("thirdweb/wallets/in-app");
|
|
10
|
+
const debug = (0, debug_1.debugB3React)("useAccountWallet");
|
|
9
11
|
function useLastAuthProvider() {
|
|
10
12
|
const [lastAuthProvider, setLastAuthProvider] = (0, react_2.useState)(null);
|
|
11
13
|
(0, react_2.useEffect)(() => {
|
|
@@ -25,6 +27,12 @@ function useAccountWallet() {
|
|
|
25
27
|
const connectedEOAWallet = connectedWallets.find(wallet => wallet.id !== constants_1.ecosystemWalletId);
|
|
26
28
|
const isActiveSmartWallet = activeWallet?.id === connectedSmartWallet?.id;
|
|
27
29
|
const isActiveEOAWallet = activeWallet?.id === connectedEOAWallet?.id;
|
|
30
|
+
debug("activeWallet", activeWallet);
|
|
31
|
+
debug("connectedWallets", connectedWallets);
|
|
32
|
+
debug("connectedSmartWallet", connectedSmartWallet);
|
|
33
|
+
debug("connectedEOAWallet", connectedEOAWallet);
|
|
34
|
+
debug("isActiveSmartWallet", isActiveSmartWallet);
|
|
35
|
+
debug("isActiveEOAWallet", isActiveEOAWallet);
|
|
28
36
|
const { data: walletImage } = (0, react_3.useWalletImage)(connectedEOAWallet?.id);
|
|
29
37
|
// If not EOA sign in, then we need to show the smart wallet icon
|
|
30
38
|
const lastAuthProvider = useLastAuthProvider();
|
|
@@ -46,7 +46,7 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
46
46
|
setIsAuthenticated(true);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
debug("
|
|
49
|
+
debug("setIsAuthenticating:true:4");
|
|
50
50
|
setIsAuthenticating(true);
|
|
51
51
|
const account = await wallet.getAccount();
|
|
52
52
|
if (!account) {
|
|
@@ -71,7 +71,7 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
71
71
|
catch (error) {
|
|
72
72
|
debug("Auto-connect authentication failed", { error });
|
|
73
73
|
setIsAuthenticated(false);
|
|
74
|
-
debug("
|
|
74
|
+
debug("setIsAuthenticating:false:4");
|
|
75
75
|
setUser();
|
|
76
76
|
}
|
|
77
77
|
},
|
|
@@ -85,14 +85,14 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
85
85
|
// Only set isAuthenticating to false if we're not authenticated
|
|
86
86
|
// This prevents the flicker state where both isAuthenticating and isAuthenticated are false
|
|
87
87
|
const timeout = setTimeout(() => {
|
|
88
|
-
debug("
|
|
88
|
+
debug("setIsAuthenticating:false:5a");
|
|
89
89
|
setIsAuthenticating(false);
|
|
90
90
|
setIsConnecting(false);
|
|
91
91
|
}, 100); // Add a small delay to prevent quick flickers
|
|
92
92
|
return () => clearTimeout(timeout);
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
95
|
-
debug("
|
|
95
|
+
debug("setIsAuthenticating:false:5b");
|
|
96
96
|
setIsAuthenticating(false);
|
|
97
97
|
setIsConnecting(false);
|
|
98
98
|
}
|
|
@@ -10,6 +10,12 @@ export declare function useB3BalanceFromAddresses(addresses?: string[] | string
|
|
|
10
10
|
address: string;
|
|
11
11
|
balance: bigint;
|
|
12
12
|
formatted: string;
|
|
13
|
+
balanceUsd: number;
|
|
14
|
+
balanceUsdFormatted: string;
|
|
15
|
+
priceChange24h: number | null;
|
|
13
16
|
}[];
|
|
17
|
+
balanceUsd: number;
|
|
18
|
+
balanceUsdFormatted: string;
|
|
19
|
+
priceChange24h: number | null;
|
|
14
20
|
}, Error>;
|
|
15
21
|
export default useB3BalanceFromAddresses;
|
|
@@ -6,6 +6,7 @@ const formatNumber_1 = require("../../../shared/utils/formatNumber");
|
|
|
6
6
|
const react_query_1 = require("@tanstack/react-query");
|
|
7
7
|
const viem_1 = require("viem");
|
|
8
8
|
const chains_1 = require("viem/chains");
|
|
9
|
+
const useTokenPrice_1 = require("./useTokenPrice");
|
|
9
10
|
// ABI for just balanceOf
|
|
10
11
|
const abi = [
|
|
11
12
|
{
|
|
@@ -23,6 +24,8 @@ const client = (0, viem_1.createPublicClient)({
|
|
|
23
24
|
});
|
|
24
25
|
async function fetchB3Balances(addresses) {
|
|
25
26
|
try {
|
|
27
|
+
// Fetch price with change data once (same for all addresses since it's the same token)
|
|
28
|
+
const priceData = await (0, useTokenPrice_1.fetchTokenPriceWithChange)(anyspend_1.B3_TOKEN.address, anyspend_1.B3_TOKEN.chainId, "usd");
|
|
26
29
|
// Fetch all balances in parallel
|
|
27
30
|
const balances = await Promise.all(addresses.map(async (address) => {
|
|
28
31
|
const balance = await client.readContract({
|
|
@@ -31,18 +34,26 @@ async function fetchB3Balances(addresses) {
|
|
|
31
34
|
functionName: "balanceOf",
|
|
32
35
|
args: [address],
|
|
33
36
|
});
|
|
37
|
+
const balanceUsd = Number((0, viem_1.formatUnits)(balance, anyspend_1.B3_TOKEN.decimals)) * priceData.price;
|
|
34
38
|
return {
|
|
35
39
|
address,
|
|
36
40
|
balance,
|
|
37
41
|
formatted: (0, viem_1.formatUnits)(balance, anyspend_1.B3_TOKEN.decimals),
|
|
42
|
+
balanceUsd,
|
|
43
|
+
balanceUsdFormatted: (0, formatNumber_1.formatNumber)(balanceUsd),
|
|
44
|
+
priceChange24h: priceData.priceChange24h,
|
|
38
45
|
};
|
|
39
46
|
}));
|
|
40
47
|
// Calculate total
|
|
41
48
|
const totalBalance = balances.reduce((sum, { balance }) => sum + balance, BigInt(0));
|
|
49
|
+
const totalBalanceUsd = balances.reduce((sum, { balanceUsd }) => sum + balanceUsd, 0);
|
|
42
50
|
return {
|
|
43
51
|
totalBalance,
|
|
44
52
|
formattedTotal: (0, formatNumber_1.formatNumber)(Number((0, viem_1.formatUnits)(totalBalance, anyspend_1.B3_TOKEN.decimals))),
|
|
45
53
|
breakdown: balances,
|
|
54
|
+
balanceUsd: totalBalanceUsd,
|
|
55
|
+
balanceUsdFormatted: (0, formatNumber_1.formatNumber)(totalBalanceUsd),
|
|
56
|
+
priceChange24h: priceData.priceChange24h,
|
|
46
57
|
};
|
|
47
58
|
}
|
|
48
59
|
catch (error) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { WalletClient } from "viem";
|
|
2
1
|
export declare function useChainSwitchWithAction(): {
|
|
3
|
-
switchChainAndExecute: (targetChainId: number, action: (
|
|
2
|
+
switchChainAndExecute: (targetChainId: number, action: () => Promise<void>) => Promise<void>;
|
|
4
3
|
isSwitchingOrExecuting: boolean;
|
|
5
4
|
};
|
|
@@ -35,7 +35,7 @@ function useChainSwitchWithAction() {
|
|
|
35
35
|
const providerId = walletClient.chain.id;
|
|
36
36
|
const onCorrectChain = providerId === targetChainId;
|
|
37
37
|
if (onCorrectChain) {
|
|
38
|
-
return run(() => action(
|
|
38
|
+
return run(() => action());
|
|
39
39
|
}
|
|
40
40
|
sonner_1.toast.info(`Switching to ${(0, anyspend_1.getChainName)(targetChainId)}…`);
|
|
41
41
|
const targetChain = supported_1.supportedChains.find(chain => chain.id === targetChainId);
|
|
@@ -60,7 +60,7 @@ function useChainSwitchWithAction() {
|
|
|
60
60
|
},
|
|
61
61
|
},
|
|
62
62
|
});
|
|
63
|
-
await run(() => action(
|
|
63
|
+
await run(() => action());
|
|
64
64
|
}
|
|
65
65
|
catch (e) {
|
|
66
66
|
if (e?.code === -32603 || e?.message?.includes("f is not a function")) {
|
|
@@ -2,31 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = useFirstEOA;
|
|
4
4
|
const react_1 = require("../../../global-account/react");
|
|
5
|
+
const debug_1 = require("../../../shared/utils/debug");
|
|
5
6
|
const react_2 = require("react");
|
|
6
7
|
const react_3 = require("thirdweb/react");
|
|
8
|
+
const debug = (0, debug_1.debugB3React)("useFirstEOA");
|
|
7
9
|
function useFirstEOA() {
|
|
8
10
|
const wallets = (0, react_3.useConnectedWallets)();
|
|
9
11
|
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
10
12
|
const [firstEOA, setFirstEOA] = (0, react_2.useState)(undefined);
|
|
11
13
|
const [address, setAddress] = (0, react_2.useState)(undefined);
|
|
12
14
|
const walletInfo = (0, react_3.useWalletInfo)(firstEOA?.id);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
debug("Wallets", wallets);
|
|
16
|
+
debug("Is connected", isConnected);
|
|
15
17
|
(0, react_2.useEffect)(() => {
|
|
16
18
|
const autoSelectFirstEOAWallet = async () => {
|
|
17
19
|
// Only proceed if auto-selection is enabled and user is authenticated
|
|
18
20
|
if (!isConnected) {
|
|
19
|
-
|
|
21
|
+
debug("Not connected");
|
|
20
22
|
return;
|
|
21
23
|
}
|
|
22
24
|
// Find the first EOA wallet (excluding ecosystem wallets)
|
|
23
25
|
const isEOAWallet = (wallet) => !wallet.id.startsWith("ecosystem.");
|
|
24
26
|
const firstEOAWallet = wallets.find(isEOAWallet);
|
|
25
|
-
|
|
26
|
-
const account =
|
|
27
|
-
|
|
27
|
+
debug("First EOA wallet", firstEOAWallet);
|
|
28
|
+
const account = firstEOAWallet?.getAccount();
|
|
29
|
+
debug("Account", account);
|
|
28
30
|
setFirstEOA(firstEOAWallet);
|
|
29
|
-
|
|
31
|
+
debug("Address", account?.address);
|
|
30
32
|
setAddress(account?.address);
|
|
31
33
|
};
|
|
32
34
|
autoSelectFirstEOAWallet();
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
export declare function useNativeBalance(address?: string, chainIds?: string): import("@tanstack/react-query").UseQueryResult<{
|
|
2
2
|
total: number;
|
|
3
3
|
formattedTotal: string;
|
|
4
|
+
totalUsd: number;
|
|
5
|
+
formattedTotalUsd: string;
|
|
6
|
+
priceChange24h: number | null;
|
|
4
7
|
breakdown: {
|
|
5
8
|
chainId: number;
|
|
6
9
|
balance: bigint;
|
|
7
10
|
formatted: string;
|
|
11
|
+
balanceUsd: number;
|
|
12
|
+
balanceUsdFormatted: string;
|
|
13
|
+
priceChange24h: number | null;
|
|
8
14
|
}[];
|
|
9
15
|
}, Error>;
|
|
10
16
|
/**
|
|
@@ -7,6 +7,7 @@ const formatNumber_1 = require("../../../shared/utils/formatNumber");
|
|
|
7
7
|
const react_query_1 = require("@tanstack/react-query");
|
|
8
8
|
const sonner_1 = require("sonner");
|
|
9
9
|
const viem_1 = require("viem");
|
|
10
|
+
const useTokenPrice_1 = require("./useTokenPrice");
|
|
10
11
|
async function fetchNativeBalance(address, chainIds) {
|
|
11
12
|
if (!address)
|
|
12
13
|
throw new Error("Address is required");
|
|
@@ -20,20 +21,52 @@ async function fetchNativeBalance(address, chainIds) {
|
|
|
20
21
|
const balance = (0, viem_1.formatUnits)(BigInt(curr.balance), curr.tokenDecimals);
|
|
21
22
|
return acc + Number(balance);
|
|
22
23
|
}, 0);
|
|
24
|
+
// TODO: Revive me once CoinGecko supports B3
|
|
25
|
+
let usdBalances = {};
|
|
26
|
+
let globalPriceChange24h = null;
|
|
27
|
+
try {
|
|
28
|
+
for (const item of data.data) {
|
|
29
|
+
// Use chain ID once since native token ETH is the same across all chains
|
|
30
|
+
const priceData = await (0, useTokenPrice_1.fetchNativeTokenPriceWithChange)("eth");
|
|
31
|
+
// Store the price change globally (same for all chains since it's ETH)
|
|
32
|
+
if (globalPriceChange24h === null) {
|
|
33
|
+
globalPriceChange24h = priceData.priceChange24h;
|
|
34
|
+
}
|
|
35
|
+
usdBalances[item.chainId] = {
|
|
36
|
+
balance: total * priceData.price,
|
|
37
|
+
formatted: (0, formatNumber_1.formatNumber)(total * priceData.price),
|
|
38
|
+
priceChange24h: priceData.priceChange24h,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error("@@useNativeBalance:error in price calculation", error);
|
|
44
|
+
}
|
|
45
|
+
const totalUsd = Object.values(usdBalances).reduce((acc, curr) => acc + curr.balance, 0);
|
|
23
46
|
return {
|
|
24
47
|
total,
|
|
25
48
|
formattedTotal: (0, formatNumber_1.formatNumber)(total),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
49
|
+
totalUsd,
|
|
50
|
+
formattedTotalUsd: (0, formatNumber_1.formatNumber)(totalUsd),
|
|
51
|
+
priceChange24h: globalPriceChange24h,
|
|
52
|
+
breakdown: data.data.map(item => {
|
|
53
|
+
const usdBalance = usdBalances[item.chainId]?.balance || 0;
|
|
54
|
+
const priceChange = usdBalances[item.chainId]?.priceChange24h || null;
|
|
55
|
+
return {
|
|
56
|
+
chainId: item.chainId,
|
|
57
|
+
balance: BigInt(item.balance),
|
|
58
|
+
formatted: (0, formatNumber_1.formatNumber)(Number((0, viem_1.formatUnits)(BigInt(item.balance), item.tokenDecimals))),
|
|
59
|
+
balanceUsd: usdBalance,
|
|
60
|
+
balanceUsdFormatted: (0, formatNumber_1.formatNumber)(usdBalance),
|
|
61
|
+
priceChange24h: priceChange,
|
|
62
|
+
};
|
|
63
|
+
}),
|
|
31
64
|
};
|
|
32
65
|
}
|
|
33
66
|
function useNativeBalance(address, chainIds = "8333") {
|
|
34
67
|
return (0, react_query_1.useQuery)({
|
|
35
68
|
queryKey: ["nativeBalance", address, chainIds],
|
|
36
|
-
queryFn: () => fetchNativeBalance(address, chainIds),
|
|
69
|
+
queryFn: () => fetchNativeBalance(address || "", chainIds),
|
|
37
70
|
enabled: Boolean(address),
|
|
38
71
|
staleTime: 30 * 1000, // Consider data fresh for 30 seconds
|
|
39
72
|
gcTime: 5 * 60 * 1000, // Keep unused data in cache for 5 minutes
|
|
@@ -7,6 +7,16 @@ interface UseTokenPriceProps {
|
|
|
7
7
|
refreshInterval?: number;
|
|
8
8
|
queryOptions?: Omit<UseQueryOptions<number, Error>, "queryKey" | "queryFn" | "refetchInterval" | "staleTime" | "retry" | "retryDelay">;
|
|
9
9
|
}
|
|
10
|
+
export declare function fetchNativeTokenPriceUsd(contractAddress: string, network: string): Promise<number>;
|
|
11
|
+
export declare function fetchNativeTokenPriceWithChange(network: string): Promise<{
|
|
12
|
+
price: number;
|
|
13
|
+
priceChange24h: number | null;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function fetchTokenPrice(contractAddress: string, chainId: number, vsCurrency?: string): Promise<number>;
|
|
16
|
+
export declare function fetchTokenPriceWithChange(contractAddress: string, chainId: number, vsCurrency?: string): Promise<{
|
|
17
|
+
price: number;
|
|
18
|
+
priceChange24h: number | null;
|
|
19
|
+
}>;
|
|
10
20
|
export declare function useTokenPrice({ contractAddress, chainId, // Default to Base
|
|
11
21
|
vsCurrency, refreshInterval, queryOptions, }: UseTokenPriceProps): {
|
|
12
22
|
price: number;
|
|
@@ -1,15 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.fetchNativeTokenPriceUsd = fetchNativeTokenPriceUsd;
|
|
5
|
+
exports.fetchNativeTokenPriceWithChange = fetchNativeTokenPriceWithChange;
|
|
6
|
+
exports.fetchTokenPrice = fetchTokenPrice;
|
|
7
|
+
exports.fetchTokenPriceWithChange = fetchTokenPriceWithChange;
|
|
4
8
|
exports.useTokenPrice = useTokenPrice;
|
|
5
9
|
const chainPlatformMap_1 = require("../../../shared/constants/chains/chainPlatformMap");
|
|
6
10
|
const react_query_1 = require("@tanstack/react-query");
|
|
11
|
+
async function fetchNativeTokenPriceUsd(contractAddress, network) {
|
|
12
|
+
const response = await fetch(`https://coingecko-api.sean-430.workers.dev?localkey=${process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET}&url=https://pro-api.coingecko.com/api/v3/onchain/simple/networks/${network}/token_price/${contractAddress}`, {
|
|
13
|
+
headers: {
|
|
14
|
+
accept: "application/json",
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error(`Failed to fetch native token price: ${response.status} ${response.statusText}`);
|
|
19
|
+
}
|
|
20
|
+
const data = await response.json();
|
|
21
|
+
// Find the price using case-insensitive address comparison
|
|
22
|
+
const prices = data.data?.attributes?.token_prices || {};
|
|
23
|
+
const price = Object.entries(prices).find(([address]) => address.toLowerCase() === contractAddress.toLowerCase())?.[1];
|
|
24
|
+
if (!price) {
|
|
25
|
+
throw new Error(`No price data found for native token: ${contractAddress}`);
|
|
26
|
+
}
|
|
27
|
+
// Convert string price to number
|
|
28
|
+
const numericPrice = Number(price);
|
|
29
|
+
if (isNaN(numericPrice)) {
|
|
30
|
+
throw new Error(`Invalid price data for native token: ${contractAddress}`);
|
|
31
|
+
}
|
|
32
|
+
return numericPrice;
|
|
33
|
+
}
|
|
34
|
+
async function fetchNativeTokenPriceWithChange(network) {
|
|
35
|
+
// For ETH, use the regular simple price API instead of on-chain API to get price changes
|
|
36
|
+
const coinId = network === "eth" ? "ethereum" : network;
|
|
37
|
+
const response = await fetch(`https://coingecko-api.sean-430.workers.dev?localkey=${process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET}&url=https://pro-api.coingecko.com/api/v3/simple/price?ids=${coinId}&vs_currencies=usd&include_24hr_change=true`, {
|
|
38
|
+
headers: {
|
|
39
|
+
accept: "application/json",
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
throw new Error(`Failed to fetch native token price with change: ${response.status} ${response.statusText}`);
|
|
44
|
+
}
|
|
45
|
+
const data = await response.json();
|
|
46
|
+
if (!data[coinId]) {
|
|
47
|
+
throw new Error(`No price data found for coin: ${coinId}`);
|
|
48
|
+
}
|
|
49
|
+
const price = data[coinId].usd;
|
|
50
|
+
const priceChange = data[coinId].usd_24h_change;
|
|
51
|
+
if (typeof price !== "number") {
|
|
52
|
+
throw new Error(`Invalid price data for coin: ${coinId}`);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
price,
|
|
56
|
+
priceChange24h: priceChange || null,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
7
59
|
async function fetchTokenPrice(contractAddress, chainId, vsCurrency = "usd") {
|
|
8
60
|
const platformId = (0, chainPlatformMap_1.getPlatformId)(chainId);
|
|
9
|
-
const response = await fetch(`https://pro-api.coingecko.com/api/v3/simple/token_price/${platformId}?contract_addresses=${contractAddress}&vs_currencies=${vsCurrency}`, {
|
|
61
|
+
const response = await fetch(`https://coingecko-api.sean-430.workers.dev?localkey=${process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET}&url=https://pro-api.coingecko.com/api/v3/simple/token_price/${platformId}?contract_addresses=${contractAddress}&vs_currencies=${vsCurrency}`, {
|
|
10
62
|
headers: {
|
|
11
63
|
accept: "application/json",
|
|
12
|
-
"x-cg-pro-api-key": process.env.COINGECKO_API_KEY,
|
|
13
64
|
},
|
|
14
65
|
});
|
|
15
66
|
if (!response.ok) {
|
|
@@ -27,6 +78,34 @@ async function fetchTokenPrice(contractAddress, chainId, vsCurrency = "usd") {
|
|
|
27
78
|
// Return the price with proper type checking
|
|
28
79
|
return data[contractAddress][vsCurrency];
|
|
29
80
|
}
|
|
81
|
+
async function fetchTokenPriceWithChange(contractAddress, chainId, vsCurrency = "usd") {
|
|
82
|
+
const platformId = (0, chainPlatformMap_1.getPlatformId)(chainId);
|
|
83
|
+
const response = await fetch(`https://coingecko-api.sean-430.workers.dev?localkey=${process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET}&url=https://pro-api.coingecko.com/api/v3/simple/token_price/${platformId}?contract_addresses=${contractAddress}&vs_currencies=${vsCurrency}&include_24hr_change=true`, {
|
|
84
|
+
headers: {
|
|
85
|
+
accept: "application/json",
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
if (!response.ok) {
|
|
89
|
+
throw new Error(`Failed to fetch token price with change: ${response.status} ${response.statusText}`);
|
|
90
|
+
}
|
|
91
|
+
const data = await response.json();
|
|
92
|
+
// Check if the contract address exists in the response
|
|
93
|
+
if (!data[contractAddress]) {
|
|
94
|
+
throw new Error(`No price data found for contract address: ${contractAddress}`);
|
|
95
|
+
}
|
|
96
|
+
// Check if the requested currency exists in the response
|
|
97
|
+
if (typeof data[contractAddress][vsCurrency] !== "number") {
|
|
98
|
+
throw new Error(`No price data found for currency: ${vsCurrency}`);
|
|
99
|
+
}
|
|
100
|
+
// Get the price change key (e.g., "usd_24h_change")
|
|
101
|
+
const priceChangeKey = `${vsCurrency}_24h_change`;
|
|
102
|
+
const priceChange = data[contractAddress][priceChangeKey];
|
|
103
|
+
// Return the price and price change with proper type checking
|
|
104
|
+
return {
|
|
105
|
+
price: data[contractAddress][vsCurrency],
|
|
106
|
+
priceChange24h: priceChange || null,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
30
109
|
function useTokenPrice({ contractAddress, chainId = 8453, // Default to Base
|
|
31
110
|
vsCurrency = "usd", refreshInterval = 30000, queryOptions = {}, }) {
|
|
32
111
|
const { data: price = 0, isLoading, error, refetch, } = (0, react_query_1.useQuery)({
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface UnifiedTransactionParams {
|
|
2
|
+
to: string;
|
|
3
|
+
data?: string;
|
|
4
|
+
value: bigint;
|
|
5
|
+
}
|
|
6
|
+
export declare function useUnifiedChainSwitchAndExecute(): {
|
|
7
|
+
switchChainAndExecute: (targetChainId: number, params: UnifiedTransactionParams) => Promise<string | undefined>;
|
|
8
|
+
isSwitchingOrExecuting: boolean;
|
|
9
|
+
isActiveSmartWallet: boolean | undefined;
|
|
10
|
+
isActiveEOAWallet: boolean | undefined;
|
|
11
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useUnifiedChainSwitchAndExecute = useUnifiedChainSwitchAndExecute;
|
|
7
|
+
const anyspend_1 = require("../../../anyspend");
|
|
8
|
+
const app_1 = __importDefault(require("../../../global-account/app"));
|
|
9
|
+
const supported_1 = require("../../../shared/constants/chains/supported");
|
|
10
|
+
const thirdweb_1 = require("../../../shared/utils/thirdweb");
|
|
11
|
+
const invariant_1 = __importDefault(require("invariant"));
|
|
12
|
+
const react_1 = require("react");
|
|
13
|
+
const sonner_1 = require("sonner");
|
|
14
|
+
const thirdweb_2 = require("thirdweb");
|
|
15
|
+
const wagmi_1 = require("wagmi");
|
|
16
|
+
const components_1 = require("../components");
|
|
17
|
+
const useAccountWallet_1 = require("./useAccountWallet");
|
|
18
|
+
function useUnifiedChainSwitchAndExecute() {
|
|
19
|
+
const { data: walletClient } = (0, wagmi_1.useWalletClient)();
|
|
20
|
+
const { switchChainAsync } = (0, wagmi_1.useSwitchChain)();
|
|
21
|
+
const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = (0, react_1.useState)(false);
|
|
22
|
+
const { isActiveSmartWallet, isActiveEOAWallet } = (0, useAccountWallet_1.useAccountWallet)();
|
|
23
|
+
const { account: aaAccount } = (0, components_1.useB3)();
|
|
24
|
+
// Handle EOA wallet chain switch and execute transaction
|
|
25
|
+
const handleEOASwitchChainAndSendTransaction = (0, react_1.useCallback)(async (targetChainId, params) => {
|
|
26
|
+
if (!walletClient) {
|
|
27
|
+
sonner_1.toast.error("Please connect your wallet");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const providerId = walletClient.chain.id;
|
|
31
|
+
const onCorrectChain = providerId === targetChainId;
|
|
32
|
+
// Helper function to execute the transaction
|
|
33
|
+
const executeTransaction = async () => {
|
|
34
|
+
const signer = walletClient.account;
|
|
35
|
+
if (!signer) {
|
|
36
|
+
throw new Error("No account connected");
|
|
37
|
+
}
|
|
38
|
+
const hash = await walletClient.sendTransaction({
|
|
39
|
+
account: signer,
|
|
40
|
+
chain: walletClient.chain,
|
|
41
|
+
to: params.to,
|
|
42
|
+
data: params.data,
|
|
43
|
+
value: params.value,
|
|
44
|
+
});
|
|
45
|
+
sonner_1.toast.success(`Transaction sent: ${hash.slice(0, 10)}...`);
|
|
46
|
+
return hash;
|
|
47
|
+
};
|
|
48
|
+
try {
|
|
49
|
+
setIsSwitchingOrExecuting(true);
|
|
50
|
+
if (onCorrectChain) {
|
|
51
|
+
return await executeTransaction();
|
|
52
|
+
}
|
|
53
|
+
sonner_1.toast.info(`Switching to ${(0, anyspend_1.getChainName)(targetChainId)}…`);
|
|
54
|
+
const targetChain = supported_1.supportedChains.find(chain => chain.id === targetChainId);
|
|
55
|
+
if (!targetChain) {
|
|
56
|
+
sonner_1.toast.error(`Chain ${targetChainId} is not supported`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const blockExplorerUrl = targetChain.blockExplorers?.default.url;
|
|
60
|
+
(0, invariant_1.default)(blockExplorerUrl, "Block explorer URL is required");
|
|
61
|
+
const nativeCurrency = (0, anyspend_1.getNativeToken)(targetChainId);
|
|
62
|
+
await switchChainAsync({
|
|
63
|
+
chainId: targetChainId,
|
|
64
|
+
addEthereumChainParameter: {
|
|
65
|
+
chainName: targetChain.name,
|
|
66
|
+
rpcUrls: [targetChain.rpcUrls.default.http[0]],
|
|
67
|
+
blockExplorerUrls: [blockExplorerUrl],
|
|
68
|
+
nativeCurrency: {
|
|
69
|
+
name: nativeCurrency.name,
|
|
70
|
+
symbol: nativeCurrency.symbol,
|
|
71
|
+
decimals: nativeCurrency.decimals,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
return await executeTransaction();
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
if (e?.code === -32603 || e?.message?.includes("f is not a function")) {
|
|
79
|
+
// This is a workaround for a bug in the wallet provider.
|
|
80
|
+
(0, sonner_1.toast)(`Switched to ${(0, anyspend_1.getChainName)(targetChainId)}. Executing…`);
|
|
81
|
+
return await handleEOASwitchChainAndSendTransaction(targetChainId, params);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
console.error(e);
|
|
85
|
+
sonner_1.toast.error(e?.message ?? "Unexpected error");
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
setIsSwitchingOrExecuting(false);
|
|
91
|
+
}
|
|
92
|
+
}, [walletClient, switchChainAsync]);
|
|
93
|
+
// Handle AA wallet transaction (no chain switch needed for AA)
|
|
94
|
+
const handleAASendTransaction = (0, react_1.useCallback)(async (targetChainId, params) => {
|
|
95
|
+
if (!aaAccount) {
|
|
96
|
+
sonner_1.toast.error("Smart wallet not connected");
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
setIsSwitchingOrExecuting(true);
|
|
101
|
+
const chain = (0, supported_1.getThirdwebChain)(targetChainId);
|
|
102
|
+
sonner_1.toast.info("Preparing transaction…");
|
|
103
|
+
const transaction = (0, thirdweb_2.prepareTransaction)({
|
|
104
|
+
client: thirdweb_1.client,
|
|
105
|
+
chain,
|
|
106
|
+
to: params.to,
|
|
107
|
+
data: params.data,
|
|
108
|
+
value: params.value,
|
|
109
|
+
});
|
|
110
|
+
// Check if we can use global-accounts-intents, if yes, create an intent.
|
|
111
|
+
try {
|
|
112
|
+
await app_1.default.service("global-accounts-intents").create({
|
|
113
|
+
partnerId: String(process.env.PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID || process.env.NEXT_PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID),
|
|
114
|
+
chainId: targetChainId,
|
|
115
|
+
to: params.to,
|
|
116
|
+
data: params.data || "0x",
|
|
117
|
+
value: params.value.toString(),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
console.error(err);
|
|
122
|
+
}
|
|
123
|
+
sonner_1.toast.info("Sending transaction…");
|
|
124
|
+
const sendTxResponse = await (0, thirdweb_2.sendTransaction)({
|
|
125
|
+
account: aaAccount,
|
|
126
|
+
transaction,
|
|
127
|
+
});
|
|
128
|
+
sonner_1.toast.success("Transaction sent successfully");
|
|
129
|
+
return sendTxResponse.transactionHash;
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
console.error(err);
|
|
133
|
+
sonner_1.toast.error(err?.message ?? "Transaction failed");
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
setIsSwitchingOrExecuting(false);
|
|
138
|
+
}
|
|
139
|
+
}, [aaAccount]);
|
|
140
|
+
// Unified switch chain and execute function
|
|
141
|
+
const switchChainAndExecute = (0, react_1.useCallback)(async (targetChainId, params) => {
|
|
142
|
+
// Check which wallet type is active
|
|
143
|
+
if (isActiveSmartWallet) {
|
|
144
|
+
return handleAASendTransaction(targetChainId, params);
|
|
145
|
+
}
|
|
146
|
+
else if (isActiveEOAWallet) {
|
|
147
|
+
return handleEOASwitchChainAndSendTransaction(targetChainId, params);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
sonner_1.toast.error("No wallet connected");
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
}, [isActiveSmartWallet, isActiveEOAWallet, handleAASendTransaction, handleEOASwitchChainAndSendTransaction]);
|
|
154
|
+
return {
|
|
155
|
+
switchChainAndExecute,
|
|
156
|
+
isSwitchingOrExecuting,
|
|
157
|
+
isActiveSmartWallet,
|
|
158
|
+
isActiveEOAWallet,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -62,3 +62,7 @@ export declare const b3TestnetThirdWeb: Readonly<import("thirdweb/dist/types/cha
|
|
|
62
62
|
export declare const b3Mainnet: import("viem").Chain;
|
|
63
63
|
export declare const b3Testnet: import("viem").Chain;
|
|
64
64
|
export declare const baseMainnet: import("viem").Chain;
|
|
65
|
+
/**
|
|
66
|
+
* Get a Thirdweb chain by chain ID from supportedChainsTW
|
|
67
|
+
*/
|
|
68
|
+
export declare function getThirdwebChain(chainId: number): ThirdwebChain;
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.baseMainnet = exports.b3Testnet = exports.b3Mainnet = exports.b3TestnetThirdWeb = exports.b3MainnetThirdWeb = exports.coingeckoChains = exports.supportedChainNetworks = exports.supportedChainsTW = exports.supportedChains = void 0;
|
|
7
7
|
exports.getCoingeckoChainInfo = getCoingeckoChainInfo;
|
|
8
|
+
exports.getThirdwebChain = getThirdwebChain;
|
|
8
9
|
const chain_transformers_1 = require("../../../shared/utils/chain-transformers");
|
|
9
10
|
const invariant_1 = __importDefault(require("invariant"));
|
|
10
11
|
// Import the JSON directly
|
|
@@ -52,3 +53,13 @@ exports.b3Testnet = _b3Testnet;
|
|
|
52
53
|
const _baseMainnet = exports.supportedChains.find(chain => chain.id === 8453);
|
|
53
54
|
(0, invariant_1.default)(_baseMainnet, "Base mainnet chain not found in supported chains");
|
|
54
55
|
exports.baseMainnet = _baseMainnet;
|
|
56
|
+
/**
|
|
57
|
+
* Get a Thirdweb chain by chain ID from supportedChainsTW
|
|
58
|
+
*/
|
|
59
|
+
function getThirdwebChain(chainId) {
|
|
60
|
+
const chain = exports.supportedChainsTW.find(c => c.id === chainId);
|
|
61
|
+
if (!chain) {
|
|
62
|
+
throw new Error(`Chain ${chainId} is not supported`);
|
|
63
|
+
}
|
|
64
|
+
return chain;
|
|
65
|
+
}
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"name": "Ethereum",
|
|
128
128
|
"rpcUrls": {
|
|
129
129
|
"default": {
|
|
130
|
-
"http": "https://
|
|
130
|
+
"http": "https://eth.llamarpc.com",
|
|
131
131
|
"ws": "wss://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2"
|
|
132
132
|
},
|
|
133
133
|
"backups": []
|