Skip to content

Commit

Permalink
Add steem/explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-skripnik committed Jan 14, 2021
1 parent 734b7b3 commit bb46cdc
Show file tree
Hide file tree
Showing 13 changed files with 319 additions and 2 deletions.
6 changes: 6 additions & 0 deletions blockchains/steem/apps/explorer/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"title": "Блок-эксплорер для Steem",
"description": "block explorer (просмотр блоков) в Steem",
"in_menu": "Explorer",
"category": "no_category"
}
54 changes: 54 additions & 0 deletions blockchains/steem/apps/explorer/content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php if (!defined('NOTLOAD')) exit('No direct script access allowed');
require 'get_dynamic_global_properties.php';
require 'get_chain_properties.php';

$res3 = $command3->execute($commandQuery3);
$mass3 = $res3['result'];
$chain_res = $chain_command->execute($chain_commandQuery);
$chain_mass = $chain_res['result'];
$content = '<form class="form" method = "post" action = "">
<input type = "hidden" name = "chain" value = "steem">
<input type = "hidden" name = "service" value = "explorer">
<label for = "data">Номер блока или id транзакции: </label>
<input align="left" type = "text" name = "data" value="">
<input align="left" type = "submit" value = "узнать инфу"/>
</form>
<hr />
<h2><a name="contents">Оглавление</a></h2>
<ul><li><a href="#stable_blocks">Последние блоки с необратимого</a></li>
<li><a href="#head_blocks">Последние блоки с последнего (обратимого)</a></li>
<li><a href="#chain_props">Основные параметры</a></li></ul>
<h2><a name="stable_blocks">Последние блоки с необратимого</a></h2>
<ul>
';
$irreversible_blocks = [$mass3['last_irreversible_block_num'], $mass3['last_irreversible_block_num']-1, $mass3['last_irreversible_block_num']-2, $mass3['last_irreversible_block_num']-3, $mass3['last_irreversible_block_num']-4, $mass3['last_irreversible_block_num']-5, $mass3['last_irreversible_block_num']-6, $mass3['last_irreversible_block_num']-7, $mass3['last_irreversible_block_num']-8, $mass3['last_irreversible_block_num']-9];
foreach ($irreversible_blocks as $irreversible_block) {
$content .= '<li><a href="'.$conf['siteUrl'].'steem/explorer/block/'.$irreversible_block.'" target="_blank">'.$irreversible_block.'</a></li>';
}
$content .= '</ul>
<p align="center"><a href="#contents">К оглавлению</a></p>
<h2><a name="head_blocks">Последние блоки с последнего (обратимого)</a></h2>
<ul>
';
$head_blocks = [$mass3['head_block_number'], $mass3['head_block_number']-1, $mass3['head_block_number']-2, $mass3['head_block_number']-3, $mass3['head_block_number']-4, $mass3['head_block_number']-5, $mass3['head_block_number']-6, $mass3['head_block_number']-7, $mass3['head_block_number']-8, $mass3['head_block_number']-9];
foreach ($head_blocks as $head_block) {
$content .= '<li><a href="'.$conf['siteUrl'].'steem/explorer/block/'.$head_block.'" target="_blank">'.$head_block.'</a></li>';
}
$content .= '</ul>
<p align="center"><a href="#contents">К оглавлению</a></p>
<h2><a name="chain_props">Основные параметры</a></h2>
<ul>';
$chf = [];
$chf['account_creation_fee'] = "Размер комиссии за создание аккаунта без делегирования (STEEM):";
$chf['maximum_block_size'] = 'Максимальный размер блока в сети (в байтах):';
$chf['sbd_interest_rate'] = "% начисляемый на SBD:";
$chf['account_subsidy_budget'] = "Субсидии аккаунта, которые будут добавлены к субсидии аккаунта за блок. Это максимальная ставка, которую можно создать с помощью субсидий:";
$chf['account_subsidy_decay'] = "сокращение субсидий по счету:";

foreach ($chain_mass as $prop => $prop_value) {
$content .= '<li>'.$chf[$prop].': '.$prop_value.'</li>';
}
$content .= '</ul>
<p align="center"><a href="#contents">К оглавлению</a></p>';
return $content;
?>
19 changes: 19 additions & 0 deletions blockchains/steem/apps/explorer/get_chain_properties.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php if (!defined('NOTLOAD')) exit('No direct script access allowed');
require $_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/helpers.php';

