diff --git a/CHANGELOG.md b/CHANGELOG.md index cb2c464f8f..16a828eb4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.22.1 (unreleased) + +- @cosmjs/launchpad: Add ed25519 support to `encodeBech32Pubkey`. + ## 0.22.0 (2020-08-03) - @cosmjs/cli: Now supports HTTPs URLs for `--init` code sources. diff --git a/packages/launchpad/src/pubkey.spec.ts b/packages/launchpad/src/pubkey.spec.ts index 03253695e4..4c34209ebe 100644 --- a/packages/launchpad/src/pubkey.spec.ts +++ b/packages/launchpad/src/pubkey.spec.ts @@ -51,5 +51,17 @@ describe("pubkey", () => { "cosmospub1addwnpepqd8sgxq7aw348ydctp3n5ajufgxp395hksxjzc6565yfp56scupfqhlgyg5", ); }); + + it("works for ed25519", () => { + // Decoded from http://localhost:26657/validators + // Encoded from `corald tendermint show-validator` + const pubkey: PubKey = { + type: "tendermint/PubKeyEd25519", + value: "YZHlYxP5R6olj3Tj3f7VgkQE5VaOvv9G0jKATqdQsqI=", + }; + expect(encodeBech32Pubkey(pubkey, "coralvalconspub")).toEqual( + "coralvalconspub1zcjduepqvxg72ccnl9r65fv0wn3amlk4sfzqfe2k36l073kjx2qyaf6sk23qw7j8wq", + ); + }); }); }); diff --git a/packages/launchpad/src/pubkey.ts b/packages/launchpad/src/pubkey.ts index 2095c05a33..d5a061d74f 100644 --- a/packages/launchpad/src/pubkey.ts +++ b/packages/launchpad/src/pubkey.ts @@ -62,6 +62,9 @@ export function encodeBech32Pubkey(pubkey: PubKey, prefix: string): string { case pubkeyType.secp256k1: aminoPrefix = pubkeyAminoPrefixSecp256k1; break; + case pubkeyType.ed25519: + aminoPrefix = pubkeyAminoPrefixEd25519; + break; default: throw new Error("Unsupported pubkey type"); }