Skip to content

Commit

Permalink
fix: duplicate structs bug (#114)
Browse files Browse the repository at this point in the history
* fix: duplicate structs bug

* chore: fixing audit warning
  • Loading branch information
aorumbayev authored Jun 12, 2024
1 parent 2b0863e commit 7a282c8
Show file tree
Hide file tree
Showing 7 changed files with 684 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def cwd(path: Path) -> Generator[None, None, None]:
def main(action: str) -> None:
match action:
case "build":
example_dirs = filter(lambda file: file.is_dir() and "__" not in file.name, root_path.glob("*"))
example_dirs = filter(lambda file: file.is_dir() and "__" not in file.name and file.name != "duplicate_structs", root_path.glob("*"))
for example in example_dirs:
logger.info(f"Building example {example.name}")
with cwd(root_path):
Expand Down
92 changes: 92 additions & 0 deletions examples/duplicate_structs/application.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"hints": {
"method_a_that_uses_struct()(uint64,uint64)": {
"call_config": {
"no_op": "CALL"
},
"structs": {
"output": {
"name": "SomeStruct",
"elements": [
[
"a",
"uint64"
],
[
"b",
"uint64"
]
]
}
}
},
"method_b_that_uses_same_struct()(uint64,uint64)": {
"call_config": {
"no_op": "CALL"
},
"structs": {
"output": {
"name": "SomeStruct",
"elements": [
[
"a",
"uint64"
],
[
"b",
"uint64"
]
]
}
}
}
},
"source": {
"approval": "I3ByYWdtYSB2ZXJzaW9uIDEwCgpzbWFydF9jb250cmFjdHMuZGVsZWdhdG9yX2NvbnRyYWN0LmNvbnRyYWN0LkR1cGxpY2F0ZVN0cnVjdHNDb250cmFjdC5hcHByb3ZhbF9wcm9ncmFtOgogICAgLy8gY29udHJhY3QucHk6MTIKICAgIC8vIGNsYXNzIER1cGxpY2F0ZVN0cnVjdHNDb250cmFjdChBUkM0Q29udHJhY3QpOgogICAgdHhuIE51bUFwcEFyZ3MKICAgIGJ6IG1haW5fYmFyZV9yb3V0aW5nQDYKICAgIG1ldGhvZCAibWV0aG9kX2Ff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X2JfdGhhdF91c2VzX3NhbWVfc3RydWN0OgogICAgLy8gY29udHJhY3QucHk6MjYtMjcKICAgIC8vIEBhcmM0LmFiaW1ldGhvZCgpCiAgICAvLyBkZWYgbWV0aG9kX2JfdGhhdF91c2VzX3NhbWVfc3RydWN0KHNlbGYpIC0+IFNvbWVTdHJ1Y3Q6CiAgICBwcm90byAwIDEKICAgIC8vIGNvbnRyYWN0LnB5OjI4LTMxCiAgICAvLyByZXR1cm4gU29tZVN0cnVjdCgKICAgIC8vICAgICBhcmM0LlVJbnQ2NCgzKSwKICAgIC8vICAgICBhcmM0LlVJbnQ2NCg0KSwKICAgIC8vICkKICAgIGJ5dGUgMHgwMDAwMDAwMDAwMDAwMDAzMDAwMDAwMDAwMDAwMDAwNAogICAgcmV0c3ViCg==",
"clear": "I3ByYWdtYSB2ZXJzaW9uIDEwCgpzbWFydF9jb250cmFjdHMuZGVsZWdhdG9yX2NvbnRyYWN0LmNvbnRyYWN0LkR1cGxpY2F0ZVN0cnVjdHNDb250cmFjdC5jbGVhcl9zdGF0ZV9wcm9ncmFtOgogICAgLy8gY29udHJhY3QucHk6MTIKICAgIC8vIGNsYXNzIER1cGxpY2F0ZVN0cnVjdHNDb250cmFjdChBUkM0Q29udHJhY3QpOgogICAgaW50IDEKICAgIHJldHVybgo="
},
"state": {
"global": {
"num_byte_slices": 0,
"num_uints": 0
},
"local": {
"num_byte_slices": 0,
"num_uints": 0
}
},
"schema": {
"global": {
"declared": {},
"reserved": {}
},
"local": {
"declared": {},
"reserved": {}
}
},
"contract": {
"name": "DuplicateStructsContract",
"desc": "\n This contract is to be used as a test artifact to verify behavior around struct generation to ensure that \n the scenarios similar to whats outlined in this contract can not result in a typed client with duplicate struct \n definitions.\n ",
"methods": [
{
"name": "method_a_that_uses_struct",
"args": [],
"returns": {
"type": "(uint64,uint64)"
}
},
{
"name": "method_b_that_uses_same_struct",
"args": [],
"returns": {
"type": "(uint64,uint64)"
}
}
],
"networks": {}
},
"bare_call_config": {
"no_op": "CREATE"
}
}
Loading

0 comments on commit 7a282c8

Please sign in to comment.