Skip to content

Commit

Permalink
Update and fix XDR
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekn committed Feb 25, 2016
1 parent 1194399 commit 0b404d9
Show file tree
Hide file tree
Showing 53 changed files with 915 additions and 154 deletions.
6 changes: 4 additions & 2 deletions src/main/java/org/stellar/sdk/xdr/AccountEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ public static void encode(XdrDataOutputStream stream, AccountEntryExt encodedAcc
}
}
public static AccountEntryExt decode(XdrDataInputStream stream) throws IOException {
AccountEntryExt decodedAccountEntryExt = new AccountEntryExt();
switch (decodedAccountEntryExt.getDiscriminant()) {
AccountEntryExt decodedAccountEntryExt = new AccountEntryExt();
Integer discriminant = stream.readInt();
decodedAccountEntryExt.setDiscriminant(discriminant);
switch (decodedAccountEntryExt.getDiscriminant()) {
case 0:
break;
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/stellar/sdk/xdr/AccountMergeResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ public static void encode(XdrDataOutputStream stream, AccountMergeResult encoded
}
}
public static AccountMergeResult decode(XdrDataInputStream stream) throws IOException {
AccountMergeResult decodedAccountMergeResult = new AccountMergeResult();
switch (decodedAccountMergeResult.getDiscriminant()) {
AccountMergeResult decodedAccountMergeResult = new AccountMergeResult();
AccountMergeResultCode discriminant = AccountMergeResultCode.decode(stream);
decodedAccountMergeResult.setDiscriminant(discriminant);
switch (decodedAccountMergeResult.getDiscriminant()) {
case ACCOUNT_MERGE_SUCCESS:
decodedAccountMergeResult.sourceAccountBalance = Int64.decode(stream);
break;
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/stellar/sdk/xdr/AllowTrustOp.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ public static void encode(XdrDataOutputStream stream, AllowTrustOpAsset encodedA
}
}
public static AllowTrustOpAsset decode(XdrDataInputStream stream) throws IOException {
AllowTrustOpAsset decodedAllowTrustOpAsset = new AllowTrustOpAsset();
switch (decodedAllowTrustOpAsset.getDiscriminant()) {
AllowTrustOpAsset decodedAllowTrustOpAsset = new AllowTrustOpAsset();
AssetType discriminant = AssetType.decode(stream);
decodedAllowTrustOpAsset.setDiscriminant(discriminant);
switch (decodedAllowTrustOpAsset.getDiscriminant()) {
case ASSET_TYPE_CREDIT_ALPHANUM4:
int assetCode4size = 4;
decodedAllowTrustOpAsset.assetCode4 = new byte[assetCode4size];
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/stellar/sdk/xdr/AllowTrustResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ public static void encode(XdrDataOutputStream stream, AllowTrustResult encodedAl
}
}
public static AllowTrustResult decode(XdrDataInputStream stream) throws IOException {
AllowTrustResult decodedAllowTrustResult = new AllowTrustResult();
switch (decodedAllowTrustResult.getDiscriminant()) {
AllowTrustResult decodedAllowTrustResult = new AllowTrustResult();
AllowTrustResultCode discriminant = AllowTrustResultCode.decode(stream);
decodedAllowTrustResult.setDiscriminant(discriminant);
switch (decodedAllowTrustResult.getDiscriminant()) {
case ALLOW_TRUST_SUCCESS:
break;
default:
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/stellar/sdk/xdr/Asset.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ public static void encode(XdrDataOutputStream stream, Asset encodedAsset) throws
}
}
public static Asset decode(XdrDataInputStream stream) throws IOException {
Asset decodedAsset = new Asset();
switch (decodedAsset.getDiscriminant()) {
Asset decodedAsset = new Asset();
AssetType discriminant = AssetType.decode(stream);
decodedAsset.setDiscriminant(discriminant);
switch (decodedAsset.getDiscriminant()) {
case ASSET_TYPE_NATIVE:
break;
case ASSET_TYPE_CREDIT_ALPHANUM4:
Expand Down
92 changes: 67 additions & 25 deletions src/main/java/org/stellar/sdk/xdr/AuthenticatedMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,89 @@

// === xdr source ============================================================

// struct AuthenticatedMessage
// union AuthenticatedMessage switch (uint32 v)
// {
// case 0:
// struct
// {
// uint64 sequence;
// StellarMessage message;
// HmacSha256Mac mac;
// } v0;
// };

// ===========================================================================
public class AuthenticatedMessage {
public AuthenticatedMessage () {}
private Uint64 sequence;
public Uint64 getSequence() {
return this.sequence;
}
public void setSequence(Uint64 value) {
this.sequence = value;
Uint32 v;
public Uint32 getDiscriminant() {
return this.v;
}
private StellarMessage message;
public StellarMessage getMessage() {
return this.message;
public void setDiscriminant(Uint32 value) {
this.v = value;
}
public void setMessage(StellarMessage value) {
this.message = value;
private AuthenticatedMessageV0 v0;
public AuthenticatedMessageV0 getV0() {
return this.v0;
}
private HmacSha256Mac mac;
public HmacSha256Mac getMac() {
return this.mac;
public void setV0(AuthenticatedMessageV0 value) {
this.v0 = value;
}
public void setMac(HmacSha256Mac value) {
this.mac = value;
public static void encode(XdrDataOutputStream stream, AuthenticatedMessage encodedAuthenticatedMessage) throws IOException {
stream.writeInt(encodedAuthenticatedMessage.getDiscriminant().getUint32());
switch (encodedAuthenticatedMessage.getDiscriminant().getUint32()) {
case 0:
AuthenticatedMessageV0.encode(stream, encodedAuthenticatedMessage.v0);
break;
}
public static void encode(XdrDataOutputStream stream, AuthenticatedMessage encodedAuthenticatedMessage) throws IOException{
Uint64.encode(stream, encodedAuthenticatedMessage.sequence);
StellarMessage.encode(stream, encodedAuthenticatedMessage.message);
HmacSha256Mac.encode(stream, encodedAuthenticatedMessage.mac);
}
public static AuthenticatedMessage decode(XdrDataInputStream stream) throws IOException {
AuthenticatedMessage decodedAuthenticatedMessage = new AuthenticatedMessage();
decodedAuthenticatedMessage.sequence = Uint64.decode(stream);
decodedAuthenticatedMessage.message = StellarMessage.decode(stream);
decodedAuthenticatedMessage.mac = HmacSha256Mac.decode(stream);
AuthenticatedMessage decodedAuthenticatedMessage = new AuthenticatedMessage();
Uint32 discriminant = Uint32.decode(stream);
decodedAuthenticatedMessage.setDiscriminant(discriminant);
switch (decodedAuthenticatedMessage.getDiscriminant().getUint32()) {
case 0:
decodedAuthenticatedMessage.v0 = AuthenticatedMessageV0.decode(stream);
break;
}
return decodedAuthenticatedMessage;
}

public static class AuthenticatedMessageV0 {
public AuthenticatedMessageV0 () {}
private Uint64 sequence;
public Uint64 getSequence() {
return this.sequence;
}
public void setSequence(Uint64 value) {
this.sequence = value;
}
private StellarMessage message;
public StellarMessage getMessage() {
return this.message;
}
public void setMessage(StellarMessage value) {
this.message = value;
}
private HmacSha256Mac mac;
public HmacSha256Mac getMac() {
return this.mac;
}
public void setMac(HmacSha256Mac value) {
this.mac = value;
}
public static void encode(XdrDataOutputStream stream, AuthenticatedMessageV0 encodedAuthenticatedMessageV0) throws IOException{
Uint64.encode(stream, encodedAuthenticatedMessageV0.sequence);
StellarMessage.encode(stream, encodedAuthenticatedMessageV0.message);
HmacSha256Mac.encode(stream, encodedAuthenticatedMessageV0.mac);
}
public static AuthenticatedMessageV0 decode(XdrDataInputStream stream) throws IOException {
AuthenticatedMessageV0 decodedAuthenticatedMessageV0 = new AuthenticatedMessageV0();
decodedAuthenticatedMessageV0.sequence = Uint64.decode(stream);
decodedAuthenticatedMessageV0.message = StellarMessage.decode(stream);
decodedAuthenticatedMessageV0.mac = HmacSha256Mac.decode(stream);
return decodedAuthenticatedMessageV0;
}

}
}
6 changes: 4 additions & 2 deletions src/main/java/org/stellar/sdk/xdr/BucketEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ public static void encode(XdrDataOutputStream stream, BucketEntry encodedBucketE
}
}
public static BucketEntry decode(XdrDataInputStream stream) throws IOException {
BucketEntry decodedBucketEntry = new BucketEntry();
switch (decodedBucketEntry.getDiscriminant()) {
BucketEntry decodedBucketEntry = new BucketEntry();
BucketEntryType discriminant = BucketEntryType.decode(stream);
decodedBucketEntry.setDiscriminant(discriminant);
switch (decodedBucketEntry.getDiscriminant()) {
case LIVEENTRY:
decodedBucketEntry.liveEntry = LedgerEntry.decode(stream);
break;
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/stellar/sdk/xdr/ChangeTrustResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ public static void encode(XdrDataOutputStream stream, ChangeTrustResult encodedC
}
}
public static ChangeTrustResult decode(XdrDataInputStream stream) throws IOException {
ChangeTrustResult decodedChangeTrustResult = new ChangeTrustResult();
switch (decodedChangeTrustResult.getDiscriminant()) {
ChangeTrustResult decodedChangeTrustResult = new ChangeTrustResult();
ChangeTrustResultCode discriminant = ChangeTrustResultCode.decode(stream);
decodedChangeTrustResult.setDiscriminant(discriminant);
switch (decodedChangeTrustResult.getDiscriminant()) {
case CHANGE_TRUST_SUCCESS:
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/stellar/sdk/xdr/ClaimOfferAtom.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// struct ClaimOfferAtom
// {
// // emited to identify the offer
// // emitted to identify the offer
// AccountID sellerID; // Account that owns the offer
// uint64 offerID;
//
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/stellar/sdk/xdr/CreateAccountResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ public static void encode(XdrDataOutputStream stream, CreateAccountResult encode
}
}
public static CreateAccountResult decode(XdrDataInputStream stream) throws IOException {
CreateAccountResult decodedCreateAccountResult = new CreateAccountResult();
switch (decodedCreateAccountResult.getDiscriminant()) {
CreateAccountResult decodedCreateAccountResult = new CreateAccountResult();
CreateAccountResultCode discriminant = CreateAccountResultCode.decode(stream);
decodedCreateAccountResult.setDiscriminant(discriminant);
switch (decodedCreateAccountResult.getDiscriminant()) {
case CREATE_ACCOUNT_SUCCESS:
break;
default:
Expand Down
100 changes: 100 additions & 0 deletions src/main/java/org/stellar/sdk/xdr/DataEntry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// 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 DataEntry
// {
// AccountID accountID; // account this data belongs to
// string64 dataName;
// DataValue dataValue;
//
// // reserved for future use
// union switch (int v)
// {
// case 0:
// void;
// }
// ext;
// };

// ===========================================================================
public class DataEntry {
public DataEntry () {}
private AccountID accountID;
public AccountID getAccountID() {
return this.accountID;
}
public void setAccountID(AccountID value) {
this.accountID = value;
}
private String64 dataName;
public String64 getDataName() {
return this.dataName;
}
public void setDataName(String64 value) {
this.dataName = value;
}
private DataValue dataValue;
public DataValue getDataValue() {
return this.dataValue;
}
public void setDataValue(DataValue value) {
this.dataValue = value;
}
private DataEntryExt ext;
public DataEntryExt getExt() {
return this.ext;
}
public void setExt(DataEntryExt value) {
this.ext = value;
}
public static void encode(XdrDataOutputStream stream, DataEntry encodedDataEntry) throws IOException{
AccountID.encode(stream, encodedDataEntry.accountID);
String64.encode(stream, encodedDataEntry.dataName);
DataValue.encode(stream, encodedDataEntry.dataValue);
DataEntryExt.encode(stream, encodedDataEntry.ext);
}
public static DataEntry decode(XdrDataInputStream stream) throws IOException {
DataEntry decodedDataEntry = new DataEntry();
decodedDataEntry.accountID = AccountID.decode(stream);
decodedDataEntry.dataName = String64.decode(stream);
decodedDataEntry.dataValue = DataValue.decode(stream);
decodedDataEntry.ext = DataEntryExt.decode(stream);
return decodedDataEntry;
}

public static class DataEntryExt {
public DataEntryExt () {}
Integer v;
public Integer getDiscriminant() {
return this.v;
}
public void setDiscriminant(Integer value) {
this.v = value;
}
public static void encode(XdrDataOutputStream stream, DataEntryExt encodedDataEntryExt) throws IOException {
stream.writeInt(encodedDataEntryExt.getDiscriminant().intValue());
switch (encodedDataEntryExt.getDiscriminant()) {
case 0:
break;
}
}
public static DataEntryExt decode(XdrDataInputStream stream) throws IOException {
DataEntryExt decodedDataEntryExt = new DataEntryExt();
Integer discriminant = stream.readInt();
decodedDataEntryExt.setDiscriminant(discriminant);
switch (decodedDataEntryExt.getDiscriminant()) {
case 0:
break;
}
return decodedDataEntryExt;
}

}
}
34 changes: 34 additions & 0 deletions src/main/java/org/stellar/sdk/xdr/DataValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten

package org.stellar.sdk.xdr;


import java.io.IOException;

// === xdr source ============================================================

// typedef opaque DataValue<64>;

// ===========================================================================
public class DataValue {
private byte[] DataValue;
public byte[] getDataValue() {
return this.DataValue;
}
public void setDataValue(byte[] value) {
this.DataValue = value;
}
public static void encode(XdrDataOutputStream stream, DataValue encodedDataValue) throws IOException {
int DataValuesize = encodedDataValue.DataValue.length;
stream.writeInt(DataValuesize);
stream.write(encodedDataValue.getDataValue(), 0, DataValuesize);
}
public static DataValue decode(XdrDataInputStream stream) throws IOException {
DataValue decodedDataValue = new DataValue();
int DataValuesize = stream.readInt();
decodedDataValue.DataValue = new byte[DataValuesize];
stream.read(decodedDataValue.DataValue, 0, DataValuesize);
return decodedDataValue;
}
}
Loading

0 comments on commit 0b404d9

Please sign in to comment.