-
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?
Changes from all commits
8c0896e
f7ede3e
6208633
ad2caee
ccee59b
e526d46
c8aab1f
b1f8c42
3149b86
ee8054c
21b1e9d
fcd0407
10b2b50
850fa74
b030ff5
16dc361
ec0c5d2
60396cd
1c92ba8
0513be4
7d8f95d
6f41e95
d699102
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.xrpl.xrpl4j.model.flags; | ||
|
||
/*- | ||
* ========================LICENSE_START================================= | ||
* xrpl4j :: core | ||
* %% | ||
* Copyright (C) 2020 - 2023 XRPL Foundation and its contributors | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* =========================LICENSE_END================================== | ||
*/ | ||
|
||
import org.xrpl.xrpl4j.model.transactions.AmmClawback; | ||
|
||
/** | ||
* {@link TransactionFlags} for {@link AmmClawback} transactions. | ||
*/ | ||
public class AmmClawbackFlags extends TransactionFlags { | ||
/** | ||
* Constant {@link AmmDepositFlags} for the {@code tfClawTwoAssets} flag. | ||
*/ | ||
public static final AmmClawbackFlags CLAW_TWO_ASSETS = new AmmClawbackFlags(0x00000001); | ||
|
||
/** | ||
* Constant {@link AmmDepositFlags} for an unset value for "flags". | ||
*/ | ||
public static final AmmClawbackFlags UNSET = new AmmClawbackFlags(0L); | ||
|
||
private AmmClawbackFlags(long value) { | ||
super(value); | ||
} | ||
|
||
private AmmClawbackFlags() { | ||
} | ||
|
||
/** | ||
* Construct an empty instance of {@link AmmClawbackFlags}. Transactions with empty flags will | ||
* not be serialized with a {@code Flags} field. | ||
* | ||
* @return An empty {@link AmmClawbackFlags}. | ||
*/ | ||
public static AmmClawbackFlags empty() { | ||
return new AmmClawbackFlags(); | ||
} | ||
|
||
/** | ||
* Whether the {@code tfClawTwoAssets} flag is set. | ||
* | ||
* @return {@code true} if {@code tfLPToken} is set, otherwise {@code false}. | ||
*/ | ||
public boolean tfClawTwoAssets() { | ||
return this.isSet(CLAW_TWO_ASSETS); | ||
} | ||
Comment on lines
+61
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,74 @@ | ||||||
package org.xrpl.xrpl4j.model.transactions; | ||||||
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty; | ||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||||||
import com.google.common.annotations.Beta; | ||||||
import org.immutables.value.Value; | ||||||
import org.xrpl.xrpl4j.model.flags.AmmClawbackFlags; | ||||||
import org.xrpl.xrpl4j.model.ledger.Issue; | ||||||
import org.xrpl.xrpl4j.model.transactions.Address; | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
import java.util.Optional; | ||||||
|
||||||
/** | ||||||
* An {@link AmmClawback} transaction claws back tokens from a holder that has funds in an AMM pool. | ||||||
*/ | ||||||
@Value.Immutable | ||||||
@JsonSerialize(as = ImmutableAmmClawback.class) | ||||||
@JsonDeserialize(as = ImmutableAmmClawback.class) | ||||||
@Beta | ||||||
public interface AmmClawback extends Transaction { | ||||||
|
||||||
/** | ||||||
* Construct a builder for this class. | ||||||
* | ||||||
* @return An {@link ImmutableAmmClawback.Builder}. | ||||||
*/ | ||||||
static ImmutableAmmClawback.Builder builder() { | ||||||
return ImmutableAmmClawback.builder(); | ||||||
} | ||||||
|
||||||
/** | ||||||
* The address of the holder that has funds deposited in the AMM pool. | ||||||
* | ||||||
* @return An {@link Address}. | ||||||
*/ | ||||||
@JsonProperty("Holder") | ||||||
Address holder(); | ||||||
|
||||||
/** | ||||||
* The asset in the AMM pool that the issuer is looking to claw back. | ||||||
* | ||||||
* @return An {@link Issue}. | ||||||
*/ | ||||||
@JsonProperty("Asset") | ||||||
Issue asset(); | ||||||
|
||||||
/** | ||||||
* Other asset in the AMM pool that the issuer is looking to claw back. | ||||||
* | ||||||
* @return An {@link Issue}. | ||||||
*/ | ||||||
@JsonProperty("Asset2") | ||||||
Issue asset2(); | ||||||
|
||||||
/** | ||||||
* Optional field that specifies the maximum amount to clawback from the AMM pool. | ||||||
* | ||||||
* @return An {@link CurrencyAmount}. | ||||||
*/ | ||||||
@JsonProperty("Amount") | ||||||
Optional<CurrencyAmount> amount(); | ||||||
|
||||||
/** | ||||||
* Transaction Flags for {@link AmmClawback}, with the only option being tfClawTwoAssets. | ||||||
* | ||||||
* @return {@link AmmClawbackFlags#UNSET} if field was not set, otherwise returns with the set flag. | ||||||
*/ | ||||||
@JsonProperty("Flags") | ||||||
@Value.Default | ||||||
default AmmClawbackFlags flags() { | ||||||
return 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.
Looking at other
TransactionFlags
implementations, we always have a staticempty()
method which calls a private no-arg constructor. Check outOfferCreateFlags
for referenceThere 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 exampleThere 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 addedAmmClawbackFlagTest
. thanks for the references 👍🏽 let me know what you think