message: Support LegacyAminoPubKey in decodePubkey
diff: @@ -3,6 +3,7 @@ import {
  encodeSecp256k1Pubkey,
  isMultisigThresholdPubkey,
  isSecp256k1Pubkey,
  + MultisigThresholdPubkey,
  Pubkey,
  SinglePubkey,
  } from "@cosmjs/amino";
  @@ -36,15 +37,36 @@ export function encodePubkey(pubkey: Pubkey): Any {
  }
  }
  -export function decodePubkey(pubkey?: Any | null): SinglePubkey | null {
  +function decodeSinglePubkey(pubkey: Any): SinglePubkey {
  + switch (pubkey.typeUrl) {
  + case "/cosmos.crypto.secp256k1.PubKey": {
  + const { key } = PubKey.decode(pubkey.value);
  + return encodeSecp256k1Pubkey(key);
  + }
  + default:
  + throw new Error(`Pubkey type_url ${pubkey.typeUrl} not recognized as single public key type`);
  + }
  +}
  +
  +export function decodePubkey(pubkey?: Any | null): Pubkey | null {
  if (!pubkey || !pubkey.value) {
  return null;
  }
  switch (pubkey.typeUrl) {
  case "/cosmos.crypto.secp256k1.PubKey": {
  - const { key } = PubKey.decode(pubkey.value);
  - return encodeSecp256k1Pubkey(key);
  + return decodeSinglePubkey(pubkey);
  + }
  + case "/cosmos.crypto.multisig.LegacyAminoPubKey": {
  + const { threshold, publicKeys } = LegacyAminoPubKey.decode(pubkey.value);
  + const out: MultisigThresholdPubkey = {
  + type: "tendermint/PubKeyMultisigThreshold",
  + value: {
  + threshold: threshold.toString(),
  + pubkeys: publicKeys.map(decodeSinglePubkey),
  + },
  + };
  + return out;
  }
  default:
  throw new Error(`Pubkey type_url ${pubkey.typeUrl} not recognized`);
  