SHA256
Локализовать интерфейс SHiNE на русский и английский
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { t, th } from '../i18n/index.js';
|
||||
import { getSolanaCluster } from '../services/solana-rpc-gateway.js';
|
||||
import { createTopBar } from '../components/topbar.js';
|
||||
import { createRegistrationStepper } from '../components/registration-stepper.js';
|
||||
@@ -30,7 +31,7 @@ import { defaultServerLogin } from '../deploy-config.js';
|
||||
import { getNamespace, normalizeFullLogin } from '../services/shine-namespace-service.js';
|
||||
import { calculateRegistrationFunding, USER_PDA_SPACE, solFromLamports } from '../services/registration-upgrade-helpers.js';
|
||||
|
||||
export const pageMeta = { id: 'registration-payment-view', title: 'Оплата регистрации', showAppChrome: false };
|
||||
export const pageMeta = { id: 'registration-payment-view', get title() { return t('screens.registration_payment_view.text_001'); }, showAppChrome: false };
|
||||
const TEST_TOPUP_AMOUNT_SOL = 0.032;
|
||||
const DEVNET_ENDPOINT = 'https://api.devnet.solana.com';
|
||||
const TEST_TOPUP_SENDER_PRIVATE_32_BASE58 = '6xqAuKYvA8qrCdAkcw7Y8aMgvBnYk8JLxWLma5BzbAvu';
|
||||
@@ -145,7 +146,7 @@ export async function completeRegistrationLogin({ navigate, keyBundle }) {
|
||||
state.registrationPayment.balanceSOL = '0.0000';
|
||||
|
||||
await refreshSessions();
|
||||
setAuthInfo(`Регистрация завершена. Вы автоматически вошли как ${resumedLogin}.`);
|
||||
setAuthInfo(t('screens.registration_payment_view.text_060', { value1: resumedLogin }));
|
||||
|
||||
const nextHash = String(state.authReturnHash || '').trim();
|
||||
state.authReturnHash = '';
|
||||
@@ -182,30 +183,30 @@ export function render({ navigate }) {
|
||||
const copyButton = document.createElement('button');
|
||||
copyButton.className = 'secondary-btn registration-payment-action registration-payment-copy-btn';
|
||||
copyButton.type = 'button';
|
||||
copyButton.textContent = 'Скопировать адрес';
|
||||
copyButton.textContent = t('screens.registration_payment_view.text_002');
|
||||
copyButton.addEventListener('click', async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(walletValue.value);
|
||||
copyButton.textContent = '✓ Адрес скопирован';
|
||||
copyButton.textContent = t('screens.registration_payment_view.text_003');
|
||||
window.setTimeout(() => {
|
||||
copyButton.textContent = 'Скопировать адрес';
|
||||
copyButton.textContent = t('screens.registration_payment_view.text_004');
|
||||
}, 1500);
|
||||
} catch {
|
||||
status.className = 'status-line is-unavailable';
|
||||
status.textContent = 'Не удалось скопировать адрес кошелька.';
|
||||
status.textContent = t('screens.registration_payment_view.text_005');
|
||||
status.style.display = '';
|
||||
}
|
||||
});
|
||||
|
||||
const walletHeading = document.createElement('h4');
|
||||
walletHeading.className = 'registration-payment-wallet-heading';
|
||||
walletHeading.textContent = 'Ваш Solana-кошелёк в Сиянии';
|
||||
walletHeading.textContent = t('screens.registration_payment_view.text_006');
|
||||
const walletHint = document.createElement('p');
|
||||
walletHint.className = 'meta-muted registration-payment-wallet-hint';
|
||||
walletHint.textContent = 'Для регистрации пополните этот Solana-кошелёк. Он уже создан из ваших ключей SHiNE.';
|
||||
walletHint.textContent = t('screens.registration_payment_view.text_007');
|
||||
const walletLabel = document.createElement('label');
|
||||
walletLabel.className = 'field-label';
|
||||
walletLabel.textContent = 'Адрес кошелька';
|
||||
walletLabel.textContent = t('screens.registration_payment_view.text_008');
|
||||
walletRow.append(walletHeading, walletHint, walletLabel, walletValue, copyButton);
|
||||
|
||||
const balanceRow = document.createElement('div');
|
||||
@@ -219,14 +220,14 @@ export function render({ navigate }) {
|
||||
const refreshButton = document.createElement('button');
|
||||
refreshButton.className = 'secondary-btn registration-payment-action registration-payment-refresh-btn';
|
||||
refreshButton.type = 'button';
|
||||
refreshButton.textContent = '↻ Обновить';
|
||||
refreshButton.title = 'Обновить баланс Solana';
|
||||
refreshButton.textContent = t('screens.registration_payment_view.text_009');
|
||||
refreshButton.title = t('screens.registration_payment_view.text_010');
|
||||
|
||||
// Коротко и по-человечески; технические подробности — во всплывающей подсказке.
|
||||
const showWalletError = (error, fallback) => {
|
||||
status.className = 'status-line is-unavailable';
|
||||
status.textContent = error?.code === 'NO_KEYS'
|
||||
? 'Не хватает данных регистрации. Вернитесь назад и нажмите «Далее».'
|
||||
? t('screens.registration_payment_view.text_049')
|
||||
: fallback;
|
||||
status.title = error?.message || '';
|
||||
status.style.display = '';
|
||||
@@ -236,7 +237,7 @@ export function render({ navigate }) {
|
||||
const address = String(addressOverride || walletValue.value || '').trim();
|
||||
if (!address) return null;
|
||||
refreshButton.disabled = true;
|
||||
refreshButton.textContent = '↻ Обновляем…';
|
||||
refreshButton.textContent = t('screens.registration_payment_view.text_011');
|
||||
try {
|
||||
const balance = await getBalanceSol({
|
||||
endpoint: state.entrySettings.solanaServer,
|
||||
@@ -246,17 +247,17 @@ export function render({ navigate }) {
|
||||
balanceValue.textContent = `${formatSol(balance.sol, 6)} SOL`;
|
||||
return BigInt(balance.lamports);
|
||||
} catch (error) {
|
||||
if (showError) showWalletError(error, 'Не удалось обновить баланс. Проверьте связь и попробуйте ещё раз.');
|
||||
if (showError) showWalletError(error, t('screens.registration_payment_view.text_046'));
|
||||
return null;
|
||||
} finally {
|
||||
refreshButton.disabled = false;
|
||||
refreshButton.textContent = '↻ Обновить';
|
||||
refreshButton.textContent = t('screens.registration_payment_view.text_012');
|
||||
}
|
||||
};
|
||||
|
||||
const deriveUserWalletAddress = async () => {
|
||||
const keyBundle = state.registrationDraft.preGeneratedKeyBundle;
|
||||
if (!keyBundle) throw new Error('Ключи ещё не сгенерированы. Вернитесь на предыдущий шаг.');
|
||||
if (!keyBundle) throw new Error(t('screens.registration_payment_view.text_051'));
|
||||
const { publicKeyB64 } = keyBundle.blockchainPair;
|
||||
const raw = atob(publicKeyB64);
|
||||
const bytes = new Uint8Array(raw.length);
|
||||
@@ -276,7 +277,7 @@ export function render({ navigate }) {
|
||||
balanceInfo.className = 'registration-payment-balance-info';
|
||||
const balanceLabel = document.createElement('span');
|
||||
balanceLabel.className = 'registration-payment-balance-label';
|
||||
balanceLabel.textContent = 'Баланс';
|
||||
balanceLabel.textContent = t('screens.registration_payment_view.text_013');
|
||||
balanceInfo.append(balanceLabel, balanceValue);
|
||||
balanceRow.append(balanceInfo, refreshButton);
|
||||
|
||||
@@ -284,12 +285,12 @@ export function render({ navigate }) {
|
||||
const topupButton = document.createElement('button');
|
||||
topupButton.className = 'secondary-btn registration-payment-action registration-payment-topup-btn';
|
||||
topupButton.type = 'button';
|
||||
topupButton.textContent = `Тестовое пополнение (+${TEST_TOPUP_AMOUNT_SOL} SOL)`;
|
||||
topupButton.textContent = t('screens.registration_payment_view.text_061', { value1: TEST_TOPUP_AMOUNT_SOL });
|
||||
topupButton.addEventListener('click', async () => {
|
||||
status.style.display = 'none';
|
||||
topupButton.disabled = true;
|
||||
const defaultText = `Тестовое пополнение (+${TEST_TOPUP_AMOUNT_SOL} SOL)`;
|
||||
topupButton.textContent = 'Пополняем...';
|
||||
const defaultText = t('screens.registration_payment_view.text_062', { value1: TEST_TOPUP_AMOUNT_SOL });
|
||||
topupButton.textContent = t('screens.registration_payment_view.text_014');
|
||||
try {
|
||||
const address = await deriveUserWalletAddress();
|
||||
const sender = await createSolanaWalletFromPrivateBase58(TEST_TOPUP_SENDER_PRIVATE_32_BASE58);
|
||||
@@ -306,10 +307,10 @@ export function render({ navigate }) {
|
||||
state.registrationPayment.balanceSOL = String(balance.sol);
|
||||
balanceValue.textContent = `${formatSol(balance.sol, 6)} SOL`;
|
||||
status.className = 'status-line is-available';
|
||||
status.textContent = `Тестовое пополнение выполнено: +${TEST_TOPUP_AMOUNT_SOL} SOL. Баланс: ${formatSol(balance.sol, 6)} SOL.`;
|
||||
status.textContent = t('screens.registration_payment_view.text_063', { value1: TEST_TOPUP_AMOUNT_SOL, value2: formatSol(balance.sol, 6) });
|
||||
status.style.display = '';
|
||||
} catch (error) {
|
||||
showWalletError(error, 'Не удалось выполнить тестовое пополнение. Попробуйте ещё раз.');
|
||||
showWalletError(error, t('screens.registration_payment_view.text_047'));
|
||||
} finally {
|
||||
topupButton.disabled = false;
|
||||
topupButton.textContent = defaultText;
|
||||
@@ -319,23 +320,23 @@ export function render({ navigate }) {
|
||||
const submitButton = document.createElement('button');
|
||||
submitButton.className = 'primary-btn';
|
||||
submitButton.type = 'button';
|
||||
submitButton.textContent = 'Зарегистрироваться';
|
||||
submitButton.textContent = t('screens.registration_payment_view.text_015');
|
||||
submitButton.addEventListener('click', async () => {
|
||||
status.style.display = 'none';
|
||||
|
||||
const cryptoState = getCryptoRuntimeState();
|
||||
if (!cryptoState.hasCrypto || !cryptoState.hasGetRandomValues || !cryptoState.hasSubtle) {
|
||||
status.className = 'status-line is-unavailable';
|
||||
status.textContent = 'Криптография браузера недоступна. Откройте приложение через HTTPS tunnel или localhost и повторите регистрацию.';
|
||||
status.textContent = t('screens.registration_payment_view.text_016');
|
||||
status.style.display = '';
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
submitButton.disabled = true;
|
||||
submitButton.textContent = 'Регистрация...';
|
||||
submitButton.textContent = t('screens.registration_payment_view.text_017');
|
||||
|
||||
if (!pricingValid) throw new Error('Актуальная стоимость ещё не загружена. Проверьте соединение с Solana.');
|
||||
if (!pricingValid) throw new Error(t('screens.registration_payment_view.text_052'));
|
||||
const walletAddress = await deriveUserWalletAddress();
|
||||
const currentBalance = await refreshBalance({ showError: true, addressOverride: walletAddress });
|
||||
if (currentBalance == null) return;
|
||||
@@ -344,14 +345,14 @@ export function render({ navigate }) {
|
||||
if (currentBalance < funding.requiredLamports) {
|
||||
const shortage = funding.requiredLamports - currentBalance;
|
||||
status.className = 'status-line is-unavailable';
|
||||
status.textContent = `Для регистрации пополните кошелёк минимум на ${solFromLamports(shortage)} SOL. Цена namespace ${solFromLamports(funding.namespaceFee)} SOL уже включает депозит PDA; фактическая комиссия сети оплачивается отдельно.`;
|
||||
if (isTestContour) status.textContent += ` В devnet можно использовать «Тестовое пополнение».`;
|
||||
status.textContent = t('screens.registration_payment_view.text_064', { value1: solFromLamports(shortage), value2: solFromLamports(funding.namespaceFee) });
|
||||
if (isTestContour) status.textContent += t('screens.registration_payment_view.text_065');
|
||||
status.style.display = '';
|
||||
return;
|
||||
}
|
||||
|
||||
const keyBundle = state.registrationDraft.preGeneratedKeyBundle;
|
||||
if (!keyBundle) throw new Error('Ключи не найдены. Вернитесь на предыдущий шаг.');
|
||||
if (!keyBundle) throw new Error(t('screens.registration_payment_view.text_053'));
|
||||
|
||||
// Перед on-chain регистрацией перепроверяем логин ещё раз:
|
||||
// между экраном выбора логина и оплатой его мог занять кто-то другой.
|
||||
@@ -360,11 +361,11 @@ export function render({ navigate }) {
|
||||
solanaEndpoint: state.entrySettings.solanaServer,
|
||||
});
|
||||
if (loginStateBeforeRegister?.exists) {
|
||||
throw new Error('Этот логин уже зарегистрирован. Войдите в существующий аккаунт или выберите другой логин.');
|
||||
throw new Error(t('screens.registration_payment_view.text_054'));
|
||||
}
|
||||
|
||||
// Регистрация на Solana (смарт контракт)
|
||||
submitButton.textContent = 'Регистрация в Solana...';
|
||||
submitButton.textContent = t('screens.registration_payment_view.text_018');
|
||||
let registrationTxId = '';
|
||||
try {
|
||||
const registrationResult = await registerUserOnSolana({
|
||||
@@ -377,42 +378,42 @@ export function render({ navigate }) {
|
||||
} catch (solanaError) {
|
||||
const solanaMsg = formatSolanaErrorDetails(solanaError);
|
||||
if (solanaMsg.includes('already') || isUserAlreadyExistsSolanaError(solanaError)) {
|
||||
throw new Error('Этот логин уже зарегистрирован. Войдите в существующий аккаунт или выберите другой логин.');
|
||||
throw new Error(t('screens.registration_payment_view.text_055'));
|
||||
}
|
||||
if (isSolanaRpcUnavailableError(solanaError)) {
|
||||
throw new Error('Нет связи с сервером Solana. Попробуйте ещё раз позже.');
|
||||
throw new Error(t('screens.registration_payment_view.text_056'));
|
||||
}
|
||||
throw new Error(`Ошибка регистрации в Solana: ${solanaMsg}`);
|
||||
throw new Error(t('screens.registration_payment_view.text_066', { value1: solanaMsg }));
|
||||
}
|
||||
|
||||
renderSolanaRegistrationStage({ navigate, status, keyBundle, registrationTxId });
|
||||
} catch (error) {
|
||||
const message = isSolanaRpcUnavailableError(error)
|
||||
? 'Нет связи с сервером Solana. Попробуйте ещё раз позже.'
|
||||
: toUserMessage(error, 'Не удалось завершить регистрацию.');
|
||||
? t('screens.registration_payment_view.text_050')
|
||||
: toUserMessage(error, t('screens.registration_payment_view.text_048'));
|
||||
setAuthError(message);
|
||||
status.className = 'status-line is-unavailable';
|
||||
status.textContent = message;
|
||||
status.style.display = '';
|
||||
} finally {
|
||||
submitButton.disabled = false;
|
||||
submitButton.textContent = 'Зарегистрироваться';
|
||||
submitButton.textContent = t('screens.registration_payment_view.text_019');
|
||||
}
|
||||
});
|
||||
|
||||
card.innerHTML = `
|
||||
<h1 class="signup-title">Создание аккаунта в Solana</h1>
|
||||
<p class="auth-copy">В Solana будет создана ваша независимая запись (PDA). Депозит PDA включён в стоимость namespace. Сетевая комиссия Solana оплачивается отдельно.</p>
|
||||
<h1 class="signup-title">${th('screens.registration_payment_view.text_069')}</h1>
|
||||
<p class="auth-copy">${th('screens.registration_payment_view.text_070')}</p>
|
||||
`;
|
||||
const priceLine = document.createElement('p');
|
||||
priceLine.className = 'registration-payment-fees';
|
||||
priceLine.textContent = 'Проверяем актуальную стоимость в Solana…';
|
||||
priceLine.textContent = t('screens.registration_payment_view.text_020');
|
||||
card.append(priceLine);
|
||||
submitButton.disabled = true;
|
||||
const loadFunding = async () => {
|
||||
const fullLogin = String(state.registrationDraft.login || '').trim();
|
||||
const name = fullLogin.split('@')[1];
|
||||
if (!name) throw new Error('В логине не указан namespace');
|
||||
if (!name) throw new Error(t('screens.registration_payment_view.text_057'));
|
||||
const solanaEndpoint = state.entrySettings.solanaServer;
|
||||
const [namespace, solana] = await Promise.all([
|
||||
getNamespace({ namespace: name, solanaEndpoint }),
|
||||
@@ -422,7 +423,7 @@ export function render({ navigate }) {
|
||||
const rentLamports = await connection.getMinimumBalanceForRentExemption(USER_PDA_SPACE, 'confirmed');
|
||||
const latestFunding = calculateRegistrationFunding({ namespaceFeeLamports: namespace.registrationFeeLamports, rentLamports });
|
||||
funding = latestFunding;
|
||||
priceLine.textContent = `Регистрация в namespace: ${solFromLamports(funding.namespaceFee)} SOL (депозит PDA включён). Для оплаты на кошельке: не менее ${solFromLamports(funding.requiredLamports)} SOL, включая небольшой запас на комиссию сети. Спишется фактическая комиссия сети, остаток сохранится.`;
|
||||
priceLine.textContent = t('screens.registration_payment_view.text_067', { value1: solFromLamports(funding.namespaceFee), value2: solFromLamports(funding.requiredLamports) });
|
||||
return funding;
|
||||
};
|
||||
card.append(walletRow, balanceRow);
|
||||
@@ -430,7 +431,7 @@ export function render({ navigate }) {
|
||||
card.append(topupButton);
|
||||
const testHint = document.createElement('p');
|
||||
testHint.className = 'meta-muted registration-payment-test-hint';
|
||||
testHint.textContent = 'Только для сети devnet. Тестовые SOL не имеют реальной стоимости.';
|
||||
testHint.textContent = t('screens.registration_payment_view.text_021');
|
||||
card.append(testHint);
|
||||
}
|
||||
card.append(submitButton, status);
|
||||
@@ -438,9 +439,9 @@ export function render({ navigate }) {
|
||||
|
||||
screen.append(
|
||||
createTopBar({
|
||||
title: 'Оплата регистрации',
|
||||
title: t('screens.registration_payment_view.text_022'),
|
||||
back: { label: '←', onClick: () => {
|
||||
if (parseBalanceSol(state.registrationPayment.balanceSOL) > 0 && !window.confirm('Если вы уже пополнили этот кошелёк, не меняйте логин и пароль: это изменит адрес кошелька. Вернуться к паролю?')) return;
|
||||
if (parseBalanceSol(state.registrationPayment.balanceSOL) > 0 && !window.confirm(t('screens.registration_payment_view.text_071'))) return;
|
||||
state.registrationDraft.uiStep = 2; navigate('register-view');
|
||||
} },
|
||||
}),
|
||||
@@ -456,7 +457,7 @@ export function render({ navigate }) {
|
||||
submitButton.disabled = false;
|
||||
} catch (error) {
|
||||
status.className = 'status-line is-unavailable';
|
||||
status.textContent = `Не удалось подготовить регистрацию: ${error?.message || 'unknown'}`;
|
||||
status.textContent = t('screens.registration_payment_view.text_068', { value1: error?.message || 'unknown' });
|
||||
status.style.display = '';
|
||||
}
|
||||
})();
|
||||
@@ -485,17 +486,17 @@ function renderSolanaRegistrationStage({ navigate, status, keyBundle, registrati
|
||||
|
||||
const title = document.createElement('h2');
|
||||
title.className = 'registration-finish-title';
|
||||
title.textContent = 'Идёт регистрация в блокчейне...';
|
||||
title.textContent = t('screens.registration_payment_view.text_023');
|
||||
|
||||
const hint = document.createElement('p');
|
||||
hint.className = 'auth-copy registration-finish-text';
|
||||
hint.textContent = 'Ждём, пока транзакция будет полностью одобрена сетью Solana.';
|
||||
hint.textContent = t('screens.registration_payment_view.text_024');
|
||||
|
||||
const txIdLine = document.createElement('p');
|
||||
txIdLine.className = 'meta-muted registration-finish-tx';
|
||||
if (registrationTxId && txExplorerUrl) {
|
||||
const txLabel = document.createElement('span');
|
||||
txLabel.textContent = 'Tx ID регистрации: ';
|
||||
txLabel.textContent = t('screens.registration_payment_view.text_025');
|
||||
const txLink = document.createElement('a');
|
||||
txLink.className = 'registration-finish-tx-link';
|
||||
txLink.href = txExplorerUrl;
|
||||
@@ -504,7 +505,7 @@ function renderSolanaRegistrationStage({ navigate, status, keyBundle, registrati
|
||||
txLink.textContent = registrationTxId;
|
||||
txIdLine.append(txLabel, txLink);
|
||||
} else {
|
||||
txIdLine.textContent = 'Tx ID регистрации: ожидаем подтверждённую подпись';
|
||||
txIdLine.textContent = t('screens.registration_payment_view.text_026');
|
||||
}
|
||||
|
||||
const progressWrap = document.createElement('div');
|
||||
@@ -516,11 +517,11 @@ function renderSolanaRegistrationStage({ navigate, status, keyBundle, registrati
|
||||
|
||||
const progress = document.createElement('p');
|
||||
progress.className = 'meta-muted registration-finish-progress';
|
||||
progress.textContent = 'Подготавливаем проверку подтверждения...';
|
||||
progress.textContent = t('screens.registration_payment_view.text_027');
|
||||
|
||||
const pollStatus = document.createElement('p');
|
||||
pollStatus.className = 'meta-muted registration-finish-progress';
|
||||
pollStatus.textContent = 'Через несколько секунд начнём проверять подтверждение регистрации.';
|
||||
pollStatus.textContent = t('screens.registration_payment_view.text_028');
|
||||
|
||||
const stopTimers = () => {
|
||||
if (progressTimerId) {
|
||||
@@ -554,22 +555,22 @@ function renderSolanaRegistrationStage({ navigate, status, keyBundle, registrati
|
||||
progressBar.style.width = `${clamp(widthPercent, 0, 98)}%`;
|
||||
|
||||
if (elapsed < REGISTRATION_POLL_START_DELAY_MS) {
|
||||
progress.textContent = 'Отправили регистрацию в сеть. Даём транзакции несколько секунд на обработку.';
|
||||
progress.textContent = t('screens.registration_payment_view.text_029');
|
||||
return;
|
||||
}
|
||||
if (elapsed < REGISTRATION_CONFIRM_TIMEOUT_MS) {
|
||||
progress.textContent = 'Идёт ожидание подтверждения Solana. Индикатор может замедлиться, это нормально.';
|
||||
progress.textContent = t('screens.registration_payment_view.text_030');
|
||||
return;
|
||||
}
|
||||
progress.textContent = 'Подтверждение затянулось. Продолжаем автоматическую проверку.';
|
||||
progress.textContent = t('screens.registration_payment_view.text_031');
|
||||
};
|
||||
|
||||
const finalizeSuccess = () => {
|
||||
if (stageClosed || successPending) return;
|
||||
successPending = true;
|
||||
stopTimers();
|
||||
progress.textContent = 'Подтверждение получено. Завершаем регистрацию...';
|
||||
pollStatus.textContent = 'Запись уже найдена в Solana, готовим финальный экран.';
|
||||
progress.textContent = t('screens.registration_payment_view.text_032');
|
||||
pollStatus.textContent = t('screens.registration_payment_view.text_033');
|
||||
status.style.display = 'none';
|
||||
progressBar.style.transition = `width ${REGISTRATION_SUCCESS_SETTLE_DELAY_MS}ms ease-out`;
|
||||
progressBar.style.width = '100%';
|
||||
@@ -584,15 +585,15 @@ function renderSolanaRegistrationStage({ navigate, status, keyBundle, registrati
|
||||
if (timeoutShown || stageClosed) return;
|
||||
timeoutShown = true;
|
||||
status.className = 'status-line is-unavailable';
|
||||
status.textContent = 'Подтверждение не пришло вовремя. Возможно, регистрация уже прошла, а возможно ещё нет. Проверьте Tx ID ниже: мы продолжим автоматическую проверку.';
|
||||
status.textContent = t('screens.registration_payment_view.text_034');
|
||||
status.style.display = '';
|
||||
pollStatus.textContent = 'Пока подтверждения нет. Подождите ещё немного, мы продолжаем проверять регистрацию.';
|
||||
pollStatus.textContent = t('screens.registration_payment_view.text_035');
|
||||
};
|
||||
|
||||
const tryCheckRegistration = async () => {
|
||||
if (stageClosed || confirmationInFlight) return;
|
||||
confirmationInFlight = true;
|
||||
progress.textContent = 'Проверяем подтверждение регистрации в Solana...';
|
||||
progress.textContent = t('screens.registration_payment_view.text_036');
|
||||
status.style.display = timeoutShown ? '' : 'none';
|
||||
try {
|
||||
const result = await checkLoginExistsOnSolana({
|
||||
@@ -603,13 +604,13 @@ function renderSolanaRegistrationStage({ navigate, status, keyBundle, registrati
|
||||
finalizeSuccess();
|
||||
return;
|
||||
}
|
||||
pollStatus.textContent = 'Пока ещё не прошла, подождите ещё немного...';
|
||||
pollStatus.textContent = t('screens.registration_payment_view.text_037');
|
||||
if ((Date.now() - stageStartedAt) >= REGISTRATION_CONFIRM_TIMEOUT_MS) {
|
||||
showTimeoutState();
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Registration confirmation check failed', toUserMessage(error, 'registration-confirmation'));
|
||||
pollStatus.textContent = 'Проверяем регистрацию повторно...';
|
||||
pollStatus.textContent = t('screens.registration_payment_view.text_038');
|
||||
if ((Date.now() - stageStartedAt) >= REGISTRATION_CONFIRM_TIMEOUT_MS) {
|
||||
showTimeoutState();
|
||||
}
|
||||
@@ -667,17 +668,17 @@ function renderSolanaDoneStage({ navigate, status, keyBundle, registrationTxId =
|
||||
|
||||
const title = document.createElement('h2');
|
||||
title.className = 'registration-finish-title';
|
||||
title.textContent = 'Поздравляем, регистрация завершена';
|
||||
title.textContent = t('screens.registration_payment_view.text_039');
|
||||
|
||||
const hint = document.createElement('p');
|
||||
hint.className = 'auth-copy registration-finish-text';
|
||||
hint.textContent = 'Регистрация подтверждена в блокчейне Solana. Сейчас выполним автоматический вход в аккаунт.';
|
||||
hint.textContent = t('screens.registration_payment_view.text_040');
|
||||
|
||||
const txIdLine = document.createElement('p');
|
||||
txIdLine.className = 'meta-muted registration-finish-tx';
|
||||
if (registrationTxId && txExplorerUrl) {
|
||||
const txLabel = document.createElement('span');
|
||||
txLabel.textContent = 'Tx ID регистрации: ';
|
||||
txLabel.textContent = t('screens.registration_payment_view.text_041');
|
||||
const txLink = document.createElement('a');
|
||||
txLink.className = 'registration-finish-tx-link';
|
||||
txLink.href = txExplorerUrl;
|
||||
@@ -686,12 +687,12 @@ function renderSolanaDoneStage({ navigate, status, keyBundle, registrationTxId =
|
||||
txLink.textContent = registrationTxId;
|
||||
txIdLine.append(txLabel, txLink);
|
||||
} else {
|
||||
txIdLine.textContent = 'Tx ID регистрации: ожидаем подтверждённую подпись';
|
||||
txIdLine.textContent = t('screens.registration_payment_view.text_042');
|
||||
}
|
||||
|
||||
const progress = document.createElement('p');
|
||||
progress.className = 'meta-muted registration-finish-progress';
|
||||
progress.textContent = 'Подготавливаем проверку регистрации...';
|
||||
progress.textContent = t('screens.registration_payment_view.text_043');
|
||||
|
||||
const stopAutoLogin = () => {
|
||||
if (initialDelayId) {
|
||||
@@ -707,7 +708,7 @@ function renderSolanaDoneStage({ navigate, status, keyBundle, registrationTxId =
|
||||
const tryAutoLogin = async () => {
|
||||
if (loginCompleted || loginInFlight) return;
|
||||
loginInFlight = true;
|
||||
progress.textContent = 'Проверяем, прошла ли регистрация...';
|
||||
progress.textContent = t('screens.registration_payment_view.text_044');
|
||||
status.style.display = 'none';
|
||||
try {
|
||||
await completeRegistrationLogin({ navigate, keyBundle });
|
||||
@@ -715,7 +716,7 @@ function renderSolanaDoneStage({ navigate, status, keyBundle, registrationTxId =
|
||||
stopAutoLogin();
|
||||
} catch (error) {
|
||||
if (!loginCompleted) {
|
||||
progress.textContent = 'Пока ещё не прошла, подождите ещё секундочку...';
|
||||
progress.textContent = t('screens.registration_payment_view.text_045');
|
||||
console.warn('Auto login after registration is not ready yet', toUserMessage(error, 'auto-login-wait'));
|
||||
}
|
||||
} finally {
|
||||
@@ -751,9 +752,9 @@ function renderSolanaDoneStage({ navigate, status, keyBundle, registrationTxId =
|
||||
* Никогда не используйте этот встроенный devnet-кошелёк для реальных средств.
|
||||
*/
|
||||
export async function fundDevnetRegistrationWallet(address) {
|
||||
if (!isTestRegistrationContour()) throw new Error('Тестовое пополнение разрешено только в devnet');
|
||||
if (!isTestRegistrationContour()) throw new Error(t('screens.registration_payment_view.text_058'));
|
||||
const cleanAddress = String(address || '').trim();
|
||||
if (!cleanAddress) throw new Error('Не указан адрес пополняемого кошелька');
|
||||
if (!cleanAddress) throw new Error(t('screens.registration_payment_view.text_059'));
|
||||
const sender = await createSolanaWalletFromPrivateBase58(TEST_TOPUP_SENDER_PRIVATE_32_BASE58);
|
||||
await transferSol({
|
||||
endpoint: DEVNET_ENDPOINT,
|
||||
|
||||
Reference in New Issue
Block a user