wowok 1.6.84 → 1.6.85
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/permission.d.ts +1 -1
- package/dist/permission.d.ts.map +1 -1
- package/dist/permission.js +0 -45
- package/package.json +1 -1
- package/src/permission.ts +18 -60
- package/tsconfig.json +112 -112
- package/dist/empty.d.ts +0 -1
- package/dist/empty.d.ts.map +0 -1
- package/dist/empty.js +0 -1
- package/dist/src/arbitration.d.ts +0 -61
- package/dist/src/arbitration.d.ts.map +0 -1
- package/dist/src/arbitration.js +0 -473
- package/dist/src/demand.d.ts +0 -26
- package/dist/src/demand.d.ts.map +0 -1
- package/dist/src/demand.js +0 -256
- package/dist/src/entity.d.ts +0 -27
- package/dist/src/entity.d.ts.map +0 -1
- package/dist/src/entity.js +0 -95
- package/dist/src/exception.d.ts +0 -31
- package/dist/src/exception.d.ts.map +0 -1
- package/dist/src/exception.js +0 -34
- package/dist/src/guard.d.ts +0 -79
- package/dist/src/guard.d.ts.map +0 -1
- package/dist/src/guard.js +0 -749
- package/dist/src/index.d.ts +0 -25
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -24
- package/dist/src/machine.d.ts +0 -67
- package/dist/src/machine.d.ts.map +0 -1
- package/dist/src/machine.js +0 -518
- package/dist/src/passport.d.ts +0 -86
- package/dist/src/passport.d.ts.map +0 -1
- package/dist/src/passport.js +0 -645
- package/dist/src/payment.d.ts +0 -16
- package/dist/src/payment.d.ts.map +0 -1
- package/dist/src/payment.js +0 -41
- package/dist/src/permission.d.ts +0 -150
- package/dist/src/permission.d.ts.map +0 -1
- package/dist/src/permission.js +0 -502
- package/dist/src/progress.d.ts +0 -72
- package/dist/src/progress.d.ts.map +0 -1
- package/dist/src/progress.js +0 -301
- package/dist/src/protocol.d.ts +0 -226
- package/dist/src/protocol.d.ts.map +0 -1
- package/dist/src/protocol.js +0 -482
- package/dist/src/repository.d.ts +0 -83
- package/dist/src/repository.d.ts.map +0 -1
- package/dist/src/repository.js +0 -528
- package/dist/src/resource.d.ts +0 -35
- package/dist/src/resource.d.ts.map +0 -1
- package/dist/src/resource.js +0 -130
- package/dist/src/service.d.ts +0 -128
- package/dist/src/service.d.ts.map +0 -1
- package/dist/src/service.js +0 -1234
- package/dist/src/treasury.d.ts +0 -55
- package/dist/src/treasury.d.ts.map +0 -1
- package/dist/src/treasury.js +0 -396
- package/dist/src/utils.d.ts +0 -93
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -616
- package/dist/src/wowok.d.ts +0 -15
- package/dist/src/wowok.d.ts.map +0 -1
- package/dist/src/wowok.js +0 -67
package/dist/src/demand.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import { Protocol } from './protocol';
|
|
2
|
-
import { IsValidDesription, IsValidAddress, IsValidArgType, IsValidU64, parseObjectType, IsValidU8 } from './utils';
|
|
3
|
-
import { Errors, ERROR } from './exception';
|
|
4
|
-
export class Demand {
|
|
5
|
-
bounty_type;
|
|
6
|
-
permission;
|
|
7
|
-
object;
|
|
8
|
-
txb;
|
|
9
|
-
get_bounty_type() { return this.bounty_type; }
|
|
10
|
-
get_object() { return this.object; }
|
|
11
|
-
static From(txb, bounty_type, permission, object) {
|
|
12
|
-
let d = new Demand(txb, bounty_type, permission);
|
|
13
|
-
d.object = Protocol.TXB_OBJECT(txb, object);
|
|
14
|
-
return d;
|
|
15
|
-
}
|
|
16
|
-
constructor(txb, bounty_type, permission) {
|
|
17
|
-
this.bounty_type = bounty_type;
|
|
18
|
-
this.permission = permission;
|
|
19
|
-
this.txb = txb;
|
|
20
|
-
this.object = '';
|
|
21
|
-
}
|
|
22
|
-
static New(txb, bounty_type, ms_expand, time, permission, description, passport) {
|
|
23
|
-
if (!IsValidDesription(description)) {
|
|
24
|
-
ERROR(Errors.IsValidDesription);
|
|
25
|
-
}
|
|
26
|
-
if (!IsValidArgType(bounty_type)) {
|
|
27
|
-
ERROR(Errors.IsValidArgType, bounty_type);
|
|
28
|
-
}
|
|
29
|
-
if (!IsValidU64(time)) {
|
|
30
|
-
ERROR(Errors.IsValidUint, 'time');
|
|
31
|
-
}
|
|
32
|
-
let d = new Demand(txb, bounty_type, permission);
|
|
33
|
-
const clock = txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
34
|
-
if (passport) {
|
|
35
|
-
d.object = txb.moveCall({
|
|
36
|
-
target: Protocol.Instance().demandFn('new_with_passport'),
|
|
37
|
-
arguments: [passport, txb.pure.string(description), txb.pure.bool(ms_expand), txb.pure.u64(time),
|
|
38
|
-
txb.object(clock), Protocol.TXB_OBJECT(txb, permission)],
|
|
39
|
-
typeArguments: [bounty_type],
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
d.object = txb.moveCall({
|
|
44
|
-
target: Protocol.Instance().demandFn('new'),
|
|
45
|
-
arguments: [txb.pure.string(description), txb.pure.bool(ms_expand), txb.pure.u64(time),
|
|
46
|
-
txb.object(clock), Protocol.TXB_OBJECT(txb, permission)],
|
|
47
|
-
typeArguments: [bounty_type],
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return d;
|
|
51
|
-
}
|
|
52
|
-
launch() {
|
|
53
|
-
return this.txb.moveCall({
|
|
54
|
-
target: Protocol.Instance().demandFn('create'),
|
|
55
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
56
|
-
typeArguments: [this.bounty_type],
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
refund(passport) {
|
|
60
|
-
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
61
|
-
if (passport) {
|
|
62
|
-
this.txb.moveCall({
|
|
63
|
-
target: Protocol.Instance().demandFn('refund_with_passport'),
|
|
64
|
-
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
65
|
-
this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
66
|
-
typeArguments: [this.bounty_type],
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.txb.moveCall({
|
|
71
|
-
target: Protocol.Instance().demandFn('refund'),
|
|
72
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
73
|
-
typeArguments: [this.bounty_type],
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// minutes_duration TRUE , time is minutes count; otherwise, the deadline time
|
|
78
|
-
expand_time(minutes_duration, time, passport) {
|
|
79
|
-
if (!IsValidU64(time)) {
|
|
80
|
-
ERROR(Errors.IsValidUint, 'time');
|
|
81
|
-
}
|
|
82
|
-
if (passport) {
|
|
83
|
-
this.txb.moveCall({
|
|
84
|
-
target: Protocol.Instance().demandFn('time_expand_with_passport'),
|
|
85
|
-
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(minutes_duration),
|
|
86
|
-
this.txb.pure.u64(time), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
87
|
-
typeArguments: [this.bounty_type],
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
this.txb.moveCall({
|
|
92
|
-
target: Protocol.Instance().demandFn('time_expand'),
|
|
93
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(minutes_duration),
|
|
94
|
-
this.txb.pure.u64(time), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
95
|
-
typeArguments: [this.bounty_type],
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
set_guard(guard, service_identifier, passport) {
|
|
100
|
-
if (guard && !Protocol.IsValidObjects([guard])) {
|
|
101
|
-
ERROR(Errors.IsValidObjects, 'guard');
|
|
102
|
-
}
|
|
103
|
-
if (service_identifier !== undefined && !IsValidU8(service_identifier)) {
|
|
104
|
-
ERROR(Errors.InvalidParam, 'set_guard.service_identifier');
|
|
105
|
-
}
|
|
106
|
-
let id = this.txb.pure.option('u8', service_identifier !== undefined ? service_identifier : undefined);
|
|
107
|
-
if (passport) {
|
|
108
|
-
if (guard) {
|
|
109
|
-
this.txb.moveCall({
|
|
110
|
-
target: Protocol.Instance().demandFn('guard_set_with_passport'),
|
|
111
|
-
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard), id,
|
|
112
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
113
|
-
typeArguments: [this.bounty_type],
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
this.txb.moveCall({
|
|
118
|
-
target: Protocol.Instance().demandFn('guard_none_with_passport'),
|
|
119
|
-
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
120
|
-
typeArguments: [this.bounty_type],
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
if (guard) {
|
|
126
|
-
this.txb.moveCall({
|
|
127
|
-
target: Protocol.Instance().demandFn('guard_set'),
|
|
128
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard), id,
|
|
129
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
130
|
-
typeArguments: [this.bounty_type],
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
this.txb.moveCall({
|
|
135
|
-
target: Protocol.Instance().demandFn('guard_none'),
|
|
136
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
137
|
-
typeArguments: [this.bounty_type],
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
set_description(description, passport) {
|
|
143
|
-
if (!IsValidDesription(description)) {
|
|
144
|
-
ERROR(Errors.IsValidDesription);
|
|
145
|
-
}
|
|
146
|
-
if (passport) {
|
|
147
|
-
this.txb.moveCall({
|
|
148
|
-
target: Protocol.Instance().demandFn('description_set_with_passport'),
|
|
149
|
-
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description),
|
|
150
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
151
|
-
typeArguments: [this.bounty_type],
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
this.txb.moveCall({
|
|
156
|
-
target: Protocol.Instance().demandFn('description_set'),
|
|
157
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
158
|
-
typeArguments: [this.bounty_type],
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
yes(service_address, passport) {
|
|
163
|
-
if (!IsValidAddress(service_address)) {
|
|
164
|
-
ERROR(Errors.IsValidAddress);
|
|
165
|
-
}
|
|
166
|
-
if (passport) {
|
|
167
|
-
this.txb.moveCall({
|
|
168
|
-
target: Protocol.Instance().demandFn('yes_with_passport'),
|
|
169
|
-
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
170
|
-
this.txb.pure.address(service_address),
|
|
171
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
172
|
-
typeArguments: [this.bounty_type],
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
this.txb.moveCall({
|
|
177
|
-
target: Protocol.Instance().demandFn('yes'),
|
|
178
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object),
|
|
179
|
-
this.txb.pure.address(service_address),
|
|
180
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
181
|
-
typeArguments: [this.bounty_type],
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
deposit(bounty) {
|
|
186
|
-
if (!Protocol.IsValidObjects([bounty])) {
|
|
187
|
-
ERROR(Errors.IsValidObjects);
|
|
188
|
-
}
|
|
189
|
-
this.txb.moveCall({
|
|
190
|
-
target: Protocol.Instance().demandFn('deposit'),
|
|
191
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, bounty)],
|
|
192
|
-
typeArguments: [this.bounty_type],
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
present(service, service_pay_type, tips, passport) {
|
|
196
|
-
if (!IsValidDesription(tips)) {
|
|
197
|
-
ERROR(Errors.IsValidDesription, 'present.tips');
|
|
198
|
-
}
|
|
199
|
-
if (service_pay_type && !IsValidArgType(service_pay_type)) {
|
|
200
|
-
ERROR(Errors.IsValidArgType, 'service_pay_type');
|
|
201
|
-
}
|
|
202
|
-
if (typeof (service) === 'number') {
|
|
203
|
-
if (!IsValidU8(service) || !passport) {
|
|
204
|
-
ERROR(Errors.IsValidU8, 'present.service or present.passport');
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
if (!Protocol.IsValidObjects([service])) {
|
|
209
|
-
ERROR(Errors.IsValidObjects, 'present.service');
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
if (passport) {
|
|
213
|
-
if (typeof (service) === 'number') {
|
|
214
|
-
this.txb.moveCall({
|
|
215
|
-
target: Protocol.Instance().demandFn('present_with_passport2'),
|
|
216
|
-
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(tips)],
|
|
217
|
-
typeArguments: [this.bounty_type],
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
this.txb.moveCall({
|
|
222
|
-
target: Protocol.Instance().demandFn('present_with_passport'),
|
|
223
|
-
arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, service),
|
|
224
|
-
this.txb.pure.string(tips)],
|
|
225
|
-
typeArguments: [this.bounty_type, service_pay_type],
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
if (typeof (service) !== 'number') {
|
|
231
|
-
this.txb.moveCall({
|
|
232
|
-
target: Protocol.Instance().demandFn('present'),
|
|
233
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, service),
|
|
234
|
-
this.txb.pure.string(tips)],
|
|
235
|
-
typeArguments: [this.bounty_type, service_pay_type],
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
change_permission(new_permission) {
|
|
241
|
-
if (!Protocol.IsValidObjects([new_permission])) {
|
|
242
|
-
ERROR(Errors.IsValidObjects);
|
|
243
|
-
}
|
|
244
|
-
this.txb.moveCall({
|
|
245
|
-
target: Protocol.Instance().demandFn('permission_set'),
|
|
246
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission), Protocol.TXB_OBJECT(this.txb, new_permission)],
|
|
247
|
-
typeArguments: [this.bounty_type]
|
|
248
|
-
});
|
|
249
|
-
this.permission = new_permission;
|
|
250
|
-
}
|
|
251
|
-
static parseObjectType = (chain_type) => {
|
|
252
|
-
return parseObjectType(chain_type, 'demand::Demand<');
|
|
253
|
-
};
|
|
254
|
-
static MAX_BOUNTY_COUNT = 300;
|
|
255
|
-
static MAX_PRESENTERS_COUNT = 200;
|
|
256
|
-
}
|
package/dist/src/entity.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { TxbObject, ResourceAddress, ResourceObject } from './protocol';
|
|
2
|
-
import { TagName, Resource } from './resource';
|
|
3
|
-
import { Transaction as TransactionBlock, TransactionResult } from '@mysten/sui/transactions';
|
|
4
|
-
export interface Entity_Info {
|
|
5
|
-
name: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
avatar?: string;
|
|
8
|
-
twitter?: string;
|
|
9
|
-
discord?: string;
|
|
10
|
-
homepage?: string;
|
|
11
|
-
}
|
|
12
|
-
export declare class Entity {
|
|
13
|
-
protected object: TxbObject;
|
|
14
|
-
protected txb: TransactionBlock;
|
|
15
|
-
get_object(): TxbObject;
|
|
16
|
-
private constructor();
|
|
17
|
-
static From(txb: TransactionBlock): Entity;
|
|
18
|
-
mark(resource: Resource, address: string | TransactionResult, like: TagName.Like | TagName.Dislike): void;
|
|
19
|
-
update(info: Entity_Info): void;
|
|
20
|
-
create_resource(): ResourceAddress;
|
|
21
|
-
create_resource2(): ResourceObject;
|
|
22
|
-
destroy_resource(resource: Resource): TransactionResult;
|
|
23
|
-
use_resource(resource: Resource): TransactionResult;
|
|
24
|
-
transfer_resource(resource: Resource, new_address: string): TransactionResult;
|
|
25
|
-
query_ent(address_queried: string): void;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=entity.d.ts.map
|
package/dist/src/entity.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,SAAS,EAAE,eAAe,EAAoB,cAAc,EAAC,MAAM,YAAY,CAAC;AAG/G,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG9F,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;IACf,SAAS,CAAC,MAAM,EAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,GAAG,mBAAC;IAEd,UAAU;IACV,OAAO;IAKP,MAAM,CAAC,IAAI,CAAC,GAAG,EAAC,gBAAgB,GAAI,MAAM;IAM1C,IAAI,CAAC,QAAQ,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,GAAG,iBAAiB,EAAE,IAAI,EAAC,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,OAAO;IAY/F,MAAM,CAAC,IAAI,EAAE,WAAW;IAsBxB,eAAe,IAAK,eAAe;IAOnC,gBAAgB,IAAI,cAAc;IAOlC,gBAAgB,CAAC,QAAQ,EAAC,QAAQ;IAOlC,YAAY,CAAC,QAAQ,EAAC,QAAQ;IAO9B,iBAAiB,CAAC,QAAQ,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM;IAUvD,SAAS,CAAC,eAAe,EAAC,MAAM;CAUnC"}
|
package/dist/src/entity.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { Protocol } from './protocol';
|
|
2
|
-
import { IsValidDesription, IsValidAddress, IsValidName, isValidHttpUrl, Bcs, } from './utils';
|
|
3
|
-
import { ERROR, Errors } from './exception';
|
|
4
|
-
export class Entity {
|
|
5
|
-
object;
|
|
6
|
-
txb;
|
|
7
|
-
get_object() { return this.object; }
|
|
8
|
-
constructor(txb) {
|
|
9
|
-
this.txb = txb;
|
|
10
|
-
this.object = '';
|
|
11
|
-
}
|
|
12
|
-
static From(txb) {
|
|
13
|
-
let r = new Entity(txb);
|
|
14
|
-
r.object = Protocol.TXB_OBJECT(txb, Protocol.Instance().objectEntity());
|
|
15
|
-
return r;
|
|
16
|
-
}
|
|
17
|
-
mark(resource, address, like) {
|
|
18
|
-
if (typeof (address) === 'string' && !IsValidAddress(address)) {
|
|
19
|
-
ERROR(Errors.IsValidAddress, like);
|
|
20
|
-
}
|
|
21
|
-
this.txb.moveCall({
|
|
22
|
-
target: Protocol.Instance().entityFn(like),
|
|
23
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, resource.get_object()),
|
|
24
|
-
typeof (address) === 'string' ? this.txb.pure.address(address) : address]
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
update(info) {
|
|
28
|
-
if (info?.name && !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
|
-
const bytes = Bcs.getInstance().bcs.ser('PersonalInfo', {
|
|
41
|
-
name: info.name ? new TextEncoder().encode(info.name) : '',
|
|
42
|
-
description: info?.description ? new TextEncoder().encode(info.description) : '',
|
|
43
|
-
avatar: info?.avatar ?? '',
|
|
44
|
-
twitter: info?.twitter ?? '',
|
|
45
|
-
discord: info?.discord ?? '',
|
|
46
|
-
homepage: info?.homepage ?? '',
|
|
47
|
-
}).toBytes();
|
|
48
|
-
this.txb.moveCall({
|
|
49
|
-
target: Protocol.Instance().entityFn('avatar_update'),
|
|
50
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('u8', [].slice.call(bytes))]
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
create_resource() {
|
|
54
|
-
return this.txb.moveCall({
|
|
55
|
-
target: Protocol.Instance().entityFn('resource_create'),
|
|
56
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object)]
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
create_resource2() {
|
|
60
|
-
return this.txb.moveCall({
|
|
61
|
-
target: Protocol.Instance().entityFn('resource_create2'),
|
|
62
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object)]
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
destroy_resource(resource) {
|
|
66
|
-
return this.txb.moveCall({
|
|
67
|
-
target: Protocol.Instance().entityFn('resource_destroy'),
|
|
68
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, resource.get_object())]
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
use_resource(resource) {
|
|
72
|
-
return this.txb.moveCall({
|
|
73
|
-
target: Protocol.Instance().entityFn('resource_use'),
|
|
74
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, resource.get_object())]
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
transfer_resource(resource, new_address) {
|
|
78
|
-
if (!IsValidAddress(new_address))
|
|
79
|
-
ERROR(Errors.IsValidAddress, 'transfer_resource');
|
|
80
|
-
return this.txb.moveCall({
|
|
81
|
-
target: Protocol.Instance().entityFn('resource_transfer'),
|
|
82
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, resource.get_object()),
|
|
83
|
-
this.txb.pure.address(new_address)]
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
query_ent(address_queried) {
|
|
87
|
-
if (!IsValidAddress(address_queried)) {
|
|
88
|
-
ERROR(Errors.InvalidParam, 'query_ent');
|
|
89
|
-
}
|
|
90
|
-
this.txb.moveCall({
|
|
91
|
-
target: Protocol.Instance().entityFn('QueryEnt'),
|
|
92
|
-
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(address_queried)]
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
package/dist/src/exception.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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 argument type",
|
|
8
|
-
IsValidTokenType = "invalid token type",
|
|
9
|
-
IsValidUint = "invalid uint",
|
|
10
|
-
IsValidInt = "invalid int",
|
|
11
|
-
IsValidU64 = "invalid u64",
|
|
12
|
-
IsValidU8 = "invalid u8",
|
|
13
|
-
IsValidPercent = "invalid percent",
|
|
14
|
-
IsValidArray = "invalid array",
|
|
15
|
-
IsValidObjects = "invalid objects",
|
|
16
|
-
AllInvalid = "one valid at least",
|
|
17
|
-
InvalidParam = "invalid parameter",
|
|
18
|
-
IsValidPermissionIndex = "invalid permission index",
|
|
19
|
-
IsValidKey = "invalid key",
|
|
20
|
-
Fail = "fail",
|
|
21
|
-
IsValidIndentifier = "indentifier invalid",
|
|
22
|
-
isValidHttpUrl = "invalid url",
|
|
23
|
-
IsValidBizPermissionIndex = "invalid biz-permission index",
|
|
24
|
-
bcsTypeInvalid = "invalid bcs type",
|
|
25
|
-
IsValidServiceItemName = "invalid service item name",
|
|
26
|
-
IsValidCoinType = "not the coin type",
|
|
27
|
-
IsValidGuardIdentifier = "guard identifier invalid",
|
|
28
|
-
noPermission = "no permission"
|
|
29
|
-
}
|
|
30
|
-
export declare const ERROR: (error: Errors, info?: any) => never;
|
|
31
|
-
//# sourceMappingURL=exception.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,0BAA0B;IACxC,gBAAgB,uBAAuB;IACvC,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,UAAU,gBAAgB;IAC1B,SAAS,eAAe;IACxB,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;IAC9B,yBAAyB,iCAAiC;IAC1D,cAAc,qBAAqB;IACnC,sBAAsB,8BAA8B;IACpD,eAAe,sBAAsB;IACrC,sBAAsB,6BAA6B;IACnD,YAAY,kBAAkB;CACjC;AAED,eAAO,MAAM,KAAK,GAAI,OAAM,MAAM,EAAE,OAAM,GAAG,UAG5C,CAAA"}
|
package/dist/src/exception.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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 argument type";
|
|
9
|
-
Errors["IsValidTokenType"] = "invalid token type";
|
|
10
|
-
Errors["IsValidUint"] = "invalid uint";
|
|
11
|
-
Errors["IsValidInt"] = "invalid int";
|
|
12
|
-
Errors["IsValidU64"] = "invalid u64";
|
|
13
|
-
Errors["IsValidU8"] = "invalid u8";
|
|
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["Fail"] = "fail";
|
|
22
|
-
Errors["IsValidIndentifier"] = "indentifier invalid";
|
|
23
|
-
Errors["isValidHttpUrl"] = "invalid url";
|
|
24
|
-
Errors["IsValidBizPermissionIndex"] = "invalid biz-permission index";
|
|
25
|
-
Errors["bcsTypeInvalid"] = "invalid bcs type";
|
|
26
|
-
Errors["IsValidServiceItemName"] = "invalid service item name";
|
|
27
|
-
Errors["IsValidCoinType"] = "not the coin type";
|
|
28
|
-
Errors["IsValidGuardIdentifier"] = "guard identifier invalid";
|
|
29
|
-
Errors["noPermission"] = "no permission";
|
|
30
|
-
})(Errors || (Errors = {}));
|
|
31
|
-
export const ERROR = (error, info) => {
|
|
32
|
-
const e = error.toString() + (info ? (' ' + info) : '');
|
|
33
|
-
throw e;
|
|
34
|
-
};
|
package/dist/src/guard.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { GuardAddress, Data_Type, MODULES, ContextType, ValueType, OperatorType, TxbObject, GuardObject } from './protocol';
|
|
2
|
-
import { Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
3
|
-
export type GuardConstant = Map<number, Guard_Variable>;
|
|
4
|
-
export interface Guard_Variable {
|
|
5
|
-
type: ValueType;
|
|
6
|
-
value?: Uint8Array;
|
|
7
|
-
bWitness: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface Guard_Options {
|
|
10
|
-
from: 'query' | 'type';
|
|
11
|
-
name: string;
|
|
12
|
-
value: number;
|
|
13
|
-
group?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface GuardAnswer {
|
|
16
|
-
txb: TransactionBlock;
|
|
17
|
-
err?: string;
|
|
18
|
-
identifiers: number[];
|
|
19
|
-
}
|
|
20
|
-
export type OnQueryAnswer = (answer: GuardAnswer) => void;
|
|
21
|
-
export declare const GUARD_QUERIES: any[];
|
|
22
|
-
export declare class Guard {
|
|
23
|
-
static MAX_INPUT_LENGTH: number;
|
|
24
|
-
protected txb: TransactionBlock;
|
|
25
|
-
protected object: TxbObject;
|
|
26
|
-
get_object(): TxbObject;
|
|
27
|
-
static From(txb: TransactionBlock, object: TxbObject): Guard;
|
|
28
|
-
private constructor();
|
|
29
|
-
static New(txb: TransactionBlock, description: string, maker: GuardMaker): Guard;
|
|
30
|
-
launch(): GuardAddress;
|
|
31
|
-
static everyone_guard(txb: TransactionBlock): GuardAddress;
|
|
32
|
-
static QueryAddressIdentifiers(guard: GuardObject, onQueryAnswer: OnQueryAnswer, sender: string): void;
|
|
33
|
-
static BoolCmd: any[];
|
|
34
|
-
static IsBoolCmd: (cmd: number) => boolean;
|
|
35
|
-
static CmdFilter: (retType: ValueType) => any[];
|
|
36
|
-
static GetCmd: (cmd: number | undefined) => any;
|
|
37
|
-
static GetCmdOption: (cmd: number) => Guard_Options | undefined;
|
|
38
|
-
static GetInputParams: (cmd: number) => ValueType[];
|
|
39
|
-
static GetModuleName: (cmd: number) => string;
|
|
40
|
-
static NumberOptions: () => Guard_Options[];
|
|
41
|
-
static Signer: Guard_Options;
|
|
42
|
-
static Time: Guard_Options;
|
|
43
|
-
static Guard: Guard_Options;
|
|
44
|
-
static Logics: () => Guard_Options[];
|
|
45
|
-
static Crunchings: Guard_Options[];
|
|
46
|
-
static CommonOptions: (retType: ValueType) => Guard_Options[];
|
|
47
|
-
static AllOptions: () => Guard_Options[];
|
|
48
|
-
static StringOptions: () => Guard_Options[];
|
|
49
|
-
static BoolOptions: () => Guard_Options[];
|
|
50
|
-
static AddressOptions: () => Guard_Options[];
|
|
51
|
-
static Options: (ret_type: ValueType | "number" | "any") => Guard_Options[];
|
|
52
|
-
}
|
|
53
|
-
export declare const IsValidGuardIdentifier: (identifier: number | undefined) => boolean;
|
|
54
|
-
export declare class GuardMaker {
|
|
55
|
-
protected data: Uint8Array[];
|
|
56
|
-
protected type_validator: Data_Type[];
|
|
57
|
-
protected constant: GuardConstant;
|
|
58
|
-
private static _witness_index;
|
|
59
|
-
private static _const_index;
|
|
60
|
-
private static GetWitnessIndex;
|
|
61
|
-
private static getConstIndex;
|
|
62
|
-
static IsValidIndentifier: (identifier: number) => boolean;
|
|
63
|
-
constructor();
|
|
64
|
-
add_constant(type: ValueType, value?: any, identifier?: number, bNeedSerialize?: boolean): number;
|
|
65
|
-
add_param(type: ValueType | ContextType, param?: any): GuardMaker;
|
|
66
|
-
add_query(module: MODULES, query_name: string, object_address_from: string | number): GuardMaker;
|
|
67
|
-
add_logic(type: OperatorType, logic_count?: number): GuardMaker;
|
|
68
|
-
hasIdentifier(id: number): boolean;
|
|
69
|
-
build(bNot?: boolean): GuardMaker;
|
|
70
|
-
IsReady(): boolean;
|
|
71
|
-
combine(otherBuilt: GuardMaker, bAnd?: boolean, bCombinConstant?: boolean): GuardMaker;
|
|
72
|
-
get_constant(): GuardConstant;
|
|
73
|
-
get_input(): Uint8Array<ArrayBufferLike>[];
|
|
74
|
-
static input_combine(input1: Uint8Array, input2: Uint8Array, bAnd?: boolean): Uint8Array;
|
|
75
|
-
static input_not(input: Uint8Array): Uint8Array;
|
|
76
|
-
static match_u256(type: number): boolean;
|
|
77
|
-
static is_multi_input_op(type: number): boolean;
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=guard.d.ts.map
|
package/dist/src/guard.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/guard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,YAAY,EAAc,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAG,YAAY,EAAE,SAAS,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAC;AAInL,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE3E,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AA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