wowok 1.1.5 → 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 +0 -2
- package/dist/demand.d.ts.map +1 -1
- package/dist/demand.js +0 -8
- 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 +65 -52
- 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 +0 -2
- package/dist/machine.d.ts.map +1 -1
- package/dist/machine.js +0 -7
- package/dist/passport.d.ts +13 -9
- package/dist/passport.d.ts.map +1 -1
- package/dist/passport.js +60 -55
- package/dist/permission.d.ts +0 -2
- package/dist/permission.d.ts.map +1 -1
- package/dist/permission.js +0 -7
- package/dist/progress.d.ts +0 -2
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +9 -7
- package/dist/protocol.d.ts +15 -8
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +29 -26
- package/dist/repository.d.ts +0 -2
- package/dist/repository.d.ts.map +1 -1
- package/dist/repository.js +10 -9
- package/dist/resource.d.ts +2 -5
- package/dist/resource.d.ts.map +1 -1
- package/dist/resource.js +4 -30
- package/dist/reward.d.ts +0 -2
- package/dist/reward.d.ts.map +1 -1
- package/dist/reward.js +9 -7
- package/dist/service.d.ts +0 -2
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +10 -8
- 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 +0 -2
- package/dist/vote.d.ts.map +1 -1
- package/dist/vote.js +0 -7
- 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 +1 -10
- package/src/entity.ts +27 -1
- package/src/guard.ts +55 -55
- package/src/index.ts +11 -8
- package/src/machine.ts +0 -8
- package/src/passport.ts +69 -65
- package/src/permission.ts +0 -8
- package/src/progress.ts +2 -2
- package/src/protocol.ts +28 -28
- package/src/repository.ts +2 -2
- package/src/resource.ts +3 -35
- package/src/reward.ts +2 -2
- package/src/service.ts +2 -2
- package/src/vote.ts +0 -8
package/src/protocol.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';
|
|
|
4
4
|
import { BCS, getSuiMoveConfig, toHEX, fromHEX, BcsReader } from '@mysten/bcs';
|
|
5
5
|
import { TransactionBlock, Inputs, TransactionResult, TransactionArgument } from '@mysten/sui.js/transactions';
|
|
6
6
|
import { capitalize, IsValidArray } from './utils'
|
|
7
|
-
import {
|
|
7
|
+
import { GuardConstant } from './guard';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
export enum MODULES {
|
|
@@ -106,38 +106,39 @@ export const IsValidValueType = (type:number) => { return ValueTypeArray.include
|
|
|
106
106
|
interface ValueTypeString {
|
|
107
107
|
type: ValueType;
|
|
108
108
|
name: string;
|
|
109
|
+
description: string;
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
export const SER_VALUE: ValueTypeString[] = [
|
|
112
|
-
{type: ValueType.TYPE_BOOL, name: 'bool'},
|
|
113
|
-
{type: ValueType.TYPE_ADDRESS, name: 'address'},
|
|
114
|
-
{type: ValueType.TYPE_U64, name: '
|
|
115
|
-
{type: ValueType.TYPE_U8, name: '
|
|
116
|
-
{type: ValueType.TYPE_VEC_U8, name: '
|
|
117
|
-
{type: ValueType.TYPE_U128, name: '
|
|
118
|
-
{type: ValueType.TYPE_VEC_ADDRESS, name: '
|
|
119
|
-
{type: ValueType.TYPE_VEC_BOOL, name: '
|
|
120
|
-
{type: ValueType.TYPE_VEC_VEC_U8, name: '
|
|
121
|
-
{type: ValueType.TYPE_VEC_U64, name: '
|
|
122
|
-
{type: ValueType.TYPE_VEC_U128, name: '
|
|
123
|
-
{type: ValueType.TYPE_OPTION_ADDRESS, name: '
|
|
124
|
-
{type: ValueType.TYPE_OPTION_BOOL, name: '
|
|
125
|
-
{type: ValueType.TYPE_OPTION_U8, name: '
|
|
126
|
-
{type: ValueType.TYPE_OPTION_U64, name: '
|
|
127
|
-
{type: ValueType.TYPE_OPTION_U128, name: '
|
|
128
|
-
{type: ValueType.TYPE_OPTION_U256, name: '
|
|
129
|
-
{type: ValueType.TYPE_VEC_U256, name: '
|
|
130
|
-
{type: ValueType.TYPE_U256, name: '
|
|
113
|
+
{type: ValueType.TYPE_BOOL, name: 'bool', description:'boolean. eg:true or false'},
|
|
114
|
+
{type: ValueType.TYPE_ADDRESS, name: 'address', description:'address or object-id. eg:0x6789af'},
|
|
115
|
+
{type: ValueType.TYPE_U64, name: 'number', description:'unsigned-64 number. eg:23870233'},
|
|
116
|
+
{type: ValueType.TYPE_U8, name: 'number', description:'unsigned-8 number. eg:255'},
|
|
117
|
+
{type: ValueType.TYPE_VEC_U8, name: '[number]', description:'unsigned-8 number array. eg:"wowok"'},
|
|
118
|
+
{type: ValueType.TYPE_U128, name: 'number', description:'unsigned-8 number. eg:12348900999'},
|
|
119
|
+
{type: ValueType.TYPE_VEC_ADDRESS, name: '[address]', description:'address array. eg:[0x2277f2, 0x3344af]'},
|
|
120
|
+
{type: ValueType.TYPE_VEC_BOOL, name: '[bool]', description:'boolean array. eg:[true, false, true]'},
|
|
121
|
+
{type: ValueType.TYPE_VEC_VEC_U8, name: '[[number]]', description:'array of unsigned-8 number array. eg:["i", "like", "wowok"]'},
|
|
122
|
+
{type: ValueType.TYPE_VEC_U64, name: '[number]', description:'unsigned-64 number array. eg:[123, 778888, 42312]'},
|
|
123
|
+
{type: ValueType.TYPE_VEC_U128, name: '[number]', description:'unsigned-128 number array. eg:[123, 778888, 42312]'},
|
|
124
|
+
{type: ValueType.TYPE_OPTION_ADDRESS, name: 'option', description:'option of address. eg:none or address'},
|
|
125
|
+
{type: ValueType.TYPE_OPTION_BOOL, name: 'option', description:'option of bool. eg:none or boolean value'},
|
|
126
|
+
{type: ValueType.TYPE_OPTION_U8, name: 'option', description:'option of u8. eg:none or u8 value'},
|
|
127
|
+
{type: ValueType.TYPE_OPTION_U64, name: 'option', description:'option of u64. eg:none or u64 value'},
|
|
128
|
+
{type: ValueType.TYPE_OPTION_U128, name: 'option', description:'option of u128. eg:none or u128 value'},
|
|
129
|
+
{type: ValueType.TYPE_OPTION_U256, name: 'option', description:'option of u256. eg:none or u256 value'},
|
|
130
|
+
{type: ValueType.TYPE_VEC_U256, name: '[number]', description:'unsigned-256 number array. eg:[123, 778888, 42312]'},
|
|
131
|
+
{type: ValueType.TYPE_U256, name: 'number', description:'unsigned-256 number. eg:12345678901233'},
|
|
131
132
|
]
|
|
132
133
|
|
|
133
134
|
export enum ContextType {
|
|
134
135
|
TYPE_SIGNER = 60,
|
|
135
136
|
TYPE_CLOCK = 61,
|
|
136
137
|
TYPE_WITNESS_ID = 62,
|
|
137
|
-
|
|
138
|
+
TYPE_CONSTANT = 80,
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
export type
|
|
141
|
+
export type ConstantType = ValueType | ContextType.TYPE_WITNESS_ID;
|
|
141
142
|
export type Data_Type = ValueType | OperatorType | ContextType;
|
|
142
143
|
|
|
143
144
|
export enum ENTRYPOINT {
|
|
@@ -164,14 +165,13 @@ export class Protocol {
|
|
|
164
165
|
this.network = network;
|
|
165
166
|
switch(network) {
|
|
166
167
|
case ENTRYPOINT.localnet:
|
|
167
|
-
this.package = "0xe9721254e97dd074e06c5efe5c57be169b64b39ae48939d89c00bf2f62b19e10";
|
|
168
168
|
break;
|
|
169
169
|
case ENTRYPOINT.devnet:
|
|
170
170
|
break;
|
|
171
171
|
case ENTRYPOINT.testnet:
|
|
172
|
-
this.package = "
|
|
173
|
-
this.wowok_object = '';
|
|
174
|
-
this.entity_object= '';
|
|
172
|
+
this.package = "0x2ac00805aa0ec3c62b575e412108bb295389bbfc86202fd7b73c69dbbb80769a";
|
|
173
|
+
this.wowok_object = '0x49d49fb41c63c3f6c838fca20c25741f20aa74a176391685446794bdaa9b7934';
|
|
174
|
+
this.entity_object= '0xd21d8d76f553b2db6c6d28a8b2ae3405bec92f2a300676d80fcc004ca40b0a77';
|
|
175
175
|
this.graphql = 'https://sui-testnet.mystenlabs.com/graphql';
|
|
176
176
|
break;
|
|
177
177
|
case ENTRYPOINT.mainnet:
|
|
@@ -335,7 +335,7 @@ export class RpcResultParser {
|
|
|
335
335
|
export type Query_Param = {
|
|
336
336
|
objectid: string;
|
|
337
337
|
callback: (protocol:Protocol, response:SuiObjectResponse, param:Query_Param, option:SuiObjectDataOptions)=>void;
|
|
338
|
-
parser?: (result:any[], guardid: string, chain_sense_bsc:Uint8Array,
|
|
338
|
+
parser?: (result:any[], guardid: string, chain_sense_bsc:Uint8Array, constant?:GuardConstant) => boolean;
|
|
339
339
|
data?: any; // response data filted by callback
|
|
340
|
-
|
|
340
|
+
constants?: GuardConstant;
|
|
341
341
|
};
|
package/src/repository.ts
CHANGED
|
@@ -82,7 +82,7 @@ export class Repository {
|
|
|
82
82
|
arguments: [Protocol.TXB_OBJECT(txb, this.object)],
|
|
83
83
|
})
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
/* move to: Entity.mark
|
|
86
86
|
mark(like:'like' | 'unlike', resource:Resource) {
|
|
87
87
|
if (!Protocol.IsValidObjects([this.object])) return false;
|
|
88
88
|
let txb = this.protocol.CurrentSession();
|
|
@@ -91,7 +91,7 @@ export class Repository {
|
|
|
91
91
|
arguments: [Protocol.TXB_OBJECT(txb, resource.get_object()), Protocol.TXB_OBJECT(txb, this.object)],
|
|
92
92
|
})
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
*/
|
|
95
95
|
add_data(data:Repository_Policy_Data) {
|
|
96
96
|
if (!Repository.IsValidName(data.key)) {
|
|
97
97
|
ERROR(Errors.IsValidName)
|
package/src/resource.ts
CHANGED
|
@@ -25,39 +25,6 @@ export class Resource {
|
|
|
25
25
|
return r
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
static New(protocol:Protocol, description:string) : Resource {
|
|
29
|
-
if (!IsValidDesription(description)) {
|
|
30
|
-
ERROR(Errors.IsValidDesription)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let r = new Resource(protocol);
|
|
34
|
-
let txb = protocol.CurrentSession();
|
|
35
|
-
|
|
36
|
-
r.object = txb.moveCall({
|
|
37
|
-
target:protocol.ResourceFn('new') as FnCallType,
|
|
38
|
-
arguments:[txb.pure(description)],
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
return r
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
launch() : ResourceAddress {
|
|
45
|
-
let txb = this.protocol.CurrentSession();
|
|
46
|
-
return txb.moveCall({
|
|
47
|
-
target:this.protocol.ResourceFn('create') as FnCallType,
|
|
48
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object)],
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
destroy() {
|
|
53
|
-
if (!Protocol.IsValidObjects([this.object])) return false;
|
|
54
|
-
let txb = this.protocol.CurrentSession();
|
|
55
|
-
txb.moveCall({
|
|
56
|
-
target:this.protocol.ResourceFn('destroy') as FnCallType,
|
|
57
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object)],
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
|
|
61
28
|
add(name:string, object:string) {
|
|
62
29
|
if (!IsValidName(name)) ERROR(Errors.IsValidName, 'Resource: add');
|
|
63
30
|
if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'Resource: add');
|
|
@@ -69,8 +36,9 @@ export class Resource {
|
|
|
69
36
|
});
|
|
70
37
|
}
|
|
71
38
|
|
|
72
|
-
remove(name:string, object
|
|
39
|
+
remove(name:string, object?:string, removeall?:boolean) {
|
|
73
40
|
if (!IsValidName(name)) ERROR(Errors.IsValidName, 'Resource: remove');
|
|
41
|
+
if (!object && !removeall) ERROR(Errors.InvalidParam, 'Resource: remove, BOTH param undefined');
|
|
74
42
|
|
|
75
43
|
let txb = this.protocol.CurrentSession();
|
|
76
44
|
if (removeall) {
|
|
@@ -78,7 +46,7 @@ export class Resource {
|
|
|
78
46
|
target:this.protocol.ResourceFn('remove_all') as FnCallType,
|
|
79
47
|
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(name, BCS.STRING)]
|
|
80
48
|
});
|
|
81
|
-
} else {
|
|
49
|
+
} else if(object) {
|
|
82
50
|
if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'Resource: remove');
|
|
83
51
|
|
|
84
52
|
txb.moveCall({
|
package/src/reward.ts
CHANGED
|
@@ -82,7 +82,7 @@ export class Reward {
|
|
|
82
82
|
arguments: [Protocol.TXB_OBJECT(txb, this.object)],
|
|
83
83
|
})
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
/*
|
|
86
86
|
mark(like:'like' | 'unlike', resource:Resource) {
|
|
87
87
|
let txb = this.protocol.CurrentSession();
|
|
88
88
|
txb.moveCall({
|
|
@@ -90,7 +90,7 @@ export class Reward {
|
|
|
90
90
|
arguments: [Protocol.TXB_OBJECT(txb, resource.get_object()), Protocol.TXB_OBJECT(txb, this.object)],
|
|
91
91
|
})
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
*/
|
|
94
94
|
refund(passport?:PassportObject) {
|
|
95
95
|
let txb = this.protocol.CurrentSession();
|
|
96
96
|
if (passport) {
|
package/src/service.ts
CHANGED
|
@@ -130,7 +130,7 @@ export class Service {
|
|
|
130
130
|
typeArguments:[this.pay_token_type]
|
|
131
131
|
})
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
/* move to: Entity.mark
|
|
134
134
|
mark(like:'like' | 'unlike', resource:Resource) {
|
|
135
135
|
let txb = this.protocol.CurrentSession();
|
|
136
136
|
txb.moveCall({
|
|
@@ -139,7 +139,7 @@ export class Service {
|
|
|
139
139
|
typeArguments:[this.pay_token_type]
|
|
140
140
|
})
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
*/
|
|
143
143
|
set_description(description:string, passport?:PassportObject) {
|
|
144
144
|
if (!IsValidDesription(description)) {
|
|
145
145
|
ERROR(Errors.IsValidDesription)
|
package/src/vote.ts
CHANGED
|
@@ -86,14 +86,6 @@ export class Vote {
|
|
|
86
86
|
})
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
mark(like:'like' | 'unlike', resource:Resource) {
|
|
90
|
-
let txb = this.protocol.CurrentSession();
|
|
91
|
-
txb.moveCall({
|
|
92
|
-
target:this.protocol.VoteFn(like) as FnCallType,
|
|
93
|
-
arguments:[Protocol.TXB_OBJECT(txb, resource.get_object()), Protocol.TXB_OBJECT(txb, this.object)]
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
|
|
97
89
|
set_description(description:string, passport?:PassportObject) {
|
|
98
90
|
if (!IsValidDesription(description)) {
|
|
99
91
|
ERROR(Errors.IsValidDesription)
|