From c1fa22c1a5bed344aaa19c2972e6407d78102b6a Mon Sep 17 00:00:00 2001 From: Dimitris Frangiadakis Date: Mon, 29 Jul 2019 10:06:25 +0300 Subject: [PATCH] Adds helper function to turn decimal ICX value to hex --- src/IconService.php | 5 +++++ tests/IconServiceTest.php | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/IconService.php b/src/IconService.php index f18cbaa..672c8bf 100644 --- a/src/IconService.php +++ b/src/IconService.php @@ -886,4 +886,9 @@ private function getBase64TimestampInMilliseconds() return $milliseconds; } + public function icxToHex($value){ + $dec = $value* 10**18; + return '0x'.dechex($value* 10**18); + } + } diff --git a/tests/IconServiceTest.php b/tests/IconServiceTest.php index 1b22d60..be126a0 100644 --- a/tests/IconServiceTest.php +++ b/tests/IconServiceTest.php @@ -1,5 +1,6 @@ icon_service_URL_yeouido); + $result = '0x2386f26fc10000'; + $this->assertTrue($var->icxToHex(0.01) === $result); + unset($var); + } }