wowok 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/demand.js CHANGED
@@ -208,14 +208,14 @@ function present(earnest_type, service_type, txb, demand, service, tips, passpor
208
208
  if (passport) {
209
209
  txb.moveCall({
210
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),],
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
212
  typeArguments: [earnest_type, service_type],
213
213
  });
214
214
  }
215
215
  else {
216
216
  txb.moveCall({
217
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),],
218
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, demand), (0, protocol_1.TXB_OBJECT)(txb, service), txb.pure(tips, bcs_1.BCS.STRING),],
219
219
  typeArguments: [earnest_type, service_type],
220
220
  });
221
221
  }
@@ -0,0 +1,102 @@
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)(`
6
+ query objects_type_version($filter:ObjectFilter!) {
7
+ objects(filter:$filter) {
8
+ nodes {
9
+ address
10
+ version
11
+ asMoveObject {
12
+ contents {
13
+ type {
14
+ repr
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }
21
+ `);
22
+ exports.GRAPHQL_OBJECT = (0, graphql_tag_1.gql)(`
23
+ query object($ObjectID:SuiAddress!) {
24
+ object(address:$ObjectID) {
25
+ address
26
+ asMoveObject {
27
+ contents {
28
+ json
29
+ type {
30
+ repr
31
+ }
32
+ }
33
+ }
34
+ dynamicFields {
35
+ pageInfo {
36
+ hasNextPage
37
+ endCursor
38
+ }
39
+ nodes {
40
+ name {
41
+ json
42
+ }
43
+ value {
44
+ ... on MoveValue {
45
+ json
46
+ }
47
+ ... on MoveObject {
48
+ contents {
49
+ json
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+ `);
58
+ exports.GRAPHQL_OWNER = (0, graphql_tag_1.gql)(`
59
+ query owner($ObjectID:SuiAddress!) {
60
+ owner (address: $ObjectID) {
61
+ address
62
+ dynamicFields {
63
+ pageInfo {
64
+ hasNextPage
65
+ endCursor
66
+ }
67
+ nodes {
68
+ name {
69
+ json
70
+ }
71
+ value {
72
+ ... on MoveValue {
73
+ json
74
+ }
75
+ ... on MoveObject {
76
+ contents {
77
+ json
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ `);
86
+ exports.GRAPHQL_OBJECTS = (0, graphql_tag_1.gql)(`
87
+ query objects($filter:ObjectFilter!){
88
+ objects(filter:$filter) {
89
+ nodes {
90
+ address
91
+ asMoveObject {
92
+ contents {
93
+ json
94
+ type {
95
+ repr
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ `);
package/dist/guard.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sense_objects_fn = exports.description_fn = exports.parse_sense_bsc = exports.SenseMaker = exports.Sense_Cmd = exports.signer_guard = exports.launch = exports.Guard_Sense_Binder = exports.MAX_SENSE_COUNT = void 0;
3
+ exports.rpc_sense_objects_fn = exports.rpc_description_fn = exports.parse_sense_bsc = exports.parse_graphql_senses = exports.SenseMaker = exports.QUERIES = exports.everyone_guard = exports.signer_guard = exports.launch = exports.Guard_Sense_Binder = exports.MAX_SENSE_COUNT = void 0;
4
4
  const bcs_1 = require("@mysten/bcs");
5
5
  const protocol_1 = require("./protocol");
6
6
  const util_1 = require("./util");
