G7DAO / seer

Apache License 2.0
8 stars 5 forks source link

Add chain cli #90

Open Andrei-Dolgolev opened 1 month ago

Andrei-Dolgolev commented 1 month ago

Merge moonstreamdb-v3 to seer. Add chain cli.

Chain cli work as chain specific so command run only for 1 chain.

go run *.go generates blockchain chain --RPC

Request RPC node for feel chain info structure:

type ChainInfo struct {
    ChainType string                 `json:"chainType"` // L1 or L2
    ChainID   *big.Int               `json:"chainID"`   // Chain ID
    Block     *seer_common.BlockJson `json:"block"`
}

By requesting eth_getBlock and eth_chainID.

parameters:

Generate definitions for various blockchains

Usage:
  seer generates blockchain chain [flags]

Flags:
      --chain string    The name of the blockchain (required)
      --definitions     Generate definitions (Optional)
      --full            Generate all  (Optional)
  -h, --help            help for chain
      --interfaces      Generate interfaces (Optional)
      --migrations      Generate migrations (Optional)
      --models          Generate models (Optional)
      --output string   The path to the output file(chain Info include lates block and transactions) (Optional)
      --rpc string      The RPC URL for the blockchain (required)
      --subscription    Generate subscription type (Optional)
      --deploy          Generate deploy scripts (Optional)

Each Optional flag decide what will be generated as output:

Generate Protobf definitions file for chain(depend on if chain detect L2 fields in RPC response will ad extra field. Create files: seer/blockchain/<chain_name_lower>

   /<chain_name_lover>.proto

Template: seer/blockchain/common/evm_proto_template.proto.tmpl

seer/moonstreamdb-v3/moonstreamdbv3

/models/<chain_name_lower>_labels.py
/models_indexes/<chain_name_lower>_indexes.py

seer/moonstreamdb-v3/moonstreamdbv3

/alembic/<new revision file>
/alembic_indexes/<new revision file>

seer/deploy

/seer-crawler-<chain_name_lower_dash>.service
/seer-historical-synchronizer-<chain_name_lower_dash>.service
/seer-historical-synchronizer-<chain_name_lower_dash>.timer
/seer-synchronizer-<chain_name_lower_dash>.service

Generate subscription resource.

Command examples: