kevinheavey / anchorpy

The Python Anchor client.
https://kevinheavey.github.io/anchorpy/
MIT License
221 stars 59 forks source link

Fix logical grouping issue in filters_to_use assignment #145

Closed bonipart closed 2 months ago

bonipart commented 4 months ago

Description

This pull request addresses an issue with the logical grouping in the filters_to_use assignment. The current logic does not properly handle the case where filters is not None, leading to potential runtime errors. By adding parentheses, we ensure the correct evaluation of the condition.

Current Code

if filters is None then [base_memcmp_opt] + [] else filters

Issue As is, if filters is not None, then the account discriminator memcmp is dropped from the list of filters to use.

Proposed Fix

if filters is None then [base_memcmp_opt] + ([]) else [base_memcmp_opt] + filters

Solution Adding parentheses ensures that the conditional expression is evaluated correctly.