From ac912ff4aa18999cfd09ef56c7ebcfac914ab46a Mon Sep 17 00:00:00 2001 From: Howard Xie Date: Fri, 18 Oct 2024 12:50:25 -0700 Subject: [PATCH] wallet webhook --- cdp/wallet.py | 20 ++++++++++++++++++++ cdp/webhook.py | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cdp/wallet.py b/cdp/wallet.py index 4f37ba1..0519e49 100644 --- a/cdp/wallet.py +++ b/cdp/wallet.py @@ -18,6 +18,7 @@ from cdp.address import Address from cdp.balance_map import BalanceMap from cdp.cdp import Cdp +from cdp.client.models.create_wallet_webhook_request import CreateWalletWebhookRequest from cdp.client.models.address import Address as AddressModel from cdp.client.models.create_address_request import CreateAddressRequest from cdp.client.models.create_wallet_request import ( @@ -33,6 +34,7 @@ from cdp.trade import Trade from cdp.wallet_address import WalletAddress from cdp.wallet_data import WalletData +from cdp.webhook import Webhook class Wallet: @@ -286,6 +288,24 @@ def create_address(self) -> "WalletAddress": return wallet_address + def create_webhook(self, notification_uri: str) -> "Webhook": + """Create a new webhook for the wallet. + + Returns: + Webhook: The created webhook object. + + Raises: + Exception: If there's an error creating the webhook. + + """ + + create_wallet_webhook_request = CreateWalletWebhookRequest(notification_uri = notification_uri) + model = Cdp.api_clients.webhooks.create_wallet_webhook( + wallet_id=self.id, create_wallet_webhook_request=create_wallet_webhook_request + ) + + return Webhook(model) + def faucet(self, asset_id: str | None = None) -> FaucetTransaction: """Request faucet funds. diff --git a/cdp/webhook.py b/cdp/webhook.py index d612492..3f6bda7 100644 --- a/cdp/webhook.py +++ b/cdp/webhook.py @@ -160,7 +160,7 @@ def update( notification_uri: str | None = None, event_type_filter: WebhookEventTypeFilter | None = None ) -> "Webhook": - """Updates the webhook with a new notification URI, and/or a new list of addresses to monitor. + """Update the webhook with a new notification URI, and/or a new list of addresses to monitor. Args: notification_uri (str): The new URI for webhook notifications.