Новый протокол Solana PDA 1.2

This commit is contained in:
AidarKC
2026-09-26 11:01:14 +03:00
parent 6e5b57fd7c
commit c997057a37
47 changed files with 2392 additions and 4480 deletions
+38 -67
View File
@@ -112,6 +112,7 @@ function renderParsed(parsed) {
renderRows([
{ label: 'PDA адрес', value: parsed.pdaAddress },
{ label: 'Формат', value: `${parsed.formatMajor}.${parsed.formatMinor}` },
{ label: 'Логин', value: parsed.login },
{ label: 'Статус', value: parsed.isServer ? 'server' : 'not server' },
{ label: 'recordNumber', value: String(parsed.recordNumber) },
@@ -126,11 +127,10 @@ function renderParsed(parsed) {
const badgeLine = $('badgeLine');
badgeLine.innerHTML = '';
const badges = [
{ label: 'format=1.2', kind: 'ok' },
{ label: `server=${parsed.isServer ? '1' : '0'}`, kind: parsed.isServer ? 'ok' : 'warn' },
{ label: `trusted=${Number(parsed.trustedCount || 0)}`, kind: Number(parsed.trustedCount || 0) > 0 ? 'ok' : 'warn' },
{ label: `sessions=${Array.isArray(parsed.sessions) ? parsed.sessions.length : 0}`, kind: 'info' },
{ label: `forks=${Array.isArray(parsed.forks) ? parsed.forks.length : 0}`, kind: 'info' },
{ label: `access=${Array.isArray(parsed.accessServers) ? parsed.accessServers.length : 0}`, kind: 'info' },
{ label: `sync=${Array.isArray(parsed.syncServers) ? parsed.syncServers.length : 0}`, kind: 'info' },
];
badges.forEach((item) => {
const badge = document.createElement('span');
@@ -141,84 +141,55 @@ function renderParsed(parsed) {
const blocks = $('blocksList');
blocks.innerHTML = '';
blocks.appendChild(renderBlock('RecoveryKeyBlock', 'block_type=0', [
{ label: 'recoveryKey32', value: base58(parsed.recoveryKey) },
]));
blocks.appendChild(renderBlock('RootKeyBlock', 'block_type=1', [
blocks.appendChild(renderBlock('RootKeyBlock', 'block_type=1, version=0', [
{ label: 'rootKey32', value: base58(parsed.rootKey) },
]));
blocks.appendChild(renderBlock('ClientKeyBlock', 'block_type=2', [
blocks.appendChild(renderBlock('ClientKeyBlock', 'block_type=2, version=0', [
{ label: 'clientKey32', value: base58(parsed.clientKey) },
]));
blocks.appendChild(renderBlock('BlockchainRegistryBlock', 'block_type=3', [
{ label: 'blockchainType', value: String(parsed.blockchain?.blockchainType ?? 0) },
{ label: 'blockchainName', value: parsed.blockchain?.blockchainName || '—' },
{ label: 'blockchainPublicKey32', value: base58(parsed.blockchain?.blockchainPublicKey) },
{ label: 'paidLimitBytes', value: formatBigInt(parsed.blockchain?.paidLimitBytes || 0n) },
{ label: 'usedBytes', value: formatBigInt(parsed.blockchain?.usedBytes || 0n) },
{ label: 'lastBlockNumber', value: String(parsed.blockchain?.lastBlockNumber ?? 0) },
{ label: 'lastBlockHash32', value: hex(parsed.blockchain?.lastBlockHash) },
{ label: 'lastBlockSignature64', value: base58(parsed.blockchain?.lastBlockSignature) },
{ label: 'arweaveTxId', value: parsed.blockchain?.arweaveTxId || '—' },
]));
blocks.appendChild(renderBlock('ServerProfileBlock', 'block_type=30', [
{ label: 'isServer', value: parsed.isServer ? '1' : '0' },
{ label: 'addressFormatType', value: String(parsed.addressFormatType ?? 0) },
{ label: 'addressFormatVersion', value: String(parsed.addressFormatVersion ?? 0) },
{ label: 'serverAddress', value: parsed.serverAddress || '—' },
{ label: 'syncServersCount', value: String(parsed.syncServers?.length || 0) },
{ label: 'syncServers', value: renderArrayLine(parsed.syncServers) },
]));
blocks.appendChild(renderBlock('AccessServersBlock', 'block_type=40', [
{ label: 'accessServersCount', value: String(parsed.accessServers?.length || 0) },
{ label: 'accessServers', value: renderArrayLine(parsed.accessServers) },
]));
blocks.appendChild(renderBlock('SessionsBlock', 'block_type=50', [
{ label: 'sessionsMode', value: String(parsed.sessionsMode ?? 0) },
{ label: 'sessionsCount', value: String(parsed.sessions?.length || 0) },
{ label: 'sessions', value: parsed.sessions?.length ? 'ниже' : '—' },
]));
blocks.appendChild(renderBlock('TrustedStateBlock', 'block_type=70', [
{ label: 'trustedCount', value: String(parsed.trustedCount ?? 0) },
]));
blocks.appendChild(renderSessionList(parsed.sessions));
$('rawJson').textContent = JSON.stringify({
const forkLines = (parsed.forks || []).map((fork, idx) =>
`#${idx}: ${base58(fork.blockchainKey)} · created=${formatTimestamp(fork.createdAtMs)} · limit=${formatBigInt(fork.paidLimitBytes)}`,
);
blocks.appendChild(renderBlock('BlockchainRegistryBlock', 'block_type=3, version=0', [
{ label: 'forkCount', value: String(parsed.forks?.length || 0) },
{ label: 'forks', value: forkLines.length ? forkLines.join('\n') : '—' },
]));
if (parsed.isServer) {
const addressLines = (parsed.serverAddresses || []).map((item) =>
`type=${item.addressFormatType}, v=${item.addressFormatVersion}: ${item.address}`,
);
blocks.appendChild(renderBlock('ServerProfileBlock', 'block_type=30, version=0', [
{ label: 'addressCount', value: String(parsed.serverAddresses?.length || 0) },
{ label: 'address', value: addressLines.length ? addressLines.join('\n') : '—' },
]));
}
if (Array.isArray(parsed.accessServers) && parsed.accessServers.length) {
blocks.appendChild(renderBlock('AccessServersBlock', 'block_type=40, version=0', [
{ label: 'accessServersCount', value: String(parsed.accessServers.length) },
{ label: 'accessServer', value: renderArrayLine(parsed.accessServers) },
]));
}
const raw = {
pdaAddress: parsed.pdaAddress,
format: `${parsed.formatMajor}.${parsed.formatMinor}`,
login: parsed.login,
isServer: parsed.isServer,
recordNumber: parsed.recordNumber,
createdAtMs: parsed.createdAtMs.toString(),
updatedAtMs: parsed.updatedAtMs.toString(),
recordLen: parsed.recordLen,
trustedCount: parsed.trustedCount,
addressFormatType: parsed.addressFormatType,
addressFormatVersion: parsed.addressFormatVersion,
serverAddress: parsed.serverAddress,
syncServers: parsed.syncServers,
accessServers: parsed.accessServers,
sessionsMode: parsed.sessionsMode,
sessions: parsed.sessions.map((s) => ({
sessionType: s.sessionType,
sessionVersion: s.sessionVersion,
sessionName: s.sessionName,
sessionPubKey32: base58(s.sessionPubKey32),
})),
recoveryKey: base58(parsed.recoveryKey),
prevRecordHash: hex(parsed.prevRecordHash),
rootKey: base58(parsed.rootKey),
clientKey: base58(parsed.clientKey),
blockchain: {
blockchainType: parsed.blockchain.blockchainType,
blockchainName: parsed.blockchain.blockchainName,
blockchainPublicKey: base58(parsed.blockchain.blockchainPublicKey),
paidLimitBytes: parsed.blockchain.paidLimitBytes.toString(),
usedBytes: parsed.blockchain.usedBytes.toString(),
lastBlockNumber: parsed.blockchain.lastBlockNumber,
lastBlockHash: hex(parsed.blockchain.lastBlockHash),
lastBlockSignature: base58(parsed.blockchain.lastBlockSignature),
arweaveTxId: parsed.blockchain.arweaveTxId || '',
},
}, null, 2);
serverAddresses: (parsed.serverAddresses || []).map((a) => ({ ...a })),
accessServers: parsed.accessServers || [],
signature: base58(parsed.signature),
};
$('rawJson').textContent = JSON.stringify(raw, null, 2);
}
$('btnLoad').addEventListener('click', async () => {