Skip to content

Commit

Permalink
meta: 7.0.0rc1 release (#744)
Browse files Browse the repository at this point in the history
Co-authored-by: Vladimir Bobrikov <wizardsbureau@protonmail.com>
  • Loading branch information
droserasprout and Wizard1209 authored Jul 21, 2023
1 parent ae00104 commit 945bcc3
Show file tree
Hide file tree
Showing 236 changed files with 2,785 additions and 2,993 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ jobs:
release:
name: Release
runs-on: ubuntu-22.04
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: ${{ github.repository }}

steps:
- name: Check out the repo
uses: actions/checkout@v3
Expand All @@ -29,11 +33,29 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

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

- name: Tag image for ghcr registry
uses: docker/metadata-action@v3
with:
images: dipdup/dipdup
flavor: |
latest=false
tags: |
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}/dipdup
- name: Set up metadata
id: meta
uses: docker/metadata-action@v3
with:
images: dipdup/dipdup
images: |
dipdup/dipdup
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}/dipdup
flavor: |
latest=false
tags: |
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog], and this project adheres to [Semantic Versioning].

## [Unreleased]
## [7.0.0rc1] - 2023-07-21

### Added

Expand Down Expand Up @@ -1089,7 +1089,8 @@ This release contains no changes except for the version number.
[semantic versioning]: https://semver.org/spec/v2.0.0.html

<!-- Versions -->
[Unreleased]: https://github.com/dipdup-io/dipdup/compare/6.5.9...HEAD
[Unreleased]: https://github.com/dipdup-io/dipdup/compare/7.0.0rc1...HEAD
[7.0.0rc1]: https://github.com/dipdup-io/dipdup/compare/6.5.9...7.0.0rc1
[6.5.9]: https://github.com/dipdup-io/dipdup/compare/6.5.8...6.5.9
[6.5.8]: https://github.com/dipdup-io/dipdup/compare/6.5.7...6.5.8
[6.5.7]: https://github.com/dipdup-io/dipdup/compare/6.5.6...6.5.7
Expand Down
4 changes: 0 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ We use `isort` and `black` for autoformatting, `ruff` for linting, and `mypy` fo
- Demos are stored in `demos` root directory. They MUST be generated automatically from project templates using replay files.
- Maintainers SHOULD run `make demos replays` command regularly to ensure that demo projects are up to date.

```admonish warning title=""
This page or paragraph is yet to be written. Come back later.
```

## Releases

