entries;
+
+ Long latestLedger;
+
+ @AllArgsConstructor
+ @Value
+ public static class LedgerEntryResult {
+ String key;
+
+ String xdr;
+
+ @SerializedName("lastModifiedLedgerSeq")
+ Long lastModifiedLedger;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/responses/sorobanrpc/GetNetworkResponse.java b/src/main/java/org/stellar/sdk/responses/sorobanrpc/GetNetworkResponse.java
new file mode 100644
index 000000000..a32cfb754
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/responses/sorobanrpc/GetNetworkResponse.java
@@ -0,0 +1,20 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import lombok.AllArgsConstructor;
+import lombok.Value;
+
+/**
+ * Response for JSON-RPC method getNetwork.
+ *
+ * @see getNetwork documentation
+ */
+@AllArgsConstructor
+@Value
+public class GetNetworkResponse {
+ String friendbotUrl;
+
+ String passphrase;
+
+ Integer protocolVersion;
+}
diff --git a/src/main/java/org/stellar/sdk/responses/sorobanrpc/GetTransactionResponse.java b/src/main/java/org/stellar/sdk/responses/sorobanrpc/GetTransactionResponse.java
new file mode 100644
index 000000000..6e099baf1
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/responses/sorobanrpc/GetTransactionResponse.java
@@ -0,0 +1,44 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import lombok.AllArgsConstructor;
+import lombok.Value;
+
+/**
+ * Response for JSON-RPC method getTransaction.
+ *
+ * @see getTransaction documentation
+ */
+@AllArgsConstructor
+@Value
+public class GetTransactionResponse {
+ GetTransactionStatus status;
+
+ Long latestLedger;
+
+ Long latestLedgerCloseTime;
+
+ Long oldestLedger;
+
+ Long oldestLedgerCloseTime;
+
+ Integer applicationOrder;
+
+ Boolean feeBump;
+
+ String envelopeXdr;
+
+ String resultXdr;
+
+ String resultMetaXdr;
+
+ Long ledger;
+
+ Long createdAt;
+
+ public enum GetTransactionStatus {
+ NOT_FOUND,
+ SUCCESS,
+ FAILED
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/responses/sorobanrpc/SendTransactionResponse.java b/src/main/java/org/stellar/sdk/responses/sorobanrpc/SendTransactionResponse.java
new file mode 100644
index 000000000..99ffeeb86
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/responses/sorobanrpc/SendTransactionResponse.java
@@ -0,0 +1,31 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import lombok.AllArgsConstructor;
+import lombok.Value;
+
+/**
+ * Response for JSON-RPC method sendTransaction.
+ *
+ * @see sendTransaction documentation
+ */
+@AllArgsConstructor
+@Value
+public class SendTransactionResponse {
+ SendTransactionStatus status;
+
+ String errorResultXdr;
+
+ String hash;
+
+ Long latestLedger;
+
+ Long latestLedgerCloseTime;
+
+ public enum SendTransactionStatus {
+ PENDING,
+ DUPLICATE,
+ TRY_AGAIN_LATER,
+ ERROR
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/responses/sorobanrpc/SimulateTransactionResponse.java b/src/main/java/org/stellar/sdk/responses/sorobanrpc/SimulateTransactionResponse.java
new file mode 100644
index 000000000..2cb5a80c7
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/responses/sorobanrpc/SimulateTransactionResponse.java
@@ -0,0 +1,70 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import com.google.gson.annotations.SerializedName;
+import java.math.BigInteger;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Value;
+
+/**
+ * Response for JSON-RPC method simulateTransaction.
+ *
+ * Note - The simulation response will have different model representations with different
+ * members present or absent depending on type of response that it is conveying. For example, the
+ * simulation response for invoke host function, could be one of three types: error, success, or
+ * restore operation needed.
+ *
+ *
Please refer to the latest Soroban simulateTransaction documentation for details on which members of the
+ * simulation response model are keyed to each type of response.
+ */
+@AllArgsConstructor
+@Value
+public class SimulateTransactionResponse {
+ String error;
+
+ String transactionData;
+
+ List events;
+
+ Long minResourceFee;
+
+ // An array of the individual host function call results.
+ // This will only contain a single element if present, because only a single
+ // invokeHostFunctionOperation
+ // is supported per transaction.
+ List results;
+
+ SimulateTransactionCost cost;
+
+ RestorePreamble restorePreamble;
+
+ Long latestLedger;
+
+ @AllArgsConstructor
+ @Value
+ public static class SimulateHostFunctionResult {
+ List auth;
+
+ String xdr;
+ }
+
+ @AllArgsConstructor
+ @Value
+ public static class SimulateTransactionCost {
+ @SerializedName("cpuInsns")
+ BigInteger cpuInstructions;
+
+ @SerializedName("memBytes")
+ BigInteger memoryBytes;
+ }
+
+ @AllArgsConstructor
+ @Value
+ public static class RestorePreamble {
+ String transactionData;
+
+ Long minResourceFee;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/responses/sorobanrpc/SorobanRpcResponse.java b/src/main/java/org/stellar/sdk/responses/sorobanrpc/SorobanRpcResponse.java
new file mode 100644
index 000000000..26ec6dd90
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/responses/sorobanrpc/SorobanRpcResponse.java
@@ -0,0 +1,36 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Value;
+import org.stellar.sdk.responses.Response;
+
+/**
+ * Represent the response returned by Soroban-RPC.
+ *
+ * @see JSON-RPC 2.0
+ * Specification - Response object
+ */
+@AllArgsConstructor
+@Getter
+public class SorobanRpcResponse extends Response {
+ @SerializedName("jsonrpc")
+ private final String jsonRpc;
+
+ private final String id;
+
+ private final T result;
+
+ private final Error error;
+
+ @AllArgsConstructor
+ @Value
+ public static class Error {
+ Integer code;
+
+ String message;
+
+ String data;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/Longs.java b/src/main/java/org/stellar/sdk/scval/Longs.java
new file mode 100644
index 000000000..3439e5d07
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/Longs.java
@@ -0,0 +1,36 @@
+package org.stellar.sdk.scval;
+
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
+final class Longs {
+ /**
+ * @return a big-endian representation of {@code value} in an 8-element byte array.
+ */
+ static byte[] toByteArray(long value) {
+ byte[] result = new byte[8];
+ for (int i = 7; i >= 0; i--) {
+ result[i] = (byte) (value & 0xffL);
+ value >>= 8;
+ }
+ return result;
+ }
+
+ /**
+ * @return the {@code long} value whose byte representation is the given 8 bytes, in big-endian
+ * order.
+ */
+ static long fromByteArray(byte[] bytes) {
+ if (bytes.length != 8) {
+ throw new IllegalArgumentException("array length is not 8");
+ }
+ return (bytes[0] & 0xFFL) << 56
+ | (bytes[1] & 0xFFL) << 48
+ | (bytes[2] & 0xFFL) << 40
+ | (bytes[3] & 0xFFL) << 32
+ | (bytes[4] & 0xFFL) << 24
+ | (bytes[5] & 0xFFL) << 16
+ | (bytes[6] & 0xFFL) << 8
+ | (bytes[7] & 0xFFL);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/Scv.java b/src/main/java/org/stellar/sdk/scval/Scv.java
new file mode 100644
index 000000000..688b8be53
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/Scv.java
@@ -0,0 +1,478 @@
+package org.stellar.sdk.scval;
+
+import java.math.BigInteger;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import lombok.NoArgsConstructor;
+import org.stellar.sdk.Address;
+import org.stellar.sdk.xdr.SCContractInstance;
+import org.stellar.sdk.xdr.SCError;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+/** Provides a range of methods to help you build and parse {@link SCVal} more conveniently. */
+@NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
+public class Scv {
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_ADDRESS}.
+ *
+ * @param address address to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_ADDRESS}
+ */
+ public static SCVal toAddress(String address) {
+ return ScvAddress.toSCVal(new Address(address));
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_ADDRESS}.
+ *
+ * @param address address to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_ADDRESS}
+ */
+ public static SCVal toAddress(Address address) {
+ return ScvAddress.toSCVal(address);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_ADDRESS} to {@link Address}.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the address
+ */
+ public static Address fromAddress(SCVal scVal) {
+ return ScvAddress.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_BOOL}.
+ *
+ * @param bool boolean to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_BOOL}
+ */
+ public static SCVal toBoolean(boolean bool) {
+ return ScvBoolean.toSCVal(bool);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_BOOL} to boolean.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return boolean
+ */
+ public static boolean fromBoolean(SCVal scVal) {
+ return ScvBoolean.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_BYTES}.
+ *
+ * @param bytes bytes to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_BYTES}
+ */
+ public static SCVal toBytes(byte[] bytes) {
+ return ScvBytes.toSCVal(bytes);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_BYTES} to byte[].
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the bytes
+ */
+ public static byte[] fromBytes(SCVal scVal) {
+ return ScvBytes.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_CONTRACT_INSTANCE}.
+ *
+ * @param instance {@link SCContractInstance} to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_CONTRACT_INSTANCE}
+ */
+ public static SCVal toContractInstance(SCContractInstance instance) {
+ return ScvContractInstance.toSCVal(instance);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_CONTRACT_INSTANCE} to {@link
+ * SCContractInstance}.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the contract instance
+ */
+ public static SCContractInstance fromContractInstance(SCVal scVal) {
+ return ScvContractInstance.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_DURATION}.
+ *
+ * @param duration duration to convert (uint64)
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_DURATION}
+ */
+ public static SCVal toDuration(BigInteger duration) {
+ return ScvDuration.toSCVal(duration);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_DURATION} to {@link
+ * BigInteger}.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the duration (uint64)
+ */
+ public static BigInteger fromDuration(SCVal scVal) {
+ return ScvDuration.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_ERROR}.
+ *
+ * @param error {@link SCError} to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_ERROR}
+ */
+ public static SCVal toError(SCError error) {
+ return ScvError.toSCVal(error);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_ERROR} to {@link SCError}.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the error
+ */
+ public static SCError fromError(SCVal scVal) {
+ return ScvError.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_I128}.
+ *
+ * @param int32 int32 to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_I128}
+ */
+ public static SCVal toInt32(int int32) {
+ return ScvInt32.toSCVal(int32);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_I128} to int32.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the int32
+ */
+ public static int fromInt32(SCVal scVal) {
+ return ScvInt32.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_I64}.
+ *
+ * @param int64 int64 to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_I64}
+ */
+ public static SCVal toInt64(long int64) {
+ return ScvInt64.toSCVal(int64);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_I64} to int64.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the int64
+ */
+ public static long fromInt64(SCVal scVal) {
+ return ScvInt64.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_I128}.
+ *
+ * @param int128 int128 to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_I128}
+ */
+ public static SCVal toInt128(BigInteger int128) {
+ return ScvInt128.toSCVal(int128);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_I128} to int128.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the int128
+ */
+ public static BigInteger fromInt128(SCVal scVal) {
+ return ScvInt128.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_I256}.
+ *
+ * @param int256 int256 to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_I256}
+ */
+ public static SCVal toInt256(BigInteger int256) {
+ return ScvInt256.toSCVal(int256);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_I256} to int256.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the int256
+ */
+ public static BigInteger fromInt256(SCVal scVal) {
+ return ScvInt256.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_LEDGER_KEY_NONCE}.
+ *
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_LEDGER_KEY_NONCE}
+ */
+ public static SCVal toLedgerKeyContractInstance() {
+ return ScvLedgerKeyContractInstance.toSCVal();
+ }
+
+ /**
+ * Parse from {@link SCVal} with the type of {@link SCValType#SCV_LEDGER_KEY_CONTRACT_INSTANCE},
+ * this function returns void if conversion succeeds.
+ *
+ * @param scVal {@link SCVal} to convert
+ */
+ public static void fromLedgerKeyContractInstance(SCVal scVal) {
+ ScvLedgerKeyContractInstance.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_LEDGER_KEY_NONCE}.
+ *
+ * @param nonce nonce to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_LEDGER_KEY_NONCE}
+ */
+ public static SCVal toLedgerKeyNonce(long nonce) {
+ return ScvLedgerKeyNonce.toSCVal(nonce);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_LEDGER_KEY_NONCE} to long.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the nonce
+ */
+ public static long fromLedgerKeyNonce(SCVal scVal) {
+ return ScvLedgerKeyNonce.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_MAP}.
+ *
+ * @param map map to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_MAP}
+ */
+ public static SCVal toMap(LinkedHashMap map) {
+ return ScvMap.toSCVal(map);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_MAP} to {@link Map}.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the map
+ */
+ public static LinkedHashMap fromMap(SCVal scVal) {
+ return ScvMap.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_STRING}.
+ *
+ * @param string string to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_STRING}
+ */
+ public static SCVal toString(String string) {
+ return ScvString.toSCVal(string.getBytes());
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_STRING}.
+ *
+ * @param string string to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_STRING}
+ */
+ public static SCVal toString(byte[] string) {
+ return ScvString.toSCVal(string);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_STRING} to String.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the string value in bytes
+ */
+ public static byte[] fromString(SCVal scVal) {
+ return ScvString.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_SYMBOL}.
+ *
+ * @param symbol symbol to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_SYMBOL}
+ */
+ public static SCVal toSymbol(String symbol) {
+ return ScvSymbol.toSCVal(symbol);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_SYMBOL} to String.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the symbol
+ */
+ public static String fromSymbol(SCVal scVal) {
+ return ScvSymbol.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_TIMEPOINT}.
+ *
+ * @param timePoint timePoint to convert (uint64)
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_TIMEPOINT}
+ */
+ public static SCVal toTimePoint(BigInteger timePoint) {
+ return ScvTimePoint.toSCVal(timePoint);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_TIMEPOINT} to {@link
+ * BigInteger}.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the timePoint (uint64)
+ */
+ public static BigInteger fromTimePoint(SCVal scVal) {
+ return ScvTimePoint.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_U32}.
+ *
+ * @param uint32 uint32 to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_U32}
+ */
+ public static SCVal toUint32(long uint32) {
+ return ScvUint32.toSCVal(uint32);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_U32} to int.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the uint32
+ */
+ public static long fromUint32(SCVal scVal) {
+ return ScvUint32.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_U64}.
+ *
+ * @param uint64 uint64 to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_U64}
+ */
+ public static SCVal toUint64(BigInteger uint64) {
+ return ScvUint64.toSCVal(uint64);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_U64} to {@link BigInteger}.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the uint64
+ */
+ public static BigInteger fromUint64(SCVal scVal) {
+ return ScvUint64.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_U128}.
+ *
+ * @param uint128 uint128 to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_U128}
+ */
+ public static SCVal toUint128(BigInteger uint128) {
+ return ScvUint128.toSCVal(uint128);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_U128} to {@link BigInteger}.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the uint128
+ */
+ public static BigInteger fromUint128(SCVal scVal) {
+ return ScvUint128.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_U256}.
+ *
+ * @param uint256 uint256 to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_U256}
+ */
+ public static SCVal toUint256(BigInteger uint256) {
+ return ScvUint256.toSCVal(uint256);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_U256} to {@link BigInteger}.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the uint256
+ */
+ public static BigInteger fromUint256(SCVal scVal) {
+ return ScvUint256.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_VEC}.
+ *
+ * @param vec vec to convert
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_VEC}
+ */
+ public static SCVal toVec(Collection vec) {
+ return ScvVec.toSCVal(vec);
+ }
+
+ /**
+ * Convert from {@link SCVal} with the type of {@link SCValType#SCV_VEC} to {@link Collection}.
+ *
+ * @param scVal {@link SCVal} to convert
+ * @return the vec
+ */
+ public static Collection fromVec(SCVal scVal) {
+ return ScvVec.fromSCVal(scVal);
+ }
+
+ /**
+ * Build a {@link SCVal} with the type of {@link SCValType#SCV_VOID}.
+ *
+ * @return {@link SCVal} with the type of {@link SCValType#SCV_VOID}
+ */
+ public static SCVal toVoid() {
+ return ScvVoid.toSCVal();
+ }
+
+ /**
+ * Parse from {@link SCVal} with the type of {@link SCValType#SCV_VOID}, this function returns
+ * void if conversion succeeds.
+ *
+ * @param scVal {@link SCVal} to convert
+ */
+ public static void fromVoid(SCVal scVal) {
+ ScvVoid.fromSCVal(scVal);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvAddress.java b/src/main/java/org/stellar/sdk/scval/ScvAddress.java
new file mode 100644
index 000000000..933f5cc1b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvAddress.java
@@ -0,0 +1,24 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.Address;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_ADDRESS}. */
+class ScvAddress {
+ private static final SCValType TYPE = SCValType.SCV_ADDRESS;
+
+ static SCVal toSCVal(Address value) {
+ return value.toSCVal();
+ }
+
+ static Address fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ return Address.fromSCVal(scVal);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvBoolean.java b/src/main/java/org/stellar/sdk/scval/ScvBoolean.java
new file mode 100644
index 000000000..a54067da2
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvBoolean.java
@@ -0,0 +1,23 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_BOOL}. */
+class ScvBoolean {
+ private static final SCValType TYPE = SCValType.SCV_BOOL;
+
+ static SCVal toSCVal(Boolean value) {
+ return new SCVal.Builder().discriminant(TYPE).b(value).build();
+ }
+
+ static boolean fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ return scVal.getB();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvBytes.java b/src/main/java/org/stellar/sdk/scval/ScvBytes.java
new file mode 100644
index 000000000..7a6c1c29f
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvBytes.java
@@ -0,0 +1,24 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.xdr.SCBytes;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_BYTES}. */
+class ScvBytes {
+ private static final SCValType TYPE = SCValType.SCV_BYTES;
+
+ static SCVal toSCVal(byte[] value) {
+ return new SCVal.Builder().discriminant(TYPE).bytes(new SCBytes(value)).build();
+ }
+
+ static byte[] fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ return scVal.getBytes().getSCBytes();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvContractInstance.java b/src/main/java/org/stellar/sdk/scval/ScvContractInstance.java
new file mode 100644
index 000000000..019837b7b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvContractInstance.java
@@ -0,0 +1,24 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.xdr.SCContractInstance;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_CONTRACT_INSTANCE}. */
+class ScvContractInstance {
+ private static final SCValType TYPE = SCValType.SCV_CONTRACT_INSTANCE;
+
+ static SCVal toSCVal(SCContractInstance value) {
+ return new SCVal.Builder().discriminant(TYPE).instance(value).build();
+ }
+
+ static SCContractInstance fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ return scVal.getInstance();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvDuration.java b/src/main/java/org/stellar/sdk/scval/ScvDuration.java
new file mode 100644
index 000000000..e9e55f26c
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvDuration.java
@@ -0,0 +1,36 @@
+package org.stellar.sdk.scval;
+
+import java.math.BigInteger;
+import org.stellar.sdk.xdr.Duration;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.Uint64;
+import org.stellar.sdk.xdr.XdrUnsignedHyperInteger;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_DURATION}. */
+class ScvDuration {
+ private static final SCValType TYPE = SCValType.SCV_DURATION;
+ private static final BigInteger MAX_VALUE = XdrUnsignedHyperInteger.MAX_VALUE;
+ private static final BigInteger MIN_VALUE = XdrUnsignedHyperInteger.MIN_VALUE;
+
+ static SCVal toSCVal(BigInteger value) {
+ if (value.compareTo(MIN_VALUE) < 0 || value.compareTo(MAX_VALUE) > 0) {
+ throw new IllegalArgumentException("Invalid Duration value, must be between 0 and 2^64-1");
+ }
+
+ return new SCVal.Builder()
+ .discriminant(TYPE)
+ .duration(new Duration(new Uint64(new XdrUnsignedHyperInteger(value))))
+ .build();
+ }
+
+ static BigInteger fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ return scVal.getDuration().getDuration().getUint64().getNumber();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvError.java b/src/main/java/org/stellar/sdk/scval/ScvError.java
new file mode 100644
index 000000000..0a1902e21
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvError.java
@@ -0,0 +1,24 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.xdr.SCError;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_ERROR}. */
+class ScvError {
+ private static final SCValType TYPE = SCValType.SCV_ERROR;
+
+ static SCVal toSCVal(SCError value) {
+ return new SCVal.Builder().discriminant(TYPE).error(value).build();
+ }
+
+ static SCError fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ return scVal.getError();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvInt128.java b/src/main/java/org/stellar/sdk/scval/ScvInt128.java
new file mode 100644
index 000000000..2326483e1
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvInt128.java
@@ -0,0 +1,69 @@
+package org.stellar.sdk.scval;
+
+import static org.stellar.sdk.Util.getBytes;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import org.stellar.sdk.xdr.Int128Parts;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.Uint64;
+import org.stellar.sdk.xdr.XdrUnsignedHyperInteger;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_I128}. */
+class ScvInt128 {
+ private static final SCValType TYPE = SCValType.SCV_I128;
+
+ private static final BigInteger MIN_VALUE = BigInteger.valueOf(-2).pow(127);
+ private static final BigInteger MAX_VALUE =
+ BigInteger.valueOf(2).pow(127).subtract(BigInteger.ONE);
+
+ static SCVal toSCVal(BigInteger value) {
+ if (value.compareTo(MIN_VALUE) < 0 || value.compareTo(MAX_VALUE) > 0) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid value, expected between %s and %s, but got %s",
+ MIN_VALUE, MAX_VALUE, value));
+ }
+
+ byte[] bytes = value.toByteArray();
+ byte[] paddedBytes = new byte[16];
+ if (value.signum() >= 0) {
+ int numBytesToCopy = Math.min(bytes.length, 16);
+ int copyStartIndex = bytes.length - numBytesToCopy;
+ System.arraycopy(bytes, copyStartIndex, paddedBytes, 16 - numBytesToCopy, numBytesToCopy);
+ } else {
+ Arrays.fill(paddedBytes, 0, 16 - bytes.length, (byte) 0xFF);
+ System.arraycopy(bytes, 0, paddedBytes, 16 - bytes.length, bytes.length);
+ }
+
+ Int128Parts int128Parts =
+ new Int128Parts.Builder()
+ .hi(new Int64(Longs.fromByteArray(Arrays.copyOfRange(paddedBytes, 0, 8))))
+ .lo(
+ new Uint64(
+ new XdrUnsignedHyperInteger(
+ new BigInteger(1, Arrays.copyOfRange(paddedBytes, 8, 16)))))
+ .build();
+ return new SCVal.Builder().discriminant(TYPE).i128(int128Parts).build();
+ }
+
+ static BigInteger fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ Int128Parts int128Parts = scVal.getI128();
+ byte[] hiBytes = Longs.toByteArray(int128Parts.getHi().getInt64());
+ byte[] loBytes = getBytes(int128Parts.getLo().getUint64().getNumber());
+
+ byte[] fullBytes = new byte[16];
+ System.arraycopy(hiBytes, 0, fullBytes, 0, 8);
+ System.arraycopy(loBytes, 0, fullBytes, 8, 8);
+
+ return new BigInteger(fullBytes);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvInt256.java b/src/main/java/org/stellar/sdk/scval/ScvInt256.java
new file mode 100644
index 000000000..2eab891b1
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvInt256.java
@@ -0,0 +1,82 @@
+package org.stellar.sdk.scval;
+
+import static org.stellar.sdk.Util.getBytes;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import org.stellar.sdk.xdr.Int256Parts;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.Uint64;
+import org.stellar.sdk.xdr.XdrUnsignedHyperInteger;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_I256}. */
+class ScvInt256 {
+ private static final SCValType TYPE = SCValType.SCV_I256;
+
+ private static final BigInteger MIN_VALUE = BigInteger.valueOf(-2).pow(255);
+ private static final BigInteger MAX_VALUE =
+ BigInteger.valueOf(2).pow(255).subtract(BigInteger.ONE);
+
+ static SCVal toSCVal(BigInteger value) {
+ if (value.compareTo(MIN_VALUE) < 0 || value.compareTo(MAX_VALUE) > 0) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid value, expected between %s and %s, but got %s",
+ MIN_VALUE, MAX_VALUE, value));
+ }
+
+ byte[] bytes = value.toByteArray();
+ byte[] paddedBytes = new byte[32];
+
+ if (value.signum() >= 0) {
+ int numBytesToCopy = Math.min(bytes.length, 32);
+ int copyStartIndex = bytes.length - numBytesToCopy;
+ System.arraycopy(bytes, copyStartIndex, paddedBytes, 32 - numBytesToCopy, numBytesToCopy);
+ } else {
+ Arrays.fill(paddedBytes, 0, 32 - bytes.length, (byte) 0xFF);
+ System.arraycopy(bytes, 0, paddedBytes, 32 - bytes.length, bytes.length);
+ }
+
+ Int256Parts int256Parts =
+ new Int256Parts.Builder()
+ .hi_hi(new Int64(Longs.fromByteArray(Arrays.copyOfRange(paddedBytes, 0, 8))))
+ .hi_lo(
+ new Uint64(
+ new XdrUnsignedHyperInteger(
+ new BigInteger(1, Arrays.copyOfRange(paddedBytes, 8, 16)))))
+ .lo_hi(
+ new Uint64(
+ new XdrUnsignedHyperInteger(
+ new BigInteger(1, Arrays.copyOfRange(paddedBytes, 16, 24)))))
+ .lo_lo(
+ new Uint64(
+ new XdrUnsignedHyperInteger(
+ new BigInteger(1, Arrays.copyOfRange(paddedBytes, 24, 32)))))
+ .build();
+ return new SCVal.Builder().discriminant(TYPE).i256(int256Parts).build();
+ }
+
+ static BigInteger fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ Int256Parts int256Parts = scVal.getI256();
+ byte[] hiHiBytes = Longs.toByteArray(int256Parts.getHi_hi().getInt64());
+ byte[] hiLoBytes = getBytes(int256Parts.getHi_lo().getUint64().getNumber());
+ byte[] loHiBytes = getBytes(int256Parts.getLo_hi().getUint64().getNumber());
+ byte[] loLoBytes = getBytes(int256Parts.getLo_lo().getUint64().getNumber());
+
+ byte[] fullBytes = new byte[32];
+ System.arraycopy(hiHiBytes, 0, fullBytes, 0, 8);
+ System.arraycopy(hiLoBytes, 0, fullBytes, 8, 8);
+ System.arraycopy(loHiBytes, 0, fullBytes, 16, 8);
+ System.arraycopy(loLoBytes, 0, fullBytes, 24, 8);
+
+ return new BigInteger(fullBytes);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvInt32.java b/src/main/java/org/stellar/sdk/scval/ScvInt32.java
new file mode 100644
index 000000000..228c8e90a
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvInt32.java
@@ -0,0 +1,24 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.xdr.Int32;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_I32}. */
+class ScvInt32 {
+ private static final SCValType TYPE = SCValType.SCV_I32;
+
+ static SCVal toSCVal(int value) {
+ return new SCVal.Builder().discriminant(TYPE).i32(new Int32(value)).build();
+ }
+
+ static int fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ return scVal.getI32().getInt32();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvInt64.java b/src/main/java/org/stellar/sdk/scval/ScvInt64.java
new file mode 100644
index 000000000..cb60936f2
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvInt64.java
@@ -0,0 +1,23 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_I64}. */
+class ScvInt64 {
+ private static final SCValType TYPE = SCValType.SCV_I64;
+
+ static SCVal toSCVal(long value) {
+ return new SCVal.Builder().discriminant(TYPE).i64(new Int64(value)).build();
+ }
+
+ static long fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+ return scVal.getI64().getInt64();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvLedgerKeyContractInstance.java b/src/main/java/org/stellar/sdk/scval/ScvLedgerKeyContractInstance.java
new file mode 100644
index 000000000..b73d4b18e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvLedgerKeyContractInstance.java
@@ -0,0 +1,21 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_CONTRACT_INSTANCE}. */
+class ScvLedgerKeyContractInstance {
+ private static final SCValType TYPE = SCValType.SCV_LEDGER_KEY_CONTRACT_INSTANCE;
+
+ static SCVal toSCVal() {
+ return new SCVal.Builder().discriminant(TYPE).build();
+ }
+
+ static void fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvLedgerKeyNonce.java b/src/main/java/org/stellar/sdk/scval/ScvLedgerKeyNonce.java
new file mode 100644
index 000000000..e3cbc89dc
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvLedgerKeyNonce.java
@@ -0,0 +1,27 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.SCNonceKey;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_LEDGER_KEY_NONCE}. */
+class ScvLedgerKeyNonce {
+ private static final SCValType TYPE = SCValType.SCV_LEDGER_KEY_NONCE;
+
+ static SCVal toSCVal(long value) {
+ return new SCVal.Builder()
+ .discriminant(TYPE)
+ .nonce_key(new SCNonceKey.Builder().nonce(new Int64(value)).build())
+ .build();
+ }
+
+ static long fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+ return scVal.getNonce_key().getNonce().getInt64();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvMap.java b/src/main/java/org/stellar/sdk/scval/ScvMap.java
new file mode 100644
index 000000000..c94cd0ed2
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvMap.java
@@ -0,0 +1,39 @@
+package org.stellar.sdk.scval;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.stellar.sdk.xdr.SCMap;
+import org.stellar.sdk.xdr.SCMapEntry;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_MAP}. */
+class ScvMap {
+ private static final SCValType TYPE = SCValType.SCV_MAP;
+
+ // we want to keep the order of the map entries
+ // this ensures that the generated XDR is deterministic.
+ static SCVal toSCVal(LinkedHashMap value) {
+ SCMapEntry[] scMapEntries = new SCMapEntry[value.size()];
+ int i = 0;
+ for (Map.Entry entry : value.entrySet()) {
+ scMapEntries[i++] =
+ new SCMapEntry.Builder().key(entry.getKey()).val(entry.getValue()).build();
+ }
+ return new SCVal.Builder().discriminant(TYPE).map(new SCMap(scMapEntries)).build();
+ }
+
+ static LinkedHashMap fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ LinkedHashMap map = new LinkedHashMap<>();
+ for (SCMapEntry entry : scVal.getMap().getSCMap()) {
+ map.put(entry.getKey(), entry.getVal());
+ }
+ return map;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvString.java b/src/main/java/org/stellar/sdk/scval/ScvString.java
new file mode 100644
index 000000000..8678c79ec
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvString.java
@@ -0,0 +1,25 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.xdr.SCString;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.XdrString;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_STRING}. */
+class ScvString {
+ private static final SCValType TYPE = SCValType.SCV_STRING;
+
+ static SCVal toSCVal(byte[] value) {
+ return new SCVal.Builder().discriminant(TYPE).str(new SCString(new XdrString(value))).build();
+ }
+
+ static byte[] fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ return scVal.getStr().getSCString().getBytes();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvSymbol.java b/src/main/java/org/stellar/sdk/scval/ScvSymbol.java
new file mode 100644
index 000000000..57d719b16
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvSymbol.java
@@ -0,0 +1,24 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.xdr.SCSymbol;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.XdrString;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_SYMBOL}. */
+class ScvSymbol {
+ private static final SCValType TYPE = SCValType.SCV_SYMBOL;
+
+ static SCVal toSCVal(String value) {
+ return new SCVal.Builder().discriminant(TYPE).sym(new SCSymbol(new XdrString(value))).build();
+ }
+
+ static String fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+ return scVal.getSym().getSCSymbol().toString();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvTimePoint.java b/src/main/java/org/stellar/sdk/scval/ScvTimePoint.java
new file mode 100644
index 000000000..065c31f86
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvTimePoint.java
@@ -0,0 +1,39 @@
+package org.stellar.sdk.scval;
+
+import java.math.BigInteger;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.TimePoint;
+import org.stellar.sdk.xdr.Uint64;
+import org.stellar.sdk.xdr.XdrUnsignedHyperInteger;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_TIMEPOINT}. */
+class ScvTimePoint {
+ private static final SCValType TYPE = SCValType.SCV_TIMEPOINT;
+
+ private static final BigInteger MAX_VALUE = XdrUnsignedHyperInteger.MAX_VALUE;
+ private static final BigInteger MIN_VALUE = XdrUnsignedHyperInteger.MIN_VALUE;
+
+ static SCVal toSCVal(BigInteger value) {
+ if (value.compareTo(MIN_VALUE) < 0 || value.compareTo(MAX_VALUE) > 0) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid value, expected between %s and %s, but got %s",
+ MIN_VALUE, MAX_VALUE, value));
+ }
+
+ return new SCVal.Builder()
+ .discriminant(TYPE)
+ .timepoint(new TimePoint(new Uint64(new XdrUnsignedHyperInteger(value))))
+ .build();
+ }
+
+ static BigInteger fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+ return scVal.getTimepoint().getTimePoint().getUint64().getNumber();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvUint128.java b/src/main/java/org/stellar/sdk/scval/ScvUint128.java
new file mode 100644
index 000000000..55a9b794e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvUint128.java
@@ -0,0 +1,66 @@
+package org.stellar.sdk.scval;
+
+import static org.stellar.sdk.Util.getBytes;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.UInt128Parts;
+import org.stellar.sdk.xdr.Uint64;
+import org.stellar.sdk.xdr.XdrUnsignedHyperInteger;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_I32}. */
+class ScvUint128 {
+ private static final SCValType TYPE = SCValType.SCV_U128;
+
+ private static final BigInteger MIN_VALUE = BigInteger.ZERO;
+ private static final BigInteger MAX_VALUE =
+ BigInteger.valueOf(2).pow(128).subtract(BigInteger.ONE);
+
+ static SCVal toSCVal(BigInteger value) {
+ if (value.compareTo(MIN_VALUE) < 0 || value.compareTo(MAX_VALUE) > 0) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid value, expected between %s and %s, but got %s",
+ MIN_VALUE, MAX_VALUE, value));
+ }
+
+ byte[] bytes = value.toByteArray();
+ byte[] paddedBytes = new byte[16];
+ int numBytesToCopy = Math.min(bytes.length, 16);
+ int copyStartIndex = bytes.length - numBytesToCopy;
+ System.arraycopy(bytes, copyStartIndex, paddedBytes, 16 - numBytesToCopy, numBytesToCopy);
+
+ UInt128Parts uInt128Parts =
+ new UInt128Parts.Builder()
+ .hi(
+ new Uint64(
+ new XdrUnsignedHyperInteger(
+ new BigInteger(1, Arrays.copyOfRange(paddedBytes, 0, 8)))))
+ .lo(
+ new Uint64(
+ new XdrUnsignedHyperInteger(
+ new BigInteger(1, Arrays.copyOfRange(paddedBytes, 8, 16)))))
+ .build();
+ return new SCVal.Builder().discriminant(TYPE).u128(uInt128Parts).build();
+ }
+
+ static BigInteger fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ UInt128Parts uInt128Parts = scVal.getU128();
+ byte[] hiBytes = getBytes(uInt128Parts.getHi().getUint64().getNumber());
+ byte[] loBytes = getBytes(uInt128Parts.getLo().getUint64().getNumber());
+
+ byte[] fullBytes = new byte[16];
+ System.arraycopy(hiBytes, 0, fullBytes, 0, 8);
+ System.arraycopy(loBytes, 0, fullBytes, 8, 8);
+
+ return new BigInteger(1, fullBytes);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvUint256.java b/src/main/java/org/stellar/sdk/scval/ScvUint256.java
new file mode 100644
index 000000000..901b64d16
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvUint256.java
@@ -0,0 +1,78 @@
+package org.stellar.sdk.scval;
+
+import static org.stellar.sdk.Util.getBytes;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.UInt256Parts;
+import org.stellar.sdk.xdr.Uint64;
+import org.stellar.sdk.xdr.XdrUnsignedHyperInteger;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_U256}. */
+class ScvUint256 {
+ private static final SCValType TYPE = SCValType.SCV_U256;
+
+ private static final BigInteger MIN_VALUE = BigInteger.ZERO;
+ private static final BigInteger MAX_VALUE =
+ BigInteger.valueOf(2).pow(256).subtract(BigInteger.ONE);
+
+ static SCVal toSCVal(BigInteger value) {
+ if (value.compareTo(MIN_VALUE) < 0 || value.compareTo(MAX_VALUE) > 0) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid value, expected between %s and %s, but got %s",
+ MIN_VALUE, MAX_VALUE, value));
+ }
+
+ byte[] bytes = value.toByteArray();
+ byte[] paddedBytes = new byte[32];
+ int numBytesToCopy = Math.min(bytes.length, 32);
+ int copyStartIndex = bytes.length - numBytesToCopy;
+ System.arraycopy(bytes, copyStartIndex, paddedBytes, 32 - numBytesToCopy, numBytesToCopy);
+
+ UInt256Parts uInt256Parts =
+ new UInt256Parts.Builder()
+ .hi_hi(
+ new Uint64(
+ new XdrUnsignedHyperInteger(
+ new BigInteger(1, Arrays.copyOfRange(paddedBytes, 0, 8)))))
+ .hi_lo(
+ new Uint64(
+ new XdrUnsignedHyperInteger(
+ new BigInteger(1, Arrays.copyOfRange(paddedBytes, 8, 16)))))
+ .lo_hi(
+ new Uint64(
+ new XdrUnsignedHyperInteger(
+ new BigInteger(1, Arrays.copyOfRange(paddedBytes, 16, 24)))))
+ .lo_lo(
+ new Uint64(
+ new XdrUnsignedHyperInteger(
+ new BigInteger(1, Arrays.copyOfRange(paddedBytes, 24, 32)))))
+ .build();
+ return new SCVal.Builder().discriminant(TYPE).u256(uInt256Parts).build();
+ }
+
+ static BigInteger fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ UInt256Parts uInt256Parts = scVal.getU256();
+ byte[] hiHiBytes = getBytes(uInt256Parts.getHi_hi().getUint64().getNumber());
+ byte[] hiLoBytes = getBytes(uInt256Parts.getHi_lo().getUint64().getNumber());
+ byte[] loHiBytes = getBytes(uInt256Parts.getLo_hi().getUint64().getNumber());
+ byte[] loLoBytes = getBytes(uInt256Parts.getLo_lo().getUint64().getNumber());
+
+ byte[] fullBytes = new byte[32];
+ System.arraycopy(hiHiBytes, 0, fullBytes, 0, 8);
+ System.arraycopy(hiLoBytes, 0, fullBytes, 8, 8);
+ System.arraycopy(loHiBytes, 0, fullBytes, 16, 8);
+ System.arraycopy(loLoBytes, 0, fullBytes, 24, 8);
+
+ return new BigInteger(1, fullBytes);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvUint32.java b/src/main/java/org/stellar/sdk/scval/ScvUint32.java
new file mode 100644
index 000000000..bfd5e95cc
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvUint32.java
@@ -0,0 +1,38 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.Uint32;
+import org.stellar.sdk.xdr.XdrUnsignedInteger;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_U32}. */
+class ScvUint32 {
+ private static final SCValType TYPE = SCValType.SCV_U32;
+
+ private static final long MAX_VALUE = XdrUnsignedInteger.MAX_VALUE;
+ private static final long MIN_VALUE = XdrUnsignedInteger.MIN_VALUE;
+
+ static SCVal toSCVal(long value) {
+ if (value < MIN_VALUE || value > MAX_VALUE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid value, expected between %s and %s, but got %s",
+ MIN_VALUE, MAX_VALUE, value));
+ }
+
+ return new SCVal.Builder()
+ .discriminant(TYPE)
+ .u32(new Uint32(new XdrUnsignedInteger(value)))
+ .build();
+ }
+
+ static long fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ return scVal.getU32().getUint32().getNumber();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvUint64.java b/src/main/java/org/stellar/sdk/scval/ScvUint64.java
new file mode 100644
index 000000000..725dd6786
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvUint64.java
@@ -0,0 +1,38 @@
+package org.stellar.sdk.scval;
+
+import java.math.BigInteger;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.Uint64;
+import org.stellar.sdk.xdr.XdrUnsignedHyperInteger;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_U64}. */
+class ScvUint64 {
+ private static final SCValType TYPE = SCValType.SCV_U64;
+
+ private static final BigInteger MAX_VALUE = XdrUnsignedHyperInteger.MAX_VALUE;
+ private static final BigInteger MIN_VALUE = XdrUnsignedHyperInteger.MIN_VALUE;
+
+ static SCVal toSCVal(BigInteger value) {
+ if (value.compareTo(MIN_VALUE) < 0 || value.compareTo(MAX_VALUE) > 0) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid value, expected between %s and %s, but got %s",
+ MIN_VALUE, MAX_VALUE, value));
+ }
+
+ return new SCVal.Builder()
+ .discriminant(TYPE)
+ .u64(new Uint64(new XdrUnsignedHyperInteger(value)))
+ .build();
+ }
+
+ static BigInteger fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+ return scVal.getU64().getUint64().getNumber();
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvVec.java b/src/main/java/org/stellar/sdk/scval/ScvVec.java
new file mode 100644
index 000000000..58e676c7f
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvVec.java
@@ -0,0 +1,30 @@
+package org.stellar.sdk.scval;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.SCVec;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_VEC}. */
+class ScvVec {
+ private static final SCValType TYPE = SCValType.SCV_VEC;
+
+ static SCVal toSCVal(Collection value) {
+ return new SCVal.Builder()
+ .discriminant(TYPE)
+ .vec(new SCVec(value.toArray(new SCVal[0])))
+ .build();
+ }
+
+ static List fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+
+ return Arrays.asList(scVal.getVec().getSCVec());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/ScvVoid.java b/src/main/java/org/stellar/sdk/scval/ScvVoid.java
new file mode 100644
index 000000000..132e163a7
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/ScvVoid.java
@@ -0,0 +1,21 @@
+package org.stellar.sdk.scval;
+
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+/** Represents an {@link SCVal} with the type of {@link SCValType#SCV_VOID}. */
+class ScvVoid {
+ private static final SCValType TYPE = SCValType.SCV_VOID;
+
+ static SCVal toSCVal() {
+ return new SCVal.Builder().discriminant(TYPE).build();
+ }
+
+ static void fromSCVal(SCVal scVal) {
+ if (scVal.getDiscriminant() != TYPE) {
+ throw new IllegalArgumentException(
+ String.format(
+ "invalid scVal type, expected %s, but got %s", TYPE, scVal.getDiscriminant()));
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/scval/package-info.java b/src/main/java/org/stellar/sdk/scval/package-info.java
new file mode 100644
index 000000000..d6f1d5b56
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/scval/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * {@link org.stellar.sdk.scval.Scv} provides a range of methods to help you build and parse {@link
+ * org.stellar.sdk.xdr.SCVal} more conveniently.
+ */
+package org.stellar.sdk.scval;
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountEntry.java b/src/main/java/org/stellar/sdk/xdr/AccountEntry.java
index d5556d60b..f72f77fe0 100644
--- a/src/main/java/org/stellar/sdk/xdr/AccountEntry.java
+++ b/src/main/java/org/stellar/sdk/xdr/AccountEntry.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -193,7 +198,7 @@ public static AccountEntry decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.accountID,
this.balance,
this.seqNum,
@@ -213,16 +218,40 @@ public boolean equals(Object object) {
}
AccountEntry other = (AccountEntry) object;
- return Objects.equal(this.accountID, other.accountID)
- && Objects.equal(this.balance, other.balance)
- && Objects.equal(this.seqNum, other.seqNum)
- && Objects.equal(this.numSubEntries, other.numSubEntries)
- && Objects.equal(this.inflationDest, other.inflationDest)
- && Objects.equal(this.flags, other.flags)
- && Objects.equal(this.homeDomain, other.homeDomain)
- && Objects.equal(this.thresholds, other.thresholds)
+ return Objects.equals(this.accountID, other.accountID)
+ && Objects.equals(this.balance, other.balance)
+ && Objects.equals(this.seqNum, other.seqNum)
+ && Objects.equals(this.numSubEntries, other.numSubEntries)
+ && Objects.equals(this.inflationDest, other.inflationDest)
+ && Objects.equals(this.flags, other.flags)
+ && Objects.equals(this.homeDomain, other.homeDomain)
+ && Objects.equals(this.thresholds, other.thresholds)
&& Arrays.equals(this.signers, other.signers)
- && Objects.equal(this.ext, other.ext);
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AccountEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AccountEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -289,21 +318,21 @@ public Builder ext(AccountEntryExt ext) {
public AccountEntry build() {
AccountEntry val = new AccountEntry();
- val.setAccountID(accountID);
- val.setBalance(balance);
- val.setSeqNum(seqNum);
- val.setNumSubEntries(numSubEntries);
- val.setInflationDest(inflationDest);
- val.setFlags(flags);
- val.setHomeDomain(homeDomain);
- val.setThresholds(thresholds);
- val.setSigners(signers);
- val.setExt(ext);
+ val.setAccountID(this.accountID);
+ val.setBalance(this.balance);
+ val.setSeqNum(this.seqNum);
+ val.setNumSubEntries(this.numSubEntries);
+ val.setInflationDest(this.inflationDest);
+ val.setFlags(this.flags);
+ val.setHomeDomain(this.homeDomain);
+ val.setThresholds(this.thresholds);
+ val.setSigners(this.signers);
+ val.setExt(this.ext);
return val;
}
}
- public static class AccountEntryExt {
+ public static class AccountEntryExt implements XdrElement {
public AccountEntryExt() {}
Integer v;
@@ -343,7 +372,7 @@ public Builder v1(AccountEntryExtensionV1 v1) {
public AccountEntryExt build() {
AccountEntryExt val = new AccountEntryExt();
val.setDiscriminant(discriminant);
- val.setV1(v1);
+ val.setV1(this.v1);
return val;
}
}
@@ -382,7 +411,7 @@ public static AccountEntryExt decode(XdrDataInputStream stream) throws IOExcepti
@Override
public int hashCode() {
- return Objects.hashCode(this.v1, this.v);
+ return Objects.hash(this.v1, this.v);
}
@Override
@@ -392,7 +421,31 @@ public boolean equals(Object object) {
}
AccountEntryExt other = (AccountEntryExt) object;
- return Objects.equal(this.v1, other.v1) && Objects.equal(this.v, other.v);
+ return Objects.equals(this.v1, other.v1) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AccountEntryExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AccountEntryExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountEntryExtensionV1.java b/src/main/java/org/stellar/sdk/xdr/AccountEntryExtensionV1.java
index 2388a5656..ee43a5559 100644
--- a/src/main/java/org/stellar/sdk/xdr/AccountEntryExtensionV1.java
+++ b/src/main/java/org/stellar/sdk/xdr/AccountEntryExtensionV1.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -66,7 +71,7 @@ public static AccountEntryExtensionV1 decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(this.liabilities, this.ext);
+ return Objects.hash(this.liabilities, this.ext);
}
@Override
@@ -76,7 +81,32 @@ public boolean equals(Object object) {
}
AccountEntryExtensionV1 other = (AccountEntryExtensionV1) object;
- return Objects.equal(this.liabilities, other.liabilities) && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.liabilities, other.liabilities)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AccountEntryExtensionV1 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AccountEntryExtensionV1 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -95,13 +125,13 @@ public Builder ext(AccountEntryExtensionV1Ext ext) {
public AccountEntryExtensionV1 build() {
AccountEntryExtensionV1 val = new AccountEntryExtensionV1();
- val.setLiabilities(liabilities);
- val.setExt(ext);
+ val.setLiabilities(this.liabilities);
+ val.setExt(this.ext);
return val;
}
}
- public static class AccountEntryExtensionV1Ext {
+ public static class AccountEntryExtensionV1Ext implements XdrElement {
public AccountEntryExtensionV1Ext() {}
Integer v;
@@ -141,7 +171,7 @@ public Builder v2(AccountEntryExtensionV2 v2) {
public AccountEntryExtensionV1Ext build() {
AccountEntryExtensionV1Ext val = new AccountEntryExtensionV1Ext();
val.setDiscriminant(discriminant);
- val.setV2(v2);
+ val.setV2(this.v2);
return val;
}
}
@@ -182,7 +212,7 @@ public static AccountEntryExtensionV1Ext decode(XdrDataInputStream stream) throw
@Override
public int hashCode() {
- return Objects.hashCode(this.v2, this.v);
+ return Objects.hash(this.v2, this.v);
}
@Override
@@ -192,7 +222,31 @@ public boolean equals(Object object) {
}
AccountEntryExtensionV1Ext other = (AccountEntryExtensionV1Ext) object;
- return Objects.equal(this.v2, other.v2) && Objects.equal(this.v, other.v);
+ return Objects.equals(this.v2, other.v2) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AccountEntryExtensionV1Ext fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AccountEntryExtensionV1Ext fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountEntryExtensionV2.java b/src/main/java/org/stellar/sdk/xdr/AccountEntryExtensionV2.java
index f93e9f4ae..1a87cd4e8 100644
--- a/src/main/java/org/stellar/sdk/xdr/AccountEntryExtensionV2.java
+++ b/src/main/java/org/stellar/sdk/xdr/AccountEntryExtensionV2.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -102,7 +107,7 @@ public static AccountEntryExtensionV2 decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.numSponsored, this.numSponsoring, Arrays.hashCode(this.signerSponsoringIDs), this.ext);
}
@@ -113,10 +118,34 @@ public boolean equals(Object object) {
}
AccountEntryExtensionV2 other = (AccountEntryExtensionV2) object;
- return Objects.equal(this.numSponsored, other.numSponsored)
- && Objects.equal(this.numSponsoring, other.numSponsoring)
+ return Objects.equals(this.numSponsored, other.numSponsored)
+ && Objects.equals(this.numSponsoring, other.numSponsoring)
&& Arrays.equals(this.signerSponsoringIDs, other.signerSponsoringIDs)
- && Objects.equal(this.ext, other.ext);
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AccountEntryExtensionV2 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AccountEntryExtensionV2 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -147,15 +176,15 @@ public Builder ext(AccountEntryExtensionV2Ext ext) {
public AccountEntryExtensionV2 build() {
AccountEntryExtensionV2 val = new AccountEntryExtensionV2();
- val.setNumSponsored(numSponsored);
- val.setNumSponsoring(numSponsoring);
- val.setSignerSponsoringIDs(signerSponsoringIDs);
- val.setExt(ext);
+ val.setNumSponsored(this.numSponsored);
+ val.setNumSponsoring(this.numSponsoring);
+ val.setSignerSponsoringIDs(this.signerSponsoringIDs);
+ val.setExt(this.ext);
return val;
}
}
- public static class AccountEntryExtensionV2Ext {
+ public static class AccountEntryExtensionV2Ext implements XdrElement {
public AccountEntryExtensionV2Ext() {}
Integer v;
@@ -195,7 +224,7 @@ public Builder v3(AccountEntryExtensionV3 v3) {
public AccountEntryExtensionV2Ext build() {
AccountEntryExtensionV2Ext val = new AccountEntryExtensionV2Ext();
val.setDiscriminant(discriminant);
- val.setV3(v3);
+ val.setV3(this.v3);
return val;
}
}
@@ -236,7 +265,7 @@ public static AccountEntryExtensionV2Ext decode(XdrDataInputStream stream) throw
@Override
public int hashCode() {
- return Objects.hashCode(this.v3, this.v);
+ return Objects.hash(this.v3, this.v);
}
@Override
@@ -246,7 +275,31 @@ public boolean equals(Object object) {
}
AccountEntryExtensionV2Ext other = (AccountEntryExtensionV2Ext) object;
- return Objects.equal(this.v3, other.v3) && Objects.equal(this.v, other.v);
+ return Objects.equals(this.v3, other.v3) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AccountEntryExtensionV2Ext fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AccountEntryExtensionV2Ext fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountEntryExtensionV3.java b/src/main/java/org/stellar/sdk/xdr/AccountEntryExtensionV3.java
index bbaf78e95..d6c54dca4 100644
--- a/src/main/java/org/stellar/sdk/xdr/AccountEntryExtensionV3.java
+++ b/src/main/java/org/stellar/sdk/xdr/AccountEntryExtensionV3.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -77,7 +82,7 @@ public static AccountEntryExtensionV3 decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(this.ext, this.seqLedger, this.seqTime);
+ return Objects.hash(this.ext, this.seqLedger, this.seqTime);
}
@Override
@@ -87,9 +92,33 @@ public boolean equals(Object object) {
}
AccountEntryExtensionV3 other = (AccountEntryExtensionV3) object;
- return Objects.equal(this.ext, other.ext)
- && Objects.equal(this.seqLedger, other.seqLedger)
- && Objects.equal(this.seqTime, other.seqTime);
+ return Objects.equals(this.ext, other.ext)
+ && Objects.equals(this.seqLedger, other.seqLedger)
+ && Objects.equals(this.seqTime, other.seqTime);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AccountEntryExtensionV3 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AccountEntryExtensionV3 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -114,9 +143,9 @@ public Builder seqTime(TimePoint seqTime) {
public AccountEntryExtensionV3 build() {
AccountEntryExtensionV3 val = new AccountEntryExtensionV3();
- val.setExt(ext);
- val.setSeqLedger(seqLedger);
- val.setSeqTime(seqTime);
+ val.setExt(this.ext);
+ val.setSeqLedger(this.seqLedger);
+ val.setSeqTime(this.seqTime);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountFlags.java b/src/main/java/org/stellar/sdk/xdr/AccountFlags.java
index 26afe0fc5..b1b7bb8fd 100644
--- a/src/main/java/org/stellar/sdk/xdr/AccountFlags.java
+++ b/src/main/java/org/stellar/sdk/xdr/AccountFlags.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -65,4 +70,28 @@ public static void encode(XdrDataOutputStream stream, AccountFlags value) throws
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AccountFlags fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AccountFlags fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountID.java b/src/main/java/org/stellar/sdk/xdr/AccountID.java
index 5c41c8183..554de2924 100644
--- a/src/main/java/org/stellar/sdk/xdr/AccountID.java
+++ b/src/main/java/org/stellar/sdk/xdr/AccountID.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -45,7 +50,7 @@ public static AccountID decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.AccountID);
+ return Objects.hash(this.AccountID);
}
@Override
@@ -55,6 +60,30 @@ public boolean equals(Object object) {
}
AccountID other = (AccountID) object;
- return Objects.equal(this.AccountID, other.AccountID);
+ return Objects.equals(this.AccountID, other.AccountID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AccountID fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AccountID fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountMergeResult.java b/src/main/java/org/stellar/sdk/xdr/AccountMergeResult.java
index d73f67bfc..91beb0805 100644
--- a/src/main/java/org/stellar/sdk/xdr/AccountMergeResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/AccountMergeResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,13 @@
// {
// case ACCOUNT_MERGE_SUCCESS:
// int64 sourceAccountBalance; // how much got transferred from source account
-// default:
+// case ACCOUNT_MERGE_MALFORMED:
+// case ACCOUNT_MERGE_NO_ACCOUNT:
+// case ACCOUNT_MERGE_IMMUTABLE_SET:
+// case ACCOUNT_MERGE_HAS_SUB_ENTRIES:
+// case ACCOUNT_MERGE_SEQNUM_TOO_FAR:
+// case ACCOUNT_MERGE_DEST_FULL:
+// case ACCOUNT_MERGE_IS_SPONSOR:
// void;
// };
@@ -57,7 +68,7 @@ public Builder sourceAccountBalance(Int64 sourceAccountBalance) {
public AccountMergeResult build() {
AccountMergeResult val = new AccountMergeResult();
val.setDiscriminant(discriminant);
- val.setSourceAccountBalance(sourceAccountBalance);
+ val.setSourceAccountBalance(this.sourceAccountBalance);
return val;
}
}
@@ -71,7 +82,13 @@ public static void encode(
case ACCOUNT_MERGE_SUCCESS:
Int64.encode(stream, encodedAccountMergeResult.sourceAccountBalance);
break;
- default:
+ case ACCOUNT_MERGE_MALFORMED:
+ case ACCOUNT_MERGE_NO_ACCOUNT:
+ case ACCOUNT_MERGE_IMMUTABLE_SET:
+ case ACCOUNT_MERGE_HAS_SUB_ENTRIES:
+ case ACCOUNT_MERGE_SEQNUM_TOO_FAR:
+ case ACCOUNT_MERGE_DEST_FULL:
+ case ACCOUNT_MERGE_IS_SPONSOR:
break;
}
}
@@ -88,7 +105,13 @@ public static AccountMergeResult decode(XdrDataInputStream stream) throws IOExce
case ACCOUNT_MERGE_SUCCESS:
decodedAccountMergeResult.sourceAccountBalance = Int64.decode(stream);
break;
- default:
+ case ACCOUNT_MERGE_MALFORMED:
+ case ACCOUNT_MERGE_NO_ACCOUNT:
+ case ACCOUNT_MERGE_IMMUTABLE_SET:
+ case ACCOUNT_MERGE_HAS_SUB_ENTRIES:
+ case ACCOUNT_MERGE_SEQNUM_TOO_FAR:
+ case ACCOUNT_MERGE_DEST_FULL:
+ case ACCOUNT_MERGE_IS_SPONSOR:
break;
}
return decodedAccountMergeResult;
@@ -96,7 +119,7 @@ public static AccountMergeResult decode(XdrDataInputStream stream) throws IOExce
@Override
public int hashCode() {
- return Objects.hashCode(this.sourceAccountBalance, this.code);
+ return Objects.hash(this.sourceAccountBalance, this.code);
}
@Override
@@ -106,7 +129,31 @@ public boolean equals(Object object) {
}
AccountMergeResult other = (AccountMergeResult) object;
- return Objects.equal(this.sourceAccountBalance, other.sourceAccountBalance)
- && Objects.equal(this.code, other.code);
+ return Objects.equals(this.sourceAccountBalance, other.sourceAccountBalance)
+ && Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AccountMergeResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AccountMergeResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountMergeResultCode.java b/src/main/java/org/stellar/sdk/xdr/AccountMergeResultCode.java
index 820c37c32..65222dfb7 100644
--- a/src/main/java/org/stellar/sdk/xdr/AccountMergeResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/AccountMergeResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -75,4 +80,28 @@ public static void encode(XdrDataOutputStream stream, AccountMergeResultCode val
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AccountMergeResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AccountMergeResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AllowTrustOp.java b/src/main/java/org/stellar/sdk/xdr/AllowTrustOp.java
index d647e019d..ae10e0d27 100644
--- a/src/main/java/org/stellar/sdk/xdr/AllowTrustOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/AllowTrustOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -72,7 +77,7 @@ public static AllowTrustOp decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(this.trustor, this.asset, this.authorize);
+ return Objects.hash(this.trustor, this.asset, this.authorize);
}
@Override
@@ -82,9 +87,33 @@ public boolean equals(Object object) {
}
AllowTrustOp other = (AllowTrustOp) object;
- return Objects.equal(this.trustor, other.trustor)
- && Objects.equal(this.asset, other.asset)
- && Objects.equal(this.authorize, other.authorize);
+ return Objects.equals(this.trustor, other.trustor)
+ && Objects.equals(this.asset, other.asset)
+ && Objects.equals(this.authorize, other.authorize);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AllowTrustOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AllowTrustOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -109,9 +138,9 @@ public Builder authorize(Uint32 authorize) {
public AllowTrustOp build() {
AllowTrustOp val = new AllowTrustOp();
- val.setTrustor(trustor);
- val.setAsset(asset);
- val.setAuthorize(authorize);
+ val.setTrustor(this.trustor);
+ val.setAsset(this.asset);
+ val.setAuthorize(this.authorize);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AllowTrustResult.java b/src/main/java/org/stellar/sdk/xdr/AllowTrustResult.java
index 6c2e5e55e..a492b1f5f 100644
--- a/src/main/java/org/stellar/sdk/xdr/AllowTrustResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/AllowTrustResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,12 @@
// {
// case ALLOW_TRUST_SUCCESS:
// void;
-// default:
+// case ALLOW_TRUST_MALFORMED:
+// case ALLOW_TRUST_NO_TRUST_LINE:
+// case ALLOW_TRUST_TRUST_NOT_REQUIRED:
+// case ALLOW_TRUST_CANT_REVOKE:
+// case ALLOW_TRUST_SELF_NOT_ALLOWED:
+// case ALLOW_TRUST_LOW_RESERVE:
// void;
// };
@@ -53,7 +63,12 @@ public static void encode(XdrDataOutputStream stream, AllowTrustResult encodedAl
switch (encodedAllowTrustResult.getDiscriminant()) {
case ALLOW_TRUST_SUCCESS:
break;
- default:
+ case ALLOW_TRUST_MALFORMED:
+ case ALLOW_TRUST_NO_TRUST_LINE:
+ case ALLOW_TRUST_TRUST_NOT_REQUIRED:
+ case ALLOW_TRUST_CANT_REVOKE:
+ case ALLOW_TRUST_SELF_NOT_ALLOWED:
+ case ALLOW_TRUST_LOW_RESERVE:
break;
}
}
@@ -69,7 +84,12 @@ public static AllowTrustResult decode(XdrDataInputStream stream) throws IOExcept
switch (decodedAllowTrustResult.getDiscriminant()) {
case ALLOW_TRUST_SUCCESS:
break;
- default:
+ case ALLOW_TRUST_MALFORMED:
+ case ALLOW_TRUST_NO_TRUST_LINE:
+ case ALLOW_TRUST_TRUST_NOT_REQUIRED:
+ case ALLOW_TRUST_CANT_REVOKE:
+ case ALLOW_TRUST_SELF_NOT_ALLOWED:
+ case ALLOW_TRUST_LOW_RESERVE:
break;
}
return decodedAllowTrustResult;
@@ -77,7 +97,7 @@ public static AllowTrustResult decode(XdrDataInputStream stream) throws IOExcept
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -87,6 +107,30 @@ public boolean equals(Object object) {
}
AllowTrustResult other = (AllowTrustResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AllowTrustResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AllowTrustResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AllowTrustResultCode.java b/src/main/java/org/stellar/sdk/xdr/AllowTrustResultCode.java
index 0296499aa..801a1206b 100644
--- a/src/main/java/org/stellar/sdk/xdr/AllowTrustResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/AllowTrustResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -72,4 +77,28 @@ public static void encode(XdrDataOutputStream stream, AllowTrustResultCode value
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AllowTrustResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AllowTrustResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AlphaNum12.java b/src/main/java/org/stellar/sdk/xdr/AlphaNum12.java
index 66b549d84..464a309ba 100644
--- a/src/main/java/org/stellar/sdk/xdr/AlphaNum12.java
+++ b/src/main/java/org/stellar/sdk/xdr/AlphaNum12.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -57,7 +62,7 @@ public static AlphaNum12 decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.assetCode, this.issuer);
+ return Objects.hash(this.assetCode, this.issuer);
}
@Override
@@ -67,8 +72,32 @@ public boolean equals(Object object) {
}
AlphaNum12 other = (AlphaNum12) object;
- return Objects.equal(this.assetCode, other.assetCode)
- && Objects.equal(this.issuer, other.issuer);
+ return Objects.equals(this.assetCode, other.assetCode)
+ && Objects.equals(this.issuer, other.issuer);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AlphaNum12 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AlphaNum12 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -87,8 +116,8 @@ public Builder issuer(AccountID issuer) {
public AlphaNum12 build() {
AlphaNum12 val = new AlphaNum12();
- val.setAssetCode(assetCode);
- val.setIssuer(issuer);
+ val.setAssetCode(this.assetCode);
+ val.setIssuer(this.issuer);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AlphaNum4.java b/src/main/java/org/stellar/sdk/xdr/AlphaNum4.java
index 69e8c7b87..4bed6e0df 100644
--- a/src/main/java/org/stellar/sdk/xdr/AlphaNum4.java
+++ b/src/main/java/org/stellar/sdk/xdr/AlphaNum4.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -57,7 +62,7 @@ public static AlphaNum4 decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.assetCode, this.issuer);
+ return Objects.hash(this.assetCode, this.issuer);
}
@Override
@@ -67,8 +72,32 @@ public boolean equals(Object object) {
}
AlphaNum4 other = (AlphaNum4) object;
- return Objects.equal(this.assetCode, other.assetCode)
- && Objects.equal(this.issuer, other.issuer);
+ return Objects.equals(this.assetCode, other.assetCode)
+ && Objects.equals(this.issuer, other.issuer);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AlphaNum4 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AlphaNum4 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -87,8 +116,8 @@ public Builder issuer(AccountID issuer) {
public AlphaNum4 build() {
AlphaNum4 val = new AlphaNum4();
- val.setAssetCode(assetCode);
- val.setIssuer(issuer);
+ val.setAssetCode(this.assetCode);
+ val.setIssuer(this.issuer);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Asset.java b/src/main/java/org/stellar/sdk/xdr/Asset.java
index 9d34821c6..bcb446458 100644
--- a/src/main/java/org/stellar/sdk/xdr/Asset.java
+++ b/src/main/java/org/stellar/sdk/xdr/Asset.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -79,8 +84,8 @@ public Builder alphaNum12(AlphaNum12 alphaNum12) {
public Asset build() {
Asset val = new Asset();
val.setDiscriminant(discriminant);
- val.setAlphaNum4(alphaNum4);
- val.setAlphaNum12(alphaNum12);
+ val.setAlphaNum4(this.alphaNum4);
+ val.setAlphaNum12(this.alphaNum12);
return val;
}
}
@@ -124,7 +129,7 @@ public static Asset decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.alphaNum4, this.alphaNum12, this.type);
+ return Objects.hash(this.alphaNum4, this.alphaNum12, this.type);
}
@Override
@@ -134,8 +139,32 @@ public boolean equals(Object object) {
}
Asset other = (Asset) object;
- return Objects.equal(this.alphaNum4, other.alphaNum4)
- && Objects.equal(this.alphaNum12, other.alphaNum12)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.alphaNum4, other.alphaNum4)
+ && Objects.equals(this.alphaNum12, other.alphaNum12)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Asset fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Asset fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AssetCode.java b/src/main/java/org/stellar/sdk/xdr/AssetCode.java
index 01b10e264..641cade63 100644
--- a/src/main/java/org/stellar/sdk/xdr/AssetCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/AssetCode.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -76,8 +81,8 @@ public Builder assetCode12(AssetCode12 assetCode12) {
public AssetCode build() {
AssetCode val = new AssetCode();
val.setDiscriminant(discriminant);
- val.setAssetCode4(assetCode4);
- val.setAssetCode12(assetCode12);
+ val.setAssetCode4(this.assetCode4);
+ val.setAssetCode12(this.assetCode12);
return val;
}
}
@@ -118,7 +123,7 @@ public static AssetCode decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.assetCode4, this.assetCode12, this.type);
+ return Objects.hash(this.assetCode4, this.assetCode12, this.type);
}
@Override
@@ -128,8 +133,32 @@ public boolean equals(Object object) {
}
AssetCode other = (AssetCode) object;
- return Objects.equal(this.assetCode4, other.assetCode4)
- && Objects.equal(this.assetCode12, other.assetCode12)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.assetCode4, other.assetCode4)
+ && Objects.equals(this.assetCode12, other.assetCode12)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AssetCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AssetCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AssetCode12.java b/src/main/java/org/stellar/sdk/xdr/AssetCode12.java
index 8c8443db5..8a2be4c92 100644
--- a/src/main/java/org/stellar/sdk/xdr/AssetCode12.java
+++ b/src/main/java/org/stellar/sdk/xdr/AssetCode12.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -60,4 +65,28 @@ public boolean equals(Object object) {
AssetCode12 other = (AssetCode12) object;
return Arrays.equals(this.AssetCode12, other.AssetCode12);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AssetCode12 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AssetCode12 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AssetCode4.java b/src/main/java/org/stellar/sdk/xdr/AssetCode4.java
index f2f969c13..e83cf0a97 100644
--- a/src/main/java/org/stellar/sdk/xdr/AssetCode4.java
+++ b/src/main/java/org/stellar/sdk/xdr/AssetCode4.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -60,4 +65,28 @@ public boolean equals(Object object) {
AssetCode4 other = (AssetCode4) object;
return Arrays.equals(this.AssetCode4, other.AssetCode4);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AssetCode4 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AssetCode4 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AssetType.java b/src/main/java/org/stellar/sdk/xdr/AssetType.java
index f38574136..30771b3f0 100644
--- a/src/main/java/org/stellar/sdk/xdr/AssetType.java
+++ b/src/main/java/org/stellar/sdk/xdr/AssetType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -55,4 +60,28 @@ public static void encode(XdrDataOutputStream stream, AssetType value) throws IO
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AssetType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AssetType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Auth.java b/src/main/java/org/stellar/sdk/xdr/Auth.java
index 01fffcef8..ce1ead623 100644
--- a/src/main/java/org/stellar/sdk/xdr/Auth.java
+++ b/src/main/java/org/stellar/sdk/xdr/Auth.java
@@ -3,34 +3,37 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
// struct Auth
// {
-// // Empty message, just to confirm
-// // establishment of MAC keys.
-// int unused;
+// int flags;
// };
// ===========================================================================
public class Auth implements XdrElement {
public Auth() {}
- private Integer unused;
+ private Integer flags;
- public Integer getUnused() {
- return this.unused;
+ public Integer getFlags() {
+ return this.flags;
}
- public void setUnused(Integer value) {
- this.unused = value;
+ public void setFlags(Integer value) {
+ this.flags = value;
}
public static void encode(XdrDataOutputStream stream, Auth encodedAuth) throws IOException {
- stream.writeInt(encodedAuth.unused);
+ stream.writeInt(encodedAuth.flags);
}
public void encode(XdrDataOutputStream stream) throws IOException {
@@ -39,13 +42,13 @@ public void encode(XdrDataOutputStream stream) throws IOException {
public static Auth decode(XdrDataInputStream stream) throws IOException {
Auth decodedAuth = new Auth();
- decodedAuth.unused = stream.readInt();
+ decodedAuth.flags = stream.readInt();
return decodedAuth;
}
@Override
public int hashCode() {
- return Objects.hashCode(this.unused);
+ return Objects.hash(this.flags);
}
@Override
@@ -55,20 +58,44 @@ public boolean equals(Object object) {
}
Auth other = (Auth) object;
- return Objects.equal(this.unused, other.unused);
+ return Objects.equals(this.flags, other.flags);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Auth fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Auth fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
- private Integer unused;
+ private Integer flags;
- public Builder unused(Integer unused) {
- this.unused = unused;
+ public Builder flags(Integer flags) {
+ this.flags = flags;
return this;
}
public Auth build() {
Auth val = new Auth();
- val.setUnused(unused);
+ val.setFlags(this.flags);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AuthCert.java b/src/main/java/org/stellar/sdk/xdr/AuthCert.java
index b3e45abf3..1f9db9ebf 100644
--- a/src/main/java/org/stellar/sdk/xdr/AuthCert.java
+++ b/src/main/java/org/stellar/sdk/xdr/AuthCert.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -70,7 +75,7 @@ public static AuthCert decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.pubkey, this.expiration, this.sig);
+ return Objects.hash(this.pubkey, this.expiration, this.sig);
}
@Override
@@ -80,9 +85,33 @@ public boolean equals(Object object) {
}
AuthCert other = (AuthCert) object;
- return Objects.equal(this.pubkey, other.pubkey)
- && Objects.equal(this.expiration, other.expiration)
- && Objects.equal(this.sig, other.sig);
+ return Objects.equals(this.pubkey, other.pubkey)
+ && Objects.equals(this.expiration, other.expiration)
+ && Objects.equals(this.sig, other.sig);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AuthCert fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AuthCert fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -107,9 +136,9 @@ public Builder sig(Signature sig) {
public AuthCert build() {
AuthCert val = new AuthCert();
- val.setPubkey(pubkey);
- val.setExpiration(expiration);
- val.setSig(sig);
+ val.setPubkey(this.pubkey);
+ val.setExpiration(this.expiration);
+ val.setSig(this.sig);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/AuthenticatedMessage.java b/src/main/java/org/stellar/sdk/xdr/AuthenticatedMessage.java
index 14f30a873..26f50cae2 100644
--- a/src/main/java/org/stellar/sdk/xdr/AuthenticatedMessage.java
+++ b/src/main/java/org/stellar/sdk/xdr/AuthenticatedMessage.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -60,7 +65,7 @@ public Builder v0(AuthenticatedMessageV0 v0) {
public AuthenticatedMessage build() {
AuthenticatedMessage val = new AuthenticatedMessage();
val.setDiscriminant(discriminant);
- val.setV0(v0);
+ val.setV0(this.v0);
return val;
}
}
@@ -70,8 +75,9 @@ public static void encode(
throws IOException {
// Xdrgen::AST::Identifier
// Uint32
- stream.writeInt(encodedAuthenticatedMessage.getDiscriminant().getUint32());
- switch (encodedAuthenticatedMessage.getDiscriminant().getUint32()) {
+ stream.writeInt(
+ encodedAuthenticatedMessage.getDiscriminant().getUint32().getNumber().intValue());
+ switch (encodedAuthenticatedMessage.getDiscriminant().getUint32().getNumber().intValue()) {
case 0:
AuthenticatedMessageV0.encode(stream, encodedAuthenticatedMessage.v0);
break;
@@ -86,7 +92,7 @@ public static AuthenticatedMessage decode(XdrDataInputStream stream) throws IOEx
AuthenticatedMessage decodedAuthenticatedMessage = new AuthenticatedMessage();
Uint32 discriminant = Uint32.decode(stream);
decodedAuthenticatedMessage.setDiscriminant(discriminant);
- switch (decodedAuthenticatedMessage.getDiscriminant().getUint32()) {
+ switch (decodedAuthenticatedMessage.getDiscriminant().getUint32().getNumber().intValue()) {
case 0:
decodedAuthenticatedMessage.v0 = AuthenticatedMessageV0.decode(stream);
break;
@@ -96,7 +102,7 @@ public static AuthenticatedMessage decode(XdrDataInputStream stream) throws IOEx
@Override
public int hashCode() {
- return Objects.hashCode(this.v0, this.v);
+ return Objects.hash(this.v0, this.v);
}
@Override
@@ -106,10 +112,34 @@ public boolean equals(Object object) {
}
AuthenticatedMessage other = (AuthenticatedMessage) object;
- return Objects.equal(this.v0, other.v0) && Objects.equal(this.v, other.v);
+ return Objects.equals(this.v0, other.v0) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AuthenticatedMessage fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AuthenticatedMessage fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
- public static class AuthenticatedMessageV0 {
+ public static class AuthenticatedMessageV0 implements XdrElement {
public AuthenticatedMessageV0() {}
private Uint64 sequence;
@@ -164,7 +194,7 @@ public static AuthenticatedMessageV0 decode(XdrDataInputStream stream) throws IO
@Override
public int hashCode() {
- return Objects.hashCode(this.sequence, this.message, this.mac);
+ return Objects.hash(this.sequence, this.message, this.mac);
}
@Override
@@ -174,9 +204,33 @@ public boolean equals(Object object) {
}
AuthenticatedMessageV0 other = (AuthenticatedMessageV0) object;
- return Objects.equal(this.sequence, other.sequence)
- && Objects.equal(this.message, other.message)
- && Objects.equal(this.mac, other.mac);
+ return Objects.equals(this.sequence, other.sequence)
+ && Objects.equals(this.message, other.message)
+ && Objects.equals(this.mac, other.mac);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static AuthenticatedMessageV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static AuthenticatedMessageV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -201,9 +255,9 @@ public Builder mac(HmacSha256Mac mac) {
public AuthenticatedMessageV0 build() {
AuthenticatedMessageV0 val = new AuthenticatedMessageV0();
- val.setSequence(sequence);
- val.setMessage(message);
- val.setMac(mac);
+ val.setSequence(this.sequence);
+ val.setMessage(this.message);
+ val.setMac(this.mac);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/BeginSponsoringFutureReservesOp.java b/src/main/java/org/stellar/sdk/xdr/BeginSponsoringFutureReservesOp.java
index 1b0d3aa25..9c9a7ce01 100644
--- a/src/main/java/org/stellar/sdk/xdr/BeginSponsoringFutureReservesOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/BeginSponsoringFutureReservesOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -48,7 +53,7 @@ public static BeginSponsoringFutureReservesOp decode(XdrDataInputStream stream)
@Override
public int hashCode() {
- return Objects.hashCode(this.sponsoredID);
+ return Objects.hash(this.sponsoredID);
}
@Override
@@ -58,7 +63,31 @@ public boolean equals(Object object) {
}
BeginSponsoringFutureReservesOp other = (BeginSponsoringFutureReservesOp) object;
- return Objects.equal(this.sponsoredID, other.sponsoredID);
+ return Objects.equals(this.sponsoredID, other.sponsoredID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BeginSponsoringFutureReservesOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BeginSponsoringFutureReservesOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -71,7 +100,7 @@ public Builder sponsoredID(AccountID sponsoredID) {
public BeginSponsoringFutureReservesOp build() {
BeginSponsoringFutureReservesOp val = new BeginSponsoringFutureReservesOp();
- val.setSponsoredID(sponsoredID);
+ val.setSponsoredID(this.sponsoredID);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/BeginSponsoringFutureReservesResult.java b/src/main/java/org/stellar/sdk/xdr/BeginSponsoringFutureReservesResult.java
index 8bcf4e4e5..127dcd520 100644
--- a/src/main/java/org/stellar/sdk/xdr/BeginSponsoringFutureReservesResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/BeginSponsoringFutureReservesResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -13,7 +18,9 @@
// {
// case BEGIN_SPONSORING_FUTURE_RESERVES_SUCCESS:
// void;
-// default:
+// case BEGIN_SPONSORING_FUTURE_RESERVES_MALFORMED:
+// case BEGIN_SPONSORING_FUTURE_RESERVES_ALREADY_SPONSORED:
+// case BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE:
// void;
// };
@@ -56,7 +63,9 @@ public static void encode(
switch (encodedBeginSponsoringFutureReservesResult.getDiscriminant()) {
case BEGIN_SPONSORING_FUTURE_RESERVES_SUCCESS:
break;
- default:
+ case BEGIN_SPONSORING_FUTURE_RESERVES_MALFORMED:
+ case BEGIN_SPONSORING_FUTURE_RESERVES_ALREADY_SPONSORED:
+ case BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE:
break;
}
}
@@ -75,7 +84,9 @@ public static BeginSponsoringFutureReservesResult decode(XdrDataInputStream stre
switch (decodedBeginSponsoringFutureReservesResult.getDiscriminant()) {
case BEGIN_SPONSORING_FUTURE_RESERVES_SUCCESS:
break;
- default:
+ case BEGIN_SPONSORING_FUTURE_RESERVES_MALFORMED:
+ case BEGIN_SPONSORING_FUTURE_RESERVES_ALREADY_SPONSORED:
+ case BEGIN_SPONSORING_FUTURE_RESERVES_RECURSIVE:
break;
}
return decodedBeginSponsoringFutureReservesResult;
@@ -83,7 +94,7 @@ public static BeginSponsoringFutureReservesResult decode(XdrDataInputStream stre
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -93,6 +104,31 @@ public boolean equals(Object object) {
}
BeginSponsoringFutureReservesResult other = (BeginSponsoringFutureReservesResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BeginSponsoringFutureReservesResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BeginSponsoringFutureReservesResult fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/BeginSponsoringFutureReservesResultCode.java b/src/main/java/org/stellar/sdk/xdr/BeginSponsoringFutureReservesResultCode.java
index f0bb13b7e..8f9a8a1f3 100644
--- a/src/main/java/org/stellar/sdk/xdr/BeginSponsoringFutureReservesResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/BeginSponsoringFutureReservesResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -61,4 +66,30 @@ public static void encode(
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BeginSponsoringFutureReservesResultCode fromXdrBase64(String xdr)
+ throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BeginSponsoringFutureReservesResultCode fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/BucketEntry.java b/src/main/java/org/stellar/sdk/xdr/BucketEntry.java
index 3ac3e6069..872c372f4 100644
--- a/src/main/java/org/stellar/sdk/xdr/BucketEntry.java
+++ b/src/main/java/org/stellar/sdk/xdr/BucketEntry.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -93,9 +98,9 @@ public Builder metaEntry(BucketMetadata metaEntry) {
public BucketEntry build() {
BucketEntry val = new BucketEntry();
val.setDiscriminant(discriminant);
- val.setLiveEntry(liveEntry);
- val.setDeadEntry(deadEntry);
- val.setMetaEntry(metaEntry);
+ val.setLiveEntry(this.liveEntry);
+ val.setDeadEntry(this.deadEntry);
+ val.setMetaEntry(this.metaEntry);
return val;
}
}
@@ -144,7 +149,7 @@ public static BucketEntry decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.liveEntry, this.deadEntry, this.metaEntry, this.type);
+ return Objects.hash(this.liveEntry, this.deadEntry, this.metaEntry, this.type);
}
@Override
@@ -154,9 +159,33 @@ public boolean equals(Object object) {
}
BucketEntry other = (BucketEntry) object;
- return Objects.equal(this.liveEntry, other.liveEntry)
- && Objects.equal(this.deadEntry, other.deadEntry)
- && Objects.equal(this.metaEntry, other.metaEntry)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.liveEntry, other.liveEntry)
+ && Objects.equals(this.deadEntry, other.deadEntry)
+ && Objects.equals(this.metaEntry, other.metaEntry)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BucketEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BucketEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/BucketEntryType.java b/src/main/java/org/stellar/sdk/xdr/BucketEntryType.java
index 1ba7d4ba7..359a29b2b 100644
--- a/src/main/java/org/stellar/sdk/xdr/BucketEntryType.java
+++ b/src/main/java/org/stellar/sdk/xdr/BucketEntryType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -57,4 +62,28 @@ public static void encode(XdrDataOutputStream stream, BucketEntryType value) thr
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BucketEntryType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BucketEntryType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/BucketMetadata.java b/src/main/java/org/stellar/sdk/xdr/BucketMetadata.java
index 161366648..9a0f8eddf 100644
--- a/src/main/java/org/stellar/sdk/xdr/BucketMetadata.java
+++ b/src/main/java/org/stellar/sdk/xdr/BucketMetadata.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -65,7 +70,7 @@ public static BucketMetadata decode(XdrDataInputStream stream) throws IOExceptio
@Override
public int hashCode() {
- return Objects.hashCode(this.ledgerVersion, this.ext);
+ return Objects.hash(this.ledgerVersion, this.ext);
}
@Override
@@ -75,8 +80,32 @@ public boolean equals(Object object) {
}
BucketMetadata other = (BucketMetadata) object;
- return Objects.equal(this.ledgerVersion, other.ledgerVersion)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.ledgerVersion, other.ledgerVersion)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BucketMetadata fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BucketMetadata fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -95,13 +124,13 @@ public Builder ext(BucketMetadataExt ext) {
public BucketMetadata build() {
BucketMetadata val = new BucketMetadata();
- val.setLedgerVersion(ledgerVersion);
- val.setExt(ext);
+ val.setLedgerVersion(this.ledgerVersion);
+ val.setExt(this.ext);
return val;
}
}
- public static class BucketMetadataExt {
+ public static class BucketMetadataExt implements XdrElement {
public BucketMetadataExt() {}
Integer v;
@@ -157,7 +186,7 @@ public static BucketMetadataExt decode(XdrDataInputStream stream) throws IOExcep
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -167,7 +196,31 @@ public boolean equals(Object object) {
}
BucketMetadataExt other = (BucketMetadataExt) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BucketMetadataExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BucketMetadataExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/BumpFootprintExpirationOp.java b/src/main/java/org/stellar/sdk/xdr/BumpFootprintExpirationOp.java
new file mode 100644
index 000000000..14155f454
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/BumpFootprintExpirationOp.java
@@ -0,0 +1,125 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct BumpFootprintExpirationOp
+// {
+// ExtensionPoint ext;
+// uint32 ledgersToExpire;
+// };
+
+// ===========================================================================
+public class BumpFootprintExpirationOp implements XdrElement {
+ public BumpFootprintExpirationOp() {}
+
+ private ExtensionPoint ext;
+
+ public ExtensionPoint getExt() {
+ return this.ext;
+ }
+
+ public void setExt(ExtensionPoint value) {
+ this.ext = value;
+ }
+
+ private Uint32 ledgersToExpire;
+
+ public Uint32 getLedgersToExpire() {
+ return this.ledgersToExpire;
+ }
+
+ public void setLedgersToExpire(Uint32 value) {
+ this.ledgersToExpire = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, BumpFootprintExpirationOp encodedBumpFootprintExpirationOp)
+ throws IOException {
+ ExtensionPoint.encode(stream, encodedBumpFootprintExpirationOp.ext);
+ Uint32.encode(stream, encodedBumpFootprintExpirationOp.ledgersToExpire);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static BumpFootprintExpirationOp decode(XdrDataInputStream stream) throws IOException {
+ BumpFootprintExpirationOp decodedBumpFootprintExpirationOp = new BumpFootprintExpirationOp();
+ decodedBumpFootprintExpirationOp.ext = ExtensionPoint.decode(stream);
+ decodedBumpFootprintExpirationOp.ledgersToExpire = Uint32.decode(stream);
+ return decodedBumpFootprintExpirationOp;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.ext, this.ledgersToExpire);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof BumpFootprintExpirationOp)) {
+ return false;
+ }
+
+ BumpFootprintExpirationOp other = (BumpFootprintExpirationOp) object;
+ return Objects.equals(this.ext, other.ext)
+ && Objects.equals(this.ledgersToExpire, other.ledgersToExpire);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BumpFootprintExpirationOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BumpFootprintExpirationOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ExtensionPoint ext;
+ private Uint32 ledgersToExpire;
+
+ public Builder ext(ExtensionPoint ext) {
+ this.ext = ext;
+ return this;
+ }
+
+ public Builder ledgersToExpire(Uint32 ledgersToExpire) {
+ this.ledgersToExpire = ledgersToExpire;
+ return this;
+ }
+
+ public BumpFootprintExpirationOp build() {
+ BumpFootprintExpirationOp val = new BumpFootprintExpirationOp();
+ val.setExt(this.ext);
+ val.setLedgersToExpire(this.ledgersToExpire);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/BumpFootprintExpirationResult.java b/src/main/java/org/stellar/sdk/xdr/BumpFootprintExpirationResult.java
new file mode 100644
index 000000000..3212a44ac
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/BumpFootprintExpirationResult.java
@@ -0,0 +1,131 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union BumpFootprintExpirationResult switch (BumpFootprintExpirationResultCode code)
+// {
+// case BUMP_FOOTPRINT_EXPIRATION_SUCCESS:
+// void;
+// case BUMP_FOOTPRINT_EXPIRATION_MALFORMED:
+// case BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED:
+// case BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE:
+// void;
+// };
+
+// ===========================================================================
+public class BumpFootprintExpirationResult implements XdrElement {
+ public BumpFootprintExpirationResult() {}
+
+ BumpFootprintExpirationResultCode code;
+
+ public BumpFootprintExpirationResultCode getDiscriminant() {
+ return this.code;
+ }
+
+ public void setDiscriminant(BumpFootprintExpirationResultCode value) {
+ this.code = value;
+ }
+
+ public static final class Builder {
+ private BumpFootprintExpirationResultCode discriminant;
+
+ public Builder discriminant(BumpFootprintExpirationResultCode discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public BumpFootprintExpirationResult build() {
+ BumpFootprintExpirationResult val = new BumpFootprintExpirationResult();
+ val.setDiscriminant(discriminant);
+ return val;
+ }
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream,
+ BumpFootprintExpirationResult encodedBumpFootprintExpirationResult)
+ throws IOException {
+ // Xdrgen::AST::Identifier
+ // BumpFootprintExpirationResultCode
+ stream.writeInt(encodedBumpFootprintExpirationResult.getDiscriminant().getValue());
+ switch (encodedBumpFootprintExpirationResult.getDiscriminant()) {
+ case BUMP_FOOTPRINT_EXPIRATION_SUCCESS:
+ break;
+ case BUMP_FOOTPRINT_EXPIRATION_MALFORMED:
+ case BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED:
+ case BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE:
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static BumpFootprintExpirationResult decode(XdrDataInputStream stream) throws IOException {
+ BumpFootprintExpirationResult decodedBumpFootprintExpirationResult =
+ new BumpFootprintExpirationResult();
+ BumpFootprintExpirationResultCode discriminant =
+ BumpFootprintExpirationResultCode.decode(stream);
+ decodedBumpFootprintExpirationResult.setDiscriminant(discriminant);
+ switch (decodedBumpFootprintExpirationResult.getDiscriminant()) {
+ case BUMP_FOOTPRINT_EXPIRATION_SUCCESS:
+ break;
+ case BUMP_FOOTPRINT_EXPIRATION_MALFORMED:
+ case BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED:
+ case BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE:
+ break;
+ }
+ return decodedBumpFootprintExpirationResult;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.code);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof BumpFootprintExpirationResult)) {
+ return false;
+ }
+
+ BumpFootprintExpirationResult other = (BumpFootprintExpirationResult) object;
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BumpFootprintExpirationResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BumpFootprintExpirationResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/BumpFootprintExpirationResultCode.java b/src/main/java/org/stellar/sdk/xdr/BumpFootprintExpirationResultCode.java
new file mode 100644
index 000000000..b55ae1e36
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/BumpFootprintExpirationResultCode.java
@@ -0,0 +1,92 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum BumpFootprintExpirationResultCode
+// {
+// // codes considered as "success" for the operation
+// BUMP_FOOTPRINT_EXPIRATION_SUCCESS = 0,
+//
+// // codes considered as "failure" for the operation
+// BUMP_FOOTPRINT_EXPIRATION_MALFORMED = -1,
+// BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED = -2,
+// BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE = -3
+// };
+
+// ===========================================================================
+public enum BumpFootprintExpirationResultCode implements XdrElement {
+ BUMP_FOOTPRINT_EXPIRATION_SUCCESS(0),
+ BUMP_FOOTPRINT_EXPIRATION_MALFORMED(-1),
+ BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED(-2),
+ BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE(-3),
+ ;
+ private int mValue;
+
+ BumpFootprintExpirationResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static BumpFootprintExpirationResultCode decode(XdrDataInputStream stream)
+ throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return BUMP_FOOTPRINT_EXPIRATION_SUCCESS;
+ case -1:
+ return BUMP_FOOTPRINT_EXPIRATION_MALFORMED;
+ case -2:
+ return BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED;
+ case -3:
+ return BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, BumpFootprintExpirationResultCode value)
+ throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BumpFootprintExpirationResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BumpFootprintExpirationResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/BumpSequenceOp.java b/src/main/java/org/stellar/sdk/xdr/BumpSequenceOp.java
index ad42446dd..4602afec0 100644
--- a/src/main/java/org/stellar/sdk/xdr/BumpSequenceOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/BumpSequenceOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -44,7 +49,7 @@ public static BumpSequenceOp decode(XdrDataInputStream stream) throws IOExceptio
@Override
public int hashCode() {
- return Objects.hashCode(this.bumpTo);
+ return Objects.hash(this.bumpTo);
}
@Override
@@ -54,7 +59,31 @@ public boolean equals(Object object) {
}
BumpSequenceOp other = (BumpSequenceOp) object;
- return Objects.equal(this.bumpTo, other.bumpTo);
+ return Objects.equals(this.bumpTo, other.bumpTo);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BumpSequenceOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BumpSequenceOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -67,7 +96,7 @@ public Builder bumpTo(SequenceNumber bumpTo) {
public BumpSequenceOp build() {
BumpSequenceOp val = new BumpSequenceOp();
- val.setBumpTo(bumpTo);
+ val.setBumpTo(this.bumpTo);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/BumpSequenceResult.java b/src/main/java/org/stellar/sdk/xdr/BumpSequenceResult.java
index 9dc1d6c38..750d061ca 100644
--- a/src/main/java/org/stellar/sdk/xdr/BumpSequenceResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/BumpSequenceResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,7 @@
// {
// case BUMP_SEQUENCE_SUCCESS:
// void;
-// default:
+// case BUMP_SEQUENCE_BAD_SEQ:
// void;
// };
@@ -53,7 +58,7 @@ public static void encode(
switch (encodedBumpSequenceResult.getDiscriminant()) {
case BUMP_SEQUENCE_SUCCESS:
break;
- default:
+ case BUMP_SEQUENCE_BAD_SEQ:
break;
}
}
@@ -69,7 +74,7 @@ public static BumpSequenceResult decode(XdrDataInputStream stream) throws IOExce
switch (decodedBumpSequenceResult.getDiscriminant()) {
case BUMP_SEQUENCE_SUCCESS:
break;
- default:
+ case BUMP_SEQUENCE_BAD_SEQ:
break;
}
return decodedBumpSequenceResult;
@@ -77,7 +82,7 @@ public static BumpSequenceResult decode(XdrDataInputStream stream) throws IOExce
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -87,6 +92,30 @@ public boolean equals(Object object) {
}
BumpSequenceResult other = (BumpSequenceResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BumpSequenceResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BumpSequenceResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/BumpSequenceResultCode.java b/src/main/java/org/stellar/sdk/xdr/BumpSequenceResultCode.java
index 383f2e3df..363656d28 100644
--- a/src/main/java/org/stellar/sdk/xdr/BumpSequenceResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/BumpSequenceResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -50,4 +55,28 @@ public static void encode(XdrDataOutputStream stream, BumpSequenceResultCode val
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static BumpSequenceResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static BumpSequenceResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ChangeTrustAsset.java b/src/main/java/org/stellar/sdk/xdr/ChangeTrustAsset.java
index c5d48291f..02e2ff442 100644
--- a/src/main/java/org/stellar/sdk/xdr/ChangeTrustAsset.java
+++ b/src/main/java/org/stellar/sdk/xdr/ChangeTrustAsset.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -98,9 +103,9 @@ public Builder liquidityPool(LiquidityPoolParameters liquidityPool) {
public ChangeTrustAsset build() {
ChangeTrustAsset val = new ChangeTrustAsset();
val.setDiscriminant(discriminant);
- val.setAlphaNum4(alphaNum4);
- val.setAlphaNum12(alphaNum12);
- val.setLiquidityPool(liquidityPool);
+ val.setAlphaNum4(this.alphaNum4);
+ val.setAlphaNum12(this.alphaNum12);
+ val.setLiquidityPool(this.liquidityPool);
return val;
}
}
@@ -151,7 +156,7 @@ public static ChangeTrustAsset decode(XdrDataInputStream stream) throws IOExcept
@Override
public int hashCode() {
- return Objects.hashCode(this.alphaNum4, this.alphaNum12, this.liquidityPool, this.type);
+ return Objects.hash(this.alphaNum4, this.alphaNum12, this.liquidityPool, this.type);
}
@Override
@@ -161,9 +166,33 @@ public boolean equals(Object object) {
}
ChangeTrustAsset other = (ChangeTrustAsset) object;
- return Objects.equal(this.alphaNum4, other.alphaNum4)
- && Objects.equal(this.alphaNum12, other.alphaNum12)
- && Objects.equal(this.liquidityPool, other.liquidityPool)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.alphaNum4, other.alphaNum4)
+ && Objects.equals(this.alphaNum12, other.alphaNum12)
+ && Objects.equals(this.liquidityPool, other.liquidityPool)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ChangeTrustAsset fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ChangeTrustAsset fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ChangeTrustOp.java b/src/main/java/org/stellar/sdk/xdr/ChangeTrustOp.java
index 8a3055e3e..c4c467d69 100644
--- a/src/main/java/org/stellar/sdk/xdr/ChangeTrustOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/ChangeTrustOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -59,7 +64,7 @@ public static ChangeTrustOp decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(this.line, this.limit);
+ return Objects.hash(this.line, this.limit);
}
@Override
@@ -69,7 +74,31 @@ public boolean equals(Object object) {
}
ChangeTrustOp other = (ChangeTrustOp) object;
- return Objects.equal(this.line, other.line) && Objects.equal(this.limit, other.limit);
+ return Objects.equals(this.line, other.line) && Objects.equals(this.limit, other.limit);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ChangeTrustOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ChangeTrustOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -88,8 +117,8 @@ public Builder limit(Int64 limit) {
public ChangeTrustOp build() {
ChangeTrustOp val = new ChangeTrustOp();
- val.setLine(line);
- val.setLimit(limit);
+ val.setLine(this.line);
+ val.setLimit(this.limit);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ChangeTrustResult.java b/src/main/java/org/stellar/sdk/xdr/ChangeTrustResult.java
index 2036a730d..8a3422f07 100644
--- a/src/main/java/org/stellar/sdk/xdr/ChangeTrustResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/ChangeTrustResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,14 @@
// {
// case CHANGE_TRUST_SUCCESS:
// void;
-// default:
+// case CHANGE_TRUST_MALFORMED:
+// case CHANGE_TRUST_NO_ISSUER:
+// case CHANGE_TRUST_INVALID_LIMIT:
+// case CHANGE_TRUST_LOW_RESERVE:
+// case CHANGE_TRUST_SELF_NOT_ALLOWED:
+// case CHANGE_TRUST_TRUST_LINE_MISSING:
+// case CHANGE_TRUST_CANNOT_DELETE:
+// case CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES:
// void;
// };
@@ -53,7 +65,14 @@ public static void encode(XdrDataOutputStream stream, ChangeTrustResult encodedC
switch (encodedChangeTrustResult.getDiscriminant()) {
case CHANGE_TRUST_SUCCESS:
break;
- default:
+ case CHANGE_TRUST_MALFORMED:
+ case CHANGE_TRUST_NO_ISSUER:
+ case CHANGE_TRUST_INVALID_LIMIT:
+ case CHANGE_TRUST_LOW_RESERVE:
+ case CHANGE_TRUST_SELF_NOT_ALLOWED:
+ case CHANGE_TRUST_TRUST_LINE_MISSING:
+ case CHANGE_TRUST_CANNOT_DELETE:
+ case CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES:
break;
}
}
@@ -69,7 +88,14 @@ public static ChangeTrustResult decode(XdrDataInputStream stream) throws IOExcep
switch (decodedChangeTrustResult.getDiscriminant()) {
case CHANGE_TRUST_SUCCESS:
break;
- default:
+ case CHANGE_TRUST_MALFORMED:
+ case CHANGE_TRUST_NO_ISSUER:
+ case CHANGE_TRUST_INVALID_LIMIT:
+ case CHANGE_TRUST_LOW_RESERVE:
+ case CHANGE_TRUST_SELF_NOT_ALLOWED:
+ case CHANGE_TRUST_TRUST_LINE_MISSING:
+ case CHANGE_TRUST_CANNOT_DELETE:
+ case CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES:
break;
}
return decodedChangeTrustResult;
@@ -77,7 +103,7 @@ public static ChangeTrustResult decode(XdrDataInputStream stream) throws IOExcep
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -87,6 +113,30 @@ public boolean equals(Object object) {
}
ChangeTrustResult other = (ChangeTrustResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ChangeTrustResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ChangeTrustResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ChangeTrustResultCode.java b/src/main/java/org/stellar/sdk/xdr/ChangeTrustResultCode.java
index c1a733784..7a5a9c050 100644
--- a/src/main/java/org/stellar/sdk/xdr/ChangeTrustResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/ChangeTrustResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -82,4 +87,28 @@ public static void encode(XdrDataOutputStream stream, ChangeTrustResultCode valu
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ChangeTrustResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ChangeTrustResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimAtom.java b/src/main/java/org/stellar/sdk/xdr/ClaimAtom.java
index 6211d89d7..fbff8b168 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimAtom.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimAtom.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -91,9 +96,9 @@ public Builder liquidityPool(ClaimLiquidityAtom liquidityPool) {
public ClaimAtom build() {
ClaimAtom val = new ClaimAtom();
val.setDiscriminant(discriminant);
- val.setV0(v0);
- val.setOrderBook(orderBook);
- val.setLiquidityPool(liquidityPool);
+ val.setV0(this.v0);
+ val.setOrderBook(this.orderBook);
+ val.setLiquidityPool(this.liquidityPool);
return val;
}
}
@@ -140,7 +145,7 @@ public static ClaimAtom decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.v0, this.orderBook, this.liquidityPool, this.type);
+ return Objects.hash(this.v0, this.orderBook, this.liquidityPool, this.type);
}
@Override
@@ -150,9 +155,33 @@ public boolean equals(Object object) {
}
ClaimAtom other = (ClaimAtom) object;
- return Objects.equal(this.v0, other.v0)
- && Objects.equal(this.orderBook, other.orderBook)
- && Objects.equal(this.liquidityPool, other.liquidityPool)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.v0, other.v0)
+ && Objects.equals(this.orderBook, other.orderBook)
+ && Objects.equals(this.liquidityPool, other.liquidityPool)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimAtom fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimAtom fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimAtomType.java b/src/main/java/org/stellar/sdk/xdr/ClaimAtomType.java
index bd1dd5452..5a3e4a4a2 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimAtomType.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimAtomType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -51,4 +56,28 @@ public static void encode(XdrDataOutputStream stream, ClaimAtomType value) throw
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimAtomType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimAtomType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimClaimableBalanceOp.java b/src/main/java/org/stellar/sdk/xdr/ClaimClaimableBalanceOp.java
index 3ae5c1d8c..d05b01927 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimClaimableBalanceOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimClaimableBalanceOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -45,7 +50,7 @@ public static ClaimClaimableBalanceOp decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(this.balanceID);
+ return Objects.hash(this.balanceID);
}
@Override
@@ -55,7 +60,31 @@ public boolean equals(Object object) {
}
ClaimClaimableBalanceOp other = (ClaimClaimableBalanceOp) object;
- return Objects.equal(this.balanceID, other.balanceID);
+ return Objects.equals(this.balanceID, other.balanceID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimClaimableBalanceOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimClaimableBalanceOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -68,7 +97,7 @@ public Builder balanceID(ClaimableBalanceID balanceID) {
public ClaimClaimableBalanceOp build() {
ClaimClaimableBalanceOp val = new ClaimClaimableBalanceOp();
- val.setBalanceID(balanceID);
+ val.setBalanceID(this.balanceID);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimClaimableBalanceResult.java b/src/main/java/org/stellar/sdk/xdr/ClaimClaimableBalanceResult.java
index 3f259d543..ef710d25b 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimClaimableBalanceResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimClaimableBalanceResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,11 @@
// {
// case CLAIM_CLAIMABLE_BALANCE_SUCCESS:
// void;
-// default:
+// case CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST:
+// case CLAIM_CLAIMABLE_BALANCE_CANNOT_CLAIM:
+// case CLAIM_CLAIMABLE_BALANCE_LINE_FULL:
+// case CLAIM_CLAIMABLE_BALANCE_NO_TRUST:
+// case CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED:
// void;
// };
@@ -54,7 +63,11 @@ public static void encode(
switch (encodedClaimClaimableBalanceResult.getDiscriminant()) {
case CLAIM_CLAIMABLE_BALANCE_SUCCESS:
break;
- default:
+ case CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST:
+ case CLAIM_CLAIMABLE_BALANCE_CANNOT_CLAIM:
+ case CLAIM_CLAIMABLE_BALANCE_LINE_FULL:
+ case CLAIM_CLAIMABLE_BALANCE_NO_TRUST:
+ case CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED:
break;
}
}
@@ -71,7 +84,11 @@ public static ClaimClaimableBalanceResult decode(XdrDataInputStream stream) thro
switch (decodedClaimClaimableBalanceResult.getDiscriminant()) {
case CLAIM_CLAIMABLE_BALANCE_SUCCESS:
break;
- default:
+ case CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST:
+ case CLAIM_CLAIMABLE_BALANCE_CANNOT_CLAIM:
+ case CLAIM_CLAIMABLE_BALANCE_LINE_FULL:
+ case CLAIM_CLAIMABLE_BALANCE_NO_TRUST:
+ case CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED:
break;
}
return decodedClaimClaimableBalanceResult;
@@ -79,7 +96,7 @@ public static ClaimClaimableBalanceResult decode(XdrDataInputStream stream) thro
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -89,6 +106,30 @@ public boolean equals(Object object) {
}
ClaimClaimableBalanceResult other = (ClaimClaimableBalanceResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimClaimableBalanceResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimClaimableBalanceResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimClaimableBalanceResultCode.java b/src/main/java/org/stellar/sdk/xdr/ClaimClaimableBalanceResultCode.java
index c70a97a60..475ec3e8f 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimClaimableBalanceResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimClaimableBalanceResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -15,7 +20,6 @@
// CLAIM_CLAIMABLE_BALANCE_LINE_FULL = -3,
// CLAIM_CLAIMABLE_BALANCE_NO_TRUST = -4,
// CLAIM_CLAIMABLE_BALANCE_NOT_AUTHORIZED = -5
-//
// };
// ===========================================================================
@@ -66,4 +70,28 @@ public static void encode(XdrDataOutputStream stream, ClaimClaimableBalanceResul
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimClaimableBalanceResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimClaimableBalanceResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimLiquidityAtom.java b/src/main/java/org/stellar/sdk/xdr/ClaimLiquidityAtom.java
index a7c4642cf..1c45b542b 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimLiquidityAtom.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimLiquidityAtom.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -100,7 +105,7 @@ public static ClaimLiquidityAtom decode(XdrDataInputStream stream) throws IOExce
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.liquidityPoolID, this.assetSold, this.amountSold, this.assetBought, this.amountBought);
}
@@ -111,11 +116,35 @@ public boolean equals(Object object) {
}
ClaimLiquidityAtom other = (ClaimLiquidityAtom) object;
- return Objects.equal(this.liquidityPoolID, other.liquidityPoolID)
- && Objects.equal(this.assetSold, other.assetSold)
- && Objects.equal(this.amountSold, other.amountSold)
- && Objects.equal(this.assetBought, other.assetBought)
- && Objects.equal(this.amountBought, other.amountBought);
+ return Objects.equals(this.liquidityPoolID, other.liquidityPoolID)
+ && Objects.equals(this.assetSold, other.assetSold)
+ && Objects.equals(this.amountSold, other.amountSold)
+ && Objects.equals(this.assetBought, other.assetBought)
+ && Objects.equals(this.amountBought, other.amountBought);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimLiquidityAtom fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimLiquidityAtom fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -152,11 +181,11 @@ public Builder amountBought(Int64 amountBought) {
public ClaimLiquidityAtom build() {
ClaimLiquidityAtom val = new ClaimLiquidityAtom();
- val.setLiquidityPoolID(liquidityPoolID);
- val.setAssetSold(assetSold);
- val.setAmountSold(amountSold);
- val.setAssetBought(assetBought);
- val.setAmountBought(amountBought);
+ val.setLiquidityPoolID(this.liquidityPoolID);
+ val.setAssetSold(this.assetSold);
+ val.setAmountSold(this.amountSold);
+ val.setAssetBought(this.assetBought);
+ val.setAmountBought(this.amountBought);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimOfferAtom.java b/src/main/java/org/stellar/sdk/xdr/ClaimOfferAtom.java
index 9bbc4aae1..55da15ce9 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimOfferAtom.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimOfferAtom.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -114,7 +119,7 @@ public static ClaimOfferAtom decode(XdrDataInputStream stream) throws IOExceptio
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.sellerID,
this.offerID,
this.assetSold,
@@ -130,12 +135,36 @@ public boolean equals(Object object) {
}
ClaimOfferAtom other = (ClaimOfferAtom) object;
- return Objects.equal(this.sellerID, other.sellerID)
- && Objects.equal(this.offerID, other.offerID)
- && Objects.equal(this.assetSold, other.assetSold)
- && Objects.equal(this.amountSold, other.amountSold)
- && Objects.equal(this.assetBought, other.assetBought)
- && Objects.equal(this.amountBought, other.amountBought);
+ return Objects.equals(this.sellerID, other.sellerID)
+ && Objects.equals(this.offerID, other.offerID)
+ && Objects.equals(this.assetSold, other.assetSold)
+ && Objects.equals(this.amountSold, other.amountSold)
+ && Objects.equals(this.assetBought, other.assetBought)
+ && Objects.equals(this.amountBought, other.amountBought);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimOfferAtom fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimOfferAtom fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -178,12 +207,12 @@ public Builder amountBought(Int64 amountBought) {
public ClaimOfferAtom build() {
ClaimOfferAtom val = new ClaimOfferAtom();
- val.setSellerID(sellerID);
- val.setOfferID(offerID);
- val.setAssetSold(assetSold);
- val.setAmountSold(amountSold);
- val.setAssetBought(assetBought);
- val.setAmountBought(amountBought);
+ val.setSellerID(this.sellerID);
+ val.setOfferID(this.offerID);
+ val.setAssetSold(this.assetSold);
+ val.setAmountSold(this.amountSold);
+ val.setAssetBought(this.assetBought);
+ val.setAmountBought(this.amountBought);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimOfferAtomV0.java b/src/main/java/org/stellar/sdk/xdr/ClaimOfferAtomV0.java
index bdb8e7228..acf4435b1 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimOfferAtomV0.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimOfferAtomV0.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -114,7 +119,7 @@ public static ClaimOfferAtomV0 decode(XdrDataInputStream stream) throws IOExcept
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.sellerEd25519,
this.offerID,
this.assetSold,
@@ -130,12 +135,36 @@ public boolean equals(Object object) {
}
ClaimOfferAtomV0 other = (ClaimOfferAtomV0) object;
- return Objects.equal(this.sellerEd25519, other.sellerEd25519)
- && Objects.equal(this.offerID, other.offerID)
- && Objects.equal(this.assetSold, other.assetSold)
- && Objects.equal(this.amountSold, other.amountSold)
- && Objects.equal(this.assetBought, other.assetBought)
- && Objects.equal(this.amountBought, other.amountBought);
+ return Objects.equals(this.sellerEd25519, other.sellerEd25519)
+ && Objects.equals(this.offerID, other.offerID)
+ && Objects.equals(this.assetSold, other.assetSold)
+ && Objects.equals(this.amountSold, other.amountSold)
+ && Objects.equals(this.assetBought, other.assetBought)
+ && Objects.equals(this.amountBought, other.amountBought);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimOfferAtomV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimOfferAtomV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -178,12 +207,12 @@ public Builder amountBought(Int64 amountBought) {
public ClaimOfferAtomV0 build() {
ClaimOfferAtomV0 val = new ClaimOfferAtomV0();
- val.setSellerEd25519(sellerEd25519);
- val.setOfferID(offerID);
- val.setAssetSold(assetSold);
- val.setAmountSold(amountSold);
- val.setAssetBought(assetBought);
- val.setAmountBought(amountBought);
+ val.setSellerEd25519(this.sellerEd25519);
+ val.setOfferID(this.offerID);
+ val.setAssetSold(this.assetSold);
+ val.setAmountSold(this.amountSold);
+ val.setAssetBought(this.assetBought);
+ val.setAmountBought(this.amountBought);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimPredicate.java b/src/main/java/org/stellar/sdk/xdr/ClaimPredicate.java
index 04af0caf3..44ddc6a1f 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimPredicate.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimPredicate.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -131,11 +136,11 @@ public Builder relBefore(Int64 relBefore) {
public ClaimPredicate build() {
ClaimPredicate val = new ClaimPredicate();
val.setDiscriminant(discriminant);
- val.setAndPredicates(andPredicates);
- val.setOrPredicates(orPredicates);
- val.setNotPredicate(notPredicate);
- val.setAbsBefore(absBefore);
- val.setRelBefore(relBefore);
+ val.setAndPredicates(this.andPredicates);
+ val.setOrPredicates(this.orPredicates);
+ val.setNotPredicate(this.notPredicate);
+ val.setAbsBefore(this.absBefore);
+ val.setRelBefore(this.relBefore);
return val;
}
}
@@ -222,7 +227,7 @@ public static ClaimPredicate decode(XdrDataInputStream stream) throws IOExceptio
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
Arrays.hashCode(this.andPredicates),
Arrays.hashCode(this.orPredicates),
this.notPredicate,
@@ -240,9 +245,33 @@ public boolean equals(Object object) {
ClaimPredicate other = (ClaimPredicate) object;
return Arrays.equals(this.andPredicates, other.andPredicates)
&& Arrays.equals(this.orPredicates, other.orPredicates)
- && Objects.equal(this.notPredicate, other.notPredicate)
- && Objects.equal(this.absBefore, other.absBefore)
- && Objects.equal(this.relBefore, other.relBefore)
- && Objects.equal(this.type, other.type);
+ && Objects.equals(this.notPredicate, other.notPredicate)
+ && Objects.equals(this.absBefore, other.absBefore)
+ && Objects.equals(this.relBefore, other.relBefore)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimPredicate fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimPredicate fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimPredicateType.java b/src/main/java/org/stellar/sdk/xdr/ClaimPredicateType.java
index 69bcfdda6..232600eaf 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimPredicateType.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimPredicateType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -64,4 +69,28 @@ public static void encode(XdrDataOutputStream stream, ClaimPredicateType value)
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimPredicateType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimPredicateType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceEntry.java b/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceEntry.java
index 9546a9994..6c5164f45 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceEntry.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceEntry.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -122,7 +127,7 @@ public static ClaimableBalanceEntry decode(XdrDataInputStream stream) throws IOE
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.balanceID, Arrays.hashCode(this.claimants), this.asset, this.amount, this.ext);
}
@@ -133,11 +138,35 @@ public boolean equals(Object object) {
}
ClaimableBalanceEntry other = (ClaimableBalanceEntry) object;
- return Objects.equal(this.balanceID, other.balanceID)
+ return Objects.equals(this.balanceID, other.balanceID)
&& Arrays.equals(this.claimants, other.claimants)
- && Objects.equal(this.asset, other.asset)
- && Objects.equal(this.amount, other.amount)
- && Objects.equal(this.ext, other.ext);
+ && Objects.equals(this.asset, other.asset)
+ && Objects.equals(this.amount, other.amount)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimableBalanceEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimableBalanceEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -174,16 +203,16 @@ public Builder ext(ClaimableBalanceEntryExt ext) {
public ClaimableBalanceEntry build() {
ClaimableBalanceEntry val = new ClaimableBalanceEntry();
- val.setBalanceID(balanceID);
- val.setClaimants(claimants);
- val.setAsset(asset);
- val.setAmount(amount);
- val.setExt(ext);
+ val.setBalanceID(this.balanceID);
+ val.setClaimants(this.claimants);
+ val.setAsset(this.asset);
+ val.setAmount(this.amount);
+ val.setExt(this.ext);
return val;
}
}
- public static class ClaimableBalanceEntryExt {
+ public static class ClaimableBalanceEntryExt implements XdrElement {
public ClaimableBalanceEntryExt() {}
Integer v;
@@ -223,7 +252,7 @@ public Builder v1(ClaimableBalanceEntryExtensionV1 v1) {
public ClaimableBalanceEntryExt build() {
ClaimableBalanceEntryExt val = new ClaimableBalanceEntryExt();
val.setDiscriminant(discriminant);
- val.setV1(v1);
+ val.setV1(this.v1);
return val;
}
}
@@ -263,7 +292,7 @@ public static ClaimableBalanceEntryExt decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(this.v1, this.v);
+ return Objects.hash(this.v1, this.v);
}
@Override
@@ -273,7 +302,31 @@ public boolean equals(Object object) {
}
ClaimableBalanceEntryExt other = (ClaimableBalanceEntryExt) object;
- return Objects.equal(this.v1, other.v1) && Objects.equal(this.v, other.v);
+ return Objects.equals(this.v1, other.v1) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimableBalanceEntryExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimableBalanceEntryExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceEntryExtensionV1.java b/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceEntryExtensionV1.java
index ea2214d17..6d078f36d 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceEntryExtensionV1.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceEntryExtensionV1.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -68,7 +73,7 @@ public static ClaimableBalanceEntryExtensionV1 decode(XdrDataInputStream stream)
@Override
public int hashCode() {
- return Objects.hashCode(this.ext, this.flags);
+ return Objects.hash(this.ext, this.flags);
}
@Override
@@ -78,7 +83,31 @@ public boolean equals(Object object) {
}
ClaimableBalanceEntryExtensionV1 other = (ClaimableBalanceEntryExtensionV1) object;
- return Objects.equal(this.ext, other.ext) && Objects.equal(this.flags, other.flags);
+ return Objects.equals(this.ext, other.ext) && Objects.equals(this.flags, other.flags);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimableBalanceEntryExtensionV1 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimableBalanceEntryExtensionV1 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -97,13 +126,13 @@ public Builder flags(Uint32 flags) {
public ClaimableBalanceEntryExtensionV1 build() {
ClaimableBalanceEntryExtensionV1 val = new ClaimableBalanceEntryExtensionV1();
- val.setExt(ext);
- val.setFlags(flags);
+ val.setExt(this.ext);
+ val.setFlags(this.flags);
return val;
}
}
- public static class ClaimableBalanceEntryExtensionV1Ext {
+ public static class ClaimableBalanceEntryExtensionV1Ext implements XdrElement {
public ClaimableBalanceEntryExtensionV1Ext() {}
Integer v;
@@ -163,7 +192,7 @@ public static ClaimableBalanceEntryExtensionV1Ext decode(XdrDataInputStream stre
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -173,7 +202,32 @@ public boolean equals(Object object) {
}
ClaimableBalanceEntryExtensionV1Ext other = (ClaimableBalanceEntryExtensionV1Ext) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimableBalanceEntryExtensionV1Ext fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimableBalanceEntryExtensionV1Ext fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceFlags.java b/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceFlags.java
index 709c9b22a..87e307958 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceFlags.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceFlags.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -46,4 +51,28 @@ public static void encode(XdrDataOutputStream stream, ClaimableBalanceFlags valu
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimableBalanceFlags fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimableBalanceFlags fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceID.java b/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceID.java
index 9ffb93ce9..a2adef3fb 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceID.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceID.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -55,7 +60,7 @@ public Builder v0(Hash v0) {
public ClaimableBalanceID build() {
ClaimableBalanceID val = new ClaimableBalanceID();
val.setDiscriminant(discriminant);
- val.setV0(v0);
+ val.setV0(this.v0);
return val;
}
}
@@ -90,7 +95,7 @@ public static ClaimableBalanceID decode(XdrDataInputStream stream) throws IOExce
@Override
public int hashCode() {
- return Objects.hashCode(this.v0, this.type);
+ return Objects.hash(this.v0, this.type);
}
@Override
@@ -100,6 +105,30 @@ public boolean equals(Object object) {
}
ClaimableBalanceID other = (ClaimableBalanceID) object;
- return Objects.equal(this.v0, other.v0) && Objects.equal(this.type, other.type);
+ return Objects.equals(this.v0, other.v0) && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimableBalanceID fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimableBalanceID fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceIDType.java b/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceIDType.java
index 31c5e13f8..b4450f579 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceIDType.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimableBalanceIDType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -44,4 +49,28 @@ public static void encode(XdrDataOutputStream stream, ClaimableBalanceIDType val
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimableBalanceIDType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimableBalanceIDType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Claimant.java b/src/main/java/org/stellar/sdk/xdr/Claimant.java
index 032941beb..0c8d14b3c 100644
--- a/src/main/java/org/stellar/sdk/xdr/Claimant.java
+++ b/src/main/java/org/stellar/sdk/xdr/Claimant.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -59,7 +64,7 @@ public Builder v0(ClaimantV0 v0) {
public Claimant build() {
Claimant val = new Claimant();
val.setDiscriminant(discriminant);
- val.setV0(v0);
+ val.setV0(this.v0);
return val;
}
}
@@ -94,7 +99,7 @@ public static Claimant decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.v0, this.type);
+ return Objects.hash(this.v0, this.type);
}
@Override
@@ -104,10 +109,34 @@ public boolean equals(Object object) {
}
Claimant other = (Claimant) object;
- return Objects.equal(this.v0, other.v0) && Objects.equal(this.type, other.type);
+ return Objects.equals(this.v0, other.v0) && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Claimant fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Claimant fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
- public static class ClaimantV0 {
+ public static class ClaimantV0 implements XdrElement {
public ClaimantV0() {}
private AccountID destination;
@@ -149,7 +178,7 @@ public static ClaimantV0 decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.destination, this.predicate);
+ return Objects.hash(this.destination, this.predicate);
}
@Override
@@ -159,8 +188,32 @@ public boolean equals(Object object) {
}
ClaimantV0 other = (ClaimantV0) object;
- return Objects.equal(this.destination, other.destination)
- && Objects.equal(this.predicate, other.predicate);
+ return Objects.equals(this.destination, other.destination)
+ && Objects.equals(this.predicate, other.predicate);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimantV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimantV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -179,8 +232,8 @@ public Builder predicate(ClaimPredicate predicate) {
public ClaimantV0 build() {
ClaimantV0 val = new ClaimantV0();
- val.setDestination(destination);
- val.setPredicate(predicate);
+ val.setDestination(this.destination);
+ val.setPredicate(this.predicate);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimantType.java b/src/main/java/org/stellar/sdk/xdr/ClaimantType.java
index 0a4f68a09..c27943bf3 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClaimantType.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimantType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -43,4 +48,28 @@ public static void encode(XdrDataOutputStream stream, ClaimantType value) throws
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClaimantType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClaimantType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClawbackClaimableBalanceOp.java b/src/main/java/org/stellar/sdk/xdr/ClawbackClaimableBalanceOp.java
index 4984f1cd6..e99f07e85 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClawbackClaimableBalanceOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClawbackClaimableBalanceOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -45,7 +50,7 @@ public static ClawbackClaimableBalanceOp decode(XdrDataInputStream stream) throw
@Override
public int hashCode() {
- return Objects.hashCode(this.balanceID);
+ return Objects.hash(this.balanceID);
}
@Override
@@ -55,7 +60,31 @@ public boolean equals(Object object) {
}
ClawbackClaimableBalanceOp other = (ClawbackClaimableBalanceOp) object;
- return Objects.equal(this.balanceID, other.balanceID);
+ return Objects.equals(this.balanceID, other.balanceID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClawbackClaimableBalanceOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClawbackClaimableBalanceOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -68,7 +97,7 @@ public Builder balanceID(ClaimableBalanceID balanceID) {
public ClawbackClaimableBalanceOp build() {
ClawbackClaimableBalanceOp val = new ClawbackClaimableBalanceOp();
- val.setBalanceID(balanceID);
+ val.setBalanceID(this.balanceID);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClawbackClaimableBalanceResult.java b/src/main/java/org/stellar/sdk/xdr/ClawbackClaimableBalanceResult.java
index ce389eff5..5a1a44e71 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClawbackClaimableBalanceResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClawbackClaimableBalanceResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -13,7 +18,9 @@
// {
// case CLAWBACK_CLAIMABLE_BALANCE_SUCCESS:
// void;
-// default:
+// case CLAWBACK_CLAIMABLE_BALANCE_DOES_NOT_EXIST:
+// case CLAWBACK_CLAIMABLE_BALANCE_NOT_ISSUER:
+// case CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED:
// void;
// };
@@ -56,7 +63,9 @@ public static void encode(
switch (encodedClawbackClaimableBalanceResult.getDiscriminant()) {
case CLAWBACK_CLAIMABLE_BALANCE_SUCCESS:
break;
- default:
+ case CLAWBACK_CLAIMABLE_BALANCE_DOES_NOT_EXIST:
+ case CLAWBACK_CLAIMABLE_BALANCE_NOT_ISSUER:
+ case CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED:
break;
}
}
@@ -75,7 +84,9 @@ public static ClawbackClaimableBalanceResult decode(XdrDataInputStream stream)
switch (decodedClawbackClaimableBalanceResult.getDiscriminant()) {
case CLAWBACK_CLAIMABLE_BALANCE_SUCCESS:
break;
- default:
+ case CLAWBACK_CLAIMABLE_BALANCE_DOES_NOT_EXIST:
+ case CLAWBACK_CLAIMABLE_BALANCE_NOT_ISSUER:
+ case CLAWBACK_CLAIMABLE_BALANCE_NOT_CLAWBACK_ENABLED:
break;
}
return decodedClawbackClaimableBalanceResult;
@@ -83,7 +94,7 @@ public static ClawbackClaimableBalanceResult decode(XdrDataInputStream stream)
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -93,6 +104,30 @@ public boolean equals(Object object) {
}
ClawbackClaimableBalanceResult other = (ClawbackClaimableBalanceResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClawbackClaimableBalanceResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClawbackClaimableBalanceResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClawbackClaimableBalanceResultCode.java b/src/main/java/org/stellar/sdk/xdr/ClawbackClaimableBalanceResultCode.java
index 007a6d0e3..6e2e61692 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClawbackClaimableBalanceResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClawbackClaimableBalanceResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -60,4 +65,28 @@ public static void encode(XdrDataOutputStream stream, ClawbackClaimableBalanceRe
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClawbackClaimableBalanceResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClawbackClaimableBalanceResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClawbackOp.java b/src/main/java/org/stellar/sdk/xdr/ClawbackOp.java
index c5a7d93e5..4d40bec5b 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClawbackOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClawbackOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -70,7 +75,7 @@ public static ClawbackOp decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.asset, this.from, this.amount);
+ return Objects.hash(this.asset, this.from, this.amount);
}
@Override
@@ -80,9 +85,33 @@ public boolean equals(Object object) {
}
ClawbackOp other = (ClawbackOp) object;
- return Objects.equal(this.asset, other.asset)
- && Objects.equal(this.from, other.from)
- && Objects.equal(this.amount, other.amount);
+ return Objects.equals(this.asset, other.asset)
+ && Objects.equals(this.from, other.from)
+ && Objects.equals(this.amount, other.amount);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClawbackOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClawbackOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -107,9 +136,9 @@ public Builder amount(Int64 amount) {
public ClawbackOp build() {
ClawbackOp val = new ClawbackOp();
- val.setAsset(asset);
- val.setFrom(from);
- val.setAmount(amount);
+ val.setAsset(this.asset);
+ val.setFrom(this.from);
+ val.setAmount(this.amount);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClawbackResult.java b/src/main/java/org/stellar/sdk/xdr/ClawbackResult.java
index 69fbce6af..6cebe6245 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClawbackResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClawbackResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,10 @@
// {
// case CLAWBACK_SUCCESS:
// void;
-// default:
+// case CLAWBACK_MALFORMED:
+// case CLAWBACK_NOT_CLAWBACK_ENABLED:
+// case CLAWBACK_NO_TRUST:
+// case CLAWBACK_UNDERFUNDED:
// void;
// };
@@ -53,7 +61,10 @@ public static void encode(XdrDataOutputStream stream, ClawbackResult encodedClaw
switch (encodedClawbackResult.getDiscriminant()) {
case CLAWBACK_SUCCESS:
break;
- default:
+ case CLAWBACK_MALFORMED:
+ case CLAWBACK_NOT_CLAWBACK_ENABLED:
+ case CLAWBACK_NO_TRUST:
+ case CLAWBACK_UNDERFUNDED:
break;
}
}
@@ -69,7 +80,10 @@ public static ClawbackResult decode(XdrDataInputStream stream) throws IOExceptio
switch (decodedClawbackResult.getDiscriminant()) {
case CLAWBACK_SUCCESS:
break;
- default:
+ case CLAWBACK_MALFORMED:
+ case CLAWBACK_NOT_CLAWBACK_ENABLED:
+ case CLAWBACK_NO_TRUST:
+ case CLAWBACK_UNDERFUNDED:
break;
}
return decodedClawbackResult;
@@ -77,7 +91,7 @@ public static ClawbackResult decode(XdrDataInputStream stream) throws IOExceptio
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -87,6 +101,30 @@ public boolean equals(Object object) {
}
ClawbackResult other = (ClawbackResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClawbackResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClawbackResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClawbackResultCode.java b/src/main/java/org/stellar/sdk/xdr/ClawbackResultCode.java
index cbd7f11f7..576f10642 100644
--- a/src/main/java/org/stellar/sdk/xdr/ClawbackResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/ClawbackResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -63,4 +68,28 @@ public static void encode(XdrDataOutputStream stream, ClawbackResultCode value)
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ClawbackResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ClawbackResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractBandwidthV0.java b/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractBandwidthV0.java
new file mode 100644
index 000000000..44fb1ffd7
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractBandwidthV0.java
@@ -0,0 +1,153 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct ConfigSettingContractBandwidthV0
+// {
+// // Maximum sum of all transaction sizes in the ledger in bytes
+// uint32 ledgerMaxTxsSizeBytes;
+// // Maximum size in bytes for a transaction
+// uint32 txMaxSizeBytes;
+//
+// // Fee for 1 KB of transaction size
+// int64 feeTxSize1KB;
+// };
+
+// ===========================================================================
+public class ConfigSettingContractBandwidthV0 implements XdrElement {
+ public ConfigSettingContractBandwidthV0() {}
+
+ private Uint32 ledgerMaxTxsSizeBytes;
+
+ public Uint32 getLedgerMaxTxsSizeBytes() {
+ return this.ledgerMaxTxsSizeBytes;
+ }
+
+ public void setLedgerMaxTxsSizeBytes(Uint32 value) {
+ this.ledgerMaxTxsSizeBytes = value;
+ }
+
+ private Uint32 txMaxSizeBytes;
+
+ public Uint32 getTxMaxSizeBytes() {
+ return this.txMaxSizeBytes;
+ }
+
+ public void setTxMaxSizeBytes(Uint32 value) {
+ this.txMaxSizeBytes = value;
+ }
+
+ private Int64 feeTxSize1KB;
+
+ public Int64 getFeeTxSize1KB() {
+ return this.feeTxSize1KB;
+ }
+
+ public void setFeeTxSize1KB(Int64 value) {
+ this.feeTxSize1KB = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream,
+ ConfigSettingContractBandwidthV0 encodedConfigSettingContractBandwidthV0)
+ throws IOException {
+ Uint32.encode(stream, encodedConfigSettingContractBandwidthV0.ledgerMaxTxsSizeBytes);
+ Uint32.encode(stream, encodedConfigSettingContractBandwidthV0.txMaxSizeBytes);
+ Int64.encode(stream, encodedConfigSettingContractBandwidthV0.feeTxSize1KB);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ConfigSettingContractBandwidthV0 decode(XdrDataInputStream stream)
+ throws IOException {
+ ConfigSettingContractBandwidthV0 decodedConfigSettingContractBandwidthV0 =
+ new ConfigSettingContractBandwidthV0();
+ decodedConfigSettingContractBandwidthV0.ledgerMaxTxsSizeBytes = Uint32.decode(stream);
+ decodedConfigSettingContractBandwidthV0.txMaxSizeBytes = Uint32.decode(stream);
+ decodedConfigSettingContractBandwidthV0.feeTxSize1KB = Int64.decode(stream);
+ return decodedConfigSettingContractBandwidthV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.ledgerMaxTxsSizeBytes, this.txMaxSizeBytes, this.feeTxSize1KB);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ConfigSettingContractBandwidthV0)) {
+ return false;
+ }
+
+ ConfigSettingContractBandwidthV0 other = (ConfigSettingContractBandwidthV0) object;
+ return Objects.equals(this.ledgerMaxTxsSizeBytes, other.ledgerMaxTxsSizeBytes)
+ && Objects.equals(this.txMaxSizeBytes, other.txMaxSizeBytes)
+ && Objects.equals(this.feeTxSize1KB, other.feeTxSize1KB);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ConfigSettingContractBandwidthV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ConfigSettingContractBandwidthV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Uint32 ledgerMaxTxsSizeBytes;
+ private Uint32 txMaxSizeBytes;
+ private Int64 feeTxSize1KB;
+
+ public Builder ledgerMaxTxsSizeBytes(Uint32 ledgerMaxTxsSizeBytes) {
+ this.ledgerMaxTxsSizeBytes = ledgerMaxTxsSizeBytes;
+ return this;
+ }
+
+ public Builder txMaxSizeBytes(Uint32 txMaxSizeBytes) {
+ this.txMaxSizeBytes = txMaxSizeBytes;
+ return this;
+ }
+
+ public Builder feeTxSize1KB(Int64 feeTxSize1KB) {
+ this.feeTxSize1KB = feeTxSize1KB;
+ return this;
+ }
+
+ public ConfigSettingContractBandwidthV0 build() {
+ ConfigSettingContractBandwidthV0 val = new ConfigSettingContractBandwidthV0();
+ val.setLedgerMaxTxsSizeBytes(this.ledgerMaxTxsSizeBytes);
+ val.setTxMaxSizeBytes(this.txMaxSizeBytes);
+ val.setFeeTxSize1KB(this.feeTxSize1KB);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractComputeV0.java b/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractComputeV0.java
new file mode 100644
index 000000000..3367bcb41
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractComputeV0.java
@@ -0,0 +1,181 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct ConfigSettingContractComputeV0
+// {
+// // Maximum instructions per ledger
+// int64 ledgerMaxInstructions;
+// // Maximum instructions per transaction
+// int64 txMaxInstructions;
+// // Cost of 10000 instructions
+// int64 feeRatePerInstructionsIncrement;
+//
+// // Memory limit per transaction. Unlike instructions, there is no fee
+// // for memory, just the limit.
+// uint32 txMemoryLimit;
+// };
+
+// ===========================================================================
+public class ConfigSettingContractComputeV0 implements XdrElement {
+ public ConfigSettingContractComputeV0() {}
+
+ private Int64 ledgerMaxInstructions;
+
+ public Int64 getLedgerMaxInstructions() {
+ return this.ledgerMaxInstructions;
+ }
+
+ public void setLedgerMaxInstructions(Int64 value) {
+ this.ledgerMaxInstructions = value;
+ }
+
+ private Int64 txMaxInstructions;
+
+ public Int64 getTxMaxInstructions() {
+ return this.txMaxInstructions;
+ }
+
+ public void setTxMaxInstructions(Int64 value) {
+ this.txMaxInstructions = value;
+ }
+
+ private Int64 feeRatePerInstructionsIncrement;
+
+ public Int64 getFeeRatePerInstructionsIncrement() {
+ return this.feeRatePerInstructionsIncrement;
+ }
+
+ public void setFeeRatePerInstructionsIncrement(Int64 value) {
+ this.feeRatePerInstructionsIncrement = value;
+ }
+
+ private Uint32 txMemoryLimit;
+
+ public Uint32 getTxMemoryLimit() {
+ return this.txMemoryLimit;
+ }
+
+ public void setTxMemoryLimit(Uint32 value) {
+ this.txMemoryLimit = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream,
+ ConfigSettingContractComputeV0 encodedConfigSettingContractComputeV0)
+ throws IOException {
+ Int64.encode(stream, encodedConfigSettingContractComputeV0.ledgerMaxInstructions);
+ Int64.encode(stream, encodedConfigSettingContractComputeV0.txMaxInstructions);
+ Int64.encode(stream, encodedConfigSettingContractComputeV0.feeRatePerInstructionsIncrement);
+ Uint32.encode(stream, encodedConfigSettingContractComputeV0.txMemoryLimit);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ConfigSettingContractComputeV0 decode(XdrDataInputStream stream)
+ throws IOException {
+ ConfigSettingContractComputeV0 decodedConfigSettingContractComputeV0 =
+ new ConfigSettingContractComputeV0();
+ decodedConfigSettingContractComputeV0.ledgerMaxInstructions = Int64.decode(stream);
+ decodedConfigSettingContractComputeV0.txMaxInstructions = Int64.decode(stream);
+ decodedConfigSettingContractComputeV0.feeRatePerInstructionsIncrement = Int64.decode(stream);
+ decodedConfigSettingContractComputeV0.txMemoryLimit = Uint32.decode(stream);
+ return decodedConfigSettingContractComputeV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.ledgerMaxInstructions,
+ this.txMaxInstructions,
+ this.feeRatePerInstructionsIncrement,
+ this.txMemoryLimit);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ConfigSettingContractComputeV0)) {
+ return false;
+ }
+
+ ConfigSettingContractComputeV0 other = (ConfigSettingContractComputeV0) object;
+ return Objects.equals(this.ledgerMaxInstructions, other.ledgerMaxInstructions)
+ && Objects.equals(this.txMaxInstructions, other.txMaxInstructions)
+ && Objects.equals(
+ this.feeRatePerInstructionsIncrement, other.feeRatePerInstructionsIncrement)
+ && Objects.equals(this.txMemoryLimit, other.txMemoryLimit);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ConfigSettingContractComputeV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ConfigSettingContractComputeV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Int64 ledgerMaxInstructions;
+ private Int64 txMaxInstructions;
+ private Int64 feeRatePerInstructionsIncrement;
+ private Uint32 txMemoryLimit;
+
+ public Builder ledgerMaxInstructions(Int64 ledgerMaxInstructions) {
+ this.ledgerMaxInstructions = ledgerMaxInstructions;
+ return this;
+ }
+
+ public Builder txMaxInstructions(Int64 txMaxInstructions) {
+ this.txMaxInstructions = txMaxInstructions;
+ return this;
+ }
+
+ public Builder feeRatePerInstructionsIncrement(Int64 feeRatePerInstructionsIncrement) {
+ this.feeRatePerInstructionsIncrement = feeRatePerInstructionsIncrement;
+ return this;
+ }
+
+ public Builder txMemoryLimit(Uint32 txMemoryLimit) {
+ this.txMemoryLimit = txMemoryLimit;
+ return this;
+ }
+
+ public ConfigSettingContractComputeV0 build() {
+ ConfigSettingContractComputeV0 val = new ConfigSettingContractComputeV0();
+ val.setLedgerMaxInstructions(this.ledgerMaxInstructions);
+ val.setTxMaxInstructions(this.txMaxInstructions);
+ val.setFeeRatePerInstructionsIncrement(this.feeRatePerInstructionsIncrement);
+ val.setTxMemoryLimit(this.txMemoryLimit);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractEventsV0.java b/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractEventsV0.java
new file mode 100644
index 000000000..e12c1f2c3
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractEventsV0.java
@@ -0,0 +1,129 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct ConfigSettingContractEventsV0
+// {
+// // Maximum size of events that a contract call can emit.
+// uint32 txMaxContractEventsSizeBytes;
+// // Fee for generating 1KB of contract events.
+// int64 feeContractEvents1KB;
+// };
+
+// ===========================================================================
+public class ConfigSettingContractEventsV0 implements XdrElement {
+ public ConfigSettingContractEventsV0() {}
+
+ private Uint32 txMaxContractEventsSizeBytes;
+
+ public Uint32 getTxMaxContractEventsSizeBytes() {
+ return this.txMaxContractEventsSizeBytes;
+ }
+
+ public void setTxMaxContractEventsSizeBytes(Uint32 value) {
+ this.txMaxContractEventsSizeBytes = value;
+ }
+
+ private Int64 feeContractEvents1KB;
+
+ public Int64 getFeeContractEvents1KB() {
+ return this.feeContractEvents1KB;
+ }
+
+ public void setFeeContractEvents1KB(Int64 value) {
+ this.feeContractEvents1KB = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream,
+ ConfigSettingContractEventsV0 encodedConfigSettingContractEventsV0)
+ throws IOException {
+ Uint32.encode(stream, encodedConfigSettingContractEventsV0.txMaxContractEventsSizeBytes);
+ Int64.encode(stream, encodedConfigSettingContractEventsV0.feeContractEvents1KB);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ConfigSettingContractEventsV0 decode(XdrDataInputStream stream) throws IOException {
+ ConfigSettingContractEventsV0 decodedConfigSettingContractEventsV0 =
+ new ConfigSettingContractEventsV0();
+ decodedConfigSettingContractEventsV0.txMaxContractEventsSizeBytes = Uint32.decode(stream);
+ decodedConfigSettingContractEventsV0.feeContractEvents1KB = Int64.decode(stream);
+ return decodedConfigSettingContractEventsV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.txMaxContractEventsSizeBytes, this.feeContractEvents1KB);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ConfigSettingContractEventsV0)) {
+ return false;
+ }
+
+ ConfigSettingContractEventsV0 other = (ConfigSettingContractEventsV0) object;
+ return Objects.equals(this.txMaxContractEventsSizeBytes, other.txMaxContractEventsSizeBytes)
+ && Objects.equals(this.feeContractEvents1KB, other.feeContractEvents1KB);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ConfigSettingContractEventsV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ConfigSettingContractEventsV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Uint32 txMaxContractEventsSizeBytes;
+ private Int64 feeContractEvents1KB;
+
+ public Builder txMaxContractEventsSizeBytes(Uint32 txMaxContractEventsSizeBytes) {
+ this.txMaxContractEventsSizeBytes = txMaxContractEventsSizeBytes;
+ return this;
+ }
+
+ public Builder feeContractEvents1KB(Int64 feeContractEvents1KB) {
+ this.feeContractEvents1KB = feeContractEvents1KB;
+ return this;
+ }
+
+ public ConfigSettingContractEventsV0 build() {
+ ConfigSettingContractEventsV0 val = new ConfigSettingContractEventsV0();
+ val.setTxMaxContractEventsSizeBytes(this.txMaxContractEventsSizeBytes);
+ val.setFeeContractEvents1KB(this.feeContractEvents1KB);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractExecutionLanesV0.java b/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractExecutionLanesV0.java
new file mode 100644
index 000000000..5ff955c77
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractExecutionLanesV0.java
@@ -0,0 +1,109 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct ConfigSettingContractExecutionLanesV0
+// {
+// // maximum number of Soroban transactions per ledger
+// uint32 ledgerMaxTxCount;
+// };
+
+// ===========================================================================
+public class ConfigSettingContractExecutionLanesV0 implements XdrElement {
+ public ConfigSettingContractExecutionLanesV0() {}
+
+ private Uint32 ledgerMaxTxCount;
+
+ public Uint32 getLedgerMaxTxCount() {
+ return this.ledgerMaxTxCount;
+ }
+
+ public void setLedgerMaxTxCount(Uint32 value) {
+ this.ledgerMaxTxCount = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream,
+ ConfigSettingContractExecutionLanesV0 encodedConfigSettingContractExecutionLanesV0)
+ throws IOException {
+ Uint32.encode(stream, encodedConfigSettingContractExecutionLanesV0.ledgerMaxTxCount);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ConfigSettingContractExecutionLanesV0 decode(XdrDataInputStream stream)
+ throws IOException {
+ ConfigSettingContractExecutionLanesV0 decodedConfigSettingContractExecutionLanesV0 =
+ new ConfigSettingContractExecutionLanesV0();
+ decodedConfigSettingContractExecutionLanesV0.ledgerMaxTxCount = Uint32.decode(stream);
+ return decodedConfigSettingContractExecutionLanesV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.ledgerMaxTxCount);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ConfigSettingContractExecutionLanesV0)) {
+ return false;
+ }
+
+ ConfigSettingContractExecutionLanesV0 other = (ConfigSettingContractExecutionLanesV0) object;
+ return Objects.equals(this.ledgerMaxTxCount, other.ledgerMaxTxCount);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ConfigSettingContractExecutionLanesV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ConfigSettingContractExecutionLanesV0 fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Uint32 ledgerMaxTxCount;
+
+ public Builder ledgerMaxTxCount(Uint32 ledgerMaxTxCount) {
+ this.ledgerMaxTxCount = ledgerMaxTxCount;
+ return this;
+ }
+
+ public ConfigSettingContractExecutionLanesV0 build() {
+ ConfigSettingContractExecutionLanesV0 val = new ConfigSettingContractExecutionLanesV0();
+ val.setLedgerMaxTxCount(this.ledgerMaxTxCount);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractHistoricalDataV0.java b/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractHistoricalDataV0.java
new file mode 100644
index 000000000..553b78164
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractHistoricalDataV0.java
@@ -0,0 +1,108 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct ConfigSettingContractHistoricalDataV0
+// {
+// int64 feeHistorical1KB; // Fee for storing 1KB in archives
+// };
+
+// ===========================================================================
+public class ConfigSettingContractHistoricalDataV0 implements XdrElement {
+ public ConfigSettingContractHistoricalDataV0() {}
+
+ private Int64 feeHistorical1KB;
+
+ public Int64 getFeeHistorical1KB() {
+ return this.feeHistorical1KB;
+ }
+
+ public void setFeeHistorical1KB(Int64 value) {
+ this.feeHistorical1KB = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream,
+ ConfigSettingContractHistoricalDataV0 encodedConfigSettingContractHistoricalDataV0)
+ throws IOException {
+ Int64.encode(stream, encodedConfigSettingContractHistoricalDataV0.feeHistorical1KB);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ConfigSettingContractHistoricalDataV0 decode(XdrDataInputStream stream)
+ throws IOException {
+ ConfigSettingContractHistoricalDataV0 decodedConfigSettingContractHistoricalDataV0 =
+ new ConfigSettingContractHistoricalDataV0();
+ decodedConfigSettingContractHistoricalDataV0.feeHistorical1KB = Int64.decode(stream);
+ return decodedConfigSettingContractHistoricalDataV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.feeHistorical1KB);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ConfigSettingContractHistoricalDataV0)) {
+ return false;
+ }
+
+ ConfigSettingContractHistoricalDataV0 other = (ConfigSettingContractHistoricalDataV0) object;
+ return Objects.equals(this.feeHistorical1KB, other.feeHistorical1KB);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ConfigSettingContractHistoricalDataV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ConfigSettingContractHistoricalDataV0 fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Int64 feeHistorical1KB;
+
+ public Builder feeHistorical1KB(Int64 feeHistorical1KB) {
+ this.feeHistorical1KB = feeHistorical1KB;
+ return this;
+ }
+
+ public ConfigSettingContractHistoricalDataV0 build() {
+ ConfigSettingContractHistoricalDataV0 val = new ConfigSettingContractHistoricalDataV0();
+ val.setFeeHistorical1KB(this.feeHistorical1KB);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractLedgerCostV0.java b/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractLedgerCostV0.java
new file mode 100644
index 000000000..5a284e6ec
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ConfigSettingContractLedgerCostV0.java
@@ -0,0 +1,434 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct ConfigSettingContractLedgerCostV0
+// {
+// // Maximum number of ledger entry read operations per ledger
+// uint32 ledgerMaxReadLedgerEntries;
+// // Maximum number of bytes that can be read per ledger
+// uint32 ledgerMaxReadBytes;
+// // Maximum number of ledger entry write operations per ledger
+// uint32 ledgerMaxWriteLedgerEntries;
+// // Maximum number of bytes that can be written per ledger
+// uint32 ledgerMaxWriteBytes;
+//
+// // Maximum number of ledger entry read operations per transaction
+// uint32 txMaxReadLedgerEntries;
+// // Maximum number of bytes that can be read per transaction
+// uint32 txMaxReadBytes;
+// // Maximum number of ledger entry write operations per transaction
+// uint32 txMaxWriteLedgerEntries;
+// // Maximum number of bytes that can be written per transaction
+// uint32 txMaxWriteBytes;
+//
+// int64 feeReadLedgerEntry; // Fee per ledger entry read
+// int64 feeWriteLedgerEntry; // Fee per ledger entry write
+//
+// int64 feeRead1KB; // Fee for reading 1KB
+//
+// // The following parameters determine the write fee per 1KB.
+// // Write fee grows linearly until bucket list reaches this size
+// int64 bucketListTargetSizeBytes;
+// // Fee per 1KB write when the bucket list is empty
+// int64 writeFee1KBBucketListLow;
+// // Fee per 1KB write when the bucket list has reached `bucketListTargetSizeBytes`
+// int64 writeFee1KBBucketListHigh;
+// // Write fee multiplier for any additional data past the first `bucketListTargetSizeBytes`
+// uint32 bucketListWriteFeeGrowthFactor;
+// };
+
+// ===========================================================================
+public class ConfigSettingContractLedgerCostV0 implements XdrElement {
+ public ConfigSettingContractLedgerCostV0() {}
+
+ private Uint32 ledgerMaxReadLedgerEntries;
+
+ public Uint32 getLedgerMaxReadLedgerEntries() {
+ return this.ledgerMaxReadLedgerEntries;
+ }
+
+ public void setLedgerMaxReadLedgerEntries(Uint32 value) {
+ this.ledgerMaxReadLedgerEntries = value;
+ }
+
+ private Uint32 ledgerMaxReadBytes;
+
+ public Uint32 getLedgerMaxReadBytes() {
+ return this.ledgerMaxReadBytes;
+ }
+
+ public void setLedgerMaxReadBytes(Uint32 value) {
+ this.ledgerMaxReadBytes = value;
+ }
+
+ private Uint32 ledgerMaxWriteLedgerEntries;
+
+ public Uint32 getLedgerMaxWriteLedgerEntries() {
+ return this.ledgerMaxWriteLedgerEntries;
+ }
+
+ public void setLedgerMaxWriteLedgerEntries(Uint32 value) {
+ this.ledgerMaxWriteLedgerEntries = value;
+ }
+
+ private Uint32 ledgerMaxWriteBytes;
+
+ public Uint32 getLedgerMaxWriteBytes() {
+ return this.ledgerMaxWriteBytes;
+ }
+
+ public void setLedgerMaxWriteBytes(Uint32 value) {
+ this.ledgerMaxWriteBytes = value;
+ }
+
+ private Uint32 txMaxReadLedgerEntries;
+
+ public Uint32 getTxMaxReadLedgerEntries() {
+ return this.txMaxReadLedgerEntries;
+ }
+
+ public void setTxMaxReadLedgerEntries(Uint32 value) {
+ this.txMaxReadLedgerEntries = value;
+ }
+
+ private Uint32 txMaxReadBytes;
+
+ public Uint32 getTxMaxReadBytes() {
+ return this.txMaxReadBytes;
+ }
+
+ public void setTxMaxReadBytes(Uint32 value) {
+ this.txMaxReadBytes = value;
+ }
+
+ private Uint32 txMaxWriteLedgerEntries;
+
+ public Uint32 getTxMaxWriteLedgerEntries() {
+ return this.txMaxWriteLedgerEntries;
+ }
+
+ public void setTxMaxWriteLedgerEntries(Uint32 value) {
+ this.txMaxWriteLedgerEntries = value;
+ }
+
+ private Uint32 txMaxWriteBytes;
+
+ public Uint32 getTxMaxWriteBytes() {
+ return this.txMaxWriteBytes;
+ }
+
+ public void setTxMaxWriteBytes(Uint32 value) {
+ this.txMaxWriteBytes = value;
+ }
+
+ private Int64 feeReadLedgerEntry;
+
+ public Int64 getFeeReadLedgerEntry() {
+ return this.feeReadLedgerEntry;
+ }
+
+ public void setFeeReadLedgerEntry(Int64 value) {
+ this.feeReadLedgerEntry = value;
+ }
+
+ private Int64 feeWriteLedgerEntry;
+
+ public Int64 getFeeWriteLedgerEntry() {
+ return this.feeWriteLedgerEntry;
+ }
+
+ public void setFeeWriteLedgerEntry(Int64 value) {
+ this.feeWriteLedgerEntry = value;
+ }
+
+ private Int64 feeRead1KB;
+
+ public Int64 getFeeRead1KB() {
+ return this.feeRead1KB;
+ }
+
+ public void setFeeRead1KB(Int64 value) {
+ this.feeRead1KB = value;
+ }
+
+ private Int64 bucketListTargetSizeBytes;
+
+ public Int64 getBucketListTargetSizeBytes() {
+ return this.bucketListTargetSizeBytes;
+ }
+
+ public void setBucketListTargetSizeBytes(Int64 value) {
+ this.bucketListTargetSizeBytes = value;
+ }
+
+ private Int64 writeFee1KBBucketListLow;
+
+ public Int64 getWriteFee1KBBucketListLow() {
+ return this.writeFee1KBBucketListLow;
+ }
+
+ public void setWriteFee1KBBucketListLow(Int64 value) {
+ this.writeFee1KBBucketListLow = value;
+ }
+
+ private Int64 writeFee1KBBucketListHigh;
+
+ public Int64 getWriteFee1KBBucketListHigh() {
+ return this.writeFee1KBBucketListHigh;
+ }
+
+ public void setWriteFee1KBBucketListHigh(Int64 value) {
+ this.writeFee1KBBucketListHigh = value;
+ }
+
+ private Uint32 bucketListWriteFeeGrowthFactor;
+
+ public Uint32 getBucketListWriteFeeGrowthFactor() {
+ return this.bucketListWriteFeeGrowthFactor;
+ }
+
+ public void setBucketListWriteFeeGrowthFactor(Uint32 value) {
+ this.bucketListWriteFeeGrowthFactor = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream,
+ ConfigSettingContractLedgerCostV0 encodedConfigSettingContractLedgerCostV0)
+ throws IOException {
+ Uint32.encode(stream, encodedConfigSettingContractLedgerCostV0.ledgerMaxReadLedgerEntries);
+ Uint32.encode(stream, encodedConfigSettingContractLedgerCostV0.ledgerMaxReadBytes);
+ Uint32.encode(stream, encodedConfigSettingContractLedgerCostV0.ledgerMaxWriteLedgerEntries);
+ Uint32.encode(stream, encodedConfigSettingContractLedgerCostV0.ledgerMaxWriteBytes);
+ Uint32.encode(stream, encodedConfigSettingContractLedgerCostV0.txMaxReadLedgerEntries);
+ Uint32.encode(stream, encodedConfigSettingContractLedgerCostV0.txMaxReadBytes);
+ Uint32.encode(stream, encodedConfigSettingContractLedgerCostV0.txMaxWriteLedgerEntries);
+ Uint32.encode(stream, encodedConfigSettingContractLedgerCostV0.txMaxWriteBytes);
+ Int64.encode(stream, encodedConfigSettingContractLedgerCostV0.feeReadLedgerEntry);
+ Int64.encode(stream, encodedConfigSettingContractLedgerCostV0.feeWriteLedgerEntry);
+ Int64.encode(stream, encodedConfigSettingContractLedgerCostV0.feeRead1KB);
+ Int64.encode(stream, encodedConfigSettingContractLedgerCostV0.bucketListTargetSizeBytes);
+ Int64.encode(stream, encodedConfigSettingContractLedgerCostV0.writeFee1KBBucketListLow);
+ Int64.encode(stream, encodedConfigSettingContractLedgerCostV0.writeFee1KBBucketListHigh);
+ Uint32.encode(stream, encodedConfigSettingContractLedgerCostV0.bucketListWriteFeeGrowthFactor);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ConfigSettingContractLedgerCostV0 decode(XdrDataInputStream stream)
+ throws IOException {
+ ConfigSettingContractLedgerCostV0 decodedConfigSettingContractLedgerCostV0 =
+ new ConfigSettingContractLedgerCostV0();
+ decodedConfigSettingContractLedgerCostV0.ledgerMaxReadLedgerEntries = Uint32.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.ledgerMaxReadBytes = Uint32.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.ledgerMaxWriteLedgerEntries = Uint32.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.ledgerMaxWriteBytes = Uint32.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.txMaxReadLedgerEntries = Uint32.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.txMaxReadBytes = Uint32.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.txMaxWriteLedgerEntries = Uint32.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.txMaxWriteBytes = Uint32.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.feeReadLedgerEntry = Int64.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.feeWriteLedgerEntry = Int64.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.feeRead1KB = Int64.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.bucketListTargetSizeBytes = Int64.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.writeFee1KBBucketListLow = Int64.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.writeFee1KBBucketListHigh = Int64.decode(stream);
+ decodedConfigSettingContractLedgerCostV0.bucketListWriteFeeGrowthFactor = Uint32.decode(stream);
+ return decodedConfigSettingContractLedgerCostV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.ledgerMaxReadLedgerEntries,
+ this.ledgerMaxReadBytes,
+ this.ledgerMaxWriteLedgerEntries,
+ this.ledgerMaxWriteBytes,
+ this.txMaxReadLedgerEntries,
+ this.txMaxReadBytes,
+ this.txMaxWriteLedgerEntries,
+ this.txMaxWriteBytes,
+ this.feeReadLedgerEntry,
+ this.feeWriteLedgerEntry,
+ this.feeRead1KB,
+ this.bucketListTargetSizeBytes,
+ this.writeFee1KBBucketListLow,
+ this.writeFee1KBBucketListHigh,
+ this.bucketListWriteFeeGrowthFactor);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ConfigSettingContractLedgerCostV0)) {
+ return false;
+ }
+
+ ConfigSettingContractLedgerCostV0 other = (ConfigSettingContractLedgerCostV0) object;
+ return Objects.equals(this.ledgerMaxReadLedgerEntries, other.ledgerMaxReadLedgerEntries)
+ && Objects.equals(this.ledgerMaxReadBytes, other.ledgerMaxReadBytes)
+ && Objects.equals(this.ledgerMaxWriteLedgerEntries, other.ledgerMaxWriteLedgerEntries)
+ && Objects.equals(this.ledgerMaxWriteBytes, other.ledgerMaxWriteBytes)
+ && Objects.equals(this.txMaxReadLedgerEntries, other.txMaxReadLedgerEntries)
+ && Objects.equals(this.txMaxReadBytes, other.txMaxReadBytes)
+ && Objects.equals(this.txMaxWriteLedgerEntries, other.txMaxWriteLedgerEntries)
+ && Objects.equals(this.txMaxWriteBytes, other.txMaxWriteBytes)
+ && Objects.equals(this.feeReadLedgerEntry, other.feeReadLedgerEntry)
+ && Objects.equals(this.feeWriteLedgerEntry, other.feeWriteLedgerEntry)
+ && Objects.equals(this.feeRead1KB, other.feeRead1KB)
+ && Objects.equals(this.bucketListTargetSizeBytes, other.bucketListTargetSizeBytes)
+ && Objects.equals(this.writeFee1KBBucketListLow, other.writeFee1KBBucketListLow)
+ && Objects.equals(this.writeFee1KBBucketListHigh, other.writeFee1KBBucketListHigh)
+ && Objects.equals(
+ this.bucketListWriteFeeGrowthFactor, other.bucketListWriteFeeGrowthFactor);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ConfigSettingContractLedgerCostV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ConfigSettingContractLedgerCostV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Uint32 ledgerMaxReadLedgerEntries;
+ private Uint32 ledgerMaxReadBytes;
+ private Uint32 ledgerMaxWriteLedgerEntries;
+ private Uint32 ledgerMaxWriteBytes;
+ private Uint32 txMaxReadLedgerEntries;
+ private Uint32 txMaxReadBytes;
+ private Uint32 txMaxWriteLedgerEntries;
+ private Uint32 txMaxWriteBytes;
+ private Int64 feeReadLedgerEntry;
+ private Int64 feeWriteLedgerEntry;
+ private Int64 feeRead1KB;
+ private Int64 bucketListTargetSizeBytes;
+ private Int64 writeFee1KBBucketListLow;
+ private Int64 writeFee1KBBucketListHigh;
+ private Uint32 bucketListWriteFeeGrowthFactor;
+
+ public Builder ledgerMaxReadLedgerEntries(Uint32 ledgerMaxReadLedgerEntries) {
+ this.ledgerMaxReadLedgerEntries = ledgerMaxReadLedgerEntries;
+ return this;
+ }
+
+ public Builder ledgerMaxReadBytes(Uint32 ledgerMaxReadBytes) {
+ this.ledgerMaxReadBytes = ledgerMaxReadBytes;
+ return this;
+ }
+
+ public Builder ledgerMaxWriteLedgerEntries(Uint32 ledgerMaxWriteLedgerEntries) {
+ this.ledgerMaxWriteLedgerEntries = ledgerMaxWriteLedgerEntries;
+ return this;
+ }
+
+ public Builder ledgerMaxWriteBytes(Uint32 ledgerMaxWriteBytes) {
+ this.ledgerMaxWriteBytes = ledgerMaxWriteBytes;
+ return this;
+ }
+
+ public Builder txMaxReadLedgerEntries(Uint32 txMaxReadLedgerEntries) {
+ this.txMaxReadLedgerEntries = txMaxReadLedgerEntries;
+ return this;
+ }
+
+ public Builder txMaxReadBytes(Uint32 txMaxReadBytes) {
+ this.txMaxReadBytes = txMaxReadBytes;
+ return this;
+ }
+
+ public Builder txMaxWriteLedgerEntries(Uint32 txMaxWriteLedgerEntries) {
+ this.txMaxWriteLedgerEntries = txMaxWriteLedgerEntries;
+ return this;
+ }
+
+ public Builder txMaxWriteBytes(Uint32 txMaxWriteBytes) {
+ this.txMaxWriteBytes = txMaxWriteBytes;
+ return this;
+ }
+
+ public Builder feeReadLedgerEntry(Int64 feeReadLedgerEntry) {
+ this.feeReadLedgerEntry = feeReadLedgerEntry;
+ return this;
+ }
+
+ public Builder feeWriteLedgerEntry(Int64 feeWriteLedgerEntry) {
+ this.feeWriteLedgerEntry = feeWriteLedgerEntry;
+ return this;
+ }
+
+ public Builder feeRead1KB(Int64 feeRead1KB) {
+ this.feeRead1KB = feeRead1KB;
+ return this;
+ }
+
+ public Builder bucketListTargetSizeBytes(Int64 bucketListTargetSizeBytes) {
+ this.bucketListTargetSizeBytes = bucketListTargetSizeBytes;
+ return this;
+ }
+
+ public Builder writeFee1KBBucketListLow(Int64 writeFee1KBBucketListLow) {
+ this.writeFee1KBBucketListLow = writeFee1KBBucketListLow;
+ return this;
+ }
+
+ public Builder writeFee1KBBucketListHigh(Int64 writeFee1KBBucketListHigh) {
+ this.writeFee1KBBucketListHigh = writeFee1KBBucketListHigh;
+ return this;
+ }
+
+ public Builder bucketListWriteFeeGrowthFactor(Uint32 bucketListWriteFeeGrowthFactor) {
+ this.bucketListWriteFeeGrowthFactor = bucketListWriteFeeGrowthFactor;
+ return this;
+ }
+
+ public ConfigSettingContractLedgerCostV0 build() {
+ ConfigSettingContractLedgerCostV0 val = new ConfigSettingContractLedgerCostV0();
+ val.setLedgerMaxReadLedgerEntries(this.ledgerMaxReadLedgerEntries);
+ val.setLedgerMaxReadBytes(this.ledgerMaxReadBytes);
+ val.setLedgerMaxWriteLedgerEntries(this.ledgerMaxWriteLedgerEntries);
+ val.setLedgerMaxWriteBytes(this.ledgerMaxWriteBytes);
+ val.setTxMaxReadLedgerEntries(this.txMaxReadLedgerEntries);
+ val.setTxMaxReadBytes(this.txMaxReadBytes);
+ val.setTxMaxWriteLedgerEntries(this.txMaxWriteLedgerEntries);
+ val.setTxMaxWriteBytes(this.txMaxWriteBytes);
+ val.setFeeReadLedgerEntry(this.feeReadLedgerEntry);
+ val.setFeeWriteLedgerEntry(this.feeWriteLedgerEntry);
+ val.setFeeRead1KB(this.feeRead1KB);
+ val.setBucketListTargetSizeBytes(this.bucketListTargetSizeBytes);
+ val.setWriteFee1KBBucketListLow(this.writeFee1KBBucketListLow);
+ val.setWriteFee1KBBucketListHigh(this.writeFee1KBBucketListHigh);
+ val.setBucketListWriteFeeGrowthFactor(this.bucketListWriteFeeGrowthFactor);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ConfigSettingEntry.java b/src/main/java/org/stellar/sdk/xdr/ConfigSettingEntry.java
new file mode 100644
index 000000000..5a539ec28
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ConfigSettingEntry.java
@@ -0,0 +1,507 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union ConfigSettingEntry switch (ConfigSettingID configSettingID)
+// {
+// case CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES:
+// uint32 contractMaxSizeBytes;
+// case CONFIG_SETTING_CONTRACT_COMPUTE_V0:
+// ConfigSettingContractComputeV0 contractCompute;
+// case CONFIG_SETTING_CONTRACT_LEDGER_COST_V0:
+// ConfigSettingContractLedgerCostV0 contractLedgerCost;
+// case CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0:
+// ConfigSettingContractHistoricalDataV0 contractHistoricalData;
+// case CONFIG_SETTING_CONTRACT_EVENTS_V0:
+// ConfigSettingContractEventsV0 contractEvents;
+// case CONFIG_SETTING_CONTRACT_BANDWIDTH_V0:
+// ConfigSettingContractBandwidthV0 contractBandwidth;
+// case CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS:
+// ContractCostParams contractCostParamsCpuInsns;
+// case CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES:
+// ContractCostParams contractCostParamsMemBytes;
+// case CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES:
+// uint32 contractDataKeySizeBytes;
+// case CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES:
+// uint32 contractDataEntrySizeBytes;
+// case CONFIG_SETTING_STATE_EXPIRATION:
+// StateExpirationSettings stateExpirationSettings;
+// case CONFIG_SETTING_CONTRACT_EXECUTION_LANES:
+// ConfigSettingContractExecutionLanesV0 contractExecutionLanes;
+// case CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW:
+// uint64 bucketListSizeWindow<>;
+// case CONFIG_SETTING_EVICTION_ITERATOR:
+// EvictionIterator evictionIterator;
+// };
+
+// ===========================================================================
+public class ConfigSettingEntry implements XdrElement {
+ public ConfigSettingEntry() {}
+
+ ConfigSettingID configSettingID;
+
+ public ConfigSettingID getDiscriminant() {
+ return this.configSettingID;
+ }
+
+ public void setDiscriminant(ConfigSettingID value) {
+ this.configSettingID = value;
+ }
+
+ private Uint32 contractMaxSizeBytes;
+
+ public Uint32 getContractMaxSizeBytes() {
+ return this.contractMaxSizeBytes;
+ }
+
+ public void setContractMaxSizeBytes(Uint32 value) {
+ this.contractMaxSizeBytes = value;
+ }
+
+ private ConfigSettingContractComputeV0 contractCompute;
+
+ public ConfigSettingContractComputeV0 getContractCompute() {
+ return this.contractCompute;
+ }
+
+ public void setContractCompute(ConfigSettingContractComputeV0 value) {
+ this.contractCompute = value;
+ }
+
+ private ConfigSettingContractLedgerCostV0 contractLedgerCost;
+
+ public ConfigSettingContractLedgerCostV0 getContractLedgerCost() {
+ return this.contractLedgerCost;
+ }
+
+ public void setContractLedgerCost(ConfigSettingContractLedgerCostV0 value) {
+ this.contractLedgerCost = value;
+ }
+
+ private ConfigSettingContractHistoricalDataV0 contractHistoricalData;
+
+ public ConfigSettingContractHistoricalDataV0 getContractHistoricalData() {
+ return this.contractHistoricalData;
+ }
+
+ public void setContractHistoricalData(ConfigSettingContractHistoricalDataV0 value) {
+ this.contractHistoricalData = value;
+ }
+
+ private ConfigSettingContractEventsV0 contractEvents;
+
+ public ConfigSettingContractEventsV0 getContractEvents() {
+ return this.contractEvents;
+ }
+
+ public void setContractEvents(ConfigSettingContractEventsV0 value) {
+ this.contractEvents = value;
+ }
+
+ private ConfigSettingContractBandwidthV0 contractBandwidth;
+
+ public ConfigSettingContractBandwidthV0 getContractBandwidth() {
+ return this.contractBandwidth;
+ }
+
+ public void setContractBandwidth(ConfigSettingContractBandwidthV0 value) {
+ this.contractBandwidth = value;
+ }
+
+ private ContractCostParams contractCostParamsCpuInsns;
+
+ public ContractCostParams getContractCostParamsCpuInsns() {
+ return this.contractCostParamsCpuInsns;
+ }
+
+ public void setContractCostParamsCpuInsns(ContractCostParams value) {
+ this.contractCostParamsCpuInsns = value;
+ }
+
+ private ContractCostParams contractCostParamsMemBytes;
+
+ public ContractCostParams getContractCostParamsMemBytes() {
+ return this.contractCostParamsMemBytes;
+ }
+
+ public void setContractCostParamsMemBytes(ContractCostParams value) {
+ this.contractCostParamsMemBytes = value;
+ }
+
+ private Uint32 contractDataKeySizeBytes;
+
+ public Uint32 getContractDataKeySizeBytes() {
+ return this.contractDataKeySizeBytes;
+ }
+
+ public void setContractDataKeySizeBytes(Uint32 value) {
+ this.contractDataKeySizeBytes = value;
+ }
+
+ private Uint32 contractDataEntrySizeBytes;
+
+ public Uint32 getContractDataEntrySizeBytes() {
+ return this.contractDataEntrySizeBytes;
+ }
+
+ public void setContractDataEntrySizeBytes(Uint32 value) {
+ this.contractDataEntrySizeBytes = value;
+ }
+
+ private StateExpirationSettings stateExpirationSettings;
+
+ public StateExpirationSettings getStateExpirationSettings() {
+ return this.stateExpirationSettings;
+ }
+
+ public void setStateExpirationSettings(StateExpirationSettings value) {
+ this.stateExpirationSettings = value;
+ }
+
+ private ConfigSettingContractExecutionLanesV0 contractExecutionLanes;
+
+ public ConfigSettingContractExecutionLanesV0 getContractExecutionLanes() {
+ return this.contractExecutionLanes;
+ }
+
+ public void setContractExecutionLanes(ConfigSettingContractExecutionLanesV0 value) {
+ this.contractExecutionLanes = value;
+ }
+
+ private Uint64[] bucketListSizeWindow;
+
+ public Uint64[] getBucketListSizeWindow() {
+ return this.bucketListSizeWindow;
+ }
+
+ public void setBucketListSizeWindow(Uint64[] value) {
+ this.bucketListSizeWindow = value;
+ }
+
+ private EvictionIterator evictionIterator;
+
+ public EvictionIterator getEvictionIterator() {
+ return this.evictionIterator;
+ }
+
+ public void setEvictionIterator(EvictionIterator value) {
+ this.evictionIterator = value;
+ }
+
+ public static final class Builder {
+ private ConfigSettingID discriminant;
+ private Uint32 contractMaxSizeBytes;
+ private ConfigSettingContractComputeV0 contractCompute;
+ private ConfigSettingContractLedgerCostV0 contractLedgerCost;
+ private ConfigSettingContractHistoricalDataV0 contractHistoricalData;
+ private ConfigSettingContractEventsV0 contractEvents;
+ private ConfigSettingContractBandwidthV0 contractBandwidth;
+ private ContractCostParams contractCostParamsCpuInsns;
+ private ContractCostParams contractCostParamsMemBytes;
+ private Uint32 contractDataKeySizeBytes;
+ private Uint32 contractDataEntrySizeBytes;
+ private StateExpirationSettings stateExpirationSettings;
+ private ConfigSettingContractExecutionLanesV0 contractExecutionLanes;
+ private Uint64[] bucketListSizeWindow;
+ private EvictionIterator evictionIterator;
+
+ public Builder discriminant(ConfigSettingID discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder contractMaxSizeBytes(Uint32 contractMaxSizeBytes) {
+ this.contractMaxSizeBytes = contractMaxSizeBytes;
+ return this;
+ }
+
+ public Builder contractCompute(ConfigSettingContractComputeV0 contractCompute) {
+ this.contractCompute = contractCompute;
+ return this;
+ }
+
+ public Builder contractLedgerCost(ConfigSettingContractLedgerCostV0 contractLedgerCost) {
+ this.contractLedgerCost = contractLedgerCost;
+ return this;
+ }
+
+ public Builder contractHistoricalData(
+ ConfigSettingContractHistoricalDataV0 contractHistoricalData) {
+ this.contractHistoricalData = contractHistoricalData;
+ return this;
+ }
+
+ public Builder contractEvents(ConfigSettingContractEventsV0 contractEvents) {
+ this.contractEvents = contractEvents;
+ return this;
+ }
+
+ public Builder contractBandwidth(ConfigSettingContractBandwidthV0 contractBandwidth) {
+ this.contractBandwidth = contractBandwidth;
+ return this;
+ }
+
+ public Builder contractCostParamsCpuInsns(ContractCostParams contractCostParamsCpuInsns) {
+ this.contractCostParamsCpuInsns = contractCostParamsCpuInsns;
+ return this;
+ }
+
+ public Builder contractCostParamsMemBytes(ContractCostParams contractCostParamsMemBytes) {
+ this.contractCostParamsMemBytes = contractCostParamsMemBytes;
+ return this;
+ }
+
+ public Builder contractDataKeySizeBytes(Uint32 contractDataKeySizeBytes) {
+ this.contractDataKeySizeBytes = contractDataKeySizeBytes;
+ return this;
+ }
+
+ public Builder contractDataEntrySizeBytes(Uint32 contractDataEntrySizeBytes) {
+ this.contractDataEntrySizeBytes = contractDataEntrySizeBytes;
+ return this;
+ }
+
+ public Builder stateExpirationSettings(StateExpirationSettings stateExpirationSettings) {
+ this.stateExpirationSettings = stateExpirationSettings;
+ return this;
+ }
+
+ public Builder contractExecutionLanes(
+ ConfigSettingContractExecutionLanesV0 contractExecutionLanes) {
+ this.contractExecutionLanes = contractExecutionLanes;
+ return this;
+ }
+
+ public Builder bucketListSizeWindow(Uint64[] bucketListSizeWindow) {
+ this.bucketListSizeWindow = bucketListSizeWindow;
+ return this;
+ }
+
+ public Builder evictionIterator(EvictionIterator evictionIterator) {
+ this.evictionIterator = evictionIterator;
+ return this;
+ }
+
+ public ConfigSettingEntry build() {
+ ConfigSettingEntry val = new ConfigSettingEntry();
+ val.setDiscriminant(discriminant);
+ val.setContractMaxSizeBytes(this.contractMaxSizeBytes);
+ val.setContractCompute(this.contractCompute);
+ val.setContractLedgerCost(this.contractLedgerCost);
+ val.setContractHistoricalData(this.contractHistoricalData);
+ val.setContractEvents(this.contractEvents);
+ val.setContractBandwidth(this.contractBandwidth);
+ val.setContractCostParamsCpuInsns(this.contractCostParamsCpuInsns);
+ val.setContractCostParamsMemBytes(this.contractCostParamsMemBytes);
+ val.setContractDataKeySizeBytes(this.contractDataKeySizeBytes);
+ val.setContractDataEntrySizeBytes(this.contractDataEntrySizeBytes);
+ val.setStateExpirationSettings(this.stateExpirationSettings);
+ val.setContractExecutionLanes(this.contractExecutionLanes);
+ val.setBucketListSizeWindow(this.bucketListSizeWindow);
+ val.setEvictionIterator(this.evictionIterator);
+ return val;
+ }
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, ConfigSettingEntry encodedConfigSettingEntry) throws IOException {
+ // Xdrgen::AST::Identifier
+ // ConfigSettingID
+ stream.writeInt(encodedConfigSettingEntry.getDiscriminant().getValue());
+ switch (encodedConfigSettingEntry.getDiscriminant()) {
+ case CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES:
+ Uint32.encode(stream, encodedConfigSettingEntry.contractMaxSizeBytes);
+ break;
+ case CONFIG_SETTING_CONTRACT_COMPUTE_V0:
+ ConfigSettingContractComputeV0.encode(stream, encodedConfigSettingEntry.contractCompute);
+ break;
+ case CONFIG_SETTING_CONTRACT_LEDGER_COST_V0:
+ ConfigSettingContractLedgerCostV0.encode(
+ stream, encodedConfigSettingEntry.contractLedgerCost);
+ break;
+ case CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0:
+ ConfigSettingContractHistoricalDataV0.encode(
+ stream, encodedConfigSettingEntry.contractHistoricalData);
+ break;
+ case CONFIG_SETTING_CONTRACT_EVENTS_V0:
+ ConfigSettingContractEventsV0.encode(stream, encodedConfigSettingEntry.contractEvents);
+ break;
+ case CONFIG_SETTING_CONTRACT_BANDWIDTH_V0:
+ ConfigSettingContractBandwidthV0.encode(
+ stream, encodedConfigSettingEntry.contractBandwidth);
+ break;
+ case CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS:
+ ContractCostParams.encode(stream, encodedConfigSettingEntry.contractCostParamsCpuInsns);
+ break;
+ case CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES:
+ ContractCostParams.encode(stream, encodedConfigSettingEntry.contractCostParamsMemBytes);
+ break;
+ case CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES:
+ Uint32.encode(stream, encodedConfigSettingEntry.contractDataKeySizeBytes);
+ break;
+ case CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES:
+ Uint32.encode(stream, encodedConfigSettingEntry.contractDataEntrySizeBytes);
+ break;
+ case CONFIG_SETTING_STATE_EXPIRATION:
+ StateExpirationSettings.encode(stream, encodedConfigSettingEntry.stateExpirationSettings);
+ break;
+ case CONFIG_SETTING_CONTRACT_EXECUTION_LANES:
+ ConfigSettingContractExecutionLanesV0.encode(
+ stream, encodedConfigSettingEntry.contractExecutionLanes);
+ break;
+ case CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW:
+ int bucketListSizeWindowsize = encodedConfigSettingEntry.getBucketListSizeWindow().length;
+ stream.writeInt(bucketListSizeWindowsize);
+ for (int i = 0; i < bucketListSizeWindowsize; i++) {
+ Uint64.encode(stream, encodedConfigSettingEntry.bucketListSizeWindow[i]);
+ }
+ break;
+ case CONFIG_SETTING_EVICTION_ITERATOR:
+ EvictionIterator.encode(stream, encodedConfigSettingEntry.evictionIterator);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ConfigSettingEntry decode(XdrDataInputStream stream) throws IOException {
+ ConfigSettingEntry decodedConfigSettingEntry = new ConfigSettingEntry();
+ ConfigSettingID discriminant = ConfigSettingID.decode(stream);
+ decodedConfigSettingEntry.setDiscriminant(discriminant);
+ switch (decodedConfigSettingEntry.getDiscriminant()) {
+ case CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES:
+ decodedConfigSettingEntry.contractMaxSizeBytes = Uint32.decode(stream);
+ break;
+ case CONFIG_SETTING_CONTRACT_COMPUTE_V0:
+ decodedConfigSettingEntry.contractCompute = ConfigSettingContractComputeV0.decode(stream);
+ break;
+ case CONFIG_SETTING_CONTRACT_LEDGER_COST_V0:
+ decodedConfigSettingEntry.contractLedgerCost =
+ ConfigSettingContractLedgerCostV0.decode(stream);
+ break;
+ case CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0:
+ decodedConfigSettingEntry.contractHistoricalData =
+ ConfigSettingContractHistoricalDataV0.decode(stream);
+ break;
+ case CONFIG_SETTING_CONTRACT_EVENTS_V0:
+ decodedConfigSettingEntry.contractEvents = ConfigSettingContractEventsV0.decode(stream);
+ break;
+ case CONFIG_SETTING_CONTRACT_BANDWIDTH_V0:
+ decodedConfigSettingEntry.contractBandwidth =
+ ConfigSettingContractBandwidthV0.decode(stream);
+ break;
+ case CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS:
+ decodedConfigSettingEntry.contractCostParamsCpuInsns = ContractCostParams.decode(stream);
+ break;
+ case CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES:
+ decodedConfigSettingEntry.contractCostParamsMemBytes = ContractCostParams.decode(stream);
+ break;
+ case CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES:
+ decodedConfigSettingEntry.contractDataKeySizeBytes = Uint32.decode(stream);
+ break;
+ case CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES:
+ decodedConfigSettingEntry.contractDataEntrySizeBytes = Uint32.decode(stream);
+ break;
+ case CONFIG_SETTING_STATE_EXPIRATION:
+ decodedConfigSettingEntry.stateExpirationSettings = StateExpirationSettings.decode(stream);
+ break;
+ case CONFIG_SETTING_CONTRACT_EXECUTION_LANES:
+ decodedConfigSettingEntry.contractExecutionLanes =
+ ConfigSettingContractExecutionLanesV0.decode(stream);
+ break;
+ case CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW:
+ int bucketListSizeWindowsize = stream.readInt();
+ decodedConfigSettingEntry.bucketListSizeWindow = new Uint64[bucketListSizeWindowsize];
+ for (int i = 0; i < bucketListSizeWindowsize; i++) {
+ decodedConfigSettingEntry.bucketListSizeWindow[i] = Uint64.decode(stream);
+ }
+ break;
+ case CONFIG_SETTING_EVICTION_ITERATOR:
+ decodedConfigSettingEntry.evictionIterator = EvictionIterator.decode(stream);
+ break;
+ }
+ return decodedConfigSettingEntry;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.contractMaxSizeBytes,
+ this.contractCompute,
+ this.contractLedgerCost,
+ this.contractHistoricalData,
+ this.contractEvents,
+ this.contractBandwidth,
+ this.contractCostParamsCpuInsns,
+ this.contractCostParamsMemBytes,
+ this.contractDataKeySizeBytes,
+ this.contractDataEntrySizeBytes,
+ this.stateExpirationSettings,
+ this.contractExecutionLanes,
+ Arrays.hashCode(this.bucketListSizeWindow),
+ this.evictionIterator,
+ this.configSettingID);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ConfigSettingEntry)) {
+ return false;
+ }
+
+ ConfigSettingEntry other = (ConfigSettingEntry) object;
+ return Objects.equals(this.contractMaxSizeBytes, other.contractMaxSizeBytes)
+ && Objects.equals(this.contractCompute, other.contractCompute)
+ && Objects.equals(this.contractLedgerCost, other.contractLedgerCost)
+ && Objects.equals(this.contractHistoricalData, other.contractHistoricalData)
+ && Objects.equals(this.contractEvents, other.contractEvents)
+ && Objects.equals(this.contractBandwidth, other.contractBandwidth)
+ && Objects.equals(this.contractCostParamsCpuInsns, other.contractCostParamsCpuInsns)
+ && Objects.equals(this.contractCostParamsMemBytes, other.contractCostParamsMemBytes)
+ && Objects.equals(this.contractDataKeySizeBytes, other.contractDataKeySizeBytes)
+ && Objects.equals(this.contractDataEntrySizeBytes, other.contractDataEntrySizeBytes)
+ && Objects.equals(this.stateExpirationSettings, other.stateExpirationSettings)
+ && Objects.equals(this.contractExecutionLanes, other.contractExecutionLanes)
+ && Arrays.equals(this.bucketListSizeWindow, other.bucketListSizeWindow)
+ && Objects.equals(this.evictionIterator, other.evictionIterator)
+ && Objects.equals(this.configSettingID, other.configSettingID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ConfigSettingEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ConfigSettingEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ConfigSettingID.java b/src/main/java/org/stellar/sdk/xdr/ConfigSettingID.java
new file mode 100644
index 000000000..8b691e033
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ConfigSettingID.java
@@ -0,0 +1,127 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum ConfigSettingID
+// {
+// CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES = 0,
+// CONFIG_SETTING_CONTRACT_COMPUTE_V0 = 1,
+// CONFIG_SETTING_CONTRACT_LEDGER_COST_V0 = 2,
+// CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0 = 3,
+// CONFIG_SETTING_CONTRACT_EVENTS_V0 = 4,
+// CONFIG_SETTING_CONTRACT_BANDWIDTH_V0 = 5,
+// CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS = 6,
+// CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES = 7,
+// CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES = 8,
+// CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES = 9,
+// CONFIG_SETTING_STATE_EXPIRATION = 10,
+// CONFIG_SETTING_CONTRACT_EXECUTION_LANES = 11,
+// CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW = 12,
+// CONFIG_SETTING_EVICTION_ITERATOR = 13
+// };
+
+// ===========================================================================
+public enum ConfigSettingID implements XdrElement {
+ CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES(0),
+ CONFIG_SETTING_CONTRACT_COMPUTE_V0(1),
+ CONFIG_SETTING_CONTRACT_LEDGER_COST_V0(2),
+ CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0(3),
+ CONFIG_SETTING_CONTRACT_EVENTS_V0(4),
+ CONFIG_SETTING_CONTRACT_BANDWIDTH_V0(5),
+ CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS(6),
+ CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES(7),
+ CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES(8),
+ CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES(9),
+ CONFIG_SETTING_STATE_EXPIRATION(10),
+ CONFIG_SETTING_CONTRACT_EXECUTION_LANES(11),
+ CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW(12),
+ CONFIG_SETTING_EVICTION_ITERATOR(13),
+ ;
+ private int mValue;
+
+ ConfigSettingID(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static ConfigSettingID decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES;
+ case 1:
+ return CONFIG_SETTING_CONTRACT_COMPUTE_V0;
+ case 2:
+ return CONFIG_SETTING_CONTRACT_LEDGER_COST_V0;
+ case 3:
+ return CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0;
+ case 4:
+ return CONFIG_SETTING_CONTRACT_EVENTS_V0;
+ case 5:
+ return CONFIG_SETTING_CONTRACT_BANDWIDTH_V0;
+ case 6:
+ return CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS;
+ case 7:
+ return CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES;
+ case 8:
+ return CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES;
+ case 9:
+ return CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES;
+ case 10:
+ return CONFIG_SETTING_STATE_EXPIRATION;
+ case 11:
+ return CONFIG_SETTING_CONTRACT_EXECUTION_LANES;
+ case 12:
+ return CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW;
+ case 13:
+ return CONFIG_SETTING_EVICTION_ITERATOR;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, ConfigSettingID value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ConfigSettingID fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ConfigSettingID fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ConfigUpgradeSet.java b/src/main/java/org/stellar/sdk/xdr/ConfigUpgradeSet.java
new file mode 100644
index 000000000..4017cf0f6
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ConfigUpgradeSet.java
@@ -0,0 +1,110 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// struct ConfigUpgradeSet {
+// ConfigSettingEntry updatedEntry<>;
+// };
+
+// ===========================================================================
+public class ConfigUpgradeSet implements XdrElement {
+ public ConfigUpgradeSet() {}
+
+ private ConfigSettingEntry[] updatedEntry;
+
+ public ConfigSettingEntry[] getUpdatedEntry() {
+ return this.updatedEntry;
+ }
+
+ public void setUpdatedEntry(ConfigSettingEntry[] value) {
+ this.updatedEntry = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, ConfigUpgradeSet encodedConfigUpgradeSet)
+ throws IOException {
+ int updatedEntrysize = encodedConfigUpgradeSet.getUpdatedEntry().length;
+ stream.writeInt(updatedEntrysize);
+ for (int i = 0; i < updatedEntrysize; i++) {
+ ConfigSettingEntry.encode(stream, encodedConfigUpgradeSet.updatedEntry[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ConfigUpgradeSet decode(XdrDataInputStream stream) throws IOException {
+ ConfigUpgradeSet decodedConfigUpgradeSet = new ConfigUpgradeSet();
+ int updatedEntrysize = stream.readInt();
+ decodedConfigUpgradeSet.updatedEntry = new ConfigSettingEntry[updatedEntrysize];
+ for (int i = 0; i < updatedEntrysize; i++) {
+ decodedConfigUpgradeSet.updatedEntry[i] = ConfigSettingEntry.decode(stream);
+ }
+ return decodedConfigUpgradeSet;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(this.updatedEntry);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ConfigUpgradeSet)) {
+ return false;
+ }
+
+ ConfigUpgradeSet other = (ConfigUpgradeSet) object;
+ return Arrays.equals(this.updatedEntry, other.updatedEntry);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ConfigUpgradeSet fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ConfigUpgradeSet fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ConfigSettingEntry[] updatedEntry;
+
+ public Builder updatedEntry(ConfigSettingEntry[] updatedEntry) {
+ this.updatedEntry = updatedEntry;
+ return this;
+ }
+
+ public ConfigUpgradeSet build() {
+ ConfigUpgradeSet val = new ConfigUpgradeSet();
+ val.setUpdatedEntry(this.updatedEntry);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ConfigUpgradeSetKey.java b/src/main/java/org/stellar/sdk/xdr/ConfigUpgradeSetKey.java
new file mode 100644
index 000000000..e43f450da
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ConfigUpgradeSetKey.java
@@ -0,0 +1,124 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct ConfigUpgradeSetKey {
+// Hash contractID;
+// Hash contentHash;
+// };
+
+// ===========================================================================
+public class ConfigUpgradeSetKey implements XdrElement {
+ public ConfigUpgradeSetKey() {}
+
+ private Hash contractID;
+
+ public Hash getContractID() {
+ return this.contractID;
+ }
+
+ public void setContractID(Hash value) {
+ this.contractID = value;
+ }
+
+ private Hash contentHash;
+
+ public Hash getContentHash() {
+ return this.contentHash;
+ }
+
+ public void setContentHash(Hash value) {
+ this.contentHash = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, ConfigUpgradeSetKey encodedConfigUpgradeSetKey)
+ throws IOException {
+ Hash.encode(stream, encodedConfigUpgradeSetKey.contractID);
+ Hash.encode(stream, encodedConfigUpgradeSetKey.contentHash);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ConfigUpgradeSetKey decode(XdrDataInputStream stream) throws IOException {
+ ConfigUpgradeSetKey decodedConfigUpgradeSetKey = new ConfigUpgradeSetKey();
+ decodedConfigUpgradeSetKey.contractID = Hash.decode(stream);
+ decodedConfigUpgradeSetKey.contentHash = Hash.decode(stream);
+ return decodedConfigUpgradeSetKey;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.contractID, this.contentHash);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ConfigUpgradeSetKey)) {
+ return false;
+ }
+
+ ConfigUpgradeSetKey other = (ConfigUpgradeSetKey) object;
+ return Objects.equals(this.contractID, other.contractID)
+ && Objects.equals(this.contentHash, other.contentHash);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ConfigUpgradeSetKey fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ConfigUpgradeSetKey fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Hash contractID;
+ private Hash contentHash;
+
+ public Builder contractID(Hash contractID) {
+ this.contractID = contractID;
+ return this;
+ }
+
+ public Builder contentHash(Hash contentHash) {
+ this.contentHash = contentHash;
+ return this;
+ }
+
+ public ConfigUpgradeSetKey build() {
+ ConfigUpgradeSetKey val = new ConfigUpgradeSetKey();
+ val.setContractID(this.contractID);
+ val.setContentHash(this.contentHash);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Constants.java b/src/main/java/org/stellar/sdk/xdr/Constants.java
new file mode 100644
index 000000000..36c0ab556
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Constants.java
@@ -0,0 +1,26 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+public final class Constants {
+ private Constants() {}
+
+ public static final int MASK_ACCOUNT_FLAGS = 0x7;
+ public static final int MASK_ACCOUNT_FLAGS_V17 = 0xF;
+ public static final int MAX_SIGNERS = 20;
+ public static final int MASK_TRUSTLINE_FLAGS = 1;
+ public static final int MASK_TRUSTLINE_FLAGS_V13 = 3;
+ public static final int MASK_TRUSTLINE_FLAGS_V17 = 7;
+ public static final int MASK_OFFERENTRY_FLAGS = 1;
+ public static final int MASK_CLAIMABLE_BALANCE_FLAGS = 0x1;
+ public static final int MASK_LEDGER_HEADER_FLAGS = 0x7;
+ public static final int AUTH_MSG_FLAG_FLOW_CONTROL_BYTES_REQUESTED = 200;
+ public static final int TX_ADVERT_VECTOR_MAX_SIZE = 1000;
+ public static final int TX_DEMAND_VECTOR_MAX_SIZE = 1000;
+ public static final int MAX_OPS_PER_TX = 100;
+ public static final int LIQUIDITY_POOL_FEE_V18 = 30;
+ public static final int SC_SPEC_DOC_LIMIT = 1024;
+ public static final int SCSYMBOL_LIMIT = 32;
+ public static final int CONTRACT_COST_COUNT_LIMIT = 1024;
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ContractCodeEntry.java b/src/main/java/org/stellar/sdk/xdr/ContractCodeEntry.java
new file mode 100644
index 000000000..f4cb52371
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ContractCodeEntry.java
@@ -0,0 +1,150 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct ContractCodeEntry {
+// ExtensionPoint ext;
+//
+// Hash hash;
+// opaque code<>;
+// };
+
+// ===========================================================================
+public class ContractCodeEntry implements XdrElement {
+ public ContractCodeEntry() {}
+
+ private ExtensionPoint ext;
+
+ public ExtensionPoint getExt() {
+ return this.ext;
+ }
+
+ public void setExt(ExtensionPoint value) {
+ this.ext = value;
+ }
+
+ private Hash hash;
+
+ public Hash getHash() {
+ return this.hash;
+ }
+
+ public void setHash(Hash value) {
+ this.hash = value;
+ }
+
+ private byte[] code;
+
+ public byte[] getCode() {
+ return this.code;
+ }
+
+ public void setCode(byte[] value) {
+ this.code = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, ContractCodeEntry encodedContractCodeEntry)
+ throws IOException {
+ ExtensionPoint.encode(stream, encodedContractCodeEntry.ext);
+ Hash.encode(stream, encodedContractCodeEntry.hash);
+ int codesize = encodedContractCodeEntry.code.length;
+ stream.writeInt(codesize);
+ stream.write(encodedContractCodeEntry.getCode(), 0, codesize);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ContractCodeEntry decode(XdrDataInputStream stream) throws IOException {
+ ContractCodeEntry decodedContractCodeEntry = new ContractCodeEntry();
+ decodedContractCodeEntry.ext = ExtensionPoint.decode(stream);
+ decodedContractCodeEntry.hash = Hash.decode(stream);
+ int codesize = stream.readInt();
+ decodedContractCodeEntry.code = new byte[codesize];
+ stream.read(decodedContractCodeEntry.code, 0, codesize);
+ return decodedContractCodeEntry;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.ext, this.hash, Arrays.hashCode(this.code));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ContractCodeEntry)) {
+ return false;
+ }
+
+ ContractCodeEntry other = (ContractCodeEntry) object;
+ return Objects.equals(this.ext, other.ext)
+ && Objects.equals(this.hash, other.hash)
+ && Arrays.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractCodeEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractCodeEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ExtensionPoint ext;
+ private Hash hash;
+ private byte[] code;
+
+ public Builder ext(ExtensionPoint ext) {
+ this.ext = ext;
+ return this;
+ }
+
+ public Builder hash(Hash hash) {
+ this.hash = hash;
+ return this;
+ }
+
+ public Builder code(byte[] code) {
+ this.code = code;
+ return this;
+ }
+
+ public ContractCodeEntry build() {
+ ContractCodeEntry val = new ContractCodeEntry();
+ val.setExt(this.ext);
+ val.setHash(this.hash);
+ val.setCode(this.code);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ContractCostParamEntry.java b/src/main/java/org/stellar/sdk/xdr/ContractCostParamEntry.java
new file mode 100644
index 000000000..7cef7a241
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ContractCostParamEntry.java
@@ -0,0 +1,147 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct ContractCostParamEntry {
+// // use `ext` to add more terms (e.g. higher order polynomials) in the future
+// ExtensionPoint ext;
+//
+// int64 constTerm;
+// int64 linearTerm;
+// };
+
+// ===========================================================================
+public class ContractCostParamEntry implements XdrElement {
+ public ContractCostParamEntry() {}
+
+ private ExtensionPoint ext;
+
+ public ExtensionPoint getExt() {
+ return this.ext;
+ }
+
+ public void setExt(ExtensionPoint value) {
+ this.ext = value;
+ }
+
+ private Int64 constTerm;
+
+ public Int64 getConstTerm() {
+ return this.constTerm;
+ }
+
+ public void setConstTerm(Int64 value) {
+ this.constTerm = value;
+ }
+
+ private Int64 linearTerm;
+
+ public Int64 getLinearTerm() {
+ return this.linearTerm;
+ }
+
+ public void setLinearTerm(Int64 value) {
+ this.linearTerm = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, ContractCostParamEntry encodedContractCostParamEntry)
+ throws IOException {
+ ExtensionPoint.encode(stream, encodedContractCostParamEntry.ext);
+ Int64.encode(stream, encodedContractCostParamEntry.constTerm);
+ Int64.encode(stream, encodedContractCostParamEntry.linearTerm);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ContractCostParamEntry decode(XdrDataInputStream stream) throws IOException {
+ ContractCostParamEntry decodedContractCostParamEntry = new ContractCostParamEntry();
+ decodedContractCostParamEntry.ext = ExtensionPoint.decode(stream);
+ decodedContractCostParamEntry.constTerm = Int64.decode(stream);
+ decodedContractCostParamEntry.linearTerm = Int64.decode(stream);
+ return decodedContractCostParamEntry;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.ext, this.constTerm, this.linearTerm);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ContractCostParamEntry)) {
+ return false;
+ }
+
+ ContractCostParamEntry other = (ContractCostParamEntry) object;
+ return Objects.equals(this.ext, other.ext)
+ && Objects.equals(this.constTerm, other.constTerm)
+ && Objects.equals(this.linearTerm, other.linearTerm);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractCostParamEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractCostParamEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ExtensionPoint ext;
+ private Int64 constTerm;
+ private Int64 linearTerm;
+
+ public Builder ext(ExtensionPoint ext) {
+ this.ext = ext;
+ return this;
+ }
+
+ public Builder constTerm(Int64 constTerm) {
+ this.constTerm = constTerm;
+ return this;
+ }
+
+ public Builder linearTerm(Int64 linearTerm) {
+ this.linearTerm = linearTerm;
+ return this;
+ }
+
+ public ContractCostParamEntry build() {
+ ContractCostParamEntry val = new ContractCostParamEntry();
+ val.setExt(this.ext);
+ val.setConstTerm(this.constTerm);
+ val.setLinearTerm(this.linearTerm);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ContractCostParams.java b/src/main/java/org/stellar/sdk/xdr/ContractCostParams.java
new file mode 100644
index 000000000..203b067db
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ContractCostParams.java
@@ -0,0 +1,98 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// typedef ContractCostParamEntry ContractCostParams;
+
+// ===========================================================================
+public class ContractCostParams implements XdrElement {
+ private ContractCostParamEntry[] ContractCostParams;
+
+ public ContractCostParams() {}
+
+ public ContractCostParams(ContractCostParamEntry[] ContractCostParams) {
+ this.ContractCostParams = ContractCostParams;
+ }
+
+ public ContractCostParamEntry[] getContractCostParams() {
+ return this.ContractCostParams;
+ }
+
+ public void setContractCostParams(ContractCostParamEntry[] value) {
+ this.ContractCostParams = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, ContractCostParams encodedContractCostParams) throws IOException {
+ int ContractCostParamssize = encodedContractCostParams.getContractCostParams().length;
+ stream.writeInt(ContractCostParamssize);
+ for (int i = 0; i < ContractCostParamssize; i++) {
+ ContractCostParamEntry.encode(stream, encodedContractCostParams.ContractCostParams[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ContractCostParams decode(XdrDataInputStream stream) throws IOException {
+ ContractCostParams decodedContractCostParams = new ContractCostParams();
+ int ContractCostParamssize = stream.readInt();
+ decodedContractCostParams.ContractCostParams =
+ new ContractCostParamEntry[ContractCostParamssize];
+ for (int i = 0; i < ContractCostParamssize; i++) {
+ decodedContractCostParams.ContractCostParams[i] = ContractCostParamEntry.decode(stream);
+ }
+ return decodedContractCostParams;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(this.ContractCostParams);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ContractCostParams)) {
+ return false;
+ }
+
+ ContractCostParams other = (ContractCostParams) object;
+ return Arrays.equals(this.ContractCostParams, other.ContractCostParams);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractCostParams fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractCostParams fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ContractCostType.java b/src/main/java/org/stellar/sdk/xdr/ContractCostType.java
new file mode 100644
index 000000000..8ff3a78c4
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ContractCostType.java
@@ -0,0 +1,214 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum ContractCostType {
+// // Cost of running 1 wasm instruction
+// WasmInsnExec = 0,
+// // Cost of growing wasm linear memory by 1 page
+// WasmMemAlloc = 1,
+// // Cost of allocating a chuck of host memory (in bytes)
+// HostMemAlloc = 2,
+// // Cost of copying a chuck of bytes into a pre-allocated host memory
+// HostMemCpy = 3,
+// // Cost of comparing two slices of host memory
+// HostMemCmp = 4,
+// // Cost of a host function dispatch, not including the actual work done by
+// // the function nor the cost of VM invocation machinary
+// DispatchHostFunction = 5,
+// // Cost of visiting a host object from the host object storage. Exists to
+// // make sure some baseline cost coverage, i.e. repeatly visiting objects
+// // by the guest will always incur some charges.
+// VisitObject = 6,
+// // Cost of serializing an xdr object to bytes
+// ValSer = 7,
+// // Cost of deserializing an xdr object from bytes
+// ValDeser = 8,
+// // Cost of computing the sha256 hash from bytes
+// ComputeSha256Hash = 9,
+// // Cost of computing the ed25519 pubkey from bytes
+// ComputeEd25519PubKey = 10,
+// // Cost of accessing an entry in a Map.
+// MapEntry = 11,
+// // Cost of accessing an entry in a Vec
+// VecEntry = 12,
+// // Cost of verifying ed25519 signature of a payload.
+// VerifyEd25519Sig = 13,
+// // Cost of reading a slice of vm linear memory
+// VmMemRead = 14,
+// // Cost of writing to a slice of vm linear memory
+// VmMemWrite = 15,
+// // Cost of instantiation a VM from wasm bytes code.
+// VmInstantiation = 16,
+// // Cost of instantiation a VM from a cached state.
+// VmCachedInstantiation = 17,
+// // Cost of invoking a function on the VM. If the function is a host function,
+// // additional cost will be covered by `DispatchHostFunction`.
+// InvokeVmFunction = 18,
+// // Cost of computing a keccak256 hash from bytes.
+// ComputeKeccak256Hash = 19,
+// // Cost of computing an ECDSA secp256k1 pubkey from bytes.
+// ComputeEcdsaSecp256k1Key = 20,
+// // Cost of computing an ECDSA secp256k1 signature from bytes.
+// ComputeEcdsaSecp256k1Sig = 21,
+// // Cost of recovering an ECDSA secp256k1 key from a signature.
+// RecoverEcdsaSecp256k1Key = 22,
+// // Cost of int256 addition (`+`) and subtraction (`-`) operations
+// Int256AddSub = 23,
+// // Cost of int256 multiplication (`*`) operation
+// Int256Mul = 24,
+// // Cost of int256 division (`/`) operation
+// Int256Div = 25,
+// // Cost of int256 power (`exp`) operation
+// Int256Pow = 26,
+// // Cost of int256 shift (`shl`, `shr`) operation
+// Int256Shift = 27
+// };
+
+// ===========================================================================
+public enum ContractCostType implements XdrElement {
+ WasmInsnExec(0),
+ WasmMemAlloc(1),
+ HostMemAlloc(2),
+ HostMemCpy(3),
+ HostMemCmp(4),
+ DispatchHostFunction(5),
+ VisitObject(6),
+ ValSer(7),
+ ValDeser(8),
+ ComputeSha256Hash(9),
+ ComputeEd25519PubKey(10),
+ MapEntry(11),
+ VecEntry(12),
+ VerifyEd25519Sig(13),
+ VmMemRead(14),
+ VmMemWrite(15),
+ VmInstantiation(16),
+ VmCachedInstantiation(17),
+ InvokeVmFunction(18),
+ ComputeKeccak256Hash(19),
+ ComputeEcdsaSecp256k1Key(20),
+ ComputeEcdsaSecp256k1Sig(21),
+ RecoverEcdsaSecp256k1Key(22),
+ Int256AddSub(23),
+ Int256Mul(24),
+ Int256Div(25),
+ Int256Pow(26),
+ Int256Shift(27),
+ ;
+ private int mValue;
+
+ ContractCostType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static ContractCostType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return WasmInsnExec;
+ case 1:
+ return WasmMemAlloc;
+ case 2:
+ return HostMemAlloc;
+ case 3:
+ return HostMemCpy;
+ case 4:
+ return HostMemCmp;
+ case 5:
+ return DispatchHostFunction;
+ case 6:
+ return VisitObject;
+ case 7:
+ return ValSer;
+ case 8:
+ return ValDeser;
+ case 9:
+ return ComputeSha256Hash;
+ case 10:
+ return ComputeEd25519PubKey;
+ case 11:
+ return MapEntry;
+ case 12:
+ return VecEntry;
+ case 13:
+ return VerifyEd25519Sig;
+ case 14:
+ return VmMemRead;
+ case 15:
+ return VmMemWrite;
+ case 16:
+ return VmInstantiation;
+ case 17:
+ return VmCachedInstantiation;
+ case 18:
+ return InvokeVmFunction;
+ case 19:
+ return ComputeKeccak256Hash;
+ case 20:
+ return ComputeEcdsaSecp256k1Key;
+ case 21:
+ return ComputeEcdsaSecp256k1Sig;
+ case 22:
+ return RecoverEcdsaSecp256k1Key;
+ case 23:
+ return Int256AddSub;
+ case 24:
+ return Int256Mul;
+ case 25:
+ return Int256Div;
+ case 26:
+ return Int256Pow;
+ case 27:
+ return Int256Shift;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, ContractCostType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractCostType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractCostType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ContractDataDurability.java b/src/main/java/org/stellar/sdk/xdr/ContractDataDurability.java
new file mode 100644
index 000000000..7a7f8032d
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ContractDataDurability.java
@@ -0,0 +1,79 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum ContractDataDurability {
+// TEMPORARY = 0,
+// PERSISTENT = 1
+// };
+
+// ===========================================================================
+public enum ContractDataDurability implements XdrElement {
+ TEMPORARY(0),
+ PERSISTENT(1),
+ ;
+ private int mValue;
+
+ ContractDataDurability(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static ContractDataDurability decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return TEMPORARY;
+ case 1:
+ return PERSISTENT;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, ContractDataDurability value)
+ throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractDataDurability fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractDataDurability fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ContractDataEntry.java b/src/main/java/org/stellar/sdk/xdr/ContractDataEntry.java
new file mode 100644
index 000000000..0c1b5b8b8
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ContractDataEntry.java
@@ -0,0 +1,187 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct ContractDataEntry {
+// ExtensionPoint ext;
+//
+// SCAddress contract;
+// SCVal key;
+// ContractDataDurability durability;
+// SCVal val;
+// };
+
+// ===========================================================================
+public class ContractDataEntry implements XdrElement {
+ public ContractDataEntry() {}
+
+ private ExtensionPoint ext;
+
+ public ExtensionPoint getExt() {
+ return this.ext;
+ }
+
+ public void setExt(ExtensionPoint value) {
+ this.ext = value;
+ }
+
+ private SCAddress contract;
+
+ public SCAddress getContract() {
+ return this.contract;
+ }
+
+ public void setContract(SCAddress value) {
+ this.contract = value;
+ }
+
+ private SCVal key;
+
+ public SCVal getKey() {
+ return this.key;
+ }
+
+ public void setKey(SCVal value) {
+ this.key = value;
+ }
+
+ private ContractDataDurability durability;
+
+ public ContractDataDurability getDurability() {
+ return this.durability;
+ }
+
+ public void setDurability(ContractDataDurability value) {
+ this.durability = value;
+ }
+
+ private SCVal val;
+
+ public SCVal getVal() {
+ return this.val;
+ }
+
+ public void setVal(SCVal value) {
+ this.val = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, ContractDataEntry encodedContractDataEntry)
+ throws IOException {
+ ExtensionPoint.encode(stream, encodedContractDataEntry.ext);
+ SCAddress.encode(stream, encodedContractDataEntry.contract);
+ SCVal.encode(stream, encodedContractDataEntry.key);
+ ContractDataDurability.encode(stream, encodedContractDataEntry.durability);
+ SCVal.encode(stream, encodedContractDataEntry.val);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ContractDataEntry decode(XdrDataInputStream stream) throws IOException {
+ ContractDataEntry decodedContractDataEntry = new ContractDataEntry();
+ decodedContractDataEntry.ext = ExtensionPoint.decode(stream);
+ decodedContractDataEntry.contract = SCAddress.decode(stream);
+ decodedContractDataEntry.key = SCVal.decode(stream);
+ decodedContractDataEntry.durability = ContractDataDurability.decode(stream);
+ decodedContractDataEntry.val = SCVal.decode(stream);
+ return decodedContractDataEntry;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.ext, this.contract, this.key, this.durability, this.val);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ContractDataEntry)) {
+ return false;
+ }
+
+ ContractDataEntry other = (ContractDataEntry) object;
+ return Objects.equals(this.ext, other.ext)
+ && Objects.equals(this.contract, other.contract)
+ && Objects.equals(this.key, other.key)
+ && Objects.equals(this.durability, other.durability)
+ && Objects.equals(this.val, other.val);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractDataEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractDataEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ExtensionPoint ext;
+ private SCAddress contract;
+ private SCVal key;
+ private ContractDataDurability durability;
+ private SCVal val;
+
+ public Builder ext(ExtensionPoint ext) {
+ this.ext = ext;
+ return this;
+ }
+
+ public Builder contract(SCAddress contract) {
+ this.contract = contract;
+ return this;
+ }
+
+ public Builder key(SCVal key) {
+ this.key = key;
+ return this;
+ }
+
+ public Builder durability(ContractDataDurability durability) {
+ this.durability = durability;
+ return this;
+ }
+
+ public Builder val(SCVal val) {
+ this.val = val;
+ return this;
+ }
+
+ public ContractDataEntry build() {
+ ContractDataEntry val = new ContractDataEntry();
+ val.setExt(this.ext);
+ val.setContract(this.contract);
+ val.setKey(this.key);
+ val.setDurability(this.durability);
+ val.setVal(this.val);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ContractEvent.java b/src/main/java/org/stellar/sdk/xdr/ContractEvent.java
new file mode 100644
index 000000000..01e955a92
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ContractEvent.java
@@ -0,0 +1,411 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct ContractEvent
+// {
+// // We can use this to add more fields, or because it
+// // is first, to change ContractEvent into a union.
+// ExtensionPoint ext;
+//
+// Hash* contractID;
+// ContractEventType type;
+//
+// union switch (int v)
+// {
+// case 0:
+// struct
+// {
+// SCVal topics<>;
+// SCVal data;
+// } v0;
+// }
+// body;
+// };
+
+// ===========================================================================
+public class ContractEvent implements XdrElement {
+ public ContractEvent() {}
+
+ private ExtensionPoint ext;
+
+ public ExtensionPoint getExt() {
+ return this.ext;
+ }
+
+ public void setExt(ExtensionPoint value) {
+ this.ext = value;
+ }
+
+ private Hash contractID;
+
+ public Hash getContractID() {
+ return this.contractID;
+ }
+
+ public void setContractID(Hash value) {
+ this.contractID = value;
+ }
+
+ private ContractEventType type;
+
+ public ContractEventType getType() {
+ return this.type;
+ }
+
+ public void setType(ContractEventType value) {
+ this.type = value;
+ }
+
+ private ContractEventBody body;
+
+ public ContractEventBody getBody() {
+ return this.body;
+ }
+
+ public void setBody(ContractEventBody value) {
+ this.body = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, ContractEvent encodedContractEvent)
+ throws IOException {
+ ExtensionPoint.encode(stream, encodedContractEvent.ext);
+ if (encodedContractEvent.contractID != null) {
+ stream.writeInt(1);
+ Hash.encode(stream, encodedContractEvent.contractID);
+ } else {
+ stream.writeInt(0);
+ }
+ ContractEventType.encode(stream, encodedContractEvent.type);
+ ContractEventBody.encode(stream, encodedContractEvent.body);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ContractEvent decode(XdrDataInputStream stream) throws IOException {
+ ContractEvent decodedContractEvent = new ContractEvent();
+ decodedContractEvent.ext = ExtensionPoint.decode(stream);
+ int contractIDPresent = stream.readInt();
+ if (contractIDPresent != 0) {
+ decodedContractEvent.contractID = Hash.decode(stream);
+ }
+ decodedContractEvent.type = ContractEventType.decode(stream);
+ decodedContractEvent.body = ContractEventBody.decode(stream);
+ return decodedContractEvent;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.ext, this.contractID, this.type, this.body);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ContractEvent)) {
+ return false;
+ }
+
+ ContractEvent other = (ContractEvent) object;
+ return Objects.equals(this.ext, other.ext)
+ && Objects.equals(this.contractID, other.contractID)
+ && Objects.equals(this.type, other.type)
+ && Objects.equals(this.body, other.body);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractEvent fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractEvent fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ExtensionPoint ext;
+ private Hash contractID;
+ private ContractEventType type;
+ private ContractEventBody body;
+
+ public Builder ext(ExtensionPoint ext) {
+ this.ext = ext;
+ return this;
+ }
+
+ public Builder contractID(Hash contractID) {
+ this.contractID = contractID;
+ return this;
+ }
+
+ public Builder type(ContractEventType type) {
+ this.type = type;
+ return this;
+ }
+
+ public Builder body(ContractEventBody body) {
+ this.body = body;
+ return this;
+ }
+
+ public ContractEvent build() {
+ ContractEvent val = new ContractEvent();
+ val.setExt(this.ext);
+ val.setContractID(this.contractID);
+ val.setType(this.type);
+ val.setBody(this.body);
+ return val;
+ }
+ }
+
+ public static class ContractEventBody implements XdrElement {
+ public ContractEventBody() {}
+
+ Integer v;
+
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+
+ private ContractEventV0 v0;
+
+ public ContractEventV0 getV0() {
+ return this.v0;
+ }
+
+ public void setV0(ContractEventV0 value) {
+ this.v0 = value;
+ }
+
+ public static final class Builder {
+ private Integer discriminant;
+ private ContractEventV0 v0;
+
+ public Builder discriminant(Integer discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder v0(ContractEventV0 v0) {
+ this.v0 = v0;
+ return this;
+ }
+
+ public ContractEventBody build() {
+ ContractEventBody val = new ContractEventBody();
+ val.setDiscriminant(discriminant);
+ val.setV0(this.v0);
+ return val;
+ }
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, ContractEventBody encodedContractEventBody) throws IOException {
+ // Xdrgen::AST::Typespecs::Int
+ // Integer
+ stream.writeInt(encodedContractEventBody.getDiscriminant().intValue());
+ switch (encodedContractEventBody.getDiscriminant()) {
+ case 0:
+ ContractEventV0.encode(stream, encodedContractEventBody.v0);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ContractEventBody decode(XdrDataInputStream stream) throws IOException {
+ ContractEventBody decodedContractEventBody = new ContractEventBody();
+ Integer discriminant = stream.readInt();
+ decodedContractEventBody.setDiscriminant(discriminant);
+ switch (decodedContractEventBody.getDiscriminant()) {
+ case 0:
+ decodedContractEventBody.v0 = ContractEventV0.decode(stream);
+ break;
+ }
+ return decodedContractEventBody;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.v0, this.v);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ContractEventBody)) {
+ return false;
+ }
+
+ ContractEventBody other = (ContractEventBody) object;
+ return Objects.equals(this.v0, other.v0) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractEventBody fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractEventBody fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static class ContractEventV0 implements XdrElement {
+ public ContractEventV0() {}
+
+ private SCVal[] topics;
+
+ public SCVal[] getTopics() {
+ return this.topics;
+ }
+
+ public void setTopics(SCVal[] value) {
+ this.topics = value;
+ }
+
+ private SCVal data;
+
+ public SCVal getData() {
+ return this.data;
+ }
+
+ public void setData(SCVal value) {
+ this.data = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, ContractEventV0 encodedContractEventV0)
+ throws IOException {
+ int topicssize = encodedContractEventV0.getTopics().length;
+ stream.writeInt(topicssize);
+ for (int i = 0; i < topicssize; i++) {
+ SCVal.encode(stream, encodedContractEventV0.topics[i]);
+ }
+ SCVal.encode(stream, encodedContractEventV0.data);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ContractEventV0 decode(XdrDataInputStream stream) throws IOException {
+ ContractEventV0 decodedContractEventV0 = new ContractEventV0();
+ int topicssize = stream.readInt();
+ decodedContractEventV0.topics = new SCVal[topicssize];
+ for (int i = 0; i < topicssize; i++) {
+ decodedContractEventV0.topics[i] = SCVal.decode(stream);
+ }
+ decodedContractEventV0.data = SCVal.decode(stream);
+ return decodedContractEventV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(Arrays.hashCode(this.topics), this.data);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ContractEventV0)) {
+ return false;
+ }
+
+ ContractEventV0 other = (ContractEventV0) object;
+ return Arrays.equals(this.topics, other.topics) && Objects.equals(this.data, other.data);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractEventV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractEventV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCVal[] topics;
+ private SCVal data;
+
+ public Builder topics(SCVal[] topics) {
+ this.topics = topics;
+ return this;
+ }
+
+ public Builder data(SCVal data) {
+ this.data = data;
+ return this;
+ }
+
+ public ContractEventV0 build() {
+ ContractEventV0 val = new ContractEventV0();
+ val.setTopics(this.topics);
+ val.setData(this.data);
+ return val;
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ContractEventType.java b/src/main/java/org/stellar/sdk/xdr/ContractEventType.java
new file mode 100644
index 000000000..21d202ea8
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ContractEventType.java
@@ -0,0 +1,84 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum ContractEventType
+// {
+// SYSTEM = 0,
+// CONTRACT = 1,
+// DIAGNOSTIC = 2
+// };
+
+// ===========================================================================
+public enum ContractEventType implements XdrElement {
+ SYSTEM(0),
+ CONTRACT(1),
+ DIAGNOSTIC(2),
+ ;
+ private int mValue;
+
+ ContractEventType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static ContractEventType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SYSTEM;
+ case 1:
+ return CONTRACT;
+ case 2:
+ return DIAGNOSTIC;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, ContractEventType value)
+ throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractEventType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractEventType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ContractExecutable.java b/src/main/java/org/stellar/sdk/xdr/ContractExecutable.java
new file mode 100644
index 000000000..8007fcbd8
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ContractExecutable.java
@@ -0,0 +1,140 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union ContractExecutable switch (ContractExecutableType type)
+// {
+// case CONTRACT_EXECUTABLE_WASM:
+// Hash wasm_hash;
+// case CONTRACT_EXECUTABLE_TOKEN:
+// void;
+// };
+
+// ===========================================================================
+public class ContractExecutable implements XdrElement {
+ public ContractExecutable() {}
+
+ ContractExecutableType type;
+
+ public ContractExecutableType getDiscriminant() {
+ return this.type;
+ }
+
+ public void setDiscriminant(ContractExecutableType value) {
+ this.type = value;
+ }
+
+ private Hash wasm_hash;
+
+ public Hash getWasm_hash() {
+ return this.wasm_hash;
+ }
+
+ public void setWasm_hash(Hash value) {
+ this.wasm_hash = value;
+ }
+
+ public static final class Builder {
+ private ContractExecutableType discriminant;
+ private Hash wasm_hash;
+
+ public Builder discriminant(ContractExecutableType discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder wasm_hash(Hash wasm_hash) {
+ this.wasm_hash = wasm_hash;
+ return this;
+ }
+
+ public ContractExecutable build() {
+ ContractExecutable val = new ContractExecutable();
+ val.setDiscriminant(discriminant);
+ val.setWasm_hash(this.wasm_hash);
+ return val;
+ }
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, ContractExecutable encodedContractExecutable) throws IOException {
+ // Xdrgen::AST::Identifier
+ // ContractExecutableType
+ stream.writeInt(encodedContractExecutable.getDiscriminant().getValue());
+ switch (encodedContractExecutable.getDiscriminant()) {
+ case CONTRACT_EXECUTABLE_WASM:
+ Hash.encode(stream, encodedContractExecutable.wasm_hash);
+ break;
+ case CONTRACT_EXECUTABLE_TOKEN:
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ContractExecutable decode(XdrDataInputStream stream) throws IOException {
+ ContractExecutable decodedContractExecutable = new ContractExecutable();
+ ContractExecutableType discriminant = ContractExecutableType.decode(stream);
+ decodedContractExecutable.setDiscriminant(discriminant);
+ switch (decodedContractExecutable.getDiscriminant()) {
+ case CONTRACT_EXECUTABLE_WASM:
+ decodedContractExecutable.wasm_hash = Hash.decode(stream);
+ break;
+ case CONTRACT_EXECUTABLE_TOKEN:
+ break;
+ }
+ return decodedContractExecutable;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.wasm_hash, this.type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ContractExecutable)) {
+ return false;
+ }
+
+ ContractExecutable other = (ContractExecutable) object;
+ return Objects.equals(this.wasm_hash, other.wasm_hash) && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractExecutable fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractExecutable fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ContractExecutableType.java b/src/main/java/org/stellar/sdk/xdr/ContractExecutableType.java
new file mode 100644
index 000000000..76c59da2b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ContractExecutableType.java
@@ -0,0 +1,80 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum ContractExecutableType
+// {
+// CONTRACT_EXECUTABLE_WASM = 0,
+// CONTRACT_EXECUTABLE_TOKEN = 1
+// };
+
+// ===========================================================================
+public enum ContractExecutableType implements XdrElement {
+ CONTRACT_EXECUTABLE_WASM(0),
+ CONTRACT_EXECUTABLE_TOKEN(1),
+ ;
+ private int mValue;
+
+ ContractExecutableType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static ContractExecutableType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return CONTRACT_EXECUTABLE_WASM;
+ case 1:
+ return CONTRACT_EXECUTABLE_TOKEN;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, ContractExecutableType value)
+ throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractExecutableType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractExecutableType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ContractIDPreimage.java b/src/main/java/org/stellar/sdk/xdr/ContractIDPreimage.java
new file mode 100644
index 000000000..ff8dfdff9
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ContractIDPreimage.java
@@ -0,0 +1,271 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union ContractIDPreimage switch (ContractIDPreimageType type)
+// {
+// case CONTRACT_ID_PREIMAGE_FROM_ADDRESS:
+// struct
+// {
+// SCAddress address;
+// uint256 salt;
+// } fromAddress;
+// case CONTRACT_ID_PREIMAGE_FROM_ASSET:
+// Asset fromAsset;
+// };
+
+// ===========================================================================
+public class ContractIDPreimage implements XdrElement {
+ public ContractIDPreimage() {}
+
+ ContractIDPreimageType type;
+
+ public ContractIDPreimageType getDiscriminant() {
+ return this.type;
+ }
+
+ public void setDiscriminant(ContractIDPreimageType value) {
+ this.type = value;
+ }
+
+ private ContractIDPreimageFromAddress fromAddress;
+
+ public ContractIDPreimageFromAddress getFromAddress() {
+ return this.fromAddress;
+ }
+
+ public void setFromAddress(ContractIDPreimageFromAddress value) {
+ this.fromAddress = value;
+ }
+
+ private Asset fromAsset;
+
+ public Asset getFromAsset() {
+ return this.fromAsset;
+ }
+
+ public void setFromAsset(Asset value) {
+ this.fromAsset = value;
+ }
+
+ public static final class Builder {
+ private ContractIDPreimageType discriminant;
+ private ContractIDPreimageFromAddress fromAddress;
+ private Asset fromAsset;
+
+ public Builder discriminant(ContractIDPreimageType discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder fromAddress(ContractIDPreimageFromAddress fromAddress) {
+ this.fromAddress = fromAddress;
+ return this;
+ }
+
+ public Builder fromAsset(Asset fromAsset) {
+ this.fromAsset = fromAsset;
+ return this;
+ }
+
+ public ContractIDPreimage build() {
+ ContractIDPreimage val = new ContractIDPreimage();
+ val.setDiscriminant(discriminant);
+ val.setFromAddress(this.fromAddress);
+ val.setFromAsset(this.fromAsset);
+ return val;
+ }
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, ContractIDPreimage encodedContractIDPreimage) throws IOException {
+ // Xdrgen::AST::Identifier
+ // ContractIDPreimageType
+ stream.writeInt(encodedContractIDPreimage.getDiscriminant().getValue());
+ switch (encodedContractIDPreimage.getDiscriminant()) {
+ case CONTRACT_ID_PREIMAGE_FROM_ADDRESS:
+ ContractIDPreimageFromAddress.encode(stream, encodedContractIDPreimage.fromAddress);
+ break;
+ case CONTRACT_ID_PREIMAGE_FROM_ASSET:
+ Asset.encode(stream, encodedContractIDPreimage.fromAsset);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ContractIDPreimage decode(XdrDataInputStream stream) throws IOException {
+ ContractIDPreimage decodedContractIDPreimage = new ContractIDPreimage();
+ ContractIDPreimageType discriminant = ContractIDPreimageType.decode(stream);
+ decodedContractIDPreimage.setDiscriminant(discriminant);
+ switch (decodedContractIDPreimage.getDiscriminant()) {
+ case CONTRACT_ID_PREIMAGE_FROM_ADDRESS:
+ decodedContractIDPreimage.fromAddress = ContractIDPreimageFromAddress.decode(stream);
+ break;
+ case CONTRACT_ID_PREIMAGE_FROM_ASSET:
+ decodedContractIDPreimage.fromAsset = Asset.decode(stream);
+ break;
+ }
+ return decodedContractIDPreimage;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.fromAddress, this.fromAsset, this.type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ContractIDPreimage)) {
+ return false;
+ }
+
+ ContractIDPreimage other = (ContractIDPreimage) object;
+ return Objects.equals(this.fromAddress, other.fromAddress)
+ && Objects.equals(this.fromAsset, other.fromAsset)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractIDPreimage fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractIDPreimage fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static class ContractIDPreimageFromAddress implements XdrElement {
+ public ContractIDPreimageFromAddress() {}
+
+ private SCAddress address;
+
+ public SCAddress getAddress() {
+ return this.address;
+ }
+
+ public void setAddress(SCAddress value) {
+ this.address = value;
+ }
+
+ private Uint256 salt;
+
+ public Uint256 getSalt() {
+ return this.salt;
+ }
+
+ public void setSalt(Uint256 value) {
+ this.salt = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream,
+ ContractIDPreimageFromAddress encodedContractIDPreimageFromAddress)
+ throws IOException {
+ SCAddress.encode(stream, encodedContractIDPreimageFromAddress.address);
+ Uint256.encode(stream, encodedContractIDPreimageFromAddress.salt);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ContractIDPreimageFromAddress decode(XdrDataInputStream stream)
+ throws IOException {
+ ContractIDPreimageFromAddress decodedContractIDPreimageFromAddress =
+ new ContractIDPreimageFromAddress();
+ decodedContractIDPreimageFromAddress.address = SCAddress.decode(stream);
+ decodedContractIDPreimageFromAddress.salt = Uint256.decode(stream);
+ return decodedContractIDPreimageFromAddress;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.address, this.salt);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ContractIDPreimageFromAddress)) {
+ return false;
+ }
+
+ ContractIDPreimageFromAddress other = (ContractIDPreimageFromAddress) object;
+ return Objects.equals(this.address, other.address) && Objects.equals(this.salt, other.salt);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractIDPreimageFromAddress fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractIDPreimageFromAddress fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCAddress address;
+ private Uint256 salt;
+
+ public Builder address(SCAddress address) {
+ this.address = address;
+ return this;
+ }
+
+ public Builder salt(Uint256 salt) {
+ this.salt = salt;
+ return this;
+ }
+
+ public ContractIDPreimageFromAddress build() {
+ ContractIDPreimageFromAddress val = new ContractIDPreimageFromAddress();
+ val.setAddress(this.address);
+ val.setSalt(this.salt);
+ return val;
+ }
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ContractIDPreimageType.java b/src/main/java/org/stellar/sdk/xdr/ContractIDPreimageType.java
new file mode 100644
index 000000000..a9a113e0e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ContractIDPreimageType.java
@@ -0,0 +1,80 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum ContractIDPreimageType
+// {
+// CONTRACT_ID_PREIMAGE_FROM_ADDRESS = 0,
+// CONTRACT_ID_PREIMAGE_FROM_ASSET = 1
+// };
+
+// ===========================================================================
+public enum ContractIDPreimageType implements XdrElement {
+ CONTRACT_ID_PREIMAGE_FROM_ADDRESS(0),
+ CONTRACT_ID_PREIMAGE_FROM_ASSET(1),
+ ;
+ private int mValue;
+
+ ContractIDPreimageType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static ContractIDPreimageType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return CONTRACT_ID_PREIMAGE_FROM_ADDRESS;
+ case 1:
+ return CONTRACT_ID_PREIMAGE_FROM_ASSET;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, ContractIDPreimageType value)
+ throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ContractIDPreimageType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ContractIDPreimageType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreateAccountOp.java b/src/main/java/org/stellar/sdk/xdr/CreateAccountOp.java
index 22ff67755..11d84b9a7 100644
--- a/src/main/java/org/stellar/sdk/xdr/CreateAccountOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/CreateAccountOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -57,7 +62,7 @@ public static CreateAccountOp decode(XdrDataInputStream stream) throws IOExcepti
@Override
public int hashCode() {
- return Objects.hashCode(this.destination, this.startingBalance);
+ return Objects.hash(this.destination, this.startingBalance);
}
@Override
@@ -67,8 +72,32 @@ public boolean equals(Object object) {
}
CreateAccountOp other = (CreateAccountOp) object;
- return Objects.equal(this.destination, other.destination)
- && Objects.equal(this.startingBalance, other.startingBalance);
+ return Objects.equals(this.destination, other.destination)
+ && Objects.equals(this.startingBalance, other.startingBalance);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static CreateAccountOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static CreateAccountOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -87,8 +116,8 @@ public Builder startingBalance(Int64 startingBalance) {
public CreateAccountOp build() {
CreateAccountOp val = new CreateAccountOp();
- val.setDestination(destination);
- val.setStartingBalance(startingBalance);
+ val.setDestination(this.destination);
+ val.setStartingBalance(this.startingBalance);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreateAccountResult.java b/src/main/java/org/stellar/sdk/xdr/CreateAccountResult.java
index 17cb74466..2ed001166 100644
--- a/src/main/java/org/stellar/sdk/xdr/CreateAccountResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/CreateAccountResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,10 @@
// {
// case CREATE_ACCOUNT_SUCCESS:
// void;
-// default:
+// case CREATE_ACCOUNT_MALFORMED:
+// case CREATE_ACCOUNT_UNDERFUNDED:
+// case CREATE_ACCOUNT_LOW_RESERVE:
+// case CREATE_ACCOUNT_ALREADY_EXIST:
// void;
// };
@@ -54,7 +62,10 @@ public static void encode(
switch (encodedCreateAccountResult.getDiscriminant()) {
case CREATE_ACCOUNT_SUCCESS:
break;
- default:
+ case CREATE_ACCOUNT_MALFORMED:
+ case CREATE_ACCOUNT_UNDERFUNDED:
+ case CREATE_ACCOUNT_LOW_RESERVE:
+ case CREATE_ACCOUNT_ALREADY_EXIST:
break;
}
}
@@ -70,7 +81,10 @@ public static CreateAccountResult decode(XdrDataInputStream stream) throws IOExc
switch (decodedCreateAccountResult.getDiscriminant()) {
case CREATE_ACCOUNT_SUCCESS:
break;
- default:
+ case CREATE_ACCOUNT_MALFORMED:
+ case CREATE_ACCOUNT_UNDERFUNDED:
+ case CREATE_ACCOUNT_LOW_RESERVE:
+ case CREATE_ACCOUNT_ALREADY_EXIST:
break;
}
return decodedCreateAccountResult;
@@ -78,7 +92,7 @@ public static CreateAccountResult decode(XdrDataInputStream stream) throws IOExc
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -88,6 +102,30 @@ public boolean equals(Object object) {
}
CreateAccountResult other = (CreateAccountResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static CreateAccountResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static CreateAccountResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreateAccountResultCode.java b/src/main/java/org/stellar/sdk/xdr/CreateAccountResultCode.java
index 894409420..dde756a97 100644
--- a/src/main/java/org/stellar/sdk/xdr/CreateAccountResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/CreateAccountResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -64,4 +69,28 @@ public static void encode(XdrDataOutputStream stream, CreateAccountResultCode va
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static CreateAccountResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static CreateAccountResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreateClaimableBalanceOp.java b/src/main/java/org/stellar/sdk/xdr/CreateClaimableBalanceOp.java
index 5ccc4285b..4a428218c 100644
--- a/src/main/java/org/stellar/sdk/xdr/CreateClaimableBalanceOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/CreateClaimableBalanceOp.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -80,7 +85,7 @@ public static CreateClaimableBalanceOp decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(this.asset, this.amount, Arrays.hashCode(this.claimants));
+ return Objects.hash(this.asset, this.amount, Arrays.hashCode(this.claimants));
}
@Override
@@ -90,11 +95,35 @@ public boolean equals(Object object) {
}
CreateClaimableBalanceOp other = (CreateClaimableBalanceOp) object;
- return Objects.equal(this.asset, other.asset)
- && Objects.equal(this.amount, other.amount)
+ return Objects.equals(this.asset, other.asset)
+ && Objects.equals(this.amount, other.amount)
&& Arrays.equals(this.claimants, other.claimants);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static CreateClaimableBalanceOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static CreateClaimableBalanceOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private Asset asset;
private Int64 amount;
@@ -117,9 +146,9 @@ public Builder claimants(Claimant[] claimants) {
public CreateClaimableBalanceOp build() {
CreateClaimableBalanceOp val = new CreateClaimableBalanceOp();
- val.setAsset(asset);
- val.setAmount(amount);
- val.setClaimants(claimants);
+ val.setAsset(this.asset);
+ val.setAmount(this.amount);
+ val.setClaimants(this.claimants);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreateClaimableBalanceResult.java b/src/main/java/org/stellar/sdk/xdr/CreateClaimableBalanceResult.java
index 000e75597..98ded2563 100644
--- a/src/main/java/org/stellar/sdk/xdr/CreateClaimableBalanceResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/CreateClaimableBalanceResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -13,7 +18,11 @@
// {
// case CREATE_CLAIMABLE_BALANCE_SUCCESS:
// ClaimableBalanceID balanceID;
-// default:
+// case CREATE_CLAIMABLE_BALANCE_MALFORMED:
+// case CREATE_CLAIMABLE_BALANCE_LOW_RESERVE:
+// case CREATE_CLAIMABLE_BALANCE_NO_TRUST:
+// case CREATE_CLAIMABLE_BALANCE_NOT_AUTHORIZED:
+// case CREATE_CLAIMABLE_BALANCE_UNDERFUNDED:
// void;
// };
@@ -58,7 +67,7 @@ public Builder balanceID(ClaimableBalanceID balanceID) {
public CreateClaimableBalanceResult build() {
CreateClaimableBalanceResult val = new CreateClaimableBalanceResult();
val.setDiscriminant(discriminant);
- val.setBalanceID(balanceID);
+ val.setBalanceID(this.balanceID);
return val;
}
}
@@ -73,7 +82,11 @@ public static void encode(
case CREATE_CLAIMABLE_BALANCE_SUCCESS:
ClaimableBalanceID.encode(stream, encodedCreateClaimableBalanceResult.balanceID);
break;
- default:
+ case CREATE_CLAIMABLE_BALANCE_MALFORMED:
+ case CREATE_CLAIMABLE_BALANCE_LOW_RESERVE:
+ case CREATE_CLAIMABLE_BALANCE_NO_TRUST:
+ case CREATE_CLAIMABLE_BALANCE_NOT_AUTHORIZED:
+ case CREATE_CLAIMABLE_BALANCE_UNDERFUNDED:
break;
}
}
@@ -91,7 +104,11 @@ public static CreateClaimableBalanceResult decode(XdrDataInputStream stream) thr
case CREATE_CLAIMABLE_BALANCE_SUCCESS:
decodedCreateClaimableBalanceResult.balanceID = ClaimableBalanceID.decode(stream);
break;
- default:
+ case CREATE_CLAIMABLE_BALANCE_MALFORMED:
+ case CREATE_CLAIMABLE_BALANCE_LOW_RESERVE:
+ case CREATE_CLAIMABLE_BALANCE_NO_TRUST:
+ case CREATE_CLAIMABLE_BALANCE_NOT_AUTHORIZED:
+ case CREATE_CLAIMABLE_BALANCE_UNDERFUNDED:
break;
}
return decodedCreateClaimableBalanceResult;
@@ -99,7 +116,7 @@ public static CreateClaimableBalanceResult decode(XdrDataInputStream stream) thr
@Override
public int hashCode() {
- return Objects.hashCode(this.balanceID, this.code);
+ return Objects.hash(this.balanceID, this.code);
}
@Override
@@ -109,6 +126,30 @@ public boolean equals(Object object) {
}
CreateClaimableBalanceResult other = (CreateClaimableBalanceResult) object;
- return Objects.equal(this.balanceID, other.balanceID) && Objects.equal(this.code, other.code);
+ return Objects.equals(this.balanceID, other.balanceID) && Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static CreateClaimableBalanceResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static CreateClaimableBalanceResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreateClaimableBalanceResultCode.java b/src/main/java/org/stellar/sdk/xdr/CreateClaimableBalanceResultCode.java
index b7880cd66..b19e0e98e 100644
--- a/src/main/java/org/stellar/sdk/xdr/CreateClaimableBalanceResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/CreateClaimableBalanceResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -65,4 +70,28 @@ public static void encode(XdrDataOutputStream stream, CreateClaimableBalanceResu
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static CreateClaimableBalanceResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static CreateClaimableBalanceResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreateContractArgs.java b/src/main/java/org/stellar/sdk/xdr/CreateContractArgs.java
new file mode 100644
index 000000000..0d7cce8f4
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/CreateContractArgs.java
@@ -0,0 +1,124 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct CreateContractArgs
+// {
+// ContractIDPreimage contractIDPreimage;
+// ContractExecutable executable;
+// };
+
+// ===========================================================================
+public class CreateContractArgs implements XdrElement {
+ public CreateContractArgs() {}
+
+ private ContractIDPreimage contractIDPreimage;
+
+ public ContractIDPreimage getContractIDPreimage() {
+ return this.contractIDPreimage;
+ }
+
+ public void setContractIDPreimage(ContractIDPreimage value) {
+ this.contractIDPreimage = value;
+ }
+
+ private ContractExecutable executable;
+
+ public ContractExecutable getExecutable() {
+ return this.executable;
+ }
+
+ public void setExecutable(ContractExecutable value) {
+ this.executable = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, CreateContractArgs encodedCreateContractArgs) throws IOException {
+ ContractIDPreimage.encode(stream, encodedCreateContractArgs.contractIDPreimage);
+ ContractExecutable.encode(stream, encodedCreateContractArgs.executable);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static CreateContractArgs decode(XdrDataInputStream stream) throws IOException {
+ CreateContractArgs decodedCreateContractArgs = new CreateContractArgs();
+ decodedCreateContractArgs.contractIDPreimage = ContractIDPreimage.decode(stream);
+ decodedCreateContractArgs.executable = ContractExecutable.decode(stream);
+ return decodedCreateContractArgs;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.contractIDPreimage, this.executable);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof CreateContractArgs)) {
+ return false;
+ }
+
+ CreateContractArgs other = (CreateContractArgs) object;
+ return Objects.equals(this.contractIDPreimage, other.contractIDPreimage)
+ && Objects.equals(this.executable, other.executable);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static CreateContractArgs fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static CreateContractArgs fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ContractIDPreimage contractIDPreimage;
+ private ContractExecutable executable;
+
+ public Builder contractIDPreimage(ContractIDPreimage contractIDPreimage) {
+ this.contractIDPreimage = contractIDPreimage;
+ return this;
+ }
+
+ public Builder executable(ContractExecutable executable) {
+ this.executable = executable;
+ return this;
+ }
+
+ public CreateContractArgs build() {
+ CreateContractArgs val = new CreateContractArgs();
+ val.setContractIDPreimage(this.contractIDPreimage);
+ val.setExecutable(this.executable);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreatePassiveOfferOp.java b/src/main/java/org/stellar/sdk/xdr/CreatePassiveOfferOp.java
deleted file mode 100644
index 040ced2f8..000000000
--- a/src/main/java/org/stellar/sdk/xdr/CreatePassiveOfferOp.java
+++ /dev/null
@@ -1,79 +0,0 @@
-// Automatically generated by xdrgen
-// DO NOT EDIT or your changes may be overwritten
-
-package org.stellar.sdk.xdr;
-
-import java.io.IOException;
-
-// === xdr source ============================================================
-
-// struct CreatePassiveOfferOp
-// {
-// Asset selling; // A
-// Asset buying; // B
-// int64 amount; // amount taker gets. if set to 0, delete the offer
-// Price price; // cost of A in terms of B
-// };
-
-// ===========================================================================
-public class CreatePassiveOfferOp {
- public CreatePassiveOfferOp() {}
-
- private Asset selling;
-
- public Asset getSelling() {
- return this.selling;
- }
-
- public void setSelling(Asset value) {
- this.selling = value;
- }
-
- private Asset buying;
-
- public Asset getBuying() {
- return this.buying;
- }
-
- public void setBuying(Asset value) {
- this.buying = value;
- }
-
- private Int64 amount;
-
- public Int64 getAmount() {
- return this.amount;
- }
-
- public void setAmount(Int64 value) {
- this.amount = value;
- }
-
- private Price price;
-
- public Price getPrice() {
- return this.price;
- }
-
- public void setPrice(Price value) {
- this.price = value;
- }
-
- public static void encode(
- XdrDataOutputStream stream, CreatePassiveOfferOp encodedCreatePassiveOfferOp)
- throws IOException {
- Asset.encode(stream, encodedCreatePassiveOfferOp.selling);
- Asset.encode(stream, encodedCreatePassiveOfferOp.buying);
- Int64.encode(stream, encodedCreatePassiveOfferOp.amount);
- Price.encode(stream, encodedCreatePassiveOfferOp.price);
- }
-
- public static CreatePassiveOfferOp decode(XdrDataInputStream stream) throws IOException {
- CreatePassiveOfferOp decodedCreatePassiveOfferOp = new CreatePassiveOfferOp();
- decodedCreatePassiveOfferOp.selling = Asset.decode(stream);
- decodedCreatePassiveOfferOp.buying = Asset.decode(stream);
- decodedCreatePassiveOfferOp.amount = Int64.decode(stream);
- decodedCreatePassiveOfferOp.price = Price.decode(stream);
- return decodedCreatePassiveOfferOp;
- }
-}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreatePassiveSellOfferOp.java b/src/main/java/org/stellar/sdk/xdr/CreatePassiveSellOfferOp.java
index 9d98406a7..0d8e0a90b 100644
--- a/src/main/java/org/stellar/sdk/xdr/CreatePassiveSellOfferOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/CreatePassiveSellOfferOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -84,7 +89,7 @@ public static CreatePassiveSellOfferOp decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(this.selling, this.buying, this.amount, this.price);
+ return Objects.hash(this.selling, this.buying, this.amount, this.price);
}
@Override
@@ -94,10 +99,34 @@ public boolean equals(Object object) {
}
CreatePassiveSellOfferOp other = (CreatePassiveSellOfferOp) object;
- return Objects.equal(this.selling, other.selling)
- && Objects.equal(this.buying, other.buying)
- && Objects.equal(this.amount, other.amount)
- && Objects.equal(this.price, other.price);
+ return Objects.equals(this.selling, other.selling)
+ && Objects.equals(this.buying, other.buying)
+ && Objects.equals(this.amount, other.amount)
+ && Objects.equals(this.price, other.price);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static CreatePassiveSellOfferOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static CreatePassiveSellOfferOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -128,10 +157,10 @@ public Builder price(Price price) {
public CreatePassiveSellOfferOp build() {
CreatePassiveSellOfferOp val = new CreatePassiveSellOfferOp();
- val.setSelling(selling);
- val.setBuying(buying);
- val.setAmount(amount);
- val.setPrice(price);
+ val.setSelling(this.selling);
+ val.setBuying(this.buying);
+ val.setAmount(this.amount);
+ val.setPrice(this.price);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/CryptoKeyType.java b/src/main/java/org/stellar/sdk/xdr/CryptoKeyType.java
index 613f6978b..80509f5d7 100644
--- a/src/main/java/org/stellar/sdk/xdr/CryptoKeyType.java
+++ b/src/main/java/org/stellar/sdk/xdr/CryptoKeyType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -61,4 +66,28 @@ public static void encode(XdrDataOutputStream stream, CryptoKeyType value) throw
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static CryptoKeyType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static CryptoKeyType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Curve25519Public.java b/src/main/java/org/stellar/sdk/xdr/Curve25519Public.java
index 7ad32c318..b94746477 100644
--- a/src/main/java/org/stellar/sdk/xdr/Curve25519Public.java
+++ b/src/main/java/org/stellar/sdk/xdr/Curve25519Public.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -60,6 +65,30 @@ public boolean equals(Object object) {
return Arrays.equals(this.key, other.key);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Curve25519Public fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Curve25519Public fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private byte[] key;
@@ -70,7 +99,7 @@ public Builder key(byte[] key) {
public Curve25519Public build() {
Curve25519Public val = new Curve25519Public();
- val.setKey(key);
+ val.setKey(this.key);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Curve25519Secret.java b/src/main/java/org/stellar/sdk/xdr/Curve25519Secret.java
index 7495c70bc..1b4e2ec51 100644
--- a/src/main/java/org/stellar/sdk/xdr/Curve25519Secret.java
+++ b/src/main/java/org/stellar/sdk/xdr/Curve25519Secret.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -60,6 +65,30 @@ public boolean equals(Object object) {
return Arrays.equals(this.key, other.key);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Curve25519Secret fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Curve25519Secret fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private byte[] key;
@@ -70,7 +99,7 @@ public Builder key(byte[] key) {
public Curve25519Secret build() {
Curve25519Secret val = new Curve25519Secret();
- val.setKey(key);
+ val.setKey(this.key);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/DataEntry.java b/src/main/java/org/stellar/sdk/xdr/DataEntry.java
index 48ba0ca45..4b279752d 100644
--- a/src/main/java/org/stellar/sdk/xdr/DataEntry.java
+++ b/src/main/java/org/stellar/sdk/xdr/DataEntry.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -90,7 +95,7 @@ public static DataEntry decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.accountID, this.dataName, this.dataValue, this.ext);
+ return Objects.hash(this.accountID, this.dataName, this.dataValue, this.ext);
}
@Override
@@ -100,10 +105,34 @@ public boolean equals(Object object) {
}
DataEntry other = (DataEntry) object;
- return Objects.equal(this.accountID, other.accountID)
- && Objects.equal(this.dataName, other.dataName)
- && Objects.equal(this.dataValue, other.dataValue)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.accountID, other.accountID)
+ && Objects.equals(this.dataName, other.dataName)
+ && Objects.equals(this.dataValue, other.dataValue)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static DataEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static DataEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -134,15 +163,15 @@ public Builder ext(DataEntryExt ext) {
public DataEntry build() {
DataEntry val = new DataEntry();
- val.setAccountID(accountID);
- val.setDataName(dataName);
- val.setDataValue(dataValue);
- val.setExt(ext);
+ val.setAccountID(this.accountID);
+ val.setDataName(this.dataName);
+ val.setDataValue(this.dataValue);
+ val.setExt(this.ext);
return val;
}
}
- public static class DataEntryExt {
+ public static class DataEntryExt implements XdrElement {
public DataEntryExt() {}
Integer v;
@@ -198,7 +227,7 @@ public static DataEntryExt decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -208,7 +237,31 @@ public boolean equals(Object object) {
}
DataEntryExt other = (DataEntryExt) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static DataEntryExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static DataEntryExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/DataValue.java b/src/main/java/org/stellar/sdk/xdr/DataValue.java
index a4889ca1f..433a40782 100644
--- a/src/main/java/org/stellar/sdk/xdr/DataValue.java
+++ b/src/main/java/org/stellar/sdk/xdr/DataValue.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -61,4 +66,28 @@ public boolean equals(Object object) {
DataValue other = (DataValue) object;
return Arrays.equals(this.DataValue, other.DataValue);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static DataValue fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static DataValue fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/DecoratedSignature.java b/src/main/java/org/stellar/sdk/xdr/DecoratedSignature.java
index ba36e9529..48d3be132 100644
--- a/src/main/java/org/stellar/sdk/xdr/DecoratedSignature.java
+++ b/src/main/java/org/stellar/sdk/xdr/DecoratedSignature.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -57,7 +62,7 @@ public static DecoratedSignature decode(XdrDataInputStream stream) throws IOExce
@Override
public int hashCode() {
- return Objects.hashCode(this.hint, this.signature);
+ return Objects.hash(this.hint, this.signature);
}
@Override
@@ -67,7 +72,31 @@ public boolean equals(Object object) {
}
DecoratedSignature other = (DecoratedSignature) object;
- return Objects.equal(this.hint, other.hint) && Objects.equal(this.signature, other.signature);
+ return Objects.equals(this.hint, other.hint) && Objects.equals(this.signature, other.signature);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static DecoratedSignature fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static DecoratedSignature fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -86,8 +115,8 @@ public Builder signature(Signature signature) {
public DecoratedSignature build() {
DecoratedSignature val = new DecoratedSignature();
- val.setHint(hint);
- val.setSignature(signature);
+ val.setHint(this.hint);
+ val.setSignature(this.signature);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/DiagnosticEvent.java b/src/main/java/org/stellar/sdk/xdr/DiagnosticEvent.java
new file mode 100644
index 000000000..2479f2428
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/DiagnosticEvent.java
@@ -0,0 +1,124 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct DiagnosticEvent
+// {
+// bool inSuccessfulContractCall;
+// ContractEvent event;
+// };
+
+// ===========================================================================
+public class DiagnosticEvent implements XdrElement {
+ public DiagnosticEvent() {}
+
+ private Boolean inSuccessfulContractCall;
+
+ public Boolean getInSuccessfulContractCall() {
+ return this.inSuccessfulContractCall;
+ }
+
+ public void setInSuccessfulContractCall(Boolean value) {
+ this.inSuccessfulContractCall = value;
+ }
+
+ private ContractEvent event;
+
+ public ContractEvent getEvent() {
+ return this.event;
+ }
+
+ public void setEvent(ContractEvent value) {
+ this.event = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, DiagnosticEvent encodedDiagnosticEvent)
+ throws IOException {
+ stream.writeInt(encodedDiagnosticEvent.inSuccessfulContractCall ? 1 : 0);
+ ContractEvent.encode(stream, encodedDiagnosticEvent.event);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static DiagnosticEvent decode(XdrDataInputStream stream) throws IOException {
+ DiagnosticEvent decodedDiagnosticEvent = new DiagnosticEvent();
+ decodedDiagnosticEvent.inSuccessfulContractCall = stream.readInt() == 1 ? true : false;
+ decodedDiagnosticEvent.event = ContractEvent.decode(stream);
+ return decodedDiagnosticEvent;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.inSuccessfulContractCall, this.event);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof DiagnosticEvent)) {
+ return false;
+ }
+
+ DiagnosticEvent other = (DiagnosticEvent) object;
+ return Objects.equals(this.inSuccessfulContractCall, other.inSuccessfulContractCall)
+ && Objects.equals(this.event, other.event);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static DiagnosticEvent fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static DiagnosticEvent fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Boolean inSuccessfulContractCall;
+ private ContractEvent event;
+
+ public Builder inSuccessfulContractCall(Boolean inSuccessfulContractCall) {
+ this.inSuccessfulContractCall = inSuccessfulContractCall;
+ return this;
+ }
+
+ public Builder event(ContractEvent event) {
+ this.event = event;
+ return this;
+ }
+
+ public DiagnosticEvent build() {
+ DiagnosticEvent val = new DiagnosticEvent();
+ val.setInSuccessfulContractCall(this.inSuccessfulContractCall);
+ val.setEvent(this.event);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/DontHave.java b/src/main/java/org/stellar/sdk/xdr/DontHave.java
index 9c101b424..0174ec9a8 100644
--- a/src/main/java/org/stellar/sdk/xdr/DontHave.java
+++ b/src/main/java/org/stellar/sdk/xdr/DontHave.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -57,7 +62,7 @@ public static DontHave decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.type, this.reqHash);
+ return Objects.hash(this.type, this.reqHash);
}
@Override
@@ -67,7 +72,31 @@ public boolean equals(Object object) {
}
DontHave other = (DontHave) object;
- return Objects.equal(this.type, other.type) && Objects.equal(this.reqHash, other.reqHash);
+ return Objects.equals(this.type, other.type) && Objects.equals(this.reqHash, other.reqHash);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static DontHave fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static DontHave fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -86,8 +115,8 @@ public Builder reqHash(Uint256 reqHash) {
public DontHave build() {
DontHave val = new DontHave();
- val.setType(type);
- val.setReqHash(reqHash);
+ val.setType(this.type);
+ val.setReqHash(this.reqHash);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Duration.java b/src/main/java/org/stellar/sdk/xdr/Duration.java
index afdf76a67..850afd980 100644
--- a/src/main/java/org/stellar/sdk/xdr/Duration.java
+++ b/src/main/java/org/stellar/sdk/xdr/Duration.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -45,7 +50,7 @@ public static Duration decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.Duration);
+ return Objects.hash(this.Duration);
}
@Override
@@ -55,6 +60,30 @@ public boolean equals(Object object) {
}
Duration other = (Duration) object;
- return Objects.equal(this.Duration, other.Duration);
+ return Objects.equals(this.Duration, other.Duration);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Duration fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Duration fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/EncryptedBody.java b/src/main/java/org/stellar/sdk/xdr/EncryptedBody.java
index 0d0634b15..195f3bbdb 100644
--- a/src/main/java/org/stellar/sdk/xdr/EncryptedBody.java
+++ b/src/main/java/org/stellar/sdk/xdr/EncryptedBody.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -61,4 +66,28 @@ public boolean equals(Object object) {
EncryptedBody other = (EncryptedBody) object;
return Arrays.equals(this.EncryptedBody, other.EncryptedBody);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static EncryptedBody fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static EncryptedBody fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/EndSponsoringFutureReservesResult.java b/src/main/java/org/stellar/sdk/xdr/EndSponsoringFutureReservesResult.java
index 1384295cc..90123a3e7 100644
--- a/src/main/java/org/stellar/sdk/xdr/EndSponsoringFutureReservesResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/EndSponsoringFutureReservesResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -13,7 +18,7 @@
// {
// case END_SPONSORING_FUTURE_RESERVES_SUCCESS:
// void;
-// default:
+// case END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED:
// void;
// };
@@ -56,7 +61,7 @@ public static void encode(
switch (encodedEndSponsoringFutureReservesResult.getDiscriminant()) {
case END_SPONSORING_FUTURE_RESERVES_SUCCESS:
break;
- default:
+ case END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED:
break;
}
}
@@ -75,7 +80,7 @@ public static EndSponsoringFutureReservesResult decode(XdrDataInputStream stream
switch (decodedEndSponsoringFutureReservesResult.getDiscriminant()) {
case END_SPONSORING_FUTURE_RESERVES_SUCCESS:
break;
- default:
+ case END_SPONSORING_FUTURE_RESERVES_NOT_SPONSORED:
break;
}
return decodedEndSponsoringFutureReservesResult;
@@ -83,7 +88,7 @@ public static EndSponsoringFutureReservesResult decode(XdrDataInputStream stream
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -93,6 +98,30 @@ public boolean equals(Object object) {
}
EndSponsoringFutureReservesResult other = (EndSponsoringFutureReservesResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static EndSponsoringFutureReservesResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static EndSponsoringFutureReservesResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/EndSponsoringFutureReservesResultCode.java b/src/main/java/org/stellar/sdk/xdr/EndSponsoringFutureReservesResultCode.java
index e5a1263a4..1d51c8c41 100644
--- a/src/main/java/org/stellar/sdk/xdr/EndSponsoringFutureReservesResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/EndSponsoringFutureReservesResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -52,4 +57,29 @@ public static void encode(XdrDataOutputStream stream, EndSponsoringFutureReserve
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static EndSponsoringFutureReservesResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static EndSponsoringFutureReservesResultCode fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/EnvelopeType.java b/src/main/java/org/stellar/sdk/xdr/EnvelopeType.java
index 9b415bfed..cda5a5a0d 100644
--- a/src/main/java/org/stellar/sdk/xdr/EnvelopeType.java
+++ b/src/main/java/org/stellar/sdk/xdr/EnvelopeType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -16,7 +21,9 @@
// ENVELOPE_TYPE_SCPVALUE = 4,
// ENVELOPE_TYPE_TX_FEE_BUMP = 5,
// ENVELOPE_TYPE_OP_ID = 6,
-// ENVELOPE_TYPE_POOL_REVOKE_OP_ID = 7
+// ENVELOPE_TYPE_POOL_REVOKE_OP_ID = 7,
+// ENVELOPE_TYPE_CONTRACT_ID = 8,
+// ENVELOPE_TYPE_SOROBAN_AUTHORIZATION = 9
// };
// ===========================================================================
@@ -29,6 +36,8 @@ public enum EnvelopeType implements XdrElement {
ENVELOPE_TYPE_TX_FEE_BUMP(5),
ENVELOPE_TYPE_OP_ID(6),
ENVELOPE_TYPE_POOL_REVOKE_OP_ID(7),
+ ENVELOPE_TYPE_CONTRACT_ID(8),
+ ENVELOPE_TYPE_SOROBAN_AUTHORIZATION(9),
;
private int mValue;
@@ -59,6 +68,10 @@ public static EnvelopeType decode(XdrDataInputStream stream) throws IOException
return ENVELOPE_TYPE_OP_ID;
case 7:
return ENVELOPE_TYPE_POOL_REVOKE_OP_ID;
+ case 8:
+ return ENVELOPE_TYPE_CONTRACT_ID;
+ case 9:
+ return ENVELOPE_TYPE_SOROBAN_AUTHORIZATION;
default:
throw new RuntimeException("Unknown enum value: " + value);
}
@@ -71,4 +84,28 @@ public static void encode(XdrDataOutputStream stream, EnvelopeType value) throws
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static EnvelopeType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static EnvelopeType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Error.java b/src/main/java/org/stellar/sdk/xdr/Error.java
index d4fb3e2ed..8cd781329 100644
--- a/src/main/java/org/stellar/sdk/xdr/Error.java
+++ b/src/main/java/org/stellar/sdk/xdr/Error.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -56,7 +61,7 @@ public static Error decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.code, this.msg);
+ return Objects.hash(this.code, this.msg);
}
@Override
@@ -66,7 +71,31 @@ public boolean equals(Object object) {
}
Error other = (Error) object;
- return Objects.equal(this.code, other.code) && Objects.equal(this.msg, other.msg);
+ return Objects.equals(this.code, other.code) && Objects.equals(this.msg, other.msg);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Error fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Error fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -85,8 +114,8 @@ public Builder msg(XdrString msg) {
public Error build() {
Error val = new Error();
- val.setCode(code);
- val.setMsg(msg);
+ val.setCode(this.code);
+ val.setMsg(this.msg);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ErrorCode.java b/src/main/java/org/stellar/sdk/xdr/ErrorCode.java
index 8d987f005..87e1cb529 100644
--- a/src/main/java/org/stellar/sdk/xdr/ErrorCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/ErrorCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -59,4 +64,28 @@ public static void encode(XdrDataOutputStream stream, ErrorCode value) throws IO
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ErrorCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ErrorCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/EvictionIterator.java b/src/main/java/org/stellar/sdk/xdr/EvictionIterator.java
new file mode 100644
index 000000000..d190d4e65
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/EvictionIterator.java
@@ -0,0 +1,144 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct EvictionIterator {
+// uint32 bucketListLevel;
+// bool isCurrBucket;
+// uint64 bucketFileOffset;
+// };
+
+// ===========================================================================
+public class EvictionIterator implements XdrElement {
+ public EvictionIterator() {}
+
+ private Uint32 bucketListLevel;
+
+ public Uint32 getBucketListLevel() {
+ return this.bucketListLevel;
+ }
+
+ public void setBucketListLevel(Uint32 value) {
+ this.bucketListLevel = value;
+ }
+
+ private Boolean isCurrBucket;
+
+ public Boolean getIsCurrBucket() {
+ return this.isCurrBucket;
+ }
+
+ public void setIsCurrBucket(Boolean value) {
+ this.isCurrBucket = value;
+ }
+
+ private Uint64 bucketFileOffset;
+
+ public Uint64 getBucketFileOffset() {
+ return this.bucketFileOffset;
+ }
+
+ public void setBucketFileOffset(Uint64 value) {
+ this.bucketFileOffset = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, EvictionIterator encodedEvictionIterator)
+ throws IOException {
+ Uint32.encode(stream, encodedEvictionIterator.bucketListLevel);
+ stream.writeInt(encodedEvictionIterator.isCurrBucket ? 1 : 0);
+ Uint64.encode(stream, encodedEvictionIterator.bucketFileOffset);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static EvictionIterator decode(XdrDataInputStream stream) throws IOException {
+ EvictionIterator decodedEvictionIterator = new EvictionIterator();
+ decodedEvictionIterator.bucketListLevel = Uint32.decode(stream);
+ decodedEvictionIterator.isCurrBucket = stream.readInt() == 1 ? true : false;
+ decodedEvictionIterator.bucketFileOffset = Uint64.decode(stream);
+ return decodedEvictionIterator;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.bucketListLevel, this.isCurrBucket, this.bucketFileOffset);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof EvictionIterator)) {
+ return false;
+ }
+
+ EvictionIterator other = (EvictionIterator) object;
+ return Objects.equals(this.bucketListLevel, other.bucketListLevel)
+ && Objects.equals(this.isCurrBucket, other.isCurrBucket)
+ && Objects.equals(this.bucketFileOffset, other.bucketFileOffset);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static EvictionIterator fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static EvictionIterator fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Uint32 bucketListLevel;
+ private Boolean isCurrBucket;
+ private Uint64 bucketFileOffset;
+
+ public Builder bucketListLevel(Uint32 bucketListLevel) {
+ this.bucketListLevel = bucketListLevel;
+ return this;
+ }
+
+ public Builder isCurrBucket(Boolean isCurrBucket) {
+ this.isCurrBucket = isCurrBucket;
+ return this;
+ }
+
+ public Builder bucketFileOffset(Uint64 bucketFileOffset) {
+ this.bucketFileOffset = bucketFileOffset;
+ return this;
+ }
+
+ public EvictionIterator build() {
+ EvictionIterator val = new EvictionIterator();
+ val.setBucketListLevel(this.bucketListLevel);
+ val.setIsCurrBucket(this.isCurrBucket);
+ val.setBucketFileOffset(this.bucketFileOffset);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ExpirationEntry.java b/src/main/java/org/stellar/sdk/xdr/ExpirationEntry.java
new file mode 100644
index 000000000..f5d0a6555
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ExpirationEntry.java
@@ -0,0 +1,124 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct ExpirationEntry {
+// // Hash of the LedgerKey that is associated with this ExpirationEntry
+// Hash keyHash;
+// uint32 expirationLedgerSeq;
+// };
+
+// ===========================================================================
+public class ExpirationEntry implements XdrElement {
+ public ExpirationEntry() {}
+
+ private Hash keyHash;
+
+ public Hash getKeyHash() {
+ return this.keyHash;
+ }
+
+ public void setKeyHash(Hash value) {
+ this.keyHash = value;
+ }
+
+ private Uint32 expirationLedgerSeq;
+
+ public Uint32 getExpirationLedgerSeq() {
+ return this.expirationLedgerSeq;
+ }
+
+ public void setExpirationLedgerSeq(Uint32 value) {
+ this.expirationLedgerSeq = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, ExpirationEntry encodedExpirationEntry)
+ throws IOException {
+ Hash.encode(stream, encodedExpirationEntry.keyHash);
+ Uint32.encode(stream, encodedExpirationEntry.expirationLedgerSeq);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static ExpirationEntry decode(XdrDataInputStream stream) throws IOException {
+ ExpirationEntry decodedExpirationEntry = new ExpirationEntry();
+ decodedExpirationEntry.keyHash = Hash.decode(stream);
+ decodedExpirationEntry.expirationLedgerSeq = Uint32.decode(stream);
+ return decodedExpirationEntry;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.keyHash, this.expirationLedgerSeq);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ExpirationEntry)) {
+ return false;
+ }
+
+ ExpirationEntry other = (ExpirationEntry) object;
+ return Objects.equals(this.keyHash, other.keyHash)
+ && Objects.equals(this.expirationLedgerSeq, other.expirationLedgerSeq);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ExpirationEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ExpirationEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Hash keyHash;
+ private Uint32 expirationLedgerSeq;
+
+ public Builder keyHash(Hash keyHash) {
+ this.keyHash = keyHash;
+ return this;
+ }
+
+ public Builder expirationLedgerSeq(Uint32 expirationLedgerSeq) {
+ this.expirationLedgerSeq = expirationLedgerSeq;
+ return this;
+ }
+
+ public ExpirationEntry build() {
+ ExpirationEntry val = new ExpirationEntry();
+ val.setKeyHash(this.keyHash);
+ val.setExpirationLedgerSeq(this.expirationLedgerSeq);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ExtensionPoint.java b/src/main/java/org/stellar/sdk/xdr/ExtensionPoint.java
index 28e383dbd..fa72e4391 100644
--- a/src/main/java/org/stellar/sdk/xdr/ExtensionPoint.java
+++ b/src/main/java/org/stellar/sdk/xdr/ExtensionPoint.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -71,7 +76,7 @@ public static ExtensionPoint decode(XdrDataInputStream stream) throws IOExceptio
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -81,6 +86,30 @@ public boolean equals(Object object) {
}
ExtensionPoint other = (ExtensionPoint) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ExtensionPoint fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ExtensionPoint fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/FeeBumpTransaction.java b/src/main/java/org/stellar/sdk/xdr/FeeBumpTransaction.java
index 9f78faa9e..0463a6137 100644
--- a/src/main/java/org/stellar/sdk/xdr/FeeBumpTransaction.java
+++ b/src/main/java/org/stellar/sdk/xdr/FeeBumpTransaction.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -93,7 +98,7 @@ public static FeeBumpTransaction decode(XdrDataInputStream stream) throws IOExce
@Override
public int hashCode() {
- return Objects.hashCode(this.feeSource, this.fee, this.innerTx, this.ext);
+ return Objects.hash(this.feeSource, this.fee, this.innerTx, this.ext);
}
@Override
@@ -103,10 +108,34 @@ public boolean equals(Object object) {
}
FeeBumpTransaction other = (FeeBumpTransaction) object;
- return Objects.equal(this.feeSource, other.feeSource)
- && Objects.equal(this.fee, other.fee)
- && Objects.equal(this.innerTx, other.innerTx)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.feeSource, other.feeSource)
+ && Objects.equals(this.fee, other.fee)
+ && Objects.equals(this.innerTx, other.innerTx)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static FeeBumpTransaction fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static FeeBumpTransaction fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -137,15 +166,15 @@ public Builder ext(FeeBumpTransactionExt ext) {
public FeeBumpTransaction build() {
FeeBumpTransaction val = new FeeBumpTransaction();
- val.setFeeSource(feeSource);
- val.setFee(fee);
- val.setInnerTx(innerTx);
- val.setExt(ext);
+ val.setFeeSource(this.feeSource);
+ val.setFee(this.fee);
+ val.setInnerTx(this.innerTx);
+ val.setExt(this.ext);
return val;
}
}
- public static class FeeBumpTransactionInnerTx {
+ public static class FeeBumpTransactionInnerTx implements XdrElement {
public FeeBumpTransactionInnerTx() {}
EnvelopeType type;
@@ -185,7 +214,7 @@ public Builder v1(TransactionV1Envelope v1) {
public FeeBumpTransactionInnerTx build() {
FeeBumpTransactionInnerTx val = new FeeBumpTransactionInnerTx();
val.setDiscriminant(discriminant);
- val.setV1(v1);
+ val.setV1(this.v1);
return val;
}
}
@@ -221,7 +250,7 @@ public static FeeBumpTransactionInnerTx decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(this.v1, this.type);
+ return Objects.hash(this.v1, this.type);
}
@Override
@@ -231,11 +260,35 @@ public boolean equals(Object object) {
}
FeeBumpTransactionInnerTx other = (FeeBumpTransactionInnerTx) object;
- return Objects.equal(this.v1, other.v1) && Objects.equal(this.type, other.type);
+ return Objects.equals(this.v1, other.v1) && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static FeeBumpTransactionInnerTx fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static FeeBumpTransactionInnerTx fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
- public static class FeeBumpTransactionExt {
+ public static class FeeBumpTransactionExt implements XdrElement {
public FeeBumpTransactionExt() {}
Integer v;
@@ -292,7 +345,7 @@ public static FeeBumpTransactionExt decode(XdrDataInputStream stream) throws IOE
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -302,7 +355,31 @@ public boolean equals(Object object) {
}
FeeBumpTransactionExt other = (FeeBumpTransactionExt) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static FeeBumpTransactionExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static FeeBumpTransactionExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/FeeBumpTransactionEnvelope.java b/src/main/java/org/stellar/sdk/xdr/FeeBumpTransactionEnvelope.java
index e71b87522..5275168d1 100644
--- a/src/main/java/org/stellar/sdk/xdr/FeeBumpTransactionEnvelope.java
+++ b/src/main/java/org/stellar/sdk/xdr/FeeBumpTransactionEnvelope.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -69,7 +74,7 @@ public static FeeBumpTransactionEnvelope decode(XdrDataInputStream stream) throw
@Override
public int hashCode() {
- return Objects.hashCode(this.tx, Arrays.hashCode(this.signatures));
+ return Objects.hash(this.tx, Arrays.hashCode(this.signatures));
}
@Override
@@ -79,7 +84,31 @@ public boolean equals(Object object) {
}
FeeBumpTransactionEnvelope other = (FeeBumpTransactionEnvelope) object;
- return Objects.equal(this.tx, other.tx) && Arrays.equals(this.signatures, other.signatures);
+ return Objects.equals(this.tx, other.tx) && Arrays.equals(this.signatures, other.signatures);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static FeeBumpTransactionEnvelope fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static FeeBumpTransactionEnvelope fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -98,8 +127,8 @@ public Builder signatures(DecoratedSignature[] signatures) {
public FeeBumpTransactionEnvelope build() {
FeeBumpTransactionEnvelope val = new FeeBumpTransactionEnvelope();
- val.setTx(tx);
- val.setSignatures(signatures);
+ val.setTx(this.tx);
+ val.setSignatures(this.signatures);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/FloodAdvert.java b/src/main/java/org/stellar/sdk/xdr/FloodAdvert.java
new file mode 100644
index 000000000..6263eeb7d
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/FloodAdvert.java
@@ -0,0 +1,103 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct FloodAdvert
+// {
+// TxAdvertVector txHashes;
+// };
+
+// ===========================================================================
+public class FloodAdvert implements XdrElement {
+ public FloodAdvert() {}
+
+ private TxAdvertVector txHashes;
+
+ public TxAdvertVector getTxHashes() {
+ return this.txHashes;
+ }
+
+ public void setTxHashes(TxAdvertVector value) {
+ this.txHashes = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, FloodAdvert encodedFloodAdvert)
+ throws IOException {
+ TxAdvertVector.encode(stream, encodedFloodAdvert.txHashes);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static FloodAdvert decode(XdrDataInputStream stream) throws IOException {
+ FloodAdvert decodedFloodAdvert = new FloodAdvert();
+ decodedFloodAdvert.txHashes = TxAdvertVector.decode(stream);
+ return decodedFloodAdvert;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.txHashes);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof FloodAdvert)) {
+ return false;
+ }
+
+ FloodAdvert other = (FloodAdvert) object;
+ return Objects.equals(this.txHashes, other.txHashes);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static FloodAdvert fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static FloodAdvert fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private TxAdvertVector txHashes;
+
+ public Builder txHashes(TxAdvertVector txHashes) {
+ this.txHashes = txHashes;
+ return this;
+ }
+
+ public FloodAdvert build() {
+ FloodAdvert val = new FloodAdvert();
+ val.setTxHashes(this.txHashes);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/FloodDemand.java b/src/main/java/org/stellar/sdk/xdr/FloodDemand.java
new file mode 100644
index 000000000..2c0ca87c2
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/FloodDemand.java
@@ -0,0 +1,103 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct FloodDemand
+// {
+// TxDemandVector txHashes;
+// };
+
+// ===========================================================================
+public class FloodDemand implements XdrElement {
+ public FloodDemand() {}
+
+ private TxDemandVector txHashes;
+
+ public TxDemandVector getTxHashes() {
+ return this.txHashes;
+ }
+
+ public void setTxHashes(TxDemandVector value) {
+ this.txHashes = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, FloodDemand encodedFloodDemand)
+ throws IOException {
+ TxDemandVector.encode(stream, encodedFloodDemand.txHashes);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static FloodDemand decode(XdrDataInputStream stream) throws IOException {
+ FloodDemand decodedFloodDemand = new FloodDemand();
+ decodedFloodDemand.txHashes = TxDemandVector.decode(stream);
+ return decodedFloodDemand;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.txHashes);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof FloodDemand)) {
+ return false;
+ }
+
+ FloodDemand other = (FloodDemand) object;
+ return Objects.equals(this.txHashes, other.txHashes);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static FloodDemand fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static FloodDemand fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private TxDemandVector txHashes;
+
+ public Builder txHashes(TxDemandVector txHashes) {
+ this.txHashes = txHashes;
+ return this;
+ }
+
+ public FloodDemand build() {
+ FloodDemand val = new FloodDemand();
+ val.setTxHashes(this.txHashes);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/GeneralizedTransactionSet.java b/src/main/java/org/stellar/sdk/xdr/GeneralizedTransactionSet.java
new file mode 100644
index 000000000..5d677dc43
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/GeneralizedTransactionSet.java
@@ -0,0 +1,136 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union GeneralizedTransactionSet switch (int v)
+// {
+// // We consider the legacy TransactionSet to be v0.
+// case 1:
+// TransactionSetV1 v1TxSet;
+// };
+
+// ===========================================================================
+public class GeneralizedTransactionSet implements XdrElement {
+ public GeneralizedTransactionSet() {}
+
+ Integer v;
+
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+
+ private TransactionSetV1 v1TxSet;
+
+ public TransactionSetV1 getV1TxSet() {
+ return this.v1TxSet;
+ }
+
+ public void setV1TxSet(TransactionSetV1 value) {
+ this.v1TxSet = value;
+ }
+
+ public static final class Builder {
+ private Integer discriminant;
+ private TransactionSetV1 v1TxSet;
+
+ public Builder discriminant(Integer discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder v1TxSet(TransactionSetV1 v1TxSet) {
+ this.v1TxSet = v1TxSet;
+ return this;
+ }
+
+ public GeneralizedTransactionSet build() {
+ GeneralizedTransactionSet val = new GeneralizedTransactionSet();
+ val.setDiscriminant(discriminant);
+ val.setV1TxSet(this.v1TxSet);
+ return val;
+ }
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, GeneralizedTransactionSet encodedGeneralizedTransactionSet)
+ throws IOException {
+ // Xdrgen::AST::Typespecs::Int
+ // Integer
+ stream.writeInt(encodedGeneralizedTransactionSet.getDiscriminant().intValue());
+ switch (encodedGeneralizedTransactionSet.getDiscriminant()) {
+ case 1:
+ TransactionSetV1.encode(stream, encodedGeneralizedTransactionSet.v1TxSet);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static GeneralizedTransactionSet decode(XdrDataInputStream stream) throws IOException {
+ GeneralizedTransactionSet decodedGeneralizedTransactionSet = new GeneralizedTransactionSet();
+ Integer discriminant = stream.readInt();
+ decodedGeneralizedTransactionSet.setDiscriminant(discriminant);
+ switch (decodedGeneralizedTransactionSet.getDiscriminant()) {
+ case 1:
+ decodedGeneralizedTransactionSet.v1TxSet = TransactionSetV1.decode(stream);
+ break;
+ }
+ return decodedGeneralizedTransactionSet;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.v1TxSet, this.v);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof GeneralizedTransactionSet)) {
+ return false;
+ }
+
+ GeneralizedTransactionSet other = (GeneralizedTransactionSet) object;
+ return Objects.equals(this.v1TxSet, other.v1TxSet) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static GeneralizedTransactionSet fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static GeneralizedTransactionSet fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Hash.java b/src/main/java/org/stellar/sdk/xdr/Hash.java
index aa92d602b..f72221f1d 100644
--- a/src/main/java/org/stellar/sdk/xdr/Hash.java
+++ b/src/main/java/org/stellar/sdk/xdr/Hash.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -59,4 +64,28 @@ public boolean equals(Object object) {
Hash other = (Hash) object;
return Arrays.equals(this.Hash, other.Hash);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Hash fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Hash fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/HashIDPreimage.java b/src/main/java/org/stellar/sdk/xdr/HashIDPreimage.java
index 71c9e940b..5216f1a5c 100644
--- a/src/main/java/org/stellar/sdk/xdr/HashIDPreimage.java
+++ b/src/main/java/org/stellar/sdk/xdr/HashIDPreimage.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -26,6 +31,20 @@
// PoolID liquidityPoolID;
// Asset asset;
// } revokeID;
+// case ENVELOPE_TYPE_CONTRACT_ID:
+// struct
+// {
+// Hash networkID;
+// ContractIDPreimage contractIDPreimage;
+// } contractID;
+// case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION:
+// struct
+// {
+// Hash networkID;
+// int64 nonce;
+// uint32 signatureExpirationLedger;
+// SorobanAuthorizedInvocation invocation;
+// } sorobanAuthorization;
// };
// ===========================================================================
@@ -62,10 +81,32 @@ public void setRevokeID(HashIDPreimageRevokeID value) {
this.revokeID = value;
}
+ private HashIDPreimageContractID contractID;
+
+ public HashIDPreimageContractID getContractID() {
+ return this.contractID;
+ }
+
+ public void setContractID(HashIDPreimageContractID value) {
+ this.contractID = value;
+ }
+
+ private HashIDPreimageSorobanAuthorization sorobanAuthorization;
+
+ public HashIDPreimageSorobanAuthorization getSorobanAuthorization() {
+ return this.sorobanAuthorization;
+ }
+
+ public void setSorobanAuthorization(HashIDPreimageSorobanAuthorization value) {
+ this.sorobanAuthorization = value;
+ }
+
public static final class Builder {
private EnvelopeType discriminant;
private HashIDPreimageOperationID operationID;
private HashIDPreimageRevokeID revokeID;
+ private HashIDPreimageContractID contractID;
+ private HashIDPreimageSorobanAuthorization sorobanAuthorization;
public Builder discriminant(EnvelopeType discriminant) {
this.discriminant = discriminant;
@@ -82,11 +123,23 @@ public Builder revokeID(HashIDPreimageRevokeID revokeID) {
return this;
}
+ public Builder contractID(HashIDPreimageContractID contractID) {
+ this.contractID = contractID;
+ return this;
+ }
+
+ public Builder sorobanAuthorization(HashIDPreimageSorobanAuthorization sorobanAuthorization) {
+ this.sorobanAuthorization = sorobanAuthorization;
+ return this;
+ }
+
public HashIDPreimage build() {
HashIDPreimage val = new HashIDPreimage();
val.setDiscriminant(discriminant);
- val.setOperationID(operationID);
- val.setRevokeID(revokeID);
+ val.setOperationID(this.operationID);
+ val.setRevokeID(this.revokeID);
+ val.setContractID(this.contractID);
+ val.setSorobanAuthorization(this.sorobanAuthorization);
return val;
}
}
@@ -103,6 +156,13 @@ public static void encode(XdrDataOutputStream stream, HashIDPreimage encodedHash
case ENVELOPE_TYPE_POOL_REVOKE_OP_ID:
HashIDPreimageRevokeID.encode(stream, encodedHashIDPreimage.revokeID);
break;
+ case ENVELOPE_TYPE_CONTRACT_ID:
+ HashIDPreimageContractID.encode(stream, encodedHashIDPreimage.contractID);
+ break;
+ case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION:
+ HashIDPreimageSorobanAuthorization.encode(
+ stream, encodedHashIDPreimage.sorobanAuthorization);
+ break;
}
}
@@ -121,13 +181,21 @@ public static HashIDPreimage decode(XdrDataInputStream stream) throws IOExceptio
case ENVELOPE_TYPE_POOL_REVOKE_OP_ID:
decodedHashIDPreimage.revokeID = HashIDPreimageRevokeID.decode(stream);
break;
+ case ENVELOPE_TYPE_CONTRACT_ID:
+ decodedHashIDPreimage.contractID = HashIDPreimageContractID.decode(stream);
+ break;
+ case ENVELOPE_TYPE_SOROBAN_AUTHORIZATION:
+ decodedHashIDPreimage.sorobanAuthorization =
+ HashIDPreimageSorobanAuthorization.decode(stream);
+ break;
}
return decodedHashIDPreimage;
}
@Override
public int hashCode() {
- return Objects.hashCode(this.operationID, this.revokeID, this.type);
+ return Objects.hash(
+ this.operationID, this.revokeID, this.contractID, this.sorobanAuthorization, this.type);
}
@Override
@@ -137,12 +205,38 @@ public boolean equals(Object object) {
}
HashIDPreimage other = (HashIDPreimage) object;
- return Objects.equal(this.operationID, other.operationID)
- && Objects.equal(this.revokeID, other.revokeID)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.operationID, other.operationID)
+ && Objects.equals(this.revokeID, other.revokeID)
+ && Objects.equals(this.contractID, other.contractID)
+ && Objects.equals(this.sorobanAuthorization, other.sorobanAuthorization)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static HashIDPreimage fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static HashIDPreimage fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
- public static class HashIDPreimageOperationID {
+ public static class HashIDPreimageOperationID implements XdrElement {
public HashIDPreimageOperationID() {}
private AccountID sourceAccount;
@@ -197,7 +291,7 @@ public static HashIDPreimageOperationID decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(this.sourceAccount, this.seqNum, this.opNum);
+ return Objects.hash(this.sourceAccount, this.seqNum, this.opNum);
}
@Override
@@ -207,9 +301,33 @@ public boolean equals(Object object) {
}
HashIDPreimageOperationID other = (HashIDPreimageOperationID) object;
- return Objects.equal(this.sourceAccount, other.sourceAccount)
- && Objects.equal(this.seqNum, other.seqNum)
- && Objects.equal(this.opNum, other.opNum);
+ return Objects.equals(this.sourceAccount, other.sourceAccount)
+ && Objects.equals(this.seqNum, other.seqNum)
+ && Objects.equals(this.opNum, other.opNum);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static HashIDPreimageOperationID fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static HashIDPreimageOperationID fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -234,15 +352,15 @@ public Builder opNum(Uint32 opNum) {
public HashIDPreimageOperationID build() {
HashIDPreimageOperationID val = new HashIDPreimageOperationID();
- val.setSourceAccount(sourceAccount);
- val.setSeqNum(seqNum);
- val.setOpNum(opNum);
+ val.setSourceAccount(this.sourceAccount);
+ val.setSeqNum(this.seqNum);
+ val.setOpNum(this.opNum);
return val;
}
}
}
- public static class HashIDPreimageRevokeID {
+ public static class HashIDPreimageRevokeID implements XdrElement {
public HashIDPreimageRevokeID() {}
private AccountID sourceAccount;
@@ -321,7 +439,7 @@ public static HashIDPreimageRevokeID decode(XdrDataInputStream stream) throws IO
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.sourceAccount, this.seqNum, this.opNum, this.liquidityPoolID, this.asset);
}
@@ -332,11 +450,35 @@ public boolean equals(Object object) {
}
HashIDPreimageRevokeID other = (HashIDPreimageRevokeID) object;
- return Objects.equal(this.sourceAccount, other.sourceAccount)
- && Objects.equal(this.seqNum, other.seqNum)
- && Objects.equal(this.opNum, other.opNum)
- && Objects.equal(this.liquidityPoolID, other.liquidityPoolID)
- && Objects.equal(this.asset, other.asset);
+ return Objects.equals(this.sourceAccount, other.sourceAccount)
+ && Objects.equals(this.seqNum, other.seqNum)
+ && Objects.equals(this.opNum, other.opNum)
+ && Objects.equals(this.liquidityPoolID, other.liquidityPoolID)
+ && Objects.equals(this.asset, other.asset);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static HashIDPreimageRevokeID fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static HashIDPreimageRevokeID fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -373,11 +515,266 @@ public Builder asset(Asset asset) {
public HashIDPreimageRevokeID build() {
HashIDPreimageRevokeID val = new HashIDPreimageRevokeID();
- val.setSourceAccount(sourceAccount);
- val.setSeqNum(seqNum);
- val.setOpNum(opNum);
- val.setLiquidityPoolID(liquidityPoolID);
- val.setAsset(asset);
+ val.setSourceAccount(this.sourceAccount);
+ val.setSeqNum(this.seqNum);
+ val.setOpNum(this.opNum);
+ val.setLiquidityPoolID(this.liquidityPoolID);
+ val.setAsset(this.asset);
+ return val;
+ }
+ }
+ }
+
+ public static class HashIDPreimageContractID implements XdrElement {
+ public HashIDPreimageContractID() {}
+
+ private Hash networkID;
+
+ public Hash getNetworkID() {
+ return this.networkID;
+ }
+
+ public void setNetworkID(Hash value) {
+ this.networkID = value;
+ }
+
+ private ContractIDPreimage contractIDPreimage;
+
+ public ContractIDPreimage getContractIDPreimage() {
+ return this.contractIDPreimage;
+ }
+
+ public void setContractIDPreimage(ContractIDPreimage value) {
+ this.contractIDPreimage = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, HashIDPreimageContractID encodedHashIDPreimageContractID)
+ throws IOException {
+ Hash.encode(stream, encodedHashIDPreimageContractID.networkID);
+ ContractIDPreimage.encode(stream, encodedHashIDPreimageContractID.contractIDPreimage);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static HashIDPreimageContractID decode(XdrDataInputStream stream) throws IOException {
+ HashIDPreimageContractID decodedHashIDPreimageContractID = new HashIDPreimageContractID();
+ decodedHashIDPreimageContractID.networkID = Hash.decode(stream);
+ decodedHashIDPreimageContractID.contractIDPreimage = ContractIDPreimage.decode(stream);
+ return decodedHashIDPreimageContractID;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.networkID, this.contractIDPreimage);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof HashIDPreimageContractID)) {
+ return false;
+ }
+
+ HashIDPreimageContractID other = (HashIDPreimageContractID) object;
+ return Objects.equals(this.networkID, other.networkID)
+ && Objects.equals(this.contractIDPreimage, other.contractIDPreimage);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static HashIDPreimageContractID fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static HashIDPreimageContractID fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Hash networkID;
+ private ContractIDPreimage contractIDPreimage;
+
+ public Builder networkID(Hash networkID) {
+ this.networkID = networkID;
+ return this;
+ }
+
+ public Builder contractIDPreimage(ContractIDPreimage contractIDPreimage) {
+ this.contractIDPreimage = contractIDPreimage;
+ return this;
+ }
+
+ public HashIDPreimageContractID build() {
+ HashIDPreimageContractID val = new HashIDPreimageContractID();
+ val.setNetworkID(this.networkID);
+ val.setContractIDPreimage(this.contractIDPreimage);
+ return val;
+ }
+ }
+ }
+
+ public static class HashIDPreimageSorobanAuthorization implements XdrElement {
+ public HashIDPreimageSorobanAuthorization() {}
+
+ private Hash networkID;
+
+ public Hash getNetworkID() {
+ return this.networkID;
+ }
+
+ public void setNetworkID(Hash value) {
+ this.networkID = value;
+ }
+
+ private Int64 nonce;
+
+ public Int64 getNonce() {
+ return this.nonce;
+ }
+
+ public void setNonce(Int64 value) {
+ this.nonce = value;
+ }
+
+ private Uint32 signatureExpirationLedger;
+
+ public Uint32 getSignatureExpirationLedger() {
+ return this.signatureExpirationLedger;
+ }
+
+ public void setSignatureExpirationLedger(Uint32 value) {
+ this.signatureExpirationLedger = value;
+ }
+
+ private SorobanAuthorizedInvocation invocation;
+
+ public SorobanAuthorizedInvocation getInvocation() {
+ return this.invocation;
+ }
+
+ public void setInvocation(SorobanAuthorizedInvocation value) {
+ this.invocation = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream,
+ HashIDPreimageSorobanAuthorization encodedHashIDPreimageSorobanAuthorization)
+ throws IOException {
+ Hash.encode(stream, encodedHashIDPreimageSorobanAuthorization.networkID);
+ Int64.encode(stream, encodedHashIDPreimageSorobanAuthorization.nonce);
+ Uint32.encode(stream, encodedHashIDPreimageSorobanAuthorization.signatureExpirationLedger);
+ SorobanAuthorizedInvocation.encode(
+ stream, encodedHashIDPreimageSorobanAuthorization.invocation);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static HashIDPreimageSorobanAuthorization decode(XdrDataInputStream stream)
+ throws IOException {
+ HashIDPreimageSorobanAuthorization decodedHashIDPreimageSorobanAuthorization =
+ new HashIDPreimageSorobanAuthorization();
+ decodedHashIDPreimageSorobanAuthorization.networkID = Hash.decode(stream);
+ decodedHashIDPreimageSorobanAuthorization.nonce = Int64.decode(stream);
+ decodedHashIDPreimageSorobanAuthorization.signatureExpirationLedger = Uint32.decode(stream);
+ decodedHashIDPreimageSorobanAuthorization.invocation =
+ SorobanAuthorizedInvocation.decode(stream);
+ return decodedHashIDPreimageSorobanAuthorization;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.networkID, this.nonce, this.signatureExpirationLedger, this.invocation);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof HashIDPreimageSorobanAuthorization)) {
+ return false;
+ }
+
+ HashIDPreimageSorobanAuthorization other = (HashIDPreimageSorobanAuthorization) object;
+ return Objects.equals(this.networkID, other.networkID)
+ && Objects.equals(this.nonce, other.nonce)
+ && Objects.equals(this.signatureExpirationLedger, other.signatureExpirationLedger)
+ && Objects.equals(this.invocation, other.invocation);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static HashIDPreimageSorobanAuthorization fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static HashIDPreimageSorobanAuthorization fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Hash networkID;
+ private Int64 nonce;
+ private Uint32 signatureExpirationLedger;
+ private SorobanAuthorizedInvocation invocation;
+
+ public Builder networkID(Hash networkID) {
+ this.networkID = networkID;
+ return this;
+ }
+
+ public Builder nonce(Int64 nonce) {
+ this.nonce = nonce;
+ return this;
+ }
+
+ public Builder signatureExpirationLedger(Uint32 signatureExpirationLedger) {
+ this.signatureExpirationLedger = signatureExpirationLedger;
+ return this;
+ }
+
+ public Builder invocation(SorobanAuthorizedInvocation invocation) {
+ this.invocation = invocation;
+ return this;
+ }
+
+ public HashIDPreimageSorobanAuthorization build() {
+ HashIDPreimageSorobanAuthorization val = new HashIDPreimageSorobanAuthorization();
+ val.setNetworkID(this.networkID);
+ val.setNonce(this.nonce);
+ val.setSignatureExpirationLedger(this.signatureExpirationLedger);
+ val.setInvocation(this.invocation);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Hello.java b/src/main/java/org/stellar/sdk/xdr/Hello.java
index 4f06c2295..e64d1faf8 100644
--- a/src/main/java/org/stellar/sdk/xdr/Hello.java
+++ b/src/main/java/org/stellar/sdk/xdr/Hello.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -147,7 +152,7 @@ public static Hello decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.ledgerVersion,
this.overlayVersion,
this.overlayMinVersion,
@@ -166,15 +171,39 @@ public boolean equals(Object object) {
}
Hello other = (Hello) object;
- return Objects.equal(this.ledgerVersion, other.ledgerVersion)
- && Objects.equal(this.overlayVersion, other.overlayVersion)
- && Objects.equal(this.overlayMinVersion, other.overlayMinVersion)
- && Objects.equal(this.networkID, other.networkID)
- && Objects.equal(this.versionStr, other.versionStr)
- && Objects.equal(this.listeningPort, other.listeningPort)
- && Objects.equal(this.peerID, other.peerID)
- && Objects.equal(this.cert, other.cert)
- && Objects.equal(this.nonce, other.nonce);
+ return Objects.equals(this.ledgerVersion, other.ledgerVersion)
+ && Objects.equals(this.overlayVersion, other.overlayVersion)
+ && Objects.equals(this.overlayMinVersion, other.overlayMinVersion)
+ && Objects.equals(this.networkID, other.networkID)
+ && Objects.equals(this.versionStr, other.versionStr)
+ && Objects.equals(this.listeningPort, other.listeningPort)
+ && Objects.equals(this.peerID, other.peerID)
+ && Objects.equals(this.cert, other.cert)
+ && Objects.equals(this.nonce, other.nonce);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Hello fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Hello fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -235,15 +264,15 @@ public Builder nonce(Uint256 nonce) {
public Hello build() {
Hello val = new Hello();
- val.setLedgerVersion(ledgerVersion);
- val.setOverlayVersion(overlayVersion);
- val.setOverlayMinVersion(overlayMinVersion);
- val.setNetworkID(networkID);
- val.setVersionStr(versionStr);
- val.setListeningPort(listeningPort);
- val.setPeerID(peerID);
- val.setCert(cert);
- val.setNonce(nonce);
+ val.setLedgerVersion(this.ledgerVersion);
+ val.setOverlayVersion(this.overlayVersion);
+ val.setOverlayMinVersion(this.overlayMinVersion);
+ val.setNetworkID(this.networkID);
+ val.setVersionStr(this.versionStr);
+ val.setListeningPort(this.listeningPort);
+ val.setPeerID(this.peerID);
+ val.setCert(this.cert);
+ val.setNonce(this.nonce);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/HmacSha256Key.java b/src/main/java/org/stellar/sdk/xdr/HmacSha256Key.java
index 3aaa1e648..6adce32ef 100644
--- a/src/main/java/org/stellar/sdk/xdr/HmacSha256Key.java
+++ b/src/main/java/org/stellar/sdk/xdr/HmacSha256Key.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -60,6 +65,30 @@ public boolean equals(Object object) {
return Arrays.equals(this.key, other.key);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static HmacSha256Key fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static HmacSha256Key fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private byte[] key;
@@ -70,7 +99,7 @@ public Builder key(byte[] key) {
public HmacSha256Key build() {
HmacSha256Key val = new HmacSha256Key();
- val.setKey(key);
+ val.setKey(this.key);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/HmacSha256Mac.java b/src/main/java/org/stellar/sdk/xdr/HmacSha256Mac.java
index 640084148..1a741c7b4 100644
--- a/src/main/java/org/stellar/sdk/xdr/HmacSha256Mac.java
+++ b/src/main/java/org/stellar/sdk/xdr/HmacSha256Mac.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -60,6 +65,30 @@ public boolean equals(Object object) {
return Arrays.equals(this.mac, other.mac);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static HmacSha256Mac fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static HmacSha256Mac fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private byte[] mac;
@@ -70,7 +99,7 @@ public Builder mac(byte[] mac) {
public HmacSha256Mac build() {
HmacSha256Mac val = new HmacSha256Mac();
- val.setMac(mac);
+ val.setMac(this.mac);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/HostFunction.java b/src/main/java/org/stellar/sdk/xdr/HostFunction.java
new file mode 100644
index 000000000..d0d2245e8
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/HostFunction.java
@@ -0,0 +1,193 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union HostFunction switch (HostFunctionType type)
+// {
+// case HOST_FUNCTION_TYPE_INVOKE_CONTRACT:
+// InvokeContractArgs invokeContract;
+// case HOST_FUNCTION_TYPE_CREATE_CONTRACT:
+// CreateContractArgs createContract;
+// case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM:
+// opaque wasm<>;
+// };
+
+// ===========================================================================
+public class HostFunction implements XdrElement {
+ public HostFunction() {}
+
+ HostFunctionType type;
+
+ public HostFunctionType getDiscriminant() {
+ return this.type;
+ }
+
+ public void setDiscriminant(HostFunctionType value) {
+ this.type = value;
+ }
+
+ private InvokeContractArgs invokeContract;
+
+ public InvokeContractArgs getInvokeContract() {
+ return this.invokeContract;
+ }
+
+ public void setInvokeContract(InvokeContractArgs value) {
+ this.invokeContract = value;
+ }
+
+ private CreateContractArgs createContract;
+
+ public CreateContractArgs getCreateContract() {
+ return this.createContract;
+ }
+
+ public void setCreateContract(CreateContractArgs value) {
+ this.createContract = value;
+ }
+
+ private byte[] wasm;
+
+ public byte[] getWasm() {
+ return this.wasm;
+ }
+
+ public void setWasm(byte[] value) {
+ this.wasm = value;
+ }
+
+ public static final class Builder {
+ private HostFunctionType discriminant;
+ private InvokeContractArgs invokeContract;
+ private CreateContractArgs createContract;
+ private byte[] wasm;
+
+ public Builder discriminant(HostFunctionType discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder invokeContract(InvokeContractArgs invokeContract) {
+ this.invokeContract = invokeContract;
+ return this;
+ }
+
+ public Builder createContract(CreateContractArgs createContract) {
+ this.createContract = createContract;
+ return this;
+ }
+
+ public Builder wasm(byte[] wasm) {
+ this.wasm = wasm;
+ return this;
+ }
+
+ public HostFunction build() {
+ HostFunction val = new HostFunction();
+ val.setDiscriminant(discriminant);
+ val.setInvokeContract(this.invokeContract);
+ val.setCreateContract(this.createContract);
+ val.setWasm(this.wasm);
+ return val;
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, HostFunction encodedHostFunction)
+ throws IOException {
+ // Xdrgen::AST::Identifier
+ // HostFunctionType
+ stream.writeInt(encodedHostFunction.getDiscriminant().getValue());
+ switch (encodedHostFunction.getDiscriminant()) {
+ case HOST_FUNCTION_TYPE_INVOKE_CONTRACT:
+ InvokeContractArgs.encode(stream, encodedHostFunction.invokeContract);
+ break;
+ case HOST_FUNCTION_TYPE_CREATE_CONTRACT:
+ CreateContractArgs.encode(stream, encodedHostFunction.createContract);
+ break;
+ case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM:
+ int wasmsize = encodedHostFunction.wasm.length;
+ stream.writeInt(wasmsize);
+ stream.write(encodedHostFunction.getWasm(), 0, wasmsize);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static HostFunction decode(XdrDataInputStream stream) throws IOException {
+ HostFunction decodedHostFunction = new HostFunction();
+ HostFunctionType discriminant = HostFunctionType.decode(stream);
+ decodedHostFunction.setDiscriminant(discriminant);
+ switch (decodedHostFunction.getDiscriminant()) {
+ case HOST_FUNCTION_TYPE_INVOKE_CONTRACT:
+ decodedHostFunction.invokeContract = InvokeContractArgs.decode(stream);
+ break;
+ case HOST_FUNCTION_TYPE_CREATE_CONTRACT:
+ decodedHostFunction.createContract = CreateContractArgs.decode(stream);
+ break;
+ case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM:
+ int wasmsize = stream.readInt();
+ decodedHostFunction.wasm = new byte[wasmsize];
+ stream.read(decodedHostFunction.wasm, 0, wasmsize);
+ break;
+ }
+ return decodedHostFunction;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.invokeContract, this.createContract, Arrays.hashCode(this.wasm), this.type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof HostFunction)) {
+ return false;
+ }
+
+ HostFunction other = (HostFunction) object;
+ return Objects.equals(this.invokeContract, other.invokeContract)
+ && Objects.equals(this.createContract, other.createContract)
+ && Arrays.equals(this.wasm, other.wasm)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static HostFunction fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static HostFunction fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/HostFunctionType.java b/src/main/java/org/stellar/sdk/xdr/HostFunctionType.java
new file mode 100644
index 000000000..18f84e1d4
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/HostFunctionType.java
@@ -0,0 +1,83 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum HostFunctionType
+// {
+// HOST_FUNCTION_TYPE_INVOKE_CONTRACT = 0,
+// HOST_FUNCTION_TYPE_CREATE_CONTRACT = 1,
+// HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2
+// };
+
+// ===========================================================================
+public enum HostFunctionType implements XdrElement {
+ HOST_FUNCTION_TYPE_INVOKE_CONTRACT(0),
+ HOST_FUNCTION_TYPE_CREATE_CONTRACT(1),
+ HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM(2),
+ ;
+ private int mValue;
+
+ HostFunctionType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static HostFunctionType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return HOST_FUNCTION_TYPE_INVOKE_CONTRACT;
+ case 1:
+ return HOST_FUNCTION_TYPE_CREATE_CONTRACT;
+ case 2:
+ return HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, HostFunctionType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static HostFunctionType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static HostFunctionType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/IPAddrType.java b/src/main/java/org/stellar/sdk/xdr/IPAddrType.java
index 730e13574..0d24dde81 100644
--- a/src/main/java/org/stellar/sdk/xdr/IPAddrType.java
+++ b/src/main/java/org/stellar/sdk/xdr/IPAddrType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -47,4 +52,28 @@ public static void encode(XdrDataOutputStream stream, IPAddrType value) throws I
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static IPAddrType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static IPAddrType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/InflationPayout.java b/src/main/java/org/stellar/sdk/xdr/InflationPayout.java
index 9323d73e5..37d782cfe 100644
--- a/src/main/java/org/stellar/sdk/xdr/InflationPayout.java
+++ b/src/main/java/org/stellar/sdk/xdr/InflationPayout.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -57,7 +62,7 @@ public static InflationPayout decode(XdrDataInputStream stream) throws IOExcepti
@Override
public int hashCode() {
- return Objects.hashCode(this.destination, this.amount);
+ return Objects.hash(this.destination, this.amount);
}
@Override
@@ -67,8 +72,32 @@ public boolean equals(Object object) {
}
InflationPayout other = (InflationPayout) object;
- return Objects.equal(this.destination, other.destination)
- && Objects.equal(this.amount, other.amount);
+ return Objects.equals(this.destination, other.destination)
+ && Objects.equals(this.amount, other.amount);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static InflationPayout fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static InflationPayout fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -87,8 +116,8 @@ public Builder amount(Int64 amount) {
public InflationPayout build() {
InflationPayout val = new InflationPayout();
- val.setDestination(destination);
- val.setAmount(amount);
+ val.setDestination(this.destination);
+ val.setAmount(this.amount);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/InflationResult.java b/src/main/java/org/stellar/sdk/xdr/InflationResult.java
index 55e250d66..394d2d0c1 100644
--- a/src/main/java/org/stellar/sdk/xdr/InflationResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/InflationResult.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -13,7 +18,7 @@
// {
// case INFLATION_SUCCESS:
// InflationPayout payouts<>;
-// default:
+// case INFLATION_NOT_TIME:
// void;
// };
@@ -58,7 +63,7 @@ public Builder payouts(InflationPayout[] payouts) {
public InflationResult build() {
InflationResult val = new InflationResult();
val.setDiscriminant(discriminant);
- val.setPayouts(payouts);
+ val.setPayouts(this.payouts);
return val;
}
}
@@ -76,7 +81,7 @@ public static void encode(XdrDataOutputStream stream, InflationResult encodedInf
InflationPayout.encode(stream, encodedInflationResult.payouts[i]);
}
break;
- default:
+ case INFLATION_NOT_TIME:
break;
}
}
@@ -97,7 +102,7 @@ public static InflationResult decode(XdrDataInputStream stream) throws IOExcepti
decodedInflationResult.payouts[i] = InflationPayout.decode(stream);
}
break;
- default:
+ case INFLATION_NOT_TIME:
break;
}
return decodedInflationResult;
@@ -105,7 +110,7 @@ public static InflationResult decode(XdrDataInputStream stream) throws IOExcepti
@Override
public int hashCode() {
- return Objects.hashCode(Arrays.hashCode(this.payouts), this.code);
+ return Objects.hash(Arrays.hashCode(this.payouts), this.code);
}
@Override
@@ -115,6 +120,30 @@ public boolean equals(Object object) {
}
InflationResult other = (InflationResult) object;
- return Arrays.equals(this.payouts, other.payouts) && Objects.equal(this.code, other.code);
+ return Arrays.equals(this.payouts, other.payouts) && Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static InflationResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static InflationResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/InflationResultCode.java b/src/main/java/org/stellar/sdk/xdr/InflationResultCode.java
index 3b14a7730..d483d06c7 100644
--- a/src/main/java/org/stellar/sdk/xdr/InflationResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/InflationResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -50,4 +55,28 @@ public static void encode(XdrDataOutputStream stream, InflationResultCode value)
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static InflationResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static InflationResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/InnerTransactionResult.java b/src/main/java/org/stellar/sdk/xdr/InnerTransactionResult.java
index 91d775b2e..b0b8af05d 100644
--- a/src/main/java/org/stellar/sdk/xdr/InnerTransactionResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/InnerTransactionResult.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -35,6 +40,7 @@
// case txBAD_SPONSORSHIP:
// case txBAD_MIN_SEQ_AGE_OR_GAP:
// case txMALFORMED:
+// case txSOROBAN_INVALID:
// void;
// }
// result;
@@ -104,7 +110,7 @@ public static InnerTransactionResult decode(XdrDataInputStream stream) throws IO
@Override
public int hashCode() {
- return Objects.hashCode(this.feeCharged, this.result, this.ext);
+ return Objects.hash(this.feeCharged, this.result, this.ext);
}
@Override
@@ -114,9 +120,33 @@ public boolean equals(Object object) {
}
InnerTransactionResult other = (InnerTransactionResult) object;
- return Objects.equal(this.feeCharged, other.feeCharged)
- && Objects.equal(this.result, other.result)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.feeCharged, other.feeCharged)
+ && Objects.equals(this.result, other.result)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static InnerTransactionResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static InnerTransactionResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -141,14 +171,14 @@ public Builder ext(InnerTransactionResultExt ext) {
public InnerTransactionResult build() {
InnerTransactionResult val = new InnerTransactionResult();
- val.setFeeCharged(feeCharged);
- val.setResult(result);
- val.setExt(ext);
+ val.setFeeCharged(this.feeCharged);
+ val.setResult(this.result);
+ val.setExt(this.ext);
return val;
}
}
- public static class InnerTransactionResultResult {
+ public static class InnerTransactionResultResult implements XdrElement {
public InnerTransactionResultResult() {}
TransactionResultCode code;
@@ -188,7 +218,7 @@ public Builder results(OperationResult[] results) {
public InnerTransactionResultResult build() {
InnerTransactionResultResult val = new InnerTransactionResultResult();
val.setDiscriminant(discriminant);
- val.setResults(results);
+ val.setResults(this.results);
return val;
}
}
@@ -223,6 +253,7 @@ public static void encode(
case txBAD_SPONSORSHIP:
case txBAD_MIN_SEQ_AGE_OR_GAP:
case txMALFORMED:
+ case txSOROBAN_INVALID:
break;
}
}
@@ -260,6 +291,7 @@ public static InnerTransactionResultResult decode(XdrDataInputStream stream)
case txBAD_SPONSORSHIP:
case txBAD_MIN_SEQ_AGE_OR_GAP:
case txMALFORMED:
+ case txSOROBAN_INVALID:
break;
}
return decodedInnerTransactionResultResult;
@@ -267,7 +299,7 @@ public static InnerTransactionResultResult decode(XdrDataInputStream stream)
@Override
public int hashCode() {
- return Objects.hashCode(Arrays.hashCode(this.results), this.code);
+ return Objects.hash(Arrays.hashCode(this.results), this.code);
}
@Override
@@ -277,11 +309,35 @@ public boolean equals(Object object) {
}
InnerTransactionResultResult other = (InnerTransactionResultResult) object;
- return Arrays.equals(this.results, other.results) && Objects.equal(this.code, other.code);
+ return Arrays.equals(this.results, other.results) && Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static InnerTransactionResultResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static InnerTransactionResultResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
- public static class InnerTransactionResultExt {
+ public static class InnerTransactionResultExt implements XdrElement {
public InnerTransactionResultExt() {}
Integer v;
@@ -338,7 +394,7 @@ public static InnerTransactionResultExt decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -348,7 +404,31 @@ public boolean equals(Object object) {
}
InnerTransactionResultExt other = (InnerTransactionResultExt) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static InnerTransactionResultExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static InnerTransactionResultExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/InnerTransactionResultPair.java b/src/main/java/org/stellar/sdk/xdr/InnerTransactionResultPair.java
index fd9943af8..3a141b39b 100644
--- a/src/main/java/org/stellar/sdk/xdr/InnerTransactionResultPair.java
+++ b/src/main/java/org/stellar/sdk/xdr/InnerTransactionResultPair.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -58,7 +63,7 @@ public static InnerTransactionResultPair decode(XdrDataInputStream stream) throw
@Override
public int hashCode() {
- return Objects.hashCode(this.transactionHash, this.result);
+ return Objects.hash(this.transactionHash, this.result);
}
@Override
@@ -68,8 +73,32 @@ public boolean equals(Object object) {
}
InnerTransactionResultPair other = (InnerTransactionResultPair) object;
- return Objects.equal(this.transactionHash, other.transactionHash)
- && Objects.equal(this.result, other.result);
+ return Objects.equals(this.transactionHash, other.transactionHash)
+ && Objects.equals(this.result, other.result);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static InnerTransactionResultPair fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static InnerTransactionResultPair fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -88,8 +117,8 @@ public Builder result(InnerTransactionResult result) {
public InnerTransactionResultPair build() {
InnerTransactionResultPair val = new InnerTransactionResultPair();
- val.setTransactionHash(transactionHash);
- val.setResult(result);
+ val.setTransactionHash(this.transactionHash);
+ val.setResult(this.result);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Int128Parts.java b/src/main/java/org/stellar/sdk/xdr/Int128Parts.java
new file mode 100644
index 000000000..1c09044cc
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Int128Parts.java
@@ -0,0 +1,122 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct Int128Parts {
+// int64 hi;
+// uint64 lo;
+// };
+
+// ===========================================================================
+public class Int128Parts implements XdrElement {
+ public Int128Parts() {}
+
+ private Int64 hi;
+
+ public Int64 getHi() {
+ return this.hi;
+ }
+
+ public void setHi(Int64 value) {
+ this.hi = value;
+ }
+
+ private Uint64 lo;
+
+ public Uint64 getLo() {
+ return this.lo;
+ }
+
+ public void setLo(Uint64 value) {
+ this.lo = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, Int128Parts encodedInt128Parts)
+ throws IOException {
+ Int64.encode(stream, encodedInt128Parts.hi);
+ Uint64.encode(stream, encodedInt128Parts.lo);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static Int128Parts decode(XdrDataInputStream stream) throws IOException {
+ Int128Parts decodedInt128Parts = new Int128Parts();
+ decodedInt128Parts.hi = Int64.decode(stream);
+ decodedInt128Parts.lo = Uint64.decode(stream);
+ return decodedInt128Parts;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.hi, this.lo);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof Int128Parts)) {
+ return false;
+ }
+
+ Int128Parts other = (Int128Parts) object;
+ return Objects.equals(this.hi, other.hi) && Objects.equals(this.lo, other.lo);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Int128Parts fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Int128Parts fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Int64 hi;
+ private Uint64 lo;
+
+ public Builder hi(Int64 hi) {
+ this.hi = hi;
+ return this;
+ }
+
+ public Builder lo(Uint64 lo) {
+ this.lo = lo;
+ return this;
+ }
+
+ public Int128Parts build() {
+ Int128Parts val = new Int128Parts();
+ val.setHi(this.hi);
+ val.setLo(this.lo);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Int256Parts.java b/src/main/java/org/stellar/sdk/xdr/Int256Parts.java
new file mode 100644
index 000000000..977f64e9a
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Int256Parts.java
@@ -0,0 +1,165 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct Int256Parts {
+// int64 hi_hi;
+// uint64 hi_lo;
+// uint64 lo_hi;
+// uint64 lo_lo;
+// };
+
+// ===========================================================================
+public class Int256Parts implements XdrElement {
+ public Int256Parts() {}
+
+ private Int64 hi_hi;
+
+ public Int64 getHi_hi() {
+ return this.hi_hi;
+ }
+
+ public void setHi_hi(Int64 value) {
+ this.hi_hi = value;
+ }
+
+ private Uint64 hi_lo;
+
+ public Uint64 getHi_lo() {
+ return this.hi_lo;
+ }
+
+ public void setHi_lo(Uint64 value) {
+ this.hi_lo = value;
+ }
+
+ private Uint64 lo_hi;
+
+ public Uint64 getLo_hi() {
+ return this.lo_hi;
+ }
+
+ public void setLo_hi(Uint64 value) {
+ this.lo_hi = value;
+ }
+
+ private Uint64 lo_lo;
+
+ public Uint64 getLo_lo() {
+ return this.lo_lo;
+ }
+
+ public void setLo_lo(Uint64 value) {
+ this.lo_lo = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, Int256Parts encodedInt256Parts)
+ throws IOException {
+ Int64.encode(stream, encodedInt256Parts.hi_hi);
+ Uint64.encode(stream, encodedInt256Parts.hi_lo);
+ Uint64.encode(stream, encodedInt256Parts.lo_hi);
+ Uint64.encode(stream, encodedInt256Parts.lo_lo);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static Int256Parts decode(XdrDataInputStream stream) throws IOException {
+ Int256Parts decodedInt256Parts = new Int256Parts();
+ decodedInt256Parts.hi_hi = Int64.decode(stream);
+ decodedInt256Parts.hi_lo = Uint64.decode(stream);
+ decodedInt256Parts.lo_hi = Uint64.decode(stream);
+ decodedInt256Parts.lo_lo = Uint64.decode(stream);
+ return decodedInt256Parts;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.hi_hi, this.hi_lo, this.lo_hi, this.lo_lo);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof Int256Parts)) {
+ return false;
+ }
+
+ Int256Parts other = (Int256Parts) object;
+ return Objects.equals(this.hi_hi, other.hi_hi)
+ && Objects.equals(this.hi_lo, other.hi_lo)
+ && Objects.equals(this.lo_hi, other.lo_hi)
+ && Objects.equals(this.lo_lo, other.lo_lo);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Int256Parts fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Int256Parts fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Int64 hi_hi;
+ private Uint64 hi_lo;
+ private Uint64 lo_hi;
+ private Uint64 lo_lo;
+
+ public Builder hi_hi(Int64 hi_hi) {
+ this.hi_hi = hi_hi;
+ return this;
+ }
+
+ public Builder hi_lo(Uint64 hi_lo) {
+ this.hi_lo = hi_lo;
+ return this;
+ }
+
+ public Builder lo_hi(Uint64 lo_hi) {
+ this.lo_hi = lo_hi;
+ return this;
+ }
+
+ public Builder lo_lo(Uint64 lo_lo) {
+ this.lo_lo = lo_lo;
+ return this;
+ }
+
+ public Int256Parts build() {
+ Int256Parts val = new Int256Parts();
+ val.setHi_hi(this.hi_hi);
+ val.setHi_lo(this.hi_lo);
+ val.setLo_hi(this.lo_hi);
+ val.setLo_lo(this.lo_lo);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Int32.java b/src/main/java/org/stellar/sdk/xdr/Int32.java
index 8ed969006..ca0d4b012 100644
--- a/src/main/java/org/stellar/sdk/xdr/Int32.java
+++ b/src/main/java/org/stellar/sdk/xdr/Int32.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -44,7 +49,7 @@ public static Int32 decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.int32);
+ return Objects.hash(this.int32);
}
@Override
@@ -54,6 +59,30 @@ public boolean equals(Object object) {
}
Int32 other = (Int32) object;
- return Objects.equal(this.int32, other.int32);
+ return Objects.equals(this.int32, other.int32);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Int32 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Int32 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Int64.java b/src/main/java/org/stellar/sdk/xdr/Int64.java
index 56ab7604b..d29362e3d 100644
--- a/src/main/java/org/stellar/sdk/xdr/Int64.java
+++ b/src/main/java/org/stellar/sdk/xdr/Int64.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -44,7 +49,7 @@ public static Int64 decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.int64);
+ return Objects.hash(this.int64);
}
@Override
@@ -54,6 +59,30 @@ public boolean equals(Object object) {
}
Int64 other = (Int64) object;
- return Objects.equal(this.int64, other.int64);
+ return Objects.equals(this.int64, other.int64);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Int64 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Int64 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/InvokeContractArgs.java b/src/main/java/org/stellar/sdk/xdr/InvokeContractArgs.java
new file mode 100644
index 000000000..b37ad8c51
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/InvokeContractArgs.java
@@ -0,0 +1,153 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct InvokeContractArgs {
+// SCAddress contractAddress;
+// SCSymbol functionName;
+// SCVal args<>;
+// };
+
+// ===========================================================================
+public class InvokeContractArgs implements XdrElement {
+ public InvokeContractArgs() {}
+
+ private SCAddress contractAddress;
+
+ public SCAddress getContractAddress() {
+ return this.contractAddress;
+ }
+
+ public void setContractAddress(SCAddress value) {
+ this.contractAddress = value;
+ }
+
+ private SCSymbol functionName;
+
+ public SCSymbol getFunctionName() {
+ return this.functionName;
+ }
+
+ public void setFunctionName(SCSymbol value) {
+ this.functionName = value;
+ }
+
+ private SCVal[] args;
+
+ public SCVal[] getArgs() {
+ return this.args;
+ }
+
+ public void setArgs(SCVal[] value) {
+ this.args = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, InvokeContractArgs encodedInvokeContractArgs) throws IOException {
+ SCAddress.encode(stream, encodedInvokeContractArgs.contractAddress);
+ SCSymbol.encode(stream, encodedInvokeContractArgs.functionName);
+ int argssize = encodedInvokeContractArgs.getArgs().length;
+ stream.writeInt(argssize);
+ for (int i = 0; i < argssize; i++) {
+ SCVal.encode(stream, encodedInvokeContractArgs.args[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static InvokeContractArgs decode(XdrDataInputStream stream) throws IOException {
+ InvokeContractArgs decodedInvokeContractArgs = new InvokeContractArgs();
+ decodedInvokeContractArgs.contractAddress = SCAddress.decode(stream);
+ decodedInvokeContractArgs.functionName = SCSymbol.decode(stream);
+ int argssize = stream.readInt();
+ decodedInvokeContractArgs.args = new SCVal[argssize];
+ for (int i = 0; i < argssize; i++) {
+ decodedInvokeContractArgs.args[i] = SCVal.decode(stream);
+ }
+ return decodedInvokeContractArgs;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.contractAddress, this.functionName, Arrays.hashCode(this.args));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof InvokeContractArgs)) {
+ return false;
+ }
+
+ InvokeContractArgs other = (InvokeContractArgs) object;
+ return Objects.equals(this.contractAddress, other.contractAddress)
+ && Objects.equals(this.functionName, other.functionName)
+ && Arrays.equals(this.args, other.args);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static InvokeContractArgs fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static InvokeContractArgs fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCAddress contractAddress;
+ private SCSymbol functionName;
+ private SCVal[] args;
+
+ public Builder contractAddress(SCAddress contractAddress) {
+ this.contractAddress = contractAddress;
+ return this;
+ }
+
+ public Builder functionName(SCSymbol functionName) {
+ this.functionName = functionName;
+ return this;
+ }
+
+ public Builder args(SCVal[] args) {
+ this.args = args;
+ return this;
+ }
+
+ public InvokeContractArgs build() {
+ InvokeContractArgs val = new InvokeContractArgs();
+ val.setContractAddress(this.contractAddress);
+ val.setFunctionName(this.functionName);
+ val.setArgs(this.args);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/InvokeHostFunctionOp.java b/src/main/java/org/stellar/sdk/xdr/InvokeHostFunctionOp.java
new file mode 100644
index 000000000..6a1348f09
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/InvokeHostFunctionOp.java
@@ -0,0 +1,136 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct InvokeHostFunctionOp
+// {
+// // Host function to invoke.
+// HostFunction hostFunction;
+// // Per-address authorizations for this host function.
+// SorobanAuthorizationEntry auth<>;
+// };
+
+// ===========================================================================
+public class InvokeHostFunctionOp implements XdrElement {
+ public InvokeHostFunctionOp() {}
+
+ private HostFunction hostFunction;
+
+ public HostFunction getHostFunction() {
+ return this.hostFunction;
+ }
+
+ public void setHostFunction(HostFunction value) {
+ this.hostFunction = value;
+ }
+
+ private SorobanAuthorizationEntry[] auth;
+
+ public SorobanAuthorizationEntry[] getAuth() {
+ return this.auth;
+ }
+
+ public void setAuth(SorobanAuthorizationEntry[] value) {
+ this.auth = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, InvokeHostFunctionOp encodedInvokeHostFunctionOp)
+ throws IOException {
+ HostFunction.encode(stream, encodedInvokeHostFunctionOp.hostFunction);
+ int authsize = encodedInvokeHostFunctionOp.getAuth().length;
+ stream.writeInt(authsize);
+ for (int i = 0; i < authsize; i++) {
+ SorobanAuthorizationEntry.encode(stream, encodedInvokeHostFunctionOp.auth[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static InvokeHostFunctionOp decode(XdrDataInputStream stream) throws IOException {
+ InvokeHostFunctionOp decodedInvokeHostFunctionOp = new InvokeHostFunctionOp();
+ decodedInvokeHostFunctionOp.hostFunction = HostFunction.decode(stream);
+ int authsize = stream.readInt();
+ decodedInvokeHostFunctionOp.auth = new SorobanAuthorizationEntry[authsize];
+ for (int i = 0; i < authsize; i++) {
+ decodedInvokeHostFunctionOp.auth[i] = SorobanAuthorizationEntry.decode(stream);
+ }
+ return decodedInvokeHostFunctionOp;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.hostFunction, Arrays.hashCode(this.auth));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof InvokeHostFunctionOp)) {
+ return false;
+ }
+
+ InvokeHostFunctionOp other = (InvokeHostFunctionOp) object;
+ return Objects.equals(this.hostFunction, other.hostFunction)
+ && Arrays.equals(this.auth, other.auth);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static InvokeHostFunctionOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static InvokeHostFunctionOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private HostFunction hostFunction;
+ private SorobanAuthorizationEntry[] auth;
+
+ public Builder hostFunction(HostFunction hostFunction) {
+ this.hostFunction = hostFunction;
+ return this;
+ }
+
+ public Builder auth(SorobanAuthorizationEntry[] auth) {
+ this.auth = auth;
+ return this;
+ }
+
+ public InvokeHostFunctionOp build() {
+ InvokeHostFunctionOp val = new InvokeHostFunctionOp();
+ val.setHostFunction(this.hostFunction);
+ val.setAuth(this.auth);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/InvokeHostFunctionResult.java b/src/main/java/org/stellar/sdk/xdr/InvokeHostFunctionResult.java
new file mode 100644
index 000000000..f8c7850da
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/InvokeHostFunctionResult.java
@@ -0,0 +1,153 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union InvokeHostFunctionResult switch (InvokeHostFunctionResultCode code)
+// {
+// case INVOKE_HOST_FUNCTION_SUCCESS:
+// Hash success; // sha256(InvokeHostFunctionSuccessPreImage)
+// case INVOKE_HOST_FUNCTION_MALFORMED:
+// case INVOKE_HOST_FUNCTION_TRAPPED:
+// case INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED:
+// case INVOKE_HOST_FUNCTION_ENTRY_EXPIRED:
+// case INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE:
+// void;
+// };
+
+// ===========================================================================
+public class InvokeHostFunctionResult implements XdrElement {
+ public InvokeHostFunctionResult() {}
+
+ InvokeHostFunctionResultCode code;
+
+ public InvokeHostFunctionResultCode getDiscriminant() {
+ return this.code;
+ }
+
+ public void setDiscriminant(InvokeHostFunctionResultCode value) {
+ this.code = value;
+ }
+
+ private Hash success;
+
+ public Hash getSuccess() {
+ return this.success;
+ }
+
+ public void setSuccess(Hash value) {
+ this.success = value;
+ }
+
+ public static final class Builder {
+ private InvokeHostFunctionResultCode discriminant;
+ private Hash success;
+
+ public Builder discriminant(InvokeHostFunctionResultCode discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder success(Hash success) {
+ this.success = success;
+ return this;
+ }
+
+ public InvokeHostFunctionResult build() {
+ InvokeHostFunctionResult val = new InvokeHostFunctionResult();
+ val.setDiscriminant(discriminant);
+ val.setSuccess(this.success);
+ return val;
+ }
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, InvokeHostFunctionResult encodedInvokeHostFunctionResult)
+ throws IOException {
+ // Xdrgen::AST::Identifier
+ // InvokeHostFunctionResultCode
+ stream.writeInt(encodedInvokeHostFunctionResult.getDiscriminant().getValue());
+ switch (encodedInvokeHostFunctionResult.getDiscriminant()) {
+ case INVOKE_HOST_FUNCTION_SUCCESS:
+ Hash.encode(stream, encodedInvokeHostFunctionResult.success);
+ break;
+ case INVOKE_HOST_FUNCTION_MALFORMED:
+ case INVOKE_HOST_FUNCTION_TRAPPED:
+ case INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED:
+ case INVOKE_HOST_FUNCTION_ENTRY_EXPIRED:
+ case INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE:
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static InvokeHostFunctionResult decode(XdrDataInputStream stream) throws IOException {
+ InvokeHostFunctionResult decodedInvokeHostFunctionResult = new InvokeHostFunctionResult();
+ InvokeHostFunctionResultCode discriminant = InvokeHostFunctionResultCode.decode(stream);
+ decodedInvokeHostFunctionResult.setDiscriminant(discriminant);
+ switch (decodedInvokeHostFunctionResult.getDiscriminant()) {
+ case INVOKE_HOST_FUNCTION_SUCCESS:
+ decodedInvokeHostFunctionResult.success = Hash.decode(stream);
+ break;
+ case INVOKE_HOST_FUNCTION_MALFORMED:
+ case INVOKE_HOST_FUNCTION_TRAPPED:
+ case INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED:
+ case INVOKE_HOST_FUNCTION_ENTRY_EXPIRED:
+ case INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE:
+ break;
+ }
+ return decodedInvokeHostFunctionResult;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.success, this.code);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof InvokeHostFunctionResult)) {
+ return false;
+ }
+
+ InvokeHostFunctionResult other = (InvokeHostFunctionResult) object;
+ return Objects.equals(this.success, other.success) && Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static InvokeHostFunctionResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static InvokeHostFunctionResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/InvokeHostFunctionResultCode.java b/src/main/java/org/stellar/sdk/xdr/InvokeHostFunctionResultCode.java
new file mode 100644
index 000000000..9bd43f4ba
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/InvokeHostFunctionResultCode.java
@@ -0,0 +1,99 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum InvokeHostFunctionResultCode
+// {
+// // codes considered as "success" for the operation
+// INVOKE_HOST_FUNCTION_SUCCESS = 0,
+//
+// // codes considered as "failure" for the operation
+// INVOKE_HOST_FUNCTION_MALFORMED = -1,
+// INVOKE_HOST_FUNCTION_TRAPPED = -2,
+// INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED = -3,
+// INVOKE_HOST_FUNCTION_ENTRY_EXPIRED = -4,
+// INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE = -5
+// };
+
+// ===========================================================================
+public enum InvokeHostFunctionResultCode implements XdrElement {
+ INVOKE_HOST_FUNCTION_SUCCESS(0),
+ INVOKE_HOST_FUNCTION_MALFORMED(-1),
+ INVOKE_HOST_FUNCTION_TRAPPED(-2),
+ INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED(-3),
+ INVOKE_HOST_FUNCTION_ENTRY_EXPIRED(-4),
+ INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE(-5),
+ ;
+ private int mValue;
+
+ InvokeHostFunctionResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static InvokeHostFunctionResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return INVOKE_HOST_FUNCTION_SUCCESS;
+ case -1:
+ return INVOKE_HOST_FUNCTION_MALFORMED;
+ case -2:
+ return INVOKE_HOST_FUNCTION_TRAPPED;
+ case -3:
+ return INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED;
+ case -4:
+ return INVOKE_HOST_FUNCTION_ENTRY_EXPIRED;
+ case -5:
+ return INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, InvokeHostFunctionResultCode value)
+ throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static InvokeHostFunctionResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static InvokeHostFunctionResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/InvokeHostFunctionSuccessPreImage.java b/src/main/java/org/stellar/sdk/xdr/InvokeHostFunctionSuccessPreImage.java
new file mode 100644
index 000000000..21a5656e3
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/InvokeHostFunctionSuccessPreImage.java
@@ -0,0 +1,137 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct InvokeHostFunctionSuccessPreImage
+// {
+// SCVal returnValue;
+// ContractEvent events<>;
+// };
+
+// ===========================================================================
+public class InvokeHostFunctionSuccessPreImage implements XdrElement {
+ public InvokeHostFunctionSuccessPreImage() {}
+
+ private SCVal returnValue;
+
+ public SCVal getReturnValue() {
+ return this.returnValue;
+ }
+
+ public void setReturnValue(SCVal value) {
+ this.returnValue = value;
+ }
+
+ private ContractEvent[] events;
+
+ public ContractEvent[] getEvents() {
+ return this.events;
+ }
+
+ public void setEvents(ContractEvent[] value) {
+ this.events = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream,
+ InvokeHostFunctionSuccessPreImage encodedInvokeHostFunctionSuccessPreImage)
+ throws IOException {
+ SCVal.encode(stream, encodedInvokeHostFunctionSuccessPreImage.returnValue);
+ int eventssize = encodedInvokeHostFunctionSuccessPreImage.getEvents().length;
+ stream.writeInt(eventssize);
+ for (int i = 0; i < eventssize; i++) {
+ ContractEvent.encode(stream, encodedInvokeHostFunctionSuccessPreImage.events[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static InvokeHostFunctionSuccessPreImage decode(XdrDataInputStream stream)
+ throws IOException {
+ InvokeHostFunctionSuccessPreImage decodedInvokeHostFunctionSuccessPreImage =
+ new InvokeHostFunctionSuccessPreImage();
+ decodedInvokeHostFunctionSuccessPreImage.returnValue = SCVal.decode(stream);
+ int eventssize = stream.readInt();
+ decodedInvokeHostFunctionSuccessPreImage.events = new ContractEvent[eventssize];
+ for (int i = 0; i < eventssize; i++) {
+ decodedInvokeHostFunctionSuccessPreImage.events[i] = ContractEvent.decode(stream);
+ }
+ return decodedInvokeHostFunctionSuccessPreImage;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.returnValue, Arrays.hashCode(this.events));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof InvokeHostFunctionSuccessPreImage)) {
+ return false;
+ }
+
+ InvokeHostFunctionSuccessPreImage other = (InvokeHostFunctionSuccessPreImage) object;
+ return Objects.equals(this.returnValue, other.returnValue)
+ && Arrays.equals(this.events, other.events);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static InvokeHostFunctionSuccessPreImage fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static InvokeHostFunctionSuccessPreImage fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCVal returnValue;
+ private ContractEvent[] events;
+
+ public Builder returnValue(SCVal returnValue) {
+ this.returnValue = returnValue;
+ return this;
+ }
+
+ public Builder events(ContractEvent[] events) {
+ this.events = events;
+ return this;
+ }
+
+ public InvokeHostFunctionSuccessPreImage build() {
+ InvokeHostFunctionSuccessPreImage val = new InvokeHostFunctionSuccessPreImage();
+ val.setReturnValue(this.returnValue);
+ val.setEvents(this.events);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerBounds.java b/src/main/java/org/stellar/sdk/xdr/LedgerBounds.java
index d3f6db404..179a7598d 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerBounds.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerBounds.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -57,7 +62,7 @@ public static LedgerBounds decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(this.minLedger, this.maxLedger);
+ return Objects.hash(this.minLedger, this.maxLedger);
}
@Override
@@ -67,8 +72,32 @@ public boolean equals(Object object) {
}
LedgerBounds other = (LedgerBounds) object;
- return Objects.equal(this.minLedger, other.minLedger)
- && Objects.equal(this.maxLedger, other.maxLedger);
+ return Objects.equals(this.minLedger, other.minLedger)
+ && Objects.equals(this.maxLedger, other.maxLedger);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerBounds fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerBounds fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -87,8 +116,8 @@ public Builder maxLedger(Uint32 maxLedger) {
public LedgerBounds build() {
LedgerBounds val = new LedgerBounds();
- val.setMinLedger(minLedger);
- val.setMaxLedger(maxLedger);
+ val.setMinLedger(this.minLedger);
+ val.setMaxLedger(this.maxLedger);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerCloseMeta.java b/src/main/java/org/stellar/sdk/xdr/LedgerCloseMeta.java
index 9b91f5c03..c39ab4434 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerCloseMeta.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerCloseMeta.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,6 +17,10 @@
// {
// case 0:
// LedgerCloseMetaV0 v0;
+// case 1:
+// LedgerCloseMetaV1 v1;
+// case 2:
+// LedgerCloseMetaV2 v2;
// };
// ===========================================================================
@@ -38,9 +47,31 @@ public void setV0(LedgerCloseMetaV0 value) {
this.v0 = value;
}
+ private LedgerCloseMetaV1 v1;
+
+ public LedgerCloseMetaV1 getV1() {
+ return this.v1;
+ }
+
+ public void setV1(LedgerCloseMetaV1 value) {
+ this.v1 = value;
+ }
+
+ private LedgerCloseMetaV2 v2;
+
+ public LedgerCloseMetaV2 getV2() {
+ return this.v2;
+ }
+
+ public void setV2(LedgerCloseMetaV2 value) {
+ this.v2 = value;
+ }
+
public static final class Builder {
private Integer discriminant;
private LedgerCloseMetaV0 v0;
+ private LedgerCloseMetaV1 v1;
+ private LedgerCloseMetaV2 v2;
public Builder discriminant(Integer discriminant) {
this.discriminant = discriminant;
@@ -52,10 +83,22 @@ public Builder v0(LedgerCloseMetaV0 v0) {
return this;
}
+ public Builder v1(LedgerCloseMetaV1 v1) {
+ this.v1 = v1;
+ return this;
+ }
+
+ public Builder v2(LedgerCloseMetaV2 v2) {
+ this.v2 = v2;
+ return this;
+ }
+
public LedgerCloseMeta build() {
LedgerCloseMeta val = new LedgerCloseMeta();
val.setDiscriminant(discriminant);
- val.setV0(v0);
+ val.setV0(this.v0);
+ val.setV1(this.v1);
+ val.setV2(this.v2);
return val;
}
}
@@ -69,6 +112,12 @@ public static void encode(XdrDataOutputStream stream, LedgerCloseMeta encodedLed
case 0:
LedgerCloseMetaV0.encode(stream, encodedLedgerCloseMeta.v0);
break;
+ case 1:
+ LedgerCloseMetaV1.encode(stream, encodedLedgerCloseMeta.v1);
+ break;
+ case 2:
+ LedgerCloseMetaV2.encode(stream, encodedLedgerCloseMeta.v2);
+ break;
}
}
@@ -84,13 +133,19 @@ public static LedgerCloseMeta decode(XdrDataInputStream stream) throws IOExcepti
case 0:
decodedLedgerCloseMeta.v0 = LedgerCloseMetaV0.decode(stream);
break;
+ case 1:
+ decodedLedgerCloseMeta.v1 = LedgerCloseMetaV1.decode(stream);
+ break;
+ case 2:
+ decodedLedgerCloseMeta.v2 = LedgerCloseMetaV2.decode(stream);
+ break;
}
return decodedLedgerCloseMeta;
}
@Override
public int hashCode() {
- return Objects.hashCode(this.v0, this.v);
+ return Objects.hash(this.v0, this.v1, this.v2, this.v);
}
@Override
@@ -100,6 +155,33 @@ public boolean equals(Object object) {
}
LedgerCloseMeta other = (LedgerCloseMeta) object;
- return Objects.equal(this.v0, other.v0) && Objects.equal(this.v, other.v);
+ return Objects.equals(this.v0, other.v0)
+ && Objects.equals(this.v1, other.v1)
+ && Objects.equals(this.v2, other.v2)
+ && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerCloseMeta fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerCloseMeta fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerCloseMetaV0.java b/src/main/java/org/stellar/sdk/xdr/LedgerCloseMetaV0.java
index 8d8a4b01d..64281560b 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerCloseMetaV0.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerCloseMetaV0.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -130,7 +135,7 @@ public static LedgerCloseMetaV0 decode(XdrDataInputStream stream) throws IOExcep
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.ledgerHeader,
this.txSet,
Arrays.hashCode(this.txProcessing),
@@ -145,13 +150,37 @@ public boolean equals(Object object) {
}
LedgerCloseMetaV0 other = (LedgerCloseMetaV0) object;
- return Objects.equal(this.ledgerHeader, other.ledgerHeader)
- && Objects.equal(this.txSet, other.txSet)
+ return Objects.equals(this.ledgerHeader, other.ledgerHeader)
+ && Objects.equals(this.txSet, other.txSet)
&& Arrays.equals(this.txProcessing, other.txProcessing)
&& Arrays.equals(this.upgradesProcessing, other.upgradesProcessing)
&& Arrays.equals(this.scpInfo, other.scpInfo);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerCloseMetaV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerCloseMetaV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private LedgerHeaderHistoryEntry ledgerHeader;
private TransactionSet txSet;
@@ -186,11 +215,11 @@ public Builder scpInfo(SCPHistoryEntry[] scpInfo) {
public LedgerCloseMetaV0 build() {
LedgerCloseMetaV0 val = new LedgerCloseMetaV0();
- val.setLedgerHeader(ledgerHeader);
- val.setTxSet(txSet);
- val.setTxProcessing(txProcessing);
- val.setUpgradesProcessing(upgradesProcessing);
- val.setScpInfo(scpInfo);
+ val.setLedgerHeader(this.ledgerHeader);
+ val.setTxSet(this.txSet);
+ val.setTxProcessing(this.txProcessing);
+ val.setUpgradesProcessing(this.upgradesProcessing);
+ val.setScpInfo(this.scpInfo);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerCloseMetaV1.java b/src/main/java/org/stellar/sdk/xdr/LedgerCloseMetaV1.java
new file mode 100644
index 000000000..c21f78354
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerCloseMetaV1.java
@@ -0,0 +1,226 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct LedgerCloseMetaV1
+// {
+// LedgerHeaderHistoryEntry ledgerHeader;
+//
+// GeneralizedTransactionSet txSet;
+//
+// // NB: transactions are sorted in apply order here
+// // fees for all transactions are processed first
+// // followed by applying transactions
+// TransactionResultMeta txProcessing<>;
+//
+// // upgrades are applied last
+// UpgradeEntryMeta upgradesProcessing<>;
+//
+// // other misc information attached to the ledger close
+// SCPHistoryEntry scpInfo<>;
+// };
+
+// ===========================================================================
+public class LedgerCloseMetaV1 implements XdrElement {
+ public LedgerCloseMetaV1() {}
+
+ private LedgerHeaderHistoryEntry ledgerHeader;
+
+ public LedgerHeaderHistoryEntry getLedgerHeader() {
+ return this.ledgerHeader;
+ }
+
+ public void setLedgerHeader(LedgerHeaderHistoryEntry value) {
+ this.ledgerHeader = value;
+ }
+
+ private GeneralizedTransactionSet txSet;
+
+ public GeneralizedTransactionSet getTxSet() {
+ return this.txSet;
+ }
+
+ public void setTxSet(GeneralizedTransactionSet value) {
+ this.txSet = value;
+ }
+
+ private TransactionResultMeta[] txProcessing;
+
+ public TransactionResultMeta[] getTxProcessing() {
+ return this.txProcessing;
+ }
+
+ public void setTxProcessing(TransactionResultMeta[] value) {
+ this.txProcessing = value;
+ }
+
+ private UpgradeEntryMeta[] upgradesProcessing;
+
+ public UpgradeEntryMeta[] getUpgradesProcessing() {
+ return this.upgradesProcessing;
+ }
+
+ public void setUpgradesProcessing(UpgradeEntryMeta[] value) {
+ this.upgradesProcessing = value;
+ }
+
+ private SCPHistoryEntry[] scpInfo;
+
+ public SCPHistoryEntry[] getScpInfo() {
+ return this.scpInfo;
+ }
+
+ public void setScpInfo(SCPHistoryEntry[] value) {
+ this.scpInfo = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, LedgerCloseMetaV1 encodedLedgerCloseMetaV1)
+ throws IOException {
+ LedgerHeaderHistoryEntry.encode(stream, encodedLedgerCloseMetaV1.ledgerHeader);
+ GeneralizedTransactionSet.encode(stream, encodedLedgerCloseMetaV1.txSet);
+ int txProcessingsize = encodedLedgerCloseMetaV1.getTxProcessing().length;
+ stream.writeInt(txProcessingsize);
+ for (int i = 0; i < txProcessingsize; i++) {
+ TransactionResultMeta.encode(stream, encodedLedgerCloseMetaV1.txProcessing[i]);
+ }
+ int upgradesProcessingsize = encodedLedgerCloseMetaV1.getUpgradesProcessing().length;
+ stream.writeInt(upgradesProcessingsize);
+ for (int i = 0; i < upgradesProcessingsize; i++) {
+ UpgradeEntryMeta.encode(stream, encodedLedgerCloseMetaV1.upgradesProcessing[i]);
+ }
+ int scpInfosize = encodedLedgerCloseMetaV1.getScpInfo().length;
+ stream.writeInt(scpInfosize);
+ for (int i = 0; i < scpInfosize; i++) {
+ SCPHistoryEntry.encode(stream, encodedLedgerCloseMetaV1.scpInfo[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static LedgerCloseMetaV1 decode(XdrDataInputStream stream) throws IOException {
+ LedgerCloseMetaV1 decodedLedgerCloseMetaV1 = new LedgerCloseMetaV1();
+ decodedLedgerCloseMetaV1.ledgerHeader = LedgerHeaderHistoryEntry.decode(stream);
+ decodedLedgerCloseMetaV1.txSet = GeneralizedTransactionSet.decode(stream);
+ int txProcessingsize = stream.readInt();
+ decodedLedgerCloseMetaV1.txProcessing = new TransactionResultMeta[txProcessingsize];
+ for (int i = 0; i < txProcessingsize; i++) {
+ decodedLedgerCloseMetaV1.txProcessing[i] = TransactionResultMeta.decode(stream);
+ }
+ int upgradesProcessingsize = stream.readInt();
+ decodedLedgerCloseMetaV1.upgradesProcessing = new UpgradeEntryMeta[upgradesProcessingsize];
+ for (int i = 0; i < upgradesProcessingsize; i++) {
+ decodedLedgerCloseMetaV1.upgradesProcessing[i] = UpgradeEntryMeta.decode(stream);
+ }
+ int scpInfosize = stream.readInt();
+ decodedLedgerCloseMetaV1.scpInfo = new SCPHistoryEntry[scpInfosize];
+ for (int i = 0; i < scpInfosize; i++) {
+ decodedLedgerCloseMetaV1.scpInfo[i] = SCPHistoryEntry.decode(stream);
+ }
+ return decodedLedgerCloseMetaV1;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.ledgerHeader,
+ this.txSet,
+ Arrays.hashCode(this.txProcessing),
+ Arrays.hashCode(this.upgradesProcessing),
+ Arrays.hashCode(this.scpInfo));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof LedgerCloseMetaV1)) {
+ return false;
+ }
+
+ LedgerCloseMetaV1 other = (LedgerCloseMetaV1) object;
+ return Objects.equals(this.ledgerHeader, other.ledgerHeader)
+ && Objects.equals(this.txSet, other.txSet)
+ && Arrays.equals(this.txProcessing, other.txProcessing)
+ && Arrays.equals(this.upgradesProcessing, other.upgradesProcessing)
+ && Arrays.equals(this.scpInfo, other.scpInfo);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerCloseMetaV1 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerCloseMetaV1 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private LedgerHeaderHistoryEntry ledgerHeader;
+ private GeneralizedTransactionSet txSet;
+ private TransactionResultMeta[] txProcessing;
+ private UpgradeEntryMeta[] upgradesProcessing;
+ private SCPHistoryEntry[] scpInfo;
+
+ public Builder ledgerHeader(LedgerHeaderHistoryEntry ledgerHeader) {
+ this.ledgerHeader = ledgerHeader;
+ return this;
+ }
+
+ public Builder txSet(GeneralizedTransactionSet txSet) {
+ this.txSet = txSet;
+ return this;
+ }
+
+ public Builder txProcessing(TransactionResultMeta[] txProcessing) {
+ this.txProcessing = txProcessing;
+ return this;
+ }
+
+ public Builder upgradesProcessing(UpgradeEntryMeta[] upgradesProcessing) {
+ this.upgradesProcessing = upgradesProcessing;
+ return this;
+ }
+
+ public Builder scpInfo(SCPHistoryEntry[] scpInfo) {
+ this.scpInfo = scpInfo;
+ return this;
+ }
+
+ public LedgerCloseMetaV1 build() {
+ LedgerCloseMetaV1 val = new LedgerCloseMetaV1();
+ val.setLedgerHeader(this.ledgerHeader);
+ val.setTxSet(this.txSet);
+ val.setTxProcessing(this.txProcessing);
+ val.setUpgradesProcessing(this.upgradesProcessing);
+ val.setScpInfo(this.scpInfo);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerCloseMetaV2.java b/src/main/java/org/stellar/sdk/xdr/LedgerCloseMetaV2.java
new file mode 100644
index 000000000..053560cec
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerCloseMetaV2.java
@@ -0,0 +1,345 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct LedgerCloseMetaV2
+// {
+// // We forgot to add an ExtensionPoint in v1 but at least
+// // we can add one now in v2.
+// ExtensionPoint ext;
+//
+// LedgerHeaderHistoryEntry ledgerHeader;
+//
+// GeneralizedTransactionSet txSet;
+//
+// // NB: transactions are sorted in apply order here
+// // fees for all transactions are processed first
+// // followed by applying transactions
+// TransactionResultMeta txProcessing<>;
+//
+// // upgrades are applied last
+// UpgradeEntryMeta upgradesProcessing<>;
+//
+// // other misc information attached to the ledger close
+// SCPHistoryEntry scpInfo<>;
+//
+// // Size in bytes of BucketList, to support downstream
+// // systems calculating storage fees correctly.
+// uint64 totalByteSizeOfBucketList;
+//
+// // Expired temp keys that are being evicted at this ledger.
+// LedgerKey evictedTemporaryLedgerKeys<>;
+//
+// // Expired restorable ledger entries that are being
+// // evicted at this ledger.
+// LedgerEntry evictedPersistentLedgerEntries<>;
+// };
+
+// ===========================================================================
+public class LedgerCloseMetaV2 implements XdrElement {
+ public LedgerCloseMetaV2() {}
+
+ private ExtensionPoint ext;
+
+ public ExtensionPoint getExt() {
+ return this.ext;
+ }
+
+ public void setExt(ExtensionPoint value) {
+ this.ext = value;
+ }
+
+ private LedgerHeaderHistoryEntry ledgerHeader;
+
+ public LedgerHeaderHistoryEntry getLedgerHeader() {
+ return this.ledgerHeader;
+ }
+
+ public void setLedgerHeader(LedgerHeaderHistoryEntry value) {
+ this.ledgerHeader = value;
+ }
+
+ private GeneralizedTransactionSet txSet;
+
+ public GeneralizedTransactionSet getTxSet() {
+ return this.txSet;
+ }
+
+ public void setTxSet(GeneralizedTransactionSet value) {
+ this.txSet = value;
+ }
+
+ private TransactionResultMeta[] txProcessing;
+
+ public TransactionResultMeta[] getTxProcessing() {
+ return this.txProcessing;
+ }
+
+ public void setTxProcessing(TransactionResultMeta[] value) {
+ this.txProcessing = value;
+ }
+
+ private UpgradeEntryMeta[] upgradesProcessing;
+
+ public UpgradeEntryMeta[] getUpgradesProcessing() {
+ return this.upgradesProcessing;
+ }
+
+ public void setUpgradesProcessing(UpgradeEntryMeta[] value) {
+ this.upgradesProcessing = value;
+ }
+
+ private SCPHistoryEntry[] scpInfo;
+
+ public SCPHistoryEntry[] getScpInfo() {
+ return this.scpInfo;
+ }
+
+ public void setScpInfo(SCPHistoryEntry[] value) {
+ this.scpInfo = value;
+ }
+
+ private Uint64 totalByteSizeOfBucketList;
+
+ public Uint64 getTotalByteSizeOfBucketList() {
+ return this.totalByteSizeOfBucketList;
+ }
+
+ public void setTotalByteSizeOfBucketList(Uint64 value) {
+ this.totalByteSizeOfBucketList = value;
+ }
+
+ private LedgerKey[] evictedTemporaryLedgerKeys;
+
+ public LedgerKey[] getEvictedTemporaryLedgerKeys() {
+ return this.evictedTemporaryLedgerKeys;
+ }
+
+ public void setEvictedTemporaryLedgerKeys(LedgerKey[] value) {
+ this.evictedTemporaryLedgerKeys = value;
+ }
+
+ private LedgerEntry[] evictedPersistentLedgerEntries;
+
+ public LedgerEntry[] getEvictedPersistentLedgerEntries() {
+ return this.evictedPersistentLedgerEntries;
+ }
+
+ public void setEvictedPersistentLedgerEntries(LedgerEntry[] value) {
+ this.evictedPersistentLedgerEntries = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, LedgerCloseMetaV2 encodedLedgerCloseMetaV2)
+ throws IOException {
+ ExtensionPoint.encode(stream, encodedLedgerCloseMetaV2.ext);
+ LedgerHeaderHistoryEntry.encode(stream, encodedLedgerCloseMetaV2.ledgerHeader);
+ GeneralizedTransactionSet.encode(stream, encodedLedgerCloseMetaV2.txSet);
+ int txProcessingsize = encodedLedgerCloseMetaV2.getTxProcessing().length;
+ stream.writeInt(txProcessingsize);
+ for (int i = 0; i < txProcessingsize; i++) {
+ TransactionResultMeta.encode(stream, encodedLedgerCloseMetaV2.txProcessing[i]);
+ }
+ int upgradesProcessingsize = encodedLedgerCloseMetaV2.getUpgradesProcessing().length;
+ stream.writeInt(upgradesProcessingsize);
+ for (int i = 0; i < upgradesProcessingsize; i++) {
+ UpgradeEntryMeta.encode(stream, encodedLedgerCloseMetaV2.upgradesProcessing[i]);
+ }
+ int scpInfosize = encodedLedgerCloseMetaV2.getScpInfo().length;
+ stream.writeInt(scpInfosize);
+ for (int i = 0; i < scpInfosize; i++) {
+ SCPHistoryEntry.encode(stream, encodedLedgerCloseMetaV2.scpInfo[i]);
+ }
+ Uint64.encode(stream, encodedLedgerCloseMetaV2.totalByteSizeOfBucketList);
+ int evictedTemporaryLedgerKeyssize =
+ encodedLedgerCloseMetaV2.getEvictedTemporaryLedgerKeys().length;
+ stream.writeInt(evictedTemporaryLedgerKeyssize);
+ for (int i = 0; i < evictedTemporaryLedgerKeyssize; i++) {
+ LedgerKey.encode(stream, encodedLedgerCloseMetaV2.evictedTemporaryLedgerKeys[i]);
+ }
+ int evictedPersistentLedgerEntriessize =
+ encodedLedgerCloseMetaV2.getEvictedPersistentLedgerEntries().length;
+ stream.writeInt(evictedPersistentLedgerEntriessize);
+ for (int i = 0; i < evictedPersistentLedgerEntriessize; i++) {
+ LedgerEntry.encode(stream, encodedLedgerCloseMetaV2.evictedPersistentLedgerEntries[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static LedgerCloseMetaV2 decode(XdrDataInputStream stream) throws IOException {
+ LedgerCloseMetaV2 decodedLedgerCloseMetaV2 = new LedgerCloseMetaV2();
+ decodedLedgerCloseMetaV2.ext = ExtensionPoint.decode(stream);
+ decodedLedgerCloseMetaV2.ledgerHeader = LedgerHeaderHistoryEntry.decode(stream);
+ decodedLedgerCloseMetaV2.txSet = GeneralizedTransactionSet.decode(stream);
+ int txProcessingsize = stream.readInt();
+ decodedLedgerCloseMetaV2.txProcessing = new TransactionResultMeta[txProcessingsize];
+ for (int i = 0; i < txProcessingsize; i++) {
+ decodedLedgerCloseMetaV2.txProcessing[i] = TransactionResultMeta.decode(stream);
+ }
+ int upgradesProcessingsize = stream.readInt();
+ decodedLedgerCloseMetaV2.upgradesProcessing = new UpgradeEntryMeta[upgradesProcessingsize];
+ for (int i = 0; i < upgradesProcessingsize; i++) {
+ decodedLedgerCloseMetaV2.upgradesProcessing[i] = UpgradeEntryMeta.decode(stream);
+ }
+ int scpInfosize = stream.readInt();
+ decodedLedgerCloseMetaV2.scpInfo = new SCPHistoryEntry[scpInfosize];
+ for (int i = 0; i < scpInfosize; i++) {
+ decodedLedgerCloseMetaV2.scpInfo[i] = SCPHistoryEntry.decode(stream);
+ }
+ decodedLedgerCloseMetaV2.totalByteSizeOfBucketList = Uint64.decode(stream);
+ int evictedTemporaryLedgerKeyssize = stream.readInt();
+ decodedLedgerCloseMetaV2.evictedTemporaryLedgerKeys =
+ new LedgerKey[evictedTemporaryLedgerKeyssize];
+ for (int i = 0; i < evictedTemporaryLedgerKeyssize; i++) {
+ decodedLedgerCloseMetaV2.evictedTemporaryLedgerKeys[i] = LedgerKey.decode(stream);
+ }
+ int evictedPersistentLedgerEntriessize = stream.readInt();
+ decodedLedgerCloseMetaV2.evictedPersistentLedgerEntries =
+ new LedgerEntry[evictedPersistentLedgerEntriessize];
+ for (int i = 0; i < evictedPersistentLedgerEntriessize; i++) {
+ decodedLedgerCloseMetaV2.evictedPersistentLedgerEntries[i] = LedgerEntry.decode(stream);
+ }
+ return decodedLedgerCloseMetaV2;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.ext,
+ this.ledgerHeader,
+ this.txSet,
+ Arrays.hashCode(this.txProcessing),
+ Arrays.hashCode(this.upgradesProcessing),
+ Arrays.hashCode(this.scpInfo),
+ this.totalByteSizeOfBucketList,
+ Arrays.hashCode(this.evictedTemporaryLedgerKeys),
+ Arrays.hashCode(this.evictedPersistentLedgerEntries));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof LedgerCloseMetaV2)) {
+ return false;
+ }
+
+ LedgerCloseMetaV2 other = (LedgerCloseMetaV2) object;
+ return Objects.equals(this.ext, other.ext)
+ && Objects.equals(this.ledgerHeader, other.ledgerHeader)
+ && Objects.equals(this.txSet, other.txSet)
+ && Arrays.equals(this.txProcessing, other.txProcessing)
+ && Arrays.equals(this.upgradesProcessing, other.upgradesProcessing)
+ && Arrays.equals(this.scpInfo, other.scpInfo)
+ && Objects.equals(this.totalByteSizeOfBucketList, other.totalByteSizeOfBucketList)
+ && Arrays.equals(this.evictedTemporaryLedgerKeys, other.evictedTemporaryLedgerKeys)
+ && Arrays.equals(this.evictedPersistentLedgerEntries, other.evictedPersistentLedgerEntries);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerCloseMetaV2 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerCloseMetaV2 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ExtensionPoint ext;
+ private LedgerHeaderHistoryEntry ledgerHeader;
+ private GeneralizedTransactionSet txSet;
+ private TransactionResultMeta[] txProcessing;
+ private UpgradeEntryMeta[] upgradesProcessing;
+ private SCPHistoryEntry[] scpInfo;
+ private Uint64 totalByteSizeOfBucketList;
+ private LedgerKey[] evictedTemporaryLedgerKeys;
+ private LedgerEntry[] evictedPersistentLedgerEntries;
+
+ public Builder ext(ExtensionPoint ext) {
+ this.ext = ext;
+ return this;
+ }
+
+ public Builder ledgerHeader(LedgerHeaderHistoryEntry ledgerHeader) {
+ this.ledgerHeader = ledgerHeader;
+ return this;
+ }
+
+ public Builder txSet(GeneralizedTransactionSet txSet) {
+ this.txSet = txSet;
+ return this;
+ }
+
+ public Builder txProcessing(TransactionResultMeta[] txProcessing) {
+ this.txProcessing = txProcessing;
+ return this;
+ }
+
+ public Builder upgradesProcessing(UpgradeEntryMeta[] upgradesProcessing) {
+ this.upgradesProcessing = upgradesProcessing;
+ return this;
+ }
+
+ public Builder scpInfo(SCPHistoryEntry[] scpInfo) {
+ this.scpInfo = scpInfo;
+ return this;
+ }
+
+ public Builder totalByteSizeOfBucketList(Uint64 totalByteSizeOfBucketList) {
+ this.totalByteSizeOfBucketList = totalByteSizeOfBucketList;
+ return this;
+ }
+
+ public Builder evictedTemporaryLedgerKeys(LedgerKey[] evictedTemporaryLedgerKeys) {
+ this.evictedTemporaryLedgerKeys = evictedTemporaryLedgerKeys;
+ return this;
+ }
+
+ public Builder evictedPersistentLedgerEntries(LedgerEntry[] evictedPersistentLedgerEntries) {
+ this.evictedPersistentLedgerEntries = evictedPersistentLedgerEntries;
+ return this;
+ }
+
+ public LedgerCloseMetaV2 build() {
+ LedgerCloseMetaV2 val = new LedgerCloseMetaV2();
+ val.setExt(this.ext);
+ val.setLedgerHeader(this.ledgerHeader);
+ val.setTxSet(this.txSet);
+ val.setTxProcessing(this.txProcessing);
+ val.setUpgradesProcessing(this.upgradesProcessing);
+ val.setScpInfo(this.scpInfo);
+ val.setTotalByteSizeOfBucketList(this.totalByteSizeOfBucketList);
+ val.setEvictedTemporaryLedgerKeys(this.evictedTemporaryLedgerKeys);
+ val.setEvictedPersistentLedgerEntries(this.evictedPersistentLedgerEntries);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerCloseValueSignature.java b/src/main/java/org/stellar/sdk/xdr/LedgerCloseValueSignature.java
index 9e2f97eec..470635bd5 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerCloseValueSignature.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerCloseValueSignature.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -58,7 +63,7 @@ public static LedgerCloseValueSignature decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(this.nodeID, this.signature);
+ return Objects.hash(this.nodeID, this.signature);
}
@Override
@@ -68,8 +73,32 @@ public boolean equals(Object object) {
}
LedgerCloseValueSignature other = (LedgerCloseValueSignature) object;
- return Objects.equal(this.nodeID, other.nodeID)
- && Objects.equal(this.signature, other.signature);
+ return Objects.equals(this.nodeID, other.nodeID)
+ && Objects.equals(this.signature, other.signature);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerCloseValueSignature fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerCloseValueSignature fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -88,8 +117,8 @@ public Builder signature(Signature signature) {
public LedgerCloseValueSignature build() {
LedgerCloseValueSignature val = new LedgerCloseValueSignature();
- val.setNodeID(nodeID);
- val.setSignature(signature);
+ val.setNodeID(this.nodeID);
+ val.setSignature(this.signature);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerEntry.java b/src/main/java/org/stellar/sdk/xdr/LedgerEntry.java
index 9275dc1be..248a39498 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerEntry.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerEntry.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -26,6 +31,14 @@
// ClaimableBalanceEntry claimableBalance;
// case LIQUIDITY_POOL:
// LiquidityPoolEntry liquidityPool;
+// case CONTRACT_DATA:
+// ContractDataEntry contractData;
+// case CONTRACT_CODE:
+// ContractCodeEntry contractCode;
+// case CONFIG_SETTING:
+// ConfigSettingEntry configSetting;
+// case EXPIRATION:
+// ExpirationEntry expiration;
// }
// data;
//
@@ -95,7 +108,7 @@ public static LedgerEntry decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.lastModifiedLedgerSeq, this.data, this.ext);
+ return Objects.hash(this.lastModifiedLedgerSeq, this.data, this.ext);
}
@Override
@@ -105,9 +118,33 @@ public boolean equals(Object object) {
}
LedgerEntry other = (LedgerEntry) object;
- return Objects.equal(this.lastModifiedLedgerSeq, other.lastModifiedLedgerSeq)
- && Objects.equal(this.data, other.data)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.lastModifiedLedgerSeq, other.lastModifiedLedgerSeq)
+ && Objects.equals(this.data, other.data)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -132,14 +169,14 @@ public Builder ext(LedgerEntryExt ext) {
public LedgerEntry build() {
LedgerEntry val = new LedgerEntry();
- val.setLastModifiedLedgerSeq(lastModifiedLedgerSeq);
- val.setData(data);
- val.setExt(ext);
+ val.setLastModifiedLedgerSeq(this.lastModifiedLedgerSeq);
+ val.setData(this.data);
+ val.setExt(this.ext);
return val;
}
}
- public static class LedgerEntryData {
+ public static class LedgerEntryData implements XdrElement {
public LedgerEntryData() {}
LedgerEntryType type;
@@ -212,6 +249,46 @@ public void setLiquidityPool(LiquidityPoolEntry value) {
this.liquidityPool = value;
}
+ private ContractDataEntry contractData;
+
+ public ContractDataEntry getContractData() {
+ return this.contractData;
+ }
+
+ public void setContractData(ContractDataEntry value) {
+ this.contractData = value;
+ }
+
+ private ContractCodeEntry contractCode;
+
+ public ContractCodeEntry getContractCode() {
+ return this.contractCode;
+ }
+
+ public void setContractCode(ContractCodeEntry value) {
+ this.contractCode = value;
+ }
+
+ private ConfigSettingEntry configSetting;
+
+ public ConfigSettingEntry getConfigSetting() {
+ return this.configSetting;
+ }
+
+ public void setConfigSetting(ConfigSettingEntry value) {
+ this.configSetting = value;
+ }
+
+ private ExpirationEntry expiration;
+
+ public ExpirationEntry getExpiration() {
+ return this.expiration;
+ }
+
+ public void setExpiration(ExpirationEntry value) {
+ this.expiration = value;
+ }
+
public static final class Builder {
private LedgerEntryType discriminant;
private AccountEntry account;
@@ -220,6 +297,10 @@ public static final class Builder {
private DataEntry data;
private ClaimableBalanceEntry claimableBalance;
private LiquidityPoolEntry liquidityPool;
+ private ContractDataEntry contractData;
+ private ContractCodeEntry contractCode;
+ private ConfigSettingEntry configSetting;
+ private ExpirationEntry expiration;
public Builder discriminant(LedgerEntryType discriminant) {
this.discriminant = discriminant;
@@ -256,15 +337,39 @@ public Builder liquidityPool(LiquidityPoolEntry liquidityPool) {
return this;
}
+ public Builder contractData(ContractDataEntry contractData) {
+ this.contractData = contractData;
+ return this;
+ }
+
+ public Builder contractCode(ContractCodeEntry contractCode) {
+ this.contractCode = contractCode;
+ return this;
+ }
+
+ public Builder configSetting(ConfigSettingEntry configSetting) {
+ this.configSetting = configSetting;
+ return this;
+ }
+
+ public Builder expiration(ExpirationEntry expiration) {
+ this.expiration = expiration;
+ return this;
+ }
+
public LedgerEntryData build() {
LedgerEntryData val = new LedgerEntryData();
val.setDiscriminant(discriminant);
- val.setAccount(account);
- val.setTrustLine(trustLine);
- val.setOffer(offer);
- val.setData(data);
- val.setClaimableBalance(claimableBalance);
- val.setLiquidityPool(liquidityPool);
+ val.setAccount(this.account);
+ val.setTrustLine(this.trustLine);
+ val.setOffer(this.offer);
+ val.setData(this.data);
+ val.setClaimableBalance(this.claimableBalance);
+ val.setLiquidityPool(this.liquidityPool);
+ val.setContractData(this.contractData);
+ val.setContractCode(this.contractCode);
+ val.setConfigSetting(this.configSetting);
+ val.setExpiration(this.expiration);
return val;
}
}
@@ -293,6 +398,18 @@ public static void encode(XdrDataOutputStream stream, LedgerEntryData encodedLed
case LIQUIDITY_POOL:
LiquidityPoolEntry.encode(stream, encodedLedgerEntryData.liquidityPool);
break;
+ case CONTRACT_DATA:
+ ContractDataEntry.encode(stream, encodedLedgerEntryData.contractData);
+ break;
+ case CONTRACT_CODE:
+ ContractCodeEntry.encode(stream, encodedLedgerEntryData.contractCode);
+ break;
+ case CONFIG_SETTING:
+ ConfigSettingEntry.encode(stream, encodedLedgerEntryData.configSetting);
+ break;
+ case EXPIRATION:
+ ExpirationEntry.encode(stream, encodedLedgerEntryData.expiration);
+ break;
}
}
@@ -323,19 +440,35 @@ public static LedgerEntryData decode(XdrDataInputStream stream) throws IOExcepti
case LIQUIDITY_POOL:
decodedLedgerEntryData.liquidityPool = LiquidityPoolEntry.decode(stream);
break;
+ case CONTRACT_DATA:
+ decodedLedgerEntryData.contractData = ContractDataEntry.decode(stream);
+ break;
+ case CONTRACT_CODE:
+ decodedLedgerEntryData.contractCode = ContractCodeEntry.decode(stream);
+ break;
+ case CONFIG_SETTING:
+ decodedLedgerEntryData.configSetting = ConfigSettingEntry.decode(stream);
+ break;
+ case EXPIRATION:
+ decodedLedgerEntryData.expiration = ExpirationEntry.decode(stream);
+ break;
}
return decodedLedgerEntryData;
}
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.account,
this.trustLine,
this.offer,
this.data,
this.claimableBalance,
this.liquidityPool,
+ this.contractData,
+ this.contractCode,
+ this.configSetting,
+ this.expiration,
this.type);
}
@@ -346,17 +479,45 @@ public boolean equals(Object object) {
}
LedgerEntryData other = (LedgerEntryData) object;
- return Objects.equal(this.account, other.account)
- && Objects.equal(this.trustLine, other.trustLine)
- && Objects.equal(this.offer, other.offer)
- && Objects.equal(this.data, other.data)
- && Objects.equal(this.claimableBalance, other.claimableBalance)
- && Objects.equal(this.liquidityPool, other.liquidityPool)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.account, other.account)
+ && Objects.equals(this.trustLine, other.trustLine)
+ && Objects.equals(this.offer, other.offer)
+ && Objects.equals(this.data, other.data)
+ && Objects.equals(this.claimableBalance, other.claimableBalance)
+ && Objects.equals(this.liquidityPool, other.liquidityPool)
+ && Objects.equals(this.contractData, other.contractData)
+ && Objects.equals(this.contractCode, other.contractCode)
+ && Objects.equals(this.configSetting, other.configSetting)
+ && Objects.equals(this.expiration, other.expiration)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerEntryData fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerEntryData fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
- public static class LedgerEntryExt {
+ public static class LedgerEntryExt implements XdrElement {
public LedgerEntryExt() {}
Integer v;
@@ -396,7 +557,7 @@ public Builder v1(LedgerEntryExtensionV1 v1) {
public LedgerEntryExt build() {
LedgerEntryExt val = new LedgerEntryExt();
val.setDiscriminant(discriminant);
- val.setV1(v1);
+ val.setV1(this.v1);
return val;
}
}
@@ -435,7 +596,7 @@ public static LedgerEntryExt decode(XdrDataInputStream stream) throws IOExceptio
@Override
public int hashCode() {
- return Objects.hashCode(this.v1, this.v);
+ return Objects.hash(this.v1, this.v);
}
@Override
@@ -445,7 +606,31 @@ public boolean equals(Object object) {
}
LedgerEntryExt other = (LedgerEntryExt) object;
- return Objects.equal(this.v1, other.v1) && Objects.equal(this.v, other.v);
+ return Objects.equals(this.v1, other.v1) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerEntryExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerEntryExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerEntryChange.java b/src/main/java/org/stellar/sdk/xdr/LedgerEntryChange.java
index 66c54ee79..1fa6cfeac 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerEntryChange.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerEntryChange.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -109,10 +114,10 @@ public Builder state(LedgerEntry state) {
public LedgerEntryChange build() {
LedgerEntryChange val = new LedgerEntryChange();
val.setDiscriminant(discriminant);
- val.setCreated(created);
- val.setUpdated(updated);
- val.setRemoved(removed);
- val.setState(state);
+ val.setCreated(this.created);
+ val.setUpdated(this.updated);
+ val.setRemoved(this.removed);
+ val.setState(this.state);
return val;
}
}
@@ -165,7 +170,7 @@ public static LedgerEntryChange decode(XdrDataInputStream stream) throws IOExcep
@Override
public int hashCode() {
- return Objects.hashCode(this.created, this.updated, this.removed, this.state, this.type);
+ return Objects.hash(this.created, this.updated, this.removed, this.state, this.type);
}
@Override
@@ -175,10 +180,34 @@ public boolean equals(Object object) {
}
LedgerEntryChange other = (LedgerEntryChange) object;
- return Objects.equal(this.created, other.created)
- && Objects.equal(this.updated, other.updated)
- && Objects.equal(this.removed, other.removed)
- && Objects.equal(this.state, other.state)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.created, other.created)
+ && Objects.equals(this.updated, other.updated)
+ && Objects.equals(this.removed, other.removed)
+ && Objects.equals(this.state, other.state)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerEntryChange fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerEntryChange fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerEntryChangeType.java b/src/main/java/org/stellar/sdk/xdr/LedgerEntryChangeType.java
index 4d7115831..88fa5dabc 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerEntryChangeType.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerEntryChangeType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -56,4 +61,28 @@ public static void encode(XdrDataOutputStream stream, LedgerEntryChangeType valu
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerEntryChangeType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerEntryChangeType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerEntryChanges.java b/src/main/java/org/stellar/sdk/xdr/LedgerEntryChanges.java
index 46caf3df9..3c051d783 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerEntryChanges.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerEntryChanges.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -65,4 +70,28 @@ public boolean equals(Object object) {
LedgerEntryChanges other = (LedgerEntryChanges) object;
return Arrays.equals(this.LedgerEntryChanges, other.LedgerEntryChanges);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerEntryChanges fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerEntryChanges fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerEntryExtensionV1.java b/src/main/java/org/stellar/sdk/xdr/LedgerEntryExtensionV1.java
index 8df4d5f3c..e7a6510c6 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerEntryExtensionV1.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerEntryExtensionV1.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -64,7 +69,7 @@ public static LedgerEntryExtensionV1 decode(XdrDataInputStream stream) throws IO
@Override
public int hashCode() {
- return Objects.hashCode(this.sponsoringID, this.ext);
+ return Objects.hash(this.sponsoringID, this.ext);
}
@Override
@@ -74,8 +79,32 @@ public boolean equals(Object object) {
}
LedgerEntryExtensionV1 other = (LedgerEntryExtensionV1) object;
- return Objects.equal(this.sponsoringID, other.sponsoringID)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.sponsoringID, other.sponsoringID)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerEntryExtensionV1 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerEntryExtensionV1 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -94,13 +123,13 @@ public Builder ext(LedgerEntryExtensionV1Ext ext) {
public LedgerEntryExtensionV1 build() {
LedgerEntryExtensionV1 val = new LedgerEntryExtensionV1();
- val.setSponsoringID(sponsoringID);
- val.setExt(ext);
+ val.setSponsoringID(this.sponsoringID);
+ val.setExt(this.ext);
return val;
}
}
- public static class LedgerEntryExtensionV1Ext {
+ public static class LedgerEntryExtensionV1Ext implements XdrElement {
public LedgerEntryExtensionV1Ext() {}
Integer v;
@@ -157,7 +186,7 @@ public static LedgerEntryExtensionV1Ext decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -167,7 +196,31 @@ public boolean equals(Object object) {
}
LedgerEntryExtensionV1Ext other = (LedgerEntryExtensionV1Ext) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerEntryExtensionV1Ext fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerEntryExtensionV1Ext fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerEntryType.java b/src/main/java/org/stellar/sdk/xdr/LedgerEntryType.java
index d7091fcc4..40774d025 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerEntryType.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerEntryType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -14,7 +19,11 @@
// OFFER = 2,
// DATA = 3,
// CLAIMABLE_BALANCE = 4,
-// LIQUIDITY_POOL = 5
+// LIQUIDITY_POOL = 5,
+// CONTRACT_DATA = 6,
+// CONTRACT_CODE = 7,
+// CONFIG_SETTING = 8,
+// EXPIRATION = 9
// };
// ===========================================================================
@@ -25,6 +34,10 @@ public enum LedgerEntryType implements XdrElement {
DATA(3),
CLAIMABLE_BALANCE(4),
LIQUIDITY_POOL(5),
+ CONTRACT_DATA(6),
+ CONTRACT_CODE(7),
+ CONFIG_SETTING(8),
+ EXPIRATION(9),
;
private int mValue;
@@ -51,6 +64,14 @@ public static LedgerEntryType decode(XdrDataInputStream stream) throws IOExcepti
return CLAIMABLE_BALANCE;
case 5:
return LIQUIDITY_POOL;
+ case 6:
+ return CONTRACT_DATA;
+ case 7:
+ return CONTRACT_CODE;
+ case 8:
+ return CONFIG_SETTING;
+ case 9:
+ return EXPIRATION;
default:
throw new RuntimeException("Unknown enum value: " + value);
}
@@ -63,4 +84,28 @@ public static void encode(XdrDataOutputStream stream, LedgerEntryType value) thr
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerEntryType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerEntryType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerFootprint.java b/src/main/java/org/stellar/sdk/xdr/LedgerFootprint.java
new file mode 100644
index 000000000..827e3beab
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerFootprint.java
@@ -0,0 +1,141 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct LedgerFootprint
+// {
+// LedgerKey readOnly<>;
+// LedgerKey readWrite<>;
+// };
+
+// ===========================================================================
+public class LedgerFootprint implements XdrElement {
+ public LedgerFootprint() {}
+
+ private LedgerKey[] readOnly;
+
+ public LedgerKey[] getReadOnly() {
+ return this.readOnly;
+ }
+
+ public void setReadOnly(LedgerKey[] value) {
+ this.readOnly = value;
+ }
+
+ private LedgerKey[] readWrite;
+
+ public LedgerKey[] getReadWrite() {
+ return this.readWrite;
+ }
+
+ public void setReadWrite(LedgerKey[] value) {
+ this.readWrite = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, LedgerFootprint encodedLedgerFootprint)
+ throws IOException {
+ int readOnlysize = encodedLedgerFootprint.getReadOnly().length;
+ stream.writeInt(readOnlysize);
+ for (int i = 0; i < readOnlysize; i++) {
+ LedgerKey.encode(stream, encodedLedgerFootprint.readOnly[i]);
+ }
+ int readWritesize = encodedLedgerFootprint.getReadWrite().length;
+ stream.writeInt(readWritesize);
+ for (int i = 0; i < readWritesize; i++) {
+ LedgerKey.encode(stream, encodedLedgerFootprint.readWrite[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static LedgerFootprint decode(XdrDataInputStream stream) throws IOException {
+ LedgerFootprint decodedLedgerFootprint = new LedgerFootprint();
+ int readOnlysize = stream.readInt();
+ decodedLedgerFootprint.readOnly = new LedgerKey[readOnlysize];
+ for (int i = 0; i < readOnlysize; i++) {
+ decodedLedgerFootprint.readOnly[i] = LedgerKey.decode(stream);
+ }
+ int readWritesize = stream.readInt();
+ decodedLedgerFootprint.readWrite = new LedgerKey[readWritesize];
+ for (int i = 0; i < readWritesize; i++) {
+ decodedLedgerFootprint.readWrite[i] = LedgerKey.decode(stream);
+ }
+ return decodedLedgerFootprint;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(Arrays.hashCode(this.readOnly), Arrays.hashCode(this.readWrite));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof LedgerFootprint)) {
+ return false;
+ }
+
+ LedgerFootprint other = (LedgerFootprint) object;
+ return Arrays.equals(this.readOnly, other.readOnly)
+ && Arrays.equals(this.readWrite, other.readWrite);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerFootprint fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerFootprint fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private LedgerKey[] readOnly;
+ private LedgerKey[] readWrite;
+
+ public Builder readOnly(LedgerKey[] readOnly) {
+ this.readOnly = readOnly;
+ return this;
+ }
+
+ public Builder readWrite(LedgerKey[] readWrite) {
+ this.readWrite = readWrite;
+ return this;
+ }
+
+ public LedgerFootprint build() {
+ LedgerFootprint val = new LedgerFootprint();
+ val.setReadOnly(this.readOnly);
+ val.setReadWrite(this.readWrite);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerHeader.java b/src/main/java/org/stellar/sdk/xdr/LedgerHeader.java
index ddddbfcd1..bcd463efe 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerHeader.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerHeader.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -255,7 +260,7 @@ public static LedgerHeader decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.ledgerVersion,
this.previousLedgerHash,
this.scpValue,
@@ -280,21 +285,45 @@ public boolean equals(Object object) {
}
LedgerHeader other = (LedgerHeader) object;
- return Objects.equal(this.ledgerVersion, other.ledgerVersion)
- && Objects.equal(this.previousLedgerHash, other.previousLedgerHash)
- && Objects.equal(this.scpValue, other.scpValue)
- && Objects.equal(this.txSetResultHash, other.txSetResultHash)
- && Objects.equal(this.bucketListHash, other.bucketListHash)
- && Objects.equal(this.ledgerSeq, other.ledgerSeq)
- && Objects.equal(this.totalCoins, other.totalCoins)
- && Objects.equal(this.feePool, other.feePool)
- && Objects.equal(this.inflationSeq, other.inflationSeq)
- && Objects.equal(this.idPool, other.idPool)
- && Objects.equal(this.baseFee, other.baseFee)
- && Objects.equal(this.baseReserve, other.baseReserve)
- && Objects.equal(this.maxTxSetSize, other.maxTxSetSize)
+ return Objects.equals(this.ledgerVersion, other.ledgerVersion)
+ && Objects.equals(this.previousLedgerHash, other.previousLedgerHash)
+ && Objects.equals(this.scpValue, other.scpValue)
+ && Objects.equals(this.txSetResultHash, other.txSetResultHash)
+ && Objects.equals(this.bucketListHash, other.bucketListHash)
+ && Objects.equals(this.ledgerSeq, other.ledgerSeq)
+ && Objects.equals(this.totalCoins, other.totalCoins)
+ && Objects.equals(this.feePool, other.feePool)
+ && Objects.equals(this.inflationSeq, other.inflationSeq)
+ && Objects.equals(this.idPool, other.idPool)
+ && Objects.equals(this.baseFee, other.baseFee)
+ && Objects.equals(this.baseReserve, other.baseReserve)
+ && Objects.equals(this.maxTxSetSize, other.maxTxSetSize)
&& Arrays.equals(this.skipList, other.skipList)
- && Objects.equal(this.ext, other.ext);
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerHeader fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerHeader fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -391,26 +420,26 @@ public Builder ext(LedgerHeaderExt ext) {
public LedgerHeader build() {
LedgerHeader val = new LedgerHeader();
- val.setLedgerVersion(ledgerVersion);
- val.setPreviousLedgerHash(previousLedgerHash);
- val.setScpValue(scpValue);
- val.setTxSetResultHash(txSetResultHash);
- val.setBucketListHash(bucketListHash);
- val.setLedgerSeq(ledgerSeq);
- val.setTotalCoins(totalCoins);
- val.setFeePool(feePool);
- val.setInflationSeq(inflationSeq);
- val.setIdPool(idPool);
- val.setBaseFee(baseFee);
- val.setBaseReserve(baseReserve);
- val.setMaxTxSetSize(maxTxSetSize);
- val.setSkipList(skipList);
- val.setExt(ext);
+ val.setLedgerVersion(this.ledgerVersion);
+ val.setPreviousLedgerHash(this.previousLedgerHash);
+ val.setScpValue(this.scpValue);
+ val.setTxSetResultHash(this.txSetResultHash);
+ val.setBucketListHash(this.bucketListHash);
+ val.setLedgerSeq(this.ledgerSeq);
+ val.setTotalCoins(this.totalCoins);
+ val.setFeePool(this.feePool);
+ val.setInflationSeq(this.inflationSeq);
+ val.setIdPool(this.idPool);
+ val.setBaseFee(this.baseFee);
+ val.setBaseReserve(this.baseReserve);
+ val.setMaxTxSetSize(this.maxTxSetSize);
+ val.setSkipList(this.skipList);
+ val.setExt(this.ext);
return val;
}
}
- public static class LedgerHeaderExt {
+ public static class LedgerHeaderExt implements XdrElement {
public LedgerHeaderExt() {}
Integer v;
@@ -450,7 +479,7 @@ public Builder v1(LedgerHeaderExtensionV1 v1) {
public LedgerHeaderExt build() {
LedgerHeaderExt val = new LedgerHeaderExt();
val.setDiscriminant(discriminant);
- val.setV1(v1);
+ val.setV1(this.v1);
return val;
}
}
@@ -489,7 +518,7 @@ public static LedgerHeaderExt decode(XdrDataInputStream stream) throws IOExcepti
@Override
public int hashCode() {
- return Objects.hashCode(this.v1, this.v);
+ return Objects.hash(this.v1, this.v);
}
@Override
@@ -499,7 +528,31 @@ public boolean equals(Object object) {
}
LedgerHeaderExt other = (LedgerHeaderExt) object;
- return Objects.equal(this.v1, other.v1) && Objects.equal(this.v, other.v);
+ return Objects.equals(this.v1, other.v1) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerHeaderExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerHeaderExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerHeaderExtensionV1.java b/src/main/java/org/stellar/sdk/xdr/LedgerHeaderExtensionV1.java
index 014514be5..d81323626 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerHeaderExtensionV1.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerHeaderExtensionV1.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -64,7 +69,7 @@ public static LedgerHeaderExtensionV1 decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(this.flags, this.ext);
+ return Objects.hash(this.flags, this.ext);
}
@Override
@@ -74,7 +79,31 @@ public boolean equals(Object object) {
}
LedgerHeaderExtensionV1 other = (LedgerHeaderExtensionV1) object;
- return Objects.equal(this.flags, other.flags) && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.flags, other.flags) && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerHeaderExtensionV1 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerHeaderExtensionV1 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -93,13 +122,13 @@ public Builder ext(LedgerHeaderExtensionV1Ext ext) {
public LedgerHeaderExtensionV1 build() {
LedgerHeaderExtensionV1 val = new LedgerHeaderExtensionV1();
- val.setFlags(flags);
- val.setExt(ext);
+ val.setFlags(this.flags);
+ val.setExt(this.ext);
return val;
}
}
- public static class LedgerHeaderExtensionV1Ext {
+ public static class LedgerHeaderExtensionV1Ext implements XdrElement {
public LedgerHeaderExtensionV1Ext() {}
Integer v;
@@ -157,7 +186,7 @@ public static LedgerHeaderExtensionV1Ext decode(XdrDataInputStream stream) throw
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -167,7 +196,31 @@ public boolean equals(Object object) {
}
LedgerHeaderExtensionV1Ext other = (LedgerHeaderExtensionV1Ext) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerHeaderExtensionV1Ext fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerHeaderExtensionV1Ext fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerHeaderFlags.java b/src/main/java/org/stellar/sdk/xdr/LedgerHeaderFlags.java
index bf9166fb0..73f179e81 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerHeaderFlags.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerHeaderFlags.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -52,4 +57,28 @@ public static void encode(XdrDataOutputStream stream, LedgerHeaderFlags value)
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerHeaderFlags fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerHeaderFlags fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerHeaderHistoryEntry.java b/src/main/java/org/stellar/sdk/xdr/LedgerHeaderHistoryEntry.java
index 032a30376..b8c91b502 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerHeaderHistoryEntry.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerHeaderHistoryEntry.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -78,7 +83,7 @@ public static LedgerHeaderHistoryEntry decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(this.hash, this.header, this.ext);
+ return Objects.hash(this.hash, this.header, this.ext);
}
@Override
@@ -88,9 +93,33 @@ public boolean equals(Object object) {
}
LedgerHeaderHistoryEntry other = (LedgerHeaderHistoryEntry) object;
- return Objects.equal(this.hash, other.hash)
- && Objects.equal(this.header, other.header)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.hash, other.hash)
+ && Objects.equals(this.header, other.header)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerHeaderHistoryEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerHeaderHistoryEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -115,14 +144,14 @@ public Builder ext(LedgerHeaderHistoryEntryExt ext) {
public LedgerHeaderHistoryEntry build() {
LedgerHeaderHistoryEntry val = new LedgerHeaderHistoryEntry();
- val.setHash(hash);
- val.setHeader(header);
- val.setExt(ext);
+ val.setHash(this.hash);
+ val.setHeader(this.header);
+ val.setExt(this.ext);
return val;
}
}
- public static class LedgerHeaderHistoryEntryExt {
+ public static class LedgerHeaderHistoryEntryExt implements XdrElement {
public LedgerHeaderHistoryEntryExt() {}
Integer v;
@@ -180,7 +209,7 @@ public static LedgerHeaderHistoryEntryExt decode(XdrDataInputStream stream) thro
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -190,7 +219,31 @@ public boolean equals(Object object) {
}
LedgerHeaderHistoryEntryExt other = (LedgerHeaderHistoryEntryExt) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerHeaderHistoryEntryExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerHeaderHistoryEntryExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerKey.java b/src/main/java/org/stellar/sdk/xdr/LedgerKey.java
index 54e9779e3..9637f7848 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerKey.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerKey.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -48,6 +53,29 @@
// {
// PoolID liquidityPoolID;
// } liquidityPool;
+// case CONTRACT_DATA:
+// struct
+// {
+// SCAddress contract;
+// SCVal key;
+// ContractDataDurability durability;
+// } contractData;
+// case CONTRACT_CODE:
+// struct
+// {
+// Hash hash;
+// } contractCode;
+// case CONFIG_SETTING:
+// struct
+// {
+// ConfigSettingID configSettingID;
+// } configSetting;
+// case EXPIRATION:
+// struct
+// {
+// // Hash of the LedgerKey that is associated with this ExpirationEntry
+// Hash keyHash;
+// } expiration;
// };
// ===========================================================================
@@ -124,6 +152,46 @@ public void setLiquidityPool(LedgerKeyLiquidityPool value) {
this.liquidityPool = value;
}
+ private LedgerKeyContractData contractData;
+
+ public LedgerKeyContractData getContractData() {
+ return this.contractData;
+ }
+
+ public void setContractData(LedgerKeyContractData value) {
+ this.contractData = value;
+ }
+
+ private LedgerKeyContractCode contractCode;
+
+ public LedgerKeyContractCode getContractCode() {
+ return this.contractCode;
+ }
+
+ public void setContractCode(LedgerKeyContractCode value) {
+ this.contractCode = value;
+ }
+
+ private LedgerKeyConfigSetting configSetting;
+
+ public LedgerKeyConfigSetting getConfigSetting() {
+ return this.configSetting;
+ }
+
+ public void setConfigSetting(LedgerKeyConfigSetting value) {
+ this.configSetting = value;
+ }
+
+ private LedgerKeyExpiration expiration;
+
+ public LedgerKeyExpiration getExpiration() {
+ return this.expiration;
+ }
+
+ public void setExpiration(LedgerKeyExpiration value) {
+ this.expiration = value;
+ }
+
public static final class Builder {
private LedgerEntryType discriminant;
private LedgerKeyAccount account;
@@ -132,6 +200,10 @@ public static final class Builder {
private LedgerKeyData data;
private LedgerKeyClaimableBalance claimableBalance;
private LedgerKeyLiquidityPool liquidityPool;
+ private LedgerKeyContractData contractData;
+ private LedgerKeyContractCode contractCode;
+ private LedgerKeyConfigSetting configSetting;
+ private LedgerKeyExpiration expiration;
public Builder discriminant(LedgerEntryType discriminant) {
this.discriminant = discriminant;
@@ -168,15 +240,39 @@ public Builder liquidityPool(LedgerKeyLiquidityPool liquidityPool) {
return this;
}
+ public Builder contractData(LedgerKeyContractData contractData) {
+ this.contractData = contractData;
+ return this;
+ }
+
+ public Builder contractCode(LedgerKeyContractCode contractCode) {
+ this.contractCode = contractCode;
+ return this;
+ }
+
+ public Builder configSetting(LedgerKeyConfigSetting configSetting) {
+ this.configSetting = configSetting;
+ return this;
+ }
+
+ public Builder expiration(LedgerKeyExpiration expiration) {
+ this.expiration = expiration;
+ return this;
+ }
+
public LedgerKey build() {
LedgerKey val = new LedgerKey();
val.setDiscriminant(discriminant);
- val.setAccount(account);
- val.setTrustLine(trustLine);
- val.setOffer(offer);
- val.setData(data);
- val.setClaimableBalance(claimableBalance);
- val.setLiquidityPool(liquidityPool);
+ val.setAccount(this.account);
+ val.setTrustLine(this.trustLine);
+ val.setOffer(this.offer);
+ val.setData(this.data);
+ val.setClaimableBalance(this.claimableBalance);
+ val.setLiquidityPool(this.liquidityPool);
+ val.setContractData(this.contractData);
+ val.setContractCode(this.contractCode);
+ val.setConfigSetting(this.configSetting);
+ val.setExpiration(this.expiration);
return val;
}
}
@@ -205,6 +301,18 @@ public static void encode(XdrDataOutputStream stream, LedgerKey encodedLedgerKey
case LIQUIDITY_POOL:
LedgerKeyLiquidityPool.encode(stream, encodedLedgerKey.liquidityPool);
break;
+ case CONTRACT_DATA:
+ LedgerKeyContractData.encode(stream, encodedLedgerKey.contractData);
+ break;
+ case CONTRACT_CODE:
+ LedgerKeyContractCode.encode(stream, encodedLedgerKey.contractCode);
+ break;
+ case CONFIG_SETTING:
+ LedgerKeyConfigSetting.encode(stream, encodedLedgerKey.configSetting);
+ break;
+ case EXPIRATION:
+ LedgerKeyExpiration.encode(stream, encodedLedgerKey.expiration);
+ break;
}
}
@@ -235,19 +343,35 @@ public static LedgerKey decode(XdrDataInputStream stream) throws IOException {
case LIQUIDITY_POOL:
decodedLedgerKey.liquidityPool = LedgerKeyLiquidityPool.decode(stream);
break;
+ case CONTRACT_DATA:
+ decodedLedgerKey.contractData = LedgerKeyContractData.decode(stream);
+ break;
+ case CONTRACT_CODE:
+ decodedLedgerKey.contractCode = LedgerKeyContractCode.decode(stream);
+ break;
+ case CONFIG_SETTING:
+ decodedLedgerKey.configSetting = LedgerKeyConfigSetting.decode(stream);
+ break;
+ case EXPIRATION:
+ decodedLedgerKey.expiration = LedgerKeyExpiration.decode(stream);
+ break;
}
return decodedLedgerKey;
}
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.account,
this.trustLine,
this.offer,
this.data,
this.claimableBalance,
this.liquidityPool,
+ this.contractData,
+ this.contractCode,
+ this.configSetting,
+ this.expiration,
this.type);
}
@@ -258,16 +382,44 @@ public boolean equals(Object object) {
}
LedgerKey other = (LedgerKey) object;
- return Objects.equal(this.account, other.account)
- && Objects.equal(this.trustLine, other.trustLine)
- && Objects.equal(this.offer, other.offer)
- && Objects.equal(this.data, other.data)
- && Objects.equal(this.claimableBalance, other.claimableBalance)
- && Objects.equal(this.liquidityPool, other.liquidityPool)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.account, other.account)
+ && Objects.equals(this.trustLine, other.trustLine)
+ && Objects.equals(this.offer, other.offer)
+ && Objects.equals(this.data, other.data)
+ && Objects.equals(this.claimableBalance, other.claimableBalance)
+ && Objects.equals(this.liquidityPool, other.liquidityPool)
+ && Objects.equals(this.contractData, other.contractData)
+ && Objects.equals(this.contractCode, other.contractCode)
+ && Objects.equals(this.configSetting, other.configSetting)
+ && Objects.equals(this.expiration, other.expiration)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerKey fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerKey fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
- public static class LedgerKeyAccount {
+ public static class LedgerKeyAccount implements XdrElement {
public LedgerKeyAccount() {}
private AccountID accountID;
@@ -297,7 +449,7 @@ public static LedgerKeyAccount decode(XdrDataInputStream stream) throws IOExcept
@Override
public int hashCode() {
- return Objects.hashCode(this.accountID);
+ return Objects.hash(this.accountID);
}
@Override
@@ -307,7 +459,31 @@ public boolean equals(Object object) {
}
LedgerKeyAccount other = (LedgerKeyAccount) object;
- return Objects.equal(this.accountID, other.accountID);
+ return Objects.equals(this.accountID, other.accountID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerKeyAccount fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerKeyAccount fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -320,13 +496,13 @@ public Builder accountID(AccountID accountID) {
public LedgerKeyAccount build() {
LedgerKeyAccount val = new LedgerKeyAccount();
- val.setAccountID(accountID);
+ val.setAccountID(this.accountID);
return val;
}
}
}
- public static class LedgerKeyTrustLine {
+ public static class LedgerKeyTrustLine implements XdrElement {
public LedgerKeyTrustLine() {}
private AccountID accountID;
@@ -369,7 +545,7 @@ public static LedgerKeyTrustLine decode(XdrDataInputStream stream) throws IOExce
@Override
public int hashCode() {
- return Objects.hashCode(this.accountID, this.asset);
+ return Objects.hash(this.accountID, this.asset);
}
@Override
@@ -379,8 +555,32 @@ public boolean equals(Object object) {
}
LedgerKeyTrustLine other = (LedgerKeyTrustLine) object;
- return Objects.equal(this.accountID, other.accountID)
- && Objects.equal(this.asset, other.asset);
+ return Objects.equals(this.accountID, other.accountID)
+ && Objects.equals(this.asset, other.asset);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerKeyTrustLine fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerKeyTrustLine fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -399,14 +599,14 @@ public Builder asset(TrustLineAsset asset) {
public LedgerKeyTrustLine build() {
LedgerKeyTrustLine val = new LedgerKeyTrustLine();
- val.setAccountID(accountID);
- val.setAsset(asset);
+ val.setAccountID(this.accountID);
+ val.setAsset(this.asset);
return val;
}
}
}
- public static class LedgerKeyOffer {
+ public static class LedgerKeyOffer implements XdrElement {
public LedgerKeyOffer() {}
private AccountID sellerID;
@@ -448,7 +648,7 @@ public static LedgerKeyOffer decode(XdrDataInputStream stream) throws IOExceptio
@Override
public int hashCode() {
- return Objects.hashCode(this.sellerID, this.offerID);
+ return Objects.hash(this.sellerID, this.offerID);
}
@Override
@@ -458,8 +658,32 @@ public boolean equals(Object object) {
}
LedgerKeyOffer other = (LedgerKeyOffer) object;
- return Objects.equal(this.sellerID, other.sellerID)
- && Objects.equal(this.offerID, other.offerID);
+ return Objects.equals(this.sellerID, other.sellerID)
+ && Objects.equals(this.offerID, other.offerID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerKeyOffer fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerKeyOffer fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -478,14 +702,14 @@ public Builder offerID(Int64 offerID) {
public LedgerKeyOffer build() {
LedgerKeyOffer val = new LedgerKeyOffer();
- val.setSellerID(sellerID);
- val.setOfferID(offerID);
+ val.setSellerID(this.sellerID);
+ val.setOfferID(this.offerID);
return val;
}
}
}
- public static class LedgerKeyData {
+ public static class LedgerKeyData implements XdrElement {
public LedgerKeyData() {}
private AccountID accountID;
@@ -527,7 +751,7 @@ public static LedgerKeyData decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(this.accountID, this.dataName);
+ return Objects.hash(this.accountID, this.dataName);
}
@Override
@@ -537,8 +761,32 @@ public boolean equals(Object object) {
}
LedgerKeyData other = (LedgerKeyData) object;
- return Objects.equal(this.accountID, other.accountID)
- && Objects.equal(this.dataName, other.dataName);
+ return Objects.equals(this.accountID, other.accountID)
+ && Objects.equals(this.dataName, other.dataName);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerKeyData fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerKeyData fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -557,14 +805,14 @@ public Builder dataName(String64 dataName) {
public LedgerKeyData build() {
LedgerKeyData val = new LedgerKeyData();
- val.setAccountID(accountID);
- val.setDataName(dataName);
+ val.setAccountID(this.accountID);
+ val.setDataName(this.dataName);
return val;
}
}
}
- public static class LedgerKeyClaimableBalance {
+ public static class LedgerKeyClaimableBalance implements XdrElement {
public LedgerKeyClaimableBalance() {}
private ClaimableBalanceID balanceID;
@@ -595,7 +843,7 @@ public static LedgerKeyClaimableBalance decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(this.balanceID);
+ return Objects.hash(this.balanceID);
}
@Override
@@ -605,7 +853,31 @@ public boolean equals(Object object) {
}
LedgerKeyClaimableBalance other = (LedgerKeyClaimableBalance) object;
- return Objects.equal(this.balanceID, other.balanceID);
+ return Objects.equals(this.balanceID, other.balanceID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerKeyClaimableBalance fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerKeyClaimableBalance fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -618,13 +890,13 @@ public Builder balanceID(ClaimableBalanceID balanceID) {
public LedgerKeyClaimableBalance build() {
LedgerKeyClaimableBalance val = new LedgerKeyClaimableBalance();
- val.setBalanceID(balanceID);
+ val.setBalanceID(this.balanceID);
return val;
}
}
}
- public static class LedgerKeyLiquidityPool {
+ public static class LedgerKeyLiquidityPool implements XdrElement {
public LedgerKeyLiquidityPool() {}
private PoolID liquidityPoolID;
@@ -655,7 +927,7 @@ public static LedgerKeyLiquidityPool decode(XdrDataInputStream stream) throws IO
@Override
public int hashCode() {
- return Objects.hashCode(this.liquidityPoolID);
+ return Objects.hash(this.liquidityPoolID);
}
@Override
@@ -665,7 +937,31 @@ public boolean equals(Object object) {
}
LedgerKeyLiquidityPool other = (LedgerKeyLiquidityPool) object;
- return Objects.equal(this.liquidityPoolID, other.liquidityPoolID);
+ return Objects.equals(this.liquidityPoolID, other.liquidityPoolID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerKeyLiquidityPool fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerKeyLiquidityPool fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -678,7 +974,383 @@ public Builder liquidityPoolID(PoolID liquidityPoolID) {
public LedgerKeyLiquidityPool build() {
LedgerKeyLiquidityPool val = new LedgerKeyLiquidityPool();
- val.setLiquidityPoolID(liquidityPoolID);
+ val.setLiquidityPoolID(this.liquidityPoolID);
+ return val;
+ }
+ }
+ }
+
+ public static class LedgerKeyContractData implements XdrElement {
+ public LedgerKeyContractData() {}
+
+ private SCAddress contract;
+
+ public SCAddress getContract() {
+ return this.contract;
+ }
+
+ public void setContract(SCAddress value) {
+ this.contract = value;
+ }
+
+ private SCVal key;
+
+ public SCVal getKey() {
+ return this.key;
+ }
+
+ public void setKey(SCVal value) {
+ this.key = value;
+ }
+
+ private ContractDataDurability durability;
+
+ public ContractDataDurability getDurability() {
+ return this.durability;
+ }
+
+ public void setDurability(ContractDataDurability value) {
+ this.durability = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, LedgerKeyContractData encodedLedgerKeyContractData)
+ throws IOException {
+ SCAddress.encode(stream, encodedLedgerKeyContractData.contract);
+ SCVal.encode(stream, encodedLedgerKeyContractData.key);
+ ContractDataDurability.encode(stream, encodedLedgerKeyContractData.durability);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static LedgerKeyContractData decode(XdrDataInputStream stream) throws IOException {
+ LedgerKeyContractData decodedLedgerKeyContractData = new LedgerKeyContractData();
+ decodedLedgerKeyContractData.contract = SCAddress.decode(stream);
+ decodedLedgerKeyContractData.key = SCVal.decode(stream);
+ decodedLedgerKeyContractData.durability = ContractDataDurability.decode(stream);
+ return decodedLedgerKeyContractData;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.contract, this.key, this.durability);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof LedgerKeyContractData)) {
+ return false;
+ }
+
+ LedgerKeyContractData other = (LedgerKeyContractData) object;
+ return Objects.equals(this.contract, other.contract)
+ && Objects.equals(this.key, other.key)
+ && Objects.equals(this.durability, other.durability);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerKeyContractData fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerKeyContractData fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCAddress contract;
+ private SCVal key;
+ private ContractDataDurability durability;
+
+ public Builder contract(SCAddress contract) {
+ this.contract = contract;
+ return this;
+ }
+
+ public Builder key(SCVal key) {
+ this.key = key;
+ return this;
+ }
+
+ public Builder durability(ContractDataDurability durability) {
+ this.durability = durability;
+ return this;
+ }
+
+ public LedgerKeyContractData build() {
+ LedgerKeyContractData val = new LedgerKeyContractData();
+ val.setContract(this.contract);
+ val.setKey(this.key);
+ val.setDurability(this.durability);
+ return val;
+ }
+ }
+ }
+
+ public static class LedgerKeyContractCode implements XdrElement {
+ public LedgerKeyContractCode() {}
+
+ private Hash hash;
+
+ public Hash getHash() {
+ return this.hash;
+ }
+
+ public void setHash(Hash value) {
+ this.hash = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, LedgerKeyContractCode encodedLedgerKeyContractCode)
+ throws IOException {
+ Hash.encode(stream, encodedLedgerKeyContractCode.hash);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static LedgerKeyContractCode decode(XdrDataInputStream stream) throws IOException {
+ LedgerKeyContractCode decodedLedgerKeyContractCode = new LedgerKeyContractCode();
+ decodedLedgerKeyContractCode.hash = Hash.decode(stream);
+ return decodedLedgerKeyContractCode;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.hash);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof LedgerKeyContractCode)) {
+ return false;
+ }
+
+ LedgerKeyContractCode other = (LedgerKeyContractCode) object;
+ return Objects.equals(this.hash, other.hash);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerKeyContractCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerKeyContractCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Hash hash;
+
+ public Builder hash(Hash hash) {
+ this.hash = hash;
+ return this;
+ }
+
+ public LedgerKeyContractCode build() {
+ LedgerKeyContractCode val = new LedgerKeyContractCode();
+ val.setHash(this.hash);
+ return val;
+ }
+ }
+ }
+
+ public static class LedgerKeyConfigSetting implements XdrElement {
+ public LedgerKeyConfigSetting() {}
+
+ private ConfigSettingID configSettingID;
+
+ public ConfigSettingID getConfigSettingID() {
+ return this.configSettingID;
+ }
+
+ public void setConfigSettingID(ConfigSettingID value) {
+ this.configSettingID = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, LedgerKeyConfigSetting encodedLedgerKeyConfigSetting)
+ throws IOException {
+ ConfigSettingID.encode(stream, encodedLedgerKeyConfigSetting.configSettingID);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static LedgerKeyConfigSetting decode(XdrDataInputStream stream) throws IOException {
+ LedgerKeyConfigSetting decodedLedgerKeyConfigSetting = new LedgerKeyConfigSetting();
+ decodedLedgerKeyConfigSetting.configSettingID = ConfigSettingID.decode(stream);
+ return decodedLedgerKeyConfigSetting;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.configSettingID);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof LedgerKeyConfigSetting)) {
+ return false;
+ }
+
+ LedgerKeyConfigSetting other = (LedgerKeyConfigSetting) object;
+ return Objects.equals(this.configSettingID, other.configSettingID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerKeyConfigSetting fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerKeyConfigSetting fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ConfigSettingID configSettingID;
+
+ public Builder configSettingID(ConfigSettingID configSettingID) {
+ this.configSettingID = configSettingID;
+ return this;
+ }
+
+ public LedgerKeyConfigSetting build() {
+ LedgerKeyConfigSetting val = new LedgerKeyConfigSetting();
+ val.setConfigSettingID(this.configSettingID);
+ return val;
+ }
+ }
+ }
+
+ public static class LedgerKeyExpiration implements XdrElement {
+ public LedgerKeyExpiration() {}
+
+ private Hash keyHash;
+
+ public Hash getKeyHash() {
+ return this.keyHash;
+ }
+
+ public void setKeyHash(Hash value) {
+ this.keyHash = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, LedgerKeyExpiration encodedLedgerKeyExpiration)
+ throws IOException {
+ Hash.encode(stream, encodedLedgerKeyExpiration.keyHash);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static LedgerKeyExpiration decode(XdrDataInputStream stream) throws IOException {
+ LedgerKeyExpiration decodedLedgerKeyExpiration = new LedgerKeyExpiration();
+ decodedLedgerKeyExpiration.keyHash = Hash.decode(stream);
+ return decodedLedgerKeyExpiration;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.keyHash);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof LedgerKeyExpiration)) {
+ return false;
+ }
+
+ LedgerKeyExpiration other = (LedgerKeyExpiration) object;
+ return Objects.equals(this.keyHash, other.keyHash);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerKeyExpiration fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerKeyExpiration fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Hash keyHash;
+
+ public Builder keyHash(Hash keyHash) {
+ this.keyHash = keyHash;
+ return this;
+ }
+
+ public LedgerKeyExpiration build() {
+ LedgerKeyExpiration val = new LedgerKeyExpiration();
+ val.setKeyHash(this.keyHash);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerSCPMessages.java b/src/main/java/org/stellar/sdk/xdr/LedgerSCPMessages.java
index ad0770d59..734e792a5 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerSCPMessages.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerSCPMessages.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -66,7 +71,7 @@ public static LedgerSCPMessages decode(XdrDataInputStream stream) throws IOExcep
@Override
public int hashCode() {
- return Objects.hashCode(this.ledgerSeq, Arrays.hashCode(this.messages));
+ return Objects.hash(this.ledgerSeq, Arrays.hashCode(this.messages));
}
@Override
@@ -76,10 +81,34 @@ public boolean equals(Object object) {
}
LedgerSCPMessages other = (LedgerSCPMessages) object;
- return Objects.equal(this.ledgerSeq, other.ledgerSeq)
+ return Objects.equals(this.ledgerSeq, other.ledgerSeq)
&& Arrays.equals(this.messages, other.messages);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerSCPMessages fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerSCPMessages fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private Uint32 ledgerSeq;
private SCPEnvelope[] messages;
@@ -96,8 +125,8 @@ public Builder messages(SCPEnvelope[] messages) {
public LedgerSCPMessages build() {
LedgerSCPMessages val = new LedgerSCPMessages();
- val.setLedgerSeq(ledgerSeq);
- val.setMessages(messages);
+ val.setLedgerSeq(this.ledgerSeq);
+ val.setMessages(this.messages);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerUpgrade.java b/src/main/java/org/stellar/sdk/xdr/LedgerUpgrade.java
index 595e40e86..e91d0416b 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerUpgrade.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerUpgrade.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -20,6 +25,13 @@
// uint32 newBaseReserve; // update baseReserve
// case LEDGER_UPGRADE_FLAGS:
// uint32 newFlags; // update flags
+// case LEDGER_UPGRADE_CONFIG:
+// // Update arbitrary `ConfigSetting` entries identified by the key.
+// ConfigUpgradeSetKey newConfig;
+// case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE:
+// // Update ConfigSettingContractExecutionLanesV0.ledgerMaxTxCount without
+// // using `LEDGER_UPGRADE_CONFIG`.
+// uint32 newMaxSorobanTxSetSize;
// };
// ===========================================================================
@@ -86,6 +98,26 @@ public void setNewFlags(Uint32 value) {
this.newFlags = value;
}
+ private ConfigUpgradeSetKey newConfig;
+
+ public ConfigUpgradeSetKey getNewConfig() {
+ return this.newConfig;
+ }
+
+ public void setNewConfig(ConfigUpgradeSetKey value) {
+ this.newConfig = value;
+ }
+
+ private Uint32 newMaxSorobanTxSetSize;
+
+ public Uint32 getNewMaxSorobanTxSetSize() {
+ return this.newMaxSorobanTxSetSize;
+ }
+
+ public void setNewMaxSorobanTxSetSize(Uint32 value) {
+ this.newMaxSorobanTxSetSize = value;
+ }
+
public static final class Builder {
private LedgerUpgradeType discriminant;
private Uint32 newLedgerVersion;
@@ -93,6 +125,8 @@ public static final class Builder {
private Uint32 newMaxTxSetSize;
private Uint32 newBaseReserve;
private Uint32 newFlags;
+ private ConfigUpgradeSetKey newConfig;
+ private Uint32 newMaxSorobanTxSetSize;
public Builder discriminant(LedgerUpgradeType discriminant) {
this.discriminant = discriminant;
@@ -124,14 +158,26 @@ public Builder newFlags(Uint32 newFlags) {
return this;
}
+ public Builder newConfig(ConfigUpgradeSetKey newConfig) {
+ this.newConfig = newConfig;
+ return this;
+ }
+
+ public Builder newMaxSorobanTxSetSize(Uint32 newMaxSorobanTxSetSize) {
+ this.newMaxSorobanTxSetSize = newMaxSorobanTxSetSize;
+ return this;
+ }
+
public LedgerUpgrade build() {
LedgerUpgrade val = new LedgerUpgrade();
val.setDiscriminant(discriminant);
- val.setNewLedgerVersion(newLedgerVersion);
- val.setNewBaseFee(newBaseFee);
- val.setNewMaxTxSetSize(newMaxTxSetSize);
- val.setNewBaseReserve(newBaseReserve);
- val.setNewFlags(newFlags);
+ val.setNewLedgerVersion(this.newLedgerVersion);
+ val.setNewBaseFee(this.newBaseFee);
+ val.setNewMaxTxSetSize(this.newMaxTxSetSize);
+ val.setNewBaseReserve(this.newBaseReserve);
+ val.setNewFlags(this.newFlags);
+ val.setNewConfig(this.newConfig);
+ val.setNewMaxSorobanTxSetSize(this.newMaxSorobanTxSetSize);
return val;
}
}
@@ -157,6 +203,12 @@ public static void encode(XdrDataOutputStream stream, LedgerUpgrade encodedLedge
case LEDGER_UPGRADE_FLAGS:
Uint32.encode(stream, encodedLedgerUpgrade.newFlags);
break;
+ case LEDGER_UPGRADE_CONFIG:
+ ConfigUpgradeSetKey.encode(stream, encodedLedgerUpgrade.newConfig);
+ break;
+ case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE:
+ Uint32.encode(stream, encodedLedgerUpgrade.newMaxSorobanTxSetSize);
+ break;
}
}
@@ -184,18 +236,26 @@ public static LedgerUpgrade decode(XdrDataInputStream stream) throws IOException
case LEDGER_UPGRADE_FLAGS:
decodedLedgerUpgrade.newFlags = Uint32.decode(stream);
break;
+ case LEDGER_UPGRADE_CONFIG:
+ decodedLedgerUpgrade.newConfig = ConfigUpgradeSetKey.decode(stream);
+ break;
+ case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE:
+ decodedLedgerUpgrade.newMaxSorobanTxSetSize = Uint32.decode(stream);
+ break;
}
return decodedLedgerUpgrade;
}
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.newLedgerVersion,
this.newBaseFee,
this.newMaxTxSetSize,
this.newBaseReserve,
this.newFlags,
+ this.newConfig,
+ this.newMaxSorobanTxSetSize,
this.type);
}
@@ -206,11 +266,37 @@ public boolean equals(Object object) {
}
LedgerUpgrade other = (LedgerUpgrade) object;
- return Objects.equal(this.newLedgerVersion, other.newLedgerVersion)
- && Objects.equal(this.newBaseFee, other.newBaseFee)
- && Objects.equal(this.newMaxTxSetSize, other.newMaxTxSetSize)
- && Objects.equal(this.newBaseReserve, other.newBaseReserve)
- && Objects.equal(this.newFlags, other.newFlags)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.newLedgerVersion, other.newLedgerVersion)
+ && Objects.equals(this.newBaseFee, other.newBaseFee)
+ && Objects.equals(this.newMaxTxSetSize, other.newMaxTxSetSize)
+ && Objects.equals(this.newBaseReserve, other.newBaseReserve)
+ && Objects.equals(this.newFlags, other.newFlags)
+ && Objects.equals(this.newConfig, other.newConfig)
+ && Objects.equals(this.newMaxSorobanTxSetSize, other.newMaxSorobanTxSetSize)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerUpgrade fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerUpgrade fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerUpgradeType.java b/src/main/java/org/stellar/sdk/xdr/LedgerUpgradeType.java
index 79663279f..d44e68d1c 100644
--- a/src/main/java/org/stellar/sdk/xdr/LedgerUpgradeType.java
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerUpgradeType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -13,7 +18,9 @@
// LEDGER_UPGRADE_BASE_FEE = 2,
// LEDGER_UPGRADE_MAX_TX_SET_SIZE = 3,
// LEDGER_UPGRADE_BASE_RESERVE = 4,
-// LEDGER_UPGRADE_FLAGS = 5
+// LEDGER_UPGRADE_FLAGS = 5,
+// LEDGER_UPGRADE_CONFIG = 6,
+// LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE = 7
// };
// ===========================================================================
@@ -23,6 +30,8 @@ public enum LedgerUpgradeType implements XdrElement {
LEDGER_UPGRADE_MAX_TX_SET_SIZE(3),
LEDGER_UPGRADE_BASE_RESERVE(4),
LEDGER_UPGRADE_FLAGS(5),
+ LEDGER_UPGRADE_CONFIG(6),
+ LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE(7),
;
private int mValue;
@@ -47,6 +56,10 @@ public static LedgerUpgradeType decode(XdrDataInputStream stream) throws IOExcep
return LEDGER_UPGRADE_BASE_RESERVE;
case 5:
return LEDGER_UPGRADE_FLAGS;
+ case 6:
+ return LEDGER_UPGRADE_CONFIG;
+ case 7:
+ return LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE;
default:
throw new RuntimeException("Unknown enum value: " + value);
}
@@ -60,4 +73,28 @@ public static void encode(XdrDataOutputStream stream, LedgerUpgradeType value)
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LedgerUpgradeType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LedgerUpgradeType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Liabilities.java b/src/main/java/org/stellar/sdk/xdr/Liabilities.java
index 8f1d8d4a2..851b06ef6 100644
--- a/src/main/java/org/stellar/sdk/xdr/Liabilities.java
+++ b/src/main/java/org/stellar/sdk/xdr/Liabilities.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -57,7 +62,7 @@ public static Liabilities decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.buying, this.selling);
+ return Objects.hash(this.buying, this.selling);
}
@Override
@@ -67,7 +72,31 @@ public boolean equals(Object object) {
}
Liabilities other = (Liabilities) object;
- return Objects.equal(this.buying, other.buying) && Objects.equal(this.selling, other.selling);
+ return Objects.equals(this.buying, other.buying) && Objects.equals(this.selling, other.selling);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Liabilities fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Liabilities fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -86,8 +115,8 @@ public Builder selling(Int64 selling) {
public Liabilities build() {
Liabilities val = new Liabilities();
- val.setBuying(buying);
- val.setSelling(selling);
+ val.setBuying(this.buying);
+ val.setSelling(this.selling);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolConstantProductParameters.java b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolConstantProductParameters.java
index b0a5ba762..c10d88b23 100644
--- a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolConstantProductParameters.java
+++ b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolConstantProductParameters.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -74,7 +79,7 @@ public static LiquidityPoolConstantProductParameters decode(XdrDataInputStream s
@Override
public int hashCode() {
- return Objects.hashCode(this.assetA, this.assetB, this.fee);
+ return Objects.hash(this.assetA, this.assetB, this.fee);
}
@Override
@@ -84,9 +89,35 @@ public boolean equals(Object object) {
}
LiquidityPoolConstantProductParameters other = (LiquidityPoolConstantProductParameters) object;
- return Objects.equal(this.assetA, other.assetA)
- && Objects.equal(this.assetB, other.assetB)
- && Objects.equal(this.fee, other.fee);
+ return Objects.equals(this.assetA, other.assetA)
+ && Objects.equals(this.assetB, other.assetB)
+ && Objects.equals(this.fee, other.fee);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LiquidityPoolConstantProductParameters fromXdrBase64(String xdr)
+ throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LiquidityPoolConstantProductParameters fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -111,9 +142,9 @@ public Builder fee(Int32 fee) {
public LiquidityPoolConstantProductParameters build() {
LiquidityPoolConstantProductParameters val = new LiquidityPoolConstantProductParameters();
- val.setAssetA(assetA);
- val.setAssetB(assetB);
- val.setFee(fee);
+ val.setAssetA(this.assetA);
+ val.setAssetB(this.assetB);
+ val.setFee(this.fee);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolDepositOp.java b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolDepositOp.java
index 1674692d1..c57457134 100644
--- a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolDepositOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolDepositOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -97,7 +102,7 @@ public static LiquidityPoolDepositOp decode(XdrDataInputStream stream) throws IO
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.liquidityPoolID, this.maxAmountA, this.maxAmountB, this.minPrice, this.maxPrice);
}
@@ -108,11 +113,35 @@ public boolean equals(Object object) {
}
LiquidityPoolDepositOp other = (LiquidityPoolDepositOp) object;
- return Objects.equal(this.liquidityPoolID, other.liquidityPoolID)
- && Objects.equal(this.maxAmountA, other.maxAmountA)
- && Objects.equal(this.maxAmountB, other.maxAmountB)
- && Objects.equal(this.minPrice, other.minPrice)
- && Objects.equal(this.maxPrice, other.maxPrice);
+ return Objects.equals(this.liquidityPoolID, other.liquidityPoolID)
+ && Objects.equals(this.maxAmountA, other.maxAmountA)
+ && Objects.equals(this.maxAmountB, other.maxAmountB)
+ && Objects.equals(this.minPrice, other.minPrice)
+ && Objects.equals(this.maxPrice, other.maxPrice);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LiquidityPoolDepositOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LiquidityPoolDepositOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -149,11 +178,11 @@ public Builder maxPrice(Price maxPrice) {
public LiquidityPoolDepositOp build() {
LiquidityPoolDepositOp val = new LiquidityPoolDepositOp();
- val.setLiquidityPoolID(liquidityPoolID);
- val.setMaxAmountA(maxAmountA);
- val.setMaxAmountB(maxAmountB);
- val.setMinPrice(minPrice);
- val.setMaxPrice(maxPrice);
+ val.setLiquidityPoolID(this.liquidityPoolID);
+ val.setMaxAmountA(this.maxAmountA);
+ val.setMaxAmountB(this.maxAmountB);
+ val.setMinPrice(this.minPrice);
+ val.setMaxPrice(this.maxPrice);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolDepositResult.java b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolDepositResult.java
index 03e3336fe..d6485dd21 100644
--- a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolDepositResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolDepositResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,13 @@
// {
// case LIQUIDITY_POOL_DEPOSIT_SUCCESS:
// void;
-// default:
+// case LIQUIDITY_POOL_DEPOSIT_MALFORMED:
+// case LIQUIDITY_POOL_DEPOSIT_NO_TRUST:
+// case LIQUIDITY_POOL_DEPOSIT_NOT_AUTHORIZED:
+// case LIQUIDITY_POOL_DEPOSIT_UNDERFUNDED:
+// case LIQUIDITY_POOL_DEPOSIT_LINE_FULL:
+// case LIQUIDITY_POOL_DEPOSIT_BAD_PRICE:
+// case LIQUIDITY_POOL_DEPOSIT_POOL_FULL:
// void;
// };
@@ -54,7 +65,13 @@ public static void encode(
switch (encodedLiquidityPoolDepositResult.getDiscriminant()) {
case LIQUIDITY_POOL_DEPOSIT_SUCCESS:
break;
- default:
+ case LIQUIDITY_POOL_DEPOSIT_MALFORMED:
+ case LIQUIDITY_POOL_DEPOSIT_NO_TRUST:
+ case LIQUIDITY_POOL_DEPOSIT_NOT_AUTHORIZED:
+ case LIQUIDITY_POOL_DEPOSIT_UNDERFUNDED:
+ case LIQUIDITY_POOL_DEPOSIT_LINE_FULL:
+ case LIQUIDITY_POOL_DEPOSIT_BAD_PRICE:
+ case LIQUIDITY_POOL_DEPOSIT_POOL_FULL:
break;
}
}
@@ -70,7 +87,13 @@ public static LiquidityPoolDepositResult decode(XdrDataInputStream stream) throw
switch (decodedLiquidityPoolDepositResult.getDiscriminant()) {
case LIQUIDITY_POOL_DEPOSIT_SUCCESS:
break;
- default:
+ case LIQUIDITY_POOL_DEPOSIT_MALFORMED:
+ case LIQUIDITY_POOL_DEPOSIT_NO_TRUST:
+ case LIQUIDITY_POOL_DEPOSIT_NOT_AUTHORIZED:
+ case LIQUIDITY_POOL_DEPOSIT_UNDERFUNDED:
+ case LIQUIDITY_POOL_DEPOSIT_LINE_FULL:
+ case LIQUIDITY_POOL_DEPOSIT_BAD_PRICE:
+ case LIQUIDITY_POOL_DEPOSIT_POOL_FULL:
break;
}
return decodedLiquidityPoolDepositResult;
@@ -78,7 +101,7 @@ public static LiquidityPoolDepositResult decode(XdrDataInputStream stream) throw
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -88,6 +111,30 @@ public boolean equals(Object object) {
}
LiquidityPoolDepositResult other = (LiquidityPoolDepositResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LiquidityPoolDepositResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LiquidityPoolDepositResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolDepositResultCode.java b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolDepositResultCode.java
index 78b762956..e409f7c29 100644
--- a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolDepositResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolDepositResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -80,4 +85,28 @@ public static void encode(XdrDataOutputStream stream, LiquidityPoolDepositResult
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LiquidityPoolDepositResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LiquidityPoolDepositResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolEntry.java b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolEntry.java
index 96d8bdf61..86d199b71 100644
--- a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolEntry.java
+++ b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolEntry.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -72,7 +77,7 @@ public static LiquidityPoolEntry decode(XdrDataInputStream stream) throws IOExce
@Override
public int hashCode() {
- return Objects.hashCode(this.liquidityPoolID, this.body);
+ return Objects.hash(this.liquidityPoolID, this.body);
}
@Override
@@ -82,8 +87,32 @@ public boolean equals(Object object) {
}
LiquidityPoolEntry other = (LiquidityPoolEntry) object;
- return Objects.equal(this.liquidityPoolID, other.liquidityPoolID)
- && Objects.equal(this.body, other.body);
+ return Objects.equals(this.liquidityPoolID, other.liquidityPoolID)
+ && Objects.equals(this.body, other.body);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LiquidityPoolEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LiquidityPoolEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -102,13 +131,13 @@ public Builder body(LiquidityPoolEntryBody body) {
public LiquidityPoolEntry build() {
LiquidityPoolEntry val = new LiquidityPoolEntry();
- val.setLiquidityPoolID(liquidityPoolID);
- val.setBody(body);
+ val.setLiquidityPoolID(this.liquidityPoolID);
+ val.setBody(this.body);
return val;
}
}
- public static class LiquidityPoolEntryBody {
+ public static class LiquidityPoolEntryBody implements XdrElement {
public LiquidityPoolEntryBody() {}
LiquidityPoolType type;
@@ -148,7 +177,7 @@ public Builder constantProduct(LiquidityPoolEntryConstantProduct constantProduct
public LiquidityPoolEntryBody build() {
LiquidityPoolEntryBody val = new LiquidityPoolEntryBody();
val.setDiscriminant(discriminant);
- val.setConstantProduct(constantProduct);
+ val.setConstantProduct(this.constantProduct);
return val;
}
}
@@ -186,7 +215,7 @@ public static LiquidityPoolEntryBody decode(XdrDataInputStream stream) throws IO
@Override
public int hashCode() {
- return Objects.hashCode(this.constantProduct, this.type);
+ return Objects.hash(this.constantProduct, this.type);
}
@Override
@@ -196,11 +225,35 @@ public boolean equals(Object object) {
}
LiquidityPoolEntryBody other = (LiquidityPoolEntryBody) object;
- return Objects.equal(this.constantProduct, other.constantProduct)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.constantProduct, other.constantProduct)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LiquidityPoolEntryBody fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LiquidityPoolEntryBody fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
- public static class LiquidityPoolEntryConstantProduct {
+ public static class LiquidityPoolEntryConstantProduct implements XdrElement {
public LiquidityPoolEntryConstantProduct() {}
private LiquidityPoolConstantProductParameters params;
@@ -284,7 +337,7 @@ public static LiquidityPoolEntryConstantProduct decode(XdrDataInputStream stream
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.params,
this.reserveA,
this.reserveB,
@@ -299,11 +352,36 @@ public boolean equals(Object object) {
}
LiquidityPoolEntryConstantProduct other = (LiquidityPoolEntryConstantProduct) object;
- return Objects.equal(this.params, other.params)
- && Objects.equal(this.reserveA, other.reserveA)
- && Objects.equal(this.reserveB, other.reserveB)
- && Objects.equal(this.totalPoolShares, other.totalPoolShares)
- && Objects.equal(this.poolSharesTrustLineCount, other.poolSharesTrustLineCount);
+ return Objects.equals(this.params, other.params)
+ && Objects.equals(this.reserveA, other.reserveA)
+ && Objects.equals(this.reserveB, other.reserveB)
+ && Objects.equals(this.totalPoolShares, other.totalPoolShares)
+ && Objects.equals(this.poolSharesTrustLineCount, other.poolSharesTrustLineCount);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LiquidityPoolEntryConstantProduct fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LiquidityPoolEntryConstantProduct fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -340,11 +418,11 @@ public Builder poolSharesTrustLineCount(Int64 poolSharesTrustLineCount) {
public LiquidityPoolEntryConstantProduct build() {
LiquidityPoolEntryConstantProduct val = new LiquidityPoolEntryConstantProduct();
- val.setParams(params);
- val.setReserveA(reserveA);
- val.setReserveB(reserveB);
- val.setTotalPoolShares(totalPoolShares);
- val.setPoolSharesTrustLineCount(poolSharesTrustLineCount);
+ val.setParams(this.params);
+ val.setReserveA(this.reserveA);
+ val.setReserveB(this.reserveB);
+ val.setTotalPoolShares(this.totalPoolShares);
+ val.setPoolSharesTrustLineCount(this.poolSharesTrustLineCount);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolParameters.java b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolParameters.java
index 10f0a14c2..e36a29f9f 100644
--- a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolParameters.java
+++ b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolParameters.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -55,7 +60,7 @@ public Builder constantProduct(LiquidityPoolConstantProductParameters constantPr
public LiquidityPoolParameters build() {
LiquidityPoolParameters val = new LiquidityPoolParameters();
val.setDiscriminant(discriminant);
- val.setConstantProduct(constantProduct);
+ val.setConstantProduct(this.constantProduct);
return val;
}
}
@@ -93,7 +98,7 @@ public static LiquidityPoolParameters decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(this.constantProduct, this.type);
+ return Objects.hash(this.constantProduct, this.type);
}
@Override
@@ -103,7 +108,31 @@ public boolean equals(Object object) {
}
LiquidityPoolParameters other = (LiquidityPoolParameters) object;
- return Objects.equal(this.constantProduct, other.constantProduct)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.constantProduct, other.constantProduct)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LiquidityPoolParameters fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LiquidityPoolParameters fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolType.java b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolType.java
index e5da1c921..f3b194758 100644
--- a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolType.java
+++ b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -44,4 +49,28 @@ public static void encode(XdrDataOutputStream stream, LiquidityPoolType value)
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LiquidityPoolType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LiquidityPoolType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolWithdrawOp.java b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolWithdrawOp.java
index b606a5248..e5e5412a9 100644
--- a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolWithdrawOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolWithdrawOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -84,7 +89,7 @@ public static LiquidityPoolWithdrawOp decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(this.liquidityPoolID, this.amount, this.minAmountA, this.minAmountB);
+ return Objects.hash(this.liquidityPoolID, this.amount, this.minAmountA, this.minAmountB);
}
@Override
@@ -94,10 +99,34 @@ public boolean equals(Object object) {
}
LiquidityPoolWithdrawOp other = (LiquidityPoolWithdrawOp) object;
- return Objects.equal(this.liquidityPoolID, other.liquidityPoolID)
- && Objects.equal(this.amount, other.amount)
- && Objects.equal(this.minAmountA, other.minAmountA)
- && Objects.equal(this.minAmountB, other.minAmountB);
+ return Objects.equals(this.liquidityPoolID, other.liquidityPoolID)
+ && Objects.equals(this.amount, other.amount)
+ && Objects.equals(this.minAmountA, other.minAmountA)
+ && Objects.equals(this.minAmountB, other.minAmountB);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LiquidityPoolWithdrawOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LiquidityPoolWithdrawOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -128,10 +157,10 @@ public Builder minAmountB(Int64 minAmountB) {
public LiquidityPoolWithdrawOp build() {
LiquidityPoolWithdrawOp val = new LiquidityPoolWithdrawOp();
- val.setLiquidityPoolID(liquidityPoolID);
- val.setAmount(amount);
- val.setMinAmountA(minAmountA);
- val.setMinAmountB(minAmountB);
+ val.setLiquidityPoolID(this.liquidityPoolID);
+ val.setAmount(this.amount);
+ val.setMinAmountA(this.minAmountA);
+ val.setMinAmountB(this.minAmountB);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolWithdrawResult.java b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolWithdrawResult.java
index eacda72b1..bbe4b663a 100644
--- a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolWithdrawResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolWithdrawResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,11 @@
// {
// case LIQUIDITY_POOL_WITHDRAW_SUCCESS:
// void;
-// default:
+// case LIQUIDITY_POOL_WITHDRAW_MALFORMED:
+// case LIQUIDITY_POOL_WITHDRAW_NO_TRUST:
+// case LIQUIDITY_POOL_WITHDRAW_UNDERFUNDED:
+// case LIQUIDITY_POOL_WITHDRAW_LINE_FULL:
+// case LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM:
// void;
// };
@@ -54,7 +63,11 @@ public static void encode(
switch (encodedLiquidityPoolWithdrawResult.getDiscriminant()) {
case LIQUIDITY_POOL_WITHDRAW_SUCCESS:
break;
- default:
+ case LIQUIDITY_POOL_WITHDRAW_MALFORMED:
+ case LIQUIDITY_POOL_WITHDRAW_NO_TRUST:
+ case LIQUIDITY_POOL_WITHDRAW_UNDERFUNDED:
+ case LIQUIDITY_POOL_WITHDRAW_LINE_FULL:
+ case LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM:
break;
}
}
@@ -71,7 +84,11 @@ public static LiquidityPoolWithdrawResult decode(XdrDataInputStream stream) thro
switch (decodedLiquidityPoolWithdrawResult.getDiscriminant()) {
case LIQUIDITY_POOL_WITHDRAW_SUCCESS:
break;
- default:
+ case LIQUIDITY_POOL_WITHDRAW_MALFORMED:
+ case LIQUIDITY_POOL_WITHDRAW_NO_TRUST:
+ case LIQUIDITY_POOL_WITHDRAW_UNDERFUNDED:
+ case LIQUIDITY_POOL_WITHDRAW_LINE_FULL:
+ case LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM:
break;
}
return decodedLiquidityPoolWithdrawResult;
@@ -79,7 +96,7 @@ public static LiquidityPoolWithdrawResult decode(XdrDataInputStream stream) thro
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -89,6 +106,30 @@ public boolean equals(Object object) {
}
LiquidityPoolWithdrawResult other = (LiquidityPoolWithdrawResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LiquidityPoolWithdrawResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LiquidityPoolWithdrawResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolWithdrawResultCode.java b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolWithdrawResultCode.java
index da511f93d..8af5e77fc 100644
--- a/src/main/java/org/stellar/sdk/xdr/LiquidityPoolWithdrawResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/LiquidityPoolWithdrawResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -71,4 +76,28 @@ public static void encode(XdrDataOutputStream stream, LiquidityPoolWithdrawResul
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static LiquidityPoolWithdrawResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static LiquidityPoolWithdrawResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageBuyOfferOp.java b/src/main/java/org/stellar/sdk/xdr/ManageBuyOfferOp.java
index ff5d36575..943b24f65 100644
--- a/src/main/java/org/stellar/sdk/xdr/ManageBuyOfferOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/ManageBuyOfferOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -99,7 +104,7 @@ public static ManageBuyOfferOp decode(XdrDataInputStream stream) throws IOExcept
@Override
public int hashCode() {
- return Objects.hashCode(this.selling, this.buying, this.buyAmount, this.price, this.offerID);
+ return Objects.hash(this.selling, this.buying, this.buyAmount, this.price, this.offerID);
}
@Override
@@ -109,11 +114,35 @@ public boolean equals(Object object) {
}
ManageBuyOfferOp other = (ManageBuyOfferOp) object;
- return Objects.equal(this.selling, other.selling)
- && Objects.equal(this.buying, other.buying)
- && Objects.equal(this.buyAmount, other.buyAmount)
- && Objects.equal(this.price, other.price)
- && Objects.equal(this.offerID, other.offerID);
+ return Objects.equals(this.selling, other.selling)
+ && Objects.equals(this.buying, other.buying)
+ && Objects.equals(this.buyAmount, other.buyAmount)
+ && Objects.equals(this.price, other.price)
+ && Objects.equals(this.offerID, other.offerID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ManageBuyOfferOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ManageBuyOfferOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -150,11 +179,11 @@ public Builder offerID(Int64 offerID) {
public ManageBuyOfferOp build() {
ManageBuyOfferOp val = new ManageBuyOfferOp();
- val.setSelling(selling);
- val.setBuying(buying);
- val.setBuyAmount(buyAmount);
- val.setPrice(price);
- val.setOfferID(offerID);
+ val.setSelling(this.selling);
+ val.setBuying(this.buying);
+ val.setBuyAmount(this.buyAmount);
+ val.setPrice(this.price);
+ val.setOfferID(this.offerID);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageBuyOfferResult.java b/src/main/java/org/stellar/sdk/xdr/ManageBuyOfferResult.java
index 9a6235d81..c04c7eae2 100644
--- a/src/main/java/org/stellar/sdk/xdr/ManageBuyOfferResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/ManageBuyOfferResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,18 @@
// {
// case MANAGE_BUY_OFFER_SUCCESS:
// ManageOfferSuccessResult success;
-// default:
+// case MANAGE_BUY_OFFER_MALFORMED:
+// case MANAGE_BUY_OFFER_SELL_NO_TRUST:
+// case MANAGE_BUY_OFFER_BUY_NO_TRUST:
+// case MANAGE_BUY_OFFER_SELL_NOT_AUTHORIZED:
+// case MANAGE_BUY_OFFER_BUY_NOT_AUTHORIZED:
+// case MANAGE_BUY_OFFER_LINE_FULL:
+// case MANAGE_BUY_OFFER_UNDERFUNDED:
+// case MANAGE_BUY_OFFER_CROSS_SELF:
+// case MANAGE_BUY_OFFER_SELL_NO_ISSUER:
+// case MANAGE_BUY_OFFER_BUY_NO_ISSUER:
+// case MANAGE_BUY_OFFER_NOT_FOUND:
+// case MANAGE_BUY_OFFER_LOW_RESERVE:
// void;
// };
@@ -57,7 +73,7 @@ public Builder success(ManageOfferSuccessResult success) {
public ManageBuyOfferResult build() {
ManageBuyOfferResult val = new ManageBuyOfferResult();
val.setDiscriminant(discriminant);
- val.setSuccess(success);
+ val.setSuccess(this.success);
return val;
}
}
@@ -72,7 +88,18 @@ public static void encode(
case MANAGE_BUY_OFFER_SUCCESS:
ManageOfferSuccessResult.encode(stream, encodedManageBuyOfferResult.success);
break;
- default:
+ case MANAGE_BUY_OFFER_MALFORMED:
+ case MANAGE_BUY_OFFER_SELL_NO_TRUST:
+ case MANAGE_BUY_OFFER_BUY_NO_TRUST:
+ case MANAGE_BUY_OFFER_SELL_NOT_AUTHORIZED:
+ case MANAGE_BUY_OFFER_BUY_NOT_AUTHORIZED:
+ case MANAGE_BUY_OFFER_LINE_FULL:
+ case MANAGE_BUY_OFFER_UNDERFUNDED:
+ case MANAGE_BUY_OFFER_CROSS_SELF:
+ case MANAGE_BUY_OFFER_SELL_NO_ISSUER:
+ case MANAGE_BUY_OFFER_BUY_NO_ISSUER:
+ case MANAGE_BUY_OFFER_NOT_FOUND:
+ case MANAGE_BUY_OFFER_LOW_RESERVE:
break;
}
}
@@ -89,7 +116,18 @@ public static ManageBuyOfferResult decode(XdrDataInputStream stream) throws IOEx
case MANAGE_BUY_OFFER_SUCCESS:
decodedManageBuyOfferResult.success = ManageOfferSuccessResult.decode(stream);
break;
- default:
+ case MANAGE_BUY_OFFER_MALFORMED:
+ case MANAGE_BUY_OFFER_SELL_NO_TRUST:
+ case MANAGE_BUY_OFFER_BUY_NO_TRUST:
+ case MANAGE_BUY_OFFER_SELL_NOT_AUTHORIZED:
+ case MANAGE_BUY_OFFER_BUY_NOT_AUTHORIZED:
+ case MANAGE_BUY_OFFER_LINE_FULL:
+ case MANAGE_BUY_OFFER_UNDERFUNDED:
+ case MANAGE_BUY_OFFER_CROSS_SELF:
+ case MANAGE_BUY_OFFER_SELL_NO_ISSUER:
+ case MANAGE_BUY_OFFER_BUY_NO_ISSUER:
+ case MANAGE_BUY_OFFER_NOT_FOUND:
+ case MANAGE_BUY_OFFER_LOW_RESERVE:
break;
}
return decodedManageBuyOfferResult;
@@ -97,7 +135,7 @@ public static ManageBuyOfferResult decode(XdrDataInputStream stream) throws IOEx
@Override
public int hashCode() {
- return Objects.hashCode(this.success, this.code);
+ return Objects.hash(this.success, this.code);
}
@Override
@@ -107,6 +145,30 @@ public boolean equals(Object object) {
}
ManageBuyOfferResult other = (ManageBuyOfferResult) object;
- return Objects.equal(this.success, other.success) && Objects.equal(this.code, other.code);
+ return Objects.equals(this.success, other.success) && Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ManageBuyOfferResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ManageBuyOfferResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageBuyOfferResultCode.java b/src/main/java/org/stellar/sdk/xdr/ManageBuyOfferResultCode.java
index f194c07d1..b6c171803 100644
--- a/src/main/java/org/stellar/sdk/xdr/ManageBuyOfferResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/ManageBuyOfferResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -99,4 +104,28 @@ public static void encode(XdrDataOutputStream stream, ManageBuyOfferResultCode v
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ManageBuyOfferResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ManageBuyOfferResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageDataOp.java b/src/main/java/org/stellar/sdk/xdr/ManageDataOp.java
index f75fc1565..77ab7e67c 100644
--- a/src/main/java/org/stellar/sdk/xdr/ManageDataOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/ManageDataOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -65,7 +70,7 @@ public static ManageDataOp decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(this.dataName, this.dataValue);
+ return Objects.hash(this.dataName, this.dataValue);
}
@Override
@@ -75,8 +80,32 @@ public boolean equals(Object object) {
}
ManageDataOp other = (ManageDataOp) object;
- return Objects.equal(this.dataName, other.dataName)
- && Objects.equal(this.dataValue, other.dataValue);
+ return Objects.equals(this.dataName, other.dataName)
+ && Objects.equals(this.dataValue, other.dataValue);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ManageDataOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ManageDataOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -95,8 +124,8 @@ public Builder dataValue(DataValue dataValue) {
public ManageDataOp build() {
ManageDataOp val = new ManageDataOp();
- val.setDataName(dataName);
- val.setDataValue(dataValue);
+ val.setDataName(this.dataName);
+ val.setDataValue(this.dataValue);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageDataResult.java b/src/main/java/org/stellar/sdk/xdr/ManageDataResult.java
index c53d336ad..910c8b379 100644
--- a/src/main/java/org/stellar/sdk/xdr/ManageDataResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/ManageDataResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,10 @@
// {
// case MANAGE_DATA_SUCCESS:
// void;
-// default:
+// case MANAGE_DATA_NOT_SUPPORTED_YET:
+// case MANAGE_DATA_NAME_NOT_FOUND:
+// case MANAGE_DATA_LOW_RESERVE:
+// case MANAGE_DATA_INVALID_NAME:
// void;
// };
@@ -53,7 +61,10 @@ public static void encode(XdrDataOutputStream stream, ManageDataResult encodedMa
switch (encodedManageDataResult.getDiscriminant()) {
case MANAGE_DATA_SUCCESS:
break;
- default:
+ case MANAGE_DATA_NOT_SUPPORTED_YET:
+ case MANAGE_DATA_NAME_NOT_FOUND:
+ case MANAGE_DATA_LOW_RESERVE:
+ case MANAGE_DATA_INVALID_NAME:
break;
}
}
@@ -69,7 +80,10 @@ public static ManageDataResult decode(XdrDataInputStream stream) throws IOExcept
switch (decodedManageDataResult.getDiscriminant()) {
case MANAGE_DATA_SUCCESS:
break;
- default:
+ case MANAGE_DATA_NOT_SUPPORTED_YET:
+ case MANAGE_DATA_NAME_NOT_FOUND:
+ case MANAGE_DATA_LOW_RESERVE:
+ case MANAGE_DATA_INVALID_NAME:
break;
}
return decodedManageDataResult;
@@ -77,7 +91,7 @@ public static ManageDataResult decode(XdrDataInputStream stream) throws IOExcept
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -87,6 +101,30 @@ public boolean equals(Object object) {
}
ManageDataResult other = (ManageDataResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ManageDataResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ManageDataResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageDataResultCode.java b/src/main/java/org/stellar/sdk/xdr/ManageDataResultCode.java
index 604498d20..8437b3885 100644
--- a/src/main/java/org/stellar/sdk/xdr/ManageDataResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/ManageDataResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -64,4 +69,28 @@ public static void encode(XdrDataOutputStream stream, ManageDataResultCode value
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ManageDataResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ManageDataResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageOfferEffect.java b/src/main/java/org/stellar/sdk/xdr/ManageOfferEffect.java
index 7336b8ae8..21e28766b 100644
--- a/src/main/java/org/stellar/sdk/xdr/ManageOfferEffect.java
+++ b/src/main/java/org/stellar/sdk/xdr/ManageOfferEffect.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -52,4 +57,28 @@ public static void encode(XdrDataOutputStream stream, ManageOfferEffect value)
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ManageOfferEffect fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ManageOfferEffect fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageOfferOp.java b/src/main/java/org/stellar/sdk/xdr/ManageOfferOp.java
deleted file mode 100644
index 722c4b549..000000000
--- a/src/main/java/org/stellar/sdk/xdr/ManageOfferOp.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// Automatically generated by xdrgen
-// DO NOT EDIT or your changes may be overwritten
-
-package org.stellar.sdk.xdr;
-
-import java.io.IOException;
-
-// === xdr source ============================================================
-
-// struct ManageOfferOp
-// {
-// Asset selling;
-// Asset buying;
-// int64 amount; // amount being sold. if set to 0, delete the offer
-// Price price; // price of thing being sold in terms of what you are buying
-//
-// // 0=create a new offer, otherwise edit an existing offer
-// uint64 offerID;
-// };
-
-// ===========================================================================
-public class ManageOfferOp {
- public ManageOfferOp() {}
-
- private Asset selling;
-
- public Asset getSelling() {
- return this.selling;
- }
-
- public void setSelling(Asset value) {
- this.selling = value;
- }
-
- private Asset buying;
-
- public Asset getBuying() {
- return this.buying;
- }
-
- public void setBuying(Asset value) {
- this.buying = value;
- }
-
- private Int64 amount;
-
- public Int64 getAmount() {
- return this.amount;
- }
-
- public void setAmount(Int64 value) {
- this.amount = value;
- }
-
- private Price price;
-
- public Price getPrice() {
- return this.price;
- }
-
- public void setPrice(Price value) {
- this.price = value;
- }
-
- private Uint64 offerID;
-
- public Uint64 getOfferID() {
- return this.offerID;
- }
-
- public void setOfferID(Uint64 value) {
- this.offerID = value;
- }
-
- public static void encode(XdrDataOutputStream stream, ManageOfferOp encodedManageOfferOp)
- throws IOException {
- Asset.encode(stream, encodedManageOfferOp.selling);
- Asset.encode(stream, encodedManageOfferOp.buying);
- Int64.encode(stream, encodedManageOfferOp.amount);
- Price.encode(stream, encodedManageOfferOp.price);
- Uint64.encode(stream, encodedManageOfferOp.offerID);
- }
-
- public static ManageOfferOp decode(XdrDataInputStream stream) throws IOException {
- ManageOfferOp decodedManageOfferOp = new ManageOfferOp();
- decodedManageOfferOp.selling = Asset.decode(stream);
- decodedManageOfferOp.buying = Asset.decode(stream);
- decodedManageOfferOp.amount = Int64.decode(stream);
- decodedManageOfferOp.price = Price.decode(stream);
- decodedManageOfferOp.offerID = Uint64.decode(stream);
- return decodedManageOfferOp;
- }
-}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageOfferResult.java b/src/main/java/org/stellar/sdk/xdr/ManageOfferResult.java
deleted file mode 100644
index 48f1a5ba8..000000000
--- a/src/main/java/org/stellar/sdk/xdr/ManageOfferResult.java
+++ /dev/null
@@ -1,67 +0,0 @@
-// Automatically generated by xdrgen
-// DO NOT EDIT or your changes may be overwritten
-
-package org.stellar.sdk.xdr;
-
-import java.io.IOException;
-
-// === xdr source ============================================================
-
-// union ManageOfferResult switch (ManageOfferResultCode code)
-// {
-// case MANAGE_OFFER_SUCCESS:
-// ManageOfferSuccessResult success;
-// default:
-// void;
-// };
-
-// ===========================================================================
-public class ManageOfferResult {
- public ManageOfferResult() {}
-
- ManageOfferResultCode code;
-
- public ManageOfferResultCode getDiscriminant() {
- return this.code;
- }
-
- public void setDiscriminant(ManageOfferResultCode value) {
- this.code = value;
- }
-
- private ManageOfferSuccessResult success;
-
- public ManageOfferSuccessResult getSuccess() {
- return this.success;
- }
-
- public void setSuccess(ManageOfferSuccessResult value) {
- this.success = value;
- }
-
- public static void encode(XdrDataOutputStream stream, ManageOfferResult encodedManageOfferResult)
- throws IOException {
- stream.writeInt(encodedManageOfferResult.getDiscriminant().getValue());
- switch (encodedManageOfferResult.getDiscriminant()) {
- case MANAGE_OFFER_SUCCESS:
- ManageOfferSuccessResult.encode(stream, encodedManageOfferResult.success);
- break;
- default:
- break;
- }
- }
-
- public static ManageOfferResult decode(XdrDataInputStream stream) throws IOException {
- ManageOfferResult decodedManageOfferResult = new ManageOfferResult();
- ManageOfferResultCode discriminant = ManageOfferResultCode.decode(stream);
- decodedManageOfferResult.setDiscriminant(discriminant);
- switch (decodedManageOfferResult.getDiscriminant()) {
- case MANAGE_OFFER_SUCCESS:
- decodedManageOfferResult.success = ManageOfferSuccessResult.decode(stream);
- break;
- default:
- break;
- }
- return decodedManageOfferResult;
- }
-}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageOfferResultCode.java b/src/main/java/org/stellar/sdk/xdr/ManageOfferResultCode.java
deleted file mode 100644
index bc2b3652b..000000000
--- a/src/main/java/org/stellar/sdk/xdr/ManageOfferResultCode.java
+++ /dev/null
@@ -1,96 +0,0 @@
-// Automatically generated by xdrgen
-// DO NOT EDIT or your changes may be overwritten
-
-package org.stellar.sdk.xdr;
-
-import java.io.IOException;
-
-// === xdr source ============================================================
-
-// enum ManageOfferResultCode
-// {
-// // codes considered as "success" for the operation
-// MANAGE_OFFER_SUCCESS = 0,
-//
-// // codes considered as "failure" for the operation
-// MANAGE_OFFER_MALFORMED = -1, // generated offer would be invalid
-// MANAGE_OFFER_SELL_NO_TRUST = -2, // no trust line for what we're selling
-// MANAGE_OFFER_BUY_NO_TRUST = -3, // no trust line for what we're buying
-// MANAGE_OFFER_SELL_NOT_AUTHORIZED = -4, // not authorized to sell
-// MANAGE_OFFER_BUY_NOT_AUTHORIZED = -5, // not authorized to buy
-// MANAGE_OFFER_LINE_FULL = -6, // can't receive more of what it's buying
-// MANAGE_OFFER_UNDERFUNDED = -7, // doesn't hold what it's trying to sell
-// MANAGE_OFFER_CROSS_SELF = -8, // would cross an offer from the same user
-// MANAGE_OFFER_SELL_NO_ISSUER = -9, // no issuer for what we're selling
-// MANAGE_OFFER_BUY_NO_ISSUER = -10, // no issuer for what we're buying
-//
-// // update errors
-// MANAGE_OFFER_NOT_FOUND = -11, // offerID does not match an existing offer
-//
-// MANAGE_OFFER_LOW_RESERVE = -12 // not enough funds to create a new Offer
-// };
-
-// ===========================================================================
-public enum ManageOfferResultCode {
- MANAGE_OFFER_SUCCESS(0),
- MANAGE_OFFER_MALFORMED(-1),
- MANAGE_OFFER_SELL_NO_TRUST(-2),
- MANAGE_OFFER_BUY_NO_TRUST(-3),
- MANAGE_OFFER_SELL_NOT_AUTHORIZED(-4),
- MANAGE_OFFER_BUY_NOT_AUTHORIZED(-5),
- MANAGE_OFFER_LINE_FULL(-6),
- MANAGE_OFFER_UNDERFUNDED(-7),
- MANAGE_OFFER_CROSS_SELF(-8),
- MANAGE_OFFER_SELL_NO_ISSUER(-9),
- MANAGE_OFFER_BUY_NO_ISSUER(-10),
- MANAGE_OFFER_NOT_FOUND(-11),
- MANAGE_OFFER_LOW_RESERVE(-12),
- ;
- private int mValue;
-
- ManageOfferResultCode(int value) {
- mValue = value;
- }
-
- public int getValue() {
- return mValue;
- }
-
- static ManageOfferResultCode decode(XdrDataInputStream stream) throws IOException {
- int value = stream.readInt();
- switch (value) {
- case 0:
- return MANAGE_OFFER_SUCCESS;
- case -1:
- return MANAGE_OFFER_MALFORMED;
- case -2:
- return MANAGE_OFFER_SELL_NO_TRUST;
- case -3:
- return MANAGE_OFFER_BUY_NO_TRUST;
- case -4:
- return MANAGE_OFFER_SELL_NOT_AUTHORIZED;
- case -5:
- return MANAGE_OFFER_BUY_NOT_AUTHORIZED;
- case -6:
- return MANAGE_OFFER_LINE_FULL;
- case -7:
- return MANAGE_OFFER_UNDERFUNDED;
- case -8:
- return MANAGE_OFFER_CROSS_SELF;
- case -9:
- return MANAGE_OFFER_SELL_NO_ISSUER;
- case -10:
- return MANAGE_OFFER_BUY_NO_ISSUER;
- case -11:
- return MANAGE_OFFER_NOT_FOUND;
- case -12:
- return MANAGE_OFFER_LOW_RESERVE;
- default:
- throw new RuntimeException("Unknown enum value: " + value);
- }
- }
-
- static void encode(XdrDataOutputStream stream, ManageOfferResultCode value) throws IOException {
- stream.writeInt(value.getValue());
- }
-}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageOfferSuccessResult.java b/src/main/java/org/stellar/sdk/xdr/ManageOfferSuccessResult.java
index 48d279ef3..0a916fc24 100644
--- a/src/main/java/org/stellar/sdk/xdr/ManageOfferSuccessResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/ManageOfferSuccessResult.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -19,7 +24,7 @@
// case MANAGE_OFFER_CREATED:
// case MANAGE_OFFER_UPDATED:
// OfferEntry offer;
-// default:
+// case MANAGE_OFFER_DELETED:
// void;
// }
// offer;
@@ -77,7 +82,7 @@ public static ManageOfferSuccessResult decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(Arrays.hashCode(this.offersClaimed), this.offer);
+ return Objects.hash(Arrays.hashCode(this.offersClaimed), this.offer);
}
@Override
@@ -88,7 +93,31 @@ public boolean equals(Object object) {
ManageOfferSuccessResult other = (ManageOfferSuccessResult) object;
return Arrays.equals(this.offersClaimed, other.offersClaimed)
- && Objects.equal(this.offer, other.offer);
+ && Objects.equals(this.offer, other.offer);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ManageOfferSuccessResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ManageOfferSuccessResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -107,13 +136,13 @@ public Builder offer(ManageOfferSuccessResultOffer offer) {
public ManageOfferSuccessResult build() {
ManageOfferSuccessResult val = new ManageOfferSuccessResult();
- val.setOffersClaimed(offersClaimed);
- val.setOffer(offer);
+ val.setOffersClaimed(this.offersClaimed);
+ val.setOffer(this.offer);
return val;
}
}
- public static class ManageOfferSuccessResultOffer {
+ public static class ManageOfferSuccessResultOffer implements XdrElement {
public ManageOfferSuccessResultOffer() {}
ManageOfferEffect effect;
@@ -153,7 +182,7 @@ public Builder offer(OfferEntry offer) {
public ManageOfferSuccessResultOffer build() {
ManageOfferSuccessResultOffer val = new ManageOfferSuccessResultOffer();
val.setDiscriminant(discriminant);
- val.setOffer(offer);
+ val.setOffer(this.offer);
return val;
}
}
@@ -170,7 +199,7 @@ public static void encode(
case MANAGE_OFFER_UPDATED:
OfferEntry.encode(stream, encodedManageOfferSuccessResultOffer.offer);
break;
- default:
+ case MANAGE_OFFER_DELETED:
break;
}
}
@@ -190,7 +219,7 @@ public static ManageOfferSuccessResultOffer decode(XdrDataInputStream stream)
case MANAGE_OFFER_UPDATED:
decodedManageOfferSuccessResultOffer.offer = OfferEntry.decode(stream);
break;
- default:
+ case MANAGE_OFFER_DELETED:
break;
}
return decodedManageOfferSuccessResultOffer;
@@ -198,7 +227,7 @@ public static ManageOfferSuccessResultOffer decode(XdrDataInputStream stream)
@Override
public int hashCode() {
- return Objects.hashCode(this.offer, this.effect);
+ return Objects.hash(this.offer, this.effect);
}
@Override
@@ -208,7 +237,31 @@ public boolean equals(Object object) {
}
ManageOfferSuccessResultOffer other = (ManageOfferSuccessResultOffer) object;
- return Objects.equal(this.offer, other.offer) && Objects.equal(this.effect, other.effect);
+ return Objects.equals(this.offer, other.offer) && Objects.equals(this.effect, other.effect);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ManageOfferSuccessResultOffer fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ManageOfferSuccessResultOffer fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageSellOfferOp.java b/src/main/java/org/stellar/sdk/xdr/ManageSellOfferOp.java
index 7b4f03778..f6808c0dd 100644
--- a/src/main/java/org/stellar/sdk/xdr/ManageSellOfferOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/ManageSellOfferOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -98,7 +103,7 @@ public static ManageSellOfferOp decode(XdrDataInputStream stream) throws IOExcep
@Override
public int hashCode() {
- return Objects.hashCode(this.selling, this.buying, this.amount, this.price, this.offerID);
+ return Objects.hash(this.selling, this.buying, this.amount, this.price, this.offerID);
}
@Override
@@ -108,11 +113,35 @@ public boolean equals(Object object) {
}
ManageSellOfferOp other = (ManageSellOfferOp) object;
- return Objects.equal(this.selling, other.selling)
- && Objects.equal(this.buying, other.buying)
- && Objects.equal(this.amount, other.amount)
- && Objects.equal(this.price, other.price)
- && Objects.equal(this.offerID, other.offerID);
+ return Objects.equals(this.selling, other.selling)
+ && Objects.equals(this.buying, other.buying)
+ && Objects.equals(this.amount, other.amount)
+ && Objects.equals(this.price, other.price)
+ && Objects.equals(this.offerID, other.offerID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ManageSellOfferOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ManageSellOfferOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -149,11 +178,11 @@ public Builder offerID(Int64 offerID) {
public ManageSellOfferOp build() {
ManageSellOfferOp val = new ManageSellOfferOp();
- val.setSelling(selling);
- val.setBuying(buying);
- val.setAmount(amount);
- val.setPrice(price);
- val.setOfferID(offerID);
+ val.setSelling(this.selling);
+ val.setBuying(this.buying);
+ val.setAmount(this.amount);
+ val.setPrice(this.price);
+ val.setOfferID(this.offerID);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageSellOfferResult.java b/src/main/java/org/stellar/sdk/xdr/ManageSellOfferResult.java
index 92276b1cf..69475ace2 100644
--- a/src/main/java/org/stellar/sdk/xdr/ManageSellOfferResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/ManageSellOfferResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,18 @@
// {
// case MANAGE_SELL_OFFER_SUCCESS:
// ManageOfferSuccessResult success;
-// default:
+// case MANAGE_SELL_OFFER_MALFORMED:
+// case MANAGE_SELL_OFFER_SELL_NO_TRUST:
+// case MANAGE_SELL_OFFER_BUY_NO_TRUST:
+// case MANAGE_SELL_OFFER_SELL_NOT_AUTHORIZED:
+// case MANAGE_SELL_OFFER_BUY_NOT_AUTHORIZED:
+// case MANAGE_SELL_OFFER_LINE_FULL:
+// case MANAGE_SELL_OFFER_UNDERFUNDED:
+// case MANAGE_SELL_OFFER_CROSS_SELF:
+// case MANAGE_SELL_OFFER_SELL_NO_ISSUER:
+// case MANAGE_SELL_OFFER_BUY_NO_ISSUER:
+// case MANAGE_SELL_OFFER_NOT_FOUND:
+// case MANAGE_SELL_OFFER_LOW_RESERVE:
// void;
// };
@@ -57,7 +73,7 @@ public Builder success(ManageOfferSuccessResult success) {
public ManageSellOfferResult build() {
ManageSellOfferResult val = new ManageSellOfferResult();
val.setDiscriminant(discriminant);
- val.setSuccess(success);
+ val.setSuccess(this.success);
return val;
}
}
@@ -72,7 +88,18 @@ public static void encode(
case MANAGE_SELL_OFFER_SUCCESS:
ManageOfferSuccessResult.encode(stream, encodedManageSellOfferResult.success);
break;
- default:
+ case MANAGE_SELL_OFFER_MALFORMED:
+ case MANAGE_SELL_OFFER_SELL_NO_TRUST:
+ case MANAGE_SELL_OFFER_BUY_NO_TRUST:
+ case MANAGE_SELL_OFFER_SELL_NOT_AUTHORIZED:
+ case MANAGE_SELL_OFFER_BUY_NOT_AUTHORIZED:
+ case MANAGE_SELL_OFFER_LINE_FULL:
+ case MANAGE_SELL_OFFER_UNDERFUNDED:
+ case MANAGE_SELL_OFFER_CROSS_SELF:
+ case MANAGE_SELL_OFFER_SELL_NO_ISSUER:
+ case MANAGE_SELL_OFFER_BUY_NO_ISSUER:
+ case MANAGE_SELL_OFFER_NOT_FOUND:
+ case MANAGE_SELL_OFFER_LOW_RESERVE:
break;
}
}
@@ -89,7 +116,18 @@ public static ManageSellOfferResult decode(XdrDataInputStream stream) throws IOE
case MANAGE_SELL_OFFER_SUCCESS:
decodedManageSellOfferResult.success = ManageOfferSuccessResult.decode(stream);
break;
- default:
+ case MANAGE_SELL_OFFER_MALFORMED:
+ case MANAGE_SELL_OFFER_SELL_NO_TRUST:
+ case MANAGE_SELL_OFFER_BUY_NO_TRUST:
+ case MANAGE_SELL_OFFER_SELL_NOT_AUTHORIZED:
+ case MANAGE_SELL_OFFER_BUY_NOT_AUTHORIZED:
+ case MANAGE_SELL_OFFER_LINE_FULL:
+ case MANAGE_SELL_OFFER_UNDERFUNDED:
+ case MANAGE_SELL_OFFER_CROSS_SELF:
+ case MANAGE_SELL_OFFER_SELL_NO_ISSUER:
+ case MANAGE_SELL_OFFER_BUY_NO_ISSUER:
+ case MANAGE_SELL_OFFER_NOT_FOUND:
+ case MANAGE_SELL_OFFER_LOW_RESERVE:
break;
}
return decodedManageSellOfferResult;
@@ -97,7 +135,7 @@ public static ManageSellOfferResult decode(XdrDataInputStream stream) throws IOE
@Override
public int hashCode() {
- return Objects.hashCode(this.success, this.code);
+ return Objects.hash(this.success, this.code);
}
@Override
@@ -107,6 +145,30 @@ public boolean equals(Object object) {
}
ManageSellOfferResult other = (ManageSellOfferResult) object;
- return Objects.equal(this.success, other.success) && Objects.equal(this.code, other.code);
+ return Objects.equals(this.success, other.success) && Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ManageSellOfferResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ManageSellOfferResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageSellOfferResultCode.java b/src/main/java/org/stellar/sdk/xdr/ManageSellOfferResultCode.java
index e046d489c..bfedd49fc 100644
--- a/src/main/java/org/stellar/sdk/xdr/ManageSellOfferResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/ManageSellOfferResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -102,4 +107,28 @@ public static void encode(XdrDataOutputStream stream, ManageSellOfferResultCode
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ManageSellOfferResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ManageSellOfferResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Memo.java b/src/main/java/org/stellar/sdk/xdr/Memo.java
index ff100d7a8..f7a402d41 100644
--- a/src/main/java/org/stellar/sdk/xdr/Memo.java
+++ b/src/main/java/org/stellar/sdk/xdr/Memo.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -111,10 +116,10 @@ public Builder retHash(Hash retHash) {
public Memo build() {
Memo val = new Memo();
val.setDiscriminant(discriminant);
- val.setText(text);
- val.setId(id);
- val.setHash(hash);
- val.setRetHash(retHash);
+ val.setText(this.text);
+ val.setId(this.id);
+ val.setHash(this.hash);
+ val.setRetHash(this.retHash);
return val;
}
}
@@ -170,7 +175,7 @@ public static Memo decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.text, this.id, this.hash, this.retHash, this.type);
+ return Objects.hash(this.text, this.id, this.hash, this.retHash, this.type);
}
@Override
@@ -180,10 +185,34 @@ public boolean equals(Object object) {
}
Memo other = (Memo) object;
- return Objects.equal(this.text, other.text)
- && Objects.equal(this.id, other.id)
- && Objects.equal(this.hash, other.hash)
- && Objects.equal(this.retHash, other.retHash)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.text, other.text)
+ && Objects.equals(this.id, other.id)
+ && Objects.equals(this.hash, other.hash)
+ && Objects.equals(this.retHash, other.retHash)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Memo fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Memo fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/MemoType.java b/src/main/java/org/stellar/sdk/xdr/MemoType.java
index 7b5eba6d2..f4f32e448 100644
--- a/src/main/java/org/stellar/sdk/xdr/MemoType.java
+++ b/src/main/java/org/stellar/sdk/xdr/MemoType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -59,4 +64,28 @@ public static void encode(XdrDataOutputStream stream, MemoType value) throws IOE
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static MemoType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static MemoType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/MessageType.java b/src/main/java/org/stellar/sdk/xdr/MessageType.java
index 8aeba242b..d93ea3c47 100644
--- a/src/main/java/org/stellar/sdk/xdr/MessageType.java
+++ b/src/main/java/org/stellar/sdk/xdr/MessageType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -18,6 +23,7 @@
//
// GET_TX_SET = 6, // gets a particular txset by hash
// TX_SET = 7,
+// GENERALIZED_TX_SET = 17,
//
// TRANSACTION = 8, // pass on a tx you have heard about
//
@@ -33,7 +39,11 @@
// SURVEY_REQUEST = 14,
// SURVEY_RESPONSE = 15,
//
-// SEND_MORE = 16
+// SEND_MORE = 16,
+// SEND_MORE_EXTENDED = 20,
+//
+// FLOOD_ADVERT = 18,
+// FLOOD_DEMAND = 19
// };
// ===========================================================================
@@ -45,6 +55,7 @@ public enum MessageType implements XdrElement {
PEERS(5),
GET_TX_SET(6),
TX_SET(7),
+ GENERALIZED_TX_SET(17),
TRANSACTION(8),
GET_SCP_QUORUMSET(9),
SCP_QUORUMSET(10),
@@ -54,6 +65,9 @@ public enum MessageType implements XdrElement {
SURVEY_REQUEST(14),
SURVEY_RESPONSE(15),
SEND_MORE(16),
+ SEND_MORE_EXTENDED(20),
+ FLOOD_ADVERT(18),
+ FLOOD_DEMAND(19),
;
private int mValue;
@@ -82,6 +96,8 @@ public static MessageType decode(XdrDataInputStream stream) throws IOException {
return GET_TX_SET;
case 7:
return TX_SET;
+ case 17:
+ return GENERALIZED_TX_SET;
case 8:
return TRANSACTION;
case 9:
@@ -100,6 +116,12 @@ public static MessageType decode(XdrDataInputStream stream) throws IOException {
return SURVEY_RESPONSE;
case 16:
return SEND_MORE;
+ case 20:
+ return SEND_MORE_EXTENDED;
+ case 18:
+ return FLOOD_ADVERT;
+ case 19:
+ return FLOOD_DEMAND;
default:
throw new RuntimeException("Unknown enum value: " + value);
}
@@ -112,4 +134,28 @@ public static void encode(XdrDataOutputStream stream, MessageType value) throws
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static MessageType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static MessageType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/MuxedAccount.java b/src/main/java/org/stellar/sdk/xdr/MuxedAccount.java
index 598738b28..d3f2351ea 100644
--- a/src/main/java/org/stellar/sdk/xdr/MuxedAccount.java
+++ b/src/main/java/org/stellar/sdk/xdr/MuxedAccount.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -77,8 +82,8 @@ public Builder med25519(MuxedAccountMed25519 med25519) {
public MuxedAccount build() {
MuxedAccount val = new MuxedAccount();
val.setDiscriminant(discriminant);
- val.setEd25519(ed25519);
- val.setMed25519(med25519);
+ val.setEd25519(this.ed25519);
+ val.setMed25519(this.med25519);
return val;
}
}
@@ -119,7 +124,7 @@ public static MuxedAccount decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(this.ed25519, this.med25519, this.type);
+ return Objects.hash(this.ed25519, this.med25519, this.type);
}
@Override
@@ -129,12 +134,36 @@ public boolean equals(Object object) {
}
MuxedAccount other = (MuxedAccount) object;
- return Objects.equal(this.ed25519, other.ed25519)
- && Objects.equal(this.med25519, other.med25519)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.ed25519, other.ed25519)
+ && Objects.equals(this.med25519, other.med25519)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static MuxedAccount fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static MuxedAccount fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
- public static class MuxedAccountMed25519 {
+ public static class MuxedAccountMed25519 implements XdrElement {
public MuxedAccountMed25519() {}
private Uint64 id;
@@ -177,7 +206,7 @@ public static MuxedAccountMed25519 decode(XdrDataInputStream stream) throws IOEx
@Override
public int hashCode() {
- return Objects.hashCode(this.id, this.ed25519);
+ return Objects.hash(this.id, this.ed25519);
}
@Override
@@ -187,7 +216,31 @@ public boolean equals(Object object) {
}
MuxedAccountMed25519 other = (MuxedAccountMed25519) object;
- return Objects.equal(this.id, other.id) && Objects.equal(this.ed25519, other.ed25519);
+ return Objects.equals(this.id, other.id) && Objects.equals(this.ed25519, other.ed25519);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static MuxedAccountMed25519 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static MuxedAccountMed25519 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -206,8 +259,8 @@ public Builder ed25519(Uint256 ed25519) {
public MuxedAccountMed25519 build() {
MuxedAccountMed25519 val = new MuxedAccountMed25519();
- val.setId(id);
- val.setEd25519(ed25519);
+ val.setId(this.id);
+ val.setEd25519(this.ed25519);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/NodeID.java b/src/main/java/org/stellar/sdk/xdr/NodeID.java
index 0f1a74096..37c9de666 100644
--- a/src/main/java/org/stellar/sdk/xdr/NodeID.java
+++ b/src/main/java/org/stellar/sdk/xdr/NodeID.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -44,7 +49,7 @@ public static NodeID decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.NodeID);
+ return Objects.hash(this.NodeID);
}
@Override
@@ -54,6 +59,30 @@ public boolean equals(Object object) {
}
NodeID other = (NodeID) object;
- return Objects.equal(this.NodeID, other.NodeID);
+ return Objects.equals(this.NodeID, other.NodeID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static NodeID fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static NodeID fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/OfferEntry.java b/src/main/java/org/stellar/sdk/xdr/OfferEntry.java
index d499d84e6..578ab2d84 100644
--- a/src/main/java/org/stellar/sdk/xdr/OfferEntry.java
+++ b/src/main/java/org/stellar/sdk/xdr/OfferEntry.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -148,7 +153,7 @@ public static OfferEntry decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.sellerID,
this.offerID,
this.selling,
@@ -166,14 +171,38 @@ public boolean equals(Object object) {
}
OfferEntry other = (OfferEntry) object;
- return Objects.equal(this.sellerID, other.sellerID)
- && Objects.equal(this.offerID, other.offerID)
- && Objects.equal(this.selling, other.selling)
- && Objects.equal(this.buying, other.buying)
- && Objects.equal(this.amount, other.amount)
- && Objects.equal(this.price, other.price)
- && Objects.equal(this.flags, other.flags)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.sellerID, other.sellerID)
+ && Objects.equals(this.offerID, other.offerID)
+ && Objects.equals(this.selling, other.selling)
+ && Objects.equals(this.buying, other.buying)
+ && Objects.equals(this.amount, other.amount)
+ && Objects.equals(this.price, other.price)
+ && Objects.equals(this.flags, other.flags)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static OfferEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static OfferEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -228,19 +257,19 @@ public Builder ext(OfferEntryExt ext) {
public OfferEntry build() {
OfferEntry val = new OfferEntry();
- val.setSellerID(sellerID);
- val.setOfferID(offerID);
- val.setSelling(selling);
- val.setBuying(buying);
- val.setAmount(amount);
- val.setPrice(price);
- val.setFlags(flags);
- val.setExt(ext);
+ val.setSellerID(this.sellerID);
+ val.setOfferID(this.offerID);
+ val.setSelling(this.selling);
+ val.setBuying(this.buying);
+ val.setAmount(this.amount);
+ val.setPrice(this.price);
+ val.setFlags(this.flags);
+ val.setExt(this.ext);
return val;
}
}
- public static class OfferEntryExt {
+ public static class OfferEntryExt implements XdrElement {
public OfferEntryExt() {}
Integer v;
@@ -296,7 +325,7 @@ public static OfferEntryExt decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -306,7 +335,31 @@ public boolean equals(Object object) {
}
OfferEntryExt other = (OfferEntryExt) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static OfferEntryExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static OfferEntryExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/OfferEntryFlags.java b/src/main/java/org/stellar/sdk/xdr/OfferEntryFlags.java
index 3283c91b2..07c112686 100644
--- a/src/main/java/org/stellar/sdk/xdr/OfferEntryFlags.java
+++ b/src/main/java/org/stellar/sdk/xdr/OfferEntryFlags.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -45,4 +50,28 @@ public static void encode(XdrDataOutputStream stream, OfferEntryFlags value) thr
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static OfferEntryFlags fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static OfferEntryFlags fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Operation.java b/src/main/java/org/stellar/sdk/xdr/Operation.java
index 8c0aadad1..ba5d805f8 100644
--- a/src/main/java/org/stellar/sdk/xdr/Operation.java
+++ b/src/main/java/org/stellar/sdk/xdr/Operation.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -65,6 +70,12 @@
// LiquidityPoolDepositOp liquidityPoolDepositOp;
// case LIQUIDITY_POOL_WITHDRAW:
// LiquidityPoolWithdrawOp liquidityPoolWithdrawOp;
+// case INVOKE_HOST_FUNCTION:
+// InvokeHostFunctionOp invokeHostFunctionOp;
+// case BUMP_FOOTPRINT_EXPIRATION:
+// BumpFootprintExpirationOp bumpFootprintExpirationOp;
+// case RESTORE_FOOTPRINT:
+// RestoreFootprintOp restoreFootprintOp;
// }
// body;
// };
@@ -120,7 +131,7 @@ public static Operation decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.sourceAccount, this.body);
+ return Objects.hash(this.sourceAccount, this.body);
}
@Override
@@ -130,8 +141,32 @@ public boolean equals(Object object) {
}
Operation other = (Operation) object;
- return Objects.equal(this.sourceAccount, other.sourceAccount)
- && Objects.equal(this.body, other.body);
+ return Objects.equals(this.sourceAccount, other.sourceAccount)
+ && Objects.equals(this.body, other.body);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Operation fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Operation fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -150,13 +185,13 @@ public Builder body(OperationBody body) {
public Operation build() {
Operation val = new Operation();
- val.setSourceAccount(sourceAccount);
- val.setBody(body);
+ val.setSourceAccount(this.sourceAccount);
+ val.setBody(this.body);
return val;
}
}
- public static class OperationBody {
+ public static class OperationBody implements XdrElement {
public OperationBody() {}
OperationType type;
@@ -389,6 +424,36 @@ public void setLiquidityPoolWithdrawOp(LiquidityPoolWithdrawOp value) {
this.liquidityPoolWithdrawOp = value;
}
+ private InvokeHostFunctionOp invokeHostFunctionOp;
+
+ public InvokeHostFunctionOp getInvokeHostFunctionOp() {
+ return this.invokeHostFunctionOp;
+ }
+
+ public void setInvokeHostFunctionOp(InvokeHostFunctionOp value) {
+ this.invokeHostFunctionOp = value;
+ }
+
+ private BumpFootprintExpirationOp bumpFootprintExpirationOp;
+
+ public BumpFootprintExpirationOp getBumpFootprintExpirationOp() {
+ return this.bumpFootprintExpirationOp;
+ }
+
+ public void setBumpFootprintExpirationOp(BumpFootprintExpirationOp value) {
+ this.bumpFootprintExpirationOp = value;
+ }
+
+ private RestoreFootprintOp restoreFootprintOp;
+
+ public RestoreFootprintOp getRestoreFootprintOp() {
+ return this.restoreFootprintOp;
+ }
+
+ public void setRestoreFootprintOp(RestoreFootprintOp value) {
+ this.restoreFootprintOp = value;
+ }
+
public static final class Builder {
private OperationType discriminant;
private CreateAccountOp createAccountOp;
@@ -413,6 +478,9 @@ public static final class Builder {
private SetTrustLineFlagsOp setTrustLineFlagsOp;
private LiquidityPoolDepositOp liquidityPoolDepositOp;
private LiquidityPoolWithdrawOp liquidityPoolWithdrawOp;
+ private InvokeHostFunctionOp invokeHostFunctionOp;
+ private BumpFootprintExpirationOp bumpFootprintExpirationOp;
+ private RestoreFootprintOp restoreFootprintOp;
public Builder discriminant(OperationType discriminant) {
this.discriminant = discriminant;
@@ -532,31 +600,50 @@ public Builder liquidityPoolWithdrawOp(LiquidityPoolWithdrawOp liquidityPoolWith
return this;
}
+ public Builder invokeHostFunctionOp(InvokeHostFunctionOp invokeHostFunctionOp) {
+ this.invokeHostFunctionOp = invokeHostFunctionOp;
+ return this;
+ }
+
+ public Builder bumpFootprintExpirationOp(
+ BumpFootprintExpirationOp bumpFootprintExpirationOp) {
+ this.bumpFootprintExpirationOp = bumpFootprintExpirationOp;
+ return this;
+ }
+
+ public Builder restoreFootprintOp(RestoreFootprintOp restoreFootprintOp) {
+ this.restoreFootprintOp = restoreFootprintOp;
+ return this;
+ }
+
public OperationBody build() {
OperationBody val = new OperationBody();
val.setDiscriminant(discriminant);
- val.setCreateAccountOp(createAccountOp);
- val.setPaymentOp(paymentOp);
- val.setPathPaymentStrictReceiveOp(pathPaymentStrictReceiveOp);
- val.setManageSellOfferOp(manageSellOfferOp);
- val.setCreatePassiveSellOfferOp(createPassiveSellOfferOp);
- val.setSetOptionsOp(setOptionsOp);
- val.setChangeTrustOp(changeTrustOp);
- val.setAllowTrustOp(allowTrustOp);
- val.setDestination(destination);
- val.setManageDataOp(manageDataOp);
- val.setBumpSequenceOp(bumpSequenceOp);
- val.setManageBuyOfferOp(manageBuyOfferOp);
- val.setPathPaymentStrictSendOp(pathPaymentStrictSendOp);
- val.setCreateClaimableBalanceOp(createClaimableBalanceOp);
- val.setClaimClaimableBalanceOp(claimClaimableBalanceOp);
- val.setBeginSponsoringFutureReservesOp(beginSponsoringFutureReservesOp);
- val.setRevokeSponsorshipOp(revokeSponsorshipOp);
- val.setClawbackOp(clawbackOp);
- val.setClawbackClaimableBalanceOp(clawbackClaimableBalanceOp);
- val.setSetTrustLineFlagsOp(setTrustLineFlagsOp);
- val.setLiquidityPoolDepositOp(liquidityPoolDepositOp);
- val.setLiquidityPoolWithdrawOp(liquidityPoolWithdrawOp);
+ val.setCreateAccountOp(this.createAccountOp);
+ val.setPaymentOp(this.paymentOp);
+ val.setPathPaymentStrictReceiveOp(this.pathPaymentStrictReceiveOp);
+ val.setManageSellOfferOp(this.manageSellOfferOp);
+ val.setCreatePassiveSellOfferOp(this.createPassiveSellOfferOp);
+ val.setSetOptionsOp(this.setOptionsOp);
+ val.setChangeTrustOp(this.changeTrustOp);
+ val.setAllowTrustOp(this.allowTrustOp);
+ val.setDestination(this.destination);
+ val.setManageDataOp(this.manageDataOp);
+ val.setBumpSequenceOp(this.bumpSequenceOp);
+ val.setManageBuyOfferOp(this.manageBuyOfferOp);
+ val.setPathPaymentStrictSendOp(this.pathPaymentStrictSendOp);
+ val.setCreateClaimableBalanceOp(this.createClaimableBalanceOp);
+ val.setClaimClaimableBalanceOp(this.claimClaimableBalanceOp);
+ val.setBeginSponsoringFutureReservesOp(this.beginSponsoringFutureReservesOp);
+ val.setRevokeSponsorshipOp(this.revokeSponsorshipOp);
+ val.setClawbackOp(this.clawbackOp);
+ val.setClawbackClaimableBalanceOp(this.clawbackClaimableBalanceOp);
+ val.setSetTrustLineFlagsOp(this.setTrustLineFlagsOp);
+ val.setLiquidityPoolDepositOp(this.liquidityPoolDepositOp);
+ val.setLiquidityPoolWithdrawOp(this.liquidityPoolWithdrawOp);
+ val.setInvokeHostFunctionOp(this.invokeHostFunctionOp);
+ val.setBumpFootprintExpirationOp(this.bumpFootprintExpirationOp);
+ val.setRestoreFootprintOp(this.restoreFootprintOp);
return val;
}
}
@@ -640,6 +727,15 @@ public static void encode(XdrDataOutputStream stream, OperationBody encodedOpera
case LIQUIDITY_POOL_WITHDRAW:
LiquidityPoolWithdrawOp.encode(stream, encodedOperationBody.liquidityPoolWithdrawOp);
break;
+ case INVOKE_HOST_FUNCTION:
+ InvokeHostFunctionOp.encode(stream, encodedOperationBody.invokeHostFunctionOp);
+ break;
+ case BUMP_FOOTPRINT_EXPIRATION:
+ BumpFootprintExpirationOp.encode(stream, encodedOperationBody.bumpFootprintExpirationOp);
+ break;
+ case RESTORE_FOOTPRINT:
+ RestoreFootprintOp.encode(stream, encodedOperationBody.restoreFootprintOp);
+ break;
}
}
@@ -725,13 +821,22 @@ public static OperationBody decode(XdrDataInputStream stream) throws IOException
case LIQUIDITY_POOL_WITHDRAW:
decodedOperationBody.liquidityPoolWithdrawOp = LiquidityPoolWithdrawOp.decode(stream);
break;
+ case INVOKE_HOST_FUNCTION:
+ decodedOperationBody.invokeHostFunctionOp = InvokeHostFunctionOp.decode(stream);
+ break;
+ case BUMP_FOOTPRINT_EXPIRATION:
+ decodedOperationBody.bumpFootprintExpirationOp = BumpFootprintExpirationOp.decode(stream);
+ break;
+ case RESTORE_FOOTPRINT:
+ decodedOperationBody.restoreFootprintOp = RestoreFootprintOp.decode(stream);
+ break;
}
return decodedOperationBody;
}
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.createAccountOp,
this.paymentOp,
this.pathPaymentStrictReceiveOp,
@@ -754,6 +859,9 @@ public int hashCode() {
this.setTrustLineFlagsOp,
this.liquidityPoolDepositOp,
this.liquidityPoolWithdrawOp,
+ this.invokeHostFunctionOp,
+ this.bumpFootprintExpirationOp,
+ this.restoreFootprintOp,
this.type);
}
@@ -764,30 +872,57 @@ public boolean equals(Object object) {
}
OperationBody other = (OperationBody) object;
- return Objects.equal(this.createAccountOp, other.createAccountOp)
- && Objects.equal(this.paymentOp, other.paymentOp)
- && Objects.equal(this.pathPaymentStrictReceiveOp, other.pathPaymentStrictReceiveOp)
- && Objects.equal(this.manageSellOfferOp, other.manageSellOfferOp)
- && Objects.equal(this.createPassiveSellOfferOp, other.createPassiveSellOfferOp)
- && Objects.equal(this.setOptionsOp, other.setOptionsOp)
- && Objects.equal(this.changeTrustOp, other.changeTrustOp)
- && Objects.equal(this.allowTrustOp, other.allowTrustOp)
- && Objects.equal(this.destination, other.destination)
- && Objects.equal(this.manageDataOp, other.manageDataOp)
- && Objects.equal(this.bumpSequenceOp, other.bumpSequenceOp)
- && Objects.equal(this.manageBuyOfferOp, other.manageBuyOfferOp)
- && Objects.equal(this.pathPaymentStrictSendOp, other.pathPaymentStrictSendOp)
- && Objects.equal(this.createClaimableBalanceOp, other.createClaimableBalanceOp)
- && Objects.equal(this.claimClaimableBalanceOp, other.claimClaimableBalanceOp)
- && Objects.equal(
+ return Objects.equals(this.createAccountOp, other.createAccountOp)
+ && Objects.equals(this.paymentOp, other.paymentOp)
+ && Objects.equals(this.pathPaymentStrictReceiveOp, other.pathPaymentStrictReceiveOp)
+ && Objects.equals(this.manageSellOfferOp, other.manageSellOfferOp)
+ && Objects.equals(this.createPassiveSellOfferOp, other.createPassiveSellOfferOp)
+ && Objects.equals(this.setOptionsOp, other.setOptionsOp)
+ && Objects.equals(this.changeTrustOp, other.changeTrustOp)
+ && Objects.equals(this.allowTrustOp, other.allowTrustOp)
+ && Objects.equals(this.destination, other.destination)
+ && Objects.equals(this.manageDataOp, other.manageDataOp)
+ && Objects.equals(this.bumpSequenceOp, other.bumpSequenceOp)
+ && Objects.equals(this.manageBuyOfferOp, other.manageBuyOfferOp)
+ && Objects.equals(this.pathPaymentStrictSendOp, other.pathPaymentStrictSendOp)
+ && Objects.equals(this.createClaimableBalanceOp, other.createClaimableBalanceOp)
+ && Objects.equals(this.claimClaimableBalanceOp, other.claimClaimableBalanceOp)
+ && Objects.equals(
this.beginSponsoringFutureReservesOp, other.beginSponsoringFutureReservesOp)
- && Objects.equal(this.revokeSponsorshipOp, other.revokeSponsorshipOp)
- && Objects.equal(this.clawbackOp, other.clawbackOp)
- && Objects.equal(this.clawbackClaimableBalanceOp, other.clawbackClaimableBalanceOp)
- && Objects.equal(this.setTrustLineFlagsOp, other.setTrustLineFlagsOp)
- && Objects.equal(this.liquidityPoolDepositOp, other.liquidityPoolDepositOp)
- && Objects.equal(this.liquidityPoolWithdrawOp, other.liquidityPoolWithdrawOp)
- && Objects.equal(this.type, other.type);
+ && Objects.equals(this.revokeSponsorshipOp, other.revokeSponsorshipOp)
+ && Objects.equals(this.clawbackOp, other.clawbackOp)
+ && Objects.equals(this.clawbackClaimableBalanceOp, other.clawbackClaimableBalanceOp)
+ && Objects.equals(this.setTrustLineFlagsOp, other.setTrustLineFlagsOp)
+ && Objects.equals(this.liquidityPoolDepositOp, other.liquidityPoolDepositOp)
+ && Objects.equals(this.liquidityPoolWithdrawOp, other.liquidityPoolWithdrawOp)
+ && Objects.equals(this.invokeHostFunctionOp, other.invokeHostFunctionOp)
+ && Objects.equals(this.bumpFootprintExpirationOp, other.bumpFootprintExpirationOp)
+ && Objects.equals(this.restoreFootprintOp, other.restoreFootprintOp)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static OperationBody fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static OperationBody fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/OperationID.java b/src/main/java/org/stellar/sdk/xdr/OperationID.java
deleted file mode 100644
index b97e1deac..000000000
--- a/src/main/java/org/stellar/sdk/xdr/OperationID.java
+++ /dev/null
@@ -1,384 +0,0 @@
-// Automatically generated by xdrgen
-// DO NOT EDIT or your changes may be overwritten
-
-package org.stellar.sdk.xdr;
-
-import com.google.common.base.Objects;
-import java.io.IOException;
-
-// === xdr source ============================================================
-
-// union OperationID switch (EnvelopeType type)
-// {
-// case ENVELOPE_TYPE_OP_ID:
-// struct
-// {
-// AccountID sourceAccount;
-// SequenceNumber seqNum;
-// uint32 opNum;
-// } id;
-// case ENVELOPE_TYPE_POOL_REVOKE_OP_ID:
-// struct
-// {
-// AccountID sourceAccount;
-// SequenceNumber seqNum;
-// uint32 opNum;
-// PoolID liquidityPoolID;
-// Asset asset;
-// } revokeId;
-// };
-
-// ===========================================================================
-public class OperationID implements XdrElement {
- public OperationID() {}
-
- EnvelopeType type;
-
- public EnvelopeType getDiscriminant() {
- return this.type;
- }
-
- public void setDiscriminant(EnvelopeType value) {
- this.type = value;
- }
-
- private OperationIDId id;
-
- public OperationIDId getId() {
- return this.id;
- }
-
- public void setId(OperationIDId value) {
- this.id = value;
- }
-
- private OperationIDRevokeId revokeId;
-
- public OperationIDRevokeId getRevokeId() {
- return this.revokeId;
- }
-
- public void setRevokeId(OperationIDRevokeId value) {
- this.revokeId = value;
- }
-
- public static final class Builder {
- private EnvelopeType discriminant;
- private OperationIDId id;
- private OperationIDRevokeId revokeId;
-
- public Builder discriminant(EnvelopeType discriminant) {
- this.discriminant = discriminant;
- return this;
- }
-
- public Builder id(OperationIDId id) {
- this.id = id;
- return this;
- }
-
- public Builder revokeId(OperationIDRevokeId revokeId) {
- this.revokeId = revokeId;
- return this;
- }
-
- public OperationID build() {
- OperationID val = new OperationID();
- val.setDiscriminant(discriminant);
- val.setId(id);
- val.setRevokeId(revokeId);
- return val;
- }
- }
-
- public static void encode(XdrDataOutputStream stream, OperationID encodedOperationID)
- throws IOException {
- // Xdrgen::AST::Identifier
- // EnvelopeType
- stream.writeInt(encodedOperationID.getDiscriminant().getValue());
- switch (encodedOperationID.getDiscriminant()) {
- case ENVELOPE_TYPE_OP_ID:
- OperationIDId.encode(stream, encodedOperationID.id);
- break;
- case ENVELOPE_TYPE_POOL_REVOKE_OP_ID:
- OperationIDRevokeId.encode(stream, encodedOperationID.revokeId);
- break;
- }
- }
-
- public void encode(XdrDataOutputStream stream) throws IOException {
- encode(stream, this);
- }
-
- public static OperationID decode(XdrDataInputStream stream) throws IOException {
- OperationID decodedOperationID = new OperationID();
- EnvelopeType discriminant = EnvelopeType.decode(stream);
- decodedOperationID.setDiscriminant(discriminant);
- switch (decodedOperationID.getDiscriminant()) {
- case ENVELOPE_TYPE_OP_ID:
- decodedOperationID.id = OperationIDId.decode(stream);
- break;
- case ENVELOPE_TYPE_POOL_REVOKE_OP_ID:
- decodedOperationID.revokeId = OperationIDRevokeId.decode(stream);
- break;
- }
- return decodedOperationID;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(this.id, this.revokeId, this.type);
- }
-
- @Override
- public boolean equals(Object object) {
- if (!(object instanceof OperationID)) {
- return false;
- }
-
- OperationID other = (OperationID) object;
- return Objects.equal(this.id, other.id)
- && Objects.equal(this.revokeId, other.revokeId)
- && Objects.equal(this.type, other.type);
- }
-
- public static class OperationIDId {
- public OperationIDId() {}
-
- private AccountID sourceAccount;
-
- public AccountID getSourceAccount() {
- return this.sourceAccount;
- }
-
- public void setSourceAccount(AccountID value) {
- this.sourceAccount = value;
- }
-
- private SequenceNumber seqNum;
-
- public SequenceNumber getSeqNum() {
- return this.seqNum;
- }
-
- public void setSeqNum(SequenceNumber value) {
- this.seqNum = value;
- }
-
- private Uint32 opNum;
-
- public Uint32 getOpNum() {
- return this.opNum;
- }
-
- public void setOpNum(Uint32 value) {
- this.opNum = value;
- }
-
- public static void encode(XdrDataOutputStream stream, OperationIDId encodedOperationIDId)
- throws IOException {
- AccountID.encode(stream, encodedOperationIDId.sourceAccount);
- SequenceNumber.encode(stream, encodedOperationIDId.seqNum);
- Uint32.encode(stream, encodedOperationIDId.opNum);
- }
-
- public void encode(XdrDataOutputStream stream) throws IOException {
- encode(stream, this);
- }
-
- public static OperationIDId decode(XdrDataInputStream stream) throws IOException {
- OperationIDId decodedOperationIDId = new OperationIDId();
- decodedOperationIDId.sourceAccount = AccountID.decode(stream);
- decodedOperationIDId.seqNum = SequenceNumber.decode(stream);
- decodedOperationIDId.opNum = Uint32.decode(stream);
- return decodedOperationIDId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(this.sourceAccount, this.seqNum, this.opNum);
- }
-
- @Override
- public boolean equals(Object object) {
- if (!(object instanceof OperationIDId)) {
- return false;
- }
-
- OperationIDId other = (OperationIDId) object;
- return Objects.equal(this.sourceAccount, other.sourceAccount)
- && Objects.equal(this.seqNum, other.seqNum)
- && Objects.equal(this.opNum, other.opNum);
- }
-
- public static final class Builder {
- private AccountID sourceAccount;
- private SequenceNumber seqNum;
- private Uint32 opNum;
-
- public Builder sourceAccount(AccountID sourceAccount) {
- this.sourceAccount = sourceAccount;
- return this;
- }
-
- public Builder seqNum(SequenceNumber seqNum) {
- this.seqNum = seqNum;
- return this;
- }
-
- public Builder opNum(Uint32 opNum) {
- this.opNum = opNum;
- return this;
- }
-
- public OperationIDId build() {
- OperationIDId val = new OperationIDId();
- val.setSourceAccount(sourceAccount);
- val.setSeqNum(seqNum);
- val.setOpNum(opNum);
- return val;
- }
- }
- }
-
- public static class OperationIDRevokeId {
- public OperationIDRevokeId() {}
-
- private AccountID sourceAccount;
-
- public AccountID getSourceAccount() {
- return this.sourceAccount;
- }
-
- public void setSourceAccount(AccountID value) {
- this.sourceAccount = value;
- }
-
- private SequenceNumber seqNum;
-
- public SequenceNumber getSeqNum() {
- return this.seqNum;
- }
-
- public void setSeqNum(SequenceNumber value) {
- this.seqNum = value;
- }
-
- private Uint32 opNum;
-
- public Uint32 getOpNum() {
- return this.opNum;
- }
-
- public void setOpNum(Uint32 value) {
- this.opNum = value;
- }
-
- private PoolID liquidityPoolID;
-
- public PoolID getLiquidityPoolID() {
- return this.liquidityPoolID;
- }
-
- public void setLiquidityPoolID(PoolID value) {
- this.liquidityPoolID = value;
- }
-
- private Asset asset;
-
- public Asset getAsset() {
- return this.asset;
- }
-
- public void setAsset(Asset value) {
- this.asset = value;
- }
-
- public static void encode(
- XdrDataOutputStream stream, OperationIDRevokeId encodedOperationIDRevokeId)
- throws IOException {
- AccountID.encode(stream, encodedOperationIDRevokeId.sourceAccount);
- SequenceNumber.encode(stream, encodedOperationIDRevokeId.seqNum);
- Uint32.encode(stream, encodedOperationIDRevokeId.opNum);
- PoolID.encode(stream, encodedOperationIDRevokeId.liquidityPoolID);
- Asset.encode(stream, encodedOperationIDRevokeId.asset);
- }
-
- public void encode(XdrDataOutputStream stream) throws IOException {
- encode(stream, this);
- }
-
- public static OperationIDRevokeId decode(XdrDataInputStream stream) throws IOException {
- OperationIDRevokeId decodedOperationIDRevokeId = new OperationIDRevokeId();
- decodedOperationIDRevokeId.sourceAccount = AccountID.decode(stream);
- decodedOperationIDRevokeId.seqNum = SequenceNumber.decode(stream);
- decodedOperationIDRevokeId.opNum = Uint32.decode(stream);
- decodedOperationIDRevokeId.liquidityPoolID = PoolID.decode(stream);
- decodedOperationIDRevokeId.asset = Asset.decode(stream);
- return decodedOperationIDRevokeId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(
- this.sourceAccount, this.seqNum, this.opNum, this.liquidityPoolID, this.asset);
- }
-
- @Override
- public boolean equals(Object object) {
- if (!(object instanceof OperationIDRevokeId)) {
- return false;
- }
-
- OperationIDRevokeId other = (OperationIDRevokeId) object;
- return Objects.equal(this.sourceAccount, other.sourceAccount)
- && Objects.equal(this.seqNum, other.seqNum)
- && Objects.equal(this.opNum, other.opNum)
- && Objects.equal(this.liquidityPoolID, other.liquidityPoolID)
- && Objects.equal(this.asset, other.asset);
- }
-
- public static final class Builder {
- private AccountID sourceAccount;
- private SequenceNumber seqNum;
- private Uint32 opNum;
- private PoolID liquidityPoolID;
- private Asset asset;
-
- public Builder sourceAccount(AccountID sourceAccount) {
- this.sourceAccount = sourceAccount;
- return this;
- }
-
- public Builder seqNum(SequenceNumber seqNum) {
- this.seqNum = seqNum;
- return this;
- }
-
- public Builder opNum(Uint32 opNum) {
- this.opNum = opNum;
- return this;
- }
-
- public Builder liquidityPoolID(PoolID liquidityPoolID) {
- this.liquidityPoolID = liquidityPoolID;
- return this;
- }
-
- public Builder asset(Asset asset) {
- this.asset = asset;
- return this;
- }
-
- public OperationIDRevokeId build() {
- OperationIDRevokeId val = new OperationIDRevokeId();
- val.setSourceAccount(sourceAccount);
- val.setSeqNum(seqNum);
- val.setOpNum(opNum);
- val.setLiquidityPoolID(liquidityPoolID);
- val.setAsset(asset);
- return val;
- }
- }
- }
-}
diff --git a/src/main/java/org/stellar/sdk/xdr/OperationMeta.java b/src/main/java/org/stellar/sdk/xdr/OperationMeta.java
index 7b77f26fb..e5181afe0 100644
--- a/src/main/java/org/stellar/sdk/xdr/OperationMeta.java
+++ b/src/main/java/org/stellar/sdk/xdr/OperationMeta.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -44,7 +49,7 @@ public static OperationMeta decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(this.changes);
+ return Objects.hash(this.changes);
}
@Override
@@ -54,7 +59,31 @@ public boolean equals(Object object) {
}
OperationMeta other = (OperationMeta) object;
- return Objects.equal(this.changes, other.changes);
+ return Objects.equals(this.changes, other.changes);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static OperationMeta fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static OperationMeta fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -67,7 +96,7 @@ public Builder changes(LedgerEntryChanges changes) {
public OperationMeta build() {
OperationMeta val = new OperationMeta();
- val.setChanges(changes);
+ val.setChanges(this.changes);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/OperationResult.java b/src/main/java/org/stellar/sdk/xdr/OperationResult.java
index e91494126..e5dd07a70 100644
--- a/src/main/java/org/stellar/sdk/xdr/OperationResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/OperationResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -61,9 +66,20 @@
// LiquidityPoolDepositResult liquidityPoolDepositResult;
// case LIQUIDITY_POOL_WITHDRAW:
// LiquidityPoolWithdrawResult liquidityPoolWithdrawResult;
+// case INVOKE_HOST_FUNCTION:
+// InvokeHostFunctionResult invokeHostFunctionResult;
+// case BUMP_FOOTPRINT_EXPIRATION:
+// BumpFootprintExpirationResult bumpFootprintExpirationResult;
+// case RESTORE_FOOTPRINT:
+// RestoreFootprintResult restoreFootprintResult;
// }
// tr;
-// default:
+// case opBAD_AUTH:
+// case opNO_ACCOUNT:
+// case opNOT_SUPPORTED:
+// case opTOO_MANY_SUBENTRIES:
+// case opEXCEEDED_WORK_LIMIT:
+// case opTOO_MANY_SPONSORING:
// void;
// };
@@ -108,7 +124,7 @@ public Builder tr(OperationResultTr tr) {
public OperationResult build() {
OperationResult val = new OperationResult();
val.setDiscriminant(discriminant);
- val.setTr(tr);
+ val.setTr(this.tr);
return val;
}
}
@@ -122,7 +138,12 @@ public static void encode(XdrDataOutputStream stream, OperationResult encodedOpe
case opINNER:
OperationResultTr.encode(stream, encodedOperationResult.tr);
break;
- default:
+ case opBAD_AUTH:
+ case opNO_ACCOUNT:
+ case opNOT_SUPPORTED:
+ case opTOO_MANY_SUBENTRIES:
+ case opEXCEEDED_WORK_LIMIT:
+ case opTOO_MANY_SPONSORING:
break;
}
}
@@ -139,7 +160,12 @@ public static OperationResult decode(XdrDataInputStream stream) throws IOExcepti
case opINNER:
decodedOperationResult.tr = OperationResultTr.decode(stream);
break;
- default:
+ case opBAD_AUTH:
+ case opNO_ACCOUNT:
+ case opNOT_SUPPORTED:
+ case opTOO_MANY_SUBENTRIES:
+ case opEXCEEDED_WORK_LIMIT:
+ case opTOO_MANY_SPONSORING:
break;
}
return decodedOperationResult;
@@ -147,7 +173,7 @@ public static OperationResult decode(XdrDataInputStream stream) throws IOExcepti
@Override
public int hashCode() {
- return Objects.hashCode(this.tr, this.code);
+ return Objects.hash(this.tr, this.code);
}
@Override
@@ -157,10 +183,34 @@ public boolean equals(Object object) {
}
OperationResult other = (OperationResult) object;
- return Objects.equal(this.tr, other.tr) && Objects.equal(this.code, other.code);
+ return Objects.equals(this.tr, other.tr) && Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
}
- public static class OperationResultTr {
+ public static OperationResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static OperationResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static class OperationResultTr implements XdrElement {
public OperationResultTr() {}
OperationType type;
@@ -413,6 +463,36 @@ public void setLiquidityPoolWithdrawResult(LiquidityPoolWithdrawResult value) {
this.liquidityPoolWithdrawResult = value;
}
+ private InvokeHostFunctionResult invokeHostFunctionResult;
+
+ public InvokeHostFunctionResult getInvokeHostFunctionResult() {
+ return this.invokeHostFunctionResult;
+ }
+
+ public void setInvokeHostFunctionResult(InvokeHostFunctionResult value) {
+ this.invokeHostFunctionResult = value;
+ }
+
+ private BumpFootprintExpirationResult bumpFootprintExpirationResult;
+
+ public BumpFootprintExpirationResult getBumpFootprintExpirationResult() {
+ return this.bumpFootprintExpirationResult;
+ }
+
+ public void setBumpFootprintExpirationResult(BumpFootprintExpirationResult value) {
+ this.bumpFootprintExpirationResult = value;
+ }
+
+ private RestoreFootprintResult restoreFootprintResult;
+
+ public RestoreFootprintResult getRestoreFootprintResult() {
+ return this.restoreFootprintResult;
+ }
+
+ public void setRestoreFootprintResult(RestoreFootprintResult value) {
+ this.restoreFootprintResult = value;
+ }
+
public static final class Builder {
private OperationType discriminant;
private CreateAccountResult createAccountResult;
@@ -439,6 +519,9 @@ public static final class Builder {
private SetTrustLineFlagsResult setTrustLineFlagsResult;
private LiquidityPoolDepositResult liquidityPoolDepositResult;
private LiquidityPoolWithdrawResult liquidityPoolWithdrawResult;
+ private InvokeHostFunctionResult invokeHostFunctionResult;
+ private BumpFootprintExpirationResult bumpFootprintExpirationResult;
+ private RestoreFootprintResult restoreFootprintResult;
public Builder discriminant(OperationType discriminant) {
this.discriminant = discriminant;
@@ -575,33 +658,52 @@ public Builder liquidityPoolWithdrawResult(
return this;
}
+ public Builder invokeHostFunctionResult(InvokeHostFunctionResult invokeHostFunctionResult) {
+ this.invokeHostFunctionResult = invokeHostFunctionResult;
+ return this;
+ }
+
+ public Builder bumpFootprintExpirationResult(
+ BumpFootprintExpirationResult bumpFootprintExpirationResult) {
+ this.bumpFootprintExpirationResult = bumpFootprintExpirationResult;
+ return this;
+ }
+
+ public Builder restoreFootprintResult(RestoreFootprintResult restoreFootprintResult) {
+ this.restoreFootprintResult = restoreFootprintResult;
+ return this;
+ }
+
public OperationResultTr build() {
OperationResultTr val = new OperationResultTr();
val.setDiscriminant(discriminant);
- val.setCreateAccountResult(createAccountResult);
- val.setPaymentResult(paymentResult);
- val.setPathPaymentStrictReceiveResult(pathPaymentStrictReceiveResult);
- val.setManageSellOfferResult(manageSellOfferResult);
- val.setCreatePassiveSellOfferResult(createPassiveSellOfferResult);
- val.setSetOptionsResult(setOptionsResult);
- val.setChangeTrustResult(changeTrustResult);
- val.setAllowTrustResult(allowTrustResult);
- val.setAccountMergeResult(accountMergeResult);
- val.setInflationResult(inflationResult);
- val.setManageDataResult(manageDataResult);
- val.setBumpSeqResult(bumpSeqResult);
- val.setManageBuyOfferResult(manageBuyOfferResult);
- val.setPathPaymentStrictSendResult(pathPaymentStrictSendResult);
- val.setCreateClaimableBalanceResult(createClaimableBalanceResult);
- val.setClaimClaimableBalanceResult(claimClaimableBalanceResult);
- val.setBeginSponsoringFutureReservesResult(beginSponsoringFutureReservesResult);
- val.setEndSponsoringFutureReservesResult(endSponsoringFutureReservesResult);
- val.setRevokeSponsorshipResult(revokeSponsorshipResult);
- val.setClawbackResult(clawbackResult);
- val.setClawbackClaimableBalanceResult(clawbackClaimableBalanceResult);
- val.setSetTrustLineFlagsResult(setTrustLineFlagsResult);
- val.setLiquidityPoolDepositResult(liquidityPoolDepositResult);
- val.setLiquidityPoolWithdrawResult(liquidityPoolWithdrawResult);
+ val.setCreateAccountResult(this.createAccountResult);
+ val.setPaymentResult(this.paymentResult);
+ val.setPathPaymentStrictReceiveResult(this.pathPaymentStrictReceiveResult);
+ val.setManageSellOfferResult(this.manageSellOfferResult);
+ val.setCreatePassiveSellOfferResult(this.createPassiveSellOfferResult);
+ val.setSetOptionsResult(this.setOptionsResult);
+ val.setChangeTrustResult(this.changeTrustResult);
+ val.setAllowTrustResult(this.allowTrustResult);
+ val.setAccountMergeResult(this.accountMergeResult);
+ val.setInflationResult(this.inflationResult);
+ val.setManageDataResult(this.manageDataResult);
+ val.setBumpSeqResult(this.bumpSeqResult);
+ val.setManageBuyOfferResult(this.manageBuyOfferResult);
+ val.setPathPaymentStrictSendResult(this.pathPaymentStrictSendResult);
+ val.setCreateClaimableBalanceResult(this.createClaimableBalanceResult);
+ val.setClaimClaimableBalanceResult(this.claimClaimableBalanceResult);
+ val.setBeginSponsoringFutureReservesResult(this.beginSponsoringFutureReservesResult);
+ val.setEndSponsoringFutureReservesResult(this.endSponsoringFutureReservesResult);
+ val.setRevokeSponsorshipResult(this.revokeSponsorshipResult);
+ val.setClawbackResult(this.clawbackResult);
+ val.setClawbackClaimableBalanceResult(this.clawbackClaimableBalanceResult);
+ val.setSetTrustLineFlagsResult(this.setTrustLineFlagsResult);
+ val.setLiquidityPoolDepositResult(this.liquidityPoolDepositResult);
+ val.setLiquidityPoolWithdrawResult(this.liquidityPoolWithdrawResult);
+ val.setInvokeHostFunctionResult(this.invokeHostFunctionResult);
+ val.setBumpFootprintExpirationResult(this.bumpFootprintExpirationResult);
+ val.setRestoreFootprintResult(this.restoreFootprintResult);
return val;
}
}
@@ -694,6 +796,17 @@ public static void encode(
LiquidityPoolWithdrawResult.encode(
stream, encodedOperationResultTr.liquidityPoolWithdrawResult);
break;
+ case INVOKE_HOST_FUNCTION:
+ InvokeHostFunctionResult.encode(
+ stream, encodedOperationResultTr.invokeHostFunctionResult);
+ break;
+ case BUMP_FOOTPRINT_EXPIRATION:
+ BumpFootprintExpirationResult.encode(
+ stream, encodedOperationResultTr.bumpFootprintExpirationResult);
+ break;
+ case RESTORE_FOOTPRINT:
+ RestoreFootprintResult.encode(stream, encodedOperationResultTr.restoreFootprintResult);
+ break;
}
}
@@ -788,13 +901,24 @@ public static OperationResultTr decode(XdrDataInputStream stream) throws IOExcep
decodedOperationResultTr.liquidityPoolWithdrawResult =
LiquidityPoolWithdrawResult.decode(stream);
break;
+ case INVOKE_HOST_FUNCTION:
+ decodedOperationResultTr.invokeHostFunctionResult =
+ InvokeHostFunctionResult.decode(stream);
+ break;
+ case BUMP_FOOTPRINT_EXPIRATION:
+ decodedOperationResultTr.bumpFootprintExpirationResult =
+ BumpFootprintExpirationResult.decode(stream);
+ break;
+ case RESTORE_FOOTPRINT:
+ decodedOperationResultTr.restoreFootprintResult = RestoreFootprintResult.decode(stream);
+ break;
}
return decodedOperationResultTr;
}
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.createAccountResult,
this.paymentResult,
this.pathPaymentStrictReceiveResult,
@@ -819,6 +943,9 @@ public int hashCode() {
this.setTrustLineFlagsResult,
this.liquidityPoolDepositResult,
this.liquidityPoolWithdrawResult,
+ this.invokeHostFunctionResult,
+ this.bumpFootprintExpirationResult,
+ this.restoreFootprintResult,
this.type);
}
@@ -829,35 +956,62 @@ public boolean equals(Object object) {
}
OperationResultTr other = (OperationResultTr) object;
- return Objects.equal(this.createAccountResult, other.createAccountResult)
- && Objects.equal(this.paymentResult, other.paymentResult)
- && Objects.equal(
+ return Objects.equals(this.createAccountResult, other.createAccountResult)
+ && Objects.equals(this.paymentResult, other.paymentResult)
+ && Objects.equals(
this.pathPaymentStrictReceiveResult, other.pathPaymentStrictReceiveResult)
- && Objects.equal(this.manageSellOfferResult, other.manageSellOfferResult)
- && Objects.equal(this.createPassiveSellOfferResult, other.createPassiveSellOfferResult)
- && Objects.equal(this.setOptionsResult, other.setOptionsResult)
- && Objects.equal(this.changeTrustResult, other.changeTrustResult)
- && Objects.equal(this.allowTrustResult, other.allowTrustResult)
- && Objects.equal(this.accountMergeResult, other.accountMergeResult)
- && Objects.equal(this.inflationResult, other.inflationResult)
- && Objects.equal(this.manageDataResult, other.manageDataResult)
- && Objects.equal(this.bumpSeqResult, other.bumpSeqResult)
- && Objects.equal(this.manageBuyOfferResult, other.manageBuyOfferResult)
- && Objects.equal(this.pathPaymentStrictSendResult, other.pathPaymentStrictSendResult)
- && Objects.equal(this.createClaimableBalanceResult, other.createClaimableBalanceResult)
- && Objects.equal(this.claimClaimableBalanceResult, other.claimClaimableBalanceResult)
- && Objects.equal(
+ && Objects.equals(this.manageSellOfferResult, other.manageSellOfferResult)
+ && Objects.equals(this.createPassiveSellOfferResult, other.createPassiveSellOfferResult)
+ && Objects.equals(this.setOptionsResult, other.setOptionsResult)
+ && Objects.equals(this.changeTrustResult, other.changeTrustResult)
+ && Objects.equals(this.allowTrustResult, other.allowTrustResult)
+ && Objects.equals(this.accountMergeResult, other.accountMergeResult)
+ && Objects.equals(this.inflationResult, other.inflationResult)
+ && Objects.equals(this.manageDataResult, other.manageDataResult)
+ && Objects.equals(this.bumpSeqResult, other.bumpSeqResult)
+ && Objects.equals(this.manageBuyOfferResult, other.manageBuyOfferResult)
+ && Objects.equals(this.pathPaymentStrictSendResult, other.pathPaymentStrictSendResult)
+ && Objects.equals(this.createClaimableBalanceResult, other.createClaimableBalanceResult)
+ && Objects.equals(this.claimClaimableBalanceResult, other.claimClaimableBalanceResult)
+ && Objects.equals(
this.beginSponsoringFutureReservesResult, other.beginSponsoringFutureReservesResult)
- && Objects.equal(
+ && Objects.equals(
this.endSponsoringFutureReservesResult, other.endSponsoringFutureReservesResult)
- && Objects.equal(this.revokeSponsorshipResult, other.revokeSponsorshipResult)
- && Objects.equal(this.clawbackResult, other.clawbackResult)
- && Objects.equal(
+ && Objects.equals(this.revokeSponsorshipResult, other.revokeSponsorshipResult)
+ && Objects.equals(this.clawbackResult, other.clawbackResult)
+ && Objects.equals(
this.clawbackClaimableBalanceResult, other.clawbackClaimableBalanceResult)
- && Objects.equal(this.setTrustLineFlagsResult, other.setTrustLineFlagsResult)
- && Objects.equal(this.liquidityPoolDepositResult, other.liquidityPoolDepositResult)
- && Objects.equal(this.liquidityPoolWithdrawResult, other.liquidityPoolWithdrawResult)
- && Objects.equal(this.type, other.type);
+ && Objects.equals(this.setTrustLineFlagsResult, other.setTrustLineFlagsResult)
+ && Objects.equals(this.liquidityPoolDepositResult, other.liquidityPoolDepositResult)
+ && Objects.equals(this.liquidityPoolWithdrawResult, other.liquidityPoolWithdrawResult)
+ && Objects.equals(this.invokeHostFunctionResult, other.invokeHostFunctionResult)
+ && Objects.equals(this.bumpFootprintExpirationResult, other.bumpFootprintExpirationResult)
+ && Objects.equals(this.restoreFootprintResult, other.restoreFootprintResult)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static OperationResultTr fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static OperationResultTr fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/OperationResultCode.java b/src/main/java/org/stellar/sdk/xdr/OperationResultCode.java
index e4ddbda09..b167762de 100644
--- a/src/main/java/org/stellar/sdk/xdr/OperationResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/OperationResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -69,4 +74,28 @@ public static void encode(XdrDataOutputStream stream, OperationResultCode value)
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static OperationResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static OperationResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/OperationType.java b/src/main/java/org/stellar/sdk/xdr/OperationType.java
index 3117d42da..1ffec8c42 100644
--- a/src/main/java/org/stellar/sdk/xdr/OperationType.java
+++ b/src/main/java/org/stellar/sdk/xdr/OperationType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -32,7 +37,10 @@
// CLAWBACK_CLAIMABLE_BALANCE = 20,
// SET_TRUST_LINE_FLAGS = 21,
// LIQUIDITY_POOL_DEPOSIT = 22,
-// LIQUIDITY_POOL_WITHDRAW = 23
+// LIQUIDITY_POOL_WITHDRAW = 23,
+// INVOKE_HOST_FUNCTION = 24,
+// BUMP_FOOTPRINT_EXPIRATION = 25,
+// RESTORE_FOOTPRINT = 26
// };
// ===========================================================================
@@ -61,6 +69,9 @@ public enum OperationType implements XdrElement {
SET_TRUST_LINE_FLAGS(21),
LIQUIDITY_POOL_DEPOSIT(22),
LIQUIDITY_POOL_WITHDRAW(23),
+ INVOKE_HOST_FUNCTION(24),
+ BUMP_FOOTPRINT_EXPIRATION(25),
+ RESTORE_FOOTPRINT(26),
;
private int mValue;
@@ -123,6 +134,12 @@ public static OperationType decode(XdrDataInputStream stream) throws IOException
return LIQUIDITY_POOL_DEPOSIT;
case 23:
return LIQUIDITY_POOL_WITHDRAW;
+ case 24:
+ return INVOKE_HOST_FUNCTION;
+ case 25:
+ return BUMP_FOOTPRINT_EXPIRATION;
+ case 26:
+ return RESTORE_FOOTPRINT;
default:
throw new RuntimeException("Unknown enum value: " + value);
}
@@ -135,4 +152,28 @@ public static void encode(XdrDataOutputStream stream, OperationType value) throw
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static OperationType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static OperationType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PathPaymentResult.java b/src/main/java/org/stellar/sdk/xdr/PathPaymentResult.java
deleted file mode 100644
index d70a90d0e..000000000
--- a/src/main/java/org/stellar/sdk/xdr/PathPaymentResult.java
+++ /dev/null
@@ -1,171 +0,0 @@
-// Automatically generated by xdrgen
-// DO NOT EDIT or your changes may be overwritten
-
-package org.stellar.sdk.xdr;
-
-import com.google.common.base.Objects;
-import java.io.IOException;
-import java.util.Arrays;
-
-// === xdr source ============================================================
-
-// union PathPaymentResult switch (PathPaymentResultCode code)
-// {
-// case PATH_PAYMENT_SUCCESS:
-// struct
-// {
-// ClaimOfferAtom offers<>;
-// SimplePaymentResult last;
-// } success;
-// case PATH_PAYMENT_NO_ISSUER:
-// Asset noIssuer; // the asset that caused the error
-// default:
-// void;
-// };
-
-// ===========================================================================
-public class PathPaymentResult {
- public PathPaymentResult() {}
-
- PathPaymentResultCode code;
-
- public PathPaymentResultCode getDiscriminant() {
- return this.code;
- }
-
- public void setDiscriminant(PathPaymentResultCode value) {
- this.code = value;
- }
-
- private PathPaymentResultSuccess success;
-
- public PathPaymentResultSuccess getSuccess() {
- return this.success;
- }
-
- public void setSuccess(PathPaymentResultSuccess value) {
- this.success = value;
- }
-
- private Asset noIssuer;
-
- public Asset getNoIssuer() {
- return this.noIssuer;
- }
-
- public void setNoIssuer(Asset value) {
- this.noIssuer = value;
- }
-
- public static void encode(XdrDataOutputStream stream, PathPaymentResult encodedPathPaymentResult)
- throws IOException {
- // Xdrgen::AST::Identifier
- // PathPaymentResultCode
- stream.writeInt(encodedPathPaymentResult.getDiscriminant().getValue());
- switch (encodedPathPaymentResult.getDiscriminant()) {
- case PATH_PAYMENT_SUCCESS:
- PathPaymentResultSuccess.encode(stream, encodedPathPaymentResult.success);
- break;
- case PATH_PAYMENT_NO_ISSUER:
- Asset.encode(stream, encodedPathPaymentResult.noIssuer);
- break;
- default:
- break;
- }
- }
-
- public static PathPaymentResult decode(XdrDataInputStream stream) throws IOException {
- PathPaymentResult decodedPathPaymentResult = new PathPaymentResult();
- PathPaymentResultCode discriminant = PathPaymentResultCode.decode(stream);
- decodedPathPaymentResult.setDiscriminant(discriminant);
- switch (decodedPathPaymentResult.getDiscriminant()) {
- case PATH_PAYMENT_SUCCESS:
- decodedPathPaymentResult.success = PathPaymentResultSuccess.decode(stream);
- break;
- case PATH_PAYMENT_NO_ISSUER:
- decodedPathPaymentResult.noIssuer = Asset.decode(stream);
- break;
- default:
- break;
- }
- return decodedPathPaymentResult;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(this.success, this.noIssuer, this.code);
- }
-
- @Override
- public boolean equals(Object object) {
- if (!(object instanceof PathPaymentResult)) {
- return false;
- }
-
- PathPaymentResult other = (PathPaymentResult) object;
- return Objects.equal(this.success, other.success)
- && Objects.equal(this.noIssuer, other.noIssuer)
- && Objects.equal(this.code, other.code);
- }
-
- public static class PathPaymentResultSuccess {
- public PathPaymentResultSuccess() {}
-
- private ClaimOfferAtom[] offers;
-
- public ClaimOfferAtom[] getOffers() {
- return this.offers;
- }
-
- public void setOffers(ClaimOfferAtom[] value) {
- this.offers = value;
- }
-
- private SimplePaymentResult last;
-
- public SimplePaymentResult getLast() {
- return this.last;
- }
-
- public void setLast(SimplePaymentResult value) {
- this.last = value;
- }
-
- public static void encode(
- XdrDataOutputStream stream, PathPaymentResultSuccess encodedPathPaymentResultSuccess)
- throws IOException {
- int offerssize = encodedPathPaymentResultSuccess.getOffers().length;
- stream.writeInt(offerssize);
- for (int i = 0; i < offerssize; i++) {
- ClaimOfferAtom.encode(stream, encodedPathPaymentResultSuccess.offers[i]);
- }
- SimplePaymentResult.encode(stream, encodedPathPaymentResultSuccess.last);
- }
-
- public static PathPaymentResultSuccess decode(XdrDataInputStream stream) throws IOException {
- PathPaymentResultSuccess decodedPathPaymentResultSuccess = new PathPaymentResultSuccess();
- int offerssize = stream.readInt();
- decodedPathPaymentResultSuccess.offers = new ClaimOfferAtom[offerssize];
- for (int i = 0; i < offerssize; i++) {
- decodedPathPaymentResultSuccess.offers[i] = ClaimOfferAtom.decode(stream);
- }
- decodedPathPaymentResultSuccess.last = SimplePaymentResult.decode(stream);
- return decodedPathPaymentResultSuccess;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(Arrays.hashCode(this.offers), this.last);
- }
-
- @Override
- public boolean equals(Object object) {
- if (!(object instanceof PathPaymentResultSuccess)) {
- return false;
- }
-
- PathPaymentResultSuccess other = (PathPaymentResultSuccess) object;
- return Arrays.equals(this.offers, other.offers) && Objects.equal(this.last, other.last);
- }
- }
-}
diff --git a/src/main/java/org/stellar/sdk/xdr/PathPaymentResultCode.java b/src/main/java/org/stellar/sdk/xdr/PathPaymentResultCode.java
deleted file mode 100644
index a696e4236..000000000
--- a/src/main/java/org/stellar/sdk/xdr/PathPaymentResultCode.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// Automatically generated by xdrgen
-// DO NOT EDIT or your changes may be overwritten
-
-package org.stellar.sdk.xdr;
-
-import java.io.IOException;
-
-// === xdr source ============================================================
-
-// enum PathPaymentResultCode
-// {
-// // codes considered as "success" for the operation
-// PATH_PAYMENT_SUCCESS = 0, // success
-//
-// // codes considered as "failure" for the operation
-// PATH_PAYMENT_MALFORMED = -1, // bad input
-// PATH_PAYMENT_UNDERFUNDED = -2, // not enough funds in source account
-// PATH_PAYMENT_SRC_NO_TRUST = -3, // no trust line on source account
-// PATH_PAYMENT_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer
-// PATH_PAYMENT_NO_DESTINATION = -5, // destination account does not exist
-// PATH_PAYMENT_NO_TRUST = -6, // dest missing a trust line for asset
-// PATH_PAYMENT_NOT_AUTHORIZED = -7, // dest not authorized to hold asset
-// PATH_PAYMENT_LINE_FULL = -8, // dest would go above their limit
-// PATH_PAYMENT_NO_ISSUER = -9, // missing issuer on one asset
-// PATH_PAYMENT_TOO_FEW_OFFERS = -10, // not enough offers to satisfy path
-// PATH_PAYMENT_OFFER_CROSS_SELF = -11, // would cross one of its own offers
-// PATH_PAYMENT_OVER_SENDMAX = -12 // could not satisfy sendmax
-// };
-
-// ===========================================================================
-public enum PathPaymentResultCode {
- PATH_PAYMENT_SUCCESS(0),
- PATH_PAYMENT_MALFORMED(-1),
- PATH_PAYMENT_UNDERFUNDED(-2),
- PATH_PAYMENT_SRC_NO_TRUST(-3),
- PATH_PAYMENT_SRC_NOT_AUTHORIZED(-4),
- PATH_PAYMENT_NO_DESTINATION(-5),
- PATH_PAYMENT_NO_TRUST(-6),
- PATH_PAYMENT_NOT_AUTHORIZED(-7),
- PATH_PAYMENT_LINE_FULL(-8),
- PATH_PAYMENT_NO_ISSUER(-9),
- PATH_PAYMENT_TOO_FEW_OFFERS(-10),
- PATH_PAYMENT_OFFER_CROSS_SELF(-11),
- PATH_PAYMENT_OVER_SENDMAX(-12),
- ;
- private int mValue;
-
- PathPaymentResultCode(int value) {
- mValue = value;
- }
-
- public int getValue() {
- return mValue;
- }
-
- static PathPaymentResultCode decode(XdrDataInputStream stream) throws IOException {
- int value = stream.readInt();
- switch (value) {
- case 0:
- return PATH_PAYMENT_SUCCESS;
- case -1:
- return PATH_PAYMENT_MALFORMED;
- case -2:
- return PATH_PAYMENT_UNDERFUNDED;
- case -3:
- return PATH_PAYMENT_SRC_NO_TRUST;
- case -4:
- return PATH_PAYMENT_SRC_NOT_AUTHORIZED;
- case -5:
- return PATH_PAYMENT_NO_DESTINATION;
- case -6:
- return PATH_PAYMENT_NO_TRUST;
- case -7:
- return PATH_PAYMENT_NOT_AUTHORIZED;
- case -8:
- return PATH_PAYMENT_LINE_FULL;
- case -9:
- return PATH_PAYMENT_NO_ISSUER;
- case -10:
- return PATH_PAYMENT_TOO_FEW_OFFERS;
- case -11:
- return PATH_PAYMENT_OFFER_CROSS_SELF;
- case -12:
- return PATH_PAYMENT_OVER_SENDMAX;
- default:
- throw new RuntimeException("Unknown enum value: " + value);
- }
- }
-
- static void encode(XdrDataOutputStream stream, PathPaymentResultCode value) throws IOException {
- stream.writeInt(value.getValue());
- }
-}
diff --git a/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictReceiveOp.java b/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictReceiveOp.java
index 29e753770..b6a5b5534 100644
--- a/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictReceiveOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictReceiveOp.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -123,7 +128,7 @@ public static PathPaymentStrictReceiveOp decode(XdrDataInputStream stream) throw
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.sendAsset,
this.sendMax,
this.destination,
@@ -139,14 +144,38 @@ public boolean equals(Object object) {
}
PathPaymentStrictReceiveOp other = (PathPaymentStrictReceiveOp) object;
- return Objects.equal(this.sendAsset, other.sendAsset)
- && Objects.equal(this.sendMax, other.sendMax)
- && Objects.equal(this.destination, other.destination)
- && Objects.equal(this.destAsset, other.destAsset)
- && Objects.equal(this.destAmount, other.destAmount)
+ return Objects.equals(this.sendAsset, other.sendAsset)
+ && Objects.equals(this.sendMax, other.sendMax)
+ && Objects.equals(this.destination, other.destination)
+ && Objects.equals(this.destAsset, other.destAsset)
+ && Objects.equals(this.destAmount, other.destAmount)
&& Arrays.equals(this.path, other.path);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PathPaymentStrictReceiveOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PathPaymentStrictReceiveOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private Asset sendAsset;
private Int64 sendMax;
@@ -187,12 +216,12 @@ public Builder path(Asset[] path) {
public PathPaymentStrictReceiveOp build() {
PathPaymentStrictReceiveOp val = new PathPaymentStrictReceiveOp();
- val.setSendAsset(sendAsset);
- val.setSendMax(sendMax);
- val.setDestination(destination);
- val.setDestAsset(destAsset);
- val.setDestAmount(destAmount);
- val.setPath(path);
+ val.setSendAsset(this.sendAsset);
+ val.setSendMax(this.sendMax);
+ val.setDestination(this.destination);
+ val.setDestAsset(this.destAsset);
+ val.setDestAmount(this.destAmount);
+ val.setPath(this.path);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictReceiveResult.java b/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictReceiveResult.java
index 6ca2d6e66..98725de63 100644
--- a/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictReceiveResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictReceiveResult.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -18,9 +23,20 @@
// ClaimAtom offers<>;
// SimplePaymentResult last;
// } success;
+// case PATH_PAYMENT_STRICT_RECEIVE_MALFORMED:
+// case PATH_PAYMENT_STRICT_RECEIVE_UNDERFUNDED:
+// case PATH_PAYMENT_STRICT_RECEIVE_SRC_NO_TRUST:
+// case PATH_PAYMENT_STRICT_RECEIVE_SRC_NOT_AUTHORIZED:
+// case PATH_PAYMENT_STRICT_RECEIVE_NO_DESTINATION:
+// case PATH_PAYMENT_STRICT_RECEIVE_NO_TRUST:
+// case PATH_PAYMENT_STRICT_RECEIVE_NOT_AUTHORIZED:
+// case PATH_PAYMENT_STRICT_RECEIVE_LINE_FULL:
+// void;
// case PATH_PAYMENT_STRICT_RECEIVE_NO_ISSUER:
// Asset noIssuer; // the asset that caused the error
-// default:
+// case PATH_PAYMENT_STRICT_RECEIVE_TOO_FEW_OFFERS:
+// case PATH_PAYMENT_STRICT_RECEIVE_OFFER_CROSS_SELF:
+// case PATH_PAYMENT_STRICT_RECEIVE_OVER_SENDMAX:
// void;
// };
@@ -81,8 +97,8 @@ public Builder noIssuer(Asset noIssuer) {
public PathPaymentStrictReceiveResult build() {
PathPaymentStrictReceiveResult val = new PathPaymentStrictReceiveResult();
val.setDiscriminant(discriminant);
- val.setSuccess(success);
- val.setNoIssuer(noIssuer);
+ val.setSuccess(this.success);
+ val.setNoIssuer(this.noIssuer);
return val;
}
}
@@ -99,10 +115,21 @@ public static void encode(
PathPaymentStrictReceiveResultSuccess.encode(
stream, encodedPathPaymentStrictReceiveResult.success);
break;
+ case PATH_PAYMENT_STRICT_RECEIVE_MALFORMED:
+ case PATH_PAYMENT_STRICT_RECEIVE_UNDERFUNDED:
+ case PATH_PAYMENT_STRICT_RECEIVE_SRC_NO_TRUST:
+ case PATH_PAYMENT_STRICT_RECEIVE_SRC_NOT_AUTHORIZED:
+ case PATH_PAYMENT_STRICT_RECEIVE_NO_DESTINATION:
+ case PATH_PAYMENT_STRICT_RECEIVE_NO_TRUST:
+ case PATH_PAYMENT_STRICT_RECEIVE_NOT_AUTHORIZED:
+ case PATH_PAYMENT_STRICT_RECEIVE_LINE_FULL:
+ break;
case PATH_PAYMENT_STRICT_RECEIVE_NO_ISSUER:
Asset.encode(stream, encodedPathPaymentStrictReceiveResult.noIssuer);
break;
- default:
+ case PATH_PAYMENT_STRICT_RECEIVE_TOO_FEW_OFFERS:
+ case PATH_PAYMENT_STRICT_RECEIVE_OFFER_CROSS_SELF:
+ case PATH_PAYMENT_STRICT_RECEIVE_OVER_SENDMAX:
break;
}
}
@@ -123,10 +150,21 @@ public static PathPaymentStrictReceiveResult decode(XdrDataInputStream stream)
decodedPathPaymentStrictReceiveResult.success =
PathPaymentStrictReceiveResultSuccess.decode(stream);
break;
+ case PATH_PAYMENT_STRICT_RECEIVE_MALFORMED:
+ case PATH_PAYMENT_STRICT_RECEIVE_UNDERFUNDED:
+ case PATH_PAYMENT_STRICT_RECEIVE_SRC_NO_TRUST:
+ case PATH_PAYMENT_STRICT_RECEIVE_SRC_NOT_AUTHORIZED:
+ case PATH_PAYMENT_STRICT_RECEIVE_NO_DESTINATION:
+ case PATH_PAYMENT_STRICT_RECEIVE_NO_TRUST:
+ case PATH_PAYMENT_STRICT_RECEIVE_NOT_AUTHORIZED:
+ case PATH_PAYMENT_STRICT_RECEIVE_LINE_FULL:
+ break;
case PATH_PAYMENT_STRICT_RECEIVE_NO_ISSUER:
decodedPathPaymentStrictReceiveResult.noIssuer = Asset.decode(stream);
break;
- default:
+ case PATH_PAYMENT_STRICT_RECEIVE_TOO_FEW_OFFERS:
+ case PATH_PAYMENT_STRICT_RECEIVE_OFFER_CROSS_SELF:
+ case PATH_PAYMENT_STRICT_RECEIVE_OVER_SENDMAX:
break;
}
return decodedPathPaymentStrictReceiveResult;
@@ -134,7 +172,7 @@ public static PathPaymentStrictReceiveResult decode(XdrDataInputStream stream)
@Override
public int hashCode() {
- return Objects.hashCode(this.success, this.noIssuer, this.code);
+ return Objects.hash(this.success, this.noIssuer, this.code);
}
@Override
@@ -144,12 +182,36 @@ public boolean equals(Object object) {
}
PathPaymentStrictReceiveResult other = (PathPaymentStrictReceiveResult) object;
- return Objects.equal(this.success, other.success)
- && Objects.equal(this.noIssuer, other.noIssuer)
- && Objects.equal(this.code, other.code);
+ return Objects.equals(this.success, other.success)
+ && Objects.equals(this.noIssuer, other.noIssuer)
+ && Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PathPaymentStrictReceiveResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PathPaymentStrictReceiveResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
- public static class PathPaymentStrictReceiveResultSuccess {
+ public static class PathPaymentStrictReceiveResultSuccess implements XdrElement {
public PathPaymentStrictReceiveResultSuccess() {}
private ClaimAtom[] offers;
@@ -203,7 +265,7 @@ public static PathPaymentStrictReceiveResultSuccess decode(XdrDataInputStream st
@Override
public int hashCode() {
- return Objects.hashCode(Arrays.hashCode(this.offers), this.last);
+ return Objects.hash(Arrays.hashCode(this.offers), this.last);
}
@Override
@@ -213,7 +275,33 @@ public boolean equals(Object object) {
}
PathPaymentStrictReceiveResultSuccess other = (PathPaymentStrictReceiveResultSuccess) object;
- return Arrays.equals(this.offers, other.offers) && Objects.equal(this.last, other.last);
+ return Arrays.equals(this.offers, other.offers) && Objects.equals(this.last, other.last);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PathPaymentStrictReceiveResultSuccess fromXdrBase64(String xdr)
+ throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PathPaymentStrictReceiveResultSuccess fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -232,8 +320,8 @@ public Builder last(SimplePaymentResult last) {
public PathPaymentStrictReceiveResultSuccess build() {
PathPaymentStrictReceiveResultSuccess val = new PathPaymentStrictReceiveResultSuccess();
- val.setOffers(offers);
- val.setLast(last);
+ val.setOffers(this.offers);
+ val.setLast(this.last);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictReceiveResultCode.java b/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictReceiveResultCode.java
index 747fef139..a3690e156 100644
--- a/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictReceiveResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictReceiveResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -105,4 +110,28 @@ public static void encode(XdrDataOutputStream stream, PathPaymentStrictReceiveRe
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PathPaymentStrictReceiveResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PathPaymentStrictReceiveResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictSendOp.java b/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictSendOp.java
index a48866ec0..f1dab1086 100644
--- a/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictSendOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictSendOp.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -123,7 +128,7 @@ public static PathPaymentStrictSendOp decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.sendAsset,
this.sendAmount,
this.destination,
@@ -139,14 +144,38 @@ public boolean equals(Object object) {
}
PathPaymentStrictSendOp other = (PathPaymentStrictSendOp) object;
- return Objects.equal(this.sendAsset, other.sendAsset)
- && Objects.equal(this.sendAmount, other.sendAmount)
- && Objects.equal(this.destination, other.destination)
- && Objects.equal(this.destAsset, other.destAsset)
- && Objects.equal(this.destMin, other.destMin)
+ return Objects.equals(this.sendAsset, other.sendAsset)
+ && Objects.equals(this.sendAmount, other.sendAmount)
+ && Objects.equals(this.destination, other.destination)
+ && Objects.equals(this.destAsset, other.destAsset)
+ && Objects.equals(this.destMin, other.destMin)
&& Arrays.equals(this.path, other.path);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PathPaymentStrictSendOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PathPaymentStrictSendOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private Asset sendAsset;
private Int64 sendAmount;
@@ -187,12 +216,12 @@ public Builder path(Asset[] path) {
public PathPaymentStrictSendOp build() {
PathPaymentStrictSendOp val = new PathPaymentStrictSendOp();
- val.setSendAsset(sendAsset);
- val.setSendAmount(sendAmount);
- val.setDestination(destination);
- val.setDestAsset(destAsset);
- val.setDestMin(destMin);
- val.setPath(path);
+ val.setSendAsset(this.sendAsset);
+ val.setSendAmount(this.sendAmount);
+ val.setDestination(this.destination);
+ val.setDestAsset(this.destAsset);
+ val.setDestMin(this.destMin);
+ val.setPath(this.path);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictSendResult.java b/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictSendResult.java
index f6a651fa2..3346740cc 100644
--- a/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictSendResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictSendResult.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -17,9 +22,20 @@
// ClaimAtom offers<>;
// SimplePaymentResult last;
// } success;
+// case PATH_PAYMENT_STRICT_SEND_MALFORMED:
+// case PATH_PAYMENT_STRICT_SEND_UNDERFUNDED:
+// case PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST:
+// case PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED:
+// case PATH_PAYMENT_STRICT_SEND_NO_DESTINATION:
+// case PATH_PAYMENT_STRICT_SEND_NO_TRUST:
+// case PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED:
+// case PATH_PAYMENT_STRICT_SEND_LINE_FULL:
+// void;
// case PATH_PAYMENT_STRICT_SEND_NO_ISSUER:
// Asset noIssuer; // the asset that caused the error
-// default:
+// case PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS:
+// case PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF:
+// case PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN:
// void;
// };
@@ -80,8 +96,8 @@ public Builder noIssuer(Asset noIssuer) {
public PathPaymentStrictSendResult build() {
PathPaymentStrictSendResult val = new PathPaymentStrictSendResult();
val.setDiscriminant(discriminant);
- val.setSuccess(success);
- val.setNoIssuer(noIssuer);
+ val.setSuccess(this.success);
+ val.setNoIssuer(this.noIssuer);
return val;
}
}
@@ -97,10 +113,21 @@ public static void encode(
PathPaymentStrictSendResultSuccess.encode(
stream, encodedPathPaymentStrictSendResult.success);
break;
+ case PATH_PAYMENT_STRICT_SEND_MALFORMED:
+ case PATH_PAYMENT_STRICT_SEND_UNDERFUNDED:
+ case PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST:
+ case PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED:
+ case PATH_PAYMENT_STRICT_SEND_NO_DESTINATION:
+ case PATH_PAYMENT_STRICT_SEND_NO_TRUST:
+ case PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED:
+ case PATH_PAYMENT_STRICT_SEND_LINE_FULL:
+ break;
case PATH_PAYMENT_STRICT_SEND_NO_ISSUER:
Asset.encode(stream, encodedPathPaymentStrictSendResult.noIssuer);
break;
- default:
+ case PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS:
+ case PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF:
+ case PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN:
break;
}
}
@@ -119,10 +146,21 @@ public static PathPaymentStrictSendResult decode(XdrDataInputStream stream) thro
decodedPathPaymentStrictSendResult.success =
PathPaymentStrictSendResultSuccess.decode(stream);
break;
+ case PATH_PAYMENT_STRICT_SEND_MALFORMED:
+ case PATH_PAYMENT_STRICT_SEND_UNDERFUNDED:
+ case PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST:
+ case PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED:
+ case PATH_PAYMENT_STRICT_SEND_NO_DESTINATION:
+ case PATH_PAYMENT_STRICT_SEND_NO_TRUST:
+ case PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED:
+ case PATH_PAYMENT_STRICT_SEND_LINE_FULL:
+ break;
case PATH_PAYMENT_STRICT_SEND_NO_ISSUER:
decodedPathPaymentStrictSendResult.noIssuer = Asset.decode(stream);
break;
- default:
+ case PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS:
+ case PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF:
+ case PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN:
break;
}
return decodedPathPaymentStrictSendResult;
@@ -130,7 +168,7 @@ public static PathPaymentStrictSendResult decode(XdrDataInputStream stream) thro
@Override
public int hashCode() {
- return Objects.hashCode(this.success, this.noIssuer, this.code);
+ return Objects.hash(this.success, this.noIssuer, this.code);
}
@Override
@@ -140,12 +178,36 @@ public boolean equals(Object object) {
}
PathPaymentStrictSendResult other = (PathPaymentStrictSendResult) object;
- return Objects.equal(this.success, other.success)
- && Objects.equal(this.noIssuer, other.noIssuer)
- && Objects.equal(this.code, other.code);
+ return Objects.equals(this.success, other.success)
+ && Objects.equals(this.noIssuer, other.noIssuer)
+ && Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
}
- public static class PathPaymentStrictSendResultSuccess {
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PathPaymentStrictSendResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PathPaymentStrictSendResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static class PathPaymentStrictSendResultSuccess implements XdrElement {
public PathPaymentStrictSendResultSuccess() {}
private ClaimAtom[] offers;
@@ -199,7 +261,7 @@ public static PathPaymentStrictSendResultSuccess decode(XdrDataInputStream strea
@Override
public int hashCode() {
- return Objects.hashCode(Arrays.hashCode(this.offers), this.last);
+ return Objects.hash(Arrays.hashCode(this.offers), this.last);
}
@Override
@@ -209,7 +271,32 @@ public boolean equals(Object object) {
}
PathPaymentStrictSendResultSuccess other = (PathPaymentStrictSendResultSuccess) object;
- return Arrays.equals(this.offers, other.offers) && Objects.equal(this.last, other.last);
+ return Arrays.equals(this.offers, other.offers) && Objects.equals(this.last, other.last);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PathPaymentStrictSendResultSuccess fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PathPaymentStrictSendResultSuccess fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -228,8 +315,8 @@ public Builder last(SimplePaymentResult last) {
public PathPaymentStrictSendResultSuccess build() {
PathPaymentStrictSendResultSuccess val = new PathPaymentStrictSendResultSuccess();
- val.setOffers(offers);
- val.setLast(last);
+ val.setOffers(this.offers);
+ val.setLast(this.last);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictSendResultCode.java b/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictSendResultCode.java
index b36ebc2f5..e4624b50b 100644
--- a/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictSendResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/PathPaymentStrictSendResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -104,4 +109,28 @@ public static void encode(XdrDataOutputStream stream, PathPaymentStrictSendResul
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PathPaymentStrictSendResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PathPaymentStrictSendResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PaymentOp.java b/src/main/java/org/stellar/sdk/xdr/PaymentOp.java
index 464ad86b2..28fe5418a 100644
--- a/src/main/java/org/stellar/sdk/xdr/PaymentOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/PaymentOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -70,7 +75,7 @@ public static PaymentOp decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.destination, this.asset, this.amount);
+ return Objects.hash(this.destination, this.asset, this.amount);
}
@Override
@@ -80,9 +85,33 @@ public boolean equals(Object object) {
}
PaymentOp other = (PaymentOp) object;
- return Objects.equal(this.destination, other.destination)
- && Objects.equal(this.asset, other.asset)
- && Objects.equal(this.amount, other.amount);
+ return Objects.equals(this.destination, other.destination)
+ && Objects.equals(this.asset, other.asset)
+ && Objects.equals(this.amount, other.amount);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PaymentOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PaymentOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -107,9 +136,9 @@ public Builder amount(Int64 amount) {
public PaymentOp build() {
PaymentOp val = new PaymentOp();
- val.setDestination(destination);
- val.setAsset(asset);
- val.setAmount(amount);
+ val.setDestination(this.destination);
+ val.setAsset(this.asset);
+ val.setAmount(this.amount);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PaymentResult.java b/src/main/java/org/stellar/sdk/xdr/PaymentResult.java
index 142c425a4..35a798897 100644
--- a/src/main/java/org/stellar/sdk/xdr/PaymentResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/PaymentResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,15 @@
// {
// case PAYMENT_SUCCESS:
// void;
-// default:
+// case PAYMENT_MALFORMED:
+// case PAYMENT_UNDERFUNDED:
+// case PAYMENT_SRC_NO_TRUST:
+// case PAYMENT_SRC_NOT_AUTHORIZED:
+// case PAYMENT_NO_DESTINATION:
+// case PAYMENT_NO_TRUST:
+// case PAYMENT_NOT_AUTHORIZED:
+// case PAYMENT_LINE_FULL:
+// case PAYMENT_NO_ISSUER:
// void;
// };
@@ -53,7 +66,15 @@ public static void encode(XdrDataOutputStream stream, PaymentResult encodedPayme
switch (encodedPaymentResult.getDiscriminant()) {
case PAYMENT_SUCCESS:
break;
- default:
+ case PAYMENT_MALFORMED:
+ case PAYMENT_UNDERFUNDED:
+ case PAYMENT_SRC_NO_TRUST:
+ case PAYMENT_SRC_NOT_AUTHORIZED:
+ case PAYMENT_NO_DESTINATION:
+ case PAYMENT_NO_TRUST:
+ case PAYMENT_NOT_AUTHORIZED:
+ case PAYMENT_LINE_FULL:
+ case PAYMENT_NO_ISSUER:
break;
}
}
@@ -69,7 +90,15 @@ public static PaymentResult decode(XdrDataInputStream stream) throws IOException
switch (decodedPaymentResult.getDiscriminant()) {
case PAYMENT_SUCCESS:
break;
- default:
+ case PAYMENT_MALFORMED:
+ case PAYMENT_UNDERFUNDED:
+ case PAYMENT_SRC_NO_TRUST:
+ case PAYMENT_SRC_NOT_AUTHORIZED:
+ case PAYMENT_NO_DESTINATION:
+ case PAYMENT_NO_TRUST:
+ case PAYMENT_NOT_AUTHORIZED:
+ case PAYMENT_LINE_FULL:
+ case PAYMENT_NO_ISSUER:
break;
}
return decodedPaymentResult;
@@ -77,7 +106,7 @@ public static PaymentResult decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -87,6 +116,30 @@ public boolean equals(Object object) {
}
PaymentResult other = (PaymentResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PaymentResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PaymentResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PaymentResultCode.java b/src/main/java/org/stellar/sdk/xdr/PaymentResultCode.java
index 358957e37..5bd68c860 100644
--- a/src/main/java/org/stellar/sdk/xdr/PaymentResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/PaymentResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -83,4 +88,28 @@ public static void encode(XdrDataOutputStream stream, PaymentResultCode value)
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PaymentResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PaymentResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PeerAddress.java b/src/main/java/org/stellar/sdk/xdr/PeerAddress.java
index 69b015d18..97f2421b4 100644
--- a/src/main/java/org/stellar/sdk/xdr/PeerAddress.java
+++ b/src/main/java/org/stellar/sdk/xdr/PeerAddress.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -78,7 +83,7 @@ public static PeerAddress decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.ip, this.port, this.numFailures);
+ return Objects.hash(this.ip, this.port, this.numFailures);
}
@Override
@@ -88,9 +93,33 @@ public boolean equals(Object object) {
}
PeerAddress other = (PeerAddress) object;
- return Objects.equal(this.ip, other.ip)
- && Objects.equal(this.port, other.port)
- && Objects.equal(this.numFailures, other.numFailures);
+ return Objects.equals(this.ip, other.ip)
+ && Objects.equals(this.port, other.port)
+ && Objects.equals(this.numFailures, other.numFailures);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PeerAddress fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PeerAddress fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -115,14 +144,14 @@ public Builder numFailures(Uint32 numFailures) {
public PeerAddress build() {
PeerAddress val = new PeerAddress();
- val.setIp(ip);
- val.setPort(port);
- val.setNumFailures(numFailures);
+ val.setIp(this.ip);
+ val.setPort(this.port);
+ val.setNumFailures(this.numFailures);
return val;
}
}
- public static class PeerAddressIp {
+ public static class PeerAddressIp implements XdrElement {
public PeerAddressIp() {}
IPAddrType type;
@@ -178,8 +207,8 @@ public Builder ipv6(byte[] ipv6) {
public PeerAddressIp build() {
PeerAddressIp val = new PeerAddressIp();
val.setDiscriminant(discriminant);
- val.setIpv4(ipv4);
- val.setIpv6(ipv6);
+ val.setIpv4(this.ipv4);
+ val.setIpv6(this.ipv6);
return val;
}
}
@@ -226,7 +255,7 @@ public static PeerAddressIp decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(Arrays.hashCode(this.ipv4), Arrays.hashCode(this.ipv6), this.type);
+ return Objects.hash(Arrays.hashCode(this.ipv4), Arrays.hashCode(this.ipv6), this.type);
}
@Override
@@ -238,7 +267,31 @@ public boolean equals(Object object) {
PeerAddressIp other = (PeerAddressIp) object;
return Arrays.equals(this.ipv4, other.ipv4)
&& Arrays.equals(this.ipv6, other.ipv6)
- && Objects.equal(this.type, other.type);
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PeerAddressIp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PeerAddressIp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PeerStatList.java b/src/main/java/org/stellar/sdk/xdr/PeerStatList.java
index 0e3b4d7b1..4065a0d27 100644
--- a/src/main/java/org/stellar/sdk/xdr/PeerStatList.java
+++ b/src/main/java/org/stellar/sdk/xdr/PeerStatList.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -65,4 +70,28 @@ public boolean equals(Object object) {
PeerStatList other = (PeerStatList) object;
return Arrays.equals(this.PeerStatList, other.PeerStatList);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PeerStatList fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PeerStatList fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PeerStats.java b/src/main/java/org/stellar/sdk/xdr/PeerStats.java
index 25d8cee6e..ac31be23b 100644
--- a/src/main/java/org/stellar/sdk/xdr/PeerStats.java
+++ b/src/main/java/org/stellar/sdk/xdr/PeerStats.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -228,7 +233,7 @@ public static PeerStats decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.id,
this.versionStr,
this.messagesRead,
@@ -253,21 +258,45 @@ public boolean equals(Object object) {
}
PeerStats other = (PeerStats) object;
- return Objects.equal(this.id, other.id)
- && Objects.equal(this.versionStr, other.versionStr)
- && Objects.equal(this.messagesRead, other.messagesRead)
- && Objects.equal(this.messagesWritten, other.messagesWritten)
- && Objects.equal(this.bytesRead, other.bytesRead)
- && Objects.equal(this.bytesWritten, other.bytesWritten)
- && Objects.equal(this.secondsConnected, other.secondsConnected)
- && Objects.equal(this.uniqueFloodBytesRecv, other.uniqueFloodBytesRecv)
- && Objects.equal(this.duplicateFloodBytesRecv, other.duplicateFloodBytesRecv)
- && Objects.equal(this.uniqueFetchBytesRecv, other.uniqueFetchBytesRecv)
- && Objects.equal(this.duplicateFetchBytesRecv, other.duplicateFetchBytesRecv)
- && Objects.equal(this.uniqueFloodMessageRecv, other.uniqueFloodMessageRecv)
- && Objects.equal(this.duplicateFloodMessageRecv, other.duplicateFloodMessageRecv)
- && Objects.equal(this.uniqueFetchMessageRecv, other.uniqueFetchMessageRecv)
- && Objects.equal(this.duplicateFetchMessageRecv, other.duplicateFetchMessageRecv);
+ return Objects.equals(this.id, other.id)
+ && Objects.equals(this.versionStr, other.versionStr)
+ && Objects.equals(this.messagesRead, other.messagesRead)
+ && Objects.equals(this.messagesWritten, other.messagesWritten)
+ && Objects.equals(this.bytesRead, other.bytesRead)
+ && Objects.equals(this.bytesWritten, other.bytesWritten)
+ && Objects.equals(this.secondsConnected, other.secondsConnected)
+ && Objects.equals(this.uniqueFloodBytesRecv, other.uniqueFloodBytesRecv)
+ && Objects.equals(this.duplicateFloodBytesRecv, other.duplicateFloodBytesRecv)
+ && Objects.equals(this.uniqueFetchBytesRecv, other.uniqueFetchBytesRecv)
+ && Objects.equals(this.duplicateFetchBytesRecv, other.duplicateFetchBytesRecv)
+ && Objects.equals(this.uniqueFloodMessageRecv, other.uniqueFloodMessageRecv)
+ && Objects.equals(this.duplicateFloodMessageRecv, other.duplicateFloodMessageRecv)
+ && Objects.equals(this.uniqueFetchMessageRecv, other.uniqueFetchMessageRecv)
+ && Objects.equals(this.duplicateFetchMessageRecv, other.duplicateFetchMessageRecv);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PeerStats fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PeerStats fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -364,21 +393,21 @@ public Builder duplicateFetchMessageRecv(Uint64 duplicateFetchMessageRecv) {
public PeerStats build() {
PeerStats val = new PeerStats();
- val.setId(id);
- val.setVersionStr(versionStr);
- val.setMessagesRead(messagesRead);
- val.setMessagesWritten(messagesWritten);
- val.setBytesRead(bytesRead);
- val.setBytesWritten(bytesWritten);
- val.setSecondsConnected(secondsConnected);
- val.setUniqueFloodBytesRecv(uniqueFloodBytesRecv);
- val.setDuplicateFloodBytesRecv(duplicateFloodBytesRecv);
- val.setUniqueFetchBytesRecv(uniqueFetchBytesRecv);
- val.setDuplicateFetchBytesRecv(duplicateFetchBytesRecv);
- val.setUniqueFloodMessageRecv(uniqueFloodMessageRecv);
- val.setDuplicateFloodMessageRecv(duplicateFloodMessageRecv);
- val.setUniqueFetchMessageRecv(uniqueFetchMessageRecv);
- val.setDuplicateFetchMessageRecv(duplicateFetchMessageRecv);
+ val.setId(this.id);
+ val.setVersionStr(this.versionStr);
+ val.setMessagesRead(this.messagesRead);
+ val.setMessagesWritten(this.messagesWritten);
+ val.setBytesRead(this.bytesRead);
+ val.setBytesWritten(this.bytesWritten);
+ val.setSecondsConnected(this.secondsConnected);
+ val.setUniqueFloodBytesRecv(this.uniqueFloodBytesRecv);
+ val.setDuplicateFloodBytesRecv(this.duplicateFloodBytesRecv);
+ val.setUniqueFetchBytesRecv(this.uniqueFetchBytesRecv);
+ val.setDuplicateFetchBytesRecv(this.duplicateFetchBytesRecv);
+ val.setUniqueFloodMessageRecv(this.uniqueFloodMessageRecv);
+ val.setDuplicateFloodMessageRecv(this.duplicateFloodMessageRecv);
+ val.setUniqueFetchMessageRecv(this.uniqueFetchMessageRecv);
+ val.setDuplicateFetchMessageRecv(this.duplicateFetchMessageRecv);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PersistedSCPState.java b/src/main/java/org/stellar/sdk/xdr/PersistedSCPState.java
new file mode 100644
index 000000000..5094b3fd0
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/PersistedSCPState.java
@@ -0,0 +1,161 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union PersistedSCPState switch (int v)
+// {
+// case 0:
+// PersistedSCPStateV0 v0;
+// case 1:
+// PersistedSCPStateV1 v1;
+// };
+
+// ===========================================================================
+public class PersistedSCPState implements XdrElement {
+ public PersistedSCPState() {}
+
+ Integer v;
+
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+
+ private PersistedSCPStateV0 v0;
+
+ public PersistedSCPStateV0 getV0() {
+ return this.v0;
+ }
+
+ public void setV0(PersistedSCPStateV0 value) {
+ this.v0 = value;
+ }
+
+ private PersistedSCPStateV1 v1;
+
+ public PersistedSCPStateV1 getV1() {
+ return this.v1;
+ }
+
+ public void setV1(PersistedSCPStateV1 value) {
+ this.v1 = value;
+ }
+
+ public static final class Builder {
+ private Integer discriminant;
+ private PersistedSCPStateV0 v0;
+ private PersistedSCPStateV1 v1;
+
+ public Builder discriminant(Integer discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder v0(PersistedSCPStateV0 v0) {
+ this.v0 = v0;
+ return this;
+ }
+
+ public Builder v1(PersistedSCPStateV1 v1) {
+ this.v1 = v1;
+ return this;
+ }
+
+ public PersistedSCPState build() {
+ PersistedSCPState val = new PersistedSCPState();
+ val.setDiscriminant(discriminant);
+ val.setV0(this.v0);
+ val.setV1(this.v1);
+ return val;
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, PersistedSCPState encodedPersistedSCPState)
+ throws IOException {
+ // Xdrgen::AST::Typespecs::Int
+ // Integer
+ stream.writeInt(encodedPersistedSCPState.getDiscriminant().intValue());
+ switch (encodedPersistedSCPState.getDiscriminant()) {
+ case 0:
+ PersistedSCPStateV0.encode(stream, encodedPersistedSCPState.v0);
+ break;
+ case 1:
+ PersistedSCPStateV1.encode(stream, encodedPersistedSCPState.v1);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static PersistedSCPState decode(XdrDataInputStream stream) throws IOException {
+ PersistedSCPState decodedPersistedSCPState = new PersistedSCPState();
+ Integer discriminant = stream.readInt();
+ decodedPersistedSCPState.setDiscriminant(discriminant);
+ switch (decodedPersistedSCPState.getDiscriminant()) {
+ case 0:
+ decodedPersistedSCPState.v0 = PersistedSCPStateV0.decode(stream);
+ break;
+ case 1:
+ decodedPersistedSCPState.v1 = PersistedSCPStateV1.decode(stream);
+ break;
+ }
+ return decodedPersistedSCPState;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.v0, this.v1, this.v);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof PersistedSCPState)) {
+ return false;
+ }
+
+ PersistedSCPState other = (PersistedSCPState) object;
+ return Objects.equals(this.v0, other.v0)
+ && Objects.equals(this.v1, other.v1)
+ && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PersistedSCPState fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PersistedSCPState fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/PersistedSCPStateV0.java b/src/main/java/org/stellar/sdk/xdr/PersistedSCPStateV0.java
new file mode 100644
index 000000000..b2021a440
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/PersistedSCPStateV0.java
@@ -0,0 +1,174 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct PersistedSCPStateV0
+// {
+// SCPEnvelope scpEnvelopes<>;
+// SCPQuorumSet quorumSets<>;
+// StoredTransactionSet txSets<>;
+// };
+
+// ===========================================================================
+public class PersistedSCPStateV0 implements XdrElement {
+ public PersistedSCPStateV0() {}
+
+ private SCPEnvelope[] scpEnvelopes;
+
+ public SCPEnvelope[] getScpEnvelopes() {
+ return this.scpEnvelopes;
+ }
+
+ public void setScpEnvelopes(SCPEnvelope[] value) {
+ this.scpEnvelopes = value;
+ }
+
+ private SCPQuorumSet[] quorumSets;
+
+ public SCPQuorumSet[] getQuorumSets() {
+ return this.quorumSets;
+ }
+
+ public void setQuorumSets(SCPQuorumSet[] value) {
+ this.quorumSets = value;
+ }
+
+ private StoredTransactionSet[] txSets;
+
+ public StoredTransactionSet[] getTxSets() {
+ return this.txSets;
+ }
+
+ public void setTxSets(StoredTransactionSet[] value) {
+ this.txSets = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, PersistedSCPStateV0 encodedPersistedSCPStateV0)
+ throws IOException {
+ int scpEnvelopessize = encodedPersistedSCPStateV0.getScpEnvelopes().length;
+ stream.writeInt(scpEnvelopessize);
+ for (int i = 0; i < scpEnvelopessize; i++) {
+ SCPEnvelope.encode(stream, encodedPersistedSCPStateV0.scpEnvelopes[i]);
+ }
+ int quorumSetssize = encodedPersistedSCPStateV0.getQuorumSets().length;
+ stream.writeInt(quorumSetssize);
+ for (int i = 0; i < quorumSetssize; i++) {
+ SCPQuorumSet.encode(stream, encodedPersistedSCPStateV0.quorumSets[i]);
+ }
+ int txSetssize = encodedPersistedSCPStateV0.getTxSets().length;
+ stream.writeInt(txSetssize);
+ for (int i = 0; i < txSetssize; i++) {
+ StoredTransactionSet.encode(stream, encodedPersistedSCPStateV0.txSets[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static PersistedSCPStateV0 decode(XdrDataInputStream stream) throws IOException {
+ PersistedSCPStateV0 decodedPersistedSCPStateV0 = new PersistedSCPStateV0();
+ int scpEnvelopessize = stream.readInt();
+ decodedPersistedSCPStateV0.scpEnvelopes = new SCPEnvelope[scpEnvelopessize];
+ for (int i = 0; i < scpEnvelopessize; i++) {
+ decodedPersistedSCPStateV0.scpEnvelopes[i] = SCPEnvelope.decode(stream);
+ }
+ int quorumSetssize = stream.readInt();
+ decodedPersistedSCPStateV0.quorumSets = new SCPQuorumSet[quorumSetssize];
+ for (int i = 0; i < quorumSetssize; i++) {
+ decodedPersistedSCPStateV0.quorumSets[i] = SCPQuorumSet.decode(stream);
+ }
+ int txSetssize = stream.readInt();
+ decodedPersistedSCPStateV0.txSets = new StoredTransactionSet[txSetssize];
+ for (int i = 0; i < txSetssize; i++) {
+ decodedPersistedSCPStateV0.txSets[i] = StoredTransactionSet.decode(stream);
+ }
+ return decodedPersistedSCPStateV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ Arrays.hashCode(this.scpEnvelopes),
+ Arrays.hashCode(this.quorumSets),
+ Arrays.hashCode(this.txSets));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof PersistedSCPStateV0)) {
+ return false;
+ }
+
+ PersistedSCPStateV0 other = (PersistedSCPStateV0) object;
+ return Arrays.equals(this.scpEnvelopes, other.scpEnvelopes)
+ && Arrays.equals(this.quorumSets, other.quorumSets)
+ && Arrays.equals(this.txSets, other.txSets);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PersistedSCPStateV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PersistedSCPStateV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCPEnvelope[] scpEnvelopes;
+ private SCPQuorumSet[] quorumSets;
+ private StoredTransactionSet[] txSets;
+
+ public Builder scpEnvelopes(SCPEnvelope[] scpEnvelopes) {
+ this.scpEnvelopes = scpEnvelopes;
+ return this;
+ }
+
+ public Builder quorumSets(SCPQuorumSet[] quorumSets) {
+ this.quorumSets = quorumSets;
+ return this;
+ }
+
+ public Builder txSets(StoredTransactionSet[] txSets) {
+ this.txSets = txSets;
+ return this;
+ }
+
+ public PersistedSCPStateV0 build() {
+ PersistedSCPStateV0 val = new PersistedSCPStateV0();
+ val.setScpEnvelopes(this.scpEnvelopes);
+ val.setQuorumSets(this.quorumSets);
+ val.setTxSets(this.txSets);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/PersistedSCPStateV1.java b/src/main/java/org/stellar/sdk/xdr/PersistedSCPStateV1.java
new file mode 100644
index 000000000..ca660fa19
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/PersistedSCPStateV1.java
@@ -0,0 +1,143 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct PersistedSCPStateV1
+// {
+// // Tx sets are saved separately
+// SCPEnvelope scpEnvelopes<>;
+// SCPQuorumSet quorumSets<>;
+// };
+
+// ===========================================================================
+public class PersistedSCPStateV1 implements XdrElement {
+ public PersistedSCPStateV1() {}
+
+ private SCPEnvelope[] scpEnvelopes;
+
+ public SCPEnvelope[] getScpEnvelopes() {
+ return this.scpEnvelopes;
+ }
+
+ public void setScpEnvelopes(SCPEnvelope[] value) {
+ this.scpEnvelopes = value;
+ }
+
+ private SCPQuorumSet[] quorumSets;
+
+ public SCPQuorumSet[] getQuorumSets() {
+ return this.quorumSets;
+ }
+
+ public void setQuorumSets(SCPQuorumSet[] value) {
+ this.quorumSets = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, PersistedSCPStateV1 encodedPersistedSCPStateV1)
+ throws IOException {
+ int scpEnvelopessize = encodedPersistedSCPStateV1.getScpEnvelopes().length;
+ stream.writeInt(scpEnvelopessize);
+ for (int i = 0; i < scpEnvelopessize; i++) {
+ SCPEnvelope.encode(stream, encodedPersistedSCPStateV1.scpEnvelopes[i]);
+ }
+ int quorumSetssize = encodedPersistedSCPStateV1.getQuorumSets().length;
+ stream.writeInt(quorumSetssize);
+ for (int i = 0; i < quorumSetssize; i++) {
+ SCPQuorumSet.encode(stream, encodedPersistedSCPStateV1.quorumSets[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static PersistedSCPStateV1 decode(XdrDataInputStream stream) throws IOException {
+ PersistedSCPStateV1 decodedPersistedSCPStateV1 = new PersistedSCPStateV1();
+ int scpEnvelopessize = stream.readInt();
+ decodedPersistedSCPStateV1.scpEnvelopes = new SCPEnvelope[scpEnvelopessize];
+ for (int i = 0; i < scpEnvelopessize; i++) {
+ decodedPersistedSCPStateV1.scpEnvelopes[i] = SCPEnvelope.decode(stream);
+ }
+ int quorumSetssize = stream.readInt();
+ decodedPersistedSCPStateV1.quorumSets = new SCPQuorumSet[quorumSetssize];
+ for (int i = 0; i < quorumSetssize; i++) {
+ decodedPersistedSCPStateV1.quorumSets[i] = SCPQuorumSet.decode(stream);
+ }
+ return decodedPersistedSCPStateV1;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(Arrays.hashCode(this.scpEnvelopes), Arrays.hashCode(this.quorumSets));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof PersistedSCPStateV1)) {
+ return false;
+ }
+
+ PersistedSCPStateV1 other = (PersistedSCPStateV1) object;
+ return Arrays.equals(this.scpEnvelopes, other.scpEnvelopes)
+ && Arrays.equals(this.quorumSets, other.quorumSets);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PersistedSCPStateV1 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PersistedSCPStateV1 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCPEnvelope[] scpEnvelopes;
+ private SCPQuorumSet[] quorumSets;
+
+ public Builder scpEnvelopes(SCPEnvelope[] scpEnvelopes) {
+ this.scpEnvelopes = scpEnvelopes;
+ return this;
+ }
+
+ public Builder quorumSets(SCPQuorumSet[] quorumSets) {
+ this.quorumSets = quorumSets;
+ return this;
+ }
+
+ public PersistedSCPStateV1 build() {
+ PersistedSCPStateV1 val = new PersistedSCPStateV1();
+ val.setScpEnvelopes(this.scpEnvelopes);
+ val.setQuorumSets(this.quorumSets);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/PoolID.java b/src/main/java/org/stellar/sdk/xdr/PoolID.java
index 331258e41..dcf3f8b9c 100644
--- a/src/main/java/org/stellar/sdk/xdr/PoolID.java
+++ b/src/main/java/org/stellar/sdk/xdr/PoolID.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -44,7 +49,7 @@ public static PoolID decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.PoolID);
+ return Objects.hash(this.PoolID);
}
@Override
@@ -54,6 +59,30 @@ public boolean equals(Object object) {
}
PoolID other = (PoolID) object;
- return Objects.equal(this.PoolID, other.PoolID);
+ return Objects.equals(this.PoolID, other.PoolID);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PoolID fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PoolID fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PreconditionType.java b/src/main/java/org/stellar/sdk/xdr/PreconditionType.java
index f3fe2e325..0c0baa105 100644
--- a/src/main/java/org/stellar/sdk/xdr/PreconditionType.java
+++ b/src/main/java/org/stellar/sdk/xdr/PreconditionType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -51,4 +56,28 @@ public static void encode(XdrDataOutputStream stream, PreconditionType value) th
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PreconditionType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PreconditionType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Preconditions.java b/src/main/java/org/stellar/sdk/xdr/Preconditions.java
index fd1e44c92..f50752ae5 100644
--- a/src/main/java/org/stellar/sdk/xdr/Preconditions.java
+++ b/src/main/java/org/stellar/sdk/xdr/Preconditions.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -75,8 +80,8 @@ public Builder v2(PreconditionsV2 v2) {
public Preconditions build() {
Preconditions val = new Preconditions();
val.setDiscriminant(discriminant);
- val.setTimeBounds(timeBounds);
- val.setV2(v2);
+ val.setTimeBounds(this.timeBounds);
+ val.setV2(this.v2);
return val;
}
}
@@ -121,7 +126,7 @@ public static Preconditions decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(this.timeBounds, this.v2, this.type);
+ return Objects.hash(this.timeBounds, this.v2, this.type);
}
@Override
@@ -131,8 +136,32 @@ public boolean equals(Object object) {
}
Preconditions other = (Preconditions) object;
- return Objects.equal(this.timeBounds, other.timeBounds)
- && Objects.equal(this.v2, other.v2)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.timeBounds, other.timeBounds)
+ && Objects.equals(this.v2, other.v2)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Preconditions fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Preconditions fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PreconditionsV2.java b/src/main/java/org/stellar/sdk/xdr/PreconditionsV2.java
index 566540e0a..80f001c7a 100644
--- a/src/main/java/org/stellar/sdk/xdr/PreconditionsV2.java
+++ b/src/main/java/org/stellar/sdk/xdr/PreconditionsV2.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -165,7 +170,7 @@ public static PreconditionsV2 decode(XdrDataInputStream stream) throws IOExcepti
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.timeBounds,
this.ledgerBounds,
this.minSeqNum,
@@ -181,14 +186,38 @@ public boolean equals(Object object) {
}
PreconditionsV2 other = (PreconditionsV2) object;
- return Objects.equal(this.timeBounds, other.timeBounds)
- && Objects.equal(this.ledgerBounds, other.ledgerBounds)
- && Objects.equal(this.minSeqNum, other.minSeqNum)
- && Objects.equal(this.minSeqAge, other.minSeqAge)
- && Objects.equal(this.minSeqLedgerGap, other.minSeqLedgerGap)
+ return Objects.equals(this.timeBounds, other.timeBounds)
+ && Objects.equals(this.ledgerBounds, other.ledgerBounds)
+ && Objects.equals(this.minSeqNum, other.minSeqNum)
+ && Objects.equals(this.minSeqAge, other.minSeqAge)
+ && Objects.equals(this.minSeqLedgerGap, other.minSeqLedgerGap)
&& Arrays.equals(this.extraSigners, other.extraSigners);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PreconditionsV2 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PreconditionsV2 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private TimeBounds timeBounds;
private LedgerBounds ledgerBounds;
@@ -229,12 +258,12 @@ public Builder extraSigners(SignerKey[] extraSigners) {
public PreconditionsV2 build() {
PreconditionsV2 val = new PreconditionsV2();
- val.setTimeBounds(timeBounds);
- val.setLedgerBounds(ledgerBounds);
- val.setMinSeqNum(minSeqNum);
- val.setMinSeqAge(minSeqAge);
- val.setMinSeqLedgerGap(minSeqLedgerGap);
- val.setExtraSigners(extraSigners);
+ val.setTimeBounds(this.timeBounds);
+ val.setLedgerBounds(this.ledgerBounds);
+ val.setMinSeqNum(this.minSeqNum);
+ val.setMinSeqAge(this.minSeqAge);
+ val.setMinSeqLedgerGap(this.minSeqLedgerGap);
+ val.setExtraSigners(this.extraSigners);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Price.java b/src/main/java/org/stellar/sdk/xdr/Price.java
index 5c14702be..e3f0da8fb 100644
--- a/src/main/java/org/stellar/sdk/xdr/Price.java
+++ b/src/main/java/org/stellar/sdk/xdr/Price.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -56,7 +61,7 @@ public static Price decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.n, this.d);
+ return Objects.hash(this.n, this.d);
}
@Override
@@ -66,7 +71,31 @@ public boolean equals(Object object) {
}
Price other = (Price) object;
- return Objects.equal(this.n, other.n) && Objects.equal(this.d, other.d);
+ return Objects.equals(this.n, other.n) && Objects.equals(this.d, other.d);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Price fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Price fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -85,8 +114,8 @@ public Builder d(Int32 d) {
public Price build() {
Price val = new Price();
- val.setN(n);
- val.setD(d);
+ val.setN(this.n);
+ val.setD(this.d);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PublicKey.java b/src/main/java/org/stellar/sdk/xdr/PublicKey.java
index eb234db25..1447caac4 100644
--- a/src/main/java/org/stellar/sdk/xdr/PublicKey.java
+++ b/src/main/java/org/stellar/sdk/xdr/PublicKey.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -55,7 +60,7 @@ public Builder ed25519(Uint256 ed25519) {
public PublicKey build() {
PublicKey val = new PublicKey();
val.setDiscriminant(discriminant);
- val.setEd25519(ed25519);
+ val.setEd25519(this.ed25519);
return val;
}
}
@@ -90,7 +95,7 @@ public static PublicKey decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.ed25519, this.type);
+ return Objects.hash(this.ed25519, this.type);
}
@Override
@@ -100,6 +105,30 @@ public boolean equals(Object object) {
}
PublicKey other = (PublicKey) object;
- return Objects.equal(this.ed25519, other.ed25519) && Objects.equal(this.type, other.type);
+ return Objects.equals(this.ed25519, other.ed25519) && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PublicKey fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PublicKey fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/PublicKeyType.java b/src/main/java/org/stellar/sdk/xdr/PublicKeyType.java
index 753384b1b..5bfd65570 100644
--- a/src/main/java/org/stellar/sdk/xdr/PublicKeyType.java
+++ b/src/main/java/org/stellar/sdk/xdr/PublicKeyType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -43,4 +48,28 @@ public static void encode(XdrDataOutputStream stream, PublicKeyType value) throw
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static PublicKeyType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static PublicKeyType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/RestoreFootprintOp.java b/src/main/java/org/stellar/sdk/xdr/RestoreFootprintOp.java
new file mode 100644
index 000000000..ece865ed7
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/RestoreFootprintOp.java
@@ -0,0 +1,103 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct RestoreFootprintOp
+// {
+// ExtensionPoint ext;
+// };
+
+// ===========================================================================
+public class RestoreFootprintOp implements XdrElement {
+ public RestoreFootprintOp() {}
+
+ private ExtensionPoint ext;
+
+ public ExtensionPoint getExt() {
+ return this.ext;
+ }
+
+ public void setExt(ExtensionPoint value) {
+ this.ext = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, RestoreFootprintOp encodedRestoreFootprintOp) throws IOException {
+ ExtensionPoint.encode(stream, encodedRestoreFootprintOp.ext);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static RestoreFootprintOp decode(XdrDataInputStream stream) throws IOException {
+ RestoreFootprintOp decodedRestoreFootprintOp = new RestoreFootprintOp();
+ decodedRestoreFootprintOp.ext = ExtensionPoint.decode(stream);
+ return decodedRestoreFootprintOp;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.ext);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof RestoreFootprintOp)) {
+ return false;
+ }
+
+ RestoreFootprintOp other = (RestoreFootprintOp) object;
+ return Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static RestoreFootprintOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static RestoreFootprintOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ExtensionPoint ext;
+
+ public Builder ext(ExtensionPoint ext) {
+ this.ext = ext;
+ return this;
+ }
+
+ public RestoreFootprintOp build() {
+ RestoreFootprintOp val = new RestoreFootprintOp();
+ val.setExt(this.ext);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/RestoreFootprintResult.java b/src/main/java/org/stellar/sdk/xdr/RestoreFootprintResult.java
new file mode 100644
index 000000000..a01215459
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/RestoreFootprintResult.java
@@ -0,0 +1,128 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union RestoreFootprintResult switch (RestoreFootprintResultCode code)
+// {
+// case RESTORE_FOOTPRINT_SUCCESS:
+// void;
+// case RESTORE_FOOTPRINT_MALFORMED:
+// case RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED:
+// case RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE:
+// void;
+// };
+
+// ===========================================================================
+public class RestoreFootprintResult implements XdrElement {
+ public RestoreFootprintResult() {}
+
+ RestoreFootprintResultCode code;
+
+ public RestoreFootprintResultCode getDiscriminant() {
+ return this.code;
+ }
+
+ public void setDiscriminant(RestoreFootprintResultCode value) {
+ this.code = value;
+ }
+
+ public static final class Builder {
+ private RestoreFootprintResultCode discriminant;
+
+ public Builder discriminant(RestoreFootprintResultCode discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public RestoreFootprintResult build() {
+ RestoreFootprintResult val = new RestoreFootprintResult();
+ val.setDiscriminant(discriminant);
+ return val;
+ }
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, RestoreFootprintResult encodedRestoreFootprintResult)
+ throws IOException {
+ // Xdrgen::AST::Identifier
+ // RestoreFootprintResultCode
+ stream.writeInt(encodedRestoreFootprintResult.getDiscriminant().getValue());
+ switch (encodedRestoreFootprintResult.getDiscriminant()) {
+ case RESTORE_FOOTPRINT_SUCCESS:
+ break;
+ case RESTORE_FOOTPRINT_MALFORMED:
+ case RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED:
+ case RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE:
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static RestoreFootprintResult decode(XdrDataInputStream stream) throws IOException {
+ RestoreFootprintResult decodedRestoreFootprintResult = new RestoreFootprintResult();
+ RestoreFootprintResultCode discriminant = RestoreFootprintResultCode.decode(stream);
+ decodedRestoreFootprintResult.setDiscriminant(discriminant);
+ switch (decodedRestoreFootprintResult.getDiscriminant()) {
+ case RESTORE_FOOTPRINT_SUCCESS:
+ break;
+ case RESTORE_FOOTPRINT_MALFORMED:
+ case RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED:
+ case RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE:
+ break;
+ }
+ return decodedRestoreFootprintResult;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.code);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof RestoreFootprintResult)) {
+ return false;
+ }
+
+ RestoreFootprintResult other = (RestoreFootprintResult) object;
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static RestoreFootprintResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static RestoreFootprintResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/RestoreFootprintResultCode.java b/src/main/java/org/stellar/sdk/xdr/RestoreFootprintResultCode.java
new file mode 100644
index 000000000..e1d0fd3e7
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/RestoreFootprintResultCode.java
@@ -0,0 +1,91 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum RestoreFootprintResultCode
+// {
+// // codes considered as "success" for the operation
+// RESTORE_FOOTPRINT_SUCCESS = 0,
+//
+// // codes considered as "failure" for the operation
+// RESTORE_FOOTPRINT_MALFORMED = -1,
+// RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED = -2,
+// RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE = -3
+// };
+
+// ===========================================================================
+public enum RestoreFootprintResultCode implements XdrElement {
+ RESTORE_FOOTPRINT_SUCCESS(0),
+ RESTORE_FOOTPRINT_MALFORMED(-1),
+ RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED(-2),
+ RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE(-3),
+ ;
+ private int mValue;
+
+ RestoreFootprintResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static RestoreFootprintResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return RESTORE_FOOTPRINT_SUCCESS;
+ case -1:
+ return RESTORE_FOOTPRINT_MALFORMED;
+ case -2:
+ return RESTORE_FOOTPRINT_RESOURCE_LIMIT_EXCEEDED;
+ case -3:
+ return RESTORE_FOOTPRINT_INSUFFICIENT_REFUNDABLE_FEE;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, RestoreFootprintResultCode value)
+ throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static RestoreFootprintResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static RestoreFootprintResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipOp.java b/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipOp.java
index 696acd791..c10a0ba19 100644
--- a/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -77,8 +82,8 @@ public Builder signer(RevokeSponsorshipOpSigner signer) {
public RevokeSponsorshipOp build() {
RevokeSponsorshipOp val = new RevokeSponsorshipOp();
val.setDiscriminant(discriminant);
- val.setLedgerKey(ledgerKey);
- val.setSigner(signer);
+ val.setLedgerKey(this.ledgerKey);
+ val.setSigner(this.signer);
return val;
}
}
@@ -120,7 +125,7 @@ public static RevokeSponsorshipOp decode(XdrDataInputStream stream) throws IOExc
@Override
public int hashCode() {
- return Objects.hashCode(this.ledgerKey, this.signer, this.type);
+ return Objects.hash(this.ledgerKey, this.signer, this.type);
}
@Override
@@ -130,12 +135,36 @@ public boolean equals(Object object) {
}
RevokeSponsorshipOp other = (RevokeSponsorshipOp) object;
- return Objects.equal(this.ledgerKey, other.ledgerKey)
- && Objects.equal(this.signer, other.signer)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.ledgerKey, other.ledgerKey)
+ && Objects.equals(this.signer, other.signer)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static RevokeSponsorshipOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static RevokeSponsorshipOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
- public static class RevokeSponsorshipOpSigner {
+ public static class RevokeSponsorshipOpSigner implements XdrElement {
public RevokeSponsorshipOpSigner() {}
private AccountID accountID;
@@ -178,7 +207,7 @@ public static RevokeSponsorshipOpSigner decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(this.accountID, this.signerKey);
+ return Objects.hash(this.accountID, this.signerKey);
}
@Override
@@ -188,8 +217,32 @@ public boolean equals(Object object) {
}
RevokeSponsorshipOpSigner other = (RevokeSponsorshipOpSigner) object;
- return Objects.equal(this.accountID, other.accountID)
- && Objects.equal(this.signerKey, other.signerKey);
+ return Objects.equals(this.accountID, other.accountID)
+ && Objects.equals(this.signerKey, other.signerKey);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static RevokeSponsorshipOpSigner fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static RevokeSponsorshipOpSigner fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -208,8 +261,8 @@ public Builder signerKey(SignerKey signerKey) {
public RevokeSponsorshipOpSigner build() {
RevokeSponsorshipOpSigner val = new RevokeSponsorshipOpSigner();
- val.setAccountID(accountID);
- val.setSignerKey(signerKey);
+ val.setAccountID(this.accountID);
+ val.setSignerKey(this.signerKey);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipResult.java b/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipResult.java
index a63703e4c..b5a027ea4 100644
--- a/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,11 @@
// {
// case REVOKE_SPONSORSHIP_SUCCESS:
// void;
-// default:
+// case REVOKE_SPONSORSHIP_DOES_NOT_EXIST:
+// case REVOKE_SPONSORSHIP_NOT_SPONSOR:
+// case REVOKE_SPONSORSHIP_LOW_RESERVE:
+// case REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE:
+// case REVOKE_SPONSORSHIP_MALFORMED:
// void;
// };
@@ -54,7 +63,11 @@ public static void encode(
switch (encodedRevokeSponsorshipResult.getDiscriminant()) {
case REVOKE_SPONSORSHIP_SUCCESS:
break;
- default:
+ case REVOKE_SPONSORSHIP_DOES_NOT_EXIST:
+ case REVOKE_SPONSORSHIP_NOT_SPONSOR:
+ case REVOKE_SPONSORSHIP_LOW_RESERVE:
+ case REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE:
+ case REVOKE_SPONSORSHIP_MALFORMED:
break;
}
}
@@ -70,7 +83,11 @@ public static RevokeSponsorshipResult decode(XdrDataInputStream stream) throws I
switch (decodedRevokeSponsorshipResult.getDiscriminant()) {
case REVOKE_SPONSORSHIP_SUCCESS:
break;
- default:
+ case REVOKE_SPONSORSHIP_DOES_NOT_EXIST:
+ case REVOKE_SPONSORSHIP_NOT_SPONSOR:
+ case REVOKE_SPONSORSHIP_LOW_RESERVE:
+ case REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE:
+ case REVOKE_SPONSORSHIP_MALFORMED:
break;
}
return decodedRevokeSponsorshipResult;
@@ -78,7 +95,7 @@ public static RevokeSponsorshipResult decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -88,6 +105,30 @@ public boolean equals(Object object) {
}
RevokeSponsorshipResult other = (RevokeSponsorshipResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static RevokeSponsorshipResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static RevokeSponsorshipResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipResultCode.java b/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipResultCode.java
index 53cf665ec..edcf6ee99 100644
--- a/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -67,4 +72,28 @@ public static void encode(XdrDataOutputStream stream, RevokeSponsorshipResultCod
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static RevokeSponsorshipResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static RevokeSponsorshipResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipType.java b/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipType.java
index 530cea01e..a24bed2e7 100644
--- a/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipType.java
+++ b/src/main/java/org/stellar/sdk/xdr/RevokeSponsorshipType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -48,4 +53,28 @@ public static void encode(XdrDataOutputStream stream, RevokeSponsorshipType valu
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static RevokeSponsorshipType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static RevokeSponsorshipType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCAddress.java b/src/main/java/org/stellar/sdk/xdr/SCAddress.java
new file mode 100644
index 000000000..c238538d2
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCAddress.java
@@ -0,0 +1,161 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union SCAddress switch (SCAddressType type)
+// {
+// case SC_ADDRESS_TYPE_ACCOUNT:
+// AccountID accountId;
+// case SC_ADDRESS_TYPE_CONTRACT:
+// Hash contractId;
+// };
+
+// ===========================================================================
+public class SCAddress implements XdrElement {
+ public SCAddress() {}
+
+ SCAddressType type;
+
+ public SCAddressType getDiscriminant() {
+ return this.type;
+ }
+
+ public void setDiscriminant(SCAddressType value) {
+ this.type = value;
+ }
+
+ private AccountID accountId;
+
+ public AccountID getAccountId() {
+ return this.accountId;
+ }
+
+ public void setAccountId(AccountID value) {
+ this.accountId = value;
+ }
+
+ private Hash contractId;
+
+ public Hash getContractId() {
+ return this.contractId;
+ }
+
+ public void setContractId(Hash value) {
+ this.contractId = value;
+ }
+
+ public static final class Builder {
+ private SCAddressType discriminant;
+ private AccountID accountId;
+ private Hash contractId;
+
+ public Builder discriminant(SCAddressType discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder accountId(AccountID accountId) {
+ this.accountId = accountId;
+ return this;
+ }
+
+ public Builder contractId(Hash contractId) {
+ this.contractId = contractId;
+ return this;
+ }
+
+ public SCAddress build() {
+ SCAddress val = new SCAddress();
+ val.setDiscriminant(discriminant);
+ val.setAccountId(this.accountId);
+ val.setContractId(this.contractId);
+ return val;
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCAddress encodedSCAddress)
+ throws IOException {
+ // Xdrgen::AST::Identifier
+ // SCAddressType
+ stream.writeInt(encodedSCAddress.getDiscriminant().getValue());
+ switch (encodedSCAddress.getDiscriminant()) {
+ case SC_ADDRESS_TYPE_ACCOUNT:
+ AccountID.encode(stream, encodedSCAddress.accountId);
+ break;
+ case SC_ADDRESS_TYPE_CONTRACT:
+ Hash.encode(stream, encodedSCAddress.contractId);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCAddress decode(XdrDataInputStream stream) throws IOException {
+ SCAddress decodedSCAddress = new SCAddress();
+ SCAddressType discriminant = SCAddressType.decode(stream);
+ decodedSCAddress.setDiscriminant(discriminant);
+ switch (decodedSCAddress.getDiscriminant()) {
+ case SC_ADDRESS_TYPE_ACCOUNT:
+ decodedSCAddress.accountId = AccountID.decode(stream);
+ break;
+ case SC_ADDRESS_TYPE_CONTRACT:
+ decodedSCAddress.contractId = Hash.decode(stream);
+ break;
+ }
+ return decodedSCAddress;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.accountId, this.contractId, this.type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCAddress)) {
+ return false;
+ }
+
+ SCAddress other = (SCAddress) object;
+ return Objects.equals(this.accountId, other.accountId)
+ && Objects.equals(this.contractId, other.contractId)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCAddress fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCAddress fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCAddressType.java b/src/main/java/org/stellar/sdk/xdr/SCAddressType.java
new file mode 100644
index 000000000..05dabef98
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCAddressType.java
@@ -0,0 +1,79 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum SCAddressType
+// {
+// SC_ADDRESS_TYPE_ACCOUNT = 0,
+// SC_ADDRESS_TYPE_CONTRACT = 1
+// };
+
+// ===========================================================================
+public enum SCAddressType implements XdrElement {
+ SC_ADDRESS_TYPE_ACCOUNT(0),
+ SC_ADDRESS_TYPE_CONTRACT(1),
+ ;
+ private int mValue;
+
+ SCAddressType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SCAddressType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SC_ADDRESS_TYPE_ACCOUNT;
+ case 1:
+ return SC_ADDRESS_TYPE_CONTRACT;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCAddressType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCAddressType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCAddressType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCBytes.java b/src/main/java/org/stellar/sdk/xdr/SCBytes.java
new file mode 100644
index 000000000..4fdd71f07
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCBytes.java
@@ -0,0 +1,92 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// typedef opaque SCBytes<>;
+
+// ===========================================================================
+public class SCBytes implements XdrElement {
+ private byte[] SCBytes;
+
+ public SCBytes() {}
+
+ public SCBytes(byte[] SCBytes) {
+ this.SCBytes = SCBytes;
+ }
+
+ public byte[] getSCBytes() {
+ return this.SCBytes;
+ }
+
+ public void setSCBytes(byte[] value) {
+ this.SCBytes = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCBytes encodedSCBytes) throws IOException {
+ int SCBytessize = encodedSCBytes.SCBytes.length;
+ stream.writeInt(SCBytessize);
+ stream.write(encodedSCBytes.getSCBytes(), 0, SCBytessize);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCBytes decode(XdrDataInputStream stream) throws IOException {
+ SCBytes decodedSCBytes = new SCBytes();
+ int SCBytessize = stream.readInt();
+ decodedSCBytes.SCBytes = new byte[SCBytessize];
+ stream.read(decodedSCBytes.SCBytes, 0, SCBytessize);
+ return decodedSCBytes;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(this.SCBytes);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCBytes)) {
+ return false;
+ }
+
+ SCBytes other = (SCBytes) object;
+ return Arrays.equals(this.SCBytes, other.SCBytes);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCBytes fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCBytes fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCContractInstance.java b/src/main/java/org/stellar/sdk/xdr/SCContractInstance.java
new file mode 100644
index 000000000..8a6bf8816
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCContractInstance.java
@@ -0,0 +1,131 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCContractInstance {
+// ContractExecutable executable;
+// SCMap* storage;
+// };
+
+// ===========================================================================
+public class SCContractInstance implements XdrElement {
+ public SCContractInstance() {}
+
+ private ContractExecutable executable;
+
+ public ContractExecutable getExecutable() {
+ return this.executable;
+ }
+
+ public void setExecutable(ContractExecutable value) {
+ this.executable = value;
+ }
+
+ private SCMap storage;
+
+ public SCMap getStorage() {
+ return this.storage;
+ }
+
+ public void setStorage(SCMap value) {
+ this.storage = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SCContractInstance encodedSCContractInstance) throws IOException {
+ ContractExecutable.encode(stream, encodedSCContractInstance.executable);
+ if (encodedSCContractInstance.storage != null) {
+ stream.writeInt(1);
+ SCMap.encode(stream, encodedSCContractInstance.storage);
+ } else {
+ stream.writeInt(0);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCContractInstance decode(XdrDataInputStream stream) throws IOException {
+ SCContractInstance decodedSCContractInstance = new SCContractInstance();
+ decodedSCContractInstance.executable = ContractExecutable.decode(stream);
+ int storagePresent = stream.readInt();
+ if (storagePresent != 0) {
+ decodedSCContractInstance.storage = SCMap.decode(stream);
+ }
+ return decodedSCContractInstance;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.executable, this.storage);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCContractInstance)) {
+ return false;
+ }
+
+ SCContractInstance other = (SCContractInstance) object;
+ return Objects.equals(this.executable, other.executable)
+ && Objects.equals(this.storage, other.storage);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCContractInstance fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCContractInstance fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ContractExecutable executable;
+ private SCMap storage;
+
+ public Builder executable(ContractExecutable executable) {
+ this.executable = executable;
+ return this;
+ }
+
+ public Builder storage(SCMap storage) {
+ this.storage = storage;
+ return this;
+ }
+
+ public SCContractInstance build() {
+ SCContractInstance val = new SCContractInstance();
+ val.setExecutable(this.executable);
+ val.setStorage(this.storage);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCEnvMetaEntry.java b/src/main/java/org/stellar/sdk/xdr/SCEnvMetaEntry.java
new file mode 100644
index 000000000..add97d7f0
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCEnvMetaEntry.java
@@ -0,0 +1,135 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union SCEnvMetaEntry switch (SCEnvMetaKind kind)
+// {
+// case SC_ENV_META_KIND_INTERFACE_VERSION:
+// uint64 interfaceVersion;
+// };
+
+// ===========================================================================
+public class SCEnvMetaEntry implements XdrElement {
+ public SCEnvMetaEntry() {}
+
+ SCEnvMetaKind kind;
+
+ public SCEnvMetaKind getDiscriminant() {
+ return this.kind;
+ }
+
+ public void setDiscriminant(SCEnvMetaKind value) {
+ this.kind = value;
+ }
+
+ private Uint64 interfaceVersion;
+
+ public Uint64 getInterfaceVersion() {
+ return this.interfaceVersion;
+ }
+
+ public void setInterfaceVersion(Uint64 value) {
+ this.interfaceVersion = value;
+ }
+
+ public static final class Builder {
+ private SCEnvMetaKind discriminant;
+ private Uint64 interfaceVersion;
+
+ public Builder discriminant(SCEnvMetaKind discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder interfaceVersion(Uint64 interfaceVersion) {
+ this.interfaceVersion = interfaceVersion;
+ return this;
+ }
+
+ public SCEnvMetaEntry build() {
+ SCEnvMetaEntry val = new SCEnvMetaEntry();
+ val.setDiscriminant(discriminant);
+ val.setInterfaceVersion(this.interfaceVersion);
+ return val;
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCEnvMetaEntry encodedSCEnvMetaEntry)
+ throws IOException {
+ // Xdrgen::AST::Identifier
+ // SCEnvMetaKind
+ stream.writeInt(encodedSCEnvMetaEntry.getDiscriminant().getValue());
+ switch (encodedSCEnvMetaEntry.getDiscriminant()) {
+ case SC_ENV_META_KIND_INTERFACE_VERSION:
+ Uint64.encode(stream, encodedSCEnvMetaEntry.interfaceVersion);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCEnvMetaEntry decode(XdrDataInputStream stream) throws IOException {
+ SCEnvMetaEntry decodedSCEnvMetaEntry = new SCEnvMetaEntry();
+ SCEnvMetaKind discriminant = SCEnvMetaKind.decode(stream);
+ decodedSCEnvMetaEntry.setDiscriminant(discriminant);
+ switch (decodedSCEnvMetaEntry.getDiscriminant()) {
+ case SC_ENV_META_KIND_INTERFACE_VERSION:
+ decodedSCEnvMetaEntry.interfaceVersion = Uint64.decode(stream);
+ break;
+ }
+ return decodedSCEnvMetaEntry;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.interfaceVersion, this.kind);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCEnvMetaEntry)) {
+ return false;
+ }
+
+ SCEnvMetaEntry other = (SCEnvMetaEntry) object;
+ return Objects.equals(this.interfaceVersion, other.interfaceVersion)
+ && Objects.equals(this.kind, other.kind);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCEnvMetaEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCEnvMetaEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCEnvMetaKind.java b/src/main/java/org/stellar/sdk/xdr/SCEnvMetaKind.java
new file mode 100644
index 000000000..20d25b485
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCEnvMetaKind.java
@@ -0,0 +1,75 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum SCEnvMetaKind
+// {
+// SC_ENV_META_KIND_INTERFACE_VERSION = 0
+// };
+
+// ===========================================================================
+public enum SCEnvMetaKind implements XdrElement {
+ SC_ENV_META_KIND_INTERFACE_VERSION(0),
+ ;
+ private int mValue;
+
+ SCEnvMetaKind(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SCEnvMetaKind decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SC_ENV_META_KIND_INTERFACE_VERSION;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCEnvMetaKind value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCEnvMetaKind fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCEnvMetaKind fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCError.java b/src/main/java/org/stellar/sdk/xdr/SCError.java
new file mode 100644
index 000000000..398489cb8
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCError.java
@@ -0,0 +1,184 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union SCError switch (SCErrorType type)
+// {
+// case SCE_CONTRACT:
+// uint32 contractCode;
+// case SCE_WASM_VM:
+// case SCE_CONTEXT:
+// case SCE_STORAGE:
+// case SCE_OBJECT:
+// case SCE_CRYPTO:
+// case SCE_EVENTS:
+// case SCE_BUDGET:
+// case SCE_VALUE:
+// case SCE_AUTH:
+// SCErrorCode code;
+// };
+
+// ===========================================================================
+public class SCError implements XdrElement {
+ public SCError() {}
+
+ SCErrorType type;
+
+ public SCErrorType getDiscriminant() {
+ return this.type;
+ }
+
+ public void setDiscriminant(SCErrorType value) {
+ this.type = value;
+ }
+
+ private Uint32 contractCode;
+
+ public Uint32 getContractCode() {
+ return this.contractCode;
+ }
+
+ public void setContractCode(Uint32 value) {
+ this.contractCode = value;
+ }
+
+ private SCErrorCode code;
+
+ public SCErrorCode getCode() {
+ return this.code;
+ }
+
+ public void setCode(SCErrorCode value) {
+ this.code = value;
+ }
+
+ public static final class Builder {
+ private SCErrorType discriminant;
+ private Uint32 contractCode;
+ private SCErrorCode code;
+
+ public Builder discriminant(SCErrorType discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder contractCode(Uint32 contractCode) {
+ this.contractCode = contractCode;
+ return this;
+ }
+
+ public Builder code(SCErrorCode code) {
+ this.code = code;
+ return this;
+ }
+
+ public SCError build() {
+ SCError val = new SCError();
+ val.setDiscriminant(discriminant);
+ val.setContractCode(this.contractCode);
+ val.setCode(this.code);
+ return val;
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCError encodedSCError) throws IOException {
+ // Xdrgen::AST::Identifier
+ // SCErrorType
+ stream.writeInt(encodedSCError.getDiscriminant().getValue());
+ switch (encodedSCError.getDiscriminant()) {
+ case SCE_CONTRACT:
+ Uint32.encode(stream, encodedSCError.contractCode);
+ break;
+ case SCE_WASM_VM:
+ case SCE_CONTEXT:
+ case SCE_STORAGE:
+ case SCE_OBJECT:
+ case SCE_CRYPTO:
+ case SCE_EVENTS:
+ case SCE_BUDGET:
+ case SCE_VALUE:
+ case SCE_AUTH:
+ SCErrorCode.encode(stream, encodedSCError.code);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCError decode(XdrDataInputStream stream) throws IOException {
+ SCError decodedSCError = new SCError();
+ SCErrorType discriminant = SCErrorType.decode(stream);
+ decodedSCError.setDiscriminant(discriminant);
+ switch (decodedSCError.getDiscriminant()) {
+ case SCE_CONTRACT:
+ decodedSCError.contractCode = Uint32.decode(stream);
+ break;
+ case SCE_WASM_VM:
+ case SCE_CONTEXT:
+ case SCE_STORAGE:
+ case SCE_OBJECT:
+ case SCE_CRYPTO:
+ case SCE_EVENTS:
+ case SCE_BUDGET:
+ case SCE_VALUE:
+ case SCE_AUTH:
+ decodedSCError.code = SCErrorCode.decode(stream);
+ break;
+ }
+ return decodedSCError;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.contractCode, this.code, this.type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCError)) {
+ return false;
+ }
+
+ SCError other = (SCError) object;
+ return Objects.equals(this.contractCode, other.contractCode)
+ && Objects.equals(this.code, other.code)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCError fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCError fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCErrorCode.java b/src/main/java/org/stellar/sdk/xdr/SCErrorCode.java
new file mode 100644
index 000000000..d1918e6b5
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCErrorCode.java
@@ -0,0 +1,111 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum SCErrorCode
+// {
+// SCEC_ARITH_DOMAIN = 0, // Some arithmetic was undefined (overflow, divide-by-zero).
+// SCEC_INDEX_BOUNDS = 1, // Something was indexed beyond its bounds.
+// SCEC_INVALID_INPUT = 2, // User provided some otherwise-bad data.
+// SCEC_MISSING_VALUE = 3, // Some value was required but not provided.
+// SCEC_EXISTING_VALUE = 4, // Some value was provided where not allowed.
+// SCEC_EXCEEDED_LIMIT = 5, // Some arbitrary limit -- gas or otherwise -- was hit.
+// SCEC_INVALID_ACTION = 6, // Data was valid but action requested was not.
+// SCEC_INTERNAL_ERROR = 7, // The host detected an error in its own logic.
+// SCEC_UNEXPECTED_TYPE = 8, // Some type wasn't as expected.
+// SCEC_UNEXPECTED_SIZE = 9 // Something's size wasn't as expected.
+// };
+
+// ===========================================================================
+public enum SCErrorCode implements XdrElement {
+ SCEC_ARITH_DOMAIN(0),
+ SCEC_INDEX_BOUNDS(1),
+ SCEC_INVALID_INPUT(2),
+ SCEC_MISSING_VALUE(3),
+ SCEC_EXISTING_VALUE(4),
+ SCEC_EXCEEDED_LIMIT(5),
+ SCEC_INVALID_ACTION(6),
+ SCEC_INTERNAL_ERROR(7),
+ SCEC_UNEXPECTED_TYPE(8),
+ SCEC_UNEXPECTED_SIZE(9),
+ ;
+ private int mValue;
+
+ SCErrorCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SCErrorCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SCEC_ARITH_DOMAIN;
+ case 1:
+ return SCEC_INDEX_BOUNDS;
+ case 2:
+ return SCEC_INVALID_INPUT;
+ case 3:
+ return SCEC_MISSING_VALUE;
+ case 4:
+ return SCEC_EXISTING_VALUE;
+ case 5:
+ return SCEC_EXCEEDED_LIMIT;
+ case 6:
+ return SCEC_INVALID_ACTION;
+ case 7:
+ return SCEC_INTERNAL_ERROR;
+ case 8:
+ return SCEC_UNEXPECTED_TYPE;
+ case 9:
+ return SCEC_UNEXPECTED_SIZE;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCErrorCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCErrorCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCErrorCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCErrorType.java b/src/main/java/org/stellar/sdk/xdr/SCErrorType.java
new file mode 100644
index 000000000..b39e8f15b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCErrorType.java
@@ -0,0 +1,111 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum SCErrorType
+// {
+// SCE_CONTRACT = 0, // Contract-specific, user-defined codes.
+// SCE_WASM_VM = 1, // Errors while interpreting WASM bytecode.
+// SCE_CONTEXT = 2, // Errors in the contract's host context.
+// SCE_STORAGE = 3, // Errors accessing host storage.
+// SCE_OBJECT = 4, // Errors working with host objects.
+// SCE_CRYPTO = 5, // Errors in cryptographic operations.
+// SCE_EVENTS = 6, // Errors while emitting events.
+// SCE_BUDGET = 7, // Errors relating to budget limits.
+// SCE_VALUE = 8, // Errors working with host values or SCVals.
+// SCE_AUTH = 9 // Errors from the authentication subsystem.
+// };
+
+// ===========================================================================
+public enum SCErrorType implements XdrElement {
+ SCE_CONTRACT(0),
+ SCE_WASM_VM(1),
+ SCE_CONTEXT(2),
+ SCE_STORAGE(3),
+ SCE_OBJECT(4),
+ SCE_CRYPTO(5),
+ SCE_EVENTS(6),
+ SCE_BUDGET(7),
+ SCE_VALUE(8),
+ SCE_AUTH(9),
+ ;
+ private int mValue;
+
+ SCErrorType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SCErrorType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SCE_CONTRACT;
+ case 1:
+ return SCE_WASM_VM;
+ case 2:
+ return SCE_CONTEXT;
+ case 3:
+ return SCE_STORAGE;
+ case 4:
+ return SCE_OBJECT;
+ case 5:
+ return SCE_CRYPTO;
+ case 6:
+ return SCE_EVENTS;
+ case 7:
+ return SCE_BUDGET;
+ case 8:
+ return SCE_VALUE;
+ case 9:
+ return SCE_AUTH;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCErrorType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCErrorType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCErrorType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCMap.java b/src/main/java/org/stellar/sdk/xdr/SCMap.java
new file mode 100644
index 000000000..40c395a5e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCMap.java
@@ -0,0 +1,96 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// typedef SCMapEntry SCMap<>;
+
+// ===========================================================================
+public class SCMap implements XdrElement {
+ private SCMapEntry[] SCMap;
+
+ public SCMap() {}
+
+ public SCMap(SCMapEntry[] SCMap) {
+ this.SCMap = SCMap;
+ }
+
+ public SCMapEntry[] getSCMap() {
+ return this.SCMap;
+ }
+
+ public void setSCMap(SCMapEntry[] value) {
+ this.SCMap = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCMap encodedSCMap) throws IOException {
+ int SCMapsize = encodedSCMap.getSCMap().length;
+ stream.writeInt(SCMapsize);
+ for (int i = 0; i < SCMapsize; i++) {
+ SCMapEntry.encode(stream, encodedSCMap.SCMap[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCMap decode(XdrDataInputStream stream) throws IOException {
+ SCMap decodedSCMap = new SCMap();
+ int SCMapsize = stream.readInt();
+ decodedSCMap.SCMap = new SCMapEntry[SCMapsize];
+ for (int i = 0; i < SCMapsize; i++) {
+ decodedSCMap.SCMap[i] = SCMapEntry.decode(stream);
+ }
+ return decodedSCMap;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(this.SCMap);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCMap)) {
+ return false;
+ }
+
+ SCMap other = (SCMap) object;
+ return Arrays.equals(this.SCMap, other.SCMap);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCMap fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCMap fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCMapEntry.java b/src/main/java/org/stellar/sdk/xdr/SCMapEntry.java
new file mode 100644
index 000000000..65c5de935
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCMapEntry.java
@@ -0,0 +1,123 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCMapEntry
+// {
+// SCVal key;
+// SCVal val;
+// };
+
+// ===========================================================================
+public class SCMapEntry implements XdrElement {
+ public SCMapEntry() {}
+
+ private SCVal key;
+
+ public SCVal getKey() {
+ return this.key;
+ }
+
+ public void setKey(SCVal value) {
+ this.key = value;
+ }
+
+ private SCVal val;
+
+ public SCVal getVal() {
+ return this.val;
+ }
+
+ public void setVal(SCVal value) {
+ this.val = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCMapEntry encodedSCMapEntry)
+ throws IOException {
+ SCVal.encode(stream, encodedSCMapEntry.key);
+ SCVal.encode(stream, encodedSCMapEntry.val);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCMapEntry decode(XdrDataInputStream stream) throws IOException {
+ SCMapEntry decodedSCMapEntry = new SCMapEntry();
+ decodedSCMapEntry.key = SCVal.decode(stream);
+ decodedSCMapEntry.val = SCVal.decode(stream);
+ return decodedSCMapEntry;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.key, this.val);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCMapEntry)) {
+ return false;
+ }
+
+ SCMapEntry other = (SCMapEntry) object;
+ return Objects.equals(this.key, other.key) && Objects.equals(this.val, other.val);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCMapEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCMapEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCVal key;
+ private SCVal val;
+
+ public Builder key(SCVal key) {
+ this.key = key;
+ return this;
+ }
+
+ public Builder val(SCVal val) {
+ this.val = val;
+ return this;
+ }
+
+ public SCMapEntry build() {
+ SCMapEntry val = new SCMapEntry();
+ val.setKey(this.key);
+ val.setVal(this.val);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCMetaEntry.java b/src/main/java/org/stellar/sdk/xdr/SCMetaEntry.java
new file mode 100644
index 000000000..bcf2ddcfe
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCMetaEntry.java
@@ -0,0 +1,134 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union SCMetaEntry switch (SCMetaKind kind)
+// {
+// case SC_META_V0:
+// SCMetaV0 v0;
+// };
+
+// ===========================================================================
+public class SCMetaEntry implements XdrElement {
+ public SCMetaEntry() {}
+
+ SCMetaKind kind;
+
+ public SCMetaKind getDiscriminant() {
+ return this.kind;
+ }
+
+ public void setDiscriminant(SCMetaKind value) {
+ this.kind = value;
+ }
+
+ private SCMetaV0 v0;
+
+ public SCMetaV0 getV0() {
+ return this.v0;
+ }
+
+ public void setV0(SCMetaV0 value) {
+ this.v0 = value;
+ }
+
+ public static final class Builder {
+ private SCMetaKind discriminant;
+ private SCMetaV0 v0;
+
+ public Builder discriminant(SCMetaKind discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder v0(SCMetaV0 v0) {
+ this.v0 = v0;
+ return this;
+ }
+
+ public SCMetaEntry build() {
+ SCMetaEntry val = new SCMetaEntry();
+ val.setDiscriminant(discriminant);
+ val.setV0(this.v0);
+ return val;
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCMetaEntry encodedSCMetaEntry)
+ throws IOException {
+ // Xdrgen::AST::Identifier
+ // SCMetaKind
+ stream.writeInt(encodedSCMetaEntry.getDiscriminant().getValue());
+ switch (encodedSCMetaEntry.getDiscriminant()) {
+ case SC_META_V0:
+ SCMetaV0.encode(stream, encodedSCMetaEntry.v0);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCMetaEntry decode(XdrDataInputStream stream) throws IOException {
+ SCMetaEntry decodedSCMetaEntry = new SCMetaEntry();
+ SCMetaKind discriminant = SCMetaKind.decode(stream);
+ decodedSCMetaEntry.setDiscriminant(discriminant);
+ switch (decodedSCMetaEntry.getDiscriminant()) {
+ case SC_META_V0:
+ decodedSCMetaEntry.v0 = SCMetaV0.decode(stream);
+ break;
+ }
+ return decodedSCMetaEntry;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.v0, this.kind);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCMetaEntry)) {
+ return false;
+ }
+
+ SCMetaEntry other = (SCMetaEntry) object;
+ return Objects.equals(this.v0, other.v0) && Objects.equals(this.kind, other.kind);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCMetaEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCMetaEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCMetaKind.java b/src/main/java/org/stellar/sdk/xdr/SCMetaKind.java
new file mode 100644
index 000000000..b4712e4c3
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCMetaKind.java
@@ -0,0 +1,75 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum SCMetaKind
+// {
+// SC_META_V0 = 0
+// };
+
+// ===========================================================================
+public enum SCMetaKind implements XdrElement {
+ SC_META_V0(0),
+ ;
+ private int mValue;
+
+ SCMetaKind(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SCMetaKind decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SC_META_V0;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCMetaKind value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCMetaKind fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCMetaKind fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCMetaV0.java b/src/main/java/org/stellar/sdk/xdr/SCMetaV0.java
new file mode 100644
index 000000000..3629a2ec0
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCMetaV0.java
@@ -0,0 +1,123 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCMetaV0
+// {
+// string key<>;
+// string val<>;
+// };
+
+// ===========================================================================
+public class SCMetaV0 implements XdrElement {
+ public SCMetaV0() {}
+
+ private XdrString key;
+
+ public XdrString getKey() {
+ return this.key;
+ }
+
+ public void setKey(XdrString value) {
+ this.key = value;
+ }
+
+ private XdrString val;
+
+ public XdrString getVal() {
+ return this.val;
+ }
+
+ public void setVal(XdrString value) {
+ this.val = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCMetaV0 encodedSCMetaV0)
+ throws IOException {
+ encodedSCMetaV0.key.encode(stream);
+ encodedSCMetaV0.val.encode(stream);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCMetaV0 decode(XdrDataInputStream stream) throws IOException {
+ SCMetaV0 decodedSCMetaV0 = new SCMetaV0();
+ decodedSCMetaV0.key = XdrString.decode(stream, Integer.MAX_VALUE);
+ decodedSCMetaV0.val = XdrString.decode(stream, Integer.MAX_VALUE);
+ return decodedSCMetaV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.key, this.val);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCMetaV0)) {
+ return false;
+ }
+
+ SCMetaV0 other = (SCMetaV0) object;
+ return Objects.equals(this.key, other.key) && Objects.equals(this.val, other.val);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCMetaV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCMetaV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString key;
+ private XdrString val;
+
+ public Builder key(XdrString key) {
+ this.key = key;
+ return this;
+ }
+
+ public Builder val(XdrString val) {
+ this.val = val;
+ return this;
+ }
+
+ public SCMetaV0 build() {
+ SCMetaV0 val = new SCMetaV0();
+ val.setKey(this.key);
+ val.setVal(this.val);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCNonceKey.java b/src/main/java/org/stellar/sdk/xdr/SCNonceKey.java
new file mode 100644
index 000000000..494b0c357
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCNonceKey.java
@@ -0,0 +1,102 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCNonceKey {
+// int64 nonce;
+// };
+
+// ===========================================================================
+public class SCNonceKey implements XdrElement {
+ public SCNonceKey() {}
+
+ private Int64 nonce;
+
+ public Int64 getNonce() {
+ return this.nonce;
+ }
+
+ public void setNonce(Int64 value) {
+ this.nonce = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCNonceKey encodedSCNonceKey)
+ throws IOException {
+ Int64.encode(stream, encodedSCNonceKey.nonce);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCNonceKey decode(XdrDataInputStream stream) throws IOException {
+ SCNonceKey decodedSCNonceKey = new SCNonceKey();
+ decodedSCNonceKey.nonce = Int64.decode(stream);
+ return decodedSCNonceKey;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.nonce);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCNonceKey)) {
+ return false;
+ }
+
+ SCNonceKey other = (SCNonceKey) object;
+ return Objects.equals(this.nonce, other.nonce);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCNonceKey fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCNonceKey fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Int64 nonce;
+
+ public Builder nonce(Int64 nonce) {
+ this.nonce = nonce;
+ return this;
+ }
+
+ public SCNonceKey build() {
+ SCNonceKey val = new SCNonceKey();
+ val.setNonce(this.nonce);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPBallot.java b/src/main/java/org/stellar/sdk/xdr/SCPBallot.java
index 90fbf4595..905329573 100644
--- a/src/main/java/org/stellar/sdk/xdr/SCPBallot.java
+++ b/src/main/java/org/stellar/sdk/xdr/SCPBallot.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -57,7 +62,7 @@ public static SCPBallot decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.counter, this.value);
+ return Objects.hash(this.counter, this.value);
}
@Override
@@ -67,7 +72,31 @@ public boolean equals(Object object) {
}
SCPBallot other = (SCPBallot) object;
- return Objects.equal(this.counter, other.counter) && Objects.equal(this.value, other.value);
+ return Objects.equals(this.counter, other.counter) && Objects.equals(this.value, other.value);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCPBallot fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCPBallot fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -86,8 +115,8 @@ public Builder value(Value value) {
public SCPBallot build() {
SCPBallot val = new SCPBallot();
- val.setCounter(counter);
- val.setValue(value);
+ val.setCounter(this.counter);
+ val.setValue(this.value);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPEnvelope.java b/src/main/java/org/stellar/sdk/xdr/SCPEnvelope.java
index fa459049a..90edd5797 100644
--- a/src/main/java/org/stellar/sdk/xdr/SCPEnvelope.java
+++ b/src/main/java/org/stellar/sdk/xdr/SCPEnvelope.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -57,7 +62,7 @@ public static SCPEnvelope decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.statement, this.signature);
+ return Objects.hash(this.statement, this.signature);
}
@Override
@@ -67,8 +72,32 @@ public boolean equals(Object object) {
}
SCPEnvelope other = (SCPEnvelope) object;
- return Objects.equal(this.statement, other.statement)
- && Objects.equal(this.signature, other.signature);
+ return Objects.equals(this.statement, other.statement)
+ && Objects.equals(this.signature, other.signature);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCPEnvelope fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCPEnvelope fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -87,8 +116,8 @@ public Builder signature(Signature signature) {
public SCPEnvelope build() {
SCPEnvelope val = new SCPEnvelope();
- val.setStatement(statement);
- val.setSignature(signature);
+ val.setStatement(this.statement);
+ val.setSignature(this.signature);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPHistoryEntry.java b/src/main/java/org/stellar/sdk/xdr/SCPHistoryEntry.java
index 6ceeddbdf..c59786ec9 100644
--- a/src/main/java/org/stellar/sdk/xdr/SCPHistoryEntry.java
+++ b/src/main/java/org/stellar/sdk/xdr/SCPHistoryEntry.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -55,7 +60,7 @@ public Builder v0(SCPHistoryEntryV0 v0) {
public SCPHistoryEntry build() {
SCPHistoryEntry val = new SCPHistoryEntry();
val.setDiscriminant(discriminant);
- val.setV0(v0);
+ val.setV0(this.v0);
return val;
}
}
@@ -90,7 +95,7 @@ public static SCPHistoryEntry decode(XdrDataInputStream stream) throws IOExcepti
@Override
public int hashCode() {
- return Objects.hashCode(this.v0, this.v);
+ return Objects.hash(this.v0, this.v);
}
@Override
@@ -100,6 +105,30 @@ public boolean equals(Object object) {
}
SCPHistoryEntry other = (SCPHistoryEntry) object;
- return Objects.equal(this.v0, other.v0) && Objects.equal(this.v, other.v);
+ return Objects.equals(this.v0, other.v0) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCPHistoryEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCPHistoryEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPHistoryEntryV0.java b/src/main/java/org/stellar/sdk/xdr/SCPHistoryEntryV0.java
index 02b74bc75..f260ac8ba 100644
--- a/src/main/java/org/stellar/sdk/xdr/SCPHistoryEntryV0.java
+++ b/src/main/java/org/stellar/sdk/xdr/SCPHistoryEntryV0.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -66,7 +71,7 @@ public static SCPHistoryEntryV0 decode(XdrDataInputStream stream) throws IOExcep
@Override
public int hashCode() {
- return Objects.hashCode(Arrays.hashCode(this.quorumSets), this.ledgerMessages);
+ return Objects.hash(Arrays.hashCode(this.quorumSets), this.ledgerMessages);
}
@Override
@@ -77,7 +82,31 @@ public boolean equals(Object object) {
SCPHistoryEntryV0 other = (SCPHistoryEntryV0) object;
return Arrays.equals(this.quorumSets, other.quorumSets)
- && Objects.equal(this.ledgerMessages, other.ledgerMessages);
+ && Objects.equals(this.ledgerMessages, other.ledgerMessages);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCPHistoryEntryV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCPHistoryEntryV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -96,8 +125,8 @@ public Builder ledgerMessages(LedgerSCPMessages ledgerMessages) {
public SCPHistoryEntryV0 build() {
SCPHistoryEntryV0 val = new SCPHistoryEntryV0();
- val.setQuorumSets(quorumSets);
- val.setLedgerMessages(ledgerMessages);
+ val.setQuorumSets(this.quorumSets);
+ val.setLedgerMessages(this.ledgerMessages);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPNomination.java b/src/main/java/org/stellar/sdk/xdr/SCPNomination.java
index 3d8657f39..a09a7654a 100644
--- a/src/main/java/org/stellar/sdk/xdr/SCPNomination.java
+++ b/src/main/java/org/stellar/sdk/xdr/SCPNomination.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -87,7 +92,7 @@ public static SCPNomination decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.quorumSetHash, Arrays.hashCode(this.votes), Arrays.hashCode(this.accepted));
}
@@ -98,11 +103,35 @@ public boolean equals(Object object) {
}
SCPNomination other = (SCPNomination) object;
- return Objects.equal(this.quorumSetHash, other.quorumSetHash)
+ return Objects.equals(this.quorumSetHash, other.quorumSetHash)
&& Arrays.equals(this.votes, other.votes)
&& Arrays.equals(this.accepted, other.accepted);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCPNomination fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCPNomination fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private Hash quorumSetHash;
private Value[] votes;
@@ -125,9 +154,9 @@ public Builder accepted(Value[] accepted) {
public SCPNomination build() {
SCPNomination val = new SCPNomination();
- val.setQuorumSetHash(quorumSetHash);
- val.setVotes(votes);
- val.setAccepted(accepted);
+ val.setQuorumSetHash(this.quorumSetHash);
+ val.setVotes(this.votes);
+ val.setAccepted(this.accepted);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPQuorumSet.java b/src/main/java/org/stellar/sdk/xdr/SCPQuorumSet.java
index 9bb00ab8d..3868ce6e2 100644
--- a/src/main/java/org/stellar/sdk/xdr/SCPQuorumSet.java
+++ b/src/main/java/org/stellar/sdk/xdr/SCPQuorumSet.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -87,7 +92,7 @@ public static SCPQuorumSet decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.threshold, Arrays.hashCode(this.validators), Arrays.hashCode(this.innerSets));
}
@@ -98,11 +103,35 @@ public boolean equals(Object object) {
}
SCPQuorumSet other = (SCPQuorumSet) object;
- return Objects.equal(this.threshold, other.threshold)
+ return Objects.equals(this.threshold, other.threshold)
&& Arrays.equals(this.validators, other.validators)
&& Arrays.equals(this.innerSets, other.innerSets);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCPQuorumSet fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCPQuorumSet fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private Uint32 threshold;
private NodeID[] validators;
@@ -125,9 +154,9 @@ public Builder innerSets(SCPQuorumSet[] innerSets) {
public SCPQuorumSet build() {
SCPQuorumSet val = new SCPQuorumSet();
- val.setThreshold(threshold);
- val.setValidators(validators);
- val.setInnerSets(innerSets);
+ val.setThreshold(this.threshold);
+ val.setValidators(this.validators);
+ val.setInnerSets(this.innerSets);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPStatement.java b/src/main/java/org/stellar/sdk/xdr/SCPStatement.java
index 77674767a..4829a04f1 100644
--- a/src/main/java/org/stellar/sdk/xdr/SCPStatement.java
+++ b/src/main/java/org/stellar/sdk/xdr/SCPStatement.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -102,7 +107,7 @@ public static SCPStatement decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(this.nodeID, this.slotIndex, this.pledges);
+ return Objects.hash(this.nodeID, this.slotIndex, this.pledges);
}
@Override
@@ -112,9 +117,33 @@ public boolean equals(Object object) {
}
SCPStatement other = (SCPStatement) object;
- return Objects.equal(this.nodeID, other.nodeID)
- && Objects.equal(this.slotIndex, other.slotIndex)
- && Objects.equal(this.pledges, other.pledges);
+ return Objects.equals(this.nodeID, other.nodeID)
+ && Objects.equals(this.slotIndex, other.slotIndex)
+ && Objects.equals(this.pledges, other.pledges);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCPStatement fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCPStatement fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -139,14 +168,14 @@ public Builder pledges(SCPStatementPledges pledges) {
public SCPStatement build() {
SCPStatement val = new SCPStatement();
- val.setNodeID(nodeID);
- val.setSlotIndex(slotIndex);
- val.setPledges(pledges);
+ val.setNodeID(this.nodeID);
+ val.setSlotIndex(this.slotIndex);
+ val.setPledges(this.pledges);
return val;
}
}
- public static class SCPStatementPledges {
+ public static class SCPStatementPledges implements XdrElement {
public SCPStatementPledges() {}
SCPStatementType type;
@@ -234,10 +263,10 @@ public Builder nominate(SCPNomination nominate) {
public SCPStatementPledges build() {
SCPStatementPledges val = new SCPStatementPledges();
val.setDiscriminant(discriminant);
- val.setPrepare(prepare);
- val.setConfirm(confirm);
- val.setExternalize(externalize);
- val.setNominate(nominate);
+ val.setPrepare(this.prepare);
+ val.setConfirm(this.confirm);
+ val.setExternalize(this.externalize);
+ val.setNominate(this.nominate);
return val;
}
}
@@ -291,8 +320,7 @@ public static SCPStatementPledges decode(XdrDataInputStream stream) throws IOExc
@Override
public int hashCode() {
- return Objects.hashCode(
- this.prepare, this.confirm, this.externalize, this.nominate, this.type);
+ return Objects.hash(this.prepare, this.confirm, this.externalize, this.nominate, this.type);
}
@Override
@@ -302,14 +330,38 @@ public boolean equals(Object object) {
}
SCPStatementPledges other = (SCPStatementPledges) object;
- return Objects.equal(this.prepare, other.prepare)
- && Objects.equal(this.confirm, other.confirm)
- && Objects.equal(this.externalize, other.externalize)
- && Objects.equal(this.nominate, other.nominate)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.prepare, other.prepare)
+ && Objects.equals(this.confirm, other.confirm)
+ && Objects.equals(this.externalize, other.externalize)
+ && Objects.equals(this.nominate, other.nominate)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
}
- public static class SCPStatementPrepare {
+ public static SCPStatementPledges fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCPStatementPledges fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static class SCPStatementPrepare implements XdrElement {
public SCPStatementPrepare() {}
private Hash quorumSetHash;
@@ -416,7 +468,7 @@ public static SCPStatementPrepare decode(XdrDataInputStream stream) throws IOExc
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.quorumSetHash, this.ballot, this.prepared, this.preparedPrime, this.nC, this.nH);
}
@@ -427,12 +479,36 @@ public boolean equals(Object object) {
}
SCPStatementPrepare other = (SCPStatementPrepare) object;
- return Objects.equal(this.quorumSetHash, other.quorumSetHash)
- && Objects.equal(this.ballot, other.ballot)
- && Objects.equal(this.prepared, other.prepared)
- && Objects.equal(this.preparedPrime, other.preparedPrime)
- && Objects.equal(this.nC, other.nC)
- && Objects.equal(this.nH, other.nH);
+ return Objects.equals(this.quorumSetHash, other.quorumSetHash)
+ && Objects.equals(this.ballot, other.ballot)
+ && Objects.equals(this.prepared, other.prepared)
+ && Objects.equals(this.preparedPrime, other.preparedPrime)
+ && Objects.equals(this.nC, other.nC)
+ && Objects.equals(this.nH, other.nH);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCPStatementPrepare fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCPStatementPrepare fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -475,18 +551,18 @@ public Builder nH(Uint32 nH) {
public SCPStatementPrepare build() {
SCPStatementPrepare val = new SCPStatementPrepare();
- val.setQuorumSetHash(quorumSetHash);
- val.setBallot(ballot);
- val.setPrepared(prepared);
- val.setPreparedPrime(preparedPrime);
- val.setNC(nC);
- val.setNH(nH);
+ val.setQuorumSetHash(this.quorumSetHash);
+ val.setBallot(this.ballot);
+ val.setPrepared(this.prepared);
+ val.setPreparedPrime(this.preparedPrime);
+ val.setNC(this.nC);
+ val.setNH(this.nH);
return val;
}
}
}
- public static class SCPStatementConfirm {
+ public static class SCPStatementConfirm implements XdrElement {
public SCPStatementConfirm() {}
private SCPBallot ballot;
@@ -565,8 +641,7 @@ public static SCPStatementConfirm decode(XdrDataInputStream stream) throws IOExc
@Override
public int hashCode() {
- return Objects.hashCode(
- this.ballot, this.nPrepared, this.nCommit, this.nH, this.quorumSetHash);
+ return Objects.hash(this.ballot, this.nPrepared, this.nCommit, this.nH, this.quorumSetHash);
}
@Override
@@ -576,11 +651,35 @@ public boolean equals(Object object) {
}
SCPStatementConfirm other = (SCPStatementConfirm) object;
- return Objects.equal(this.ballot, other.ballot)
- && Objects.equal(this.nPrepared, other.nPrepared)
- && Objects.equal(this.nCommit, other.nCommit)
- && Objects.equal(this.nH, other.nH)
- && Objects.equal(this.quorumSetHash, other.quorumSetHash);
+ return Objects.equals(this.ballot, other.ballot)
+ && Objects.equals(this.nPrepared, other.nPrepared)
+ && Objects.equals(this.nCommit, other.nCommit)
+ && Objects.equals(this.nH, other.nH)
+ && Objects.equals(this.quorumSetHash, other.quorumSetHash);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCPStatementConfirm fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCPStatementConfirm fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -617,17 +716,17 @@ public Builder quorumSetHash(Hash quorumSetHash) {
public SCPStatementConfirm build() {
SCPStatementConfirm val = new SCPStatementConfirm();
- val.setBallot(ballot);
- val.setNPrepared(nPrepared);
- val.setNCommit(nCommit);
- val.setNH(nH);
- val.setQuorumSetHash(quorumSetHash);
+ val.setBallot(this.ballot);
+ val.setNPrepared(this.nPrepared);
+ val.setNCommit(this.nCommit);
+ val.setNH(this.nH);
+ val.setQuorumSetHash(this.quorumSetHash);
return val;
}
}
}
- public static class SCPStatementExternalize {
+ public static class SCPStatementExternalize implements XdrElement {
public SCPStatementExternalize() {}
private SCPBallot commit;
@@ -682,7 +781,7 @@ public static SCPStatementExternalize decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(this.commit, this.nH, this.commitQuorumSetHash);
+ return Objects.hash(this.commit, this.nH, this.commitQuorumSetHash);
}
@Override
@@ -692,9 +791,33 @@ public boolean equals(Object object) {
}
SCPStatementExternalize other = (SCPStatementExternalize) object;
- return Objects.equal(this.commit, other.commit)
- && Objects.equal(this.nH, other.nH)
- && Objects.equal(this.commitQuorumSetHash, other.commitQuorumSetHash);
+ return Objects.equals(this.commit, other.commit)
+ && Objects.equals(this.nH, other.nH)
+ && Objects.equals(this.commitQuorumSetHash, other.commitQuorumSetHash);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCPStatementExternalize fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCPStatementExternalize fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -719,9 +842,9 @@ public Builder commitQuorumSetHash(Hash commitQuorumSetHash) {
public SCPStatementExternalize build() {
SCPStatementExternalize val = new SCPStatementExternalize();
- val.setCommit(commit);
- val.setNH(nH);
- val.setCommitQuorumSetHash(commitQuorumSetHash);
+ val.setCommit(this.commit);
+ val.setNH(this.nH);
+ val.setCommitQuorumSetHash(this.commitQuorumSetHash);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPStatementType.java b/src/main/java/org/stellar/sdk/xdr/SCPStatementType.java
index 7a0b26298..4afeed5d1 100644
--- a/src/main/java/org/stellar/sdk/xdr/SCPStatementType.java
+++ b/src/main/java/org/stellar/sdk/xdr/SCPStatementType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -55,4 +60,28 @@ public static void encode(XdrDataOutputStream stream, SCPStatementType value) th
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCPStatementType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCPStatementType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecEntry.java b/src/main/java/org/stellar/sdk/xdr/SCSpecEntry.java
new file mode 100644
index 000000000..14cc67e05
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecEntry.java
@@ -0,0 +1,245 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union SCSpecEntry switch (SCSpecEntryKind kind)
+// {
+// case SC_SPEC_ENTRY_FUNCTION_V0:
+// SCSpecFunctionV0 functionV0;
+// case SC_SPEC_ENTRY_UDT_STRUCT_V0:
+// SCSpecUDTStructV0 udtStructV0;
+// case SC_SPEC_ENTRY_UDT_UNION_V0:
+// SCSpecUDTUnionV0 udtUnionV0;
+// case SC_SPEC_ENTRY_UDT_ENUM_V0:
+// SCSpecUDTEnumV0 udtEnumV0;
+// case SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0:
+// SCSpecUDTErrorEnumV0 udtErrorEnumV0;
+// };
+
+// ===========================================================================
+public class SCSpecEntry implements XdrElement {
+ public SCSpecEntry() {}
+
+ SCSpecEntryKind kind;
+
+ public SCSpecEntryKind getDiscriminant() {
+ return this.kind;
+ }
+
+ public void setDiscriminant(SCSpecEntryKind value) {
+ this.kind = value;
+ }
+
+ private SCSpecFunctionV0 functionV0;
+
+ public SCSpecFunctionV0 getFunctionV0() {
+ return this.functionV0;
+ }
+
+ public void setFunctionV0(SCSpecFunctionV0 value) {
+ this.functionV0 = value;
+ }
+
+ private SCSpecUDTStructV0 udtStructV0;
+
+ public SCSpecUDTStructV0 getUdtStructV0() {
+ return this.udtStructV0;
+ }
+
+ public void setUdtStructV0(SCSpecUDTStructV0 value) {
+ this.udtStructV0 = value;
+ }
+
+ private SCSpecUDTUnionV0 udtUnionV0;
+
+ public SCSpecUDTUnionV0 getUdtUnionV0() {
+ return this.udtUnionV0;
+ }
+
+ public void setUdtUnionV0(SCSpecUDTUnionV0 value) {
+ this.udtUnionV0 = value;
+ }
+
+ private SCSpecUDTEnumV0 udtEnumV0;
+
+ public SCSpecUDTEnumV0 getUdtEnumV0() {
+ return this.udtEnumV0;
+ }
+
+ public void setUdtEnumV0(SCSpecUDTEnumV0 value) {
+ this.udtEnumV0 = value;
+ }
+
+ private SCSpecUDTErrorEnumV0 udtErrorEnumV0;
+
+ public SCSpecUDTErrorEnumV0 getUdtErrorEnumV0() {
+ return this.udtErrorEnumV0;
+ }
+
+ public void setUdtErrorEnumV0(SCSpecUDTErrorEnumV0 value) {
+ this.udtErrorEnumV0 = value;
+ }
+
+ public static final class Builder {
+ private SCSpecEntryKind discriminant;
+ private SCSpecFunctionV0 functionV0;
+ private SCSpecUDTStructV0 udtStructV0;
+ private SCSpecUDTUnionV0 udtUnionV0;
+ private SCSpecUDTEnumV0 udtEnumV0;
+ private SCSpecUDTErrorEnumV0 udtErrorEnumV0;
+
+ public Builder discriminant(SCSpecEntryKind discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder functionV0(SCSpecFunctionV0 functionV0) {
+ this.functionV0 = functionV0;
+ return this;
+ }
+
+ public Builder udtStructV0(SCSpecUDTStructV0 udtStructV0) {
+ this.udtStructV0 = udtStructV0;
+ return this;
+ }
+
+ public Builder udtUnionV0(SCSpecUDTUnionV0 udtUnionV0) {
+ this.udtUnionV0 = udtUnionV0;
+ return this;
+ }
+
+ public Builder udtEnumV0(SCSpecUDTEnumV0 udtEnumV0) {
+ this.udtEnumV0 = udtEnumV0;
+ return this;
+ }
+
+ public Builder udtErrorEnumV0(SCSpecUDTErrorEnumV0 udtErrorEnumV0) {
+ this.udtErrorEnumV0 = udtErrorEnumV0;
+ return this;
+ }
+
+ public SCSpecEntry build() {
+ SCSpecEntry val = new SCSpecEntry();
+ val.setDiscriminant(discriminant);
+ val.setFunctionV0(this.functionV0);
+ val.setUdtStructV0(this.udtStructV0);
+ val.setUdtUnionV0(this.udtUnionV0);
+ val.setUdtEnumV0(this.udtEnumV0);
+ val.setUdtErrorEnumV0(this.udtErrorEnumV0);
+ return val;
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecEntry encodedSCSpecEntry)
+ throws IOException {
+ // Xdrgen::AST::Identifier
+ // SCSpecEntryKind
+ stream.writeInt(encodedSCSpecEntry.getDiscriminant().getValue());
+ switch (encodedSCSpecEntry.getDiscriminant()) {
+ case SC_SPEC_ENTRY_FUNCTION_V0:
+ SCSpecFunctionV0.encode(stream, encodedSCSpecEntry.functionV0);
+ break;
+ case SC_SPEC_ENTRY_UDT_STRUCT_V0:
+ SCSpecUDTStructV0.encode(stream, encodedSCSpecEntry.udtStructV0);
+ break;
+ case SC_SPEC_ENTRY_UDT_UNION_V0:
+ SCSpecUDTUnionV0.encode(stream, encodedSCSpecEntry.udtUnionV0);
+ break;
+ case SC_SPEC_ENTRY_UDT_ENUM_V0:
+ SCSpecUDTEnumV0.encode(stream, encodedSCSpecEntry.udtEnumV0);
+ break;
+ case SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0:
+ SCSpecUDTErrorEnumV0.encode(stream, encodedSCSpecEntry.udtErrorEnumV0);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecEntry decode(XdrDataInputStream stream) throws IOException {
+ SCSpecEntry decodedSCSpecEntry = new SCSpecEntry();
+ SCSpecEntryKind discriminant = SCSpecEntryKind.decode(stream);
+ decodedSCSpecEntry.setDiscriminant(discriminant);
+ switch (decodedSCSpecEntry.getDiscriminant()) {
+ case SC_SPEC_ENTRY_FUNCTION_V0:
+ decodedSCSpecEntry.functionV0 = SCSpecFunctionV0.decode(stream);
+ break;
+ case SC_SPEC_ENTRY_UDT_STRUCT_V0:
+ decodedSCSpecEntry.udtStructV0 = SCSpecUDTStructV0.decode(stream);
+ break;
+ case SC_SPEC_ENTRY_UDT_UNION_V0:
+ decodedSCSpecEntry.udtUnionV0 = SCSpecUDTUnionV0.decode(stream);
+ break;
+ case SC_SPEC_ENTRY_UDT_ENUM_V0:
+ decodedSCSpecEntry.udtEnumV0 = SCSpecUDTEnumV0.decode(stream);
+ break;
+ case SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0:
+ decodedSCSpecEntry.udtErrorEnumV0 = SCSpecUDTErrorEnumV0.decode(stream);
+ break;
+ }
+ return decodedSCSpecEntry;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.functionV0,
+ this.udtStructV0,
+ this.udtUnionV0,
+ this.udtEnumV0,
+ this.udtErrorEnumV0,
+ this.kind);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecEntry)) {
+ return false;
+ }
+
+ SCSpecEntry other = (SCSpecEntry) object;
+ return Objects.equals(this.functionV0, other.functionV0)
+ && Objects.equals(this.udtStructV0, other.udtStructV0)
+ && Objects.equals(this.udtUnionV0, other.udtUnionV0)
+ && Objects.equals(this.udtEnumV0, other.udtEnumV0)
+ && Objects.equals(this.udtErrorEnumV0, other.udtErrorEnumV0)
+ && Objects.equals(this.kind, other.kind);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecEntryKind.java b/src/main/java/org/stellar/sdk/xdr/SCSpecEntryKind.java
new file mode 100644
index 000000000..939af0447
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecEntryKind.java
@@ -0,0 +1,91 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum SCSpecEntryKind
+// {
+// SC_SPEC_ENTRY_FUNCTION_V0 = 0,
+// SC_SPEC_ENTRY_UDT_STRUCT_V0 = 1,
+// SC_SPEC_ENTRY_UDT_UNION_V0 = 2,
+// SC_SPEC_ENTRY_UDT_ENUM_V0 = 3,
+// SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0 = 4
+// };
+
+// ===========================================================================
+public enum SCSpecEntryKind implements XdrElement {
+ SC_SPEC_ENTRY_FUNCTION_V0(0),
+ SC_SPEC_ENTRY_UDT_STRUCT_V0(1),
+ SC_SPEC_ENTRY_UDT_UNION_V0(2),
+ SC_SPEC_ENTRY_UDT_ENUM_V0(3),
+ SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0(4),
+ ;
+ private int mValue;
+
+ SCSpecEntryKind(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SCSpecEntryKind decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SC_SPEC_ENTRY_FUNCTION_V0;
+ case 1:
+ return SC_SPEC_ENTRY_UDT_STRUCT_V0;
+ case 2:
+ return SC_SPEC_ENTRY_UDT_UNION_V0;
+ case 3:
+ return SC_SPEC_ENTRY_UDT_ENUM_V0;
+ case 4:
+ return SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecEntryKind value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecEntryKind fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecEntryKind fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecFunctionInputV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecFunctionInputV0.java
new file mode 100644
index 000000000..e3b5e378b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecFunctionInputV0.java
@@ -0,0 +1,146 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecFunctionInputV0
+// {
+// string doc;
+// string name<30>;
+// SCSpecTypeDef type;
+// };
+
+// ===========================================================================
+public class SCSpecFunctionInputV0 implements XdrElement {
+ public SCSpecFunctionInputV0() {}
+
+ private XdrString doc;
+
+ public XdrString getDoc() {
+ return this.doc;
+ }
+
+ public void setDoc(XdrString value) {
+ this.doc = value;
+ }
+
+ private XdrString name;
+
+ public XdrString getName() {
+ return this.name;
+ }
+
+ public void setName(XdrString value) {
+ this.name = value;
+ }
+
+ private SCSpecTypeDef type;
+
+ public SCSpecTypeDef getType() {
+ return this.type;
+ }
+
+ public void setType(SCSpecTypeDef value) {
+ this.type = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SCSpecFunctionInputV0 encodedSCSpecFunctionInputV0)
+ throws IOException {
+ encodedSCSpecFunctionInputV0.doc.encode(stream);
+ encodedSCSpecFunctionInputV0.name.encode(stream);
+ SCSpecTypeDef.encode(stream, encodedSCSpecFunctionInputV0.type);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecFunctionInputV0 decode(XdrDataInputStream stream) throws IOException {
+ SCSpecFunctionInputV0 decodedSCSpecFunctionInputV0 = new SCSpecFunctionInputV0();
+ decodedSCSpecFunctionInputV0.doc = XdrString.decode(stream, SC_SPEC_DOC_LIMIT);
+ decodedSCSpecFunctionInputV0.name = XdrString.decode(stream, 30);
+ decodedSCSpecFunctionInputV0.type = SCSpecTypeDef.decode(stream);
+ return decodedSCSpecFunctionInputV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.doc, this.name, this.type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecFunctionInputV0)) {
+ return false;
+ }
+
+ SCSpecFunctionInputV0 other = (SCSpecFunctionInputV0) object;
+ return Objects.equals(this.doc, other.doc)
+ && Objects.equals(this.name, other.name)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecFunctionInputV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecFunctionInputV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString doc;
+ private XdrString name;
+ private SCSpecTypeDef type;
+
+ public Builder doc(XdrString doc) {
+ this.doc = doc;
+ return this;
+ }
+
+ public Builder name(XdrString name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder type(SCSpecTypeDef type) {
+ this.type = type;
+ return this;
+ }
+
+ public SCSpecFunctionInputV0 build() {
+ SCSpecFunctionInputV0 val = new SCSpecFunctionInputV0();
+ val.setDoc(this.doc);
+ val.setName(this.name);
+ val.setType(this.type);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecFunctionV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecFunctionV0.java
new file mode 100644
index 000000000..12100314c
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecFunctionV0.java
@@ -0,0 +1,184 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecFunctionV0
+// {
+// string doc;
+// SCSymbol name;
+// SCSpecFunctionInputV0 inputs<10>;
+// SCSpecTypeDef outputs<1>;
+// };
+
+// ===========================================================================
+public class SCSpecFunctionV0 implements XdrElement {
+ public SCSpecFunctionV0() {}
+
+ private XdrString doc;
+
+ public XdrString getDoc() {
+ return this.doc;
+ }
+
+ public void setDoc(XdrString value) {
+ this.doc = value;
+ }
+
+ private SCSymbol name;
+
+ public SCSymbol getName() {
+ return this.name;
+ }
+
+ public void setName(SCSymbol value) {
+ this.name = value;
+ }
+
+ private SCSpecFunctionInputV0[] inputs;
+
+ public SCSpecFunctionInputV0[] getInputs() {
+ return this.inputs;
+ }
+
+ public void setInputs(SCSpecFunctionInputV0[] value) {
+ this.inputs = value;
+ }
+
+ private SCSpecTypeDef[] outputs;
+
+ public SCSpecTypeDef[] getOutputs() {
+ return this.outputs;
+ }
+
+ public void setOutputs(SCSpecTypeDef[] value) {
+ this.outputs = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecFunctionV0 encodedSCSpecFunctionV0)
+ throws IOException {
+ encodedSCSpecFunctionV0.doc.encode(stream);
+ SCSymbol.encode(stream, encodedSCSpecFunctionV0.name);
+ int inputssize = encodedSCSpecFunctionV0.getInputs().length;
+ stream.writeInt(inputssize);
+ for (int i = 0; i < inputssize; i++) {
+ SCSpecFunctionInputV0.encode(stream, encodedSCSpecFunctionV0.inputs[i]);
+ }
+ int outputssize = encodedSCSpecFunctionV0.getOutputs().length;
+ stream.writeInt(outputssize);
+ for (int i = 0; i < outputssize; i++) {
+ SCSpecTypeDef.encode(stream, encodedSCSpecFunctionV0.outputs[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecFunctionV0 decode(XdrDataInputStream stream) throws IOException {
+ SCSpecFunctionV0 decodedSCSpecFunctionV0 = new SCSpecFunctionV0();
+ decodedSCSpecFunctionV0.doc = XdrString.decode(stream, SC_SPEC_DOC_LIMIT);
+ decodedSCSpecFunctionV0.name = SCSymbol.decode(stream);
+ int inputssize = stream.readInt();
+ decodedSCSpecFunctionV0.inputs = new SCSpecFunctionInputV0[inputssize];
+ for (int i = 0; i < inputssize; i++) {
+ decodedSCSpecFunctionV0.inputs[i] = SCSpecFunctionInputV0.decode(stream);
+ }
+ int outputssize = stream.readInt();
+ decodedSCSpecFunctionV0.outputs = new SCSpecTypeDef[outputssize];
+ for (int i = 0; i < outputssize; i++) {
+ decodedSCSpecFunctionV0.outputs[i] = SCSpecTypeDef.decode(stream);
+ }
+ return decodedSCSpecFunctionV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.doc, this.name, Arrays.hashCode(this.inputs), Arrays.hashCode(this.outputs));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecFunctionV0)) {
+ return false;
+ }
+
+ SCSpecFunctionV0 other = (SCSpecFunctionV0) object;
+ return Objects.equals(this.doc, other.doc)
+ && Objects.equals(this.name, other.name)
+ && Arrays.equals(this.inputs, other.inputs)
+ && Arrays.equals(this.outputs, other.outputs);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecFunctionV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecFunctionV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString doc;
+ private SCSymbol name;
+ private SCSpecFunctionInputV0[] inputs;
+ private SCSpecTypeDef[] outputs;
+
+ public Builder doc(XdrString doc) {
+ this.doc = doc;
+ return this;
+ }
+
+ public Builder name(SCSymbol name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder inputs(SCSpecFunctionInputV0[] inputs) {
+ this.inputs = inputs;
+ return this;
+ }
+
+ public Builder outputs(SCSpecTypeDef[] outputs) {
+ this.outputs = outputs;
+ return this;
+ }
+
+ public SCSpecFunctionV0 build() {
+ SCSpecFunctionV0 val = new SCSpecFunctionV0();
+ val.setDoc(this.doc);
+ val.setName(this.name);
+ val.setInputs(this.inputs);
+ val.setOutputs(this.outputs);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecType.java b/src/main/java/org/stellar/sdk/xdr/SCSpecType.java
new file mode 100644
index 000000000..d8b2f9936
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecType.java
@@ -0,0 +1,177 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum SCSpecType
+// {
+// SC_SPEC_TYPE_VAL = 0,
+//
+// // Types with no parameters.
+// SC_SPEC_TYPE_BOOL = 1,
+// SC_SPEC_TYPE_VOID = 2,
+// SC_SPEC_TYPE_ERROR = 3,
+// SC_SPEC_TYPE_U32 = 4,
+// SC_SPEC_TYPE_I32 = 5,
+// SC_SPEC_TYPE_U64 = 6,
+// SC_SPEC_TYPE_I64 = 7,
+// SC_SPEC_TYPE_TIMEPOINT = 8,
+// SC_SPEC_TYPE_DURATION = 9,
+// SC_SPEC_TYPE_U128 = 10,
+// SC_SPEC_TYPE_I128 = 11,
+// SC_SPEC_TYPE_U256 = 12,
+// SC_SPEC_TYPE_I256 = 13,
+// SC_SPEC_TYPE_BYTES = 14,
+// SC_SPEC_TYPE_STRING = 16,
+// SC_SPEC_TYPE_SYMBOL = 17,
+// SC_SPEC_TYPE_ADDRESS = 19,
+//
+// // Types with parameters.
+// SC_SPEC_TYPE_OPTION = 1000,
+// SC_SPEC_TYPE_RESULT = 1001,
+// SC_SPEC_TYPE_VEC = 1002,
+// SC_SPEC_TYPE_MAP = 1004,
+// SC_SPEC_TYPE_TUPLE = 1005,
+// SC_SPEC_TYPE_BYTES_N = 1006,
+//
+// // User defined types.
+// SC_SPEC_TYPE_UDT = 2000
+// };
+
+// ===========================================================================
+public enum SCSpecType implements XdrElement {
+ SC_SPEC_TYPE_VAL(0),
+ SC_SPEC_TYPE_BOOL(1),
+ SC_SPEC_TYPE_VOID(2),
+ SC_SPEC_TYPE_ERROR(3),
+ SC_SPEC_TYPE_U32(4),
+ SC_SPEC_TYPE_I32(5),
+ SC_SPEC_TYPE_U64(6),
+ SC_SPEC_TYPE_I64(7),
+ SC_SPEC_TYPE_TIMEPOINT(8),
+ SC_SPEC_TYPE_DURATION(9),
+ SC_SPEC_TYPE_U128(10),
+ SC_SPEC_TYPE_I128(11),
+ SC_SPEC_TYPE_U256(12),
+ SC_SPEC_TYPE_I256(13),
+ SC_SPEC_TYPE_BYTES(14),
+ SC_SPEC_TYPE_STRING(16),
+ SC_SPEC_TYPE_SYMBOL(17),
+ SC_SPEC_TYPE_ADDRESS(19),
+ SC_SPEC_TYPE_OPTION(1000),
+ SC_SPEC_TYPE_RESULT(1001),
+ SC_SPEC_TYPE_VEC(1002),
+ SC_SPEC_TYPE_MAP(1004),
+ SC_SPEC_TYPE_TUPLE(1005),
+ SC_SPEC_TYPE_BYTES_N(1006),
+ SC_SPEC_TYPE_UDT(2000),
+ ;
+ private int mValue;
+
+ SCSpecType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SCSpecType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SC_SPEC_TYPE_VAL;
+ case 1:
+ return SC_SPEC_TYPE_BOOL;
+ case 2:
+ return SC_SPEC_TYPE_VOID;
+ case 3:
+ return SC_SPEC_TYPE_ERROR;
+ case 4:
+ return SC_SPEC_TYPE_U32;
+ case 5:
+ return SC_SPEC_TYPE_I32;
+ case 6:
+ return SC_SPEC_TYPE_U64;
+ case 7:
+ return SC_SPEC_TYPE_I64;
+ case 8:
+ return SC_SPEC_TYPE_TIMEPOINT;
+ case 9:
+ return SC_SPEC_TYPE_DURATION;
+ case 10:
+ return SC_SPEC_TYPE_U128;
+ case 11:
+ return SC_SPEC_TYPE_I128;
+ case 12:
+ return SC_SPEC_TYPE_U256;
+ case 13:
+ return SC_SPEC_TYPE_I256;
+ case 14:
+ return SC_SPEC_TYPE_BYTES;
+ case 16:
+ return SC_SPEC_TYPE_STRING;
+ case 17:
+ return SC_SPEC_TYPE_SYMBOL;
+ case 19:
+ return SC_SPEC_TYPE_ADDRESS;
+ case 1000:
+ return SC_SPEC_TYPE_OPTION;
+ case 1001:
+ return SC_SPEC_TYPE_RESULT;
+ case 1002:
+ return SC_SPEC_TYPE_VEC;
+ case 1004:
+ return SC_SPEC_TYPE_MAP;
+ case 1005:
+ return SC_SPEC_TYPE_TUPLE;
+ case 1006:
+ return SC_SPEC_TYPE_BYTES_N;
+ case 2000:
+ return SC_SPEC_TYPE_UDT;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecTypeBytesN.java b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeBytesN.java
new file mode 100644
index 000000000..55092cd1f
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeBytesN.java
@@ -0,0 +1,103 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecTypeBytesN
+// {
+// uint32 n;
+// };
+
+// ===========================================================================
+public class SCSpecTypeBytesN implements XdrElement {
+ public SCSpecTypeBytesN() {}
+
+ private Uint32 n;
+
+ public Uint32 getN() {
+ return this.n;
+ }
+
+ public void setN(Uint32 value) {
+ this.n = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecTypeBytesN encodedSCSpecTypeBytesN)
+ throws IOException {
+ Uint32.encode(stream, encodedSCSpecTypeBytesN.n);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecTypeBytesN decode(XdrDataInputStream stream) throws IOException {
+ SCSpecTypeBytesN decodedSCSpecTypeBytesN = new SCSpecTypeBytesN();
+ decodedSCSpecTypeBytesN.n = Uint32.decode(stream);
+ return decodedSCSpecTypeBytesN;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.n);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecTypeBytesN)) {
+ return false;
+ }
+
+ SCSpecTypeBytesN other = (SCSpecTypeBytesN) object;
+ return Objects.equals(this.n, other.n);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecTypeBytesN fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecTypeBytesN fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Uint32 n;
+
+ public Builder n(Uint32 n) {
+ this.n = n;
+ return this;
+ }
+
+ public SCSpecTypeBytesN build() {
+ SCSpecTypeBytesN val = new SCSpecTypeBytesN();
+ val.setN(this.n);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecTypeDef.java b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeDef.java
new file mode 100644
index 000000000..f88c62831
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeDef.java
@@ -0,0 +1,349 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union SCSpecTypeDef switch (SCSpecType type)
+// {
+// case SC_SPEC_TYPE_VAL:
+// case SC_SPEC_TYPE_BOOL:
+// case SC_SPEC_TYPE_VOID:
+// case SC_SPEC_TYPE_ERROR:
+// case SC_SPEC_TYPE_U32:
+// case SC_SPEC_TYPE_I32:
+// case SC_SPEC_TYPE_U64:
+// case SC_SPEC_TYPE_I64:
+// case SC_SPEC_TYPE_TIMEPOINT:
+// case SC_SPEC_TYPE_DURATION:
+// case SC_SPEC_TYPE_U128:
+// case SC_SPEC_TYPE_I128:
+// case SC_SPEC_TYPE_U256:
+// case SC_SPEC_TYPE_I256:
+// case SC_SPEC_TYPE_BYTES:
+// case SC_SPEC_TYPE_STRING:
+// case SC_SPEC_TYPE_SYMBOL:
+// case SC_SPEC_TYPE_ADDRESS:
+// void;
+// case SC_SPEC_TYPE_OPTION:
+// SCSpecTypeOption option;
+// case SC_SPEC_TYPE_RESULT:
+// SCSpecTypeResult result;
+// case SC_SPEC_TYPE_VEC:
+// SCSpecTypeVec vec;
+// case SC_SPEC_TYPE_MAP:
+// SCSpecTypeMap map;
+// case SC_SPEC_TYPE_TUPLE:
+// SCSpecTypeTuple tuple;
+// case SC_SPEC_TYPE_BYTES_N:
+// SCSpecTypeBytesN bytesN;
+// case SC_SPEC_TYPE_UDT:
+// SCSpecTypeUDT udt;
+// };
+
+// ===========================================================================
+public class SCSpecTypeDef implements XdrElement {
+ public SCSpecTypeDef() {}
+
+ SCSpecType type;
+
+ public SCSpecType getDiscriminant() {
+ return this.type;
+ }
+
+ public void setDiscriminant(SCSpecType value) {
+ this.type = value;
+ }
+
+ private SCSpecTypeOption option;
+
+ public SCSpecTypeOption getOption() {
+ return this.option;
+ }
+
+ public void setOption(SCSpecTypeOption value) {
+ this.option = value;
+ }
+
+ private SCSpecTypeResult result;
+
+ public SCSpecTypeResult getResult() {
+ return this.result;
+ }
+
+ public void setResult(SCSpecTypeResult value) {
+ this.result = value;
+ }
+
+ private SCSpecTypeVec vec;
+
+ public SCSpecTypeVec getVec() {
+ return this.vec;
+ }
+
+ public void setVec(SCSpecTypeVec value) {
+ this.vec = value;
+ }
+
+ private SCSpecTypeMap map;
+
+ public SCSpecTypeMap getMap() {
+ return this.map;
+ }
+
+ public void setMap(SCSpecTypeMap value) {
+ this.map = value;
+ }
+
+ private SCSpecTypeTuple tuple;
+
+ public SCSpecTypeTuple getTuple() {
+ return this.tuple;
+ }
+
+ public void setTuple(SCSpecTypeTuple value) {
+ this.tuple = value;
+ }
+
+ private SCSpecTypeBytesN bytesN;
+
+ public SCSpecTypeBytesN getBytesN() {
+ return this.bytesN;
+ }
+
+ public void setBytesN(SCSpecTypeBytesN value) {
+ this.bytesN = value;
+ }
+
+ private SCSpecTypeUDT udt;
+
+ public SCSpecTypeUDT getUdt() {
+ return this.udt;
+ }
+
+ public void setUdt(SCSpecTypeUDT value) {
+ this.udt = value;
+ }
+
+ public static final class Builder {
+ private SCSpecType discriminant;
+ private SCSpecTypeOption option;
+ private SCSpecTypeResult result;
+ private SCSpecTypeVec vec;
+ private SCSpecTypeMap map;
+ private SCSpecTypeTuple tuple;
+ private SCSpecTypeBytesN bytesN;
+ private SCSpecTypeUDT udt;
+
+ public Builder discriminant(SCSpecType discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder option(SCSpecTypeOption option) {
+ this.option = option;
+ return this;
+ }
+
+ public Builder result(SCSpecTypeResult result) {
+ this.result = result;
+ return this;
+ }
+
+ public Builder vec(SCSpecTypeVec vec) {
+ this.vec = vec;
+ return this;
+ }
+
+ public Builder map(SCSpecTypeMap map) {
+ this.map = map;
+ return this;
+ }
+
+ public Builder tuple(SCSpecTypeTuple tuple) {
+ this.tuple = tuple;
+ return this;
+ }
+
+ public Builder bytesN(SCSpecTypeBytesN bytesN) {
+ this.bytesN = bytesN;
+ return this;
+ }
+
+ public Builder udt(SCSpecTypeUDT udt) {
+ this.udt = udt;
+ return this;
+ }
+
+ public SCSpecTypeDef build() {
+ SCSpecTypeDef val = new SCSpecTypeDef();
+ val.setDiscriminant(discriminant);
+ val.setOption(this.option);
+ val.setResult(this.result);
+ val.setVec(this.vec);
+ val.setMap(this.map);
+ val.setTuple(this.tuple);
+ val.setBytesN(this.bytesN);
+ val.setUdt(this.udt);
+ return val;
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecTypeDef encodedSCSpecTypeDef)
+ throws IOException {
+ // Xdrgen::AST::Identifier
+ // SCSpecType
+ stream.writeInt(encodedSCSpecTypeDef.getDiscriminant().getValue());
+ switch (encodedSCSpecTypeDef.getDiscriminant()) {
+ case SC_SPEC_TYPE_VAL:
+ case SC_SPEC_TYPE_BOOL:
+ case SC_SPEC_TYPE_VOID:
+ case SC_SPEC_TYPE_ERROR:
+ case SC_SPEC_TYPE_U32:
+ case SC_SPEC_TYPE_I32:
+ case SC_SPEC_TYPE_U64:
+ case SC_SPEC_TYPE_I64:
+ case SC_SPEC_TYPE_TIMEPOINT:
+ case SC_SPEC_TYPE_DURATION:
+ case SC_SPEC_TYPE_U128:
+ case SC_SPEC_TYPE_I128:
+ case SC_SPEC_TYPE_U256:
+ case SC_SPEC_TYPE_I256:
+ case SC_SPEC_TYPE_BYTES:
+ case SC_SPEC_TYPE_STRING:
+ case SC_SPEC_TYPE_SYMBOL:
+ case SC_SPEC_TYPE_ADDRESS:
+ break;
+ case SC_SPEC_TYPE_OPTION:
+ SCSpecTypeOption.encode(stream, encodedSCSpecTypeDef.option);
+ break;
+ case SC_SPEC_TYPE_RESULT:
+ SCSpecTypeResult.encode(stream, encodedSCSpecTypeDef.result);
+ break;
+ case SC_SPEC_TYPE_VEC:
+ SCSpecTypeVec.encode(stream, encodedSCSpecTypeDef.vec);
+ break;
+ case SC_SPEC_TYPE_MAP:
+ SCSpecTypeMap.encode(stream, encodedSCSpecTypeDef.map);
+ break;
+ case SC_SPEC_TYPE_TUPLE:
+ SCSpecTypeTuple.encode(stream, encodedSCSpecTypeDef.tuple);
+ break;
+ case SC_SPEC_TYPE_BYTES_N:
+ SCSpecTypeBytesN.encode(stream, encodedSCSpecTypeDef.bytesN);
+ break;
+ case SC_SPEC_TYPE_UDT:
+ SCSpecTypeUDT.encode(stream, encodedSCSpecTypeDef.udt);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecTypeDef decode(XdrDataInputStream stream) throws IOException {
+ SCSpecTypeDef decodedSCSpecTypeDef = new SCSpecTypeDef();
+ SCSpecType discriminant = SCSpecType.decode(stream);
+ decodedSCSpecTypeDef.setDiscriminant(discriminant);
+ switch (decodedSCSpecTypeDef.getDiscriminant()) {
+ case SC_SPEC_TYPE_VAL:
+ case SC_SPEC_TYPE_BOOL:
+ case SC_SPEC_TYPE_VOID:
+ case SC_SPEC_TYPE_ERROR:
+ case SC_SPEC_TYPE_U32:
+ case SC_SPEC_TYPE_I32:
+ case SC_SPEC_TYPE_U64:
+ case SC_SPEC_TYPE_I64:
+ case SC_SPEC_TYPE_TIMEPOINT:
+ case SC_SPEC_TYPE_DURATION:
+ case SC_SPEC_TYPE_U128:
+ case SC_SPEC_TYPE_I128:
+ case SC_SPEC_TYPE_U256:
+ case SC_SPEC_TYPE_I256:
+ case SC_SPEC_TYPE_BYTES:
+ case SC_SPEC_TYPE_STRING:
+ case SC_SPEC_TYPE_SYMBOL:
+ case SC_SPEC_TYPE_ADDRESS:
+ break;
+ case SC_SPEC_TYPE_OPTION:
+ decodedSCSpecTypeDef.option = SCSpecTypeOption.decode(stream);
+ break;
+ case SC_SPEC_TYPE_RESULT:
+ decodedSCSpecTypeDef.result = SCSpecTypeResult.decode(stream);
+ break;
+ case SC_SPEC_TYPE_VEC:
+ decodedSCSpecTypeDef.vec = SCSpecTypeVec.decode(stream);
+ break;
+ case SC_SPEC_TYPE_MAP:
+ decodedSCSpecTypeDef.map = SCSpecTypeMap.decode(stream);
+ break;
+ case SC_SPEC_TYPE_TUPLE:
+ decodedSCSpecTypeDef.tuple = SCSpecTypeTuple.decode(stream);
+ break;
+ case SC_SPEC_TYPE_BYTES_N:
+ decodedSCSpecTypeDef.bytesN = SCSpecTypeBytesN.decode(stream);
+ break;
+ case SC_SPEC_TYPE_UDT:
+ decodedSCSpecTypeDef.udt = SCSpecTypeUDT.decode(stream);
+ break;
+ }
+ return decodedSCSpecTypeDef;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.option, this.result, this.vec, this.map, this.tuple, this.bytesN, this.udt, this.type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecTypeDef)) {
+ return false;
+ }
+
+ SCSpecTypeDef other = (SCSpecTypeDef) object;
+ return Objects.equals(this.option, other.option)
+ && Objects.equals(this.result, other.result)
+ && Objects.equals(this.vec, other.vec)
+ && Objects.equals(this.map, other.map)
+ && Objects.equals(this.tuple, other.tuple)
+ && Objects.equals(this.bytesN, other.bytesN)
+ && Objects.equals(this.udt, other.udt)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecTypeDef fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecTypeDef fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecTypeMap.java b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeMap.java
new file mode 100644
index 000000000..1a2547271
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeMap.java
@@ -0,0 +1,124 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecTypeMap
+// {
+// SCSpecTypeDef keyType;
+// SCSpecTypeDef valueType;
+// };
+
+// ===========================================================================
+public class SCSpecTypeMap implements XdrElement {
+ public SCSpecTypeMap() {}
+
+ private SCSpecTypeDef keyType;
+
+ public SCSpecTypeDef getKeyType() {
+ return this.keyType;
+ }
+
+ public void setKeyType(SCSpecTypeDef value) {
+ this.keyType = value;
+ }
+
+ private SCSpecTypeDef valueType;
+
+ public SCSpecTypeDef getValueType() {
+ return this.valueType;
+ }
+
+ public void setValueType(SCSpecTypeDef value) {
+ this.valueType = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecTypeMap encodedSCSpecTypeMap)
+ throws IOException {
+ SCSpecTypeDef.encode(stream, encodedSCSpecTypeMap.keyType);
+ SCSpecTypeDef.encode(stream, encodedSCSpecTypeMap.valueType);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecTypeMap decode(XdrDataInputStream stream) throws IOException {
+ SCSpecTypeMap decodedSCSpecTypeMap = new SCSpecTypeMap();
+ decodedSCSpecTypeMap.keyType = SCSpecTypeDef.decode(stream);
+ decodedSCSpecTypeMap.valueType = SCSpecTypeDef.decode(stream);
+ return decodedSCSpecTypeMap;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.keyType, this.valueType);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecTypeMap)) {
+ return false;
+ }
+
+ SCSpecTypeMap other = (SCSpecTypeMap) object;
+ return Objects.equals(this.keyType, other.keyType)
+ && Objects.equals(this.valueType, other.valueType);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecTypeMap fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecTypeMap fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCSpecTypeDef keyType;
+ private SCSpecTypeDef valueType;
+
+ public Builder keyType(SCSpecTypeDef keyType) {
+ this.keyType = keyType;
+ return this;
+ }
+
+ public Builder valueType(SCSpecTypeDef valueType) {
+ this.valueType = valueType;
+ return this;
+ }
+
+ public SCSpecTypeMap build() {
+ SCSpecTypeMap val = new SCSpecTypeMap();
+ val.setKeyType(this.keyType);
+ val.setValueType(this.valueType);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecTypeOption.java b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeOption.java
new file mode 100644
index 000000000..4bc06f4a4
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeOption.java
@@ -0,0 +1,103 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecTypeOption
+// {
+// SCSpecTypeDef valueType;
+// };
+
+// ===========================================================================
+public class SCSpecTypeOption implements XdrElement {
+ public SCSpecTypeOption() {}
+
+ private SCSpecTypeDef valueType;
+
+ public SCSpecTypeDef getValueType() {
+ return this.valueType;
+ }
+
+ public void setValueType(SCSpecTypeDef value) {
+ this.valueType = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecTypeOption encodedSCSpecTypeOption)
+ throws IOException {
+ SCSpecTypeDef.encode(stream, encodedSCSpecTypeOption.valueType);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecTypeOption decode(XdrDataInputStream stream) throws IOException {
+ SCSpecTypeOption decodedSCSpecTypeOption = new SCSpecTypeOption();
+ decodedSCSpecTypeOption.valueType = SCSpecTypeDef.decode(stream);
+ return decodedSCSpecTypeOption;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.valueType);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecTypeOption)) {
+ return false;
+ }
+
+ SCSpecTypeOption other = (SCSpecTypeOption) object;
+ return Objects.equals(this.valueType, other.valueType);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecTypeOption fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecTypeOption fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCSpecTypeDef valueType;
+
+ public Builder valueType(SCSpecTypeDef valueType) {
+ this.valueType = valueType;
+ return this;
+ }
+
+ public SCSpecTypeOption build() {
+ SCSpecTypeOption val = new SCSpecTypeOption();
+ val.setValueType(this.valueType);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecTypeResult.java b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeResult.java
new file mode 100644
index 000000000..a1f6d84ac
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeResult.java
@@ -0,0 +1,124 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecTypeResult
+// {
+// SCSpecTypeDef okType;
+// SCSpecTypeDef errorType;
+// };
+
+// ===========================================================================
+public class SCSpecTypeResult implements XdrElement {
+ public SCSpecTypeResult() {}
+
+ private SCSpecTypeDef okType;
+
+ public SCSpecTypeDef getOkType() {
+ return this.okType;
+ }
+
+ public void setOkType(SCSpecTypeDef value) {
+ this.okType = value;
+ }
+
+ private SCSpecTypeDef errorType;
+
+ public SCSpecTypeDef getErrorType() {
+ return this.errorType;
+ }
+
+ public void setErrorType(SCSpecTypeDef value) {
+ this.errorType = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecTypeResult encodedSCSpecTypeResult)
+ throws IOException {
+ SCSpecTypeDef.encode(stream, encodedSCSpecTypeResult.okType);
+ SCSpecTypeDef.encode(stream, encodedSCSpecTypeResult.errorType);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecTypeResult decode(XdrDataInputStream stream) throws IOException {
+ SCSpecTypeResult decodedSCSpecTypeResult = new SCSpecTypeResult();
+ decodedSCSpecTypeResult.okType = SCSpecTypeDef.decode(stream);
+ decodedSCSpecTypeResult.errorType = SCSpecTypeDef.decode(stream);
+ return decodedSCSpecTypeResult;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.okType, this.errorType);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecTypeResult)) {
+ return false;
+ }
+
+ SCSpecTypeResult other = (SCSpecTypeResult) object;
+ return Objects.equals(this.okType, other.okType)
+ && Objects.equals(this.errorType, other.errorType);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecTypeResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecTypeResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCSpecTypeDef okType;
+ private SCSpecTypeDef errorType;
+
+ public Builder okType(SCSpecTypeDef okType) {
+ this.okType = okType;
+ return this;
+ }
+
+ public Builder errorType(SCSpecTypeDef errorType) {
+ this.errorType = errorType;
+ return this;
+ }
+
+ public SCSpecTypeResult build() {
+ SCSpecTypeResult val = new SCSpecTypeResult();
+ val.setOkType(this.okType);
+ val.setErrorType(this.errorType);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecTypeTuple.java b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeTuple.java
new file mode 100644
index 000000000..ba25be63e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeTuple.java
@@ -0,0 +1,111 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// struct SCSpecTypeTuple
+// {
+// SCSpecTypeDef valueTypes<12>;
+// };
+
+// ===========================================================================
+public class SCSpecTypeTuple implements XdrElement {
+ public SCSpecTypeTuple() {}
+
+ private SCSpecTypeDef[] valueTypes;
+
+ public SCSpecTypeDef[] getValueTypes() {
+ return this.valueTypes;
+ }
+
+ public void setValueTypes(SCSpecTypeDef[] value) {
+ this.valueTypes = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecTypeTuple encodedSCSpecTypeTuple)
+ throws IOException {
+ int valueTypessize = encodedSCSpecTypeTuple.getValueTypes().length;
+ stream.writeInt(valueTypessize);
+ for (int i = 0; i < valueTypessize; i++) {
+ SCSpecTypeDef.encode(stream, encodedSCSpecTypeTuple.valueTypes[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecTypeTuple decode(XdrDataInputStream stream) throws IOException {
+ SCSpecTypeTuple decodedSCSpecTypeTuple = new SCSpecTypeTuple();
+ int valueTypessize = stream.readInt();
+ decodedSCSpecTypeTuple.valueTypes = new SCSpecTypeDef[valueTypessize];
+ for (int i = 0; i < valueTypessize; i++) {
+ decodedSCSpecTypeTuple.valueTypes[i] = SCSpecTypeDef.decode(stream);
+ }
+ return decodedSCSpecTypeTuple;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(this.valueTypes);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecTypeTuple)) {
+ return false;
+ }
+
+ SCSpecTypeTuple other = (SCSpecTypeTuple) object;
+ return Arrays.equals(this.valueTypes, other.valueTypes);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecTypeTuple fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecTypeTuple fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCSpecTypeDef[] valueTypes;
+
+ public Builder valueTypes(SCSpecTypeDef[] valueTypes) {
+ this.valueTypes = valueTypes;
+ return this;
+ }
+
+ public SCSpecTypeTuple build() {
+ SCSpecTypeTuple val = new SCSpecTypeTuple();
+ val.setValueTypes(this.valueTypes);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecTypeUDT.java b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeUDT.java
new file mode 100644
index 000000000..b22748df9
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeUDT.java
@@ -0,0 +1,103 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecTypeUDT
+// {
+// string name<60>;
+// };
+
+// ===========================================================================
+public class SCSpecTypeUDT implements XdrElement {
+ public SCSpecTypeUDT() {}
+
+ private XdrString name;
+
+ public XdrString getName() {
+ return this.name;
+ }
+
+ public void setName(XdrString value) {
+ this.name = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecTypeUDT encodedSCSpecTypeUDT)
+ throws IOException {
+ encodedSCSpecTypeUDT.name.encode(stream);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecTypeUDT decode(XdrDataInputStream stream) throws IOException {
+ SCSpecTypeUDT decodedSCSpecTypeUDT = new SCSpecTypeUDT();
+ decodedSCSpecTypeUDT.name = XdrString.decode(stream, 60);
+ return decodedSCSpecTypeUDT;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.name);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecTypeUDT)) {
+ return false;
+ }
+
+ SCSpecTypeUDT other = (SCSpecTypeUDT) object;
+ return Objects.equals(this.name, other.name);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecTypeUDT fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecTypeUDT fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString name;
+
+ public Builder name(XdrString name) {
+ this.name = name;
+ return this;
+ }
+
+ public SCSpecTypeUDT build() {
+ SCSpecTypeUDT val = new SCSpecTypeUDT();
+ val.setName(this.name);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecTypeVec.java b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeVec.java
new file mode 100644
index 000000000..10c3a41b6
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecTypeVec.java
@@ -0,0 +1,103 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecTypeVec
+// {
+// SCSpecTypeDef elementType;
+// };
+
+// ===========================================================================
+public class SCSpecTypeVec implements XdrElement {
+ public SCSpecTypeVec() {}
+
+ private SCSpecTypeDef elementType;
+
+ public SCSpecTypeDef getElementType() {
+ return this.elementType;
+ }
+
+ public void setElementType(SCSpecTypeDef value) {
+ this.elementType = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecTypeVec encodedSCSpecTypeVec)
+ throws IOException {
+ SCSpecTypeDef.encode(stream, encodedSCSpecTypeVec.elementType);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecTypeVec decode(XdrDataInputStream stream) throws IOException {
+ SCSpecTypeVec decodedSCSpecTypeVec = new SCSpecTypeVec();
+ decodedSCSpecTypeVec.elementType = SCSpecTypeDef.decode(stream);
+ return decodedSCSpecTypeVec;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.elementType);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecTypeVec)) {
+ return false;
+ }
+
+ SCSpecTypeVec other = (SCSpecTypeVec) object;
+ return Objects.equals(this.elementType, other.elementType);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecTypeVec fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecTypeVec fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCSpecTypeDef elementType;
+
+ public Builder elementType(SCSpecTypeDef elementType) {
+ this.elementType = elementType;
+ return this;
+ }
+
+ public SCSpecTypeVec build() {
+ SCSpecTypeVec val = new SCSpecTypeVec();
+ val.setElementType(this.elementType);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTEnumCaseV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTEnumCaseV0.java
new file mode 100644
index 000000000..c26d9d35a
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTEnumCaseV0.java
@@ -0,0 +1,146 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecUDTEnumCaseV0
+// {
+// string doc;
+// string name<60>;
+// uint32 value;
+// };
+
+// ===========================================================================
+public class SCSpecUDTEnumCaseV0 implements XdrElement {
+ public SCSpecUDTEnumCaseV0() {}
+
+ private XdrString doc;
+
+ public XdrString getDoc() {
+ return this.doc;
+ }
+
+ public void setDoc(XdrString value) {
+ this.doc = value;
+ }
+
+ private XdrString name;
+
+ public XdrString getName() {
+ return this.name;
+ }
+
+ public void setName(XdrString value) {
+ this.name = value;
+ }
+
+ private Uint32 value;
+
+ public Uint32 getValue() {
+ return this.value;
+ }
+
+ public void setValue(Uint32 value) {
+ this.value = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SCSpecUDTEnumCaseV0 encodedSCSpecUDTEnumCaseV0)
+ throws IOException {
+ encodedSCSpecUDTEnumCaseV0.doc.encode(stream);
+ encodedSCSpecUDTEnumCaseV0.name.encode(stream);
+ Uint32.encode(stream, encodedSCSpecUDTEnumCaseV0.value);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecUDTEnumCaseV0 decode(XdrDataInputStream stream) throws IOException {
+ SCSpecUDTEnumCaseV0 decodedSCSpecUDTEnumCaseV0 = new SCSpecUDTEnumCaseV0();
+ decodedSCSpecUDTEnumCaseV0.doc = XdrString.decode(stream, SC_SPEC_DOC_LIMIT);
+ decodedSCSpecUDTEnumCaseV0.name = XdrString.decode(stream, 60);
+ decodedSCSpecUDTEnumCaseV0.value = Uint32.decode(stream);
+ return decodedSCSpecUDTEnumCaseV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.doc, this.name, this.value);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecUDTEnumCaseV0)) {
+ return false;
+ }
+
+ SCSpecUDTEnumCaseV0 other = (SCSpecUDTEnumCaseV0) object;
+ return Objects.equals(this.doc, other.doc)
+ && Objects.equals(this.name, other.name)
+ && Objects.equals(this.value, other.value);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecUDTEnumCaseV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecUDTEnumCaseV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString doc;
+ private XdrString name;
+ private Uint32 value;
+
+ public Builder doc(XdrString doc) {
+ this.doc = doc;
+ return this;
+ }
+
+ public Builder name(XdrString name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder value(Uint32 value) {
+ this.value = value;
+ return this;
+ }
+
+ public SCSpecUDTEnumCaseV0 build() {
+ SCSpecUDTEnumCaseV0 val = new SCSpecUDTEnumCaseV0();
+ val.setDoc(this.doc);
+ val.setName(this.name);
+ val.setValue(this.value);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTEnumV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTEnumV0.java
new file mode 100644
index 000000000..3397a0b72
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTEnumV0.java
@@ -0,0 +1,175 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecUDTEnumV0
+// {
+// string doc;
+// string lib<80>;
+// string name<60>;
+// SCSpecUDTEnumCaseV0 cases<50>;
+// };
+
+// ===========================================================================
+public class SCSpecUDTEnumV0 implements XdrElement {
+ public SCSpecUDTEnumV0() {}
+
+ private XdrString doc;
+
+ public XdrString getDoc() {
+ return this.doc;
+ }
+
+ public void setDoc(XdrString value) {
+ this.doc = value;
+ }
+
+ private XdrString lib;
+
+ public XdrString getLib() {
+ return this.lib;
+ }
+
+ public void setLib(XdrString value) {
+ this.lib = value;
+ }
+
+ private XdrString name;
+
+ public XdrString getName() {
+ return this.name;
+ }
+
+ public void setName(XdrString value) {
+ this.name = value;
+ }
+
+ private SCSpecUDTEnumCaseV0[] cases;
+
+ public SCSpecUDTEnumCaseV0[] getCases() {
+ return this.cases;
+ }
+
+ public void setCases(SCSpecUDTEnumCaseV0[] value) {
+ this.cases = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecUDTEnumV0 encodedSCSpecUDTEnumV0)
+ throws IOException {
+ encodedSCSpecUDTEnumV0.doc.encode(stream);
+ encodedSCSpecUDTEnumV0.lib.encode(stream);
+ encodedSCSpecUDTEnumV0.name.encode(stream);
+ int casessize = encodedSCSpecUDTEnumV0.getCases().length;
+ stream.writeInt(casessize);
+ for (int i = 0; i < casessize; i++) {
+ SCSpecUDTEnumCaseV0.encode(stream, encodedSCSpecUDTEnumV0.cases[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecUDTEnumV0 decode(XdrDataInputStream stream) throws IOException {
+ SCSpecUDTEnumV0 decodedSCSpecUDTEnumV0 = new SCSpecUDTEnumV0();
+ decodedSCSpecUDTEnumV0.doc = XdrString.decode(stream, SC_SPEC_DOC_LIMIT);
+ decodedSCSpecUDTEnumV0.lib = XdrString.decode(stream, 80);
+ decodedSCSpecUDTEnumV0.name = XdrString.decode(stream, 60);
+ int casessize = stream.readInt();
+ decodedSCSpecUDTEnumV0.cases = new SCSpecUDTEnumCaseV0[casessize];
+ for (int i = 0; i < casessize; i++) {
+ decodedSCSpecUDTEnumV0.cases[i] = SCSpecUDTEnumCaseV0.decode(stream);
+ }
+ return decodedSCSpecUDTEnumV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.doc, this.lib, this.name, Arrays.hashCode(this.cases));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecUDTEnumV0)) {
+ return false;
+ }
+
+ SCSpecUDTEnumV0 other = (SCSpecUDTEnumV0) object;
+ return Objects.equals(this.doc, other.doc)
+ && Objects.equals(this.lib, other.lib)
+ && Objects.equals(this.name, other.name)
+ && Arrays.equals(this.cases, other.cases);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecUDTEnumV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecUDTEnumV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString doc;
+ private XdrString lib;
+ private XdrString name;
+ private SCSpecUDTEnumCaseV0[] cases;
+
+ public Builder doc(XdrString doc) {
+ this.doc = doc;
+ return this;
+ }
+
+ public Builder lib(XdrString lib) {
+ this.lib = lib;
+ return this;
+ }
+
+ public Builder name(XdrString name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder cases(SCSpecUDTEnumCaseV0[] cases) {
+ this.cases = cases;
+ return this;
+ }
+
+ public SCSpecUDTEnumV0 build() {
+ SCSpecUDTEnumV0 val = new SCSpecUDTEnumV0();
+ val.setDoc(this.doc);
+ val.setLib(this.lib);
+ val.setName(this.name);
+ val.setCases(this.cases);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTErrorEnumCaseV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTErrorEnumCaseV0.java
new file mode 100644
index 000000000..1148aa476
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTErrorEnumCaseV0.java
@@ -0,0 +1,146 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecUDTErrorEnumCaseV0
+// {
+// string doc;
+// string name<60>;
+// uint32 value;
+// };
+
+// ===========================================================================
+public class SCSpecUDTErrorEnumCaseV0 implements XdrElement {
+ public SCSpecUDTErrorEnumCaseV0() {}
+
+ private XdrString doc;
+
+ public XdrString getDoc() {
+ return this.doc;
+ }
+
+ public void setDoc(XdrString value) {
+ this.doc = value;
+ }
+
+ private XdrString name;
+
+ public XdrString getName() {
+ return this.name;
+ }
+
+ public void setName(XdrString value) {
+ this.name = value;
+ }
+
+ private Uint32 value;
+
+ public Uint32 getValue() {
+ return this.value;
+ }
+
+ public void setValue(Uint32 value) {
+ this.value = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SCSpecUDTErrorEnumCaseV0 encodedSCSpecUDTErrorEnumCaseV0)
+ throws IOException {
+ encodedSCSpecUDTErrorEnumCaseV0.doc.encode(stream);
+ encodedSCSpecUDTErrorEnumCaseV0.name.encode(stream);
+ Uint32.encode(stream, encodedSCSpecUDTErrorEnumCaseV0.value);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecUDTErrorEnumCaseV0 decode(XdrDataInputStream stream) throws IOException {
+ SCSpecUDTErrorEnumCaseV0 decodedSCSpecUDTErrorEnumCaseV0 = new SCSpecUDTErrorEnumCaseV0();
+ decodedSCSpecUDTErrorEnumCaseV0.doc = XdrString.decode(stream, SC_SPEC_DOC_LIMIT);
+ decodedSCSpecUDTErrorEnumCaseV0.name = XdrString.decode(stream, 60);
+ decodedSCSpecUDTErrorEnumCaseV0.value = Uint32.decode(stream);
+ return decodedSCSpecUDTErrorEnumCaseV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.doc, this.name, this.value);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecUDTErrorEnumCaseV0)) {
+ return false;
+ }
+
+ SCSpecUDTErrorEnumCaseV0 other = (SCSpecUDTErrorEnumCaseV0) object;
+ return Objects.equals(this.doc, other.doc)
+ && Objects.equals(this.name, other.name)
+ && Objects.equals(this.value, other.value);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecUDTErrorEnumCaseV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecUDTErrorEnumCaseV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString doc;
+ private XdrString name;
+ private Uint32 value;
+
+ public Builder doc(XdrString doc) {
+ this.doc = doc;
+ return this;
+ }
+
+ public Builder name(XdrString name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder value(Uint32 value) {
+ this.value = value;
+ return this;
+ }
+
+ public SCSpecUDTErrorEnumCaseV0 build() {
+ SCSpecUDTErrorEnumCaseV0 val = new SCSpecUDTErrorEnumCaseV0();
+ val.setDoc(this.doc);
+ val.setName(this.name);
+ val.setValue(this.value);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTErrorEnumV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTErrorEnumV0.java
new file mode 100644
index 000000000..9e55c65fb
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTErrorEnumV0.java
@@ -0,0 +1,176 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecUDTErrorEnumV0
+// {
+// string doc;
+// string lib<80>;
+// string name<60>;
+// SCSpecUDTErrorEnumCaseV0 cases<50>;
+// };
+
+// ===========================================================================
+public class SCSpecUDTErrorEnumV0 implements XdrElement {
+ public SCSpecUDTErrorEnumV0() {}
+
+ private XdrString doc;
+
+ public XdrString getDoc() {
+ return this.doc;
+ }
+
+ public void setDoc(XdrString value) {
+ this.doc = value;
+ }
+
+ private XdrString lib;
+
+ public XdrString getLib() {
+ return this.lib;
+ }
+
+ public void setLib(XdrString value) {
+ this.lib = value;
+ }
+
+ private XdrString name;
+
+ public XdrString getName() {
+ return this.name;
+ }
+
+ public void setName(XdrString value) {
+ this.name = value;
+ }
+
+ private SCSpecUDTErrorEnumCaseV0[] cases;
+
+ public SCSpecUDTErrorEnumCaseV0[] getCases() {
+ return this.cases;
+ }
+
+ public void setCases(SCSpecUDTErrorEnumCaseV0[] value) {
+ this.cases = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SCSpecUDTErrorEnumV0 encodedSCSpecUDTErrorEnumV0)
+ throws IOException {
+ encodedSCSpecUDTErrorEnumV0.doc.encode(stream);
+ encodedSCSpecUDTErrorEnumV0.lib.encode(stream);
+ encodedSCSpecUDTErrorEnumV0.name.encode(stream);
+ int casessize = encodedSCSpecUDTErrorEnumV0.getCases().length;
+ stream.writeInt(casessize);
+ for (int i = 0; i < casessize; i++) {
+ SCSpecUDTErrorEnumCaseV0.encode(stream, encodedSCSpecUDTErrorEnumV0.cases[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecUDTErrorEnumV0 decode(XdrDataInputStream stream) throws IOException {
+ SCSpecUDTErrorEnumV0 decodedSCSpecUDTErrorEnumV0 = new SCSpecUDTErrorEnumV0();
+ decodedSCSpecUDTErrorEnumV0.doc = XdrString.decode(stream, SC_SPEC_DOC_LIMIT);
+ decodedSCSpecUDTErrorEnumV0.lib = XdrString.decode(stream, 80);
+ decodedSCSpecUDTErrorEnumV0.name = XdrString.decode(stream, 60);
+ int casessize = stream.readInt();
+ decodedSCSpecUDTErrorEnumV0.cases = new SCSpecUDTErrorEnumCaseV0[casessize];
+ for (int i = 0; i < casessize; i++) {
+ decodedSCSpecUDTErrorEnumV0.cases[i] = SCSpecUDTErrorEnumCaseV0.decode(stream);
+ }
+ return decodedSCSpecUDTErrorEnumV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.doc, this.lib, this.name, Arrays.hashCode(this.cases));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecUDTErrorEnumV0)) {
+ return false;
+ }
+
+ SCSpecUDTErrorEnumV0 other = (SCSpecUDTErrorEnumV0) object;
+ return Objects.equals(this.doc, other.doc)
+ && Objects.equals(this.lib, other.lib)
+ && Objects.equals(this.name, other.name)
+ && Arrays.equals(this.cases, other.cases);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecUDTErrorEnumV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecUDTErrorEnumV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString doc;
+ private XdrString lib;
+ private XdrString name;
+ private SCSpecUDTErrorEnumCaseV0[] cases;
+
+ public Builder doc(XdrString doc) {
+ this.doc = doc;
+ return this;
+ }
+
+ public Builder lib(XdrString lib) {
+ this.lib = lib;
+ return this;
+ }
+
+ public Builder name(XdrString name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder cases(SCSpecUDTErrorEnumCaseV0[] cases) {
+ this.cases = cases;
+ return this;
+ }
+
+ public SCSpecUDTErrorEnumV0 build() {
+ SCSpecUDTErrorEnumV0 val = new SCSpecUDTErrorEnumV0();
+ val.setDoc(this.doc);
+ val.setLib(this.lib);
+ val.setName(this.name);
+ val.setCases(this.cases);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTStructFieldV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTStructFieldV0.java
new file mode 100644
index 000000000..ccd0d1bae
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTStructFieldV0.java
@@ -0,0 +1,146 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecUDTStructFieldV0
+// {
+// string doc;
+// string name<30>;
+// SCSpecTypeDef type;
+// };
+
+// ===========================================================================
+public class SCSpecUDTStructFieldV0 implements XdrElement {
+ public SCSpecUDTStructFieldV0() {}
+
+ private XdrString doc;
+
+ public XdrString getDoc() {
+ return this.doc;
+ }
+
+ public void setDoc(XdrString value) {
+ this.doc = value;
+ }
+
+ private XdrString name;
+
+ public XdrString getName() {
+ return this.name;
+ }
+
+ public void setName(XdrString value) {
+ this.name = value;
+ }
+
+ private SCSpecTypeDef type;
+
+ public SCSpecTypeDef getType() {
+ return this.type;
+ }
+
+ public void setType(SCSpecTypeDef value) {
+ this.type = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SCSpecUDTStructFieldV0 encodedSCSpecUDTStructFieldV0)
+ throws IOException {
+ encodedSCSpecUDTStructFieldV0.doc.encode(stream);
+ encodedSCSpecUDTStructFieldV0.name.encode(stream);
+ SCSpecTypeDef.encode(stream, encodedSCSpecUDTStructFieldV0.type);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecUDTStructFieldV0 decode(XdrDataInputStream stream) throws IOException {
+ SCSpecUDTStructFieldV0 decodedSCSpecUDTStructFieldV0 = new SCSpecUDTStructFieldV0();
+ decodedSCSpecUDTStructFieldV0.doc = XdrString.decode(stream, SC_SPEC_DOC_LIMIT);
+ decodedSCSpecUDTStructFieldV0.name = XdrString.decode(stream, 30);
+ decodedSCSpecUDTStructFieldV0.type = SCSpecTypeDef.decode(stream);
+ return decodedSCSpecUDTStructFieldV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.doc, this.name, this.type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecUDTStructFieldV0)) {
+ return false;
+ }
+
+ SCSpecUDTStructFieldV0 other = (SCSpecUDTStructFieldV0) object;
+ return Objects.equals(this.doc, other.doc)
+ && Objects.equals(this.name, other.name)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecUDTStructFieldV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecUDTStructFieldV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString doc;
+ private XdrString name;
+ private SCSpecTypeDef type;
+
+ public Builder doc(XdrString doc) {
+ this.doc = doc;
+ return this;
+ }
+
+ public Builder name(XdrString name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder type(SCSpecTypeDef type) {
+ this.type = type;
+ return this;
+ }
+
+ public SCSpecUDTStructFieldV0 build() {
+ SCSpecUDTStructFieldV0 val = new SCSpecUDTStructFieldV0();
+ val.setDoc(this.doc);
+ val.setName(this.name);
+ val.setType(this.type);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTStructV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTStructV0.java
new file mode 100644
index 000000000..2fc3a43f3
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTStructV0.java
@@ -0,0 +1,175 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecUDTStructV0
+// {
+// string doc;
+// string lib<80>;
+// string name<60>;
+// SCSpecUDTStructFieldV0 fields<40>;
+// };
+
+// ===========================================================================
+public class SCSpecUDTStructV0 implements XdrElement {
+ public SCSpecUDTStructV0() {}
+
+ private XdrString doc;
+
+ public XdrString getDoc() {
+ return this.doc;
+ }
+
+ public void setDoc(XdrString value) {
+ this.doc = value;
+ }
+
+ private XdrString lib;
+
+ public XdrString getLib() {
+ return this.lib;
+ }
+
+ public void setLib(XdrString value) {
+ this.lib = value;
+ }
+
+ private XdrString name;
+
+ public XdrString getName() {
+ return this.name;
+ }
+
+ public void setName(XdrString value) {
+ this.name = value;
+ }
+
+ private SCSpecUDTStructFieldV0[] fields;
+
+ public SCSpecUDTStructFieldV0[] getFields() {
+ return this.fields;
+ }
+
+ public void setFields(SCSpecUDTStructFieldV0[] value) {
+ this.fields = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecUDTStructV0 encodedSCSpecUDTStructV0)
+ throws IOException {
+ encodedSCSpecUDTStructV0.doc.encode(stream);
+ encodedSCSpecUDTStructV0.lib.encode(stream);
+ encodedSCSpecUDTStructV0.name.encode(stream);
+ int fieldssize = encodedSCSpecUDTStructV0.getFields().length;
+ stream.writeInt(fieldssize);
+ for (int i = 0; i < fieldssize; i++) {
+ SCSpecUDTStructFieldV0.encode(stream, encodedSCSpecUDTStructV0.fields[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecUDTStructV0 decode(XdrDataInputStream stream) throws IOException {
+ SCSpecUDTStructV0 decodedSCSpecUDTStructV0 = new SCSpecUDTStructV0();
+ decodedSCSpecUDTStructV0.doc = XdrString.decode(stream, SC_SPEC_DOC_LIMIT);
+ decodedSCSpecUDTStructV0.lib = XdrString.decode(stream, 80);
+ decodedSCSpecUDTStructV0.name = XdrString.decode(stream, 60);
+ int fieldssize = stream.readInt();
+ decodedSCSpecUDTStructV0.fields = new SCSpecUDTStructFieldV0[fieldssize];
+ for (int i = 0; i < fieldssize; i++) {
+ decodedSCSpecUDTStructV0.fields[i] = SCSpecUDTStructFieldV0.decode(stream);
+ }
+ return decodedSCSpecUDTStructV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.doc, this.lib, this.name, Arrays.hashCode(this.fields));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecUDTStructV0)) {
+ return false;
+ }
+
+ SCSpecUDTStructV0 other = (SCSpecUDTStructV0) object;
+ return Objects.equals(this.doc, other.doc)
+ && Objects.equals(this.lib, other.lib)
+ && Objects.equals(this.name, other.name)
+ && Arrays.equals(this.fields, other.fields);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecUDTStructV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecUDTStructV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString doc;
+ private XdrString lib;
+ private XdrString name;
+ private SCSpecUDTStructFieldV0[] fields;
+
+ public Builder doc(XdrString doc) {
+ this.doc = doc;
+ return this;
+ }
+
+ public Builder lib(XdrString lib) {
+ this.lib = lib;
+ return this;
+ }
+
+ public Builder name(XdrString name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder fields(SCSpecUDTStructFieldV0[] fields) {
+ this.fields = fields;
+ return this;
+ }
+
+ public SCSpecUDTStructV0 build() {
+ SCSpecUDTStructV0 val = new SCSpecUDTStructV0();
+ val.setDoc(this.doc);
+ val.setLib(this.lib);
+ val.setName(this.name);
+ val.setFields(this.fields);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionCaseTupleV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionCaseTupleV0.java
new file mode 100644
index 000000000..60c0a065a
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionCaseTupleV0.java
@@ -0,0 +1,155 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecUDTUnionCaseTupleV0
+// {
+// string doc;
+// string name<60>;
+// SCSpecTypeDef type<12>;
+// };
+
+// ===========================================================================
+public class SCSpecUDTUnionCaseTupleV0 implements XdrElement {
+ public SCSpecUDTUnionCaseTupleV0() {}
+
+ private XdrString doc;
+
+ public XdrString getDoc() {
+ return this.doc;
+ }
+
+ public void setDoc(XdrString value) {
+ this.doc = value;
+ }
+
+ private XdrString name;
+
+ public XdrString getName() {
+ return this.name;
+ }
+
+ public void setName(XdrString value) {
+ this.name = value;
+ }
+
+ private SCSpecTypeDef[] type;
+
+ public SCSpecTypeDef[] getType() {
+ return this.type;
+ }
+
+ public void setType(SCSpecTypeDef[] value) {
+ this.type = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SCSpecUDTUnionCaseTupleV0 encodedSCSpecUDTUnionCaseTupleV0)
+ throws IOException {
+ encodedSCSpecUDTUnionCaseTupleV0.doc.encode(stream);
+ encodedSCSpecUDTUnionCaseTupleV0.name.encode(stream);
+ int typesize = encodedSCSpecUDTUnionCaseTupleV0.getType().length;
+ stream.writeInt(typesize);
+ for (int i = 0; i < typesize; i++) {
+ SCSpecTypeDef.encode(stream, encodedSCSpecUDTUnionCaseTupleV0.type[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecUDTUnionCaseTupleV0 decode(XdrDataInputStream stream) throws IOException {
+ SCSpecUDTUnionCaseTupleV0 decodedSCSpecUDTUnionCaseTupleV0 = new SCSpecUDTUnionCaseTupleV0();
+ decodedSCSpecUDTUnionCaseTupleV0.doc = XdrString.decode(stream, SC_SPEC_DOC_LIMIT);
+ decodedSCSpecUDTUnionCaseTupleV0.name = XdrString.decode(stream, 60);
+ int typesize = stream.readInt();
+ decodedSCSpecUDTUnionCaseTupleV0.type = new SCSpecTypeDef[typesize];
+ for (int i = 0; i < typesize; i++) {
+ decodedSCSpecUDTUnionCaseTupleV0.type[i] = SCSpecTypeDef.decode(stream);
+ }
+ return decodedSCSpecUDTUnionCaseTupleV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.doc, this.name, Arrays.hashCode(this.type));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecUDTUnionCaseTupleV0)) {
+ return false;
+ }
+
+ SCSpecUDTUnionCaseTupleV0 other = (SCSpecUDTUnionCaseTupleV0) object;
+ return Objects.equals(this.doc, other.doc)
+ && Objects.equals(this.name, other.name)
+ && Arrays.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecUDTUnionCaseTupleV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecUDTUnionCaseTupleV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString doc;
+ private XdrString name;
+ private SCSpecTypeDef[] type;
+
+ public Builder doc(XdrString doc) {
+ this.doc = doc;
+ return this;
+ }
+
+ public Builder name(XdrString name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder type(SCSpecTypeDef[] type) {
+ this.type = type;
+ return this;
+ }
+
+ public SCSpecUDTUnionCaseTupleV0 build() {
+ SCSpecUDTUnionCaseTupleV0 val = new SCSpecUDTUnionCaseTupleV0();
+ val.setDoc(this.doc);
+ val.setName(this.name);
+ val.setType(this.type);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionCaseV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionCaseV0.java
new file mode 100644
index 000000000..dde5eac73
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionCaseV0.java
@@ -0,0 +1,162 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union SCSpecUDTUnionCaseV0 switch (SCSpecUDTUnionCaseV0Kind kind)
+// {
+// case SC_SPEC_UDT_UNION_CASE_VOID_V0:
+// SCSpecUDTUnionCaseVoidV0 voidCase;
+// case SC_SPEC_UDT_UNION_CASE_TUPLE_V0:
+// SCSpecUDTUnionCaseTupleV0 tupleCase;
+// };
+
+// ===========================================================================
+public class SCSpecUDTUnionCaseV0 implements XdrElement {
+ public SCSpecUDTUnionCaseV0() {}
+
+ SCSpecUDTUnionCaseV0Kind kind;
+
+ public SCSpecUDTUnionCaseV0Kind getDiscriminant() {
+ return this.kind;
+ }
+
+ public void setDiscriminant(SCSpecUDTUnionCaseV0Kind value) {
+ this.kind = value;
+ }
+
+ private SCSpecUDTUnionCaseVoidV0 voidCase;
+
+ public SCSpecUDTUnionCaseVoidV0 getVoidCase() {
+ return this.voidCase;
+ }
+
+ public void setVoidCase(SCSpecUDTUnionCaseVoidV0 value) {
+ this.voidCase = value;
+ }
+
+ private SCSpecUDTUnionCaseTupleV0 tupleCase;
+
+ public SCSpecUDTUnionCaseTupleV0 getTupleCase() {
+ return this.tupleCase;
+ }
+
+ public void setTupleCase(SCSpecUDTUnionCaseTupleV0 value) {
+ this.tupleCase = value;
+ }
+
+ public static final class Builder {
+ private SCSpecUDTUnionCaseV0Kind discriminant;
+ private SCSpecUDTUnionCaseVoidV0 voidCase;
+ private SCSpecUDTUnionCaseTupleV0 tupleCase;
+
+ public Builder discriminant(SCSpecUDTUnionCaseV0Kind discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder voidCase(SCSpecUDTUnionCaseVoidV0 voidCase) {
+ this.voidCase = voidCase;
+ return this;
+ }
+
+ public Builder tupleCase(SCSpecUDTUnionCaseTupleV0 tupleCase) {
+ this.tupleCase = tupleCase;
+ return this;
+ }
+
+ public SCSpecUDTUnionCaseV0 build() {
+ SCSpecUDTUnionCaseV0 val = new SCSpecUDTUnionCaseV0();
+ val.setDiscriminant(discriminant);
+ val.setVoidCase(this.voidCase);
+ val.setTupleCase(this.tupleCase);
+ return val;
+ }
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SCSpecUDTUnionCaseV0 encodedSCSpecUDTUnionCaseV0)
+ throws IOException {
+ // Xdrgen::AST::Identifier
+ // SCSpecUDTUnionCaseV0Kind
+ stream.writeInt(encodedSCSpecUDTUnionCaseV0.getDiscriminant().getValue());
+ switch (encodedSCSpecUDTUnionCaseV0.getDiscriminant()) {
+ case SC_SPEC_UDT_UNION_CASE_VOID_V0:
+ SCSpecUDTUnionCaseVoidV0.encode(stream, encodedSCSpecUDTUnionCaseV0.voidCase);
+ break;
+ case SC_SPEC_UDT_UNION_CASE_TUPLE_V0:
+ SCSpecUDTUnionCaseTupleV0.encode(stream, encodedSCSpecUDTUnionCaseV0.tupleCase);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecUDTUnionCaseV0 decode(XdrDataInputStream stream) throws IOException {
+ SCSpecUDTUnionCaseV0 decodedSCSpecUDTUnionCaseV0 = new SCSpecUDTUnionCaseV0();
+ SCSpecUDTUnionCaseV0Kind discriminant = SCSpecUDTUnionCaseV0Kind.decode(stream);
+ decodedSCSpecUDTUnionCaseV0.setDiscriminant(discriminant);
+ switch (decodedSCSpecUDTUnionCaseV0.getDiscriminant()) {
+ case SC_SPEC_UDT_UNION_CASE_VOID_V0:
+ decodedSCSpecUDTUnionCaseV0.voidCase = SCSpecUDTUnionCaseVoidV0.decode(stream);
+ break;
+ case SC_SPEC_UDT_UNION_CASE_TUPLE_V0:
+ decodedSCSpecUDTUnionCaseV0.tupleCase = SCSpecUDTUnionCaseTupleV0.decode(stream);
+ break;
+ }
+ return decodedSCSpecUDTUnionCaseV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.voidCase, this.tupleCase, this.kind);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecUDTUnionCaseV0)) {
+ return false;
+ }
+
+ SCSpecUDTUnionCaseV0 other = (SCSpecUDTUnionCaseV0) object;
+ return Objects.equals(this.voidCase, other.voidCase)
+ && Objects.equals(this.tupleCase, other.tupleCase)
+ && Objects.equals(this.kind, other.kind);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecUDTUnionCaseV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecUDTUnionCaseV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionCaseV0Kind.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionCaseV0Kind.java
new file mode 100644
index 000000000..a3f701587
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionCaseV0Kind.java
@@ -0,0 +1,80 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum SCSpecUDTUnionCaseV0Kind
+// {
+// SC_SPEC_UDT_UNION_CASE_VOID_V0 = 0,
+// SC_SPEC_UDT_UNION_CASE_TUPLE_V0 = 1
+// };
+
+// ===========================================================================
+public enum SCSpecUDTUnionCaseV0Kind implements XdrElement {
+ SC_SPEC_UDT_UNION_CASE_VOID_V0(0),
+ SC_SPEC_UDT_UNION_CASE_TUPLE_V0(1),
+ ;
+ private int mValue;
+
+ SCSpecUDTUnionCaseV0Kind(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SCSpecUDTUnionCaseV0Kind decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SC_SPEC_UDT_UNION_CASE_VOID_V0;
+ case 1:
+ return SC_SPEC_UDT_UNION_CASE_TUPLE_V0;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecUDTUnionCaseV0Kind value)
+ throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecUDTUnionCaseV0Kind fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecUDTUnionCaseV0Kind fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionCaseVoidV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionCaseVoidV0.java
new file mode 100644
index 000000000..21f3e12cf
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionCaseVoidV0.java
@@ -0,0 +1,124 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecUDTUnionCaseVoidV0
+// {
+// string doc;
+// string name<60>;
+// };
+
+// ===========================================================================
+public class SCSpecUDTUnionCaseVoidV0 implements XdrElement {
+ public SCSpecUDTUnionCaseVoidV0() {}
+
+ private XdrString doc;
+
+ public XdrString getDoc() {
+ return this.doc;
+ }
+
+ public void setDoc(XdrString value) {
+ this.doc = value;
+ }
+
+ private XdrString name;
+
+ public XdrString getName() {
+ return this.name;
+ }
+
+ public void setName(XdrString value) {
+ this.name = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SCSpecUDTUnionCaseVoidV0 encodedSCSpecUDTUnionCaseVoidV0)
+ throws IOException {
+ encodedSCSpecUDTUnionCaseVoidV0.doc.encode(stream);
+ encodedSCSpecUDTUnionCaseVoidV0.name.encode(stream);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecUDTUnionCaseVoidV0 decode(XdrDataInputStream stream) throws IOException {
+ SCSpecUDTUnionCaseVoidV0 decodedSCSpecUDTUnionCaseVoidV0 = new SCSpecUDTUnionCaseVoidV0();
+ decodedSCSpecUDTUnionCaseVoidV0.doc = XdrString.decode(stream, SC_SPEC_DOC_LIMIT);
+ decodedSCSpecUDTUnionCaseVoidV0.name = XdrString.decode(stream, 60);
+ return decodedSCSpecUDTUnionCaseVoidV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.doc, this.name);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecUDTUnionCaseVoidV0)) {
+ return false;
+ }
+
+ SCSpecUDTUnionCaseVoidV0 other = (SCSpecUDTUnionCaseVoidV0) object;
+ return Objects.equals(this.doc, other.doc) && Objects.equals(this.name, other.name);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecUDTUnionCaseVoidV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecUDTUnionCaseVoidV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString doc;
+ private XdrString name;
+
+ public Builder doc(XdrString doc) {
+ this.doc = doc;
+ return this;
+ }
+
+ public Builder name(XdrString name) {
+ this.name = name;
+ return this;
+ }
+
+ public SCSpecUDTUnionCaseVoidV0 build() {
+ SCSpecUDTUnionCaseVoidV0 val = new SCSpecUDTUnionCaseVoidV0();
+ val.setDoc(this.doc);
+ val.setName(this.name);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionV0.java b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionV0.java
new file mode 100644
index 000000000..6ef52f7bd
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSpecUDTUnionV0.java
@@ -0,0 +1,175 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SCSpecUDTUnionV0
+// {
+// string doc;
+// string lib<80>;
+// string name<60>;
+// SCSpecUDTUnionCaseV0 cases<50>;
+// };
+
+// ===========================================================================
+public class SCSpecUDTUnionV0 implements XdrElement {
+ public SCSpecUDTUnionV0() {}
+
+ private XdrString doc;
+
+ public XdrString getDoc() {
+ return this.doc;
+ }
+
+ public void setDoc(XdrString value) {
+ this.doc = value;
+ }
+
+ private XdrString lib;
+
+ public XdrString getLib() {
+ return this.lib;
+ }
+
+ public void setLib(XdrString value) {
+ this.lib = value;
+ }
+
+ private XdrString name;
+
+ public XdrString getName() {
+ return this.name;
+ }
+
+ public void setName(XdrString value) {
+ this.name = value;
+ }
+
+ private SCSpecUDTUnionCaseV0[] cases;
+
+ public SCSpecUDTUnionCaseV0[] getCases() {
+ return this.cases;
+ }
+
+ public void setCases(SCSpecUDTUnionCaseV0[] value) {
+ this.cases = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSpecUDTUnionV0 encodedSCSpecUDTUnionV0)
+ throws IOException {
+ encodedSCSpecUDTUnionV0.doc.encode(stream);
+ encodedSCSpecUDTUnionV0.lib.encode(stream);
+ encodedSCSpecUDTUnionV0.name.encode(stream);
+ int casessize = encodedSCSpecUDTUnionV0.getCases().length;
+ stream.writeInt(casessize);
+ for (int i = 0; i < casessize; i++) {
+ SCSpecUDTUnionCaseV0.encode(stream, encodedSCSpecUDTUnionV0.cases[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSpecUDTUnionV0 decode(XdrDataInputStream stream) throws IOException {
+ SCSpecUDTUnionV0 decodedSCSpecUDTUnionV0 = new SCSpecUDTUnionV0();
+ decodedSCSpecUDTUnionV0.doc = XdrString.decode(stream, SC_SPEC_DOC_LIMIT);
+ decodedSCSpecUDTUnionV0.lib = XdrString.decode(stream, 80);
+ decodedSCSpecUDTUnionV0.name = XdrString.decode(stream, 60);
+ int casessize = stream.readInt();
+ decodedSCSpecUDTUnionV0.cases = new SCSpecUDTUnionCaseV0[casessize];
+ for (int i = 0; i < casessize; i++) {
+ decodedSCSpecUDTUnionV0.cases[i] = SCSpecUDTUnionCaseV0.decode(stream);
+ }
+ return decodedSCSpecUDTUnionV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.doc, this.lib, this.name, Arrays.hashCode(this.cases));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSpecUDTUnionV0)) {
+ return false;
+ }
+
+ SCSpecUDTUnionV0 other = (SCSpecUDTUnionV0) object;
+ return Objects.equals(this.doc, other.doc)
+ && Objects.equals(this.lib, other.lib)
+ && Objects.equals(this.name, other.name)
+ && Arrays.equals(this.cases, other.cases);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSpecUDTUnionV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSpecUDTUnionV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private XdrString doc;
+ private XdrString lib;
+ private XdrString name;
+ private SCSpecUDTUnionCaseV0[] cases;
+
+ public Builder doc(XdrString doc) {
+ this.doc = doc;
+ return this;
+ }
+
+ public Builder lib(XdrString lib) {
+ this.lib = lib;
+ return this;
+ }
+
+ public Builder name(XdrString name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder cases(SCSpecUDTUnionCaseV0[] cases) {
+ this.cases = cases;
+ return this;
+ }
+
+ public SCSpecUDTUnionV0 build() {
+ SCSpecUDTUnionV0 val = new SCSpecUDTUnionV0();
+ val.setDoc(this.doc);
+ val.setLib(this.lib);
+ val.setName(this.name);
+ val.setCases(this.cases);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCString.java b/src/main/java/org/stellar/sdk/xdr/SCString.java
new file mode 100644
index 000000000..5e3690af7
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCString.java
@@ -0,0 +1,89 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// typedef string SCString<>;
+
+// ===========================================================================
+public class SCString implements XdrElement {
+ private XdrString SCString;
+
+ public SCString() {}
+
+ public SCString(XdrString SCString) {
+ this.SCString = SCString;
+ }
+
+ public XdrString getSCString() {
+ return this.SCString;
+ }
+
+ public void setSCString(XdrString value) {
+ this.SCString = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCString encodedSCString)
+ throws IOException {
+ encodedSCString.SCString.encode(stream);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCString decode(XdrDataInputStream stream) throws IOException {
+ SCString decodedSCString = new SCString();
+ decodedSCString.SCString = XdrString.decode(stream, Integer.MAX_VALUE);
+ return decodedSCString;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.SCString);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCString)) {
+ return false;
+ }
+
+ SCString other = (SCString) object;
+ return Objects.equals(this.SCString, other.SCString);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCString fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCString fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCSymbol.java b/src/main/java/org/stellar/sdk/xdr/SCSymbol.java
new file mode 100644
index 000000000..63d2867d3
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCSymbol.java
@@ -0,0 +1,89 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// typedef string SCSymbol;
+
+// ===========================================================================
+public class SCSymbol implements XdrElement {
+ private XdrString SCSymbol;
+
+ public SCSymbol() {}
+
+ public SCSymbol(XdrString SCSymbol) {
+ this.SCSymbol = SCSymbol;
+ }
+
+ public XdrString getSCSymbol() {
+ return this.SCSymbol;
+ }
+
+ public void setSCSymbol(XdrString value) {
+ this.SCSymbol = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCSymbol encodedSCSymbol)
+ throws IOException {
+ encodedSCSymbol.SCSymbol.encode(stream);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCSymbol decode(XdrDataInputStream stream) throws IOException {
+ SCSymbol decodedSCSymbol = new SCSymbol();
+ decodedSCSymbol.SCSymbol = XdrString.decode(stream, SCSYMBOL_LIMIT);
+ return decodedSCSymbol;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.SCSymbol);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCSymbol)) {
+ return false;
+ }
+
+ SCSymbol other = (SCSymbol) object;
+ return Objects.equals(this.SCSymbol, other.SCSymbol);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCSymbol fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCSymbol fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCVal.java b/src/main/java/org/stellar/sdk/xdr/SCVal.java
new file mode 100644
index 000000000..18ac123c4
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCVal.java
@@ -0,0 +1,691 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union SCVal switch (SCValType type)
+// {
+//
+// case SCV_BOOL:
+// bool b;
+// case SCV_VOID:
+// void;
+// case SCV_ERROR:
+// SCError error;
+//
+// case SCV_U32:
+// uint32 u32;
+// case SCV_I32:
+// int32 i32;
+//
+// case SCV_U64:
+// uint64 u64;
+// case SCV_I64:
+// int64 i64;
+// case SCV_TIMEPOINT:
+// TimePoint timepoint;
+// case SCV_DURATION:
+// Duration duration;
+//
+// case SCV_U128:
+// UInt128Parts u128;
+// case SCV_I128:
+// Int128Parts i128;
+//
+// case SCV_U256:
+// UInt256Parts u256;
+// case SCV_I256:
+// Int256Parts i256;
+//
+// case SCV_BYTES:
+// SCBytes bytes;
+// case SCV_STRING:
+// SCString str;
+// case SCV_SYMBOL:
+// SCSymbol sym;
+//
+// // Vec and Map are recursive so need to live
+// // behind an option, due to xdrpp limitations.
+// case SCV_VEC:
+// SCVec *vec;
+// case SCV_MAP:
+// SCMap *map;
+//
+// case SCV_ADDRESS:
+// SCAddress address;
+//
+// // Special SCVals reserved for system-constructed contract-data
+// // ledger keys, not generally usable elsewhere.
+// case SCV_LEDGER_KEY_CONTRACT_INSTANCE:
+// void;
+// case SCV_LEDGER_KEY_NONCE:
+// SCNonceKey nonce_key;
+//
+// case SCV_CONTRACT_INSTANCE:
+// SCContractInstance instance;
+// };
+
+// ===========================================================================
+public class SCVal implements XdrElement {
+ public SCVal() {}
+
+ SCValType type;
+
+ public SCValType getDiscriminant() {
+ return this.type;
+ }
+
+ public void setDiscriminant(SCValType value) {
+ this.type = value;
+ }
+
+ private Boolean b;
+
+ public Boolean getB() {
+ return this.b;
+ }
+
+ public void setB(Boolean value) {
+ this.b = value;
+ }
+
+ private SCError error;
+
+ public SCError getError() {
+ return this.error;
+ }
+
+ public void setError(SCError value) {
+ this.error = value;
+ }
+
+ private Uint32 u32;
+
+ public Uint32 getU32() {
+ return this.u32;
+ }
+
+ public void setU32(Uint32 value) {
+ this.u32 = value;
+ }
+
+ private Int32 i32;
+
+ public Int32 getI32() {
+ return this.i32;
+ }
+
+ public void setI32(Int32 value) {
+ this.i32 = value;
+ }
+
+ private Uint64 u64;
+
+ public Uint64 getU64() {
+ return this.u64;
+ }
+
+ public void setU64(Uint64 value) {
+ this.u64 = value;
+ }
+
+ private Int64 i64;
+
+ public Int64 getI64() {
+ return this.i64;
+ }
+
+ public void setI64(Int64 value) {
+ this.i64 = value;
+ }
+
+ private TimePoint timepoint;
+
+ public TimePoint getTimepoint() {
+ return this.timepoint;
+ }
+
+ public void setTimepoint(TimePoint value) {
+ this.timepoint = value;
+ }
+
+ private Duration duration;
+
+ public Duration getDuration() {
+ return this.duration;
+ }
+
+ public void setDuration(Duration value) {
+ this.duration = value;
+ }
+
+ private UInt128Parts u128;
+
+ public UInt128Parts getU128() {
+ return this.u128;
+ }
+
+ public void setU128(UInt128Parts value) {
+ this.u128 = value;
+ }
+
+ private Int128Parts i128;
+
+ public Int128Parts getI128() {
+ return this.i128;
+ }
+
+ public void setI128(Int128Parts value) {
+ this.i128 = value;
+ }
+
+ private UInt256Parts u256;
+
+ public UInt256Parts getU256() {
+ return this.u256;
+ }
+
+ public void setU256(UInt256Parts value) {
+ this.u256 = value;
+ }
+
+ private Int256Parts i256;
+
+ public Int256Parts getI256() {
+ return this.i256;
+ }
+
+ public void setI256(Int256Parts value) {
+ this.i256 = value;
+ }
+
+ private SCBytes bytes;
+
+ public SCBytes getBytes() {
+ return this.bytes;
+ }
+
+ public void setBytes(SCBytes value) {
+ this.bytes = value;
+ }
+
+ private SCString str;
+
+ public SCString getStr() {
+ return this.str;
+ }
+
+ public void setStr(SCString value) {
+ this.str = value;
+ }
+
+ private SCSymbol sym;
+
+ public SCSymbol getSym() {
+ return this.sym;
+ }
+
+ public void setSym(SCSymbol value) {
+ this.sym = value;
+ }
+
+ private SCVec vec;
+
+ public SCVec getVec() {
+ return this.vec;
+ }
+
+ public void setVec(SCVec value) {
+ this.vec = value;
+ }
+
+ private SCMap map;
+
+ public SCMap getMap() {
+ return this.map;
+ }
+
+ public void setMap(SCMap value) {
+ this.map = value;
+ }
+
+ private SCAddress address;
+
+ public SCAddress getAddress() {
+ return this.address;
+ }
+
+ public void setAddress(SCAddress value) {
+ this.address = value;
+ }
+
+ private SCNonceKey nonce_key;
+
+ public SCNonceKey getNonce_key() {
+ return this.nonce_key;
+ }
+
+ public void setNonce_key(SCNonceKey value) {
+ this.nonce_key = value;
+ }
+
+ private SCContractInstance instance;
+
+ public SCContractInstance getInstance() {
+ return this.instance;
+ }
+
+ public void setInstance(SCContractInstance value) {
+ this.instance = value;
+ }
+
+ public static final class Builder {
+ private SCValType discriminant;
+ private Boolean b;
+ private SCError error;
+ private Uint32 u32;
+ private Int32 i32;
+ private Uint64 u64;
+ private Int64 i64;
+ private TimePoint timepoint;
+ private Duration duration;
+ private UInt128Parts u128;
+ private Int128Parts i128;
+ private UInt256Parts u256;
+ private Int256Parts i256;
+ private SCBytes bytes;
+ private SCString str;
+ private SCSymbol sym;
+ private SCVec vec;
+ private SCMap map;
+ private SCAddress address;
+ private SCNonceKey nonce_key;
+ private SCContractInstance instance;
+
+ public Builder discriminant(SCValType discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder b(Boolean b) {
+ this.b = b;
+ return this;
+ }
+
+ public Builder error(SCError error) {
+ this.error = error;
+ return this;
+ }
+
+ public Builder u32(Uint32 u32) {
+ this.u32 = u32;
+ return this;
+ }
+
+ public Builder i32(Int32 i32) {
+ this.i32 = i32;
+ return this;
+ }
+
+ public Builder u64(Uint64 u64) {
+ this.u64 = u64;
+ return this;
+ }
+
+ public Builder i64(Int64 i64) {
+ this.i64 = i64;
+ return this;
+ }
+
+ public Builder timepoint(TimePoint timepoint) {
+ this.timepoint = timepoint;
+ return this;
+ }
+
+ public Builder duration(Duration duration) {
+ this.duration = duration;
+ return this;
+ }
+
+ public Builder u128(UInt128Parts u128) {
+ this.u128 = u128;
+ return this;
+ }
+
+ public Builder i128(Int128Parts i128) {
+ this.i128 = i128;
+ return this;
+ }
+
+ public Builder u256(UInt256Parts u256) {
+ this.u256 = u256;
+ return this;
+ }
+
+ public Builder i256(Int256Parts i256) {
+ this.i256 = i256;
+ return this;
+ }
+
+ public Builder bytes(SCBytes bytes) {
+ this.bytes = bytes;
+ return this;
+ }
+
+ public Builder str(SCString str) {
+ this.str = str;
+ return this;
+ }
+
+ public Builder sym(SCSymbol sym) {
+ this.sym = sym;
+ return this;
+ }
+
+ public Builder vec(SCVec vec) {
+ this.vec = vec;
+ return this;
+ }
+
+ public Builder map(SCMap map) {
+ this.map = map;
+ return this;
+ }
+
+ public Builder address(SCAddress address) {
+ this.address = address;
+ return this;
+ }
+
+ public Builder nonce_key(SCNonceKey nonce_key) {
+ this.nonce_key = nonce_key;
+ return this;
+ }
+
+ public Builder instance(SCContractInstance instance) {
+ this.instance = instance;
+ return this;
+ }
+
+ public SCVal build() {
+ SCVal val = new SCVal();
+ val.setDiscriminant(discriminant);
+ val.setB(this.b);
+ val.setError(this.error);
+ val.setU32(this.u32);
+ val.setI32(this.i32);
+ val.setU64(this.u64);
+ val.setI64(this.i64);
+ val.setTimepoint(this.timepoint);
+ val.setDuration(this.duration);
+ val.setU128(this.u128);
+ val.setI128(this.i128);
+ val.setU256(this.u256);
+ val.setI256(this.i256);
+ val.setBytes(this.bytes);
+ val.setStr(this.str);
+ val.setSym(this.sym);
+ val.setVec(this.vec);
+ val.setMap(this.map);
+ val.setAddress(this.address);
+ val.setNonce_key(this.nonce_key);
+ val.setInstance(this.instance);
+ return val;
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCVal encodedSCVal) throws IOException {
+ // Xdrgen::AST::Identifier
+ // SCValType
+ stream.writeInt(encodedSCVal.getDiscriminant().getValue());
+ switch (encodedSCVal.getDiscriminant()) {
+ case SCV_BOOL:
+ stream.writeInt(encodedSCVal.b ? 1 : 0);
+ break;
+ case SCV_VOID:
+ break;
+ case SCV_ERROR:
+ SCError.encode(stream, encodedSCVal.error);
+ break;
+ case SCV_U32:
+ Uint32.encode(stream, encodedSCVal.u32);
+ break;
+ case SCV_I32:
+ Int32.encode(stream, encodedSCVal.i32);
+ break;
+ case SCV_U64:
+ Uint64.encode(stream, encodedSCVal.u64);
+ break;
+ case SCV_I64:
+ Int64.encode(stream, encodedSCVal.i64);
+ break;
+ case SCV_TIMEPOINT:
+ TimePoint.encode(stream, encodedSCVal.timepoint);
+ break;
+ case SCV_DURATION:
+ Duration.encode(stream, encodedSCVal.duration);
+ break;
+ case SCV_U128:
+ UInt128Parts.encode(stream, encodedSCVal.u128);
+ break;
+ case SCV_I128:
+ Int128Parts.encode(stream, encodedSCVal.i128);
+ break;
+ case SCV_U256:
+ UInt256Parts.encode(stream, encodedSCVal.u256);
+ break;
+ case SCV_I256:
+ Int256Parts.encode(stream, encodedSCVal.i256);
+ break;
+ case SCV_BYTES:
+ SCBytes.encode(stream, encodedSCVal.bytes);
+ break;
+ case SCV_STRING:
+ SCString.encode(stream, encodedSCVal.str);
+ break;
+ case SCV_SYMBOL:
+ SCSymbol.encode(stream, encodedSCVal.sym);
+ break;
+ case SCV_VEC:
+ if (encodedSCVal.vec != null) {
+ stream.writeInt(1);
+ SCVec.encode(stream, encodedSCVal.vec);
+ } else {
+ stream.writeInt(0);
+ }
+ break;
+ case SCV_MAP:
+ if (encodedSCVal.map != null) {
+ stream.writeInt(1);
+ SCMap.encode(stream, encodedSCVal.map);
+ } else {
+ stream.writeInt(0);
+ }
+ break;
+ case SCV_ADDRESS:
+ SCAddress.encode(stream, encodedSCVal.address);
+ break;
+ case SCV_LEDGER_KEY_CONTRACT_INSTANCE:
+ break;
+ case SCV_LEDGER_KEY_NONCE:
+ SCNonceKey.encode(stream, encodedSCVal.nonce_key);
+ break;
+ case SCV_CONTRACT_INSTANCE:
+ SCContractInstance.encode(stream, encodedSCVal.instance);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCVal decode(XdrDataInputStream stream) throws IOException {
+ SCVal decodedSCVal = new SCVal();
+ SCValType discriminant = SCValType.decode(stream);
+ decodedSCVal.setDiscriminant(discriminant);
+ switch (decodedSCVal.getDiscriminant()) {
+ case SCV_BOOL:
+ decodedSCVal.b = stream.readInt() == 1 ? true : false;
+ break;
+ case SCV_VOID:
+ break;
+ case SCV_ERROR:
+ decodedSCVal.error = SCError.decode(stream);
+ break;
+ case SCV_U32:
+ decodedSCVal.u32 = Uint32.decode(stream);
+ break;
+ case SCV_I32:
+ decodedSCVal.i32 = Int32.decode(stream);
+ break;
+ case SCV_U64:
+ decodedSCVal.u64 = Uint64.decode(stream);
+ break;
+ case SCV_I64:
+ decodedSCVal.i64 = Int64.decode(stream);
+ break;
+ case SCV_TIMEPOINT:
+ decodedSCVal.timepoint = TimePoint.decode(stream);
+ break;
+ case SCV_DURATION:
+ decodedSCVal.duration = Duration.decode(stream);
+ break;
+ case SCV_U128:
+ decodedSCVal.u128 = UInt128Parts.decode(stream);
+ break;
+ case SCV_I128:
+ decodedSCVal.i128 = Int128Parts.decode(stream);
+ break;
+ case SCV_U256:
+ decodedSCVal.u256 = UInt256Parts.decode(stream);
+ break;
+ case SCV_I256:
+ decodedSCVal.i256 = Int256Parts.decode(stream);
+ break;
+ case SCV_BYTES:
+ decodedSCVal.bytes = SCBytes.decode(stream);
+ break;
+ case SCV_STRING:
+ decodedSCVal.str = SCString.decode(stream);
+ break;
+ case SCV_SYMBOL:
+ decodedSCVal.sym = SCSymbol.decode(stream);
+ break;
+ case SCV_VEC:
+ int vecPresent = stream.readInt();
+ if (vecPresent != 0) {
+ decodedSCVal.vec = SCVec.decode(stream);
+ }
+ break;
+ case SCV_MAP:
+ int mapPresent = stream.readInt();
+ if (mapPresent != 0) {
+ decodedSCVal.map = SCMap.decode(stream);
+ }
+ break;
+ case SCV_ADDRESS:
+ decodedSCVal.address = SCAddress.decode(stream);
+ break;
+ case SCV_LEDGER_KEY_CONTRACT_INSTANCE:
+ break;
+ case SCV_LEDGER_KEY_NONCE:
+ decodedSCVal.nonce_key = SCNonceKey.decode(stream);
+ break;
+ case SCV_CONTRACT_INSTANCE:
+ decodedSCVal.instance = SCContractInstance.decode(stream);
+ break;
+ }
+ return decodedSCVal;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.b,
+ this.error,
+ this.u32,
+ this.i32,
+ this.u64,
+ this.i64,
+ this.timepoint,
+ this.duration,
+ this.u128,
+ this.i128,
+ this.u256,
+ this.i256,
+ this.bytes,
+ this.str,
+ this.sym,
+ this.vec,
+ this.map,
+ this.address,
+ this.nonce_key,
+ this.instance,
+ this.type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCVal)) {
+ return false;
+ }
+
+ SCVal other = (SCVal) object;
+ return Objects.equals(this.b, other.b)
+ && Objects.equals(this.error, other.error)
+ && Objects.equals(this.u32, other.u32)
+ && Objects.equals(this.i32, other.i32)
+ && Objects.equals(this.u64, other.u64)
+ && Objects.equals(this.i64, other.i64)
+ && Objects.equals(this.timepoint, other.timepoint)
+ && Objects.equals(this.duration, other.duration)
+ && Objects.equals(this.u128, other.u128)
+ && Objects.equals(this.i128, other.i128)
+ && Objects.equals(this.u256, other.u256)
+ && Objects.equals(this.i256, other.i256)
+ && Objects.equals(this.bytes, other.bytes)
+ && Objects.equals(this.str, other.str)
+ && Objects.equals(this.sym, other.sym)
+ && Objects.equals(this.vec, other.vec)
+ && Objects.equals(this.map, other.map)
+ && Objects.equals(this.address, other.address)
+ && Objects.equals(this.nonce_key, other.nonce_key)
+ && Objects.equals(this.instance, other.instance)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCVal fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCVal fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCValType.java b/src/main/java/org/stellar/sdk/xdr/SCValType.java
new file mode 100644
index 000000000..8a186750c
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCValType.java
@@ -0,0 +1,188 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum SCValType
+// {
+// SCV_BOOL = 0,
+// SCV_VOID = 1,
+// SCV_ERROR = 2,
+//
+// // 32 bits is the smallest type in WASM or XDR; no need for u8/u16.
+// SCV_U32 = 3,
+// SCV_I32 = 4,
+//
+// // 64 bits is naturally supported by both WASM and XDR also.
+// SCV_U64 = 5,
+// SCV_I64 = 6,
+//
+// // Time-related u64 subtypes with their own functions and formatting.
+// SCV_TIMEPOINT = 7,
+// SCV_DURATION = 8,
+//
+// // 128 bits is naturally supported by Rust and we use it for Soroban
+// // fixed-point arithmetic prices / balances / similar "quantities". These
+// // are represented in XDR as a pair of 2 u64s.
+// SCV_U128 = 9,
+// SCV_I128 = 10,
+//
+// // 256 bits is the size of sha256 output, ed25519 keys, and the EVM machine
+// // word, so for interop use we include this even though it requires a small
+// // amount of Rust guest and/or host library code.
+// SCV_U256 = 11,
+// SCV_I256 = 12,
+//
+// // Bytes come in 3 flavors, 2 of which have meaningfully different
+// // formatting and validity-checking / domain-restriction.
+// SCV_BYTES = 13,
+// SCV_STRING = 14,
+// SCV_SYMBOL = 15,
+//
+// // Vecs and maps are just polymorphic containers of other ScVals.
+// SCV_VEC = 16,
+// SCV_MAP = 17,
+//
+// // Address is the universal identifier for contracts and classic
+// // accounts.
+// SCV_ADDRESS = 18,
+//
+// // The following are the internal SCVal variants that are not
+// // exposed to the contracts.
+// SCV_CONTRACT_INSTANCE = 19,
+//
+// // SCV_LEDGER_KEY_CONTRACT_INSTANCE and SCV_LEDGER_KEY_NONCE are unique
+// // symbolic SCVals used as the key for ledger entries for a contract's
+// // instance and an address' nonce, respectively.
+// SCV_LEDGER_KEY_CONTRACT_INSTANCE = 20,
+// SCV_LEDGER_KEY_NONCE = 21
+// };
+
+// ===========================================================================
+public enum SCValType implements XdrElement {
+ SCV_BOOL(0),
+ SCV_VOID(1),
+ SCV_ERROR(2),
+ SCV_U32(3),
+ SCV_I32(4),
+ SCV_U64(5),
+ SCV_I64(6),
+ SCV_TIMEPOINT(7),
+ SCV_DURATION(8),
+ SCV_U128(9),
+ SCV_I128(10),
+ SCV_U256(11),
+ SCV_I256(12),
+ SCV_BYTES(13),
+ SCV_STRING(14),
+ SCV_SYMBOL(15),
+ SCV_VEC(16),
+ SCV_MAP(17),
+ SCV_ADDRESS(18),
+ SCV_CONTRACT_INSTANCE(19),
+ SCV_LEDGER_KEY_CONTRACT_INSTANCE(20),
+ SCV_LEDGER_KEY_NONCE(21),
+ ;
+ private int mValue;
+
+ SCValType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SCValType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SCV_BOOL;
+ case 1:
+ return SCV_VOID;
+ case 2:
+ return SCV_ERROR;
+ case 3:
+ return SCV_U32;
+ case 4:
+ return SCV_I32;
+ case 5:
+ return SCV_U64;
+ case 6:
+ return SCV_I64;
+ case 7:
+ return SCV_TIMEPOINT;
+ case 8:
+ return SCV_DURATION;
+ case 9:
+ return SCV_U128;
+ case 10:
+ return SCV_I128;
+ case 11:
+ return SCV_U256;
+ case 12:
+ return SCV_I256;
+ case 13:
+ return SCV_BYTES;
+ case 14:
+ return SCV_STRING;
+ case 15:
+ return SCV_SYMBOL;
+ case 16:
+ return SCV_VEC;
+ case 17:
+ return SCV_MAP;
+ case 18:
+ return SCV_ADDRESS;
+ case 19:
+ return SCV_CONTRACT_INSTANCE;
+ case 20:
+ return SCV_LEDGER_KEY_CONTRACT_INSTANCE;
+ case 21:
+ return SCV_LEDGER_KEY_NONCE;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCValType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCValType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCValType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCVec.java b/src/main/java/org/stellar/sdk/xdr/SCVec.java
new file mode 100644
index 000000000..3de069d23
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCVec.java
@@ -0,0 +1,96 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// typedef SCVal SCVec<>;
+
+// ===========================================================================
+public class SCVec implements XdrElement {
+ private SCVal[] SCVec;
+
+ public SCVec() {}
+
+ public SCVec(SCVal[] SCVec) {
+ this.SCVec = SCVec;
+ }
+
+ public SCVal[] getSCVec() {
+ return this.SCVec;
+ }
+
+ public void setSCVec(SCVal[] value) {
+ this.SCVec = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SCVec encodedSCVec) throws IOException {
+ int SCVecsize = encodedSCVec.getSCVec().length;
+ stream.writeInt(SCVecsize);
+ for (int i = 0; i < SCVecsize; i++) {
+ SCVal.encode(stream, encodedSCVec.SCVec[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SCVec decode(XdrDataInputStream stream) throws IOException {
+ SCVec decodedSCVec = new SCVec();
+ int SCVecsize = stream.readInt();
+ decodedSCVec.SCVec = new SCVal[SCVecsize];
+ for (int i = 0; i < SCVecsize; i++) {
+ decodedSCVec.SCVec[i] = SCVal.decode(stream);
+ }
+ return decodedSCVec;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(this.SCVec);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SCVec)) {
+ return false;
+ }
+
+ SCVec other = (SCVec) object;
+ return Arrays.equals(this.SCVec, other.SCVec);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SCVec fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SCVec fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SendMore.java b/src/main/java/org/stellar/sdk/xdr/SendMore.java
index ec7537759..a9c02b09d 100644
--- a/src/main/java/org/stellar/sdk/xdr/SendMore.java
+++ b/src/main/java/org/stellar/sdk/xdr/SendMore.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -44,7 +49,7 @@ public static SendMore decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.numMessages);
+ return Objects.hash(this.numMessages);
}
@Override
@@ -54,7 +59,31 @@ public boolean equals(Object object) {
}
SendMore other = (SendMore) object;
- return Objects.equal(this.numMessages, other.numMessages);
+ return Objects.equals(this.numMessages, other.numMessages);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SendMore fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SendMore fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -67,7 +96,7 @@ public Builder numMessages(Uint32 numMessages) {
public SendMore build() {
SendMore val = new SendMore();
- val.setNumMessages(numMessages);
+ val.setNumMessages(this.numMessages);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SendMoreExtended.java b/src/main/java/org/stellar/sdk/xdr/SendMoreExtended.java
new file mode 100644
index 000000000..95a345899
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SendMoreExtended.java
@@ -0,0 +1,124 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SendMoreExtended
+// {
+// uint32 numMessages;
+// uint32 numBytes;
+// };
+
+// ===========================================================================
+public class SendMoreExtended implements XdrElement {
+ public SendMoreExtended() {}
+
+ private Uint32 numMessages;
+
+ public Uint32 getNumMessages() {
+ return this.numMessages;
+ }
+
+ public void setNumMessages(Uint32 value) {
+ this.numMessages = value;
+ }
+
+ private Uint32 numBytes;
+
+ public Uint32 getNumBytes() {
+ return this.numBytes;
+ }
+
+ public void setNumBytes(Uint32 value) {
+ this.numBytes = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SendMoreExtended encodedSendMoreExtended)
+ throws IOException {
+ Uint32.encode(stream, encodedSendMoreExtended.numMessages);
+ Uint32.encode(stream, encodedSendMoreExtended.numBytes);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SendMoreExtended decode(XdrDataInputStream stream) throws IOException {
+ SendMoreExtended decodedSendMoreExtended = new SendMoreExtended();
+ decodedSendMoreExtended.numMessages = Uint32.decode(stream);
+ decodedSendMoreExtended.numBytes = Uint32.decode(stream);
+ return decodedSendMoreExtended;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.numMessages, this.numBytes);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SendMoreExtended)) {
+ return false;
+ }
+
+ SendMoreExtended other = (SendMoreExtended) object;
+ return Objects.equals(this.numMessages, other.numMessages)
+ && Objects.equals(this.numBytes, other.numBytes);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SendMoreExtended fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SendMoreExtended fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Uint32 numMessages;
+ private Uint32 numBytes;
+
+ public Builder numMessages(Uint32 numMessages) {
+ this.numMessages = numMessages;
+ return this;
+ }
+
+ public Builder numBytes(Uint32 numBytes) {
+ this.numBytes = numBytes;
+ return this;
+ }
+
+ public SendMoreExtended build() {
+ SendMoreExtended val = new SendMoreExtended();
+ val.setNumMessages(this.numMessages);
+ val.setNumBytes(this.numBytes);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SequenceNumber.java b/src/main/java/org/stellar/sdk/xdr/SequenceNumber.java
index a300fd82a..e7c6e02f6 100644
--- a/src/main/java/org/stellar/sdk/xdr/SequenceNumber.java
+++ b/src/main/java/org/stellar/sdk/xdr/SequenceNumber.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -45,7 +50,7 @@ public static SequenceNumber decode(XdrDataInputStream stream) throws IOExceptio
@Override
public int hashCode() {
- return Objects.hashCode(this.SequenceNumber);
+ return Objects.hash(this.SequenceNumber);
}
@Override
@@ -55,6 +60,30 @@ public boolean equals(Object object) {
}
SequenceNumber other = (SequenceNumber) object;
- return Objects.equal(this.SequenceNumber, other.SequenceNumber);
+ return Objects.equals(this.SequenceNumber, other.SequenceNumber);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SequenceNumber fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SequenceNumber fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SetOptionsOp.java b/src/main/java/org/stellar/sdk/xdr/SetOptionsOp.java
index fbc61bc30..c34720e5e 100644
--- a/src/main/java/org/stellar/sdk/xdr/SetOptionsOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/SetOptionsOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -227,7 +232,7 @@ public static SetOptionsOp decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.inflationDest,
this.clearFlags,
this.setFlags,
@@ -246,15 +251,39 @@ public boolean equals(Object object) {
}
SetOptionsOp other = (SetOptionsOp) object;
- return Objects.equal(this.inflationDest, other.inflationDest)
- && Objects.equal(this.clearFlags, other.clearFlags)
- && Objects.equal(this.setFlags, other.setFlags)
- && Objects.equal(this.masterWeight, other.masterWeight)
- && Objects.equal(this.lowThreshold, other.lowThreshold)
- && Objects.equal(this.medThreshold, other.medThreshold)
- && Objects.equal(this.highThreshold, other.highThreshold)
- && Objects.equal(this.homeDomain, other.homeDomain)
- && Objects.equal(this.signer, other.signer);
+ return Objects.equals(this.inflationDest, other.inflationDest)
+ && Objects.equals(this.clearFlags, other.clearFlags)
+ && Objects.equals(this.setFlags, other.setFlags)
+ && Objects.equals(this.masterWeight, other.masterWeight)
+ && Objects.equals(this.lowThreshold, other.lowThreshold)
+ && Objects.equals(this.medThreshold, other.medThreshold)
+ && Objects.equals(this.highThreshold, other.highThreshold)
+ && Objects.equals(this.homeDomain, other.homeDomain)
+ && Objects.equals(this.signer, other.signer);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SetOptionsOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SetOptionsOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -315,15 +344,15 @@ public Builder signer(Signer signer) {
public SetOptionsOp build() {
SetOptionsOp val = new SetOptionsOp();
- val.setInflationDest(inflationDest);
- val.setClearFlags(clearFlags);
- val.setSetFlags(setFlags);
- val.setMasterWeight(masterWeight);
- val.setLowThreshold(lowThreshold);
- val.setMedThreshold(medThreshold);
- val.setHighThreshold(highThreshold);
- val.setHomeDomain(homeDomain);
- val.setSigner(signer);
+ val.setInflationDest(this.inflationDest);
+ val.setClearFlags(this.clearFlags);
+ val.setSetFlags(this.setFlags);
+ val.setMasterWeight(this.masterWeight);
+ val.setLowThreshold(this.lowThreshold);
+ val.setMedThreshold(this.medThreshold);
+ val.setHighThreshold(this.highThreshold);
+ val.setHomeDomain(this.homeDomain);
+ val.setSigner(this.signer);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SetOptionsResult.java b/src/main/java/org/stellar/sdk/xdr/SetOptionsResult.java
index ebafb0c18..068a83427 100644
--- a/src/main/java/org/stellar/sdk/xdr/SetOptionsResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/SetOptionsResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,16 @@
// {
// case SET_OPTIONS_SUCCESS:
// void;
-// default:
+// case SET_OPTIONS_LOW_RESERVE:
+// case SET_OPTIONS_TOO_MANY_SIGNERS:
+// case SET_OPTIONS_BAD_FLAGS:
+// case SET_OPTIONS_INVALID_INFLATION:
+// case SET_OPTIONS_CANT_CHANGE:
+// case SET_OPTIONS_UNKNOWN_FLAG:
+// case SET_OPTIONS_THRESHOLD_OUT_OF_RANGE:
+// case SET_OPTIONS_BAD_SIGNER:
+// case SET_OPTIONS_INVALID_HOME_DOMAIN:
+// case SET_OPTIONS_AUTH_REVOCABLE_REQUIRED:
// void;
// };
@@ -53,7 +67,16 @@ public static void encode(XdrDataOutputStream stream, SetOptionsResult encodedSe
switch (encodedSetOptionsResult.getDiscriminant()) {
case SET_OPTIONS_SUCCESS:
break;
- default:
+ case SET_OPTIONS_LOW_RESERVE:
+ case SET_OPTIONS_TOO_MANY_SIGNERS:
+ case SET_OPTIONS_BAD_FLAGS:
+ case SET_OPTIONS_INVALID_INFLATION:
+ case SET_OPTIONS_CANT_CHANGE:
+ case SET_OPTIONS_UNKNOWN_FLAG:
+ case SET_OPTIONS_THRESHOLD_OUT_OF_RANGE:
+ case SET_OPTIONS_BAD_SIGNER:
+ case SET_OPTIONS_INVALID_HOME_DOMAIN:
+ case SET_OPTIONS_AUTH_REVOCABLE_REQUIRED:
break;
}
}
@@ -69,7 +92,16 @@ public static SetOptionsResult decode(XdrDataInputStream stream) throws IOExcept
switch (decodedSetOptionsResult.getDiscriminant()) {
case SET_OPTIONS_SUCCESS:
break;
- default:
+ case SET_OPTIONS_LOW_RESERVE:
+ case SET_OPTIONS_TOO_MANY_SIGNERS:
+ case SET_OPTIONS_BAD_FLAGS:
+ case SET_OPTIONS_INVALID_INFLATION:
+ case SET_OPTIONS_CANT_CHANGE:
+ case SET_OPTIONS_UNKNOWN_FLAG:
+ case SET_OPTIONS_THRESHOLD_OUT_OF_RANGE:
+ case SET_OPTIONS_BAD_SIGNER:
+ case SET_OPTIONS_INVALID_HOME_DOMAIN:
+ case SET_OPTIONS_AUTH_REVOCABLE_REQUIRED:
break;
}
return decodedSetOptionsResult;
@@ -77,7 +109,7 @@ public static SetOptionsResult decode(XdrDataInputStream stream) throws IOExcept
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -87,6 +119,30 @@ public boolean equals(Object object) {
}
SetOptionsResult other = (SetOptionsResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SetOptionsResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SetOptionsResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SetOptionsResultCode.java b/src/main/java/org/stellar/sdk/xdr/SetOptionsResultCode.java
index 466ea4769..be73b41b9 100644
--- a/src/main/java/org/stellar/sdk/xdr/SetOptionsResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/SetOptionsResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -87,4 +92,28 @@ public static void encode(XdrDataOutputStream stream, SetOptionsResultCode value
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SetOptionsResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SetOptionsResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SetTrustLineFlagsOp.java b/src/main/java/org/stellar/sdk/xdr/SetTrustLineFlagsOp.java
index a4cfe47f2..6766e4fcd 100644
--- a/src/main/java/org/stellar/sdk/xdr/SetTrustLineFlagsOp.java
+++ b/src/main/java/org/stellar/sdk/xdr/SetTrustLineFlagsOp.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -85,7 +90,7 @@ public static SetTrustLineFlagsOp decode(XdrDataInputStream stream) throws IOExc
@Override
public int hashCode() {
- return Objects.hashCode(this.trustor, this.asset, this.clearFlags, this.setFlags);
+ return Objects.hash(this.trustor, this.asset, this.clearFlags, this.setFlags);
}
@Override
@@ -95,10 +100,34 @@ public boolean equals(Object object) {
}
SetTrustLineFlagsOp other = (SetTrustLineFlagsOp) object;
- return Objects.equal(this.trustor, other.trustor)
- && Objects.equal(this.asset, other.asset)
- && Objects.equal(this.clearFlags, other.clearFlags)
- && Objects.equal(this.setFlags, other.setFlags);
+ return Objects.equals(this.trustor, other.trustor)
+ && Objects.equals(this.asset, other.asset)
+ && Objects.equals(this.clearFlags, other.clearFlags)
+ && Objects.equals(this.setFlags, other.setFlags);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SetTrustLineFlagsOp fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SetTrustLineFlagsOp fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -129,10 +158,10 @@ public Builder setFlags(Uint32 setFlags) {
public SetTrustLineFlagsOp build() {
SetTrustLineFlagsOp val = new SetTrustLineFlagsOp();
- val.setTrustor(trustor);
- val.setAsset(asset);
- val.setClearFlags(clearFlags);
- val.setSetFlags(setFlags);
+ val.setTrustor(this.trustor);
+ val.setAsset(this.asset);
+ val.setClearFlags(this.clearFlags);
+ val.setSetFlags(this.setFlags);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SetTrustLineFlagsResult.java b/src/main/java/org/stellar/sdk/xdr/SetTrustLineFlagsResult.java
index 1938eac61..4ded3bedc 100644
--- a/src/main/java/org/stellar/sdk/xdr/SetTrustLineFlagsResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/SetTrustLineFlagsResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,7 +17,11 @@
// {
// case SET_TRUST_LINE_FLAGS_SUCCESS:
// void;
-// default:
+// case SET_TRUST_LINE_FLAGS_MALFORMED:
+// case SET_TRUST_LINE_FLAGS_NO_TRUST_LINE:
+// case SET_TRUST_LINE_FLAGS_CANT_REVOKE:
+// case SET_TRUST_LINE_FLAGS_INVALID_STATE:
+// case SET_TRUST_LINE_FLAGS_LOW_RESERVE:
// void;
// };
@@ -54,7 +63,11 @@ public static void encode(
switch (encodedSetTrustLineFlagsResult.getDiscriminant()) {
case SET_TRUST_LINE_FLAGS_SUCCESS:
break;
- default:
+ case SET_TRUST_LINE_FLAGS_MALFORMED:
+ case SET_TRUST_LINE_FLAGS_NO_TRUST_LINE:
+ case SET_TRUST_LINE_FLAGS_CANT_REVOKE:
+ case SET_TRUST_LINE_FLAGS_INVALID_STATE:
+ case SET_TRUST_LINE_FLAGS_LOW_RESERVE:
break;
}
}
@@ -70,7 +83,11 @@ public static SetTrustLineFlagsResult decode(XdrDataInputStream stream) throws I
switch (decodedSetTrustLineFlagsResult.getDiscriminant()) {
case SET_TRUST_LINE_FLAGS_SUCCESS:
break;
- default:
+ case SET_TRUST_LINE_FLAGS_MALFORMED:
+ case SET_TRUST_LINE_FLAGS_NO_TRUST_LINE:
+ case SET_TRUST_LINE_FLAGS_CANT_REVOKE:
+ case SET_TRUST_LINE_FLAGS_INVALID_STATE:
+ case SET_TRUST_LINE_FLAGS_LOW_RESERVE:
break;
}
return decodedSetTrustLineFlagsResult;
@@ -78,7 +95,7 @@ public static SetTrustLineFlagsResult decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(this.code);
+ return Objects.hash(this.code);
}
@Override
@@ -88,6 +105,30 @@ public boolean equals(Object object) {
}
SetTrustLineFlagsResult other = (SetTrustLineFlagsResult) object;
- return Objects.equal(this.code, other.code);
+ return Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SetTrustLineFlagsResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SetTrustLineFlagsResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SetTrustLineFlagsResultCode.java b/src/main/java/org/stellar/sdk/xdr/SetTrustLineFlagsResultCode.java
index 9714bef41..7deb5e653 100644
--- a/src/main/java/org/stellar/sdk/xdr/SetTrustLineFlagsResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/SetTrustLineFlagsResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -68,4 +73,28 @@ public static void encode(XdrDataOutputStream stream, SetTrustLineFlagsResultCod
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SetTrustLineFlagsResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SetTrustLineFlagsResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Signature.java b/src/main/java/org/stellar/sdk/xdr/Signature.java
index 2616ae0ca..42103a825 100644
--- a/src/main/java/org/stellar/sdk/xdr/Signature.java
+++ b/src/main/java/org/stellar/sdk/xdr/Signature.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -61,4 +66,28 @@ public boolean equals(Object object) {
Signature other = (Signature) object;
return Arrays.equals(this.Signature, other.Signature);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Signature fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Signature fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SignatureHint.java b/src/main/java/org/stellar/sdk/xdr/SignatureHint.java
index 3cb8b3df0..28e138563 100644
--- a/src/main/java/org/stellar/sdk/xdr/SignatureHint.java
+++ b/src/main/java/org/stellar/sdk/xdr/SignatureHint.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -60,4 +65,28 @@ public boolean equals(Object object) {
SignatureHint other = (SignatureHint) object;
return Arrays.equals(this.SignatureHint, other.SignatureHint);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SignatureHint fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SignatureHint fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SignedSurveyRequestMessage.java b/src/main/java/org/stellar/sdk/xdr/SignedSurveyRequestMessage.java
index 49acda013..ba6c35ec5 100644
--- a/src/main/java/org/stellar/sdk/xdr/SignedSurveyRequestMessage.java
+++ b/src/main/java/org/stellar/sdk/xdr/SignedSurveyRequestMessage.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -58,7 +63,7 @@ public static SignedSurveyRequestMessage decode(XdrDataInputStream stream) throw
@Override
public int hashCode() {
- return Objects.hashCode(this.requestSignature, this.request);
+ return Objects.hash(this.requestSignature, this.request);
}
@Override
@@ -68,8 +73,32 @@ public boolean equals(Object object) {
}
SignedSurveyRequestMessage other = (SignedSurveyRequestMessage) object;
- return Objects.equal(this.requestSignature, other.requestSignature)
- && Objects.equal(this.request, other.request);
+ return Objects.equals(this.requestSignature, other.requestSignature)
+ && Objects.equals(this.request, other.request);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SignedSurveyRequestMessage fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SignedSurveyRequestMessage fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -88,8 +117,8 @@ public Builder request(SurveyRequestMessage request) {
public SignedSurveyRequestMessage build() {
SignedSurveyRequestMessage val = new SignedSurveyRequestMessage();
- val.setRequestSignature(requestSignature);
- val.setRequest(request);
+ val.setRequestSignature(this.requestSignature);
+ val.setRequest(this.request);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SignedSurveyResponseMessage.java b/src/main/java/org/stellar/sdk/xdr/SignedSurveyResponseMessage.java
index be424049c..85c1083ea 100644
--- a/src/main/java/org/stellar/sdk/xdr/SignedSurveyResponseMessage.java
+++ b/src/main/java/org/stellar/sdk/xdr/SignedSurveyResponseMessage.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -59,7 +64,7 @@ public static SignedSurveyResponseMessage decode(XdrDataInputStream stream) thro
@Override
public int hashCode() {
- return Objects.hashCode(this.responseSignature, this.response);
+ return Objects.hash(this.responseSignature, this.response);
}
@Override
@@ -69,8 +74,32 @@ public boolean equals(Object object) {
}
SignedSurveyResponseMessage other = (SignedSurveyResponseMessage) object;
- return Objects.equal(this.responseSignature, other.responseSignature)
- && Objects.equal(this.response, other.response);
+ return Objects.equals(this.responseSignature, other.responseSignature)
+ && Objects.equals(this.response, other.response);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SignedSurveyResponseMessage fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SignedSurveyResponseMessage fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -89,8 +118,8 @@ public Builder response(SurveyResponseMessage response) {
public SignedSurveyResponseMessage build() {
SignedSurveyResponseMessage val = new SignedSurveyResponseMessage();
- val.setResponseSignature(responseSignature);
- val.setResponse(response);
+ val.setResponseSignature(this.responseSignature);
+ val.setResponse(this.response);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Signer.java b/src/main/java/org/stellar/sdk/xdr/Signer.java
index 3a57efea7..1d8918247 100644
--- a/src/main/java/org/stellar/sdk/xdr/Signer.java
+++ b/src/main/java/org/stellar/sdk/xdr/Signer.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -56,7 +61,7 @@ public static Signer decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.key, this.weight);
+ return Objects.hash(this.key, this.weight);
}
@Override
@@ -66,7 +71,31 @@ public boolean equals(Object object) {
}
Signer other = (Signer) object;
- return Objects.equal(this.key, other.key) && Objects.equal(this.weight, other.weight);
+ return Objects.equals(this.key, other.key) && Objects.equals(this.weight, other.weight);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Signer fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Signer fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -85,8 +114,8 @@ public Builder weight(Uint32 weight) {
public Signer build() {
Signer val = new Signer();
- val.setKey(key);
- val.setWeight(weight);
+ val.setKey(this.key);
+ val.setWeight(this.weight);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SignerKey.java b/src/main/java/org/stellar/sdk/xdr/SignerKey.java
index 3522883d0..9a73e3a8d 100644
--- a/src/main/java/org/stellar/sdk/xdr/SignerKey.java
+++ b/src/main/java/org/stellar/sdk/xdr/SignerKey.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -118,10 +123,10 @@ public Builder ed25519SignedPayload(SignerKeyEd25519SignedPayload ed25519SignedP
public SignerKey build() {
SignerKey val = new SignerKey();
val.setDiscriminant(discriminant);
- val.setEd25519(ed25519);
- val.setPreAuthTx(preAuthTx);
- val.setHashX(hashX);
- val.setEd25519SignedPayload(ed25519SignedPayload);
+ val.setEd25519(this.ed25519);
+ val.setPreAuthTx(this.preAuthTx);
+ val.setHashX(this.hashX);
+ val.setEd25519SignedPayload(this.ed25519SignedPayload);
return val;
}
}
@@ -174,7 +179,7 @@ public static SignerKey decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.ed25519, this.preAuthTx, this.hashX, this.ed25519SignedPayload, this.type);
}
@@ -185,14 +190,38 @@ public boolean equals(Object object) {
}
SignerKey other = (SignerKey) object;
- return Objects.equal(this.ed25519, other.ed25519)
- && Objects.equal(this.preAuthTx, other.preAuthTx)
- && Objects.equal(this.hashX, other.hashX)
- && Objects.equal(this.ed25519SignedPayload, other.ed25519SignedPayload)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.ed25519, other.ed25519)
+ && Objects.equals(this.preAuthTx, other.preAuthTx)
+ && Objects.equals(this.hashX, other.hashX)
+ && Objects.equals(this.ed25519SignedPayload, other.ed25519SignedPayload)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SignerKey fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SignerKey fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
- public static class SignerKeyEd25519SignedPayload {
+ public static class SignerKeyEd25519SignedPayload implements XdrElement {
public SignerKeyEd25519SignedPayload() {}
private Uint256 ed25519;
@@ -242,7 +271,7 @@ public static SignerKeyEd25519SignedPayload decode(XdrDataInputStream stream)
@Override
public int hashCode() {
- return Objects.hashCode(this.ed25519, Arrays.hashCode(this.payload));
+ return Objects.hash(this.ed25519, Arrays.hashCode(this.payload));
}
@Override
@@ -252,10 +281,34 @@ public boolean equals(Object object) {
}
SignerKeyEd25519SignedPayload other = (SignerKeyEd25519SignedPayload) object;
- return Objects.equal(this.ed25519, other.ed25519)
+ return Objects.equals(this.ed25519, other.ed25519)
&& Arrays.equals(this.payload, other.payload);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SignerKeyEd25519SignedPayload fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SignerKeyEd25519SignedPayload fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private Uint256 ed25519;
private byte[] payload;
@@ -272,8 +325,8 @@ public Builder payload(byte[] payload) {
public SignerKeyEd25519SignedPayload build() {
SignerKeyEd25519SignedPayload val = new SignerKeyEd25519SignedPayload();
- val.setEd25519(ed25519);
- val.setPayload(payload);
+ val.setEd25519(this.ed25519);
+ val.setPayload(this.payload);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SignerKeyType.java b/src/main/java/org/stellar/sdk/xdr/SignerKeyType.java
index 89b320d91..90453dcf0 100644
--- a/src/main/java/org/stellar/sdk/xdr/SignerKeyType.java
+++ b/src/main/java/org/stellar/sdk/xdr/SignerKeyType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -55,4 +60,28 @@ public static void encode(XdrDataOutputStream stream, SignerKeyType value) throw
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SignerKeyType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SignerKeyType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SimplePaymentResult.java b/src/main/java/org/stellar/sdk/xdr/SimplePaymentResult.java
index 07bd2e388..43825f1e7 100644
--- a/src/main/java/org/stellar/sdk/xdr/SimplePaymentResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/SimplePaymentResult.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -71,7 +76,7 @@ public static SimplePaymentResult decode(XdrDataInputStream stream) throws IOExc
@Override
public int hashCode() {
- return Objects.hashCode(this.destination, this.asset, this.amount);
+ return Objects.hash(this.destination, this.asset, this.amount);
}
@Override
@@ -81,9 +86,33 @@ public boolean equals(Object object) {
}
SimplePaymentResult other = (SimplePaymentResult) object;
- return Objects.equal(this.destination, other.destination)
- && Objects.equal(this.asset, other.asset)
- && Objects.equal(this.amount, other.amount);
+ return Objects.equals(this.destination, other.destination)
+ && Objects.equals(this.asset, other.asset)
+ && Objects.equals(this.amount, other.amount);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SimplePaymentResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SimplePaymentResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -108,9 +137,9 @@ public Builder amount(Int64 amount) {
public SimplePaymentResult build() {
SimplePaymentResult val = new SimplePaymentResult();
- val.setDestination(destination);
- val.setAsset(asset);
- val.setAmount(amount);
+ val.setDestination(this.destination);
+ val.setAsset(this.asset);
+ val.setAmount(this.amount);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SorobanAddressCredentials.java b/src/main/java/org/stellar/sdk/xdr/SorobanAddressCredentials.java
new file mode 100644
index 000000000..1d1ddd442
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SorobanAddressCredentials.java
@@ -0,0 +1,167 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SorobanAddressCredentials
+// {
+// SCAddress address;
+// int64 nonce;
+// uint32 signatureExpirationLedger;
+// SCVal signature;
+// };
+
+// ===========================================================================
+public class SorobanAddressCredentials implements XdrElement {
+ public SorobanAddressCredentials() {}
+
+ private SCAddress address;
+
+ public SCAddress getAddress() {
+ return this.address;
+ }
+
+ public void setAddress(SCAddress value) {
+ this.address = value;
+ }
+
+ private Int64 nonce;
+
+ public Int64 getNonce() {
+ return this.nonce;
+ }
+
+ public void setNonce(Int64 value) {
+ this.nonce = value;
+ }
+
+ private Uint32 signatureExpirationLedger;
+
+ public Uint32 getSignatureExpirationLedger() {
+ return this.signatureExpirationLedger;
+ }
+
+ public void setSignatureExpirationLedger(Uint32 value) {
+ this.signatureExpirationLedger = value;
+ }
+
+ private SCVal signature;
+
+ public SCVal getSignature() {
+ return this.signature;
+ }
+
+ public void setSignature(SCVal value) {
+ this.signature = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SorobanAddressCredentials encodedSorobanAddressCredentials)
+ throws IOException {
+ SCAddress.encode(stream, encodedSorobanAddressCredentials.address);
+ Int64.encode(stream, encodedSorobanAddressCredentials.nonce);
+ Uint32.encode(stream, encodedSorobanAddressCredentials.signatureExpirationLedger);
+ SCVal.encode(stream, encodedSorobanAddressCredentials.signature);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SorobanAddressCredentials decode(XdrDataInputStream stream) throws IOException {
+ SorobanAddressCredentials decodedSorobanAddressCredentials = new SorobanAddressCredentials();
+ decodedSorobanAddressCredentials.address = SCAddress.decode(stream);
+ decodedSorobanAddressCredentials.nonce = Int64.decode(stream);
+ decodedSorobanAddressCredentials.signatureExpirationLedger = Uint32.decode(stream);
+ decodedSorobanAddressCredentials.signature = SCVal.decode(stream);
+ return decodedSorobanAddressCredentials;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.address, this.nonce, this.signatureExpirationLedger, this.signature);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SorobanAddressCredentials)) {
+ return false;
+ }
+
+ SorobanAddressCredentials other = (SorobanAddressCredentials) object;
+ return Objects.equals(this.address, other.address)
+ && Objects.equals(this.nonce, other.nonce)
+ && Objects.equals(this.signatureExpirationLedger, other.signatureExpirationLedger)
+ && Objects.equals(this.signature, other.signature);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SorobanAddressCredentials fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SorobanAddressCredentials fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SCAddress address;
+ private Int64 nonce;
+ private Uint32 signatureExpirationLedger;
+ private SCVal signature;
+
+ public Builder address(SCAddress address) {
+ this.address = address;
+ return this;
+ }
+
+ public Builder nonce(Int64 nonce) {
+ this.nonce = nonce;
+ return this;
+ }
+
+ public Builder signatureExpirationLedger(Uint32 signatureExpirationLedger) {
+ this.signatureExpirationLedger = signatureExpirationLedger;
+ return this;
+ }
+
+ public Builder signature(SCVal signature) {
+ this.signature = signature;
+ return this;
+ }
+
+ public SorobanAddressCredentials build() {
+ SorobanAddressCredentials val = new SorobanAddressCredentials();
+ val.setAddress(this.address);
+ val.setNonce(this.nonce);
+ val.setSignatureExpirationLedger(this.signatureExpirationLedger);
+ val.setSignature(this.signature);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizationEntry.java b/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizationEntry.java
new file mode 100644
index 000000000..49476b3f7
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizationEntry.java
@@ -0,0 +1,125 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SorobanAuthorizationEntry
+// {
+// SorobanCredentials credentials;
+// SorobanAuthorizedInvocation rootInvocation;
+// };
+
+// ===========================================================================
+public class SorobanAuthorizationEntry implements XdrElement {
+ public SorobanAuthorizationEntry() {}
+
+ private SorobanCredentials credentials;
+
+ public SorobanCredentials getCredentials() {
+ return this.credentials;
+ }
+
+ public void setCredentials(SorobanCredentials value) {
+ this.credentials = value;
+ }
+
+ private SorobanAuthorizedInvocation rootInvocation;
+
+ public SorobanAuthorizedInvocation getRootInvocation() {
+ return this.rootInvocation;
+ }
+
+ public void setRootInvocation(SorobanAuthorizedInvocation value) {
+ this.rootInvocation = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SorobanAuthorizationEntry encodedSorobanAuthorizationEntry)
+ throws IOException {
+ SorobanCredentials.encode(stream, encodedSorobanAuthorizationEntry.credentials);
+ SorobanAuthorizedInvocation.encode(stream, encodedSorobanAuthorizationEntry.rootInvocation);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SorobanAuthorizationEntry decode(XdrDataInputStream stream) throws IOException {
+ SorobanAuthorizationEntry decodedSorobanAuthorizationEntry = new SorobanAuthorizationEntry();
+ decodedSorobanAuthorizationEntry.credentials = SorobanCredentials.decode(stream);
+ decodedSorobanAuthorizationEntry.rootInvocation = SorobanAuthorizedInvocation.decode(stream);
+ return decodedSorobanAuthorizationEntry;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.credentials, this.rootInvocation);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SorobanAuthorizationEntry)) {
+ return false;
+ }
+
+ SorobanAuthorizationEntry other = (SorobanAuthorizationEntry) object;
+ return Objects.equals(this.credentials, other.credentials)
+ && Objects.equals(this.rootInvocation, other.rootInvocation);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SorobanAuthorizationEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SorobanAuthorizationEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SorobanCredentials credentials;
+ private SorobanAuthorizedInvocation rootInvocation;
+
+ public Builder credentials(SorobanCredentials credentials) {
+ this.credentials = credentials;
+ return this;
+ }
+
+ public Builder rootInvocation(SorobanAuthorizedInvocation rootInvocation) {
+ this.rootInvocation = rootInvocation;
+ return this;
+ }
+
+ public SorobanAuthorizationEntry build() {
+ SorobanAuthorizationEntry val = new SorobanAuthorizationEntry();
+ val.setCredentials(this.credentials);
+ val.setRootInvocation(this.rootInvocation);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunction.java b/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunction.java
new file mode 100644
index 000000000..f36d5cbe7
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunction.java
@@ -0,0 +1,162 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union SorobanAuthorizedFunction switch (SorobanAuthorizedFunctionType type)
+// {
+// case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN:
+// InvokeContractArgs contractFn;
+// case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN:
+// CreateContractArgs createContractHostFn;
+// };
+
+// ===========================================================================
+public class SorobanAuthorizedFunction implements XdrElement {
+ public SorobanAuthorizedFunction() {}
+
+ SorobanAuthorizedFunctionType type;
+
+ public SorobanAuthorizedFunctionType getDiscriminant() {
+ return this.type;
+ }
+
+ public void setDiscriminant(SorobanAuthorizedFunctionType value) {
+ this.type = value;
+ }
+
+ private InvokeContractArgs contractFn;
+
+ public InvokeContractArgs getContractFn() {
+ return this.contractFn;
+ }
+
+ public void setContractFn(InvokeContractArgs value) {
+ this.contractFn = value;
+ }
+
+ private CreateContractArgs createContractHostFn;
+
+ public CreateContractArgs getCreateContractHostFn() {
+ return this.createContractHostFn;
+ }
+
+ public void setCreateContractHostFn(CreateContractArgs value) {
+ this.createContractHostFn = value;
+ }
+
+ public static final class Builder {
+ private SorobanAuthorizedFunctionType discriminant;
+ private InvokeContractArgs contractFn;
+ private CreateContractArgs createContractHostFn;
+
+ public Builder discriminant(SorobanAuthorizedFunctionType discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder contractFn(InvokeContractArgs contractFn) {
+ this.contractFn = contractFn;
+ return this;
+ }
+
+ public Builder createContractHostFn(CreateContractArgs createContractHostFn) {
+ this.createContractHostFn = createContractHostFn;
+ return this;
+ }
+
+ public SorobanAuthorizedFunction build() {
+ SorobanAuthorizedFunction val = new SorobanAuthorizedFunction();
+ val.setDiscriminant(discriminant);
+ val.setContractFn(this.contractFn);
+ val.setCreateContractHostFn(this.createContractHostFn);
+ return val;
+ }
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SorobanAuthorizedFunction encodedSorobanAuthorizedFunction)
+ throws IOException {
+ // Xdrgen::AST::Identifier
+ // SorobanAuthorizedFunctionType
+ stream.writeInt(encodedSorobanAuthorizedFunction.getDiscriminant().getValue());
+ switch (encodedSorobanAuthorizedFunction.getDiscriminant()) {
+ case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN:
+ InvokeContractArgs.encode(stream, encodedSorobanAuthorizedFunction.contractFn);
+ break;
+ case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN:
+ CreateContractArgs.encode(stream, encodedSorobanAuthorizedFunction.createContractHostFn);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SorobanAuthorizedFunction decode(XdrDataInputStream stream) throws IOException {
+ SorobanAuthorizedFunction decodedSorobanAuthorizedFunction = new SorobanAuthorizedFunction();
+ SorobanAuthorizedFunctionType discriminant = SorobanAuthorizedFunctionType.decode(stream);
+ decodedSorobanAuthorizedFunction.setDiscriminant(discriminant);
+ switch (decodedSorobanAuthorizedFunction.getDiscriminant()) {
+ case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN:
+ decodedSorobanAuthorizedFunction.contractFn = InvokeContractArgs.decode(stream);
+ break;
+ case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN:
+ decodedSorobanAuthorizedFunction.createContractHostFn = CreateContractArgs.decode(stream);
+ break;
+ }
+ return decodedSorobanAuthorizedFunction;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.contractFn, this.createContractHostFn, this.type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SorobanAuthorizedFunction)) {
+ return false;
+ }
+
+ SorobanAuthorizedFunction other = (SorobanAuthorizedFunction) object;
+ return Objects.equals(this.contractFn, other.contractFn)
+ && Objects.equals(this.createContractHostFn, other.createContractHostFn)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SorobanAuthorizedFunction fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SorobanAuthorizedFunction fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunctionType.java b/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunctionType.java
new file mode 100644
index 000000000..d1d22f9fe
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedFunctionType.java
@@ -0,0 +1,80 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum SorobanAuthorizedFunctionType
+// {
+// SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN = 0,
+// SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1
+// };
+
+// ===========================================================================
+public enum SorobanAuthorizedFunctionType implements XdrElement {
+ SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN(0),
+ SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN(1),
+ ;
+ private int mValue;
+
+ SorobanAuthorizedFunctionType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SorobanAuthorizedFunctionType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN;
+ case 1:
+ return SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SorobanAuthorizedFunctionType value)
+ throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SorobanAuthorizedFunctionType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SorobanAuthorizedFunctionType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedInvocation.java b/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedInvocation.java
new file mode 100644
index 000000000..3e874354d
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SorobanAuthorizedInvocation.java
@@ -0,0 +1,138 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SorobanAuthorizedInvocation
+// {
+// SorobanAuthorizedFunction function;
+// SorobanAuthorizedInvocation subInvocations<>;
+// };
+
+// ===========================================================================
+public class SorobanAuthorizedInvocation implements XdrElement {
+ public SorobanAuthorizedInvocation() {}
+
+ private SorobanAuthorizedFunction function;
+
+ public SorobanAuthorizedFunction getFunction() {
+ return this.function;
+ }
+
+ public void setFunction(SorobanAuthorizedFunction value) {
+ this.function = value;
+ }
+
+ private SorobanAuthorizedInvocation[] subInvocations;
+
+ public SorobanAuthorizedInvocation[] getSubInvocations() {
+ return this.subInvocations;
+ }
+
+ public void setSubInvocations(SorobanAuthorizedInvocation[] value) {
+ this.subInvocations = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SorobanAuthorizedInvocation encodedSorobanAuthorizedInvocation)
+ throws IOException {
+ SorobanAuthorizedFunction.encode(stream, encodedSorobanAuthorizedInvocation.function);
+ int subInvocationssize = encodedSorobanAuthorizedInvocation.getSubInvocations().length;
+ stream.writeInt(subInvocationssize);
+ for (int i = 0; i < subInvocationssize; i++) {
+ SorobanAuthorizedInvocation.encode(
+ stream, encodedSorobanAuthorizedInvocation.subInvocations[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SorobanAuthorizedInvocation decode(XdrDataInputStream stream) throws IOException {
+ SorobanAuthorizedInvocation decodedSorobanAuthorizedInvocation =
+ new SorobanAuthorizedInvocation();
+ decodedSorobanAuthorizedInvocation.function = SorobanAuthorizedFunction.decode(stream);
+ int subInvocationssize = stream.readInt();
+ decodedSorobanAuthorizedInvocation.subInvocations =
+ new SorobanAuthorizedInvocation[subInvocationssize];
+ for (int i = 0; i < subInvocationssize; i++) {
+ decodedSorobanAuthorizedInvocation.subInvocations[i] =
+ SorobanAuthorizedInvocation.decode(stream);
+ }
+ return decodedSorobanAuthorizedInvocation;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.function, Arrays.hashCode(this.subInvocations));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SorobanAuthorizedInvocation)) {
+ return false;
+ }
+
+ SorobanAuthorizedInvocation other = (SorobanAuthorizedInvocation) object;
+ return Objects.equals(this.function, other.function)
+ && Arrays.equals(this.subInvocations, other.subInvocations);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SorobanAuthorizedInvocation fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SorobanAuthorizedInvocation fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private SorobanAuthorizedFunction function;
+ private SorobanAuthorizedInvocation[] subInvocations;
+
+ public Builder function(SorobanAuthorizedFunction function) {
+ this.function = function;
+ return this;
+ }
+
+ public Builder subInvocations(SorobanAuthorizedInvocation[] subInvocations) {
+ this.subInvocations = subInvocations;
+ return this;
+ }
+
+ public SorobanAuthorizedInvocation build() {
+ SorobanAuthorizedInvocation val = new SorobanAuthorizedInvocation();
+ val.setFunction(this.function);
+ val.setSubInvocations(this.subInvocations);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SorobanCredentials.java b/src/main/java/org/stellar/sdk/xdr/SorobanCredentials.java
new file mode 100644
index 000000000..e982dc68d
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SorobanCredentials.java
@@ -0,0 +1,140 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union SorobanCredentials switch (SorobanCredentialsType type)
+// {
+// case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT:
+// void;
+// case SOROBAN_CREDENTIALS_ADDRESS:
+// SorobanAddressCredentials address;
+// };
+
+// ===========================================================================
+public class SorobanCredentials implements XdrElement {
+ public SorobanCredentials() {}
+
+ SorobanCredentialsType type;
+
+ public SorobanCredentialsType getDiscriminant() {
+ return this.type;
+ }
+
+ public void setDiscriminant(SorobanCredentialsType value) {
+ this.type = value;
+ }
+
+ private SorobanAddressCredentials address;
+
+ public SorobanAddressCredentials getAddress() {
+ return this.address;
+ }
+
+ public void setAddress(SorobanAddressCredentials value) {
+ this.address = value;
+ }
+
+ public static final class Builder {
+ private SorobanCredentialsType discriminant;
+ private SorobanAddressCredentials address;
+
+ public Builder discriminant(SorobanCredentialsType discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder address(SorobanAddressCredentials address) {
+ this.address = address;
+ return this;
+ }
+
+ public SorobanCredentials build() {
+ SorobanCredentials val = new SorobanCredentials();
+ val.setDiscriminant(discriminant);
+ val.setAddress(this.address);
+ return val;
+ }
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SorobanCredentials encodedSorobanCredentials) throws IOException {
+ // Xdrgen::AST::Identifier
+ // SorobanCredentialsType
+ stream.writeInt(encodedSorobanCredentials.getDiscriminant().getValue());
+ switch (encodedSorobanCredentials.getDiscriminant()) {
+ case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT:
+ break;
+ case SOROBAN_CREDENTIALS_ADDRESS:
+ SorobanAddressCredentials.encode(stream, encodedSorobanCredentials.address);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SorobanCredentials decode(XdrDataInputStream stream) throws IOException {
+ SorobanCredentials decodedSorobanCredentials = new SorobanCredentials();
+ SorobanCredentialsType discriminant = SorobanCredentialsType.decode(stream);
+ decodedSorobanCredentials.setDiscriminant(discriminant);
+ switch (decodedSorobanCredentials.getDiscriminant()) {
+ case SOROBAN_CREDENTIALS_SOURCE_ACCOUNT:
+ break;
+ case SOROBAN_CREDENTIALS_ADDRESS:
+ decodedSorobanCredentials.address = SorobanAddressCredentials.decode(stream);
+ break;
+ }
+ return decodedSorobanCredentials;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.address, this.type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SorobanCredentials)) {
+ return false;
+ }
+
+ SorobanCredentials other = (SorobanCredentials) object;
+ return Objects.equals(this.address, other.address) && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SorobanCredentials fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SorobanCredentials fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SorobanCredentialsType.java b/src/main/java/org/stellar/sdk/xdr/SorobanCredentialsType.java
new file mode 100644
index 000000000..80718d95d
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SorobanCredentialsType.java
@@ -0,0 +1,80 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum SorobanCredentialsType
+// {
+// SOROBAN_CREDENTIALS_SOURCE_ACCOUNT = 0,
+// SOROBAN_CREDENTIALS_ADDRESS = 1
+// };
+
+// ===========================================================================
+public enum SorobanCredentialsType implements XdrElement {
+ SOROBAN_CREDENTIALS_SOURCE_ACCOUNT(0),
+ SOROBAN_CREDENTIALS_ADDRESS(1),
+ ;
+ private int mValue;
+
+ SorobanCredentialsType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SorobanCredentialsType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SOROBAN_CREDENTIALS_SOURCE_ACCOUNT;
+ case 1:
+ return SOROBAN_CREDENTIALS_ADDRESS;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SorobanCredentialsType value)
+ throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SorobanCredentialsType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SorobanCredentialsType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SorobanResources.java b/src/main/java/org/stellar/sdk/xdr/SorobanResources.java
new file mode 100644
index 000000000..7197024d2
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SorobanResources.java
@@ -0,0 +1,171 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SorobanResources
+// {
+// // The ledger footprint of the transaction.
+// LedgerFootprint footprint;
+// // The maximum number of instructions this transaction can use
+// uint32 instructions;
+//
+// // The maximum number of bytes this transaction can read from ledger
+// uint32 readBytes;
+// // The maximum number of bytes this transaction can write to ledger
+// uint32 writeBytes;
+// };
+
+// ===========================================================================
+public class SorobanResources implements XdrElement {
+ public SorobanResources() {}
+
+ private LedgerFootprint footprint;
+
+ public LedgerFootprint getFootprint() {
+ return this.footprint;
+ }
+
+ public void setFootprint(LedgerFootprint value) {
+ this.footprint = value;
+ }
+
+ private Uint32 instructions;
+
+ public Uint32 getInstructions() {
+ return this.instructions;
+ }
+
+ public void setInstructions(Uint32 value) {
+ this.instructions = value;
+ }
+
+ private Uint32 readBytes;
+
+ public Uint32 getReadBytes() {
+ return this.readBytes;
+ }
+
+ public void setReadBytes(Uint32 value) {
+ this.readBytes = value;
+ }
+
+ private Uint32 writeBytes;
+
+ public Uint32 getWriteBytes() {
+ return this.writeBytes;
+ }
+
+ public void setWriteBytes(Uint32 value) {
+ this.writeBytes = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, SorobanResources encodedSorobanResources)
+ throws IOException {
+ LedgerFootprint.encode(stream, encodedSorobanResources.footprint);
+ Uint32.encode(stream, encodedSorobanResources.instructions);
+ Uint32.encode(stream, encodedSorobanResources.readBytes);
+ Uint32.encode(stream, encodedSorobanResources.writeBytes);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SorobanResources decode(XdrDataInputStream stream) throws IOException {
+ SorobanResources decodedSorobanResources = new SorobanResources();
+ decodedSorobanResources.footprint = LedgerFootprint.decode(stream);
+ decodedSorobanResources.instructions = Uint32.decode(stream);
+ decodedSorobanResources.readBytes = Uint32.decode(stream);
+ decodedSorobanResources.writeBytes = Uint32.decode(stream);
+ return decodedSorobanResources;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.footprint, this.instructions, this.readBytes, this.writeBytes);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SorobanResources)) {
+ return false;
+ }
+
+ SorobanResources other = (SorobanResources) object;
+ return Objects.equals(this.footprint, other.footprint)
+ && Objects.equals(this.instructions, other.instructions)
+ && Objects.equals(this.readBytes, other.readBytes)
+ && Objects.equals(this.writeBytes, other.writeBytes);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SorobanResources fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SorobanResources fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private LedgerFootprint footprint;
+ private Uint32 instructions;
+ private Uint32 readBytes;
+ private Uint32 writeBytes;
+
+ public Builder footprint(LedgerFootprint footprint) {
+ this.footprint = footprint;
+ return this;
+ }
+
+ public Builder instructions(Uint32 instructions) {
+ this.instructions = instructions;
+ return this;
+ }
+
+ public Builder readBytes(Uint32 readBytes) {
+ this.readBytes = readBytes;
+ return this;
+ }
+
+ public Builder writeBytes(Uint32 writeBytes) {
+ this.writeBytes = writeBytes;
+ return this;
+ }
+
+ public SorobanResources build() {
+ SorobanResources val = new SorobanResources();
+ val.setFootprint(this.footprint);
+ val.setInstructions(this.instructions);
+ val.setReadBytes(this.readBytes);
+ val.setWriteBytes(this.writeBytes);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SorobanTransactionData.java b/src/main/java/org/stellar/sdk/xdr/SorobanTransactionData.java
new file mode 100644
index 000000000..1885f4450
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SorobanTransactionData.java
@@ -0,0 +1,147 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SorobanTransactionData
+// {
+// ExtensionPoint ext;
+// SorobanResources resources;
+// // Portion of transaction `fee` allocated to refundable fees.
+// int64 refundableFee;
+// };
+
+// ===========================================================================
+public class SorobanTransactionData implements XdrElement {
+ public SorobanTransactionData() {}
+
+ private ExtensionPoint ext;
+
+ public ExtensionPoint getExt() {
+ return this.ext;
+ }
+
+ public void setExt(ExtensionPoint value) {
+ this.ext = value;
+ }
+
+ private SorobanResources resources;
+
+ public SorobanResources getResources() {
+ return this.resources;
+ }
+
+ public void setResources(SorobanResources value) {
+ this.resources = value;
+ }
+
+ private Int64 refundableFee;
+
+ public Int64 getRefundableFee() {
+ return this.refundableFee;
+ }
+
+ public void setRefundableFee(Int64 value) {
+ this.refundableFee = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SorobanTransactionData encodedSorobanTransactionData)
+ throws IOException {
+ ExtensionPoint.encode(stream, encodedSorobanTransactionData.ext);
+ SorobanResources.encode(stream, encodedSorobanTransactionData.resources);
+ Int64.encode(stream, encodedSorobanTransactionData.refundableFee);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SorobanTransactionData decode(XdrDataInputStream stream) throws IOException {
+ SorobanTransactionData decodedSorobanTransactionData = new SorobanTransactionData();
+ decodedSorobanTransactionData.ext = ExtensionPoint.decode(stream);
+ decodedSorobanTransactionData.resources = SorobanResources.decode(stream);
+ decodedSorobanTransactionData.refundableFee = Int64.decode(stream);
+ return decodedSorobanTransactionData;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.ext, this.resources, this.refundableFee);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SorobanTransactionData)) {
+ return false;
+ }
+
+ SorobanTransactionData other = (SorobanTransactionData) object;
+ return Objects.equals(this.ext, other.ext)
+ && Objects.equals(this.resources, other.resources)
+ && Objects.equals(this.refundableFee, other.refundableFee);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SorobanTransactionData fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SorobanTransactionData fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ExtensionPoint ext;
+ private SorobanResources resources;
+ private Int64 refundableFee;
+
+ public Builder ext(ExtensionPoint ext) {
+ this.ext = ext;
+ return this;
+ }
+
+ public Builder resources(SorobanResources resources) {
+ this.resources = resources;
+ return this;
+ }
+
+ public Builder refundableFee(Int64 refundableFee) {
+ this.refundableFee = refundableFee;
+ return this;
+ }
+
+ public SorobanTransactionData build() {
+ SorobanTransactionData val = new SorobanTransactionData();
+ val.setExt(this.ext);
+ val.setResources(this.resources);
+ val.setRefundableFee(this.refundableFee);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SorobanTransactionMeta.java b/src/main/java/org/stellar/sdk/xdr/SorobanTransactionMeta.java
new file mode 100644
index 000000000..5fea572eb
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SorobanTransactionMeta.java
@@ -0,0 +1,194 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct SorobanTransactionMeta
+// {
+// ExtensionPoint ext;
+//
+// ContractEvent events<>; // custom events populated by the
+// // contracts themselves.
+// SCVal returnValue; // return value of the host fn invocation
+//
+// // Diagnostics events that are not hashed.
+// // This will contain all contract and diagnostic events. Even ones
+// // that were emitted in a failed contract call.
+// DiagnosticEvent diagnosticEvents<>;
+// };
+
+// ===========================================================================
+public class SorobanTransactionMeta implements XdrElement {
+ public SorobanTransactionMeta() {}
+
+ private ExtensionPoint ext;
+
+ public ExtensionPoint getExt() {
+ return this.ext;
+ }
+
+ public void setExt(ExtensionPoint value) {
+ this.ext = value;
+ }
+
+ private ContractEvent[] events;
+
+ public ContractEvent[] getEvents() {
+ return this.events;
+ }
+
+ public void setEvents(ContractEvent[] value) {
+ this.events = value;
+ }
+
+ private SCVal returnValue;
+
+ public SCVal getReturnValue() {
+ return this.returnValue;
+ }
+
+ public void setReturnValue(SCVal value) {
+ this.returnValue = value;
+ }
+
+ private DiagnosticEvent[] diagnosticEvents;
+
+ public DiagnosticEvent[] getDiagnosticEvents() {
+ return this.diagnosticEvents;
+ }
+
+ public void setDiagnosticEvents(DiagnosticEvent[] value) {
+ this.diagnosticEvents = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, SorobanTransactionMeta encodedSorobanTransactionMeta)
+ throws IOException {
+ ExtensionPoint.encode(stream, encodedSorobanTransactionMeta.ext);
+ int eventssize = encodedSorobanTransactionMeta.getEvents().length;
+ stream.writeInt(eventssize);
+ for (int i = 0; i < eventssize; i++) {
+ ContractEvent.encode(stream, encodedSorobanTransactionMeta.events[i]);
+ }
+ SCVal.encode(stream, encodedSorobanTransactionMeta.returnValue);
+ int diagnosticEventssize = encodedSorobanTransactionMeta.getDiagnosticEvents().length;
+ stream.writeInt(diagnosticEventssize);
+ for (int i = 0; i < diagnosticEventssize; i++) {
+ DiagnosticEvent.encode(stream, encodedSorobanTransactionMeta.diagnosticEvents[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static SorobanTransactionMeta decode(XdrDataInputStream stream) throws IOException {
+ SorobanTransactionMeta decodedSorobanTransactionMeta = new SorobanTransactionMeta();
+ decodedSorobanTransactionMeta.ext = ExtensionPoint.decode(stream);
+ int eventssize = stream.readInt();
+ decodedSorobanTransactionMeta.events = new ContractEvent[eventssize];
+ for (int i = 0; i < eventssize; i++) {
+ decodedSorobanTransactionMeta.events[i] = ContractEvent.decode(stream);
+ }
+ decodedSorobanTransactionMeta.returnValue = SCVal.decode(stream);
+ int diagnosticEventssize = stream.readInt();
+ decodedSorobanTransactionMeta.diagnosticEvents = new DiagnosticEvent[diagnosticEventssize];
+ for (int i = 0; i < diagnosticEventssize; i++) {
+ decodedSorobanTransactionMeta.diagnosticEvents[i] = DiagnosticEvent.decode(stream);
+ }
+ return decodedSorobanTransactionMeta;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.ext,
+ Arrays.hashCode(this.events),
+ this.returnValue,
+ Arrays.hashCode(this.diagnosticEvents));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof SorobanTransactionMeta)) {
+ return false;
+ }
+
+ SorobanTransactionMeta other = (SorobanTransactionMeta) object;
+ return Objects.equals(this.ext, other.ext)
+ && Arrays.equals(this.events, other.events)
+ && Objects.equals(this.returnValue, other.returnValue)
+ && Arrays.equals(this.diagnosticEvents, other.diagnosticEvents);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SorobanTransactionMeta fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SorobanTransactionMeta fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ExtensionPoint ext;
+ private ContractEvent[] events;
+ private SCVal returnValue;
+ private DiagnosticEvent[] diagnosticEvents;
+
+ public Builder ext(ExtensionPoint ext) {
+ this.ext = ext;
+ return this;
+ }
+
+ public Builder events(ContractEvent[] events) {
+ this.events = events;
+ return this;
+ }
+
+ public Builder returnValue(SCVal returnValue) {
+ this.returnValue = returnValue;
+ return this;
+ }
+
+ public Builder diagnosticEvents(DiagnosticEvent[] diagnosticEvents) {
+ this.diagnosticEvents = diagnosticEvents;
+ return this;
+ }
+
+ public SorobanTransactionMeta build() {
+ SorobanTransactionMeta val = new SorobanTransactionMeta();
+ val.setExt(this.ext);
+ val.setEvents(this.events);
+ val.setReturnValue(this.returnValue);
+ val.setDiagnosticEvents(this.diagnosticEvents);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SponsorshipDescriptor.java b/src/main/java/org/stellar/sdk/xdr/SponsorshipDescriptor.java
index d64f8d171..a02fd20f4 100644
--- a/src/main/java/org/stellar/sdk/xdr/SponsorshipDescriptor.java
+++ b/src/main/java/org/stellar/sdk/xdr/SponsorshipDescriptor.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -54,7 +59,7 @@ public static SponsorshipDescriptor decode(XdrDataInputStream stream) throws IOE
@Override
public int hashCode() {
- return Objects.hashCode(this.SponsorshipDescriptor);
+ return Objects.hash(this.SponsorshipDescriptor);
}
@Override
@@ -64,6 +69,30 @@ public boolean equals(Object object) {
}
SponsorshipDescriptor other = (SponsorshipDescriptor) object;
- return Objects.equal(this.SponsorshipDescriptor, other.SponsorshipDescriptor);
+ return Objects.equals(this.SponsorshipDescriptor, other.SponsorshipDescriptor);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SponsorshipDescriptor fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SponsorshipDescriptor fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/StateExpirationSettings.java b/src/main/java/org/stellar/sdk/xdr/StateExpirationSettings.java
new file mode 100644
index 000000000..f9ac799c8
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/StateExpirationSettings.java
@@ -0,0 +1,290 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct StateExpirationSettings {
+// uint32 maxEntryExpiration;
+// uint32 minTempEntryExpiration;
+// uint32 minPersistentEntryExpiration;
+//
+// // rent_fee = wfee_rate_average / rent_rate_denominator_for_type
+// int64 persistentRentRateDenominator;
+// int64 tempRentRateDenominator;
+//
+// // max number of entries that emit expiration meta in a single ledger
+// uint32 maxEntriesToExpire;
+//
+// // Number of snapshots to use when calculating average BucketList size
+// uint32 bucketListSizeWindowSampleSize;
+//
+// // Maximum number of bytes that we scan for eviction per ledger
+// uint64 evictionScanSize;
+//
+// // Lowest BucketList level to be scanned to evict entries
+// uint32 startingEvictionScanLevel;
+// };
+
+// ===========================================================================
+public class StateExpirationSettings implements XdrElement {
+ public StateExpirationSettings() {}
+
+ private Uint32 maxEntryExpiration;
+
+ public Uint32 getMaxEntryExpiration() {
+ return this.maxEntryExpiration;
+ }
+
+ public void setMaxEntryExpiration(Uint32 value) {
+ this.maxEntryExpiration = value;
+ }
+
+ private Uint32 minTempEntryExpiration;
+
+ public Uint32 getMinTempEntryExpiration() {
+ return this.minTempEntryExpiration;
+ }
+
+ public void setMinTempEntryExpiration(Uint32 value) {
+ this.minTempEntryExpiration = value;
+ }
+
+ private Uint32 minPersistentEntryExpiration;
+
+ public Uint32 getMinPersistentEntryExpiration() {
+ return this.minPersistentEntryExpiration;
+ }
+
+ public void setMinPersistentEntryExpiration(Uint32 value) {
+ this.minPersistentEntryExpiration = value;
+ }
+
+ private Int64 persistentRentRateDenominator;
+
+ public Int64 getPersistentRentRateDenominator() {
+ return this.persistentRentRateDenominator;
+ }
+
+ public void setPersistentRentRateDenominator(Int64 value) {
+ this.persistentRentRateDenominator = value;
+ }
+
+ private Int64 tempRentRateDenominator;
+
+ public Int64 getTempRentRateDenominator() {
+ return this.tempRentRateDenominator;
+ }
+
+ public void setTempRentRateDenominator(Int64 value) {
+ this.tempRentRateDenominator = value;
+ }
+
+ private Uint32 maxEntriesToExpire;
+
+ public Uint32 getMaxEntriesToExpire() {
+ return this.maxEntriesToExpire;
+ }
+
+ public void setMaxEntriesToExpire(Uint32 value) {
+ this.maxEntriesToExpire = value;
+ }
+
+ private Uint32 bucketListSizeWindowSampleSize;
+
+ public Uint32 getBucketListSizeWindowSampleSize() {
+ return this.bucketListSizeWindowSampleSize;
+ }
+
+ public void setBucketListSizeWindowSampleSize(Uint32 value) {
+ this.bucketListSizeWindowSampleSize = value;
+ }
+
+ private Uint64 evictionScanSize;
+
+ public Uint64 getEvictionScanSize() {
+ return this.evictionScanSize;
+ }
+
+ public void setEvictionScanSize(Uint64 value) {
+ this.evictionScanSize = value;
+ }
+
+ private Uint32 startingEvictionScanLevel;
+
+ public Uint32 getStartingEvictionScanLevel() {
+ return this.startingEvictionScanLevel;
+ }
+
+ public void setStartingEvictionScanLevel(Uint32 value) {
+ this.startingEvictionScanLevel = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, StateExpirationSettings encodedStateExpirationSettings)
+ throws IOException {
+ Uint32.encode(stream, encodedStateExpirationSettings.maxEntryExpiration);
+ Uint32.encode(stream, encodedStateExpirationSettings.minTempEntryExpiration);
+ Uint32.encode(stream, encodedStateExpirationSettings.minPersistentEntryExpiration);
+ Int64.encode(stream, encodedStateExpirationSettings.persistentRentRateDenominator);
+ Int64.encode(stream, encodedStateExpirationSettings.tempRentRateDenominator);
+ Uint32.encode(stream, encodedStateExpirationSettings.maxEntriesToExpire);
+ Uint32.encode(stream, encodedStateExpirationSettings.bucketListSizeWindowSampleSize);
+ Uint64.encode(stream, encodedStateExpirationSettings.evictionScanSize);
+ Uint32.encode(stream, encodedStateExpirationSettings.startingEvictionScanLevel);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static StateExpirationSettings decode(XdrDataInputStream stream) throws IOException {
+ StateExpirationSettings decodedStateExpirationSettings = new StateExpirationSettings();
+ decodedStateExpirationSettings.maxEntryExpiration = Uint32.decode(stream);
+ decodedStateExpirationSettings.minTempEntryExpiration = Uint32.decode(stream);
+ decodedStateExpirationSettings.minPersistentEntryExpiration = Uint32.decode(stream);
+ decodedStateExpirationSettings.persistentRentRateDenominator = Int64.decode(stream);
+ decodedStateExpirationSettings.tempRentRateDenominator = Int64.decode(stream);
+ decodedStateExpirationSettings.maxEntriesToExpire = Uint32.decode(stream);
+ decodedStateExpirationSettings.bucketListSizeWindowSampleSize = Uint32.decode(stream);
+ decodedStateExpirationSettings.evictionScanSize = Uint64.decode(stream);
+ decodedStateExpirationSettings.startingEvictionScanLevel = Uint32.decode(stream);
+ return decodedStateExpirationSettings;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.maxEntryExpiration,
+ this.minTempEntryExpiration,
+ this.minPersistentEntryExpiration,
+ this.persistentRentRateDenominator,
+ this.tempRentRateDenominator,
+ this.maxEntriesToExpire,
+ this.bucketListSizeWindowSampleSize,
+ this.evictionScanSize,
+ this.startingEvictionScanLevel);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof StateExpirationSettings)) {
+ return false;
+ }
+
+ StateExpirationSettings other = (StateExpirationSettings) object;
+ return Objects.equals(this.maxEntryExpiration, other.maxEntryExpiration)
+ && Objects.equals(this.minTempEntryExpiration, other.minTempEntryExpiration)
+ && Objects.equals(this.minPersistentEntryExpiration, other.minPersistentEntryExpiration)
+ && Objects.equals(this.persistentRentRateDenominator, other.persistentRentRateDenominator)
+ && Objects.equals(this.tempRentRateDenominator, other.tempRentRateDenominator)
+ && Objects.equals(this.maxEntriesToExpire, other.maxEntriesToExpire)
+ && Objects.equals(this.bucketListSizeWindowSampleSize, other.bucketListSizeWindowSampleSize)
+ && Objects.equals(this.evictionScanSize, other.evictionScanSize)
+ && Objects.equals(this.startingEvictionScanLevel, other.startingEvictionScanLevel);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static StateExpirationSettings fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static StateExpirationSettings fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Uint32 maxEntryExpiration;
+ private Uint32 minTempEntryExpiration;
+ private Uint32 minPersistentEntryExpiration;
+ private Int64 persistentRentRateDenominator;
+ private Int64 tempRentRateDenominator;
+ private Uint32 maxEntriesToExpire;
+ private Uint32 bucketListSizeWindowSampleSize;
+ private Uint64 evictionScanSize;
+ private Uint32 startingEvictionScanLevel;
+
+ public Builder maxEntryExpiration(Uint32 maxEntryExpiration) {
+ this.maxEntryExpiration = maxEntryExpiration;
+ return this;
+ }
+
+ public Builder minTempEntryExpiration(Uint32 minTempEntryExpiration) {
+ this.minTempEntryExpiration = minTempEntryExpiration;
+ return this;
+ }
+
+ public Builder minPersistentEntryExpiration(Uint32 minPersistentEntryExpiration) {
+ this.minPersistentEntryExpiration = minPersistentEntryExpiration;
+ return this;
+ }
+
+ public Builder persistentRentRateDenominator(Int64 persistentRentRateDenominator) {
+ this.persistentRentRateDenominator = persistentRentRateDenominator;
+ return this;
+ }
+
+ public Builder tempRentRateDenominator(Int64 tempRentRateDenominator) {
+ this.tempRentRateDenominator = tempRentRateDenominator;
+ return this;
+ }
+
+ public Builder maxEntriesToExpire(Uint32 maxEntriesToExpire) {
+ this.maxEntriesToExpire = maxEntriesToExpire;
+ return this;
+ }
+
+ public Builder bucketListSizeWindowSampleSize(Uint32 bucketListSizeWindowSampleSize) {
+ this.bucketListSizeWindowSampleSize = bucketListSizeWindowSampleSize;
+ return this;
+ }
+
+ public Builder evictionScanSize(Uint64 evictionScanSize) {
+ this.evictionScanSize = evictionScanSize;
+ return this;
+ }
+
+ public Builder startingEvictionScanLevel(Uint32 startingEvictionScanLevel) {
+ this.startingEvictionScanLevel = startingEvictionScanLevel;
+ return this;
+ }
+
+ public StateExpirationSettings build() {
+ StateExpirationSettings val = new StateExpirationSettings();
+ val.setMaxEntryExpiration(this.maxEntryExpiration);
+ val.setMinTempEntryExpiration(this.minTempEntryExpiration);
+ val.setMinPersistentEntryExpiration(this.minPersistentEntryExpiration);
+ val.setPersistentRentRateDenominator(this.persistentRentRateDenominator);
+ val.setTempRentRateDenominator(this.tempRentRateDenominator);
+ val.setMaxEntriesToExpire(this.maxEntriesToExpire);
+ val.setBucketListSizeWindowSampleSize(this.bucketListSizeWindowSampleSize);
+ val.setEvictionScanSize(this.evictionScanSize);
+ val.setStartingEvictionScanLevel(this.startingEvictionScanLevel);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/StellarMessage.java b/src/main/java/org/stellar/sdk/xdr/StellarMessage.java
index 96ee925ce..0ab193c4b 100644
--- a/src/main/java/org/stellar/sdk/xdr/StellarMessage.java
+++ b/src/main/java/org/stellar/sdk/xdr/StellarMessage.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -28,6 +33,8 @@
// uint256 txSetHash;
// case TX_SET:
// TransactionSet txSet;
+// case GENERALIZED_TX_SET:
+// GeneralizedTransactionSet generalizedTxSet;
//
// case TRANSACTION:
// TransactionEnvelope transaction;
@@ -49,6 +56,13 @@
// uint32 getSCPLedgerSeq; // ledger seq requested ; if 0, requests the latest
// case SEND_MORE:
// SendMore sendMoreMessage;
+// case SEND_MORE_EXTENDED:
+// SendMoreExtended sendMoreExtendedMessage;
+// // Pull mode
+// case FLOOD_ADVERT:
+// FloodAdvert floodAdvert;
+// case FLOOD_DEMAND:
+// FloodDemand floodDemand;
// };
// ===========================================================================
@@ -135,6 +149,16 @@ public void setTxSet(TransactionSet value) {
this.txSet = value;
}
+ private GeneralizedTransactionSet generalizedTxSet;
+
+ public GeneralizedTransactionSet getGeneralizedTxSet() {
+ return this.generalizedTxSet;
+ }
+
+ public void setGeneralizedTxSet(GeneralizedTransactionSet value) {
+ this.generalizedTxSet = value;
+ }
+
private TransactionEnvelope transaction;
public TransactionEnvelope getTransaction() {
@@ -215,6 +239,36 @@ public void setSendMoreMessage(SendMore value) {
this.sendMoreMessage = value;
}
+ private SendMoreExtended sendMoreExtendedMessage;
+
+ public SendMoreExtended getSendMoreExtendedMessage() {
+ return this.sendMoreExtendedMessage;
+ }
+
+ public void setSendMoreExtendedMessage(SendMoreExtended value) {
+ this.sendMoreExtendedMessage = value;
+ }
+
+ private FloodAdvert floodAdvert;
+
+ public FloodAdvert getFloodAdvert() {
+ return this.floodAdvert;
+ }
+
+ public void setFloodAdvert(FloodAdvert value) {
+ this.floodAdvert = value;
+ }
+
+ private FloodDemand floodDemand;
+
+ public FloodDemand getFloodDemand() {
+ return this.floodDemand;
+ }
+
+ public void setFloodDemand(FloodDemand value) {
+ this.floodDemand = value;
+ }
+
public static final class Builder {
private MessageType discriminant;
private Error error;
@@ -224,6 +278,7 @@ public static final class Builder {
private PeerAddress[] peers;
private Uint256 txSetHash;
private TransactionSet txSet;
+ private GeneralizedTransactionSet generalizedTxSet;
private TransactionEnvelope transaction;
private SignedSurveyRequestMessage signedSurveyRequestMessage;
private SignedSurveyResponseMessage signedSurveyResponseMessage;
@@ -232,6 +287,9 @@ public static final class Builder {
private SCPEnvelope envelope;
private Uint32 getSCPLedgerSeq;
private SendMore sendMoreMessage;
+ private SendMoreExtended sendMoreExtendedMessage;
+ private FloodAdvert floodAdvert;
+ private FloodDemand floodDemand;
public Builder discriminant(MessageType discriminant) {
this.discriminant = discriminant;
@@ -273,6 +331,11 @@ public Builder txSet(TransactionSet txSet) {
return this;
}
+ public Builder generalizedTxSet(GeneralizedTransactionSet generalizedTxSet) {
+ this.generalizedTxSet = generalizedTxSet;
+ return this;
+ }
+
public Builder transaction(TransactionEnvelope transaction) {
this.transaction = transaction;
return this;
@@ -315,24 +378,43 @@ public Builder sendMoreMessage(SendMore sendMoreMessage) {
return this;
}
+ public Builder sendMoreExtendedMessage(SendMoreExtended sendMoreExtendedMessage) {
+ this.sendMoreExtendedMessage = sendMoreExtendedMessage;
+ return this;
+ }
+
+ public Builder floodAdvert(FloodAdvert floodAdvert) {
+ this.floodAdvert = floodAdvert;
+ return this;
+ }
+
+ public Builder floodDemand(FloodDemand floodDemand) {
+ this.floodDemand = floodDemand;
+ return this;
+ }
+
public StellarMessage build() {
StellarMessage val = new StellarMessage();
val.setDiscriminant(discriminant);
- val.setError(error);
- val.setHello(hello);
- val.setAuth(auth);
- val.setDontHave(dontHave);
- val.setPeers(peers);
- val.setTxSetHash(txSetHash);
- val.setTxSet(txSet);
- val.setTransaction(transaction);
- val.setSignedSurveyRequestMessage(signedSurveyRequestMessage);
- val.setSignedSurveyResponseMessage(signedSurveyResponseMessage);
- val.setQSetHash(qSetHash);
- val.setQSet(qSet);
- val.setEnvelope(envelope);
- val.setGetSCPLedgerSeq(getSCPLedgerSeq);
- val.setSendMoreMessage(sendMoreMessage);
+ val.setError(this.error);
+ val.setHello(this.hello);
+ val.setAuth(this.auth);
+ val.setDontHave(this.dontHave);
+ val.setPeers(this.peers);
+ val.setTxSetHash(this.txSetHash);
+ val.setTxSet(this.txSet);
+ val.setGeneralizedTxSet(this.generalizedTxSet);
+ val.setTransaction(this.transaction);
+ val.setSignedSurveyRequestMessage(this.signedSurveyRequestMessage);
+ val.setSignedSurveyResponseMessage(this.signedSurveyResponseMessage);
+ val.setQSetHash(this.qSetHash);
+ val.setQSet(this.qSet);
+ val.setEnvelope(this.envelope);
+ val.setGetSCPLedgerSeq(this.getSCPLedgerSeq);
+ val.setSendMoreMessage(this.sendMoreMessage);
+ val.setSendMoreExtendedMessage(this.sendMoreExtendedMessage);
+ val.setFloodAdvert(this.floodAdvert);
+ val.setFloodDemand(this.floodDemand);
return val;
}
}
@@ -370,6 +452,9 @@ public static void encode(XdrDataOutputStream stream, StellarMessage encodedStel
case TX_SET:
TransactionSet.encode(stream, encodedStellarMessage.txSet);
break;
+ case GENERALIZED_TX_SET:
+ GeneralizedTransactionSet.encode(stream, encodedStellarMessage.generalizedTxSet);
+ break;
case TRANSACTION:
TransactionEnvelope.encode(stream, encodedStellarMessage.transaction);
break;
@@ -395,6 +480,15 @@ public static void encode(XdrDataOutputStream stream, StellarMessage encodedStel
case SEND_MORE:
SendMore.encode(stream, encodedStellarMessage.sendMoreMessage);
break;
+ case SEND_MORE_EXTENDED:
+ SendMoreExtended.encode(stream, encodedStellarMessage.sendMoreExtendedMessage);
+ break;
+ case FLOOD_ADVERT:
+ FloodAdvert.encode(stream, encodedStellarMessage.floodAdvert);
+ break;
+ case FLOOD_DEMAND:
+ FloodDemand.encode(stream, encodedStellarMessage.floodDemand);
+ break;
}
}
@@ -434,6 +528,9 @@ public static StellarMessage decode(XdrDataInputStream stream) throws IOExceptio
case TX_SET:
decodedStellarMessage.txSet = TransactionSet.decode(stream);
break;
+ case GENERALIZED_TX_SET:
+ decodedStellarMessage.generalizedTxSet = GeneralizedTransactionSet.decode(stream);
+ break;
case TRANSACTION:
decodedStellarMessage.transaction = TransactionEnvelope.decode(stream);
break;
@@ -460,13 +557,22 @@ public static StellarMessage decode(XdrDataInputStream stream) throws IOExceptio
case SEND_MORE:
decodedStellarMessage.sendMoreMessage = SendMore.decode(stream);
break;
+ case SEND_MORE_EXTENDED:
+ decodedStellarMessage.sendMoreExtendedMessage = SendMoreExtended.decode(stream);
+ break;
+ case FLOOD_ADVERT:
+ decodedStellarMessage.floodAdvert = FloodAdvert.decode(stream);
+ break;
+ case FLOOD_DEMAND:
+ decodedStellarMessage.floodDemand = FloodDemand.decode(stream);
+ break;
}
return decodedStellarMessage;
}
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.error,
this.hello,
this.auth,
@@ -474,6 +580,7 @@ public int hashCode() {
Arrays.hashCode(this.peers),
this.txSetHash,
this.txSet,
+ this.generalizedTxSet,
this.transaction,
this.signedSurveyRequestMessage,
this.signedSurveyResponseMessage,
@@ -482,6 +589,9 @@ public int hashCode() {
this.envelope,
this.getSCPLedgerSeq,
this.sendMoreMessage,
+ this.sendMoreExtendedMessage,
+ this.floodAdvert,
+ this.floodDemand,
this.type);
}
@@ -492,21 +602,49 @@ public boolean equals(Object object) {
}
StellarMessage other = (StellarMessage) object;
- return Objects.equal(this.error, other.error)
- && Objects.equal(this.hello, other.hello)
- && Objects.equal(this.auth, other.auth)
- && Objects.equal(this.dontHave, other.dontHave)
+ return Objects.equals(this.error, other.error)
+ && Objects.equals(this.hello, other.hello)
+ && Objects.equals(this.auth, other.auth)
+ && Objects.equals(this.dontHave, other.dontHave)
&& Arrays.equals(this.peers, other.peers)
- && Objects.equal(this.txSetHash, other.txSetHash)
- && Objects.equal(this.txSet, other.txSet)
- && Objects.equal(this.transaction, other.transaction)
- && Objects.equal(this.signedSurveyRequestMessage, other.signedSurveyRequestMessage)
- && Objects.equal(this.signedSurveyResponseMessage, other.signedSurveyResponseMessage)
- && Objects.equal(this.qSetHash, other.qSetHash)
- && Objects.equal(this.qSet, other.qSet)
- && Objects.equal(this.envelope, other.envelope)
- && Objects.equal(this.getSCPLedgerSeq, other.getSCPLedgerSeq)
- && Objects.equal(this.sendMoreMessage, other.sendMoreMessage)
- && Objects.equal(this.type, other.type);
+ && Objects.equals(this.txSetHash, other.txSetHash)
+ && Objects.equals(this.txSet, other.txSet)
+ && Objects.equals(this.generalizedTxSet, other.generalizedTxSet)
+ && Objects.equals(this.transaction, other.transaction)
+ && Objects.equals(this.signedSurveyRequestMessage, other.signedSurveyRequestMessage)
+ && Objects.equals(this.signedSurveyResponseMessage, other.signedSurveyResponseMessage)
+ && Objects.equals(this.qSetHash, other.qSetHash)
+ && Objects.equals(this.qSet, other.qSet)
+ && Objects.equals(this.envelope, other.envelope)
+ && Objects.equals(this.getSCPLedgerSeq, other.getSCPLedgerSeq)
+ && Objects.equals(this.sendMoreMessage, other.sendMoreMessage)
+ && Objects.equals(this.sendMoreExtendedMessage, other.sendMoreExtendedMessage)
+ && Objects.equals(this.floodAdvert, other.floodAdvert)
+ && Objects.equals(this.floodDemand, other.floodDemand)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static StellarMessage fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static StellarMessage fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/StellarValue.java b/src/main/java/org/stellar/sdk/xdr/StellarValue.java
index 77a4fac62..3aa932c61 100644
--- a/src/main/java/org/stellar/sdk/xdr/StellarValue.java
+++ b/src/main/java/org/stellar/sdk/xdr/StellarValue.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -107,8 +112,7 @@ public static StellarValue decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(
- this.txSetHash, this.closeTime, Arrays.hashCode(this.upgrades), this.ext);
+ return Objects.hash(this.txSetHash, this.closeTime, Arrays.hashCode(this.upgrades), this.ext);
}
@Override
@@ -118,10 +122,34 @@ public boolean equals(Object object) {
}
StellarValue other = (StellarValue) object;
- return Objects.equal(this.txSetHash, other.txSetHash)
- && Objects.equal(this.closeTime, other.closeTime)
+ return Objects.equals(this.txSetHash, other.txSetHash)
+ && Objects.equals(this.closeTime, other.closeTime)
&& Arrays.equals(this.upgrades, other.upgrades)
- && Objects.equal(this.ext, other.ext);
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static StellarValue fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static StellarValue fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -152,15 +180,15 @@ public Builder ext(StellarValueExt ext) {
public StellarValue build() {
StellarValue val = new StellarValue();
- val.setTxSetHash(txSetHash);
- val.setCloseTime(closeTime);
- val.setUpgrades(upgrades);
- val.setExt(ext);
+ val.setTxSetHash(this.txSetHash);
+ val.setCloseTime(this.closeTime);
+ val.setUpgrades(this.upgrades);
+ val.setExt(this.ext);
return val;
}
}
- public static class StellarValueExt {
+ public static class StellarValueExt implements XdrElement {
public StellarValueExt() {}
StellarValueType v;
@@ -200,7 +228,7 @@ public Builder lcValueSignature(LedgerCloseValueSignature lcValueSignature) {
public StellarValueExt build() {
StellarValueExt val = new StellarValueExt();
val.setDiscriminant(discriminant);
- val.setLcValueSignature(lcValueSignature);
+ val.setLcValueSignature(this.lcValueSignature);
return val;
}
}
@@ -239,7 +267,7 @@ public static StellarValueExt decode(XdrDataInputStream stream) throws IOExcepti
@Override
public int hashCode() {
- return Objects.hashCode(this.lcValueSignature, this.v);
+ return Objects.hash(this.lcValueSignature, this.v);
}
@Override
@@ -249,8 +277,32 @@ public boolean equals(Object object) {
}
StellarValueExt other = (StellarValueExt) object;
- return Objects.equal(this.lcValueSignature, other.lcValueSignature)
- && Objects.equal(this.v, other.v);
+ return Objects.equals(this.lcValueSignature, other.lcValueSignature)
+ && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static StellarValueExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static StellarValueExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/StellarValueType.java b/src/main/java/org/stellar/sdk/xdr/StellarValueType.java
index 9d8caa640..8af9f42a7 100644
--- a/src/main/java/org/stellar/sdk/xdr/StellarValueType.java
+++ b/src/main/java/org/stellar/sdk/xdr/StellarValueType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -47,4 +52,28 @@ public static void encode(XdrDataOutputStream stream, StellarValueType value) th
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static StellarValueType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static StellarValueType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/StoredTransactionSet.java b/src/main/java/org/stellar/sdk/xdr/StoredTransactionSet.java
new file mode 100644
index 000000000..ae0839212
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/StoredTransactionSet.java
@@ -0,0 +1,162 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union StoredTransactionSet switch (int v)
+// {
+// case 0:
+// TransactionSet txSet;
+// case 1:
+// GeneralizedTransactionSet generalizedTxSet;
+// };
+
+// ===========================================================================
+public class StoredTransactionSet implements XdrElement {
+ public StoredTransactionSet() {}
+
+ Integer v;
+
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+
+ private TransactionSet txSet;
+
+ public TransactionSet getTxSet() {
+ return this.txSet;
+ }
+
+ public void setTxSet(TransactionSet value) {
+ this.txSet = value;
+ }
+
+ private GeneralizedTransactionSet generalizedTxSet;
+
+ public GeneralizedTransactionSet getGeneralizedTxSet() {
+ return this.generalizedTxSet;
+ }
+
+ public void setGeneralizedTxSet(GeneralizedTransactionSet value) {
+ this.generalizedTxSet = value;
+ }
+
+ public static final class Builder {
+ private Integer discriminant;
+ private TransactionSet txSet;
+ private GeneralizedTransactionSet generalizedTxSet;
+
+ public Builder discriminant(Integer discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder txSet(TransactionSet txSet) {
+ this.txSet = txSet;
+ return this;
+ }
+
+ public Builder generalizedTxSet(GeneralizedTransactionSet generalizedTxSet) {
+ this.generalizedTxSet = generalizedTxSet;
+ return this;
+ }
+
+ public StoredTransactionSet build() {
+ StoredTransactionSet val = new StoredTransactionSet();
+ val.setDiscriminant(discriminant);
+ val.setTxSet(this.txSet);
+ val.setGeneralizedTxSet(this.generalizedTxSet);
+ return val;
+ }
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, StoredTransactionSet encodedStoredTransactionSet)
+ throws IOException {
+ // Xdrgen::AST::Typespecs::Int
+ // Integer
+ stream.writeInt(encodedStoredTransactionSet.getDiscriminant().intValue());
+ switch (encodedStoredTransactionSet.getDiscriminant()) {
+ case 0:
+ TransactionSet.encode(stream, encodedStoredTransactionSet.txSet);
+ break;
+ case 1:
+ GeneralizedTransactionSet.encode(stream, encodedStoredTransactionSet.generalizedTxSet);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static StoredTransactionSet decode(XdrDataInputStream stream) throws IOException {
+ StoredTransactionSet decodedStoredTransactionSet = new StoredTransactionSet();
+ Integer discriminant = stream.readInt();
+ decodedStoredTransactionSet.setDiscriminant(discriminant);
+ switch (decodedStoredTransactionSet.getDiscriminant()) {
+ case 0:
+ decodedStoredTransactionSet.txSet = TransactionSet.decode(stream);
+ break;
+ case 1:
+ decodedStoredTransactionSet.generalizedTxSet = GeneralizedTransactionSet.decode(stream);
+ break;
+ }
+ return decodedStoredTransactionSet;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.txSet, this.generalizedTxSet, this.v);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof StoredTransactionSet)) {
+ return false;
+ }
+
+ StoredTransactionSet other = (StoredTransactionSet) object;
+ return Objects.equals(this.txSet, other.txSet)
+ && Objects.equals(this.generalizedTxSet, other.generalizedTxSet)
+ && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static StoredTransactionSet fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static StoredTransactionSet fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/String32.java b/src/main/java/org/stellar/sdk/xdr/String32.java
index 3893aa20d..21182a0b8 100644
--- a/src/main/java/org/stellar/sdk/xdr/String32.java
+++ b/src/main/java/org/stellar/sdk/xdr/String32.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -45,7 +50,7 @@ public static String32 decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.string32);
+ return Objects.hash(this.string32);
}
@Override
@@ -55,6 +60,30 @@ public boolean equals(Object object) {
}
String32 other = (String32) object;
- return Objects.equal(this.string32, other.string32);
+ return Objects.equals(this.string32, other.string32);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static String32 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static String32 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/String64.java b/src/main/java/org/stellar/sdk/xdr/String64.java
index 8d060d124..9fc11681a 100644
--- a/src/main/java/org/stellar/sdk/xdr/String64.java
+++ b/src/main/java/org/stellar/sdk/xdr/String64.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -45,7 +50,7 @@ public static String64 decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.string64);
+ return Objects.hash(this.string64);
}
@Override
@@ -55,6 +60,30 @@ public boolean equals(Object object) {
}
String64 other = (String64) object;
- return Objects.equal(this.string64, other.string64);
+ return Objects.equals(this.string64, other.string64);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static String64 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static String64 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SurveyMessageCommandType.java b/src/main/java/org/stellar/sdk/xdr/SurveyMessageCommandType.java
index f8772f675..0c2d57183 100644
--- a/src/main/java/org/stellar/sdk/xdr/SurveyMessageCommandType.java
+++ b/src/main/java/org/stellar/sdk/xdr/SurveyMessageCommandType.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -44,4 +49,28 @@ public static void encode(XdrDataOutputStream stream, SurveyMessageCommandType v
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SurveyMessageCommandType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SurveyMessageCommandType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SurveyMessageResponseType.java b/src/main/java/org/stellar/sdk/xdr/SurveyMessageResponseType.java
new file mode 100644
index 000000000..95b33dc5e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SurveyMessageResponseType.java
@@ -0,0 +1,80 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum SurveyMessageResponseType
+// {
+// SURVEY_TOPOLOGY_RESPONSE_V0 = 0,
+// SURVEY_TOPOLOGY_RESPONSE_V1 = 1
+// };
+
+// ===========================================================================
+public enum SurveyMessageResponseType implements XdrElement {
+ SURVEY_TOPOLOGY_RESPONSE_V0(0),
+ SURVEY_TOPOLOGY_RESPONSE_V1(1),
+ ;
+ private int mValue;
+
+ SurveyMessageResponseType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static SurveyMessageResponseType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return SURVEY_TOPOLOGY_RESPONSE_V0;
+ case 1:
+ return SURVEY_TOPOLOGY_RESPONSE_V1;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, SurveyMessageResponseType value)
+ throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SurveyMessageResponseType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SurveyMessageResponseType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SurveyRequestMessage.java b/src/main/java/org/stellar/sdk/xdr/SurveyRequestMessage.java
index b9c8e6d58..a4172172b 100644
--- a/src/main/java/org/stellar/sdk/xdr/SurveyRequestMessage.java
+++ b/src/main/java/org/stellar/sdk/xdr/SurveyRequestMessage.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -97,7 +102,7 @@ public static SurveyRequestMessage decode(XdrDataInputStream stream) throws IOEx
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.surveyorPeerID,
this.surveyedPeerID,
this.ledgerNum,
@@ -112,11 +117,35 @@ public boolean equals(Object object) {
}
SurveyRequestMessage other = (SurveyRequestMessage) object;
- return Objects.equal(this.surveyorPeerID, other.surveyorPeerID)
- && Objects.equal(this.surveyedPeerID, other.surveyedPeerID)
- && Objects.equal(this.ledgerNum, other.ledgerNum)
- && Objects.equal(this.encryptionKey, other.encryptionKey)
- && Objects.equal(this.commandType, other.commandType);
+ return Objects.equals(this.surveyorPeerID, other.surveyorPeerID)
+ && Objects.equals(this.surveyedPeerID, other.surveyedPeerID)
+ && Objects.equals(this.ledgerNum, other.ledgerNum)
+ && Objects.equals(this.encryptionKey, other.encryptionKey)
+ && Objects.equals(this.commandType, other.commandType);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SurveyRequestMessage fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SurveyRequestMessage fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -153,11 +182,11 @@ public Builder commandType(SurveyMessageCommandType commandType) {
public SurveyRequestMessage build() {
SurveyRequestMessage val = new SurveyRequestMessage();
- val.setSurveyorPeerID(surveyorPeerID);
- val.setSurveyedPeerID(surveyedPeerID);
- val.setLedgerNum(ledgerNum);
- val.setEncryptionKey(encryptionKey);
- val.setCommandType(commandType);
+ val.setSurveyorPeerID(this.surveyorPeerID);
+ val.setSurveyedPeerID(this.surveyedPeerID);
+ val.setLedgerNum(this.ledgerNum);
+ val.setEncryptionKey(this.encryptionKey);
+ val.setCommandType(this.commandType);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SurveyResponseBody.java b/src/main/java/org/stellar/sdk/xdr/SurveyResponseBody.java
index d4d765764..1f5217d97 100644
--- a/src/main/java/org/stellar/sdk/xdr/SurveyResponseBody.java
+++ b/src/main/java/org/stellar/sdk/xdr/SurveyResponseBody.java
@@ -3,59 +3,83 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
-// union SurveyResponseBody switch (SurveyMessageCommandType type)
+// union SurveyResponseBody switch (SurveyMessageResponseType type)
// {
-// case SURVEY_TOPOLOGY:
-// TopologyResponseBody topologyResponseBody;
+// case SURVEY_TOPOLOGY_RESPONSE_V0:
+// TopologyResponseBodyV0 topologyResponseBodyV0;
+// case SURVEY_TOPOLOGY_RESPONSE_V1:
+// TopologyResponseBodyV1 topologyResponseBodyV1;
// };
// ===========================================================================
public class SurveyResponseBody implements XdrElement {
public SurveyResponseBody() {}
- SurveyMessageCommandType type;
+ SurveyMessageResponseType type;
- public SurveyMessageCommandType getDiscriminant() {
+ public SurveyMessageResponseType getDiscriminant() {
return this.type;
}
- public void setDiscriminant(SurveyMessageCommandType value) {
+ public void setDiscriminant(SurveyMessageResponseType value) {
this.type = value;
}
- private TopologyResponseBody topologyResponseBody;
+ private TopologyResponseBodyV0 topologyResponseBodyV0;
+
+ public TopologyResponseBodyV0 getTopologyResponseBodyV0() {
+ return this.topologyResponseBodyV0;
+ }
+
+ public void setTopologyResponseBodyV0(TopologyResponseBodyV0 value) {
+ this.topologyResponseBodyV0 = value;
+ }
+
+ private TopologyResponseBodyV1 topologyResponseBodyV1;
- public TopologyResponseBody getTopologyResponseBody() {
- return this.topologyResponseBody;
+ public TopologyResponseBodyV1 getTopologyResponseBodyV1() {
+ return this.topologyResponseBodyV1;
}
- public void setTopologyResponseBody(TopologyResponseBody value) {
- this.topologyResponseBody = value;
+ public void setTopologyResponseBodyV1(TopologyResponseBodyV1 value) {
+ this.topologyResponseBodyV1 = value;
}
public static final class Builder {
- private SurveyMessageCommandType discriminant;
- private TopologyResponseBody topologyResponseBody;
+ private SurveyMessageResponseType discriminant;
+ private TopologyResponseBodyV0 topologyResponseBodyV0;
+ private TopologyResponseBodyV1 topologyResponseBodyV1;
- public Builder discriminant(SurveyMessageCommandType discriminant) {
+ public Builder discriminant(SurveyMessageResponseType discriminant) {
this.discriminant = discriminant;
return this;
}
- public Builder topologyResponseBody(TopologyResponseBody topologyResponseBody) {
- this.topologyResponseBody = topologyResponseBody;
+ public Builder topologyResponseBodyV0(TopologyResponseBodyV0 topologyResponseBodyV0) {
+ this.topologyResponseBodyV0 = topologyResponseBodyV0;
+ return this;
+ }
+
+ public Builder topologyResponseBodyV1(TopologyResponseBodyV1 topologyResponseBodyV1) {
+ this.topologyResponseBodyV1 = topologyResponseBodyV1;
return this;
}
public SurveyResponseBody build() {
SurveyResponseBody val = new SurveyResponseBody();
val.setDiscriminant(discriminant);
- val.setTopologyResponseBody(topologyResponseBody);
+ val.setTopologyResponseBodyV0(this.topologyResponseBodyV0);
+ val.setTopologyResponseBodyV1(this.topologyResponseBodyV1);
return val;
}
}
@@ -63,11 +87,14 @@ public SurveyResponseBody build() {
public static void encode(
XdrDataOutputStream stream, SurveyResponseBody encodedSurveyResponseBody) throws IOException {
// Xdrgen::AST::Identifier
- // SurveyMessageCommandType
+ // SurveyMessageResponseType
stream.writeInt(encodedSurveyResponseBody.getDiscriminant().getValue());
switch (encodedSurveyResponseBody.getDiscriminant()) {
- case SURVEY_TOPOLOGY:
- TopologyResponseBody.encode(stream, encodedSurveyResponseBody.topologyResponseBody);
+ case SURVEY_TOPOLOGY_RESPONSE_V0:
+ TopologyResponseBodyV0.encode(stream, encodedSurveyResponseBody.topologyResponseBodyV0);
+ break;
+ case SURVEY_TOPOLOGY_RESPONSE_V1:
+ TopologyResponseBodyV1.encode(stream, encodedSurveyResponseBody.topologyResponseBodyV1);
break;
}
}
@@ -78,11 +105,14 @@ public void encode(XdrDataOutputStream stream) throws IOException {
public static SurveyResponseBody decode(XdrDataInputStream stream) throws IOException {
SurveyResponseBody decodedSurveyResponseBody = new SurveyResponseBody();
- SurveyMessageCommandType discriminant = SurveyMessageCommandType.decode(stream);
+ SurveyMessageResponseType discriminant = SurveyMessageResponseType.decode(stream);
decodedSurveyResponseBody.setDiscriminant(discriminant);
switch (decodedSurveyResponseBody.getDiscriminant()) {
- case SURVEY_TOPOLOGY:
- decodedSurveyResponseBody.topologyResponseBody = TopologyResponseBody.decode(stream);
+ case SURVEY_TOPOLOGY_RESPONSE_V0:
+ decodedSurveyResponseBody.topologyResponseBodyV0 = TopologyResponseBodyV0.decode(stream);
+ break;
+ case SURVEY_TOPOLOGY_RESPONSE_V1:
+ decodedSurveyResponseBody.topologyResponseBodyV1 = TopologyResponseBodyV1.decode(stream);
break;
}
return decodedSurveyResponseBody;
@@ -90,7 +120,7 @@ public static SurveyResponseBody decode(XdrDataInputStream stream) throws IOExce
@Override
public int hashCode() {
- return Objects.hashCode(this.topologyResponseBody, this.type);
+ return Objects.hash(this.topologyResponseBodyV0, this.topologyResponseBodyV1, this.type);
}
@Override
@@ -100,7 +130,32 @@ public boolean equals(Object object) {
}
SurveyResponseBody other = (SurveyResponseBody) object;
- return Objects.equal(this.topologyResponseBody, other.topologyResponseBody)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.topologyResponseBodyV0, other.topologyResponseBodyV0)
+ && Objects.equals(this.topologyResponseBodyV1, other.topologyResponseBodyV1)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SurveyResponseBody fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SurveyResponseBody fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/SurveyResponseMessage.java b/src/main/java/org/stellar/sdk/xdr/SurveyResponseMessage.java
index e118c84fc..cc8ee37bc 100644
--- a/src/main/java/org/stellar/sdk/xdr/SurveyResponseMessage.java
+++ b/src/main/java/org/stellar/sdk/xdr/SurveyResponseMessage.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -97,7 +102,7 @@ public static SurveyResponseMessage decode(XdrDataInputStream stream) throws IOE
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.surveyorPeerID,
this.surveyedPeerID,
this.ledgerNum,
@@ -112,11 +117,35 @@ public boolean equals(Object object) {
}
SurveyResponseMessage other = (SurveyResponseMessage) object;
- return Objects.equal(this.surveyorPeerID, other.surveyorPeerID)
- && Objects.equal(this.surveyedPeerID, other.surveyedPeerID)
- && Objects.equal(this.ledgerNum, other.ledgerNum)
- && Objects.equal(this.commandType, other.commandType)
- && Objects.equal(this.encryptedBody, other.encryptedBody);
+ return Objects.equals(this.surveyorPeerID, other.surveyorPeerID)
+ && Objects.equals(this.surveyedPeerID, other.surveyedPeerID)
+ && Objects.equals(this.ledgerNum, other.ledgerNum)
+ && Objects.equals(this.commandType, other.commandType)
+ && Objects.equals(this.encryptedBody, other.encryptedBody);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static SurveyResponseMessage fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static SurveyResponseMessage fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -153,11 +182,11 @@ public Builder encryptedBody(EncryptedBody encryptedBody) {
public SurveyResponseMessage build() {
SurveyResponseMessage val = new SurveyResponseMessage();
- val.setSurveyorPeerID(surveyorPeerID);
- val.setSurveyedPeerID(surveyedPeerID);
- val.setLedgerNum(ledgerNum);
- val.setCommandType(commandType);
- val.setEncryptedBody(encryptedBody);
+ val.setSurveyorPeerID(this.surveyorPeerID);
+ val.setSurveyedPeerID(this.surveyedPeerID);
+ val.setLedgerNum(this.ledgerNum);
+ val.setCommandType(this.commandType);
+ val.setEncryptedBody(this.encryptedBody);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ThresholdIndexes.java b/src/main/java/org/stellar/sdk/xdr/ThresholdIndexes.java
index c85d2cfae..eb7ced745 100644
--- a/src/main/java/org/stellar/sdk/xdr/ThresholdIndexes.java
+++ b/src/main/java/org/stellar/sdk/xdr/ThresholdIndexes.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -55,4 +60,28 @@ public static void encode(XdrDataOutputStream stream, ThresholdIndexes value) th
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static ThresholdIndexes fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static ThresholdIndexes fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/ThresholdIndices.java b/src/main/java/org/stellar/sdk/xdr/ThresholdIndices.java
deleted file mode 100644
index 1ef43b166..000000000
--- a/src/main/java/org/stellar/sdk/xdr/ThresholdIndices.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// Automatically generated on 2015-11-05T11:21:06-08:00
-// DO NOT EDIT or your changes may be overwritten
-
-package org.stellar.sdk.xdr;
-
-import java.io.IOException;
-
-// === xdr source ============================================================
-
-// enum ThresholdIndexes
-// {
-// THRESHOLD_MASTER_WEIGHT = 0,
-// THRESHOLD_LOW = 1,
-// THRESHOLD_MED = 2,
-// THRESHOLD_HIGH = 3
-// };
-
-// ===========================================================================
-public enum ThresholdIndices {
- THRESHOLD_MASTER_WEIGHT(0),
- THRESHOLD_LOW(1),
- THRESHOLD_MED(2),
- THRESHOLD_HIGH(3),
- ;
- private int mValue;
-
- ThresholdIndices(int value) {
- mValue = value;
- }
-
- public int getValue() {
- return mValue;
- }
-
- static ThresholdIndices decode(XdrDataInputStream stream) throws IOException {
- int value = stream.readInt();
- switch (value) {
- case 0:
- return THRESHOLD_MASTER_WEIGHT;
- case 1:
- return THRESHOLD_LOW;
- case 2:
- return THRESHOLD_MED;
- case 3:
- return THRESHOLD_HIGH;
- default:
- throw new RuntimeException("Unknown enum value: " + value);
- }
- }
-
- static void encode(XdrDataOutputStream stream, ThresholdIndices value) throws IOException {
- stream.writeInt(value.getValue());
- }
-}
diff --git a/src/main/java/org/stellar/sdk/xdr/Thresholds.java b/src/main/java/org/stellar/sdk/xdr/Thresholds.java
index 7da4111ba..288853d4c 100644
--- a/src/main/java/org/stellar/sdk/xdr/Thresholds.java
+++ b/src/main/java/org/stellar/sdk/xdr/Thresholds.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -60,4 +65,28 @@ public boolean equals(Object object) {
Thresholds other = (Thresholds) object;
return Arrays.equals(this.Thresholds, other.Thresholds);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Thresholds fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Thresholds fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TimeBounds.java b/src/main/java/org/stellar/sdk/xdr/TimeBounds.java
index c1ef69520..f7d00a24b 100644
--- a/src/main/java/org/stellar/sdk/xdr/TimeBounds.java
+++ b/src/main/java/org/stellar/sdk/xdr/TimeBounds.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -57,7 +62,7 @@ public static TimeBounds decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.minTime, this.maxTime);
+ return Objects.hash(this.minTime, this.maxTime);
}
@Override
@@ -67,7 +72,32 @@ public boolean equals(Object object) {
}
TimeBounds other = (TimeBounds) object;
- return Objects.equal(this.minTime, other.minTime) && Objects.equal(this.maxTime, other.maxTime);
+ return Objects.equals(this.minTime, other.minTime)
+ && Objects.equals(this.maxTime, other.maxTime);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TimeBounds fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TimeBounds fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -86,8 +116,8 @@ public Builder maxTime(TimePoint maxTime) {
public TimeBounds build() {
TimeBounds val = new TimeBounds();
- val.setMinTime(minTime);
- val.setMaxTime(maxTime);
+ val.setMinTime(this.minTime);
+ val.setMaxTime(this.maxTime);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TimePoint.java b/src/main/java/org/stellar/sdk/xdr/TimePoint.java
index 0caede008..e093806fc 100644
--- a/src/main/java/org/stellar/sdk/xdr/TimePoint.java
+++ b/src/main/java/org/stellar/sdk/xdr/TimePoint.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -45,7 +50,7 @@ public static TimePoint decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(this.TimePoint);
+ return Objects.hash(this.TimePoint);
}
@Override
@@ -55,6 +60,30 @@ public boolean equals(Object object) {
}
TimePoint other = (TimePoint) object;
- return Objects.equal(this.TimePoint, other.TimePoint);
+ return Objects.equals(this.TimePoint, other.TimePoint);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TimePoint fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TimePoint fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TopologyResponseBody.java b/src/main/java/org/stellar/sdk/xdr/TopologyResponseBody.java
deleted file mode 100644
index 3d0513145..000000000
--- a/src/main/java/org/stellar/sdk/xdr/TopologyResponseBody.java
+++ /dev/null
@@ -1,143 +0,0 @@
-// Automatically generated by xdrgen
-// DO NOT EDIT or your changes may be overwritten
-
-package org.stellar.sdk.xdr;
-
-import com.google.common.base.Objects;
-import java.io.IOException;
-
-// === xdr source ============================================================
-
-// struct TopologyResponseBody
-// {
-// PeerStatList inboundPeers;
-// PeerStatList outboundPeers;
-//
-// uint32 totalInboundPeerCount;
-// uint32 totalOutboundPeerCount;
-// };
-
-// ===========================================================================
-public class TopologyResponseBody implements XdrElement {
- public TopologyResponseBody() {}
-
- private PeerStatList inboundPeers;
-
- public PeerStatList getInboundPeers() {
- return this.inboundPeers;
- }
-
- public void setInboundPeers(PeerStatList value) {
- this.inboundPeers = value;
- }
-
- private PeerStatList outboundPeers;
-
- public PeerStatList getOutboundPeers() {
- return this.outboundPeers;
- }
-
- public void setOutboundPeers(PeerStatList value) {
- this.outboundPeers = value;
- }
-
- private Uint32 totalInboundPeerCount;
-
- public Uint32 getTotalInboundPeerCount() {
- return this.totalInboundPeerCount;
- }
-
- public void setTotalInboundPeerCount(Uint32 value) {
- this.totalInboundPeerCount = value;
- }
-
- private Uint32 totalOutboundPeerCount;
-
- public Uint32 getTotalOutboundPeerCount() {
- return this.totalOutboundPeerCount;
- }
-
- public void setTotalOutboundPeerCount(Uint32 value) {
- this.totalOutboundPeerCount = value;
- }
-
- public static void encode(
- XdrDataOutputStream stream, TopologyResponseBody encodedTopologyResponseBody)
- throws IOException {
- PeerStatList.encode(stream, encodedTopologyResponseBody.inboundPeers);
- PeerStatList.encode(stream, encodedTopologyResponseBody.outboundPeers);
- Uint32.encode(stream, encodedTopologyResponseBody.totalInboundPeerCount);
- Uint32.encode(stream, encodedTopologyResponseBody.totalOutboundPeerCount);
- }
-
- public void encode(XdrDataOutputStream stream) throws IOException {
- encode(stream, this);
- }
-
- public static TopologyResponseBody decode(XdrDataInputStream stream) throws IOException {
- TopologyResponseBody decodedTopologyResponseBody = new TopologyResponseBody();
- decodedTopologyResponseBody.inboundPeers = PeerStatList.decode(stream);
- decodedTopologyResponseBody.outboundPeers = PeerStatList.decode(stream);
- decodedTopologyResponseBody.totalInboundPeerCount = Uint32.decode(stream);
- decodedTopologyResponseBody.totalOutboundPeerCount = Uint32.decode(stream);
- return decodedTopologyResponseBody;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(
- this.inboundPeers,
- this.outboundPeers,
- this.totalInboundPeerCount,
- this.totalOutboundPeerCount);
- }
-
- @Override
- public boolean equals(Object object) {
- if (!(object instanceof TopologyResponseBody)) {
- return false;
- }
-
- TopologyResponseBody other = (TopologyResponseBody) object;
- return Objects.equal(this.inboundPeers, other.inboundPeers)
- && Objects.equal(this.outboundPeers, other.outboundPeers)
- && Objects.equal(this.totalInboundPeerCount, other.totalInboundPeerCount)
- && Objects.equal(this.totalOutboundPeerCount, other.totalOutboundPeerCount);
- }
-
- public static final class Builder {
- private PeerStatList inboundPeers;
- private PeerStatList outboundPeers;
- private Uint32 totalInboundPeerCount;
- private Uint32 totalOutboundPeerCount;
-
- public Builder inboundPeers(PeerStatList inboundPeers) {
- this.inboundPeers = inboundPeers;
- return this;
- }
-
- public Builder outboundPeers(PeerStatList outboundPeers) {
- this.outboundPeers = outboundPeers;
- return this;
- }
-
- public Builder totalInboundPeerCount(Uint32 totalInboundPeerCount) {
- this.totalInboundPeerCount = totalInboundPeerCount;
- return this;
- }
-
- public Builder totalOutboundPeerCount(Uint32 totalOutboundPeerCount) {
- this.totalOutboundPeerCount = totalOutboundPeerCount;
- return this;
- }
-
- public TopologyResponseBody build() {
- TopologyResponseBody val = new TopologyResponseBody();
- val.setInboundPeers(inboundPeers);
- val.setOutboundPeers(outboundPeers);
- val.setTotalInboundPeerCount(totalInboundPeerCount);
- val.setTotalOutboundPeerCount(totalOutboundPeerCount);
- return val;
- }
- }
-}
diff --git a/src/main/java/org/stellar/sdk/xdr/TopologyResponseBodyV0.java b/src/main/java/org/stellar/sdk/xdr/TopologyResponseBodyV0.java
new file mode 100644
index 000000000..ad3b33eb3
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TopologyResponseBodyV0.java
@@ -0,0 +1,172 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct TopologyResponseBodyV0
+// {
+// PeerStatList inboundPeers;
+// PeerStatList outboundPeers;
+//
+// uint32 totalInboundPeerCount;
+// uint32 totalOutboundPeerCount;
+// };
+
+// ===========================================================================
+public class TopologyResponseBodyV0 implements XdrElement {
+ public TopologyResponseBodyV0() {}
+
+ private PeerStatList inboundPeers;
+
+ public PeerStatList getInboundPeers() {
+ return this.inboundPeers;
+ }
+
+ public void setInboundPeers(PeerStatList value) {
+ this.inboundPeers = value;
+ }
+
+ private PeerStatList outboundPeers;
+
+ public PeerStatList getOutboundPeers() {
+ return this.outboundPeers;
+ }
+
+ public void setOutboundPeers(PeerStatList value) {
+ this.outboundPeers = value;
+ }
+
+ private Uint32 totalInboundPeerCount;
+
+ public Uint32 getTotalInboundPeerCount() {
+ return this.totalInboundPeerCount;
+ }
+
+ public void setTotalInboundPeerCount(Uint32 value) {
+ this.totalInboundPeerCount = value;
+ }
+
+ private Uint32 totalOutboundPeerCount;
+
+ public Uint32 getTotalOutboundPeerCount() {
+ return this.totalOutboundPeerCount;
+ }
+
+ public void setTotalOutboundPeerCount(Uint32 value) {
+ this.totalOutboundPeerCount = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, TopologyResponseBodyV0 encodedTopologyResponseBodyV0)
+ throws IOException {
+ PeerStatList.encode(stream, encodedTopologyResponseBodyV0.inboundPeers);
+ PeerStatList.encode(stream, encodedTopologyResponseBodyV0.outboundPeers);
+ Uint32.encode(stream, encodedTopologyResponseBodyV0.totalInboundPeerCount);
+ Uint32.encode(stream, encodedTopologyResponseBodyV0.totalOutboundPeerCount);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static TopologyResponseBodyV0 decode(XdrDataInputStream stream) throws IOException {
+ TopologyResponseBodyV0 decodedTopologyResponseBodyV0 = new TopologyResponseBodyV0();
+ decodedTopologyResponseBodyV0.inboundPeers = PeerStatList.decode(stream);
+ decodedTopologyResponseBodyV0.outboundPeers = PeerStatList.decode(stream);
+ decodedTopologyResponseBodyV0.totalInboundPeerCount = Uint32.decode(stream);
+ decodedTopologyResponseBodyV0.totalOutboundPeerCount = Uint32.decode(stream);
+ return decodedTopologyResponseBodyV0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.inboundPeers,
+ this.outboundPeers,
+ this.totalInboundPeerCount,
+ this.totalOutboundPeerCount);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof TopologyResponseBodyV0)) {
+ return false;
+ }
+
+ TopologyResponseBodyV0 other = (TopologyResponseBodyV0) object;
+ return Objects.equals(this.inboundPeers, other.inboundPeers)
+ && Objects.equals(this.outboundPeers, other.outboundPeers)
+ && Objects.equals(this.totalInboundPeerCount, other.totalInboundPeerCount)
+ && Objects.equals(this.totalOutboundPeerCount, other.totalOutboundPeerCount);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TopologyResponseBodyV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TopologyResponseBodyV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private PeerStatList inboundPeers;
+ private PeerStatList outboundPeers;
+ private Uint32 totalInboundPeerCount;
+ private Uint32 totalOutboundPeerCount;
+
+ public Builder inboundPeers(PeerStatList inboundPeers) {
+ this.inboundPeers = inboundPeers;
+ return this;
+ }
+
+ public Builder outboundPeers(PeerStatList outboundPeers) {
+ this.outboundPeers = outboundPeers;
+ return this;
+ }
+
+ public Builder totalInboundPeerCount(Uint32 totalInboundPeerCount) {
+ this.totalInboundPeerCount = totalInboundPeerCount;
+ return this;
+ }
+
+ public Builder totalOutboundPeerCount(Uint32 totalOutboundPeerCount) {
+ this.totalOutboundPeerCount = totalOutboundPeerCount;
+ return this;
+ }
+
+ public TopologyResponseBodyV0 build() {
+ TopologyResponseBodyV0 val = new TopologyResponseBodyV0();
+ val.setInboundPeers(this.inboundPeers);
+ val.setOutboundPeers(this.outboundPeers);
+ val.setTotalInboundPeerCount(this.totalInboundPeerCount);
+ val.setTotalOutboundPeerCount(this.totalOutboundPeerCount);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TopologyResponseBodyV1.java b/src/main/java/org/stellar/sdk/xdr/TopologyResponseBodyV1.java
new file mode 100644
index 000000000..cc9713013
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TopologyResponseBodyV1.java
@@ -0,0 +1,217 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct TopologyResponseBodyV1
+// {
+// PeerStatList inboundPeers;
+// PeerStatList outboundPeers;
+//
+// uint32 totalInboundPeerCount;
+// uint32 totalOutboundPeerCount;
+//
+// uint32 maxInboundPeerCount;
+// uint32 maxOutboundPeerCount;
+// };
+
+// ===========================================================================
+public class TopologyResponseBodyV1 implements XdrElement {
+ public TopologyResponseBodyV1() {}
+
+ private PeerStatList inboundPeers;
+
+ public PeerStatList getInboundPeers() {
+ return this.inboundPeers;
+ }
+
+ public void setInboundPeers(PeerStatList value) {
+ this.inboundPeers = value;
+ }
+
+ private PeerStatList outboundPeers;
+
+ public PeerStatList getOutboundPeers() {
+ return this.outboundPeers;
+ }
+
+ public void setOutboundPeers(PeerStatList value) {
+ this.outboundPeers = value;
+ }
+
+ private Uint32 totalInboundPeerCount;
+
+ public Uint32 getTotalInboundPeerCount() {
+ return this.totalInboundPeerCount;
+ }
+
+ public void setTotalInboundPeerCount(Uint32 value) {
+ this.totalInboundPeerCount = value;
+ }
+
+ private Uint32 totalOutboundPeerCount;
+
+ public Uint32 getTotalOutboundPeerCount() {
+ return this.totalOutboundPeerCount;
+ }
+
+ public void setTotalOutboundPeerCount(Uint32 value) {
+ this.totalOutboundPeerCount = value;
+ }
+
+ private Uint32 maxInboundPeerCount;
+
+ public Uint32 getMaxInboundPeerCount() {
+ return this.maxInboundPeerCount;
+ }
+
+ public void setMaxInboundPeerCount(Uint32 value) {
+ this.maxInboundPeerCount = value;
+ }
+
+ private Uint32 maxOutboundPeerCount;
+
+ public Uint32 getMaxOutboundPeerCount() {
+ return this.maxOutboundPeerCount;
+ }
+
+ public void setMaxOutboundPeerCount(Uint32 value) {
+ this.maxOutboundPeerCount = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream, TopologyResponseBodyV1 encodedTopologyResponseBodyV1)
+ throws IOException {
+ PeerStatList.encode(stream, encodedTopologyResponseBodyV1.inboundPeers);
+ PeerStatList.encode(stream, encodedTopologyResponseBodyV1.outboundPeers);
+ Uint32.encode(stream, encodedTopologyResponseBodyV1.totalInboundPeerCount);
+ Uint32.encode(stream, encodedTopologyResponseBodyV1.totalOutboundPeerCount);
+ Uint32.encode(stream, encodedTopologyResponseBodyV1.maxInboundPeerCount);
+ Uint32.encode(stream, encodedTopologyResponseBodyV1.maxOutboundPeerCount);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static TopologyResponseBodyV1 decode(XdrDataInputStream stream) throws IOException {
+ TopologyResponseBodyV1 decodedTopologyResponseBodyV1 = new TopologyResponseBodyV1();
+ decodedTopologyResponseBodyV1.inboundPeers = PeerStatList.decode(stream);
+ decodedTopologyResponseBodyV1.outboundPeers = PeerStatList.decode(stream);
+ decodedTopologyResponseBodyV1.totalInboundPeerCount = Uint32.decode(stream);
+ decodedTopologyResponseBodyV1.totalOutboundPeerCount = Uint32.decode(stream);
+ decodedTopologyResponseBodyV1.maxInboundPeerCount = Uint32.decode(stream);
+ decodedTopologyResponseBodyV1.maxOutboundPeerCount = Uint32.decode(stream);
+ return decodedTopologyResponseBodyV1;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.inboundPeers,
+ this.outboundPeers,
+ this.totalInboundPeerCount,
+ this.totalOutboundPeerCount,
+ this.maxInboundPeerCount,
+ this.maxOutboundPeerCount);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof TopologyResponseBodyV1)) {
+ return false;
+ }
+
+ TopologyResponseBodyV1 other = (TopologyResponseBodyV1) object;
+ return Objects.equals(this.inboundPeers, other.inboundPeers)
+ && Objects.equals(this.outboundPeers, other.outboundPeers)
+ && Objects.equals(this.totalInboundPeerCount, other.totalInboundPeerCount)
+ && Objects.equals(this.totalOutboundPeerCount, other.totalOutboundPeerCount)
+ && Objects.equals(this.maxInboundPeerCount, other.maxInboundPeerCount)
+ && Objects.equals(this.maxOutboundPeerCount, other.maxOutboundPeerCount);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TopologyResponseBodyV1 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TopologyResponseBodyV1 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private PeerStatList inboundPeers;
+ private PeerStatList outboundPeers;
+ private Uint32 totalInboundPeerCount;
+ private Uint32 totalOutboundPeerCount;
+ private Uint32 maxInboundPeerCount;
+ private Uint32 maxOutboundPeerCount;
+
+ public Builder inboundPeers(PeerStatList inboundPeers) {
+ this.inboundPeers = inboundPeers;
+ return this;
+ }
+
+ public Builder outboundPeers(PeerStatList outboundPeers) {
+ this.outboundPeers = outboundPeers;
+ return this;
+ }
+
+ public Builder totalInboundPeerCount(Uint32 totalInboundPeerCount) {
+ this.totalInboundPeerCount = totalInboundPeerCount;
+ return this;
+ }
+
+ public Builder totalOutboundPeerCount(Uint32 totalOutboundPeerCount) {
+ this.totalOutboundPeerCount = totalOutboundPeerCount;
+ return this;
+ }
+
+ public Builder maxInboundPeerCount(Uint32 maxInboundPeerCount) {
+ this.maxInboundPeerCount = maxInboundPeerCount;
+ return this;
+ }
+
+ public Builder maxOutboundPeerCount(Uint32 maxOutboundPeerCount) {
+ this.maxOutboundPeerCount = maxOutboundPeerCount;
+ return this;
+ }
+
+ public TopologyResponseBodyV1 build() {
+ TopologyResponseBodyV1 val = new TopologyResponseBodyV1();
+ val.setInboundPeers(this.inboundPeers);
+ val.setOutboundPeers(this.outboundPeers);
+ val.setTotalInboundPeerCount(this.totalInboundPeerCount);
+ val.setTotalOutboundPeerCount(this.totalOutboundPeerCount);
+ val.setMaxInboundPeerCount(this.maxInboundPeerCount);
+ val.setMaxOutboundPeerCount(this.maxOutboundPeerCount);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Transaction.java b/src/main/java/org/stellar/sdk/xdr/Transaction.java
index ae317f601..b5896d5b2 100644
--- a/src/main/java/org/stellar/sdk/xdr/Transaction.java
+++ b/src/main/java/org/stellar/sdk/xdr/Transaction.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -32,6 +37,8 @@
// {
// case 0:
// void;
+// case 1:
+// SorobanTransactionData sorobanData;
// }
// ext;
// };
@@ -147,7 +154,7 @@ public static Transaction decode(XdrDataInputStream stream) throws IOException {
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.sourceAccount,
this.fee,
this.seqNum,
@@ -164,13 +171,37 @@ public boolean equals(Object object) {
}
Transaction other = (Transaction) object;
- return Objects.equal(this.sourceAccount, other.sourceAccount)
- && Objects.equal(this.fee, other.fee)
- && Objects.equal(this.seqNum, other.seqNum)
- && Objects.equal(this.cond, other.cond)
- && Objects.equal(this.memo, other.memo)
+ return Objects.equals(this.sourceAccount, other.sourceAccount)
+ && Objects.equals(this.fee, other.fee)
+ && Objects.equals(this.seqNum, other.seqNum)
+ && Objects.equals(this.cond, other.cond)
+ && Objects.equals(this.memo, other.memo)
&& Arrays.equals(this.operations, other.operations)
- && Objects.equal(this.ext, other.ext);
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Transaction fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Transaction fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -219,18 +250,18 @@ public Builder ext(TransactionExt ext) {
public Transaction build() {
Transaction val = new Transaction();
- val.setSourceAccount(sourceAccount);
- val.setFee(fee);
- val.setSeqNum(seqNum);
- val.setCond(cond);
- val.setMemo(memo);
- val.setOperations(operations);
- val.setExt(ext);
+ val.setSourceAccount(this.sourceAccount);
+ val.setFee(this.fee);
+ val.setSeqNum(this.seqNum);
+ val.setCond(this.cond);
+ val.setMemo(this.memo);
+ val.setOperations(this.operations);
+ val.setExt(this.ext);
return val;
}
}
- public static class TransactionExt {
+ public static class TransactionExt implements XdrElement {
public TransactionExt() {}
Integer v;
@@ -243,17 +274,34 @@ public void setDiscriminant(Integer value) {
this.v = value;
}
+ private SorobanTransactionData sorobanData;
+
+ public SorobanTransactionData getSorobanData() {
+ return this.sorobanData;
+ }
+
+ public void setSorobanData(SorobanTransactionData value) {
+ this.sorobanData = value;
+ }
+
public static final class Builder {
private Integer discriminant;
+ private SorobanTransactionData sorobanData;
public Builder discriminant(Integer discriminant) {
this.discriminant = discriminant;
return this;
}
+ public Builder sorobanData(SorobanTransactionData sorobanData) {
+ this.sorobanData = sorobanData;
+ return this;
+ }
+
public TransactionExt build() {
TransactionExt val = new TransactionExt();
val.setDiscriminant(discriminant);
+ val.setSorobanData(this.sorobanData);
return val;
}
}
@@ -266,6 +314,9 @@ public static void encode(XdrDataOutputStream stream, TransactionExt encodedTran
switch (encodedTransactionExt.getDiscriminant()) {
case 0:
break;
+ case 1:
+ SorobanTransactionData.encode(stream, encodedTransactionExt.sorobanData);
+ break;
}
}
@@ -280,13 +331,16 @@ public static TransactionExt decode(XdrDataInputStream stream) throws IOExceptio
switch (decodedTransactionExt.getDiscriminant()) {
case 0:
break;
+ case 1:
+ decodedTransactionExt.sorobanData = SorobanTransactionData.decode(stream);
+ break;
}
return decodedTransactionExt;
}
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.sorobanData, this.v);
}
@Override
@@ -296,7 +350,31 @@ public boolean equals(Object object) {
}
TransactionExt other = (TransactionExt) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.sorobanData, other.sorobanData) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionEnvelope.java b/src/main/java/org/stellar/sdk/xdr/TransactionEnvelope.java
index 159b5739b..b8c9fe213 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionEnvelope.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionEnvelope.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -91,9 +96,9 @@ public Builder feeBump(FeeBumpTransactionEnvelope feeBump) {
public TransactionEnvelope build() {
TransactionEnvelope val = new TransactionEnvelope();
val.setDiscriminant(discriminant);
- val.setV0(v0);
- val.setV1(v1);
- val.setFeeBump(feeBump);
+ val.setV0(this.v0);
+ val.setV1(this.v1);
+ val.setFeeBump(this.feeBump);
return val;
}
}
@@ -141,7 +146,7 @@ public static TransactionEnvelope decode(XdrDataInputStream stream) throws IOExc
@Override
public int hashCode() {
- return Objects.hashCode(this.v0, this.v1, this.feeBump, this.type);
+ return Objects.hash(this.v0, this.v1, this.feeBump, this.type);
}
@Override
@@ -151,9 +156,33 @@ public boolean equals(Object object) {
}
TransactionEnvelope other = (TransactionEnvelope) object;
- return Objects.equal(this.v0, other.v0)
- && Objects.equal(this.v1, other.v1)
- && Objects.equal(this.feeBump, other.feeBump)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.v0, other.v0)
+ && Objects.equals(this.v1, other.v1)
+ && Objects.equals(this.feeBump, other.feeBump)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionEnvelope fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionEnvelope fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionHistoryEntry.java b/src/main/java/org/stellar/sdk/xdr/TransactionHistoryEntry.java
index 661059741..3b3bc9d16 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionHistoryEntry.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionHistoryEntry.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -13,11 +18,13 @@
// uint32 ledgerSeq;
// TransactionSet txSet;
//
-// // reserved for future use
+// // when v != 0, txSet must be empty
// union switch (int v)
// {
// case 0:
// void;
+// case 1:
+// GeneralizedTransactionSet generalizedTxSet;
// }
// ext;
// };
@@ -78,7 +85,7 @@ public static TransactionHistoryEntry decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(this.ledgerSeq, this.txSet, this.ext);
+ return Objects.hash(this.ledgerSeq, this.txSet, this.ext);
}
@Override
@@ -88,9 +95,33 @@ public boolean equals(Object object) {
}
TransactionHistoryEntry other = (TransactionHistoryEntry) object;
- return Objects.equal(this.ledgerSeq, other.ledgerSeq)
- && Objects.equal(this.txSet, other.txSet)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.ledgerSeq, other.ledgerSeq)
+ && Objects.equals(this.txSet, other.txSet)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionHistoryEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionHistoryEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -115,14 +146,14 @@ public Builder ext(TransactionHistoryEntryExt ext) {
public TransactionHistoryEntry build() {
TransactionHistoryEntry val = new TransactionHistoryEntry();
- val.setLedgerSeq(ledgerSeq);
- val.setTxSet(txSet);
- val.setExt(ext);
+ val.setLedgerSeq(this.ledgerSeq);
+ val.setTxSet(this.txSet);
+ val.setExt(this.ext);
return val;
}
}
- public static class TransactionHistoryEntryExt {
+ public static class TransactionHistoryEntryExt implements XdrElement {
public TransactionHistoryEntryExt() {}
Integer v;
@@ -135,17 +166,34 @@ public void setDiscriminant(Integer value) {
this.v = value;
}
+ private GeneralizedTransactionSet generalizedTxSet;
+
+ public GeneralizedTransactionSet getGeneralizedTxSet() {
+ return this.generalizedTxSet;
+ }
+
+ public void setGeneralizedTxSet(GeneralizedTransactionSet value) {
+ this.generalizedTxSet = value;
+ }
+
public static final class Builder {
private Integer discriminant;
+ private GeneralizedTransactionSet generalizedTxSet;
public Builder discriminant(Integer discriminant) {
this.discriminant = discriminant;
return this;
}
+ public Builder generalizedTxSet(GeneralizedTransactionSet generalizedTxSet) {
+ this.generalizedTxSet = generalizedTxSet;
+ return this;
+ }
+
public TransactionHistoryEntryExt build() {
TransactionHistoryEntryExt val = new TransactionHistoryEntryExt();
val.setDiscriminant(discriminant);
+ val.setGeneralizedTxSet(this.generalizedTxSet);
return val;
}
}
@@ -159,6 +207,10 @@ public static void encode(
switch (encodedTransactionHistoryEntryExt.getDiscriminant()) {
case 0:
break;
+ case 1:
+ GeneralizedTransactionSet.encode(
+ stream, encodedTransactionHistoryEntryExt.generalizedTxSet);
+ break;
}
}
@@ -174,13 +226,17 @@ public static TransactionHistoryEntryExt decode(XdrDataInputStream stream) throw
switch (decodedTransactionHistoryEntryExt.getDiscriminant()) {
case 0:
break;
+ case 1:
+ decodedTransactionHistoryEntryExt.generalizedTxSet =
+ GeneralizedTransactionSet.decode(stream);
+ break;
}
return decodedTransactionHistoryEntryExt;
}
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.generalizedTxSet, this.v);
}
@Override
@@ -190,7 +246,32 @@ public boolean equals(Object object) {
}
TransactionHistoryEntryExt other = (TransactionHistoryEntryExt) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.generalizedTxSet, other.generalizedTxSet)
+ && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionHistoryEntryExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionHistoryEntryExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionHistoryResultEntry.java b/src/main/java/org/stellar/sdk/xdr/TransactionHistoryResultEntry.java
index d5451fbd0..3f85fdfaf 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionHistoryResultEntry.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionHistoryResultEntry.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -80,7 +85,7 @@ public static TransactionHistoryResultEntry decode(XdrDataInputStream stream) th
@Override
public int hashCode() {
- return Objects.hashCode(this.ledgerSeq, this.txResultSet, this.ext);
+ return Objects.hash(this.ledgerSeq, this.txResultSet, this.ext);
}
@Override
@@ -90,9 +95,33 @@ public boolean equals(Object object) {
}
TransactionHistoryResultEntry other = (TransactionHistoryResultEntry) object;
- return Objects.equal(this.ledgerSeq, other.ledgerSeq)
- && Objects.equal(this.txResultSet, other.txResultSet)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.ledgerSeq, other.ledgerSeq)
+ && Objects.equals(this.txResultSet, other.txResultSet)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionHistoryResultEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionHistoryResultEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -117,14 +146,14 @@ public Builder ext(TransactionHistoryResultEntryExt ext) {
public TransactionHistoryResultEntry build() {
TransactionHistoryResultEntry val = new TransactionHistoryResultEntry();
- val.setLedgerSeq(ledgerSeq);
- val.setTxResultSet(txResultSet);
- val.setExt(ext);
+ val.setLedgerSeq(this.ledgerSeq);
+ val.setTxResultSet(this.txResultSet);
+ val.setExt(this.ext);
return val;
}
}
- public static class TransactionHistoryResultEntryExt {
+ public static class TransactionHistoryResultEntryExt implements XdrElement {
public TransactionHistoryResultEntryExt() {}
Integer v;
@@ -184,7 +213,7 @@ public static TransactionHistoryResultEntryExt decode(XdrDataInputStream stream)
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -194,7 +223,31 @@ public boolean equals(Object object) {
}
TransactionHistoryResultEntryExt other = (TransactionHistoryResultEntryExt) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionHistoryResultEntryExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionHistoryResultEntryExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionMeta.java b/src/main/java/org/stellar/sdk/xdr/TransactionMeta.java
index d83c57b17..a5f901e5f 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionMeta.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionMeta.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -17,6 +22,8 @@
// TransactionMetaV1 v1;
// case 2:
// TransactionMetaV2 v2;
+// case 3:
+// TransactionMetaV3 v3;
// };
// ===========================================================================
@@ -63,11 +70,22 @@ public void setV2(TransactionMetaV2 value) {
this.v2 = value;
}
+ private TransactionMetaV3 v3;
+
+ public TransactionMetaV3 getV3() {
+ return this.v3;
+ }
+
+ public void setV3(TransactionMetaV3 value) {
+ this.v3 = value;
+ }
+
public static final class Builder {
private Integer discriminant;
private OperationMeta[] operations;
private TransactionMetaV1 v1;
private TransactionMetaV2 v2;
+ private TransactionMetaV3 v3;
public Builder discriminant(Integer discriminant) {
this.discriminant = discriminant;
@@ -89,12 +107,18 @@ public Builder v2(TransactionMetaV2 v2) {
return this;
}
+ public Builder v3(TransactionMetaV3 v3) {
+ this.v3 = v3;
+ return this;
+ }
+
public TransactionMeta build() {
TransactionMeta val = new TransactionMeta();
val.setDiscriminant(discriminant);
- val.setOperations(operations);
- val.setV1(v1);
- val.setV2(v2);
+ val.setOperations(this.operations);
+ val.setV1(this.v1);
+ val.setV2(this.v2);
+ val.setV3(this.v3);
return val;
}
}
@@ -118,6 +142,9 @@ public static void encode(XdrDataOutputStream stream, TransactionMeta encodedTra
case 2:
TransactionMetaV2.encode(stream, encodedTransactionMeta.v2);
break;
+ case 3:
+ TransactionMetaV3.encode(stream, encodedTransactionMeta.v3);
+ break;
}
}
@@ -143,13 +170,16 @@ public static TransactionMeta decode(XdrDataInputStream stream) throws IOExcepti
case 2:
decodedTransactionMeta.v2 = TransactionMetaV2.decode(stream);
break;
+ case 3:
+ decodedTransactionMeta.v3 = TransactionMetaV3.decode(stream);
+ break;
}
return decodedTransactionMeta;
}
@Override
public int hashCode() {
- return Objects.hashCode(Arrays.hashCode(this.operations), this.v1, this.v2, this.v);
+ return Objects.hash(Arrays.hashCode(this.operations), this.v1, this.v2, this.v3, this.v);
}
@Override
@@ -160,8 +190,33 @@ public boolean equals(Object object) {
TransactionMeta other = (TransactionMeta) object;
return Arrays.equals(this.operations, other.operations)
- && Objects.equal(this.v1, other.v1)
- && Objects.equal(this.v2, other.v2)
- && Objects.equal(this.v, other.v);
+ && Objects.equals(this.v1, other.v1)
+ && Objects.equals(this.v2, other.v2)
+ && Objects.equals(this.v3, other.v3)
+ && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionMeta fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionMeta fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionMetaV1.java b/src/main/java/org/stellar/sdk/xdr/TransactionMetaV1.java
index f84fb2206..304753da3 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionMetaV1.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionMetaV1.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -66,7 +71,7 @@ public static TransactionMetaV1 decode(XdrDataInputStream stream) throws IOExcep
@Override
public int hashCode() {
- return Objects.hashCode(this.txChanges, Arrays.hashCode(this.operations));
+ return Objects.hash(this.txChanges, Arrays.hashCode(this.operations));
}
@Override
@@ -76,10 +81,34 @@ public boolean equals(Object object) {
}
TransactionMetaV1 other = (TransactionMetaV1) object;
- return Objects.equal(this.txChanges, other.txChanges)
+ return Objects.equals(this.txChanges, other.txChanges)
&& Arrays.equals(this.operations, other.operations);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionMetaV1 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionMetaV1 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private LedgerEntryChanges txChanges;
private OperationMeta[] operations;
@@ -96,8 +125,8 @@ public Builder operations(OperationMeta[] operations) {
public TransactionMetaV1 build() {
TransactionMetaV1 val = new TransactionMetaV1();
- val.setTxChanges(txChanges);
- val.setOperations(operations);
+ val.setTxChanges(this.txChanges);
+ val.setOperations(this.operations);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionMetaV2.java b/src/main/java/org/stellar/sdk/xdr/TransactionMetaV2.java
index 6e46edf1c..c7f68ba44 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionMetaV2.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionMetaV2.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -81,7 +86,7 @@ public static TransactionMetaV2 decode(XdrDataInputStream stream) throws IOExcep
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.txChangesBefore, Arrays.hashCode(this.operations), this.txChangesAfter);
}
@@ -92,9 +97,33 @@ public boolean equals(Object object) {
}
TransactionMetaV2 other = (TransactionMetaV2) object;
- return Objects.equal(this.txChangesBefore, other.txChangesBefore)
+ return Objects.equals(this.txChangesBefore, other.txChangesBefore)
&& Arrays.equals(this.operations, other.operations)
- && Objects.equal(this.txChangesAfter, other.txChangesAfter);
+ && Objects.equals(this.txChangesAfter, other.txChangesAfter);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionMetaV2 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionMetaV2 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -119,9 +148,9 @@ public Builder txChangesAfter(LedgerEntryChanges txChangesAfter) {
public TransactionMetaV2 build() {
TransactionMetaV2 val = new TransactionMetaV2();
- val.setTxChangesBefore(txChangesBefore);
- val.setOperations(operations);
- val.setTxChangesAfter(txChangesAfter);
+ val.setTxChangesBefore(this.txChangesBefore);
+ val.setOperations(this.operations);
+ val.setTxChangesAfter(this.txChangesAfter);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionMetaV3.java b/src/main/java/org/stellar/sdk/xdr/TransactionMetaV3.java
new file mode 100644
index 000000000..33b525771
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionMetaV3.java
@@ -0,0 +1,213 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct TransactionMetaV3
+// {
+// ExtensionPoint ext;
+//
+// LedgerEntryChanges txChangesBefore; // tx level changes before operations
+// // are applied if any
+// OperationMeta operations<>; // meta for each operation
+// LedgerEntryChanges txChangesAfter; // tx level changes after operations are
+// // applied if any
+// SorobanTransactionMeta* sorobanMeta; // Soroban-specific meta (only for
+// // Soroban transactions).
+// };
+
+// ===========================================================================
+public class TransactionMetaV3 implements XdrElement {
+ public TransactionMetaV3() {}
+
+ private ExtensionPoint ext;
+
+ public ExtensionPoint getExt() {
+ return this.ext;
+ }
+
+ public void setExt(ExtensionPoint value) {
+ this.ext = value;
+ }
+
+ private LedgerEntryChanges txChangesBefore;
+
+ public LedgerEntryChanges getTxChangesBefore() {
+ return this.txChangesBefore;
+ }
+
+ public void setTxChangesBefore(LedgerEntryChanges value) {
+ this.txChangesBefore = value;
+ }
+
+ private OperationMeta[] operations;
+
+ public OperationMeta[] getOperations() {
+ return this.operations;
+ }
+
+ public void setOperations(OperationMeta[] value) {
+ this.operations = value;
+ }
+
+ private LedgerEntryChanges txChangesAfter;
+
+ public LedgerEntryChanges getTxChangesAfter() {
+ return this.txChangesAfter;
+ }
+
+ public void setTxChangesAfter(LedgerEntryChanges value) {
+ this.txChangesAfter = value;
+ }
+
+ private SorobanTransactionMeta sorobanMeta;
+
+ public SorobanTransactionMeta getSorobanMeta() {
+ return this.sorobanMeta;
+ }
+
+ public void setSorobanMeta(SorobanTransactionMeta value) {
+ this.sorobanMeta = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, TransactionMetaV3 encodedTransactionMetaV3)
+ throws IOException {
+ ExtensionPoint.encode(stream, encodedTransactionMetaV3.ext);
+ LedgerEntryChanges.encode(stream, encodedTransactionMetaV3.txChangesBefore);
+ int operationssize = encodedTransactionMetaV3.getOperations().length;
+ stream.writeInt(operationssize);
+ for (int i = 0; i < operationssize; i++) {
+ OperationMeta.encode(stream, encodedTransactionMetaV3.operations[i]);
+ }
+ LedgerEntryChanges.encode(stream, encodedTransactionMetaV3.txChangesAfter);
+ if (encodedTransactionMetaV3.sorobanMeta != null) {
+ stream.writeInt(1);
+ SorobanTransactionMeta.encode(stream, encodedTransactionMetaV3.sorobanMeta);
+ } else {
+ stream.writeInt(0);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static TransactionMetaV3 decode(XdrDataInputStream stream) throws IOException {
+ TransactionMetaV3 decodedTransactionMetaV3 = new TransactionMetaV3();
+ decodedTransactionMetaV3.ext = ExtensionPoint.decode(stream);
+ decodedTransactionMetaV3.txChangesBefore = LedgerEntryChanges.decode(stream);
+ int operationssize = stream.readInt();
+ decodedTransactionMetaV3.operations = new OperationMeta[operationssize];
+ for (int i = 0; i < operationssize; i++) {
+ decodedTransactionMetaV3.operations[i] = OperationMeta.decode(stream);
+ }
+ decodedTransactionMetaV3.txChangesAfter = LedgerEntryChanges.decode(stream);
+ int sorobanMetaPresent = stream.readInt();
+ if (sorobanMetaPresent != 0) {
+ decodedTransactionMetaV3.sorobanMeta = SorobanTransactionMeta.decode(stream);
+ }
+ return decodedTransactionMetaV3;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ this.ext,
+ this.txChangesBefore,
+ Arrays.hashCode(this.operations),
+ this.txChangesAfter,
+ this.sorobanMeta);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof TransactionMetaV3)) {
+ return false;
+ }
+
+ TransactionMetaV3 other = (TransactionMetaV3) object;
+ return Objects.equals(this.ext, other.ext)
+ && Objects.equals(this.txChangesBefore, other.txChangesBefore)
+ && Arrays.equals(this.operations, other.operations)
+ && Objects.equals(this.txChangesAfter, other.txChangesAfter)
+ && Objects.equals(this.sorobanMeta, other.sorobanMeta);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionMetaV3 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionMetaV3 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private ExtensionPoint ext;
+ private LedgerEntryChanges txChangesBefore;
+ private OperationMeta[] operations;
+ private LedgerEntryChanges txChangesAfter;
+ private SorobanTransactionMeta sorobanMeta;
+
+ public Builder ext(ExtensionPoint ext) {
+ this.ext = ext;
+ return this;
+ }
+
+ public Builder txChangesBefore(LedgerEntryChanges txChangesBefore) {
+ this.txChangesBefore = txChangesBefore;
+ return this;
+ }
+
+ public Builder operations(OperationMeta[] operations) {
+ this.operations = operations;
+ return this;
+ }
+
+ public Builder txChangesAfter(LedgerEntryChanges txChangesAfter) {
+ this.txChangesAfter = txChangesAfter;
+ return this;
+ }
+
+ public Builder sorobanMeta(SorobanTransactionMeta sorobanMeta) {
+ this.sorobanMeta = sorobanMeta;
+ return this;
+ }
+
+ public TransactionMetaV3 build() {
+ TransactionMetaV3 val = new TransactionMetaV3();
+ val.setExt(this.ext);
+ val.setTxChangesBefore(this.txChangesBefore);
+ val.setOperations(this.operations);
+ val.setTxChangesAfter(this.txChangesAfter);
+ val.setSorobanMeta(this.sorobanMeta);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionPhase.java b/src/main/java/org/stellar/sdk/xdr/TransactionPhase.java
new file mode 100644
index 000000000..8df20aff5
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionPhase.java
@@ -0,0 +1,143 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union TransactionPhase switch (int v)
+// {
+// case 0:
+// TxSetComponent v0Components<>;
+// };
+
+// ===========================================================================
+public class TransactionPhase implements XdrElement {
+ public TransactionPhase() {}
+
+ Integer v;
+
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+
+ private TxSetComponent[] v0Components;
+
+ public TxSetComponent[] getV0Components() {
+ return this.v0Components;
+ }
+
+ public void setV0Components(TxSetComponent[] value) {
+ this.v0Components = value;
+ }
+
+ public static final class Builder {
+ private Integer discriminant;
+ private TxSetComponent[] v0Components;
+
+ public Builder discriminant(Integer discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder v0Components(TxSetComponent[] v0Components) {
+ this.v0Components = v0Components;
+ return this;
+ }
+
+ public TransactionPhase build() {
+ TransactionPhase val = new TransactionPhase();
+ val.setDiscriminant(discriminant);
+ val.setV0Components(this.v0Components);
+ return val;
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, TransactionPhase encodedTransactionPhase)
+ throws IOException {
+ // Xdrgen::AST::Typespecs::Int
+ // Integer
+ stream.writeInt(encodedTransactionPhase.getDiscriminant().intValue());
+ switch (encodedTransactionPhase.getDiscriminant()) {
+ case 0:
+ int v0Componentssize = encodedTransactionPhase.getV0Components().length;
+ stream.writeInt(v0Componentssize);
+ for (int i = 0; i < v0Componentssize; i++) {
+ TxSetComponent.encode(stream, encodedTransactionPhase.v0Components[i]);
+ }
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static TransactionPhase decode(XdrDataInputStream stream) throws IOException {
+ TransactionPhase decodedTransactionPhase = new TransactionPhase();
+ Integer discriminant = stream.readInt();
+ decodedTransactionPhase.setDiscriminant(discriminant);
+ switch (decodedTransactionPhase.getDiscriminant()) {
+ case 0:
+ int v0Componentssize = stream.readInt();
+ decodedTransactionPhase.v0Components = new TxSetComponent[v0Componentssize];
+ for (int i = 0; i < v0Componentssize; i++) {
+ decodedTransactionPhase.v0Components[i] = TxSetComponent.decode(stream);
+ }
+ break;
+ }
+ return decodedTransactionPhase;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(Arrays.hashCode(this.v0Components), this.v);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof TransactionPhase)) {
+ return false;
+ }
+
+ TransactionPhase other = (TransactionPhase) object;
+ return Arrays.equals(this.v0Components, other.v0Components) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionPhase fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionPhase fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionResult.java b/src/main/java/org/stellar/sdk/xdr/TransactionResult.java
index 13032d1de..f4acced97 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionResult.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionResult.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -21,7 +26,22 @@
// case txSUCCESS:
// case txFAILED:
// OperationResult results<>;
-// default:
+// case txTOO_EARLY:
+// case txTOO_LATE:
+// case txMISSING_OPERATION:
+// case txBAD_SEQ:
+// case txBAD_AUTH:
+// case txINSUFFICIENT_BALANCE:
+// case txNO_ACCOUNT:
+// case txINSUFFICIENT_FEE:
+// case txBAD_AUTH_EXTRA:
+// case txINTERNAL_ERROR:
+// case txNOT_SUPPORTED:
+// // case txFEE_BUMP_INNER_FAILED: handled above
+// case txBAD_SPONSORSHIP:
+// case txBAD_MIN_SEQ_AGE_OR_GAP:
+// case txMALFORMED:
+// case txSOROBAN_INVALID:
// void;
// }
// result;
@@ -90,7 +110,7 @@ public static TransactionResult decode(XdrDataInputStream stream) throws IOExcep
@Override
public int hashCode() {
- return Objects.hashCode(this.feeCharged, this.result, this.ext);
+ return Objects.hash(this.feeCharged, this.result, this.ext);
}
@Override
@@ -100,9 +120,33 @@ public boolean equals(Object object) {
}
TransactionResult other = (TransactionResult) object;
- return Objects.equal(this.feeCharged, other.feeCharged)
- && Objects.equal(this.result, other.result)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.feeCharged, other.feeCharged)
+ && Objects.equals(this.result, other.result)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -127,14 +171,14 @@ public Builder ext(TransactionResultExt ext) {
public TransactionResult build() {
TransactionResult val = new TransactionResult();
- val.setFeeCharged(feeCharged);
- val.setResult(result);
- val.setExt(ext);
+ val.setFeeCharged(this.feeCharged);
+ val.setResult(this.result);
+ val.setExt(this.ext);
return val;
}
}
- public static class TransactionResultResult {
+ public static class TransactionResultResult implements XdrElement {
public TransactionResultResult() {}
TransactionResultCode code;
@@ -190,8 +234,8 @@ public Builder results(OperationResult[] results) {
public TransactionResultResult build() {
TransactionResultResult val = new TransactionResultResult();
val.setDiscriminant(discriminant);
- val.setInnerResultPair(innerResultPair);
- val.setResults(results);
+ val.setInnerResultPair(this.innerResultPair);
+ val.setResults(this.results);
return val;
}
}
@@ -215,7 +259,21 @@ public static void encode(
OperationResult.encode(stream, encodedTransactionResultResult.results[i]);
}
break;
- default:
+ case txTOO_EARLY:
+ case txTOO_LATE:
+ case txMISSING_OPERATION:
+ case txBAD_SEQ:
+ case txBAD_AUTH:
+ case txINSUFFICIENT_BALANCE:
+ case txNO_ACCOUNT:
+ case txINSUFFICIENT_FEE:
+ case txBAD_AUTH_EXTRA:
+ case txINTERNAL_ERROR:
+ case txNOT_SUPPORTED:
+ case txBAD_SPONSORSHIP:
+ case txBAD_MIN_SEQ_AGE_OR_GAP:
+ case txMALFORMED:
+ case txSOROBAN_INVALID:
break;
}
}
@@ -242,7 +300,21 @@ public static TransactionResultResult decode(XdrDataInputStream stream) throws I
decodedTransactionResultResult.results[i] = OperationResult.decode(stream);
}
break;
- default:
+ case txTOO_EARLY:
+ case txTOO_LATE:
+ case txMISSING_OPERATION:
+ case txBAD_SEQ:
+ case txBAD_AUTH:
+ case txINSUFFICIENT_BALANCE:
+ case txNO_ACCOUNT:
+ case txINSUFFICIENT_FEE:
+ case txBAD_AUTH_EXTRA:
+ case txINTERNAL_ERROR:
+ case txNOT_SUPPORTED:
+ case txBAD_SPONSORSHIP:
+ case txBAD_MIN_SEQ_AGE_OR_GAP:
+ case txMALFORMED:
+ case txSOROBAN_INVALID:
break;
}
return decodedTransactionResultResult;
@@ -250,7 +322,7 @@ public static TransactionResultResult decode(XdrDataInputStream stream) throws I
@Override
public int hashCode() {
- return Objects.hashCode(this.innerResultPair, Arrays.hashCode(this.results), this.code);
+ return Objects.hash(this.innerResultPair, Arrays.hashCode(this.results), this.code);
}
@Override
@@ -260,13 +332,37 @@ public boolean equals(Object object) {
}
TransactionResultResult other = (TransactionResultResult) object;
- return Objects.equal(this.innerResultPair, other.innerResultPair)
+ return Objects.equals(this.innerResultPair, other.innerResultPair)
&& Arrays.equals(this.results, other.results)
- && Objects.equal(this.code, other.code);
+ && Objects.equals(this.code, other.code);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionResultResult fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionResultResult fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
- public static class TransactionResultExt {
+ public static class TransactionResultExt implements XdrElement {
public TransactionResultExt() {}
Integer v;
@@ -323,7 +419,7 @@ public static TransactionResultExt decode(XdrDataInputStream stream) throws IOEx
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -333,7 +429,31 @@ public boolean equals(Object object) {
}
TransactionResultExt other = (TransactionResultExt) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionResultExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionResultExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionResultCode.java b/src/main/java/org/stellar/sdk/xdr/TransactionResultCode.java
index fa7134edc..b8fe71cd7 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionResultCode.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionResultCode.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -26,12 +31,12 @@
// txBAD_AUTH_EXTRA = -10, // unused signatures attached to transaction
// txINTERNAL_ERROR = -11, // an unknown error occurred
//
-// txNOT_SUPPORTED = -12, // transaction type not supported
-// txFEE_BUMP_INNER_FAILED = -13, // fee bump inner transaction failed
-// txBAD_SPONSORSHIP = -14, // sponsorship not confirmed
-// txBAD_MIN_SEQ_AGE_OR_GAP =
-// -15, // minSeqAge or minSeqLedgerGap conditions not met
-// txMALFORMED = -16 // precondition is invalid
+// txNOT_SUPPORTED = -12, // transaction type not supported
+// txFEE_BUMP_INNER_FAILED = -13, // fee bump inner transaction failed
+// txBAD_SPONSORSHIP = -14, // sponsorship not confirmed
+// txBAD_MIN_SEQ_AGE_OR_GAP = -15, // minSeqAge or minSeqLedgerGap conditions not met
+// txMALFORMED = -16, // precondition is invalid
+// txSOROBAN_INVALID = -17 // soroban-specific preconditions were not met
// };
// ===========================================================================
@@ -54,6 +59,7 @@ public enum TransactionResultCode implements XdrElement {
txBAD_SPONSORSHIP(-14),
txBAD_MIN_SEQ_AGE_OR_GAP(-15),
txMALFORMED(-16),
+ txSOROBAN_INVALID(-17),
;
private int mValue;
@@ -104,6 +110,8 @@ public static TransactionResultCode decode(XdrDataInputStream stream) throws IOE
return txBAD_MIN_SEQ_AGE_OR_GAP;
case -16:
return txMALFORMED;
+ case -17:
+ return txSOROBAN_INVALID;
default:
throw new RuntimeException("Unknown enum value: " + value);
}
@@ -117,4 +125,28 @@ public static void encode(XdrDataOutputStream stream, TransactionResultCode valu
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionResultCode fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionResultCode fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionResultMeta.java b/src/main/java/org/stellar/sdk/xdr/TransactionResultMeta.java
index b1576aa09..a1c031ba4 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionResultMeta.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionResultMeta.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -71,7 +76,7 @@ public static TransactionResultMeta decode(XdrDataInputStream stream) throws IOE
@Override
public int hashCode() {
- return Objects.hashCode(this.result, this.feeProcessing, this.txApplyProcessing);
+ return Objects.hash(this.result, this.feeProcessing, this.txApplyProcessing);
}
@Override
@@ -81,9 +86,33 @@ public boolean equals(Object object) {
}
TransactionResultMeta other = (TransactionResultMeta) object;
- return Objects.equal(this.result, other.result)
- && Objects.equal(this.feeProcessing, other.feeProcessing)
- && Objects.equal(this.txApplyProcessing, other.txApplyProcessing);
+ return Objects.equals(this.result, other.result)
+ && Objects.equals(this.feeProcessing, other.feeProcessing)
+ && Objects.equals(this.txApplyProcessing, other.txApplyProcessing);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionResultMeta fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionResultMeta fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -108,9 +137,9 @@ public Builder txApplyProcessing(TransactionMeta txApplyProcessing) {
public TransactionResultMeta build() {
TransactionResultMeta val = new TransactionResultMeta();
- val.setResult(result);
- val.setFeeProcessing(feeProcessing);
- val.setTxApplyProcessing(txApplyProcessing);
+ val.setResult(this.result);
+ val.setFeeProcessing(this.feeProcessing);
+ val.setTxApplyProcessing(this.txApplyProcessing);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionResultPair.java b/src/main/java/org/stellar/sdk/xdr/TransactionResultPair.java
index f925e376f..3ba025093 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionResultPair.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionResultPair.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -58,7 +63,7 @@ public static TransactionResultPair decode(XdrDataInputStream stream) throws IOE
@Override
public int hashCode() {
- return Objects.hashCode(this.transactionHash, this.result);
+ return Objects.hash(this.transactionHash, this.result);
}
@Override
@@ -68,8 +73,32 @@ public boolean equals(Object object) {
}
TransactionResultPair other = (TransactionResultPair) object;
- return Objects.equal(this.transactionHash, other.transactionHash)
- && Objects.equal(this.result, other.result);
+ return Objects.equals(this.transactionHash, other.transactionHash)
+ && Objects.equals(this.result, other.result);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionResultPair fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionResultPair fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -88,8 +117,8 @@ public Builder result(TransactionResult result) {
public TransactionResultPair build() {
TransactionResultPair val = new TransactionResultPair();
- val.setTransactionHash(transactionHash);
- val.setResult(result);
+ val.setTransactionHash(this.transactionHash);
+ val.setResult(this.result);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionResultSet.java b/src/main/java/org/stellar/sdk/xdr/TransactionResultSet.java
index c16007de8..4c06be4f1 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionResultSet.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionResultSet.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -66,6 +71,30 @@ public boolean equals(Object object) {
return Arrays.equals(this.results, other.results);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionResultSet fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionResultSet fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private TransactionResultPair[] results;
@@ -76,7 +105,7 @@ public Builder results(TransactionResultPair[] results) {
public TransactionResultSet build() {
TransactionResultSet val = new TransactionResultSet();
- val.setResults(results);
+ val.setResults(this.results);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionSet.java b/src/main/java/org/stellar/sdk/xdr/TransactionSet.java
index 7e83e7156..8719f592c 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionSet.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionSet.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -66,7 +71,7 @@ public static TransactionSet decode(XdrDataInputStream stream) throws IOExceptio
@Override
public int hashCode() {
- return Objects.hashCode(this.previousLedgerHash, Arrays.hashCode(this.txs));
+ return Objects.hash(this.previousLedgerHash, Arrays.hashCode(this.txs));
}
@Override
@@ -76,10 +81,34 @@ public boolean equals(Object object) {
}
TransactionSet other = (TransactionSet) object;
- return Objects.equal(this.previousLedgerHash, other.previousLedgerHash)
+ return Objects.equals(this.previousLedgerHash, other.previousLedgerHash)
&& Arrays.equals(this.txs, other.txs);
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionSet fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionSet fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
public static final class Builder {
private Hash previousLedgerHash;
private TransactionEnvelope[] txs;
@@ -96,8 +125,8 @@ public Builder txs(TransactionEnvelope[] txs) {
public TransactionSet build() {
TransactionSet val = new TransactionSet();
- val.setPreviousLedgerHash(previousLedgerHash);
- val.setTxs(txs);
+ val.setPreviousLedgerHash(this.previousLedgerHash);
+ val.setTxs(this.txs);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionSetV1.java b/src/main/java/org/stellar/sdk/xdr/TransactionSetV1.java
new file mode 100644
index 000000000..3fcd7d818
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionSetV1.java
@@ -0,0 +1,133 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct TransactionSetV1
+// {
+// Hash previousLedgerHash;
+// TransactionPhase phases<>;
+// };
+
+// ===========================================================================
+public class TransactionSetV1 implements XdrElement {
+ public TransactionSetV1() {}
+
+ private Hash previousLedgerHash;
+
+ public Hash getPreviousLedgerHash() {
+ return this.previousLedgerHash;
+ }
+
+ public void setPreviousLedgerHash(Hash value) {
+ this.previousLedgerHash = value;
+ }
+
+ private TransactionPhase[] phases;
+
+ public TransactionPhase[] getPhases() {
+ return this.phases;
+ }
+
+ public void setPhases(TransactionPhase[] value) {
+ this.phases = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, TransactionSetV1 encodedTransactionSetV1)
+ throws IOException {
+ Hash.encode(stream, encodedTransactionSetV1.previousLedgerHash);
+ int phasessize = encodedTransactionSetV1.getPhases().length;
+ stream.writeInt(phasessize);
+ for (int i = 0; i < phasessize; i++) {
+ TransactionPhase.encode(stream, encodedTransactionSetV1.phases[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static TransactionSetV1 decode(XdrDataInputStream stream) throws IOException {
+ TransactionSetV1 decodedTransactionSetV1 = new TransactionSetV1();
+ decodedTransactionSetV1.previousLedgerHash = Hash.decode(stream);
+ int phasessize = stream.readInt();
+ decodedTransactionSetV1.phases = new TransactionPhase[phasessize];
+ for (int i = 0; i < phasessize; i++) {
+ decodedTransactionSetV1.phases[i] = TransactionPhase.decode(stream);
+ }
+ return decodedTransactionSetV1;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.previousLedgerHash, Arrays.hashCode(this.phases));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof TransactionSetV1)) {
+ return false;
+ }
+
+ TransactionSetV1 other = (TransactionSetV1) object;
+ return Objects.equals(this.previousLedgerHash, other.previousLedgerHash)
+ && Arrays.equals(this.phases, other.phases);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionSetV1 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionSetV1 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Hash previousLedgerHash;
+ private TransactionPhase[] phases;
+
+ public Builder previousLedgerHash(Hash previousLedgerHash) {
+ this.previousLedgerHash = previousLedgerHash;
+ return this;
+ }
+
+ public Builder phases(TransactionPhase[] phases) {
+ this.phases = phases;
+ return this;
+ }
+
+ public TransactionSetV1 build() {
+ TransactionSetV1 val = new TransactionSetV1();
+ val.setPreviousLedgerHash(this.previousLedgerHash);
+ val.setPhases(this.phases);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionSignaturePayload.java b/src/main/java/org/stellar/sdk/xdr/TransactionSignaturePayload.java
index a15eb3dc3..88820c66b 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionSignaturePayload.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionSignaturePayload.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -69,7 +74,7 @@ public static TransactionSignaturePayload decode(XdrDataInputStream stream) thro
@Override
public int hashCode() {
- return Objects.hashCode(this.networkId, this.taggedTransaction);
+ return Objects.hash(this.networkId, this.taggedTransaction);
}
@Override
@@ -79,8 +84,32 @@ public boolean equals(Object object) {
}
TransactionSignaturePayload other = (TransactionSignaturePayload) object;
- return Objects.equal(this.networkId, other.networkId)
- && Objects.equal(this.taggedTransaction, other.taggedTransaction);
+ return Objects.equals(this.networkId, other.networkId)
+ && Objects.equals(this.taggedTransaction, other.taggedTransaction);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionSignaturePayload fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionSignaturePayload fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -100,13 +129,13 @@ public Builder taggedTransaction(
public TransactionSignaturePayload build() {
TransactionSignaturePayload val = new TransactionSignaturePayload();
- val.setNetworkId(networkId);
- val.setTaggedTransaction(taggedTransaction);
+ val.setNetworkId(this.networkId);
+ val.setTaggedTransaction(this.taggedTransaction);
return val;
}
}
- public static class TransactionSignaturePayloadTaggedTransaction {
+ public static class TransactionSignaturePayloadTaggedTransaction implements XdrElement {
public TransactionSignaturePayloadTaggedTransaction() {}
EnvelopeType type;
@@ -163,8 +192,8 @@ public TransactionSignaturePayloadTaggedTransaction build() {
TransactionSignaturePayloadTaggedTransaction val =
new TransactionSignaturePayloadTaggedTransaction();
val.setDiscriminant(discriminant);
- val.setTx(tx);
- val.setFeeBump(feeBump);
+ val.setTx(this.tx);
+ val.setFeeBump(this.feeBump);
return val;
}
}
@@ -214,7 +243,7 @@ public static TransactionSignaturePayloadTaggedTransaction decode(XdrDataInputSt
@Override
public int hashCode() {
- return Objects.hashCode(this.tx, this.feeBump, this.type);
+ return Objects.hash(this.tx, this.feeBump, this.type);
}
@Override
@@ -225,9 +254,35 @@ public boolean equals(Object object) {
TransactionSignaturePayloadTaggedTransaction other =
(TransactionSignaturePayloadTaggedTransaction) object;
- return Objects.equal(this.tx, other.tx)
- && Objects.equal(this.feeBump, other.feeBump)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.tx, other.tx)
+ && Objects.equals(this.feeBump, other.feeBump)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionSignaturePayloadTaggedTransaction fromXdrBase64(String xdr)
+ throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionSignaturePayloadTaggedTransaction fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionV0.java b/src/main/java/org/stellar/sdk/xdr/TransactionV0.java
index cfaa8b6ce..9b7d5228f 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionV0.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionV0.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -144,7 +149,7 @@ public static TransactionV0 decode(XdrDataInputStream stream) throws IOException
@Override
public int hashCode() {
- return Objects.hashCode(
+ return Objects.hash(
this.sourceAccountEd25519,
this.fee,
this.seqNum,
@@ -161,13 +166,37 @@ public boolean equals(Object object) {
}
TransactionV0 other = (TransactionV0) object;
- return Objects.equal(this.sourceAccountEd25519, other.sourceAccountEd25519)
- && Objects.equal(this.fee, other.fee)
- && Objects.equal(this.seqNum, other.seqNum)
- && Objects.equal(this.timeBounds, other.timeBounds)
- && Objects.equal(this.memo, other.memo)
+ return Objects.equals(this.sourceAccountEd25519, other.sourceAccountEd25519)
+ && Objects.equals(this.fee, other.fee)
+ && Objects.equals(this.seqNum, other.seqNum)
+ && Objects.equals(this.timeBounds, other.timeBounds)
+ && Objects.equals(this.memo, other.memo)
&& Arrays.equals(this.operations, other.operations)
- && Objects.equal(this.ext, other.ext);
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionV0 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionV0 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -216,18 +245,18 @@ public Builder ext(TransactionV0Ext ext) {
public TransactionV0 build() {
TransactionV0 val = new TransactionV0();
- val.setSourceAccountEd25519(sourceAccountEd25519);
- val.setFee(fee);
- val.setSeqNum(seqNum);
- val.setTimeBounds(timeBounds);
- val.setMemo(memo);
- val.setOperations(operations);
- val.setExt(ext);
+ val.setSourceAccountEd25519(this.sourceAccountEd25519);
+ val.setFee(this.fee);
+ val.setSeqNum(this.seqNum);
+ val.setTimeBounds(this.timeBounds);
+ val.setMemo(this.memo);
+ val.setOperations(this.operations);
+ val.setExt(this.ext);
return val;
}
}
- public static class TransactionV0Ext {
+ public static class TransactionV0Ext implements XdrElement {
public TransactionV0Ext() {}
Integer v;
@@ -283,7 +312,7 @@ public static TransactionV0Ext decode(XdrDataInputStream stream) throws IOExcept
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -293,7 +322,31 @@ public boolean equals(Object object) {
}
TransactionV0Ext other = (TransactionV0Ext) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionV0Ext fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionV0Ext fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionV0Envelope.java b/src/main/java/org/stellar/sdk/xdr/TransactionV0Envelope.java
index 90892b658..51b1b870d 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionV0Envelope.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionV0Envelope.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -69,7 +74,7 @@ public static TransactionV0Envelope decode(XdrDataInputStream stream) throws IOE
@Override
public int hashCode() {
- return Objects.hashCode(this.tx, Arrays.hashCode(this.signatures));
+ return Objects.hash(this.tx, Arrays.hashCode(this.signatures));
}
@Override
@@ -79,7 +84,31 @@ public boolean equals(Object object) {
}
TransactionV0Envelope other = (TransactionV0Envelope) object;
- return Objects.equal(this.tx, other.tx) && Arrays.equals(this.signatures, other.signatures);
+ return Objects.equals(this.tx, other.tx) && Arrays.equals(this.signatures, other.signatures);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionV0Envelope fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionV0Envelope fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -98,8 +127,8 @@ public Builder signatures(DecoratedSignature[] signatures) {
public TransactionV0Envelope build() {
TransactionV0Envelope val = new TransactionV0Envelope();
- val.setTx(tx);
- val.setSignatures(signatures);
+ val.setTx(this.tx);
+ val.setSignatures(this.signatures);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionV1Envelope.java b/src/main/java/org/stellar/sdk/xdr/TransactionV1Envelope.java
index be2118dcc..6ea151351 100644
--- a/src/main/java/org/stellar/sdk/xdr/TransactionV1Envelope.java
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionV1Envelope.java
@@ -3,9 +3,14 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -69,7 +74,7 @@ public static TransactionV1Envelope decode(XdrDataInputStream stream) throws IOE
@Override
public int hashCode() {
- return Objects.hashCode(this.tx, Arrays.hashCode(this.signatures));
+ return Objects.hash(this.tx, Arrays.hashCode(this.signatures));
}
@Override
@@ -79,7 +84,31 @@ public boolean equals(Object object) {
}
TransactionV1Envelope other = (TransactionV1Envelope) object;
- return Objects.equal(this.tx, other.tx) && Arrays.equals(this.signatures, other.signatures);
+ return Objects.equals(this.tx, other.tx) && Arrays.equals(this.signatures, other.signatures);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TransactionV1Envelope fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TransactionV1Envelope fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -98,8 +127,8 @@ public Builder signatures(DecoratedSignature[] signatures) {
public TransactionV1Envelope build() {
TransactionV1Envelope val = new TransactionV1Envelope();
- val.setTx(tx);
- val.setSignatures(signatures);
+ val.setTx(this.tx);
+ val.setSignatures(this.signatures);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TrustLineAsset.java b/src/main/java/org/stellar/sdk/xdr/TrustLineAsset.java
index b74a7bd62..00e588e4b 100644
--- a/src/main/java/org/stellar/sdk/xdr/TrustLineAsset.java
+++ b/src/main/java/org/stellar/sdk/xdr/TrustLineAsset.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -98,9 +103,9 @@ public Builder liquidityPoolID(PoolID liquidityPoolID) {
public TrustLineAsset build() {
TrustLineAsset val = new TrustLineAsset();
val.setDiscriminant(discriminant);
- val.setAlphaNum4(alphaNum4);
- val.setAlphaNum12(alphaNum12);
- val.setLiquidityPoolID(liquidityPoolID);
+ val.setAlphaNum4(this.alphaNum4);
+ val.setAlphaNum12(this.alphaNum12);
+ val.setLiquidityPoolID(this.liquidityPoolID);
return val;
}
}
@@ -151,7 +156,7 @@ public static TrustLineAsset decode(XdrDataInputStream stream) throws IOExceptio
@Override
public int hashCode() {
- return Objects.hashCode(this.alphaNum4, this.alphaNum12, this.liquidityPoolID, this.type);
+ return Objects.hash(this.alphaNum4, this.alphaNum12, this.liquidityPoolID, this.type);
}
@Override
@@ -161,9 +166,33 @@ public boolean equals(Object object) {
}
TrustLineAsset other = (TrustLineAsset) object;
- return Objects.equal(this.alphaNum4, other.alphaNum4)
- && Objects.equal(this.alphaNum12, other.alphaNum12)
- && Objects.equal(this.liquidityPoolID, other.liquidityPoolID)
- && Objects.equal(this.type, other.type);
+ return Objects.equals(this.alphaNum4, other.alphaNum4)
+ && Objects.equals(this.alphaNum12, other.alphaNum12)
+ && Objects.equals(this.liquidityPoolID, other.liquidityPoolID)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TrustLineAsset fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TrustLineAsset fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TrustLineEntry.java b/src/main/java/org/stellar/sdk/xdr/TrustLineEntry.java
index fa707f3e6..ee1fc1271 100644
--- a/src/main/java/org/stellar/sdk/xdr/TrustLineEntry.java
+++ b/src/main/java/org/stellar/sdk/xdr/TrustLineEntry.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -132,8 +137,7 @@ public static TrustLineEntry decode(XdrDataInputStream stream) throws IOExceptio
@Override
public int hashCode() {
- return Objects.hashCode(
- this.accountID, this.asset, this.balance, this.limit, this.flags, this.ext);
+ return Objects.hash(this.accountID, this.asset, this.balance, this.limit, this.flags, this.ext);
}
@Override
@@ -143,12 +147,36 @@ public boolean equals(Object object) {
}
TrustLineEntry other = (TrustLineEntry) object;
- return Objects.equal(this.accountID, other.accountID)
- && Objects.equal(this.asset, other.asset)
- && Objects.equal(this.balance, other.balance)
- && Objects.equal(this.limit, other.limit)
- && Objects.equal(this.flags, other.flags)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.accountID, other.accountID)
+ && Objects.equals(this.asset, other.asset)
+ && Objects.equals(this.balance, other.balance)
+ && Objects.equals(this.limit, other.limit)
+ && Objects.equals(this.flags, other.flags)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TrustLineEntry fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TrustLineEntry fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -191,17 +219,17 @@ public Builder ext(TrustLineEntryExt ext) {
public TrustLineEntry build() {
TrustLineEntry val = new TrustLineEntry();
- val.setAccountID(accountID);
- val.setAsset(asset);
- val.setBalance(balance);
- val.setLimit(limit);
- val.setFlags(flags);
- val.setExt(ext);
+ val.setAccountID(this.accountID);
+ val.setAsset(this.asset);
+ val.setBalance(this.balance);
+ val.setLimit(this.limit);
+ val.setFlags(this.flags);
+ val.setExt(this.ext);
return val;
}
}
- public static class TrustLineEntryExt {
+ public static class TrustLineEntryExt implements XdrElement {
public TrustLineEntryExt() {}
Integer v;
@@ -241,7 +269,7 @@ public Builder v1(TrustLineEntryV1 v1) {
public TrustLineEntryExt build() {
TrustLineEntryExt val = new TrustLineEntryExt();
val.setDiscriminant(discriminant);
- val.setV1(v1);
+ val.setV1(this.v1);
return val;
}
}
@@ -280,7 +308,7 @@ public static TrustLineEntryExt decode(XdrDataInputStream stream) throws IOExcep
@Override
public int hashCode() {
- return Objects.hashCode(this.v1, this.v);
+ return Objects.hash(this.v1, this.v);
}
@Override
@@ -290,10 +318,34 @@ public boolean equals(Object object) {
}
TrustLineEntryExt other = (TrustLineEntryExt) object;
- return Objects.equal(this.v1, other.v1) && Objects.equal(this.v, other.v);
+ return Objects.equals(this.v1, other.v1) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TrustLineEntryExt fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TrustLineEntryExt fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
- public static class TrustLineEntryV1 {
+ public static class TrustLineEntryV1 implements XdrElement {
public TrustLineEntryV1() {}
private Liabilities liabilities;
@@ -335,7 +387,7 @@ public static TrustLineEntryV1 decode(XdrDataInputStream stream) throws IOExcept
@Override
public int hashCode() {
- return Objects.hashCode(this.liabilities, this.ext);
+ return Objects.hash(this.liabilities, this.ext);
}
@Override
@@ -345,8 +397,32 @@ public boolean equals(Object object) {
}
TrustLineEntryV1 other = (TrustLineEntryV1) object;
- return Objects.equal(this.liabilities, other.liabilities)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.liabilities, other.liabilities)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TrustLineEntryV1 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TrustLineEntryV1 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -365,13 +441,13 @@ public Builder ext(TrustLineEntryV1Ext ext) {
public TrustLineEntryV1 build() {
TrustLineEntryV1 val = new TrustLineEntryV1();
- val.setLiabilities(liabilities);
- val.setExt(ext);
+ val.setLiabilities(this.liabilities);
+ val.setExt(this.ext);
return val;
}
}
- public static class TrustLineEntryV1Ext {
+ public static class TrustLineEntryV1Ext implements XdrElement {
public TrustLineEntryV1Ext() {}
Integer v;
@@ -411,7 +487,7 @@ public Builder v2(TrustLineEntryExtensionV2 v2) {
public TrustLineEntryV1Ext build() {
TrustLineEntryV1Ext val = new TrustLineEntryV1Ext();
val.setDiscriminant(discriminant);
- val.setV2(v2);
+ val.setV2(this.v2);
return val;
}
}
@@ -451,7 +527,7 @@ public static TrustLineEntryV1Ext decode(XdrDataInputStream stream) throws IOExc
@Override
public int hashCode() {
- return Objects.hashCode(this.v2, this.v);
+ return Objects.hash(this.v2, this.v);
}
@Override
@@ -461,7 +537,31 @@ public boolean equals(Object object) {
}
TrustLineEntryV1Ext other = (TrustLineEntryV1Ext) object;
- return Objects.equal(this.v2, other.v2) && Objects.equal(this.v, other.v);
+ return Objects.equals(this.v2, other.v2) && Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TrustLineEntryV1Ext fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TrustLineEntryV1Ext fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TrustLineEntryExtensionV2.java b/src/main/java/org/stellar/sdk/xdr/TrustLineEntryExtensionV2.java
index cd08a15ab..57f7b0e2c 100644
--- a/src/main/java/org/stellar/sdk/xdr/TrustLineEntryExtensionV2.java
+++ b/src/main/java/org/stellar/sdk/xdr/TrustLineEntryExtensionV2.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -64,7 +69,7 @@ public static TrustLineEntryExtensionV2 decode(XdrDataInputStream stream) throws
@Override
public int hashCode() {
- return Objects.hashCode(this.liquidityPoolUseCount, this.ext);
+ return Objects.hash(this.liquidityPoolUseCount, this.ext);
}
@Override
@@ -74,8 +79,32 @@ public boolean equals(Object object) {
}
TrustLineEntryExtensionV2 other = (TrustLineEntryExtensionV2) object;
- return Objects.equal(this.liquidityPoolUseCount, other.liquidityPoolUseCount)
- && Objects.equal(this.ext, other.ext);
+ return Objects.equals(this.liquidityPoolUseCount, other.liquidityPoolUseCount)
+ && Objects.equals(this.ext, other.ext);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TrustLineEntryExtensionV2 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TrustLineEntryExtensionV2 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -94,13 +123,13 @@ public Builder ext(TrustLineEntryExtensionV2Ext ext) {
public TrustLineEntryExtensionV2 build() {
TrustLineEntryExtensionV2 val = new TrustLineEntryExtensionV2();
- val.setLiquidityPoolUseCount(liquidityPoolUseCount);
- val.setExt(ext);
+ val.setLiquidityPoolUseCount(this.liquidityPoolUseCount);
+ val.setExt(this.ext);
return val;
}
}
- public static class TrustLineEntryExtensionV2Ext {
+ public static class TrustLineEntryExtensionV2Ext implements XdrElement {
public TrustLineEntryExtensionV2Ext() {}
Integer v;
@@ -160,7 +189,7 @@ public static TrustLineEntryExtensionV2Ext decode(XdrDataInputStream stream)
@Override
public int hashCode() {
- return Objects.hashCode(this.v);
+ return Objects.hash(this.v);
}
@Override
@@ -170,7 +199,31 @@ public boolean equals(Object object) {
}
TrustLineEntryExtensionV2Ext other = (TrustLineEntryExtensionV2Ext) object;
- return Objects.equal(this.v, other.v);
+ return Objects.equals(this.v, other.v);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TrustLineEntryExtensionV2Ext fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TrustLineEntryExtensionV2Ext fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TrustLineFlags.java b/src/main/java/org/stellar/sdk/xdr/TrustLineFlags.java
index 24303725c..78df565f5 100644
--- a/src/main/java/org/stellar/sdk/xdr/TrustLineFlags.java
+++ b/src/main/java/org/stellar/sdk/xdr/TrustLineFlags.java
@@ -3,7 +3,12 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
// === xdr source ============================================================
@@ -56,4 +61,28 @@ public static void encode(XdrDataOutputStream stream, TrustLineFlags value) thro
public void encode(XdrDataOutputStream stream) throws IOException {
encode(stream, this);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TrustLineFlags fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TrustLineFlags fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/TxAdvertVector.java b/src/main/java/org/stellar/sdk/xdr/TxAdvertVector.java
new file mode 100644
index 000000000..347eae01b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TxAdvertVector.java
@@ -0,0 +1,97 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// typedef Hash TxAdvertVector;
+
+// ===========================================================================
+public class TxAdvertVector implements XdrElement {
+ private Hash[] TxAdvertVector;
+
+ public TxAdvertVector() {}
+
+ public TxAdvertVector(Hash[] TxAdvertVector) {
+ this.TxAdvertVector = TxAdvertVector;
+ }
+
+ public Hash[] getTxAdvertVector() {
+ return this.TxAdvertVector;
+ }
+
+ public void setTxAdvertVector(Hash[] value) {
+ this.TxAdvertVector = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, TxAdvertVector encodedTxAdvertVector)
+ throws IOException {
+ int TxAdvertVectorsize = encodedTxAdvertVector.getTxAdvertVector().length;
+ stream.writeInt(TxAdvertVectorsize);
+ for (int i = 0; i < TxAdvertVectorsize; i++) {
+ Hash.encode(stream, encodedTxAdvertVector.TxAdvertVector[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static TxAdvertVector decode(XdrDataInputStream stream) throws IOException {
+ TxAdvertVector decodedTxAdvertVector = new TxAdvertVector();
+ int TxAdvertVectorsize = stream.readInt();
+ decodedTxAdvertVector.TxAdvertVector = new Hash[TxAdvertVectorsize];
+ for (int i = 0; i < TxAdvertVectorsize; i++) {
+ decodedTxAdvertVector.TxAdvertVector[i] = Hash.decode(stream);
+ }
+ return decodedTxAdvertVector;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(this.TxAdvertVector);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof TxAdvertVector)) {
+ return false;
+ }
+
+ TxAdvertVector other = (TxAdvertVector) object;
+ return Arrays.equals(this.TxAdvertVector, other.TxAdvertVector);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TxAdvertVector fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TxAdvertVector fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TxDemandVector.java b/src/main/java/org/stellar/sdk/xdr/TxDemandVector.java
new file mode 100644
index 000000000..7d7d9f989
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TxDemandVector.java
@@ -0,0 +1,97 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// typedef Hash TxDemandVector;
+
+// ===========================================================================
+public class TxDemandVector implements XdrElement {
+ private Hash[] TxDemandVector;
+
+ public TxDemandVector() {}
+
+ public TxDemandVector(Hash[] TxDemandVector) {
+ this.TxDemandVector = TxDemandVector;
+ }
+
+ public Hash[] getTxDemandVector() {
+ return this.TxDemandVector;
+ }
+
+ public void setTxDemandVector(Hash[] value) {
+ this.TxDemandVector = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, TxDemandVector encodedTxDemandVector)
+ throws IOException {
+ int TxDemandVectorsize = encodedTxDemandVector.getTxDemandVector().length;
+ stream.writeInt(TxDemandVectorsize);
+ for (int i = 0; i < TxDemandVectorsize; i++) {
+ Hash.encode(stream, encodedTxDemandVector.TxDemandVector[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static TxDemandVector decode(XdrDataInputStream stream) throws IOException {
+ TxDemandVector decodedTxDemandVector = new TxDemandVector();
+ int TxDemandVectorsize = stream.readInt();
+ decodedTxDemandVector.TxDemandVector = new Hash[TxDemandVectorsize];
+ for (int i = 0; i < TxDemandVectorsize; i++) {
+ decodedTxDemandVector.TxDemandVector[i] = Hash.decode(stream);
+ }
+ return decodedTxDemandVector;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(this.TxDemandVector);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof TxDemandVector)) {
+ return false;
+ }
+
+ TxDemandVector other = (TxDemandVector) object;
+ return Arrays.equals(this.TxDemandVector, other.TxDemandVector);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TxDemandVector fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TxDemandVector fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TxSetComponent.java b/src/main/java/org/stellar/sdk/xdr/TxSetComponent.java
new file mode 100644
index 000000000..ea7cf8189
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TxSetComponent.java
@@ -0,0 +1,266 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// union TxSetComponent switch (TxSetComponentType type)
+// {
+// case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE:
+// struct
+// {
+// int64* baseFee;
+// TransactionEnvelope txs<>;
+// } txsMaybeDiscountedFee;
+// };
+
+// ===========================================================================
+public class TxSetComponent implements XdrElement {
+ public TxSetComponent() {}
+
+ TxSetComponentType type;
+
+ public TxSetComponentType getDiscriminant() {
+ return this.type;
+ }
+
+ public void setDiscriminant(TxSetComponentType value) {
+ this.type = value;
+ }
+
+ private TxSetComponentTxsMaybeDiscountedFee txsMaybeDiscountedFee;
+
+ public TxSetComponentTxsMaybeDiscountedFee getTxsMaybeDiscountedFee() {
+ return this.txsMaybeDiscountedFee;
+ }
+
+ public void setTxsMaybeDiscountedFee(TxSetComponentTxsMaybeDiscountedFee value) {
+ this.txsMaybeDiscountedFee = value;
+ }
+
+ public static final class Builder {
+ private TxSetComponentType discriminant;
+ private TxSetComponentTxsMaybeDiscountedFee txsMaybeDiscountedFee;
+
+ public Builder discriminant(TxSetComponentType discriminant) {
+ this.discriminant = discriminant;
+ return this;
+ }
+
+ public Builder txsMaybeDiscountedFee(
+ TxSetComponentTxsMaybeDiscountedFee txsMaybeDiscountedFee) {
+ this.txsMaybeDiscountedFee = txsMaybeDiscountedFee;
+ return this;
+ }
+
+ public TxSetComponent build() {
+ TxSetComponent val = new TxSetComponent();
+ val.setDiscriminant(discriminant);
+ val.setTxsMaybeDiscountedFee(this.txsMaybeDiscountedFee);
+ return val;
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, TxSetComponent encodedTxSetComponent)
+ throws IOException {
+ // Xdrgen::AST::Identifier
+ // TxSetComponentType
+ stream.writeInt(encodedTxSetComponent.getDiscriminant().getValue());
+ switch (encodedTxSetComponent.getDiscriminant()) {
+ case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE:
+ TxSetComponentTxsMaybeDiscountedFee.encode(
+ stream, encodedTxSetComponent.txsMaybeDiscountedFee);
+ break;
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static TxSetComponent decode(XdrDataInputStream stream) throws IOException {
+ TxSetComponent decodedTxSetComponent = new TxSetComponent();
+ TxSetComponentType discriminant = TxSetComponentType.decode(stream);
+ decodedTxSetComponent.setDiscriminant(discriminant);
+ switch (decodedTxSetComponent.getDiscriminant()) {
+ case TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE:
+ decodedTxSetComponent.txsMaybeDiscountedFee =
+ TxSetComponentTxsMaybeDiscountedFee.decode(stream);
+ break;
+ }
+ return decodedTxSetComponent;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.txsMaybeDiscountedFee, this.type);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof TxSetComponent)) {
+ return false;
+ }
+
+ TxSetComponent other = (TxSetComponent) object;
+ return Objects.equals(this.txsMaybeDiscountedFee, other.txsMaybeDiscountedFee)
+ && Objects.equals(this.type, other.type);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TxSetComponent fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TxSetComponent fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static class TxSetComponentTxsMaybeDiscountedFee implements XdrElement {
+ public TxSetComponentTxsMaybeDiscountedFee() {}
+
+ private Int64 baseFee;
+
+ public Int64 getBaseFee() {
+ return this.baseFee;
+ }
+
+ public void setBaseFee(Int64 value) {
+ this.baseFee = value;
+ }
+
+ private TransactionEnvelope[] txs;
+
+ public TransactionEnvelope[] getTxs() {
+ return this.txs;
+ }
+
+ public void setTxs(TransactionEnvelope[] value) {
+ this.txs = value;
+ }
+
+ public static void encode(
+ XdrDataOutputStream stream,
+ TxSetComponentTxsMaybeDiscountedFee encodedTxSetComponentTxsMaybeDiscountedFee)
+ throws IOException {
+ if (encodedTxSetComponentTxsMaybeDiscountedFee.baseFee != null) {
+ stream.writeInt(1);
+ Int64.encode(stream, encodedTxSetComponentTxsMaybeDiscountedFee.baseFee);
+ } else {
+ stream.writeInt(0);
+ }
+ int txssize = encodedTxSetComponentTxsMaybeDiscountedFee.getTxs().length;
+ stream.writeInt(txssize);
+ for (int i = 0; i < txssize; i++) {
+ TransactionEnvelope.encode(stream, encodedTxSetComponentTxsMaybeDiscountedFee.txs[i]);
+ }
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static TxSetComponentTxsMaybeDiscountedFee decode(XdrDataInputStream stream)
+ throws IOException {
+ TxSetComponentTxsMaybeDiscountedFee decodedTxSetComponentTxsMaybeDiscountedFee =
+ new TxSetComponentTxsMaybeDiscountedFee();
+ int baseFeePresent = stream.readInt();
+ if (baseFeePresent != 0) {
+ decodedTxSetComponentTxsMaybeDiscountedFee.baseFee = Int64.decode(stream);
+ }
+ int txssize = stream.readInt();
+ decodedTxSetComponentTxsMaybeDiscountedFee.txs = new TransactionEnvelope[txssize];
+ for (int i = 0; i < txssize; i++) {
+ decodedTxSetComponentTxsMaybeDiscountedFee.txs[i] = TransactionEnvelope.decode(stream);
+ }
+ return decodedTxSetComponentTxsMaybeDiscountedFee;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.baseFee, Arrays.hashCode(this.txs));
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof TxSetComponentTxsMaybeDiscountedFee)) {
+ return false;
+ }
+
+ TxSetComponentTxsMaybeDiscountedFee other = (TxSetComponentTxsMaybeDiscountedFee) object;
+ return Objects.equals(this.baseFee, other.baseFee) && Arrays.equals(this.txs, other.txs);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TxSetComponentTxsMaybeDiscountedFee fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TxSetComponentTxsMaybeDiscountedFee fromXdrByteArray(byte[] xdr)
+ throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Int64 baseFee;
+ private TransactionEnvelope[] txs;
+
+ public Builder baseFee(Int64 baseFee) {
+ this.baseFee = baseFee;
+ return this;
+ }
+
+ public Builder txs(TransactionEnvelope[] txs) {
+ this.txs = txs;
+ return this;
+ }
+
+ public TxSetComponentTxsMaybeDiscountedFee build() {
+ TxSetComponentTxsMaybeDiscountedFee val = new TxSetComponentTxsMaybeDiscountedFee();
+ val.setBaseFee(this.baseFee);
+ val.setTxs(this.txs);
+ return val;
+ }
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TxSetComponentType.java b/src/main/java/org/stellar/sdk/xdr/TxSetComponentType.java
new file mode 100644
index 000000000..840db4bb7
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TxSetComponentType.java
@@ -0,0 +1,78 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+
+// === xdr source ============================================================
+
+// enum TxSetComponentType
+// {
+// // txs with effective fee <= bid derived from a base fee (if any).
+// // If base fee is not specified, no discount is applied.
+// TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE = 0
+// };
+
+// ===========================================================================
+public enum TxSetComponentType implements XdrElement {
+ TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE(0),
+ ;
+ private int mValue;
+
+ TxSetComponentType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ public static TxSetComponentType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0:
+ return TXSET_COMP_TXS_MAYBE_DISCOUNTED_FEE;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ public static void encode(XdrDataOutputStream stream, TxSetComponentType value)
+ throws IOException {
+ stream.writeInt(value.getValue());
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static TxSetComponentType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static TxSetComponentType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/UInt128Parts.java b/src/main/java/org/stellar/sdk/xdr/UInt128Parts.java
new file mode 100644
index 000000000..e5516d05d
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/UInt128Parts.java
@@ -0,0 +1,122 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct UInt128Parts {
+// uint64 hi;
+// uint64 lo;
+// };
+
+// ===========================================================================
+public class UInt128Parts implements XdrElement {
+ public UInt128Parts() {}
+
+ private Uint64 hi;
+
+ public Uint64 getHi() {
+ return this.hi;
+ }
+
+ public void setHi(Uint64 value) {
+ this.hi = value;
+ }
+
+ private Uint64 lo;
+
+ public Uint64 getLo() {
+ return this.lo;
+ }
+
+ public void setLo(Uint64 value) {
+ this.lo = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, UInt128Parts encodedUInt128Parts)
+ throws IOException {
+ Uint64.encode(stream, encodedUInt128Parts.hi);
+ Uint64.encode(stream, encodedUInt128Parts.lo);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static UInt128Parts decode(XdrDataInputStream stream) throws IOException {
+ UInt128Parts decodedUInt128Parts = new UInt128Parts();
+ decodedUInt128Parts.hi = Uint64.decode(stream);
+ decodedUInt128Parts.lo = Uint64.decode(stream);
+ return decodedUInt128Parts;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.hi, this.lo);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof UInt128Parts)) {
+ return false;
+ }
+
+ UInt128Parts other = (UInt128Parts) object;
+ return Objects.equals(this.hi, other.hi) && Objects.equals(this.lo, other.lo);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static UInt128Parts fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static UInt128Parts fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Uint64 hi;
+ private Uint64 lo;
+
+ public Builder hi(Uint64 hi) {
+ this.hi = hi;
+ return this;
+ }
+
+ public Builder lo(Uint64 lo) {
+ this.lo = lo;
+ return this;
+ }
+
+ public UInt128Parts build() {
+ UInt128Parts val = new UInt128Parts();
+ val.setHi(this.hi);
+ val.setLo(this.lo);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/UInt256Parts.java b/src/main/java/org/stellar/sdk/xdr/UInt256Parts.java
new file mode 100644
index 000000000..2b97e6a47
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/UInt256Parts.java
@@ -0,0 +1,165 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+// === xdr source ============================================================
+
+// struct UInt256Parts {
+// uint64 hi_hi;
+// uint64 hi_lo;
+// uint64 lo_hi;
+// uint64 lo_lo;
+// };
+
+// ===========================================================================
+public class UInt256Parts implements XdrElement {
+ public UInt256Parts() {}
+
+ private Uint64 hi_hi;
+
+ public Uint64 getHi_hi() {
+ return this.hi_hi;
+ }
+
+ public void setHi_hi(Uint64 value) {
+ this.hi_hi = value;
+ }
+
+ private Uint64 hi_lo;
+
+ public Uint64 getHi_lo() {
+ return this.hi_lo;
+ }
+
+ public void setHi_lo(Uint64 value) {
+ this.hi_lo = value;
+ }
+
+ private Uint64 lo_hi;
+
+ public Uint64 getLo_hi() {
+ return this.lo_hi;
+ }
+
+ public void setLo_hi(Uint64 value) {
+ this.lo_hi = value;
+ }
+
+ private Uint64 lo_lo;
+
+ public Uint64 getLo_lo() {
+ return this.lo_lo;
+ }
+
+ public void setLo_lo(Uint64 value) {
+ this.lo_lo = value;
+ }
+
+ public static void encode(XdrDataOutputStream stream, UInt256Parts encodedUInt256Parts)
+ throws IOException {
+ Uint64.encode(stream, encodedUInt256Parts.hi_hi);
+ Uint64.encode(stream, encodedUInt256Parts.hi_lo);
+ Uint64.encode(stream, encodedUInt256Parts.lo_hi);
+ Uint64.encode(stream, encodedUInt256Parts.lo_lo);
+ }
+
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ encode(stream, this);
+ }
+
+ public static UInt256Parts decode(XdrDataInputStream stream) throws IOException {
+ UInt256Parts decodedUInt256Parts = new UInt256Parts();
+ decodedUInt256Parts.hi_hi = Uint64.decode(stream);
+ decodedUInt256Parts.hi_lo = Uint64.decode(stream);
+ decodedUInt256Parts.lo_hi = Uint64.decode(stream);
+ decodedUInt256Parts.lo_lo = Uint64.decode(stream);
+ return decodedUInt256Parts;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.hi_hi, this.hi_lo, this.lo_hi, this.lo_lo);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof UInt256Parts)) {
+ return false;
+ }
+
+ UInt256Parts other = (UInt256Parts) object;
+ return Objects.equals(this.hi_hi, other.hi_hi)
+ && Objects.equals(this.hi_lo, other.hi_lo)
+ && Objects.equals(this.lo_hi, other.lo_hi)
+ && Objects.equals(this.lo_lo, other.lo_lo);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static UInt256Parts fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static UInt256Parts fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ public static final class Builder {
+ private Uint64 hi_hi;
+ private Uint64 hi_lo;
+ private Uint64 lo_hi;
+ private Uint64 lo_lo;
+
+ public Builder hi_hi(Uint64 hi_hi) {
+ this.hi_hi = hi_hi;
+ return this;
+ }
+
+ public Builder hi_lo(Uint64 hi_lo) {
+ this.hi_lo = hi_lo;
+ return this;
+ }
+
+ public Builder lo_hi(Uint64 lo_hi) {
+ this.lo_hi = lo_hi;
+ return this;
+ }
+
+ public Builder lo_lo(Uint64 lo_lo) {
+ this.lo_lo = lo_lo;
+ return this;
+ }
+
+ public UInt256Parts build() {
+ UInt256Parts val = new UInt256Parts();
+ val.setHi_hi(this.hi_hi);
+ val.setHi_lo(this.hi_lo);
+ val.setLo_hi(this.lo_hi);
+ val.setLo_lo(this.lo_lo);
+ return val;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Uint256.java b/src/main/java/org/stellar/sdk/xdr/Uint256.java
index 21e0bde5e..bc6dd91af 100644
--- a/src/main/java/org/stellar/sdk/xdr/Uint256.java
+++ b/src/main/java/org/stellar/sdk/xdr/Uint256.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -59,4 +64,28 @@ public boolean equals(Object object) {
Uint256 other = (Uint256) object;
return Arrays.equals(this.uint256, other.uint256);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Uint256 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Uint256 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Uint32.java b/src/main/java/org/stellar/sdk/xdr/Uint32.java
index 76b47f98a..fc29d318f 100644
--- a/src/main/java/org/stellar/sdk/xdr/Uint32.java
+++ b/src/main/java/org/stellar/sdk/xdr/Uint32.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,24 +17,24 @@
// ===========================================================================
public class Uint32 implements XdrElement {
- private Integer uint32;
+ private XdrUnsignedInteger uint32;
public Uint32() {}
- public Uint32(Integer uint32) {
+ public Uint32(XdrUnsignedInteger uint32) {
this.uint32 = uint32;
}
- public Integer getUint32() {
+ public XdrUnsignedInteger getUint32() {
return this.uint32;
}
- public void setUint32(Integer value) {
+ public void setUint32(XdrUnsignedInteger value) {
this.uint32 = value;
}
public static void encode(XdrDataOutputStream stream, Uint32 encodedUint32) throws IOException {
- stream.writeInt(encodedUint32.uint32);
+ encodedUint32.uint32.encode(stream);
}
public void encode(XdrDataOutputStream stream) throws IOException {
@@ -38,13 +43,13 @@ public void encode(XdrDataOutputStream stream) throws IOException {
public static Uint32 decode(XdrDataInputStream stream) throws IOException {
Uint32 decodedUint32 = new Uint32();
- decodedUint32.uint32 = stream.readInt();
+ decodedUint32.uint32 = XdrUnsignedInteger.decode(stream);
return decodedUint32;
}
@Override
public int hashCode() {
- return Objects.hashCode(this.uint32);
+ return Objects.hash(this.uint32);
}
@Override
@@ -54,6 +59,30 @@ public boolean equals(Object object) {
}
Uint32 other = (Uint32) object;
- return Objects.equal(this.uint32, other.uint32);
+ return Objects.equals(this.uint32, other.uint32);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Uint32 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Uint32 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Uint64.java b/src/main/java/org/stellar/sdk/xdr/Uint64.java
index a38bc2224..c12f13fbb 100644
--- a/src/main/java/org/stellar/sdk/xdr/Uint64.java
+++ b/src/main/java/org/stellar/sdk/xdr/Uint64.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -12,24 +17,24 @@
// ===========================================================================
public class Uint64 implements XdrElement {
- private Long uint64;
+ private XdrUnsignedHyperInteger uint64;
public Uint64() {}
- public Uint64(Long uint64) {
+ public Uint64(XdrUnsignedHyperInteger uint64) {
this.uint64 = uint64;
}
- public Long getUint64() {
+ public XdrUnsignedHyperInteger getUint64() {
return this.uint64;
}
- public void setUint64(Long value) {
+ public void setUint64(XdrUnsignedHyperInteger value) {
this.uint64 = value;
}
public static void encode(XdrDataOutputStream stream, Uint64 encodedUint64) throws IOException {
- stream.writeLong(encodedUint64.uint64);
+ encodedUint64.uint64.encode(stream);
}
public void encode(XdrDataOutputStream stream) throws IOException {
@@ -38,13 +43,13 @@ public void encode(XdrDataOutputStream stream) throws IOException {
public static Uint64 decode(XdrDataInputStream stream) throws IOException {
Uint64 decodedUint64 = new Uint64();
- decodedUint64.uint64 = stream.readLong();
+ decodedUint64.uint64 = XdrUnsignedHyperInteger.decode(stream);
return decodedUint64;
}
@Override
public int hashCode() {
- return Objects.hashCode(this.uint64);
+ return Objects.hash(this.uint64);
}
@Override
@@ -54,6 +59,30 @@ public boolean equals(Object object) {
}
Uint64 other = (Uint64) object;
- return Objects.equal(this.uint64, other.uint64);
+ return Objects.equals(this.uint64, other.uint64);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Uint64 fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Uint64 fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/UpgradeEntryMeta.java b/src/main/java/org/stellar/sdk/xdr/UpgradeEntryMeta.java
index 9c41a19be..a690af049 100644
--- a/src/main/java/org/stellar/sdk/xdr/UpgradeEntryMeta.java
+++ b/src/main/java/org/stellar/sdk/xdr/UpgradeEntryMeta.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
-import com.google.common.base.Objects;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
// === xdr source ============================================================
@@ -57,7 +62,7 @@ public static UpgradeEntryMeta decode(XdrDataInputStream stream) throws IOExcept
@Override
public int hashCode() {
- return Objects.hashCode(this.upgrade, this.changes);
+ return Objects.hash(this.upgrade, this.changes);
}
@Override
@@ -67,7 +72,32 @@ public boolean equals(Object object) {
}
UpgradeEntryMeta other = (UpgradeEntryMeta) object;
- return Objects.equal(this.upgrade, other.upgrade) && Objects.equal(this.changes, other.changes);
+ return Objects.equals(this.upgrade, other.upgrade)
+ && Objects.equals(this.changes, other.changes);
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static UpgradeEntryMeta fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static UpgradeEntryMeta fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
}
public static final class Builder {
@@ -86,8 +116,8 @@ public Builder changes(LedgerEntryChanges changes) {
public UpgradeEntryMeta build() {
UpgradeEntryMeta val = new UpgradeEntryMeta();
- val.setUpgrade(upgrade);
- val.setChanges(changes);
+ val.setUpgrade(this.upgrade);
+ val.setChanges(this.changes);
return val;
}
}
diff --git a/src/main/java/org/stellar/sdk/xdr/UpgradeType.java b/src/main/java/org/stellar/sdk/xdr/UpgradeType.java
index 0e9866853..8acd939b1 100644
--- a/src/main/java/org/stellar/sdk/xdr/UpgradeType.java
+++ b/src/main/java/org/stellar/sdk/xdr/UpgradeType.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -61,4 +66,28 @@ public boolean equals(Object object) {
UpgradeType other = (UpgradeType) object;
return Arrays.equals(this.UpgradeType, other.UpgradeType);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static UpgradeType fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static UpgradeType fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/Value.java b/src/main/java/org/stellar/sdk/xdr/Value.java
index c52ffe1e7..850f27806 100644
--- a/src/main/java/org/stellar/sdk/xdr/Value.java
+++ b/src/main/java/org/stellar/sdk/xdr/Value.java
@@ -3,8 +3,13 @@
package org.stellar.sdk.xdr;
+import static org.stellar.sdk.xdr.Constants.*;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Base64;
// === xdr source ============================================================
@@ -60,4 +65,28 @@ public boolean equals(Object object) {
Value other = (Value) object;
return Arrays.equals(this.Value, other.Value);
}
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static Value fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static Value fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
}
diff --git a/src/main/java/org/stellar/sdk/xdr/XdrElement.java b/src/main/java/org/stellar/sdk/xdr/XdrElement.java
index fffc167ed..511360659 100644
--- a/src/main/java/org/stellar/sdk/xdr/XdrElement.java
+++ b/src/main/java/org/stellar/sdk/xdr/XdrElement.java
@@ -5,4 +5,8 @@
/** Common parent interface for all generated classes. */
interface XdrElement {
void encode(XdrDataOutputStream stream) throws IOException;
+
+ String toXdrBase64() throws IOException;
+
+ byte[] toXdrByteArray() throws IOException;
}
diff --git a/src/main/java/org/stellar/sdk/xdr/XdrString.java b/src/main/java/org/stellar/sdk/xdr/XdrString.java
index ab0e0ff24..3320d5bce 100644
--- a/src/main/java/org/stellar/sdk/xdr/XdrString.java
+++ b/src/main/java/org/stellar/sdk/xdr/XdrString.java
@@ -1,9 +1,12 @@
package org.stellar.sdk.xdr;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InvalidClassException;
import java.nio.charset.Charset;
import java.util.Arrays;
+import java.util.Base64;
public class XdrString implements XdrElement {
private byte[] bytes;
@@ -36,6 +39,38 @@ public byte[] getBytes() {
return this.bytes;
}
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static XdrString fromXdrBase64(String xdr, int maxSize) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes, maxSize);
+ }
+
+ public static XdrString fromXdrBase64(String xdr) throws IOException {
+ return fromXdrBase64(xdr, Integer.MAX_VALUE);
+ }
+
+ public static XdrString fromXdrByteArray(byte[] xdr, int maxSize) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream, maxSize);
+ }
+
+ public static XdrString fromXdrByteArray(byte[] xdr) throws IOException {
+ return fromXdrByteArray(xdr, Integer.MAX_VALUE);
+ }
+
@Override
public int hashCode() {
return Arrays.hashCode(this.bytes);
diff --git a/src/main/java/org/stellar/sdk/xdr/XdrUnsignedHyperInteger.java b/src/main/java/org/stellar/sdk/xdr/XdrUnsignedHyperInteger.java
new file mode 100644
index 000000000..4c570cc4b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/XdrUnsignedHyperInteger.java
@@ -0,0 +1,104 @@
+package org.stellar.sdk.xdr;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.Base64;
+import java.util.Objects;
+
+/**
+ * Represents XDR Unsigned Hyper Integer.
+ *
+ * @see XDR: External Data
+ * Representation Standard
+ */
+public class XdrUnsignedHyperInteger implements XdrElement {
+ public static final BigInteger MAX_VALUE = new BigInteger("18446744073709551615");
+ public static final BigInteger MIN_VALUE = BigInteger.ZERO;
+ private final BigInteger number;
+
+ public XdrUnsignedHyperInteger(BigInteger number) {
+ if (number.compareTo(MIN_VALUE) < 0 || number.compareTo(MAX_VALUE) > 0) {
+ throw new IllegalArgumentException("number must be between 0 and 2^64 - 1 inclusive");
+ }
+ this.number = number;
+ }
+
+ public XdrUnsignedHyperInteger(Long number) {
+ if (number < 0) {
+ throw new IllegalArgumentException(
+ "number must be greater than or equal to 0 if you want to construct it from Long");
+ }
+ this.number = BigInteger.valueOf(number);
+ }
+
+ @Override
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ stream.write(getBytes());
+ }
+
+ public static XdrUnsignedHyperInteger decode(XdrDataInputStream stream) throws IOException {
+ byte[] bytes = new byte[8];
+ stream.readFully(bytes);
+ BigInteger uint64 = new BigInteger(1, bytes);
+ return new XdrUnsignedHyperInteger(uint64);
+ }
+
+ private byte[] getBytes() {
+ byte[] bytes = number.toByteArray();
+ byte[] paddedBytes = new byte[8];
+
+ int numBytesToCopy = Math.min(bytes.length, 8);
+ int copyStartIndex = bytes.length - numBytesToCopy;
+ System.arraycopy(bytes, copyStartIndex, paddedBytes, 8 - numBytesToCopy, numBytesToCopy);
+ return paddedBytes;
+ }
+
+ public BigInteger getNumber() {
+ return number;
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static XdrUnsignedHyperInteger fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static XdrUnsignedHyperInteger fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.number);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof XdrUnsignedHyperInteger)) {
+ return false;
+ }
+
+ XdrUnsignedHyperInteger other = (XdrUnsignedHyperInteger) object;
+ return Objects.equals(this.number, other.number);
+ }
+
+ public String toString() {
+ return "XdrUnsignedInteger(number=" + this.getNumber() + ")";
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/XdrUnsignedInteger.java b/src/main/java/org/stellar/sdk/xdr/XdrUnsignedInteger.java
new file mode 100644
index 000000000..a3b037db6
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/XdrUnsignedInteger.java
@@ -0,0 +1,92 @@
+package org.stellar.sdk.xdr;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.Objects;
+
+/**
+ * Represents XDR Unsigned Integer.
+ *
+ * @see XDR: External Data
+ * Representation Standard
+ */
+public class XdrUnsignedInteger implements XdrElement {
+ public static final long MAX_VALUE = (1L << 32) - 1;
+ public static final long MIN_VALUE = 0;
+ private final Long number;
+
+ public XdrUnsignedInteger(Long number) {
+ if (number < MIN_VALUE || number > MAX_VALUE) {
+ throw new IllegalArgumentException("number must be between 0 and 2^32 - 1 inclusive");
+ }
+ this.number = number;
+ }
+
+ public XdrUnsignedInteger(Integer number) {
+ if (number < 0) {
+ throw new IllegalArgumentException(
+ "number must be greater than or equal to 0 if you want to construct it from Integer");
+ }
+ this.number = number.longValue();
+ }
+
+ public Long getNumber() {
+ return number;
+ }
+
+ public static XdrUnsignedInteger decode(XdrDataInputStream stream) throws IOException {
+ int intValue = stream.readInt();
+ long uint32Value = Integer.toUnsignedLong(intValue);
+ return new XdrUnsignedInteger(uint32Value);
+ }
+
+ @Override
+ public void encode(XdrDataOutputStream stream) throws IOException {
+ stream.writeInt(number.intValue());
+ }
+
+ @Override
+ public String toXdrBase64() throws IOException {
+ return Base64.getEncoder().encodeToString(toXdrByteArray());
+ }
+
+ @Override
+ public byte[] toXdrByteArray() throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrDataOutputStream = new XdrDataOutputStream(byteArrayOutputStream);
+ encode(xdrDataOutputStream);
+ return byteArrayOutputStream.toByteArray();
+ }
+
+ public static XdrUnsignedInteger fromXdrBase64(String xdr) throws IOException {
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ return fromXdrByteArray(bytes);
+ }
+
+ public static XdrUnsignedInteger fromXdrByteArray(byte[] xdr) throws IOException {
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
+ XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
+ return decode(xdrDataInputStream);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.number);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof XdrUnsignedInteger)) {
+ return false;
+ }
+
+ XdrUnsignedInteger other = (XdrUnsignedInteger) object;
+ return Objects.equals(this.number, other.number);
+ }
+
+ public String toString() {
+ return "XdrUnsignedInteger(number=" + this.getNumber() + ")";
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/AccountTest.java b/src/test/java/org/stellar/sdk/AccountTest.java
index 791356ae6..bc636923d 100644
--- a/src/test/java/org/stellar/sdk/AccountTest.java
+++ b/src/test/java/org/stellar/sdk/AccountTest.java
@@ -28,11 +28,11 @@ public void testGetIncrementedSequenceNumber() {
Account account = new Account(random.getAccountId(), 100L);
Long incremented;
incremented = account.getIncrementedSequenceNumber();
- assertEquals(new Long(100L), account.getSequenceNumber());
- assertEquals(new Long(101L), incremented);
+ assertEquals(Long.valueOf(100L), account.getSequenceNumber());
+ assertEquals(Long.valueOf(101L), incremented);
incremented = account.getIncrementedSequenceNumber();
- assertEquals(new Long(100L), account.getSequenceNumber());
- assertEquals(new Long(101L), incremented);
+ assertEquals(Long.valueOf(100L), account.getSequenceNumber());
+ assertEquals(Long.valueOf(101L), incremented);
}
@Test
@@ -40,7 +40,7 @@ public void testIncrementSequenceNumber() {
KeyPair random = KeyPair.random();
Account account = new Account(random.getAccountId(), 100L);
account.incrementSequenceNumber();
- assertEquals(account.getSequenceNumber(), new Long(101L));
+ assertEquals(account.getSequenceNumber(), Long.valueOf(101L));
}
@Test
@@ -49,6 +49,6 @@ public void testGetters() {
Account account = new Account(keypair.getAccountId(), 100L);
assertEquals(account.getKeyPair().getAccountId(), keypair.getAccountId());
assertEquals(account.getAccountId(), keypair.getAccountId());
- assertEquals(account.getSequenceNumber(), new Long(100L));
+ assertEquals(account.getSequenceNumber(), Long.valueOf(100L));
}
}
diff --git a/src/test/java/org/stellar/sdk/AddressTest.java b/src/test/java/org/stellar/sdk/AddressTest.java
new file mode 100644
index 000000000..e878fafbe
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/AddressTest.java
@@ -0,0 +1,159 @@
+package org.stellar.sdk;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Base64;
+import org.junit.Assert;
+import org.junit.Test;
+import org.stellar.sdk.xdr.SCAddress;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.XdrDataInputStream;
+
+public class AddressTest {
+ @Test
+ public void testConstructorAccountId() {
+ String accountId = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ";
+ Address address = new Address(accountId);
+ assertEquals(address.toString(), accountId);
+ assertEquals(address.getAddressType(), Address.AddressType.ACCOUNT);
+ }
+
+ @Test
+ public void testConstructorContractId() {
+ String contractId = "CA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUWDA";
+ Address address = new Address(contractId);
+ assertEquals(address.toString(), contractId);
+ assertEquals(address.getAddressType(), Address.AddressType.CONTRACT);
+ }
+
+ @Test
+ public void testConstructorInvalidAddressThrows() {
+ String accountId = "GINVALID";
+ try {
+ new Address(accountId);
+ fail();
+ } catch (IllegalArgumentException e) {
+ Assert.assertEquals("Unsupported address type", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testConstructorSecretThrows() {
+ String secret = "SBUIAXRYKAEJWBSJZYE6P4N4X4ATXP5GAFK5TZ6SKKQ6TS4MLX6G6E4M";
+ try {
+ new Address(secret);
+ fail();
+ } catch (IllegalArgumentException e) {
+ Assert.assertEquals("Unsupported address type", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testFromAccountByte() {
+ String accountId = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ";
+ byte[] accountIdBytes = StrKey.decodeStellarAccountId(accountId);
+ Address address = Address.fromAccount(accountIdBytes);
+ assertEquals(address.toString(), accountId);
+ assertEquals(address.getAddressType(), Address.AddressType.ACCOUNT);
+ }
+
+ @Test
+ public void testFromContractByte() {
+ String contractId = "CA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUWDA";
+ byte[] contractIdBytes = StrKey.decodeContractId(contractId);
+ Address address = Address.fromContract(contractIdBytes);
+ assertEquals(address.toString(), contractId);
+ assertEquals(address.getAddressType(), Address.AddressType.CONTRACT);
+ }
+
+ @Test
+ public void testToSCAddressAccount() throws IOException {
+ String accountId = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ";
+ Address address = new Address(accountId);
+ SCAddress scAddress = address.toSCAddress();
+
+ String xdr = "AAAAAAAAAAA/DDS/k60NmXHQTMyQ9wVRHIOKrZc0pKL7DXoD/H/omg==";
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ SCAddress expectScAddress =
+ SCAddress.decode(new XdrDataInputStream(new ByteArrayInputStream(bytes)));
+ assertEquals(scAddress, expectScAddress);
+ }
+
+ @Test
+ public void testToSCAddressContract() throws IOException {
+ String contract = "CA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUWDA";
+ Address address = new Address(contract);
+ SCAddress scAddress = address.toSCAddress();
+
+ String xdr = "AAAAAT8MNL+TrQ2ZcdBMzJD3BVEcg4qtlzSkovsNegP8f+ia";
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ SCAddress expectScAddress =
+ SCAddress.decode(new XdrDataInputStream(new ByteArrayInputStream(bytes)));
+ assertEquals(scAddress, expectScAddress);
+ }
+
+ @Test
+ public void testFromSCAddressAccount() throws IOException {
+ String xdr = "AAAAAAAAAAA/DDS/k60NmXHQTMyQ9wVRHIOKrZc0pKL7DXoD/H/omg==";
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ SCAddress scAddress = SCAddress.decode(new XdrDataInputStream(new ByteArrayInputStream(bytes)));
+
+ Address address = Address.fromSCAddress(scAddress);
+ String accountId = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ";
+ assertEquals(address.toString(), accountId);
+ assertEquals(address.getAddressType(), Address.AddressType.ACCOUNT);
+ }
+
+ @Test
+ public void testFromSCAddressContract() throws IOException {
+ String xdr = "AAAAAT8MNL+TrQ2ZcdBMzJD3BVEcg4qtlzSkovsNegP8f+ia";
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ SCAddress scAddress = SCAddress.decode(new XdrDataInputStream(new ByteArrayInputStream(bytes)));
+
+ Address address = Address.fromSCAddress(scAddress);
+ String contract = "CA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUWDA";
+ assertEquals(address.toString(), contract);
+ assertEquals(address.getAddressType(), Address.AddressType.CONTRACT);
+ }
+
+ @Test
+ public void testToSCVal() throws IOException {
+ String contract = "CA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUWDA";
+ Address address = new Address(contract);
+ SCVal scVal = address.toSCVal();
+
+ String xdr = "AAAAEgAAAAE/DDS/k60NmXHQTMyQ9wVRHIOKrZc0pKL7DXoD/H/omg==";
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ SCVal expectSCVal = SCVal.decode(new XdrDataInputStream(new ByteArrayInputStream(bytes)));
+ assertEquals(scVal, expectSCVal);
+ }
+
+ @Test
+ public void testFromSCVal() throws IOException {
+ String xdr = "AAAAEgAAAAE/DDS/k60NmXHQTMyQ9wVRHIOKrZc0pKL7DXoD/H/omg==";
+ byte[] bytes = Base64.getDecoder().decode(xdr);
+ SCVal scVal = SCVal.decode(new XdrDataInputStream(new ByteArrayInputStream(bytes)));
+
+ Address address = Address.fromSCVal(scVal);
+ String contract = "CA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUWDA";
+ assertEquals(address.toString(), contract);
+ assertEquals(address.getAddressType(), Address.AddressType.CONTRACT);
+ }
+
+ @Test
+ public void testToStringAccountId() {
+ String accountId = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ";
+ Address address = new Address(accountId);
+ assertEquals(address.toString(), accountId);
+ }
+
+ @Test
+ public void testToStringContractId() {
+ String contractId = "CA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUWDA";
+ Address address = new Address(contractId);
+ assertEquals(address.toString(), contractId);
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/AuthTest.java b/src/test/java/org/stellar/sdk/AuthTest.java
new file mode 100644
index 000000000..e8f843b63
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/AuthTest.java
@@ -0,0 +1,606 @@
+package org.stellar.sdk;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import org.junit.Test;
+import org.stellar.sdk.scval.Scv;
+import org.stellar.sdk.xdr.EnvelopeType;
+import org.stellar.sdk.xdr.Hash;
+import org.stellar.sdk.xdr.HashIDPreimage;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.InvokeContractArgs;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.SorobanAddressCredentials;
+import org.stellar.sdk.xdr.SorobanAuthorizationEntry;
+import org.stellar.sdk.xdr.SorobanAuthorizedFunction;
+import org.stellar.sdk.xdr.SorobanAuthorizedFunctionType;
+import org.stellar.sdk.xdr.SorobanAuthorizedInvocation;
+import org.stellar.sdk.xdr.SorobanCredentials;
+import org.stellar.sdk.xdr.SorobanCredentialsType;
+import org.stellar.sdk.xdr.Uint32;
+import org.stellar.sdk.xdr.XdrUnsignedInteger;
+
+public class AuthTest {
+ @Test
+ public void testSignAuthorizeEntryWithBase64EntryAndKeypairSigner() throws IOException {
+ String contractId = "CDCYWK73YTYFJZZSJ5V7EDFNHYBG4QN3VUNG2IGD27KJDDPNCZKBCBXK";
+ KeyPair signer =
+ KeyPair.fromSecretSeed("SAEZSI6DY7AXJFIYA4PM6SIBNEYYXIEM2MSOTHFGKHDW32MBQ7KVO6EN");
+ long validUntilLedgerSeq = 654656L;
+ Network network = Network.TESTNET;
+
+ SorobanCredentials credentials =
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS)
+ .address(
+ new SorobanAddressCredentials.Builder()
+ .address(new Address(signer.getAccountId()).toSCAddress())
+ .nonce(new Int64(123456789L))
+ .signatureExpirationLedger(new Uint32(new XdrUnsignedInteger(0L)))
+ .signature(Scv.toVoid())
+ .build())
+ .build();
+ SorobanAuthorizedInvocation invocation =
+ new SorobanAuthorizedInvocation.Builder()
+ .function(
+ new SorobanAuthorizedFunction.Builder()
+ .discriminant(
+ SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN)
+ .contractFn(
+ new InvokeContractArgs.Builder()
+ .contractAddress(new Address(contractId).toSCAddress())
+ .functionName(Scv.toSymbol("increment").getSym())
+ .args(new SCVal[0])
+ .build())
+ .build())
+ .subInvocations(new SorobanAuthorizedInvocation[0])
+ .build();
+ SorobanAuthorizationEntry entry =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(credentials)
+ .rootInvocation(invocation)
+ .build();
+
+ SorobanAuthorizationEntry signedEntry =
+ Auth.authorizeEntry(entry.toXdrBase64(), signer, validUntilLedgerSeq, network);
+
+ HashIDPreimage preimage =
+ new HashIDPreimage.Builder()
+ .discriminant(EnvelopeType.ENVELOPE_TYPE_SOROBAN_AUTHORIZATION)
+ .sorobanAuthorization(
+ new HashIDPreimage.HashIDPreimageSorobanAuthorization.Builder()
+ .networkID(new Hash(network.getNetworkId()))
+ .nonce(new Int64(123456789L))
+ .invocation(invocation)
+ .signatureExpirationLedger(
+ new Uint32(new XdrUnsignedInteger(validUntilLedgerSeq)))
+ .build())
+ .build();
+ byte[] signature = signer.sign(Util.hash(preimage.toXdrByteArray()));
+ SorobanCredentials expectedCredentials =
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS)
+ .address(
+ new SorobanAddressCredentials.Builder()
+ .address(new Address(signer.getAccountId()).toSCAddress())
+ .nonce(new Int64(123456789L))
+ .signatureExpirationLedger(
+ new Uint32(new XdrUnsignedInteger(validUntilLedgerSeq)))
+ .signature(
+ Scv.toVec(
+ Collections.singleton(
+ Scv.toMap(
+ new LinkedHashMap() {
+ {
+ put(
+ Scv.toSymbol("public_key"),
+ Scv.toBytes(signer.getPublicKey()));
+ put(Scv.toSymbol("signature"), Scv.toBytes(signature));
+ }
+ }))))
+ .build())
+ .build();
+
+ SorobanAuthorizationEntry expectedEntry =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(expectedCredentials)
+ .rootInvocation(invocation)
+ .build();
+ assertEquals(expectedEntry, signedEntry);
+ assertNotSame(entry, signedEntry);
+ }
+
+ @Test
+ public void testSignAuthorizeEntryWithXdrEntryAndKeypairSigner() throws IOException {
+ String contractId = "CDCYWK73YTYFJZZSJ5V7EDFNHYBG4QN3VUNG2IGD27KJDDPNCZKBCBXK";
+ KeyPair signer =
+ KeyPair.fromSecretSeed("SAEZSI6DY7AXJFIYA4PM6SIBNEYYXIEM2MSOTHFGKHDW32MBQ7KVO6EN");
+ long validUntilLedgerSeq = 654656L;
+ Network network = Network.TESTNET;
+
+ SorobanCredentials credentials =
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS)
+ .address(
+ new SorobanAddressCredentials.Builder()
+ .address(new Address(signer.getAccountId()).toSCAddress())
+ .nonce(new Int64(123456789L))
+ .signatureExpirationLedger(new Uint32(new XdrUnsignedInteger(0L)))
+ .signature(Scv.toVoid())
+ .build())
+ .build();
+ SorobanAuthorizedInvocation invocation =
+ new SorobanAuthorizedInvocation.Builder()
+ .function(
+ new SorobanAuthorizedFunction.Builder()
+ .discriminant(
+ SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN)
+ .contractFn(
+ new InvokeContractArgs.Builder()
+ .contractAddress(new Address(contractId).toSCAddress())
+ .functionName(Scv.toSymbol("increment").getSym())
+ .args(new SCVal[0])
+ .build())
+ .build())
+ .subInvocations(new SorobanAuthorizedInvocation[0])
+ .build();
+ SorobanAuthorizationEntry entry =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(credentials)
+ .rootInvocation(invocation)
+ .build();
+
+ SorobanAuthorizationEntry signedEntry =
+ Auth.authorizeEntry(entry, signer, validUntilLedgerSeq, network);
+
+ HashIDPreimage preimage =
+ new HashIDPreimage.Builder()
+ .discriminant(EnvelopeType.ENVELOPE_TYPE_SOROBAN_AUTHORIZATION)
+ .sorobanAuthorization(
+ new HashIDPreimage.HashIDPreimageSorobanAuthorization.Builder()
+ .networkID(new Hash(network.getNetworkId()))
+ .nonce(new Int64(123456789L))
+ .invocation(invocation)
+ .signatureExpirationLedger(
+ new Uint32(new XdrUnsignedInteger(validUntilLedgerSeq)))
+ .build())
+ .build();
+ byte[] signature = signer.sign(Util.hash(preimage.toXdrByteArray()));
+ SorobanCredentials expectedCredentials =
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS)
+ .address(
+ new SorobanAddressCredentials.Builder()
+ .address(new Address(signer.getAccountId()).toSCAddress())
+ .nonce(new Int64(123456789L))
+ .signatureExpirationLedger(
+ new Uint32(new XdrUnsignedInteger(validUntilLedgerSeq)))
+ .signature(
+ Scv.toVec(
+ Collections.singleton(
+ Scv.toMap(
+ new LinkedHashMap() {
+ {
+ put(
+ Scv.toSymbol("public_key"),
+ Scv.toBytes(signer.getPublicKey()));
+ put(Scv.toSymbol("signature"), Scv.toBytes(signature));
+ }
+ }))))
+ .build())
+ .build();
+
+ SorobanAuthorizationEntry expectedEntry =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(expectedCredentials)
+ .rootInvocation(invocation)
+ .build();
+ assertEquals(expectedEntry, signedEntry);
+ assertNotSame(entry, signedEntry);
+ }
+
+ @Test
+ public void testSignAuthorizeEntryWithBase64EntryAndFunctionSigner() throws IOException {
+ String contractId = "CDCYWK73YTYFJZZSJ5V7EDFNHYBG4QN3VUNG2IGD27KJDDPNCZKBCBXK";
+ KeyPair signer =
+ KeyPair.fromSecretSeed("SAEZSI6DY7AXJFIYA4PM6SIBNEYYXIEM2MSOTHFGKHDW32MBQ7KVO6EN");
+ Auth.Signer entrySigner =
+ preimage -> {
+ byte[] data;
+ try {
+ data = preimage.toXdrByteArray();
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Unable to convert preimage to bytes", e);
+ }
+ byte[] payload = Util.hash(data);
+ return signer.sign(payload);
+ };
+ long validUntilLedgerSeq = 654656L;
+ Network network = Network.TESTNET;
+
+ SorobanCredentials credentials =
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS)
+ .address(
+ new SorobanAddressCredentials.Builder()
+ .address(new Address(signer.getAccountId()).toSCAddress())
+ .nonce(new Int64(123456789L))
+ .signatureExpirationLedger(new Uint32(new XdrUnsignedInteger(0L)))
+ .signature(Scv.toVoid())
+ .build())
+ .build();
+ SorobanAuthorizedInvocation invocation =
+ new SorobanAuthorizedInvocation.Builder()
+ .function(
+ new SorobanAuthorizedFunction.Builder()
+ .discriminant(
+ SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN)
+ .contractFn(
+ new InvokeContractArgs.Builder()
+ .contractAddress(new Address(contractId).toSCAddress())
+ .functionName(Scv.toSymbol("increment").getSym())
+ .args(new SCVal[0])
+ .build())
+ .build())
+ .subInvocations(new SorobanAuthorizedInvocation[0])
+ .build();
+ SorobanAuthorizationEntry entry =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(credentials)
+ .rootInvocation(invocation)
+ .build();
+
+ SorobanAuthorizationEntry signedEntry =
+ Auth.authorizeEntry(entry.toXdrBase64(), entrySigner, validUntilLedgerSeq, network);
+
+ HashIDPreimage preimage =
+ new HashIDPreimage.Builder()
+ .discriminant(EnvelopeType.ENVELOPE_TYPE_SOROBAN_AUTHORIZATION)
+ .sorobanAuthorization(
+ new HashIDPreimage.HashIDPreimageSorobanAuthorization.Builder()
+ .networkID(new Hash(network.getNetworkId()))
+ .nonce(new Int64(123456789L))
+ .invocation(invocation)
+ .signatureExpirationLedger(
+ new Uint32(new XdrUnsignedInteger(validUntilLedgerSeq)))
+ .build())
+ .build();
+ byte[] signature = signer.sign(Util.hash(preimage.toXdrByteArray()));
+ SorobanCredentials expectedCredentials =
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS)
+ .address(
+ new SorobanAddressCredentials.Builder()
+ .address(new Address(signer.getAccountId()).toSCAddress())
+ .nonce(new Int64(123456789L))
+ .signatureExpirationLedger(
+ new Uint32(new XdrUnsignedInteger(validUntilLedgerSeq)))
+ .signature(
+ Scv.toVec(
+ Collections.singleton(
+ Scv.toMap(
+ new LinkedHashMap() {
+ {
+ put(
+ Scv.toSymbol("public_key"),
+ Scv.toBytes(signer.getPublicKey()));
+ put(Scv.toSymbol("signature"), Scv.toBytes(signature));
+ }
+ }))))
+ .build())
+ .build();
+
+ SorobanAuthorizationEntry expectedEntry =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(expectedCredentials)
+ .rootInvocation(invocation)
+ .build();
+ assertEquals(expectedEntry, signedEntry);
+ assertNotSame(entry, signedEntry);
+ }
+
+ @Test
+ public void testSignAuthorizeEntryWithXdrEntryAndFunctionSigner() throws IOException {
+ String contractId = "CDCYWK73YTYFJZZSJ5V7EDFNHYBG4QN3VUNG2IGD27KJDDPNCZKBCBXK";
+ KeyPair signer =
+ KeyPair.fromSecretSeed("SAEZSI6DY7AXJFIYA4PM6SIBNEYYXIEM2MSOTHFGKHDW32MBQ7KVO6EN");
+ Auth.Signer entrySigner =
+ preimage -> {
+ byte[] data;
+ try {
+ data = preimage.toXdrByteArray();
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Unable to convert preimage to bytes", e);
+ }
+ byte[] payload = Util.hash(data);
+ return signer.sign(payload);
+ };
+ long validUntilLedgerSeq = 654656L;
+ Network network = Network.TESTNET;
+
+ SorobanCredentials credentials =
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS)
+ .address(
+ new SorobanAddressCredentials.Builder()
+ .address(new Address(signer.getAccountId()).toSCAddress())
+ .nonce(new Int64(123456789L))
+ .signatureExpirationLedger(new Uint32(new XdrUnsignedInteger(0L)))
+ .signature(Scv.toVoid())
+ .build())
+ .build();
+ SorobanAuthorizedInvocation invocation =
+ new SorobanAuthorizedInvocation.Builder()
+ .function(
+ new SorobanAuthorizedFunction.Builder()
+ .discriminant(
+ SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN)
+ .contractFn(
+ new InvokeContractArgs.Builder()
+ .contractAddress(new Address(contractId).toSCAddress())
+ .functionName(Scv.toSymbol("increment").getSym())
+ .args(new SCVal[0])
+ .build())
+ .build())
+ .subInvocations(new SorobanAuthorizedInvocation[0])
+ .build();
+ SorobanAuthorizationEntry entry =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(credentials)
+ .rootInvocation(invocation)
+ .build();
+
+ SorobanAuthorizationEntry signedEntry =
+ Auth.authorizeEntry(entry, entrySigner, validUntilLedgerSeq, network);
+
+ HashIDPreimage preimage =
+ new HashIDPreimage.Builder()
+ .discriminant(EnvelopeType.ENVELOPE_TYPE_SOROBAN_AUTHORIZATION)
+ .sorobanAuthorization(
+ new HashIDPreimage.HashIDPreimageSorobanAuthorization.Builder()
+ .networkID(new Hash(network.getNetworkId()))
+ .nonce(new Int64(123456789L))
+ .invocation(invocation)
+ .signatureExpirationLedger(
+ new Uint32(new XdrUnsignedInteger(validUntilLedgerSeq)))
+ .build())
+ .build();
+ byte[] signature = signer.sign(Util.hash(preimage.toXdrByteArray()));
+ SorobanCredentials expectedCredentials =
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS)
+ .address(
+ new SorobanAddressCredentials.Builder()
+ .address(new Address(signer.getAccountId()).toSCAddress())
+ .nonce(new Int64(123456789L))
+ .signatureExpirationLedger(
+ new Uint32(new XdrUnsignedInteger(validUntilLedgerSeq)))
+ .signature(
+ Scv.toVec(
+ Collections.singleton(
+ Scv.toMap(
+ new LinkedHashMap() {
+ {
+ put(
+ Scv.toSymbol("public_key"),
+ Scv.toBytes(signer.getPublicKey()));
+ put(Scv.toSymbol("signature"), Scv.toBytes(signature));
+ }
+ }))))
+ .build())
+ .build();
+
+ SorobanAuthorizationEntry expectedEntry =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(expectedCredentials)
+ .rootInvocation(invocation)
+ .build();
+ assertEquals(expectedEntry, signedEntry);
+ assertNotSame(entry, signedEntry);
+ }
+
+ @Test
+ public void testSignAuthorizeEntryWithSourceCredentialsEntry() {
+ String contractId = "CDCYWK73YTYFJZZSJ5V7EDFNHYBG4QN3VUNG2IGD27KJDDPNCZKBCBXK";
+ KeyPair signer =
+ KeyPair.fromSecretSeed("SAEZSI6DY7AXJFIYA4PM6SIBNEYYXIEM2MSOTHFGKHDW32MBQ7KVO6EN");
+ long validUntilLedgerSeq = 654656L;
+ Network network = Network.TESTNET;
+
+ SorobanCredentials credentials =
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_SOURCE_ACCOUNT)
+ .build();
+ SorobanAuthorizedInvocation invocation =
+ new SorobanAuthorizedInvocation.Builder()
+ .function(
+ new SorobanAuthorizedFunction.Builder()
+ .discriminant(
+ SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN)
+ .contractFn(
+ new InvokeContractArgs.Builder()
+ .contractAddress(new Address(contractId).toSCAddress())
+ .functionName(Scv.toSymbol("increment").getSym())
+ .args(new SCVal[0])
+ .build())
+ .build())
+ .subInvocations(new SorobanAuthorizedInvocation[0])
+ .build();
+ SorobanAuthorizationEntry entry =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(credentials)
+ .rootInvocation(invocation)
+ .build();
+
+ SorobanAuthorizationEntry signedEntry =
+ Auth.authorizeEntry(entry, signer, validUntilLedgerSeq, network);
+ assertEquals(entry, signedEntry);
+ assertNotSame(entry, signedEntry);
+ }
+
+ @Test
+ public void testSignAuthorizeEntryWithSignatureMismatchThrows() throws IOException {
+ String contractId = "CDCYWK73YTYFJZZSJ5V7EDFNHYBG4QN3VUNG2IGD27KJDDPNCZKBCBXK";
+ KeyPair signer =
+ KeyPair.fromSecretSeed("SAEZSI6DY7AXJFIYA4PM6SIBNEYYXIEM2MSOTHFGKHDW32MBQ7KVO6EN");
+ long validUntilLedgerSeq = 654656L;
+ Network network = Network.TESTNET;
+
+ SorobanCredentials credentials =
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS)
+ .address(
+ new SorobanAddressCredentials.Builder()
+ .address(new Address(KeyPair.random().getAccountId()).toSCAddress())
+ .nonce(new Int64(123456789L))
+ .signatureExpirationLedger(new Uint32(new XdrUnsignedInteger(0L)))
+ .signature(Scv.toVoid())
+ .build())
+ .build();
+ SorobanAuthorizedInvocation invocation =
+ new SorobanAuthorizedInvocation.Builder()
+ .function(
+ new SorobanAuthorizedFunction.Builder()
+ .discriminant(
+ SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN)
+ .contractFn(
+ new InvokeContractArgs.Builder()
+ .contractAddress(new Address(contractId).toSCAddress())
+ .functionName(Scv.toSymbol("increment").getSym())
+ .args(new SCVal[0])
+ .build())
+ .build())
+ .subInvocations(new SorobanAuthorizedInvocation[0])
+ .build();
+ SorobanAuthorizationEntry entry =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(credentials)
+ .rootInvocation(invocation)
+ .build();
+
+ try {
+ Auth.authorizeEntry(entry.toXdrBase64(), signer, validUntilLedgerSeq, network);
+ fail();
+ } catch (IllegalArgumentException e) {
+ assertEquals("signature does not match payload", e.getMessage());
+ }
+ }
+
+ @Test
+ public void authorizeInvocationWithKeypairSigner() {
+ String contractId = "CDCYWK73YTYFJZZSJ5V7EDFNHYBG4QN3VUNG2IGD27KJDDPNCZKBCBXK";
+ KeyPair signer =
+ KeyPair.fromSecretSeed("SAEZSI6DY7AXJFIYA4PM6SIBNEYYXIEM2MSOTHFGKHDW32MBQ7KVO6EN");
+ long validUntilLedgerSeq = 654656L;
+ Network network = Network.TESTNET;
+
+ SorobanAuthorizedInvocation invocation =
+ new SorobanAuthorizedInvocation.Builder()
+ .function(
+ new SorobanAuthorizedFunction.Builder()
+ .discriminant(
+ SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN)
+ .contractFn(
+ new InvokeContractArgs.Builder()
+ .contractAddress(new Address(contractId).toSCAddress())
+ .functionName(Scv.toSymbol("increment").getSym())
+ .args(new SCVal[0])
+ .build())
+ .build())
+ .subInvocations(new SorobanAuthorizedInvocation[0])
+ .build();
+
+ SorobanAuthorizationEntry signedEntry =
+ Auth.authorizeInvocation(signer, validUntilLedgerSeq, invocation, network);
+
+ assertEquals(signedEntry.getRootInvocation(), invocation);
+ assertEquals(
+ signedEntry.getCredentials().getDiscriminant(),
+ SorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS);
+ assertEquals(
+ signedEntry.getCredentials().getAddress().getAddress(),
+ new Address(signer.getAccountId()).toSCAddress());
+ assertEquals(
+ signedEntry
+ .getCredentials()
+ .getAddress()
+ .getSignatureExpirationLedger()
+ .getUint32()
+ .getNumber()
+ .longValue(),
+ validUntilLedgerSeq);
+ assertEquals(
+ signedEntry.getCredentials().getAddress().getSignature().getDiscriminant(),
+ SCValType.SCV_VEC);
+ assertEquals(
+ signedEntry.getCredentials().getAddress().getSignature().getVec().getSCVec().length, 1);
+ }
+
+ @Test
+ public void authorizeInvocationWithFunctionSigner() {
+ String contractId = "CDCYWK73YTYFJZZSJ5V7EDFNHYBG4QN3VUNG2IGD27KJDDPNCZKBCBXK";
+ KeyPair signer =
+ KeyPair.fromSecretSeed("SAEZSI6DY7AXJFIYA4PM6SIBNEYYXIEM2MSOTHFGKHDW32MBQ7KVO6EN");
+ Auth.Signer entrySigner =
+ preimage -> {
+ byte[] data;
+ try {
+ data = preimage.toXdrByteArray();
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Unable to convert preimage to bytes", e);
+ }
+ byte[] payload = Util.hash(data);
+ return signer.sign(payload);
+ };
+ long validUntilLedgerSeq = 654656L;
+ Network network = Network.TESTNET;
+
+ SorobanAuthorizedInvocation invocation =
+ new SorobanAuthorizedInvocation.Builder()
+ .function(
+ new SorobanAuthorizedFunction.Builder()
+ .discriminant(
+ SorobanAuthorizedFunctionType.SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN)
+ .contractFn(
+ new InvokeContractArgs.Builder()
+ .contractAddress(new Address(contractId).toSCAddress())
+ .functionName(Scv.toSymbol("increment").getSym())
+ .args(new SCVal[0])
+ .build())
+ .build())
+ .subInvocations(new SorobanAuthorizedInvocation[0])
+ .build();
+
+ SorobanAuthorizationEntry signedEntry =
+ Auth.authorizeInvocation(
+ entrySigner, signer.getAccountId(), validUntilLedgerSeq, invocation, network);
+
+ assertEquals(signedEntry.getRootInvocation(), invocation);
+ assertEquals(
+ signedEntry.getCredentials().getDiscriminant(),
+ SorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS);
+ assertEquals(
+ signedEntry.getCredentials().getAddress().getAddress(),
+ new Address(signer.getAccountId()).toSCAddress());
+ assertEquals(
+ signedEntry
+ .getCredentials()
+ .getAddress()
+ .getSignatureExpirationLedger()
+ .getUint32()
+ .getNumber()
+ .longValue(),
+ validUntilLedgerSeq);
+ assertEquals(
+ signedEntry.getCredentials().getAddress().getSignature().getDiscriminant(),
+ SCValType.SCV_VEC);
+ assertEquals(
+ signedEntry.getCredentials().getAddress().getSignature().getVec().getSCVec().length, 1);
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/BumpFootprintExpirationOperationTest.java b/src/test/java/org/stellar/sdk/BumpFootprintExpirationOperationTest.java
new file mode 100644
index 000000000..1319103f9
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/BumpFootprintExpirationOperationTest.java
@@ -0,0 +1,121 @@
+package org.stellar.sdk;
+
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNull;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class BumpFootprintExpirationOperationTest {
+ @Test
+ public void testBuilderWithSource() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ BumpFootprintExpirationOperation op =
+ BumpFootprintExpirationOperation.builder()
+ .ledgersToExpire(123L)
+ .sourceAccount(source)
+ .build();
+ assertEquals(Long.valueOf(123), op.getLedgersToExpire());
+ assertEquals(source, op.getSourceAccount());
+ String expectXdr = "AAAAAQAAAAAk4TTtavBWsGnEN3KxHw4Ohwi22ZJHWi8hlamN5pm0TgAAABkAAAAAAAAAew==";
+ assertEquals(expectXdr, op.toXdrBase64());
+ }
+
+ @Test
+ public void testBuilderWithoutSource() {
+ BumpFootprintExpirationOperation op =
+ BumpFootprintExpirationOperation.builder().ledgersToExpire(123L).build();
+ assertEquals(Long.valueOf(123), op.getLedgersToExpire());
+ assertNull(op.getSourceAccount());
+ String expectXdr = "AAAAAAAAABkAAAAAAAAAew==";
+ assertEquals(expectXdr, op.toXdrBase64());
+ }
+
+ @Test
+ public void testFromXdr() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ BumpFootprintExpirationOperation originOp =
+ BumpFootprintExpirationOperation.builder()
+ .ledgersToExpire(123L)
+ .sourceAccount(source)
+ .build();
+ org.stellar.sdk.xdr.Operation xdrObject = originOp.toXdr();
+ Operation restartOp = Operation.fromXdr(xdrObject);
+ Assert.assertEquals(restartOp, originOp);
+ }
+
+ @Test
+ public void testEquals() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ BumpFootprintExpirationOperation operation1 =
+ BumpFootprintExpirationOperation.builder()
+ .ledgersToExpire(123L)
+ .sourceAccount(source)
+ .build();
+ BumpFootprintExpirationOperation operation2 =
+ BumpFootprintExpirationOperation.builder()
+ .ledgersToExpire(123L)
+ .sourceAccount(source)
+ .build();
+ assertEquals(operation1, operation2);
+ }
+
+ @Test
+ public void testNotEquals() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ BumpFootprintExpirationOperation operation1 =
+ BumpFootprintExpirationOperation.builder()
+ .ledgersToExpire(123L)
+ .sourceAccount(source)
+ .build();
+ BumpFootprintExpirationOperation operation2 =
+ BumpFootprintExpirationOperation.builder()
+ .ledgersToExpire(124L)
+ .sourceAccount(source)
+ .build();
+ Assert.assertNotEquals(operation1, operation2);
+ }
+
+ @Test
+ public void testNotEqualsSource() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ BumpFootprintExpirationOperation operation1 =
+ BumpFootprintExpirationOperation.builder()
+ .ledgersToExpire(123L)
+ .sourceAccount(source)
+ .build();
+ BumpFootprintExpirationOperation operation2 =
+ BumpFootprintExpirationOperation.builder().ledgersToExpire(123L).build();
+ Assert.assertNotEquals(operation1, operation2);
+ }
+
+ @Test
+ public void testLedgersToExpireIsInvalidThrowsLessThanZero() {
+ try {
+ BumpFootprintExpirationOperation.builder().ledgersToExpire(-1L).build();
+ Assert.fail();
+ } catch (IllegalArgumentException e) {
+ Assert.assertEquals("ledgersToExpire isn't a ledger quantity (uint32)", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testLedgersToExpireIsInvalidThrowsGreatThanMaxUint32() {
+ try {
+ BumpFootprintExpirationOperation.builder().ledgersToExpire(4294967296L).build();
+ Assert.fail();
+ } catch (IllegalArgumentException e) {
+ Assert.assertEquals("ledgersToExpire isn't a ledger quantity (uint32)", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testLedgersToExpireIsNullThrows() {
+ try {
+ BumpFootprintExpirationOperation.builder().build();
+ Assert.fail();
+ } catch (NullPointerException e) {
+ Assert.assertEquals("ledgersToExpire is marked non-null but is null", e.getMessage());
+ }
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/ClaimableBalanceIdTest.java b/src/test/java/org/stellar/sdk/ClaimableBalanceIdTest.java
index 361195308..c8de442a8 100644
--- a/src/test/java/org/stellar/sdk/ClaimableBalanceIdTest.java
+++ b/src/test/java/org/stellar/sdk/ClaimableBalanceIdTest.java
@@ -3,12 +3,13 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import com.google.common.collect.Lists;
import java.io.IOException;
+import java.util.Collections;
import org.junit.Test;
import org.stellar.sdk.xdr.CryptoKeyType;
import org.stellar.sdk.xdr.MuxedAccount;
import org.stellar.sdk.xdr.Uint64;
+import org.stellar.sdk.xdr.XdrUnsignedHyperInteger;
public class ClaimableBalanceIdTest {
@@ -21,7 +22,7 @@ public void testClaimableBalanceIds() throws IOException {
new CreateClaimableBalanceOperation.Builder(
"420",
new AssetTypeNative(),
- Lists.newArrayList(
+ Collections.singletonList(
new Claimant(
"GCACCFMIWJAHUUASSE2WC7V6VVDLYRLSJYZ3DJEXCG523FSHTNII6KOG",
new Predicate.Unconditional())))
@@ -51,7 +52,7 @@ public void testClaimableBalanceIds() throws IOException {
new CreateClaimableBalanceOperation.Builder(
"420",
new AssetTypeNative(),
- Lists.newArrayList(
+ Collections.singletonList(
new Claimant(
"GCACCFMIWJAHUUASSE2WC7V6VVDLYRLSJYZ3DJEXCG523FSHTNII6KOG",
new Predicate.Unconditional())))
@@ -84,7 +85,7 @@ public void testClaimableBalanceIds() throws IOException {
muxedAccount.setDiscriminant(CryptoKeyType.KEY_TYPE_MUXED_ED25519);
MuxedAccount.MuxedAccountMed25519 med = new MuxedAccount.MuxedAccountMed25519();
med.setEd25519(StrKey.encodeToXDRMuxedAccount(sourceAccount).getEd25519());
- med.setId(new Uint64(41l));
+ med.setId(new Uint64(new XdrUnsignedHyperInteger(41l)));
muxedAccount.setMed25519(med);
transaction =
diff --git a/src/test/java/org/stellar/sdk/InvokeHostFunctionOperationTest.java b/src/test/java/org/stellar/sdk/InvokeHostFunctionOperationTest.java
new file mode 100644
index 000000000..ee6c1e460
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/InvokeHostFunctionOperationTest.java
@@ -0,0 +1,510 @@
+package org.stellar.sdk;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collections;
+import java.util.List;
+import org.junit.Test;
+import org.stellar.sdk.scval.Scv;
+import org.stellar.sdk.xdr.ContractExecutable;
+import org.stellar.sdk.xdr.ContractExecutableType;
+import org.stellar.sdk.xdr.ContractIDPreimage;
+import org.stellar.sdk.xdr.ContractIDPreimageType;
+import org.stellar.sdk.xdr.CreateContractArgs;
+import org.stellar.sdk.xdr.Hash;
+import org.stellar.sdk.xdr.HostFunction;
+import org.stellar.sdk.xdr.HostFunctionType;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.InvokeContractArgs;
+import org.stellar.sdk.xdr.SCAddress;
+import org.stellar.sdk.xdr.SCSymbol;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SorobanAddressCredentials;
+import org.stellar.sdk.xdr.SorobanAuthorizationEntry;
+import org.stellar.sdk.xdr.SorobanAuthorizedFunction;
+import org.stellar.sdk.xdr.SorobanAuthorizedFunctionType;
+import org.stellar.sdk.xdr.SorobanAuthorizedInvocation;
+import org.stellar.sdk.xdr.SorobanCredentials;
+import org.stellar.sdk.xdr.SorobanCredentialsType;
+import org.stellar.sdk.xdr.Uint256;
+import org.stellar.sdk.xdr.Uint32;
+import org.stellar.sdk.xdr.XdrString;
+import org.stellar.sdk.xdr.XdrUnsignedInteger;
+
+public class InvokeHostFunctionOperationTest {
+ CreateContractArgs createContractArgs =
+ new CreateContractArgs.Builder()
+ .contractIDPreimage(
+ new ContractIDPreimage.Builder()
+ .discriminant(ContractIDPreimageType.CONTRACT_ID_PREIMAGE_FROM_ADDRESS)
+ .fromAddress(
+ new ContractIDPreimage.ContractIDPreimageFromAddress.Builder()
+ .address(
+ new Address(
+ "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO")
+ .toSCAddress())
+ .salt(new Uint256(new byte[32]))
+ .build())
+ .build())
+ .executable(
+ new ContractExecutable.Builder()
+ .discriminant(ContractExecutableType.CONTRACT_EXECUTABLE_TOKEN)
+ .build())
+ .build();
+
+ @Test
+ public void testConstructorsFromHostFunction() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ HostFunction hostFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+ InvokeHostFunctionOperation invokeHostFunctionOperation =
+ InvokeHostFunctionOperation.builder()
+ .hostFunction(hostFunction)
+ .sourceAccount(source)
+ .build();
+ assertEquals(invokeHostFunctionOperation.getHostFunction(), hostFunction);
+ assertTrue(invokeHostFunctionOperation.getAuth().isEmpty());
+ String expectXdr =
+ "AAAAAQAAAAAk4TTtavBWsGnEN3KxHw4Ohwi22ZJHWi8hlamN5pm0TgAAABgAAAABAAAAAAAAAAAAAAAAfzBiNMmJ6dZ/ad/ZMRmLYA89bOa2TCJAcB+2KwiDK4cAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAA";
+ assertEquals(expectXdr, invokeHostFunctionOperation.toXdrBase64());
+ }
+
+ @Test
+ public void testConstructorsFromHostFunctionAndSorobanAuthorizationEntries() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ HostFunction hostFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+ SorobanAuthorizationEntry auth =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_SOURCE_ACCOUNT)
+ .build())
+ .rootInvocation(
+ new SorobanAuthorizedInvocation.Builder()
+ .subInvocations(new SorobanAuthorizedInvocation[] {})
+ .function(
+ new SorobanAuthorizedFunction.Builder()
+ .discriminant(
+ SorobanAuthorizedFunctionType
+ .SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN)
+ .createContractHostFn(createContractArgs)
+ .build())
+ .build())
+ .build();
+ InvokeHostFunctionOperation invokeHostFunctionOperation =
+ InvokeHostFunctionOperation.builder()
+ .hostFunction(hostFunction)
+ .auth(Collections.singletonList(auth))
+ .sourceAccount(source)
+ .build();
+ invokeHostFunctionOperation.setSourceAccount(source);
+ assertEquals(invokeHostFunctionOperation.getHostFunction(), hostFunction);
+ assertEquals(invokeHostFunctionOperation.getAuth(), Collections.singletonList(auth));
+ String expectXdr =
+ "AAAAAQAAAAAk4TTtavBWsGnEN3KxHw4Ohwi22ZJHWi8hlamN5pm0TgAAABgAAAABAAAAAAAAAAAAAAAAfzBiNMmJ6dZ/ad/ZMRmLYA89bOa2TCJAcB+2KwiDK4cAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAB/MGI0yYnp1n9p39kxGYtgDz1s5rZMIkBwH7YrCIMrhwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAA=";
+ assertEquals(expectXdr, invokeHostFunctionOperation.toXdrBase64());
+ }
+
+ @Test
+ public void testFromXdr() {
+ HostFunction hostFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+ InvokeHostFunctionOperation originOp =
+ InvokeHostFunctionOperation.builder().hostFunction(hostFunction).build();
+ org.stellar.sdk.xdr.Operation xdrObject = originOp.toXdr();
+ Operation restartOp = Operation.fromXdr(xdrObject);
+ assertEquals(restartOp, originOp);
+ }
+
+ @Test
+ public void testEquals() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ HostFunction hostFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+ InvokeHostFunctionOperation operation1 =
+ InvokeHostFunctionOperation.builder()
+ .hostFunction(hostFunction)
+ .sourceAccount(source)
+ .build();
+ InvokeHostFunctionOperation operation2 =
+ InvokeHostFunctionOperation.builder()
+ .hostFunction(hostFunction)
+ .sourceAccount(source)
+ .build();
+ assertEquals(operation1, operation2);
+ }
+
+ @Test
+ public void testNotEqualsHostFunction() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ HostFunction hostFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+ InvokeHostFunctionOperation operation1 =
+ InvokeHostFunctionOperation.builder()
+ .hostFunction(hostFunction)
+ .sourceAccount(source)
+ .build();
+
+ CreateContractArgs createContractArgs2 =
+ new CreateContractArgs.Builder()
+ .contractIDPreimage(
+ new ContractIDPreimage.Builder()
+ .discriminant(ContractIDPreimageType.CONTRACT_ID_PREIMAGE_FROM_ADDRESS)
+ .fromAddress(
+ new ContractIDPreimage.ContractIDPreimageFromAddress.Builder()
+ .address(
+ new Address(
+ "GAHJJJKMOKYE4RVPZEWZTKH5FVI4PA3VL7GK2LFNUBSGBV6OJP7TQSLX")
+ .toSCAddress())
+ .salt(new Uint256(new byte[32]))
+ .build())
+ .build())
+ .executable(
+ new ContractExecutable.Builder()
+ .discriminant(ContractExecutableType.CONTRACT_EXECUTABLE_TOKEN)
+ .build())
+ .build();
+ HostFunction hostFunction2 =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs2)
+ .build();
+ InvokeHostFunctionOperation operation2 =
+ InvokeHostFunctionOperation.builder()
+ .hostFunction(hostFunction2)
+ .sourceAccount(source)
+ .build();
+ assertNotEquals(operation1, operation2);
+ }
+
+ @Test
+ public void testNotEqualsAuth() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ HostFunction hostFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+ SorobanAuthorizationEntry auth1 =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_ADDRESS)
+ .address(
+ new SorobanAddressCredentials.Builder()
+ .address(
+ new Address(
+ "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW")
+ .toSCAddress())
+ .nonce(new Int64(123123432L))
+ .signatureExpirationLedger(new Uint32(new XdrUnsignedInteger(10)))
+ .build())
+ .build())
+ .rootInvocation(
+ new SorobanAuthorizedInvocation.Builder()
+ .subInvocations(new SorobanAuthorizedInvocation[] {})
+ .function(
+ new SorobanAuthorizedFunction.Builder()
+ .discriminant(
+ SorobanAuthorizedFunctionType
+ .SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN)
+ .createContractHostFn(createContractArgs)
+ .build())
+ .build())
+ .build();
+
+ SorobanAuthorizationEntry auth2 =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_SOURCE_ACCOUNT)
+ .build())
+ .rootInvocation(
+ new SorobanAuthorizedInvocation.Builder()
+ .subInvocations(new SorobanAuthorizedInvocation[] {})
+ .function(
+ new SorobanAuthorizedFunction.Builder()
+ .discriminant(
+ SorobanAuthorizedFunctionType
+ .SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN)
+ .createContractHostFn(createContractArgs)
+ .build())
+ .build())
+ .build();
+ InvokeHostFunctionOperation operation1 =
+ InvokeHostFunctionOperation.builder()
+ .hostFunction(hostFunction)
+ .auth(Collections.singletonList(auth1))
+ .sourceAccount(source)
+ .build();
+ InvokeHostFunctionOperation operation2 =
+ InvokeHostFunctionOperation.builder()
+ .hostFunction(hostFunction)
+ .auth(Collections.singletonList(auth2))
+ .sourceAccount(source)
+ .build();
+ assertNotEquals(operation1, operation2);
+ }
+
+ @Test
+ public void testNotEqualsSource() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ HostFunction hostFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+ InvokeHostFunctionOperation operation1 =
+ InvokeHostFunctionOperation.builder()
+ .hostFunction(hostFunction)
+ .sourceAccount(source)
+ .build();
+ InvokeHostFunctionOperation operation2 =
+ InvokeHostFunctionOperation.builder().hostFunction(hostFunction).build();
+ assertNotEquals(operation1, operation2);
+ }
+
+ @Test
+ public void testUploadContractWasmOperationBuilder() {
+ byte[] wasm = new byte[] {0x00, 0x01, 0x02, 0x03, 0x34, 0x45, 0x66, 0x46};
+ InvokeHostFunctionOperation operation =
+ InvokeHostFunctionOperation.uploadContractWasmOperationBuilder(wasm).build();
+ HostFunction expectedFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM)
+ .wasm(wasm)
+ .build();
+ assertEquals(operation.getHostFunction(), expectedFunction);
+ assertTrue(operation.getAuth().isEmpty());
+ assertNull(operation.getSourceAccount());
+ String expectedXdr = "AAAAAAAAABgAAAACAAAACAABAgM0RWZGAAAAAA==";
+ assertEquals(expectedXdr, operation.toXdrBase64());
+ }
+
+ @Test
+ public void createContractOperationBuilderWithWasmIdString() {
+ byte[] wasmId =
+ new byte[] {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
+ 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
+ 0x1e, 0x1f
+ };
+ String wasmIdString = Util.bytesToHex(wasmId);
+ byte[] salt =
+ new byte[] {
+ 0x11, 0x33, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
+ 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
+ 0x1e, 0x1f
+ };
+ Address address = new Address("GAHJJJKMOKYE4RVPZEWZTKH5FVI4PA3VL7GK2LFNUBSGBV6OJP7TQSLX");
+ InvokeHostFunctionOperation operation =
+ InvokeHostFunctionOperation.createContractOperationBuilder(wasmIdString, address, salt)
+ .build();
+
+ CreateContractArgs createContractArgs =
+ new CreateContractArgs.Builder()
+ .contractIDPreimage(
+ new ContractIDPreimage.Builder()
+ .discriminant(ContractIDPreimageType.CONTRACT_ID_PREIMAGE_FROM_ADDRESS)
+ .fromAddress(
+ new ContractIDPreimage.ContractIDPreimageFromAddress.Builder()
+ .address(address.toSCAddress())
+ .salt(new Uint256(salt))
+ .build())
+ .build())
+ .executable(
+ new ContractExecutable.Builder()
+ .discriminant(ContractExecutableType.CONTRACT_EXECUTABLE_WASM)
+ .wasm_hash(new Hash(wasmId))
+ .build())
+ .build();
+ HostFunction expectedFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+
+ assertEquals(operation.getHostFunction(), expectedFunction);
+ assertTrue(operation.getAuth().isEmpty());
+ assertNull(operation.getSourceAccount());
+ String expectedXdr =
+ "AAAAAAAAABgAAAABAAAAAAAAAAAAAAAADpSlTHKwTkavyS2ZqP0tUceDdV/MrSytoGRg185L/zgRMwIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHwAAAAAAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHwAAAAA=";
+ assertEquals(expectedXdr, operation.toXdrBase64());
+ }
+
+ @Test
+ public void createContractOperationBuilderWithWasmIdBytes() {
+ byte[] wasmId =
+ new byte[] {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
+ 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
+ 0x1e, 0x1f
+ };
+ byte[] salt =
+ new byte[] {
+ 0x11, 0x33, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
+ 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
+ 0x1e, 0x1f
+ };
+ Address address = new Address("GAHJJJKMOKYE4RVPZEWZTKH5FVI4PA3VL7GK2LFNUBSGBV6OJP7TQSLX");
+ InvokeHostFunctionOperation operation =
+ InvokeHostFunctionOperation.createContractOperationBuilder(wasmId, address, salt).build();
+
+ CreateContractArgs createContractArgs =
+ new CreateContractArgs.Builder()
+ .contractIDPreimage(
+ new ContractIDPreimage.Builder()
+ .discriminant(ContractIDPreimageType.CONTRACT_ID_PREIMAGE_FROM_ADDRESS)
+ .fromAddress(
+ new ContractIDPreimage.ContractIDPreimageFromAddress.Builder()
+ .address(address.toSCAddress())
+ .salt(new Uint256(salt))
+ .build())
+ .build())
+ .executable(
+ new ContractExecutable.Builder()
+ .discriminant(ContractExecutableType.CONTRACT_EXECUTABLE_WASM)
+ .wasm_hash(new Hash(wasmId))
+ .build())
+ .build();
+ HostFunction expectedFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+
+ assertEquals(operation.getHostFunction(), expectedFunction);
+ assertTrue(operation.getAuth().isEmpty());
+ assertNull(operation.getSourceAccount());
+ String expectedXdr =
+ "AAAAAAAAABgAAAABAAAAAAAAAAAAAAAADpSlTHKwTkavyS2ZqP0tUceDdV/MrSytoGRg185L/zgRMwIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHwAAAAAAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHwAAAAA=";
+ assertEquals(expectedXdr, operation.toXdrBase64());
+ }
+
+ @Test
+ public void createTokenContractOperationBuilderWithAddress() {
+ Address address = new Address("GAHJJJKMOKYE4RVPZEWZTKH5FVI4PA3VL7GK2LFNUBSGBV6OJP7TQSLX");
+ byte[] salt =
+ new byte[] {
+ 0x11, 0x33, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
+ 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
+ 0x1e, 0x1f
+ };
+ InvokeHostFunctionOperation operation =
+ InvokeHostFunctionOperation.createTokenContractOperationBuilder(address, salt).build();
+ CreateContractArgs createContractArgs =
+ new CreateContractArgs.Builder()
+ .contractIDPreimage(
+ new ContractIDPreimage.Builder()
+ .discriminant(ContractIDPreimageType.CONTRACT_ID_PREIMAGE_FROM_ADDRESS)
+ .fromAddress(
+ new ContractIDPreimage.ContractIDPreimageFromAddress.Builder()
+ .address(address.toSCAddress())
+ .salt(new Uint256(salt))
+ .build())
+ .build())
+ .executable(
+ new ContractExecutable.Builder()
+ .discriminant(ContractExecutableType.CONTRACT_EXECUTABLE_TOKEN)
+ .build())
+ .build();
+ HostFunction expectedFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+
+ assertEquals(operation.getHostFunction(), expectedFunction);
+ assertTrue(operation.getAuth().isEmpty());
+ assertNull(operation.getSourceAccount());
+ String expectedXdr =
+ "AAAAAAAAABgAAAABAAAAAAAAAAAAAAAADpSlTHKwTkavyS2ZqP0tUceDdV/MrSytoGRg185L/zgRMwIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHwAAAAEAAAAA";
+ assertEquals(expectedXdr, operation.toXdrBase64());
+ }
+
+ @Test
+ public void createTokenContractOperationBuilderWithAsset() {
+ Asset asset =
+ new AssetTypeCreditAlphaNum4(
+ "CAT", "GAHJJJKMOKYE4RVPZEWZTKH5FVI4PA3VL7GK2LFNUBSGBV6OJP7TQSLX");
+ InvokeHostFunctionOperation operation =
+ InvokeHostFunctionOperation.createTokenContractOperationBuilder(asset).build();
+ CreateContractArgs createContractArgs =
+ new CreateContractArgs.Builder()
+ .contractIDPreimage(
+ new ContractIDPreimage.Builder()
+ .discriminant(ContractIDPreimageType.CONTRACT_ID_PREIMAGE_FROM_ASSET)
+ .fromAsset(asset.toXdr())
+ .build())
+ .executable(
+ new ContractExecutable.Builder()
+ .discriminant(ContractExecutableType.CONTRACT_EXECUTABLE_TOKEN)
+ .build())
+ .build();
+ HostFunction expectedFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+
+ assertEquals(operation.getHostFunction(), expectedFunction);
+ assertTrue(operation.getAuth().isEmpty());
+ assertNull(operation.getSourceAccount());
+ String expectedXdr =
+ "AAAAAAAAABgAAAABAAAAAQAAAAFDQVQAAAAAAA6UpUxysE5Gr8ktmaj9LVHHg3VfzK0sraBkYNfOS/84AAAAAQAAAAA=";
+ assertEquals(expectedXdr, operation.toXdrBase64());
+ }
+
+ @Test
+ public void invokeContractFunctionOperationBuilder() {
+ String contractId = "CA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUWDA";
+ String funcName = "hello";
+ List parameters = Collections.singletonList(Scv.toSymbol("world"));
+ InvokeHostFunctionOperation operation =
+ InvokeHostFunctionOperation.invokeContractFunctionOperationBuilder(
+ contractId, funcName, parameters)
+ .build();
+
+ SCAddress contractIdScAddress = new Address(contractId).toSCAddress();
+ SCSymbol functionNameSCSymbol = new SCSymbol(new XdrString(funcName));
+ SCVal paramScVal = parameters.get(0);
+
+ InvokeContractArgs invokeContractArgs =
+ new InvokeContractArgs.Builder()
+ .contractAddress(contractIdScAddress)
+ .functionName(functionNameSCSymbol)
+ .args(new SCVal[] {paramScVal})
+ .build();
+ HostFunction expectedFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_INVOKE_CONTRACT)
+ .invokeContract(invokeContractArgs)
+ .build();
+
+ assertEquals(operation.getHostFunction(), expectedFunction);
+ assertTrue(operation.getAuth().isEmpty());
+ assertNull(operation.getSourceAccount());
+ String expectedXdr =
+ "AAAAAAAAABgAAAAAAAAAAT8MNL+TrQ2ZcdBMzJD3BVEcg4qtlzSkovsNegP8f+iaAAAABWhlbGxvAAAAAAAAAQAAAA8AAAAFd29ybGQAAAAAAAAA";
+ assertEquals(expectedXdr, operation.toXdrBase64());
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/MemoTest.java b/src/test/java/org/stellar/sdk/MemoTest.java
index f67702033..133c5aea6 100644
--- a/src/test/java/org/stellar/sdk/MemoTest.java
+++ b/src/test/java/org/stellar/sdk/MemoTest.java
@@ -5,10 +5,9 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.google.common.base.Strings;
-import com.google.common.io.BaseEncoding;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
+import java.math.BigInteger;
import java.util.Arrays;
import org.junit.Test;
import org.stellar.sdk.responses.TransactionDeserializer;
@@ -62,22 +61,22 @@ public void testMemoTextTooLongUtf8() {
@Test
public void testMemoId() {
MemoId memo = Memo.id(9223372036854775807L);
- assertEquals(9223372036854775807L, memo.getId());
+ assertEquals(BigInteger.valueOf(9223372036854775807L), memo.getId());
assertEquals(MemoType.MEMO_ID, memo.toXdr().getDiscriminant());
- assertEquals(new Long(9223372036854775807L), memo.toXdr().getId().getUint64());
+ assertEquals(
+ BigInteger.valueOf(9223372036854775807L), memo.toXdr().getId().getUint64().getNumber());
assertEquals("9223372036854775807", memo.toString());
}
@Test
public void testParseMemoId() {
- String longId = "10048071741004807174";
+ String maxId = "18446744073709551615";
JsonElement element =
- new JsonParser()
- .parse(String.format("{ \"memo_type\": \"id\", \"memo\": \"%s\" }", longId));
+ new JsonParser().parse(String.format("{ \"memo_type\": \"id\", \"memo\": \"%s\" }", maxId));
TransactionResponse transactionResponse =
new TransactionDeserializer().deserialize(element, null, null);
MemoId memoId = (MemoId) transactionResponse.getMemo();
- assertEquals(longId, Long.toUnsignedString(memoId.getId()));
+ assertEquals(new BigInteger(maxId), memoId.getId());
}
@Test
@@ -94,7 +93,7 @@ public void testMemoNullHexHashSuccess() {
@Test
public void testMemoHashSuccess() {
- MemoHash memo = Memo.hash(Strings.padEnd("4142434445464748494a4b4c", 64, '0'));
+ MemoHash memo = Memo.hash("4142434445464748494a4b4c0000000000000000000000000000000000000000");
assertEquals(MemoType.MEMO_HASH, memo.toXdr().getDiscriminant());
String test = "ABCDEFGHIJKL";
assertEquals(test, Util.paddedByteArrayToString(memo.getBytes()));
@@ -104,7 +103,8 @@ public void testMemoHashSuccess() {
@Test
public void testMemoHashSuccessUppercase() {
- MemoHash memo = Memo.hash(Strings.padEnd("4142434445464748494a4b4c".toUpperCase(), 64, '0'));
+ MemoHash memo =
+ Memo.hash("4142434445464748494a4b4c0000000000000000000000000000000000000000".toUpperCase());
assertEquals(MemoType.MEMO_HASH, memo.toXdr().getDiscriminant());
String test = "ABCDEFGHIJKL";
assertEquals(test, Util.paddedByteArrayToString(memo.getBytes()));
@@ -162,6 +162,6 @@ public void testMemoReturnHashSuccess() {
assertNull(memoXdr.getHash());
assertEquals(
"4142434445464748494a4b4c0000000000000000000000000000000000000000",
- BaseEncoding.base16().lowerCase().encode(memoXdr.getRetHash().getHash()));
+ Util.bytesToHex(memoXdr.getRetHash().getHash()).toLowerCase());
}
}
diff --git a/src/test/java/org/stellar/sdk/OperationTest.java b/src/test/java/org/stellar/sdk/OperationTest.java
index 6d6f905b0..55a61d1e0 100644
--- a/src/test/java/org/stellar/sdk/OperationTest.java
+++ b/src/test/java/org/stellar/sdk/OperationTest.java
@@ -1,20 +1,17 @@
package org.stellar.sdk;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.stellar.sdk.Asset.create;
-import com.google.common.collect.Lists;
-import com.google.common.io.BaseEncoding;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.EnumSet;
import org.junit.Test;
import org.stellar.sdk.xdr.SignerKey;
import org.stellar.sdk.xdr.TrustLineFlags;
-import org.stellar.sdk.xdr.XdrDataInputStream;
public class OperationTest {
@@ -161,8 +158,7 @@ public void testPathPaymentStrictReceiveOperation()
assertEquals(sendMax, parsedOperation.getSendMax());
assertTrue(parsedOperation.getDestAsset() instanceof AssetTypeCreditAlphaNum4);
assertEquals(destAmount, parsedOperation.getDestAmount());
- assertEquals(Lists.newArrayList(path), Lists.newArrayList(parsedOperation.getPath()));
-
+ assertArrayEquals(path, parsedOperation.getPath());
assertEquals(
"AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAIAAAAAAAAAAAAAA+gAAAAA7eBSYbzcL5UKo7oXO24y1ckX+XuCtkDsyNHOp1n1bxAAAAABVVNEAAAAAACNlYd30HdCuLI54eyYjyX/fDyH9IJWIr/hKDcXKQbq1QAAAAAAAAPoAAAAAgAAAAFVU0QAAAAAACoIKnpnw8rtrfxa276dFZo1C19mDqWXtG4ufhWrLUd1AAAAAlRFU1RURVNUAAAAAAAAAABE/ttVl8BLV0csW/xgXtbXOVf1lMyDluMiafl0IDVFIg==",
operation.toXdrBase64(AccountConverter.enableMuxed()));
@@ -302,7 +298,7 @@ public void testPathPaymentStrictSendOperation()
assertEquals(sendAmount, parsedOperation.getSendAmount());
assertTrue(parsedOperation.getDestAsset() instanceof AssetTypeCreditAlphaNum4);
assertEquals(destMin, parsedOperation.getDestMin());
- assertEquals(Lists.newArrayList(path), Lists.newArrayList(parsedOperation.getPath()));
+ assertArrayEquals(path, parsedOperation.getPath());
assertEquals(
"AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAA0AAAAAAAAAAAAAA+gAAAAA7eBSYbzcL5UKo7oXO24y1ckX+XuCtkDsyNHOp1n1bxAAAAABVVNEAAAAAACNlYd30HdCuLI54eyYjyX/fDyH9IJWIr/hKDcXKQbq1QAAAAAAACMoAAAAAgAAAAFVU0QAAAAAACoIKnpnw8rtrfxa276dFZo1C19mDqWXtG4ufhWrLUd1AAAAAlRFU1RURVNUAAAAAAAAAABE/ttVl8BLV0csW/xgXtbXOVf1lMyDluMiafl0IDVFIg==",
@@ -751,12 +747,9 @@ public void testManageSellOfferOperation_BadArithmeticRegression() throws IOExce
String transactionEnvelopeToDecode =
"AAAAAButy5zasS3DLZ5uFpZHL25aiHUfKRwdv1+3Wp12Ce7XAAAAZAEyGwYAAAAOAAAAAAAAAAAAAAABAAAAAQAAAAAbrcuc2rEtwy2ebhaWRy9uWoh1HykcHb9ft1qddgnu1wAAAAMAAAAAAAAAAUtJTgAAAAAARkrT28ebM6YQyhVZi1ttlwq/dk6ijTpyTNuHIMgUp+EAAAAAAAARPSfDKZ0AAv7oAAAAAAAAAAAAAAAAAAAAAXYJ7tcAAABAbE8rEoFt0Hcv41iwVCl74C1Hyr+Lj8ZyaYn7zTJhezClbc+pTW1KgYFIZOJiGVth2xFnBT1pMXuQkVdTlB3FCw==";
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] bytes = base64Encoding.decode(transactionEnvelopeToDecode);
org.stellar.sdk.xdr.TransactionEnvelope transactionEnvelope =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(
- new XdrDataInputStream(new ByteArrayInputStream(bytes)));
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transactionEnvelopeToDecode);
assertEquals(1, transactionEnvelope.getV0().getTx().getOperations().length);
ManageSellOfferOperation op =
@@ -774,12 +767,9 @@ public void testManageBuyOfferOperation_BadArithmeticRegression() throws IOExcep
String transactionEnvelopeToDecode =
"AAAAAButy5zasS3DLZ5uFpZHL25aiHUfKRwdv1+3Wp12Ce7XAAAAZAEyGwYAAAAxAAAAAAAAAAAAAAABAAAAAQAAAAAbrcuc2rEtwy2ebhaWRy9uWoh1HykcHb9ft1qddgnu1wAAAAwAAAABS0lOAAAAAABGStPbx5szphDKFVmLW22XCr92TqKNOnJM24cgyBSn4QAAAAAAAAAAACNyOCfDKZ0AAv7oAAAAAAABv1IAAAAAAAAAAA==";
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] bytes = base64Encoding.decode(transactionEnvelopeToDecode);
org.stellar.sdk.xdr.TransactionEnvelope transactionEnvelope =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(
- new XdrDataInputStream(new ByteArrayInputStream(bytes)));
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transactionEnvelopeToDecode);
assertEquals(1, transactionEnvelope.getV0().getTx().getOperations().length);
ManageBuyOfferOperation op =
@@ -1329,11 +1319,11 @@ public void testSetTrustlineFlagsOperation() {
org.stellar.sdk.xdr.Operation xdr = operation.toXdr(AccountConverter.enableMuxed());
assertEquals(
TrustLineFlags.AUTHORIZED_FLAG.getValue(),
- xdr.getBody().getSetTrustLineFlagsOp().getClearFlags().getUint32().intValue());
+ xdr.getBody().getSetTrustLineFlagsOp().getClearFlags().getUint32().getNumber().intValue());
assertEquals(
TrustLineFlags.AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG.getValue()
| TrustLineFlags.TRUSTLINE_CLAWBACK_ENABLED_FLAG.getValue(),
- xdr.getBody().getSetTrustLineFlagsOp().getSetFlags().getUint32().intValue());
+ xdr.getBody().getSetTrustLineFlagsOp().getSetFlags().getUint32().getNumber().intValue());
SetTrustlineFlagsOperation parsedOperation =
(SetTrustlineFlagsOperation) Operation.fromXdr(AccountConverter.enableMuxed(), xdr);
assertEquals(accountId, parsedOperation.getTrustor());
diff --git a/src/test/java/org/stellar/sdk/PredicateTest.java b/src/test/java/org/stellar/sdk/PredicateTest.java
new file mode 100644
index 000000000..8df4aef94
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/PredicateTest.java
@@ -0,0 +1,25 @@
+package org.stellar.sdk;
+
+import static org.junit.Assert.assertEquals;
+
+import java.math.BigInteger;
+import java.time.Instant;
+import org.junit.Test;
+
+public class PredicateTest {
+ @Test
+ public void testAbsBeforeEpochLargeThanInstantMax() {
+ BigInteger epoch = BigInteger.valueOf(Instant.MAX.getEpochSecond()).add(BigInteger.ONE);
+ Predicate.AbsBefore absBefore = new Predicate.AbsBefore(epoch);
+ assertEquals(absBefore.getDate(), Instant.MAX);
+ assertEquals(absBefore.getTimestampSeconds(), epoch);
+ }
+
+ @Test
+ public void testAbsBeforeEpochLessThanInstantMax() {
+ BigInteger epoch = BigInteger.valueOf(1691448835L);
+ Predicate.AbsBefore absBefore = new Predicate.AbsBefore(epoch);
+ assertEquals(absBefore.getDate().toString(), "2023-08-07T22:53:55Z");
+ assertEquals(absBefore.getTimestampSeconds(), epoch);
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/RestoreFootprintOperationTest.java b/src/test/java/org/stellar/sdk/RestoreFootprintOperationTest.java
new file mode 100644
index 000000000..ac55cd8dd
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/RestoreFootprintOperationTest.java
@@ -0,0 +1,56 @@
+package org.stellar.sdk;
+
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNull;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class RestoreFootprintOperationTest {
+ @Test
+ public void testBuilderWithSource() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ RestoreFootprintOperation op =
+ RestoreFootprintOperation.builder().sourceAccount(source).build();
+ assertEquals(source, op.getSourceAccount());
+ String expectXdr = "AAAAAQAAAAAk4TTtavBWsGnEN3KxHw4Ohwi22ZJHWi8hlamN5pm0TgAAABoAAAAA";
+ assertEquals(expectXdr, op.toXdrBase64());
+ }
+
+ @Test
+ public void testBuilderWithoutSource() {
+ RestoreFootprintOperation op = RestoreFootprintOperation.builder().build();
+ assertNull(op.getSourceAccount());
+ String expectXdr = "AAAAAAAAABoAAAAA";
+ assertEquals(expectXdr, op.toXdrBase64());
+ }
+
+ @Test
+ public void testFromXdr() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ RestoreFootprintOperation originOp =
+ RestoreFootprintOperation.builder().sourceAccount(source).build();
+ org.stellar.sdk.xdr.Operation xdrObject = originOp.toXdr();
+ Operation restartOp = Operation.fromXdr(xdrObject);
+ Assert.assertEquals(restartOp, originOp);
+ }
+
+ @Test
+ public void testEquals() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ RestoreFootprintOperation operation1 =
+ RestoreFootprintOperation.builder().sourceAccount(source).build();
+ RestoreFootprintOperation operation2 =
+ RestoreFootprintOperation.builder().sourceAccount(source).build();
+ assertEquals(operation1, operation2);
+ }
+
+ @Test
+ public void testNotEquals() {
+ String source = "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW";
+ RestoreFootprintOperation operation1 =
+ RestoreFootprintOperation.builder().sourceAccount(source).build();
+ RestoreFootprintOperation operation2 = RestoreFootprintOperation.builder().build();
+ Assert.assertNotEquals(operation1, operation2);
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/Sep10ChallengeTest.java b/src/test/java/org/stellar/sdk/Sep10ChallengeTest.java
index 1f928fd3f..95ca1e0d9 100644
--- a/src/test/java/org/stellar/sdk/Sep10ChallengeTest.java
+++ b/src/test/java/org/stellar/sdk/Sep10ChallengeTest.java
@@ -5,11 +5,11 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.google.common.collect.ImmutableList;
-import com.google.common.io.BaseEncoding;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.Arrays;
+import java.util.Base64;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -47,8 +47,7 @@ public void testChallenge() throws InvalidSep10ChallengeException {
assertEquals(domainName + " auth", homeDomainOp.getName());
assertEquals(64, homeDomainOp.getValue().length);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- assertTrue(base64Encoding.canDecode(new String(homeDomainOp.getValue())));
+ Base64.getDecoder().decode(new String(homeDomainOp.getValue()));
ManageDataOperation webAuthDomainOp = (ManageDataOperation) transaction.getOperations()[1];
assertEquals(server.getAccountId(), webAuthDomainOp.getSourceAccount());
@@ -151,7 +150,7 @@ public void testReadChallengeTransactionAcceptsBothV0AndV1()
assertEquals(v0ChallengeTransaction, v1ChallengeTransaction);
- for (String envelopeBase64 : ImmutableList.of(v0Base64, v1Base64)) {
+ for (String envelopeBase64 : Arrays.asList(v0Base64, v1Base64)) {
Sep10Challenge.ChallengeTransaction challengeTransaction =
Sep10Challenge.readChallengeTransaction(
envelopeBase64, server.getAccountId(), Network.TESTNET, domainName, webAuthDomain);
@@ -288,8 +287,7 @@ public void testReadChallengeTransactionInvalidNotSignedByServer() throws IOExce
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation manageDataOperation1 =
@@ -397,8 +395,7 @@ public void testReadChallengeTransactionInvalidSeqNoNotZero() throws IOException
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), 100L);
ManageDataOperation manageDataOperation1 =
@@ -443,8 +440,7 @@ public void testReadChallengeTransactionInvalidTimeboundsInfinite() throws IOExc
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation operation =
@@ -480,7 +476,7 @@ public void testReadChallengeTransactionInvalidTimeBoundsTooEarly()
KeyPair client = KeyPair.random();
long current = System.currentTimeMillis() / 1000L;
- long start = current + Sep10Challenge.GRACE_PERIOD_SECONDS + 30;
+ long start = current + Sep10Challenge.GRACE_PERIOD_SECONDS.longValue() + 30;
long end = current + 600;
TimeBounds timeBounds = new TimeBounds(start, end);
String domainName = "example.com";
@@ -510,7 +506,7 @@ public void testReadChallengeTransactionGracePeriod()
KeyPair client = KeyPair.random();
long current = System.currentTimeMillis() / 1000L;
- long start = current + Sep10Challenge.GRACE_PERIOD_SECONDS - 30;
+ long start = current + Sep10Challenge.GRACE_PERIOD_SECONDS.longValue() - 30;
long end = current + 600;
TimeBounds timeBounds = new TimeBounds(start, end);
String domainName = "example.com";
@@ -614,8 +610,7 @@ public void testReadChallengeTransactionInvalidOperationNoSourceAccount() throws
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation manageDataOperation1 =
@@ -658,8 +653,7 @@ public void testReadChallengeTransactionInvalidDataValueWrongEncodedLength() thr
byte[] nonce = new byte[32];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation manageDataOperation1 =
@@ -701,7 +695,8 @@ public void testReadChallengeTransactionInvalidDataValueCorruptBase64() throws I
TimeBounds timeBounds = new TimeBounds(now, end);
byte[] encodedNonce =
- "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA?AAAAAAAAAAAAAAAAAAAAAAAAAA".getBytes("UTF-8");
+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA?AAAAAAAAAAAAAAAAAAAAAAAAAA"
+ .getBytes(StandardCharsets.UTF_8);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation manageDataOperation1 =
new ManageDataOperation.Builder(domainName + " auth", encodedNonce)
@@ -726,9 +721,7 @@ public void testReadChallengeTransactionInvalidDataValueCorruptBase64() throws I
} catch (InvalidSep10ChallengeException e) {
assertEquals(
"Failed to decode random nonce provided in ManageData operation.", e.getMessage());
- assertEquals(
- "com.google.common.io.BaseEncoding$DecodingException: Unrecognized character: ?",
- e.getCause().getMessage());
+ assertEquals("Illegal base64 character 3f", e.getCause().getMessage());
}
}
@@ -748,8 +741,7 @@ public void testReadChallengeTransactionInvalidDataValueWrongByteLength() throws
byte[] nonce = new byte[47];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation manageDataOperation1 =
@@ -835,8 +827,7 @@ public void testReadChallengeTransactionInvalidDataValueIsNull() throws IOExcept
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation operation1 =
@@ -884,8 +875,7 @@ public void testReadChallengeTransactionInvalidDataValueIsNull() throws IOExcept
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation operation1 =
@@ -933,8 +923,7 @@ public void testReadChallengeTransactionInvalidAdditionalManageDataOpsWithSource
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation operation1 =
@@ -979,8 +968,7 @@ public void testReadChallengeTransactionInvalidAdditionalOpsOfOtherTypes() throw
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation operation1 =
@@ -1231,8 +1219,7 @@ public void testReadChallengeTransactionInvalidWebAuthDomainOperationValueIsNull
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation domainNameOperation =
@@ -1281,8 +1268,7 @@ public void testReadChallengeTransactionInvalidWebAuthDomainOperationValueIsNull
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation domainNameOperation =
@@ -1353,8 +1339,7 @@ public void testChallengeWithClientDomain() throws InvalidSep10ChallengeExceptio
assertEquals(domainName + " auth", homeDomainOp.getName());
assertEquals(64, homeDomainOp.getValue().length);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- assertTrue(base64Encoding.canDecode(new String(homeDomainOp.getValue())));
+ Base64.getDecoder().decode(new String(homeDomainOp.getValue()));
ManageDataOperation webAuthDomainOp = (ManageDataOperation) transaction.getOperations()[1];
assertEquals(server.getAccountId(), webAuthDomainOp.getSourceAccount());
@@ -1445,7 +1430,7 @@ public void testVerifyChallengeWithClientDomain()
transaction.sign(clientDomainSigner);
// should pass if clientDomainSigner is omitted from signers set
- Set signers = new HashSet(Arrays.asList(client.getAccountId()));
+ Set signers = new HashSet<>(Collections.singletonList(client.getAccountId()));
Sep10Challenge.verifyChallengeTransactionSigners(
transaction.toEnvelopeXdrBase64(),
server.getAccountId(),
@@ -1530,8 +1515,7 @@ public void testVerifyChallengeTransactionThresholdInvalidNotSignedByServer() th
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation manageDataOperation1 =
@@ -2080,8 +2064,7 @@ public void testVerifyChallengeTransactionSignersInvalidServer() throws IOExcept
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation manageDataOperation1 =
@@ -2677,8 +2660,7 @@ public void testVerifyChallengeTransactionSignersInvalidNoSignersEmptySet()
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation operation1 =
@@ -2731,8 +2713,7 @@ public void testVerifyChallengeTransactionSignersInvalidNoSignersEmptySet()
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation operation1 =
@@ -2788,8 +2769,7 @@ public void testVerifyChallengeTransactionSignersInvalidNoSignersEmptySet()
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation operation1 =
@@ -2841,8 +2821,7 @@ public void testVerifyChallengeTransactionInvalidAdditionalOpsOfOtherTypes() thr
byte[] nonce = new byte[48];
SecureRandom random = new SecureRandom();
random.nextBytes(nonce);
- BaseEncoding base64Encoding = BaseEncoding.base64();
- byte[] encodedNonce = base64Encoding.encode(nonce).getBytes();
+ byte[] encodedNonce = Base64.getEncoder().encode(nonce);
Account sourceAccount = new Account(server.getAccountId(), -1L);
ManageDataOperation operation1 =
diff --git a/src/test/java/org/stellar/sdk/ServerTest.java b/src/test/java/org/stellar/sdk/ServerTest.java
index cb4486cac..ad839a7a2 100644
--- a/src/test/java/org/stellar/sdk/ServerTest.java
+++ b/src/test/java/org/stellar/sdk/ServerTest.java
@@ -206,7 +206,7 @@ Transaction buildTransaction(Network network) throws IOException {
assertEquals(1, builder.getOperationsCount());
Transaction transaction = builder.build();
assertEquals(2908908335136769L, transaction.getSequenceNumber());
- assertEquals(new Long(2908908335136769L), account.getSequenceNumber());
+ assertEquals(Long.valueOf(2908908335136769L), account.getSequenceNumber());
transaction.sign(source);
return transaction;
}
@@ -240,7 +240,7 @@ public void testSubmitTransactionSuccess() throws IOException, AccountRequiresMe
SubmitTransactionResponse response = server.submitTransaction(this.buildTransaction(), true);
assertTrue(response.isSuccess());
- assertEquals(response.getLedger(), new Long(826150L));
+ assertEquals(response.getLedger(), Long.valueOf(826150L));
assertEquals(
response.getHash(), "2634d2cf5adcbd3487d1df042166eef53830115844fdde1588828667bf93ff42");
assertEquals(
diff --git a/src/test/java/org/stellar/sdk/SetOptionsOperationTest.java b/src/test/java/org/stellar/sdk/SetOptionsOperationTest.java
index ab61c79a5..092e4baa7 100644
--- a/src/test/java/org/stellar/sdk/SetOptionsOperationTest.java
+++ b/src/test/java/org/stellar/sdk/SetOptionsOperationTest.java
@@ -3,7 +3,6 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import com.google.common.io.BaseEncoding;
import org.junit.Test;
import org.stellar.sdk.xdr.SignerKey;
@@ -17,9 +16,8 @@ public void testPaylodSignerKey() {
String payloadSignerStrKey = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ";
byte[] payload =
- BaseEncoding.base16()
- .decode(
- "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20".toUpperCase());
+ Util.hexToBytes(
+ "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20".toUpperCase());
SignedPayloadSigner signedPayloadSigner =
new SignedPayloadSigner(StrKey.decodeStellarAccountId(payloadSignerStrKey), payload);
SignerKey signerKey = Signer.signedPayload(signedPayloadSigner);
diff --git a/src/test/java/org/stellar/sdk/SignedPayloadSignerTest.java b/src/test/java/org/stellar/sdk/SignedPayloadSignerTest.java
index 7b5666b35..787ee9759 100644
--- a/src/test/java/org/stellar/sdk/SignedPayloadSignerTest.java
+++ b/src/test/java/org/stellar/sdk/SignedPayloadSignerTest.java
@@ -2,7 +2,6 @@
import static org.junit.Assert.fail;
-import com.google.common.io.BaseEncoding;
import org.junit.Test;
import org.stellar.sdk.xdr.AccountID;
import org.stellar.sdk.xdr.PublicKey;
@@ -22,10 +21,9 @@ public void itFailsWhenAccoutIDIsNull() {
public void itFailsWhenPayloadLengthTooBig() {
String accountStrKey = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ";
byte[] payload =
- BaseEncoding.base16()
- .decode(
- "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f200102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2001"
- .toUpperCase());
+ Util.hexToBytes(
+ "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f200102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2001"
+ .toUpperCase());
try {
new SignedPayloadSigner(StrKey.decodeStellarAccountId(accountStrKey), payload);
fail("should not create a payload signer if payload > max length");
diff --git a/src/test/java/org/stellar/sdk/SignerTest.java b/src/test/java/org/stellar/sdk/SignerTest.java
index 28e7ec6f0..5a3855982 100644
--- a/src/test/java/org/stellar/sdk/SignerTest.java
+++ b/src/test/java/org/stellar/sdk/SignerTest.java
@@ -3,7 +3,6 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import com.google.common.io.BaseEncoding;
import org.junit.Test;
import org.stellar.sdk.xdr.SignerKey;
@@ -14,9 +13,8 @@ public void itCreatesSignedPayloadSigner() {
String accountStrKey = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ";
byte[] payload =
- BaseEncoding.base16()
- .decode(
- "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20".toUpperCase());
+ Util.hexToBytes(
+ "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20".toUpperCase());
SignedPayloadSigner signedPayloadSigner =
new SignedPayloadSigner(StrKey.decodeStellarAccountId(accountStrKey), payload);
SignerKey signerKey = Signer.signedPayload(signedPayloadSigner);
diff --git a/src/test/java/org/stellar/sdk/SorobanDataBuilderTest.java b/src/test/java/org/stellar/sdk/SorobanDataBuilderTest.java
new file mode 100644
index 000000000..f85f51c3e
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/SorobanDataBuilderTest.java
@@ -0,0 +1,142 @@
+package org.stellar.sdk;
+
+import static java.util.Collections.singletonList;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import org.junit.Test;
+import org.stellar.sdk.xdr.ExtensionPoint;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.LedgerEntryType;
+import org.stellar.sdk.xdr.LedgerFootprint;
+import org.stellar.sdk.xdr.LedgerKey;
+import org.stellar.sdk.xdr.SorobanResources;
+import org.stellar.sdk.xdr.SorobanTransactionData;
+import org.stellar.sdk.xdr.Uint32;
+import org.stellar.sdk.xdr.XdrUnsignedInteger;
+
+public class SorobanDataBuilderTest {
+ LedgerKey readOnly =
+ new LedgerKey.Builder()
+ .discriminant(LedgerEntryType.ACCOUNT)
+ .account(
+ new LedgerKey.LedgerKeyAccount.Builder()
+ .accountID(
+ KeyPair.fromAccountId(
+ "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO")
+ .getXdrAccountId())
+ .build())
+ .build();
+ LedgerKey readWrite =
+ new LedgerKey.Builder()
+ .discriminant(LedgerEntryType.ACCOUNT)
+ .account(
+ new LedgerKey.LedgerKeyAccount.Builder()
+ .accountID(
+ KeyPair.fromAccountId(
+ "GAHJJJKMOKYE4RVPZEWZTKH5FVI4PA3VL7GK2LFNUBSGBV6OJP7TQSLX")
+ .getXdrAccountId())
+ .build())
+ .build();
+
+ SorobanTransactionData emptySorobanData =
+ new SorobanTransactionData.Builder()
+ .resources(
+ new SorobanResources.Builder()
+ .footprint(
+ new LedgerFootprint.Builder()
+ .readOnly(new LedgerKey[] {})
+ .readWrite(new LedgerKey[] {})
+ .build())
+ .instructions(new Uint32(new XdrUnsignedInteger(0)))
+ .readBytes(new Uint32(new XdrUnsignedInteger(0)))
+ .writeBytes(new Uint32(new XdrUnsignedInteger(0)))
+ .build())
+ .refundableFee(new Int64(0L))
+ .ext(new ExtensionPoint.Builder().discriminant(0).build())
+ .build();
+
+ SorobanTransactionData presetSorobanData =
+ new SorobanTransactionData.Builder()
+ .resources(
+ new SorobanResources.Builder()
+ .footprint(
+ new LedgerFootprint.Builder()
+ .readOnly(new LedgerKey[] {readOnly})
+ .readWrite(new LedgerKey[] {readWrite})
+ .build())
+ .instructions(new Uint32(new XdrUnsignedInteger(1)))
+ .readBytes(new Uint32(new XdrUnsignedInteger(2)))
+ .writeBytes(new Uint32(new XdrUnsignedInteger(3)))
+ .build())
+ .refundableFee(new Int64(5L))
+ .ext(new ExtensionPoint.Builder().discriminant(0).build())
+ .build();
+
+ @Test
+ public void testConstructorFromEmpty() {
+ SorobanTransactionData actualData = new SorobanDataBuilder().build();
+ assertEquals(emptySorobanData, actualData);
+ }
+
+ @Test
+ public void testConstructorFromBase64() throws IOException {
+ String base64 = presetSorobanData.toXdrBase64();
+ SorobanTransactionData actualData = new SorobanDataBuilder(base64).build();
+ assertEquals(presetSorobanData, actualData);
+ }
+
+ @Test
+ public void testConstructorFromSorobanTransactionData() {
+ SorobanTransactionData actualData = new SorobanDataBuilder(presetSorobanData).build();
+ assertEquals(presetSorobanData, actualData);
+ }
+
+ @Test
+ public void testSetProperties() {
+ SorobanTransactionData actualData =
+ new SorobanDataBuilder()
+ .setReadOnly(singletonList(readOnly))
+ .setReadWrite(singletonList(readWrite))
+ .setRefundableFee(5)
+ .setResources(
+ new SorobanDataBuilder.Resources.ResourcesBuilder()
+ .cpuInstructions(1L)
+ .readBytes(2L)
+ .writeBytes(3L)
+ .build())
+ .build();
+ assertEquals(presetSorobanData, actualData);
+ }
+
+ @Test
+ public void testLeavesUntouchedFootprintsUntouched() {
+ SorobanTransactionData data0 =
+ new SorobanDataBuilder(presetSorobanData).setReadOnly(null).build();
+ assertArrayEquals(
+ new LedgerKey[] {readOnly}, data0.getResources().getFootprint().getReadOnly());
+
+ SorobanTransactionData data1 =
+ new SorobanDataBuilder(presetSorobanData).setReadOnly(new ArrayList<>()).build();
+ assertArrayEquals(new LedgerKey[] {}, data1.getResources().getFootprint().getReadOnly());
+
+ SorobanTransactionData data3 =
+ new SorobanDataBuilder(presetSorobanData).setReadWrite(null).build();
+ assertArrayEquals(
+ new LedgerKey[] {readWrite}, data3.getResources().getFootprint().getReadWrite());
+
+ SorobanTransactionData data4 =
+ new SorobanDataBuilder(presetSorobanData).setReadWrite(new ArrayList<>()).build();
+ assertArrayEquals(new LedgerKey[] {}, data4.getResources().getFootprint().getReadWrite());
+ }
+
+ @Test
+ public void testBuildCopy() {
+ SorobanTransactionData actualData = new SorobanDataBuilder(presetSorobanData).build();
+ assertEquals(presetSorobanData, actualData);
+ assertNotSame(presetSorobanData, actualData);
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/SorobanServerTest.java b/src/test/java/org/stellar/sdk/SorobanServerTest.java
new file mode 100644
index 000000000..bc504c511
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/SorobanServerTest.java
@@ -0,0 +1,1364 @@
+package org.stellar.sdk;
+
+import static java.util.Collections.singletonList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.stellar.sdk.xdr.SCValType.SCV_LEDGER_KEY_CONTRACT_INSTANCE;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import okhttp3.HttpUrl;
+import okhttp3.mockwebserver.Dispatcher;
+import okhttp3.mockwebserver.MockResponse;
+import okhttp3.mockwebserver.MockWebServer;
+import okhttp3.mockwebserver.RecordedRequest;
+import org.jetbrains.annotations.NotNull;
+import org.junit.Test;
+import org.stellar.sdk.requests.sorobanrpc.EventFilterType;
+import org.stellar.sdk.requests.sorobanrpc.GetEventsRequest;
+import org.stellar.sdk.requests.sorobanrpc.GetLedgerEntriesRequest;
+import org.stellar.sdk.requests.sorobanrpc.GetTransactionRequest;
+import org.stellar.sdk.requests.sorobanrpc.SendTransactionRequest;
+import org.stellar.sdk.requests.sorobanrpc.SimulateTransactionRequest;
+import org.stellar.sdk.requests.sorobanrpc.SorobanRpcErrorResponse;
+import org.stellar.sdk.requests.sorobanrpc.SorobanRpcRequest;
+import org.stellar.sdk.responses.sorobanrpc.GetEventsResponse;
+import org.stellar.sdk.responses.sorobanrpc.GetHealthResponse;
+import org.stellar.sdk.responses.sorobanrpc.GetLatestLedgerResponse;
+import org.stellar.sdk.responses.sorobanrpc.GetLedgerEntriesResponse;
+import org.stellar.sdk.responses.sorobanrpc.GetNetworkResponse;
+import org.stellar.sdk.responses.sorobanrpc.SendTransactionResponse;
+import org.stellar.sdk.responses.sorobanrpc.SimulateTransactionResponse;
+import org.stellar.sdk.xdr.ContractDataDurability;
+import org.stellar.sdk.xdr.ContractExecutable;
+import org.stellar.sdk.xdr.ContractExecutableType;
+import org.stellar.sdk.xdr.ContractIDPreimage;
+import org.stellar.sdk.xdr.ContractIDPreimageType;
+import org.stellar.sdk.xdr.CreateContractArgs;
+import org.stellar.sdk.xdr.ExtensionPoint;
+import org.stellar.sdk.xdr.HostFunction;
+import org.stellar.sdk.xdr.HostFunctionType;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.InvokeContractArgs;
+import org.stellar.sdk.xdr.LedgerEntryType;
+import org.stellar.sdk.xdr.LedgerFootprint;
+import org.stellar.sdk.xdr.LedgerKey;
+import org.stellar.sdk.xdr.SCSymbol;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.SorobanAuthorizationEntry;
+import org.stellar.sdk.xdr.SorobanAuthorizedFunction;
+import org.stellar.sdk.xdr.SorobanAuthorizedFunctionType;
+import org.stellar.sdk.xdr.SorobanAuthorizedInvocation;
+import org.stellar.sdk.xdr.SorobanCredentials;
+import org.stellar.sdk.xdr.SorobanCredentialsType;
+import org.stellar.sdk.xdr.SorobanResources;
+import org.stellar.sdk.xdr.SorobanTransactionData;
+import org.stellar.sdk.xdr.Uint256;
+import org.stellar.sdk.xdr.Uint32;
+import org.stellar.sdk.xdr.XdrString;
+import org.stellar.sdk.xdr.XdrUnsignedInteger;
+
+public class SorobanServerTest {
+ private final Gson gson = new Gson();
+
+ @Test
+ public void testGetAccount()
+ throws IOException, SorobanRpcErrorResponse, AccountNotFoundException {
+ String accountId = "GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54";
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"ecb18f82ec12484190673502d0486b98\",\n"
+ + " \"result\": {\n"
+ + " \"entries\": [\n"
+ + " {\n"
+ + " \"key\": \"AAAAAAAAAADBPp7TMinJylnn+6dQXJACNc15LF+aJ2Py1BaR4P10JA==\",\n"
+ + " \"xdr\": \"AAAAAAAAAADBPp7TMinJylnn+6dQXJACNc15LF+aJ2Py1BaR4P10JAAAABdIcDhpAAADHAAAAAwAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAABfI8AAAAAZMK3qQ==\",\n"
+ + " \"lastModifiedLedgerSeq\": \"97423\"\n"
+ + " }\n"
+ + " ],\n"
+ + " \"latestLedger\": \"108023\"\n"
+ + " }\n"
+ + "}";
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ GetLedgerEntriesRequest expectedRequest =
+ new GetLedgerEntriesRequest(
+ singletonList("AAAAAAAAAADBPp7TMinJylnn+6dQXJACNc15LF+aJ2Py1BaR4P10JA=="));
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("getLedgerEntries")
+ && sorobanRpcRequest.getParams().equals(expectedRequest)) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ TransactionBuilderAccount resp = server.getAccount(accountId);
+ assertEquals(resp.getAccountId(), accountId);
+ assertEquals(resp.getSequenceNumber().longValue(), 3418793967628L);
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test(expected = AccountNotFoundException.class)
+ public void testGetAccountNotFoundThrows()
+ throws IOException, SorobanRpcErrorResponse, AccountNotFoundException {
+ String accountId = "GBG6OSICP2YJ5ROY4HBGNSVRQDCQ4RYPFFUH6I6BI7LHYNW2CM7AJVBE";
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"0376b51e6a744dd2abb3b83be4c2e6dd\",\n"
+ + " \"result\": {\n"
+ + " \"entries\": null,\n"
+ + " \"latestLedger\": \"109048\"\n"
+ + " }\n"
+ + "}";
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("getLedgerEntries")) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ server.getAccount(accountId);
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testGetHealth() throws IOException, SorobanRpcErrorResponse {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"status\": \"healthy\"\n"
+ + " }\n"
+ + "}";
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("getHealth")) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ GetHealthResponse resp = server.getHealth();
+ assertEquals(resp.getStatus(), "healthy");
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testGetContractData() throws IOException, SorobanRpcErrorResponse {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"839c6c921d40456db5ba8a1c4e1a0e70\",\n"
+ + " \"result\": {\n"
+ + " \"entries\": [\n"
+ + " {\n"
+ + " \"key\": \"AAAABgAAAAFgdoLyR3pr6M3w/fMr4T1fJaaGzAlP2T1ao9e2gjLQwAAAABQAAAABAAAAAA==\",\n"
+ + " \"xdr\": \"AAAABgAAAAFgdoLyR3pr6M3w/fMr4T1fJaaGzAlP2T1ao9e2gjLQwAAAABQAAAABAAAAAAAAAAAAAAATAAAAALnBupvoT7RHZ+oTeaPHSiSufpac3O3mc0u663Kqbko/AAAAAQAAAAEAAAAPAAAAB0NPVU5URVIAAAAAAwAAAAEAABD1\",\n"
+ + " \"lastModifiedLedgerSeq\": \"290\"\n"
+ + " }\n"
+ + " ],\n"
+ + " \"latestLedger\": \"296\"\n"
+ + " }\n"
+ + "}";
+
+ String contractId = "CBQHNAXSI55GX2GN6D67GK7BHVPSLJUGZQEU7WJ5LKR5PNUCGLIMAO4K";
+ SCVal key = new SCVal.Builder().discriminant(SCV_LEDGER_KEY_CONTRACT_INSTANCE).build();
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+
+ Address address = new Address(contractId);
+ LedgerKey.LedgerKeyContractData ledgerKeyContractData =
+ new LedgerKey.LedgerKeyContractData.Builder()
+ .contract(address.toSCAddress())
+ .key(key)
+ .durability(ContractDataDurability.PERSISTENT)
+ .build();
+ LedgerKey ledgerKey =
+ new LedgerKey.Builder()
+ .discriminant(LedgerEntryType.CONTRACT_DATA)
+ .contractData(ledgerKeyContractData)
+ .build();
+
+ GetLedgerEntriesRequest expectedRequest = null;
+ try {
+ expectedRequest = new GetLedgerEntriesRequest(singletonList(ledgerKey.toXdrBase64()));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("getLedgerEntries")
+ && sorobanRpcRequest.getParams().equals(expectedRequest)) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ Optional resp =
+ server.getContractData(contractId, key, SorobanServer.Durability.PERSISTENT);
+ assertTrue(resp.isPresent());
+ assertEquals(resp.get().getLastModifiedLedger().longValue(), 290L);
+ assertEquals(
+ resp.get().getKey(),
+ "AAAABgAAAAFgdoLyR3pr6M3w/fMr4T1fJaaGzAlP2T1ao9e2gjLQwAAAABQAAAABAAAAAA==");
+ assertEquals(
+ resp.get().getXdr(),
+ "AAAABgAAAAFgdoLyR3pr6M3w/fMr4T1fJaaGzAlP2T1ao9e2gjLQwAAAABQAAAABAAAAAAAAAAAAAAATAAAAALnBupvoT7RHZ+oTeaPHSiSufpac3O3mc0u663Kqbko/AAAAAQAAAAEAAAAPAAAAB0NPVU5URVIAAAAAAwAAAAEAABD1");
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testGetContractDataReturnNull() throws IOException, SorobanRpcErrorResponse {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"7d61ef6b1f974ba886b323f4266b4211\",\n"
+ + " \"result\": {\n"
+ + " \"entries\": null,\n"
+ + " \"latestLedger\": \"191\"\n"
+ + " }\n"
+ + "}";
+ String contractId = "CBQHNAXSI55GX2GN6D67GK7BHVPSLJUGZQEU7WJ5LKR5PNUCGLIMAO4K";
+ SCVal key = new SCVal.Builder().discriminant(SCV_LEDGER_KEY_CONTRACT_INSTANCE).build();
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+
+ Address address = new Address(contractId);
+ LedgerKey.LedgerKeyContractData ledgerKeyContractData =
+ new LedgerKey.LedgerKeyContractData.Builder()
+ .contract(address.toSCAddress())
+ .key(key)
+ .durability(ContractDataDurability.PERSISTENT)
+ .build();
+ LedgerKey ledgerKey =
+ new LedgerKey.Builder()
+ .discriminant(LedgerEntryType.CONTRACT_DATA)
+ .contractData(ledgerKeyContractData)
+ .build();
+
+ GetLedgerEntriesRequest expectedRequest = null;
+ try {
+ expectedRequest = new GetLedgerEntriesRequest(singletonList(ledgerKey.toXdrBase64()));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("getLedgerEntries")
+ && sorobanRpcRequest.getParams().equals(expectedRequest)) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ Optional resp =
+ server.getContractData(contractId, key, SorobanServer.Durability.PERSISTENT);
+ assertFalse(resp.isPresent());
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testGetLedgerEntries() throws IOException, SorobanRpcErrorResponse {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"0ce70038b1804b3c93ca7abc137f3061\",\n"
+ + " \"result\": {\n"
+ + " \"entries\": [\n"
+ + " {\n"
+ + " \"key\": \"AAAAAAAAAACynni6I2ACEzWuORVM1b2y0k1ZDni0W6JlC/Ad/mfCSg==\",\n"
+ + " \"xdr\": \"AAAAAAAAAACynni6I2ACEzWuORVM1b2y0k1ZDni0W6JlC/Ad/mfCSgAAABdIdugAAAAAnwAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA\",\n"
+ + " \"lastModifiedLedgerSeq\": \"159\"\n"
+ + " },\n"
+ + " {\n"
+ + " \"key\": \"AAAAAAAAAADBPp7TMinJylnn+6dQXJACNc15LF+aJ2Py1BaR4P10JA==\",\n"
+ + " \"xdr\": \"AAAAAAAAAADBPp7TMinJylnn+6dQXJACNc15LF+aJ2Py1BaR4P10JAAAABdIcmH6AAAAoQAAAAgAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAAAHAkAAAAAZMPQ0g==\",\n"
+ + " \"lastModifiedLedgerSeq\": \"7177\"\n"
+ + " }\n"
+ + " ],\n"
+ + " \"latestLedger\": \"7943\"\n"
+ + " }\n"
+ + "}";
+
+ String accountId0 = "GCZJ46F2ENQAEEZVVY4RKTGVXWZNETKZBZ4LIW5CMUF7AHP6M7BEV464";
+ LedgerKey.LedgerKeyAccount ledgerKeyAccount0 =
+ new LedgerKey.LedgerKeyAccount.Builder()
+ .accountID(KeyPair.fromAccountId(accountId0).getXdrAccountId())
+ .build();
+ LedgerKey ledgerKey0 =
+ new LedgerKey.Builder()
+ .account(ledgerKeyAccount0)
+ .discriminant(LedgerEntryType.ACCOUNT)
+ .build();
+ String ledgerKey0Xdr = ledgerKey0.toXdrBase64();
+
+ String accountId1 = "GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54";
+ LedgerKey.LedgerKeyAccount ledgerKeyAccount1 =
+ new LedgerKey.LedgerKeyAccount.Builder()
+ .accountID(KeyPair.fromAccountId(accountId1).getXdrAccountId())
+ .build();
+ LedgerKey ledgerKey1 =
+ new LedgerKey.Builder()
+ .account(ledgerKeyAccount1)
+ .discriminant(LedgerEntryType.ACCOUNT)
+ .build();
+ String ledgerKey1Xdr = ledgerKey1.toXdrBase64();
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+
+ // add ledgerKey0Xdr and ledgerKey1Xdr
+ GetLedgerEntriesRequest expectedRequest =
+ new GetLedgerEntriesRequest(Arrays.asList(ledgerKey0Xdr, ledgerKey1Xdr));
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("getLedgerEntries")
+ && sorobanRpcRequest.getParams().equals(expectedRequest)) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ GetLedgerEntriesResponse resp = server.getLedgerEntries(Arrays.asList(ledgerKey0, ledgerKey1));
+ assertEquals(resp.getLatestLedger().longValue(), 7943L);
+ assertEquals(resp.getEntries().size(), 2);
+ assertEquals(
+ resp.getEntries().get(0).getKey(),
+ "AAAAAAAAAACynni6I2ACEzWuORVM1b2y0k1ZDni0W6JlC/Ad/mfCSg==");
+ assertEquals(
+ resp.getEntries().get(0).getXdr(),
+ "AAAAAAAAAACynni6I2ACEzWuORVM1b2y0k1ZDni0W6JlC/Ad/mfCSgAAABdIdugAAAAAnwAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA");
+ assertEquals(
+ resp.getEntries().get(1).getKey(),
+ "AAAAAAAAAADBPp7TMinJylnn+6dQXJACNc15LF+aJ2Py1BaR4P10JA==");
+ assertEquals(
+ resp.getEntries().get(1).getXdr(),
+ "AAAAAAAAAADBPp7TMinJylnn+6dQXJACNc15LF+aJ2Py1BaR4P10JAAAABdIcmH6AAAAoQAAAAgAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAAAHAkAAAAAZMPQ0g==");
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testGetTransaction() throws IOException, SorobanRpcErrorResponse {
+ String hash = "06dd9ee70bf93bbfe219e2b31363ab5a0361cc6285328592e4d3d1fed4c9025c";
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"status\": \"SUCCESS\",\n"
+ + " \"latestLedger\": \"79289\",\n"
+ + " \"latestLedgerCloseTime\": \"1690387240\",\n"
+ + " \"oldestLedger\": \"77850\",\n"
+ + " \"oldestLedgerCloseTime\": \"1690379694\",\n"
+ + " \"applicationOrder\": 1,\n"
+ + " \"envelopeXdr\": \"AAAAAgAAAADTYKIzfa0ubKp7qjOcF+ZO8sjQutzo1iHuDh8esi9q+wABNjQAATW1AAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAYAAAAAAAAAAIAAAASAAAAAb3H+V1yFoNDBpje4rchxeaR7/hRNS2CAT2Dh6A8z6xrAAAADwAAAARuYW1lAAAAAAAAAAEAAAAAAAAAAwAAAAYAAAABvcf5XXIWg0MGmN7ityHF5pHv+FE1LYIBPYOHoDzPrGsAAAAPAAAACE1FVEFEQVRBAAAAAQAAAAAAAAAGAAAAAb3H+V1yFoNDBpje4rchxeaR7/hRNS2CAT2Dh6A8z6xrAAAAFAAAAAEAAAAAAAAAB++FkDTZODW0rvolF6AuIZf4w7+GQd8RofaH8u2pM+UPAAAAAAAAAAAAUrutAAAiqAAAAAAAAADIAAAAAAAAACgAAAABsi9q+wAAAEDgHR/5rU+bsXD/oPUFodyEgXFNbDm5T2+M1GarZXy+d+tZ757PBL9ysK41F1hUYz3p5CA7Urlpe3fnNjYcu1EM\",\n"
+ + " \"resultXdr\": \"AAAAAAABNCwAAAAAAAAAAQAAAAAAAAAYAAAAAJhEDjNV0Jj46jrxCj87qJ6JaYKJN4c+p5tvapkLwrn8AAAAAA==\",\n"
+ + " \"resultMetaXdr\": \"AAAAAwAAAAAAAAACAAAAAwABNbYAAAAAAAAAANNgojN9rS5sqnuqM5wX5k7yyNC63OjWIe4OHx6yL2r7AAAAF0h1s9QAATW1AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAQABNbYAAAAAAAAAANNgojN9rS5sqnuqM5wX5k7yyNC63OjWIe4OHx6yL2r7AAAAF0h1s9QAATW1AAAAAQAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAMAAAAAAAE1tgAAAABkwUMZAAAAAAAAAAEAAAAAAAAAAgAAAAMAATW2AAAAAAAAAADTYKIzfa0ubKp7qjOcF+ZO8sjQutzo1iHuDh8esi9q+wAAABdIdbPUAAE1tQAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAABNbYAAAAAZMFDGQAAAAAAAAABAAE1tgAAAAAAAAAA02CiM32tLmyqe6oznBfmTvLI0Lrc6NYh7g4fHrIvavsAAAAXSHWz/AABNbUAAAABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAATW2AAAAAGTBQxkAAAAAAAAAAQAAAAAAAAAAAAAADgAAAAZUb2tlbkEAAAAAAAIAAAABAAAAAAAAAAAAAAACAAAAAAAAAAMAAAAPAAAAB2ZuX2NhbGwAAAAADQAAACC9x/ldchaDQwaY3uK3IcXmke/4UTUtggE9g4egPM+sawAAAA8AAAAEbmFtZQAAAAEAAAABAAAAAAAAAAG9x/ldchaDQwaY3uK3IcXmke/4UTUtggE9g4egPM+sawAAAAIAAAAAAAAAAgAAAA8AAAAJZm5fcmV0dXJuAAAAAAAADwAAAARuYW1lAAAADgAAAAZUb2tlbkEAAA==\",\n"
+ + " \"ledger\": \"79286\",\n"
+ + " \"createdAt\": \"1690387225\"\n"
+ + " }\n"
+ + "}";
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ GetTransactionRequest expectedRequest = new GetTransactionRequest(hash);
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("getTransaction")
+ && sorobanRpcRequest.getParams().equals(expectedRequest)) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ server.getTransaction(hash);
+
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testGetEvents() throws IOException, SorobanRpcErrorResponse {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"events\": [\n"
+ + " {\n"
+ + " \"type\": \"contract\",\n"
+ + " \"ledger\": \"107\",\n"
+ + " \"ledgerClosedAt\": \"2023-07-28T14:57:02Z\",\n"
+ + " \"contractId\": \"607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0\",\n"
+ + " \"id\": \"0000000459561504768-0000000000\",\n"
+ + " \"pagingToken\": \"0000000459561504768-0000000000\",\n"
+ + " \"topic\": [\n"
+ + " \"AAAADwAAAAdDT1VOVEVSAA==\",\n"
+ + " \"AAAADwAAAAlpbmNyZW1lbnQAAAA=\"\n"
+ + " ],\n"
+ + " \"value\": {\n"
+ + " \"xdr\": \"AAAAAwAAAAQ=\"\n"
+ + " },\n"
+ + " \"inSuccessfulContractCall\": true\n"
+ + " },\n"
+ + " {\n"
+ + " \"type\": \"contract\",\n"
+ + " \"ledger\": \"109\",\n"
+ + " \"ledgerClosedAt\": \"2023-07-28T14:57:04Z\",\n"
+ + " \"contractId\": \"607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0\",\n"
+ + " \"id\": \"0000000468151439360-0000000000\",\n"
+ + " \"pagingToken\": \"0000000468151439360-0000000000\",\n"
+ + " \"topic\": [\n"
+ + " \"AAAADwAAAAdDT1VOVEVSAA==\",\n"
+ + " \"AAAADwAAAAlpbmNyZW1lbnQAAAA=\"\n"
+ + " ],\n"
+ + " \"value\": {\n"
+ + " \"xdr\": \"AAAAAwAAAAU=\"\n"
+ + " },\n"
+ + " \"inSuccessfulContractCall\": true\n"
+ + " }\n"
+ + " ],\n"
+ + " \"latestLedger\": \"187\"\n"
+ + " }\n"
+ + "}";
+
+ GetEventsRequest.EventFilter eventFilter =
+ GetEventsRequest.EventFilter.builder()
+ .contractIds(
+ singletonList("607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0"))
+ .type(EventFilterType.CONTRACT)
+ .topic(Arrays.asList("AAAADwAAAAdDT1VOVEVSAA==", "AAAADwAAAAlpbmNyZW1lbnQAAAA="))
+ .build();
+ GetEventsRequest.PaginationOptions paginationOptions =
+ GetEventsRequest.PaginationOptions.builder()
+ .limit(10L)
+ .cursor("0000007799660613632-0000000000")
+ .build();
+ GetEventsRequest getEventsRequest =
+ GetEventsRequest.builder()
+ .startLedger("100")
+ .filter(eventFilter)
+ .pagination(paginationOptions)
+ .build();
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("getEvents")
+ && sorobanRpcRequest.getParams().equals(getEventsRequest)) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ GetEventsResponse resp = server.getEvents(getEventsRequest);
+ assertEquals(resp.getLatestLedger().longValue(), 187L);
+ assertEquals(resp.getEvents().size(), 2);
+ assertEquals(resp.getEvents().get(0).getType(), EventFilterType.CONTRACT);
+ assertEquals(resp.getEvents().get(0).getLedger().longValue(), 107L);
+ assertEquals(resp.getEvents().get(0).getLedgerClosedAt(), "2023-07-28T14:57:02Z");
+ assertEquals(
+ resp.getEvents().get(0).getContractId(),
+ "607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0");
+ assertEquals(resp.getEvents().get(0).getId(), "0000000459561504768-0000000000");
+ assertEquals(resp.getEvents().get(0).getPagingToken(), "0000000459561504768-0000000000");
+ assertEquals(resp.getEvents().get(0).getTopic().size(), 2);
+ assertEquals(resp.getEvents().get(0).getTopic().get(0), "AAAADwAAAAdDT1VOVEVSAA==");
+ assertEquals(resp.getEvents().get(0).getTopic().get(1), "AAAADwAAAAlpbmNyZW1lbnQAAAA=");
+ assertEquals(resp.getEvents().get(0).getValue().getXdr(), "AAAAAwAAAAQ=");
+ assertEquals(resp.getEvents().get(0).getInSuccessfulContractCall(), true);
+
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testGetNetwork() throws IOException, SorobanRpcErrorResponse {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"friendbotUrl\": \"http://localhost:8000/friendbot\",\n"
+ + " \"passphrase\": \"Standalone Network ; February 2017\",\n"
+ + " \"protocolVersion\": \"20\"\n"
+ + " }\n"
+ + "}";
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("getNetwork")) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ GetNetworkResponse resp = server.getNetwork();
+ assertEquals(resp.getFriendbotUrl(), "http://localhost:8000/friendbot");
+ assertEquals(resp.getPassphrase(), "Standalone Network ; February 2017");
+ assertEquals(resp.getProtocolVersion().longValue(), 20L);
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testGetLatestLedger() throws IOException, SorobanRpcErrorResponse {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"id\": \"e73d7654b72daa637f396669182c6072549736a9e3b6fcb8e685adb61f8c910a\",\n"
+ + " \"protocolVersion\": \"20\",\n"
+ + " \"sequence\": 24170\n"
+ + " }\n"
+ + "}";
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("getLatestLedger")) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ GetLatestLedgerResponse resp = server.getLatestLedger();
+ assertEquals(resp.getId(), "e73d7654b72daa637f396669182c6072549736a9e3b6fcb8e685adb61f8c910a");
+ assertEquals(resp.getProtocolVersion().intValue(), 20);
+ assertEquals(resp.getSequence().intValue(), 24170);
+
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testSimulateTransaction() throws IOException, SorobanRpcErrorResponse {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"7a469b9d6ed4444893491be530862ce3\",\n"
+ + " \"result\": {\n"
+ + " \"transactionData\": \"AAAAAAAAAAIAAAAGAAAAAem354u9STQWq5b3Ed1j9tOemvL7xV0NPwhn4gXg0AP8AAAAFAAAAAEAAAAH8dTe2OoI0BnhlDbH0fWvXmvprkBvBAgKIcL9busuuMEAAAABAAAABgAAAAHpt+eLvUk0FquW9xHdY/bTnpry+8VdDT8IZ+IF4NAD/AAAABAAAAABAAAAAgAAAA8AAAAHQ291bnRlcgAAAAASAAAAAAAAAABYt8SiyPKXqo89JHEoH9/M7K/kjlZjMT7BjhKnPsqYoQAAAAEAHifGAAAFlAAAAIgAAAAAAAAAAg==\",\n"
+ + " \"minResourceFee\": \"58181\",\n"
+ + " \"events\": [\n"
+ + " \"AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAg6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAPAAAACWluY3JlbWVudAAAAAAAABAAAAABAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAo=\",\n"
+ + " \"AAAAAQAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAACAAAAAAAAAAIAAAAPAAAACWZuX3JldHVybgAAAAAAAA8AAAAJaW5jcmVtZW50AAAAAAAAAwAAABQ=\"\n"
+ + " ],\n"
+ + " \"results\": [\n"
+ + " {\n"
+ + " \"auth\": [\n"
+ + " \"AAAAAAAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAJaW5jcmVtZW50AAAAAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAoAAAAA\"\n"
+ + " ],\n"
+ + " \"xdr\": \"AAAAAwAAABQ=\"\n"
+ + " }\n"
+ + " ],\n"
+ + " \"cost\": { \"cpuInsns\": \"1646885\", \"memBytes\": \"1296481\" },\n"
+ + " \"latestLedger\": \"14245\"\n"
+ + " }\n"
+ + "}\n";
+
+ Transaction transaction = buildSorobanTransaction(null, null);
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("simulateTransaction")
+ && sorobanRpcRequest
+ .getParams()
+ .getTransaction()
+ .equals(transaction.toEnvelopeXdrBase64())) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ SimulateTransactionResponse resp = server.simulateTransaction(transaction);
+ assertEquals(resp.getLatestLedger().longValue(), 14245L);
+ assertEquals(
+ resp.getTransactionData(),
+ "AAAAAAAAAAIAAAAGAAAAAem354u9STQWq5b3Ed1j9tOemvL7xV0NPwhn4gXg0AP8AAAAFAAAAAEAAAAH8dTe2OoI0BnhlDbH0fWvXmvprkBvBAgKIcL9busuuMEAAAABAAAABgAAAAHpt+eLvUk0FquW9xHdY/bTnpry+8VdDT8IZ+IF4NAD/AAAABAAAAABAAAAAgAAAA8AAAAHQ291bnRlcgAAAAASAAAAAAAAAABYt8SiyPKXqo89JHEoH9/M7K/kjlZjMT7BjhKnPsqYoQAAAAEAHifGAAAFlAAAAIgAAAAAAAAAAg==");
+ assertEquals(resp.getEvents().size(), 2);
+ assertEquals(
+ resp.getEvents().get(0),
+ "AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAg6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAPAAAACWluY3JlbWVudAAAAAAAABAAAAABAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAo=");
+ assertEquals(
+ resp.getEvents().get(1),
+ "AAAAAQAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAACAAAAAAAAAAIAAAAPAAAACWZuX3JldHVybgAAAAAAAA8AAAAJaW5jcmVtZW50AAAAAAAAAwAAABQ=");
+ assertEquals(resp.getMinResourceFee().longValue(), 58181L);
+ assertEquals(resp.getResults().size(), 1);
+ assertEquals(resp.getResults().get(0).getAuth().size(), 1);
+ assertEquals(
+ resp.getResults().get(0).getAuth().get(0),
+ "AAAAAAAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAJaW5jcmVtZW50AAAAAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAoAAAAA");
+ assertEquals(resp.getResults().get(0).getXdr(), "AAAAAwAAABQ=");
+ assertEquals(resp.getCost().getCpuInstructions().longValue(), 1646885L);
+ assertEquals(resp.getCost().getMemoryBytes().longValue(), 1296481L);
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testPrepareTransaction()
+ throws IOException, SorobanRpcErrorResponse, PrepareTransactionException {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"7a469b9d6ed4444893491be530862ce3\",\n"
+ + " \"result\": {\n"
+ + " \"transactionData\": \"AAAAAAAAAAIAAAAGAAAAAem354u9STQWq5b3Ed1j9tOemvL7xV0NPwhn4gXg0AP8AAAAFAAAAAEAAAAH8dTe2OoI0BnhlDbH0fWvXmvprkBvBAgKIcL9busuuMEAAAABAAAABgAAAAHpt+eLvUk0FquW9xHdY/bTnpry+8VdDT8IZ+IF4NAD/AAAABAAAAABAAAAAgAAAA8AAAAHQ291bnRlcgAAAAASAAAAAAAAAABYt8SiyPKXqo89JHEoH9/M7K/kjlZjMT7BjhKnPsqYoQAAAAEAHifGAAAFlAAAAIgAAAAAAAAAAg==\",\n"
+ + " \"minResourceFee\": \"58181\",\n"
+ + " \"events\": [\n"
+ + " \"AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAg6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAPAAAACWluY3JlbWVudAAAAAAAABAAAAABAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAo=\",\n"
+ + " \"AAAAAQAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAACAAAAAAAAAAIAAAAPAAAACWZuX3JldHVybgAAAAAAAA8AAAAJaW5jcmVtZW50AAAAAAAAAwAAABQ=\"\n"
+ + " ],\n"
+ + " \"results\": [\n"
+ + " {\n"
+ + " \"auth\": [\n"
+ + " \"AAAAAAAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAJaW5jcmVtZW50AAAAAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAoAAAAA\"\n"
+ + " ],\n"
+ + " \"xdr\": \"AAAAAwAAABQ=\"\n"
+ + " }\n"
+ + " ],\n"
+ + " \"cost\": { \"cpuInsns\": \"1646885\", \"memBytes\": \"1296481\" },\n"
+ + " \"latestLedger\": \"14245\"\n"
+ + " }\n"
+ + "}\n";
+
+ Transaction transaction = buildSorobanTransaction(null, null);
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("simulateTransaction")
+ && sorobanRpcRequest
+ .getParams()
+ .getTransaction()
+ .equals(transaction.toEnvelopeXdrBase64())) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ Transaction newTx = server.prepareTransaction(transaction);
+
+ SorobanTransactionData sorobanData =
+ SorobanTransactionData.fromXdrBase64(
+ "AAAAAAAAAAIAAAAGAAAAAem354u9STQWq5b3Ed1j9tOemvL7xV0NPwhn4gXg0AP8AAAAFAAAAAEAAAAH8dTe2OoI0BnhlDbH0fWvXmvprkBvBAgKIcL9busuuMEAAAABAAAABgAAAAHpt+eLvUk0FquW9xHdY/bTnpry+8VdDT8IZ+IF4NAD/AAAABAAAAABAAAAAgAAAA8AAAAHQ291bnRlcgAAAAASAAAAAAAAAABYt8SiyPKXqo89JHEoH9/M7K/kjlZjMT7BjhKnPsqYoQAAAAEAHifGAAAFlAAAAIgAAAAAAAAAAg==");
+ InvokeHostFunctionOperation operation =
+ InvokeHostFunctionOperation.builder()
+ .hostFunction(
+ ((InvokeHostFunctionOperation) transaction.getOperations()[0]).getHostFunction())
+ .sourceAccount(transaction.getOperations()[0].getSourceAccount())
+ .auth(
+ singletonList(
+ SorobanAuthorizationEntry.fromXdrBase64(
+ "AAAAAAAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAJaW5jcmVtZW50AAAAAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAoAAAAA")))
+ .build();
+ Transaction expectedTx =
+ new Transaction(
+ transaction.getAccountConverter(),
+ transaction.getSourceAccount(),
+ transaction.getFee() + 58181L,
+ transaction.getSequenceNumber(),
+ new Operation[] {operation},
+ transaction.getMemo(),
+ transaction.getPreconditions(),
+ sorobanData,
+ transaction.getNetwork());
+ assertEquals(expectedTx, newTx);
+
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testPrepareTransactionWithSorobanData()
+ throws IOException, SorobanRpcErrorResponse, PrepareTransactionException {
+ // soroban data will be overwritten
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"7a469b9d6ed4444893491be530862ce3\",\n"
+ + " \"result\": {\n"
+ + " \"transactionData\": \"AAAAAAAAAAIAAAAGAAAAAem354u9STQWq5b3Ed1j9tOemvL7xV0NPwhn4gXg0AP8AAAAFAAAAAEAAAAH8dTe2OoI0BnhlDbH0fWvXmvprkBvBAgKIcL9busuuMEAAAABAAAABgAAAAHpt+eLvUk0FquW9xHdY/bTnpry+8VdDT8IZ+IF4NAD/AAAABAAAAABAAAAAgAAAA8AAAAHQ291bnRlcgAAAAASAAAAAAAAAABYt8SiyPKXqo89JHEoH9/M7K/kjlZjMT7BjhKnPsqYoQAAAAEAHifGAAAFlAAAAIgAAAAAAAAAAg==\",\n"
+ + " \"minResourceFee\": \"58181\",\n"
+ + " \"events\": [\n"
+ + " \"AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAg6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAPAAAACWluY3JlbWVudAAAAAAAABAAAAABAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAo=\",\n"
+ + " \"AAAAAQAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAACAAAAAAAAAAIAAAAPAAAACWZuX3JldHVybgAAAAAAAA8AAAAJaW5jcmVtZW50AAAAAAAAAwAAABQ=\"\n"
+ + " ],\n"
+ + " \"results\": [\n"
+ + " {\n"
+ + " \"auth\": [\n"
+ + " \"AAAAAAAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAJaW5jcmVtZW50AAAAAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAoAAAAA\"\n"
+ + " ],\n"
+ + " \"xdr\": \"AAAAAwAAABQ=\"\n"
+ + " }\n"
+ + " ],\n"
+ + " \"cost\": { \"cpuInsns\": \"1646885\", \"memBytes\": \"1296481\" },\n"
+ + " \"latestLedger\": \"14245\"\n"
+ + " }\n"
+ + "}\n";
+ LedgerKey ledgerKey =
+ new LedgerKey.Builder()
+ .discriminant(LedgerEntryType.ACCOUNT)
+ .account(
+ new LedgerKey.LedgerKeyAccount.Builder()
+ .accountID(
+ KeyPair.fromAccountId(
+ "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO")
+ .getXdrAccountId())
+ .build())
+ .build();
+ SorobanTransactionData originSorobanData =
+ new SorobanTransactionData.Builder()
+ .resources(
+ new SorobanResources.Builder()
+ .footprint(
+ new LedgerFootprint.Builder()
+ .readOnly(new LedgerKey[] {ledgerKey})
+ .readWrite(new LedgerKey[] {})
+ .build())
+ .readBytes(new Uint32(new XdrUnsignedInteger(699)))
+ .writeBytes(new Uint32(new XdrUnsignedInteger(0)))
+ .instructions(new Uint32(new XdrUnsignedInteger(34567)))
+ .build())
+ .refundableFee(new Int64(100L))
+ .ext(new ExtensionPoint.Builder().discriminant(0).build())
+ .build();
+ Transaction transaction = buildSorobanTransaction(originSorobanData, null);
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("simulateTransaction")
+ && sorobanRpcRequest
+ .getParams()
+ .getTransaction()
+ .equals(transaction.toEnvelopeXdrBase64())) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ Transaction newTx = server.prepareTransaction(transaction);
+
+ SorobanTransactionData sorobanData =
+ SorobanTransactionData.fromXdrBase64(
+ "AAAAAAAAAAIAAAAGAAAAAem354u9STQWq5b3Ed1j9tOemvL7xV0NPwhn4gXg0AP8AAAAFAAAAAEAAAAH8dTe2OoI0BnhlDbH0fWvXmvprkBvBAgKIcL9busuuMEAAAABAAAABgAAAAHpt+eLvUk0FquW9xHdY/bTnpry+8VdDT8IZ+IF4NAD/AAAABAAAAABAAAAAgAAAA8AAAAHQ291bnRlcgAAAAASAAAAAAAAAABYt8SiyPKXqo89JHEoH9/M7K/kjlZjMT7BjhKnPsqYoQAAAAEAHifGAAAFlAAAAIgAAAAAAAAAAg==");
+ InvokeHostFunctionOperation operation =
+ InvokeHostFunctionOperation.builder()
+ .hostFunction(
+ ((InvokeHostFunctionOperation) transaction.getOperations()[0]).getHostFunction())
+ .sourceAccount(transaction.getOperations()[0].getSourceAccount())
+ .auth(
+ singletonList(
+ SorobanAuthorizationEntry.fromXdrBase64(
+ "AAAAAAAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAJaW5jcmVtZW50AAAAAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAoAAAAA")))
+ .build();
+ Transaction expectedTx =
+ new Transaction(
+ transaction.getAccountConverter(),
+ transaction.getSourceAccount(),
+ transaction.getFee() + 58181L,
+ transaction.getSequenceNumber(),
+ new Operation[] {operation},
+ transaction.getMemo(),
+ transaction.getPreconditions(),
+ sorobanData,
+ transaction.getNetwork());
+ assertEquals(expectedTx, newTx);
+
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testPrepareTransactionWithAuth()
+ throws IOException, SorobanRpcErrorResponse, PrepareTransactionException {
+ // origin auth will not be overwritten
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"7a469b9d6ed4444893491be530862ce3\",\n"
+ + " \"result\": {\n"
+ + " \"transactionData\": \"AAAAAAAAAAIAAAAGAAAAAem354u9STQWq5b3Ed1j9tOemvL7xV0NPwhn4gXg0AP8AAAAFAAAAAEAAAAH8dTe2OoI0BnhlDbH0fWvXmvprkBvBAgKIcL9busuuMEAAAABAAAABgAAAAHpt+eLvUk0FquW9xHdY/bTnpry+8VdDT8IZ+IF4NAD/AAAABAAAAABAAAAAgAAAA8AAAAHQ291bnRlcgAAAAASAAAAAAAAAABYt8SiyPKXqo89JHEoH9/M7K/kjlZjMT7BjhKnPsqYoQAAAAEAHifGAAAFlAAAAIgAAAAAAAAAAg==\",\n"
+ + " \"minResourceFee\": \"58181\",\n"
+ + " \"events\": [\n"
+ + " \"AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAg6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAPAAAACWluY3JlbWVudAAAAAAAABAAAAABAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAo=\",\n"
+ + " \"AAAAAQAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAACAAAAAAAAAAIAAAAPAAAACWZuX3JldHVybgAAAAAAAA8AAAAJaW5jcmVtZW50AAAAAAAAAwAAABQ=\"\n"
+ + " ],\n"
+ + " \"results\": [\n"
+ + " {\n"
+ + " \"auth\": [\n"
+ + " \"AAAAAAAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAJaW5jcmVtZW50AAAAAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAoAAAAA\"\n"
+ + " ],\n"
+ + " \"xdr\": \"AAAAAwAAABQ=\"\n"
+ + " }\n"
+ + " ],\n"
+ + " \"cost\": { \"cpuInsns\": \"1646885\", \"memBytes\": \"1296481\" },\n"
+ + " \"latestLedger\": \"14245\"\n"
+ + " }\n"
+ + "}\n";
+ CreateContractArgs createContractArgs =
+ new CreateContractArgs.Builder()
+ .contractIDPreimage(
+ new ContractIDPreimage.Builder()
+ .discriminant(ContractIDPreimageType.CONTRACT_ID_PREIMAGE_FROM_ADDRESS)
+ .fromAddress(
+ new ContractIDPreimage.ContractIDPreimageFromAddress.Builder()
+ .address(
+ new Address(
+ "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO")
+ .toSCAddress())
+ .salt(new Uint256(new byte[32]))
+ .build())
+ .build())
+ .executable(
+ new ContractExecutable.Builder()
+ .discriminant(ContractExecutableType.CONTRACT_EXECUTABLE_TOKEN)
+ .build())
+ .build();
+ SorobanAuthorizationEntry auth =
+ new SorobanAuthorizationEntry.Builder()
+ .credentials(
+ new SorobanCredentials.Builder()
+ .discriminant(SorobanCredentialsType.SOROBAN_CREDENTIALS_SOURCE_ACCOUNT)
+ .build())
+ .rootInvocation(
+ new SorobanAuthorizedInvocation.Builder()
+ .subInvocations(new SorobanAuthorizedInvocation[] {})
+ .function(
+ new SorobanAuthorizedFunction.Builder()
+ .discriminant(
+ SorobanAuthorizedFunctionType
+ .SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN)
+ .createContractHostFn(createContractArgs)
+ .build())
+ .build())
+ .build();
+
+ Transaction transaction = buildSorobanTransaction(null, singletonList(auth));
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("simulateTransaction")
+ && sorobanRpcRequest
+ .getParams()
+ .getTransaction()
+ .equals(transaction.toEnvelopeXdrBase64())) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ Transaction newTx = server.prepareTransaction(transaction);
+
+ SorobanTransactionData sorobanData =
+ SorobanTransactionData.fromXdrBase64(
+ "AAAAAAAAAAIAAAAGAAAAAem354u9STQWq5b3Ed1j9tOemvL7xV0NPwhn4gXg0AP8AAAAFAAAAAEAAAAH8dTe2OoI0BnhlDbH0fWvXmvprkBvBAgKIcL9busuuMEAAAABAAAABgAAAAHpt+eLvUk0FquW9xHdY/bTnpry+8VdDT8IZ+IF4NAD/AAAABAAAAABAAAAAgAAAA8AAAAHQ291bnRlcgAAAAASAAAAAAAAAABYt8SiyPKXqo89JHEoH9/M7K/kjlZjMT7BjhKnPsqYoQAAAAEAHifGAAAFlAAAAIgAAAAAAAAAAg==");
+ InvokeHostFunctionOperation operation =
+ InvokeHostFunctionOperation.builder()
+ .hostFunction(
+ ((InvokeHostFunctionOperation) transaction.getOperations()[0]).getHostFunction())
+ .sourceAccount(transaction.getOperations()[0].getSourceAccount())
+ .auth(singletonList(auth))
+ .build();
+ Transaction expectedTx =
+ new Transaction(
+ transaction.getAccountConverter(),
+ transaction.getSourceAccount(),
+ transaction.getFee() + 58181L,
+ transaction.getSequenceNumber(),
+ new Operation[] {operation},
+ transaction.getMemo(),
+ transaction.getPreconditions(),
+ sorobanData,
+ transaction.getNetwork());
+ assertEquals(expectedTx, newTx);
+
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test(expected = PrepareTransactionException.class)
+ public void testPrepareTransactionWithPrepareTransactionExceptionThrowsErrorResponse()
+ throws IOException, SorobanRpcErrorResponse, PrepareTransactionException {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"7b6ada2bdec04ee28147d1557aadc3cf\",\n"
+ + " \"result\": {\n"
+ + " \"error\": \"HostError: Error(WasmVm, MissingValue)\\n\\nEvent log (newest first):\\n 0: [Diagnostic Event] contract:607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0, topics:[error, Error(WasmVm, MissingValue)], data:[\\\"invoking unknown export\\\", increment]\\n 1: [Diagnostic Event] topics:[fn_call, Bytes(607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0), increment], data:[Address(Account(58b7c4a2c8f297aa8f3d2471281fdfccecafe48e5663313ec18e12a73eca98a1)), 10]\\n\\nBacktrace (newest first):\\n 0: soroban_env_host::vm::Vm::invoke_function_raw\\n 1: soroban_env_host::host::frame::::call_n_internal\\n 2: soroban_env_host::host::frame::::invoke_function\\n 3: preflight::preflight_invoke_hf_op::{{closure}}\\n 4: preflight::catch_preflight_panic\\n 5: _cgo_a3255893d7fd_Cfunc_preflight_invoke_hf_op\\n at /tmp/go-build/cgo-gcc-prolog:99:11\\n 6: runtime.asmcgocall\\n at ./runtime/asm_amd64.s:848\\n\\n\",\n"
+ + " \"transactionData\": null,\n"
+ + " \"events\": null,\n"
+ + " \"minResourceFee\": \"0\",\n"
+ + " \"cost\": {\n"
+ + " \"cpuInsns\": \"0\",\n"
+ + " \"memBytes\": \"0\"\n"
+ + " },\n"
+ + " \"latestLedger\": \"898\"\n"
+ + " }\n"
+ + "}";
+
+ Transaction transaction = buildSorobanTransaction(null, null);
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("simulateTransaction")
+ && sorobanRpcRequest
+ .getParams()
+ .getTransaction()
+ .equals(transaction.toEnvelopeXdrBase64())) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ server.prepareTransaction(transaction);
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testPrepareTransactionWithIllegalArgumentExceptionThrowsErrorResultsIsEmpty()
+ throws IOException, SorobanRpcErrorResponse, PrepareTransactionException {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"7a469b9d6ed4444893491be530862ce3\",\n"
+ + " \"result\": {\n"
+ + " \"transactionData\": \"AAAAAAAAAAIAAAAGAAAAAem354u9STQWq5b3Ed1j9tOemvL7xV0NPwhn4gXg0AP8AAAAFAAAAAEAAAAH8dTe2OoI0BnhlDbH0fWvXmvprkBvBAgKIcL9busuuMEAAAABAAAABgAAAAHpt+eLvUk0FquW9xHdY/bTnpry+8VdDT8IZ+IF4NAD/AAAABAAAAABAAAAAgAAAA8AAAAHQ291bnRlcgAAAAASAAAAAAAAAABYt8SiyPKXqo89JHEoH9/M7K/kjlZjMT7BjhKnPsqYoQAAAAEAHifGAAAFlAAAAIgAAAAAAAAAAg==\",\n"
+ + " \"minResourceFee\": \"58181\",\n"
+ + " \"events\": [\n"
+ + " \"AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAg6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAAPAAAACWluY3JlbWVudAAAAAAAABAAAAABAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAo=\",\n"
+ + " \"AAAAAQAAAAAAAAAB6bfni71JNBarlvcR3WP2056a8vvFXQ0/CGfiBeDQA/wAAAACAAAAAAAAAAIAAAAPAAAACWZuX3JldHVybgAAAAAAAA8AAAAJaW5jcmVtZW50AAAAAAAAAwAAABQ=\"\n"
+ + " ],\n"
+ + " \"results\": [],\n"
+ + " \"cost\": { \"cpuInsns\": \"1646885\", \"memBytes\": \"1296481\" },\n"
+ + " \"latestLedger\": \"14245\"\n"
+ + " }\n"
+ + "}";
+
+ Transaction transaction = buildSorobanTransaction(null, null);
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("simulateTransaction")
+ && sorobanRpcRequest
+ .getParams()
+ .getTransaction()
+ .equals(transaction.toEnvelopeXdrBase64())) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ server.prepareTransaction(transaction);
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testSendTransaction()
+ throws IOException, SorobanRpcErrorResponse, PrepareTransactionException {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"688dfcf3bcd04f52af4866e98dffe387\",\n"
+ + " \"result\": {\n"
+ + " \"status\": \"PENDING\",\n"
+ + " \"hash\": \"64977cc4bb7f8bf75bdc47570548a994667899d3319b72f95cb2a64e567ad52c\",\n"
+ + " \"latestLedger\": \"1479\",\n"
+ + " \"latestLedgerCloseTime\": \"1690594566\"\n"
+ + " }\n"
+ + "}";
+
+ Transaction transaction = buildSorobanTransaction(null, null);
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("sendTransaction")
+ && sorobanRpcRequest
+ .getParams()
+ .getTransaction()
+ .equals(transaction.toEnvelopeXdrBase64())) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ SendTransactionResponse response = server.sendTransaction(transaction);
+ assertEquals(response.getStatus(), SendTransactionResponse.SendTransactionStatus.PENDING);
+ assertEquals(response.getHash(), transaction.hashHex());
+ assertEquals(response.getLatestLedger().longValue(), 1479L);
+ assertEquals(response.getLatestLedgerCloseTime().longValue(), 1690594566L);
+
+ server.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ public void testSorobanRpcErrorResponseThrows() throws IOException {
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"error\": {\n"
+ + " \"code\": -32601,\n"
+ + " \"message\": \"method not found\",\n"
+ + " \"data\": \"mockTest\"\n"
+ + " }\n"
+ + "}";
+
+ MockWebServer mockWebServer = new MockWebServer();
+ Dispatcher dispatcher =
+ new Dispatcher() {
+ @NotNull
+ @Override
+ public MockResponse dispatch(@NotNull RecordedRequest recordedRequest)
+ throws InterruptedException {
+ SorobanRpcRequest sorobanRpcRequest =
+ gson.fromJson(
+ recordedRequest.getBody().readUtf8(),
+ new TypeToken>() {}.getType());
+ if ("POST".equals(recordedRequest.getMethod())
+ && sorobanRpcRequest.getMethod().equals("getNetwork")) {
+ return new MockResponse().setResponseCode(200).setBody(json);
+ }
+ return new MockResponse().setResponseCode(404);
+ }
+ };
+ mockWebServer.setDispatcher(dispatcher);
+ mockWebServer.start();
+
+ HttpUrl baseUrl = mockWebServer.url("");
+ SorobanServer server = new SorobanServer(baseUrl.toString());
+ try {
+ server.getNetwork();
+ fail();
+ } catch (SorobanRpcErrorResponse e) {
+ assertEquals(e.getCode().longValue(), -32601L);
+ assertEquals(e.getMessage(), "method not found");
+ assertEquals(e.getData(), "mockTest");
+ }
+
+ server.close();
+ mockWebServer.close();
+ }
+
+ private Transaction buildSorobanTransaction(
+ SorobanTransactionData sorobanData, List auth) {
+ String contractId = "CDU3PZ4LXVETIFVLS33RDXLD63JZ5GXS7PCV2DJ7BBT6EBPA2AB7YR5H";
+ KeyPair txSubmitterKp =
+ KeyPair.fromSecretSeed("SAAPYAPTTRZMCUZFPG3G66V4ZMHTK4TWA6NS7U4F7Z3IMUD52EK4DDEV");
+ KeyPair opInvokerKp =
+ KeyPair.fromSecretSeed("SAEZSI6DY7AXJFIYA4PM6SIBNEYYXIEM2MSOTHFGKHDW32MBQ7KVO6EN");
+
+ TransactionBuilderAccount source = new Account(txSubmitterKp.getAccountId(), 3053721747476L);
+
+ if (auth == null) {
+ auth = new ArrayList<>();
+ }
+
+ InvokeContractArgs invokeContractArgs =
+ new InvokeContractArgs.Builder()
+ .contractAddress(new Address(contractId).toSCAddress())
+ .functionName(new SCSymbol(new XdrString("increment")))
+ .args(
+ new SCVal[] {
+ new Address(opInvokerKp.getAccountId()).toSCVal(),
+ new SCVal.Builder()
+ .discriminant(SCValType.SCV_U32)
+ .u32(new Uint32(new XdrUnsignedInteger(10)))
+ .build()
+ })
+ .build();
+
+ TransactionBuilder transactionBuilder =
+ new TransactionBuilder(AccountConverter.enableMuxed(), source, Network.STANDALONE)
+ .setBaseFee(50000)
+ .addPreconditions(
+ TransactionPreconditions.builder().timeBounds(new TimeBounds(0, 0)).build())
+ .addOperation(
+ InvokeHostFunctionOperation.builder()
+ .sourceAccount(opInvokerKp.getAccountId())
+ .hostFunction(
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_INVOKE_CONTRACT)
+ .invokeContract(invokeContractArgs)
+ .build())
+ .auth(auth)
+ .build());
+
+ if (sorobanData != null) {
+ transactionBuilder.setSorobanData(sorobanData);
+ }
+
+ return transactionBuilder.build();
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/StrKeyTest.java b/src/test/java/org/stellar/sdk/StrKeyTest.java
index 0526241ce..7a8cff31c 100644
--- a/src/test/java/org/stellar/sdk/StrKeyTest.java
+++ b/src/test/java/org/stellar/sdk/StrKeyTest.java
@@ -4,7 +4,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import com.google.common.io.BaseEncoding;
import java.io.IOException;
import org.junit.Test;
import org.stellar.sdk.xdr.AccountID;
@@ -14,6 +13,7 @@
public class StrKeyTest {
@Test
public void testDecodeEncode() throws IOException, FormatException {
+
String seed = "SDJHRQF4GCMIIKAAAQ6IHY42X73FQFLHUULAPSKKD4DFDM7UXWWCRHBE";
byte[] secret = StrKey.decodeCheck(StrKey.VersionByte.SEED, seed.toCharArray());
char[] encoded = StrKey.encodeCheck(StrKey.VersionByte.SEED, secret);
@@ -141,9 +141,8 @@ public void testRoundTripHashXFromBytes() {
public void testValidSignedPayloadEncode() {
// Valid signed payload with an ed25519 public key and a 32-byte payload.
byte[] payload =
- BaseEncoding.base16()
- .decode(
- "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20".toUpperCase());
+ Util.hexToBytes(
+ "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20".toUpperCase());
SignedPayloadSigner signedPayloadSigner =
new SignedPayloadSigner(
StrKey.decodeStellarAccountId(
@@ -156,8 +155,7 @@ public void testValidSignedPayloadEncode() {
// Valid signed payload with an ed25519 public key and a 29-byte payload.
payload =
- BaseEncoding.base16()
- .decode("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d".toUpperCase());
+ Util.hexToBytes("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d".toUpperCase());
signedPayloadSigner =
new SignedPayloadSigner(
StrKey.decodeStellarAccountId(
@@ -308,7 +306,9 @@ public void testEncodeToXDRMuxedAccountMAddress() {
MuxedAccount muxedAccount = StrKey.encodeToXDRMuxedAccount(muxedAddress);
assertEquals(CryptoKeyType.KEY_TYPE_MUXED_ED25519, muxedAccount.getDiscriminant());
assertEquals(account.getAccountID().getEd25519(), muxedAccount.getMed25519().getEd25519());
- assertEquals(new Long(-9223372036854775808L), muxedAccount.getMed25519().getId().getUint64());
+ assertEquals(
+ -9223372036854775808L,
+ muxedAccount.getMed25519().getId().getUint64().getNumber().longValue());
assertEquals(muxedAddress, StrKey.encodeStellarMuxedAccount(muxedAccount));
diff --git a/src/test/java/org/stellar/sdk/StreamingSmokeTest.java b/src/test/java/org/stellar/sdk/StreamingSmokeTest.java
index 7f988aa17..068f2b7f6 100644
--- a/src/test/java/org/stellar/sdk/StreamingSmokeTest.java
+++ b/src/test/java/org/stellar/sdk/StreamingSmokeTest.java
@@ -1,6 +1,6 @@
package org.stellar.sdk;
-import com.google.common.base.Optional;
+import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Assert;
import org.junit.Ignore;
diff --git a/src/test/java/org/stellar/sdk/TimeBoundsTest.java b/src/test/java/org/stellar/sdk/TimeBoundsTest.java
index eaded0cb7..4bbdd40c8 100644
--- a/src/test/java/org/stellar/sdk/TimeBoundsTest.java
+++ b/src/test/java/org/stellar/sdk/TimeBoundsTest.java
@@ -11,7 +11,7 @@ public void testSetTimeBoundsNegativeMinTime() {
new TimeBounds(-1, 300);
fail();
} catch (IllegalArgumentException e) {
- assertEquals("minTime cannot be negative", e.getMessage());
+ assertEquals("minTime must be between 0 and 2^64-1", e.getMessage());
}
}
@@ -21,7 +21,7 @@ public void testSetTimeBoundsNegativeMaxTime() {
new TimeBounds(1, -300);
fail();
} catch (IllegalArgumentException e) {
- assertEquals("maxTime cannot be negative", e.getMessage());
+ assertEquals("maxTime must be between 0 and 2^64-1", e.getMessage());
}
}
@@ -31,36 +31,36 @@ public void testSetTimeBoundsMinTimeGreatThanMaxTime() {
new TimeBounds(300, 1);
fail();
} catch (IllegalArgumentException e) {
- assertEquals("minTime must be >= maxTime", e.getMessage());
+ assertEquals("minTime must be <= maxTime", e.getMessage());
}
}
@Test
public void TestSetTimeoutInfinite() {
TimeBounds timebounds = new TimeBounds(300, 0);
- assertEquals(300, timebounds.getMinTime());
- assertEquals(0, timebounds.getMaxTime());
+ assertEquals(300, timebounds.getMinTime().longValue());
+ assertEquals(0, timebounds.getMaxTime().longValue());
}
@Test
public void TestSetTimeoutInfiniteBothZero() {
TimeBounds timebounds = new TimeBounds(0, 0);
- assertEquals(0, timebounds.getMinTime());
- assertEquals(0, timebounds.getMaxTime());
+ assertEquals(0, timebounds.getMinTime().longValue());
+ assertEquals(0, timebounds.getMaxTime().longValue());
}
@Test
public void TestSetTimeout() {
TimeBounds timebounds = new TimeBounds(1, 300);
- assertEquals(1, timebounds.getMinTime());
- assertEquals(300, timebounds.getMaxTime());
+ assertEquals(1, timebounds.getMinTime().longValue());
+ assertEquals(300, timebounds.getMaxTime().longValue());
}
@Test
public void TestSetTimeoutMinEqualMax() {
TimeBounds timebounds = new TimeBounds(300, 300);
- assertEquals(300, timebounds.getMinTime());
- assertEquals(300, timebounds.getMaxTime());
+ assertEquals(300, timebounds.getMinTime().longValue());
+ assertEquals(300, timebounds.getMaxTime().longValue());
}
@Test
@@ -68,8 +68,9 @@ public void TestTimeoutWithTimeout() {
long timeout = 300;
TimeBounds timebounds = TimeBounds.expiresAfter(timeout);
long now = System.currentTimeMillis() / 1000L;
- assertEquals(0, timebounds.getMinTime());
+ assertEquals(0, timebounds.getMinTime().longValue());
assertTrue(
- timebounds.getMaxTime() - timeout <= now && timebounds.getMaxTime() - timeout >= now - 1);
+ timebounds.getMaxTime().longValue() - timeout <= now
+ && timebounds.getMaxTime().longValue() - timeout >= now - 1);
}
}
diff --git a/src/test/java/org/stellar/sdk/TransactionBuilderTest.java b/src/test/java/org/stellar/sdk/TransactionBuilderTest.java
index dee0d8df4..081a16a30 100644
--- a/src/test/java/org/stellar/sdk/TransactionBuilderTest.java
+++ b/src/test/java/org/stellar/sdk/TransactionBuilderTest.java
@@ -1,22 +1,13 @@
package org.stellar.sdk;
-import static com.google.common.collect.Lists.newArrayList;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.google.common.io.BaseEncoding;
-import java.io.ByteArrayInputStream;
+import static org.junit.Assert.*;
+
import java.io.IOException;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
import org.junit.Test;
-import org.stellar.sdk.xdr.Int64;
-import org.stellar.sdk.xdr.PreconditionsV2;
-import org.stellar.sdk.xdr.SequenceNumber;
-import org.stellar.sdk.xdr.SignerKey;
-import org.stellar.sdk.xdr.SignerKeyType;
-import org.stellar.sdk.xdr.Uint256;
-import org.stellar.sdk.xdr.XdrDataInputStream;
+import org.stellar.sdk.xdr.*;
public class TransactionBuilderTest {
@@ -67,14 +58,13 @@ public void testBuilderSuccessTestnet() throws Exception {
"AAAAAgAAAABexSIg06FtXzmFBQQtHZsrnyWxUzmthkBEhs/ktoeVYgAAAGQAClWjAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAADt4FJhvNwvlQqjuhc7bjLVyRf5e4K2QOzI0c6nWfVvEAAAAASoF8gAAAAAAAAAAAG2h5ViAAAAQLJxvwao6eyNHaDX2QFhgdqlxJUqkpgA03UUOqf4DwOXSV9GN4ZWut2uzRuza4DWyVGBEHmmnQX+SQKFo0Sb/wA=",
transaction.toEnvelopeXdrBase64());
+ org.stellar.sdk.xdr.Transaction.TransactionExt expectedExt =
+ new org.stellar.sdk.xdr.Transaction.TransactionExt.Builder().discriminant(0).build();
+ assertEquals(expectedExt, transaction.toEnvelopeXdr().getV1().getTx().getExt());
+
// Convert transaction to binary XDR and back again to make sure correctly xdr de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- javax.xml.bind.DatatypeConverter.parseBase64Binary(
- transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
Transaction transaction2 =
(Transaction)
Transaction.fromEnvelopeXdr(
@@ -103,13 +93,8 @@ public void testBuilderMemoText() throws Exception {
transaction.sign(source);
// Convert transaction to binary XDR and back again to make sure correctly xdr de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- javax.xml.bind.DatatypeConverter.parseBase64Binary(
- transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
Transaction transaction2 =
(Transaction)
Transaction.fromEnvelopeXdr(
@@ -143,13 +128,8 @@ public void testBuilderTimeBounds() throws FormatException, IOException {
// Convert transaction to binary XDR and back again to make sure timebounds are correctly
// de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- javax.xml.bind.DatatypeConverter.parseBase64Binary(
- transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
assertEquals(
decodedTransaction
@@ -160,6 +140,7 @@ public void testBuilderTimeBounds() throws FormatException, IOException {
.getMinTime()
.getTimePoint()
.getUint64()
+ .getNumber()
.longValue(),
42);
assertEquals(
@@ -171,6 +152,7 @@ public void testBuilderTimeBounds() throws FormatException, IOException {
.getMaxTime()
.getTimePoint()
.getUint64()
+ .getNumber()
.longValue(),
1337);
@@ -201,13 +183,8 @@ public void testBuilderBaseFee() throws Exception {
transaction.sign(source);
// Convert transaction to binary XDR and back again to make sure correctly xdr de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- javax.xml.bind.DatatypeConverter.parseBase64Binary(
- transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
Transaction transaction2 =
(Transaction)
Transaction.fromEnvelopeXdr(
@@ -248,17 +225,12 @@ public void testBuilderTimebounds() throws IOException {
.setBaseFee(Transaction.MIN_BASE_FEE)
.build();
- assertEquals(42, transaction.getTimeBounds().getMinTime());
- assertEquals(1337, transaction.getTimeBounds().getMaxTime());
+ assertEquals(42, transaction.getTimeBounds().getMinTime().intValue());
+ assertEquals(1337, transaction.getTimeBounds().getMaxTime().intValue());
// Convert transaction to binary XDR and back again to make sure correctly xdr de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- javax.xml.bind.DatatypeConverter.parseBase64Binary(
- transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
Transaction transaction2 =
(Transaction)
Transaction.fromEnvelopeXdr(
@@ -310,18 +282,13 @@ public void testBuilderTimeout() throws IOException {
.setBaseFee(Transaction.MIN_BASE_FEE)
.build();
- assertEquals(0, transaction.getTimeBounds().getMinTime());
- assertTrue(currentUnix + 10 <= transaction.getTimeBounds().getMaxTime());
+ assertEquals(0, transaction.getTimeBounds().getMinTime().longValue());
+ assertTrue(currentUnix + 10 <= transaction.getTimeBounds().getMaxTime().longValue());
// Convert transaction to binary XDR and back again to make sure timebounds are correctly
// de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- javax.xml.bind.DatatypeConverter.parseBase64Binary(
- transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
Transaction transaction2 =
(Transaction)
Transaction.fromEnvelopeXdr(
@@ -343,7 +310,8 @@ public void testBuilderSetsLedgerBounds() throws IOException {
new CreateAccountOperation.Builder(newAccount.getAccountId(), "2000").build())
.addPreconditions(
TransactionPreconditions.builder()
- .timeBounds(new TimeBounds(0L, TransactionPreconditions.TIMEOUT_INFINITE))
+ .timeBounds(
+ new TimeBounds(BigInteger.ZERO, TransactionPreconditions.TIMEOUT_INFINITE))
.ledgerBounds(LedgerBounds.builder().minLedger(1).maxLedger(2).build())
.build())
.setBaseFee(Transaction.MIN_BASE_FEE)
@@ -352,13 +320,8 @@ public void testBuilderSetsLedgerBounds() throws IOException {
assertEquals(1, transaction.getPreconditions().getLedgerBounds().getMinLedger());
assertEquals(2, transaction.getPreconditions().getLedgerBounds().getMaxLedger());
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- javax.xml.bind.DatatypeConverter.parseBase64Binary(
- transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
Transaction transaction2 =
(Transaction)
Transaction.fromEnvelopeXdr(
@@ -382,7 +345,7 @@ public void testBuilderSetsMinSeqNum() throws IOException {
SequenceNumber seqNum = new SequenceNumber();
seqNum.setSequenceNumber(new Int64(5L));
preconditionsV2.timeBounds(
- TransactionBuilder.buildTimeBounds(0, TransactionPreconditions.TIMEOUT_INFINITE));
+ buildTimeBounds(BigInteger.ZERO, TransactionPreconditions.TIMEOUT_INFINITE));
preconditionsV2.minSeqNum(seqNum);
Transaction transaction =
@@ -391,7 +354,8 @@ public void testBuilderSetsMinSeqNum() throws IOException {
new CreateAccountOperation.Builder(newAccount.getAccountId(), "2000").build())
.addPreconditions(
TransactionPreconditions.builder()
- .timeBounds(new TimeBounds(0L, TransactionPreconditions.TIMEOUT_INFINITE))
+ .timeBounds(
+ new TimeBounds(BigInteger.ZERO, TransactionPreconditions.TIMEOUT_INFINITE))
.minSeqNumber(5L)
.build())
.setBaseFee(Transaction.MIN_BASE_FEE)
@@ -400,13 +364,8 @@ public void testBuilderSetsMinSeqNum() throws IOException {
assertEquals(Long.valueOf(5), transaction.getPreconditions().getMinSeqNumber());
// Convert transaction to binary XDR and back again to make sure correctly xdr de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- javax.xml.bind.DatatypeConverter.parseBase64Binary(
- transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
Transaction transaction2 =
(Transaction)
Transaction.fromEnvelopeXdr(
@@ -432,22 +391,18 @@ public void testBuilderSetsMinSeqAge() throws IOException {
new CreateAccountOperation.Builder(newAccount.getAccountId(), "2000").build())
.addPreconditions(
TransactionPreconditions.builder()
- .timeBounds(new TimeBounds(0L, TransactionPreconditions.TIMEOUT_INFINITE))
- .minSeqAge(5L)
+ .timeBounds(
+ new TimeBounds(BigInteger.ZERO, TransactionPreconditions.TIMEOUT_INFINITE))
+ .minSeqAge(BigInteger.valueOf(5L))
.build())
.setBaseFee(Transaction.MIN_BASE_FEE)
.build();
- assertEquals(5, transaction.getPreconditions().getMinSeqAge());
+ assertEquals(5, transaction.getPreconditions().getMinSeqAge().intValue());
// Convert transaction to binary XDR and back again to make sure correctly xdr de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- javax.xml.bind.DatatypeConverter.parseBase64Binary(
- transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
Transaction transaction2 =
(Transaction)
Transaction.fromEnvelopeXdr(
@@ -473,7 +428,8 @@ public void testBuilderSetsMinSeqLedgerGap() throws IOException {
new CreateAccountOperation.Builder(newAccount.getAccountId(), "2000").build())
.addPreconditions(
TransactionPreconditions.builder()
- .timeBounds(new TimeBounds(0L, TransactionPreconditions.TIMEOUT_INFINITE))
+ .timeBounds(
+ new TimeBounds(BigInteger.ZERO, TransactionPreconditions.TIMEOUT_INFINITE))
.minSeqLedgerGap(5)
.build())
.setBaseFee(Transaction.MIN_BASE_FEE)
@@ -482,13 +438,8 @@ public void testBuilderSetsMinSeqLedgerGap() throws IOException {
assertEquals(5, transaction.getPreconditions().getMinSeqLedgerGap());
// Convert transaction to binary XDR and back again to make sure correctly xdr de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- javax.xml.bind.DatatypeConverter.parseBase64Binary(
- transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
Transaction transaction2 =
(Transaction)
Transaction.fromEnvelopeXdr(
@@ -509,10 +460,9 @@ public void testBuilderExtraSigners() throws IOException {
Account account = new Account(source.getAccountId(), 2908908335136768L);
String accountStrKey = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ";
- byte[] payload =
- BaseEncoding.base16()
- .decode(
- "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20".toUpperCase());
+
+ String encodedString = "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20";
+ byte[] payload = Util.hexToBytes(encodedString);
SignerKey signerKey =
new SignerKey.Builder()
@@ -530,8 +480,9 @@ public void testBuilderExtraSigners() throws IOException {
new CreateAccountOperation.Builder(newAccount.getAccountId(), "2000").build())
.addPreconditions(
TransactionPreconditions.builder()
- .timeBounds(new TimeBounds(0L, TransactionPreconditions.TIMEOUT_INFINITE))
- .extraSigners(newArrayList(signerKey))
+ .timeBounds(
+ new TimeBounds(BigInteger.ZERO, TransactionPreconditions.TIMEOUT_INFINITE))
+ .extraSigners(Collections.singletonList(signerKey))
.minSeqLedgerGap(5)
.build())
.setBaseFee(Transaction.MIN_BASE_FEE)
@@ -539,22 +490,19 @@ public void testBuilderExtraSigners() throws IOException {
assertEquals(
SignerKeyType.SIGNER_KEY_TYPE_ED25519_SIGNED_PAYLOAD,
- newArrayList(transaction.getPreconditions().getExtraSigners()).get(0).getDiscriminant());
+ transaction.getPreconditions().getExtraSigners().get(0).getDiscriminant());
assertArrayEquals(
payload,
- newArrayList(transaction.getPreconditions().getExtraSigners())
+ transaction
+ .getPreconditions()
+ .getExtraSigners()
.get(0)
.getEd25519SignedPayload()
.getPayload());
// Convert transaction to binary XDR and back again to make sure correctly xdr de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- javax.xml.bind.DatatypeConverter.parseBase64Binary(
- transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
Transaction transaction2 =
(Transaction)
Transaction.fromEnvelopeXdr(
@@ -576,9 +524,10 @@ public void testBuilderFailsWhenTooManyExtraSigners() throws IOException {
new CreateAccountOperation.Builder(KeyPair.random().getAccountId(), "2000").build())
.addPreconditions(
TransactionPreconditions.builder()
- .timeBounds(new TimeBounds(0L, TransactionPreconditions.TIMEOUT_INFINITE))
+ .timeBounds(
+ new TimeBounds(BigInteger.ZERO, TransactionPreconditions.TIMEOUT_INFINITE))
.extraSigners(
- newArrayList(
+ Arrays.asList(
new SignerKey.Builder().build(),
new SignerKey.Builder().build(),
new SignerKey.Builder().build()))
@@ -604,14 +553,14 @@ public void testBuilderFailsWhenTimeoutLessThanTimeBoundsMinimum() throws Except
// set min time to 120 seconds from now
.timeBounds(
new TimeBounds(
- (System.currentTimeMillis() / 1000) + 120,
+ BigInteger.valueOf((System.currentTimeMillis() / 1000) + 120),
TransactionPreconditions.TIMEOUT_INFINITE))
.build())
.setBaseFee(Transaction.MIN_BASE_FEE)
.setTimeout(1); // sat max time to 1 second from now
fail();
} catch (IllegalArgumentException exception) {
- assertTrue(exception.getMessage().contains("minTime must be >= maxTime"));
+ assertTrue(exception.getMessage().contains("minTime must be <= maxTime"));
}
}
@@ -624,7 +573,8 @@ public void testBuilderUsesAccountSequence() throws IOException {
new CreateAccountOperation.Builder(KeyPair.random().getAccountId(), "2000").build())
.addPreconditions(
TransactionPreconditions.builder()
- .timeBounds(new TimeBounds(0L, TransactionPreconditions.TIMEOUT_INFINITE))
+ .timeBounds(
+ new TimeBounds(BigInteger.ZERO, TransactionPreconditions.TIMEOUT_INFINITE))
.build())
.setBaseFee(Transaction.MIN_BASE_FEE)
.build();
@@ -710,12 +660,8 @@ public void testBuilderInfinteTimeoutOnly() throws IOException {
// Convert transaction to binary XDR and back again to make sure timeout is correctly
// de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- BaseEncoding.base64().decode(transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
assertEquals(
decodedTransaction
@@ -726,6 +672,7 @@ public void testBuilderInfinteTimeoutOnly() throws IOException {
.getMinTime()
.getTimePoint()
.getUint64()
+ .getNumber()
.longValue(),
0);
assertEquals(
@@ -737,6 +684,7 @@ public void testBuilderInfinteTimeoutOnly() throws IOException {
.getMaxTime()
.getTimePoint()
.getUint64()
+ .getNumber()
.longValue(),
0);
}
@@ -762,12 +710,8 @@ public void testBuilderTimeoutOnly() throws IOException {
// Convert transaction to binary XDR and back again to make sure timeout is correctly
// de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- BaseEncoding.base64().decode(transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
assertEquals(
decodedTransaction
@@ -778,6 +722,7 @@ public void testBuilderTimeoutOnly() throws IOException {
.getMinTime()
.getTimePoint()
.getUint64()
+ .getNumber()
.longValue(),
0);
assertTrue(
@@ -790,6 +735,7 @@ public void testBuilderTimeoutOnly() throws IOException {
.getMaxTime()
.getTimePoint()
.getUint64()
+ .getNumber()
.longValue());
}
@@ -806,7 +752,8 @@ public void testBuilderTimeoutAndMaxTimeNotSet() throws IOException {
new TransactionBuilder(AccountConverter.enableMuxed(), account, Network.TESTNET)
.addOperation(
new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build())
- .addTimeBounds(new TimeBounds(42, TransactionPreconditions.TIMEOUT_INFINITE))
+ .addTimeBounds(
+ new TimeBounds(BigInteger.valueOf(42), TransactionPreconditions.TIMEOUT_INFINITE))
.setTimeout(10)
.setBaseFee(Transaction.MIN_BASE_FEE)
.build();
@@ -815,12 +762,8 @@ public void testBuilderTimeoutAndMaxTimeNotSet() throws IOException {
// Convert transaction to binary XDR and back again to make sure timeout is correctly
// de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- BaseEncoding.base64().decode(transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
assertEquals(
decodedTransaction
@@ -831,6 +774,7 @@ public void testBuilderTimeoutAndMaxTimeNotSet() throws IOException {
.getMinTime()
.getTimePoint()
.getUint64()
+ .getNumber()
.longValue(),
42);
assertTrue(
@@ -843,6 +787,7 @@ public void testBuilderTimeoutAndMaxTimeNotSet() throws IOException {
.getMaxTime()
.getTimePoint()
.getUint64()
+ .getNumber()
.longValue());
}
@@ -859,7 +804,8 @@ public void testBuilderInfinteTimeoutAndMaxTimeNotSet() throws FormatException,
new TransactionBuilder(AccountConverter.enableMuxed(), account, Network.TESTNET)
.addOperation(
new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build())
- .addTimeBounds(new TimeBounds(42, TransactionPreconditions.TIMEOUT_INFINITE))
+ .addTimeBounds(
+ new TimeBounds(BigInteger.valueOf(42), TransactionPreconditions.TIMEOUT_INFINITE))
.setTimeout(TransactionPreconditions.TIMEOUT_INFINITE)
.addMemo(Memo.hash(Util.hash("abcdef".getBytes())))
.setBaseFee(100)
@@ -869,12 +815,8 @@ public void testBuilderInfinteTimeoutAndMaxTimeNotSet() throws FormatException,
// Convert transaction to binary XDR and back again to make sure timebounds are correctly
// de/serialized.
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- BaseEncoding.base64().decode(transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
assertEquals(
decodedTransaction
@@ -885,6 +827,7 @@ public void testBuilderInfinteTimeoutAndMaxTimeNotSet() throws FormatException,
.getMinTime()
.getTimePoint()
.getUint64()
+ .getNumber()
.longValue(),
42);
assertEquals(
@@ -896,6 +839,7 @@ public void testBuilderInfinteTimeoutAndMaxTimeNotSet() throws FormatException,
.getMaxTime()
.getTimePoint()
.getUint64()
+ .getNumber()
.longValue(),
0);
}
@@ -992,7 +936,152 @@ public void testNoNetworkSet() throws FormatException {
.build();
fail();
} catch (NullPointerException e) {
- assertTrue(e.getMessage().contains("Network cannot be null"));
+ assertTrue(e.getMessage().contains("network is marked non-null but is null"));
}
}
+
+ @Test
+ public void voidBuilderSorobanDataXdrString() {
+ KeyPair source =
+ KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS");
+ KeyPair destination =
+ KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR");
+
+ LedgerKey ledgerKey =
+ new LedgerKey.Builder()
+ .discriminant(LedgerEntryType.ACCOUNT)
+ .account(
+ new LedgerKey.LedgerKeyAccount.Builder()
+ .accountID(
+ KeyPair.fromAccountId(
+ "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO")
+ .getXdrAccountId())
+ .build())
+ .build();
+ SorobanTransactionData sorobanData =
+ new SorobanTransactionData.Builder()
+ .resources(
+ new SorobanResources.Builder()
+ .footprint(
+ new LedgerFootprint.Builder()
+ .readOnly(new LedgerKey[] {ledgerKey})
+ .readWrite(new LedgerKey[] {})
+ .build())
+ .readBytes(new Uint32(new XdrUnsignedInteger(699)))
+ .writeBytes(new Uint32(new XdrUnsignedInteger(0)))
+ .instructions(new Uint32(new XdrUnsignedInteger(34567)))
+ .build())
+ .refundableFee(new Int64(100L))
+ .ext(new ExtensionPoint.Builder().discriminant(0).build())
+ .build();
+
+ long sequenceNumber = 2908908335136768L;
+ Account account = new Account(source.getAccountId(), sequenceNumber);
+ Transaction transaction =
+ new TransactionBuilder(AccountConverter.enableMuxed(), account, Network.TESTNET)
+ .addOperation(
+ new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build())
+ .setTimeout(TransactionPreconditions.TIMEOUT_INFINITE)
+ .setBaseFee(Transaction.MIN_BASE_FEE)
+ .setSorobanData(sorobanData)
+ .build();
+
+ assertEquals(sorobanData, transaction.getSorobanData());
+ org.stellar.sdk.xdr.Transaction.TransactionExt expectedExt =
+ new org.stellar.sdk.xdr.Transaction.TransactionExt.Builder()
+ .discriminant(1)
+ .sorobanData(sorobanData)
+ .build();
+ assertEquals(expectedExt, transaction.toEnvelopeXdr().getV1().getTx().getExt());
+ }
+
+ @Test
+ public void voidBuilderSorobanDataXdrObject() throws IOException {
+ KeyPair source =
+ KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS");
+ KeyPair destination =
+ KeyPair.fromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR");
+
+ LedgerKey ledgerKey =
+ new LedgerKey.Builder()
+ .discriminant(LedgerEntryType.ACCOUNT)
+ .account(
+ new LedgerKey.LedgerKeyAccount.Builder()
+ .accountID(
+ KeyPair.fromAccountId(
+ "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO")
+ .getXdrAccountId())
+ .build())
+ .build();
+ SorobanTransactionData sorobanData =
+ new SorobanTransactionData.Builder()
+ .resources(
+ new SorobanResources.Builder()
+ .footprint(
+ new LedgerFootprint.Builder()
+ .readOnly(new LedgerKey[] {ledgerKey})
+ .readWrite(new LedgerKey[] {})
+ .build())
+ .readBytes(new Uint32(new XdrUnsignedInteger(699)))
+ .writeBytes(new Uint32(new XdrUnsignedInteger(0)))
+ .instructions(new Uint32(new XdrUnsignedInteger(34567)))
+ .build())
+ .refundableFee(new Int64(100L))
+ .ext(new ExtensionPoint.Builder().discriminant(0).build())
+ .build();
+ String sorobanDataString = sorobanData.toXdrBase64();
+
+ CreateContractArgs createContractArgs =
+ new CreateContractArgs.Builder()
+ .contractIDPreimage(
+ new ContractIDPreimage.Builder()
+ .discriminant(ContractIDPreimageType.CONTRACT_ID_PREIMAGE_FROM_ADDRESS)
+ .fromAddress(
+ new ContractIDPreimage.ContractIDPreimageFromAddress.Builder()
+ .address(
+ new Address(
+ "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO")
+ .toSCAddress())
+ .salt(new Uint256(new byte[32]))
+ .build())
+ .build())
+ .executable(
+ new ContractExecutable.Builder()
+ .discriminant(ContractExecutableType.CONTRACT_EXECUTABLE_TOKEN)
+ .build())
+ .build();
+ HostFunction hostFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+ InvokeHostFunctionOperation invokeHostFunctionOperation =
+ InvokeHostFunctionOperation.builder().hostFunction(hostFunction).build();
+
+ long sequenceNumber = 2908908335136768L;
+ Account account = new Account(source.getAccountId(), sequenceNumber);
+ Transaction transaction =
+ new TransactionBuilder(AccountConverter.enableMuxed(), account, Network.TESTNET)
+ .addOperation(invokeHostFunctionOperation)
+ .setTimeout(TransactionPreconditions.TIMEOUT_INFINITE)
+ .setBaseFee(Transaction.MIN_BASE_FEE)
+ .setSorobanData(sorobanDataString)
+ .build();
+
+ assertEquals(sorobanData, transaction.getSorobanData());
+ org.stellar.sdk.xdr.Transaction.TransactionExt expectedExt =
+ new org.stellar.sdk.xdr.Transaction.TransactionExt.Builder()
+ .discriminant(1)
+ .sorobanData(sorobanData)
+ .build();
+ assertEquals(expectedExt, transaction.toEnvelopeXdr().getV1().getTx().getExt());
+ }
+
+ private static org.stellar.sdk.xdr.TimeBounds buildTimeBounds(
+ BigInteger minTime, BigInteger maxTime) {
+ return new org.stellar.sdk.xdr.TimeBounds.Builder()
+ .minTime(new TimePoint(new Uint64(new XdrUnsignedHyperInteger(minTime))))
+ .maxTime(new TimePoint(new Uint64(new XdrUnsignedHyperInteger(maxTime))))
+ .build();
+ }
}
diff --git a/src/test/java/org/stellar/sdk/TransactionPreconditionsTest.java b/src/test/java/org/stellar/sdk/TransactionPreconditionsTest.java
index d66b0b539..af65395e0 100644
--- a/src/test/java/org/stellar/sdk/TransactionPreconditionsTest.java
+++ b/src/test/java/org/stellar/sdk/TransactionPreconditionsTest.java
@@ -1,15 +1,14 @@
package org.stellar.sdk;
-import static com.google.common.collect.Lists.newArrayList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.google.common.io.BaseEncoding;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.Arrays;
import org.junit.Test;
import org.stellar.sdk.xdr.Duration;
import org.stellar.sdk.xdr.Int64;
@@ -25,6 +24,8 @@
import org.stellar.sdk.xdr.Uint64;
import org.stellar.sdk.xdr.XdrDataInputStream;
import org.stellar.sdk.xdr.XdrDataOutputStream;
+import org.stellar.sdk.xdr.XdrUnsignedHyperInteger;
+import org.stellar.sdk.xdr.XdrUnsignedInteger;
public class TransactionPreconditionsTest {
@@ -36,14 +37,14 @@ public void itConvertsFromXdr() throws IOException {
PreconditionsV2.Builder v2Builder = new PreconditionsV2.Builder();
v2Builder.extraSigners(new SignerKey[] {});
- v2Builder.minSeqAge(new Duration(new Uint64(2L)));
+ v2Builder.minSeqAge(new Duration(new Uint64(new XdrUnsignedHyperInteger(2L))));
v2Builder.ledgerBounds(
new org.stellar.sdk.xdr.LedgerBounds.Builder()
- .minLedger(new Uint32(1))
- .maxLedger(new Uint32(2))
+ .minLedger(new Uint32(new XdrUnsignedInteger(1)))
+ .maxLedger(new Uint32(new XdrUnsignedInteger(2)))
.build());
v2Builder.minSeqNum(new SequenceNumber(new Int64(4L)));
- v2Builder.minSeqLedgerGap(new Uint32(0));
+ v2Builder.minSeqLedgerGap(new Uint32(new XdrUnsignedInteger(0)));
preconditionsBuilder.v2(v2Builder.build());
Preconditions xdr = preconditionsBuilder.build();
@@ -54,7 +55,7 @@ public void itConvertsFromXdr() throws IOException {
TransactionPreconditions transactionPreconditions = TransactionPreconditions.fromXdr(xdr);
- assertEquals(transactionPreconditions.getMinSeqAge(), 2);
+ assertEquals(transactionPreconditions.getMinSeqAge().longValue(), 2);
assertEquals(transactionPreconditions.getLedgerBounds().getMinLedger(), 1);
assertEquals(transactionPreconditions.getLedgerBounds().getMaxLedger(), 2);
assertEquals(transactionPreconditions.getMinSeqNumber(), Long.valueOf(4));
@@ -69,12 +70,12 @@ public void itRoundTripsFromV2ToV1IfOnlyTimeboundsPresent() throws IOException {
PreconditionsV2.Builder v2Builder = new PreconditionsV2.Builder();
org.stellar.sdk.xdr.TimeBounds xdrTimeBounds =
new org.stellar.sdk.xdr.TimeBounds.Builder()
- .minTime(new TimePoint(new Uint64(1L)))
- .maxTime(new TimePoint(new Uint64(2L)))
+ .minTime(new TimePoint(new Uint64(new XdrUnsignedHyperInteger(1L))))
+ .maxTime(new TimePoint(new Uint64(new XdrUnsignedHyperInteger(2L))))
.build();
v2Builder.timeBounds(xdrTimeBounds);
- v2Builder.minSeqLedgerGap(new Uint32(0));
- v2Builder.minSeqAge(new Duration(new Uint64(0L)));
+ v2Builder.minSeqLedgerGap(new Uint32(new XdrUnsignedInteger(0)));
+ v2Builder.minSeqAge(new Duration(new Uint64(new XdrUnsignedHyperInteger(0L))));
v2Builder.extraSigners(new SignerKey[] {});
preconditionsBuilder.v2(v2Builder.build());
// create V2 Precond with just timebounds
@@ -102,9 +103,8 @@ public void itRoundTripsFromV2ToV1IfOnlyTimeboundsPresent() throws IOException {
public void itConvertsToV2Xdr() throws IOException {
byte[] payload =
- BaseEncoding.base16()
- .decode(
- "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20".toUpperCase());
+ Util.hexToBytes(
+ "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20".toUpperCase());
SignerKey signerKey =
new SignerKey.Builder()
.discriminant(SignerKeyType.SIGNER_KEY_TYPE_ED25519_SIGNED_PAYLOAD)
@@ -122,7 +122,7 @@ public void itConvertsToV2Xdr() throws IOException {
TransactionPreconditions.builder()
.timeBounds(new TimeBounds(1, 2))
.minSeqNumber(3L)
- .extraSigners(newArrayList(signerKey, signerKey, signerKey))
+ .extraSigners(Arrays.asList(signerKey, signerKey, signerKey))
.build();
Preconditions xdr = preconditions.toXdr();
@@ -135,14 +135,16 @@ public void itConvertsToV2Xdr() throws IOException {
assertEquals(xdr.getDiscriminant(), PreconditionType.PRECOND_V2);
assertEquals(
- xdr.getV2().getTimeBounds().getMinTime().getTimePoint().getUint64(), Long.valueOf(1));
+ xdr.getV2().getTimeBounds().getMinTime().getTimePoint().getUint64().getNumber().longValue(),
+ 1L);
assertEquals(
- xdr.getV2().getTimeBounds().getMaxTime().getTimePoint().getUint64(), Long.valueOf(2));
+ xdr.getV2().getTimeBounds().getMaxTime().getTimePoint().getUint64().getNumber().longValue(),
+ 2L);
assertEquals(xdr.getV2().getMinSeqNum().getSequenceNumber().getInt64(), Long.valueOf(3));
// xdr encoding requires non-null for min ledger gap
- assertEquals(xdr.getV2().getMinSeqLedgerGap().getUint32().intValue(), 0);
+ assertEquals(xdr.getV2().getMinSeqLedgerGap().getUint32().getNumber().intValue(), 0);
// xdr encoding requires non-null for min seq age
- assertEquals(xdr.getV2().getMinSeqAge().getDuration().getUint64().longValue(), 0);
+ assertEquals(xdr.getV2().getMinSeqAge().getDuration().getUint64().getNumber().longValue(), 0);
assertEquals(xdr.getV2().getExtraSigners().length, 3);
}
@@ -160,8 +162,10 @@ public void itConvertsOnlyTimeBoundsXdr() throws IOException {
Preconditions.decode(new XdrDataInputStream(new ByteArrayInputStream(baos.toByteArray())));
assertEquals(xdr.getDiscriminant(), PreconditionType.PRECOND_TIME);
- assertEquals(xdr.getTimeBounds().getMinTime().getTimePoint().getUint64(), Long.valueOf(1));
- assertEquals(xdr.getTimeBounds().getMaxTime().getTimePoint().getUint64(), Long.valueOf(2));
+ assertEquals(
+ xdr.getTimeBounds().getMinTime().getTimePoint().getUint64().getNumber().longValue(), 1L);
+ assertEquals(
+ xdr.getTimeBounds().getMaxTime().getTimePoint().getUint64().getNumber().longValue(), 2L);
assertNull(xdr.getV2());
}
@@ -209,7 +213,7 @@ public void itChecksNonValidityOfExtraSignersSize() {
TransactionPreconditions.builder()
.timeBounds(new TimeBounds(1, 2))
.extraSigners(
- newArrayList(
+ Arrays.asList(
new SignerKey.Builder().build(),
new SignerKey.Builder().build(),
new SignerKey.Builder().build()))
@@ -239,11 +243,11 @@ public void itChecksV2Status() {
PreconditionsV2.Builder v2Builder = new PreconditionsV2.Builder();
v2Builder.extraSigners(new SignerKey[] {});
- v2Builder.minSeqAge(new Duration(new Uint64(2L)));
+ v2Builder.minSeqAge(new Duration(new Uint64(new XdrUnsignedHyperInteger(2L))));
v2Builder.ledgerBounds(
new org.stellar.sdk.xdr.LedgerBounds.Builder()
- .minLedger(new Uint32(1))
- .maxLedger(new Uint32(2))
+ .minLedger(new Uint32(new XdrUnsignedInteger(1)))
+ .maxLedger(new Uint32(new XdrUnsignedInteger(2)))
.build());
v2Builder.minSeqNum(new SequenceNumber(new Int64(4L)));
preconditionsBuilder.v2(v2Builder.build());
diff --git a/src/test/java/org/stellar/sdk/TransactionTest.java b/src/test/java/org/stellar/sdk/TransactionTest.java
index 3e423e253..164bc9cb4 100644
--- a/src/test/java/org/stellar/sdk/TransactionTest.java
+++ b/src/test/java/org/stellar/sdk/TransactionTest.java
@@ -2,20 +2,41 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.google.common.io.BaseEncoding;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
import org.junit.Test;
+import org.stellar.sdk.scval.Scv;
+import org.stellar.sdk.xdr.ContractDataDurability;
+import org.stellar.sdk.xdr.ContractExecutable;
+import org.stellar.sdk.xdr.ContractExecutableType;
+import org.stellar.sdk.xdr.ContractIDPreimage;
+import org.stellar.sdk.xdr.ContractIDPreimageType;
+import org.stellar.sdk.xdr.CreateContractArgs;
import org.stellar.sdk.xdr.DecoratedSignature;
import org.stellar.sdk.xdr.EnvelopeType;
+import org.stellar.sdk.xdr.ExtensionPoint;
+import org.stellar.sdk.xdr.HostFunction;
+import org.stellar.sdk.xdr.HostFunctionType;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.LedgerEntryType;
+import org.stellar.sdk.xdr.LedgerFootprint;
+import org.stellar.sdk.xdr.LedgerKey;
+import org.stellar.sdk.xdr.SCVal;
import org.stellar.sdk.xdr.SignerKey;
-import org.stellar.sdk.xdr.XdrDataInputStream;
+import org.stellar.sdk.xdr.SorobanResources;
+import org.stellar.sdk.xdr.SorobanTransactionData;
+import org.stellar.sdk.xdr.Uint256;
+import org.stellar.sdk.xdr.Uint32;
+import org.stellar.sdk.xdr.XdrUnsignedInteger;
public class TransactionTest {
@@ -40,25 +61,23 @@ public void testParseV0Transaction() throws FormatException, IOException {
new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()
},
null,
- new TransactionPreconditions(null, null, 0, 0, new ArrayList(), null),
+ new TransactionPreconditions(
+ null, null, BigInteger.ZERO, 0, new ArrayList(), null),
+ null,
Network.PUBLIC);
transaction.setEnvelopeType(EnvelopeType.ENVELOPE_TYPE_TX_V0);
transaction.sign(source);
- XdrDataInputStream is =
- new XdrDataInputStream(
- new ByteArrayInputStream(
- BaseEncoding.base64().decode(transaction.toEnvelopeXdrBase64())));
org.stellar.sdk.xdr.TransactionEnvelope decodedTransaction =
- org.stellar.sdk.xdr.TransactionEnvelope.decode(is);
+ org.stellar.sdk.xdr.TransactionEnvelope.fromXdrBase64(transaction.toEnvelopeXdrBase64());
assertEquals(EnvelopeType.ENVELOPE_TYPE_TX_V0, decodedTransaction.getDiscriminant());
Transaction parsed =
(Transaction)
Transaction.fromEnvelopeXdr(
AccountConverter.enableMuxed(), transaction.toEnvelopeXdrBase64(), Network.PUBLIC);
- assertTrue(parsed.equals(transaction));
+ assertEquals(parsed, transaction);
assertEquals(EnvelopeType.ENVELOPE_TYPE_TX_V0, parsed.toEnvelopeXdr().getDiscriminant());
assertEquals(transaction.toEnvelopeXdrBase64(), parsed.toEnvelopeXdrBase64());
@@ -86,7 +105,9 @@ public void testAddingSignaturesDirectly() {
new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()
},
null,
- new TransactionPreconditions(null, null, 0, 0, new ArrayList(), null),
+ new TransactionPreconditions(
+ null, null, BigInteger.ZERO, 0, new ArrayList(), null),
+ null,
Network.PUBLIC);
assertEquals(0, transaction.getSignatures().size());
@@ -123,7 +144,9 @@ public void testSha256HashSigning() throws FormatException {
.build()
},
null,
- new TransactionPreconditions(null, null, 0, 0, new ArrayList(), null),
+ new TransactionPreconditions(
+ null, null, BigInteger.ZERO, 0, new ArrayList(), null),
+ null,
Network.PUBLIC);
byte[] preimage = new byte[64];
@@ -158,7 +181,9 @@ public void testToBase64EnvelopeXdrBuilderNoSignatures() throws FormatException,
new CreateAccountOperation.Builder(destination.getAccountId(), "2000").build()
},
null,
- new TransactionPreconditions(null, null, 0, 0, new ArrayList(), null),
+ new TransactionPreconditions(
+ null, null, BigInteger.ZERO, 0, new ArrayList(), null),
+ null,
Network.TESTNET);
Transaction parsed =
@@ -170,4 +195,245 @@ public void testToBase64EnvelopeXdrBuilderNoSignatures() throws FormatException,
"AAAAAgAAAABexSIg06FtXzmFBQQtHZsrnyWxUzmthkBEhs/ktoeVYgAAAGQAClWjAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAO3gUmG83C+VCqO6FztuMtXJF/l7grZA7MjRzqdZ9W8QAAAABKgXyAAAAAAAAAAAAA==",
transaction.toEnvelopeXdrBase64());
}
+
+ @Test
+ public void testConstructorWithSorobanData() throws IOException {
+ KeyPair source =
+ KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS");
+
+ Account account = new Account(source.getAccountId(), 2908908335136768L);
+ LedgerKey ledgerKey =
+ new LedgerKey.Builder()
+ .discriminant(LedgerEntryType.ACCOUNT)
+ .account(
+ new LedgerKey.LedgerKeyAccount.Builder()
+ .accountID(
+ KeyPair.fromAccountId(
+ "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO")
+ .getXdrAccountId())
+ .build())
+ .build();
+ SorobanTransactionData sorobanData =
+ new SorobanTransactionData.Builder()
+ .resources(
+ new SorobanResources.Builder()
+ .footprint(
+ new LedgerFootprint.Builder()
+ .readOnly(new LedgerKey[] {ledgerKey})
+ .readWrite(new LedgerKey[] {})
+ .build())
+ .readBytes(new Uint32(new XdrUnsignedInteger(699)))
+ .writeBytes(new Uint32(new XdrUnsignedInteger(0)))
+ .instructions(new Uint32(new XdrUnsignedInteger(34567)))
+ .build())
+ .refundableFee(new Int64(100L))
+ .ext(new ExtensionPoint.Builder().discriminant(0).build())
+ .build();
+
+ CreateContractArgs createContractArgs =
+ new CreateContractArgs.Builder()
+ .contractIDPreimage(
+ new ContractIDPreimage.Builder()
+ .discriminant(ContractIDPreimageType.CONTRACT_ID_PREIMAGE_FROM_ADDRESS)
+ .fromAddress(
+ new ContractIDPreimage.ContractIDPreimageFromAddress.Builder()
+ .address(
+ new Address(
+ "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO")
+ .toSCAddress())
+ .salt(new Uint256(new byte[32]))
+ .build())
+ .build())
+ .executable(
+ new ContractExecutable.Builder()
+ .discriminant(ContractExecutableType.CONTRACT_EXECUTABLE_TOKEN)
+ .build())
+ .build();
+ HostFunction hostFunction =
+ new HostFunction.Builder()
+ .discriminant(HostFunctionType.HOST_FUNCTION_TYPE_CREATE_CONTRACT)
+ .createContract(createContractArgs)
+ .build();
+ InvokeHostFunctionOperation invokeHostFunctionOperation =
+ InvokeHostFunctionOperation.builder().hostFunction(hostFunction).build();
+ Transaction transaction =
+ new Transaction(
+ AccountConverter.enableMuxed(),
+ account.getAccountId(),
+ Transaction.MIN_BASE_FEE,
+ account.getIncrementedSequenceNumber(),
+ new org.stellar.sdk.Operation[] {invokeHostFunctionOperation},
+ null,
+ new TransactionPreconditions(
+ null, null, BigInteger.ZERO, 0, new ArrayList(), null),
+ sorobanData,
+ Network.TESTNET);
+
+ Transaction parsed =
+ (Transaction)
+ Transaction.fromEnvelopeXdr(
+ AccountConverter.enableMuxed(), transaction.toEnvelopeXdrBase64(), Network.TESTNET);
+ assertEquals(parsed, transaction);
+ String expectedXdr =
+ "AAAAAgAAAABexSIg06FtXzmFBQQtHZsrnyWxUzmthkBEhs/ktoeVYgAAAGQAClWjAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAYAAAAAQAAAAAAAAAAAAAAAH8wYjTJienWf2nf2TEZi2APPWzmtkwiQHAftisIgyuHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAfzBiNMmJ6dZ/ad/ZMRmLYA89bOa2TCJAcB+2KwiDK4cAAAAAAACHBwAAArsAAAAAAAAAAAAAAGQAAAAA";
+ assertEquals(expectedXdr, transaction.toEnvelopeXdrBase64());
+ }
+
+ @Test
+ public void testIsSorobanTransactionInvokeHostFunctionOperation() {
+ KeyPair source =
+ KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS");
+
+ Account account = new Account(source.getAccountId(), 2908908335136768L);
+
+ String contractId = "CDYUOBUVMZPWIU4GB4XNBAYL6NIHIMYLZFNEXOCDIO33MBJMNPSFBYKU";
+ String functionName = "hello";
+ List params = Collections.singletonList(Scv.toSymbol("Soroban"));
+ InvokeHostFunctionOperation operation =
+ InvokeHostFunctionOperation.invokeContractFunctionOperationBuilder(
+ contractId, functionName, params)
+ .build();
+
+ Transaction transaction =
+ new Transaction(
+ AccountConverter.enableMuxed(),
+ account.getAccountId(),
+ Transaction.MIN_BASE_FEE,
+ account.getIncrementedSequenceNumber(),
+ new org.stellar.sdk.Operation[] {operation},
+ null,
+ new TransactionPreconditions(
+ null, null, BigInteger.ZERO, 0, new ArrayList(), null),
+ null,
+ Network.TESTNET);
+ assertTrue(transaction.isSorobanTransaction());
+ }
+
+ @Test
+ public void testIsSorobanTransactionBumpFootprintExpirationOperation() {
+ KeyPair source =
+ KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS");
+
+ Account account = new Account(source.getAccountId(), 2908908335136768L);
+ String contractId = "CDYUOBUVMZPWIU4GB4XNBAYL6NIHIMYLZFNEXOCDIO33MBJMNPSFBYKU";
+ SorobanTransactionData sorobanData =
+ new SorobanDataBuilder()
+ .setReadOnly(
+ Collections.singletonList(
+ new LedgerKey.Builder()
+ .discriminant(LedgerEntryType.CONTRACT_DATA)
+ .contractData(
+ new LedgerKey.LedgerKeyContractData.Builder()
+ .contract(new Address(contractId).toSCAddress())
+ .key(Scv.toLedgerKeyContractInstance())
+ .durability(ContractDataDurability.PERSISTENT)
+ .build())
+ .build()))
+ .build();
+ BumpFootprintExpirationOperation operation =
+ BumpFootprintExpirationOperation.builder().ledgersToExpire(4096L).build();
+ Transaction transaction =
+ new Transaction(
+ AccountConverter.enableMuxed(),
+ account.getAccountId(),
+ Transaction.MIN_BASE_FEE,
+ account.getIncrementedSequenceNumber(),
+ new org.stellar.sdk.Operation[] {operation},
+ null,
+ new TransactionPreconditions(
+ null, null, BigInteger.ZERO, 0, new ArrayList(), null),
+ sorobanData,
+ Network.TESTNET);
+ assertTrue(transaction.isSorobanTransaction());
+ }
+
+ @Test
+ public void testIsSorobanTransactionRestoreFootprintOperation() {
+ KeyPair source =
+ KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS");
+
+ Account account = new Account(source.getAccountId(), 2908908335136768L);
+ String contractId = "CDYUOBUVMZPWIU4GB4XNBAYL6NIHIMYLZFNEXOCDIO33MBJMNPSFBYKU";
+ SorobanTransactionData sorobanData =
+ new SorobanDataBuilder()
+ .setReadOnly(
+ Collections.singletonList(
+ new LedgerKey.Builder()
+ .discriminant(LedgerEntryType.CONTRACT_DATA)
+ .contractData(
+ new LedgerKey.LedgerKeyContractData.Builder()
+ .contract(new Address(contractId).toSCAddress())
+ .key(Scv.toLedgerKeyContractInstance())
+ .durability(ContractDataDurability.PERSISTENT)
+ .build())
+ .build()))
+ .build();
+ RestoreFootprintOperation operation = RestoreFootprintOperation.builder().build();
+ Transaction transaction =
+ new Transaction(
+ AccountConverter.enableMuxed(),
+ account.getAccountId(),
+ Transaction.MIN_BASE_FEE,
+ account.getIncrementedSequenceNumber(),
+ new org.stellar.sdk.Operation[] {operation},
+ null,
+ new TransactionPreconditions(
+ null, null, BigInteger.ZERO, 0, new ArrayList(), null),
+ sorobanData,
+ Network.TESTNET);
+ assertTrue(transaction.isSorobanTransaction());
+ }
+
+ @Test
+ public void testIsSorobanTransactionMultiOperations() {
+ KeyPair source =
+ KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS");
+
+ Account account = new Account(source.getAccountId(), 2908908335136768L);
+
+ String contractId = "CDYUOBUVMZPWIU4GB4XNBAYL6NIHIMYLZFNEXOCDIO33MBJMNPSFBYKU";
+ String functionName = "hello";
+ List params = Collections.singletonList(Scv.toSymbol("Soroban"));
+ InvokeHostFunctionOperation operation =
+ InvokeHostFunctionOperation.invokeContractFunctionOperationBuilder(
+ contractId, functionName, params)
+ .build();
+
+ Transaction transaction =
+ new Transaction(
+ AccountConverter.enableMuxed(),
+ account.getAccountId(),
+ Transaction.MIN_BASE_FEE,
+ account.getIncrementedSequenceNumber(),
+ new org.stellar.sdk.Operation[] {operation, operation},
+ null,
+ new TransactionPreconditions(
+ null, null, BigInteger.ZERO, 0, new ArrayList(), null),
+ null,
+ Network.TESTNET);
+ assertFalse(transaction.isSorobanTransaction());
+ }
+
+ @Test
+ public void testIsSorobanTransactionBumpSequenceOperation() {
+ KeyPair source =
+ KeyPair.fromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS");
+
+ Account account = new Account(source.getAccountId(), 2908908335136768L);
+ BumpSequenceOperation operation = new BumpSequenceOperation.Builder(0L).build();
+
+ Transaction transaction =
+ new Transaction(
+ AccountConverter.enableMuxed(),
+ account.getAccountId(),
+ Transaction.MIN_BASE_FEE,
+ account.getIncrementedSequenceNumber(),
+ new org.stellar.sdk.Operation[] {operation},
+ null,
+ new TransactionPreconditions(
+ null, null, BigInteger.ZERO, 0, new ArrayList(), null),
+ null,
+ Network.TESTNET);
+ assertFalse(transaction.isSorobanTransaction());
+ }
}
diff --git a/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java
index a29352323..d7ba8440d 100644
--- a/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java
+++ b/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java
@@ -62,7 +62,7 @@ public void testOperationById() throws IOException, InterruptedException {
Server server = new Server(mockWebServer.url("").toString());
OperationResponse response = server.operations().operation(438086668289l);
assertEquals(response.getType(), "create_account");
- assertEquals(response.getId(), new Long(438086668289l));
+ assertEquals(response.getId(), Long.valueOf(438086668289l));
assertEquals(
response.getSourceAccount(), "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H");
RecordedRequest request = mockWebServer.takeRequest();
diff --git a/src/test/java/org/stellar/sdk/requests/PathsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/PathsRequestBuilderTest.java
index 94c4a766c..a2ad1408f 100644
--- a/src/test/java/org/stellar/sdk/requests/PathsRequestBuilderTest.java
+++ b/src/test/java/org/stellar/sdk/requests/PathsRequestBuilderTest.java
@@ -5,7 +5,7 @@
import static org.junit.Assert.fail;
import static org.stellar.sdk.Asset.create;
-import com.google.common.collect.Lists;
+import java.util.Arrays;
import java.util.List;
import okhttp3.HttpUrl;
import org.junit.Test;
@@ -46,7 +46,7 @@ public void testStrictReceiveWithSourceAccount() {
@Test
public void testStrictReceiveWithSourceAssets() {
List assets =
- Lists.newArrayList(
+ Arrays.asList(
create("native", "", ""),
create(
"credit_alphanum4",
@@ -87,7 +87,7 @@ public void testStrictReceiveWithSourceAssets() {
@Test
public void testStrictReceiveWithSourceAccountAndSourceAssets() {
List assets =
- Lists.newArrayList(
+ Arrays.asList(
create("native", "", ""),
create(
"credit_alphanum4",
@@ -151,7 +151,7 @@ public void testStrictSendWithDestinationAccount() {
@Test
public void testStrictSendWithDestinationAssets() {
List assets =
- Lists.newArrayList(
+ Arrays.asList(
create("native", "", ""),
create(
"credit_alphanum4",
@@ -190,7 +190,7 @@ public void testStrictSendWithDestinationAssets() {
@Test
public void testStrictSendWithDestinationAccountAndDestinationAssets() {
List assets =
- Lists.newArrayList(
+ Arrays.asList(
create("native", "", ""),
create(
"credit_alphanum4",
diff --git a/src/test/java/org/stellar/sdk/requests/ResponseHandlerTest.java b/src/test/java/org/stellar/sdk/requests/ResponseHandlerTest.java
index 620a17216..8cbea5d26 100644
--- a/src/test/java/org/stellar/sdk/requests/ResponseHandlerTest.java
+++ b/src/test/java/org/stellar/sdk/requests/ResponseHandlerTest.java
@@ -2,8 +2,8 @@
import static org.junit.Assert.assertEquals;
-import com.google.common.base.Optional;
import java.io.IOException;
+import java.util.Optional;
import okhttp3.OkHttpClient;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
@@ -54,7 +54,7 @@ public void testTooManyRequestsNoHeader() throws IOException, InterruptedExcepti
AccountsRequestBuilder.execute(okHttpClient, mockWebServer.url("/"));
Assert.fail();
} catch (TooManyRequestsException tmre) {
- assertEquals(Optional.absent(), tmre.getRetryAfter());
+ assertEquals(Optional.empty(), tmre.getRetryAfter());
} finally {
mockWebServer.shutdown();
diff --git a/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java
index f4f3fa96a..9aa379d9b 100644
--- a/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java
@@ -1,7 +1,7 @@
package org.stellar.sdk.responses;
-import com.google.common.base.Optional;
import java.util.Arrays;
+import java.util.Optional;
import junit.framework.TestCase;
import org.junit.Test;
import org.stellar.sdk.AssetTypeCreditAlphaNum4;
@@ -44,8 +44,8 @@ public void testDeserialize() {
AccountResponse account = GsonSingleton.getInstance().fromJson(json, AccountResponse.class);
assertEquals(
account.getAccountId(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7");
- assertEquals(account.getSequenceNumber(), new Long(2319149195853854L));
- assertEquals(account.getSubentryCount(), new Integer(0));
+ assertEquals(account.getSequenceNumber(), Long.valueOf(2319149195853854L));
+ assertEquals(account.getSubentryCount(), Integer.valueOf(0));
assertEquals(account.getSequenceUpdatedAtLedger().longValue(), 1234);
assertEquals(account.getSequenceUpdatedAtTime().longValue(), 4567);
assertEquals(
@@ -155,14 +155,14 @@ public void testDeserializeV9() {
"ABC", "GCRA6COW27CY5MTKIA7POQ2326C5ABYCXODBN4TFF5VL4FMBRHOT3YHU")));
assertEquals(account.getBalances()[0].getBalance(), "1001.0000000");
assertEquals(account.getBalances()[0].getLimit(), "12000.4775807");
- assertEquals(account.getBalances()[0].getBuyingLiabilities(), Optional.absent());
- assertEquals(account.getBalances()[0].getSellingLiabilities(), Optional.absent());
+ assertEquals(account.getBalances()[0].getBuyingLiabilities(), Optional.empty());
+ assertEquals(account.getBalances()[0].getSellingLiabilities(), Optional.empty());
assertEquals(account.getBalances()[1].getAssetType(), "native");
assertEquals(account.getBalances()[1].getAsset(), Optional.of(new AssetTypeNative()));
assertEquals(account.getBalances()[1].getBalance(), "20.0000300");
- assertEquals(account.getBalances()[1].getBuyingLiabilities(), Optional.absent());
- assertEquals(account.getBalances()[1].getSellingLiabilities(), Optional.absent());
+ assertEquals(account.getBalances()[1].getBuyingLiabilities(), Optional.empty());
+ assertEquals(account.getBalances()[1].getSellingLiabilities(), Optional.empty());
assertEquals(account.getBalances()[1].getLimit(), null);
}
@@ -172,12 +172,12 @@ public void testDeserializeLiquidityPoolBalanc() {
GsonSingleton.getInstance().fromJson(jsonLiquidityPoolBalance, AccountResponse.class);
assertEquals(account.getBalances()[0].getAssetType(), "liquidity_pool_shares");
- assertEquals(account.getBalances()[0].getAssetCode(), Optional.absent());
- assertEquals(account.getBalances()[0].getAssetIssuer(), Optional.absent());
+ assertEquals(account.getBalances()[0].getAssetCode(), Optional.empty());
+ assertEquals(account.getBalances()[0].getAssetIssuer(), Optional.empty());
assertEquals(account.getBalances()[0].getBalance(), "223.6067977");
assertEquals(account.getBalances()[0].getLimit(), "10000.00000");
- assertEquals(account.getBalances()[0].getBuyingLiabilities(), Optional.absent());
- assertEquals(account.getBalances()[0].getSellingLiabilities(), Optional.absent());
+ assertEquals(account.getBalances()[0].getBuyingLiabilities(), Optional.empty());
+ assertEquals(account.getBalances()[0].getSellingLiabilities(), Optional.empty());
assertTrue(account.getBalances()[0].getLiquidityPoolID().isPresent());
assertEquals(
account.getBalances()[0].getLiquidityPoolID().get().toString(),
@@ -185,8 +185,8 @@ public void testDeserializeLiquidityPoolBalanc() {
assertEquals(account.getBalances()[1].getAssetType(), "native");
assertEquals(account.getBalances()[1].getBalance(), "20.0000300");
- assertEquals(account.getBalances()[1].getBuyingLiabilities(), Optional.absent());
- assertEquals(account.getBalances()[1].getSellingLiabilities(), Optional.absent());
+ assertEquals(account.getBalances()[1].getBuyingLiabilities(), Optional.empty());
+ assertEquals(account.getBalances()[1].getSellingLiabilities(), Optional.empty());
assertEquals(account.getBalances()[1].getLimit(), null);
}
diff --git a/src/test/java/org/stellar/sdk/responses/AccountsPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/AccountsPageDeserializerTest.java
index f4bc259ca..fb9d220f0 100644
--- a/src/test/java/org/stellar/sdk/responses/AccountsPageDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/AccountsPageDeserializerTest.java
@@ -1,7 +1,7 @@
package org.stellar.sdk.responses;
-import com.google.common.base.Optional;
import com.google.gson.reflect.TypeToken;
+import java.util.Optional;
import junit.framework.TestCase;
import org.junit.Test;
import org.stellar.sdk.LiquidityPoolID;
@@ -43,7 +43,7 @@ public void testDeserializeWithLiquidityPoolBalance() {
new LiquidityPoolID(
"a468d41d8e9b8f3c7209651608b74b7db7ac9952dcae0cdf24871d1d9c7b0088")));
assertEquals(
- accountsPage.getRecords().get(0).getBalances()[1].getLiquidityPoolID(), Optional.absent());
+ accountsPage.getRecords().get(0).getBalances()[1].getLiquidityPoolID(), Optional.empty());
}
String json =
diff --git a/src/test/java/org/stellar/sdk/responses/AssetsPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/AssetsPageDeserializerTest.java
index c8d966f4d..68f5dd94a 100644
--- a/src/test/java/org/stellar/sdk/responses/AssetsPageDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/AssetsPageDeserializerTest.java
@@ -13,48 +13,53 @@ public void testDeserialize() {
assertEquals(
page.getLinks().getSelf().getHref(),
- "https://horizon.stellar.org/assets?order=asc&limit=10&cursor=");
+ "https://horizon-futurenet.stellar.org/assets?cursor=FRS1_GC6HLY2JXKXYXUU3XYC63O2RJNH4E3GEW26ABTHDF6AF6MY32B5QRISO_credit_alphanum4&limit=5&order=asc");
assertEquals(
page.getLinks().getNext().getHref(),
- "https://horizon.stellar.org/assets?order=asc&limit=10&cursor=AsrtoDollar_GDJWXY5XUASXNL4ABCONR6T5MOXJ2S4HD6WDNAJDSDKQ4VS3TVUQJEDJ_credit_alphanum12");
+ "https://horizon-futurenet.stellar.org/assets?cursor=Fsdk_GBP5VJVRLEZWRMOARGWIPZKV26PBR7SQPHC43ZNJNTATFDOPTOQB4P7I_credit_alphanum4&limit=5&order=asc");
- assertEquals(page.getRecords().get(0).getAssetType(), "credit_alphanum12");
- assertEquals(page.getRecords().get(0).getAssetCode(), "6497847");
+ assertEquals(page.getRecords().get(0).getAssetType(), "credit_alphanum4");
+ assertEquals(page.getRecords().get(0).getAssetCode(), "Fsdk");
assertEquals(
page.getRecords().get(0).getAssetIssuer(),
- "GCGNWKCJ3KHRLPM3TM6N7D3W5YKDJFL6A2YCXFXNMRTZ4Q66MEMZ6FI2");
+ "GAO5OFEWI5ABK66MSPQ6HBXSXNCQLDTF6J444ICGYIQYAPFIWZ7V4MED");
assertEquals(
page.getRecords().get(0).getPagingToken(),
- "6497847_GCGNWKCJ3KHRLPM3TM6N7D3W5YKDJFL6A2YCXFXNMRTZ4Q66MEMZ6FI2_credit_alphanum12");
+ "Fsdk_GAO5OFEWI5ABK66MSPQ6HBXSXNCQLDTF6J444ICGYIQYAPFIWZ7V4MED_credit_alphanum4");
assertEquals(page.getRecords().get(0).getAccounts().authorized(), 1);
assertEquals(page.getRecords().get(0).getAccounts().authorizedToMaintainLiabilities(), 0);
assertEquals(page.getRecords().get(0).getAccounts().unauthorized(), 0);
- assertEquals(page.getRecords().get(0).getBalances().authorized(), "0.0000000");
+ assertEquals(page.getRecords().get(0).getBalances().authorized(), "200.0000000");
assertEquals(
page.getRecords().get(0).getBalances().authorizedToMaintainLiabilities(), "0.0000000");
assertEquals(page.getRecords().get(0).getBalances().unauthorized(), "0.0000000");
assertEquals(page.getRecords().get(0).getNumClaimableBalances(), 0);
assertEquals(page.getRecords().get(0).getClaimableBalancesAmount(), "0.0000000");
- assertEquals(page.getRecords().get(0).getAmount(), "0.0000000");
+ assertEquals(page.getRecords().get(0).getAmount(), "200.0000000");
assertEquals(page.getRecords().get(0).getNumAccounts(), 1);
assertEquals(
page.getRecords().get(0).getLinks().getToml().getHref(),
"https://www.stellar.org/.well-known/stellar.toml");
- assertEquals(page.getRecords().get(0).getFlags().isAuthRequired(), true);
- assertEquals(page.getRecords().get(0).getFlags().isAuthRevocable(), false);
+ assertTrue(page.getRecords().get(0).getFlags().isAuthRequired());
+ assertFalse(page.getRecords().get(0).getFlags().isAuthRevocable());
+ assertEquals(
+ page.getRecords().get(0).getContractID(),
+ "CAKBXQ7XXRMY5F6YFAY4D45HY25VHNKOGWHS3KZX5ULP6E5TRVITMJS2");
+ assertEquals(page.getRecords().get(0).getNumContracts(), 2);
+ assertEquals(page.getRecords().get(0).getContractsAmount(), "25.1230000");
}
String json =
"{\n"
+ " \"_links\": {\n"
+ " \"self\": {\n"
- + " \"href\": \"https://horizon.stellar.org/assets?order=asc\\u0026limit=10\\u0026cursor=\"\n"
+ + " \"href\": \"https://horizon-futurenet.stellar.org/assets?cursor=FRS1_GC6HLY2JXKXYXUU3XYC63O2RJNH4E3GEW26ABTHDF6AF6MY32B5QRISO_credit_alphanum4&limit=5&order=asc\"\n"
+ " },\n"
+ " \"next\": {\n"
- + " \"href\": \"https://horizon.stellar.org/assets?order=asc\\u0026limit=10\\u0026cursor=AsrtoDollar_GDJWXY5XUASXNL4ABCONR6T5MOXJ2S4HD6WDNAJDSDKQ4VS3TVUQJEDJ_credit_alphanum12\"\n"
+ + " \"href\": \"https://horizon-futurenet.stellar.org/assets?cursor=Fsdk_GBP5VJVRLEZWRMOARGWIPZKV26PBR7SQPHC43ZNJNTATFDOPTOQB4P7I_credit_alphanum4&limit=5&order=asc\"\n"
+ " },\n"
+ " \"prev\": {\n"
- + " \"href\": \"https://horizon.stellar.org/assets?order=desc\\u0026limit=10\\u0026cursor=6497847_GCGNWKCJ3KHRLPM3TM6N7D3W5YKDJFL6A2YCXFXNMRTZ4Q66MEMZ6FI2_credit_alphanum12\"\n"
+ + " \"href\": \"https://horizon-futurenet.stellar.org/assets?cursor=Fsdk_GAO5OFEWI5ABK66MSPQ6HBXSXNCQLDTF6J444ICGYIQYAPFIWZ7V4MED_credit_alphanum4&limit=5&order=desc\"\n"
+ " }\n"
+ " },\n"
+ " \"_embedded\": {\n"
@@ -65,56 +70,34 @@ public void testDeserialize() {
+ " \"href\": \"https://www.stellar.org/.well-known/stellar.toml\"\n"
+ " }\n"
+ " },\n"
- + " \"asset_type\": \"credit_alphanum12\",\n"
- + " \"asset_code\": \"6497847\",\n"
- + " \"asset_issuer\": \"GCGNWKCJ3KHRLPM3TM6N7D3W5YKDJFL6A2YCXFXNMRTZ4Q66MEMZ6FI2\",\n"
- + " \"paging_token\": \"6497847_GCGNWKCJ3KHRLPM3TM6N7D3W5YKDJFL6A2YCXFXNMRTZ4Q66MEMZ6FI2_credit_alphanum12\",\n"
+ + " \"asset_type\": \"credit_alphanum4\",\n"
+ + " \"asset_code\": \"Fsdk\",\n"
+ + " \"asset_issuer\": \"GAO5OFEWI5ABK66MSPQ6HBXSXNCQLDTF6J444ICGYIQYAPFIWZ7V4MED\",\n"
+ + " \"paging_token\": \"Fsdk_GAO5OFEWI5ABK66MSPQ6HBXSXNCQLDTF6J444ICGYIQYAPFIWZ7V4MED_credit_alphanum4\",\n"
+ + " \"contract_id\": \"CAKBXQ7XXRMY5F6YFAY4D45HY25VHNKOGWHS3KZX5ULP6E5TRVITMJS2\",\n"
+ + " \"num_accounts\": 1,\n"
+ + " \"num_claimable_balances\": 0,\n"
+ + " \"num_liquidity_pools\": 0,\n"
+ + " \"num_contracts\": 2,\n"
+ + " \"amount\": \"200.0000000\",\n"
+ " \"accounts\": {\n"
+ " \"authorized\": 1,\n"
+ " \"authorized_to_maintain_liabilities\": 0,\n"
+ " \"unauthorized\": 0\n"
+ " },\n"
- + " \"balances\": {\n"
- + " \"authorized\": \"0.0000000\",\n"
- + " \"authorized_to_maintain_liabilities\": \"0.0000000\",\n"
- + " \"unauthorized\": \"0.0000000\"\n"
- + " },\n"
+ " \"claimable_balances_amount\": \"0.0000000\",\n"
- + " \"num_claimable_balances\": 0,\n"
- + " \"amount\": \"0.0000000\",\n"
- + " \"num_accounts\": 1,\n"
- + " \"flags\": {\n"
- + " \"auth_required\": true,\n"
- + " \"auth_revocable\": false\n"
- + " }\n"
- + " },\n"
- + " {\n"
- + " \"_links\": {\n"
- + " \"toml\": {\n"
- + " \"href\": \"\"\n"
- + " }\n"
- + " },\n"
- + " \"asset_type\": \"credit_alphanum12\",\n"
- + " \"asset_code\": \"9HORIZONS\",\n"
- + " \"asset_issuer\": \"GB2HXY7UEDCSHOWZ4553QFGFILNU73OFS2P4HU5IB3UUU66TWPBPVTGW\",\n"
- + " \"paging_token\": \"9HORIZONS_GB2HXY7UEDCSHOWZ4553QFGFILNU73OFS2P4HU5IB3UUU66TWPBPVTGW_credit_alphanum12\",\n"
- + " \"accounts\": {\n"
- + " \"authorized\": 3,\n"
- + " \"authorized_to_maintain_liabilities\": 0,\n"
- + " \"unauthorized\": 0\n"
- + " },\n"
+ + " \"liquidity_pools_amount\": \"0.0000000\",\n"
+ + " \"contracts_amount\": \"25.1230000\",\n"
+ " \"balances\": {\n"
- + " \"authorized\": \"1000000.0000000\",\n"
+ + " \"authorized\": \"200.0000000\",\n"
+ " \"authorized_to_maintain_liabilities\": \"0.0000000\",\n"
+ " \"unauthorized\": \"0.0000000\"\n"
+ " },\n"
- + " \"claimable_balances_amount\": \"0.0000000\",\n"
- + " \"num_claimable_balances\": 0,\n"
- + " \"amount\": \"1000000.0000000\",\n"
- + " \"num_accounts\": 3,\n"
+ " \"flags\": {\n"
- + " \"auth_required\": false,\n"
- + " \"auth_revocable\": false\n"
+ + " \"auth_required\": true,\n"
+ + " \"auth_revocable\": false,\n"
+ + " \"auth_immutable\": false,\n"
+ + " \"auth_clawback_enabled\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
@@ -124,55 +107,32 @@ public void testDeserialize() {
+ " }\n"
+ " },\n"
+ " \"asset_type\": \"credit_alphanum4\",\n"
- + " \"asset_code\": \"AIR\",\n"
- + " \"asset_issuer\": \"GB2SQ74JCS6F4MVDU4BF4L4S4Z5Z36ABOTP6DF5JJOFGFE3ETZAUVUQK\",\n"
- + " \"paging_token\": \"AIR_GB2SQ74JCS6F4MVDU4BF4L4S4Z5Z36ABOTP6DF5JJOFGFE3ETZAUVUQK_credit_alphanum4\",\n"
- + " \"accounts\": {\n"
- + " \"authorized\": 2,\n"
- + " \"authorized_to_maintain_liabilities\": 0,\n"
- + " \"unauthorized\": 0\n"
- + " },\n"
- + " \"balances\": {\n"
- + " \"authorized\": \"100000000000.0000000\",\n"
- + " \"authorized_to_maintain_liabilities\": \"0.0000000\",\n"
- + " \"unauthorized\": \"0.0000000\"\n"
- + " },\n"
- + " \"claimable_balances_amount\": \"0.0000000\",\n"
+ + " \"asset_code\": \"Fsdk\",\n"
+ + " \"asset_issuer\": \"GAPMSH3ZYNL4JB4OBKESIHWK3WZ4IFV4TDNHJRUNI62RT56I7RVUSBWI\",\n"
+ + " \"paging_token\": \"Fsdk_GAPMSH3ZYNL4JB4OBKESIHWK3WZ4IFV4TDNHJRUNI62RT56I7RVUSBWI_credit_alphanum4\",\n"
+ + " \"num_accounts\": 1,\n"
+ " \"num_claimable_balances\": 0,\n"
- + " \"amount\": \"100000000000.0000000\",\n"
- + " \"num_accounts\": 2,\n"
- + " \"flags\": {\n"
- + " \"auth_required\": false,\n"
- + " \"auth_revocable\": false\n"
- + " }\n"
- + " },\n"
- + " {\n"
- + " \"_links\": {\n"
- + " \"toml\": {\n"
- + " \"href\": \"\"\n"
- + " }\n"
- + " },\n"
- + " \"asset_type\": \"credit_alphanum12\",\n"
- + " \"asset_code\": \"AlambLedgerS\",\n"
- + " \"asset_issuer\": \"GCMXATSZBEYTNPFQXHFQXUYXOTHA4HA5L2YZEKKOVGYWTUT24KIHECG3\",\n"
- + " \"paging_token\": \"AlambLedgerS_GCMXATSZBEYTNPFQXHFQXUYXOTHA4HA5L2YZEKKOVGYWTUT24KIHECG3_credit_alphanum12\",\n"
+ + " \"num_liquidity_pools\": 0,\n"
+ + " \"num_contracts\": 0,\n"
+ + " \"amount\": \"200.0000000\",\n"
+ " \"accounts\": {\n"
- + " \"authorized\": 0,\n"
+ + " \"authorized\": 1,\n"
+ " \"authorized_to_maintain_liabilities\": 0,\n"
+ " \"unauthorized\": 0\n"
+ " },\n"
+ + " \"claimable_balances_amount\": \"0.0000000\",\n"
+ + " \"liquidity_pools_amount\": \"0.0000000\",\n"
+ + " \"contracts_amount\": \"0.0000000\",\n"
+ " \"balances\": {\n"
- + " \"authorized\": \"0.0000000\",\n"
+ + " \"authorized\": \"200.0000000\",\n"
+ " \"authorized_to_maintain_liabilities\": \"0.0000000\",\n"
+ " \"unauthorized\": \"0.0000000\"\n"
+ " },\n"
- + " \"claimable_balances_amount\": \"0.0000000\",\n"
- + " \"num_claimable_balances\": 0,\n"
- + " \"amount\": \"0.0000000\",\n"
- + " \"num_accounts\": 0,\n"
+ " \"flags\": {\n"
- + " \"auth_required\": false,\n"
- + " \"auth_revocable\": false\n"
+ + " \"auth_required\": true,\n"
+ + " \"auth_revocable\": false,\n"
+ + " \"auth_immutable\": false,\n"
+ + " \"auth_clawback_enabled\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
@@ -182,26 +142,33 @@ public void testDeserialize() {
+ " }\n"
+ " },\n"
+ " \"asset_type\": \"credit_alphanum4\",\n"
- + " \"asset_code\": \"AMO\",\n"
- + " \"asset_issuer\": \"GBOMFBZG5PWUXDIIW5ITVRVEL6YCIC6ZDXLNBH33BNPCX3D7AXDCDKHF\",\n"
- + " \"paging_token\": \"AMO_GBOMFBZG5PWUXDIIW5ITVRVEL6YCIC6ZDXLNBH33BNPCX3D7AXDCDKHF_credit_alphanum4\",\n"
+ + " \"asset_code\": \"Fsdk\",\n"
+ + " \"asset_issuer\": \"GAZGEVSF73ZUCD7FIZFZK7NRZHYB3TGKLVZIWBD7XPKFF6HKUHKXZ4R4\",\n"
+ + " \"paging_token\": \"Fsdk_GAZGEVSF73ZUCD7FIZFZK7NRZHYB3TGKLVZIWBD7XPKFF6HKUHKXZ4R4_credit_alphanum4\",\n"
+ + " \"contract_id\": \"CCENU3B5K7TXRXRGSF3R32R4FTANRK3KRPLPMN6PDNCKA6MW7B5JOXBJ\",\n"
+ + " \"num_accounts\": 1,\n"
+ + " \"num_claimable_balances\": 0,\n"
+ + " \"num_liquidity_pools\": 0,\n"
+ + " \"num_contracts\": 0,\n"
+ + " \"amount\": \"200.0000000\",\n"
+ " \"accounts\": {\n"
+ " \"authorized\": 1,\n"
+ " \"authorized_to_maintain_liabilities\": 0,\n"
+ " \"unauthorized\": 0\n"
+ " },\n"
+ + " \"claimable_balances_amount\": \"0.0000000\",\n"
+ + " \"liquidity_pools_amount\": \"0.0000000\",\n"
+ + " \"contracts_amount\": \"0.0000000\",\n"
+ " \"balances\": {\n"
- + " \"authorized\": \"10000000.0000000\",\n"
+ + " \"authorized\": \"200.0000000\",\n"
+ " \"authorized_to_maintain_liabilities\": \"0.0000000\",\n"
+ " \"unauthorized\": \"0.0000000\"\n"
+ " },\n"
- + " \"claimable_balances_amount\": \"0.0000000\",\n"
- + " \"num_claimable_balances\": 0,\n"
- + " \"amount\": \"10000000.0000000\",\n"
- + " \"num_accounts\": 1,\n"
+ " \"flags\": {\n"
+ " \"auth_required\": false,\n"
- + " \"auth_revocable\": false\n"
+ + " \"auth_revocable\": false,\n"
+ + " \"auth_immutable\": false,\n"
+ + " \"auth_clawback_enabled\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
@@ -211,145 +178,72 @@ public void testDeserialize() {
+ " }\n"
+ " },\n"
+ " \"asset_type\": \"credit_alphanum4\",\n"
- + " \"asset_code\": \"AMO\",\n"
- + " \"asset_issuer\": \"GDIAIZ7S7L2OBEQBH62KE7IWXK76XA7ES7XCH7JCPXQGV7VB3V6VETOX\",\n"
- + " \"paging_token\": \"AMO_GDIAIZ7S7L2OBEQBH62KE7IWXK76XA7ES7XCH7JCPXQGV7VB3V6VETOX_credit_alphanum4\",\n"
+ + " \"asset_code\": \"Fsdk\",\n"
+ + " \"asset_issuer\": \"GBENWRA65WGOL3OK7DMQXQJWXSO34WQRP5QKFW4LYLCPG5BLFVEMYPF5\",\n"
+ + " \"paging_token\": \"Fsdk_GBENWRA65WGOL3OK7DMQXQJWXSO34WQRP5QKFW4LYLCPG5BLFVEMYPF5_credit_alphanum4\",\n"
+ + " \"contract_id\": \"CC7GMZZM4YJK32V6ZZOWELQMBH7BTKVF52PYWFUR7GGBFAVEAZPQTUJA\",\n"
+ + " \"num_accounts\": 1,\n"
+ + " \"num_claimable_balances\": 0,\n"
+ + " \"num_liquidity_pools\": 0,\n"
+ + " \"num_contracts\": 0,\n"
+ + " \"amount\": \"200.0000000\",\n"
+ " \"accounts\": {\n"
+ " \"authorized\": 1,\n"
+ " \"authorized_to_maintain_liabilities\": 0,\n"
+ " \"unauthorized\": 0\n"
+ " },\n"
- + " \"balances\": {\n"
- + " \"authorized\": \"0.0000000\",\n"
- + " \"authorized_to_maintain_liabilities\": \"0.0000000\",\n"
- + " \"unauthorized\": \"0.0000000\"\n"
- + " },\n"
+ " \"claimable_balances_amount\": \"0.0000000\",\n"
- + " \"num_claimable_balances\": 0,\n"
- + " \"amount\": \"0.0000000\",\n"
- + " \"num_accounts\": 1,\n"
- + " \"flags\": {\n"
- + " \"auth_required\": false,\n"
- + " \"auth_revocable\": false\n"
- + " }\n"
- + " },\n"
- + " {\n"
- + " \"_links\": {\n"
- + " \"toml\": {\n"
- + " \"href\": \"\"\n"
- + " }\n"
- + " },\n"
- + " \"asset_type\": \"credit_alphanum4\",\n"
- + " \"asset_code\": \"ASD\",\n"
- + " \"asset_issuer\": \"GAOMRMILWSX7UXZMYC4X7B7BVJXORYV36XUK3EURVJF7DA6B77ABFVOJ\",\n"
- + " \"paging_token\": \"ASD_GAOMRMILWSX7UXZMYC4X7B7BVJXORYV36XUK3EURVJF7DA6B77ABFVOJ_credit_alphanum4\",\n"
- + " \"accounts\": {\n"
- + " \"authorized\": 0,\n"
- + " \"authorized_to_maintain_liabilities\": 0,\n"
- + " \"unauthorized\": 0\n"
- + " },\n"
+ + " \"liquidity_pools_amount\": \"0.0000000\",\n"
+ + " \"contracts_amount\": \"0.0000000\",\n"
+ " \"balances\": {\n"
- + " \"authorized\": \"0.0000000\",\n"
+ + " \"authorized\": \"200.0000000\",\n"
+ " \"authorized_to_maintain_liabilities\": \"0.0000000\",\n"
+ " \"unauthorized\": \"0.0000000\"\n"
+ " },\n"
- + " \"claimable_balances_amount\": \"0.0000000\",\n"
- + " \"num_claimable_balances\": 0,\n"
- + " \"amount\": \"0.0000000\",\n"
- + " \"num_accounts\": 0,\n"
+ " \"flags\": {\n"
+ " \"auth_required\": false,\n"
- + " \"auth_revocable\": false\n"
+ + " \"auth_revocable\": false,\n"
+ + " \"auth_immutable\": false,\n"
+ + " \"auth_clawback_enabled\": false\n"
+ " }\n"
+ " },\n"
+ " {\n"
+ " \"_links\": {\n"
+ " \"toml\": {\n"
- + " \"href\": \"https://mystellar.tools/.well-known/stellar.toml\"\n"
+ + " \"href\": \"\"\n"
+ " }\n"
+ " },\n"
+ " \"asset_type\": \"credit_alphanum4\",\n"
- + " \"asset_code\": \"ASD\",\n"
- + " \"asset_issuer\": \"GDP4SJE5Y5ODX627DO2F7ZNBAPVXRFHKKR3W4UJ6I4XMW3S3OH2XRWYD\",\n"
- + " \"paging_token\": \"ASD_GDP4SJE5Y5ODX627DO2F7ZNBAPVXRFHKKR3W4UJ6I4XMW3S3OH2XRWYD_credit_alphanum4\",\n"
- + " \"accounts\": {\n"
- + " \"authorized\": 0,\n"
- + " \"authorized_to_maintain_liabilities\": 0,\n"
- + " \"unauthorized\": 0\n"
- + " },\n"
- + " \"balances\": {\n"
- + " \"authorized\": \"0.0000000\",\n"
- + " \"authorized_to_maintain_liabilities\": \"0.0000000\",\n"
- + " \"unauthorized\": \"0.0000000\"\n"
- + " },\n"
- + " \"claimable_balances_amount\": \"0.0000000\",\n"
+ + " \"asset_code\": \"Fsdk\",\n"
+ + " \"asset_issuer\": \"GBP5VJVRLEZWRMOARGWIPZKV26PBR7SQPHC43ZNJNTATFDOPTOQB4P7I\",\n"
+ + " \"paging_token\": \"Fsdk_GBP5VJVRLEZWRMOARGWIPZKV26PBR7SQPHC43ZNJNTATFDOPTOQB4P7I_credit_alphanum4\",\n"
+ + " \"contract_id\": \"CC52PADO3R5DBLXXEBVTKWOKZ7TRBLTPSJV6WQT62JL3MRKDWOJDTT6J\",\n"
+ + " \"num_accounts\": 1,\n"
+ " \"num_claimable_balances\": 0,\n"
- + " \"amount\": \"0.0000000\",\n"
- + " \"num_accounts\": 0,\n"
- + " \"flags\": {\n"
- + " \"auth_required\": false,\n"
- + " \"auth_revocable\": false\n"
- + " }\n"
- + " },\n"
- + " {\n"
- + " \"_links\": {\n"
- + " \"toml\": {\n"
- + " \"href\": \"\"\n"
- + " }\n"
- + " },\n"
- + " \"asset_type\": \"credit_alphanum12\",\n"
- + " \"asset_code\": \"AsrtoDollar\",\n"
- + " \"asset_issuer\": \"GBPGO557IQWSWOIKHWB7YJ5QIBWVF4QS6SPGWT5YBGDUPE6QKOD7RR7S\",\n"
- + " \"paging_token\": \"AsrtoDollar_GBPGO557IQWSWOIKHWB7YJ5QIBWVF4QS6SPGWT5YBGDUPE6QKOD7RR7S_credit_alphanum12\",\n"
+ + " \"num_liquidity_pools\": 0,\n"
+ + " \"num_contracts\": 0,\n"
+ + " \"amount\": \"200.0000000\",\n"
+ " \"accounts\": {\n"
- + " \"authorized\": 0,\n"
+ + " \"authorized\": 1,\n"
+ " \"authorized_to_maintain_liabilities\": 0,\n"
+ " \"unauthorized\": 0\n"
+ " },\n"
- + " \"balances\": {\n"
- + " \"authorized\": \"0.0000000\",\n"
- + " \"authorized_to_maintain_liabilities\": \"0.0000000\",\n"
- + " \"unauthorized\": \"0.0000000\"\n"
- + " },\n"
+ " \"claimable_balances_amount\": \"0.0000000\",\n"
- + " \"num_claimable_balances\": 0,\n"
- + " \"amount\": \"0.0000000\",\n"
- + " \"num_accounts\": 0,\n"
- + " \"flags\": {\n"
- + " \"auth_required\": false,\n"
- + " \"auth_revocable\": false\n"
- + " }\n"
- + " },\n"
- + " {\n"
- + " \"_links\": {\n"
- + " \"toml\": {\n"
- + " \"href\": \"\"\n"
- + " }\n"
- + " },\n"
- + " \"asset_type\": \"credit_alphanum12\",\n"
- + " \"asset_code\": \"AsrtoDollar\",\n"
- + " \"asset_issuer\": \"GDJWXY5XUASXNL4ABCONR6T5MOXJ2S4HD6WDNAJDSDKQ4VS3TVUQJEDJ\",\n"
- + " \"paging_token\": \"AsrtoDollar_GDJWXY5XUASXNL4ABCONR6T5MOXJ2S4HD6WDNAJDSDKQ4VS3TVUQJEDJ_credit_alphanum12\",\n"
- + " \"accounts\": {\n"
- + " \"authorized\": 0,\n"
- + " \"authorized_to_maintain_liabilities\": 0,\n"
- + " \"unauthorized\": 0\n"
- + " },\n"
+ + " \"liquidity_pools_amount\": \"0.0000000\",\n"
+ + " \"contracts_amount\": \"0.0000000\",\n"
+ " \"balances\": {\n"
- + " \"authorized\": \"0.0000000\",\n"
+ + " \"authorized\": \"200.0000000\",\n"
+ " \"authorized_to_maintain_liabilities\": \"0.0000000\",\n"
+ " \"unauthorized\": \"0.0000000\"\n"
+ " },\n"
- + " \"claimable_balances_amount\": \"0.0000000\",\n"
- + " \"num_claimable_balances\": 0,\n"
- + " \"amount\": \"0.0000000\",\n"
- + " \"num_accounts\": 0,\n"
+ " \"flags\": {\n"
+ " \"auth_required\": false,\n"
- + " \"auth_revocable\": false\n"
+ + " \"auth_revocable\": false,\n"
+ + " \"auth_immutable\": false,\n"
+ + " \"auth_clawback_enabled\": false\n"
+ " }\n"
+ " }\n"
+ " ]\n"
+ " }\n"
- + "}";
+ + "}\n";
}
diff --git a/src/test/java/org/stellar/sdk/responses/ClaimableBalancePageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/ClaimableBalancePageDeserializerTest.java
index 56f189983..bdb50ee9f 100644
--- a/src/test/java/org/stellar/sdk/responses/ClaimableBalancePageDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/ClaimableBalancePageDeserializerTest.java
@@ -1,7 +1,7 @@
package org.stellar.sdk.responses;
-import com.google.common.base.Optional;
import com.google.gson.reflect.TypeToken;
+import java.util.Optional;
import junit.framework.TestCase;
import org.junit.Test;
import org.stellar.sdk.Asset;
diff --git a/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java
index 100d106b1..d1303f1a5 100644
--- a/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java
@@ -3,6 +3,7 @@
import static org.junit.Assert.assertArrayEquals;
import static org.stellar.sdk.Asset.create;
+import java.math.BigInteger;
import java.util.Arrays;
import junit.framework.TestCase;
import org.junit.Test;
@@ -19,6 +20,8 @@
import org.stellar.sdk.responses.effects.AccountThresholdsUpdatedEffectResponse;
import org.stellar.sdk.responses.effects.ClaimableBalanceClaimantCreatedEffectResponse;
import org.stellar.sdk.responses.effects.ClaimableBalanceClawedBackEffectResponse;
+import org.stellar.sdk.responses.effects.ContractCreditedEffectResponse;
+import org.stellar.sdk.responses.effects.ContractDebitedEffectResponse;
import org.stellar.sdk.responses.effects.DataCreatedEffectResponse;
import org.stellar.sdk.responses.effects.DataRemovedEffectResponse;
import org.stellar.sdk.responses.effects.DataUpdatedEffectResponse;
@@ -379,7 +382,8 @@ public void testDeserializeClaimableBalanceClaimantCreatedEffect() {
assertEquals(effect.getType(), "claimable_balance_claimant_created");
assertSame(effect.getPredicate().getClass(), Predicate.AbsBefore.class);
assertEquals(
- ((Predicate.AbsBefore) effect.getPredicate()).getTimestampSeconds(), 1234567890982222222L);
+ ((Predicate.AbsBefore) effect.getPredicate()).getTimestampSeconds(),
+ BigInteger.valueOf(1234567890982222222L));
}
@Test
@@ -422,7 +426,9 @@ public void testBackwardsCompatAbsBeforeEpoch() {
"0000000071d3336fa6b6cf81fcbeda85a503ccfabc786ab1066594716f3f9551ea4b89ca");
assertEquals(effect.getType(), "claimable_balance_claimant_created");
assertSame(effect.getPredicate().getClass(), Predicate.AbsBefore.class);
- assertEquals(((Predicate.AbsBefore) effect.getPredicate()).getTimestampSeconds(), 1637479450L);
+ assertEquals(
+ ((Predicate.AbsBefore) effect.getPredicate()).getTimestampSeconds(),
+ BigInteger.valueOf(1637479450L));
}
@Test
@@ -1413,4 +1419,86 @@ public void testDeserializeLiquidityPoolRevokedEffect() {
});
assertEquals(effect.getSharesRevoked(), "24452.3233794");
}
+
+ @Test
+ public void testDeserializeContractCreditedEffect() {
+ String json =
+ "{\n"
+ + " \"_links\": {\n"
+ + " \"operation\": {\n"
+ + " \"href\": \"http://100.83.15.43:8000/operations/21517786157057\"\n"
+ + " },\n"
+ + " \"succeeds\": {\n"
+ + " \"href\": \"http://100.83.15.43:8000/effects?order=desc&cursor=21517786157057-2\"\n"
+ + " },\n"
+ + " \"precedes\": {\n"
+ + " \"href\": \"http://100.83.15.43:8000/effects?order=asc&cursor=21517786157057-2\"\n"
+ + " }\n"
+ + " },\n"
+ + " \"id\": \"0000021517786157057-0000000002\",\n"
+ + " \"paging_token\": \"21517786157057-2\",\n"
+ + " \"account\": \"GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54\",\n"
+ + " \"type\": \"contract_credited\",\n"
+ + " \"type_i\": 96,\n"
+ + " \"created_at\": \"2023-09-19T05:43:12Z\",\n"
+ + " \"asset_type\": \"native\",\n"
+ + " \"contract\": \"CDCYWK73YTYFJZZSJ5V7EDFNHYBG4QN3VUNG2IGD27KJDDPNCZKBCBXK\",\n"
+ + " \"amount\": \"100.0000000\"\n"
+ + "}\n";
+
+ ContractCreditedEffectResponse effect =
+ (ContractCreditedEffectResponse)
+ GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
+
+ assertEquals(effect.getType(), "contract_credited");
+ assertEquals(effect.getId(), "0000021517786157057-0000000002");
+ assertEquals(effect.getPagingToken(), "21517786157057-2");
+ assertEquals(effect.getAccount(), "GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54");
+ assertEquals(effect.getCreatedAt(), "2023-09-19T05:43:12Z");
+ assertEquals(effect.getAmount(), "100.0000000");
+ assertEquals(effect.getAssetType(), "native");
+ assertNull(effect.getAssetCode());
+ assertNull(effect.getAssetIssuer());
+ }
+
+ @Test
+ public void testDeserializeContractDebitedEffect() {
+ String json =
+ "{\n"
+ + " \"_links\": {\n"
+ + " \"operation\": {\n"
+ + " \"href\": \"http://100.83.15.43:8000/operations/21517786157057\"\n"
+ + " },\n"
+ + " \"succeeds\": {\n"
+ + " \"href\": \"http://100.83.15.43:8000/effects?order=desc&cursor=21517786157057-2\"\n"
+ + " },\n"
+ + " \"precedes\": {\n"
+ + " \"href\": \"http://100.83.15.43:8000/effects?order=asc&cursor=21517786157057-2\"\n"
+ + " }\n"
+ + " },\n"
+ + " \"id\": \"0000021517786157057-0000000002\",\n"
+ + " \"paging_token\": \"21517786157057-2\",\n"
+ + " \"account\": \"GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54\",\n"
+ + " \"type\": \"contract_debited\",\n"
+ + " \"type_i\": 97,\n"
+ + " \"created_at\": \"2023-09-19T05:43:12Z\",\n"
+ + " \"asset_type\": \"native\",\n"
+ + " \"contract\": \"CDCYWK73YTYFJZZSJ5V7EDFNHYBG4QN3VUNG2IGD27KJDDPNCZKBCBXK\",\n"
+ + " \"amount\": \"100.0000000\"\n"
+ + "}\n";
+
+ ContractDebitedEffectResponse effect =
+ (ContractDebitedEffectResponse)
+ GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
+
+ assertEquals(effect.getType(), "contract_debited");
+ assertEquals(effect.getId(), "0000021517786157057-0000000002");
+ assertEquals(effect.getPagingToken(), "21517786157057-2");
+ assertEquals(effect.getAccount(), "GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54");
+ assertEquals(effect.getCreatedAt(), "2023-09-19T05:43:12Z");
+ assertEquals(effect.getAmount(), "100.0000000");
+ assertEquals(effect.getAssetType(), "native");
+ assertNull(effect.getAssetCode());
+ assertNull(effect.getAssetIssuer());
+ }
}
diff --git a/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java
index 4864dac56..cd7c46274 100644
--- a/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java
@@ -3,13 +3,11 @@
import static java.math.BigInteger.valueOf;
import static org.stellar.sdk.Asset.create;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
import java.math.BigInteger;
import java.util.Arrays;
+import java.util.Collections;
import junit.framework.TestCase;
import org.junit.Test;
-import org.stellar.sdk.Asset;
import org.stellar.sdk.AssetAmount;
import org.stellar.sdk.AssetTypeNative;
import org.stellar.sdk.AssetTypePoolShare;
@@ -18,6 +16,7 @@
import org.stellar.sdk.Price;
import org.stellar.sdk.responses.operations.AccountMergeOperationResponse;
import org.stellar.sdk.responses.operations.AllowTrustOperationResponse;
+import org.stellar.sdk.responses.operations.BumpFootprintExpirationOperationResponse;
import org.stellar.sdk.responses.operations.BumpSequenceOperationResponse;
import org.stellar.sdk.responses.operations.ChangeTrustOperationResponse;
import org.stellar.sdk.responses.operations.ClaimClaimableBalanceOperationResponse;
@@ -27,6 +26,7 @@
import org.stellar.sdk.responses.operations.CreateClaimableBalanceOperationResponse;
import org.stellar.sdk.responses.operations.EndSponsoringFutureReservesOperationResponse;
import org.stellar.sdk.responses.operations.InflationOperationResponse;
+import org.stellar.sdk.responses.operations.InvokeHostFunctionOperationResponse;
import org.stellar.sdk.responses.operations.LiquidityPoolDepositOperationResponse;
import org.stellar.sdk.responses.operations.LiquidityPoolWithdrawOperationResponse;
import org.stellar.sdk.responses.operations.ManageBuyOfferOperationResponse;
@@ -35,6 +35,7 @@
import org.stellar.sdk.responses.operations.PathPaymentStrictReceiveOperationResponse;
import org.stellar.sdk.responses.operations.PathPaymentStrictSendOperationResponse;
import org.stellar.sdk.responses.operations.PaymentOperationResponse;
+import org.stellar.sdk.responses.operations.RestoreFootprintOperationResponse;
import org.stellar.sdk.responses.operations.SetOptionsOperationResponse;
import org.stellar.sdk.responses.operations.SetTrustLineFlagsOperationResponse;
@@ -868,7 +869,7 @@ public void testDeserializePathPaymentOperation() {
assertEquals(operation.getAsset(), new AssetTypeNative());
assertEquals(
operation.getPath(),
- ImmutableList.of(
+ Arrays.asList(
new AssetTypeNative(),
create(null, "CNY", "GAREELUB43IRHWEASCFBLKHURCGMHE5IF6XSE7EXDLACYHGRHM43RFOX"),
create(null, "CNYMNL", "GAREELUB43IRHWEASCFBLKHURCGMHE5IF6XSE7EXDLACYHGRHM43RFOX")));
@@ -932,7 +933,7 @@ public void testDeserializePathPaymentStrictSendOperation() {
assertEquals(operation.getAsset(), new AssetTypeNative());
assertEquals(
operation.getPath(),
- ImmutableList.of(
+ Arrays.asList(
new AssetTypeNative(),
create(null, "CNY", "GAREELUB43IRHWEASCFBLKHURCGMHE5IF6XSE7EXDLACYHGRHM43RFOX"),
create(null, "CNYMNL", "GAREELUB43IRHWEASCFBLKHURCGMHE5IF6XSE7EXDLACYHGRHM43RFOX")));
@@ -1055,7 +1056,7 @@ public void testDeserializePathPaymentOperationSourceAssetNative() {
assertEquals(operation.getAmount(), "2.5000000");
assertEquals(operation.getSourceMax(), "1.1779523");
assertEquals(operation.getSourceAsset(), new AssetTypeNative());
- assertEquals(operation.getPath(), ImmutableList.of());
+ assertEquals(operation.getPath(), Collections.emptyList());
assertEquals(
operation.getAsset(),
create(null, "XRP", "GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5"));
@@ -1584,11 +1585,12 @@ public void testDeserializeSetTrustlineFlagsOperation() {
operation.getAssetIssuer(), "GCWVFBJ24754I5GXG4JOEB72GJCL3MKWC7VAEYWKGQHPVH3ENPNBSKWS");
assertEquals(operation.getAssetCode(), "EUR");
assertEquals(operation.getAssetType(), "credit_alphanum4");
- assertEquals(operation.getSetFlags(), Lists.newArrayList(4));
- assertEquals(operation.getClearFlags(), Lists.newArrayList(2));
- assertEquals(operation.getSetFlagStrings(), Lists.newArrayList("clawback_enabled"));
+ assertEquals(operation.getSetFlags(), Collections.singletonList(4));
+ assertEquals(operation.getClearFlags(), Collections.singletonList(2));
+ assertEquals(operation.getSetFlagStrings(), Collections.singletonList("clawback_enabled"));
assertEquals(
- operation.getClearFlagStrings(), Lists.newArrayList("authorized_to_maintain_liabilites"));
+ operation.getClearFlagStrings(),
+ Collections.singletonList("authorized_to_maintain_liabilites"));
}
@Test
@@ -1826,7 +1828,7 @@ public void testDeserializeCreateClaimableBalanceOperation() {
assertEquals(
((Predicate.AbsBefore) operation.getClaimants().get(0).getPredicate())
.getTimestampSeconds(),
- 1234567890982222222L);
+ BigInteger.valueOf(1234567890982222222L));
assertEquals(
operation.getClaimants().get(1).getDestination(),
"GAKFBRS24U3PEN6XDMEX4JEV5NGBARS2ZFF5O4CF3JL464SQSD4MDCPF");
@@ -1834,4 +1836,223 @@ public void testDeserializeCreateClaimableBalanceOperation() {
operation.getClaimants().get(1).getPredicate().getClass(), Predicate.Unconditional.class);
assertEquals(operation.getType(), "create_claimable_balance");
}
+
+ @Test
+ public void testDeserializeInvokeHostFunctionOperation() {
+ String json =
+ "{\n"
+ + " \"_links\": {\n"
+ + " \"self\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/operations/2224793063425\"\n"
+ + " },\n"
+ + " \"transaction\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/transactions/4ef3d81fba4b7db959080e4894cb8b2575418b8da9aa484f6306a79a3f63de3d\"\n"
+ + " },\n"
+ + " \"effects\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/operations/2224793063425/effects\"\n"
+ + " },\n"
+ + " \"succeeds\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/effects?order=desc&cursor=2224793063425\"\n"
+ + " },\n"
+ + " \"precedes\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/effects?order=asc&cursor=2224793063425\"\n"
+ + " }\n"
+ + " },\n"
+ + " \"id\": \"2224793063425\",\n"
+ + " \"paging_token\": \"2224793063425\",\n"
+ + " \"transaction_successful\": true,\n"
+ + " \"source_account\": \"GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54\",\n"
+ + " \"type\": \"invoke_host_function\",\n"
+ + " \"type_i\": 24,\n"
+ + " \"created_at\": \"2023-07-20T10:44:56Z\",\n"
+ + " \"transaction_hash\": \"4ef3d81fba4b7db959080e4894cb8b2575418b8da9aa484f6306a79a3f63de3d\",\n"
+ + " \"function\": \"HostFunctionTypeHostFunctionTypeInvokeContract\",\n"
+ + " \"parameters\": [\n"
+ + " {\n"
+ + " \"value\": \"AAAAEgAAAAGw7oy+G8a9SeTIE5E/EuJYl5JfwF0eZJWk8S7LmE7fwA==\",\n"
+ + " \"type\": \"Address\"\n"
+ + " },\n"
+ + " {\n"
+ + " \"value\": \"AAAADwAAAAh0cmFuc2Zlcg==\",\n"
+ + " \"type\": \"Sym\"\n"
+ + " },\n"
+ + " {\n"
+ + " \"value\": \"AAAAEgAAAAAAAAAAwT6e0zIpycpZ5/unUFyQAjXNeSxfmidj8tQWkeD9dCQ=\",\n"
+ + " \"type\": \"Address\"\n"
+ + " },\n"
+ + " {\n"
+ + " \"value\": \"AAAAEgAAAAAAAAAAWLfEosjyl6qPPSRxKB/fzOyv5I5WYzE+wY4Spz7KmKE=\",\n"
+ + " \"type\": \"Address\"\n"
+ + " },\n"
+ + " {\n"
+ + " \"value\": \"AAAACgAAAAAAAAAAAAAAASoF8gA=\",\n"
+ + " \"type\": \"I128\"\n"
+ + " }\n"
+ + " ],\n"
+ + " \"address\": \"\",\n"
+ + " \"salt\": \"\",\n"
+ + " \"asset_balance_changes\": [\n"
+ + " {\n"
+ + " \"asset_type\": \"credit_alphanum12\",\n"
+ + " \"asset_code\": \"Hello\",\n"
+ + " \"asset_issuer\": \"GDJKBIYIPBE2NC5XIZX6GCFZHVWFUA7ONMQUOOVTLIM3BESTI4BYADAN\",\n"
+ + " \"type\": \"transfer\",\n"
+ + " \"from\": \"GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54\",\n"
+ + " \"to\": \"GBMLPRFCZDZJPKUPHUSHCKA737GOZL7ERZLGGMJ6YGHBFJZ6ZKMKCZTM\",\n"
+ + " \"amount\": \"500.0000000\"\n"
+ + " }\n"
+ + " ]\n"
+ + "}";
+
+ InvokeHostFunctionOperationResponse operation =
+ (InvokeHostFunctionOperationResponse)
+ GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
+ assertEquals(
+ operation.getLinks().getSelf().getHref(), "http://127.0.0.1:8000/operations/2224793063425");
+ assertEquals(operation.getId().longValue(), 2224793063425L);
+ assertEquals(operation.getPagingToken(), "2224793063425");
+ // TODO: add transaction_successful field to the response
+ // assertEquals(operation.getTransactionSuccessful(), true);
+ assertEquals(
+ operation.getSourceAccount(), "GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54");
+ assertEquals(operation.getType(), "invoke_host_function");
+ // TODO: add type_i field to the response
+ assertEquals(operation.getCreatedAt(), "2023-07-20T10:44:56Z");
+ assertEquals(
+ operation.getTransactionHash(),
+ "4ef3d81fba4b7db959080e4894cb8b2575418b8da9aa484f6306a79a3f63de3d");
+ assertEquals(operation.getFunction(), "HostFunctionTypeHostFunctionTypeInvokeContract");
+ assertEquals(operation.getParameters().size(), 5);
+ assertEquals(operation.getParameters().get(0).getType(), "Address");
+ assertEquals(
+ operation.getParameters().get(0).getValue(),
+ "AAAAEgAAAAGw7oy+G8a9SeTIE5E/EuJYl5JfwF0eZJWk8S7LmE7fwA==");
+ assertEquals(operation.getParameters().get(1).getType(), "Sym");
+ assertEquals(operation.getParameters().get(1).getValue(), "AAAADwAAAAh0cmFuc2Zlcg==");
+ assertEquals(operation.getParameters().get(2).getType(), "Address");
+ assertEquals(
+ operation.getParameters().get(2).getValue(),
+ "AAAAEgAAAAAAAAAAwT6e0zIpycpZ5/unUFyQAjXNeSxfmidj8tQWkeD9dCQ=");
+ assertEquals(operation.getParameters().get(3).getType(), "Address");
+ assertEquals(
+ operation.getParameters().get(3).getValue(),
+ "AAAAEgAAAAAAAAAAWLfEosjyl6qPPSRxKB/fzOyv5I5WYzE+wY4Spz7KmKE=");
+ assertEquals(operation.getParameters().get(4).getType(), "I128");
+ assertEquals(operation.getParameters().get(4).getValue(), "AAAACgAAAAAAAAAAAAAAASoF8gA=");
+
+ assertEquals(operation.getAddress(), "");
+ assertEquals(operation.getSalt(), "");
+ assertEquals(operation.getAssetBalanceChanges().size(), 1);
+ assertEquals(operation.getAssetBalanceChanges().get(0).getAssetType(), "credit_alphanum12");
+ assertEquals(operation.getAssetBalanceChanges().get(0).getAssetCode(), "Hello");
+ assertEquals(
+ operation.getAssetBalanceChanges().get(0).getAssetIssuer(),
+ "GDJKBIYIPBE2NC5XIZX6GCFZHVWFUA7ONMQUOOVTLIM3BESTI4BYADAN");
+ assertEquals(operation.getAssetBalanceChanges().get(0).getType(), "transfer");
+ assertEquals(
+ operation.getAssetBalanceChanges().get(0).getFrom(),
+ "GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54");
+ assertEquals(
+ operation.getAssetBalanceChanges().get(0).getTo(),
+ "GBMLPRFCZDZJPKUPHUSHCKA737GOZL7ERZLGGMJ6YGHBFJZ6ZKMKCZTM");
+ assertEquals(operation.getAssetBalanceChanges().get(0).getAmount(), "500.0000000");
+ }
+
+ @Test
+ public void testDeserializeBumpFootprintExpirationOperation() {
+ String json =
+ "{\n"
+ + " \"_links\": {\n"
+ + " \"self\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/operations/2224793063426\"\n"
+ + " },\n"
+ + " \"transaction\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/transactions/c452cd9d1ff9692499d0d2aa2f8e898b8c38025300c0f293f4a2adde7295c82f\"\n"
+ + " },\n"
+ + " \"effects\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/operations/2224793063426/effects\"\n"
+ + " },\n"
+ + " \"succeeds\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/effects?order=desc&cursor=2224793063426\"\n"
+ + " },\n"
+ + " \"precedes\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/effects?order=asc&cursor=2224793063426\"\n"
+ + " }\n"
+ + " },\n"
+ + " \"id\": \"2224793063426\",\n"
+ + " \"paging_token\": \"2224793063426\",\n"
+ + " \"transaction_successful\": true,\n"
+ + " \"source_account\": \"GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54\",\n"
+ + " \"type\": \"bump_footprint_expiration\",\n"
+ + " \"type_i\": 25,\n"
+ + " \"created_at\": \"2023-07-20T10:44:56Z\",\n"
+ + " \"transaction_hash\": \"c452cd9d1ff9692499d0d2aa2f8e898b8c38025300c0f293f4a2adde7295c82f\",\n"
+ + " \"ledgers_to_expire\": \"2343241\"\n"
+ + "}";
+
+ BumpFootprintExpirationOperationResponse operation =
+ (BumpFootprintExpirationOperationResponse)
+ GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
+ assertEquals(
+ operation.getLinks().getSelf().getHref(), "http://127.0.0.1:8000/operations/2224793063426");
+ assertEquals(operation.getId().longValue(), 2224793063426L);
+ assertEquals(operation.getPagingToken(), "2224793063426");
+ // assertEquals(operation.getTransactionSuccessful(), true);
+ assertEquals(
+ operation.getSourceAccount(), "GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54");
+ assertEquals(operation.getType(), "bump_footprint_expiration");
+ assertEquals(operation.getCreatedAt(), "2023-07-20T10:44:56Z");
+ assertEquals(
+ operation.getTransactionHash(),
+ "c452cd9d1ff9692499d0d2aa2f8e898b8c38025300c0f293f4a2adde7295c82f");
+ assertEquals(operation.getLedgersToExpire().longValue(), 2343241);
+ }
+
+ @Test
+ public void testDeserializeRestoreFootprintOperationResponse() {
+ String json =
+ "{\n"
+ + " \"_links\": {\n"
+ + " \"self\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/operations/2224793063427\"\n"
+ + " },\n"
+ + " \"transaction\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/transactions/b6932dacb25e05ca8e3d006d2a5a119683602f70474cc9f5de9fc53e99f627f8\"\n"
+ + " },\n"
+ + " \"effects\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/operations/2224793063427/effects\"\n"
+ + " },\n"
+ + " \"succeeds\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/effects?order=desc&cursor=2224793063427\"\n"
+ + " },\n"
+ + " \"precedes\": {\n"
+ + " \"href\": \"http://127.0.0.1:8000/effects?order=asc&cursor=2224793063427\"\n"
+ + " }\n"
+ + " },\n"
+ + " \"id\": \"2224793063427\",\n"
+ + " \"paging_token\": \"2224793063427\",\n"
+ + " \"transaction_successful\": true,\n"
+ + " \"source_account\": \"GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54\",\n"
+ + " \"type\": \"restore_footprint\",\n"
+ + " \"type_i\": 26,\n"
+ + " \"created_at\": \"2023-07-20T10:44:56Z\",\n"
+ + " \"transaction_hash\": \"b6932dacb25e05ca8e3d006d2a5a119683602f70474cc9f5de9fc53e99f627f8\"\n"
+ + "}";
+
+ RestoreFootprintOperationResponse operation =
+ (RestoreFootprintOperationResponse)
+ GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
+ assertEquals(
+ operation.getLinks().getSelf().getHref(), "http://127.0.0.1:8000/operations/2224793063427");
+ assertEquals(operation.getId().longValue(), 2224793063427L);
+ assertEquals(operation.getPagingToken(), "2224793063427");
+ // assertEquals(operation.getTransactionSuccessful(), true);
+ assertEquals(
+ operation.getSourceAccount(), "GDAT5HWTGIU4TSSZ4752OUC4SABDLTLZFRPZUJ3D6LKBNEPA7V2CIG54");
+ assertEquals(operation.getType(), "restore_footprint");
+ assertEquals(operation.getCreatedAt(), "2023-07-20T10:44:56Z");
+ assertEquals(
+ operation.getTransactionHash(),
+ "b6932dacb25e05ca8e3d006d2a5a119683602f70474cc9f5de9fc53e99f627f8");
+ }
}
diff --git a/src/test/java/org/stellar/sdk/responses/TradesPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/TradesPageDeserializerTest.java
index 811f3deff..f6d697053 100644
--- a/src/test/java/org/stellar/sdk/responses/TradesPageDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/TradesPageDeserializerTest.java
@@ -3,8 +3,8 @@
import static java.lang.Long.valueOf;
import static org.stellar.sdk.Asset.create;
-import com.google.common.base.Optional;
import com.google.gson.reflect.TypeToken;
+import java.util.Optional;
import junit.framework.TestCase;
import org.junit.Test;
import org.stellar.sdk.AssetTypeNative;
@@ -39,8 +39,8 @@ public void testDeserialize() {
create(null, "JPY", "GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM"));
assertEquals(tradesPage.getRecords().get(0).getPrice().getNumerator(), valueOf(267));
assertEquals(tradesPage.getRecords().get(0).getPrice().getDenominator(), valueOf(1000));
- assertEquals(tradesPage.getRecords().get(0).getCounterLiquidityPoolID(), Optional.absent());
- assertEquals(tradesPage.getRecords().get(0).getBaseLiquidityPoolID(), Optional.absent());
+ assertEquals(tradesPage.getRecords().get(0).getCounterLiquidityPoolID(), Optional.empty());
+ assertEquals(tradesPage.getRecords().get(0).getBaseLiquidityPoolID(), Optional.empty());
assertEquals(
tradesPage.getRecords().get(1).getBaseAccount(),
@@ -58,8 +58,8 @@ public void testDeserializeLiquidityPool() {
Optional.of(
new LiquidityPoolID(
"a468d41d8e9b8f3c7209651608b74b7db7ac9952dcae0cdf24871d1d9c7bbase")));
- assertEquals(tradesPage.getRecords().get(0).getCounterLiquidityPoolID(), Optional.absent());
- assertEquals(tradesPage.getRecords().get(1).getBaseLiquidityPoolID(), Optional.absent());
+ assertEquals(tradesPage.getRecords().get(0).getCounterLiquidityPoolID(), Optional.empty());
+ assertEquals(tradesPage.getRecords().get(1).getBaseLiquidityPoolID(), Optional.empty());
assertEquals(
tradesPage.getRecords().get(1).getCounterLiquidityPoolID(),
Optional.of(
diff --git a/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java
index 94d4fe781..0dc88025a 100644
--- a/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java
@@ -1,11 +1,10 @@
package org.stellar.sdk.responses;
import static java.math.BigInteger.valueOf;
-import static org.junit.Assert.assertEquals;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.Optional;
import junit.framework.TestCase;
import org.junit.Test;
import org.stellar.sdk.MemoHash;
@@ -28,20 +27,20 @@ public void testDeserializeFeeBump() {
assertEquals(transaction.getMaxFee(), Long.valueOf(776));
assertEquals(transaction.getFeeCharged(), Long.valueOf(123));
assertEquals(transaction.getOperationCount(), Integer.valueOf(1));
- assertEquals(transaction.getSignatures(), ImmutableList.of("Hh4e"));
+ assertEquals(transaction.getSignatures(), Collections.singletonList("Hh4e"));
TransactionResponse.FeeBumpTransaction feeBumpTransaction = transaction.getFeeBump().get();
assertEquals(
feeBumpTransaction.getHash(),
"3dfef7d7226995b504f2827cc63d45ad41e9687bb0a8abcf08ba755fedca0352");
- assertEquals(feeBumpTransaction.getSignatures(), ImmutableList.of("Hh4e"));
+ assertEquals(feeBumpTransaction.getSignatures(), Collections.singletonList("Hh4e"));
TransactionResponse.InnerTransaction innerTransaction = transaction.getInner().get();
assertEquals(
innerTransaction.getHash(),
"e98869bba8bce08c10b78406202127f3888c25454cd37b02600862452751f526");
assertEquals(innerTransaction.getMaxFee(), Long.valueOf(99));
- assertEquals(innerTransaction.getSignatures(), ImmutableList.of("FBQU"));
+ assertEquals(innerTransaction.getSignatures(), Collections.singletonList("FBQU"));
assertFalse(transaction.getSourceAccountMuxed().isPresent());
assertFalse(transaction.getFeeAccountMuxed().isPresent());
@@ -74,11 +73,10 @@ public void testDeserialize() {
"AAAAAAAAAAEAAAACAAAAAAAN+SAAAAAAAAAAAMDtGdqtLMLCPc5P4zZu0IwWlUF2rElL5KvTSoGO0W/uAAAAAEsKz9AADfkgAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAQAN+SAAAAAAAAAAAP1qe44j+i4uIT+arbD4QDQBt8ryEeJd7a0jskQ3nwDeAAHp6WMr55YACD1BAAAAHgAAAAoAAAAAAAAAAAAAAAABAAAAAAAACgAAAAARC07BokpLTOF+/vVKBwiAlop7hHGJTNeGGlY4MoPykwAAAAEAAAAAK+Lzfd3yDD+Ov0GbYu1g7SaIBrKZeBUxoCunkLuI7aoAAAABAAAAAERmsKL73CyLV/HvjyQCERDXXpWE70Xhyb6MR5qPO3yQAAAAAQAAAABSORGwAdyuanN3sNOHqNSpACyYdkUM3L8VafUu69EvEgAAAAEAAAAAeCzqJNkMM/jLvyuMIfyFHljBlLCtDyj17RMycPuNtRMAAAABAAAAAIEi4R7juq15ymL00DNlAddunyFT4FyUD4muC4t3bobdAAAAAQAAAACaNpLL5YMfjOTdXVEqrAh99LM12sN6He6pHgCRAa1f1QAAAAEAAAAAqB+lfAPV9ak+Zkv4aTNZwGaFFAfui4+yhM3dGhoYJ+sAAAABAAAAAMNJrEvdMg6M+M+n4BDIdzsVSj/ZI9SvAp7mOOsvAD/WAAAAAQAAAADbHA6xiKB1+G79mVqpsHMOleOqKa5mxDpP5KEp/Xdz9wAAAAEAAAAAAAAAAA==");
assertEquals(
transaction.getSignatures(),
- ImmutableList.of(
+ Collections.singletonList(
"b/noKPYnxb8oJmv6gLixY0PUJMZZ9pxwc226JtAfyRkhv6oFINj3iDuGJoBeuUh6D1vujP9e4/fH0xZjDaO3Aw=="));
- assertEquals(
- transaction.getFeeBump(), Optional.absent());
- assertEquals(transaction.getInner(), Optional.absent());
+ assertEquals(transaction.getFeeBump(), Optional.empty());
+ assertEquals(transaction.getInner(), Optional.empty());
assertTrue(transaction.getMemo() instanceof MemoHash);
MemoHash memo = (MemoHash) transaction.getMemo();
assertEquals(
diff --git a/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetEventsDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetEventsDeserializerTest.java
new file mode 100644
index 000000000..0f162dd80
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetEventsDeserializerTest.java
@@ -0,0 +1,98 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import static org.junit.Assert.assertEquals;
+
+import com.google.gson.reflect.TypeToken;
+import org.junit.Test;
+import org.stellar.sdk.requests.sorobanrpc.EventFilterType;
+import org.stellar.sdk.responses.GsonSingleton;
+
+public class GetEventsDeserializerTest {
+ @Test
+ public void testDeserialize() {
+ SorobanRpcResponse getEventsResponse =
+ GsonSingleton.getInstance()
+ .fromJson(json, new TypeToken>() {}.getType());
+ assertEquals(getEventsResponse.getResult().getLatestLedger().longValue(), 169L);
+ assertEquals(getEventsResponse.getResult().getEvents().size(), 3);
+ GetEventsResponse.EventInfo eventInfo0 = getEventsResponse.getResult().getEvents().get(0);
+ assertEquals(eventInfo0.getType(), EventFilterType.CONTRACT);
+ assertEquals(eventInfo0.getLedger().intValue(), 108);
+ assertEquals(eventInfo0.getLedgerClosedAt(), "2023-07-23T14:47:01Z");
+ assertEquals(
+ eventInfo0.getContractId(),
+ "607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0");
+ assertEquals(eventInfo0.getId(), "0000000463856472064-0000000000");
+ assertEquals(eventInfo0.getPagingToken(), "0000000463856472064-0000000000");
+ assertEquals(eventInfo0.getTopic().size(), 2);
+ assertEquals(eventInfo0.getTopic().get(0), "AAAADwAAAAdDT1VOVEVSAA==");
+ assertEquals(eventInfo0.getTopic().get(1), "AAAADwAAAAlpbmNyZW1lbnQAAAA=");
+ assertEquals(eventInfo0.getValue().getXdr(), "AAAAAwAAAAE=");
+ assertEquals(eventInfo0.getInSuccessfulContractCall(), true);
+
+ GetEventsResponse.EventInfo eventInfo1 = getEventsResponse.getResult().getEvents().get(1);
+ assertEquals(eventInfo1.getType(), EventFilterType.SYSTEM);
+
+ GetEventsResponse.EventInfo eventInfo2 = getEventsResponse.getResult().getEvents().get(2);
+ assertEquals(eventInfo2.getType(), EventFilterType.DIAGNOSTIC);
+ }
+
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"events\": [\n"
+ + " {\n"
+ + " \"type\": \"contract\",\n"
+ + " \"ledger\": \"108\",\n"
+ + " \"ledgerClosedAt\": \"2023-07-23T14:47:01Z\",\n"
+ + " \"contractId\": \"607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0\",\n"
+ + " \"id\": \"0000000463856472064-0000000000\",\n"
+ + " \"pagingToken\": \"0000000463856472064-0000000000\",\n"
+ + " \"topic\": [\n"
+ + " \"AAAADwAAAAdDT1VOVEVSAA==\",\n"
+ + " \"AAAADwAAAAlpbmNyZW1lbnQAAAA=\"\n"
+ + " ],\n"
+ + " \"value\": {\n"
+ + " \"xdr\": \"AAAAAwAAAAE=\"\n"
+ + " },\n"
+ + " \"inSuccessfulContractCall\": true\n"
+ + " },\n"
+ + " {\n"
+ + " \"type\": \"system\",\n"
+ + " \"ledger\": \"111\",\n"
+ + " \"ledgerClosedAt\": \"2023-07-23T14:47:04Z\",\n"
+ + " \"contractId\": \"607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0\",\n"
+ + " \"id\": \"0000000476741373952-0000000000\",\n"
+ + " \"pagingToken\": \"0000000476741373952-0000000000\",\n"
+ + " \"topic\": [\n"
+ + " \"AAAADwAAAAdDT1VOVEVSAA==\",\n"
+ + " \"AAAADwAAAAlpbmNyZW1lbnQAAAA=\"\n"
+ + " ],\n"
+ + " \"value\": {\n"
+ + " \"xdr\": \"AAAAAwAAAAI=\"\n"
+ + " },\n"
+ + " \"inSuccessfulContractCall\": true\n"
+ + " },\n"
+ + " {\n"
+ + " \"type\": \"diagnostic\",\n"
+ + " \"ledger\": \"114\",\n"
+ + " \"ledgerClosedAt\": \"2023-07-23T14:47:07Z\",\n"
+ + " \"contractId\": \"607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0\",\n"
+ + " \"id\": \"0000000489626275840-0000000000\",\n"
+ + " \"pagingToken\": \"0000000489626275840-0000000000\",\n"
+ + " \"topic\": [\n"
+ + " \"AAAADwAAAAdDT1VOVEVSAA==\",\n"
+ + " \"AAAADwAAAAlpbmNyZW1lbnQAAAA=\"\n"
+ + " ],\n"
+ + " \"value\": {\n"
+ + " \"xdr\": \"AAAAAwAAAAM=\"\n"
+ + " },\n"
+ + " \"inSuccessfulContractCall\": true\n"
+ + " }\n"
+ + " ],\n"
+ + " \"latestLedger\": \"169\"\n"
+ + " }\n"
+ + "}";
+}
diff --git a/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetHealthDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetHealthDeserializerTest.java
new file mode 100644
index 000000000..fc3e33712
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetHealthDeserializerTest.java
@@ -0,0 +1,27 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import static org.junit.Assert.assertEquals;
+
+import com.google.gson.reflect.TypeToken;
+import org.junit.Test;
+import org.stellar.sdk.responses.GsonSingleton;
+
+public class GetHealthDeserializerTest {
+
+ @Test
+ public void testDeserialize() {
+ SorobanRpcResponse getHealthResponse =
+ GsonSingleton.getInstance()
+ .fromJson(json, new TypeToken>() {}.getType());
+ assertEquals(getHealthResponse.getResult().getStatus(), "healthy");
+ }
+
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"status\": \"healthy\"\n"
+ + " }\n"
+ + "}";
+}
diff --git a/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetLatestLedgerDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetLatestLedgerDeserializerTest.java
new file mode 100644
index 000000000..360384272
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetLatestLedgerDeserializerTest.java
@@ -0,0 +1,33 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import static org.junit.Assert.assertEquals;
+
+import com.google.gson.reflect.TypeToken;
+import org.junit.Test;
+import org.stellar.sdk.responses.GsonSingleton;
+
+public class GetLatestLedgerDeserializerTest {
+ @Test
+ public void testDeserialize() {
+ SorobanRpcResponse getLatestLedgerResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ json, new TypeToken>() {}.getType());
+ assertEquals(
+ getLatestLedgerResponse.getResult().getId(),
+ "e73d7654b72daa637f396669182c6072549736a9e3b6fcb8e685adb61f8c910a");
+ assertEquals(getLatestLedgerResponse.getResult().getProtocolVersion().intValue(), 20);
+ assertEquals(getLatestLedgerResponse.getResult().getSequence().intValue(), 24170);
+ }
+
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"id\": \"e73d7654b72daa637f396669182c6072549736a9e3b6fcb8e685adb61f8c910a\",\n"
+ + " \"protocolVersion\": \"20\",\n"
+ + " \"sequence\": 24170\n"
+ + " }\n"
+ + "}";
+}
diff --git a/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetLedgerEntriesDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetLedgerEntriesDeserializerTest.java
new file mode 100644
index 000000000..279e15e2f
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetLedgerEntriesDeserializerTest.java
@@ -0,0 +1,73 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import com.google.gson.reflect.TypeToken;
+import org.junit.Test;
+import org.stellar.sdk.responses.GsonSingleton;
+
+public class GetLedgerEntriesDeserializerTest {
+
+ @Test
+ public void testDeserializeEntriesNotNull() {
+ SorobanRpcResponse getLedgerEntriesResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ getJsonEntriesNotNull,
+ new TypeToken>() {}.getType());
+ assertEquals(getLedgerEntriesResponse.getResult().getLatestLedger().longValue(), 1457);
+ assertEquals(getLedgerEntriesResponse.getResult().getEntries().size(), 1);
+ assertEquals(
+ getLedgerEntriesResponse.getResult().getEntries().get(0).getKey(),
+ "AAAAAAAAAADBPp7TMinJylnn+6dQXJACNc15LF+aJ2Py1BaR4P10JA==");
+ assertEquals(
+ getLedgerEntriesResponse.getResult().getEntries().get(0).getXdr(),
+ "AAAAAAAAAADBPp7TMinJylnn+6dQXJACNc15LF+aJ2Py1BaR4P10JAAAABdIcjmeAAAAfgAAAAgAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAAAArcAAAAAZMIW+A==");
+ assertEquals(
+ getLedgerEntriesResponse
+ .getResult()
+ .getEntries()
+ .get(0)
+ .getLastModifiedLedger()
+ .longValue(),
+ 695);
+ }
+
+ @Test
+ public void testDeserializeEntriesNull() {
+ SorobanRpcResponse getLedgerEntriesResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ jsonEntriesNull,
+ new TypeToken>() {}.getType());
+ assertNull(getLedgerEntriesResponse.getResult().getEntries());
+ assertEquals(getLedgerEntriesResponse.getResult().getLatestLedger().longValue(), 1009L);
+ }
+
+ String getJsonEntriesNotNull =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"44dc79a1b2734eb79d28fe8806345b39\",\n"
+ + " \"result\": {\n"
+ + " \"entries\": [\n"
+ + " {\n"
+ + " \"key\": \"AAAAAAAAAADBPp7TMinJylnn+6dQXJACNc15LF+aJ2Py1BaR4P10JA==\",\n"
+ + " \"xdr\": \"AAAAAAAAAADBPp7TMinJylnn+6dQXJACNc15LF+aJ2Py1BaR4P10JAAAABdIcjmeAAAAfgAAAAgAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAAAArcAAAAAZMIW+A==\",\n"
+ + " \"lastModifiedLedgerSeq\": \"695\"\n"
+ + " }\n"
+ + " ],\n"
+ + " \"latestLedger\": \"1457\"\n"
+ + " }\n"
+ + "}";
+
+ String jsonEntriesNull =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": 8675309,\n"
+ + " \"result\": {\n"
+ + " \"entries\": null,\n"
+ + " \"latestLedger\": \"1009\"\n"
+ + " }\n"
+ + "}";
+}
diff --git a/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetNetworkDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetNetworkDeserializerTest.java
new file mode 100644
index 000000000..5148a9534
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetNetworkDeserializerTest.java
@@ -0,0 +1,32 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import static org.junit.Assert.assertEquals;
+
+import com.google.gson.reflect.TypeToken;
+import org.junit.Test;
+import org.stellar.sdk.responses.GsonSingleton;
+
+public class GetNetworkDeserializerTest {
+ @Test
+ public void testDeserialize() {
+ SorobanRpcResponse getLatestLedgerResponse =
+ GsonSingleton.getInstance()
+ .fromJson(json, new TypeToken>() {}.getType());
+ assertEquals(
+ getLatestLedgerResponse.getResult().getFriendbotUrl(), "http://localhost:8000/friendbot");
+ assertEquals(
+ getLatestLedgerResponse.getResult().getPassphrase(), "Standalone Network ; February 2017");
+ assertEquals(getLatestLedgerResponse.getResult().getProtocolVersion().intValue(), 20);
+ }
+
+ String json =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"friendbotUrl\": \"http://localhost:8000/friendbot\",\n"
+ + " \"passphrase\": \"Standalone Network ; February 2017\",\n"
+ + " \"protocolVersion\": \"20\"\n"
+ + " }\n"
+ + "}";
+}
diff --git a/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetTransactionDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetTransactionDeserializerTest.java
new file mode 100644
index 000000000..053f01300
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/responses/sorobanrpc/GetTransactionDeserializerTest.java
@@ -0,0 +1,149 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import com.google.gson.reflect.TypeToken;
+import org.junit.Test;
+import org.stellar.sdk.responses.GsonSingleton;
+
+public class GetTransactionDeserializerTest {
+ @Test
+ public void testDeserializeSuccess() {
+ SorobanRpcResponse getTransactionResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ jsonSuccess,
+ new TypeToken>() {}.getType());
+ assertEquals(
+ getTransactionResponse.getResult().getStatus(),
+ GetTransactionResponse.GetTransactionStatus.SUCCESS);
+ assertEquals(getTransactionResponse.getResult().getLatestLedger().longValue(), 79289L);
+ assertEquals(
+ getTransactionResponse.getResult().getLatestLedgerCloseTime().longValue(), 1690387240L);
+ assertEquals(getTransactionResponse.getResult().getOldestLedger().longValue(), 77850L);
+ assertEquals(
+ getTransactionResponse.getResult().getOldestLedgerCloseTime().longValue(), 1690379694L);
+ assertEquals(getTransactionResponse.getResult().getApplicationOrder().intValue(), 1);
+ assertEquals(
+ getTransactionResponse.getResult().getEnvelopeXdr(),
+ "AAAAAgAAAADTYKIzfa0ubKp7qjOcF+ZO8sjQutzo1iHuDh8esi9q+wABNjQAATW1AAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAYAAAAAAAAAAIAAAASAAAAAb3H+V1yFoNDBpje4rchxeaR7/hRNS2CAT2Dh6A8z6xrAAAADwAAAARuYW1lAAAAAAAAAAEAAAAAAAAAAwAAAAYAAAABvcf5XXIWg0MGmN7ityHF5pHv+FE1LYIBPYOHoDzPrGsAAAAPAAAACE1FVEFEQVRBAAAAAQAAAAAAAAAGAAAAAb3H+V1yFoNDBpje4rchxeaR7/hRNS2CAT2Dh6A8z6xrAAAAFAAAAAEAAAAAAAAAB++FkDTZODW0rvolF6AuIZf4w7+GQd8RofaH8u2pM+UPAAAAAAAAAAAAUrutAAAiqAAAAAAAAADIAAAAAAAAACgAAAABsi9q+wAAAEDgHR/5rU+bsXD/oPUFodyEgXFNbDm5T2+M1GarZXy+d+tZ757PBL9ysK41F1hUYz3p5CA7Urlpe3fnNjYcu1EM");
+ assertEquals(
+ getTransactionResponse.getResult().getResultXdr(),
+ "AAAAAAABNCwAAAAAAAAAAQAAAAAAAAAYAAAAAJhEDjNV0Jj46jrxCj87qJ6JaYKJN4c+p5tvapkLwrn8AAAAAA==");
+ assertEquals(
+ getTransactionResponse.getResult().getResultMetaXdr(),
+ "AAAAAwAAAAAAAAACAAAAAwABNbYAAAAAAAAAANNgojN9rS5sqnuqM5wX5k7yyNC63OjWIe4OHx6yL2r7AAAAF0h1s9QAATW1AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAQABNbYAAAAAAAAAANNgojN9rS5sqnuqM5wX5k7yyNC63OjWIe4OHx6yL2r7AAAAF0h1s9QAATW1AAAAAQAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAMAAAAAAAE1tgAAAABkwUMZAAAAAAAAAAEAAAAAAAAAAgAAAAMAATW2AAAAAAAAAADTYKIzfa0ubKp7qjOcF+ZO8sjQutzo1iHuDh8esi9q+wAAABdIdbPUAAE1tQAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAABNbYAAAAAZMFDGQAAAAAAAAABAAE1tgAAAAAAAAAA02CiM32tLmyqe6oznBfmTvLI0Lrc6NYh7g4fHrIvavsAAAAXSHWz/AABNbUAAAABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAATW2AAAAAGTBQxkAAAAAAAAAAQAAAAAAAAAAAAAADgAAAAZUb2tlbkEAAAAAAAIAAAABAAAAAAAAAAAAAAACAAAAAAAAAAMAAAAPAAAAB2ZuX2NhbGwAAAAADQAAACC9x/ldchaDQwaY3uK3IcXmke/4UTUtggE9g4egPM+sawAAAA8AAAAEbmFtZQAAAAEAAAABAAAAAAAAAAG9x/ldchaDQwaY3uK3IcXmke/4UTUtggE9g4egPM+sawAAAAIAAAAAAAAAAgAAAA8AAAAJZm5fcmV0dXJuAAAAAAAADwAAAARuYW1lAAAADgAAAAZUb2tlbkEAAA==");
+ assertEquals(getTransactionResponse.getResult().getLedger().longValue(), 79286L);
+ assertEquals(getTransactionResponse.getResult().getCreatedAt().longValue(), 1690387225L);
+ assertNull(getTransactionResponse.getResult().getFeeBump());
+ }
+
+ @Test
+ public void testDeserializeFailed() {
+ SorobanRpcResponse getTransactionResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ jsonFailed,
+ new TypeToken>() {}.getType());
+ assertEquals(
+ getTransactionResponse.getResult().getStatus(),
+ GetTransactionResponse.GetTransactionStatus.FAILED);
+ assertEquals(getTransactionResponse.getResult().getLatestLedger().longValue(), 79289L);
+ assertEquals(
+ getTransactionResponse.getResult().getLatestLedgerCloseTime().longValue(), 1690387240L);
+ assertEquals(getTransactionResponse.getResult().getOldestLedger().longValue(), 77850L);
+ assertEquals(
+ getTransactionResponse.getResult().getOldestLedgerCloseTime().longValue(), 1690379694L);
+ assertEquals(getTransactionResponse.getResult().getApplicationOrder().intValue(), 1);
+ assertEquals(
+ getTransactionResponse.getResult().getEnvelopeXdr(),
+ "AAAAAgAAAADTYKIzfa0ubKp7qjOcF+ZO8sjQutzo1iHuDh8esi9q+wABNjQAATW1AAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAYAAAAAAAAAAIAAAASAAAAAb3H+V1yFoNDBpje4rchxeaR7/hRNS2CAT2Dh6A8z6xrAAAADwAAAARuYW1lAAAAAAAAAAEAAAAAAAAAAwAAAAYAAAABvcf5XXIWg0MGmN7ityHF5pHv+FE1LYIBPYOHoDzPrGsAAAAPAAAACE1FVEFEQVRBAAAAAQAAAAAAAAAGAAAAAb3H+V1yFoNDBpje4rchxeaR7/hRNS2CAT2Dh6A8z6xrAAAAFAAAAAEAAAAAAAAAB++FkDTZODW0rvolF6AuIZf4w7+GQd8RofaH8u2pM+UPAAAAAAAAAAAAUrutAAAiqAAAAAAAAADIAAAAAAAAACgAAAABsi9q+wAAAEDgHR/5rU+bsXD/oPUFodyEgXFNbDm5T2+M1GarZXy+d+tZ757PBL9ysK41F1hUYz3p5CA7Urlpe3fnNjYcu1EM");
+ assertEquals(
+ getTransactionResponse.getResult().getResultXdr(),
+ "AAAAAAABNCwAAAAAAAAAAQAAAAAAAAAYAAAAAJhEDjNV0Jj46jrxCj87qJ6JaYKJN4c+p5tvapkLwrn8AAAAAA==");
+ assertEquals(
+ getTransactionResponse.getResult().getResultMetaXdr(),
+ "AAAAAwAAAAAAAAACAAAAAwABNbYAAAAAAAAAANNgojN9rS5sqnuqM5wX5k7yyNC63OjWIe4OHx6yL2r7AAAAF0h1s9QAATW1AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAQABNbYAAAAAAAAAANNgojN9rS5sqnuqM5wX5k7yyNC63OjWIe4OHx6yL2r7AAAAF0h1s9QAATW1AAAAAQAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAMAAAAAAAE1tgAAAABkwUMZAAAAAAAAAAEAAAAAAAAAAgAAAAMAATW2AAAAAAAAAADTYKIzfa0ubKp7qjOcF+ZO8sjQutzo1iHuDh8esi9q+wAAABdIdbPUAAE1tQAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAABNbYAAAAAZMFDGQAAAAAAAAABAAE1tgAAAAAAAAAA02CiM32tLmyqe6oznBfmTvLI0Lrc6NYh7g4fHrIvavsAAAAXSHWz/AABNbUAAAABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAATW2AAAAAGTBQxkAAAAAAAAAAQAAAAAAAAAAAAAADgAAAAZUb2tlbkEAAAAAAAIAAAABAAAAAAAAAAAAAAACAAAAAAAAAAMAAAAPAAAAB2ZuX2NhbGwAAAAADQAAACC9x/ldchaDQwaY3uK3IcXmke/4UTUtggE9g4egPM+sawAAAA8AAAAEbmFtZQAAAAEAAAABAAAAAAAAAAG9x/ldchaDQwaY3uK3IcXmke/4UTUtggE9g4egPM+sawAAAAIAAAAAAAAAAgAAAA8AAAAJZm5fcmV0dXJuAAAAAAAADwAAAARuYW1lAAAADgAAAAZUb2tlbkEAAA==");
+ assertEquals(getTransactionResponse.getResult().getLedger().longValue(), 79286L);
+ assertEquals(getTransactionResponse.getResult().getCreatedAt().longValue(), 1690387225L);
+ assertNull(getTransactionResponse.getResult().getFeeBump());
+ }
+
+ @Test
+ public void testDeserializeNotFound() {
+ SorobanRpcResponse getTransactionResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ jsonNotFound,
+ new TypeToken>() {}.getType());
+ assertEquals(
+ getTransactionResponse.getResult().getStatus(),
+ GetTransactionResponse.GetTransactionStatus.NOT_FOUND);
+ assertEquals(getTransactionResponse.getResult().getLatestLedger().longValue(), 79285L);
+ assertEquals(
+ getTransactionResponse.getResult().getLatestLedgerCloseTime().longValue(), 1690387220L);
+ assertEquals(getTransactionResponse.getResult().getOldestLedger().longValue(), 77846L);
+ assertEquals(
+ getTransactionResponse.getResult().getOldestLedgerCloseTime().longValue(), 1690379672L);
+
+ assertNull(getTransactionResponse.getResult().getApplicationOrder());
+ assertNull(getTransactionResponse.getResult().getEnvelopeXdr());
+ assertNull(getTransactionResponse.getResult().getResultXdr());
+ assertNull(getTransactionResponse.getResult().getResultMetaXdr());
+ assertNull(getTransactionResponse.getResult().getLedger());
+ assertNull(getTransactionResponse.getResult().getCreatedAt());
+ assertNull(getTransactionResponse.getResult().getFeeBump());
+ }
+
+ String jsonSuccess =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"status\": \"SUCCESS\",\n"
+ + " \"latestLedger\": \"79289\",\n"
+ + " \"latestLedgerCloseTime\": \"1690387240\",\n"
+ + " \"oldestLedger\": \"77850\",\n"
+ + " \"oldestLedgerCloseTime\": \"1690379694\",\n"
+ + " \"applicationOrder\": 1,\n"
+ + " \"envelopeXdr\": \"AAAAAgAAAADTYKIzfa0ubKp7qjOcF+ZO8sjQutzo1iHuDh8esi9q+wABNjQAATW1AAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAYAAAAAAAAAAIAAAASAAAAAb3H+V1yFoNDBpje4rchxeaR7/hRNS2CAT2Dh6A8z6xrAAAADwAAAARuYW1lAAAAAAAAAAEAAAAAAAAAAwAAAAYAAAABvcf5XXIWg0MGmN7ityHF5pHv+FE1LYIBPYOHoDzPrGsAAAAPAAAACE1FVEFEQVRBAAAAAQAAAAAAAAAGAAAAAb3H+V1yFoNDBpje4rchxeaR7/hRNS2CAT2Dh6A8z6xrAAAAFAAAAAEAAAAAAAAAB++FkDTZODW0rvolF6AuIZf4w7+GQd8RofaH8u2pM+UPAAAAAAAAAAAAUrutAAAiqAAAAAAAAADIAAAAAAAAACgAAAABsi9q+wAAAEDgHR/5rU+bsXD/oPUFodyEgXFNbDm5T2+M1GarZXy+d+tZ757PBL9ysK41F1hUYz3p5CA7Urlpe3fnNjYcu1EM\",\n"
+ + " \"resultXdr\": \"AAAAAAABNCwAAAAAAAAAAQAAAAAAAAAYAAAAAJhEDjNV0Jj46jrxCj87qJ6JaYKJN4c+p5tvapkLwrn8AAAAAA==\",\n"
+ + " \"resultMetaXdr\": \"AAAAAwAAAAAAAAACAAAAAwABNbYAAAAAAAAAANNgojN9rS5sqnuqM5wX5k7yyNC63OjWIe4OHx6yL2r7AAAAF0h1s9QAATW1AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAQABNbYAAAAAAAAAANNgojN9rS5sqnuqM5wX5k7yyNC63OjWIe4OHx6yL2r7AAAAF0h1s9QAATW1AAAAAQAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAMAAAAAAAE1tgAAAABkwUMZAAAAAAAAAAEAAAAAAAAAAgAAAAMAATW2AAAAAAAAAADTYKIzfa0ubKp7qjOcF+ZO8sjQutzo1iHuDh8esi9q+wAAABdIdbPUAAE1tQAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAABNbYAAAAAZMFDGQAAAAAAAAABAAE1tgAAAAAAAAAA02CiM32tLmyqe6oznBfmTvLI0Lrc6NYh7g4fHrIvavsAAAAXSHWz/AABNbUAAAABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAATW2AAAAAGTBQxkAAAAAAAAAAQAAAAAAAAAAAAAADgAAAAZUb2tlbkEAAAAAAAIAAAABAAAAAAAAAAAAAAACAAAAAAAAAAMAAAAPAAAAB2ZuX2NhbGwAAAAADQAAACC9x/ldchaDQwaY3uK3IcXmke/4UTUtggE9g4egPM+sawAAAA8AAAAEbmFtZQAAAAEAAAABAAAAAAAAAAG9x/ldchaDQwaY3uK3IcXmke/4UTUtggE9g4egPM+sawAAAAIAAAAAAAAAAgAAAA8AAAAJZm5fcmV0dXJuAAAAAAAADwAAAARuYW1lAAAADgAAAAZUb2tlbkEAAA==\",\n"
+ + " \"ledger\": \"79286\",\n"
+ + " \"createdAt\": \"1690387225\"\n"
+ + " }\n"
+ + "}";
+
+ String jsonNotFound =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"status\": \"NOT_FOUND\",\n"
+ + " \"latestLedger\": \"79285\",\n"
+ + " \"latestLedgerCloseTime\": \"1690387220\",\n"
+ + " \"oldestLedger\": \"77846\",\n"
+ + " \"oldestLedgerCloseTime\": \"1690379672\"\n"
+ + " }\n"
+ + "}";
+
+ String jsonFailed =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"status\": \"FAILED\",\n"
+ + " \"latestLedger\": \"79289\",\n"
+ + " \"latestLedgerCloseTime\": \"1690387240\",\n"
+ + " \"oldestLedger\": \"77850\",\n"
+ + " \"oldestLedgerCloseTime\": \"1690379694\",\n"
+ + " \"applicationOrder\": 1,\n"
+ + " \"envelopeXdr\": \"AAAAAgAAAADTYKIzfa0ubKp7qjOcF+ZO8sjQutzo1iHuDh8esi9q+wABNjQAATW1AAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAYAAAAAAAAAAIAAAASAAAAAb3H+V1yFoNDBpje4rchxeaR7/hRNS2CAT2Dh6A8z6xrAAAADwAAAARuYW1lAAAAAAAAAAEAAAAAAAAAAwAAAAYAAAABvcf5XXIWg0MGmN7ityHF5pHv+FE1LYIBPYOHoDzPrGsAAAAPAAAACE1FVEFEQVRBAAAAAQAAAAAAAAAGAAAAAb3H+V1yFoNDBpje4rchxeaR7/hRNS2CAT2Dh6A8z6xrAAAAFAAAAAEAAAAAAAAAB++FkDTZODW0rvolF6AuIZf4w7+GQd8RofaH8u2pM+UPAAAAAAAAAAAAUrutAAAiqAAAAAAAAADIAAAAAAAAACgAAAABsi9q+wAAAEDgHR/5rU+bsXD/oPUFodyEgXFNbDm5T2+M1GarZXy+d+tZ757PBL9ysK41F1hUYz3p5CA7Urlpe3fnNjYcu1EM\",\n"
+ + " \"resultXdr\": \"AAAAAAABNCwAAAAAAAAAAQAAAAAAAAAYAAAAAJhEDjNV0Jj46jrxCj87qJ6JaYKJN4c+p5tvapkLwrn8AAAAAA==\",\n"
+ + " \"resultMetaXdr\": \"AAAAAwAAAAAAAAACAAAAAwABNbYAAAAAAAAAANNgojN9rS5sqnuqM5wX5k7yyNC63OjWIe4OHx6yL2r7AAAAF0h1s9QAATW1AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAQABNbYAAAAAAAAAANNgojN9rS5sqnuqM5wX5k7yyNC63OjWIe4OHx6yL2r7AAAAF0h1s9QAATW1AAAAAQAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAMAAAAAAAE1tgAAAABkwUMZAAAAAAAAAAEAAAAAAAAAAgAAAAMAATW2AAAAAAAAAADTYKIzfa0ubKp7qjOcF+ZO8sjQutzo1iHuDh8esi9q+wAAABdIdbPUAAE1tQAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAABNbYAAAAAZMFDGQAAAAAAAAABAAE1tgAAAAAAAAAA02CiM32tLmyqe6oznBfmTvLI0Lrc6NYh7g4fHrIvavsAAAAXSHWz/AABNbUAAAABAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAATW2AAAAAGTBQxkAAAAAAAAAAQAAAAAAAAAAAAAADgAAAAZUb2tlbkEAAAAAAAIAAAABAAAAAAAAAAAAAAACAAAAAAAAAAMAAAAPAAAAB2ZuX2NhbGwAAAAADQAAACC9x/ldchaDQwaY3uK3IcXmke/4UTUtggE9g4egPM+sawAAAA8AAAAEbmFtZQAAAAEAAAABAAAAAAAAAAG9x/ldchaDQwaY3uK3IcXmke/4UTUtggE9g4egPM+sawAAAAIAAAAAAAAAAgAAAA8AAAAJZm5fcmV0dXJuAAAAAAAADwAAAARuYW1lAAAADgAAAAZUb2tlbkEAAA==\",\n"
+ + " \"ledger\": \"79286\",\n"
+ + " \"createdAt\": \"1690387225\"\n"
+ + " }\n"
+ + "}";
+}
diff --git a/src/test/java/org/stellar/sdk/responses/sorobanrpc/SendTransactionDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/sorobanrpc/SendTransactionDeserializerTest.java
new file mode 100644
index 000000000..decdeed5d
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/responses/sorobanrpc/SendTransactionDeserializerTest.java
@@ -0,0 +1,123 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import com.google.gson.reflect.TypeToken;
+import org.junit.Test;
+import org.stellar.sdk.responses.GsonSingleton;
+
+public class SendTransactionDeserializerTest {
+ @Test
+ public void testDeserializeError() {
+ SorobanRpcResponse getTransactionResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ jsonError,
+ new TypeToken>() {}.getType());
+ SendTransactionResponse data = getTransactionResponse.getResult();
+ assertEquals(data.getErrorResultXdr(), "AAAAAAAAf67////6AAAAAA==");
+ assertEquals(data.getStatus(), SendTransactionResponse.SendTransactionStatus.ERROR);
+ assertEquals(
+ data.getHash(), "3b0c982bb8245be869d34ec822f999deb68f3a8480cf6e663643cf2f6e397e64");
+ assertEquals(data.getLatestLedger().longValue(), 62L);
+ assertEquals(data.getLatestLedgerCloseTime().longValue(), 1690447331L);
+ }
+
+ @Test
+ public void testDeserializePending() {
+ SorobanRpcResponse getTransactionResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ jsonPending,
+ new TypeToken>() {}.getType());
+ SendTransactionResponse data = getTransactionResponse.getResult();
+ assertNull(data.getErrorResultXdr());
+ assertEquals(data.getStatus(), SendTransactionResponse.SendTransactionStatus.PENDING);
+ assertEquals(
+ data.getHash(), "5e58bb3530cf4ff852805ad1a5077b181b227e541301bdfa17f5a66991910d13");
+ assertEquals(data.getLatestLedger().longValue(), 3449L);
+ assertEquals(data.getLatestLedgerCloseTime().longValue(), 1690444223L);
+ }
+
+ @Test
+ public void testDeserializeDuplicate() {
+ SorobanRpcResponse getTransactionResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ jsonDuplicate,
+ new TypeToken>() {}.getType());
+ SendTransactionResponse data = getTransactionResponse.getResult();
+ assertNull(data.getErrorResultXdr());
+ assertEquals(data.getStatus(), SendTransactionResponse.SendTransactionStatus.DUPLICATE);
+ assertEquals(
+ data.getHash(), "5e58bb3530cf4ff852805ad1a5077b181b227e541301bdfa17f5a66991910d13");
+ assertEquals(data.getLatestLedger().longValue(), 3449L);
+ assertEquals(data.getLatestLedgerCloseTime().longValue(), 1690444223L);
+ }
+
+ @Test
+ public void testDeserializeTryAgainLater() {
+ SorobanRpcResponse getTransactionResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ jsonTryAgainLater,
+ new TypeToken>() {}.getType());
+ SendTransactionResponse data = getTransactionResponse.getResult();
+ assertNull(data.getErrorResultXdr());
+ assertEquals(data.getStatus(), SendTransactionResponse.SendTransactionStatus.TRY_AGAIN_LATER);
+ assertEquals(
+ data.getHash(), "5e58bb3530cf4ff852805ad1a5077b181b227e541301bdfa17f5a66991910d13");
+ assertEquals(data.getLatestLedger().longValue(), 3449L);
+ assertEquals(data.getLatestLedgerCloseTime().longValue(), 1690444223L);
+ }
+
+ String jsonError =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"b96311af98d54d7cbb8736dbb0ed7730\",\n"
+ + " \"result\": {\n"
+ + " \"errorResultXdr\": \"AAAAAAAAf67////6AAAAAA==\",\n"
+ + " \"status\": \"ERROR\",\n"
+ + " \"hash\": \"3b0c982bb8245be869d34ec822f999deb68f3a8480cf6e663643cf2f6e397e64\",\n"
+ + " \"latestLedger\": \"62\",\n"
+ + " \"latestLedgerCloseTime\": \"1690447331\"\n"
+ + " }\n"
+ + "}";
+
+ String jsonPending =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"ce651a0633e8407e9f377127bd649476\",\n"
+ + " \"result\": {\n"
+ + " \"status\": \"PENDING\",\n"
+ + " \"hash\": \"5e58bb3530cf4ff852805ad1a5077b181b227e541301bdfa17f5a66991910d13\",\n"
+ + " \"latestLedger\": \"3449\",\n"
+ + " \"latestLedgerCloseTime\": \"1690444223\"\n"
+ + " }\n"
+ + "}";
+
+ String jsonDuplicate =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"ce651a0633e8407e9f377127bd649476\",\n"
+ + " \"result\": {\n"
+ + " \"status\": \"DUPLICATE\",\n"
+ + " \"hash\": \"5e58bb3530cf4ff852805ad1a5077b181b227e541301bdfa17f5a66991910d13\",\n"
+ + " \"latestLedger\": \"3449\",\n"
+ + " \"latestLedgerCloseTime\": \"1690444223\"\n"
+ + " }\n"
+ + "}";
+
+ String jsonTryAgainLater =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"ce651a0633e8407e9f377127bd649476\",\n"
+ + " \"result\": {\n"
+ + " \"status\": \"TRY_AGAIN_LATER\",\n"
+ + " \"hash\": \"5e58bb3530cf4ff852805ad1a5077b181b227e541301bdfa17f5a66991910d13\",\n"
+ + " \"latestLedger\": \"3449\",\n"
+ + " \"latestLedgerCloseTime\": \"1690444223\"\n"
+ + " }\n"
+ + "}";
+}
diff --git a/src/test/java/org/stellar/sdk/responses/sorobanrpc/SimulateTransactionDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/sorobanrpc/SimulateTransactionDeserializerTest.java
new file mode 100644
index 000000000..2da5249e1
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/responses/sorobanrpc/SimulateTransactionDeserializerTest.java
@@ -0,0 +1,104 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import com.google.gson.reflect.TypeToken;
+import org.junit.Test;
+import org.stellar.sdk.responses.GsonSingleton;
+
+public class SimulateTransactionDeserializerTest {
+ @Test
+ public void testDeserializeSuccess() {
+ SorobanRpcResponse simulateTransactionResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ jsonSuccess,
+ new TypeToken>() {}.getType());
+ SimulateTransactionResponse data = simulateTransactionResponse.getResult();
+ assertEquals(
+ data.getTransactionData(),
+ "AAAAAAAAAAMAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAABgAAAAHFiyv7xPBU5zJPa/IMrT4CbkG7rRptIMPX1JGN7RZUEQAAABQAAAABAAAAAAAAAAd9NB8oNB2RvkInt877MS77oKzbRandwCJ7VsvW4NmL2QAAAAAAAAACAAAABgAAAAAAAAAAWLfEosjyl6qPPSRxKB/fzOyv5I5WYzE+wY4Spz7KmKEAAAAVWqB4d0kcwg0AAAAAAAAAAAAAAAYAAAABxYsr+8TwVOcyT2vyDK0+Am5Bu60abSDD19SRje0WVBEAAAAQAAAAAQAAAAIAAAAPAAAAB0NvdW50ZXIAAAAAEgAAAAAAAAAAWLfEosjyl6qPPSRxKB/fzOyv5I5WYzE+wY4Spz7KmKEAAAABAAAAAAAWW9sAAAYkAAABnAAAA2AAAAAAAAAAqQ==");
+ assertEquals(data.getEvents().size(), 2);
+ assertEquals(
+ data.getEvents().get(0),
+ "AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAgxYsr+8TwVOcyT2vyDK0+Am5Bu60abSDD19SRje0WVBEAAAAPAAAACWluY3JlbWVudAAAAAAAABAAAAABAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAo=");
+ assertEquals(
+ data.getEvents().get(1),
+ "AAAAAQAAAAAAAAABxYsr+8TwVOcyT2vyDK0+Am5Bu60abSDD19SRje0WVBEAAAACAAAAAAAAAAIAAAAPAAAACWZuX3JldHVybgAAAAAAAA8AAAAJaW5jcmVtZW50AAAAAAAAAwAAAAo=");
+ assertEquals(data.getMinResourceFee().longValue(), 94876L);
+ assertEquals(data.getResults().size(), 1);
+ assertEquals(data.getResults().get(0).getAuth().size(), 1);
+ assertEquals(
+ data.getResults().get(0).getAuth().get(0),
+ "AAAAAQAAAAAAAAAAWLfEosjyl6qPPSRxKB/fzOyv5I5WYzE+wY4Spz7KmKFaoHh3SRzCDQAAAAAAAAAAAAAAAAAAAAHFiyv7xPBU5zJPa/IMrT4CbkG7rRptIMPX1JGN7RZUEQAAAAlpbmNyZW1lbnQAAAAAAAACAAAAEgAAAAAAAAAAWLfEosjyl6qPPSRxKB/fzOyv5I5WYzE+wY4Spz7KmKEAAAADAAAACgAAAAA=");
+ assertEquals(data.getResults().get(0).getXdr(), "AAAAAwAAAAo=");
+ assertEquals(data.getCost().getCpuInstructions().longValue(), 1274180L);
+ assertEquals(data.getCost().getMemoryBytes().longValue(), 162857L);
+ assertEquals(data.getLatestLedger().longValue(), 694L);
+ assertNull(data.getError());
+ }
+
+ @Test
+ public void testDeserializeFailed() {
+ SorobanRpcResponse simulateTransactionResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ jsonFailed,
+ new TypeToken>() {}.getType());
+ SimulateTransactionResponse data = simulateTransactionResponse.getResult();
+ assertEquals(
+ data.getError(),
+ "HostError: Error(WasmVm, MissingValue)\n\nEvent log (newest first):\n 0: [Diagnostic Event] contract:607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0, topics:[error, Error(WasmVm, MissingValue)], data:[\"invoking unknown export\", increment]\n 1: [Diagnostic Event] topics:[fn_call, Bytes(607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0), increment], data:[Address(Account(58b7c4a2c8f297aa8f3d2471281fdfccecafe48e5663313ec18e12a73eca98a1)), 10]\n\nBacktrace (newest first):\n 0: soroban_env_host::vm::Vm::invoke_function_raw\n 1: soroban_env_host::host::frame::::call_n_internal\n 2: soroban_env_host::host::frame::::invoke_function\n 3: preflight::preflight_invoke_hf_op::{{closure}}\n 4: preflight::catch_preflight_panic\n 5: _cgo_a3255893d7fd_Cfunc_preflight_invoke_hf_op\n at /tmp/go-build/cgo-gcc-prolog:99:11\n 6: runtime.asmcgocall\n at ./runtime/asm_amd64.s:848\n\n");
+ assertEquals(data.getTransactionData(), "");
+ assertNull(data.getEvents());
+ assertEquals(data.getMinResourceFee().longValue(), 0L);
+ assertEquals(data.getCost().getCpuInstructions().longValue(), 0L);
+ assertEquals(data.getCost().getMemoryBytes().longValue(), 0L);
+ assertEquals(data.getLatestLedger().longValue(), 898L);
+ }
+
+ String jsonSuccess =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"4a69486e5a83404bbf9772f3f02c21e5\",\n"
+ + " \"result\": {\n"
+ + " \"transactionData\": \"AAAAAAAAAAMAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAABgAAAAHFiyv7xPBU5zJPa/IMrT4CbkG7rRptIMPX1JGN7RZUEQAAABQAAAABAAAAAAAAAAd9NB8oNB2RvkInt877MS77oKzbRandwCJ7VsvW4NmL2QAAAAAAAAACAAAABgAAAAAAAAAAWLfEosjyl6qPPSRxKB/fzOyv5I5WYzE+wY4Spz7KmKEAAAAVWqB4d0kcwg0AAAAAAAAAAAAAAAYAAAABxYsr+8TwVOcyT2vyDK0+Am5Bu60abSDD19SRje0WVBEAAAAQAAAAAQAAAAIAAAAPAAAAB0NvdW50ZXIAAAAAEgAAAAAAAAAAWLfEosjyl6qPPSRxKB/fzOyv5I5WYzE+wY4Spz7KmKEAAAABAAAAAAAWW9sAAAYkAAABnAAAA2AAAAAAAAAAqQ==\",\n"
+ + " \"events\": [\n"
+ + " \"AAAAAQAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAgxYsr+8TwVOcyT2vyDK0+Am5Bu60abSDD19SRje0WVBEAAAAPAAAACWluY3JlbWVudAAAAAAAABAAAAABAAAAAgAAABIAAAAAAAAAAFi3xKLI8peqjz0kcSgf38zsr+SOVmMxPsGOEqc+ypihAAAAAwAAAAo=\",\n"
+ + " \"AAAAAQAAAAAAAAABxYsr+8TwVOcyT2vyDK0+Am5Bu60abSDD19SRje0WVBEAAAACAAAAAAAAAAIAAAAPAAAACWZuX3JldHVybgAAAAAAAA8AAAAJaW5jcmVtZW50AAAAAAAAAwAAAAo=\"\n"
+ + " ],\n"
+ + " \"minResourceFee\": \"94876\",\n"
+ + " \"results\": [\n"
+ + " {\n"
+ + " \"auth\": [\n"
+ + " \"AAAAAQAAAAAAAAAAWLfEosjyl6qPPSRxKB/fzOyv5I5WYzE+wY4Spz7KmKFaoHh3SRzCDQAAAAAAAAAAAAAAAAAAAAHFiyv7xPBU5zJPa/IMrT4CbkG7rRptIMPX1JGN7RZUEQAAAAlpbmNyZW1lbnQAAAAAAAACAAAAEgAAAAAAAAAAWLfEosjyl6qPPSRxKB/fzOyv5I5WYzE+wY4Spz7KmKEAAAADAAAACgAAAAA=\"\n"
+ + " ],\n"
+ + " \"xdr\": \"AAAAAwAAAAo=\"\n"
+ + " }\n"
+ + " ],\n"
+ + " \"cost\": {\n"
+ + " \"cpuInsns\": \"1274180\",\n"
+ + " \"memBytes\": \"162857\"\n"
+ + " },\n"
+ + " \"latestLedger\": \"694\"\n"
+ + " }\n"
+ + "}";
+
+ String jsonFailed =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"7b6ada2bdec04ee28147d1557aadc3cf\",\n"
+ + " \"result\": {\n"
+ + " \"error\": \"HostError: Error(WasmVm, MissingValue)\\n\\nEvent log (newest first):\\n 0: [Diagnostic Event] contract:607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0, topics:[error, Error(WasmVm, MissingValue)], data:[\\\"invoking unknown export\\\", increment]\\n 1: [Diagnostic Event] topics:[fn_call, Bytes(607682f2477a6be8cdf0fdf32be13d5f25a686cc094fd93d5aa3d7b68232d0c0), increment], data:[Address(Account(58b7c4a2c8f297aa8f3d2471281fdfccecafe48e5663313ec18e12a73eca98a1)), 10]\\n\\nBacktrace (newest first):\\n 0: soroban_env_host::vm::Vm::invoke_function_raw\\n 1: soroban_env_host::host::frame::::call_n_internal\\n 2: soroban_env_host::host::frame::::invoke_function\\n 3: preflight::preflight_invoke_hf_op::{{closure}}\\n 4: preflight::catch_preflight_panic\\n 5: _cgo_a3255893d7fd_Cfunc_preflight_invoke_hf_op\\n at /tmp/go-build/cgo-gcc-prolog:99:11\\n 6: runtime.asmcgocall\\n at ./runtime/asm_amd64.s:848\\n\\n\",\n"
+ + " \"transactionData\": \"\",\n"
+ + " \"events\": null,\n"
+ + " \"minResourceFee\": \"0\",\n"
+ + " \"cost\": {\n"
+ + " \"cpuInsns\": \"0\",\n"
+ + " \"memBytes\": \"0\"\n"
+ + " },\n"
+ + " \"latestLedger\": \"898\"\n"
+ + " }\n"
+ + "}";
+}
diff --git a/src/test/java/org/stellar/sdk/responses/sorobanrpc/SorobanRpcDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/sorobanrpc/SorobanRpcDeserializerTest.java
new file mode 100644
index 000000000..cd85ec4b0
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/responses/sorobanrpc/SorobanRpcDeserializerTest.java
@@ -0,0 +1,56 @@
+package org.stellar.sdk.responses.sorobanrpc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import com.google.gson.reflect.TypeToken;
+import org.junit.Test;
+import org.stellar.sdk.responses.GsonSingleton;
+
+public class SorobanRpcDeserializerTest {
+ @Test
+ public void testDeserializeSuccess() {
+ SorobanRpcResponse sorobanRpcResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ jsonSuccess, new TypeToken>() {}.getType());
+ assertEquals(sorobanRpcResponse.getJsonRpc(), "2.0");
+ assertEquals(sorobanRpcResponse.getId(), "198cb1a8-9104-4446-a269-88bf000c2721");
+ assertNotNull(sorobanRpcResponse.getResult());
+ assertNull(sorobanRpcResponse.getError());
+ }
+
+ @Test
+ public void testDeserializeError() {
+ SorobanRpcResponse sorobanRpcResponse =
+ GsonSingleton.getInstance()
+ .fromJson(
+ jsonError, new TypeToken>() {}.getType());
+ assertEquals(sorobanRpcResponse.getJsonRpc(), "2.0");
+ assertEquals(sorobanRpcResponse.getId(), "e860b82a-1738-4646-a999-b97ea3e117eb");
+ assertNull(sorobanRpcResponse.getResult());
+ assertNotNull(sorobanRpcResponse.getError());
+ assertEquals(sorobanRpcResponse.getError().getCode().longValue(), -32602);
+ assertEquals(sorobanRpcResponse.getError().getMessage(), "startLedger must be positive");
+ }
+
+ String jsonSuccess =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"198cb1a8-9104-4446-a269-88bf000c2721\",\n"
+ + " \"result\": {\n"
+ + " \"status\": \"healthy\"\n"
+ + " }\n"
+ + "}";
+
+ String jsonError =
+ "{\n"
+ + " \"jsonrpc\": \"2.0\",\n"
+ + " \"id\": \"e860b82a-1738-4646-a999-b97ea3e117eb\",\n"
+ + " \"error\": {\n"
+ + " \"code\": -32602,\n"
+ + " \"message\": \"startLedger must be positive\"\n"
+ + " }\n"
+ + "}";
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvAddressTest.java b/src/test/java/org/stellar/sdk/scval/ScvAddressTest.java
new file mode 100644
index 000000000..4b1ab6f21
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvAddressTest.java
@@ -0,0 +1,42 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.stellar.sdk.Address;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+public class ScvAddressTest {
+ @Test
+ public void testScvAddressFromAddress() {
+ String publicKey = "GAHJJJKMOKYE4RVPZEWZTKH5FVI4PA3VL7GK2LFNUBSGBV6OJP7TQSLX";
+ Address address = new Address(publicKey);
+
+ SCVal expectedScVal =
+ new SCVal.Builder()
+ .discriminant(SCValType.SCV_ADDRESS)
+ .address(address.toSCAddress())
+ .build();
+
+ SCVal actualScVal = Scv.toAddress(address);
+ assertEquals(expectedScVal, actualScVal);
+ assertEquals(address, Scv.fromAddress(actualScVal));
+ }
+
+ @Test
+ public void testScvAddressFromKeyString() {
+ String publicKey = "GAHJJJKMOKYE4RVPZEWZTKH5FVI4PA3VL7GK2LFNUBSGBV6OJP7TQSLX";
+ Address address = new Address(publicKey);
+
+ SCVal expectedScVal =
+ new SCVal.Builder()
+ .discriminant(SCValType.SCV_ADDRESS)
+ .address(address.toSCAddress())
+ .build();
+
+ SCVal actualScVal = Scv.toAddress(publicKey);
+ assertEquals(expectedScVal, actualScVal);
+ assertEquals(address, Scv.fromAddress(actualScVal));
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvBooleanTest.java b/src/test/java/org/stellar/sdk/scval/ScvBooleanTest.java
new file mode 100644
index 000000000..48bc693f0
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvBooleanTest.java
@@ -0,0 +1,18 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+public class ScvBooleanTest {
+ @Test
+ public void testScvBoolean() {
+ boolean value = true;
+ SCVal expectedScVal = new SCVal.Builder().discriminant(SCValType.SCV_BOOL).b(value).build();
+ SCVal actualScVal = Scv.toBoolean(value);
+ assertEquals(expectedScVal, actualScVal);
+ assertEquals(value, Scv.fromBoolean(actualScVal));
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvBytesTest.java b/src/test/java/org/stellar/sdk/scval/ScvBytesTest.java
new file mode 100644
index 000000000..7a1c6ce9d
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvBytesTest.java
@@ -0,0 +1,22 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.stellar.sdk.xdr.SCBytes;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+public class ScvBytesTest {
+ @Test
+ public void testScvBytes() {
+ byte[] data = new byte[] {0x01, 0x02, 0x03};
+
+ SCVal expectedScVal =
+ new SCVal.Builder().discriminant(SCValType.SCV_BYTES).bytes(new SCBytes(data)).build();
+
+ SCVal actualScVal = Scv.toBytes(data);
+ assertEquals(expectedScVal, actualScVal);
+ assertEquals(data, Scv.fromBytes(actualScVal));
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvContractInstanceTest.java b/src/test/java/org/stellar/sdk/scval/ScvContractInstanceTest.java
new file mode 100644
index 000000000..94b30b302
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvContractInstanceTest.java
@@ -0,0 +1,30 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.stellar.sdk.xdr.ContractExecutable;
+import org.stellar.sdk.xdr.ContractExecutableType;
+import org.stellar.sdk.xdr.SCContractInstance;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+public class ScvContractInstanceTest {
+ @Test
+ public void testScvContractInstance() {
+ SCContractInstance value =
+ new SCContractInstance.Builder()
+ .executable(
+ new ContractExecutable.Builder()
+ .discriminant(ContractExecutableType.CONTRACT_EXECUTABLE_TOKEN)
+ .build())
+ .build();
+
+ SCVal expectedScVal =
+ new SCVal.Builder().discriminant(SCValType.SCV_CONTRACT_INSTANCE).instance(value).build();
+
+ SCVal actualScVal = Scv.toContractInstance(value);
+ assertEquals(expectedScVal, actualScVal);
+ assertEquals(value, Scv.fromContractInstance(actualScVal));
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvDurationTest.java b/src/test/java/org/stellar/sdk/scval/ScvDurationTest.java
new file mode 100644
index 000000000..558ce8a69
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvDurationTest.java
@@ -0,0 +1,55 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertEquals;
+
+import java.math.BigInteger;
+import org.junit.Test;
+import org.stellar.sdk.xdr.Duration;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+import org.stellar.sdk.xdr.Uint64;
+import org.stellar.sdk.xdr.XdrUnsignedHyperInteger;
+
+public class ScvDurationTest {
+ @Test
+ public void testScvDurationMax() {
+ BigInteger value = XdrUnsignedHyperInteger.MAX_VALUE;
+
+ SCVal expectedScVal =
+ new SCVal.Builder()
+ .discriminant(SCValType.SCV_DURATION)
+ .duration(new Duration(new Uint64(new XdrUnsignedHyperInteger(value))))
+ .build();
+
+ SCVal actualScVal = Scv.toDuration(value);
+ assertEquals(expectedScVal, actualScVal);
+ assertEquals(value, Scv.fromDuration(actualScVal));
+ }
+
+ @Test
+ public void testScvDurationMin() {
+ BigInteger value = XdrUnsignedHyperInteger.MIN_VALUE;
+
+ SCVal expectedScVal =
+ new SCVal.Builder()
+ .discriminant(SCValType.SCV_DURATION)
+ .duration(new Duration(new Uint64(new XdrUnsignedHyperInteger(value))))
+ .build();
+
+ SCVal actualScVal = Scv.toDuration(value);
+ assertEquals(expectedScVal, actualScVal);
+ assertEquals(value, Scv.fromDuration(actualScVal));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testScvDurationMoreThanMaxThrows() {
+ BigInteger value = XdrUnsignedHyperInteger.MAX_VALUE.add(BigInteger.ONE);
+ ScvDuration.toSCVal(value);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testScvDurationLessThanMinThrows() {
+ BigInteger value = XdrUnsignedHyperInteger.MIN_VALUE.subtract(BigInteger.ONE);
+ ScvDuration.toSCVal(value);
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvErrorTest.java b/src/test/java/org/stellar/sdk/scval/ScvErrorTest.java
new file mode 100644
index 000000000..1dc073cb7
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvErrorTest.java
@@ -0,0 +1,26 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.stellar.sdk.xdr.SCError;
+import org.stellar.sdk.xdr.SCErrorCode;
+import org.stellar.sdk.xdr.SCErrorType;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+public class ScvErrorTest {
+ @Test
+ public void testScvError() {
+ SCErrorType errorType = SCErrorType.SCE_CONTEXT;
+ SCErrorCode errorCode = SCErrorCode.SCEC_UNEXPECTED_TYPE;
+ SCError scError = new SCError.Builder().code(errorCode).discriminant(errorType).build();
+
+ SCVal expectedScVal =
+ new SCVal.Builder().discriminant(SCValType.SCV_ERROR).error(scError).build();
+
+ SCVal actualScVal = Scv.toError(scError);
+ assertEquals(expectedScVal, actualScVal);
+ assertEquals(scError, Scv.fromError(actualScVal));
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvInt128Test.java b/src/test/java/org/stellar/sdk/scval/ScvInt128Test.java
new file mode 100644
index 000000000..d05507d9b
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvInt128Test.java
@@ -0,0 +1,124 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Value;
+import org.junit.Test;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+public class ScvInt128Test {
+ private static final BigInteger MIN_VALUE = BigInteger.valueOf(-2).pow(127);
+ private static final BigInteger MAX_VALUE =
+ BigInteger.valueOf(2).pow(127).subtract(BigInteger.ONE);
+
+ @Test
+ public void testScvInt128() throws IOException {
+ List values =
+ Arrays.asList(
+ new TestCase(
+ BigInteger.ZERO, new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}),
+ new TestCase(
+ BigInteger.valueOf(1), new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}),
+ new TestCase(
+ BigInteger.valueOf(-1),
+ new byte[] {
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff
+ }),
+ new TestCase(
+ BigInteger.valueOf(2L).pow(64),
+ new byte[] {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}),
+ new TestCase(
+ BigInteger.valueOf(2L).pow(64).negate(),
+ new byte[] {
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+ }),
+ new TestCase(
+ MAX_VALUE,
+ new byte[] {
+ (byte) 0x7f,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff
+ }),
+ new TestCase(
+ MIN_VALUE, new byte[] {(byte) 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}));
+
+ for (TestCase value : values) {
+ checkScvInt128(value);
+ }
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testScvInt128GreaterThanMaxValueThrows() {
+ Scv.toInt128(MAX_VALUE.add(BigInteger.ONE));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testScvInt128LessThanMinValueThrows() {
+ Scv.toInt128(MIN_VALUE.subtract(BigInteger.ONE));
+ }
+
+ private void checkScvInt128(TestCase value) throws IOException {
+
+ SCVal scVal = Scv.toInt128(value.v);
+ assertEquals(scVal.getDiscriminant(), SCValType.SCV_I128);
+ assertEquals(Scv.fromInt128(scVal), value.v);
+ assertArrayEquals(scVal.getI128().toXdrByteArray(), value.getExpectedBytes());
+ }
+
+ @Value
+ @AllArgsConstructor
+ private static class TestCase {
+ BigInteger v;
+ byte[] expectedBytes;
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvInt256Test.java b/src/test/java/org/stellar/sdk/scval/ScvInt256Test.java
new file mode 100644
index 000000000..ebd75704b
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvInt256Test.java
@@ -0,0 +1,307 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Value;
+import org.junit.Test;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+public class ScvInt256Test {
+ private static final BigInteger MIN_VALUE = BigInteger.valueOf(-2).pow(255);
+ private static final BigInteger MAX_VALUE =
+ BigInteger.valueOf(2).pow(255).subtract(BigInteger.ONE);
+
+ @Test
+ public void testScvInt256() throws IOException {
+ List values =
+ Arrays.asList(
+ new TestCase(BigInteger.ZERO, new byte[32]),
+ new TestCase(
+ BigInteger.valueOf(1),
+ new byte[] {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1
+ }),
+ new TestCase(
+ BigInteger.valueOf(-1),
+ new byte[] {
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff
+ }),
+ new TestCase(
+ BigInteger.valueOf(2L).pow(64),
+ new byte[] {
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1,
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0
+ }),
+ new TestCase(
+ BigInteger.valueOf(2L).pow(64).negate(),
+ new byte[] {
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0
+ }),
+ new TestCase(
+ BigInteger.valueOf(2L).pow(128),
+ new byte[] {
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0
+ }),
+ new TestCase(
+ BigInteger.valueOf(2L).pow(128).negate(),
+ new byte[] {
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0
+ }),
+ new TestCase(
+ BigInteger.valueOf(2L).pow(192),
+ new byte[] {
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x1, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
+ (byte) 0x0, (byte) 0x0
+ }),
+ new TestCase(
+ BigInteger.valueOf(2L).pow(192).negate(),
+ new byte[] {
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0,
+ (byte) 0x0
+ }),
+ new TestCase(
+ MAX_VALUE,
+ new byte[] {
+ (byte) 0x7f,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ (byte) 0xff,
+ }),
+ new TestCase(
+ MIN_VALUE,
+ new byte[] {
+ (byte) 0x80,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+ }));
+
+ for (TestCase value : values) {
+ checkScvInt256(value);
+ }
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testScvInt256GreaterThanMaxValueThrows() {
+ Scv.toInt256(MAX_VALUE.add(BigInteger.ONE));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testScvInt256LessThanMinValueThrows() {
+ Scv.toInt256(MIN_VALUE.subtract(BigInteger.ONE));
+ }
+
+ private void checkScvInt256(TestCase value) throws IOException {
+ SCVal scVal = Scv.toInt256(value.v);
+ assertEquals(scVal.getDiscriminant(), SCValType.SCV_I256);
+ assertEquals(Scv.fromInt256(scVal), value.v);
+ assertArrayEquals(scVal.getI256().toXdrByteArray(), value.getExpectedBytes());
+ }
+
+ @Value
+ @AllArgsConstructor
+ private static class TestCase {
+ BigInteger v;
+ byte[] expectedBytes;
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvInt32Test.java b/src/test/java/org/stellar/sdk/scval/ScvInt32Test.java
new file mode 100644
index 000000000..aa53ce9ad
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvInt32Test.java
@@ -0,0 +1,22 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.stellar.sdk.xdr.Int32;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+public class ScvInt32Test {
+ @Test
+ public void testScvInt32() {
+ int value = -234;
+
+ SCVal expectedScVal =
+ new SCVal.Builder().discriminant(SCValType.SCV_I32).i32(new Int32(value)).build();
+
+ SCVal actualScVal = Scv.toInt32(value);
+ assertEquals(expectedScVal, actualScVal);
+ assertEquals(value, Scv.fromInt32(actualScVal));
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvInt64Test.java b/src/test/java/org/stellar/sdk/scval/ScvInt64Test.java
new file mode 100644
index 000000000..50f40d996
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvInt64Test.java
@@ -0,0 +1,22 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+public class ScvInt64Test {
+ @Test
+ public void testScvInt64() {
+ long value = 23453454L;
+
+ SCVal expectedScVal =
+ new SCVal.Builder().discriminant(SCValType.SCV_I64).i64(new Int64(value)).build();
+
+ SCVal actualScVal = Scv.toInt64(value);
+ assertEquals(expectedScVal, actualScVal);
+ assertEquals(value, Scv.fromInt64(actualScVal));
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvLedgerKeyContractInstanceTest.java b/src/test/java/org/stellar/sdk/scval/ScvLedgerKeyContractInstanceTest.java
new file mode 100644
index 000000000..08069da56
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvLedgerKeyContractInstanceTest.java
@@ -0,0 +1,19 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+public class ScvLedgerKeyContractInstanceTest {
+ @Test
+ public void testScvLedgerKeyContractInstance() {
+ SCVal expectedScVal =
+ new SCVal.Builder().discriminant(SCValType.SCV_LEDGER_KEY_CONTRACT_INSTANCE).build();
+
+ SCVal actualScVal = Scv.toLedgerKeyContractInstance();
+ assertEquals(expectedScVal, actualScVal);
+ Scv.fromLedgerKeyContractInstance(actualScVal);
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvLedgerKeyNonceTest.java b/src/test/java/org/stellar/sdk/scval/ScvLedgerKeyNonceTest.java
new file mode 100644
index 000000000..a9d07f9fd
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvLedgerKeyNonceTest.java
@@ -0,0 +1,25 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.SCNonceKey;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+public class ScvLedgerKeyNonceTest {
+ @Test
+ public void testScvLedgerKeyNonce() {
+ long value = 123456L;
+
+ SCVal expectedScVal =
+ new SCVal.Builder()
+ .discriminant(SCValType.SCV_LEDGER_KEY_NONCE)
+ .nonce_key(new SCNonceKey.Builder().nonce(new Int64(value)).build())
+ .build();
+
+ SCVal actualScVal = Scv.toLedgerKeyNonce(value);
+ assertEquals(expectedScVal, actualScVal);
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/scval/ScvMapTest.java b/src/test/java/org/stellar/sdk/scval/ScvMapTest.java
new file mode 100644
index 000000000..72d7f9adc
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/scval/ScvMapTest.java
@@ -0,0 +1,40 @@
+package org.stellar.sdk.scval;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.LinkedHashMap;
+import org.junit.Test;
+import org.stellar.sdk.xdr.SCMap;
+import org.stellar.sdk.xdr.SCMapEntry;
+import org.stellar.sdk.xdr.SCVal;
+import org.stellar.sdk.xdr.SCValType;
+
+public class ScvMapTest {
+ @Test
+ public void testScvMap() {
+ LinkedHashMap