azimuth-watcher-ts/generate-watchers.md
Prathamesh Musale 08f08316cb Add generated docs (#2)
Part of https://www.notion.so/Implement-stacks-1b5a6b22d472806a82f5dafed6955138

Reviewed-on: #2
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2025-06-11 08:46:56 +00:00

2.5 KiB

Generate Azimuth Watchers

  • Clone the original Azimuth repo for required contracts:

    git clone git@github.com:urbit/azimuth.git
    
    # Install dependencies
    npm install
    
    # Contracts are located in the contracts folder
    
  • Setup cerc-io/watcher-ts repo:

    git clone git@github.com:cerc-io/watcher-ts.git
    
    # Install dependencies and build packages
    yarn install && yarn build
    
  • Create a folder to place all the generated watchers in:

    mkdir -p azimuth-watcher-ts/packages
    
  • In watcher-ts/packages/codegen, create a config.yaml file with required codegen config for generating the watcher for a contract

    For example, for Azimuth contract:

    # Contracts to watch (required).
    contracts:
        # Contract name.
      - name: Azimuth
        # Contract file path or an url.
        path: /home/user/azimuth/contracts/Azimuth.sol
        # Contract kind
        kind: Azimuth
    
    # Output folder path (logs output using `stdout` if not provided).
    outputFolder: /home/user/azimuth-watcher-ts/packages/azimuth-watcher
    
    # Code generation mode [eth_call | storage | all | none] (default: none).
    mode: eth_call
    
    # Kind of watcher [lazy | active] (default: active).
    kind: active
    
    # Watcher server port (default: 3008).
    port: 3001
    
    # Solc version to use (optional)
    # If not defined, uses solc version listed in dependencies
    solc: v0.4.24+commit.e67f0147
    
    # Flatten the input contract file(s) [true | false] (default: true).
    flatten: true
    

    Note: Create .sol files with the contract code from Etherscan for ConditionalStarRelease, DelegatedSending, Ecliptic and LinearStarRelease contracts and use the file path for contracts.path

  • Run codegen command to generate the watcher:

    # In watcher-ts/packages/codegen
    yarn codegen --config-file ./config.yaml
    
  • Update contracts, outputFolder and port fields in the config and re-run the codegen command for all other contracts

  • Setup the parent folder /home/user/azimuth-watcher-ts where all the generated watchers are placed as a monorepo

  • The gateway GQL server can be used to proxy queries to their respective watchers