use GrapheneNodeClient\Commands\CommandQueryData;
use GrapheneNodeClient\Commands\Single\GetChainPropertiesCommand;

$chain_connector_class = CONNECTORS_MAP['steem'];

$chain_commandQuery = new CommandQueryData();

$chain_data = [];

$chain_commandQuery->setParams($chain_data);

$chain_connector = new $chain_connector_class();

$chain_command = new GetChainPropertiesCommand($chain_connector);

19 changes: 19 additions & 0 deletions blockchains/steem/apps/explorer/get_dynamic_global_properties.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php if (!defined('NOTLOAD')) exit('No direct script access allowed');
require $_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/helpers.php';

use GrapheneNodeClient\Commands\CommandQueryData;
use GrapheneNodeClient\Commands\Single\GetDynamicGlobalPropertiesCommand;

$connector_class = CONNECTORS_MAP['steem'];

$commandQuery3 = new CommandQueryData();

$data3 = [];

$commandQuery3->setParams($data3);

$connector = new $connector_class();

$command3 = new GetDynamicGlobalPropertiesCommand($connector);

28 changes: 28 additions & 0 deletions blockchains/steem/apps/explorer/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php if (!defined('NOTLOAD')) exit('No direct script access allowed');
ob_start();

require_once 'functions.php';
function generateAppPages($blockchain_snippet) {
global $conf;
$page = pageUrl()[2];
$datas = pageUrl()[3];

if (is_dir(__DIR__.'/pages/'.$page) && isset($datas)) {
$page_config = configs(__DIR__.'/pages/'.$page.'/config.json');
$data = [];
$data['title'] = $page_config['title'].$datas;
$data['description'] = $page_config['description'].$datas;
$data['content'] = $blockchain_snippet;
$data['content'] .= require_once(__DIR__.'/pages/'.$page.'/content.php');
} else {
if (is_numeric($page)) {
header( "Refresh: 1; URL=" .$conf['siteUrl'] . 'steem/explorer/block/'.$page);
} else if (strlen($page) === 40 && is_float(HexDec($page))) {
header( "Refresh: 1; URL=".$conf['siteUrl'] . 'steem/explorer/tx/'.$page);
}
}
return $data;
}
$data = generateAppPages($blockchain_snippet);
ob_end_flush();
?>
4 changes: 4 additions & 0 deletions blockchains/steem/apps/explorer/pages/block/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Блок-эксплорер для Steem | блок ",
"description": "block explorer (просмотр блоков) в Steem - блок "
}
85 changes: 85 additions & 0 deletions blockchains/steem/apps/explorer/pages/block/content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php if (!defined('NOTLOAD')) exit('No direct script access allowed');
require 'get_ops_in_block.php';
try {
$res = $command->execute($commandQuery);
$mass = $res['result'];
$tr_count = count($mass);
function convert_operation_data($arr, $site_url) {
$result = '{<br />';
foreach ($arr as $key => $value) {
if ($key === 'from' || $key === 'initiator' || $key === 'receiver' || $key === 'to' || $key === 'account' || $key === 'account_seller' || $key === 'subaccount_seller' || $key === 'seller' || $key === 'benefactor' || $key === 'new_account_name' || $key === 'producer' || $key === 'owner' || $key === 'publisher' || $key === 'author' || $key === 'curator' || $key === 'comment_author' || $key === 'witness' || $key === 'voter') {
$result .= $key.': "<a href="'.$site_url.'steem/profiles/'.$value.'" target="_blank">'.$value.'</a>",';
} else if ($key === 'beneficiaries') {
$benif = $key.': [';
foreach ($value as $benefactor) {
$benif .= '{
account: "<a href="'.$site_url.'steem/profiles/'.$benefactor['account'].'" target="_blank">'.$benefactor['account'].'</a>,
Weight: '.$benefactor['Weight'].'
},';
}
$benif = str_replace(array(","), ",<br />", $benif);
$benif .= '],';
$result .= $benif;
} else {
if (is_array($value)) {
$value = json_encode($value);
}
$result .= $key.': "'.$value.'",';
}
}
$result = str_replace(array(","), ",<br />", $result);
$result = substr($result, 0, -7);
$result .= '<br />}';
return $result;
}
date_default_timezone_set('UTC');
$month = array('01' => 'января', '02' => 'февраля', '03' => 'марта', '04' => 'апреля', '05' => 'мая', '06' => 'июня', '07' => 'июля', '08' => 'августа', '09' => 'сентября', '10' => 'октября', '11' => 'ноября', '12' => 'декабря');
$timestamp1 = $mass[$tr_count-1]['timestamp'];
$timestamp2 = strtotime($timestamp1);
$month1 = date('m', $timestamp2);
$timestamp = date('d', $timestamp2).' '.$month[$month1].' '.date('Y г. H:i:s', $timestamp2);
$prev_block = $datas-1;
$next_block = $datas+1;
$witness = '';
for ($i = 0; $i < count($mass); $i++) {
if (isset($mass[$i]['op'][1]['producer'])) {
$witness = $mass[$i]['op'][1]['producer'];
}
}

