@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,37 @@
|
|
|
1
|
+
import { Button, useUnifiedChainSwitchAndExecute } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import type { JSX } from "react";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
|
|
5
|
+
interface SendETHButtonProps {
|
|
6
|
+
chainId: number;
|
|
7
|
+
to: `0x${string}`;
|
|
8
|
+
value: bigint;
|
|
9
|
+
className?: string;
|
|
10
|
+
children?: string | JSX.Element;
|
|
11
|
+
onSuccess?: (tx: `0x${string}`) => void;
|
|
12
|
+
onError?: (error: Error) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function SendETHButton({ chainId, to, value, className, children, onSuccess, onError }: SendETHButtonProps) {
|
|
16
|
+
const { switchChainAndExecute, isSwitchingOrExecuting } = useUnifiedChainSwitchAndExecute();
|
|
17
|
+
|
|
18
|
+
const handleSendETH = useCallback(async () => {
|
|
19
|
+
try {
|
|
20
|
+
const tx = await switchChainAndExecute(chainId, { to: to as `0x${string}`, value });
|
|
21
|
+
if (tx) {
|
|
22
|
+
onSuccess?.(tx as `0x${string}`);
|
|
23
|
+
}
|
|
24
|
+
} catch (error) {
|
|
25
|
+
onError?.(error as Error);
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}, [switchChainAndExecute, chainId, to, value, onSuccess, onError]);
|
|
29
|
+
|
|
30
|
+
const buttonText = isSwitchingOrExecuting ? "Sending..." : String(children);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Button onClick={handleSendETH} disabled={isSwitchingOrExecuting} className={className}>
|
|
34
|
+
{buttonText}
|
|
35
|
+
</Button>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -79,17 +79,15 @@ export function SignIn(props: SignInWithB3Props) {
|
|
|
79
79
|
<Menu className={`relative flex items-center ${className || ""}`} as="div">
|
|
80
80
|
{globalAddress ? (
|
|
81
81
|
<>
|
|
82
|
-
<MenuButton className="bg-
|
|
82
|
+
<MenuButton className="bg-b3-react-background group flex h-10 items-center gap-1 rounded-xl px-3">
|
|
83
83
|
{!!wallet.meta?.icon && (
|
|
84
84
|
<img
|
|
85
85
|
src={wallet.meta.icon}
|
|
86
86
|
alt={wallet.meta.icon}
|
|
87
|
-
className="bg-
|
|
87
|
+
className="bg-b3-react-primary h-6 w-6 rounded-full object-cover opacity-100"
|
|
88
88
|
/>
|
|
89
89
|
)}
|
|
90
|
-
<div className="text-
|
|
91
|
-
{ensName ? ensName : truncateAddress(globalAddress)}
|
|
92
|
-
</div>
|
|
90
|
+
<div className="text-as-primary">{ensName ? ensName : truncateAddress(globalAddress)}</div>
|
|
93
91
|
</MenuButton>
|
|
94
92
|
<Transition
|
|
95
93
|
enter="duration-200 ease-out"
|
|
@@ -100,7 +98,7 @@ export function SignIn(props: SignInWithB3Props) {
|
|
|
100
98
|
leaveTo="scale-95 opacity-0"
|
|
101
99
|
>
|
|
102
100
|
<MenuItems
|
|
103
|
-
className="b3-root
|
|
101
|
+
className="b3-root absolute -right-4 top-full min-w-64 rounded-2xl border lg:right-0"
|
|
104
102
|
modal={false}
|
|
105
103
|
// TODO: Figure out why setting anchor on mobile causes z-index issues where it appears under elements
|
|
106
104
|
anchor={isMobile ? "top end" : undefined}
|
|
@@ -110,46 +108,47 @@ export function SignIn(props: SignInWithB3Props) {
|
|
|
110
108
|
<div
|
|
111
109
|
className={cn(
|
|
112
110
|
"border-b3-react-subtle bg-b3-react-background flex cursor-pointer items-center justify-between rounded-xl p-3",
|
|
113
|
-
"hover:bg-theme-on-surface-2",
|
|
114
111
|
)}
|
|
115
112
|
onClick={() => handleSetActiveAccount(connectedEOAWallet?.id)}
|
|
116
113
|
>
|
|
117
114
|
<div className="flex items-center">
|
|
118
115
|
<img
|
|
119
|
-
className="bg-
|
|
116
|
+
className="bg-b3-react-primary h-16 w-16 rounded-full opacity-100"
|
|
120
117
|
src={eoaWalletIcon}
|
|
121
118
|
alt={connectedEOAWallet?.id}
|
|
122
119
|
/>
|
|
123
120
|
<div className="ml-4 grow">
|
|
124
|
-
{ensName && <div
|
|
125
|
-
<div
|
|
126
|
-
<div
|
|
121
|
+
{ensName && <div>{ensName}</div>}
|
|
122
|
+
<div>{truncateAddress(globalAddress)}</div>
|
|
123
|
+
<div>{walletInfo?.name}</div>
|
|
127
124
|
</div>
|
|
128
125
|
</div>
|
|
129
|
-
{isActiveEOAWallet && <Icon className="fill-
|
|
126
|
+
{isActiveEOAWallet && <Icon className="fill-b3-react-primary" name="check" />}
|
|
130
127
|
</div>
|
|
131
128
|
) : (
|
|
132
129
|
connectedSmartWallet && (
|
|
133
130
|
<div
|
|
134
131
|
className={cn(
|
|
135
132
|
"mb-2 flex cursor-pointer items-center justify-between rounded-xl p-3",
|
|
136
|
-
isActiveSmartWallet
|
|
133
|
+
isActiveSmartWallet
|
|
134
|
+
? "bg-b3-react-background"
|
|
135
|
+
: "bg-b3-react-background hover:bg-b3-react-background",
|
|
137
136
|
)}
|
|
138
137
|
onClick={() => handleSetActiveAccount(connectedSmartWallet?.id)}
|
|
139
138
|
>
|
|
140
139
|
<div className="flex items-center">
|
|
141
140
|
<img
|
|
142
|
-
className="bg-
|
|
141
|
+
className="bg-b3-react-primary h-16 w-16 rounded-full opacity-100"
|
|
143
142
|
src={smartWalletIcon}
|
|
144
143
|
alt={connectedSmartWallet?.id}
|
|
145
144
|
/>
|
|
146
|
-
<div className="pl-4
|
|
147
|
-
{ensName && <div
|
|
148
|
-
<div
|
|
149
|
-
<div
|
|
145
|
+
<div className="grow pl-4">
|
|
146
|
+
{ensName && <div>{ensName}</div>}
|
|
147
|
+
<div>{truncateAddress(globalAddress)}</div>
|
|
148
|
+
<div>Smart wallet</div>
|
|
150
149
|
</div>
|
|
151
150
|
</div>
|
|
152
|
-
{isActiveSmartWallet && <Icon className="fill-
|
|
151
|
+
{isActiveSmartWallet && <Icon className="fill-b3-react-primary" name="check" />}
|
|
153
152
|
</div>
|
|
154
153
|
)
|
|
155
154
|
)}
|
|
@@ -159,12 +158,12 @@ export function SignIn(props: SignInWithB3Props) {
|
|
|
159
158
|
</div>
|
|
160
159
|
|
|
161
160
|
<button className="mb-2 w-full space-y-1" onClick={onDisconnect}>
|
|
162
|
-
<div className="hover:bg-
|
|
161
|
+
<div className="hover:bg-b3-react-background group flex h-12 items-center rounded-xl px-4 transition-colors">
|
|
163
162
|
<Icon
|
|
164
|
-
className="fill-
|
|
163
|
+
className="fill-b3-react-background group-hover:fill-b3-react-primary mr-4 shrink-0 transition-colors"
|
|
165
164
|
name="logout"
|
|
166
165
|
/>
|
|
167
|
-
<div className="text-
|
|
166
|
+
<div className="text-b3-react-background group-hover:text-b3-react-primary mr-auto transition-colors">
|
|
168
167
|
Disconnect
|
|
169
168
|
</div>
|
|
170
169
|
</div>
|
|
@@ -196,14 +196,14 @@ export function SignInWithB3Flow({
|
|
|
196
196
|
debug("Authenticating with B3 via SIWE");
|
|
197
197
|
setIsConnected(true);
|
|
198
198
|
if (loginWithSiwe) {
|
|
199
|
-
debug("
|
|
199
|
+
debug("setIsAuthenticating:true:1");
|
|
200
200
|
setIsAuthenticating(true);
|
|
201
201
|
const userAuth = await authenticate(account, partnerId);
|
|
202
202
|
setUser(userAuth.user);
|
|
203
203
|
}
|
|
204
204
|
debug("handleLoginSuccess:account", account);
|
|
205
205
|
onLoginSuccess?.(account);
|
|
206
|
-
debug("
|
|
206
|
+
debug("setIsAuthenticating:false:1");
|
|
207
207
|
setIsAuthenticating(false);
|
|
208
208
|
},
|
|
209
209
|
[loginWithSiwe, onLoginSuccess, setIsAuthenticating, authenticate, partnerId, setUser, setIsConnected],
|
|
@@ -46,7 +46,7 @@ export function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }: Sign
|
|
|
46
46
|
await logout();
|
|
47
47
|
setIsAuthenticated(false);
|
|
48
48
|
} finally {
|
|
49
|
-
debug("
|
|
49
|
+
debug("setIsAuthenticating:false:7");
|
|
50
50
|
setIsAuthenticating(false);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -114,7 +114,7 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }: LoginStepPro
|
|
|
114
114
|
onConnect={async wallet => {
|
|
115
115
|
try {
|
|
116
116
|
setIsAuthenticating(true);
|
|
117
|
-
debug("
|
|
117
|
+
debug("setIsAuthenticating:true:6");
|
|
118
118
|
|
|
119
119
|
const account = wallet.getAccount();
|
|
120
120
|
if (!account) throw new Error("No account found");
|
|
@@ -128,7 +128,7 @@ export function LoginStep({ onSuccess, onError, partnerId, chain }: LoginStepPro
|
|
|
128
128
|
await logout();
|
|
129
129
|
setIsAuthenticated(false);
|
|
130
130
|
} finally {
|
|
131
|
-
debug("
|
|
131
|
+
debug("setIsAuthenticating:false:6");
|
|
132
132
|
setIsAuthenticating(false);
|
|
133
133
|
}
|
|
134
134
|
}}
|
|
@@ -53,7 +53,7 @@ export function LoginStepCustom({
|
|
|
53
53
|
const handleConnect = async (strategy: AllowedStrategy) => {
|
|
54
54
|
try {
|
|
55
55
|
setIsLoading(true);
|
|
56
|
-
debug("
|
|
56
|
+
debug("setIsAuthenticating:true:3");
|
|
57
57
|
setIsAuthenticating(true);
|
|
58
58
|
const options = getConnectOptionsFromStrategy(strategy);
|
|
59
59
|
let connectResult: Wallet | null;
|
|
@@ -86,7 +86,7 @@ export function LoginStepCustom({
|
|
|
86
86
|
setIsAuthenticated(false);
|
|
87
87
|
} finally {
|
|
88
88
|
setIsLoading(false);
|
|
89
|
-
debug("
|
|
89
|
+
debug("setIsAuthenticating:false:3");
|
|
90
90
|
setIsAuthenticating(false);
|
|
91
91
|
}
|
|
92
92
|
};
|
|
@@ -29,6 +29,12 @@ export { AccountAssets } from "./AccountAssets/AccountAssets";
|
|
|
29
29
|
// MintButton Components
|
|
30
30
|
export { MintButton } from "./MintButton/MintButton";
|
|
31
31
|
|
|
32
|
+
// SendETHButton Components
|
|
33
|
+
export { SendETHButton } from "./SendETHButton/SendETHButton";
|
|
34
|
+
|
|
35
|
+
// SendERC20Button Components
|
|
36
|
+
export { SendERC20Button } from "./SendERC20Button/SendERC20Button";
|
|
37
|
+
|
|
32
38
|
// Transak Components
|
|
33
39
|
export { TransakModal } from "./Transak/TransakModal";
|
|
34
40
|
|
|
@@ -26,8 +26,8 @@ const ScrollBar = React.forwardRef<
|
|
|
26
26
|
orientation={orientation}
|
|
27
27
|
className={cn(
|
|
28
28
|
"flex touch-none select-none transition-colors",
|
|
29
|
-
orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-
|
|
30
|
-
orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-
|
|
29
|
+
orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-px",
|
|
30
|
+
orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-px",
|
|
31
31
|
className,
|
|
32
32
|
)}
|
|
33
33
|
{...props}
|
|
@@ -14,7 +14,7 @@ const TooltipTrigger: React.ForwardRefExoticComponent<
|
|
|
14
14
|
> = TooltipPrimitive.Trigger;
|
|
15
15
|
|
|
16
16
|
const TooltipContent: React.ForwardRefExoticComponent<
|
|
17
|
-
|
|
17
|
+
TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>
|
|
18
18
|
> = React.forwardRef<
|
|
19
19
|
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
20
20
|
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
@@ -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";
|
|
@@ -38,4 +38,5 @@ export { useTokenFromUrl } from "./useTokenFromUrl";
|
|
|
38
38
|
export { useTokenPrice } from "./useTokenPrice";
|
|
39
39
|
export { useTokenPriceWithFallback } from "./useTokenPriceWithFallback";
|
|
40
40
|
export { useTokensFromAddress } from "./useTokensFromAddress";
|
|
41
|
+
export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute";
|
|
41
42
|
export { useURLParams } from "./useURLParams";
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { useB3, useProfile } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
3
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
4
|
import { useEffect, useMemo, useState } from "react";
|
|
4
5
|
import { getLastAuthProvider, useActiveWallet, useConnectedWallets, useWalletImage } from "thirdweb/react";
|
|
5
6
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
6
7
|
import { socialIcons } from "thirdweb/wallets/in-app";
|
|
7
8
|
|
|
9
|
+
const debug = debugB3React("useAccountWallet");
|
|
10
|
+
|
|
8
11
|
function useLastAuthProvider(): string | null {
|
|
9
12
|
const [lastAuthProvider, setLastAuthProvider] = useState<string | null>(null);
|
|
10
13
|
|
|
@@ -43,7 +46,6 @@ export function useAccountWallet(): {
|
|
|
43
46
|
const { account } = useB3();
|
|
44
47
|
|
|
45
48
|
const activeWallet = useActiveWallet();
|
|
46
|
-
|
|
47
49
|
const connectedWallets = useConnectedWallets();
|
|
48
50
|
|
|
49
51
|
const connectedSmartWallet = connectedWallets.find(wallet => wallet.id === ecosystemWalletId);
|
|
@@ -51,6 +53,13 @@ export function useAccountWallet(): {
|
|
|
51
53
|
const isActiveSmartWallet = activeWallet?.id === connectedSmartWallet?.id;
|
|
52
54
|
const isActiveEOAWallet = activeWallet?.id === connectedEOAWallet?.id;
|
|
53
55
|
|
|
56
|
+
debug("activeWallet", activeWallet);
|
|
57
|
+
debug("connectedWallets", connectedWallets);
|
|
58
|
+
debug("connectedSmartWallet", connectedSmartWallet);
|
|
59
|
+
debug("connectedEOAWallet", connectedEOAWallet);
|
|
60
|
+
debug("isActiveSmartWallet", isActiveSmartWallet);
|
|
61
|
+
debug("isActiveEOAWallet", isActiveEOAWallet);
|
|
62
|
+
|
|
54
63
|
const { data: walletImage } = useWalletImage(connectedEOAWallet?.id);
|
|
55
64
|
|
|
56
65
|
// If not EOA sign in, then we need to show the smart wallet icon
|
|
@@ -44,7 +44,7 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
44
44
|
setIsAuthenticated(true);
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
debug("
|
|
47
|
+
debug("setIsAuthenticating:true:4");
|
|
48
48
|
setIsAuthenticating(true);
|
|
49
49
|
const account = await wallet.getAccount();
|
|
50
50
|
if (!account) {
|
|
@@ -68,7 +68,7 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
68
68
|
} catch (error) {
|
|
69
69
|
debug("Auto-connect authentication failed", { error });
|
|
70
70
|
setIsAuthenticated(false);
|
|
71
|
-
debug("
|
|
71
|
+
debug("setIsAuthenticating:false:4");
|
|
72
72
|
setUser();
|
|
73
73
|
}
|
|
74
74
|
},
|
|
@@ -82,13 +82,13 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
82
82
|
// Only set isAuthenticating to false if we're not authenticated
|
|
83
83
|
// This prevents the flicker state where both isAuthenticating and isAuthenticated are false
|
|
84
84
|
const timeout = setTimeout(() => {
|
|
85
|
-
debug("
|
|
85
|
+
debug("setIsAuthenticating:false:5a");
|
|
86
86
|
setIsAuthenticating(false);
|
|
87
87
|
setIsConnecting(false);
|
|
88
88
|
}, 100); // Add a small delay to prevent quick flickers
|
|
89
89
|
return () => clearTimeout(timeout);
|
|
90
90
|
} else {
|
|
91
|
-
debug("
|
|
91
|
+
debug("setIsAuthenticating:false:5b");
|
|
92
92
|
setIsAuthenticating(false);
|
|
93
93
|
setIsConnecting(false);
|
|
94
94
|
}
|
|
@@ -3,7 +3,6 @@ import { supportedChains } from "@b3dotfun/sdk/shared/constants/chains/supported
|
|
|
3
3
|
import invariant from "invariant";
|
|
4
4
|
import { useCallback, useState } from "react";
|
|
5
5
|
import { toast } from "sonner";
|
|
6
|
-
import { WalletClient } from "viem";
|
|
7
6
|
import { useSwitchChain, useWalletClient } from "wagmi";
|
|
8
7
|
|
|
9
8
|
export function useChainSwitchWithAction() {
|
|
@@ -24,7 +23,7 @@ export function useChainSwitchWithAction() {
|
|
|
24
23
|
}, []);
|
|
25
24
|
|
|
26
25
|
const switchChainAndExecute = useCallback(
|
|
27
|
-
async (targetChainId: number, action: (
|
|
26
|
+
async (targetChainId: number, action: () => Promise<void>) => {
|
|
28
27
|
if (!walletClient) {
|
|
29
28
|
toast.error("Please connect your wallet");
|
|
30
29
|
return;
|
|
@@ -34,7 +33,7 @@ export function useChainSwitchWithAction() {
|
|
|
34
33
|
const onCorrectChain = providerId === targetChainId;
|
|
35
34
|
|
|
36
35
|
if (onCorrectChain) {
|
|
37
|
-
return run(() => action(
|
|
36
|
+
return run(() => action());
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
toast.info(`Switching to ${getChainName(targetChainId)}…`);
|
|
@@ -62,7 +61,7 @@ export function useChainSwitchWithAction() {
|
|
|
62
61
|
},
|
|
63
62
|
},
|
|
64
63
|
});
|
|
65
|
-
await run(() => action(
|
|
64
|
+
await run(() => action());
|
|
66
65
|
} catch (e: any) {
|
|
67
66
|
if (e?.code === -32603 || e?.message?.includes("f is not a function")) {
|
|
68
67
|
// This is a workaround for a bug in the wallet provider.
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
2
3
|
import { useEffect, useState } from "react";
|
|
3
4
|
import { useConnectedWallets, useWalletInfo } from "thirdweb/react";
|
|
4
5
|
import { Wallet } from "thirdweb/wallets";
|
|
5
6
|
|
|
7
|
+
const debug = debugB3React("useFirstEOA");
|
|
8
|
+
|
|
6
9
|
export default function useFirstEOA() {
|
|
7
10
|
const wallets = useConnectedWallets();
|
|
8
11
|
const isConnected = useAuthStore(state => state.isConnected);
|
|
@@ -10,26 +13,26 @@ export default function useFirstEOA() {
|
|
|
10
13
|
const [address, setAddress] = useState<string | undefined>(undefined);
|
|
11
14
|
const walletInfo = useWalletInfo(firstEOA?.id);
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
debug("Wallets", wallets);
|
|
17
|
+
debug("Is connected", isConnected);
|
|
15
18
|
|
|
16
19
|
useEffect(() => {
|
|
17
20
|
const autoSelectFirstEOAWallet = async () => {
|
|
18
21
|
// Only proceed if auto-selection is enabled and user is authenticated
|
|
19
22
|
if (!isConnected) {
|
|
20
|
-
|
|
23
|
+
debug("Not connected");
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
// Find the first EOA wallet (excluding ecosystem wallets)
|
|
25
28
|
const isEOAWallet = (wallet: Wallet) => !wallet.id.startsWith("ecosystem.");
|
|
26
29
|
const firstEOAWallet = wallets.find(isEOAWallet);
|
|
27
|
-
|
|
30
|
+
debug("First EOA wallet", firstEOAWallet);
|
|
28
31
|
|
|
29
|
-
const account =
|
|
30
|
-
|
|
32
|
+
const account = firstEOAWallet?.getAccount();
|
|
33
|
+
debug("Account", account);
|
|
31
34
|
setFirstEOA(firstEOAWallet);
|
|
32
|
-
|
|
35
|
+
debug("Address", account?.address);
|
|
33
36
|
setAddress(account?.address);
|
|
34
37
|
};
|
|
35
38
|
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { getChainName, getNativeToken } from "@b3dotfun/sdk/anyspend";
|
|
2
|
+
import app from "@b3dotfun/sdk/global-account/app";
|
|
3
|
+
import { getThirdwebChain, supportedChains } from "@b3dotfun/sdk/shared/constants/chains/supported";
|
|
4
|
+
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
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";
|
|
11
|
+
import { useAccountWallet } from "./useAccountWallet";
|
|
12
|
+
|
|
13
|
+
export interface UnifiedTransactionParams {
|
|
14
|
+
to: string;
|
|
15
|
+
data?: string;
|
|
16
|
+
value: bigint;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useUnifiedChainSwitchAndExecute() {
|
|
20
|
+
const { data: walletClient } = useWalletClient();
|
|
21
|
+
const { switchChainAsync } = useSwitchChain();
|
|
22
|
+
const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = useState(false);
|
|
23
|
+
|
|
24
|
+
const { isActiveSmartWallet, isActiveEOAWallet } = useAccountWallet();
|
|
25
|
+
const { account: aaAccount } = useB3();
|
|
26
|
+
|
|
27
|
+
// Handle EOA wallet chain switch and execute transaction
|
|
28
|
+
const handleEOASwitchChainAndSendTransaction = useCallback(
|
|
29
|
+
async (targetChainId: number, params: UnifiedTransactionParams): Promise<string | undefined> => {
|
|
30
|
+
if (!walletClient) {
|
|
31
|
+
toast.error("Please connect your wallet");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const providerId = walletClient.chain.id;
|
|
36
|
+
const onCorrectChain = providerId === targetChainId;
|
|
37
|
+
|
|
38
|
+
// Helper function to execute the transaction
|
|
39
|
+
const executeTransaction = async (): Promise<string> => {
|
|
40
|
+
const signer = walletClient.account;
|
|
41
|
+
if (!signer) {
|
|
42
|
+
throw new Error("No account connected");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const hash = await walletClient.sendTransaction({
|
|
46
|
+
account: signer,
|
|
47
|
+
chain: walletClient.chain,
|
|
48
|
+
to: params.to,
|
|
49
|
+
data: params.data as `0x${string}`,
|
|
50
|
+
value: params.value,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
toast.success(`Transaction sent: ${hash.slice(0, 10)}...`);
|
|
54
|
+
return hash;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
setIsSwitchingOrExecuting(true);
|
|
59
|
+
|
|
60
|
+
if (onCorrectChain) {
|
|
61
|
+
return await executeTransaction();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
toast.info(`Switching to ${getChainName(targetChainId)}…`);
|
|
65
|
+
|
|
66
|
+
const targetChain = supportedChains.find(chain => chain.id === targetChainId);
|
|
67
|
+
if (!targetChain) {
|
|
68
|
+
toast.error(`Chain ${targetChainId} is not supported`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const blockExplorerUrl = targetChain.blockExplorers?.default.url;
|
|
73
|
+
invariant(blockExplorerUrl, "Block explorer URL is required");
|
|
74
|
+
const nativeCurrency = getNativeToken(targetChainId);
|
|
75
|
+
|
|
76
|
+
await switchChainAsync({
|
|
77
|
+
chainId: targetChainId,
|
|
78
|
+
addEthereumChainParameter: {
|
|
79
|
+
chainName: targetChain.name,
|
|
80
|
+
rpcUrls: [targetChain.rpcUrls.default.http[0]],
|
|
81
|
+
blockExplorerUrls: [blockExplorerUrl],
|
|
82
|
+
nativeCurrency: {
|
|
83
|
+
name: nativeCurrency.name,
|
|
84
|
+
symbol: nativeCurrency.symbol,
|
|
85
|
+
decimals: nativeCurrency.decimals,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return await executeTransaction();
|
|
91
|
+
} catch (e: any) {
|
|
92
|
+
if (e?.code === -32603 || e?.message?.includes("f is not a function")) {
|
|
93
|
+
// This is a workaround for a bug in the wallet provider.
|
|
94
|
+
toast(`Switched to ${getChainName(targetChainId)}. Executing…`);
|
|
95
|
+
return await handleEOASwitchChainAndSendTransaction(targetChainId, params);
|
|
96
|
+
} else {
|
|
97
|
+
console.error(e);
|
|
98
|
+
toast.error(e?.message ?? "Unexpected error");
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
} finally {
|
|
102
|
+
setIsSwitchingOrExecuting(false);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
[walletClient, switchChainAsync],
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// Handle AA wallet transaction (no chain switch needed for AA)
|
|
109
|
+
const handleAASendTransaction = useCallback(
|
|
110
|
+
async (targetChainId: number, params: UnifiedTransactionParams): Promise<string | undefined> => {
|
|
111
|
+
if (!aaAccount) {
|
|
112
|
+
toast.error("Smart wallet not connected");
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
setIsSwitchingOrExecuting(true);
|
|
118
|
+
|
|
119
|
+
const chain = getThirdwebChain(targetChainId);
|
|
120
|
+
|
|
121
|
+
toast.info("Preparing transaction…");
|
|
122
|
+
const transaction = prepareTransaction({
|
|
123
|
+
client,
|
|
124
|
+
chain,
|
|
125
|
+
to: params.to,
|
|
126
|
+
data: params.data as `0x${string}`,
|
|
127
|
+
value: params.value,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Check if we can use global-accounts-intents, if yes, create an intent.
|
|
131
|
+
try {
|
|
132
|
+
await app.service("global-accounts-intents").create({
|
|
133
|
+
partnerId: String(
|
|
134
|
+
process.env.PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID || process.env.NEXT_PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID,
|
|
135
|
+
),
|
|
136
|
+
chainId: targetChainId,
|
|
137
|
+
to: params.to,
|
|
138
|
+
data: params.data || "0x",
|
|
139
|
+
value: params.value.toString(),
|
|
140
|
+
});
|
|
141
|
+
} catch (err: any) {
|
|
142
|
+
console.error(err);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
toast.info("Sending transaction…");
|
|
146
|
+
const sendTxResponse = await twSendTransaction({
|
|
147
|
+
account: aaAccount,
|
|
148
|
+
transaction,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
toast.success("Transaction sent successfully");
|
|
152
|
+
return sendTxResponse.transactionHash;
|
|
153
|
+
} catch (err: any) {
|
|
154
|
+
console.error(err);
|
|
155
|
+
toast.error(err?.message ?? "Transaction failed");
|
|
156
|
+
return undefined;
|
|
157
|
+
} finally {
|
|
158
|
+
setIsSwitchingOrExecuting(false);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
[aaAccount],
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
// Unified switch chain and execute function
|
|
165
|
+
const switchChainAndExecute = useCallback(
|
|
166
|
+
async (targetChainId: number, params: UnifiedTransactionParams): Promise<string | undefined> => {
|
|
167
|
+
// Check which wallet type is active
|
|
168
|
+
if (isActiveSmartWallet) {
|
|
169
|
+
return handleAASendTransaction(targetChainId, params);
|
|
170
|
+
} else if (isActiveEOAWallet) {
|
|
171
|
+
return handleEOASwitchChainAndSendTransaction(targetChainId, params);
|
|
172
|
+
} else {
|
|
173
|
+
toast.error("No wallet connected");
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
[isActiveSmartWallet, isActiveEOAWallet, handleAASendTransaction, handleEOASwitchChainAndSendTransaction],
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
switchChainAndExecute,
|
|
182
|
+
isSwitchingOrExecuting,
|
|
183
|
+
isActiveSmartWallet,
|
|
184
|
+
isActiveEOAWallet,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
@@ -66,3 +66,14 @@ export const b3Testnet = _b3Testnet;
|
|
|
66
66
|
const _baseMainnet = supportedChains.find(chain => chain.id === 8453);
|
|
67
67
|
invariant(_baseMainnet, "Base mainnet chain not found in supported chains");
|
|
68
68
|
export const baseMainnet = _baseMainnet;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Get a Thirdweb chain by chain ID from supportedChainsTW
|
|
72
|
+
*/
|
|
73
|
+
export function getThirdwebChain(chainId: number): ThirdwebChain {
|
|
74
|
+
const chain = supportedChainsTW.find(c => c.id === chainId);
|
|
75
|
+
if (!chain) {
|
|
76
|
+
throw new Error(`Chain ${chainId} is not supported`);
|
|
77
|
+
}
|
|
78
|
+
return chain;
|
|
79
|
+
}
|
|
@@ -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": []
|
package/src/styles/index.css
CHANGED
|
@@ -299,3 +299,30 @@ Dark version
|
|
|
299
299
|
letter-spacing: 0.05em;
|
|
300
300
|
font-family: "SFCompact", sans-serif;
|
|
301
301
|
}
|
|
302
|
+
|
|
303
|
+
/* Radix UI Accordion animations */
|
|
304
|
+
@keyframes accordion-down {
|
|
305
|
+
from {
|
|
306
|
+
height: 0;
|
|
307
|
+
}
|
|
308
|
+
to {
|
|
309
|
+
height: var(--radix-accordion-content-height);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
@keyframes accordion-up {
|
|
314
|
+
from {
|
|
315
|
+
height: var(--radix-accordion-content-height);
|
|
316
|
+
}
|
|
317
|
+
to {
|
|
318
|
+
height: 0;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.animate-accordion-down {
|
|
323
|
+
animation: accordion-down 0.2s ease-out;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.animate-accordion-up {
|
|
327
|
+
animation: accordion-up 0.2s ease-out;
|
|
328
|
+
}
|