├── .github ├── pull_request_template.md └── workflows │ ├── e2e_tests.yml │ ├── lint.yml │ ├── publish.yml │ ├── publish_docs.yml │ └── unit_tests.yml ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── Makefile ├── README.md ├── SECURITY.md ├── cdp ├── __init__.py ├── __version__.py ├── address.py ├── address_reputation.py ├── api_clients.py ├── api_key_utils.py ├── asset.py ├── balance.py ├── balance_map.py ├── cdp.py ├── cdp_api_client.py ├── client │ ├── __init__.py │ ├── api │ │ ├── __init__.py │ │ ├── addresses_api.py │ │ ├── assets_api.py │ │ ├── balance_history_api.py │ │ ├── contract_events_api.py │ │ ├── contract_invocations_api.py │ │ ├── external_addresses_api.py │ │ ├── fund_api.py │ │ ├── mpc_wallet_stake_api.py │ │ ├── networks_api.py │ │ ├── onchain_identity_api.py │ │ ├── reputation_api.py │ │ ├── server_signers_api.py │ │ ├── smart_contracts_api.py │ │ ├── smart_wallets_api.py │ │ ├── stake_api.py │ │ ├── trades_api.py │ │ ├── transaction_history_api.py │ │ ├── transfers_api.py │ │ ├── users_api.py │ │ ├── validators_api.py │ │ ├── wallet_stake_api.py │ │ ├── wallets_api.py │ │ └── webhooks_api.py │ ├── api_client.py │ ├── api_response.py │ ├── configuration.py │ ├── exceptions.py │ ├── models │ │ ├── __init__.py │ │ ├── abi.py │ │ ├── address.py │ │ ├── address_balance_list.py │ │ ├── address_historical_balance_list.py │ │ ├── address_list.py │ │ ├── address_reputation.py │ │ ├── address_reputation_metadata.py │ │ ├── address_risk.py │ │ ├── address_transaction_list.py │ │ ├── asset.py │ │ ├── balance.py │ │ ├── broadcast_contract_invocation_request.py │ │ ├── broadcast_external_transaction200_response.py │ │ ├── broadcast_external_transaction_request.py │ │ ├── broadcast_external_transfer_request.py │ │ ├── broadcast_staking_operation_request.py │ │ ├── broadcast_trade_request.py │ │ ├── broadcast_transfer_request.py │ │ ├── broadcast_user_operation_request.py │ │ ├── build_staking_operation_request.py │ │ ├── call.py │ │ ├── compile_smart_contract_request.py │ │ ├── compiled_smart_contract.py │ │ ├── contract_event.py │ │ ├── contract_event_list.py │ │ ├── contract_invocation.py │ │ ├── contract_invocation_list.py │ │ ├── create_address_request.py │ │ ├── create_contract_invocation_request.py │ │ ├── create_external_transfer_request.py │ │ ├── create_fund_operation_request.py │ │ ├── create_fund_quote_request.py │ │ ├── create_payload_signature_request.py │ │ ├── create_server_signer_request.py │ │ ├── create_smart_contract_request.py │ │ ├── create_smart_wallet_request.py │ │ ├── create_staking_operation_request.py │ │ ├── create_trade_request.py │ │ ├── create_transfer_request.py │ │ ├── create_user_operation_request.py │ │ ├── create_wallet_request.py │ │ ├── create_wallet_request_wallet.py │ │ ├── create_wallet_webhook_request.py │ │ ├── create_webhook_request.py │ │ ├── crypto_amount.py │ │ ├── deploy_smart_contract_request.py │ │ ├── erc20_transfer_event.py │ │ ├── erc721_transfer_event.py │ │ ├── error.py │ │ ├── ethereum_token_transfer.py │ │ ├── ethereum_transaction.py │ │ ├── ethereum_transaction_access.py │ │ ├── ethereum_transaction_access_list.py │ │ ├── ethereum_transaction_flattened_trace.py │ │ ├── ethereum_validator_metadata.py │ │ ├── faucet_transaction.py │ │ ├── feature_set.py │ │ ├── fetch_historical_staking_balances200_response.py │ │ ├── fetch_staking_rewards200_response.py │ │ ├── fetch_staking_rewards_request.py │ │ ├── fiat_amount.py │ │ ├── fund_operation.py │ │ ├── fund_operation_fees.py │ │ ├── fund_operation_list.py │ │ ├── fund_quote.py │ │ ├── get_staking_context_request.py │ │ ├── historical_balance.py │ │ ├── multi_token_contract_options.py │ │ ├── network.py │ │ ├── network_identifier.py │ │ ├── nft_contract_options.py │ │ ├── onchain_name.py │ │ ├── onchain_name_list.py │ │ ├── onchain_name_text_records_inner.py │ │ ├── payload_signature.py │ │ ├── payload_signature_list.py │ │ ├── read_contract_request.py │ │ ├── read_smart_contract_request.py │ │ ├── register_smart_contract_request.py │ │ ├── seed_creation_event.py │ │ ├── seed_creation_event_result.py │ │ ├── server_signer.py │ │ ├── server_signer_event.py │ │ ├── server_signer_event_event.py │ │ ├── server_signer_event_list.py │ │ ├── server_signer_list.py │ │ ├── signature_creation_event.py │ │ ├── signature_creation_event_result.py │ │ ├── signed_voluntary_exit_message_metadata.py │ │ ├── smart_contract.py │ │ ├── smart_contract_activity_event.py │ │ ├── smart_contract_list.py │ │ ├── smart_contract_options.py │ │ ├── smart_contract_type.py │ │ ├── smart_wallet.py │ │ ├── smart_wallet_list.py │ │ ├── solidity_value.py │ │ ├── sponsored_send.py │ │ ├── staking_balance.py │ │ ├── staking_context.py │ │ ├── staking_context_context.py │ │ ├── staking_operation.py │ │ ├── staking_operation_metadata.py │ │ ├── staking_reward.py │ │ ├── staking_reward_format.py │ │ ├── staking_reward_usd_value.py │ │ ├── token_contract_options.py │ │ ├── token_transfer_type.py │ │ ├── trade.py │ │ ├── trade_list.py │ │ ├── transaction.py │ │ ├── transaction_content.py │ │ ├── transaction_log.py │ │ ├── transaction_receipt.py │ │ ├── transaction_type.py │ │ ├── transfer.py │ │ ├── transfer_list.py │ │ ├── update_smart_contract_request.py │ │ ├── update_webhook_request.py │ │ ├── user.py │ │ ├── user_operation.py │ │ ├── validator.py │ │ ├── validator_details.py │ │ ├── validator_list.py │ │ ├── validator_status.py │ │ ├── wallet.py │ │ ├── wallet_list.py │ │ ├── webhook.py │ │ ├── webhook_event_filter.py │ │ ├── webhook_event_type.py │ │ ├── webhook_event_type_filter.py │ │ ├── webhook_list.py │ │ ├── webhook_smart_contract_event_filter.py │ │ ├── webhook_status.py │ │ └── webhook_wallet_activity_filter.py │ ├── py.typed │ └── rest.py ├── constants.py ├── contract_invocation.py ├── crypto_amount.py ├── errors.py ├── evm_call_types.py ├── external_address.py ├── faucet_transaction.py ├── fiat_amount.py ├── fund_operation.py ├── fund_quote.py ├── hash_utils.py ├── historical_balance.py ├── mnemonic_seed_phrase.py ├── network.py ├── payload_signature.py ├── py.typed ├── smart_contract.py ├── smart_wallet.py ├── sponsored_send.py ├── trade.py ├── transaction.py ├── transfer.py ├── user_operation.py ├── wallet.py ├── wallet_address.py ├── wallet_data.py └── webhook.py ├── docs ├── Makefile ├── README.md ├── cdp.client.api.rst ├── cdp.client.models.rst ├── cdp.client.rst ├── cdp.rst ├── conf.py ├── index.rst ├── make.bat └── modules.rst ├── poetry.lock ├── pyproject.toml └── tests ├── __init__.py ├── conftest.py ├── factories ├── __init__.py ├── account_factory.py ├── address_factory.py ├── address_reputation_factory.py ├── api_key_factory.py ├── asset_factory.py ├── balance_factory.py ├── compiled_smart_contract_factory.py ├── contract_invocation_factory.py ├── crypto_amount_factory.py ├── faucet_transaction_factory.py ├── fund_operation_factory.py ├── fund_quote_factory.py ├── historical_balance_factory.py ├── payload_signature_factory.py ├── smart_contract_factory.py ├── smart_wallet_factory.py ├── sponsored_send_factory.py ├── trade_factory.py ├── transaction_factory.py ├── transfer_factory.py ├── user_operation_factory.py ├── wallet_address_factory.py ├── wallet_factory.py └── webhook_factory.py ├── test_address.py ├── test_address_reputation.py ├── test_api_client.py ├── test_api_key_utils.py ├── test_asset.py ├── test_balance.py ├── test_cdp.py ├── test_contract_invocation.py ├── test_crypto_amount.py ├── test_e2e.py ├── test_errors.py ├── test_evm_call_types.py ├── test_faucet_transaction.py ├── test_fiat_amount.py ├── test_fund_operation.py ├── test_fund_quote.py ├── test_hash_utils.py ├── test_historical_balance.py ├── test_network.py ├── test_payload_signature.py ├── test_smart_contract.py ├── test_smart_wallet.py ├── test_trade.py ├── test_transaction.py ├── test_transfer.py ├── test_user_operation.py ├── test_wallet.py ├── test_wallet_address.py └── test_webhook.py /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ### What changed? Why? 2 | 3 | 4 | #### Qualified Impact 5 | 8 | -------------------------------------------------------------------------------- /.github/workflows/e2e_tests.yml: -------------------------------------------------------------------------------- 1 | name: Run E2E Tests 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | test: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v3 10 | 11 | - name: Set up Python 3.10 12 | uses: actions/setup-python@v4 13 | with: 14 | python-version: '3.10' 15 | 16 | - name: Install Poetry 17 | uses: snok/install-poetry@v1 18 | with: 19 | version: latest 20 | virtualenvs-create: true 21 | virtualenvs-in-project: true 22 | 23 | - name: Load cached venv 24 | id: cached-poetry-dependencies 25 | uses: actions/cache@v3 26 | with: 27 | path: ./.venv 28 | key: venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }} 29 | 30 | - name: Install dependencies 31 | if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' 32 | run: poetry install --with dev 33 | 34 | - name: Run tests 35 | env: 36 | CDP_API_KEY_NAME: ${{ secrets.CDP_API_KEY_NAME }} 37 | CDP_API_KEY_PRIVATE_KEY: ${{ secrets.CDP_API_KEY_PRIVATE_KEY }} 38 | NETWORK_ID: ${{ secrets.NETWORK_ID}} 39 | WALLET_DATA: ${{ secrets.WALLET_DATA }} 40 | run: make e2e 41 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | lint: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v3 11 | 12 | - name: Set up Python 13 | uses: actions/setup-python@v4 14 | with: 15 | python-version: '3.10' 16 | 17 | - name: Install Poetry 18 | uses: snok/install-poetry@v1 19 | with: 20 | version: latest 21 | virtualenvs-create: true 22 | virtualenvs-in-project: true 23 | 24 | - name: Load cached venv 25 | id: cached-poetry-dependencies 26 | uses: actions/cache@v3 27 | with: 28 | path: ./.venv 29 | key: venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }} 30 | 31 | - name: Install dependencies 32 | if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' 33 | run: poetry install --with dev 34 | 35 | - name: Lint 36 | run: make lint 37 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Release to PyPI 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | deploy: 9 | runs-on: ubuntu-latest 10 | environment: 11 | name: pypi 12 | url: https://pypi.org/p/cdp-sdk 13 | permissions: 14 | contents: read 15 | id-token: write 16 | 17 | steps: 18 | - uses: actions/checkout@v3 19 | 20 | - name: Set up Python 3.10 21 | uses: actions/setup-python@v4 22 | with: 23 | python-version: '3.10' 24 | 25 | - name: Install Poetry 26 | uses: snok/install-poetry@v1 27 | with: 28 | version: latest 29 | virtualenvs-create: true 30 | virtualenvs-in-project: true 31 | 32 | - name: Install dependencies 33 | run: poetry install --only main 34 | 35 | - name: Build package 36 | run: poetry build 37 | 38 | - name: Publish package 39 | uses: pypa/gh-action-pypi-publish@release/v1 40 | with: 41 | password: ${{ secrets.PYPI_API_TOKEN }} 42 | -------------------------------------------------------------------------------- /.github/workflows/publish_docs.yml: -------------------------------------------------------------------------------- 1 | name: Publish Docs to Github Pages 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | docs: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v3 13 | 14 | - name: Set up Python 15 | uses: actions/setup-python@v4 16 | with: 17 | python-version: '3.10' 18 | 19 | - name: Install Poetry 20 | uses: snok/install-poetry@v1 21 | with: 22 | version: latest 23 | virtualenvs-create: true 24 | virtualenvs-in-project: true 25 | 26 | - name: Load cached venv 27 | id: cached-poetry-dependencies 28 | uses: actions/cache@v3 29 | with: 30 | path: ./.venv 31 | key: venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }} 32 | 33 | - name: Install dependencies 34 | if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' 35 | run: poetry install --with dev 36 | 37 | - name: Build Sphinx Documentation 38 | run: | 39 | make docs 40 | cd docs 41 | poetry run make html 42 | 43 | - name: Deploy to Github Pages 44 | uses: peaceiris/actions-gh-pages@v4 45 | with: 46 | github_token: ${{ secrets.GITHUB_TOKEN }} 47 | publish_dir: ./docs/_build/html 48 | keep_files: false 49 | -------------------------------------------------------------------------------- /.github/workflows/unit_tests.yml: -------------------------------------------------------------------------------- 1 | name: Run Unit Tests 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | test: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | matrix: 10 | python: ['3.10', '3.11', '3.12'] 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | 15 | - name: Set up Python ${{ matrix.python }} 16 | uses: actions/setup-python@v4 17 | with: 18 | python-version: ${{ matrix.python }} 19 | 20 | - name: Install Poetry 21 | uses: snok/install-poetry@v1 22 | with: 23 | version: latest 24 | virtualenvs-create: true 25 | virtualenvs-in-project: true 26 | 27 | - name: Install dependencies 28 | if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' 29 | run: poetry install --with dev 30 | 31 | - name: Run tests 32 | run: make test 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | .coverage 4 | 5 | .python-version 6 | 7 | **/__pycache__/ 8 | 9 | .pytest_cache 10 | 11 | .ruff_cache 12 | 13 | **/_build/ 14 | 15 | **/build/ 16 | 17 | cdp_sdk.egg-info/ 18 | 19 | venv/ 20 | .venv/ 21 | 22 | env/ 23 | .env/ 24 | .env.local/ 25 | .env.test/ 26 | 27 | *~ 28 | \#*\# 29 | .\#* 30 | .projectile 31 | 32 | .idea/ 33 | 34 | dist/ -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guide 2 | 3 | ## Development 4 | 5 | ### Python Version 6 | 7 | Developing in this repository requires Python 3.10 or higher. 8 | 9 | ### Set-up 10 | 11 | Clone the repo by running: 12 | 13 | ```bash 14 | git clone git@github.com:coinbase/cdp-sdk-python.git 15 | ``` 16 | 17 | To install all dependencies, run: 18 | 19 | ```bash 20 | make install-deps 21 | ``` 22 | 23 | ### Formatting 24 | 25 | To format the code, run: 26 | 27 | ```bash 28 | make format 29 | ``` 30 | 31 | ### Linting 32 | 33 | To detect all lint errors, run: 34 | 35 | ```bash 36 | make lint 37 | ``` 38 | 39 | To autocorrect all lint errors, run: 40 | 41 | ```bash 42 | make lint-fix 43 | ``` 44 | 45 | ### Testing 46 | To run all tests, run: 47 | 48 | ```bash 49 | make test 50 | ``` 51 | 52 | ### Generating Documentation 53 | 54 | To build and view the documentation locally, run: 55 | 56 | ```bash 57 | make local-docs 58 | ``` -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache-2.0 License 2 | 3 | Copyright 2024 Coinbase 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: format 2 | format: 3 | poetry run ruff format . 4 | 5 | .PHONY: lint 6 | lint: 7 | poetry run ruff check . 8 | 9 | .PHONY: lint-fix 10 | lint-fix: 11 | poetry run ruff check . --fix 12 | 13 | .PHONY: test 14 | test: 15 | poetry run pytest -m "not e2e" 16 | 17 | .PHONY: e2e 18 | e2e: 19 | poetry run pytest -m "e2e" 20 | 21 | .PHONY: repl 22 | repl: 23 | poetry run python 24 | 25 | .PHONY: install-deps 26 | install-deps: 27 | poetry install 28 | 29 | .PHONY: docs 30 | docs: 31 | poetry run sphinx-apidoc -f -o docs/ ./cdp/ 32 | 33 | .PHONY: local-docs 34 | local-docs: docs 35 | cd docs && make html && open ./_build/html/index.html 36 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | The Coinbase team takes security seriously. Please do not file a public ticket discussing a potential vulnerability. 4 | 5 | Please report your findings through our [HackerOne][1] program. 6 | 7 | [1]: https://hackerone.com/coinbase 8 | -------------------------------------------------------------------------------- /cdp/__init__.py: -------------------------------------------------------------------------------- 1 | from cdp.__version__ import __version__ 2 | from cdp.address import Address 3 | from cdp.asset import Asset 4 | from cdp.balance import Balance 5 | from cdp.balance_map import BalanceMap 6 | from cdp.cdp import Cdp 7 | from cdp.contract_invocation import ContractInvocation 8 | from cdp.evm_call_types import EncodedCall, FunctionCall 9 | from cdp.external_address import ExternalAddress 10 | from cdp.faucet_transaction import FaucetTransaction 11 | from cdp.hash_utils import hash_message, hash_typed_data_message 12 | from cdp.mnemonic_seed_phrase import MnemonicSeedPhrase 13 | from cdp.network import Network, SupportedChainId 14 | from cdp.payload_signature import PayloadSignature 15 | from cdp.smart_contract import SmartContract 16 | from cdp.smart_wallet import SmartWallet, to_smart_wallet 17 | from cdp.sponsored_send import SponsoredSend 18 | from cdp.trade import Trade 19 | from cdp.transaction import Transaction 20 | from cdp.transfer import Transfer 21 | from cdp.user_operation import UserOperation 22 | from cdp.wallet import Wallet 23 | from cdp.wallet_address import WalletAddress 24 | from cdp.wallet_data import WalletData 25 | from cdp.webhook import Webhook 26 | 27 | __all__ = [ 28 | "Address", 29 | "Asset", 30 | "Balance", 31 | "BalanceMap", 32 | "Cdp", 33 | "ContractInvocation", 34 | "ExternalAddress", 35 | "FaucetTransaction", 36 | "MnemonicSeedPhrase", 37 | "PayloadSignature", 38 | "SmartContract", 39 | "SponsoredSend", 40 | "Trade", 41 | "Transaction", 42 | "Transfer", 43 | "Wallet", 44 | "WalletAddress", 45 | "WalletData", 46 | "Webhook", 47 | "to_smart_wallet", 48 | "SmartWallet", 49 | "__version__", 50 | "hash_message", 51 | "hash_typed_data_message", 52 | "Network", 53 | "SupportedChainId", 54 | "EncodedCall", 55 | "FunctionCall", 56 | "UserOperation", 57 | "Network", 58 | ] 59 | -------------------------------------------------------------------------------- /cdp/__version__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.21.0" 2 | -------------------------------------------------------------------------------- /cdp/address_reputation.py: -------------------------------------------------------------------------------- 1 | from cdp.client import AddressReputationMetadata 2 | from cdp.client.models.address_reputation import AddressReputation as AddressReputationModel 3 | 4 | 5 | class AddressReputation: 6 | """A representation of the reputation of a blockchain address.""" 7 | 8 | def __init__(self, model: AddressReputationModel) -> None: 9 | """Initialize the AddressReputation class.""" 10 | if not model: 11 | raise ValueError("model is required") 12 | 13 | self._score = model.score 14 | self._metadata = model.metadata 15 | 16 | @property 17 | def metadata(self) -> AddressReputationMetadata: 18 | """Return the metadata of the address.""" 19 | return self._metadata 20 | 21 | @property 22 | def score(self) -> int: 23 | """Return the score of the address.""" 24 | return self._score 25 | 26 | @property 27 | def risky(self) -> bool: 28 | """Return whether the address is risky.""" 29 | return self.score < 0 30 | 31 | def __str__(self) -> str: 32 | """Return a string representation of the AddressReputation.""" 33 | metadata = ", ".join(f"{key}={getattr(self.metadata, key)}" for key in vars(self.metadata)) 34 | return f"Address Reputation: (score={self.score}, metadata=({metadata}))" 35 | 36 | def __repr__(self) -> str: 37 | """Return a string representation of the AddressReputation.""" 38 | return str(self) 39 | -------------------------------------------------------------------------------- /cdp/api_key_utils.py: -------------------------------------------------------------------------------- 1 | import base64 2 | 3 | from cryptography.hazmat.primitives import serialization 4 | from cryptography.hazmat.primitives.asymmetric import ed25519 5 | 6 | 7 | def _parse_private_key(key_str: str): 8 | """Parse a private key from a given string representation. 9 | 10 | Args: 11 | key_str (str): A string representing the private key. It should be either a PEM-encoded 12 | key (for ECDSA keys) or a base64-encoded string (for Ed25519 keys). 13 | 14 | Returns: 15 | An instance of a private key. Specifically: 16 | 17 | Raises: 18 | ValueError: If the key cannot be parsed as a valid PEM-encoded key or a base64-encoded 19 | Ed25519 private key. 20 | 21 | """ 22 | key_data = key_str.encode() 23 | try: 24 | return serialization.load_pem_private_key(key_data, password=None) 25 | except Exception: 26 | try: 27 | decoded_key = base64.b64decode(key_str) 28 | if len(decoded_key) == 32: 29 | return ed25519.Ed25519PrivateKey.from_private_bytes(decoded_key) 30 | elif len(decoded_key) == 64: 31 | return ed25519.Ed25519PrivateKey.from_private_bytes(decoded_key[:32]) 32 | else: 33 | raise ValueError("Ed25519 private key must be 32 or 64 bytes after base64 decoding") 34 | except Exception as e: 35 | raise ValueError("Could not parse the private key") from e 36 | -------------------------------------------------------------------------------- /cdp/balance.py: -------------------------------------------------------------------------------- 1 | from decimal import Decimal 2 | 3 | from cdp.asset import Asset 4 | from cdp.client.models.balance import Balance as BalanceModel 5 | 6 | 7 | class Balance: 8 | """A class representing a balance.""" 9 | 10 | def __init__(self, amount: Decimal, asset: Asset, asset_id: str | None = None): 11 | """Initialize the Balance class. 12 | 13 | Args: 14 | amount (Decimal): The amount. 15 | asset (Asset): The asset. 16 | asset_id (Optional[str]): The asset ID. 17 | 18 | """ 19 | self._amount = amount 20 | self._asset = asset 21 | self._asset_id = asset_id if asset_id is not None else asset.asset_id 22 | 23 | @staticmethod 24 | def from_model(model: BalanceModel, asset_id: str | None = None) -> "Balance": 25 | """Create a Balance instance from a model. 26 | 27 | Args: 28 | model (BalanceModel): The model representing the balance. 29 | asset_id (Optional[str]): The asset ID. 30 | 31 | Returns: 32 | Balance: The Balance instance. 33 | 34 | """ 35 | asset = Asset.from_model(model.asset, asset_id=asset_id) 36 | 37 | return Balance( 38 | amount=asset.from_atomic_amount(model.amount), 39 | asset=asset, 40 | asset_id=asset_id, 41 | ) 42 | 43 | @property 44 | def amount(self) -> Decimal: 45 | """Get the amount. 46 | 47 | Returns: 48 | Decimal: The amount. 49 | 50 | """ 51 | return self._amount 52 | 53 | @property 54 | def asset(self) -> Asset: 55 | """Get the asset. 56 | 57 | Returns: 58 | Asset: The asset. 59 | 60 | """ 61 | return self._asset 62 | 63 | @property 64 | def asset_id(self) -> str: 65 | """Get the asset ID. 66 | 67 | Returns: 68 | str: The asset ID. 69 | 70 | """ 71 | return self._asset_id 72 | 73 | def __str__(self) -> str: 74 | """Return a string representation of the Balance.""" 75 | return f"Balance: (amount: {self.amount}, asset: {self.asset})" 76 | 77 | def __repr__(self) -> str: 78 | """Return a string representation of the Balance.""" 79 | return str(self) 80 | -------------------------------------------------------------------------------- /cdp/balance_map.py: -------------------------------------------------------------------------------- 1 | import json 2 | from decimal import Decimal 3 | 4 | from cdp.balance import Balance 5 | from cdp.client.models.balance import Balance as BalanceModel 6 | 7 | 8 | class BalanceMap(dict[str, Decimal]): 9 | """A class representing asset balances. 10 | 11 | This class extends the built-in dict class, where keys are asset IDs (str) 12 | and values are balance amounts (Decimal). 13 | """ 14 | 15 | @classmethod 16 | def from_models(cls, models: list[BalanceModel]) -> "BalanceMap": 17 | """Create a BalanceMap instance from a list of BalanceModel objects. 18 | 19 | Args: 20 | models (List[BalanceModel]): A list of BalanceModel objects. 21 | 22 | Returns: 23 | BalanceMap: A new BalanceMap instance populated with the given models. 24 | 25 | """ 26 | balance_map = cls() 27 | 28 | for model in models: 29 | balance = Balance.from_model(model) 30 | balance_map.add(balance) 31 | 32 | return balance_map 33 | 34 | def add(self, balance: Balance) -> None: 35 | """Add a Balance object to the BalanceMap. 36 | 37 | Args: 38 | balance (Balance): The Balance object to add. 39 | 40 | Raises: 41 | ValueError: If the provided balance is not a Balance instance. 42 | 43 | """ 44 | if not isinstance(balance, Balance): 45 | raise ValueError("balance must be a Balance instance") 46 | 47 | self[balance.asset_id] = balance.amount 48 | 49 | def __str__(self) -> str: 50 | """Return a JSON string representation of the BalanceMap. 51 | 52 | Returns: 53 | str: A JSON string with asset IDs as keys and formatted balance amounts as values. 54 | 55 | """ 56 | result: dict[str, str] = {} 57 | 58 | for asset_id, amount in self.items(): 59 | amount_str = format(amount, "f") 60 | 61 | if amount == amount.to_integral(): 62 | amount_str = str(int(amount)) 63 | 64 | result[asset_id] = amount_str 65 | 66 | return json.dumps(result, separators=(",", ":")) 67 | 68 | def __repr__(self) -> str: 69 | """Return a string representation of the BalanceMap. 70 | 71 | Returns: 72 | str: The string representation of the BalanceMap. 73 | 74 | """ 75 | return str(self) 76 | -------------------------------------------------------------------------------- /cdp/client/api/__init__.py: -------------------------------------------------------------------------------- 1 | # flake8: noqa 2 | 3 | # import apis into api package 4 | from cdp.client.api.addresses_api import AddressesApi 5 | from cdp.client.api.assets_api import AssetsApi 6 | from cdp.client.api.balance_history_api import BalanceHistoryApi 7 | from cdp.client.api.contract_events_api import ContractEventsApi 8 | from cdp.client.api.contract_invocations_api import ContractInvocationsApi 9 | from cdp.client.api.external_addresses_api import ExternalAddressesApi 10 | from cdp.client.api.fund_api import FundApi 11 | from cdp.client.api.mpc_wallet_stake_api import MPCWalletStakeApi 12 | from cdp.client.api.networks_api import NetworksApi 13 | from cdp.client.api.onchain_identity_api import OnchainIdentityApi 14 | from cdp.client.api.reputation_api import ReputationApi 15 | from cdp.client.api.server_signers_api import ServerSignersApi 16 | from cdp.client.api.smart_contracts_api import SmartContractsApi 17 | from cdp.client.api.smart_wallets_api import SmartWalletsApi 18 | from cdp.client.api.stake_api import StakeApi 19 | from cdp.client.api.trades_api import TradesApi 20 | from cdp.client.api.transaction_history_api import TransactionHistoryApi 21 | from cdp.client.api.transfers_api import TransfersApi 22 | from cdp.client.api.users_api import UsersApi 23 | from cdp.client.api.wallets_api import WalletsApi 24 | from cdp.client.api.webhooks_api import WebhooksApi 25 | 26 | -------------------------------------------------------------------------------- /cdp/client/api_response.py: -------------------------------------------------------------------------------- 1 | """API response object.""" 2 | 3 | from __future__ import annotations 4 | from typing import Optional, Generic, Mapping, TypeVar 5 | from pydantic import Field, StrictInt, StrictBytes, BaseModel 6 | 7 | T = TypeVar("T") 8 | 9 | class ApiResponse(BaseModel, Generic[T]): 10 | """ 11 | API response object 12 | """ 13 | 14 | status_code: StrictInt = Field(description="HTTP status code") 15 | headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") 16 | data: T = Field(description="Deserialized data given the data type") 17 | raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") 18 | 19 | model_config = { 20 | "arbitrary_types_allowed": True 21 | } 22 | -------------------------------------------------------------------------------- /cdp/client/models/abi.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class ABI(BaseModel): 26 | """ 27 | Smart Contract to be registered 28 | """ # noqa: E501 29 | abi: StrictStr = Field(description="ABI of the smart contract") 30 | contract_name: StrictStr = Field(description="Name of the smart contract") 31 | __properties: ClassVar[List[str]] = ["abi", "contract_name"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of ABI from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of ABI from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "abi": obj.get("abi"), 85 | "contract_name": obj.get("contract_name") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/address_risk.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictInt 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class AddressRisk(BaseModel): 26 | """ 27 | The risk score of a blockchain address. 28 | """ # noqa: E501 29 | risk_score: StrictInt = Field(description="The lower the score is, the higher the risk is. The score lies between -100 to 0.") 30 | __properties: ClassVar[List[str]] = ["risk_score"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of AddressRisk from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of AddressRisk from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "risk_score": obj.get("risk_score") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /cdp/client/models/balance.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from cdp.client.models.asset import Asset 23 | from typing import Optional, Set 24 | from typing_extensions import Self 25 | 26 | class Balance(BaseModel): 27 | """ 28 | The balance of an asset onchain 29 | """ # noqa: E501 30 | amount: StrictStr = Field(description="The amount in the atomic units of the asset") 31 | asset: Asset 32 | __properties: ClassVar[List[str]] = ["amount", "asset"] 33 | 34 | model_config = ConfigDict( 35 | populate_by_name=True, 36 | validate_assignment=True, 37 | protected_namespaces=(), 38 | ) 39 | 40 | 41 | def to_str(self) -> str: 42 | """Returns the string representation of the model using alias""" 43 | return pprint.pformat(self.model_dump(by_alias=True)) 44 | 45 | def to_json(self) -> str: 46 | """Returns the JSON representation of the model using alias""" 47 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 48 | return json.dumps(self.to_dict()) 49 | 50 | @classmethod 51 | def from_json(cls, json_str: str) -> Optional[Self]: 52 | """Create an instance of Balance from a JSON string""" 53 | return cls.from_dict(json.loads(json_str)) 54 | 55 | def to_dict(self) -> Dict[str, Any]: 56 | """Return the dictionary representation of the model using alias. 57 | 58 | This has the following differences from calling pydantic's 59 | `self.model_dump(by_alias=True)`: 60 | 61 | * `None` is only added to the output dict for nullable fields that 62 | were set at model initialization. Other fields with value `None` 63 | are ignored. 64 | """ 65 | excluded_fields: Set[str] = set([ 66 | ]) 67 | 68 | _dict = self.model_dump( 69 | by_alias=True, 70 | exclude=excluded_fields, 71 | exclude_none=True, 72 | ) 73 | # override the default output from pydantic by calling `to_dict()` of asset 74 | if self.asset: 75 | _dict['asset'] = self.asset.to_dict() 76 | return _dict 77 | 78 | @classmethod 79 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 80 | """Create an instance of Balance from a dict""" 81 | if obj is None: 82 | return None 83 | 84 | if not isinstance(obj, dict): 85 | return cls.model_validate(obj) 86 | 87 | _obj = cls.model_validate({ 88 | "amount": obj.get("amount"), 89 | "asset": Asset.from_dict(obj["asset"]) if obj.get("asset") is not None else None 90 | }) 91 | return _obj 92 | 93 | 94 | -------------------------------------------------------------------------------- /cdp/client/models/broadcast_contract_invocation_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class BroadcastContractInvocationRequest(BaseModel): 26 | """ 27 | BroadcastContractInvocationRequest 28 | """ # noqa: E501 29 | signed_payload: StrictStr = Field(description="The hex-encoded signed payload of the contract invocation") 30 | __properties: ClassVar[List[str]] = ["signed_payload"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of BroadcastContractInvocationRequest from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of BroadcastContractInvocationRequest from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "signed_payload": obj.get("signed_payload") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /cdp/client/models/broadcast_external_transaction200_response.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class BroadcastExternalTransaction200Response(BaseModel): 26 | """ 27 | External Transaction Broadcast Response 28 | """ # noqa: E501 29 | transaction_hash: StrictStr = Field(description="The transaction hash") 30 | transaction_link: Optional[StrictStr] = Field(default=None, description="The link to view the transaction on a block explorer. This is optional and may not be present for all transactions.") 31 | __properties: ClassVar[List[str]] = ["transaction_hash", "transaction_link"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of BroadcastExternalTransaction200Response from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of BroadcastExternalTransaction200Response from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "transaction_hash": obj.get("transaction_hash"), 85 | "transaction_link": obj.get("transaction_link") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/broadcast_external_transaction_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class BroadcastExternalTransactionRequest(BaseModel): 26 | """ 27 | BroadcastExternalTransactionRequest 28 | """ # noqa: E501 29 | signed_payload: StrictStr = Field(description="The hex-encoded signed payload of the external address transaction.") 30 | __properties: ClassVar[List[str]] = ["signed_payload"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of BroadcastExternalTransactionRequest from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of BroadcastExternalTransactionRequest from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "signed_payload": obj.get("signed_payload") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /cdp/client/models/broadcast_external_transfer_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class BroadcastExternalTransferRequest(BaseModel): 26 | """ 27 | BroadcastExternalTransferRequest 28 | """ # noqa: E501 29 | signed_payload: StrictStr = Field(description="The hex-encoded signed payload of the external transfer") 30 | __properties: ClassVar[List[str]] = ["signed_payload"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of BroadcastExternalTransferRequest from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of BroadcastExternalTransferRequest from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "signed_payload": obj.get("signed_payload") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /cdp/client/models/broadcast_staking_operation_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class BroadcastStakingOperationRequest(BaseModel): 26 | """ 27 | BroadcastStakingOperationRequest 28 | """ # noqa: E501 29 | signed_payload: StrictStr = Field(description="The hex-encoded signed payload of the staking operation.") 30 | transaction_index: StrictInt = Field(description="The index in the transaction array of the staking operation.") 31 | __properties: ClassVar[List[str]] = ["signed_payload", "transaction_index"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of BroadcastStakingOperationRequest from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of BroadcastStakingOperationRequest from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "signed_payload": obj.get("signed_payload"), 85 | "transaction_index": obj.get("transaction_index") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/broadcast_trade_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class BroadcastTradeRequest(BaseModel): 26 | """ 27 | BroadcastTradeRequest 28 | """ # noqa: E501 29 | signed_payload: StrictStr = Field(description="The hex-encoded signed payload of the trade") 30 | approve_transaction_signed_payload: Optional[StrictStr] = Field(default=None, description="The hex-encoded signed payload of the approval transaction") 31 | __properties: ClassVar[List[str]] = ["signed_payload", "approve_transaction_signed_payload"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of BroadcastTradeRequest from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of BroadcastTradeRequest from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "signed_payload": obj.get("signed_payload"), 85 | "approve_transaction_signed_payload": obj.get("approve_transaction_signed_payload") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/broadcast_transfer_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class BroadcastTransferRequest(BaseModel): 26 | """ 27 | BroadcastTransferRequest 28 | """ # noqa: E501 29 | signed_payload: StrictStr = Field(description="The hex-encoded signed payload of the transfer") 30 | __properties: ClassVar[List[str]] = ["signed_payload"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of BroadcastTransferRequest from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of BroadcastTransferRequest from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "signed_payload": obj.get("signed_payload") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /cdp/client/models/broadcast_user_operation_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class BroadcastUserOperationRequest(BaseModel): 26 | """ 27 | BroadcastUserOperationRequest 28 | """ # noqa: E501 29 | signature: StrictStr = Field(description="The hex-encoded signature of the user operation.") 30 | __properties: ClassVar[List[str]] = ["signature"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of BroadcastUserOperationRequest from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of BroadcastUserOperationRequest from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "signature": obj.get("signature") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /cdp/client/models/call.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class Call(BaseModel): 26 | """ 27 | An action that will be bundled into a user operation. 28 | """ # noqa: E501 29 | to: StrictStr = Field(description="The address the call is interacting with.") 30 | data: StrictStr = Field(description="The hex-encoded data to send with the call.") 31 | value: StrictStr = Field(description="The string-encoded integer value to send with the call.") 32 | __properties: ClassVar[List[str]] = ["to", "data", "value"] 33 | 34 | model_config = ConfigDict( 35 | populate_by_name=True, 36 | validate_assignment=True, 37 | protected_namespaces=(), 38 | ) 39 | 40 | 41 | def to_str(self) -> str: 42 | """Returns the string representation of the model using alias""" 43 | return pprint.pformat(self.model_dump(by_alias=True)) 44 | 45 | def to_json(self) -> str: 46 | """Returns the JSON representation of the model using alias""" 47 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 48 | return json.dumps(self.to_dict()) 49 | 50 | @classmethod 51 | def from_json(cls, json_str: str) -> Optional[Self]: 52 | """Create an instance of Call from a JSON string""" 53 | return cls.from_dict(json.loads(json_str)) 54 | 55 | def to_dict(self) -> Dict[str, Any]: 56 | """Return the dictionary representation of the model using alias. 57 | 58 | This has the following differences from calling pydantic's 59 | `self.model_dump(by_alias=True)`: 60 | 61 | * `None` is only added to the output dict for nullable fields that 62 | were set at model initialization. Other fields with value `None` 63 | are ignored. 64 | """ 65 | excluded_fields: Set[str] = set([ 66 | ]) 67 | 68 | _dict = self.model_dump( 69 | by_alias=True, 70 | exclude=excluded_fields, 71 | exclude_none=True, 72 | ) 73 | return _dict 74 | 75 | @classmethod 76 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 77 | """Create an instance of Call from a dict""" 78 | if obj is None: 79 | return None 80 | 81 | if not isinstance(obj, dict): 82 | return cls.model_validate(obj) 83 | 84 | _obj = cls.model_validate({ 85 | "to": obj.get("to"), 86 | "data": obj.get("data"), 87 | "value": obj.get("value") 88 | }) 89 | return _obj 90 | 91 | 92 | -------------------------------------------------------------------------------- /cdp/client/models/create_fund_quote_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class CreateFundQuoteRequest(BaseModel): 26 | """ 27 | CreateFundQuoteRequest 28 | """ # noqa: E501 29 | amount: StrictStr = Field(description="The amount of the asset to fund the address with in atomic units.") 30 | asset_id: StrictStr = Field(description="The ID of the asset to fund the address with. Can be an asset symbol alias or a token contract address.") 31 | __properties: ClassVar[List[str]] = ["amount", "asset_id"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of CreateFundQuoteRequest from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of CreateFundQuoteRequest from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "amount": obj.get("amount"), 85 | "asset_id": obj.get("asset_id") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/create_payload_signature_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class CreatePayloadSignatureRequest(BaseModel): 26 | """ 27 | CreatePayloadSignatureRequest 28 | """ # noqa: E501 29 | unsigned_payload: StrictStr = Field(description="The unsigned payload.") 30 | signature: Optional[StrictStr] = Field(default=None, description="The signature of the payload.") 31 | __properties: ClassVar[List[str]] = ["unsigned_payload", "signature"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of CreatePayloadSignatureRequest from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of CreatePayloadSignatureRequest from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "unsigned_payload": obj.get("unsigned_payload"), 85 | "signature": obj.get("signature") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/create_smart_wallet_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class CreateSmartWalletRequest(BaseModel): 26 | """ 27 | CreateSmartWalletRequest 28 | """ # noqa: E501 29 | owner: StrictStr = Field(description="The address of the owner of the smart wallet.") 30 | __properties: ClassVar[List[str]] = ["owner"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of CreateSmartWalletRequest from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of CreateSmartWalletRequest from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "owner": obj.get("owner") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /cdp/client/models/create_trade_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class CreateTradeRequest(BaseModel): 26 | """ 27 | CreateTradeRequest 28 | """ # noqa: E501 29 | amount: StrictStr = Field(description="The amount to trade") 30 | from_asset_id: StrictStr = Field(description="The ID of the asset to trade") 31 | to_asset_id: StrictStr = Field(description="The ID of the asset to receive from the trade") 32 | __properties: ClassVar[List[str]] = ["amount", "from_asset_id", "to_asset_id"] 33 | 34 | model_config = ConfigDict( 35 | populate_by_name=True, 36 | validate_assignment=True, 37 | protected_namespaces=(), 38 | ) 39 | 40 | 41 | def to_str(self) -> str: 42 | """Returns the string representation of the model using alias""" 43 | return pprint.pformat(self.model_dump(by_alias=True)) 44 | 45 | def to_json(self) -> str: 46 | """Returns the JSON representation of the model using alias""" 47 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 48 | return json.dumps(self.to_dict()) 49 | 50 | @classmethod 51 | def from_json(cls, json_str: str) -> Optional[Self]: 52 | """Create an instance of CreateTradeRequest from a JSON string""" 53 | return cls.from_dict(json.loads(json_str)) 54 | 55 | def to_dict(self) -> Dict[str, Any]: 56 | """Return the dictionary representation of the model using alias. 57 | 58 | This has the following differences from calling pydantic's 59 | `self.model_dump(by_alias=True)`: 60 | 61 | * `None` is only added to the output dict for nullable fields that 62 | were set at model initialization. Other fields with value `None` 63 | are ignored. 64 | """ 65 | excluded_fields: Set[str] = set([ 66 | ]) 67 | 68 | _dict = self.model_dump( 69 | by_alias=True, 70 | exclude=excluded_fields, 71 | exclude_none=True, 72 | ) 73 | return _dict 74 | 75 | @classmethod 76 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 77 | """Create an instance of CreateTradeRequest from a dict""" 78 | if obj is None: 79 | return None 80 | 81 | if not isinstance(obj, dict): 82 | return cls.model_validate(obj) 83 | 84 | _obj = cls.model_validate({ 85 | "amount": obj.get("amount"), 86 | "from_asset_id": obj.get("from_asset_id"), 87 | "to_asset_id": obj.get("to_asset_id") 88 | }) 89 | return _obj 90 | 91 | 92 | -------------------------------------------------------------------------------- /cdp/client/models/create_wallet_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict 21 | from typing import Any, ClassVar, Dict, List 22 | from cdp.client.models.create_wallet_request_wallet import CreateWalletRequestWallet 23 | from typing import Optional, Set 24 | from typing_extensions import Self 25 | 26 | class CreateWalletRequest(BaseModel): 27 | """ 28 | CreateWalletRequest 29 | """ # noqa: E501 30 | wallet: CreateWalletRequestWallet 31 | __properties: ClassVar[List[str]] = ["wallet"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of CreateWalletRequest from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | # override the default output from pydantic by calling `to_dict()` of wallet 73 | if self.wallet: 74 | _dict['wallet'] = self.wallet.to_dict() 75 | return _dict 76 | 77 | @classmethod 78 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 79 | """Create an instance of CreateWalletRequest from a dict""" 80 | if obj is None: 81 | return None 82 | 83 | if not isinstance(obj, dict): 84 | return cls.model_validate(obj) 85 | 86 | _obj = cls.model_validate({ 87 | "wallet": CreateWalletRequestWallet.from_dict(obj["wallet"]) if obj.get("wallet") is not None else None 88 | }) 89 | return _obj 90 | 91 | 92 | -------------------------------------------------------------------------------- /cdp/client/models/create_wallet_request_wallet.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class CreateWalletRequestWallet(BaseModel): 26 | """ 27 | Parameters for configuring a wallet 28 | """ # noqa: E501 29 | network_id: StrictStr = Field(description="The ID of the blockchain network") 30 | use_server_signer: Optional[StrictBool] = Field(default=None, description="Whether the wallet should use the project's server signer or if the addresses in the wallets will belong to a private key the developer manages. Defaults to false.") 31 | __properties: ClassVar[List[str]] = ["network_id", "use_server_signer"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of CreateWalletRequestWallet from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of CreateWalletRequestWallet from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "network_id": obj.get("network_id"), 85 | "use_server_signer": obj.get("use_server_signer") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/create_wallet_webhook_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class CreateWalletWebhookRequest(BaseModel): 26 | """ 27 | CreateWalletWebhookRequest 28 | """ # noqa: E501 29 | notification_uri: StrictStr = Field(description="The URL to which the notifications will be sent.") 30 | signature_header: Optional[StrictStr] = Field(default=None, description="The custom header to be used for x-webhook-signature header on callbacks, so developers can verify the requests are coming from Coinbase.") 31 | __properties: ClassVar[List[str]] = ["notification_uri", "signature_header"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of CreateWalletWebhookRequest from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of CreateWalletWebhookRequest from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "notification_uri": obj.get("notification_uri"), 85 | "signature_header": obj.get("signature_header") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/crypto_amount.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from cdp.client.models.asset import Asset 23 | from typing import Optional, Set 24 | from typing_extensions import Self 25 | 26 | class CryptoAmount(BaseModel): 27 | """ 28 | An amount in cryptocurrency 29 | """ # noqa: E501 30 | amount: StrictStr = Field(description="The amount of the crypto in atomic units") 31 | asset: Asset 32 | __properties: ClassVar[List[str]] = ["amount", "asset"] 33 | 34 | model_config = ConfigDict( 35 | populate_by_name=True, 36 | validate_assignment=True, 37 | protected_namespaces=(), 38 | ) 39 | 40 | 41 | def to_str(self) -> str: 42 | """Returns the string representation of the model using alias""" 43 | return pprint.pformat(self.model_dump(by_alias=True)) 44 | 45 | def to_json(self) -> str: 46 | """Returns the JSON representation of the model using alias""" 47 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 48 | return json.dumps(self.to_dict()) 49 | 50 | @classmethod 51 | def from_json(cls, json_str: str) -> Optional[Self]: 52 | """Create an instance of CryptoAmount from a JSON string""" 53 | return cls.from_dict(json.loads(json_str)) 54 | 55 | def to_dict(self) -> Dict[str, Any]: 56 | """Return the dictionary representation of the model using alias. 57 | 58 | This has the following differences from calling pydantic's 59 | `self.model_dump(by_alias=True)`: 60 | 61 | * `None` is only added to the output dict for nullable fields that 62 | were set at model initialization. Other fields with value `None` 63 | are ignored. 64 | """ 65 | excluded_fields: Set[str] = set([ 66 | ]) 67 | 68 | _dict = self.model_dump( 69 | by_alias=True, 70 | exclude=excluded_fields, 71 | exclude_none=True, 72 | ) 73 | # override the default output from pydantic by calling `to_dict()` of asset 74 | if self.asset: 75 | _dict['asset'] = self.asset.to_dict() 76 | return _dict 77 | 78 | @classmethod 79 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 80 | """Create an instance of CryptoAmount from a dict""" 81 | if obj is None: 82 | return None 83 | 84 | if not isinstance(obj, dict): 85 | return cls.model_validate(obj) 86 | 87 | _obj = cls.model_validate({ 88 | "amount": obj.get("amount"), 89 | "asset": Asset.from_dict(obj["asset"]) if obj.get("asset") is not None else None 90 | }) 91 | return _obj 92 | 93 | 94 | -------------------------------------------------------------------------------- /cdp/client/models/deploy_smart_contract_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class DeploySmartContractRequest(BaseModel): 26 | """ 27 | DeploySmartContractRequest 28 | """ # noqa: E501 29 | signed_payload: StrictStr = Field(description="The hex-encoded signed payload of the contract deployment transaction.") 30 | __properties: ClassVar[List[str]] = ["signed_payload"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of DeploySmartContractRequest from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of DeploySmartContractRequest from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "signed_payload": obj.get("signed_payload") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /cdp/client/models/ethereum_transaction_access.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class EthereumTransactionAccess(BaseModel): 26 | """ 27 | EthereumTransactionAccess 28 | """ # noqa: E501 29 | address: Optional[StrictStr] = None 30 | storage_keys: Optional[List[StrictStr]] = None 31 | __properties: ClassVar[List[str]] = ["address", "storage_keys"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of EthereumTransactionAccess from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of EthereumTransactionAccess from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "address": obj.get("address"), 85 | "storage_keys": obj.get("storage_keys") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/fiat_amount.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class FiatAmount(BaseModel): 26 | """ 27 | An amount in fiat currency 28 | """ # noqa: E501 29 | amount: StrictStr = Field(description="The amount of the fiat in whole units.") 30 | currency: StrictStr = Field(description="The currency of the fiat") 31 | __properties: ClassVar[List[str]] = ["amount", "currency"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of FiatAmount from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of FiatAmount from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "amount": obj.get("amount"), 85 | "currency": obj.get("currency") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/multi_token_contract_options.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class MultiTokenContractOptions(BaseModel): 26 | """ 27 | Options for multi-token contract creation 28 | """ # noqa: E501 29 | uri: StrictStr = Field(description="The URI for all token metadata") 30 | __properties: ClassVar[List[str]] = ["uri"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of MultiTokenContractOptions from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of MultiTokenContractOptions from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "uri": obj.get("uri") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /cdp/client/models/network_identifier.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class NetworkIdentifier(str, Enum): 22 | """ 23 | The ID of the blockchain network. This is unique across all networks, and takes the form of `-`. 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | BASE_MINUS_SEPOLIA = 'base-sepolia' 30 | BASE_MINUS_MAINNET = 'base-mainnet' 31 | ETHEREUM_MINUS_HOLESKY = 'ethereum-holesky' 32 | ETHEREUM_MINUS_SEPOLIA = 'ethereum-sepolia' 33 | ETHEREUM_MINUS_MAINNET = 'ethereum-mainnet' 34 | POLYGON_MINUS_MAINNET = 'polygon-mainnet' 35 | SOLANA_MINUS_DEVNET = 'solana-devnet' 36 | SOLANA_MINUS_MAINNET = 'solana-mainnet' 37 | ARBITRUM_MINUS_MAINNET = 'arbitrum-mainnet' 38 | ARBITRUM_MINUS_SEPOLIA = 'arbitrum-sepolia' 39 | BITCOIN_MINUS_MAINNET = 'bitcoin-mainnet' 40 | NEAR_MINUS_TESTNET = 'near-testnet' 41 | NEAR_MINUS_MAINNET = 'near-mainnet' 42 | 43 | @classmethod 44 | def from_json(cls, json_str: str) -> Self: 45 | """Create an instance of NetworkIdentifier from a JSON string""" 46 | return cls(json.loads(json_str)) 47 | 48 | 49 | -------------------------------------------------------------------------------- /cdp/client/models/nft_contract_options.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class NFTContractOptions(BaseModel): 26 | """ 27 | Options for NFT contract creation 28 | """ # noqa: E501 29 | name: StrictStr = Field(description="The name of the NFT") 30 | symbol: StrictStr = Field(description="The symbol of the NFT") 31 | base_uri: StrictStr = Field(description="The base URI for the NFT metadata") 32 | __properties: ClassVar[List[str]] = ["name", "symbol", "base_uri"] 33 | 34 | model_config = ConfigDict( 35 | populate_by_name=True, 36 | validate_assignment=True, 37 | protected_namespaces=(), 38 | ) 39 | 40 | 41 | def to_str(self) -> str: 42 | """Returns the string representation of the model using alias""" 43 | return pprint.pformat(self.model_dump(by_alias=True)) 44 | 45 | def to_json(self) -> str: 46 | """Returns the JSON representation of the model using alias""" 47 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 48 | return json.dumps(self.to_dict()) 49 | 50 | @classmethod 51 | def from_json(cls, json_str: str) -> Optional[Self]: 52 | """Create an instance of NFTContractOptions from a JSON string""" 53 | return cls.from_dict(json.loads(json_str)) 54 | 55 | def to_dict(self) -> Dict[str, Any]: 56 | """Return the dictionary representation of the model using alias. 57 | 58 | This has the following differences from calling pydantic's 59 | `self.model_dump(by_alias=True)`: 60 | 61 | * `None` is only added to the output dict for nullable fields that 62 | were set at model initialization. Other fields with value `None` 63 | are ignored. 64 | """ 65 | excluded_fields: Set[str] = set([ 66 | ]) 67 | 68 | _dict = self.model_dump( 69 | by_alias=True, 70 | exclude=excluded_fields, 71 | exclude_none=True, 72 | ) 73 | return _dict 74 | 75 | @classmethod 76 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 77 | """Create an instance of NFTContractOptions from a dict""" 78 | if obj is None: 79 | return None 80 | 81 | if not isinstance(obj, dict): 82 | return cls.model_validate(obj) 83 | 84 | _obj = cls.model_validate({ 85 | "name": obj.get("name"), 86 | "symbol": obj.get("symbol"), 87 | "base_uri": obj.get("base_uri") 88 | }) 89 | return _obj 90 | 91 | 92 | -------------------------------------------------------------------------------- /cdp/client/models/onchain_name_text_records_inner.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class OnchainNameTextRecordsInner(BaseModel): 26 | """ 27 | OnchainNameTextRecordsInner 28 | """ # noqa: E501 29 | key: Optional[StrictStr] = Field(default=None, description="The key for the text record") 30 | value: Optional[StrictStr] = Field(default=None, description="The value for the text record") 31 | __properties: ClassVar[List[str]] = ["key", "value"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of OnchainNameTextRecordsInner from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of OnchainNameTextRecordsInner from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "key": obj.get("key"), 85 | "value": obj.get("value") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/read_contract_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class ReadContractRequest(BaseModel): 26 | """ 27 | ReadContractRequest 28 | """ # noqa: E501 29 | method: StrictStr = Field(description="The name of the contract method to call") 30 | args: StrictStr = Field(description="The JSON-encoded arguments to pass to the contract method. The keys should be the argument names and the values should be the argument values.") 31 | abi: Optional[StrictStr] = Field(default=None, description="The JSON-encoded ABI of the contract method (optional, will use cached ABI if not provided)") 32 | __properties: ClassVar[List[str]] = ["method", "args", "abi"] 33 | 34 | model_config = ConfigDict( 35 | populate_by_name=True, 36 | validate_assignment=True, 37 | protected_namespaces=(), 38 | ) 39 | 40 | 41 | def to_str(self) -> str: 42 | """Returns the string representation of the model using alias""" 43 | return pprint.pformat(self.model_dump(by_alias=True)) 44 | 45 | def to_json(self) -> str: 46 | """Returns the JSON representation of the model using alias""" 47 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 48 | return json.dumps(self.to_dict()) 49 | 50 | @classmethod 51 | def from_json(cls, json_str: str) -> Optional[Self]: 52 | """Create an instance of ReadContractRequest from a JSON string""" 53 | return cls.from_dict(json.loads(json_str)) 54 | 55 | def to_dict(self) -> Dict[str, Any]: 56 | """Return the dictionary representation of the model using alias. 57 | 58 | This has the following differences from calling pydantic's 59 | `self.model_dump(by_alias=True)`: 60 | 61 | * `None` is only added to the output dict for nullable fields that 62 | were set at model initialization. Other fields with value `None` 63 | are ignored. 64 | """ 65 | excluded_fields: Set[str] = set([ 66 | ]) 67 | 68 | _dict = self.model_dump( 69 | by_alias=True, 70 | exclude=excluded_fields, 71 | exclude_none=True, 72 | ) 73 | return _dict 74 | 75 | @classmethod 76 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 77 | """Create an instance of ReadContractRequest from a dict""" 78 | if obj is None: 79 | return None 80 | 81 | if not isinstance(obj, dict): 82 | return cls.model_validate(obj) 83 | 84 | _obj = cls.model_validate({ 85 | "method": obj.get("method"), 86 | "args": obj.get("args"), 87 | "abi": obj.get("abi") 88 | }) 89 | return _obj 90 | 91 | 92 | -------------------------------------------------------------------------------- /cdp/client/models/read_smart_contract_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class ReadSmartContractRequest(BaseModel): 26 | """ 27 | ReadSmartContractRequest 28 | """ # noqa: E501 29 | method: StrictStr = Field(description="The name of the contract method to call") 30 | args: List[StrictStr] = Field(description="The arguments to pass to the contract method") 31 | abi: Optional[StrictStr] = Field(default=None, description="The JSON-encoded ABI of the contract method (optional, will use cached ABI if not provided)") 32 | __properties: ClassVar[List[str]] = ["method", "args", "abi"] 33 | 34 | model_config = ConfigDict( 35 | populate_by_name=True, 36 | validate_assignment=True, 37 | protected_namespaces=(), 38 | ) 39 | 40 | 41 | def to_str(self) -> str: 42 | """Returns the string representation of the model using alias""" 43 | return pprint.pformat(self.model_dump(by_alias=True)) 44 | 45 | def to_json(self) -> str: 46 | """Returns the JSON representation of the model using alias""" 47 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 48 | return json.dumps(self.to_dict()) 49 | 50 | @classmethod 51 | def from_json(cls, json_str: str) -> Optional[Self]: 52 | """Create an instance of ReadSmartContractRequest from a JSON string""" 53 | return cls.from_dict(json.loads(json_str)) 54 | 55 | def to_dict(self) -> Dict[str, Any]: 56 | """Return the dictionary representation of the model using alias. 57 | 58 | This has the following differences from calling pydantic's 59 | `self.model_dump(by_alias=True)`: 60 | 61 | * `None` is only added to the output dict for nullable fields that 62 | were set at model initialization. Other fields with value `None` 63 | are ignored. 64 | """ 65 | excluded_fields: Set[str] = set([ 66 | ]) 67 | 68 | _dict = self.model_dump( 69 | by_alias=True, 70 | exclude=excluded_fields, 71 | exclude_none=True, 72 | ) 73 | return _dict 74 | 75 | @classmethod 76 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 77 | """Create an instance of ReadSmartContractRequest from a dict""" 78 | if obj is None: 79 | return None 80 | 81 | if not isinstance(obj, dict): 82 | return cls.model_validate(obj) 83 | 84 | _obj = cls.model_validate({ 85 | "method": obj.get("method"), 86 | "args": obj.get("args"), 87 | "abi": obj.get("abi") 88 | }) 89 | return _obj 90 | 91 | 92 | -------------------------------------------------------------------------------- /cdp/client/models/register_smart_contract_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing_extensions import Annotated 23 | from typing import Optional, Set 24 | from typing_extensions import Self 25 | 26 | class RegisterSmartContractRequest(BaseModel): 27 | """ 28 | Smart Contract data to be registered 29 | """ # noqa: E501 30 | abi: StrictStr = Field(description="ABI of the smart contract") 31 | contract_name: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="Name of the smart contract") 32 | __properties: ClassVar[List[str]] = ["abi", "contract_name"] 33 | 34 | model_config = ConfigDict( 35 | populate_by_name=True, 36 | validate_assignment=True, 37 | protected_namespaces=(), 38 | ) 39 | 40 | 41 | def to_str(self) -> str: 42 | """Returns the string representation of the model using alias""" 43 | return pprint.pformat(self.model_dump(by_alias=True)) 44 | 45 | def to_json(self) -> str: 46 | """Returns the JSON representation of the model using alias""" 47 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 48 | return json.dumps(self.to_dict()) 49 | 50 | @classmethod 51 | def from_json(cls, json_str: str) -> Optional[Self]: 52 | """Create an instance of RegisterSmartContractRequest from a JSON string""" 53 | return cls.from_dict(json.loads(json_str)) 54 | 55 | def to_dict(self) -> Dict[str, Any]: 56 | """Return the dictionary representation of the model using alias. 57 | 58 | This has the following differences from calling pydantic's 59 | `self.model_dump(by_alias=True)`: 60 | 61 | * `None` is only added to the output dict for nullable fields that 62 | were set at model initialization. Other fields with value `None` 63 | are ignored. 64 | """ 65 | excluded_fields: Set[str] = set([ 66 | ]) 67 | 68 | _dict = self.model_dump( 69 | by_alias=True, 70 | exclude=excluded_fields, 71 | exclude_none=True, 72 | ) 73 | return _dict 74 | 75 | @classmethod 76 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 77 | """Create an instance of RegisterSmartContractRequest from a dict""" 78 | if obj is None: 79 | return None 80 | 81 | if not isinstance(obj, dict): 82 | return cls.model_validate(obj) 83 | 84 | _obj = cls.model_validate({ 85 | "abi": obj.get("abi"), 86 | "contract_name": obj.get("contract_name") 87 | }) 88 | return _obj 89 | 90 | 91 | -------------------------------------------------------------------------------- /cdp/client/models/seed_creation_event.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class SeedCreationEvent(BaseModel): 26 | """ 27 | An event representing a seed creation. 28 | """ # noqa: E501 29 | wallet_id: StrictStr = Field(description="The ID of the wallet that the server-signer should create the seed for") 30 | wallet_user_id: StrictStr = Field(description="The ID of the user that the wallet belongs to") 31 | __properties: ClassVar[List[str]] = ["wallet_id", "wallet_user_id"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of SeedCreationEvent from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of SeedCreationEvent from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "wallet_id": obj.get("wallet_id"), 85 | "wallet_user_id": obj.get("wallet_user_id") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/server_signer.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class ServerSigner(BaseModel): 26 | """ 27 | A Server-Signer assigned to sign transactions in a wallet. 28 | """ # noqa: E501 29 | server_signer_id: StrictStr = Field(description="The ID of the server-signer") 30 | wallets: Optional[List[StrictStr]] = Field(default=None, description="The IDs of the wallets that the server-signer can sign for") 31 | is_mpc: StrictBool = Field(description="Whether the Server-Signer uses MPC.") 32 | __properties: ClassVar[List[str]] = ["server_signer_id", "wallets", "is_mpc"] 33 | 34 | model_config = ConfigDict( 35 | populate_by_name=True, 36 | validate_assignment=True, 37 | protected_namespaces=(), 38 | ) 39 | 40 | 41 | def to_str(self) -> str: 42 | """Returns the string representation of the model using alias""" 43 | return pprint.pformat(self.model_dump(by_alias=True)) 44 | 45 | def to_json(self) -> str: 46 | """Returns the JSON representation of the model using alias""" 47 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 48 | return json.dumps(self.to_dict()) 49 | 50 | @classmethod 51 | def from_json(cls, json_str: str) -> Optional[Self]: 52 | """Create an instance of ServerSigner from a JSON string""" 53 | return cls.from_dict(json.loads(json_str)) 54 | 55 | def to_dict(self) -> Dict[str, Any]: 56 | """Return the dictionary representation of the model using alias. 57 | 58 | This has the following differences from calling pydantic's 59 | `self.model_dump(by_alias=True)`: 60 | 61 | * `None` is only added to the output dict for nullable fields that 62 | were set at model initialization. Other fields with value `None` 63 | are ignored. 64 | """ 65 | excluded_fields: Set[str] = set([ 66 | ]) 67 | 68 | _dict = self.model_dump( 69 | by_alias=True, 70 | exclude=excluded_fields, 71 | exclude_none=True, 72 | ) 73 | return _dict 74 | 75 | @classmethod 76 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 77 | """Create an instance of ServerSigner from a dict""" 78 | if obj is None: 79 | return None 80 | 81 | if not isinstance(obj, dict): 82 | return cls.model_validate(obj) 83 | 84 | _obj = cls.model_validate({ 85 | "server_signer_id": obj.get("server_signer_id"), 86 | "wallets": obj.get("wallets"), 87 | "is_mpc": obj.get("is_mpc") 88 | }) 89 | return _obj 90 | 91 | 92 | -------------------------------------------------------------------------------- /cdp/client/models/smart_contract_type.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class SmartContractType(str, Enum): 22 | """ 23 | The type of the smart contract. 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | ERC20 = 'erc20' 30 | ERC721 = 'erc721' 31 | ERC1155 = 'erc1155' 32 | CUSTOM = 'custom' 33 | 34 | @classmethod 35 | def from_json(cls, json_str: str) -> Self: 36 | """Create an instance of SmartContractType from a JSON string""" 37 | return cls(json.loads(json_str)) 38 | 39 | 40 | -------------------------------------------------------------------------------- /cdp/client/models/smart_wallet.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class SmartWallet(BaseModel): 26 | """ 27 | SmartWallet 28 | """ # noqa: E501 29 | address: StrictStr = Field(description="The onchain address of the smart wallet.") 30 | owners: List[StrictStr] = Field(description="The list of owner addresses for the smart wallet.") 31 | __properties: ClassVar[List[str]] = ["address", "owners"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of SmartWallet from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of SmartWallet from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "address": obj.get("address"), 85 | "owners": obj.get("owners") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/staking_context.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict 21 | from typing import Any, ClassVar, Dict, List 22 | from cdp.client.models.staking_context_context import StakingContextContext 23 | from typing import Optional, Set 24 | from typing_extensions import Self 25 | 26 | class StakingContext(BaseModel): 27 | """ 28 | Context needed to perform a staking operation 29 | """ # noqa: E501 30 | context: StakingContextContext 31 | __properties: ClassVar[List[str]] = ["context"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of StakingContext from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | # override the default output from pydantic by calling `to_dict()` of context 73 | if self.context: 74 | _dict['context'] = self.context.to_dict() 75 | return _dict 76 | 77 | @classmethod 78 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 79 | """Create an instance of StakingContext from a dict""" 80 | if obj is None: 81 | return None 82 | 83 | if not isinstance(obj, dict): 84 | return cls.model_validate(obj) 85 | 86 | _obj = cls.model_validate({ 87 | "context": StakingContextContext.from_dict(obj["context"]) if obj.get("context") is not None else None 88 | }) 89 | return _obj 90 | 91 | 92 | -------------------------------------------------------------------------------- /cdp/client/models/staking_reward_format.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class StakingRewardFormat(str, Enum): 22 | """ 23 | The format in which the rewards are to be fetched i.e native or in equivalent USD 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | USD = 'usd' 30 | NATIVE = 'native' 31 | 32 | @classmethod 33 | def from_json(cls, json_str: str) -> Self: 34 | """Create an instance of StakingRewardFormat from a JSON string""" 35 | return cls(json.loads(json_str)) 36 | 37 | 38 | -------------------------------------------------------------------------------- /cdp/client/models/staking_reward_usd_value.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from datetime import datetime 21 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 22 | from typing import Any, ClassVar, Dict, List 23 | from typing import Optional, Set 24 | from typing_extensions import Self 25 | 26 | class StakingRewardUSDValue(BaseModel): 27 | """ 28 | The USD value of the reward 29 | """ # noqa: E501 30 | amount: StrictStr = Field(description="The value of the reward in USD") 31 | conversion_price: StrictStr = Field(description="The conversion price from native currency to USD") 32 | conversion_time: datetime = Field(description="The time of the conversion in UTC.") 33 | __properties: ClassVar[List[str]] = ["amount", "conversion_price", "conversion_time"] 34 | 35 | model_config = ConfigDict( 36 | populate_by_name=True, 37 | validate_assignment=True, 38 | protected_namespaces=(), 39 | ) 40 | 41 | 42 | def to_str(self) -> str: 43 | """Returns the string representation of the model using alias""" 44 | return pprint.pformat(self.model_dump(by_alias=True)) 45 | 46 | def to_json(self) -> str: 47 | """Returns the JSON representation of the model using alias""" 48 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 49 | return json.dumps(self.to_dict()) 50 | 51 | @classmethod 52 | def from_json(cls, json_str: str) -> Optional[Self]: 53 | """Create an instance of StakingRewardUSDValue from a JSON string""" 54 | return cls.from_dict(json.loads(json_str)) 55 | 56 | def to_dict(self) -> Dict[str, Any]: 57 | """Return the dictionary representation of the model using alias. 58 | 59 | This has the following differences from calling pydantic's 60 | `self.model_dump(by_alias=True)`: 61 | 62 | * `None` is only added to the output dict for nullable fields that 63 | were set at model initialization. Other fields with value `None` 64 | are ignored. 65 | """ 66 | excluded_fields: Set[str] = set([ 67 | ]) 68 | 69 | _dict = self.model_dump( 70 | by_alias=True, 71 | exclude=excluded_fields, 72 | exclude_none=True, 73 | ) 74 | return _dict 75 | 76 | @classmethod 77 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 78 | """Create an instance of StakingRewardUSDValue from a dict""" 79 | if obj is None: 80 | return None 81 | 82 | if not isinstance(obj, dict): 83 | return cls.model_validate(obj) 84 | 85 | _obj = cls.model_validate({ 86 | "amount": obj.get("amount"), 87 | "conversion_price": obj.get("conversion_price"), 88 | "conversion_time": obj.get("conversion_time") 89 | }) 90 | return _obj 91 | 92 | 93 | -------------------------------------------------------------------------------- /cdp/client/models/token_contract_options.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class TokenContractOptions(BaseModel): 26 | """ 27 | Options for token contract creation 28 | """ # noqa: E501 29 | name: StrictStr = Field(description="The name of the token") 30 | symbol: StrictStr = Field(description="The symbol of the token") 31 | total_supply: StrictStr = Field(description="The total supply of the token denominated in the whole amount of the token.") 32 | __properties: ClassVar[List[str]] = ["name", "symbol", "total_supply"] 33 | 34 | model_config = ConfigDict( 35 | populate_by_name=True, 36 | validate_assignment=True, 37 | protected_namespaces=(), 38 | ) 39 | 40 | 41 | def to_str(self) -> str: 42 | """Returns the string representation of the model using alias""" 43 | return pprint.pformat(self.model_dump(by_alias=True)) 44 | 45 | def to_json(self) -> str: 46 | """Returns the JSON representation of the model using alias""" 47 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 48 | return json.dumps(self.to_dict()) 49 | 50 | @classmethod 51 | def from_json(cls, json_str: str) -> Optional[Self]: 52 | """Create an instance of TokenContractOptions from a JSON string""" 53 | return cls.from_dict(json.loads(json_str)) 54 | 55 | def to_dict(self) -> Dict[str, Any]: 56 | """Return the dictionary representation of the model using alias. 57 | 58 | This has the following differences from calling pydantic's 59 | `self.model_dump(by_alias=True)`: 60 | 61 | * `None` is only added to the output dict for nullable fields that 62 | were set at model initialization. Other fields with value `None` 63 | are ignored. 64 | """ 65 | excluded_fields: Set[str] = set([ 66 | ]) 67 | 68 | _dict = self.model_dump( 69 | by_alias=True, 70 | exclude=excluded_fields, 71 | exclude_none=True, 72 | ) 73 | return _dict 74 | 75 | @classmethod 76 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 77 | """Create an instance of TokenContractOptions from a dict""" 78 | if obj is None: 79 | return None 80 | 81 | if not isinstance(obj, dict): 82 | return cls.model_validate(obj) 83 | 84 | _obj = cls.model_validate({ 85 | "name": obj.get("name"), 86 | "symbol": obj.get("symbol"), 87 | "total_supply": obj.get("total_supply") 88 | }) 89 | return _obj 90 | 91 | 92 | -------------------------------------------------------------------------------- /cdp/client/models/token_transfer_type.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class TokenTransferType(str, Enum): 22 | """ 23 | The type of the token transfer. 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | ERC20 = 'erc20' 30 | ERC721 = 'erc721' 31 | ERC1155 = 'erc1155' 32 | UNKNOWN = 'unknown' 33 | 34 | @classmethod 35 | def from_json(cls, json_str: str) -> Self: 36 | """Create an instance of TokenTransferType from a JSON string""" 37 | return cls(json.loads(json_str)) 38 | 39 | 40 | -------------------------------------------------------------------------------- /cdp/client/models/transaction_log.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class TransactionLog(BaseModel): 26 | """ 27 | A log emitted from an onchain transaction. 28 | """ # noqa: E501 29 | address: StrictStr = Field(description="An onchain address of a contract.") 30 | topics: List[StrictStr] 31 | data: StrictStr = Field(description="The data included in this log.") 32 | __properties: ClassVar[List[str]] = ["address", "topics", "data"] 33 | 34 | model_config = ConfigDict( 35 | populate_by_name=True, 36 | validate_assignment=True, 37 | protected_namespaces=(), 38 | ) 39 | 40 | 41 | def to_str(self) -> str: 42 | """Returns the string representation of the model using alias""" 43 | return pprint.pformat(self.model_dump(by_alias=True)) 44 | 45 | def to_json(self) -> str: 46 | """Returns the JSON representation of the model using alias""" 47 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 48 | return json.dumps(self.to_dict()) 49 | 50 | @classmethod 51 | def from_json(cls, json_str: str) -> Optional[Self]: 52 | """Create an instance of TransactionLog from a JSON string""" 53 | return cls.from_dict(json.loads(json_str)) 54 | 55 | def to_dict(self) -> Dict[str, Any]: 56 | """Return the dictionary representation of the model using alias. 57 | 58 | This has the following differences from calling pydantic's 59 | `self.model_dump(by_alias=True)`: 60 | 61 | * `None` is only added to the output dict for nullable fields that 62 | were set at model initialization. Other fields with value `None` 63 | are ignored. 64 | """ 65 | excluded_fields: Set[str] = set([ 66 | ]) 67 | 68 | _dict = self.model_dump( 69 | by_alias=True, 70 | exclude=excluded_fields, 71 | exclude_none=True, 72 | ) 73 | return _dict 74 | 75 | @classmethod 76 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 77 | """Create an instance of TransactionLog from a dict""" 78 | if obj is None: 79 | return None 80 | 81 | if not isinstance(obj, dict): 82 | return cls.model_validate(obj) 83 | 84 | _obj = cls.model_validate({ 85 | "address": obj.get("address"), 86 | "topics": obj.get("topics"), 87 | "data": obj.get("data") 88 | }) 89 | return _obj 90 | 91 | 92 | -------------------------------------------------------------------------------- /cdp/client/models/transaction_type.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class TransactionType(str, Enum): 22 | """ 23 | TransactionType 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | TRANSFER = 'transfer' 30 | 31 | @classmethod 32 | def from_json(cls, json_str: str) -> Self: 33 | """Create an instance of TransactionType from a JSON string""" 34 | return cls(json.loads(json_str)) 35 | 36 | 37 | -------------------------------------------------------------------------------- /cdp/client/models/update_smart_contract_request.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing_extensions import Annotated 23 | from typing import Optional, Set 24 | from typing_extensions import Self 25 | 26 | class UpdateSmartContractRequest(BaseModel): 27 | """ 28 | Smart Contract data to be updated 29 | """ # noqa: E501 30 | abi: Optional[StrictStr] = Field(default=None, description="ABI of the smart contract") 31 | contract_name: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="Name of the smart contract") 32 | __properties: ClassVar[List[str]] = ["abi", "contract_name"] 33 | 34 | model_config = ConfigDict( 35 | populate_by_name=True, 36 | validate_assignment=True, 37 | protected_namespaces=(), 38 | ) 39 | 40 | 41 | def to_str(self) -> str: 42 | """Returns the string representation of the model using alias""" 43 | return pprint.pformat(self.model_dump(by_alias=True)) 44 | 45 | def to_json(self) -> str: 46 | """Returns the JSON representation of the model using alias""" 47 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 48 | return json.dumps(self.to_dict()) 49 | 50 | @classmethod 51 | def from_json(cls, json_str: str) -> Optional[Self]: 52 | """Create an instance of UpdateSmartContractRequest from a JSON string""" 53 | return cls.from_dict(json.loads(json_str)) 54 | 55 | def to_dict(self) -> Dict[str, Any]: 56 | """Return the dictionary representation of the model using alias. 57 | 58 | This has the following differences from calling pydantic's 59 | `self.model_dump(by_alias=True)`: 60 | 61 | * `None` is only added to the output dict for nullable fields that 62 | were set at model initialization. Other fields with value `None` 63 | are ignored. 64 | """ 65 | excluded_fields: Set[str] = set([ 66 | ]) 67 | 68 | _dict = self.model_dump( 69 | by_alias=True, 70 | exclude=excluded_fields, 71 | exclude_none=True, 72 | ) 73 | return _dict 74 | 75 | @classmethod 76 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 77 | """Create an instance of UpdateSmartContractRequest from a dict""" 78 | if obj is None: 79 | return None 80 | 81 | if not isinstance(obj, dict): 82 | return cls.model_validate(obj) 83 | 84 | _obj = cls.model_validate({ 85 | "abi": obj.get("abi"), 86 | "contract_name": obj.get("contract_name") 87 | }) 88 | return _obj 89 | 90 | 91 | -------------------------------------------------------------------------------- /cdp/client/models/user.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List, Optional 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class User(BaseModel): 26 | """ 27 | User 28 | """ # noqa: E501 29 | id: StrictStr = Field(description="The ID of the user") 30 | display_name: Optional[StrictStr] = None 31 | __properties: ClassVar[List[str]] = ["id", "display_name"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of User from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of User from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "id": obj.get("id"), 85 | "display_name": obj.get("display_name") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /cdp/client/models/validator_status.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class ValidatorStatus(str, Enum): 22 | """ 23 | The status of the validator. 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | UNKNOWN = 'unknown' 30 | PROVISIONING = 'provisioning' 31 | PROVISIONED = 'provisioned' 32 | DEPOSITED = 'deposited' 33 | PENDING_ACTIVATION = 'pending_activation' 34 | ACTIVE = 'active' 35 | EXITING = 'exiting' 36 | EXITED = 'exited' 37 | WITHDRAWAL_AVAILABLE = 'withdrawal_available' 38 | WITHDRAWAL_COMPLETE = 'withdrawal_complete' 39 | ACTIVE_SLASHED = 'active_slashed' 40 | EXITED_SLASHED = 'exited_slashed' 41 | REAPED = 'reaped' 42 | 43 | @classmethod 44 | def from_json(cls, json_str: str) -> Self: 45 | """Create an instance of ValidatorStatus from a JSON string""" 46 | return cls(json.loads(json_str)) 47 | 48 | 49 | -------------------------------------------------------------------------------- /cdp/client/models/webhook_event_type.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class WebhookEventType(str, Enum): 22 | """ 23 | WebhookEventType 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | UNSPECIFIED = 'unspecified' 30 | ERC20_TRANSFER = 'erc20_transfer' 31 | ERC721_TRANSFER = 'erc721_transfer' 32 | WALLET_ACTIVITY = 'wallet_activity' 33 | SMART_CONTRACT_EVENT_ACTIVITY = 'smart_contract_event_activity' 34 | 35 | @classmethod 36 | def from_json(cls, json_str: str) -> Self: 37 | """Create an instance of WebhookEventType from a JSON string""" 38 | return cls(json.loads(json_str)) 39 | 40 | 41 | -------------------------------------------------------------------------------- /cdp/client/models/webhook_smart_contract_event_filter.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import pprint 17 | import re # noqa: F401 18 | import json 19 | 20 | from pydantic import BaseModel, ConfigDict, Field, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class WebhookSmartContractEventFilter(BaseModel): 26 | """ 27 | Filter for smart contract events. This filter allows the client to specify smart contract addresses to monitor for activities such as contract function calls. 28 | """ # noqa: E501 29 | contract_addresses: List[StrictStr] = Field(description="A list of smart contract addresses to filter on.") 30 | __properties: ClassVar[List[str]] = ["contract_addresses"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of WebhookSmartContractEventFilter from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of WebhookSmartContractEventFilter from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "contract_addresses": obj.get("contract_addresses") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /cdp/client/models/webhook_status.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Coinbase Platform API 5 | 6 | This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs. 7 | 8 | The version of the OpenAPI document: 0.0.1-alpha 9 | Generated by OpenAPI Generator (https://openapi-generator.tech) 10 | 11 | Do not edit the class manually. 12 | """ # noqa: E501 13 | 14 | 15 | from __future__ import annotations 16 | import json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class WebhookStatus(str, Enum): 22 | """ 23 | The status of the webhook. 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | ACTIVE = 'active' 30 | INACTIVE = 'inactive' 31 | 32 | @classmethod 33 | def from_json(cls, json_str: str) -> Self: 34 | """Create an instance of WebhookStatus from a JSON string""" 35 | return cls(json.loads(json_str)) 36 | 37 | 38 | -------------------------------------------------------------------------------- /cdp/client/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coinbase/cdp-sdk-python/34bd2c2552e19bd3a90c9c9d74a214e7b7c6f981/cdp/client/py.typed -------------------------------------------------------------------------------- /cdp/constants.py: -------------------------------------------------------------------------------- 1 | """Specifies package level constants used throughout the package.""" 2 | 3 | # SDK_DEFAULT_SOURCE (str): Denotes the default source for the Python SDK. 4 | SDK_DEFAULT_SOURCE = "sdk" 5 | -------------------------------------------------------------------------------- /cdp/evm_call_types.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | from eth_typing import HexAddress 4 | from pydantic import BaseModel, Field 5 | from web3.types import HexStr, Wei 6 | 7 | 8 | class EncodedCall(BaseModel): 9 | """Represents an encoded call to a smart contract.""" 10 | 11 | to: HexAddress = Field(..., description="Target contract address") 12 | value: Wei | None = Field(None, description="Amount of native currency to send") 13 | data: HexStr | None = Field(None, description="Encoded call data") 14 | 15 | 16 | class FunctionCall(BaseModel): 17 | """Represents a call to a smart contract that needs to be encoded using the ABI.""" 18 | 19 | to: HexAddress = Field(..., description="Target contract address") 20 | value: Wei | None = Field(None, description="Amount of native currency to send") 21 | abi: list[dict[str, Any]] = Field(..., description="Contract ABI specification") 22 | function_name: str = Field(..., description="Name of the function to call") 23 | args: list[Any] = Field(..., description="Arguments to pass to the function") 24 | 25 | 26 | ContractCall = EncodedCall | FunctionCall 27 | -------------------------------------------------------------------------------- /cdp/external_address.py: -------------------------------------------------------------------------------- 1 | from cdp.address import Address 2 | 3 | 4 | class ExternalAddress(Address): 5 | """A class representing an external address.""" 6 | -------------------------------------------------------------------------------- /cdp/fiat_amount.py: -------------------------------------------------------------------------------- 1 | from decimal import Decimal 2 | 3 | from cdp.client.models.fiat_amount import FiatAmount as FiatAmountModel 4 | 5 | 6 | class FiatAmount: 7 | """A representation of a FiatAmount that includes the amount and currency.""" 8 | 9 | def __init__(self, amount: Decimal, currency: str) -> None: 10 | """Initialize a new FiatAmount. Do not use this directly, use the from_model method instead. 11 | 12 | Args: 13 | amount (Decimal): The amount in the fiat currency 14 | currency (str): The currency code (e.g. 'USD') 15 | 16 | """ 17 | self._amount = amount 18 | self._currency = currency 19 | 20 | @classmethod 21 | def from_model(cls, fiat_amount_model: FiatAmountModel) -> "FiatAmount": 22 | """Convert a FiatAmount model to a FiatAmount. 23 | 24 | Args: 25 | fiat_amount_model (FiatAmountModel): The fiat amount from the API. 26 | 27 | Returns: 28 | FiatAmount: The converted FiatAmount object. 29 | 30 | """ 31 | return cls(amount=Decimal(fiat_amount_model.amount), currency=fiat_amount_model.currency) 32 | 33 | @property 34 | def amount(self) -> Decimal: 35 | """Get the amount in the fiat currency. 36 | 37 | Returns: 38 | Decimal: The amount in the fiat currency. 39 | 40 | """ 41 | return self._amount 42 | 43 | @property 44 | def currency(self) -> str: 45 | """Get the currency code. 46 | 47 | Returns: 48 | str: The currency code. 49 | 50 | """ 51 | return self._currency 52 | 53 | def __str__(self) -> str: 54 | """Get a string representation of the FiatAmount. 55 | 56 | Returns: 57 | str: A string representation of the FiatAmount. 58 | 59 | """ 60 | return f"FiatAmount(amount: '{int(self.amount)}', currency: '{self.currency}')" 61 | 62 | def __repr__(self) -> str: 63 | """Get a string representation of the FiatAmount. 64 | 65 | Returns: 66 | str: A string representation of the FiatAmount. 67 | 68 | """ 69 | return self.__str__() 70 | -------------------------------------------------------------------------------- /cdp/hash_utils.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | from eth_account.messages import _hash_eip191_message, encode_defunct, encode_typed_data 4 | from eth_utils import to_hex 5 | 6 | 7 | def hash_message(message_text: str) -> str: 8 | """Hashes a message according to EIP-191 and returns the hash as a 0x-prefixed hexadecimal string. 9 | 10 | This function prefixes the message with the standard Ethereum message prefix and hashes it using Keccak-256. 11 | 12 | Args: 13 | message_text (str): The message to hash. 14 | 15 | Returns: 16 | str: The 0x-prefixed hexadecimal string of the message hash. 17 | 18 | """ 19 | message = encode_defunct(text=message_text) 20 | message_hash = _hash_eip191_message(message) 21 | 22 | return to_hex(message_hash) 23 | 24 | 25 | def hash_typed_data_message(typed_data: dict[str, Any]) -> str: 26 | """Hashes typed data according to EIP-712 and returns the hash as a 0x-prefixed hexadecimal string. 27 | 28 | This function encodes the typed data as per EIP-712 and hashes it using Keccak-256. 29 | 30 | Args: 31 | typed_data (dict): The typed data to hash, following the EIP-712 specification. 32 | 33 | Returns: 34 | str: The 0x-prefixed hexadecimal string of the typed data hash. 35 | 36 | """ 37 | typed_data_message = encode_typed_data(full_message=typed_data) 38 | typed_data_message_hash = _hash_eip191_message(typed_data_message) 39 | 40 | return to_hex(typed_data_message_hash) 41 | -------------------------------------------------------------------------------- /cdp/mnemonic_seed_phrase.py: -------------------------------------------------------------------------------- 1 | from dataclasses import dataclass 2 | 3 | 4 | @dataclass 5 | class MnemonicSeedPhrase: 6 | """Class representing a BIP-39mnemonic seed phrase. 7 | 8 | Used to import external wallets into CDP as 1-of-1 wallets. 9 | 10 | Args: 11 | mnemonic_phrase (str): A valid BIP-39 mnemonic phrase (12, 15, 18, 21, or 24 words). 12 | 13 | """ 14 | 15 | mnemonic_phrase: str 16 | -------------------------------------------------------------------------------- /cdp/network.py: -------------------------------------------------------------------------------- 1 | from dataclasses import dataclass 2 | from typing import Literal 3 | 4 | from cdp.client.models.network_identifier import NetworkIdentifier 5 | 6 | # Only SmartWallet related chains are listed here right now 7 | SupportedChainId = Literal[8453, 84532] 8 | 9 | CHAIN_ID_TO_NETWORK_ID: dict[SupportedChainId, NetworkIdentifier] = { 10 | 8453: "base-mainnet", 11 | 84532: "base-sepolia", 12 | } 13 | 14 | 15 | @dataclass(frozen=True) 16 | class Network: 17 | """Represents a network with its chain ID and network identifier.""" 18 | 19 | chain_id: SupportedChainId 20 | network_id: NetworkIdentifier 21 | 22 | @classmethod 23 | def from_chain_id(cls, chain_id: SupportedChainId) -> "Network": 24 | """Create a Network instance from a supported chain ID.""" 25 | return cls(chain_id, CHAIN_ID_TO_NETWORK_ID[chain_id]) 26 | -------------------------------------------------------------------------------- /cdp/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coinbase/cdp-sdk-python/34bd2c2552e19bd3a90c9c9d74a214e7b7c6f981/cdp/py.typed -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /docs/cdp.client.rst: -------------------------------------------------------------------------------- 1 | cdp.client package 2 | ================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | cdp.client.api 11 | cdp.client.models 12 | 13 | Submodules 14 | ---------- 15 | 16 | cdp.client.api\_client module 17 | ----------------------------- 18 | 19 | .. automodule:: cdp.client.api_client 20 | :members: 21 | :undoc-members: 22 | :show-inheritance: 23 | 24 | cdp.client.api\_response module 25 | ------------------------------- 26 | 27 | .. automodule:: cdp.client.api_response 28 | :members: 29 | :undoc-members: 30 | :show-inheritance: 31 | 32 | cdp.client.configuration module 33 | ------------------------------- 34 | 35 | .. automodule:: cdp.client.configuration 36 | :members: 37 | :undoc-members: 38 | :show-inheritance: 39 | 40 | cdp.client.exceptions module 41 | ---------------------------- 42 | 43 | .. automodule:: cdp.client.exceptions 44 | :members: 45 | :undoc-members: 46 | :show-inheritance: 47 | 48 | cdp.client.rest module 49 | ---------------------- 50 | 51 | .. automodule:: cdp.client.rest 52 | :members: 53 | :undoc-members: 54 | :show-inheritance: 55 | 56 | Module contents 57 | --------------- 58 | 59 | .. automodule:: cdp.client 60 | :members: 61 | :undoc-members: 62 | :show-inheritance: 63 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # For the full list of built-in configuration values, see the documentation: 4 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 5 | 6 | # -- Project information ----------------------------------------------------- 7 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information 8 | 9 | import sys 10 | import os 11 | 12 | sys.path.insert(0, os.path.abspath("..")) 13 | 14 | 15 | project = 'CDP SDK' 16 | author = 'Coinbase Developer Platform' 17 | release = '0.21.0' 18 | 19 | # -- General configuration --------------------------------------------------- 20 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration 21 | 22 | extensions = [ 23 | 'myst_parser', # Parsing Markdown 24 | 'sphinx.ext.autodoc', # Automatically generate documentation from docstrings 25 | 'sphinx.ext.napoleon', # Google-style docstring support 26 | 'sphinx_autodoc_typehints' # Type hints in function signatures 27 | ] 28 | 29 | templates_path = ['_templates'] 30 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 31 | 32 | 33 | # -- Options for HTML output ------------------------------------------------- 34 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output 35 | 36 | html_theme = 'alabaster' 37 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | CDP SDK documentation 2 | ===================== 3 | 4 | .. include:: README.md 5 | :parser: myst_parser.sphinx_ 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | :caption: Contents: 10 | :hidden: 11 | 12 | modules 13 | 14 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | %SPHINXBUILD% >NUL 2>NUL 14 | if errorlevel 9009 ( 15 | echo. 16 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 17 | echo.installed, then set the SPHINXBUILD environment variable to point 18 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 19 | echo.may add the Sphinx directory to PATH. 20 | echo. 21 | echo.If you don't have Sphinx installed, grab it from 22 | echo.https://www.sphinx-doc.org/ 23 | exit /b 1 24 | ) 25 | 26 | if "%1" == "" goto help 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/modules.rst: -------------------------------------------------------------------------------- 1 | cdp 2 | === 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | cdp 8 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "cdp-sdk" 3 | version = "0.21.0" 4 | description = "CDP Python SDK" 5 | authors = ["John Peterson "] 6 | license = "LICENSE.md" 7 | readme = "README.md" 8 | packages = [{ include = "cdp" }] 9 | 10 | [tool.poetry.dependencies] 11 | python = "^3.10" 12 | urllib3 = "^2.2.3" 13 | pydantic = "^2.10.3" 14 | web3 = "^7.6.0" 15 | pyjwt = "^2.10.1" 16 | cryptography = "^44.0.0" 17 | python-dateutil = "^2.9.0.post0" 18 | coincurve = "^20.0.0" 19 | bip-utils = "^2.9.3" 20 | 21 | [tool.poetry.group.dev.dependencies] 22 | ruff = "^0.7.1" 23 | mypy = "^1.13.0" 24 | pytest = "^8.3.3" 25 | pytest-cov = "^6.0.0" 26 | sphinx = "^8.0.2" 27 | sphinx-autobuild = "^2024.9.19" 28 | sphinxcontrib-napoleon = "^0.7" 29 | sphinx-autodoc-typehints = "^2.4.4" 30 | myst-parser = "^4.0.0" 31 | ruff-lsp = "^0.0.58" 32 | python-lsp-server = "^1.12.0" 33 | python-dotenv = "^1.0.1" 34 | 35 | [build-system] 36 | requires = ["poetry-core"] 37 | build-backend = "poetry.core.masonry.api" 38 | 39 | [tool.mypy] 40 | python_version = "3.10" 41 | strict = true 42 | ignore_missing_imports = true 43 | 44 | [tool.ruff] 45 | line-length = 100 46 | target-version = "py310" 47 | exclude = ["./build/**", "./dist/**", "./docs/**", "./cdp/client/**"] 48 | 49 | [tool.ruff.lint] 50 | select = ["E", "F", "I", "N", "W", "D", "UP", "B", "C4", "SIM", "RUF"] 51 | ignore = ["D213", "D203", "D100", "D104", "D107", "E501"] 52 | 53 | [tool.ruff.lint.pep8-naming] 54 | # Allow camelCase property names in WalletData import for cross-compatibility with Node.JS SDK 55 | classmethod-decorators = ["classmethod"] 56 | ignore-names = ["networkId", "walletId"] 57 | 58 | [tool.ruff.format] 59 | quote-style = "double" 60 | indent-style = "space" 61 | skip-magic-trailing-comma = false 62 | line-ending = "auto" 63 | 64 | [tool.ruff.lint.isort] 65 | known-first-party = ["cdp"] 66 | 67 | [tool.pytest.ini_options] 68 | minversion = "6.0" 69 | addopts = "-ra -q --cov=cdp --cov-report=term-missing -m 'not e2e'" 70 | testpaths = [ 71 | "tests", 72 | ] 73 | markers = [ 74 | "e2e: e2e tests, requiring env, deselect with '-m \"not e2e\"'", 75 | ] 76 | 77 | [tool.coverage.run] 78 | omit = ["cdp/client/*"] 79 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coinbase/cdp-sdk-python/34bd2c2552e19bd3a90c9c9d74a214e7b7c6f981/tests/__init__.py -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | import os 2 | from unittest.mock import MagicMock 3 | 4 | import pytest 5 | 6 | from cdp import Cdp 7 | from cdp.api_clients import ApiClients 8 | 9 | 10 | @pytest.fixture(autouse=True) 11 | def initialize_cdp(request): 12 | """Initialize the CDP SDK with mock API clients before each test.""" 13 | # Skip this fixture for e2e tests 14 | if request.node.get_closest_marker("e2e"): 15 | yield 16 | return 17 | 18 | original_api_clients = Cdp.api_clients 19 | mock_api_clients = MagicMock(spec=ApiClients) 20 | Cdp.api_clients = mock_api_clients 21 | yield 22 | Cdp.api_clients = original_api_clients 23 | 24 | 25 | factory_modules = [ 26 | f[:-3] for f in os.listdir("./tests/factories") if f.endswith(".py") and f != "__init__.py" 27 | ] 28 | 29 | pytest_plugins = [f"tests.factories.{module_name}" for module_name in factory_modules] 30 | -------------------------------------------------------------------------------- /tests/factories/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coinbase/cdp-sdk-python/34bd2c2552e19bd3a90c9c9d74a214e7b7c6f981/tests/factories/__init__.py -------------------------------------------------------------------------------- /tests/factories/account_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from eth_account import Account 3 | 4 | 5 | @pytest.fixture 6 | def account_factory(): 7 | """Create and return a factory for test accounts.""" 8 | 9 | def _create_account(private_key="0x" + "1" * 64): 10 | return Account.from_key(private_key) 11 | 12 | return _create_account 13 | -------------------------------------------------------------------------------- /tests/factories/address_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.address import Address 4 | 5 | 6 | @pytest.fixture 7 | def address_factory(): 8 | """Create and return a factory for Address fixtures.""" 9 | 10 | def _create_address( 11 | network_id="base-sepolia", 12 | address_id="0x1234567890123456789012345678901234567890", 13 | ): 14 | return Address(network_id, address_id) 15 | 16 | return _create_address 17 | -------------------------------------------------------------------------------- /tests/factories/address_reputation_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.address_reputation import AddressReputation 4 | from cdp.client.models.address_reputation import AddressReputation as AddressReputationModel 5 | from cdp.client.models.address_reputation_metadata import AddressReputationMetadata 6 | 7 | 8 | @pytest.fixture 9 | def address_reputation_model_factory(): 10 | """Create and return a factory for creating AddressReputation fixtures.""" 11 | 12 | def _create_address_reputation_model( 13 | score=1, 14 | total_transactions=2, 15 | unique_days_active=3, 16 | longest_active_streak=4, 17 | current_active_streak=5, 18 | activity_period_days=6, 19 | token_swaps_performed=7, 20 | bridge_transactions_performed=8, 21 | lend_borrow_stake_transactions=9, 22 | ens_contract_interactions=10, 23 | smart_contract_deployments=10, 24 | ): 25 | metadata = AddressReputationMetadata( 26 | total_transactions=total_transactions, 27 | unique_days_active=unique_days_active, 28 | longest_active_streak=longest_active_streak, 29 | current_active_streak=current_active_streak, 30 | activity_period_days=activity_period_days, 31 | token_swaps_performed=token_swaps_performed, 32 | bridge_transactions_performed=bridge_transactions_performed, 33 | lend_borrow_stake_transactions=lend_borrow_stake_transactions, 34 | ens_contract_interactions=ens_contract_interactions, 35 | smart_contract_deployments=smart_contract_deployments, 36 | ) 37 | return AddressReputationModel(score=score, metadata=metadata) 38 | 39 | return _create_address_reputation_model 40 | 41 | 42 | @pytest.fixture 43 | def address_reputation_factory(address_reputation_model_factory): 44 | """Create and return a factory for creating AddressReputation fixtures.""" 45 | 46 | def _create_address_reputation(score=10): 47 | reputation_model = address_reputation_model_factory(score=score) 48 | return AddressReputation(reputation_model) 49 | 50 | return _create_address_reputation 51 | -------------------------------------------------------------------------------- /tests/factories/api_key_factory.py: -------------------------------------------------------------------------------- 1 | import base64 2 | 3 | import pytest 4 | 5 | 6 | @pytest.fixture 7 | def dummy_key_factory(): 8 | """Create and return a factory function for generating dummy keys for testing. 9 | 10 | The factory accepts a `key_type` parameter with the following options: 11 | - "ecdsa": Returns a PEM-encoded ECDSA private key. 12 | - "ed25519-32": Returns a base64-encoded 32-byte Ed25519 private key. 13 | - "ed25519-64": Returns a base64-encoded 64-byte dummy Ed25519 key (the first 32 bytes will be used). 14 | """ 15 | 16 | def _create_dummy(key_type: str = "ecdsa") -> str: 17 | if key_type == "ecdsa": 18 | return ( 19 | "-----BEGIN EC PRIVATE KEY-----\n" 20 | "MHcCAQEEIMM75bm9WZCYPkfjXSUWNU5eHx47fWM2IpG8ki90BhRDoAoGCCqGSM49\n" 21 | "AwEHoUQDQgAEicwlaAqy7Z4SS7lvrEYoy6qR9Kf0n0jFzg+XExcXKU1JMr18z47W\n" 22 | "5mrftEqWIqPCLQ16ByoKW2Bsup5V3q9P4g==\n" 23 | "-----END EC PRIVATE KEY-----\n" 24 | ) 25 | elif key_type == "ed25519-32": 26 | return "BXyKC+eFINc/6ztE/3neSaPGgeiU9aDRpaDnAbaA/vyTrUNgtuh/1oX6Vp+OEObV3SLWF+OkF2EQNPtpl0pbfA==" 27 | elif key_type == "ed25519-64": 28 | # Create a 64-byte dummy by concatenating a 32-byte sequence with itself. 29 | dummy_32 = b"\x01" * 32 30 | dummy_64 = dummy_32 + dummy_32 31 | return base64.b64encode(dummy_64).decode("utf-8") 32 | else: 33 | raise ValueError("Unsupported key type for dummy key creation") 34 | 35 | return _create_dummy 36 | -------------------------------------------------------------------------------- /tests/factories/asset_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.asset import Asset 4 | from cdp.client.models.asset import Asset as AssetModel 5 | 6 | 7 | @pytest.fixture 8 | def asset_model_factory(): 9 | """Create and return a factory for creating AssetModel fixtures.""" 10 | 11 | def _create_asset_model(network_id="base-sepolia", asset_id="usdc", decimals=6): 12 | return AssetModel(network_id=network_id, asset_id=asset_id, decimals=decimals) 13 | 14 | return _create_asset_model 15 | 16 | 17 | @pytest.fixture 18 | def asset_factory(asset_model_factory): 19 | """Create and return a factory for creating Asset fixtures.""" 20 | 21 | def _create_asset(network_id="base-sepolia", asset_id="usdc", decimals=6): 22 | asset_model = asset_model_factory(network_id, asset_id, decimals) 23 | return Asset.from_model(asset_model) 24 | 25 | return _create_asset 26 | -------------------------------------------------------------------------------- /tests/factories/balance_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.balance import Balance 4 | from cdp.client.models.balance import Balance as BalanceModel 5 | 6 | 7 | @pytest.fixture 8 | def balance_model_factory(asset_model_factory): 9 | """Create and return a factory for creating BalanceModel fixtures.""" 10 | 11 | def _create_balance_model( 12 | amount="1000000000000000000", network_id="base-sepolia", asset_id="eth", decimals=18 13 | ): 14 | asset_model = asset_model_factory(network_id, asset_id, decimals) 15 | return BalanceModel(amount=amount, asset=asset_model) 16 | 17 | return _create_balance_model 18 | 19 | 20 | @pytest.fixture 21 | def balance_factory(asset_factory): 22 | """Create and return a factory for creating Balance fixtures.""" 23 | 24 | def _create_balance( 25 | amount="1000000000000000000", network_id="base-sepolia", asset_id="eth", decimals=18 26 | ): 27 | asset = asset_factory(network_id="base-sepolia", asset_id="eth", decimals=18) 28 | return Balance(amount, asset) 29 | 30 | return _create_balance 31 | -------------------------------------------------------------------------------- /tests/factories/compiled_smart_contract_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.compiled_smart_contract import ( 4 | CompiledSmartContract as CompiledSmartContractModel, 5 | ) 6 | 7 | 8 | @pytest.fixture 9 | def compiled_smart_contract_model_factory(): 10 | """Create and return a factory for creating CompiledSmartContractModel fixtures.""" 11 | 12 | def _create_compiled_smart_contract_model(): 13 | return CompiledSmartContractModel( 14 | compiled_smart_contract_id="test-compiled-smart-contract-id", 15 | contract_name="TestContract", 16 | abi='{"abi":"data"}', 17 | solidity_version="0.8.28+commit.7893614a", 18 | solidity_input_json='{"abi":"data"}', 19 | ) 20 | 21 | return _create_compiled_smart_contract_model 22 | -------------------------------------------------------------------------------- /tests/factories/contract_invocation_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.contract_invocation import ContractInvocation as ContractInvocationModel 4 | from cdp.contract_invocation import ContractInvocation 5 | 6 | 7 | @pytest.fixture 8 | def contract_invocation_model_factory(transaction_model_factory): 9 | """Create and return a factory for creating ContractInvocationModel fixtures.""" 10 | 11 | def _create_contract_invocation_model(status="complete"): 12 | return ContractInvocationModel( 13 | network_id="base-sepolia", 14 | wallet_id="test-wallet-id", 15 | address_id="0xaddressid", 16 | contract_invocation_id="test-invocation-id", 17 | contract_address="0xcontractaddress", 18 | method="testMethod", 19 | args='{"arg1": "value1"}', 20 | abi='{"abi": "data"}', 21 | amount="1", 22 | transaction=transaction_model_factory(status), 23 | ) 24 | 25 | return _create_contract_invocation_model 26 | 27 | 28 | @pytest.fixture 29 | def contract_invocation_factory(contract_invocation_model_factory): 30 | """Create and return a factory for creating ContractInvocation fixtures.""" 31 | 32 | def _create_contract_invocation(status="complete"): 33 | contract_invocation_model = contract_invocation_model_factory(status) 34 | return ContractInvocation(contract_invocation_model) 35 | 36 | return _create_contract_invocation 37 | -------------------------------------------------------------------------------- /tests/factories/crypto_amount_factory.py: -------------------------------------------------------------------------------- 1 | from decimal import Decimal 2 | 3 | import pytest 4 | 5 | from cdp.client.models.crypto_amount import CryptoAmount as CryptoAmountModel 6 | from cdp.crypto_amount import CryptoAmount 7 | 8 | 9 | @pytest.fixture 10 | def crypto_amount_model_factory(asset_model_factory): 11 | """Create and return a factory for creating CryptoAmountModel fixtures.""" 12 | 13 | def _create_crypto_amount_model(asset_id="USDC", decimals=6, amount="1"): 14 | asset_model = asset_model_factory("base-sepolia", asset_id, decimals) 15 | return CryptoAmountModel(amount=amount, asset=asset_model) 16 | 17 | return _create_crypto_amount_model 18 | 19 | 20 | @pytest.fixture 21 | def crypto_amount_factory(asset_factory): 22 | """Create and return a factory for creating CryptoAmount fixtures.""" 23 | 24 | def _create_crypto_amount(asset_id="USDC", decimals=6, amount="1"): 25 | asset = asset_factory("base-sepolia", asset_id, decimals) 26 | return CryptoAmount(Decimal(amount), asset) 27 | 28 | return _create_crypto_amount 29 | -------------------------------------------------------------------------------- /tests/factories/faucet_transaction_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.faucet_transaction import FaucetTransaction as FaucetTransactionModel 4 | from cdp.faucet_transaction import FaucetTransaction 5 | 6 | 7 | @pytest.fixture 8 | def faucet_transaction_model_factory(transaction_model_factory): 9 | """Create and return a factory for creating FaucetTransactionModel fixtures.""" 10 | 11 | def _create_faucet_tx_model(status="complete"): 12 | transaction_model = transaction_model_factory(status) 13 | 14 | if transaction_model.transaction_hash is None: 15 | raise ValueError("Faucet transaction must have a hash.") 16 | 17 | if transaction_model.transaction_link is None: 18 | raise ValueError("Faucet transaction must have a link.") 19 | 20 | return FaucetTransactionModel( 21 | transaction=transaction_model, 22 | transaction_hash=transaction_model.transaction_hash, 23 | transaction_link=transaction_model.transaction_link, 24 | ) 25 | 26 | return _create_faucet_tx_model 27 | 28 | 29 | @pytest.fixture 30 | def faucet_transaction_factory(faucet_transaction_model_factory): 31 | """Create and return a factory for creating FaucetTransaction fixtures.""" 32 | 33 | def _create_faucet_transaction(status="complete"): 34 | faucet_tx_model = faucet_transaction_model_factory(status) 35 | return FaucetTransaction(faucet_tx_model) 36 | 37 | return _create_faucet_transaction 38 | -------------------------------------------------------------------------------- /tests/factories/fund_operation_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.fiat_amount import FiatAmount 4 | from cdp.client.models.fund_operation import FundOperation as FundOperationModel 5 | from cdp.client.models.fund_operation_fees import FundOperationFees 6 | from cdp.fund_operation import FundOperation 7 | 8 | 9 | @pytest.fixture 10 | def fund_operation_model_factory( 11 | crypto_amount_model_factory, transaction_model_factory, fund_quote_model_factory 12 | ): 13 | """Create and return a factory for creating FundOperationModel fixtures.""" 14 | 15 | def _create_fund_operation_model( 16 | status="complete", asset_id="eth", amount="2000000000000000000", decimals=18 17 | ): 18 | crypto_amount_model = crypto_amount_model_factory(asset_id, decimals, amount) 19 | transfer_fee_crypto_amount_model = crypto_amount_model_factory( 20 | asset_id, 18, "10000000000000000" 21 | ) # 0.01 ETH 22 | return FundOperationModel( 23 | fund_operation_id="test-operation-id", 24 | network_id="base-sepolia", 25 | wallet_id="test-wallet-id", 26 | address_id="test-address-id", 27 | crypto_amount=crypto_amount_model, 28 | fiat_amount=FiatAmount(amount="100", currency="USD"), 29 | fees=FundOperationFees( 30 | buy_fee=FiatAmount(amount="1", currency="USD"), 31 | transfer_fee=transfer_fee_crypto_amount_model, 32 | ), 33 | status=status, 34 | ) 35 | 36 | return _create_fund_operation_model 37 | 38 | 39 | @pytest.fixture 40 | def fund_operation_factory(fund_operation_model_factory): 41 | """Create and return a factory for creating FundOperation fixtures.""" 42 | 43 | def _create_fund_operation( 44 | status="complete", asset_id="eth", amount="2000000000000000000", decimals=18 45 | ): 46 | fund_operation_model = fund_operation_model_factory( 47 | status=status, asset_id=asset_id, amount=amount, decimals=decimals 48 | ) 49 | return FundOperation(fund_operation_model) 50 | 51 | return _create_fund_operation 52 | -------------------------------------------------------------------------------- /tests/factories/fund_quote_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.fiat_amount import FiatAmount 4 | from cdp.client.models.fund_operation_fees import FundOperationFees 5 | from cdp.client.models.fund_quote import FundQuote as FundQuoteModel 6 | from cdp.fund_quote import FundQuote 7 | 8 | 9 | @pytest.fixture 10 | def fund_quote_model_factory(crypto_amount_model_factory): 11 | """Create and return a factory for creating FundQuoteModel fixtures.""" 12 | 13 | def _create_fund_quote_model(amount="2000000000000000000", decimals=18, asset_id="eth"): 14 | crypto_amount_model = crypto_amount_model_factory(asset_id, decimals, amount) 15 | transfer_fee_crypto_amount_model = crypto_amount_model_factory( 16 | asset_id, 18, "10000000000000000" 17 | ) # 0.01 ETH 18 | return FundQuoteModel( 19 | fund_quote_id="test-quote-id", 20 | network_id="base-sepolia", 21 | wallet_id="test-wallet-id", 22 | address_id="test-address-id", 23 | crypto_amount=crypto_amount_model, 24 | fiat_amount=FiatAmount(amount="100", currency="USD"), 25 | expires_at="2024-12-31T23:59:59Z", 26 | fees=FundOperationFees( 27 | buy_fee=FiatAmount(amount="1", currency="USD"), 28 | transfer_fee=transfer_fee_crypto_amount_model, 29 | ), 30 | ) 31 | 32 | return _create_fund_quote_model 33 | 34 | 35 | @pytest.fixture 36 | def fund_quote_factory(fund_quote_model_factory): 37 | """Create and return a factory for creating FundQuote fixtures.""" 38 | 39 | def _create_fund_quote(amount="2000000000000000000", decimals=18, asset_id="eth"): 40 | fund_quote_model = fund_quote_model_factory( 41 | amount=amount, decimals=decimals, asset_id=asset_id 42 | ) 43 | return FundQuote(fund_quote_model) 44 | 45 | return _create_fund_quote 46 | -------------------------------------------------------------------------------- /tests/factories/historical_balance_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.historical_balance import HistoricalBalance as HistoricalBalanceModel 4 | from cdp.historical_balance import HistoricalBalance 5 | 6 | 7 | @pytest.fixture 8 | def historical_balance_model_factory(asset_model_factory): 9 | """Create and return a factory for creating HistoricalBalance fixtures.""" 10 | 11 | def _create_historical_balance_model( 12 | amount="1000000000000000000", 13 | network_id="base-sepolia", 14 | asset_id="eth", 15 | decimals=18, 16 | block_hash="0xblockhash", 17 | block_height="12345", 18 | ): 19 | asset_model = asset_model_factory(network_id, asset_id, decimals) 20 | return HistoricalBalanceModel( 21 | amount=amount, block_hash=block_hash, block_height=block_height, asset=asset_model 22 | ) 23 | 24 | return _create_historical_balance_model 25 | 26 | 27 | @pytest.fixture 28 | def historical_balance_factory(asset_factory): 29 | """Create and return a factory for creating HistoricalBalance fixtures.""" 30 | 31 | def _create_historical_balance( 32 | amount="1000000000000000000", 33 | network_id="base-sepolia", 34 | asset_id="eth", 35 | decimals=18, 36 | block_hash="0xblockhash", 37 | block_height="12345", 38 | ): 39 | asset = asset_factory(network_id=network_id, asset_id=asset_id, decimals=decimals) 40 | return HistoricalBalance(amount, asset, block_height, block_hash) 41 | 42 | return _create_historical_balance 43 | -------------------------------------------------------------------------------- /tests/factories/payload_signature_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.payload_signature import PayloadSignature as PayloadSignatureModel 4 | from cdp.payload_signature import PayloadSignature 5 | 6 | 7 | @pytest.fixture 8 | def payload_signature_model_factory(): 9 | """Create and return a factory for creating PayloadSignatureModel fixtures.""" 10 | 11 | def _create_payload_signature_model(status="signed"): 12 | payload_signature_model = PayloadSignatureModel( 13 | payload_signature_id="test-payload-signature-id", 14 | address_id="0xaddressid", 15 | wallet_id="test-wallet-id", 16 | unsigned_payload="0xunsignedpayload", 17 | signature="0xsignature" if status == "signed" else None, 18 | status=status, 19 | ) 20 | 21 | return payload_signature_model 22 | 23 | return _create_payload_signature_model 24 | 25 | 26 | @pytest.fixture 27 | def payload_signature_factory(payload_signature_model_factory): 28 | """Create and return a factory for creating PayloadSignature fixtures.""" 29 | 30 | def _create_payload_signature(status="signed"): 31 | payload_signature_model = payload_signature_model_factory(status) 32 | return PayloadSignature(payload_signature_model) 33 | 34 | return _create_payload_signature 35 | -------------------------------------------------------------------------------- /tests/factories/smart_wallet_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.smart_wallet import SmartWallet as SmartWalletModel 4 | from cdp.smart_wallet import SmartWallet 5 | 6 | 7 | @pytest.fixture 8 | def smart_wallet_model_factory(account_factory): 9 | """Create and return a factory for WalletModel fixtures.""" 10 | 11 | def _create_smart_wallet_model( 12 | address="0x1234567890123456789012345678901234567890", 13 | owner=None, 14 | ): 15 | if owner is None: 16 | owner = account_factory() 17 | return SmartWalletModel(address=address, owners=[owner]) 18 | 19 | return _create_smart_wallet_model 20 | 21 | 22 | @pytest.fixture 23 | def smart_wallet_factory(smart_wallet_model_factory, account_factory): 24 | """Create and return a factory for SmartWallet fixtures.""" 25 | 26 | def _create_smart_wallet(smart_wallet_address, account=account_factory): 27 | smart_wallet_model = smart_wallet_model_factory( 28 | address=smart_wallet_address, owner=account.address 29 | ) 30 | return SmartWallet(smart_wallet_model.address, account) 31 | 32 | return _create_smart_wallet 33 | -------------------------------------------------------------------------------- /tests/factories/sponsored_send_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.sponsored_send import SponsoredSend as SponsoredSendModel 4 | 5 | 6 | @pytest.fixture 7 | def sponsored_send_model_factory(): 8 | """Create and return a factory for creating SponsoredSendModel fixtures.""" 9 | 10 | def _create_sponsored_send_model(status="complete"): 11 | status = "submitted" if status == "broadcast" else status 12 | 13 | return SponsoredSendModel( 14 | to_address_id="0xdestination", 15 | raw_typed_data="0xtypeddata", 16 | typed_data_hash="0xtypeddatahash", 17 | signature="0xsignature" if status in ["signed", "submitted", "complete"] else None, 18 | transaction_hash="0xtransactionhash" if status == "complete" else None, 19 | transaction_link="https://sepolia.basescan.org/tx/0xtransactionlink" 20 | if status == "complete" 21 | else None, 22 | status=status, 23 | ) 24 | 25 | return _create_sponsored_send_model 26 | -------------------------------------------------------------------------------- /tests/factories/trade_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.trade import Trade as TradeModel 4 | from cdp.trade import Trade 5 | 6 | 7 | @pytest.fixture 8 | def trade_model_factory(asset_model_factory, transaction_model_factory): 9 | """Create and return a factory for creating TradeModel fixtures.""" 10 | 11 | def _create_trade_model( 12 | status="complete", 13 | from_asset_id="usdc", 14 | to_asset_id="eth", 15 | from_asset_decimals=6, 16 | to_asset_decimals=18, 17 | ): 18 | from_asset_model = asset_model_factory(asset_id=from_asset_id, decimals=from_asset_decimals) 19 | to_asset_model = asset_model_factory(asset_id=to_asset_id, decimals=to_asset_decimals) 20 | transaction_model = transaction_model_factory(status) 21 | approve_transaction_model = transaction_model_factory(status) 22 | 23 | return TradeModel( 24 | network_id="base-sepolia", 25 | wallet_id="test-wallet-id", 26 | address_id="0xaddressid", 27 | trade_id="test-trade-id", 28 | from_asset=from_asset_model, 29 | to_asset=to_asset_model, 30 | from_amount="1000000", # 1 USDC 31 | to_amount="500000000000000000", # 0.5 ETH 32 | transaction=transaction_model, 33 | approve_transaction=approve_transaction_model, 34 | ) 35 | 36 | return _create_trade_model 37 | 38 | 39 | @pytest.fixture 40 | def trade_factory(trade_model_factory): 41 | """Create and return a factory for creating Trade fixtures.""" 42 | 43 | def _create_trade(status="complete", from_asset_id="usdc", to_asset_id="eth"): 44 | trade_model = trade_model_factory(status, from_asset_id, to_asset_id) 45 | return Trade(trade_model) 46 | 47 | return _create_trade 48 | -------------------------------------------------------------------------------- /tests/factories/transaction_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.transaction import Transaction as TransactionModel 4 | from cdp.transaction import Transaction 5 | 6 | 7 | @pytest.fixture 8 | def transaction_model_factory(): 9 | """Create and return a factory for creating TransactionModel fixtures.""" 10 | 11 | def _create_transaction_model(status="complete"): 12 | return TransactionModel( 13 | network_id="base-sepolia", 14 | transaction_hash="0xtransactionhash", 15 | from_address_id="0xaddressid", 16 | to_address_id="0xdestination", 17 | unsigned_payload="0xunsignedpayload", 18 | signed_payload="0xsignedpayload" 19 | if status in ["signed", "broadcast", "complete"] 20 | else None, 21 | status=status, 22 | transaction_link="https://sepolia.basescan.org/tx/0xtransactionlink" 23 | if status in ["broadcast", "complete"] 24 | else None, 25 | block_hash="0xblockhash" if status == "complete" else None, 26 | block_height="123456" if status == "complete" else None, 27 | ) 28 | 29 | return _create_transaction_model 30 | 31 | 32 | @pytest.fixture 33 | def transaction_factory(transaction_model_factory): 34 | """Create and return a factory for creating Transaction fixtures.""" 35 | 36 | def _create_transaction(status="complete"): 37 | model = transaction_model_factory(status) 38 | return Transaction(model) 39 | 40 | return _create_transaction 41 | -------------------------------------------------------------------------------- /tests/factories/transfer_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.transfer import Transfer as TransferModel 4 | from cdp.transfer import Transfer 5 | 6 | 7 | @pytest.fixture 8 | def transfer_model_factory( 9 | asset_model_factory, sponsored_send_model_factory, transaction_model_factory 10 | ): 11 | """Create and return a factory for creating TransferModel fixtures.""" 12 | 13 | def _create_transfer_model(gasless=True, status="complete", asset_id="usdc"): 14 | asset_model = asset_model_factory(asset_id=asset_id) 15 | if gasless: 16 | sponsored_send_model = sponsored_send_model_factory(status) 17 | transaction_model = None 18 | else: 19 | sponsored_send_model = None 20 | transaction_model = transaction_model_factory(status) 21 | 22 | return TransferModel( 23 | network_id="base-sepolia", 24 | wallet_id="test-wallet-id", 25 | address_id="0xaddressid", 26 | destination="0xdestination", 27 | amount="1000000", # 1 USDC or 1 ETH in wei 28 | asset_id=asset_model.asset_id, 29 | transfer_id="test-transfer-id", 30 | asset=asset_model, 31 | gasless=gasless, 32 | sponsored_send=sponsored_send_model, 33 | transaction=transaction_model, 34 | ) 35 | 36 | return _create_transfer_model 37 | 38 | 39 | @pytest.fixture 40 | def transfer_factory(transfer_model_factory): 41 | """Create and return a factory for creating Transfer fixtures.""" 42 | 43 | def _create_transfer(gasless=True, status="complete", asset_id="usdc"): 44 | transfer_model = transfer_model_factory(gasless, status, asset_id) 45 | return Transfer(transfer_model) 46 | 47 | return _create_transfer 48 | -------------------------------------------------------------------------------- /tests/factories/user_operation_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client.models.call import Call 4 | from cdp.client.models.user_operation import UserOperation as UserOperationModel 5 | 6 | 7 | @pytest.fixture 8 | def user_operation_model_factory(): 9 | """Create and return a factory for UserOperationModel fixtures.""" 10 | 11 | def _create_user_operation_model( 12 | id="test-user-operation-id", 13 | network_id="base-sepolia", 14 | calls=None, 15 | user_op_hash="0x" + "1" * 64, 16 | signature="0x3456789012345678901234567890123456789012", 17 | transaction_hash="0x4567890123456789012345678901234567890123", 18 | status="pending", 19 | ): 20 | if calls is None: 21 | calls = [ 22 | Call( 23 | to="0x1234567890123456789012345678901234567890", 24 | value="1000000000000000000", 25 | data="0x", 26 | ) 27 | ] 28 | return UserOperationModel( 29 | id=id, 30 | network_id=network_id, 31 | calls=calls, 32 | unsigned_payload=user_op_hash, 33 | user_op_hash=user_op_hash, 34 | signature=signature, 35 | transaction_hash=transaction_hash, 36 | status=status, 37 | ) 38 | 39 | return _create_user_operation_model 40 | -------------------------------------------------------------------------------- /tests/factories/wallet_address_factory.py: -------------------------------------------------------------------------------- 1 | from unittest.mock import Mock 2 | 3 | import pytest 4 | from eth_account.signers.local import LocalAccount 5 | 6 | from cdp.client.models.address import Address as AddressModel 7 | from cdp.wallet_address import WalletAddress 8 | 9 | 10 | @pytest.fixture 11 | def address_model_factory(): 12 | """Create and return a factory for AddressModel fixtures.""" 13 | 14 | def _create_address_model( 15 | network_id="base-sepolia", 16 | address_id="0x1234567890123456789012345678901234567890", 17 | wallet_id="test-wallet-id", 18 | public_key="0xpublickey", 19 | index=0, 20 | ): 21 | return AddressModel( 22 | network_id=network_id, 23 | address_id=address_id, 24 | wallet_id=wallet_id, 25 | public_key=public_key, 26 | index=index, 27 | ) 28 | 29 | return _create_address_model 30 | 31 | 32 | @pytest.fixture 33 | def wallet_address_factory(address_model_factory): 34 | """Create and return a factory for WalletAddress fixtures.""" 35 | 36 | def _create_wallet_address(key=False, **kwargs): 37 | model = address_model_factory(**kwargs) 38 | 39 | _key = None 40 | if key: 41 | _key = Mock(spec=LocalAccount) 42 | 43 | return WalletAddress(model, _key) 44 | 45 | return _create_wallet_address 46 | -------------------------------------------------------------------------------- /tests/factories/wallet_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from bip_utils import Bip32Slip10Secp256k1 3 | 4 | from cdp.client.models.feature_set import FeatureSet 5 | from cdp.client.models.wallet import Wallet as WalletModel 6 | from cdp.wallet import Wallet 7 | 8 | 9 | @pytest.fixture 10 | def wallet_model_factory(address_model_factory): 11 | """Create and return a factory for WalletModel fixtures.""" 12 | 13 | def _create_wallet_model( 14 | id="test-wallet-id", 15 | network_id="base-sepolia", 16 | default_address=None, 17 | feature_set=None, 18 | server_signer_status="active_seed", 19 | ): 20 | if default_address is None: 21 | default_address = address_model_factory() 22 | if feature_set is None: 23 | feature_set = FeatureSet( 24 | faucet=True, 25 | server_signer=True, 26 | transfer=True, 27 | trade=True, 28 | stake=True, 29 | gasless_send=True, 30 | ) 31 | return WalletModel( 32 | id=id, 33 | network_id=network_id, 34 | default_address=default_address, 35 | feature_set=feature_set, 36 | server_signer_status=server_signer_status, 37 | ) 38 | 39 | return _create_wallet_model 40 | 41 | 42 | @pytest.fixture 43 | def master_key_factory(): 44 | """Create and return a factory for master key fixtures.""" 45 | 46 | def _create_master_key(seed=b"\x00" * 64): 47 | return Bip32Slip10Secp256k1.FromSeed(seed) 48 | 49 | return _create_master_key 50 | 51 | 52 | @pytest.fixture 53 | def wallet_factory(wallet_model_factory): 54 | """Create and return a factory for Wallet fixtures.""" 55 | 56 | def _create_wallet(seed=None, **kwargs): 57 | model = wallet_model_factory(**kwargs) 58 | return Wallet(model, seed) 59 | 60 | return _create_wallet 61 | -------------------------------------------------------------------------------- /tests/factories/webhook_factory.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp.client import WebhookEventTypeFilter, WebhookStatus, WebhookWalletActivityFilter 4 | from cdp.webhook import Webhook, WebhookEventType, WebhookModel 5 | 6 | 7 | @pytest.fixture 8 | def webhook_factory(): 9 | """Create and return a factory for Webhook fixtures.""" 10 | 11 | def _create_webhook( 12 | webhook_id="webhook-123", 13 | network_id="base-sepolia", 14 | notification_uri="https://example.com/webhook", 15 | event_type=WebhookEventType.WALLET_ACTIVITY, 16 | event_type_filter=None, 17 | event_filters=None, 18 | ): 19 | # Ensure the event_type_filter is properly initialized 20 | if event_type_filter is None and event_type == WebhookEventType.WALLET_ACTIVITY: 21 | event_type_filter = WebhookEventTypeFilter( 22 | actual_instance=WebhookWalletActivityFilter( 23 | wallet_id="w1", 24 | addresses=["0xa55C5950F7A3C42Fa5799B2Cac0e455774a07382"], 25 | ) 26 | ) 27 | 28 | model = WebhookModel( 29 | id=webhook_id, 30 | network_id=network_id, 31 | notification_uri=notification_uri, 32 | event_type=event_type, 33 | event_type_filter=event_type_filter, 34 | event_filters=event_filters or [], 35 | status=WebhookStatus.ACTIVE, 36 | ) 37 | return Webhook(model) 38 | 39 | return _create_webhook 40 | -------------------------------------------------------------------------------- /tests/test_address_reputation.py: -------------------------------------------------------------------------------- 1 | from cdp.address_reputation import AddressReputation 2 | 3 | 4 | def test_address_reputation_initialization(address_reputation_factory): 5 | """Test address reputation initialization.""" 6 | address_reputation = address_reputation_factory() 7 | assert isinstance(address_reputation, AddressReputation) 8 | 9 | 10 | def test_address_reputation_score(address_reputation_factory): 11 | """Test address reputation score.""" 12 | address_reputation = address_reputation_factory() 13 | 14 | assert address_reputation.score == 10 15 | 16 | 17 | def test_address_reputation_metadata(address_reputation_factory): 18 | """Test address reputation metadata.""" 19 | address_reputation = address_reputation_factory() 20 | 21 | assert address_reputation.metadata.total_transactions == 2 22 | assert address_reputation.metadata.unique_days_active == 3 23 | 24 | 25 | def test_address_reputation_risky(address_reputation_factory): 26 | """Test address reputation risky.""" 27 | address_reputation = address_reputation_factory(score=-5) 28 | assert address_reputation.risky is True 29 | 30 | address_reputation = address_reputation_factory(score=0) 31 | assert address_reputation.risky is False 32 | 33 | address_reputation = address_reputation_factory(score=5) 34 | assert address_reputation.risky is False 35 | 36 | 37 | def test_address_reputation_str(address_reputation_factory): 38 | """Test address reputation str.""" 39 | address_reputation = address_reputation_factory(score=10) 40 | expected_str = "Address Reputation: (score=10, metadata=(total_transactions=2, unique_days_active=3, longest_active_streak=4, current_active_streak=5, activity_period_days=6, token_swaps_performed=7, bridge_transactions_performed=8, lend_borrow_stake_transactions=9, ens_contract_interactions=10, smart_contract_deployments=10))" 41 | assert str(address_reputation) == expected_str 42 | 43 | 44 | def test_address_reputation_repr(address_reputation_factory): 45 | """Test address reputation repr.""" 46 | address_reputation = address_reputation_factory(score=10) 47 | expected_repr = "Address Reputation: (score=10, metadata=(total_transactions=2, unique_days_active=3, longest_active_streak=4, current_active_streak=5, activity_period_days=6, token_swaps_performed=7, bridge_transactions_performed=8, lend_borrow_stake_transactions=9, ens_contract_interactions=10, smart_contract_deployments=10))" 48 | assert repr(address_reputation) == expected_repr 49 | -------------------------------------------------------------------------------- /tests/test_api_client.py: -------------------------------------------------------------------------------- 1 | from cdp import __version__ 2 | from cdp.cdp import Cdp 3 | from cdp.cdp_api_client import CdpApiClient 4 | from cdp.constants import SDK_DEFAULT_SOURCE 5 | 6 | 7 | def test_api_client_get_correlation_data(): 8 | """Tests _get_correlation_data from the CdpApiClient.""" 9 | cdp_api_client = CdpApiClient( 10 | api_key="test", 11 | private_key="test", 12 | ) 13 | expected_result = f"""sdk_version={__version__},sdk_language=python,source={SDK_DEFAULT_SOURCE},source_version={__version__}""" 14 | assert cdp_api_client._get_correlation_data() == expected_result 15 | 16 | cdp_api_client2 = CdpApiClient( 17 | api_key="test", 18 | private_key="test", 19 | host="https://api.cdp.coinbase.com/platform", 20 | debugging=False, 21 | max_network_retries=3, 22 | source="test", 23 | source_version="test_ver", 24 | ) 25 | expected_result2 = ( 26 | f"""sdk_version={__version__},sdk_language=python,source=test,source_version=test_ver""" 27 | ) 28 | assert cdp_api_client2._get_correlation_data() == expected_result2 29 | 30 | Cdp.configure(api_key_name="test", private_key="test") 31 | assert Cdp.api_clients._cdp_client._get_correlation_data() == expected_result 32 | 33 | Cdp.configure(api_key_name="test", private_key="test", source="test", source_version="test_ver") 34 | assert Cdp.api_clients._cdp_client._get_correlation_data() == expected_result2 35 | -------------------------------------------------------------------------------- /tests/test_api_key_utils.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from cryptography.hazmat.primitives.asymmetric import ec, ed25519 3 | 4 | from cdp.api_key_utils import _parse_private_key 5 | 6 | 7 | def test_parse_private_key_pem_ec(dummy_key_factory): 8 | """Test that a PEM-encoded ECDSA key is parsed correctly using a dummy key from the factory.""" 9 | dummy_key = dummy_key_factory("ecdsa") 10 | parsed_key = _parse_private_key(dummy_key) 11 | assert isinstance(parsed_key, ec.EllipticCurvePrivateKey) 12 | 13 | 14 | def test_parse_private_key_ed25519_32(dummy_key_factory): 15 | """Test that a base64-encoded 32-byte Ed25519 key is parsed correctly using a dummy key from the factory.""" 16 | dummy_key = dummy_key_factory("ed25519-32") 17 | parsed_key = _parse_private_key(dummy_key) 18 | assert isinstance(parsed_key, ed25519.Ed25519PrivateKey) 19 | 20 | 21 | def test_parse_private_key_ed25519_64(dummy_key_factory): 22 | """Test that a base64-encoded 64-byte input is parsed correctly by taking the first 32 bytes using a dummy key from the factory.""" 23 | dummy_key = dummy_key_factory("ed25519-64") 24 | parsed_key = _parse_private_key(dummy_key) 25 | assert isinstance(parsed_key, ed25519.Ed25519PrivateKey) 26 | 27 | 28 | def test_parse_private_key_invalid(): 29 | """Test that an invalid key string raises a ValueError.""" 30 | with pytest.raises(ValueError, match="Could not parse the private key"): 31 | _parse_private_key("invalid_key") 32 | -------------------------------------------------------------------------------- /tests/test_balance.py: -------------------------------------------------------------------------------- 1 | from decimal import Decimal 2 | 3 | from cdp.asset import Asset 4 | from cdp.balance import Balance 5 | 6 | 7 | def test_balance_initialization(asset_factory): 8 | """Test balance initialization.""" 9 | asset = asset_factory(asset_id="eth", decimals=18) 10 | 11 | balance = Balance(Decimal("1"), asset) 12 | assert balance.amount == Decimal("1") 13 | assert balance.asset == asset 14 | assert balance.asset_id == "eth" 15 | 16 | 17 | def test_balance_initialization_with_asset_id(asset_factory): 18 | """Test balance initialization with asset ID.""" 19 | asset = asset_factory(asset_id="eth", decimals=18) 20 | 21 | balance = Balance(Decimal("10"), asset, asset_id="gwei") 22 | assert balance.amount == Decimal("10") 23 | assert balance.asset == asset 24 | assert balance.asset_id == "gwei" 25 | 26 | 27 | def test_balance_from_model(balance_model_factory): 28 | """Test balance from model.""" 29 | balance_model = balance_model_factory() 30 | 31 | balance = Balance.from_model(balance_model) 32 | assert balance.amount == Decimal("1") 33 | assert isinstance(balance.asset, Asset) 34 | assert balance.asset.asset_id == "eth" 35 | assert balance.asset_id == "eth" 36 | 37 | 38 | def test_balance_from_model_with_asset_id(balance_model_factory): 39 | """Test balance from model with asset ID.""" 40 | balance_model = balance_model_factory() 41 | 42 | balance = Balance.from_model(balance_model, asset_id="gwei") 43 | assert balance.amount == Decimal("1000000000") 44 | assert isinstance(balance.asset, Asset) 45 | assert balance.asset.asset_id == "gwei" 46 | assert balance.asset_id == "gwei" 47 | 48 | 49 | def test_balance_amount(balance_factory): 50 | """Test balance amount.""" 51 | balance = balance_factory(amount=1.5) 52 | 53 | assert balance.amount == Decimal("1.5") 54 | 55 | 56 | def test_balance_str_representation(balance_factory): 57 | """Test balance string representation.""" 58 | balance = balance_factory(amount=1.5) 59 | assert ( 60 | str(balance) 61 | == "Balance: (amount: 1.5, asset: Asset: (asset_id: eth, network_id: base-sepolia, contract_address: None, decimals: 18))" 62 | ) 63 | 64 | 65 | def test_balance_repr(balance_factory): 66 | """Test balance repr.""" 67 | balance = balance_factory(amount=1.5) 68 | assert ( 69 | repr(balance) 70 | == "Balance: (amount: 1.5, asset: Asset: (asset_id: eth, network_id: base-sepolia, contract_address: None, decimals: 18))" 71 | ) 72 | -------------------------------------------------------------------------------- /tests/test_cdp.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cdp import Cdp 4 | from cdp.errors import UninitializedSDKError 5 | 6 | 7 | def test_uninitialized_error(): 8 | """Test that direct access to API clients raises UninitializedSDKError.""" 9 | Cdp.api_clients = Cdp.ApiClientsWrapper() 10 | 11 | with pytest.raises(UninitializedSDKError) as excinfo: 12 | _ = Cdp.api_clients.wallets 13 | 14 | assert "Coinbase SDK has not been initialized" in str(excinfo.value) 15 | assert "Cdp.configure(api_key_name=" in str(excinfo.value) 16 | assert "Cdp.configure_from_json(file_path=" in str(excinfo.value) 17 | -------------------------------------------------------------------------------- /tests/test_crypto_amount.py: -------------------------------------------------------------------------------- 1 | from decimal import Decimal 2 | 3 | from cdp.crypto_amount import CryptoAmount 4 | 5 | 6 | def test_crypto_amount_initialization(crypto_amount_factory): 7 | """Test crypto amount initialization.""" 8 | crypto_amount = crypto_amount_factory("USDC", 6, "1") 9 | assert isinstance(crypto_amount, CryptoAmount) 10 | assert crypto_amount.amount == Decimal("1") 11 | assert crypto_amount.asset.asset_id == "USDC" 12 | assert crypto_amount.asset.network_id == "base-sepolia" 13 | assert crypto_amount.asset.decimals == 6 14 | 15 | 16 | def test_crypto_amount_from_model(crypto_amount_model_factory): 17 | """Test crypto amount from model.""" 18 | crypto_amount_model = crypto_amount_model_factory("USDC", 6, "1") 19 | crypto_amount = CryptoAmount.from_model(crypto_amount_model) 20 | assert isinstance(crypto_amount, CryptoAmount) 21 | assert crypto_amount.amount == ( 22 | Decimal(crypto_amount_model.amount) / Decimal(10) ** crypto_amount_model.asset.decimals 23 | ) 24 | assert crypto_amount.asset.asset_id == "USDC" 25 | assert crypto_amount.asset.network_id == "base-sepolia" 26 | assert crypto_amount.asset.decimals == 6 27 | 28 | 29 | def test_crypto_amount_from_model_and_asset_id_with_gwei(crypto_amount_model_factory): 30 | """Test crypto amount from model with gwei.""" 31 | crypto_amount_model = crypto_amount_model_factory("eth", 18, "1") 32 | crypto_amount = CryptoAmount.from_model_and_asset_id(crypto_amount_model, "gwei") 33 | assert isinstance(crypto_amount, CryptoAmount) 34 | assert crypto_amount.amount == (Decimal(crypto_amount_model.amount) / Decimal(10) ** 9) 35 | assert crypto_amount.asset.asset_id == "gwei" 36 | assert crypto_amount.asset.network_id == "base-sepolia" 37 | assert crypto_amount.asset.decimals == 9 38 | 39 | 40 | def test_crypto_amount_from_model_and_asset_id_with_wei(crypto_amount_model_factory): 41 | """Test crypto amount from model with wei.""" 42 | crypto_amount_model = crypto_amount_model_factory("eth", 18, "1") 43 | crypto_amount = CryptoAmount.from_model_and_asset_id(crypto_amount_model, "wei") 44 | assert isinstance(crypto_amount, CryptoAmount) 45 | assert crypto_amount.amount == Decimal(crypto_amount_model.amount) 46 | assert crypto_amount.asset.asset_id == "wei" 47 | assert crypto_amount.asset.network_id == "base-sepolia" 48 | assert crypto_amount.asset.decimals == 0 49 | 50 | 51 | def test_crypto_amount_to_atomic_amount(crypto_amount_factory): 52 | """Test crypto amount to atomic amount.""" 53 | crypto_amount = crypto_amount_factory() 54 | assert crypto_amount.to_atomic_amount() == ( 55 | Decimal(crypto_amount.amount) * Decimal(10) ** crypto_amount.asset.decimals 56 | ) 57 | 58 | 59 | def test_crypto_amount_str_representation(crypto_amount_factory): 60 | """Test crypto amount string representation.""" 61 | crypto_amount = crypto_amount_factory() 62 | assert ( 63 | str(crypto_amount) 64 | == f"CryptoAmount(amount: '{int(crypto_amount.amount)}', asset_id: '{crypto_amount.asset.asset_id}')" 65 | ) 66 | 67 | 68 | def test_crypto_amount_repr(crypto_amount_factory): 69 | """Test crypto amount repr.""" 70 | crypto_amount = crypto_amount_factory() 71 | assert ( 72 | repr(crypto_amount) 73 | == f"CryptoAmount(amount: '{int(crypto_amount.amount)}', asset_id: '{crypto_amount.asset.asset_id}')" 74 | ) 75 | -------------------------------------------------------------------------------- /tests/test_evm_call_types.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from web3.types import Wei 3 | 4 | from cdp.evm_call_types import ContractCall, EncodedCall, FunctionCall 5 | 6 | 7 | def test_evm_call_dict_valid(): 8 | """Test that the EVMCallDict is valid.""" 9 | call = EncodedCall(to="0x742d35Cc6634C0532925a3b844Bc454e4438f44e") 10 | assert isinstance(call.to, str) 11 | assert call.value is None 12 | assert call.data is None 13 | 14 | call = EncodedCall( 15 | to="0x742d35Cc6634C0532925a3b844Bc454e4438f44e", 16 | value=Wei(1000000000000000000), 17 | data="0x095ea7b30000000000000000000000742d35cc6634c0532925a3b844bc454e4438f44e", 18 | ) 19 | assert isinstance(call.to, str) 20 | assert call.value == 1000000000000000000 21 | assert isinstance(call.data, str) 22 | 23 | 24 | def test_evm_abi_call_dict_valid(): 25 | """Test that the EVMAbiCallDict is valid.""" 26 | call = FunctionCall( 27 | to="0x742d35Cc6634C0532925a3b844Bc454e4438f44e", 28 | abi=[ 29 | { 30 | "inputs": [], 31 | "name": "totalSupply", 32 | "outputs": [{"type": "uint256"}], 33 | "stateMutability": "view", 34 | "type": "function", 35 | } 36 | ], 37 | function_name="totalSupply", 38 | args=[], 39 | ) 40 | assert isinstance(call.to, str) 41 | assert call.value is None 42 | assert isinstance(call.abi, list) 43 | assert call.function_name == "totalSupply" 44 | assert call.args == [] 45 | 46 | call = FunctionCall( 47 | to="0x742d35Cc6634C0532925a3b844Bc454e4438f44e", 48 | value=Wei(1000000000000000000), 49 | abi=[ 50 | { 51 | "inputs": [ 52 | {"name": "spender", "type": "address"}, 53 | {"name": "amount", "type": "uint256"}, 54 | ], 55 | "name": "approve", 56 | "outputs": [{"type": "bool"}], 57 | "stateMutability": "nonpayable", 58 | "type": "function", 59 | } 60 | ], 61 | function_name="approve", 62 | args=["0x742d35Cc6634C0532925a3b844Bc454e4438f44e", 1000000], 63 | ) 64 | assert isinstance(call.to, str) 65 | assert call.value == 1000000000000000000 66 | assert isinstance(call.abi, list) 67 | assert call.function_name == "approve" 68 | assert len(call.args) == 2 69 | 70 | 71 | def test_evm_abi_call_dict_invalid(): 72 | """Test that the EVMAbiCallDict is invalid.""" 73 | with pytest.raises(ValueError): 74 | FunctionCall(to="0x742d35Cc6634C0532925a3b844Bc454e4438f44e", function_name="test", args=[]) 75 | 76 | 77 | def test_evm_call_union(): 78 | """Test that the EVMCall union is valid.""" 79 | call_dict = EncodedCall(to="0x742d35Cc6634C0532925a3b844Bc454e4438f44e") 80 | abi_call_dict = FunctionCall( 81 | to="0x742d35Cc6634C0532925a3b844Bc454e4438f44e", abi=[], function_name="test", args=[] 82 | ) 83 | 84 | call: ContractCall = call_dict 85 | assert isinstance(call, EncodedCall) 86 | 87 | call = abi_call_dict 88 | assert isinstance(call, FunctionCall) 89 | -------------------------------------------------------------------------------- /tests/test_fiat_amount.py: -------------------------------------------------------------------------------- 1 | from decimal import Decimal 2 | 3 | from cdp.client.models.fiat_amount import FiatAmount as FiatAmountModel 4 | from cdp.fiat_amount import FiatAmount 5 | 6 | 7 | def test_fiat_amount_from_model(): 8 | """Test converting a FiatAmount model to a FiatAmount.""" 9 | model = FiatAmountModel(amount="100.50", currency="USD") 10 | fiat_amount = FiatAmount.from_model(model) 11 | 12 | assert fiat_amount.amount == Decimal("100.50") 13 | assert fiat_amount.currency == "USD" 14 | 15 | 16 | def test_fiat_amount_properties(): 17 | """Test FiatAmount properties.""" 18 | fiat_amount = FiatAmount(amount=Decimal("50.25"), currency="USD") 19 | 20 | assert fiat_amount.amount == Decimal("50.25") 21 | assert fiat_amount.currency == "USD" 22 | 23 | 24 | def test_fiat_amount_str_representation(): 25 | """Test string representation of FiatAmount.""" 26 | fiat_amount = FiatAmount(amount=Decimal("75.00"), currency="USD") 27 | expected_str = "FiatAmount(amount: '75', currency: 'USD')" 28 | 29 | assert str(fiat_amount) == expected_str 30 | assert repr(fiat_amount) == expected_str 31 | 32 | 33 | def test_fiat_amount_repr(): 34 | """Test repr of FiatAmount.""" 35 | fiat_amount = FiatAmount(amount=Decimal("75.00"), currency="USD") 36 | assert repr(fiat_amount) == "FiatAmount(amount: '75', currency: 'USD')" 37 | -------------------------------------------------------------------------------- /tests/test_hash_utils.py: -------------------------------------------------------------------------------- 1 | from cdp.hash_utils import hash_message, hash_typed_data_message 2 | 3 | 4 | def test_hash_message(): 5 | """Test hash_message utility method.""" 6 | message_hash = hash_message("Hello, EIP-191!") 7 | assert message_hash == "0x54c2490066f5b62dd2e2ea2310c2b3d63039bbce5e3f96175a1b66a0c484e74f" 8 | 9 | 10 | def test_hash_typed_data_message(): 11 | """Test hash_typed_data_message utility method.""" 12 | typed_data = { 13 | "types": { 14 | "EIP712Domain": [ 15 | {"name": "name", "type": "string"}, 16 | {"name": "version", "type": "string"}, 17 | {"name": "chainId", "type": "uint256"}, 18 | {"name": "verifyingContract", "type": "address"}, 19 | ], 20 | "Person": [{"name": "name", "type": "string"}, {"name": "wallet", "type": "address"}], 21 | "Mail": [ 22 | {"name": "from", "type": "Person"}, 23 | {"name": "to", "type": "Person"}, 24 | {"name": "contents", "type": "string"}, 25 | ], 26 | }, 27 | "primaryType": "Mail", 28 | "domain": { 29 | "name": "Ether Mail", 30 | "version": "1", 31 | "chainId": 1, 32 | "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC", 33 | }, 34 | "message": { 35 | "from": {"name": "Alice", "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"}, 36 | "to": {"name": "Bob", "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"}, 37 | "contents": "Hello, Bob!", 38 | }, 39 | } 40 | typed_data_message_hash = hash_typed_data_message(typed_data) 41 | assert ( 42 | typed_data_message_hash 43 | == "0x4644890d40a2ebb8cbf599801c4412c03f8027f04044d0dd12a0605fbd72bb8b" 44 | ) 45 | -------------------------------------------------------------------------------- /tests/test_network.py: -------------------------------------------------------------------------------- 1 | from dataclasses import FrozenInstanceError 2 | 3 | import pytest 4 | 5 | from cdp.network import Network 6 | 7 | 8 | def test_network_creation(): 9 | """Test basic network instance creation.""" 10 | network = Network(8453, "base-mainnet") 11 | assert network.chain_id == 8453 12 | assert network.network_id == "base-mainnet" 13 | 14 | 15 | def test_network_immutability(): 16 | """Test that the network instance is immutable.""" 17 | network = Network(8453, "base-mainnet") 18 | with pytest.raises(FrozenInstanceError): 19 | network.chain_id = 84532 20 | 21 | 22 | def test_from_chain_id_factory(): 23 | """Test the from_chain_id factory method.""" 24 | network = Network.from_chain_id(8453) 25 | assert network.chain_id == 8453 26 | assert network.network_id == "base-mainnet" 27 | --------------------------------------------------------------------------------