-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0d8302
commit e3847c4
Showing
11 changed files
with
185 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
name: 'Interface exporter action' | ||
description: 'An action to generate npm packages based on Solidity contract interfaces' | ||
description: 'An action to generate npm packages based on Solidity interfaces and contracts' | ||
author: 'Wonderland' | ||
|
||
inputs: | ||
out_dir: | ||
description: 'path to the `out` folder containing the compiled contracts' | ||
required: true | ||
interfaces_dir: | ||
description: 'path to the `interfaces` folder containing the contract interfaces' | ||
default: 'src/interfaces' | ||
required: false | ||
typing_type: | ||
description: 'interface compatibility: abi, contracts' | ||
required: true | ||
package_name: | ||
description: 'name of the package to be publish' | ||
required: true | ||
destination_dir: | ||
description: 'path to the directory where your package will be exported' | ||
description: 'name of the package to be published' | ||
required: true | ||
contracts_dir: | ||
description: 'path to the directory where the contracts are located' | ||
out: | ||
description: 'path to the `out` folder containing the compiled contracts' | ||
required: false | ||
default: 'out' | ||
interfaces: | ||
description: 'path to the interfaces directory' | ||
required: false | ||
default: 'solidity/interfaces' | ||
contracts: | ||
description: 'path to the contracts directory' | ||
required: false | ||
default: 'solidity/contracts' | ||
export_type: | ||
description: '`interface` for exporting only the interfaces and their ABIs, `contracts` for exporting the contracts, interfaces and their ABIs as well' | ||
required: false | ||
default: 'interfaces' | ||
|
||
outputs: | ||
passed: | ||
description: 'boolean describing if the test passed or not' | ||
exported: | ||
description: 'boolean describing package was exported successfully or not' | ||
runs: | ||
using: 'node16' | ||
main: 'dist/index.js' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export enum TypingType { | ||
ABI = 'abi', | ||
export enum ExportType { | ||
INTERFACES = 'interfaces', | ||
CONTRACTS = 'contracts', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import glob from 'glob'; | ||
import path from 'path'; | ||
import fse from 'fs-extra'; | ||
import { transformRemappings } from './transformRemappings'; | ||
|
||
export const copySolidityFiles = (baseDir: string, filesDir: string, destinationDir: string) => { | ||
const filesDestination = `${destinationDir}/${filesDir}`; | ||
const abiDestination = `${destinationDir}/abi`; | ||
|
||
// List all of the solidity files on the input directory | ||
const filesGlob = `${filesDir}/**/*.sol`; | ||
glob(filesGlob, (err, filesPaths) => { | ||
if (err) throw err; | ||
|
||
for (const filePath of filesPaths) { | ||
const file = fse.readFileSync(filePath, 'utf8'); | ||
const relativeFile = transformRemappings(file); | ||
|
||
// Copy the file to the destination directory | ||
const relativeFilePath = filePath.substring(filesDir.length + 1); | ||
fse.outputFileSync(path.join(filesDestination, relativeFilePath), relativeFile); | ||
console.log(`Copied ${relativeFilePath} to ${filesDestination}`); | ||
|
||
// Copy the abi to the export directory using the same file name | ||
const fileName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.lastIndexOf('.')); | ||
fse.copySync(`${baseDir}/${fileName}.sol/${fileName}.json`, `${abiDestination}/${fileName}.json`); | ||
console.log(`Copied ${fileName}.json to ${abiDestination}`); | ||
} | ||
|
||
console.log(`Copied ${filesPaths.length} interfaces and ABIs`); | ||
}); | ||
}; |
Oops, something went wrong.