turnkey-http 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {turnkey_http-0.2.0/src/turnkey_http.egg-info → turnkey_http-0.2.2}/PKG-INFO +5 -6
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/pyproject.toml +5 -6
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/src/turnkey_http/generated/client.py +17 -2
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/src/turnkey_http/version.py +1 -1
- {turnkey_http-0.2.0 → turnkey_http-0.2.2/src/turnkey_http.egg-info}/PKG-INFO +5 -6
- turnkey_http-0.2.2/src/turnkey_http.egg-info/requires.txt +9 -0
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/tests/test_activity_errors.py +63 -1
- turnkey_http-0.2.0/src/turnkey_http.egg-info/requires.txt +0 -8
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/LICENSE +0 -0
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/README.md +0 -0
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/setup.cfg +0 -0
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/src/turnkey_http/__init__.py +0 -0
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/src/turnkey_http.egg-info/SOURCES.txt +0 -0
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/src/turnkey_http.egg-info/dependency_links.txt +0 -0
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/src/turnkey_http.egg-info/top_level.txt +0 -0
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/tests/test_activities.py +0 -0
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/tests/test_queries.py +0 -0
- {turnkey_http-0.2.0 → turnkey_http-0.2.2}/tests/test_send_signed_request.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: turnkey-http
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: HTTP client for Turnkey API
|
|
5
5
|
Author-email: Turnkey <hello@turnkey.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -10,17 +10,16 @@ Project-URL: Documentation, https://github.com/tkhq/python-sdk/tree/main/package
|
|
|
10
10
|
Keywords: turnkey,api,http,client,sdk
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
15
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
-
Requires-Python: >=3.
|
|
16
|
+
Requires-Python: >=3.10
|
|
19
17
|
Description-Content-Type: text/markdown
|
|
20
18
|
License-File: LICENSE
|
|
21
19
|
Requires-Dist: requests>=2.31.0
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist: turnkey-
|
|
20
|
+
Requires-Dist: certifi>=2026.10.19
|
|
21
|
+
Requires-Dist: turnkey-api-key-stamper>=0.1.0
|
|
22
|
+
Requires-Dist: turnkey-sdk-types>=0.2.0
|
|
24
23
|
Provides-Extra: dev
|
|
25
24
|
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
26
25
|
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "turnkey-http"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.2"
|
|
8
8
|
description = "HTTP client for Turnkey API"
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
11
|
license = "Apache-2.0"
|
|
12
12
|
license-files = ["LICENSE"]
|
|
13
13
|
authors = [
|
|
@@ -17,16 +17,15 @@ keywords = ["turnkey", "api", "http", "client", "sdk"]
|
|
|
17
17
|
classifiers = [
|
|
18
18
|
"Intended Audience :: Developers",
|
|
19
19
|
"Programming Language :: Python :: 3",
|
|
20
|
-
"Programming Language :: Python :: 3.8",
|
|
21
|
-
"Programming Language :: Python :: 3.9",
|
|
22
20
|
"Programming Language :: Python :: 3.10",
|
|
23
21
|
"Programming Language :: Python :: 3.11",
|
|
24
22
|
"Programming Language :: Python :: 3.12",
|
|
25
23
|
]
|
|
26
24
|
dependencies = [
|
|
27
25
|
"requests>=2.31.0",
|
|
28
|
-
"
|
|
29
|
-
"turnkey-
|
|
26
|
+
"certifi>=2026.10.19",
|
|
27
|
+
"turnkey-api-key-stamper>=0.1.0",
|
|
28
|
+
"turnkey-sdk-types>=0.2.0",
|
|
30
29
|
]
|
|
31
30
|
|
|
32
31
|
[project.optional-dependencies]
|
|
@@ -147,6 +147,21 @@ class TurnkeyClient:
|
|
|
147
147
|
response_data = response.json()
|
|
148
148
|
return response_type(**response_data)
|
|
149
149
|
|
|
150
|
+
def _poll_body(self, activity: Any) -> GetActivityBody:
|
|
151
|
+
"""Build the get_activity body to poll an activity in its own organization.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
activity: Activity object with id and organizationId attributes.
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
GetActivityBody for the activity's organization. Falls back to the
|
|
158
|
+
client's default organization if the activity has none.
|
|
159
|
+
"""
|
|
160
|
+
organization_id = (
|
|
161
|
+
getattr(activity, "organizationId", None) or self.organization_id
|
|
162
|
+
)
|
|
163
|
+
return GetActivityBody(organizationId=organization_id, activityId=activity.id)
|
|
164
|
+
|
|
150
165
|
def _poll_for_completion(self, activity: Any) -> Any:
|
|
151
166
|
"""Poll until activity reaches terminal status.
|
|
152
167
|
|
|
@@ -162,7 +177,7 @@ class TurnkeyClient:
|
|
|
162
177
|
attempts = 0
|
|
163
178
|
while attempts < self.max_polling_retries:
|
|
164
179
|
time.sleep(self.polling_interval_ms / 1000.0)
|
|
165
|
-
poll_response = self.get_activity(
|
|
180
|
+
poll_response = self.get_activity(self._poll_body(activity))
|
|
166
181
|
activity = poll_response.activity
|
|
167
182
|
if activity.status in TERMINAL_ACTIVITY_STATUSES:
|
|
168
183
|
break
|
|
@@ -270,7 +285,7 @@ class TurnkeyClient:
|
|
|
270
285
|
if time.monotonic() >= deadline:
|
|
271
286
|
return activity
|
|
272
287
|
|
|
273
|
-
poll_response = self.get_activity(
|
|
288
|
+
poll_response = self.get_activity(self._poll_body(activity))
|
|
274
289
|
activity = poll_response.activity
|
|
275
290
|
status = getattr(activity.status, "value", activity.status)
|
|
276
291
|
if status != watched_status:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: turnkey-http
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: HTTP client for Turnkey API
|
|
5
5
|
Author-email: Turnkey <hello@turnkey.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -10,17 +10,16 @@ Project-URL: Documentation, https://github.com/tkhq/python-sdk/tree/main/package
|
|
|
10
10
|
Keywords: turnkey,api,http,client,sdk
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
15
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
-
Requires-Python: >=3.
|
|
16
|
+
Requires-Python: >=3.10
|
|
19
17
|
Description-Content-Type: text/markdown
|
|
20
18
|
License-File: LICENSE
|
|
21
19
|
Requires-Dist: requests>=2.31.0
|
|
22
|
-
Requires-Dist:
|
|
23
|
-
Requires-Dist: turnkey-
|
|
20
|
+
Requires-Dist: certifi>=2026.10.19
|
|
21
|
+
Requires-Dist: turnkey-api-key-stamper>=0.1.0
|
|
22
|
+
Requires-Dist: turnkey-sdk-types>=0.2.0
|
|
24
23
|
Provides-Extra: dev
|
|
25
24
|
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
26
25
|
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
@@ -5,6 +5,7 @@ credentials and make no network calls. They do not use the fixtures in
|
|
|
5
5
|
``conftest.py``.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
import json
|
|
8
9
|
from typing import Any, Dict, List, Optional
|
|
9
10
|
|
|
10
11
|
import pytest
|
|
@@ -25,6 +26,7 @@ from turnkey_http.generated.client import PollingConfig, TurnkeyClient
|
|
|
25
26
|
|
|
26
27
|
ACTIVITY_ID = "activity-123"
|
|
27
28
|
ORG_ID = "org-123"
|
|
29
|
+
SUB_ORG_ID = "sub-org-456"
|
|
28
30
|
|
|
29
31
|
|
|
30
32
|
class StubStamper:
|
|
@@ -49,10 +51,11 @@ def activity_payload(
|
|
|
49
51
|
result: Optional[Dict[str, Any]] = None,
|
|
50
52
|
failure: Optional[Dict[str, Any]] = None,
|
|
51
53
|
activity_type: str = "ACTIVITY_TYPE_CREATE_WALLET",
|
|
54
|
+
organization_id: str = ORG_ID,
|
|
52
55
|
) -> Dict[str, Any]:
|
|
53
56
|
activity: Dict[str, Any] = {
|
|
54
57
|
"id": ACTIVITY_ID,
|
|
55
|
-
"organizationId":
|
|
58
|
+
"organizationId": organization_id,
|
|
56
59
|
"status": status,
|
|
57
60
|
"type": activity_type,
|
|
58
61
|
"intent": {},
|
|
@@ -553,3 +556,62 @@ def test_raw_path_unpacks_versioned_result_key(client, mock_post):
|
|
|
553
556
|
|
|
554
557
|
assert payload["subOrganizationId"] == "sub-1"
|
|
555
558
|
assert payload["activity"]["status"] == "ACTIVITY_STATUS_COMPLETED"
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
def poll_bodies(calls: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
|
562
|
+
return [
|
|
563
|
+
json.loads(call["data"])
|
|
564
|
+
for call in calls
|
|
565
|
+
if call["url"].endswith("/public/v1/query/get_activity")
|
|
566
|
+
]
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
def create_sub_org_wallet(client: TurnkeyClient):
|
|
570
|
+
return client.create_wallet(
|
|
571
|
+
CreateWalletBody(organizationId=SUB_ORG_ID, walletName="w", accounts=[])
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
def completed_sub_org_wallet_payload() -> Dict[str, Any]:
|
|
576
|
+
return activity_payload(
|
|
577
|
+
"ACTIVITY_STATUS_COMPLETED",
|
|
578
|
+
result={"createWalletResult": {"walletId": "w-1", "addresses": ["0xabc"]}},
|
|
579
|
+
organization_id=SUB_ORG_ID,
|
|
580
|
+
)
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
def test_pending_poll_uses_activity_organization(client, mock_post):
|
|
584
|
+
calls = mock_post(
|
|
585
|
+
activity_payload("ACTIVITY_STATUS_PENDING", organization_id=SUB_ORG_ID),
|
|
586
|
+
completed_sub_org_wallet_payload(),
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
response = create_sub_org_wallet(client)
|
|
590
|
+
|
|
591
|
+
assert response.walletId == "w-1"
|
|
592
|
+
assert json.loads(calls[0]["data"])["organizationId"] == SUB_ORG_ID
|
|
593
|
+
bodies = poll_bodies(calls)
|
|
594
|
+
assert len(bodies) == 1
|
|
595
|
+
assert bodies[0] == {"organizationId": SUB_ORG_ID, "activityId": ACTIVITY_ID}
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
@pytest.mark.parametrize(
|
|
599
|
+
("status", "enable"),
|
|
600
|
+
[
|
|
601
|
+
("ACTIVITY_STATUS_AUTHENTICATORS_NEEDED", enable_mfa_polling),
|
|
602
|
+
("ACTIVITY_STATUS_CONSENSUS_NEEDED", enable_consensus_polling),
|
|
603
|
+
],
|
|
604
|
+
)
|
|
605
|
+
def test_approval_poll_uses_activity_organization(client, mock_post, status, enable):
|
|
606
|
+
calls = mock_post(
|
|
607
|
+
activity_payload(status, organization_id=SUB_ORG_ID),
|
|
608
|
+
completed_sub_org_wallet_payload(),
|
|
609
|
+
)
|
|
610
|
+
enable(client)
|
|
611
|
+
|
|
612
|
+
response = create_sub_org_wallet(client)
|
|
613
|
+
|
|
614
|
+
assert response.walletId == "w-1"
|
|
615
|
+
bodies = poll_bodies(calls)
|
|
616
|
+
assert len(bodies) == 1
|
|
617
|
+
assert bodies[0]["organizationId"] == SUB_ORG_ID
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|