@@ -17,7 +17,7 @@ function launch(txb, creation) {
17
17
  return false;
18
18
  let bValid = true;
19
19
  creation.senses.forEach((v) => {
20
- if (v.input.length == 0)
20
+ if (!v.input || v.input.length == 0)
21
21
  bValid = false;
22
22
  });
23
23
  if (!bValid)
@@ -42,19 +42,30 @@ function launch(txb, creation) {
42
42
  }
43
43
  exports.launch = launch;
44
44
  function signer_guard(txb) {
45
- txb.moveCall({
45
+ return txb.moveCall({
46
46
  target: protocol_1.PROTOCOL.GuardFn('signer_guard'),
47
47
  arguments: []
48
- }); // { kind: 'Result', index: 0 }, ref to address could used by PTB
49
- return true;
48
+ });
50
49
  }
51
50
  exports.signer_guard = signer_guard;
52
- exports.Sense_Cmd = [[protocol_1.MODULES.permission, 'creator', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
51
+ function everyone_guard(txb) {
52
+ return txb.moveCall({
53
+ target: protocol_1.PROTOCOL.GuardFn('everyone_guard'),
54
+ arguments: []
55
+ });
56
+ }
57
+ exports.everyone_guard = everyone_guard;
58
+ exports.QUERIES = [
59
+ // module, 'name', 'id', [input], output
60
+ [protocol_1.MODULES.permission, 'builder', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
53
61
  [protocol_1.MODULES.permission, 'is_admin', 2, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
54
62
  [protocol_1.MODULES.permission, 'has_rights', 3, [protocol_1.ValueType.TYPE_STATIC_address, protocol_1.ValueType.TYPE_STATIC_u64], protocol_1.ValueType.TYPE_STATIC_bool],
55
63
  [protocol_1.MODULES.permission, 'contains_address', 4, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
56
64
  [protocol_1.MODULES.permission, 'contains_index', 5, [protocol_1.ValueType.TYPE_STATIC_address, protocol_1.ValueType.TYPE_STATIC_u64], protocol_1.ValueType.TYPE_STATIC_bool],
57
65
  [protocol_1.MODULES.permission, 'contains_guard', 6, [protocol_1.ValueType.TYPE_STATIC_address, protocol_1.ValueType.TYPE_STATIC_u64], protocol_1.ValueType.TYPE_STATIC_bool],
66
+ [protocol_1.MODULES.permission, 'contains_guard', 7, [protocol_1.ValueType.TYPE_STATIC_address, protocol_1.ValueType.TYPE_STATIC_u64], protocol_1.ValueType.TYPE_STATIC_address],
67
+ [protocol_1.MODULES.permission, 'entity_count', 8, [], protocol_1.ValueType.TYPE_STATIC_u64],
68
+ [protocol_1.MODULES.permission, 'admin_count', 9, [], protocol_1.ValueType.TYPE_STATIC_u64],
58
69
  [protocol_1.MODULES.repository, 'permission', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
59
70
  [protocol_1.MODULES.repository, 'policy_contains', 2, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_bool],
60
71
  [protocol_1.MODULES.repository, 'policy_has_permission_index', 3, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_bool],
@@ -66,6 +77,102 @@ exports.Sense_Cmd = [[protocol_1.MODULES.permission, 'creator', 1, [], protocol_
66
77
  [protocol_1.MODULES.repository, 'value', 9, [protocol_1.ValueType.TYPE_STATIC_address, protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_vec_u8],
67
78
  [protocol_1.MODULES.repository, 'type', 10, [], protocol_1.ValueType.TYPE_STATIC_u8],
68
79
  [protocol_1.MODULES.repository, 'policy_mode', 11, [], protocol_1.ValueType.TYPE_STATIC_u8],
80
+ [protocol_1.MODULES.machine, 'permission', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
81
+ [protocol_1.MODULES.machine, 'has_paused', 2, [], protocol_1.ValueType.TYPE_STATIC_bool],
82
+ [protocol_1.MODULES.machine, 'has_published', 3, [], protocol_1.ValueType.TYPE_STATIC_bool],
83
+ [protocol_1.MODULES.machine, 'consensus_repositories_contains', 5, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
84
+ [protocol_1.MODULES.machine, 'has_endpoint', 6, [], protocol_1.ValueType.TYPE_STATIC_bool],
85
+ [protocol_1.MODULES.machine, 'endpoint', 7, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
86
+ [protocol_1.MODULES.progress, 'machine', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
87
+ [protocol_1.MODULES.progress, 'current', 2, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
88
+ [protocol_1.MODULES.progress, 'has_parent', 3, [], protocol_1.ValueType.TYPE_STATIC_bool],
89
+ [protocol_1.MODULES.progress, 'parent', 4, [], protocol_1.ValueType.TYPE_STATIC_address],
90
+ [protocol_1.MODULES.progress, 'has_task', 5, [], protocol_1.ValueType.TYPE_STATIC_bool],
91
+ [protocol_1.MODULES.progress, 'task', 6, [], protocol_1.ValueType.TYPE_STATIC_address],
92
+ [protocol_1.MODULES.progress, 'has_namedOperator', 7, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_bool],
93
+ [protocol_1.MODULES.progress, 'namedOperator_contains', 8, [protocol_1.ValueType.TYPE_STATIC_vec_u8, protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
94
+ [protocol_1.MODULES.progress, 'has_context_repository', 9, [], protocol_1.ValueType.TYPE_STATIC_bool],
95
+ [protocol_1.MODULES.progress, 'context_repository', 10, [], protocol_1.ValueType.TYPE_STATIC_address],
96
+ [protocol_1.MODULES.demand, 'permission', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
97
+ [protocol_1.MODULES.demand, 'has_time_expire', 2, [], protocol_1.ValueType.TYPE_STATIC_bool],
98
+ [protocol_1.MODULES.demand, 'time_expire', 3, [], protocol_1.ValueType.TYPE_STATIC_u64],
99
+ [protocol_1.MODULES.demand, 'earnest_count', 4, [], protocol_1.ValueType.TYPE_STATIC_u64],
100
+ [protocol_1.MODULES.demand, 'has_guard', 5, [], protocol_1.ValueType.TYPE_STATIC_bool],
101
+ [protocol_1.MODULES.demand, 'guard', 6, [], protocol_1.ValueType.TYPE_STATIC_address],
102
+ [protocol_1.MODULES.demand, 'has_yes', 7, [], protocol_1.ValueType.TYPE_STATIC_bool],
103
+ [protocol_1.MODULES.demand, 'yes', 8, [], protocol_1.ValueType.TYPE_STATIC_address],
104
+ [protocol_1.MODULES.demand, 'presenters_count', 9, [], protocol_1.ValueType.TYPE_STATIC_u64],
105
+ [protocol_1.MODULES.demand, 'has_presenter', 10, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
106
+ [protocol_1.MODULES.demand, 'persenter', 11, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_address],
107
+ [protocol_1.MODULES.order, 'amount', 1, [], protocol_1.ValueType.TYPE_STATIC_u64],
108
+ [protocol_1.MODULES.order, 'payer', 2, [], protocol_1.ValueType.TYPE_STATIC_address],
109
+ [protocol_1.MODULES.order, 'service', 3, [], protocol_1.ValueType.TYPE_STATIC_address],
110
+ [protocol_1.MODULES.order, 'has_progress', 4, [], protocol_1.ValueType.TYPE_STATIC_bool],
111
+ [protocol_1.MODULES.order, 'progress', 5, [], protocol_1.ValueType.TYPE_STATIC_address],
112
+ [protocol_1.MODULES.order, 'has_requred_info', 6, [], protocol_1.ValueType.TYPE_STATIC_bool],
113
+ [protocol_1.MODULES.order, 'requred_info_service_pubkey', 7, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
114
+ [protocol_1.MODULES.order, 'requred_info_customer_pubkey', 8, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
115
+ [protocol_1.MODULES.order, 'requred_info_info', 9, [], protocol_1.ValueType.TYPE_STATIC_vec_vec_u8],
116
+ [protocol_1.MODULES.order, 'has_discount', 10, [], protocol_1.ValueType.TYPE_STATIC_bool],
117
+ [protocol_1.MODULES.order, 'discount', 11, [], protocol_1.ValueType.TYPE_STATIC_address],
118
+ [protocol_1.MODULES.order, 'balance', 12, [], protocol_1.ValueType.TYPE_STATIC_u64],
119
+ [protocol_1.MODULES.order, 'bRefunded', 13, [], protocol_1.ValueType.TYPE_STATIC_u8],
120
+ [protocol_1.MODULES.order, 'bWithdrawed', 14, [], protocol_1.ValueType.TYPE_STATIC_u8],
121
+ [protocol_1.MODULES.service, 'permission', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
122
+ [protocol_1.MODULES.service, 'payee', 2, [], protocol_1.ValueType.TYPE_STATIC_address],
123
+ [protocol_1.MODULES.service, 'has_buy_guard', 3, [], protocol_1.ValueType.TYPE_STATIC_bool],
124
+ [protocol_1.MODULES.service, 'buy_guard', 4, [], protocol_1.ValueType.TYPE_STATIC_address],
125
+ [protocol_1.MODULES.service, 'repository_contains', 5, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
126
+ [protocol_1.MODULES.service, 'has_withdraw_guard', 6, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
127
+ [protocol_1.MODULES.service, 'withdraw_guard_percent', 7, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
128
+ [protocol_1.MODULES.service, 'has_refund_guard', 8, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
129
+ [protocol_1.MODULES.service, 'refund_guard_percent', 9, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
130
+ [protocol_1.MODULES.service, 'has_sale', 10, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_bool],
131
+ [protocol_1.MODULES.service, 'sale_price', 11, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_u64],
132
+ [protocol_1.MODULES.service, 'sale_stock', 12, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_u64],
133
+ [protocol_1.MODULES.service, 'has_machine', 13, [], protocol_1.ValueType.TYPE_STATIC_bool],
134
+ [protocol_1.MODULES.service, 'machine', 14, [], protocol_1.ValueType.TYPE_STATIC_address],
135
+ [protocol_1.MODULES.service, 'bPaused', 15, [], protocol_1.ValueType.TYPE_STATIC_bool],
136
+ [protocol_1.MODULES.service, 'bPublished', 16, [], protocol_1.ValueType.TYPE_STATIC_bool],
137
+ [protocol_1.MODULES.service, 'has_required', 17, [], protocol_1.ValueType.TYPE_STATIC_bool],
138
+ [protocol_1.MODULES.service, 'requrired_pubkey', 18, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
139
+ [protocol_1.MODULES.service, 'requrired_info', 19, [], protocol_1.ValueType.TYPE_STATIC_vec_vec_u8],
140
+ [protocol_1.MODULES.reward, 'permission', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
141
+ [protocol_1.MODULES.reward, 'rewards_count_remain', 2, [], protocol_1.ValueType.TYPE_STATIC_u64],
142
+ [protocol_1.MODULES.reward, 'rewards_count_supplied', 3, [], protocol_1.ValueType.TYPE_STATIC_u64],
143
+ [protocol_1.MODULES.reward, 'guard_count', 4, [], protocol_1.ValueType.TYPE_STATIC_u64],
144
+ [protocol_1.MODULES.reward, 'has_guard', 5, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
145
+ [protocol_1.MODULES.reward, 'guard_portions', 6, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
146
+ [protocol_1.MODULES.reward, 'time_expire', 7, [], protocol_1.ValueType.TYPE_STATIC_u64],
147
+ [protocol_1.MODULES.reward, 'has_claimed', 8, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
148
+ [protocol_1.MODULES.reward, 'claimed', 9, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
149
+ [protocol_1.MODULES.reward, 'has_claimed_count', 10, [], protocol_1.ValueType.TYPE_STATIC_u64],
150
+ [protocol_1.MODULES.reward, 'is_sponsor', 11, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
151
+ [protocol_1.MODULES.reward, 'sponsor', 12, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
152
+ [protocol_1.MODULES.reward, 'sponsor_count', 13, [], protocol_1.ValueType.TYPE_STATIC_u64],
153
+ [protocol_1.MODULES.reward, 'bAllowRepeatClaim', 14, [], protocol_1.ValueType.TYPE_STATIC_bool],
154
+ [protocol_1.MODULES.vote, 'permission', 1, [], protocol_1.ValueType.TYPE_STATIC_address],
155
+ [protocol_1.MODULES.vote, 'bOptions_locked_for_voting', 2, [], protocol_1.ValueType.TYPE_STATIC_bool],
156
+ [protocol_1.MODULES.vote, 'bdeadline_locked', 3, [], protocol_1.ValueType.TYPE_STATIC_bool],
157
+ [protocol_1.MODULES.vote, 'bLockedGuard', 4, [], protocol_1.ValueType.TYPE_STATIC_bool],
158
+ [protocol_1.MODULES.vote, 'max_choice_count', 5, [], protocol_1.ValueType.TYPE_STATIC_u8],
159
+ [protocol_1.MODULES.vote, 'deadline', 6, [], protocol_1.ValueType.TYPE_STATIC_u64],
160
+ [protocol_1.MODULES.vote, 'has_reference', 7, [], protocol_1.ValueType.TYPE_STATIC_bool],
161
+ [protocol_1.MODULES.vote, 'reference', 8, [], protocol_1.ValueType.TYPE_STATIC_address],
162
+ [protocol_1.MODULES.vote, 'has_guard', 9, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
163
+ [protocol_1.MODULES.vote, 'guard', 10, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
164
+ [protocol_1.MODULES.vote, 'voted', 11, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_bool],
165
+ [protocol_1.MODULES.vote, 'voted_weight', 12, [protocol_1.ValueType.TYPE_STATIC_address], protocol_1.ValueType.TYPE_STATIC_u64],
166
+ [protocol_1.MODULES.vote, 'has_agree', 13, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_bool],
167
+ [protocol_1.MODULES.vote, 'agree_has_object', 14, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_bool],
168
+ [protocol_1.MODULES.vote, 'agree_object', 15, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_address],
169
+ [protocol_1.MODULES.vote, 'agree_count', 16, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_u64],
170
+ [protocol_1.MODULES.vote, 'agree_votes', 17, [protocol_1.ValueType.TYPE_STATIC_vec_u8], protocol_1.ValueType.TYPE_STATIC_u64],
171
+ [protocol_1.MODULES.vote, 'voted_count', 18, [], protocol_1.ValueType.TYPE_STATIC_u64],
172
+ [protocol_1.MODULES.vote, 'top1_name_by_count', 19, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
173
+ [protocol_1.MODULES.vote, 'top1_count', 20, [], protocol_1.ValueType.TYPE_STATIC_u64],
174
+ [protocol_1.MODULES.vote, 'top1_name_by_votes', 21, [], protocol_1.ValueType.TYPE_STATIC_vec_u8],
175
+ [protocol_1.MODULES.vote, 'top1_votes', 22, [], protocol_1.ValueType.TYPE_STATIC_u64],
69
176
  ];
70
177
  class SenseMaker {
71
178
  data = [];
@@ -97,7 +204,7 @@ class SenseMaker {
97
204
  break;
98
205
  case protocol_1.ValueType.TYPE_STATIC_vec_u8:
99
206
  this.data.push(bcs.ser(bcs_1.BCS.U8, type).toBytes());
100
- this.data.push(bcs.ser("vector<u8>", param).toBytes());
207
+ this.data.push(bcs.ser(bcs_1.BCS.STRING, param).toBytes());
101
208
  this.type_validator.push(type);
102
209
  // this.data[this.data.length-1].forEach((item : number) => console.log(item))
103
210
  break;
@@ -119,24 +226,34 @@ class SenseMaker {
119
226
  ;
120
227
  return true;
121
228
  }
122
- add_cmd(object_address, sense_index) {
123
- if (!object_address || sense_index >= exports.Sense_Cmd.length) {
229
+ query_index(module, query_name) {
230
+ for (let i = 0; i < exports.QUERIES.length; i++) {
231
+ if (exports.QUERIES[i][0] == module && exports.QUERIES[i][1] == query_name) {
232
+ return i;
233
+ }
234
+ }
235
+ return -1;
236
+ }
237
+ // query_index: index(from 0) of array QUERIES
238
+ add_query(object_address, module, query_name) {
239
+ let query_index = this.query_index(module, query_name);
240
+ if (!object_address || query_index == -1) {
124
241
  return false;
125
242
  }
126
- let offset = this.type_validator.length - exports.Sense_Cmd[sense_index][3].length;
243
+ let offset = this.type_validator.length - exports.QUERIES[query_index][3].length;
127
244
  if (offset < 0) {
128
245
  return false;
129
246
  }
130
247
  let types = this.type_validator.slice(offset);
131
- if (!(0, util_1.array_equal)(types, exports.Sense_Cmd[sense_index][3])) { // type validate
248
+ if (!(0, util_1.array_equal)(types, exports.QUERIES[query_index][3])) { // type validate
132
249
  return false;
133
250
  }
134
251
  const bcs = new bcs_1.BCS((0, bcs_1.getSuiMoveConfig)());
135
252
  this.data.push(bcs.ser(bcs_1.BCS.U8, protocol_1.OperatorType.TYPE_DYNAMIC_QUERY).toBytes()); // TYPE
136
253
  this.data.push(bcs.ser(bcs_1.BCS.ADDRESS, object_address).toBytes()); // object address
137
- this.data.push(bcs.ser(bcs_1.BCS.U8, exports.Sense_Cmd[sense_index][2]).toBytes()); // cmd
138
- this.type_validator.splice(offset, exports.Sense_Cmd[sense_index][3].length); // delete type stack
139
- this.type_validator.push(exports.Sense_Cmd[sense_index][4]); // add the return value type to type stack
254
+ this.data.push(bcs.ser(bcs_1.BCS.U8, exports.QUERIES[query_index][2]).toBytes()); // cmd
255
+ this.type_validator.splice(offset, exports.QUERIES[query_index][3].length); // delete type stack
256
+ this.type_validator.push(exports.QUERIES[query_index][4]); // add the return value type to type stack
140
257
  // console.log(this.type_validator)
141
258
  return true;
142
259
  }
@@ -172,10 +289,11 @@ class SenseMaker {
172
289
  this.type_validator.push(protocol_1.ValueType.TYPE_STATIC_bool); // add bool to type stack
173
290
  return true;
174
291
  }
175
- make(bNotAfterSense, binder) {
292
+ make(bNotAfterSense = false, binder = Guard_Sense_Binder.AND) {
176
293
  //console.log(this.type_validator);
177
294
  //this.data.forEach((value:Uint8Array) => console.log(value));
178
295
  if (this.type_validator.length != 1 || this.type_validator[0] != protocol_1.ValueType.TYPE_STATIC_bool) {
296
+ // console.log(this.type_validator)
179
297
  return false;
180
298
  } // ERROR
181
299
  let input = (0, util_1.concatenate)(Uint8Array, ...this.data);
@@ -185,21 +303,31 @@ class SenseMaker {
185
303
  }
186
304
  exports.SenseMaker = SenseMaker;
187
305
  function match_u128(type) {
188
- if (type == protocol_1.ValueType.TYPE_STATIC_option_u8 ||
189
- type == protocol_1.ValueType.TYPE_STATIC_option_u64 ||
190
- type == protocol_1.ValueType.TYPE_STATIC_option_u128) {
306
+ if (type == protocol_1.ValueType.TYPE_STATIC_u8 ||
307
+ type == protocol_1.ValueType.TYPE_STATIC_u64 ||
308
+ type == protocol_1.ValueType.TYPE_STATIC_u128) {
191
309
  return true;
192
310
  }
193
311
  return false;
194
312
  }
313
+ function parse_graphql_senses(senses) {
314
+ let objects = [];
315
+ senses.forEach((s) => {
316
+ let res = parse_sense_bsc(Uint8Array.from(s.input.bytes));
317
+ if (res) {
318
+ objects = objects.concat(res);
319
+ }
320
+ });
321
+ return (0, util_1.array_unique)(objects);
322
+ }
323
+ exports.parse_graphql_senses = parse_graphql_senses;
195
324
  // parse guard senses input bytes of a guard, return [objectids] for 'query_cmd'
196
325
  function parse_sense_bsc(chain_sense_bsc) {
197
- // console.log(data);
198
- var array = [].slice.call(chain_sense_bsc.reverse());
326
+ var arr = [].slice.call(chain_sense_bsc.reverse());
199
327
  const bcs = new bcs_1.BCS((0, bcs_1.getSuiMoveConfig)());
200
328
  var result = [];
201
- while (array.length > 0) {
202
- var type = array.shift();
329
+ while (arr.length > 0) {
330
+ var type = arr.shift();
203
331
  // console.log(type);
204
332
  switch (type) {
205
333
  case protocol_1.ContextType.TYPE_CONTEXT_SIGNER:
@@ -212,42 +340,44 @@ function parse_sense_bsc(chain_sense_bsc) {
212
340
  case protocol_1.OperatorType.TYPE_LOGIC_OPERATOR_U128_EQUAL:
213
341
  case protocol_1.OperatorType.TYPE_LOGIC_OPERATOR_EQUAL:
214
342
  case protocol_1.OperatorType.TYPE_LOGIC_OPERATOR_HAS_SUBSTRING:
343
+ case protocol_1.OperatorType.TYPE_LOGIC_ALWAYS_TRUE:
215
344
  break;
216
345
  case protocol_1.ValueType.TYPE_STATIC_address:
217
346
  //console.log('0x' + bcs.de(BCS.ADDRESS, Uint8Array.from(array)).toString());
218
- array.splice(0, 32);
347
+ arr.splice(0, 32);
219
348
  break;
220
349
  case protocol_1.ValueType.TYPE_STATIC_bool:
221
350
  case protocol_1.ValueType.TYPE_STATIC_u8:
222
- array.splice(0, 1);
351
+ arr.splice(0, 1);
223
352
  break;
224
353
  case protocol_1.ValueType.TYPE_STATIC_u64:
225
- array.splice(0, 8);
354
+ arr.splice(0, 8);
226
355
  break;
227
356
  case protocol_1.ValueType.TYPE_STATIC_u128:
228
- array.splice(0, 16);
357
+ arr.splice(0, 16);
229
358
  break;
230
359
  case protocol_1.ValueType.TYPE_STATIC_vec_u8:
231
- let { value, length } = (0, util_1.ulebDecode)(Uint8Array.from(array));
232
- array.splice(0, value + length);
360
+ let { value, length } = (0, util_1.ulebDecode)(Uint8Array.from(arr));
361
+ arr.splice(0, value + length);
233
362
  break;
234
363
  case protocol_1.OperatorType.TYPE_DYNAMIC_QUERY:
235
- result.push('0x' + bcs.de(bcs_1.BCS.ADDRESS, Uint8Array.from(array)).toString());
236
- array.splice(0, 33); // address + cmd
364
+ result.push('0x' + bcs.de(bcs_1.BCS.ADDRESS, Uint8Array.from(arr)).toString());
365
+ arr.splice(0, 33); // address + cmd
237
366
  break;
238
367
  default:
239
- // console.log('parse_sense_bsc:undefined');
368
+ console.error('parse_sense_bsc:undefined');
369
+ console.log(type);
370
+ console.log(arr);
240
371
  return false; // error
241
372
  }
242
373
  }
243
374
  return result;
244
375
  }
245
376
  exports.parse_sense_bsc = parse_sense_bsc;
246
- const MODULE_GUARD_INDEX = 7;
247
- const description_fn = (response, param, option) => {
377
+ const rpc_description_fn = (response, param, option) => {
248
378
  if (!response.error) {
249
379
  let c = response?.data?.content;
250
- if (c.type == protocol_1.OBJECTS_TYPE[MODULE_GUARD_INDEX] && c.fields.id.id == param.objectid) { // GUARD OBJECT
380
+ if ((0, protocol_1.OBJECTS_TYPE)().find((v) => (v == c.type)) && c.fields.id.id == param.objectid) { // GUARD OBJECT
251
381
  let description = c.fields.description;
252
382
  if (!param.data.includes(description)) {
253
383
  param.data.push(description);
@@ -255,19 +385,23 @@ const description_fn = (response, param, option) => {
255
385
  }
256
386
  }
257
387
  };
258
- exports.description_fn = description_fn;
259
- const sense_objects_fn = (response, param, option) => {
388
+ exports.rpc_description_fn = rpc_description_fn;
389
+ const rpc_sense_objects_fn = (response, param, option) => {
260
390
  if (!response.error) {
261
391
  let c = response?.data?.content;
262
- if (c.type == protocol_1.OBJECTS_TYPE[MODULE_GUARD_INDEX] && c.fields.id.id == param.objectid) { // GUARD OBJECT
392
+ let index = (0, protocol_1.OBJECTS_TYPE)().findIndex(v => v.includes('guard::Guard') && v == c.type);
393
+ if (index >= 0 && c.fields.id.id == param.objectid) { // GUARD OBJECT
263
394
  for (let i = 0; i < c.fields.senses.length; i++) {
264
395
  let sense = c.fields.senses[i];
265
- if (sense.type == (protocol_1.OBJECTS_TYPE_PREFIX[MODULE_GUARD_INDEX] + 'Sense')) { // ...::guard::Sense
266
- let ids = parse_sense_bsc(Uint8Array.from(sense.fields.input.fields.bytes));
267
- param.data = (0, util_1.array_unique)(param.data.concat(ids));
396
+ if (sense.type == ((0, protocol_1.OBJECTS_TYPE_PREFIX)()[index] + 'Sense')) { // ...::guard::Sense
397
+ let res = parse_sense_bsc(Uint8Array.from(sense.fields.input.fields.bytes));
398
+ if (res) {
399
+ let ids = res;
400
+ param.data = param.data.concat(ids); // DONT array_unique senses
401
+ }
268
402
  }
269
403
  }
270
404
  }
271
405
  }
272
406
  };
273
- exports.sense_objects_fn = sense_objects_fn;
407
+ exports.rpc_sense_objects_fn = rpc_sense_objects_fn;
package/dist/index.js CHANGED
@@ -1 +1,47 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.machine_destroy = exports.machine_launch = exports.machine_set_endpoint = exports.machine_set_description = exports.machine_remove_repository = exports.machine_remove_node = exports.machine_publish = exports.machine_pause = exports.machine_clone = exports.machine_add_repository = exports.machine_add_node2 = exports.machine_add_node = exports.machine = exports.MAX_PRESENTERS_COUNT = exports.MAX_EARNEST_COUNT = exports.demand_change_permission = exports.present = exports.demand_launch = exports.demand_destroy = exports.demand_deposit = exports.demand_yes = exports.demand_set_guard = exports.demand_set_description = exports.demand_refund = exports.demand_expand_time = exports.demand = void 0;
18
+ __exportStar(require("./protocol"), exports);
19
+ var demand_1 = require("./demand");
20
+ Object.defineProperty(exports, "demand", { enumerable: true, get: function () { return demand_1.demand; } });
21
+ Object.defineProperty(exports, "demand_expand_time", { enumerable: true, get: function () { return demand_1.demand_expand_time; } });
22
+ Object.defineProperty(exports, "demand_refund", { enumerable: true, get: function () { return demand_1.demand_refund; } });
23
+ Object.defineProperty(exports, "demand_set_description", { enumerable: true, get: function () { return demand_1.demand_set_description; } });
24
+ Object.defineProperty(exports, "demand_set_guard", { enumerable: true, get: function () { return demand_1.demand_set_guard; } });
25
+ Object.defineProperty(exports, "demand_yes", { enumerable: true, get: function () { return demand_1.demand_yes; } });
26
+ Object.defineProperty(exports, "demand_deposit", { enumerable: true, get: function () { return demand_1.deposit; } });
27
+ Object.defineProperty(exports, "demand_destroy", { enumerable: true, get: function () { return demand_1.destroy; } });
28
+ Object.defineProperty(exports, "demand_launch", { enumerable: true, get: function () { return demand_1.launch; } });
29
+ Object.defineProperty(exports, "present", { enumerable: true, get: function () { return demand_1.present; } });
30
+ Object.defineProperty(exports, "demand_change_permission", { enumerable: true, get: function () { return demand_1.change_permission; } });
31
+ Object.defineProperty(exports, "MAX_EARNEST_COUNT", { enumerable: true, get: function () { return demand_1.MAX_EARNEST_COUNT; } });
32
+ Object.defineProperty(exports, "MAX_PRESENTERS_COUNT", { enumerable: true, get: function () { return demand_1.MAX_PRESENTERS_COUNT; } });
33
+ var machine_1 = require("./machine");
34
+ Object.defineProperty(exports, "machine", { enumerable: true, get: function () { return machine_1.machine; } });
35
+ Object.defineProperty(exports, "machine_add_node", { enumerable: true, get: function () { return machine_1.machine_add_node; } });
36
+ Object.defineProperty(exports, "machine_add_node2", { enumerable: true, get: function () { return machine_1.machine_add_node2; } });
37
+ Object.defineProperty(exports, "machine_add_repository", { enumerable: true, get: function () { return machine_1.machine_add_repository; } });
38
+ Object.defineProperty(exports, "machine_clone", { enumerable: true, get: function () { return machine_1.machine_clone; } });
39
+ Object.defineProperty(exports, "machine_pause", { enumerable: true, get: function () { return machine_1.machine_pause; } });
40
+ Object.defineProperty(exports, "machine_publish", { enumerable: true, get: function () { return machine_1.machine_publish; } });
41
+ Object.defineProperty(exports, "machine_remove_node", { enumerable: true, get: function () { return machine_1.machine_remove_node; } });
42
+ Object.defineProperty(exports, "machine_remove_repository", { enumerable: true, get: function () { return machine_1.machine_remove_repository; } });
43
+ Object.defineProperty(exports, "machine_set_description", { enumerable: true, get: function () { return machine_1.machine_set_description; } });
44
+ Object.defineProperty(exports, "machine_set_endpoint", { enumerable: true, get: function () { return machine_1.machine_set_endpoint; } });
45
+ Object.defineProperty(exports, "machine_launch", { enumerable: true, get: function () { return machine_1.launch; } });
46
+ Object.defineProperty(exports, "machine_destroy", { enumerable: true, get: function () { return machine_1.destroy; } });
47
+ __exportStar(require("./passport"), exports);
package/dist/machine.js CHANGED
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.change_permission = exports.machine_publish = exports.machine_pause = exports.machine_set_endpoint = exports.machine_clone = exports.machine_remove_repository = exports.machine_add_repository = exports.machine_set_description = exports.launch = exports.destroy = exports.machine = exports.machine_remove_node = exports.machine_add_node2 = exports.machine_add_node = exports.INITIAL_NODE_NAME = void 0;
3
+ exports.change_permission = exports.machine_publish = exports.machine_pause = exports.machine_set_endpoint = exports.machine_clone = exports.machine_remove_repository = exports.machine_add_repository = exports.machine_set_description = exports.launch = exports.destroy = exports.machine = exports.machine_remove_node = exports.machine_add_node2 = exports.machine_add_node = exports.namedOperator_ORDER_PAYER = exports.INITIAL_NODE_NAME = void 0;
4
+ const bcs_1 = require("@mysten/bcs");
4
5
  const protocol_1 = require("./protocol");
5
6
  const util_1 = require("./util");
6
7
  const permission_1 = require("./permission");
7
8
  exports.INITIAL_NODE_NAME = '';
8
- // 创建新的node加入到machine
9
+ exports.namedOperator_ORDER_PAYER = 'order payer';
10
+ // create new nodes for machine
9
11
  function machine_add_node(txb, machine, permission, nodes, passport) {
10
12
  if (!(0, protocol_1.IsValidObjects)([machine, permission]))
11
13
  return false;
@@ -78,29 +80,33 @@ function machine_add_node(txb, machine, permission, nodes, passport) {
78
80
  return machine_add_node2(txb, machine, permission, new_nodes, passport);
79
81
  }
80
82
  exports.machine_add_node = machine_add_node;
81
- // 把个人拥有的node加入到machine
83
+ // move MachineNodeObject to the machine from signer-owned MachineNode object
82
84
  function machine_add_node2(txb, machine, permission, nodes, passport) {
83
85
  if (!(0, protocol_1.IsValidObjects)([machine, permission]))
84
86
  return false;
85
87
  if (!nodes)
86
88
  return false;
89
+ let n = [];
90
+ (0, util_1.array_unique)(nodes).forEach((v) => {
91
+ n.push((0, protocol_1.TXB_OBJECT)(txb, v));
92
+ });
87
93
  if (passport) {
88
94
  txb.moveCall({
89
95
  target: protocol_1.PROTOCOL.MachineFn('node_add_with_passport'),
90
- arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, machine), txb.makeMoveVec({ objects: nodes }), (0, protocol_1.TXB_OBJECT)(txb, permission)]
96
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, machine), txb.makeMoveVec({ objects: n }), (0, protocol_1.TXB_OBJECT)(txb, permission)]
91
97
  });
92
98
  }
93
99
  else {
94
100
  txb.moveCall({
95
101
  target: protocol_1.PROTOCOL.MachineFn('node_add'),
96
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, machine), txb.makeMoveVec({ objects: nodes }), (0, protocol_1.TXB_OBJECT)(txb, permission)]
102
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, machine), txb.makeMoveVec({ objects: n }), (0, protocol_1.TXB_OBJECT)(txb, permission)]
97
103
  });
98
104
  }
99
105
  return true;
100
106
  }
101
107
  exports.machine_add_node2 = machine_add_node2;
102
- // machine把node移动到个人地址
103
- function machine_remove_node(txb, machine, permission, nodes_name, passport) {
108
+ // move MachineNodeObject from machine to signer-owned MachineNode object
109
+ function machine_remove_node(txb, machine, permission, nodes_name, bTransferMyself = false, passport) {
104
110
  if (!(0, protocol_1.IsValidObjects)([machine, permission]))
105
111
  return false;
106
112
  if (!nodes_name || !(0, protocol_1.IsValidArray)(nodes_name, protocol_1.IsValidName))
@@ -108,13 +114,14 @@ function machine_remove_node(txb, machine, permission, nodes_name, passport) {
108
114
  if (passport) {
109
115
  txb.moveCall({
110
116
  target: protocol_1.PROTOCOL.MachineFn('node_remove_with_passport'),
111
- arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(util_1.BCS_CONVERT.ser_vector_string(nodes_name)), permission],
117
+ arguments: [passport, (0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(util_1.BCS_CONVERT.ser_vector_string(nodes_name)),
118
+ txb.pure(bTransferMyself, bcs_1.BCS.BOOL), (0, protocol_1.TXB_OBJECT)(txb, permission)],
112
119
  });
113
120
  }
114
121
  else {
115
122
  txb.moveCall({
116
123
  target: protocol_1.PROTOCOL.MachineFn('node_remove'),
117
- arguments: [(0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(util_1.BCS_CONVERT.ser_vector_string(nodes_name)), permission],
124
+ arguments: [(0, protocol_1.TXB_OBJECT)(txb, machine), txb.pure(util_1.BCS_CONVERT.ser_vector_string(nodes_name)), txb.pure(bTransferMyself, bcs_1.BCS.BOOL), (0, protocol_1.TXB_OBJECT)(txb, permission)],
118
125
  });
119
126
  }
120
127
  return true;
@@ -123,7 +130,7 @@ exports.machine_remove_node = machine_remove_node;
123
130
  function machine(txb, permission, description, endpoint, passport) {
124
131
  if (!(0, protocol_1.IsValidObjects)([permission]))
125
132
  return false;
126
- if ((0, protocol_1.IsValidDesription)(description))
133
+ if (!(0, protocol_1.IsValidDesription)(description))
127
134
  return false;
128
135
  if (endpoint && !(0, protocol_1.IsValidEndpoint)(endpoint))
129
136
  return false;