wowok 1.6.67 → 1.6.69
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/entity.ts +12 -43
- package/src/protocol.ts +10 -9
- package/src/repository.ts +0 -3
- package/src/resource.ts +101 -120
- package/src/treasury.ts +1 -1
- package/src/utils.ts +12 -3
package/package.json
CHANGED
package/src/entity.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { Protocol, FnCallType, TxbObject, ResourceAddress, PermissionObject, ResourceObject} from './protocol';
|
|
2
2
|
import { IsValidDesription, IsValidAddress, IsValidName, isValidHttpUrl, Bcs, IsValidArray, } from './utils';
|
|
3
3
|
import { ERROR, Errors } from './exception';
|
|
4
|
-
import {
|
|
4
|
+
import { TagName, Resource } from './resource';
|
|
5
5
|
import { Transaction as TransactionBlock, TransactionResult } from '@mysten/sui/transactions';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
name: string;
|
|
9
|
-
value: string;
|
|
10
|
-
}
|
|
7
|
+
|
|
11
8
|
export interface Entity_Info {
|
|
12
9
|
name: string;
|
|
13
10
|
description?: string;
|
|
@@ -33,7 +30,7 @@ export class Entity {
|
|
|
33
30
|
return r
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
mark(resource:Resource, address:string | TransactionResult, like:
|
|
33
|
+
mark(resource:Resource, address:string | TransactionResult, like:TagName.Like | TagName.Dislike) {
|
|
37
34
|
if (typeof(address) === 'string' && !IsValidAddress(address)) {
|
|
38
35
|
ERROR(Errors.IsValidAddress, like);
|
|
39
36
|
}
|
|
@@ -44,41 +41,6 @@ export class Entity {
|
|
|
44
41
|
typeof(address) === 'string' ? this.txb.pure.address(address) : address]
|
|
45
42
|
})
|
|
46
43
|
}
|
|
47
|
-
/*
|
|
48
|
-
add_safer(safer: Safer[], bExistModify:boolean=true) {
|
|
49
|
-
if (safer.length === 0) return ;
|
|
50
|
-
if (!IsValidArray(safer, (v:Safer) => {
|
|
51
|
-
if (!IsValidName(v.name) || !IsValidDesription(v.value)) {
|
|
52
|
-
return false
|
|
53
|
-
}
|
|
54
|
-
})) {
|
|
55
|
-
ERROR(Errors.InvalidParam, 'add_safer');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const name = safer.map((v)=>v.name);
|
|
59
|
-
const value = safer.map((v)=>v.value);
|
|
60
|
-
this.txb.moveCall({
|
|
61
|
-
target:Protocol.Instance().entityFn('safer_add') as FnCallType,
|
|
62
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', name),
|
|
63
|
-
this.txb.pure.vector('string', value), this.txb.pure.bool(bExistModify)]
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
remove_safer(name:string[], removeall?:boolean) {
|
|
68
|
-
if (name.length === 0 && !removeall) return;
|
|
69
|
-
|
|
70
|
-
if (removeall) {
|
|
71
|
-
this.txb.moveCall({
|
|
72
|
-
target:Protocol.Instance().entityFn('safer_remove_all') as FnCallType,
|
|
73
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object)]
|
|
74
|
-
})
|
|
75
|
-
} else {
|
|
76
|
-
this.txb.moveCall({
|
|
77
|
-
target:Protocol.Instance().entityFn('safer_remove') as FnCallType,
|
|
78
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', name)]
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
}*/
|
|
82
44
|
|
|
83
45
|
update(info: Entity_Info) {
|
|
84
46
|
if (info?.name && !IsValidName(info.name)) ERROR(Errors.IsValidName, 'update');
|
|
@@ -116,14 +78,21 @@ export class Entity {
|
|
|
116
78
|
})
|
|
117
79
|
}
|
|
118
80
|
|
|
119
|
-
destroy_resource(resource:Resource) {
|
|
81
|
+
destroy_resource(resource:Resource) { // Resource must self-owned.
|
|
120
82
|
return this.txb.moveCall({
|
|
121
83
|
target:Protocol.Instance().entityFn('resource_destroy') as FnCallType,
|
|
122
84
|
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, resource.get_object())]
|
|
123
85
|
})
|
|
124
86
|
}
|
|
125
87
|
|
|
126
|
-
|
|
88
|
+
use_resource(resource:Resource) { // Resource must self-owned.
|
|
89
|
+
return this.txb.moveCall({
|
|
90
|
+
target:Protocol.Instance().entityFn('resource_use') as FnCallType,
|
|
91
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, resource.get_object())]
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
transfer_resource(resource:Resource, new_address:string) { // Resource must self-owned.
|
|
127
96
|
if (!IsValidAddress(new_address)) ERROR(Errors.IsValidAddress, 'transfer_resource');
|
|
128
97
|
|
|
129
98
|
return this.txb.moveCall({
|
package/src/protocol.ts
CHANGED
|
@@ -64,6 +64,7 @@ export type PaymentAddress = TransactionResult;
|
|
|
64
64
|
export type ReceivedObject = TransactionResult | string | TransactionArgument;
|
|
65
65
|
export type CoinWrapperObject = TransactionResult;
|
|
66
66
|
|
|
67
|
+
export type TxbAddress = string | TransactionResult;
|
|
67
68
|
export type TxbObject = string | TransactionResult | TransactionArgument | GuardObject | RepositoryObject | PermissionObject | MachineObject | PassportObject |
|
|
68
69
|
DemandObject | ServiceObject | OrderObject | DiscountObject | DemandObject | ResourceObject | EntityObject | ArbitrationObject | ArbObject | TreasuryObject;
|
|
69
70
|
|
|
@@ -219,15 +220,15 @@ const TESTNET = {
|
|
|
219
220
|
}
|
|
220
221
|
*/
|
|
221
222
|
const TESTNET = {
|
|
222
|
-
wowok: "
|
|
223
|
-
wowok_origin:'
|
|
224
|
-
base: '
|
|
225
|
-
base_origin: '
|
|
226
|
-
|
|
227
|
-
wowok_object: '
|
|
228
|
-
entity_object: '
|
|
229
|
-
treasury_cap:'
|
|
230
|
-
oracle_object:'
|
|
223
|
+
wowok: "0xe98ef6b139de57b59d71496dc2b48d4e36e195013194748bdfe90688a9821132",
|
|
224
|
+
wowok_origin:'0xe98ef6b139de57b59d71496dc2b48d4e36e195013194748bdfe90688a9821132' ,
|
|
225
|
+
base: '0xa475682a229bcf913b2d561370ed44a055d0091a4a02b25d780d48aed03df267',
|
|
226
|
+
base_origin: '0xa475682a229bcf913b2d561370ed44a055d0091a4a02b25d780d48aed03df267',
|
|
227
|
+
|
|
228
|
+
wowok_object: '0xf2d3dc8667e21ca03fd808e51f7f9f291bad861bab1f62b4f07f39834830a5d9',
|
|
229
|
+
entity_object: '0x40eb7a354875548a55a196c0f1cbbf217026fee9d86f94615b992878a6629e03',
|
|
230
|
+
treasury_cap:'0x405105d71add6c57c1de0dbceb2676320ddb5bbe4c3cfdf79c7b23783e9e3761',
|
|
231
|
+
oracle_object:'0x4592d870a3c79c37d49fe55d1eba3ed2e82bcf707822d698beeceacce0dabdc6',
|
|
231
232
|
}
|
|
232
233
|
const MAINNET = {
|
|
233
234
|
wowok: "",
|
package/src/repository.ts
CHANGED
|
@@ -460,9 +460,6 @@ export class Repository {
|
|
|
460
460
|
static IsValidValue = (value:Uint8Array) => {
|
|
461
461
|
return value.length < Repository.MAX_VALUE_LENGTH;
|
|
462
462
|
}
|
|
463
|
-
static parseObjectType = (chain_type?:string | null) : string => {
|
|
464
|
-
return parseObjectType(chain_type, 'repository::Repository<');
|
|
465
|
-
}
|
|
466
463
|
|
|
467
464
|
static rpc_de_data(fields:any) : RepData [] {
|
|
468
465
|
const rep: RepData[] = fields?.map((v:any) => {
|
package/src/resource.ts
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import { Protocol, FnCallType, TxbObject,
|
|
1
|
+
import { Protocol, FnCallType, TxbObject, TxbAddress} from './protocol';
|
|
2
2
|
import { IsValidDesription, IsValidAddress, IsValidName, IsValidArray, } from './utils';
|
|
3
3
|
import { ERROR, Errors } from './exception';
|
|
4
4
|
import { type TransactionResult, Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
5
|
+
import { Entity } from './entity';
|
|
5
6
|
|
|
6
7
|
export interface Tags { // tag am address
|
|
7
8
|
address: string; // address to tag
|
|
8
|
-
|
|
9
|
+
name?: string; // named address
|
|
9
10
|
tags: string[]; // tags for address
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export interface
|
|
13
|
-
|
|
13
|
+
export interface TagData {
|
|
14
|
+
tag: string; // tag name
|
|
14
15
|
address: string[]; // objects in folder
|
|
15
|
-
}
|
|
16
|
-
export enum
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
}
|
|
17
|
+
export enum TagName {
|
|
18
|
+
Like = "like",
|
|
19
|
+
Dislike = "dislike",
|
|
20
|
+
Launch = 'launch',
|
|
21
|
+
Order = 'order',
|
|
22
|
+
Payment = 'payment'
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export class Resource {
|
|
25
|
-
static
|
|
26
|
-
static
|
|
26
|
+
static MAX_ADDRESS_COUNT_FOR_TAG = 1000; // max address count
|
|
27
|
+
static MAX_TAG_COUNT_FOR_ADDRESS = 64; // max tag count for an address
|
|
28
|
+
//static MAX_ADDRESS_COUNT_FOR_MARK = 200; // max address count for a mark
|
|
29
|
+
//static MAX_MARK_COUNT = 600; // max mark count
|
|
27
30
|
|
|
28
31
|
protected object:TxbObject;
|
|
29
32
|
protected txb;
|
|
@@ -40,146 +43,124 @@ export class Resource {
|
|
|
40
43
|
return r
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
launch() {
|
|
46
|
+
launch() : TxbAddress{
|
|
44
47
|
if (!this.object) ERROR(Errors.Fail, 'launch object Invalid');
|
|
45
|
-
this.txb.moveCall({
|
|
48
|
+
return this.txb.moveCall({
|
|
46
49
|
target:Protocol.Instance().resourceFn('create') as FnCallType,
|
|
47
50
|
arguments:[Protocol.TXB_OBJECT(this.txb, this.object)]
|
|
48
51
|
});
|
|
49
52
|
}
|
|
50
|
-
add(name:string, object:string[] | TransactionResult[]) {
|
|
51
|
-
if (object.length === 0) return;
|
|
52
|
-
|
|
53
|
-
var bString = true;
|
|
54
|
-
if (!IsValidName(name)) ERROR(Errors.IsValidName, 'add.name');
|
|
55
|
-
if (!IsValidArray(object, (item:any) => {
|
|
56
|
-
if (typeof(item) === 'string') {
|
|
57
|
-
return IsValidAddress(item)
|
|
58
|
-
} else {
|
|
59
|
-
bString = false;
|
|
60
|
-
}
|
|
61
|
-
return true;
|
|
62
|
-
})) {
|
|
63
|
-
ERROR(Errors.IsValidArray, 'add.object');
|
|
64
|
-
}
|
|
65
53
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(name),
|
|
70
|
-
this.txb.pure.vector('address', object as string[])]
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
this.txb.moveCall({
|
|
74
|
-
target:Protocol.Instance().resourceFn('add') as FnCallType,
|
|
75
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(name),
|
|
76
|
-
this.txb.makeMoveVec({elements:object as TransactionResult[], type:'address'})]
|
|
77
|
-
});
|
|
54
|
+
private resolve_add(address:TransactionResult | string, tags:string[]) {
|
|
55
|
+
if (tags.find(v => v===TagName.Like)) {
|
|
56
|
+
Entity.From(this.txb).mark(this, address, TagName.Like);
|
|
78
57
|
}
|
|
58
|
+
if (tags.find(v => v===TagName.Dislike)) {
|
|
59
|
+
Entity.From(this.txb).mark(this, address, TagName.Dislike);
|
|
60
|
+
}
|
|
61
|
+
return (tags.filter(v => v !== TagName.Like && v !== TagName.Dislike && IsValidName(v)));
|
|
79
62
|
}
|
|
80
63
|
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (!IsValidArray(name, IsValidName)) ERROR(Errors.IsValidArray, 'add2.name');
|
|
64
|
+
add(address:TransactionResult | string, tags:string[], name?:string) {
|
|
65
|
+
if (typeof(address) === 'string' && !IsValidAddress(address)) {
|
|
66
|
+
ERROR(Errors.IsValidAddress, 'Resource: add.address');
|
|
67
|
+
}
|
|
86
68
|
|
|
87
|
-
this.
|
|
88
|
-
|
|
89
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), typeof(object) === 'string' ? this.txb.pure.address(object) : object,
|
|
90
|
-
this.txb.pure.vector('string', name)]
|
|
91
|
-
});
|
|
92
|
-
}
|
|
69
|
+
var realtags = this.resolve_add(address, tags);
|
|
70
|
+
if (!name && realtags.length === 0) return;
|
|
93
71
|
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
var bString = true;
|
|
99
|
-
if (!IsValidArray(object, (item:any) => {
|
|
100
|
-
if (typeof(item) === 'string') {
|
|
101
|
-
return IsValidAddress(item)
|
|
102
|
-
} else {
|
|
103
|
-
bString = false;
|
|
104
|
-
}
|
|
105
|
-
return true;
|
|
106
|
-
})) {
|
|
107
|
-
ERROR(Errors.IsValidArray, 'remove.object');
|
|
72
|
+
if (name && !IsValidName(name)) ERROR(Errors.IsValidName, 'Resource: add.name');
|
|
73
|
+
if (realtags.length > Resource.MAX_TAG_COUNT_FOR_ADDRESS) {
|
|
74
|
+
realtags = realtags.slice(0, Resource.MAX_TAG_COUNT_FOR_ADDRESS)
|
|
108
75
|
}
|
|
109
76
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(name),
|
|
119
|
-
bString ? this.txb.pure.vector('address', object as string[]) : this.txb.makeMoveVec({elements:object as TransactionResult[], type:'address'})]
|
|
120
|
-
});
|
|
121
|
-
}
|
|
77
|
+
this.txb.moveCall({
|
|
78
|
+
target:Protocol.Instance().resourceFn('add') as FnCallType,
|
|
79
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
80
|
+
typeof(address) === 'string' ? this.txb.pure.address(address) : address,
|
|
81
|
+
this.txb.pure.option('string', name),
|
|
82
|
+
this.txb.pure.vector('string', realtags)
|
|
83
|
+
]
|
|
84
|
+
});
|
|
122
85
|
}
|
|
123
86
|
|
|
124
|
-
|
|
125
|
-
if (typeof(
|
|
126
|
-
ERROR(Errors.IsValidAddress, 'Resource:
|
|
87
|
+
remove(address:TransactionResult | string, tags:string[]) {
|
|
88
|
+
if (typeof(address) === 'string' && !IsValidAddress(address)) {
|
|
89
|
+
ERROR(Errors.IsValidAddress, 'Resource: remove.address');
|
|
127
90
|
}
|
|
128
|
-
if (!IsValidArray(name, IsValidName)) ERROR(Errors.InvalidParam, 'Resource: remove2');
|
|
129
|
-
if (!name) return
|
|
130
91
|
|
|
131
92
|
this.txb.moveCall({
|
|
132
|
-
target:Protocol.Instance().resourceFn('
|
|
93
|
+
target:Protocol.Instance().resourceFn('remove') as FnCallType,
|
|
133
94
|
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
134
|
-
typeof(
|
|
135
|
-
this.txb.pure.vector('string',
|
|
95
|
+
typeof(address) === 'string' ? this.txb.pure.address(address) : address,
|
|
96
|
+
this.txb.pure.vector('string', tags)
|
|
97
|
+
]
|
|
136
98
|
});
|
|
137
99
|
}
|
|
138
100
|
|
|
139
|
-
|
|
140
|
-
if (
|
|
101
|
+
removeall(address: TxbAddress) {
|
|
102
|
+
if (typeof(address) === 'string' && !IsValidAddress(address)) {
|
|
103
|
+
ERROR(Errors.IsValidAddress, 'Resource: removeall.address');
|
|
104
|
+
}
|
|
141
105
|
|
|
142
106
|
this.txb.moveCall({
|
|
143
|
-
target:Protocol.Instance().resourceFn('
|
|
144
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
145
|
-
this.txb.pure.
|
|
146
|
-
|
|
107
|
+
target:Protocol.Instance().resourceFn('removeall') as FnCallType,
|
|
108
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
109
|
+
typeof(address) === 'string' ? this.txb.pure.address(address) : address,
|
|
110
|
+
]
|
|
111
|
+
});
|
|
147
112
|
}
|
|
148
113
|
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
ERROR(Errors.IsValidAddress, 'Resource: add_tags.object');
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (nick && !IsValidName(nick)) ERROR(Errors.IsValidName, 'Resource: add_tags.nick');
|
|
157
|
-
if (!IsValidArray(tags, IsValidName)) ERROR(Errors.IsValidArray, 'Resource: add_tags.tags');
|
|
158
|
-
if (tags.length > Resource.MAX_TAGS) {
|
|
159
|
-
tags = tags.slice(0, Resource.MAX_TAGS)
|
|
160
|
-
}
|
|
114
|
+
query(address: TxbAddress) {
|
|
115
|
+
if (typeof(address) === 'string' && !IsValidAddress(address)) {
|
|
116
|
+
ERROR(Errors.IsValidAddress, 'Resource: query.address');
|
|
117
|
+
}
|
|
161
118
|
|
|
162
119
|
this.txb.moveCall({
|
|
163
|
-
target:Protocol.Instance().resourceFn('
|
|
120
|
+
target:Protocol.Instance().resourceFn('query') as FnCallType,
|
|
164
121
|
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
165
|
-
typeof(
|
|
166
|
-
this.txb.pure.string(nick),
|
|
167
|
-
this.txb.pure.vector('string', tags)
|
|
122
|
+
typeof(address) === 'string' ? this.txb.pure.address(address) : address,
|
|
168
123
|
]
|
|
169
|
-
})
|
|
124
|
+
})
|
|
170
125
|
}
|
|
171
126
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
127
|
+
static TagData(tags: Tags[], innerTag:boolean=true) : TagData[] {
|
|
128
|
+
const data : TagData[] = [];
|
|
129
|
+
tags.forEach(v => {
|
|
130
|
+
v.tags.forEach(i => {
|
|
131
|
+
const f = data.find(k => k.tag === i);
|
|
132
|
+
if (f) {
|
|
133
|
+
if (!f.address.find(k => k === v.address)) { // add address
|
|
134
|
+
f.address.push(v.address)
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
data.push({tag:i, address:[v.address]}); // add tag
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
if (innerTag) {
|
|
142
|
+
(Object.keys(TagName) as Array<keyof typeof TagName>).forEach(i => {
|
|
143
|
+
if (!data.find(v => v.tag === TagName[i])) {
|
|
144
|
+
data.push({tag:TagName[i], address:[]})
|
|
145
|
+
}
|
|
146
|
+
})
|
|
175
147
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
148
|
+
return data;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static Tags(data: TagData) : Tags[] {
|
|
152
|
+
const tags : Tags[] = [];
|
|
153
|
+
data.address.forEach(v => {
|
|
154
|
+
const f = tags.find(i => i.address === v);
|
|
155
|
+
if (f) {
|
|
156
|
+
if (!f.tags.find(k => k === data.tag)) {
|
|
157
|
+
f.tags.push(data.tag)
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
tags.push({address:v, tags:[data.tag]})
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
return tags;
|
|
183
164
|
}
|
|
184
165
|
}
|
|
185
166
|
|
package/src/treasury.ts
CHANGED
|
@@ -415,7 +415,7 @@ export class Treasury {
|
|
|
415
415
|
})
|
|
416
416
|
this.permission = new_permission
|
|
417
417
|
}
|
|
418
|
-
static parseObjectType = (chain_type
|
|
418
|
+
static parseObjectType = (chain_type?:string) : string => {
|
|
419
419
|
return parseObjectType(chain_type, 'treasury::Treasury<')
|
|
420
420
|
}
|
|
421
421
|
|
package/src/utils.ts
CHANGED
|
@@ -177,6 +177,10 @@ export class Bcs {
|
|
|
177
177
|
"safer_value": "vector<string>",
|
|
178
178
|
'like': BCS.U32,
|
|
179
179
|
'dislike': BCS.U32,
|
|
180
|
+
});
|
|
181
|
+
this.bcs.registerStructType('TagStruct', {
|
|
182
|
+
'nick': 'string',
|
|
183
|
+
'tags': "vector<string>",
|
|
180
184
|
})
|
|
181
185
|
this.bcs.registerStructType('PersonalInfo', {
|
|
182
186
|
'name': 'vector<u8>',
|
|
@@ -335,7 +339,12 @@ export class Bcs {
|
|
|
335
339
|
r.name = new TextDecoder().decode(Uint8Array.from(r.name));
|
|
336
340
|
r.description = new TextDecoder().decode(Uint8Array.from(r.description));
|
|
337
341
|
return r
|
|
338
|
-
}
|
|
342
|
+
}
|
|
343
|
+
de_tags(data:Uint8Array | undefined) : any {
|
|
344
|
+
if (!data || data.length === 0) return ''
|
|
345
|
+
const struct_vec = this.bcs.de('vector<u8>', data);
|
|
346
|
+
return this.bcs.de('TagStruct', Uint8Array.from(struct_vec));
|
|
347
|
+
}
|
|
339
348
|
de_perms(data:Uint8Array | undefined) : any {
|
|
340
349
|
if (!data || data.length < 1) return ''
|
|
341
350
|
let r = this.bcs.de('Perms', data);
|
|
@@ -390,8 +399,8 @@ export const MAX_NAME_LENGTH = 64;
|
|
|
390
399
|
export const MAX_ENDPOINT_LENGTH = 1024;
|
|
391
400
|
// export const OptionNone = (txb:TransactionBlock) : TransactionArgument => { return txb.pure([], BCS.U8) };
|
|
392
401
|
|
|
393
|
-
export const IsValidDesription = (description:string) : boolean => { return description
|
|
394
|
-
export const IsValidName = (name
|
|
402
|
+
export const IsValidDesription = (description:string) : boolean => { return description.length <= MAX_DESCRIPTION_LENGTH }
|
|
403
|
+
export const IsValidName = (name?:string) : boolean => { if(!name) return false; return name.length <= MAX_NAME_LENGTH && name.length != 0 }
|
|
395
404
|
export const IsValidName_AllowEmpty = (name:string) : boolean => { return name.length <= MAX_NAME_LENGTH }
|
|
396
405
|
export const IsValidEndpoint = (endpoint:string) : boolean => {
|
|
397
406
|
return (endpoint.length > 0 && endpoint.length <= MAX_ENDPOINT_LENGTH && isValidHttpUrl(endpoint)) ;
|