0.2.3 • Published 2 months ago

dero-sc-ts-api-generator v0.2.3

Weekly downloads
-
License
-
Repository
-
Last release
2 months ago

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

$ bun install -g dero-sc-ts-api-generator

Usage

Config

# Create the config file
$ dstag init

Example 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 build

The build command reads dstag.config.json to:

  • Generate a lib.ts file containing common code in APIs.
  • Read all SCs in the source folder:
    • Generate a <Smart Contract Name>/api.ts for each smart contract
  • Move the generated files in both the local dist folder and the target folder so you can write tests locally and have the api available in your frontend.

Development

To build:

bun run build
0.2.3

2 months ago

0.2.1

3 months ago

0.2.0

3 months ago

0.2.2

3 months ago

0.1.2

4 months ago

0.1.1

4 months ago

0.1.0

4 months ago