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: centralise delegate call verification in verifier #2427

Merged
merged 5 commits into from
Mar 7, 2025

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Mar 6, 2025

Summary

We refine confirmations and hashes of transaction proposal, confirmation and that from our API. We also block delegate calls by default or based on their trust. This was added as part of verification but it is not within the verifier.

This moves the relevant logic into the verifier, thereby centralising all logic in one place.

Changes

  • Move delegate call verification into verifier
  • Add/update test coverage appropriately

@iamacook iamacook self-assigned this Mar 6, 2025
@iamacook iamacook requested a review from a team as a code owner March 6, 2025 08:30
@PooyaRaki PooyaRaki self-requested a review March 6, 2025 16:27
const getMultisigTransactionUrl = `${chain.transactionService}/api/v1/multisig-transactions/${proposeTransactionDto.safeTxHash}/`;
const getContractUrlPattern = `${chain.transactionService}/api/v1/contracts/`;
networkService.get.mockImplementation(({ url }) => {
if (url === getChainUrl) {
return Promise.resolve({ data: rawify(chain), status: 200 });
}
if (url === getSafeUrl) {
Copy link
Contributor

@PooyaRaki PooyaRaki Mar 6, 2025

Choose a reason for hiding this comment

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

Nit: We could change this if statement and the one after to else if for better readability/performance.

Copy link
Member Author

Choose a reason for hiding this comment

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

As other mocks here use early returns, I suggest we sooner unify the implementation across the entire project in a follow up. There are places that use switch, if/else if and early returns. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

In my opinion performance is not a problem here, as each if statement makes the mock to return early. Anyway, I agree we should unify these mock routers across the entire project. For the sake of readability and considering they use to have many branches, I'd go with switch statements, but I also think this would be a low value/priority refactor, wdyt?

safe,
});
if (
!transaction.confirmations ||
Copy link
Contributor

Choose a reason for hiding this comment

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

We are building with confirmation and the minLength of the confirmation faker is 1 which means there must be at least 1 confirmation. Why do we need to check here whether a confirmation exist or not?

Copy link
Member Author

@iamacook iamacook Mar 6, 2025

Choose a reason for hiding this comment

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

This is to prevent TypeScript errors. I'm currently working on increased test coverage where this is entriely removed though.

Edit: I've opened the PR removing these across all suites.

safe,
});
if (
!transaction.confirmations ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as before, I won’t mark any further occurrences of such checks in the code.

@hectorgomezv
Copy link
Member

LGTM, but the PR has some conflicts with the main branch that would possibly require a refactor and the test adjustment 🤔

@iamacook
Copy link
Member Author

iamacook commented Mar 7, 2025

LGTM, but the PR has some conflicts with the main branch that would possibly require a refactor and the test adjustment 🤔

I'll hold off on merging this until #2431 is finished as there are tests marked as todo there that require changes here.

@iamacook
Copy link
Member Author

iamacook commented Mar 7, 2025

LGTM, but the PR has some conflicts with the main branch that would possibly require a refactor and the test adjustment 🤔

This has now been addressed in accordance with my previous comment.

@iamacook iamacook merged commit 2e660bf into main Mar 7, 2025
16 checks passed
@iamacook iamacook deleted the refactor/delegate-call-verification branch March 7, 2025 15:20
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