contract batch send transaction
This commit is contained in:
parent
d69ce96a64
commit
a47544b991
@ -490,7 +490,6 @@ class Contract
|
||||
if (isset($this->functions)) {
|
||||
$arguments = func_get_args();
|
||||
$method = array_splice($arguments, 0, 1)[0];
|
||||
$callback = array_pop($arguments);
|
||||
|
||||
if (!is_string($method)) {
|
||||
throw new InvalidArgumentException('Please make sure the method is string.');
|
||||
@ -505,9 +504,18 @@ class Contract
|
||||
if (count($functions) < 1) {
|
||||
throw new InvalidArgumentException('Please make sure the method exists.');
|
||||
}
|
||||
/* if (is_callable($callback) !== true) {
|
||||
throw new \InvalidArgumentException('The last param must be callback function.');
|
||||
}*/
|
||||
if ($this->eth->provider->isBatch) {
|
||||
$callback = null;
|
||||
} else {
|
||||
$callback = array_pop($arguments);
|
||||
|
||||
if (is_callable($callback) !== true) {
|
||||
throw new \InvalidArgumentException('The last param must be callback function.');
|
||||
}
|
||||
}
|
||||
|
||||
// check the last one in arguments is transaction object
|
||||
$argsLen = count($arguments);
|
||||
@ -564,6 +572,9 @@ class Contract
|
||||
$transaction['to'] = $this->toAddress;
|
||||
$transaction['data'] = $functionSignature . Utils::stripZero($data);
|
||||
|
||||
if ($this->eth->provider->isBatch) {
|
||||
$this->eth->sendTransaction($transaction);
|
||||
} else {
|
||||
$this->eth->sendTransaction($transaction, function ($err, $transaction) use ($callback){
|
||||
if ($err !== null) {
|
||||
return call_user_func($callback, $err, null);
|
||||
@ -572,6 +583,7 @@ class Contract
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* call
|
||||
|
Loading…
Reference in New Issue
Block a user