diff --git a/CHANGELOG.md b/CHANGELOG.md index cf8ab2d..29ed4fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # CDP Python SDK Changelog +## [0.17.0] - 2025-02-11 + +### Added + +- Add `broadcast_external_transaction` to `Address` class. + + ## [0.16.0] - 2025-01-28 ### Added diff --git a/cdp/address.py b/cdp/address.py index c3e848f..9ffbb35 100644 --- a/cdp/address.py +++ b/cdp/address.py @@ -6,6 +6,12 @@ from cdp.balance import Balance from cdp.balance_map import BalanceMap from cdp.cdp import Cdp +from cdp.client.models.broadcast_external_transaction200_response import ( + BroadcastExternalTransaction200Response, +) +from cdp.client.models.broadcast_external_transaction_request import ( + BroadcastExternalTransactionRequest, +) from cdp.faucet_transaction import FaucetTransaction from cdp.historical_balance import HistoricalBalance from cdp.transaction import Transaction @@ -151,6 +157,31 @@ def reputation(self) -> AddressReputation: self._reputation = AddressReputation(response) return self._reputation + def broadcast_external_transaction( + self, signed_payload: str + ) -> BroadcastExternalTransaction200Response: + """Broadcast an external transaction given a signed payload. + + Args: + signed_payload (str): The signed payload of the transaction to be broadcasted. + + Returns: + BroadcastExternalTransaction200Response: The response from the broadcasted transaction. + + Raises: + Exception: If there's an error broadcasting the transaction. + + """ + broadcast_external_transaction_request = BroadcastExternalTransactionRequest( + signed_payload=signed_payload + ) + + return Cdp.api_clients.external_addresses.broadcast_external_transaction( + network_id=self.network_id, + address_id=self.address_id, + broadcast_external_transaction_request=broadcast_external_transaction_request, + ) + def __str__(self) -> str: """Return a string representation of the Address.""" return f"Address: (address_id: {self.address_id}, network_id: {self.network_id})" diff --git a/cdp/client/__init__.py b/cdp/client/__init__.py index 706cc91..1eac2d4 100644 --- a/cdp/client/__init__.py +++ b/cdp/client/__init__.py @@ -30,6 +30,7 @@ from cdp.client.api.reputation_api import ReputationApi from cdp.client.api.server_signers_api import ServerSignersApi from cdp.client.api.smart_contracts_api import SmartContractsApi +from cdp.client.api.smart_wallets_api import SmartWalletsApi from cdp.client.api.stake_api import StakeApi from cdp.client.api.trades_api import TradesApi from cdp.client.api.transaction_history_api import TransactionHistoryApi @@ -60,11 +61,15 @@ from cdp.client.models.asset import Asset from cdp.client.models.balance import Balance from cdp.client.models.broadcast_contract_invocation_request import BroadcastContractInvocationRequest +from cdp.client.models.broadcast_external_transaction200_response import BroadcastExternalTransaction200Response +from cdp.client.models.broadcast_external_transaction_request import BroadcastExternalTransactionRequest from cdp.client.models.broadcast_external_transfer_request import BroadcastExternalTransferRequest from cdp.client.models.broadcast_staking_operation_request import BroadcastStakingOperationRequest from cdp.client.models.broadcast_trade_request import BroadcastTradeRequest from cdp.client.models.broadcast_transfer_request import BroadcastTransferRequest +from cdp.client.models.broadcast_user_operation_request import BroadcastUserOperationRequest from cdp.client.models.build_staking_operation_request import BuildStakingOperationRequest +from cdp.client.models.call import Call from cdp.client.models.compile_smart_contract_request import CompileSmartContractRequest from cdp.client.models.compiled_smart_contract import CompiledSmartContract from cdp.client.models.contract_event import ContractEvent @@ -79,9 +84,11 @@ from cdp.client.models.create_payload_signature_request import CreatePayloadSignatureRequest from cdp.client.models.create_server_signer_request import CreateServerSignerRequest from cdp.client.models.create_smart_contract_request import CreateSmartContractRequest +from cdp.client.models.create_smart_wallet_request import CreateSmartWalletRequest from cdp.client.models.create_staking_operation_request import CreateStakingOperationRequest from cdp.client.models.create_trade_request import CreateTradeRequest from cdp.client.models.create_transfer_request import CreateTransferRequest +from cdp.client.models.create_user_operation_request import CreateUserOperationRequest from cdp.client.models.create_wallet_request import CreateWalletRequest from cdp.client.models.create_wallet_request_wallet import CreateWalletRequestWallet from cdp.client.models.create_wallet_webhook_request import CreateWalletWebhookRequest @@ -134,6 +141,8 @@ from cdp.client.models.smart_contract_list import SmartContractList from cdp.client.models.smart_contract_options import SmartContractOptions from cdp.client.models.smart_contract_type import SmartContractType +from cdp.client.models.smart_wallet import SmartWallet +from cdp.client.models.smart_wallet_list import SmartWalletList from cdp.client.models.solidity_value import SolidityValue from cdp.client.models.sponsored_send import SponsoredSend from cdp.client.models.staking_balance import StakingBalance @@ -156,6 +165,7 @@ from cdp.client.models.update_smart_contract_request import UpdateSmartContractRequest from cdp.client.models.update_webhook_request import UpdateWebhookRequest from cdp.client.models.user import User +from cdp.client.models.user_operation import UserOperation from cdp.client.models.validator import Validator from cdp.client.models.validator_details import ValidatorDetails from cdp.client.models.validator_list import ValidatorList @@ -168,4 +178,5 @@ from cdp.client.models.webhook_event_type_filter import WebhookEventTypeFilter from cdp.client.models.webhook_list import WebhookList from cdp.client.models.webhook_smart_contract_event_filter import WebhookSmartContractEventFilter +from cdp.client.models.webhook_status import WebhookStatus from cdp.client.models.webhook_wallet_activity_filter import WebhookWalletActivityFilter diff --git a/cdp/client/api/__init__.py b/cdp/client/api/__init__.py index 09e4751..adccfb8 100644 --- a/cdp/client/api/__init__.py +++ b/cdp/client/api/__init__.py @@ -14,6 +14,7 @@ from cdp.client.api.reputation_api import ReputationApi from cdp.client.api.server_signers_api import ServerSignersApi from cdp.client.api.smart_contracts_api import SmartContractsApi +from cdp.client.api.smart_wallets_api import SmartWalletsApi from cdp.client.api.stake_api import StakeApi from cdp.client.api.trades_api import TradesApi from cdp.client.api.transaction_history_api import TransactionHistoryApi diff --git a/cdp/client/api/external_addresses_api.py b/cdp/client/api/external_addresses_api.py index 18becfb..703b5ba 100644 --- a/cdp/client/api/external_addresses_api.py +++ b/cdp/client/api/external_addresses_api.py @@ -21,6 +21,8 @@ from typing_extensions import Annotated from cdp.client.models.address_balance_list import AddressBalanceList from cdp.client.models.balance import Balance +from cdp.client.models.broadcast_external_transaction200_response import BroadcastExternalTransaction200Response +from cdp.client.models.broadcast_external_transaction_request import BroadcastExternalTransactionRequest from cdp.client.models.broadcast_external_transfer_request import BroadcastExternalTransferRequest from cdp.client.models.create_external_transfer_request import CreateExternalTransferRequest from cdp.client.models.faucet_transaction import FaucetTransaction @@ -44,6 +46,311 @@ def __init__(self, api_client=None) -> None: self.api_client = api_client + @validate_call + def broadcast_external_transaction( + self, + network_id: Annotated[StrictStr, Field(description="The ID of the network the external address belongs to.")], + address_id: Annotated[StrictStr, Field(description="The onchain address of the transaction sender.")], + broadcast_external_transaction_request: BroadcastExternalTransactionRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> BroadcastExternalTransaction200Response: + """Broadcast an arbitrary transaction. + + Broadcast an arbitrary transaction to the node constructed and signed by an external address. + + :param network_id: The ID of the network the external address belongs to. (required) + :type network_id: str + :param address_id: The onchain address of the transaction sender. (required) + :type address_id: str + :param broadcast_external_transaction_request: (required) + :type broadcast_external_transaction_request: BroadcastExternalTransactionRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._broadcast_external_transaction_serialize( + network_id=network_id, + address_id=address_id, + broadcast_external_transaction_request=broadcast_external_transaction_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "BroadcastExternalTransaction200Response", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def broadcast_external_transaction_with_http_info( + self, + network_id: Annotated[StrictStr, Field(description="The ID of the network the external address belongs to.")], + address_id: Annotated[StrictStr, Field(description="The onchain address of the transaction sender.")], + broadcast_external_transaction_request: BroadcastExternalTransactionRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[BroadcastExternalTransaction200Response]: + """Broadcast an arbitrary transaction. + + Broadcast an arbitrary transaction to the node constructed and signed by an external address. + + :param network_id: The ID of the network the external address belongs to. (required) + :type network_id: str + :param address_id: The onchain address of the transaction sender. (required) + :type address_id: str + :param broadcast_external_transaction_request: (required) + :type broadcast_external_transaction_request: BroadcastExternalTransactionRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._broadcast_external_transaction_serialize( + network_id=network_id, + address_id=address_id, + broadcast_external_transaction_request=broadcast_external_transaction_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "BroadcastExternalTransaction200Response", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def broadcast_external_transaction_without_preload_content( + self, + network_id: Annotated[StrictStr, Field(description="The ID of the network the external address belongs to.")], + address_id: Annotated[StrictStr, Field(description="The onchain address of the transaction sender.")], + broadcast_external_transaction_request: BroadcastExternalTransactionRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Broadcast an arbitrary transaction. + + Broadcast an arbitrary transaction to the node constructed and signed by an external address. + + :param network_id: The ID of the network the external address belongs to. (required) + :type network_id: str + :param address_id: The onchain address of the transaction sender. (required) + :type address_id: str + :param broadcast_external_transaction_request: (required) + :type broadcast_external_transaction_request: BroadcastExternalTransactionRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._broadcast_external_transaction_serialize( + network_id=network_id, + address_id=address_id, + broadcast_external_transaction_request=broadcast_external_transaction_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "BroadcastExternalTransaction200Response", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _broadcast_external_transaction_serialize( + self, + network_id, + address_id, + broadcast_external_transaction_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if network_id is not None: + _path_params['network_id'] = network_id + if address_id is not None: + _path_params['address_id'] = address_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if broadcast_external_transaction_request is not None: + _body_params = broadcast_external_transaction_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'apiKey', + 'session' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/v1/networks/{network_id}/addresses/{address_id}/transactions', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def broadcast_external_transfer( self, diff --git a/cdp/client/api/smart_wallets_api.py b/cdp/client/api/smart_wallets_api.py new file mode 100644 index 0000000..b240b0a --- /dev/null +++ b/cdp/client/api/smart_wallets_api.py @@ -0,0 +1,1746 @@ +# coding: utf-8 + +""" + Coinbase Platform API + + This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + + The version of the OpenAPI document: 0.0.1-alpha + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictInt, StrictStr +from typing import Optional +from typing_extensions import Annotated +from cdp.client.models.broadcast_user_operation_request import BroadcastUserOperationRequest +from cdp.client.models.create_smart_wallet_request import CreateSmartWalletRequest +from cdp.client.models.create_user_operation_request import CreateUserOperationRequest +from cdp.client.models.smart_wallet import SmartWallet +from cdp.client.models.smart_wallet_list import SmartWalletList +from cdp.client.models.user_operation import UserOperation + +from cdp.client.api_client import ApiClient, RequestSerialized +from cdp.client.api_response import ApiResponse +from cdp.client.rest import RESTResponseType + + +class SmartWalletsApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def broadcast_user_operation( + self, + smart_wallet_address: Annotated[StrictStr, Field(description="The address of the smart wallet to broadcast the user operation from.")], + user_operation_id: Annotated[StrictStr, Field(description="The ID of the user operation to broadcast.")], + broadcast_user_operation_request: Optional[BroadcastUserOperationRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> UserOperation: + """Broadcast a user operation + + Broadcast a user operation + + :param smart_wallet_address: The address of the smart wallet to broadcast the user operation from. (required) + :type smart_wallet_address: str + :param user_operation_id: The ID of the user operation to broadcast. (required) + :type user_operation_id: str + :param broadcast_user_operation_request: + :type broadcast_user_operation_request: BroadcastUserOperationRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._broadcast_user_operation_serialize( + smart_wallet_address=smart_wallet_address, + user_operation_id=user_operation_id, + broadcast_user_operation_request=broadcast_user_operation_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserOperation", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def broadcast_user_operation_with_http_info( + self, + smart_wallet_address: Annotated[StrictStr, Field(description="The address of the smart wallet to broadcast the user operation from.")], + user_operation_id: Annotated[StrictStr, Field(description="The ID of the user operation to broadcast.")], + broadcast_user_operation_request: Optional[BroadcastUserOperationRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[UserOperation]: + """Broadcast a user operation + + Broadcast a user operation + + :param smart_wallet_address: The address of the smart wallet to broadcast the user operation from. (required) + :type smart_wallet_address: str + :param user_operation_id: The ID of the user operation to broadcast. (required) + :type user_operation_id: str + :param broadcast_user_operation_request: + :type broadcast_user_operation_request: BroadcastUserOperationRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._broadcast_user_operation_serialize( + smart_wallet_address=smart_wallet_address, + user_operation_id=user_operation_id, + broadcast_user_operation_request=broadcast_user_operation_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserOperation", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def broadcast_user_operation_without_preload_content( + self, + smart_wallet_address: Annotated[StrictStr, Field(description="The address of the smart wallet to broadcast the user operation from.")], + user_operation_id: Annotated[StrictStr, Field(description="The ID of the user operation to broadcast.")], + broadcast_user_operation_request: Optional[BroadcastUserOperationRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Broadcast a user operation + + Broadcast a user operation + + :param smart_wallet_address: The address of the smart wallet to broadcast the user operation from. (required) + :type smart_wallet_address: str + :param user_operation_id: The ID of the user operation to broadcast. (required) + :type user_operation_id: str + :param broadcast_user_operation_request: + :type broadcast_user_operation_request: BroadcastUserOperationRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._broadcast_user_operation_serialize( + smart_wallet_address=smart_wallet_address, + user_operation_id=user_operation_id, + broadcast_user_operation_request=broadcast_user_operation_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserOperation", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _broadcast_user_operation_serialize( + self, + smart_wallet_address, + user_operation_id, + broadcast_user_operation_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if smart_wallet_address is not None: + _path_params['smart_wallet_address'] = smart_wallet_address + if user_operation_id is not None: + _path_params['user_operation_id'] = user_operation_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if broadcast_user_operation_request is not None: + _body_params = broadcast_user_operation_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'apiKey' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/v1/smart_wallets/{smart_wallet_address}/user_operations/{user_operation_id}/broadcast', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def create_smart_wallet( + self, + create_smart_wallet_request: Optional[CreateSmartWalletRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> SmartWallet: + """Create a new smart wallet + + Create a new smart wallet, not scoped to a given network. + + :param create_smart_wallet_request: + :type create_smart_wallet_request: CreateSmartWalletRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_smart_wallet_serialize( + create_smart_wallet_request=create_smart_wallet_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SmartWallet", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def create_smart_wallet_with_http_info( + self, + create_smart_wallet_request: Optional[CreateSmartWalletRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[SmartWallet]: + """Create a new smart wallet + + Create a new smart wallet, not scoped to a given network. + + :param create_smart_wallet_request: + :type create_smart_wallet_request: CreateSmartWalletRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_smart_wallet_serialize( + create_smart_wallet_request=create_smart_wallet_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SmartWallet", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def create_smart_wallet_without_preload_content( + self, + create_smart_wallet_request: Optional[CreateSmartWalletRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create a new smart wallet + + Create a new smart wallet, not scoped to a given network. + + :param create_smart_wallet_request: + :type create_smart_wallet_request: CreateSmartWalletRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_smart_wallet_serialize( + create_smart_wallet_request=create_smart_wallet_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SmartWallet", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _create_smart_wallet_serialize( + self, + create_smart_wallet_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_smart_wallet_request is not None: + _body_params = create_smart_wallet_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'apiKey' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/v1/smart_wallets', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def create_user_operation( + self, + smart_wallet_address: Annotated[StrictStr, Field(description="The address of the smart wallet to create the user operation on.")], + network_id: Annotated[StrictStr, Field(description="The ID of the network to create the user operation on.")], + create_user_operation_request: Optional[CreateUserOperationRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> UserOperation: + """Create a new user operation + + Create a new user operation on a smart wallet. + + :param smart_wallet_address: The address of the smart wallet to create the user operation on. (required) + :type smart_wallet_address: str + :param network_id: The ID of the network to create the user operation on. (required) + :type network_id: str + :param create_user_operation_request: + :type create_user_operation_request: CreateUserOperationRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_user_operation_serialize( + smart_wallet_address=smart_wallet_address, + network_id=network_id, + create_user_operation_request=create_user_operation_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserOperation", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def create_user_operation_with_http_info( + self, + smart_wallet_address: Annotated[StrictStr, Field(description="The address of the smart wallet to create the user operation on.")], + network_id: Annotated[StrictStr, Field(description="The ID of the network to create the user operation on.")], + create_user_operation_request: Optional[CreateUserOperationRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[UserOperation]: + """Create a new user operation + + Create a new user operation on a smart wallet. + + :param smart_wallet_address: The address of the smart wallet to create the user operation on. (required) + :type smart_wallet_address: str + :param network_id: The ID of the network to create the user operation on. (required) + :type network_id: str + :param create_user_operation_request: + :type create_user_operation_request: CreateUserOperationRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_user_operation_serialize( + smart_wallet_address=smart_wallet_address, + network_id=network_id, + create_user_operation_request=create_user_operation_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserOperation", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def create_user_operation_without_preload_content( + self, + smart_wallet_address: Annotated[StrictStr, Field(description="The address of the smart wallet to create the user operation on.")], + network_id: Annotated[StrictStr, Field(description="The ID of the network to create the user operation on.")], + create_user_operation_request: Optional[CreateUserOperationRequest] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create a new user operation + + Create a new user operation on a smart wallet. + + :param smart_wallet_address: The address of the smart wallet to create the user operation on. (required) + :type smart_wallet_address: str + :param network_id: The ID of the network to create the user operation on. (required) + :type network_id: str + :param create_user_operation_request: + :type create_user_operation_request: CreateUserOperationRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._create_user_operation_serialize( + smart_wallet_address=smart_wallet_address, + network_id=network_id, + create_user_operation_request=create_user_operation_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserOperation", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _create_user_operation_serialize( + self, + smart_wallet_address, + network_id, + create_user_operation_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if smart_wallet_address is not None: + _path_params['smart_wallet_address'] = smart_wallet_address + if network_id is not None: + _path_params['network_id'] = network_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if create_user_operation_request is not None: + _body_params = create_user_operation_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'apiKey' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/v1/smart_wallets/{smart_wallet_address}/networks/{network_id}/user_operations', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_smart_wallet( + self, + smart_wallet_address: Annotated[StrictStr, Field(description="The address of that smart wallet to fetch.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> SmartWallet: + """Get smart wallet by address + + Get smart wallet + + :param smart_wallet_address: The address of that smart wallet to fetch. (required) + :type smart_wallet_address: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_smart_wallet_serialize( + smart_wallet_address=smart_wallet_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SmartWallet", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_smart_wallet_with_http_info( + self, + smart_wallet_address: Annotated[StrictStr, Field(description="The address of that smart wallet to fetch.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[SmartWallet]: + """Get smart wallet by address + + Get smart wallet + + :param smart_wallet_address: The address of that smart wallet to fetch. (required) + :type smart_wallet_address: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_smart_wallet_serialize( + smart_wallet_address=smart_wallet_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SmartWallet", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_smart_wallet_without_preload_content( + self, + smart_wallet_address: Annotated[StrictStr, Field(description="The address of that smart wallet to fetch.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get smart wallet by address + + Get smart wallet + + :param smart_wallet_address: The address of that smart wallet to fetch. (required) + :type smart_wallet_address: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_smart_wallet_serialize( + smart_wallet_address=smart_wallet_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SmartWallet", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_smart_wallet_serialize( + self, + smart_wallet_address, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if smart_wallet_address is not None: + _path_params['smart_wallet_address'] = smart_wallet_address + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'apiKey', + 'session' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/smart_wallets/{smart_wallet_address}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_user_operation( + self, + smart_wallet_address: Annotated[StrictStr, Field(description="The address of the smart wallet the user operation belongs to.")], + user_operation_id: Annotated[StrictStr, Field(description="The ID of the user operation to fetch.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> UserOperation: + """Get user operation + + Get user operation + + :param smart_wallet_address: The address of the smart wallet the user operation belongs to. (required) + :type smart_wallet_address: str + :param user_operation_id: The ID of the user operation to fetch. (required) + :type user_operation_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_user_operation_serialize( + smart_wallet_address=smart_wallet_address, + user_operation_id=user_operation_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserOperation", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_user_operation_with_http_info( + self, + smart_wallet_address: Annotated[StrictStr, Field(description="The address of the smart wallet the user operation belongs to.")], + user_operation_id: Annotated[StrictStr, Field(description="The ID of the user operation to fetch.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[UserOperation]: + """Get user operation + + Get user operation + + :param smart_wallet_address: The address of the smart wallet the user operation belongs to. (required) + :type smart_wallet_address: str + :param user_operation_id: The ID of the user operation to fetch. (required) + :type user_operation_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_user_operation_serialize( + smart_wallet_address=smart_wallet_address, + user_operation_id=user_operation_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserOperation", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_user_operation_without_preload_content( + self, + smart_wallet_address: Annotated[StrictStr, Field(description="The address of the smart wallet the user operation belongs to.")], + user_operation_id: Annotated[StrictStr, Field(description="The ID of the user operation to fetch.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get user operation + + Get user operation + + :param smart_wallet_address: The address of the smart wallet the user operation belongs to. (required) + :type smart_wallet_address: str + :param user_operation_id: The ID of the user operation to fetch. (required) + :type user_operation_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_user_operation_serialize( + smart_wallet_address=smart_wallet_address, + user_operation_id=user_operation_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "UserOperation", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_user_operation_serialize( + self, + smart_wallet_address, + user_operation_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if smart_wallet_address is not None: + _path_params['smart_wallet_address'] = smart_wallet_address + if user_operation_id is not None: + _path_params['user_operation_id'] = user_operation_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'apiKey', + 'session' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/smart_wallets/{smart_wallet_address}/user_operations/{user_operation_id}', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def list_smart_wallets( + self, + limit: Annotated[Optional[StrictInt], Field(description="A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.")] = None, + page: Annotated[Optional[Annotated[str, Field(strict=True, max_length=5000)]], Field(description="A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> SmartWalletList: + """List smart wallets + + List smart wallets + + :param limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. + :type limit: int + :param page: A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + :type page: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._list_smart_wallets_serialize( + limit=limit, + page=page, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SmartWalletList", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def list_smart_wallets_with_http_info( + self, + limit: Annotated[Optional[StrictInt], Field(description="A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.")] = None, + page: Annotated[Optional[Annotated[str, Field(strict=True, max_length=5000)]], Field(description="A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[SmartWalletList]: + """List smart wallets + + List smart wallets + + :param limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. + :type limit: int + :param page: A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + :type page: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._list_smart_wallets_serialize( + limit=limit, + page=page, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SmartWalletList", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def list_smart_wallets_without_preload_content( + self, + limit: Annotated[Optional[StrictInt], Field(description="A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.")] = None, + page: Annotated[Optional[Annotated[str, Field(strict=True, max_length=5000)]], Field(description="A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List smart wallets + + List smart wallets + + :param limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. + :type limit: int + :param page: A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + :type page: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._list_smart_wallets_serialize( + limit=limit, + page=page, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "SmartWalletList", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _list_smart_wallets_serialize( + self, + limit, + page, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if limit is not None: + + _query_params.append(('limit', limit)) + + if page is not None: + + _query_params.append(('page', page)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'apiKey', + 'session' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v1/smart_wallets', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/cdp/client/api_client.py b/cdp/client/api_client.py index 82d3c54..a598883 100644 --- a/cdp/client/api_client.py +++ b/cdp/client/api_client.py @@ -517,7 +517,7 @@ def parameters_to_url_query(self, params, collection_formats): if k in collection_formats: collection_format = collection_formats[k] if collection_format == 'multi': - new_params.extend((k, str(value)) for value in v) + new_params.extend((k, quote(str(value))) for value in v) else: if collection_format == 'ssv': delimiter = ' ' diff --git a/cdp/client/configuration.py b/cdp/client/configuration.py index 8f7de86..462dd24 100644 --- a/cdp/client/configuration.py +++ b/cdp/client/configuration.py @@ -13,14 +13,16 @@ import copy +import http.client as httplib import logging from logging import FileHandler import multiprocessing import sys -from typing import Optional +from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict +from typing_extensions import NotRequired, Self + import urllib3 -import http.client as httplib JSON_SCHEMA_VALIDATION_KEYWORDS = { 'multipleOf', 'maximum', 'exclusiveMaximum', @@ -28,6 +30,108 @@ 'minLength', 'pattern', 'maxItems', 'minItems' } +ServerVariablesT = Dict[str, str] + +GenericAuthSetting = TypedDict( + "GenericAuthSetting", + { + "type": str, + "in": str, + "key": str, + "value": str, + }, +) + + +OAuth2AuthSetting = TypedDict( + "OAuth2AuthSetting", + { + "type": Literal["oauth2"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +APIKeyAuthSetting = TypedDict( + "APIKeyAuthSetting", + { + "type": Literal["api_key"], + "in": str, + "key": str, + "value": Optional[str], + }, +) + + +BasicAuthSetting = TypedDict( + "BasicAuthSetting", + { + "type": Literal["basic"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": Optional[str], + }, +) + + +BearerFormatAuthSetting = TypedDict( + "BearerFormatAuthSetting", + { + "type": Literal["bearer"], + "in": Literal["header"], + "format": Literal["JWT"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +BearerAuthSetting = TypedDict( + "BearerAuthSetting", + { + "type": Literal["bearer"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": str, + }, +) + + +HTTPSignatureAuthSetting = TypedDict( + "HTTPSignatureAuthSetting", + { + "type": Literal["http-signature"], + "in": Literal["header"], + "key": Literal["Authorization"], + "value": None, + }, +) + + +AuthSettings = TypedDict( + "AuthSettings", + { + "apiKey": APIKeyAuthSetting, + "session": APIKeyAuthSetting, + }, + total=False, +) + + +class HostSettingVariable(TypedDict): + description: str + default_value: str + enum_values: List[str] + + +class HostSetting(TypedDict): + url: str + description: str + variables: NotRequired[Dict[str, HostSettingVariable]] + + class Configuration: """This class contains various settings of the API client. @@ -81,20 +185,26 @@ class Configuration: Cookie: JSESSIONID abc123 """ - _default = None - - def __init__(self, host=None, - api_key=None, api_key_prefix=None, - username=None, password=None, - access_token=None, - server_index=None, server_variables=None, - server_operation_index=None, server_operation_variables=None, - ignore_operation_servers=False, - ssl_ca_cert=None, - retries=None, - *, - debug: Optional[bool] = None - ) -> None: + _default: ClassVar[Optional[Self]] = None + + def __init__( + self, + host: Optional[str]=None, + api_key: Optional[Dict[str, str]]=None, + api_key_prefix: Optional[Dict[str, str]]=None, + username: Optional[str]=None, + password: Optional[str]=None, + access_token: Optional[str]=None, + server_index: Optional[int]=None, + server_variables: Optional[ServerVariablesT]=None, + server_operation_index: Optional[Dict[int, int]]=None, + server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None, + ignore_operation_servers: bool=False, + ssl_ca_cert: Optional[str]=None, + retries: Optional[int] = None, + *, + debug: Optional[bool] = None, + ) -> None: """Constructor """ self._base_path = "https://api.cdp.coinbase.com/platform" if host is None else host @@ -218,7 +328,7 @@ def __init__(self, host=None, """date format """ - def __deepcopy__(self, memo): + def __deepcopy__(self, memo: Dict[int, Any]) -> Self: cls = self.__class__ result = cls.__new__(cls) memo[id(self)] = result @@ -232,11 +342,11 @@ def __deepcopy__(self, memo): result.debug = self.debug return result - def __setattr__(self, name, value): + def __setattr__(self, name: str, value: Any) -> None: object.__setattr__(self, name, value) @classmethod - def set_default(cls, default): + def set_default(cls, default: Optional[Self]) -> None: """Set default instance of configuration. It stores default configuration, which can be @@ -247,7 +357,7 @@ def set_default(cls, default): cls._default = default @classmethod - def get_default_copy(cls): + def get_default_copy(cls) -> Self: """Deprecated. Please use `get_default` instead. Deprecated. Please use `get_default` instead. @@ -257,7 +367,7 @@ def get_default_copy(cls): return cls.get_default() @classmethod - def get_default(cls): + def get_default(cls) -> Self: """Return the default configuration. This method returns newly created, based on default constructor, @@ -267,11 +377,11 @@ def get_default(cls): :return: The configuration object. """ if cls._default is None: - cls._default = Configuration() + cls._default = cls() return cls._default @property - def logger_file(self): + def logger_file(self) -> Optional[str]: """The logger file. If the logger_file is None, then add stream handler and remove file @@ -283,7 +393,7 @@ def logger_file(self): return self.__logger_file @logger_file.setter - def logger_file(self, value): + def logger_file(self, value: Optional[str]) -> None: """The logger file. If the logger_file is None, then add stream handler and remove file @@ -302,7 +412,7 @@ def logger_file(self, value): logger.addHandler(self.logger_file_handler) @property - def debug(self): + def debug(self) -> bool: """Debug status :param value: The debug status, True or False. @@ -311,7 +421,7 @@ def debug(self): return self.__debug @debug.setter - def debug(self, value): + def debug(self, value: bool) -> None: """Debug status :param value: The debug status, True or False. @@ -333,7 +443,7 @@ def debug(self, value): httplib.HTTPConnection.debuglevel = 0 @property - def logger_format(self): + def logger_format(self) -> str: """The logger format. The logger_formatter will be updated when sets logger_format. @@ -344,7 +454,7 @@ def logger_format(self): return self.__logger_format @logger_format.setter - def logger_format(self, value): + def logger_format(self, value: str) -> None: """The logger format. The logger_formatter will be updated when sets logger_format. @@ -355,7 +465,7 @@ def logger_format(self, value): self.__logger_format = value self.logger_formatter = logging.Formatter(self.__logger_format) - def get_api_key_with_prefix(self, identifier, alias=None): + def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]: """Gets API key (with prefix if set). :param identifier: The identifier of apiKey. @@ -372,7 +482,9 @@ def get_api_key_with_prefix(self, identifier, alias=None): else: return key - def get_basic_auth_token(self): + return None + + def get_basic_auth_token(self) -> Optional[str]: """Gets HTTP basic authentication header (string). :return: The token for basic HTTP authentication. @@ -387,12 +499,12 @@ def get_basic_auth_token(self): basic_auth=username + ':' + password ).get('authorization') - def auth_settings(self): + def auth_settings(self)-> AuthSettings: """Gets Auth Settings dict for api client. :return: The Auth Settings information dict. """ - auth = {} + auth: AuthSettings = {} if 'apiKey' in self.api_key: auth['apiKey'] = { 'type': 'api_key', @@ -413,7 +525,7 @@ def auth_settings(self): } return auth - def to_debug_report(self): + def to_debug_report(self) -> str: """Gets the essential information for debugging. :return: The report for debugging. @@ -425,7 +537,7 @@ def to_debug_report(self): "SDK Package Version: 1.0.0".\ format(env=sys.platform, pyversion=sys.version) - def get_host_settings(self): + def get_host_settings(self) -> List[HostSetting]: """Gets an array of host settings :return: An array of host settings @@ -437,7 +549,12 @@ def get_host_settings(self): } ] - def get_host_from_settings(self, index, variables=None, servers=None): + def get_host_from_settings( + self, + index: Optional[int], + variables: Optional[ServerVariablesT]=None, + servers: Optional[List[HostSetting]]=None, + ) -> str: """Gets host URL based on the index and variables :param index: array index of the host settings :param variables: hash of variable and the corresponding value @@ -477,12 +594,12 @@ def get_host_from_settings(self, index, variables=None, servers=None): return url @property - def host(self): + def host(self) -> str: """Return generated host.""" return self.get_host_from_settings(self.server_index, variables=self.server_variables) @host.setter - def host(self, value): + def host(self, value: str) -> None: """Fix base path.""" self._base_path = value self.server_index = None diff --git a/cdp/client/exceptions.py b/cdp/client/exceptions.py index a126d9f..85a2589 100644 --- a/cdp/client/exceptions.py +++ b/cdp/client/exceptions.py @@ -150,6 +150,13 @@ def from_response( if http_resp.status == 404: raise NotFoundException(http_resp=http_resp, body=body, data=data) + # Added new conditions for 409 and 422 + if http_resp.status == 409: + raise ConflictException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 422: + raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data) + if 500 <= http_resp.status <= 599: raise ServiceException(http_resp=http_resp, body=body, data=data) raise ApiException(http_resp=http_resp, body=body, data=data) @@ -188,6 +195,16 @@ class ServiceException(ApiException): pass +class ConflictException(ApiException): + """Exception for HTTP 409 Conflict.""" + pass + + +class UnprocessableEntityException(ApiException): + """Exception for HTTP 422 Unprocessable Entity.""" + pass + + def render_path(path_to_item): """Returns a string representation of a path""" result = "" diff --git a/cdp/client/models/__init__.py b/cdp/client/models/__init__.py index b66d34c..80300d3 100644 --- a/cdp/client/models/__init__.py +++ b/cdp/client/models/__init__.py @@ -24,11 +24,15 @@ from cdp.client.models.asset import Asset from cdp.client.models.balance import Balance from cdp.client.models.broadcast_contract_invocation_request import BroadcastContractInvocationRequest +from cdp.client.models.broadcast_external_transaction200_response import BroadcastExternalTransaction200Response +from cdp.client.models.broadcast_external_transaction_request import BroadcastExternalTransactionRequest from cdp.client.models.broadcast_external_transfer_request import BroadcastExternalTransferRequest from cdp.client.models.broadcast_staking_operation_request import BroadcastStakingOperationRequest from cdp.client.models.broadcast_trade_request import BroadcastTradeRequest from cdp.client.models.broadcast_transfer_request import BroadcastTransferRequest +from cdp.client.models.broadcast_user_operation_request import BroadcastUserOperationRequest from cdp.client.models.build_staking_operation_request import BuildStakingOperationRequest +from cdp.client.models.call import Call from cdp.client.models.compile_smart_contract_request import CompileSmartContractRequest from cdp.client.models.compiled_smart_contract import CompiledSmartContract from cdp.client.models.contract_event import ContractEvent @@ -43,9 +47,11 @@ from cdp.client.models.create_payload_signature_request import CreatePayloadSignatureRequest from cdp.client.models.create_server_signer_request import CreateServerSignerRequest from cdp.client.models.create_smart_contract_request import CreateSmartContractRequest +from cdp.client.models.create_smart_wallet_request import CreateSmartWalletRequest from cdp.client.models.create_staking_operation_request import CreateStakingOperationRequest from cdp.client.models.create_trade_request import CreateTradeRequest from cdp.client.models.create_transfer_request import CreateTransferRequest +from cdp.client.models.create_user_operation_request import CreateUserOperationRequest from cdp.client.models.create_wallet_request import CreateWalletRequest from cdp.client.models.create_wallet_request_wallet import CreateWalletRequestWallet from cdp.client.models.create_wallet_webhook_request import CreateWalletWebhookRequest @@ -98,6 +104,8 @@ from cdp.client.models.smart_contract_list import SmartContractList from cdp.client.models.smart_contract_options import SmartContractOptions from cdp.client.models.smart_contract_type import SmartContractType +from cdp.client.models.smart_wallet import SmartWallet +from cdp.client.models.smart_wallet_list import SmartWalletList from cdp.client.models.solidity_value import SolidityValue from cdp.client.models.sponsored_send import SponsoredSend from cdp.client.models.staking_balance import StakingBalance @@ -120,6 +128,7 @@ from cdp.client.models.update_smart_contract_request import UpdateSmartContractRequest from cdp.client.models.update_webhook_request import UpdateWebhookRequest from cdp.client.models.user import User +from cdp.client.models.user_operation import UserOperation from cdp.client.models.validator import Validator from cdp.client.models.validator_details import ValidatorDetails from cdp.client.models.validator_list import ValidatorList @@ -132,4 +141,5 @@ from cdp.client.models.webhook_event_type_filter import WebhookEventTypeFilter from cdp.client.models.webhook_list import WebhookList from cdp.client.models.webhook_smart_contract_event_filter import WebhookSmartContractEventFilter +from cdp.client.models.webhook_status import WebhookStatus from cdp.client.models.webhook_wallet_activity_filter import WebhookWalletActivityFilter diff --git a/cdp/client/models/broadcast_external_transaction200_response.py b/cdp/client/models/broadcast_external_transaction200_response.py new file mode 100644 index 0000000..f203491 --- /dev/null +++ b/cdp/client/models/broadcast_external_transaction200_response.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + Coinbase Platform API + + This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + + The version of the OpenAPI document: 0.0.1-alpha + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class BroadcastExternalTransaction200Response(BaseModel): + """ + External Transaction Broadcast Response + """ # noqa: E501 + transaction_hash: StrictStr = Field(description="The transaction hash") + transaction_link: Optional[StrictStr] = Field(default=None, description="The link to view the transaction on a block explorer. This is optional and may not be present for all transactions.") + __properties: ClassVar[List[str]] = ["transaction_hash", "transaction_link"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of BroadcastExternalTransaction200Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of BroadcastExternalTransaction200Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "transaction_hash": obj.get("transaction_hash"), + "transaction_link": obj.get("transaction_link") + }) + return _obj + + diff --git a/cdp/client/models/broadcast_external_transaction_request.py b/cdp/client/models/broadcast_external_transaction_request.py new file mode 100644 index 0000000..2e3a75c --- /dev/null +++ b/cdp/client/models/broadcast_external_transaction_request.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + Coinbase Platform API + + This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + + The version of the OpenAPI document: 0.0.1-alpha + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class BroadcastExternalTransactionRequest(BaseModel): + """ + BroadcastExternalTransactionRequest + """ # noqa: E501 + signed_payload: StrictStr = Field(description="The hex-encoded signed payload of the external address transaction.") + __properties: ClassVar[List[str]] = ["signed_payload"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of BroadcastExternalTransactionRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of BroadcastExternalTransactionRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "signed_payload": obj.get("signed_payload") + }) + return _obj + + diff --git a/cdp/client/models/broadcast_user_operation_request.py b/cdp/client/models/broadcast_user_operation_request.py new file mode 100644 index 0000000..b1169fe --- /dev/null +++ b/cdp/client/models/broadcast_user_operation_request.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + Coinbase Platform API + + This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + + The version of the OpenAPI document: 0.0.1-alpha + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class BroadcastUserOperationRequest(BaseModel): + """ + BroadcastUserOperationRequest + """ # noqa: E501 + signature: StrictStr = Field(description="The hex-encoded signature of the user operation.") + __properties: ClassVar[List[str]] = ["signature"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of BroadcastUserOperationRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of BroadcastUserOperationRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "signature": obj.get("signature") + }) + return _obj + + diff --git a/cdp/client/models/call.py b/cdp/client/models/call.py new file mode 100644 index 0000000..7feaae1 --- /dev/null +++ b/cdp/client/models/call.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + Coinbase Platform API + + This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + + The version of the OpenAPI document: 0.0.1-alpha + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class Call(BaseModel): + """ + An action that will be bundled into a user operation. + """ # noqa: E501 + to: StrictStr = Field(description="The address the call is interacting with.") + data: StrictStr = Field(description="The hex-encoded data to send with the call.") + value: StrictStr = Field(description="The string-encoded integer value to send with the call.") + __properties: ClassVar[List[str]] = ["to", "data", "value"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of Call from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of Call from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "to": obj.get("to"), + "data": obj.get("data"), + "value": obj.get("value") + }) + return _obj + + diff --git a/cdp/client/models/create_smart_wallet_request.py b/cdp/client/models/create_smart_wallet_request.py new file mode 100644 index 0000000..0f033fb --- /dev/null +++ b/cdp/client/models/create_smart_wallet_request.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + Coinbase Platform API + + This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + + The version of the OpenAPI document: 0.0.1-alpha + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class CreateSmartWalletRequest(BaseModel): + """ + CreateSmartWalletRequest + """ # noqa: E501 + owner: StrictStr = Field(description="The address of the owner of the smart wallet.") + __properties: ClassVar[List[str]] = ["owner"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateSmartWalletRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateSmartWalletRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "owner": obj.get("owner") + }) + return _obj + + diff --git a/cdp/client/models/create_user_operation_request.py b/cdp/client/models/create_user_operation_request.py new file mode 100644 index 0000000..e735bcb --- /dev/null +++ b/cdp/client/models/create_user_operation_request.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + Coinbase Platform API + + This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + + The version of the OpenAPI document: 0.0.1-alpha + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List +from cdp.client.models.call import Call +from typing import Optional, Set +from typing_extensions import Self + +class CreateUserOperationRequest(BaseModel): + """ + CreateUserOperationRequest + """ # noqa: E501 + calls: List[Call] = Field(description="The list of calls to make from the smart wallet.") + __properties: ClassVar[List[str]] = ["calls"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CreateUserOperationRequest from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in calls (list) + _items = [] + if self.calls: + for _item_calls in self.calls: + if _item_calls: + _items.append(_item_calls.to_dict()) + _dict['calls'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateUserOperationRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "calls": [Call.from_dict(_item) for _item in obj["calls"]] if obj.get("calls") is not None else None + }) + return _obj + + diff --git a/cdp/client/models/network_identifier.py b/cdp/client/models/network_identifier.py index 709679a..ebe8afd 100644 --- a/cdp/client/models/network_identifier.py +++ b/cdp/client/models/network_identifier.py @@ -29,6 +29,7 @@ class NetworkIdentifier(str, Enum): BASE_MINUS_SEPOLIA = 'base-sepolia' BASE_MINUS_MAINNET = 'base-mainnet' ETHEREUM_MINUS_HOLESKY = 'ethereum-holesky' + ETHEREUM_MINUS_SEPOLIA = 'ethereum-sepolia' ETHEREUM_MINUS_MAINNET = 'ethereum-mainnet' POLYGON_MINUS_MAINNET = 'polygon-mainnet' SOLANA_MINUS_DEVNET = 'solana-devnet' @@ -36,6 +37,8 @@ class NetworkIdentifier(str, Enum): ARBITRUM_MINUS_MAINNET = 'arbitrum-mainnet' ARBITRUM_MINUS_SEPOLIA = 'arbitrum-sepolia' BITCOIN_MINUS_MAINNET = 'bitcoin-mainnet' + NEAR_MINUS_TESTNET = 'near-testnet' + NEAR_MINUS_MAINNET = 'near-mainnet' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/cdp/client/models/smart_wallet.py b/cdp/client/models/smart_wallet.py new file mode 100644 index 0000000..0057880 --- /dev/null +++ b/cdp/client/models/smart_wallet.py @@ -0,0 +1,89 @@ +# coding: utf-8 + +""" + Coinbase Platform API + + This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + + The version of the OpenAPI document: 0.0.1-alpha + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class SmartWallet(BaseModel): + """ + SmartWallet + """ # noqa: E501 + address: StrictStr = Field(description="The onchain address of the smart wallet.") + owners: List[StrictStr] = Field(description="The list of owner addresses for the smart wallet.") + __properties: ClassVar[List[str]] = ["address", "owners"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of SmartWallet from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SmartWallet from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "address": obj.get("address"), + "owners": obj.get("owners") + }) + return _obj + + diff --git a/cdp/client/models/smart_wallet_list.py b/cdp/client/models/smart_wallet_list.py new file mode 100644 index 0000000..d791804 --- /dev/null +++ b/cdp/client/models/smart_wallet_list.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + Coinbase Platform API + + This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + + The version of the OpenAPI document: 0.0.1-alpha + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from cdp.client.models.smart_wallet import SmartWallet +from typing import Optional, Set +from typing_extensions import Self + +class SmartWalletList(BaseModel): + """ + Paginated list of smart wallets + """ # noqa: E501 + data: List[SmartWallet] + has_more: StrictBool = Field(description="True if this list has another page of items after this one that can be fetched.") + next_page: StrictStr = Field(description="The page token to be used to fetch the next page.") + total_count: StrictInt = Field(description="The total number of wallets") + __properties: ClassVar[List[str]] = ["data", "has_more", "next_page", "total_count"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of SmartWalletList from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in data (list) + _items = [] + if self.data: + for _item_data in self.data: + if _item_data: + _items.append(_item_data.to_dict()) + _dict['data'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of SmartWalletList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "data": [SmartWallet.from_dict(_item) for _item in obj["data"]] if obj.get("data") is not None else None, + "has_more": obj.get("has_more"), + "next_page": obj.get("next_page"), + "total_count": obj.get("total_count") + }) + return _obj + + diff --git a/cdp/client/models/staking_context_context.py b/cdp/client/models/staking_context_context.py index 239cd8b..080dc94 100644 --- a/cdp/client/models/staking_context_context.py +++ b/cdp/client/models/staking_context_context.py @@ -29,8 +29,9 @@ class StakingContextContext(BaseModel): """ # noqa: E501 stakeable_balance: Balance unstakeable_balance: Balance + pending_claimable_balance: Balance claimable_balance: Balance - __properties: ClassVar[List[str]] = ["stakeable_balance", "unstakeable_balance", "claimable_balance"] + __properties: ClassVar[List[str]] = ["stakeable_balance", "unstakeable_balance", "pending_claimable_balance", "claimable_balance"] model_config = ConfigDict( populate_by_name=True, @@ -77,6 +78,9 @@ def to_dict(self) -> Dict[str, Any]: # override the default output from pydantic by calling `to_dict()` of unstakeable_balance if self.unstakeable_balance: _dict['unstakeable_balance'] = self.unstakeable_balance.to_dict() + # override the default output from pydantic by calling `to_dict()` of pending_claimable_balance + if self.pending_claimable_balance: + _dict['pending_claimable_balance'] = self.pending_claimable_balance.to_dict() # override the default output from pydantic by calling `to_dict()` of claimable_balance if self.claimable_balance: _dict['claimable_balance'] = self.claimable_balance.to_dict() @@ -94,6 +98,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "stakeable_balance": Balance.from_dict(obj["stakeable_balance"]) if obj.get("stakeable_balance") is not None else None, "unstakeable_balance": Balance.from_dict(obj["unstakeable_balance"]) if obj.get("unstakeable_balance") is not None else None, + "pending_claimable_balance": Balance.from_dict(obj["pending_claimable_balance"]) if obj.get("pending_claimable_balance") is not None else None, "claimable_balance": Balance.from_dict(obj["claimable_balance"]) if obj.get("claimable_balance") is not None else None }) return _obj diff --git a/cdp/client/models/update_webhook_request.py b/cdp/client/models/update_webhook_request.py index d7b6600..1da9471 100644 --- a/cdp/client/models/update_webhook_request.py +++ b/cdp/client/models/update_webhook_request.py @@ -21,6 +21,7 @@ from typing import Any, ClassVar, Dict, List, Optional from cdp.client.models.webhook_event_filter import WebhookEventFilter from cdp.client.models.webhook_event_type_filter import WebhookEventTypeFilter +from cdp.client.models.webhook_status import WebhookStatus from typing import Optional, Set from typing_extensions import Self @@ -31,7 +32,8 @@ class UpdateWebhookRequest(BaseModel): event_type_filter: Optional[WebhookEventTypeFilter] = None event_filters: Optional[List[WebhookEventFilter]] = Field(default=None, description="Webhook will monitor all events that matches any one of the event filters.") notification_uri: Optional[StrictStr] = Field(default=None, description="The Webhook uri that updates to") - __properties: ClassVar[List[str]] = ["event_type_filter", "event_filters", "notification_uri"] + status: Optional[WebhookStatus] = None + __properties: ClassVar[List[str]] = ["event_type_filter", "event_filters", "notification_uri", "status"] model_config = ConfigDict( populate_by_name=True, @@ -96,7 +98,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "event_type_filter": WebhookEventTypeFilter.from_dict(obj["event_type_filter"]) if obj.get("event_type_filter") is not None else None, "event_filters": [WebhookEventFilter.from_dict(_item) for _item in obj["event_filters"]] if obj.get("event_filters") is not None else None, - "notification_uri": obj.get("notification_uri") + "notification_uri": obj.get("notification_uri"), + "status": obj.get("status") }) return _obj diff --git a/cdp/client/models/user_operation.py b/cdp/client/models/user_operation.py new file mode 100644 index 0000000..947319c --- /dev/null +++ b/cdp/client/models/user_operation.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + Coinbase Platform API + + This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + + The version of the OpenAPI document: 0.0.1-alpha + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from cdp.client.models.call import Call +from typing import Optional, Set +from typing_extensions import Self + +class UserOperation(BaseModel): + """ + UserOperation + """ # noqa: E501 + id: StrictStr = Field(description="The ID of the user operation.") + network_id: StrictStr = Field(description="The ID of the network the user operation is being created on.") + calls: List[Call] = Field(description="The list of calls to make from the smart wallet.") + unsigned_payload: StrictStr = Field(description="The hex-encoded hash that must be signed by the user.") + signature: Optional[StrictStr] = Field(default=None, description="The hex-encoded signature of the user operation.") + status: Optional[StrictStr] = Field(default=None, description="The status of the user operation.") + __properties: ClassVar[List[str]] = ["id", "network_id", "calls", "unsigned_payload", "signature", "status"] + + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['pending', 'signed', 'broadcast', 'complete', 'failed']): + raise ValueError("must be one of enum values ('pending', 'signed', 'broadcast', 'complete', 'failed')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of UserOperation from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in calls (list) + _items = [] + if self.calls: + for _item_calls in self.calls: + if _item_calls: + _items.append(_item_calls.to_dict()) + _dict['calls'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UserOperation from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "network_id": obj.get("network_id"), + "calls": [Call.from_dict(_item) for _item in obj["calls"]] if obj.get("calls") is not None else None, + "unsigned_payload": obj.get("unsigned_payload"), + "signature": obj.get("signature"), + "status": obj.get("status") + }) + return _obj + + diff --git a/cdp/client/models/webhook.py b/cdp/client/models/webhook.py index e71b31c..28807b3 100644 --- a/cdp/client/models/webhook.py +++ b/cdp/client/models/webhook.py @@ -23,6 +23,7 @@ from cdp.client.models.webhook_event_filter import WebhookEventFilter from cdp.client.models.webhook_event_type import WebhookEventType from cdp.client.models.webhook_event_type_filter import WebhookEventTypeFilter +from cdp.client.models.webhook_status import WebhookStatus from typing import Optional, Set from typing_extensions import Self @@ -39,7 +40,8 @@ class Webhook(BaseModel): created_at: Optional[datetime] = Field(default=None, description="The date and time the webhook was created.") updated_at: Optional[datetime] = Field(default=None, description="The date and time the webhook was last updated.") signature_header: Optional[StrictStr] = Field(default=None, description="The header that will contain the signature of the webhook payload.") - __properties: ClassVar[List[str]] = ["id", "network_id", "event_type", "event_type_filter", "event_filters", "notification_uri", "created_at", "updated_at", "signature_header"] + status: WebhookStatus + __properties: ClassVar[List[str]] = ["id", "network_id", "event_type", "event_type_filter", "event_filters", "notification_uri", "created_at", "updated_at", "signature_header", "status"] model_config = ConfigDict( populate_by_name=True, @@ -110,7 +112,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "notification_uri": obj.get("notification_uri"), "created_at": obj.get("created_at"), "updated_at": obj.get("updated_at"), - "signature_header": obj.get("signature_header") + "signature_header": obj.get("signature_header"), + "status": obj.get("status") }) return _obj diff --git a/cdp/client/models/webhook_status.py b/cdp/client/models/webhook_status.py new file mode 100644 index 0000000..8cc6a09 --- /dev/null +++ b/cdp/client/models/webhook_status.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + Coinbase Platform API + + This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. + + The version of the OpenAPI document: 0.0.1-alpha + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import json +from enum import Enum +from typing_extensions import Self + + +class WebhookStatus(str, Enum): + """ + The status of the webhook. + """ + + """ + allowed enum values + """ + ACTIVE = 'active' + INACTIVE = 'inactive' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of WebhookStatus from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/cdp/wallet.py b/cdp/wallet.py index da17b71..a2fedfe 100644 --- a/cdp/wallet.py +++ b/cdp/wallet.py @@ -260,7 +260,9 @@ def list(cls) -> Iterator["Wallet"]: page = response.next_page @classmethod - def import_wallet(cls, data: WalletData | MnemonicSeedPhrase, network_id: str = "base-sepolia") -> "Wallet": + def import_wallet( + cls, data: WalletData | MnemonicSeedPhrase, network_id: str = "base-sepolia" + ) -> "Wallet": """Import a wallet from previously exported wallet data or a mnemonic seed phrase. Args: diff --git a/docs/conf.py b/docs/conf.py index af613b0..0978418 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -14,7 +14,7 @@ project = 'CDP SDK' author = 'Coinbase Developer Platform' -release = '0.16.0' +release = '0.17.0' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/pyproject.toml b/pyproject.toml index 220674a..ccc9730 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cdp-sdk" -version = "0.16.0" +version = "0.17.0" description = "CDP Python SDK" authors = ["John Peterson "] license = "LICENSE.md" diff --git a/tests/factories/webhook_factory.py b/tests/factories/webhook_factory.py index 2a3dcc2..6503e02 100644 --- a/tests/factories/webhook_factory.py +++ b/tests/factories/webhook_factory.py @@ -1,6 +1,6 @@ import pytest -from cdp.client import WebhookEventTypeFilter, WebhookWalletActivityFilter +from cdp.client import WebhookEventTypeFilter, WebhookStatus, WebhookWalletActivityFilter from cdp.webhook import Webhook, WebhookEventType, WebhookModel @@ -32,6 +32,7 @@ def _create_webhook( event_type=event_type, event_type_filter=event_type_filter, event_filters=event_filters or [], + status=WebhookStatus.ACTIVE, ) return Webhook(model) diff --git a/tests/test_address.py b/tests/test_address.py index a247728..87ce505 100644 --- a/tests/test_address.py +++ b/tests/test_address.py @@ -6,6 +6,7 @@ from cdp.address import Address from cdp.address_reputation import AddressReputation from cdp.balance_map import BalanceMap +from cdp.client import BroadcastExternalTransaction200Response, BroadcastExternalTransactionRequest from cdp.client.exceptions import ApiException from cdp.errors import ApiError from cdp.faucet_transaction import FaucetTransaction @@ -263,6 +264,58 @@ def test_address_reputation(mock_api_clients, address_factory, address_reputatio ) +@patch("cdp.Cdp.api_clients") +def test_address_broadcast_external_transaction(mock_api_clients, address_factory): + """Test the broadcast_external_transaction method of an Address.""" + address = address_factory() + signed_payload = "0x1234567890123456789012345678901234567890" + + mock_broadcast_external_transaction = Mock() + mock_broadcast_external_transaction.return_value = BroadcastExternalTransaction200Response( + transaction_hash="0x1234567890123456789012345678901234567890", + transaction_link="https://etherscan.io/tx/0x1234567890123456789012345678901234567890", + ) + mock_api_clients.external_addresses.broadcast_external_transaction = ( + mock_broadcast_external_transaction + ) + + broadcast_external_transaction = address.broadcast_external_transaction(signed_payload) + + assert isinstance(broadcast_external_transaction, BroadcastExternalTransaction200Response) + assert ( + broadcast_external_transaction.transaction_hash + == "0x1234567890123456789012345678901234567890" + ) + assert ( + broadcast_external_transaction.transaction_link + == "https://etherscan.io/tx/0x1234567890123456789012345678901234567890" + ) + + mock_broadcast_external_transaction.assert_called_once_with( + network_id=address.network_id, + address_id=address.address_id, + broadcast_external_transaction_request=BroadcastExternalTransactionRequest( + signed_payload=signed_payload + ), + ) + + +@patch("cdp.Cdp.api_clients") +def test_address_broadcast_external_transaction_error(mock_api_clients, address_factory): + """Test the broadcast_external_transaction method of an Address raises an error when the API call fails.""" + address = address_factory() + + mock_broadcast_external_transaction = Mock() + err = ApiException(500, "boom") + mock_broadcast_external_transaction.side_effect = ApiError(err, code="boom", message="boom") + mock_api_clients.external_addresses.broadcast_external_transaction = ( + mock_broadcast_external_transaction + ) + + with pytest.raises(ApiError): + address.broadcast_external_transaction("0x1234567890123456789012345678901234567890") + + def test_address_str_representation(address_factory): """Test the str representation of an Address.""" address = address_factory() diff --git a/tests/test_asset.py b/tests/test_asset.py index b9ed48a..354d87f 100644 --- a/tests/test_asset.py +++ b/tests/test_asset.py @@ -52,17 +52,23 @@ def test_asset_from_model_with_invalid_asset_id(asset_model_factory): with pytest.raises(ValueError, match="Unsupported asset ID: invalid"): Asset.from_model(asset_model, asset_id="invalid") + def test_asset_from_model_with_non_checksummed_address(asset_model_factory): """Test asset from model with non-checksummed address.""" - asset_model = asset_model_factory(asset_id="0x8309fbdF021eDF768DC13195741940ba544dEa98", decimals=18) + asset_model = asset_model_factory( + asset_id="0x8309fbdF021eDF768DC13195741940ba544dEa98", decimals=18 + ) asset = Asset.from_model(asset_model, asset_id="0x8309fbdf021edf768dc13195741940ba544dea98") assert asset.asset_id == "0x8309fbdf021edf768dc13195741940ba544dea98" assert asset.decimals == 18 + def test_asset_from_model_with_checksummed_address(asset_model_factory): """Test asset from model with checksummed address.""" - asset_model = asset_model_factory(asset_id="0x8309fbdF021eDF768DC13195741940ba544dEa98", decimals=18) + asset_model = asset_model_factory( + asset_id="0x8309fbdF021eDF768DC13195741940ba544dEa98", decimals=18 + ) asset = Asset.from_model(asset_model, asset_id="0x8309fbdF021eDF768DC13195741940ba544dEa98") assert asset.asset_id == "0x8309fbdF021eDF768DC13195741940ba544dEa98" diff --git a/tests/test_webhook.py b/tests/test_webhook.py index 08bea9e..18a7986 100644 --- a/tests/test_webhook.py +++ b/tests/test_webhook.py @@ -1,7 +1,6 @@ from unittest.mock import patch -from cdp.client.models.create_webhook_request import CreateWebhookRequest -from cdp.client.models.update_webhook_request import UpdateWebhookRequest +from cdp.client import CreateWebhookRequest, UpdateWebhookRequest, WebhookStatus from cdp.client.models.webhook import WebhookEventFilter, WebhookEventType, WebhookEventTypeFilter from cdp.webhook import Webhook, WebhookModel @@ -72,6 +71,7 @@ def test_webhook_update(mock_api_clients, webhook_factory): event_type=webhook.event_type, event_type_filter=webhook.event_type_filter, event_filters=webhook.event_filters, + status=WebhookStatus.ACTIVE, ) expected_request = UpdateWebhookRequest(