├── .gitignore
├── .travis.yml
├── composer.json
├── tests
├── SteemHelperFailureTest.php
├── SteemBlockTest.php
├── SteemBlockFailureTest.php
├── SteemPrivateTest.php
├── SteemWitnessTest.php
├── SteemWitnessFailureTest.php
├── SteemChainFailureTest.php
├── SteemChainTest.php
├── SteemAccountFailureTest.php
├── SteemAccountTest.php
├── SteemMarketFailureTest.php
├── SteemHelperTest.php
├── SteemMarketTest.php
├── SteemArticleTest.php
├── SteemArticleFailureTest.php
└── SteemConfigTest.php
├── LICENSE
├── phpunit.xml
├── README.md
└── src
└── SteemPHP
├── SteemAuth.php
├── SteemPrivate.php
├── SteemAddress.php
├── SteemChain.php
├── SteemWitness.php
├── SteemAccount.php
├── SteemMarket.php
├── SteemBlock.php
├── SteemHelper.php
├── SteemConfig.php
└── SteemArticle.php
/.gitignore:
--------------------------------------------------------------------------------
1 | vendor/
2 | composer.lock
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 | php:
3 | - 5.6
4 | before_script:
5 | - composer self-update
6 | - composer install
7 | - composer require satooshi/php-coveralls:dev-master
8 | script: phpunit
9 | after_script:
10 | - php vendor/bin/coveralls -v
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "davidkevork/steemphp",
3 | "description": "steem php client api",
4 | "homepage": "https://github.com/davidkevork/steemphp",
5 | "license": "MIT",
6 | "authors": [
7 | {
8 | "name": "David Kevork",
9 | "email": "david@davidkevork.me"
10 | }
11 | ],
12 | "require": {
13 | "php": ">=5.6",
14 | "fguillot/json-rpc": "^1.2",
15 | "bitwasp/bitcoin": "0.0.33.x-dev"
16 | },
17 | "require-dev": {
18 | "phpunit/phpunit": "3.7.*"
19 | },
20 | "autoload": {
21 | "psr-4": {
22 | "SteemPHP\\": "src/SteemPHP/"
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/tests/SteemHelperFailureTest.php:
--------------------------------------------------------------------------------
1 | assertEquals(0, SteemHelper::reputation('fail'));
13 | }
14 |
15 | public function testEstimateAccountValue()
16 | {
17 | $this->assertEquals(null, SteemHelper::estimateAccountValue('', '', ''));
18 | }
19 |
20 | public function testHandleError()
21 | {
22 | try {
23 | if ('a' !== 'b') {
24 | throw new Exception('Empty exception for phpunit');
25 | }
26 | } catch (Exception $e) {
27 | $this->assertArrayHasKey('instance', SteemHelper::handleError($e));
28 | }
29 | }
30 |
31 | public function testSlice()
32 | {
33 | $this->assertEquals(['error' => 'Invalid start or length'] ,SteemHelper::slice(['a','b','c','d','e','f','g'], 10, 10));
34 | }
35 |
36 | }
37 |
38 | ?>
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 David Kevork https://davidkevork.github.io/
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 | ./tests/
15 |
16 |
17 |
18 |
19 | ./src/SteemPHP/
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # steemphp
2 |
3 |
4 | [](https://travis-ci.org/davidkevork/steemphp) [](https://coveralls.io/github/davidkevork/steemphp?branch=master)
5 |
6 | ## Introduction
7 |
8 | > This Project is Steem Client Api in PHP based on the official steemit steem.js https://github.com/steemit/steem-js/
9 |
10 | ## Install in your project
11 |
12 | Run the command in your project folder:
13 |
14 | ```
15 | composer require davidkevork/steemphp:dev-master
16 | ```
17 |
18 | Or modify your 'composer.json' to include:
19 |
20 | ```
21 | {
22 | "name": "yourname/projectname",
23 | "require": {
24 | "davidkevork/steemphp": "master"
25 | }
26 | }
27 | ```
28 |
29 | ## Development
30 |
31 | ```
32 | git clone https://github.com/davidkevork/steemphp.git
33 | cd steemphp
34 | composer install
35 | ```
36 |
37 | `phpunit` within the folder should execute all unit tests for this project. If you're on OSX using entr (`brew install entr`), you can run the following command for live testing as you develop:
38 |
39 | ```
40 | find src/ tests/ | entr -c phpunit
41 | ```
42 |
43 | ## License
44 |
45 | This project is licensed under the [MIT license](LICENSE).
--------------------------------------------------------------------------------
/tests/SteemBlockTest.php:
--------------------------------------------------------------------------------
1 | SteemBlock = new \SteemPHP\SteemBlock('https://steemd.steemit.com');
10 | }
11 |
12 | public function testGetApi()
13 | {
14 | $this->assertInternalType('int', $this->SteemBlock->getApi('login_api'));
15 | }
16 |
17 | public function testGetBlock()
18 | {
19 | $this->assertArrayHasKey('witness', $this->SteemBlock->getBlock(1));
20 | }
21 |
22 | public function testGetBlockHeader()
23 | {
24 | $this->assertArrayHasKey('witness', $this->SteemBlock->getBlockHeader(1));
25 | }
26 |
27 | public function testGetOpsInBlock()
28 | {
29 | $this->assertArrayHasKey('trx_id', $this->SteemBlock->getOpsInBlock(15082480)[0]);
30 | }
31 |
32 | public function testGetTransactionHex()
33 | {
34 | $this->assertEquals('00000000000000000000000000', $this->SteemBlock->getTransactionHex('22e7151e8dbf10c8342cf174db4d18788dbede28'));
35 | }
36 |
37 | public function testGetTransaction()
38 | {
39 | $this->assertArrayHasKey('ref_block_num', $this->SteemBlock->getTransaction('22e7151e8dbf10c8342cf174db4d18788dbede28'));
40 | }
41 |
42 | public function testGetKeyReferences()
43 | {
44 | $this->assertArrayHasKey('0', $this->SteemBlock->getKeyReferences('STM8TkTHDY5ayet6JHyktY9ghV8PwiZ8FSgKSGaSM9PHEdtvCdxBK'));
45 | }
46 |
47 | }
48 |
49 | ?>
--------------------------------------------------------------------------------
/tests/SteemBlockFailureTest.php:
--------------------------------------------------------------------------------
1 | SteemBlock = new \SteemPHP\SteemBlock('https://rpc.google.com/');
10 | }
11 |
12 | public function testGetApi()
13 | {
14 | $this->assertArrayHasKey('instance', $this->SteemBlock->getApi('login_api'));
15 | }
16 |
17 | public function testGetBlock()
18 | {
19 | $this->assertArrayHasKey('instance', $this->SteemBlock->getBlock(1));
20 | }
21 |
22 | public function testGetBlockHeader()
23 | {
24 | $this->assertArrayHasKey('instance', $this->SteemBlock->getBlockHeader(1));
25 | }
26 |
27 | public function testGetOpsInBlock()
28 | {
29 | $this->assertArrayHasKey('instance', $this->SteemBlock->getOpsInBlock(15082480));
30 | }
31 |
32 | public function testGetTransactionHex()
33 | {
34 | $this->assertArrayHasKey('instance', $this->SteemBlock->getTransactionHex('22e7151e8dbf10c8342cf174db4d18788dbede28'));
35 | }
36 |
37 | public function testGetTransaction()
38 | {
39 | $this->assertArrayHasKey('instance', $this->SteemBlock->getTransaction('22e7151e8dbf10c8342cf174db4d18788dbede28'));
40 | }
41 |
42 | public function testGetKeyReferences()
43 | {
44 | $this->assertArrayHasKey('instance', $this->SteemBlock->getKeyReferences('STM8TkTHDY5ayet6JHyktY9ghV8PwiZ8FSgKSGaSM9PHEdtvCdxBK'));
45 | }
46 |
47 | }
48 |
49 | ?>
--------------------------------------------------------------------------------
/tests/SteemPrivateTest.php:
--------------------------------------------------------------------------------
1 | SteemPrivate = new \SteemPHP\SteemPrivate;
10 | }
11 |
12 | public function testSetPrefix()
13 | {
14 | $this->SteemPrivate->setPrefix('STX');
15 | $this->assertEquals('STX', $this->SteemPrivate->prefix);
16 | }
17 |
18 | public function testToWif()
19 | {
20 | $this->assertEquals('5JpHaesrxhiaBsqNxWFAWkkykVBPTqs1KdiRLhcBbpLjiVDRypg', $this->SteemPrivate->toWif('guest123', '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg', 'owner'));
21 | }
22 |
23 | public function testFromSeed()
24 | {
25 | $this->assertEquals('5JN8BCwLUw3CddU9tGjyWX7ahV9iye1tfsDzn9Ab5tg6kzd1fZ8', $this->SteemPrivate->fromSeed('guest1235JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLgowner'));
26 | }
27 |
28 | public function testFromBuffer()
29 | {
30 | $this->assertEquals('5JN8BCwLUw3CddU9tGjyWX7ahV9iye1tfsDzn9Ab5tg6kzd1fZ8', $this->SteemPrivate->fromBuffer('484aaef3bc4f8983a6ae44526f39f949b7cdd731db7d6f87a93b1432b3dde468'));
31 | }
32 |
33 | public function testIsWifT()
34 | {
35 | $this->assertTrue($this->SteemPrivate->isWif('5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg'));
36 | }
37 |
38 | public function testIsWifF()
39 | {
40 | $this->assertFalse($this->SteemPrivate->isWif('davidk'));
41 | }
42 |
43 | public function testFromWif()
44 | {
45 | $this->assertEquals('5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg', $this->SteemPrivate->fromWif('5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg'));
46 | }
47 |
48 | }
49 |
50 | ?>
--------------------------------------------------------------------------------
/tests/SteemWitnessTest.php:
--------------------------------------------------------------------------------
1 | SteemWitness = new \SteemPHP\SteemWitness('https://steemd.steemit.com');
10 | }
11 |
12 | public function testGetApi()
13 | {
14 | $this->assertInternalType('int', $this->SteemWitness->getApi('login_api'));
15 | }
16 |
17 | public function testGetWitnessCount()
18 | {
19 | $this->assertInternalType('int', $this->SteemWitness->getWitnessCount());
20 | }
21 |
22 | public function testLookupWitnessAccounts()
23 | {
24 | $this->assertEquals('admin', $this->SteemWitness->lookupWitnessAccounts('admin', 10)[0]);
25 | }
26 |
27 | public function testGetWitnessSchedule()
28 | {
29 | $this->assertArrayHasKey('median_props', $this->SteemWitness->getWitnessSchedule());
30 | }
31 |
32 | public function testGetWitnesses()
33 | {
34 | $this->assertEquals('admin', $this->SteemWitness->getWitnesses('1')[0]['owner']);
35 | }
36 |
37 | public function testGetWitnessByAccount()
38 | {
39 | $this->assertEquals('admin', $this->SteemWitness->getWitnessByAccount('admin')['owner']);
40 | }
41 |
42 | public function testGetWitnessesByVote()
43 | {
44 | $this->assertEquals('good-karma', $this->SteemWitness->getWitnessesByVote('good-karma', 1)[0]['owner']);
45 | }
46 |
47 | public function testGetActiveWitnesses()
48 | {
49 | $this->assertArrayHasKey('0', $this->SteemWitness->getActiveWitnesses());
50 | }
51 |
52 | public function testGetMinerQueue()
53 | {
54 | $this->assertArrayHasKey('0', $this->SteemWitness->getMinerQueue());
55 | }
56 |
57 | }
58 |
59 | ?>
--------------------------------------------------------------------------------
/tests/SteemWitnessFailureTest.php:
--------------------------------------------------------------------------------
1 | SteemWitness = new \SteemPHP\SteemWitness('https://rpc.google.com/');
10 | }
11 |
12 | public function testGetApi()
13 | {
14 | $this->assertArrayHasKey('instance', $this->SteemWitness->getApi('login_api'));
15 | }
16 |
17 | public function testGetWitnessCount()
18 | {
19 | $this->assertArrayHasKey('instance', $this->SteemWitness->getWitnessCount());
20 | }
21 |
22 | public function testLookupWitnessAccounts()
23 | {
24 | $this->assertArrayHasKey('instance', $this->SteemWitness->lookupWitnessAccounts('admin', 10));
25 | }
26 |
27 | public function testGetWitnessSchedule()
28 | {
29 | $this->assertArrayHasKey('instance', $this->SteemWitness->getWitnessSchedule());
30 | }
31 |
32 | public function testGetWitnesses()
33 | {
34 | $this->assertArrayHasKey('instance', $this->SteemWitness->getWitnesses('1'));
35 | }
36 |
37 | public function testGetWitnessByAccount()
38 | {
39 | $this->assertArrayHasKey('instance', $this->SteemWitness->getWitnessByAccount('admin'));
40 | }
41 |
42 | public function testGetWitnessesByVote()
43 | {
44 | $this->assertArrayHasKey('instance', $this->SteemWitness->getWitnessesByVote('good-karma', 1));
45 | }
46 |
47 | public function testGetActiveWitnesses()
48 | {
49 | $this->assertArrayHasKey('instance', $this->SteemWitness->getActiveWitnesses());
50 | }
51 |
52 | public function testGetMinerQueue()
53 | {
54 | $this->assertArrayHasKey('instance', $this->SteemWitness->getMinerQueue());
55 | }
56 |
57 | }
58 |
59 | ?>
--------------------------------------------------------------------------------
/src/SteemPHP/SteemAuth.php:
--------------------------------------------------------------------------------
1 | prefix = trim($prefix);
32 | }
33 |
34 | /**
35 | * Gets the private keys.
36 | *
37 | * @param string $name The name
38 | * @param string $password The password
39 | *
40 | * @return arrray The private keys.
41 | */
42 | public function getPrivateKeys($name, $password)
43 | {
44 | $this->role = ['owner', 'active', 'posting', 'memo'];
45 | $this->key = [];
46 | $SteemPrivate = new SteemPrivate;
47 | $SteemPublic = new SteemPublic;
48 | foreach ($this->role as $value) {
49 | $this->key[$value] = $SteemPrivate->toWif($name, $password, $value);
50 | $this->key[$value.'Pubkey'] = ($this->key[$value]);
51 | }
52 | return $this->key;
53 | }
54 |
55 | /**
56 | * Nomralize the brain key
57 | *
58 | * @param string $brain_key The brain key
59 | *
60 | * @return array|string array on failure|string on success
61 | */
62 | public function normalize($brain_key)
63 | {
64 | if (gettype($brain_key) != "string") {
65 | return ['error' => 'string required for brain_key'];
66 | } else {
67 | return implode(" ", explode("/[\t\n\v\f\r ]+/", trim($brain_key)));
68 | }
69 | }
70 |
71 | }
72 |
73 | ?>
--------------------------------------------------------------------------------
/tests/SteemChainFailureTest.php:
--------------------------------------------------------------------------------
1 | SteemChain = new \SteemPHP\SteemChain('https://rpc.google.com/');
10 | }
11 |
12 | public function testGetApi()
13 | {
14 | $this->assertArrayHasKey('instance', $this->SteemChain->getApi('login_api'));
15 | }
16 |
17 | public function testGetVersion()
18 | {
19 | $this->assertArrayHasKey('instance', $this->SteemChain->getVersion());
20 | }
21 |
22 | public function testGetAccountCount()
23 | {
24 | $this->assertArrayHasKey('instance', $this->SteemChain->getAccountCount());
25 | }
26 |
27 | public function testGetChainProperties()
28 | {
29 | $this->assertArrayHasKey('instance', $this->SteemChain->getChainProperties());
30 | }
31 |
32 | public function testGetConfig()
33 | {
34 | $this->assertArrayHasKey('instance', $this->SteemChain->getConfig());
35 | }
36 |
37 | public function testGetDynamicGlobalProperties()
38 | {
39 | $this->assertArrayHasKey('instance', $this->SteemChain->getDynamicGlobalProperties());
40 | }
41 |
42 | public function testGetFeedHistory()
43 | {
44 | $this->assertArrayHasKey('instance', $this->SteemChain->getFeedHistory());
45 | }
46 |
47 | public function testGetCurrentMeidanHistoryPrice()
48 | {
49 | $this->assertArrayHasKey('instance', $this->SteemChain->getCurrentMeidanHistoryPrice());
50 | }
51 |
52 | public function testGetHardforkVersion()
53 | {
54 | $this->assertArrayHasKey('instance', $this->SteemChain->getHardforkVersion());
55 | }
56 |
57 | public function testGetNextScheduledHardfork()
58 | {
59 | $this->assertArrayHasKey('instance', $this->SteemChain->getNextScheduledHardfork());
60 | }
61 | }
62 |
63 | ?>
--------------------------------------------------------------------------------
/tests/SteemChainTest.php:
--------------------------------------------------------------------------------
1 | SteemChain = new \SteemPHP\SteemChain('https://steemd.steemit.com');
10 | }
11 |
12 | public function testGetApi()
13 | {
14 | $this->assertInternalType('int', $this->SteemChain->getApi('login_api'));
15 | }
16 |
17 | public function testGetVersion()
18 | {
19 | $this->assertArrayHasKey('blockchain_version', $this->SteemChain->getVersion());
20 | }
21 |
22 | public function testGetAccountCount()
23 | {
24 | $this->assertInternalType('int', $this->SteemChain->getAccountCount());
25 | }
26 |
27 | public function testGetChainProperties()
28 | {
29 | $this->assertArrayHasKey('account_creation_fee', $this->SteemChain->getChainProperties());
30 | }
31 |
32 | public function testGetConfig()
33 | {
34 | $this->assertArrayHasKey('SBD_SYMBOL', $this->SteemChain->getConfig());
35 | }
36 |
37 | public function testGetDynamicGlobalProperties()
38 | {
39 | $this->assertArrayHasKey('head_block_id', $this->SteemChain->getDynamicGlobalProperties());
40 | }
41 |
42 | public function testGetFeedHistory()
43 | {
44 | $this->assertArrayHasKey('id', $this->SteemChain->getFeedHistory());
45 | }
46 |
47 | public function testGetCurrentMeidanHistoryPrice()
48 | {
49 | $this->assertArrayHasKey('base', $this->SteemChain->getCurrentMeidanHistoryPrice());
50 | }
51 |
52 | public function testGetHardforkVersion()
53 | {
54 | $this->assertInternalType('string', $this->SteemChain->getHardforkVersion());
55 | }
56 |
57 | public function testGetNextScheduledHardfork()
58 | {
59 | $this->assertArrayHasKey('hf_version', $this->SteemChain->getNextScheduledHardfork());
60 | }
61 | }
62 |
63 | ?>
--------------------------------------------------------------------------------
/tests/SteemAccountFailureTest.php:
--------------------------------------------------------------------------------
1 | SteemAccount = new \SteemPHP\SteemAccount('https://rpc.google.com/');
10 | }
11 |
12 | public function testGetApi()
13 | {
14 | $this->assertArrayHasKey('instance', $this->SteemAccount->getApi('login_api'));
15 | }
16 |
17 | public function testGetProps()
18 | {
19 | $this->assertArrayHasKey('instance', $this->SteemAccount->getProps());
20 | }
21 |
22 | public function testGetAccountHistory()
23 | {
24 | $this->assertArrayHasKey('instance', $this->SteemAccount->getAccountHistory('davidk', 2));
25 | }
26 |
27 | public function testGetAccount()
28 | {
29 | $this->assertArrayHasKey('instance', $this->SteemAccount->getAccount('davidk'));
30 | }
31 |
32 | public function testGetReputation()
33 | {
34 | $this->assertArrayHasKey('instance', $this->SteemAccount->getReputation('davidk'));
35 | }
36 |
37 | public function testVestToSteemByAccount()
38 | {
39 | $this->assertArrayHasKey('instance', $this->SteemAccount->vestToSteemByAccount('davidk'));
40 | }
41 |
42 | public function testGetFollowing()
43 | {
44 | $this->assertArrayHasKey('instance', $this->SteemAccount->getFollowing('davidk'));
45 | }
46 |
47 | public function testGetFollowers()
48 | {
49 | $this->assertArrayHasKey('instance', $this->SteemAccount->getFollowers('davidk'));
50 | }
51 |
52 | public function testCountFollows()
53 | {
54 | $this->assertArrayHasKey('instance', $this->SteemAccount->countFollows('davidk'));
55 | }
56 |
57 | public function testGetAccountReputations()
58 | {
59 | $this->assertArrayHasKey('instance', $this->SteemAccount->getAccountReputations('davidk', 2));
60 | }
61 |
62 | }
63 |
64 | ?>
--------------------------------------------------------------------------------
/tests/SteemAccountTest.php:
--------------------------------------------------------------------------------
1 | SteemAccount = new \SteemPHP\SteemAccount('https://steemd.steemit.com');
10 | }
11 |
12 | public function testGetApi()
13 | {
14 | $this->assertInternalType('int', $this->SteemAccount->getApi('login_api'));
15 | }
16 |
17 | public function testGetProps()
18 | {
19 | $this->assertArrayHasKey('head_block_number', $this->SteemAccount->getProps());
20 | }
21 |
22 | public function testGetAccountHistory()
23 | {
24 | $this->assertArrayHasKey('trx_id', $this->SteemAccount->getAccountHistory('davidk', 2)[0][1]);
25 | }
26 |
27 | public function testGetAccount()
28 | {
29 | $this->assertArrayHasKey('name', $this->SteemAccount->getAccount('davidk')[0]);
30 | }
31 |
32 | public function testGetReputation()
33 | {
34 | $this->assertInternalType('int', $this->SteemAccount->getReputation('davidk'));
35 | }
36 |
37 | public function testVestToSteemByAccount()
38 | {
39 | $this->assertInternalType('float', $this->SteemAccount->vestToSteemByAccount('davidk'));
40 | }
41 |
42 | public function testGetFollowing()
43 | {
44 | $this->assertArrayHasKey('follower', $this->SteemAccount->getFollowing('davidk')[0]);
45 | }
46 |
47 | public function testGetFollowers()
48 | {
49 | $this->assertArrayHasKey('follower', $this->SteemAccount->getFollowers('davidk')[0]);
50 | }
51 |
52 | public function testCountFollows()
53 | {
54 | $this->assertArrayHasKey('account', $this->SteemAccount->countFollows('davidk'));
55 | }
56 |
57 | public function testGetAccountReputations()
58 | {
59 | $this->assertArrayHasKey('account', $this->SteemAccount->getAccountReputations('davidk', 2)[0]);
60 | }
61 |
62 | }
63 |
64 | ?>
--------------------------------------------------------------------------------
/tests/SteemMarketFailureTest.php:
--------------------------------------------------------------------------------
1 | SteemMarket = new \SteemPHP\SteemMarket('https://rpc.google.com/');
10 | }
11 |
12 | public function testGetApi()
13 | {
14 | $this->assertArrayHasKey('instance', $this->SteemMarket->getApi('login_api'));
15 | }
16 |
17 | public function testGetOrderBook()
18 | {
19 | $order = $this->SteemMarket->getOrderBook(5);
20 | $this->assertArrayHasKey('instance', $order);
21 | }
22 |
23 | public function testGetOpenOrders()
24 | {
25 | $this->assertArrayHasKey('instance', $this->SteemMarket->getOpenOrders('david'));
26 | }
27 |
28 | public function testGetLiquidityQueue()
29 | {
30 | $this->assertArrayHasKey('instance', $this->SteemMarket->getLiquidityQueue('davidk', 5));
31 | }
32 |
33 | public function testGetOwnerHistory()
34 | {
35 | $this->assertArrayHasKey('instance', $this->SteemMarket->getOwnerHistory('davidk'));
36 | }
37 |
38 | public function testGetTicker()
39 | {
40 | $this->assertArrayHasKey('instance', $this->SteemMarket->getTicker());
41 | }
42 |
43 | public function testGetMarketHistory()
44 | {
45 | $this->assertArrayHasKey('instance', $this->SteemMarket->getMarketHistory('2017/7/11', '2017/8/11', 60));
46 | }
47 |
48 | public function testGetMarketHistoryBuckets()
49 | {
50 | $this->assertArrayHasKey('instance', $this->SteemMarket->getMarketHistoryBuckets());
51 | }
52 |
53 | public function testGetOrderBookFromMarket()
54 | {
55 | $order = $this->SteemMarket->getOrderBookFromMarket();
56 | $this->assertArrayHasKey('instance', $order);
57 | }
58 |
59 | public function testGetRecentTrades()
60 | {
61 | $this->assertArrayHasKey('instance', $this->SteemMarket->getRecentTrades(5));
62 | }
63 |
64 | public function testGetTradeHistory()
65 | {
66 | $this->assertArrayHasKey('instance', $this->SteemMarket->getTradeHistory('2017/8/10', '2017/8/11', 5));
67 | }
68 |
69 | public function testGetVolume()
70 | {
71 | $this->assertArrayHasKey('instance', $this->SteemMarket->getVolume());
72 | }
73 |
74 | }
75 |
76 | ?>
--------------------------------------------------------------------------------
/tests/SteemHelperTest.php:
--------------------------------------------------------------------------------
1 | assertInternalType('string', SteemHelper::toInt('500 STEEM'));
13 | }
14 |
15 | public function testNodes()
16 | {
17 | $this->assertEquals(['https://gtg.steem.house:8090',
18 | 'https://steemd.steemitdev.com',
19 | 'https://steemd.steemit.com',
20 | 'https://steemd-int.steemit.com',
21 | 'https://seed.bitcoiner.me',
22 | 'https://steemd.privex.io'], SteemHelper::nodes());
23 | }
24 |
25 | public function testFilterInt()
26 | {
27 | $this->assertInternalType('int', SteemHelper::filterInt(500));
28 | }
29 |
30 | public function testReputation()
31 | {
32 | $this->assertInternalType('int', SteemHelper::reputation(3000000));
33 | }
34 |
35 | public function testFilterDate()
36 | {
37 | $this->assertEquals(SteemHelper::now(), SteemHelper::filterDate(SteemHelper::now()));
38 | }
39 |
40 | public function testNow()
41 | {
42 | $this->assertEquals(date('Y-m-d\TH:i:s'), SteemHelper::now());
43 | }
44 |
45 | public function testBlockTime()
46 | {
47 | $this->assertEquals(date('Y-m-d\TH:i:s', strtotime('+1 minute')), SteemHelper::BlockTime(SteemHelper::now(), 'PT1M'));
48 | }
49 |
50 | public function testVestToSteem()
51 | {
52 | $this->assertInternalType('float', SteemHelper::vestToSteem('24477.640182 VESTS', '369735200112.175967 VESTS', '178661603.552 STEEM'));
53 | }
54 |
55 | public function testContains()
56 | {
57 | $this->assertEquals('1', SteemHelper::contains('davidk', 'd'));
58 | }
59 |
60 | public function testCharAt()
61 | {
62 | $this->assertEquals('a', SteemHelper::charAt('abcd', 0));
63 | }
64 |
65 | public function testHandleError()
66 | {
67 | $this->assertEquals([], SteemHelper::handleError(''));
68 | }
69 |
70 | public function testStr_slice()
71 | {
72 | $this->assertEquals('abc', SteemHelper::str_slice('abcdefg', 0, 3));
73 | }
74 |
75 | public function testSlice()
76 | {
77 | $this->assertEquals(['result' => ['d','e','f','g']] ,SteemHelper::slice(['a','b','c','d','e','f','g'], -4, 7));
78 | }
79 |
80 | }
81 |
82 | ?>
--------------------------------------------------------------------------------
/tests/SteemMarketTest.php:
--------------------------------------------------------------------------------
1 | SteemMarket = new \SteemPHP\SteemMarket('https://steemd.steemit.com');
10 | }
11 |
12 | public function testGetApi()
13 | {
14 | $this->assertInternalType('int', $this->SteemMarket->getApi('login_api'));
15 | }
16 |
17 | public function testGetOrderBook()
18 | {
19 | $order = $this->SteemMarket->getOrderBook(5);
20 | $this->assertArrayHasKey('asks', $order);
21 | $this->assertArrayHasKey('bids', $order);
22 | }
23 |
24 | public function testGetOpenOrders()
25 | {
26 | $this->assertInternalType('array', $this->SteemMarket->getOpenOrders('david'));
27 | }
28 |
29 | public function testGetLiquidityQueue()
30 | {
31 | $this->assertInternalType('array', $this->SteemMarket->getLiquidityQueue('davidk', 5));
32 | }
33 |
34 | public function testGetOwnerHistory()
35 | {
36 | $this->assertInternalType('array', $this->SteemMarket->getOwnerHistory('davidk'));
37 | }
38 |
39 | public function testGetTicker()
40 | {
41 | $this->assertArrayHasKey('latest', $this->SteemMarket->getTicker());
42 | }
43 |
44 | public function testGetMarketHistory()
45 | {
46 | $this->assertInternalType('array', $this->SteemMarket->getMarketHistory('2017/7/11', '2017/8/11', 60));
47 | }
48 |
49 | public function testGetMarketHistoryBuckets()
50 | {
51 | $this->assertEquals('15', $this->SteemMarket->getMarketHistoryBuckets()[0]);
52 | }
53 |
54 | public function testGetOrderBookFromMarket()
55 | {
56 | $order = $this->SteemMarket->getOrderBookFromMarket();
57 | $this->assertArrayHasKey('asks', $order);
58 | $this->assertArrayHasKey('bids', $order);
59 | }
60 |
61 | public function testGetRecentTrades()
62 | {
63 | $this->assertArrayHasKey('date', $this->SteemMarket->getRecentTrades(5)[0]);
64 | }
65 |
66 | public function testGetTradeHistory()
67 | {
68 | $this->assertArrayHasKey('date', $this->SteemMarket->getTradeHistory('2017/8/10', '2017/8/11', 5)[0]);
69 | }
70 |
71 | public function testGetVolume()
72 | {
73 | $this->assertArrayHasKey('steem_volume', $this->SteemMarket->getVolume());
74 | }
75 |
76 | }
77 |
78 | ?>
--------------------------------------------------------------------------------
/src/SteemPHP/SteemPrivate.php:
--------------------------------------------------------------------------------
1 | prefix = trim($prefix);
32 | }
33 |
34 | /**
35 | * password to private WIF
36 | *
37 | * @param string $name The username
38 | * @param string $password The password
39 | * @param string $role The role
40 | *
41 | * @return array private wif
42 | */
43 | public function toWif($name, $password, $role)
44 | {
45 | $seed = $name.$role.$password;
46 | $brainKey = implode(" ", explode("/[\t\n\v\f\r ]+/", trim($seed)));
47 | $hashSha256 = hash('sha256', $brainKey);
48 | $privKey = PrivateKeyFactory::fromHex($hashSha256);
49 | $privWif = $privKey->toWif();
50 | return $privWif;
51 | }
52 |
53 | /**
54 | * Get Private Key / WIF from seed
55 | *
56 | * @param string $seed The seed
57 | *
58 | * @return array private wif
59 | */
60 | public function fromSeed($seed)
61 | {
62 | if (gettype($seed) != "string") {
63 | return ['error' => 'string required for seed'];
64 | } else {
65 | return PrivateKeyFactory::fromHex(hash('sha256', $seed))->toWif();
66 | }
67 | }
68 |
69 | /**
70 | * Get Private Key / WIF from a buffer
71 | * buffer is the same as hex
72 | *
73 | * @param string $buffer The buffer/hex
74 | *
75 | * @return array|string array on failure|wif on success
76 | */
77 | public function fromBuffer($buffer)
78 | {
79 | if (!Buffer::hex($buffer)) {
80 | return ['error' => 'Expecting paramter to be a Buffer type'];
81 | } else if (strlen($buffer) == 32) {
82 | return ['error' => 'Empty Buffer'];
83 | } else {
84 | return PrivateKeyFactory::fromHex($buffer)->toWif();
85 | }
86 | }
87 |
88 | /**
89 | * Check if the given string is wif
90 | *
91 | * @param string $wif The wif
92 | *
93 | * @return boolean True if wif, False otherwise.
94 | */
95 | public function isWif($wif)
96 | {
97 | try {
98 | PrivateKeyFactory::fromWif($wif);
99 | return true;
100 | } catch(\Exception $e) {
101 | return false;
102 | }
103 | }
104 |
105 | /**
106 | * Get wif from wif
107 | *
108 | * @param string $wif The wif
109 | *
110 | * @return string The wif
111 | */
112 | public function fromWif($wif)
113 | {
114 | return PrivateKeyFactory::fromWif($wif)->toWif();
115 | }
116 |
117 | }
118 |
119 | ?>
--------------------------------------------------------------------------------
/src/SteemPHP/SteemAddress.php:
--------------------------------------------------------------------------------
1 | addy = new Buffer(trim($addy));
43 | $this->setPrefix($address_prefix);
44 | }
45 |
46 | /**
47 | * Sets the address prefix.
48 | *
49 | * @param string $prefix The address prefix
50 | */
51 | public function setPrefix($address_prefix)
52 | {
53 | $this->address_prefix = trim($address_prefix);
54 | }
55 |
56 | /**
57 | * SteemAddress from buffer
58 | *
59 | * @param string $buffer The buffer
60 | *
61 | * @return string address from the given buffer
62 | */
63 | public function fromBuffer($buffer)
64 | {
65 | $this->_hash = new Buffer(hash('sha512', $buffer));
66 | $this->addy = Hash::ripemd160($this->_hash);
67 | $SteemAddress = new SteemAddress($this->addy->getHex(), $this->address_prefix);
68 | return $SteemAddress->toString();
69 | }
70 |
71 | /**
72 | * SteemAddress from a given public key
73 | *
74 | * @param string $string The public key
75 | *
76 | * @return string address from a given public key
77 | */
78 | public function fromString($string)
79 | {
80 | $prefix = SteemHelper::str_slice($string, 0, strlen($this->address_prefix));
81 | if ($prefix != $this->address_prefix) {
82 | return "Expecting key to begin with ".$this->address_prefix.", instead got ".$prefix;
83 | } else {
84 | $addy = SteemHelper::str_slice($string, strlen($this->address_prefix));
85 | $addy = new Buffer(Base58::decode($addy)->getHex());
86 | $checksum = $addy->slice(-4);
87 | $addy = $addy->slice(0, 4);
88 | $new_checksum = Hash::ripemd160($addy);
89 | $new_checksum = $new_checksum->slice(0, 4);
90 | if ($checksum->getHex() != $new_checksum->getHex())
91 | {
92 | return 'Checksum did not match';
93 | }
94 | $SteemAddress = new SteemAddress($addy->getHex(), $this->address_prefix);
95 | return $SteemAddress->toString();
96 | }
97 | }
98 |
99 | /**
100 | * Get the addy in buffer format
101 | * @return string
102 | */
103 | public function toBuffer()
104 | {
105 | return $this->addy->getHex();
106 | }
107 |
108 | /**
109 | * turn the addy into an address
110 | * @return type
111 | */
112 | public function toString()
113 | {
114 | $checksum = Hash::ripemd160($this->addy);
115 | $this->addy = Buffertools::concat($this->addy, $checksum->slice(0, 4));
116 | return $this->address_prefix . Base58::encode($this->addy);
117 | }
118 |
119 | }
120 |
121 | ?>
--------------------------------------------------------------------------------
/tests/SteemArticleTest.php:
--------------------------------------------------------------------------------
1 | SteemArticle = new \SteemPHP\SteemArticle('https://steemd.steemit.com');
11 | }
12 |
13 | public function testGetApi()
14 | {
15 | $this->assertInternalType('int', $this->SteemArticle->getApi('login_api'));
16 | }
17 |
18 | public function testGetTrendingTags()
19 | {
20 | $this->assertArrayHasKey('name', $this->SteemArticle->getTrendingTags('steemit', 10)[0]);
21 | }
22 |
23 | public function testGetContent()
24 | {
25 | $this->assertArrayHasKey('author', $this->SteemArticle->getContent('davidk', 'steemphp-new-functions-added-part-1'));
26 | }
27 |
28 | public function testGetcontentReplies()
29 | {
30 | $this->assertArrayHasKey('author', $this->SteemArticle->getContentReplies('davidk', 'steemphp-new-functions-added-part-1')[0]);
31 | }
32 |
33 | public function testGetDiscussionsByTrending()
34 | {
35 | $this->assertArrayHasKey('author', $this->SteemArticle->getDiscussionsByTrending('life', 2)[0]);
36 | }
37 |
38 | public function testGetDiscussionsByCreated()
39 | {
40 | $this->assertArrayHasKey('author', $this->SteemArticle->getDiscussionsByCreated('life', 2)[0]);
41 | }
42 |
43 | public function testGetDiscussionsByActive()
44 | {
45 | $this->assertArrayHasKey('author', $this->SteemArticle->getDiscussionsByActive('life', 2)[0]);
46 | }
47 |
48 | public function testGetDiscussionsByPromoted()
49 | {
50 | $this->assertArrayHasKey('author', $this->SteemArticle->getDiscussionsByPromoted('life', 2)[0]);
51 | }
52 |
53 | public function testGetDiscussionsByCashout()
54 | {
55 | $this->assertInternalType('array', $this->SteemArticle->getDiscussionsByCashout('life', 2));
56 | }
57 |
58 | public function testGetDiscussionsByPayout()
59 | {
60 | $this->assertArrayHasKey('author', $this->SteemArticle->getDiscussionsByPayout('life', 2)[0]);
61 | }
62 |
63 | public function testGetDiscussionsByVotes()
64 | {
65 | $this->assertArrayHasKey('author', $this->SteemArticle->getDiscussionsByVotes('life', 2)[0]);
66 | }
67 |
68 | public function testGetDiscussionsByChildren()
69 | {
70 | $this->assertArrayHasKey('author', $this->SteemArticle->getDiscussionsByChildren('life', 2)[0]);
71 | }
72 |
73 | public function testGetDiscussionsByHot()
74 | {
75 | $this->assertArrayHasKey('author', $this->SteemArticle->getDiscussionsByHot('life', 2)[0]);
76 | }
77 |
78 | public function testGetDiscussionsByFeed()
79 | {
80 | $this->assertArrayHasKey('author', $this->SteemArticle->getDiscussionsByFeed('davidk', 2)[0]);
81 | }
82 |
83 | public function testGetDiscussionsByBlog()
84 | {
85 | $this->assertArrayHasKey('author', $this->SteemArticle->getDiscussionsByBlog('davidk', 2)[0]);
86 | }
87 |
88 | public function testGetDiscussionsByComments()
89 | {
90 | $this->assertArrayHasKey('author', $this->SteemArticle->getDiscussionsByComments('davidk', '', 2)[0]);
91 | }
92 |
93 | public function testGetDiscussionsByAuthorBeforeDate()
94 | {
95 | $this->assertArrayHasKey('author', $this->SteemArticle->getDiscussionsByAuthorBeforeDate('davidk', '', '2017-06-29', 2)[0]);
96 | }
97 |
98 | public function testGetRepliesByLastUpvote()
99 | {
100 | $this->assertArrayHasKey('author', $this->SteemArticle->getRepliesByLastUpvote('davidk', '', 2)[0]);
101 | }
102 |
103 | public function testGet()
104 | {
105 | $this->assertArrayHasKey('voter', $this->SteemArticle->getActiveVotes('davidk', 'steemphp-new-functions-added-part-1')[0]);
106 | }
107 |
108 | public function testGetState()
109 | {
110 | $this->assertArrayHasKey('props', $this->SteemArticle->getState('/@davidk'));
111 | }
112 |
113 | }
114 |
115 | ?>
--------------------------------------------------------------------------------
/tests/SteemArticleFailureTest.php:
--------------------------------------------------------------------------------
1 | SteemArticle = new \SteemPHP\SteemArticle('https://rpc.google.com/');
11 | }
12 |
13 | public function testGetApi()
14 | {
15 | $this->assertArrayHasKey('instance', $this->SteemArticle->getApi('login_api'));
16 | }
17 |
18 | public function testGetTrendingTags()
19 | {
20 | $this->assertArrayHasKey('instance', $this->SteemArticle->getTrendingTags('steemit', 10));
21 | }
22 |
23 | public function testGetContent()
24 | {
25 | $this->assertArrayHasKey('instance', $this->SteemArticle->getContent('davidk', 'steemphp-new-functions-added-part-1'));
26 | }
27 |
28 | public function testGetcontentReplies()
29 | {
30 | $this->assertArrayHasKey('instance', $this->SteemArticle->getContentReplies('davidk', 'steemphp-new-functions-added-part-1'));
31 | }
32 |
33 | public function testGetDiscussionsByTrending()
34 | {
35 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByTrending('life', 2));
36 | }
37 |
38 | public function testGetDiscussionsByCreated()
39 | {
40 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByCreated('life', 2));
41 | }
42 |
43 | public function testGetDiscussionsByActive()
44 | {
45 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByActive('life', 2));
46 | }
47 |
48 | public function testGetDiscussionsByPromoted()
49 | {
50 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByPromoted('life', 2));
51 | }
52 |
53 | public function testGetDiscussionsByCashout()
54 | {
55 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByCashout('life', 2));
56 | }
57 |
58 | public function testGetDiscussionsByPayout()
59 | {
60 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByPayout('life', 2));
61 | }
62 |
63 | public function testGetDiscussionsByVotes()
64 | {
65 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByVotes('life', 2));
66 | }
67 |
68 | public function testGetDiscussionsByChildren()
69 | {
70 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByChildren('life', 2));
71 | }
72 |
73 | public function testGetDiscussionsByHot()
74 | {
75 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByHot('life', 2));
76 | }
77 |
78 | public function testGetDiscussionsByFeed()
79 | {
80 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByFeed('davidk', 2));
81 | }
82 |
83 | public function testGetDiscussionsByBlog()
84 | {
85 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByBlog('davidk', 2));
86 | }
87 |
88 | public function testGetDiscussionsByComments()
89 | {
90 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByComments('davidk', '', 2));
91 | }
92 |
93 | public function testGetDiscussionsByAuthorBeforeDate()
94 | {
95 | $this->assertArrayHasKey('instance', $this->SteemArticle->getDiscussionsByAuthorBeforeDate('davidk', '', '2017-06-29', 2));
96 | }
97 |
98 | public function testGetRepliesByLastUpvote()
99 | {
100 | $this->assertArrayHasKey('instance', $this->SteemArticle->getRepliesByLastUpvote('davidk', '', 2));
101 | }
102 |
103 | public function testGet()
104 | {
105 | $this->assertArrayHasKey('instance', $this->SteemArticle->getActiveVotes('davidk', 'steemphp-new-functions-added-part-1'));
106 | }
107 |
108 | public function testGetState()
109 | {
110 | $this->assertArrayHasKey('instance', $this->SteemArticle->getState('/@davidk'));
111 | }
112 |
113 | }
114 |
115 | ?>
--------------------------------------------------------------------------------
/src/SteemPHP/SteemChain.php:
--------------------------------------------------------------------------------
1 | host = trim($host);
38 | $this->httpClient = new HttpClient($this->host);
39 | $this->httpClient->withoutSslVerification();
40 | $this->client = new Client($this->host, false, $this->httpClient);
41 | }
42 |
43 | /**
44 | * Get Api number
45 | * @param String $name
46 | * @return int
47 | */
48 | public function getApi($name)
49 | {
50 | try {
51 | return $this->client->call(1, 'get_api_by_name', [$name]);
52 | } catch (\Exception $e) {
53 | return SteemHelper::handleError($e);
54 | }
55 | }
56 |
57 | /**
58 | * Get Current blockchain version with steem and fc revision
59 | * @return array
60 | */
61 | public function getVersion()
62 | {
63 | try {
64 | $this->api = $this->getApi('login_api');
65 | return $this->client->call($this->api, 'get_version', []);
66 | } catch (\Exception $e) {
67 | return SteemHelper::handleError($e);
68 | }
69 | }
70 |
71 | /**
72 | * Get the total number of registered steem accounts
73 | * @return int
74 | */
75 | public function getAccountCount()
76 | {
77 | try {
78 | $this->api = $this->getApi('database_api');
79 | return $this->client->call($this->api, 'get_account_count', []);
80 | } catch (\Exception $e) {
81 | return SteemHelper::handleError($e);
82 | }
83 | }
84 |
85 | /**
86 | * Get currency blockchain properties
87 | * @return array
88 | */
89 | public function getChainProperties()
90 | {
91 | try {
92 | $this->api = $this->getApi('database_api');
93 | return $this->client->call($this->api, 'get_chain_properties', []);
94 | } catch (\Exception $e) {
95 | return SteemHelper::handleError($e);
96 | }
97 | }
98 |
99 | /**
100 | * Get blockchain configuration
101 | * @return array
102 | */
103 | public function getConfig()
104 | {
105 | try {
106 | $this->api = $this->getApi('database_api');
107 | return $this->client->call($this->api, 'get_config', []);
108 | } catch (\Exception $e) {
109 | return SteemHelper::handleError($e);
110 | }
111 | }
112 |
113 | /**
114 | * Get Dynamic Global Properties
115 | * @return array
116 | */
117 | public function getDynamicGlobalProperties()
118 | {
119 | try {
120 | $this->api = $this->getApi('database_api');
121 | return $this->client->call($this->api, 'get_dynamic_global_properties', []);
122 | } catch (\Exception $e) {
123 | return SteemHelper::handleError($e);
124 | }
125 | }
126 |
127 | /**
128 | * Get Feed History
129 | * @return array
130 | */
131 | public function getFeedHistory()
132 | {
133 | try {
134 | $this->api = $this->getApi('database_api');
135 | return $this->client->call($this->api, 'get_feed_history', []);
136 | } catch (\Exception $e) {
137 | return SteemHelper::handleError($e);
138 | }
139 | }
140 |
141 | /**
142 | * Get Current Median History Price
143 | * @return array
144 | */
145 | public function getCurrentMeidanHistoryPrice()
146 | {
147 | try {
148 | $this->api = $this->getApi('database_api');
149 | return $this->client->call($this->api, 'get_current_median_history_price', []);
150 | } catch (\Exception $e) {
151 | return SteemHelper::handleError($e);
152 | }
153 | }
154 |
155 | /**
156 | * Get current Hardfork version
157 | * @return version
158 | */
159 | public function getHardforkVersion()
160 | {
161 | try {
162 | $this->api = $this->getApi('database_api');
163 | return $this->client->call($this->api, 'get_hardfork_version', []);
164 | } catch (\Exception $e) {
165 | return SteemHelper::handleError($e);
166 | }
167 | }
168 |
169 | /**
170 | * Get next scheduled hardfork version and date
171 | * @return array
172 | */
173 | public function getNextScheduledHardfork()
174 | {
175 | try {
176 | $this->api = $this->getApi('database_api');
177 | return $this->client->call($this->api, 'get_next_scheduled_hardfork', []);
178 | } catch (\Exception $e) {
179 | return SteemHelper::handleError($e);
180 | }
181 | }
182 |
183 | }
184 |
185 | ?>
--------------------------------------------------------------------------------
/src/SteemPHP/SteemWitness.php:
--------------------------------------------------------------------------------
1 | host = trim($host);
38 | $this->httpClient = new HttpClient($this->host);
39 | $this->httpClient->withoutSslVerification();
40 | $this->client = new Client($this->host, false, $this->httpClient);
41 | }
42 |
43 | /**
44 | * Get Api number
45 | * @param String $name
46 | * @return int
47 | */
48 | public function getApi($name)
49 | {
50 | try {
51 | return $this->client->call(1, 'get_api_by_name', [$name]);
52 | } catch (\Exception $e) {
53 | return SteemHelper::handleError($e);
54 | }
55 | }
56 |
57 | /**
58 | * Get total withness count
59 | * @return int
60 | */
61 | public function getWitnessCount()
62 | {
63 | try {
64 | $this->api = $this->getApi('database_api');
65 | return $this->client->call($this->api, 'get_witness_count', []);
66 | } catch (\Exception $e) {
67 | return SteemHelper::handleError($e);
68 | }
69 | }
70 |
71 | /**
72 | * Get list of witness account names similar to $account
73 | * @param String $account
74 | * @param int $limit
75 | * @return array
76 | */
77 | public function lookupWitnessAccounts($lowerBoundName, $limit = 100)
78 | {
79 | try {
80 | $this->api = $this->getApi('database_api');
81 | return $this->client->call($this->api, 'lookup_witness_accounts', [$lowerBoundName, SteemHelper::filterInt($limit)]);
82 | } catch (\Exception $e) {
83 | return SteemHelper::handleError($e);
84 | }
85 | }
86 |
87 | /**
88 | * Get the next witness schedule
89 | * @return array
90 | */
91 | public function getWitnessSchedule()
92 | {
93 | try {
94 | $this->api = $this->getApi('database_api');
95 | return $this->client->call($this->api, 'get_witness_schedule', []);
96 | } catch (\Exception $e) {
97 | return SteemHelper::handleError($e);
98 | }
99 | }
100 |
101 | /**
102 | * Get witness information by ID
103 | * @param int|array $accounts
104 | * @return array
105 | */
106 | public function getWitnesses($accounts = [])
107 | {
108 | try {
109 | $accounts = !is_array($accounts) ? [$accounts] : $accounts;
110 | $this->api = $this->getApi('database_api');
111 | return $this->client->call($this->api, 'get_witnesses', [$accounts]);
112 | } catch (\Exception $e) {
113 | return SteemHelper::handleError($e);
114 | }
115 | }
116 |
117 | /**
118 | * Get witness information by account name
119 | * @param String $account
120 | * @return array
121 | */
122 | public function getWitnessByAccount($account)
123 | {
124 | try {
125 | $this->api = $this->getApi('database_api');
126 | return $this->client->call($this->api, 'get_witness_by_account', [$account]);
127 | } catch (\Exception $e) {
128 | return SteemHelper::handleError($e);
129 | }
130 | }
131 |
132 | /**
133 | * Get Witnesses by vote where the names are similar to $account name
134 | * @param String $account
135 | * @param int $limit
136 | * @return array
137 | */
138 | public function getWitnessesByVote($account, $limit = 100)
139 | {
140 | try {
141 | $this->api = $this->getApi('database_api');
142 | return $this->client->call($this->api, 'get_witnesses_by_vote', [$account, SteemHelper::filterInt($limit)]);
143 | } catch (\Exception $e) {
144 | return SteemHelper::handleError($e);
145 | }
146 | }
147 |
148 | /**
149 | * Get list of active witnesses
150 | * @return array
151 | */
152 | public function getActiveWitnesses()
153 | {
154 | try {
155 | $this->api = $this->getApi('database_api');
156 | return $this->client->call($this->api, 'get_active_witnesses', []);
157 | } catch (\Exception $e) {
158 | return SteemHelper::handleError($e);
159 | }
160 | }
161 |
162 | /**
163 | * Get list of miners queue
164 | * @return array
165 | */
166 | public function getMinerQueue()
167 | {
168 | try {
169 | $this->api = $this->getApi('database_api');
170 | return $this->client->call($this->api, 'get_miner_queue', []);
171 | } catch (\Exception $e) {
172 | return SteemHelper::handleError($e);
173 | }
174 | }
175 |
176 | }
177 |
178 | ?>
--------------------------------------------------------------------------------
/src/SteemPHP/SteemAccount.php:
--------------------------------------------------------------------------------
1 | host = trim($host);
39 | $this->httpClient = new HttpClient($this->host);
40 | $this->httpClient->withoutSslVerification();
41 | $this->client = new Client($this->host, false, $this->httpClient);
42 | }
43 |
44 | /**
45 | * Gets the api number by api $name
46 | *
47 | * @param sting $name The name of the api
48 | *
49 | * @return integer The api number
50 | */
51 | public function getApi($name)
52 | {
53 | try {
54 | return $this->client->call(1, 'get_api_by_name', [$name]);
55 | } catch (\Exception $e) {
56 | return SteemHelper::handleError($e);
57 | }
58 | }
59 |
60 | /**
61 | * Gets Dynamic Global Properties
62 | *
63 | * @return array The properties
64 | */
65 | public function getProps()
66 | {
67 | try {
68 | $return = $this->client->call(0, 'get_dynamic_global_properties', []);
69 | $return['steem_per_mvests'] = floor(SteemHelper::toInt($return['total_vesting_fund_steem']) / SteemHelper::toInt($return['total_vesting_shares']) * 1000000 * 1000) / 1000;
70 | return $return;
71 | } catch (\Exception $e) {
72 | return SteemHelper::handleError($e);
73 | }
74 | }
75 |
76 | /**
77 | * Gets the account history.
78 | *
79 | * @param string $username The username
80 | * @param integer $limit The limit
81 | * @param integer $skip Skip is the place to start for pagination
82 | *
83 | * @return array The account history.
84 | */
85 | public function getAccountHistory($username, $limit = 100, $skip = -1)
86 | {
87 | try {
88 | return $this->client->call(0, 'get_account_history', [$username, SteemHelper::filterInt($skip), SteemHelper::filterInt($limit)]);
89 | } catch (\Exception $e) {
90 | return SteemHelper::handleError($e);
91 | }
92 | }
93 |
94 | /**
95 | * Gets the account information.
96 | *
97 | * @param string $account The account name
98 | *
99 | * @return array The account information
100 | */
101 | public function getAccount($account)
102 | {
103 | try {
104 | $this->return = $this->client->call(0, 'get_accounts', [[$account]]);
105 | foreach($this->return as $this->index => $this->username) {
106 | $this->return[$this->index]['profile'] = json_decode($this->username['json_metadata'], true)['profile'];
107 | }
108 | return $this->return;
109 | } catch (\Exception $e) {
110 | return SteemHelper::handleError($e);
111 | }
112 | }
113 |
114 | /**
115 | * Gets the reputation of an account.
116 | *
117 | * @param string $account The account name
118 | *
119 | * @return integer The reputation.
120 | */
121 | public function getReputation($account)
122 | {
123 | try {
124 | $this->accountDetails = $this->getAccount($account);
125 | return SteemHelper::reputation($this->accountDetails[0]['reputation']);
126 | } catch (\Exception $e) {
127 | return SteemHelper::handleError($e);
128 | }
129 | }
130 |
131 | /**
132 | * Gets the account reputations of accounts having $account as lower bound
133 | *
134 | * @param string $account The account name
135 | * @param integer $limit The limit
136 | *
137 | * @return array The account reputations.
138 | */
139 | public function getAccountReputations($account, $limit = 100)
140 | {
141 | try {
142 | $this->api = $this->getApi('follow_api');
143 | $this->return = $this->client->call($this->api, 'get_account_reputations', [$account, SteemHelper::filterInt($limit)]);
144 | return $this->return;
145 | } catch (\Exception $e) {
146 | return SteemHelper::handleError($e);
147 | }
148 | }
149 |
150 | /**
151 | * Get the amount of steem $account's vest is worth
152 | *
153 | * @param string $account The account
154 | *
155 | * @return integer steem amount
156 | */
157 | public function vestToSteemByAccount($account)
158 | {
159 | try {
160 | $this->accountDetails = $this->getAccount($account);
161 | $this->Props = $this->getProps();
162 | return SteemHelper::vestToSteem($this->accountDetails[0]['vesting_shares'], $this->Props['total_vesting_shares'], $this->Props['total_vesting_fund_steem']);
163 | } catch (\Exception $e) {
164 | return SteemHelper::handleError($e);
165 | }
166 | }
167 |
168 | /**
169 | * Get list of people the $account is following
170 | *
171 | * @param string $account The account name
172 | * @param integer $limit The limit
173 | * @param integer $skip Skip is the place to start for pagination
174 | *
175 | * @return arra The following.
176 | */
177 | public function getFollowing($account, $limit = 100, $skip = -1)
178 | {
179 | try {
180 | $this->api = $this->getApi('follow_api');
181 | return $this->client->call($this->api, 'get_following', [$account, SteemHelper::filterInt($skip), 'blog', SteemHelper::filterInt($limit)]);
182 | } catch (\Exception $e) {
183 | return SteemHelper::handleError($e);
184 | }
185 | }
186 |
187 | /**
188 | * Get the followers list for $account
189 | *
190 | * @param string $account The account name
191 | * @param integer $limit The limit
192 | * @param integer $skip Skip is the place to start for pagination
193 | *
194 | * @return array The followers.
195 | */
196 | public function getFollowers($account, $limit = 100, $skip = -1)
197 | {
198 | try {
199 | $this->api = $this->getApi('follow_api');
200 | return $this->client->call($this->api, 'get_followers', [$account, SteemHelper::filterInt($skip), 'blog', SteemHelper::filterInt($limit)]);
201 | } catch (\Exception $e) {
202 | return SteemHelper::handleError($e);
203 | }
204 | }
205 |
206 | /**
207 | * Count the number of follows and followers of $account
208 | *
209 | * @param string $account The account name
210 | *
211 | * @return array Number of follows.
212 | */
213 | public function countFollows($account)
214 | {
215 | try {
216 | $this->api = $this->getApi('follow_api');
217 | return $this->client->call($this->api, 'get_follow_count', [$account]);
218 | } catch (\Exception $e) {
219 | return SteemHelper::handleError($e);
220 | }
221 | }
222 |
223 | /**
224 | * Get the estimated account value of $account
225 | *
226 | * $state = $SteemArticle->getState('/@'.$account.'/transfers')
227 | * $market = $SteemMaket->getOpenOrders($account);
228 | *
229 | * NOTE: This function only gets the estimated amount of money inside the $accounts wallet
230 | *
231 | * @param array $state The state
232 | * @param array $openOrders The open orders
233 | * @param string $account The account
234 | *
235 | * if (success) {
236 | * @return integer estimated account value
237 | * } else {
238 | * @return array the error that it catches
239 | * }
240 | */
241 | public function estimateAccountValue($state, $openOrders, $account)
242 | {
243 | try {
244 | return SteemHelper::estimateAccountValue($state, $openOrders, $account);
245 | } catch (\Exception $e) {
246 | return SteemHelper::handleError($e);
247 | }
248 | }
249 |
250 | }
251 |
252 | ?>
--------------------------------------------------------------------------------
/src/SteemPHP/SteemMarket.php:
--------------------------------------------------------------------------------
1 | host = trim($host);
39 | $this->httpClient = new HttpClient($this->host);
40 | $this->httpClient->withoutSslVerification();
41 | $this->client = new Client($this->host, false, $this->httpClient);
42 | }
43 |
44 | /**
45 | * Gets the api number by api $name
46 | *
47 | * @param sting $name The name of the api
48 | *
49 | * @return integer The api number
50 | */
51 | public function getApi($name)
52 | {
53 | try{
54 | return $this->client->call(1, 'get_api_by_name', [$name]);
55 | } catch (\Exception $e) {
56 | return SteemHelper::handleError($e);
57 | }
58 | }
59 |
60 | /**
61 | * Get the list of sell & buy for STEEM & SBD
62 | *
63 | * @param integer $limit The limit
64 | *
65 | * @return array The order book.
66 | */
67 | public function getOrderBook($limit = 100)
68 | {
69 | try {
70 | $this->api = $this->getApi('database_api');
71 | return $this->client->call($this->api, 'get_order_book', [SteemHelper::filterInt($limit)]);
72 | } catch (\Exception $e) {
73 | return SteemHelper::handleError($e);
74 | }
75 | }
76 |
77 | /**
78 | * Get open orders for $account
79 | *
80 | * @param string $account The account name
81 | *
82 | * @return array The open orders of $account.
83 | */
84 | public function getOpenOrders($account)
85 | {
86 | try {
87 | $this->api = $this->getApi('database_api');
88 | return $this->client->call($this->api, 'get_open_orders', [$account]);
89 | } catch (\Exception $e) {
90 | return SteemHelper::handleError($e);
91 | }
92 | }
93 |
94 | /**
95 | * Get liquidity reward queue starting from $startAccount and get upto $limit list
96 | *
97 | * @param string $startAccount The start account
98 | * @param integer $limit The limit
99 | *
100 | * @return array The liquidity queue.
101 | */
102 | public function getLiquidityQueue($startAccount, $limit = 100)
103 | {
104 | try {
105 | $this->api = $this->getApi('database_api');
106 | return $this->client->call($this->api, 'get_liquidity_queue', [$startAccount, $limit]);
107 | } catch (\Exception $e) {
108 | return SteemHelper::handleError($e);
109 | }
110 | }
111 |
112 | /**
113 | * Gets the owner history of $account.
114 | *
115 | * @param string $account The account
116 | *
117 | * @return array The owner history.
118 | */
119 | public function getOwnerHistory($account)
120 | {
121 | try {
122 | $this->api = $this->getApi('database_api');
123 | return $this->client->call($this->api, 'get_owner_history', [$account]);
124 | } catch (\Exception $e) {
125 | return SteemHelper::handleError($e);
126 | }
127 | }
128 |
129 | /**
130 | * Gets the market ticker for the internal SBD:STEEM market
131 | *
132 | * @return array The ticker.
133 | */
134 | public function getTicker()
135 | {
136 | try {
137 | $this->api = $this->getApi('market_history_api');
138 | return $this->client->call($this->api, 'get_ticker', []);
139 | } catch (\Exception $e) {
140 | return SteemHelper::handleError($e);
141 | }
142 | }
143 |
144 | /**
145 | * Gets the market history for the internal SBD:STEEM market.
146 | *
147 | * @param date|time $startTime The start time to get market history.
148 | * @param date|time $endTime The end time to get market history
149 | * @param integer $bucket_seconds The size of buckets the history is broken into.
150 | * The bucket size must be configured in the plugin options.
151 | *
152 | * @return array A list of market history buckets.
153 | */
154 | public function getMarketHistory($startTime, $endTime, $bucket_seconds)
155 | {
156 | $this->bucket_seconds = $bucket_seconds;
157 | $this->startTime = SteemHelper::filterDate($startTime);
158 | $this->endTime = SteemHelper::filterDate($endTime);
159 | try {
160 | $this->api = $this->getApi('market_history_api');
161 | return $this->client->call($this->api, 'get_market_history', [$this->bucket_seconds, $this->startTime, $this->endTime]);
162 | } catch (\Exception $e) {
163 | return SteemHelper::handleError($e);
164 | }
165 | }
166 |
167 | /**
168 | * Gets the bucket seconds being tracked by the plugin.
169 | *
170 | * @return array The market history buckets.
171 | */
172 | public function getMarketHistoryBuckets()
173 | {
174 | try {
175 | $this->api = $this->getApi('market_history_api');
176 | return $this->client->call($this->api, 'get_market_history_buckets', []);
177 | } catch (\Exception $e) {
178 | return SteemHelper::handleError($e);
179 | }
180 | }
181 |
182 | /**
183 | * Gets the current order book for the internal SBD:STEEM market.
184 | *
185 | * @param integer $limit The number of orders to have on each side of the order book.
186 | * Maximum is 500
187 | *
188 | * @return array The order book from market.
189 | */
190 | public function getOrderBookFromMarket($limit = 100)
191 | {
192 | try {
193 | $this->api = $this->getApi('market_history_api');
194 | return $this->client->call($this->api, 'get_order_book', [SteemHelper::filterInt($limit)]);
195 | } catch (\Exception $e) {
196 | return SteemHelper::handleError($e);
197 | }
198 | }
199 |
200 | /**
201 | * Gets the N most recent trades for the internal SBD:STEEM market.
202 | *
203 | * @param integer $limit The number of recent trades to return.
204 | * Maximum is 1000.
205 | *
206 | * @return array A list of completed trades.
207 | */
208 | public function getRecentTrades($limit = 100)
209 | {
210 | try {
211 | $this->api = $this->getApi('market_history_api');
212 | return $this->client->call($this->api, 'get_recent_trades', [SteemHelper::filterInt($limit)]);
213 | } catch (\Exception $e) {
214 | return SteemHelper::handleError($e);
215 | }
216 | }
217 |
218 | /**
219 | * Gets the trade history for the internal SBD:STEEM market.
220 | *
221 | * @param date|time $startTime The start time of the trade history.
222 | * param date|time $endTime The end time of the trade history.
223 | * @param integer $limit The number of trades to return. Maximum is 1000.
224 | *
225 | * @return array A list of completed trades.
226 | */
227 | public function getTradeHistory($startTime, $endTime, $limit = 100)
228 | {
229 | $this->limit = SteemHelper::filterInt($limit);
230 | $this->startTime = SteemHelper::filterDate($startTime);
231 | $this->endTime = SteemHelper::filterDate($endTime);
232 | try {
233 | $this->api = $this->getApi('market_history_api');
234 | return $this->client->call($this->api, 'get_trade_history', [$this->startTime, $this->endTime, $this->limit]);
235 | } catch (\Exception $e) {
236 | return SteemHelper::handleError($e);
237 | }
238 | }
239 |
240 | /**
241 | * Gets the market volume for the past 24 hours
242 | *
243 | * @return array The market volume.
244 | */
245 | public function getVolume()
246 | {
247 | try {
248 | $this->api = $this->getApi('market_history_api');
249 | return $this->client->call($this->api, 'get_volume', []);
250 | } catch (\Exception $e) {
251 | return SteemHelper::handleError($e);
252 | }
253 | }
254 |
255 | }
256 |
257 | ?>
--------------------------------------------------------------------------------
/src/SteemPHP/SteemBlock.php:
--------------------------------------------------------------------------------
1 | host = trim($host);
41 | $this->httpClient = new HttpClient($this->host);
42 | $this->httpClient->withoutSslVerification();
43 | $this->client = new Client($this->host, false, $this->httpClient);
44 | }
45 |
46 | /**
47 | * Gets the api number by api $name
48 | *
49 | * @param string $name The name of the api
50 | *
51 | * @return integer The api number
52 | */
53 | public function getApi($name)
54 | {
55 | try {
56 | return $this->client->call(1, 'get_api_by_name', [$name]);
57 | } catch (\Exception $e) {
58 | return SteemHelper::handleError($e);
59 | }
60 | }
61 |
62 | /**
63 | * Get Block by block number
64 | * @param int $blockNumber
65 | * @return array
66 | */
67 | public function getBlock($blockNumber)
68 | {
69 | try {
70 | $this->api = $this->getApi('database_api');
71 | return $this->client->call($this->api, 'get_block', [SteemHelper::filterInt($blockNumber)]);
72 | } catch (\Exception $e) {
73 | return SteemHelper::handleError($e);
74 | }
75 | }
76 |
77 | /**
78 | * Get Block header by block number
79 | * @param int $blockNumber
80 | * @return array
81 | */
82 | public function getBlockHeader($blockNumber)
83 | {
84 | try {
85 | $this->api = $this->getApi('database_api');
86 | return $this->client->call($this->api, 'get_block_header', [SteemHelper::filterInt($blockNumber)]);
87 | } catch (\Exception $e) {
88 | return SteemHelper::handleError($e);
89 | }
90 | }
91 |
92 | /**
93 | * Get Block header by block number
94 | * @param int $blockNumber
95 | * @param boolean $onlyVirtual
96 | * @return array
97 | */
98 | public function getOpsInBlock($blockNumber, $onlyVirtual = false)
99 | {
100 | try {
101 | $this->api = $this->getApi('database_api');
102 | return $this->client->call($this->api, 'get_ops_in_block', [SteemHelper::filterInt($blockNumber), $onlyVirtual]);
103 | } catch (\Exception $e) {
104 | return SteemHelper::handleError($e);
105 | }
106 | }
107 |
108 | /**
109 | * Get Transaction Hex from a transaction
110 | * std::string get_transaction_hex(const signed_transaction& trx)const;
111 | * @param string $trx
112 | * @return array
113 | */
114 | public function getTransactionHex($trx)
115 | {
116 | try {
117 | $this->api = $this->getApi('database_api');
118 | return $this->client->call($this->api, 'get_transaction_hex', [['trx' => $trx]]);
119 | } catch (\Exception $e) {
120 | return SteemHelper::handleError($e);
121 | }
122 | }
123 |
124 | /**
125 | * Get transaction by transaction id
126 | * annotated_signed_transaction database_api::get_transaction( transaction_id_type id )const
127 | * @param string $trx_id
128 | * @return array
129 | */
130 | public function getTransaction($trx_id)
131 | {
132 | try {
133 | $this->api = $this->getApi('database_api');
134 | return $this->client->call($this->api, 'get_transaction', [$trx_id]);
135 | } catch (\Exception $e) {
136 | return SteemHelper::handleError($e);
137 | }
138 | }
139 |
140 | /**
141 | * set get_required_signatures( const signed_transaction& trx, const flat_set& available_keys )const;
142 | * @param signed_transaction $trx
143 | * @param flat_set $availableKeys
144 | * @return array
145 | */
146 | public function getRequiredSignatures($trx, $availableKeys)
147 | {
148 | try {
149 | $this->api = $this->getApi('database_api');
150 | return $this->client->call($this->api, 'get_required_signatures', [$trx, $availableKeys]);
151 | } catch (\Exception $e) {
152 | return SteemHelper::handleError($e);
153 | }
154 | }
155 |
156 | /**
157 | * set get_potential_signatures( const signed_transaction& trx )const;
158 | * @param signed_transaction $trx
159 | * @return array
160 | */
161 | public function getPotentialSignatures($trx)
162 | {
163 | try {
164 | $this->api = $this->getApi('database_api');
165 | return $this->client->call($this->api, 'get_potential_signatures', [$trx]);
166 | } catch (\Exception $e) {
167 | return SteemHelper::handleError($e);
168 | }
169 | }
170 |
171 | /**
172 | * bool verify_authority( const signed_transaction& trx )const;
173 | * @param signed_transaction $trx
174 | * @return array on failure - boolean if successful
175 | */
176 | public function verifyAuthority($trx)
177 | {
178 | try {
179 | $this->api = $this->getApi('database_api');
180 | return $this->client->call($this->api, 'verify_authority', [$trx]);
181 | } catch (\Exception $e) {
182 | return SteemHelper::handleError($e);
183 | }
184 | }
185 |
186 | /**
187 | * bool verify_account_authority( const string& name_or_id, const flat_set& signers )const;
188 | * @param string $NameOrId
189 | * @param flat_set $singers
190 | * @return array on failure - boolean if successful
191 | */
192 | public function verifyAccountAuthority($NameOrId, $singers)
193 | {
194 | try {
195 | $this->api = $this->getApi('get_key_references');
196 | return $this->client->call($this->api, 'verify_account_authority', [$NameOrId, $singers]);
197 | } catch (\Exception $e) {
198 | return SteemHelper::handleError($e);
199 | }
200 | }
201 |
202 | /**
203 | * vector> get_key_references( vector key )const;
204 | * @param vector $key
205 | * @return array
206 | */
207 | public function getKeyReferences($key)
208 | {
209 | if (!is_array($key)) {
210 | $this->key[] = $key;
211 | } else {
212 | $this->key = $key;
213 | }
214 | try {
215 | $this->api = $this->getApi('account_by_key_api');
216 | return $this->client->call($this->api, 'get_key_references', [$this->key]);
217 | } catch (\Exception $e) {
218 | return SteemHelper::handleError($e);
219 | }
220 | }
221 |
222 | /**
223 | * @brief Broadcast a transaction to the network
224 | * @param trx The transaction to broadcast
225 | *
226 | * The transaction will be checked for validity in the local database prior to broadcasting. If it fails to
227 | * apply locally, an error will be thrown and the transaction will not be broadcast.
228 | *
229 | * void broadcast_transaction(const signed_transaction& trx);
230 | * @param string $trx
231 | * @return array
232 | */
233 | public function broadcastTransaction($trx)
234 | {
235 | try {
236 | $this->api = $this->getApi('network_broadcast_api');
237 | return $this->client->call($this->api, 'broadcast_transaction', [$trx]);
238 | } catch (\Exception $e) {
239 | return SteemHelper::handleError($e);
240 | }
241 | }
242 |
243 | /**
244 | * @brief Broadcast a transaction to the network
245 | * @param trx The transaction to broadcast
246 | *
247 | * The transaction will be checked for validity in the local database prior to broadcasting. If it fails to
248 | * apply locally, an error will be thrown and the transaction will not be broadcast.
249 | *
250 | * void broadcast_transaction(const signed_transaction& trx);
251 | * @param string $trx
252 | * @return array
253 | */
254 | public function broadcastTransactionSynchronous($trx)
255 | {
256 | try {
257 | $this->api = $this->getApi('network_broadcast_api');
258 | return $this->client->call($this->api, 'broadcast_transaction_synchronous', [$trx]);
259 | } catch (\Exception $e) {
260 | return SteemHelper::handleError($e);
261 | }
262 | }
263 |
264 | /**
265 | * void broadcast_block( const signed_block& block );
266 | * @param array $block
267 | * @return array
268 | * @failure array['instance'] = 'JsonRPC\Exception\ResponseException';
269 | */
270 | public function broadcastBlock($block)
271 | {
272 | try {
273 | $this->api = $this->getApi('network_broadcast_api');
274 | return $this->client->call($this->api, 'broadcast_block', [$block]);
275 | } catch (\Exception $e) {
276 | return SteemHelper::handleError($e);
277 | }
278 | }
279 |
280 | /**
281 | * void broadcast_block( const signed_block& block );
282 | * @param array $block
283 | * @return array
284 | */
285 | public function broadcastTransactionWithCallback($confirmationCallback, $trx)
286 | {
287 | try {
288 | $this->api = $this->getApi('network_broadcast_api');
289 | return $this->client->call($this->api, 'broadcast_transaction_with_callback', [$confirmationCallback, $trx]);
290 | } catch (\Exception $e) {
291 | return SteemHelper::handleError($e);
292 | }
293 | }
294 |
295 | // To be documented
296 | public function setMaxBlockAge($maxBlockAge)
297 | {
298 | try {
299 | $this->api = $this->getApi('network_broadcast_api');
300 | return $this->client->call($this->api, 'set_max_block_age', [$maxBlockAge]);
301 | } catch (\Exception $e) {
302 | return SteemHelper::handleError($e);
303 | }
304 | }
305 |
306 | // To be documented
307 | public function setSubscribeCallback($callBack, $clearFilter)
308 | {
309 | try {
310 | $this->api = $this->getApi('database_api');
311 | return $this->client->call($this->api, 'set_subscribe_callback', [$callBack, $clearFilter]);
312 | } catch (\Exception $e) {
313 | return SteemHelper::handleError($e);
314 | }
315 | }
316 |
317 | // To be documented
318 | public function setPendingTransactionCallback($cb)
319 | {
320 | try {
321 | $this->api = $this->getApi('database_api');
322 | return $this->client->call($this->api, 'set_pending_transaction_callback', [$cb]);
323 | } catch (\Exception $e) {
324 | return SteemHelper::handleError($e);
325 | }
326 | }
327 |
328 | // To be documented
329 | public function setBlockAppliedCallback($cb)
330 | {
331 | try {
332 | $this->api = $this->getApi('database_api');
333 | return $this->client->call($this->api, 'set_block_applied_callback', [$cb]);
334 | } catch (\Exception $e) {
335 | return SteemHelper::handleError($e);
336 | }
337 | }
338 |
339 | // To be documented
340 | public function cancelAllSubscriptions()
341 | {
342 | try {
343 | $this->api = $this->getApi('database_api');
344 | return $this->client->call($this->api, 'cancel_all_subscriptions', []);
345 | } catch (\Exception $e) {
346 | return SteemHelper::handleError($e);
347 | }
348 | }
349 |
350 | }
351 |
352 | ?>
--------------------------------------------------------------------------------
/src/SteemPHP/SteemHelper.php:
--------------------------------------------------------------------------------
1 | setTimeZone(new \DateTimeZone('UTC'));
62 | return $dt->format('Y-m-d\TH:i:s');
63 | }
64 |
65 | /**
66 | * Get the current time informat('Y-m-d\TH:i:s')
67 | *
68 | * @return date the current time
69 | */
70 | public static function now()
71 | {
72 | return (new \DateTime())->format('Y-m-d\TH:i:s');
73 | }
74 |
75 | /**
76 | * Steem Block expiration time should always be set 1 minute ahead of the current time
77 | *
78 | * @param date $now The current time
79 | * @param string $add The time to add
80 | *
81 | * @return date the current time
82 | *
83 | * To add Years use 'P1Y'
84 | * To add Months use 'P1M'
85 | * To add days use 'P1D'
86 | * To add hours use 'PT1H'
87 | * To add minutes use 'PT1M'
88 | * To add seconds use 'PT1S'
89 | */
90 | public static function BlockTime($now, $add)
91 | {
92 | $date = new \DateTime($now);
93 | $date->add(new \DateInterval(strtoupper($add)));
94 | return $date->format('Y-m-d\TH:i:s');
95 | }
96 |
97 | /**
98 | * calculated the reputation from the raw reputation
99 | *
100 | * @param integer $rep The rar reputation
101 | *
102 | * @return integer The repution
103 | */
104 | public static function reputation($rep)
105 | {
106 | if (is_null($rep) || !is_numeric($rep)) {
107 | return 0;
108 | } else {
109 | $e = $rep;
110 | $r = $e < 0 ? true : false;
111 | $e = $r ? substr($e, 1) : $e;
112 | $a = log10($e);
113 | $a = max($a - 9, 0);
114 | $a = ($r ? -1 : 1) * $a;
115 | $a = ($a * 9) + 25;
116 | return intval($a);
117 | }
118 | }
119 |
120 | /**
121 | * get estimated account value
122 | *
123 | * NOTE: this code is broken and only calculated the amount of money the user currently has
124 | * do not use until we fix it
125 | *
126 | * @param array $data The data
127 | * @param array $market The market
128 | * @param array $account The account
129 | *
130 | * @return array|null If correct data is not supplied will return null
131 | */
132 | public static function estimateAccountValue($data, $market, $account)
133 | {
134 | if (is_null($data) || !is_array($data)) {
135 | return null;
136 | } else {
137 | $props = $data['props'];
138 | $feed_price = $data['feed_price'];
139 | $savings_withdraws = $data['accounts'][$account]['savings_withdraw_requests'];
140 | $vesting_steem = $data['accounts'][$account]['reward_vesting_steem'];
141 | $assetPrecision = 1000;
142 | $open_orders = self::processOrders($market, $assetPrecision);
143 | $savings = self::calculateSaving($savings_withdraws);
144 | $price_per_steem = 0;
145 | $_feed_price = $feed_price;
146 | $base = $_feed_price['base'];
147 | $quote = $_feed_price['quote'];
148 | if (self::contains($base, "SBD") && self::contains($quote, "STEEM")) {
149 | $price_per_steem = floatval(explode(' ', $base)[0]);
150 | }
151 | $savings_balance = $data['accounts'][$account]['savings_balance'];
152 | $savings_sbd_balance = $data['accounts'][$account]['savings_sbd_balance'];
153 | $balance_steem = floatval(explode(' ', $data['accounts'][$account]['balance'])[0]);
154 | $saving_balance_steem = floatval(explode(' ', $savings_balance)[0]);
155 | $sbd_balance = floatval(explode(' ', $data['accounts'][$account]['sbd_balance'])[0]);
156 | $sbd_balance_savings = floatval(explode(' ', $data['accounts'][$account]['savings_sbd_balance'])[0]);
157 | $conversionValue = 0;
158 | $currentTime = time();
159 | foreach ($data['accounts'][$account]['other_history'] as $other_history_key => $other_history_value) {
160 | if ($other_history_value[1]["op"][0] == "convert") {
161 | $timestamp = strtotime($other_history_value[1]['timestamp']);
162 | $finishTime = $timestamp + 86400000 * 3.5; // 3.5 day convesion delay
163 | if ($finishTime > $currentTime) {
164 | $conversionValue += floatval(self::toInt($other_history_value[1]['op'][1]['amount']));
165 | }
166 | }
167 | }
168 | $total_sbd = self::toInt($sbd_balance) + self::toInt($sbd_balance_savings) + self::toInt($savings['savings_sbd_pending']) + self::toInt($open_orders['sbdOrders']) + self::toInt($conversionValue);
169 | $total_steem = self::toInt($vesting_steem) + self::toInt($balance_steem) + self::toInt($saving_balance_steem) + self::toInt($savings['savings_pending']) + self::toInt($open_orders['steemOrders']);
170 | return [number_format(($total_steem * $price_per_steem + $total_sbd), 2), $total_steem, $price_per_steem, $total_sbd];
171 | }
172 | }
173 |
174 | /**
175 | * Process the orders of the accoutn and return the total SBD and STEEM orders
176 | *
177 | * @param array $open_orders The open orders
178 | * @param integer $precision The precision
179 | *
180 | * @return array sbdOrders and steemOrders
181 | */
182 | public static function processOrders($open_orders, $precision)
183 | {
184 | $sbdOrders = 0;
185 | $steemOrders = 0;
186 | if (is_array($open_orders)) {
187 | foreach ($open_orders as $open_orders_key => $open_orders_value) {
188 | if (self::contains($open_orders_value['sell_price']['base'], "SBD")) {
189 | $sbdOrders += $open_orders_value['for_sale'] / $precision;
190 | } else if(self::contains($open_orders_value['sell_price']['base'], "STEEM")) {
191 | $steemOrders += $open_orders_value['for_sale'] / $precision;
192 | }
193 | }
194 | }
195 | return ['sbdOrders' => $sbdOrders, 'steemOrders' => $steemOrders];
196 | }
197 |
198 | /**
199 | * Calculate the toal SBD and STEEM saving of the account
200 | *
201 | * @param array $savings_withdraws The savings withdraws
202 | *
203 | * @return array The saving.
204 | */
205 | public static function calculateSaving($savings_withdraws)
206 | {
207 | $savings_pending = 0;
208 | $savings_sbd_pending = 0;
209 | if (is_array($savings_withdraws)) {
210 | foreach ($savings_withdraws as $savings_withdraws_key => $savings_withdraws_value) {
211 | $_withdraw_amount_split = explode(' ', $savings_withdraws_value['amount']);
212 | $amount = $_withdraw_amount_split[0];
213 | $asset = $_withdraw_amount_split[1];
214 | if ($asset == "STEEM") {
215 | $savings_pending += floatval($amount);
216 | } else if ($asset == "SBD") {
217 | $savings_sbd_pending += floatval($amount);
218 | }
219 | }
220 | }
221 | return ['savings_pending' => $savings_pending, 'savings_sbd_pending' => $savings_sbd_pending];
222 | }
223 |
224 | /**
225 | * Find the amount of steem the vests are worth
226 | *
227 | * @param integer $vestingShares The vesting shares
228 | * @param integer $totalVestingFundSteem The total vesting fund steem
229 | * @param integer $totalVestingShares The total vesting shares
230 | *
231 | * @return integer The amount of steem worth
232 | */
233 | public static function vestToSteem($vestingShares, $totalVestingFundSteem, $totalVestingShares)
234 | {
235 | return floatval($totalVestingFundSteem) * floatval($vestingShares) / floatval($totalVestingShares);
236 | }
237 |
238 | /**
239 | * Checks if the $contains is found in the $data
240 | *
241 | * @param string $data The data
242 | * @param string $contains The char that it contains
243 | *
244 | * @return integer 1 if contains, 0 otherwise
245 | */
246 | public static function contains($data, $contains)
247 | {
248 | return preg_match('/('.$contains.')/', $data);
249 | }
250 |
251 | /**
252 | * Get the character at the position $pos
253 | *
254 | * @param string $string The string
255 | * @param integer $pos The position
256 | *
257 | * @return string The character at that position
258 | */
259 | public static function charAt($string, $pos)
260 | {
261 | return $string{$pos};
262 | }
263 |
264 | /**
265 | * Handle exceptions thrown while running the script
266 | *
267 | * @param Exception $e The exception that is catched
268 | *
269 | * @return array details of the exception
270 | */
271 | public static function handleError($e)
272 | {
273 | if (!is_object($e)) {
274 | return [];
275 | } else {
276 | $instance = 'Exception';
277 | if ($e instanceof \JsonRPC\Exception\ResponseException) {
278 | $instance = 'JsonRPC\Exception\ResponseException';
279 | } else if ($e instanceof \JsonRPC\Exception\ConnectionFailureException) {
280 | $instance = 'JsonRPC\Exception\ConnectionFailureException';
281 | } else if ($e instanceof \JsonRPC\Exception\InvalidJsonFormatException) {
282 | $instance = 'JsonRPC\Exception\InvalidJsonFormatException';
283 | } else if ($e instanceof \JsonRPC\Exception\ServerErrorException) {
284 | $instance = 'JsonRPC\Exception\ServerErrorException';
285 | } else if ($e instanceof \JsonRPC\Exception\ResponseEncodingFailureException) {
286 | $instance = 'JsonRPC\Exception\ResponseEncodingFailureException';
287 | }
288 | return ['instance' => $instance,
289 | 'message' => $e->getMessage(),
290 | 'file' => $e->getFile(),
291 | 'line' => $e->getLine(),
292 | 'trace' => $e->getTrace()];
293 | }
294 | }
295 |
296 | /**
297 | * PHP port of JavaScript String slice() method
298 | * from https://gist.github.com/janogarcia/743209
299 | *
300 | * @param string $str The string
301 | * @param integer $start The start
302 | * @param integer $end The end (optional)
303 | *
304 | * @return string The sliced data
305 | */
306 | public static function str_slice($str, $start, $end = FALSE)
307 | {
308 | $max = strlen($str);
309 | $start = ($start < 0) ? $max + $start : $start;
310 | $end = ($end < 0) ? $max + $end : (($end === FALSE) ? $max : $end);
311 | $slice = substr($str, $start, ($end > $start) ? $end - $start : 0);
312 | return ($slice === FALSE) ? '' : $slice;
313 | }
314 |
315 | /**
316 | * PHP port of JavaScript String slice() method taken from BitWasp\Bitcoin
317 | *
318 | * @param array $array The array
319 | * @param integer $start The start
320 | * @param integer $length The length
321 | *
322 | * @return array error on failue, result on success
323 | */
324 | public static function slice($array, $start, $length)
325 | {
326 | $end = count($array);
327 | if ($start > $end || $length > $end) {
328 | return ['error' => 'Invalid start or length'];
329 | } else {
330 | return ['result' => array_slice($array, $start, $length)];
331 | }
332 | }
333 |
334 | }
335 |
336 |
337 | ?>
--------------------------------------------------------------------------------
/src/SteemPHP/SteemConfig.php:
--------------------------------------------------------------------------------
1 | >16
170 | /** NOTE: making this a power of 2 (say 2^15) would greatly accelerate fee calcs */
171 | const STEEMIT_MAX_AUTHORITY_MEMBERSHIP = 10;
172 | const STEEMIT_MAX_ASSET_WHITELIST_AUTHORITIES = 10;
173 | const STEEMIT_MAX_URL_LENGTH = 127;
174 | const STEEMIT_IRREVERSIBLE_THRESHOLD = 75 * self::STEEMIT_1_PERCENT;
175 | // VIRTUAL_SCHEDULE_LAP_LENGTH and VIRTUAL_SCHEDULE_LAP_LENGTH2 has to be compiled
176 | // with fc inorder to get a value
177 | const VIRTUAL_SCHEDULE_LAP_LENGTH = null; // fc::uint128(uint64_t(-1))
178 | const VIRTUAL_SCHEDULE_LAP_LENGTH2 = null; // fc::uint128::max_value()
179 | /**
180 | * Reserved Account IDs with special meaning
181 | */
182 | //@{
183 | // Represents the current witnesses
184 | const STEEMIT_MINER_ACCOUNT = "miners";
185 | // Represents the canonical account with NO authority (nobody can access funds in null account)
186 | const STEEMIT_NULL_ACCOUNT = "null";
187 | // Represents the canonical account with WILDCARD authority (anybody can access funds in temp account)
188 | const STEEMIT_TEMP_ACCOUNT = "temp";
189 | // Represents the canonical account for specifying you will vote for directly (as opposed to a proxy)
190 | const STEEMIT_PROXY_TO_SELF_ACCOUNT = "";
191 | // Represents the canonical root post parent account
192 | //const STEEMIT_ROOT_POST_PARENT = (account_name_type())
193 | //@}
194 |
195 | }
196 |
197 | ?>
--------------------------------------------------------------------------------
/tests/SteemConfigTest.php:
--------------------------------------------------------------------------------
1 | assertEquals('0.19.1', \SteemPHP\SteemConfig::STEEMIT_BLOCKCHAIN_VERSION);
11 | $this->assertEquals('0.19.1', \SteemPHP\SteemConfig::STEEMIT_BLOCKCHAIN_HARDFORK_VERSION);
12 | $this->assertEquals('STM8GC13uCZbP44HzMLV6zPZGwVQ8Nt4Kji8PapsPiNq1BK153XTX', \SteemPHP\SteemConfig::STEEMIT_INIT_PUBLIC_KEY_STR);
13 | $this->assertEquals('0', \SteemPHP\SteemConfig::STEEMIT_CHAIN_ID);
14 | $this->assertEquals('VESTS', \SteemPHP\SteemConfig::VESTS_SYMBOL);
15 | $this->assertEquals('STEEM', \SteemPHP\SteemConfig::STEEM_SYMBOL);
16 | $this->assertEquals('SBD', \SteemPHP\SteemConfig::SBD_SYMBOL);
17 | $this->assertEquals('STMD', \SteemPHP\SteemConfig::STMD_SYMBOL);
18 | $this->assertEquals('STEEM', \SteemPHP\SteemConfig::STEEMIT_SYMBOL);
19 | $this->assertEquals('STM', \SteemPHP\SteemConfig::STEEMIT_ADDRESS_PREFIX);
20 | $this->assertEquals('1458835200', \SteemPHP\SteemConfig::STEEMIT_GENESIS_TIME);
21 | $this->assertEquals('1458838800', \SteemPHP\SteemConfig::STEEMIT_MINING_TIME);
22 | $this->assertEquals('86400', \SteemPHP\SteemConfig::STEEMIT_CASHOUT_WINDOW_SECONDS_PRE_HF12);
23 | $this->assertEquals('43200', \SteemPHP\SteemConfig::STEEMIT_CASHOUT_WINDOW_SECONDS_PRE_HF17);
24 | $this->assertEquals('604800', \SteemPHP\SteemConfig::STEEMIT_CASHOUT_WINDOW_SECONDS);
25 | $this->assertEquals('2592000', \SteemPHP\SteemConfig::STEEMIT_SECOND_CASHOUT_WINDOW);
26 | $this->assertEquals('1209600', \SteemPHP\SteemConfig::STEEMIT_MAX_CASHOUT_WINDOW_SECONDS);
27 | $this->assertEquals('7200', \SteemPHP\SteemConfig::STEEMIT_VOTE_CHANGE_LOCKOUT_PERIOD);
28 | $this->assertEquals('60', \SteemPHP\SteemConfig::STEEMIT_UPVOTE_LOCKOUT_HF7);
29 | $this->assertEquals('43200', \SteemPHP\SteemConfig::STEEMIT_UPVOTE_LOCKOUT_HF17);
30 | $this->assertEquals('100000', \SteemPHP\SteemConfig::STEEMIT_ORIGINAL_MIN_ACCOUNT_CREATION_FEE);
31 | $this->assertEquals('1', \SteemPHP\SteemConfig::STEEMIT_MIN_ACCOUNT_CREATION_FEE);
32 | $this->assertEquals('2592000', \SteemPHP\SteemConfig::STEEMIT_OWNER_AUTH_RECOVERY_PERIOD);
33 | $this->assertEquals('86400', \SteemPHP\SteemConfig::STEEMIT_ACCOUNT_RECOVERY_REQUEST_EXPIRATION_PERIOD);
34 | $this->assertEquals('3600', \SteemPHP\SteemConfig::STEEMIT_OWNER_UPDATE_LIMIT);
35 | $this->assertEquals('3186477', \SteemPHP\SteemConfig::STEEMIT_OWNER_AUTH_HISTORY_TRACKING_START_BLOCK_NUM);
36 | $this->assertEquals('3', \SteemPHP\SteemConfig::STEEMIT_BLOCK_INTERVAL);
37 | $this->assertEquals('10512000', \SteemPHP\SteemConfig::STEEMIT_BLOCKS_PER_YEAR);
38 | $this->assertEquals('28800', \SteemPHP\SteemConfig::STEEMIT_BLOCKS_PER_DAY);
39 | $this->assertEquals('201600', \SteemPHP\SteemConfig::STEEMIT_START_VESTING_BLOCK);
40 | $this->assertEquals('864000', \SteemPHP\SteemConfig::STEEMIT_START_MINER_VOTING_BLOCK);
41 | $this->assertEquals('initminer', \SteemPHP\SteemConfig::STEEMIT_INIT_MINER_NAME);
42 | $this->assertEquals('1', \SteemPHP\SteemConfig::STEEMIT_NUM_INIT_MINERS);
43 | $this->assertEquals('0', \SteemPHP\SteemConfig::STEEMIT_INIT_TIME);
44 | $this->assertEquals('21', \SteemPHP\SteemConfig::STEEMIT_MAX_WITNESSES);
45 | $this->assertEquals('19', \SteemPHP\SteemConfig::STEEMIT_MAX_VOTED_WITNESSES_HF0);
46 | $this->assertEquals('1', \SteemPHP\SteemConfig::STEEMIT_MAX_MINER_WITNESSES_HF0);
47 | $this->assertEquals('1', \SteemPHP\SteemConfig::STEEMIT_MAX_RUNNER_WITNESSES_HF0);
48 | $this->assertEquals('20', \SteemPHP\SteemConfig::STEEMIT_MAX_VOTED_WITNESSES_HF17);
49 | $this->assertEquals('0', \SteemPHP\SteemConfig::STEEMIT_MAX_MINER_WITNESSES_HF17);
50 | $this->assertEquals('1', \SteemPHP\SteemConfig::STEEMIT_MAX_RUNNER_WITNESSES_HF17);
51 | $this->assertEquals('17', \SteemPHP\SteemConfig::STEEMIT_HARDFORK_REQUIRED_WITNESSES);
52 | $this->assertEquals('3600', \SteemPHP\SteemConfig::STEEMIT_MAX_TIME_UNTIL_EXPIRATION);
53 | $this->assertEquals('2048', \SteemPHP\SteemConfig::STEEMIT_MAX_MEMO_SIZE);
54 | $this->assertEquals('4', \SteemPHP\SteemConfig::STEEMIT_MAX_PROXY_RECURSION_DEPTH);
55 | $this->assertEquals('104', \SteemPHP\SteemConfig::STEEMIT_VESTING_WITHDRAW_INTERVALS_PRE_HF_16);
56 | $this->assertEquals('13', \SteemPHP\SteemConfig::STEEMIT_VESTING_WITHDRAW_INTERVALS);
57 | $this->assertEquals('604800', \SteemPHP\SteemConfig::STEEMIT_VESTING_WITHDRAW_INTERVAL_SECONDS);
58 | $this->assertEquals('10', \SteemPHP\SteemConfig::STEEMIT_MAX_WITHDRAW_ROUTES);
59 | $this->assertEquals('259200', \SteemPHP\SteemConfig::STEEMIT_SAVINGS_WITHDRAW_TIME);
60 | $this->assertEquals('100', \SteemPHP\SteemConfig::STEEMIT_SAVINGS_WITHDRAW_REQUEST_LIMIT);
61 | $this->assertEquals('432000', \SteemPHP\SteemConfig::STEEMIT_VOTE_REGENERATION_SECONDS);
62 | $this->assertEquals('5', \SteemPHP\SteemConfig::STEEMIT_MAX_VOTE_CHANGES);
63 | $this->assertEquals('1800', \SteemPHP\SteemConfig::STEEMIT_REVERSE_AUCTION_WINDOW_SECONDS);
64 | $this->assertEquals('3', \SteemPHP\SteemConfig::STEEMIT_MIN_VOTE_INTERVAL_SEC);
65 | $this->assertEquals('50000000', \SteemPHP\SteemConfig::STEEMIT_VOTE_DUST_THRESHOLD);
66 | $this->assertEquals('300', \SteemPHP\SteemConfig::STEEMIT_MIN_ROOT_COMMENT_INTERVAL);
67 | $this->assertEquals('20', \SteemPHP\SteemConfig::STEEMIT_MIN_REPLY_INTERVAL);
68 | $this->assertEquals('86400', \SteemPHP\SteemConfig::STEEMIT_POST_AVERAGE_WINDOW);
69 | $this->assertEquals('40000', \SteemPHP\SteemConfig::STEEMIT_POST_MAX_BANDWIDTH);
70 | $this->assertEquals('1600000000', \SteemPHP\SteemConfig::STEEMIT_POST_WEIGHT_CONSTANT);
71 | $this->assertEquals('30', \SteemPHP\SteemConfig::STEEMIT_MAX_ACCOUNT_WITNESS_VOTES);
72 | $this->assertEquals('10000', \SteemPHP\SteemConfig::STEEMIT_100_PERCENT);
73 | $this->assertEquals('100', \SteemPHP\SteemConfig::STEEMIT_1_PERCENT);
74 | $this->assertEquals('10', \SteemPHP\SteemConfig::STEEMIT_1_TENTH_PERCENT);
75 | $this->assertEquals('1000', \SteemPHP\SteemConfig::STEEMIT_DEFAULT_SBD_INTEREST_RATE);
76 | $this->assertEquals('978', \SteemPHP\SteemConfig::STEEMIT_INFLATION_RATE_START_PERCENT);
77 | $this->assertEquals('95', \SteemPHP\SteemConfig::STEEMIT_INFLATION_RATE_STOP_PERCENT);
78 | $this->assertEquals('250000', \SteemPHP\SteemConfig::STEEMIT_INFLATION_NARROWING_PERIOD);
79 | $this->assertEquals('7500', \SteemPHP\SteemConfig::STEEMIT_CONTENT_REWARD_PERCENT);
80 | $this->assertEquals('1500', \SteemPHP\SteemConfig::STEEMIT_VESTING_FUND_PERCENT);
81 | $this->assertEquals('100', \SteemPHP\SteemConfig::STEEMIT_MINER_PAY_PERCENT);
82 | $this->assertEquals('100000', \SteemPHP\SteemConfig::STEEMIT_MIN_RATION);
83 | $this->assertEquals('1000000', \SteemPHP\SteemConfig::STEEMIT_MAX_RATION_DECAY_RATE);
84 | $this->assertEquals('100', \SteemPHP\SteemConfig::STEEMIT_FREE_TRANSACTIONS_WITH_NEW_ACCOUNT);
85 | $this->assertEquals('604800', \SteemPHP\SteemConfig::STEEMIT_BANDWIDTH_AVERAGE_WINDOW_SECONDS);
86 | $this->assertEquals('1000000', \SteemPHP\SteemConfig::STEEMIT_BANDWIDTH_PRECISION);
87 | $this->assertEquals('6', \SteemPHP\SteemConfig::STEEMIT_MAX_COMMENT_DEPTH_PRE_HF17);
88 | $this->assertEquals('65535', \SteemPHP\SteemConfig::STEEMIT_MAX_COMMENT_DEPTH);
89 | $this->assertEquals('255', \SteemPHP\SteemConfig::STEEMIT_SOFT_MAX_COMMENT_DEPTH);
90 | $this->assertEquals('20000', \SteemPHP\SteemConfig::STEEMIT_MAX_RESERVE_RATIO);
91 | $this->assertEquals('30', \SteemPHP\SteemConfig::STEEMIT_CREATE_ACCOUNT_WITH_STEEM_MODIFIER);
92 | $this->assertEquals('5', \SteemPHP\SteemConfig::STEEMIT_CREATE_ACCOUNT_DELEGATION_RATIO);
93 | $this->assertEquals('2592000', \SteemPHP\SteemConfig::STEEMIT_CREATE_ACCOUNT_DELEGATION_TIME);
94 | $this->assertEquals('1 STEEM', \SteemPHP\SteemConfig::STEEMIT_MINING_REWARD);
95 | $this->assertEquals('140', \SteemPHP\SteemConfig::STEEMIT_EQUIHASH_N);
96 | $this->assertEquals('6', \SteemPHP\SteemConfig::STEEMIT_EQUIHASH_K);
97 | $this->assertEquals('604800', \SteemPHP\SteemConfig::STEEMIT_LIQUIDITY_TIMEOUT_SEC);
98 | $this->assertEquals('60', \SteemPHP\SteemConfig::STEEMIT_MIN_LIQUIDITY_REWARD_PERIOD_SEC);
99 | $this->assertEquals('3600', \SteemPHP\SteemConfig::STEEMIT_LIQUIDITY_REWARD_PERIOD_SEC);
100 | $this->assertEquals('1200', \SteemPHP\SteemConfig::STEEMIT_LIQUIDITY_REWARD_BLOCKS);
101 | $this->assertEquals('1200 STEEM', \SteemPHP\SteemConfig::STEEMIT_MIN_LIQUIDITY_REWARD);
102 | $this->assertEquals('1 STEEM', \SteemPHP\SteemConfig::STEEMIT_MIN_CONTENT_REWARD);
103 | $this->assertEquals('1 STEEM', \SteemPHP\SteemConfig::STEEMIT_MIN_CURATE_REWARD);
104 | $this->assertEquals('1 STEEM', \SteemPHP\SteemConfig::STEEMIT_MIN_PRODUCER_REWARD);
105 | $this->assertEquals('1 STEEM', \SteemPHP\SteemConfig::STEEMIT_MIN_POW_REWARD);
106 | $this->assertEquals('2 STEEM', \SteemPHP\SteemConfig::STEEMIT_ACTIVE_CHALLENGE_FEE);
107 | $this->assertEquals('30 STEEM', \SteemPHP\SteemConfig::STEEMIT_OWNER_CHALLENGE_FEE);
108 | $this->assertEquals('86400', \SteemPHP\SteemConfig::STEEMIT_ACTIVE_CHALLENGE_COOLDOWN);
109 | $this->assertEquals('86400', \SteemPHP\SteemConfig::STEEMIT_OWNER_CHALLENGE_COOLDOWN);
110 | $this->assertEquals('post', \SteemPHP\SteemConfig::STEEMIT_POST_REWARD_FUND_NAME);
111 | $this->assertEquals('comment', \SteemPHP\SteemConfig::STEEMIT_COMMENT_REWARD_FUND_NAME);
112 | $this->assertEquals('2592000', \SteemPHP\SteemConfig::STEEMIT_RECENT_RSHARES_DECAY_RATE_HF17);
113 | $this->assertEquals('1296000', \SteemPHP\SteemConfig::STEEMIT_RECENT_RSHARES_DECAY_RATE_HF19);
114 | $this->assertEquals('2000000000000', \SteemPHP\SteemConfig::STEEMIT_CONTENT_CONSTANT_HF0);
115 | $this->assertEquals('102035135585887', \SteemPHP\SteemConfig::STEEMIT_APR_PERCENT_MULTIPLY_PER_BLOCK);
116 | $this->assertEquals('87', \SteemPHP\SteemConfig::STEEMIT_APR_PERCENT_SHIFT_PER_BLOCK);
117 | $this->assertEquals('133921203762304', \SteemPHP\SteemConfig::STEEMIT_APR_PERCENT_MULTIPLY_PER_ROUND);
118 | $this->assertEquals('83', \SteemPHP\SteemConfig::STEEMIT_APR_PERCENT_SHIFT_PER_ROUND);
119 | $this->assertEquals('119577151364285', \SteemPHP\SteemConfig::STEEMIT_APR_PERCENT_MULTIPLY_PER_HOUR);
120 | $this->assertEquals('77', \SteemPHP\SteemConfig::STEEMIT_APR_PERCENT_SHIFT_PER_HOUR);
121 | $this->assertEquals('3875', \SteemPHP\SteemConfig::STEEMIT_CURATE_APR_PERCENT);
122 | $this->assertEquals('3875', \SteemPHP\SteemConfig::STEEMIT_CONTENT_APR_PERCENT);
123 | $this->assertEquals('750', \SteemPHP\SteemConfig::STEEMIT_LIQUIDITY_APR_PERCENT);
124 | $this->assertEquals('750', \SteemPHP\SteemConfig::STEEMIT_PRODUCER_APR_PERCENT);
125 | $this->assertEquals('750', \SteemPHP\SteemConfig::STEEMIT_POW_APR_PERCENT);
126 | $this->assertEquals('0.02 SBD', \SteemPHP\SteemConfig::STEEMIT_MIN_PAYOUT_SBD);
127 | $this->assertEquals('500', \SteemPHP\SteemConfig::STEEMIT_SBD_STOP_PERCENT);
128 | $this->assertEquals('200', \SteemPHP\SteemConfig::STEEMIT_SBD_START_PERCENT);
129 | $this->assertEquals('3', \SteemPHP\SteemConfig::STEEMIT_MIN_ACCOUNT_NAME_LENGTH);
130 | $this->assertEquals('16', \SteemPHP\SteemConfig::STEEMIT_MAX_ACCOUNT_NAME_LENGTH);
131 | $this->assertEquals('0', \SteemPHP\SteemConfig::STEEMIT_MIN_PERMLINK_LENGTH);
132 | $this->assertEquals('256', \SteemPHP\SteemConfig::STEEMIT_MAX_PERMLINK_LENGTH);
133 | $this->assertEquals('2048', \SteemPHP\SteemConfig::STEEMIT_MAX_WITNESS_URL_LENGTH);
134 | $this->assertEquals('0', \SteemPHP\SteemConfig::STEEMIT_INIT_SUPPLY);
135 | $this->assertEquals('1000000000000000', \SteemPHP\SteemConfig::STEEMIT_MAX_SHARE_SUPPLY);
136 | $this->assertEquals('2', \SteemPHP\SteemConfig::STEEMIT_MAX_SIG_CHECK_DEPTH);
137 | $this->assertEquals('1024', \SteemPHP\SteemConfig::STEEMIT_MIN_TRANSACTION_SIZE_LIMIT);
138 | $this->assertEquals('31536000', \SteemPHP\SteemConfig::STEEMIT_SECONDS_PER_YEAR);
139 | $this->assertEquals('2592000', \SteemPHP\SteemConfig::STEEMIT_SBD_INTEREST_COMPOUND_INTERVAL_SEC);
140 | $this->assertEquals('65536', \SteemPHP\SteemConfig::STEEMIT_MAX_TRANSACTION_SIZE);
141 | $this->assertEquals('65536', \SteemPHP\SteemConfig::STEEMIT_MIN_BLOCK_SIZE_LIMIT);
142 | $this->assertEquals('393216000', \SteemPHP\SteemConfig::STEEMIT_MAX_BLOCK_SIZE);
143 | $this->assertEquals('1200', \SteemPHP\SteemConfig::STEEMIT_BLOCKS_PER_HOUR);
144 | $this->assertEquals('1200', \SteemPHP\SteemConfig::STEEMIT_FEED_INTERVAL_BLOCKS);
145 | $this->assertEquals('168', \SteemPHP\SteemConfig::STEEMIT_FEED_HISTORY_WINDOW_PRE_HF_16);
146 | $this->assertEquals('84', \SteemPHP\SteemConfig::STEEMIT_FEED_HISTORY_WINDOW);
147 | $this->assertEquals('604800', \SteemPHP\SteemConfig::STEEMIT_MAX_FEED_AGE_SECONDS);
148 | $this->assertEquals('7', \SteemPHP\SteemConfig::STEEMIT_MIN_FEEDS);
149 | $this->assertEquals('604800', \SteemPHP\SteemConfig::STEEMIT_CONVERSION_DELAY_PRE_HF_16);
150 | $this->assertEquals('5040', \SteemPHP\SteemConfig::STEEMIT_CONVERSION_DELAY);
151 | $this->assertEquals('10', \SteemPHP\SteemConfig::STEEMIT_MIN_UNDO_HISTORY);
152 | $this->assertEquals('10000', \SteemPHP\SteemConfig::STEEMIT_MAX_UNDO_HISTORY);
153 | $this->assertEquals('15', \SteemPHP\SteemConfig::STEEMIT_MIN_TRANSACTION_EXPIRATION_LIMIT);
154 | $this->assertEquals('1000', \SteemPHP\SteemConfig::STEEMIT_BLOCKCHAIN_PRECISION);
155 | $this->assertEquals('3', \SteemPHP\SteemConfig::STEEMIT_BLOCKCHAIN_PRECISION_DIGITS);
156 | $this->assertEquals('281474976710655', \SteemPHP\SteemConfig::STEEMIT_MAX_INSTANCE_ID);
157 | $this->assertEquals('10', \SteemPHP\SteemConfig::STEEMIT_MAX_AUTHORITY_MEMBERSHIP);
158 | $this->assertEquals('10', \SteemPHP\SteemConfig::STEEMIT_MAX_ASSET_WHITELIST_AUTHORITIES);
159 | $this->assertEquals('127', \SteemPHP\SteemConfig::STEEMIT_MAX_URL_LENGTH);
160 | $this->assertEquals('7500', \SteemPHP\SteemConfig::STEEMIT_IRREVERSIBLE_THRESHOLD);
161 | $this->assertEquals('', \SteemPHP\SteemConfig::VIRTUAL_SCHEDULE_LAP_LENGTH);
162 | $this->assertEquals('', \SteemPHP\SteemConfig::VIRTUAL_SCHEDULE_LAP_LENGTH2);
163 | $this->assertEquals('miners', \SteemPHP\SteemConfig::STEEMIT_MINER_ACCOUNT);
164 | $this->assertEquals('null', \SteemPHP\SteemConfig::STEEMIT_NULL_ACCOUNT);
165 | $this->assertEquals('temp', \SteemPHP\SteemConfig::STEEMIT_TEMP_ACCOUNT);
166 | $this->assertEquals('', \SteemPHP\SteemConfig::STEEMIT_PROXY_TO_SELF_ACCOUNT);
167 | }
168 |
169 | }
170 |
171 | ?>
--------------------------------------------------------------------------------
/src/SteemPHP/SteemArticle.php:
--------------------------------------------------------------------------------
1 | host = trim($host);
39 | $this->httpClient = new HttpClient($this->host);
40 | $this->httpClient->withoutSslVerification();
41 | $this->client = new Client($this->host, false, $this->httpClient);
42 | }
43 |
44 | /**
45 | * Gets the api number by api $name
46 | *
47 | * @param sting $name The name of the api
48 | *
49 | * @return integer The api number
50 | */
51 | public function getApi($name)
52 | {
53 | try{
54 | return $this->client->call(1, 'get_api_by_name', [$name]);
55 | } catch (\Exception $e) {
56 | return SteemHelper::handleError($e);
57 | }
58 | }
59 |
60 | /**
61 | * Gets the list of trending tags after $afterTag.
62 | *
63 | * @param string $afterTag The after tag
64 | * @param integer $limit The limit
65 | *
66 | * @return array The trending tags.
67 | */
68 | public function getTrendingTags($afterTag, $limit = 100)
69 | {
70 | try {
71 | $this->api = $this->getApi('database_api');
72 | return $this->client->call($this->api, 'get_trending_tags', [$afterTag, SteemHelper::filterInt($limit)]);
73 | } catch (\Exception $e) {
74 | return SteemHelper::handleError($e);
75 | }
76 | }
77 |
78 | /**
79 | * Gets the content of an article.
80 | *
81 | * @param string $author The author
82 | * @param string $permlink The permlink
83 | *
84 | * @return array The content.
85 | */
86 | public function getContent($author, $permlink)
87 | {
88 | try {
89 | $this->api = $this->getApi('database_api');
90 | return $this->client->call($this->api, 'get_content', [$author, $permlink]);
91 | } catch (\Exception $e) {
92 | return SteemHelper::handleError($e);
93 | }
94 | }
95 |
96 | /**
97 | * Gets the content replies.
98 | *
99 | * @param string $author The author
100 | * @param string $permlink The permlink
101 | *
102 | * @return array The content replies.
103 | */
104 | public function getContentReplies($author, $permlink)
105 | {
106 | try {
107 | $this->api = $this->getApi('database_api');
108 | return $this->client->call($this->api, 'get_content_replies', [$author, $permlink]);
109 | } catch (\Exception $e) {
110 | return SteemHelper::handleError($e);
111 | }
112 | }
113 |
114 | /**
115 | * Gets the list of trending articles (content/votes/replies) posted under the $tag.
116 | * Start author and start permlink are for pagination.
117 | *
118 | * @param string $tag The tag
119 | * @param integer $limit The limit
120 | * @param string $startAuthor The start author
121 | * @param string $startPermlink The start permlink
122 | *
123 | * @return array The list of trending articles.
124 | */
125 | public function getDiscussionsByTrending($tag, $limit = 100, $startAuthor = null, $startPermlink = null)
126 | {
127 | try {
128 | $this->api = $this->getApi('database_api');
129 | $query = ['tag' => $tag, 'limit' => SteemHelper::filterInt($limit), 'start_author' => $startAuthor, 'start_permlink' => $startPermlink];
130 | return $this->client->call($this->api, 'get_discussions_by_trending', [$query]);
131 | } catch (\Exception $e) {
132 | return SteemHelper::handleError($e);
133 | }
134 | }
135 |
136 | /**
137 | * Gets the list of articles created under the $tag
138 | * Start author and start permlink are for pagination.
139 | *
140 | * @param string $tag The tag
141 | * @param integer $limit The limit
142 | * @param string $startAuthor The start author
143 | * @param string $startPermlink The start permlink
144 | *
145 | * @return array The list of articles.
146 | */
147 | public function getDiscussionsByCreated($tag, $limit = 100, $startAuthor = null, $startPermlink = null)
148 | {
149 | try {
150 | $this->api = $this->getApi('database_api');
151 | $query = ['tag' => $tag, 'limit' => SteemHelper::filterInt($limit), 'start_author' => $startAuthor, 'start_permlink' => $startPermlink];
152 | return $this->client->call($this->api, 'get_discussions_by_created', [$query]);
153 | } catch (\Exception $e) {
154 | return SteemHelper::handleError($e);
155 | }
156 | }
157 |
158 | /**
159 | * Gets the list of active articles under the $tag
160 | * active article: an article that has just recieved an upvote/comment/reblog
161 | * Start author and start permlink are for pagination
162 | *
163 | * @param string $tag The tag
164 | * @param integer $limit The limit
165 | * @param string $startAuthor The start author
166 | * @param string $startPermlink The start permlink
167 | *
168 | * @return array The list of active articles.
169 | */
170 | public function getDiscussionsByActive($tag, $limit = 100, $startAuthor = null, $startPermlink = null)
171 | {
172 | try {
173 | $this->api = $this->getApi('database_api');
174 | $query = ['tag' => $tag, 'limit' => SteemHelper::filterInt($limit), 'start_author' => $startAuthor, 'start_permlink' => $startPermlink];
175 | return $this->client->call($this->api, 'get_discussions_by_active', [$query]);
176 | } catch (\Exception $e) {
177 | return SteemHelper::handleError($e);
178 | }
179 | }
180 |
181 | /**
182 | * Gets the list of articles which are promoted under the tag $tag
183 | * Start author and start permlink are for pagination
184 | *
185 | * @param string $tag The tag
186 | * @param integer $limit The limit
187 | * @param string $startAuthor The start author
188 | * @param string $startPermlink The start permlink
189 | *
190 | * @return array The list of promoted articles
191 | */
192 | public function getDiscussionsByPromoted($tag, $limit = 100, $startAuthor = null, $startPermlink = null)
193 | {
194 | try {
195 | $this->api = $this->getApi('database_api');
196 | $query = ['tag' => $tag, 'limit' => SteemHelper::filterInt($limit), 'start_author' => $startAuthor, 'start_permlink' => $startPermlink];
197 | return $this->client->call($this->api, 'get_discussions_by_promoted', [$query]);
198 | } catch (\Exception $e) {
199 | return SteemHelper::handleError($e);
200 | }
201 | }
202 |
203 | /**
204 | * Gets the list of articles where the rewards will be payed in less than 12 hour.
205 | * Start author and start permlink are for pagination.
206 | *
207 | * @param string $tag The tag
208 | * @param integer $limit The limit
209 | * @param string $startAuthor The start author
210 | * @param string $startPermlink The start permlink
211 | *
212 | * @return array The list of articles by cashout.
213 | */
214 | public function getDiscussionsByCashout($tag, $limit = 100, $startAuthor = null, $startPermlink = null)
215 | {
216 | try {
217 | $this->api = $this->getApi('database_api');
218 | $query = ['tag' => $tag, 'limit' => SteemHelper::filterInt($limit), 'start_author' => $startAuthor, 'start_permlink' => $startPermlink];
219 | return $this->client->call($this->api, 'get_discussions_by_cashout', [$query]);
220 | } catch (\Exception $e) {
221 | return SteemHelper::handleError($e);
222 | }
223 | }
224 |
225 | /**
226 | * Gets the list of articles which have the highest payout under the $tag.
227 | * Start author and start permlink are for pagination.
228 | *
229 | * @param string $tag The tag
230 | * @param integer $limit The limit
231 | * @param string $startAuthor The start author
232 | * @param string $startPermlink The start permlink
233 | *
234 | * @return array The list of articles by payout.
235 | */
236 | public function getDiscussionsByPayout($tag, $limit = 100, $startAuthor = null, $startPermlink = null)
237 | {
238 | try {
239 | $this->api = $this->getApi('database_api');
240 | $query = ['tag' => $tag, 'limit' => SteemHelper::filterInt($limit), 'start_author' => $startAuthor, 'start_permlink' => $startPermlink];
241 | return $this->client->call($this->api, 'get_discussions_by_payout', [$query]);
242 | } catch (\Exception $e) {
243 | return SteemHelper::handleError($e);
244 | }
245 | }
246 |
247 | /**
248 | * Get list of articles that has recieved the highest upvotes using the tag $tag
249 | * Start author and start permlink are for pagination
250 | *
251 | * @param string $tag The tag
252 | * @param integer $limit The limit
253 | * @param string $startAuthor The start author
254 | * @param string $startPermlink The start permlink
255 | *
256 | * @return array The discussions by votes.
257 | */
258 | public function getDiscussionsByVotes($tag, $limit = 100, $startAuthor = null, $startPermlink = null)
259 | {
260 | try {
261 | $this->api = $this->getApi('database_api');
262 | $query = ['tag' => $tag, 'limit' => SteemHelper::filterInt($limit), 'start_author' => $startAuthor, 'start_permlink' => $startPermlink];
263 | return $this->client->call($this->api, 'get_discussions_by_votes', [$query]);
264 | } catch (\Exception $e) {
265 | return SteemHelper::handleError($e);
266 | }
267 | }
268 |
269 | /**
270 | * Get articles by childer
271 | * Start author and start permlink are for pagination
272 | *
273 | * @param string $tag The tag
274 | * @param integer $limit The limit
275 | * @param string $startAuthor The start author
276 | * @param string $startPermlink The start permlink
277 | *
278 | * @return array The discussions by children.
279 | */
280 | public function getDiscussionsByChildren($tag, $limit = 100, $startAuthor = null, $startPermlink = null)
281 | {
282 | try {
283 | $this->api = $this->getApi('database_api');
284 | $query = ['tag' => $tag, 'limit' => SteemHelper::filterInt($limit), 'start_author' => $startAuthor, 'start_permlink' => $startPermlink];
285 | return $this->client->call($this->api, 'get_discussions_by_children', [$query]);
286 | } catch (\Exception $e) {
287 | return SteemHelper::handleError($e);
288 | }
289 | }
290 |
291 | /**
292 | * Get list of articles which are hot and using tha tag $tag
293 | * Start author and start permlink are for pagination
294 | *
295 | * @param string $tag The tag
296 | * @param integer $limit The limit
297 | * @param string $startAuthor The start author
298 | * @param string $startPermlink The start permlink
299 | *
300 | * @return array The discussions by hot.
301 | */
302 | public function getDiscussionsByHot($tag, $limit = 100, $startAuthor = null, $startPermlink = null)
303 | {
304 | try {
305 | $this->api = $this->getApi('database_api');
306 | $query = ['tag' => $tag, 'limit' => SteemHelper::filterInt($limit), 'start_author' => $startAuthor, 'start_permlink' => $startPermlink];
307 | return $this->client->call($this->api, 'get_discussions_by_hot', [$query]);
308 | } catch (\Exception $e) {
309 | return SteemHelper::handleError($e);
310 | }
311 | }
312 |
313 | /**
314 | * Get list of articles in the feed section for the author $author
315 | * Start author and start permlink are for pagination
316 | *
317 | * @param string $author The author
318 | * @param integer $limit The limit
319 | * @param string $startAuthor The start author
320 | * @param string $startPermlink The start permlink
321 | *
322 | * @return array The discussions by feed.
323 | */
324 | public function getDiscussionsByFeed($author, $limit = 100, $startAuthor = null, $startPermlink = null)
325 | {
326 | try {
327 | $this->api = $this->getApi('database_api');
328 | $query = ['tag' => $author, 'limit' => SteemHelper::filterInt($limit), 'start_author' => $startAuthor, 'start_permlink' => $startPermlink];
329 | return $this->client->call($this->api, 'get_discussions_by_feed', [$query]);
330 | } catch (\Exception $e) {
331 | return SteemHelper::handleError($e);
332 | }
333 | }
334 |
335 | /**
336 | * Get list of articles written/reblogged by the author $author
337 | * $startPermlink are null by default and the data can be used for pagination
338 | *
339 | * @param string $author The author
340 | * @param integer $limit The limit
341 | * @param string $startPermlink The start permlink
342 | *
343 | * @return array The discussions by blog.
344 | */
345 | public function getDiscussionsByBlog($author, $limit = 100, $startPermlink = null)
346 | {
347 | try {
348 | $this->api = $this->getApi('database_api');
349 | $startAuthor = !is_null($startPermlink) ? $author : null;
350 | $query = ['tag' => $author, 'limit' => SteemHelper::filterInt($limit), 'start_author' => $startAuthor, 'start_permlink' => $startPermlink];
351 | return $this->client->call($this->api, 'get_discussions_by_blog', [$query]);
352 | } catch (\Exception $e) {
353 | return SteemHelper::handleError($e);
354 | }
355 | }
356 |
357 | /**
358 | * Get list of articles the $author has commented on
359 | *
360 | * @param string $author The author
361 | * @param string $permlink The permlink
362 | * @param integer $limit The limit
363 | *
364 | * @return array The discussions by comments.
365 | */
366 | public function getDiscussionsByComments($author, $permlink, $limit = 100)
367 | {
368 | try {
369 | $this->api = $this->getApi('database_api');
370 | $query = ['start_author' => $author, 'start_permlink' => $permlink, 'limit' => SteemHelper::filterInt($limit)];
371 | return $this->client->call($this->api, 'get_discussions_by_comments', [$query]);
372 | } catch (\Exception $e) {
373 | return SteemHelper::handleError($e);
374 | }
375 | }
376 |
377 | /**
378 | * Get the list of articles written by the $author before the date $beforeDate
379 | *
380 | * @param string $author The author
381 | * @param string $startPermlink The start permlink
382 | * @param date $beforeDate The before date
383 | * @param integer $limit The limit
384 | *
385 | * @return array The discussions by author before date.
386 | */
387 | public function getDiscussionsByAuthorBeforeDate($author, $startPermlink, $beforeDate, $limit = 100)
388 | {
389 | try {
390 | $this->api = $this->getApi('database_api');
391 | return $this->client->call($this->api, 'get_discussions_by_author_before_date', [$author, $startPermlink, SteemHelper::filterDate($beforeDate), SteemHelper::filterInt($limit)]);
392 | } catch (\Exception $e) {
393 | return SteemHelper::handleError($e);
394 | }
395 | }
396 |
397 | /**
398 | * Get list of replies for where the article has recieved the most upvotes for the author $author
399 | * where the article has been posted less than a week ago
400 | *
401 | * @param string $startAuthor The start author
402 | * @param string $startPermlink The start permlink
403 | * @param integer $limit The limit
404 | *
405 | * @return array The replies by last upvote.
406 | */
407 | public function getRepliesByLastUpvote($startAuthor, $startPermlink, $limit = 100)
408 | {
409 | try {
410 | $this->api = $this->getApi('database_api');
411 | return $this->client->call($this->api, 'get_replies_by_last_update', [$startAuthor, $startPermlink, SteemHelper::filterInt($limit)]);
412 | } catch (\Exception $e) {
413 | return SteemHelper::handleError($e);
414 | }
415 | }
416 |
417 | /**
418 | * Get the list of upvotes the article $startPermlink has received
419 | *
420 | * @param string $startAuthor The start author
421 | * @param string $startPermlink The start permlink
422 | *
423 | * @return array The active votes.
424 | */
425 | public function getActiveVotes($startAuthor, $startPermlink)
426 | {
427 | try {
428 | $this->api = $this->getApi('database_api');
429 | return $this->client->call($this->api, 'get_active_votes', [$startAuthor, $startPermlink]);
430 | } catch (\Exception $e) {
431 | return SteemHelper::handleError($e);
432 | }
433 | }
434 |
435 | /**
436 | * Get state for $path eg: /@davidk
437 | *
438 | * @param string $path The path
439 | *
440 | * @return array The state.
441 | */
442 | public function getState($path)
443 | {
444 | try {
445 | $this->api = $this->getApi('database_api');
446 | return $this->client->call($this->api, 'get_state', [$path]);
447 | } catch (\Exception $e) {
448 | return SteemHelper::handleError($e);
449 | }
450 | }
451 |
452 | }
453 |
454 | ?>
--------------------------------------------------------------------------------