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

Check namespace decorators for interfaces #85

Merged
merged 2 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion amarna/rules/gatherer_rules/DeclaredFunctionsGatherer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ def code_element_function(self, tree: Tree) -> None:

# find if the current tree is part of a @contract_interface
# to ignore if unused in that case
for struct in self.original_tree.find_data("code_element_struct"):
namespace_struct = list(self.original_tree.find_data("code_element_namespace")) + list(
self.original_tree.find_data("code_element_struct")
)

for struct in namespace_struct:
for child in struct.find_data("decorator_list"):
for decorator in child.find_data("identifier_def"):
if decorator.children[0] in ["contract_interface"]:
Expand Down
5 changes: 4 additions & 1 deletion amarna/rules/local_rules/UnusedArgumentRule.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def code_element_function(self, tree: Tree) -> None:

# find if the current tree is part of a @contract_interface
# to ignore unused arguments in that case
for struct in self.original_tree.find_data("code_element_struct"):
structures_namespaces = list(self.original_tree.find_data("code_element_struct")) + list(
self.original_tree.find_data("code_element_namespace")
)
for struct in structures_namespaces:
for child in struct.find_data("decorator_list"):
for decorator in child.find_data("identifier_def"):
if decorator.children[0] == "contract_interface":
Expand Down
Empty file.
8 changes: 8 additions & 0 deletions tests/interface_namespace.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@contract_interface
namespace IBalanceContract {
func increase_balance(amount: felt) {
}

func get_balance() -> (res: felt) {
}
}