SHA256
Промежуточный коммит: состояние до нормальной Solana-first регистрации
This commit is contained in:
@@ -7,7 +7,6 @@ import {
|
||||
} from '../state.js';
|
||||
import { toUserMessage } from '../services/ui-error-texts.js';
|
||||
import {
|
||||
deriveWalletFromPassword,
|
||||
formatSol,
|
||||
getBalanceSol,
|
||||
getTopupSiteUrl,
|
||||
@@ -107,10 +106,14 @@ export function render({ navigate }) {
|
||||
};
|
||||
|
||||
const deriveUserWalletAddress = async () => {
|
||||
const draftPassword = String(state.registrationDraft.password ?? '');
|
||||
const wallet = await deriveWalletFromPassword(draftPassword);
|
||||
const address = String(wallet?.address || '').trim();
|
||||
if (!address) throw new Error('Не удалось вычислить адрес wallet.key');
|
||||
const keyBundle = state.registrationDraft.preGeneratedKeyBundle;
|
||||
if (!keyBundle) throw new Error('Ключи ещё не сгенерированы. Вернитесь на предыдущий шаг.');
|
||||
const { publicKeyB64 } = keyBundle.devicePair;
|
||||
const raw = atob(publicKeyB64);
|
||||
const bytes = new Uint8Array(raw.length);
|
||||
for (let i = 0; i < raw.length; i++) bytes[i] = raw.charCodeAt(i);
|
||||
const { PublicKey } = await import('https://esm.sh/@solana/web3.js@1.98.4');
|
||||
const address = new PublicKey(bytes).toBase58();
|
||||
state.registrationPayment.walletAddress = address;
|
||||
walletValue.value = address;
|
||||
return address;
|
||||
@@ -176,14 +179,8 @@ export function render({ navigate }) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Используем предсгенерированный keyBundle или генерируем заново
|
||||
let keyBundle = state.registrationDraft.preGeneratedKeyBundle;
|
||||
if (!keyBundle) {
|
||||
keyBundle = await authService.derivePasswordKeyBundle(
|
||||
state.registrationDraft.login,
|
||||
state.registrationDraft.password,
|
||||
);
|
||||
}
|
||||
const keyBundle = state.registrationDraft.preGeneratedKeyBundle;
|
||||
if (!keyBundle) throw new Error('Ключи не найдены. Вернитесь на предыдущий шаг.');
|
||||
|
||||
// Регистрация на Solana (смарт контракт)
|
||||
submitButton.textContent = 'Регистрация в Solana...';
|
||||
@@ -204,7 +201,7 @@ export function render({ navigate }) {
|
||||
// Регистрация на сервере SHiNE
|
||||
submitButton.textContent = 'Регистрация на сервере...';
|
||||
await authService.reconnect(state.entrySettings.shineServer);
|
||||
const result = await authService.registerUser(state.registrationDraft.login, state.registrationDraft.password);
|
||||
const result = await authService.registerUserWithKeyBundle(state.registrationDraft.login, keyBundle);
|
||||
state.registrationDraft.flowType = 'registration';
|
||||
state.registrationDraft.sessionId = result.sessionId;
|
||||
state.registrationDraft.storagePwd = result.storagePwd;
|
||||
|
||||
Reference in New Issue
Block a user