-
Notifications
You must be signed in to change notification settings - Fork 6
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
Update tezos-utils #351
base: master
Are you sure you want to change the base?
Update tezos-utils #351
Conversation
08c0f42
to
80940ad
Compare
80940ad
to
f711cba
Compare
@@ -23,6 +23,11 @@ On Ubuntu Linux derivatives, the system dependencies include: | |||
For other distributions, you will need to find the appropriate packages. | |||
|
|||
The Python dependencies are all available available via PyPI packages and can be installed via `pip`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Python dependencies are all available available via PyPI packages and can be installed via `pip`: | |
The Python dependencies are all available via PyPI packages and can be installed via `pip`: |
@@ -215,9 +234,9 @@ def is_micheline(mcode): | |||
else: | |||
return False | |||
|
|||
def micheline_to_dot(mcode, skipRevert = False): | |||
def micheline_to_dot(mcode, skipRevert = False, type_length=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def micheline_to_dot(mcode, skipRevert = False, type_length=None): | |
def micheline_to_dot(mcode, skipRevert=False, type_length=None): |
# check that section names are correct | ||
sections = dict() | ||
for prim in mcode: | ||
name,val = prim['prim'], prim['args'] | ||
# skip view functions | ||
if name == 'view': continue | ||
# if we encounter an unexpected name, stop | ||
if name not in ['parameter', 'storage', 'code'] or name in sections.keys(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if name not in ['parameter', 'storage', 'code'] or name in sections.keys(): | |
if name not in {'parameter', 'storage', 'code'} or name in sections: |
def truncate(s, l): | ||
if len(s) <= l: return s | ||
else: return s[:l] + "..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def truncate(s, l): | |
if len(s) <= l: return s | |
else: return s[:l] + "..." | |
def truncate(s, length): | |
if len(s) <= length: | |
return s | |
else: | |
return s[:length] + "..." |
class BlockType(Enum): | ||
STD = 1 | ||
SELFBREAK = 2 | ||
BREAK = 3 | ||
JOIN = 4 | ||
|
||
class Block: | ||
def __init__(self, prim_seq, depth=0): | ||
def __init__(self, prim_seq, depth=0, type_length=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider making the optional arguments keyword-only:
def __init__(self, prim_seq, depth=0, type_length=None): | |
def __init__(self, prim_seq, *, depth=0, type_length=None): |
@@ -135,7 +140,7 @@ class Block: | |||
|
|||
elif name in HIDDEN_BLOCK_INSTRS: | |||
self.append(prim) | |||
hidden_block = Block({'prim' : '...' }, depth=self.depth) | |||
hidden_block = Block({'prim' : '...' }, depth=self.depth, type_length=self.type_length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hidden_block = Block({'prim' : '...' }, depth=self.depth, type_length=self.type_length) | |
hidden_block = Block({'prim' : '...'}, depth=self.depth, type_length=self.type_length) |
@@ -200,6 +218,7 @@ def get_code_section(mcode): | |||
code = sections['code'][0] | |||
logging.debug(f"Get code section: {code}") | |||
return code | |||
logging.debug("The code was not a JSON-encoded Micheline representation of a contract; fallback") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logging.debug("The code was not a JSON-encoded Micheline representation of a contract; fallback") | |
logging.debug("The code is not a JSON-encoded Micheline representation of a contract; fallback") |
bafe90a
to
fff3cfc
Compare
This update solves three problems with tezos-utils which makes it more usable for more kinds of programs:
@tothtamas28 I have currently assigned this to you since you know python well and are working on a Michelson-related audit with me. If you aren't able to review this or if you have questions, let me know.