$content = '<h2>Блок №'.$datas.' (<a href="'.$conf['siteUrl'].'steem/explorer/block/'.$prev_block.'" target="_blank">← предыдущий</a>, <a href="'.$conf['siteUrl'].'steem/explorer/block/'.$next_block.'" target="_blank">→ следующий</a>)</h2>
<ul><li>Сформирован '.$timestamp.' GMT</li>
<li>Подписал делегат <a href="'.$conf['siteUrl'].'steem/profiles/'.$witness.'/witness" target="_blank">'.$witness.'</a></li></ul>
<hr />
<h3>Транзакции</h3>
<ol>';
$prev_id = '';
foreach ($mass as $num => $tr) {
$timestamp1 = $tr['timestamp'];
$timestamp2 = strtotime($timestamp1);
$month1 = date('m', $timestamp2);
$timestamp = date('d', $timestamp2).' '.$month[$month1].' '.date('Y г. H:i:s', $timestamp2);
if ($tr['trx_id'] !== $prev_id) {
if ($num !== 0) {
$content .= '</table></li>';
}
$content .= '<li><h4>id: <a href="'.$conf['siteUrl'].'steem/explorer/tx/'.$tr['trx_id'].'" target="_blank">'.$tr['trx_id'].'</a></h4>
<p>Создана: '.$timestamp.'</p>
<h5>Операции</h5>
<table><tr><th>Название</th><th>Данные</th></tr>';
}
$op = $tr['op'];
$op_data = convert_operation_data($op[1], $conf['siteUrl']);
$content .= '<tr><td>'.$op[0].'</td>
<td>'.$op_data.'</td></tr>';
if (count($mass) === $num+1) {
$content .= '</table></li>';
}
$prev_id = $tr['trx_id'];
}
$content .= '</ol>';
return $content;
} catch (Exception $e) {
return '<p>Такого блока нет или ошибка соединения с Нодой.</p>';
}
?>
23 changes: 23 additions & 0 deletions blockchains/steem/apps/explorer/pages/block/get_ops_in_block.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php if (!defined('NOTLOAD')) exit('No direct script access allowed');
require $_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/helpers.php';

use GrapheneNodeClient\Commands\Single;
use GrapheneNodeClient\Commands\CommandQueryData;
use GrapheneNodeClient\Commands\Single\GetOpsInBlock;

$connector_class = CONNECTORS_MAP['steem'];

$commandQuery = new CommandQueryData();

$command_data = [
'0' => (int)$datas, //block_num
'1' => false, //block_num
];

$commandQuery->setParams($command_data);

$connector = new $connector_class();
$command = new GetOpsInBlock($connector);

