wowok_agent 0.1.13 → 0.1.16
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/README.md +17 -0
- package/dist/124.index.js +1 -0
- package/dist/account.d.ts +38 -0
- package/dist/account.d.ts.map +1 -0
- package/dist/account.js +273 -0
- package/dist/agent/empty.d.ts +1 -0
- package/dist/agent/empty.d.ts.map +1 -0
- package/dist/agent/src/account.d.ts +38 -0
- package/dist/agent/src/account.d.ts.map +1 -0
- package/dist/agent/src/cache.d.ts +46 -0
- package/dist/agent/src/cache.d.ts.map +1 -0
- package/dist/agent/src/call/arbitration.d.ts +63 -0
- package/dist/agent/src/call/arbitration.d.ts.map +1 -0
- package/dist/agent/src/call/base.d.ts +34 -0
- package/dist/agent/src/call/base.d.ts.map +1 -0
- package/dist/agent/src/call/demand.d.ts +55 -0
- package/dist/agent/src/call/demand.d.ts.map +1 -0
- package/dist/agent/src/call/guard.d.ts +44 -0
- package/dist/agent/src/call/guard.d.ts.map +1 -0
- package/dist/agent/src/call/machine.d.ts +109 -0
- package/dist/agent/src/call/machine.d.ts.map +1 -0
- package/dist/agent/src/call/object_permission.d.ts +13 -0
- package/dist/agent/src/call/object_permission.d.ts.map +1 -0
- package/dist/agent/src/call/permission.d.ts +47 -0
- package/dist/agent/src/call/permission.d.ts.map +1 -0
- package/dist/agent/src/call/personal.d.ts +43 -0
- package/dist/agent/src/call/personal.d.ts.map +1 -0
- package/dist/agent/src/call/repository.d.ts +53 -0
- package/dist/agent/src/call/repository.d.ts.map +1 -0
- package/dist/agent/src/call/service.d.ts +134 -0
- package/dist/agent/src/call/service.d.ts.map +1 -0
- package/dist/agent/src/call/treasury.d.ts +53 -0
- package/dist/agent/src/call/treasury.d.ts.map +1 -0
- package/dist/agent/src/call.d.ts +24 -0
- package/dist/agent/src/call.d.ts.map +1 -0
- package/dist/agent/src/events.d.ts +65 -0
- package/dist/agent/src/events.d.ts.map +1 -0
- package/dist/agent/src/index.d.ts +19 -0
- package/dist/agent/src/index.d.ts.map +1 -0
- package/dist/agent/src/objects.d.ts +308 -0
- package/dist/agent/src/objects.d.ts.map +1 -0
- package/dist/agent/src/permission.d.ts +12 -0
- package/dist/agent/src/permission.d.ts.map +1 -0
- package/dist/agent/src/private_info.d.ts +26 -0
- package/dist/agent/src/private_info.d.ts.map +1 -0
- package/dist/cache.d.ts +46 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +59 -0
- package/dist/call/arbitration.d.ts +63 -0
- package/dist/call/arbitration.d.ts.map +1 -0
- package/dist/call/arbitration.js +182 -0
- package/dist/call/base.d.ts +34 -0
- package/dist/call/base.d.ts.map +1 -0
- package/dist/call/base.js +131 -0
- package/dist/call/demand.d.ts +55 -0
- package/dist/call/demand.d.ts.map +1 -0
- package/dist/call/demand.js +135 -0
- package/dist/call/guard.d.ts +44 -0
- package/dist/call/guard.d.ts.map +1 -0
- package/dist/call/guard.js +244 -0
- package/dist/call/machine.d.ts +109 -0
- package/dist/call/machine.d.ts.map +1 -0
- package/dist/call/machine.js +210 -0
- package/dist/call/object_permission.d.ts +13 -0
- package/dist/call/object_permission.d.ts.map +1 -0
- package/dist/call/object_permission.js +49 -0
- package/dist/call/permission.d.ts +47 -0
- package/dist/call/permission.d.ts.map +1 -0
- package/dist/call/permission.js +95 -0
- package/dist/call/personal.d.ts +43 -0
- package/dist/call/personal.d.ts.map +1 -0
- package/dist/call/personal.js +60 -0
- package/dist/call/repository.d.ts +53 -0
- package/dist/call/repository.d.ts.map +1 -0
- package/dist/call/repository.js +125 -0
- package/dist/call/service.d.ts +134 -0
- package/dist/call/service.d.ts.map +1 -0
- package/dist/call/service.js +340 -0
- package/dist/call/treasury.d.ts +53 -0
- package/dist/call/treasury.d.ts.map +1 -0
- package/dist/call/treasury.js +161 -0
- package/dist/call.d.ts +24 -0
- package/dist/call.d.ts.map +1 -0
- package/dist/call.js +58 -0
- package/dist/empty.d.ts +1 -0
- package/dist/empty.d.ts.map +1 -0
- package/dist/empty.js +1 -0
- package/dist/events.d.ts +65 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +59 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/objects.d.ts +308 -0
- package/dist/objects.d.ts.map +1 -0
- package/dist/objects.js +448 -0
- package/dist/permission.d.ts +12 -0
- package/dist/permission.d.ts.map +1 -0
- package/dist/permission.js +40 -0
- package/dist/private_info.d.ts +26 -0
- package/dist/private_info.d.ts.map +1 -0
- package/dist/private_info.js +243 -0
- package/dist/src/account.d.ts +38 -0
- package/dist/src/account.d.ts.map +1 -0
- package/dist/src/account.js +273 -0
- package/dist/src/cache.d.ts +46 -0
- package/dist/src/cache.d.ts.map +1 -0
- package/dist/src/cache.js +59 -0
- package/dist/src/call/arbitration.d.ts +63 -0
- package/dist/src/call/arbitration.d.ts.map +1 -0
- package/dist/src/call/arbitration.js +182 -0
- package/dist/src/call/base.d.ts +34 -0
- package/dist/src/call/base.d.ts.map +1 -0
- package/dist/src/call/base.js +131 -0
- package/dist/src/call/demand.d.ts +55 -0
- package/dist/src/call/demand.d.ts.map +1 -0
- package/dist/src/call/demand.js +135 -0
- package/dist/src/call/guard.d.ts +44 -0
- package/dist/src/call/guard.d.ts.map +1 -0
- package/dist/src/call/guard.js +244 -0
- package/dist/src/call/machine.d.ts +109 -0
- package/dist/src/call/machine.d.ts.map +1 -0
- package/dist/src/call/machine.js +210 -0
- package/dist/src/call/object_permission.d.ts +13 -0
- package/dist/src/call/object_permission.d.ts.map +1 -0
- package/dist/src/call/object_permission.js +49 -0
- package/dist/src/call/permission.d.ts +47 -0
- package/dist/src/call/permission.d.ts.map +1 -0
- package/dist/src/call/permission.js +95 -0
- package/dist/src/call/personal.d.ts +43 -0
- package/dist/src/call/personal.d.ts.map +1 -0
- package/dist/src/call/personal.js +60 -0
- package/dist/src/call/repository.d.ts +53 -0
- package/dist/src/call/repository.d.ts.map +1 -0
- package/dist/src/call/repository.js +125 -0
- package/dist/src/call/service.d.ts +134 -0
- package/dist/src/call/service.d.ts.map +1 -0
- package/dist/src/call/service.js +340 -0
- package/dist/src/call/treasury.d.ts +53 -0
- package/dist/src/call/treasury.d.ts.map +1 -0
- package/dist/src/call/treasury.js +161 -0
- package/dist/src/call.d.ts +24 -0
- package/dist/src/call.d.ts.map +1 -0
- package/dist/src/call.js +58 -0
- package/dist/src/events.d.ts +65 -0
- package/dist/src/events.d.ts.map +1 -0
- package/dist/src/events.js +59 -0
- package/dist/src/index.d.ts +19 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +18 -0
- package/dist/src/objects.d.ts +308 -0
- package/dist/src/objects.d.ts.map +1 -0
- package/dist/src/objects.js +448 -0
- package/dist/src/permission.d.ts +12 -0
- package/dist/src/permission.d.ts.map +1 -0
- package/dist/src/permission.js +40 -0
- package/dist/src/private_info.d.ts +26 -0
- package/dist/src/private_info.d.ts.map +1 -0
- package/dist/src/private_info.js +243 -0
- package/dist/webpack.config.d.ts +2 -0
- package/dist/webpack.config.d.ts.map +1 -0
- package/dist/webpack.config.js +17 -0
- package/dist/wowok/src/arbitration.d.ts +63 -0
- package/dist/wowok/src/arbitration.d.ts.map +1 -0
- package/dist/wowok/src/demand.d.ts +26 -0
- package/dist/wowok/src/demand.d.ts.map +1 -0
- package/dist/wowok/src/entity.d.ts +27 -0
- package/dist/wowok/src/entity.d.ts.map +1 -0
- package/dist/wowok/src/exception.d.ts +31 -0
- package/dist/wowok/src/exception.d.ts.map +1 -0
- package/dist/wowok/src/guard.d.ts +79 -0
- package/dist/wowok/src/guard.d.ts.map +1 -0
- package/dist/wowok/src/index.d.ts +35 -0
- package/dist/wowok/src/index.d.ts.map +1 -0
- package/dist/wowok/src/machine.d.ts +67 -0
- package/dist/wowok/src/machine.d.ts.map +1 -0
- package/dist/wowok/src/passport.d.ts +86 -0
- package/dist/wowok/src/passport.d.ts.map +1 -0
- package/dist/wowok/src/payment.d.ts +16 -0
- package/dist/wowok/src/payment.d.ts.map +1 -0
- package/dist/wowok/src/permission.d.ts +150 -0
- package/dist/wowok/src/permission.d.ts.map +1 -0
- package/dist/wowok/src/progress.d.ts +72 -0
- package/dist/wowok/src/progress.d.ts.map +1 -0
- package/dist/wowok/src/protocol.d.ts +226 -0
- package/dist/wowok/src/protocol.d.ts.map +1 -0
- package/dist/wowok/src/repository.d.ts +83 -0
- package/dist/wowok/src/repository.d.ts.map +1 -0
- package/dist/wowok/src/resource.d.ts +35 -0
- package/dist/wowok/src/resource.d.ts.map +1 -0
- package/dist/wowok/src/service.d.ts +138 -0
- package/dist/wowok/src/service.d.ts.map +1 -0
- package/dist/wowok/src/treasury.d.ts +55 -0
- package/dist/wowok/src/treasury.d.ts.map +1 -0
- package/dist/wowok/src/utils.d.ts +93 -0
- package/dist/wowok/src/utils.d.ts.map +1 -0
- package/dist/wowok/src/wowok.d.ts +15 -0
- package/dist/wowok/src/wowok.d.ts.map +1 -0
- package/dist/wowok_agent/empty.d.ts +1 -0
- package/dist/wowok_agent/empty.d.ts.map +1 -0
- package/dist/wowok_agent/src/account.d.ts +38 -0
- package/dist/wowok_agent/src/account.d.ts.map +1 -0
- package/dist/wowok_agent/src/cache.d.ts +46 -0
- package/dist/wowok_agent/src/cache.d.ts.map +1 -0
- package/dist/wowok_agent/src/call/arbitration.d.ts +63 -0
- package/dist/wowok_agent/src/call/arbitration.d.ts.map +1 -0
- package/dist/wowok_agent/src/call/base.d.ts +34 -0
- package/dist/wowok_agent/src/call/base.d.ts.map +1 -0
- package/dist/wowok_agent/src/call/demand.d.ts +55 -0
- package/dist/wowok_agent/src/call/demand.d.ts.map +1 -0
- package/dist/wowok_agent/src/call/guard.d.ts +44 -0
- package/dist/wowok_agent/src/call/guard.d.ts.map +1 -0
- package/dist/wowok_agent/src/call/machine.d.ts +109 -0
- package/dist/wowok_agent/src/call/machine.d.ts.map +1 -0
- package/dist/wowok_agent/src/call/object_permission.d.ts +13 -0
- package/dist/wowok_agent/src/call/object_permission.d.ts.map +1 -0
- package/dist/wowok_agent/src/call/permission.d.ts +47 -0
- package/dist/wowok_agent/src/call/permission.d.ts.map +1 -0
- package/dist/wowok_agent/src/call/personal.d.ts +43 -0
- package/dist/wowok_agent/src/call/personal.d.ts.map +1 -0
- package/dist/wowok_agent/src/call/repository.d.ts +53 -0
- package/dist/wowok_agent/src/call/repository.d.ts.map +1 -0
- package/dist/wowok_agent/src/call/service.d.ts +134 -0
- package/dist/wowok_agent/src/call/service.d.ts.map +1 -0
- package/dist/wowok_agent/src/call/treasury.d.ts +53 -0
- package/dist/wowok_agent/src/call/treasury.d.ts.map +1 -0
- package/dist/wowok_agent/src/call.d.ts +24 -0
- package/dist/wowok_agent/src/call.d.ts.map +1 -0
- package/dist/wowok_agent/src/events.d.ts +65 -0
- package/dist/wowok_agent/src/events.d.ts.map +1 -0
- package/dist/wowok_agent/src/index.d.ts +19 -0
- package/dist/wowok_agent/src/index.d.ts.map +1 -0
- package/dist/wowok_agent/src/objects.d.ts +308 -0
- package/dist/wowok_agent/src/objects.d.ts.map +1 -0
- package/dist/wowok_agent/src/permission.d.ts +12 -0
- package/dist/wowok_agent/src/permission.d.ts.map +1 -0
- package/dist/wowok_agent/src/private_info.d.ts +26 -0
- package/dist/wowok_agent/src/private_info.d.ts.map +1 -0
- package/empty.ts +0 -0
- package/package.json +12 -3
- package/src/account.ts +40 -37
- package/src/call/arbitration.ts +41 -19
- package/src/call/base.ts +14 -16
- package/src/call/demand.ts +8 -7
- package/src/call/guard.ts +2 -7
- package/src/call/machine.ts +56 -35
- package/src/call/repository.ts +17 -15
- package/src/call/service.ts +87 -55
- package/src/call/treasury.ts +11 -10
- package/src/call.ts +3 -3
- package/src/index.ts +1 -1
- package/tsconfig.json +6 -2
- package/webpack.config.cjs +26 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { IsValidArgType, TagName, IsValidAddress, Errors, ERROR, Permission, PermissionIndex, Service, Treasury, } from 'wowok';
|
|
2
|
+
import { query_objects } from '../objects';
|
|
3
|
+
import { CallBase } from "./base";
|
|
4
|
+
import { Account } from '../account';
|
|
5
|
+
export class CallService extends CallBase {
|
|
6
|
+
data;
|
|
7
|
+
constructor(data) {
|
|
8
|
+
super();
|
|
9
|
+
this.data = data;
|
|
10
|
+
}
|
|
11
|
+
async call(account) {
|
|
12
|
+
if (!this.data.type_parameter || !IsValidArgType(this.data.type_parameter)) {
|
|
13
|
+
ERROR(Errors.IsValidArgType, 'service.type_parameter');
|
|
14
|
+
}
|
|
15
|
+
var checkOwner = false;
|
|
16
|
+
const guards = [];
|
|
17
|
+
const perms = [];
|
|
18
|
+
var obj;
|
|
19
|
+
const permission_address = this.data?.permission?.address;
|
|
20
|
+
const object_address = this.data?.object?.address;
|
|
21
|
+
const treasury_address = this.data?.payee_treasury?.address;
|
|
22
|
+
if (permission_address && IsValidAddress(permission_address)) {
|
|
23
|
+
if (!this.data?.object) {
|
|
24
|
+
perms.push(PermissionIndex.service);
|
|
25
|
+
}
|
|
26
|
+
if (this.data?.description !== undefined && object_address) {
|
|
27
|
+
perms.push(PermissionIndex.service_description);
|
|
28
|
+
}
|
|
29
|
+
if (this.data?.bPaused !== undefined) {
|
|
30
|
+
perms.push(PermissionIndex.service_pause);
|
|
31
|
+
}
|
|
32
|
+
if (this.data?.bPublished) { // publish is an irreversible one-time operation
|
|
33
|
+
perms.push(PermissionIndex.service_publish);
|
|
34
|
+
}
|
|
35
|
+
if (this.data?.endpoint !== undefined) {
|
|
36
|
+
perms.push(PermissionIndex.service_endpoint);
|
|
37
|
+
}
|
|
38
|
+
if (this.data?.repository !== undefined) {
|
|
39
|
+
perms.push(PermissionIndex.service_repository);
|
|
40
|
+
}
|
|
41
|
+
if (this.data?.clone_new !== undefined) {
|
|
42
|
+
perms.push(PermissionIndex.service_clone);
|
|
43
|
+
}
|
|
44
|
+
if (this.data?.gen_discount !== undefined) {
|
|
45
|
+
perms.push(PermissionIndex.service_discount_transfer);
|
|
46
|
+
}
|
|
47
|
+
if (this.data?.arbitration !== undefined) {
|
|
48
|
+
perms.push(PermissionIndex.service_arbitration);
|
|
49
|
+
}
|
|
50
|
+
if (this.data?.buy_guard !== undefined) {
|
|
51
|
+
perms.push(PermissionIndex.service_buyer_guard);
|
|
52
|
+
}
|
|
53
|
+
if (this.data?.endpoint !== undefined) {
|
|
54
|
+
perms.push(PermissionIndex.service_endpoint);
|
|
55
|
+
}
|
|
56
|
+
if (this.data?.extern_withdraw_treasury !== undefined) {
|
|
57
|
+
perms.push(PermissionIndex.service_treasury);
|
|
58
|
+
}
|
|
59
|
+
if (this.data?.machine !== undefined) {
|
|
60
|
+
perms.push(PermissionIndex.service_machine);
|
|
61
|
+
}
|
|
62
|
+
if (treasury_address !== undefined && object_address) {
|
|
63
|
+
perms.push(PermissionIndex.service_payee);
|
|
64
|
+
}
|
|
65
|
+
if (this.data?.withdraw_guard !== undefined) {
|
|
66
|
+
perms.push(PermissionIndex.service_withdraw_guards);
|
|
67
|
+
}
|
|
68
|
+
if (this.data?.refund_guard !== undefined) {
|
|
69
|
+
perms.push(PermissionIndex.service_refund_guards);
|
|
70
|
+
}
|
|
71
|
+
if (this.data?.customer_required_info !== undefined) {
|
|
72
|
+
perms.push(PermissionIndex.service_customer_required);
|
|
73
|
+
}
|
|
74
|
+
if (this.data?.sales !== undefined) {
|
|
75
|
+
perms.push(PermissionIndex.service_sales);
|
|
76
|
+
}
|
|
77
|
+
if (this.data?.order_new?.guard !== undefined) {
|
|
78
|
+
if (IsValidAddress(this.data.order_new.guard)) {
|
|
79
|
+
guards.push(this.data.order_new.guard);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
if (!this.data.object) {
|
|
83
|
+
if (this.data?.buy_guard && IsValidAddress(this.data.buy_guard)) {
|
|
84
|
+
guards.push(this.data?.buy_guard);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
if (!obj) {
|
|
89
|
+
const r = await query_objects({ objects: [object_address], showContent: true });
|
|
90
|
+
if (r?.objects && r.objects[0].type === 'Service') {
|
|
91
|
+
obj = r.objects[0];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (obj?.buy_guard) {
|
|
95
|
+
guards.push(obj?.buy_guard);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (IsValidAddress(this.data?.order_refund?.guard)) {
|
|
101
|
+
guards.push(this.data?.order_refund?.guard);
|
|
102
|
+
}
|
|
103
|
+
if (this.data.order_withdrawl !== undefined) { // permission(may be guard) + withdraw_guard
|
|
104
|
+
perms.push(PermissionIndex.service_withdraw);
|
|
105
|
+
}
|
|
106
|
+
if (typeof (this.data?.order_withdrawl?.data?.withdraw_guard) === 'string' && IsValidAddress(this.data?.order_withdrawl?.data?.withdraw_guard)) {
|
|
107
|
+
guards.push(this.data?.order_withdrawl?.data?.withdraw_guard);
|
|
108
|
+
}
|
|
109
|
+
return await this.check_permission_and_call(permission_address, perms, guards, checkOwner, undefined, account);
|
|
110
|
+
}
|
|
111
|
+
return await this.exec(account);
|
|
112
|
+
}
|
|
113
|
+
async operate(txb, passport, account) {
|
|
114
|
+
let obj;
|
|
115
|
+
let permission;
|
|
116
|
+
let payee;
|
|
117
|
+
const permission_address = this.data?.permission?.address;
|
|
118
|
+
const object_address = this.data?.object?.address;
|
|
119
|
+
const treasury_address = this.data?.payee_treasury?.address;
|
|
120
|
+
if (!object_address) {
|
|
121
|
+
if (!permission_address || !IsValidAddress(permission_address)) {
|
|
122
|
+
const d = this.data?.permission?.description ?? '';
|
|
123
|
+
permission = Permission.New(txb, d);
|
|
124
|
+
}
|
|
125
|
+
if (!treasury_address || !IsValidAddress(treasury_address)) {
|
|
126
|
+
const d = this.data?.payee_treasury?.description ?? '';
|
|
127
|
+
payee = Treasury.New(txb, this.data?.type_parameter, permission ?? permission_address, d, permission ? undefined : passport);
|
|
128
|
+
}
|
|
129
|
+
obj = Service.New(txb, this.data.type_parameter, permission ? permission.get_object() : permission_address, this.data?.description ?? '', payee ? payee.get_object() : treasury_address, permission ? undefined : passport);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
if (IsValidAddress(object_address) && this.data.type_parameter && permission_address && IsValidAddress(permission_address)) {
|
|
133
|
+
obj = Service.From(txb, this.data.type_parameter, permission_address, object_address);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
ERROR(Errors.InvalidParam, 'object or permission address invalid.');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (obj) {
|
|
140
|
+
//const perm = permission ? permission.get_object() : permission_address;
|
|
141
|
+
const pst = permission ? undefined : passport;
|
|
142
|
+
if (this.data?.description !== undefined && object_address) {
|
|
143
|
+
obj?.set_description(this.data.description, pst);
|
|
144
|
+
}
|
|
145
|
+
if (this.data?.endpoint !== undefined) {
|
|
146
|
+
obj?.set_endpoint(this.data.endpoint, pst);
|
|
147
|
+
}
|
|
148
|
+
if (this.data?.payee_treasury !== undefined && object_address) {
|
|
149
|
+
obj?.set_payee(treasury_address, pst);
|
|
150
|
+
}
|
|
151
|
+
if (this.data?.gen_discount !== undefined) {
|
|
152
|
+
obj?.discount_transfer(this.data.gen_discount, pst);
|
|
153
|
+
}
|
|
154
|
+
if (this.data?.repository !== undefined) {
|
|
155
|
+
switch (this.data.repository.op) {
|
|
156
|
+
case 'add':
|
|
157
|
+
this.data.repository.repositories.forEach(v => obj?.add_repository(v, pst));
|
|
158
|
+
break;
|
|
159
|
+
case 'remove':
|
|
160
|
+
obj?.remove_repository(this.data.repository.repositories, false, pst);
|
|
161
|
+
break;
|
|
162
|
+
case 'set':
|
|
163
|
+
obj?.remove_repository([], true, pst);
|
|
164
|
+
this.data.repository.repositories.forEach(v => obj?.add_repository(v, pst));
|
|
165
|
+
break;
|
|
166
|
+
case 'removeall':
|
|
167
|
+
obj?.remove_repository([], true, pst);
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (this.data?.extern_withdraw_treasury !== undefined) {
|
|
172
|
+
switch (this.data.extern_withdraw_treasury.op) {
|
|
173
|
+
case 'add':
|
|
174
|
+
this.data.extern_withdraw_treasury.treasuries.forEach(v => obj?.add_treasury(v.token_type, v.address, pst));
|
|
175
|
+
break;
|
|
176
|
+
case 'set':
|
|
177
|
+
obj?.remove_treasury([], true, pst);
|
|
178
|
+
this.data.extern_withdraw_treasury.treasuries.forEach(v => obj?.add_treasury(v.token_type, v.address, pst));
|
|
179
|
+
break;
|
|
180
|
+
case 'remove':
|
|
181
|
+
obj?.remove_treasury(this.data.extern_withdraw_treasury.addresses, false, pst);
|
|
182
|
+
break;
|
|
183
|
+
case 'removeall':
|
|
184
|
+
obj?.remove_treasury([], false, pst);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (this.data?.machine !== undefined) {
|
|
189
|
+
obj?.set_machine(this.data.machine, pst);
|
|
190
|
+
}
|
|
191
|
+
if (this.data?.arbitration !== undefined) {
|
|
192
|
+
switch (this.data.arbitration.op) {
|
|
193
|
+
case 'add':
|
|
194
|
+
this.data.arbitration.arbitrations.forEach(v => obj?.add_arbitration(v.address, v.type_parameter, pst));
|
|
195
|
+
break;
|
|
196
|
+
case 'set':
|
|
197
|
+
obj?.remove_arbitration([], true, pst);
|
|
198
|
+
this.data.arbitration.arbitrations.forEach(v => obj?.add_arbitration(v.address, v.type_parameter, pst));
|
|
199
|
+
break;
|
|
200
|
+
case 'remove':
|
|
201
|
+
obj?.remove_arbitration(this.data.arbitration.addresses, false, pst);
|
|
202
|
+
break;
|
|
203
|
+
case 'removeall':
|
|
204
|
+
obj?.remove_arbitration([], false, pst);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (this.data?.customer_required_info !== undefined) {
|
|
209
|
+
if (this.data.customer_required_info.required_info && this.data.customer_required_info.pubkey) {
|
|
210
|
+
obj?.set_customer_required(this.data.customer_required_info.pubkey, this.data.customer_required_info.required_info, pst);
|
|
211
|
+
}
|
|
212
|
+
else if (this.data.customer_required_info.pubkey) {
|
|
213
|
+
obj?.change_required_pubkey(this.data.customer_required_info.pubkey, pst);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (this.data?.sales !== undefined) {
|
|
217
|
+
switch (this.data.sales.op) {
|
|
218
|
+
case 'add':
|
|
219
|
+
obj?.add_sales(this.data.sales.sales, false, pst);
|
|
220
|
+
break;
|
|
221
|
+
case 'remove':
|
|
222
|
+
obj?.remove_sales(this.data.sales.sales_name, pst);
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (this.data?.withdraw_guard !== undefined) {
|
|
227
|
+
switch (this.data.withdraw_guard.op) {
|
|
228
|
+
case 'add':
|
|
229
|
+
obj?.add_withdraw_guards(this.data.withdraw_guard.guards, pst);
|
|
230
|
+
break;
|
|
231
|
+
case 'set':
|
|
232
|
+
obj?.remove_withdraw_guards([], true, pst);
|
|
233
|
+
obj?.add_withdraw_guards(this.data.withdraw_guard.guards, pst);
|
|
234
|
+
break;
|
|
235
|
+
case 'remove':
|
|
236
|
+
obj?.remove_withdraw_guards(this.data.withdraw_guard.addresses, false, pst);
|
|
237
|
+
break;
|
|
238
|
+
case 'removeall':
|
|
239
|
+
obj?.remove_withdraw_guards([], true, pst);
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (this.data?.refund_guard !== undefined) {
|
|
244
|
+
switch (this.data.refund_guard.op) {
|
|
245
|
+
case 'add':
|
|
246
|
+
obj?.add_refund_guards(this.data.refund_guard.guards, pst);
|
|
247
|
+
break;
|
|
248
|
+
case 'set':
|
|
249
|
+
obj?.remove_refund_guards([], true, pst);
|
|
250
|
+
obj?.add_refund_guards(this.data.refund_guard.guards, pst);
|
|
251
|
+
break;
|
|
252
|
+
case 'remove':
|
|
253
|
+
obj?.remove_refund_guards(this.data.refund_guard.addresses, false, pst);
|
|
254
|
+
break;
|
|
255
|
+
case 'removeall':
|
|
256
|
+
obj?.remove_refund_guards([], true, pst);
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (this.data?.bPublished) {
|
|
261
|
+
obj?.publish(pst);
|
|
262
|
+
}
|
|
263
|
+
var order_new;
|
|
264
|
+
if (this.data?.order_new !== undefined) {
|
|
265
|
+
let b = BigInt(0);
|
|
266
|
+
let coin;
|
|
267
|
+
this.data.order_new.buy_items.forEach(v => {
|
|
268
|
+
b += BigInt(v.max_price) * BigInt(v.count);
|
|
269
|
+
});
|
|
270
|
+
if (b > BigInt(0)) {
|
|
271
|
+
const coin = await Account.Instance().get_coin_object(txb, b, account, this.data.type_parameter);
|
|
272
|
+
if (coin) {
|
|
273
|
+
//@ crypto tools support
|
|
274
|
+
order_new = obj.order(this.data.order_new.buy_items, coin, this.data.order_new.discount, this.data.order_new.machine, this.data.order_new.customer_info_crypto, pst);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (this.data?.order_agent !== undefined) {
|
|
279
|
+
const o = this.data.order_agent.order ?? order_new?.order;
|
|
280
|
+
if (!o)
|
|
281
|
+
ERROR(Errors.Fail, 'order invalid: order_agent');
|
|
282
|
+
obj?.set_order_agent(o, this.data.order_agent.agents, this.data.order_agent.progress);
|
|
283
|
+
}
|
|
284
|
+
if (this.data?.order_required_info !== undefined) {
|
|
285
|
+
const o = this.data.order_required_info.order ?? order_new?.order;
|
|
286
|
+
if (!o)
|
|
287
|
+
ERROR(Errors.Fail, 'order invalid: order_required_info');
|
|
288
|
+
obj?.update_order_required_info(o, this.data.order_required_info.info);
|
|
289
|
+
}
|
|
290
|
+
if (this.data?.order_refund !== undefined) {
|
|
291
|
+
const o = this.data.order_refund.order ?? order_new?.order;
|
|
292
|
+
if (!o)
|
|
293
|
+
ERROR(Errors.Fail, 'order invalid: order_refund');
|
|
294
|
+
if (this.data?.order_refund?.arb && this.data?.order_refund?.arb_token_type) {
|
|
295
|
+
obj?.refund_withArb(o, this.data?.order_refund?.arb, this.data?.order_refund?.arb_token_type);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
obj?.refund(o, this.data?.order_refund?.guard, pst);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (this.data?.order_withdrawl !== undefined && pst) { //@ need withdrawal pst
|
|
302
|
+
const o = this.data.order_withdrawl.order ?? order_new?.order;
|
|
303
|
+
if (!o)
|
|
304
|
+
ERROR(Errors.Fail, 'order invalid: order_withdrawl');
|
|
305
|
+
obj?.withdraw(o, this.data.order_withdrawl.data, pst);
|
|
306
|
+
}
|
|
307
|
+
if (this.data?.order_payer !== undefined && obj) {
|
|
308
|
+
const o = this.data.order_payer.order ?? order_new?.order;
|
|
309
|
+
if (!o)
|
|
310
|
+
ERROR(Errors.Fail, 'order invalid: order_payer');
|
|
311
|
+
obj?.change_order_payer(o, this.data.order_payer.payer_new, this.data.order_payer.progress);
|
|
312
|
+
}
|
|
313
|
+
if (order_new && this?.data?.order_new) {
|
|
314
|
+
const buy = obj.order_launch(order_new);
|
|
315
|
+
await this.new_with_mark(txb, buy.order, this.data?.order_new?.namedNewOrder, account, [TagName.Launch, TagName.Order]);
|
|
316
|
+
if (buy?.progress) {
|
|
317
|
+
await this.new_with_mark(txb, buy.progress, this.data?.order_new?.namedNewProgress, account, [TagName.Launch]);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (this.data?.buy_guard !== undefined) {
|
|
321
|
+
obj?.set_buy_guard(this.data.buy_guard, pst);
|
|
322
|
+
}
|
|
323
|
+
if (this.data?.bPaused !== undefined) {
|
|
324
|
+
obj?.pause(this.data.bPaused, pst);
|
|
325
|
+
}
|
|
326
|
+
if (this.data?.clone_new !== undefined && obj) {
|
|
327
|
+
await this.new_with_mark(txb, obj.clone(this.data.clone_new?.token_type_new, true, pst), this.data?.clone_new?.namedNew, account);
|
|
328
|
+
}
|
|
329
|
+
if (payee) {
|
|
330
|
+
await this.new_with_mark(txb, payee.launch(), this.data?.payee_treasury?.namedNew, account);
|
|
331
|
+
}
|
|
332
|
+
if (permission) {
|
|
333
|
+
await this.new_with_mark(txb, permission.launch(), this.data?.permission?.namedNew, account);
|
|
334
|
+
}
|
|
335
|
+
if (!object_address) {
|
|
336
|
+
await this.new_with_mark(txb, obj.launch(), this.data?.object?.namedNew, account);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { TransactionBlock, PassportObject, Treasury_WithdrawMode, WithdrawParam } from 'wowok';
|
|
2
|
+
import { CallBase, CallResult, Namedbject } from "./base";
|
|
3
|
+
export interface CallTreasury_Data {
|
|
4
|
+
type_parameter: string;
|
|
5
|
+
object?: {
|
|
6
|
+
address: string;
|
|
7
|
+
} | {
|
|
8
|
+
namedNew: Namedbject;
|
|
9
|
+
};
|
|
10
|
+
permission?: {
|
|
11
|
+
address: string;
|
|
12
|
+
} | {
|
|
13
|
+
namedNew: Namedbject;
|
|
14
|
+
description?: string;
|
|
15
|
+
};
|
|
16
|
+
description?: string;
|
|
17
|
+
deposit?: {
|
|
18
|
+
data: {
|
|
19
|
+
balance: string | number;
|
|
20
|
+
index?: number;
|
|
21
|
+
remark?: string;
|
|
22
|
+
for_object?: string;
|
|
23
|
+
for_guard?: string;
|
|
24
|
+
};
|
|
25
|
+
guard?: string | 'fetch';
|
|
26
|
+
};
|
|
27
|
+
receive?: {
|
|
28
|
+
payment: string;
|
|
29
|
+
received_object: string;
|
|
30
|
+
};
|
|
31
|
+
withdraw?: WithdrawParam;
|
|
32
|
+
deposit_guard?: string;
|
|
33
|
+
withdraw_guard?: {
|
|
34
|
+
op: 'add' | 'set';
|
|
35
|
+
data: {
|
|
36
|
+
guard: string;
|
|
37
|
+
amount: string | number;
|
|
38
|
+
}[];
|
|
39
|
+
} | {
|
|
40
|
+
op: 'remove';
|
|
41
|
+
guards: string[];
|
|
42
|
+
} | {
|
|
43
|
+
op: 'removeall';
|
|
44
|
+
};
|
|
45
|
+
withdraw_mode?: Treasury_WithdrawMode;
|
|
46
|
+
}
|
|
47
|
+
export declare class CallTreasury extends CallBase {
|
|
48
|
+
data: CallTreasury_Data;
|
|
49
|
+
constructor(data: CallTreasury_Data);
|
|
50
|
+
call(account?: string): Promise<CallResult>;
|
|
51
|
+
protected operate(txb: TransactionBlock, passport?: PassportObject, account?: string): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=treasury.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treasury.d.ts","sourceRoot":"","sources":["../../src/call/treasury.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAkB,cAAc,EACtB,qBAAqB,EAAE,aAAa,EACtE,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAI1D,MAAM,WAAW,iBAAiB;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE;QAAC,OAAO,EAAC,MAAM,CAAA;KAAC,GAAG;QAAC,QAAQ,EAAE,UAAU,CAAA;KAAC,CAAC;IACnD,UAAU,CAAC,EAAE;QAAC,OAAO,EAAC,MAAM,CAAA;KAAC,GAAG;QAAC,QAAQ,EAAE,UAAU,CAAC;QAAC,WAAW,CAAC,EAAC,MAAM,CAAA;KAAC,CAAC;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE;QAAC,IAAI,EAAC;YAAC,OAAO,EAAC,MAAM,GAAC,MAAM,CAAC;YAAC,KAAK,CAAC,EAAC,MAAM,CAAC;YAAC,MAAM,CAAC,EAAC,MAAM,CAAC;YAAC,UAAU,CAAC,EAAC,MAAM,CAAC;YAAC,SAAS,CAAC,EAAC,MAAM,CAAA;SAAC,CAAC;QAAC,KAAK,CAAC,EAAC,MAAM,GAAG,OAAO,CAAA;KAAC,CAAC;IACxI,OAAO,CAAC,EAAE;QAAC,OAAO,EAAC,MAAM,CAAC;QAAC,eAAe,EAAC,MAAM,CAAA;KAAC,CAAC;IACnD,QAAQ,CAAC,EAAC,aAAa,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE;QAAC,EAAE,EAAC,KAAK,GAAG,KAAK,CAAC;QAAC,IAAI,EAAC;YAAC,KAAK,EAAC,MAAM,CAAC;YAAC,MAAM,EAAC,MAAM,GAAC,MAAM,CAAA;SAAC,EAAE,CAAA;KAAC,GAAG;QAAC,EAAE,EAAC,QAAQ,CAAC;QAAC,MAAM,EAAC,MAAM,EAAE,CAAA;KAAC,GAAG;QAAC,EAAE,EAAC,WAAW,CAAA;KAAC,CAAC;IACrI,aAAa,CAAC,EAAE,qBAAqB,CAAC;CACzC;AACD,qBAAa,YAAa,SAAQ,QAAQ;IACtC,IAAI,EAAE,iBAAiB,CAAC;gBACZ,IAAI,EAAC,iBAAiB;IAK5B,IAAI,CAAC,OAAO,CAAC,EAAC,MAAM,GAAI,OAAO,CAAC,UAAU,CAAC;cA2EjC,OAAO,CAAE,GAAG,EAAC,gBAAgB,EAAE,QAAQ,CAAC,EAAC,cAAc,EAAE,OAAO,CAAC,EAAC,MAAM;CAwE3F"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { IsValidArgType, IsValidAddress, Errors, ERROR, Permission, PermissionIndex, Treasury, } from 'wowok';
|
|
2
|
+
import { query_objects } from '../objects';
|
|
3
|
+
import { CallBase } from "./base";
|
|
4
|
+
import { Account } from '../account';
|
|
5
|
+
export class CallTreasury extends CallBase {
|
|
6
|
+
data;
|
|
7
|
+
constructor(data) {
|
|
8
|
+
super();
|
|
9
|
+
this.data = data;
|
|
10
|
+
}
|
|
11
|
+
async call(account) {
|
|
12
|
+
if (!this.data.type_parameter || !IsValidArgType(this.data.type_parameter)) {
|
|
13
|
+
ERROR(Errors.IsValidArgType, 'treasury.type_parameter');
|
|
14
|
+
}
|
|
15
|
+
var checkOwner = false;
|
|
16
|
+
const guards = [];
|
|
17
|
+
const perms = [];
|
|
18
|
+
var obj;
|
|
19
|
+
const permission_address = this.data?.permission?.address;
|
|
20
|
+
const object_address = this.data?.object?.address;
|
|
21
|
+
if (permission_address && IsValidAddress(permission_address)) {
|
|
22
|
+
if (!this.data?.object) {
|
|
23
|
+
perms.push(PermissionIndex.treasury);
|
|
24
|
+
}
|
|
25
|
+
if (this.data?.description !== undefined && object_address) {
|
|
26
|
+
perms.push(PermissionIndex.treasury_descritption);
|
|
27
|
+
}
|
|
28
|
+
if (this.data?.withdraw_mode !== undefined) {
|
|
29
|
+
perms.push(PermissionIndex.treasury_withdraw_mode);
|
|
30
|
+
}
|
|
31
|
+
if (this.data?.withdraw_guard == undefined) { // publish is an irreversible one-time operation
|
|
32
|
+
perms.push(PermissionIndex.treasury_withdraw_guard);
|
|
33
|
+
}
|
|
34
|
+
if (this.data?.deposit_guard !== undefined) {
|
|
35
|
+
perms.push(PermissionIndex.treasury_deposit_guard);
|
|
36
|
+
}
|
|
37
|
+
if (this.data?.deposit_guard !== undefined) {
|
|
38
|
+
perms.push(PermissionIndex.treasury_deposit_guard);
|
|
39
|
+
}
|
|
40
|
+
if (this.data?.deposit?.guard !== undefined) {
|
|
41
|
+
if (IsValidAddress(this.data.deposit.guard)) {
|
|
42
|
+
guards.push(this.data.deposit.guard);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
if (!this.data.object) {
|
|
46
|
+
if (this.data?.deposit_guard && IsValidAddress(this.data?.deposit_guard)) {
|
|
47
|
+
guards.push(this.data.deposit_guard);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
if (!obj) {
|
|
52
|
+
const r = await query_objects({ objects: [object_address], showContent: true });
|
|
53
|
+
if (r?.objects && r.objects[0].type === 'Treasury') {
|
|
54
|
+
obj = r.objects[0];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (obj?.deposit_guard) {
|
|
58
|
+
guards.push(obj?.deposit_guard);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (this.data?.receive !== undefined) {
|
|
64
|
+
perms.push(PermissionIndex.treasury_receive);
|
|
65
|
+
}
|
|
66
|
+
if (this.data?.withdraw?.withdraw_guard !== undefined) {
|
|
67
|
+
if (typeof (this.data.withdraw.withdraw_guard) === 'string' && IsValidAddress(this.data.withdraw.withdraw_guard)) {
|
|
68
|
+
guards.push(this.data.withdraw.withdraw_guard);
|
|
69
|
+
}
|
|
70
|
+
else if (this.data.object) {
|
|
71
|
+
if (!obj) {
|
|
72
|
+
const r = await query_objects({ objects: [object_address], showContent: true });
|
|
73
|
+
if (r?.objects && r.objects[0].type === 'Treasury') {
|
|
74
|
+
obj = r.objects[0];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (typeof (obj?.withdraw_guard) === 'string') {
|
|
78
|
+
guards.push(obj?.withdraw_guard);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
perms.push(PermissionIndex.treasury_withdraw);
|
|
84
|
+
}
|
|
85
|
+
return await this.check_permission_and_call(permission_address, perms, guards, checkOwner, undefined, account);
|
|
86
|
+
}
|
|
87
|
+
return await this.exec(account);
|
|
88
|
+
}
|
|
89
|
+
async operate(txb, passport, account) {
|
|
90
|
+
let obj;
|
|
91
|
+
let permission;
|
|
92
|
+
const permission_address = this.data?.permission?.address;
|
|
93
|
+
const object_address = this.data?.object?.address;
|
|
94
|
+
if (!object_address) {
|
|
95
|
+
if (!permission_address || !IsValidAddress(permission_address)) {
|
|
96
|
+
const d = this.data?.permission?.description ?? '';
|
|
97
|
+
permission = Permission.New(txb, d);
|
|
98
|
+
}
|
|
99
|
+
obj = Treasury.New(txb, this.data.type_parameter, permission ? permission.get_object() : permission_address, this.data?.description ?? '', permission ? undefined : passport);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
if (IsValidAddress(object_address) && this.data.type_parameter && permission_address && IsValidAddress(permission_address)) {
|
|
103
|
+
obj = Treasury.From(txb, this.data.type_parameter, permission_address, object_address);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
ERROR(Errors.InvalidParam, 'object or permission address invalid.');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (obj) {
|
|
110
|
+
const pst = permission ? undefined : passport;
|
|
111
|
+
if (this.data?.description !== undefined && object_address) {
|
|
112
|
+
obj?.set_description(this.data.description, pst);
|
|
113
|
+
}
|
|
114
|
+
if (this.data.deposit !== undefined) {
|
|
115
|
+
const coin = await Account.Instance().get_coin_object(txb, this.data.deposit.data.balance, account, this.data.type_parameter);
|
|
116
|
+
if (coin) {
|
|
117
|
+
const index = this.data.deposit.data?.index ?? 0;
|
|
118
|
+
obj?.deposit({ coin: coin, index: BigInt(index), remark: this.data.deposit.data.remark ?? '',
|
|
119
|
+
for_guard: this.data.deposit.data?.for_guard,
|
|
120
|
+
for_object: this.data.deposit.data?.for_object
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (this.data?.receive !== undefined) {
|
|
125
|
+
obj?.receive(this.data.receive.payment, this.data.receive.received_object, pst);
|
|
126
|
+
}
|
|
127
|
+
if (this.data?.withdraw !== undefined) {
|
|
128
|
+
obj?.withdraw(this.data.withdraw, pst);
|
|
129
|
+
}
|
|
130
|
+
if (this.data?.deposit_guard !== undefined) {
|
|
131
|
+
obj?.set_deposit_guard(this.data.deposit_guard, pst);
|
|
132
|
+
}
|
|
133
|
+
if (this.data?.withdraw_guard !== undefined) {
|
|
134
|
+
switch (this.data.withdraw_guard.op) {
|
|
135
|
+
case 'add':
|
|
136
|
+
this.data.withdraw_guard.data.forEach(v => obj?.add_withdraw_guard(v.guard, BigInt(v.amount), pst));
|
|
137
|
+
break;
|
|
138
|
+
case 'remove':
|
|
139
|
+
obj?.remove_withdraw_guard(this.data.withdraw_guard.guards, false, pst);
|
|
140
|
+
break;
|
|
141
|
+
case 'set':
|
|
142
|
+
obj?.remove_withdraw_guard([], true, pst);
|
|
143
|
+
this.data.withdraw_guard.data.forEach(v => obj?.add_withdraw_guard(v.guard, BigInt(v.amount), pst));
|
|
144
|
+
break;
|
|
145
|
+
case 'removeall':
|
|
146
|
+
obj?.remove_withdraw_guard([], true, pst);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (this.data?.withdraw_mode !== undefined) {
|
|
151
|
+
obj?.set_withdraw_mode(this.data.withdraw_mode, pst);
|
|
152
|
+
}
|
|
153
|
+
if (permission) {
|
|
154
|
+
await this.new_with_mark(txb, permission.launch(), this.data?.permission?.namedNew, account);
|
|
155
|
+
}
|
|
156
|
+
if (!object_address) {
|
|
157
|
+
await this.new_with_mark(txb, obj.launch(), this.data?.object?.namedNew, account);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
package/dist/call.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provide an operate interface for AI
|
|
3
|
+
* Restrictive prioritization, such as setting a deposit first and setting a deposit guard later (only subsequent deposits are affected).
|
|
4
|
+
*/
|
|
5
|
+
import { CallArbitration_Data } from "./call/arbitration";
|
|
6
|
+
import { CallDemand_Data } from "./call/demand";
|
|
7
|
+
import { CallMachine_Data } from "./call/machine";
|
|
8
|
+
import { CallPermission_Data } from "./call/permission";
|
|
9
|
+
import { CallRepository_Data } from "./call/repository";
|
|
10
|
+
import { CallService_Data } from "./call/service";
|
|
11
|
+
import { CallTreasury_Data } from "./call/treasury";
|
|
12
|
+
import { CallResult, GuardInfo_forCall } from "./call/base";
|
|
13
|
+
import { CallObjectPermission_Data } from "./call/object_permission";
|
|
14
|
+
export type CallObjectType = 'Demand' | 'Service' | 'Machine' | 'Treasury' | 'Arbitration' | 'Guard' | 'Repository' | 'Personal' | 'Permission' | 'ObjectPermission';
|
|
15
|
+
export type CallObjectData = CallDemand_Data | CallMachine_Data | CallArbitration_Data | CallPermission_Data | CallObjectPermission_Data | CallTreasury_Data | CallService_Data | CallRepository_Data;
|
|
16
|
+
export interface CallObject {
|
|
17
|
+
type: CallObjectType;
|
|
18
|
+
data: CallObjectData;
|
|
19
|
+
account?: string;
|
|
20
|
+
witness?: GuardInfo_forCall;
|
|
21
|
+
}
|
|
22
|
+
export declare const call_object_json: (json: string) => Promise<string>;
|
|
23
|
+
export declare const call_object: (call: CallObject) => Promise<CallResult>;
|
|
24
|
+
//# sourceMappingURL=call.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../src/call.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,EAAmB,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAe,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAkB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAe,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAgB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAY,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAwB,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAE3F,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,GAAG,OAAO,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,GAAG,kBAAkB,CAAC;AACrK,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,gBAAgB,GAAG,oBAAoB,GAAG,mBAAmB,GAAG,yBAAyB,GACtI,iBAAiB,GAAG,gBAAgB,GAAI,mBAAmB,CAAC;AAC9D,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,iBAAiB,CAAC;CAC/B;AAED,eAAO,MAAM,gBAAgB,GAAU,MAAM,MAAM,KAAI,OAAO,CAAC,MAAM,CAOpE,CAAA;AAED,eAAO,MAAM,WAAW,GAAU,MAAM,UAAU,KAAI,OAAO,CAAC,UAAU,CAUvE,CAAA"}
|
package/dist/call.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provide an operate interface for AI
|
|
3
|
+
* Restrictive prioritization, such as setting a deposit first and setting a deposit guard later (only subsequent deposits are affected).
|
|
4
|
+
*/
|
|
5
|
+
import { CallArbitration } from "./call/arbitration";
|
|
6
|
+
import { CallDemand } from "./call/demand";
|
|
7
|
+
import { CallMachine } from "./call/machine";
|
|
8
|
+
import { CallPermission } from "./call/permission";
|
|
9
|
+
import { CallPersonal } from "./call/personal";
|
|
10
|
+
import { CallRepository } from "./call/repository";
|
|
11
|
+
import { CallService } from "./call/service";
|
|
12
|
+
import { CallTreasury } from "./call/treasury";
|
|
13
|
+
import { CallGuard } from "./call/guard";
|
|
14
|
+
import { CallObjectPermission } from "./call/object_permission";
|
|
15
|
+
export const call_object_json = async (json) => {
|
|
16
|
+
try {
|
|
17
|
+
const c = JSON.parse(json);
|
|
18
|
+
return JSON.stringify({ data: await call_object(c) });
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
return JSON.stringify({ error: e?.toString() });
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export const call_object = async (call) => {
|
|
25
|
+
var obj = call_object_new(call);
|
|
26
|
+
if (obj) {
|
|
27
|
+
if (call.witness) {
|
|
28
|
+
return obj.call_with_witness(call.witness, call.account);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return obj.call(call.account);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function call_object_new(call) {
|
|
36
|
+
switch (call.type) {
|
|
37
|
+
case 'Demand':
|
|
38
|
+
return new CallDemand(call.data);
|
|
39
|
+
case 'Service':
|
|
40
|
+
return new CallService(call.data);
|
|
41
|
+
case 'Machine':
|
|
42
|
+
return new CallMachine(call.data);
|
|
43
|
+
case 'Treasury':
|
|
44
|
+
return new CallTreasury(call.data);
|
|
45
|
+
case 'Arbitration':
|
|
46
|
+
return new CallArbitration(call.data);
|
|
47
|
+
case 'Guard':
|
|
48
|
+
return new CallGuard(call.data);
|
|
49
|
+
case 'Repository':
|
|
50
|
+
return new CallRepository(call.data);
|
|
51
|
+
case 'Personal':
|
|
52
|
+
return new CallPersonal(call.data);
|
|
53
|
+
case 'Permission':
|
|
54
|
+
return new CallPermission(call.data);
|
|
55
|
+
case 'ObjectPermission':
|
|
56
|
+
return new CallObjectPermission(call.data);
|
|
57
|
+
}
|
|
58
|
+
}
|
package/dist/empty.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=empty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../empty.ts"],"names":[],"mappings":""}
|
package/dist/empty.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|