Skip to content

MuKnSys/watcher-dsl-beta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

watcher-dsl-beta

This repository contains a beta version of a Domain-Specific Language (DSL) compiler that is designed to generate watcher code.

You can find here a more detailed specification of the DSL.

Watcher-DSL uses a custom modified version of the TypeScript parser that allows for the use of custom functions specific to describing watchers.

ESLint is used to verify that all syntactic rules are met.

The Abstract Syntax Tree (AST) generated by the parser is then processed in Haskell and with usage of watcher-ts library produce the watcher code.

The beta version of the compiler in this repository does not have implemented part responsible for adding hooks. For now, code generating part is just a stub, mainly calling code-generator.

Hardware Requirements

  • OS: Ubuntu 22.10
  • CPU: 64-bit, 2.5 GHz.
  • RAM: Minimum 4 GB of RAM, but 8 GB or more recommended
  • Storage: At least 20 GB of free disk space recommended.
  • OS: Windows, macOS or Linux.

Dependencies

Prerequisites

Create and change into a directory called `watcherDSL'.

$ mkdir watcherDSL

$ cd watcherDSL

Clone the Watcher DSL repository. $ git clone https://github.com/MuKnSys/watcher-dsl-beta.git

Build Node Dependencies

$ cd watcher-dsl-beta/src/node

$ npm install

Build Haskell Dependencies

$ cd ..

$ cd haskell

$ cabal build all

Build Watcher Dependencies

$ cd ~/watcherDSL 

$ git clone https://github.com/cerc-io/watcher-ts.git 

$ cd watcher-ts

$ npm i -g corepack 

$ yarn && yarn build
$ cd ~/watcherDSL/watcher-ts/node_modules/@openzeppelin/contracts/token/ERC20

cd ~/watcherDSL/watcher-dsl-beta/data/example

Open the ERC20TOT.watcher file in this directory with your text editor of choice. For example, use the following command to open in Emacs:

$ emacs ERCTOT.watcher 

Open the ERC20TOT.watcher file, and replace the default path value for the contract interface with /home/user/Desktop/watchers/watcher-ts/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol. Then, save and close the file.

$ cd ~/watcherDSL/watcher-dsl-beta/src/haskell/dist-newstyle/build/x86_64-linux/ghc-9.2.7

There are three paths that you have to provide as a parameters:

  • Path to .watcher file
  • Path to watcher-ts library
  • Path to node directory in watcher-dsl-beta project
$ ./haskell "compile" ~/watcherDSL/watcher-dsl-beta/data/example ~/watcherDSL/watchers/watcher-ts /home/user/Desktop/watcher-dsl-beta/src/node/

The watcher will appear in packages folder of watcher-ts library.

Previous Version of Instructions

  • As example use the watcher from data/example folder.
  • In the example/ERC20TOT.watcher put the directory of the contract into the import declaration f.e /home/user/Desktop/watchers/watcher-ts/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol. Contracts path currently had to be absolute.
  • To build all node project dependencies go into: /watcher-dsl-beta/src/node and run npm install command.
  • To build all haskell project dependencies go into: /watcher-dsl-beta/src/haskell and run cabal build all command.
  • After this you can run command from watcher-dsl-beta/src/haskell/dist-newstyle/build/x86_64-linux/ghc-9.2.4/haskell-0.1.0.0/x/haskell/build/haskell
  • There are three paths that you have to provide as a parameters:
    • Path to .watcher file.
    • Path to watcher-ts library.
    • Path to node directory in watcher-dsl-beta project.
  • example ./haskell "compile" /home/user/Desktop/watcher-dsl-beta/data/example /home/user/Desktop/watchers/watcher-ts /home/user/Desktop/watcher-dsl-beta/src/node/
  • watcher will appear in packages folder of watcher-ts library

Previous Examples

preview:

27-03-23 Demo

TypeScript Generation Demo:

08-03-23 Demo

preview:

15-02-23

dsl-example.mp4

preview:

22-02-23

demo2202.mp4

About

A repository for domain specific language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published