Validation Script
See original GitHub issueProvide lightweight stand-alone npm package that can be used as a commandline interface and from nodejs scripts that can consume metadata and source files and produces standard-json structures such that people can re-compile contracts to verify them.
Feature list:
- run the script with a list of files as commandline arguments, potentially also directories or zip files
- scan these files for metadata files and return a list of them
- scan each file in the provided directories
- if the file is a json file and contains the required keys for metadata files, consider it a metadata file
- if the file is not a json file / is too large / a binary file, then scan for
"{\"compiler\":{\"version\".*?},\"version\":1}"
, un-quote this and consider this as a metadata file
- each metadata file is / can be identified by the contract it represents (and should be reported to the user like that): `metadata[‘settings’][‘compilationTarget’]’ - there should be a single key that contains the file name and the value is the contract name. The file name can be used to disambiguate if there are multiple contracts of the same name.
- for each metadata file / contract file look for the referenced source files
For each metadata file / contract, we can have a success (all files found) or a failure case (not all files found, or something malformatted).
Output (given for the commandline interface, suitably formatted as json if used via nodejs directly - the instructional texts are only given on the commandline):
MyContractName (my/file/name):
Error: Malformed json
MyContractName2 (my/file/name):
Error: Missing sources:
The following files were not part in the list of files and directories provided.
Please retrieve the files (potentially via ipfs) and re-run the script.
- my/sourcefileA.sol (keccak256: 0x1234... bzzr://... ipfs://...)
- my/otherfile.sol (keccak256: 0x1234... bzzr://... ipfs://...)
7 other source files were found successfully.
TheOtherContractName (my/file/othername):
Success!
Compiled with Solidity 0.6.5
https://solc-bin.ethereum.org/wasm/soljson-v0.6.6+commit.6c089d02.js
https://solc-bin.ethereum.org/linux-amd64/solc-v0.6.6+commit.6c089d02
To re-compile, use:
echo "{...}" | solc --standard-json -
...
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
What is the purpose of Validation Scripts? - ServiceNow
The validation script is useful when you want to validate the value in some specific data type fields.It impacts globally. For example you...
Read more >Creating a validation script - Forcepoint
Each database fingerprints classifier can use a validation script. The validation script receives an input file containing the raw database data in a...
Read more >Validation script examples - Collibra | Product Resource Center
These are examples of real validation scripts of validation rules. An asset must have at least one definition. ... An attribute must comply...
Read more >Validating using automation scripts - IBM
With the Automation Scripts application, you can create scripts to validate attributes, offerings and carts.
Read more >How to Use a Basic Data Validation Script in SQL Server
This video walks you through how to use the basic data validation script in SQL Server. It includes 66 sample test cases demonstrating...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For the scan for
"{"compiler":{"version".*?},"version":1}"
it is not a requirement that the file itself is json parseable. Just do this as a second step if the file is not json parseable or does not conform to metadata itself.Ok, thank you for the clarification, makes sense. And regarding the naming of the option, I had already chosen the same one (-j, --standard-json); guess I might want to think of something else.