Skip to content
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 53 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
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 Oct 4, 2021
6785baa
Merge branch 'release/v1.9.0b1'
onetechnical Nov 26, 2021
6bb2533
Merge branch 'release/v1.9.0b2'
egieseke Jan 3, 2022
1e4990f
Merge branch 'release/v1.9.0'
algobarb Jan 14, 2022
598a5b6
adding dryrun result object
barnjamin Jan 31, 2022
062ce94
fmt
barnjamin Jan 31, 2022
072e947
typo
barnjamin Jan 31, 2022
508025b
make space size configurable
barnjamin Jan 31, 2022
0d2f81c
zeph cr, thanks!
barnjamin Feb 4, 2022
4ce2a14
inline snake caser, fix str call
barnjamin Feb 4, 2022
8815d72
add check to make sure we have the attr we try to use
barnjamin Feb 4, 2022
0fa8d8e
first stab at test
barnjamin Feb 5, 2022
dd1b093
some changes to formatting to help with readability
barnjamin Feb 5, 2022
31d49f1
update
barnjamin Feb 5, 2022
d1083ce
use lsig disassembly
barnjamin Feb 5, 2022
c010e75
pad before line number, remove pipe
barnjamin Feb 5, 2022
efb281e
make the max line width work right
barnjamin Feb 5, 2022
33bb685
adding pc and headers
barnjamin Feb 6, 2022
5e2ef10
unpack into vars
barnjamin Feb 6, 2022
1e35187
take out empty string thing
barnjamin Feb 6, 2022
edd8328
fmt
barnjamin Feb 6, 2022
69a891a
adding methods to check if the DryrunTxnResult was successful
barnjamin Feb 8, 2022
357e1c6
take out case since its merged
barnjamin Feb 9, 2022
0e036ec
merge develop
barnjamin Feb 10, 2022
89182e8
changing padding math
barnjamin Feb 10, 2022
c01d415
adding dryrun trace for application test
barnjamin Feb 10, 2022
07eca10
fmt
barnjamin Feb 10, 2022
ede274a
added new given string, temporarily chekced out the branch with the t…
barnjamin Feb 11, 2022
5287739
fmt
barnjamin Feb 11, 2022
eaebf36
merge develop
barnjamin Feb 23, 2022
f661cca
revert sdk testing to master branch
barnjamin Feb 23, 2022
fa9211a
almost
barnjamin Mar 22, 2022
83dca7e
passing tests with new formatting
barnjamin Mar 22, 2022
2972067
dont use type, its incorrect in some cases
barnjamin Mar 22, 2022
3dfe4c4
trigger build
barnjamin Mar 22, 2022
48ffbda
alias package name
barnjamin Mar 22, 2022
a81d5b8
Update algosdk/dryrun_results.py
barnjamin Mar 23, 2022
8190e2b
Update algosdk/dryrun_results.py
barnjamin Mar 23, 2022
0d2620c
Update algosdk/dryrun_results.py
barnjamin Mar 23, 2022
e9022c1
Update algosdk/dryrun_results.py
barnjamin Mar 23, 2022
bd2a723
Update algosdk/dryrun_results.py
barnjamin Mar 23, 2022
ed3605a
Update test/steps/v2_steps.py
barnjamin Mar 23, 2022
0185f87
Update Makefile
barnjamin Mar 23, 2022
5181e2d
Update algosdk/dryrun_results.py
barnjamin Mar 23, 2022
8b54442
Update algosdk/dryrun_results.py
barnjamin Mar 23, 2022
78aa402
fix comma, fmt
barnjamin Mar 23, 2022
8ded7ec
adding tabulate as requirement
barnjamin Mar 23, 2022
371875f
remove tabulate dep
barnjamin Mar 23, 2022
846e7e9
better name of max width config param
barnjamin Mar 25, 2022
5efa115
Merge branch 'develop' into dryrun-response
barnjamin Mar 31, 2022
b7fb15c
merge fmt
barnjamin Mar 31, 2022
d336364
merge fmt
barnjamin Mar 31, 2022
8e562b9
Merge branch 'dryrun-response' of github.com:algorand/py-algorand-sdk…
barnjamin Mar 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions algosdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
from . import util
from . import wallet
from . import wordlist
from . import dryrun_results
Copy link
Contributor

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?


name = "algosdk"
85 changes: 85 additions & 0 deletions algosdk/dryrun_results.py
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