mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-19 02:14:35 +08:00
fix(web): remove undefined setHyperliquidWalletAddr call in ExchangeConfigModal (#525)
This commit is contained in:
@@ -660,8 +660,10 @@ export function AITradersPage({ onTraderSelect }: AITradersPageProps) {
|
||||
</div>
|
||||
|
||||
{/* 信号源配置警告 */}
|
||||
{traders && traders.some(t => (t.use_coin_pool || t.use_oi_top)) &&
|
||||
(!userSignalSource.coinPoolUrl && !userSignalSource.oiTopUrl) && (
|
||||
{traders &&
|
||||
traders.some((t) => t.use_coin_pool || t.use_oi_top) &&
|
||||
!userSignalSource.coinPoolUrl &&
|
||||
!userSignalSource.oiTopUrl && (
|
||||
<div
|
||||
className="rounded-lg px-4 py-3 flex items-start gap-3 animate-slide-in"
|
||||
style={{
|
||||
@@ -1576,22 +1578,23 @@ function ExchangeConfigModal({
|
||||
onClose: () => void
|
||||
language: Language
|
||||
}) {
|
||||
const [selectedExchangeId, setSelectedExchangeId] = useState(editingExchangeId || '');
|
||||
const [apiKey, setApiKey] = useState('');
|
||||
const [secretKey, setSecretKey] = useState('');
|
||||
const [passphrase, setPassphrase] = useState('');
|
||||
const [testnet, setTestnet] = useState(false);
|
||||
const [showGuide, setShowGuide] = useState(false);
|
||||
const [selectedExchangeId, setSelectedExchangeId] = useState(
|
||||
editingExchangeId || ''
|
||||
)
|
||||
const [apiKey, setApiKey] = useState('')
|
||||
const [secretKey, setSecretKey] = useState('')
|
||||
const [passphrase, setPassphrase] = useState('')
|
||||
const [testnet, setTestnet] = useState(false)
|
||||
const [showGuide, setShowGuide] = useState(false)
|
||||
const [serverIP, setServerIP] = useState<{
|
||||
public_ip: string;
|
||||
message: string;
|
||||
} | null>(null);
|
||||
const [loadingIP, setLoadingIP] = useState(false);
|
||||
const [copiedIP, setCopiedIP] = useState(false);
|
||||
public_ip: string
|
||||
message: string
|
||||
} | null>(null)
|
||||
const [loadingIP, setLoadingIP] = useState(false)
|
||||
const [copiedIP, setCopiedIP] = useState(false)
|
||||
|
||||
// 币安配置指南展开状态
|
||||
const [showBinanceGuide, setShowBinanceGuide] = useState(false);
|
||||
|
||||
const [showBinanceGuide, setShowBinanceGuide] = useState(false)
|
||||
|
||||
// Aster 特定字段
|
||||
const [asterUser, setAsterUser] = useState('')
|
||||
@@ -1611,9 +1614,6 @@ function ExchangeConfigModal({
|
||||
setPassphrase('') // Don't load existing passphrase for security
|
||||
setTestnet(selectedExchange.testnet || false)
|
||||
|
||||
// Hyperliquid 字段
|
||||
setHyperliquidWalletAddr(selectedExchange.hyperliquidWalletAddr || '')
|
||||
|
||||
// Aster 字段
|
||||
setAsterUser(selectedExchange.asterUser || '')
|
||||
setAsterSigner(selectedExchange.asterSigner || '')
|
||||
@@ -1624,26 +1624,27 @@ function ExchangeConfigModal({
|
||||
// 加载服务器IP(当选择binance时)
|
||||
useEffect(() => {
|
||||
if (selectedExchangeId === 'binance' && !serverIP) {
|
||||
setLoadingIP(true);
|
||||
api.getServerIP()
|
||||
.then(data => {
|
||||
setServerIP(data);
|
||||
setLoadingIP(true)
|
||||
api
|
||||
.getServerIP()
|
||||
.then((data) => {
|
||||
setServerIP(data)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Failed to load server IP:', err);
|
||||
.catch((err) => {
|
||||
console.error('Failed to load server IP:', err)
|
||||
})
|
||||
.finally(() => {
|
||||
setLoadingIP(false);
|
||||
});
|
||||
setLoadingIP(false)
|
||||
})
|
||||
}
|
||||
}, [selectedExchangeId]);
|
||||
}, [selectedExchangeId])
|
||||
|
||||
const handleCopyIP = (ip: string) => {
|
||||
navigator.clipboard.writeText(ip).then(() => {
|
||||
setCopiedIP(true);
|
||||
setTimeout(() => setCopiedIP(false), 2000);
|
||||
});
|
||||
};
|
||||
setCopiedIP(true)
|
||||
setTimeout(() => setCopiedIP(false), 2000)
|
||||
})
|
||||
}
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
@@ -1789,7 +1790,10 @@ function ExchangeConfigModal({
|
||||
{selectedExchange && (
|
||||
<>
|
||||
{/* Binance 和其他 CEX 交易所的字段 */}
|
||||
{(selectedExchange.id === 'binance' || selectedExchange.type === 'cex') && selectedExchange.id !== 'hyperliquid' && selectedExchange.id !== 'aster' && (
|
||||
{(selectedExchange.id === 'binance' ||
|
||||
selectedExchange.type === 'cex') &&
|
||||
selectedExchange.id !== 'hyperliquid' &&
|
||||
selectedExchange.id !== 'aster' && (
|
||||
<>
|
||||
{/* 币安用户配置提示 (D1 方案) */}
|
||||
{selectedExchange.id === 'binance' && (
|
||||
@@ -1804,7 +1808,10 @@ function ExchangeConfigModal({
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<span style={{ color: '#58a6ff' }}>ℹ️</span>
|
||||
<span className="text-sm font-medium" style={{ color: '#EAECEF' }}>
|
||||
<span
|
||||
className="text-sm font-medium"
|
||||
style={{ color: '#EAECEF' }}
|
||||
>
|
||||
<strong>币安用户必读:</strong>
|
||||
使用「现货与合约交易」API,不要用「统一账户 API」
|
||||
</span>
|
||||
@@ -1821,25 +1828,52 @@ function ExchangeConfigModal({
|
||||
style={{
|
||||
borderTop: '1px solid #2b5278',
|
||||
fontSize: '0.875rem',
|
||||
color: '#c9d1d9'
|
||||
color: '#c9d1d9',
|
||||
}}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<p className="mb-2" style={{ color: '#8b949e' }}>
|
||||
<strong>原因:</strong>统一账户 API 权限结构不同,会导致订单提交失败
|
||||
<strong>原因:</strong>统一账户 API
|
||||
权限结构不同,会导致订单提交失败
|
||||
</p>
|
||||
|
||||
<p className="font-semibold mb-1" style={{ color: '#EAECEF' }}>
|
||||
<p
|
||||
className="font-semibold mb-1"
|
||||
style={{ color: '#EAECEF' }}
|
||||
>
|
||||
正确配置步骤:
|
||||
</p>
|
||||
<ol className="list-decimal list-inside space-y-1 mb-3" style={{ paddingLeft: '0.5rem' }}>
|
||||
<li>登录币安 → 个人中心 → <strong>API 管理</strong></li>
|
||||
<li>创建 API → 选择「<strong>系统生成的 API 密钥</strong>」</li>
|
||||
<li>勾选「<strong>现货与合约交易</strong>」(<span style={{ color: '#f85149' }}>不选统一账户</span>)</li>
|
||||
<li>IP 限制选「<strong>无限制</strong>」或添加服务器 IP</li>
|
||||
<ol
|
||||
className="list-decimal list-inside space-y-1 mb-3"
|
||||
style={{ paddingLeft: '0.5rem' }}
|
||||
>
|
||||
<li>
|
||||
登录币安 → 个人中心 → <strong>API 管理</strong>
|
||||
</li>
|
||||
<li>
|
||||
创建 API → 选择「
|
||||
<strong>系统生成的 API 密钥</strong>」
|
||||
</li>
|
||||
<li>
|
||||
勾选「<strong>现货与合约交易</strong>」(
|
||||
<span style={{ color: '#f85149' }}>
|
||||
不选统一账户
|
||||
</span>
|
||||
)
|
||||
</li>
|
||||
<li>
|
||||
IP 限制选「<strong>无限制</strong>」或添加服务器
|
||||
IP
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<p className="mb-2 p-2 rounded" style={{ background: '#3d2a00', border: '1px solid #9e6a03' }}>
|
||||
<p
|
||||
className="mb-2 p-2 rounded"
|
||||
style={{
|
||||
background: '#3d2a00',
|
||||
border: '1px solid #9e6a03',
|
||||
}}
|
||||
>
|
||||
💡 <strong>多资产模式用户注意:</strong>
|
||||
如果您开启了多资产模式,将强制使用全仓模式。建议关闭多资产模式以支持逐仓交易。
|
||||
</p>
|
||||
@@ -1859,7 +1893,10 @@ function ExchangeConfigModal({
|
||||
)}
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-semibold mb-2" style={{ color: '#EAECEF' }}>
|
||||
<label
|
||||
className="block text-sm font-semibold mb-2"
|
||||
style={{ color: '#EAECEF' }}
|
||||
>
|
||||
{t('apiKey', language)}
|
||||
</label>
|
||||
<input
|
||||
@@ -1868,13 +1905,20 @@ function ExchangeConfigModal({
|
||||
onChange={(e) => setApiKey(e.target.value)}
|
||||
placeholder={t('enterAPIKey', language)}
|
||||
className="w-full px-3 py-2 rounded"
|
||||
style={{ background: '#0B0E11', border: '1px solid #2B3139', color: '#EAECEF' }}
|
||||
style={{
|
||||
background: '#0B0E11',
|
||||
border: '1px solid #2B3139',
|
||||
color: '#EAECEF',
|
||||
}}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-semibold mb-2" style={{ color: '#EAECEF' }}>
|
||||
<label
|
||||
className="block text-sm font-semibold mb-2"
|
||||
style={{ color: '#EAECEF' }}
|
||||
>
|
||||
{t('secretKey', language)}
|
||||
</label>
|
||||
<input
|
||||
@@ -1883,7 +1927,11 @@ function ExchangeConfigModal({
|
||||
onChange={(e) => setSecretKey(e.target.value)}
|
||||
placeholder={t('enterSecretKey', language)}
|
||||
className="w-full px-3 py-2 rounded"
|
||||
style={{ background: '#0B0E11', border: '1px solid #2B3139', color: '#EAECEF' }}
|
||||
style={{
|
||||
background: '#0B0E11',
|
||||
border: '1px solid #2B3139',
|
||||
color: '#EAECEF',
|
||||
}}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
@@ -1936,11 +1984,23 @@ function ExchangeConfigModal({
|
||||
|
||||
{/* Binance 白名单IP提示 */}
|
||||
{selectedExchange.id === 'binance' && (
|
||||
<div className="p-4 rounded" style={{ background: 'rgba(240, 185, 11, 0.1)', border: '1px solid rgba(240, 185, 11, 0.2)' }}>
|
||||
<div className="text-sm font-semibold mb-2" style={{ color: '#F0B90B' }}>
|
||||
<div
|
||||
className="p-4 rounded"
|
||||
style={{
|
||||
background: 'rgba(240, 185, 11, 0.1)',
|
||||
border: '1px solid rgba(240, 185, 11, 0.2)',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="text-sm font-semibold mb-2"
|
||||
style={{ color: '#F0B90B' }}
|
||||
>
|
||||
{t('whitelistIP', language)}
|
||||
</div>
|
||||
<div className="text-xs mb-3" style={{ color: '#848E9C' }}>
|
||||
<div
|
||||
className="text-xs mb-3"
|
||||
style={{ color: '#848E9C' }}
|
||||
>
|
||||
{t('whitelistIPDesc', language)}
|
||||
</div>
|
||||
|
||||
@@ -1949,15 +2009,28 @@ function ExchangeConfigModal({
|
||||
{t('loadingServerIP', language)}
|
||||
</div>
|
||||
) : serverIP && serverIP.public_ip ? (
|
||||
<div className="flex items-center gap-2 p-2 rounded" style={{ background: '#0B0E11' }}>
|
||||
<code className="flex-1 text-sm font-mono" style={{ color: '#F0B90B' }}>{serverIP.public_ip}</code>
|
||||
<div
|
||||
className="flex items-center gap-2 p-2 rounded"
|
||||
style={{ background: '#0B0E11' }}
|
||||
>
|
||||
<code
|
||||
className="flex-1 text-sm font-mono"
|
||||
style={{ color: '#F0B90B' }}
|
||||
>
|
||||
{serverIP.public_ip}
|
||||
</code>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleCopyIP(serverIP.public_ip)}
|
||||
className="px-3 py-1 rounded text-xs font-semibold transition-all hover:scale-105"
|
||||
style={{ background: 'rgba(240, 185, 11, 0.2)', color: '#F0B90B' }}
|
||||
style={{
|
||||
background: 'rgba(240, 185, 11, 0.2)',
|
||||
color: '#F0B90B',
|
||||
}}
|
||||
>
|
||||
{copiedIP ? t('ipCopied', language) : t('copyIP', language)}
|
||||
{copiedIP
|
||||
? t('ipCopied', language)
|
||||
: t('copyIP', language)}
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
Reference in New Issue
Block a user