This repository was archived by the owner on Feb 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathLedgerKey.cs
145 lines (137 loc) · 5.19 KB
/
LedgerKey.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten
namespace Stellar.Generated
{
// === xdr source ============================================================
// union LedgerKey switch (LedgerEntryType type)
// {
// case ACCOUNT:
// struct
// {
// AccountID accountID;
// } account;
//
// case TRUSTLINE:
// struct
// {
// AccountID accountID;
// Asset asset;
// } trustLine;
//
// case OFFER:
// struct
// {
// AccountID sellerID;
// uint64 offerID;
// } offer;
//
// case DATA:
// struct
// {
// AccountID accountID;
// string64 dataName;
// } data;
// };
// ===========================================================================
public class LedgerKey {
public LedgerKey () {}
public LedgerEntryType Discriminant { get; set; } = new LedgerEntryType();
public LedgerKeyAccount Account { get; set; } = default(LedgerKeyAccount);
public LedgerKeyTrustLine TrustLine { get; set; } = default(LedgerKeyTrustLine);
public LedgerKeyOffer Offer { get; set; } = default(LedgerKeyOffer);
public LedgerKeyData Data { get; set; } = default(LedgerKeyData);
public static void Encode(IByteWriter stream, LedgerKey encodedLedgerKey) {
XdrEncoding.EncodeInt32((int)encodedLedgerKey.Discriminant.InnerValue, stream);
switch (encodedLedgerKey.Discriminant.InnerValue) {
case LedgerEntryType.LedgerEntryTypeEnum.ACCOUNT:
LedgerKeyAccount.Encode(stream, encodedLedgerKey.Account);
break;
case LedgerEntryType.LedgerEntryTypeEnum.TRUSTLINE:
LedgerKeyTrustLine.Encode(stream, encodedLedgerKey.TrustLine);
break;
case LedgerEntryType.LedgerEntryTypeEnum.OFFER:
LedgerKeyOffer.Encode(stream, encodedLedgerKey.Offer);
break;
case LedgerEntryType.LedgerEntryTypeEnum.DATA:
LedgerKeyData.Encode(stream, encodedLedgerKey.Data);
break;
}
}
public static LedgerKey Decode(IByteReader stream) {
LedgerKey decodedLedgerKey = new LedgerKey();
decodedLedgerKey.Discriminant = LedgerEntryType.Decode(stream);
switch (decodedLedgerKey.Discriminant.InnerValue) {
case LedgerEntryType.LedgerEntryTypeEnum.ACCOUNT:
decodedLedgerKey.Account = LedgerKeyAccount.Decode(stream);
break;
case LedgerEntryType.LedgerEntryTypeEnum.TRUSTLINE:
decodedLedgerKey.TrustLine = LedgerKeyTrustLine.Decode(stream);
break;
case LedgerEntryType.LedgerEntryTypeEnum.OFFER:
decodedLedgerKey.Offer = LedgerKeyOffer.Decode(stream);
break;
case LedgerEntryType.LedgerEntryTypeEnum.DATA:
decodedLedgerKey.Data = LedgerKeyData.Decode(stream);
break;
}
return decodedLedgerKey;
}
public class LedgerKeyAccount {
public LedgerKeyAccount () {}
public AccountID AccountID { get; set; }
public static void Encode(IByteWriter stream, LedgerKeyAccount encodedLedgerKeyAccount) {
AccountID.Encode(stream, encodedLedgerKeyAccount.AccountID);
}
public static LedgerKeyAccount Decode(IByteReader stream) {
LedgerKeyAccount decodedLedgerKeyAccount = new LedgerKeyAccount();
decodedLedgerKeyAccount.AccountID = AccountID.Decode(stream);
return decodedLedgerKeyAccount;
}
}
public class LedgerKeyTrustLine {
public LedgerKeyTrustLine () {}
public AccountID AccountID { get; set; }
public Asset Asset { get; set; }
public static void Encode(IByteWriter stream, LedgerKeyTrustLine encodedLedgerKeyTrustLine) {
AccountID.Encode(stream, encodedLedgerKeyTrustLine.AccountID);
Asset.Encode(stream, encodedLedgerKeyTrustLine.Asset);
}
public static LedgerKeyTrustLine Decode(IByteReader stream) {
LedgerKeyTrustLine decodedLedgerKeyTrustLine = new LedgerKeyTrustLine();
decodedLedgerKeyTrustLine.AccountID = AccountID.Decode(stream);
decodedLedgerKeyTrustLine.Asset = Asset.Decode(stream);
return decodedLedgerKeyTrustLine;
}
}
public class LedgerKeyOffer {
public LedgerKeyOffer () {}
public AccountID SellerID { get; set; }
public Uint64 OfferID { get; set; }
public static void Encode(IByteWriter stream, LedgerKeyOffer encodedLedgerKeyOffer) {
AccountID.Encode(stream, encodedLedgerKeyOffer.SellerID);
Uint64.Encode(stream, encodedLedgerKeyOffer.OfferID);
}
public static LedgerKeyOffer Decode(IByteReader stream) {
LedgerKeyOffer decodedLedgerKeyOffer = new LedgerKeyOffer();
decodedLedgerKeyOffer.SellerID = AccountID.Decode(stream);
decodedLedgerKeyOffer.OfferID = Uint64.Decode(stream);
return decodedLedgerKeyOffer;
}
}
public class LedgerKeyData {
public LedgerKeyData () {}
public AccountID AccountID { get; set; }
public String64 DataName { get; set; }
public static void Encode(IByteWriter stream, LedgerKeyData encodedLedgerKeyData) {
AccountID.Encode(stream, encodedLedgerKeyData.AccountID);
String64.Encode(stream, encodedLedgerKeyData.DataName);
}
public static LedgerKeyData Decode(IByteReader stream) {
LedgerKeyData decodedLedgerKeyData = new LedgerKeyData();
decodedLedgerKeyData.AccountID = AccountID.Decode(stream);
decodedLedgerKeyData.DataName = String64.Decode(stream);
return decodedLedgerKeyData;
}
}
}
}