- Release versions MUST conform to [Semantic Versioning](https://semver.org/). Releases that introduce breaking changes MUST be major ones.
Expand Down
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@
[![GitHub issues](https://img.shields.io/github/issues/dipdup-io/dipdup?color=2c2c2c)](https://github.com/dipdup-io/dipdup/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr/dipdup-io/dipdup?color=2c2c2c)](https://github.com/dipdup-io/dipdup/pulls)

```text
____ _ ____
/ __ \ (_)____ / __ \ __ __ ____
/ / / // // __ \ / / / // / / // __ \
/ /_/ // // /_/ // /_/ // /_/ // /_/ /
/_____//_// .___//_____/ \__,_// .___/
/_/ /_/
```
<h3 align="center"><img src="https://actual-docs.interface-1bp.pages.dev/_nuxt/logo.9b02ab5e.svg" alt="DipDup logo"></h3>

DipDup is a Python framework for building smart contract indexers. It helps developers focus on business logic instead of writing a boilerplate to store and serve data. DipDup-based indexers are selective, which means only required data is requested. This approach allows to achieve faster indexing times and decreased load on underlying APIs.

Expand All @@ -26,7 +19,7 @@ DipDup is a Python framework for building smart contract indexers. It helps deve

* **Want to participate?** Vote for [open issues](https://github.com/dipdup-io/dipdup/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc), join [discussions](https://github.com/dipdup-io/dipdup/discussions) or [become a sponsor](https://github.com/sponsors/dipdup-io).

* **Have a question?** Join our [Discord](https://discord.gg/sfqjBpmU) or tag @dipdup_io on [Twitter](https://twitter.com/dipdup_io).
* **Have a question?** Join our [Discord](https://discord.gg/NbANhqCJHA) or tag @dipdup_io on [Twitter](https://twitter.com/dipdup_io).

This project is maintained by the [Baking Bad](https://bakingbad.dev/) team.
<br>
Expand Down
5 changes: 0 additions & 5 deletions docs/.gitignore

This file was deleted.

157 changes: 78 additions & 79 deletions docs/11.move-us/4.quickstart.md → docs/0.quickstart.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
---
title: "Quickstart"
description: "This page will guide you through the steps to get your first selective indexer up and running in a few minutes without getting too deep into the details."
navigation.icon: "stars"
---

# Quickstart

This page will guide you through the steps to get your first selective indexer up and running in a few minutes without getting too deep into the details.

Let's create an indexer for the [tzBTC FA1.2 token contract](https://tzkt.io/KT1PWx2mnDueood7fEmfbBDKx1D9BAnnXitn/operations/). Our goal is to save all token transfers to the database and then calculate some statistics of its holders' activity.

`demo_token` demo is discussed in this guide; you can find it in the list of available templates when running `dipdup new` command.

A modern Linux/macOS distribution with Python 3.11 installed is required to run DipDup.

## Create a new project
Expand All @@ -12,25 +20,30 @@ A modern Linux/macOS distribution with Python 3.11 installed is required to run

You can initialize a hello-world project interactively by choosing configuration options in the terminal. The following command will install DipDup for the current user:

```shell
curl -Lsf https://dipdup.io/install.py | python
```shell [Terminal]
curl -Lsf https://dipdup.io/install.py | python3.11
```

Now, let's create a new project:

```shell
```shell [Terminal]
dipdup new
```

Follow the instructions; the project will be created in the current directory. You can skip reading the rest of this page and slap `dipdup run` instead.

### From scratch

Currently, we mainly use [Poetry](https://python-poetry.org) for dependency management in DipDup. If you prefer hatch, pdb, piptools or others — use them instead. Below are some snippets to get you started.
If you don't want to use our installer, you can install DipDup manually. You can use any Python package manager you like, but we recommend [PDM](https://pdm.fming.dev/latest/).

```shell
```shell [Terminal]
# Create a new project directory
mkdir dipdup_indexer; cd dipdup_indexer
mkdir {{ project.package }}; cd {{ project.package }}

# PDM
pdm init --python ">=3.11,<3.12"
pdm add dipdup
pdm venv activate

# Plain pip
python -m venv .venv
Expand All @@ -43,138 +56,124 @@ poetry add dipdup
poetry shell
```

::banner{type="note"}

* {{ #summary getting-started/installation.md}}
* [Poetry documentation](https://python-poetry.org/docs/)
::

## Write a configuration file

DipDup configuration is stored in YAML files of a specific format. Create a new file named `dipdup.yaml` in your current working directory with the following content:
DipDup configuration is stored in YAML files of a specific format. Create a new file named `dipdup.yaml` in the project root with the following content:

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

::banner{type="note"}

* {{ #summary getting-started/templates-and-variables.md}}
* {{ #summary config/README.md}}
::

## Initialize project tree
## Generate types and stubs

Now it's time to generate typeclasses and callback stubs. Run the following command:

```shell
```shell [Terminal]
dipdup init
```

DipDup will create a Python package `demo_token` having the following structure:

```
demo_token
```shell
demo_token [src/demo_token]
├── abi
├── configs
│ ├── dipdup.compose.yaml
│ ├── dipdup.sqlite.yaml
│ ├── dipdup.swarm.yaml
│ └── replay.yaml
├── deploy
│ ├── .env.default
│ ├── Dockerfile
│ ├── compose.sqlite.yaml
│ ├── compose.swarm.yaml
│ ├── compose.yaml
│ ├── sqlite.env.default
│ └── swarm.env.default
├── graphql
├── handlers
│ ├── __init__.py
│ ├── on_balance_update.py
│ ├── on_mint.py
│ └── on_transfer.py
├── hasura
├── hooks
│ ├── __init__.py
│ ├── on_index_rollback.py
│ ├── on_reindex.py
│ ├── on_restart.py
│ ├── on_index_rollback.py
│ └── on_synchronized.py
├── __init__.py
── models.py
├── models
│ └── __init__.py
├── sql
│ ├── on_reindex
│ ├── on_restart
│ ├── on_index_rollback
│ └── on_synchronized
└── types
├── __init__.py
└── tzbtc
├── __init__.py
├── parameter
│ ├── __init__.py
│ ├── mint.py
│ └── transfer.py
└── storage.py
├── types
│ ├── tzbtc/tezos_parameters/mint.py
│ ├── tzbtc/tezos_parameters/transfer.py
│ └── tzbtc/tezos_storage.py
├── py.typed
├── __init__.py
└── pyproject.toml
```

That's a lot of files and directories! But don't worry, we will need only `models.py` and `handlers` modules in this guide.

::banner{type="note"}

* {{ #summary getting-started/project-package.md}}
* {{ #summary cli-reference.md#init}}
::
That's a lot of files and directories! But don't worry, we will need only `models` and `handlers` sections in this guide.

## Define data models

Our schema will consist of a single model `Holder` having several fields:

* `address` — account address
* `balance` — in tzBTC
* `volume` — total transfer/mint amount bypassed
* `tx_count` — number of transfers/mints
* `last_seen` — time of the last transfer/mint
- `address` — account address
- `balance` — in tzBTC
- `volume` — total transfer/mint amount bypassed
- `tx_count` — number of transfers/mints
- `last_seen` — time of the last transfer/mint

Put the following content in the `models.py` file:
Put the following content in the `models/__init__.py` file:

```python
```python [models/__init__.py]
{{ #include ../src/demo_token/models/__init__.py }}
```

::banner{type="note"}

* {{ #summary getting-started/defining-models.md}}
* [Tortoise ORM documentation](https://tortoise-orm.readthedocs.io/en/latest/)
* [Tortoise ORM examples](https://tortoise-orm.readthedocs.io/en/latest/examples.html)
::

## Implement handlers

Everything's ready to implement an actual indexer logic.

Our task is to index all the balance updates, so we'll start with a helper method to handle them. Create a file named `on_balance_update.py` in the `handlers` package with the following content:

```python
```python [handlers/on_balance_update.py]
{{ #include ../src/demo_token/handlers/on_balance_update.py }}
```

Three methods of tzBTC contract can alter token balances — `transfer`, `mint`, and `burn`. The last one is omitted in this tutorial for simplicity. Edit corresponding handlers to call the `on_balance_update` method with data from matched operations:

`on_transfer.py`

```python
```python [handlers/on_transfer.py]
{{ #include ../src/demo_token/handlers/on_transfer.py }}
```

`on_mint.py`

```python
```python [handlers/on_mint.py]
{{ #include ../src/demo_token/handlers/on_mint.py }}
```

And that's all! We can run the indexer now.

::banner{type="note"}

* {{ #summary getting-started/implementing-handlers.md}}
::
## Next steps

## Run your indexer
Run the indexer in-memory:

```shell
```bash
dipdup run
```

DipDup will fetch all the historical data and then switch to realtime updates. Your application data has been successfully indexed!
Store data in SQLite database:

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

::banner{type="note"}
Or spawn a docker-compose stack:

* {{ #summary cli-reference.md}}
::
```bash
cd deploy
cp .env.default .env
# Edit .env before running
docker-compose up
```

DipDup will fetch all the historical data and then switch to realtime updates. Your application data has been successfully indexed!
Loading

0 comments on commit 945bcc3

Please sign in to comment.