Closed ckeshava closed 5 months ago
@mvadari I felt it is more appropriate to make the deliver max
changes in the from_dict
overload. The autofill
and other utility functions work with a Transaction
object. Since DeliverMax
is not a part of protocol, it is not a recognized field in the Payment request.
@mvadari I felt it is more appropriate to make the
deliver max
changes in thefrom_dict
overload. Theautofill
and other utility functions work with aTransaction
object. SinceDeliverMax
is not a part of protocol, it is not a recognized field in the Payment request.
This won't work in a lot of cases (including internal uses of from_dict
). A lot of people use Transaction.from_dict
instead of the specific transaction type.
@mvadari I agree that there are limitations in my current design.
If I were to make this change in autofill
method, how can I go about it? autofill
takes in a Transaction
object and I cannot address any field titled deliver_max
because its not a part of the Payment
transaction model here: https://github.com/XRPLF/xrpl-py/blob/2e1435c37c3f2e1a3b41ac21f02f1a692258cee0/xrpl/models/transactions/payment.py#L62
I'd like to test inputs such as
transaction_dict = {
"account": _ACCOUNT,
"fee": _FEE,
"sequence": _SEQUENCE,
"deliver_max": _ISSUED_CURRENCY_AMOUNT,
"send_max": _XRP_AMOUNT,
"destination": _DESTINATION,
}
# convert the above JSON into a Payment object, without throwing any errors.
We are passing along Transaction
object to methods like autofill
, autofill_and_sign
, sign_and_submit
etc. Where can I get the opportunity to modify the JSON version of a Transaction?
@mvadari I agree that there are limitations in my current design.
If I were to make this change in
autofill
method, how can I go about it?autofill
takes in aTransaction
object and I cannot address any field titleddeliver_max
because its not a part of thePayment
transaction model here:
That's a fair point. In that case, perhaps from_xrpl
is the right place to have this change - but it should be in Transaction.from_xrpl
, not Payment.from_xrpl
.
I have moved the changes to Transaction.from_dict
from the Payment
class. from_xrpl
invokes from_dict
in the course of its actions. I felt the former is most appropriate to accomodate these changes.
I felt the former is most appropriate to accomodate these changes.
I disagree, because it's only ever going to be necessary when pulling from XRPL data, not from any other dictionary.
I've addressed your comments @mvadari 👍
@mvadari does this design look okay? Can I do the same for JS too?
@khancode can you please take a look at this PR? does this design look alright?
@justinr1234 I need some clarification on your prior comments. Let me know if I need to make any more changes.
thnks
the snippets tests are failing due to an unfunded account (We believe it lacks "USD" tokens). It will need to be addressed in a separate PR
If there are no objections, I'd like to merge this PR.
Thank you all for your feedback
High Level Overview of Change
Add support for
DeliverMax
field in the Payment transactions. The following links will give you more context on theDeliverMax
field: https://github.com/XRPLF/rippled/pull/4733, https://github.com/XRPLF/rippled/issues/3484Context of Change
Payment
transactions accept a new fieldDeliverMax
, which serves as an alias to theAmount
field. This is intended to prevent misinterpretation of the response ofPayment
transactions and the consequent loss of funds.Type of Change
Did you update CHANGELOG.md?
Test Plan
Additional unit tests have been added to validate the usage of
Payment
transactions.