diff --git a/VERSION.properties b/VERSION.properties index c6a44b3..cf1bc62 100644 --- a/VERSION.properties +++ b/VERSION.properties @@ -1,2 +1,2 @@ -client.version=1.2.18 -server.version=1.2.18 +client.version=1.2.19 +server.version=1.2.19 diff --git a/shine-UI/js/pages/registration-payment-view.js b/shine-UI/js/pages/registration-payment-view.js index d3b5fbb..9544e8c 100644 --- a/shine-UI/js/pages/registration-payment-view.js +++ b/shine-UI/js/pages/registration-payment-view.js @@ -44,9 +44,7 @@ export function render({ navigate }) { walletValue.className = 'input'; walletValue.type = 'text'; walletValue.value = state.registrationPayment.walletAddress || ''; - walletValue.addEventListener('input', () => { - state.registrationPayment.walletAddress = walletValue.value; - }); + walletValue.readOnly = true; const walletRow = document.createElement('div'); walletRow.className = 'inline-input-row'; @@ -83,8 +81,8 @@ export function render({ navigate }) { refreshButton.textContent = '↻'; refreshButton.title = 'Обновить'; - const refreshBalance = async ({ showError = true } = {}) => { - const address = String(walletValue.value || '').trim(); + const refreshBalance = async ({ showError = true, addressOverride = '' } = {}) => { + const address = String(addressOverride || walletValue.value || '').trim(); if (!address) return null; refreshButton.disabled = true; try { @@ -107,6 +105,19 @@ export function render({ navigate }) { } }; + const deriveUserWalletAddress = async () => { + const draftPassword = String(state.registrationDraft.password ?? ''); + if (!draftPassword) { + throw new Error('Не найден пароль регистрации для вычисления wallet.key'); + } + const wallet = await deriveWalletFromPassword(draftPassword); + const address = String(wallet?.address || '').trim(); + if (!address) throw new Error('Не удалось вычислить адрес wallet.key'); + state.registrationPayment.walletAddress = address; + walletValue.value = address; + return address; + }; + refreshButton.addEventListener('click', () => { void refreshBalance(); }); @@ -117,9 +128,15 @@ export function render({ navigate }) { topupButton.className = 'ghost-btn'; topupButton.type = 'button'; topupButton.textContent = 'Пополнить кошелёк'; - topupButton.addEventListener('click', () => { - const walletAddress = String(walletValue.value || '').trim(); - window.open(getTopupSiteUrl(walletAddress), '_blank', 'noopener,noreferrer'); + topupButton.addEventListener('click', async () => { + try { + const walletAddress = await deriveUserWalletAddress(); + window.open(getTopupSiteUrl(walletAddress), '_blank', 'noopener,noreferrer'); + } catch (error) { + status.className = 'status-line is-unavailable'; + status.textContent = `Не удалось подготовить кошелёк: ${error?.message || 'unknown'}`; + status.style.display = ''; + } }); const submitButton = document.createElement('button'); @@ -141,15 +158,8 @@ export function render({ navigate }) { submitButton.disabled = true; submitButton.textContent = 'Регистрация...'; - const walletAddress = String(walletValue.value || '').trim(); - if (!walletAddress) { - status.className = 'status-line is-unavailable'; - status.textContent = 'Кошелёк не подготовлен. Нажмите «Обновить» и попробуйте снова.'; - status.style.display = ''; - return; - } - - const currentBalance = await refreshBalance({ showError: true }); + const walletAddress = await deriveUserWalletAddress(); + const currentBalance = await refreshBalance({ showError: true, addressOverride: walletAddress }); if (currentBalance == null) return; if (currentBalance < MIN_REQUIRED_SOL) { status.className = 'status-line is-unavailable'; @@ -205,11 +215,8 @@ export function render({ navigate }) { (async () => { try { - const draftPassword = String(state.registrationDraft.password ?? ''); - const wallet = await deriveWalletFromPassword(draftPassword); - state.registrationPayment.walletAddress = wallet.address; - walletValue.value = wallet.address; - await refreshBalance(); + const walletAddress = await deriveUserWalletAddress(); + await refreshBalance({ addressOverride: walletAddress }); } catch (error) { status.className = 'status-line is-unavailable'; status.textContent = `Не удалось подготовить wallet.key: ${error?.message || 'unknown'}`;