-
Notifications
You must be signed in to change notification settings - Fork 97
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
feat: add submit and wait for transaction submission #528
Conversation
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 agree with this commit, refining the auto fill and sign step into submit_and_wait.
payment_transaction, WALLET, client | ||
) | ||
await accept_ledger_async(delay=1) | ||
payment_transaction_signed_blob = encode(payment_transaction_signed.to_xrpl()) |
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.
This is perhaps a separate ticket, but encode(tx.to_xrpl())
feels like a good helper function on the Transaction
object (something like tx.blob()
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 just added the helper function for this ticket.
if transaction.is_signed(): | ||
return transaction | ||
|
||
if not wallet: | ||
raise XRPLException( | ||
"Wallet must be provided when submitting an unsigned transaction" | ||
) |
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: I'd recommend including the else even though it's not strictly necessary because the logic relies on that return to make sense. Each time I've reviewed the PR it's taken me a minute or two to remember why it's guaranteed that at this point the transaction MUST require a signature, and I think adding this else would clarify that.
if transaction.is_signed(): | |
return transaction | |
if not wallet: | |
raise XRPLException( | |
"Wallet must be provided when submitting an unsigned transaction" | |
) | |
if transaction.is_signed(): | |
return transaction | |
else: | |
if not wallet: | |
raise XRPLException( | |
"Wallet must be provided when submitting an unsigned transaction" | |
) |
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 think adding a comment saying "Attempts to validate fee, autofill, and sign the transaction when unsigned" would suffice. The return
statement already tells that we only proceed to the remaining steps for unsigned transaction and I would prefer not to have many conditional layers in the code. Other functions also add comments when if/else clarification is needed.
signed_transaction = await _get_signed_tx( | ||
transaction, client, wallet, check_fee, autofill | ||
) | ||
return await send_reliable_submission( |
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.
Note for later: If we make send_reliable_submission
deprecated, we should move that logic into this function, or a helper.
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.
Agree, we can mention that in the deprecate ticket.
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 - couple nitpicks but logic looks solid as far as I can tell :)
High Level Overview of Change
Currently, user has to call 2 functions (
autofill_and_sign
andsend_reliable_submission
) in order to sign, autofill, submit and verifies that the transaction has been included in a validated ledger. This PR would simplify the workflow to a single call (submit_and_wait
) similar to xrpl.js (the old workflow would still work so it is not a breaking change). Tests and snippets are also fixed to use the new method.Couple of other improvements:
fail_hard
is_signed
checks for multi-sign transactionType of Change