Skip to content
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

feat: ABI type inference - base type inference logic and inferred function inputs #1114

Closed
wants to merge 109 commits into from

Conversation

nedsalk
Copy link
Contributor

@nedsalk nedsalk commented Jul 21, 2023

NOTE: This PR is merging into branch ns/feat/abi-type-inference

Due to the importance, size and impact of this PR and the subsequent PRs on the developer experience of users, I've created a separate feature branch feat/abi-type-inference into which all PRs will be merged. When we're satisfied with the results, we'll merge that branch into master.
Issue #1021 will serve as a reference where all the tasks related to this whole feature will be listed.

This PR represents a big improvement to the developer experience of our users and is a stepping stone to trimming down and eventually deleting the abi-typegen package altogether.

The idea of this endeavor is to load the whole abi into the type system and parse it, which results in correct type safety of everything functions, their inputs and outputs, configurables, ...) on our Interface and program types: Contract, Script, Predicate.

This PR's scope is to make the functions and their inputs type safe on the Interface level. Subsequent PRs will deal with programs, configurables, and everything else relevant.

In order to ensure that the type inference logic covers all use cases, I've used the ABIs found in abi-typegen and also added some examples from the exhaustiveExamples sway project where it was necessary. For the time being, I've just copied these abis and referenced them in the tests. In the future this should be automated and based off of their sway programs directly so that the abis never get stale. The ABIs and their corresponding compilation tests can be found in the abi-coder/test/type-inference-tests folder. These tests get run during pretest and the relevant changes to get them running are found in package.json and tsconfig.json.

The type inference logic is located in the type-inferrer folder.

nedsalk and others added 30 commits July 6, 2023 14:28
….toml

Co-authored-by: Sérgio Torres <30977845+Torres-ssf@users.noreply.github.com>
…mat' into 1071-remove-usage-of-old-abi-format
@nedsalk nedsalk marked this pull request as ready for review August 24, 2023 16:53
@nedsalk
Copy link
Contributor Author

nedsalk commented Sep 11, 2023

Closed until there is completely no need for a CLI tool (after implementation of TS issue 32063). Will be revisited then.

@nedsalk nedsalk closed this Sep 11, 2023
@nedsalk nedsalk deleted the 1021-infer-abi-types branch November 14, 2023 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infer types based off of the abi.json directly
6 participants