wowok 1.1.4 → 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 +6 -6
- package/dist/demand.d.ts.map +1 -1
- package/dist/demand.js +38 -38
- 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 +66 -58
- 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.map +1 -1
- package/dist/machine.js +1 -1
- package/dist/passport.d.ts +16 -9
- package/dist/passport.d.ts.map +1 -1
- package/dist/passport.js +69 -59
- package/dist/permission.d.ts.map +1 -1
- package/dist/permission.js +1 -1
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +10 -1
- package/dist/protocol.d.ts +19 -8
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +31 -26
- package/dist/repository.d.ts.map +1 -1
- package/dist/repository.js +11 -1
- package/dist/resource.d.ts +16 -0
- package/dist/resource.d.ts.map +1 -0
- package/dist/resource.js +83 -0
- package/dist/reward.d.ts.map +1 -1
- package/dist/reward.js +10 -1
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +11 -1
- 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.map +1 -1
- package/dist/vote.js +1 -1
- 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 +42 -42
- package/src/entity.ts +83 -0
- package/src/exception.ts +1 -0
- package/src/guard.ts +71 -57
- package/src/index.ts +11 -8
- package/src/machine.ts +3 -2
- package/src/passport.ts +70 -65
- package/src/permission.ts +5 -4
- package/src/progress.ts +11 -3
- package/src/protocol.ts +41 -31
- package/src/repository.ts +12 -2
- package/src/resource.ts +90 -0
- package/src/reward.ts +11 -2
- package/src/service.ts +12 -1
- package/src/utils.ts +12 -1
- package/src/vote.ts +2 -1
- package/src/wowok.ts +56 -0
package/README.md
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
# Wowok
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Create, collaborate, and transact on your own terms with the AI-driven web3 collaboration protocol.
|
|
5
5
|
|
|
6
6
|
Github: [https://github.com/wowok-ai/sdk](https://github.com/wowok-ai/sdk)
|
|
7
|
-
Examples: [https://github.com/wowok-ai/sdk-examples](https://github.com/wowok-ai/sdk-examples)
|
|
7
|
+
Examples: [https://github.com/wowok-ai/sdk-examples](https://github.com/wowok-ai/sdk-examples)
|
|
8
|
+
Website: [https://wowok-ai.github.io/wowok-ai](https://wowok-ai.github.io/wowok-ai)
|
|
8
9
|
Docs: [https://github.com/wowok-ai/sdk/wiki](https://github.com/wowok-ai/sdk/wiki)
|
|
9
10
|
|
|
11
|
+
Introduction: [https://wowok-ai.github.io/wowok-ai/](https://wowok-ai.github.io/wowok-ai/)
|
|
12
|
+
X: [https://x.com/Wowok_Ai](https://x.com/Wowok_Ai)
|
|
13
|
+
|
|
14
|
+
|
|
10
15
|
### Installation
|
|
11
16
|
|
|
12
17
|
```
|
package/dist/demand.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { type TransactionResult } from '@mysten/sui.js/transactions';
|
|
2
2
|
import { Protocol, PassportObject, PermissionObject, GuardObject, DemandAddress, TxbObject } from './protocol';
|
|
3
3
|
export declare class Demand {
|
|
4
|
-
protected
|
|
4
|
+
protected bounty_type: string;
|
|
5
5
|
protected permission: PermissionObject;
|
|
6
6
|
protected object: TxbObject;
|
|
7
7
|
protected protocol: Protocol;
|
|
8
|
-
|
|
8
|
+
get_bounty_type(): string;
|
|
9
9
|
get_object(): TxbObject;
|
|
10
|
-
static From(protocol: Protocol,
|
|
10
|
+
static From(protocol: Protocol, bounty_type: string, permission: PermissionObject, object: TxbObject): Demand;
|
|
11
11
|
private constructor();
|
|
12
|
-
static New(protocol: Protocol,
|
|
12
|
+
static New(protocol: Protocol, bounty_type: string, permission: PermissionObject, description: string, bounty: TransactionResult, passport?: PassportObject): Demand;
|
|
13
13
|
launch(): DemandAddress;
|
|
14
14
|
destroy(): void;
|
|
15
15
|
refund(passport?: PassportObject): void;
|
|
@@ -17,10 +17,10 @@ export declare class Demand {
|
|
|
17
17
|
set_guard(guard?: GuardObject, passport?: PassportObject): void;
|
|
18
18
|
set_description(description: string, passport?: PassportObject): void;
|
|
19
19
|
yes(service_address: string, passport?: PassportObject): void;
|
|
20
|
-
deposit(
|
|
20
|
+
deposit(bounty: TxbObject): void;
|
|
21
21
|
present(service_address: string, service_pay_type: string, tips: string, passport?: PassportObject): void;
|
|
22
22
|
change_permission(new_permission: PermissionObject): void;
|
|
23
|
-
static
|
|
23
|
+
static MAX_BOUNTY_COUNT: number;
|
|
24
24
|
static MAX_PRESENTERS_COUNT: number;
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=demand.d.ts.map
|
package/dist/demand.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"demand.d.ts","sourceRoot":"","sources":["../src/demand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAc,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"demand.d.ts","sourceRoot":"","sources":["../src/demand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAc,QAAQ,EAAE,cAAc,EAA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O;CACrC"}
|
package/dist/demand.js
CHANGED
|
@@ -3,47 +3,47 @@ import { Protocol } from './protocol';
|
|
|
3
3
|
import { IsValidDesription, IsValidUint, IsValidAddress, IsValidArgType, } from './utils';
|
|
4
4
|
import { Errors, ERROR } from './exception';
|
|
5
5
|
export class Demand {
|
|
6
|
-
|
|
6
|
+
bounty_type;
|
|
7
7
|
permission;
|
|
8
8
|
object;
|
|
9
9
|
protocol;
|
|
10
|
-
|
|
10
|
+
get_bounty_type() { return this.bounty_type; }
|
|
11
11
|
get_object() { return this.object; }
|
|
12
|
-
static From(protocol,
|
|
13
|
-
let d = new Demand(protocol,
|
|
12
|
+
static From(protocol, bounty_type, permission, object) {
|
|
13
|
+
let d = new Demand(protocol, bounty_type, permission);
|
|
14
14
|
d.object = Protocol.TXB_OBJECT(protocol.CurrentSession(), object);
|
|
15
15
|
return d;
|
|
16
16
|
}
|
|
17
|
-
constructor(protocol,
|
|
18
|
-
this.
|
|
17
|
+
constructor(protocol, bounty_type, permission) {
|
|
18
|
+
this.bounty_type = bounty_type;
|
|
19
19
|
this.permission = permission;
|
|
20
20
|
this.protocol = protocol;
|
|
21
21
|
this.object = '';
|
|
22
22
|
}
|
|
23
|
-
static New(protocol,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
ERROR(Errors.IsValidObjects, 'permission, earnest');
|
|
23
|
+
static New(protocol, bounty_type, permission, description, bounty, passport) {
|
|
24
|
+
if (!Protocol.IsValidObjects([permission, bounty])) {
|
|
25
|
+
ERROR(Errors.IsValidObjects, 'permission, bounty');
|
|
27
26
|
}
|
|
28
27
|
if (!IsValidDesription(description)) {
|
|
29
28
|
ERROR(Errors.IsValidDesription);
|
|
30
29
|
}
|
|
31
|
-
if (!IsValidArgType(
|
|
32
|
-
ERROR(Errors.IsValidArgType,
|
|
30
|
+
if (!IsValidArgType(bounty_type)) {
|
|
31
|
+
ERROR(Errors.IsValidArgType, bounty_type);
|
|
33
32
|
}
|
|
33
|
+
let d = new Demand(protocol, bounty_type, permission);
|
|
34
34
|
let txb = protocol.CurrentSession();
|
|
35
35
|
if (passport) {
|
|
36
36
|
d.object = txb.moveCall({
|
|
37
37
|
target: protocol.DemandFn('new_with_passport'),
|
|
38
|
-
arguments: [passport, txb.pure(description),
|
|
39
|
-
typeArguments: [
|
|
38
|
+
arguments: [passport, txb.pure(description), bounty, Protocol.TXB_OBJECT(txb, permission)],
|
|
39
|
+
typeArguments: [bounty_type],
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
43
|
d.object = txb.moveCall({
|
|
44
44
|
target: protocol.DemandFn('new'),
|
|
45
|
-
arguments: [txb.pure(description),
|
|
46
|
-
typeArguments: [
|
|
45
|
+
arguments: [txb.pure(description), bounty, Protocol.TXB_OBJECT(txb, permission)],
|
|
46
|
+
typeArguments: [bounty_type],
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
return d;
|
|
@@ -53,7 +53,7 @@ export class Demand {
|
|
|
53
53
|
return txb.moveCall({
|
|
54
54
|
target: this.protocol.DemandFn('create'),
|
|
55
55
|
arguments: [Protocol.TXB_OBJECT(txb, this.object)],
|
|
56
|
-
typeArguments: [this.
|
|
56
|
+
typeArguments: [this.bounty_type],
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
destroy() {
|
|
@@ -61,7 +61,7 @@ export class Demand {
|
|
|
61
61
|
txb.moveCall({
|
|
62
62
|
target: this.protocol.DemandFn('destroy'),
|
|
63
63
|
arguments: [Protocol.TXB_OBJECT(txb, this.object)],
|
|
64
|
-
typeArguments: [this.
|
|
64
|
+
typeArguments: [this.bounty_type]
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
refund(passport) {
|
|
@@ -70,14 +70,14 @@ export class Demand {
|
|
|
70
70
|
txb.moveCall({
|
|
71
71
|
target: this.protocol.DemandFn('refund_with_passport'),
|
|
72
72
|
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
73
|
-
typeArguments: [this.
|
|
73
|
+
typeArguments: [this.bounty_type],
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
77
|
txb.moveCall({
|
|
78
78
|
target: this.protocol.DemandFn('refund'),
|
|
79
79
|
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
80
|
-
typeArguments: [this.
|
|
80
|
+
typeArguments: [this.bounty_type],
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -91,7 +91,7 @@ export class Demand {
|
|
|
91
91
|
target: this.protocol.DemandFn('time_expand_with_passport'),
|
|
92
92
|
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(minutes_duration, BCS.U64),
|
|
93
93
|
txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
94
|
-
typeArguments: [this.
|
|
94
|
+
typeArguments: [this.bounty_type],
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
@@ -99,7 +99,7 @@ export class Demand {
|
|
|
99
99
|
target: this.protocol.DemandFn('time_expand'),
|
|
100
100
|
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(minutes_duration, BCS.U64),
|
|
101
101
|
txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
102
|
-
typeArguments: [this.
|
|
102
|
+
typeArguments: [this.bounty_type],
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -114,14 +114,14 @@ export class Demand {
|
|
|
114
114
|
target: this.protocol.DemandFn('guard_set_with_passport'),
|
|
115
115
|
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, guard),
|
|
116
116
|
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
117
|
-
typeArguments: [this.
|
|
117
|
+
typeArguments: [this.bounty_type],
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
121
121
|
txb.moveCall({
|
|
122
122
|
target: this.protocol.DemandFn('guard_none_with_passport'),
|
|
123
123
|
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
124
|
-
typeArguments: [this.
|
|
124
|
+
typeArguments: [this.bounty_type],
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -131,14 +131,14 @@ export class Demand {
|
|
|
131
131
|
target: this.protocol.DemandFn('guard_set'),
|
|
132
132
|
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, guard),
|
|
133
133
|
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
134
|
-
typeArguments: [this.
|
|
134
|
+
typeArguments: [this.bounty_type],
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
else {
|
|
138
138
|
txb.moveCall({
|
|
139
139
|
target: this.protocol.DemandFn('guard_none'),
|
|
140
140
|
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
141
|
-
typeArguments: [this.
|
|
141
|
+
typeArguments: [this.bounty_type],
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -153,14 +153,14 @@ export class Demand {
|
|
|
153
153
|
target: this.protocol.DemandFn('description_set_with_passport'),
|
|
154
154
|
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(description),
|
|
155
155
|
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
156
|
-
typeArguments: [this.
|
|
156
|
+
typeArguments: [this.bounty_type],
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
else {
|
|
160
160
|
txb.moveCall({
|
|
161
161
|
target: this.protocol.DemandFn('description_set'),
|
|
162
162
|
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(description), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
163
|
-
typeArguments: [this.
|
|
163
|
+
typeArguments: [this.bounty_type],
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
}
|
|
@@ -175,7 +175,7 @@ export class Demand {
|
|
|
175
175
|
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object),
|
|
176
176
|
txb.pure(service_address, BCS.ADDRESS),
|
|
177
177
|
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
178
|
-
typeArguments: [this.
|
|
178
|
+
typeArguments: [this.bounty_type],
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
else {
|
|
@@ -184,19 +184,19 @@ export class Demand {
|
|
|
184
184
|
arguments: [Protocol.TXB_OBJECT(txb, this.object),
|
|
185
185
|
txb.pure(service_address, BCS.ADDRESS),
|
|
186
186
|
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
187
|
-
typeArguments: [this.
|
|
187
|
+
typeArguments: [this.bounty_type],
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
deposit(
|
|
192
|
-
if (!Protocol.IsValidObjects([
|
|
191
|
+
deposit(bounty) {
|
|
192
|
+
if (!Protocol.IsValidObjects([bounty])) {
|
|
193
193
|
ERROR(Errors.IsValidObjects);
|
|
194
194
|
}
|
|
195
195
|
let txb = this.protocol.CurrentSession();
|
|
196
196
|
txb.moveCall({
|
|
197
197
|
target: this.protocol.DemandFn('deposit'),
|
|
198
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb,
|
|
199
|
-
typeArguments: [this.
|
|
198
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, bounty)],
|
|
199
|
+
typeArguments: [this.bounty_type],
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
present(service_address, service_pay_type, tips, passport) {
|
|
@@ -215,7 +215,7 @@ export class Demand {
|
|
|
215
215
|
target: this.protocol.DemandFn('present_with_passport'),
|
|
216
216
|
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, service_address),
|
|
217
217
|
txb.pure(tips, BCS.STRING)],
|
|
218
|
-
typeArguments: [this.
|
|
218
|
+
typeArguments: [this.bounty_type, service_pay_type],
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
else {
|
|
@@ -223,7 +223,7 @@ export class Demand {
|
|
|
223
223
|
target: this.protocol.DemandFn('present'),
|
|
224
224
|
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, service_address),
|
|
225
225
|
txb.pure(tips, BCS.STRING)],
|
|
226
|
-
typeArguments: [this.
|
|
226
|
+
typeArguments: [this.bounty_type, service_pay_type],
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
229
|
}
|
|
@@ -235,10 +235,10 @@ export class Demand {
|
|
|
235
235
|
txb.moveCall({
|
|
236
236
|
target: this.protocol.DemandFn('permission_set'),
|
|
237
237
|
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission), Protocol.TXB_OBJECT(txb, new_permission)],
|
|
238
|
-
typeArguments: [this.
|
|
238
|
+
typeArguments: [this.bounty_type]
|
|
239
239
|
});
|
|
240
240
|
this.permission = new_permission;
|
|
241
241
|
}
|
|
242
|
-
static
|
|
242
|
+
static MAX_BOUNTY_COUNT = 200;
|
|
243
243
|
static MAX_PRESENTERS_COUNT = 200;
|
|
244
244
|
}
|
package/dist/entity.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Protocol, TxbObject, ResourceAddress } from './protocol';
|
|
2
|
+
import { Resource } from './resource';
|
|
3
|
+
export interface Entity_Info {
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
avatar?: string;
|
|
7
|
+
twitter?: string;
|
|
8
|
+
discord?: string;
|
|
9
|
+
homepage?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class Entity {
|
|
12
|
+
protected object: TxbObject;
|
|
13
|
+
protected protocol: Protocol;
|
|
14
|
+
get_object(): TxbObject;
|
|
15
|
+
private constructor();
|
|
16
|
+
static From(protocol: Protocol): Entity;
|
|
17
|
+
mark(resource: Resource, address: string, like: 'like' | 'dislike'): void;
|
|
18
|
+
update(info: Entity_Info): void;
|
|
19
|
+
create_resource(description: string): ResourceAddress;
|
|
20
|
+
destroy_resource(resource: Resource): import("@mysten/sui.js/transactions").TransactionResult;
|
|
21
|
+
transfer_resource(resource: Resource, new_address: string): import("@mysten/sui.js/transactions").TransactionResult;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../src/entity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAc,SAAS,EAAE,eAAe,EAAmC,MAAM,YAAY,CAAC;AAG/G,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,MAAM;IAEf,SAAS,CAAC,MAAM,EAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,QAAQ,WAAC;IAEnB,UAAU;IACV,OAAO;IAKP,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAC,QAAQ,GAAI,MAAM;IAMvC,IAAI,CAAC,QAAQ,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,GAAG,SAAS;IAU/D,MAAM,CAAC,IAAI,EAAE,WAAW;IAexB,eAAe,CAAC,WAAW,EAAC,MAAM,GAAI,eAAe;IASrD,gBAAgB,CAAC,QAAQ,EAAC,QAAQ;IAQlC,iBAAiB,CAAC,QAAQ,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM;CAQ1D"}
|
package/dist/entity.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BCS } from '@mysten/bcs';
|
|
2
|
+
import { Protocol } from './protocol';
|
|
3
|
+
import { IsValidDesription, IsValidAddress, IsValidName, isValidHttpUrl, } from './utils';
|
|
4
|
+
import { ERROR, Errors } from './exception';
|
|
5
|
+
export class Entity {
|
|
6
|
+
object;
|
|
7
|
+
protocol;
|
|
8
|
+
get_object() { return this.object; }
|
|
9
|
+
constructor(protocol) {
|
|
10
|
+
this.protocol = protocol;
|
|
11
|
+
this.object = '';
|
|
12
|
+
}
|
|
13
|
+
static From(protocol) {
|
|
14
|
+
let r = new Entity(protocol);
|
|
15
|
+
r.object = Protocol.TXB_OBJECT(protocol.CurrentSession(), protocol.EntityObject());
|
|
16
|
+
return r;
|
|
17
|
+
}
|
|
18
|
+
mark(resource, address, like) {
|
|
19
|
+
if (!IsValidAddress(address))
|
|
20
|
+
ERROR(Errors.IsValidAddress, like);
|
|
21
|
+
let txb = this.protocol.CurrentSession();
|
|
22
|
+
txb.moveCall({
|
|
23
|
+
target: this.protocol.EntityFn(like),
|
|
24
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, resource.get_object()), txb.pure(address, BCS.ADDRESS)]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
update(info) {
|
|
28
|
+
if (!IsValidName(info.name))
|
|
29
|
+
ERROR(Errors.IsValidName, 'update');
|
|
30
|
+
if (info?.description && !IsValidDesription(info.description))
|
|
31
|
+
ERROR(Errors.IsValidDesription, 'update');
|
|
32
|
+
if (info?.avatar && !isValidHttpUrl(info.avatar))
|
|
33
|
+
ERROR(Errors.isValidHttpUrl, 'update:avatar');
|
|
34
|
+
if (info?.twitter && !IsValidName(info.twitter))
|
|
35
|
+
ERROR(Errors.IsValidName, 'update:twitter');
|
|
36
|
+
if (info?.homepage && !isValidHttpUrl(info.homepage))
|
|
37
|
+
ERROR(Errors.isValidHttpUrl, 'update:homepage');
|
|
38
|
+
if (info?.discord && !IsValidName(info.discord))
|
|
39
|
+
ERROR(Errors.IsValidName, 'update:discord');
|
|
40
|
+
let txb = this.protocol.CurrentSession();
|
|
41
|
+
txb.moveCall({
|
|
42
|
+
target: this.protocol.EntityFn('avatar_update'),
|
|
43
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(JSON.stringify(info), BCS.STRING)]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
create_resource(description) {
|
|
47
|
+
if (!IsValidDesription(description))
|
|
48
|
+
ERROR(Errors.IsValidDesription, 'create_resource');
|
|
49
|
+
let txb = this.protocol.CurrentSession();
|
|
50
|
+
return txb.moveCall({
|
|
51
|
+
target: this.protocol.EntityFn('resource_create'),
|
|
52
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(description, BCS.STRING)]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
destroy_resource(resource) {
|
|
56
|
+
let txb = this.protocol.CurrentSession();
|
|
57
|
+
return txb.moveCall({
|
|
58
|
+
target: this.protocol.EntityFn('resource_destroy'),
|
|
59
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, resource.get_object())]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
transfer_resource(resource, new_address) {
|
|
63
|
+
if (!IsValidAddress(new_address))
|
|
64
|
+
ERROR(Errors.IsValidAddress, 'transfer_resource');
|
|
65
|
+
let txb = this.protocol.CurrentSession();
|
|
66
|
+
return txb.moveCall({
|
|
67
|
+
target: this.protocol.EntityFn('resource_transfer'),
|
|
68
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, resource.get_object()), txb.pure(new_address, BCS.ADDRESS)]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
package/dist/exception.d.ts
CHANGED
|
@@ -15,7 +15,8 @@ export declare enum Errors {
|
|
|
15
15
|
IsValidPermissionIndex = "invalid permission index",
|
|
16
16
|
IsValidKey = "invalid key",
|
|
17
17
|
Fail = "fail",
|
|
18
|
-
IsValidIndentifier = "indentifier invalid"
|
|
18
|
+
IsValidIndentifier = "indentifier invalid",
|
|
19
|
+
isValidHttpUrl = "invalid url"
|
|
19
20
|
}
|
|
20
21
|
export declare const ERROR: (error: Errors, info?: any) => never;
|
|
21
22
|
//# sourceMappingURL=exception.d.ts.map
|
package/dist/exception.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AACA,oBAAY,MAAM;IACd,iBAAiB,wBAAwB;IACzC,WAAW,iBAAiB;IAC5B,sBAAsB,iBAAiB;IACvC,eAAe,qBAAqB;IACpC,cAAc,oBAAoB;IAClC,cAAc,yBAAyB;IACvC,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,cAAc,oBAAoB;IAClC,YAAY,kBAAkB;IAC9B,cAAc,oBAAoB;IAClC,UAAU,uBAAuB;IACjC,YAAY,sBAAuB;IACnC,sBAAsB,6BAA6B;IACnD,UAAU,gBAAgB;IAC1B,IAAI,SAAS;IACb,kBAAkB,wBAAwB;
|
|
1
|
+
{"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AACA,oBAAY,MAAM;IACd,iBAAiB,wBAAwB;IACzC,WAAW,iBAAiB;IAC5B,sBAAsB,iBAAiB;IACvC,eAAe,qBAAqB;IACpC,cAAc,oBAAoB;IAClC,cAAc,yBAAyB;IACvC,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,cAAc,oBAAoB;IAClC,YAAY,kBAAkB;IAC9B,cAAc,oBAAoB;IAClC,UAAU,uBAAuB;IACjC,YAAY,sBAAuB;IACnC,sBAAsB,6BAA6B;IACnD,UAAU,gBAAgB;IAC1B,IAAI,SAAS;IACb,kBAAkB,wBAAwB;IAC1C,cAAc,gBAAgB;CACjC;AAED,eAAO,MAAM,KAAK,UAAU,MAAM,SAAQ,GAAG,UAG5C,CAAA"}
|
package/dist/exception.js
CHANGED
|
@@ -17,6 +17,7 @@ export var Errors;
|
|
|
17
17
|
Errors["IsValidKey"] = "invalid key";
|
|
18
18
|
Errors["Fail"] = "fail";
|
|
19
19
|
Errors["IsValidIndentifier"] = "indentifier invalid";
|
|
20
|
+
Errors["isValidHttpUrl"] = "invalid url";
|
|
20
21
|
})(Errors || (Errors = {}));
|
|
21
22
|
export const ERROR = (error, info) => {
|
|
22
23
|
const e = error + info ? (': ' + info) : '';
|
package/dist/guard.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Protocol, GuardAddress, Data_Type, MODULES, ContextType, ValueType, OperatorType,
|
|
2
|
-
export type
|
|
1
|
+
import { Protocol, GuardAddress, Data_Type, MODULES, ContextType, ValueType, OperatorType, ConstantType } from './protocol';
|
|
2
|
+
export type GuardConstant = Map<number, Guard_Vriable>;
|
|
3
3
|
export interface Guard_Vriable {
|
|
4
|
-
type:
|
|
4
|
+
type: ConstantType;
|
|
5
5
|
value?: Uint8Array;
|
|
6
6
|
witness?: Uint8Array;
|
|
7
7
|
}
|
|
@@ -15,29 +15,29 @@ export declare class Guard {
|
|
|
15
15
|
static IsBoolCmd: (cmd: number) => boolean;
|
|
16
16
|
static GetCmd: (cmd: number) => any;
|
|
17
17
|
}
|
|
18
|
-
export declare class
|
|
18
|
+
export declare class GuardConstantHelper {
|
|
19
19
|
static IsValidIndentifier: (identifier: number) => boolean;
|
|
20
|
-
static
|
|
21
|
-
static
|
|
22
|
-
static
|
|
23
|
-
static
|
|
20
|
+
static get_constant_value(constants: GuardConstant, identifier: number, type: ConstantType): Uint8Array | undefined;
|
|
21
|
+
static get_constant_witness(constants: GuardConstant, identifier: number): Uint8Array | undefined;
|
|
22
|
+
static add_future_constant(constants: GuardConstant, identifier: number, witness: any, value?: any, bNeedSerialize?: boolean): void;
|
|
23
|
+
static add_constant(constants: GuardConstant, identifier: number, type: ValueType, value: any, bNeedSerialize?: boolean): false | undefined;
|
|
24
24
|
}
|
|
25
25
|
export declare class GuardMaker {
|
|
26
26
|
protected data: Uint8Array[];
|
|
27
27
|
protected type_validator: Data_Type[];
|
|
28
|
-
protected
|
|
28
|
+
protected constant: GuardConstant;
|
|
29
29
|
private static index;
|
|
30
30
|
private static get_index;
|
|
31
31
|
constructor();
|
|
32
|
-
|
|
32
|
+
add_constant(type: ConstantType, value: any, bNeedSerialize?: boolean): number;
|
|
33
33
|
private serValueParam;
|
|
34
34
|
add_param(type: ValueType | ContextType, param?: any): GuardMaker;
|
|
35
35
|
add_query(module: MODULES, query_name: string, object_address_from: string | number, bWitness?: boolean): GuardMaker;
|
|
36
36
|
add_logic(type: OperatorType): GuardMaker;
|
|
37
37
|
build(bNot?: boolean): GuardMaker;
|
|
38
38
|
IsReady(): boolean;
|
|
39
|
-
combine(otherBuilt: GuardMaker, bAnd?: boolean,
|
|
40
|
-
|
|
39
|
+
combine(otherBuilt: GuardMaker, bAnd?: boolean, bCombinConstant?: boolean): GuardMaker;
|
|
40
|
+
get_constant(): GuardConstant;
|
|
41
41
|
get_input(): Uint8Array[];
|
|
42
42
|
static input_combine(input1: Uint8Array, input2: Uint8Array, bAnd?: boolean): Uint8Array;
|
|
43
43
|
static input_not(input: Uint8Array): Uint8Array;
|
package/dist/guard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAc,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAG,YAAY,EAAE,YAAY,EAAY,MAAM,YAAY,CAA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