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: Reuse v6 starknet_getTransactionByHash handler for v7 #2486

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

hudem1
Copy link
Contributor

@hudem1 hudem1 commented Feb 14, 2025

rpc pkg cleanup according to issue #2437

  • for v6: Updated handler code to take into account pending block as well.

  • for v7: Reuse v6 handler for v7 as the logic is the same.

  • for v8: The logic is the same as v6/v7, but not exactly the returned Transaction type (more particularly, Resource type inside Transaction type). Therefore, we cannot refactor v8's types or logic

@hudem1 hudem1 mentioned this pull request Feb 14, 2025
23 tasks
Copy link
Contributor

@AnkushinDaniil AnkushinDaniil left a comment

Choose a reason for hiding this comment

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

We should also be handling the pending block in v6 in the same way. As far as I know, this difference happened because the old code for v6 was copied in #2419 . You can use the same code from v7 and continue refactoring.

Copy link

codecov bot commented Feb 15, 2025

Codecov Report

Attention: Patch coverage is 47.05882% with 9 lines in your changes missing coverage. Please review.

Project coverage is 73.54%. Comparing base (94071e4) to head (b1ccc4f).

Files with missing lines Patch % Lines
rpc/v6/transaction.go 43.75% 6 Missing and 3 partials ⚠️

❌ Your patch check has failed because the patch coverage (47.05%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2486      +/-   ##
==========================================
- Coverage   73.65%   73.54%   -0.12%     
==========================================
  Files         137      137              
  Lines       16659    16653       -6     
==========================================
- Hits        12271    12248      -23     
- Misses       3526     3541      +15     
- Partials      862      864       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hudem1
Copy link
Contributor Author

hudem1 commented Feb 17, 2025

We should also be handling the pending block in v6 in the same way. As far as I know, this difference happened because the old code for v6 was copied in #2419 . You can use the same code from v7 and continue refactoring.

Ah yes indeed, good catch! I updated v6 code, and I could then reuse v6 handler for v7.

@hudem1 hudem1 changed the title fix: Distinguish between ErrTxnHashNotFound and ErrInternal refactor: Reuse v6 starknet_getTransactionByHash handler for v7 Feb 20, 2025
@rianhughes rianhughes self-requested a review February 24, 2025 14:29
})
}

// Convert a v6 transaction object to a v7 transaction object
func AdaptV6TxToV7(t *testing.T, tx *rpcv6.Transaction) *rpc.Transaction {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can un-export this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor

@rianhughes rianhughes left a comment

Choose a reason for hiding this comment

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

Just need to un-export AdaptV6TxToV7 and then it looks good to me

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