wowok 1.4.31 → 1.4.35
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 +2 -3
- package/src/exception.ts +1 -1
- package/src/guard.ts +27 -10
- package/src/permission.ts +5 -3
- package/src/protocol.ts +4 -4
- package/src/treasury.ts +13 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wowok",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.35",
|
|
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",
|
|
@@ -38,8 +38,7 @@
|
|
|
38
38
|
"move language",
|
|
39
39
|
"move",
|
|
40
40
|
"treasury",
|
|
41
|
-
"payment"
|
|
42
|
-
"Withholding"
|
|
41
|
+
"payment"
|
|
43
42
|
],
|
|
44
43
|
"author": "wowok",
|
|
45
44
|
"license": "Apache-2.0",
|
package/src/exception.ts
CHANGED
package/src/guard.ts
CHANGED
|
@@ -298,14 +298,29 @@ export class Guard {
|
|
|
298
298
|
[MODULES.treasury, 'Number of Flow Records', 1402, [], ValueType.TYPE_U64, 'Number of treasury transactions.', []],
|
|
299
299
|
[MODULES.treasury, 'Inflow Amount', 1403, [], ValueType.TYPE_U128, 'Treasury inflow amount.', []],
|
|
300
300
|
[MODULES.treasury, 'Outflow Amount', 1404, [], ValueType.TYPE_U128, 'Treasury outflow amount.', []],
|
|
301
|
-
[MODULES.treasury, 'Has
|
|
302
|
-
[MODULES.treasury, '
|
|
303
|
-
[MODULES.treasury, '
|
|
304
|
-
[MODULES.treasury, '
|
|
305
|
-
[MODULES.treasury, '
|
|
306
|
-
[MODULES.treasury, '
|
|
307
|
-
[MODULES.treasury, '
|
|
308
|
-
[MODULES.treasury, '
|
|
301
|
+
[MODULES.treasury, 'Has Deposit Guard', 1405, [], ValueType.TYPE_BOOL, 'Whether the deposit Guard set?', []],
|
|
302
|
+
[MODULES.treasury, 'Deposit Guard', 1406, [], ValueType.TYPE_ADDRESS, 'Deposit Guard address.', []],
|
|
303
|
+
[MODULES.treasury, 'Number of Withdraw Guards', 1407, [], ValueType.TYPE_U64, 'Number of withdraw guards.', []],
|
|
304
|
+
[MODULES.treasury, 'Has Withdraw Guard', 1408, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Has a Withdraw Guard added?', ['guard address']],
|
|
305
|
+
[MODULES.treasury, 'Withdrawal Amount with Guard', 1409, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'withdrawal amount corresponding the Guard.', ['guard address']],
|
|
306
|
+
[MODULES.treasury, 'Recent Time with Operation', 1410, [ValueType.TYPE_U8], ValueType.TYPE_U64, 'Time of the most recent fund operation.', ['operation']],
|
|
307
|
+
[MODULES.treasury, 'Recent Signer with Operation', 1411, [ValueType.TYPE_U8], ValueType.TYPE_ADDRESS, 'Signer address of the most recent fund operation.', ['operation']],
|
|
308
|
+
[MODULES.treasury, 'Recent Payment with Operation', 1412, [ValueType.TYPE_U8], ValueType.TYPE_ADDRESS, 'Payment address of the most recent fund operation.', ['operation']],
|
|
309
|
+
[MODULES.treasury, 'Recent Amount with Operation', 1413, [ValueType.TYPE_U8], ValueType.TYPE_U64, 'Amount of the most recent fund operation.', ['operation']],
|
|
310
|
+
[MODULES.treasury, 'Recent Time with Op/Pmt', 1414, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Time of the most recent fund operation with payment specified.', ['operation', 'payment address']],
|
|
311
|
+
[MODULES.treasury, 'Recent Signer with Op&Pmt', 1415, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS, 'Signer of the most recent fund operationwith payment specified.', ['operation', 'payment address']],
|
|
312
|
+
[MODULES.treasury, 'Recent Amount with Op/Pmt', 1416, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Amount of the most recent fund operation with payment specified.', ['operation', 'payment address']],
|
|
313
|
+
[MODULES.treasury, 'Recent Time with Op/Sgr', 1417, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Time of the most recent fund operation with signer specified.', ['operation', 'signer address']],
|
|
314
|
+
[MODULES.treasury, 'Recent Payment with Op/Sgr', 1418, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS, 'Payment of the most recent fund operation with singner specified.', ['operation', 'signer address']],
|
|
315
|
+
[MODULES.treasury, 'Recent Amount with Op/Sgr', 1419, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Amount of the most recent fund operation with singer specified.', ['operation', 'signer address']],
|
|
316
|
+
[MODULES.treasury, 'Recent Time with Op/Pmt/Sgr', 1420, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS, ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Time of the most recent fund operation.', ['operation', 'payment address', 'singer address']],
|
|
317
|
+
[MODULES.treasury, 'Recent Amount with Op/Pmt/Sgr', 1421, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS, ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'Amount of the most recent fund operation.', ['operation', 'payment address', 'singer address']],
|
|
318
|
+
[MODULES.treasury, 'Has Operation', 1422, [ValueType.TYPE_U8], ValueType.TYPE_BOOL, 'Whether there was a fund operation?', ['operation']],
|
|
319
|
+
[MODULES.treasury, 'Has Operation with Pmt', 1423, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether there was a fund operation with payment specified?', ['operation', 'payment address']],
|
|
320
|
+
[MODULES.treasury, 'Has Operation with Sgr', 1424, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether there was a fund operation with singer specified?', ['operation', 'singer address']],
|
|
321
|
+
[MODULES.treasury, 'Has Operation with Pmt/Sgr', 1425, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS, ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether there was a fund operation?', ['operation', 'payment address', 'singer address']],
|
|
322
|
+
[MODULES.treasury, 'Operation at Least Times', 1426, [ValueType.TYPE_U8, ValueType.TYPE_U8], ValueType.TYPE_BOOL, 'Does it operate at least a certain number of times?', ['operation', 'at least times']],
|
|
323
|
+
[MODULES.treasury, 'Operation at Least Times by a Signer', 1427, [ValueType.TYPE_U8, ValueType.TYPE_ADDRESS, ValueType.TYPE_U8], ValueType.TYPE_BOOL, 'Does it operate at least a certain number of times by a signer?', ['operation', 'signer address', 'at least times']],
|
|
309
324
|
];
|
|
310
325
|
|
|
311
326
|
static BoolCmd = Guard.QUERIES.filter(q => q[4] === ValueType.TYPE_BOOL);
|
|
@@ -490,7 +505,9 @@ export class GuardMaker {
|
|
|
490
505
|
|
|
491
506
|
// object_address_from: string for static address; number as identifier inconstant
|
|
492
507
|
add_query(module:MODULES, query_name:string, object_address_from:string | number) : GuardMaker {
|
|
493
|
-
let query_index = Guard.QUERIES.findIndex((q) => {
|
|
508
|
+
let query_index = Guard.QUERIES.findIndex((q) => {
|
|
509
|
+
return q[0] == module && q[1] == query_name
|
|
510
|
+
})
|
|
494
511
|
if (query_index == -1) {
|
|
495
512
|
ERROR(Errors.InvalidParam, 'query_name:'+query_name);
|
|
496
513
|
}
|
|
@@ -507,7 +524,7 @@ export class GuardMaker {
|
|
|
507
524
|
|
|
508
525
|
let offset = this.type_validator.length - Guard.QUERIES[query_index][3].length;
|
|
509
526
|
if (offset < 0) {
|
|
510
|
-
ERROR(Errors.InvalidParam, '
|
|
527
|
+
ERROR(Errors.InvalidParam, 'offset:'+query_name);
|
|
511
528
|
}
|
|
512
529
|
|
|
513
530
|
let types = this.type_validator.slice(offset);
|
package/src/permission.ts
CHANGED
|
@@ -548,12 +548,14 @@ export class Permission {
|
|
|
548
548
|
let i = answer.items?.find((v)=>v.query == index); // index maybe string, so ==
|
|
549
549
|
if (i) {
|
|
550
550
|
return {has:i.permission, guard:i.guard, owner:answer.owner};
|
|
551
|
-
}
|
|
551
|
+
} else {
|
|
552
|
+
return {has:false, guard:undefined, owner:answer?.owner}
|
|
553
|
+
}
|
|
552
554
|
}
|
|
553
555
|
if (bStrict) {
|
|
554
|
-
return {has:false, guard:undefined, owner:
|
|
556
|
+
return {has:false, guard:undefined, owner:false}
|
|
555
557
|
}
|
|
556
|
-
return undefined
|
|
558
|
+
return undefined // basic: !== false ; otherwise: !
|
|
557
559
|
}
|
|
558
560
|
|
|
559
561
|
static MAX_ADMIN_COUNT = 64;
|
package/src/protocol.ts
CHANGED
|
@@ -213,11 +213,11 @@ const TESTNET = {
|
|
|
213
213
|
}
|
|
214
214
|
*/
|
|
215
215
|
const TESTNET = {
|
|
216
|
-
wowok: "
|
|
217
|
-
wowok_origin:'
|
|
216
|
+
wowok: "0x93a47e2e77b150258877b31a49d6e2dbda58c7840f14a99aeb658bddb3d0d021",
|
|
217
|
+
wowok_origin:'0x93a47e2e77b150258877b31a49d6e2dbda58c7840f14a99aeb658bddb3d0d021' ,
|
|
218
218
|
base: '0x7efcdab72af2351e5915e34ad2ac8d4ea7f4f408e08138d3498af35a362db782',
|
|
219
|
-
wowok_object: '
|
|
220
|
-
entity_object: '
|
|
219
|
+
wowok_object: '0xdc4f31084f0f0ceb8c59feb78a361091fa84d54d562e28302f2b02b1d22e2905',
|
|
220
|
+
entity_object: '0xbf547b1185c458a2498baf7235ce9824740e4c2fce27440354f342f9ccc79de0',
|
|
221
221
|
treasury_cap:'0x538cf8f32d59f58c0450a3a97c1eeed3096f4ce63e07e0bdf343a5cc1464887c',
|
|
222
222
|
}
|
|
223
223
|
const MAINNET = {
|
package/src/treasury.ts
CHANGED
|
@@ -136,7 +136,8 @@ export class Treasury {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
// return payment address
|
|
140
|
+
deposit(param:DepositParam, passport?:PassportObject) :TransactionResult {
|
|
140
141
|
if (!Protocol.IsValidObjects([param.coin])) {
|
|
141
142
|
ERROR(Errors.IsValidObjects, 'deposit.param.coin')
|
|
142
143
|
}
|
|
@@ -155,7 +156,6 @@ export class Treasury {
|
|
|
155
156
|
|
|
156
157
|
const for_obj = this.txb.pure.option('address', param.for_object ?? undefined);
|
|
157
158
|
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
158
|
-
|
|
159
159
|
if (passport) {
|
|
160
160
|
if (param.for_guard) {
|
|
161
161
|
return this.txb.moveCall({
|
|
@@ -192,29 +192,31 @@ export class Treasury {
|
|
|
192
192
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
// return current balance
|
|
196
|
+
receive(payment:PaymentObject, received:ReceivedObject, passport?:PassportObject) : TransactionResult {
|
|
196
197
|
if (!Protocol.IsValidObjects([payment, received])) {
|
|
197
198
|
ERROR(Errors.IsValidArray, 'receive.payment&received');
|
|
198
199
|
}
|
|
199
|
-
|
|
200
|
+
const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
|
|
200
201
|
if (passport) {
|
|
201
202
|
return this.txb.moveCall({
|
|
202
203
|
target:Protocol.Instance().TreasuryFn('receive_with_passport') as FnCallType,
|
|
203
204
|
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(received), this.txb.object(payment),
|
|
204
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
205
|
+
this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
205
206
|
typeArguments:[this.token_type],
|
|
206
207
|
})
|
|
207
208
|
} else {
|
|
208
209
|
return this.txb.moveCall({
|
|
209
210
|
target:Protocol.Instance().TreasuryFn('receive') as FnCallType,
|
|
210
211
|
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.object(received), this.txb.object(payment),
|
|
211
|
-
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
212
|
+
this.txb.object(clock), Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
212
213
|
typeArguments:[this.token_type],
|
|
213
214
|
})
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
217
|
|
|
217
|
-
|
|
218
|
+
// return payment address
|
|
219
|
+
withdraw(param:WithdrawParam, passport?:PassportObject) : TransactionResult | undefined {
|
|
218
220
|
if (param.items.length === 0) return undefined;
|
|
219
221
|
if (!IsValidArray(param.items, (item:WithdrawItem) => IsValidU64(item.amount) && IsValidAddress(item.address))) {
|
|
220
222
|
ERROR(Errors.IsValidArray, 'withdraw.param.items')
|
|
@@ -422,9 +424,10 @@ export class Treasury {
|
|
|
422
424
|
return parseObjectType(chain_type, 'treasury::Treasury<')
|
|
423
425
|
}
|
|
424
426
|
|
|
425
|
-
static OP_WITHDRAW =
|
|
426
|
-
static OP_DEPOSIT =
|
|
427
|
-
static OP_RECEIVE =
|
|
427
|
+
static OP_WITHDRAW = 1;
|
|
428
|
+
static OP_DEPOSIT = 2;
|
|
429
|
+
static OP_RECEIVE = 4;
|
|
430
|
+
|
|
428
431
|
static MAX_WITHDRAW_GUARD_COUNT = 16;
|
|
429
432
|
}
|
|
430
433
|
|