(value: HexString)
| 25 | |
| 26 | // This is a clone from ethers.util hexStripZeros, in order to match polkadot util hex value with ethers |
| 27 | export function hexStripZeros(value: HexString): string { |
| 28 | if (!isHex(value)) { |
| 29 | throw new Error(`invalid hex string ${value}`); |
| 30 | } |
| 31 | const str = value.toString().substring(2); |
| 32 | let offset = 0; |
| 33 | while (offset < str.length && str[offset] === '0') { |
| 34 | offset++; |
| 35 | } |
| 36 | const trimmed = `0x${str.substring(offset)}`; |
| 37 | if (trimmed === '0x') { |
| 38 | return '0x0'; |
| 39 | } |
| 40 | return trimmed; |
| 41 | } |
no outgoing calls
no test coverage detected