Skip to content

Commit 622d9a8

Browse files
committed
add new api methods for WHALESHARES blockchain
1 parent 3688a10 commit 622d9a8

File tree

3 files changed

+229
-11
lines changed

3 files changed

+229
-11
lines changed

Commands/Commands.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @method Commands get_account_votes()
1616
* @method Commands get_active_votes()
1717
* @method Commands get_active_witnesses()
18-
* @method Commands get_api_by_name() ONLY for STEEM
18+
* @method Commands get_api_by_name() ONLY for STEEM/whaleshares
1919
* @method Commands get_block()
2020
* @method Commands get_block_header()
2121
* @method Commands get_content()
@@ -29,10 +29,10 @@
2929
* @method Commands get_dynamic_global_properties()
3030
* @method Commands get_followers()
3131
* @method Commands get_ops_in_block()
32-
* @method Commands get_trending_categories() //only steem
32+
* @method Commands get_trending_categories() //only steem/whaleshares
3333
* @method Commands get_version()
3434
* @method Commands get_witnesses_by_vote()
35-
* @method Commands login() ONLY for STEEM
35+
* @method Commands login() //ONLY for STEEM/whaleshares
3636
*/
3737
class Commands implements CommandInterface
3838
{
@@ -150,12 +150,14 @@ public function __call($name, $params)
150150
$platform = $this->connector->getPlatform();
151151

152152
if (!isset(self::$queryDataMap[$platform])) {
153-
if ($platform === ConnectorInterface::PLATFORM_VIZ) {
154-
$api = VizApiMethods::$map;
155-
} elseif ($platform === ConnectorInterface::PLATFORM_GOLOS) {
153+
if ($platform === ConnectorInterface::PLATFORM_GOLOS) {
156154
$api = GolosApiMethods::$map;
157155
} elseif ($platform === ConnectorInterface::PLATFORM_STEEMIT) {
158156
$api = SteemitApiMethods::$map;
157+
} elseif ($platform === ConnectorInterface::PLATFORM_VIZ) {
158+
$api = VizApiMethods::$map;
159+
} elseif ($platform === ConnectorInterface::PLATFORM_WHALESHARES) {
160+
$api = WhalesharesApiMethods::$map;
159161
} else {
160162
throw new \Exception('There is no api');
161163
}

Commands/WhalesharesApiMethods.php

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
<?php
2+
3+
4+
namespace GrapheneNodeClient\Commands;
5+
6+
7+
class WhalesharesApiMethods
8+
{
9+
/**
10+
* [ 'method_name' => [ 'apiName' => 'api_name', 'fields'=>['массив с полями из команды']]];
11+
*
12+
* @var array
13+
*/
14+
public static $map = [
15+
'get_block' => [
16+
'apiName' => 'database_api',
17+
'fields' => [
18+
'0' => ['integer'], //block_id
19+
]
20+
],
21+
'get_accounts' => [
22+
'apiName' => 'database_api',
23+
'fields' => [
24+
'0' => ['array'], //authors
25+
]
26+
],
27+
'get_account_count' => [
28+
'apiName' => 'database_api',
29+
'fields' => []
30+
],
31+
'get_account_history' => [
32+
'apiName' => 'database_api',
33+
'fields' => [
34+
'0' => ['string'], //author
35+
'1' => ['integer'], //from
36+
'2' => ['integer'], //limit max 2000
37+
]
38+
],
39+
'get_account_votes' => [
40+
'apiName' => 'database_api',
41+
'fields' => [
42+
'0' => ['string'] //account name
43+
]
44+
],
45+
'get_active_votes' => [
46+
'apiName' => 'database_api',
47+
'fields' => [
48+
'0' => ['string'], //author
49+
'1' => ['string'] //permlink
50+
]
51+
],
52+
'get_active_witnesses' => [
53+
'apiName' => 'database_api',
54+
'fields' => [
55+
]
56+
],
57+
'get_block_header' => [
58+
'apiName' => 'database_api',
59+
'fields' => [
60+
'0' => ['integer'], //block_id
61+
]
62+
],
63+
'get_config' => [
64+
'apiName' => 'database_api',
65+
'fields' => [
66+
]
67+
],
68+
'get_content' => [
69+
'apiName' => 'database_api',
70+
'fields' => [
71+
'0' => ['string'], //author
72+
'1' => ['string'] //permlink
73+
]
74+
],
75+
'get_content_replies' => [
76+
'apiName' => 'database_api',
77+
'fields' => [
78+
'0' => ['string'], //author
79+
'1' => ['string'] //permlink
80+
]
81+
],
82+
'get_discussions_by_author_before_date' => [
83+
'apiName' => 'database_api',
84+
'fields' => [
85+
'0' => ['string'], //'author',
86+
'1' => ['string'], //'start_permlink' for pagination,
87+
'2' => ['string'], //'before_date'
88+
'3' => ['integer'] //'limit'
89+
]
90+
],
91+
'get_discussions_by_blog' => [
92+
'apiName' => 'database_api',
93+
'fields' => [
94+
'*:tag' => ['string'], //'author',
95+
'*:limit' => ['integer'], //'limit'
96+
'*:start_author' => ['nullOrString'], //'start_author' for pagination,
97+
'*:start_permlink' => ['nullOrString'] //'start_permlink' for pagination,
98+
]
99+
],
100+
'get_discussions_by_created' => [
101+
'apiName' => 'database_api',
102+
'fields' => [
103+
'*:tag' => ['nullOrString'], //'author',
104+
'*:limit' => ['integer'], //'limit'
105+
'*:start_author' => ['nullOrString'], //'start_author' for pagination,
106+
'*:start_permlink' => ['nullOrString'] //'start_permlink' for pagination,
107+
],
108+
],
109+
'get_discussions_by_feed' => [
110+
'apiName' => 'database_api',
111+
'fields' => [
112+
'*:tag' => ['string'], //'author',
113+
'*:limit' => ['integer'], //'limit'
114+
'*:start_author' => ['nullOrString'], //'start_author' for pagination,
115+
'*:start_permlink' => ['nullOrString'] //'start_permlink' for pagination,
116+
]
117+
],
118+
'get_discussions_by_trending' => [
119+
'apiName' => 'database_api',
120+
'fields' => [
121+
'*:tag' => ['nullOrString'], //'author',
122+
'*:limit' => ['integer'], //'limit'
123+
'*:start_author' => ['nullOrString'], //'start_author' for pagination,
124+
'*:start_permlink' => ['nullOrString'] //'start_permlink' for pagination,
125+
]
126+
],
127+
'get_dynamic_global_properties' => [
128+
'apiName' => 'database_api',
129+
'fields' => [
130+
]
131+
],
132+
'get_ops_in_block' => [
133+
'apiName' => 'database_api',
134+
'fields' => [
135+
'0' => ['integer'], //blockNum
136+
'1' => ['bool'], //onlyVirtual
137+
]
138+
],
139+
'get_trending_categories' => [
140+
'apiName' => 'database_api',
141+
'fields' => [
142+
'0' => ['nullOrString'], //after
143+
'1' => ['integer'], //permlink
144+
]
145+
],
146+
'get_trending_tags' => [
147+
'apiName' => 'database_api',
148+
'fields' => [
149+
'0' => ['nullOrString'], //after
150+
'1' => ['integer'], //permlink
151+
]
152+
],
153+
'get_witnesses_by_vote' => [
154+
'apiName' => 'database_api',
155+
'fields' => [
156+
'0' => ['string'], //from accountName, can be empty string ''
157+
'1' => ['integer'] //limit
158+
]
159+
],
160+
'get_followers' => [
161+
'apiName' => 'follow_api',
162+
'fields' => [
163+
'0' => ['string'], //author
164+
'1' => ['nullOrString'], //startFollower
165+
'2' => ['string'], //followType //blog, ignore
166+
'3' => ['integer'], //limit
167+
]
168+
],
169+
'login' => [
170+
'apiName' => 'login_api',
171+
'fields' => [
172+
0 => ['string'],
173+
1 => ['string']
174+
]
175+
],
176+
'get_version' => [
177+
'apiName' => 'login_api',
178+
'fields' => [
179+
]
180+
],
181+
'get_api_by_name' => [
182+
'apiName' => 'login_api',
183+
'fields' => [
184+
'0' => ['string'], //'api_name',for example follow_api, database_api, login_api and ect.
185+
]
186+
],
187+
'broadcast_transaction' => [
188+
'apiName' => 'network_broadcast_api',
189+
'fields' => [
190+
'0:ref_block_num' => ['integer'],
191+
'0:ref_block_prefix' => ['integer'],
192+
'0:expiration' => ['string'],
193+
'0:operations:*:0' => ['string'],
194+
'0:operations:*:1' => ['array'],
195+
'0:extensions' => ['array'],
196+
'0:signatures' => ['array']
197+
]
198+
],
199+
'broadcast_transaction_synchronous' => [
200+
'apiName' => 'network_broadcast_api',
201+
'fields' => [
202+
'0:ref_block_num' => ['integer'],
203+
'0:ref_block_prefix' => ['integer'],
204+
'0:expiration' => ['string'],
205+
'0:operations:*:0' => ['string'],
206+
'0:operations:*:1' => ['array'],
207+
'0:extensions' => ['array'],
208+
'0:signatures' => ['array']
209+
]
210+
],
211+
];
212+
}

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# php-graphene-node-client
2-
PHP client for connection to VIZ/STEEM/GOLOS node
2+
PHP client for connection to [VIZ](https://github.com/viz-world)/[STEEM](https://github.com/steemit)/[GOLOS](https://github.com/goloschain)/[WHALESHARES](https://gitlab.com/beyondbitcoin) node
33

44

55
## Install Via Composer
@@ -123,7 +123,7 @@ $golosPosts = $commands->get_discussions_by_created()
123123
- GetAccountsCommand
124124
- GetAccountVotesCommand
125125
- GetActiveWitnessesCommand
126-
- GetApiByNameCommand //ONLY STEEM
126+
- GetApiByNameCommand //ONLY STEEM/whaleshares
127127
- GetBlockCommand
128128
- GetBlockHeaderCommand
129129
- GetConfigCommand
@@ -138,10 +138,10 @@ $golosPosts = $commands->get_discussions_by_created()
138138
- GetDynamicGlobalPropertiesCommand
139139
- GetFollowersCommand
140140
- GetOpsInBlock
141-
- GetTrendingCategoriesCommand
141+
- GetTrendingCategoriesCommand //only steem/whaleshares
142142
- GetVersionCommand
143143
- GetWitnessesByVoteCommand
144-
- LoginCommand //ONLY STEEM
144+
- LoginCommand //ONLY for STEEM/whaleshares
145145

146146
All single commands can be called through Commands Class as methods (example: (new Commands)->get_block()->execute(...) )
147147

@@ -437,7 +437,11 @@ $command = new BroadcastTransactionSynchronousCommand($connector);
437437
Transaction::sign($chainName, $tx, ['posting' => $publicWif]);
438438

439439
$trxString = mb_strlen(json_encode($tx->getParams()), '8bit');
440-
Bandwidth::isEnough($connector, $voter, 'market', $trxString);
440+
if (Bandwidth::isEnough($connector, $voter, 'market', $trxString)) {
441+
$answer = $command->execute(
442+
$tx
443+
);
444+
}
441445

442446
//or other way
443447

0 commit comments

Comments
 (0)