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

update webhook bugfix #288

Closed
wants to merge 1 commit into from
Closed

update webhook bugfix #288

wants to merge 1 commit into from

Conversation

howard-at-cb
Copy link
Contributor

What changed? Why?

Fixed a bug that overwrites existing webhook notification URI when only updating a webhook's addresses

 let wh = await Webhook.create({ networkId: "base-mainnet", notificationUri: "https://www.google.com/callback", eventType: "wallet_activity",  eventTypeFilter: {addresses: ["0xa55C5950F7A3C42Fa5799B2Cac0e455774a07382"], wallet_id: "w1"}, eventFilters: [{ contract_address: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913" }], signatureHeader: "optional-signature-string"});
undefined
> wh.update({eventTypeFilter: {addresses:["0x40A28c0fCc0BE09400bB89CdF556Cd8C4eF1c165","0x6f03b3Df22F0C57A4477EEAc3a49c2Bc4EAe2206"]}})
Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 136,
  [Symbol(trigger_async_id_symbol)]: 4
}
> wh
Webhook {
  model: {
    created_at: '2024-10-09T18:47:59.182Z',
    event_filters: [ [Object] ],
    event_type: 'wallet_activity',
    event_type_filter: { addresses: [Array], wallet_id: 'w1' },
    id: '6706cfdf1f3dda7f7fc8f6d2',
    network_id: 'base-mainnet',
    notification_uri: 'https://www.google.com/callback',
    updated_at: '2024-10-09T18:48:13.901Z'
  }
}

Qualified Impact

@howard-at-cb howard-at-cb marked this pull request as ready for review October 9, 2024 18:55
Comment on lines 191 to 195
const result = await Coinbase.apiClients.webhook!.updateWebhook(this.getId()!, {
notification_uri: notificationUri,
notification_uri: finalNotificationUri,
event_filters: this.getEventFilters()!,
event_type_filter: eventTypeFilter,
event_type_filter: finalEventTypeFilter,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Are all of those props required on the request? What about not sending it, if user hasn't sent on the SDK function param? It would be ideal to the API request to mimic what user intended, this could also possibly prevent issues in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because on the CDP side this is a PUT endpoint, so we have to provide all these parameters when calling it. These parameters are as good as required, although not labeled as "required".

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 1 more test where we update the event type filter and not the notification URI.

Comment on lines +5 to +6
## [0.8.1] - 2024-10-09
### Fixed
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
## [0.8.1] - 2024-10-09
### Fixed
## [0.8.1] - 2024-10-09
### Fixed

@jazz-cb jazz-cb deleted the v0.8.1 branch October 11, 2024 20:31
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.

3 participants