Skip to content

Commit

Permalink
Adds helper function to turn decimal ICX value to hex
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsosf committed Jul 29, 2019
1 parent 10bba75 commit c1fa22c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/IconService.php
Original file line number Diff line number Diff line change
Expand Up @@ -886,4 +886,9 @@ private function getBase64TimestampInMilliseconds()
return $milliseconds;
}

public function icxToHex($value){
$dec = $value* 10**18;
return '0x'.dechex($value* 10**18);
}

}
8 changes: 8 additions & 0 deletions tests/IconServiceTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use mitsosf\IconSDK\IconService;
use PHPUnit\Framework\TestCase;


Expand Down Expand Up @@ -245,4 +246,11 @@ public function test_message()


}

public function test_icxToHex(){
$var = new mitsosf\IconSDK\IconService($this->icon_service_URL_yeouido);
$result = '0x2386f26fc10000';
$this->assertTrue($var->icxToHex(0.01) === $result);
unset($var);
}
}

0 comments on commit c1fa22c

Please sign in to comment.