Skip to content

Commit

Permalink
Remove Bech32 class
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Mar 7, 2023
1 parent e89a914 commit 0351a46
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 28 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ and this project adheres to
let it support both Tendermint 0.34 and 0.37 events as input.
- @cosmjs/cosmwasm-stargate: Remove `cosmWasmTypes`. Use
`createWasmAminoConverters()` instead.
- @cosmjs/encoding: Remove previously deprecated `Bech32` class. Please replace
`Bech32.encode`/`.decode` with free the functions `toBech32`/`fromBech32`.

[#1002]: https://github.com/cosmos/cosmjs/issues/1002
[#1240]: https://github.com/cosmos/cosmjs/pull/1240
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $ cosmjs-cli
const account = await client.getAccount(faucetAddress);

// Craft a send transaction
const emptyAddress = Bech32.encode("cosmos", Random.getBytes(20));
const emptyAddress = toBech32("cosmos", Random.getBytes(20));
const memo = "My very first tx!";
const msgSend = {
fromAddress: faucetAddress,
Expand Down
1 change: 0 additions & 1 deletion packages/cli/examples/local_faucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { StdFee, SigningStargateClient } from "@cosmjs/stargate";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
import { coins } from "@cosmjs/amino";
import { Bech32 } from "@cosmjs/encoding";
import { Random } from "@cosmjs/crypto";

const defaultHttpUrl = "http://localhost:26658";
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export async function main(originalArgs: readonly string[]): Promise<void> {
toBase64,
toHex,
toUtf8,
Bech32,
} from "@cosmjs/encoding";
import { sha512, Bip39, Random } from "@cosmjs/crypto";
import {
Expand Down
22 changes: 0 additions & 22 deletions packages/encoding/src/bech32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,3 @@ export function normalizeBech32(address: string): string {
const { prefix, data } = fromBech32(address);
return toBech32(prefix, data);
}

/**
* @deprecated This class is deprecated and will be removed soon. Please use fromBech32() and toBech32() instead. For more details please refer to https://github.com/cosmos/cosmjs/issues/1053.
*/
export class Bech32 {
/**
* @deprecated This class is deprecated and will be removed soon. Please use fromBech32() and toBech32() instead. For more details please refer to https://github.com/cosmos/cosmjs/issues/1053.
*/
public static encode(prefix: string, data: Uint8Array, limit?: number): string {
return toBech32(prefix, data, limit);
}

/**
* @deprecated This class is deprecated and will be removed soon. Please use fromBech32() and toBech32() instead. For more details please refer to https://github.com/cosmos/cosmjs/issues/1053.
*/
public static decode(
address: string,
limit = Infinity,
): { readonly prefix: string; readonly data: Uint8Array } {
return fromBech32(address, limit);
}
}
2 changes: 1 addition & 1 deletion packages/encoding/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { fromAscii, toAscii } from "./ascii";
export { fromBase64, toBase64 } from "./base64";
export { Bech32, fromBech32, normalizeBech32, toBech32 } from "./bech32";
export { fromBech32, normalizeBech32, toBech32 } from "./bech32";
export { fromHex, toHex } from "./hex";
export { fromRfc3339, toRfc3339 } from "./rfc3339";
export { fromUtf8, toUtf8 } from "./utf8";
4 changes: 2 additions & 2 deletions packages/faucet/src/addresses.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Bech32 } from "@cosmjs/encoding";
import { fromBech32 } from "@cosmjs/encoding";

export function isValidAddress(input: string, requiredPrefix: string): boolean {
try {
const { prefix, data } = Bech32.decode(input);
const { prefix, data } = fromBech32(input);
if (prefix !== requiredPrefix) {
return false;
}
Expand Down

0 comments on commit 0351a46

Please sign in to comment.