wowok 1.2.11 → 1.3.3

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