wowok 1.2.11 → 1.2.12
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/package.json +3 -3
- package/src/demand.ts +85 -98
- package/src/entity.ts +34 -34
- package/src/guard.ts +15 -15
- package/src/machine.ts +150 -174
- package/src/passport.ts +34 -37
- package/src/permission.ts +80 -96
- package/src/progress.ts +118 -118
- package/src/protocol.ts +25 -28
- package/src/repository.ts +147 -160
- package/src/resource.ts +43 -45
- package/src/reward.ts +108 -119
- package/src/service.ts +338 -364
- package/src/utils.ts +4 -4
- package/src/vote.ts +139 -157
- package/src/wowok.ts +19 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wowok",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.12",
|
|
4
4
|
"description": "Create, collaborate, and transact on your own terms with the AI-driven web3 collaboration protocol.",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"vote",
|
|
33
33
|
"tags",
|
|
34
34
|
"entity",
|
|
35
|
-
"resource",
|
|
35
|
+
"resource",
|
|
36
36
|
"grantor",
|
|
37
37
|
"grantee",
|
|
38
38
|
"move language",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"license": "Apache-2.0",
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@mysten/bcs": "^0.11.1",
|
|
45
|
-
"@mysten/sui
|
|
45
|
+
"@mysten/sui": "^1.7.0",
|
|
46
46
|
"graphql-tag": "^2.12.6"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
package/src/demand.ts
CHANGED
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
import { type TransactionResult } from '@mysten/sui
|
|
1
|
+
import { type TransactionResult, Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
2
2
|
import { BCS } from '@mysten/bcs';
|
|
3
3
|
import { FnCallType, Protocol, PassportObject, PermissionObject, GuardObject, DemandAddress, TxbObject, ResourceObject} from './protocol';
|
|
4
4
|
import { IsValidDesription, IsValidUintLarge, IsValidAddress, IsValidArgType, } from './utils'
|
|
5
5
|
import { Errors, ERROR} from './exception'
|
|
6
|
-
import { Resource } from './resource'
|
|
7
|
-
|
|
8
6
|
|
|
9
7
|
export class Demand {
|
|
10
8
|
protected bounty_type;
|
|
11
9
|
protected permission ;
|
|
12
|
-
protected object : TxbObject
|
|
13
|
-
protected
|
|
10
|
+
protected object : TxbObject;
|
|
11
|
+
protected txb;
|
|
14
12
|
|
|
15
13
|
get_bounty_type() { return this.bounty_type }
|
|
16
14
|
get_object() { return this.object }
|
|
17
15
|
|
|
18
|
-
static From(
|
|
19
|
-
let d = new Demand(
|
|
20
|
-
d.object = Protocol.TXB_OBJECT(
|
|
16
|
+
static From(txb:TransactionBlock, bounty_type:string, permission:PermissionObject, object:TxbObject) : Demand {
|
|
17
|
+
let d = new Demand(txb, bounty_type, permission)
|
|
18
|
+
d.object = Protocol.TXB_OBJECT(txb, object)
|
|
21
19
|
return d
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
private constructor(
|
|
22
|
+
private constructor(txb:TransactionBlock, bounty_type:string, permission:PermissionObject) {
|
|
25
23
|
this.bounty_type = bounty_type;
|
|
26
24
|
this.permission = permission;
|
|
27
|
-
this.
|
|
25
|
+
this.txb = txb;
|
|
28
26
|
this.object = '';
|
|
29
27
|
}
|
|
30
|
-
static New(
|
|
28
|
+
static New(txb:TransactionBlock, bounty_type:string, permission:PermissionObject, description:string,
|
|
31
29
|
bounty:TransactionResult | string, passport?:PassportObject) : Demand {
|
|
32
30
|
if (!Protocol.IsValidObjects([permission, bounty])) {
|
|
33
31
|
ERROR(Errors.IsValidObjects, 'permission, bounty');
|
|
@@ -39,18 +37,17 @@ export class Demand {
|
|
|
39
37
|
ERROR(Errors.IsValidArgType, bounty_type);
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
let d = new Demand(
|
|
43
|
-
let txb = protocol.CurrentSession();
|
|
40
|
+
let d = new Demand(txb, bounty_type, permission);
|
|
44
41
|
if (passport) {
|
|
45
42
|
d.object = txb.moveCall({
|
|
46
|
-
target:
|
|
47
|
-
arguments:[passport, txb.pure(description), txb.object(bounty), Protocol.TXB_OBJECT(txb, permission)],
|
|
43
|
+
target:Protocol.Instance().DemandFn('new_with_passport') as FnCallType,
|
|
44
|
+
arguments:[passport, txb.pure.string(description), txb.object(bounty), Protocol.TXB_OBJECT(txb, permission)],
|
|
48
45
|
typeArguments:[bounty_type],
|
|
49
46
|
})
|
|
50
47
|
} else {
|
|
51
48
|
d.object = txb.moveCall({
|
|
52
|
-
target:
|
|
53
|
-
arguments:[txb.pure(description), txb.object(bounty), Protocol.TXB_OBJECT(txb, permission)],
|
|
49
|
+
target:Protocol.Instance().DemandFn('new') as FnCallType,
|
|
50
|
+
arguments:[txb.pure.string(description), txb.object(bounty), Protocol.TXB_OBJECT(txb, permission)],
|
|
54
51
|
typeArguments:[bounty_type],
|
|
55
52
|
})
|
|
56
53
|
}
|
|
@@ -58,35 +55,34 @@ export class Demand {
|
|
|
58
55
|
}
|
|
59
56
|
|
|
60
57
|
launch() : DemandAddress {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object)],
|
|
58
|
+
return this.txb.moveCall({
|
|
59
|
+
target:Protocol.Instance().DemandFn('create') as FnCallType,
|
|
60
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
65
61
|
typeArguments:[this.bounty_type],
|
|
66
62
|
})
|
|
67
63
|
}
|
|
68
64
|
|
|
69
65
|
destroy() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object)],
|
|
66
|
+
this.txb.moveCall({
|
|
67
|
+
target:Protocol.Instance().DemandFn('destroy') as FnCallType,
|
|
68
|
+
arguments: [Protocol.TXB_OBJECT(this.txb, this.object)],
|
|
74
69
|
typeArguments:[this.bounty_type]
|
|
75
70
|
})
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
refund(passport?:PassportObject) {
|
|
79
|
-
|
|
74
|
+
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
80
75
|
if (passport) {
|
|
81
|
-
txb.moveCall({
|
|
82
|
-
target:
|
|
83
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object),
|
|
76
|
+
this.txb.moveCall({
|
|
77
|
+
target:Protocol.Instance().DemandFn('refund_with_passport') as FnCallType,
|
|
78
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
79
|
+
this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
84
80
|
typeArguments:[this.bounty_type],
|
|
85
81
|
})
|
|
86
82
|
} else {
|
|
87
|
-
txb.moveCall({
|
|
88
|
-
target:
|
|
89
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.object(
|
|
83
|
+
this.txb.moveCall({
|
|
84
|
+
target:Protocol.Instance().DemandFn('refund') as FnCallType,
|
|
85
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
90
86
|
typeArguments:[this.bounty_type],
|
|
91
87
|
})
|
|
92
88
|
}
|
|
@@ -97,22 +93,19 @@ export class Demand {
|
|
|
97
93
|
if (!IsValidUintLarge(time)) {
|
|
98
94
|
ERROR(Errors.IsValidUint, 'time');
|
|
99
95
|
}
|
|
100
|
-
|
|
101
|
-
let txb = this.protocol.CurrentSession();
|
|
96
|
+
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
102
97
|
if (passport) {
|
|
103
|
-
txb.moveCall({
|
|
104
|
-
target:
|
|
105
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(minutes_duration
|
|
106
|
-
txb.pure(time,
|
|
107
|
-
txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
98
|
+
this.txb.moveCall({
|
|
99
|
+
target:Protocol.Instance().DemandFn('time_expand_with_passport') as FnCallType,
|
|
100
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(minutes_duration),
|
|
101
|
+
this.txb.pure.u64(time), this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
108
102
|
typeArguments:[this.bounty_type],
|
|
109
103
|
})
|
|
110
104
|
} else {
|
|
111
|
-
txb.moveCall({
|
|
112
|
-
target:
|
|
113
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(minutes_duration
|
|
114
|
-
txb.pure(time,
|
|
115
|
-
txb.object(Protocol.CLOCK_OBJECT), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
105
|
+
this.txb.moveCall({
|
|
106
|
+
target:Protocol.Instance().DemandFn('time_expand') as FnCallType,
|
|
107
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.bool(minutes_duration),
|
|
108
|
+
this.txb.pure.u64(time), this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
116
109
|
typeArguments:[this.bounty_type],
|
|
117
110
|
})
|
|
118
111
|
}
|
|
@@ -122,35 +115,34 @@ export class Demand {
|
|
|
122
115
|
if (guard && !Protocol.IsValidObjects([guard])) {
|
|
123
116
|
ERROR(Errors.IsValidObjects, 'guard');
|
|
124
117
|
}
|
|
125
|
-
|
|
126
|
-
let txb = this.protocol.CurrentSession();
|
|
118
|
+
|
|
127
119
|
if (passport) {
|
|
128
120
|
if (guard) {
|
|
129
|
-
txb.moveCall({
|
|
130
|
-
target:
|
|
131
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, guard),
|
|
132
|
-
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
121
|
+
this.txb.moveCall({
|
|
122
|
+
target:Protocol.Instance().DemandFn('guard_set_with_passport') as FnCallType,
|
|
123
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard),
|
|
124
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
133
125
|
typeArguments:[this.bounty_type],
|
|
134
126
|
})
|
|
135
127
|
} else {
|
|
136
|
-
txb.moveCall({
|
|
137
|
-
target:
|
|
138
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
128
|
+
this.txb.moveCall({
|
|
129
|
+
target:Protocol.Instance().DemandFn('guard_none_with_passport') as FnCallType,
|
|
130
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
139
131
|
typeArguments:[this.bounty_type],
|
|
140
132
|
})
|
|
141
133
|
}
|
|
142
134
|
} else {
|
|
143
135
|
if (guard) {
|
|
144
|
-
txb.moveCall({
|
|
145
|
-
target:
|
|
146
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, guard),
|
|
147
|
-
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
136
|
+
this.txb.moveCall({
|
|
137
|
+
target:Protocol.Instance().DemandFn('guard_set') as FnCallType,
|
|
138
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard),
|
|
139
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
148
140
|
typeArguments:[this.bounty_type],
|
|
149
141
|
})
|
|
150
142
|
} else {
|
|
151
|
-
txb.moveCall({
|
|
152
|
-
target:
|
|
153
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
143
|
+
this.txb.moveCall({
|
|
144
|
+
target:Protocol.Instance().DemandFn('guard_none') as FnCallType,
|
|
145
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
154
146
|
typeArguments:[this.bounty_type],
|
|
155
147
|
})
|
|
156
148
|
}
|
|
@@ -162,18 +154,17 @@ export class Demand {
|
|
|
162
154
|
ERROR(Errors.IsValidDesription);
|
|
163
155
|
}
|
|
164
156
|
|
|
165
|
-
let txb = this.protocol.CurrentSession();
|
|
166
157
|
if (passport) {
|
|
167
|
-
txb.moveCall({
|
|
168
|
-
target:
|
|
169
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), txb.pure(description),
|
|
170
|
-
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
158
|
+
this.txb.moveCall({
|
|
159
|
+
target:Protocol.Instance().DemandFn('description_set_with_passport') as FnCallType,
|
|
160
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description),
|
|
161
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
171
162
|
typeArguments:[this.bounty_type],
|
|
172
163
|
})
|
|
173
164
|
} else {
|
|
174
|
-
txb.moveCall({
|
|
175
|
-
target:
|
|
176
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(description), Protocol.TXB_OBJECT(txb, this.permission)],
|
|
165
|
+
this.txb.moveCall({
|
|
166
|
+
target:Protocol.Instance().DemandFn('description_set') as FnCallType,
|
|
167
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(description), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
177
168
|
typeArguments:[this.bounty_type],
|
|
178
169
|
})
|
|
179
170
|
}
|
|
@@ -184,21 +175,20 @@ export class Demand {
|
|
|
184
175
|
ERROR(Errors.IsValidAddress)
|
|
185
176
|
}
|
|
186
177
|
|
|
187
|
-
let txb = this.protocol.CurrentSession();
|
|
188
178
|
if (passport) {
|
|
189
|
-
txb.moveCall({
|
|
190
|
-
target:
|
|
191
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object),
|
|
192
|
-
txb.pure(service_address
|
|
193
|
-
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
179
|
+
this.txb.moveCall({
|
|
180
|
+
target:Protocol.Instance().DemandFn('yes_with_passport') as FnCallType,
|
|
181
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object),
|
|
182
|
+
this.txb.pure.address(service_address),
|
|
183
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
194
184
|
typeArguments:[this.bounty_type],
|
|
195
185
|
})
|
|
196
186
|
} else {
|
|
197
|
-
txb.moveCall({
|
|
198
|
-
target:
|
|
199
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object),
|
|
200
|
-
txb.pure(service_address
|
|
201
|
-
Protocol.TXB_OBJECT(txb, this.permission)],
|
|
187
|
+
this.txb.moveCall({
|
|
188
|
+
target:Protocol.Instance().DemandFn('yes') as FnCallType,
|
|
189
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object),
|
|
190
|
+
this.txb.pure.address(service_address),
|
|
191
|
+
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
202
192
|
typeArguments:[this.bounty_type],
|
|
203
193
|
})
|
|
204
194
|
}
|
|
@@ -208,11 +198,10 @@ export class Demand {
|
|
|
208
198
|
if (!Protocol.IsValidObjects([bounty])) {
|
|
209
199
|
ERROR(Errors.IsValidObjects)
|
|
210
200
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, bounty)],
|
|
201
|
+
|
|
202
|
+
this.txb.moveCall({
|
|
203
|
+
target:Protocol.Instance().DemandFn('deposit') as FnCallType,
|
|
204
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, bounty)],
|
|
216
205
|
typeArguments:[this.bounty_type],
|
|
217
206
|
})
|
|
218
207
|
}
|
|
@@ -227,20 +216,19 @@ export class Demand {
|
|
|
227
216
|
if (!IsValidArgType(service_pay_type)) {
|
|
228
217
|
ERROR(Errors.IsValidArgType, 'service_pay_type')
|
|
229
218
|
}
|
|
230
|
-
|
|
231
|
-
let txb = this.protocol.CurrentSession();
|
|
219
|
+
|
|
232
220
|
if (passport) {
|
|
233
|
-
txb.moveCall({
|
|
234
|
-
target:
|
|
235
|
-
arguments:[passport, Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, service_address),
|
|
236
|
-
txb.pure(tips)],
|
|
221
|
+
this.txb.moveCall({
|
|
222
|
+
target:Protocol.Instance().DemandFn('present_with_passport') as FnCallType,
|
|
223
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, service_address),
|
|
224
|
+
this.txb.pure.string(tips)],
|
|
237
225
|
typeArguments:[this.bounty_type, service_pay_type],
|
|
238
226
|
})
|
|
239
227
|
} else {
|
|
240
|
-
txb.moveCall({
|
|
241
|
-
target:
|
|
242
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, service_address),
|
|
243
|
-
txb.pure(tips)],
|
|
228
|
+
this.txb.moveCall({
|
|
229
|
+
target:Protocol.Instance().DemandFn('present') as FnCallType,
|
|
230
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, service_address),
|
|
231
|
+
this.txb.pure.string(tips)],
|
|
244
232
|
typeArguments:[this.bounty_type, service_pay_type],
|
|
245
233
|
})
|
|
246
234
|
}
|
|
@@ -250,10 +238,9 @@ export class Demand {
|
|
|
250
238
|
ERROR(Errors.IsValidObjects)
|
|
251
239
|
}
|
|
252
240
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, this.permission), Protocol.TXB_OBJECT(txb, new_permission)],
|
|
241
|
+
this.txb.moveCall({
|
|
242
|
+
target:Protocol.Instance().DemandFn('permission_set') as FnCallType,
|
|
243
|
+
arguments: [Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, this.permission), Protocol.TXB_OBJECT(this.txb, new_permission)],
|
|
257
244
|
typeArguments:[this.bounty_type]
|
|
258
245
|
})
|
|
259
246
|
this.permission = new_permission
|
package/src/entity.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Protocol, FnCallType, TxbObject, ResourceAddress, PermissionObject, Res
|
|
|
3
3
|
import { IsValidDesription, IsValidAddress, IsValidName, isValidHttpUrl, Bcs, } from './utils';
|
|
4
4
|
import { ERROR, Errors } from './exception';
|
|
5
5
|
import { Resource } from './resource';
|
|
6
|
+
import { type TransactionResult, Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
6
7
|
|
|
7
8
|
export interface Entity_Info {
|
|
8
9
|
name: string;
|
|
@@ -16,27 +17,27 @@ export interface Entity_Info {
|
|
|
16
17
|
export class Entity {
|
|
17
18
|
|
|
18
19
|
protected object:TxbObject;
|
|
19
|
-
protected
|
|
20
|
+
protected txb;
|
|
20
21
|
|
|
21
22
|
get_object() { return this.object }
|
|
22
|
-
private constructor(
|
|
23
|
-
this.
|
|
23
|
+
private constructor(txb:TransactionBlock) {
|
|
24
|
+
this.txb = txb;
|
|
24
25
|
this.object = '';
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
static From(
|
|
28
|
-
let r = new Entity(
|
|
29
|
-
r.object = Protocol.TXB_OBJECT(
|
|
28
|
+
static From(txb:TransactionBlock) : Entity {
|
|
29
|
+
let r = new Entity(txb);
|
|
30
|
+
r.object = Protocol.TXB_OBJECT(txb, Protocol.Instance().EntityObject());
|
|
30
31
|
return r
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
mark(resource:Resource, address:string, like:'like' | 'dislike') {
|
|
34
35
|
if (!IsValidAddress(address)) ERROR(Errors.IsValidAddress, like);
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
this.txb.moveCall({
|
|
38
|
+
target:Protocol.Instance().EntityFn(like) as FnCallType,
|
|
39
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, resource.get_object()),
|
|
40
|
+
this.txb.pure.address(address)]
|
|
40
41
|
})
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -48,7 +49,6 @@ export class Entity {
|
|
|
48
49
|
if (info?.homepage && !isValidHttpUrl(info.homepage)) ERROR(Errors.isValidHttpUrl, 'update:homepage');
|
|
49
50
|
if (info?.discord && !IsValidName(info.discord)) ERROR(Errors.IsValidName, 'update:discord');
|
|
50
51
|
|
|
51
|
-
const txb = this.protocol.CurrentSession();
|
|
52
52
|
const bytes = Bcs.getInstance().bcs.ser('PersonalInfo', {
|
|
53
53
|
name:info.name ? new TextEncoder().encode(info.name) :'',
|
|
54
54
|
description : info?.description ? new TextEncoder().encode(info.description) : '',
|
|
@@ -57,42 +57,43 @@ export class Entity {
|
|
|
57
57
|
discord : info?.discord ?? '',
|
|
58
58
|
homepage : info?.homepage ?? '',
|
|
59
59
|
}).toBytes();
|
|
60
|
-
txb.moveCall({
|
|
61
|
-
target:
|
|
62
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure([].slice.call(bytes)
|
|
60
|
+
this.txb.moveCall({
|
|
61
|
+
target:Protocol.Instance().EntityFn('avatar_update') as FnCallType,
|
|
62
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('u8', [].slice.call(bytes))]
|
|
63
63
|
})
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
create_resource() : ResourceAddress {
|
|
67
|
-
|
|
68
|
-
return txb.moveCall({
|
|
69
|
-
target:
|
|
70
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object)]
|
|
67
|
+
|
|
68
|
+
return this.txb.moveCall({
|
|
69
|
+
target:Protocol.Instance().EntityFn('resource_create') as FnCallType,
|
|
70
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object)]
|
|
71
71
|
})
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
create_resource2(): ResourceObject {
|
|
75
|
-
|
|
76
|
-
return txb.moveCall({
|
|
77
|
-
target:
|
|
78
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object)]
|
|
75
|
+
|
|
76
|
+
return this.txb.moveCall({
|
|
77
|
+
target:Protocol.Instance().EntityFn('resource_create2') as FnCallType,
|
|
78
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object)]
|
|
79
79
|
})
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
destroy_resource(resource:Resource) {
|
|
83
|
-
|
|
84
|
-
return txb.moveCall({
|
|
85
|
-
target:
|
|
86
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, resource.get_object())]
|
|
83
|
+
|
|
84
|
+
return this.txb.moveCall({
|
|
85
|
+
target:Protocol.Instance().EntityFn('resource_destroy') as FnCallType,
|
|
86
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, resource.get_object())]
|
|
87
87
|
})
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
transfer_resource(resource:Resource, new_address:string) {
|
|
91
91
|
if (!IsValidAddress(new_address)) ERROR(Errors.IsValidAddress, 'transfer_resource');
|
|
92
|
-
|
|
93
|
-
return txb.moveCall({
|
|
94
|
-
target:
|
|
95
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, resource.get_object()),
|
|
92
|
+
|
|
93
|
+
return this.txb.moveCall({
|
|
94
|
+
target:Protocol.Instance().EntityFn('resource_transfer') as FnCallType,
|
|
95
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, resource.get_object()),
|
|
96
|
+
this.txb.pure.address(new_address)]
|
|
96
97
|
})
|
|
97
98
|
}
|
|
98
99
|
|
|
@@ -101,10 +102,9 @@ export class Entity {
|
|
|
101
102
|
ERROR(Errors.InvalidParam, 'query_ent');
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
arguments:[Protocol.TXB_OBJECT(txb, this.object), txb.pure(address_queried, BCS.ADDRESS)]
|
|
105
|
+
this.txb.moveCall({
|
|
106
|
+
target:Protocol.Instance().EntityFn('QueryEnt') as FnCallType,
|
|
107
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(address_queried)]
|
|
108
108
|
})
|
|
109
109
|
}
|
|
110
110
|
}
|
package/src/guard.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Protocol, LogicsInfo, GuardAddress, FnCallType, Data_Type, MODULES, Con
|
|
|
4
4
|
import { concatenate, array_equal } from './utils';
|
|
5
5
|
import { IsValidDesription, Bcs, IsValidInt, IsValidAddress, FirstLetterUppercase } from './utils';
|
|
6
6
|
import { ERROR, Errors } from './exception';
|
|
7
|
+
import { Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
7
8
|
|
|
8
9
|
export type GuardConstant = Map<number, Guard_Vriable>;
|
|
9
10
|
|
|
@@ -22,7 +23,7 @@ export interface Guard_Options {
|
|
|
22
23
|
|
|
23
24
|
export class Guard {
|
|
24
25
|
static MAX_INPUT_LENGTH = 2048;
|
|
25
|
-
static launch(
|
|
26
|
+
static launch(txb:TransactionBlock, description:string, maker:GuardMaker) : GuardAddress {
|
|
26
27
|
if (!maker.IsReady()) {
|
|
27
28
|
ERROR(Errors.InvalidParam, 'launch maker');
|
|
28
29
|
}
|
|
@@ -45,13 +46,12 @@ export class Guard {
|
|
|
45
46
|
ERROR(Errors.InvalidParam, 'launch constants')
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
let txb = protocol.CurrentSession();
|
|
49
49
|
let input = new Uint8Array(bcs_input); // copy new uint8array to reserve!
|
|
50
50
|
|
|
51
51
|
// reserve the bytes for guard
|
|
52
52
|
let guard = txb.moveCall({
|
|
53
|
-
target:
|
|
54
|
-
arguments: [txb.pure(description), txb.pure([].slice.call(input.reverse()))],
|
|
53
|
+
target: Protocol.Instance().GuardFn('new') as FnCallType,
|
|
54
|
+
arguments: [txb.pure.string(description), txb.pure.vector('u8', [].slice.call(input.reverse()))],
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
constants?.forEach((v, k) => {
|
|
@@ -61,8 +61,8 @@ export class Guard {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
txb.moveCall({
|
|
64
|
-
target:
|
|
65
|
-
arguments:[guard, txb.pure(k
|
|
64
|
+
target:Protocol.Instance().GuardFn("constant_add") as FnCallType,
|
|
65
|
+
arguments:[guard, txb.pure.u8(k), txb.pure.u8(v.type), txb.pure.vector('u8', [].slice.call(v.witness)), txb.pure.bool(true)]
|
|
66
66
|
})
|
|
67
67
|
} else {
|
|
68
68
|
if (!v.value) {
|
|
@@ -70,28 +70,28 @@ export class Guard {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
txb.moveCall({
|
|
73
|
-
target:
|
|
74
|
-
arguments:[guard, txb.pure(k
|
|
73
|
+
target:Protocol.Instance().GuardFn("constant_add") as FnCallType,
|
|
74
|
+
arguments:[guard, txb.pure.u8(k), txb.pure.u8(v.type), txb.pure.vector('u8', [].slice.call(v.value)), txb.pure.bool(true)]
|
|
75
75
|
})
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
return txb.moveCall({
|
|
80
|
-
target:
|
|
80
|
+
target:Protocol.Instance().GuardFn("create") as FnCallType,
|
|
81
81
|
arguments:[guard]
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
static signer_guard(
|
|
86
|
-
return
|
|
87
|
-
target:
|
|
85
|
+
static signer_guard(txb: TransactionBlock) : GuardAddress {
|
|
86
|
+
return txb.moveCall({
|
|
87
|
+
target: Protocol.Instance().GuardFn('signer_guard') as FnCallType,
|
|
88
88
|
arguments: []
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
static everyone_guard(
|
|
93
|
-
return
|
|
94
|
-
target:
|
|
92
|
+
static everyone_guard(txb:TransactionBlock) : GuardAddress {
|
|
93
|
+
return txb.moveCall({
|
|
94
|
+
target: Protocol.Instance().GuardFn('everyone_guard') as FnCallType,
|
|
95
95
|
arguments: []
|
|
96
96
|
});
|
|
97
97
|
}
|