Skip to content

Commit 7511ab1

Browse files
Release 0.15.0 (#89)
1 parent e6cd894 commit 7511ab1

23 files changed

+922
-31
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# CDP Python SDK Changelog
22

3-
## Unreleased
3+
## [0.15.0] - 2025-01-17
4+
5+
### Added
6+
7+
- Add `deploy_contract` method to `WalletAddress` and `Wallet` to deploy an arbitrary contract.
48

59
## [0.14.1] - 2025-01-17
610

cdp/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.14.1"
1+
__version__ = "0.15.0"

cdp/client/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
from cdp.client.models.broadcast_trade_request import BroadcastTradeRequest
6666
from cdp.client.models.broadcast_transfer_request import BroadcastTransferRequest
6767
from cdp.client.models.build_staking_operation_request import BuildStakingOperationRequest
68+
from cdp.client.models.compile_smart_contract_request import CompileSmartContractRequest
69+
from cdp.client.models.compiled_smart_contract import CompiledSmartContract
6870
from cdp.client.models.contract_event import ContractEvent
6971
from cdp.client.models.contract_event_list import ContractEventList
7072
from cdp.client.models.contract_invocation import ContractInvocation

cdp/client/api/smart_contracts_api.py

+276
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from pydantic import Field, StrictStr
2020
from typing import Optional
2121
from typing_extensions import Annotated
22+
from cdp.client.models.compile_smart_contract_request import CompileSmartContractRequest
23+
from cdp.client.models.compiled_smart_contract import CompiledSmartContract
2224
from cdp.client.models.create_smart_contract_request import CreateSmartContractRequest
2325
from cdp.client.models.deploy_smart_contract_request import DeploySmartContractRequest
2426
from cdp.client.models.read_contract_request import ReadContractRequest
@@ -46,6 +48,280 @@ def __init__(self, api_client=None) -> None:
4648
self.api_client = api_client
4749

4850

51+
@validate_call
52+
def compile_smart_contract(
53+
self,
54+
compile_smart_contract_request: CompileSmartContractRequest,
55+
_request_timeout: Union[
56+
None,
57+
Annotated[StrictFloat, Field(gt=0)],
58+
Tuple[
59+
Annotated[StrictFloat, Field(gt=0)],
60+
Annotated[StrictFloat, Field(gt=0)]
61+
]
62+
] = None,
63+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
64+
_content_type: Optional[StrictStr] = None,
65+
_headers: Optional[Dict[StrictStr, Any]] = None,
66+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
67+
) -> CompiledSmartContract:
68+
"""Compile a smart contract
69+
70+
Compile a smart contract
71+
72+
:param compile_smart_contract_request: (required)
73+
:type compile_smart_contract_request: CompileSmartContractRequest
74+
:param _request_timeout: timeout setting for this request. If one
75+
number provided, it will be total request
76+
timeout. It can also be a pair (tuple) of
77+
(connection, read) timeouts.
78+
:type _request_timeout: int, tuple(int, int), optional
79+
:param _request_auth: set to override the auth_settings for an a single
80+
request; this effectively ignores the
81+
authentication in the spec for a single request.
82+
:type _request_auth: dict, optional
83+
:param _content_type: force content-type for the request.
84+
:type _content_type: str, Optional
85+
:param _headers: set to override the headers for a single
86+
request; this effectively ignores the headers
87+
in the spec for a single request.
88+
:type _headers: dict, optional
89+
:param _host_index: set to override the host_index for a single
90+
request; this effectively ignores the host_index
91+
in the spec for a single request.
92+
:type _host_index: int, optional
93+
:return: Returns the result object.
94+
""" # noqa: E501
95+
96+
_param = self._compile_smart_contract_serialize(
97+
compile_smart_contract_request=compile_smart_contract_request,
98+
_request_auth=_request_auth,
99+
_content_type=_content_type,
100+
_headers=_headers,
101+
_host_index=_host_index
102+
)
103+
104+
_response_types_map: Dict[str, Optional[str]] = {
105+
'200': "CompiledSmartContract",
106+
}
107+
response_data = self.api_client.call_api(
108+
*_param,
109+
_request_timeout=_request_timeout
110+
)
111+
response_data.read()
112+
return self.api_client.response_deserialize(
113+
response_data=response_data,
114+
response_types_map=_response_types_map,
115+
).data
116+
117+
118+
@validate_call
119+
def compile_smart_contract_with_http_info(
120+
self,
121+
compile_smart_contract_request: CompileSmartContractRequest,
122+
_request_timeout: Union[
123+
None,
124+
Annotated[StrictFloat, Field(gt=0)],
125+
Tuple[
126+
Annotated[StrictFloat, Field(gt=0)],
127+
Annotated[StrictFloat, Field(gt=0)]
128+
]
129+
] = None,
130+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
131+
_content_type: Optional[StrictStr] = None,
132+
_headers: Optional[Dict[StrictStr, Any]] = None,
133+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
134+
) -> ApiResponse[CompiledSmartContract]:
135+
"""Compile a smart contract
136+
137+
Compile a smart contract
138+
139+
:param compile_smart_contract_request: (required)
140+
:type compile_smart_contract_request: CompileSmartContractRequest
141+
:param _request_timeout: timeout setting for this request. If one
142+
number provided, it will be total request
143+
timeout. It can also be a pair (tuple) of
144+
(connection, read) timeouts.
145+
:type _request_timeout: int, tuple(int, int), optional
146+
:param _request_auth: set to override the auth_settings for an a single
147+
request; this effectively ignores the
148+
authentication in the spec for a single request.
149+
:type _request_auth: dict, optional
150+
:param _content_type: force content-type for the request.
151+
:type _content_type: str, Optional
152+
:param _headers: set to override the headers for a single
153+
request; this effectively ignores the headers
154+
in the spec for a single request.
155+
:type _headers: dict, optional
156+
:param _host_index: set to override the host_index for a single
157+
request; this effectively ignores the host_index
158+
in the spec for a single request.
159+
:type _host_index: int, optional
160+
:return: Returns the result object.
161+
""" # noqa: E501
162+
163+
_param = self._compile_smart_contract_serialize(
164+
compile_smart_contract_request=compile_smart_contract_request,
165+
_request_auth=_request_auth,
166+
_content_type=_content_type,
167+
_headers=_headers,
168+
_host_index=_host_index
169+
)
170+
171+
_response_types_map: Dict[str, Optional[str]] = {
172+
'200': "CompiledSmartContract",
173+
}
174+
response_data = self.api_client.call_api(
175+
*_param,
176+
_request_timeout=_request_timeout
177+
)
178+
response_data.read()
179+
return self.api_client.response_deserialize(
180+
response_data=response_data,
181+
response_types_map=_response_types_map,
182+
)
183+
184+
185+
@validate_call
186+
def compile_smart_contract_without_preload_content(
187+
self,
188+
compile_smart_contract_request: CompileSmartContractRequest,
189+
_request_timeout: Union[
190+
None,
191+
Annotated[StrictFloat, Field(gt=0)],
192+
Tuple[
193+
Annotated[StrictFloat, Field(gt=0)],
194+
Annotated[StrictFloat, Field(gt=0)]
195+
]
196+
] = None,
197+
_request_auth: Optional[Dict[StrictStr, Any]] = None,
198+
_content_type: Optional[StrictStr] = None,
199+
_headers: Optional[Dict[StrictStr, Any]] = None,
200+
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
201+
) -> RESTResponseType:
202+
"""Compile a smart contract
203+
204+
Compile a smart contract
205+
206+
:param compile_smart_contract_request: (required)
207+
:type compile_smart_contract_request: CompileSmartContractRequest
208+
:param _request_timeout: timeout setting for this request. If one
209+
number provided, it will be total request
210+
timeout. It can also be a pair (tuple) of
211+
(connection, read) timeouts.
212+
:type _request_timeout: int, tuple(int, int), optional
213+
:param _request_auth: set to override the auth_settings for an a single
214+
request; this effectively ignores the
215+
authentication in the spec for a single request.
216+
:type _request_auth: dict, optional
217+
:param _content_type: force content-type for the request.
218+
:type _content_type: str, Optional
219+
:param _headers: set to override the headers for a single
220+
request; this effectively ignores the headers
221+
in the spec for a single request.
222+
:type _headers: dict, optional
223+
:param _host_index: set to override the host_index for a single
224+
request; this effectively ignores the host_index
225+
in the spec for a single request.
226+
:type _host_index: int, optional
227+
:return: Returns the result object.
228+
""" # noqa: E501
229+
230+
_param = self._compile_smart_contract_serialize(
231+
compile_smart_contract_request=compile_smart_contract_request,
232+
_request_auth=_request_auth,
233+
_content_type=_content_type,
234+
_headers=_headers,
235+
_host_index=_host_index
236+
)
237+
238+
_response_types_map: Dict[str, Optional[str]] = {
239+
'200': "CompiledSmartContract",
240+
}
241+
response_data = self.api_client.call_api(
242+
*_param,
243+
_request_timeout=_request_timeout
244+
)
245+
return response_data.response
246+
247+
248+
def _compile_smart_contract_serialize(
249+
self,
250+
compile_smart_contract_request,
251+
_request_auth,
252+
_content_type,
253+
_headers,
254+
_host_index,
255+
) -> RequestSerialized:
256+
257+
_host = None
258+
259+
_collection_formats: Dict[str, str] = {
260+
}
261+
262+
_path_params: Dict[str, str] = {}
263+
_query_params: List[Tuple[str, str]] = []
264+
_header_params: Dict[str, Optional[str]] = _headers or {}
265+
_form_params: List[Tuple[str, str]] = []
266+
_files: Dict[
267+
str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
268+
] = {}
269+
_body_params: Optional[bytes] = None
270+
271+
# process the path parameters
272+
# process the query parameters
273+
# process the header parameters
274+
# process the form parameters
275+
# process the body parameter
276+
if compile_smart_contract_request is not None:
277+
_body_params = compile_smart_contract_request
278+
279+
280+
# set the HTTP header `Accept`
281+
if 'Accept' not in _header_params:
282+
_header_params['Accept'] = self.api_client.select_header_accept(
283+
[
284+
'application/json'
285+
]
286+
)
287+
288+
# set the HTTP header `Content-Type`
289+
if _content_type:
290+
_header_params['Content-Type'] = _content_type
291+
else:
292+
_default_content_type = (
293+
self.api_client.select_header_content_type(
294+
[
295+
'application/json'
296+
]
297+
)
298+
)
299+
if _default_content_type is not None:
300+
_header_params['Content-Type'] = _default_content_type
301+
302+
# authentication setting
303+
_auth_settings: List[str] = [
304+
'apiKey'
305+
]
306+
307+
return self.api_client.param_serialize(
308+
method='POST',
309+
resource_path='/v1/smart_contracts/compile',
310+
path_params=_path_params,
311+
query_params=_query_params,
312+
header_params=_header_params,
313+
body=_body_params,
314+
post_params=_form_params,
315+
files=_files,
316+
auth_settings=_auth_settings,
317+
collection_formats=_collection_formats,
318+
_host=_host,
319+
_request_auth=_request_auth
320+
)
321+
322+
323+
324+
49325
@validate_call
50326
def create_smart_contract(
51327
self,

cdp/client/models/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
from cdp.client.models.broadcast_trade_request import BroadcastTradeRequest
3030
from cdp.client.models.broadcast_transfer_request import BroadcastTransferRequest
3131
from cdp.client.models.build_staking_operation_request import BuildStakingOperationRequest
32+
from cdp.client.models.compile_smart_contract_request import CompileSmartContractRequest
33+
from cdp.client.models.compiled_smart_contract import CompiledSmartContract
3234
from cdp.client.models.contract_event import ContractEvent
3335
from cdp.client.models.contract_event_list import ContractEventList
3436
from cdp.client.models.contract_invocation import ContractInvocation

0 commit comments

Comments
 (0)