Skip to content
Open
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: 4 additions & 0 deletions sdks/python/pmxt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
BuiltOrder,
CreateOrderParams,
TxPayload,
AuthNonceResponse,
AuthLoginResponse,
Position,
Balance,
MarketFilterCriteria,
Expand Down Expand Up @@ -243,6 +245,8 @@ def restart_server() -> None:
"BuiltOrder",
"CreateOrderParams",
"TxPayload",
"AuthNonceResponse",
"AuthLoginResponse",
"ExecutionPriceResult",
"Position",
"Balance",
Expand Down
6 changes: 4 additions & 2 deletions sdks/python/pmxt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
Order,
BuiltOrder,
Position,
AuthNonceResponse,
AuthLoginResponse,
Balance,
ExecutionPriceResult,
MarketFilterCriteria,
Expand Down Expand Up @@ -1306,7 +1308,7 @@ def load_markets(self, reload: bool = False) -> Dict[str, UnifiedMarket]:

# BEGIN GENERATED METHODS

def get_auth_nonce(self, wallet_address: str) -> Dict[str, Any]:
def get_auth_nonce(self, wallet_address: str) -> AuthNonceResponse:
try:
args = []
args.append(wallet_address)
Expand All @@ -1326,7 +1328,7 @@ def get_auth_nonce(self, wallet_address: str) -> Dict[str, Any]:
except ApiException as e:
raise self._parse_api_exception(e) from None

def login_with_signature(self, wallet_address: str, signature: str, nonce: str) -> Dict[str, Any]:
def login_with_signature(self, wallet_address: str, signature: str, nonce: str) -> AuthLoginResponse:
try:
args = []
args.append(wallet_address)
Expand Down
21 changes: 21 additions & 0 deletions sdks/python/pmxt/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,27 @@ class TxPayload(TypedDict):
value: str
chainId: int


class _AuthNonceRequired(TypedDict):
nonce: str
messageToSign: str


class AuthNonceResponse(_AuthNonceRequired, total=False):
"""Challenge returned by ``get_auth_nonce`` for the Web3 login flow."""
expiresAt: int


class _AuthLoginRequired(TypedDict):
apiKey: str
apiSecret: str


class AuthLoginResponse(_AuthLoginRequired, total=False):
"""Credentials returned by ``login_with_signature``."""
passphrase: str
expiresAt: int

@dataclass
class Position:
"""A current position in a market.
Expand Down
4 changes: 2 additions & 2 deletions sdks/python/scripts/generate-client-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ const TYPE_MAP = {
PaginatedMarketsResult: { pyType: 'PaginatedMarketsResult', converter: null, pattern: 'paginatedMarkets' },
PaginatedEventsResult: { pyType: 'PaginatedEventsResult', converter: null, pattern: 'paginatedEvents' },

AuthNonceResponse: { pyType: 'Dict[str, Any]', converter: null, pattern: 'raw' },
AuthLoginResponse: { pyType: 'Dict[str, Any]', converter: null, pattern: 'raw' },
AuthNonceResponse: { pyType: 'AuthNonceResponse', converter: null, pattern: 'raw' },
AuthLoginResponse: { pyType: 'AuthLoginResponse', converter: null, pattern: 'raw' },
};

// Parameter names that represent outcome IDs and should accept MarketOutcome.
Expand Down
14 changes: 14 additions & 0 deletions sdks/python/tests/test_public_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,17 @@ def fake_call_method(method_name, params=None):
assert by_id.id == "12345"
assert isinstance(by_slug, UnifiedEvent)
assert by_slug.slug == "example-event"


def test_auth_response_types_are_public_exports_and_used_by_client():
import pmxt
from pmxt.client import Exchange
from typing import get_type_hints

assert pmxt.AuthNonceResponse.__required_keys__ == {"nonce", "messageToSign"}
assert pmxt.AuthNonceResponse.__optional_keys__ == {"expiresAt"}
assert pmxt.AuthLoginResponse.__required_keys__ == {"apiKey", "apiSecret"}
assert pmxt.AuthLoginResponse.__optional_keys__ == {"passphrase", "expiresAt"}

assert get_type_hints(Exchange.get_auth_nonce)["return"] is pmxt.AuthNonceResponse
assert get_type_hints(Exchange.login_with_signature)["return"] is pmxt.AuthLoginResponse