0.2.3 • Published 2 years ago
dero-sc-ts-api-generator v0.2.3
dero-sc-ts-api-generator
Generate a TypeScript API based on a Smart Contract source code to allows easier development by exporting functions and required arguments.
Installation
- Requires
Bun.js
$ bun install -g dero-sc-ts-api-generatorUsage
Config
# Create the config file
$ dstag initExample dstag.config.json file:
{
"source": "src", // source folder with .bas files
"build": {
"target": "../frontend/src/api" // target folder in TS frontend app
}
}you can also ignore some file so that they are built but not copied to the target
{
"source": "src", // source folder with .bas files
"build": {
"target": "../frontend/src/api" // target folder in TS frontend app
},
"ignore": ["Test.bas"] // a test sc not needed in the target frontend
}Build
# Build APIs
$ dstag buildThe build command reads dstag.config.json to:
- Generate a
lib.tsfile containing common code in APIs. - Read all SCs in the
sourcefolder:- Generate a
<Smart Contract Name>/api.tsfor each smart contract
- Generate a
- Move the generated files in both the local
distfolder and the target folder so you can write tests locally and have the api available in your frontend.
Development
To build:
bun run build