Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Fix prompt list parsing #956

Merged
merged 1 commit into from
Jun 5, 2019
Merged

Fix prompt list parsing #956

merged 1 commit into from
Jun 5, 2019

Conversation

ixje
Copy link
Member

@ixje ixje commented Jun 5, 2019

What current issue(s) does this address, or what feature is it adding?
when running sc invocations via e.g. the build_run command we parse the smart contract parameters from the console. Specifically list arguments were trouble some. Take

sc build_run sc.py False False False 0210 01 1 ['aa']

The old logic would parse ['aa'] into a BigInteger because

item = PromptUtils.parse_param(p, wallet, parse_addr=no_parse_addresses)

would turn ['aa'] into [b'6161'] because it uses recursion internally.
Then when we continue we parse the items again in which

if type(item) is list:
item.reverse()
listlength = len(item)
for listitem in item:
subitem = PromptUtils.parse_param(listitem, wallet, parse_addr=no_parse_addresses)

which now tries to parse [b'6161'] and that will happily be picked up at

try:
val = int(p)
out = BigInteger(val)
return out

and now we have a BigInteger we do not want.

How did you solve this problem?
the quick fix was to remove the recursion from list parsing. The downside this limits how many lists can be nested. The upside is it is fast. We should redo the whole prompt parsing and script builder for neo-python 3.0

How did you make sure your solution works?
manual testing

Are there any special changes in the code that we should be aware of?

Please check the following, if applicable:

  • Did you add any tests?
  • Did you run make lint?
  • Did you run make test?
  • Are you making a PR to a feature branch or development rather than master?
  • Did you add an entry to CHANGELOG.rst? (if not, please do)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 85.095% when pulling e0a276b on ixje:fix-prompt-list into d2362d4 on CityOfZion:development.

@ixje ixje merged commit 9d3b4a0 into CityOfZion:development Jun 5, 2019
@ixje ixje deleted the fix-prompt-list branch June 5, 2019 12:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants