wowok 1.1.4 → 1.2.0
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/README.md +7 -2
- package/dist/demand.d.ts +6 -6
- package/dist/demand.d.ts.map +1 -1
- package/dist/demand.js +38 -38
- package/dist/entity.d.ts +23 -0
- package/dist/entity.d.ts.map +1 -0
- package/dist/entity.js +71 -0
- package/dist/exception.d.ts +2 -1
- package/dist/exception.d.ts.map +1 -1
- package/dist/exception.js +1 -0
- package/dist/guard.d.ts +12 -12
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +66 -58
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/machine.d.ts.map +1 -1
- package/dist/machine.js +1 -1
- package/dist/passport.d.ts +16 -9
- package/dist/passport.d.ts.map +1 -1
- package/dist/passport.js +69 -59
- package/dist/permission.d.ts.map +1 -1
- package/dist/permission.js +1 -1
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +10 -1
- package/dist/protocol.d.ts +19 -8
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +31 -26
- package/dist/repository.d.ts.map +1 -1
- package/dist/repository.js +11 -1
- package/dist/resource.d.ts +16 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +83 -0
- package/dist/reward.d.ts.map +1 -1
- package/dist/reward.js +10 -1
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +11 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +10 -0
- package/dist/vote.d.ts.map +1 -1
- package/dist/vote.js +1 -1
- package/dist/wowok.d.ts +12 -0
- package/dist/wowok.d.ts.map +1 -0
- package/dist/wowok.js +48 -0
- package/package.json +10 -3
- package/src/demand.ts +42 -42
- package/src/entity.ts +83 -0
- package/src/exception.ts +1 -0
- package/src/guard.ts +71 -57
- package/src/index.ts +11 -8
- package/src/machine.ts +3 -2
- package/src/passport.ts +70 -65
- package/src/permission.ts +5 -4
- package/src/progress.ts +11 -3
- package/src/protocol.ts +41 -31
- package/src/repository.ts +12 -2
- package/src/resource.ts +90 -0
- package/src/reward.ts +11 -2
- package/src/service.ts +12 -1
- package/src/utils.ts +12 -1
- package/src/vote.ts +2 -1
- package/src/wowok.ts +56 -0
package/dist/passport.js
CHANGED
|
@@ -15,27 +15,15 @@ export class GuardParser {
|
|
|
15
15
|
this.guards = guards.map(g => protocol.CurrentSession().object(g));
|
|
16
16
|
}
|
|
17
17
|
guardlist = () => { return this.guard_list; };
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
ERROR(Errors.IsValidAddress, 'GuardObject guard');
|
|
22
|
-
}
|
|
23
|
-
let res = await protocol.Query_Raw([guard]);
|
|
24
|
-
if (res.length == 0 || !res[0].data || res[0].data?.objectId != guard) {
|
|
25
|
-
ERROR(Errors.Fail, 'GuardObject query error');
|
|
26
|
-
}
|
|
27
|
-
console.log(res[0].data?.content);
|
|
28
|
-
let content = res[0].data.content;
|
|
29
|
-
if (content?.type != protocol.Package() + '::guard::Guard') {
|
|
30
|
-
ERROR(Errors.Fail, 'GuardObject object invalid');
|
|
31
|
-
}
|
|
32
|
-
let variables = [];
|
|
33
|
-
content.fields.variables.forEach((v) => {
|
|
18
|
+
static DeGuardObject_FromData = (guard_constants, guard_input_bytes) => {
|
|
19
|
+
let constants = [];
|
|
20
|
+
guard_constants.forEach((c) => {
|
|
34
21
|
let value;
|
|
35
|
-
|
|
22
|
+
let v = c?.fields ?? c; // graphql dosnot 'fields', but rpcall has.
|
|
23
|
+
switch (v.type) {
|
|
36
24
|
case ContextType.TYPE_WITNESS_ID:
|
|
37
25
|
case ValueType.TYPE_ADDRESS:
|
|
38
|
-
value = '0x' + Bcs.getInstance().de(BCS.ADDRESS, Uint8Array.from(v.
|
|
26
|
+
value = '0x' + Bcs.getInstance().de(BCS.ADDRESS, Uint8Array.from(v.value)).toString();
|
|
39
27
|
break;
|
|
40
28
|
case ValueType.TYPE_BOOL:
|
|
41
29
|
case ValueType.TYPE_U8:
|
|
@@ -55,18 +43,19 @@ export class GuardParser {
|
|
|
55
43
|
case ValueType.TYPE_OPTION_U64:
|
|
56
44
|
case ValueType.TYPE_OPTION_U256:
|
|
57
45
|
case ValueType.TYPE_VEC_U256:
|
|
58
|
-
let de = SER_VALUE.find(s => s.type == v.
|
|
46
|
+
let de = SER_VALUE.find(s => s.type == v.type);
|
|
59
47
|
if (!de)
|
|
60
48
|
ERROR(Errors.Fail, 'GuardObject de error');
|
|
61
|
-
value = Bcs.getInstance().de(de.name, Uint8Array.from(v.
|
|
49
|
+
value = Bcs.getInstance().de(de.name, Uint8Array.from(v.value));
|
|
62
50
|
break;
|
|
63
51
|
default:
|
|
64
|
-
ERROR(Errors.Fail, 'GuardObject
|
|
52
|
+
ERROR(Errors.Fail, 'GuardObject constant type invalid');
|
|
65
53
|
}
|
|
66
|
-
|
|
54
|
+
constants.push({ identifier: v.identifier, type: v.type, value: value });
|
|
67
55
|
});
|
|
68
|
-
console.log(
|
|
69
|
-
let
|
|
56
|
+
// console.log(constants)
|
|
57
|
+
let bytes = Uint8Array.from(guard_input_bytes);
|
|
58
|
+
let arr = [].slice.call(bytes.reverse());
|
|
70
59
|
let data = [];
|
|
71
60
|
while (arr.length > 0) {
|
|
72
61
|
let type = arr.shift();
|
|
@@ -88,10 +77,10 @@ export class GuardParser {
|
|
|
88
77
|
case OperatorType.TYPE_LOGIC_AND:
|
|
89
78
|
case OperatorType.TYPE_LOGIC_OR:
|
|
90
79
|
break;
|
|
91
|
-
case ContextType.
|
|
80
|
+
case ContextType.TYPE_CONSTANT:
|
|
92
81
|
identifier = arr.shift(); // identifier
|
|
93
82
|
break;
|
|
94
|
-
case ContextType.TYPE_WITNESS_ID: // add to
|
|
83
|
+
case ContextType.TYPE_WITNESS_ID: // add to constant
|
|
95
84
|
case ValueType.TYPE_ADDRESS:
|
|
96
85
|
value = '0x' + Bcs.getInstance().de(BCS.ADDRESS, Uint8Array.from(arr)).toString();
|
|
97
86
|
arr.splice(0, 32); // address
|
|
@@ -161,18 +150,18 @@ export class GuardParser {
|
|
|
161
150
|
value = addr;
|
|
162
151
|
cmd = arr.shift(); // cmd
|
|
163
152
|
}
|
|
164
|
-
else if (t[0] == ContextType.
|
|
153
|
+
else if (t[0] == ContextType.TYPE_CONSTANT) {
|
|
165
154
|
let id = arr.splice(0, 1); // key
|
|
166
|
-
let v =
|
|
155
|
+
let v = constants.find((v) => (v.identifier == id[0]) &&
|
|
167
156
|
((v.type == ValueType.TYPE_ADDRESS) || (v.type == ContextType.TYPE_WITNESS_ID)));
|
|
168
157
|
if (!v) {
|
|
169
|
-
ERROR(Errors.Fail, 'GuardObject: indentifier not in
|
|
158
|
+
ERROR(Errors.Fail, 'GuardObject: indentifier not in constant');
|
|
170
159
|
}
|
|
171
160
|
identifier = id[0];
|
|
172
161
|
cmd = arr.shift(); // cmd
|
|
173
162
|
}
|
|
174
163
|
else {
|
|
175
|
-
ERROR(Errors.Fail, 'GuardObject:
|
|
164
|
+
ERROR(Errors.Fail, 'GuardObject: constant type invalid');
|
|
176
165
|
}
|
|
177
166
|
break;
|
|
178
167
|
case ValueType.TYPE_OPTION_ADDRESS:
|
|
@@ -216,17 +205,35 @@ export class GuardParser {
|
|
|
216
205
|
}
|
|
217
206
|
data.push({ type: type, value: value, cmd: cmd, identifier: identifier, child: [] });
|
|
218
207
|
}
|
|
219
|
-
console.log(data);
|
|
208
|
+
// console.log(data);
|
|
220
209
|
if (!data || data.length == 0)
|
|
221
210
|
ERROR(Errors.Fail, 'GuardObject: data parsed error');
|
|
222
211
|
let stack = [];
|
|
223
212
|
data.forEach((d) => {
|
|
224
|
-
this.ResolveData(
|
|
225
|
-
console.log('---------------------------------');
|
|
226
|
-
console.log(stack);
|
|
213
|
+
this.ResolveData(constants, stack, d);
|
|
227
214
|
});
|
|
215
|
+
if (stack.length != 1) {
|
|
216
|
+
ERROR(Errors.Fail, 'GuardObject: parse error');
|
|
217
|
+
}
|
|
218
|
+
return { object: stack.pop(), constant: constants };
|
|
228
219
|
};
|
|
229
|
-
|
|
220
|
+
/// convert guard-on-chain to js object
|
|
221
|
+
static DeGuardObject = async (protocol, guard) => {
|
|
222
|
+
if (!IsValidAddress(guard)) {
|
|
223
|
+
ERROR(Errors.IsValidAddress, 'GuardObject guard');
|
|
224
|
+
}
|
|
225
|
+
let res = await protocol.Query_Raw([guard]);
|
|
226
|
+
if (res.length == 0 || !res[0].data || res[0].data?.objectId != guard) {
|
|
227
|
+
ERROR(Errors.Fail, 'GuardObject query error');
|
|
228
|
+
}
|
|
229
|
+
// console.log(res[0].data?.content);
|
|
230
|
+
let content = res[0].data.content;
|
|
231
|
+
if (content?.type != protocol.Package() + '::guard::Guard') {
|
|
232
|
+
ERROR(Errors.Fail, 'GuardObject object invalid');
|
|
233
|
+
}
|
|
234
|
+
return GuardParser.DeGuardObject_FromData(content.fields.constants, content.fields.input.fields.bytes);
|
|
235
|
+
};
|
|
236
|
+
static ResolveData = (constants, stack, current) => {
|
|
230
237
|
switch (current.type) {
|
|
231
238
|
case OperatorType.TYPE_LOGIC_ALWAYS_TRUE:
|
|
232
239
|
current.ret_type = ValueType.TYPE_BOOL;
|
|
@@ -314,7 +321,7 @@ export class GuardParser {
|
|
|
314
321
|
let r = Guard.GetCmd(current.cmd);
|
|
315
322
|
if (!r)
|
|
316
323
|
ERROR(Errors.Fail, 'OperateParamCount: cmd not supported ' + current.type);
|
|
317
|
-
|
|
324
|
+
current.ret_type = r[4];
|
|
318
325
|
if (stack.length < r[3].length)
|
|
319
326
|
ERROR(Errors.Fail, 'OperateParamCount: cmd param lost ' + current.type);
|
|
320
327
|
r[3].forEach((e) => {
|
|
@@ -345,7 +352,6 @@ export class GuardParser {
|
|
|
345
352
|
case ValueType.TYPE_OPTION_U256:
|
|
346
353
|
case ValueType.TYPE_OPTION_U64:
|
|
347
354
|
case ValueType.TYPE_OPTION_U8:
|
|
348
|
-
case ContextType.TYPE_WITNESS_ID: /// notice!!
|
|
349
355
|
current.ret_type = current.type;
|
|
350
356
|
stack.push(current);
|
|
351
357
|
return;
|
|
@@ -354,14 +360,18 @@ export class GuardParser {
|
|
|
354
360
|
stack.push(current);
|
|
355
361
|
return;
|
|
356
362
|
case ContextType.TYPE_SIGNER:
|
|
363
|
+
case ContextType.TYPE_WITNESS_ID: /// notice!! convert witness type to address type
|
|
357
364
|
current.ret_type = ValueType.TYPE_ADDRESS;
|
|
358
365
|
stack.push(current);
|
|
359
366
|
return;
|
|
360
|
-
case ContextType.
|
|
361
|
-
let v =
|
|
367
|
+
case ContextType.TYPE_CONSTANT:
|
|
368
|
+
let v = constants.find((e) => e.identifier == current?.identifier);
|
|
362
369
|
if (!v)
|
|
363
370
|
ERROR(Errors.Fail, 'OperateParamCount: identifier invalid ' + current.type);
|
|
364
371
|
current.ret_type = v?.type;
|
|
372
|
+
if (v?.type == ContextType.TYPE_WITNESS_ID) {
|
|
373
|
+
current.ret_type = ValueType.TYPE_ADDRESS;
|
|
374
|
+
}
|
|
365
375
|
stack.push(current);
|
|
366
376
|
return;
|
|
367
377
|
}
|
|
@@ -382,8 +392,8 @@ export class GuardParser {
|
|
|
382
392
|
let index = protocol.WOWOK_OBJECTS_TYPE().findIndex(v => { return v.includes('guard::Guard') && v == c.type; });
|
|
383
393
|
if (index == -1)
|
|
384
394
|
return;
|
|
385
|
-
let info = { id: c.fields.id.id, query_list: [],
|
|
386
|
-
me.
|
|
395
|
+
let info = { id: c.fields.id.id, query_list: [], constant: [], input_witness: [] };
|
|
396
|
+
me.parse_constant(info, c.fields.constants);
|
|
387
397
|
if (c.fields.input.type == (protocol.Package() + '::bcs::BCS')) {
|
|
388
398
|
me.parse_bcs(info, Uint8Array.from(c.fields.input.fields.bytes));
|
|
389
399
|
}
|
|
@@ -391,12 +401,12 @@ export class GuardParser {
|
|
|
391
401
|
});
|
|
392
402
|
return me;
|
|
393
403
|
};
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if (v.type == (this.protocol.Package() + '::guard::
|
|
404
|
+
parse_constant = (info, constants) => {
|
|
405
|
+
constants.forEach((v) => {
|
|
406
|
+
if (v.type == (this.protocol.Package() + '::guard::Constant')) {
|
|
397
407
|
// ValueType.TYPE_ADDRESS: Query_Cmd maybe used the address, so save it for using
|
|
398
408
|
if (v.fields.type == ContextType.TYPE_WITNESS_ID || v.fields.type == ValueType.TYPE_ADDRESS) {
|
|
399
|
-
info.
|
|
409
|
+
info.constant.push({ identifier: v.fields.identifier, index: this.get_index(), type: v.fields.type,
|
|
400
410
|
value_or_witness: '0x' + Bcs.getInstance().de(BCS.ADDRESS, Uint8Array.from(v.fields.value)) });
|
|
401
411
|
}
|
|
402
412
|
}
|
|
@@ -422,10 +432,10 @@ export class GuardParser {
|
|
|
422
432
|
case OperatorType.TYPE_LOGIC_AND:
|
|
423
433
|
case OperatorType.TYPE_LOGIC_OR:
|
|
424
434
|
break;
|
|
425
|
-
case ContextType.
|
|
426
|
-
arr.splice(0, 1); // identifier of
|
|
435
|
+
case ContextType.TYPE_CONSTANT:
|
|
436
|
+
arr.splice(0, 1); // identifier of constant
|
|
427
437
|
break;
|
|
428
|
-
case ContextType.TYPE_WITNESS_ID: // add to
|
|
438
|
+
case ContextType.TYPE_WITNESS_ID: // add to constant
|
|
429
439
|
let addr = '0x' + Bcs.getInstance().de(BCS.ADDRESS, Uint8Array.from(arr)).toString();
|
|
430
440
|
arr.splice(0, 32); // address
|
|
431
441
|
info.input_witness.push({ index: this.get_index(), type: ContextType.TYPE_WITNESS_ID, value_or_witness: addr });
|
|
@@ -462,22 +472,22 @@ export class GuardParser {
|
|
|
462
472
|
info.query_list.push({ index: this.get_index(), type: type[0], value_or_witness: addr });
|
|
463
473
|
}
|
|
464
474
|
}
|
|
465
|
-
else if (type[0] == ContextType.
|
|
475
|
+
else if (type[0] == ContextType.TYPE_CONSTANT) {
|
|
466
476
|
let identifer = arr.splice(0, 2); // key + cmd
|
|
467
|
-
let
|
|
477
|
+
let constant = info.constant.find((v) => (v.identifier == identifer[0]) &&
|
|
468
478
|
((v.type == ValueType.TYPE_ADDRESS) || (v.type == ContextType.TYPE_WITNESS_ID)));
|
|
469
|
-
if (!
|
|
470
|
-
ERROR(Errors.Fail, 'indentifier not in
|
|
479
|
+
if (!constant) {
|
|
480
|
+
ERROR(Errors.Fail, 'indentifier not in constant');
|
|
471
481
|
}
|
|
472
|
-
if (
|
|
473
|
-
info.query_list.push(
|
|
482
|
+
if (constant?.type == ValueType.TYPE_ADDRESS) {
|
|
483
|
+
info.query_list.push(constant.value_or_witness);
|
|
474
484
|
}
|
|
475
|
-
else if (
|
|
476
|
-
info.query_list.push({ identifier: identifer[0], type:
|
|
485
|
+
else if (constant?.type == ContextType.TYPE_WITNESS_ID) {
|
|
486
|
+
info.query_list.push({ identifier: identifer[0], type: constant.type, value_or_witness: constant.value_or_witness, index: this.get_index() });
|
|
477
487
|
}
|
|
478
488
|
}
|
|
479
489
|
else {
|
|
480
|
-
ERROR(Errors.Fail, '
|
|
490
|
+
ERROR(Errors.Fail, 'constant type invalid');
|
|
481
491
|
}
|
|
482
492
|
break;
|
|
483
493
|
default:
|
|
@@ -500,7 +510,7 @@ export class GuardParser {
|
|
|
500
510
|
done = async (fill) => {
|
|
501
511
|
let objects = [];
|
|
502
512
|
this.guard_list.forEach((g) => {
|
|
503
|
-
g.
|
|
513
|
+
g.constant.filter(v => v.type == ContextType.TYPE_WITNESS_ID).forEach((q) => {
|
|
504
514
|
objects.push(this.get_object(g.id, q, fill));
|
|
505
515
|
});
|
|
506
516
|
let list = g.query_list.map((q) => {
|
|
@@ -536,7 +546,7 @@ export class GuardParser {
|
|
|
536
546
|
query.push(object);
|
|
537
547
|
});
|
|
538
548
|
res.forEach(q => {
|
|
539
|
-
let r1 = g.
|
|
549
|
+
let r1 = g.constant.find(v => v.future == q.data?.objectId);
|
|
540
550
|
let r2 = g.input_witness.find(v => v.future == q.data?.objectId);
|
|
541
551
|
// not match r1 || r2 means query-cmd, not witness-cmd
|
|
542
552
|
if (r1 || r2) {
|
package/dist/permission.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../src/permission.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,SAAS,EAAoB,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../src/permission.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,SAAS,EAAoB,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAK9G,oBAAY,eAAe;IACvB,UAAU,MAAM;IAChB,8BAA8B,MAAM;IACpC,0BAA0B,MAAM;IAChC,uBAAuB,MAAM;IAC7B,0BAA0B,MAAM;IAChC,iCAAiC,MAAM;IACvC,gCAAgC,MAAM;IACtC,wBAAwB,MAAM;IAC9B,2BAA2B,MAAM;IACjC,8BAA8B,MAAM;IACpC,IAAI,MAAM;IACV,oBAAoB,MAAM;IAC1B,kBAAkB,MAAM;IACxB,cAAc,MAAM;IACpB,iBAAiB,MAAM;IACvB,eAAe,MAAM;IACrB,kBAAkB,MAAM;IACxB,yBAAyB,MAAM;IAC/B,gBAAgB,MAAM;IACtB,kBAAkB,MAAM;IACxB,oBAAoB,MAAM;IAC1B,eAAe,MAAM;IACrB,OAAO,MAAM;IACb,uBAAuB,MAAM;IAC7B,iBAAiB,MAAM;IACvB,iBAAiB,MAAM;IACvB,iBAAiB,MAAM;IACvB,oBAAoB,MAAM;IAC1B,iBAAiB,MAAM;IACvB,sBAAsB,MAAM;IAC5B,yBAAyB,MAAM;IAC/B,2BAA2B,MAAM;IACjC,8BAA8B,MAAO;IACrC,yBAAyB,MAAM;IAC/B,4BAA4B,MAAM;IAClC,iBAAiB,MAAM;IACvB,oBAAoB,MAAM;IAC1B,yBAAyB,MAAM;IAC/B,gBAAg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AI,CAAC,QAAQ,EAAC,QAAQ,EAAE,MAAM,EAAC,SAAS,GAAI,UAAU;IAM7D,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,GAAI,UAAU;IAc9D,MAAM,IAAK,iBAAiB;IAQ5B,OAAO;IAQP,UAAU,CAAC,QAAQ,EAAC,iBAAiB,EAAE;IAwDvC,SAAS,CAAC,cAAc,EAAC,MAAM,EAAE,KAAK,EAAC,mBAAmB,EAAE,KAAK,CAAC,EAAC,WAAW;IAyB9E,YAAY,CAAC,cAAc,EAAC,MAAM,EAAE,KAAK,EAAC,mBAAmB,EAAE;IAe/D,aAAa,CAAC,cAAc,EAAC,MAAM,EAAE;IAYrC,eAAe,CAAC,WAAW,EAAC,MAAM;IAYlC,SAAS,CAAC,KAAK,EAAC,MAAM,EAAE;IAaxB,YAAY,CAAC,KAAK,CAAC,EAAC,MAAM,EAAE,EAAE,SAAS,CAAC,EAAC,OAAO;IAwBhD,YAAY,CAAC,SAAS,EAAC,MAAM;IAY7B,MAAM,CAAC,eAAe,SAAM;IAC5B,MAAM,CAAC,gBAAgB,SAAQ;IAC/B,MAAM,CAAC,0BAA0B,SAAO;IACxC,MAAM,CAAC,uBAAuB,UAAU,MAAM,aAE7C;IAED,MAAM,CAAC,sBAAsB,UAAU,mBAAmB,KAAI,OAAO,CAOpE;CACJ"}
|
package/dist/permission.js
CHANGED
|
@@ -98,10 +98,10 @@ export class Permission {
|
|
|
98
98
|
return p;
|
|
99
99
|
}
|
|
100
100
|
static New(protocol, description) {
|
|
101
|
-
let p = new Permission(protocol);
|
|
102
101
|
if (!IsValidDesription(description)) {
|
|
103
102
|
ERROR(Errors.IsValidDesription);
|
|
104
103
|
}
|
|
104
|
+
let p = new Permission(protocol);
|
|
105
105
|
let txb = protocol.CurrentSession();
|
|
106
106
|
p.object = txb.moveCall({
|
|
107
107
|
target: protocol.PermissionFn('new'),
|
package/dist/progress.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAClF,cAAc,EAAE,eAAe,EAAE,QAAQ,EACzC,SAAS,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAClF,cAAc,EAAE,eAAe,EAAE,QAAQ,EACzC,SAAS,EAAC,MAAM,YAAY,CAAC;AAKjC,MAAM,MAAM,YAAY,GAAG;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;CAC7B,CAAA;AAED,qBAAa,QAAQ;IACjB,SAAS,CAAC,UAAU,mBAAE;IACtB,SAAS,CAAC,OAAO,gBAAC;IAClB,SAAS,CAAC,MAAM,EAAG,SAAS,CAAC;IAC7B,SAAS,CAAC,QAAQ,WAAC;IAEnB,UAAU;IACV,OAAO;IAMP,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAC,QAAQ,EAAE,OAAO,EAAC,aAAa,EAAE,UAAU,EAAC,gBAAgB,EAAE,MAAM,EAAC,SAAS,GAAI,QAAQ;IAK/G,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAC,QAAQ,EAAE,OAAO,EAAC,aAAa,EAAE,UAAU,EAAC,gBAAgB,EAAE,QAAQ,CAAC,EAAC,cAAc,GAAI,QAAQ;IAsBtH,MAAM,IAAK,eAAe;IAQ1B,eAAe,CAAC,MAAM,EAAC,cAAc,EAAE,WAAW,EAAC,YAAY,GAAI,eAAe;IAelF,OAAO;IAgBP,iBAAiB,CAAC,IAAI,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAC,cAAc;IA0B3E,SAAS,CAAC,YAAY,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,cAAc;IAqBvD,sBAAsB,CAAC,UAAU,CAAC,EAAC,gBAAgB,EAAE,QAAQ,CAAC,EAAC,cAAc;IAmC7E,MAAM,CAAC,IAAI,EAAC,YAAY,EAAE,QAAQ,CAAC,EAAC,cAAc;IAsBlD,MAAM,CAAC,MAAM,EAAC,cAAc,EAAE,QAAQ,CAAC,EAAC,cAAc;IAyCtD,IAAI,CAAC,IAAI,EAAC,YAAY,EAAE,oBAAoB,CAAC,EAAC,MAAM,EAAE,MAAM,CAAC,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,cAAc;IAgC9F,IAAI,CAAC,IAAI,EAAC,YAAY,EAAE,IAAI,EAAC,OAAO;IAYpC,MAAM,CAAC,wBAAwB,SAAO;IACtC,MAAM,CAAC,mBAAmB,SAAS,YAAY,aAE9C;CAEJ"}
|
package/dist/progress.js
CHANGED
|
@@ -20,10 +20,10 @@ export class Progress {
|
|
|
20
20
|
return p;
|
|
21
21
|
}
|
|
22
22
|
static New(protocol, machine, permission, passport) {
|
|
23
|
-
let p = new Progress(protocol, machine, permission);
|
|
24
23
|
if (!Protocol.IsValidObjects([machine, permission])) {
|
|
25
24
|
ERROR(Errors.IsValidObjects, 'machine & permission');
|
|
26
25
|
}
|
|
26
|
+
let p = new Progress(protocol, machine, permission);
|
|
27
27
|
let txb = protocol.CurrentSession();
|
|
28
28
|
if (passport) {
|
|
29
29
|
p.object = txb.moveCall({
|
|
@@ -67,6 +67,15 @@ export class Progress {
|
|
|
67
67
|
arguments: [Protocol.TXB_OBJECT(txb, this.object)],
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
+
/* move to: Entity.mark
|
|
71
|
+
mark(like:'like' | 'unlike', resource:Resource) {
|
|
72
|
+
let txb = this.protocol.CurrentSession();
|
|
73
|
+
txb.moveCall({
|
|
74
|
+
target:this.protocol.ProgressFn(like) as FnCallType,
|
|
75
|
+
arguments: [Protocol.TXB_OBJECT(txb, resource.get_object()), Protocol.TXB_OBJECT(txb, this.object)],
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
*/
|
|
70
79
|
set_namedOperator(name, addresses, passport) {
|
|
71
80
|
if (!IsValidName(name)) {
|
|
72
81
|
ERROR(Errors.IsValidName, 'name');
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SuiObjectResponse, SuiObjectDataOptions, SuiTransactionBlockResponseOptions, SuiTransactionBlockResponse } from '@mysten/sui.js/client';
|
|
2
2
|
import { TransactionBlock, TransactionResult } from '@mysten/sui.js/transactions';
|
|
3
|
-
import {
|
|
3
|
+
import { GuardConstant } from './guard';
|
|
4
4
|
export declare enum MODULES {
|
|
5
5
|
machine = "machine",
|
|
6
6
|
node = "node",
|
|
@@ -15,6 +15,8 @@ export declare enum MODULES {
|
|
|
15
15
|
order = "order",
|
|
16
16
|
reward = "reward",
|
|
17
17
|
service = "service",
|
|
18
|
+
resource = "resource",
|
|
19
|
+
entity = "entity",
|
|
18
20
|
wowok = "wowok"
|
|
19
21
|
}
|
|
20
22
|
export type PermissionAddress = TransactionResult;
|
|
@@ -40,7 +42,11 @@ export type DiscountObject = TransactionResult | string;
|
|
|
40
42
|
export type CoinObject = TransactionResult | string;
|
|
41
43
|
export type VoteObject = TransactionResult | string;
|
|
42
44
|
export type VoteAddress = TransactionResult;
|
|
43
|
-
export type
|
|
45
|
+
export type ResourceObject = TransactionResult | string;
|
|
46
|
+
export type ResourceAddress = TransactionResult;
|
|
47
|
+
export type EntityObject = TransactionResult | string;
|
|
48
|
+
export type EntityAddress = TransactionResult;
|
|
49
|
+
export type TxbObject = string | TransactionResult | GuardObject | RepositoryObject | PermissionObject | MachineObject | PassportObject | DemandObject | ServiceObject | RewardObject | OrderObject | DiscountObject | VoteObject | DemandObject | ResourceObject | EntityObject;
|
|
44
50
|
export type WowokObject = TransactionResult;
|
|
45
51
|
export type FnCallType = `${string}::${string}::${string}`;
|
|
46
52
|
export declare enum OperatorType {
|
|
@@ -85,15 +91,16 @@ export declare const IsValidValueType: (type: number) => boolean;
|
|
|
85
91
|
interface ValueTypeString {
|
|
86
92
|
type: ValueType;
|
|
87
93
|
name: string;
|
|
94
|
+
description: string;
|
|
88
95
|
}
|
|
89
96
|
export declare const SER_VALUE: ValueTypeString[];
|
|
90
97
|
export declare enum ContextType {
|
|
91
98
|
TYPE_SIGNER = 60,
|
|
92
99
|
TYPE_CLOCK = 61,
|
|
93
100
|
TYPE_WITNESS_ID = 62,
|
|
94
|
-
|
|
101
|
+
TYPE_CONSTANT = 80
|
|
95
102
|
}
|
|
96
|
-
export type
|
|
103
|
+
export type ConstantType = ValueType | ContextType.TYPE_WITNESS_ID;
|
|
97
104
|
export type Data_Type = ValueType | OperatorType | ContextType;
|
|
98
105
|
export declare enum ENTRYPOINT {
|
|
99
106
|
mainnet = "mainnet",
|
|
@@ -105,13 +112,15 @@ export declare class Protocol {
|
|
|
105
112
|
protected network: string;
|
|
106
113
|
protected package: string;
|
|
107
114
|
protected signer: string;
|
|
108
|
-
protected
|
|
115
|
+
protected wowok_object: string;
|
|
116
|
+
protected entity_object: string;
|
|
109
117
|
protected graphql: string;
|
|
110
118
|
protected txb: TransactionBlock | undefined;
|
|
111
119
|
constructor(network?: ENTRYPOINT);
|
|
112
120
|
UseNetwork(network?: ENTRYPOINT): void;
|
|
113
121
|
Package(): string;
|
|
114
|
-
|
|
122
|
+
WowokObject(): string;
|
|
123
|
+
EntityObject(): string;
|
|
115
124
|
GraphqlUrl(): string;
|
|
116
125
|
NetworkUrl(): string;
|
|
117
126
|
MachineFn: (fn: any) => string;
|
|
@@ -127,6 +136,8 @@ export declare class Protocol {
|
|
|
127
136
|
OrderFn: (fn: any) => string;
|
|
128
137
|
RewardFn: (fn: any) => string;
|
|
129
138
|
ServiceFn: (fn: any) => string;
|
|
139
|
+
ResourceFn: (fn: any) => string;
|
|
140
|
+
EntityFn: (fn: any) => string;
|
|
130
141
|
WowokFn: (fn: any) => string;
|
|
131
142
|
Query: (objects: Query_Param[], options?: SuiObjectDataOptions) => Promise<SuiObjectResponse[]>;
|
|
132
143
|
Query_Raw: (objects: string[], options?: SuiObjectDataOptions) => Promise<SuiObjectResponse[]>;
|
|
@@ -171,9 +182,9 @@ export declare class RpcResultParser {
|
|
|
171
182
|
export type Query_Param = {
|
|
172
183
|
objectid: string;
|
|
173
184
|
callback: (protocol: Protocol, response: SuiObjectResponse, param: Query_Param, option: SuiObjectDataOptions) => void;
|
|
174
|
-
parser?: (result: any[], guardid: string, chain_sense_bsc: Uint8Array,
|
|
185
|
+
parser?: (result: any[], guardid: string, chain_sense_bsc: Uint8Array, constant?: GuardConstant) => boolean;
|
|
175
186
|
data?: any;
|
|
176
|
-
|
|
187
|
+
constants?: GuardConstant;
|
|
177
188
|
};
|
|
178
189
|
export {};
|
|
179
190
|
//# sourceMappingURL=protocol.d.ts.map
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,iBAAiB,EAAE,oBAAoB,EAAE,kCAAkC,EAC3F,2BAA2B,EAAmB,MAAM,uBAAuB,CAAC;AAGhF,OAAO,EAAE,gBAAgB,EAAU,iBAAiB,EAAuB,MAAM,6BAA6B,CAAC;AAE/G,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,oBAAY,OAAO;IACf,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,KA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
MODULES["order"] = "order";
|
|
19
19
|
MODULES["reward"] = "reward";
|
|
20
20
|
MODULES["service"] = "service";
|
|
21
|
+
MODULES["resource"] = "resource";
|
|
22
|
+
MODULES["entity"] = "entity";
|
|
21
23
|
MODULES["wowok"] = "wowok";
|
|
22
24
|
})(MODULES || (MODULES = {}));
|
|
23
25
|
export var OperatorType;
|
|
@@ -62,32 +64,32 @@ export const ValueTypeArray = Object.values(ValueType).filter((v) => typeof (v)
|
|
|
62
64
|
export const IsValidOperatorType = (type) => { return OperatorTypeArray.includes(type); };
|
|
63
65
|
export const IsValidValueType = (type) => { return ValueTypeArray.includes(type); };
|
|
64
66
|
export const SER_VALUE = [
|
|
65
|
-
{ type: ValueType.TYPE_BOOL, name: 'bool' },
|
|
66
|
-
{ type: ValueType.TYPE_ADDRESS, name: 'address' },
|
|
67
|
-
{ type: ValueType.TYPE_U64, name: '
|
|
68
|
-
{ type: ValueType.TYPE_U8, name: '
|
|
69
|
-
{ type: ValueType.TYPE_VEC_U8, name: '
|
|
70
|
-
{ type: ValueType.TYPE_U128, name: '
|
|
71
|
-
{ type: ValueType.TYPE_VEC_ADDRESS, name: '
|
|
72
|
-
{ type: ValueType.TYPE_VEC_BOOL, name: '
|
|
73
|
-
{ type: ValueType.TYPE_VEC_VEC_U8, name: '
|
|
74
|
-
{ type: ValueType.TYPE_VEC_U64, name: '
|
|
75
|
-
{ type: ValueType.TYPE_VEC_U128, name: '
|
|
76
|
-
{ type: ValueType.TYPE_OPTION_ADDRESS, name: '
|
|
77
|
-
{ type: ValueType.TYPE_OPTION_BOOL, name: '
|
|
78
|
-
{ type: ValueType.TYPE_OPTION_U8, name: '
|
|
79
|
-
{ type: ValueType.TYPE_OPTION_U64, name: '
|
|
80
|
-
{ type: ValueType.TYPE_OPTION_U128, name: '
|
|
81
|
-
{ type: ValueType.TYPE_OPTION_U256, name: '
|
|
82
|
-
{ type: ValueType.TYPE_VEC_U256, name: '
|
|
83
|
-
{ type: ValueType.TYPE_U256, name: '
|
|
67
|
+
{ type: ValueType.TYPE_BOOL, name: 'bool', description: 'boolean. eg:true or false' },
|
|
68
|
+
{ type: ValueType.TYPE_ADDRESS, name: 'address', description: 'address or object-id. eg:0x6789af' },
|
|
69
|
+
{ type: ValueType.TYPE_U64, name: 'number', description: 'unsigned-64 number. eg:23870233' },
|
|
70
|
+
{ type: ValueType.TYPE_U8, name: 'number', description: 'unsigned-8 number. eg:255' },
|
|
71
|
+
{ type: ValueType.TYPE_VEC_U8, name: '[number]', description: 'unsigned-8 number array. eg:"wowok"' },
|
|
72
|
+
{ type: ValueType.TYPE_U128, name: 'number', description: 'unsigned-8 number. eg:12348900999' },
|
|
73
|
+
{ type: ValueType.TYPE_VEC_ADDRESS, name: '[address]', description: 'address array. eg:[0x2277f2, 0x3344af]' },
|
|
74
|
+
{ type: ValueType.TYPE_VEC_BOOL, name: '[bool]', description: 'boolean array. eg:[true, false, true]' },
|
|
75
|
+
{ type: ValueType.TYPE_VEC_VEC_U8, name: '[[number]]', description: 'array of unsigned-8 number array. eg:["i", "like", "wowok"]' },
|
|
76
|
+
{ type: ValueType.TYPE_VEC_U64, name: '[number]', description: 'unsigned-64 number array. eg:[123, 778888, 42312]' },
|
|
77
|
+
{ type: ValueType.TYPE_VEC_U128, name: '[number]', description: 'unsigned-128 number array. eg:[123, 778888, 42312]' },
|
|
78
|
+
{ type: ValueType.TYPE_OPTION_ADDRESS, name: 'option', description: 'option of address. eg:none or address' },
|
|
79
|
+
{ type: ValueType.TYPE_OPTION_BOOL, name: 'option', description: 'option of bool. eg:none or boolean value' },
|
|
80
|
+
{ type: ValueType.TYPE_OPTION_U8, name: 'option', description: 'option of u8. eg:none or u8 value' },
|
|
81
|
+
{ type: ValueType.TYPE_OPTION_U64, name: 'option', description: 'option of u64. eg:none or u64 value' },
|
|
82
|
+
{ type: ValueType.TYPE_OPTION_U128, name: 'option', description: 'option of u128. eg:none or u128 value' },
|
|
83
|
+
{ type: ValueType.TYPE_OPTION_U256, name: 'option', description: 'option of u256. eg:none or u256 value' },
|
|
84
|
+
{ type: ValueType.TYPE_VEC_U256, name: '[number]', description: 'unsigned-256 number array. eg:[123, 778888, 42312]' },
|
|
85
|
+
{ type: ValueType.TYPE_U256, name: 'number', description: 'unsigned-256 number. eg:12345678901233' },
|
|
84
86
|
];
|
|
85
87
|
export var ContextType;
|
|
86
88
|
(function (ContextType) {
|
|
87
89
|
ContextType[ContextType["TYPE_SIGNER"] = 60] = "TYPE_SIGNER";
|
|
88
90
|
ContextType[ContextType["TYPE_CLOCK"] = 61] = "TYPE_CLOCK";
|
|
89
91
|
ContextType[ContextType["TYPE_WITNESS_ID"] = 62] = "TYPE_WITNESS_ID";
|
|
90
|
-
ContextType[ContextType["
|
|
92
|
+
ContextType[ContextType["TYPE_CONSTANT"] = 80] = "TYPE_CONSTANT";
|
|
91
93
|
})(ContextType || (ContextType = {}));
|
|
92
94
|
export var ENTRYPOINT;
|
|
93
95
|
(function (ENTRYPOINT) {
|
|
@@ -100,7 +102,8 @@ export class Protocol {
|
|
|
100
102
|
network = '';
|
|
101
103
|
package = '';
|
|
102
104
|
signer = '';
|
|
103
|
-
|
|
105
|
+
wowok_object = '';
|
|
106
|
+
entity_object = '';
|
|
104
107
|
graphql = '';
|
|
105
108
|
txb;
|
|
106
109
|
constructor(network = ENTRYPOINT.testnet) {
|
|
@@ -111,14 +114,13 @@ export class Protocol {
|
|
|
111
114
|
this.network = network;
|
|
112
115
|
switch (network) {
|
|
113
116
|
case ENTRYPOINT.localnet:
|
|
114
|
-
this.package = "0xe9721254e97dd074e06c5efe5c57be169b64b39ae48939d89c00bf2f62b19e10";
|
|
115
|
-
this.everyone_guard = "0xb2a3fe7881cb883743c4e962b7e3c7716a1cd47a67adad01dc79795def4f769d";
|
|
116
117
|
break;
|
|
117
118
|
case ENTRYPOINT.devnet:
|
|
118
119
|
break;
|
|
119
120
|
case ENTRYPOINT.testnet:
|
|
120
|
-
this.package = "
|
|
121
|
-
this.
|
|
121
|
+
this.package = "0x2ac00805aa0ec3c62b575e412108bb295389bbfc86202fd7b73c69dbbb80769a";
|
|
122
|
+
this.wowok_object = '0x49d49fb41c63c3f6c838fca20c25741f20aa74a176391685446794bdaa9b7934';
|
|
123
|
+
this.entity_object = '0xd21d8d76f553b2db6c6d28a8b2ae3405bec92f2a300676d80fcc004ca40b0a77';
|
|
122
124
|
this.graphql = 'https://sui-testnet.mystenlabs.com/graphql';
|
|
123
125
|
break;
|
|
124
126
|
case ENTRYPOINT.mainnet:
|
|
@@ -127,7 +129,8 @@ export class Protocol {
|
|
|
127
129
|
;
|
|
128
130
|
}
|
|
129
131
|
Package() { return this.package; }
|
|
130
|
-
|
|
132
|
+
WowokObject() { return this.wowok_object; }
|
|
133
|
+
EntityObject() { return this.entity_object; }
|
|
131
134
|
GraphqlUrl() { return this.graphql; }
|
|
132
135
|
NetworkUrl() {
|
|
133
136
|
switch (this.network) {
|
|
@@ -157,6 +160,8 @@ export class Protocol {
|
|
|
157
160
|
OrderFn = (fn) => { return `${this.package}::${MODULES.order}::${fn}`; };
|
|
158
161
|
RewardFn = (fn) => { return `${this.package}::${MODULES.reward}::${fn}`; };
|
|
159
162
|
ServiceFn = (fn) => { return `${this.package}::${MODULES.service}::${fn}`; };
|
|
163
|
+
ResourceFn = (fn) => { return `${this.package}::${MODULES.resource}::${fn}`; };
|
|
164
|
+
EntityFn = (fn) => { return `${this.package}::${MODULES.entity}::${fn}`; };
|
|
160
165
|
WowokFn = (fn) => { return `${this.package}::${MODULES.wowok}::${fn}`; };
|
|
161
166
|
Query = async (objects, options = { showContent: true }) => {
|
|
162
167
|
const client = new SuiClient({ url: this.NetworkUrl() });
|
package/dist/repository.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAc,SAAS,EAAoB,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,S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, passport) {
|
|
27
|
-
let r = new Repository(protocol, permission);
|
|
28
27
|
if (!Protocol.IsValidObjects([permission])) {
|
|
29
28
|
ERROR(Errors.IsValidObjects, 'permission');
|
|
30
29
|
}
|
|
31
30
|
if (!IsValidDesription(description)) {
|
|
32
31
|
ERROR(Errors.IsValidDesription);
|
|
33
32
|
}
|
|
33
|
+
let r = new Repository(protocol, permission);
|
|
34
34
|
let txb = protocol.CurrentSession();
|
|
35
35
|
if (passport) {
|
|
36
36
|
r.object = txb.moveCall({
|
|
@@ -62,6 +62,16 @@ export class Repository {
|
|
|
62
62
|
arguments: [Protocol.TXB_OBJECT(txb, this.object)],
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
+
/* move to: Entity.mark
|
|
66
|
+
mark(like:'like' | 'unlike', resource:Resource) {
|
|
67
|
+
if (!Protocol.IsValidObjects([this.object])) return false;
|
|
68
|
+
let txb = this.protocol.CurrentSession();
|
|
69
|
+
txb.moveCall({
|
|
70
|
+
target:this.protocol.RepositoryFn(like) as FnCallType,
|
|
71
|
+
arguments: [Protocol.TXB_OBJECT(txb, resource.get_object()), Protocol.TXB_OBJECT(txb, this.object)],
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
*/
|
|
65
75
|
add_data(data) {
|
|
66
76
|
if (!Repository.IsValidName(data.key)) {
|
|
67
77
|
ERROR(Errors.IsValidName);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Protocol, TxbObject } from './protocol';
|
|
2
|
+
export declare class Resource {
|
|
3
|
+
static MAX_WORDS_LEN: number;
|
|
4
|
+
static IsValidWords(words: string): boolean;
|
|
5
|
+
protected object: TxbObject;
|
|
6
|
+
protected protocol: Protocol;
|
|
7
|
+
get_object(): TxbObject;
|
|
8
|
+
private constructor();
|
|
9
|
+
static From(protocol: Protocol, object: TxbObject): Resource;
|
|
10
|
+
add(name: string, object: string): void;
|
|
11
|
+
remove(name: string, object?: string, removeall?: boolean): void;
|
|
12
|
+
rename(old_name: string, new_name: string): void;
|
|
13
|
+
add_words(object: string, words: string): void;
|
|
14
|
+
remove_words(object: string): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAc,SAAS,EAAkB,MAAM,YAAY,CAAC;AAK7E,qBAAa,QAAQ;IACjB,MAAM,CAAC,aAAa,SAAU;IAC9B,MAAM,CAAC,YAAY,CAAC,KAAK,EAAC,MAAM,GAAI,OAAO;IAI3C,SAAS,CAAC,MAAM,EAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,QAAQ,WAAC;IAEnB,UAAU;IACV,OAAO;IAKP,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAC,QAAQ,EAAE,MAAM,EAAC,SAAS,GAAI,QAAQ;IAM3D,GAAG,CAAC,IAAI,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM;IAW9B,MAAM,CAAC,IAAI,EAAC,MAAM,EAAE,MAAM,CAAC,EAAC,MAAM,EAAE,SAAS,CAAC,EAAC,OAAO;IAoBtD,MAAM,CAAC,QAAQ,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM;IAUvC,SAAS,CAAC,MAAM,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM;IAWrC,YAAY,CAAC,MAAM,EAAC,MAAM;CAS7B"}
|