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

Feature request: output AST in the SDK #268

Closed
MarvinJanssen opened this issue Feb 22, 2022 · 11 comments · Fixed by #1162
Closed

Feature request: output AST in the SDK #268

MarvinJanssen opened this issue Feb 22, 2022 · 11 comments · Fixed by #1162
Assignees
Labels
functional enhancement New feature or request icebox
Milestone

Comments

@MarvinJanssen
Copy link

Asking for the possibility of receiving contract AST in clarinet run. I remember one of the very early versions of this command having the capability (although I might be wrong).

I want to make a simplistic analyser that checks if a given contract conforms to the SIP-013 semi-fungible token standard stacksgov/sips#42.

The SIP defines parameters that cannot be captured by mere trait compliance. I wanted to use the AST to check if there is some usage of specific Clarity primitives; including, but not limited to:

  • Check if transfer calls both ft-transfer? and nft-burn?.
  • Check if the contract prints the right events.
  • ...and so on.

If it works, I am even thinking about generalising such a check system into a separate SIP. Then future SIPs that describe contracts could add a reference trait as well as an AST check. (Cool future feature for Clarinet as well?)

@unclemantis
Copy link

Sounds cool!

@obycode
Copy link
Member

obycode commented Feb 22, 2022

Sounds a bit like #463.

We've been discussing enabling extensions using the ASTVisitor trait (see https://github.com/hirosystems/clarity-repl/blob/develop/src/analysis/ast_visitor.rs). I will work on this soon.

@obycode
Copy link
Member

obycode commented Mar 2, 2022

Ignore my last comment. I discussed with @lgalabru and now understand that defining a plugin in Rust is not what we're looking for here. We can just expose the AST in Typescript (and maybe later create an ASTVisitor for Typescript).

@MarvinJanssen
Copy link
Author

@obycode wondering if there have been any follow-up discussions on this feature request? I would love to include a SIP013 validator script for stacksgov/sips#42.

With the AST exposed, I could make a script that checks:

  1. if the public functions call the right native functions; e.g., transfer calls ft-transfer?, etc..
  2. if the burn-and-mint post condition mechanism exists.
  3. if the proper events are emitted.

@obycode
Copy link
Member

obycode commented May 2, 2022

Hi @MarvinJanssen. I have not been able to prioritize this yet. How urgent is your need?

@MarvinJanssen
Copy link
Author

MarvinJanssen commented May 3, 2022

@obycode Not sure, it is definitely not a requirement for SIP013 or the other SIP we will be working on at the Lab. However, it would definitely be cool. Is it a lot of work? Maybe I could take a crack at it. Anything in Rust just takes ages for me to figure out.

@obycode
Copy link
Member

obycode commented May 3, 2022

I'm not really sure what kind of effort this will take. I have not looked at this code path yet. I'm going to take a look now...

@obycode
Copy link
Member

obycode commented May 3, 2022

I think the key task for this is going to be figuring out how to represent the AST in the JSON (which gets passed from Rust to Typescript).

@lgalabru lgalabru added functional enhancement New feature or request and removed feature labels Aug 8, 2022
@github-project-automation github-project-automation bot moved this to 🆕 New in DevTools Jul 7, 2023
@hugocaillard
Copy link
Collaborator

Is this still need?
I think we might be able quite easily to the @clarinet-sdk (in progress #1065)

@smcclellan smcclellan moved this from 🆕 New to 📋 Backlog in DevTools Jul 19, 2023
@smcclellan smcclellan assigned hugocaillard and unassigned obycode Aug 16, 2023
@hugocaillard hugocaillard moved this from 📋 Backlog to 👀 In Review in DevTools Sep 28, 2023
@hugocaillard hugocaillard added this to the Q3-2023 milestone Sep 28, 2023
@hugocaillard hugocaillard changed the title Feature request: output AST for clarinet run Feature request: output AST in the SDK Sep 28, 2023
@hugocaillard
Copy link
Collaborator

I slightly repurposed this issue following the deprecation of clarinet run and the release of clarinet sdk

@hugocaillard hugocaillard linked a pull request Sep 28, 2023 that will close this issue
@hugocaillard
Copy link
Collaborator

Addressed in #1162

@github-project-automation github-project-automation bot moved this from 👀 In Review to ✅ Done in DevTools Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functional enhancement New feature or request icebox
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants