Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: vm-connector used obsolete software #594

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docker/vm_connector.dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM python:3.9
FROM python:3.11

RUN apt-get update && apt-get -y upgrade && apt-get install -y \
libsecp256k1-dev \
zip \
&& rm -rf /var/lib/apt/lists/*

RUN pip install fastapi aiofiles uvicorn aleph-client eth-account
RUN pip install 'fastapi==0.110.0' 'aiofiles==23.2.1' 'uvicorn==0.29.0' 'aleph-sdk-python==0.9.1'

WORKDIR /opt
ENV PYTHONPATH=/opt
Expand Down
36 changes: 21 additions & 15 deletions vm_connector/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
from typing import Dict, Optional, Union

import aiohttp
from aleph_client.asynchronous import create_post
from aleph_client.chains.common import get_fallback_private_key
from aleph_client.chains.ethereum import ETHAccount
from aleph_client.types import StorageEnum
from aleph_message.status import MessageStatus
from fastapi import FastAPI, HTTPException, Request
from fastapi.responses import Response, StreamingResponse
from pydantic import BaseModel

from aleph.sdk import AuthenticatedAlephHttpClient
from aleph.sdk.chains.common import get_fallback_private_key
from aleph.sdk.chains.ethereum import ETHAccount
from aleph.sdk.types import StorageEnum

from .conf import settings

logger = logging.getLogger(__file__)
Expand Down Expand Up @@ -167,17 +169,21 @@ async def publish_data(body: PostBody):
content = json.loads(message["item_content"])
content_content = content["content"]

result = await create_post(
account=account,
post_content=content_content,
post_type=content["type"],
address=content["address"],
ref=None,
channel=message["channel"],
inline=True,
storage_engine=StorageEnum.storage,
)
return {"status": "success"}
async with AuthenticatedAlephHttpClient(account) as client:
result, status = await client.create_post(
post_content=content_content,
post_type=content["type"],
address=content["address"],
ref=None,
channel=message["channel"],
inline=True,
storage_engine=StorageEnum.storage,
sync=True,
)
if status == MessageStatus.PROCESSED:
return {"status": "success"}
else:
return {"status": "error"}


@app.get("/properties")
Expand Down