Skip to content

Commit 22e22dd

Browse files
authored
Merge branch 'main' into mhh-domain-node
2 parents b1ad1a5 + 4080042 commit 22e22dd

File tree

14 files changed

+129
-55
lines changed

14 files changed

+129
-55
lines changed

examples/httpgateway.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" Server metrics upload.
22
"""
3+
34
# -*- coding: utf-8 -*-
45

56
import click

examples/metrics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" Server metrics upload.
22
"""
3+
34
import asyncio
45
import os
56
import platform

examples/mqtt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" Server metrics upload.
22
"""
3+
34
# -*- coding: utf-8 -*-
45

56
import asyncio

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ exclude =
167167
dist
168168
.eggs
169169
docs/conf.py
170-
ignore = E501 W291 W503 E203
170+
ignore = E501 W291 W503 E203 E704
171171

172172
[isort]
173173
profile = black

src/aleph/sdk/chains/nuls1.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
""" Barebone NULS address and message signing support.
22
"""
3+
34
import hashlib
45
import logging
56
import struct

src/aleph/sdk/chains/remote.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Remote account, accessible via an API.
33
"""
4+
45
import asyncio
56
from typing import Dict, Optional
67

src/aleph/sdk/client/authenticated_http.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from ..conf import settings
3838
from ..exceptions import BroadcastError, InsufficientFundsError, InvalidMessageError
3939
from ..types import Account, StorageEnum
40-
from ..utils import extended_json_encoder
40+
from ..utils import extended_json_encoder, parse_volume
4141
from .abstract import AuthenticatedAlephClient
4242
from .http import AlephHttpClient
4343

@@ -68,7 +68,7 @@ class AuthenticatedAlephHttpClient(AlephHttpClient, AuthenticatedAlephClient):
6868
def __init__(
6969
self,
7070
account: Account,
71-
api_server: Optional[str],
71+
api_server: Optional[str] = None,
7272
api_unix_socket: Optional[str] = None,
7373
allow_unix_sockets: bool = True,
7474
timeout: Optional[aiohttp.ClientTimeout] = None,
@@ -449,9 +449,7 @@ async def create_program(
449449
# Trigger on HTTP calls.
450450
triggers = {"http": True, "persistent": persistent}
451451

452-
volumes: List[MachineVolume] = [
453-
MachineVolume.parse_obj(volume) for volume in volumes
454-
]
452+
volumes: List[MachineVolume] = [parse_volume(volume) for volume in volumes]
455453

456454
content = ProgramContent(
457455
type="vm-function",
@@ -478,11 +476,13 @@ async def create_program(
478476
runtime=FunctionRuntime(
479477
ref=runtime,
480478
use_latest=True,
481-
comment="Official aleph.im runtime"
482-
if runtime == settings.DEFAULT_RUNTIME_ID
483-
else "",
479+
comment=(
480+
"Official aleph.im runtime"
481+
if runtime == settings.DEFAULT_RUNTIME_ID
482+
else ""
483+
),
484484
),
485-
volumes=[MachineVolume.parse_obj(volume) for volume in volumes],
485+
volumes=[parse_volume(volume) for volume in volumes],
486486
time=time.time(),
487487
metadata=metadata,
488488
)
@@ -551,11 +551,13 @@ async def create_instance(
551551
size_mib=rootfs_size,
552552
persistence="host",
553553
use_latest=True,
554-
comment="Official Aleph Debian root filesystem"
555-
if rootfs == settings.DEFAULT_RUNTIME_ID
556-
else "",
554+
comment=(
555+
"Official Aleph Debian root filesystem"
556+
if rootfs == settings.DEFAULT_RUNTIME_ID
557+
else ""
558+
),
557559
),
558-
volumes=[MachineVolume.parse_obj(volume) for volume in volumes],
560+
volumes=[parse_volume(volume) for volume in volumes],
559561
time=time.time(),
560562
authorized_keys=ssh_keys,
561563
metadata=metadata,

src/aleph/sdk/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ class Settings(BaseSettings):
2929
REMOTE_CRYPTO_UNIX_SOCKET: Optional[str] = None
3030
ADDRESS_TO_USE: Optional[str] = None
3131

32-
DEFAULT_RUNTIME_ID: str = "f873715dc2feec3833074bd4b8745363a0e0093746b987b4c8191268883b2463" # Debian 12 official runtime
32+
DEFAULT_RUNTIME_ID: str = (
33+
"f873715dc2feec3833074bd4b8745363a0e0093746b987b4c8191268883b2463" # Debian 12 official runtime
34+
)
3335
DEFAULT_VM_MEMORY: int = 256
3436
DEFAULT_VM_VCPUS: int = 1
3537
DEFAULT_VM_TIMEOUT: float = 30.0

src/aleph/sdk/domain.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ async def check_domain(
187187
Returns:
188188
A dictionary containing the status of the domain configuration.
189189
"""
190-
status = {"cname": False, "owner_proof": False}
190+
status = {}
191191

192192
dns_rules = self.get_required_dns_rules(hostname, target, owner)
193-
193+
resolver = await self.get_resolver_for(hostname)
194194
for dns_rule in dns_rules:
195195
status[dns_rule.name] = False
196196

@@ -199,26 +199,25 @@ async def check_domain(
199199
record_value = dns_rule.dns["value"]
200200

201201
try:
202-
resolver = await self.get_resolver_for(hostname)
203202
entries = await resolver.query(record_name, record_type.upper())
204203
except aiodns.error.DNSError:
205204
# Continue checks
206205
entries = None
207206

208-
if entries and record_type == "txt":
209-
for entry in entries:
210-
if hasattr(entry, "text") and entry.text == record_value:
211-
break
212-
else:
213-
return dns_rule.raise_error(status)
214-
elif (
215-
entries is None
216-
or not hasattr(entries, record_type)
217-
or getattr(entries, record_type) != record_value
218-
):
219-
return dns_rule.raise_error(status)
220-
221-
status[dns_rule.name] = True
207+
if entries:
208+
if record_type == "txt":
209+
for entry in entries:
210+
if hasattr(entry, "text") and entry.text == record_value:
211+
status[dns_rule.name] = True
212+
break
213+
elif (
214+
hasattr(entries, record_type)
215+
and getattr(entries, record_type) == record_value
216+
):
217+
status[dns_rule.name] = True
218+
219+
if all(status.values()) is False:
220+
dns_rule.raise_error(status)
222221

223222
return status
224223

src/aleph/sdk/types.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,19 @@ class Account(Protocol):
1818
CURVE: str
1919

2020
@abstractmethod
21-
async def sign_message(self, message: Dict) -> Dict:
22-
...
21+
async def sign_message(self, message: Dict) -> Dict: ...
2322

2423
@abstractmethod
25-
def get_address(self) -> str:
26-
...
24+
def get_address(self) -> str: ...
2725

2826
@abstractmethod
29-
def get_public_key(self) -> str:
30-
...
27+
def get_public_key(self) -> str: ...
3128

3229

3330
class AccountFromPrivateKey(Account, Protocol):
3431
"""Only accounts that are initialized from a private key string are supported."""
3532

36-
def __init__(self, private_key: bytes):
37-
...
33+
def __init__(self, private_key: bytes): ...
3834

3935

4036
GenericMessage = TypeVar("GenericMessage", bound=AlephMessage)

0 commit comments

Comments
 (0)