Skip to content

Commit

Permalink
Merge branch '50-tominhex-bug' into 'develop'
Browse files Browse the repository at this point in the history
Resolve "toMinHex() bug"

Closes #46 and #50

See merge request in3/ts/in3!46
  • Loading branch information
simon-jentzsch committed Jul 22, 2019
2 parents 00f6eb0 + 2bc93f0 commit 1012eb9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ export function getAddress(pk: string) {
export function toMinHex(key: string | Buffer | number) {
if (typeof key === 'number')
key = toHex(key)

if (typeof key === 'string') {
key = key.trim()

if(key.length<3 || key[0]!='0' || key[1]!='x')
throw new Error("Only Hex format is supported. Given value "+ key +" is not valid Hex ")

for (let i = 2; i < key.length; i++) {
if (key[i] !== '0')
return '0x' + key.substr(i)
Expand Down

0 comments on commit 1012eb9

Please sign in to comment.