wowok 1.7.10 → 1.7.13
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/entity.d.ts +21 -4
- package/dist/entity.d.ts.map +1 -1
- package/dist/entity.js +67 -39
- package/dist/entity.js.map +1 -1
- package/dist/guard.d.ts +3 -1
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +31 -6
- package/dist/guard.js.map +1 -1
- package/dist/passport.d.ts +3 -1
- package/dist/passport.d.ts.map +1 -1
- package/dist/passport.js +69 -18
- package/dist/passport.js.map +1 -1
- package/dist/permission.d.ts +2 -0
- package/dist/permission.d.ts.map +1 -1
- package/dist/permission.js +4 -0
- package/dist/permission.js.map +1 -1
- package/dist/protocol.d.ts +1 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +9 -8
- package/dist/protocol.js.map +1 -1
- package/dist/repository.d.ts +2 -1
- package/dist/repository.d.ts.map +1 -1
- package/dist/repository.js +33 -0
- package/dist/repository.js.map +1 -1
- package/dist/service.d.ts +1 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +19 -0
- package/dist/service.js.map +1 -1
- package/dist/utils.d.ts +2 -11
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +17 -26
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/entity.ts +84 -39
- package/src/guard.ts +32 -10
- package/src/passport.ts +79 -19
- package/src/permission.ts +4 -0
- package/src/protocol.ts +10 -9
- package/src/repository.ts +33 -1
- package/src/service.ts +19 -1
- package/src/utils.ts +22 -34
- package/tsconfig.tsbuildinfo +1 -1
package/src/passport.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { type TransactionObjectInput, Inputs, Transaction as TransactionBlock, T
|
|
|
2
2
|
import { SuiObjectResponse } from '@mysten/sui/client';
|
|
3
3
|
import { FnCallType, GuardObject, Protocol, ContextType, OperatorType, Data_Type,
|
|
4
4
|
ValueType, SER_VALUE, IsValidOperatorType } from './protocol.js';
|
|
5
|
-
import { parse_object_type, array_unique, Bcs, ulebDecode, IsValidAddress, IsValidArray, insertAtHead, readOption, readOptionString } from './utils.js';
|
|
5
|
+
import { parse_object_type, array_unique, Bcs, ulebDecode, IsValidAddress, IsValidArray, insertAtHead, readOption, readOptionString, deepCopy } from './utils.js';
|
|
6
6
|
import { ERROR, Errors } from './exception.js';
|
|
7
|
-
import { Guard, GuardMaker } from './guard.js';
|
|
7
|
+
import { CMD_CHECK_GUARD, Guard, GuardMaker } from './guard.js';
|
|
8
8
|
import { bcs } from '@mysten/sui/bcs';
|
|
9
9
|
|
|
10
10
|
export type Guard_Query_Object = {
|
|
@@ -102,7 +102,7 @@ export class GuardParser {
|
|
|
102
102
|
switch (current.type) {
|
|
103
103
|
case OperatorType.TYPE_LOGIC_NOT:
|
|
104
104
|
current.ret_type = ValueType.TYPE_BOOL;
|
|
105
|
-
if (stack.length < 1) ERROR(Errors.Fail,
|
|
105
|
+
if (stack.length < 1) ERROR(Errors.Fail, `ResolveData: TYPE_LOGIC_NOT`);
|
|
106
106
|
|
|
107
107
|
var param = stack.pop() as DeGuardData;
|
|
108
108
|
if (!param.ret_type || param.ret_type != ValueType.TYPE_BOOL) {
|
|
@@ -121,6 +121,18 @@ export class GuardParser {
|
|
|
121
121
|
ERROR(Errors.Fail, 'ResolveData: TYPE_NUMBER_ADDRESS type invalid');
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
current.child.push(param);
|
|
125
|
+
stack.push(current);
|
|
126
|
+
return;
|
|
127
|
+
case OperatorType.TYPE_STRING_LOWERCASE:
|
|
128
|
+
current.ret_type = ValueType.TYPE_STRING;
|
|
129
|
+
if (stack.length < 1) ERROR(Errors.Fail, 'ResolveData: TYPE_STRING_LOWERCASE');
|
|
130
|
+
|
|
131
|
+
var param = stack.pop() as DeGuardData;
|
|
132
|
+
if (!param.ret_type || param.ret_type !== ValueType.TYPE_STRING) {
|
|
133
|
+
ERROR(Errors.Fail, 'ResolveData: TYPE_STRING_LOWERCASE type invalid');
|
|
134
|
+
}
|
|
135
|
+
|
|
124
136
|
current.child.push(param);
|
|
125
137
|
stack.push(current);
|
|
126
138
|
return;
|
|
@@ -244,12 +256,13 @@ export class GuardParser {
|
|
|
244
256
|
return;
|
|
245
257
|
|
|
246
258
|
}
|
|
247
|
-
ERROR(Errors.Fail, 'OperateParamCount: type
|
|
259
|
+
ERROR(Errors.Fail, 'OperateParamCount: type invalid ' + current.type);
|
|
248
260
|
}
|
|
249
261
|
|
|
250
|
-
private static Parse_Guard_Helper(guards: string[], res:SuiObjectResponse[]) {
|
|
262
|
+
private static Parse_Guard_Helper(guards: string[], res:SuiObjectResponse[]) : GuardParser{
|
|
251
263
|
const protocol = Protocol.Instance();
|
|
252
264
|
const me = new GuardParser(guards);
|
|
265
|
+
|
|
253
266
|
res.forEach((r) => {
|
|
254
267
|
const c = r.data?.content as any;
|
|
255
268
|
if (!c) ERROR(Errors.Fail, 'Parse_Guard_Helper invalid content');
|
|
@@ -267,25 +280,70 @@ export class GuardParser {
|
|
|
267
280
|
return me
|
|
268
281
|
}
|
|
269
282
|
|
|
270
|
-
static Create = async (guards: string[]
|
|
283
|
+
static Create = async (guards: string[]) : Promise<GuardParser | undefined> => {
|
|
271
284
|
if (!IsValidArray(guards, IsValidAddress)) {
|
|
272
|
-
|
|
273
|
-
return undefined;
|
|
285
|
+
ERROR(Errors.InvalidParam, 'GuardParser.Create: guards invalid');
|
|
274
286
|
}
|
|
275
287
|
|
|
276
288
|
let guard_list = array_unique(guards);
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
289
|
+
let check_guards = [...guard_list];
|
|
290
|
+
let i = 0; const parsers : GuardParser[] = [];
|
|
291
|
+
|
|
292
|
+
for (;i < GuardParser.MAX_REPOSITORY_DEPTH; ++i) {
|
|
293
|
+
const res = await Protocol.Instance().query_raw(check_guards);
|
|
294
|
+
const p = GuardParser.Parse_Guard_Helper(guards, res);
|
|
295
|
+
|
|
296
|
+
const repositories: string[] = [];
|
|
297
|
+
p.guardlist().forEach((g) => {
|
|
298
|
+
g.input.forEach((i) => {
|
|
299
|
+
if (i.cmd !== undefined && CMD_CHECK_GUARD.includes(i.cmd)) {
|
|
300
|
+
if (i.identifier !== undefined) {
|
|
301
|
+
const id = g.constant.find((c) => c.identifier === i.identifier);
|
|
302
|
+
if (id && id.value) {
|
|
303
|
+
repositories.push(id.value);
|
|
304
|
+
}
|
|
305
|
+
} else if (i.value) {
|
|
306
|
+
repositories.push(i.value as string);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
parsers.push(p);
|
|
313
|
+
if (repositories.length === 0) {
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
check_guards = await GuardParser.RepositoryGuards(repositories);
|
|
318
|
+
if (check_guards.length === 0) {
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (i >= GuardParser.MAX_REPOSITORY_DEPTH) {
|
|
324
|
+
ERROR(Errors.Fail, `GuardParser.Create: Retrieve guards from the Repository with a maximum depth of more than ${GuardParser.MAX_REPOSITORY_DEPTH} levels.`);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// concatenate all parsers
|
|
328
|
+
for (let i = 1; i < parsers.length; ++i) {
|
|
329
|
+
parsers[0].guard_list = parsers[0].guard_list.concat(deepCopy(parsers[i].guard_list));
|
|
330
|
+
parsers[0].guards = parsers[0].guards.concat(parsers[i].guards);
|
|
331
|
+
}
|
|
332
|
+
if (parsers.length > 0) {
|
|
333
|
+
return parsers[0];
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// fetch repository guards
|
|
338
|
+
static RepositoryGuards = async (repositories: string[]) : Promise<string[]> => {
|
|
339
|
+
const res = await Protocol.Instance().query_raw(repositories);
|
|
340
|
+
const guards : string[] = [];
|
|
341
|
+
for (let i=0; i < res.length; ++i) {
|
|
342
|
+
if ((res[i].data?.content as any)?.fields?.guard) {
|
|
343
|
+
guards.push((res[i].data?.content as any).fields.guard);
|
|
344
|
+
}
|
|
288
345
|
}
|
|
346
|
+
return guards;
|
|
289
347
|
}
|
|
290
348
|
|
|
291
349
|
future_fills = () : WitnessFill[] => {
|
|
@@ -369,6 +427,7 @@ export class GuardParser {
|
|
|
369
427
|
case ContextType.TYPE_GUARD:
|
|
370
428
|
case OperatorType.TYPE_LOGIC_NOT:
|
|
371
429
|
case OperatorType.TYPE_NUMBER_ADDRESS:
|
|
430
|
+
case OperatorType.TYPE_STRING_LOWERCASE:
|
|
372
431
|
break;
|
|
373
432
|
case OperatorType.TYPE_LOGIC_AS_U256_GREATER:
|
|
374
433
|
case OperatorType.TYPE_LOGIC_AS_U256_GREATER_EQUAL:
|
|
@@ -593,6 +652,7 @@ export class GuardParser {
|
|
|
593
652
|
}
|
|
594
653
|
}
|
|
595
654
|
}
|
|
655
|
+
static MAX_REPOSITORY_DEPTH = 3;
|
|
596
656
|
}
|
|
597
657
|
|
|
598
658
|
export class Passport {
|
package/src/permission.ts
CHANGED
|
@@ -10,6 +10,7 @@ export enum PermissionIndex {
|
|
|
10
10
|
repository_mode = 102,
|
|
11
11
|
repository_policies = 103,
|
|
12
12
|
repository_reference = 104,
|
|
13
|
+
repository_guard = 105,
|
|
13
14
|
|
|
14
15
|
service = 200,
|
|
15
16
|
service_description = 201,
|
|
@@ -30,6 +31,7 @@ export enum PermissionIndex {
|
|
|
30
31
|
service_treasury = 216,
|
|
31
32
|
service_arbitration = 217,
|
|
32
33
|
service_location = 218,
|
|
34
|
+
service_refund = 219,
|
|
33
35
|
|
|
34
36
|
demand = 260,
|
|
35
37
|
demand_refund = 261,
|
|
@@ -93,6 +95,7 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
93
95
|
{index:PermissionIndex.repository_mode, name:'Policy mode', description:'Set Repository mode', module: MODULES.repository},
|
|
94
96
|
{index:PermissionIndex.repository_policies, name:'Policy', description:'Set Repository policies', module: MODULES.repository},
|
|
95
97
|
{index:PermissionIndex.repository_reference, name:'Reference', description:'Set Repository reference', module: MODULES.repository},
|
|
98
|
+
{index:PermissionIndex.repository_guard, name:'Guard', description:'Set Guard for data query', module: MODULES.repository},
|
|
96
99
|
|
|
97
100
|
{index:PermissionIndex.service, name:'Service', description:'Launch new Service', module: MODULES.service},
|
|
98
101
|
{index:PermissionIndex.service_description, name:'Description', description:'Set Service description', module: MODULES.service},
|
|
@@ -112,6 +115,7 @@ export const PermissionInfo : PermissionInfoType[] = [
|
|
|
112
115
|
{index:PermissionIndex.service_treasury, name:'Treasury', description:'Externally withdrawable treasury for compensation or rewards', module: MODULES.service},
|
|
113
116
|
{index:PermissionIndex.service_arbitration, name:'Arbitration', description:'Add/Remove arbitration that allows refunds from orders at any time based on arbitration results', module: MODULES.service},
|
|
114
117
|
{index:PermissionIndex.service_location, name:'Location', description:'Set Service location', module: MODULES.service},
|
|
118
|
+
{index:PermissionIndex.service_refund, name:'Refund', description:'Initiate order refund', module: MODULES.service},
|
|
115
119
|
|
|
116
120
|
{index:PermissionIndex.demand, name:'Demand', description:'Launch new Demand', module: MODULES.demand},
|
|
117
121
|
{index:PermissionIndex.demand_refund, name:'Refund', description:'Refund from Demand', module: MODULES.demand},
|
package/src/protocol.ts
CHANGED
|
@@ -78,6 +78,7 @@ export enum OperatorType {
|
|
|
78
78
|
TYPE_NUMBER_DEVIDE = 5,
|
|
79
79
|
TYPE_NUMBER_MOD = 6,
|
|
80
80
|
TYPE_NUMBER_ADDRESS = 7,
|
|
81
|
+
TYPE_STRING_LOWERCASE = 8, // string to lowercase
|
|
81
82
|
|
|
82
83
|
TYPE_LOGIC_AS_U256_GREATER = 11,
|
|
83
84
|
TYPE_LOGIC_AS_U256_GREATER_EQUAL = 12,
|
|
@@ -210,15 +211,15 @@ export enum ENTRYPOINT {
|
|
|
210
211
|
}
|
|
211
212
|
|
|
212
213
|
const TESTNET = {
|
|
213
|
-
wowok: "
|
|
214
|
-
wowok_origin:'
|
|
215
|
-
base: '
|
|
216
|
-
base_origin: '
|
|
217
|
-
|
|
218
|
-
wowok_object: '
|
|
219
|
-
entity_object: '
|
|
220
|
-
treasury_cap:'
|
|
221
|
-
oracle_object:'
|
|
214
|
+
wowok: "0x245f15f58b5e5bd790e7dcdb5bd66d647b4fc60c6265c6a91f20e33cbef54202",
|
|
215
|
+
wowok_origin:'0x245f15f58b5e5bd790e7dcdb5bd66d647b4fc60c6265c6a91f20e33cbef54202' ,
|
|
216
|
+
base: '0x5322c1df09a3d0fd4cb5cd933dc39ee11872a10b21c5aef794702661070ab182',
|
|
217
|
+
base_origin: '0x5322c1df09a3d0fd4cb5cd933dc39ee11872a10b21c5aef794702661070ab182',
|
|
218
|
+
|
|
219
|
+
wowok_object: '0x88db80974d677ab6c8a783f5c89e41ae9ecbb76962684788523f5df4acde40a4',
|
|
220
|
+
entity_object: '0x160816194a1b50534d96c73064ac69af76e1e72262adf7b17d8552a1b833a263',
|
|
221
|
+
treasury_cap:'0xc1a799cf0b3e6854359e4cd1724b20b25d612a0d951bacb7c7d208f6d26534a7',
|
|
222
|
+
oracle_object:'0xec39bc61ff38d3ed54b2a5afedc21158ff93686064f353ae169f97907b493fde',
|
|
222
223
|
}
|
|
223
224
|
const MAINNET = {
|
|
224
225
|
wowok: "",
|
package/src/repository.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Protocol, FnCallType, ValueType, RepositoryValueType, RepositoryAddress, PermissionObject, PassportObject, TxbObject, } from './protocol.js';
|
|
1
|
+
import { Protocol, FnCallType, ValueType, RepositoryValueType, RepositoryAddress, PermissionObject, PassportObject, TxbObject, GuardObject, } from './protocol.js';
|
|
2
2
|
import { PermissionIndexType, Permission } from './permission.js'
|
|
3
3
|
import { Bcs, array_unique, IsValidDesription, IsValidAddress, IsValidArray, IsValidName, ValueTypeConvert, IsValidStringLength, uint2address} from './utils.js';
|
|
4
4
|
import { ERROR, Errors } from './exception.js';
|
|
@@ -446,6 +446,38 @@ export class Repository {
|
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
448
|
|
|
449
|
+
set_guard(guard?:GuardObject | null, passport?:PassportObject) {
|
|
450
|
+
if (guard && !Protocol.IsValidObjects([guard])) {
|
|
451
|
+
ERROR(Errors.IsValidObjects, `set_guard.guard ${guard}`);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
if (passport) {
|
|
455
|
+
if (guard) {
|
|
456
|
+
this.txb.moveCall({
|
|
457
|
+
target:Protocol.Instance().repositoryFn('guard_set_with_passport') as FnCallType,
|
|
458
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
459
|
+
})
|
|
460
|
+
} else {
|
|
461
|
+
this.txb.moveCall({
|
|
462
|
+
target:Protocol.Instance().repositoryFn('guard_none_with_passport') as FnCallType,
|
|
463
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
464
|
+
})
|
|
465
|
+
}
|
|
466
|
+
} else {
|
|
467
|
+
if (guard) {
|
|
468
|
+
this.txb.moveCall({
|
|
469
|
+
target:Protocol.Instance().repositoryFn('guard_set') as FnCallType,
|
|
470
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
471
|
+
})
|
|
472
|
+
} else {
|
|
473
|
+
this.txb.moveCall({
|
|
474
|
+
target:Protocol.Instance().repositoryFn('guard_none') as FnCallType,
|
|
475
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)]
|
|
476
|
+
})
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
449
481
|
set_policy_description(policy:string, description:string, passport?:PassportObject) {
|
|
450
482
|
if (!Repository.IsValidName(policy)) {
|
|
451
483
|
ERROR(Errors.IsValidName, 'policy')
|
package/src/service.ts
CHANGED
|
@@ -965,6 +965,24 @@ export class Service {
|
|
|
965
965
|
})
|
|
966
966
|
}
|
|
967
967
|
} */
|
|
968
|
+
refund_by_service(order:OrderObject, passport?:PassportObject) {
|
|
969
|
+
if (!Protocol.IsValidObjects([order])) {
|
|
970
|
+
ERROR(Errors.IsValidObjects, `refund_by_service.order ${order}`)
|
|
971
|
+
}
|
|
972
|
+
if (passport) {
|
|
973
|
+
this.txb.moveCall({
|
|
974
|
+
target:Protocol.Instance().serviceFn('refund_by_service_with_passport') as FnCallType,
|
|
975
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
976
|
+
typeArguments:[this.pay_token_type]
|
|
977
|
+
})
|
|
978
|
+
} else {
|
|
979
|
+
this.txb.moveCall({
|
|
980
|
+
target:Protocol.Instance().serviceFn('refund_by_service') as FnCallType,
|
|
981
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, order), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
982
|
+
typeArguments:[this.pay_token_type]
|
|
983
|
+
})
|
|
984
|
+
}
|
|
985
|
+
}
|
|
968
986
|
|
|
969
987
|
pause(pause:boolean, passport?:PassportObject) {
|
|
970
988
|
if (passport) {
|
|
@@ -996,7 +1014,7 @@ export class Service {
|
|
|
996
1014
|
typeArguments:[this.pay_token_type, arb_type]
|
|
997
1015
|
})
|
|
998
1016
|
}
|
|
999
|
-
|
|
1017
|
+
|
|
1000
1018
|
refund(order:OrderObject, refund_guard?:GuardObject, passport?:PassportObject) {
|
|
1001
1019
|
if (!Protocol.IsValidObjects([order])) {
|
|
1002
1020
|
ERROR(Errors.IsValidObjects, 'refund.order')
|
package/src/utils.ts
CHANGED
|
@@ -120,6 +120,20 @@ export const concatenate = (resultConstructor:any, ...arrays:any[]) => {
|
|
|
120
120
|
return result;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
export function deepCopy<T>(obj: T): T {
|
|
124
|
+
if (obj === null || typeof obj !== 'object') {
|
|
125
|
+
return obj;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const copy: any = Array.isArray(obj) ? [] : {};
|
|
129
|
+
for (const key in obj) {
|
|
130
|
+
if (obj.hasOwnProperty(key)) {
|
|
131
|
+
copy[key] = deepCopy(obj[key]);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return copy;
|
|
135
|
+
}
|
|
136
|
+
|
|
123
137
|
export const parseObjectType = (chain_type:string | null | undefined, header:string='payment::Payment<') : string => {
|
|
124
138
|
if (chain_type) {
|
|
125
139
|
const i = chain_type.indexOf(header);
|
|
@@ -163,22 +177,17 @@ export function parse_object_type(object_data:string) : string[] {
|
|
|
163
177
|
return object_type;
|
|
164
178
|
}
|
|
165
179
|
|
|
166
|
-
export interface Entity_Info {
|
|
167
|
-
name: string;
|
|
168
|
-
description?: string;
|
|
169
|
-
avatar?: string;
|
|
170
|
-
twitter?: string;
|
|
171
|
-
discord?: string;
|
|
172
|
-
homepage?: string;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
180
|
export class Bcs {
|
|
176
181
|
private static _instance : any;
|
|
182
|
+
|
|
183
|
+
private VecMapStruct = bcs.struct('VecMap', {
|
|
184
|
+
contents: bcs.vector(bcs.tuple([bcs.string(), bcs.string()])),
|
|
185
|
+
});
|
|
186
|
+
|
|
177
187
|
private EntStruct = bcs.struct('EntStruct', {
|
|
178
|
-
|
|
188
|
+
description: bcs.string(),
|
|
189
|
+
info: this.VecMapStruct,
|
|
179
190
|
resource: bcs.option(bcs.Address),
|
|
180
|
-
safer_name: bcs.vector(bcs.string()),
|
|
181
|
-
safer_value: bcs.vector(bcs.string()),
|
|
182
191
|
like: bcs.u32(),
|
|
183
192
|
dislike: bcs.u32(),
|
|
184
193
|
});
|
|
@@ -186,14 +195,6 @@ export class Bcs {
|
|
|
186
195
|
nick: bcs.string(),
|
|
187
196
|
tags: bcs.vector(bcs.string()),
|
|
188
197
|
})
|
|
189
|
-
private PersonalInfo = bcs.struct('PersonalInfo', {
|
|
190
|
-
name: bcs.string(),
|
|
191
|
-
description: bcs.string(),
|
|
192
|
-
avatar: bcs.string(),
|
|
193
|
-
twitter: bcs.string(),
|
|
194
|
-
discord: bcs.string(),
|
|
195
|
-
homepage: bcs.string(),
|
|
196
|
-
})
|
|
197
198
|
private Guards = bcs.struct('Guards', {
|
|
198
199
|
address: bcs.option(bcs.Address),
|
|
199
200
|
})
|
|
@@ -325,20 +326,7 @@ export class Bcs {
|
|
|
325
326
|
const struct_vec = bcs.vector(bcs.u8()).parse(data);
|
|
326
327
|
return this.EntStruct.parse(Uint8Array.from(struct_vec))
|
|
327
328
|
}
|
|
328
|
-
|
|
329
|
-
return this.PersonalInfo.serialize({
|
|
330
|
-
name: info.name ?? '',
|
|
331
|
-
description: info.description ?? '',
|
|
332
|
-
avatar: info.avatar ?? '',
|
|
333
|
-
twitter: info.twitter ?? '',
|
|
334
|
-
discord: info.discord ?? '',
|
|
335
|
-
homepage: info.homepage ?? '',
|
|
336
|
-
}).toBytes();
|
|
337
|
-
}
|
|
338
|
-
de_entInfo(data:Uint8Array | undefined) : any | undefined {
|
|
339
|
-
if (!data || data.length === 0) return undefined
|
|
340
|
-
return this.PersonalInfo.parse(data);
|
|
341
|
-
}
|
|
329
|
+
|
|
342
330
|
de_tags(data:Uint8Array | undefined) : any | undefined {
|
|
343
331
|
if (!data || data.length === 0) return undefined;
|
|
344
332
|
const struct_vec = bcs.vector(bcs.u8()).parse(data);
|