webb-tools / gadget

A framework for building modular AVS and Tangle Blueprints: https://docs.tangle.tools/developers/blueprints.
https://tangle.tools
MIT License
5 stars 1 forks source link

[TASK] Shell Manager - Listen for blueprints #157

Open shekohex opened 1 month ago

shekohex commented 1 month ago

Overview

The shell manager once it starts, it should query the node to get all the blueprints that this operator is registered in, then it listens for a stream of finality notifications.

In other words, we do this at startup, to get a full view of the world (i.e sync):

let servicesWithBlueprint = await api.rpc.services.queryServicesWithBlueprintsByOperator(ALICE);

See: https://github.com/webb-tools/tangle/pull/647

Then we should listen for events that are produced by the network, and here are some of them:

/// An new operator has been registered.
Registered {
  /// The account that registered as a operator.
  provider: T::AccountId,
  /// The ID of the service blueprint.
  blueprint_id: u64,
  /// The preferences for the operator for this specific blueprint.
  preferences: OperatorPreferences,
  /// The arguments used for registration.
  registration_args: Vec<Field<T::Constraints, T::AccountId>>,
}
/// An operator has been unregistered.
Unregistered {
  /// The account that unregistered as am operator.
  operator: T::AccountId,
  /// The ID of the service blueprint.
  blueprint_id: u64,
}

These events should tell you that if the current operator has registered or unregistered from a blueprint. More could be found here: https://github.com/webb-tools/tangle/blob/74ef976802a68b960677277786b91bca13e260a3/pallets/services/src/lib.rs#L196-L330

Task Checklist