@b3dotfun/sdk 0.0.23 → 0.0.24
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 +5 -8
- 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 +4 -4
- 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 +1 -1
- 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 +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
- 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/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/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 +5 -8
- 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 +4 -4
- 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 +1 -1
- 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 +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
- 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/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/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/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/useChainSwitchWithAction.d.ts +1 -2
- 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 +42 -7
- package/src/anyspend/react/components/AnySpend.tsx +5 -23
- 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 +7 -13
- 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 +2 -1
- 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 +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
- 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/useChainSwitchWithAction.ts +3 -4
- package/src/global-account/react/hooks/useFirstEOA.tsx +10 -7
- 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 +27 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button, useUnifiedChainSwitchAndExecute } from "../../../../global-account/react/index.js";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
export function SendETHButton({ chainId, to, value, className, children, onSuccess, onError }) {
|
|
5
|
+
const { switchChainAndExecute, isSwitchingOrExecuting } = useUnifiedChainSwitchAndExecute();
|
|
6
|
+
const handleSendETH = useCallback(async () => {
|
|
7
|
+
try {
|
|
8
|
+
const tx = await switchChainAndExecute(chainId, { to: to, value });
|
|
9
|
+
if (tx) {
|
|
10
|
+
onSuccess?.(tx);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
onError?.(error);
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
}, [switchChainAndExecute, chainId, to, value, onSuccess, onError]);
|
|
18
|
+
const buttonText = isSwitchingOrExecuting ? "Sending..." : String(children);
|
|
19
|
+
return (_jsx(Button, { onClick: handleSendETH, disabled: isSwitchingOrExecuting, className: className, children: buttonText }));
|
|
20
|
+
}
|
|
@@ -35,9 +35,11 @@ export function SignIn(props) {
|
|
|
35
35
|
}
|
|
36
36
|
}, [connectedEOAWallet, isActiveEOAWallet, setActiveWallet, automaticallySetFirstEoa]);
|
|
37
37
|
// Desktop version - original dropdown menu
|
|
38
|
-
return (_jsx(StyleRoot, { children: _jsx(Menu, { className: `relative flex items-center ${className || ""}`, as: "div", children: globalAddress ? (_jsxs(_Fragment, { children: [_jsxs(MenuButton, { className: "bg-
|
|
38
|
+
return (_jsx(StyleRoot, { children: _jsx(Menu, { className: `relative flex items-center ${className || ""}`, as: "div", children: globalAddress ? (_jsxs(_Fragment, { children: [_jsxs(MenuButton, { className: "bg-b3-react-background group flex h-10 items-center gap-1 rounded-xl px-3", children: [!!wallet.meta?.icon && (_jsx("img", { src: wallet.meta.icon, alt: wallet.meta.icon, className: "bg-b3-react-primary h-6 w-6 rounded-full object-cover opacity-100" })), _jsx("div", { className: "text-as-primary", children: ensName ? ensName : truncateAddress(globalAddress) })] }), _jsx(Transition, { enter: "duration-200 ease-out", enterFrom: "scale-95 opacity-0", enterTo: "scale-100 opacity-100", leave: "duration-300 ease-out", leaveFrom: "scale-100 opacity-100", leaveTo: "scale-95 opacity-0", children: _jsx(MenuItems, { className: "b3-root absolute -right-4 top-full min-w-64 rounded-2xl border lg:right-0", modal: false,
|
|
39
39
|
// TODO: Figure out why setting anchor on mobile causes z-index issues where it appears under elements
|
|
40
|
-
anchor: isMobile ? "top end" : undefined, children: _jsxs("div", { className: "bg-b3-react-background", children: [connectedEOAWallet ? (_jsxs("div", { className: cn("border-b3-react-subtle bg-b3-react-background flex cursor-pointer items-center justify-between rounded-xl p-3"
|
|
40
|
+
anchor: isMobile ? "top end" : undefined, children: _jsxs("div", { className: "bg-b3-react-background", children: [connectedEOAWallet ? (_jsxs("div", { className: cn("border-b3-react-subtle bg-b3-react-background flex cursor-pointer items-center justify-between rounded-xl p-3"), onClick: () => handleSetActiveAccount(connectedEOAWallet?.id), children: [_jsxs("div", { className: "flex items-center", children: [_jsx("img", { className: "bg-b3-react-primary h-16 w-16 rounded-full opacity-100", src: eoaWalletIcon, alt: connectedEOAWallet?.id }), _jsxs("div", { className: "ml-4 grow", children: [ensName && _jsx("div", { children: ensName }), _jsx("div", { children: truncateAddress(globalAddress) }), _jsx("div", { children: walletInfo?.name })] })] }), isActiveEOAWallet && _jsx(Icon, { className: "fill-b3-react-primary", name: "check" })] })) : (connectedSmartWallet && (_jsxs("div", { className: cn("mb-2 flex cursor-pointer items-center justify-between rounded-xl p-3", isActiveSmartWallet
|
|
41
|
+
? "bg-b3-react-background"
|
|
42
|
+
: "bg-b3-react-background hover:bg-b3-react-background"), onClick: () => handleSetActiveAccount(connectedSmartWallet?.id), children: [_jsxs("div", { className: "flex items-center", children: [_jsx("img", { className: "bg-b3-react-primary h-16 w-16 rounded-full opacity-100", src: smartWalletIcon, alt: connectedSmartWallet?.id }), _jsxs("div", { className: "grow pl-4", children: [ensName && _jsx("div", { children: ensName }), _jsx("div", { children: truncateAddress(globalAddress) }), _jsx("div", { children: "Smart wallet" })] })] }), isActiveSmartWallet && _jsx(Icon, { className: "fill-b3-react-primary", name: "check" })] }))), _jsx("div", { className: "ml-3", children: _jsx(ManageAccountButton, { ...props, className: "w-[calc(100%-12px)]" }) }), _jsx("button", { className: "mb-2 w-full space-y-1", onClick: onDisconnect, children: _jsxs("div", { className: "hover:bg-b3-react-background group flex h-12 items-center rounded-xl px-4 transition-colors", children: [_jsx(Icon, { className: "fill-b3-react-background group-hover:fill-b3-react-primary mr-4 shrink-0 transition-colors", name: "logout" }), _jsx("div", { className: "text-b3-react-background group-hover:text-b3-react-primary mr-auto transition-colors", children: "Disconnect" })] }) })] }) }) })] })) : (_jsx(SignInWithB3, { closeAfterLogin: true, onLoginSuccess: async (globalAccount) => {
|
|
41
43
|
console.log("User authenticated with Global Account!", globalAccount);
|
|
42
44
|
}, ...props })) }) }));
|
|
43
45
|
}
|
|
@@ -161,14 +161,14 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
161
161
|
debug("Authenticating with B3 via SIWE");
|
|
162
162
|
setIsConnected(true);
|
|
163
163
|
if (loginWithSiwe) {
|
|
164
|
-
debug("
|
|
164
|
+
debug("setIsAuthenticating:true:1");
|
|
165
165
|
setIsAuthenticating(true);
|
|
166
166
|
const userAuth = await authenticate(account, partnerId);
|
|
167
167
|
setUser(userAuth.user);
|
|
168
168
|
}
|
|
169
169
|
debug("handleLoginSuccess:account", account);
|
|
170
170
|
onLoginSuccess?.(account);
|
|
171
|
-
debug("
|
|
171
|
+
debug("setIsAuthenticating:false:1");
|
|
172
172
|
setIsAuthenticating(false);
|
|
173
173
|
}, [loginWithSiwe, onLoginSuccess, setIsAuthenticating, authenticate, partnerId, setUser, setIsConnected]);
|
|
174
174
|
useEffect(() => {
|
|
@@ -61,7 +61,7 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }) {
|
|
|
61
61
|
}, onConnect: async (wallet) => {
|
|
62
62
|
try {
|
|
63
63
|
setIsAuthenticating(true);
|
|
64
|
-
debug("
|
|
64
|
+
debug("setIsAuthenticating:true:6");
|
|
65
65
|
const account = wallet.getAccount();
|
|
66
66
|
if (!account)
|
|
67
67
|
throw new Error("No account found");
|
|
@@ -75,7 +75,7 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }) {
|
|
|
75
75
|
setIsAuthenticated(false);
|
|
76
76
|
}
|
|
77
77
|
finally {
|
|
78
|
-
debug("
|
|
78
|
+
debug("setIsAuthenticating:false:6");
|
|
79
79
|
setIsAuthenticating(false);
|
|
80
80
|
}
|
|
81
81
|
} }) }));
|
|
@@ -21,7 +21,7 @@ export function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategi
|
|
|
21
21
|
const handleConnect = async (strategy) => {
|
|
22
22
|
try {
|
|
23
23
|
setIsLoading(true);
|
|
24
|
-
debug("
|
|
24
|
+
debug("setIsAuthenticating:true:3");
|
|
25
25
|
setIsAuthenticating(true);
|
|
26
26
|
const options = getConnectOptionsFromStrategy(strategy);
|
|
27
27
|
let connectResult;
|
|
@@ -55,7 +55,7 @@ export function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategi
|
|
|
55
55
|
}
|
|
56
56
|
finally {
|
|
57
57
|
setIsLoading(false);
|
|
58
|
-
debug("
|
|
58
|
+
debug("setIsAuthenticating:false:3");
|
|
59
59
|
setIsAuthenticating(false);
|
|
60
60
|
}
|
|
61
61
|
};
|
|
@@ -17,6 +17,8 @@ export { RequestPermissions } from "./RequestPermissions/RequestPermissions";
|
|
|
17
17
|
export { RequestPermissionsButton } from "./RequestPermissions/RequestPermissionsButton";
|
|
18
18
|
export { AccountAssets } from "./AccountAssets/AccountAssets";
|
|
19
19
|
export { MintButton } from "./MintButton/MintButton";
|
|
20
|
+
export { SendETHButton } from "./SendETHButton/SendETHButton";
|
|
21
|
+
export { SendERC20Button } from "./SendERC20Button/SendERC20Button";
|
|
20
22
|
export { TransakModal } from "./Transak/TransakModal";
|
|
21
23
|
export { Button as CustomButton, buttonVariants as customButtonVariants } from "./custom/Button";
|
|
22
24
|
export { ClientOnly } from "./custom/ClientOnly";
|
|
@@ -23,6 +23,10 @@ export { RequestPermissionsButton } from "./RequestPermissions/RequestPermission
|
|
|
23
23
|
export { AccountAssets } from "./AccountAssets/AccountAssets.js";
|
|
24
24
|
// MintButton Components
|
|
25
25
|
export { MintButton } from "./MintButton/MintButton.js";
|
|
26
|
+
// SendETHButton Components
|
|
27
|
+
export { SendETHButton } from "./SendETHButton/SendETHButton.js";
|
|
28
|
+
// SendERC20Button Components
|
|
29
|
+
export { SendERC20Button } from "./SendERC20Button/SendERC20Button.js";
|
|
26
30
|
// Transak Components
|
|
27
31
|
export { TransakModal } from "./Transak/TransakModal.js";
|
|
28
32
|
// Custom Components
|
|
@@ -5,6 +5,6 @@ import * as React from "react";
|
|
|
5
5
|
import { cn } from "../../../../shared/utils/index.js";
|
|
6
6
|
const ScrollArea = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(ScrollAreaPrimitive.Root, { ref: ref, className: cn("relative overflow-hidden", className), ...props, children: [_jsx(ScrollAreaPrimitive.Viewport, { className: "h-full w-full rounded-[inherit]", children: children }), _jsx(ScrollBar, {}), _jsx(ScrollAreaPrimitive.Corner, {})] })));
|
|
7
7
|
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
|
8
|
-
const ScrollBar = React.forwardRef(({ className, orientation = "vertical", ...props }, ref) => (_jsx(ScrollAreaPrimitive.ScrollAreaScrollbar, { ref: ref, orientation: orientation, className: cn("flex touch-none select-none transition-colors", orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-
|
|
8
|
+
const ScrollBar = React.forwardRef(({ className, orientation = "vertical", ...props }, ref) => (_jsx(ScrollAreaPrimitive.ScrollAreaScrollbar, { ref: ref, orientation: orientation, className: cn("flex touch-none select-none transition-colors", orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-px", orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-px", className), ...props, children: _jsx(ScrollAreaPrimitive.ScrollAreaThumb, { className: "bg-border relative flex-1 rounded-full" }) })));
|
|
9
9
|
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
|
10
10
|
export { ScrollArea, ScrollBar };
|
|
@@ -3,5 +3,5 @@ import * as React from "react";
|
|
|
3
3
|
declare const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderProps>;
|
|
4
4
|
declare const Tooltip: React.FC<TooltipPrimitive.TooltipProps>;
|
|
5
5
|
declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
6
|
-
declare const TooltipContent: React.ForwardRefExoticComponent<
|
|
6
|
+
declare const TooltipContent: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
7
7
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -6,7 +6,7 @@ export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
|
|
|
6
6
|
export { useB3EnsName } from "./useB3EnsName";
|
|
7
7
|
export { useBestTransactionPath } from "./useBestTransactionPath";
|
|
8
8
|
export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
|
|
9
|
-
export
|
|
9
|
+
export * from "./useClaim";
|
|
10
10
|
export { useConnect } from "./useConnect";
|
|
11
11
|
export { useExchangeRate } from "./useExchangeRate";
|
|
12
12
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
@@ -32,4 +32,5 @@ export { useTokenFromUrl } from "./useTokenFromUrl";
|
|
|
32
32
|
export { useTokenPrice } from "./useTokenPrice";
|
|
33
33
|
export { useTokenPriceWithFallback } from "./useTokenPriceWithFallback";
|
|
34
34
|
export { useTokensFromAddress } from "./useTokensFromAddress";
|
|
35
|
+
export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute";
|
|
35
36
|
export { useURLParams } from "./useURLParams";
|
|
@@ -6,7 +6,7 @@ export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses.js";
|
|
|
6
6
|
export { useB3EnsName } from "./useB3EnsName.js";
|
|
7
7
|
export { useBestTransactionPath } from "./useBestTransactionPath.js";
|
|
8
8
|
export { useChainSwitchWithAction } from "./useChainSwitchWithAction.js";
|
|
9
|
-
export
|
|
9
|
+
export * from "./useClaim.js";
|
|
10
10
|
export { useConnect } from "./useConnect.js";
|
|
11
11
|
export { useExchangeRate } from "./useExchangeRate.js";
|
|
12
12
|
export { useGetAllTWSigners } from "./useGetAllTWSigners.js";
|
|
@@ -32,4 +32,5 @@ export { useTokenFromUrl } from "./useTokenFromUrl.js";
|
|
|
32
32
|
export { useTokenPrice } from "./useTokenPrice.js";
|
|
33
33
|
export { useTokenPriceWithFallback } from "./useTokenPriceWithFallback.js";
|
|
34
34
|
export { useTokensFromAddress } from "./useTokensFromAddress.js";
|
|
35
|
+
export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute.js";
|
|
35
36
|
export { useURLParams } from "./useURLParams.js";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useB3, useProfile } from "../../../global-account/react/index.js";
|
|
2
2
|
import { ecosystemWalletId } from "../../../shared/constants/index.js";
|
|
3
|
+
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
3
4
|
import { useEffect, useMemo, useState } from "react";
|
|
4
5
|
import { getLastAuthProvider, useActiveWallet, useConnectedWallets, useWalletImage } from "thirdweb/react";
|
|
5
6
|
import { socialIcons } from "thirdweb/wallets/in-app";
|
|
7
|
+
const debug = debugB3React("useAccountWallet");
|
|
6
8
|
function useLastAuthProvider() {
|
|
7
9
|
const [lastAuthProvider, setLastAuthProvider] = useState(null);
|
|
8
10
|
useEffect(() => {
|
|
@@ -22,6 +24,12 @@ export function useAccountWallet() {
|
|
|
22
24
|
const connectedEOAWallet = connectedWallets.find(wallet => wallet.id !== ecosystemWalletId);
|
|
23
25
|
const isActiveSmartWallet = activeWallet?.id === connectedSmartWallet?.id;
|
|
24
26
|
const isActiveEOAWallet = activeWallet?.id === connectedEOAWallet?.id;
|
|
27
|
+
debug("activeWallet", activeWallet);
|
|
28
|
+
debug("connectedWallets", connectedWallets);
|
|
29
|
+
debug("connectedSmartWallet", connectedSmartWallet);
|
|
30
|
+
debug("connectedEOAWallet", connectedEOAWallet);
|
|
31
|
+
debug("isActiveSmartWallet", isActiveSmartWallet);
|
|
32
|
+
debug("isActiveEOAWallet", isActiveEOAWallet);
|
|
25
33
|
const { data: walletImage } = useWalletImage(connectedEOAWallet?.id);
|
|
26
34
|
// If not EOA sign in, then we need to show the smart wallet icon
|
|
27
35
|
const lastAuthProvider = useLastAuthProvider();
|
|
@@ -40,7 +40,7 @@ export function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
40
40
|
setIsAuthenticated(true);
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
debug("
|
|
43
|
+
debug("setIsAuthenticating:true:4");
|
|
44
44
|
setIsAuthenticating(true);
|
|
45
45
|
const account = await wallet.getAccount();
|
|
46
46
|
if (!account) {
|
|
@@ -65,7 +65,7 @@ export function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
65
65
|
catch (error) {
|
|
66
66
|
debug("Auto-connect authentication failed", { error });
|
|
67
67
|
setIsAuthenticated(false);
|
|
68
|
-
debug("
|
|
68
|
+
debug("setIsAuthenticating:false:4");
|
|
69
69
|
setUser();
|
|
70
70
|
}
|
|
71
71
|
},
|
|
@@ -79,14 +79,14 @@ export function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
79
79
|
// Only set isAuthenticating to false if we're not authenticated
|
|
80
80
|
// This prevents the flicker state where both isAuthenticating and isAuthenticated are false
|
|
81
81
|
const timeout = setTimeout(() => {
|
|
82
|
-
debug("
|
|
82
|
+
debug("setIsAuthenticating:false:5a");
|
|
83
83
|
setIsAuthenticating(false);
|
|
84
84
|
setIsConnecting(false);
|
|
85
85
|
}, 100); // Add a small delay to prevent quick flickers
|
|
86
86
|
return () => clearTimeout(timeout);
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
89
|
-
debug("
|
|
89
|
+
debug("setIsAuthenticating:false:5b");
|
|
90
90
|
setIsAuthenticating(false);
|
|
91
91
|
setIsConnecting(false);
|
|
92
92
|
}
|
|
@@ -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
|
};
|
|
@@ -29,7 +29,7 @@ export function useChainSwitchWithAction() {
|
|
|
29
29
|
const providerId = walletClient.chain.id;
|
|
30
30
|
const onCorrectChain = providerId === targetChainId;
|
|
31
31
|
if (onCorrectChain) {
|
|
32
|
-
return run(() => action(
|
|
32
|
+
return run(() => action());
|
|
33
33
|
}
|
|
34
34
|
toast.info(`Switching to ${getChainName(targetChainId)}…`);
|
|
35
35
|
const targetChain = supportedChains.find(chain => chain.id === targetChainId);
|
|
@@ -54,7 +54,7 @@ export function useChainSwitchWithAction() {
|
|
|
54
54
|
},
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
|
-
await run(() => action(
|
|
57
|
+
await run(() => action());
|
|
58
58
|
}
|
|
59
59
|
catch (e) {
|
|
60
60
|
if (e?.code === -32603 || e?.message?.includes("f is not a function")) {
|
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
import { useAuthStore } from "../../../global-account/react/index.js";
|
|
2
|
+
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
2
3
|
import { useEffect, useState } from "react";
|
|
3
4
|
import { useConnectedWallets, useWalletInfo } from "thirdweb/react";
|
|
5
|
+
const debug = debugB3React("useFirstEOA");
|
|
4
6
|
export default function useFirstEOA() {
|
|
5
7
|
const wallets = useConnectedWallets();
|
|
6
8
|
const isConnected = useAuthStore(state => state.isConnected);
|
|
7
9
|
const [firstEOA, setFirstEOA] = useState(undefined);
|
|
8
10
|
const [address, setAddress] = useState(undefined);
|
|
9
11
|
const walletInfo = useWalletInfo(firstEOA?.id);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
debug("Wallets", wallets);
|
|
13
|
+
debug("Is connected", isConnected);
|
|
12
14
|
useEffect(() => {
|
|
13
15
|
const autoSelectFirstEOAWallet = async () => {
|
|
14
16
|
// Only proceed if auto-selection is enabled and user is authenticated
|
|
15
17
|
if (!isConnected) {
|
|
16
|
-
|
|
18
|
+
debug("Not connected");
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
21
|
// Find the first EOA wallet (excluding ecosystem wallets)
|
|
20
22
|
const isEOAWallet = (wallet) => !wallet.id.startsWith("ecosystem.");
|
|
21
23
|
const firstEOAWallet = wallets.find(isEOAWallet);
|
|
22
|
-
|
|
23
|
-
const account =
|
|
24
|
-
|
|
24
|
+
debug("First EOA wallet", firstEOAWallet);
|
|
25
|
+
const account = firstEOAWallet?.getAccount();
|
|
26
|
+
debug("Account", account);
|
|
25
27
|
setFirstEOA(firstEOAWallet);
|
|
26
|
-
|
|
28
|
+
debug("Address", account?.address);
|
|
27
29
|
setAddress(account?.address);
|
|
28
30
|
};
|
|
29
31
|
autoSelectFirstEOAWallet();
|
|
@@ -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,154 @@
|
|
|
1
|
+
import { getChainName, getNativeToken } from "../../../anyspend/index.js";
|
|
2
|
+
import app from "../../../global-account/app.js";
|
|
3
|
+
import { getThirdwebChain, supportedChains } from "../../../shared/constants/chains/supported.js";
|
|
4
|
+
import { client } from "../../../shared/utils/thirdweb.js";
|
|
5
|
+
import invariant from "invariant";
|
|
6
|
+
import { useCallback, useState } from "react";
|
|
7
|
+
import { toast } from "sonner";
|
|
8
|
+
import { prepareTransaction, sendTransaction as twSendTransaction } from "thirdweb";
|
|
9
|
+
import { useSwitchChain, useWalletClient } from "wagmi";
|
|
10
|
+
import { useB3 } from "../components/index.js";
|
|
11
|
+
import { useAccountWallet } from "./useAccountWallet.js";
|
|
12
|
+
export function useUnifiedChainSwitchAndExecute() {
|
|
13
|
+
const { data: walletClient } = useWalletClient();
|
|
14
|
+
const { switchChainAsync } = useSwitchChain();
|
|
15
|
+
const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = useState(false);
|
|
16
|
+
const { isActiveSmartWallet, isActiveEOAWallet } = useAccountWallet();
|
|
17
|
+
const { account: aaAccount } = useB3();
|
|
18
|
+
// Handle EOA wallet chain switch and execute transaction
|
|
19
|
+
const handleEOASwitchChainAndSendTransaction = useCallback(async (targetChainId, params) => {
|
|
20
|
+
if (!walletClient) {
|
|
21
|
+
toast.error("Please connect your wallet");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const providerId = walletClient.chain.id;
|
|
25
|
+
const onCorrectChain = providerId === targetChainId;
|
|
26
|
+
// Helper function to execute the transaction
|
|
27
|
+
const executeTransaction = async () => {
|
|
28
|
+
const signer = walletClient.account;
|
|
29
|
+
if (!signer) {
|
|
30
|
+
throw new Error("No account connected");
|
|
31
|
+
}
|
|
32
|
+
const hash = await walletClient.sendTransaction({
|
|
33
|
+
account: signer,
|
|
34
|
+
chain: walletClient.chain,
|
|
35
|
+
to: params.to,
|
|
36
|
+
data: params.data,
|
|
37
|
+
value: params.value,
|
|
38
|
+
});
|
|
39
|
+
toast.success(`Transaction sent: ${hash.slice(0, 10)}...`);
|
|
40
|
+
return hash;
|
|
41
|
+
};
|
|
42
|
+
try {
|
|
43
|
+
setIsSwitchingOrExecuting(true);
|
|
44
|
+
if (onCorrectChain) {
|
|
45
|
+
return await executeTransaction();
|
|
46
|
+
}
|
|
47
|
+
toast.info(`Switching to ${getChainName(targetChainId)}…`);
|
|
48
|
+
const targetChain = supportedChains.find(chain => chain.id === targetChainId);
|
|
49
|
+
if (!targetChain) {
|
|
50
|
+
toast.error(`Chain ${targetChainId} is not supported`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const blockExplorerUrl = targetChain.blockExplorers?.default.url;
|
|
54
|
+
invariant(blockExplorerUrl, "Block explorer URL is required");
|
|
55
|
+
const nativeCurrency = getNativeToken(targetChainId);
|
|
56
|
+
await switchChainAsync({
|
|
57
|
+
chainId: targetChainId,
|
|
58
|
+
addEthereumChainParameter: {
|
|
59
|
+
chainName: targetChain.name,
|
|
60
|
+
rpcUrls: [targetChain.rpcUrls.default.http[0]],
|
|
61
|
+
blockExplorerUrls: [blockExplorerUrl],
|
|
62
|
+
nativeCurrency: {
|
|
63
|
+
name: nativeCurrency.name,
|
|
64
|
+
symbol: nativeCurrency.symbol,
|
|
65
|
+
decimals: nativeCurrency.decimals,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
return await executeTransaction();
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
if (e?.code === -32603 || e?.message?.includes("f is not a function")) {
|
|
73
|
+
// This is a workaround for a bug in the wallet provider.
|
|
74
|
+
toast(`Switched to ${getChainName(targetChainId)}. Executing…`);
|
|
75
|
+
return await handleEOASwitchChainAndSendTransaction(targetChainId, params);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.error(e);
|
|
79
|
+
toast.error(e?.message ?? "Unexpected error");
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
setIsSwitchingOrExecuting(false);
|
|
85
|
+
}
|
|
86
|
+
}, [walletClient, switchChainAsync]);
|
|
87
|
+
// Handle AA wallet transaction (no chain switch needed for AA)
|
|
88
|
+
const handleAASendTransaction = useCallback(async (targetChainId, params) => {
|
|
89
|
+
if (!aaAccount) {
|
|
90
|
+
toast.error("Smart wallet not connected");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
setIsSwitchingOrExecuting(true);
|
|
95
|
+
const chain = getThirdwebChain(targetChainId);
|
|
96
|
+
toast.info("Preparing transaction…");
|
|
97
|
+
const transaction = prepareTransaction({
|
|
98
|
+
client,
|
|
99
|
+
chain,
|
|
100
|
+
to: params.to,
|
|
101
|
+
data: params.data,
|
|
102
|
+
value: params.value,
|
|
103
|
+
});
|
|
104
|
+
// Check if we can use global-accounts-intents, if yes, create an intent.
|
|
105
|
+
try {
|
|
106
|
+
await app.service("global-accounts-intents").create({
|
|
107
|
+
partnerId: String(process.env.PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID || process.env.NEXT_PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID),
|
|
108
|
+
chainId: targetChainId,
|
|
109
|
+
to: params.to,
|
|
110
|
+
data: params.data || "0x",
|
|
111
|
+
value: params.value.toString(),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
console.error(err);
|
|
116
|
+
}
|
|
117
|
+
toast.info("Sending transaction…");
|
|
118
|
+
const sendTxResponse = await twSendTransaction({
|
|
119
|
+
account: aaAccount,
|
|
120
|
+
transaction,
|
|
121
|
+
});
|
|
122
|
+
toast.success("Transaction sent successfully");
|
|
123
|
+
return sendTxResponse.transactionHash;
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
console.error(err);
|
|
127
|
+
toast.error(err?.message ?? "Transaction failed");
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
setIsSwitchingOrExecuting(false);
|
|
132
|
+
}
|
|
133
|
+
}, [aaAccount]);
|
|
134
|
+
// Unified switch chain and execute function
|
|
135
|
+
const switchChainAndExecute = useCallback(async (targetChainId, params) => {
|
|
136
|
+
// Check which wallet type is active
|
|
137
|
+
if (isActiveSmartWallet) {
|
|
138
|
+
return handleAASendTransaction(targetChainId, params);
|
|
139
|
+
}
|
|
140
|
+
else if (isActiveEOAWallet) {
|
|
141
|
+
return handleEOASwitchChainAndSendTransaction(targetChainId, params);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
toast.error("No wallet connected");
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
}, [isActiveSmartWallet, isActiveEOAWallet, handleAASendTransaction, handleEOASwitchChainAndSendTransaction]);
|
|
148
|
+
return {
|
|
149
|
+
switchChainAndExecute,
|
|
150
|
+
isSwitchingOrExecuting,
|
|
151
|
+
isActiveSmartWallet,
|
|
152
|
+
isActiveEOAWallet,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
@@ -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;
|
|
@@ -45,3 +45,13 @@ export const b3Testnet = _b3Testnet;
|
|
|
45
45
|
const _baseMainnet = supportedChains.find(chain => chain.id === 8453);
|
|
46
46
|
invariant(_baseMainnet, "Base mainnet chain not found in supported chains");
|
|
47
47
|
export const baseMainnet = _baseMainnet;
|
|
48
|
+
/**
|
|
49
|
+
* Get a Thirdweb chain by chain ID from supportedChainsTW
|
|
50
|
+
*/
|
|
51
|
+
export function getThirdwebChain(chainId) {
|
|
52
|
+
const chain = supportedChainsTW.find(c => c.id === chainId);
|
|
53
|
+
if (!chain) {
|
|
54
|
+
throw new Error(`Chain ${chainId} is not supported`);
|
|
55
|
+
}
|
|
56
|
+
return chain;
|
|
57
|
+
}
|
|
@@ -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": []
|