PHP Graphene Node Client [v5.0.3 - v5.1.0]

in #utopian-io6 years ago (edited)

php-graphene-node-client

It is PHP API client for Steem/GOLOS/VIZ blockchain

Github or packagist with MIT license. Author @t3ran13 and active contributor @semasping

In Release v5.0.3

  • fix critical bug for WS connectors implement WSConnectorAbstract.php

In Release v5.0.4

  • new method isEnough was added to Bandwidth Tool
  • abstract connectors was updated
  • string serializer was improved
  • class OpComment was updated

In Release v5.1.0

  • blockchain API methods are placed in own classes accordinly to blockchain names
  • new HTTP/WS connectors were added for VIZ
  • new api methods were added for VIZ
  • new operations types where added in serializator
  • broadcast was upated for working with VIZ blockchain
  • new broadcast operation "content" was added for VIZ

fix critical bug for WS connectors implement WSConnectorAbstract.php

It was crashed when connestor was not opened and tried to be closed. It is fixed now with additional checking.

new method isEnough was added to Bandwidth Tool

There is easy way to check you Bandwidth before make transaction now:

<?php

use GrapheneNodeClient\Connectors\Http\SteemitHttpConnector;
use GrapheneNodeClient\Commands\CommandQueryData;
use GrapheneNodeClient\Tools\Bandwidth;
use GrapheneNodeClient\Tools\Transaction;


$connector = new SteemitHttpConnector();
/** @var CommandQueryData $tx */
$tx = Transaction::init($connector, 'PT4M');
$tx->setParamByKey(
    '0:operations:0',
    [
        'vote',
        [
            'voter'    => $voter,
            'author'   => $author,
            'permlink' => $permlink,
            'weight'   => $weight
        ]
    ]
);
$command = new BroadcastTransactionSynchronousCommand($connector);
Transaction::sign($chainName, $tx, ['posting' => $publicWif]);


$trxString = mb_strlen(json_encode($tx->getParams()), '8bit');
if (Bandwidth::isEnough($connector, $voter, 'market', $trxString)) {
    $answer = $command->execute(
        $tx
    );
}

abstract connectors was updated

It was updated for json sending to node with JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES flags according to Steem/GOLOS/VIZ blockchains rules.
It is mean that slashes and unicode symbols have not to be unescaped.

string serializer was improved

It can serialize strings with length up to 16kk, it was 16k before.

class OpComment was updated

The parameter $parentPermlink is required now in OpComment class-helper, it is rule for STEEM/GOLOS blockchains.

blockchain API methods are placed in own classes accordinly to blockchain names

It was modified for more convenience, there are own class *Api Methods for each blockchain.

new HTTP/WS connectors were added for VIZ, new api methods were added for VIZ

VIZ is one more graphene blochchain, it is GOLOS fork. More details viz.world or https://t.me/viz_world

It is availible working with VIZ blockchain, methods were added:

  • get_block
  • get_accounts
  • get_account_count
  • get_account_history
  • get_account_votes
  • get_active_votes
  • get_active_witnesses
  • get_block_header
  • get_config
  • get_content
  • get_content_replies
  • get_discussions_by_author_before_date
  • get_discussions_by_blog
  • get_discussions_by_created
  • get_discussions_by_feed
  • get_discussions_by_trending
  • get_dynamic_global_properties
  • get_ops_in_block
  • get_trending_tags
  • get_witnesses_by_vote
  • get_followers
  • broadcast_transaction
  • broadcast_transaction_synchronous

new operations types where added in serializator

New types were added for serializer:

  • TYPE_SET_EXTENSIONS
  • TYPE_SET_BENEFICIARIES
  • TYPE_BENEFICIARY

It gives possibility for adding beneficiaries to posts.

broadcast was upated for working with VIZ blockchain, new broadcast operation "content" was added for VIZ

It is availible next broadcast operations for VIZ blockchain

  • OpVote
  • OpTransfer
  • OpContent(the same to OpComment in GOLOS/STEEM)
$connector = new VizWSConnector();

$answer = OpContent::doSynchronous(
    $connector,
    '5_private_posting_key', //VIZ
    'guest123',
    strtolower(str_replace(' ', '-', Transliterator::encode(mb_strtolower($title2, 'utf-8'), Transliterator::LANG_RU))),
    $title2,
    $body,
    json_encode(['tags' => ['test']], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), //meta
    9000, //$curationPercent only for VIZ
    [], //[['account' => 'php-node-client', 'weight' => 9000]], //$beneficiaries only for VIZ
    '', 
    ''
);

$answer = OpVote::doSynchronous(
    $connector,
    'guest123',//voter
//    '5_private_posting_key', //viz
    'volv',//author
    'tikhaya-okhota-otkrytie-sezona-1539526902',//post
    10000//weght
);

$answer = OpTransfer::doSynchronous(
    $connector,
    '5_active_private_key',
    'guest123',//from
    'php-node-client',//to
    '0.010 SBD',//amount
    'test php transfer'//memo
);

It is better with each commit

Commits were done by me in master branch

  • fix critical bug for WS connectors implement WSConnectorAbstract.php
  • add new method isEnough for Bandwidth (last 14 days)
  • fix abstract connectors (last 14 days)
  • fix string serializer (last 14 days)
  • fix bug in string serializer (last 14 days)
  • fix OpComment (last 14 days)
  • upd each blockchain methods are placed in own class (last 14 days)
  • new HTTP/WS connectors for VIZ (last 14 days)
  • new api methods for VIZ platform (last 14 days)
  • add new operations types (last 14 days)
  • add VIZ blockchain to broadcast (last 14 days)
  • add new operation content for VIZ (last 14 days)
  • upd README.md (last 14 days)

Compare v5.0.1-v5.1.0

Sort:  

Thank you for your contribution. It would be better if you would have described what VIZ platform is. In Tools/ChainOperations/OperationSerializer.php file you are doing a lot of calculations with numbers, it would be better if you could have explained (comment in the code) what exactly those numbers are.


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

thx a lot for feedback) i add some info about VIZ, it is golos fork) https://t.me/viz_world

Thank you for your review, @codingdefined!

So far this week you've reviewed 7 contributions. Keep up the good work!

Hi @t3ran13!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

thank you! good luck with project)

Hey, @t3ran13!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!