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

Enable wallet activity events support for webhooks at wallet level #189

Open
wants to merge 8 commits into
base: v0.7.0
Choose a base branch
from

Conversation

chaoyaji-cb
Copy link
Contributor

@chaoyaji-cb chaoyaji-cb commented Sep 17, 2024

What changed? Why?

  • Introduce wallet_activity event type with event_type_filter -> wallet_activity_filter that tracks wallet addresses with wallet id
  • Enable wallet.create_webhook()
[2] pry(main)> wa = Coinbase::Wallet.list.first
=> Coinbase::Wallet{id: '7808e5ad-afff-4295-8474-fee86814a7f4', network_id: 'base_sepolia', default_address: '0x0462dbeD18478e4e7e54f32391E2cAF672Ea2144'}
[3] pry(main)> wa.create_webhook(notification_uri:"https://david_demo.com")
=> Coinbase::Webhook{id: '66e9be77b97a771dc092d266', network_id: 'base-sepolia', event_type: 'wallet_activity', notification_uri: 'https://david_demo.com', event_filters: '[]', signature_header: '', event_type_filter: '{:addresses=>["0x0462dbed18478e4e7e54f32391e2caf672ea2144"], :wallet_id=>"7808e5ad-afff-4295-8474-fee86814a7f4"}'}

Qualified Impact

@cb-heimdall
Copy link

cb-heimdall commented Sep 17, 2024

✅ Heimdall Review Status

Requirement Status More Info
Reviews 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@chaoyaji-cb chaoyaji-cb changed the title Wallet Enable wallet activity events support for webhooks at wallet level Sep 17, 2024
@chaoyaji-cb chaoyaji-cb marked this pull request as ready for review September 17, 2024 22:34
# defaulting to an empty string.
#
# @return [Coinbase::Webhook] The newly created webhook instance.
def create_webhook(notification_uri:, addresses: self.addresses.map(&:id), signature_header: '')

Choose a reason for hiding this comment

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

are we providing some sort of override to wallet addresses?
i feel they should not be able to do that... if custom group of addresses needs to be provided they can just go through webhook object

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we disallow clients to specify addresses when calling wallet.create_webhook() ? We can use the wallet's existing addresses.

@alex-stone alex-stone changed the base branch from master to v0.7.0 September 19, 2024 14:04
notification_uri: notification_uri,
event_type: Coinbase::Webhook::WALLET_ACTIVITY_EVENT,
event_type_filter: {
addresses: addresses.map(&: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 the addresses be determined by the backend?

Otherwise when we create a new address, the user would need to update the webhook or the backend would need to manage it anyways

@@ -21,10 +21,12 @@
let(:second_address_model) do
build(:address_model, network_id, :with_seed, seed: seed, wallet_id: wallet_id, index: 1)
end
let(:webhook_model) { build(:webhook_model, :wallet_activity) }
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is only used in the #create_webhook test, please define it in that test.

The let should generally be defined in the most narrow scope possible (e.g. the top-level lets are referenced by multiple test cases or in a top-level before block_

Choose a reason for hiding this comment

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

could it be Eth?

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