Skip to content

Commit

Permalink
add RPC methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nkramer44 committed Nov 9, 2024
1 parent 01fd33e commit 102d035
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@ enum AccountObjectType {
/**
* State account object type.
*/
STATE("state");
STATE("state"),
/**
* MPToken Issuance object type.
*/
MPT_ISSUANCE("mpt_issuance"),
/**
* MPToken object type.
*/
MP_TOKEN("mptoken");

private final String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import org.xrpl.xrpl4j.model.ledger.DidObject;
import org.xrpl.xrpl4j.model.ledger.EscrowObject;
import org.xrpl.xrpl4j.model.ledger.LedgerObject;
import org.xrpl.xrpl4j.model.ledger.MpTokenIssuanceObject;
import org.xrpl.xrpl4j.model.ledger.MpTokenObject;
import org.xrpl.xrpl4j.model.ledger.NfTokenPageObject;
import org.xrpl.xrpl4j.model.ledger.OfferObject;
import org.xrpl.xrpl4j.model.ledger.OracleObject;
Expand All @@ -25,6 +27,7 @@
import org.xrpl.xrpl4j.model.ledger.TicketObject;
import org.xrpl.xrpl4j.model.transactions.Address;
import org.xrpl.xrpl4j.model.transactions.Hash256;
import org.xrpl.xrpl4j.model.transactions.MpTokenIssuanceId;
import org.xrpl.xrpl4j.model.transactions.XChainBridge;

import java.util.Optional;
Expand Down Expand Up @@ -361,6 +364,42 @@ static LedgerEntryRequestParams<OracleObject> oracle(
.build();
}

/**
* Construct a {@link LedgerEntryRequestParams} that requests a {@link MpTokenIssuanceObject} ledger entry.
*
* @param issuanceId The {@link MpTokenIssuanceId} of the token.
* @param ledgerSpecifier A {@link LedgerSpecifier} indicating the ledger to query data from.
*
* @return A {@link LedgerEntryRequestParams} for {@link OracleObject}.
*/
static LedgerEntryRequestParams<MpTokenIssuanceObject> mpTokenIssuance(
MpTokenIssuanceId issuanceId,
LedgerSpecifier ledgerSpecifier
) {
return ImmutableLedgerEntryRequestParams.<MpTokenIssuanceObject>builder()
.mptIssuance(issuanceId)
.ledgerSpecifier(ledgerSpecifier)
.build();
}

/**
* Construct a {@link LedgerEntryRequestParams} that requests a {@link MpTokenObject} ledger entry.
*
* @param mpToken The {@link MpTokenLedgerEntryParams} specifying the MPToken.
* @param ledgerSpecifier A {@link LedgerSpecifier} indicating the ledger to query data from.
*
* @return A {@link LedgerEntryRequestParams} for {@link OracleObject}.
*/
static LedgerEntryRequestParams<MpTokenObject> mpToken(
MpTokenLedgerEntryParams mpToken,
LedgerSpecifier ledgerSpecifier
) {
return ImmutableLedgerEntryRequestParams.<MpTokenObject>builder()
.mpToken(mpToken)
.ledgerSpecifier(ledgerSpecifier)
.build();
}

/**
* Specifies the ledger version to request. A ledger version can be specified by ledger hash, numerical ledger index,
* or a shortcut value.
Expand Down Expand Up @@ -494,6 +533,12 @@ default boolean binary() {
*/
Optional<OracleLedgerEntryParams> oracle();

@JsonProperty("mpt_issuance")
Optional<MpTokenIssuanceId> mptIssuance();

@JsonProperty("mptoken")
Optional<MpTokenLedgerEntryParams> mpToken();

/**
* The {@link Class} of {@link T}. This field is helpful when telling Jackson how to deserialize rippled's response to
* a {@link T}.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.xrpl.xrpl4j.model.client.ledger;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.immutables.value.Value.Immutable;
import org.xrpl.xrpl4j.model.transactions.Address;
import org.xrpl.xrpl4j.model.transactions.MpTokenIssuanceId;

@Immutable
@JsonSerialize(as = ImmutableMpTokenLedgerEntryParams.class)
@JsonDeserialize(as = ImmutableMpTokenLedgerEntryParams.class)
public interface MpTokenLedgerEntryParams {

/**
* Construct a {@code MpTokenLedgerEntryParams} builder.
*
* @return An {@link ImmutableMpTokenLedgerEntryParams.Builder}.
*/
static ImmutableMpTokenLedgerEntryParams.Builder builder() {
return ImmutableMpTokenLedgerEntryParams.builder();
}

@JsonProperty("mpt_issuance_id")
MpTokenIssuanceId mpTokenIssuanceId();

Address account();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.xrpl.xrpl4j.model.client.mpt;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.immutables.value.Value.Immutable;
import org.xrpl.xrpl4j.model.flags.MpTokenFlags;
import org.xrpl.xrpl4j.model.transactions.Address;
import org.xrpl.xrpl4j.model.transactions.Hash256;
import org.xrpl.xrpl4j.model.transactions.MpTokenAmount;
import org.xrpl.xrpl4j.model.transactions.MpTokenObjectAmount;

import java.util.Optional;

@Immutable
@JsonSerialize(as = ImmutableMptHoldersMpToken.class)
@JsonDeserialize(as = ImmutableMptHoldersMpToken.class)
public interface MptHoldersMpToken {

/**
* Construct a {@code MptHoldersMpToken} builder.
*
* @return An {@link ImmutableMptHoldersMpToken.Builder}.
*/
static ImmutableMptHoldersMpToken.Builder builder() {
return ImmutableMptHoldersMpToken.builder();
}

Address account();

MpTokenFlags flags();

@JsonProperty("mpt_amount")
MpTokenObjectAmount mptAmount();

@JsonProperty("locked_amount")
Optional<MpTokenAmount> lockedAmount();

@JsonProperty("mptoken_index")
Hash256 mpTokenIndex();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.xrpl.xrpl4j.model.client.mpt;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.primitives.UnsignedInteger;
import org.immutables.value.Value.Immutable;
import org.xrpl.xrpl4j.model.client.common.LedgerSpecifier;
import org.xrpl.xrpl4j.model.transactions.Marker;
import org.xrpl.xrpl4j.model.transactions.MpTokenIssuanceId;

import java.util.Optional;

@Immutable
@JsonSerialize(as = ImmutableMptHoldersRequestParams.class)
@JsonDeserialize(as = ImmutableMptHoldersRequestParams.class)
public interface MptHoldersRequestParams {

/**
* Construct a {@code MptHoldersRequestParams} builder.
*
* @return An {@link ImmutableMptHoldersRequestParams.Builder}.
*/
static ImmutableMptHoldersRequestParams.Builder builder() {
return ImmutableMptHoldersRequestParams.builder();
}

@JsonProperty("mpt_issuance_id")
MpTokenIssuanceId mpTokenIssuanceId();

@JsonUnwrapped
LedgerSpecifier ledgerSpecifier();

Optional<Marker> marker();

Optional<UnsignedInteger> limit();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.xrpl.xrpl4j.model.client.mpt;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.primitives.UnsignedInteger;
import org.immutables.value.Value.Immutable;
import org.xrpl.xrpl4j.model.client.common.LedgerIndex;
import org.xrpl.xrpl4j.model.transactions.Marker;
import org.xrpl.xrpl4j.model.transactions.MpTokenIssuanceId;

import java.util.List;
import java.util.Optional;

@Immutable
@JsonSerialize(as = ImmutableMptHoldersResponse.class)
@JsonDeserialize(as = ImmutableMptHoldersResponse.class)
public interface MptHoldersResponse {

/**
* Construct a {@code MptHoldersResponse} builder.
*
* @return An {@link ImmutableMptHoldersResponse.Builder}.
*/
static ImmutableMptHoldersResponse.Builder builder() {
return ImmutableMptHoldersResponse.builder();
}

@JsonProperty("mpt_issuance_id")
MpTokenIssuanceId mpTokenIssuanceId();

@JsonProperty("mptokens")
List<MptHoldersMpToken> mpTokens();

Optional<Marker> marker();

Optional<UnsignedInteger> limit();

// FIXME: Is this always the field, or does clio also return `ledger_hash` and potentially `ledger_current_index`?
@JsonProperty("ledger_index")
LedgerIndex ledgerIndex();
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.xrpl.xrpl4j.model.transactions.Address;
import org.xrpl.xrpl4j.model.transactions.AssetScale;
import org.xrpl.xrpl4j.model.transactions.Hash256;
import org.xrpl.xrpl4j.model.transactions.MpTokenIssuanceId;
import org.xrpl.xrpl4j.model.transactions.MpTokenObjectAmount;
import org.xrpl.xrpl4j.model.transactions.TransferFee;

Expand Down Expand Up @@ -101,4 +102,12 @@ default LedgerEntryType ledgerEntryType() {
* @return A {@link Hash256} containing the ID.
*/
Hash256 index();

/**
* The {@link MpTokenIssuanceId} of the issuance. Only present in responses to {@code ledger_data} and
* {@code account_objects} RPC calls.
*
* @return An {@link Optional}<{@link MpTokenIssuanceId}>.
*/
Optional<MpTokenIssuanceId> mpTokenIssuanceId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ static ImmutableTransactionMetadata.Builder builder() {
@JsonProperty("nftoken_ids")
List<NfTokenId> nfTokenIds();

/**
* The {@link MpTokenIssuanceId} of the {@link org.xrpl.xrpl4j.model.ledger.MpTokenIssuanceObject} created
* via an {@link MpTokenIssuanceCreate} transaction.
*
* @return An {@link Optional}<{@link MpTokenIssuanceId}>.
*/
@JsonProperty("mpt_issuance_id")
Optional<MpTokenIssuanceId> mpTokenIssuanceId();

/**
* The ID of the offer created by {@link NfTokenCreateOffer} transactions. Only present in metadata for
* {@link NfTokenCreateOffer} transactions.
Expand Down

0 comments on commit 102d035

Please sign in to comment.