Fix for PHP Notice: Undefined index: inputs in src/Contract.php on line 394
When creating an instance of the contract with the new method, `$constructor['inputs']` is not available all the time, causing the above notice This commit fixes it by checking it first
This commit is contained in:
parent
1fb7762eb7
commit
0f1b9183b0
@ -391,7 +391,8 @@ class Contract
|
|||||||
$arguments = func_get_args();
|
$arguments = func_get_args();
|
||||||
$callback = array_pop($arguments);
|
$callback = array_pop($arguments);
|
||||||
|
|
||||||
if (count($arguments) < count($constructor['inputs'])) {
|
$input_count = isset($constructor['inputs']) ? count($constructor['inputs']) : 0;
|
||||||
|
if (count($arguments) < $input_count) {
|
||||||
throw new InvalidArgumentException('Please make sure you have put all constructor params and callback.');
|
throw new InvalidArgumentException('Please make sure you have put all constructor params and callback.');
|
||||||
}
|
}
|
||||||
if (is_callable($callback) !== true) {
|
if (is_callable($callback) !== true) {
|
||||||
@ -400,7 +401,7 @@ class Contract
|
|||||||
if (!isset($this->bytecode)) {
|
if (!isset($this->bytecode)) {
|
||||||
throw new \InvalidArgumentException('Please call bytecode($bytecode) before new().');
|
throw new \InvalidArgumentException('Please call bytecode($bytecode) before new().');
|
||||||
}
|
}
|
||||||
$params = array_splice($arguments, 0, count($constructor['inputs']));
|
$params = array_splice($arguments, 0, $input_count);
|
||||||
$data = $this->ethabi->encodeParameters($constructor, $params);
|
$data = $this->ethabi->encodeParameters($constructor, $params);
|
||||||
$transaction = [];
|
$transaction = [];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user