-
Notifications
You must be signed in to change notification settings - Fork 72
adding createDryrun method #284
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
Conversation
winder
left a comment
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.
Looks like a helpful utility. I haven't used the DryRun feature, so I'll let @ahangsu respond to the correctness of how that is being constructed.
For my part, just some small cleanup requests.
|
While testing this with tealdbg && msgpack encoded DryrunRequest, I found that tealdbg is expecting the programs to be a byte array but I'm not sure I can force the output of Guessing here without digging too deep into the encoder/decoder stuff but I think this decorator is used to flag the property we use when decoding and when its called, it automatically b64 encodes the underlying bytes: |
|
@barnjamin I think your observation is correct, namely it automatically encodes the raw bytes in b64 format. |
In order for it to be read by tealdbg when passing a msgp formated dryrun request, it must be the raw bytes. The decoder logic of tealdbg tries to interpret the b64 string as the bytes of an assembled program. We need to either add something to this SDK to allow it or tweak the decoder in tealdbg to figure out it should try to b64 decode the bytes. Or maybe there is another option? |
ahangsu
left a comment
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.
LGTM
| public void approvalProgram(String base64Encoded) { | ||
| this.approvalProgram = Encoder.decodeFromBase64(base64Encoded); | ||
| } | ||
| @JsonProperty("approval-program") |
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 model code seems to be generated from https://github.com/algorand/generator/blob/master/src/main/java/com/algorand/sdkutils/listeners/JavaGenerator.java#L970-L986, I haven't checked whether we want to remove this annotation, but apparently there are two options:
- open a PR for
generatorin favor of this PR - if the annotation does not hurt the behavior, then revert it back
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.
I'll open one for generator, removing this annotation allows us to pass the bytes for the approval/clear program as bytes when we msgpack encode them rather than getting the b64 encoded version.
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.
Ping me once this is opened, and hopefully nothing's broken 😅
| import java.math.BigInteger; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Arrays; |
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: unnecessary import
| assets.addAll(tx.foreignAssets); | ||
| } | ||
|
|
||
| if (tx.accounts.size() > 0) { |
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.
I saw in implementation of createDryrun for other SDK that you add sender to accts, wondering do we also want to do this in Java, or sender is included in tx.accounts so we can omit this.
|
|
||
| for (String acct : accts) { | ||
| Response<Account> ar = client.AccountInformation(new Address(acct)).execute(); | ||
| if(ar.isSuccessful()){ |
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.
one thing to make sure: for other SDK implementation, there's a decodeProgram involved here, this is not needed in Java case, right?
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 I can edit the generator to allow raw bytes when we msgpack encode, this should work without decoding since the java decoder handles it for us.
Co-authored-by: Hang Su <[email protected]>
Untested, will work on that next but please take a look and make sure it's reasonable.
Seems like too many args for the method
Had to set the logic.StateSchema bytes/ints to public since that is what is used in Transaction class (tho we also have it in models?)