-
Notifications
You must be signed in to change notification settings - Fork 24
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!: workspace + ports + adapters #73
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
segfault-magnet
requested review from
digorithm,
Br1ght0ne,
Salka1988,
MujkicA,
hal3e and
a team
May 6, 2024 07:34
MujkicA
approved these changes
May 7, 2024
hal3e
approved these changes
May 8, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful! This will make the DevX so much better! 🚀
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous organisation of everything being in one crate had the downside of all dependencies being available to you in every place. That meant you can circumvent the database, eth and fuel traits. The LSP would suggest things you probably aren't looking for (sqlx::Postgres vs storage::Postgres). You can use whatever type you like and couple the project tighter to a dependency.
The project was separated according to the following guidelines:
ports
.If you want your code to interact with any of the outside deps (the
eth
orfuel
nodes or with the database), just add a dependency onports
with the feature flags of the ports you want. You're now dependent only on the interface and you're not pulling inethers-rs
orsqlx
orfuel-core-client
. You're forced to use the interface if you want to communicate with the external systems. Also the compile targets drop significantly and the autocompletion thanks you.port
needs to be reexported from theports
crate. This is so you don't have to guess what crate you need ifU256
shows up in a port. For types we borrow fromethers
ethers-core
was used so not to drag in the whole sdk just to reexport a few types.Error::Storage
variant.main
. This is easily achieved by making the adapter errors pub(crate) so you'll get an error/warning if you try to include them in anypub
method.fuel
,eth
andstorage
. These should only be used by the main binary. Once started every other component accesses them through theports
crate mentioned above.services
crate. This forces you to write services against the ports sinceservices
doesn't have a dep on any of the adapters.fuel
andeth
.EthereumAdapter
was split into two ports:Api
andContract
.Api
is used by the wallet balance tracker and contains general purpose eth node API calls.Contract
represents the contract binding (much like acontract_instance
infuels-rs
).eth
naming was replaced withL1
wherever appropriate. Any public configuration wasn't changed until we actually need to support anything other than eth.