Skip to content

Commit 9ba1ed2

Browse files
authored
Merge pull request HemeraProtocol#174 from HemeraProtocol/pre-release/v0.3.0
Release/v0.3.0
2 parents 3d9489f + edf77d6 commit 9ba1ed2

File tree

277 files changed

+35640
-1711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+35640
-1711
lines changed

.github/workflows/ci.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Hemera Indexer Continuous Integration
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
services:
9+
postgres:
10+
image: postgres:15
11+
env:
12+
POSTGRES_USER: hemera
13+
POSTGRES_PASSWORD: password
14+
options: >-
15+
--health-cmd pg_isready
16+
--health-interval 10s
17+
--health-timeout 5s
18+
--health-retries 5
19+
ports:
20+
- 5432:5432
21+
env:
22+
ETHEREUM_PUBLIC_NODE_DEBUG_RPC_URL: '${{ secrets.ETHEREUM_PUBLIC_NODE_DEBUG_RPC_URL }}'
23+
ETHEREUM_PUBLIC_NODE_RPC_URL: '${{ secrets.ETHEREUM_PUBLIC_NODE_RPC_URL }}'
24+
LINEA_PUBLIC_NODE_DEBUG_RPC_URL: '${{ secrets.LINEA_PUBLIC_NODE_DEBUG_RPC_URL }}'
25+
LINEA_PUBLIC_NODE_RPC_URL: '${{ secrets.LINEA_PUBLIC_NODE_RPC_URL }}'
26+
POSTGRES_USER: hemera
27+
POSTGRES_PASSWORD: password
28+
POSTGRES_URL: postgresql://hemera:password@localhost:5432/hemera
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: Set up Python
32+
uses: actions/setup-python@v3
33+
with:
34+
python-version: '3.9'
35+
36+
- name: Install dependencies
37+
run: |
38+
pip install --upgrade pip
39+
pip install poetry
40+
poetry update
41+
poetry install -v
42+
poetry show
43+
44+
- name: Set PYTHONPATH
45+
run: echo "PYTHONPATH=\$PYTHONPATH:$(pwd)" >> $GITHUB_ENV
46+
47+
- name: Verify PYTHONPATH
48+
run: echo $PYTHONPATH
49+
50+
- name: Init database
51+
run: |
52+
export PYTHONPATH=$(pwd)
53+
make init_db
54+
55+
- name: Pipeline Test with pytest
56+
run: |
57+
export PYTHONPATH=$(pwd)
58+
make test indexer

