-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoperation-manage-account-rule.x
145 lines (126 loc) · 3.87 KB
/
operation-manage-account-rule.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
140
141
142
143
144
145
%#include "xdr/ledger-entries.h"
%#include "xdr/ledger-entries-account-rule.h"
namespace stellar
{
/* ManageAccountRolePermissionOp
Creates, updates or deletes account role permission
Threshold: med
Result: ManageAccountRolePermissionResult
*/
//: Actions that can be performed with account rule
enum ManageAccountRuleAction
{
CREATE = 0,
UPDATE = 1,
REMOVE = 2
};
//: CreateAccountRuleData is used to pass necessary params to create a new account rule
struct CreateAccountRuleData
{
//: Resource is used to specify an entity (for some - with properties) that can be managed through operations
AccountRuleResource resource;
//: Value from enum that can be applied to `resource`
AccountRuleAction action;
//: True if such `action` on such `resource` is prohibited, otherwise allows
bool forbids;
//: Arbitrary stringified json object that will be attached to rule
longstring details;
//: reserved for future use
union switch (LedgerVersion v)
{
case EMPTY_VERSION:
void;
} ext;
};
//: UpdateAccountRuleData is used to pass necessary params to update existing account rule
struct UpdateAccountRuleData
{
//: Identifier of existing signer rule
uint64 ruleID;
//: Resource is used to specify entity (for some - with properties) that can be managed through operations
AccountRuleResource resource;
//: Value from enum that can be applied to `resource`
AccountRuleAction action;
//: True if such `action` on such `resource` is prohibited, otherwise allows
bool forbids;
//: Arbitrary stringified json object that will be attached to rule
longstring details;
//: reserved for future use
union switch (LedgerVersion v)
{
case EMPTY_VERSION:
void;
} ext;
};
//: RemoveAccountRuleData is used to pass necessary params to remove existing account rule
struct RemoveAccountRuleData
{
//: Identifier of existing account rule
uint64 ruleID;
//: reserved for future use
union switch (LedgerVersion v)
{
case EMPTY_VERSION:
void;
} ext;
};
//: ManageAccountRuleOp is used to create, update or remove account rule
struct ManageAccountRuleOp
{
//: data is used to pass one of `ManageAccountRuleAction` with required params
union switch (ManageAccountRuleAction action)
{
case CREATE:
CreateAccountRuleData createData;
case UPDATE:
UpdateAccountRuleData updateData;
case REMOVE:
RemoveAccountRuleData removeData;
} data;
//: reserved for future use
union switch (LedgerVersion v)
{
case EMPTY_VERSION:
void;
}
ext;
};
/******* ManageAccountRolePermissionOp Result ********/
//: Result codes of ManageAccountRuleResultCode
enum ManageAccountRuleResultCode
{
//: Means that specified action in `data` of ManageAccountRuleOp was successfully performed
SUCCESS = 0,
// codes considered as "failure" for the operation
//: There is no account rule with such id
NOT_FOUND = -1,
//: It is not allowed to remove the rule if it is used at least in one role
RULE_IS_USED = -2,
//: Passed details has invalid json structure
INVALID_DETAILS = -3,
//: Custom rule action can not be used with entries other than CUSTOM
INVALID_ACTION = -4
};
//: Result of operation applying
union ManageAccountRuleResult switch (ManageAccountRuleResultCode code)
{
case SUCCESS:
//: Is used to pass useful params if operation is success
struct {
//: id of the rule that was managed
uint64 ruleID;
//: reserved for future use
union switch (LedgerVersion v)
{
case EMPTY_VERSION:
void;
}
ext;
} success;
case RULE_IS_USED:
//: ids of roles that use the rule that cannot be removed
uint64 roleIDs<>;
default:
void;
};
}