@b3dotfun/sdk 0.0.29 → 0.0.30-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/constants/index.d.ts +1 -0
- package/dist/cjs/anyspend/constants/index.js +2 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +23 -24
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +2 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +17 -10
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +9 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +124 -41
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +6 -3
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +6 -4
- package/dist/cjs/anyspend/react/components/common/OrderStatus.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PaySection.js +6 -4
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +34 -3
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/cjs/bondkit/abis/BondkitTokenABI.d.ts +62 -17
- package/dist/cjs/bondkit/abis/BondkitTokenABI.js +41 -9
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.d.ts +0 -25
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.js +0 -9
- package/dist/cjs/bondkit/constants.js +1 -1
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +28 -15
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/cjs/global-account/react/hooks/useB3BalanceFromAddresses.js +2 -1
- package/dist/cjs/global-account/react/hooks/useNativeBalance.js +2 -1
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +1 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -2
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/cjs/shared/constants/chains/supported.d.ts +4 -4
- package/dist/cjs/shared/constants/index.d.ts +1 -0
- package/dist/cjs/shared/constants/index.js +2 -1
- package/dist/esm/anyspend/constants/index.d.ts +1 -0
- package/dist/esm/anyspend/constants/index.js +1 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +23 -24
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +2 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +19 -12
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +126 -43
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +7 -4
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +7 -5
- package/dist/esm/anyspend/react/components/common/OrderStatus.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +1 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaySection.js +7 -5
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +35 -4
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/esm/bondkit/abis/BondkitTokenABI.d.ts +62 -17
- package/dist/esm/bondkit/abis/BondkitTokenABI.js +41 -9
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.d.ts +0 -25
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.js +0 -9
- package/dist/esm/bondkit/constants.js +1 -1
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +28 -15
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/esm/global-account/react/hooks/useB3BalanceFromAddresses.js +2 -1
- package/dist/esm/global-account/react/hooks/useNativeBalance.js +2 -1
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +1 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -2
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/esm/shared/constants/chains/supported.d.ts +4 -4
- package/dist/esm/shared/constants/index.d.ts +1 -0
- package/dist/esm/shared/constants/index.js +1 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/types/anyspend/react/components/common/OrderStatus.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/types/bondkit/abis/BondkitTokenABI.d.ts +62 -17
- package/dist/types/bondkit/abis/BondkitTokenFactoryABI.d.ts +0 -25
- package/dist/types/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -2
- package/dist/types/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/types/shared/constants/chains/supported.d.ts +4 -4
- package/dist/types/shared/constants/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +2 -0
- package/src/anyspend/react/components/AnySpend.tsx +2 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +28 -28
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +2 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +1 -1
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +2 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +143 -130
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +9 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +243 -104
- package/src/anyspend/react/components/common/OrderDetails.tsx +7 -3
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +10 -4
- package/src/anyspend/react/components/common/OrderStatus.tsx +9 -2
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +2 -2
- package/src/anyspend/react/components/common/PanelOnramp.tsx +3 -1
- package/src/anyspend/react/components/common/PaySection.tsx +10 -8
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +41 -3
- package/src/bondkit/abis/BondkitTokenABI.ts +41 -9
- package/src/bondkit/abis/BondkitTokenFactoryABI.ts +0 -9
- package/src/bondkit/constants.ts +1 -1
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +26 -10
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +5 -1
- package/src/global-account/react/hooks/useB3BalanceFromAddresses.ts +2 -1
- package/src/global-account/react/hooks/useNativeBalance.tsx +2 -1
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +1 -0
- package/src/global-account/react/stores/useModalStore.ts +4 -2
- package/src/shared/constants/index.ts +2 -0
- package/dist/cjs/anyspend/abis/bondKit.d.ts +0 -35
- package/dist/cjs/anyspend/abis/bondKit.js +0 -29
- package/dist/esm/anyspend/abis/bondKit.d.ts +0 -35
- package/dist/esm/anyspend/abis/bondKit.js +0 -26
- package/dist/types/anyspend/abis/bondKit.d.ts +0 -35
- package/src/anyspend/abis/bondKit.ts +0 -26
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useAccountWallet } from "@b3dotfun/sdk/global-account/react";
|
|
4
|
-
import { thirdwebB3Mainnet } from "@b3dotfun/sdk/shared/constants/chains/b3Chain";
|
|
5
4
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
6
5
|
import { shortenAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
|
|
7
|
-
import {
|
|
8
|
-
import { ChevronLeft, ChevronRightCircle, Wallet, X } from "lucide-react";
|
|
6
|
+
import { ChevronLeft, ChevronRightCircle, Wallet, X, ZapIcon } from "lucide-react";
|
|
9
7
|
import { useState } from "react";
|
|
10
8
|
import { createPortal } from "react-dom";
|
|
11
9
|
import { toast } from "sonner";
|
|
12
|
-
import {
|
|
13
|
-
import { createWallet } from "thirdweb/wallets";
|
|
14
|
-
import { useDisconnect } from "wagmi";
|
|
10
|
+
import { useAccount, useConnect, useDisconnect, useWalletClient } from "wagmi";
|
|
15
11
|
|
|
16
12
|
export enum CryptoPaymentMethodType {
|
|
17
13
|
NONE = "none",
|
|
@@ -41,20 +37,110 @@ export function CryptoPaymentMethod({
|
|
|
41
37
|
onSelectPaymentMethod,
|
|
42
38
|
}: CryptoPaymentMethodProps) {
|
|
43
39
|
const { wallet: globalWallet } = useAccountWallet();
|
|
44
|
-
const
|
|
40
|
+
const { address, isConnected, connector } = useAccount();
|
|
41
|
+
const { connect, connectors, isPending } = useConnect();
|
|
45
42
|
const { disconnect } = useDisconnect();
|
|
46
|
-
const {
|
|
43
|
+
const { data: walletClient } = useWalletClient();
|
|
47
44
|
const [showWalletModal, setShowWalletModal] = useState(false);
|
|
48
45
|
|
|
49
|
-
// Define available
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
// Define available wallet connectors
|
|
47
|
+
const availableConnectors = connectors.filter(connector =>
|
|
48
|
+
["MetaMask", "WalletConnect", "Coinbase Wallet", "Rainbow"].includes(connector.name),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// Define wallet options with icons and info
|
|
52
|
+
const walletOptions = [
|
|
53
|
+
{
|
|
54
|
+
id: "metamask",
|
|
55
|
+
name: "MetaMask",
|
|
56
|
+
icon: "🦊",
|
|
57
|
+
description: "Connect using MetaMask browser extension",
|
|
58
|
+
connector: availableConnectors.find(c => c.name === "MetaMask"),
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "coinbase",
|
|
62
|
+
name: "Coinbase Wallet",
|
|
63
|
+
icon: "🔵",
|
|
64
|
+
description: "Connect using Coinbase Wallet",
|
|
65
|
+
connector: availableConnectors.find(c => c.name === "Coinbase Wallet"),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "rainbow",
|
|
69
|
+
name: "Rainbow",
|
|
70
|
+
icon: "🌈",
|
|
71
|
+
description: "Connect using Rainbow wallet",
|
|
72
|
+
connector: availableConnectors.find(c => c.name === "Rainbow"),
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: "walletconnect",
|
|
76
|
+
name: "WalletConnect",
|
|
77
|
+
icon: "🔗",
|
|
78
|
+
description: "Connect using WalletConnect protocol",
|
|
79
|
+
connector: availableConnectors.find(c => c.name === "WalletConnect"),
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: "phantom",
|
|
83
|
+
name: "Phantom",
|
|
84
|
+
icon: "https://phantom.app/favicon.ico",
|
|
85
|
+
description: "Connect using Phantom wallet",
|
|
86
|
+
connector: availableConnectors.find(c => c.name === "Phantom"),
|
|
87
|
+
},
|
|
88
|
+
].filter(wallet => wallet.connector); // Only show wallets that have available connectors
|
|
89
|
+
|
|
90
|
+
// Reset modal state when closing
|
|
91
|
+
const handleCloseModal = () => {
|
|
92
|
+
setShowWalletModal(false);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Function to request wallet permissions for specific wallet
|
|
96
|
+
const requestWalletPermissions = async (walletConnector?: any) => {
|
|
97
|
+
try {
|
|
98
|
+
// If a specific wallet connector is provided and it's different from current
|
|
99
|
+
if (walletConnector && connector?.name !== walletConnector.name) {
|
|
100
|
+
// Disconnect current and connect to the selected wallet
|
|
101
|
+
// if (isConnected) {
|
|
102
|
+
// disconnect();
|
|
103
|
+
// // Small delay to ensure disconnection
|
|
104
|
+
// await new Promise(resolve => setTimeout(resolve, 100));
|
|
105
|
+
// }
|
|
106
|
+
await connect({ connector: walletConnector });
|
|
107
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
108
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
109
|
+
toast.success(`Connected to ${walletConnector.name}`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// If same wallet or no specific wallet, request permissions for account switching
|
|
114
|
+
if (walletClient && "request" in walletClient) {
|
|
115
|
+
await walletClient.request({
|
|
116
|
+
method: "wallet_requestPermissions",
|
|
117
|
+
params: [{ eth_accounts: {} }],
|
|
118
|
+
});
|
|
119
|
+
toast.success("Account selection completed");
|
|
120
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
121
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
122
|
+
} else {
|
|
123
|
+
// Fallback: show modal for manual wallet selection
|
|
124
|
+
setShowWalletModal(true);
|
|
125
|
+
}
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.error("Failed to request wallet permissions:", error);
|
|
128
|
+
if (error && typeof error === "object" && "message" in error) {
|
|
129
|
+
const errorMessage = (error as any).message.toLowerCase();
|
|
130
|
+
if (
|
|
131
|
+
errorMessage.includes("rejected") ||
|
|
132
|
+
errorMessage.includes("denied") ||
|
|
133
|
+
errorMessage.includes("cancelled")
|
|
134
|
+
) {
|
|
135
|
+
toast.error("Account selection cancelled");
|
|
136
|
+
} else {
|
|
137
|
+
toast.error("Failed to open account selection");
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
toast.error("Failed to open account selection");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
58
144
|
|
|
59
145
|
return (
|
|
60
146
|
<div className="crypto-payment-method mx-auto h-fit w-[460px] max-w-full">
|
|
@@ -68,78 +154,32 @@ export function CryptoPaymentMethod({
|
|
|
68
154
|
</button>
|
|
69
155
|
<div className="flex items-center justify-around gap-4">
|
|
70
156
|
<div className="flex-1 text-center">
|
|
71
|
-
<h2 className="text-as-primary text-lg font-semibold">
|
|
157
|
+
<h2 className="text-as-primary text-lg font-semibold">Select a payment method</h2>
|
|
72
158
|
</div>
|
|
73
159
|
</div>
|
|
74
160
|
|
|
75
161
|
{/* Payment Methods */}
|
|
76
|
-
<div className="crypto-payment-methods flex flex-col gap-
|
|
77
|
-
{/* Connect Wallet
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
<div className="flex flex-col items-start text-left">
|
|
89
|
-
<h4 className="text-as-primary font-semibold">Connect wallet</h4>
|
|
90
|
-
<p className="text-as-primary/60 text-sm">Choose from multiple wallet options</p>
|
|
91
|
-
</div>
|
|
162
|
+
<div className="crypto-payment-methods flex flex-col gap-6">
|
|
163
|
+
{/* Connect Wallet Section */}
|
|
164
|
+
<button
|
|
165
|
+
onClick={() => {
|
|
166
|
+
// Always show wallet selection modal first
|
|
167
|
+
setShowWalletModal(true);
|
|
168
|
+
}}
|
|
169
|
+
className="crypto-payment-method-connect-wallet bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md"
|
|
170
|
+
>
|
|
171
|
+
<div className="flex items-center gap-3">
|
|
172
|
+
<div className="wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-blue-100">
|
|
173
|
+
<Wallet className="h-4 w-4 text-blue-600" />
|
|
92
174
|
</div>
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
) : (
|
|
96
|
-
// Connected - show wallet info
|
|
97
|
-
<div className="crypto-payment-method-connect-wallet wallet-connected bg-as-surface-primary border-as-border-secondary rounded-xl border">
|
|
98
|
-
<div className="flex items-center justify-between p-4">
|
|
99
|
-
<div className="flex items-center gap-3">
|
|
100
|
-
{globalWallet?.meta?.icon ? (
|
|
101
|
-
<img src={globalWallet.meta.icon} alt="Connected Wallet" className="h-8 w-8 rounded-full" />
|
|
102
|
-
) : (
|
|
103
|
-
<div className="wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-green-100">
|
|
104
|
-
<Wallet className="h-4 w-4 text-green-600" />
|
|
105
|
-
</div>
|
|
106
|
-
)}
|
|
107
|
-
<div className="flex flex-col">
|
|
108
|
-
<span className="text-as-primary font-semibold">Connected Wallet</span>
|
|
109
|
-
<span className="text-as-primary/60 text-sm">
|
|
110
|
-
{shortenAddress(activeWallet.getAccount()?.address || "")}
|
|
111
|
-
</span>
|
|
112
|
-
</div>
|
|
113
|
-
</div>
|
|
114
|
-
<div className="flex items-center gap-2">
|
|
115
|
-
<button
|
|
116
|
-
onClick={() => {
|
|
117
|
-
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
118
|
-
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
119
|
-
}}
|
|
120
|
-
className="bg-as-brand hover:bg-as-brand/90 rounded-lg px-3 py-1.5 text-sm font-medium text-white transition-colors"
|
|
121
|
-
>
|
|
122
|
-
Use Wallet
|
|
123
|
-
</button>
|
|
124
|
-
<button
|
|
125
|
-
onClick={async () => {
|
|
126
|
-
disconnect();
|
|
127
|
-
disconnectThirdweb(activeWallet);
|
|
128
|
-
toast.success("Wallet disconnected");
|
|
129
|
-
if (selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
130
|
-
setSelectedPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
131
|
-
}
|
|
132
|
-
}}
|
|
133
|
-
className="text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors"
|
|
134
|
-
>
|
|
135
|
-
<X className="h-4 w-4" />
|
|
136
|
-
</button>
|
|
137
|
-
</div>
|
|
175
|
+
<div className="flex flex-col items-start text-left">
|
|
176
|
+
<h4 className="text-as-primary font-semibold">Connect wallet</h4>
|
|
138
177
|
</div>
|
|
139
178
|
</div>
|
|
140
|
-
|
|
179
|
+
<ChevronRightCircle className="text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" />
|
|
180
|
+
</button>
|
|
141
181
|
|
|
142
|
-
{/* Transfer Crypto
|
|
182
|
+
{/* Transfer Crypto Section */}
|
|
143
183
|
<button
|
|
144
184
|
onClick={() => {
|
|
145
185
|
setSelectedPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
@@ -148,46 +188,145 @@ export function CryptoPaymentMethod({
|
|
|
148
188
|
disabled={isCreatingOrder}
|
|
149
189
|
className="crypto-payment-method-transfer bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md"
|
|
150
190
|
>
|
|
151
|
-
<div className="flex
|
|
152
|
-
<
|
|
191
|
+
<div className="flex items-center gap-3">
|
|
192
|
+
<div className="wallet-icon flex h-8 w-8 items-center justify-center rounded-full bg-orange-100">
|
|
193
|
+
<ZapIcon className="h-4 w-4" />
|
|
194
|
+
</div>
|
|
195
|
+
<div className="flex flex-col items-start text-left">
|
|
196
|
+
<h4 className="text-as-primary font-semibold">Transfer crypto</h4>
|
|
197
|
+
</div>
|
|
153
198
|
</div>
|
|
154
199
|
<ChevronRightCircle className="text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" />
|
|
155
200
|
</button>
|
|
201
|
+
|
|
202
|
+
{/* Installed Wallets Section */}
|
|
203
|
+
{isConnected && (
|
|
204
|
+
<div className="installed-wallets">
|
|
205
|
+
<h3 className="text-as-primary/80 mb-3 text-sm font-medium">Connected wallets</h3>
|
|
206
|
+
<div className="space-y-2">
|
|
207
|
+
{/* Current Connected Wallet */}
|
|
208
|
+
<button
|
|
209
|
+
onClick={() => {
|
|
210
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
211
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
212
|
+
toast.success(`Selected ${connector?.name || "wallet"}`);
|
|
213
|
+
}}
|
|
214
|
+
className={cn(
|
|
215
|
+
"crypto-payment-method-connect-wallet w-full rounded-xl border p-4 text-left transition-all hover:shadow-md",
|
|
216
|
+
selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET
|
|
217
|
+
? "connected-wallet border-as-brand bg-as-brand/5"
|
|
218
|
+
: "border-as-border-secondary bg-as-surface-primary hover:border-as-secondary/80",
|
|
219
|
+
)}
|
|
220
|
+
>
|
|
221
|
+
<div className="flex items-center justify-between">
|
|
222
|
+
<div className="flex items-center gap-3">
|
|
223
|
+
{globalWallet?.meta?.icon ? (
|
|
224
|
+
<img src={globalWallet.meta.icon} alt="Wallet" className="h-10 w-10 rounded-full" />
|
|
225
|
+
) : (
|
|
226
|
+
<div className="wallet-icon flex h-10 w-10 items-center justify-center rounded-full bg-blue-100">
|
|
227
|
+
<Wallet className="h-5 w-5 text-blue-600" />
|
|
228
|
+
</div>
|
|
229
|
+
)}
|
|
230
|
+
<div className="flex flex-col">
|
|
231
|
+
<span className="text-as-primary font-semibold">{connector?.name || "Connected Wallet"}</span>
|
|
232
|
+
<span className="text-as-primary/60 text-sm">{shortenAddress(address || "")}</span>
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
<div className="flex items-center gap-2">
|
|
236
|
+
{selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET && (
|
|
237
|
+
<div className="h-2 w-2 rounded-full bg-green-500"></div>
|
|
238
|
+
)}
|
|
239
|
+
<button
|
|
240
|
+
onClick={e => {
|
|
241
|
+
e.stopPropagation();
|
|
242
|
+
disconnect();
|
|
243
|
+
toast.success("Wallet disconnected");
|
|
244
|
+
if (selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
245
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
246
|
+
}
|
|
247
|
+
}}
|
|
248
|
+
className="text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors"
|
|
249
|
+
>
|
|
250
|
+
<X className="h-4 w-4" />
|
|
251
|
+
</button>
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
</button>
|
|
255
|
+
</div>
|
|
256
|
+
</div>
|
|
257
|
+
)}
|
|
156
258
|
</div>
|
|
157
259
|
</div>
|
|
158
260
|
|
|
159
261
|
{/* Wallet Connection Modal */}
|
|
160
262
|
{showWalletModal &&
|
|
161
263
|
createPortal(
|
|
162
|
-
<div className="pointer-events-auto fixed inset-0 z-[9999] flex items-center justify-center bg-black/50">
|
|
264
|
+
<div className="wallet-connection-modal pointer-events-auto fixed inset-0 z-[9999] flex items-center justify-center bg-black/50">
|
|
163
265
|
<div className="max-h-[80vh] w-[400px] max-w-[90vw] overflow-auto rounded-xl bg-white p-6 dark:bg-gray-900">
|
|
164
266
|
<div className="mb-4 flex items-center justify-between">
|
|
165
|
-
<h3 className="text-lg font-semibold text-gray-900 dark:text-white">
|
|
267
|
+
<h3 className="text-lg font-semibold text-gray-900 dark:text-white">
|
|
268
|
+
{isConnected ? "Switch wallet or account" : "Choose wallet to connect"}
|
|
269
|
+
</h3>
|
|
166
270
|
<button
|
|
167
|
-
onClick={
|
|
271
|
+
onClick={handleCloseModal}
|
|
168
272
|
className="text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"
|
|
169
273
|
>
|
|
170
274
|
<X className="h-5 w-5" />
|
|
171
275
|
</button>
|
|
172
276
|
</div>
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
277
|
+
|
|
278
|
+
<div className="space-y-4">
|
|
279
|
+
{/* Custom wallet options */}
|
|
280
|
+
<div className="space-y-3">
|
|
281
|
+
{walletOptions.map(walletOption => {
|
|
282
|
+
const isCurrentWallet = isConnected && connector?.name === walletOption.connector?.name;
|
|
283
|
+
|
|
284
|
+
return (
|
|
285
|
+
<button
|
|
286
|
+
key={walletOption.id}
|
|
287
|
+
onClick={async () => {
|
|
288
|
+
handleCloseModal();
|
|
289
|
+
await requestWalletPermissions(walletOption.connector);
|
|
290
|
+
}}
|
|
291
|
+
disabled={isPending}
|
|
292
|
+
className={`wallet-option w-full rounded-xl border p-4 text-left transition-all hover:shadow-md disabled:opacity-50 ${
|
|
293
|
+
isCurrentWallet
|
|
294
|
+
? "wallet-option--active border-blue-500 bg-blue-50 dark:bg-blue-900/20"
|
|
295
|
+
: "border-gray-200 bg-white hover:border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:hover:border-gray-500"
|
|
296
|
+
}`}
|
|
297
|
+
>
|
|
298
|
+
<div className="flex items-center justify-between">
|
|
299
|
+
<div className="flex items-center gap-3">
|
|
300
|
+
<div
|
|
301
|
+
className={`flex h-12 w-12 items-center justify-center rounded-xl text-xl ${
|
|
302
|
+
isCurrentWallet ? "bg-blue-100 dark:bg-blue-800" : "bg-gray-100 dark:bg-gray-700"
|
|
303
|
+
}`}
|
|
304
|
+
>
|
|
305
|
+
{walletOption.icon}
|
|
306
|
+
</div>
|
|
307
|
+
<div>
|
|
308
|
+
<div className="flex items-center gap-2">
|
|
309
|
+
<div className="text-sm font-semibold text-gray-900 dark:text-white">
|
|
310
|
+
{walletOption.name}
|
|
311
|
+
</div>
|
|
312
|
+
{isCurrentWallet && (
|
|
313
|
+
<span className="rounded-full bg-blue-100 px-2 py-0.5 text-xs font-medium text-blue-700 dark:bg-blue-800 dark:text-blue-200">
|
|
314
|
+
Connected
|
|
315
|
+
</span>
|
|
316
|
+
)}
|
|
317
|
+
</div>
|
|
318
|
+
<div className="text-xs text-gray-500 dark:text-gray-400">
|
|
319
|
+
{isCurrentWallet ? "Switch account or reconnect" : walletOption.description}
|
|
320
|
+
</div>
|
|
321
|
+
</div>
|
|
322
|
+
</div>
|
|
323
|
+
<ChevronRightCircle className="h-5 w-5 text-gray-400" />
|
|
324
|
+
</div>
|
|
325
|
+
</button>
|
|
326
|
+
);
|
|
327
|
+
})}
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
191
330
|
</div>
|
|
192
331
|
</div>,
|
|
193
332
|
typeof window !== "undefined" ? document.getElementById("b3-root") || document.body : document.body,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
ALL_CHAINS,
|
|
5
|
+
DEPOSIT_HYPE_ACTION,
|
|
5
6
|
getChainName,
|
|
6
7
|
getErrorDisplay,
|
|
7
8
|
getExplorerTxUrl,
|
|
@@ -97,6 +98,9 @@ function getOrderSuccessText({
|
|
|
97
98
|
actionText = `funded ${tournament?.name}`;
|
|
98
99
|
return `Successfully ${actionText}`;
|
|
99
100
|
case "custom":
|
|
101
|
+
if (order.metadata.action === DEPOSIT_HYPE_ACTION) {
|
|
102
|
+
return `Successfully deposited ${formatTokenAmount(BigInt(order.payload?.amount || "0"), 18)} HYPE to ${recipient}`;
|
|
103
|
+
}
|
|
100
104
|
actionText = order.metadata.action || `executed contract`;
|
|
101
105
|
return `Successfully ${actionText}`;
|
|
102
106
|
default:
|
|
@@ -225,7 +229,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
225
229
|
const [showQRCode, setShowQRCode] = useState(false);
|
|
226
230
|
const { isLoading: txLoading, isSuccess: txSuccess } = useWaitForTransactionReceipt({ hash: txHash });
|
|
227
231
|
|
|
228
|
-
const {
|
|
232
|
+
const { switchChainAndExecuteWithEOA, isSwitchingOrExecuting } = useUnifiedChainSwitchAndExecute();
|
|
229
233
|
|
|
230
234
|
const { colorMode } = useColorMode();
|
|
231
235
|
|
|
@@ -260,12 +264,12 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
260
264
|
value = BigInt(0);
|
|
261
265
|
}
|
|
262
266
|
|
|
263
|
-
const txHash = await
|
|
267
|
+
const txHash = await switchChainAndExecuteWithEOA(order.srcChain, { to, data: txData, value });
|
|
264
268
|
|
|
265
269
|
if (txHash) {
|
|
266
270
|
setTxHash(txHash as `0x${string}`);
|
|
267
271
|
}
|
|
268
|
-
}, [order,
|
|
272
|
+
}, [order, switchChainAndExecuteWithEOA]);
|
|
269
273
|
|
|
270
274
|
// Main payment handler that triggers chain switch and payment
|
|
271
275
|
const handlePayment = async () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { ALL_CHAINS, capitalizeFirstLetter, getChainName } from "@b3dotfun/sdk/anyspend";
|
|
3
|
+
import { ALL_CHAINS, capitalizeFirstLetter, DEPOSIT_HYPE_ACTION, getChainName } from "@b3dotfun/sdk/anyspend";
|
|
4
4
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
5
5
|
import { CopyToClipboard } from "@b3dotfun/sdk/global-account/react";
|
|
6
6
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
@@ -94,9 +94,11 @@ export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({
|
|
|
94
94
|
: order.type === "fund_tournament"
|
|
95
95
|
? "Fund tournament"
|
|
96
96
|
: order.type === "custom"
|
|
97
|
-
? order.metadata.action
|
|
98
|
-
?
|
|
99
|
-
:
|
|
97
|
+
? order.metadata.action === DEPOSIT_HYPE_ACTION
|
|
98
|
+
? "Deposit HYPE"
|
|
99
|
+
: order.metadata.action
|
|
100
|
+
? capitalizeFirstLetter(order.metadata.action)
|
|
101
|
+
: "Contract execution"
|
|
100
102
|
: ""}
|
|
101
103
|
</div>
|
|
102
104
|
|
|
@@ -113,6 +115,10 @@ export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({
|
|
|
113
115
|
<img src={tournament?.imageUrl} alt={tournament?.name || "Tournament"} className="h-5 w-5" />
|
|
114
116
|
<div>{tournament?.name || "Tournament"}</div>
|
|
115
117
|
</div>
|
|
118
|
+
) : order.type === "custom" && order.metadata.action === DEPOSIT_HYPE_ACTION ? (
|
|
119
|
+
<div className="flex items-center gap-2">
|
|
120
|
+
<div>{formatTokenAmount(BigInt(order.payload.amount), dstToken.decimals)} HYPE</div>
|
|
121
|
+
</div>
|
|
116
122
|
) : null}
|
|
117
123
|
|
|
118
124
|
<div className="text-as-primary/50 flex items-center gap-2">
|
|
@@ -3,13 +3,20 @@ import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
|
3
3
|
import { useSearchParams } from "@b3dotfun/sdk/shared/react";
|
|
4
4
|
import { Check, X } from "lucide-react";
|
|
5
5
|
import { memo } from "react";
|
|
6
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
6
7
|
import { Step, StepProgress } from "./StepProgress";
|
|
7
8
|
|
|
8
|
-
export const OrderStatus = memo(function OrderStatus({
|
|
9
|
+
export const OrderStatus = memo(function OrderStatus({
|
|
10
|
+
order,
|
|
11
|
+
selectedCryptoPaymentMethod,
|
|
12
|
+
}: {
|
|
13
|
+
order: components["schemas"]["Order"];
|
|
14
|
+
selectedCryptoPaymentMethod?: CryptoPaymentMethodType;
|
|
15
|
+
}) {
|
|
9
16
|
const isComplete = order.status === "executed";
|
|
10
17
|
const { text, status: displayStatus, description } = getStatusDisplay(order);
|
|
11
18
|
const searchParams = useSearchParams();
|
|
12
|
-
const cryptoPaymentMethod = searchParams.get("cryptoPaymentMethod");
|
|
19
|
+
const cryptoPaymentMethod = selectedCryptoPaymentMethod || searchParams.get("cryptoPaymentMethod");
|
|
13
20
|
|
|
14
21
|
console.log("OrderStatus", displayStatus);
|
|
15
22
|
console.log("OrderStatus", order);
|
|
@@ -5,11 +5,11 @@ import { useEffect, useRef } from "react";
|
|
|
5
5
|
import { NumericFormat } from "react-number-format";
|
|
6
6
|
|
|
7
7
|
import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspend";
|
|
8
|
+
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
8
9
|
import { Button } from "@b3dotfun/sdk/global-account/react";
|
|
9
10
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
10
11
|
import { TokenSelector } from "@reservoir0x/relay-kit-ui";
|
|
11
12
|
import { ChainTokenIcon } from "./ChainTokenIcon";
|
|
12
|
-
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
13
13
|
|
|
14
14
|
export function OrderTokenAmount({
|
|
15
15
|
disabled,
|
|
@@ -140,7 +140,7 @@ export function OrderTokenAmount({
|
|
|
140
140
|
variant="outline"
|
|
141
141
|
role="combobox"
|
|
142
142
|
className={cn(
|
|
143
|
-
"bg-b3-react-background border-as-stroke flex h-auto w-fit shrink-0 items-center justify-center gap-2 rounded-xl border-2 px-2 py-1 pr-2 text-center",
|
|
143
|
+
"token-selector-button bg-b3-react-background border-as-stroke flex h-auto w-fit shrink-0 items-center justify-center gap-2 rounded-xl border-2 px-2 py-1 pr-2 text-center",
|
|
144
144
|
tokenSelectClassName,
|
|
145
145
|
)}
|
|
146
146
|
>
|
|
@@ -22,6 +22,7 @@ export function PanelOnramp({
|
|
|
22
22
|
onDestinationTokenChange,
|
|
23
23
|
onDestinationChainChange,
|
|
24
24
|
fiatPaymentMethodIndex,
|
|
25
|
+
recipientSelectionPanelIndex,
|
|
25
26
|
}: {
|
|
26
27
|
srcAmountOnRamp: string;
|
|
27
28
|
setSrcAmountOnRamp: (amount: string) => void;
|
|
@@ -34,6 +35,7 @@ export function PanelOnramp({
|
|
|
34
35
|
onDestinationTokenChange?: (token: components["schemas"]["Token"]) => void;
|
|
35
36
|
onDestinationChainChange?: (chainId: number) => void;
|
|
36
37
|
fiatPaymentMethodIndex: number;
|
|
38
|
+
recipientSelectionPanelIndex: number;
|
|
37
39
|
}) {
|
|
38
40
|
// Get geo-based onramp options to access fee information
|
|
39
41
|
const { stripeWeb2Support } = useGeoOnrampOptions(srcAmountOnRamp);
|
|
@@ -199,7 +201,7 @@ export function PanelOnramp({
|
|
|
199
201
|
{_recipientAddress ? (
|
|
200
202
|
<button
|
|
201
203
|
className="text-as-tertiarry flex h-7 items-center gap-1 text-sm transition-colors hover:text-blue-700"
|
|
202
|
-
onClick={() => setActivePanel(
|
|
204
|
+
onClick={() => setActivePanel(recipientSelectionPanelIndex)} // Recipient selection panel
|
|
203
205
|
>
|
|
204
206
|
<span className="text-sm">
|
|
205
207
|
{recipientName ? formatUsername(recipientName) : formatAddress(_recipientAddress)}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Input,
|
|
1
|
+
import { Input, useProfile, useTokenData } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { formatUsername } from "@b3dotfun/sdk/shared/utils";
|
|
3
3
|
import { shortenAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
|
|
4
4
|
import { formatDisplayNumber } from "@b3dotfun/sdk/shared/utils/number";
|
|
5
5
|
import { ChevronRight } from "lucide-react";
|
|
6
6
|
import { motion } from "motion/react";
|
|
7
7
|
import { useEffect, useRef } from "react";
|
|
8
|
+
import { useAccount } from "wagmi";
|
|
8
9
|
import { components } from "../../../types/api";
|
|
9
10
|
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
10
11
|
import { FiatPaymentMethod } from "./FiatPaymentMethod";
|
|
@@ -45,8 +46,9 @@ export function PaySection({
|
|
|
45
46
|
onSelectFiatPaymentMethod,
|
|
46
47
|
anyspendQuote,
|
|
47
48
|
}: PaySectionProps) {
|
|
48
|
-
const { address:
|
|
49
|
-
const
|
|
49
|
+
const { address: connectedAddress, isConnected } = useAccount();
|
|
50
|
+
const { data: profileData } = useProfile({ address: connectedAddress });
|
|
51
|
+
const connectedName = profileData?.displayName;
|
|
50
52
|
const { data: srcTokenMetadata } = useTokenData(selectedSrcToken?.chainId, selectedSrcToken?.address);
|
|
51
53
|
|
|
52
54
|
// Add ref to track if we've applied metadata
|
|
@@ -82,18 +84,18 @@ export function PaySection({
|
|
|
82
84
|
initial={{ opacity: 0, y: 20, filter: "blur(10px)" }}
|
|
83
85
|
animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
|
|
84
86
|
transition={{ duration: 0.3, delay: 0, ease: "easeInOut" }}
|
|
85
|
-
className="bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6"
|
|
87
|
+
className="pay-section bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6"
|
|
86
88
|
>
|
|
87
89
|
<div className="flex items-center justify-between">
|
|
88
90
|
<div className="text-as-primary/50 flex h-7 items-center text-sm">Pay</div>
|
|
89
91
|
{paymentType === "crypto" ? (
|
|
90
92
|
<button
|
|
91
|
-
className="text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors"
|
|
93
|
+
className="text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none"
|
|
92
94
|
onClick={onSelectCryptoPaymentMethod}
|
|
93
95
|
>
|
|
94
96
|
{selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (
|
|
95
97
|
<>
|
|
96
|
-
{
|
|
98
|
+
{isConnected ? (
|
|
97
99
|
<div className="flex items-center gap-1">
|
|
98
100
|
{connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress || "")}
|
|
99
101
|
</div>
|
|
@@ -151,7 +153,7 @@ export function PaySection({
|
|
|
151
153
|
{paymentType === "crypto" ? (
|
|
152
154
|
<>
|
|
153
155
|
<OrderTokenAmount
|
|
154
|
-
address={
|
|
156
|
+
address={connectedAddress}
|
|
155
157
|
context="from"
|
|
156
158
|
inputValue={srcAmount}
|
|
157
159
|
onChangeInput={value => {
|
|
@@ -172,7 +174,7 @@ export function PaySection({
|
|
|
172
174
|
</div>
|
|
173
175
|
<TokenBalance
|
|
174
176
|
token={selectedSrcToken}
|
|
175
|
-
walletAddress={
|
|
177
|
+
walletAddress={connectedAddress}
|
|
176
178
|
onChangeInput={value => {
|
|
177
179
|
setIsSrcInputDirty(true);
|
|
178
180
|
setSrcAmount(value);
|