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

allow updating address list of a wallet activity webhook #280

Merged
merged 5 commits into from
Oct 3, 2024

Conversation

howard-at-cb
Copy link
Contributor

What changed? Why?

let wh1 = await Webhook.create({ networkId: "base-mainnet", notificationUri: "https://e.com/callback", eventType: "wallet_activity",  eventTypeFilter: {addresses: ["0xa55C5950F7A3C42Fa5799B2Cac0e455774a07382"], wallet_id: "w1"}, eventFilters: [{ contract_address: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913" }], signatureHeader: "optional-signature-string"});

 wh1.update({eventTypeFilter: {addresses:["0x40A28c0fCc0BE09400bB89CdF556Cd8C4eF1c165","0x6f03b3Df22F0C57A4477EEAc3a49c2Bc4EAe2206"]}})

 wh1.toString()
`Webhook { id: '66fdd5ac01e05f73022c2a7d', networkId: 'base-mainnet', eventType: 'wallet_activity', eventFilter: [{"contract_address":"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"}], eventTypeFilter: {"addresses":["0x40a28c0fcc0be09400bb89cdf556cd8c4ef1c165","0x6f03b3df22f0c57a4477eeac3a49c2bc4eae2206"],"wallet_id":"w1"}, notificationUri: '', signatureHeader: 'undefined' }`

Qualified Impact

@howard-at-cb howard-at-cb marked this pull request as ready for review October 3, 2024 01:27
Copy link
Contributor

@jair-rosa-cb jair-rosa-cb left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +173 to +176
public async update({
notificationUri,
eventTypeFilter,
}: UpdateWebhookOptions): Promise<Webhook> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note that we're breaking back compat by changing the params here. Not sure if this would be an issue at this point, though.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is a good call out cc @jazz-cb not sure if it matters at this point

or maybe we can make the param like this: notificationUriOrOptions: string | UpdateWebhookOptions
then we can check their input: typeof notificationUriOrOptions === 'string'

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's note it in the release logs.

For update functions lets make sure to use Objects for this forward-compatibility!

CHANGELOG.md Outdated
## [0.8.0] - 2024-10-03

### Breaking
- `Webhook#update` now takes an Object of `{notificationUri, eventTypeFilter}` instead of a string of notification Uri.
Copy link
Contributor

Choose a reason for hiding this comment

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

Webhook#update now takes an Object of {notificationUri, eventTypeFilter} instead of notificationUri string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified.

@howard-at-cb howard-at-cb requested a review from jazz-cb October 3, 2024 17:19
@@ -2,6 +2,11 @@

## Unreleased

## [0.8.0] - 2024-10-03

### Breaking
Copy link
Contributor

Choose a reason for hiding this comment

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

could you also add the instructions to docs

 wh1.update({eventTypeFilter: {addresses:["0x40A28c0fCc0BE09400bB89CdF556Cd8C4eF1c165","0x6f03b3Df22F0C57A4477EEAc3a49c2Bc4EAe2206"]}})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if that is the place to put documentation then this change is documented. cc: @jazz-cb

* @param notificationUri - The new URI for webhook notifications.
* @param options - The options to update webhook.
* @param options.notificationUri - The new URI for webhook notifications.
* @param options.eventTypeFilter - The new eventTypeFilter that contains a new list (replacement) of addresses to monitor for the webhook.
Copy link
Contributor

@jazz-cb jazz-cb Oct 3, 2024

Choose a reason for hiding this comment

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

if eventTypeFilter can only contain replacement addresses, should this be called just addresses?

Also replacement is confusing. Aren't you adding new addresses to the webhook and not replacing the old ones?

@chaoyaji-cb @howard-at-cb

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. I thought about the naming eventTypeFilter, my thought process is that in future we might add more stuff into eventTypeFilter, and we might want to allow clients to update them, so keeping this name for the purpose of extensibility.
  2. It is actually a PUT not a PATCH, so address array passed in will replace the existing addresses in the webhook. I clarified it in this doc PR https://github.cbhq.net/solutions-architecture/docs/pull/715/files#diff-e948e3fa52983fe8dee3cacd990a72989a39f539973f07fca0f2065dc7a0577dR15
    This might not be the ideal solution, we can follow up with changes to this behavior.

@howard-at-cb howard-at-cb merged commit 2edb0af into v0.8.0 Oct 3, 2024
4 checks passed
@howard-at-cb howard-at-cb deleted the update-wallet-webhook-address branch October 3, 2024 18:05
John-peterson-coinbase pushed a commit that referenced this pull request Oct 4, 2024
* test pass

* optional notif URI

* Update wallet.ts

* Update CHANGELOG.md

* Update CHANGELOG.md
John-peterson-coinbase added a commit that referenced this pull request Oct 4, 2024
* update rewards api to latest spec

* update generated client

* update SDK's listAddressTransaction (#260)

* listAddressTransaction

* Update coinbase.ts

* add examples

* allow updating address list of a wallet activity webhook (#280)

* test pass

* optional notif URI

* Update wallet.ts

* Update CHANGELOG.md

* Update CHANGELOG.md

* feat(PSDK-535): Explicit Pagination for list Methods (#282)

* feat(PSDK-535): Explicit Pagination for list Methods

* address comments

* chore: Release v0.8.0 (#283)

---------

Co-authored-by: Filipe Azevedo <[email protected]>
Co-authored-by: cb-howardatcb <[email protected]>
Co-authored-by: Filipe Azevedo <[email protected]>
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.

6 participants