Skip to content

Commit

Permalink
fix: interfaces paths (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
gas1cent authored Oct 2, 2023
1 parent 6d0c948 commit af0efd7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
13 changes: 7 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "interface-exporter-action",
"version": "1.0.0",
"private": true,
"description": "An action to generate npm packages based on Solidity contract interfaces",
"main": "lib/main.js",
"scripts": {
Expand Down
13 changes: 7 additions & 6 deletions src/createPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export const createPackage = (
packageJson: PackageJson,
typingType: TypingType,
) => {
const abiDir = `${exportDir}/abi`;
const contractsDir = `${exportDir}/contracts`;
const abiDestination = `${exportDir}/abi`;
const contractsDestination = `${exportDir}/${contractsExportDir}`;
const interfacesDestination = `${exportDir}/${interfacesDir}`;

const interfacesGlob = `${interfacesDir}/**/*.sol`;
const contractsGlob = `${contractsExportDir}/**/*.sol`;
Expand All @@ -37,13 +38,13 @@ export const createPackage = (
const relativeInterfaceFile = transformRemappings(interfaceFile);

const contractPath = interfacePath.substring(interfacesDir.length + 1);
fse.outputFileSync(path.join(contractsDir, contractPath), relativeInterfaceFile);
fse.outputFileSync(path.join(interfacesDestination, contractPath), relativeInterfaceFile);

// get the interface name
const interfaceName = interfacePath.substring(interfacePath.lastIndexOf('/') + 1, interfacePath.lastIndexOf('.'));

// copy interface abi to the export directory
fse.copySync(`${outDir}/${interfaceName}.sol/${interfaceName}.json`, `${abiDir}/${interfaceName}.json`);
fse.copySync(`${outDir}/${interfaceName}.sol/${interfaceName}.json`, `${abiDestination}/${interfaceName}.json`);
}
console.log(`Copied ${interfacePaths.length} interfaces`);

Expand All @@ -56,10 +57,10 @@ export const createPackage = (
const relativeContractFile = transformRemappings(contractFile);

const relativeContractPath = contractPath.substring(contractsExportDir.length + 1);
fse.outputFileSync(path.join(exportDir, relativeContractPath), relativeContractFile);
fse.outputFileSync(path.join(contractsDestination, relativeContractPath), relativeContractFile);

const contractName = contractPath.substring(contractPath.lastIndexOf('/') + 1, contractPath.lastIndexOf('.'));
fse.copySync(`${outDir}/${contractName}.sol/${contractName}.json`, `${abiDir}/${contractName}.json`);
fse.copySync(`${outDir}/${contractName}.sol/${contractName}.json`, `${abiDestination}/${contractName}.json`);
}
console.log(`Copied ${contractPaths.length} contracts`);
});
Expand Down

0 comments on commit af0efd7

Please sign in to comment.