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

chore/56 separate services logic #121

Merged
merged 9 commits into from
Aug 25, 2020
Merged

Conversation

AlanVerbner
Copy link
Contributor

@AlanVerbner AlanVerbner commented Aug 23, 2020

Description

This PR contains a huge (but safe thanks to the tests) refactor. Due to the fact we followed openapi-glue we eneded up with huge modules with a lot of code. This PR tries to fix that.

Also, as it was just part of following the same refactor, I introduced the refactor for #105

Sorry this PR got too big and it's not easy to review but it was a little bit cumbersome to create a PR for each module.

This PR depends on #120

Proposed Solution

  • Logic between controllers and services was separated
  • A data-mapper was introduced to map between model types and Rosetta ones
  • Construction service still requires more work but I'm leaving it for future enhancements
  • Tests were splited in smaller ones to make them easier to read

Important Changes Introduced

Environment config, TESTS_ENABLED is no longer needed, we can just set level to silent and it will work

Testing

yarn test

@AlanVerbner AlanVerbner added the enhancement New feature or request label Aug 23, 2020
@AlanVerbner AlanVerbner added this to Ready For Review in Rosetta API Aug 23, 2020
@AlanVerbner AlanVerbner added this to the Before Releasing milestone Aug 23, 2020
@AlanVerbner AlanVerbner removed this from Ready For Review in Rosetta API Aug 23, 2020
@AlanVerbner AlanVerbner linked an issue Aug 23, 2020 that may be closed by this pull request
@AlanVerbner AlanVerbner marked this pull request as ready for review August 23, 2020 20:15
import { BlockService } from '../services/block-service';
import { mapToAccountBalanceResponse } from '../utils/data-mapper';

/* eslint-disable camelcase */
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think this is necessary

request,
async () => {
const ttlOffset = request.body.options.relative_ttl;
const ttl = await (await constructionService.calculateTtl(request.log, ttlOffset)).toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

why is there two awaits? I think the one outside the parenthesis is not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch

@@ -0,0 +1,7 @@
export const generateNetworkPayload = (blockchain: string, network: string) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no return type in function

@@ -29,9 +29,9 @@ export const cardanoCliMock: CardanoCli = {
export const setupServer = (database: Pool): FastifyInstance => {
const logger = configLogger();
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not used

@t-dallas t-dallas force-pushed the chore/56-separate-services-logic branch from b21d478 to 02ff90d Compare August 24, 2020 15:28
@t-dallas
Copy link
Contributor

We are not being consistent with the loggeer variable name, some places is used as log.info and others as logger.info

@AlanVerbner
Copy link
Contributor Author

I think I replaced all the logs to logger or at least I tried to do so, will fix it.

@AlanVerbner
Copy link
Contributor Author

@t-dallas all comments fixed!

@rhyslbw rhyslbw force-pushed the chore/56-separate-services-logic branch from ec245ba to 81830da Compare August 25, 2020 08:47
@rhyslbw rhyslbw requested a review from t-dallas August 25, 2020 08:48
@rhyslbw
Copy link
Collaborator

rhyslbw commented Aug 25, 2020

I've run the Docker image build locally:

./scripts/build_dev_docker_images.sh
...
Successfully built f296c61e5dbe
Successfully tagged cardano-rosetta:dev
...
Successfully built f9cc3f12df98
Successfully tagged cardano-rosetta:dev-testnet

@t-dallas t-dallas force-pushed the chore/56-separate-services-logic branch from 81830da to ccf7522 Compare August 25, 2020 13:48
@t-dallas t-dallas merged commit 2c6dafd into master Aug 25, 2020
@rhyslbw rhyslbw deleted the chore/56-separate-services-logic branch August 26, 2020 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Separate services logic
3 participants