Skip to content

Commit

Permalink
Merge branch 'next' into feat/init-include
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Oct 20, 2023
2 parents 6a3a939 + 3e6cee8 commit 95c2966
Show file tree
Hide file tree
Showing 73 changed files with 1,471 additions and 228 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@ jobs:

steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
install: true

- name: Log in to the registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up metadata
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
flavor: |
Expand All @@ -55,7 +55,7 @@ jobs:
type=ref,event=tag
- name: Publish nightly image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ jobs:
# && sudo apt install gh -y

- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@main
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
Expand All @@ -47,7 +47,7 @@ jobs:
run: pip install pdm

- name: Install project
run: pdm install
run: pdm sync

- name: Clone frontend
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
arch: arm64
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@main
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,35 @@ jobs:

steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4
# NOTE: Fetch full history for Sentry release
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
install: true

- name: Log in to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to GHCR
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker metadata
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
images: |
dipdup/dipdup
Expand All @@ -55,7 +55,7 @@ jobs:
type=pep440,pattern={{major}}.{{minor}}
- name: Set up Python
uses: actions/setup-python@main
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
Expand All @@ -72,7 +72,7 @@ jobs:
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}

- name: Publish stable image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ jobs:
arch: arm64
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install PDM
run: pipx install pdm

- name: Set up Python
uses: actions/setup-python@main
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'

- name: Run install
run: pdm install
run: pdm sync

- name: Run lint
run: pdm run lint
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic
### Added

- cli: Relative paths to be initialized now can be passed to the `init` command as arguments.
- tezos.tzkt.token_balances: Added new index.

### Fixed

- tezos.tzkt.token_transfers: Fixed filtering transfers by token_id.

## [7.0.2] - 2023-10-10

Expand Down
1 change: 1 addition & 0 deletions docs/1.getting-started/7.indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Multiple indexes are available for different workloads. Every index is linked to
| [tezos.tzkt.operations](../2.indexes/5.tezos_tzkt_operations.md) | Tezos | TzKT | typed operations |
| [tezos.tzkt.operations_unfiltered](../2.indexes/6.tezos_tzkt_operations_unfiltered.md) | Tezos | TzKT | untyped operations |
| [tezos.tzkt.token_transfers](../2.indexes/7.tezos_tzkt_token_transfers.md) | Tezos | TzKT | TZIP-12/16 token transfers |
| [tezos.tzkt.token_balances](../2.indexes/8.tezos_tzkt_token_balances.md) | Tezos | TzKT | TZIP-12/16 token balances |

Indexes can join multiple contracts considered as a single application. Also, contracts can be used by multiple indexes of any kind, but make sure that they are independent of each other and that indexed data don't overlap.

Expand Down
19 changes: 19 additions & 0 deletions docs/2.indexes/8.tezos_tzkt_token_balances.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: "Token balances"
description: "This index allows indexing token balances of contracts compatible with FA1.2 or FA2 standards."
network: "tezos"
---

# `tezos.tzkt.token_balances` index

