From 5866875813e9a3b15af2934c2d5d56370b63c9ab Mon Sep 17 00:00:00 2001 From: joelcho Date: Thu, 14 Jul 2022 01:45:35 +0800 Subject: [PATCH] fix Invalid request Some RPC services will return invalid request when the param is null --- Core/SWeb3.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Core/SWeb3.php b/Core/SWeb3.php index 631170c..ab7b149 100644 --- a/Core/SWeb3.php +++ b/Core/SWeb3.php @@ -82,15 +82,17 @@ function setPersonalData($address, $privKey) function call($method, $params = null) { - if ($params != null) $params = $this->utils->forceAllNumbersHex($params); - //format api data $ethRequest = new Ethereum_CRPC(); $ethRequest->id = 1; $ethRequest->jsonrpc = '2.0'; $ethRequest->method = $method; - $ethRequest->params = $params; - + if ($params != null) { + $ethRequest->params = $this->utils->forceAllNumbersHex($params); + } else { + $ethRequest->params = []; + } + if ($this->do_batch) { $this->batched_calls []= $ethRequest; return true;