Add set functions.
This commit is contained in:
parent
ee114fe7d1
commit
12994a7884
@ -28,6 +28,7 @@ use Web3\Contracts\Types\Uinteger;
|
|||||||
use Web3\Validators\AddressValidator;
|
use Web3\Validators\AddressValidator;
|
||||||
use Web3\Validators\HexValidator;
|
use Web3\Validators\HexValidator;
|
||||||
use Web3\Formatters\AddressFormatter;
|
use Web3\Formatters\AddressFormatter;
|
||||||
|
use Web3\Validators\StringValidator;
|
||||||
|
|
||||||
class Contract
|
class Contract
|
||||||
{
|
{
|
||||||
@ -168,6 +169,7 @@ class Contract
|
|||||||
if (method_exists($this, $method)) {
|
if (method_exists($this, $method)) {
|
||||||
return call_user_func_array([$this, $method], []);
|
return call_user_func_array([$this, $method], []);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,7 +177,7 @@ class Contract
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return bool
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function __set($name, $value)
|
public function __set($name, $value)
|
||||||
{
|
{
|
||||||
@ -201,15 +203,14 @@ class Contract
|
|||||||
* setProvider
|
* setProvider
|
||||||
*
|
*
|
||||||
* @param $provider
|
* @param $provider
|
||||||
* @return bool
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setProvider($provider)
|
public function setProvider($provider)
|
||||||
{
|
{
|
||||||
if ($provider instanceof Provider) {
|
if ($provider instanceof Provider) {
|
||||||
$this->provider = $provider;
|
$this->provider = $provider;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -252,6 +253,17 @@ class Contract
|
|||||||
return $this->abi;
|
return $this->abi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setAbi
|
||||||
|
*
|
||||||
|
* @param string $abi
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setAbi($abi)
|
||||||
|
{
|
||||||
|
return $this->abi($abi);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getEthabi
|
* getEthabi
|
||||||
*
|
*
|
||||||
@ -272,6 +284,28 @@ class Contract
|
|||||||
return $this->eth;
|
return $this->eth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setBytecode
|
||||||
|
*
|
||||||
|
* @param string $bytecode
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setBytecode($bytecode)
|
||||||
|
{
|
||||||
|
return $this->bytecode($bytecode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setToAddress
|
||||||
|
*
|
||||||
|
* @param string $bytecode
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setToAddress($address)
|
||||||
|
{
|
||||||
|
return $this->at($address);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* at
|
* at
|
||||||
*
|
*
|
||||||
@ -304,6 +338,35 @@ class Contract
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* abi
|
||||||
|
*
|
||||||
|
* @param string $abi
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function abi($abi)
|
||||||
|
{
|
||||||
|
if (StringValidator::validate($abi) === false) {
|
||||||
|
throw new InvalidArgumentException('Please make sure abi is valid.');
|
||||||
|
}
|
||||||
|
$abi = Utils::jsonToArray($abi, 5);
|
||||||
|
|
||||||
|
foreach ($abi as $item) {
|
||||||
|
if (isset($item['type'])) {
|
||||||
|
if ($item['type'] === 'function') {
|
||||||
|
$this->functions[$item['name']] = $item;
|
||||||
|
} elseif ($item['type'] === 'constructor') {
|
||||||
|
$this->constructor = $item;
|
||||||
|
} elseif ($item['type'] === 'event') {
|
||||||
|
$this->events[$item['name']] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->abi = $abi;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* new
|
* new
|
||||||
* Deploy a contruct with params.
|
* Deploy a contruct with params.
|
||||||
|
Loading…
Reference in New Issue
Block a user