@sentio/truffle-fetch-and-compile
Version:
Used to obtain external verified sources and compile them
51 lines • 2.01 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeFetcherNames = exports.normalizeFetchAndCompileOptions = void 0;
const config_1 = __importDefault(require("@truffle/config"));
const source_fetcher_1 = __importDefault(require("@truffle/source-fetcher"));
function normalizeFetchAndCompileOptions(options) {
if (options instanceof config_1.default) {
let normalizedOptions = {
network: {
networkId: options.network_id
},
compile: {
docker: ((options.compilers || {}).solc || {}).docker,
nativeCompilerMap: ((options.compilers || {}).solc || {})
.nativeCompilerMap
},
fetch: {
precedence: options.sourceFetchers,
fetcherOptions: {}
}
};
for (const fetcher of source_fetcher_1.default) {
const fetcherName = fetcher.fetcherName;
const fetcherOptions = options[fetcherName];
//@ts-ignore TS can't recognize that the objects we just set up are definitely not undefined :-/
normalizedOptions.fetch.fetcherOptions[fetcherName] = fetcherOptions;
}
return normalizedOptions;
}
else {
return options;
}
}
exports.normalizeFetchAndCompileOptions = normalizeFetchAndCompileOptions;
function normalizeFetcherNames(optionsOrFetcherNames) {
if (Array.isArray(optionsOrFetcherNames)) {
return optionsOrFetcherNames;
}
else if (!optionsOrFetcherNames) {
return optionsOrFetcherNames;
}
else {
const options = normalizeFetchAndCompileOptions(optionsOrFetcherNames);
return ((options || {}).fetch || {}).precedence;
}
}
exports.normalizeFetcherNames = normalizeFetcherNames;
//# sourceMappingURL=utils.js.map