.github/workflows/test.yaml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/ut.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Python application unit test
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
test:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up Python
13+
uses: actions/setup-python@v3
14+
with:
15+
python-version: '3.9'
16+
17+
- name: Install dependencies
18+
run: |
19+
pip install --upgrade pip
20+
pip install poetry
21+
poetry update
22+
poetry install -v
23+
24+
- name: Set PYTHONPATH
25+
run: echo "PYTHONPATH=\$PYTHONPATH:$(pwd)" >> $GITHUB_ENV
26+
27+
- name: Verify PYTHONPATH
28+
run: echo $PYTHONPATH
29+
30+
- name: Unit Test with pytest
31+
env:
32+
ETHEREUM_PUBLIC_NODE_DEBUG_RPC_URL: '${{ secrets.ETHEREUM_PUBLIC_NODE_DEBUG_RPC_URL }}'
33+
ETHEREUM_PUBLIC_NODE_RPC_URL: '${{ secrets.ETHEREUM_PUBLIC_NODE_RPC_URL }}'
34+
LINEA_PUBLIC_NODE_DEBUG_RPC_URL: '${{ secrets.LINEA_PUBLIC_NODE_DEBUG_RPC_URL }}'
35+
LINEA_PUBLIC_NODE_RPC_URL: '${{ secrets.LINEA_PUBLIC_NODE_RPC_URL }}'
36+
run: |
37+
export PYTHONPATH=$(pwd)
38+
make test indexer

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ docker-compose/postgres/
4949
resource/hemera.ini
5050
sync_record
5151
alembic.ini
52+
!indexer/modules/custom/hemera_ens/abi/*.json

Dockerfile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
FROM python:3.9-slim
1+
FROM python:3.9-slim AS builder
2+
3+
ENV PYTHONUNBUFFERED=1
4+
ENV PYTHONDONTWRITEBYTECODE=1
25

3-
WORKDIR /app
6+
RUN pip install poetry && poetry config virtualenvs.in-project true
47

8+
WORKDIR "/app"
59
COPY . .
610

7-
RUN pip install --no-cache-dir build && \
8-
python -m build && \
9-
pip install dist/*.whl && \
10-
rm dist/*.whl
11+
RUN poetry install
12+
RUN poetry build
13+
14+
FROM python:3.9-slim
15+
16+
WORKDIR "/app"
1117

12-
ENV PYTHONPATH=/app:$PYTHONPATH
18+
COPY --from=builder /app/migrations ./migrations
19+
COPY --from=builder /app/dist/*.whl .
20+
RUN pip install *.whl
1321

1422
ENTRYPOINT ["hemera"]

Makefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION := $(shell cat VERSION)
1+
VERSION := $(shell poetry version -s)
22
BUILD := `git rev-parse --short=7 HEAD`
33
SERVICES =
44
.PHONY: all build image test
@@ -10,15 +10,17 @@ RESET=\033[0m
1010

1111
image:
1212

13-
docker build $(IMAGE_FLAGS) --network host -t hemera-protocol:$(VERSION)-$(BUILD) . -q
13+
docker build $(IMAGE_FLAGS) --network host -t hemera-protocol:$(VERSION)-$(BUILD) . --no-cache
14+
echo "Built image hemera-protocol:$(VERSION)-$(BUILD)"
1415

1516
test:
1617
@if [ "$(filter-out $@,$(MAKECMDGOALS))" = "" ]; then \
17-
pytest -vv; \
18+
poetry run pytest -vv; \
1819
else \
19-
pytest -vv -m $(filter-out $@,$(MAKECMDGOALS)); \
20+
poetry run pytest -vv -m $(filter-out $@,$(MAKECMDGOALS)); \
2021
fi
2122

23+
2224
PRE_COMMIT_INSTALLED := $(shell command -v pre-commit > /dev/null 2>&1 && echo yes || echo no)
2325

2426
format:
@@ -27,4 +29,8 @@ ifeq ($(PRE_COMMIT_INSTALLED),yes)
2729
@pre-commit run --all-files
2830
else
2931
@echo "Please install pre-commit in your local machine(pip install pre-commit or brew install pre-commit)"
30-
endif
32+
endif
33+
34+
init_db:
35+
@echo "Initializing database..."
36+
poetry run python -m hemera.py init_db

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from pathlib import Path
22

3-
VERSION_FILE = Path(__file__).parent / "VERSION"
4-
__version__ = VERSION_FILE.read_text().strip()
3+
import tomli
4+
5+
__version__ = "0.3.0"

api/app/address/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from flask_restx.namespace import Namespace
2+
3+
address_features_namespace = Namespace(
4+
"Address Features",
5+
path="/",
6+
description="Address Features API",
7+
)

api/app/address/models.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from sqlalchemy import Column, Integer, PrimaryKeyConstraint, func
2+
from sqlalchemy.dialects.postgresql import BOOLEAN, BYTEA, INTEGER, NUMERIC, TEXT, TIMESTAMP
3+
4+
from common.models import HemeraModel
5+
6+
7+
class AddressBaseProfile(HemeraModel):
8+
__tablename__ = "af_base_profile"
9+
10+
address = Column(BYTEA, primary_key=True, nullable=False)
11+
init_funding_from_address = Column(BYTEA)
12+
init_funding_value = Column(NUMERIC)
13+
init_funding_transaction_hash = Column(BYTEA)
14+
init_funding_block_timestamp = Column(TIMESTAMP)
15+
init_block_hash = Column(BYTEA)
16+
init_block_number = Column(INTEGER)
17+
creation_code = Column(BYTEA)
18+
deployed_code = Column(BYTEA)
19+
deployed_block_timestamp = Column(TIMESTAMP)
20+
deployed_block_number = Column(INTEGER)
21+
deployed_block_hash = Column(BYTEA)
22+
deployed_transaction_hash = Column(BYTEA)
23+
deployed_internal_transaction_from_address = Column(BYTEA)
24+
deployed_transaction_from_address = Column(BYTEA)
25+
deployed_trace_id = Column(TEXT)
26+
is_contract = Column(BOOLEAN)
27+
first_transaction_hash = Column(BYTEA)
28+
first_block_hash = Column(BYTEA)
29+
first_block_number = Column(INTEGER)
30+
first_block_timestamp = Column(TIMESTAMP)
31+
first_trace_id = Column(TEXT)
32+
first_is_from_address = Column(BOOLEAN)
33+
first_trace_type = Column(TEXT)
34+
first_call_type = Column(TEXT)
35+
36+
37+
class ScheduledMetadata(HemeraModel):
38+
__tablename__ = "af_base_na_scheduled_metadata"
39+
40+
id = Column(Integer, primary_key=True)
41+
dag_id = Column(TEXT)
42+
execution_date = Column(TIMESTAMP)
43+
last_data_timestamp = Column(TIMESTAMP)

0 commit comments

Comments
 (0)