UNPKG

@buildship/hardhat-ipfs-upload

Version:
33 lines 1.53 kB
"use strict"; // Adapted from https://github.com/0xleung/hardhat-etherscan/blob/b3d905ddc268ca106682ec2195862f3bd45c5180/src/solc/version.ts Object.defineProperty(exports, "__esModule", { value: true }); exports.getVersions = exports.getLongVersion = void 0; const platform_js_1 = require("nft.storage/src/platform.js"); const COMPILERS_LIST_URL = "https://solc-bin.ethereum.org/bin/list.json"; // TODO: this could be retrieved from the hardhat config instead. async function getLongVersion(shortVersion) { const versions = await getVersions(); const fullVersion = versions.releases[shortVersion]; if (fullVersion === undefined || fullVersion === "") { throw new Error("Given solc version doesn't exist"); } return fullVersion.replace(/(soljson-)(.*)(.js)/, "$2"); } exports.getLongVersion = getLongVersion; async function getVersions() { try { // It would be better to query an etherscan API to get this list but there's no such API yet. const response = await platform_js_1.fetch(COMPILERS_LIST_URL); if (!response.ok) { const responseText = await response.text(); throw new Error(`HTTP response is not ok. Status code: ${response.status} Response text: ${responseText}`); } const list = await response.json(); return list; } catch (error) { throw new Error(`Failed to obtain list of solc versions. Reason: ${error.message}`); } } exports.getVersions = getVersions; //# sourceMappingURL=version.js.map