diff --git a/.travis.yml b/.travis.yml index e6f816a..7ff137e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ language: php php: - 7.1 - 7.2 + - 7.3 install: - composer install @@ -20,4 +21,4 @@ script: - vendor/bin/phpunit --coverage-clover=coverage.xml after_success: - - bash <(curl -s https://codecov.io/bash) -t 284c5fc4-2109-4bb3-822f-82026d67b1bd \ No newline at end of file + - bash <(curl -s https://codecov.io/bash) -t 284c5fc4-2109-4bb3-822f-82026d67b1bd diff --git a/composer.json b/composer.json index b7787a2..3daaf81 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,9 @@ } }, "require": { - "web3p/rlp": "~0.2.1", - "web3p/ethereum-util": "~0.1.1", + "web3p/rlp": "0.3.2", + "web3p/ethereum-util": "~0.1.2", "kornrunner/keccak": "~1", - "simplito/elliptic-php": "1.0.*" + "simplito/elliptic-php": "~1.0.6" } } diff --git a/composer.lock b/composer.lock index 5a0ad5d..9249fb7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b4f99eafb5be92c13f45102e918ab6eb", + "content-hash": "de28da405ac699ffb57506b1f832536f", "packages": [ { "name": "kornrunner/keccak", @@ -128,16 +128,16 @@ }, { "name": "simplito/elliptic-php", - "version": "1.0.3", + "version": "1.0.6", "source": { "type": "git", "url": "https://github.com/simplito/elliptic-php.git", - "reference": "cab829d270dfd6acdff8383d862ed02a12d1f9dd" + "reference": "15652609aa55968d56685c2a9120535ccdc00fd9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/simplito/elliptic-php/zipball/cab829d270dfd6acdff8383d862ed02a12d1f9dd", - "reference": "cab829d270dfd6acdff8383d862ed02a12d1f9dd", + "url": "https://api.github.com/repos/simplito/elliptic-php/zipball/15652609aa55968d56685c2a9120535ccdc00fd9", + "reference": "15652609aa55968d56685c2a9120535ccdc00fd9", "shasum": "" }, "require": { @@ -184,20 +184,20 @@ "nistp521", "secp256k1" ], - "time": "2018-04-12T11:17:52+00:00" + "time": "2019-11-14T13:43:07+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.11.0", + "version": "v1.9.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" + "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d0cd638f4634c16d8df4508e847f14e9e43168b8", + "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8", "shasum": "" }, "require": { @@ -209,7 +209,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.9-dev" } }, "autoload": { @@ -243,26 +243,26 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2018-08-06T14:22:27+00:00" }, { "name": "web3p/ethereum-util", - "version": "0.1.1", + "version": "0.1.2", "source": { "type": "git", "url": "https://github.com/web3p/ethereum-util.git", - "reference": "4e5ef4dc4d60f7c8939f9f4da6f8dff5d51a2e91" + "reference": "c7b5edd1a3ca20d0dae93f6fb9d253c61dfb73c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/web3p/ethereum-util/zipball/4e5ef4dc4d60f7c8939f9f4da6f8dff5d51a2e91", - "reference": "4e5ef4dc4d60f7c8939f9f4da6f8dff5d51a2e91", + "url": "https://api.github.com/repos/web3p/ethereum-util/zipball/c7b5edd1a3ca20d0dae93f6fb9d253c61dfb73c6", + "reference": "c7b5edd1a3ca20d0dae93f6fb9d253c61dfb73c6", "shasum": "" }, "require": { "kornrunner/keccak": "~1", "php": "^7.1", - "simplito/elliptic-php": "1.0.3" + "simplito/elliptic-php": "~1.0.6" }, "require-dev": { "phpunit/phpunit": "^6.1" @@ -284,24 +284,24 @@ } ], "description": "A collection of utility functions for Ethereum written in PHP.", - "time": "2018-08-17T06:28:32+00:00" + "time": "2019-11-23T08:43:24+00:00" }, { "name": "web3p/rlp", - "version": "0.2.2", + "version": "0.3.2", "source": { "type": "git", "url": "https://github.com/web3p/rlp.git", - "reference": "1d0ebb4cb3baf5c45d0c653aecbe3f8daffd3bcd" + "reference": "bc9e29f7a1f658408f25322ea21ff5687a851470" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/web3p/rlp/zipball/1d0ebb4cb3baf5c45d0c653aecbe3f8daffd3bcd", - "reference": "1d0ebb4cb3baf5c45d0c653aecbe3f8daffd3bcd", + "url": "https://api.github.com/repos/web3p/rlp/zipball/bc9e29f7a1f658408f25322ea21ff5687a851470", + "reference": "bc9e29f7a1f658408f25322ea21ff5687a851470", "shasum": "" }, "require-dev": { - "phpunit/phpunit": "~6.0" + "phpunit/phpunit": "~7" }, "type": "library", "autoload": { @@ -320,35 +320,33 @@ } ], "description": "Recursive Length Prefix Encoding in PHP.", - "time": "2018-06-10T09:55:27+00:00" + "time": "2019-11-23T08:20:30+00:00" } ], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.2.0", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "a2c590166b2133a4633738648b6b064edae0814a" + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", - "reference": "a2c590166b2133a4633738648b6b064edae0814a", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "shasum": "" }, "require": { "php": "^7.1" }, "require-dev": { - "doctrine/coding-standard": "^6.0", + "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-shim": "^0.11", - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" }, "type": "library", "extra": { @@ -373,25 +371,25 @@ } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "homepage": "https://github.com/doctrine/instantiator", "keywords": [ "constructor", "instantiate" ], - "time": "2019-03-17T17:37:11+00:00" + "time": "2017-07-22T11:58:36+00:00" }, { "name": "myclabs/deep-copy", - "version": "1.9.1", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72" + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", - "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", "shasum": "" }, "require": { @@ -426,7 +424,7 @@ "object", "object graph" ], - "time": "2019-04-07T13:18:21+00:00" + "time": "2018-06-11T23:09:50+00:00" }, { "name": "phar-io/manifest", @@ -586,16 +584,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.1", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c" + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", "shasum": "" }, "require": { @@ -633,7 +631,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-04-30T17:48:53+00:00" + "time": "2017-11-30T07:14:17+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -996,16 +994,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.5.14", + "version": "6.5.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7" + "reference": "7bab54cb366076023bbf457a2a0d513332cd40f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bac23fe7ff13dbdb461481f706f0e9fe746334b7", - "reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7bab54cb366076023bbf457a2a0d513332cd40f2", + "reference": "7bab54cb366076023bbf457a2a0d513332cd40f2", "shasum": "" }, "require": { @@ -1076,7 +1074,7 @@ "testing", "xunit" ], - "time": "2019-02-01T05:22:47+00:00" + "time": "2018-08-07T07:05:35+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -1697,76 +1695,18 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.11.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "82ebae02209c21113908c229e9883c419720738a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", - "reference": "82ebae02209c21113908c229e9883c419720738a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "time": "2019-02-06T07:57:58+00:00" - }, { "name": "theseer/tokenizer", - "version": "1.1.2", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8" + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/1c42705be2b6c1de5904f8afacef5895cab44bf8", - "reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", "shasum": "" }, "require": { @@ -1793,25 +1733,24 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2019-04-04T09:56:43+00:00" + "time": "2017-04-07T12:08:54+00:00" }, { "name": "webmozart/assert", - "version": "1.4.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0", - "symfony/polyfill-ctype": "^1.8" + "php": "^5.3.3 || ^7.0" }, "require-dev": { "phpunit/phpunit": "^4.6", @@ -1844,7 +1783,7 @@ "check", "validate" ], - "time": "2018-12-25T11:19:39+00:00" + "time": "2018-01-29T19:49:41+00:00" } ], "aliases": [], diff --git a/src/Transaction.php b/src/Transaction.php index 0a4ad3e..04ed8db 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -148,7 +148,7 @@ public function __construct($txData=[]) foreach ($txData as $txKey => $data) { if (is_int($txKey)) { - $hexData = $data->toString('hex'); + $hexData = $data; if (strlen($hexData) > 0) { $tx[$txKey] = '0x' . $hexData; @@ -357,7 +357,7 @@ public function sign(string $privateKey) $this->offsetSet('v', $v); $this->privateKey = $privateKey; - return $this->serialize()->toString('hex'); + return $this->serialize(); } /** @@ -396,9 +396,9 @@ public function hash($includeSignature=false) } $this->txData = $rawTxData; } - $serializedTx = $this->rlp->encode($txData)->toString('utf8'); + $serializedTx = $this->rlp->encode($txData); - return $this->util->sha3($serializedTx); + return $this->util->sha3(hex2bin($serializedTx)); } /** diff --git a/test/unit/TransactionTest.php b/test/unit/TransactionTest.php index 09ca49c..9dd1e79 100644 --- a/test/unit/TransactionTest.php +++ b/test/unit/TransactionTest.php @@ -168,12 +168,12 @@ public function testSerialize() 'data' => '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675' ]); - $this->assertEquals('f84f018609184e72a0008276c094d46e8dd67c5d32be8058bb8eb970870f07244567849184e72aa9d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675', $transaction->serialize()->toString('hex')); + $this->assertEquals('f84f018609184e72a0008276c094d46e8dd67c5d32be8058bb8eb970870f07244567849184e72aa9d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675', $transaction->serialize()); // sign tx $transaction->sign($this->testPrivateKey); - $this->assertEquals('f892018609184e72a0008276c094d46e8dd67c5d32be8058bb8eb970870f07244567849184e72aa9d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f07244567523a0a48d3ce9c68bb49825aea5335bd07432823e858e8a504767d08290c28aafddf8a0416c7abc3a67080db0ad07c42de82db4e05518f99595119677398c68d431ab37', $transaction->serialize()->toString('hex')); + $this->assertEquals('f892018609184e72a0008276c094d46e8dd67c5d32be8058bb8eb970870f07244567849184e72aa9d46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f07244567523a0a48d3ce9c68bb49825aea5335bd07432823e858e8a504767d08290c28aafddf8a0416c7abc3a67080db0ad07c42de82db4e05518f99595119677398c68d431ab37', $transaction->serialize()); } /** @@ -197,7 +197,7 @@ public function testEIP155() $transaction['r'] = ''; $transaction['s'] = ''; $transaction['v'] = 1; - $this->assertEquals('ec098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a764000080018080', $transaction->serialize()->toString('hex')); + $this->assertEquals('ec098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a764000080018080', $transaction->serialize()); $transaction = new Transaction([ 'nonce' => '0x09', @@ -223,7 +223,7 @@ public function testEIP155() $this->assertEquals('f864098504a817c800825208943535353535353535353535353535353535353535808025a0855ec9b7d4fcabf535fe4ac4a7c31a9e521214d05bc6efbc058d4757c35e92bba0043d7df30c8a79e5522b3de8fc169df5fa7145714100ee8ec413292d97ce4d3a', $transaction->sign('0x4646464646464646464646464646464646464646464646464646464646464646')); $transaction = new Transaction('0xf86c098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a76400008025a028ef61340bd939bc2195fe537567866003e1a15d3c71ff63e1590620aa636276a067cbe9d8997f761aecb703304b3800ccf555c9f3dc64214b297fb1966a3b6d83'); - $this->assertEquals('f86c098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a76400008025a028ef61340bd939bc2195fe537567866003e1a15d3c71ff63e1590620aa636276a067cbe9d8997f761aecb703304b3800ccf555c9f3dc64214b297fb1966a3b6d83', $transaction->serialize()->toString('hex')); + $this->assertEquals('f86c098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a76400008025a028ef61340bd939bc2195fe537567866003e1a15d3c71ff63e1590620aa636276a067cbe9d8997f761aecb703304b3800ccf555c9f3dc64214b297fb1966a3b6d83', $transaction->serialize()); } /**