-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ABI generation #301
ABI generation #301
Conversation
src/cli/abi.ts
Outdated
const diagnostics = ts.getPreEmitDiagnostics(program); | ||
if (diagnostics.length > 0) { | ||
diagnostics.forEach((diagnostic) => { | ||
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); | ||
if (diagnostic.file) { | ||
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); | ||
console.error(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); | ||
} else { | ||
console.error(message); | ||
} | ||
}); | ||
return undefined; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can get rid of the preceding CLI step that does typechecking since this piece does effectively the same without having to instantiate tsc
twice. But up to you guys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still unclear to me if IBI is a separate package. If it is not - then we can do a TS check once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IBI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, "ABI"
src/cli/abi.ts
Outdated
const diagnostics = ts.getPreEmitDiagnostics(program); | ||
if (diagnostics.length > 0) { | ||
diagnostics.forEach((diagnostic) => { | ||
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); | ||
if (diagnostic.file) { | ||
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); | ||
console.error(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); | ||
} else { | ||
console.error(message); | ||
} | ||
}); | ||
return undefined; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still unclear to me if IBI is a separate package. If it is not - then we can do a TS check once.
src/cli/abi.ts
Outdated
target: ts.ScriptTarget.ES5, | ||
module: ts.ModuleKind.CommonJS, | ||
allowUnusedLabels: true, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So these overrides options load in basePath/tsconfig.json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I tried to use contract's tsconfig.json
, but then it picks up all TS files in this project, not just the one you directly specify (e.g. all examples under /examples
, not just counter-ts
). I will play around with this a bit more and see what can be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I figured out the right way to deal with this, PTAL.
While we are at this, how do you think the path to package.json
and tsconfig.json
should be specified? I have just added a 3rd and 4th argument to the CLI command, but that's probably not what we want.
Generally your implementation and comprehensive validation looks great! |
958270f
to
34429d0
Compare
I am working on stabilizing this and I have a couple of things that I am not sure how to go about.
So far most examples work, only NFT is failing because |
@itegulov our build command now consists of several steps. I think ABI can become one of them. It should be easy to have as a separate command as well. I do not think that we need to keep it as a separate project. |
588bef6
to
4c9363c
Compare
4c9363c
to
a53a588
Compare
@@ -67,7 +67,7 @@ export class ParkingLot { | |||
} | |||
|
|||
@view({}) | |||
getCarSpecs({ name }: { name: string }) { | |||
getCarSpecs({ name }: { name: string }): CarSpecs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will we get warnings (or configure tsconfig in a way) when method doesn't have return type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! It's very solid implementation! Also thank you for fixing a few signatures!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @itegulov!
Merging now, but do you think it's possible to test ABI somehow?
This is still pretty raw, but sharing for visibility.
Instructions for running:
yarn install && yarn build
(needed because it is not released yet)yarn install && yarn build
(needed because I had to expose some API that makes life much much easier).yarn build:counter-ts
inexamples
and see what happens 👀