Skip to content

Commit

Permalink
chore: upgrade generated XDR definitions to Protocol 22
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat committed Sep 28, 2024
1 parent 72fad65 commit 050aa08
Show file tree
Hide file tree
Showing 52 changed files with 2,879 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ xdr/Stellar-contract-config-setting.x
# xdrgen commit to use, see https://github.com/stellar/xdrgen
XDRGEN_COMMIT=6d4d47b4bc6815e26a52d62fd6613cfb56676d4b
# stellar-xdr commit to use, see https://github.com/stellar/stellar-xdr
XDRNEXT_COMMIT=1a04392432dacc0092caaeae22a600ea1af3c6a5
XDR_COMMIT=529d5176f24c73eeccfa5eba481d4e89c19b1181

.PHONY: xdr xdr-clean xdr-update

Expand All @@ -31,7 +31,7 @@ xdr-generate: $(XDRS)
./gradlew :spotlessApply

xdr/%.x:
curl -Lsf -o $@ https://raw.githubusercontent.com/stellar/stellar-xdr/$(XDRNEXT_COMMIT)/$(@F)
curl -Lsf -o $@ https://raw.githubusercontent.com/stellar/stellar-xdr/$(XDR_COMMIT)/$(@F)

xdr-clean:
rm xdr/*.x || true
Expand Down
123 changes: 123 additions & 0 deletions src/main/java/org/stellar/sdk/xdr/ArchivalProof.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten

package org.stellar.sdk.xdr;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.stellar.sdk.Base64Factory;

/**
* ArchivalProof's original definition in the XDR file is:
*
* <pre>
* struct ArchivalProof
* {
* uint32 epoch; // AST Subtree for this proof
*
* union switch (ArchivalProofType t)
* {
* case EXISTENCE:
* NonexistenceProofBody nonexistenceProof;
* case NONEXISTENCE:
* ExistenceProofBody existenceProof;
* } body;
* };
* </pre>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder(toBuilder = true)
public class ArchivalProof implements XdrElement {
private Uint32 epoch;
private ArchivalProofBody body;

public void encode(XdrDataOutputStream stream) throws IOException {
epoch.encode(stream);
body.encode(stream);
}

public static ArchivalProof decode(XdrDataInputStream stream) throws IOException {
ArchivalProof decodedArchivalProof = new ArchivalProof();
decodedArchivalProof.epoch = Uint32.decode(stream);
decodedArchivalProof.body = ArchivalProofBody.decode(stream);
return decodedArchivalProof;
}

public static ArchivalProof fromXdrBase64(String xdr) throws IOException {
byte[] bytes = Base64Factory.getInstance().decode(xdr);
return fromXdrByteArray(bytes);
}

public static ArchivalProof fromXdrByteArray(byte[] xdr) throws IOException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
return decode(xdrDataInputStream);
}

/**
* ArchivalProofBody's original definition in the XDR file is:
*
* <pre>
* union switch (ArchivalProofType t)
* {
* case EXISTENCE:
* NonexistenceProofBody nonexistenceProof;
* case NONEXISTENCE:
* ExistenceProofBody existenceProof;
* }
* </pre>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder(toBuilder = true)
public static class ArchivalProofBody implements XdrElement {
private ArchivalProofType discriminant;
private NonexistenceProofBody nonexistenceProof;
private ExistenceProofBody existenceProof;

public void encode(XdrDataOutputStream stream) throws IOException {
stream.writeInt(discriminant.getValue());
switch (discriminant) {
case EXISTENCE:
nonexistenceProof.encode(stream);
break;
case NONEXISTENCE:
existenceProof.encode(stream);
break;
}
}

public static ArchivalProofBody decode(XdrDataInputStream stream) throws IOException {
ArchivalProofBody decodedArchivalProofBody = new ArchivalProofBody();
ArchivalProofType discriminant = ArchivalProofType.decode(stream);
decodedArchivalProofBody.setDiscriminant(discriminant);
switch (decodedArchivalProofBody.getDiscriminant()) {
case EXISTENCE:
decodedArchivalProofBody.nonexistenceProof = NonexistenceProofBody.decode(stream);
break;
case NONEXISTENCE:
decodedArchivalProofBody.existenceProof = ExistenceProofBody.decode(stream);
break;
}
return decodedArchivalProofBody;
}

public static ArchivalProofBody fromXdrBase64(String xdr) throws IOException {
byte[] bytes = Base64Factory.getInstance().decode(xdr);
return fromXdrByteArray(bytes);
}

public static ArchivalProofBody fromXdrByteArray(byte[] xdr) throws IOException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
return decode(xdrDataInputStream);
}
}
}
55 changes: 55 additions & 0 deletions src/main/java/org/stellar/sdk/xdr/ArchivalProofNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten

package org.stellar.sdk.xdr;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.stellar.sdk.Base64Factory;

/**
* ArchivalProofNode's original definition in the XDR file is:
*
* <pre>
* struct ArchivalProofNode
* {
* uint32 index;
* Hash hash;
* };
* </pre>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder(toBuilder = true)
public class ArchivalProofNode implements XdrElement {
private Uint32 index;
private Hash hash;

public void encode(XdrDataOutputStream stream) throws IOException {
index.encode(stream);
hash.encode(stream);
}

public static ArchivalProofNode decode(XdrDataInputStream stream) throws IOException {
ArchivalProofNode decodedArchivalProofNode = new ArchivalProofNode();
decodedArchivalProofNode.index = Uint32.decode(stream);
decodedArchivalProofNode.hash = Hash.decode(stream);
return decodedArchivalProofNode;
}

public static ArchivalProofNode fromXdrBase64(String xdr) throws IOException {
byte[] bytes = Base64Factory.getInstance().decode(xdr);
return fromXdrByteArray(bytes);
}

public static ArchivalProofNode fromXdrByteArray(byte[] xdr) throws IOException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
return decode(xdrDataInputStream);
}
}
61 changes: 61 additions & 0 deletions src/main/java/org/stellar/sdk/xdr/ArchivalProofType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten

package org.stellar.sdk.xdr;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.stellar.sdk.Base64Factory;

/**
* ArchivalProofType's original definition in the XDR file is:
*
* <pre>
* enum ArchivalProofType
* {
* EXISTENCE = 0,
* NONEXISTENCE = 1
* };
* </pre>
*/
public enum ArchivalProofType implements XdrElement {
EXISTENCE(0),
NONEXISTENCE(1);

private final int value;

ArchivalProofType(int value) {
this.value = value;
}

public int getValue() {
return value;
}

public static ArchivalProofType decode(XdrDataInputStream stream) throws IOException {
int value = stream.readInt();
switch (value) {
case 0:
return EXISTENCE;
case 1:
return NONEXISTENCE;
default:
throw new IllegalArgumentException("Unknown enum value: " + value);
}
}

public void encode(XdrDataOutputStream stream) throws IOException {
stream.writeInt(value);
}

public static ArchivalProofType fromXdrBase64(String xdr) throws IOException {
byte[] bytes = Base64Factory.getInstance().decode(xdr);
return fromXdrByteArray(bytes);
}

public static ArchivalProofType fromXdrByteArray(byte[] xdr) throws IOException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
return decode(xdrDataInputStream);
}
}
65 changes: 65 additions & 0 deletions src/main/java/org/stellar/sdk/xdr/BinaryFuseFilterType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten

