mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 02:07:55 +00:00
31 lines
740 B
TypeScript
31 lines
740 B
TypeScript
import soljson from 'solc/soljson'
|
|
import Resolc from './resolc/resolc'
|
|
import type { SolcOutput } from '.'
|
|
|
|
export function resolc(input: string): SolcOutput {
|
|
const m = Resolc() as any // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
m.soljson = soljson
|
|
m.writeToStdin(input)
|
|
m.callMain(['--standard-json'])
|
|
const err = m.readFromStderr()
|
|
|
|
if (err) {
|
|
throw new Error(err)
|
|
}
|
|
|
|
return JSON.parse(m.readFromStdout()) as SolcOutput
|
|
}
|
|
|
|
export function version(): string {
|
|
const m = Resolc() as any // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
m.soljson = soljson
|
|
m.callMain(['--version'])
|
|
const err = m.readFromStderr()
|
|
|
|
if (err) {
|
|
throw new Error(err)
|
|
}
|
|
|
|
return m.readFromStdout()
|
|
}
|