Skip to content

Commit 122d81a

Browse files
authored
Feature: Implement 2 new messages statuses and 3 new EVM chains. (#220)
1 parent 3d39ca6 commit 122d81a

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dynamic = [ "version" ]
3030
dependencies = [
3131
"aiohttp>=3.8.3",
3232
"aioresponses>=0.7.6",
33-
"aleph-message>=1.0.1",
33+
"aleph-message>=1.0.2",
3434
"aleph-superfluid>=0.3",
3535
"base58==2.1.1", # Needed now as default with _load_account changement
3636
"coincurve; python_version>='3.9'",

src/aleph/sdk/client/http.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
ForgottenMessageError,
4040
InvalidHashError,
4141
MessageNotFoundError,
42+
RemovedMessageError,
43+
ResourceNotFoundError,
4244
)
4345
from ..query.filters import MessageFilter, PostFilter
4446
from ..query.responses import MessagesResponse, Post, PostsResponse, PriceResponse
@@ -231,6 +233,9 @@ async def download_file_to_buffer(
231233
)
232234
else:
233235
raise FileTooLarge(f"The file from {file_hash} is too large")
236+
if response.status == 404:
237+
raise ResourceNotFoundError()
238+
return None
234239

235240
async def download_file_ipfs_to_buffer(
236241
self,
@@ -400,6 +405,10 @@ async def get_message(
400405
raise ForgottenMessageError(
401406
f"The requested message {message_raw['item_hash']} has been forgotten by {', '.join(message_raw['forgotten_by'])}"
402407
)
408+
if message_raw["status"] == "removed":
409+
raise RemovedMessageError(
410+
f"The requested message {message_raw['item_hash']} has been removed by {', '.join(message_raw['reason'])}"
411+
)
403412
message = parse_message(message_raw["message"])
404413
if message_type:
405414
expected_type = get_message_type_value(message_type)
@@ -429,6 +438,10 @@ async def get_message_error(
429438
raise ForgottenMessageError(
430439
f"The requested message {message_raw['item_hash']} has been forgotten by {', '.join(message_raw['forgotten_by'])}"
431440
)
441+
if message_raw["status"] == "removed":
442+
raise RemovedMessageError(
443+
f"The requested message {message_raw['item_hash']} has been removed by {', '.join(message_raw['reason'])}"
444+
)
432445
if message_raw["status"] != "rejected":
433446
return None
434447
return {
@@ -558,6 +571,8 @@ async def get_stored_content(
558571
resp = f"Message not found: {item_hash}"
559572
except ForgottenMessageError:
560573
resp = f"Message forgotten: {item_hash}"
574+
except RemovedMessageError as e:
575+
resp = f"Message resources not available {item_hash}: {str(e)}"
561576
return (
562577
result
563578
if result

src/aleph/sdk/conf.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,26 @@ class Settings(BaseSettings):
136136
rpc="https://eth-mainnet.public.blastapi.io",
137137
token="0x27702a26126e0B3702af63Ee09aC4d1A084EF628",
138138
),
139+
Chain.ETHERLINK: ChainInfo(
140+
chain_id=42793,
141+
rpc="https://node.mainnet.etherlink.com",
142+
),
139143
Chain.FRAXTAL: ChainInfo(
140144
chain_id=252,
141145
rpc="https://rpc.frax.com",
142146
),
147+
Chain.HYPE: ChainInfo(
148+
chain_id=999,
149+
rpc="https://rpc.hyperliquid.xyz/evm",
150+
),
151+
Chain.INK: ChainInfo(
152+
chain_id=57073,
153+
rpc="https://rpc-gel.inkonchain.com",
154+
),
155+
Chain.LENS: ChainInfo(
156+
chain_id=232,
157+
rpc="https://rpc.lens.xyz",
158+
),
143159
Chain.LINEA: ChainInfo(
144160
chain_id=59144,
145161
rpc="https://linea-rpc.publicnode.com",

src/aleph/sdk/exceptions.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ class ForgottenMessageError(QueryError):
6969
pass
7070

7171

72+
class RemovedMessageError(QueryError):
73+
"""The requested message was removed"""
74+
75+
pass
76+
77+
78+
class ResourceNotFoundError(QueryError):
79+
"""A message resource was expected but could not be found."""
80+
81+
pass
82+
83+
7284
class InsufficientFundsError(Exception):
7385
"""Raised when the account does not have enough funds to perform an action"""
7486

0 commit comments

Comments
 (0)