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

[clarity-repl] Expose method to construct JSON abi from contract source #913

Closed
aulneau opened this issue Mar 1, 2023 · 6 comments · Fixed by #1151
Closed

[clarity-repl] Expose method to construct JSON abi from contract source #913

aulneau opened this issue Mar 1, 2023 · 6 comments · Fixed by #1151
Assignees
Labels
functional enhancement New feature or request
Milestone

Comments

@aulneau
Copy link

aulneau commented Mar 1, 2023

I'm working on an index of clarity contracts, and I want the ability to convert a string representation (standard .clar contents as string) of a contract into a JSON ABI, similar to the results from the stacks-blockchain-api/node.

There are lots of use cases I have planned for it, but generally it's so I'm able to construct different views of a contract or find similarities between many.

@github-project-automation github-project-automation bot moved this to 🆕 New in DevTools Mar 1, 2023
@lgalabru lgalabru assigned lgalabru and hugocaillard and unassigned lgalabru Mar 1, 2023
@lgalabru lgalabru moved this from 🆕 New to 🔖 To do in DevTools Mar 1, 2023
@aulneau
Copy link
Author

aulneau commented Mar 17, 2023

@hugocaillard @lgalabru is there any way that I can hack on something to get this working? such as can I use this https://github.com/stacks-network/stacks-blockchain/blob/master/clarity/src/vm/analysis/contract_interface_builder/mod.rs as a wasm module?

@hugocaillard
Copy link
Collaborator

Hey @aulneau,
Is think the idea would be to expose build_contract_interface in the repl,
Something like

/* components/clarity-repl/src/lib.rs */

/* ... */

#[cfg(feature = "wasm")]
#[wasm_bindgen]
pub fn get_contract_interface(name: &str) {
    let mut session = unsafe {
        match WASM_GLOBAL_CONTEXT.session.take() {
            Some(session) => session,
            None => return (),
        }
    };
    build_contract_interface(session. /* get analysis ... */);
    ()
}

I could try to dig a bit deeper over the weekend or early next week

@smcclellan smcclellan added the functional enhancement New feature or request label May 3, 2023
@smcclellan
Copy link
Contributor

@aulneau Is this still needed?

@aulneau
Copy link
Author

aulneau commented May 3, 2023

Yes please

@hugocaillard
Copy link
Collaborator

Just moved this issue in progress, it will be available in the v1.0.0 of the clarinet-sdk #1065

For context, @aulneau a new clarinet-sdk will be released next week on npm (release candidate 1). So if you're still interested, let's talk 🙌

@hugocaillard
Copy link
Collaborator

I marked this issue as fixed with #1151, because it's available in the clarinet-sdk.
More documentation to come soon.

import { initVM } from "obscurity-sdk";

async function main() {
  const vm = await initVM();
  const ci = vm.getContractsInterfaces();
}

More documentation to come soon.

@aulneau It might not be exactly what you were looking for so feel free to re-open or reach out to me

@github-project-automation github-project-automation bot moved this from 🏗 In Progress to ✅ Done in DevTools Sep 20, 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
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants