diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..21e0e7c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,17 @@ +# Ignore all +* + +# Add build files +!requirements** +!README.md + +# Add code +!registrydao + +# Add configs +!*.yml + +# Ignore caches +**/.mypy_cache +**/.pytest_cache +**/__pycache__ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aad2dbc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM dipdup/dipdup:6.1.2 + +COPY requirements.txt . + +RUN pip3 install -r requirements.txt + +COPY . . diff --git a/dipdup.yml b/dipdup.yml index 3c30762..60cf324 100644 --- a/dipdup.yml +++ b/dipdup.yml @@ -23,7 +23,7 @@ contracts: # address: KT1Je26VLhis2X8FaTda7SQT4PsstmCZL2ez # typename: registry registry_ghostnet: - address: KT1MFNuLR6yDCSBiDDKcsvVyNWcZVWNCFRTf + address: KT1QZtF8vVUvZYRxttRwgftc4EaQHZWgzXNp typename: registry datasources: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..99ef058 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +version: '3.3' +services: + hasura: + depends_on: + - db + # command: + # - "hasura metadata track --all-tables [--schema public]" + ports: + - '0.0.0.0:8080:8080' + environment: + - 'HASURA_GRAPHQL_DATABASE_URL=postgres://indexer:qwerty@hb-indexer-postgres:5432/indexer_db' + - HASURA_GRAPHQL_ENABLE_CONSOLE=true + - HASURA_GRAPHQL_DEV_MODE=true + - HASURA_GRAPHQL_ADMIN_SECRET=changeme + - HASURA_GRAPHQL_UNAUTHORIZED_ROLE=indexer + - HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES=true + image: hasura/graphql-engine:v2.8.3.cli-migrations-v3 + db: + container_name: hb-indexer-postgres + ports: + - '0.0.0.0:5432:5432' + environment: + - POSTGRES_USER=indexer + - POSTGRES_PASSWORD=qwerty + - POSTGRES_DB=indexer_db + image: postgres + indexer: + build: . + depends_on: + - db + command: ["-c", "dipdup.yml", "run"] + environment: + - PG_HOST=db + - PG_PORT=5432 + - PG_USER=indexer + - PG_PASSWORD=qwerty + - PG_DB=indexer_db + - PG_SCHEMA=public + ports: + - 0.0.0.0:9000:9000 \ No newline at end of file diff --git a/registrydao/handlers/on_call_custom.py b/registrydao/handlers/on_call_custom.py deleted file mode 100644 index 6c76482..0000000 --- a/registrydao/handlers/on_call_custom.py +++ /dev/null @@ -1,37 +0,0 @@ -from typing import Optional - -from dipdup.models import OperationData, Origination, Transaction -from dipdup.context import HandlerContext - -import registrydao.models as models - -from registrydao.types.registry.parameter.call_custom import CallCustomParameter -from registrydao.types.registry.storage import RegistryStorage - - -async def on_call_custom( - ctx: HandlerContext, - call_custom: Transaction[CallCustomParameter, RegistryStorage], -) -> None: - try: - dao_address = call_custom.data.target_address - dao = await models.DAO.get(address=dao_address).prefetch_related('governance_token') - timestamp = call_custom.data.timestamp - amount = call_custom.data.amount - integer_amount = call_custom.data.amount - decimal_amount = (call_custom.data.amount) / (10 ** 6) - from_address = call_custom.data.sender_address - hash = call_custom.data.hash - - await models.Transfer.get_or_create( - timestamp=timestamp, - amount=amount, - integer_amount=integer_amount, - decimal_amount=decimal_amount, - from_address=from_address, - dao=dao, - hash=hash - ) - except Exception as e: - print("Error in on_call_custom: " + str(call_custom.data.target_address)) - print(e) \ No newline at end of file