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/src/permission.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { TransactionBlock, Inputs, type TransactionResult } from '@mysten/sui.js/transactions';
|
|
2
2
|
import { BCS } from '@mysten/bcs';
|
|
3
|
-
import {
|
|
3
|
+
import { FnCallType, PROTOCOL, TxbObject, PermissionObject, PermissionAddress, TXB_OBJECT, IsValidDesription,
|
|
4
|
+
IsValidObjects, IsValidAddress, IsValidArray, GuardObject, IsValidUint} from './protocol';
|
|
4
5
|
import { array_unique } from './util';
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
export const MAX_ADMIN_COUNT = 64;
|
|
8
|
-
export const MAX_ENTITY_COUNT =
|
|
9
|
-
export const MAX_PERMISSION_INDEX_COUNT =
|
|
9
|
+
export const MAX_ENTITY_COUNT = 2000;
|
|
10
|
+
export const MAX_PERMISSION_INDEX_COUNT = 200;
|
|
10
11
|
|
|
11
12
|
export enum PermissionIndex {
|
|
12
13
|
repository = 100,
|
|
@@ -84,34 +85,70 @@ export enum PermissionIndex {
|
|
|
84
85
|
progress_bind_task = 652,
|
|
85
86
|
progress_set_context_repository = 653,
|
|
86
87
|
progress_unhold = 654,
|
|
88
|
+
user_defined_start = 10000,
|
|
87
89
|
}
|
|
90
|
+
|
|
91
|
+
export type PermissionIndexType = PermissionIndex | number;
|
|
92
|
+
export const IsValidUserDefinedIndex = (index:number) : boolean => {
|
|
93
|
+
return index >= PermissionIndex.user_defined_start && IsValidUint(index)
|
|
94
|
+
}
|
|
95
|
+
export const IsValidPermissionIndex = (index:PermissionIndexType) : boolean => {
|
|
96
|
+
//console.log(index)
|
|
97
|
+
if (Object.values(PermissionIndex).includes(index)) {
|
|
98
|
+
return true
|
|
99
|
+
}
|
|
100
|
+
//console.log(Object.keys(PermissionIndex))
|
|
101
|
+
return IsValidUserDefinedIndex(index);
|
|
102
|
+
}
|
|
103
|
+
|
|
88
104
|
export type Permission_Index = {
|
|
89
|
-
index:
|
|
105
|
+
index: PermissionIndexType;
|
|
90
106
|
guard?: TxbObject;
|
|
91
107
|
}
|
|
108
|
+
|
|
92
109
|
export type Permission_Entity = {
|
|
93
|
-
|
|
110
|
+
entity_address:string;
|
|
94
111
|
permissions:Permission_Index[];
|
|
95
112
|
}
|
|
96
113
|
|
|
97
|
-
export
|
|
98
|
-
|
|
114
|
+
export function permission(txb:TransactionBlock, description:string) : PermissionObject | boolean {
|
|
115
|
+
if (!IsValidDesription(description)) return false;
|
|
99
116
|
|
|
100
|
-
export function permission(txb:TransactionBlock, description:string) : PermissionObject {
|
|
101
117
|
return txb.moveCall({
|
|
102
118
|
target: PROTOCOL.PermissionFn('new') as FnCallType,
|
|
103
|
-
arguments: [txb.pure(
|
|
119
|
+
arguments: [txb.pure(description)]
|
|
104
120
|
});
|
|
105
121
|
}
|
|
106
122
|
|
|
107
|
-
export function launch(txb:TransactionBlock, permission:PermissionObject) : PermissionAddress {
|
|
123
|
+
export function launch(txb:TransactionBlock, permission:PermissionObject) : PermissionAddress | boolean {
|
|
124
|
+
if (!IsValidObjects([permission])) return false;
|
|
108
125
|
return txb.moveCall({ // address returned
|
|
109
126
|
target:PROTOCOL.PermissionFn('create') as FnCallType,
|
|
110
|
-
arguments:[ permission ]
|
|
127
|
+
arguments:[ TXB_OBJECT(txb, permission) ]
|
|
111
128
|
})
|
|
112
129
|
}
|
|
130
|
+
export function destroy(txb:TransactionBlock, permission:PermissionObject) : boolean {
|
|
131
|
+
if (!IsValidObjects([permission])) return false;
|
|
132
|
+
txb.moveCall({
|
|
133
|
+
target:PROTOCOL.PermissionFn('destroy') as FnCallType,
|
|
134
|
+
arguments: [TXB_OBJECT(txb, permission)],
|
|
135
|
+
})
|
|
136
|
+
return true
|
|
137
|
+
}
|
|
138
|
+
export function add_entity(txb:TransactionBlock, permission:PermissionObject, entities:Permission_Entity[]) : boolean {
|
|
139
|
+
if (!IsValidObjects([permission])) return false;
|
|
140
|
+
if (!entities) return false;
|
|
141
|
+
|
|
142
|
+
let bValid = true;
|
|
143
|
+
let e = entities.forEach((v) => {
|
|
144
|
+
if (!IsValidAddress(v.entity_address)) bValid = false;
|
|
145
|
+
v.permissions.forEach((p) => {
|
|
146
|
+
if (!IsValidPermissionIndex(p.index)) bValid = false;
|
|
147
|
+
if (p?.guard && !IsValidObjects([p.guard])) bValid = false;
|
|
148
|
+
})
|
|
149
|
+
});
|
|
150
|
+
if (!bValid) return false;
|
|
113
151
|
|
|
114
|
-
export function add_entity(txb:TransactionBlock, permission:PermissionObject, entities:Permission_Entity[]) {
|
|
115
152
|
let guards:any[] = [];
|
|
116
153
|
for (let i = 0; i < entities.length; i++) {
|
|
117
154
|
let entity = entities[i];
|
|
@@ -119,106 +156,125 @@ export function add_entity(txb:TransactionBlock, permission:PermissionObject, en
|
|
|
119
156
|
|
|
120
157
|
for (let j = 0; j < entity.permissions.length; j++) {
|
|
121
158
|
let index = entity.permissions[j];
|
|
122
|
-
if (index
|
|
123
|
-
|
|
159
|
+
if (!IsValidPermissionIndex(index.index)) {
|
|
160
|
+
continue;
|
|
124
161
|
}
|
|
125
162
|
|
|
126
163
|
if (!indexes.includes(index.index)) {
|
|
127
164
|
indexes.push(index.index);
|
|
165
|
+
if (index?.guard) {
|
|
166
|
+
guards.push({entity_address:entity.entity_address, index:index.index, guard:index.guard});
|
|
167
|
+
}
|
|
128
168
|
}
|
|
129
169
|
}
|
|
130
170
|
if (indexes.length > 0) {
|
|
131
171
|
txb.moveCall({
|
|
132
172
|
target:PROTOCOL.PermissionFn('add_batch') as FnCallType,
|
|
133
|
-
arguments:[permission, txb.pure(entity.
|
|
173
|
+
arguments:[TXB_OBJECT(txb, permission), txb.pure(entity.entity_address, BCS.ADDRESS), txb.pure(indexes, 'vector<u64>')]
|
|
134
174
|
})
|
|
135
175
|
}
|
|
136
176
|
}
|
|
137
177
|
// set guards
|
|
138
|
-
guards.forEach(({
|
|
178
|
+
guards.forEach(({entity_address, index, guard}) => {
|
|
139
179
|
txb.moveCall({
|
|
140
180
|
target:PROTOCOL.PermissionFn('guard_set') as FnCallType,
|
|
141
|
-
arguments:[ permission, txb.pure(
|
|
181
|
+
arguments:[ TXB_OBJECT(txb, permission), txb.pure(entity_address, BCS.ADDRESS), txb.pure(index, BCS.U64), TXB_OBJECT(txb, guard)]
|
|
142
182
|
})
|
|
143
183
|
})
|
|
184
|
+
|
|
185
|
+
return true;
|
|
144
186
|
}
|
|
145
187
|
|
|
146
188
|
// guard: undefine to set none
|
|
147
|
-
export function set_guard(txb:TransactionBlock, permission:PermissionObject,
|
|
189
|
+
export function set_guard(txb:TransactionBlock, permission:PermissionObject, entity_address:string,
|
|
190
|
+
index:PermissionIndexType, guard?:GuardObject) : boolean {
|
|
191
|
+
if (!IsValidObjects([permission])) return false;
|
|
192
|
+
if (!IsValidAddress(entity_address) || !IsValidPermissionIndex(index)) return false;
|
|
193
|
+
|
|
148
194
|
if (guard) {
|
|
149
195
|
txb.moveCall({
|
|
150
196
|
target:PROTOCOL.PermissionFn('guard_set') as FnCallType,
|
|
151
|
-
arguments:[permission, txb.pure(
|
|
197
|
+
arguments:[TXB_OBJECT(txb, permission), txb.pure(entity_address, BCS.ADDRESS), txb.pure(index, BCS.U64), TXB_OBJECT(txb, guard)]
|
|
152
198
|
})
|
|
153
199
|
} else {
|
|
154
200
|
txb.moveCall({
|
|
155
201
|
target:PROTOCOL.PermissionFn('guard_none') as FnCallType,
|
|
156
|
-
arguments:[permission, txb.pure(
|
|
202
|
+
arguments:[TXB_OBJECT(txb, permission), txb.pure(entity_address, BCS.ADDRESS), txb.pure(index, BCS.U64)]
|
|
157
203
|
})
|
|
158
204
|
}
|
|
205
|
+
return true;
|
|
159
206
|
}
|
|
160
207
|
|
|
161
|
-
export function
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
export function remove_index(txb:TransactionBlock, permission:PermissionObject, who:string, index:number[]) {
|
|
175
|
-
if (index) {
|
|
176
|
-
txb.moveCall({
|
|
177
|
-
target:PROTOCOL.PermissionFn('remove_index') as FnCallType,
|
|
178
|
-
arguments:[permission, txb.pure(who, BCS.ADDRESS), txb.pure(index, 'vector<u64>')]
|
|
179
|
-
})
|
|
180
|
-
}
|
|
208
|
+
export function remove_index(txb:TransactionBlock, permission:PermissionObject, entity_address:string,
|
|
209
|
+
index:PermissionIndexType[]) : boolean {
|
|
210
|
+
if (!IsValidObjects([permission])) return false;
|
|
211
|
+
if (!IsValidAddress(entity_address)) return false;
|
|
212
|
+
if (!index || !(IsValidArray(index, IsValidPermissionIndex))) return false;
|
|
213
|
+
|
|
214
|
+
txb.moveCall({
|
|
215
|
+
target:PROTOCOL.PermissionFn('remove_index') as FnCallType,
|
|
216
|
+
arguments:[TXB_OBJECT(txb, permission), txb.pure(entity_address, BCS.ADDRESS), txb.pure(array_unique(index), 'vector<u64>')]
|
|
217
|
+
})
|
|
218
|
+
return true;
|
|
181
219
|
}
|
|
182
|
-
export function remove_entity(txb:TransactionBlock, permission:PermissionObject,
|
|
183
|
-
if (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
220
|
+
export function remove_entity(txb:TransactionBlock, permission:PermissionObject, entity_address:string[]) : boolean {
|
|
221
|
+
if (!IsValidObjects([permission])) return false;
|
|
222
|
+
if (!entity_address || !IsValidArray(entity_address, IsValidAddress)) return false;
|
|
223
|
+
|
|
224
|
+
txb.moveCall({
|
|
225
|
+
target:PROTOCOL.PermissionFn('remove') as FnCallType,
|
|
226
|
+
arguments:[TXB_OBJECT(txb, permission), txb.pure(array_unique(entity_address), 'vector<address>')]
|
|
227
|
+
})
|
|
228
|
+
return true;
|
|
189
229
|
}
|
|
190
|
-
export function set_description(txb:TransactionBlock, permission:PermissionObject, description:string) {
|
|
230
|
+
export function set_description(txb:TransactionBlock, permission:PermissionObject, description:string) : boolean {
|
|
231
|
+
if (!IsValidObjects([permission])) return false;
|
|
232
|
+
if (!IsValidDesription(description)) return false;
|
|
233
|
+
|
|
191
234
|
txb.moveCall({
|
|
192
235
|
target:PROTOCOL.PermissionFn('description_set') as FnCallType,
|
|
193
|
-
arguments: [permission, txb.pure(
|
|
236
|
+
arguments: [TXB_OBJECT(txb, permission), txb.pure(description)]
|
|
194
237
|
})
|
|
238
|
+
return true;
|
|
195
239
|
}
|
|
196
240
|
|
|
197
|
-
export function add_admin(txb:TransactionBlock, permission:PermissionObject, admin:string[]) {
|
|
198
|
-
|
|
241
|
+
export function add_admin(txb:TransactionBlock, permission:PermissionObject, admin:string[]) : boolean {
|
|
242
|
+
if (!IsValidObjects([permission])) return false;
|
|
243
|
+
if (!admin || !IsValidArray(admin, IsValidAddress)) return false;
|
|
244
|
+
|
|
199
245
|
txb.moveCall({
|
|
200
246
|
target:PROTOCOL.PermissionFn('admin_add_batch') as FnCallType,
|
|
201
|
-
arguments:[permission, txb.pure(
|
|
202
|
-
});
|
|
247
|
+
arguments:[TXB_OBJECT(txb, permission), txb.pure(array_unique(admin), 'vector<address>')]
|
|
248
|
+
});
|
|
249
|
+
return true;
|
|
203
250
|
}
|
|
204
251
|
|
|
205
|
-
export function remove_admin(txb:TransactionBlock, permission:PermissionObject, admin:string[], removeall?:boolean) {
|
|
252
|
+
export function remove_admin(txb:TransactionBlock, permission:PermissionObject, admin:string[], removeall?:boolean) : boolean {
|
|
253
|
+
if (!IsValidObjects([permission])) return false;
|
|
254
|
+
if (!removeall && !admin) return false;
|
|
255
|
+
if (!IsValidArray(admin, IsValidAddress)) return false;
|
|
256
|
+
|
|
206
257
|
if (removeall) {
|
|
207
258
|
txb.moveCall({
|
|
208
259
|
target:PROTOCOL.PermissionFn('admins_clear') as FnCallType,
|
|
209
|
-
arguments:[permission]
|
|
260
|
+
arguments:[TXB_OBJECT(txb, permission)]
|
|
210
261
|
});
|
|
211
|
-
} else {
|
|
262
|
+
} else if (admin) {
|
|
212
263
|
txb.moveCall({
|
|
213
264
|
target:PROTOCOL.PermissionFn('admin_remove_batch') as FnCallType,
|
|
214
|
-
arguments:[permission, txb.pure(admin, 'vector<address>')]
|
|
265
|
+
arguments:[TXB_OBJECT(txb, permission), txb.pure(array_unique(admin), 'vector<address>')]
|
|
215
266
|
});
|
|
216
267
|
}
|
|
268
|
+
return true
|
|
217
269
|
}
|
|
218
270
|
|
|
219
|
-
export function change_owner(txb:TransactionBlock, permission:PermissionObject, new_owner:string) {
|
|
271
|
+
export function change_owner(txb:TransactionBlock, permission:PermissionObject, new_owner:string) :boolean {
|
|
272
|
+
if (!IsValidObjects([permission])) return false;
|
|
273
|
+
if (!IsValidAddress(new_owner)) return false;
|
|
274
|
+
|
|
220
275
|
txb.moveCall({
|
|
221
276
|
target:PROTOCOL.PermissionFn('builder_set') as FnCallType,
|
|
222
|
-
arguments:[permission, txb.pure(new_owner, BCS.ADDRESS)]
|
|
277
|
+
arguments:[TXB_OBJECT(txb, permission), txb.pure(new_owner, BCS.ADDRESS)]
|
|
223
278
|
});
|
|
279
|
+
return true
|
|
224
280
|
}
|
package/src/progress.ts
CHANGED
|
@@ -1,139 +1,225 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export type ProgressAddress = TransactionResult;
|
|
13
|
-
export const MAX_NAMED_OPERATOR_COUNT = 64;
|
|
14
|
-
|
|
15
|
-
export function progress(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, passport?:PassportObject) : ProgressObject {
|
|
1
|
+
import { TransactionBlock } from '@mysten/sui.js/transactions';
|
|
2
|
+
import { BCS } from '@mysten/bcs';
|
|
3
|
+
import { FnCallType, PROTOCOL, PermissionObject, RepositoryObject, PassportObject, MachineObject, TXB_OBJECT,
|
|
4
|
+
ProgressObject, ProgressAddress, IsValidName, IsValidAddress, IsValidArray, OptionNone, IsValidObjects,
|
|
5
|
+
IsValidInt} from './protocol';
|
|
6
|
+
import { BCS_CONVERT, array_unique } from './util'
|
|
7
|
+
|
|
8
|
+
export const MAX_NAMED_OPERATOR_COUNT = 100;
|
|
9
|
+
|
|
10
|
+
export function progress(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, passport?:PassportObject) : ProgressObject | boolean {
|
|
11
|
+
if (!IsValidObjects([machine, permission])) return false;
|
|
16
12
|
if (passport) {
|
|
17
13
|
return txb.moveCall({
|
|
18
14
|
target:PROTOCOL.ProgressFn('new_with_passport') as FnCallType,
|
|
19
|
-
arguments: [passport, machine, permission],
|
|
15
|
+
arguments: [passport, TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
|
|
20
16
|
})
|
|
21
17
|
} else {
|
|
22
18
|
return txb.moveCall({
|
|
23
19
|
target:PROTOCOL.ProgressFn('new') as FnCallType,
|
|
24
|
-
arguments: [machine, permission],
|
|
20
|
+
arguments: [TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
|
|
25
21
|
})
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
|
-
export function launch(txb:TransactionBlock, progress:ProgressObject) : ProgressAddress {
|
|
24
|
+
export function launch(txb:TransactionBlock, progress:ProgressObject) : ProgressAddress | boolean {
|
|
25
|
+
if (!IsValidObjects([progress])) return false;
|
|
29
26
|
return txb.moveCall({
|
|
30
27
|
target:PROTOCOL.ProgressFn('create') as FnCallType,
|
|
31
|
-
arguments: [progress],
|
|
28
|
+
arguments: [TXB_OBJECT(txb, progress)],
|
|
32
29
|
})
|
|
33
30
|
}
|
|
34
|
-
export function launch_as_child(txb:TransactionBlock, progress:ProgressObject, parent:ProgressObject, parent_next:ProgressNext) : ProgressAddress {
|
|
31
|
+
export function launch_as_child(txb:TransactionBlock, progress:ProgressObject, parent:ProgressObject, parent_next:ProgressNext) : ProgressAddress | boolean {
|
|
32
|
+
if (!IsValidObjects([progress, parent])) return false;
|
|
33
|
+
if (!IsValidProgressNext(parent_next)) return false;
|
|
34
|
+
|
|
35
35
|
return txb.moveCall({
|
|
36
36
|
target:PROTOCOL.ProgressFn('create_as_child') as FnCallType,
|
|
37
|
-
arguments: [progress, parent, txb.pure(parent_next.next_node_name), txb.pure(
|
|
37
|
+
arguments: [TXB_OBJECT(txb, progress), TXB_OBJECT(txb, parent), txb.pure(parent_next.next_node_name), txb.pure(parent_next.forward)],
|
|
38
38
|
})
|
|
39
39
|
}
|
|
40
|
-
export function destroy(txb:TransactionBlock, progress:ProgressObject) {
|
|
41
|
-
return
|
|
40
|
+
export function destroy(txb:TransactionBlock, progress:ProgressObject) : boolean {
|
|
41
|
+
if (!IsValidObjects([progress])) return false;
|
|
42
|
+
txb.moveCall({
|
|
42
43
|
target:PROTOCOL.ProgressFn('destroy') as FnCallType,
|
|
43
|
-
arguments: [progress],
|
|
44
|
+
arguments: [TXB_OBJECT(txb, progress)],
|
|
44
45
|
})
|
|
46
|
+
return true
|
|
45
47
|
}
|
|
46
|
-
export function progress_set_namedOperator(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
|
|
47
|
-
|
|
48
|
+
export function progress_set_namedOperator(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
|
|
49
|
+
progress:ProgressObject, name:string, addresses:string[], passport?:PassportObject) : boolean {
|
|
50
|
+
if (!IsValidObjects([machine, permission, progress])) return false;
|
|
51
|
+
if (!IsValidName(name)) return false;
|
|
52
|
+
if (!addresses || addresses.length > MAX_NAMED_OPERATOR_COUNT) return false;
|
|
53
|
+
if (!IsValidArray(addresses, IsValidAddress)) return false;
|
|
48
54
|
|
|
49
55
|
if (passport) {
|
|
50
56
|
txb.moveCall({
|
|
51
57
|
target:PROTOCOL.ProgressFn('namedOperator_set_with_passport') as FnCallType,
|
|
52
|
-
arguments: [passport, progress, txb.pure(
|
|
53
|
-
|
|
58
|
+
arguments: [passport, TXB_OBJECT(txb, progress), txb.pure(name), txb.pure(array_unique(addresses), 'vector<address>'),
|
|
59
|
+
TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
|
|
54
60
|
})
|
|
55
61
|
} else {
|
|
56
62
|
txb.moveCall({
|
|
57
63
|
target:PROTOCOL.ProgressFn('namedOperator_set') as FnCallType,
|
|
58
|
-
arguments: [progress, txb.pure(
|
|
59
|
-
|
|
64
|
+
arguments: [TXB_OBJECT(txb, progress), txb.pure(name), txb.pure(array_unique(addresses), 'vector<address>'),
|
|
65
|
+
TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
|
|
60
66
|
})
|
|
61
67
|
}
|
|
68
|
+
return true
|
|
62
69
|
}
|
|
63
|
-
export function progress_bind_task(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
|
|
70
|
+
export function progress_bind_task(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
|
|
71
|
+
progress:ProgressObject, task_address:string, passport?:PassportObject) : boolean {
|
|
72
|
+
if (!IsValidObjects([machine, permission, progress])) return false;
|
|
73
|
+
if (!IsValidAddress(task_address)) return false;
|
|
74
|
+
|
|
64
75
|
if (passport) {
|
|
65
76
|
txb.moveCall({
|
|
66
77
|
target:PROTOCOL.ProgressFn('task_set_with_passport') as FnCallType,
|
|
67
|
-
arguments: [passport, progress, txb.pure(task_address, BCS.ADDRESS), machine, permission],
|
|
78
|
+
arguments: [passport, TXB_OBJECT(txb, progress), txb.pure(task_address, BCS.ADDRESS), TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
|
|
68
79
|
})
|
|
69
80
|
} else {
|
|
70
81
|
txb.moveCall({
|
|
71
82
|
target:PROTOCOL.ProgressFn('task_set') as FnCallType,
|
|
72
|
-
arguments: [progress, txb.pure(task_address, BCS.ADDRESS), machine, permission],
|
|
83
|
+
arguments: [TXB_OBJECT(txb, progress), txb.pure(task_address, BCS.ADDRESS), TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
|
|
73
84
|
})
|
|
74
85
|
}
|
|
86
|
+
return true
|
|
75
87
|
}
|
|
76
|
-
export function progress_set_context_repository(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
|
|
88
|
+
export function progress_set_context_repository(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
|
|
89
|
+
progress:ProgressObject, repository?:RepositoryObject, passport?:PassportObject) : boolean {
|
|
90
|
+
if (!IsValidObjects([machine, permission, progress])) return false;
|
|
77
91
|
if (passport) {
|
|
78
92
|
if (repository) {
|
|
79
93
|
txb.moveCall({
|
|
80
94
|
target:PROTOCOL.ProgressFn('context_repository_set_with_passport') as FnCallType,
|
|
81
|
-
arguments: [passport, progress, repository, machine, permission],
|
|
95
|
+
arguments: [passport, TXB_OBJECT(txb, progress), TXB_OBJECT(txb, repository), TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
|
|
82
96
|
})
|
|
83
97
|
} else {
|
|
84
98
|
txb.moveCall({
|
|
85
99
|
target:PROTOCOL.ProgressFn('context_repository_none_with_passport') as FnCallType,
|
|
86
|
-
arguments: [passport, progress, machine, permission],
|
|
100
|
+
arguments: [passport, TXB_OBJECT(txb, progress), TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
|
|
87
101
|
})
|
|
88
102
|
}
|
|
89
103
|
} else {
|
|
90
104
|
if (repository) {
|
|
91
105
|
txb.moveCall({
|
|
92
106
|
target:PROTOCOL.ProgressFn('context_repository_set') as FnCallType,
|
|
93
|
-
arguments: [progress, repository, machine, permission],
|
|
107
|
+
arguments: [TXB_OBJECT(txb, progress), TXB_OBJECT(txb, repository), TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
|
|
94
108
|
})
|
|
95
109
|
} else {
|
|
96
110
|
txb.moveCall({
|
|
97
111
|
target:PROTOCOL.ProgressFn('context_repository_none') as FnCallType,
|
|
98
|
-
arguments: [progress, machine, permission],
|
|
112
|
+
arguments: [TXB_OBJECT(txb, progress), TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
|
|
99
113
|
})
|
|
100
114
|
}
|
|
101
115
|
}
|
|
116
|
+
return true
|
|
102
117
|
}
|
|
103
|
-
export function progress_unhold(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
118
|
+
export function progress_unhold(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject,
|
|
119
|
+
progress:ProgressObject, next:ProgressNext, passport?:PassportObject) : boolean {
|
|
120
|
+
if (!IsValidObjects([machine, permission, progress])) return false;
|
|
121
|
+
if (!IsValidProgressNext(next)) return false;
|
|
122
|
+
|
|
123
|
+
if (passport) {
|
|
124
|
+
txb.moveCall({
|
|
125
|
+
target:PROTOCOL.ProgressFn('unhold_with_passport') as FnCallType,
|
|
126
|
+
arguments: [passport, TXB_OBJECT(txb, progress), TXB_OBJECT(txb, machine), txb.pure(next.next_node_name), txb.pure(next.forward), TXB_OBJECT(txb, permission)],
|
|
127
|
+
})
|
|
128
|
+
} else {
|
|
129
|
+
txb.moveCall({
|
|
130
|
+
target:PROTOCOL.ProgressFn('unhold') as FnCallType,
|
|
131
|
+
arguments: [TXB_OBJECT(txb, progress), TXB_OBJECT(txb, machine), txb.pure(next.next_node_name), txb.pure(next.forward), TXB_OBJECT(txb, permission)],
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return true
|
|
108
136
|
}
|
|
109
137
|
|
|
110
|
-
export type
|
|
111
|
-
|
|
112
|
-
|
|
138
|
+
export type ParentProgress = {
|
|
139
|
+
parent_progress_id: string;
|
|
140
|
+
parent_session_id: number;
|
|
113
141
|
}
|
|
114
|
-
export function
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
142
|
+
export function progress_parent(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, progress:ProgressObject,
|
|
143
|
+
parent_progress?:ParentProgress, passport?:PassportObject) : boolean {
|
|
144
|
+
if (!IsValidObjects([machine, permission, progress])) return false;
|
|
145
|
+
if (parent_progress && (!IsValidAddress(parent_progress.parent_progress_id) || !IsValidInt(parent_progress.parent_session_id))) return false;
|
|
118
146
|
|
|
119
|
-
|
|
147
|
+
if (passport) {
|
|
148
|
+
if (parent_progress) {
|
|
120
149
|
txb.moveCall({
|
|
121
|
-
target:PROTOCOL.ProgressFn('
|
|
122
|
-
arguments: [passport, progress, machine, txb.pure(
|
|
123
|
-
txb.pure(
|
|
124
|
-
})
|
|
150
|
+
target:PROTOCOL.ProgressFn('parent_set_with_passport') as FnCallType,
|
|
151
|
+
arguments: [passport, TXB_OBJECT(txb, progress), TXB_OBJECT(txb, machine), txb.pure(parent_progress.parent_progress_id, BCS.ADDRESS),
|
|
152
|
+
txb.pure(parent_progress.parent_session_id, BCS.U64), TXB_OBJECT(txb, permission)],
|
|
153
|
+
})
|
|
125
154
|
} else {
|
|
126
155
|
txb.moveCall({
|
|
127
|
-
target:PROTOCOL.ProgressFn('
|
|
128
|
-
arguments: [progress, machine, txb
|
|
129
|
-
|
|
130
|
-
})
|
|
156
|
+
target:PROTOCOL.ProgressFn('parent_none_with_passport') as FnCallType,
|
|
157
|
+
arguments: [passport, TXB_OBJECT(txb, progress), TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
|
|
158
|
+
})
|
|
131
159
|
}
|
|
160
|
+
} else {
|
|
161
|
+
if (parent_progress) {
|
|
162
|
+
txb.moveCall({
|
|
163
|
+
target:PROTOCOL.ProgressFn('parent_set') as FnCallType,
|
|
164
|
+
arguments: [TXB_OBJECT(txb, progress), TXB_OBJECT(txb, machine), txb.pure(parent_progress.parent_progress_id, BCS.ADDRESS),
|
|
165
|
+
txb.pure(parent_progress.parent_session_id, BCS.U64), TXB_OBJECT(txb, permission)],
|
|
166
|
+
})
|
|
167
|
+
} else {
|
|
168
|
+
txb.moveCall({
|
|
169
|
+
target:PROTOCOL.ProgressFn('parent_none') as FnCallType,
|
|
170
|
+
arguments: [TXB_OBJECT(txb, progress), TXB_OBJECT(txb, machine), TXB_OBJECT(txb, permission)],
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return true
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export type ProgressNext = {
|
|
179
|
+
next_node_name: string;
|
|
180
|
+
forward: string;
|
|
181
|
+
}
|
|
182
|
+
function IsValidProgressNext(next:ProgressNext) : boolean {
|
|
183
|
+
return IsValidName(next.forward) && IsValidName(next.next_node_name);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function next(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, progress:ProgressObject,
|
|
187
|
+
next:ProgressNext, deliverables_address?:string, sub_progress_id?:string, passport?:PassportObject) : boolean {
|
|
188
|
+
if (!IsValidObjects([machine, permission, progress])) return false;
|
|
189
|
+
if (!IsValidProgressNext(next)) return false;
|
|
190
|
+
if (deliverables_address && !IsValidAddress(deliverables_address)) return false;
|
|
191
|
+
if (sub_progress_id && !IsValidAddress(sub_progress_id)) return false;
|
|
192
|
+
|
|
193
|
+
let diliverable = deliverables_address? txb.pure(BCS_CONVERT.ser_option_address(deliverables_address)) : OptionNone(txb)
|
|
194
|
+
let sub = sub_progress_id? txb.pure(BCS_CONVERT.ser_option_address(sub_progress_id)) : OptionNone(txb)
|
|
195
|
+
|
|
196
|
+
if (passport) {
|
|
197
|
+
txb.moveCall({
|
|
198
|
+
target:PROTOCOL.ProgressFn('next_with_passport') as FnCallType,
|
|
199
|
+
arguments: [passport, TXB_OBJECT(txb, progress), TXB_OBJECT(txb, machine), txb.pure(next.next_node_name, BCS.STRING),
|
|
200
|
+
txb.pure(next.forward, BCS.STRING), diliverable, sub, TXB_OBJECT(txb, permission)],
|
|
201
|
+
})
|
|
202
|
+
} else {
|
|
203
|
+
txb.moveCall({
|
|
204
|
+
target:PROTOCOL.ProgressFn('next') as FnCallType,
|
|
205
|
+
arguments: [TXB_OBJECT(txb, progress), TXB_OBJECT(txb, machine), txb.pure(next.next_node_name, BCS.STRING),
|
|
206
|
+
txb.pure(next.forward, BCS.STRING), diliverable, sub, TXB_OBJECT(txb, permission)],
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
return true
|
|
132
210
|
}
|
|
133
|
-
|
|
211
|
+
|
|
212
|
+
export function hold(txb:TransactionBlock, machine:MachineObject, permission:PermissionObject, progress:ProgressObject,
|
|
213
|
+
next:ProgressNext, hold:boolean) : boolean {
|
|
214
|
+
if (!IsValidObjects([machine, permission, progress])) return false;
|
|
215
|
+
if (!IsValidProgressNext(next)) return false;
|
|
216
|
+
|
|
134
217
|
txb.moveCall({
|
|
135
218
|
target:PROTOCOL.ProgressFn('hold') as FnCallType,
|
|
136
|
-
arguments: [progress, machine, txb.pure(next.next_node_name),
|
|
137
|
-
txb.pure(
|
|
219
|
+
arguments: [TXB_OBJECT(txb, progress), TXB_OBJECT(txb, machine), txb.pure(next.next_node_name),
|
|
220
|
+
txb.pure(next.forward), txb.pure(hold, BCS.BOOL), TXB_OBJECT(txb, permission)],
|
|
138
221
|
})
|
|
139
|
-
|
|
222
|
+
return true
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|