eth.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. /*
  3. This file is part of web3.js.
  4. web3.js is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. web3.js is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with web3.js. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. exports.isValidEthBaseType = void 0;
  17. const utils_js_1 = require("../utils.js");
  18. const isValidEthBaseType = (type) => {
  19. const { baseType, baseTypeSize } = (0, utils_js_1.parseBaseType)(type);
  20. if (!baseType) {
  21. return false;
  22. }
  23. if (baseType === type) {
  24. return true;
  25. }
  26. if ((baseType === 'int' || baseType === 'uint') && baseTypeSize) {
  27. if (!(baseTypeSize <= 256 && baseTypeSize % 8 === 0)) {
  28. return false;
  29. }
  30. }
  31. if (baseType === 'bytes' && baseTypeSize) {
  32. if (!(baseTypeSize >= 1 && baseTypeSize <= 32)) {
  33. return false;
  34. }
  35. }
  36. return true;
  37. };
  38. exports.isValidEthBaseType = isValidEthBaseType;
  39. //# sourceMappingURL=eth.js.map