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.
Files changed (66) hide show
  1. package/dist/demand.d.ts +27 -0
  2. package/dist/demand.d.ts.map +1 -0
  3. package/dist/demand.js +203 -202
  4. package/dist/exception.d.ts +19 -0
  5. package/dist/exception.d.ts.map +1 -0
  6. package/dist/exception.js +22 -0
  7. package/dist/graphql.d.ts +5 -0
  8. package/dist/graphql.d.ts.map +1 -0
  9. package/dist/graphql.js +5 -8
  10. package/dist/guard.d.ts +47 -0
  11. package/dist/guard.d.ts.map +1 -0
  12. package/dist/guard.js +394 -589
  13. package/dist/index.d.ts +13 -2
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +12 -167
  16. package/dist/machine.d.ts +46 -0
  17. package/dist/machine.d.ts.map +1 -0
  18. package/dist/machine.js +278 -283
  19. package/dist/passport.d.ts +42 -0
  20. package/dist/passport.d.ts.map +1 -0
  21. package/dist/passport.js +322 -148
  22. package/dist/permission.d.ts +112 -0
  23. package/dist/permission.d.ts.map +1 -0
  24. package/dist/permission.js +188 -183
  25. package/dist/progress.d.ts +32 -0
  26. package/dist/progress.d.ts.map +1 -0
  27. package/dist/progress.js +214 -189
  28. package/dist/protocol.d.ts +165 -0
  29. package/dist/protocol.d.ts.map +1 -0
  30. package/dist/protocol.js +90 -95
  31. package/dist/repository.d.ts +47 -0
  32. package/dist/repository.d.ts.map +1 -0
  33. package/dist/repository.js +262 -250
  34. package/dist/reward.d.ts +32 -0
  35. package/dist/reward.d.ts.map +1 -0
  36. package/dist/reward.js +243 -261
  37. package/dist/service.d.ts +95 -0
  38. package/dist/service.d.ts.map +1 -0
  39. package/dist/service.js +840 -888
  40. package/dist/utils.d.ts +48 -0
  41. package/dist/utils.d.ts.map +1 -0
  42. package/dist/utils.js +48 -72
  43. package/dist/vote.d.ts +32 -0
  44. package/dist/vote.d.ts.map +1 -0
  45. package/dist/vote.js +307 -293
  46. package/package.json +8 -3
  47. package/src/demand.ts +223 -184
  48. package/src/exception.ts +23 -0
  49. package/src/guard.ts +338 -536
  50. package/src/index.ts +12 -33
  51. package/src/machine.ts +286 -244
  52. package/src/passport.ts +363 -159
  53. package/src/permission.ts +206 -160
  54. package/src/progress.ts +253 -194
  55. package/src/protocol.ts +76 -55
  56. package/src/repository.ts +277 -228
  57. package/src/reward.ts +252 -220
  58. package/src/service.ts +888 -821
  59. package/src/utils.ts +29 -38
  60. package/src/vote.ts +334 -267
  61. package/tsconfig.json +4 -4
  62. package/dist/community.d.ts +0 -8
  63. package/dist/community.js +0 -96
  64. package/dist/config.d.ts +0 -19
  65. package/dist/config.js +0 -27
  66. package/dist/util.js +0 -158
