aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src/collect_contract_data.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-10 23:08:07 +0800
committerFabio Berger <me@fabioberger.com>2018-05-10 23:08:07 +0800
commitcd5f00ac4d41221c99eb8ce767e63e09a6de6a11 (patch)
tree2b1865b5fa6ef86965ea753c032ffaba48403921 /packages/sol-cov/src/collect_contract_data.ts
parent23c4027c83b9f30fad352615386b988084f8b39f (diff)
parentc64ad1af28ef116e210aafb3ea6ad2138361cd7c (diff)
downloaddexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar
dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.gz
dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.bz2
dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.lz
dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.xz
dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.zst
dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.zip
Merge branch 'development' into breakUp0xjs
* development: (38 commits) Add fallback image support to relayer grid tile Clear relayer grid state when fetching Configure the compiler to generate artifacts with deployedBytecode Implement loading and error state for relayer grid Fallback image for relayer grid tile Change relayer grid tile to link on header Display top tokens from backend Remove overflowZ property from portal Suggestions and fix bad merge Fix typo Only show untracked tokens Make wallet scrollable Add token flow Update The Ocean logo Fix artifacts paths Create an artifacts folder Introduce a var Add removeHexPrefix util method CHeck if ABI exists Improve the readability of the check for should compile ... # Conflicts: # .gitignore # packages/contracts/test/multi_sig_with_time_lock.ts # packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts # packages/contracts/util/artifacts.ts
Diffstat (limited to 'packages/sol-cov/src/collect_contract_data.ts')
-rw-r--r--packages/sol-cov/src/collect_contract_data.ts25
1 files changed, 12 insertions, 13 deletions
diff --git a/packages/sol-cov/src/collect_contract_data.ts b/packages/sol-cov/src/collect_contract_data.ts
index 1d8bc7178..bb20e98be 100644
--- a/packages/sol-cov/src/collect_contract_data.ts
+++ b/packages/sol-cov/src/collect_contract_data.ts
@@ -8,25 +8,24 @@ import { ContractData } from './types';
export const collectContractsData = (artifactsPath: string, sourcesPath: string, networkId: number) => {
const artifactsGlob = `${artifactsPath}/**/*.json`;
const artifactFileNames = glob.sync(artifactsGlob, { absolute: true });
- const contractsDataIfExists: Array<ContractData | {}> = _.map(artifactFileNames, artifactFileName => {
+ const contractsData: ContractData[] = [];
+ _.forEach(artifactFileNames, artifactFileName => {
const artifact = JSON.parse(fs.readFileSync(artifactFileName).toString());
- const sources = artifact.networks[networkId].sources;
- const contractName = artifact.contract_name;
+ const sources = _.keys(artifact.sources);
+ const contractName = artifact.contractName;
// We don't compute coverage for dependencies
- const sourceCodes = _.map(sources, (source: string) => fs.readFileSync(source).toString());
- if (_.isUndefined(artifact.networks[networkId])) {
- throw new Error(`No ${contractName} artifacts found for networkId ${networkId}`);
- }
+ const sourceCodes = _.map(sources, (source: string) =>
+ fs.readFileSync(path.join(sourcesPath, source)).toString(),
+ );
const contractData = {
sourceCodes,
sources,
- sourceMap: artifact.networks[networkId].source_map,
- sourceMapRuntime: artifact.networks[networkId].source_map_runtime,
- runtimeBytecode: artifact.networks[networkId].runtime_bytecode,
- bytecode: artifact.networks[networkId].bytecode,
+ bytecode: artifact.compilerOutput.evm.bytecode.object,
+ sourceMap: artifact.compilerOutput.evm.bytecode.sourceMap,
+ runtimeBytecode: artifact.compilerOutput.evm.deployedBytecode.object,
+ sourceMapRuntime: artifact.compilerOutput.evm.deployedBytecode.sourceMap,
};
- return contractData;
+ contractsData.push(contractData);
});
- const contractsData = _.filter(contractsDataIfExists, contractData => !_.isEmpty(contractData)) as ContractData[];
return contractsData;
};