text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.ValConsPubKey = exports.ValPubKey = exports.AccPubKey = exports.ValConsAddress = exports.ValAddress = exports.AccAddress = void 0;
  var bech32_1 = require("bech32");
  function checkPrefixAndLength(prefix, data, length) {
      try {
          var vals = bech32_1.bech32.decode(data);
          return vals.prefix === prefix && data.length == length;
      }
      catch (e) {
          return false;
      }
  }
  var AccAddress;
  (function (AccAddress) {
      /**
       * Checks if a string is a valid Terra account address.
       *
       * @param data string to check
       */
      function validate(data) {
          return checkPrefixAndLength('terra', data, 44);
      }
      AccAddress.validate = validate;
      /**
       * Converts a validator address into an account address
       *
       * @param address validator address
       */
      function fromValAddress(address) {
          var vals = bech32_1.bech32.decode(address);
          return bech32_1.bech32.encode('terra', vals.words);
      }
      AccAddress.fromValAddress = fromValAddress;
  })(AccAddress = exports.AccAddress || (exports.AccAddress = {}));
  var ValAddress;
  (function (ValAddress) {
      /**
       * Checks if a string is a Terra validator address.
       *
       * @param data string to check
       */
      function validate(data) {
          return checkPrefixAndLength('terravaloper', data, 51);
      }
      ValAddress.validate = validate;
      /**
       * Converts a Terra account address to a validator address.
       * @param address account address to convert
       */
      function fromAccAddress(address) {
          var vals = bech32_1.bech32.decode(address);
          return bech32_1.bech32.encode('terravaloper', vals.words);
      }
      ValAddress.fromAccAddress = fromAccAddress;
  })(ValAddress = exports.ValAddress || (exports.ValAddress = {}));
  var ValConsAddress;
  (function (ValConsAddress) {
      /**
       * Checks if a string is a Terra validator consensus address
       * @param data string to check
       */
      function validate(data) {
          return checkPrefixAndLength('terravalcons', data, 51);
      }
      ValConsAddress.validate = validate;
  })(ValConsAddress = exports.ValConsAddress || (exports.ValConsAddress = {}));
  var AccPubKey;
  (function (AccPubKey) {
      /**
       * Checks if a string is a Terra validator consensus address
       * @param data string to check
       */
      function validate(data) {
          return checkPrefixAndLength('terrapub', data, 76);
      }
      AccPubKey.validate = validate;
      /**
       * Converts a Terra validator pubkey to an account pubkey.
       * @param address validator pubkey to convert
       */
      function fromValPubKey(pubkey) {
          var vals = bech32_1.bech32.decode(pubkey);
          return bech32_1.bech32.encode('terrapub', vals.words);
      }
      AccPubKey.fromValPubKey = fromValPubKey;
  })(AccPubKey = exports.AccPubKey || (exports.AccPubKey = {}));
  var ValPubKey;
  (function (ValPubKey) {
      /**
       * Checks if a string is a Terra validator pubkey
       * @param data string to check
       */
      function validate(data) {
          return checkPrefixAndLength('terravaloperpub', data, 83);
      }
      ValPubKey.validate = validate;
      /**
       * Converts a Terra account pubkey to a validator pubkey.
       * @param pubkey account pubkey
       */
      function fromAccPubKey(pubkey) {
          var vals = bech32_1.bech32.decode(pubkey);
          return bech32_1.bech32.encode('terravaloperpub', vals.words);
      }
      ValPubKey.fromAccPubKey = fromAccPubKey;
  })(ValPubKey = exports.ValPubKey || (exports.ValPubKey = {}));
  var ValConsPubKey;
  (function (ValConsPubKey) {
      /**
       * Checks if string is a valid Terra consensus (node) pubkey.
       * @param data string to check
       */
      function validate(data) {
          return data.type === 'tendermint/PubKeyEd25519' && typeof data.value === 'string';
      }
      ValConsPubKey.validate = validate;
  })(ValConsPubKey = exports.ValConsPubKey || (exports.ValConsPubKey = {}));
  //# sourceMappingURL=strings.js.map