diff --git a/packages/bcp/src/address.ts b/packages/bcp/src/address.ts index 10a718bf..11afa609 100644 --- a/packages/bcp/src/address.ts +++ b/packages/bcp/src/address.ts @@ -1,4 +1,4 @@ -import { decodeBech32Pubkey, encodeAddress, types } from "@cosmwasm/sdk"; +import { decodeBech32Pubkey, pubkeyToAddress as sdkPubkeyToAddress, types } from "@cosmwasm/sdk"; import { Address, Algorithm, PubkeyBundle, PubkeyBytes } from "@iov/bcp"; import { Secp256k1 } from "@iov/crypto"; import { Encoding } from "@iov/encoding"; @@ -34,5 +34,5 @@ export function pubkeyToAddress(pubkey: PubkeyBundle, prefix: string): Address { throw new Error(`Unsupported algorithm: ${pubkey.algo}`); } - return encodeAddress(sdkKey, prefix) as Address; + return sdkPubkeyToAddress(sdkKey, prefix) as Address; } diff --git a/packages/sdk/src/address.spec.ts b/packages/sdk/src/address.spec.ts index 875ec9bd..713ffd03 100644 --- a/packages/sdk/src/address.spec.ts +++ b/packages/sdk/src/address.spec.ts @@ -1,18 +1,18 @@ import { Encoding } from "@iov/encoding"; -import { encodeAddress } from "./address"; +import { pubkeyToAddress } from "./address"; const { toBase64, fromHex } = Encoding; describe("address", () => { - describe("encodeAddress", () => { + describe("pubkeyToAddress", () => { it("works for Secp256k1 compressed", () => { const prefix = "cosmos"; const pubkey = { type: "tendermint/PubKeySecp256k1", value: "AtQaCqFnshaZQp6rIkvAPyzThvCvXSDO+9AzbxVErqJP", }; - expect(encodeAddress(pubkey, prefix)).toEqual("cosmos1h806c7khnvmjlywdrkdgk2vrayy2mmvf9rxk2r"); + expect(pubkeyToAddress(pubkey, prefix)).toEqual("cosmos1h806c7khnvmjlywdrkdgk2vrayy2mmvf9rxk2r"); }); it("works for Ed25519", () => { @@ -21,7 +21,7 @@ describe("address", () => { type: "tendermint/PubKeyEd25519", value: toBase64(fromHex("12ee6f581fe55673a1e9e1382a0829e32075a0aa4763c968bc526e1852e78c95")), }; - expect(encodeAddress(pubkey, prefix)).toEqual("cosmos1pfq05em6sfkls66ut4m2257p7qwlk448h8mysz"); + expect(pubkeyToAddress(pubkey, prefix)).toEqual("cosmos1pfq05em6sfkls66ut4m2257p7qwlk448h8mysz"); }); }); }); diff --git a/packages/sdk/src/address.ts b/packages/sdk/src/address.ts index 2aa2e0cf..58ec7da3 100644 --- a/packages/sdk/src/address.ts +++ b/packages/sdk/src/address.ts @@ -7,7 +7,7 @@ const { fromBase64 } = Encoding; // See https://github.com/tendermint/tendermint/blob/f2ada0a604b4c0763bda2f64fac53d506d3beca7/docs/spec/blockchain/encoding.md#public-key-cryptography // This assumes we already have a cosmos-compressed pubkey -export function encodeAddress(pubkey: PubKey, prefix: string): string { +export function pubkeyToAddress(pubkey: PubKey, prefix: string): string { const pubkeyBytes = fromBase64(pubkey.value); switch (pubkey.type) { case pubkeyType.secp256k1: { diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index 22a96fa5..5b73039a 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -2,7 +2,7 @@ import * as logs from "./logs"; import * as types from "./types"; export { logs, types }; -export { encodeAddress } from "./address"; +export { pubkeyToAddress } from "./address"; export { unmarshalTx } from "./decoding"; export { makeSignBytes, marshalTx } from "./encoding"; export { BroadcastMode, RestClient, TxsResponse } from "./restclient"; diff --git a/packages/sdk/types/address.d.ts b/packages/sdk/types/address.d.ts index ab4e3184..a8f251fb 100644 --- a/packages/sdk/types/address.d.ts +++ b/packages/sdk/types/address.d.ts @@ -1,2 +1,2 @@ import { PubKey } from "./types"; -export declare function encodeAddress(pubkey: PubKey, prefix: string): string; +export declare function pubkeyToAddress(pubkey: PubKey, prefix: string): string; diff --git a/packages/sdk/types/index.d.ts b/packages/sdk/types/index.d.ts index a2907b3d..df828d87 100644 --- a/packages/sdk/types/index.d.ts +++ b/packages/sdk/types/index.d.ts @@ -1,7 +1,7 @@ import * as logs from "./logs"; import * as types from "./types"; export { logs, types }; -export { encodeAddress } from "./address"; +export { pubkeyToAddress } from "./address"; export { unmarshalTx } from "./decoding"; export { makeSignBytes, marshalTx } from "./encoding"; export { BroadcastMode, RestClient, TxsResponse } from "./restclient";