Skip to content

Commit

Permalink
Fix empty array behavior and release a new patch version (v0.1.4) (0x…
Browse files Browse the repository at this point in the history
…SpaceShard#7)

* Fix behavior for passing empty arrays

* Bump version to v0.1.4
  • Loading branch information
FabijanC committed Nov 4, 2021
1 parent 836be67 commit b462a7f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "starknet_devnet"
version = "0.1.3"
version = "0.1.4"
description = "A local testnet for Starknet"
authors = ["FabijanC <[email protected]>"]
license = "ISC"
Expand Down
2 changes: 1 addition & 1 deletion starknet_devnet/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.3"
__version__ = "0.1.4"
12 changes: 9 additions & 3 deletions starknet_devnet/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ def adapt_calldata(calldata, expected_inputs, types):
input_name = input_entry["name"]
input_type = input_entry["type"]
if calldata_i >= len(calldata):
abort(Response(f"Too few function arguments provided: {len(calldata)}.", 400))
if input_type == "felt*" and last_name == f"{input_name}_len" and last_value == 0:
# This means that an empty array is provided.
# Last element was array length (0), it's replaced with the array itself
adapted_calldata[-1] = []
continue
else:
abort(Response(f"Too few function arguments provided: {len(calldata)}.", 400))
input_value = calldata[calldata_i]

if input_type == "felt*":
Expand All @@ -109,8 +115,8 @@ def adapt_calldata(calldata, expected_inputs, types):
if len(arr) < arr_length:
abort(Response(f"Too few function arguments provided: {len(calldata)}.", 400))

adapted_calldata.pop() # last element was length, it's not needed
adapted_calldata.append(arr)
# last element was array length, it's replaced with the array itself
adapted_calldata[-1] = arr
calldata_i += arr_length

elif input_type == "felt":
Expand Down

0 comments on commit b462a7f

Please sign in to comment.