Skip to content

Commit

Permalink
Update EVM demos, make ws_url optional (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout authored Jan 29, 2024
1 parent 3eed92d commit a502c17
Show file tree
Hide file tree
Showing 50 changed files with 454 additions and 423 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Run all checks
run: pdm run all
env:
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
NODE_API_KEY: ${{ secrets.ALCHEMY_KEY }}

- name: Publish stable image
uses: docker/build-push-action@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
- name: Run tests
run: pdm run test
env:
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
NODE_API_KEY: ${{ secrets.ALCHEMY_KEY }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ruff: ## Lint with ruff
ruff check --fix ${SOURCE}

mypy: ## Lint with mypy
mypy --no-incremental --exclude ${PACKAGE} ${SOURCE}
mypy --no-incremental ${SOURCE}

##

Expand Down
2 changes: 1 addition & 1 deletion docs/0.quickstart-evm.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Let's create an indexer for the [USDt token contract](https://etherscan.io/addre

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

The easiest way to install DipDup as a CLI application [pipx](https://pypa.github.io/pipx/). We have a convenient wrapper script that installs DipDup for the current user. Run the following command in your terminal:
The easiest way to install DipDup as a CLI application [pipx](https://pipx.pypa.io/stable/). We have a convenient wrapper script that installs DipDup for the current user. Run the following command in your terminal:

```shell [Terminal]
curl -Lsf https://dipdup.io/install.py | python3
Expand Down
2 changes: 1 addition & 1 deletion docs/0.quickstart-tezos.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Let's create an indexer for the [tzBTC FA1.2 token contract](https://tzkt.io/KT1

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

The easiest way to install DipDup as a CLI application [pipx](https://pypa.github.io/pipx/). We have a convenient wrapper script that installs DipDup for the current user. Run the following command in your terminal:
The easiest way to install DipDup as a CLI application [pipx](https://pipx.pypa.io/stable/). We have a convenient wrapper script that installs DipDup for the current user. Run the following command in your terminal:

```shell [Terminal]
curl -Lsf https://dipdup.io/install.py | python3
Expand Down
20 changes: 10 additions & 10 deletions docs/1.getting-started/6.datasources.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ Datasources are DipDup connectors to various APIs. They are defined in config an

Index datasources, ones that can be attached to a specific index, are prefixed with blockchain name, e.g. `tezos.tzkt` or `evm.subsquid`.

| kind | blockchain | description |
| ---------------------------------------------------------- | -------------- | ------------------------------- |
| [abi.etherscan](../3.datasources/1.abi_etherscan.md) | EVM-compatible | Provides ABIs for EVM contracts |
| [coinbase](../3.datasources/2.coinbase.md) | any | Coinbase price feed |
| [evm.node](../3.datasources/3.evm_node.md) | EVM-compatible | Ethereum node |
| [evm.subsquid](../3.datasources/4.evm_subsquid.md) | EVM-compatible | Subsquid Archives node |
| [http](../3.datasources/5.http.md) | any | Generic HTTP API |
| [ipfs](../3.datasources/6.ipfs.md) | any | IPFS gateway |
| [tezos.tzkt](../3.datasources/7.tezos_tzkt.md) | Tezos | TzKT API |
| [tezos.tzip_metadata](../3.datasources/8.tzip_metadata.md) | Tezos | TZIP-16 metadata |
| kind | blockchain | description |
| ---------------------------------------------------------- | ---------------- | ------------------------------- |
| [abi.etherscan](../3.datasources/1.abi_etherscan.md) | EVM-compatible | Provides ABIs for EVM contracts |
| [coinbase](../3.datasources/2.coinbase.md) | any | Coinbase price feed |
| [evm.node](../3.datasources/3.evm_node.md) | EVM-compatible | Ethereum node |
| [evm.subsquid](../3.datasources/4.evm_subsquid.md) | EVM-compatible | Subsquid Network node |
| [http](../3.datasources/5.http.md) | any | Generic HTTP API |
| [ipfs](../3.datasources/6.ipfs.md) | any | IPFS gateway |
| [tezos.tzkt](../3.datasources/7.tezos_tzkt.md) | Tezos | TzKT API |
| [tezos.tzip_metadata](../3.datasources/8.tzip_metadata.md) | Tezos | TZIP-16 metadata |

## Connection settings

Expand Down
4 changes: 2 additions & 2 deletions docs/15.thanks.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ We are grateful to all the people who helped us with the project.
- [852Kerfunkle](https://github.com/852Kerfunkle)
- [Anshit Bhardwaj](https://github.com/Anshit01)
- [arrijabba](https://github.com/arrijabba)
- [Do Quang Huy](https://github.com/huydo2105)
- [Fitblip](https://github.com/Fitblip)
- [Florian PAUTOT](https://github.com/xflpt)
- [Florian PAUTOT](https://github.com/0x666c6f)
- [gdsoumya](https://github.com/gdsoumya)
- [Göran Sandström](https://github.com/veqtor)
- [herohthd](https://github.com/herohthd)
- [Javier Graciá Carpio](https://github.com/jagracar)
- [Karan Dua](https://github.com/Karantezsure)
- [Nick Kalomoiris](https://github.com/nikos-kalomoiris)
Expand Down
2 changes: 1 addition & 1 deletion docs/2.indexes/1.evm_subsquid_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ network: "ethereum"

This index allows indexing events emitted by Ethereum smart contracts. You can define a handler for each contract/tag pair. Only necessary events are processed.

RPC node is optional for this index. If not specified, the index will lack real-time data and will be able to process only historical data provided by Subsquid Archives API.
RPC node is optional for this index. If not specified, the index will lack real-time data and will be able to process only historical data provided by Subsquid Network API.

This is a basic config for USDt token contract. You can use this demo as a template for your project choosing `demo_evm_events` in `dipdup new` command.

Expand Down
16 changes: 8 additions & 8 deletions docs/3.datasources/3.evm_node.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
---
title: "EVM Node"
description: "DipDup can connect to any EVM-compatible node via JSON-RPC. It can be used as a last mile datasource for EVM indexes (data that is not in Subsquid Archives yet) or as a standalone datasource for handlers and hooks."
description: "DipDup can connect to any EVM-compatible node via JSON-RPC. It can be used as a last mile datasource for EVM indexes (data that is not in Subsquid Network yet) or as a standalone datasource for handlers and hooks."
network: "ethereum"
---

# EVM node

DipDup can connect to any EVM-compatible node via JSON-RPC. It can be used as a "last mile" datasource for EVM indexes (data that is not in Subsquid Archives yet) or as a standalone datasource for handlers and hooks.
DipDup can connect to any EVM-compatible node via JSON-RPC. It can be used as a "last mile" datasource for EVM indexes (data that is not in Subsquid Network yet) or as a standalone datasource for handlers and hooks.

Examples below show how to connect to Infura and Alchemy nodes for Ethereum mainnet indexes. You can also use your own node, but make sure it has all the necessary data (e.g. archive node).

```yaml [dipdup.yaml]
datasources:
mainnet_alchemy_node:
kind: evm.node
url: https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}
ws_url: wss://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}
url: ${NODE_URL:-https://eth-mainnet.g.alchemy.com/v2}/${NODE_API_KEY:-''}
ws_url: ${NODE_WS_URL:-wss://eth-mainnet.g.alchemy.com/v2}/${NODE_API_KEY:-''}
```
EVM node datasources could linked to specific Subsquid ones instead of being used directly in indexes.
```yaml [dipdup.yaml]
datasources:
mainnet_subsquid:
subsquid:
kind: evm.subsquid
url: ${ARCHIVE_URL:-https://v2.archive.subsquid.io/network/ethereum-mainnet}
node: mainnet_node
url: ${SUBSQUID_URL:-https://v2.archive.subsquid.io/network/ethereum-mainnet}
node: evm_node
```
## web3 client
Expand All @@ -39,7 +39,7 @@ Don't initialize web3 clients manually! It will break the connection pooling, lo
To access the client, use `web3` property of the datasource. The underlying web3 client is asynchronous, so you should use `await` keyword to call its methods.

```python
web3: AsyncWeb3 = ctx.get_evm_node_datasource('mainnet_node').web3
web3: AsyncWeb3 = ctx.get_evm_node_datasource('evm_node').web3
contract = self.web3.eth.contract(...)
symbol = await contract.functions.symbol().call()
```
Expand Down
24 changes: 12 additions & 12 deletions docs/3.datasources/4.evm_subsquid.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
---
title: "Subsquid Archives"
description: "DipDup uses Subsquid Archives as a source of historical data for EVM-compatible blockchains."
title: "Subsquid Network"
description: "DipDup uses Subsquid Network as a source of historical data for EVM-compatible blockchains."
network: "ethereum"
---

# Subsquid Archives
# Subsquid Network

DipDup uses [Subsquid Archives](https://docs.subsquid.io/archives/) as a source of historical data for EVM-compatible blockchains. Configure the datasource in your project config:
DipDup uses [Subsquid Network](https://docs.subsquid.io/subsquid-network/reference/evm-api/) as a source of historical data for EVM-compatible blockchains. Configure the datasource in your project config:

```yaml [dipdup.yaml]
datasources:
mainnet_subsquid:
subsquid:
kind: evm.subsquid
url: ${ARCHIVE_URL:-https://v2.archive.subsquid.io/network/ethereum-mainnet}
url: ${SUBSQUID_URL:-https://v2.archive.subsquid.io/network/ethereum-mainnet}
```
You can also link the datasource to a specific node to allow realtime indexing:
```yaml [dipdup.yaml]
datasources:
mainnet_node:
evm_node:
kind: evm.node
url: https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY:-''}
ws_url: wss://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY:-''}
mainnet_subsquid:
url: ${NODE_URL:-https://eth-mainnet.g.alchemy.com/v2}/${NODE_API_KEY:-''}
ws_url: ${NODE_WS_URL:-wss://eth-mainnet.g.alchemy.com/v2}/${NODE_API_KEY:-''}
subsquid:
kind: evm.subsquid
url: ${ARCHIVE_URL:-https://v2.archive.subsquid.io/network/ethereum-mainnet}
url: ${SUBSQUID_URL:-https://v2.archive.subsquid.io/network/ethereum-mainnet}
```
Now, use this datasource in EVM index definitions:
Expand All @@ -34,6 +34,6 @@ Now, use this datasource in EVM index definitions:
indexes:
uniswap_v3:
kind: evm.subsquid.events
datasource: mainnet_subsquid
datasource: subsquid
...
```
2 changes: 1 addition & 1 deletion docs/4.graphql/4.genql.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ yarn
yarn build
```

Read more about CLI [options](https://genql.vercel.app/docs/cli/generate) available.
Read more about CLI [options](https://genql.dev/docs/cli-reference) available.

### Demo

Expand Down
Loading

0 comments on commit a502c17

Please sign in to comment.