Checkpoint: v6: 添加 TronLink 钱包检测功能(TRON 标签显示连接按钮/安装引导),确认 BSC/ETH/XIC 合约地址正确,构建并部署到 pre-sale.newassetchain.io
This commit is contained in:
parent
4e5743512c
commit
809b6327b8
|
|
@ -114,6 +114,49 @@ function TRC20Panel({ usdtAmount, lang, connectedAddress, onConnectWallet }: { u
|
|||
const [isAutoConnecting, setIsAutoConnecting] = useState(false);
|
||||
const hasEthereum = typeof window !== "undefined" && !!window.ethereum;
|
||||
|
||||
// TronLink detection state
|
||||
const [tronAddress, setTronAddress] = useState<string | null>(null);
|
||||
const [isTronConnecting, setIsTronConnecting] = useState(false);
|
||||
const hasTronLink = typeof window !== "undefined" && (!!(window as unknown as Record<string, unknown>).tronWeb || !!(window as unknown as Record<string, unknown>).tronLink);
|
||||
|
||||
// Auto-detect TronLink on mount
|
||||
useEffect(() => {
|
||||
const detectTron = async () => {
|
||||
// Wait briefly for TronLink to inject
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
const tronWeb = (window as unknown as Record<string, unknown>).tronWeb as { defaultAddress?: { base58?: string }; ready?: boolean } | undefined;
|
||||
if (tronWeb && tronWeb.ready && tronWeb.defaultAddress?.base58) {
|
||||
setTronAddress(tronWeb.defaultAddress.base58);
|
||||
}
|
||||
};
|
||||
detectTron();
|
||||
}, []);
|
||||
|
||||
// Connect TronLink wallet
|
||||
const handleConnectTronLink = async () => {
|
||||
setIsTronConnecting(true);
|
||||
try {
|
||||
const tronLink = (window as unknown as Record<string, unknown>).tronLink as { request?: (args: { method: string }) => Promise<{ code: number }> } | undefined;
|
||||
const tronWeb = (window as unknown as Record<string, unknown>).tronWeb as { defaultAddress?: { base58?: string }; ready?: boolean } | undefined;
|
||||
if (tronLink?.request) {
|
||||
const result = await tronLink.request({ method: 'tron_requestAccounts' });
|
||||
if (result?.code === 200 && tronWeb?.defaultAddress?.base58) {
|
||||
setTronAddress(tronWeb.defaultAddress.base58);
|
||||
toast.success(lang === "zh" ? "TronLink已连接!" : "TronLink connected!");
|
||||
}
|
||||
} else if (tronWeb?.ready && tronWeb.defaultAddress?.base58) {
|
||||
setTronAddress(tronWeb.defaultAddress.base58);
|
||||
toast.success(lang === "zh" ? "TronLink已检测到!" : "TronLink detected!");
|
||||
} else {
|
||||
toast.error(lang === "zh" ? "请安装TronLink钱包扩展" : "Please install TronLink wallet extension");
|
||||
}
|
||||
} catch {
|
||||
toast.error(lang === "zh" ? "连接TronLink失败" : "Failed to connect TronLink");
|
||||
} finally {
|
||||
setIsTronConnecting(false);
|
||||
}
|
||||
};
|
||||
|
||||
// Auto-fill EVM address whenever wallet connects or address changes (unless user already submitted)
|
||||
useEffect(() => {
|
||||
if (connectedAddress && !submitted) {
|
||||
|
|
@ -240,6 +283,80 @@ function TRC20Panel({ usdtAmount, lang, connectedAddress, onConnectWallet }: { u
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{/* TronLink Wallet Detection */}
|
||||
<div className="rounded-xl p-4 space-y-3" style={{ background: "rgba(255,0,19,0.06)", border: "1px solid rgba(255,0,19,0.25)" }}>
|
||||
<div className="flex items-center gap-2">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none">
|
||||
<circle cx="12" cy="12" r="12" fill="#FF0013"/>
|
||||
<path d="M12 5L19 9.5V14.5L12 19L5 14.5V9.5L12 5Z" fill="white" opacity="0.9"/>
|
||||
<path d="M12 8L16 10.5V13.5L12 16L8 13.5V10.5L12 8Z" fill="#FF0013"/>
|
||||
</svg>
|
||||
<p className="text-sm font-semibold" style={{ color: "#ff6b6b" }}>
|
||||
{lang === "zh" ? "TronLink 钱包(可选)" : "TronLink Wallet (Optional)"}
|
||||
</p>
|
||||
</div>
|
||||
{tronAddress ? (
|
||||
<div className="space-y-2">
|
||||
<p className="text-xs text-white/50">
|
||||
{lang === "zh" ? "已连接 TronLink 地址:" : "Connected TronLink address:"}
|
||||
</p>
|
||||
<div
|
||||
className="p-3 rounded-lg text-xs font-mono break-all"
|
||||
style={{ background: "rgba(0,230,118,0.08)", border: "1px solid rgba(0,230,118,0.3)", color: "#00e676" }}
|
||||
>
|
||||
✓ {tronAddress}
|
||||
</div>
|
||||
<p className="text-xs text-white/40">
|
||||
{lang === "zh"
|
||||
? "您的 TronLink 已连接。请在上方填写 EVM 地址以接收 XIC 代币,然后向下方地址发送 USDT。"
|
||||
: "TronLink connected. Please fill your EVM address above to receive XIC tokens, then send USDT to the address below."}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
<p className="text-xs text-white/50">
|
||||
{lang === "zh"
|
||||
? "如果您使用 TronLink 钱包,可以连接后自动验证您的 TRON 地址。"
|
||||
: "If you use TronLink wallet, connect to auto-verify your TRON address."}
|
||||
</p>
|
||||
{hasTronLink ? (
|
||||
<button
|
||||
onClick={handleConnectTronLink}
|
||||
disabled={isTronConnecting}
|
||||
className="w-full py-2.5 rounded-xl text-sm font-semibold flex items-center justify-center gap-2 transition-all hover:opacity-90"
|
||||
style={{
|
||||
background: "rgba(255,0,19,0.15)",
|
||||
border: "1px solid rgba(255,0,19,0.4)",
|
||||
color: "#ff6b6b",
|
||||
}}
|
||||
>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none">
|
||||
<circle cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="2"/>
|
||||
<path d="M12 6v6l4 2" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/>
|
||||
</svg>
|
||||
{isTronConnecting
|
||||
? (lang === "zh" ? "连接中..." : "Connecting...")
|
||||
: (lang === "zh" ? "连接 TronLink 自动验证" : "Connect TronLink to verify")}
|
||||
</button>
|
||||
) : (
|
||||
<a
|
||||
href="https://www.tronlink.org/"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="w-full py-2.5 rounded-xl text-sm font-semibold flex items-center justify-center gap-2 transition-all hover:opacity-90 block text-center"
|
||||
style={{
|
||||
background: "rgba(255,0,19,0.08)",
|
||||
border: "1px solid rgba(255,0,19,0.25)",
|
||||
color: "rgba(255,107,107,0.7)",
|
||||
}}
|
||||
>
|
||||
{lang === "zh" ? "安装 TronLink 钱包 →" : "Install TronLink Wallet →"}
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="nac-card-blue rounded-xl p-4 space-y-3">
|
||||
<p className="text-sm font-medium text-white/80">{t("trc20_send_to")}</p>
|
||||
<div
|
||||
|
|
|
|||
7
todo.md
7
todo.md
|
|
@ -52,3 +52,10 @@
|
|||
- [x] 将useWallet()提升到Home顶层,通过props传递给NavWalletButton和EVMPurchasePanel
|
||||
- [x] 验证导航栏和购买面板钱包状态同步
|
||||
- [ ] 完整域名浏览器购买测试验证
|
||||
|
||||
## v6 合约地址更新 + TronLink 检测
|
||||
- [x] 更新 BSC 预售合约地址为 0xc65e7a2738ed884db8d26a6eb2fecf7daca2e90c
|
||||
- [x] 更新 ETH 预售合约地址为 0x85AB2F2d9f7ca7ecB272b5E8726c70f3fd45D1E3
|
||||
- [x] 更新 XIC 代币合约地址为 0x59ff34dd59680a7125782b1f6df2a86ed46f5a24
|
||||
- [x] 为 TRON 标签添加 TronLink 钱包检测并自动填充 TRON 接收地址
|
||||
- [x] 构建并部署到备份服务器 pre-sale.newassetchain.io
|
||||
|
|
|
|||
Loading…
Reference in New Issue