Skip to content

introduce wallet activity webhook - #1

Open
lizard-boy wants to merge 17 commits into
v0.6.0from
wallet-activity-support
Open

introduce wallet activity webhook #1
lizard-boy wants to merge 17 commits into
v0.6.0from
wallet-activity-support

Conversation

@lizard-boy

Copy link
Copy Markdown

What changed? Why?

let w2 = 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"});
undefined
> w2.toString()
`Webhook { id: '66e9dc7bb97a771dc092d26b', networkId: 'base-mainnet', eventType: 'wallet_activity', eventFilter: [{"contract_address":"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"}], eventTypeFilter: {"addresses":["0xa55c5950f7a3c42fa5799b2cac0e455774a07382"],"wallet_id":"w1"}, notificationUri: 'https://e.com/callback', signatureHeader: 'optional-signature-string' }`

Qualified Impact

@lizard-boy lizard-boy changed the title Wallet activity support introduce wallet activity webhook Sep 18, 2024
@dakshgup

Copy link
Copy Markdown

@greptileai

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PR Summary

This PR introduces support for wallet activity webhooks in the Coinbase SDK for Node.js, enhancing the webhook functionality with more specific event filtering capabilities.

  • Added eventTypeFilter field to CreateWebhookOptions type in src/coinbase/types.ts
  • Implemented createWebhook method in Wallet class in src/coinbase/wallet.ts
  • Updated Webhook class in src/coinbase/webhook.ts to handle new eventTypeFilter parameter
  • Modified webhook test suite in src/tests/webhook_test.ts to cover new functionality
  • Changes align with the example provided in the PR description, demonstrating proper implementation

4 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings

Comment thread src/coinbase/wallet.ts
Comment on lines +770 to +773
addresses: this.addresses.map(address => address.getId()!),
wallet_id: this.getId()!,
},
signatureHeader: signatureHeader,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

logic: this.addresses might be empty if listAddresses hasn't been called. Consider adding a check or calling listAddresses if needed

Comment thread src/coinbase/wallet.ts
Comment on lines +752 to +760
/**
* Creates a Webhook.
*
* @param notificationUri - [String] The URI to which the webhook notifications will be sent.
* @param signatureHeader - [String] (Optional) A header used to sign the webhook request,
* defaulting to an empty string.
*
* @returns [Coinbase::Webhook] The newly created webhook instance.
*/

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: Add @throws annotation to document potential errors

Comment thread src/coinbase/webhook.ts
Comment on lines +147 to +149
public getEventTypeFilter(): WebhookEventTypeFilter | undefined {
return this.model?.event_type_filter;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: Add JSDoc for the return type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants