Skip to content

Commit

Permalink
Update minter/wallet, minter/validators
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-skripnik committed Jan 20, 2021
1 parent 9afa6e9 commit d55cb43
Show file tree
Hide file tree
Showing 7 changed files with 427 additions and 1,001 deletions.
22 changes: 19 additions & 3 deletions blockchains/minter/apps/profiles/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ async function main() {
return datetime_str;
}

function prepareContent(text) {
try {
return text.replace(/[^=][^""][^"=\/](https?:\/\/[^" <>\n]+)/gi, data => {
const link = data.slice(3);
if(/(jpe?g|png|svg|gif)$/.test(link)) return `${data.slice(0,3)} <img src="${link}" alt="" /> `
if(/(vimeo)/.test(link)) return `${data.slice(0,3)} <iframe src="${link}" frameborder="0" allowfullscreen></iframe> `;
if(/(youtu)/.test(link)) return `${data.slice(0,3)} <iframe src="${link.replace(/.*v=(.*)/, 'https://www.youtube.com/embed/$1')}" frameborder="0" allowfullscreen></iframe> `;
return `${data.slice(0,3)} <a href="${link}">${link}</a> `
}).replace(/ (@[^< \.,]+)/gi, user => ` <a href="/minter/profiles/${user.trim().slice(1)}">${user.trim()}</a>`)
} catch(e) {
return text;
}
}

async function getHistory(page) {
try {
let response = await axios.get('https://explorer-api.minter.network/api/v2/addresses/' + address + '/transactions?page=' + page);
Expand Down Expand Up @@ -109,13 +123,15 @@ amount = sum_amount;
amount += coin;
}
let get_time = Date.parse(tr.timestamp);

let memo = decodeURIComponent(escape(window.atob(tr.payload)));
memo = prepareContent(memo);
results += `
<tr><td>${date_str(get_time - timezoneOffset, true, false, true)}</td>
<td><a href="https://explorer.minter.network/blocks/${tr.height}" target="_blank">${tr.height}</a></td>
<td><a href="https://explorer.minter.network/transactions/${tr.hash}" target="_blank">${tr.hash}</a></td>
<td><a href="/minter/explorer/block/${tr.height}" target="_blank">${tr.height}</a></td>
<td><a href="/minter/explorer/tx/${tr.hash}" target="_blank">${tr.hash}</a></td>
<td>${type}</td>
<td>${amount}</td>
<td>${memo}</td>
</tr>`;
}
let next_page = page + 1;
Expand Down
3 changes: 2 additions & 1 deletion blockchains/minter/apps/profiles/page/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<th>Блок</th>
<th>Хеш транзакции</th>
<th>Тип</th>
<th>Сумма</th></tr>
<th>Сумма</th>
<th>Сообщение</th></tr>
</thead>
<tbody id="history_tbody"></tbody></table>
<div id="history_pages"></div>
Expand Down
4 changes: 2 additions & 2 deletions blockchains/minter/apps/validators/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "Валидаторы Cyber",
"description": "Список валидаторов Cyber",
"title": "Валидаторы Minter",
"description": "Список валидаторов Minter",
"in_menu": "Валидаторы",
"category": "no_category"
}
45 changes: 31 additions & 14 deletions blockchains/minter/apps/validators/content.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
<?php if (!defined('NOTLOAD')) exit('No direct script access allowed');
function cmp_function_desc($a, $b){
return ($a['stake'] < $b['stake']);
}

try {
$html = file_get_contents('https://api.cyber.cybernode.ai/validators?page=1&per_page=100');
$validators = json_decode($html, true)['result'];
$list = $validators['validators'];
$content = '<h2>Блок: <a href="'.$conf['siteUrl'].'cyber/explorer/block/'.$validators['block_height'].'" target="_blank">'.$validators['block_height'].'</a></h2>
<table><thead><tr><th>№</th><th>Адрес</th>
$html = file_get_contents('https://explorer-api.minter.network/api/v2/validators');
$validators = json_decode($html, true)['data'];
$list = $validators;
$content = '<table><thead><tr><th>№</th>
<th>Публичный ключ</th>
<th>Сила Голоса</th>
<th>Преоритет претендента</th></tr></thead><tbody>';
foreach ($list as $num => $validator) {
<th>Название</th>
<th>Стек</th>
<th>Комиссия</th>
<th>Описание</th>
<th>сайт</th>
</tr></thead><tbody>';
uasort($list, 'cmp_function_desc');
$num = 0;
foreach ($list as $validator) {
$num++;
$content .= '<tr><td>'.$num.'</td>
<td>'.$validator['address'].'</td>
<td>'.$validator['pub_key']['value'].'</td>
<td>'.$validator['voting_power'].'</td>
<td>'.$validator['proposer_priority'].'</td>
</tr>';
if ($validator['status'] === 2 || $validator['status'] === 1) {
$content .= '<tr><td>'.$num.'</td>
<td><input type="text" readonly id="validator_'.$num.'_key" value="'.$validator['public_key'].'"> (<input type="button" onclick="copyText(`validator_'.$num.'_key`);" value="копировать"></td>
<td>'.$validator['name'].'</td>
<td>'.round($validator['stake'], 3).' BIP</td>
<td>'.$validator['commission'].'%</td>
<td>'.$validator['description'].'</td>';
if (isset($validator['site_url']) && $validator['site_url'] !== '') {
$content .= '<td><a href="'.$validator['site_url'].'" target="_blank">'.$validator['site_url'].'</a></td>';
} else {
$content .= '<td></td>';
}
$content .= '</tr>';
}
}
$content .= '</tbody></table>';
return $content;
Expand Down
Loading

0 comments on commit d55cb43

Please sign in to comment.