-
Notifications
You must be signed in to change notification settings - Fork 57
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
#576: Add support for AMMClawback #601
base: main
Are you sure you want to change the base?
Conversation
public boolean tfClawTwoAssets() { | ||
return this.isSet(CLAW_TWO_ASSETS); | ||
} |
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 unused, i added it to follow the practice I saw with other TransactionFlag classes I saw (e.g. AmmWithdrawFlags
). Let me know if I should remove.
@@ -84,7 +82,7 @@ public class RippledContainer { | |||
* No-args constructor. | |||
*/ | |||
public RippledContainer() { | |||
try (GenericContainer<?> container = new GenericContainer<>("rippleci/rippled:2.2.0")) { | |||
try (GenericContainer<?> container = new GenericContainer<>("rippleci/rippled:2.3.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.
Let me know if there is another version I could use here instead of 2.3.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 think version 2.3.1 is the most recent version, so we should use that
@JsonProperty("Flags") | ||
@Value.Default | ||
default AmmClawbackFlags flags() { | ||
return AmmClawbackFlags.UNSET; | ||
} |
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 noticed there was only one flag AMMClawback
can be set to, this tfClawTwoAssets
so I set the default to be UNSET
, but if I should instead just make this an Optional<>
field, let me know.
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.
To align with other Transaction
sub-types, this should default to AmmClawbackFlags.empty()
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.
import org.xrpl.xrpl4j.model.flags.AmmClawbackFlags; | ||
import org.xrpl.xrpl4j.model.flags.TransactionFlags; | ||
import org.xrpl.xrpl4j.model.ledger.Issue; | ||
|
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.
import org.xrpl.xrpl4j.model.transactions.Address; |
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 have added this extra import, but on my IDE it shows as unused.
when i define the type for holder
, i do see the Address
references this path, but doesn't add the import. is there any reason why this happens?
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
SubmitResult<TrustSet> trustlineSubmitResult2 = xrplClient.submit(signedTrustline2); | ||
assertThat(trustlineSubmitResult2.engineResult()).isEqualTo(TransactionResultCodes.TES_SUCCESS); | ||
|
||
// send payment of ZFT to trader wallet from issuer |
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.
Consider using real currency names, especially ones that are a familiar, like usd
and xrp
. It will be one less thing for developers to have keep track of while they seek to understand these tests.
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 have replaced TST with USD and replaced ZFT with the existing token xrpl4j
and not sure why, i was able to build before committing... but after committing this last change, now my build constantly fails 😅
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.
upd: build no longer failing
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
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
Show resolved
Hide resolved
"nth": 258, | ||
"isVLEncoded": false, | ||
"isSerialized": false, | ||
"isSigningField": false, | ||
"type": "Amount" | ||
} |
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.
What version of rippled did you generate this definitions.json from?
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 initially generated the definitions.json using this branch on the xrpl.js
library. i compared it to the definitions.json that was commited to that repo after adding support for AMMClawback, and noticed mine was different so i used the same one the xrpl.js library used.
should i instead commit the file i get by running the script again on the latest in rippled's develop branch?
/** | ||
* {@link TransactionFlags} for {@link AmmClawback} transactions. | ||
*/ | ||
public class AmmClawbackFlags extends TransactionFlags { |
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.
Looking at other TransactionFlags
implementations, we always have a static empty()
method which calls a private no-arg constructor. Check out OfferCreateFlags
for reference
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.
Also this class needs a test. Check out OfferCreateFlagsTests
as an example
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 have added this static empty()
method and also added AmmClawbackFlagTest
. thanks for the references 👍🏽 let me know what you think
@JsonProperty("Flags") | ||
@Value.Default | ||
default AmmClawbackFlags flags() { | ||
return AmmClawbackFlags.UNSET; | ||
} |
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.
To align with other Transaction
sub-types, this should default to AmmClawbackFlags.empty()
xrpl4j-core/src/test/java/org/xrpl/xrpl4j/crypto/signing/SignatureUtilsTest.java
Show resolved
Hide resolved
@@ -60,10 +65,11 @@ public class AmmIT extends AbstractIT { | |||
|
|||
static boolean shouldNotRun() { | |||
return System.getProperty("useTestnet") != null || | |||
System.getProperty("useClioTestnet") != null; | |||
System.getProperty("useClioTestnet") != null; |
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 your formatting settings are off, I'll send you the intellij formatting template
@@ -84,7 +82,7 @@ public class RippledContainer { | |||
* No-args constructor. | |||
*/ | |||
public RippledContainer() { | |||
try (GenericContainer<?> container = new GenericContainer<>("rippleci/rippled:2.2.0")) { | |||
try (GenericContainer<?> container = new GenericContainer<>("rippleci/rippled:2.3.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 think version 2.3.1 is the most recent version, so we should use that
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