wowok 1.1.2 → 1.1.3
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 +3 -2
- 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 +24 -24
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +307 -324
- package/dist/passport.d.ts +17 -14
- package/dist/passport.d.ts.map +1 -1
- package/dist/passport.js +111 -76
- package/dist/protocol.d.ts +34 -38
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +32 -48
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +6 -0
- package/package.json +3 -2
- package/src/exception.ts +1 -0
- package/src/guard.ts +315 -335
- package/src/passport.ts +121 -82
- package/src/protocol.ts +35 -51
- package/src/utils.ts +6 -0
package/src/passport.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { SuiObjectResponse, SuiObjectDataOptions } from '@mysten/sui.js/client';
|
|
2
1
|
import { type TransactionObjectInput, Inputs } from '@mysten/sui.js/transactions';
|
|
3
|
-
import { FnCallType,
|
|
2
|
+
import { FnCallType, GuardObject, Protocol, ContextType, OperatorType, Data_Type,
|
|
4
3
|
ValueType, MODULES } from './protocol';
|
|
5
4
|
import { parse_object_type, array_unique, Bcs, ulebDecode, IsValidAddress, IsValidArray } from './utils';
|
|
6
|
-
import { VariableType, Guard, Guard_Vriable, GuardVariableMaker } from './guard';
|
|
7
5
|
import { BCS } from '@mysten/bcs';
|
|
8
6
|
import { ERROR, Errors } from './exception';
|
|
9
7
|
|
|
@@ -14,31 +12,41 @@ export type Guard_Query_Object = {
|
|
|
14
12
|
id: string, // object id
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
interface
|
|
18
|
-
identifier
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
interface QueryInfo {
|
|
16
|
+
identifier?: number;
|
|
17
|
+
index: number;
|
|
18
|
+
type: number;
|
|
19
|
+
value_or_witness: string;
|
|
20
|
+
future?: string;
|
|
22
21
|
}
|
|
23
22
|
interface GuardInfo {
|
|
24
23
|
id: string;
|
|
25
|
-
query_list: (string |
|
|
26
|
-
|
|
24
|
+
query_list: (string | QueryInfo)[]; // object or witness object query
|
|
25
|
+
variable: QueryInfo[]; // witness in variable & ValueType.TYPE_ADDRESS(for Query)
|
|
26
|
+
input_witness: QueryInfo[]; // witness in input
|
|
27
27
|
}
|
|
28
|
+
|
|
28
29
|
interface FutrueFill {
|
|
29
30
|
guard: string;
|
|
30
|
-
|
|
31
|
+
index: number;
|
|
31
32
|
future: string;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
34
|
interface PassportQuery {
|
|
35
|
+
guard: GuardObject[];
|
|
35
36
|
query: Guard_Query_Object[];
|
|
36
37
|
witness: Guard_Query_Object[];
|
|
37
38
|
}
|
|
38
39
|
export class GuardParser {
|
|
39
40
|
protected guard_list: GuardInfo[] = [];
|
|
40
41
|
protected protocol: Protocol;
|
|
41
|
-
|
|
42
|
+
protected guards: GuardObject[];
|
|
43
|
+
private index:number = 0;
|
|
44
|
+
private get_index() { return this.index++ }
|
|
45
|
+
|
|
46
|
+
private constructor(protocol: Protocol, guards: string[]) {
|
|
47
|
+
this.protocol = protocol ;
|
|
48
|
+
this.guards = guards.map(g => protocol.CurrentSession().object(g) as GuardObject);
|
|
49
|
+
}
|
|
42
50
|
guardlist = () => { return this.guard_list }
|
|
43
51
|
|
|
44
52
|
static CreateAsync = async (protocol: Protocol, guards: string[]) => {
|
|
@@ -47,18 +55,18 @@ export class GuardParser {
|
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
let guard_list = array_unique(guards);
|
|
50
|
-
const me = new GuardParser(protocol);
|
|
58
|
+
const me = new GuardParser(protocol, guards);
|
|
51
59
|
|
|
52
|
-
let res = await protocol.Query_Raw(
|
|
60
|
+
let res = await protocol.Query_Raw(guard_list);
|
|
53
61
|
res.forEach((r) => {
|
|
54
62
|
let c = r.data?.content as any;
|
|
55
63
|
if (!c) return;
|
|
56
64
|
|
|
57
|
-
let index = protocol.WOWOK_OBJECTS_TYPE().findIndex(v => v.includes('guard::Guard') && v == c.type);
|
|
65
|
+
let index = protocol.WOWOK_OBJECTS_TYPE().findIndex(v => {return v.includes('guard::Guard') && v == c.type});
|
|
58
66
|
if (index == -1) return;
|
|
59
67
|
|
|
60
|
-
let info:GuardInfo = {id: c.fields.id.id, query_list:[],
|
|
61
|
-
me.
|
|
68
|
+
let info:GuardInfo = {id: c.fields.id.id, query_list:[], variable:[], input_witness:[]};
|
|
69
|
+
me.parse_variable(info, c.fields.variables);
|
|
62
70
|
if (c.fields.input.type == (protocol.Package() + '::bcs::BCS')) {
|
|
63
71
|
me.parse_bcs(info, Uint8Array.from(c.fields.input.fields.bytes));
|
|
64
72
|
}
|
|
@@ -67,75 +75,91 @@ export class GuardParser {
|
|
|
67
75
|
return me
|
|
68
76
|
}
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
parse_variable = (info:GuardInfo, variables:any) => {
|
|
71
79
|
variables.forEach((v:any) => {
|
|
72
80
|
if (v.type == (this.protocol.Package() + '::guard::Variable')) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
// ValueType.TYPE_ADDRESS: Query_Cmd maybe used the address, so save it for using
|
|
82
|
+
if (v.fields.type == ContextType.TYPE_WITNESS_ID || v.fields.type == ValueType.TYPE_ADDRESS) {
|
|
83
|
+
info.variable.push({identifier:v.fields.identifier, index:this.get_index(), type:v.fields.type,
|
|
84
|
+
value_or_witness:'0x' + Bcs.getInstance().de(BCS.ADDRESS, Uint8Array.from(v.fields.value))});
|
|
76
85
|
}
|
|
77
86
|
}
|
|
78
87
|
});
|
|
79
88
|
}
|
|
80
89
|
|
|
81
|
-
|
|
90
|
+
parse_bcs = (info:GuardInfo, chain_bytes: Uint8Array) => {
|
|
82
91
|
var arr = [].slice.call(chain_bytes.reverse());
|
|
83
92
|
while (arr.length > 0) {
|
|
84
93
|
var type : unknown = arr.shift() ;
|
|
85
94
|
// console.log(type);
|
|
86
95
|
switch (type as Data_Type) {
|
|
87
|
-
case ContextType.
|
|
88
|
-
case ContextType.
|
|
89
|
-
case OperatorType.
|
|
90
|
-
case OperatorType.
|
|
91
|
-
case OperatorType.
|
|
92
|
-
case OperatorType.
|
|
93
|
-
case OperatorType.
|
|
94
|
-
case OperatorType.
|
|
95
|
-
case OperatorType.
|
|
96
|
+
case ContextType.TYPE_SIGNER:
|
|
97
|
+
case ContextType.TYPE_CLOCK:
|
|
98
|
+
case OperatorType.TYPE_LOGIC_AS_U256_GREATER:
|
|
99
|
+
case OperatorType.TYPE_LOGIC_AS_U256_GREATER_EQUAL:
|
|
100
|
+
case OperatorType.TYPE_LOGIC_AS_U256_LESSER:
|
|
101
|
+
case OperatorType.TYPE_LOGIC_AS_U256_LESSER_EQUAL:
|
|
102
|
+
case OperatorType.TYPE_LOGIC_AS_U256_EQUAL:
|
|
103
|
+
case OperatorType.TYPE_LOGIC_EQUAL:
|
|
104
|
+
case OperatorType.TYPE_LOGIC_HAS_SUBSTRING:
|
|
96
105
|
case OperatorType.TYPE_LOGIC_ALWAYS_TRUE:
|
|
97
106
|
case OperatorType.TYPE_LOGIC_NOT:
|
|
98
107
|
case OperatorType.TYPE_LOGIC_AND:
|
|
99
108
|
case OperatorType.TYPE_LOGIC_OR:
|
|
100
109
|
break;
|
|
101
|
-
case ContextType.
|
|
102
|
-
|
|
103
|
-
var identifer = arr.splice(0, 1);
|
|
104
|
-
let i = info.futrue_list.find(f => f.identifier == identifer[0]) ;
|
|
105
|
-
if (!i) { ERROR(Errors.Fail, 'futrue_list not found')}
|
|
106
|
-
if (type == OperatorType.TYPE_FUTURE_QUERY) {
|
|
107
|
-
info.query_list.push({identifier:identifer[0], type:type as number, witness:i!.witness}); // query list item
|
|
108
|
-
arr.splice(0, 1); // cmd
|
|
109
|
-
}
|
|
110
|
+
case ContextType.TYPE_VARIABLE:
|
|
111
|
+
arr.splice(0, 1); // identifier of variable
|
|
110
112
|
break;
|
|
111
|
-
case ContextType.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
case ContextType.TYPE_CONTEXT_vec_u8:
|
|
116
|
-
case ValueType.TYPE_STATIC_bool:
|
|
117
|
-
case ValueType.TYPE_STATIC_u8:
|
|
118
|
-
arr.splice(0, 1); // identifier
|
|
113
|
+
case ContextType.TYPE_WITNESS_ID: // add to variable
|
|
114
|
+
let addr = '0x' + Bcs.getInstance().de(BCS.ADDRESS, Uint8Array.from(arr)).toString();
|
|
115
|
+
arr.splice(0, 32); // address
|
|
116
|
+
info.input_witness.push({index:this.get_index(), type:ContextType.TYPE_WITNESS_ID, value_or_witness:addr})
|
|
119
117
|
break;
|
|
120
|
-
case
|
|
121
|
-
|
|
118
|
+
case ValueType.TYPE_BOOL:
|
|
119
|
+
case ValueType.TYPE_U8:
|
|
120
|
+
arr.splice(0, 1); // identifier
|
|
122
121
|
break;
|
|
123
|
-
case ValueType.
|
|
122
|
+
case ValueType.TYPE_ADDRESS:
|
|
124
123
|
arr.splice(0, 32);
|
|
125
124
|
break;
|
|
126
|
-
case ValueType.
|
|
125
|
+
case ValueType.TYPE_U64:
|
|
127
126
|
arr.splice(0, 8);
|
|
128
127
|
break;
|
|
129
|
-
case ValueType.
|
|
128
|
+
case ValueType.TYPE_U128:
|
|
130
129
|
arr.splice(0, 16);
|
|
131
130
|
break;
|
|
132
|
-
case ValueType.
|
|
131
|
+
case ValueType.TYPE_U256:
|
|
132
|
+
arr.splice(0, 32);
|
|
133
|
+
break;
|
|
134
|
+
case ValueType.TYPE_VEC_U8:
|
|
133
135
|
let {value, length} = ulebDecode(Uint8Array.from(arr));
|
|
134
136
|
arr.splice(0, value+length);
|
|
135
137
|
break;
|
|
136
138
|
case OperatorType.TYPE_QUERY:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
let type = arr.splice(0, 1);
|
|
140
|
+
if (type[0] == ValueType.TYPE_ADDRESS || type[0] == ContextType.TYPE_WITNESS_ID) {
|
|
141
|
+
let addr = '0x' + Bcs.getInstance().de(BCS.ADDRESS, Uint8Array.from(arr)).toString();
|
|
142
|
+
arr.splice(0, 33); // address + cmd
|
|
143
|
+
if (type[0] == ValueType.TYPE_ADDRESS) {
|
|
144
|
+
info.query_list.push(addr);
|
|
145
|
+
} else if (type[0] == ContextType.TYPE_WITNESS_ID){
|
|
146
|
+
info.query_list.push({index:this.get_index(), type:type[0], value_or_witness:addr});
|
|
147
|
+
}
|
|
148
|
+
} else if (type[0] == ContextType.TYPE_VARIABLE) {
|
|
149
|
+
let identifer = arr.splice(0, 2); // key + cmd
|
|
150
|
+
let variable = info.variable.find((v) =>
|
|
151
|
+
(v.identifier == identifer[0]) &&
|
|
152
|
+
((v.type == ValueType.TYPE_ADDRESS) || (v.type == ContextType.TYPE_WITNESS_ID)));
|
|
153
|
+
if (!variable) { ERROR(Errors.Fail, 'indentifier not in variable')}
|
|
154
|
+
if (variable?.type == ValueType.TYPE_ADDRESS) {
|
|
155
|
+
info.query_list.push(variable.value_or_witness);
|
|
156
|
+
} else if (variable?.type == ContextType.TYPE_WITNESS_ID) {
|
|
157
|
+
info.query_list.push({identifier:identifer[0], type:variable.type, value_or_witness:variable.value_or_witness, index:this.get_index()});
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
ERROR(Errors.Fail, 'variable type invalid');
|
|
161
|
+
}
|
|
162
|
+
|
|
139
163
|
break;
|
|
140
164
|
default:
|
|
141
165
|
ERROR(Errors.Fail, 'parse_bcs types')
|
|
@@ -143,27 +167,38 @@ export class GuardParser {
|
|
|
143
167
|
}
|
|
144
168
|
}
|
|
145
169
|
|
|
170
|
+
private get_object(guardid:string, info:QueryInfo, fill?:FutrueFill[]) : string {
|
|
171
|
+
let r = fill?.find(i => guardid == i.guard && i.index == info.index);
|
|
172
|
+
if (!r || !r.future) {
|
|
173
|
+
if (!info.future) {
|
|
174
|
+
ERROR(Errors.InvalidParam, 'index invalid for fill')
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
info.future = r!.future;
|
|
178
|
+
}
|
|
179
|
+
return info.future!
|
|
180
|
+
}
|
|
181
|
+
|
|
146
182
|
done = async (fill?:FutrueFill[]) : Promise<PassportQuery>=> {
|
|
147
183
|
let objects: string[] = [];
|
|
148
184
|
this.guard_list.forEach((g) => {
|
|
149
|
-
g.
|
|
150
|
-
|
|
151
|
-
if (!r && !f.futrue) { ERROR(Errors.InvalidParam, 'fill') }
|
|
152
|
-
|
|
153
|
-
if (r) f.futrue = r!.future;
|
|
154
|
-
objects.push(f.futrue!);
|
|
185
|
+
g.variable.filter(v => v.type == ContextType.TYPE_WITNESS_ID).forEach((q) => {
|
|
186
|
+
objects.push(this.get_object(g.id, q, fill));
|
|
155
187
|
})
|
|
156
|
-
|
|
188
|
+
let list = g.query_list.map((q) => {
|
|
157
189
|
if (typeof(q) === "string") {
|
|
158
190
|
objects.push(q)
|
|
159
191
|
return q
|
|
160
192
|
} else {
|
|
161
|
-
let r =
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return r!.futrue!
|
|
193
|
+
let r = this.get_object(g.id, q, fill);
|
|
194
|
+
objects.push(r);
|
|
195
|
+
return r
|
|
165
196
|
}
|
|
166
197
|
})
|
|
198
|
+
g.query_list = list;
|
|
199
|
+
g.input_witness.forEach((q) => {
|
|
200
|
+
objects.push(this.get_object(g.id, q, fill));
|
|
201
|
+
})
|
|
167
202
|
})
|
|
168
203
|
|
|
169
204
|
// objects info
|
|
@@ -175,18 +210,22 @@ export class GuardParser {
|
|
|
175
210
|
let r = res.find(r => r.data?.objectId == q as string);
|
|
176
211
|
if (!r) { ERROR(Errors.Fail, 'query object not match')}
|
|
177
212
|
let object = this.object_query(r!.data);
|
|
178
|
-
if (!object) { ERROR(Errors.Fail, 'object fail')}
|
|
213
|
+
if (!object) { ERROR(Errors.Fail, 'query object fail')}
|
|
179
214
|
query.push(object!);
|
|
180
215
|
})
|
|
181
|
-
|
|
182
|
-
let
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
216
|
+
res.forEach(q => {
|
|
217
|
+
let r1 = g.variable.find(v => v.future == q.data?.objectId);
|
|
218
|
+
let r2 = g.input_witness.find(v => v.future == q.data?.objectId)
|
|
219
|
+
// not match r1 || r2 means query-cmd, not witness-cmd
|
|
220
|
+
if (r1 || r2) {
|
|
221
|
+
let object = this.object_query(q.data, 'witness');
|
|
222
|
+
if (!object) { ERROR(Errors.Fail, 'witness object fail') }
|
|
223
|
+
witness.push(object!);
|
|
224
|
+
}
|
|
186
225
|
})
|
|
187
226
|
})
|
|
188
227
|
|
|
189
|
-
return {query:query, witness:witness} as PassportQuery;
|
|
228
|
+
return {guard:this.guards, query:query, witness:witness} as PassportQuery;
|
|
190
229
|
}
|
|
191
230
|
|
|
192
231
|
private object_query = (data: any, method:string='guard_query') : Guard_Query_Object | undefined=> {
|
|
@@ -213,11 +252,11 @@ export class Passport {
|
|
|
213
252
|
|
|
214
253
|
get_object () { return this.passport }
|
|
215
254
|
// return passport object used
|
|
216
|
-
constructor (protocol:Protocol,
|
|
217
|
-
if (!
|
|
255
|
+
constructor (protocol:Protocol, query:PassportQuery) {
|
|
256
|
+
if (!query.guard || query.guard.length > Passport.MAX_GUARD_COUNT) {
|
|
218
257
|
ERROR(Errors.InvalidParam, 'guards' )
|
|
219
258
|
}
|
|
220
|
-
if (!Protocol.IsValidObjects(
|
|
259
|
+
if (!Protocol.IsValidObjects(query.guard)) {
|
|
221
260
|
ERROR(Errors.IsValidObjects, 'guards')
|
|
222
261
|
}
|
|
223
262
|
|
|
@@ -229,10 +268,10 @@ export class Passport {
|
|
|
229
268
|
});
|
|
230
269
|
|
|
231
270
|
// add others guards, if any
|
|
232
|
-
|
|
271
|
+
query.guard.forEach((g) => {
|
|
233
272
|
txb.moveCall({
|
|
234
273
|
target:protocol.PassportFn('guard_add') as FnCallType,
|
|
235
|
-
arguments:[this.passport, Protocol.TXB_OBJECT(txb,
|
|
274
|
+
arguments:[this.passport, Protocol.TXB_OBJECT(txb, g)]
|
|
236
275
|
});
|
|
237
276
|
})
|
|
238
277
|
|
|
@@ -247,13 +286,13 @@ export class Passport {
|
|
|
247
286
|
|
|
248
287
|
// rules: 'verify' & 'query' in turns;'verify' at final end.
|
|
249
288
|
query?.query.forEach((q) => {
|
|
250
|
-
let
|
|
289
|
+
let address = txb.moveCall({
|
|
251
290
|
target: protocol.PassportFn('passport_verify') as FnCallType,
|
|
252
291
|
arguments: [ this.passport, txb.object(Protocol.CLOCK_OBJECT)]
|
|
253
292
|
});
|
|
254
293
|
txb.moveCall({
|
|
255
294
|
target: q.target as FnCallType,
|
|
256
|
-
arguments: [ txb.object(q.object), this.passport,
|
|
295
|
+
arguments: [ txb.object(q.object), this.passport, address ],
|
|
257
296
|
typeArguments: q.types,
|
|
258
297
|
})
|
|
259
298
|
})
|
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 { GuardVariable } from './guard';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
export enum MODULES {
|
|
@@ -56,64 +56,48 @@ export type FnCallType = `${string}::${string}::${string}`;
|
|
|
56
56
|
|
|
57
57
|
export enum OperatorType {
|
|
58
58
|
TYPE_QUERY = 1, // query wowok object
|
|
59
|
-
TYPE_FUTURE_QUERY = 2,
|
|
60
|
-
TYPE_QUERY_FROM_CONTEXT = 3,
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
TYPE_LOGIC_AS_U256_GREATER = 11,
|
|
61
|
+
TYPE_LOGIC_AS_U256_GREATER_EQUAL = 12,
|
|
62
|
+
TYPE_LOGIC_AS_U256_LESSER = 13,
|
|
63
|
+
TYPE_LOGIC_AS_U256_LESSER_EQUAL = 14,
|
|
64
|
+
TYPE_LOGIC_AS_U256_EQUAL = 15,
|
|
65
|
+
TYPE_LOGIC_EQUAL = 16, // TYPE&DATA(vector<u8>) MUST BE EQUAL
|
|
66
|
+
TYPE_LOGIC_HAS_SUBSTRING = 17, // SUBSTRING
|
|
69
67
|
TYPE_LOGIC_ALWAYS_TRUE = 18, // aways true
|
|
70
68
|
TYPE_LOGIC_NOT = 19, // NOT
|
|
71
69
|
TYPE_LOGIC_AND = 20, // AND
|
|
72
70
|
TYPE_LOGIC_OR = 21, // OR
|
|
73
71
|
}
|
|
74
72
|
|
|
75
|
-
export enum
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
TYPE_CONTEXT_option_u8 = 83,
|
|
94
|
-
TYPE_CONTEXT_option_u64 = 84,
|
|
95
|
-
TYPE_CONTEXT_option_u128 = 85,*/
|
|
73
|
+
export enum ValueType {
|
|
74
|
+
TYPE_BOOL = 100,
|
|
75
|
+
TYPE_ADDRESS = 101,
|
|
76
|
+
TYPE_U64 = 102,
|
|
77
|
+
TYPE_U8 = 103,
|
|
78
|
+
TYPE_VEC_U8 = 104,
|
|
79
|
+
TYPE_U128 = 105,
|
|
80
|
+
TYPE_VEC_ADDRESS = 106,
|
|
81
|
+
TYPE_VEC_BOOL = 107,
|
|
82
|
+
TYPE_VEC_VEC_U8 = 108,
|
|
83
|
+
TYPE_VEC_U64 = 109,
|
|
84
|
+
TYPE_VEC_U128 = 110,
|
|
85
|
+
TYPE_OPTION_ADDRESS = 111,
|
|
86
|
+
TYPE_OPTION_BOOL = 112,
|
|
87
|
+
TYPE_OPTION_U8 = 113,
|
|
88
|
+
TYPE_OPTION_U64 = 114,
|
|
89
|
+
TYPE_OPTION_U128 = 115,
|
|
90
|
+
TYPE_U256 = 116,
|
|
96
91
|
}
|
|
97
92
|
|
|
98
|
-
export enum
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
TYPE_STATIC_vec_u8 = 104,
|
|
104
|
-
TYPE_STATIC_u128 = 105,
|
|
105
|
-
TYPE_STATIC_vec_address = 106,
|
|
106
|
-
TYPE_STATIC_vec_bool = 107,
|
|
107
|
-
TYPE_STATIC_vec_vec_u8 = 108,
|
|
108
|
-
TYPE_STATIC_vec_u64 = 109,
|
|
109
|
-
TYPE_STATIC_vec_u128 = 110,
|
|
110
|
-
TYPE_STATIC_option_address = 111,
|
|
111
|
-
TYPE_STATIC_option_bool = 112,
|
|
112
|
-
TYPE_STATIC_option_u8 = 113,
|
|
113
|
-
TYPE_STATIC_option_u64 = 114,
|
|
114
|
-
TYPE_STATIC_option_u128 = 115,
|
|
93
|
+
export enum ContextType {
|
|
94
|
+
TYPE_SIGNER = 60,
|
|
95
|
+
TYPE_CLOCK = 61,
|
|
96
|
+
TYPE_WITNESS_ID = 62,
|
|
97
|
+
TYPE_VARIABLE = 80,
|
|
115
98
|
}
|
|
116
99
|
|
|
100
|
+
export type VariableType = ValueType | ContextType.TYPE_WITNESS_ID;
|
|
117
101
|
export type Data_Type = ValueType | OperatorType | ContextType;
|
|
118
102
|
|
|
119
103
|
export enum ENTRYPOINT {
|
|
@@ -145,7 +129,7 @@ export class Protocol {
|
|
|
145
129
|
case ENTRYPOINT.devnet:
|
|
146
130
|
break;
|
|
147
131
|
case ENTRYPOINT.testnet:
|
|
148
|
-
this.package = "
|
|
132
|
+
this.package = "0xffd87461cb8e54e0ae612a0d6a323d8c6fb4a85933e7481d3f4926ced3e6d7c7";
|
|
149
133
|
this.everyone_guard = "0x78a41fcc4f566360839613f6b917fb101ae015e56b43143f496f265b6422fddc";
|
|
150
134
|
this.graphql = 'https://sui-testnet.mystenlabs.com/graphql';
|
|
151
135
|
break;
|
|
@@ -307,7 +291,7 @@ export class RpcResultParser {
|
|
|
307
291
|
export type Query_Param = {
|
|
308
292
|
objectid: string;
|
|
309
293
|
callback: (protocol:Protocol, response:SuiObjectResponse, param:Query_Param, option:SuiObjectDataOptions)=>void;
|
|
310
|
-
parser?: (result:any[], guardid: string, chain_sense_bsc:Uint8Array, variable?:
|
|
294
|
+
parser?: (result:any[], guardid: string, chain_sense_bsc:Uint8Array, variable?:GuardVariable) => boolean;
|
|
311
295
|
data?: any; // response data filted by callback
|
|
312
|
-
variables?:
|
|
296
|
+
variables?: GuardVariable;
|
|
313
297
|
};
|
package/src/utils.ts
CHANGED
|
@@ -118,6 +118,12 @@ export class Bcs {
|
|
|
118
118
|
ser_u64(data:number) : Uint8Array {
|
|
119
119
|
return this.bcs.ser(BCS.U64, data).toBytes();
|
|
120
120
|
}
|
|
121
|
+
ser_u128(data:number) : Uint8Array {
|
|
122
|
+
return this.bcs.ser(BCS.U128, data).toBytes();
|
|
123
|
+
}
|
|
124
|
+
ser_u256(data:number) : Uint8Array {
|
|
125
|
+
return this.bcs.ser(BCS.U256, data).toBytes();
|
|
126
|
+
}
|
|
121
127
|
ser_string(data:string) : Uint8Array {
|
|
122
128
|
return this.bcs.ser(BCS.STRING, data).toBytes();
|
|
123
129
|
}
|