-
Notifications
You must be signed in to change notification settings - Fork 143
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
Dryrun response #283
Merged
Merged
Dryrun response #283
Changes from 8 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
7b62bab
Merge branch 'release/v1.8.0'
bricerisingalgorand 6785baa
Merge branch 'release/v1.9.0b1'
onetechnical 6bb2533
Merge branch 'release/v1.9.0b2'
egieseke 1e4990f
Merge branch 'release/v1.9.0'
algobarb 598a5b6
adding dryrun result object
barnjamin 062ce94
fmt
barnjamin 072e947
typo
barnjamin 508025b
make space size configurable
barnjamin 0d2f81c
zeph cr, thanks!
barnjamin 4ce2a14
inline snake caser, fix str call
barnjamin 8815d72
add check to make sure we have the attr we try to use
barnjamin 0fa8d8e
first stab at test
barnjamin dd1b093
some changes to formatting to help with readability
barnjamin 31d49f1
update
barnjamin d1083ce
use lsig disassembly
barnjamin c010e75
pad before line number, remove pipe
barnjamin efb281e
make the max line width work right
barnjamin 33bb685
adding pc and headers
barnjamin 5e2ef10
unpack into vars
barnjamin 1e35187
take out empty string thing
barnjamin edd8328
fmt
barnjamin 69a891a
adding methods to check if the DryrunTxnResult was successful
barnjamin 357e1c6
take out case since its merged
barnjamin 0e036ec
merge develop
barnjamin 89182e8
changing padding math
barnjamin c01d415
adding dryrun trace for application test
barnjamin 07eca10
fmt
barnjamin ede274a
added new given string, temporarily chekced out the branch with the t…
barnjamin 5287739
fmt
barnjamin eaebf36
merge develop
barnjamin f661cca
revert sdk testing to master branch
barnjamin fa9211a
almost
barnjamin 83dca7e
passing tests with new formatting
barnjamin 2972067
dont use type, its incorrect in some cases
barnjamin 3dfe4c4
trigger build
barnjamin 48ffbda
alias package name
barnjamin a81d5b8
Update algosdk/dryrun_results.py
barnjamin 8190e2b
Update algosdk/dryrun_results.py
barnjamin 0d2620c
Update algosdk/dryrun_results.py
barnjamin e9022c1
Update algosdk/dryrun_results.py
barnjamin bd2a723
Update algosdk/dryrun_results.py
barnjamin ed3605a
Update test/steps/v2_steps.py
barnjamin 0185f87
Update Makefile
barnjamin 5181e2d
Update algosdk/dryrun_results.py
barnjamin 8b54442
Update algosdk/dryrun_results.py
barnjamin 78aa402
fix comma, fmt
barnjamin 8ded7ec
adding tabulate as requirement
barnjamin 371875f
remove tabulate dep
barnjamin 846e7e9
better name of max width config param
barnjamin 5efa115
Merge branch 'develop' into dryrun-response
barnjamin b7fb15c
merge fmt
barnjamin d336364
merge fmt
barnjamin 8e562b9
Merge branch 'dryrun-response' of github.com:algorand/py-algorand-sdk…
barnjamin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,6 @@ | |
from . import util | ||
from . import wallet | ||
from . import wordlist | ||
from . import dryrun_results | ||
|
||
name = "algosdk" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from typing import List | ||
|
||
|
||
class DryrunResponse: | ||
def __init__(self, drrjson: dict): | ||
# These are all required fields | ||
barnjamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.error = drrjson["error"] | ||
self.protocol = drrjson["protocol-version"] | ||
self.txns = [DryrunTransactionResult(txn) for txn in drrjson["txns"]] | ||
|
||
|
||
class DryrunTransactionResult: | ||
def __init__(self, dr): | ||
# Only required field | ||
self.disassembly = dr["disassembly"] | ||
barnjamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# These are all optional | ||
barnjamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if "app-call-messages" in dr: | ||
self.app_call_messages = dr["app-call-messages"] | ||
if "app-call-trace" in dr: | ||
self.app_call_trace = DryrunTrace(dr["app-call-trace"]) | ||
if "local-deltas" in dr: | ||
self.local_deltas = dr["local-deltas"] | ||
if "global-delta" in dr: | ||
self.global_delta = dr["global-delta"] | ||
if "cost" in dr: | ||
self.app_call_cost = dr["cost"] | ||
if "logic-sig-messages" in dr: | ||
self.logic_sig_messages = dr["logic-sig-messages"] | ||
if "logic-sig-trace" in dr: | ||
self.logic_sig_trace = DryrunTrace(dr["logic-sig-trace"]) | ||
if "logs" in dr: | ||
self.logs = dr["logs"] | ||
|
||
def app_trace(self, trace_spaces: int = 16): | ||
barnjamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
lines = [] | ||
for line in self.app_call_trace.get_trace(): | ||
src_line = self.disassembly[line[0] - 1] | ||
lines.append( | ||
"{}{}\t{}".format( | ||
src_line, " " * (trace_spaces - len(src_line)), line[1] | ||
) | ||
) | ||
return "\n".join(lines) | ||
|
||
def lsig_trace(self, trace_spaces: int = 16): | ||
lines = [] | ||
for line in self.logic_sig_trace.get_trace(): | ||
src_line = self.disassembly[line[0] - 1] | ||
lines.append( | ||
"{}{}\t{}".format( | ||
src_line, " " * (trace_spaces - len(src_line)), line[1] | ||
) | ||
) | ||
return "\n".join(lines) | ||
|
||
|
||
class DryrunTrace: | ||
def __init__(self, trace): | ||
self.trace = [DryrunTraceLine(line) for line in trace] | ||
|
||
def get_trace(self) -> List[str]: | ||
return [line.trace_line() for line in self.trace] | ||
|
||
|
||
class DryrunTraceLine: | ||
def __init__(self, tl): | ||
self.line = tl["line"] | ||
self.pc = tl["pc"] | ||
self.stack = [DryrunStackValue(sv) for sv in tl["stack"]] | ||
|
||
def trace_line(self): | ||
return (self.line, [sv.__str__() for sv in self.stack]) | ||
barnjamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
class DryrunStackValue: | ||
def __init__(self, v): | ||
self.type = v["type"] | ||
self.bytes = v["bytes"] | ||
self.int = v["uint"] | ||
|
||
def __str__(self): | ||
if self.type == 1: | ||
return self.bytes | ||
return self.int | ||
tzaffi marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: can we keep this in alphabetical order?