wowok 1.4.18 → 1.4.20
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 +1 -1
- package/src/guard.ts +215 -282
- package/src/passport.ts +276 -417
- package/src/permission.ts +8 -0
- package/src/progress.ts +8 -8
- package/src/protocol.ts +9 -8
- package/src/utils.ts +2 -4
package/src/guard.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import { Protocol, LogicsInfo, GuardAddress, FnCallType, Data_Type, MODULES, ContextType, ValueType, OperatorType,
|
|
3
|
+
import { Protocol, LogicsInfo, GuardAddress, FnCallType, Data_Type, MODULES, ContextType, ValueType, OperatorType, SER_VALUE} from './protocol';
|
|
4
4
|
import { concatenate, array_equal } from './utils';
|
|
5
5
|
import { IsValidDesription, Bcs, IsValidInt, IsValidAddress, FirstLetterUppercase, insertAtHead } from './utils';
|
|
6
6
|
import { ERROR, Errors } from './exception';
|
|
@@ -9,9 +9,9 @@ import { Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
|
9
9
|
export type GuardConstant = Map<number, Guard_Variable>;
|
|
10
10
|
|
|
11
11
|
export interface Guard_Variable {
|
|
12
|
-
type:
|
|
12
|
+
type: ValueType ,
|
|
13
13
|
value?: Uint8Array,
|
|
14
|
-
|
|
14
|
+
bWitness : boolean,
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface Guard_Options {
|
|
@@ -39,8 +39,9 @@ export class Guard {
|
|
|
39
39
|
|
|
40
40
|
let bValid = true;
|
|
41
41
|
constants?.forEach((v, k) => {
|
|
42
|
-
if (!
|
|
43
|
-
if (
|
|
42
|
+
if (!GuardMaker.IsValidIndentifier(k)) bValid = false;
|
|
43
|
+
if (v.value && v.bWitness) bValid = false;
|
|
44
|
+
if (v.value === undefined && !v.bWitness) bValid = false;
|
|
44
45
|
})
|
|
45
46
|
if (!bValid) {
|
|
46
47
|
ERROR(Errors.InvalidParam, 'launch constants')
|
|
@@ -55,23 +56,17 @@ export class Guard {
|
|
|
55
56
|
});
|
|
56
57
|
|
|
57
58
|
constants?.forEach((v, k) => {
|
|
58
|
-
if (v.
|
|
59
|
-
|
|
60
|
-
ERROR(Errors.InvalidParam, 'constants type')
|
|
61
|
-
}
|
|
62
|
-
const n = insertAtHead(v.witness!, v.type);
|
|
59
|
+
if (v.bWitness) {
|
|
60
|
+
const n = new Uint8Array(1); n.set([v.type], 0);
|
|
63
61
|
txb.moveCall({
|
|
64
62
|
target:Protocol.Instance().GuardFn("constant_add") as FnCallType,
|
|
65
|
-
arguments:[guard, txb.pure.u8(k), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(true)]
|
|
66
|
-
})
|
|
63
|
+
arguments:[guard, txb.pure.u8(k), txb.pure.bool(true), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(true)]
|
|
64
|
+
})
|
|
67
65
|
} else {
|
|
68
|
-
if (!v.value) {
|
|
69
|
-
ERROR(Errors.InvalidParam, 'constants type')
|
|
70
|
-
}
|
|
71
66
|
const n = insertAtHead(v.value!, v.type);
|
|
72
67
|
txb.moveCall({
|
|
73
68
|
target:Protocol.Instance().GuardFn("constant_add") as FnCallType,
|
|
74
|
-
arguments:[guard, txb.pure.u8(k), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(true)]
|
|
69
|
+
arguments:[guard, txb.pure.u8(k), txb.pure.bool(false), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(true)]
|
|
75
70
|
})
|
|
76
71
|
}
|
|
77
72
|
});
|
|
@@ -95,7 +90,6 @@ export class Guard {
|
|
|
95
90
|
arguments: []
|
|
96
91
|
});
|
|
97
92
|
}
|
|
98
|
-
|
|
99
93
|
static QUERIES:any[] = [
|
|
100
94
|
// module, 'name', 'id', [input], output
|
|
101
95
|
[MODULES.permission, 'Owner', 1, [], ValueType.TYPE_ADDRESS, "Owner's address."],
|
|
@@ -108,126 +102,182 @@ export class Guard {
|
|
|
108
102
|
[MODULES.permission, 'Number of Entities', 8, [], ValueType.TYPE_U64, 'Number of entities in the personnel permission table.'],
|
|
109
103
|
[MODULES.permission, 'Number of Admin', 9, [], ValueType.TYPE_U64, 'Number of administrators.'],
|
|
110
104
|
|
|
111
|
-
[MODULES.repository, 'Permission',
|
|
112
|
-
[MODULES.repository, 'Contains Policy',
|
|
113
|
-
[MODULES.repository, 'Is Permission set of Policy',
|
|
114
|
-
[MODULES.repository, 'Permission of Policy',
|
|
115
|
-
[MODULES.repository, 'Value Type of Policy',
|
|
116
|
-
[MODULES.repository, 'Contains Data for An Address',
|
|
117
|
-
[MODULES.repository, 'Contains Data',
|
|
118
|
-
[MODULES.repository, 'Raw data without Type',
|
|
119
|
-
[MODULES.repository, 'Raw data',
|
|
120
|
-
[MODULES.repository, 'Type',
|
|
121
|
-
[MODULES.repository, 'Policy Mode',
|
|
122
|
-
[MODULES.repository, 'Reference Count',
|
|
123
|
-
[MODULES.repository, 'Is Referenced by An Object',
|
|
124
|
-
[MODULES.repository, 'Data
|
|
125
|
-
[MODULES.repository, 'Data
|
|
126
|
-
[MODULES.repository, 'Data
|
|
127
|
-
[MODULES.repository, 'Data
|
|
128
|
-
[MODULES.repository, '
|
|
129
|
-
[MODULES.repository, '
|
|
130
|
-
[MODULES.repository, '
|
|
131
|
-
[MODULES.repository, '
|
|
132
|
-
|
|
105
|
+
[MODULES.repository, 'Permission', 100, [], ValueType.TYPE_ADDRESS, 'Permission object address.'],
|
|
106
|
+
[MODULES.repository, 'Contains Policy', 101, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Is a consensus policy included?', 'Input:the filed name'],
|
|
107
|
+
[MODULES.repository, 'Is Permission set of Policy', 102, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Does a certain consensus policy set data operation permissions?', 'Input:the policy name'],
|
|
108
|
+
[MODULES.repository, 'Permission of Policy', 103, [ValueType.TYPE_STRING], ValueType.TYPE_U64, 'The permission index of a certain consensus policy in the Permission object.', 'Input:the policy name'],
|
|
109
|
+
[MODULES.repository, 'Value Type of Policy', 104, [ValueType.TYPE_STRING], ValueType.TYPE_U8, 'Data types defined by consensus policy.', 'Input:the policy name'],
|
|
110
|
+
[MODULES.repository, 'Contains Data for An Address', 105, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether data exists at a certain address?', 'Input:address'],
|
|
111
|
+
[MODULES.repository, 'Contains Data', 106, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Does it contain data for a certain field of an address?', 'Input 1:address, Input 2:the field name'],
|
|
112
|
+
[MODULES.repository, 'Raw data without Type', 107, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_VEC_U8, 'Data for a field at an address and does not contain data type information.', 'Input 1:address, Input 2:the field name'],
|
|
113
|
+
[MODULES.repository, 'Raw data', 108, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_VEC_U8, 'Data for a field at an address, and the first byte contains data type information.', 'Input 1:address, Input 2:the field name'],
|
|
114
|
+
[MODULES.repository, 'Type', 109, [], ValueType.TYPE_U8, 'The repository Type. 0: Normal; 1: Wowok greenee.'],
|
|
115
|
+
[MODULES.repository, 'Policy Mode', 110, [], ValueType.TYPE_U8, 'Policy Mode. 0: Free mode; 1: Strict mode.'],
|
|
116
|
+
[MODULES.repository, 'Reference Count', 111, [], ValueType.TYPE_U64, 'The number of times it is referenced by other objects.'],
|
|
117
|
+
[MODULES.repository, 'Is Referenced by An Object', 112, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Is it referenced by an object?', 'Input:address'],
|
|
118
|
+
[MODULES.repository, 'Number Data', 113, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_U256, 'Data for a field at an address and get unsigned integer type data.', 'Input 1:address, Input 2:the field name'],
|
|
119
|
+
[MODULES.repository, 'String Data', 114, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_STRING, 'Data for a field at an address and get string type data.', 'Input 1:address, Input 2:the field name'],
|
|
120
|
+
[MODULES.repository, 'Address Data', 115, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'Data for a field at an address and get address type data.', 'Input 1:address, Input 2:the field name'],
|
|
121
|
+
[MODULES.repository, 'Bool Data', 116, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Data for a field at an address and get bool type data.', 'Input 1:address, Input 2:the field name'],
|
|
122
|
+
[MODULES.repository, 'Number Vector Data', 117, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_VEC_U256, 'Data for a field at an address and get unsigned integer vector type data.', 'Input 1:address, Input 2:the field name'],
|
|
123
|
+
[MODULES.repository, 'String Vector Data', 118, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_VEC_STRING, 'Data for a field at an address and get string vector type data.', 'Input 1:address, Input 2:the field name'],
|
|
124
|
+
[MODULES.repository, 'Address Vector Data', 119, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_VEC_ADDRESS, 'Data for a field at an address and get address vector type data.', 'Input 1:address, Input 2:the field name'],
|
|
125
|
+
[MODULES.repository, 'Bool Vector Data', 120, [ValueType.TYPE_ADDRESS, ValueType.TYPE_STRING], ValueType.TYPE_VEC_BOOL, 'Data for a field at an address and get bool vector type data.', 'Input 1:address, Input 2:the field name'],
|
|
126
|
+
|
|
127
|
+
[MODULES.entity, 'Contains Entity?', 200, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Is an entity already registered?', 'Input:address'],
|
|
128
|
+
[MODULES.entity, 'Likes', 201, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The number of likes for an address by other addresses.', 'Input:address'],
|
|
129
|
+
[MODULES.entity, 'Dislikes', 202, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The number of dislikes for an address by other addresses.', 'Input:address'],
|
|
130
|
+
[MODULES.entity, 'Entity Info', 203, [ValueType.TYPE_ADDRESS], ValueType.TYPE_VEC_U8, 'Public information about an entity.', 'Input:address'],
|
|
131
|
+
[MODULES.entity, 'Has Resource by Entity?', 204, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether an entity created a resource?', 'Input:address'],
|
|
132
|
+
[MODULES.entity, 'Entity Resource', 205, [ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS, 'The address of a resource object created by an entity.', 'Input:address'],
|
|
133
|
+
|
|
134
|
+
[MODULES.demand, 'Permission', 300, [], ValueType.TYPE_ADDRESS, 'Permission object address.'],
|
|
135
|
+
[MODULES.demand, 'Has Deadline', 301, [], ValueType.TYPE_BOOL, 'Whether to set the expiration time of presenting?'],
|
|
136
|
+
[MODULES.demand, 'Deadline', 302, [], ValueType.TYPE_U64, 'The expiration time of presenting.'],
|
|
137
|
+
[MODULES.demand, 'Bounty Count', 303, [], ValueType.TYPE_U64, 'Number of Bounties.'],
|
|
138
|
+
[MODULES.demand, 'Has Guard', 304, [], ValueType.TYPE_BOOL, 'Whether the present guard is set?'],
|
|
139
|
+
[MODULES.demand, 'Guard', 305, [], ValueType.TYPE_ADDRESS, 'The present guard address.'],
|
|
140
|
+
[MODULES.demand, 'Has Service Picked', 306, [], ValueType.TYPE_BOOL, 'Whether a service has been picked and bounties given?'],
|
|
141
|
+
[MODULES.demand, 'Service Picked', 307, [], ValueType.TYPE_ADDRESS, 'Service address that has been picked.'],
|
|
142
|
+
[MODULES.demand, 'Presenter Count', 308, [], ValueType.TYPE_U64, 'Number of presenters.'],
|
|
143
|
+
[MODULES.demand, 'Has Presenter', 309, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Is a certain address a presenter?', 'Input:address'],
|
|
144
|
+
[MODULES.demand, 'Who Got Bounty', 310, [ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS, 'The address that bounties given.', 'Input:address'],
|
|
145
|
+
|
|
146
|
+
[MODULES.service, 'Permission', 400, [], ValueType.TYPE_ADDRESS, 'Permission object address.'],
|
|
147
|
+
[MODULES.service, 'Payee', 401, [], ValueType.TYPE_ADDRESS, 'Payee address, that all order withdrawals will be collected to this address.'],
|
|
148
|
+
[MODULES.service, 'Has Buying Guard', 402, [], ValueType.TYPE_BOOL, 'Is the guard condition of buying set?'],
|
|
149
|
+
[MODULES.service, 'Buying Guard', 403, [], ValueType.TYPE_ADDRESS, 'Buying guard, that Purchase only if you meet the conditions of the guard.'],
|
|
150
|
+
[MODULES.service, 'Contains Repository', 404, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, "Is a certain repository one of the service's consensus repositories?", 'Input:address'],
|
|
151
|
+
[MODULES.service, 'Has Withdrawing Guard', 405, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether a certain guard is set when withdrawing money?', 'Input:address'],
|
|
152
|
+
[MODULES.service, 'Withdrawing Guard Percent', 406, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The percentage of withdrawals allowed by a certain withdrawal guard.', 'Input:address'],
|
|
153
|
+
[MODULES.service, 'Has Refunding Guard', 407, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether a certain guard is set when refunding money?', 'Input:address'],
|
|
154
|
+
[MODULES.service, 'Refunding Guard Percent', 408, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The percentage of refund allowed by a certain refund guard.', 'Input:address'],
|
|
155
|
+
[MODULES.service, 'Has Sales Item', 409, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Is there a sales item for the service?', 'Input:the item name'],
|
|
156
|
+
[MODULES.service, 'Sale Item Price', 410, [ValueType.TYPE_STRING], ValueType.TYPE_U64, 'What is the price of a certain sale item?', 'Input:the item name'],
|
|
157
|
+
[MODULES.service, 'Sale Item Inventory', 411, [ValueType.TYPE_STRING], ValueType.TYPE_U64, 'How much inventory is there for a certain sales item?', 'Input:the item name'],
|
|
158
|
+
[MODULES.service, 'Has Machine', 412, [], ValueType.TYPE_BOOL, "Has the machine(progress generator) that serves the order been set up?"],
|
|
159
|
+
[MODULES.service, 'Machine', 413, [], ValueType.TYPE_ADDRESS, 'Machine address, that generate progresses serving the execution process of order.'],
|
|
160
|
+
[MODULES.service, 'Paused', 414, [], ValueType.TYPE_BOOL, 'Pause the creation of new order?'],
|
|
161
|
+
[MODULES.service, 'Published', 415, [], ValueType.TYPE_BOOL, 'Is it allowed to create orders?'],
|
|
162
|
+
[MODULES.service, 'Has Required Info', 416, [], ValueType.TYPE_BOOL, 'Whether the necessary information that needs to be provided by the customer is set?'],
|
|
163
|
+
[MODULES.service, 'Required Info of Service-Pubkey', 417, [], ValueType.TYPE_STRING, 'The public key used to encrypt customer information, and only the service provider can decrypt and view customer information.'],
|
|
164
|
+
[MODULES.service, 'Required Info', 418, [], ValueType.TYPE_VEC_STRING, 'Names of the required information item that needs to be provided by the customer.'],
|
|
165
|
+
|
|
166
|
+
[MODULES.order, 'Amount', 500, [], ValueType.TYPE_U64, 'Order amount.'],
|
|
167
|
+
[MODULES.order, 'Payer', 501, [], ValueType.TYPE_ADDRESS, 'Order payer.'],
|
|
168
|
+
[MODULES.order, 'Service', 502, [], ValueType.TYPE_ADDRESS, 'Service for creating orders.'],
|
|
169
|
+
[MODULES.order, 'Has Progress', 503, [], ValueType.TYPE_BOOL, 'Is there a Progress for executing the order process?'],
|
|
170
|
+
[MODULES.order, 'Progress', 504, [], ValueType.TYPE_ADDRESS, 'Progress address for executing the order process.'],
|
|
171
|
+
[MODULES.order, 'Required Info Counts', 505, [], ValueType.TYPE_U64, 'How much customer information is required for this order?'],
|
|
172
|
+
[MODULES.order, 'Discount Used', 506, [], ValueType.TYPE_BOOL, 'Discount coupon used for this order?'],
|
|
173
|
+
[MODULES.order, 'Discount', 507, [], ValueType.TYPE_ADDRESS, 'Discount address that already used.'],
|
|
174
|
+
[MODULES.order, 'Balance', 508, [], ValueType.TYPE_U64, 'The amount currently in the order.'],
|
|
175
|
+
[MODULES.order, 'Refunded', 509, [], ValueType.TYPE_BOOL, 'Whether a refund has occurred?'],
|
|
176
|
+
[MODULES.order, 'Withdrawed', 510, [], ValueType.TYPE_BOOL, 'Whether a service provider withdrawal has occurred?'],
|
|
177
|
+
|
|
178
|
+
[MODULES.reward, 'Permission', 600, [], ValueType.TYPE_ADDRESS, 'Permission object address.'],
|
|
179
|
+
[MODULES.reward, 'Rewards Remaining', 601, [], ValueType.TYPE_U64, 'Number of rewards to be claimed.'],
|
|
180
|
+
[MODULES.reward, 'Reward Count Supplied', 602, [], ValueType.TYPE_U64, 'Total rewards supplied.'],
|
|
181
|
+
[MODULES.reward, 'Guard Count', 603, [], ValueType.TYPE_U64, 'The number of claiming guards.'],
|
|
182
|
+
[MODULES.reward, 'Has Guard', 604, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether a claiming guard is set up?', 'Input:address'],
|
|
183
|
+
[MODULES.reward, 'Guard Portion', 605, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The portions of rewards, that can be claimed if a certain guard condition is met.', 'Input:address'],
|
|
184
|
+
[MODULES.reward, 'Deadline', 606, [], ValueType.TYPE_U64, 'The expiration time of claiming.'],
|
|
185
|
+
[MODULES.reward, 'Has Claimed by An Address', 607, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether a certain address has claimed rewards?', 'Input:address'],
|
|
186
|
+
[MODULES.reward, 'Portions Claimed by An Address', 608, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The portions of rewards that have been claimed by a certain address.'],
|
|
187
|
+
[MODULES.reward, 'Number of Addresses Claimed', 609, [], ValueType.TYPE_U64, 'Number of addresses that have claimed rewards.'],
|
|
188
|
+
[MODULES.reward, 'Is Sponsor', 620, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether an address is a sponsor of the reward pool?', 'Input:address'],
|
|
189
|
+
[MODULES.reward, 'Portions by A Sponsor', 611, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The portions of sponsorship reward pools for a certain address.', 'Input:address'],
|
|
190
|
+
[MODULES.reward, 'Number of Sponsors', 612, [], ValueType.TYPE_U64, 'Number of sponsors in the sponsorship reward pool.'],
|
|
191
|
+
[MODULES.reward, 'Allow Repeated Claims', 613, [], ValueType.TYPE_BOOL, 'Whether to allow repeated claims?'],
|
|
192
|
+
|
|
133
193
|
// , means that data fields and data outside the consensus policy definition are allowed to be written
|
|
134
194
|
// , means that only data fields and data defined by the consensus policy are allowed to be written.
|
|
135
|
-
[MODULES.machine, 'Permission',
|
|
136
|
-
[MODULES.machine, 'Paused',
|
|
137
|
-
[MODULES.machine, 'Published',
|
|
138
|
-
[MODULES.machine, 'Is Consensus Repository',
|
|
139
|
-
[MODULES.machine, 'Has Endpoint',
|
|
140
|
-
[MODULES.machine, 'Endpoint',
|
|
195
|
+
[MODULES.machine, 'Permission', 700, [], ValueType.TYPE_ADDRESS, 'Permission object address.'],
|
|
196
|
+
[MODULES.machine, 'Paused', 701, [], ValueType.TYPE_BOOL, 'Pause the creation of new Progress?'],
|
|
197
|
+
[MODULES.machine, 'Published', 702, [], ValueType.TYPE_BOOL, 'Is it allowed to create Progress?'],
|
|
198
|
+
[MODULES.machine, 'Is Consensus Repository', 703, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether an address is a consensus repository?', 'Input:adddress'],
|
|
199
|
+
[MODULES.machine, 'Has Endpoint', 704, [], ValueType.TYPE_BOOL, 'Is the endpoint set?'],
|
|
200
|
+
[MODULES.machine, 'Endpoint', 705, [], ValueType.TYPE_STRING, 'Endpoint url/ipfs.'],
|
|
141
201
|
|
|
142
|
-
[MODULES.progress, 'Machine',
|
|
143
|
-
[MODULES.progress, 'Current Node',
|
|
144
|
-
[MODULES.progress, 'Has Parent',
|
|
145
|
-
[MODULES.progress, 'Parent',
|
|
146
|
-
[MODULES.progress, 'Has Task',
|
|
147
|
-
[MODULES.progress, 'Task',
|
|
148
|
-
[MODULES.progress, 'Has Unique Permission',
|
|
149
|
-
[MODULES.progress, 'Is Unique Permission Operator',
|
|
150
|
-
[MODULES.progress, 'Has Context Repository',
|
|
151
|
-
[MODULES.progress, 'Context Repository',
|
|
152
|
-
[MODULES.progress, 'Last Session Time',
|
|
153
|
-
[MODULES.progress, 'Last Session Node',
|
|
154
|
-
[MODULES.progress, 'Current Session-id',
|
|
155
|
-
[MODULES.progress, 'Parent Session-id',
|
|
156
|
-
[MODULES.progress, 'Parent Next Node',
|
|
157
|
-
[MODULES.progress, 'Parent Forward',
|
|
158
|
-
[MODULES.progress, 'Parent Node',
|
|
159
|
-
[MODULES.progress, 'Forward Accomplished',
|
|
160
|
-
[MODULES.progress, 'Forward Operator',
|
|
161
|
-
[MODULES.progress, 'Forward Sub-progress',
|
|
162
|
-
[MODULES.progress, 'Forward Deliverables',
|
|
163
|
-
[MODULES.progress, 'Forward time',
|
|
164
|
-
[MODULES.progress, 'Closest Session Time',
|
|
165
|
-
[MODULES.progress, 'Closest Forward Accomplished',
|
|
166
|
-
[MODULES.progress, 'Closest Forward Operator',
|
|
167
|
-
[MODULES.progress, 'Closest Forward Sub-progress',
|
|
168
|
-
[MODULES.progress, 'Closest Forward Deliverables',
|
|
169
|
-
[MODULES.progress, 'Closest Forward time',
|
|
170
|
-
|
|
171
|
-
[MODULES.
|
|
172
|
-
[MODULES.
|
|
173
|
-
[MODULES.
|
|
174
|
-
[MODULES.
|
|
175
|
-
[MODULES.
|
|
176
|
-
[MODULES.
|
|
177
|
-
[MODULES.
|
|
178
|
-
[MODULES.
|
|
179
|
-
[MODULES.
|
|
180
|
-
[MODULES.order, 'Refunded', 100, [], ValueType.TYPE_BOOL, 'Whether a refund has occurred?'],
|
|
181
|
-
[MODULES.order, 'Withdrawed', 101, [], ValueType.TYPE_BOOL, 'Whether a service provider withdrawal has occurred?'],
|
|
202
|
+
[MODULES.progress, 'Machine', 800, [], ValueType.TYPE_ADDRESS, 'The Machine object that created this Progress.'],
|
|
203
|
+
[MODULES.progress, 'Current Node', 801, [], ValueType.TYPE_STRING, 'The name of the currently running node.'],
|
|
204
|
+
[MODULES.progress, 'Has Parent', 802, [], ValueType.TYPE_BOOL, 'Is the parent Progress defined?'],
|
|
205
|
+
[MODULES.progress, 'Parent', 803, [], ValueType.TYPE_ADDRESS, 'The parent Progress, that contains some child Progress.'],
|
|
206
|
+
[MODULES.progress, 'Has Task', 804, [], ValueType.TYPE_BOOL, 'Does it contain clear task(eg. an Order)?'],
|
|
207
|
+
[MODULES.progress, 'Task', 805, [], ValueType.TYPE_ADDRESS, 'Task object address.'],
|
|
208
|
+
[MODULES.progress, 'Has Unique Permission', 806, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Does Progress define a unique operation permission?', 'Input:opertor name'],
|
|
209
|
+
[MODULES.progress, 'Is Unique Permission Operator', 807, [ValueType.TYPE_STRING, ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Is an address an operator with unique permissions?', 'Input 1:operator name; Input 2:address'],
|
|
210
|
+
[MODULES.progress, 'Has Context Repository', 808, [], ValueType.TYPE_BOOL, 'Whether the repository reference for Progress is set?'],
|
|
211
|
+
[MODULES.progress, 'Context Repository', 809, [], ValueType.TYPE_ADDRESS, 'Repository reference for Progress.'],
|
|
212
|
+
[MODULES.progress, 'Last Session Time', 810, [], ValueType.TYPE_U64, 'Time when the previous session was completed.'],
|
|
213
|
+
[MODULES.progress, 'Last Session Node', 811, [], ValueType.TYPE_STRING, 'The name of the last completed node.'],
|
|
214
|
+
[MODULES.progress, 'Current Session-id', 812, [], ValueType.TYPE_U64, 'The session id of ongoing node.'],
|
|
215
|
+
[MODULES.progress, 'Parent Session-id', 813, [], ValueType.TYPE_U64, 'The child process was started in the Session-id phase of the parent process.'],
|
|
216
|
+
[MODULES.progress, 'Parent Next Node', 814, [], ValueType.TYPE_STRING, 'The child process is started at the next node stage of the parent process.'],
|
|
217
|
+
[MODULES.progress, 'Parent Forward', 815, [], ValueType.TYPE_STRING, 'The child process is started in the Forward phase of the next node of the parent process.'],
|
|
218
|
+
[MODULES.progress, 'Parent Node', 816, [], ValueType.TYPE_STRING, 'The node name of the parent process where the child process is located.'],
|
|
219
|
+
[MODULES.progress, 'Forward Accomplished', 817, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Has a forward been accomplished?', 'Input 1:session-id; Input 2:next node name; Input 3:forward name'],
|
|
220
|
+
[MODULES.progress, 'Forward Operator', 818, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The forward operator.', 'Input 1:session-id; Input 2:next node name; Input 3:forward name'],
|
|
221
|
+
[MODULES.progress, 'Forward Sub-progress', 819, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The forward child process address(if set).', 'Input 1:session-id; Input 2:next node name; Input 3:forward name'],
|
|
222
|
+
[MODULES.progress, 'Forward Deliverables', 820, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The forward deliverable(if set).', 'Input 1:session-id; Input 2:next node name; Input 3:forward name'],
|
|
223
|
+
[MODULES.progress, 'Forward time', 821, [ValueType.TYPE_U64, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_U64, 'The time when the forward was last triggered.', 'Input 1:session-id; Input 2:next node name; Input 3:forward name'],
|
|
224
|
+
[MODULES.progress, 'Closest Session Time', 822, [ValueType.TYPE_STRING], ValueType.TYPE_U64, 'The time a node that closest time to the current node completes its session.', 'Input:the node name'],
|
|
225
|
+
[MODULES.progress, 'Closest Forward Accomplished', 823, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Has a forward been accomplished?', 'Input 1:node name; Input 2:next node name; Input 3:forward name'],
|
|
226
|
+
[MODULES.progress, 'Closest Forward Operator', 824, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The operator of the forward that closest time to the current node.', 'Input 1:node name; Input 2:next node name; Input 3:forward name'],
|
|
227
|
+
[MODULES.progress, 'Closest Forward Sub-progress', 825, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The child process address(if set) of the forward that closest time to the current node.', 'Input 1:node name; Input 2:next node name; Input 3:forward name'],
|
|
228
|
+
[MODULES.progress, 'Closest Forward Deliverables', 826, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The deliverable(if set) of the forward that closest time to the current node.', 'Input 1:node name; Input 2:next node name; Input 3:forward name'],
|
|
229
|
+
[MODULES.progress, 'Closest Forward time', 827, [ValueType.TYPE_STRING, ValueType.TYPE_STRING, ValueType.TYPE_STRING], ValueType.TYPE_U64, 'The time when the forward that closest time to the current node was last triggered.', 'Input 1:node name; Input 2:next node name; Input 3:forward name'],
|
|
230
|
+
|
|
231
|
+
[MODULES.wowok, 'Builder', 900, [], ValueType.TYPE_ADDRESS, 'Builder address of Wowok.'],
|
|
232
|
+
[MODULES.wowok, 'Everyone Guard', 901, [], ValueType.TYPE_ADDRESS, 'A guard that all addresses can pass through.'],
|
|
233
|
+
[MODULES.wowok, 'Object of Entities', 902, [], ValueType.TYPE_ADDRESS, 'The address of entity information object.'],
|
|
234
|
+
[MODULES.wowok, 'Grantor Count', 903, [], ValueType.TYPE_U64, 'Number of registered grantors.'],
|
|
235
|
+
[MODULES.wowok, 'Has Grantor', 904, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether an address has been registered as a grantor?', , 'Input:address'],
|
|
236
|
+
[MODULES.wowok, 'Grantor Name', 905, [ValueType.TYPE_ADDRESS], ValueType.TYPE_STRING, "Name of a grantor.", 'Input:address'],
|
|
237
|
+
[MODULES.wowok, 'Grantor Registration Time', 906, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Registration time of a grantor.', 'Input:address'],
|
|
238
|
+
[MODULES.wowok, 'Grantor Expired Time', 907, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The expiration time of a grantor.', 'Input:address'],
|
|
239
|
+
[MODULES.wowok, 'Grantee Object for Grantor', 908, [ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS, 'Grantee repository address of a grantor.', 'Input:address'],
|
|
182
240
|
|
|
183
|
-
[MODULES.
|
|
184
|
-
[MODULES.
|
|
185
|
-
[MODULES.
|
|
186
|
-
[MODULES.
|
|
187
|
-
[MODULES.
|
|
188
|
-
[MODULES.
|
|
189
|
-
[MODULES.
|
|
190
|
-
[MODULES.
|
|
191
|
-
[MODULES.
|
|
192
|
-
[MODULES.
|
|
193
|
-
[MODULES.
|
|
194
|
-
[MODULES.
|
|
195
|
-
[MODULES.
|
|
196
|
-
|
|
197
|
-
[MODULES.
|
|
198
|
-
[MODULES.
|
|
199
|
-
[MODULES.
|
|
200
|
-
[MODULES.
|
|
201
|
-
[MODULES.
|
|
202
|
-
|
|
203
|
-
[MODULES.
|
|
204
|
-
[MODULES.
|
|
205
|
-
[MODULES.
|
|
206
|
-
[MODULES.
|
|
207
|
-
[MODULES.
|
|
208
|
-
[MODULES.
|
|
209
|
-
[MODULES.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
[MODULES.
|
|
214
|
-
|
|
215
|
-
[MODULES.
|
|
216
|
-
[MODULES.
|
|
217
|
-
[MODULES.
|
|
218
|
-
[MODULES.
|
|
219
|
-
[MODULES.
|
|
220
|
-
[MODULES.
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
[MODULES.reward, 'Portions Claimed by An Address', 159, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The portions of rewards that have been claimed by a certain address.'],
|
|
224
|
-
[MODULES.reward, 'Number of Addresses Claimed', 160, [], ValueType.TYPE_U64, 'Number of addresses that have claimed rewards.'],
|
|
225
|
-
[MODULES.reward, 'Is Sponsor', 161, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether an address is a sponsor of the reward pool?', 'Input:address'],
|
|
226
|
-
[MODULES.reward, 'Portions by A Sponsor', 162, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The portions of sponsorship reward pools for a certain address.', 'Input:address'],
|
|
227
|
-
[MODULES.reward, 'Number of Sponsors', 163, [], ValueType.TYPE_U64, 'Number of sponsors in the sponsorship reward pool.'],
|
|
228
|
-
[MODULES.reward, 'Allow Repeated Claims', 164, [], ValueType.TYPE_BOOL, 'Whether to allow repeated claims?'],
|
|
229
|
-
|
|
230
|
-
/* [MODULES.vote, 'Permission', 171, [], ValueType.TYPE_ADDRESS],
|
|
241
|
+
[MODULES.payment, 'Sender', 1200, [], ValueType.TYPE_ADDRESS, 'Whether an address has been registered as a grantor?', , 'Input:address'],
|
|
242
|
+
[MODULES.payment, 'Total Amount', 1201, [], ValueType.TYPE_U64, "Name of a grantor.", 'Input:address'],
|
|
243
|
+
[MODULES.payment, 'Tips', 1202, [], ValueType.TYPE_STRING, 'Registration time of a grantor.', 'Input:address'],
|
|
244
|
+
[MODULES.payment, 'Has Guard for Perpose', 1203, [], ValueType.TYPE_BOOL, 'The expiration time of a grantor.', 'Input:address'],
|
|
245
|
+
[MODULES.payment, 'Has Object for Perpose', 1204, [], ValueType.TYPE_BOOL, 'Grantee repository address of a grantor.', 'Input:address'],
|
|
246
|
+
[MODULES.payment, 'Guard for Perpose', 1205, [], ValueType.TYPE_ADDRESS, 'Whether an address has been registered as a grantor?', , 'Input:address'],
|
|
247
|
+
[MODULES.payment, 'Object for Perpose', 1206, [], ValueType.TYPE_ADDRESS, "Name of a grantor.", 'Input:address'],
|
|
248
|
+
[MODULES.payment, 'Number of Transfer', 1207, [], ValueType.TYPE_U64, 'Registration time of a grantor.', 'Input:address'],
|
|
249
|
+
[MODULES.payment, 'Is a Recipient', 1208, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'The expiration time of a grantor.', 'Input:address'],
|
|
250
|
+
[MODULES.payment, 'Amount for a Recipient', 1209, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Grantee repository address of a grantor.', 'Input:address'],
|
|
251
|
+
[MODULES.payment, 'Time', 1210, [], ValueType.TYPE_U64, 'Registration time of a grantor.', 'Input:address'],
|
|
252
|
+
[MODULES.payment, 'Is from Treasury', 1211, [], ValueType.TYPE_BOOL, 'The expiration time of a grantor.', 'Input:address'],
|
|
253
|
+
[MODULES.payment, 'Treasury Address', 1212, [], ValueType.TYPE_ADDRESS, 'Grantee repository address of a grantor.', 'Input:address'],
|
|
254
|
+
|
|
255
|
+
[MODULES.withholding, 'Has Deposited', 1300, [], ValueType.TYPE_BOOL, 'Whether an address has been registered as a grantor?', , 'Input:address'],
|
|
256
|
+
[MODULES.withholding, 'Original Type Deposited', 1301, [], ValueType.TYPE_STRING, "Name of a grantor.", 'Input:address'],
|
|
257
|
+
[MODULES.withholding, 'Original Package', 1302, [], ValueType.TYPE_ADDRESS, 'Registration time of a grantor.', 'Input:address'],
|
|
258
|
+
[MODULES.withholding, 'Original Module', 1303, [], ValueType.TYPE_STRING, 'The expiration time of a grantor.', 'Input:address'],
|
|
259
|
+
[MODULES.withholding, 'Type Deposited', 1304, [], ValueType.TYPE_STRING, 'Grantee repository address of a grantor.', 'Input:address'],
|
|
260
|
+
[MODULES.withholding, 'Package', 1305, [], ValueType.TYPE_ADDRESS, 'Whether an address has been registered as a grantor?', , 'Input:address'],
|
|
261
|
+
[MODULES.withholding, 'Module', 1306, [], ValueType.TYPE_STRING, 'The expiration time of a grantor.', 'Input:address'],
|
|
262
|
+
[MODULES.withholding, 'Guard for Withdrawing', 1307, [], ValueType.TYPE_ADDRESS, 'Registration time of a grantor.', 'Input:address'],
|
|
263
|
+
[MODULES.withholding, 'Guard for Refunding', 1308, [], ValueType.TYPE_STRING, 'The expiration time of a grantor.', 'Input:address'],
|
|
264
|
+
[MODULES.withholding, 'Deposit Time', 1309, [], ValueType.TYPE_U64, 'Grantee repository address of a grantor.', 'Input:address'],
|
|
265
|
+
[MODULES.withholding, 'Refund Time', 1310, [], ValueType.TYPE_U64, 'Whether an address has been registered as a grantor?', , 'Input:address'],
|
|
266
|
+
[MODULES.withholding, 'Depositor address', 1311, [], ValueType.TYPE_ADDRESS, 'The expiration time of a grantor.', 'Input:address'],
|
|
267
|
+
[MODULES.withholding, 'Re address', 1312, [], ValueType.TYPE_U64, 'Grantee repository address of a grantor.', 'Input:address'],
|
|
268
|
+
// [MODULES.withholding, 'Refund Time', 1313, [], ValueType.TYPE_U64, 'Whether an address has been registered as a grantor?', , 'Input:address'],
|
|
269
|
+
// [MODULES.withholding, 'Depositor address', 1314, [], ValueType.TYPE_ADDRESS, 'The expiration time of a grantor.', 'Input:address'],
|
|
270
|
+
|
|
271
|
+
[MODULES.treasury, 'Permission', 1400, [], ValueType.TYPE_ADDRESS, 'Whether an address has been registered as a grantor?', , 'Input:address'],
|
|
272
|
+
[MODULES.treasury, 'Balance', 1401, [], ValueType.TYPE_U64, "Name of a grantor.", 'Input:address'],
|
|
273
|
+
[MODULES.treasury, 'Number of Flow Records', 1402, [], ValueType.TYPE_U64, 'Registration time of a grantor.', 'Input:address'],
|
|
274
|
+
[MODULES.treasury, 'Deposit Flow', 1403, [], ValueType.TYPE_U128, 'The expiration time of a grantor.', 'Input:address'],
|
|
275
|
+
[MODULES.treasury, 'Take Flow', 1404, [], ValueType.TYPE_U128, 'Grantee repository address of a grantor.', 'Input:address'],
|
|
276
|
+
[MODULES.treasury, 'Flow over a Period of Time', 1405, [ValueType.TYPE_U64, ValueType.TYPE_U64], ValueType.TYPE_U128, 'Whether an address has been registered as a grantor?', , 'Input:address'],
|
|
277
|
+
[MODULES.treasury, 'Deposit Flow over a Period of Time', 1406, [ValueType.TYPE_U64, ValueType.TYPE_U64], ValueType.TYPE_U128, "Name of a grantor.", 'Input:address'],
|
|
278
|
+
[MODULES.treasury, 'Take Flow over a Period of Time', 1407, [ValueType.TYPE_U64, ValueType.TYPE_U64], ValueType.TYPE_U128, 'Registration time of a grantor.', 'Input:address'],
|
|
279
|
+
|
|
280
|
+
/* [MODULES.vote, 'Permission', 171, [], ValueType.TYPE_ADDRESS],
|
|
231
281
|
[MODULES.vote, 'Options Locked', 172, [], ValueType.TYPE_BOOL],
|
|
232
282
|
[MODULES.vote, 'Deadline Locked', 173, [], ValueType.TYPE_BOOL],
|
|
233
283
|
[MODULES.vote, 'Vote-Guard Locked', 174, [], ValueType.TYPE_BOOL],
|
|
@@ -249,23 +299,6 @@ export class Guard {
|
|
|
249
299
|
[MODULES.vote, 'Top1 Count by Addresses', 190, [], ValueType.TYPE_U64],
|
|
250
300
|
[MODULES.vote, 'Top1 Option by Votes', 191, [], ValueType.TYPE_STRING],
|
|
251
301
|
[MODULES.vote, 'Top1 Count by Votes', 192, [], ValueType.TYPE_U64], */
|
|
252
|
-
|
|
253
|
-
[MODULES.wowok, 'Builder', 210, [], ValueType.TYPE_ADDRESS, 'Builder address of Wowok.'],
|
|
254
|
-
[MODULES.wowok, 'Everyone Guard', 211, [], ValueType.TYPE_ADDRESS, 'A guard that all addresses can pass through.'],
|
|
255
|
-
[MODULES.wowok, 'Object of Entities', 212, [], ValueType.TYPE_ADDRESS, 'The address of entity information object.'],
|
|
256
|
-
[MODULES.wowok, 'Grantor Count', 213, [], ValueType.TYPE_U64, 'Number of registered grantors.'],
|
|
257
|
-
[MODULES.wowok, 'Has Grantor', 214, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether an address has been registered as a grantor?', , 'Input:address'],
|
|
258
|
-
[MODULES.wowok, 'Grantor Name', 215, [ValueType.TYPE_ADDRESS], ValueType.TYPE_STRING, "Name of a grantor.", 'Input:address'],
|
|
259
|
-
[MODULES.wowok, 'Grantor Registration Time', 216, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Registration time of a grantor.', 'Input:address'],
|
|
260
|
-
[MODULES.wowok, 'Grantor Expired Time', 217, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The expiration time of a grantor.', 'Input:address'],
|
|
261
|
-
[MODULES.wowok, 'Grantee Object for Grantor', 218, [ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS, 'Grantee repository address of a grantor.', 'Input:address'],
|
|
262
|
-
|
|
263
|
-
[MODULES.entity, 'Contains Entity?', 230, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Is an entity already registered?', 'Input:address'],
|
|
264
|
-
[MODULES.entity, 'Likes', 231, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The number of likes for an address by other addresses.', 'Input:address'],
|
|
265
|
-
[MODULES.entity, 'Dislikes', 232, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The number of dislikes for an address by other addresses.', 'Input:address'],
|
|
266
|
-
[MODULES.entity, 'Entity Info', 233, [ValueType.TYPE_ADDRESS], ValueType.TYPE_VEC_U8, 'Public information about an entity.', 'Input:address'],
|
|
267
|
-
[MODULES.entity, 'Has Resource by Entity?', 234, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether an entity created a resource?', 'Input:address'],
|
|
268
|
-
[MODULES.entity, 'Entity Resource', 235, [ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS, 'The address of a resource object created by an entity.', 'Input:address'],
|
|
269
302
|
];
|
|
270
303
|
|
|
271
304
|
static BoolCmd = Guard.QUERIES.filter(q => q[4] === ValueType.TYPE_BOOL);
|
|
@@ -350,127 +383,39 @@ export class Guard {
|
|
|
350
383
|
return Guard.CommonOptions(ret_type);
|
|
351
384
|
}
|
|
352
385
|
}
|
|
353
|
-
|
|
354
|
-
export class GuardConstantHelper {
|
|
355
|
-
static IsValidIndentifier = (identifier:number) : boolean => {
|
|
356
|
-
if (!IsValidInt(identifier) || identifier > 255) return false;
|
|
357
|
-
return true
|
|
358
|
-
}
|
|
359
|
-
static get_constant_value(constants:GuardConstant, identifier:number, type:ConstantType) : Uint8Array | undefined {
|
|
360
|
-
if (constants.has(identifier)) {
|
|
361
|
-
let v = constants.get(identifier);
|
|
362
|
-
if (v?.value && v.type == type) {
|
|
363
|
-
return v.value;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
static get_constant_witness(constants:GuardConstant, identifier:number) : Uint8Array | undefined {
|
|
368
|
-
if (constants.has(identifier)) {
|
|
369
|
-
let v = constants.get(identifier);
|
|
370
|
-
if (v?.witness && v.type == ContextType.TYPE_WITNESS_ID) {
|
|
371
|
-
return v.witness;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
static add_future_constant(constants:GuardConstant, identifier:number, witness:any, value?:any, bNeedSerialize=true) {
|
|
377
|
-
if (!GuardConstantHelper.IsValidIndentifier(identifier)) ERROR(Errors.IsValidIndentifier, 'add_future_constant');
|
|
378
|
-
if (!witness && !value) ERROR(Errors.InvalidParam, 'both witness and value invalid');
|
|
379
|
-
let v = constants.get(identifier);
|
|
380
|
-
if (!v || v.type == ContextType.TYPE_WITNESS_ID) {
|
|
381
|
-
if (bNeedSerialize) {
|
|
382
|
-
constants.set(identifier, {type:ContextType.TYPE_WITNESS_ID, value:value ? Bcs.getInstance().ser(ValueType.TYPE_ADDRESS, value) : undefined,
|
|
383
|
-
witness:witness ? Bcs.getInstance().ser(ValueType.TYPE_ADDRESS, witness) : undefined})
|
|
384
|
-
} else {
|
|
385
|
-
constants.set(identifier, {type:ContextType.TYPE_WITNESS_ID, value:value?value:undefined, witness:witness?witness:undefined});
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
static add_constant(constants:GuardConstant, identifier:number, type:ValueType, value:any, bNeedSerialize=true) {
|
|
391
|
-
const e = SER_VALUE.find((v:any)=>v.type===type)?.name ?? '' + ' invalid';
|
|
392
|
-
if (!GuardConstantHelper.IsValidIndentifier(identifier)) {
|
|
393
|
-
ERROR(Errors.InvalidParam, 'add_constant identifier')
|
|
394
|
-
}
|
|
395
|
-
if (value === undefined) {
|
|
396
|
-
ERROR(Errors.InvalidParam, 'add_constant value')
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
switch (type) {
|
|
400
|
-
case ValueType.TYPE_BOOL:
|
|
401
|
-
case ValueType.TYPE_ADDRESS:
|
|
402
|
-
case ValueType.TYPE_U64:
|
|
403
|
-
case ValueType.TYPE_U8:
|
|
404
|
-
case ValueType.TYPE_U128:
|
|
405
|
-
case ValueType.TYPE_U256:
|
|
406
|
-
case ValueType.TYPE_VEC_U64:
|
|
407
|
-
case ValueType.TYPE_VEC_VEC_U8:
|
|
408
|
-
case ValueType.TYPE_OPTION_ADDRESS:
|
|
409
|
-
case ValueType.TYPE_OPTION_BOOL:
|
|
410
|
-
case ValueType.TYPE_OPTION_U128:
|
|
411
|
-
case ValueType.TYPE_OPTION_U256:
|
|
412
|
-
case ValueType.TYPE_OPTION_U64:
|
|
413
|
-
case ValueType.TYPE_OPTION_U8:
|
|
414
|
-
case ValueType.TYPE_VEC_ADDRESS:
|
|
415
|
-
case ValueType.TYPE_VEC_BOOL:
|
|
416
|
-
case ValueType.TYPE_VEC_U128:
|
|
417
|
-
case ValueType.TYPE_VEC_U256:
|
|
418
|
-
case ValueType.TYPE_STRING:
|
|
419
|
-
case ValueType.TYPE_VEC_U8:
|
|
420
|
-
case ValueType.TYPE_OPTION_STRING:
|
|
421
|
-
case ValueType.TYPE_OPTION_VEC_U8:
|
|
422
|
-
case ValueType.TYPE_VEC_STRING:
|
|
423
|
-
let ser = SER_VALUE.find(s=>s.type==type);
|
|
424
|
-
if (!ser) ERROR(Errors.Fail, 'add_constant: invalid type:'+e);
|
|
425
|
-
if (bNeedSerialize) {
|
|
426
|
-
constants.set(identifier, {type:type, value:Bcs.getInstance().ser(type, value)})
|
|
427
|
-
} else {
|
|
428
|
-
constants.set(identifier, {type:type, value:value})
|
|
429
|
-
}
|
|
430
|
-
return
|
|
431
|
-
default:
|
|
432
|
-
ERROR(Errors.Fail, 'add_constant serialize not impl yet:'+e)
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
386
|
export class GuardMaker {
|
|
437
387
|
protected data : Uint8Array[] = [];
|
|
438
388
|
protected type_validator : Data_Type[] = [];
|
|
439
389
|
protected constant : GuardConstant = new Map<number, Guard_Variable>();
|
|
440
390
|
|
|
441
|
-
private static index: number =
|
|
391
|
+
private static index: number = 1;
|
|
442
392
|
private static get_index() {
|
|
443
393
|
if (GuardMaker.index == 256) {
|
|
444
|
-
GuardMaker.index =
|
|
394
|
+
GuardMaker.index = 1;
|
|
445
395
|
}
|
|
446
396
|
return GuardMaker.index++
|
|
447
397
|
}
|
|
448
|
-
|
|
398
|
+
static IsValidIndentifier = (identifier:number) : boolean => {
|
|
399
|
+
if (!IsValidInt(identifier) || identifier > 255) return false;
|
|
400
|
+
return true
|
|
401
|
+
}
|
|
449
402
|
constructor() { }
|
|
450
403
|
|
|
451
|
-
|
|
404
|
+
// undefined value means witness
|
|
405
|
+
add_constant(type:ValueType, value?:any, identifier?:number, bNeedSerialize=true) : number {
|
|
452
406
|
if (identifier === undefined) identifier = GuardMaker.get_index();
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
407
|
+
let v = this.constant.get(identifier);
|
|
408
|
+
if (!v) {
|
|
409
|
+
if (bNeedSerialize && value !== undefined) {
|
|
410
|
+
value = Bcs.getInstance().ser(type, value);
|
|
411
|
+
}
|
|
412
|
+
this.constant.set(identifier, {type:type, value:value===undefined ? undefined:value, bWitness:value===undefined ? true:false});
|
|
413
|
+
}
|
|
459
414
|
return identifier
|
|
460
415
|
}
|
|
461
416
|
|
|
462
|
-
|
|
463
|
-
if (param === undefined) ERROR(Errors.InvalidParam, 'param');
|
|
464
|
-
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, type));
|
|
465
|
-
let ser = SER_VALUE.find(s=>s.type==type);
|
|
466
|
-
if (!ser) ERROR(Errors.Fail, 'serValueParam: invalid type');
|
|
467
|
-
this.data.push(Bcs.getInstance().ser(ser!.type as number, param));
|
|
468
|
-
this.type_validator.push(type);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
// serialize const & data
|
|
417
|
+
// serialize const & data, WITNESS use constants only.
|
|
472
418
|
add_param(type:ValueType | ContextType, param?:any) : GuardMaker {
|
|
473
|
-
const e = SER_VALUE.find((v:any)=>v.type===type)?.name ?? '' + ' invalid';
|
|
474
419
|
switch(type) {
|
|
475
420
|
case ValueType.TYPE_ADDRESS:
|
|
476
421
|
case ValueType.TYPE_BOOL:
|
|
@@ -490,12 +435,14 @@ export class GuardMaker {
|
|
|
490
435
|
case ValueType.TYPE_OPTION_U256:
|
|
491
436
|
case ValueType.TYPE_OPTION_U8:
|
|
492
437
|
case ValueType.TYPE_VEC_U256:
|
|
493
|
-
this.
|
|
438
|
+
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, type));
|
|
439
|
+
this.data.push(Bcs.getInstance().ser(type as number, param));
|
|
440
|
+
this.type_validator.push(type);
|
|
494
441
|
break;
|
|
495
442
|
case ValueType.TYPE_STRING:
|
|
496
443
|
case ValueType.TYPE_VEC_U8:
|
|
497
|
-
if (!param) ERROR(Errors.InvalidParam, 'param:'+
|
|
498
|
-
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, type));
|
|
444
|
+
if (!param) ERROR(Errors.InvalidParam, 'param: ' + type);
|
|
445
|
+
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, type));
|
|
499
446
|
if (typeof(param) == 'string') {
|
|
500
447
|
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_STRING, param));
|
|
501
448
|
} else {
|
|
@@ -511,45 +458,32 @@ export class GuardMaker {
|
|
|
511
458
|
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, type));
|
|
512
459
|
this.type_validator.push(ValueType.TYPE_U64);
|
|
513
460
|
break;
|
|
514
|
-
case ContextType.TYPE_WITNESS_ID:
|
|
515
|
-
if (!param) ERROR(Errors.InvalidParam, 'param:'+e);
|
|
516
|
-
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, type));
|
|
517
|
-
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_ADDRESS, param));
|
|
518
|
-
this.type_validator.push(ValueType.TYPE_ADDRESS);
|
|
519
|
-
break;
|
|
520
461
|
case ContextType.TYPE_CONSTANT:
|
|
521
|
-
if (!param) {
|
|
522
|
-
ERROR(Errors.InvalidParam, 'param invalid:'+e);
|
|
523
|
-
}
|
|
524
|
-
if (typeof(param) != 'number' || !IsValidInt(param) || param > 255) {
|
|
462
|
+
if (typeof(param) !== 'number' || !IsValidInt(param) || param > 255) {
|
|
525
463
|
ERROR(Errors.InvalidParam, 'add_param param:'+type);
|
|
526
464
|
}
|
|
527
465
|
|
|
528
466
|
var v = this.constant.get(param);
|
|
529
|
-
if (!v) ERROR(Errors.Fail, 'identifier not in constant:'+
|
|
530
|
-
|
|
531
|
-
if (v?.type === ContextType.TYPE_WITNESS_ID) {
|
|
532
|
-
t = ValueType.TYPE_ADDRESS;
|
|
533
|
-
}
|
|
534
|
-
this.type_validator.push(t); //@ type validator convert
|
|
467
|
+
if (!v) ERROR(Errors.Fail, 'identifier not in constant:'+param);
|
|
468
|
+
this.type_validator.push(v!.type); //@ type validator convert
|
|
535
469
|
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, type)); // constant flag
|
|
536
470
|
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, param)); // identifier
|
|
537
471
|
break;
|
|
538
472
|
default:
|
|
539
|
-
ERROR(Errors.InvalidParam, 'add_param type:'+
|
|
473
|
+
ERROR(Errors.InvalidParam, 'add_param type:'+type);
|
|
540
474
|
};
|
|
541
475
|
return this;
|
|
542
476
|
}
|
|
543
477
|
|
|
544
478
|
// object_address_from: string for static address; number as identifier inconstant
|
|
545
|
-
add_query(module:MODULES, query_name:string, object_address_from:string | number
|
|
479
|
+
add_query(module:MODULES, query_name:string, object_address_from:string | number) : GuardMaker {
|
|
546
480
|
let query_index = Guard.QUERIES.findIndex((q) => { return q[0] == module && q[1] == query_name})
|
|
547
481
|
if (query_index == -1) {
|
|
548
482
|
ERROR(Errors.InvalidParam, 'query_name:'+query_name);
|
|
549
483
|
}
|
|
550
484
|
|
|
551
485
|
if (typeof(object_address_from) == 'number' ) {
|
|
552
|
-
if (!
|
|
486
|
+
if (!GuardMaker.IsValidIndentifier(object_address_from)) {
|
|
553
487
|
ERROR(Errors.InvalidParam, 'object_address_from:'+query_name);
|
|
554
488
|
}
|
|
555
489
|
} else {
|
|
@@ -570,13 +504,12 @@ export class GuardMaker {
|
|
|
570
504
|
|
|
571
505
|
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, OperatorType.TYPE_QUERY)); // QUERY TYPE
|
|
572
506
|
if (typeof(object_address_from) == 'string') {
|
|
573
|
-
|
|
574
|
-
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, ValueType.TYPE_ADDRESS));
|
|
507
|
+
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, ValueType.TYPE_ADDRESS));
|
|
575
508
|
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_ADDRESS, object_address_from)); // object address
|
|
576
509
|
} else {
|
|
577
510
|
let v = this.constant.get(object_address_from);
|
|
578
511
|
if (!v) ERROR(Errors.Fail, 'object_address_from not in constant:'+query_name);
|
|
579
|
-
if (
|
|
512
|
+
if (v?.type == ValueType.TYPE_ADDRESS) {
|
|
580
513
|
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, ContextType.TYPE_CONSTANT));
|
|
581
514
|
this.data.push(Bcs.getInstance().ser(ValueType.TYPE_U8, object_address_from)); // object identifer in constants
|
|
582
515
|
} else {
|
|
@@ -584,7 +517,7 @@ export class GuardMaker {
|
|
|
584
517
|
}
|
|
585
518
|
}
|
|
586
519
|
|
|
587
|
-
this.data.push(Bcs.getInstance().ser(
|
|
520
|
+
this.data.push(Bcs.getInstance().ser('u16', Guard.QUERIES[query_index][2])); // cmd(u16)
|
|
588
521
|
this.type_validator.splice(offset, Guard.QUERIES[query_index][3].length); // delete type stack
|
|
589
522
|
this.type_validator.push(Guard.QUERIES[query_index][4]); // add the return value type to type stack
|
|
590
523
|
return this;
|
|
@@ -693,13 +626,13 @@ export class GuardMaker {
|
|
|
693
626
|
if (!otherBuilt.IsReady() || !this.IsReady()) { ERROR(Errors.Fail, 'both should built yet')};
|
|
694
627
|
let maker = new GuardMaker();
|
|
695
628
|
this.constant.forEach((v, k) => {
|
|
696
|
-
maker.constant.set(k, {type:v.type, value:v.value,
|
|
629
|
+
maker.constant.set(k, {type:v.type, value:v.value, bWitness:v.bWitness});
|
|
697
630
|
})
|
|
698
631
|
otherBuilt.constant.forEach((v, k) => {
|
|
699
632
|
if (maker.constant.has(k) && !bCombinConstant) {
|
|
700
633
|
ERROR(Errors.Fail, 'constant identifier exist');
|
|
701
634
|
}
|
|
702
|
-
maker.constant.set(k, {type:v.type, value:v.value,
|
|
635
|
+
maker.constant.set(k, {type:v.type, value:v.value, bWitness:v.bWitness});
|
|
703
636
|
})
|
|
704
637
|
let op = bAnd ? OperatorType.TYPE_LOGIC_AND : OperatorType.TYPE_LOGIC_OR;
|
|
705
638
|
maker.data.push(concatenate(Uint8Array, ...this.data, ...otherBuilt.data, Bcs.getInstance().ser(ValueType.TYPE_U8, op), Bcs.getInstance().ser(ValueType.TYPE_U8, 2)));
|