-
Notifications
You must be signed in to change notification settings - Fork 71
Added account permission delegation #689
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
base: main
Are you sure you want to change the base?
Changes from 16 commits
474eb81
ba48f46
7304367
fc834c7
a9d902b
bfc033d
ab0045c
be9d4f7
d9ff2f1
9868950
408efff
af2fc8f
d5ce28f
be26ff3
a270901
4844bc4
38c887c
26c6a98
f3ca876
bd1b597
ea3dcea
e32e21d
30cf686
35c6694
198668f
9f3b13a
bfdaafc
5bd0628
2b357cc
7cc6652
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 |
|---|---|---|
|
|
@@ -24,6 +24,8 @@ | |
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
| import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
| import com.google.common.collect.ImmutableMap; | ||
| import org.immutables.value.Value.Default; | ||
| import org.immutables.value.Value.Immutable; | ||
|
|
||
| import java.util.List; | ||
|
|
@@ -77,4 +79,16 @@ public interface Definitions { | |
| @JsonProperty("TRANSACTION_RESULTS") | ||
| Map<String, Integer> transactionResults(); | ||
|
|
||
| /** | ||
| * Permission values mappings (permission value to ordinal value). | ||
| * This field is not present in the generated definitions.json file and is populated | ||
| * programmatically by {@link DefaultDefinitionsProvider}. | ||
| * | ||
| * @return {@link Map} keyed by {@link String} with {@link Integer} values for all permission values. | ||
| */ | ||
| @JsonProperty("PERMISSION_VALUES") | ||
| @Default | ||
| default Map<String, Integer> permissionValues() { | ||
|
||
| return ImmutableMap.of(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ | |
| import org.xrpl.xrpl4j.model.transactions.CredentialAccept; | ||
| import org.xrpl.xrpl4j.model.transactions.CredentialCreate; | ||
| import org.xrpl.xrpl4j.model.transactions.CredentialDelete; | ||
| import org.xrpl.xrpl4j.model.transactions.DelegateSet; | ||
| import org.xrpl.xrpl4j.model.transactions.DepositPreAuth; | ||
| import org.xrpl.xrpl4j.model.transactions.DidDelete; | ||
| import org.xrpl.xrpl4j.model.transactions.DidSet; | ||
|
|
@@ -481,6 +482,10 @@ public <T extends Transaction> SingleSignedTransaction<T> addSignatureToTransact | |
| transactionWithSignature = CredentialDelete.builder().from((CredentialDelete) transaction) | ||
| .transactionSignature(signature) | ||
| .build(); | ||
| } else if (DelegateSet.class.isAssignableFrom(transaction.getClass())) { | ||
|
Collaborator
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. nit: Since we are adding tests in
Collaborator
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 see this comment as resolved, but when I run
Collaborator
Author
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. Added coverage for this line and reran tests with coverage to confirm |
||
| transactionWithSignature = DelegateSet.builder().from((DelegateSet) transaction) | ||
| .transactionSignature(signature) | ||
| .build(); | ||
| } else if (PermissionedDomainSet.class.isAssignableFrom(transaction.getClass())) { | ||
| transactionWithSignature = PermissionedDomainSet.builder().from((PermissionedDomainSet) transaction) | ||
| .transactionSignature(signature) | ||
|
|
@@ -736,6 +741,10 @@ public <T extends Transaction> T addMultiSignaturesToTransaction(T transaction, | |
| transactionWithSignatures = CredentialDelete.builder().from((CredentialDelete) transaction) | ||
| .signers(signers) | ||
| .build(); | ||
| } else if (DelegateSet.class.isAssignableFrom(transaction.getClass())) { | ||
| transactionWithSignatures = DelegateSet.builder().from((DelegateSet) transaction) | ||
| .signers(signers) | ||
| .build(); | ||
| } else if (PermissionedDomainSet.class.isAssignableFrom(transaction.getClass())) { | ||
| transactionWithSignatures = PermissionedDomainSet.builder().from((PermissionedDomainSet) transaction) | ||
| .signers(signers) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| package org.xrpl.xrpl4j.model.ledger; | ||
|
|
||
| /*- | ||
| * ========================LICENSE_START================================= | ||
| * xrpl4j :: model | ||
| * %% | ||
| * Copyright (C) 2020 - 2022 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 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 com.google.common.primitives.UnsignedInteger; | ||
| import org.immutables.value.Value; | ||
| import org.xrpl.xrpl4j.model.flags.Flags; | ||
| import org.xrpl.xrpl4j.model.transactions.Address; | ||
| import org.xrpl.xrpl4j.model.transactions.DelegateSet; | ||
| import org.xrpl.xrpl4j.model.transactions.Hash256; | ||
| import org.xrpl.xrpl4j.model.transactions.PermissionWrapper; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * This object represents a set of permissions that an account has delegated to another account. | ||
| * {@link DelegateSet} transactions create these objects. | ||
| * | ||
| * <p>This class will be marked {@link Beta} until the featurePermissionDelegation amendment is enabled on mainnet. | ||
| * Its API is subject to change.</p> | ||
| */ | ||
| @Value.Immutable | ||
| @JsonSerialize(as = ImmutableDelegateObject.class) | ||
| @JsonDeserialize(as = ImmutableDelegateObject.class) | ||
| @Beta | ||
| public interface DelegateObject extends LedgerObject { | ||
Patel-Raj11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Construct a builder for this class. | ||
| * | ||
| * @return An {@link ImmutableDelegateObject.Builder}. | ||
| */ | ||
| static ImmutableDelegateObject.Builder builder() { | ||
| return ImmutableDelegateObject.builder(); | ||
| } | ||
|
|
||
| /** | ||
| * The type of ledger object, which will always be "Delegate" in this case. | ||
| * | ||
| * @return Always {@link LedgerEntryType#DELEGATE}. | ||
| */ | ||
| @JsonProperty("LedgerEntryType") | ||
| @Value.Derived | ||
| default LedgerEntryType ledgerEntryType() { | ||
| return LedgerEntryType.DELEGATE; | ||
| } | ||
|
|
||
| /** | ||
| * The account that wants to authorize another account. | ||
| * | ||
| * @return The {@link Address} of the account. | ||
| */ | ||
| @JsonProperty("Account") | ||
| Address account(); | ||
|
|
||
| /** | ||
| * The authorized account. | ||
| * | ||
| * @return The {@link Address} of the authorized account. | ||
| */ | ||
| @JsonProperty("Authorize") | ||
| Address authorize(); | ||
|
|
||
| /** | ||
| * The transaction permissions that the account has access to. | ||
| * | ||
| * @return A {@link List} of {@link PermissionWrapper}s. | ||
| */ | ||
| @JsonProperty("Permissions") | ||
| List<PermissionWrapper> permissions(); | ||
|
|
||
| /** | ||
| * A hint indicating which page of the sender's owner directory links to this object, | ||
| * in case the directory consists of multiple pages. | ||
| * | ||
| * <p>Note: The object does not contain a direct link to the owner directory containing it, since that value can be | ||
| * derived from the Account. | ||
| * | ||
| * @return A {@link String} containing the owner node hint. | ||
| */ | ||
| @JsonProperty("OwnerNode") | ||
| String ownerNode(); | ||
|
|
||
| /** | ||
| * A bit-map of boolean flags. No flags are defined for the Delegate object | ||
| * type, so this value is always 0. | ||
| * | ||
| * @return Always {@link Flags#UNSET}. | ||
| */ | ||
| @JsonProperty("Flags") | ||
| @Value.Derived | ||
| default Flags flags() { | ||
| return Flags.UNSET; | ||
| } | ||
|
|
||
| /** | ||
| * The identifying hash of the transaction that most recently modified this object. | ||
| * | ||
| * @return A {@link Hash256} containing the previous transaction hash. | ||
| */ | ||
| @JsonProperty("PreviousTxnID") | ||
| Hash256 previousTransactionId(); | ||
|
|
||
| /** | ||
| * The index of the ledger that contains the transaction that most recently modified this object. | ||
| * | ||
| * @return An {@link UnsignedInteger} representing the previous transaction ledger sequence. | ||
| */ | ||
| @JsonProperty("PreviousTxnLgrSeq") | ||
| UnsignedInteger previousTransactionLedgerSequence(); | ||
|
|
||
| /** | ||
| * The unique ID of the {@link DelegateObject}. | ||
| * | ||
| * @return A {@link Hash256} containing the ID. | ||
| */ | ||
| Hash256 index(); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.