wowok 1.7.13 → 1.7.16
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/arbitration.d.ts.map +1 -1
- package/dist/arbitration.js +21 -32
- package/dist/arbitration.js.map +1 -1
- package/dist/entity.d.ts +1 -0
- package/dist/entity.d.ts.map +1 -1
- package/dist/entity.js +12 -6
- package/dist/entity.js.map +1 -1
- package/dist/exception.d.ts +2 -1
- package/dist/exception.d.ts.map +1 -1
- package/dist/exception.js +1 -0
- package/dist/exception.js.map +1 -1
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +8 -4
- package/dist/guard.js.map +1 -1
- package/dist/payment.d.ts +2 -2
- package/dist/payment.d.ts.map +1 -1
- package/dist/payment.js +2 -2
- package/dist/payment.js.map +1 -1
- package/dist/protocol.d.ts +21 -19
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +211 -58
- package/dist/protocol.js.map +1 -1
- package/dist/service.d.ts +2 -2
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +5 -6
- package/dist/service.js.map +1 -1
- package/package.json +5 -2
- package/src/arbitration.ts +0 -551
- package/src/demand.ts +0 -300
- package/src/entity.ts +0 -171
- package/src/exception.ts +0 -37
- package/src/guard.ts +0 -810
- package/src/index.ts +0 -40
- package/src/machine.ts +0 -542
- package/src/passport.ts +0 -777
- package/src/payment.ts +0 -94
- package/src/permission.ts +0 -550
- package/src/progress.ts +0 -367
- package/src/protocol.ts +0 -549
- package/src/repository.ts +0 -680
- package/src/resource.ts +0 -155
- package/src/service.ts +0 -1349
- package/src/treasury.ts +0 -425
- package/src/utils.ts +0 -660
- package/src/wowok.ts +0 -70
- package/tsconfig.json +0 -30
- package/tsconfig.tsbuildinfo +0 -1
- package/webpack.config.cjs +0 -23
package/src/resource.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { Protocol, FnCallType, TxbObject, TxbAddress} from './protocol.js';
|
|
2
|
-
import { IsValidDesription, IsValidAddress, IsValidName, IsValidArray, } from './utils.js';
|
|
3
|
-
import { ERROR, Errors } from './exception.js';
|
|
4
|
-
import { type TransactionResult, Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
5
|
-
import { Entity } from './entity.js';
|
|
6
|
-
|
|
7
|
-
export interface Tags { // tag am address
|
|
8
|
-
address: string; // address to tag
|
|
9
|
-
name?: string; // named address
|
|
10
|
-
tags: string[]; // tags for address
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface TagData {
|
|
14
|
-
tag: string; // tag name
|
|
15
|
-
address: string[]; // objects in folder
|
|
16
|
-
}
|
|
17
|
-
export enum TagName {
|
|
18
|
-
Like = "like",
|
|
19
|
-
Dislike = "dislike",
|
|
20
|
-
Launch = 'launch',
|
|
21
|
-
Order = 'order',
|
|
22
|
-
Payment = 'payment',
|
|
23
|
-
Progress = 'progress',
|
|
24
|
-
//Account = 'account',
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class Resource {
|
|
28
|
-
static MAX_ADDRESS_COUNT_FOR_TAG = 1000; // max address count
|
|
29
|
-
static MAX_TAG_COUNT_FOR_ADDRESS = 64; // max tag count for an address
|
|
30
|
-
//static MAX_ADDRESS_COUNT_FOR_MARK = 200; // max address count for a mark
|
|
31
|
-
//static MAX_MARK_COUNT = 600; // max mark count
|
|
32
|
-
|
|
33
|
-
protected object:TxbObject;
|
|
34
|
-
protected txb;
|
|
35
|
-
|
|
36
|
-
get_object() { return this.object }
|
|
37
|
-
private constructor(txb:TransactionBlock) {
|
|
38
|
-
this.txb = txb;
|
|
39
|
-
this.object = '';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static From(txb:TransactionBlock, object:TxbObject) : Resource {
|
|
43
|
-
let r = new Resource(txb);
|
|
44
|
-
r.object = Protocol.TXB_OBJECT(txb, object);
|
|
45
|
-
return r
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
launch() : TxbAddress{
|
|
49
|
-
if (!this.object) ERROR(Errors.Fail, 'launch object Invalid');
|
|
50
|
-
return this.txb.moveCall({
|
|
51
|
-
target:Protocol.Instance().resourceFn('create') as FnCallType,
|
|
52
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object)]
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
private resolve_add(address:TransactionResult | string, tags:string[]) {
|
|
57
|
-
if (tags.find(v => v===TagName.Like)) {
|
|
58
|
-
Entity.From(this.txb).mark(this, address, TagName.Like);
|
|
59
|
-
}
|
|
60
|
-
if (tags.find(v => v===TagName.Dislike)) {
|
|
61
|
-
Entity.From(this.txb).mark(this, address, TagName.Dislike);
|
|
62
|
-
}
|
|
63
|
-
return (tags.filter(v => v !== TagName.Like && v !== TagName.Dislike && IsValidName(v)));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
add(address:TransactionResult | string, tags:string[], name?:string) {
|
|
67
|
-
if (typeof(address) === 'string' && !IsValidAddress(address)) {
|
|
68
|
-
ERROR(Errors.IsValidAddress, 'Resource: add.address');
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
var realtags = this.resolve_add(address, tags);
|
|
72
|
-
if (!name && realtags.length === 0) return;
|
|
73
|
-
|
|
74
|
-
if (name && !IsValidName(name)) ERROR(Errors.IsValidName, 'Resource: add.name');
|
|
75
|
-
if (realtags.length > Resource.MAX_TAG_COUNT_FOR_ADDRESS) {
|
|
76
|
-
realtags = realtags.slice(0, Resource.MAX_TAG_COUNT_FOR_ADDRESS)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
this.txb.moveCall({
|
|
80
|
-
target:Protocol.Instance().resourceFn('add') as FnCallType,
|
|
81
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
82
|
-
typeof(address) === 'string' ? this.txb.pure.address(address) : address,
|
|
83
|
-
this.txb.pure.option('string', name),
|
|
84
|
-
this.txb.pure.vector('string', realtags)
|
|
85
|
-
]
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
remove(address:TransactionResult | string, tags:string[]) {
|
|
90
|
-
if (typeof(address) === 'string' && !IsValidAddress(address)) {
|
|
91
|
-
ERROR(Errors.IsValidAddress, 'Resource: remove.address');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
this.txb.moveCall({
|
|
95
|
-
target:Protocol.Instance().resourceFn('remove') as FnCallType,
|
|
96
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
97
|
-
typeof(address) === 'string' ? this.txb.pure.address(address) : address,
|
|
98
|
-
this.txb.pure.vector('string', tags)
|
|
99
|
-
]
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
removeall(address: TxbAddress) {
|
|
104
|
-
if (typeof(address) === 'string' && !IsValidAddress(address)) {
|
|
105
|
-
ERROR(Errors.IsValidAddress, 'Resource: removeall.address');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
this.txb.moveCall({
|
|
109
|
-
target:Protocol.Instance().resourceFn('removeall') as FnCallType,
|
|
110
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
111
|
-
typeof(address) === 'string' ? this.txb.pure.address(address) : address,
|
|
112
|
-
]
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
static TagData(tags: Tags[], innerTag:boolean=true) : TagData[] {
|
|
117
|
-
const data : TagData[] = [];
|
|
118
|
-
tags.forEach(v => {
|
|
119
|
-
v.tags.forEach(i => {
|
|
120
|
-
const f = data.find(k => k.tag === i);
|
|
121
|
-
if (f) {
|
|
122
|
-
if (!f.address.find(k => k === v.address)) { // add address
|
|
123
|
-
f.address.push(v.address)
|
|
124
|
-
}
|
|
125
|
-
} else {
|
|
126
|
-
data.push({tag:i, address:[v.address]}); // add tag
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
})
|
|
130
|
-
if (innerTag) {
|
|
131
|
-
(Object.keys(TagName) as Array<keyof typeof TagName>).forEach(i => {
|
|
132
|
-
if (!data.find(v => v.tag === TagName[i])) {
|
|
133
|
-
data.push({tag:TagName[i], address:[]})
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
}
|
|
137
|
-
return data;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
static Tags(data: TagData) : Tags[] {
|
|
141
|
-
const tags : Tags[] = [];
|
|
142
|
-
data.address.forEach(v => {
|
|
143
|
-
const f = tags.find(i => i.address === v);
|
|
144
|
-
if (f) {
|
|
145
|
-
if (!f.tags.find(k => k === data.tag)) {
|
|
146
|
-
f.tags.push(data.tag)
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
tags.push({address:v, tags:[data.tag]})
|
|
150
|
-
}
|
|
151
|
-
})
|
|
152
|
-
return tags;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|