diff --git a/src/core/bech32.ts b/src/core/bech32.ts index 52bce2b..9e68583 100644 --- a/src/core/bech32.ts +++ b/src/core/bech32.ts @@ -67,7 +67,7 @@ export namespace AccAddress { * @param hexAddress hex address */ export function fromHex(hexAddress: string): AccAddress { - const hex = hexAddress.startsWith('0x') ? hexAddress.slice(2) : hexAddress; + const hex = hexAddress.replace(/^0x0+|^0x|^0+(?!x)/, ''); // That moudule address reach here is nearly impossible if (hex.length <= 40) { return bech32.encode(