wowok 1.0.9 → 1.0.11
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/demand.d.ts +27 -0
- package/dist/demand.d.ts.map +1 -0
- package/dist/demand.js +203 -202
- package/dist/exception.d.ts +19 -0
- package/dist/exception.d.ts.map +1 -0
- package/dist/exception.js +22 -0
- package/dist/graphql.d.ts +5 -0
- package/dist/graphql.d.ts.map +1 -0
- package/dist/graphql.js +5 -8
- package/dist/guard.d.ts +47 -0
- package/dist/guard.d.ts.map +1 -0
- package/dist/guard.js +394 -589
- package/dist/index.d.ts +13 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -167
- package/dist/machine.d.ts +46 -0
- package/dist/machine.d.ts.map +1 -0
- package/dist/machine.js +278 -283
- package/dist/passport.d.ts +42 -0
- package/dist/passport.d.ts.map +1 -0
- package/dist/passport.js +322 -148
- package/dist/permission.d.ts +112 -0
- package/dist/permission.d.ts.map +1 -0
- package/dist/permission.js +188 -183
- package/dist/progress.d.ts +32 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +214 -189
- package/dist/protocol.d.ts +165 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +90 -95
- package/dist/repository.d.ts +47 -0
- package/dist/repository.d.ts.map +1 -0
- package/dist/repository.js +262 -250
- package/dist/reward.d.ts +32 -0
- package/dist/reward.d.ts.map +1 -0
- package/dist/reward.js +243 -261
- package/dist/service.d.ts +95 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +840 -888
- package/dist/utils.d.ts +48 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +48 -72
- package/dist/vote.d.ts +32 -0
- package/dist/vote.d.ts.map +1 -0
- package/dist/vote.js +307 -293
- package/package.json +8 -3
- package/src/demand.ts +223 -184
- package/src/exception.ts +23 -0
- package/src/guard.ts +338 -536
- package/src/index.ts +12 -33
- package/src/machine.ts +286 -244
- package/src/passport.ts +363 -159
- package/src/permission.ts +206 -160
- package/src/progress.ts +253 -194
- package/src/protocol.ts +76 -55
- package/src/repository.ts +277 -228
- package/src/reward.ts +252 -220
- package/src/service.ts +888 -821
- package/src/utils.ts +29 -38
- package/src/vote.ts +334 -267
- package/tsconfig.json +4 -4
- 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/dist/demand.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type TransactionResult } from '@mysten/sui.js/transactions';
|
|
2
|
+
import { Protocol, PassportObject, PermissionObject, GuardObject, DemandAddress, TxbObject } from './protocol.js';
|
|
3
|
+
import { Service } from './service.js';
|
|
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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G,CAAC,UAAU,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,cAAc;IAuB/C,OAAO,CAAC,OAAO,EAAC,SAAS;IAazB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,cAAc,GAAI,OAAO;IAuB1E,iBAAiB,CAAC,cAAc,EAAC,gBAAgB;IAcjD,MAAM,CAAC,iBAAiB,SAAO;IAC/B,MAAM,CAAC,oBAAoB,SAAO;CACrC"}
|
package/dist/demand.js
CHANGED
|
@@ -1,237 +1,238 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
arguments: [passport, txb.pure(description), earnest, (0, protocol_1.TXB_OBJECT)(txb, permission)],
|
|
17
|
-
typeArguments: [earnest_type],
|
|
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
|
-
});
|
|
1
|
+
import { BCS } from '@mysten/bcs';
|
|
2
|
+
import { Protocol } from './protocol.js';
|
|
3
|
+
import { IsValidDesription, IsValidUint, IsValidAddress, IsValidArgType, } from './utils.js';
|
|
4
|
+
import { Errors, ERROR } from './exception.js';
|
|
5
|
+
export class Demand {
|
|
6
|
+
earnest_type;
|
|
7
|
+
permission;
|
|
8
|
+
object;
|
|
9
|
+
protocol;
|
|
10
|
+
get_earnest_type() { return this.earnest_type; }
|
|
11
|
+
get_object() { return this.object; }
|
|
12
|
+
static From(protocol, earnest_type, permission, object) {
|
|
13
|
+
let d = new Demand(protocol, earnest_type, permission);
|
|
14
|
+
d.object = Protocol.TXB_OBJECT(protocol.CurrentSession(), object);
|
|
15
|
+
return d;
|
|
26
16
|
}
|
|
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
|
-
});
|
|
17
|
+
constructor(protocol, earnest_type, permission) {
|
|
18
|
+
this.earnest_type = earnest_type;
|
|
19
|
+
this.permission = permission;
|
|
20
|
+
this.protocol = protocol;
|
|
21
|
+
this.object = '';
|
|
65
22
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
23
|
+
static New(protocol, earnest_type, permission, description, earnest, passport) {
|
|
24
|
+
let d = new Demand(protocol, earnest_type, permission);
|
|
25
|
+
if (!Protocol.IsValidObjects([permission, earnest])) {
|
|
26
|
+
ERROR(Errors.IsValidObjects, 'permission, earnest');
|
|
27
|
+
}
|
|
28
|
+
if (!IsValidDesription(description)) {
|
|
29
|
+
ERROR(Errors.IsValidDesription);
|
|
30
|
+
}
|
|
31
|
+
if (!IsValidArgType(earnest_type)) {
|
|
32
|
+
ERROR(Errors.IsValidArgType, earnest_type);
|
|
33
|
+
}
|
|
34
|
+
let txb = protocol.CurrentSession();
|
|
35
|
+
if (passport) {
|
|
36
|
+
d.object = txb.moveCall({
|
|
37
|
+
target: protocol.DemandFn('new_with_passport'),
|
|
38
|
+
arguments: [passport, txb.pure(description), earnest, Protocol.TXB_OBJECT(txb, permission)],
|
|
39
|
+
typeArguments: [earnest_type],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
d.object = txb.moveCall({
|
|
44
|
+
target: protocol.DemandFn('new'),
|
|
45
|
+
arguments: [txb.pure(description), earnest, Protocol.TXB_OBJECT(txb, permission)],
|
|
46
|
+
typeArguments: [earnest_type],
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return d;
|
|
72
50
|
}
|
|
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],
|
|
51
|
+
launch() {
|
|
52
|
+
let txb = this.protocol.CurrentSession();
|
|
53
|
+
return txb.moveCall({
|
|
54
|
+
target: this.protocol.DemandFn('create'),
|
|
55
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object)],
|
|
56
|
+
typeArguments: [this.earnest_type],
|
|
88
57
|
});
|
|
89
58
|
}
|
|
90
|
-
|
|
59
|
+
destroy() {
|
|
60
|
+
let txb = this.protocol.CurrentSession();
|
|
91
61
|
txb.moveCall({
|
|
92
|
-
target:
|
|
93
|
-
arguments: [
|
|
94
|
-
typeArguments: [earnest_type]
|
|
62
|
+
target: this.protocol.DemandFn('destroy'),
|
|
63
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object)],
|
|
64
|
+
typeArguments: [this.earnest_type]
|
|
95
65
|
});
|
|
96
66
|
}
|
|
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) {
|
|
67
|
+
refund(passport) {
|
|
68
|
+
let txb = this.protocol.CurrentSession();
|
|
69
|
+
if (passport) {
|
|
107
70
|
txb.moveCall({
|
|
108
|
-
target:
|
|
109
|
-
arguments: [passport,
|
|
110
|
-
typeArguments: [earnest_type],
|
|
71
|
+
target: this.protocol.DemandFn('refund_with_passport'),
|
|
72
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
73
|
+
typeArguments: [this.earnest_type],
|
|
111
74
|
});
|
|
112
75
|
}
|
|
113
76
|
else {
|
|
114
77
|
txb.moveCall({
|
|
115
|
-
target:
|
|
116
|
-
arguments: [
|
|
117
|
-
typeArguments: [earnest_type],
|
|
78
|
+
target: this.protocol.DemandFn('refund'),
|
|
79
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
80
|
+
typeArguments: [this.earnest_type],
|
|
118
81
|
});
|
|
119
82
|
}
|
|
120
83
|
}
|
|
121
|
-
|
|
122
|
-
if (
|
|
84
|
+
expand_time(minutes_duration, passport) {
|
|
85
|
+
if (!IsValidUint(minutes_duration)) {
|
|
86
|
+
ERROR(Errors.IsValidUint, 'minutes_duration');
|
|
87
|
+
}
|
|
88
|
+
let txb = this.protocol.CurrentSession();
|
|
89
|
+
if (passport) {
|
|
123
90
|
txb.moveCall({
|
|
124
|
-
target:
|
|
125
|
-
arguments: [
|
|
126
|
-
|
|
91
|
+
target: this.protocol.DemandFn('time_expand_with_passport'),
|
|
92
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(minutes_duration, BCS.U64),
|
|
93
|
+
txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
94
|
+
typeArguments: [this.earnest_type],
|
|
127
95
|
});
|
|
128
96
|
}
|
|
129
97
|
else {
|
|
130
98
|
txb.moveCall({
|
|
131
|
-
target:
|
|
132
|
-
arguments: [
|
|
133
|
-
|
|
99
|
+
target: this.protocol.DemandFn('time_expand'),
|
|
100
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(minutes_duration, BCS.U64),
|
|
101
|
+
txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
102
|
+
typeArguments: [this.earnest_type],
|
|
134
103
|
});
|
|
135
104
|
}
|
|
136
105
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
106
|
+
set_guard(guard, passport) {
|
|
107
|
+
if (guard && !Protocol.IsValidObjects([guard])) {
|
|
108
|
+
ERROR(Errors.IsValidObjects, 'guard');
|
|
109
|
+
}
|
|
110
|
+
let txb = this.protocol.CurrentSession();
|
|
111
|
+
if (passport) {
|
|
112
|
+
if (guard) {
|
|
113
|
+
txb.moveCall({
|
|
114
|
+
target: this.protocol.DemandFn('guard_set_with_passport'),
|
|
115
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, guard),
|
|
116
|
+
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
117
|
+
typeArguments: [this.earnest_type],
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
txb.moveCall({
|
|
122
|
+
target: this.protocol.DemandFn('guard_none_with_passport'),
|
|
123
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
124
|
+
typeArguments: [this.earnest_type],
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
if (guard) {
|
|
130
|
+
txb.moveCall({
|
|
131
|
+
target: this.protocol.DemandFn('guard_set'),
|
|
132
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, guard),
|
|
133
|
+
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
134
|
+
typeArguments: [this.earnest_type],
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
txb.moveCall({
|
|
139
|
+
target: this.protocol.DemandFn('guard_none'),
|
|
140
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
141
|
+
typeArguments: [this.earnest_type],
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
153
145
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
146
|
+
set_description(description, passport) {
|
|
147
|
+
if (!IsValidDesription(description)) {
|
|
148
|
+
ERROR(Errors.IsValidDesription);
|
|
149
|
+
}
|
|
150
|
+
let txb = this.protocol.CurrentSession();
|
|
151
|
+
if (passport) {
|
|
152
|
+
txb.moveCall({
|
|
153
|
+
target: this.protocol.DemandFn('description_set_with_passport'),
|
|
154
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(description),
|
|
155
|
+
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
156
|
+
typeArguments: [this.earnest_type],
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
txb.moveCall({
|
|
161
|
+
target: this.protocol.DemandFn('description_set'),
|
|
162
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(description), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
163
|
+
typeArguments: [this.earnest_type],
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return true;
|
|
160
167
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
168
|
+
yes(service_id, passport) {
|
|
169
|
+
if (!IsValidAddress(service_id)) {
|
|
170
|
+
ERROR(Errors.IsValidAddress);
|
|
171
|
+
}
|
|
172
|
+
let txb = this.protocol.CurrentSession();
|
|
173
|
+
if (passport) {
|
|
174
|
+
txb.moveCall({
|
|
175
|
+
target: this.protocol.DemandFn('yes_with_passport'),
|
|
176
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(service_id, BCS.ADDRESS),
|
|
177
|
+
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
178
|
+
typeArguments: [this.earnest_type],
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
txb.moveCall({
|
|
183
|
+
target: this.protocol.DemandFn('yes'),
|
|
184
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(service_id, BCS.ADDRESS),
|
|
185
|
+
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
186
|
+
typeArguments: [this.earnest_type],
|
|
187
|
+
});
|
|
188
|
+
}
|
|
177
189
|
}
|
|
178
|
-
|
|
190
|
+
deposit(earnest) {
|
|
191
|
+
if (!Protocol.IsValidObjects([earnest])) {
|
|
192
|
+
ERROR(Errors.IsValidObjects);
|
|
193
|
+
}
|
|
194
|
+
let txb = this.protocol.CurrentSession();
|
|
179
195
|
txb.moveCall({
|
|
180
|
-
target:
|
|
181
|
-
arguments: [
|
|
182
|
-
typeArguments: [earnest_type],
|
|
196
|
+
target: this.protocol.DemandFn('deposit'),
|
|
197
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, earnest)],
|
|
198
|
+
typeArguments: [this.earnest_type],
|
|
183
199
|
});
|
|
184
200
|
}
|
|
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
|
-
});
|
|
201
|
+
present(service, tips, passport) {
|
|
202
|
+
if (!IsValidDesription(tips)) {
|
|
203
|
+
ERROR(Errors.IsValidDesription, 'tips');
|
|
204
|
+
}
|
|
205
|
+
let txb = this.protocol.CurrentSession();
|
|
206
|
+
if (passport) {
|
|
207
|
+
txb.moveCall({
|
|
208
|
+
target: this.protocol.DemandFn('present_with_passport'),
|
|
209
|
+
arguments: [passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, service.get_object()),
|
|
210
|
+
txb.pure(tips, BCS.STRING),],
|
|
211
|
+
typeArguments: [this.earnest_type, service.get_pay_type()],
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
txb.moveCall({
|
|
216
|
+
target: this.protocol.DemandFn('present'),
|
|
217
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, service.get_object()),
|
|
218
|
+
txb.pure(tips, BCS.STRING),],
|
|
219
|
+
typeArguments: [this.earnest_type, service.get_pay_type()],
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
return true;
|
|
214
223
|
}
|
|
215
|
-
|
|
224
|
+
change_permission(new_permission) {
|
|
225
|
+
if (!Protocol.IsValidObjects([new_permission])) {
|
|
226
|
+
ERROR(Errors.IsValidObjects);
|
|
227
|
+
}
|
|
228
|
+
let txb = this.protocol.CurrentSession();
|
|
216
229
|
txb.moveCall({
|
|
217
|
-
target:
|
|
218
|
-
arguments: [
|
|
219
|
-
typeArguments: [earnest_type
|
|
230
|
+
target: this.protocol.DemandFn('permission_set'),
|
|
231
|
+
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission), Protocol.TXB_OBJECT(txb, new_permission)],
|
|
232
|
+
typeArguments: [this.earnest_type]
|
|
220
233
|
});
|
|
234
|
+
return true;
|
|
221
235
|
}
|
|
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;
|
|
236
|
+
static MAX_EARNEST_COUNT = 200;
|
|
237
|
+
static MAX_PRESENTERS_COUNT = 200;
|
|
236
238
|
}
|
|
237
|
-
exports.change_permission = change_permission;
|
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
19
|
+
//# sourceMappingURL=exception.d.ts.map
|
|
@@ -0,0 +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;CAC7B;AAED,eAAO,MAAM,KAAK,UAAU,MAAM,SAAQ,GAAG,UAG5C,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export var Errors;
|
|
2
|
+
(function (Errors) {
|
|
3
|
+
Errors["IsValidDesription"] = "invalid description";
|
|
4
|
+
Errors["IsValidName"] = "invalid name";
|
|
5
|
+
Errors["IsValidName_AllowEmpty"] = "invalid name";
|
|
6
|
+
Errors["IsValidEndpoint"] = "invalid endpoint";
|
|
7
|
+
Errors["IsValidAddress"] = "invalid address";
|
|
8
|
+
Errors["IsValidArgType"] = "invalid argumentType";
|
|
9
|
+
Errors["IsValidUint"] = "invalid uint";
|
|
10
|
+
Errors["IsValidInt"] = "invalid int";
|
|
11
|
+
Errors["IsValidPercent"] = "invalid percent";
|
|
12
|
+
Errors["IsValidArray"] = "invalid array";
|
|
13
|
+
Errors["IsValidObjects"] = "invalid objects";
|
|
14
|
+
Errors["AllInvalid"] = "one valid at least";
|
|
15
|
+
Errors["InvalidParam"] = "invalid parameter";
|
|
16
|
+
Errors["IsValidPermissionIndex"] = "invalid permission index";
|
|
17
|
+
Errors["IsValidKey"] = "invalid key";
|
|
18
|
+
})(Errors || (Errors = {}));
|
|
19
|
+
export const ERROR = (error, info) => {
|
|
20
|
+
const e = error + info ? (': ' + info) : '';
|
|
21
|
+
throw e;
|
|
22
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
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;
|
|
5
|
+
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../src/graphql.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB,6CAgB/B,CAAC;AAEH,eAAO,MAAM,cAAc,6CAmCzB,CAAC;AAEH,eAAO,MAAM,aAAa,6CA2BxB,CAAC;AAEH,eAAO,MAAM,eAAe,6CAgB1B,CAAC"}
|
package/dist/graphql.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.GRAPHQL_OBJECTS = exports.GRAPHQL_OWNER = exports.GRAPHQL_OBJECT = exports.GRAPHQL_OBJECTS_TYPE = void 0;
|
|
4
|
-
const graphql_tag_1 = require("graphql-tag");
|
|
5
|
-
exports.GRAPHQL_OBJECTS_TYPE = (0, graphql_tag_1.gql)(`
|
|
1
|
+
import { gql } from "graphql-tag";
|
|
2
|
+
export const GRAPHQL_OBJECTS_TYPE = gql(`
|
|
6
3
|
query objects_type_version($filter:ObjectFilter!) {
|
|
7
4
|
objects(filter:$filter) {
|
|
8
5
|
nodes {
|
|
@@ -19,7 +16,7 @@ exports.GRAPHQL_OBJECTS_TYPE = (0, graphql_tag_1.gql)(`
|
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
18
|
`);
|
|
22
|
-
|
|
19
|
+
export const GRAPHQL_OBJECT = gql(`
|
|
23
20
|
query object($ObjectID:SuiAddress!) {
|
|
24
21
|
object(address:$ObjectID) {
|
|
25
22
|
address
|
|
@@ -55,7 +52,7 @@ exports.GRAPHQL_OBJECT = (0, graphql_tag_1.gql)(`
|
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
`);
|
|
58
|
-
|
|
55
|
+
export const GRAPHQL_OWNER = gql(`
|
|
59
56
|
query owner($ObjectID:SuiAddress!) {
|
|
60
57
|
owner (address: $ObjectID) {
|
|
61
58
|
address
|
|
@@ -83,7 +80,7 @@ exports.GRAPHQL_OWNER = (0, graphql_tag_1.gql)(`
|
|
|
83
80
|
}
|
|
84
81
|
}
|
|
85
82
|
`);
|
|
86
|
-
|
|
83
|
+
export const GRAPHQL_OBJECTS = gql(`
|
|
87
84
|
query objects($filter:ObjectFilter!){
|
|
88
85
|
objects(filter:$filter) {
|
|
89
86
|
nodes {
|
package/dist/guard.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Protocol, GuardAddress, Data_Type, MODULES, ContextType, ValueType, OperatorType } from './protocol.js';
|
|
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
|
+
}
|
|
47
|
+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