feat: typed client poc - #1860
Open
hugo-stacks wants to merge 1 commit into
Open
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
poc
Explore 2 approaches for a typed contract client.
Details here: stx-labs/clarinet#2364
The "generated/" directory comes from a new
clarinet typegencommand, that also explore the two approaches (pr here stx-labs/clarinet#2393)goals
The code itself doesn't really matter here (we won't fully implement and review the two approaches). But the goal is two pick the approach we want to go with.
You can see the new lib in actions in
packages/stck/tests/playground/index.ts.The important bits are
The goal really is to play with these parts of the code, hover the types and introduce errors (eg: extra function arg, string instead of number, etc) to see how TS handles the type errors.
The most visible difference is on hovering the functions
makeUnsignedContractCall.Approach A, because it has types aliases, really shows an superiority in terms of DX here
You may find some dead code or older decision patterns. I explored multiple paths (eg: kebab-case to camelCase function name to do
counter.getCount([])instead ofcounter.fetchCallReadOnlyFunction('get-count', []).I think both approach are still on the table here, but none of these design decisions are set in stone at this point. Implementation details