wowok 1.6.69 → 1.6.70
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/package.json +1 -1
- package/src/exception.ts +2 -1
- package/src/guard.ts +6 -2
- package/src/permission.ts +11 -11
- package/src/resource.ts +0 -13
package/package.json
CHANGED
package/src/exception.ts
CHANGED
|
@@ -21,10 +21,11 @@ export enum Errors {
|
|
|
21
21
|
Fail = 'fail',
|
|
22
22
|
IsValidIndentifier = 'indentifier invalid',
|
|
23
23
|
isValidHttpUrl = 'invalid url',
|
|
24
|
-
|
|
24
|
+
IsValidBizPermissionIndex = 'invalid biz-permission index',
|
|
25
25
|
bcsTypeInvalid = 'invalid bcs type',
|
|
26
26
|
IsValidServiceItemName = 'invalid service item name',
|
|
27
27
|
IsValidCoinType = 'not the coin type',
|
|
28
|
+
IsValidGuardIdentifier = 'guard identifier invalid',
|
|
28
29
|
noPermission = 'no permission',
|
|
29
30
|
}
|
|
30
31
|
|
package/src/guard.ts
CHANGED
|
@@ -466,6 +466,10 @@ export class Guard {
|
|
|
466
466
|
return Guard.CommonOptions(ret_type);
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
|
+
|
|
470
|
+
export const IsValidGuardIdentifier = (identifier:number | undefined) : boolean => {
|
|
471
|
+
return IsValidU8(identifier) && identifier !== 0;
|
|
472
|
+
}
|
|
469
473
|
export class GuardMaker {
|
|
470
474
|
protected data : Uint8Array[] = [];
|
|
471
475
|
protected type_validator : Data_Type[] = [];
|
|
@@ -556,8 +560,8 @@ export class GuardMaker {
|
|
|
556
560
|
this.type_validator.push(ValueType.TYPE_U64);
|
|
557
561
|
break;
|
|
558
562
|
case ContextType.TYPE_CONSTANT:
|
|
559
|
-
if (
|
|
560
|
-
ERROR(Errors.
|
|
563
|
+
if (!IsValidGuardIdentifier(param)) {
|
|
564
|
+
ERROR(Errors.IsValidGuardIdentifier, 'add_param param:'+type);
|
|
561
565
|
}
|
|
562
566
|
|
|
563
567
|
var v = this.constant.get(param);
|
package/src/permission.ts
CHANGED
|
@@ -233,7 +233,7 @@ export interface Permission_Index {
|
|
|
233
233
|
entities: Permission_Index_Entity[];
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
export interface
|
|
236
|
+
export interface BizPermission {
|
|
237
237
|
index: PermissionIndexType;
|
|
238
238
|
name: string;
|
|
239
239
|
}
|
|
@@ -271,13 +271,13 @@ export class Permission {
|
|
|
271
271
|
})
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
|
|
275
|
-
if (!Permission.
|
|
276
|
-
ERROR(Errors.
|
|
274
|
+
add_bizPermission(index: number, name:string) {
|
|
275
|
+
if (!Permission.IsValidBizPermissionIndex(index)) {
|
|
276
|
+
ERROR(Errors.IsValidBizPermissionIndex, 'add_bizPermission');
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
if (!IsValidName(name)) {
|
|
280
|
-
ERROR(Errors.IsValidName, '
|
|
280
|
+
ERROR(Errors.IsValidName, 'add_bizPermission');
|
|
281
281
|
}
|
|
282
282
|
this.txb.moveCall({
|
|
283
283
|
target:Protocol.Instance().permissionFn('user_define_add') as FnCallType,
|
|
@@ -285,9 +285,9 @@ export class Permission {
|
|
|
285
285
|
})
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
|
|
289
|
-
if (!Permission.
|
|
290
|
-
ERROR(Errors.
|
|
288
|
+
remove_bizPermission(index: number) {
|
|
289
|
+
if (!Permission.IsValidBizPermissionIndex(index)) {
|
|
290
|
+
ERROR(Errors.IsValidBizPermissionIndex, 'remove_bizPermission');
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
this.txb.moveCall({
|
|
@@ -407,7 +407,7 @@ export class Permission {
|
|
|
407
407
|
if (!IsValidAddress(address)) {
|
|
408
408
|
ERROR(Errors.IsValidAddress, 'address')
|
|
409
409
|
}
|
|
410
|
-
if(!Permission.IsValidPermissionIndex(index) && !Permission.
|
|
410
|
+
if(!Permission.IsValidPermissionIndex(index) && !Permission.IsValidBizPermissionIndex(index)) {
|
|
411
411
|
ERROR(Errors.IsValidPermissionIndex, 'index')
|
|
412
412
|
}
|
|
413
413
|
|
|
@@ -572,7 +572,7 @@ export class Permission {
|
|
|
572
572
|
static PERMISSION_OWNER_AND_ADMIN = 3;
|
|
573
573
|
static BUSINESS_PERMISSIONS_START = PermissionIndex.user_defined_start;
|
|
574
574
|
|
|
575
|
-
static
|
|
575
|
+
static IsValidBizPermissionIndex = (index:number) => {
|
|
576
576
|
return index >= Permission.BUSINESS_PERMISSIONS_START && IsValidU64(index)
|
|
577
577
|
}
|
|
578
578
|
|
|
@@ -582,6 +582,6 @@ export class Permission {
|
|
|
582
582
|
return true
|
|
583
583
|
}
|
|
584
584
|
//console.log(Object.keys(PermissionIndex))
|
|
585
|
-
return Permission.
|
|
585
|
+
return Permission.IsValidBizPermissionIndex(index);
|
|
586
586
|
}
|
|
587
587
|
}
|
package/src/resource.ts
CHANGED
|
@@ -111,19 +111,6 @@ export class Resource {
|
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
query(address: TxbAddress) {
|
|
115
|
-
if (typeof(address) === 'string' && !IsValidAddress(address)) {
|
|
116
|
-
ERROR(Errors.IsValidAddress, 'Resource: query.address');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
this.txb.moveCall({
|
|
120
|
-
target:Protocol.Instance().resourceFn('query') as FnCallType,
|
|
121
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
122
|
-
typeof(address) === 'string' ? this.txb.pure.address(address) : address,
|
|
123
|
-
]
|
|
124
|
-
})
|
|
125
|
-
}
|
|
126
|
-
|
|
127
114
|
static TagData(tags: Tags[], innerTag:boolean=true) : TagData[] {
|
|
128
115
|
const data : TagData[] = [];
|
|
129
116
|
tags.forEach(v => {
|