diff --git a/.gitignore b/.gitignore index 68bec91..e46670d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ .env.* virtualenv venv -__pycache__ \ No newline at end of file +__pycache__/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index aad2dbc..baab606 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM dipdup/dipdup:6.1.2 +FROM dipdup/dipdup:6.5.7 COPY requirements.txt . RUN pip3 install -r requirements.txt -COPY . . +COPY --chown=dipdup . . diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..486623c --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright 2023 dOrg, LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index f9a96f2..58a6fbe 100644 --- a/README.md +++ b/README.md @@ -1 +1,44 @@ -homebase-indexer +# Homebase Indexer + +## Overview +**Homebase Indexer** is a specialized tool crafted using DipDup, Tezos's Python framework. It serves as an equivalent to [a subgraph](https://thegraph.com/) and provides a GraphQL API, enabling efficient interaction with the Tezos blockchain. Primarily driven by the `dipdup.yml` file, it efficiently handles contract events. The main branches for the current version are `v3-master` and `v3-develop` (production and development respectively), although version 2 branches are still maintained for some DAOs that have not transitioned to version 3. + +## Prerequisites +Before installing Homebase Indexer, ensure you have the following: +- Python 3.8 or higher +- Docker and Docker Compose +- Basic understanding of blockchain concepts and Tezos + +## Installation and Setup +1. **Clone the Repository**: `git clone https://github.com/dOrgTech/homebase-indexer.git -b v3-develop` +2. **Navigate to the Project Directory**: `cd homebase-indexer` +3. **Build the Docker Image**: `docker build -t homebase-indexer .` +4. **Initialize Using Docker Compose**: `docker-compose up` + +## Usage +To run the Homebase Indexer: +``` +docker-compose up +``` +This will start the indexer and initiate syncing with the Tezos node as per the configuration. + +## Configuration +Configure the indexer using the `dipdup.yml` file. For advanced settings and customization, refer to the [DipDup's documentation](https://docs.dipdup.io). + +## Contribution Guidelines +Contributions are welcome! To contribute: +1. Fork the repository +2. Create a new branch for your feature +3. Commit your changes +4. Push to the branch +5. Open a pull request + +## Troubleshooting +- **Issue**: Docker build fails. + **Solution**: Ensure Docker is running and you have the necessary permissions. + +- **Issue**: Indexer not syncing. + **Solution**: Check the `dipdup.yml` configuration and ensure network connectivity. + +## License +Homebase Indexer is licensed under [MIT License](LICENSE). \ No newline at end of file diff --git a/dipdup.yml b/dipdup.yml index e12b2bd..9de0c09 100644 --- a/dipdup.yml +++ b/dipdup.yml @@ -20,10 +20,10 @@ advanced: contracts: registry_mainnet: - address: KT1MFxwTan4ptw6PSc3KK6e1xfzMrCb382tw + code_hash: KT1MFxwTan4ptw6PSc3KK6e1xfzMrCb382tw typename: registry registry_ghostnet: - address: KT1QZtF8vVUvZYRxttRwgftc4EaQHZWgzXNp + code_hash: KT1QZtF8vVUvZYRxttRwgftc4EaQHZWgzXNp typename: registry datasources: @@ -86,93 +86,13 @@ templates: indexes: factory_mainnet: - kind: operation - datasource: tzkt_mainnet - types: - - origination - handlers: - - callback: on_factory_origination - pattern: - - type: origination - similar_to: registry_mainnet - - callback: on_propose - pattern: - - type: transaction - destination: registry_mainnet - entrypoint: propose - - callback: on_vote - pattern: - - type: transaction - destination: registry_mainnet - entrypoint: vote - - callback: on_drop_proposal - pattern: - - type: transaction - destination: registry_mainnet - entrypoint: drop_proposal - - callback: on_unstake_vote - pattern: - - type: transaction - destination: registry_mainnet - entrypoint: unstake_vote - - callback: on_flush - pattern: - - type: transaction - destination: registry_mainnet - entrypoint: flush - - callback: on_freeze - pattern: - - type: transaction - destination: registry_mainnet - entrypoint: freeze - - callback: on_unfreeze - pattern: - - type: transaction - destination: registry_mainnet - entrypoint: unfreeze + template: registry_dao + values: + datasource: tzkt_mainnet + contract: registry_mainnet factory_ghostnet: - kind: operation - datasource: tzkt_ghostnet - types: - - origination - handlers: - - callback: on_factory_origination - pattern: - - type: origination - similar_to: registry_ghostnet - - callback: on_propose - pattern: - - type: transaction - destination: registry_ghostnet - entrypoint: propose - - callback: on_vote - pattern: - - type: transaction - destination: registry_ghostnet - entrypoint: vote - - callback: on_drop_proposal - pattern: - - type: transaction - destination: registry_ghostnet - entrypoint: drop_proposal - - callback: on_unstake_vote - pattern: - - type: transaction - destination: registry_ghostnet - entrypoint: unstake_vote - - callback: on_flush - pattern: - - type: transaction - destination: registry_ghostnet - entrypoint: flush - - callback: on_freeze - pattern: - - type: transaction - destination: registry_ghostnet - entrypoint: freeze - - callback: on_unfreeze - pattern: - - type: transaction - destination: registry_ghostnet - entrypoint: unfreeze + template: registry_dao + values: + datasource: tzkt_ghostnet + contract: registry_ghostnet diff --git a/docker-compose.yml b/docker-compose.yml index 99ef058..40cbde2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,7 @@ services: - HASURA_GRAPHQL_UNAUTHORIZED_ROLE=indexer - HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES=true image: hasura/graphql-engine:v2.8.3.cli-migrations-v3 + restart: always db: container_name: hb-indexer-postgres ports: diff --git a/registrydao/__pycache__/__init__.cpython-38.pyc b/registrydao/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 897cc09..0000000 Binary files a/registrydao/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/registrydao/__pycache__/models.cpython-38.pyc b/registrydao/__pycache__/models.cpython-38.pyc deleted file mode 100644 index c2d26ac..0000000 Binary files a/registrydao/__pycache__/models.cpython-38.pyc and /dev/null differ diff --git a/registrydao/handlers/on_factory_origination.py b/registrydao/handlers/on_factory_origination.py index ea4fb3f..6daf612 100644 --- a/registrydao/handlers/on_factory_origination.py +++ b/registrydao/handlers/on_factory_origination.py @@ -18,11 +18,6 @@ async def on_factory_origination( network = extract_network_from_ctx(ctx) if index_name not in ctx.config.indexes: - await ctx.add_contract( - name=originated_contract, - address=originated_contract, - typename='registry', - ) await ctx.add_index( name=index_name, template='registry_dao', diff --git a/requirements.txt b/requirements.txt index 9b2785f..f10a2e1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,72 +1,72 @@ -aiohttp==3.8.1 -aiolimiter==1.0.0 -aiosignal==1.2.0 -aiosqlite==0.17.0 -anyio==3.5.0 -appdirs==1.4.4 -APScheduler==3.9.1 -argcomplete==2.0.0 -async-timeout==4.0.2 -asyncclick==8.0.3.2 -asyncpg==0.26.0 -attrs==21.4.0 -black==22.3.0 -certifi==2021.10.8 -chardet==4.0.0 -charset-normalizer==2.0.12 -click==8.1.2 -datamodel-code-generator==0.13.1 -dipdup==6.1.2 -dnspython==2.2.1 -email-validator==1.2.0 -fcache==0.4.7 -frozenlist==1.3.0 -genson==1.2.2 -idna==3.3 -inflect==5.5.2 -iso8601==1.0.2 -isodate==0.6.1 -isort==5.10.1 -Jinja2==3.1.1 -jsonschema==3.2.0 -MarkupSafe==2.1.1 -msgpack==1.0.3 -multidict==6.0.2 -mypy-extensions==0.4.3 -openapi-schema-validator==0.1.6 -openapi-spec-validator==0.3.3 -orjson==3.6.8 -pathspec==0.9.0 -platformdirs==2.5.2 -prance==0.21.8.0 -prometheus-client==0.14.1 -pydantic==1.9.2 -pyhumps==3.5.3 -pypika-tortoise==0.1.6 -pyrsistent==0.16.1 -pysignalr==0.1.2 -PySnooper==1.1.1 -python-dotenv==0.19.2 -pytz==2022.1 -pytz-deprecation-shim==0.1.0.post0 -PyYAML==6.0 -requests==2.27.1 -ruamel.yaml==0.17.21 -ruamel.yaml.clib==0.2.6 -semver==2.13.0 -sentry-sdk==1.5.10 -six==1.16.0 -sniffio==1.2.0 -sqlparse==0.4.2 -tabulate==0.8.9 -toml==0.10.2 -tomli==2.0.1 -tortoise-orm==0.19.2 -typed-ast==1.5.3 -typing-inspect==0.6.0 -typing_extensions==4.2.0 -tzdata==2022.1 -tzlocal==4.2 -urllib3==1.26.9 -websockets==10.3 -yarl==1.7.2 +dipdup==6.5.7 +aiohttp +aiolimiter +aiosignal +aiosqlite +anyio +appdirs +APScheduler +argcomplete +async-timeout +asyncclick +asyncpg +attrs +black +certifi +chardet +charset-normalizer +click +datamodel-code-generator +dnspython +email-validator +fcache +frozenlist +genson +idna +inflect +iso8601 +isodate +isort +Jinja2 +jsonschema +MarkupSafe +msgpack +multidict +mypy-extensions +openapi-schema-validator +openapi-spec-validator +orjson +pathspec +platformdirs +prance +prometheus-client +pydantic +pyhumps +pypika-tortoise +pyrsistent +pysignalr +PySnooper +python-dotenv +pytz +pytz-deprecation-shim +PyYAML +requests +ruamel.yaml +ruamel.yaml.clib +semver +sentry-sdk +six +sniffio +sqlparse +tabulate +toml +tomli +tortoise-orm +typed-ast +typing-inspect +typing_extensions +tzdata +tzlocal +urllib3 +websockets +yarl