add: defaultBlock in Contract.call() method
This commit is contained in:
parent
8a34582d23
commit
7cdb9a31a2
@ -12,12 +12,6 @@
|
||||
namespace Web3;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Web3\Providers\Provider;
|
||||
use Web3\Providers\HttpProvider;
|
||||
use Web3\RequestManagers\RequestManager;
|
||||
use Web3\RequestManagers\HttpRequestManager;
|
||||
use Web3\Utils;
|
||||
use Web3\Eth;
|
||||
use Web3\Contracts\Ethabi;
|
||||
use Web3\Contracts\Types\Address;
|
||||
use Web3\Contracts\Types\Boolean;
|
||||
@ -26,9 +20,14 @@ use Web3\Contracts\Types\DynamicBytes;
|
||||
use Web3\Contracts\Types\Integer;
|
||||
use Web3\Contracts\Types\Str;
|
||||
use Web3\Contracts\Types\Uinteger;
|
||||
use Web3\Eth;
|
||||
use Web3\Formatters\AddressFormatter;
|
||||
use Web3\Providers\HttpProvider;
|
||||
use Web3\Providers\Provider;
|
||||
use Web3\RequestManagers\HttpRequestManager;
|
||||
use Web3\Utils;
|
||||
use Web3\Validators\AddressValidator;
|
||||
use Web3\Validators\HexValidator;
|
||||
use Web3\Formatters\AddressFormatter;
|
||||
use Web3\Validators\StringValidator;
|
||||
|
||||
class Contract
|
||||
@ -82,6 +81,13 @@ class Contract
|
||||
*/
|
||||
protected $bytecode;
|
||||
|
||||
/**
|
||||
* defaultBlock
|
||||
*
|
||||
* @var string|int
|
||||
*/
|
||||
protected $defaultBlock;
|
||||
|
||||
/**
|
||||
* eth
|
||||
*
|
||||
@ -103,7 +109,7 @@ class Contract
|
||||
* @param string|\stdClass|array $abi
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($provider, $abi)
|
||||
public function __construct($provider, $abi, $defaultBlock = 'pending')
|
||||
{
|
||||
if (is_string($provider) && (filter_var($provider, FILTER_VALIDATE_URL) !== false)) {
|
||||
// check the uri schema
|
||||
@ -148,6 +154,7 @@ class Contract
|
||||
'string' => new Str,
|
||||
'uint' => new Uinteger,
|
||||
]);
|
||||
$this->defaultBlock = $defaultBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -402,8 +409,7 @@ class Contract
|
||||
* @param mixed
|
||||
* @return void
|
||||
*/
|
||||
public function new()
|
||||
{
|
||||
function new () {
|
||||
if (isset($this->constructor)) {
|
||||
$constructor = $this->constructor;
|
||||
$arguments = func_get_args();
|
||||
@ -428,7 +434,7 @@ class Contract
|
||||
}
|
||||
$transaction['data'] = '0x' . $this->bytecode . Utils::stripZero($data);
|
||||
|
||||
$this->eth->sendTransaction($transaction, function ($err, $transaction) use ($callback){
|
||||
$this->eth->sendTransaction($transaction, function ($err, $transaction) use ($callback) {
|
||||
if ($err !== null) {
|
||||
return call_user_func($callback, $err, null);
|
||||
}
|
||||
@ -523,7 +529,7 @@ class Contract
|
||||
$transaction['to'] = $this->toAddress;
|
||||
$transaction['data'] = $functionSignature . Utils::stripZero($data);
|
||||
|
||||
$this->eth->sendTransaction($transaction, function ($err, $transaction) use ($callback){
|
||||
$this->eth->sendTransaction($transaction, function ($err, $transaction) use ($callback) {
|
||||
if ($err !== null) {
|
||||
return call_user_func($callback, $err, null);
|
||||
}
|
||||
@ -618,7 +624,7 @@ class Contract
|
||||
$transaction['to'] = $this->toAddress;
|
||||
$transaction['data'] = $functionSignature . Utils::stripZero($data);
|
||||
|
||||
$this->eth->call($transaction, function ($err, $transaction) use ($callback, $function){
|
||||
$this->eth->call($transaction, $this->defaultBlock, function ($err, $transaction) use ($callback, $function) {
|
||||
if ($err !== null) {
|
||||
return call_user_func($callback, $err, null);
|
||||
}
|
||||
@ -738,7 +744,7 @@ class Contract
|
||||
$transaction['data'] = $functionSignature . Utils::stripZero($data);
|
||||
}
|
||||
|
||||
$this->eth->estimateGas($transaction, function ($err, $gas) use ($callback){
|
||||
$this->eth->estimateGas($transaction, function ($err, $gas) use ($callback) {
|
||||
if ($err !== null) {
|
||||
return call_user_func($callback, $err, null);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user