diff --git a/examples/python/end_user/create_end_user_policy.py b/examples/python/end_user/create_end_user_policy.py index bf492cc23..f598b54a6 100644 --- a/examples/python/end_user/create_end_user_policy.py +++ b/examples/python/end_user/create_end_user_policy.py @@ -4,6 +4,7 @@ from cdp import CdpClient from cdp.policies.types import ( + CreateEndUserEvmSwapRule, CreatePolicyOptions, EthValueCriterion, EvmAddressCriterion, @@ -63,6 +64,20 @@ async def main(): ), ], ), + # Restrict end-user EVM swaps to a specific network and max USD exposure + CreateEndUserEvmSwapRule( + action="accept", + criteria=[ + EvmNetworkCriterion( + networks=["base", "base-sepolia"], + operator="in", + ), + NetUSDChangeCriterion( + changeCents=10000, # $100.00 + operator="<=", + ), + ], + ), # Restrict end-user EVM message signing to messages matching a specific pattern SignEndUserEvmMessageRule( action="accept", diff --git a/python/CHANGELOG.md b/python/CHANGELOG.md index 331cc3097..f5de56919 100644 --- a/python/CHANGELOG.md +++ b/python/CHANGELOG.md @@ -2,6 +2,12 @@ +## Unreleased + +### Features + +- Added support for the `createEndUserEvmSwap` policy rule, enabling policy controls for end user EVM swap operations with all existing EVM criteria (ethValue, evmAddress, evmNetwork, evmData, netUSDChange). + ## [1.40.0] - 2026-03-06 ### Features diff --git a/python/cdp/openapi_client/__init__.py b/python/cdp/openapi_client/__init__.py index b3594b5f3..71d39fd60 100644 --- a/python/cdp/openapi_client/__init__.py +++ b/python/cdp/openapi_client/__init__.py @@ -27,7 +27,7 @@ from cdp.openapi_client.api.onchain_data_api import OnchainDataApi from cdp.openapi_client.api.onramp_api import OnrampApi from cdp.openapi_client.api.policy_engine_api import PolicyEngineApi -from cdp.openapi_client.api.sqlapi_alpha_api import SQLAPIAlphaApi +from cdp.openapi_client.api.sqlapi_api import SQLAPIApi from cdp.openapi_client.api.solana_accounts_api import SolanaAccountsApi from cdp.openapi_client.api.solana_token_balances_api import SolanaTokenBalancesApi from cdp.openapi_client.api.webhooks_api import WebhooksApi @@ -62,6 +62,7 @@ from cdp.openapi_client.models.common_swap_response_issues import CommonSwapResponseIssues from cdp.openapi_client.models.common_swap_response_issues_allowance import CommonSwapResponseIssuesAllowance from cdp.openapi_client.models.common_swap_response_issues_balance import CommonSwapResponseIssuesBalance +from cdp.openapi_client.models.create_end_user_evm_swap_rule import CreateEndUserEvmSwapRule from cdp.openapi_client.models.create_end_user_request import CreateEndUserRequest from cdp.openapi_client.models.create_end_user_request_evm_account import CreateEndUserRequestEvmAccount from cdp.openapi_client.models.create_end_user_request_solana_account import CreateEndUserRequestSolanaAccount @@ -151,11 +152,14 @@ from cdp.openapi_client.models.net_usd_change_criterion import NetUSDChangeCriterion from cdp.openapi_client.models.o_auth2_authentication import OAuth2Authentication from cdp.openapi_client.models.o_auth2_provider_type import OAuth2ProviderType +from cdp.openapi_client.models.onchain_data_column_schema import OnchainDataColumnSchema from cdp.openapi_client.models.onchain_data_query import OnchainDataQuery from cdp.openapi_client.models.onchain_data_result import OnchainDataResult from cdp.openapi_client.models.onchain_data_result_metadata import OnchainDataResultMetadata from cdp.openapi_client.models.onchain_data_result_schema import OnchainDataResultSchema from cdp.openapi_client.models.onchain_data_result_schema_columns_inner import OnchainDataResultSchemaColumnsInner +from cdp.openapi_client.models.onchain_data_schema_response import OnchainDataSchemaResponse +from cdp.openapi_client.models.onchain_data_table_schema import OnchainDataTableSchema from cdp.openapi_client.models.onramp_limit_type import OnrampLimitType from cdp.openapi_client.models.onramp_order import OnrampOrder from cdp.openapi_client.models.onramp_order_fee import OnrampOrderFee @@ -192,6 +196,7 @@ from cdp.openapi_client.models.send_solana_transaction_request import SendSolanaTransactionRequest from cdp.openapi_client.models.send_user_operation_request import SendUserOperationRequest from cdp.openapi_client.models.send_user_operation_rule import SendUserOperationRule +from cdp.openapi_client.models.sign_end_user_evm_hash_rule import SignEndUserEvmHashRule from cdp.openapi_client.models.sign_end_user_evm_message_rule import SignEndUserEvmMessageRule from cdp.openapi_client.models.sign_end_user_evm_transaction_rule import SignEndUserEvmTransactionRule from cdp.openapi_client.models.sign_end_user_evm_typed_data_rule import SignEndUserEvmTypedDataRule @@ -224,6 +229,7 @@ from cdp.openapi_client.models.sign_solana_message_request import SignSolanaMessageRequest from cdp.openapi_client.models.sign_solana_transaction200_response import SignSolanaTransaction200Response from cdp.openapi_client.models.sign_solana_transaction_request import SignSolanaTransactionRequest +from cdp.openapi_client.models.siwe_authentication import SiweAuthentication from cdp.openapi_client.models.sms_authentication import SmsAuthentication from cdp.openapi_client.models.sol_address_criterion import SolAddressCriterion from cdp.openapi_client.models.sol_data_condition import SolDataCondition @@ -258,6 +264,9 @@ from cdp.openapi_client.models.user_operation_receipt_revert import UserOperationReceiptRevert from cdp.openapi_client.models.validate_end_user_access_token_request import ValidateEndUserAccessTokenRequest from cdp.openapi_client.models.verify_x402_payment_request import VerifyX402PaymentRequest +from cdp.openapi_client.models.webhook_event_list_response import WebhookEventListResponse +from cdp.openapi_client.models.webhook_event_response import WebhookEventResponse +from cdp.openapi_client.models.webhook_event_response_detail import WebhookEventResponseDetail from cdp.openapi_client.models.webhook_subscription_list_response import WebhookSubscriptionListResponse from cdp.openapi_client.models.webhook_subscription_request import WebhookSubscriptionRequest from cdp.openapi_client.models.webhook_subscription_response import WebhookSubscriptionResponse @@ -278,9 +287,9 @@ from cdp.openapi_client.models.x402_settle_payment_rejection import X402SettlePaymentRejection from cdp.openapi_client.models.x402_supported_payment_kind import X402SupportedPaymentKind from cdp.openapi_client.models.x402_v1_payment_payload import X402V1PaymentPayload -from cdp.openapi_client.models.x402_v1_payment_payload_payload import X402V1PaymentPayloadPayload from cdp.openapi_client.models.x402_v1_payment_requirements import X402V1PaymentRequirements from cdp.openapi_client.models.x402_v2_payment_payload import X402V2PaymentPayload +from cdp.openapi_client.models.x402_v2_payment_payload_payload import X402V2PaymentPayloadPayload from cdp.openapi_client.models.x402_v2_payment_requirements import X402V2PaymentRequirements from cdp.openapi_client.models.x402_verify_invalid_reason import X402VerifyInvalidReason from cdp.openapi_client.models.x402_verify_payment_rejection import X402VerifyPaymentRejection diff --git a/python/cdp/openapi_client/api/__init__.py b/python/cdp/openapi_client/api/__init__.py index 32ca5ac3f..9d3c4cfb3 100644 --- a/python/cdp/openapi_client/api/__init__.py +++ b/python/cdp/openapi_client/api/__init__.py @@ -10,7 +10,7 @@ from cdp.openapi_client.api.onchain_data_api import OnchainDataApi from cdp.openapi_client.api.onramp_api import OnrampApi from cdp.openapi_client.api.policy_engine_api import PolicyEngineApi -from cdp.openapi_client.api.sqlapi_alpha_api import SQLAPIAlphaApi +from cdp.openapi_client.api.sqlapi_api import SQLAPIApi from cdp.openapi_client.api.solana_accounts_api import SolanaAccountsApi from cdp.openapi_client.api.solana_token_balances_api import SolanaTokenBalancesApi from cdp.openapi_client.api.webhooks_api import WebhooksApi diff --git a/python/cdp/openapi_client/api/faucets_api.py b/python/cdp/openapi_client/api/faucets_api.py index ce998b2ea..7240dac31 100644 --- a/python/cdp/openapi_client/api/faucets_api.py +++ b/python/cdp/openapi_client/api/faucets_api.py @@ -352,7 +352,7 @@ async def request_solana_faucet( ) -> RequestSolanaFaucet200Response: """Request funds on Solana devnet - Request funds from the CDP Faucet on Solana devnet. Faucets are available for SOL. To prevent abuse, we enforce rate limits within a rolling 24-hour window to control the amount of funds that can be requested. These limits are applied at both the CDP Project level and the blockchain address level. A single blockchain address cannot exceed the specified limits, even if multiple users submit requests to the same address. | Token | Amount per Faucet Request |Rolling 24-hour window Rate Limits| |:-----:|:-------------------------:|:--------------------------------:| | SOL | 0.00125 SOL | 0.0125 SOL | | USDC | 1 USDC | 10 USDC | + Request funds from the CDP Faucet on Solana devnet. Faucets are available for SOL, USDC, and CBTUSD. To prevent abuse, we enforce rate limits within a rolling 24-hour window to control the amount of funds that can be requested. These limits are applied at both the CDP Project level and the blockchain address level. A single blockchain address cannot exceed the specified limits, even if multiple users submit requests to the same address. | Token | Amount per Faucet Request |Rolling 24-hour window Rate Limits| |:-----: |:-------------------------:|:--------------------------------:| | SOL | 0.00125 SOL | 0.0125 SOL | | USDC | 1 USDC | 10 USDC | | CBTUSD | 1 CBTUSD | 10 CBTUSD | :param request_solana_faucet_request: :type request_solana_faucet_request: RequestSolanaFaucetRequest @@ -425,7 +425,7 @@ async def request_solana_faucet_with_http_info( ) -> ApiResponse[RequestSolanaFaucet200Response]: """Request funds on Solana devnet - Request funds from the CDP Faucet on Solana devnet. Faucets are available for SOL. To prevent abuse, we enforce rate limits within a rolling 24-hour window to control the amount of funds that can be requested. These limits are applied at both the CDP Project level and the blockchain address level. A single blockchain address cannot exceed the specified limits, even if multiple users submit requests to the same address. | Token | Amount per Faucet Request |Rolling 24-hour window Rate Limits| |:-----:|:-------------------------:|:--------------------------------:| | SOL | 0.00125 SOL | 0.0125 SOL | | USDC | 1 USDC | 10 USDC | + Request funds from the CDP Faucet on Solana devnet. Faucets are available for SOL, USDC, and CBTUSD. To prevent abuse, we enforce rate limits within a rolling 24-hour window to control the amount of funds that can be requested. These limits are applied at both the CDP Project level and the blockchain address level. A single blockchain address cannot exceed the specified limits, even if multiple users submit requests to the same address. | Token | Amount per Faucet Request |Rolling 24-hour window Rate Limits| |:-----: |:-------------------------:|:--------------------------------:| | SOL | 0.00125 SOL | 0.0125 SOL | | USDC | 1 USDC | 10 USDC | | CBTUSD | 1 CBTUSD | 10 CBTUSD | :param request_solana_faucet_request: :type request_solana_faucet_request: RequestSolanaFaucetRequest @@ -498,7 +498,7 @@ async def request_solana_faucet_without_preload_content( ) -> RESTResponseType: """Request funds on Solana devnet - Request funds from the CDP Faucet on Solana devnet. Faucets are available for SOL. To prevent abuse, we enforce rate limits within a rolling 24-hour window to control the amount of funds that can be requested. These limits are applied at both the CDP Project level and the blockchain address level. A single blockchain address cannot exceed the specified limits, even if multiple users submit requests to the same address. | Token | Amount per Faucet Request |Rolling 24-hour window Rate Limits| |:-----:|:-------------------------:|:--------------------------------:| | SOL | 0.00125 SOL | 0.0125 SOL | | USDC | 1 USDC | 10 USDC | + Request funds from the CDP Faucet on Solana devnet. Faucets are available for SOL, USDC, and CBTUSD. To prevent abuse, we enforce rate limits within a rolling 24-hour window to control the amount of funds that can be requested. These limits are applied at both the CDP Project level and the blockchain address level. A single blockchain address cannot exceed the specified limits, even if multiple users submit requests to the same address. | Token | Amount per Faucet Request |Rolling 24-hour window Rate Limits| |:-----: |:-------------------------:|:--------------------------------:| | SOL | 0.00125 SOL | 0.0125 SOL | | USDC | 1 USDC | 10 USDC | | CBTUSD | 1 CBTUSD | 10 CBTUSD | :param request_solana_faucet_request: :type request_solana_faucet_request: RequestSolanaFaucetRequest diff --git a/python/cdp/openapi_client/api/sqlapi_alpha_api.py b/python/cdp/openapi_client/api/sqlapi_api.py similarity index 54% rename from python/cdp/openapi_client/api/sqlapi_alpha_api.py rename to python/cdp/openapi_client/api/sqlapi_api.py index 3b71b0a07..c01c69506 100644 --- a/python/cdp/openapi_client/api/sqlapi_alpha_api.py +++ b/python/cdp/openapi_client/api/sqlapi_api.py @@ -17,16 +17,19 @@ from typing import Any, Dict, List, Optional, Tuple, Union from typing_extensions import Annotated -from pydantic import StrictStr +from pydantic import Field, StrictStr, field_validator +from typing import Optional +from typing_extensions import Annotated from cdp.openapi_client.models.onchain_data_query import OnchainDataQuery from cdp.openapi_client.models.onchain_data_result import OnchainDataResult +from cdp.openapi_client.models.onchain_data_schema_response import OnchainDataSchemaResponse from cdp.openapi_client.api_client import ApiClient, RequestSerialized from cdp.openapi_client.api_response import ApiResponse from cdp.openapi_client.rest import RESTResponseType -class SQLAPIAlphaApi: +class SQLAPIApi: """NOTE: This class is auto generated by OpenAPI Generator Ref: https://openapi-generator.tech @@ -57,7 +60,7 @@ async def get_sql_grammar( ) -> str: """Get SQL grammar - Retrieve the SQL grammar for the SQL API. The SQL queries that are supported by the SQL API are defined via an ANTLR4 grammar which is evaluated by server before executing the query. This ensures the safety and soundness of the SQL API. This endpoint returns the ANTLR4 grammar that is used to evaluate the SQL queries so that developers can understand the SQL API and build SQL queries with high confidence and correctness. LLMs interact well with ANTLR4 grammar as well. + Retrieve the SQL grammar for the SQL API. The SQL queries that are supported by the SQL API are defined in ANTLR4 grammar which is evaluated by server before executing the query. This ensures the safety and soundness of the SQL query before execution. This endpoint returns the ANTLR4 grammar that is used to evaluate the SQL queries so that developers can understand the SQL API and build SQL queries with high confidence and correctness. LLMs interact well with ANTLR4 grammar. You can feed the grammar directly into the LLMs to help generate SQL queries. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request @@ -124,7 +127,7 @@ async def get_sql_grammar_with_http_info( ) -> ApiResponse[str]: """Get SQL grammar - Retrieve the SQL grammar for the SQL API. The SQL queries that are supported by the SQL API are defined via an ANTLR4 grammar which is evaluated by server before executing the query. This ensures the safety and soundness of the SQL API. This endpoint returns the ANTLR4 grammar that is used to evaluate the SQL queries so that developers can understand the SQL API and build SQL queries with high confidence and correctness. LLMs interact well with ANTLR4 grammar as well. + Retrieve the SQL grammar for the SQL API. The SQL queries that are supported by the SQL API are defined in ANTLR4 grammar which is evaluated by server before executing the query. This ensures the safety and soundness of the SQL query before execution. This endpoint returns the ANTLR4 grammar that is used to evaluate the SQL queries so that developers can understand the SQL API and build SQL queries with high confidence and correctness. LLMs interact well with ANTLR4 grammar. You can feed the grammar directly into the LLMs to help generate SQL queries. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request @@ -191,7 +194,7 @@ async def get_sql_grammar_without_preload_content( ) -> RESTResponseType: """Get SQL grammar - Retrieve the SQL grammar for the SQL API. The SQL queries that are supported by the SQL API are defined via an ANTLR4 grammar which is evaluated by server before executing the query. This ensures the safety and soundness of the SQL API. This endpoint returns the ANTLR4 grammar that is used to evaluate the SQL queries so that developers can understand the SQL API and build SQL queries with high confidence and correctness. LLMs interact well with ANTLR4 grammar as well. + Retrieve the SQL grammar for the SQL API. The SQL queries that are supported by the SQL API are defined in ANTLR4 grammar which is evaluated by server before executing the query. This ensures the safety and soundness of the SQL query before execution. This endpoint returns the ANTLR4 grammar that is used to evaluate the SQL queries so that developers can understand the SQL API and build SQL queries with high confidence and correctness. LLMs interact well with ANTLR4 grammar. You can feed the grammar directly into the LLMs to help generate SQL queries. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request @@ -297,6 +300,292 @@ def _get_sql_grammar_serialize( + @validate_call + async def get_sql_schema( + self, + database: Annotated[Optional[StrictStr], Field(description="The name of the database to query. Defaults to \"base\" when not specified.")] = None, + table: Annotated[Optional[StrictStr], Field(description="Get the schema for a specific table.")] = 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, + ) -> OnchainDataSchemaResponse: + """Get schemas details + + Retrieve the schema information for the available tables in the SQL API's indexed data. This includes table names, column definitions, data types, and indexed fields. + + :param database: The name of the database to query. Defaults to \"base\" when not specified. + :type database: str + :param table: Get the schema for a specific table. + :type table: 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_sql_schema_serialize( + database=database, + table=table, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OnchainDataSchemaResponse", + '401': "Error", + '500': "Error", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def get_sql_schema_with_http_info( + self, + database: Annotated[Optional[StrictStr], Field(description="The name of the database to query. Defaults to \"base\" when not specified.")] = None, + table: Annotated[Optional[StrictStr], Field(description="Get the schema for a specific table.")] = 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[OnchainDataSchemaResponse]: + """Get schemas details + + Retrieve the schema information for the available tables in the SQL API's indexed data. This includes table names, column definitions, data types, and indexed fields. + + :param database: The name of the database to query. Defaults to \"base\" when not specified. + :type database: str + :param table: Get the schema for a specific table. + :type table: 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_sql_schema_serialize( + database=database, + table=table, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OnchainDataSchemaResponse", + '401': "Error", + '500': "Error", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def get_sql_schema_without_preload_content( + self, + database: Annotated[Optional[StrictStr], Field(description="The name of the database to query. Defaults to \"base\" when not specified.")] = None, + table: Annotated[Optional[StrictStr], Field(description="Get the schema for a specific table.")] = 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: + """Get schemas details + + Retrieve the schema information for the available tables in the SQL API's indexed data. This includes table names, column definitions, data types, and indexed fields. + + :param database: The name of the database to query. Defaults to \"base\" when not specified. + :type database: str + :param table: Get the schema for a specific table. + :type table: 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_sql_schema_serialize( + database=database, + table=table, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "OnchainDataSchemaResponse", + '401': "Error", + '500': "Error", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_sql_schema_serialize( + self, + database, + table, + _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 database is not None: + + _query_params.append(('database', database)) + + if table is not None: + + _query_params.append(('table', table)) + + # 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] = [ + 'apiKeyAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v2/data/query/schema', + 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 async def run_sql_query( self, @@ -316,7 +605,7 @@ async def run_sql_query( ) -> OnchainDataResult: """Run SQL Query - Run a read-only SQL query against indexed blockchain data including transactions, events, and decoded logs. This endpoint provides direct SQL access to comprehensive blockchain data across supported networks. Queries are executed against optimized data structures for high-performance analytics. ### Allowed Queries - Standard SQL syntax (ClickHouse dialect) - Read-only queries (SELECT statements) - No DDL or DML operations - No cartesian products ### Supported Tables - `base.events` - Base mainnet decoded event logs with parameters, event signature, topics, and more. - `base.transactions` - Base mainnet transaction data including hash, block number, gas usage. - `base.blocks` - Base mainnet block information. - `base.encoded_logs` - Encoded log data of event logs that aren't able to be decoded by our event decoder (ex: log0 opcode). - `base.transfers` - All event logs with event signature `Transfer(address,address,uint256)`. ERC-20, ERC-721, and ERC-1155 transfers are all included. ### Query Limits - Maximum result set: 100,000 rows - Query timeout: 30 seconds + Run a read-only SQL query against indexed blockchain data including transactions, events, and decoded logs. This endpoint provides direct SQL access to comprehensive blockchain data across supported networks. Queries are executed against optimized data structures for high-performance analytics. ### Allowed Queries - Standard SQL syntax (CoinbaSeQL dialect, based on ClickHouse dialect) - Read-only queries (SELECT statements) - No DDL or DML operations - Query that follow limits (defined below) ### Supported Tables - `.events` - Base mainnet decoded event logs with parameters, event signature, topics, and more. - `.transactions` - Base mainnet transaction data including hash, block number, gas usage. - `.blocks` - Base mainnet block information. - `.encoded_logs` - Encoded log data of event logs that aren't able to be decoded by our event decoder (ex: log0 opcode). - `.decoded_user_operations` - Decoded user operations data including hash, block number, gas usage, builder codes, entrypoint version, and more. - `.transaction_attributions` - Information about the attributions of a transaction to a builder and associated builder codes. ### Supported Networks - Base Mainnet: `base` - Base Sepolia: `base_sepolia` So for example, valid tables are: `base.events`, `base_sepolia.events`, `base.transactions`, etc. ### Query Limits - Maximum result set: 50,000 rows - Maximum query length: 10,000 characters - Maximum on-disk data to read: 100GB - Maximum memory usage: 15GB - Query timeout: 30 seconds - Maximum JOINs: 12 ### Query Caching By default, each query result is returned from cache so long as the result is from an identical query and less than 750ms old. This freshness tolerance can be modified upwards, to a maximum of 900000ms (i.e. 900s, 15m). This can be helpful for users who wish to reduce expensive calls to the SQL API by reusing cached results. :param onchain_data_query: (required) :type onchain_data_query: OnchainDataQuery @@ -354,6 +643,7 @@ async def run_sql_query( '200': "OnchainDataResult", '400': "Error", '401': "Error", + '402': "Error", '408': "Error", '429': "Error", '499': "Error", @@ -390,7 +680,7 @@ async def run_sql_query_with_http_info( ) -> ApiResponse[OnchainDataResult]: """Run SQL Query - Run a read-only SQL query against indexed blockchain data including transactions, events, and decoded logs. This endpoint provides direct SQL access to comprehensive blockchain data across supported networks. Queries are executed against optimized data structures for high-performance analytics. ### Allowed Queries - Standard SQL syntax (ClickHouse dialect) - Read-only queries (SELECT statements) - No DDL or DML operations - No cartesian products ### Supported Tables - `base.events` - Base mainnet decoded event logs with parameters, event signature, topics, and more. - `base.transactions` - Base mainnet transaction data including hash, block number, gas usage. - `base.blocks` - Base mainnet block information. - `base.encoded_logs` - Encoded log data of event logs that aren't able to be decoded by our event decoder (ex: log0 opcode). - `base.transfers` - All event logs with event signature `Transfer(address,address,uint256)`. ERC-20, ERC-721, and ERC-1155 transfers are all included. ### Query Limits - Maximum result set: 100,000 rows - Query timeout: 30 seconds + Run a read-only SQL query against indexed blockchain data including transactions, events, and decoded logs. This endpoint provides direct SQL access to comprehensive blockchain data across supported networks. Queries are executed against optimized data structures for high-performance analytics. ### Allowed Queries - Standard SQL syntax (CoinbaSeQL dialect, based on ClickHouse dialect) - Read-only queries (SELECT statements) - No DDL or DML operations - Query that follow limits (defined below) ### Supported Tables - `.events` - Base mainnet decoded event logs with parameters, event signature, topics, and more. - `.transactions` - Base mainnet transaction data including hash, block number, gas usage. - `.blocks` - Base mainnet block information. - `.encoded_logs` - Encoded log data of event logs that aren't able to be decoded by our event decoder (ex: log0 opcode). - `.decoded_user_operations` - Decoded user operations data including hash, block number, gas usage, builder codes, entrypoint version, and more. - `.transaction_attributions` - Information about the attributions of a transaction to a builder and associated builder codes. ### Supported Networks - Base Mainnet: `base` - Base Sepolia: `base_sepolia` So for example, valid tables are: `base.events`, `base_sepolia.events`, `base.transactions`, etc. ### Query Limits - Maximum result set: 50,000 rows - Maximum query length: 10,000 characters - Maximum on-disk data to read: 100GB - Maximum memory usage: 15GB - Query timeout: 30 seconds - Maximum JOINs: 12 ### Query Caching By default, each query result is returned from cache so long as the result is from an identical query and less than 750ms old. This freshness tolerance can be modified upwards, to a maximum of 900000ms (i.e. 900s, 15m). This can be helpful for users who wish to reduce expensive calls to the SQL API by reusing cached results. :param onchain_data_query: (required) :type onchain_data_query: OnchainDataQuery @@ -428,6 +718,7 @@ async def run_sql_query_with_http_info( '200': "OnchainDataResult", '400': "Error", '401': "Error", + '402': "Error", '408': "Error", '429': "Error", '499': "Error", @@ -464,7 +755,7 @@ async def run_sql_query_without_preload_content( ) -> RESTResponseType: """Run SQL Query - Run a read-only SQL query against indexed blockchain data including transactions, events, and decoded logs. This endpoint provides direct SQL access to comprehensive blockchain data across supported networks. Queries are executed against optimized data structures for high-performance analytics. ### Allowed Queries - Standard SQL syntax (ClickHouse dialect) - Read-only queries (SELECT statements) - No DDL or DML operations - No cartesian products ### Supported Tables - `base.events` - Base mainnet decoded event logs with parameters, event signature, topics, and more. - `base.transactions` - Base mainnet transaction data including hash, block number, gas usage. - `base.blocks` - Base mainnet block information. - `base.encoded_logs` - Encoded log data of event logs that aren't able to be decoded by our event decoder (ex: log0 opcode). - `base.transfers` - All event logs with event signature `Transfer(address,address,uint256)`. ERC-20, ERC-721, and ERC-1155 transfers are all included. ### Query Limits - Maximum result set: 100,000 rows - Query timeout: 30 seconds + Run a read-only SQL query against indexed blockchain data including transactions, events, and decoded logs. This endpoint provides direct SQL access to comprehensive blockchain data across supported networks. Queries are executed against optimized data structures for high-performance analytics. ### Allowed Queries - Standard SQL syntax (CoinbaSeQL dialect, based on ClickHouse dialect) - Read-only queries (SELECT statements) - No DDL or DML operations - Query that follow limits (defined below) ### Supported Tables - `.events` - Base mainnet decoded event logs with parameters, event signature, topics, and more. - `.transactions` - Base mainnet transaction data including hash, block number, gas usage. - `.blocks` - Base mainnet block information. - `.encoded_logs` - Encoded log data of event logs that aren't able to be decoded by our event decoder (ex: log0 opcode). - `.decoded_user_operations` - Decoded user operations data including hash, block number, gas usage, builder codes, entrypoint version, and more. - `.transaction_attributions` - Information about the attributions of a transaction to a builder and associated builder codes. ### Supported Networks - Base Mainnet: `base` - Base Sepolia: `base_sepolia` So for example, valid tables are: `base.events`, `base_sepolia.events`, `base.transactions`, etc. ### Query Limits - Maximum result set: 50,000 rows - Maximum query length: 10,000 characters - Maximum on-disk data to read: 100GB - Maximum memory usage: 15GB - Query timeout: 30 seconds - Maximum JOINs: 12 ### Query Caching By default, each query result is returned from cache so long as the result is from an identical query and less than 750ms old. This freshness tolerance can be modified upwards, to a maximum of 900000ms (i.e. 900s, 15m). This can be helpful for users who wish to reduce expensive calls to the SQL API by reusing cached results. :param onchain_data_query: (required) :type onchain_data_query: OnchainDataQuery @@ -502,6 +793,7 @@ async def run_sql_query_without_preload_content( '200': "OnchainDataResult", '400': "Error", '401': "Error", + '402': "Error", '408': "Error", '429': "Error", '499': "Error", diff --git a/python/cdp/openapi_client/api/webhooks_api.py b/python/cdp/openapi_client/api/webhooks_api.py index 613cbf6d5..4ac1759b3 100644 --- a/python/cdp/openapi_client/api/webhooks_api.py +++ b/python/cdp/openapi_client/api/webhooks_api.py @@ -17,9 +17,11 @@ from typing import Any, Dict, List, Optional, Tuple, Union from typing_extensions import Annotated +from datetime import datetime from pydantic import Field, StrictStr from typing import Optional from typing_extensions import Annotated +from cdp.openapi_client.models.webhook_event_list_response import WebhookEventListResponse from cdp.openapi_client.models.webhook_subscription_list_response import WebhookSubscriptionListResponse from cdp.openapi_client.models.webhook_subscription_request import WebhookSubscriptionRequest from cdp.openapi_client.models.webhook_subscription_response import WebhookSubscriptionResponse @@ -875,6 +877,368 @@ def _get_webhook_subscription_serialize( + @validate_call + async def list_webhook_subscription_events( + self, + subscription_id: Annotated[StrictStr, Field(description="Unique identifier for the webhook subscription.")], + event_id: Annotated[Optional[StrictStr], Field(description="Filter by a specific event ID.")] = None, + min_created_at: Annotated[Optional[datetime], Field(description="Filter events created at or after this timestamp (RFC 3339 format).")] = None, + max_created_at: Annotated[Optional[datetime], Field(description="Filter events created at or before this timestamp (RFC 3339 format).")] = None, + event_type_names: Annotated[Optional[StrictStr], Field(description="Filter by event type names (comma-separated).")] = 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, + ) -> WebhookEventListResponse: + """List webhook subscription events + + Retrieve webhook event delivery attempts for a specific subscription. Returns event deliveries in descending order by creation time (newest first), including delivery status, retry count, and response details. ### Use Cases - Debug webhook delivery failures and inspect response codes - Monitor delivery status and retry counts - Audit event delivery history for a subscription - Verify that expected events were sent to webhook URLs ### Filtering Use optional query parameters to narrow results: - `eventId` — find a specific event by ID - `minCreatedAt` / `maxCreatedAt` — filter by time range - `eventTypeNames` — filter by event type (comma-separated) **Note:** Results are limited to the 50 most recent events (newest first). No pagination is supported. + + :param subscription_id: Unique identifier for the webhook subscription. (required) + :type subscription_id: str + :param event_id: Filter by a specific event ID. + :type event_id: str + :param min_created_at: Filter events created at or after this timestamp (RFC 3339 format). + :type min_created_at: datetime + :param max_created_at: Filter events created at or before this timestamp (RFC 3339 format). + :type max_created_at: datetime + :param event_type_names: Filter by event type names (comma-separated). + :type event_type_names: 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_webhook_subscription_events_serialize( + subscription_id=subscription_id, + event_id=event_id, + min_created_at=min_created_at, + max_created_at=max_created_at, + event_type_names=event_type_names, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "WebhookEventListResponse", + '400': "Error", + '401': "Error", + '404': "Error", + '429': "Error", + '500': "Error", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def list_webhook_subscription_events_with_http_info( + self, + subscription_id: Annotated[StrictStr, Field(description="Unique identifier for the webhook subscription.")], + event_id: Annotated[Optional[StrictStr], Field(description="Filter by a specific event ID.")] = None, + min_created_at: Annotated[Optional[datetime], Field(description="Filter events created at or after this timestamp (RFC 3339 format).")] = None, + max_created_at: Annotated[Optional[datetime], Field(description="Filter events created at or before this timestamp (RFC 3339 format).")] = None, + event_type_names: Annotated[Optional[StrictStr], Field(description="Filter by event type names (comma-separated).")] = 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[WebhookEventListResponse]: + """List webhook subscription events + + Retrieve webhook event delivery attempts for a specific subscription. Returns event deliveries in descending order by creation time (newest first), including delivery status, retry count, and response details. ### Use Cases - Debug webhook delivery failures and inspect response codes - Monitor delivery status and retry counts - Audit event delivery history for a subscription - Verify that expected events were sent to webhook URLs ### Filtering Use optional query parameters to narrow results: - `eventId` — find a specific event by ID - `minCreatedAt` / `maxCreatedAt` — filter by time range - `eventTypeNames` — filter by event type (comma-separated) **Note:** Results are limited to the 50 most recent events (newest first). No pagination is supported. + + :param subscription_id: Unique identifier for the webhook subscription. (required) + :type subscription_id: str + :param event_id: Filter by a specific event ID. + :type event_id: str + :param min_created_at: Filter events created at or after this timestamp (RFC 3339 format). + :type min_created_at: datetime + :param max_created_at: Filter events created at or before this timestamp (RFC 3339 format). + :type max_created_at: datetime + :param event_type_names: Filter by event type names (comma-separated). + :type event_type_names: 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_webhook_subscription_events_serialize( + subscription_id=subscription_id, + event_id=event_id, + min_created_at=min_created_at, + max_created_at=max_created_at, + event_type_names=event_type_names, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "WebhookEventListResponse", + '400': "Error", + '401': "Error", + '404': "Error", + '429': "Error", + '500': "Error", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def list_webhook_subscription_events_without_preload_content( + self, + subscription_id: Annotated[StrictStr, Field(description="Unique identifier for the webhook subscription.")], + event_id: Annotated[Optional[StrictStr], Field(description="Filter by a specific event ID.")] = None, + min_created_at: Annotated[Optional[datetime], Field(description="Filter events created at or after this timestamp (RFC 3339 format).")] = None, + max_created_at: Annotated[Optional[datetime], Field(description="Filter events created at or before this timestamp (RFC 3339 format).")] = None, + event_type_names: Annotated[Optional[StrictStr], Field(description="Filter by event type names (comma-separated).")] = 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 webhook subscription events + + Retrieve webhook event delivery attempts for a specific subscription. Returns event deliveries in descending order by creation time (newest first), including delivery status, retry count, and response details. ### Use Cases - Debug webhook delivery failures and inspect response codes - Monitor delivery status and retry counts - Audit event delivery history for a subscription - Verify that expected events were sent to webhook URLs ### Filtering Use optional query parameters to narrow results: - `eventId` — find a specific event by ID - `minCreatedAt` / `maxCreatedAt` — filter by time range - `eventTypeNames` — filter by event type (comma-separated) **Note:** Results are limited to the 50 most recent events (newest first). No pagination is supported. + + :param subscription_id: Unique identifier for the webhook subscription. (required) + :type subscription_id: str + :param event_id: Filter by a specific event ID. + :type event_id: str + :param min_created_at: Filter events created at or after this timestamp (RFC 3339 format). + :type min_created_at: datetime + :param max_created_at: Filter events created at or before this timestamp (RFC 3339 format). + :type max_created_at: datetime + :param event_type_names: Filter by event type names (comma-separated). + :type event_type_names: 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_webhook_subscription_events_serialize( + subscription_id=subscription_id, + event_id=event_id, + min_created_at=min_created_at, + max_created_at=max_created_at, + event_type_names=event_type_names, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "WebhookEventListResponse", + '400': "Error", + '401': "Error", + '404': "Error", + '429': "Error", + '500': "Error", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _list_webhook_subscription_events_serialize( + self, + subscription_id, + event_id, + min_created_at, + max_created_at, + event_type_names, + _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 subscription_id is not None: + _path_params['subscriptionId'] = subscription_id + # process the query parameters + if event_id is not None: + + _query_params.append(('eventId', event_id)) + + if min_created_at is not None: + if isinstance(min_created_at, datetime): + _query_params.append( + ( + 'minCreatedAt', + min_created_at.strftime( + self.api_client.configuration.datetime_format + ) + ) + ) + else: + _query_params.append(('minCreatedAt', min_created_at)) + + if max_created_at is not None: + if isinstance(max_created_at, datetime): + _query_params.append( + ( + 'maxCreatedAt', + max_created_at.strftime( + self.api_client.configuration.datetime_format + ) + ) + ) + else: + _query_params.append(('maxCreatedAt', max_created_at)) + + if event_type_names is not None: + + _query_params.append(('eventTypeNames', event_type_names)) + + # 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] = [ + 'apiKeyAuth' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/v2/data/webhooks/subscriptions/{subscriptionId}/events', + 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 async def list_webhook_subscriptions( self, diff --git a/python/cdp/openapi_client/models/__init__.py b/python/cdp/openapi_client/models/__init__.py index 9fa7f21f4..85959b2e8 100644 --- a/python/cdp/openapi_client/models/__init__.py +++ b/python/cdp/openapi_client/models/__init__.py @@ -31,6 +31,7 @@ from cdp.openapi_client.models.common_swap_response_issues import CommonSwapResponseIssues from cdp.openapi_client.models.common_swap_response_issues_allowance import CommonSwapResponseIssuesAllowance from cdp.openapi_client.models.common_swap_response_issues_balance import CommonSwapResponseIssuesBalance +from cdp.openapi_client.models.create_end_user_evm_swap_rule import CreateEndUserEvmSwapRule from cdp.openapi_client.models.create_end_user_request import CreateEndUserRequest from cdp.openapi_client.models.create_end_user_request_evm_account import CreateEndUserRequestEvmAccount from cdp.openapi_client.models.create_end_user_request_solana_account import CreateEndUserRequestSolanaAccount @@ -120,11 +121,14 @@ from cdp.openapi_client.models.net_usd_change_criterion import NetUSDChangeCriterion from cdp.openapi_client.models.o_auth2_authentication import OAuth2Authentication from cdp.openapi_client.models.o_auth2_provider_type import OAuth2ProviderType +from cdp.openapi_client.models.onchain_data_column_schema import OnchainDataColumnSchema from cdp.openapi_client.models.onchain_data_query import OnchainDataQuery from cdp.openapi_client.models.onchain_data_result import OnchainDataResult from cdp.openapi_client.models.onchain_data_result_metadata import OnchainDataResultMetadata from cdp.openapi_client.models.onchain_data_result_schema import OnchainDataResultSchema from cdp.openapi_client.models.onchain_data_result_schema_columns_inner import OnchainDataResultSchemaColumnsInner +from cdp.openapi_client.models.onchain_data_schema_response import OnchainDataSchemaResponse +from cdp.openapi_client.models.onchain_data_table_schema import OnchainDataTableSchema from cdp.openapi_client.models.onramp_limit_type import OnrampLimitType from cdp.openapi_client.models.onramp_order import OnrampOrder from cdp.openapi_client.models.onramp_order_fee import OnrampOrderFee @@ -161,6 +165,7 @@ from cdp.openapi_client.models.send_solana_transaction_request import SendSolanaTransactionRequest from cdp.openapi_client.models.send_user_operation_request import SendUserOperationRequest from cdp.openapi_client.models.send_user_operation_rule import SendUserOperationRule +from cdp.openapi_client.models.sign_end_user_evm_hash_rule import SignEndUserEvmHashRule from cdp.openapi_client.models.sign_end_user_evm_message_rule import SignEndUserEvmMessageRule from cdp.openapi_client.models.sign_end_user_evm_transaction_rule import SignEndUserEvmTransactionRule from cdp.openapi_client.models.sign_end_user_evm_typed_data_rule import SignEndUserEvmTypedDataRule @@ -193,6 +198,7 @@ from cdp.openapi_client.models.sign_solana_message_request import SignSolanaMessageRequest from cdp.openapi_client.models.sign_solana_transaction200_response import SignSolanaTransaction200Response from cdp.openapi_client.models.sign_solana_transaction_request import SignSolanaTransactionRequest +from cdp.openapi_client.models.siwe_authentication import SiweAuthentication from cdp.openapi_client.models.sms_authentication import SmsAuthentication from cdp.openapi_client.models.sol_address_criterion import SolAddressCriterion from cdp.openapi_client.models.sol_data_condition import SolDataCondition @@ -227,6 +233,9 @@ from cdp.openapi_client.models.user_operation_receipt_revert import UserOperationReceiptRevert from cdp.openapi_client.models.validate_end_user_access_token_request import ValidateEndUserAccessTokenRequest from cdp.openapi_client.models.verify_x402_payment_request import VerifyX402PaymentRequest +from cdp.openapi_client.models.webhook_event_list_response import WebhookEventListResponse +from cdp.openapi_client.models.webhook_event_response import WebhookEventResponse +from cdp.openapi_client.models.webhook_event_response_detail import WebhookEventResponseDetail from cdp.openapi_client.models.webhook_subscription_list_response import WebhookSubscriptionListResponse from cdp.openapi_client.models.webhook_subscription_request import WebhookSubscriptionRequest from cdp.openapi_client.models.webhook_subscription_response import WebhookSubscriptionResponse @@ -247,9 +256,9 @@ from cdp.openapi_client.models.x402_settle_payment_rejection import X402SettlePaymentRejection from cdp.openapi_client.models.x402_supported_payment_kind import X402SupportedPaymentKind from cdp.openapi_client.models.x402_v1_payment_payload import X402V1PaymentPayload -from cdp.openapi_client.models.x402_v1_payment_payload_payload import X402V1PaymentPayloadPayload from cdp.openapi_client.models.x402_v1_payment_requirements import X402V1PaymentRequirements from cdp.openapi_client.models.x402_v2_payment_payload import X402V2PaymentPayload +from cdp.openapi_client.models.x402_v2_payment_payload_payload import X402V2PaymentPayloadPayload from cdp.openapi_client.models.x402_v2_payment_requirements import X402V2PaymentRequirements from cdp.openapi_client.models.x402_verify_invalid_reason import X402VerifyInvalidReason from cdp.openapi_client.models.x402_verify_payment_rejection import X402VerifyPaymentRejection diff --git a/python/cdp/openapi_client/models/authentication_method.py b/python/cdp/openapi_client/models/authentication_method.py index 1cfc8ff9e..22f1353cc 100644 --- a/python/cdp/openapi_client/models/authentication_method.py +++ b/python/cdp/openapi_client/models/authentication_method.py @@ -21,13 +21,14 @@ from cdp.openapi_client.models.developer_jwt_authentication import DeveloperJWTAuthentication from cdp.openapi_client.models.email_authentication import EmailAuthentication from cdp.openapi_client.models.o_auth2_authentication import OAuth2Authentication +from cdp.openapi_client.models.siwe_authentication import SiweAuthentication from cdp.openapi_client.models.sms_authentication import SmsAuthentication from cdp.openapi_client.models.telegram_authentication import TelegramAuthentication from pydantic import StrictStr, Field from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self -AUTHENTICATIONMETHOD_ONE_OF_SCHEMAS = ["DeveloperJWTAuthentication", "EmailAuthentication", "OAuth2Authentication", "SmsAuthentication", "TelegramAuthentication"] +AUTHENTICATIONMETHOD_ONE_OF_SCHEMAS = ["DeveloperJWTAuthentication", "EmailAuthentication", "OAuth2Authentication", "SiweAuthentication", "SmsAuthentication", "TelegramAuthentication"] class AuthenticationMethod(BaseModel): """ @@ -43,8 +44,10 @@ class AuthenticationMethod(BaseModel): oneof_schema_4_validator: Optional[OAuth2Authentication] = None # data type: TelegramAuthentication oneof_schema_5_validator: Optional[TelegramAuthentication] = None - actual_instance: Optional[Union[DeveloperJWTAuthentication, EmailAuthentication, OAuth2Authentication, SmsAuthentication, TelegramAuthentication]] = None - one_of_schemas: Set[str] = { "DeveloperJWTAuthentication", "EmailAuthentication", "OAuth2Authentication", "SmsAuthentication", "TelegramAuthentication" } + # data type: SiweAuthentication + oneof_schema_6_validator: Optional[SiweAuthentication] = None + actual_instance: Optional[Union[DeveloperJWTAuthentication, EmailAuthentication, OAuth2Authentication, SiweAuthentication, SmsAuthentication, TelegramAuthentication]] = None + one_of_schemas: Set[str] = { "DeveloperJWTAuthentication", "EmailAuthentication", "OAuth2Authentication", "SiweAuthentication", "SmsAuthentication", "TelegramAuthentication" } model_config = ConfigDict( validate_assignment=True, @@ -92,12 +95,17 @@ def actual_instance_must_validate_oneof(cls, v): error_messages.append(f"Error! Input type `{type(v)}` is not `TelegramAuthentication`") else: match += 1 + # validate data type: SiweAuthentication + if not isinstance(v, SiweAuthentication): + error_messages.append(f"Error! Input type `{type(v)}` is not `SiweAuthentication`") + else: + match += 1 if match > 1: # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in AuthenticationMethod with oneOf schemas: DeveloperJWTAuthentication, EmailAuthentication, OAuth2Authentication, SmsAuthentication, TelegramAuthentication. Details: " + ", ".join(error_messages)) + raise ValueError("Multiple matches found when setting `actual_instance` in AuthenticationMethod with oneOf schemas: DeveloperJWTAuthentication, EmailAuthentication, OAuth2Authentication, SiweAuthentication, SmsAuthentication, TelegramAuthentication. Details: " + ", ".join(error_messages)) elif match == 0: # no match - raise ValueError("No match found when setting `actual_instance` in AuthenticationMethod with oneOf schemas: DeveloperJWTAuthentication, EmailAuthentication, OAuth2Authentication, SmsAuthentication, TelegramAuthentication. Details: " + ", ".join(error_messages)) + raise ValueError("No match found when setting `actual_instance` in AuthenticationMethod with oneOf schemas: DeveloperJWTAuthentication, EmailAuthentication, OAuth2Authentication, SiweAuthentication, SmsAuthentication, TelegramAuthentication. Details: " + ", ".join(error_messages)) else: return v @@ -142,13 +150,19 @@ def from_json(cls, json_str: str) -> Self: match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) + # deserialize data into SiweAuthentication + try: + instance.actual_instance = SiweAuthentication.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) if match > 1: # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into AuthenticationMethod with oneOf schemas: DeveloperJWTAuthentication, EmailAuthentication, OAuth2Authentication, SmsAuthentication, TelegramAuthentication. Details: " + ", ".join(error_messages)) + raise ValueError("Multiple matches found when deserializing the JSON string into AuthenticationMethod with oneOf schemas: DeveloperJWTAuthentication, EmailAuthentication, OAuth2Authentication, SiweAuthentication, SmsAuthentication, TelegramAuthentication. Details: " + ", ".join(error_messages)) elif match == 0: # no match - raise ValueError("No match found when deserializing the JSON string into AuthenticationMethod with oneOf schemas: DeveloperJWTAuthentication, EmailAuthentication, OAuth2Authentication, SmsAuthentication, TelegramAuthentication. Details: " + ", ".join(error_messages)) + raise ValueError("No match found when deserializing the JSON string into AuthenticationMethod with oneOf schemas: DeveloperJWTAuthentication, EmailAuthentication, OAuth2Authentication, SiweAuthentication, SmsAuthentication, TelegramAuthentication. Details: " + ", ".join(error_messages)) else: return instance @@ -162,7 +176,7 @@ def to_json(self) -> str: else: return json.dumps(self.actual_instance) - def to_dict(self) -> Optional[Union[Dict[str, Any], DeveloperJWTAuthentication, EmailAuthentication, OAuth2Authentication, SmsAuthentication, TelegramAuthentication]]: + def to_dict(self) -> Optional[Union[Dict[str, Any], DeveloperJWTAuthentication, EmailAuthentication, OAuth2Authentication, SiweAuthentication, SmsAuthentication, TelegramAuthentication]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None diff --git a/python/cdp/openapi_client/models/create_end_user_evm_swap_rule.py b/python/cdp/openapi_client/models/create_end_user_evm_swap_rule.py new file mode 100644 index 000000000..8a94fb262 --- /dev/null +++ b/python/cdp/openapi_client/models/create_end_user_evm_swap_rule.py @@ -0,0 +1,114 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + 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 +from cdp.openapi_client.models.send_evm_transaction_criteria_inner import SendEvmTransactionCriteriaInner +from typing import Optional, Set +from typing_extensions import Self + +class CreateEndUserEvmSwapRule(BaseModel): + """ + CreateEndUserEvmSwapRule + """ # noqa: E501 + action: StrictStr = Field(description="Whether matching the rule will cause the request to be rejected or accepted.") + operation: StrictStr = Field(description="The operation to which the rule applies. Every element of the `criteria` array must match the specified operation.") + criteria: List[SendEvmTransactionCriteriaInner] = Field(description="A schema for specifying criteria for the createEndUserEvmSwap operation.") + __properties: ClassVar[List[str]] = ["action", "operation", "criteria"] + + @field_validator('action') + def action_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['reject', 'accept']): + raise ValueError("must be one of enum values ('reject', 'accept')") + return value + + @field_validator('operation') + def operation_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['createEndUserEvmSwap']): + raise ValueError("must be one of enum values ('createEndUserEvmSwap')") + 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 CreateEndUserEvmSwapRule 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 criteria (list) + _items = [] + if self.criteria: + for _item_criteria in self.criteria: + if _item_criteria: + _items.append(_item_criteria.to_dict()) + _dict['criteria'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CreateEndUserEvmSwapRule from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "action": obj.get("action"), + "operation": obj.get("operation"), + "criteria": [SendEvmTransactionCriteriaInner.from_dict(_item) for _item in obj["criteria"]] if obj.get("criteria") is not None else None + }) + return _obj + + diff --git a/python/cdp/openapi_client/models/error_type.py b/python/cdp/openapi_client/models/error_type.py index a83d1c314..3f6c9d42a 100644 --- a/python/cdp/openapi_client/models/error_type.py +++ b/python/cdp/openapi_client/models/error_type.py @@ -85,6 +85,9 @@ class ErrorType(str, Enum): ORDER_ALREADY_FILLED = 'order_already_filled' ORDER_ALREADY_CANCELED = 'order_already_canceled' ACCOUNT_NOT_READY = 'account_not_ready' + INSUFFICIENT_LIQUIDITY = 'insufficient_liquidity' + INSUFFICIENT_ALLOWANCE = 'insufficient_allowance' + TRANSACTION_SIMULATION_FAILED = 'transaction_simulation_failed' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/python/cdp/openapi_client/models/inline_object1.py b/python/cdp/openapi_client/models/inline_object1.py index ad8f7c859..99f661acf 100644 --- a/python/cdp/openapi_client/models/inline_object1.py +++ b/python/cdp/openapi_client/models/inline_object1.py @@ -35,7 +35,8 @@ class InlineObject1(BaseModel): payer: Annotated[str, Field(strict=True)] = Field(description="The onchain address of the client that is paying for the resource. For EVM networks, the payer will be a 0x-prefixed, checksum EVM address. For Solana-based networks, the payer will be a base58-encoded Solana address.") transaction: Annotated[str, Field(strict=True)] = Field(description="The transaction of the settlement. For EVM networks, the transaction will be a 0x-prefixed, EVM transaction hash. For Solana-based networks, the transaction will be a base58-encoded Solana signature.") network: StrictStr = Field(description="The network where the settlement occurred.") - __properties: ClassVar[List[str]] = ["success", "errorReason", "errorMessage", "payer", "transaction", "network"] + amount: Optional[StrictStr] = Field(default=None, description="The amount that was settled, in atomic units.") + __properties: ClassVar[List[str]] = ["success", "errorReason", "errorMessage", "payer", "transaction", "network", "amount"] @field_validator('payer') def payer_validate_regular_expression(cls, value): @@ -107,7 +108,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "errorMessage": obj.get("errorMessage"), "payer": obj.get("payer"), "transaction": obj.get("transaction"), - "network": obj.get("network") + "network": obj.get("network"), + "amount": obj.get("amount") }) return _obj diff --git a/python/cdp/openapi_client/models/o_auth2_provider_type.py b/python/cdp/openapi_client/models/o_auth2_provider_type.py index eb6a6dcf5..f7b6c120a 100644 --- a/python/cdp/openapi_client/models/o_auth2_provider_type.py +++ b/python/cdp/openapi_client/models/o_auth2_provider_type.py @@ -31,6 +31,7 @@ class OAuth2ProviderType(str, Enum): APPLE = 'apple' X = 'x' TELEGRAM = 'telegram' + GITHUB = 'github' @classmethod def from_json(cls, json_str: str) -> Self: diff --git a/python/cdp/openapi_client/models/onchain_data_column_schema.py b/python/cdp/openapi_client/models/onchain_data_column_schema.py new file mode 100644 index 000000000..8a874593a --- /dev/null +++ b/python/cdp/openapi_client/models/onchain_data_column_schema.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + 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, Optional +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class OnchainDataColumnSchema(BaseModel): + """ + Schema definition for a table column. + """ # noqa: E501 + name: Optional[StrictStr] = Field(default=None, description="Column name.") + type: Optional[StrictStr] = Field(default=None, description="Column data type.") + nullable: Optional[StrictBool] = Field(default=None, description="Whether this column can contain NULL values.") + description: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=500)]] = Field(default=None, description="Human-readable description of the column.") + index_order: Optional[StrictInt] = Field(default=None, description="The order of the column in the index. A lower number means the column is more important for the index and should be first in the query.", alias="indexOrder") + __properties: ClassVar[List[str]] = ["name", "type", "nullable", "description", "indexOrder"] + + 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 OnchainDataColumnSchema 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 OnchainDataColumnSchema from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "name": obj.get("name"), + "type": obj.get("type"), + "nullable": obj.get("nullable"), + "description": obj.get("description"), + "indexOrder": obj.get("indexOrder") + }) + return _obj + + diff --git a/python/cdp/openapi_client/models/onchain_data_schema_response.py b/python/cdp/openapi_client/models/onchain_data_schema_response.py new file mode 100644 index 000000000..cd059de0b --- /dev/null +++ b/python/cdp/openapi_client/models/onchain_data_schema_response.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + 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, Optional +from cdp.openapi_client.models.onchain_data_table_schema import OnchainDataTableSchema +from typing import Optional, Set +from typing_extensions import Self + +class OnchainDataSchemaResponse(BaseModel): + """ + Schema information for available blockchain data tables. + """ # noqa: E501 + tables: Optional[List[OnchainDataTableSchema]] = Field(default=None, description="List of available tables.") + __properties: ClassVar[List[str]] = ["tables"] + + 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 OnchainDataSchemaResponse 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 tables (list) + _items = [] + if self.tables: + for _item_tables in self.tables: + if _item_tables: + _items.append(_item_tables.to_dict()) + _dict['tables'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OnchainDataSchemaResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "tables": [OnchainDataTableSchema.from_dict(_item) for _item in obj["tables"]] if obj.get("tables") is not None else None + }) + return _obj + + diff --git a/python/cdp/openapi_client/models/onchain_data_table_schema.py b/python/cdp/openapi_client/models/onchain_data_table_schema.py new file mode 100644 index 000000000..255f9902e --- /dev/null +++ b/python/cdp/openapi_client/models/onchain_data_table_schema.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + 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 cdp.openapi_client.models.onchain_data_column_schema import OnchainDataColumnSchema +from typing import Optional, Set +from typing_extensions import Self + +class OnchainDataTableSchema(BaseModel): + """ + Schema definition for a data table. + """ # noqa: E501 + database: Optional[StrictStr] = Field(default=None, description="The blockchain network database this table belongs to.") + table: Optional[StrictStr] = Field(default=None, description="Table name.") + columns: Optional[List[OnchainDataColumnSchema]] = Field(default=None, description="Column definitions for this table.") + __properties: ClassVar[List[str]] = ["database", "table", "columns"] + + 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 OnchainDataTableSchema 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 columns (list) + _items = [] + if self.columns: + for _item_columns in self.columns: + if _item_columns: + _items.append(_item_columns.to_dict()) + _dict['columns'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of OnchainDataTableSchema from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "database": obj.get("database"), + "table": obj.get("table"), + "columns": [OnchainDataColumnSchema.from_dict(_item) for _item in obj["columns"]] if obj.get("columns") is not None else None + }) + return _obj + + diff --git a/python/cdp/openapi_client/models/request_solana_faucet_request.py b/python/cdp/openapi_client/models/request_solana_faucet_request.py index 21a349ddf..1dc2b0e3d 100644 --- a/python/cdp/openapi_client/models/request_solana_faucet_request.py +++ b/python/cdp/openapi_client/models/request_solana_faucet_request.py @@ -42,8 +42,8 @@ def address_validate_regular_expression(cls, value): @field_validator('token') def token_validate_enum(cls, value): """Validates the enum""" - if value not in set(['sol', 'usdc']): - raise ValueError("must be one of enum values ('sol', 'usdc')") + if value not in set(['sol', 'usdc', 'cbtusd']): + raise ValueError("must be one of enum values ('sol', 'usdc', 'cbtusd')") return value model_config = ConfigDict( diff --git a/python/cdp/openapi_client/models/rule.py b/python/cdp/openapi_client/models/rule.py index 83408a6cb..499237fc3 100644 --- a/python/cdp/openapi_client/models/rule.py +++ b/python/cdp/openapi_client/models/rule.py @@ -18,12 +18,14 @@ import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional +from cdp.openapi_client.models.create_end_user_evm_swap_rule import CreateEndUserEvmSwapRule from cdp.openapi_client.models.prepare_user_operation_rule import PrepareUserOperationRule from cdp.openapi_client.models.send_end_user_evm_transaction_rule import SendEndUserEvmTransactionRule from cdp.openapi_client.models.send_end_user_sol_transaction_rule import SendEndUserSolTransactionRule from cdp.openapi_client.models.send_evm_transaction_rule import SendEvmTransactionRule from cdp.openapi_client.models.send_sol_transaction_rule import SendSolTransactionRule from cdp.openapi_client.models.send_user_operation_rule import SendUserOperationRule +from cdp.openapi_client.models.sign_end_user_evm_hash_rule import SignEndUserEvmHashRule from cdp.openapi_client.models.sign_end_user_evm_message_rule import SignEndUserEvmMessageRule from cdp.openapi_client.models.sign_end_user_evm_transaction_rule import SignEndUserEvmTransactionRule from cdp.openapi_client.models.sign_end_user_evm_typed_data_rule import SignEndUserEvmTypedDataRule @@ -39,7 +41,7 @@ from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self -RULE_ONE_OF_SCHEMAS = ["PrepareUserOperationRule", "SendEndUserEvmTransactionRule", "SendEndUserSolTransactionRule", "SendEvmTransactionRule", "SendSolTransactionRule", "SendUserOperationRule", "SignEndUserEvmMessageRule", "SignEndUserEvmTransactionRule", "SignEndUserEvmTypedDataRule", "SignEndUserSolMessageRule", "SignEndUserSolTransactionRule", "SignEvmHashRule", "SignEvmMessageRule", "SignEvmTransactionRule", "SignEvmTypedDataRule", "SignSolMessageRule", "SignSolTransactionRule"] +RULE_ONE_OF_SCHEMAS = ["CreateEndUserEvmSwapRule", "PrepareUserOperationRule", "SendEndUserEvmTransactionRule", "SendEndUserSolTransactionRule", "SendEvmTransactionRule", "SendSolTransactionRule", "SendUserOperationRule", "SignEndUserEvmHashRule", "SignEndUserEvmMessageRule", "SignEndUserEvmTransactionRule", "SignEndUserEvmTypedDataRule", "SignEndUserSolMessageRule", "SignEndUserSolTransactionRule", "SignEvmHashRule", "SignEvmMessageRule", "SignEvmTransactionRule", "SignEvmTypedDataRule", "SignSolMessageRule", "SignSolTransactionRule"] class Rule(BaseModel): """ @@ -73,14 +75,18 @@ class Rule(BaseModel): oneof_schema_13_validator: Optional[SignEndUserEvmMessageRule] = None # data type: SignEndUserEvmTypedDataRule oneof_schema_14_validator: Optional[SignEndUserEvmTypedDataRule] = None + # data type: SignEndUserEvmHashRule + oneof_schema_15_validator: Optional[SignEndUserEvmHashRule] = None # data type: SignEndUserSolTransactionRule - oneof_schema_15_validator: Optional[SignEndUserSolTransactionRule] = None + oneof_schema_16_validator: Optional[SignEndUserSolTransactionRule] = None # data type: SendEndUserSolTransactionRule - oneof_schema_16_validator: Optional[SendEndUserSolTransactionRule] = None + oneof_schema_17_validator: Optional[SendEndUserSolTransactionRule] = None # data type: SignEndUserSolMessageRule - oneof_schema_17_validator: Optional[SignEndUserSolMessageRule] = None - actual_instance: Optional[Union[PrepareUserOperationRule, SendEndUserEvmTransactionRule, SendEndUserSolTransactionRule, SendEvmTransactionRule, SendSolTransactionRule, SendUserOperationRule, SignEndUserEvmMessageRule, SignEndUserEvmTransactionRule, SignEndUserEvmTypedDataRule, SignEndUserSolMessageRule, SignEndUserSolTransactionRule, SignEvmHashRule, SignEvmMessageRule, SignEvmTransactionRule, SignEvmTypedDataRule, SignSolMessageRule, SignSolTransactionRule]] = None - one_of_schemas: Set[str] = { "PrepareUserOperationRule", "SendEndUserEvmTransactionRule", "SendEndUserSolTransactionRule", "SendEvmTransactionRule", "SendSolTransactionRule", "SendUserOperationRule", "SignEndUserEvmMessageRule", "SignEndUserEvmTransactionRule", "SignEndUserEvmTypedDataRule", "SignEndUserSolMessageRule", "SignEndUserSolTransactionRule", "SignEvmHashRule", "SignEvmMessageRule", "SignEvmTransactionRule", "SignEvmTypedDataRule", "SignSolMessageRule", "SignSolTransactionRule" } + oneof_schema_18_validator: Optional[SignEndUserSolMessageRule] = None + # data type: CreateEndUserEvmSwapRule + oneof_schema_19_validator: Optional[CreateEndUserEvmSwapRule] = None + actual_instance: Optional[Union[CreateEndUserEvmSwapRule, PrepareUserOperationRule, SendEndUserEvmTransactionRule, SendEndUserSolTransactionRule, SendEvmTransactionRule, SendSolTransactionRule, SendUserOperationRule, SignEndUserEvmHashRule, SignEndUserEvmMessageRule, SignEndUserEvmTransactionRule, SignEndUserEvmTypedDataRule, SignEndUserSolMessageRule, SignEndUserSolTransactionRule, SignEvmHashRule, SignEvmMessageRule, SignEvmTransactionRule, SignEvmTypedDataRule, SignSolMessageRule, SignSolTransactionRule]] = None + one_of_schemas: Set[str] = { "CreateEndUserEvmSwapRule", "PrepareUserOperationRule", "SendEndUserEvmTransactionRule", "SendEndUserSolTransactionRule", "SendEvmTransactionRule", "SendSolTransactionRule", "SendUserOperationRule", "SignEndUserEvmHashRule", "SignEndUserEvmMessageRule", "SignEndUserEvmTransactionRule", "SignEndUserEvmTypedDataRule", "SignEndUserSolMessageRule", "SignEndUserSolTransactionRule", "SignEvmHashRule", "SignEvmMessageRule", "SignEvmTransactionRule", "SignEvmTypedDataRule", "SignSolMessageRule", "SignSolTransactionRule" } model_config = ConfigDict( validate_assignment=True, @@ -173,6 +179,11 @@ def actual_instance_must_validate_oneof(cls, v): error_messages.append(f"Error! Input type `{type(v)}` is not `SignEndUserEvmTypedDataRule`") else: match += 1 + # validate data type: SignEndUserEvmHashRule + if not isinstance(v, SignEndUserEvmHashRule): + error_messages.append(f"Error! Input type `{type(v)}` is not `SignEndUserEvmHashRule`") + else: + match += 1 # validate data type: SignEndUserSolTransactionRule if not isinstance(v, SignEndUserSolTransactionRule): error_messages.append(f"Error! Input type `{type(v)}` is not `SignEndUserSolTransactionRule`") @@ -188,12 +199,17 @@ def actual_instance_must_validate_oneof(cls, v): error_messages.append(f"Error! Input type `{type(v)}` is not `SignEndUserSolMessageRule`") else: match += 1 + # validate data type: CreateEndUserEvmSwapRule + if not isinstance(v, CreateEndUserEvmSwapRule): + error_messages.append(f"Error! Input type `{type(v)}` is not `CreateEndUserEvmSwapRule`") + else: + match += 1 if match > 1: # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in Rule with oneOf schemas: PrepareUserOperationRule, SendEndUserEvmTransactionRule, SendEndUserSolTransactionRule, SendEvmTransactionRule, SendSolTransactionRule, SendUserOperationRule, SignEndUserEvmMessageRule, SignEndUserEvmTransactionRule, SignEndUserEvmTypedDataRule, SignEndUserSolMessageRule, SignEndUserSolTransactionRule, SignEvmHashRule, SignEvmMessageRule, SignEvmTransactionRule, SignEvmTypedDataRule, SignSolMessageRule, SignSolTransactionRule. Details: " + ", ".join(error_messages)) + raise ValueError("Multiple matches found when setting `actual_instance` in Rule with oneOf schemas: CreateEndUserEvmSwapRule, PrepareUserOperationRule, SendEndUserEvmTransactionRule, SendEndUserSolTransactionRule, SendEvmTransactionRule, SendSolTransactionRule, SendUserOperationRule, SignEndUserEvmHashRule, SignEndUserEvmMessageRule, SignEndUserEvmTransactionRule, SignEndUserEvmTypedDataRule, SignEndUserSolMessageRule, SignEndUserSolTransactionRule, SignEvmHashRule, SignEvmMessageRule, SignEvmTransactionRule, SignEvmTypedDataRule, SignSolMessageRule, SignSolTransactionRule. Details: " + ", ".join(error_messages)) elif match == 0: # no match - raise ValueError("No match found when setting `actual_instance` in Rule with oneOf schemas: PrepareUserOperationRule, SendEndUserEvmTransactionRule, SendEndUserSolTransactionRule, SendEvmTransactionRule, SendSolTransactionRule, SendUserOperationRule, SignEndUserEvmMessageRule, SignEndUserEvmTransactionRule, SignEndUserEvmTypedDataRule, SignEndUserSolMessageRule, SignEndUserSolTransactionRule, SignEvmHashRule, SignEvmMessageRule, SignEvmTransactionRule, SignEvmTypedDataRule, SignSolMessageRule, SignSolTransactionRule. Details: " + ", ".join(error_messages)) + raise ValueError("No match found when setting `actual_instance` in Rule with oneOf schemas: CreateEndUserEvmSwapRule, PrepareUserOperationRule, SendEndUserEvmTransactionRule, SendEndUserSolTransactionRule, SendEvmTransactionRule, SendSolTransactionRule, SendUserOperationRule, SignEndUserEvmHashRule, SignEndUserEvmMessageRule, SignEndUserEvmTransactionRule, SignEndUserEvmTypedDataRule, SignEndUserSolMessageRule, SignEndUserSolTransactionRule, SignEvmHashRule, SignEvmMessageRule, SignEvmTransactionRule, SignEvmTypedDataRule, SignSolMessageRule, SignSolTransactionRule. Details: " + ", ".join(error_messages)) else: return v @@ -292,6 +308,12 @@ def from_json(cls, json_str: str) -> Self: match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) + # deserialize data into SignEndUserEvmHashRule + try: + instance.actual_instance = SignEndUserEvmHashRule.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) # deserialize data into SignEndUserSolTransactionRule try: instance.actual_instance = SignEndUserSolTransactionRule.from_json(json_str) @@ -310,13 +332,19 @@ def from_json(cls, json_str: str) -> Self: match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) + # deserialize data into CreateEndUserEvmSwapRule + try: + instance.actual_instance = CreateEndUserEvmSwapRule.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) if match > 1: # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into Rule with oneOf schemas: PrepareUserOperationRule, SendEndUserEvmTransactionRule, SendEndUserSolTransactionRule, SendEvmTransactionRule, SendSolTransactionRule, SendUserOperationRule, SignEndUserEvmMessageRule, SignEndUserEvmTransactionRule, SignEndUserEvmTypedDataRule, SignEndUserSolMessageRule, SignEndUserSolTransactionRule, SignEvmHashRule, SignEvmMessageRule, SignEvmTransactionRule, SignEvmTypedDataRule, SignSolMessageRule, SignSolTransactionRule. Details: " + ", ".join(error_messages)) + raise ValueError("Multiple matches found when deserializing the JSON string into Rule with oneOf schemas: CreateEndUserEvmSwapRule, PrepareUserOperationRule, SendEndUserEvmTransactionRule, SendEndUserSolTransactionRule, SendEvmTransactionRule, SendSolTransactionRule, SendUserOperationRule, SignEndUserEvmHashRule, SignEndUserEvmMessageRule, SignEndUserEvmTransactionRule, SignEndUserEvmTypedDataRule, SignEndUserSolMessageRule, SignEndUserSolTransactionRule, SignEvmHashRule, SignEvmMessageRule, SignEvmTransactionRule, SignEvmTypedDataRule, SignSolMessageRule, SignSolTransactionRule. Details: " + ", ".join(error_messages)) elif match == 0: # no match - raise ValueError("No match found when deserializing the JSON string into Rule with oneOf schemas: PrepareUserOperationRule, SendEndUserEvmTransactionRule, SendEndUserSolTransactionRule, SendEvmTransactionRule, SendSolTransactionRule, SendUserOperationRule, SignEndUserEvmMessageRule, SignEndUserEvmTransactionRule, SignEndUserEvmTypedDataRule, SignEndUserSolMessageRule, SignEndUserSolTransactionRule, SignEvmHashRule, SignEvmMessageRule, SignEvmTransactionRule, SignEvmTypedDataRule, SignSolMessageRule, SignSolTransactionRule. Details: " + ", ".join(error_messages)) + raise ValueError("No match found when deserializing the JSON string into Rule with oneOf schemas: CreateEndUserEvmSwapRule, PrepareUserOperationRule, SendEndUserEvmTransactionRule, SendEndUserSolTransactionRule, SendEvmTransactionRule, SendSolTransactionRule, SendUserOperationRule, SignEndUserEvmHashRule, SignEndUserEvmMessageRule, SignEndUserEvmTransactionRule, SignEndUserEvmTypedDataRule, SignEndUserSolMessageRule, SignEndUserSolTransactionRule, SignEvmHashRule, SignEvmMessageRule, SignEvmTransactionRule, SignEvmTypedDataRule, SignSolMessageRule, SignSolTransactionRule. Details: " + ", ".join(error_messages)) else: return instance @@ -330,7 +358,7 @@ def to_json(self) -> str: else: return json.dumps(self.actual_instance) - def to_dict(self) -> Optional[Union[Dict[str, Any], PrepareUserOperationRule, SendEndUserEvmTransactionRule, SendEndUserSolTransactionRule, SendEvmTransactionRule, SendSolTransactionRule, SendUserOperationRule, SignEndUserEvmMessageRule, SignEndUserEvmTransactionRule, SignEndUserEvmTypedDataRule, SignEndUserSolMessageRule, SignEndUserSolTransactionRule, SignEvmHashRule, SignEvmMessageRule, SignEvmTransactionRule, SignEvmTypedDataRule, SignSolMessageRule, SignSolTransactionRule]]: + def to_dict(self) -> Optional[Union[Dict[str, Any], CreateEndUserEvmSwapRule, PrepareUserOperationRule, SendEndUserEvmTransactionRule, SendEndUserSolTransactionRule, SendEvmTransactionRule, SendSolTransactionRule, SendUserOperationRule, SignEndUserEvmHashRule, SignEndUserEvmMessageRule, SignEndUserEvmTransactionRule, SignEndUserEvmTypedDataRule, SignEndUserSolMessageRule, SignEndUserSolTransactionRule, SignEvmHashRule, SignEvmMessageRule, SignEvmTransactionRule, SignEvmTypedDataRule, SignSolMessageRule, SignSolTransactionRule]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None diff --git a/python/cdp/openapi_client/models/sign_end_user_evm_hash_rule.py b/python/cdp/openapi_client/models/sign_end_user_evm_hash_rule.py new file mode 100644 index 000000000..9410b465b --- /dev/null +++ b/python/cdp/openapi_client/models/sign_end_user_evm_hash_rule.py @@ -0,0 +1,104 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + 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 +from typing import Optional, Set +from typing_extensions import Self + +class SignEndUserEvmHashRule(BaseModel): + """ + SignEndUserEvmHashRule + """ # noqa: E501 + action: StrictStr = Field(description="Whether any attempts to sign a hash will be accepted or rejected. This rule does not accept any criteria.") + operation: StrictStr = Field(description="The operation to which the rule applies.") + __properties: ClassVar[List[str]] = ["action", "operation"] + + @field_validator('action') + def action_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['reject', 'accept']): + raise ValueError("must be one of enum values ('reject', 'accept')") + return value + + @field_validator('operation') + def operation_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['signEndUserEvmHash']): + raise ValueError("must be one of enum values ('signEndUserEvmHash')") + 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 SignEndUserEvmHashRule 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 SignEndUserEvmHashRule from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "action": obj.get("action"), + "operation": obj.get("operation") + }) + return _obj + + diff --git a/python/cdp/openapi_client/models/siwe_authentication.py b/python/cdp/openapi_client/models/siwe_authentication.py new file mode 100644 index 000000000..c4d460be2 --- /dev/null +++ b/python/cdp/openapi_client/models/siwe_authentication.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + 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 +from typing_extensions import Annotated +from typing import Optional, Set +from typing_extensions import Self + +class SiweAuthentication(BaseModel): + """ + Information about an end user who authenticates using Sign In With Ethereum (EIP-4361). + """ # noqa: E501 + type: StrictStr = Field(description="The type of authentication information.") + address: Annotated[str, Field(min_length=1, strict=True, max_length=128)] = Field(description="The ERC-55 checksummed Ethereum address of the end user.") + __properties: ClassVar[List[str]] = ["type", "address"] + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['siwe']): + raise ValueError("must be one of enum values ('siwe')") + 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 SiweAuthentication 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 SiweAuthentication from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type"), + "address": obj.get("address") + }) + return _obj + + diff --git a/python/cdp/openapi_client/models/webhook_event_list_response.py b/python/cdp/openapi_client/models/webhook_event_list_response.py new file mode 100644 index 000000000..82c21b4a4 --- /dev/null +++ b/python/cdp/openapi_client/models/webhook_event_list_response.py @@ -0,0 +1,96 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + 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.openapi_client.models.webhook_event_response import WebhookEventResponse +from typing import Optional, Set +from typing_extensions import Self + +class WebhookEventListResponse(BaseModel): + """ + Response containing a list of webhook event delivery attempts. + """ # noqa: E501 + events: List[WebhookEventResponse] = Field(description="The list of webhook event delivery attempts.") + __properties: ClassVar[List[str]] = ["events"] + + 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 WebhookEventListResponse 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 events (list) + _items = [] + if self.events: + for _item_events in self.events: + if _item_events: + _items.append(_item_events.to_dict()) + _dict['events'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WebhookEventListResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "events": [WebhookEventResponse.from_dict(_item) for _item in obj["events"]] if obj.get("events") is not None else None + }) + return _obj + + diff --git a/python/cdp/openapi_client/models/webhook_event_response.py b/python/cdp/openapi_client/models/webhook_event_response.py new file mode 100644 index 000000000..e8509bb35 --- /dev/null +++ b/python/cdp/openapi_client/models/webhook_event_response.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + 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 datetime import datetime +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from cdp.openapi_client.models.webhook_event_response_detail import WebhookEventResponseDetail +from typing import Optional, Set +from typing_extensions import Self + +class WebhookEventResponse(BaseModel): + """ + Details of a webhook event delivery attempt for a subscription. + """ # noqa: E501 + event_id: StrictStr = Field(description="Unique identifier for the webhook event.", alias="eventId") + event_type_name: StrictStr = Field(description="The type of event that was delivered (e.g., \"onchain.activity.detected\").", alias="eventTypeName") + status: StrictStr = Field(description="Current delivery status of the event.") + created_at: datetime = Field(description="Timestamp when the event delivery attempt was created.", alias="createdAt") + succeeded_at: Optional[datetime] = Field(default=None, description="Timestamp when the event was successfully delivered. Only present if status is \"succeeded\".", alias="succeededAt") + retry_count: StrictInt = Field(description="Number of delivery retry attempts so far.", alias="retryCount") + response: Optional[WebhookEventResponseDetail] = None + __properties: ClassVar[List[str]] = ["eventId", "eventTypeName", "status", "createdAt", "succeededAt", "retryCount", "response"] + + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['pending', 'processing', 'succeeded', 'failed', 'retrying']): + raise ValueError("must be one of enum values ('pending', 'processing', 'succeeded', 'failed', 'retrying')") + 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 WebhookEventResponse 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 response + if self.response: + _dict['response'] = self.response.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WebhookEventResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "eventId": obj.get("eventId"), + "eventTypeName": obj.get("eventTypeName"), + "status": obj.get("status"), + "createdAt": obj.get("createdAt"), + "succeededAt": obj.get("succeededAt"), + "retryCount": obj.get("retryCount"), + "response": WebhookEventResponseDetail.from_dict(obj["response"]) if obj.get("response") is not None else None + }) + return _obj + + diff --git a/python/cdp/openapi_client/models/webhook_event_response_detail.py b/python/cdp/openapi_client/models/webhook_event_response_detail.py new file mode 100644 index 000000000..06d9ce40f --- /dev/null +++ b/python/cdp/openapi_client/models/webhook_event_response_detail.py @@ -0,0 +1,94 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + 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, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class WebhookEventResponseDetail(BaseModel): + """ + Details of the HTTP response received from the webhook target. + """ # noqa: E501 + http_code: Optional[StrictInt] = Field(default=None, description="HTTP status code returned by the webhook target.", alias="httpCode") + elapsed_time_ms: Optional[StrictInt] = Field(default=None, description="Round-trip time of the webhook delivery in milliseconds.", alias="elapsedTimeMs") + body: Optional[StrictStr] = Field(default=None, description="Response body returned by the webhook target.") + error_name: Optional[StrictStr] = Field(default=None, description="Error name if the delivery failed (e.g., timeout, connection_refused).", alias="errorName") + __properties: ClassVar[List[str]] = ["httpCode", "elapsedTimeMs", "body", "errorName"] + + 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 WebhookEventResponseDetail 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 WebhookEventResponseDetail from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "httpCode": obj.get("httpCode"), + "elapsedTimeMs": obj.get("elapsedTimeMs"), + "body": obj.get("body"), + "errorName": obj.get("errorName") + }) + return _obj + + diff --git a/python/cdp/openapi_client/models/webhook_subscription_request.py b/python/cdp/openapi_client/models/webhook_subscription_request.py index 062d9ca4e..5f31745ec 100644 --- a/python/cdp/openapi_client/models/webhook_subscription_request.py +++ b/python/cdp/openapi_client/models/webhook_subscription_request.py @@ -30,7 +30,7 @@ class WebhookSubscriptionRequest(BaseModel): Request to create a new webhook subscription with support for multi-label filtering. """ # noqa: E501 description: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=500)]] = Field(default=None, description="Description of the webhook subscription.") - event_types: List[StrictStr] = Field(description="Types of events to subscribe to. Event types follow a three-part dot-separated format: service.resource.verb (e.g., \"onchain.activity.detected\", \"wallet.activity.detected\", \"onramp.transaction.created\"). The subscription will only receive events matching these types AND the label filter(s). ", alias="eventTypes") + event_types: List[StrictStr] = Field(description="Types of events to subscribe to. Event types follow a three-part dot-separated format: service.resource.verb (e.g., \"onchain.activity.detected\", \"wallet.activity.detected\", \"onramp.transaction.created\", \"acceptance.payment_session\"). The subscription will only receive events matching these types AND the label filter(s). ", alias="eventTypes") is_enabled: StrictBool = Field(description="Whether the subscription is enabled.", alias="isEnabled") target: WebhookTarget metadata: Optional[Dict[str, Annotated[str, Field(min_length=0, strict=True, max_length=500)]]] = Field(default=None, description="Optional metadata as key-value pairs. Use this to store additional structured information on a resource, such as customer IDs, order references, or any application-specific data. Up to 50 key/value pairs may be provided. Keys and values are both strings. Keys must be ≤ 40 characters; values must be ≤ 500 characters.") diff --git a/python/cdp/openapi_client/models/webhook_subscription_response.py b/python/cdp/openapi_client/models/webhook_subscription_response.py index 5819b7598..09836a8ae 100644 --- a/python/cdp/openapi_client/models/webhook_subscription_response.py +++ b/python/cdp/openapi_client/models/webhook_subscription_response.py @@ -32,15 +32,16 @@ class WebhookSubscriptionResponse(BaseModel): Response containing webhook subscription details. """ # noqa: E501 created_at: datetime = Field(description="When the subscription was created.", alias="createdAt") + updated_at: Optional[datetime] = Field(default=None, description="When the subscription was last updated.", alias="updatedAt") description: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=500)]] = Field(default=None, description="Description of the webhook subscription.") - event_types: List[StrictStr] = Field(description="Types of events to subscribe to. Event types follow a three-part dot-separated format: service.resource.verb (e.g., \"onchain.activity.detected\", \"wallet.activity.detected\", \"onramp.transaction.created\"). ", alias="eventTypes") + event_types: List[StrictStr] = Field(description="Types of events to subscribe to. Event types follow a three-part dot-separated format: service.resource.verb (e.g., \"onchain.activity.detected\", \"wallet.activity.detected\", \"onramp.transaction.created\", \"acceptance.payment_session\"). ", alias="eventTypes") is_enabled: StrictBool = Field(description="Whether the subscription is enabled.", alias="isEnabled") metadata: Optional[WebhookSubscriptionResponseMetadata] = None secret: StrictStr = Field(description="Secret for webhook signature validation.") subscription_id: StrictStr = Field(description="Unique identifier for the subscription.", alias="subscriptionId") target: WebhookTarget labels: Optional[Dict[str, StrictStr]] = Field(default=None, description="Multi-label filters using total overlap logic. Total overlap means the subscription only triggers when events contain ALL these key-value pairs. Present when subscription uses multi-label format. ") - __properties: ClassVar[List[str]] = ["createdAt", "description", "eventTypes", "isEnabled", "metadata", "secret", "subscriptionId", "target", "labels"] + __properties: ClassVar[List[str]] = ["createdAt", "updatedAt", "description", "eventTypes", "isEnabled", "metadata", "secret", "subscriptionId", "target", "labels"] model_config = ConfigDict( populate_by_name=True, @@ -100,6 +101,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "createdAt": obj.get("createdAt"), + "updatedAt": obj.get("updatedAt"), "description": obj.get("description"), "eventTypes": obj.get("eventTypes"), "isEnabled": obj.get("isEnabled"), diff --git a/python/cdp/openapi_client/models/x402_payment_payload.py b/python/cdp/openapi_client/models/x402_payment_payload.py index 41748b9a5..15467fc10 100644 --- a/python/cdp/openapi_client/models/x402_payment_payload.py +++ b/python/cdp/openapi_client/models/x402_payment_payload.py @@ -30,10 +30,10 @@ class X402PaymentPayload(BaseModel): """ The x402 protocol payment payload that the client attaches to x402-paid API requests to the resource server in the X-PAYMENT header. For EVM networks, smart account signatures can be longer than 65 bytes. """ - # data type: X402V1PaymentPayload - oneof_schema_1_validator: Optional[X402V1PaymentPayload] = None # data type: X402V2PaymentPayload - oneof_schema_2_validator: Optional[X402V2PaymentPayload] = None + oneof_schema_1_validator: Optional[X402V2PaymentPayload] = None + # data type: X402V1PaymentPayload + oneof_schema_2_validator: Optional[X402V1PaymentPayload] = None actual_instance: Optional[Union[X402V1PaymentPayload, X402V2PaymentPayload]] = None one_of_schemas: Set[str] = { "X402V1PaymentPayload", "X402V2PaymentPayload" } @@ -58,16 +58,16 @@ def actual_instance_must_validate_oneof(cls, v): instance = X402PaymentPayload.model_construct() error_messages = [] match = 0 - # validate data type: X402V1PaymentPayload - if not isinstance(v, X402V1PaymentPayload): - error_messages.append(f"Error! Input type `{type(v)}` is not `X402V1PaymentPayload`") - else: - match += 1 # validate data type: X402V2PaymentPayload if not isinstance(v, X402V2PaymentPayload): error_messages.append(f"Error! Input type `{type(v)}` is not `X402V2PaymentPayload`") else: match += 1 + # validate data type: X402V1PaymentPayload + if not isinstance(v, X402V1PaymentPayload): + error_messages.append(f"Error! Input type `{type(v)}` is not `X402V1PaymentPayload`") + else: + match += 1 if match > 1: # more than 1 match raise ValueError("Multiple matches found when setting `actual_instance` in X402PaymentPayload with oneOf schemas: X402V1PaymentPayload, X402V2PaymentPayload. Details: " + ", ".join(error_messages)) @@ -88,15 +88,15 @@ def from_json(cls, json_str: str) -> Self: error_messages = [] match = 0 - # deserialize data into X402V1PaymentPayload + # deserialize data into X402V2PaymentPayload try: - instance.actual_instance = X402V1PaymentPayload.from_json(json_str) + instance.actual_instance = X402V2PaymentPayload.from_json(json_str) match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) - # deserialize data into X402V2PaymentPayload + # deserialize data into X402V1PaymentPayload try: - instance.actual_instance = X402V2PaymentPayload.from_json(json_str) + instance.actual_instance = X402V1PaymentPayload.from_json(json_str) match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) diff --git a/python/cdp/openapi_client/models/x402_payment_requirements.py b/python/cdp/openapi_client/models/x402_payment_requirements.py index 5b30fa9a8..ab3aa83aa 100644 --- a/python/cdp/openapi_client/models/x402_payment_requirements.py +++ b/python/cdp/openapi_client/models/x402_payment_requirements.py @@ -30,10 +30,10 @@ class X402PaymentRequirements(BaseModel): """ The x402 protocol payment requirements that the resource server expects the client's payment payload to meet. """ - # data type: X402V1PaymentRequirements - oneof_schema_1_validator: Optional[X402V1PaymentRequirements] = None # data type: X402V2PaymentRequirements - oneof_schema_2_validator: Optional[X402V2PaymentRequirements] = None + oneof_schema_1_validator: Optional[X402V2PaymentRequirements] = None + # data type: X402V1PaymentRequirements + oneof_schema_2_validator: Optional[X402V1PaymentRequirements] = None actual_instance: Optional[Union[X402V1PaymentRequirements, X402V2PaymentRequirements]] = None one_of_schemas: Set[str] = { "X402V1PaymentRequirements", "X402V2PaymentRequirements" } @@ -58,16 +58,16 @@ def actual_instance_must_validate_oneof(cls, v): instance = X402PaymentRequirements.model_construct() error_messages = [] match = 0 - # validate data type: X402V1PaymentRequirements - if not isinstance(v, X402V1PaymentRequirements): - error_messages.append(f"Error! Input type `{type(v)}` is not `X402V1PaymentRequirements`") - else: - match += 1 # validate data type: X402V2PaymentRequirements if not isinstance(v, X402V2PaymentRequirements): error_messages.append(f"Error! Input type `{type(v)}` is not `X402V2PaymentRequirements`") else: match += 1 + # validate data type: X402V1PaymentRequirements + if not isinstance(v, X402V1PaymentRequirements): + error_messages.append(f"Error! Input type `{type(v)}` is not `X402V1PaymentRequirements`") + else: + match += 1 if match > 1: # more than 1 match raise ValueError("Multiple matches found when setting `actual_instance` in X402PaymentRequirements with oneOf schemas: X402V1PaymentRequirements, X402V2PaymentRequirements. Details: " + ", ".join(error_messages)) @@ -88,15 +88,15 @@ def from_json(cls, json_str: str) -> Self: error_messages = [] match = 0 - # deserialize data into X402V1PaymentRequirements + # deserialize data into X402V2PaymentRequirements try: - instance.actual_instance = X402V1PaymentRequirements.from_json(json_str) + instance.actual_instance = X402V2PaymentRequirements.from_json(json_str) match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) - # deserialize data into X402V2PaymentRequirements + # deserialize data into X402V1PaymentRequirements try: - instance.actual_instance = X402V2PaymentRequirements.from_json(json_str) + instance.actual_instance = X402V1PaymentRequirements.from_json(json_str) match += 1 except (ValidationError, ValueError) as e: error_messages.append(str(e)) diff --git a/python/cdp/openapi_client/models/x402_supported_payment_kind.py b/python/cdp/openapi_client/models/x402_supported_payment_kind.py index 033b0d191..915fb4d51 100644 --- a/python/cdp/openapi_client/models/x402_supported_payment_kind.py +++ b/python/cdp/openapi_client/models/x402_supported_payment_kind.py @@ -37,8 +37,8 @@ class X402SupportedPaymentKind(BaseModel): @field_validator('scheme') def scheme_validate_enum(cls, value): """Validates the enum""" - if value not in set(['exact']): - raise ValueError("must be one of enum values ('exact')") + if value not in set(['exact', 'upto']): + raise ValueError("must be one of enum values ('exact', 'upto')") return value @field_validator('network') diff --git a/python/cdp/openapi_client/models/x402_v1_payment_payload.py b/python/cdp/openapi_client/models/x402_v1_payment_payload.py index 2d624d279..74f7b0db4 100644 --- a/python/cdp/openapi_client/models/x402_v1_payment_payload.py +++ b/python/cdp/openapi_client/models/x402_v1_payment_payload.py @@ -20,7 +20,7 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing import Any, ClassVar, Dict, List -from cdp.openapi_client.models.x402_v1_payment_payload_payload import X402V1PaymentPayloadPayload +from cdp.openapi_client.models.x402_v2_payment_payload_payload import X402V2PaymentPayloadPayload from cdp.openapi_client.models.x402_version import X402Version from typing import Optional, Set from typing_extensions import Self @@ -32,7 +32,7 @@ class X402V1PaymentPayload(BaseModel): x402_version: X402Version = Field(alias="x402Version") scheme: StrictStr = Field(description="The scheme of the payment protocol to use. Currently, the only supported scheme is `exact`.") network: StrictStr = Field(description="The network of the blockchain to send payment on.") - payload: X402V1PaymentPayloadPayload + payload: X402V2PaymentPayloadPayload __properties: ClassVar[List[str]] = ["x402Version", "scheme", "network", "payload"] @field_validator('scheme') @@ -106,7 +106,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "x402Version": obj.get("x402Version"), "scheme": obj.get("scheme"), "network": obj.get("network"), - "payload": X402V1PaymentPayloadPayload.from_dict(obj["payload"]) if obj.get("payload") is not None else None + "payload": X402V2PaymentPayloadPayload.from_dict(obj["payload"]) if obj.get("payload") is not None else None }) return _obj diff --git a/python/cdp/openapi_client/models/x402_v2_payment_payload.py b/python/cdp/openapi_client/models/x402_v2_payment_payload.py index 1e90b2bdf..a1cda7ca0 100644 --- a/python/cdp/openapi_client/models/x402_v2_payment_payload.py +++ b/python/cdp/openapi_client/models/x402_v2_payment_payload.py @@ -21,7 +21,7 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from cdp.openapi_client.models.x402_resource_info import X402ResourceInfo -from cdp.openapi_client.models.x402_v1_payment_payload_payload import X402V1PaymentPayloadPayload +from cdp.openapi_client.models.x402_v2_payment_payload_payload import X402V2PaymentPayloadPayload from cdp.openapi_client.models.x402_v2_payment_requirements import X402V2PaymentRequirements from cdp.openapi_client.models.x402_version import X402Version from typing import Optional, Set @@ -32,7 +32,7 @@ class X402V2PaymentPayload(BaseModel): The x402 protocol payment payload that the client attaches to x402-paid API requests to the resource server in the X-PAYMENT header. """ # noqa: E501 x402_version: X402Version = Field(alias="x402Version") - payload: X402V1PaymentPayloadPayload + payload: X402V2PaymentPayloadPayload accepted: X402V2PaymentRequirements resource: Optional[X402ResourceInfo] = None extensions: Optional[Dict[str, Any]] = Field(default=None, description="Optional protocol extensions.") @@ -99,7 +99,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "x402Version": obj.get("x402Version"), - "payload": X402V1PaymentPayloadPayload.from_dict(obj["payload"]) if obj.get("payload") is not None else None, + "payload": X402V2PaymentPayloadPayload.from_dict(obj["payload"]) if obj.get("payload") is not None else None, "accepted": X402V2PaymentRequirements.from_dict(obj["accepted"]) if obj.get("accepted") is not None else None, "resource": X402ResourceInfo.from_dict(obj["resource"]) if obj.get("resource") is not None else None, "extensions": obj.get("extensions") diff --git a/python/cdp/openapi_client/models/x402_v1_payment_payload_payload.py b/python/cdp/openapi_client/models/x402_v2_payment_payload_payload.py similarity index 93% rename from python/cdp/openapi_client/models/x402_v1_payment_payload_payload.py rename to python/cdp/openapi_client/models/x402_v2_payment_payload_payload.py index c853dde3e..4a0760bd5 100644 --- a/python/cdp/openapi_client/models/x402_v1_payment_payload_payload.py +++ b/python/cdp/openapi_client/models/x402_v2_payment_payload_payload.py @@ -25,9 +25,9 @@ from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self -X402V1PAYMENTPAYLOADPAYLOAD_ONE_OF_SCHEMAS = ["X402ExactEvmPayload", "X402ExactEvmPermit2Payload", "X402ExactSolanaPayload"] +X402V2PAYMENTPAYLOADPAYLOAD_ONE_OF_SCHEMAS = ["X402ExactEvmPayload", "X402ExactEvmPermit2Payload", "X402ExactSolanaPayload"] -class X402V1PaymentPayloadPayload(BaseModel): +class X402V2PaymentPayloadPayload(BaseModel): """ The payload of the payment depending on the x402Version, scheme, and network. """ @@ -58,7 +58,7 @@ def __init__(self, *args, **kwargs) -> None: @field_validator('actual_instance') def actual_instance_must_validate_oneof(cls, v): - instance = X402V1PaymentPayloadPayload.model_construct() + instance = X402V2PaymentPayloadPayload.model_construct() error_messages = [] match = 0 # validate data type: X402ExactEvmPayload @@ -78,10 +78,10 @@ def actual_instance_must_validate_oneof(cls, v): match += 1 if match > 1: # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in X402V1PaymentPayloadPayload with oneOf schemas: X402ExactEvmPayload, X402ExactEvmPermit2Payload, X402ExactSolanaPayload. Details: " + ", ".join(error_messages)) + raise ValueError("Multiple matches found when setting `actual_instance` in X402V2PaymentPayloadPayload with oneOf schemas: X402ExactEvmPayload, X402ExactEvmPermit2Payload, X402ExactSolanaPayload. Details: " + ", ".join(error_messages)) elif match == 0: # no match - raise ValueError("No match found when setting `actual_instance` in X402V1PaymentPayloadPayload with oneOf schemas: X402ExactEvmPayload, X402ExactEvmPermit2Payload, X402ExactSolanaPayload. Details: " + ", ".join(error_messages)) + raise ValueError("No match found when setting `actual_instance` in X402V2PaymentPayloadPayload with oneOf schemas: X402ExactEvmPayload, X402ExactEvmPermit2Payload, X402ExactSolanaPayload. Details: " + ", ".join(error_messages)) else: return v @@ -117,10 +117,10 @@ def from_json(cls, json_str: str) -> Self: if match > 1: # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into X402V1PaymentPayloadPayload with oneOf schemas: X402ExactEvmPayload, X402ExactEvmPermit2Payload, X402ExactSolanaPayload. Details: " + ", ".join(error_messages)) + raise ValueError("Multiple matches found when deserializing the JSON string into X402V2PaymentPayloadPayload with oneOf schemas: X402ExactEvmPayload, X402ExactEvmPermit2Payload, X402ExactSolanaPayload. Details: " + ", ".join(error_messages)) elif match == 0: # no match - raise ValueError("No match found when deserializing the JSON string into X402V1PaymentPayloadPayload with oneOf schemas: X402ExactEvmPayload, X402ExactEvmPermit2Payload, X402ExactSolanaPayload. Details: " + ", ".join(error_messages)) + raise ValueError("No match found when deserializing the JSON string into X402V2PaymentPayloadPayload with oneOf schemas: X402ExactEvmPayload, X402ExactEvmPermit2Payload, X402ExactSolanaPayload. Details: " + ", ".join(error_messages)) else: return instance diff --git a/python/cdp/openapi_client/models/x402_v2_payment_requirements.py b/python/cdp/openapi_client/models/x402_v2_payment_requirements.py index 730eb0d68..2fdf53103 100644 --- a/python/cdp/openapi_client/models/x402_v2_payment_requirements.py +++ b/python/cdp/openapi_client/models/x402_v2_payment_requirements.py @@ -28,7 +28,7 @@ class X402V2PaymentRequirements(BaseModel): """ The x402 protocol payment requirements that the resource server expects the client's payment payload to meet. """ # noqa: E501 - scheme: StrictStr = Field(description="The scheme of the payment protocol to use. Currently, the only supported scheme is `exact`.") + scheme: StrictStr = Field(description="The scheme of the payment protocol to use. Supported schemes are `exact` and `upto`.") network: StrictStr = Field(description="The network of the blockchain to send payment on in caip2 format.") asset: Annotated[str, Field(strict=True)] = Field(description="The asset to pay with. For EVM networks, the asset will be a 0x-prefixed, checksum EVM address. For Solana-based networks, the asset will be a base58-encoded Solana address.") amount: StrictStr = Field(description="The amount to pay for the resource in atomic units of the payment asset.") @@ -40,8 +40,8 @@ class X402V2PaymentRequirements(BaseModel): @field_validator('scheme') def scheme_validate_enum(cls, value): """Validates the enum""" - if value not in set(['exact']): - raise ValueError("must be one of enum values ('exact')") + if value not in set(['exact', 'upto']): + raise ValueError("must be one of enum values ('exact', 'upto')") return value @field_validator('asset') diff --git a/python/cdp/openapi_client/test/test_authentication_method.py b/python/cdp/openapi_client/test/test_authentication_method.py index 0d5cd7ff9..6fdc31ec9 100644 --- a/python/cdp/openapi_client/test/test_authentication_method.py +++ b/python/cdp/openapi_client/test/test_authentication_method.py @@ -47,7 +47,8 @@ def make_instance(self, include_optional) -> AuthenticationMethod: first_name = 'Satoshi', last_name = 'Nakamoto', photo_url = 'https://image.url/profile.png', - auth_date = 1770681412 + auth_date = 1770681412, + address = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e' ) else: return AuthenticationMethod( @@ -58,6 +59,7 @@ def make_instance(self, include_optional) -> AuthenticationMethod: sub = 'e051beeb-7163-4527-a5b6-35e301529ff2', id = 123456, auth_date = 1770681412, + address = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', ) """ diff --git a/python/cdp/openapi_client/test/test_create_end_user_evm_swap_rule.py b/python/cdp/openapi_client/test/test_create_end_user_evm_swap_rule.py new file mode 100644 index 000000000..33134ece5 --- /dev/null +++ b/python/cdp/openapi_client/test/test_create_end_user_evm_swap_rule.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from cdp.openapi_client.models.create_end_user_evm_swap_rule import CreateEndUserEvmSwapRule + +class TestCreateEndUserEvmSwapRule(unittest.TestCase): + """CreateEndUserEvmSwapRule unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> CreateEndUserEvmSwapRule: + """Test CreateEndUserEvmSwapRule + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `CreateEndUserEvmSwapRule` + """ + model = CreateEndUserEvmSwapRule() + if include_optional: + return CreateEndUserEvmSwapRule( + action = 'accept', + operation = 'createEndUserEvmSwap', + criteria = [{type=ethValue, ethValue=1000000, operator=>=}, {type=evmAddress, addresses=[0x742d35Cc6634C0532925a3b844Bc454e4438f44e], operator=in}, {type=evmNetwork, networks=[base, ethereum], operator=in}, {type=evmData, abi=erc20, conditions=[{function=transfer, params=[{name=value, operator=<=, value=10000}]}]}, {type=netUSDChange, changeCents=10000, operator=<=}] + ) + else: + return CreateEndUserEvmSwapRule( + action = 'accept', + operation = 'createEndUserEvmSwap', + criteria = [{type=ethValue, ethValue=1000000, operator=>=}, {type=evmAddress, addresses=[0x742d35Cc6634C0532925a3b844Bc454e4438f44e], operator=in}, {type=evmNetwork, networks=[base, ethereum], operator=in}, {type=evmData, abi=erc20, conditions=[{function=transfer, params=[{name=value, operator=<=, value=10000}]}]}, {type=netUSDChange, changeCents=10000, operator=<=}], + ) + """ + + def testCreateEndUserEvmSwapRule(self): + """Test CreateEndUserEvmSwapRule""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/cdp/openapi_client/test/test_create_end_user_request.py b/python/cdp/openapi_client/test/test_create_end_user_request.py index 347297409..868898ed1 100644 --- a/python/cdp/openapi_client/test/test_create_end_user_request.py +++ b/python/cdp/openapi_client/test/test_create_end_user_request.py @@ -37,7 +37,7 @@ def make_instance(self, include_optional) -> CreateEndUserRequest: if include_optional: return CreateEndUserRequest( user_id = 'e051beeb-7163-4527-a5b6-35e301529ff2', - authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}], + authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}, {type=siwe, address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e}], evm_account = cdp.openapi_client.models.create_end_user_request_evm_account.createEndUser_request_evmAccount( create_smart_account = True, enable_spend_permissions = True, ), @@ -46,7 +46,7 @@ def make_instance(self, include_optional) -> CreateEndUserRequest: ) else: return CreateEndUserRequest( - authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}], + authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}, {type=siwe, address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e}], ) """ diff --git a/python/cdp/openapi_client/test/test_end_user.py b/python/cdp/openapi_client/test/test_end_user.py index 18fb2f0c4..6ef194ea7 100644 --- a/python/cdp/openapi_client/test/test_end_user.py +++ b/python/cdp/openapi_client/test/test_end_user.py @@ -37,7 +37,7 @@ def make_instance(self, include_optional) -> EndUser: if include_optional: return EndUser( user_id = 'e051beeb-7163-4527-a5b6-35e301529ff2', - authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}], + authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}, {type=siwe, address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e}], mfa_methods = {enrollmentPromptedAt=2025-01-15T10:30:00Z, totp={enrolledAt=2025-01-15T10:30:00Z}, sms={enrolledAt=2025-01-15T10:30:00Z}}, evm_accounts = [0x742d35Cc6634C0532925a3b844Bc454e4438f44e], evm_account_objects = [{address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, createdAt=2025-01-15T10:30:00Z}, {address=0x1234567890abcdef1234567890abcdef12345678, createdAt=2025-01-15T11:00:00Z}], @@ -50,7 +50,7 @@ def make_instance(self, include_optional) -> EndUser: else: return EndUser( user_id = 'e051beeb-7163-4527-a5b6-35e301529ff2', - authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}], + authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}, {type=siwe, address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e}], evm_accounts = [0x742d35Cc6634C0532925a3b844Bc454e4438f44e], evm_account_objects = [{address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, createdAt=2025-01-15T10:30:00Z}, {address=0x1234567890abcdef1234567890abcdef12345678, createdAt=2025-01-15T11:00:00Z}], evm_smart_accounts = [0x742d35Cc6634C0532925a3b844Bc454e4438f44e], diff --git a/python/cdp/openapi_client/test/test_import_end_user_request.py b/python/cdp/openapi_client/test/test_import_end_user_request.py index a0e1e7bd5..9db99a0fb 100644 --- a/python/cdp/openapi_client/test/test_import_end_user_request.py +++ b/python/cdp/openapi_client/test/test_import_end_user_request.py @@ -37,14 +37,14 @@ def make_instance(self, include_optional) -> ImportEndUserRequest: if include_optional: return ImportEndUserRequest( user_id = 'e051beeb-7163-4527-a5b6-35e301529ff2', - authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}], + authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}, {type=siwe, address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e}], encrypted_private_key = 'U2FsdGVkX1+vupppZksvRf5X5YgHq4+da+Q4qf51+Q4=', key_type = 'evm' ) else: return ImportEndUserRequest( user_id = 'e051beeb-7163-4527-a5b6-35e301529ff2', - authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}], + authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}, {type=siwe, address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e}], encrypted_private_key = 'U2FsdGVkX1+vupppZksvRf5X5YgHq4+da+Q4qf51+Q4=', key_type = 'evm', ) diff --git a/python/cdp/openapi_client/test/test_inline_object1.py b/python/cdp/openapi_client/test/test_inline_object1.py index b0a374f08..5b7a7fe95 100644 --- a/python/cdp/openapi_client/test/test_inline_object1.py +++ b/python/cdp/openapi_client/test/test_inline_object1.py @@ -41,7 +41,8 @@ def make_instance(self, include_optional) -> InlineObject1: error_message = 'Insufficient funds', payer = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', transaction = '0x89c91c789e57059b17285e7ba1716a1f5ff4c5dace0ea5a5135f26158d0421b9', - network = 'base' + network = 'base', + amount = '1000000' ) else: return InlineObject1( diff --git a/python/cdp/openapi_client/test/test_list_end_users200_response.py b/python/cdp/openapi_client/test/test_list_end_users200_response.py index 94c3322a1..5c683d61d 100644 --- a/python/cdp/openapi_client/test/test_list_end_users200_response.py +++ b/python/cdp/openapi_client/test/test_list_end_users200_response.py @@ -40,7 +40,7 @@ def make_instance(self, include_optional) -> ListEndUsers200Response: end_users = [ cdp.openapi_client.models.end_user.EndUser( user_id = 'e051beeb-7163-4527-a5b6-35e301529ff2', - authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}], + authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}, {type=siwe, address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e}], mfa_methods = {enrollmentPromptedAt=2025-01-15T10:30:00Z, totp={enrolledAt=2025-01-15T10:30:00Z}, sms={enrolledAt=2025-01-15T10:30:00Z}}, evm_accounts = [0x742d35Cc6634C0532925a3b844Bc454e4438f44e], evm_account_objects = [{address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, createdAt=2025-01-15T10:30:00Z}, {address=0x1234567890abcdef1234567890abcdef12345678, createdAt=2025-01-15T11:00:00Z}], @@ -56,7 +56,7 @@ def make_instance(self, include_optional) -> ListEndUsers200Response: end_users = [ cdp.openapi_client.models.end_user.EndUser( user_id = 'e051beeb-7163-4527-a5b6-35e301529ff2', - authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}], + authentication_methods = [{type=email, email=user@example.com}, {type=sms, phoneNumber=+12055555555}, {type=jwt, sub=e051beeb-7163-4527-a5b6-35e301529ff2, kid=NjVBRjY5MDlCMUIwNzU4RTA2QzZFMDQ4QzQ2MDAyQjVDNjk1RTM2Qg}, {type=google, sub=115346410074741490243, email=test.user@gmail.com}, {type=telegram, id=1223456, firstName=Satoshi, lastName=Nakamoto, photoUrl=https://image.url/profile.jpg, authDate=1770681412, username=satoshinakamoto}, {type=siwe, address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e}], mfa_methods = {enrollmentPromptedAt=2025-01-15T10:30:00Z, totp={enrolledAt=2025-01-15T10:30:00Z}, sms={enrolledAt=2025-01-15T10:30:00Z}}, evm_accounts = [0x742d35Cc6634C0532925a3b844Bc454e4438f44e], evm_account_objects = [{address=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, createdAt=2025-01-15T10:30:00Z}, {address=0x1234567890abcdef1234567890abcdef12345678, createdAt=2025-01-15T11:00:00Z}], diff --git a/python/cdp/openapi_client/test/test_onchain_data_column_schema.py b/python/cdp/openapi_client/test/test_onchain_data_column_schema.py new file mode 100644 index 000000000..65f74fdc3 --- /dev/null +++ b/python/cdp/openapi_client/test/test_onchain_data_column_schema.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from cdp.openapi_client.models.onchain_data_column_schema import OnchainDataColumnSchema + +class TestOnchainDataColumnSchema(unittest.TestCase): + """OnchainDataColumnSchema unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> OnchainDataColumnSchema: + """Test OnchainDataColumnSchema + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `OnchainDataColumnSchema` + """ + model = OnchainDataColumnSchema() + if include_optional: + return OnchainDataColumnSchema( + name = 'event_signature', + type = 'String', + nullable = False, + description = 'A description of the resource.', + index_order = 0 + ) + else: + return OnchainDataColumnSchema( + ) + """ + + def testOnchainDataColumnSchema(self): + """Test OnchainDataColumnSchema""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/cdp/openapi_client/test/test_onchain_data_schema_response.py b/python/cdp/openapi_client/test/test_onchain_data_schema_response.py new file mode 100644 index 000000000..8b4ca8477 --- /dev/null +++ b/python/cdp/openapi_client/test/test_onchain_data_schema_response.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from cdp.openapi_client.models.onchain_data_schema_response import OnchainDataSchemaResponse + +class TestOnchainDataSchemaResponse(unittest.TestCase): + """OnchainDataSchemaResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> OnchainDataSchemaResponse: + """Test OnchainDataSchemaResponse + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `OnchainDataSchemaResponse` + """ + model = OnchainDataSchemaResponse() + if include_optional: + return OnchainDataSchemaResponse( + tables = [{database=base, table=events, columns=[{name=event_signature, type=String, nullable=false, description=The signature of the decoded event log., indexOrder=0}]}] + ) + else: + return OnchainDataSchemaResponse( + ) + """ + + def testOnchainDataSchemaResponse(self): + """Test OnchainDataSchemaResponse""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/cdp/openapi_client/test/test_onchain_data_table_schema.py b/python/cdp/openapi_client/test/test_onchain_data_table_schema.py new file mode 100644 index 000000000..dfa1127d2 --- /dev/null +++ b/python/cdp/openapi_client/test/test_onchain_data_table_schema.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from cdp.openapi_client.models.onchain_data_table_schema import OnchainDataTableSchema + +class TestOnchainDataTableSchema(unittest.TestCase): + """OnchainDataTableSchema unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> OnchainDataTableSchema: + """Test OnchainDataTableSchema + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `OnchainDataTableSchema` + """ + model = OnchainDataTableSchema() + if include_optional: + return OnchainDataTableSchema( + database = 'base', + table = 'events', + columns = [{name=event_signature, type=String, nullable=false, description=The signature of the decoded event log., indexOrder=0}] + ) + else: + return OnchainDataTableSchema( + ) + """ + + def testOnchainDataTableSchema(self): + """Test OnchainDataTableSchema""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/cdp/openapi_client/test/test_rule.py b/python/cdp/openapi_client/test/test_rule.py index 246ff364e..29c6820e4 100644 --- a/python/cdp/openapi_client/test/test_rule.py +++ b/python/cdp/openapi_client/test/test_rule.py @@ -37,14 +37,14 @@ def make_instance(self, include_optional) -> Rule: if include_optional: return Rule( action = 'accept', - operation = 'signEndUserSolMessage', - criteria = [{type=solMessage, match=^hello ([a-z]+)$}] + operation = 'createEndUserEvmSwap', + criteria = [{type=ethValue, ethValue=1000000, operator=>=}, {type=evmAddress, addresses=[0x742d35Cc6634C0532925a3b844Bc454e4438f44e], operator=in}, {type=evmNetwork, networks=[base, ethereum], operator=in}, {type=evmData, abi=erc20, conditions=[{function=transfer, params=[{name=value, operator=<=, value=10000}]}]}, {type=netUSDChange, changeCents=10000, operator=<=}] ) else: return Rule( action = 'accept', - operation = 'signEndUserSolMessage', - criteria = [{type=solMessage, match=^hello ([a-z]+)$}], + operation = 'createEndUserEvmSwap', + criteria = [{type=ethValue, ethValue=1000000, operator=>=}, {type=evmAddress, addresses=[0x742d35Cc6634C0532925a3b844Bc454e4438f44e], operator=in}, {type=evmNetwork, networks=[base, ethereum], operator=in}, {type=evmData, abi=erc20, conditions=[{function=transfer, params=[{name=value, operator=<=, value=10000}]}]}, {type=netUSDChange, changeCents=10000, operator=<=}], ) """ diff --git a/python/cdp/openapi_client/test/test_sign_end_user_evm_hash_rule.py b/python/cdp/openapi_client/test/test_sign_end_user_evm_hash_rule.py new file mode 100644 index 000000000..e06b79151 --- /dev/null +++ b/python/cdp/openapi_client/test/test_sign_end_user_evm_hash_rule.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from cdp.openapi_client.models.sign_end_user_evm_hash_rule import SignEndUserEvmHashRule + +class TestSignEndUserEvmHashRule(unittest.TestCase): + """SignEndUserEvmHashRule unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> SignEndUserEvmHashRule: + """Test SignEndUserEvmHashRule + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `SignEndUserEvmHashRule` + """ + model = SignEndUserEvmHashRule() + if include_optional: + return SignEndUserEvmHashRule( + action = 'accept', + operation = 'signEndUserEvmHash' + ) + else: + return SignEndUserEvmHashRule( + action = 'accept', + operation = 'signEndUserEvmHash', + ) + """ + + def testSignEndUserEvmHashRule(self): + """Test SignEndUserEvmHashRule""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/cdp/openapi_client/test/test_siwe_authentication.py b/python/cdp/openapi_client/test/test_siwe_authentication.py new file mode 100644 index 000000000..8386a4057 --- /dev/null +++ b/python/cdp/openapi_client/test/test_siwe_authentication.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from cdp.openapi_client.models.siwe_authentication import SiweAuthentication + +class TestSiweAuthentication(unittest.TestCase): + """SiweAuthentication unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> SiweAuthentication: + """Test SiweAuthentication + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `SiweAuthentication` + """ + model = SiweAuthentication() + if include_optional: + return SiweAuthentication( + type = 'siwe', + address = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e' + ) + else: + return SiweAuthentication( + type = 'siwe', + address = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', + ) + """ + + def testSiweAuthentication(self): + """Test SiweAuthentication""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/cdp/openapi_client/test/test_sqlapi_alpha_api.py b/python/cdp/openapi_client/test/test_sqlapi_api.py similarity index 71% rename from python/cdp/openapi_client/test/test_sqlapi_alpha_api.py rename to python/cdp/openapi_client/test/test_sqlapi_api.py index 8ad2feab9..448794f4e 100644 --- a/python/cdp/openapi_client/test/test_sqlapi_alpha_api.py +++ b/python/cdp/openapi_client/test/test_sqlapi_api.py @@ -15,14 +15,14 @@ import unittest -from cdp.openapi_client.api.sqlapi_alpha_api import SQLAPIAlphaApi +from cdp.openapi_client.api.sqlapi_api import SQLAPIApi -class TestSQLAPIAlphaApi(unittest.IsolatedAsyncioTestCase): - """SQLAPIAlphaApi unit test stubs""" +class TestSQLAPIApi(unittest.IsolatedAsyncioTestCase): + """SQLAPIApi unit test stubs""" async def asyncSetUp(self) -> None: - self.api = SQLAPIAlphaApi() + self.api = SQLAPIApi() async def asyncTearDown(self) -> None: await self.api.api_client.close() @@ -34,6 +34,13 @@ async def test_get_sql_grammar(self) -> None: """ pass + async def test_get_sql_schema(self) -> None: + """Test case for get_sql_schema + + Get schemas details + """ + pass + async def test_run_sql_query(self) -> None: """Test case for run_sql_query diff --git a/python/cdp/openapi_client/test/test_verify_x402_payment_request.py b/python/cdp/openapi_client/test/test_verify_x402_payment_request.py index e42a7cc2d..bc2e4b018 100644 --- a/python/cdp/openapi_client/test/test_verify_x402_payment_request.py +++ b/python/cdp/openapi_client/test/test_verify_x402_payment_request.py @@ -36,13 +36,13 @@ def make_instance(self, include_optional) -> VerifyX402PaymentRequest: model = VerifyX402PaymentRequest() if include_optional: return VerifyX402PaymentRequest( - x402_version = 1, + x402_version = 2, payment_payload = cdp.openapi_client.models.x402_payment_payload.x402PaymentPayload(), payment_requirements = cdp.openapi_client.models.x402_payment_requirements.x402PaymentRequirements() ) else: return VerifyX402PaymentRequest( - x402_version = 1, + x402_version = 2, payment_payload = cdp.openapi_client.models.x402_payment_payload.x402PaymentPayload(), payment_requirements = cdp.openapi_client.models.x402_payment_requirements.x402PaymentRequirements(), ) diff --git a/python/cdp/openapi_client/test/test_webhook_event_list_response.py b/python/cdp/openapi_client/test/test_webhook_event_list_response.py new file mode 100644 index 000000000..5b82c2842 --- /dev/null +++ b/python/cdp/openapi_client/test/test_webhook_event_list_response.py @@ -0,0 +1,57 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from cdp.openapi_client.models.webhook_event_list_response import WebhookEventListResponse + +class TestWebhookEventListResponse(unittest.TestCase): + """WebhookEventListResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> WebhookEventListResponse: + """Test WebhookEventListResponse + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `WebhookEventListResponse` + """ + model = WebhookEventListResponse() + if include_optional: + return WebhookEventListResponse( + events = [ + {eventId=a1b2c3d4-e5f6-7890-abcd-ef1234567890, eventTypeName=onchain.activity.detected, status=succeeded, createdAt=2025-01-15T10:30:00Z, succeededAt=2025-01-15T10:30:02Z, retryCount=0, response={httpCode=200, elapsedTimeMs=142, body=ok}} + ] + ) + else: + return WebhookEventListResponse( + events = [ + {eventId=a1b2c3d4-e5f6-7890-abcd-ef1234567890, eventTypeName=onchain.activity.detected, status=succeeded, createdAt=2025-01-15T10:30:00Z, succeededAt=2025-01-15T10:30:02Z, retryCount=0, response={httpCode=200, elapsedTimeMs=142, body=ok}} + ], + ) + """ + + def testWebhookEventListResponse(self): + """Test WebhookEventListResponse""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/cdp/openapi_client/test/test_webhook_event_response.py b/python/cdp/openapi_client/test/test_webhook_event_response.py new file mode 100644 index 000000000..3546cdc4f --- /dev/null +++ b/python/cdp/openapi_client/test/test_webhook_event_response.py @@ -0,0 +1,63 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from cdp.openapi_client.models.webhook_event_response import WebhookEventResponse + +class TestWebhookEventResponse(unittest.TestCase): + """WebhookEventResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> WebhookEventResponse: + """Test WebhookEventResponse + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `WebhookEventResponse` + """ + model = WebhookEventResponse() + if include_optional: + return WebhookEventResponse( + event_id = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890', + event_type_name = 'onchain.activity.detected', + status = 'succeeded', + created_at = '2025-01-15T10:30:00Z', + succeeded_at = '2025-01-15T10:30:02Z', + retry_count = 0, + response = {httpCode=200, elapsedTimeMs=142, body=ok} + ) + else: + return WebhookEventResponse( + event_id = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890', + event_type_name = 'onchain.activity.detected', + status = 'succeeded', + created_at = '2025-01-15T10:30:00Z', + retry_count = 0, + ) + """ + + def testWebhookEventResponse(self): + """Test WebhookEventResponse""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/cdp/openapi_client/test/test_webhook_event_response_detail.py b/python/cdp/openapi_client/test/test_webhook_event_response_detail.py new file mode 100644 index 000000000..0bbcced5d --- /dev/null +++ b/python/cdp/openapi_client/test/test_webhook_event_response_detail.py @@ -0,0 +1,55 @@ +# coding: utf-8 + +""" + Coinbase Developer Platform APIs + + The Coinbase Developer Platform APIs - leading the world's transition onchain. + + The version of the OpenAPI document: 2.0.0 + Contact: cdp@coinbase.com + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from cdp.openapi_client.models.webhook_event_response_detail import WebhookEventResponseDetail + +class TestWebhookEventResponseDetail(unittest.TestCase): + """WebhookEventResponseDetail unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> WebhookEventResponseDetail: + """Test WebhookEventResponseDetail + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `WebhookEventResponseDetail` + """ + model = WebhookEventResponseDetail() + if include_optional: + return WebhookEventResponseDetail( + http_code = 200, + elapsed_time_ms = 142, + body = 'ok', + error_name = 'timeout' + ) + else: + return WebhookEventResponseDetail( + ) + """ + + def testWebhookEventResponseDetail(self): + """Test WebhookEventResponseDetail""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/cdp/openapi_client/test/test_webhook_subscription_list_response.py b/python/cdp/openapi_client/test/test_webhook_subscription_list_response.py index b903d065f..439c93966 100644 --- a/python/cdp/openapi_client/test/test_webhook_subscription_list_response.py +++ b/python/cdp/openapi_client/test/test_webhook_subscription_list_response.py @@ -38,13 +38,13 @@ def make_instance(self, include_optional) -> WebhookSubscriptionListResponse: return WebhookSubscriptionListResponse( next_page_token = 'eyJsYXN0X2lkIjogImFiYzEyMyIsICJ0aW1lc3RhbXAiOiAxNzA3ODIzNzAxfQ==', subscriptions = [ - {subscriptionId=123e4567-e89b-12d3-a456-426614174000, eventTypes=[onchain.activity.detected], isEnabled=true, labels={contract_address=0x833589fcd6edb6e08f4c7c32d4f71b54bda02913, event_name=Transfer, network=base-mainnet, transaction_to=0xf5042e6ffac5a625d4e7848e0b01373d8eb9e222}, description=USDC Transfer events to specific address., createdAt=2025-11-12T09:19:52.051Z, metadata={secret=a1b2c3d4-e5f6-7890-abcd-ef1234567890}, secret=a1b2c3d4-e5f6-7890-abcd-ef1234567890, target={url=https://api.example.com/webhooks}} + {subscriptionId=123e4567-e89b-12d3-a456-426614174000, eventTypes=[onchain.activity.detected], isEnabled=true, labels={contract_address=0x833589fcd6edb6e08f4c7c32d4f71b54bda02913, event_name=Transfer, network=base-mainnet, transaction_to=0xf5042e6ffac5a625d4e7848e0b01373d8eb9e222}, description=USDC Transfer events to specific address., createdAt=2025-11-12T09:19:52.051Z, updatedAt=2025-11-13T11:30:00.000Z, metadata={secret=a1b2c3d4-e5f6-7890-abcd-ef1234567890}, secret=a1b2c3d4-e5f6-7890-abcd-ef1234567890, target={url=https://api.example.com/webhooks}} ] ) else: return WebhookSubscriptionListResponse( subscriptions = [ - {subscriptionId=123e4567-e89b-12d3-a456-426614174000, eventTypes=[onchain.activity.detected], isEnabled=true, labels={contract_address=0x833589fcd6edb6e08f4c7c32d4f71b54bda02913, event_name=Transfer, network=base-mainnet, transaction_to=0xf5042e6ffac5a625d4e7848e0b01373d8eb9e222}, description=USDC Transfer events to specific address., createdAt=2025-11-12T09:19:52.051Z, metadata={secret=a1b2c3d4-e5f6-7890-abcd-ef1234567890}, secret=a1b2c3d4-e5f6-7890-abcd-ef1234567890, target={url=https://api.example.com/webhooks}} + {subscriptionId=123e4567-e89b-12d3-a456-426614174000, eventTypes=[onchain.activity.detected], isEnabled=true, labels={contract_address=0x833589fcd6edb6e08f4c7c32d4f71b54bda02913, event_name=Transfer, network=base-mainnet, transaction_to=0xf5042e6ffac5a625d4e7848e0b01373d8eb9e222}, description=USDC Transfer events to specific address., createdAt=2025-11-12T09:19:52.051Z, updatedAt=2025-11-13T11:30:00.000Z, metadata={secret=a1b2c3d4-e5f6-7890-abcd-ef1234567890}, secret=a1b2c3d4-e5f6-7890-abcd-ef1234567890, target={url=https://api.example.com/webhooks}} ], ) """ diff --git a/python/cdp/openapi_client/test/test_webhook_subscription_response.py b/python/cdp/openapi_client/test/test_webhook_subscription_response.py index 01d390341..b5215ba4f 100644 --- a/python/cdp/openapi_client/test/test_webhook_subscription_response.py +++ b/python/cdp/openapi_client/test/test_webhook_subscription_response.py @@ -37,6 +37,7 @@ def make_instance(self, include_optional) -> WebhookSubscriptionResponse: if include_optional: return WebhookSubscriptionResponse( created_at = '2025-01-15T10:30:00Z', + updated_at = '2025-01-16T14:00:00Z', description = 'A description of the resource.', event_types = [onchain.activity.detected], is_enabled = True, diff --git a/python/cdp/openapi_client/test/test_webhooks_api.py b/python/cdp/openapi_client/test/test_webhooks_api.py index 083b29d7e..4fd79a6c5 100644 --- a/python/cdp/openapi_client/test/test_webhooks_api.py +++ b/python/cdp/openapi_client/test/test_webhooks_api.py @@ -48,6 +48,13 @@ async def test_get_webhook_subscription(self) -> None: """ pass + async def test_list_webhook_subscription_events(self) -> None: + """Test case for list_webhook_subscription_events + + List webhook subscription events + """ + pass + async def test_list_webhook_subscriptions(self) -> None: """Test case for list_webhook_subscriptions diff --git a/python/cdp/openapi_client/test/test_x402_payment_payload.py b/python/cdp/openapi_client/test/test_x402_payment_payload.py index 3cb3d0cef..bd13eafed 100644 --- a/python/cdp/openapi_client/test/test_x402_payment_payload.py +++ b/python/cdp/openapi_client/test/test_x402_payment_payload.py @@ -36,9 +36,7 @@ def make_instance(self, include_optional) -> X402PaymentPayload: model = X402PaymentPayload() if include_optional: return X402PaymentPayload( - x402_version = 1, - scheme = 'exact', - network = 'base', + x402_version = 2, payload = {signature=0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f134801234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1b, authorization={from=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, to=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, value=1000000000000000000, validAfter=1716150000, validBefore=1716150000, nonce=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef}}, accepted = cdp.openapi_client.models.x402_v2_payment_requirements.x402V2PaymentRequirements( scheme = 'exact', @@ -52,13 +50,13 @@ def make_instance(self, include_optional) -> X402PaymentPayload: url = 'https://api.example.com/premium/resource/123', description = Premium API access for data analysis, mime_type = 'application/json', ), - extensions = {bazaar={discoveryEnabled=true}} + extensions = {bazaar={discoveryEnabled=true}}, + scheme = 'exact', + network = 'base' ) else: return X402PaymentPayload( - x402_version = 1, - scheme = 'exact', - network = 'base', + x402_version = 2, payload = {signature=0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f134801234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1b, authorization={from=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, to=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, value=1000000000000000000, validAfter=1716150000, validBefore=1716150000, nonce=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef}}, accepted = cdp.openapi_client.models.x402_v2_payment_requirements.x402V2PaymentRequirements( scheme = 'exact', @@ -68,6 +66,8 @@ def make_instance(self, include_optional) -> X402PaymentPayload: pay_to = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', max_timeout_seconds = 10, extra = {name=USDC, version=2}, ), + scheme = 'exact', + network = 'base', ) """ diff --git a/python/cdp/openapi_client/test/test_x402_payment_requirements.py b/python/cdp/openapi_client/test/test_x402_payment_requirements.py index ae2b6ffb6..1877733c2 100644 --- a/python/cdp/openapi_client/test/test_x402_payment_requirements.py +++ b/python/cdp/openapi_client/test/test_x402_payment_requirements.py @@ -37,30 +37,30 @@ def make_instance(self, include_optional) -> X402PaymentRequirements: if include_optional: return X402PaymentRequirements( scheme = 'exact', - network = 'eip155:1', + network = 'base', + asset = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', + amount = '1000000', + pay_to = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', + max_timeout_seconds = 10, + extra = {gasLimit=1000000}, max_amount_required = '1000000', resource = 'https://api.example.com/premium/resource/123', description = 'A description of the resource.', mime_type = 'application/json', - output_schema = {data=string}, - pay_to = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', - max_timeout_seconds = 10, - asset = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', - extra = {name=USDC, version=2}, - amount = '1000000' + output_schema = {data=string} ) else: return X402PaymentRequirements( scheme = 'exact', - network = 'eip155:1', + network = 'base', + asset = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', + amount = '1000000', + pay_to = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', + max_timeout_seconds = 10, max_amount_required = '1000000', resource = 'https://api.example.com/premium/resource/123', description = 'A description of the resource.', mime_type = 'application/json', - pay_to = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', - max_timeout_seconds = 10, - asset = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', - amount = '1000000', ) """ diff --git a/python/cdp/openapi_client/test/test_x402_supported_payment_kind.py b/python/cdp/openapi_client/test/test_x402_supported_payment_kind.py index 1bf844db8..07cd3ddc3 100644 --- a/python/cdp/openapi_client/test/test_x402_supported_payment_kind.py +++ b/python/cdp/openapi_client/test/test_x402_supported_payment_kind.py @@ -36,14 +36,14 @@ def make_instance(self, include_optional) -> X402SupportedPaymentKind: model = X402SupportedPaymentKind() if include_optional: return X402SupportedPaymentKind( - x402_version = 1, + x402_version = 2, scheme = 'exact', network = 'base', extra = {feePayer=HpabPRRCFbBKSuJr5PdkVvQc85FyxyTWkFM2obBRSvHT} ) else: return X402SupportedPaymentKind( - x402_version = 1, + x402_version = 2, scheme = 'exact', network = 'base', ) diff --git a/python/cdp/openapi_client/test/test_x402_v1_payment_payload.py b/python/cdp/openapi_client/test/test_x402_v1_payment_payload.py index a4bb54b12..b891b55ca 100644 --- a/python/cdp/openapi_client/test/test_x402_v1_payment_payload.py +++ b/python/cdp/openapi_client/test/test_x402_v1_payment_payload.py @@ -36,14 +36,14 @@ def make_instance(self, include_optional) -> X402V1PaymentPayload: model = X402V1PaymentPayload() if include_optional: return X402V1PaymentPayload( - x402_version = 1, + x402_version = 2, scheme = 'exact', network = 'base', payload = {signature=0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f134801234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1b, authorization={from=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, to=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, value=1000000000000000000, validAfter=1716150000, validBefore=1716150000, nonce=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef}} ) else: return X402V1PaymentPayload( - x402_version = 1, + x402_version = 2, scheme = 'exact', network = 'base', payload = {signature=0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f134801234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1b, authorization={from=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, to=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, value=1000000000000000000, validAfter=1716150000, validBefore=1716150000, nonce=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef}}, diff --git a/python/cdp/openapi_client/test/test_x402_v2_payment_payload.py b/python/cdp/openapi_client/test/test_x402_v2_payment_payload.py index f242e691b..98539aeb7 100644 --- a/python/cdp/openapi_client/test/test_x402_v2_payment_payload.py +++ b/python/cdp/openapi_client/test/test_x402_v2_payment_payload.py @@ -36,7 +36,7 @@ def make_instance(self, include_optional) -> X402V2PaymentPayload: model = X402V2PaymentPayload() if include_optional: return X402V2PaymentPayload( - x402_version = 1, + x402_version = 2, payload = {signature=0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f134801234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1b, authorization={from=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, to=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, value=1000000000000000000, validAfter=1716150000, validBefore=1716150000, nonce=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef}}, accepted = cdp.openapi_client.models.x402_v2_payment_requirements.x402V2PaymentRequirements( scheme = 'exact', @@ -54,7 +54,7 @@ def make_instance(self, include_optional) -> X402V2PaymentPayload: ) else: return X402V2PaymentPayload( - x402_version = 1, + x402_version = 2, payload = {signature=0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f134801234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1b, authorization={from=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, to=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, value=1000000000000000000, validAfter=1716150000, validBefore=1716150000, nonce=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef}}, accepted = cdp.openapi_client.models.x402_v2_payment_requirements.x402V2PaymentRequirements( scheme = 'exact', diff --git a/python/cdp/openapi_client/test/test_x402_v1_payment_payload_payload.py b/python/cdp/openapi_client/test/test_x402_v2_payment_payload_payload.py similarity index 83% rename from python/cdp/openapi_client/test/test_x402_v1_payment_payload_payload.py rename to python/cdp/openapi_client/test/test_x402_v2_payment_payload_payload.py index 9bfaf3c38..9387c9c20 100644 --- a/python/cdp/openapi_client/test/test_x402_v1_payment_payload_payload.py +++ b/python/cdp/openapi_client/test/test_x402_v2_payment_payload_payload.py @@ -15,10 +15,10 @@ import unittest -from cdp.openapi_client.models.x402_v1_payment_payload_payload import X402V1PaymentPayloadPayload +from cdp.openapi_client.models.x402_v2_payment_payload_payload import X402V2PaymentPayloadPayload -class TestX402V1PaymentPayloadPayload(unittest.TestCase): - """X402V1PaymentPayloadPayload unit test stubs""" +class TestX402V2PaymentPayloadPayload(unittest.TestCase): + """X402V2PaymentPayloadPayload unit test stubs""" def setUp(self): pass @@ -26,23 +26,23 @@ def setUp(self): def tearDown(self): pass - def make_instance(self, include_optional) -> X402V1PaymentPayloadPayload: - """Test X402V1PaymentPayloadPayload + def make_instance(self, include_optional) -> X402V2PaymentPayloadPayload: + """Test X402V2PaymentPayloadPayload include_optional is a boolean, when False only required params are included, when True both required and optional params are included """ - # uncomment below to create an instance of `X402V1PaymentPayloadPayload` + # uncomment below to create an instance of `X402V2PaymentPayloadPayload` """ - model = X402V1PaymentPayloadPayload() + model = X402V2PaymentPayloadPayload() if include_optional: - return X402V1PaymentPayloadPayload( + return X402V2PaymentPayloadPayload( signature = '0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f134801234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1b', authorization = {from=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, to=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, value=1000000000000000000, validAfter=1716150000, validBefore=1716150000, nonce=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef}, permit2_authorization = {from=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, permitted={token=0x036CbD53842c5426634e7929541eC2318f3dCF7e, amount=1000000}, spender=0x4020615294c913F045dc10f0a5cdEbd86c280001, nonce=12345678901234567890, deadline=1716150000, witness={to=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, validAfter=1716150000, extra=0x}}, transaction = 'AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAQECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8CBgMBAQAAAAIBAwQAAAAABgIAAAAAAAYDBQEBAAAGBAgAAAAABgUAAAAA6AMAAAAAAAAGBgUBAQEBBgcEAQAAAAYICgMBAQIDBgkCBgAAAAYKAwABAQEGCwMGAQEBBgwDAAABAQAAAAA=' ) else: - return X402V1PaymentPayloadPayload( + return X402V2PaymentPayloadPayload( signature = '0xf3746613c2d920b5fdabc0856f2aeb2d4f88ee6037b8cc5d04a71a4462f134801234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1b', authorization = {from=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, to=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, value=1000000000000000000, validAfter=1716150000, validBefore=1716150000, nonce=0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef}, permit2_authorization = {from=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, permitted={token=0x036CbD53842c5426634e7929541eC2318f3dCF7e, amount=1000000}, spender=0x4020615294c913F045dc10f0a5cdEbd86c280001, nonce=12345678901234567890, deadline=1716150000, witness={to=0x742d35Cc6634C0532925a3b844Bc454e4438f44e, validAfter=1716150000, extra=0x}}, @@ -50,8 +50,8 @@ def make_instance(self, include_optional) -> X402V1PaymentPayloadPayload: ) """ - def testX402V1PaymentPayloadPayload(self): - """Test X402V1PaymentPayloadPayload""" + def testX402V2PaymentPayloadPayload(self): + """Test X402V2PaymentPayloadPayload""" # inst_req_only = self.make_instance(include_optional=False) # inst_req_and_optional = self.make_instance(include_optional=True) diff --git a/python/cdp/policies/request_transformer.py b/python/cdp/policies/request_transformer.py index 1f45f7bc8..c61b341af 100644 --- a/python/cdp/policies/request_transformer.py +++ b/python/cdp/policies/request_transformer.py @@ -1,3 +1,4 @@ +from cdp.openapi_client.models.create_end_user_evm_swap_rule import CreateEndUserEvmSwapRule from cdp.openapi_client.models.eth_value_criterion import EthValueCriterion from cdp.openapi_client.models.evm_address_criterion import EvmAddressCriterion from cdp.openapi_client.models.evm_data_condition import EvmDataCondition as OpenAPIEvmDataCondition @@ -587,6 +588,9 @@ "sendEvmTransaction" ] openapi_criterion_mapping["signEndUserEvmMessage"] = openapi_criterion_mapping["signEvmMessage"] +openapi_criterion_mapping["createEndUserEvmSwap"] = openapi_criterion_mapping[ + "sendEvmTransaction" +] openapi_criterion_mapping["signEndUserEvmTypedData"] = openapi_criterion_mapping["signEvmTypedData"] openapi_criterion_mapping["signEndUserSolTransaction"] = openapi_criterion_mapping[ "signSolTransaction" @@ -610,6 +614,7 @@ "sendUserOperation": SendUserOperationRule, "signEndUserEvmTransaction": SignEndUserEvmTransactionRule, "sendEndUserEvmTransaction": SendEndUserEvmTransactionRule, + "createEndUserEvmSwap": CreateEndUserEvmSwapRule, "signEndUserEvmMessage": SignEndUserEvmMessageRule, "signEndUserEvmTypedData": SignEndUserEvmTypedDataRule, "signEndUserSolTransaction": SignEndUserSolTransactionRule, diff --git a/python/cdp/policies/response_transformer.py b/python/cdp/policies/response_transformer.py index 051fb86b4..1a69764ed 100644 --- a/python/cdp/policies/response_transformer.py +++ b/python/cdp/policies/response_transformer.py @@ -1,5 +1,6 @@ from cdp.openapi_client.models.rule import Rule from cdp.policies.types import ( + CreateEndUserEvmSwapRule as CreateEndUserEvmSwapRuleModel, EthValueCriterion as EthValueCriterionModel, EvmAddressCriterion as EvmAddressCriterionModel, EvmDataCondition as EvmDataConditionModel, @@ -351,6 +352,9 @@ "sendEvmTransaction" ] response_criterion_mapping["signEndUserEvmMessage"] = response_criterion_mapping["signEvmMessage"] +response_criterion_mapping["createEndUserEvmSwap"] = response_criterion_mapping[ + "sendEvmTransaction" +] response_criterion_mapping["signEndUserEvmTypedData"] = response_criterion_mapping[ "signEvmTypedData" ] @@ -376,6 +380,7 @@ "sendUserOperation": SendUserOperationRuleModel, "signEndUserEvmTransaction": SignEndUserEvmTransactionRuleModel, "sendEndUserEvmTransaction": SendEndUserEvmTransactionRuleModel, + "createEndUserEvmSwap": CreateEndUserEvmSwapRuleModel, "signEndUserEvmMessage": SignEndUserEvmMessageRuleModel, "signEndUserEvmTypedData": SignEndUserEvmTypedDataRuleModel, "signEndUserSolTransaction": SignEndUserSolTransactionRuleModel, diff --git a/python/cdp/policies/types.py b/python/cdp/policies/types.py index 661cfa667..14e914c55 100644 --- a/python/cdp/policies/types.py +++ b/python/cdp/policies/types.py @@ -811,6 +811,29 @@ class SendEndUserEvmTransactionRule(BaseModel): ) +class CreateEndUserEvmSwapRule(BaseModel): + """Type representing a 'createEndUserEvmSwap' policy rule that can accept or reject specific operations based on a set of criteria.""" + + action: Action = Field( + ..., + description="Determines whether matching the rule will cause a request to be rejected or accepted. 'accept' will allow the swap, 'reject' will block it.", + ) + operation: Literal["createEndUserEvmSwap"] = Field( + "createEndUserEvmSwap", + description="The operation to which this rule applies. Must be 'createEndUserEvmSwap'.", + ) + criteria: list[ + EthValueCriterion + | EvmAddressCriterion + | EvmNetworkCriterion + | EvmDataCriterion + | NetUSDChangeCriterion + ] = Field( + ..., + description="The set of criteria that must be matched for this rule to apply. Must be compatible with the specified operation type.", + ) + + class SignEndUserEvmMessageRule(BaseModel): """Type representing a 'signEndUserEvmMessage' policy rule that can accept or reject specific operations based on a set of criteria.""" @@ -976,6 +999,7 @@ class SendUserOperationRule(BaseModel): | SendUserOperationRule | SignEndUserEvmTransactionRule | SendEndUserEvmTransactionRule + | CreateEndUserEvmSwapRule | SignEndUserEvmMessageRule | SignEndUserEvmTypedDataRule | SignEndUserSolTransactionRule diff --git a/python/cdp/test/test_policies_client.py b/python/cdp/test/test_policies_client.py index 70c35f93d..5bac5cbdf 100644 --- a/python/cdp/test/test_policies_client.py +++ b/python/cdp/test/test_policies_client.py @@ -11,6 +11,7 @@ from cdp.openapi_client.models.update_policy_request import UpdatePolicyRequest from cdp.policies.request_transformer import map_request_rules_to_openapi_format from cdp.policies.types import ( + CreateEndUserEvmSwapRule, CreatePolicyOptions, EvmAddressCriterion, EvmNetworkCriterion, @@ -206,6 +207,62 @@ async def test_create_policy_with_send_end_user_evm_transaction_rule( assert result.updated_at == policy_model.updated_at +@pytest.mark.asyncio +async def test_create_policy_with_create_end_user_evm_swap_rule( + openapi_policy_model_factory, policy_model_factory +): + """Test that a policy can be created with a CreateEndUserEvmSwapRule.""" + openapi_policy_model = openapi_policy_model_factory() + + mock_policies_api = AsyncMock() + mock_api_clients = AsyncMock() + mock_api_clients.policies = mock_policies_api + mock_policies_api.create_policy = AsyncMock(return_value=openapi_policy_model) + + policy_model = policy_model_factory() + client = PoliciesClient(api_clients=mock_api_clients) + + create_options = CreatePolicyOptions( + scope="account", + description="EndUser EVM Swap Policy", + rules=[ + CreateEndUserEvmSwapRule( + action="reject", + operation="createEndUserEvmSwap", + criteria=[ + EvmAddressCriterion( + type="evmAddress", + addresses=["0x742d35Cc6634C0532925a3b844Bc454e4438f44e"], + operator="not in", + ), + NetUSDChangeCriterion( + type="netUSDChange", + changeCents=10000, + operator=">=", + ), + ], + ) + ], + ) + + result = await client.create_policy(create_options) + + mock_policies_api.create_policy.assert_called_once_with( + create_policy_request=CreatePolicyRequest( + scope=create_options.scope, + description=create_options.description, + rules=map_request_rules_to_openapi_format(create_options.rules), + ), + x_idempotency_key=None, + ) + assert result.id is not None + assert result.scope == policy_model.scope + assert result.description == policy_model.description + assert result.rules == policy_model.rules + assert result.created_at == policy_model.created_at + assert result.updated_at == policy_model.updated_at + + @pytest.mark.asyncio async def test_create_policy_with_sign_end_user_sol_transaction_rule( openapi_policy_model_factory, policy_model_factory diff --git a/typescript/src/CHANGELOG.md b/typescript/src/CHANGELOG.md index 17d612f39..72b5d1dbe 100644 --- a/typescript/src/CHANGELOG.md +++ b/typescript/src/CHANGELOG.md @@ -1,5 +1,11 @@ # CDP SDK Changelog +## Unreleased + +### Minor Changes + +- Added support for the `createEndUserEvmSwap` policy rule, enabling policy controls for end user EVM swap operations with all existing EVM criteria (ethValue, evmAddress, evmNetwork, evmData, netUSDChange). + ## [1.46.1] - 2026-03-30 ### Security fix diff --git a/typescript/src/client/policies/policies.test.ts b/typescript/src/client/policies/policies.test.ts index dde1d8d67..1dfda85cd 100644 --- a/typescript/src/client/policies/policies.test.ts +++ b/typescript/src/client/policies/policies.test.ts @@ -2209,5 +2209,86 @@ describe("PoliciesClient", () => { expect(result).toEqual(mockPolicy); expect(createPolicyMock).toHaveBeenCalledWith(policyWithEvmNetwork, "idem-key"); }); + + it("should permit valid createEndUserEvmSwap policies", async () => { + const createPolicyMock = CdpOpenApiClient.createPolicy as MockedFunction< + typeof CdpOpenApiClient.createPolicy + >; + createPolicyMock.mockResolvedValue(mockPolicy); + + const validSwapPolicy = { + scope: "account" as const, + description: "Swap policy", + rules: [ + { + action: "reject" as const, + operation: "createEndUserEvmSwap" as const, + criteria: [ + { + type: "ethValue" as const, + ethValue: "1000000000000000000", + operator: "<=" as const, + }, + ], + }, + ], + }; + + const result = await client.createPolicy({ + policy: validSwapPolicy, + idempotencyKey: "idem-key", + }); + + expect(result).toEqual(mockPolicy); + expect(createPolicyMock).toHaveBeenCalledWith(validSwapPolicy, "idem-key"); + }); + + it("should create policies with createEndUserEvmSwap rules using all supported criteria", async () => { + const createPolicyMock = CdpOpenApiClient.createPolicy as MockedFunction< + typeof CdpOpenApiClient.createPolicy + >; + createPolicyMock.mockResolvedValue(mockPolicy); + + const swapPolicyAllCriteria = { + scope: "account" as const, + description: "Swap all criteria", + rules: [ + { + action: "accept" as const, + operation: "createEndUserEvmSwap" as const, + criteria: [ + { + type: "ethValue" as const, + ethValue: "500000000000000000", + operator: "<=" as const, + }, + { + type: "evmAddress" as const, + addresses: ["0x1234567890123456789012345678901234567890" as const], + operator: "in" as const, + }, + { + type: "evmNetwork" as const, + networks: ["base", "base-sepolia"] as const, + operator: "in" as const, + }, + { + type: "netUSDChange" as const, + changeCents: 10000, + operator: "<=" as const, + }, + ], + }, + ], + }; + + const result = await client.createPolicy({ + policy: swapPolicyAllCriteria, + idempotencyKey: "idem-key", + }); + + expect(result).toEqual(mockPolicy); + expect(createPolicyMock).toHaveBeenCalledWith(swapPolicyAllCriteria, "idem-key"); + }); }); }); diff --git a/typescript/src/policies/evmSchema.ts b/typescript/src/policies/evmSchema.ts index 61e5e0812..a99fd2f4d 100644 --- a/typescript/src/policies/evmSchema.ts +++ b/typescript/src/policies/evmSchema.ts @@ -551,6 +551,26 @@ export type SendEndUserEvmTransactionCriteria = z.infer< typeof SendEndUserEvmTransactionCriteriaSchema >; +/** + * Schema for criteria used in CreateEndUserEvmSwap operations + */ +export const CreateEndUserEvmSwapCriteriaSchema = z + .array( + z.discriminatedUnion("type", [ + EthValueCriterionSchema, + EvmAddressCriterionSchema, + PrepareUserOperationEvmNetworkCriterionSchema, + EvmDataCriterionSchema, + NetUSDChangeCriterionSchema, + ]), + ) + .max(10) + .min(1); +/** + * Type representing a set of criteria for the createEndUserEvmSwap operation. + */ +export type CreateEndUserEvmSwapCriteria = z.infer; + /** * Schema for criteria used in SignEndUserEvmMessage operations */ @@ -810,6 +830,29 @@ export const SendEndUserEvmTransactionRuleSchema = z.object({ }); export type SendEndUserEvmTransactionRule = z.infer; +/** + * Type representing a 'createEndUserEvmSwap' policy rule that can accept or reject specific operations + * based on a set of criteria. + */ +export const CreateEndUserEvmSwapRuleSchema = z.object({ + /** + * Determines whether matching the rule will cause a request to be rejected or accepted. + * "accept" will allow the swap, "reject" will block it. + */ + action: ActionEnum, + /** + * The operation to which this rule applies. + * Must be "createEndUserEvmSwap". + */ + operation: z.literal("createEndUserEvmSwap"), + /** + * The set of criteria that must be matched for this rule to apply. + * Must be compatible with the specified operation type. + */ + criteria: CreateEndUserEvmSwapCriteriaSchema, +}); +export type CreateEndUserEvmSwapRule = z.infer; + /** * Type representing a 'signEndUserEvmMessage' policy rule that can accept or reject specific operations * based on a set of criteria. diff --git a/typescript/src/policies/types.ts b/typescript/src/policies/types.ts index 164f14756..2feed0d39 100644 --- a/typescript/src/policies/types.ts +++ b/typescript/src/policies/types.ts @@ -10,6 +10,7 @@ import { SendUserOperationRuleSchema, SignEndUserEvmTransactionRuleSchema, SendEndUserEvmTransactionRuleSchema, + CreateEndUserEvmSwapRuleSchema, SignEndUserEvmMessageRuleSchema, SignEndUserEvmTypedDataRuleSchema, } from "./evmSchema.js"; @@ -66,6 +67,7 @@ export const RuleSchema = z.discriminatedUnion("operation", [ SendUserOperationRuleSchema, SignEndUserEvmTransactionRuleSchema, SendEndUserEvmTransactionRuleSchema, + CreateEndUserEvmSwapRuleSchema, SignEndUserEvmMessageRuleSchema, SignEndUserEvmTypedDataRuleSchema, SignEndUserSolTransactionRuleSchema,