Created
November 18, 2021 10:49
-
-
Save leonardoalt/70d659eb0ec2f0e82b1fa5681d5ce3e8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const fs = require('fs'); | |
const path = require('path'); | |
const solc = require('./index.js'); | |
const smtchecker = require('./smtchecker.js'); | |
const smtsolver = require('./smtsolver.js'); | |
const settings = { modelChecker: { | |
engine: 'chc', | |
targets: ['assert'], | |
solvers: ['smtlib2'] | |
} }; | |
const sources = | |
{ | |
'deposit.sol': | |
{ | |
'urls': [ './deposit.sol' ] | |
} | |
}; | |
const basePath = './'; | |
function readFileCallback(path) { | |
path = basePath + '/' + path; | |
if (fs.existsSync(path)) { | |
try { | |
return { 'contents': fs.readFileSync(path).toString('utf8') } | |
} catch (e) { | |
return { error: 'Error reading ' + path + ': ' + e }; | |
} | |
} else | |
return { error: 'File not found at ' + path} | |
} | |
let eldarica = smtsolver.availableSolvers[1]; | |
eldarica.params = '-horn -abstract:off -t:1000'; | |
const output = JSON.parse(solc.compile( | |
JSON.stringify({ | |
language: 'Solidity', | |
sources: sources, | |
settings: settings | |
}), | |
{ | |
'import': readFileCallback, | |
smtSolver: smtchecker.smtCallback(smtsolver.smtSolver, eldarica) | |
} | |
)); | |
console.log(output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment