-
Notifications
You must be signed in to change notification settings - Fork 78
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
feat: optimize trusted contracts retrieval #2430
Conversation
src/datasources/transaction-api/transaction-api.service.spec.ts
Outdated
Show resolved
Hide resolved
args.chainId, | ||
); | ||
return trustedContracts.results.some((contract) => | ||
isAddressEqual(contract.address, args.contractAddress), |
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.
Althought theoretically correct, I think we should still check the flag to be safe.
isAddressEqual(contract.address, args.contractAddress), | |
isAddressEqual(contract.address, args.contractAddress) && | |
contract.trustedForDelegateCall,``` |
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.
Agreed. Even if it's not needed theoretically, we can check the flag to avoid the case the filter is not working properly on the Transaction Service for some reason. Thanks. Changed in 7e3b393
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.
Should we want to expose pages of contracts later on, we are also covered, e.g. we call a hypothetical getContracts
method on the domain, passing the query there instead.
Summary
After the addition of a new filter that makes it possible to get the complete list of trusted for delegate call contracts in the Transaction Service API, the Client Gateway can take advantage of it by caching that list and comparing proposals and transaction mappings against the list, instead of checking each contract on demand.
This PR adds a new function to retrieve the list, and checks against that list instead of calling
ContractRepository.getContract
in bothTransactionDataMapper
andSafeRepository
.Changes
ContractRepository['isTrustedForDelegateCall']
function.FF_TRUSTED_FOR_DELEGATE_CALL_CONTRACTS_LIST
feature flag.