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

feat(protocol): add update subscription message type #2192

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Dec 12, 2024

Description

Add UpdateSubscription message type to allow dynamic subscription updates.

Changes

  • Added UpdateSubscriptionRequest type to protocol with idempotent update behavior
  • Added UpdateSubscription message type to JS SDK
  • Updated example code demonstrating subscription update functionality
  • Fixed ESLint configuration for auto-generated Fuel contract types
  • Made subscription updates use SubscriptionParams directly for consistency

Testing

  • Protocol tests pass
  • JS SDK tests pass
  • ESLint passes for all packages (including Fuel JS SDK)
  • Example code demonstrates subscription update functionality
  • Pre-commit hooks pass

Implementation Details

  • Added idempotent UpdateSubscription message type using SubscriptionParams
  • Allows updating priceFeedIds and properties for existing subscriptions
  • Maintains consistent API between Rust and JavaScript implementations
  • Fixed lint issues in auto-generated code through ESLint configuration
  • Added example code demonstrating subscription update usage

Link to Devin run: https://app.devin.ai/sessions/9c04ee7e379a442ab53ad30c4a689203

Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2024 4:25pm
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2024 4:25pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2024 4:25pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
component-library ⬜️ Ignored (Inspect) Visit Preview Dec 18, 2024 4:25pm
insights ⬜️ Ignored (Inspect) Visit Preview Dec 18, 2024 4:25pm

Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Add "(aside)" to your comment to have me ignore it.

darunrs
darunrs previously approved these changes Dec 12, 2024
Copy link
Contributor

@darunrs darunrs left a comment

Choose a reason for hiding this comment

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

I'm assuming that we intend to add support for this event to Lazer? Also, I believe we do need to tag a release for the SDK in order to use this change. I wonder if there's a way to add a GitHub CI to automatically make a release if a change to this line is detected. Would this be something we would want to add?

@darunrs darunrs dismissed their stale review December 12, 2024 19:00

Noticed something

Comment on lines 41 to 45
pub subscription_id: SubscriptionId,
pub add_price_feed_ids: Vec<PriceFeedId>,
pub remove_price_feed_ids: Vec<PriceFeedId>,
pub add_properties: Vec<PriceFeedProperty>,
pub remove_properties: Vec<PriceFeedProperty>,
Copy link
Contributor

@darunrs darunrs Dec 12, 2024

Choose a reason for hiding this comment

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

I can understand updating price feed IDs. But, is subscription ID and properties something we want to allow updates for? I'm actually not even sure what these properties even are...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can allow updates for all parameters (except SubscriptionId obviously, which just specifies the subscription to update).

I'd like UpdateSubscriptionRequest to be idempotent. The user should specify full SubscriptionParams when updating subscription, so UpdateSubscriptionRequest should have the same structure as SubscribeRequest.

Comment on lines 41 to 45
pub subscription_id: SubscriptionId,
pub add_price_feed_ids: Vec<PriceFeedId>,
pub remove_price_feed_ids: Vec<PriceFeedId>,
pub add_properties: Vec<PriceFeedProperty>,
pub remove_properties: Vec<PriceFeedProperty>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can allow updates for all parameters (except SubscriptionId obviously, which just specifies the subscription to update).

I'd like UpdateSubscriptionRequest to be idempotent. The user should specify full SubscriptionParams when updating subscription, so UpdateSubscriptionRequest should have the same structure as SubscribeRequest.

Comment on lines 101 to 105
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SubscriptionUpdatedResponse {
pub subscription_id: SubscriptionId,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think Response::Subscribed will be a suitable response. Let's try to keep the API minimal and not add this one.

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.

2 participants