diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz index d3754825..f2a9289d 100644 Binary files a/.yarn/install-state.gz and b/.yarn/install-state.gz differ diff --git a/packages/utils/package.json b/packages/utils/package.json index 26751d28..aee9a392 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@kiichain/kiijs-utils", - "version": "0.1.2", + "version": "0.1.3", "type": "module", "author": "kiiglobal.io ", "description": "TypeScript utility library for the Kii blockchain", diff --git a/packages/utils/src/ethers/bech32Conversion.ts b/packages/utils/src/ethers/bech32Conversion.ts index d31ededd..fb157663 100644 --- a/packages/utils/src/ethers/bech32Conversion.ts +++ b/packages/utils/src/ethers/bech32Conversion.ts @@ -1,6 +1,5 @@ -import { fromBech32 } from '@cosmjs/encoding'; -import { isAddress } from 'ethers'; -import { toBech32 } from '@cosmjs/encoding'; +import { fromBech32, toBech32, toHex } from '@cosmjs/encoding'; +import { getAddress, isAddress } from 'ethers'; /** * Function to turn a kii bech32 into an associated hex address @@ -12,7 +11,7 @@ export function Bech32ToHex(bechAddress: string): string | null { const { prefix, data } = fromBech32(bechAddress); if (prefix !== 'kii') return null; - const hex = '0x' + Buffer.from(data).toString('hex'); + const hex = getAddress(toHex(data)); return hex; } /** diff --git a/packages/utils/tests/address.test.ts b/packages/utils/tests/address.test.ts index a9ac155c..3fcc8d2e 100644 --- a/packages/utils/tests/address.test.ts +++ b/packages/utils/tests/address.test.ts @@ -1,7 +1,7 @@ import { Bech32ToHex } from '../src/ethers'; describe('Connect Wallet Test', () => { - const hex_address = '0x6647af9d3d958f0ce9d16913949a3a90b8a40a6a'; + const hex_address = '0x6647af9d3D958f0cE9D16913949A3A90B8A40a6a'; const kii_address = 'kii1ver6l8fajk8se6w3dyfefx36jzu2gzn2qmu3t9'; it('convert kii to hex', async () => {