Transaction formatter.
This commit is contained in:
parent
b8e4773787
commit
b48ac9f97f
47
src/Formatters/TransactionFormatter.php
Normal file
47
src/Formatters/TransactionFormatter.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of web3.php package.
|
||||
*
|
||||
* (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
|
||||
*
|
||||
* @author Peter Lai <alk03073135@gmail.com>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace Web3\Formatters;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Web3\Utils;
|
||||
use Web3\Formatters\IFormatter;
|
||||
use Web3\Formatters\HexFormatter;
|
||||
use Web3\Formatters\QuantityFormatter;
|
||||
|
||||
class TransactionFormatter implements IFormatter
|
||||
{
|
||||
/**
|
||||
* format
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public static function format($value)
|
||||
{
|
||||
if (isset($value['gas'])) {
|
||||
$value['gas'] = QuantityFormatter::format($value['gas']);
|
||||
}
|
||||
if (isset($value['gasPrice'])) {
|
||||
$value['gasPrice'] = QuantityFormatter::format($value['gasPrice']);
|
||||
}
|
||||
if (isset($value['value'])) {
|
||||
$value['value'] = QuantityFormatter::format($value['value']);
|
||||
}
|
||||
if (isset($value['data'])) {
|
||||
$value['data'] = HexFormatter::format($value['gas']);
|
||||
}
|
||||
if (isset($value['nonce'])) {
|
||||
$value['nonce'] = QuantityFormatter::format($value['nonce']);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user