-
Notifications
You must be signed in to change notification settings - Fork 61
#576: Add support for AMMClawback #601
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
xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmClawbackFlags.java
Show resolved
Hide resolved
xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/environment/RippledContainer.java
Outdated
Show resolved
Hide resolved
xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmClawback.java
Outdated
Show resolved
Hide resolved
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.
For the three integration tests that I wrote, i would say around 90% of the code is the exact same:
- create trust lines
- send payments
- create amm
- deposit in amm
- clawback assets in AMM
the only difference really is in the flags and/or the inclusion of amount
in the final AMMClawback
tx.
should I break down that that 90% into something more reusable?
e.g.
- create the following functions:
createTrustline
createPayment
depositToAmm
- etc..
- adjust the
createAmm
function so that it can be reused
i had started going down this path (like what I did when changing enableRippling
to enableFlag
), but wanted to get an opinion first.
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 a good callout -- there does appear to be a lot of duplicated code. I'd be up for experimenting with how to make this test more concise with less duplicated code. Couple of thoughts:
- We try to define commonly-used functions in
AbstractIT.java
, so take a look there to see if anything fits your needs. Basically, if there's a function that other ITs could use, then it probably makes sense to define those inAbstractIT
. However, we simultaneously need to be judicious about this because sometimes it's clearer to simply create aPayment
transaction using the builder (as your test does now) than to simply define a helper function that does the same thing (i.e., this merely shifts inputs around). - Instead of things like
createPayment
, I would look for higher-order functions to abstract away. E.g.,createAmm
seems like a good candidate, depending on the differences in usage in test cases. If you want to speak face-to-face sometime and experiment here, I'd be up for doing that. I think our ITs could use some refactoring/love anyway, and this might be a good use-case to experiment a bit with. - Despite 1 and 2 right above, we probably want to experiment with refactoring this IT in a separate PR, just so we can get this feature merged. What's in here already is probably good enough for this PR.
xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmClawback.java
Show resolved
Hide resolved
xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java
Outdated
Show resolved
Hide resolved
xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java
Outdated
Show resolved
Hide resolved
xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java
Outdated
Show resolved
Hide resolved
xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java
Outdated
Show resolved
Hide resolved
xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmClawbackTest.java
Show resolved
Hide resolved
xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmClawbackTest.java
Outdated
Show resolved
Hide resolved
xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmClawbackTest.java
Outdated
Show resolved
Hide resolved
xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmClawbackTest.java
Outdated
Show resolved
Hide resolved
xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/AmmClawbackTest.java
Show resolved
Hide resolved
xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/flags/AmmClawbackFlags.java
Show resolved
Hide resolved
xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmClawback.java
Outdated
Show resolved
Hide resolved
xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java
Show resolved
Hide resolved
xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java
Outdated
Show resolved
Hide resolved
xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/environment/RippledContainer.java
Outdated
Show resolved
Hide resolved
@sappenin i have addressed your requested changes (format change requested today + changes requested on Feb 25th), could you please take a look? |
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.
@agutierrez0 This PR is looking good, and feels very close. I think once we get the formatting worked out, and updates from main
merged in, there's not much left.
Also, thanks for your patience in waiting for reviews on this one!
xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java
Outdated
Show resolved
Hide resolved
xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java
Outdated
Show resolved
Hide resolved
xrpl4j-core/src/main/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtils.java
Outdated
Show resolved
Hide resolved
xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java
Outdated
Show resolved
Hide resolved
xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/environment/RippledContainer.java
Outdated
Show resolved
Hide resolved
xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmClawback.java
Outdated
Show resolved
Hide resolved
xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java
Outdated
Show resolved
Hide resolved
xrpl4j-integration-tests/src/test/java/org/xrpl/xrpl4j/tests/AmmIT.java
Outdated
Show resolved
Hide resolved
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 a good callout -- there does appear to be a lot of duplicated code. I'd be up for experimenting with how to make this test more concise with less duplicated code. Couple of thoughts:
- We try to define commonly-used functions in
AbstractIT.java
, so take a look there to see if anything fits your needs. Basically, if there's a function that other ITs could use, then it probably makes sense to define those inAbstractIT
. However, we simultaneously need to be judicious about this because sometimes it's clearer to simply create aPayment
transaction using the builder (as your test does now) than to simply define a helper function that does the same thing (i.e., this merely shifts inputs around). - Instead of things like
createPayment
, I would look for higher-order functions to abstract away. E.g.,createAmm
seems like a good candidate, depending on the differences in usage in test cases. If you want to speak face-to-face sometime and experiment here, I'd be up for doing that. I think our ITs could use some refactoring/love anyway, and this might be a good use-case to experiment a bit with. - Despite 1 and 2 right above, we probably want to experiment with refactoring this IT in a separate PR, just so we can get this feature merged. What's in here already is probably good enough for this PR.
Yeah I think being able to abstract some of this code for AMMs into function could reduce code duplication which could be nice. yeah would be great to chat, i will try to find a time on your calendar |
@sappenin I have addressed your requested changes, could you PTAL? i finally properly configured my formatting settings and cleaned up files that previously had changes. the PR is a lot cleaner now. pls let me know if anything else needs to be addressed |
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.
@agutierrez0 All looks good. Just one small typo to fix in the Javadoc, and then I think we can merge this one.
(If you agree with the change, I think you can commit it directly from Github).
xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/TransactionType.java
Outdated
Show resolved
Hide resolved
…ransactionType.java
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.
@agutierrez0 I decided to just merge my suggestion. This is all set to merge. Once the build passes, I'll do that. Thanks for your contribution!!
closes #576
AmmClawback
toSignatureUtils
,Transaction.java
,TransactionType.java
, andTransactionTypeTests.java
SignatureUtils
for the newAmmClawback
classAmmClawbackFlags
with onlytfCalwTwoAssets
flag or unset flagsAmmClawback
undertransactions
definitions.json
AmmClawbackTest
transaction test2.3.0
from2.2.0-rc3
AMMClawback
amendment inrippled.cfg
AmmIt