@@ -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_PRESENTERS_COUNT: number;
26
+ }
27
+ //#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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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.change_permission = exports.present = exports.deposit = exports.demand_yes = exports.demand_set_description = exports.demand_set_guard = exports.demand_expand_time = exports.demand_refund = exports.destroy = exports.launch = exports.demand = exports.MAX_PRESENTERS_COUNT = exports.MAX_EARNEST_COUNT = void 0;
4
- const bcs_1 = require("@mysten/bcs");
5
- const protocol_1 = require("./protocol");
6
- exports.MAX_EARNEST_COUNT = 200;
7
- exports.MAX_PRESENTERS_COUNT = 200;
8
- function demand(earnest_type, txb, permission, description, earnest, passport) {
9
- if (!(0, protocol_1.IsValidObjects)([permission, earnest]))
10
- return false;
11
- if (!(0, protocol_1.IsValidDesription)(description) || !(0, protocol_1.IsValidArgType)(earnest_type))
12
- return false;
13
- if (passport) {
14
- return txb.moveCall({
15
- target: protocol_1.PROTOCOL.DemandFn('new_with_passport'),
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
- exports.demand = demand;
29
- function launch(earnest_type, txb, demand) {
30
- if (!(0, protocol_1.IsValidObjects)([demand]))
31
- return false;
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
- else {
67
- txb.moveCall({
68
- target: protocol_1.PROTOCOL.DemandFn('refund'),
69
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand), txb.object(protocol_1.CLOCK_OBJECT), (0, protocol_1.TXB_OBJECT)(txb, permission)],
70
- typeArguments: [earnest_type],
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
- return true;
74
- }
75
- exports.demand_refund = demand_refund;
76
- function demand_expand_time(earnest_type, txb, demand, permission, minutes_duration, passport) {
77
- if (!(0, protocol_1.IsValidObjects)([demand, permission]))
78
- return false;
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
- else {
59
+ destroy() {
60
+ let txb = this.protocol.CurrentSession();
91
61
  txb.moveCall({
92
- target: protocol_1.PROTOCOL.DemandFn('time_expand'),
93
- arguments: [(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)],
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
- return true;
98
- }
99
- exports.demand_expand_time = demand_expand_time;
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: protocol_1.PROTOCOL.DemandFn('guard_set_with_passport'),
109
- arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, guard), (0, protocol_1.TXB_OBJECT)(txb, permission)],
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: protocol_1.PROTOCOL.DemandFn('guard_none_with_passport'),
116
- arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, permission)],
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
- else {
122
- if (guard) {
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: protocol_1.PROTOCOL.DemandFn('guard_set'),
125
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, guard), (0, protocol_1.TXB_OBJECT)(txb, permission)],
126
- typeArguments: [earnest_type],
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: protocol_1.PROTOCOL.DemandFn('guard_none'),
132
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, permission)],
133
- typeArguments: [earnest_type],
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
- return true;
138
- }
139
- exports.demand_set_guard = demand_set_guard;
140
- function demand_set_description(earnest_type, txb, demand, permission, description, passport) {
141
- if (!(0, protocol_1.IsValidObjects)([demand, permission]))
142
- return false;
143
- if (!(0, protocol_1.IsValidArgType)(earnest_type))
144
- return false;
145
- if (!(0, protocol_1.IsValidDesription)(description))
146
- return false;
147
- if (passport) {
148
- txb.moveCall({
149
- target: protocol_1.PROTOCOL.DemandFn('description_set_with_passport'),
150
- arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, demand), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)],
151
- typeArguments: [earnest_type],
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
- else {
155
- txb.moveCall({
156
- target: protocol_1.PROTOCOL.DemandFn('description_set'),
157
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand), txb.pure(description), (0, protocol_1.TXB_OBJECT)(txb, permission)],
158
- typeArguments: [earnest_type],
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
- return true;
162
- }
163
- exports.demand_set_description = demand_set_description;
164
- function demand_yes(earnest_type, txb, demand, permission, service_id, passport) {
165
- if (!(0, protocol_1.IsValidObjects)([demand, permission]))
166
- return false;
167
- if (!(0, protocol_1.IsValidArgType)(earnest_type))
168
- return false;
169
- if (!(0, protocol_1.IsValidAddress)(service_id))
170
- return false;
171
- if (passport) {
172
- txb.moveCall({
173
- target: protocol_1.PROTOCOL.DemandFn('yes_with_passport'),
174
- arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, demand), txb.pure(service_id, bcs_1.BCS.ADDRESS), (0, protocol_1.TXB_OBJECT)(txb, permission)],
175
- typeArguments: [earnest_type],
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
- else {
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: protocol_1.PROTOCOL.DemandFn('yes'),
181
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand), txb.pure(service_id, bcs_1.BCS.ADDRESS), (0, protocol_1.TXB_OBJECT)(txb, permission)],
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
- return true;
186
- }
187
- exports.demand_yes = demand_yes;
188
- function deposit(earnest_type, txb, demand, earnest) {
189
- if (!(0, protocol_1.IsValidObjects)([demand, earnest]))
190
- return false;
191
- if (!(0, protocol_1.IsValidArgType)(earnest_type))
192
- return false;
193
- txb.moveCall({
194
- target: protocol_1.PROTOCOL.DemandFn('deposit'),
195
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, earnest)],
196
- typeArguments: [earnest_type],
197
- });
198
- return true;
199
- }
200
- exports.deposit = deposit;
201
- function present(earnest_type, service_type, txb, demand, service, tips, passport) {
202
- if (!(0, protocol_1.IsValidObjects)([demand, service]))
203
- return false;
204
- if (!(0, protocol_1.IsValidArgType)(earnest_type))
205
- return false;
206
- if (!(0, protocol_1.IsValidDesription)(tips))
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
- else {
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: protocol_1.PROTOCOL.DemandFn('present'),
218
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(tips, bcs_1.BCS.STRING),],
219
- typeArguments: [earnest_type, service_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
- return true;
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- exports.GRAPHQL_OBJECT = (0, graphql_tag_1.gql)(`
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
- exports.GRAPHQL_OWNER = (0, graphql_tag_1.gql)(`
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
- exports.GRAPHQL_OBJECTS = (0, graphql_tag_1.gql)(`
83
+ export const GRAPHQL_OBJECTS = gql(`
87
84
  query objects($filter:ObjectFilter!){
88
85
  objects(filter:$filter) {
89
86
  nodes {
@@ -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;
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