wowok 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +17 -0
- package/dist/demand.js +91 -30
- package/dist/guard.js +206 -80
- package/dist/machine.js +130 -65
- package/dist/passport.js +14 -5
- package/dist/permission.js +117 -49
- package/dist/progress.js +74 -30
- package/dist/protocol.js +85 -53
- package/dist/repository.js +154 -50
- package/dist/reward.js +134 -28
- package/dist/service.js +457 -161
- package/dist/util.js +25 -1
- package/dist/vote.js +134 -56
- package/package.json +11 -7
- package/src/demand.ts +96 -52
- package/src/graphql.ts +103 -0
- package/src/guard.ts +268 -114
- package/src/index.ts +12 -0
- package/src/machine.ts +137 -86
- package/src/passport.ts +67 -30
- package/src/permission.ts +115 -59
- package/src/progress.ts +149 -63
- package/src/protocol.ts +94 -40
- package/src/repository.ts +152 -79
- package/src/reward.ts +134 -45
- package/src/service.ts +437 -209
- package/src/util.ts +28 -1
- package/src/vote.ts +141 -74
package/dist/protocol.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OBJECTS_TYPE = exports.OBJECTS_TYPE_PREFIX = exports.PROTOCOL = exports.Protocol = exports.ENTRYPOINT = exports.
|
|
3
|
+
exports.OBJECTS_TYPE = exports.OBJECTS_TYPE_PREFIX = exports.PROTOCOL = exports.Protocol = exports.ENTRYPOINT = exports.ContextType = exports.OperatorType = exports.ValueType = exports.CLOCK_OBJECT = exports.TXB_OBJECT = exports.MODULES = exports.IsValidObjects = exports.IsValidArray = exports.IsValidPercent = exports.IsValidInt = exports.IsValidUint = exports.IsValidArgType = exports.IsValidAddress = exports.IsValidEndpoint = exports.IsValidName_AllowEmpty = exports.IsValidName = exports.IsValidDesription = exports.OptionNone = exports.MAX_ENDPOINT_LENGTH = exports.MAX_NAME_LENGTH = exports.MAX_DESCRIPTION_LENGTH = void 0;
|
|
4
4
|
const client_1 = require("@mysten/sui.js/client");
|
|
5
5
|
const ed25519_1 = require("@mysten/sui.js/keypairs/ed25519");
|
|
6
6
|
const bcs_1 = require("@mysten/bcs");
|
|
@@ -9,18 +9,44 @@ const util_1 = require("./util");
|
|
|
9
9
|
exports.MAX_DESCRIPTION_LENGTH = 1024;
|
|
10
10
|
exports.MAX_NAME_LENGTH = 64;
|
|
11
11
|
exports.MAX_ENDPOINT_LENGTH = 1024;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
exports.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
exports.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
exports.
|
|
12
|
+
const OptionNone = (txb) => { return txb.pure([], bcs_1.BCS.U8); };
|
|
13
|
+
exports.OptionNone = OptionNone;
|
|
14
|
+
const IsValidDesription = (description) => { return description.length <= exports.MAX_DESCRIPTION_LENGTH; };
|
|
15
|
+
exports.IsValidDesription = IsValidDesription;
|
|
16
|
+
const IsValidName = (name) => { return name.length <= exports.MAX_NAME_LENGTH && name.length != 0; };
|
|
17
|
+
exports.IsValidName = IsValidName;
|
|
18
|
+
const IsValidName_AllowEmpty = (name) => { return name.length <= exports.MAX_NAME_LENGTH; };
|
|
19
|
+
exports.IsValidName_AllowEmpty = IsValidName_AllowEmpty;
|
|
20
|
+
const IsValidEndpoint = (endpoint) => { return endpoint.length <= exports.MAX_ENDPOINT_LENGTH; };
|
|
21
|
+
exports.IsValidEndpoint = IsValidEndpoint;
|
|
22
|
+
const IsValidAddress = (address) => { return address.length != 0; };
|
|
23
|
+
exports.IsValidAddress = IsValidAddress;
|
|
24
|
+
const IsValidArgType = (argType) => { return argType.length != 0; };
|
|
25
|
+
exports.IsValidArgType = IsValidArgType;
|
|
26
|
+
const IsValidUint = (value) => { return Number.isSafeInteger(value) && value != 0; };
|
|
27
|
+
exports.IsValidUint = IsValidUint;
|
|
28
|
+
const IsValidInt = (value) => { return Number.isSafeInteger(value); };
|
|
29
|
+
exports.IsValidInt = IsValidInt;
|
|
30
|
+
const IsValidPercent = (value) => { return Number.isSafeInteger(value) && value > 0 && value <= 100; };
|
|
31
|
+
exports.IsValidPercent = IsValidPercent;
|
|
32
|
+
const IsValidArray = (arr, validFunc) => {
|
|
33
|
+
let bValid = true;
|
|
34
|
+
arr.forEach((v) => {
|
|
35
|
+
if (!validFunc(v)) {
|
|
36
|
+
bValid = false;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return bValid;
|
|
40
|
+
};
|
|
41
|
+
exports.IsValidArray = IsValidArray;
|
|
42
|
+
const IsValidObjects = (arr) => {
|
|
43
|
+
return (0, exports.IsValidArray)(arr, (v) => {
|
|
44
|
+
if (!v)
|
|
45
|
+
return false;
|
|
46
|
+
return true;
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
exports.IsValidObjects = IsValidObjects;
|
|
24
50
|
var MODULES;
|
|
25
51
|
(function (MODULES) {
|
|
26
52
|
MODULES["machine"] = "machine";
|
|
@@ -49,40 +75,43 @@ exports.CLOCK_OBJECT = transactions_1.Inputs.SharedObjectRef({
|
|
|
49
75
|
mutable: false,
|
|
50
76
|
initialSharedVersion: 1,
|
|
51
77
|
});
|
|
52
|
-
var
|
|
53
|
-
(function (
|
|
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
|
-
|
|
78
|
+
var ValueType;
|
|
79
|
+
(function (ValueType) {
|
|
80
|
+
ValueType[ValueType["TYPE_STATIC_bool"] = 100] = "TYPE_STATIC_bool";
|
|
81
|
+
ValueType[ValueType["TYPE_STATIC_address"] = 101] = "TYPE_STATIC_address";
|
|
82
|
+
ValueType[ValueType["TYPE_STATIC_u64"] = 102] = "TYPE_STATIC_u64";
|
|
83
|
+
ValueType[ValueType["TYPE_STATIC_u8"] = 103] = "TYPE_STATIC_u8";
|
|
84
|
+
ValueType[ValueType["TYPE_STATIC_u128"] = 104] = "TYPE_STATIC_u128";
|
|
85
|
+
ValueType[ValueType["TYPE_STATIC_vec_u8"] = 105] = "TYPE_STATIC_vec_u8";
|
|
86
|
+
ValueType[ValueType["TYPE_STATIC_vec_address"] = 106] = "TYPE_STATIC_vec_address";
|
|
87
|
+
ValueType[ValueType["TYPE_STATIC_vec_bool"] = 107] = "TYPE_STATIC_vec_bool";
|
|
88
|
+
ValueType[ValueType["TYPE_STATIC_vec_vec_u8"] = 108] = "TYPE_STATIC_vec_vec_u8";
|
|
89
|
+
ValueType[ValueType["TYPE_STATIC_vec_u64"] = 109] = "TYPE_STATIC_vec_u64";
|
|
90
|
+
ValueType[ValueType["TYPE_STATIC_vec_u128"] = 110] = "TYPE_STATIC_vec_u128";
|
|
91
|
+
ValueType[ValueType["TYPE_STATIC_option_address"] = 111] = "TYPE_STATIC_option_address";
|
|
92
|
+
ValueType[ValueType["TYPE_STATIC_option_bool"] = 112] = "TYPE_STATIC_option_bool";
|
|
93
|
+
ValueType[ValueType["TYPE_STATIC_option_u8"] = 113] = "TYPE_STATIC_option_u8";
|
|
94
|
+
ValueType[ValueType["TYPE_STATIC_option_u64"] = 114] = "TYPE_STATIC_option_u64";
|
|
95
|
+
ValueType[ValueType["TYPE_STATIC_option_u128"] = 115] = "TYPE_STATIC_option_u128";
|
|
96
|
+
})(ValueType || (exports.ValueType = ValueType = {}));
|
|
97
|
+
var OperatorType;
|
|
98
|
+
(function (OperatorType) {
|
|
99
|
+
OperatorType[OperatorType["TYPE_DYNAMIC_QUERY"] = 1] = "TYPE_DYNAMIC_QUERY";
|
|
100
|
+
OperatorType[OperatorType["TYPE_LOGIC_OPERATOR_U128_GREATER"] = 11] = "TYPE_LOGIC_OPERATOR_U128_GREATER";
|
|
101
|
+
OperatorType[OperatorType["TYPE_LOGIC_OPERATOR_U128_GREATER_EQUAL"] = 12] = "TYPE_LOGIC_OPERATOR_U128_GREATER_EQUAL";
|
|
102
|
+
OperatorType[OperatorType["TYPE_LOGIC_OPERATOR_U128_LESSER"] = 13] = "TYPE_LOGIC_OPERATOR_U128_LESSER";
|
|
103
|
+
OperatorType[OperatorType["TYPE_LOGIC_OPERATOR_U128_LESSER_EQUAL"] = 14] = "TYPE_LOGIC_OPERATOR_U128_LESSER_EQUAL";
|
|
104
|
+
OperatorType[OperatorType["TYPE_LOGIC_OPERATOR_U128_EQUAL"] = 15] = "TYPE_LOGIC_OPERATOR_U128_EQUAL";
|
|
105
|
+
OperatorType[OperatorType["TYPE_LOGIC_OPERATOR_EQUAL"] = 16] = "TYPE_LOGIC_OPERATOR_EQUAL";
|
|
106
|
+
OperatorType[OperatorType["TYPE_LOGIC_OPERATOR_HAS_SUBSTRING"] = 17] = "TYPE_LOGIC_OPERATOR_HAS_SUBSTRING";
|
|
107
|
+
OperatorType[OperatorType["TYPE_LOGIC_ALWAYS_TRUE"] = 18] = "TYPE_LOGIC_ALWAYS_TRUE";
|
|
108
|
+
})(OperatorType || (exports.OperatorType = OperatorType = {}));
|
|
109
|
+
var ContextType;
|
|
110
|
+
(function (ContextType) {
|
|
111
|
+
ContextType[ContextType["TYPE_CONTEXT_SIGNER"] = 60] = "TYPE_CONTEXT_SIGNER";
|
|
112
|
+
ContextType[ContextType["TYPE_CONTEXT_CURRENT_PROGRESS"] = 61] = "TYPE_CONTEXT_CURRENT_PROGRESS";
|
|
113
|
+
ContextType[ContextType["TYPE_CONTEXT_CURRENT_CLOCK"] = 62] = "TYPE_CONTEXT_CURRENT_CLOCK";
|
|
114
|
+
})(ContextType || (exports.ContextType = ContextType = {}));
|
|
86
115
|
var ENTRYPOINT;
|
|
87
116
|
(function (ENTRYPOINT) {
|
|
88
117
|
ENTRYPOINT["mainnet"] = "mainnet";
|
|
@@ -96,18 +125,21 @@ class Protocol {
|
|
|
96
125
|
signer = '';
|
|
97
126
|
everyone_guard = '';
|
|
98
127
|
constructor(network = ENTRYPOINT.localnet, signer = "0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f") {
|
|
99
|
-
this.network = network;
|
|
100
128
|
this.signer = signer;
|
|
129
|
+
this.UseNetwork(network);
|
|
130
|
+
}
|
|
131
|
+
UseNetwork(network = ENTRYPOINT.localnet) {
|
|
132
|
+
this.network = network;
|
|
101
133
|
switch (network) {
|
|
102
134
|
case ENTRYPOINT.localnet:
|
|
103
|
-
this.package = "
|
|
104
|
-
this.everyone_guard = "
|
|
135
|
+
this.package = "0xe9721254e97dd074e06c5efe5c57be169b64b39ae48939d89c00bf2f62b19e10";
|
|
136
|
+
this.everyone_guard = "0xb2a3fe7881cb883743c4e962b7e3c7716a1cd47a67adad01dc79795def4f769d";
|
|
105
137
|
break;
|
|
106
138
|
case ENTRYPOINT.devnet:
|
|
107
139
|
break;
|
|
108
140
|
case ENTRYPOINT.testnet:
|
|
109
|
-
this.package = "
|
|
110
|
-
this.everyone_guard = "
|
|
141
|
+
this.package = "0x717b14e0fb287594ce9aed4ee5fb87323469c79d15c1f82c676cf55c338bfb76";
|
|
142
|
+
this.everyone_guard = "0x78a41fcc4f566360839613f6b917fb101ae015e56b43143f496f265b6422fddc";
|
|
111
143
|
break;
|
|
112
144
|
case ENTRYPOINT.mainnet:
|
|
113
145
|
break;
|
|
@@ -160,7 +192,7 @@ class Protocol {
|
|
|
160
192
|
Sign_Excute = async (exes, priv_key, param, options = { showObjectChanges: true }) => {
|
|
161
193
|
const client = new client_1.SuiClient({ url: exports.PROTOCOL.NetworkUrl() });
|
|
162
194
|
const txb = new transactions_1.TransactionBlock();
|
|
163
|
-
exes(txb, param);
|
|
195
|
+
exes.forEach((e) => { e(txb, param); });
|
|
164
196
|
const privkey = (0, bcs_1.fromHEX)(priv_key);
|
|
165
197
|
const keypair = ed25519_1.Ed25519Keypair.fromSecretKey(privkey);
|
|
166
198
|
const response = await client.signAndExecuteTransactionBlock({
|
package/dist/repository.js
CHANGED
|
@@ -1,118 +1,195 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.change_permission = exports.repository_set_policy_permission = exports.repository_set_policy_description = exports.repository_set_policy_mode = exports.repository_set_description = exports.repository_remove_policies = exports.repository_add_policies = exports.remove = exports.add_data = exports.destroy = exports.launch = exports.repository = exports.Repository_Policy_Mode = exports.MAX_POLICY_COUNT = void 0;
|
|
3
|
+
exports.change_permission = exports.repository_set_policy_permission = exports.repository_set_policy_description = exports.repository_set_policy_mode = exports.repository_set_description = exports.repository_remove_policies = exports.repository_add_policies = exports.remove = exports.add_data = exports.destroy = exports.launch = exports.repository = exports.Repository_Policy_Mode = exports.IsValidValue = exports.IsValidKey = exports.MAX_VALUE_LENGTH = exports.MAX_KEY_LENGTH = exports.MAX_POLICY_COUNT = void 0;
|
|
4
4
|
const bcs_1 = require("@mysten/bcs");
|
|
5
5
|
const protocol_1 = require("./protocol");
|
|
6
|
-
|
|
6
|
+
const permission_1 = require("./permission");
|
|
7
|
+
const util_1 = require("./util");
|
|
8
|
+
exports.MAX_POLICY_COUNT = 1000;
|
|
9
|
+
exports.MAX_KEY_LENGTH = 128;
|
|
10
|
+
exports.MAX_VALUE_LENGTH = 204800;
|
|
11
|
+
const IsValidKey = (key) => {
|
|
12
|
+
return key.length <= exports.MAX_KEY_LENGTH && key.length != 0;
|
|
13
|
+
};
|
|
14
|
+
exports.IsValidKey = IsValidKey;
|
|
15
|
+
const IsValidValue = (value) => {
|
|
16
|
+
if (typeof (value === 'number')) {
|
|
17
|
+
return (0, protocol_1.IsValidInt)(value);
|
|
18
|
+
}
|
|
19
|
+
else if (typeof (value === 'string')) {
|
|
20
|
+
return value.length < exports.MAX_VALUE_LENGTH;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return value.length < exports.MAX_VALUE_LENGTH;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.IsValidValue = IsValidValue;
|
|
7
27
|
var Repository_Policy_Mode;
|
|
8
28
|
(function (Repository_Policy_Mode) {
|
|
9
29
|
Repository_Policy_Mode[Repository_Policy_Mode["POLICY_MODE_FREE"] = 0] = "POLICY_MODE_FREE";
|
|
10
30
|
Repository_Policy_Mode[Repository_Policy_Mode["POLICY_MODE_STRICT"] = 1] = "POLICY_MODE_STRICT";
|
|
11
31
|
})(Repository_Policy_Mode || (exports.Repository_Policy_Mode = Repository_Policy_Mode = {}));
|
|
12
32
|
function repository(txb, permission, description, policy_mode, passport) {
|
|
33
|
+
if (!(0, protocol_1.IsValidObjects)([permission]))
|
|
34
|
+
return false;
|
|
35
|
+
if (!(0, protocol_1.IsValidDesription)(description))
|
|
36
|
+
return false;
|
|
13
37
|
if (passport) {
|
|
14
38
|
return txb.moveCall({
|
|
15
39
|
target: protocol_1.PROTOCOL.RepositoryFn('new_with_passport'),
|
|
16
|
-
arguments: [passport, txb.pure(
|
|
40
|
+
arguments: [passport, txb.pure(description), txb.pure(policy_mode, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
17
41
|
});
|
|
18
42
|
}
|
|
19
43
|
else {
|
|
20
44
|
return txb.moveCall({
|
|
21
45
|
target: protocol_1.PROTOCOL.RepositoryFn('new'),
|
|
22
|
-
arguments: [txb.pure(
|
|
46
|
+
arguments: [txb.pure(description), txb.pure(policy_mode, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
23
47
|
});
|
|
24
48
|
}
|
|
49
|
+
return true;
|
|
25
50
|
}
|
|
26
51
|
exports.repository = repository;
|
|
27
52
|
function launch(txb, repository) {
|
|
53
|
+
if (!(0, protocol_1.IsValidObjects)([repository]))
|
|
54
|
+
return false;
|
|
28
55
|
return txb.moveCall({
|
|
29
56
|
target: protocol_1.PROTOCOL.RepositoryFn('create'),
|
|
30
|
-
arguments: [repository],
|
|
57
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository)],
|
|
31
58
|
});
|
|
32
59
|
}
|
|
33
60
|
exports.launch = launch;
|
|
34
61
|
function destroy(txb, repository) {
|
|
35
|
-
|
|
62
|
+
if (!(0, protocol_1.IsValidObjects)([repository]))
|
|
63
|
+
return false;
|
|
64
|
+
txb.moveCall({
|
|
36
65
|
target: protocol_1.PROTOCOL.RepositoryFn('destroy'),
|
|
37
|
-
arguments: [repository],
|
|
66
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository)],
|
|
38
67
|
});
|
|
68
|
+
return true;
|
|
39
69
|
}
|
|
40
70
|
exports.destroy = destroy;
|
|
71
|
+
function to_uint8Array(value) {
|
|
72
|
+
if (typeof (value === 'number')) {
|
|
73
|
+
return (0, util_1.numToUint8Array)(value);
|
|
74
|
+
}
|
|
75
|
+
else if (typeof (value === 'string')) {
|
|
76
|
+
return (0, util_1.stringToUint8Array)(value);
|
|
77
|
+
}
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
41
80
|
function add_data(txb, repository, permission, data) {
|
|
81
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
82
|
+
return false;
|
|
83
|
+
if (!(0, exports.IsValidKey)(data.key))
|
|
84
|
+
return false;
|
|
85
|
+
let bValid = true;
|
|
86
|
+
data.data.forEach((value) => {
|
|
87
|
+
if (!(0, protocol_1.IsValidAddress)(value.address) || !(0, exports.IsValidValue)(value.value))
|
|
88
|
+
bValid = false;
|
|
89
|
+
});
|
|
90
|
+
if (!bValid)
|
|
91
|
+
return false;
|
|
42
92
|
if (data?.value_type) {
|
|
43
93
|
data.data.forEach((d) => txb.moveCall({
|
|
44
94
|
target: protocol_1.PROTOCOL.RepositoryFn('add'),
|
|
45
|
-
arguments: [repository,
|
|
95
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository),
|
|
46
96
|
txb.pure(d.address, bcs_1.BCS.ADDRESS),
|
|
47
|
-
txb.pure(
|
|
97
|
+
txb.pure(data.key),
|
|
48
98
|
txb.pure(data.value_type, bcs_1.BCS.U8),
|
|
49
|
-
txb.pure(d.value, 'vector<u8>'),
|
|
50
|
-
permission,
|
|
99
|
+
txb.pure([...to_uint8Array(d.value)], 'vector<u8>'),
|
|
100
|
+
(0, protocol_1.TXB_OBJECT)(txb, permission),
|
|
51
101
|
],
|
|
52
102
|
}));
|
|
53
103
|
}
|
|
54
104
|
else {
|
|
55
105
|
data.data.forEach((d) => txb.moveCall({
|
|
56
106
|
target: protocol_1.PROTOCOL.RepositoryFn('add_typed_data'),
|
|
57
|
-
arguments: [repository,
|
|
107
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository),
|
|
58
108
|
txb.pure(d.address, bcs_1.BCS.ADDRESS),
|
|
59
|
-
txb.pure(
|
|
60
|
-
txb.pure(d.value, 'vector<u8>'),
|
|
61
|
-
permission,
|
|
109
|
+
txb.pure(data.key),
|
|
110
|
+
txb.pure([...to_uint8Array(d.value)], 'vector<u8>'),
|
|
111
|
+
(0, protocol_1.TXB_OBJECT)(txb, permission),
|
|
62
112
|
],
|
|
63
113
|
}));
|
|
64
114
|
}
|
|
115
|
+
return true;
|
|
65
116
|
}
|
|
66
117
|
exports.add_data = add_data;
|
|
67
|
-
function remove(txb, repository, permission, address,
|
|
118
|
+
function remove(txb, repository, permission, address, key) {
|
|
119
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
120
|
+
return false;
|
|
121
|
+
if (!(0, exports.IsValidKey)(key) || !(0, protocol_1.IsValidAddress)(address))
|
|
122
|
+
return false;
|
|
68
123
|
txb.moveCall({
|
|
69
124
|
target: protocol_1.PROTOCOL.RepositoryFn('remove'),
|
|
70
|
-
arguments: [repository,
|
|
125
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository),
|
|
71
126
|
txb.pure(address, bcs_1.BCS.ADDRESS),
|
|
72
|
-
txb.pure(
|
|
73
|
-
permission,
|
|
127
|
+
txb.pure(key),
|
|
128
|
+
(0, protocol_1.TXB_OBJECT)(txb, permission),
|
|
74
129
|
],
|
|
75
130
|
});
|
|
131
|
+
return true;
|
|
76
132
|
}
|
|
77
133
|
exports.remove = remove;
|
|
78
134
|
// add or modify the old
|
|
79
135
|
function repository_add_policies(txb, repository, permission, policies, passport) {
|
|
136
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
137
|
+
return false;
|
|
138
|
+
if (!policies)
|
|
139
|
+
return false;
|
|
140
|
+
let bValid = true;
|
|
141
|
+
policies.forEach((p) => {
|
|
142
|
+
if (!(0, protocol_1.IsValidDesription)(p.description) || !(0, exports.IsValidKey)(p.key)) {
|
|
143
|
+
bValid = false;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
if (!bValid)
|
|
147
|
+
return false;
|
|
80
148
|
policies.forEach((policy) => {
|
|
81
|
-
let permission_index = policy?.permission ? txb.pure(policy.permission
|
|
149
|
+
let permission_index = policy?.permission ? txb.pure(util_1.BCS_CONVERT.ser_option_u64(policy.permission)) : txb.pure([0], bcs_1.BCS.U8);
|
|
82
150
|
if (passport) {
|
|
83
151
|
txb.moveCall({
|
|
84
152
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_add_with_passport'),
|
|
85
|
-
arguments: [passport, repository,
|
|
86
|
-
txb.pure(
|
|
87
|
-
txb.pure(
|
|
88
|
-
permission_index, txb.pure(policy.value_type, bcs_1.BCS.U8)
|
|
153
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository),
|
|
154
|
+
txb.pure(policy.key),
|
|
155
|
+
txb.pure(policy.description),
|
|
156
|
+
permission_index, txb.pure(policy.value_type, bcs_1.BCS.U8),
|
|
157
|
+
(0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
89
158
|
});
|
|
90
159
|
}
|
|
91
160
|
else {
|
|
92
161
|
txb.moveCall({
|
|
93
162
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_add'),
|
|
94
|
-
arguments: [repository,
|
|
95
|
-
txb.pure(
|
|
96
|
-
txb.pure(
|
|
97
|
-
permission_index, txb.pure(policy.value_type, bcs_1.BCS.U8)
|
|
163
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository),
|
|
164
|
+
txb.pure(policy.key),
|
|
165
|
+
txb.pure(policy.description),
|
|
166
|
+
permission_index, txb.pure(policy.value_type, bcs_1.BCS.U8),
|
|
167
|
+
(0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
98
168
|
});
|
|
99
169
|
}
|
|
100
170
|
});
|
|
171
|
+
return true;
|
|
101
172
|
}
|
|
102
173
|
exports.repository_add_policies = repository_add_policies;
|
|
103
|
-
function repository_remove_policies(txb, repository, permission,
|
|
174
|
+
function repository_remove_policies(txb, repository, permission, policy_keys, removeall, passport) {
|
|
175
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
176
|
+
return false;
|
|
177
|
+
if (!removeall && !policy_keys)
|
|
178
|
+
return false;
|
|
179
|
+
if (policy_keys && !(0, protocol_1.IsValidArray)(policy_keys, exports.IsValidKey))
|
|
180
|
+
return false;
|
|
104
181
|
if (passport) {
|
|
105
182
|
if (removeall) {
|
|
106
183
|
txb.moveCall({
|
|
107
184
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove_all_with_passport'),
|
|
108
|
-
arguments: [passport, repository, permission]
|
|
185
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
109
186
|
});
|
|
110
187
|
}
|
|
111
188
|
else {
|
|
112
|
-
|
|
189
|
+
(0, util_1.array_unique)(policy_keys).forEach((key) => {
|
|
113
190
|
txb.moveCall({
|
|
114
191
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove_with_passport'),
|
|
115
|
-
arguments: [passport, repository, txb.pure((0,
|
|
192
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure((0, util_1.array_unique)(key)), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
116
193
|
});
|
|
117
194
|
});
|
|
118
195
|
}
|
|
@@ -121,85 +198,112 @@ function repository_remove_policies(txb, repository, permission, policy_names, r
|
|
|
121
198
|
if (removeall) {
|
|
122
199
|
txb.moveCall({
|
|
123
200
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove_all'),
|
|
124
|
-
arguments: [repository, permission]
|
|
201
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
125
202
|
});
|
|
126
203
|
}
|
|
127
204
|
else {
|
|
128
|
-
|
|
205
|
+
policy_keys.forEach((key) => {
|
|
129
206
|
txb.moveCall({
|
|
130
207
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove'),
|
|
131
|
-
arguments: [repository, txb.pure((0, protocol_1.
|
|
208
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(key), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
132
209
|
});
|
|
133
210
|
});
|
|
134
211
|
}
|
|
135
212
|
}
|
|
213
|
+
return true;
|
|
136
214
|
}
|
|
137
215
|
exports.repository_remove_policies = repository_remove_policies;
|
|
138
216
|
// PermissionIndex.repository_description_set
|
|
139
217
|
function repository_set_description(txb, repository, permission, description, passport) {
|
|
218
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
219
|
+
return false;
|
|
220
|
+
if (!(0, protocol_1.IsValidDesription)(description))
|
|
221
|
+
return false;
|
|
140
222
|
if (passport) {
|
|
141
223
|
txb.moveCall({
|
|
142
224
|
target: protocol_1.PROTOCOL.RepositoryFn('description_set_with_passport'),
|
|
143
|
-
arguments: [passport, repository, txb.pure((0, protocol_1.
|
|
225
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
144
226
|
});
|
|
145
227
|
}
|
|
146
228
|
else {
|
|
147
229
|
txb.moveCall({
|
|
148
230
|
target: protocol_1.PROTOCOL.RepositoryFn('description_set'),
|
|
149
|
-
arguments: [repository, txb.pure((0, protocol_1.
|
|
231
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
150
232
|
});
|
|
151
233
|
}
|
|
234
|
+
return true;
|
|
152
235
|
}
|
|
153
236
|
exports.repository_set_description = repository_set_description;
|
|
154
237
|
function repository_set_policy_mode(txb, repository, permission, policy_mode, passport) {
|
|
238
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
239
|
+
return false;
|
|
155
240
|
if (passport) {
|
|
156
241
|
txb.moveCall({
|
|
157
242
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_mode_set_with_passport'),
|
|
158
|
-
arguments: [passport, repository, txb.pure(policy_mode), permission]
|
|
243
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(policy_mode), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
159
244
|
});
|
|
160
245
|
}
|
|
161
246
|
else {
|
|
162
247
|
txb.moveCall({
|
|
163
248
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_mode_set'),
|
|
164
|
-
arguments: [repository, txb.pure(policy_mode), permission]
|
|
249
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(policy_mode), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
165
250
|
});
|
|
166
251
|
}
|
|
252
|
+
return true;
|
|
167
253
|
}
|
|
168
254
|
exports.repository_set_policy_mode = repository_set_policy_mode;
|
|
169
|
-
function repository_set_policy_description(txb, repository, permission, description, passport) {
|
|
255
|
+
function repository_set_policy_description(txb, repository, permission, policy, description, passport) {
|
|
256
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
257
|
+
return false;
|
|
258
|
+
if (!(0, exports.IsValidKey)(policy) || !(0, protocol_1.IsValidDesription)(description))
|
|
259
|
+
return false;
|
|
170
260
|
if (passport) {
|
|
171
261
|
txb.moveCall({
|
|
172
|
-
target: protocol_1.PROTOCOL.RepositoryFn('
|
|
173
|
-
arguments: [passport, repository, txb.pure((0, protocol_1.
|
|
262
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_description_set_with_passport'),
|
|
263
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(policy), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
174
264
|
});
|
|
175
265
|
}
|
|
176
266
|
else {
|
|
177
267
|
txb.moveCall({
|
|
178
|
-
target: protocol_1.PROTOCOL.RepositoryFn('
|
|
179
|
-
arguments: [repository, txb.pure((0, protocol_1.
|
|
268
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_description_set'),
|
|
269
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(policy), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
180
270
|
});
|
|
181
271
|
}
|
|
272
|
+
return true;
|
|
182
273
|
}
|
|
183
274
|
exports.repository_set_policy_description = repository_set_policy_description;
|
|
184
|
-
function repository_set_policy_permission(txb, repository, permission, permission_index, passport) {
|
|
275
|
+
function repository_set_policy_permission(txb, repository, permission, policy, permission_index, passport) {
|
|
276
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
277
|
+
return false;
|
|
278
|
+
if (!(0, exports.IsValidKey)(policy))
|
|
279
|
+
return false;
|
|
280
|
+
let index = (0, protocol_1.OptionNone)(txb);
|
|
281
|
+
if (permission_index) {
|
|
282
|
+
if (!(0, permission_1.IsValidPermissionIndex)(permission_index))
|
|
283
|
+
return false;
|
|
284
|
+
index = txb.pure(util_1.BCS_CONVERT.ser_option_u64(permission_index));
|
|
285
|
+
}
|
|
185
286
|
if (passport) {
|
|
186
287
|
txb.moveCall({
|
|
187
|
-
target: protocol_1.PROTOCOL.RepositoryFn('
|
|
188
|
-
arguments: [passport,
|
|
288
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_permission_set_with_passport'),
|
|
289
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), index, (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
189
290
|
});
|
|
190
291
|
}
|
|
191
292
|
else {
|
|
192
293
|
txb.moveCall({
|
|
193
|
-
target: protocol_1.PROTOCOL.RepositoryFn('
|
|
194
|
-
arguments: [
|
|
294
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_permission_set'),
|
|
295
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), index, (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
195
296
|
});
|
|
196
297
|
}
|
|
298
|
+
return true;
|
|
197
299
|
}
|
|
198
300
|
exports.repository_set_policy_permission = repository_set_policy_permission;
|
|
199
301
|
function change_permission(txb, repository, old_permission, new_permission) {
|
|
302
|
+
if (!(0, protocol_1.IsValidObjects)([repository, old_permission, new_permission]))
|
|
303
|
+
return false;
|
|
200
304
|
txb.moveCall({
|
|
201
305
|
target: protocol_1.PROTOCOL.RepositoryFn('permission_set'),
|
|
202
|
-
arguments: [repository, old_permission, new_permission],
|
|
306
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), (0, protocol_1.TXB_OBJECT)(txb, old_permission), (0, protocol_1.TXB_OBJECT)(txb, new_permission)],
|
|
203
307
|
typeArguments: []
|
|
204
308
|
});
|
|
205
309
|
}
|