From bb46cdc8fa3c48da6bad3cc455f13e90e0cd9d53 Mon Sep 17 00:00:00 2001 From: denis-skripnik Date: Thu, 14 Jan 2021 19:38:30 +0700 Subject: [PATCH] Add steem/explorer --- blockchains/steem/apps/explorer/config.json | 6 ++ blockchains/steem/apps/explorer/content.php | 54 ++++++++++++ .../apps/explorer/get_chain_properties.php | 19 +++++ .../get_dynamic_global_properties.php | 19 +++++ blockchains/steem/apps/explorer/index.php | 28 ++++++ .../apps/explorer/pages/block/config.json | 4 + .../apps/explorer/pages/block/content.php | 85 +++++++++++++++++++ .../explorer/pages/block/get_ops_in_block.php | 23 +++++ .../steem/apps/explorer/pages/tx/config.json | 4 + .../steem/apps/explorer/pages/tx/content.php | 51 +++++++++++ .../explorer/pages/tx/get_transaction.php | 22 +++++ menu.json | 2 +- .../Http/SteemitHttpJsonRpcConnector.php | 4 +- 13 files changed, 319 insertions(+), 2 deletions(-) create mode 100644 blockchains/steem/apps/explorer/config.json create mode 100644 blockchains/steem/apps/explorer/content.php create mode 100644 blockchains/steem/apps/explorer/get_chain_properties.php create mode 100644 blockchains/steem/apps/explorer/get_dynamic_global_properties.php create mode 100644 blockchains/steem/apps/explorer/index.php create mode 100644 blockchains/steem/apps/explorer/pages/block/config.json create mode 100644 blockchains/steem/apps/explorer/pages/block/content.php create mode 100644 blockchains/steem/apps/explorer/pages/block/get_ops_in_block.php create mode 100644 blockchains/steem/apps/explorer/pages/tx/config.json create mode 100644 blockchains/steem/apps/explorer/pages/tx/content.php create mode 100644 blockchains/steem/apps/explorer/pages/tx/get_transaction.php diff --git a/blockchains/steem/apps/explorer/config.json b/blockchains/steem/apps/explorer/config.json new file mode 100644 index 00000000..13044df0 --- /dev/null +++ b/blockchains/steem/apps/explorer/config.json @@ -0,0 +1,6 @@ +{ +"title": "Блок-эксплорер для Steem", +"description": "block explorer (просмотр блоков) в Steem", +"in_menu": "Explorer", +"category": "no_category" +} \ No newline at end of file diff --git a/blockchains/steem/apps/explorer/content.php b/blockchains/steem/apps/explorer/content.php new file mode 100644 index 00000000..519d7f53 --- /dev/null +++ b/blockchains/steem/apps/explorer/content.php @@ -0,0 +1,54 @@ +execute($commandQuery3); +$mass3 = $res3['result']; +$chain_res = $chain_command->execute($chain_commandQuery); +$chain_mass = $chain_res['result']; +$content = '
+ + + + + +
+
+

Оглавление

+ +

Последние блоки с необратимого

+ +

К оглавлению

+

Последние блоки с последнего (обратимого)

+ +

К оглавлению

+

Основные параметры

+ +

К оглавлению

