-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoperation-check-sale-state.x
140 lines (127 loc) · 3.41 KB
/
operation-check-sale-state.x
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
%#include "xdr/ledger-entries.h"
%#include "xdr/operation-manage-offer.h"
namespace stellar
{
/* CheckSaleState
Closes or cancels sale if conditions for that are met.
Threshold: med
Result: CheckSaleStateResult
*/
//: CheckSaleState operation is used to perform check on sale state - whether the sale was successful or not
struct CheckSaleStateOp
{
//:ID of the sale to check
uint64 saleID;
//: Reserved for future use
union switch (LedgerVersion v)
{
case EMPTY_VERSION:
void;
}
ext;
};
/******* CheckSaleState Result ********/
//: Result codes of CheckSaleState operation
enum CheckSaleStateResultCode
{
// codes considered as "success" for the operation
//: CheckSaleState operation was successfully applied
SUCCESS = 0,
// codes considered as "failure" for the operation
//: Sale with provided ID not found
NOT_FOUND = -1,
//: Sale was not processed, because it's still active
NOT_READY = -2
};
//: Effect of performed check sale state operation
enum CheckSaleStateEffect {
//: Sale hasn't reached the soft cap before end time
CANCELED = 1,
//: Sale has either reached the soft cap and ended or reached hard cap
CLOSED = 2,
//: Crowdfunding sale was successfully closed and the price for the base asset was updated according to participants contribution
UPDATED = 3
};
//: Entry for additional information regarding sale cancel
struct SaleCanceled {
//: Reserved for future use
union switch (LedgerVersion v)
{
case EMPTY_VERSION:
void;
}
ext;
};
//: Entry for additional information regarding sale update
struct SaleUpdated {
//: Reserved for future use
union switch (LedgerVersion v)
{
case EMPTY_VERSION:
void;
}
ext;
};
//: Entry for additional information regarding sub sale closing
struct CheckSubSaleClosedResult {
//: Balance in base asset of the closed sale
BalanceID saleBaseBalance;
//: Balance in one of the quote assets of the closed sale
BalanceID saleQuoteBalance;
//: Result of an individual offer made during the sale and completed on its close
ManageOfferSuccessResult saleDetails;
//: Reserved for future use
union switch (LedgerVersion v)
{
case EMPTY_VERSION:
void;
}
ext;
};
//: Entry for additional information regarding sale closing
struct CheckSaleClosedResult {
//: AccountID of the sale owner
AccountID saleOwner;
//: Array of individual's contribution details
CheckSubSaleClosedResult results<>;
//: Reserved for future use
union switch (LedgerVersion v)
{
case EMPTY_VERSION:
void;
}
ext;
};
//: Result of the successful application of CheckSaleState operation
struct CheckSaleStateSuccess
{
//: ID of the sale being checked
uint64 saleID;
//: Additional information regarding eventual result
union switch (CheckSaleStateEffect effect)
{
case CANCELED:
SaleCanceled saleCanceled;
case CLOSED:
CheckSaleClosedResult saleClosed;
case UPDATED:
SaleUpdated saleUpdated;
}
effect;
//: Reserved for future use
union switch (LedgerVersion v)
{
case EMPTY_VERSION:
void;
}
ext;
};
//: Result of the CheckSaleState operation along with the result code
union CheckSaleStateResult switch (CheckSaleStateResultCode code)
{
case SUCCESS:
CheckSaleStateSuccess success;
default:
void;
};
}