Skip to content

Commit

Permalink
block & transaction info
Browse files Browse the repository at this point in the history
  • Loading branch information
kesar committed Nov 12, 2017
1 parent 5903dea commit 749fa99
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/EthereumPHP/Types/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Block
public function __construct($response)
{
$this->difficulty = hexdec($response['difficulty']);
$this->extraData = hexdec($response['extraData']);
$this->extraData = $response['extraData'];
$this->gasLimit = hexdec($response['gasLimit']);
$this->gasUsed = new Wei(hexdec($response['gasUsed']));
$this->hash = new BlockHash($response['hash']);
Expand All @@ -55,17 +55,17 @@ public function __construct($response)
}
}

public function difficulty(): number
public function difficulty(): int
{
return $this->difficulty;
}

public function extraData(): number
public function extraData(): string
{
return $this->extraData;
}

public function gasLimit(): number
public function gasLimit(): int
{
return $this->gasLimit;
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public function nonce(): string
return $this->nonce;
}

public function number(): number
public function number(): int
{
return $this->number;
}
Expand All @@ -120,7 +120,7 @@ public function sha3Uncles(): Hash
return $this->sha3Uncles;
}

public function size(): number
public function size(): int
{
return $this->size;
}
Expand All @@ -130,12 +130,12 @@ public function stateRoot(): Hash
return $this->stateRoot;
}

public function timestamp(): number
public function timestamp(): int
{
return $this->timestamp;
}

public function totalDifficulty(): number
public function totalDifficulty(): int
{
return $this->totalDifficulty;
}
Expand Down
100 changes: 99 additions & 1 deletion src/EthereumPHP/Types/TransactionInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,106 @@

class TransactionInfo
{
// TODO: do it
private $blockHash;
private $blockNumber;
private $from;
private $to;
private $gas;
private $gasPrice;
private $hash;
private $input;
private $nonce;
private $transactionIndex;
private $value;
private $v;
private $r;
private $s;

public function __construct($response)
{
$this->blockHash = new BlockHash($response['blockHash']);
$this->blockNumber = hexdec($response['blockHash']);
$this->from = new Address($response['from']);
$this->to = new Address($response['to']);
$this->gas = new Wei(hexdec($response['gas']));
$this->gasPrice = hexdec($response['gasPrice']);
$this->hash = new TransactionHash($response['hash']);
$this->input = $response['input'];
$this->nonce = $response['nonce'];
$this->transactionIndex = hexdec($response['transactionIndex']);
$this->value = hexdec($response['value']);
$this->v = $response['v'];
$this->r = $response['r'];
$this->s = $response['s'];
}

public function blockHash(): BlockHash
{
return $this->blockHash;
}

public function blockNumber(): int
{
return $this->blockNumber;
}

public function from(): Address
{
return $this->from;
}

public function to(): Address
{
return $this->to;
}

public function gas(): Wei
{
return $this->gas;
}

public function gasPrice(): int
{
return $this->gasPrice;
}

public function hash(): TransactionHash
{
return $this->hash;
}

public function input(): string
{
return $this->input;
}

public function nonce(): string
{
return $this->nonce;
}

public function transactionIndex(): int
{
return $this->transactionIndex;
}

public function value(): int
{
return $this->value;
}

public function v(): string
{
return $this->v;
}

public function r(): string
{
return $this->r;
}

public function s(): string
{
return $this->s;
}
}

0 comments on commit 749fa99

Please sign in to comment.