aepp-sdk-js icon indicating copy to clipboard operation
aepp-sdk-js copied to clipboard

TypeScript definitions for contracts

Open davidyuk opened this issue 3 years ago • 4 comments

Working on #1233 I was thinking about the generation of TypeScript definitions for smart contracts by ACI. Features that we need there:

  • actual generation of TypeScript code
  • to cast parameters names (including nested structures) to camelCase (that is common in JS)

If we would find an easy way to define custom types in autorest then we would be able to:

  • convert ACI to something similar to swagger api
  • generate TS definitions with a patched version of autorest (including replacement of http interface with contractCall)

part of #1215

davidyuk avatar Jun 22 '21 20:06 davidyuk

wouldn't that be a logic that could (and maybe should) be integrated in the CLI? I guess we wouldn't be able to make use of this stuff during runtime, right? so one would need to generate the definitions separately and integrate into their project. or do I miss sth. here? 😅

marc0olo avatar Jun 22 '21 21:06 marc0olo

I guess we wouldn't be able to make use of this stuff during runtime, right?

Yep

wouldn't that be a logic that could (and maybe should) be integrated in the CLI?

This is intended to be used from CLI, and SDK doesn't need its own CLI, so yes.

I'm not sure yet in which project this code should be. Alongside with typescript generator, we need to maintain a runtime generator (obviously it still would be needed), would be nice to keep the same interface between them, it is easier to do in the same project.

davidyuk avatar Jun 26 '21 07:06 davidyuk

@kenodressel I'm not sure how to elaborate on this, the thing that is missed is the meaning of ACI (aeternity crypto interface), but I can't find any documentation on this.

davidyuk avatar Jun 26 '21 07:06 davidyuk

I am not sure about the documentation you need. but for the java sdk we did kind of a similar thing. we are using the ACI and generate java classes that make use of the SDK under the hood. this is done with a maven plugin that includes a code generator, see https://github.com/kryptokrauts/contraect-maven-plugin

I guess the meaning itself is "aeternity contract interface". in the json you can see the Sophia return types and params needed for each function:

  • https://github.com/aeternity/aesophia/blob/master/docs/aeso_aci.md

does that help you?

marc0olo avatar Jun 26 '21 07:06 marc0olo