Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contract webhook support #52

Merged
merged 3 commits into from
Nov 27, 2024
Merged

Contract webhook support #52

merged 3 commits into from
Nov 27, 2024

Conversation

howard-at-cb
Copy link
Contributor

What changed? Why?

allow creating and updating contract webhook

existing wallet webhook features unchanged.

from cdp.client.models.webhook_wallet_activity_filter import WebhookWalletActivityFilter
from cdp.client.models.webhook_smart_contract_event_filter import WebhookSmartContractEventFilter

wallet_activity_filter = WebhookWalletActivityFilter(
    addresses=["0x09de27c5bDA91F8CFAC09Da41A0316Fdb8EA2044"],
    wallet_id="w1"
)

event_type_filter = WebhookEventTypeFilter(actual_instance=wallet_activity_filter)


wh2 = cdp.Webhook.create(notification_uri='https://coinbase.com', event_type=WebhookEventType.WALLET_ACTIVITY, event_type_filter=event_type_filter)

new_wallet_activity_filter = WebhookWalletActivityFilter(
   addresses=["0x09de27c5bDA91F8CFAC09Da41A0316Fdb8EA2044", "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],
   wallet_id="w1"
)

new_event_type_filter = WebhookEventTypeFilter(actual_instance=new_wallet_activity_filter)

wh2.update(event_type_filter =new_event_type_filter)


contract_activity_filter = WebhookSmartContractEventFilter(
    contract_addresses=["0x09de27c5bDA91F8CFAC09Da41A0316Fdb8EA2044"],
)

contract webhook create and update

contract_etf = WebhookEventTypeFilter(actual_instance=contract_activity_filter)

wh3 = cdp.Webhook.create(notification_uri='https://kraken.com/callback', event_type=WebhookEventType.SMART_CONTRACT_EVENT_ACTIVITY, event_type_filter=contract_etf)


new_contract_activity_filter = WebhookSmartContractEventFilter(
    contract_addresses=["0x09de27c5bDA91F8CFAC09Da41A0316Fdb8EA2044","0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],
)

new_contract_etf = WebhookEventTypeFilter(actual_instance=new_contract_activity_filter)

wh3.update(event_type_filter =new_contract_etf)

Qualified Impact

# wallet ID is required for wallet activity event type filter, but we do not support updating it just yet, this will be added in the future
if self.event_type == WebhookEventType.WALLET_ACTIVITY:
final_event_type_filter.actual_instance.wallet_id = (
self.event_type_filter.actual_instance.wallet_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a unit test for these in a follow-up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes sir

@alex-stone alex-stone merged commit 59d554c into v0.11.0 Nov 27, 2024
5 checks passed
@alex-stone alex-stone mentioned this pull request Nov 27, 2024
alex-stone added a commit that referenced this pull request Nov 27, 2024
* Fix Asset from_model bug to use passed in asset_id when initializing (#46)

* Support for fund and quote_fund for wallet funding (#47)

* Fix quote fund to properly pass in normalized amount (#50)

* Contract webhook support (#52)

* contract activity webhook support

* Update webhook.py

* Update webhook_factory.py

* chore: Prep v0.11.0 release (#51)

---------

Co-authored-by: rohan-agarwal-coinbase <[email protected]>
Co-authored-by: cb-howardatcb <[email protected]>
@howard-at-cb howard-at-cb deleted the contract-webhook branch November 27, 2024 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants