mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49:15 +00:00
commit
fca31fa51a
@ -26,6 +26,8 @@ and this project adheres to
|
|||||||
let it support both Tendermint 0.34 and 0.37 events as input.
|
let it support both Tendermint 0.34 and 0.37 events as input.
|
||||||
- @cosmjs/cosmwasm-stargate: Remove `cosmWasmTypes`. Use
|
- @cosmjs/cosmwasm-stargate: Remove `cosmWasmTypes`. Use
|
||||||
`createWasmAminoConverters()` instead.
|
`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
|
[#1002]: https://github.com/cosmos/cosmjs/issues/1002
|
||||||
[#1240]: https://github.com/cosmos/cosmjs/pull/1240
|
[#1240]: https://github.com/cosmos/cosmjs/pull/1240
|
||||||
|
@ -48,7 +48,7 @@ $ cosmjs-cli
|
|||||||
const account = await client.getAccount(faucetAddress);
|
const account = await client.getAccount(faucetAddress);
|
||||||
|
|
||||||
// Craft a send transaction
|
// 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 memo = "My very first tx!";
|
||||||
const msgSend = {
|
const msgSend = {
|
||||||
fromAddress: faucetAddress,
|
fromAddress: faucetAddress,
|
||||||
|
@ -2,7 +2,6 @@ import { StdFee, SigningStargateClient } from "@cosmjs/stargate";
|
|||||||
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
|
||||||
import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
|
import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
|
||||||
import { coins } from "@cosmjs/amino";
|
import { coins } from "@cosmjs/amino";
|
||||||
import { Bech32 } from "@cosmjs/encoding";
|
|
||||||
import { Random } from "@cosmjs/crypto";
|
import { Random } from "@cosmjs/crypto";
|
||||||
|
|
||||||
const defaultHttpUrl = "http://localhost:26658";
|
const defaultHttpUrl = "http://localhost:26658";
|
||||||
|
@ -71,7 +71,6 @@ export async function main(originalArgs: readonly string[]): Promise<void> {
|
|||||||
toBase64,
|
toBase64,
|
||||||
toHex,
|
toHex,
|
||||||
toUtf8,
|
toUtf8,
|
||||||
Bech32,
|
|
||||||
} from "@cosmjs/encoding";
|
} from "@cosmjs/encoding";
|
||||||
import { sha512, Bip39, Random } from "@cosmjs/crypto";
|
import { sha512, Bip39, Random } from "@cosmjs/crypto";
|
||||||
import {
|
import {
|
||||||
|
@ -26,25 +26,3 @@ export function normalizeBech32(address: string): string {
|
|||||||
const { prefix, data } = fromBech32(address);
|
const { prefix, data } = fromBech32(address);
|
||||||
return toBech32(prefix, data);
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export { fromAscii, toAscii } from "./ascii";
|
export { fromAscii, toAscii } from "./ascii";
|
||||||
export { fromBase64, toBase64 } from "./base64";
|
export { fromBase64, toBase64 } from "./base64";
|
||||||
export { Bech32, fromBech32, normalizeBech32, toBech32 } from "./bech32";
|
export { fromBech32, normalizeBech32, toBech32 } from "./bech32";
|
||||||
export { fromHex, toHex } from "./hex";
|
export { fromHex, toHex } from "./hex";
|
||||||
export { fromRfc3339, toRfc3339 } from "./rfc3339";
|
export { fromRfc3339, toRfc3339 } from "./rfc3339";
|
||||||
export { fromUtf8, toUtf8 } from "./utf8";
|
export { fromUtf8, toUtf8 } from "./utf8";
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Bech32 } from "@cosmjs/encoding";
|
import { fromBech32 } from "@cosmjs/encoding";
|
||||||
|
|
||||||
export function isValidAddress(input: string, requiredPrefix: string): boolean {
|
export function isValidAddress(input: string, requiredPrefix: string): boolean {
|
||||||
try {
|
try {
|
||||||
const { prefix, data } = Bech32.decode(input);
|
const { prefix, data } = fromBech32(input);
|
||||||
if (prefix !== requiredPrefix) {
|
if (prefix !== requiredPrefix) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user