Skip to content

Commit 6b1781f

Browse files
committed
Fix: vm-connector used obsolete software
The vm-connector service used to run with obsolete versions of the aleph-sdk and Python. Solution: Use the latest the version of the SDK and pin the version of dependencies.
1 parent ab29137 commit 6b1781f

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

docker/vm_connector.dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM python:3.9
1+
FROM python:3.11
22

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

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

1010
WORKDIR /opt
1111
ENV PYTHONPATH=/opt

vm_connector/main.py

+21-15
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
from typing import Dict, Optional, Union
44

55
import aiohttp
6-
from aleph_client.asynchronous import create_post
7-
from aleph_client.chains.common import get_fallback_private_key
8-
from aleph_client.chains.ethereum import ETHAccount
9-
from aleph_client.types import StorageEnum
6+
from aleph_message.status import MessageStatus
107
from fastapi import FastAPI, HTTPException, Request
118
from fastapi.responses import Response, StreamingResponse
129
from pydantic import BaseModel
1310

11+
from aleph.sdk import AuthenticatedAlephHttpClient
12+
from aleph.sdk.chains.common import get_fallback_private_key
13+
from aleph.sdk.chains.ethereum import ETHAccount
14+
from aleph.sdk.types import StorageEnum
15+
1416
from .conf import settings
1517

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

170-
result = await create_post(
171-
account=account,
172-
post_content=content_content,
173-
post_type=content["type"],
174-
address=content["address"],
175-
ref=None,
176-
channel=message["channel"],
177-
inline=True,
178-
storage_engine=StorageEnum.storage,
179-
)
180-
return {"status": "success"}
172+
async with AuthenticatedAlephHttpClient(account) as client:
173+
result, status = await client.create_post(
174+
post_content=content_content,
175+
post_type=content["type"],
176+
address=content["address"],
177+
ref=None,
178+
channel=message["channel"],
179+
inline=True,
180+
storage_engine=StorageEnum.storage,
181+
sync=True,
182+
)
183+
if status == MessageStatus.PROCESSED:
184+
return {"status": "success"}
185+
else:
186+
return {"status": "error"}
181187

182188

183189
@app.get("/properties")

0 commit comments

Comments
 (0)