Skip to content

Commit

Permalink
fix when contracts with same abi (StabilityBoardProxy & PreToken)
Browse files Browse the repository at this point in the history
  • Loading branch information
szerintedmi committed Apr 4, 2019
1 parent 7429fac commit 20a7a41
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lib/checkIntegrity.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,39 @@ async function checkIntegrity(options) {
abiHash: abiFileContent.abiHash,
contractName: abiFileContent.contractName,
file: abiFile,
referenceCount: 0
addresses: []
});
});

const deploymentFiles = await filesLib.fileWalker(deploymentsOutputDir);

const deploymentsWithoutAbiFile = [];
deploymentFiles.forEach(file => {
const content = filesLib.readJsonFile(file);
const deployContent = filesLib.readJsonFile(file);

for (const abiHash in content.deployedAbis) {
const abi = abis.find(abi => abi.abiHash === abiHash);
if (abi) {
abi.referenceCount++;
} else {
for (const abiHash in deployContent.deployedAbis) {
const abiUses = abis.filter(
abi => abi.abiHash === abiHash && deployContent.contractName === abi.contractName
);
if (abiUses.length === 0) {
deploymentsWithoutAbiFile.push({ abiHash, fileName: file });
} else {
abiUses.forEach(abi => {
for (const deployedAddress in deployContent.deployedAbis[abiHash].deployments) {
abi.addresses.push(deployedAddress);
}
});
}
}
});

console.log(
'***** ABI files with references from deployment files:\n',
abis.filter(abi => abi.referenceCount !== 0)
JSON.stringify(abis.filter(abi => abi.addresses.length !== 0), null, 3)
);
console.log(
'***** ABI files WITHOUT reference from deployment files:\n',
abis.filter(abi => abi.referenceCount === 0)
JSON.stringify(abis.filter(abi => abi.addresses.length === 0), null, 3)
);
console.log('***** Deployments without ABI file:\n', deploymentsWithoutAbiFile);
} catch (error) {
Expand Down

0 comments on commit 20a7a41

Please sign in to comment.