dfns-sdk 0.0.0.dev0__py3-none-any.whl
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.
- dfns_sdk/__init__.py +24 -0
- dfns_sdk/_internal/__init__.py +5 -0
- dfns_sdk/_internal/http_client.py +395 -0
- dfns_sdk/auth.py +137 -0
- dfns_sdk/base_auth_api.py +129 -0
- dfns_sdk/client.py +81 -0
- dfns_sdk/delegated_client.py +97 -0
- dfns_sdk/generated/__init__.py +47 -0
- dfns_sdk/generated/agreements/__init__.py +7 -0
- dfns_sdk/generated/agreements/client.py +55 -0
- dfns_sdk/generated/agreements/delegated_client.py +95 -0
- dfns_sdk/generated/agreements/types.py +20 -0
- dfns_sdk/generated/allocations/__init__.py +7 -0
- dfns_sdk/generated/allocations/client.py +118 -0
- dfns_sdk/generated/allocations/delegated_client.py +187 -0
- dfns_sdk/generated/allocations/types.py +69 -0
- dfns_sdk/generated/auth/__init__.py +7 -0
- dfns_sdk/generated/auth/client.py +1215 -0
- dfns_sdk/generated/auth/delegated_client.py +1825 -0
- dfns_sdk/generated/auth/types.py +702 -0
- dfns_sdk/generated/exchanges/__init__.py +7 -0
- dfns_sdk/generated/exchanges/client.py +209 -0
- dfns_sdk/generated/exchanges/delegated_client.py +341 -0
- dfns_sdk/generated/exchanges/types.py +96 -0
- dfns_sdk/generated/fee_sponsors/__init__.py +7 -0
- dfns_sdk/generated/fee_sponsors/client.py +161 -0
- dfns_sdk/generated/fee_sponsors/delegated_client.py +287 -0
- dfns_sdk/generated/fee_sponsors/types.py +89 -0
- dfns_sdk/generated/keys/__init__.py +7 -0
- dfns_sdk/generated/keys/client.py +310 -0
- dfns_sdk/generated/keys/delegated_client.py +518 -0
- dfns_sdk/generated/keys/types.py +229 -0
- dfns_sdk/generated/networks/__init__.py +7 -0
- dfns_sdk/generated/networks/client.py +176 -0
- dfns_sdk/generated/networks/delegated_client.py +274 -0
- dfns_sdk/generated/networks/types.py +77 -0
- dfns_sdk/generated/permissions/__init__.py +7 -0
- dfns_sdk/generated/permissions/client.py +185 -0
- dfns_sdk/generated/permissions/delegated_client.py +344 -0
- dfns_sdk/generated/permissions/types.py +107 -0
- dfns_sdk/generated/policies/__init__.py +7 -0
- dfns_sdk/generated/policies/client.py +187 -0
- dfns_sdk/generated/policies/delegated_client.py +311 -0
- dfns_sdk/generated/policies/types.py +70 -0
- dfns_sdk/generated/signers/__init__.py +7 -0
- dfns_sdk/generated/signers/client.py +45 -0
- dfns_sdk/generated/signers/delegated_client.py +56 -0
- dfns_sdk/generated/signers/types.py +13 -0
- dfns_sdk/generated/staking/__init__.py +7 -0
- dfns_sdk/generated/staking/client.py +142 -0
- dfns_sdk/generated/staking/delegated_client.py +211 -0
- dfns_sdk/generated/staking/types.py +64 -0
- dfns_sdk/generated/swaps/__init__.py +7 -0
- dfns_sdk/generated/swaps/client.py +118 -0
- dfns_sdk/generated/swaps/delegated_client.py +157 -0
- dfns_sdk/generated/swaps/types.py +99 -0
- dfns_sdk/generated/wallets/__init__.py +7 -0
- dfns_sdk/generated/wallets/client.py +805 -0
- dfns_sdk/generated/wallets/delegated_client.py +1231 -0
- dfns_sdk/generated/wallets/types.py +534 -0
- dfns_sdk/generated/webhooks/__init__.py +7 -0
- dfns_sdk/generated/webhooks/client.py +193 -0
- dfns_sdk/generated/webhooks/delegated_client.py +320 -0
- dfns_sdk/generated/webhooks/types.py +101 -0
- dfns_sdk/types.py +72 -0
- dfns_sdk-0.0.0.dev0.dist-info/METADATA +191 -0
- dfns_sdk-0.0.0.dev0.dist-info/RECORD +69 -0
- dfns_sdk-0.0.0.dev0.dist-info/WHEEL +4 -0
- dfns_sdk-0.0.0.dev0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""Delegated client for the allocations domain."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from typing import Any, Literal, Optional, TypedDict, Union
|
|
5
|
+
|
|
6
|
+
from ..._internal import HttpClient
|
|
7
|
+
from ...base_auth_api import (
|
|
8
|
+
BaseAuthApi,
|
|
9
|
+
SignUserActionChallengeRequest,
|
|
10
|
+
UserActionChallengeResponse,
|
|
11
|
+
)
|
|
12
|
+
from . import types as T
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class DelegatedAllocationsClient:
|
|
16
|
+
"""
|
|
17
|
+
Delegated client for allocations operations.
|
|
18
|
+
|
|
19
|
+
This client separates user action signing into _init() and _complete() method pairs,
|
|
20
|
+
allowing external systems to handle the signing process.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, http_client: HttpClient):
|
|
24
|
+
self._http = http_client
|
|
25
|
+
|
|
26
|
+
def list_allocations(self, query: Optional[T.ListAllocationsQuery] = None) -> T.ListAllocationsResponse:
|
|
27
|
+
"""
|
|
28
|
+
List Allocations.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
query: Query parameters.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
T.ListAllocationsResponse: The API response.
|
|
35
|
+
"""
|
|
36
|
+
return self._http.request(
|
|
37
|
+
method="GET",
|
|
38
|
+
path="/allocations",
|
|
39
|
+
path_params={},
|
|
40
|
+
query_params=query,
|
|
41
|
+
body=None,
|
|
42
|
+
requires_signature=False,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
def create_allocation_init(self, body: dict[str, Any]) -> UserActionChallengeResponse:
|
|
46
|
+
"""
|
|
47
|
+
Initialize Create Allocation.
|
|
48
|
+
|
|
49
|
+
Creates a user action challenge for external signing.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
body: Request body.
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
UserActionChallengeResponse: The challenge to sign externally.
|
|
56
|
+
"""
|
|
57
|
+
path = "/allocations"
|
|
58
|
+
payload = json.dumps(body, separators=(",", ":")) if body else ""
|
|
59
|
+
|
|
60
|
+
return BaseAuthApi.create_user_action_challenge(
|
|
61
|
+
self._http,
|
|
62
|
+
user_action_http_method="POST",
|
|
63
|
+
user_action_http_path=path,
|
|
64
|
+
user_action_payload=payload,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
def create_allocation_complete(self, body: dict[str, Any], signed_challenge: SignUserActionChallengeRequest) -> T.CreateAllocationResponse:
|
|
68
|
+
"""
|
|
69
|
+
Complete Create Allocation.
|
|
70
|
+
|
|
71
|
+
Submits the signed challenge and makes the API request.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
body: Request body.
|
|
75
|
+
signed_challenge: The signed challenge from external signing.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
T.CreateAllocationResponse: The API response.
|
|
79
|
+
"""
|
|
80
|
+
user_action_result = BaseAuthApi.sign_user_action_challenge(
|
|
81
|
+
self._http, signed_challenge
|
|
82
|
+
)
|
|
83
|
+
user_action_token = user_action_result["userAction"]
|
|
84
|
+
|
|
85
|
+
return self._http.request_with_user_action(
|
|
86
|
+
method="POST",
|
|
87
|
+
path="/allocations",
|
|
88
|
+
path_params={},
|
|
89
|
+
query_params=None,
|
|
90
|
+
body=body,
|
|
91
|
+
user_action=user_action_token,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
def list_allocation_actions(self, allocation_id: str, query: Optional[T.ListAllocationActionsQuery] = None) -> T.ListAllocationActionsResponse:
|
|
95
|
+
"""
|
|
96
|
+
List Allocation Actions.
|
|
97
|
+
|
|
98
|
+
Retrieve the list of actions for a specific allocation.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
allocation_id: Unique identifier for the allocation investment.
|
|
102
|
+
query: Query parameters.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
T.ListAllocationActionsResponse: The API response.
|
|
106
|
+
"""
|
|
107
|
+
return self._http.request(
|
|
108
|
+
method="GET",
|
|
109
|
+
path="/allocations/{allocationId}/actions",
|
|
110
|
+
path_params={"allocationId": allocation_id},
|
|
111
|
+
query_params=query,
|
|
112
|
+
body=None,
|
|
113
|
+
requires_signature=False,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
def create_allocation_action_init(self, allocation_id: str, body: T.CreateAllocationActionRequest) -> UserActionChallengeResponse:
|
|
117
|
+
"""
|
|
118
|
+
Initialize Create Allocation Action.
|
|
119
|
+
|
|
120
|
+
Creates a user action challenge for external signing.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
allocation_id: Unique identifier for the allocation investment.
|
|
124
|
+
body: Request body.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
UserActionChallengeResponse: The challenge to sign externally.
|
|
128
|
+
"""
|
|
129
|
+
path = "/allocations/{allocationId}/actions"
|
|
130
|
+
path = path.replace("{allocationId}", str(allocation_id))
|
|
131
|
+
payload = json.dumps(body, separators=(",", ":")) if body else ""
|
|
132
|
+
|
|
133
|
+
return BaseAuthApi.create_user_action_challenge(
|
|
134
|
+
self._http,
|
|
135
|
+
user_action_http_method="POST",
|
|
136
|
+
user_action_http_path=path,
|
|
137
|
+
user_action_payload=payload,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
def create_allocation_action_complete(self, allocation_id: str, body: T.CreateAllocationActionRequest, signed_challenge: SignUserActionChallengeRequest) -> T.CreateAllocationActionResponse:
|
|
141
|
+
"""
|
|
142
|
+
Complete Create Allocation Action.
|
|
143
|
+
|
|
144
|
+
Submits the signed challenge and makes the API request.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
allocation_id: Unique identifier for the allocation investment.
|
|
148
|
+
body: Request body.
|
|
149
|
+
signed_challenge: The signed challenge from external signing.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
T.CreateAllocationActionResponse: The API response.
|
|
153
|
+
"""
|
|
154
|
+
user_action_result = BaseAuthApi.sign_user_action_challenge(
|
|
155
|
+
self._http, signed_challenge
|
|
156
|
+
)
|
|
157
|
+
user_action_token = user_action_result["userAction"]
|
|
158
|
+
|
|
159
|
+
return self._http.request_with_user_action(
|
|
160
|
+
method="POST",
|
|
161
|
+
path="/allocations/{allocationId}/actions",
|
|
162
|
+
path_params={"allocationId": allocation_id},
|
|
163
|
+
query_params=None,
|
|
164
|
+
body=body,
|
|
165
|
+
user_action=user_action_token,
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
def get_allocation(self, allocation_id: str) -> T.GetAllocationResponse:
|
|
169
|
+
"""
|
|
170
|
+
Get Allocation.
|
|
171
|
+
|
|
172
|
+
Retrieve the details of a specific allocation.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
allocation_id: Unique identifier for the allocation investment.
|
|
176
|
+
|
|
177
|
+
Returns:
|
|
178
|
+
T.GetAllocationResponse: The API response.
|
|
179
|
+
"""
|
|
180
|
+
return self._http.request(
|
|
181
|
+
method="GET",
|
|
182
|
+
path="/allocations/{allocationId}",
|
|
183
|
+
path_params={"allocationId": allocation_id},
|
|
184
|
+
query_params=None,
|
|
185
|
+
body=None,
|
|
186
|
+
requires_signature=False,
|
|
187
|
+
)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Types for the allocations domain."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Literal, NotRequired, Optional, TypedDict, Union
|
|
4
|
+
|
|
5
|
+
class ListAllocationsResponse(TypedDict, total=False):
|
|
6
|
+
"""listAllocations response."""
|
|
7
|
+
|
|
8
|
+
items: list[TypedDict]
|
|
9
|
+
next_page_token: NotRequired[str]
|
|
10
|
+
|
|
11
|
+
class ListAllocationsQuery(TypedDict, total=False):
|
|
12
|
+
"""listAllocations query parameters."""
|
|
13
|
+
|
|
14
|
+
limit: NotRequired[int]
|
|
15
|
+
pagination_token: NotRequired[str]
|
|
16
|
+
|
|
17
|
+
class CreateAllocationResponse(TypedDict, total=False):
|
|
18
|
+
"""createAllocation response."""
|
|
19
|
+
|
|
20
|
+
id: str
|
|
21
|
+
wallet_id: str
|
|
22
|
+
protocol: Literal["0fns"]
|
|
23
|
+
amount: TypedDict
|
|
24
|
+
rewards: TypedDict
|
|
25
|
+
date_created: str
|
|
26
|
+
actions: list[TypedDict]
|
|
27
|
+
|
|
28
|
+
class ListAllocationActionsResponse(TypedDict, total=False):
|
|
29
|
+
"""listAllocationActions response."""
|
|
30
|
+
|
|
31
|
+
items: list[TypedDict]
|
|
32
|
+
next_page_token: NotRequired[str]
|
|
33
|
+
|
|
34
|
+
class ListAllocationActionsQuery(TypedDict, total=False):
|
|
35
|
+
"""listAllocationActions query parameters."""
|
|
36
|
+
|
|
37
|
+
limit: NotRequired[int]
|
|
38
|
+
pagination_token: NotRequired[str]
|
|
39
|
+
|
|
40
|
+
class CreateAllocationActionRequest(TypedDict, total=False):
|
|
41
|
+
"""createAllocationAction request body."""
|
|
42
|
+
|
|
43
|
+
kind: Literal["Deposit", "Withdraw"]
|
|
44
|
+
external_id: NotRequired[str]
|
|
45
|
+
source_asset: TypedDict
|
|
46
|
+
target_asset: TypedDict
|
|
47
|
+
slippage_bps: float
|
|
48
|
+
|
|
49
|
+
class CreateAllocationActionResponse(TypedDict, total=False):
|
|
50
|
+
"""createAllocationAction response."""
|
|
51
|
+
|
|
52
|
+
id: str
|
|
53
|
+
wallet_id: str
|
|
54
|
+
protocol: Literal["0fns"]
|
|
55
|
+
amount: TypedDict
|
|
56
|
+
rewards: TypedDict
|
|
57
|
+
date_created: str
|
|
58
|
+
actions: list[TypedDict]
|
|
59
|
+
|
|
60
|
+
class GetAllocationResponse(TypedDict, total=False):
|
|
61
|
+
"""getAllocation response."""
|
|
62
|
+
|
|
63
|
+
id: str
|
|
64
|
+
wallet_id: str
|
|
65
|
+
protocol: Literal["0fns"]
|
|
66
|
+
amount: TypedDict
|
|
67
|
+
rewards: TypedDict
|
|
68
|
+
date_created: str
|
|
69
|
+
actions: list[TypedDict]
|