?>
4 changes: 4 additions & 0 deletions blockchains/steem/apps/explorer/pages/tx/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"title": "Блок-эксплорер для Steem | Транзакция ",
"description": "block explorer (просмотр блоков) в Steem - транзакция "
}
51 changes: 51 additions & 0 deletions blockchains/steem/apps/explorer/pages/tx/content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php if (!defined('NOTLOAD')) exit('No direct script access allowed');
require 'get_transaction.php';
try {
$res = $command->execute($commandQuery);
$mass = $res['result'];
function convert_operation_data($arr, $site_url) {
$result = '{<br />';
foreach ($arr as $key => $value) {
if ($key === 'from' || $key === 'initiator' || $key === 'receiver' || $key === 'to' || $key === 'account' || $key === 'account_seller' || $key === 'subaccount_seller' || $key === 'seller' || $key === 'benefactor' || $key === 'new_account_name' || $key === 'producer' || $key === 'owner' || $key === 'publisher' || $key === 'author' || $key === 'curator' || $key === 'comment_author' || $key === 'witness') {
$result .= $key.': "<a href="'.$site_url.'steem/profiles/'.$value.'" target="_blank">'.$value.'</a>",';
} else if ($key === 'beneficiaries') {
$benif = $key.': [';
foreach ($value as $benefactor) {
$benif .= '{
account: "<a href="'.$site_url.'steem/profiles/'.$benefactor['account'].'" target="_blank">'.$benefactor['account'].'</a>,
Weight: '.$benefactor['Weight'].'
},';
}
$benif = str_replace(array(","), ",<br />", $benif);
$benif .= '],';
$result .= $benif;
} else {
if (is_array($value)) {
$value = json_encode($value);
}
$result .= $key.': "'.$value.'",';
}
}
$result = str_replace(array(","), ",<br />", $result);
$result = substr($result, 0, -7);
$result .= '<br />}';
return $result;
}

$content = '<h2>Транзакция '.$datas.'</h2>
<p>Блок: <a href="'.$conf['siteUrl'].'steem/explorer/block/'.$mass['block_num'].'" target="_blank">'.$mass['block_num'].'</a></p>
<hr />
<h3>Операции</h3>
<table><tr><th>Тип операции</th>
<th>JSON</th></tr>';
foreach ($mass['operations'] as $op) {
$op_data = convert_operation_data($op[1], $conf['siteUrl']);
$content .= '<tr><td>'.$op[0].'</td>
<td>'.$op_data.'</td></tr>';
}
$content .= '</table>';
return $content;
} catch (Exception $e) {
return '<p>Такой транзакции нет или ошибка: '.$e.'.</p>';
}
?>
22 changes: 22 additions & 0 deletions blockchains/steem/apps/explorer/pages/tx/get_transaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php if (!defined('NOTLOAD')) exit('No direct script access allowed');
require $_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/helpers.php';

use GrapheneNodeClient\Commands\Single;
use GrapheneNodeClient\Commands\CommandQueryData;
use GrapheneNodeClient\Commands\Single\GetTransaction;

$connector_class = CONNECTORS_MAP['steem'];

$commandQuery = new CommandQueryData();

$command_data = [
'0' => $datas //tx_id
];

$commandQuery->setParams($command_data);

$connector = new $connector_class();
$command = new GetTransaction($connector);

