├── .gitignore
├── LICENSE
├── README.md
├── composer
├── composer.json
├── composer.lock
├── example
├── account.php
├── api.php
├── crypto.php
└── transaction.php
├── package-lock.json
├── src
├── Core
│ ├── Account.php
│ ├── Transaction.php
│ ├── TransactionBinaryPayload.php
│ ├── TransactionCallPayload.php
│ ├── TransactionDeployPayload.php
│ └── TransactionPayload.php
├── Rpc
│ ├── Admin.php
│ ├── Api.php
│ ├── HttpProvider.php
│ └── Neb.php
├── Utils
│ ├── ByteUtils.php
│ ├── Crypto.php
│ ├── Http.php
│ ├── Unit.php
│ └── Utils.php
└── proto
│ ├── dist
│ ├── Corepb
│ │ ├── Data.php
│ │ └── Transaction.php
│ ├── GPBMetadata
│ │ ├── Rpc.php
│ │ └── Transaction.php
│ └── Rpcpb
│ │ ├── AccountsResponse.php
│ │ ├── BlockResponse.php
│ │ ├── ByBlockHeightRequest.php
│ │ ├── CallResponse.php
│ │ ├── ConsensusRoot.php
│ │ ├── ContractRequest.php
│ │ ├── Event.php
│ │ ├── EventsResponse.php
│ │ ├── GasPriceResponse.php
│ │ ├── GasResponse.php
│ │ ├── GetAccountStateRequest.php
│ │ ├── GetAccountStateResponse.php
│ │ ├── GetBlockByHashRequest.php
│ │ ├── GetBlockByHeightRequest.php
│ │ ├── GetDynastyResponse.php
│ │ ├── GetNebStateResponse.php
│ │ ├── GetTransactionByHashRequest.php
│ │ ├── HashRequest.php
│ │ ├── LockAccountRequest.php
│ │ ├── LockAccountResponse.php
│ │ ├── NewAccountRequest.php
│ │ ├── NewAccountResponse.php
│ │ ├── NodeInfoResponse.php
│ │ ├── NonParamsRequest.php
│ │ ├── PprofRequest.php
│ │ ├── PprofResponse.php
│ │ ├── RouteTable.php
│ │ ├── SendRawTransactionRequest.php
│ │ ├── SendTransactionPassphraseRequest.php
│ │ ├── SendTransactionResponse.php
│ │ ├── SignHashRequest.php
│ │ ├── SignHashResponse.php
│ │ ├── SignTransactionPassphraseRequest.php
│ │ ├── SignTransactionPassphraseResponse.php
│ │ ├── SubscribeRequest.php
│ │ ├── SubscribeResponse.php
│ │ ├── TransactionRequest.php
│ │ ├── TransactionResponse.php
│ │ ├── UnlockAccountRequest.php
│ │ └── UnlockAccountResponse.php
│ ├── google
│ └── api
│ │ ├── annotations.proto
│ │ └── http.proto
│ ├── rpc.proto
│ └── transaction.proto
└── tests
├── Core
├── AccountTest.php
├── TransactionCallPayloadTest.php
├── TransactionDeployPayloadTest.php
└── TransactionTest.php
├── Rpc
├── AdminTest.php
└── ApiTest.php
└── utils
├── CryptoTest.php
└── UnitTest.php
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 | #
3 | # If you find yourself ignoring temporary files generated by your text editor
4 | # or operating system, you probably want to add a global ignore instead:
5 | # git config --global core.excludesfile ~/.gitignore_global
6 |
7 | vendor
8 | .idea
9 | trash
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
It's parameters is the same with api/calland api/estimateGas.
115 | * @param string $from
116 | * @param string $to
117 | * @param string $value note that it's unit is wei.
118 | * @param int $nonce
119 | * @param string $gasPrice
120 | * @param string $gasLimit
121 | * @param string|null $type -transaction type, should be "binary","deploy", or "call", or null
122 | * @param array|null $contract -contract data for deploy/call type. Please refer to {@link https://github.com/nebulasio/wiki/blob/master/rpc_admin.md/#sendtransaction}
123 | * @param string|null $binary
124 | * @return mixed
125 | */
126 | public function sendTransaction(string $from, string $to,
127 | string $value, int $nonce,
128 | string $gasPrice, string $gasLimit,
129 | string $type = null, array $contract = null, string $binary = null)
130 | {
131 | $param = array(
132 | "from" => $from,
133 | "to" => $to,
134 | "value" => $value,
135 | "nonce" => $nonce,
136 | "gasPrice" => $gasPrice,
137 | "gasLimit" => $gasLimit,
138 | 'type' => $type,
139 | "contract" => $contract,
140 | "binary" => $binary
141 | );
142 | return $this->sendRequest("post", "/transaction", $param);
143 | }
144 |
145 | /**
146 | * Sign hash.
147 | * The account must be unlocked before sign.
148 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc_admin.md#signhash}
149 | *
150 | * @param string $address account string
151 | * @param string $hash a base64 encoded sha3-256 hash string
152 | * @param int|null $alg the sign algorithm, an int value,
153 | * @return mixed
154 | */
155 | public function signHash(string $address, string $hash, int $alg = 1){
156 | $param = array(
157 | 'address' => $address,
158 | 'hash' => $hash,
159 | 'alg' => $alg
160 | );
161 | return $this->sendRequest("post", "/sign/hash", $param);
162 | }
163 |
164 | public function signTransactionWithPassphrase(string $from, string $to,
165 | string $value, string $nonce,
166 | string $gasPrice, string $gasLimit,
167 | string $type = null, array $contract = null, string $binary = null,
168 | string $passphrase)
169 | {
170 | $tx = array(
171 | "from" => $from,
172 | "to" => $to,
173 | "value" => $value,
174 | "nonce" => $nonce,
175 | "gasPrice" => $gasPrice,
176 | "gasLimit" => $gasLimit,
177 | 'type' => $type,
178 | "contract" => $contract,
179 | "binary" => $binary
180 | );
181 | $param = array(
182 | "transaction" => $tx,
183 | "passphrase" => $passphrase
184 | );
185 | return $this->sendRequest("post", "/sign", $param);
186 | }
187 |
188 | /**
189 | * Send transaction with passphrase.
190 | * The transaction's sender addrees must be unlock before send.
191 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc_admin.md#signtransactionwithpassphrase}
192 | *
193 | * @param string $from
194 | * @param string $to
195 | * @param string $value
196 | * @param string $nonce
197 | * @param string $gasPrice
198 | * @param string $gasLimit
199 | * @param string $type
200 | * @param string $contract
201 | * @param string $binary
202 | * @param string $passphrase
203 | * @return mixed
204 | */
205 | public function sendTransactionWithPassphrase(string $from, string $to,
206 | string $value, string $nonce,
207 | string $gasPrice, string $gasLimit,
208 | string $type = null, array $contract = null, string $binary = null,
209 | string $passphrase)
210 | {
211 | $tx = array(
212 | "from" => $from,
213 | "to" => $to,
214 | "value" => $value,
215 | "nonce" => $nonce,
216 | "gasPrice" => $gasPrice,
217 | "gasLimit" => $gasLimit,
218 | 'type' => $type,
219 | "contract" => $contract,
220 | "binary" => $binary
221 | );
222 | $param = array(
223 | "transaction" => $tx,
224 | "passphrase" => $passphrase
225 | );
226 | return $this->sendRequest("post", "/transactionWithPassphrase", $param);
227 | }
228 |
229 | /**
230 | * Start listen to provided port.
231 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc_admin.md#startpprof}
232 | *
233 | * @param string $listen the specified port
234 | * @return mixed
235 | * @example
236 | *
237 | *
238 | */
239 | public function startPprof(string $listen){
240 | $param = array(
241 | 'listen' => $listen
242 | );
243 | return $this->sendRequest("post", "/pprof", $param);
244 | }
245 |
246 | /**
247 | * Get config of node in Nebulas Network.
248 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc_admin.md#getConfig}
249 | *
250 | * @return mixed
251 | */
252 | public function getConfig(){
253 | $param = array();
254 | return $this->sendRequest("get", "/getConfig", $param);
255 | }
256 |
257 | function sendRequest(string $method, string $api, array $param){
258 | $api = $this->path . $api; // e.g. "/user/accountstate"
259 | //$param = json_encode($param); // e.g. "{"address":"n1H2Yb5Q6ZfKvs61htVSV4b1U2gr2GA9vo6","height":"0"}"
260 | $paramString = Utils::JsonEncode($param);
261 | //echo "payload formatted: ", Utils::JsonEncode($param,JSON_PRETTY_PRINT),PHP_EOL;
262 |
263 | $options = (object) array(
264 | "method" => $method,
265 | );
266 | return $this->provider->request($api, $paramString, $this->apiVersion, $options);
267 | }
268 |
269 |
270 | }
--------------------------------------------------------------------------------
/src/Rpc/Api.php:
--------------------------------------------------------------------------------
1 | setProvidr($neb->provider);
25 | $this->apiVersion = $apiVersion;
26 | }
27 |
28 | public function setProvidr($provider){
29 | $this->provider = $provider;
30 | $this->path = "/user";
31 | }
32 |
33 | /**
34 | * Get state of Nebulas Network.
35 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#getnebstate}
36 | *
37 | * @return mixed
38 | */
39 | public function getNebState(){
40 | $param = array();
41 | return $this->sendRequest("get", "/nebstate", $param);
42 | }
43 |
44 | /**
45 | * Get latest irreversible block of Nebulas Network.
46 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#latestirreversibleblock}
47 | *
48 | * @return mixed
49 | */
50 | public function latestIrreversibleBlock(){
51 | $param = array();
52 | return $this->sendRequest("get", "/lib", $param);
53 | }
54 |
55 | /**
56 | * Method return the state of the account. Balance and nonce.
57 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#getaccountstate}
58 | *
59 | * @param string $address
60 | * @param int $height int value, the height at which you want to get the account state
61 | * @return mixed
62 | */
63 | public function getAccountState(string $address,int $height = 0){
64 | $param = array(
65 | "address" => $address,
66 | "height" => $height
67 | );
68 | return $this->sendRequest("post", "/accountstate", $param);
69 | }
70 |
71 | /**
72 | * Simulate a transaction, to get the result and error info.
73 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#call}
74 | *
75 | * @param string $from
76 | * @param string $to
77 | * @param string $value note that it's unit is wei.
78 | * @param int $nonce
79 | * @param string $gasprice
80 | * @param string $gasLimit
81 | * @param string|null $type -transaction type, should be "binary","deploy", or "call", or null
82 | * @param array|null $contract -contract data for deploy/call type. Please refer to {@link https://github.com/nebulasio/wiki/blob/master/rpc_admin.md/#sendtransaction}
83 | * @param string|null $binary
84 | * @return mixed
85 | */
86 | public function call(string $from, string $to,
87 | string $value, int $nonce,
88 | string $gasprice, string $gasLimit,
89 | string $type = null, array $contract = null, string $binary = null){
90 | $param = array(
91 | "from" => $from,
92 | "to" => $to,
93 | "value" => $value,
94 | "nonce" => $nonce,
95 | "gasPrice" => $gasprice,
96 | "gasLimit" => $gasLimit,
97 | "contract" => $contract,
98 | "type" => $type,
99 | "binary" => $binary
100 | );
101 | return $this->sendRequest("post", "/call", $param);
102 | }
103 |
104 | /**
105 | * Send a signed transaction data. The data is a base64 encoded string of transaction details.
106 | * The data could be generated by hashTransaction and then signTransaction
.
107 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#sendrawtransaction}
108 | *
109 | * @param string $data
110 | * @return mixed
111 | */
112 | public function sendRawTransaction(string $data){
113 | $param = array(
114 | "data" => $data
115 | );
116 | return $this->sendRequest("post", "/rawtransaction", $param);
117 | }
118 |
119 | /**
120 | * Get block header info by the block hash.
121 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#getblockbyhash}
122 | *
123 | * @param string $hash
124 | * @param bool $isFull
125 | * @return mixed
126 | */
127 | public function getBlockByHash(string $hash, bool $isFull = false){
128 | $param = array(
129 | "hash" => $hash,
130 | "full_fill_transaction" => $isFull, // json_encode($isFull)
131 | );
132 | return $this->sendRequest("post", "/getBlockByHash", $param);
133 | }
134 |
135 | /**
136 | * Get block header info by the block height.
137 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#getblockbyheight}
138 | *
139 | * @param string $height
140 | * @return mixed
141 | */
142 | public function getBlockByHeight(string $height){
143 | $param = array(
144 | "height" => $height,
145 | );
146 | return $this->sendRequest("post", "/getBlockByHeight", $param);
147 | }
148 |
149 | /**
150 | * Get transactionReceipt info by tansaction hash.
151 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#gettransactionreceipt}
152 | *
153 | * @param string $hash
154 | * @return mixed
155 | */
156 | public function getTransactionReceipt(string $hash){
157 | $param = array(
158 | "hash" => $hash,
159 | );
160 | return $this->sendRequest("post", "/getTransactionReceipt", $param);
161 | }
162 |
163 | /**
164 | * Get transactionReceipt info by contract address.
165 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#gettransactionbycontract}
166 | *
167 | * @param string $address
168 | * @return mixed
169 | */
170 | public function getTransactionByContract(string $address){
171 | $param = array(
172 | "address" => $address,
173 | );
174 | return $this->sendRequest("post", "/getTransactionByContract", $param);
175 |
176 | }
177 |
178 | /**
179 | * Return the subscribed events of transaction & block.
180 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#subscribe}
181 | * Here is an example of the returned event data:
182 | * {"result":{"topic":"chain.pendingTransaction","data":"{\"chainID\":100,\"data\":\"\",\"from\":\"n1NrMKTYESZRCwPFDLFKiKREzZKaN1nhQvz\",\"gaslimit\":\"2000000\",\"gasprice\":\"2000000\",\"hash\":\"dbde8d409647387c99630bba201b31e000dd95344b1d3afacf7d21286e3042f8\",\"nonce\":29,\"timestamp\":1529045611,\"to\":\"n1NrMKTYESZRCwPFDLFKiKREzZKaN1nhQvz\",\"type\":\"binary\",\"value\":\"0\"}"}}
183 | *
184 | * @param array $topics
185 | * @param callable $onDownloadProgress this is the function that handle the subscribed data,
186 | * when a new subscribed event is received, it will be called.
187 | * Actually it is the "CURLOPT_WRITEFUNCTION" option for curl, please refercurl_setopt
188 | * Here is an example onDownloadProgress function
189 | *
190 | * function writeCallback($curlHandle, $data){
191 | * echo "received data: $data",PHP_EOL; //handle the subscribed event data
192 | * return strlen($data); //return the received data length, or the http connection will close.
193 | * }
194 | *
195 | * @example ../../example/api.php
196 | * @return mixed
197 | */
198 | public function subscribe(array $topics, callable $onDownloadProgress){
199 | $param = array(
200 | "topics" => $topics,
201 | );
202 | return $this->sendRequest("post", "/subscribe", $param, $onDownloadProgress);
203 | }
204 |
205 | /**
206 | * Get current gasPrice.
207 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#getgasprice}
208 | *
209 | * @return mixed
210 | */
211 | public function gasPrice(){
212 | $param = array();
213 | return $this->sendRequest("get", "/getGasPrice", $param);
214 | }
215 |
216 | /**
217 | * it's parameter is the same with {@code call}.
218 | *
219 | */
220 | public function estimateGas(string $from, string $to,
221 | string $value, $nonce, //todo $nonce int or string
222 | $gasPrice, $gasLimit,
223 | string $type = null, array $contract = null, string $binary = null)
224 | {
225 | $param = array(
226 | "from" => $from,
227 | "to" => $to,
228 | "value" => $value,
229 | "nonce" => $nonce,
230 | "gasPrice" => $gasPrice,
231 | "gasLimit" => $gasLimit,
232 | "type" => $type,
233 | "contract" => $contract,
234 | "binary" => $binary, //todo: check type
235 | );
236 | return $this->sendRequest("post", "/estimateGas", $param);
237 | }
238 |
239 | /**
240 | * Return the events list of a given transaction.
241 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#geteventsbyhash}
242 | *
243 | * @param string $hash
244 | * @return mixed
245 | */
246 | public function getEventsByHash(string $hash){
247 | $param = array("hash" => $hash);
248 | return $this->sendRequest("post", "/getEventsByHash", $param);
249 | }
250 |
251 | /**
252 | * Get the current dpos dynasty.
253 | * @see {@link https://github.com/nebulasio/wiki/blob/master/rpc.md#getdynasty}
254 | *
255 | * @param string $height
256 | * @return mixed
257 | */
258 | public function getDynasty(string $height){
259 | $param = array("height" => $height);
260 | return $this->sendRequest("post", "/dynasty", $param);
261 | }
262 |
263 | function sendRequest(string $method, string $api, array $param, callable $writeFunction = null){
264 | $api = $this->path . $api; // e.g. "/user/accountstate"
265 | //$param = json_encode($param); // e.g. "{"address":"n1H2Yb5Q6ZfKvs61htVSV4b1U2gr2GA9vo6","height":"0"}"
266 | $param = Utils::JsonEncode($param);
267 | //echo "payload: ", $param,PHP_EOL;
268 |
269 | $options = (object) array(
270 | "method" => $method,
271 | "callback" => $writeFunction
272 | );
273 | return $this->provider->request($api, $param, $this->apiVersion, $options);
274 | }
275 |
276 |
277 | }
--------------------------------------------------------------------------------
/src/Rpc/HttpProvider.php:
--------------------------------------------------------------------------------
1 | host = $host;
31 | $this->timeout = $timeout;
32 | }
33 |
34 | //e.g. https://testnet.nebulas.io/v1/user/getTransactionReceipt
35 | function createUrl($apiVersion, $api){
36 | return $this->host . '/' . $apiVersion . $api;
37 | }
38 |
39 | function request(string $api, string $payload, string $apiVersion, /*object*/ $options){
40 | $url = $this->createUrl($apiVersion, $api);
41 | //echo "url: ", $url, PHP_EOL;
42 |
43 | if(empty($options->method))
44 | throw new \Exception("HTTP method has not specified.");
45 |
46 | if(is_callable($options->callback)){
47 | return Http::request_alive($options->method, $url, $payload, $options->callback);
48 | }
49 |
50 | return Http::request($options->method, $url, $payload, $this->timeout);
51 | }
52 |
53 |
54 | }
--------------------------------------------------------------------------------
/src/Rpc/Neb.php:
--------------------------------------------------------------------------------
1 | provider = $request;
34 |
35 | $this->api = new Api($this, $apiVersion);
36 | $this->admin = new Admin($this, $apiVersion);
37 | }
38 |
39 | public function setProvider(HttpProvider $provider){
40 | $this->provider = $provider;
41 | $this->api->setProvidr($provider);
42 | $this->admin->serProvider($provider);
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/src/Utils/ByteUtils.php:
--------------------------------------------------------------------------------
1 | genKeyPair();
45 | return $keyPair->getPrivate()->toString(16);
46 | }
47 |
48 | public static function privateToPublic($priv_hex)
49 | {
50 | $ec = new EC('secp256k1');
51 | $privKey = $ec->keyFromPrivate($priv_hex);
52 | $pub_hex = $privKey->getPublic("hex");
53 | //echo "returned public key is : ", $pub_hex, PHP_EOL;
54 | return $pub_hex;
55 | }
56 |
57 | public static function sign($hash, $privKey){
58 | $ec = new EC('secp256k1');
59 | $key = $ec->keyFromPrivate($privKey);
60 | $sign = $key->sign($hash);
61 | //print_r($sign);
62 | $sign_R = $sign->r->tostring(16);
63 | $sign_S = $sign->s->tostring(16);
64 |
65 | return hex2bin($sign_R) . hex2bin($sign_S) . chr($sign->recoveryParam);
66 | }
67 |
68 | // public static function isValidPublic($pub_hex)
69 | // {
70 | //
71 | // }
72 |
73 | //$data is a random of 16 bytes, such as openssl_random_pseudo_bytes(16)
74 | public static function guidv4($data)
75 | {
76 | assert(strlen($data) == 16);
77 |
78 | $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
79 | $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
80 |
81 | return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
82 | }
83 |
84 | /**
85 | * Create a password hash
86 | *
87 | * @param string $password The clear text password
88 | * @param string $salt The salt to use, or null to generate a random one
89 | * @param int $N The CPU difficultly (must be a power of 2, > 1)
90 | * @param int $r The memory difficultly
91 | * @param int $p The parallel difficultly
92 | *
93 | * @return string The hashed password
94 | */
95 | public static function getScrypt($password, $salt, $N, $r, $p, $kdlen)
96 | {
97 | if ($N == 0 || ($N & ($N - 1)) != 0) {
98 | throw new \InvalidArgumentException("N must be > 0 and a power of 2");
99 | }
100 | if ($N > PHP_INT_MAX / 128 / $r) {
101 | throw new \InvalidArgumentException("Parameter N is too large");
102 | }
103 | if ($r > PHP_INT_MAX / 128 / $p) {
104 | throw new \InvalidArgumentException("Parameter r is too large");
105 | }
106 | return scrypt($password, $salt, $N, $r, $p, $kdlen);
107 | }
108 |
109 |
110 |
111 | }
--------------------------------------------------------------------------------
/src/Utils/Http.php:
--------------------------------------------------------------------------------
1 | $url,
20 | CURLOPT_HTTPHEADER => array("Content-type: application/json"),
21 | CURLOPT_POSTFIELDS => $payload,
22 | CURLOPT_RETURNTRANSFER => true,
23 | CURLOPT_CUSTOMREQUEST => strtoupper($method),
24 | CURLOPT_TIMEOUT => $timeout //or use CURLOPT_TIMEOUT_MS
25 | );
26 |
27 | curl_setopt_array($curl, $options);
28 | $result = curl_exec($curl);
29 | curl_close($curl);
30 | return $result;
31 |
32 | }
33 |
34 | //keep-alive connection
35 | static function request_alive(string $method, string $url, string $payload, callable $downloadProcess){
36 |
37 | $curl=curl_init();
38 | $options = array(
39 | CURLOPT_URL => $url,
40 | CURLOPT_HTTPHEADER => array("Content-type: application/json"),
41 | CURLOPT_POSTFIELDS => $payload,
42 | CURLOPT_RETURNTRANSFER => true,
43 | CURLOPT_CUSTOMREQUEST => strtoupper($method),
44 |
45 | CURLOPT_WRITEFUNCTION => $downloadProcess
46 | );
47 |
48 | curl_setopt_array($curl, $options);
49 | $result = curl_exec($curl);
50 | curl_close($curl);
51 | return $result;
52 |
53 | }
54 | }
--------------------------------------------------------------------------------
/src/Utils/Unit.php:
--------------------------------------------------------------------------------
1 | '0',
20 | 'None'=> '0',
21 | 'wei'=> '1',
22 | 'Wei'=> '1',
23 | 'kwei'=> '1000',
24 | 'Kwei'=> '1000',
25 | 'mwei'=> '1000000',
26 | 'Mwei'=> '1000000',
27 | 'gwei'=> '1000000000',
28 | 'Gwei'=> '1000000000',
29 | 'nas'=> '1000000000000000000',
30 | 'NAS'=> '1000000000000000000',
31 | );
32 |
33 | private static function unitValue(string $unit = 'nas'){
34 | $unit = strtolower($unit);
35 | if(empty(Unit::UnitMap[$unit]))
36 | throw new \Exception('The unit undefined, please use the following units:' . PHP_EOL . Utils::JsonEncode(Unit::UnitMap, JSON_PRETTY_PRINT));
37 | return Unit::UnitMap[$unit];
38 | }
39 |
40 | /**
41 | * Change number from unit to wei.
42 | * For example:
43 | * $wei = Unit::toBasic('1', 'kwei'); // $wei = 1000
44 | *
45 | * @param string $number
46 | * @param string $unit
47 | * @return string the result value in unit of wei
48 | * @throws \Exception
49 | */
50 | static function toBasic(string $number, string $unit){
51 | $value = Decimal::fromString($number);
52 | $unitValue = Decimal::fromString(static::unitValue($unit));
53 | $result = $value->mul($unitValue, 0); //remove decimal
54 | return $result->__toString();
55 |
56 | }
57 |
58 | /**
59 | * @param string $number
60 | * @return string
61 | * @throws \Exception
62 | */
63 | static function nasToBasic(string $number){
64 | return static::toBasic($number, 'nas');
65 | }
66 |
67 | /**
68 | * Change number from wei to unit.
69 | * For example:
70 | * $result = Unit::fromBasic('1010', 'kwei'); // $result = '1.01'
71 | *
72 | * @param string $number
73 | * @param string $unit
74 | * @return string
75 | * @throws \Exception
76 | */
77 | static function fromBasic(string $number, string $unit){
78 | $value = Decimal::fromString($number);
79 | $unitValue = Decimal::fromString(static::unitValue($unit));
80 | $result = $value->div($unitValue, BNScale);
81 | return $result->__toString();
82 | }
83 |
84 | /**
85 | * @param string $number
86 | * @param string $unit
87 | * @return string
88 | * @throws \Exception
89 | */
90 | static function toNas(string $number, string $unit){
91 | $wei = static::toBasic($number,$unit);
92 | return static::fromBasic($wei,'nas');
93 |
94 | }
95 |
96 |
97 | }
--------------------------------------------------------------------------------
/src/Utils/Utils.php:
--------------------------------------------------------------------------------
1 | corepb.Data
13 | */
14 | class Data extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field string payload_type = 1;
18 | */
19 | private $payload_type = '';
20 | /**
21 | * Generated from protobuf field bytes payload = 2;
22 | */
23 | private $payload = '';
24 |
25 | public function __construct() {
26 | \GPBMetadata\Transaction::initOnce();
27 | parent::__construct();
28 | }
29 |
30 | /**
31 | * Generated from protobuf field string payload_type = 1;
32 | * @return string
33 | */
34 | public function getPayloadType()
35 | {
36 | return $this->payload_type;
37 | }
38 |
39 | /**
40 | * Generated from protobuf field string payload_type = 1;
41 | * @param string $var
42 | * @return $this
43 | */
44 | public function setPayloadType($var)
45 | {
46 | GPBUtil::checkString($var, True);
47 | $this->payload_type = $var;
48 |
49 | return $this;
50 | }
51 |
52 | /**
53 | * Generated from protobuf field bytes payload = 2;
54 | * @return string
55 | */
56 | public function getPayload()
57 | {
58 | return $this->payload;
59 | }
60 |
61 | /**
62 | * Generated from protobuf field bytes payload = 2;
63 | * @param string $var
64 | * @return $this
65 | */
66 | public function setPayload($var)
67 | {
68 | GPBUtil::checkString($var, False);
69 | $this->payload = $var;
70 |
71 | return $this;
72 | }
73 |
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/src/proto/dist/Corepb/Transaction.php:
--------------------------------------------------------------------------------
1 | corepb.Transaction
13 | */
14 | class Transaction extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field bytes hash = 1;
18 | */
19 | private $hash = '';
20 | /**
21 | * Generated from protobuf field bytes from = 2;
22 | */
23 | private $from = '';
24 | /**
25 | * Generated from protobuf field bytes to = 3;
26 | */
27 | private $to = '';
28 | /**
29 | * Generated from protobuf field bytes value = 4;
30 | */
31 | private $value = '';
32 | /**
33 | * Generated from protobuf field uint64 nonce = 5;
34 | */
35 | private $nonce = 0;
36 | /**
37 | * Generated from protobuf field int64 timestamp = 6;
38 | */
39 | private $timestamp = 0;
40 | /**
41 | * Generated from protobuf field .corepb.Data data = 7;
42 | */
43 | private $data = null;
44 | /**
45 | * Generated from protobuf field uint32 chain_id = 8;
46 | */
47 | private $chain_id = 0;
48 | /**
49 | * Generated from protobuf field bytes gas_price = 9;
50 | */
51 | private $gas_price = '';
52 | /**
53 | * Generated from protobuf field bytes gas_limit = 10;
54 | */
55 | private $gas_limit = '';
56 | /**
57 | * Generated from protobuf field uint32 alg = 11;
58 | */
59 | private $alg = 0;
60 | /**
61 | * Generated from protobuf field bytes sign = 12;
62 | */
63 | private $sign = '';
64 |
65 | public function __construct() {
66 | \GPBMetadata\Transaction::initOnce();
67 | parent::__construct();
68 | }
69 |
70 | /**
71 | * Generated from protobuf field bytes hash = 1;
72 | * @return string
73 | */
74 | public function getHash()
75 | {
76 | return $this->hash;
77 | }
78 |
79 | /**
80 | * Generated from protobuf field bytes hash = 1;
81 | * @param string $var
82 | * @return $this
83 | */
84 | public function setHash($var)
85 | {
86 | GPBUtil::checkString($var, False);
87 | $this->hash = $var;
88 |
89 | return $this;
90 | }
91 |
92 | /**
93 | * Generated from protobuf field bytes from = 2;
94 | * @return string
95 | */
96 | public function getFrom()
97 | {
98 | return $this->from;
99 | }
100 |
101 | /**
102 | * Generated from protobuf field bytes from = 2;
103 | * @param string $var
104 | * @return $this
105 | */
106 | public function setFrom($var)
107 | {
108 | GPBUtil::checkString($var, False);
109 | $this->from = $var;
110 |
111 | return $this;
112 | }
113 |
114 | /**
115 | * Generated from protobuf field bytes to = 3;
116 | * @return string
117 | */
118 | public function getTo()
119 | {
120 | return $this->to;
121 | }
122 |
123 | /**
124 | * Generated from protobuf field bytes to = 3;
125 | * @param string $var
126 | * @return $this
127 | */
128 | public function setTo($var)
129 | {
130 | GPBUtil::checkString($var, False);
131 | $this->to = $var;
132 |
133 | return $this;
134 | }
135 |
136 | /**
137 | * Generated from protobuf field bytes value = 4;
138 | * @return string
139 | */
140 | public function getValue()
141 | {
142 | return $this->value;
143 | }
144 |
145 | /**
146 | * Generated from protobuf field bytes value = 4;
147 | * @param string $var
148 | * @return $this
149 | */
150 | public function setValue($var)
151 | {
152 | GPBUtil::checkString($var, False);
153 | $this->value = $var;
154 |
155 | return $this;
156 | }
157 |
158 | /**
159 | * Generated from protobuf field uint64 nonce = 5;
160 | * @return int|string
161 | */
162 | public function getNonce()
163 | {
164 | return $this->nonce;
165 | }
166 |
167 | /**
168 | * Generated from protobuf field uint64 nonce = 5;
169 | * @param int|string $var
170 | * @return $this
171 | */
172 | public function setNonce($var)
173 | {
174 | GPBUtil::checkUint64($var);
175 | $this->nonce = $var;
176 |
177 | return $this;
178 | }
179 |
180 | /**
181 | * Generated from protobuf field int64 timestamp = 6;
182 | * @return int|string
183 | */
184 | public function getTimestamp()
185 | {
186 | return $this->timestamp;
187 | }
188 |
189 | /**
190 | * Generated from protobuf field int64 timestamp = 6;
191 | * @param int|string $var
192 | * @return $this
193 | */
194 | public function setTimestamp($var)
195 | {
196 | GPBUtil::checkInt64($var);
197 | $this->timestamp = $var;
198 |
199 | return $this;
200 | }
201 |
202 | /**
203 | * Generated from protobuf field .corepb.Data data = 7;
204 | * @return \Corepb\Data
205 | */
206 | public function getData()
207 | {
208 | return $this->data;
209 | }
210 |
211 | /**
212 | * Generated from protobuf field .corepb.Data data = 7;
213 | * @param \Corepb\Data $var
214 | * @return $this
215 | */
216 | public function setData($var)
217 | {
218 | GPBUtil::checkMessage($var, \Corepb\Data::class);
219 | $this->data = $var;
220 |
221 | return $this;
222 | }
223 |
224 | /**
225 | * Generated from protobuf field uint32 chain_id = 8;
226 | * @return int
227 | */
228 | public function getChainId()
229 | {
230 | return $this->chain_id;
231 | }
232 |
233 | /**
234 | * Generated from protobuf field uint32 chain_id = 8;
235 | * @param int $var
236 | * @return $this
237 | */
238 | public function setChainId($var)
239 | {
240 | GPBUtil::checkUint32($var);
241 | $this->chain_id = $var;
242 |
243 | return $this;
244 | }
245 |
246 | /**
247 | * Generated from protobuf field bytes gas_price = 9;
248 | * @return string
249 | */
250 | public function getGasPrice()
251 | {
252 | return $this->gas_price;
253 | }
254 |
255 | /**
256 | * Generated from protobuf field bytes gas_price = 9;
257 | * @param string $var
258 | * @return $this
259 | */
260 | public function setGasPrice($var)
261 | {
262 | GPBUtil::checkString($var, False);
263 | $this->gas_price = $var;
264 |
265 | return $this;
266 | }
267 |
268 | /**
269 | * Generated from protobuf field bytes gas_limit = 10;
270 | * @return string
271 | */
272 | public function getGasLimit()
273 | {
274 | return $this->gas_limit;
275 | }
276 |
277 | /**
278 | * Generated from protobuf field bytes gas_limit = 10;
279 | * @param string $var
280 | * @return $this
281 | */
282 | public function setGasLimit($var)
283 | {
284 | GPBUtil::checkString($var, False);
285 | $this->gas_limit = $var;
286 |
287 | return $this;
288 | }
289 |
290 | /**
291 | * Generated from protobuf field uint32 alg = 11;
292 | * @return int
293 | */
294 | public function getAlg()
295 | {
296 | return $this->alg;
297 | }
298 |
299 | /**
300 | * Generated from protobuf field uint32 alg = 11;
301 | * @param int $var
302 | * @return $this
303 | */
304 | public function setAlg($var)
305 | {
306 | GPBUtil::checkUint32($var);
307 | $this->alg = $var;
308 |
309 | return $this;
310 | }
311 |
312 | /**
313 | * Generated from protobuf field bytes sign = 12;
314 | * @return string
315 | */
316 | public function getSign()
317 | {
318 | return $this->sign;
319 | }
320 |
321 | /**
322 | * Generated from protobuf field bytes sign = 12;
323 | * @param string $var
324 | * @return $this
325 | */
326 | public function setSign($var)
327 | {
328 | GPBUtil::checkString($var, False);
329 | $this->sign = $var;
330 |
331 | return $this;
332 | }
333 |
334 | }
335 |
336 |
--------------------------------------------------------------------------------
/src/proto/dist/GPBMetadata/Transaction.php:
--------------------------------------------------------------------------------
1 | internalAddGeneratedFile(hex2bin(
18 | "0aaa020a117472616e73616374696f6e2e70726f746f1206636f72657062" .
19 | "222d0a044461746112140a0c7061796c6f61645f74797065180120012809" .
20 | "120f0a077061796c6f616418022001280c22d5010a0b5472616e73616374" .
21 | "696f6e120c0a046861736818012001280c120c0a0466726f6d1802200128" .
22 | "0c120a0a02746f18032001280c120d0a0576616c756518042001280c120d" .
23 | "0a056e6f6e636518052001280412110a0974696d657374616d7018062001" .
24 | "2803121a0a046461746118072001280b320c2e636f726570622e44617461" .
25 | "12100a08636861696e5f696418082001280d12110a096761735f70726963" .
26 | "6518092001280c12110a096761735f6c696d6974180a2001280c120b0a03" .
27 | "616c67180b2001280d120c0a047369676e180c2001280c620670726f746f" .
28 | "33"
29 | ));
30 |
31 | static::$is_initialized = true;
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/AccountsResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.AccountsResponse
15 | */
16 | class AccountsResponse extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Account list
20 | *
21 | * Generated from protobuf field repeated string addresses = 1;
22 | */
23 | private $addresses;
24 |
25 | public function __construct() {
26 | \GPBMetadata\Rpc::initOnce();
27 | parent::__construct();
28 | }
29 |
30 | /**
31 | * Account list
32 | *
33 | * Generated from protobuf field repeated string addresses = 1;
34 | * @return \Google\Protobuf\Internal\RepeatedField
35 | */
36 | public function getAddresses()
37 | {
38 | return $this->addresses;
39 | }
40 |
41 | /**
42 | * Account list
43 | *
44 | * Generated from protobuf field repeated string addresses = 1;
45 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var
46 | * @return $this
47 | */
48 | public function setAddresses($var)
49 | {
50 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
51 | $this->addresses = $arr;
52 |
53 | return $this;
54 | }
55 |
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/ByBlockHeightRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.ByBlockHeightRequest
15 | */
16 | class ByBlockHeightRequest extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Generated from protobuf field uint64 height = 1;
20 | */
21 | private $height = 0;
22 |
23 | public function __construct() {
24 | \GPBMetadata\Rpc::initOnce();
25 | parent::__construct();
26 | }
27 |
28 | /**
29 | * Generated from protobuf field uint64 height = 1;
30 | * @return int|string
31 | */
32 | public function getHeight()
33 | {
34 | return $this->height;
35 | }
36 |
37 | /**
38 | * Generated from protobuf field uint64 height = 1;
39 | * @param int|string $var
40 | * @return $this
41 | */
42 | public function setHeight($var)
43 | {
44 | GPBUtil::checkUint64($var);
45 | $this->height = $var;
46 |
47 | return $this;
48 | }
49 |
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/CallResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.CallResponse
15 | */
16 | class CallResponse extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * result of smart contract method call.
20 | *
21 | * Generated from protobuf field string result = 1;
22 | */
23 | private $result = '';
24 | /**
25 | *execute error
26 | *
27 | * Generated from protobuf field string execute_err = 2;
28 | */
29 | private $execute_err = '';
30 | /**
31 | *estimate gas used
32 | *
33 | * Generated from protobuf field string estimate_gas = 3;
34 | */
35 | private $estimate_gas = '';
36 |
37 | public function __construct() {
38 | \GPBMetadata\Rpc::initOnce();
39 | parent::__construct();
40 | }
41 |
42 | /**
43 | * result of smart contract method call.
44 | *
45 | * Generated from protobuf field string result = 1;
46 | * @return string
47 | */
48 | public function getResult()
49 | {
50 | return $this->result;
51 | }
52 |
53 | /**
54 | * result of smart contract method call.
55 | *
56 | * Generated from protobuf field string result = 1;
57 | * @param string $var
58 | * @return $this
59 | */
60 | public function setResult($var)
61 | {
62 | GPBUtil::checkString($var, True);
63 | $this->result = $var;
64 |
65 | return $this;
66 | }
67 |
68 | /**
69 | *execute error
70 | *
71 | * Generated from protobuf field string execute_err = 2;
72 | * @return string
73 | */
74 | public function getExecuteErr()
75 | {
76 | return $this->execute_err;
77 | }
78 |
79 | /**
80 | *execute error
81 | *
82 | * Generated from protobuf field string execute_err = 2;
83 | * @param string $var
84 | * @return $this
85 | */
86 | public function setExecuteErr($var)
87 | {
88 | GPBUtil::checkString($var, True);
89 | $this->execute_err = $var;
90 |
91 | return $this;
92 | }
93 |
94 | /**
95 | *estimate gas used
96 | *
97 | * Generated from protobuf field string estimate_gas = 3;
98 | * @return string
99 | */
100 | public function getEstimateGas()
101 | {
102 | return $this->estimate_gas;
103 | }
104 |
105 | /**
106 | *estimate gas used
107 | *
108 | * Generated from protobuf field string estimate_gas = 3;
109 | * @param string $var
110 | * @return $this
111 | */
112 | public function setEstimateGas($var)
113 | {
114 | GPBUtil::checkString($var, True);
115 | $this->estimate_gas = $var;
116 |
117 | return $this;
118 | }
119 |
120 | }
121 |
122 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/ConsensusRoot.php:
--------------------------------------------------------------------------------
1 | rpcpb.ConsensusRoot
13 | */
14 | class ConsensusRoot extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field int64 timestamp = 1;
18 | */
19 | private $timestamp = 0;
20 | /**
21 | * Generated from protobuf field bytes proposer = 2;
22 | */
23 | private $proposer = '';
24 | /**
25 | * Generated from protobuf field bytes dynasty_root = 3;
26 | */
27 | private $dynasty_root = '';
28 |
29 | public function __construct() {
30 | \GPBMetadata\Rpc::initOnce();
31 | parent::__construct();
32 | }
33 |
34 | /**
35 | * Generated from protobuf field int64 timestamp = 1;
36 | * @return int|string
37 | */
38 | public function getTimestamp()
39 | {
40 | return $this->timestamp;
41 | }
42 |
43 | /**
44 | * Generated from protobuf field int64 timestamp = 1;
45 | * @param int|string $var
46 | * @return $this
47 | */
48 | public function setTimestamp($var)
49 | {
50 | GPBUtil::checkInt64($var);
51 | $this->timestamp = $var;
52 |
53 | return $this;
54 | }
55 |
56 | /**
57 | * Generated from protobuf field bytes proposer = 2;
58 | * @return string
59 | */
60 | public function getProposer()
61 | {
62 | return $this->proposer;
63 | }
64 |
65 | /**
66 | * Generated from protobuf field bytes proposer = 2;
67 | * @param string $var
68 | * @return $this
69 | */
70 | public function setProposer($var)
71 | {
72 | GPBUtil::checkString($var, False);
73 | $this->proposer = $var;
74 |
75 | return $this;
76 | }
77 |
78 | /**
79 | * Generated from protobuf field bytes dynasty_root = 3;
80 | * @return string
81 | */
82 | public function getDynastyRoot()
83 | {
84 | return $this->dynasty_root;
85 | }
86 |
87 | /**
88 | * Generated from protobuf field bytes dynasty_root = 3;
89 | * @param string $var
90 | * @return $this
91 | */
92 | public function setDynastyRoot($var)
93 | {
94 | GPBUtil::checkString($var, False);
95 | $this->dynasty_root = $var;
96 |
97 | return $this;
98 | }
99 |
100 | }
101 |
102 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/ContractRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.ContractRequest
13 | */
14 | class ContractRequest extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * contract source code.
18 | *
19 | * Generated from protobuf field string source = 1;
20 | */
21 | private $source = '';
22 | /**
23 | * contract source type, support javascript and typescript
24 | *
25 | * Generated from protobuf field string source_type = 2;
26 | */
27 | private $source_type = '';
28 | /**
29 | * call contract function name
30 | *
31 | * Generated from protobuf field string function = 3;
32 | */
33 | private $function = '';
34 | /**
35 | * the params of contract.
36 | *
37 | * Generated from protobuf field string args = 4;
38 | */
39 | private $args = '';
40 |
41 | public function __construct() {
42 | \GPBMetadata\Rpc::initOnce();
43 | parent::__construct();
44 | }
45 |
46 | /**
47 | * contract source code.
48 | *
49 | * Generated from protobuf field string source = 1;
50 | * @return string
51 | */
52 | public function getSource()
53 | {
54 | return $this->source;
55 | }
56 |
57 | /**
58 | * contract source code.
59 | *
60 | * Generated from protobuf field string source = 1;
61 | * @param string $var
62 | * @return $this
63 | */
64 | public function setSource($var)
65 | {
66 | GPBUtil::checkString($var, True);
67 | $this->source = $var;
68 |
69 | return $this;
70 | }
71 |
72 | /**
73 | * contract source type, support javascript and typescript
74 | *
75 | * Generated from protobuf field string source_type = 2;
76 | * @return string
77 | */
78 | public function getSourceType()
79 | {
80 | return $this->source_type;
81 | }
82 |
83 | /**
84 | * contract source type, support javascript and typescript
85 | *
86 | * Generated from protobuf field string source_type = 2;
87 | * @param string $var
88 | * @return $this
89 | */
90 | public function setSourceType($var)
91 | {
92 | GPBUtil::checkString($var, True);
93 | $this->source_type = $var;
94 |
95 | return $this;
96 | }
97 |
98 | /**
99 | * call contract function name
100 | *
101 | * Generated from protobuf field string function = 3;
102 | * @return string
103 | */
104 | public function getFunction()
105 | {
106 | return $this->function;
107 | }
108 |
109 | /**
110 | * call contract function name
111 | *
112 | * Generated from protobuf field string function = 3;
113 | * @param string $var
114 | * @return $this
115 | */
116 | public function setFunction($var)
117 | {
118 | GPBUtil::checkString($var, True);
119 | $this->function = $var;
120 |
121 | return $this;
122 | }
123 |
124 | /**
125 | * the params of contract.
126 | *
127 | * Generated from protobuf field string args = 4;
128 | * @return string
129 | */
130 | public function getArgs()
131 | {
132 | return $this->args;
133 | }
134 |
135 | /**
136 | * the params of contract.
137 | *
138 | * Generated from protobuf field string args = 4;
139 | * @param string $var
140 | * @return $this
141 | */
142 | public function setArgs($var)
143 | {
144 | GPBUtil::checkString($var, True);
145 | $this->args = $var;
146 |
147 | return $this;
148 | }
149 |
150 | }
151 |
152 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/Event.php:
--------------------------------------------------------------------------------
1 | rpcpb.Event
13 | */
14 | class Event extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field string topic = 1;
18 | */
19 | private $topic = '';
20 | /**
21 | * Generated from protobuf field string data = 2;
22 | */
23 | private $data = '';
24 |
25 | public function __construct() {
26 | \GPBMetadata\Rpc::initOnce();
27 | parent::__construct();
28 | }
29 |
30 | /**
31 | * Generated from protobuf field string topic = 1;
32 | * @return string
33 | */
34 | public function getTopic()
35 | {
36 | return $this->topic;
37 | }
38 |
39 | /**
40 | * Generated from protobuf field string topic = 1;
41 | * @param string $var
42 | * @return $this
43 | */
44 | public function setTopic($var)
45 | {
46 | GPBUtil::checkString($var, True);
47 | $this->topic = $var;
48 |
49 | return $this;
50 | }
51 |
52 | /**
53 | * Generated from protobuf field string data = 2;
54 | * @return string
55 | */
56 | public function getData()
57 | {
58 | return $this->data;
59 | }
60 |
61 | /**
62 | * Generated from protobuf field string data = 2;
63 | * @param string $var
64 | * @return $this
65 | */
66 | public function setData($var)
67 | {
68 | GPBUtil::checkString($var, True);
69 | $this->data = $var;
70 |
71 | return $this;
72 | }
73 |
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/EventsResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.EventsResponse
13 | */
14 | class EventsResponse extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field repeated .rpcpb.Event events = 1;
18 | */
19 | private $events;
20 |
21 | public function __construct() {
22 | \GPBMetadata\Rpc::initOnce();
23 | parent::__construct();
24 | }
25 |
26 | /**
27 | * Generated from protobuf field repeated .rpcpb.Event events = 1;
28 | * @return \Google\Protobuf\Internal\RepeatedField
29 | */
30 | public function getEvents()
31 | {
32 | return $this->events;
33 | }
34 |
35 | /**
36 | * Generated from protobuf field repeated .rpcpb.Event events = 1;
37 | * @param \Rpcpb\Event[]|\Google\Protobuf\Internal\RepeatedField $var
38 | * @return $this
39 | */
40 | public function setEvents($var)
41 | {
42 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Rpcpb\Event::class);
43 | $this->events = $arr;
44 |
45 | return $this;
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/GasPriceResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.GasPriceResponse
13 | */
14 | class GasPriceResponse extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field string gas_price = 1;
18 | */
19 | private $gas_price = '';
20 |
21 | public function __construct() {
22 | \GPBMetadata\Rpc::initOnce();
23 | parent::__construct();
24 | }
25 |
26 | /**
27 | * Generated from protobuf field string gas_price = 1;
28 | * @return string
29 | */
30 | public function getGasPrice()
31 | {
32 | return $this->gas_price;
33 | }
34 |
35 | /**
36 | * Generated from protobuf field string gas_price = 1;
37 | * @param string $var
38 | * @return $this
39 | */
40 | public function setGasPrice($var)
41 | {
42 | GPBUtil::checkString($var, True);
43 | $this->gas_price = $var;
44 |
45 | return $this;
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/GasResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.GasResponse
13 | */
14 | class GasResponse extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field string gas = 1;
18 | */
19 | private $gas = '';
20 | /**
21 | * Generated from protobuf field string err = 2;
22 | */
23 | private $err = '';
24 |
25 | public function __construct() {
26 | \GPBMetadata\Rpc::initOnce();
27 | parent::__construct();
28 | }
29 |
30 | /**
31 | * Generated from protobuf field string gas = 1;
32 | * @return string
33 | */
34 | public function getGas()
35 | {
36 | return $this->gas;
37 | }
38 |
39 | /**
40 | * Generated from protobuf field string gas = 1;
41 | * @param string $var
42 | * @return $this
43 | */
44 | public function setGas($var)
45 | {
46 | GPBUtil::checkString($var, True);
47 | $this->gas = $var;
48 |
49 | return $this;
50 | }
51 |
52 | /**
53 | * Generated from protobuf field string err = 2;
54 | * @return string
55 | */
56 | public function getErr()
57 | {
58 | return $this->err;
59 | }
60 |
61 | /**
62 | * Generated from protobuf field string err = 2;
63 | * @param string $var
64 | * @return $this
65 | */
66 | public function setErr($var)
67 | {
68 | GPBUtil::checkString($var, True);
69 | $this->err = $var;
70 |
71 | return $this;
72 | }
73 |
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/GetAccountStateRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.GetAccountStateRequest
15 | */
16 | class GetAccountStateRequest extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Hex string of the account addresss.
20 | *
21 | * Generated from protobuf field string address = 1;
22 | */
23 | private $address = '';
24 | /**
25 | * block account state with height. If not specified, use 0 as tail height.
26 | *
27 | * Generated from protobuf field uint64 height = 2;
28 | */
29 | private $height = 0;
30 |
31 | public function __construct() {
32 | \GPBMetadata\Rpc::initOnce();
33 | parent::__construct();
34 | }
35 |
36 | /**
37 | * Hex string of the account addresss.
38 | *
39 | * Generated from protobuf field string address = 1;
40 | * @return string
41 | */
42 | public function getAddress()
43 | {
44 | return $this->address;
45 | }
46 |
47 | /**
48 | * Hex string of the account addresss.
49 | *
50 | * Generated from protobuf field string address = 1;
51 | * @param string $var
52 | * @return $this
53 | */
54 | public function setAddress($var)
55 | {
56 | GPBUtil::checkString($var, True);
57 | $this->address = $var;
58 |
59 | return $this;
60 | }
61 |
62 | /**
63 | * block account state with height. If not specified, use 0 as tail height.
64 | *
65 | * Generated from protobuf field uint64 height = 2;
66 | * @return int|string
67 | */
68 | public function getHeight()
69 | {
70 | return $this->height;
71 | }
72 |
73 | /**
74 | * block account state with height. If not specified, use 0 as tail height.
75 | *
76 | * Generated from protobuf field uint64 height = 2;
77 | * @param int|string $var
78 | * @return $this
79 | */
80 | public function setHeight($var)
81 | {
82 | GPBUtil::checkUint64($var);
83 | $this->height = $var;
84 |
85 | return $this;
86 | }
87 |
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/GetAccountStateResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.GetAccountStateResponse
15 | */
16 | class GetAccountStateResponse extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Current balance in unit of 1/(10^18) nas.
20 | *
21 | * Generated from protobuf field string balance = 1;
22 | */
23 | private $balance = '';
24 | /**
25 | * Current transaction count.
26 | *
27 | * Generated from protobuf field uint64 nonce = 2;
28 | */
29 | private $nonce = 0;
30 | /**
31 | * Account type
32 | *
33 | * Generated from protobuf field uint32 type = 3;
34 | */
35 | private $type = 0;
36 |
37 | public function __construct() {
38 | \GPBMetadata\Rpc::initOnce();
39 | parent::__construct();
40 | }
41 |
42 | /**
43 | * Current balance in unit of 1/(10^18) nas.
44 | *
45 | * Generated from protobuf field string balance = 1;
46 | * @return string
47 | */
48 | public function getBalance()
49 | {
50 | return $this->balance;
51 | }
52 |
53 | /**
54 | * Current balance in unit of 1/(10^18) nas.
55 | *
56 | * Generated from protobuf field string balance = 1;
57 | * @param string $var
58 | * @return $this
59 | */
60 | public function setBalance($var)
61 | {
62 | GPBUtil::checkString($var, True);
63 | $this->balance = $var;
64 |
65 | return $this;
66 | }
67 |
68 | /**
69 | * Current transaction count.
70 | *
71 | * Generated from protobuf field uint64 nonce = 2;
72 | * @return int|string
73 | */
74 | public function getNonce()
75 | {
76 | return $this->nonce;
77 | }
78 |
79 | /**
80 | * Current transaction count.
81 | *
82 | * Generated from protobuf field uint64 nonce = 2;
83 | * @param int|string $var
84 | * @return $this
85 | */
86 | public function setNonce($var)
87 | {
88 | GPBUtil::checkUint64($var);
89 | $this->nonce = $var;
90 |
91 | return $this;
92 | }
93 |
94 | /**
95 | * Account type
96 | *
97 | * Generated from protobuf field uint32 type = 3;
98 | * @return int
99 | */
100 | public function getType()
101 | {
102 | return $this->type;
103 | }
104 |
105 | /**
106 | * Account type
107 | *
108 | * Generated from protobuf field uint32 type = 3;
109 | * @param int $var
110 | * @return $this
111 | */
112 | public function setType($var)
113 | {
114 | GPBUtil::checkUint32($var);
115 | $this->type = $var;
116 |
117 | return $this;
118 | }
119 |
120 | }
121 |
122 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/GetBlockByHashRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.GetBlockByHashRequest
15 | */
16 | class GetBlockByHashRequest extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Hex string of block hash.
20 | *
21 | * Generated from protobuf field string hash = 1;
22 | */
23 | private $hash = '';
24 | /**
25 | * If true it returns the full transaction objects, if false only the hashes of the transactions.
26 | *
27 | * Generated from protobuf field bool full_fill_transaction = 2;
28 | */
29 | private $full_fill_transaction = false;
30 |
31 | public function __construct() {
32 | \GPBMetadata\Rpc::initOnce();
33 | parent::__construct();
34 | }
35 |
36 | /**
37 | * Hex string of block hash.
38 | *
39 | * Generated from protobuf field string hash = 1;
40 | * @return string
41 | */
42 | public function getHash()
43 | {
44 | return $this->hash;
45 | }
46 |
47 | /**
48 | * Hex string of block hash.
49 | *
50 | * Generated from protobuf field string hash = 1;
51 | * @param string $var
52 | * @return $this
53 | */
54 | public function setHash($var)
55 | {
56 | GPBUtil::checkString($var, True);
57 | $this->hash = $var;
58 |
59 | return $this;
60 | }
61 |
62 | /**
63 | * If true it returns the full transaction objects, if false only the hashes of the transactions.
64 | *
65 | * Generated from protobuf field bool full_fill_transaction = 2;
66 | * @return bool
67 | */
68 | public function getFullFillTransaction()
69 | {
70 | return $this->full_fill_transaction;
71 | }
72 |
73 | /**
74 | * If true it returns the full transaction objects, if false only the hashes of the transactions.
75 | *
76 | * Generated from protobuf field bool full_fill_transaction = 2;
77 | * @param bool $var
78 | * @return $this
79 | */
80 | public function setFullFillTransaction($var)
81 | {
82 | GPBUtil::checkBool($var);
83 | $this->full_fill_transaction = $var;
84 |
85 | return $this;
86 | }
87 |
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/GetBlockByHeightRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.GetBlockByHeightRequest
15 | */
16 | class GetBlockByHeightRequest extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * block height.
20 | *
21 | * Generated from protobuf field uint64 height = 1;
22 | */
23 | private $height = 0;
24 | /**
25 | * If true it returns the full transaction objects, if false only the hashes of the transactions.
26 | *
27 | * Generated from protobuf field bool full_fill_transaction = 2;
28 | */
29 | private $full_fill_transaction = false;
30 |
31 | public function __construct() {
32 | \GPBMetadata\Rpc::initOnce();
33 | parent::__construct();
34 | }
35 |
36 | /**
37 | * block height.
38 | *
39 | * Generated from protobuf field uint64 height = 1;
40 | * @return int|string
41 | */
42 | public function getHeight()
43 | {
44 | return $this->height;
45 | }
46 |
47 | /**
48 | * block height.
49 | *
50 | * Generated from protobuf field uint64 height = 1;
51 | * @param int|string $var
52 | * @return $this
53 | */
54 | public function setHeight($var)
55 | {
56 | GPBUtil::checkUint64($var);
57 | $this->height = $var;
58 |
59 | return $this;
60 | }
61 |
62 | /**
63 | * If true it returns the full transaction objects, if false only the hashes of the transactions.
64 | *
65 | * Generated from protobuf field bool full_fill_transaction = 2;
66 | * @return bool
67 | */
68 | public function getFullFillTransaction()
69 | {
70 | return $this->full_fill_transaction;
71 | }
72 |
73 | /**
74 | * If true it returns the full transaction objects, if false only the hashes of the transactions.
75 | *
76 | * Generated from protobuf field bool full_fill_transaction = 2;
77 | * @param bool $var
78 | * @return $this
79 | */
80 | public function setFullFillTransaction($var)
81 | {
82 | GPBUtil::checkBool($var);
83 | $this->full_fill_transaction = $var;
84 |
85 | return $this;
86 | }
87 |
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/GetDynastyResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.GetDynastyResponse
15 | */
16 | class GetDynastyResponse extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Generated from protobuf field repeated string miners = 1;
20 | */
21 | private $miners;
22 |
23 | public function __construct() {
24 | \GPBMetadata\Rpc::initOnce();
25 | parent::__construct();
26 | }
27 |
28 | /**
29 | * Generated from protobuf field repeated string miners = 1;
30 | * @return \Google\Protobuf\Internal\RepeatedField
31 | */
32 | public function getMiners()
33 | {
34 | return $this->miners;
35 | }
36 |
37 | /**
38 | * Generated from protobuf field repeated string miners = 1;
39 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var
40 | * @return $this
41 | */
42 | public function setMiners($var)
43 | {
44 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
45 | $this->miners = $arr;
46 |
47 | return $this;
48 | }
49 |
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/GetNebStateResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.GetNebStateResponse
15 | */
16 | class GetNebStateResponse extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Block chain id
20 | *
21 | * Generated from protobuf field uint32 chain_id = 1;
22 | */
23 | private $chain_id = 0;
24 | /**
25 | * Current neb tail hash
26 | *
27 | * Generated from protobuf field string tail = 2;
28 | */
29 | private $tail = '';
30 | /**
31 | * Current neb lib hash
32 | *
33 | * Generated from protobuf field string lib = 3;
34 | */
35 | private $lib = '';
36 | /**
37 | * Current neb tail block height
38 | *
39 | * Generated from protobuf field uint64 height = 4;
40 | */
41 | private $height = 0;
42 | /**
43 | * The current neb protocol version.
44 | *
45 | * Generated from protobuf field string protocol_version = 6;
46 | */
47 | private $protocol_version = '';
48 | /**
49 | * The peer sync status.
50 | *
51 | * Generated from protobuf field bool synchronized = 7;
52 | */
53 | private $synchronized = false;
54 | /**
55 | * neb version
56 | *
57 | * Generated from protobuf field string version = 8;
58 | */
59 | private $version = '';
60 |
61 | public function __construct() {
62 | \GPBMetadata\Rpc::initOnce();
63 | parent::__construct();
64 | }
65 |
66 | /**
67 | * Block chain id
68 | *
69 | * Generated from protobuf field uint32 chain_id = 1;
70 | * @return int
71 | */
72 | public function getChainId()
73 | {
74 | return $this->chain_id;
75 | }
76 |
77 | /**
78 | * Block chain id
79 | *
80 | * Generated from protobuf field uint32 chain_id = 1;
81 | * @param int $var
82 | * @return $this
83 | */
84 | public function setChainId($var)
85 | {
86 | GPBUtil::checkUint32($var);
87 | $this->chain_id = $var;
88 |
89 | return $this;
90 | }
91 |
92 | /**
93 | * Current neb tail hash
94 | *
95 | * Generated from protobuf field string tail = 2;
96 | * @return string
97 | */
98 | public function getTail()
99 | {
100 | return $this->tail;
101 | }
102 |
103 | /**
104 | * Current neb tail hash
105 | *
106 | * Generated from protobuf field string tail = 2;
107 | * @param string $var
108 | * @return $this
109 | */
110 | public function setTail($var)
111 | {
112 | GPBUtil::checkString($var, True);
113 | $this->tail = $var;
114 |
115 | return $this;
116 | }
117 |
118 | /**
119 | * Current neb lib hash
120 | *
121 | * Generated from protobuf field string lib = 3;
122 | * @return string
123 | */
124 | public function getLib()
125 | {
126 | return $this->lib;
127 | }
128 |
129 | /**
130 | * Current neb lib hash
131 | *
132 | * Generated from protobuf field string lib = 3;
133 | * @param string $var
134 | * @return $this
135 | */
136 | public function setLib($var)
137 | {
138 | GPBUtil::checkString($var, True);
139 | $this->lib = $var;
140 |
141 | return $this;
142 | }
143 |
144 | /**
145 | * Current neb tail block height
146 | *
147 | * Generated from protobuf field uint64 height = 4;
148 | * @return int|string
149 | */
150 | public function getHeight()
151 | {
152 | return $this->height;
153 | }
154 |
155 | /**
156 | * Current neb tail block height
157 | *
158 | * Generated from protobuf field uint64 height = 4;
159 | * @param int|string $var
160 | * @return $this
161 | */
162 | public function setHeight($var)
163 | {
164 | GPBUtil::checkUint64($var);
165 | $this->height = $var;
166 |
167 | return $this;
168 | }
169 |
170 | /**
171 | * The current neb protocol version.
172 | *
173 | * Generated from protobuf field string protocol_version = 6;
174 | * @return string
175 | */
176 | public function getProtocolVersion()
177 | {
178 | return $this->protocol_version;
179 | }
180 |
181 | /**
182 | * The current neb protocol version.
183 | *
184 | * Generated from protobuf field string protocol_version = 6;
185 | * @param string $var
186 | * @return $this
187 | */
188 | public function setProtocolVersion($var)
189 | {
190 | GPBUtil::checkString($var, True);
191 | $this->protocol_version = $var;
192 |
193 | return $this;
194 | }
195 |
196 | /**
197 | * The peer sync status.
198 | *
199 | * Generated from protobuf field bool synchronized = 7;
200 | * @return bool
201 | */
202 | public function getSynchronized()
203 | {
204 | return $this->synchronized;
205 | }
206 |
207 | /**
208 | * The peer sync status.
209 | *
210 | * Generated from protobuf field bool synchronized = 7;
211 | * @param bool $var
212 | * @return $this
213 | */
214 | public function setSynchronized($var)
215 | {
216 | GPBUtil::checkBool($var);
217 | $this->synchronized = $var;
218 |
219 | return $this;
220 | }
221 |
222 | /**
223 | * neb version
224 | *
225 | * Generated from protobuf field string version = 8;
226 | * @return string
227 | */
228 | public function getVersion()
229 | {
230 | return $this->version;
231 | }
232 |
233 | /**
234 | * neb version
235 | *
236 | * Generated from protobuf field string version = 8;
237 | * @param string $var
238 | * @return $this
239 | */
240 | public function setVersion($var)
241 | {
242 | GPBUtil::checkString($var, True);
243 | $this->version = $var;
244 |
245 | return $this;
246 | }
247 |
248 | }
249 |
250 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/GetTransactionByHashRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.GetTransactionByHashRequest
15 | */
16 | class GetTransactionByHashRequest extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Hex string of transaction hash.
20 | *
21 | * Generated from protobuf field string hash = 1;
22 | */
23 | private $hash = '';
24 |
25 | public function __construct() {
26 | \GPBMetadata\Rpc::initOnce();
27 | parent::__construct();
28 | }
29 |
30 | /**
31 | * Hex string of transaction hash.
32 | *
33 | * Generated from protobuf field string hash = 1;
34 | * @return string
35 | */
36 | public function getHash()
37 | {
38 | return $this->hash;
39 | }
40 |
41 | /**
42 | * Hex string of transaction hash.
43 | *
44 | * Generated from protobuf field string hash = 1;
45 | * @param string $var
46 | * @return $this
47 | */
48 | public function setHash($var)
49 | {
50 | GPBUtil::checkString($var, True);
51 | $this->hash = $var;
52 |
53 | return $this;
54 | }
55 |
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/HashRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.HashRequest
15 | */
16 | class HashRequest extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Hex string of block/transaction hash.
20 | *
21 | * Generated from protobuf field string hash = 1;
22 | */
23 | private $hash = '';
24 |
25 | public function __construct() {
26 | \GPBMetadata\Rpc::initOnce();
27 | parent::__construct();
28 | }
29 |
30 | /**
31 | * Hex string of block/transaction hash.
32 | *
33 | * Generated from protobuf field string hash = 1;
34 | * @return string
35 | */
36 | public function getHash()
37 | {
38 | return $this->hash;
39 | }
40 |
41 | /**
42 | * Hex string of block/transaction hash.
43 | *
44 | * Generated from protobuf field string hash = 1;
45 | * @param string $var
46 | * @return $this
47 | */
48 | public function setHash($var)
49 | {
50 | GPBUtil::checkString($var, True);
51 | $this->hash = $var;
52 |
53 | return $this;
54 | }
55 |
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/LockAccountRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.LockAccountRequest
13 | */
14 | class LockAccountRequest extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field string address = 1;
18 | */
19 | private $address = '';
20 |
21 | public function __construct() {
22 | \GPBMetadata\Rpc::initOnce();
23 | parent::__construct();
24 | }
25 |
26 | /**
27 | * Generated from protobuf field string address = 1;
28 | * @return string
29 | */
30 | public function getAddress()
31 | {
32 | return $this->address;
33 | }
34 |
35 | /**
36 | * Generated from protobuf field string address = 1;
37 | * @param string $var
38 | * @return $this
39 | */
40 | public function setAddress($var)
41 | {
42 | GPBUtil::checkString($var, True);
43 | $this->address = $var;
44 |
45 | return $this;
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/LockAccountResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.LockAccountResponse
13 | */
14 | class LockAccountResponse extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field bool result = 1;
18 | */
19 | private $result = false;
20 |
21 | public function __construct() {
22 | \GPBMetadata\Rpc::initOnce();
23 | parent::__construct();
24 | }
25 |
26 | /**
27 | * Generated from protobuf field bool result = 1;
28 | * @return bool
29 | */
30 | public function getResult()
31 | {
32 | return $this->result;
33 | }
34 |
35 | /**
36 | * Generated from protobuf field bool result = 1;
37 | * @param bool $var
38 | * @return $this
39 | */
40 | public function setResult($var)
41 | {
42 | GPBUtil::checkBool($var);
43 | $this->result = $var;
44 |
45 | return $this;
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/NewAccountRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.NewAccountRequest
13 | */
14 | class NewAccountRequest extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field string passphrase = 1;
18 | */
19 | private $passphrase = '';
20 |
21 | public function __construct() {
22 | \GPBMetadata\Rpc::initOnce();
23 | parent::__construct();
24 | }
25 |
26 | /**
27 | * Generated from protobuf field string passphrase = 1;
28 | * @return string
29 | */
30 | public function getPassphrase()
31 | {
32 | return $this->passphrase;
33 | }
34 |
35 | /**
36 | * Generated from protobuf field string passphrase = 1;
37 | * @param string $var
38 | * @return $this
39 | */
40 | public function setPassphrase($var)
41 | {
42 | GPBUtil::checkString($var, True);
43 | $this->passphrase = $var;
44 |
45 | return $this;
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/NewAccountResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.NewAccountResponse
13 | */
14 | class NewAccountResponse extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field string address = 1;
18 | */
19 | private $address = '';
20 |
21 | public function __construct() {
22 | \GPBMetadata\Rpc::initOnce();
23 | parent::__construct();
24 | }
25 |
26 | /**
27 | * Generated from protobuf field string address = 1;
28 | * @return string
29 | */
30 | public function getAddress()
31 | {
32 | return $this->address;
33 | }
34 |
35 | /**
36 | * Generated from protobuf field string address = 1;
37 | * @param string $var
38 | * @return $this
39 | */
40 | public function setAddress($var)
41 | {
42 | GPBUtil::checkString($var, True);
43 | $this->address = $var;
44 |
45 | return $this;
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/NodeInfoResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.NodeInfoResponse
15 | */
16 | class NodeInfoResponse extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * the node ID.
20 | *
21 | * Generated from protobuf field string id = 1;
22 | */
23 | private $id = '';
24 | /**
25 | * the block chainID.
26 | *
27 | * Generated from protobuf field uint32 chain_id = 2;
28 | */
29 | private $chain_id = 0;
30 | /**
31 | * coinbase
32 | *
33 | * Generated from protobuf field string coinbase = 3;
34 | */
35 | private $coinbase = '';
36 | /**
37 | * Number of peers currenly connected.
38 | *
39 | * Generated from protobuf field uint32 peer_count = 4;
40 | */
41 | private $peer_count = 0;
42 | /**
43 | * the node synchronized status.
44 | *
45 | * Generated from protobuf field bool synchronized = 5;
46 | */
47 | private $synchronized = false;
48 | /**
49 | * the node route table bucket size.
50 | *
51 | * Generated from protobuf field int32 bucket_size = 6;
52 | */
53 | private $bucket_size = 0;
54 | /**
55 | * the network protocol version.
56 | *
57 | * Generated from protobuf field string protocol_version = 10;
58 | */
59 | private $protocol_version = '';
60 | /**
61 | * Generated from protobuf field repeated .rpcpb.RouteTable route_table = 11;
62 | */
63 | private $route_table;
64 |
65 | public function __construct() {
66 | \GPBMetadata\Rpc::initOnce();
67 | parent::__construct();
68 | }
69 |
70 | /**
71 | * the node ID.
72 | *
73 | * Generated from protobuf field string id = 1;
74 | * @return string
75 | */
76 | public function getId()
77 | {
78 | return $this->id;
79 | }
80 |
81 | /**
82 | * the node ID.
83 | *
84 | * Generated from protobuf field string id = 1;
85 | * @param string $var
86 | * @return $this
87 | */
88 | public function setId($var)
89 | {
90 | GPBUtil::checkString($var, True);
91 | $this->id = $var;
92 |
93 | return $this;
94 | }
95 |
96 | /**
97 | * the block chainID.
98 | *
99 | * Generated from protobuf field uint32 chain_id = 2;
100 | * @return int
101 | */
102 | public function getChainId()
103 | {
104 | return $this->chain_id;
105 | }
106 |
107 | /**
108 | * the block chainID.
109 | *
110 | * Generated from protobuf field uint32 chain_id = 2;
111 | * @param int $var
112 | * @return $this
113 | */
114 | public function setChainId($var)
115 | {
116 | GPBUtil::checkUint32($var);
117 | $this->chain_id = $var;
118 |
119 | return $this;
120 | }
121 |
122 | /**
123 | * coinbase
124 | *
125 | * Generated from protobuf field string coinbase = 3;
126 | * @return string
127 | */
128 | public function getCoinbase()
129 | {
130 | return $this->coinbase;
131 | }
132 |
133 | /**
134 | * coinbase
135 | *
136 | * Generated from protobuf field string coinbase = 3;
137 | * @param string $var
138 | * @return $this
139 | */
140 | public function setCoinbase($var)
141 | {
142 | GPBUtil::checkString($var, True);
143 | $this->coinbase = $var;
144 |
145 | return $this;
146 | }
147 |
148 | /**
149 | * Number of peers currenly connected.
150 | *
151 | * Generated from protobuf field uint32 peer_count = 4;
152 | * @return int
153 | */
154 | public function getPeerCount()
155 | {
156 | return $this->peer_count;
157 | }
158 |
159 | /**
160 | * Number of peers currenly connected.
161 | *
162 | * Generated from protobuf field uint32 peer_count = 4;
163 | * @param int $var
164 | * @return $this
165 | */
166 | public function setPeerCount($var)
167 | {
168 | GPBUtil::checkUint32($var);
169 | $this->peer_count = $var;
170 |
171 | return $this;
172 | }
173 |
174 | /**
175 | * the node synchronized status.
176 | *
177 | * Generated from protobuf field bool synchronized = 5;
178 | * @return bool
179 | */
180 | public function getSynchronized()
181 | {
182 | return $this->synchronized;
183 | }
184 |
185 | /**
186 | * the node synchronized status.
187 | *
188 | * Generated from protobuf field bool synchronized = 5;
189 | * @param bool $var
190 | * @return $this
191 | */
192 | public function setSynchronized($var)
193 | {
194 | GPBUtil::checkBool($var);
195 | $this->synchronized = $var;
196 |
197 | return $this;
198 | }
199 |
200 | /**
201 | * the node route table bucket size.
202 | *
203 | * Generated from protobuf field int32 bucket_size = 6;
204 | * @return int
205 | */
206 | public function getBucketSize()
207 | {
208 | return $this->bucket_size;
209 | }
210 |
211 | /**
212 | * the node route table bucket size.
213 | *
214 | * Generated from protobuf field int32 bucket_size = 6;
215 | * @param int $var
216 | * @return $this
217 | */
218 | public function setBucketSize($var)
219 | {
220 | GPBUtil::checkInt32($var);
221 | $this->bucket_size = $var;
222 |
223 | return $this;
224 | }
225 |
226 | /**
227 | * the network protocol version.
228 | *
229 | * Generated from protobuf field string protocol_version = 10;
230 | * @return string
231 | */
232 | public function getProtocolVersion()
233 | {
234 | return $this->protocol_version;
235 | }
236 |
237 | /**
238 | * the network protocol version.
239 | *
240 | * Generated from protobuf field string protocol_version = 10;
241 | * @param string $var
242 | * @return $this
243 | */
244 | public function setProtocolVersion($var)
245 | {
246 | GPBUtil::checkString($var, True);
247 | $this->protocol_version = $var;
248 |
249 | return $this;
250 | }
251 |
252 | /**
253 | * Generated from protobuf field repeated .rpcpb.RouteTable route_table = 11;
254 | * @return \Google\Protobuf\Internal\RepeatedField
255 | */
256 | public function getRouteTable()
257 | {
258 | return $this->route_table;
259 | }
260 |
261 | /**
262 | * Generated from protobuf field repeated .rpcpb.RouteTable route_table = 11;
263 | * @param \Rpcpb\RouteTable[]|\Google\Protobuf\Internal\RepeatedField $var
264 | * @return $this
265 | */
266 | public function setRouteTable($var)
267 | {
268 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Rpcpb\RouteTable::class);
269 | $this->route_table = $arr;
270 |
271 | return $this;
272 | }
273 |
274 | }
275 |
276 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/NonParamsRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.NonParamsRequest
15 | */
16 | class NonParamsRequest extends \Google\Protobuf\Internal\Message
17 | {
18 |
19 | public function __construct() {
20 | \GPBMetadata\Rpc::initOnce();
21 | parent::__construct();
22 | }
23 |
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/PprofRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.PprofRequest
13 | */
14 | class PprofRequest extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field string listen = 1;
18 | */
19 | private $listen = '';
20 |
21 | public function __construct() {
22 | \GPBMetadata\Rpc::initOnce();
23 | parent::__construct();
24 | }
25 |
26 | /**
27 | * Generated from protobuf field string listen = 1;
28 | * @return string
29 | */
30 | public function getListen()
31 | {
32 | return $this->listen;
33 | }
34 |
35 | /**
36 | * Generated from protobuf field string listen = 1;
37 | * @param string $var
38 | * @return $this
39 | */
40 | public function setListen($var)
41 | {
42 | GPBUtil::checkString($var, True);
43 | $this->listen = $var;
44 |
45 | return $this;
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/PprofResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.PprofResponse
13 | */
14 | class PprofResponse extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field bool result = 1;
18 | */
19 | private $result = false;
20 |
21 | public function __construct() {
22 | \GPBMetadata\Rpc::initOnce();
23 | parent::__construct();
24 | }
25 |
26 | /**
27 | * Generated from protobuf field bool result = 1;
28 | * @return bool
29 | */
30 | public function getResult()
31 | {
32 | return $this->result;
33 | }
34 |
35 | /**
36 | * Generated from protobuf field bool result = 1;
37 | * @param bool $var
38 | * @return $this
39 | */
40 | public function setResult($var)
41 | {
42 | GPBUtil::checkBool($var);
43 | $this->result = $var;
44 |
45 | return $this;
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/RouteTable.php:
--------------------------------------------------------------------------------
1 | rpcpb.RouteTable
13 | */
14 | class RouteTable extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field string id = 1;
18 | */
19 | private $id = '';
20 | /**
21 | * Generated from protobuf field repeated string address = 2;
22 | */
23 | private $address;
24 |
25 | public function __construct() {
26 | \GPBMetadata\Rpc::initOnce();
27 | parent::__construct();
28 | }
29 |
30 | /**
31 | * Generated from protobuf field string id = 1;
32 | * @return string
33 | */
34 | public function getId()
35 | {
36 | return $this->id;
37 | }
38 |
39 | /**
40 | * Generated from protobuf field string id = 1;
41 | * @param string $var
42 | * @return $this
43 | */
44 | public function setId($var)
45 | {
46 | GPBUtil::checkString($var, True);
47 | $this->id = $var;
48 |
49 | return $this;
50 | }
51 |
52 | /**
53 | * Generated from protobuf field repeated string address = 2;
54 | * @return \Google\Protobuf\Internal\RepeatedField
55 | */
56 | public function getAddress()
57 | {
58 | return $this->address;
59 | }
60 |
61 | /**
62 | * Generated from protobuf field repeated string address = 2;
63 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var
64 | * @return $this
65 | */
66 | public function setAddress($var)
67 | {
68 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
69 | $this->address = $arr;
70 |
71 | return $this;
72 | }
73 |
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/SendRawTransactionRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.SendRawTransactionRequest
15 | */
16 | class SendRawTransactionRequest extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Signed data of transaction
20 | *
21 | * Generated from protobuf field bytes data = 1;
22 | */
23 | private $data = '';
24 |
25 | public function __construct() {
26 | \GPBMetadata\Rpc::initOnce();
27 | parent::__construct();
28 | }
29 |
30 | /**
31 | * Signed data of transaction
32 | *
33 | * Generated from protobuf field bytes data = 1;
34 | * @return string
35 | */
36 | public function getData()
37 | {
38 | return $this->data;
39 | }
40 |
41 | /**
42 | * Signed data of transaction
43 | *
44 | * Generated from protobuf field bytes data = 1;
45 | * @param string $var
46 | * @return $this
47 | */
48 | public function setData($var)
49 | {
50 | GPBUtil::checkString($var, False);
51 | $this->data = $var;
52 |
53 | return $this;
54 | }
55 |
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/SendTransactionPassphraseRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.SendTransactionPassphraseRequest
13 | */
14 | class SendTransactionPassphraseRequest extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * transaction struct
18 | *
19 | * Generated from protobuf field .rpcpb.TransactionRequest transaction = 1;
20 | */
21 | private $transaction = null;
22 | /**
23 | * from account passphrase
24 | *
25 | * Generated from protobuf field string passphrase = 2;
26 | */
27 | private $passphrase = '';
28 |
29 | public function __construct() {
30 | \GPBMetadata\Rpc::initOnce();
31 | parent::__construct();
32 | }
33 |
34 | /**
35 | * transaction struct
36 | *
37 | * Generated from protobuf field .rpcpb.TransactionRequest transaction = 1;
38 | * @return \Rpcpb\TransactionRequest
39 | */
40 | public function getTransaction()
41 | {
42 | return $this->transaction;
43 | }
44 |
45 | /**
46 | * transaction struct
47 | *
48 | * Generated from protobuf field .rpcpb.TransactionRequest transaction = 1;
49 | * @param \Rpcpb\TransactionRequest $var
50 | * @return $this
51 | */
52 | public function setTransaction($var)
53 | {
54 | GPBUtil::checkMessage($var, \Rpcpb\TransactionRequest::class);
55 | $this->transaction = $var;
56 |
57 | return $this;
58 | }
59 |
60 | /**
61 | * from account passphrase
62 | *
63 | * Generated from protobuf field string passphrase = 2;
64 | * @return string
65 | */
66 | public function getPassphrase()
67 | {
68 | return $this->passphrase;
69 | }
70 |
71 | /**
72 | * from account passphrase
73 | *
74 | * Generated from protobuf field string passphrase = 2;
75 | * @param string $var
76 | * @return $this
77 | */
78 | public function setPassphrase($var)
79 | {
80 | GPBUtil::checkString($var, True);
81 | $this->passphrase = $var;
82 |
83 | return $this;
84 | }
85 |
86 | }
87 |
88 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/SendTransactionResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.SendTransactionResponse
15 | */
16 | class SendTransactionResponse extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Hex string of transaction hash.
20 | *
21 | * Generated from protobuf field string txhash = 1;
22 | */
23 | private $txhash = '';
24 | /**
25 | * Hex string of contract address if transaction is deploy type
26 | *
27 | * Generated from protobuf field string contract_address = 2;
28 | */
29 | private $contract_address = '';
30 |
31 | public function __construct() {
32 | \GPBMetadata\Rpc::initOnce();
33 | parent::__construct();
34 | }
35 |
36 | /**
37 | * Hex string of transaction hash.
38 | *
39 | * Generated from protobuf field string txhash = 1;
40 | * @return string
41 | */
42 | public function getTxhash()
43 | {
44 | return $this->txhash;
45 | }
46 |
47 | /**
48 | * Hex string of transaction hash.
49 | *
50 | * Generated from protobuf field string txhash = 1;
51 | * @param string $var
52 | * @return $this
53 | */
54 | public function setTxhash($var)
55 | {
56 | GPBUtil::checkString($var, True);
57 | $this->txhash = $var;
58 |
59 | return $this;
60 | }
61 |
62 | /**
63 | * Hex string of contract address if transaction is deploy type
64 | *
65 | * Generated from protobuf field string contract_address = 2;
66 | * @return string
67 | */
68 | public function getContractAddress()
69 | {
70 | return $this->contract_address;
71 | }
72 |
73 | /**
74 | * Hex string of contract address if transaction is deploy type
75 | *
76 | * Generated from protobuf field string contract_address = 2;
77 | * @param string $var
78 | * @return $this
79 | */
80 | public function setContractAddress($var)
81 | {
82 | GPBUtil::checkString($var, True);
83 | $this->contract_address = $var;
84 |
85 | return $this;
86 | }
87 |
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/SignHashRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.SignHashRequest
13 | */
14 | class SignHashRequest extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * sign address
18 | *
19 | * Generated from protobuf field string address = 1;
20 | */
21 | private $address = '';
22 | /**
23 | * sign msg
24 | *
25 | * Generated from protobuf field bytes hash = 2;
26 | */
27 | private $hash = '';
28 | /**
29 | * sign algorithm
30 | *
31 | * Generated from protobuf field uint32 alg = 3;
32 | */
33 | private $alg = 0;
34 |
35 | public function __construct() {
36 | \GPBMetadata\Rpc::initOnce();
37 | parent::__construct();
38 | }
39 |
40 | /**
41 | * sign address
42 | *
43 | * Generated from protobuf field string address = 1;
44 | * @return string
45 | */
46 | public function getAddress()
47 | {
48 | return $this->address;
49 | }
50 |
51 | /**
52 | * sign address
53 | *
54 | * Generated from protobuf field string address = 1;
55 | * @param string $var
56 | * @return $this
57 | */
58 | public function setAddress($var)
59 | {
60 | GPBUtil::checkString($var, True);
61 | $this->address = $var;
62 |
63 | return $this;
64 | }
65 |
66 | /**
67 | * sign msg
68 | *
69 | * Generated from protobuf field bytes hash = 2;
70 | * @return string
71 | */
72 | public function getHash()
73 | {
74 | return $this->hash;
75 | }
76 |
77 | /**
78 | * sign msg
79 | *
80 | * Generated from protobuf field bytes hash = 2;
81 | * @param string $var
82 | * @return $this
83 | */
84 | public function setHash($var)
85 | {
86 | GPBUtil::checkString($var, False);
87 | $this->hash = $var;
88 |
89 | return $this;
90 | }
91 |
92 | /**
93 | * sign algorithm
94 | *
95 | * Generated from protobuf field uint32 alg = 3;
96 | * @return int
97 | */
98 | public function getAlg()
99 | {
100 | return $this->alg;
101 | }
102 |
103 | /**
104 | * sign algorithm
105 | *
106 | * Generated from protobuf field uint32 alg = 3;
107 | * @param int $var
108 | * @return $this
109 | */
110 | public function setAlg($var)
111 | {
112 | GPBUtil::checkUint32($var);
113 | $this->alg = $var;
114 |
115 | return $this;
116 | }
117 |
118 | }
119 |
120 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/SignHashResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.SignHashResponse
13 | */
14 | class SignHashResponse extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field bytes data = 1;
18 | */
19 | private $data = '';
20 |
21 | public function __construct() {
22 | \GPBMetadata\Rpc::initOnce();
23 | parent::__construct();
24 | }
25 |
26 | /**
27 | * Generated from protobuf field bytes data = 1;
28 | * @return string
29 | */
30 | public function getData()
31 | {
32 | return $this->data;
33 | }
34 |
35 | /**
36 | * Generated from protobuf field bytes data = 1;
37 | * @param string $var
38 | * @return $this
39 | */
40 | public function setData($var)
41 | {
42 | GPBUtil::checkString($var, False);
43 | $this->data = $var;
44 |
45 | return $this;
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/SignTransactionPassphraseRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.SignTransactionPassphraseRequest
13 | */
14 | class SignTransactionPassphraseRequest extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * transaction struct
18 | *
19 | * Generated from protobuf field .rpcpb.TransactionRequest transaction = 1;
20 | */
21 | private $transaction = null;
22 | /**
23 | * from account passphrase
24 | *
25 | * Generated from protobuf field string passphrase = 2;
26 | */
27 | private $passphrase = '';
28 |
29 | public function __construct() {
30 | \GPBMetadata\Rpc::initOnce();
31 | parent::__construct();
32 | }
33 |
34 | /**
35 | * transaction struct
36 | *
37 | * Generated from protobuf field .rpcpb.TransactionRequest transaction = 1;
38 | * @return \Rpcpb\TransactionRequest
39 | */
40 | public function getTransaction()
41 | {
42 | return $this->transaction;
43 | }
44 |
45 | /**
46 | * transaction struct
47 | *
48 | * Generated from protobuf field .rpcpb.TransactionRequest transaction = 1;
49 | * @param \Rpcpb\TransactionRequest $var
50 | * @return $this
51 | */
52 | public function setTransaction($var)
53 | {
54 | GPBUtil::checkMessage($var, \Rpcpb\TransactionRequest::class);
55 | $this->transaction = $var;
56 |
57 | return $this;
58 | }
59 |
60 | /**
61 | * from account passphrase
62 | *
63 | * Generated from protobuf field string passphrase = 2;
64 | * @return string
65 | */
66 | public function getPassphrase()
67 | {
68 | return $this->passphrase;
69 | }
70 |
71 | /**
72 | * from account passphrase
73 | *
74 | * Generated from protobuf field string passphrase = 2;
75 | * @param string $var
76 | * @return $this
77 | */
78 | public function setPassphrase($var)
79 | {
80 | GPBUtil::checkString($var, True);
81 | $this->passphrase = $var;
82 |
83 | return $this;
84 | }
85 |
86 | }
87 |
88 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/SignTransactionPassphraseResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.SignTransactionPassphraseResponse
13 | */
14 | class SignTransactionPassphraseResponse extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field bytes data = 1;
18 | */
19 | private $data = '';
20 |
21 | public function __construct() {
22 | \GPBMetadata\Rpc::initOnce();
23 | parent::__construct();
24 | }
25 |
26 | /**
27 | * Generated from protobuf field bytes data = 1;
28 | * @return string
29 | */
30 | public function getData()
31 | {
32 | return $this->data;
33 | }
34 |
35 | /**
36 | * Generated from protobuf field bytes data = 1;
37 | * @param string $var
38 | * @return $this
39 | */
40 | public function setData($var)
41 | {
42 | GPBUtil::checkString($var, False);
43 | $this->data = $var;
44 |
45 | return $this;
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/SubscribeRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.SubscribeRequest
15 | */
16 | class SubscribeRequest extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Generated from protobuf field repeated string topics = 1;
20 | */
21 | private $topics;
22 |
23 | public function __construct() {
24 | \GPBMetadata\Rpc::initOnce();
25 | parent::__construct();
26 | }
27 |
28 | /**
29 | * Generated from protobuf field repeated string topics = 1;
30 | * @return \Google\Protobuf\Internal\RepeatedField
31 | */
32 | public function getTopics()
33 | {
34 | return $this->topics;
35 | }
36 |
37 | /**
38 | * Generated from protobuf field repeated string topics = 1;
39 | * @param string[]|\Google\Protobuf\Internal\RepeatedField $var
40 | * @return $this
41 | */
42 | public function setTopics($var)
43 | {
44 | $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING);
45 | $this->topics = $arr;
46 |
47 | return $this;
48 | }
49 |
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/SubscribeResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.SubscribeResponse
15 | */
16 | class SubscribeResponse extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Generated from protobuf field string topic = 1;
20 | */
21 | private $topic = '';
22 | /**
23 | * Generated from protobuf field string data = 2;
24 | */
25 | private $data = '';
26 |
27 | public function __construct() {
28 | \GPBMetadata\Rpc::initOnce();
29 | parent::__construct();
30 | }
31 |
32 | /**
33 | * Generated from protobuf field string topic = 1;
34 | * @return string
35 | */
36 | public function getTopic()
37 | {
38 | return $this->topic;
39 | }
40 |
41 | /**
42 | * Generated from protobuf field string topic = 1;
43 | * @param string $var
44 | * @return $this
45 | */
46 | public function setTopic($var)
47 | {
48 | GPBUtil::checkString($var, True);
49 | $this->topic = $var;
50 |
51 | return $this;
52 | }
53 |
54 | /**
55 | * Generated from protobuf field string data = 2;
56 | * @return string
57 | */
58 | public function getData()
59 | {
60 | return $this->data;
61 | }
62 |
63 | /**
64 | * Generated from protobuf field string data = 2;
65 | * @param string $var
66 | * @return $this
67 | */
68 | public function setData($var)
69 | {
70 | GPBUtil::checkString($var, True);
71 | $this->data = $var;
72 |
73 | return $this;
74 | }
75 |
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/TransactionRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.TransactionRequest
15 | */
16 | class TransactionRequest extends \Google\Protobuf\Internal\Message
17 | {
18 | /**
19 | * Hex string of the sender account addresss.
20 | *
21 | * Generated from protobuf field string from = 1;
22 | */
23 | private $from = '';
24 | /**
25 | * Hex string of the receiver account addresss.
26 | *
27 | * Generated from protobuf field string to = 2;
28 | */
29 | private $to = '';
30 | /**
31 | * Amount of value sending with this transaction.
32 | *
33 | * Generated from protobuf field string value = 3;
34 | */
35 | private $value = '';
36 | /**
37 | * Transaction nonce.
38 | *
39 | * Generated from protobuf field uint64 nonce = 4;
40 | */
41 | private $nonce = 0;
42 | /**
43 | * gasPrice sending with this transaction.
44 | *
45 | * Generated from protobuf field string gas_price = 5;
46 | */
47 | private $gas_price = '';
48 | /**
49 | * gasLimit sending with this transaction.
50 | *
51 | * Generated from protobuf field string gas_limit = 6;
52 | */
53 | private $gas_limit = '';
54 | /**
55 | * contract sending with this transaction
56 | *
57 | * Generated from protobuf field .rpcpb.ContractRequest contract = 7;
58 | */
59 | private $contract = null;
60 | /**
61 | * binary data for transaction
62 | *
63 | * Generated from protobuf field bytes binary = 10;
64 | */
65 | private $binary = '';
66 |
67 | public function __construct() {
68 | \GPBMetadata\Rpc::initOnce();
69 | parent::__construct();
70 | }
71 |
72 | /**
73 | * Hex string of the sender account addresss.
74 | *
75 | * Generated from protobuf field string from = 1;
76 | * @return string
77 | */
78 | public function getFrom()
79 | {
80 | return $this->from;
81 | }
82 |
83 | /**
84 | * Hex string of the sender account addresss.
85 | *
86 | * Generated from protobuf field string from = 1;
87 | * @param string $var
88 | * @return $this
89 | */
90 | public function setFrom($var)
91 | {
92 | GPBUtil::checkString($var, True);
93 | $this->from = $var;
94 |
95 | return $this;
96 | }
97 |
98 | /**
99 | * Hex string of the receiver account addresss.
100 | *
101 | * Generated from protobuf field string to = 2;
102 | * @return string
103 | */
104 | public function getTo()
105 | {
106 | return $this->to;
107 | }
108 |
109 | /**
110 | * Hex string of the receiver account addresss.
111 | *
112 | * Generated from protobuf field string to = 2;
113 | * @param string $var
114 | * @return $this
115 | */
116 | public function setTo($var)
117 | {
118 | GPBUtil::checkString($var, True);
119 | $this->to = $var;
120 |
121 | return $this;
122 | }
123 |
124 | /**
125 | * Amount of value sending with this transaction.
126 | *
127 | * Generated from protobuf field string value = 3;
128 | * @return string
129 | */
130 | public function getValue()
131 | {
132 | return $this->value;
133 | }
134 |
135 | /**
136 | * Amount of value sending with this transaction.
137 | *
138 | * Generated from protobuf field string value = 3;
139 | * @param string $var
140 | * @return $this
141 | */
142 | public function setValue($var)
143 | {
144 | GPBUtil::checkString($var, True);
145 | $this->value = $var;
146 |
147 | return $this;
148 | }
149 |
150 | /**
151 | * Transaction nonce.
152 | *
153 | * Generated from protobuf field uint64 nonce = 4;
154 | * @return int|string
155 | */
156 | public function getNonce()
157 | {
158 | return $this->nonce;
159 | }
160 |
161 | /**
162 | * Transaction nonce.
163 | *
164 | * Generated from protobuf field uint64 nonce = 4;
165 | * @param int|string $var
166 | * @return $this
167 | */
168 | public function setNonce($var)
169 | {
170 | GPBUtil::checkUint64($var);
171 | $this->nonce = $var;
172 |
173 | return $this;
174 | }
175 |
176 | /**
177 | * gasPrice sending with this transaction.
178 | *
179 | * Generated from protobuf field string gas_price = 5;
180 | * @return string
181 | */
182 | public function getGasPrice()
183 | {
184 | return $this->gas_price;
185 | }
186 |
187 | /**
188 | * gasPrice sending with this transaction.
189 | *
190 | * Generated from protobuf field string gas_price = 5;
191 | * @param string $var
192 | * @return $this
193 | */
194 | public function setGasPrice($var)
195 | {
196 | GPBUtil::checkString($var, True);
197 | $this->gas_price = $var;
198 |
199 | return $this;
200 | }
201 |
202 | /**
203 | * gasLimit sending with this transaction.
204 | *
205 | * Generated from protobuf field string gas_limit = 6;
206 | * @return string
207 | */
208 | public function getGasLimit()
209 | {
210 | return $this->gas_limit;
211 | }
212 |
213 | /**
214 | * gasLimit sending with this transaction.
215 | *
216 | * Generated from protobuf field string gas_limit = 6;
217 | * @param string $var
218 | * @return $this
219 | */
220 | public function setGasLimit($var)
221 | {
222 | GPBUtil::checkString($var, True);
223 | $this->gas_limit = $var;
224 |
225 | return $this;
226 | }
227 |
228 | /**
229 | * contract sending with this transaction
230 | *
231 | * Generated from protobuf field .rpcpb.ContractRequest contract = 7;
232 | * @return \Rpcpb\ContractRequest
233 | */
234 | public function getContract()
235 | {
236 | return $this->contract;
237 | }
238 |
239 | /**
240 | * contract sending with this transaction
241 | *
242 | * Generated from protobuf field .rpcpb.ContractRequest contract = 7;
243 | * @param \Rpcpb\ContractRequest $var
244 | * @return $this
245 | */
246 | public function setContract($var)
247 | {
248 | GPBUtil::checkMessage($var, \Rpcpb\ContractRequest::class);
249 | $this->contract = $var;
250 |
251 | return $this;
252 | }
253 |
254 | /**
255 | * binary data for transaction
256 | *
257 | * Generated from protobuf field bytes binary = 10;
258 | * @return string
259 | */
260 | public function getBinary()
261 | {
262 | return $this->binary;
263 | }
264 |
265 | /**
266 | * binary data for transaction
267 | *
268 | * Generated from protobuf field bytes binary = 10;
269 | * @param string $var
270 | * @return $this
271 | */
272 | public function setBinary($var)
273 | {
274 | GPBUtil::checkString($var, False);
275 | $this->binary = $var;
276 |
277 | return $this;
278 | }
279 |
280 | }
281 |
282 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/UnlockAccountRequest.php:
--------------------------------------------------------------------------------
1 | rpcpb.UnlockAccountRequest
13 | */
14 | class UnlockAccountRequest extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field string address = 1;
18 | */
19 | private $address = '';
20 | /**
21 | * Generated from protobuf field string passphrase = 2;
22 | */
23 | private $passphrase = '';
24 | /**
25 | * Generated from protobuf field uint64 duration = 3;
26 | */
27 | private $duration = 0;
28 |
29 | public function __construct() {
30 | \GPBMetadata\Rpc::initOnce();
31 | parent::__construct();
32 | }
33 |
34 | /**
35 | * Generated from protobuf field string address = 1;
36 | * @return string
37 | */
38 | public function getAddress()
39 | {
40 | return $this->address;
41 | }
42 |
43 | /**
44 | * Generated from protobuf field string address = 1;
45 | * @param string $var
46 | * @return $this
47 | */
48 | public function setAddress($var)
49 | {
50 | GPBUtil::checkString($var, True);
51 | $this->address = $var;
52 |
53 | return $this;
54 | }
55 |
56 | /**
57 | * Generated from protobuf field string passphrase = 2;
58 | * @return string
59 | */
60 | public function getPassphrase()
61 | {
62 | return $this->passphrase;
63 | }
64 |
65 | /**
66 | * Generated from protobuf field string passphrase = 2;
67 | * @param string $var
68 | * @return $this
69 | */
70 | public function setPassphrase($var)
71 | {
72 | GPBUtil::checkString($var, True);
73 | $this->passphrase = $var;
74 |
75 | return $this;
76 | }
77 |
78 | /**
79 | * Generated from protobuf field uint64 duration = 3;
80 | * @return int|string
81 | */
82 | public function getDuration()
83 | {
84 | return $this->duration;
85 | }
86 |
87 | /**
88 | * Generated from protobuf field uint64 duration = 3;
89 | * @param int|string $var
90 | * @return $this
91 | */
92 | public function setDuration($var)
93 | {
94 | GPBUtil::checkUint64($var);
95 | $this->duration = $var;
96 |
97 | return $this;
98 | }
99 |
100 | }
101 |
102 |
--------------------------------------------------------------------------------
/src/proto/dist/Rpcpb/UnlockAccountResponse.php:
--------------------------------------------------------------------------------
1 | rpcpb.UnlockAccountResponse
13 | */
14 | class UnlockAccountResponse extends \Google\Protobuf\Internal\Message
15 | {
16 | /**
17 | * Generated from protobuf field bool result = 1;
18 | */
19 | private $result = false;
20 |
21 | public function __construct() {
22 | \GPBMetadata\Rpc::initOnce();
23 | parent::__construct();
24 | }
25 |
26 | /**
27 | * Generated from protobuf field bool result = 1;
28 | * @return bool
29 | */
30 | public function getResult()
31 | {
32 | return $this->result;
33 | }
34 |
35 | /**
36 | * Generated from protobuf field bool result = 1;
37 | * @param bool $var
38 | * @return $this
39 | */
40 | public function setResult($var)
41 | {
42 | GPBUtil::checkBool($var);
43 | $this->result = $var;
44 |
45 | return $this;
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/proto/google/api/annotations.proto:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015, Google Inc.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | syntax = "proto3";
16 |
17 | package google.api;
18 |
19 | import "google/api/http.proto";
20 | import "google/protobuf/descriptor.proto";
21 |
22 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
23 | option java_multiple_files = true;
24 | option java_outer_classname = "AnnotationsProto";
25 | option java_package = "com.google.api";
26 | option objc_class_prefix = "GAPI";
27 |
28 | extend google.protobuf.MethodOptions {
29 | // See `HttpRule`.
30 | HttpRule http = 72295728;
31 | }
32 |
--------------------------------------------------------------------------------
/src/proto/transaction.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package corepb;
3 |
4 | message Data {
5 | string payload_type = 1;
6 | bytes payload = 2;
7 | }
8 |
9 | message Transaction {
10 | bytes hash = 1;
11 | bytes from = 2;
12 | bytes to = 3;
13 | bytes value = 4;
14 | uint64 nonce = 5;
15 | int64 timestamp = 6;
16 | Data data = 7;
17 | uint32 chain_id = 8;
18 | bytes gas_price = 9;
19 | bytes gas_limit = 10;
20 |
21 | uint32 alg = 11;
22 | bytes sign = 12;
23 | }
--------------------------------------------------------------------------------
/tests/Core/AccountTest.php:
--------------------------------------------------------------------------------
1 | account = Account::newAccount();
28 | $this->account =Account::fromKeyStore($this->keyJson, $this->password);
29 | }
30 |
31 | public function testGetAddress()
32 | {
33 | self::assertEquals($this->account->getAddress(), ($this->addressHex));
34 | }
35 |
36 | public function testGetAddressString()
37 | {
38 | self::assertEquals($this->account->getAddressString(), $this->address);
39 | }
40 |
41 |
42 | public function testIsValidAddress()
43 | {
44 | $address = "n1HUbJZ45Ra5jrRqWvfVaRMiBMB3CACGhqc"; //account
45 | $this->assertTrue(Account::isValidAddress($address));
46 |
47 | $address = "n1oXdmwuo5jJRExnZR5rbceMEyzRsPeALgm"; //contract
48 | $this->assertTrue(Account::isValidAddress($address));
49 |
50 | $address = "n1HUbJZ45Ra5jrRqWvfVaRMiBMB3CACGhq1"; //wrong
51 | $this->assertFalse(Account::isValidAddress($address));
52 | $address = ""; //empty
53 | $this->assertFalse(Account::isValidAddress($address));
54 |
55 | }
56 |
57 | public function testIsValidAccountAddress(){
58 | $address = "n1HUbJZ45Ra5jrRqWvfVaRMiBMB3CACGhqc"; //account
59 | $this->assertTrue(Account::isValidAccountAddress($address));
60 |
61 | $address = "n1oXdmwuo5jJRExnZR5rbceMEyzRsPeALgm"; //contract
62 | $this->assertFalse(Account::isValidAccountAddress($address));
63 |
64 | $address = "n1HUbJZ45Ra5jrRqWvfVaRMiBMB3CACGhq1"; //wrong
65 | $this->assertFalse(Account::isValidAccountAddress($address));
66 | $address = ""; //empty
67 | $this->assertFalse(Account::isValidAccountAddress($address));
68 |
69 | }
70 | public function testIsValidContractAddress(){
71 | $address = "n1HUbJZ45Ra5jrRqWvfVaRMiBMB3CACGhqc"; //account
72 | $this->assertFalse(Account::isValidContractAddress($address));
73 |
74 | $address = "n1oXdmwuo5jJRExnZR5rbceMEyzRsPeALgm"; //contract
75 | $this->assertTrue(Account::isValidContractAddress($address));
76 |
77 | $address = "n1HUbJZ45Ra5jrRqWvfVaRMiBMB3CACGhq1"; //wrong
78 | $this->assertFalse(Account::isValidContractAddress($address));
79 | $address = ""; //empty
80 | $this->assertFalse(Account::isValidContractAddress($address));
81 |
82 | }
83 |
84 | public function testSetPrivateKey()
85 | {
86 | $priv = "8d464aeeca0281523fda55da220f1257219052b1450849fea6b23695ee6b3f93";
87 | $acc = Account::newAccount();
88 | $acc->setPrivateKey($priv);
89 | self::assertEquals( $acc->getAddressString() ,'n1HUbJZ45Ra5jrRqWvfVaRMiBMB3CACGhqc');
90 |
91 | }
92 |
93 | public function testGetPrivateKey()
94 | {
95 | self::assertEquals($this->account->getPrivateKey(), $this->givenPrivKey);
96 | }
97 |
98 | public function testGetPublicKey()
99 | {
100 | $account = Account::newAccount();
101 | $account->setPrivateKey($this->givenPrivKey);
102 | $gotPub = $account->getPublicKey();
103 | $this->assertTrue($gotPub === $this->estPubKey);
104 | }
105 |
106 | public function testToKey()
107 | {
108 | $password = "passphraseeee";
109 | $acc1 = Account::newAccount();
110 | $keyString = $acc1->toKeyStore($password);
111 |
112 | $acc2 =Account::fromKeyStore($keyString, $password);
113 | self::assertEquals($acc1->getAddressString(), $acc2->getAddressString());
114 | }
115 |
116 |
117 | public function testFromKey()
118 | {
119 | /**
120 | * V3
121 | */
122 | $keyV3 = '{"version":3,"id":"ccdea027-bea5-4626-b5e4-53b987091b8d","address":"n1X1N4Jq7mhm3tK74AqE29Rdp97kdTWftzS","crypto":{"ciphertext":"0535aac6d78ad8ddfa2274b05c7a6fcfdb3b9fcff91ed59b1531ec8cd3671715","cipherparams":{"iv":"03e09e5994ad41df77b9c94ffa1ecd9e"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"7237d1a9e755adbf7e6b1364b6c7a1c8101043b693e671357895684aa5c3e7f1","n":4096,"r":8,"p":1},"mac":"288ae2984d7d40d25f7261342ef5ec4f1b576dce3f2e324fa0483f710fb42fd3","machash":"sha3256"}}';
123 | $acc = Account::fromKeyStore($keyV3,'passphrase');
124 | self::assertTrue(Account::isValidAccountAddress($acc->getAddressString()));
125 | /**
126 | * V4
127 | */
128 | $keyV4 = '{"version":4,"id":"814745d0-9200-42bd-a4df-557b2d7e1d8b","address":"n1H2Yb5Q6ZfKvs61htVSV4b1U2gr2GA9vo6","crypto":{"ciphertext":"fb831107ce71ed9064fca0de8d514d7b2ba0aa03aa4fa6302d09fdfdfad23a18","cipherparams":{"iv":"fb65caf32f4dbb2593e36b02c07b8484"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"dddc4f9b3e2079b5cc65d82d4f9ecf27da6ec86770cb627a19bc76d094bf9472","n":4096,"r":8,"p":1},"mac":"1a66d8e18d10404440d2762c0d59d0ce9e12a4bbdfc03323736a435a0761ee23","machash":"sha3256"}}';
129 | $acc2 = Account::fromKeyStore($keyV4,'passphrase');
130 | self::assertTrue(Account::isValidAccountAddress($acc2->getAddressString()));
131 |
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/tests/Core/TransactionCallPayloadTest.php:
--------------------------------------------------------------------------------
1 | expectExceptionMessageRegExp('/Payload length exceeds max*/');
65 | $args = str_repeat("s",128*1024);
66 | echo "arg length: ", strlen($args)/1024.0, "K ", PHP_EOL;
67 | new TransactionCallPayload("function", $args);
68 | }
69 |
70 | /**
71 | * @dataProvider providerValidFunc
72 | */
73 | function testCheckArgs_ValidFunc($func)
74 | {
75 | echo "test function name: ", $func, PHP_EOL;
76 | $t = new TransactionCallPayload($func, "");
77 | self::assertInstanceOf('\Nebulas\Core\TransactionCallPayload', $t);
78 | }
79 |
80 | /**
81 | * @dataProvider providerValidArgs
82 | */
83 | function testCheckArgs_ValidArg($arg)
84 | {
85 | echo "test arg name: ", $arg, PHP_EOL;
86 | $t = new TransactionCallPayload("function", $arg);
87 | self::assertInstanceOf('\Nebulas\Core\TransactionCallPayload', $t);
88 | }
89 |
90 | /**
91 | * @dataProvider providerInvalidFunc
92 | */
93 | function testCheckArgs_InvalidFunc($func)
94 | {
95 | $this->expectExceptionMessage("Invalid function name of call payload");
96 |
97 | echo "test function name: ", $func, PHP_EOL;
98 | new TransactionCallPayload($func, "");
99 | }
100 |
101 | /**
102 | * @dataProvider providerInvalidArg
103 | */
104 | function testCheckArgs_InvalidArgs($args)
105 | {
106 | $this->expectExceptionMessage("Args is not an array of json");
107 |
108 | echo "test arg name: ", $args, PHP_EOL;
109 | new TransactionCallPayload("function", $args);
110 | }
111 |
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/tests/Core/TransactionDeployPayloadTest.php:
--------------------------------------------------------------------------------
1 | expectExceptionMessageRegExp('/Payload length exceeds max*/');
60 | $args = str_repeat("s",128*1024);
61 | echo "arg length: ", strlen($args)/1024.0, "K ", PHP_EOL;
62 | new TransactionDeployPayload("js","function", $args);
63 | }
64 |
65 | /**
66 | * @dataProvider providerValidSource
67 | */
68 | function testCheckArgs_ValidSource($func)
69 | {
70 | echo "test function name: ", $func, PHP_EOL;
71 | $t = new TransactionDeployPayload("js", $func, "");
72 | self::assertInstanceOf('\Nebulas\Core\TransactionDeployPayload', $t);
73 | }
74 |
75 | /**
76 | * @dataProvider providerValidArgs
77 | */
78 | function testCheckArgs_ValidArg($arg)
79 | {
80 | echo "test arg name: ", $arg, PHP_EOL;
81 | $t = new TransactionDeployPayload("js","source", $arg);
82 | self::assertInstanceOf('\Nebulas\Core\TransactionDeployPayload', $t);
83 | }
84 |
85 | /**
86 | * @dataProvider providerInvalidSource
87 | */
88 | function testCheckArgs_InvalidSource($func)
89 | {
90 | $this->expectExceptionMessage("Invalid source of deploy payload");
91 |
92 | echo "test function name: ", $func, PHP_EOL;
93 | new TransactionDeployPayload("js", $func, "");
94 | }
95 |
96 | /**
97 | * @dataProvider providerInvalidArg
98 | */
99 | function testCheckArgs_InvalidArgs($args)
100 | {
101 | $this->expectExceptionMessage("Args is not an array of json");
102 |
103 | echo "test arg name: ", $args, PHP_EOL;
104 | new TransactionDeployPayload("js","source", $args);
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/tests/Core/TransactionTest.php:
--------------------------------------------------------------------------------
1 | expectExceptionMessageRegExp('/^gmp_init*/');
24 | $this->expectExceptionMessage("gmp_init(): Unable to convert variable to GMP - string is not an integer");
25 |
26 | $from = new Account();
27 | $to = "n1H2Yb5Q6ZfKvs61htVSV4b1U2gr2GA9vo6";
28 | $tx = new Transaction("1001", $from, $to, "0.1", 0 );
29 | echo $tx->toString();
30 | }
31 |
32 | public function prepare(){
33 |
34 | $chainID = 1001;
35 | $from = Account::newAccount();
36 | $privHex = "8d464aeeca0281523fda55da220f1257219052b1450849fea6b23695ee6b3f93";
37 | $from->setPrivateKey($privHex);
38 |
39 | $to = "n1HUbJZ45Ra5jrRqWvfVaRMiBMB3CACGhqc";
40 | $value = "1000000000000000000";
41 | $nonce = 1;
42 | $payloadType = Transaction::BINARY;
43 | $payload = new TransactionBinaryPayload("data") ;
44 | $timestamp = 1527177398;
45 | $gasPrice = "1000000";
46 | $gasLimit = "20000";
47 | //$data = '{"payloadType":"binary","payload":null}';
48 | $hash = "9dedc6db0d895e346355f2c702a7a8e462993fee16a1ec8847b2852d49245564";
49 | $sign = "ee291ab49ba4ad1c5874a3842bcf02ce3e948ea0938289835eea353394297a166d8b3a93c4d10ffb115a30466c4499fd38e2288586efb36f9fb83399350d3ce600";
50 | $rawData = "CiCd7cbbDYleNGNV8scCp6jkYpk/7hah7IhHsoUtSSRVZBIaGVcgewayZc0Og2LO7RuSi1alpXte7NOSLwsaGhlXIHsGsmXNDoNizu0bkotWpaV7XuzTki8LIhAAAAAAAAAAAA3gtrOnZAAAKAEwtsGb2AU6CAoGYmluYXJ5QOkHShAAAAAAAAAAAAAAAAAAD0JAUhAAAAAAAAAAAAAAAAAAAE4gWAFiQe4pGrSbpK0cWHSjhCvPAs4+lI6gk4KJg17qNTOUKXoWbYs6k8TRD/sRWjBGbESZ/TjiKIWG77Nvn7gzmTUNPOYA";
51 |
52 | $this->tx = new Transaction($chainID, $from, $to, $value, $nonce, $gasPrice, $gasLimit, $payloadType, $payload);
53 |
54 | }
55 |
56 |
57 | public function testHashTransaction()
58 | {
59 |
60 | }
61 |
62 | public function testFromProto()
63 | {
64 |
65 | }
66 |
67 |
68 | public function testSignTransaction()
69 | {
70 |
71 |
72 | }
73 |
74 |
75 | public function testToProtoString()
76 | {
77 |
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/tests/Rpc/AdminTest.php:
--------------------------------------------------------------------------------
1 | admin->accounts();
39 | //echo $result,PHP_EOL;
40 | $Obj = json_decode($result);
41 | return $Obj->result->addresses[0];
42 | }
43 |
44 | public function testNewAccount()
45 | {
46 | $neb = new Neb(new HttpProvider(ApiTestHost));
47 | $result = $neb->admin->newAccount("passphrase");
48 | echo $result,PHP_EOL;
49 | self::assertStringStartsWith('{"result"', $result);
50 | }
51 |
52 | public function testAccounts()
53 | {
54 | $neb = new Neb(new HttpProvider(ApiTestHost));
55 | $result = $neb->admin->accounts();
56 | echo $result,PHP_EOL;
57 | self::assertStringStartsWith('{"result"', $result);
58 | }
59 |
60 | public function testUnlockAccount()
61 | {
62 | $account = $this->getAccount();
63 | echo "account tobe unlocked: ", $account,PHP_EOL;
64 | $neb = new Neb(new HttpProvider(ApiTestHost));
65 | $result = $neb->admin->unlockAccount($account,"passphrase", "300000000000"); //300s
66 | echo $result,PHP_EOL;
67 | self::assertStringStartsWith('{"result"', $result);
68 |
69 | }
70 |
71 | public function testLockAccount()
72 | {
73 | $account = $this->getAccount();
74 | echo "account tobe locked: ", $account,PHP_EOL;
75 | $neb = new Neb(new HttpProvider(ApiTestHost));
76 | $result = $neb->admin->lockAccount($account);
77 | echo $result,PHP_EOL;
78 | self::assertStringStartsWith('{"result"', $result);
79 | }
80 |
81 |
82 | public function testSendTransaction()
83 | {
84 | $account = $this->getAccount();
85 | $neb = new Neb(new HttpProvider(ApiTestHost));
86 | $neb->admin->unlockAccount($account,"passphrase");
87 | /**
88 | * default
89 | */
90 | $result = $neb->admin->sendTransaction($account,
91 | $account,
92 | "100000",
93 | 1,
94 | "1000000",
95 | "200000");
96 | echo "default(binary): ",$result,PHP_EOL,PHP_EOL;
97 | self::assertStringStartsWith('{"result"', $result);
98 | /**
99 | * Binary
100 | */
101 | $result = $neb->admin->sendTransaction($account,
102 | $account,
103 | "100000",
104 | 1,
105 | "1000000",
106 | "200000",
107 | "binary",
108 | null,
109 | "data");
110 | echo "binary: ",$result,PHP_EOL,PHP_EOL;
111 | self::assertStringStartsWith('{"result"', $result);
112 | /**
113 | * deploy
114 | */
115 | $result = $neb->admin->sendTransaction($account,
116 | $account,
117 | "100000",
118 | 1,
119 | "1000000",
120 | "200000",
121 | null,
122 | array(
123 | 'sourceType' => 'js',
124 | 'source' => $this->source
125 | ),
126 | null);
127 | echo "deploy: ", $result,PHP_EOL;
128 | self::assertStringStartsWith('{"result"', $result);
129 | $Obj = json_decode($result);
130 | $contract = $Obj->result->contract_address;
131 | echo "contract address: $contract",PHP_EOL,PHP_EOL;
132 | /**
133 | * deploy
134 | */
135 | // $result = $neb->admin->sendTransaction($account,
136 | // $account,
137 | // "100000",
138 | // 1,
139 | // "1000000",
140 | // "200000",
141 | // "deploy",
142 | // array(
143 | // 'sourceType' => 'js',
144 | // 'source' => $this->source
145 | // ),
146 | // null);
147 | // echo "deploy: ", $result,PHP_EOL;
148 | // self::assertStringStartsWith('{"result"', $result);
149 | // $Obj = json_decode($result);
150 | // $contract = $Obj->result->contract_address;
151 | // echo "contract address: $contract",PHP_EOL,PHP_EOL;
152 |
153 | /**
154 | * call
155 | */
156 | $result = $neb->admin->sendTransaction($account,
157 | $contract,
158 | "100000",
159 | 1,
160 | "1000000",
161 | "200000",
162 | "call",
163 | array(
164 | "function"=> "getValue",
165 | "args" => null,
166 | ),
167 | null);
168 | echo $result,PHP_EOL,PHP_EOL;
169 | self::assertStringStartsWith('{"result"', $result);
170 | }
171 |
172 | public function testSighHash()
173 | {
174 | $account = "n1c3kQyTXJkCEejGrBLYkH4L4qSV9JxntyS";
175 | $account = $this->getAccount();
176 | $neb = new Neb(new HttpProvider(ApiTestHost));
177 | $result = $neb->admin->signHash($account,
178 | base64_encode(hash("sha3-256","any data", true)), //"W+rOKNqs/tlvz02ez77yIYMCOr2EubpuNh5LvmwceI0=",
179 | 1);
180 | echo $result,PHP_EOL;
181 | self::assertStringStartsWith('{"result"', $result);
182 |
183 | }
184 |
185 | public function testSignTransactionWithPassphrase()
186 | {
187 |
188 | }
189 |
190 | public function testSendTransactionWithPassphrase()
191 | {
192 |
193 | }
194 |
195 | public function testStartPprof()
196 | {
197 | $neb = new Neb(new HttpProvider(ApiTestHost));
198 | $result = $neb->admin->startPprof("8080");
199 | echo $result,PHP_EOL;
200 | self::assertStringStartsWith('{"result"', $result);
201 | }
202 |
203 | public function testGetConfig()
204 | {
205 | $neb = new Neb(new HttpProvider(ApiTestHost));
206 | $result = $neb->admin->getConfig();
207 | echo $result,PHP_EOL;
208 | self::assertStringStartsWith('{"result"', $result);
209 | }
210 |
211 | public function testNodeInfo()
212 | {
213 | $neb = new Neb(new HttpProvider(ApiTestHost));
214 | $result = $neb->admin->nodeInfo();
215 | echo $result,PHP_EOL;
216 | self::assertStringStartsWith('{"result"', $result);
217 | }
218 | }
219 |
--------------------------------------------------------------------------------
/tests/Rpc/ApiTest.php:
--------------------------------------------------------------------------------
1 | api->sendRawTransaction($rawTx);
43 | echo $result,PHP_EOL;
44 | self::assertStringStartsWith('{"error":"transaction', $result);
45 | }
46 |
47 | // public function testSubscribe()
48 | // {
49 | //
50 | // }
51 |
52 | public function testEstimateGas()
53 | {
54 | $neb = new Neb(new HttpProvider(ApiTestHost));
55 | $api = $neb->api;
56 | /**
57 | * default(binary)
58 | */
59 | $result = $api->estimateGas("n1JmhE82GNjdZPNZr6dgUuSfzy2WRwmD9zy",
60 | "n1JmhE82GNjdZPNZr6dgUuSfzy2WRwmD9zy",
61 | "100000",
62 | 0,
63 | "200000",
64 | "200000");
65 | echo "estimateGas of default type: ", $result, PHP_EOL, PHP_EOL;
66 | self::assertStringStartsWith('{"result"', $result);
67 | /**
68 | * binary
69 | */
70 | $result = $api->estimateGas("n1JmhE82GNjdZPNZr6dgUuSfzy2WRwmD9zy",
71 | "n1JmhE82GNjdZPNZr6dgUuSfzy2WRwmD9zy",
72 | "100000",
73 | 0,
74 | "200000",
75 | "200000",
76 | "binary",
77 | null,
78 | "data");
79 | echo "estimateGas of binary type: ", $result, PHP_EOL, PHP_EOL;
80 | self::assertStringStartsWith('{"result"', $result);
81 | /**
82 | * call
83 | */
84 | $result = $api->estimateGas("n1JmhE82GNjdZPNZr6dgUuSfzy2WRwmD9zy",
85 | "n1oXdmwuo5jJRExnZR5rbceMEyzRsPeALgm",
86 | "100000",
87 | 0,
88 | "200000",
89 | "200000",
90 | "call",
91 | array(
92 | "function"=> "get",
93 | 'args' => '["nebulas"]'
94 | ),
95 | null);
96 | echo "estimateGas of call type: ", $result, PHP_EOL, PHP_EOL;
97 | self::assertStringStartsWith('{"result"', $result);
98 | /**
99 | * deploy
100 | */
101 | $result = $api->estimateGas("n1JmhE82GNjdZPNZr6dgUuSfzy2WRwmD9zy",
102 | "n1JmhE82GNjdZPNZr6dgUuSfzy2WRwmD9zy",
103 | "100000",
104 | 0,
105 | "200000",
106 | "200000",
107 | "deploy",
108 | array(
109 | "sourceType"=> "js",
110 | 'source' => $this->source
111 | ),
112 | null);
113 | echo "estimateGas of deploy type: ", $result, PHP_EOL, PHP_EOL;
114 | self::assertStringStartsWith('{"result"', $result);
115 | }
116 |
117 | public function testCall()
118 | {
119 | $neb = new Neb(new HttpProvider(ApiTestHost));
120 | $api = $neb->api;
121 | $fromAcc = new Account();
122 | $from = $fromAcc->getAddressString();
123 | /**
124 | * binary
125 | */
126 | $result = $api->call($from,
127 | "n1JmhE82GNjdZPNZr6dgUuSfzy2WRwmD9zy",
128 | "100000",
129 | 0,
130 | "200000",
131 | "200000");
132 |
133 | echo 'Call(binary type): ',$result, PHP_EOL;
134 | self::assertStringStartsWith('{"result"', $result);
135 | /**
136 | * call
137 | */
138 | $result = $api->call($from,
139 | "n1oXdmwuo5jJRExnZR5rbceMEyzRsPeALgm",
140 | "0",
141 | 0,
142 | "200000",
143 | "200000",
144 | 'call',
145 | array("function" => 'get', 'args' => '["nebulas"]'));
146 | echo 'Call(call type): ',$result, PHP_EOL;
147 | self::assertStringStartsWith('{"result"', $result);
148 |
149 | /**
150 | * deploy
151 | */
152 |
153 | $result = $api->call($from,
154 | $from,
155 | "0",
156 | 0,
157 | "200000",
158 | "200000",
159 | 'deploy',
160 | array(
161 | "sourceType" => 'js',
162 | "source" => $this->source
163 | ));
164 | echo 'Call(deploy type): ',$result, PHP_EOL;
165 | self::assertStringStartsWith('{"result"', $result);
166 |
167 | }
168 |
169 | public function testGetEventsByHash()
170 | {
171 | $neb = new Neb(new HttpProvider(ApiTestHost));
172 | $result = $neb->api->getEventsByHash("8b98a5e4a27d2744a6295fe71e4f138d3e423ced11c81e201c12ac8379226ad1");
173 | echo "GetEventsByHash: ",$result, PHP_EOL;
174 | self::assertStringStartsWith('{"result"', $result);
175 | }
176 |
177 | public function testGetBlockByHeight()
178 | {
179 | $neb = new Neb(new HttpProvider(ApiTestHost));
180 | $result = $neb->api->getBlockByHeight("100");
181 | echo "GetBlockByHeight: ",$result, PHP_EOL;
182 | self::assertStringStartsWith('{"result"', $result);
183 | }
184 |
185 | public function testGetNebState()
186 | {
187 | $neb = new Neb(new HttpProvider(ApiTestHost));
188 | $result = $neb->api->getNebState();
189 | echo "NebState: $result", PHP_EOL;
190 | self::assertStringStartsWith('{"result"', $result);
191 | }
192 |
193 | public function testGasPrice()
194 | {
195 | $neb = new Neb(new HttpProvider(ApiTestHost));
196 | $result = $neb->api->gasPrice();
197 | echo "GasPrice: ",$result, PHP_EOL;
198 | self::assertStringStartsWith('{"result"', $result);
199 | }
200 |
201 | public function testGetAccountState()
202 | {
203 | $neb = new Neb(new HttpProvider(ApiTestHost));
204 | $result = $neb->api->getAccountState("n1H2Yb5Q6ZfKvs61htVSV4b1U2gr2GA9vo6");
205 | echo "AccountState: ",$result, PHP_EOL;
206 | self::assertStringStartsWith('{"result"', $result);
207 | }
208 |
209 | public function testGetBlockByHash()
210 | {
211 | $neb = new Neb(new HttpProvider(ApiTestHost));
212 | $result = $neb->api->getBlockByHash("5cce7b5e719b5af679dbc0f4166e9c8665eb03704eb33b97ccb59d4e4ba14352");
213 | echo "GetBlockByHash: $result", PHP_EOL;
214 | self::assertStringStartsWith('{"result"', $result);
215 | }
216 |
217 | public function testGetTransactionByContract()
218 | {
219 | $neb = new Neb(new HttpProvider(ApiTestHost));
220 | $result = $neb->api->getTransactionByContract("n1oXdmwuo5jJRExnZR5rbceMEyzRsPeALgm");
221 | echo "GetTransactionByContract: $result", PHP_EOL;
222 | self::assertStringStartsWith('{"result"', $result);
223 | }
224 |
225 | public function testLatestIrreversibleBlock()
226 | {
227 | $neb = new Neb(new HttpProvider(ApiTestHost));
228 | $result = $neb->api->latestIrreversibleBlock();
229 | echo "LatestIrreversibleBlock: $result", PHP_EOL;
230 | self::assertStringStartsWith('{"result"', $result);
231 | }
232 |
233 | public function testGetDynasty()
234 | {
235 | $neb = new Neb(new HttpProvider(ApiTestHost));
236 | $result = $neb->api->getDynasty(1);
237 | echo "Dynasty: $result", PHP_EOL;
238 | self::assertStringStartsWith('{"result"', $result);
239 | }
240 |
241 | public function testGetTransactionReceipt()
242 | {
243 | $neb = new Neb(new HttpProvider(ApiTestHost));
244 | $result = $neb->api->getTransactionReceipt("8b98a5e4a27d2744a6295fe71e4f138d3e423ced11c81e201c12ac8379226ad1");
245 | echo "TransactionReceipt: $result", PHP_EOL;
246 | self::assertStringStartsWith('{"result"', $result);
247 | }
248 | }
249 |
--------------------------------------------------------------------------------
/tests/utils/CryptoTest.php:
--------------------------------------------------------------------------------
1 | assertTrue(strlen($privKey) === 64);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/tests/utils/UnitTest.php:
--------------------------------------------------------------------------------
1 | assertEquals($expect, $result);
24 | }
25 |
26 | /**
27 | * @dataProvider providerNasToBasic
28 | */
29 | public function testNasToBasic($number, $expect)
30 | {
31 | $result = Unit::nasToBasic($number);
32 | $this->assertEquals($expect, $result);
33 | }
34 |
35 | /**
36 | * @dataProvider providerFromBasic
37 | */
38 | public function testFromBasic($number, $unit, $expect)
39 | {
40 | $result = Unit::fromBasic($number, $unit);
41 | $this->assertEquals($expect, $result);
42 | }
43 |
44 | /**
45 | * @dataProvider providerToNas
46 | */
47 | public function testToNas($number, $unit, $expect)
48 | {
49 | $result = Unit::toNas($number, $unit);
50 | $this->assertEquals($expect, $result);
51 | }
52 |
53 | /**
54 | * @dataProvider providerException
55 | */
56 | public function testUnit($number, $unit, $expect)
57 | {
58 | $this->expectExceptionMessageRegExp('/The unit undefined, please use*/');
59 | $result = Unit::toNas($number, $unit);
60 | $this->assertEquals($expect, $result);
61 | }
62 |
63 | function providerNasToBasic()
64 | {
65 | return array(
66 | //array(nas, wei)
67 | array('1', '1'.'000000'.'000000'.'000000'),
68 | array('1.1', '1'.'100000'.'000000'.'000000'),
69 | array('0.001', '1000'.'000000'.'000000'),
70 | array('0.1234567891234567891234','123456789123456789')
71 | );
72 | }
73 |
74 | function providerToBasic()
75 | {
76 | return array(
77 | array('1.2', 'wei', '1'),
78 | array('1.2', 'kwei', '1'.'200'),
79 | array('1.2', 'mwei', '1'.'200'.'000'),
80 | array('1.2', 'Gwei', '1'.'200'.'000000'),
81 | array('1.2', 'nas', '1'.'200000'.'000000'.'000000'),
82 | );
83 | }
84 |
85 | function providerFromBasic()
86 | {
87 | return array(
88 | array('123456', 'wei', '123456'),
89 | array('123456', 'kwei', '123.456'),
90 | array('123456', 'mwei', '0.'.'123456'),
91 | array('123456', 'Gwei', '0.'.'000123456'),
92 | array('123456', 'nas', '0.'.'000000'.'000000'.'123456'),
93 | );
94 | }
95 |
96 | function providerToNas()
97 | {
98 | return array(
99 | array('123456', 'wei', '0.'.'000000'.'000000'.'123456'),
100 | array('123456', 'Kwei', '0.'.'000'.'000000'.'123456'),
101 | array('123456', 'mwei', '0.'.'000000'.'123456'),
102 | array('123456', 'Gwei', '0.'.'000'.'123456'),
103 | array('123456', 'nas', '123456'),
104 | array('0.123456789123456789'.'1234','nas','0.123456789123456789')
105 | );
106 | }
107 |
108 | //unit is wrong
109 | function providerException(){
110 | return array(
111 | array('1.2', 'wee', '1'),
112 | array('1.2', 'kkwei', '1'.'200'),
113 | array('1.2', 'mnwei', '1'.'200'.'000'),
114 | array('1.2', 'GWE', '1'.'200'.'000000'),
115 | array('1.2', 'Nass', '1'.'200000'.'000000'.'000000'),
116 | );
117 |
118 | }
119 |
120 | }
121 |
--------------------------------------------------------------------------------