Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed Nov 7, 2024
1 parent f1b45c5 commit b7cf928
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,24 @@ type SolcInput = {
}
}

type SolcError = {
component: string
errorCode: string
formattedMessage: string
message: string
severity: string
sourceLocation?: {
file: string
start: number
end: number
}
type: string
}

type SolcOutput = {
contracts: {
[contractName: string]: {
Storage: {
[contractPath: string]: {
[contractName: string]: {
abi: Array<{
name: string
inputs: Array<{ name: string; type: string }>
Expand All @@ -25,19 +39,7 @@ type SolcOutput = {
}
}
}
errors?: Array<{
component: string
errorCode: string
formattedMessage: string
message: string
severity: string
sourceLocation?: {
file: string
start: number
end: number
}
type: string
}>
errors?: Array<SolcError>
}

export function resolveInputs(sources: SolcInput): SolcInput {
Expand All @@ -63,6 +65,11 @@ export function resolveInputs(sources: SolcInput): SolcInput {

const output = JSON.parse(out) as {
sources: { [fileName: string]: { id: number } }
errors: Array<SolcError>
}

if (output.errors && Object.keys(output.sources).length === 0) {
throw new Error(output.errors[0].formattedMessage)
}

return Object.fromEntries(
Expand Down

0 comments on commit b7cf928

Please sign in to comment.