wowok 1.0.5 → 1.0.6
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/dist/demand.js +2 -2
- package/dist/graphql.js +102 -0
- package/dist/guard.js +42 -28
- package/dist/index.js +46 -0
- package/dist/machine.js +16 -9
- package/dist/passport.js +54 -20
- package/dist/progress.js +62 -13
- package/dist/protocol.js +12 -4
- package/dist/repository.js +12 -31
- package/dist/reward.js +6 -5
- package/dist/service.js +9 -5
- package/dist/util.js +9 -6
- package/package.json +1 -1
- package/src/guard.ts +2 -2
- package/src/index.ts +31 -11
- package/src/machine.ts +1 -1
- package/src/passport.ts +1 -4
- package/src/permission.ts +1 -1
- package/src/progress.ts +1 -1
- package/src/protocol.ts +1 -1
- package/src/repository.ts +1 -1
- package/src/reward.ts +6 -6
- package/src/service.ts +3 -3
- package/src/{util.ts → utils.ts} +4 -7
- package/src/vote.ts +1 -1
package/dist/demand.js
CHANGED
|
@@ -208,14 +208,14 @@ function present(earnest_type, service_type, txb, demand, service, tips, passpor
|
|
|
208
208
|
if (passport) {
|
|
209
209
|
txb.moveCall({
|
|
210
210
|
target: protocol_1.PROTOCOL.DemandFn('present_with_passport'),
|
|
211
|
-
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(tips),],
|
|
211
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(tips, bcs_1.BCS.STRING),],
|
|
212
212
|
typeArguments: [earnest_type, service_type],
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
215
|
else {
|
|
216
216
|
txb.moveCall({
|
|
217
217
|
target: protocol_1.PROTOCOL.DemandFn('present'),
|
|
218
|
-
arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(tips),],
|
|
218
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(tips, bcs_1.BCS.STRING),],
|
|
219
219
|
typeArguments: [earnest_type, service_type],
|
|
220
220
|
});
|
|
221
221
|
}
|
package/dist/graphql.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GRAPHQL_OBJECTS = exports.GRAPHQL_OWNER = exports.GRAPHQL_OBJECT = exports.GRAPHQL_OBJECTS_TYPE = void 0;
|
|
4
|
+
const graphql_tag_1 = require("graphql-tag");
|
|
5
|
+
exports.GRAPHQL_OBJECTS_TYPE = (0, graphql_tag_1.gql)(`
|
|
6
|
+
query objects_type_version($filter:ObjectFilter!) {
|
|
7
|
+
objects(filter:$filter) {
|
|
8
|
+
nodes {
|
|
9
|
+
address
|
|
10
|
+
version
|
|
11
|
+
asMoveObject {
|
|
12
|
+
contents {
|
|
13
|
+
type {
|
|
14
|
+
repr
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`);
|
|
22
|
+
exports.GRAPHQL_OBJECT = (0, graphql_tag_1.gql)(`
|
|
23
|
+
query object($ObjectID:SuiAddress!) {
|
|
24
|
+
object(address:$ObjectID) {
|
|
25
|
+
address
|
|
26
|
+
asMoveObject {
|
|
27
|
+
contents {
|
|
28
|
+
json
|
|
29
|
+
type {
|
|
30
|
+
repr
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
dynamicFields {
|
|
35
|
+
pageInfo {
|
|
36
|
+
hasNextPage
|
|
37
|
+
endCursor
|
|
38
|
+
}
|
|
39
|
+
nodes {
|
|
40
|
+
name {
|
|
41
|
+
json
|
|
42
|
+
}
|
|
43
|
+
value {
|
|
44
|
+
... on MoveValue {
|
|
45
|
+
json
|
|
46
|
+
}
|
|
47
|
+
... on MoveObject {
|
|
48
|
+
contents {
|
|
49
|
+
json
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`);
|
|
58
|
+
exports.GRAPHQL_OWNER = (0, graphql_tag_1.gql)(`
|
|
59
|
+
query owner($ObjectID:SuiAddress!) {
|
|
60
|
+
owner (address: $ObjectID) {
|
|
61
|
+
address
|
|
62
|
+
dynamicFields {
|
|
63
|
+
pageInfo {
|
|
64
|
+
hasNextPage
|
|
65
|
+
endCursor
|
|
66
|
+
}
|
|
67
|
+
nodes {
|
|
68
|
+
name {
|
|
69
|
+
json
|
|
70
|
+
}
|
|
71
|
+
value {
|
|
72
|
+
... on MoveValue {
|
|
73
|
+
json
|
|
74
|
+
}
|
|
75
|
+
... on MoveObject {
|
|
76
|
+
contents {
|
|
77
|
+
json
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
`);
|
|
86
|
+
exports.GRAPHQL_OBJECTS = (0, graphql_tag_1.gql)(`
|
|
87
|
+
query objects($filter:ObjectFilter!){
|
|
88
|
+
objects(filter:$filter) {
|
|
89
|
+
nodes {
|
|
90
|
+
address
|
|
91
|
+
asMoveObject {
|
|
92
|
+
contents {
|
|
93
|
+
json
|
|
94
|
+
type {
|
|
95
|
+
repr
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
`);
|
package/dist/guard.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.rpc_sense_objects_fn = exports.rpc_description_fn = exports.parse_sense_bsc = exports.parse_graphql_senses = exports.SenseMaker = exports.QUERIES = exports.everyone_guard = exports.signer_guard = exports.launch = exports.Guard_Sense_Binder = exports.MAX_SENSE_COUNT = void 0;
|
|
4
4
|
const bcs_1 = require("@mysten/bcs");
|
|
5
5
|
const protocol_1 = require("./protocol");
|
|
6
6
|
const util_1 = require("./util");
|
|
@@ -42,19 +42,17 @@ function launch(txb, creation) {
|
|
|
42
42
|
}
|
|
43
43
|
exports.launch = launch;
|
|
44
44
|
function signer_guard(txb) {
|
|
45
|
-
txb.moveCall({
|
|
45
|
+
return txb.moveCall({
|
|
46
46
|
target: protocol_1.PROTOCOL.GuardFn('signer_guard'),
|
|
47
47
|
arguments: []
|
|
48
48
|
});
|
|
49
|
-
return true;
|
|
50
49
|
}
|
|
51
50
|
exports.signer_guard = signer_guard;
|
|
52
51
|
function everyone_guard(txb) {
|
|
53
|
-
txb.moveCall({
|
|
52
|
+
return txb.moveCall({
|
|
54
53
|
target: protocol_1.PROTOCOL.GuardFn('everyone_guard'),
|
|
55
54
|
arguments: []
|
|
56
55
|
});
|
|
57
|
-
return true;
|
|
58
56
|
}
|
|
59
57
|
exports.everyone_guard = everyone_guard;
|
|
60
58
|
exports.QUERIES = [
|
|
@@ -312,14 +310,24 @@ function match_u128(type) {
|
|
|
312
310
|
}
|
|
313
311
|
return false;
|
|
314
312
|
}
|
|
313
|
+
function parse_graphql_senses(senses) {
|
|
314
|
+
let objects = [];
|
|
315
|
+
senses.forEach((s) => {
|
|
316
|
+
let res = parse_sense_bsc(Uint8Array.from(s.input.bytes));
|
|
317
|
+
if (res) {
|
|
318
|
+
objects = objects.concat(res);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
return (0, util_1.array_unique)(objects);
|
|
322
|
+
}
|
|
323
|
+
exports.parse_graphql_senses = parse_graphql_senses;
|
|
315
324
|
// parse guard senses input bytes of a guard, return [objectids] for 'query_cmd'
|
|
316
325
|
function parse_sense_bsc(chain_sense_bsc) {
|
|
317
|
-
|
|
318
|
-
var array = [].slice.call(chain_sense_bsc.reverse());
|
|
326
|
+
var arr = [].slice.call(chain_sense_bsc.reverse());
|
|
319
327
|
const bcs = new bcs_1.BCS((0, bcs_1.getSuiMoveConfig)());
|
|
320
328
|
var result = [];
|
|
321
|
-
while (
|
|
322
|
-
var type =
|
|
329
|
+
while (arr.length > 0) {
|
|
330
|
+
var type = arr.shift();
|
|
323
331
|
// console.log(type);
|
|
324
332
|
switch (type) {
|
|
325
333
|
case protocol_1.ContextType.TYPE_CONTEXT_SIGNER:
|
|
@@ -332,42 +340,44 @@ function parse_sense_bsc(chain_sense_bsc) {
|
|
|
332
340
|
case protocol_1.OperatorType.TYPE_LOGIC_OPERATOR_U128_EQUAL:
|
|
333
341
|
case protocol_1.OperatorType.TYPE_LOGIC_OPERATOR_EQUAL:
|
|
334
342
|
case protocol_1.OperatorType.TYPE_LOGIC_OPERATOR_HAS_SUBSTRING:
|
|
343
|
+
case protocol_1.OperatorType.TYPE_LOGIC_ALWAYS_TRUE:
|
|
335
344
|
break;
|
|
336
345
|
case protocol_1.ValueType.TYPE_STATIC_address:
|
|
337
346
|
//console.log('0x' + bcs.de(BCS.ADDRESS, Uint8Array.from(array)).toString());
|
|
338
|
-
|
|
347
|
+
arr.splice(0, 32);
|
|
339
348
|
break;
|
|
340
349
|
case protocol_1.ValueType.TYPE_STATIC_bool:
|
|
341
350
|
case protocol_1.ValueType.TYPE_STATIC_u8:
|
|
342
|
-
|
|
351
|
+
arr.splice(0, 1);
|
|
343
352
|
break;
|
|
344
353
|
case protocol_1.ValueType.TYPE_STATIC_u64:
|
|
345
|
-
|
|
354
|
+
arr.splice(0, 8);
|
|
346
355
|
break;
|
|
347
356
|
case protocol_1.ValueType.TYPE_STATIC_u128:
|
|
348
|
-
|
|
357
|
+
arr.splice(0, 16);
|
|
349
358
|
break;
|
|
350
359
|
case protocol_1.ValueType.TYPE_STATIC_vec_u8:
|
|
351
|
-
let { value, length } = (0, util_1.ulebDecode)(Uint8Array.from(
|
|
352
|
-
|
|
360
|
+
let { value, length } = (0, util_1.ulebDecode)(Uint8Array.from(arr));
|
|
361
|
+
arr.splice(0, value + length);
|
|
353
362
|
break;
|
|
354
363
|
case protocol_1.OperatorType.TYPE_DYNAMIC_QUERY:
|
|
355
|
-
result.push('0x' + bcs.de(bcs_1.BCS.ADDRESS, Uint8Array.from(
|
|
356
|
-
|
|
364
|
+
result.push('0x' + bcs.de(bcs_1.BCS.ADDRESS, Uint8Array.from(arr)).toString());
|
|
365
|
+
arr.splice(0, 33); // address + cmd
|
|
357
366
|
break;
|
|
358
367
|
default:
|
|
359
|
-
|
|
368
|
+
console.error('parse_sense_bsc:undefined');
|
|
369
|
+
console.log(type);
|
|
370
|
+
console.log(arr);
|
|
360
371
|
return false; // error
|
|
361
372
|
}
|
|
362
373
|
}
|
|
363
374
|
return result;
|
|
364
375
|
}
|
|
365
376
|
exports.parse_sense_bsc = parse_sense_bsc;
|
|
366
|
-
const
|
|
367
|
-
const description_fn = (response, param, option) => {
|
|
377
|
+
const rpc_description_fn = (response, param, option) => {
|
|
368
378
|
if (!response.error) {
|
|
369
379
|
let c = response?.data?.content;
|
|
370
|
-
if (
|
|
380
|
+
if ((0, protocol_1.OBJECTS_TYPE)().find((v) => (v == c.type)) && c.fields.id.id == param.objectid) { // GUARD OBJECT
|
|
371
381
|
let description = c.fields.description;
|
|
372
382
|
if (!param.data.includes(description)) {
|
|
373
383
|
param.data.push(description);
|
|
@@ -375,19 +385,23 @@ const description_fn = (response, param, option) => {
|
|
|
375
385
|
}
|
|
376
386
|
}
|
|
377
387
|
};
|
|
378
|
-
exports.
|
|
379
|
-
const
|
|
388
|
+
exports.rpc_description_fn = rpc_description_fn;
|
|
389
|
+
const rpc_sense_objects_fn = (response, param, option) => {
|
|
380
390
|
if (!response.error) {
|
|
381
391
|
let c = response?.data?.content;
|
|
382
|
-
|
|
392
|
+
let index = (0, protocol_1.OBJECTS_TYPE)().findIndex(v => v.includes('guard::Guard') && v == c.type);
|
|
393
|
+
if (index >= 0 && c.fields.id.id == param.objectid) { // GUARD OBJECT
|
|
383
394
|
for (let i = 0; i < c.fields.senses.length; i++) {
|
|
384
395
|
let sense = c.fields.senses[i];
|
|
385
|
-
if (sense.type == (protocol_1.OBJECTS_TYPE_PREFIX[
|
|
386
|
-
let
|
|
387
|
-
|
|
396
|
+
if (sense.type == ((0, protocol_1.OBJECTS_TYPE_PREFIX)()[index] + 'Sense')) { // ...::guard::Sense
|
|
397
|
+
let res = parse_sense_bsc(Uint8Array.from(sense.fields.input.fields.bytes));
|
|
398
|
+
if (res) {
|
|
399
|
+
let ids = res;
|
|
400
|
+
param.data = param.data.concat(ids); // DONT array_unique senses
|
|
401
|
+
}
|
|
388
402
|
}
|
|
389
403
|
}
|
|
390
404
|
}
|
|
391
405
|
}
|
|
392
406
|
};
|
|
393
|
-
exports.
|
|
407
|
+
exports.rpc_sense_objects_fn = rpc_sense_objects_fn;
|
package/dist/index.js
CHANGED
|
@@ -1 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.machine_destroy = exports.machine_launch = exports.machine_set_endpoint = exports.machine_set_description = exports.machine_remove_repository = exports.machine_remove_node = exports.machine_publish = exports.machine_pause = exports.machine_clone = exports.machine_add_repository = exports.machine_add_node2 = exports.machine_add_node = exports.machine = exports.MAX_PRESENTERS_COUNT = exports.MAX_EARNEST_COUNT = exports.demand_change_permission = exports.present = exports.demand_launch = exports.demand_destroy = exports.demand_deposit = exports.demand_yes = exports.demand_set_guard = exports.demand_set_description = exports.demand_refund = exports.demand_expand_time = exports.demand = void 0;
|
|
18
|
+
__exportStar(require("./protocol"), exports);
|
|
19
|
+
var demand_1 = require("./demand");
|
|
20
|
+
Object.defineProperty(exports, "demand", { enumerable: true, get: function () { return demand_1.demand; } });
|
|
21
|
+
Object.defineProperty(exports, "demand_expand_time", { enumerable: true, get: function () { return demand_1.demand_expand_time; } });
|
|
22
|
+
Object.defineProperty(exports, "demand_refund", { enumerable: true, get: function () { return demand_1.demand_refund; } });
|
|
23
|
+
Object.defineProperty(exports, "demand_set_description", { enumerable: true, get: function () { return demand_1.demand_set_description; } });
|
|
24
|
+
Object.defineProperty(exports, "demand_set_guard", { enumerable: true, get: function () { return demand_1.demand_set_guard; } });
|
|
25
|
+
Object.defineProperty(exports, "demand_yes", { enumerable: true, get: function () { return demand_1.demand_yes; } });
|
|
26
|
+
Object.defineProperty(exports, "demand_deposit", { enumerable: true, get: function () { return demand_1.deposit; } });
|
|
27
|
+
Object.defineProperty(exports, "demand_destroy", { enumerable: true, get: function () { return demand_1.destroy; } });
|
|
28
|
+
Object.defineProperty(exports, "demand_launch", { enumerable: true, get: function () { return demand_1.launch; } });
|
|
29
|
+
Object.defineProperty(exports, "present", { enumerable: true, get: function () { return demand_1.present; } });
|
|
30
|
+
Object.defineProperty(exports, "demand_change_permission", { enumerable: true, get: function () { return demand_1.change_permission; } });
|
|
31
|
+
Object.defineProperty(exports, "MAX_EARNEST_COUNT", { enumerable: true, get: function () { return demand_1.MAX_EARNEST_COUNT; } });
|
|
32
|
+
Object.defineProperty(exports, "MAX_PRESENTERS_COUNT", { enumerable: true, get: function () { return demand_1.MAX_PRESENTERS_COUNT; } });
|
|
33
|
+
var machine_1 = require("./machine");
|
|
34
|
+
Object.defineProperty(exports, "machine", { enumerable: true, get: function () { return machine_1.machine; } });
|
|
35
|
+
Object.defineProperty(exports, "machine_add_node", { enumerable: true, get: function () { return machine_1.machine_add_node; } });
|
|
36
|
+
Object.defineProperty(exports, "machine_add_node2", { enumerable: true, get: function () { return machine_1.machine_add_node2; } });
|
|
37
|
+
Object.defineProperty(exports, "machine_add_repository", { enumerable: true, get: function () { return machine_1.machine_add_repository; } });
|
|
38
|
+
Object.defineProperty(exports, "machine_clone", { enumerable: true, get: function () { return machine_1.machine_clone; } });
|
|
39
|
+
Object.defineProperty(exports, "machine_pause", { enumerable: true, get: function () { return machine_1.machine_pause; } });
|
|
40
|
+
Object.defineProperty(exports, "machine_publish", { enumerable: true, get: function () { return machine_1.machine_publish; } });
|
|
41
|
+
Object.defineProperty(exports, "machine_remove_node", { enumerable: true, get: function () { return machine_1.machine_remove_node; } });
|
|
42
|
+
Object.defineProperty(exports, "machine_remove_repository", { enumerable: true, get: function () { return machine_1.machine_remove_repository; } });
|
|
43
|
+
Object.defineProperty(exports, "machine_set_description", { enumerable: true, get: function () { return machine_1.machine_set_description; } });
|
|
44
|
+
Object.defineProperty(exports, "machine_set_endpoint", { enumerable: true, get: function () { return machine_1.machine_set_endpoint; } });
|
|
45
|
+
Object.defineProperty(exports, "machine_launch", { enumerable: true, get: function () { return machine_1.launch; } });
|
|
46
|
+
Object.defineProperty(exports, "machine_destroy", { enumerable: true, get: function () { return machine_1.destroy; } });
|
|
47
|
+
__exportStar(require("./passport"), exports);
|
package/dist/machine.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.change_permission = exports.machine_publish = exports.machine_pause = exports.machine_set_endpoint = exports.machine_clone = exports.machine_remove_repository = exports.machine_add_repository = exports.machine_set_description = exports.launch = exports.destroy = exports.machine = exports.machine_remove_node = exports.machine_add_node2 = exports.machine_add_node = exports.INITIAL_NODE_NAME = void 0;
|
|
3
|
+
exports.change_permission = exports.machine_publish = exports.machine_pause = exports.machine_set_endpoint = exports.machine_clone = exports.machine_remove_repository = exports.machine_add_repository = exports.machine_set_description = exports.launch = exports.destroy = exports.machine = exports.machine_remove_node = exports.machine_add_node2 = exports.machine_add_node = exports.namedOperator_ORDER_PAYER = exports.INITIAL_NODE_NAME = void 0;
|
|
4
|
+
const bcs_1 = require("@mysten/bcs");
|
|
4
5
|
const protocol_1 = require("./protocol");
|
|
5
6
|
const util_1 = require("./util");
|
|
6
7
|
const permission_1 = require("./permission");
|
|
7
8
|
exports.INITIAL_NODE_NAME = '';
|
|
8
|
-
|
|
9
|
+
exports.namedOperator_ORDER_PAYER = 'order payer';
|
|
10
|
+
// create new nodes for machine
|
|
9
11
|
function machine_add_node(txb, machine, permission, nodes, passport) {
|
|
10
12
|
if (!(0, protocol_1.IsValidObjects)([machine, permission]))
|
|
11
13
|
return false;
|
|
@@ -78,29 +80,33 @@ function machine_add_node(txb, machine, permission, nodes, passport) {
|
|
|
78
80
|
return machine_add_node2(txb, machine, permission, new_nodes, passport);
|
|
79
81
|
}
|
|
80
82
|
exports.machine_add_node = machine_add_node;
|
|
81
|
-
//
|
|
83
|
+
// move MachineNodeObject to the machine from signer-owned MachineNode object
|
|
82
84
|
function machine_add_node2(txb, machine, permission, nodes, passport) {
|
|
83
85
|
if (!(0, protocol_1.IsValidObjects)([machine, permission]))
|
|
84
86
|
return false;
|
|
85
87
|
if (!nodes)
|
|
86
88
|
return false;
|
|
89
|
+
let n = [];
|
|
90
|
+
(0, util_1.array_unique)(nodes).forEach((v) => {
|
|
91
|
+
n.push((0, protocol_1.TXB_OBJECT)(txb, v));
|
|
92
|
+
});
|
|
87
93
|
if (passport) {
|
|
88
94
|
txb.moveCall({
|
|
89
95
|
target: protocol_1.PROTOCOL.MachineFn('node_add_with_passport'),
|
|
90
|
-
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, machine), txb.makeMoveVec({ objects:
|
|
96
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, machine), txb.makeMoveVec({ objects: n }), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
91
97
|
});
|
|
92
98
|
}
|
|
93
99
|
else {
|
|
94
100
|
txb.moveCall({
|
|
95
101
|
target: protocol_1.PROTOCOL.MachineFn('node_add'),
|
|
96
|
-
arguments: [(0, protocol_1.TXB_OBJECT)(txb, machine), txb.makeMoveVec({ objects:
|
|
102
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, machine), txb.makeMoveVec({ objects: n }), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
97
103
|
});
|
|
98
104
|
}
|
|
99
105
|
return true;
|
|
100
106
|
}
|
|
101
107
|
exports.machine_add_node2 = machine_add_node2;
|
|
102
|
-
//
|
|
103
|
-
function machine_remove_node(txb, machine, permission, nodes_name, passport) {
|
|
108
|
+
// move MachineNodeObject from machine to signer-owned MachineNode object
|
|
109
|
+
function machine_remove_node(txb, machine, permission, nodes_name, bTransferMyself = false, passport) {
|
|
104
110
|
if (!(0, protocol_1.IsValidObjects)([machine, permission]))
|
|
105
111
|
return false;
|
|
106
112
|
if (!nodes_name || !(0, protocol_1.IsValidArray)(nodes_name, protocol_1.IsValidName))
|
|
@@ -108,13 +114,14 @@ function machine_remove_node(txb, machine, permission, nodes_name, passport) {
|
|
|
108
114
|
if (passport) {
|
|
109
115
|
txb.moveCall({
|
|
110
116
|
target: protocol_1.PROTOCOL.MachineFn('node_remove_with_passport'),
|
|
111
|
-
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(util_1.BCS_CONVERT.ser_vector_string(nodes_name)),
|
|
117
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(util_1.BCS_CONVERT.ser_vector_string(nodes_name)),
|
|
118
|
+
txb.pure(bTransferMyself, bcs_1.BCS.BOOL), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
112
119
|
});
|
|
113
120
|
}
|
|
114
121
|
else {
|
|
115
122
|
txb.moveCall({
|
|
116
123
|
target: protocol_1.PROTOCOL.MachineFn('node_remove'),
|
|
117
|
-
arguments: [(0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(util_1.BCS_CONVERT.ser_vector_string(nodes_name)), permission],
|
|
124
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(util_1.BCS_CONVERT.ser_vector_string(nodes_name)), txb.pure(bTransferMyself, bcs_1.BCS.BOOL), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
118
125
|
});
|
|
119
126
|
}
|
|
120
127
|
return true;
|
package/dist/passport.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.graphql_query_objects = exports.rpc_query_cmd_fn = exports.destroy = exports.verify = exports.passport_queries = exports.MAX_GUARD_COUNT = void 0;
|
|
4
4
|
const transactions_1 = require("@mysten/sui.js/transactions");
|
|
5
5
|
const protocol_1 = require("./protocol");
|
|
6
6
|
const util_1 = require("./util");
|
|
@@ -16,39 +16,54 @@ exports.MAX_GUARD_COUNT = 8;
|
|
|
16
16
|
// 6. destroy passport
|
|
17
17
|
const passport_queries = async (guards) => {
|
|
18
18
|
let sense_objects = guards.map((value) => {
|
|
19
|
-
return { objectid: value, callback: guard_1.
|
|
19
|
+
return { objectid: value, callback: guard_1.rpc_sense_objects_fn, data: [] };
|
|
20
20
|
});
|
|
21
21
|
await protocol_1.PROTOCOL.Query(sense_objects); // objects need quering in guards
|
|
22
22
|
let sense_objects_result = [];
|
|
23
23
|
sense_objects.forEach((value) => {
|
|
24
24
|
sense_objects_result = sense_objects_result.concat(value.data);
|
|
25
25
|
});
|
|
26
|
-
sense_objects_result = (0, util_1.array_unique)(sense_objects_result);
|
|
27
|
-
console.log(sense_objects_result);
|
|
26
|
+
sense_objects_result = (0, util_1.array_unique)(sense_objects_result); // objects in guards
|
|
27
|
+
// console.log(sense_objects_result);
|
|
28
28
|
let queries = sense_objects_result.map((value) => {
|
|
29
|
-
return { objectid: value, callback: exports.
|
|
29
|
+
return { objectid: value, callback: exports.rpc_query_cmd_fn, data: [] };
|
|
30
30
|
});
|
|
31
31
|
await protocol_1.PROTOCOL.Query(queries, { 'showType': true }); // queries for passport verifing
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
let res = [];
|
|
33
|
+
sense_objects.forEach((guard) => {
|
|
34
|
+
res = res.concat(guard.data.map((object) => {
|
|
35
|
+
let data = queries.filter((v) => {
|
|
36
|
+
return v.objectid == object;
|
|
37
|
+
});
|
|
38
|
+
if (!data) {
|
|
39
|
+
console.error('error find data');
|
|
40
|
+
console.log(queries);
|
|
41
|
+
console.log(object);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
return data[0].data;
|
|
45
|
+
}));
|
|
34
46
|
});
|
|
47
|
+
return res;
|
|
35
48
|
};
|
|
36
49
|
exports.passport_queries = passport_queries;
|
|
37
|
-
// return passport object
|
|
38
|
-
function verify(txb, passport_queries) {
|
|
39
|
-
if (passport_queries.length == 0 || passport_queries.length > exports.MAX_GUARD_COUNT) {
|
|
50
|
+
// return passport object used
|
|
51
|
+
function verify(txb, guards, passport_queries) {
|
|
52
|
+
if (!guards || passport_queries.length == 0 || passport_queries.length > exports.MAX_GUARD_COUNT) {
|
|
40
53
|
return false;
|
|
41
54
|
}
|
|
42
|
-
|
|
55
|
+
console.log(guards);
|
|
56
|
+
console.log(passport_queries);
|
|
43
57
|
var passport = txb.moveCall({
|
|
44
58
|
target: protocol_1.PROTOCOL.PassportFn('new'),
|
|
45
|
-
arguments: [
|
|
59
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, guards[0]), txb.object(protocol_1.CLOCK_OBJECT)]
|
|
46
60
|
});
|
|
47
61
|
// add others guards, if any
|
|
48
|
-
for (let i = 1; i <
|
|
62
|
+
for (let i = 1; i < guards.length; i++) {
|
|
63
|
+
console.log('dfdfdf');
|
|
49
64
|
txb.moveCall({
|
|
50
65
|
target: protocol_1.PROTOCOL.PassportFn('guard_add'),
|
|
51
|
-
arguments: [passport,
|
|
66
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, guards[i])]
|
|
52
67
|
});
|
|
53
68
|
}
|
|
54
69
|
// rules: 'verify' & 'query' in turns;'verify' at final end.
|
|
@@ -79,13 +94,13 @@ function destroy(txb, passport) {
|
|
|
79
94
|
}
|
|
80
95
|
exports.destroy = destroy;
|
|
81
96
|
// construct Guard_Query_Object of wowok objects for passport verify
|
|
82
|
-
const
|
|
97
|
+
const rpc_query_cmd_fn = (response, param, option) => {
|
|
83
98
|
if (!response.error && response.data?.objectId == param.objectid && response.data?.type) {
|
|
84
|
-
for (let k = 0; k < protocol_1.OBJECTS_TYPE.length; k++) {
|
|
85
|
-
if (response?.data?.type.includes(protocol_1.OBJECTS_TYPE[k])) { // type: pack::m::Object<...>
|
|
86
|
-
param.data = { target: protocol_1.OBJECTS_TYPE_PREFIX[k] + 'guard_query',
|
|
99
|
+
for (let k = 0; k < (0, protocol_1.OBJECTS_TYPE)().length; k++) {
|
|
100
|
+
if (response?.data?.type.includes((0, protocol_1.OBJECTS_TYPE)()[k])) { // type: pack::m::Object<...>
|
|
101
|
+
param.data = { target: (0, protocol_1.OBJECTS_TYPE_PREFIX)()[k] + 'guard_query',
|
|
87
102
|
object: transactions_1.Inputs.SharedObjectRef({
|
|
88
|
-
objectId:
|
|
103
|
+
objectId: response.data.objectId,
|
|
89
104
|
mutable: false,
|
|
90
105
|
initialSharedVersion: response.data.version,
|
|
91
106
|
}),
|
|
@@ -95,4 +110,23 @@ const query_cmd_fn = (response, param, option) => {
|
|
|
95
110
|
}
|
|
96
111
|
}
|
|
97
112
|
};
|
|
98
|
-
exports.
|
|
113
|
+
exports.rpc_query_cmd_fn = rpc_query_cmd_fn;
|
|
114
|
+
const graphql_query_objects = (nodes) => {
|
|
115
|
+
let ret = [];
|
|
116
|
+
nodes.forEach((node) => {
|
|
117
|
+
for (let k = 0; k < (0, protocol_1.OBJECTS_TYPE)().length; k++) {
|
|
118
|
+
if (node?.asMoveObject?.contents?.type?.repr?.includes((0, protocol_1.OBJECTS_TYPE)()[k])) { // type: pack::m::Object<...>
|
|
119
|
+
ret.push({ target: (0, protocol_1.OBJECTS_TYPE_PREFIX)()[k] + 'guard_query',
|
|
120
|
+
object: transactions_1.Inputs.SharedObjectRef({
|
|
121
|
+
objectId: node.address,
|
|
122
|
+
mutable: false,
|
|
123
|
+
initialSharedVersion: node.version,
|
|
124
|
+
}),
|
|
125
|
+
types: (0, util_1.parse_object_type)(node.asMoveObject.contents.type.repr),
|
|
126
|
+
id: node.address, });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return ret;
|
|
131
|
+
};
|
|
132
|
+
exports.graphql_query_objects = graphql_query_objects;
|
package/dist/progress.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hold = exports.next = exports.progress_unhold = exports.progress_set_context_repository = exports.progress_bind_task = exports.progress_set_namedOperator = exports.destroy = exports.launch_as_child = exports.launch = exports.progress = exports.MAX_NAMED_OPERATOR_COUNT = void 0;
|
|
3
|
+
exports.hold = exports.next = exports.progress_parent = exports.progress_unhold = exports.progress_set_context_repository = exports.progress_bind_task = exports.progress_set_namedOperator = exports.destroy = exports.launch_as_child = exports.launch = exports.progress = exports.MAX_NAMED_OPERATOR_COUNT = void 0;
|
|
4
4
|
const bcs_1 = require("@mysten/bcs");
|
|
5
5
|
const protocol_1 = require("./protocol");
|
|
6
6
|
const util_1 = require("./util");
|
|
@@ -132,41 +132,90 @@ function progress_set_context_repository(txb, machine, permission, progress, rep
|
|
|
132
132
|
return true;
|
|
133
133
|
}
|
|
134
134
|
exports.progress_set_context_repository = progress_set_context_repository;
|
|
135
|
-
function progress_unhold(txb, machine, permission, progress, next) {
|
|
135
|
+
function progress_unhold(txb, machine, permission, progress, next, passport) {
|
|
136
136
|
if (!(0, protocol_1.IsValidObjects)([machine, permission, progress]))
|
|
137
137
|
return false;
|
|
138
138
|
if (!IsValidProgressNext(next))
|
|
139
139
|
return false;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
if (passport) {
|
|
141
|
+
txb.moveCall({
|
|
142
|
+
target: protocol_1.PROTOCOL.ProgressFn('unhold_with_passport'),
|
|
143
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name), txb.pure(next.forward), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
txb.moveCall({
|
|
148
|
+
target: protocol_1.PROTOCOL.ProgressFn('unhold'),
|
|
149
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name), txb.pure(next.forward), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
150
|
+
});
|
|
151
|
+
}
|
|
144
152
|
return true;
|
|
145
153
|
}
|
|
146
154
|
exports.progress_unhold = progress_unhold;
|
|
155
|
+
function progress_parent(txb, machine, permission, progress, parent_progress, passport) {
|
|
156
|
+
if (!(0, protocol_1.IsValidObjects)([machine, permission, progress]))
|
|
157
|
+
return false;
|
|
158
|
+
if (parent_progress && (!(0, protocol_1.IsValidAddress)(parent_progress.parent_progress_id) || !(0, protocol_1.IsValidInt)(parent_progress.parent_session_id)))
|
|
159
|
+
return false;
|
|
160
|
+
if (passport) {
|
|
161
|
+
if (parent_progress) {
|
|
162
|
+
txb.moveCall({
|
|
163
|
+
target: protocol_1.PROTOCOL.ProgressFn('parent_set_with_passport'),
|
|
164
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(parent_progress.parent_progress_id, bcs_1.BCS.ADDRESS),
|
|
165
|
+
txb.pure(parent_progress.parent_session_id, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
txb.moveCall({
|
|
170
|
+
target: protocol_1.PROTOCOL.ProgressFn('parent_none_with_passport'),
|
|
171
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
if (parent_progress) {
|
|
177
|
+
txb.moveCall({
|
|
178
|
+
target: protocol_1.PROTOCOL.ProgressFn('parent_set'),
|
|
179
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(parent_progress.parent_progress_id, bcs_1.BCS.ADDRESS),
|
|
180
|
+
txb.pure(parent_progress.parent_session_id, bcs_1.BCS.U64), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
txb.moveCall({
|
|
185
|
+
target: protocol_1.PROTOCOL.ProgressFn('parent_none'),
|
|
186
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
exports.progress_parent = progress_parent;
|
|
147
193
|
function IsValidProgressNext(next) {
|
|
148
194
|
return (0, protocol_1.IsValidName)(next.forward) && (0, protocol_1.IsValidName)(next.next_node_name);
|
|
149
195
|
}
|
|
150
|
-
function next(txb, machine, permission, progress, next, deliverables_address, passport) {
|
|
196
|
+
function next(txb, machine, permission, progress, next, deliverables_address, sub_progress_id, passport) {
|
|
151
197
|
if (!(0, protocol_1.IsValidObjects)([machine, permission, progress]))
|
|
152
198
|
return false;
|
|
153
199
|
if (!IsValidProgressNext(next))
|
|
154
200
|
return false;
|
|
155
201
|
if (deliverables_address && !(0, protocol_1.IsValidAddress)(deliverables_address))
|
|
156
202
|
return false;
|
|
203
|
+
if (sub_progress_id && !(0, protocol_1.IsValidAddress)(sub_progress_id))
|
|
204
|
+
return false;
|
|
157
205
|
let diliverable = deliverables_address ? txb.pure(util_1.BCS_CONVERT.ser_option_address(deliverables_address)) : (0, protocol_1.OptionNone)(txb);
|
|
206
|
+
let sub = sub_progress_id ? txb.pure(util_1.BCS_CONVERT.ser_option_address(sub_progress_id)) : (0, protocol_1.OptionNone)(txb);
|
|
158
207
|
if (passport) {
|
|
159
208
|
txb.moveCall({
|
|
160
|
-
target: protocol_1.PROTOCOL.ProgressFn('
|
|
161
|
-
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name),
|
|
162
|
-
txb.pure(next.forward), diliverable, (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
209
|
+
target: protocol_1.PROTOCOL.ProgressFn('next_with_passport'),
|
|
210
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name, bcs_1.BCS.STRING),
|
|
211
|
+
txb.pure(next.forward, bcs_1.BCS.STRING), diliverable, sub, (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
163
212
|
});
|
|
164
213
|
}
|
|
165
214
|
else {
|
|
166
215
|
txb.moveCall({
|
|
167
|
-
target: protocol_1.PROTOCOL.ProgressFn('
|
|
168
|
-
arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name),
|
|
169
|
-
txb.pure(next.forward), diliverable, (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
216
|
+
target: protocol_1.PROTOCOL.ProgressFn('next'),
|
|
217
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, progress), (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(next.next_node_name, bcs_1.BCS.STRING),
|
|
218
|
+
txb.pure(next.forward, bcs_1.BCS.STRING), diliverable, sub, (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
170
219
|
});
|
|
171
220
|
}
|
|
172
221
|
return true;
|
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.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;
|
|
3
|
+
exports.OBJECTS_TYPE = exports.OBJECTS_TYPE_PREFIX = exports.WOWOK_TYPE = exports.SUI_TYPE = 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");
|
|
@@ -124,6 +124,7 @@ class Protocol {
|
|
|
124
124
|
package = '';
|
|
125
125
|
signer = '';
|
|
126
126
|
everyone_guard = '';
|
|
127
|
+
graphql = '';
|
|
127
128
|
constructor(network = ENTRYPOINT.localnet, signer = "0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f") {
|
|
128
129
|
this.signer = signer;
|
|
129
130
|
this.UseNetwork(network);
|
|
@@ -138,8 +139,9 @@ class Protocol {
|
|
|
138
139
|
case ENTRYPOINT.devnet:
|
|
139
140
|
break;
|
|
140
141
|
case ENTRYPOINT.testnet:
|
|
141
|
-
this.package = "
|
|
142
|
+
this.package = "0x877375bc3bde063e4b95f428df218af7faaeef431993f4a68f2dfa5ceb8acb2e";
|
|
142
143
|
this.everyone_guard = "0x78a41fcc4f566360839613f6b917fb101ae015e56b43143f496f265b6422fddc";
|
|
144
|
+
this.graphql = 'https://sui-testnet.mystenlabs.com/graphql';
|
|
143
145
|
break;
|
|
144
146
|
case ENTRYPOINT.mainnet:
|
|
145
147
|
break;
|
|
@@ -148,6 +150,7 @@ class Protocol {
|
|
|
148
150
|
}
|
|
149
151
|
Package() { return this.package; }
|
|
150
152
|
EveryoneGuard() { return this.everyone_guard; }
|
|
153
|
+
GraphqlUrl() { return this.graphql; }
|
|
151
154
|
NetworkUrl() {
|
|
152
155
|
switch (this.network) {
|
|
153
156
|
case ENTRYPOINT.localnet:
|
|
@@ -205,5 +208,10 @@ class Protocol {
|
|
|
205
208
|
}
|
|
206
209
|
exports.Protocol = Protocol;
|
|
207
210
|
exports.PROTOCOL = new Protocol();
|
|
208
|
-
exports.
|
|
209
|
-
|
|
211
|
+
exports.SUI_TYPE = '0x2::coin::Coin<0x2::sui::SUI>';
|
|
212
|
+
const WOWOK_TYPE = () => { '0x2::coin::Coin<' + exports.PROTOCOL.Package() + '::wowok::WOWOK'; };
|
|
213
|
+
exports.WOWOK_TYPE = WOWOK_TYPE;
|
|
214
|
+
const OBJECTS_TYPE_PREFIX = () => Object.keys(MODULES).map((key) => { return exports.PROTOCOL.Package() + '::' + key + '::'; });
|
|
215
|
+
exports.OBJECTS_TYPE_PREFIX = OBJECTS_TYPE_PREFIX;
|
|
216
|
+
const OBJECTS_TYPE = () => Object.keys(MODULES).map((key) => { let i = exports.PROTOCOL.Package() + '::' + key + '::'; return i + (0, util_1.capitalize)(key); });
|
|
217
|
+
exports.OBJECTS_TYPE = OBJECTS_TYPE;
|
package/dist/repository.js
CHANGED
|
@@ -13,15 +13,7 @@ const IsValidKey = (key) => {
|
|
|
13
13
|
};
|
|
14
14
|
exports.IsValidKey = IsValidKey;
|
|
15
15
|
const IsValidValue = (value) => {
|
|
16
|
-
|
|
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
|
-
}
|
|
16
|
+
return value.length < exports.MAX_VALUE_LENGTH;
|
|
25
17
|
};
|
|
26
18
|
exports.IsValidValue = IsValidValue;
|
|
27
19
|
var Repository_Policy_Mode;
|
|
@@ -68,15 +60,6 @@ function destroy(txb, repository) {
|
|
|
68
60
|
return true;
|
|
69
61
|
}
|
|
70
62
|
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
|
-
}
|
|
80
63
|
function add_data(txb, repository, permission, data) {
|
|
81
64
|
if (!(0, protocol_1.IsValidObjects)([repository, permission]))
|
|
82
65
|
return false;
|
|
@@ -84,7 +67,9 @@ function add_data(txb, repository, permission, data) {
|
|
|
84
67
|
return false;
|
|
85
68
|
let bValid = true;
|
|
86
69
|
data.data.forEach((value) => {
|
|
87
|
-
if (!(0, protocol_1.IsValidAddress)(value.address)
|
|
70
|
+
if (!(0, protocol_1.IsValidAddress)(value.address))
|
|
71
|
+
bValid = false;
|
|
72
|
+
if (!(0, exports.IsValidValue)(value.bcsBytes))
|
|
88
73
|
bValid = false;
|
|
89
74
|
});
|
|
90
75
|
if (!bValid)
|
|
@@ -96,7 +81,7 @@ function add_data(txb, repository, permission, data) {
|
|
|
96
81
|
txb.pure(d.address, bcs_1.BCS.ADDRESS),
|
|
97
82
|
txb.pure(data.key),
|
|
98
83
|
txb.pure(data.value_type, bcs_1.BCS.U8),
|
|
99
|
-
txb.pure([...
|
|
84
|
+
txb.pure([...d.bcsBytes], 'vector<u8>'),
|
|
100
85
|
(0, protocol_1.TXB_OBJECT)(txb, permission),
|
|
101
86
|
],
|
|
102
87
|
}));
|
|
@@ -107,7 +92,7 @@ function add_data(txb, repository, permission, data) {
|
|
|
107
92
|
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository),
|
|
108
93
|
txb.pure(d.address, bcs_1.BCS.ADDRESS),
|
|
109
94
|
txb.pure(data.key),
|
|
110
|
-
txb.pure([...
|
|
95
|
+
txb.pure([...d.bcsBytes], 'vector<u8>'),
|
|
111
96
|
(0, protocol_1.TXB_OBJECT)(txb, permission),
|
|
112
97
|
],
|
|
113
98
|
}));
|
|
@@ -186,11 +171,9 @@ function repository_remove_policies(txb, repository, permission, policy_keys, re
|
|
|
186
171
|
});
|
|
187
172
|
}
|
|
188
173
|
else {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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)]
|
|
193
|
-
});
|
|
174
|
+
txb.moveCall({
|
|
175
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove_with_passport'),
|
|
176
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(util_1.BCS_CONVERT.ser_vector_string((0, util_1.array_unique)(policy_keys))), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
194
177
|
});
|
|
195
178
|
}
|
|
196
179
|
}
|
|
@@ -202,11 +185,9 @@ function repository_remove_policies(txb, repository, permission, policy_keys, re
|
|
|
202
185
|
});
|
|
203
186
|
}
|
|
204
187
|
else {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(key), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
209
|
-
});
|
|
188
|
+
txb.moveCall({
|
|
189
|
+
target: protocol_1.PROTOCOL.RepositoryFn('policy_remove'),
|
|
190
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, repository), txb.pure(util_1.BCS_CONVERT.ser_vector_string((0, util_1.array_unique)(policy_keys))), (0, protocol_1.TXB_OBJECT)(txb, permission)]
|
|
210
191
|
});
|
|
211
192
|
}
|
|
212
193
|
}
|
package/dist/reward.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.change_permission = exports.deposit = exports.claim = exports.reward_lock_guards = exports.reward_set_description = exports.allow_repeat_claim = exports.reward_remove_guard = exports.reward_add_guard = exports.reward_expand_time = exports.reward_refund = exports.destroy = exports.launch = exports.reward = void 0;
|
|
3
|
+
exports.change_permission = exports.deposit = exports.claim = exports.reward_lock_guards = exports.reward_set_description = exports.allow_repeat_claim = exports.reward_remove_guard = exports.reward_add_guard = exports.MAX_PORTIONS_COUNT = exports.reward_expand_time = exports.reward_refund = exports.destroy = exports.launch = exports.reward = void 0;
|
|
4
4
|
const bcs_1 = require("@mysten/bcs");
|
|
5
5
|
const protocol_1 = require("./protocol");
|
|
6
6
|
const util_1 = require("./util");
|
|
@@ -101,6 +101,7 @@ function reward_expand_time(reward_type, txb, reward, permission, minutes_expand
|
|
|
101
101
|
return true;
|
|
102
102
|
}
|
|
103
103
|
exports.reward_expand_time = reward_expand_time;
|
|
104
|
+
exports.MAX_PORTIONS_COUNT = 255;
|
|
104
105
|
function reward_add_guard(reward_type, txb, reward, permission, gurads, passport) {
|
|
105
106
|
if (!(0, protocol_1.IsValidObjects)([reward, permission]))
|
|
106
107
|
return false;
|
|
@@ -110,7 +111,7 @@ function reward_add_guard(reward_type, txb, reward, permission, gurads, passport
|
|
|
110
111
|
return false;
|
|
111
112
|
let bValid = true;
|
|
112
113
|
gurads.forEach((v) => {
|
|
113
|
-
if (!(0, protocol_1.IsValidUint)(v.portions))
|
|
114
|
+
if (!(0, protocol_1.IsValidUint)(v.portions) || v.portions > exports.MAX_PORTIONS_COUNT)
|
|
114
115
|
bValid = false;
|
|
115
116
|
if (!(0, protocol_1.IsValidObjects)([v.guard]))
|
|
116
117
|
bValid = false;
|
|
@@ -120,14 +121,14 @@ function reward_add_guard(reward_type, txb, reward, permission, gurads, passport
|
|
|
120
121
|
if (passport) {
|
|
121
122
|
gurads.forEach((guard) => txb.moveCall({
|
|
122
123
|
target: protocol_1.PROTOCOL.RewardFn('guard_add_with_passport'),
|
|
123
|
-
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, guard.guard), txb.pure(guard.portions, bcs_1.BCS.
|
|
124
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, guard.guard), txb.pure(guard.portions, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
124
125
|
typeArguments: [reward_type]
|
|
125
126
|
}));
|
|
126
127
|
}
|
|
127
128
|
else {
|
|
128
129
|
gurads.forEach((guard) => txb.moveCall({
|
|
129
130
|
target: protocol_1.PROTOCOL.RewardFn('guard_add'),
|
|
130
|
-
arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, guard.guard), txb.pure(guard.portions, bcs_1.BCS.
|
|
131
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, guard.guard), txb.pure(guard.portions, bcs_1.BCS.U8), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
131
132
|
typeArguments: [reward_type]
|
|
132
133
|
}));
|
|
133
134
|
}
|
|
@@ -192,7 +193,7 @@ function allow_repeat_claim(reward_type, txb, reward, permission, allow_repeat_c
|
|
|
192
193
|
}
|
|
193
194
|
else {
|
|
194
195
|
txb.moveCall({
|
|
195
|
-
target: protocol_1.PROTOCOL.RewardFn('
|
|
196
|
+
target: protocol_1.PROTOCOL.RewardFn('allow_repeat_claim'),
|
|
196
197
|
arguments: [(0, protocol_1.TXB_OBJECT)(txb, reward), (0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure(allow_repeat_claim, bcs_1.BCS.BOOL)],
|
|
197
198
|
typeArguments: [reward_type]
|
|
198
199
|
});
|
package/dist/service.js
CHANGED
|
@@ -539,16 +539,20 @@ function service_discount_transfer(pay_type, txb, service, permission, discount_
|
|
|
539
539
|
if (passport) {
|
|
540
540
|
txb.moveCall({
|
|
541
541
|
target: protocol_1.PROTOCOL.ServiceFn('dicscount_create_with_passport'),
|
|
542
|
-
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(discount.discount.name), txb.pure(discount.discount.type, bcs_1.BCS.U8),
|
|
543
|
-
|
|
542
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(discount.discount.name), txb.pure(discount.discount.type, bcs_1.BCS.U8),
|
|
543
|
+
txb.pure(discount.discount.off, bcs_1.BCS.U64), price_greater, time_start,
|
|
544
|
+
txb.pure(discount.discount.duration_minutes, bcs_1.BCS.U64), txb.pure(discount.count, bcs_1.BCS.U64),
|
|
545
|
+
(0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure(discount.receiver, bcs_1.BCS.ADDRESS), txb.object(protocol_1.CLOCK_OBJECT)],
|
|
544
546
|
typeArguments: [pay_type]
|
|
545
547
|
});
|
|
546
548
|
}
|
|
547
549
|
else {
|
|
548
550
|
txb.moveCall({
|
|
549
551
|
target: protocol_1.PROTOCOL.ServiceFn('dicscount_create'),
|
|
550
|
-
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(discount.discount.name), txb.pure(discount.discount.type, bcs_1.BCS.U8),
|
|
551
|
-
|
|
552
|
+
arguments: [(0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(discount.discount.name), txb.pure(discount.discount.type, bcs_1.BCS.U8),
|
|
553
|
+
txb.pure(discount.discount.off, bcs_1.BCS.U64), price_greater, time_start,
|
|
554
|
+
txb.pure(discount.discount.duration_minutes, bcs_1.BCS.U64), txb.pure(discount.count, bcs_1.BCS.U64),
|
|
555
|
+
(0, protocol_1.TXB_OBJECT)(txb, permission), txb.pure(discount.receiver, bcs_1.BCS.ADDRESS), txb.object(protocol_1.CLOCK_OBJECT)],
|
|
552
556
|
typeArguments: [pay_type]
|
|
553
557
|
});
|
|
554
558
|
}
|
|
@@ -565,7 +569,7 @@ function service_withdraw(pay_type, txb, service, permission, order, passport) {
|
|
|
565
569
|
if (passport) {
|
|
566
570
|
txb.moveCall({
|
|
567
571
|
target: protocol_1.PROTOCOL.ServiceFn('withdraw_with_passport'),
|
|
568
|
-
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, order),
|
|
572
|
+
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, service), (0, protocol_1.TXB_OBJECT)(txb, order), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
569
573
|
typeArguments: [pay_type]
|
|
570
574
|
});
|
|
571
575
|
}
|
package/dist/util.js
CHANGED
|
@@ -145,11 +145,14 @@ function stringToUint8Array(str) {
|
|
|
145
145
|
}
|
|
146
146
|
exports.stringToUint8Array = stringToUint8Array;
|
|
147
147
|
function numToUint8Array(num) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
if (!num)
|
|
149
|
+
return new Uint8Array(0);
|
|
150
|
+
const a = [];
|
|
151
|
+
a.unshift(num & 255);
|
|
152
|
+
while (num >= 256) {
|
|
153
|
+
num = num >>> 8;
|
|
154
|
+
a.unshift(num & 255);
|
|
155
|
+
}
|
|
156
|
+
return new Uint8Array(a);
|
|
154
157
|
}
|
|
155
158
|
exports.numToUint8Array = numToUint8Array;
|
package/package.json
CHANGED
package/src/guard.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { TransactionBlock, Inputs, type TransactionResult } from '@mysten/sui.js
|
|
|
3
3
|
import { BCS, getSuiMoveConfig, toHEX, fromHEX, BcsReader } from '@mysten/bcs';
|
|
4
4
|
import { PROTOCOL, GuardAddress, FnCallType, Data_Type, MODULES, ContextType, OBJECTS_TYPE,
|
|
5
5
|
OBJECTS_TYPE_PREFIX, Query_Param, IsValidDesription, ValueType, OperatorType} from './protocol';
|
|
6
|
-
import { concatenate, array_equal, ulebDecode, array_unique } from './
|
|
7
|
-
import { stringToUint8Array } from './
|
|
6
|
+
import { concatenate, array_equal, ulebDecode, array_unique } from './utils';
|
|
7
|
+
import { stringToUint8Array } from './utils';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
export const MAX_SENSE_COUNT = 16;
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
export * from './protocol'
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
|
|
12
|
-
export
|
|
2
|
+
export * from './passport'
|
|
3
|
+
export { demand, demand_expand_time, demand_refund, demand_set_description, demand_set_guard, demand_yes, deposit as demand_deposit,
|
|
4
|
+
destroy as demand_destroy, launch as demand_launch, present, change_permission as demand_change_permission,
|
|
5
|
+
MAX_EARNEST_COUNT, MAX_PRESENTERS_COUNT} from './demand'
|
|
6
|
+
export { machine, machine_add_node, machine_add_node2, machine_add_repository, machine_clone, machine_pause, machine_publish,
|
|
7
|
+
machine_remove_node, machine_remove_repository, machine_set_description, machine_set_endpoint, MachineNodeObject, Machine_Forward,
|
|
8
|
+
Machine_Node, Machine_Node_Pair, launch as machine_launch, destroy as machine_destroy, change_permission as machine_change_permission,
|
|
9
|
+
INITIAL_NODE_NAME, namedOperator_ORDER_PAYER } from './machine'
|
|
10
|
+
export { progress, ProgressNext, ParentProgress, progress_bind_task, progress_parent, progress_set_context_repository, progress_unhold,
|
|
11
|
+
hold, progress_set_namedOperator, MAX_NAMED_OPERATOR_COUNT, next } from './progress'
|
|
12
|
+
export { service, service_add_refund_guards, service_add_sale, service_add_stock, service_add_withdraw_guards, service_clone,
|
|
13
|
+
service_change_order_required_pubkey, service_change_required_pubkey, service_remove_customer_required, service_discount_transfer,
|
|
14
|
+
service_pause, service_publish, service_reduce_stock, service_remove_refund_guards, service_remove_sales, service_remove_withdraw_guards,
|
|
15
|
+
service_repository_add, service_repository_remove, service_set_buy_guard, service_set_customer_required, service_set_description, service_set_endpoint,
|
|
16
|
+
service_set_machine, service_set_payee, service_set_price, service_set_stock, service_withdraw, Service_Buy, Service_Discount, Service_Buy_RequiredInfo,
|
|
17
|
+
Service_Discount_Type, Service_Guard_Percent, Service_Sale, order_bind_service_machine, buy, change_permission as service_change_permission,
|
|
18
|
+
update_order_required_info, launch as service_launch, MAX_DISCOUNT_RECEIVER_COUNT, MAX_DISCOUNT_COUNT_ONCE} from './service'
|
|
19
|
+
export { reward, reward_add_guard, reward_expand_time, reward_lock_guards, reward_refund, reward_remove_guard, reward_set_description,
|
|
20
|
+
launch as reward_launch, destroy as reward_destroy, deposit as reward_deposit, RewardGuardPortions, CoinReward, MAX_PORTIONS_COUNT,
|
|
21
|
+
change_permission as reward_change_permission} from './reward'
|
|
22
|
+
export { array_unique, array_equal, concatenate, Bcs, Object_Type_Extra, objectids_from_response, stringToUint8Array } from './utils'
|
|
23
|
+
export { permission, PermissionIndex, PermissionIndexType, Permission_Entity, Permission_Index, IsValidPermissionIndex, MAX_PERMISSION_INDEX_COUNT,
|
|
24
|
+
add_admin, add_entity, remove_admin, remove_entity, remove_index, MAX_ADMIN_COUNT, MAX_ENTITY_COUNT, change_owner, destroy as permission_destroy,
|
|
25
|
+
launch as permission_launch } from './permission'
|
|
26
|
+
export { Guard_Creation, Guard_Sense, Guard_Sense_Binder, launch as guard_launch, QUERIES, QUERIES_Type} from './guard'
|
|
27
|
+
export { repository, remove, repository_add_policies, repository_remove_policies, repository_set_description, repository_set_policy_description,
|
|
28
|
+
repository_set_policy_mode, repository_set_policy_permission, launch as repository_launch, destroy as repository_destroy,
|
|
29
|
+
Repository_Policy, Repository_Policy_Data, Repository_Policy_Mode, Repository_Value, change_permission as repository_change_permission,} from './repository'
|
|
30
|
+
export { vote, vote_add_guard, vote_add_option, vote_expand_deadline, vote_lock_deadline, vote_lock_guard, vote_open_voting,
|
|
31
|
+
vote_remove_guard, vote_remove_option, vote_set_description, vote_set_max_choice_count, vote_set_reference, VoteOption,
|
|
32
|
+
launch as vote_launch, destroy as vote_destroy, change_permission as vote_change_permission } from './vote'
|
package/src/machine.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BCS } from '@mysten/bcs';
|
|
|
3
3
|
import { PROTOCOL, FnCallType, PermissionObject, RepositoryObject, IsValidEndpoint, OptionNone, IsValidDesription, PassportObject,
|
|
4
4
|
TXB_OBJECT, MachineObject, MachineAddress, IsValidArray, IsValidAddress, IsValidName, IsValidName_AllowEmpty, GuardObject,
|
|
5
5
|
IsValidInt, IsValidUint, IsValidObjects} from './protocol';
|
|
6
|
-
import { BCS_CONVERT, array_unique } from './
|
|
6
|
+
import { BCS_CONVERT, array_unique } from './utils'
|
|
7
7
|
import { IsValidPermissionIndex, PermissionIndexType } from './permission';
|
|
8
8
|
|
|
9
9
|
|
package/src/passport.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SuiObjectResponse, SuiObjectDataOptions } from '@mysten/sui.js/client';
|
|
2
2
|
import { TransactionBlock, TransactionResult, type TransactionObjectInput, Inputs } from '@mysten/sui.js/transactions';
|
|
3
3
|
import { PROTOCOL, FnCallType, CLOCK_OBJECT, Query_Param, OBJECTS_TYPE, OBJECTS_TYPE_PREFIX, PassportObject, GuardObject, TXB_OBJECT} from './protocol';
|
|
4
|
-
import { parse_object_type, array_unique } from './
|
|
4
|
+
import { parse_object_type, array_unique } from './utils';
|
|
5
5
|
import { rpc_sense_objects_fn } from './guard';
|
|
6
6
|
|
|
7
7
|
export const MAX_GUARD_COUNT = 8;
|
|
@@ -55,8 +55,6 @@ export function verify(txb:TransactionBlock, guards:string[], passport_queries:G
|
|
|
55
55
|
if (!guards || passport_queries.length == 0 || passport_queries.length > MAX_GUARD_COUNT) {
|
|
56
56
|
return false;
|
|
57
57
|
}
|
|
58
|
-
console.log(guards)
|
|
59
|
-
console.log(passport_queries)
|
|
60
58
|
|
|
61
59
|
var passport = txb.moveCall({
|
|
62
60
|
target: PROTOCOL.PassportFn('new') as FnCallType,
|
|
@@ -65,7 +63,6 @@ export function verify(txb:TransactionBlock, guards:string[], passport_queries:G
|
|
|
65
63
|
|
|
66
64
|
// add others guards, if any
|
|
67
65
|
for (let i = 1; i < guards.length; i++) {
|
|
68
|
-
console.log('dfdfdf')
|
|
69
66
|
txb.moveCall({
|
|
70
67
|
target:PROTOCOL.PassportFn('guard_add') as FnCallType,
|
|
71
68
|
arguments:[passport, TXB_OBJECT(txb, guards[i])]
|
package/src/permission.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { TransactionBlock, Inputs, type TransactionResult } from '@mysten/sui.js
|
|
|
2
2
|
import { BCS } from '@mysten/bcs';
|
|
3
3
|
import { FnCallType, PROTOCOL, TxbObject, PermissionObject, PermissionAddress, TXB_OBJECT, IsValidDesription,
|
|
4
4
|
IsValidObjects, IsValidAddress, IsValidArray, GuardObject, IsValidUint} from './protocol';
|
|
5
|
-
import { array_unique } from './
|
|
5
|
+
import { array_unique } from './utils';
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
export const MAX_ADMIN_COUNT = 64;
|
package/src/progress.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BCS } from '@mysten/bcs';
|
|
|
3
3
|
import { FnCallType, PROTOCOL, PermissionObject, RepositoryObject, PassportObject, MachineObject, TXB_OBJECT,
|
|
4
4
|
ProgressObject, ProgressAddress, IsValidName, IsValidAddress, IsValidArray, OptionNone, IsValidObjects,
|
|
5
5
|
IsValidInt} from './protocol';
|
|
6
|
-
import { BCS_CONVERT, array_unique } from './
|
|
6
|
+
import { BCS_CONVERT, array_unique } from './utils'
|
|
7
7
|
|
|
8
8
|
export const MAX_NAMED_OPERATOR_COUNT = 100;
|
|
9
9
|
|
package/src/protocol.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { SuiClient, SuiObjectResponse, SuiObjectDataOptions, SuiTransactionBlock
|
|
|
3
3
|
import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';
|
|
4
4
|
import { BCS, getSuiMoveConfig, toHEX, fromHEX, BcsReader } from '@mysten/bcs';
|
|
5
5
|
import { TransactionBlock, Inputs, type TransactionResult, type TransactionArgument } from '@mysten/sui.js/transactions';
|
|
6
|
-
import { capitalize } from './
|
|
6
|
+
import { capitalize } from './utils'
|
|
7
7
|
|
|
8
8
|
export const MAX_DESCRIPTION_LENGTH = 1024;
|
|
9
9
|
export const MAX_NAME_LENGTH = 64;
|
package/src/repository.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { FnCallType, PROTOCOL, ValueType, IsValidDesription, IsValidAddress, IsV
|
|
|
4
4
|
RepositoryObject, RepositoryAddress, PermissionObject, TXB_OBJECT, PassportObject, IsValidObjects,
|
|
5
5
|
IsValidInt} from './protocol';
|
|
6
6
|
import { IsValidPermissionIndex, PermissionIndexType } from './permission'
|
|
7
|
-
import { BCS_CONVERT, array_unique } from './
|
|
7
|
+
import { BCS_CONVERT, array_unique } from './utils';
|
|
8
8
|
|
|
9
9
|
export const MAX_POLICY_COUNT = 1000;
|
|
10
10
|
export const MAX_KEY_LENGTH = 128;
|
package/src/reward.ts
CHANGED
|
@@ -2,10 +2,15 @@ import { TransactionBlock, type TransactionResult } from '@mysten/sui.js/transac
|
|
|
2
2
|
import { BCS} from '@mysten/bcs';
|
|
3
3
|
import { CLOCK_OBJECT, FnCallType, GuardObject, IsValidAddress, IsValidArgType, IsValidArray, IsValidDesription, IsValidObjects, IsValidUint, PROTOCOL, PassportObject, PermissionObject,
|
|
4
4
|
RewardAddress, RewardObject, TXB_OBJECT} from './protocol';
|
|
5
|
-
import { array_unique } from './
|
|
5
|
+
import { array_unique } from './utils';
|
|
6
6
|
|
|
7
7
|
export type Reward = TransactionResult;
|
|
8
8
|
export type CoinReward = TransactionResult;
|
|
9
|
+
export type RewardGuardPortions = {
|
|
10
|
+
guard:GuardObject;
|
|
11
|
+
portions:number;
|
|
12
|
+
}
|
|
13
|
+
export const MAX_PORTIONS_COUNT = 255;
|
|
9
14
|
|
|
10
15
|
export function reward(reward_type:string, txb:TransactionBlock, permission:PermissionObject, description:string,
|
|
11
16
|
minutes_duration:number, passport?:PassportObject) : RewardObject | boolean {
|
|
@@ -90,11 +95,6 @@ export function reward_expand_time(reward_type:string, txb:TransactionBlock, rew
|
|
|
90
95
|
}
|
|
91
96
|
return true
|
|
92
97
|
}
|
|
93
|
-
export type RewardGuardPortions = {
|
|
94
|
-
guard:GuardObject;
|
|
95
|
-
portions:number;
|
|
96
|
-
}
|
|
97
|
-
export const MAX_PORTIONS_COUNT = 255;
|
|
98
98
|
|
|
99
99
|
export function reward_add_guard(reward_type:string, txb:TransactionBlock, reward:RewardObject,
|
|
100
100
|
permission:PermissionObject, gurads:RewardGuardPortions[], passport?:PassportObject) : boolean {
|
package/src/service.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TransactionBlock, type TransactionResult } from '@mysten/sui.js/transactions';
|
|
2
2
|
import { BCS } from '@mysten/bcs';
|
|
3
|
-
import { BCS_CONVERT, array_unique } from './
|
|
3
|
+
import { BCS_CONVERT, array_unique } from './utils'
|
|
4
4
|
import { CLOCK_OBJECT, FnCallType, GuardObject, PROTOCOL, PassportObject, PermissionObject,
|
|
5
5
|
RepositoryObject, MachineObject, ServiceAddress, ServiceObject, IsValidObjects, IsValidArgType, IsValidDesription,
|
|
6
6
|
IsValidAddress, IsValidEndpoint, OptionNone, TXB_OBJECT, IsValidUint, IsValidInt, IsValidName, DiscountObject,
|
|
@@ -450,8 +450,8 @@ export type Service_Discount = {
|
|
|
450
450
|
time_start?: number; // current time if undefined
|
|
451
451
|
price_greater?: number;
|
|
452
452
|
}
|
|
453
|
-
const MAX_DISCOUNT_COUNT_ONCE = 200;
|
|
454
|
-
const MAX_DISCOUNT_RECEIVER_COUNT = 200;
|
|
453
|
+
export const MAX_DISCOUNT_COUNT_ONCE = 200;
|
|
454
|
+
export const MAX_DISCOUNT_RECEIVER_COUNT = 200;
|
|
455
455
|
|
|
456
456
|
export type DicountDispatch = {
|
|
457
457
|
receiver: string;
|
package/src/{util.ts → utils.ts}
RENAMED
|
@@ -2,10 +2,7 @@ import { SuiTransactionBlockResponse, SuiObjectChange } from '@mysten/sui.js/cli
|
|
|
2
2
|
import { bcs, BCS, toHEX, fromHEX, getSuiMoveConfig } from '@mysten/bcs';
|
|
3
3
|
import { PROTOCOL, MODULES, OBJECTS_TYPE } from './protocol';
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
value: number;
|
|
7
|
-
length: number;
|
|
8
|
-
} {
|
|
5
|
+
export const ulebDecode = (arr: number[] | Uint8Array) : {value: number, length: number} => {
|
|
9
6
|
let total = 0;
|
|
10
7
|
let shift = 0;
|
|
11
8
|
let len = 0;
|
|
@@ -27,7 +24,7 @@ export function ulebDecode(arr: number[] | Uint8Array): {
|
|
|
27
24
|
};
|
|
28
25
|
}
|
|
29
26
|
|
|
30
|
-
export
|
|
27
|
+
export const concatenate = (resultConstructor:any, ...arrays:any[]) => {
|
|
31
28
|
let totalLength = 0;
|
|
32
29
|
for (const arr of arrays) {
|
|
33
30
|
totalLength += arr.length;
|
|
@@ -41,7 +38,7 @@ export function concatenate(resultConstructor:any, ...arrays:any[]) {
|
|
|
41
38
|
return result;
|
|
42
39
|
}
|
|
43
40
|
|
|
44
|
-
export
|
|
41
|
+
export const array_equal = (arr1: any[], arr2: any[]) => {
|
|
45
42
|
// Array.some(): 有一项不满足,返回false
|
|
46
43
|
if (arr1.length !== arr2.length) {
|
|
47
44
|
return false;
|
|
@@ -49,7 +46,7 @@ export function array_equal(arr1: any[], arr2: any[]) {
|
|
|
49
46
|
return !arr1.some((item) => !arr2.includes(item));
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
export
|
|
49
|
+
export const array_unique = (arr:any[]) : any[] => {
|
|
53
50
|
var newArr = [];
|
|
54
51
|
for(var i = 0; i < arr.length; i++) {
|
|
55
52
|
if(newArr.indexOf(arr[i]) == -1) {
|
package/src/vote.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BCS } from '@mysten/bcs';
|
|
|
3
3
|
import { CLOCK_OBJECT, FnCallType, PROTOCOL, PassportObject, PermissionObject, GuardObject, VoteAddress,
|
|
4
4
|
VoteObject, IsValidObjects, IsValidDesription, IsValidUint, IsValidAddress, OptionNone, TXB_OBJECT,
|
|
5
5
|
IsValidArray, IsValidName} from './protocol';
|
|
6
|
-
import { BCS_CONVERT, array_unique } from './
|
|
6
|
+
import { BCS_CONVERT, array_unique } from './utils';
|
|
7
7
|
|
|
8
8
|
export const MAX_AGREES_COUNT = 200;
|
|
9
9
|
export const MAX_CHOICE_COUNT = 200;
|