Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
transformBinFile(file: TFileDesc): TFileDesc[] | void {
const name = getFilename(file.path);
const bytecode = extractBytecode(file.contents);
if (!bytecode) {
return;
}
if (this.contractCache[name]) {
const { contract, abi } = this.contractCache[name];
delete this.contractCache[name];
return [this.genContractFactoryFile(contract, abi, bytecode)];
} else {
this.bytecodeCache[name] = bytecode;
}
}
transformAbiOrFullJsonFile(file: TFileDesc): TFileDesc[] | void {
const name = getFilename(file.path);
const abi = extractAbi(file.contents);
if (abi.length === 0) {
return;
}
const contract = parse(abi, name);
const bytecode = extractBytecode(file.contents) || this.bytecodeCache[name];
if (bytecode) {
return [
this.genContractTypingsFile(contract),
this.genContractFactoryFile(contract, abi, bytecode),
];
} else {
this.contractCache[name] = { abi, contract };
return [this.genContractTypingsFile(contract)];
}
}