wowok 1.0.3 → 1.0.4
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 +79 -73
- package/dist/machine.js +130 -65
- package/dist/passport.js +14 -5
- package/dist/permission.js +111 -49
- package/dist/progress.js +74 -30
- package/dist/protocol.js +84 -52
- package/dist/repository.js +138 -50
- package/dist/reward.js +134 -28
- package/dist/service.js +457 -161
- package/dist/util.js +16 -1
- package/dist/vote.js +134 -56
- package/package.json +4 -5
- package/src/address.graphql +0 -0
- package/src/demand.ts +96 -52
- package/src/guard.ts +88 -82
- package/src/machine.ts +126 -81
- package/src/object.graphql +30 -0
- package/src/passport.ts +7 -7
- package/src/permission.ts +110 -59
- package/src/progress.ts +89 -58
- package/src/protocol.ts +80 -33
- package/src/repository.ts +146 -70
- package/src/reward.ts +131 -45
- package/src/service.ts +433 -209
- package/src/util.ts +16 -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_DESCRIPTION_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 = "0x27ab80fa4fed1755508558ed430453ee9aa36f9c9f0982cf8bbe94a5aac8543b";
|
|
142
|
+
this.everyone_guard = "0xafc6ddc2509f17afb9b0617aebb38208218cf48cff39cd04ef4a127b1ea3bec0";
|
|
111
143
|
break;
|
|
112
144
|
case ENTRYPOINT.mainnet:
|
|
113
145
|
break;
|
package/dist/repository.js
CHANGED
|
@@ -1,118 +1,179 @@
|
|
|
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
|
+
return value.length < exports.MAX_VALUE_LENGTH;
|
|
17
|
+
};
|
|
18
|
+
exports.IsValidValue = IsValidValue;
|
|
7
19
|
var Repository_Policy_Mode;
|
|
8
20
|
(function (Repository_Policy_Mode) {
|
|
9
21
|
Repository_Policy_Mode[Repository_Policy_Mode["POLICY_MODE_FREE"] = 0] = "POLICY_MODE_FREE";
|
|
10
22
|
Repository_Policy_Mode[Repository_Policy_Mode["POLICY_MODE_STRICT"] = 1] = "POLICY_MODE_STRICT";
|
|
11
23
|
})(Repository_Policy_Mode || (exports.Repository_Policy_Mode = Repository_Policy_Mode = {}));
|
|
12
24
|
function repository(txb, permission, description, policy_mode, passport) {
|
|
25
|
+
if (!(0, protocol_1.IsValidObjects)([permission]))
|
|
26
|
+
return false;
|
|
27
|
+
if (!(0, protocol_1.IsValidDesription)(description))
|
|
28
|
+
return false;
|
|
13
29
|
if (passport) {
|
|
14
30
|
return txb.moveCall({
|
|
15
31
|
target: protocol_1.PROTOCOL.RepositoryFn('new_with_passport'),
|
|
16
|
-
arguments: [passport, txb.pure(
|
|
32
|
+
arguments: [passport, txb.pure(description), txb.pure(policy_mode, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
17
33
|
});
|
|
18
34
|
}
|
|
19
35
|
else {
|
|
20
36
|
return txb.moveCall({
|
|
21
37
|
target: protocol_1.PROTOCOL.RepositoryFn('new'),
|
|
22
|
-
arguments: [txb.pure(
|
|
38
|
+
arguments: [txb.pure(description), txb.pure(policy_mode, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
23
39
|
});
|
|
24
40
|
}
|
|
41
|
+
return true;
|
|
25
42
|
}
|
|
26
43
|
exports.repository = repository;
|
|
27
44
|
function launch(txb, repository) {
|
|
45
|
+
if (!(0, protocol_1.IsValidObjects)([repository]))
|
|
46
|
+
return false;
|
|
28
47
|
return txb.moveCall({
|
|
29
48
|
target: protocol_1.PROTOCOL.RepositoryFn('create'),
|
|
30
|
-
arguments: [repository],
|
|
49
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository)],
|
|
31
50
|
});
|
|
32
51
|
}
|
|
33
52
|
exports.launch = launch;
|
|
34
53
|
function destroy(txb, repository) {
|
|
35
|
-
|
|
54
|
+
if (!(0, protocol_1.IsValidObjects)([repository]))
|
|
55
|
+
return false;
|
|
56
|
+
txb.moveCall({
|
|
36
57
|
target: protocol_1.PROTOCOL.RepositoryFn('destroy'),
|
|
37
|
-
arguments: [repository],
|
|
58
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository)],
|
|
38
59
|
});
|
|
60
|
+
return true;
|
|
39
61
|
}
|
|
40
62
|
exports.destroy = destroy;
|
|
41
63
|
function add_data(txb, repository, permission, data) {
|
|
64
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
65
|
+
return false;
|
|
66
|
+
if (!(0, exports.IsValidKey)(data.key))
|
|
67
|
+
return false;
|
|
68
|
+
let bValid = true;
|
|
69
|
+
data.data.forEach((value) => {
|
|
70
|
+
if (!(0, exports.IsValidValue)(value.value) || !(0, protocol_1.IsValidAddress)(value.address)) {
|
|
71
|
+
bValid = false;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (!bValid)
|
|
75
|
+
return false;
|
|
42
76
|
if (data?.value_type) {
|
|
43
77
|
data.data.forEach((d) => txb.moveCall({
|
|
44
78
|
target: protocol_1.PROTOCOL.RepositoryFn('add'),
|
|
45
|
-
arguments: [repository,
|
|
79
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository),
|
|
46
80
|
txb.pure(d.address, bcs_1.BCS.ADDRESS),
|
|
47
|
-
txb.pure(
|
|
81
|
+
txb.pure(data.key),
|
|
48
82
|
txb.pure(data.value_type, bcs_1.BCS.U8),
|
|
49
|
-
txb.pure(d.value, 'vector<u8>'),
|
|
50
|
-
permission,
|
|
83
|
+
txb.pure([...d.value], 'vector<u8>'),
|
|
84
|
+
(0, protocol_1.TXB_OBJECT)(txb, permission),
|
|
51
85
|
],
|
|
52
86
|
}));
|
|
53
87
|
}
|
|
54
88
|
else {
|
|
55
89
|
data.data.forEach((d) => txb.moveCall({
|
|
56
90
|
target: protocol_1.PROTOCOL.RepositoryFn('add_typed_data'),
|
|
57
|
-
arguments: [repository,
|
|
91
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository),
|
|
58
92
|
txb.pure(d.address, bcs_1.BCS.ADDRESS),
|
|
59
|
-
txb.pure(
|
|
60
|
-
txb.pure(d.value, 'vector<u8>'),
|
|
61
|
-
permission,
|
|
93
|
+
txb.pure(data.key),
|
|
94
|
+
txb.pure([...d.value], 'vector<u8>'),
|
|
95
|
+
(0, protocol_1.TXB_OBJECT)(txb, permission),
|
|
62
96
|
],
|
|
63
97
|
}));
|
|
64
98
|
}
|
|
99
|
+
return true;
|
|
65
100
|
}
|
|
66
101
|
exports.add_data = add_data;
|
|
67
|
-
function remove(txb, repository, permission, address,
|
|
102
|
+
function remove(txb, repository, permission, address, key) {
|
|
103
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
104
|
+
return false;
|
|
105
|
+
if (!(0, exports.IsValidKey)(key) || !(0, protocol_1.IsValidAddress)(address))
|
|
106
|
+
return false;
|
|
68
107
|
txb.moveCall({
|
|
69
108
|
target: protocol_1.PROTOCOL.RepositoryFn('remove'),
|
|
70
|
-
arguments: [repository,
|
|
109
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository),
|
|
71
110
|
txb.pure(address, bcs_1.BCS.ADDRESS),
|
|
72
|
-
txb.pure(
|
|
73
|
-
permission,
|
|
111
|
+
txb.pure(key),
|
|
112
|
+
(0, protocol_1.TXB_OBJECT)(txb, permission),
|
|
74
113
|
],
|
|
75
114
|
});
|
|
115
|
+
return true;
|
|
76
116
|
}
|
|
77
117
|
exports.remove = remove;
|
|
78
118
|
// add or modify the old
|
|
79
119
|
function repository_add_policies(txb, repository, permission, policies, passport) {
|
|
120
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
121
|
+
return false;
|
|
122
|
+
if (!policies)
|
|
123
|
+
return false;
|
|
124
|
+
let bValid = true;
|
|
125
|
+
policies.forEach((p) => {
|
|
126
|
+
if (!(0, protocol_1.IsValidDesription)(p.description) || !(0, exports.IsValidKey)(p.key)) {
|
|
127
|
+
bValid = false;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
if (!bValid)
|
|
131
|
+
return false;
|
|
80
132
|
policies.forEach((policy) => {
|
|
81
|
-
let permission_index = policy?.permission ? txb.pure(policy.permission
|
|
133
|
+
let permission_index = policy?.permission ? txb.pure(util_1.BCS_CONVERT.ser_option_u64(policy.permission)) : txb.pure([0], bcs_1.BCS.U8);
|
|
82
134
|
if (passport) {
|
|
83
135
|
txb.moveCall({
|
|
84
136
|
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)
|
|
137
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository),
|
|
138
|
+
txb.pure(policy.key),
|
|
139
|
+
txb.pure(policy.description),
|
|
140
|
+
permission_index, txb.pure(policy.value_type, bcs_1.BCS.U8),
|
|
141
|
+
(0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
89
142
|
});
|
|
90
143
|
}
|
|
91
144
|
else {
|
|
92
145
|
txb.moveCall({
|
|
93
146
|
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)
|
|
147
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository),
|
|
148
|
+
txb.pure(policy.key),
|
|
149
|
+
txb.pure(policy.description),
|
|
150
|
+
permission_index, txb.pure(policy.value_type, bcs_1.BCS.U8),
|
|
151
|
+
(0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
98
152
|
});
|
|
99
153
|
}
|
|
100
154
|
});
|
|
155
|
+
return true;
|
|
101
156
|
}
|
|
102
157
|
exports.repository_add_policies = repository_add_policies;
|
|
103
|
-
function repository_remove_policies(txb, repository, permission,
|
|
158
|
+
function repository_remove_policies(txb, repository, permission, policy_keys, removeall, passport) {
|
|
159
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
160
|
+
return false;
|
|
161
|
+
if (!removeall && !policy_keys)
|
|
162
|
+
return false;
|
|
163
|
+
if (policy_keys && !(0, protocol_1.IsValidArray)(policy_keys, exports.IsValidKey))
|
|
164
|
+
return false;
|
|
104
165
|
if (passport) {
|
|
105
166
|
if (removeall) {
|
|
106
167
|
txb.moveCall({
|
|
107
168
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove_all_with_passport'),
|
|
108
|
-
arguments: [passport, repository, permission]
|
|
169
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
109
170
|
});
|
|
110
171
|
}
|
|
111
172
|
else {
|
|
112
|
-
|
|
173
|
+
(0, util_1.array_unique)(policy_keys).forEach((key) => {
|
|
113
174
|
txb.moveCall({
|
|
114
175
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove_with_passport'),
|
|
115
|
-
arguments: [passport, repository, txb.pure((0,
|
|
176
|
+
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
177
|
});
|
|
117
178
|
});
|
|
118
179
|
}
|
|
@@ -121,85 +182,112 @@ function repository_remove_policies(txb, repository, permission, policy_names, r
|
|
|
121
182
|
if (removeall) {
|
|
122
183
|
txb.moveCall({
|
|
123
184
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove_all'),
|
|
124
|
-
arguments: [repository, permission]
|
|
185
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
125
186
|
});
|
|
126
187
|
}
|
|
127
188
|
else {
|
|
128
|
-
|
|
189
|
+
policy_keys.forEach((key) => {
|
|
129
190
|
txb.moveCall({
|
|
130
191
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove'),
|
|
131
|
-
arguments: [repository, txb.pure((0, protocol_1.
|
|
192
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(key), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
132
193
|
});
|
|
133
194
|
});
|
|
134
195
|
}
|
|
135
196
|
}
|
|
197
|
+
return true;
|
|
136
198
|
}
|
|
137
199
|
exports.repository_remove_policies = repository_remove_policies;
|
|
138
200
|
// PermissionIndex.repository_description_set
|
|
139
201
|
function repository_set_description(txb, repository, permission, description, passport) {
|
|
202
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
203
|
+
return false;
|
|
204
|
+
if (!(0, protocol_1.IsValidDesription)(description))
|
|
205
|
+
return false;
|
|
140
206
|
if (passport) {
|
|
141
207
|
txb.moveCall({
|
|
142
208
|
target: protocol_1.PROTOCOL.RepositoryFn('description_set_with_passport'),
|
|
143
|
-
arguments: [passport, repository, txb.pure((0, protocol_1.
|
|
209
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
144
210
|
});
|
|
145
211
|
}
|
|
146
212
|
else {
|
|
147
213
|
txb.moveCall({
|
|
148
214
|
target: protocol_1.PROTOCOL.RepositoryFn('description_set'),
|
|
149
|
-
arguments: [repository, txb.pure((0, protocol_1.
|
|
215
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
150
216
|
});
|
|
151
217
|
}
|
|
218
|
+
return true;
|
|
152
219
|
}
|
|
153
220
|
exports.repository_set_description = repository_set_description;
|
|
154
221
|
function repository_set_policy_mode(txb, repository, permission, policy_mode, passport) {
|
|
222
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
223
|
+
return false;
|
|
155
224
|
if (passport) {
|
|
156
225
|
txb.moveCall({
|
|
157
226
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_mode_set_with_passport'),
|
|
158
|
-
arguments: [passport, repository, txb.pure(policy_mode), permission]
|
|
227
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(policy_mode), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
159
228
|
});
|
|
160
229
|
}
|
|
161
230
|
else {
|
|
162
231
|
txb.moveCall({
|
|
163
232
|
target: protocol_1.PROTOCOL.RepositoryFn('policy_mode_set'),
|
|
164
|
-
arguments: [repository, txb.pure(policy_mode), permission]
|
|
233
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(policy_mode), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
165
234
|
});
|
|
166
235
|
}
|
|
236
|
+
return true;
|
|
167
237
|
}
|
|
168
238
|
exports.repository_set_policy_mode = repository_set_policy_mode;
|
|
169
|
-
function repository_set_policy_description(txb, repository, permission, description, passport) {
|
|
239
|
+
function repository_set_policy_description(txb, repository, permission, policy, description, passport) {
|
|
240
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
241
|
+
return false;
|
|
242
|
+
if (!(0, exports.IsValidKey)(policy) || !(0, protocol_1.IsValidDesription)(description))
|
|
243
|
+
return false;
|
|
170
244
|
if (passport) {
|
|
171
245
|
txb.moveCall({
|
|
172
|
-
target: protocol_1.PROTOCOL.RepositoryFn('
|
|
173
|
-
arguments: [passport, repository, txb.pure((0, protocol_1.
|
|
246
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_description_set_with_passport'),
|
|
247
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(policy), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
174
248
|
});
|
|
175
249
|
}
|
|
176
250
|
else {
|
|
177
251
|
txb.moveCall({
|
|
178
|
-
target: protocol_1.PROTOCOL.RepositoryFn('
|
|
179
|
-
arguments: [repository, txb.pure((0, protocol_1.
|
|
252
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_description_set'),
|
|
253
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(policy), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
180
254
|
});
|
|
181
255
|
}
|
|
256
|
+
return true;
|
|
182
257
|
}
|
|
183
258
|
exports.repository_set_policy_description = repository_set_policy_description;
|
|
184
|
-
function repository_set_policy_permission(txb, repository, permission, permission_index, passport) {
|
|
259
|
+
function repository_set_policy_permission(txb, repository, permission, policy, permission_index, passport) {
|
|
260
|
+
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
261
|
+
return false;
|
|
262
|
+
if (!(0, exports.IsValidKey)(policy))
|
|
263
|
+
return false;
|
|
264
|
+
let index = (0, protocol_1.OptionNone)(txb);
|
|
265
|
+
if (permission_index) {
|
|
266
|
+
if (!(0, permission_1.IsValidPermissionIndex)(permission_index))
|
|
267
|
+
return false;
|
|
268
|
+
index = txb.pure(util_1.BCS_CONVERT.ser_option_u64(permission_index));
|
|
269
|
+
}
|
|
185
270
|
if (passport) {
|
|
186
271
|
txb.moveCall({
|
|
187
|
-
target: protocol_1.PROTOCOL.RepositoryFn('
|
|
188
|
-
arguments: [passport,
|
|
272
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_permission_set_with_passport'),
|
|
273
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), index, (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
189
274
|
});
|
|
190
275
|
}
|
|
191
276
|
else {
|
|
192
277
|
txb.moveCall({
|
|
193
|
-
target: protocol_1.PROTOCOL.RepositoryFn('
|
|
194
|
-
arguments: [
|
|
278
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_permission_set'),
|
|
279
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), index, (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
195
280
|
});
|
|
196
281
|
}
|
|
282
|
+
return true;
|
|
197
283
|
}
|
|
198
284
|
exports.repository_set_policy_permission = repository_set_policy_permission;
|
|
199
285
|
function change_permission(txb, repository, old_permission, new_permission) {
|
|
286
|
+
if (!(0, protocol_1.IsValidObjects)([repository, old_permission, new_permission]))
|
|
287
|
+
return false;
|
|
200
288
|
txb.moveCall({
|
|
201
289
|
target: protocol_1.PROTOCOL.RepositoryFn('permission_set'),
|
|
202
|
-
arguments: [repository, old_permission, new_permission],
|
|
290
|
+
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
291
|
typeArguments: []
|
|
204
292
|
});
|
|
205
293
|
}
|