Skip to content

Commit 0683f70

Browse files
committed
Fix error when parsing ABI call string arguments
1 parent 823b6ad commit 0683f70

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/simple_safe/abi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ def parse_abi_type(abi_type: str, val_str: str) -> Any:
112112
f"Boolean value must be 'true' or 'false' (not '{val_str}'"
113113
)
114114
return True if val_str == "true" else False
115-
elif abi_type.startswith("bytes") or abi_type in ("string", "function"):
115+
elif abi_type.startswith("bytes") or abi_type == "function":
116116
return HexBytes(val_str)
117+
elif abi_type == "string":
118+
return val_str
117119
elif abi_type == "tuple" or is_array_type(abi_type):
118120
val: list[Any] | dict[str, Any] = json.loads(val_str)
119121
if isinstance(val, list):

tests/test_abi.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ def test_parse_abi_type_bool():
161161
assert not parse_abi_type("bool", "false")
162162

163163

164+
def test_parse_abi_type_string():
165+
for valid_string in ["", "£", "⚠️", "👾 κόσμε 👾"]:
166+
assert parse_abi_type("string", valid_string) == valid_string
167+
168+
164169
def test_parse_abi_type_invalid_value():
165170
for basic_typ in ("int", "address", "bool", "bytes", "tuple"):
166171
for typ in (basic_typ, basic_typ + "[]"):

0 commit comments

Comments
 (0)