-
Notifications
You must be signed in to change notification settings - Fork 60
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
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
Show resolved
Hide resolved
xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/AmmClawback.java
Outdated
Show resolved
Hide resolved
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?
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 don't think you need an import here because AmmClawback and Address are in the same package. We can remove this
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 removed the extra import 👍🏽
// create Trustline from issuer to trader for currency TST and define two currencies | ||
String testCurrency = "TST"; | ||
TrustSet trustSet = TrustSet.builder() | ||
.account(traderKeyPair.publicKey().deriveAddress()) |
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.
Need to fix formatting - use 2 spaces (no tabs)
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.
after finally being able to build, i have been able to address all of the checkstyle errors
assertThat(trustlineSubmitResult2.engineResult()).isEqualTo(TransactionResultCodes.TES_SUCCESS); | ||
|
||
// send payment of ZFT to trader wallet from issuer | ||
Payment paymentZFT = Payment.builder() |
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 naming convention breaks our Checkstyle plugin. Need to replace all instances of ...ZFT
with Zft
. For example:
Payment paymentZFT = Payment.builder() | |
Payment paymentZft = Payment.builder() |
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.
fixed
assertThat(paymentZFTSubmitResult.engineResult()).isEqualTo(TransactionResultCodes.TES_SUCCESS); | ||
|
||
// send payment of TST to trader wallet from issuer | ||
Payment paymentTST = Payment.builder() |
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 naming convention breaks our Checkstyle plugin. Need to replace all instances of ...TFT
with Tft
. For example:
Payment paymentTST = Payment.builder() | |
Payment paymentTft = Payment.builder() |
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've updated this along with all the other checkstyle issues
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
" \"Fee\" : \"10\",\n" + | ||
" \"Sequence\" : 6,\n" + | ||
" \"SigningPubKey\" : \"02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC\",\n" + | ||
" \"TransactionType\" : \"AMMClawback\"\n" + |
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 test currently fails. Need to add this:
" \"TransactionType\" : \"AMMClawback\"\n" + | |
" \"TransactionType\" : \"AMMClawback\",\n" + | |
" \"Flags\" : 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.
thanks for raising the issues in this unit test file, added the extra field to the json and switched to USD from TST
.value("25") | ||
.build() | ||
) | ||
.holder(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) |
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 test is failing -- This transaction won't build without specifying asset1
and asset2
.
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 addressed all of the failing tests in this unit test file
.value("25") | ||
.build() | ||
) | ||
.holder(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) |
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 test is failing -- This transaction won't build without specifying asset1
and asset2
.
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.
fixed all the tests in this unit test file, all 3 passing now
.signingPublicKey( | ||
PublicKey.fromBase16EncodedPublicKey("02356E89059A75438887F9FEE2056A2890DB82A68353BE9C0C0C8F89C0018B37FC") | ||
) | ||
.flags((AmmClawbackFlags) 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.
.flags((AmmClawbackFlags) AmmClawbackFlags.UNSET) | |
.flags(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 have removed this unnecessary casting, my IDE was also showing i didnt need this
import org.xrpl.xrpl4j.model.flags.TransactionFlags; | ||
import org.xrpl.xrpl4j.model.ledger.Issue; | ||
|
||
public class AmmClawbackTest extends AbstractJsonTest { |
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.
Use this as a standard Javadoc for unit tests:
public class AmmClawbackTest extends AbstractJsonTest { | |
/** | |
* Unit tests for {@link AmmClawback}. | |
**/ | |
public class AmmClawbackTest extends AbstractJsonTest { |
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, thanks for mentioning i didn't know these were called a "Javadoc"
"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?
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/environment/RippledContainer.java
Show resolved
Hide resolved
@nkramer44 / @sappenin - was looking to wrap up this work, could you PTAL? saw comment on this thread, not sure if we want to wait till that's merged? |
@agutierrez0 Please see my code review comments. If they've been addressed, please add a response to let me know to go check. Once addressed, I'll resolve the comments. |
@Test | ||
void testJson() throws JSONException, JsonProcessingException { | ||
AmmClawback ammClawback = AmmClawback.builder() | ||
.account(Address.of("rJVUeRqDFNs2xqA7ncVE6ZoAhPUoaJJSQm")) |
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.
Please set your tabs to use spaces
and set all indent levels to 2
.
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.
@sappenin i have addressed your requested changes (format change requested today + changes requested on Feb 25th), could you please take a look? |
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