Skip to content

Commit

Permalink
make unpadHexString return Hex String!
Browse files Browse the repository at this point in the history
  • Loading branch information
acolytec3 committed Mar 29, 2022
1 parent 38ce498 commit 74de550
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/util/src/bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const unpadArray = function (a: number[]): number[] {
export const unpadHexString = function (a: string): string {
assertIsHexString(a)
a = stripHexPrefix(a)
return stripZeros(a) as string
return ('0x' + stripZeros(a)) as string
}

export type ToBufferInputTypes =
Expand Down
2 changes: 1 addition & 1 deletion packages/util/test/bytes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ tape('unpadHexString', function (t) {
t.test('should unpad a hex prefixed string', function (st) {
const str = '0x0000000006600'
const r = unpadHexString(str)
st.equal(r, '6600')
st.equal(r, '0x6600')
st.end()
})
t.test('should throw if input is not hex-prefixed', function (st) {
Expand Down

0 comments on commit 74de550

Please sign in to comment.