'; +return $content; +?> \ No newline at end of file diff --git a/blockchains/steem/apps/explorer/get_chain_properties.php b/blockchains/steem/apps/explorer/get_chain_properties.php new file mode 100644 index 00000000..018c3759 --- /dev/null +++ b/blockchains/steem/apps/explorer/get_chain_properties.php @@ -0,0 +1,19 @@ +setParams($chain_data); + +$chain_connector = new $chain_connector_class(); + +$chain_command = new GetChainPropertiesCommand($chain_connector); + diff --git a/blockchains/steem/apps/explorer/get_dynamic_global_properties.php b/blockchains/steem/apps/explorer/get_dynamic_global_properties.php new file mode 100644 index 00000000..f420a893 --- /dev/null +++ b/blockchains/steem/apps/explorer/get_dynamic_global_properties.php @@ -0,0 +1,19 @@ +setParams($data3); + +$connector = new $connector_class(); + +$command3 = new GetDynamicGlobalPropertiesCommand($connector); + diff --git a/blockchains/steem/apps/explorer/index.php b/blockchains/steem/apps/explorer/index.php new file mode 100644 index 00000000..ef882313 --- /dev/null +++ b/blockchains/steem/apps/explorer/index.php @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/blockchains/steem/apps/explorer/pages/block/config.json b/blockchains/steem/apps/explorer/pages/block/config.json new file mode 100644 index 00000000..ffaad5b0 --- /dev/null +++ b/blockchains/steem/apps/explorer/pages/block/config.json @@ -0,0 +1,4 @@ +{ +"title": "Блок-эксплорер для Steem | блок ", +"description": "block explorer (просмотр блоков) в Steem - блок " +} \ No newline at end of file diff --git a/blockchains/steem/apps/explorer/pages/block/content.php b/blockchains/steem/apps/explorer/pages/block/content.php new file mode 100644 index 00000000..b8329e8e --- /dev/null +++ b/blockchains/steem/apps/explorer/pages/block/content.php @@ -0,0 +1,85 @@ +execute($commandQuery); +$mass = $res['result']; +$tr_count = count($mass); +function convert_operation_data($arr, $site_url) { + $result = '{
'; + 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.': "'.$value.'",'; + } else if ($key === 'beneficiaries') { +$benif = $key.': ['; + foreach ($value as $benefactor) { + $benif .= '{ +account: "'.$benefactor['account'].', +Weight: '.$benefactor['Weight'].' +},'; +} +$benif = str_replace(array(","), ",
", $benif); +$benif .= '],'; +$result .= $benif; + } else { + if (is_array($value)) { + $value = json_encode($value); + } + $result .= $key.': "'.$value.'",'; + } + } + $result = str_replace(array(","), ",
", $result); +$result = substr($result, 0, -7); + $result .= '
}'; + 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 = '

Блок №'.$datas.' (← предыдущий, → следующий)

+ +
+

Транзакции

+
    '; +$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 .= ''; +} + $content .= '
  1. id: '.$tr['trx_id'].'

    +

    Создана: '.$timestamp.'

    +
    Операции
    +'; +} +$op = $tr['op']; +$op_data = convert_operation_data($op[1], $conf['siteUrl']); + $content .= ' + '; +if (count($mass) === $num+1) { + $content .= '
    НазваниеДанные
    '.$op[0].''.$op_data.'
  2. '; +} +$prev_id = $tr['trx_id']; + } +$content .= '
'; +return $content; +} catch (Exception $e) { + return '

Такого блока нет или ошибка соединения с Нодой.

'; +} +?> \ No newline at end of file diff --git a/blockchains/steem/apps/explorer/pages/block/get_ops_in_block.php b/blockchains/steem/apps/explorer/pages/block/get_ops_in_block.php new file mode 100644 index 00000000..cf40415d --- /dev/null +++ b/blockchains/steem/apps/explorer/pages/block/get_ops_in_block.php @@ -0,0 +1,23 @@ + (int)$datas, //block_num +'1' => false, //block_num +]; + +$commandQuery->setParams($command_data); + +$connector = new $connector_class(); +$command = new GetOpsInBlock($connector); + +?> \ No newline at end of file diff --git a/blockchains/steem/apps/explorer/pages/tx/config.json b/blockchains/steem/apps/explorer/pages/tx/config.json new file mode 100644 index 00000000..642076b8 --- /dev/null +++ b/blockchains/steem/apps/explorer/pages/tx/config.json @@ -0,0 +1,4 @@ +{ +"title": "Блок-эксплорер для Steem | Транзакция ", +"description": "block explorer (просмотр блоков) в Steem - транзакция " +} \ No newline at end of file diff --git a/blockchains/steem/apps/explorer/pages/tx/content.php b/blockchains/steem/apps/explorer/pages/tx/content.php new file mode 100644 index 00000000..7f019d94 --- /dev/null +++ b/blockchains/steem/apps/explorer/pages/tx/content.php @@ -0,0 +1,51 @@ +execute($commandQuery); +$mass = $res['result']; +function convert_operation_data($arr, $site_url) { + $result = '{
'; + 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.': "'.$value.'",'; + } else if ($key === 'beneficiaries') { +$benif = $key.': ['; + foreach ($value as $benefactor) { + $benif .= '{ +account: "'.$benefactor['account'].', +Weight: '.$benefactor['Weight'].' +},'; +} +$benif = str_replace(array(","), ",
", $benif); +$benif .= '],'; +$result .= $benif; + } else { + if (is_array($value)) { + $value = json_encode($value); + } + $result .= $key.': "'.$value.'",'; + } + } + $result = str_replace(array(","), ",
", $result); +$result = substr($result, 0, -7); + $result .= '
}'; + return $result; +} + +$content = '

Транзакция '.$datas.'

+

Блок: '.$mass['block_num'].'

+
+

Операции

+ +'; +foreach ($mass['operations'] as $op) { +$op_data = convert_operation_data($op[1], $conf['siteUrl']); + $content .= ' +'; +} +$content .= '
Тип операцииJSON
'.$op[0].''.$op_data.'
'; +return $content; +} catch (Exception $e) { + return '

Такой транзакции нет или ошибка: '.$e.'.

'; +} +?> \ No newline at end of file diff --git a/blockchains/steem/apps/explorer/pages/tx/get_transaction.php b/blockchains/steem/apps/explorer/pages/tx/get_transaction.php new file mode 100644 index 00000000..ae56ab22 --- /dev/null +++ b/blockchains/steem/apps/explorer/pages/tx/get_transaction.php @@ -0,0 +1,22 @@ + $datas //tx_id +]; + +$commandQuery->setParams($command_data); + +$connector = new $connector_class(); +$command = new GetTransaction($connector); + +?> \ No newline at end of file diff --git a/menu.json b/menu.json index 6071b26f..379c52ff 100644 --- a/menu.json +++ b/menu.json @@ -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"}}}} \ No newline at end of file +{"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"}}}} \ No newline at end of file diff --git a/vendor/t3ran13/php-graphene-node-client/Connectors/Http/SteemitHttpJsonRpcConnector.php b/vendor/t3ran13/php-graphene-node-client/Connectors/Http/SteemitHttpJsonRpcConnector.php index bec1e2b1..82d8b920 100644 --- a/vendor/t3ran13/php-graphene-node-client/Connectors/Http/SteemitHttpJsonRpcConnector.php +++ b/vendor/t3ran13/php-graphene-node-client/Connectors/Http/SteemitHttpJsonRpcConnector.php @@ -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 ];