wowok 1.0.8 → 1.0.10
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 +2 -1
- package/dist/demand.d.ts +26 -0
- package/dist/demand.js +203 -198
- package/dist/exception.d.ts +18 -0
- package/dist/exception.js +26 -0
- package/dist/graphql.d.ts +4 -0
- package/dist/guard.d.ts +46 -0
- package/dist/guard.js +344 -511
- package/dist/index.d.ts +14 -2
- package/dist/index.js +45 -156
- package/dist/machine.d.ts +45 -0
- package/dist/machine.js +276 -277
- package/dist/passport.d.ts +41 -0
- package/dist/passport.js +321 -140
- package/dist/permission.d.ts +111 -0
- package/dist/permission.js +189 -180
- package/dist/progress.d.ts +31 -0
- package/dist/progress.js +213 -184
- package/dist/protocol.d.ts +164 -0
- package/dist/protocol.js +74 -74
- package/dist/repository.d.ts +46 -0
- package/dist/repository.js +258 -242
- package/dist/reward.d.ts +31 -0
- package/dist/reward.js +242 -256
- package/dist/service.d.ts +94 -0
- package/dist/service.js +839 -883
- package/dist/utils.d.ts +47 -0
- package/dist/utils.js +39 -38
- package/dist/vote.d.ts +31 -0
- package/dist/vote.js +304 -286
- package/package.json +1 -1
- package/src/demand.ts +223 -184
- package/src/exception.ts +23 -0
- package/src/guard.ts +343 -517
- package/src/index.ts +33 -32
- package/src/machine.ts +286 -244
- package/src/passport.ts +363 -159
- package/src/permission.ts +210 -164
- package/src/progress.ts +253 -194
- package/src/protocol.ts +75 -54
- package/src/repository.ts +277 -228
- package/src/reward.ts +252 -220
- package/src/service.ts +888 -821
- package/src/utils.ts +30 -37
- package/src/vote.ts +334 -267
- package/tsconfig.json +1 -1
- package/dist/community.d.ts +0 -8
- package/dist/community.js +0 -96
- package/dist/config.d.ts +0 -19
- package/dist/config.js +0 -27
- package/dist/util.js +0 -158
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
AI-oriented web3 collaboration protocol, driving innovaion and making it more likely to happen.
|
|
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
8
|
|
|
8
9
|
### Installation
|
|
9
10
|
|
package/dist/demand.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type TransactionResult } from '@mysten/sui.js/transactions';
|
|
2
|
+
import { Protocol, PassportObject, PermissionObject, GuardObject, DemandAddress, TxbObject } from './protocol';
|
|
3
|
+
import { Service } from './service';
|
|
4
|
+
export declare class Demand {
|
|
5
|
+
protected earnest_type: string;
|
|
6
|
+
protected permission: PermissionObject;
|
|
7
|
+
protected object: TxbObject;
|
|
8
|
+
protected protocol: Protocol;
|
|
9
|
+
get_earnest_type(): string;
|
|
10
|
+
get_object(): TxbObject;
|
|
11
|
+
static From(protocol: Protocol, earnest_type: string, permission: PermissionObject, object: TxbObject): Demand;
|
|
12
|
+
private constructor();
|
|
13
|
+
static New(protocol: Protocol, earnest_type: string, permission: PermissionObject, description: string, earnest: TransactionResult, passport?: PassportObject): Demand;
|
|
14
|
+
launch(): DemandAddress;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
refund(passport?: PassportObject): void;
|
|
17
|
+
expand_time(minutes_duration: number, passport?: PassportObject): void;
|
|
18
|
+
set_guard(guard?: GuardObject, passport?: PassportObject): void;
|
|
19
|
+
set_description(description: string, passport?: PassportObject): boolean;
|
|
20
|
+
yes(service_id: string, passport?: PassportObject): void;
|
|
21
|
+
deposit(earnest: TxbObject): void;
|
|
22
|
+
present(service: Service, tips: string, passport?: PassportObject): boolean;
|
|
23
|
+
change_permission(new_permission: PermissionObject): boolean;
|
|
24
|
+
static MAX_EARNEST_COUNT: number;
|
|
25
|
+
static MAX_PRESENTERS_COUNT: number;
|
|
26
|
+
}
|
package/dist/demand.js
CHANGED
|
@@ -1,237 +1,242 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Demand = void 0;
|
|
4
4
|
const bcs_1 = require("@mysten/bcs");
|
|
5
5
|
const protocol_1 = require("./protocol");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
return txb.moveCall({
|
|
22
|
-
target: protocol_1.PROTOCOL.DemandFn('new'),
|
|
23
|
-
arguments: [txb.pure(description), earnest, (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
24
|
-
typeArguments: [earnest_type],
|
|
25
|
-
});
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const exception_1 = require("./exception");
|
|
8
|
+
class Demand {
|
|
9
|
+
earnest_type;
|
|
10
|
+
permission;
|
|
11
|
+
object;
|
|
12
|
+
protocol;
|
|
13
|
+
get_earnest_type() { return this.earnest_type; }
|
|
14
|
+
get_object() { return this.object; }
|
|
15
|
+
static From(protocol, earnest_type, permission, object) {
|
|
16
|
+
let d = new Demand(protocol, earnest_type, permission);
|
|
17
|
+
d.object = protocol_1.Protocol.TXB_OBJECT(protocol.CurrentSession(), object);
|
|
18
|
+
return d;
|
|
26
19
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (!(0, protocol_1.IsValidArgType)(earnest_type))
|
|
33
|
-
return false;
|
|
34
|
-
return txb.moveCall({
|
|
35
|
-
target: protocol_1.PROTOCOL.DemandFn('create'),
|
|
36
|
-
arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand)],
|
|
37
|
-
typeArguments: [earnest_type],
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
exports.launch = launch;
|
|
41
|
-
function destroy(earnest_type, txb, demand) {
|
|
42
|
-
if (!(0, protocol_1.IsValidObjects)([demand]))
|
|
43
|
-
return false;
|
|
44
|
-
if (!(0, protocol_1.IsValidArgType)(earnest_type))
|
|
45
|
-
return false;
|
|
46
|
-
txb.moveCall({
|
|
47
|
-
target: protocol_1.PROTOCOL.DemandFn('destroy'),
|
|
48
|
-
arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand)],
|
|
49
|
-
typeArguments: [earnest_type]
|
|
50
|
-
});
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
exports.destroy = destroy;
|
|
54
|
-
function demand_refund(earnest_type, txb, demand, permission, passport) {
|
|
55
|
-
if (!(0, protocol_1.IsValidObjects)([demand, permission]))
|
|
56
|
-
return false;
|
|
57
|
-
if (!(0, protocol_1.IsValidArgType)(earnest_type))
|
|
58
|
-
return false;
|
|
59
|
-
if (passport) {
|
|
60
|
-
txb.moveCall({
|
|
61
|
-
target: protocol_1.PROTOCOL.DemandFn('refund_with_passport'),
|
|
62
|
-
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, demand), txb.object(protocol_1.CLOCK_OBJECT), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
63
|
-
typeArguments: [earnest_type],
|
|
64
|
-
});
|
|
20
|
+
constructor(protocol, earnest_type, permission) {
|
|
21
|
+
this.earnest_type = earnest_type;
|
|
22
|
+
this.permission = permission;
|
|
23
|
+
this.protocol = protocol;
|
|
24
|
+
this.object = '';
|
|
65
25
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
26
|
+
static New(protocol, earnest_type, permission, description, earnest, passport) {
|
|
27
|
+
let d = new Demand(protocol, earnest_type, permission);
|
|
28
|
+
if (!protocol_1.Protocol.IsValidObjects([permission, earnest])) {
|
|
29
|
+
(0, exception_1.ERROR)(exception_1.Errors.IsValidObjects, 'permission, earnest');
|
|
30
|
+
}
|
|
31
|
+
if (!(0, utils_1.IsValidDesription)(description)) {
|
|
32
|
+
(0, exception_1.ERROR)(exception_1.Errors.IsValidDesription);
|
|
33
|
+
}
|
|
34
|
+
if (!(0, utils_1.IsValidArgType)(earnest_type)) {
|
|
35
|
+
(0, exception_1.ERROR)(exception_1.Errors.IsValidArgType, earnest_type);
|
|
36
|
+
}
|
|
37
|
+
let txb = protocol.CurrentSession();
|
|
38
|
+
if (passport) {
|
|
39
|
+
d.object = txb.moveCall({
|
|
40
|
+
target: protocol.DemandFn('new_with_passport'),
|
|
41
|
+
arguments: [passport, txb.pure(description), earnest, protocol_1.Protocol.TXB_OBJECT(txb, permission)],
|
|
42
|
+
typeArguments: [earnest_type],
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
d.object = txb.moveCall({
|
|
47
|
+
target: protocol.DemandFn('new'),
|
|
48
|
+
arguments: [txb.pure(description), earnest, protocol_1.Protocol.TXB_OBJECT(txb, permission)],
|
|
49
|
+
typeArguments: [earnest_type],
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return d;
|
|
72
53
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (!(0, protocol_1.IsValidArgType)(earnest_type))
|
|
80
|
-
return false;
|
|
81
|
-
if (!(0, protocol_1.IsValidUint)(minutes_duration))
|
|
82
|
-
return false;
|
|
83
|
-
if (passport) {
|
|
84
|
-
txb.moveCall({
|
|
85
|
-
target: protocol_1.PROTOCOL.DemandFn('time_expand_with_passport'),
|
|
86
|
-
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, demand), txb.pure(minutes_duration, bcs_1.BCS.U64), txb.object(protocol_1.CLOCK_OBJECT), (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
87
|
-
typeArguments: [earnest_type],
|
|
54
|
+
launch() {
|
|
55
|
+
let txb = this.protocol.CurrentSession();
|
|
56
|
+
return txb.moveCall({
|
|
57
|
+
target: this.protocol.DemandFn('create'),
|
|
58
|
+
arguments: [protocol_1.Protocol.TXB_OBJECT(txb, this.object)],
|
|
59
|
+
typeArguments: [this.earnest_type],
|
|
88
60
|
});
|
|
89
61
|
}
|
|
90
|
-
|
|
62
|
+
destroy() {
|
|
63
|
+
let txb = this.protocol.CurrentSession();
|
|
91
64
|
txb.moveCall({
|
|
92
|
-
target:
|
|
93
|
-
arguments: [
|
|
94
|
-
typeArguments: [earnest_type]
|
|
65
|
+
target: this.protocol.DemandFn('destroy'),
|
|
66
|
+
arguments: [protocol_1.Protocol.TXB_OBJECT(txb, this.object)],
|
|
67
|
+
typeArguments: [this.earnest_type]
|
|
95
68
|
});
|
|
96
69
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
function demand_set_guard(earnest_type, txb, demand, permission, guard, passport) {
|
|
101
|
-
if (!(0, protocol_1.IsValidObjects)([demand, permission]))
|
|
102
|
-
return false;
|
|
103
|
-
if (!(0, protocol_1.IsValidArgType)(earnest_type))
|
|
104
|
-
return false;
|
|
105
|
-
if (passport) {
|
|
106
|
-
if (guard) {
|
|
70
|
+
refund(passport) {
|
|
71
|
+
let txb = this.protocol.CurrentSession();
|
|
72
|
+
if (passport) {
|
|
107
73
|
txb.moveCall({
|
|
108
|
-
target:
|
|
109
|
-
arguments: [passport,
|
|
110
|
-
typeArguments: [earnest_type],
|
|
74
|
+
target: this.protocol.DemandFn('refund_with_passport'),
|
|
75
|
+
arguments: [passport, protocol_1.Protocol.TXB_OBJECT(txb, this.object), txb.object(protocol_1.Protocol.CLOCK_OBJECT), protocol_1.Protocol.TXB_OBJECT(txb, this.permission)],
|
|
76
|
+
typeArguments: [this.earnest_type],
|
|
111
77
|
});
|
|
112
78
|
}
|
|
113
79
|
else {
|
|
114
80
|
txb.moveCall({
|
|
115
|
-
target:
|
|
116
|
-
arguments: [
|
|
117
|
-
typeArguments: [earnest_type],
|
|
81
|
+
target: this.protocol.DemandFn('refund'),
|
|
82
|
+
arguments: [protocol_1.Protocol.TXB_OBJECT(txb, this.object), txb.object(protocol_1.Protocol.CLOCK_OBJECT), protocol_1.Protocol.TXB_OBJECT(txb, this.permission)],
|
|
83
|
+
typeArguments: [this.earnest_type],
|
|
118
84
|
});
|
|
119
85
|
}
|
|
120
86
|
}
|
|
121
|
-
|
|
122
|
-
if (
|
|
87
|
+
expand_time(minutes_duration, passport) {
|
|
88
|
+
if (!(0, utils_1.IsValidUint)(minutes_duration)) {
|
|
89
|
+
(0, exception_1.ERROR)(exception_1.Errors.IsValidUint, 'minutes_duration');
|
|
90
|
+
}
|
|
91
|
+
let txb = this.protocol.CurrentSession();
|
|
92
|
+
if (passport) {
|
|
123
93
|
txb.moveCall({
|
|
124
|
-
target:
|
|
125
|
-
arguments: [
|
|
126
|
-
|
|
94
|
+
target: this.protocol.DemandFn('time_expand_with_passport'),
|
|
95
|
+
arguments: [passport, protocol_1.Protocol.TXB_OBJECT(txb, this.object), txb.pure(minutes_duration, bcs_1.BCS.U64),
|
|
96
|
+
txb.object(protocol_1.Protocol.CLOCK_OBJECT), protocol_1.Protocol.TXB_OBJECT(txb, this.permission)],
|
|
97
|
+
typeArguments: [this.earnest_type],
|
|
127
98
|
});
|
|
128
99
|
}
|
|
129
100
|
else {
|
|
130
101
|
txb.moveCall({
|
|
131
|
-
target:
|
|
132
|
-
arguments: [
|
|
133
|
-
|
|
102
|
+
target: this.protocol.DemandFn('time_expand'),
|
|
103
|
+
arguments: [protocol_1.Protocol.TXB_OBJECT(txb, this.object), txb.pure(minutes_duration, bcs_1.BCS.U64),
|
|
104
|
+
txb.object(protocol_1.Protocol.CLOCK_OBJECT), protocol_1.Protocol.TXB_OBJECT(txb, this.permission)],
|
|
105
|
+
typeArguments: [this.earnest_type],
|
|
134
106
|
});
|
|
135
107
|
}
|
|
136
108
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
109
|
+
set_guard(guard, passport) {
|
|
110
|
+
if (guard && !protocol_1.Protocol.IsValidObjects([guard])) {
|
|
111
|
+
(0, exception_1.ERROR)(exception_1.Errors.IsValidObjects, 'guard');
|
|
112
|
+
}
|
|
113
|
+
let txb = this.protocol.CurrentSession();
|
|
114
|
+
if (passport) {
|
|
115
|
+
if (guard) {
|
|
116
|
+
txb.moveCall({
|
|
117
|
+
target: this.protocol.DemandFn('guard_set_with_passport'),
|
|
118
|
+
arguments: [passport, protocol_1.Protocol.TXB_OBJECT(txb, this.object), protocol_1.Protocol.TXB_OBJECT(txb, guard),
|
|
119
|
+
protocol_1.Protocol.TXB_OBJECT(txb, this.permission)],
|
|
120
|
+
typeArguments: [this.earnest_type],
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
txb.moveCall({
|
|
125
|
+
target: this.protocol.DemandFn('guard_none_with_passport'),
|
|
126
|
+
arguments: [passport, protocol_1.Protocol.TXB_OBJECT(txb, this.object), protocol_1.Protocol.TXB_OBJECT(txb, this.permission)],
|
|
127
|
+
typeArguments: [this.earnest_type],
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
if (guard) {
|
|
133
|
+
txb.moveCall({
|
|
134
|
+
target: this.protocol.DemandFn('guard_set'),
|
|
135
|
+
arguments: [protocol_1.Protocol.TXB_OBJECT(txb, this.object), protocol_1.Protocol.TXB_OBJECT(txb, guard),
|
|
136
|
+
protocol_1.Protocol.TXB_OBJECT(txb, this.permission)],
|
|
137
|
+
typeArguments: [this.earnest_type],
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
txb.moveCall({
|
|
142
|
+
target: this.protocol.DemandFn('guard_none'),
|
|
143
|
+
arguments: [protocol_1.Protocol.TXB_OBJECT(txb, this.object), protocol_1.Protocol.TXB_OBJECT(txb, this.permission)],
|
|
144
|
+
typeArguments: [this.earnest_type],
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
153
148
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
149
|
+
set_description(description, passport) {
|
|
150
|
+
if (!(0, utils_1.IsValidDesription)(description)) {
|
|
151
|
+
(0, exception_1.ERROR)(exception_1.Errors.IsValidDesription);
|
|
152
|
+
}
|
|
153
|
+
let txb = this.protocol.CurrentSession();
|
|
154
|
+
if (passport) {
|
|
155
|
+
txb.moveCall({
|
|
156
|
+
target: this.protocol.DemandFn('description_set_with_passport'),
|
|
157
|
+
arguments: [passport, protocol_1.Protocol.TXB_OBJECT(txb, this.object), txb.pure(description),
|
|
158
|
+
protocol_1.Protocol.TXB_OBJECT(txb, this.permission)],
|
|
159
|
+
typeArguments: [this.earnest_type],
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
txb.moveCall({
|
|
164
|
+
target: this.protocol.DemandFn('description_set'),
|
|
165
|
+
arguments: [protocol_1.Protocol.TXB_OBJECT(txb, this.object), txb.pure(description), protocol_1.Protocol.TXB_OBJECT(txb, this.permission)],
|
|
166
|
+
typeArguments: [this.earnest_type],
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
160
170
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
yes(service_id, passport) {
|
|
172
|
+
if (!(0, utils_1.IsValidAddress)(service_id)) {
|
|
173
|
+
(0, exception_1.ERROR)(exception_1.Errors.IsValidAddress);
|
|
174
|
+
}
|
|
175
|
+
let txb = this.protocol.CurrentSession();
|
|
176
|
+
if (passport) {
|
|
177
|
+
txb.moveCall({
|
|
178
|
+
target: this.protocol.DemandFn('yes_with_passport'),
|
|
179
|
+
arguments: [passport, protocol_1.Protocol.TXB_OBJECT(txb, this.object), txb.pure(service_id, bcs_1.BCS.ADDRESS),
|
|
180
|
+
protocol_1.Protocol.TXB_OBJECT(txb, this.permission)],
|
|
181
|
+
typeArguments: [this.earnest_type],
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
txb.moveCall({
|
|
186
|
+
target: this.protocol.DemandFn('yes'),
|
|
187
|
+
arguments: [protocol_1.Protocol.TXB_OBJECT(txb, this.object), txb.pure(service_id, bcs_1.BCS.ADDRESS),
|
|
188
|
+
protocol_1.Protocol.TXB_OBJECT(txb, this.permission)],
|
|
189
|
+
typeArguments: [this.earnest_type],
|
|
190
|
+
});
|
|
191
|
+
}
|
|
177
192
|
}
|
|
178
|
-
|
|
193
|
+
deposit(earnest) {
|
|
194
|
+
if (!protocol_1.Protocol.IsValidObjects([earnest])) {
|
|
195
|
+
(0, exception_1.ERROR)(exception_1.Errors.IsValidObjects);
|
|
196
|
+
}
|
|
197
|
+
let txb = this.protocol.CurrentSession();
|
|
179
198
|
txb.moveCall({
|
|
180
|
-
target:
|
|
181
|
-
arguments: [
|
|
182
|
-
typeArguments: [earnest_type],
|
|
199
|
+
target: this.protocol.DemandFn('deposit'),
|
|
200
|
+
arguments: [protocol_1.Protocol.TXB_OBJECT(txb, this.object), protocol_1.Protocol.TXB_OBJECT(txb, earnest)],
|
|
201
|
+
typeArguments: [this.earnest_type],
|
|
183
202
|
});
|
|
184
203
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
return false;
|
|
208
|
-
if (passport) {
|
|
209
|
-
txb.moveCall({
|
|
210
|
-
target: protocol_1.PROTOCOL.DemandFn('present_with_passport'),
|
|
211
|
-
arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(tips, bcs_1.BCS.STRING),],
|
|
212
|
-
typeArguments: [earnest_type, service_type],
|
|
213
|
-
});
|
|
204
|
+
present(service, tips, passport) {
|
|
205
|
+
if (!(0, utils_1.IsValidDesription)(tips)) {
|
|
206
|
+
(0, exception_1.ERROR)(exception_1.Errors.IsValidDesription, 'tips');
|
|
207
|
+
}
|
|
208
|
+
let txb = this.protocol.CurrentSession();
|
|
209
|
+
if (passport) {
|
|
210
|
+
txb.moveCall({
|
|
211
|
+
target: this.protocol.DemandFn('present_with_passport'),
|
|
212
|
+
arguments: [passport, protocol_1.Protocol.TXB_OBJECT(txb, this.object), protocol_1.Protocol.TXB_OBJECT(txb, service.get_object()),
|
|
213
|
+
txb.pure(tips, bcs_1.BCS.STRING),],
|
|
214
|
+
typeArguments: [this.earnest_type, service.get_pay_type()],
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
txb.moveCall({
|
|
219
|
+
target: this.protocol.DemandFn('present'),
|
|
220
|
+
arguments: [protocol_1.Protocol.TXB_OBJECT(txb, this.object), protocol_1.Protocol.TXB_OBJECT(txb, service.get_object()),
|
|
221
|
+
txb.pure(tips, bcs_1.BCS.STRING),],
|
|
222
|
+
typeArguments: [this.earnest_type, service.get_pay_type()],
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
return true;
|
|
214
226
|
}
|
|
215
|
-
|
|
227
|
+
change_permission(new_permission) {
|
|
228
|
+
if (!protocol_1.Protocol.IsValidObjects([new_permission])) {
|
|
229
|
+
(0, exception_1.ERROR)(exception_1.Errors.IsValidObjects);
|
|
230
|
+
}
|
|
231
|
+
let txb = this.protocol.CurrentSession();
|
|
216
232
|
txb.moveCall({
|
|
217
|
-
target:
|
|
218
|
-
arguments: [
|
|
219
|
-
typeArguments: [earnest_type
|
|
233
|
+
target: this.protocol.DemandFn('permission_set'),
|
|
234
|
+
arguments: [protocol_1.Protocol.TXB_OBJECT(txb, this.object), protocol_1.Protocol.TXB_OBJECT(txb, this.permission), protocol_1.Protocol.TXB_OBJECT(txb, new_permission)],
|
|
235
|
+
typeArguments: [this.earnest_type]
|
|
220
236
|
});
|
|
237
|
+
return true;
|
|
221
238
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
exports.present = present;
|
|
225
|
-
function change_permission(earnest_type, txb, demand, old_permission, new_permission) {
|
|
226
|
-
if (!(0, protocol_1.IsValidObjects)([demand, old_permission, new_permission]))
|
|
227
|
-
return false;
|
|
228
|
-
if (!(0, protocol_1.IsValidArgType)(earnest_type))
|
|
229
|
-
return false;
|
|
230
|
-
txb.moveCall({
|
|
231
|
-
target: protocol_1.PROTOCOL.DemandFn('permission_set'),
|
|
232
|
-
arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, old_permission), (0, protocol_1.TXB_OBJECT)(txb, new_permission)],
|
|
233
|
-
typeArguments: [earnest_type]
|
|
234
|
-
});
|
|
235
|
-
return true;
|
|
239
|
+
static MAX_EARNEST_COUNT = 200;
|
|
240
|
+
static MAX_PRESENTERS_COUNT = 200;
|
|
236
241
|
}
|
|
237
|
-
exports.
|
|
242
|
+
exports.Demand = Demand;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum Errors {
|
|
2
|
+
IsValidDesription = "invalid description",
|
|
3
|
+
IsValidName = "invalid name",
|
|
4
|
+
IsValidName_AllowEmpty = "invalid name",
|
|
5
|
+
IsValidEndpoint = "invalid endpoint",
|
|
6
|
+
IsValidAddress = "invalid address",
|
|
7
|
+
IsValidArgType = "invalid argumentType",
|
|
8
|
+
IsValidUint = "invalid uint",
|
|
9
|
+
IsValidInt = "invalid int",
|
|
10
|
+
IsValidPercent = "invalid percent",
|
|
11
|
+
IsValidArray = "invalid array",
|
|
12
|
+
IsValidObjects = "invalid objects",
|
|
13
|
+
AllInvalid = "one valid at least",
|
|
14
|
+
InvalidParam = "invalid parameter",
|
|
15
|
+
IsValidPermissionIndex = "invalid permission index",
|
|
16
|
+
IsValidKey = "invalid key"
|
|
17
|
+
}
|
|
18
|
+
export declare const ERROR: (error: Errors, info?: any) => never;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERROR = exports.Errors = void 0;
|
|
4
|
+
var Errors;
|
|
5
|
+
(function (Errors) {
|
|
6
|
+
Errors["IsValidDesription"] = "invalid description";
|
|
7
|
+
Errors["IsValidName"] = "invalid name";
|
|
8
|
+
Errors["IsValidName_AllowEmpty"] = "invalid name";
|
|
9
|
+
Errors["IsValidEndpoint"] = "invalid endpoint";
|
|
10
|
+
Errors["IsValidAddress"] = "invalid address";
|
|
11
|
+
Errors["IsValidArgType"] = "invalid argumentType";
|
|
12
|
+
Errors["IsValidUint"] = "invalid uint";
|
|
13
|
+
Errors["IsValidInt"] = "invalid int";
|
|
14
|
+
Errors["IsValidPercent"] = "invalid percent";
|
|
15
|
+
Errors["IsValidArray"] = "invalid array";
|
|
16
|
+
Errors["IsValidObjects"] = "invalid objects";
|
|
17
|
+
Errors["AllInvalid"] = "one valid at least";
|
|
18
|
+
Errors["InvalidParam"] = "invalid parameter";
|
|
19
|
+
Errors["IsValidPermissionIndex"] = "invalid permission index";
|
|
20
|
+
Errors["IsValidKey"] = "invalid key";
|
|
21
|
+
})(Errors || (exports.Errors = Errors = {}));
|
|
22
|
+
const ERROR = (error, info) => {
|
|
23
|
+
const e = error + info ? (': ' + info) : '';
|
|
24
|
+
throw e;
|
|
25
|
+
};
|
|
26
|
+
exports.ERROR = ERROR;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const GRAPHQL_OBJECTS_TYPE: import("graphql/language/ast").DocumentNode;
|
|
2
|
+
export declare const GRAPHQL_OBJECT: import("graphql/language/ast").DocumentNode;
|
|
3
|
+
export declare const GRAPHQL_OWNER: import("graphql/language/ast").DocumentNode;
|
|
4
|
+
export declare const GRAPHQL_OBJECTS: import("graphql/language/ast").DocumentNode;
|
package/dist/guard.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Protocol, GuardAddress, Data_Type, MODULES, ContextType, ValueType, OperatorType } from './protocol';
|
|
2
|
+
export declare enum Guard_Sense_Binder {
|
|
3
|
+
AND = 0,
|
|
4
|
+
OR = 1
|
|
5
|
+
}
|
|
6
|
+
export type Guard_Sense = {
|
|
7
|
+
input: Uint8Array;
|
|
8
|
+
notAfterSense: boolean;
|
|
9
|
+
binder: Guard_Sense_Binder;
|
|
10
|
+
};
|
|
11
|
+
export type VariableType = Map<number, Guard_Vriable>;
|
|
12
|
+
export type Guard_Vriable = {
|
|
13
|
+
type: ContextType | OperatorType;
|
|
14
|
+
value?: Uint8Array;
|
|
15
|
+
witness?: Uint8Array;
|
|
16
|
+
};
|
|
17
|
+
export type Guard_Creation = {
|
|
18
|
+
description: string;
|
|
19
|
+
variables?: VariableType;
|
|
20
|
+
senses: Guard_Sense[];
|
|
21
|
+
};
|
|
22
|
+
export declare class Guard {
|
|
23
|
+
static MAX_SENSE_COUNT: number;
|
|
24
|
+
static IsValidGuardVirableType: (type: OperatorType | ContextType) => boolean;
|
|
25
|
+
static IsValidIndentifier: (identifier: number) => boolean;
|
|
26
|
+
static get_variable_value(variables: VariableType, identifier: number, type: OperatorType | ContextType): Uint8Array | boolean;
|
|
27
|
+
static get_variable_witness(variables: VariableType, identifier: number, type: OperatorType | ContextType): Uint8Array | boolean;
|
|
28
|
+
static add_future_variable(variables: VariableType, identifier: number, type: OperatorType | ContextType, witness: any, value?: any, bNeedSerialize?: boolean): boolean;
|
|
29
|
+
static add_variable(variables: VariableType, identifier: number, type: OperatorType | ContextType, value: any, bNeedSerialize?: boolean): boolean;
|
|
30
|
+
static launch(protocol: Protocol, creation: Guard_Creation): GuardAddress;
|
|
31
|
+
static signer_guard(protocol: Protocol): GuardAddress;
|
|
32
|
+
static everyone_guard(protocol: Protocol): GuardAddress;
|
|
33
|
+
static QUERIES: any[];
|
|
34
|
+
}
|
|
35
|
+
export declare class SenseMaker {
|
|
36
|
+
protected data: Uint8Array[];
|
|
37
|
+
protected type_validator: Data_Type[];
|
|
38
|
+
constructor();
|
|
39
|
+
add_param(type: ValueType | ContextType, param?: any, variable?: VariableType): boolean;
|
|
40
|
+
static query_index(module: MODULES, query_name: string): number;
|
|
41
|
+
add_future_query(identifier: number, module: MODULES, query_name: string, variable: VariableType): boolean;
|
|
42
|
+
add_query(module: MODULES, query_name: string, object_address_from: string | number): boolean;
|
|
43
|
+
add_logic(type: OperatorType): boolean;
|
|
44
|
+
make(bNotAfterSense?: boolean, binder?: Guard_Sense_Binder): boolean | Guard_Sense;
|
|
45
|
+
static match_u128(type: number): boolean;
|
|
46
|
+
}
|