diff --git a/frontend/src/components/DecryptWallet.jsx b/frontend/src/components/DecryptWallet.jsx index a53eec1..a96d9db 100644 --- a/frontend/src/components/DecryptWallet.jsx +++ b/frontend/src/components/DecryptWallet.jsx @@ -1,8 +1,6 @@ import { useState, useRef } from 'react' import CopyButton from './CopyButton' -const API = '' - export default function DecryptWallet() { const [password, setPassword] = useState('') const [wallet, setWallet] = useState(null) @@ -37,13 +35,7 @@ export default function DecryptWallet() { setError(null) setResult(null) try { - const res = await fetch(`${API}/api/hd/decrypt`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ wallet, password }), - }) - if (!res.ok) throw new Error((await res.json()).detail) - setResult(await res.json()) + setResult(await window.electronAPI.hdDecrypt({ wallet, password })) setSeedVisible(false) } catch (e) { setError(e.message) diff --git a/frontend/src/components/HDWallet.jsx b/frontend/src/components/HDWallet.jsx index 1e04a5a..1865959 100644 --- a/frontend/src/components/HDWallet.jsx +++ b/frontend/src/components/HDWallet.jsx @@ -1,8 +1,6 @@ import { useState } from 'react' import CopyButton from './CopyButton' -const API = '' - export default function HDWallet() { const [form, setForm] = useState({ network: 'mainnet', @@ -28,23 +26,15 @@ export default function HDWallet() { setWallet(null) setSeedVisible(false) try { - const res = await fetch(`${API}/api/hd/generate`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - network: form.network, - bip_type: form.bip_type, - mnemonic: form.mnemonic.trim() || null, - passphrase: form.passphrase, - account: parseInt(form.account) || 0, - num_addresses: parseInt(form.num_addresses) || 5, - }), + const data = await window.electronAPI.hdGenerate({ + network: form.network, + bip_type: form.bip_type, + mnemonic: form.mnemonic.trim() || null, + passphrase: form.passphrase, + account: parseInt(form.account) || 0, + num_addresses: parseInt(form.num_addresses) || 5, }) - if (!res.ok) { - const e = await res.json() - throw new Error(e.detail || 'API error') - } - setWallet(await res.json()) + setWallet(data) } catch (e) { setError(e.message) } finally { @@ -59,13 +49,7 @@ export default function HDWallet() { try { let data = wallet if (savePassword.trim()) { - const res = await fetch(`${API}/api/hd/encrypt`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ wallet, password: savePassword }), - }) - if (!res.ok) throw new Error((await res.json()).detail) - data = await res.json() + data = await window.electronAPI.hdEncrypt({ wallet, password: savePassword }) } const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' }) const url = URL.createObjectURL(blob) @@ -89,7 +73,6 @@ export default function HDWallet() {