This index allows indexing token balances of contracts compatible with [FA1.2](https://gitlab.com/tzip/tzip/-/blob/master/proposals/tzip-7/README.md) or [FA2](https://gitlab.com/tzip/tzip/-/blob/master/proposals/tzip-12/tzip-12.md) standards. You can either index transfers and cumulatively calculate balances or use this index type to fetch the latest balance information directly.

```yaml [dipdup.yaml]
{{ #include ../src/demo_token_balances/dipdup.yaml }}
```

Callback receives `TzktTokenBalanceData` model that optionally contains the owner, token, and balance values

```python
{{ #include ../src/demo_token_balances/handlers/on_balance_update.py }}
```
22 changes: 22 additions & 0 deletions src/demo_token_balances/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Ignore all
*

# Add metadata and build files
!demo_token_balances
!pyproject.toml
!pdm.lock
!README.md

# Add Python code
!**/*.py
**/.*_cache
**/__pycache__

# Add configs and scripts (but not env!)
!**/*.graphql
!**/*.json
!**/*.sql
!**/*.yaml
!**/*.yml
!**/*.j2
!**/.keep
29 changes: 29 additions & 0 deletions src/demo_token_balances/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Ignore all
*
!*/

# Add metadata and build files
!demo_token_balances
!.gitignore
!.dockerignore
!py.typed
!**/Dockerfile
!**/Makefile
!**/pyproject.toml
!**/pdm.lock
!**/README.md
!**/.keep

# Add Python code
!**/*.py
**/.*_cache
**/__pycache__

# Add configs and scripts (but not env!)
!**/*.graphql
!**/*.json
!**/*.sql
!**/*.yaml
!**/*.yml
!**/*.j2
!**/*.env.default
61 changes: 61 additions & 0 deletions src/demo_token_balances/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# demo_token_balances

TzBTC FA1.2 token balances

## Installation

This project is based on [DipDup](https://dipdup.io), a framework for building featureful dapps.

You need a Linux/macOS system with Python 3.11 installed. Use our installer for easy setup:

```bash
curl -Lsf https://dipdup.io/install.py | python3
```

See the [Installation](https://dipdup.io/docs/installation) page for all options.

## Usage

Run the indexer in-memory:

```bash
dipdup run
```

Store data in SQLite database:

```bash
dipdup -c . -c configs/dipdup.sqlite.yml run
```

Or spawn a docker-compose stack:

```bash
cp deploy/.env.default deploy/.env
# Edit .env before running
docker-compose -f deploy/compose.yaml up
```

## Development setup

We recommend [PDM](https://pdm.fming.dev/latest/) for managing Python projects. To set up the development environment:

```bash
pdm install
$(pdm venv activate)
```

Some tools are included to help you keep the code quality high: black, ruff and mypy.

```bash
# Format code
pdm fmt

# Lint code
pdm lint

# Build Docker image
pdm image
```

Inspect the `pyproject.toml` file. It contains all the dependencies and tools used in the project.
Empty file.
Empty file.
Empty file.
22 changes: 22 additions & 0 deletions src/demo_token_balances/configs/dipdup.compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
database:
kind: postgres
host: ${POSTGRES_HOST:-db}
port: 5432
user: ${POSTGRES_USER:-dipdup}
password: ${POSTGRES_PASSWORD}
database: ${POSTGRES_DB:-dipdup}

hasura:
url: http://${HASURA_HOST:-hasura}:8080
admin_secret: ${HASURA_SECRET}
allow_aggregations: true
camel_case: true

sentry:
dsn: ${SENTRY_DSN:-""}
environment: ${SENTRY_ENVIRONMENT:-""}

prometheus:
host: 0.0.0.0

logging: ${LOGLEVEL:-INFO}
5 changes: 5 additions & 0 deletions src/demo_token_balances/configs/dipdup.sqlite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
database:
kind: sqlite
path: ${SQLITE_PATH:-/tmp/demo_token_balances.sqlite}

logging: ${LOGLEVEL:-INFO}
22 changes: 22 additions & 0 deletions src/demo_token_balances/configs/dipdup.swarm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
database:
kind: postgres
host: ${POSTGRES_HOST:-demo_token_balances_db}
port: 5432
user: ${POSTGRES_USER:-dipdup}
password: ${POSTGRES_PASSWORD}
database: ${POSTGRES_DB:-dipdup}

hasura:
url: http://${HASURA_HOST:-demo_token_balances_hasura}:8080
admin_secret: ${HASURA_SECRET}
allow_aggregations: false
camel_case: true

sentry:
dsn: ${SENTRY_DSN:-""}
environment: ${SENTRY_ENVIRONMENT:-""}

prometheus:
host: 0.0.0.0

logging: ${LOGLEVEL:-INFO}
15 changes: 15 additions & 0 deletions src/demo_token_balances/configs/replay.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Run `dipdup new --replay configs/replay.yaml` to generate new project from this replay
spec_version: 2.0
replay:
dipdup_version: 7
template: demo_token_balances
package: demo_token_balances
version: 0.0.1
description: TzBTC FA1.2 token balances
license: MIT
name: John Doe
email: [email protected]
postgres_image: postgres:15
postgres_data_path: /var/lib/postgresql/data
hasura_image: hasura/graphql-engine:latest
line_length: 120
Loading

0 comments on commit 95c2966

Please sign in to comment.