Skip to content

Commit

Permalink
Missing chain field on auth
Browse files Browse the repository at this point in the history
  • Loading branch information
philogicae committed Oct 9, 2024
1 parent a636106 commit 580e591
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/aleph/sdk/client/vm_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
from urllib.parse import urlparse

import aiohttp
from aleph_message.models import ItemHash
from aleph_message.models import Chain, ItemHash
from eth_account.messages import encode_defunct
from jwcrypto import jwk

from aleph.sdk.chains.solana import SOLAccount
from aleph.sdk.types import Account
from aleph.sdk.utils import (
create_vm_control_payload,
Expand Down Expand Up @@ -36,11 +37,13 @@ def __init__(
self.account = account
self.ephemeral_key = jwk.JWK.generate(kty="EC", crv="P-256")
self.node_url = node_url.rstrip("/")
self.pubkey_payload = self._generate_pubkey_payload()
self.pubkey_payload = self._generate_pubkey_payload(
Chain.SOL if isinstance(account, SOLAccount) else Chain.ETH
)
self.pubkey_signature_header = ""
self.session = session or aiohttp.ClientSession()

def _generate_pubkey_payload(self) -> Dict[str, Any]:
def _generate_pubkey_payload(self, chain: Chain = Chain.ETH) -> Dict[str, Any]:
return {
"pubkey": json.loads(self.ephemeral_key.export_public()),
"alg": "ECDSA",
Expand All @@ -50,6 +53,7 @@ def _generate_pubkey_payload(self) -> Dict[str, Any]:
datetime.datetime.utcnow() + datetime.timedelta(days=1)
).isoformat()
+ "Z",
"chain": chain.value,
}

async def _generate_pubkey_signature_header(self) -> str:
Expand Down

0 comments on commit 580e591

Please sign in to comment.