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

refactor: Extract registry types in to own crate #453

Merged
merged 8 commits into from
Dec 15, 2023

Conversation

morgsmccauley
Copy link
Collaborator

@morgsmccauley morgsmccauley commented Dec 14, 2023

This PR extract the types exposed by the registry contract in to its own reusable crate: registry_types. This was done to avoid the duplication across our different service which; fetch the JSON, and then construct the Rust types.

registry_types crate

The registry types were already partially shared between Coordinator and the registry, but I've expanded on this to include all types rather than just a subset. I've created a new crate, rather than using the existing ./indexer/indexer_rule_type crate as some packages needed to be upgraded, which caused conflicts across the indexer/ cargo workspace - which seemed unnecessary to fix given that it is being deprecated.

Registry contract updates

near-sdk version 4.1.1 is no longer compilable because it depends on a non-existent crate, hence the upgrade to 5.0.0-alpha.1. Since I was already making changes here, I decided to remove the migration related code as it is no longer needed.

Consuming registry_types

With the shared types in place, I've updated block-streamer/ to use them, removing the existing types which it duplicates. I also went ahead and removed all types which were unused (left over from Alertexer).

indexer_rule_type depends on near-sdk version 4.1.1 (the broken one), and since it's no longer shared, I removed that dependency so that it can compile again.

Relates to #421

@morgsmccauley morgsmccauley requested a review from a team as a code owner December 14, 2023 21:17
uint = { version = "0.9.3", default-features = false }
indexer_rule_type = { features = ["nearsdk"], path = "../../indexer/indexer_rule_type" }
registry-types = { path = "../types", features = ["nearsdk"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

are we using the nearsdk feature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes - it forces the crate to use near-sdk types so that it is compatible with the registry contract

@roshaans
Copy link
Contributor

Can we add some details in the main readme about this readme?

@morgsmccauley
Copy link
Collaborator Author

Can we add some details in the main readme about this readme?

The types are used internally, I'm not sure adding something would provide much benefit? Did you have something specific in mind?

@morgsmccauley morgsmccauley merged commit af38be3 into main Dec 15, 2023
10 checks passed
@morgsmccauley morgsmccauley deleted the refactor/shared-registry-types branch December 15, 2023 02:02
@morgsmccauley morgsmccauley linked an issue Dec 17, 2023 that may be closed by this pull request
@morgsmccauley morgsmccauley mentioned this pull request Dec 19, 2023
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.

Create Control service
3 participants