Skip to content

Commit 7cc6652

Browse files
committed
used TransactionType for non_delegable_transactions
1 parent 2b357cc commit 7cc6652

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/DelegateSet.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ public interface DelegateSet extends Transaction {
5555
/**
5656
* Set of transaction types that cannot be delegated.
5757
*/
58-
Set<String> NON_DELEGABLE_TRANSACTIONS = Sets.newHashSet(
59-
TransactionType.ACCOUNT_SET.value(),
60-
TransactionType.SET_REGULAR_KEY.value(),
61-
TransactionType.SIGNER_LIST_SET.value(),
62-
TransactionType.DELEGATE_SET.value(),
63-
TransactionType.ACCOUNT_DELETE.value(),
64-
TransactionType.BATCH.value(),
58+
Set<TransactionType> NON_DELEGABLE_TRANSACTIONS = Sets.newHashSet(
59+
TransactionType.ACCOUNT_SET,
60+
TransactionType.SET_REGULAR_KEY,
61+
TransactionType.SIGNER_LIST_SET,
62+
TransactionType.DELEGATE_SET,
63+
TransactionType.ACCOUNT_DELETE,
64+
TransactionType.BATCH,
6565
// Pseudo transactions below:
66-
TransactionType.ENABLE_AMENDMENT.value(),
67-
TransactionType.SET_FEE.value(),
68-
TransactionType.UNL_MODIFY.value()
66+
TransactionType.ENABLE_AMENDMENT,
67+
TransactionType.SET_FEE,
68+
TransactionType.UNL_MODIFY
6969
);
7070

7171
/**
@@ -155,8 +155,10 @@ default void validateNoDuplicatePermissions() {
155155
default void validateNoNonDelegatableTransactions() {
156156
for (AccountPermissionWrapper wrapper : permissions()) {
157157
String permissionValue = wrapper.permission().permissionValue();
158+
boolean isNonDelegatable = NON_DELEGABLE_TRANSACTIONS.stream()
159+
.anyMatch(txType -> txType.value().equals(permissionValue));
158160
Preconditions.checkArgument(
159-
!NON_DELEGABLE_TRANSACTIONS.contains(permissionValue),
161+
!isNonDelegatable,
160162
String.format("DelegateSet: PermissionValue contains a non-delegatable transaction %s", permissionValue)
161163
);
162164
}

xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/transactions/DelegateSetTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ public void testDelegateSetValidationDuplicatePermissions() {
167167
@Test
168168
public void testDelegateSetValidationNonDelegatableTransactions() {
169169
// Test each non-delegatable transaction type by reusing DelegateSet.NON_DELEGABLE_TRANSACTIONS
170-
for (String txType : DelegateSet.NON_DELEGABLE_TRANSACTIONS) {
170+
for (TransactionType txType : DelegateSet.NON_DELEGABLE_TRANSACTIONS) {
171171
List<AccountPermissionWrapper> permissions = Arrays.asList(
172172
AccountPermissionWrapper.builder()
173-
.permission(AccountPermission.builder().permissionValue(txType).build())
173+
.permission(AccountPermission.builder().permissionValue(txType.value()).build())
174174
.build()
175175
);
176176

@@ -371,7 +371,7 @@ public void testAllDelegatableTransactionTypes() {
371371
// from all TransactionType values. This ensures that when new transaction types are added
372372
// to the enum, they are automatically tested.
373373
List<TransactionType> delegatableTypes = Arrays.stream(TransactionType.values())
374-
.filter(txType -> !DelegateSet.NON_DELEGABLE_TRANSACTIONS.contains(txType.value()))
374+
.filter(txType -> !DelegateSet.NON_DELEGABLE_TRANSACTIONS.contains(txType))
375375
.filter(txType -> txType != TransactionType.UNKNOWN) // Exclude UNKNOWN
376376
.collect(Collectors.toList());
377377

@@ -403,7 +403,7 @@ public void testAllNonDelegatableTransactionTypesWithEnum() {
403403
// Automatically derive non-delegatable transaction types from DelegateSet.NON_DELEGABLE_TRANSACTIONS
404404
// This ensures that when new non-delegatable types are added, they are automatically tested
405405
List<TransactionType> nonDelegatableTypes = Arrays.stream(TransactionType.values())
406-
.filter(txType -> DelegateSet.NON_DELEGABLE_TRANSACTIONS.contains(txType.value()))
406+
.filter(txType -> DelegateSet.NON_DELEGABLE_TRANSACTIONS.contains(txType))
407407
.collect(Collectors.toList());
408408

409409
// Verify we have the expected number of non-delegatable types (sanity check)

0 commit comments

Comments
 (0)