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

Only log when trying to map restricted swap transfers #1732

Merged
merged 3 commits into from
Jul 5, 2024

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Jul 5, 2024

Summary

When mapping a swap transfer, we are currently throwing if the transfer was created by a disallowed app. This means that the mapping breaks when we should be falling back to "standard" transfer mapping.

This switches from throwing to instead logging and returning null instead of a mapped swap transfer. This means that the "standard" mapping will be done instead.

Changes

  • Log/return null instead of throwing when mapping a disallowed swap transfer
  • Update test accordingly

@iamacook iamacook self-assigned this Jul 5, 2024
@iamacook iamacook requested a review from a team as a code owner July 5, 2024 10:21
`Unsupported App: ${order.fullAppData?.appCode}`,
);
// Don't throw in order to fallback to "standard" transfer mapping
return null;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: while I see null returns in many other places related to transactions/swap/twaps mappings to indicate a failure, I also think we should refactor the null returns and change them for actual errors and do proper error handling in the upper layers/caller functions, wdyt? (This is just a general comment, I'm totally fine with this PR 🙂)

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. There is a common pattern with the finding then mapping of swap-related transactions that needs to be refactored in general. I think it would also solve this.

Copy link
Member Author

Choose a reason for hiding this comment

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

"Proper error handling" has been included in #1733, but it should definitely be refactored as mentioned.

@coveralls
Copy link

coveralls commented Jul 5, 2024

Pull Request Test Coverage Report for Build 9806877275

Details

  • 2 of 4 (50.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.006%) to 48.272%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/routes/transactions/mappers/transfers/swap-transfer-info.mapper.ts 2 4 50.0%
Totals Coverage Status
Change from base Build 9806327775: 0.006%
Covered Lines: 4225
Relevant Lines: 7019

💛 - Coveralls

@iamacook iamacook merged commit f9c567e into main Jul 5, 2024
16 checks passed
@iamacook iamacook deleted the log-swap-transfer-info-allowance branch July 5, 2024 10:33
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.

3 participants