package org.stellar.sdk.xdr;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.stellar.sdk.Base64Factory;

/**
* BinaryFuseFilterType's original definition in the XDR file is:
*
* <pre>
* enum BinaryFuseFilterType
* {
* BINARY_FUSE_FILTER_8_BIT = 0,
* BINARY_FUSE_FILTER_16_BIT = 1,
* BINARY_FUSE_FILTER_32_BIT = 2
* };
* </pre>
*/
public enum BinaryFuseFilterType implements XdrElement {
BINARY_FUSE_FILTER_8_BIT(0),
BINARY_FUSE_FILTER_16_BIT(1),
BINARY_FUSE_FILTER_32_BIT(2);

private final int value;

BinaryFuseFilterType(int value) {
this.value = value;
}

public int getValue() {
return value;
}

public static BinaryFuseFilterType decode(XdrDataInputStream stream) throws IOException {
int value = stream.readInt();
switch (value) {
case 0:
return BINARY_FUSE_FILTER_8_BIT;
case 1:
return BINARY_FUSE_FILTER_16_BIT;
case 2:
return BINARY_FUSE_FILTER_32_BIT;
default:
throw new IllegalArgumentException("Unknown enum value: " + value);
}
}

public void encode(XdrDataOutputStream stream) throws IOException {
stream.writeInt(value);
}

public static BinaryFuseFilterType fromXdrBase64(String xdr) throws IOException {
byte[] bytes = Base64Factory.getInstance().decode(xdr);
return fromXdrByteArray(bytes);
}

public static BinaryFuseFilterType fromXdrByteArray(byte[] xdr) throws IOException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
return decode(xdrDataInputStream);
}
}
65 changes: 65 additions & 0 deletions src/main/java/org/stellar/sdk/xdr/BucketListType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten

package org.stellar.sdk.xdr;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import org.stellar.sdk.Base64Factory;

/**
* BucketListType's original definition in the XDR file is:
*
* <pre>
* enum BucketListType
* {
* LIVE = 0,
* HOT_ARCHIVE = 1,
* COLD_ARCHIVE = 2
* };
* </pre>
*/
public enum BucketListType implements XdrElement {
LIVE(0),
HOT_ARCHIVE(1),
COLD_ARCHIVE(2);

private final int value;

BucketListType(int value) {
this.value = value;
}

public int getValue() {
return value;
}

public static BucketListType decode(XdrDataInputStream stream) throws IOException {
int value = stream.readInt();
switch (value) {
case 0:
return LIVE;
case 1:
return HOT_ARCHIVE;
case 2:
return COLD_ARCHIVE;
default:
throw new IllegalArgumentException("Unknown enum value: " + value);
}
}

public void encode(XdrDataOutputStream stream) throws IOException {
stream.writeInt(value);
}

public static BucketListType fromXdrBase64(String xdr) throws IOException {
byte[] bytes = Base64Factory.getInstance().decode(xdr);
return fromXdrByteArray(bytes);
}

public static BucketListType fromXdrByteArray(byte[] xdr) throws IOException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
return decode(xdrDataInputStream);
}
}
Loading

0 comments on commit 050aa08

Please sign in to comment.