?>
2 changes: 1 addition & 1 deletion menu.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"viz":{"name":"Viz","services":{"no_category":{"name":"","accounts":"Аккаунты","profiles":"Профили","projects":"Проекты","wallet":"Кошелёк"},"tools":{"name":"Инструменты","awards":"Награждение","calc":"Калькулятор","custom-generator":"JSON-генератор","randomblockchain":"ГСЧ","search":"Viz-links","exchange":"Обмен","manage":"Управление","polls":"Опросы"},"reytings":{"name":"Рейтинги","top":"Пользователи","witnesses-rewards":"Делегаты"},"info":{"name":"Информация","explorer":"Explorer","buy":"Купить VIZ","help":"Справка"}}},"golos":{"name":"Golos","services":{"reytings":{"name":"Рейтинги","activities":"Активность","donates":"Донаты","referrers":"Рефереры","top":"Пользователи","witnesses-rewards":"Делегаты"},"tools":{"name":"Инструменты","backup":"Бекап постов","calc":"Калькулятор","polls":"Опросы","randomblockchain":"ГСЧ","swap":"Swap","post":"Редактор","manage":"Управление"},"games":{"name":"Игры","stakebot":"Stake_bot"},"no_category":{"name":"","accounts":"Аккаунты","profiles":"Профили","wallet":"кошелёк","explorer":"Explorer","help":"Справка"}}},"steem":{"name":"Steem","services":{"no_category":{"name":"","accounts":"Аккаунты","wallet":"Кошелёк","profiles":"Профили","post":"Редактор","manage":"Управление"},"tools":{"name":"Инструменты","randomblockchain":"ГСЧ","calc":"Калькулятор","backup":"Бекап постов","swap":"Swap"}}},"hive":{"name":"Hive","services":{"tools":{"name":"Инструменты","calc":"Калькулятор","randomblockchain":"ГСЧ","backup":"Бекап постов"},"no_category":{"name":"","profiles":"Профили","accounts":"Аккаунты","wallet":"Кошелёк","post":"Редактор","manage":"Управление"}}},"minter":{"name":"Minter","services":{"no_category":{"name":"","randomblockchain":"ГСЧ","profiles":"Профили"}}},"cyber":{"name":"Cyber","services":{"no_category":{"name":"","profiles":"Профили","wallet":"Кошелёк","validators":"Валидаторы","explorer":"Explorer","accounts":"Аккаунты"},"tools":{"name":"Инструменты","linker":"Линкер","randomblockchain":"ГСЧ","ipfs":"IPFS"}}}}
{"viz":{"name":"Viz","services":{"no_category":{"name":"","accounts":"Аккаунты","profiles":"Профили","projects":"Проекты","wallet":"Кошелёк"},"tools":{"name":"Инструменты","awards":"Награждение","calc":"Калькулятор","custom-generator":"JSON-генератор","randomblockchain":"ГСЧ","search":"Viz-links","exchange":"Обмен","manage":"Управление","polls":"Опросы"},"reytings":{"name":"Рейтинги","top":"Пользователи","witnesses-rewards":"Делегаты"},"info":{"name":"Информация","explorer":"Explorer","buy":"Купить VIZ","help":"Справка"}}},"golos":{"name":"Golos","services":{"reytings":{"name":"Рейтинги","activities":"Активность","donates":"Донаты","referrers":"Рефереры","top":"Пользователи","witnesses-rewards":"Делегаты"},"tools":{"name":"Инструменты","backup":"Бекап постов","calc":"Калькулятор","polls":"Опросы","randomblockchain":"ГСЧ","swap":"Swap","post":"Редактор","manage":"Управление"},"games":{"name":"Игры","stakebot":"Stake_bot"},"no_category":{"name":"","accounts":"Аккаунты","profiles":"Профили","wallet":"кошелёк","explorer":"Explorer","help":"Справка"}}},"steem":{"name":"Steem","services":{"no_category":{"name":"","accounts":"Аккаунты","wallet":"Кошелёк","profiles":"Профили","post":"Редактор","manage":"Управление","explorer":"Explorer"},"tools":{"name":"Инструменты","randomblockchain":"ГСЧ","calc":"Калькулятор","backup":"Бекап постов","swap":"Swap"}}},"hive":{"name":"Hive","services":{"tools":{"name":"Инструменты","calc":"Калькулятор","randomblockchain":"ГСЧ","backup":"Бекап постов"},"no_category":{"name":"","profiles":"Профили","accounts":"Аккаунты","wallet":"Кошелёк","post":"Редактор","manage":"Управление"}}},"minter":{"name":"Minter","services":{"no_category":{"name":"","randomblockchain":"ГСЧ","profiles":"Профили"}}},"cyber":{"name":"Cyber","services":{"no_category":{"name":"","profiles":"Профили","wallet":"Кошелёк","validators":"Валидаторы","explorer":"Explorer","accounts":"Аккаунты"},"tools":{"name":"Инструменты","linker":"Линкер","randomblockchain":"ГСЧ","ipfs":"IPFS"}}}}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class SteemitHttpJsonRpcConnector extends HttpJsonRpcConnectorAbstract
* @var string
*/
protected static $nodeURL = [
'https://api.steemit.com'
'https://api.steemit.com',
'https://api.justyy.com',
'https://steem.61bts.com'
// 'https://steemd.pevo.science' //too often 503
// 'https://steemd.minnowsupportproject.org' //not full answers, some fields are empty
];
Expand Down

0 comments on commit bb46cdc

Please sign in to comment.