wowok_agent 1.3.47 → 1.3.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/call/arbitration.d.ts +4 -3
- package/dist/call/arbitration.d.ts.map +1 -1
- package/dist/call/arbitration.js +134 -131
- package/dist/call/arbitration.js.map +1 -1
- package/dist/call/base.d.ts +15 -7
- package/dist/call/base.d.ts.map +1 -1
- package/dist/call/base.js +21 -23
- package/dist/call/base.js.map +1 -1
- package/dist/call/call.d.ts +0 -6
- package/dist/call/call.d.ts.map +1 -1
- package/dist/call/demand.d.ts +1 -0
- package/dist/call/demand.d.ts.map +1 -1
- package/dist/call/demand.js +86 -80
- package/dist/call/demand.js.map +1 -1
- package/dist/call/machine.d.ts +10 -10
- package/dist/call/machine.d.ts.map +1 -1
- package/dist/call/machine.js +174 -146
- package/dist/call/machine.js.map +1 -1
- package/dist/call/permission.d.ts +10 -9
- package/dist/call/permission.d.ts.map +1 -1
- package/dist/call/permission.js +90 -85
- package/dist/call/permission.js.map +1 -1
- package/dist/call/personal.d.ts +3 -3
- package/dist/call/personal.d.ts.map +1 -1
- package/dist/call/personal.js +6 -12
- package/dist/call/personal.js.map +1 -1
- package/dist/call/repository.d.ts +24 -8
- package/dist/call/repository.d.ts.map +1 -1
- package/dist/call/repository.js +114 -94
- package/dist/call/repository.js.map +1 -1
- package/dist/call/service.d.ts +15 -26
- package/dist/call/service.d.ts.map +1 -1
- package/dist/call/service.js +274 -264
- package/dist/call/service.js.map +1 -1
- package/dist/call/treasury.d.ts +5 -7
- package/dist/call/treasury.d.ts.map +1 -1
- package/dist/call/treasury.js +108 -97
- package/dist/call/treasury.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/query/objects.d.ts +2 -1
- package/dist/query/objects.d.ts.map +1 -1
- package/dist/query/objects.js +7 -7
- package/dist/query/objects.js.map +1 -1
- package/dist/query/owned.d.ts +2 -0
- package/dist/query/owned.d.ts.map +1 -0
- package/dist/query/owned.js +2 -0
- package/dist/query/owned.js.map +1 -0
- package/dist/query/permission.d.ts +3 -2
- package/dist/query/permission.d.ts.map +1 -1
- package/dist/query/permission.js +6 -3
- package/dist/query/permission.js.map +1 -1
- package/dist/query/treasury_received.d.ts +14 -0
- package/dist/query/treasury_received.d.ts.map +1 -0
- package/dist/query/treasury_received.js +19 -0
- package/dist/query/treasury_received.js.map +1 -0
- package/package.json +1 -1
- package/src/call/arbitration.ts +144 -141
- package/src/call/base.ts +27 -29
- package/src/call/call.ts +6 -6
- package/src/call/demand.ts +89 -81
- package/src/call/machine.ts +184 -145
- package/src/call/permission.ts +98 -90
- package/src/call/personal.ts +8 -13
- package/src/call/repository.ts +138 -95
- package/src/call/service.ts +290 -272
- package/src/call/treasury.ts +110 -99
- package/src/index.ts +1 -0
- package/src/query/objects.ts +10 -10
- package/src/query/permission.ts +9 -6
- package/src/query/treasury_received.ts +35 -0
- package/tsconfig.tsbuildinfo +1 -1
package/src/call/base.ts
CHANGED
|
@@ -34,36 +34,41 @@ export interface TypeNamedObjectWithPermission extends NamedObjectWithPermission
|
|
|
34
34
|
/// object address or namedNew for creating a new object
|
|
35
35
|
export type ObjectTypedMain = string | TypeNamedObjectWithPermission ;
|
|
36
36
|
export type ObjectMain = string | NamedObjectWithPermission ;
|
|
37
|
+
export type ObjectPermissionMain = string | Namedbject;
|
|
37
38
|
export type ObjectParam = string | NamedObjectWithDescription;
|
|
38
39
|
|
|
39
|
-
export const GetObjectExisted = (object: ObjectMain | ObjectTypedMain | ObjectParam | undefined) : string | undefined => {
|
|
40
|
+
export const GetObjectExisted = (object: ObjectMain | ObjectTypedMain | ObjectParam | ObjectPermissionMain | undefined) : string | undefined => {
|
|
40
41
|
return (typeof object === 'string' ) ? object : undefined;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
export const GetObjectMain = (object: ObjectMain | ObjectTypedMain | undefined) : NamedObjectWithPermission | TypeNamedObjectWithPermission | undefined => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
export const GetObjectMain = (object: ObjectMain | ObjectTypedMain | ObjectPermissionMain | undefined) : NamedObjectWithPermission | TypeNamedObjectWithPermission | Namedbject | undefined => {
|
|
45
|
+
if (typeof object === 'object' && object !== null && 'type_parameter' in object) {
|
|
46
|
+
return (object as TypeNamedObjectWithPermission);
|
|
47
|
+
} else if (typeof object === 'object' && object !== null && 'permission' in object) {
|
|
48
|
+
return (object as NamedObjectWithPermission);
|
|
49
|
+
} else if (typeof object === 'object') {
|
|
50
|
+
return (object as Namedbject);
|
|
51
|
+
}
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
export const GetObjectParam = (object: ObjectParam | undefined) : NamedObjectWithDescription | undefined => {
|
|
51
55
|
return (typeof object === 'object' && object!== null && 'description' in object)? (object as NamedObjectWithDescription) : undefined;
|
|
52
56
|
}
|
|
53
57
|
|
|
58
|
+
export type ObjectsOp = {op:'set' | 'add' | 'remove' ; objects:string[]} | {op:'removeall'};
|
|
59
|
+
|
|
54
60
|
// address from local Account or local Mark.
|
|
55
|
-
export type AccountOrMark_Address = {
|
|
61
|
+
export type AccountOrMark_Address = {account_name?: string} | {mark_name: string};
|
|
56
62
|
|
|
57
63
|
export const GetAccountOrMark_Address = async (entity?: AccountOrMark_Address) : Promise<string | undefined> => {
|
|
58
|
-
if (typeof((entity as any)?.
|
|
59
|
-
return await LocalMark.Instance().get_address((entity as any).
|
|
64
|
+
if (typeof((entity as any)?.mark_name) === 'string') {
|
|
65
|
+
return await LocalMark.Instance().get_address((entity as any).mark_name);
|
|
60
66
|
} else {
|
|
61
|
-
|
|
62
|
-
return acc?.address;
|
|
67
|
+
return (await Account.Instance().get((entity as any)?.account_name))?.address;
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
|
|
66
|
-
export const GetManyAccountOrMark_Address = async (entities: AccountOrMark_Address[]) : Promise<
|
|
71
|
+
export const GetManyAccountOrMark_Address = async (entities: AccountOrMark_Address[]) : Promise<string[]> => {
|
|
67
72
|
const res = [];
|
|
68
73
|
for (let i = 0; i < entities.length; ++i) {
|
|
69
74
|
const addr = await GetAccountOrMark_Address(entities[i]);
|
|
@@ -72,14 +77,14 @@ export const GetManyAccountOrMark_Address = async (entities: AccountOrMark_Addre
|
|
|
72
77
|
return res;
|
|
73
78
|
}
|
|
74
79
|
|
|
75
|
-
export interface
|
|
80
|
+
export interface PayParam {
|
|
76
81
|
index: bigint | string | number,
|
|
77
82
|
remark: string,
|
|
78
83
|
for_object?: string,
|
|
79
84
|
for_guard?: string,
|
|
80
85
|
}
|
|
81
86
|
|
|
82
|
-
export const SetWithdrawFee = async (param:
|
|
87
|
+
export const SetWithdrawFee = async (param: PayParam, treasury?:TreasuryObject) : Promise<WithdrawFee> => {
|
|
83
88
|
if (!treasury) {
|
|
84
89
|
ERROR(Errors.InvalidParam, 'WithdrawFee: treasury_address invalid');
|
|
85
90
|
}
|
|
@@ -123,6 +128,7 @@ export class CallBase {
|
|
|
123
128
|
content: ObjectBase | undefined = undefined;
|
|
124
129
|
|
|
125
130
|
protected async operate(txb:TransactionBlock, passport?:PassportObject, account?:string) {};
|
|
131
|
+
protected async prepare() {};
|
|
126
132
|
constructor () {}
|
|
127
133
|
// return WitnessFill to resolve filling witness, and than 'call_with_witness' to complete the call;
|
|
128
134
|
// return ResponseData when the call has completed;
|
|
@@ -137,6 +143,7 @@ export class CallBase {
|
|
|
137
143
|
if (query) {
|
|
138
144
|
const txb = new TransactionBlock();
|
|
139
145
|
const passport = new Passport(txb, query!);
|
|
146
|
+
await this.prepare();
|
|
140
147
|
await this.operate(txb, passport?.get_object(), account)
|
|
141
148
|
passport.destroy();
|
|
142
149
|
|
|
@@ -153,10 +160,7 @@ export class CallBase {
|
|
|
153
160
|
var guards : string[] = [];
|
|
154
161
|
|
|
155
162
|
if (permIndex.length > 0 || checkOwner) {
|
|
156
|
-
const
|
|
157
|
-
if (!addr) ERROR(Errors.InvalidParam, 'check_permission_and_call: account invalid');
|
|
158
|
-
|
|
159
|
-
const p = await query_permission({object_address_or_name:permission, entity_address_or_name:addr.address});
|
|
163
|
+
const p = await query_permission({permission_object:permission, address:{account_name:account}});
|
|
160
164
|
if (checkOwner && !p.owner) ERROR(Errors.noPermission, 'owner');
|
|
161
165
|
if (checkAdmin && !p.admin) ERROR(Errors.noPermission, 'admin');
|
|
162
166
|
|
|
@@ -207,18 +211,12 @@ export class CallBase {
|
|
|
207
211
|
|
|
208
212
|
// onchain mark
|
|
209
213
|
if (!this.resouceObject) {
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (!r?.mark_object) {
|
|
215
|
-
this.resouceObject = Entity.From(txb).create_resource2(); // new
|
|
216
|
-
Resource.From(txb, this.resouceObject).add(object, tags, named_new?.name);
|
|
217
|
-
} else {
|
|
218
|
-
Resource.From(txb, r.mark_object).add(object, tags, named_new?.name);
|
|
219
|
-
}
|
|
214
|
+
const r = await query_personal({address:{account_name:account}});
|
|
215
|
+
if (!r?.mark_object) {
|
|
216
|
+
this.resouceObject = Entity.From(txb).create_resource2(); // new
|
|
217
|
+
Resource.From(txb, this.resouceObject).add(object, tags, named_new?.name);
|
|
220
218
|
} else {
|
|
221
|
-
|
|
219
|
+
Resource.From(txb, r.mark_object).add(object, tags, named_new?.name);
|
|
222
220
|
}
|
|
223
221
|
} else {
|
|
224
222
|
Resource.From(txb, this.resouceObject).add(object, tags, named_new?.name);
|
package/src/call/call.ts
CHANGED
|
@@ -20,32 +20,32 @@ export interface CallDemandObject {
|
|
|
20
20
|
data: CallDemand_Data;
|
|
21
21
|
account?: string | null;
|
|
22
22
|
witness?: GuardInfo_forCall | null;
|
|
23
|
-
no_cache?: boolean;
|
|
23
|
+
//no_cache?: boolean;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface CallServiceObject {
|
|
27
27
|
data: CallService_Data;
|
|
28
28
|
account?: string | null;
|
|
29
29
|
witness?: GuardInfo_forCall | null;
|
|
30
|
-
no_cache?: boolean;
|
|
30
|
+
//no_cache?: boolean;
|
|
31
31
|
}
|
|
32
32
|
export interface CallMachineObject {
|
|
33
33
|
data: CallMachine_Data;
|
|
34
34
|
account?: string | null;
|
|
35
35
|
witness?: GuardInfo_forCall | null;
|
|
36
|
-
no_cache?: boolean; // true: no cache to query the machine, false: use cache if exist
|
|
36
|
+
//no_cache?: boolean; // true: no cache to query the machine, false: use cache if exist
|
|
37
37
|
}
|
|
38
38
|
export interface CallTreasuryObject {
|
|
39
39
|
data: CallTreasury_Data;
|
|
40
40
|
account?: string | null;
|
|
41
41
|
witness?: GuardInfo_forCall | null;
|
|
42
|
-
no_cache?: boolean;
|
|
42
|
+
//no_cache?: boolean;
|
|
43
43
|
}
|
|
44
44
|
export interface CallArbitrationObject {
|
|
45
45
|
data: CallArbitration_Data;
|
|
46
46
|
account?: string | null;
|
|
47
47
|
witness?: GuardInfo_forCall | null;
|
|
48
|
-
no_cache?: boolean;
|
|
48
|
+
//no_cache?: boolean;
|
|
49
49
|
}
|
|
50
50
|
export interface CallGuardObject {
|
|
51
51
|
data: CallGuard_Data;
|
|
@@ -55,7 +55,7 @@ export interface CallRepositoryObject {
|
|
|
55
55
|
data: CallRepository_Data;
|
|
56
56
|
account?: string | null;
|
|
57
57
|
witness?: GuardInfo_forCall | null;
|
|
58
|
-
no_cache?: boolean;
|
|
58
|
+
//no_cache?: boolean;
|
|
59
59
|
}
|
|
60
60
|
export interface CallPersonalObject {
|
|
61
61
|
data: CallPersonal_Data;
|
package/src/call/demand.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { TransactionBlock, IsValidArgType, Service, PassportObject, Errors, ERROR, Permission, PermissionIndex,
|
|
2
|
-
PermissionIndexType, Demand,
|
|
2
|
+
PermissionIndexType, Demand,
|
|
3
|
+
PermissionObject, } from 'wowok';
|
|
3
4
|
import { ObjectDemand, query_objects } from '../query/objects.js';
|
|
4
5
|
import { CallBase, CallResult, GetObjectExisted, GetObjectMain, GetObjectParam, ObjectTypedMain, TypeNamedObjectWithPermission } from "./base.js";
|
|
5
6
|
import { Account } from '../local/account.js';
|
|
6
7
|
import { LocalMark } from '../local/local.js';
|
|
8
|
+
import { off } from 'process';
|
|
7
9
|
|
|
8
10
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
9
11
|
export interface CallDemand_Data {
|
|
@@ -30,24 +32,30 @@ export class CallDemand extends CallBase {
|
|
|
30
32
|
super();
|
|
31
33
|
this.data = data;
|
|
32
34
|
}
|
|
35
|
+
|
|
36
|
+
protected async prepare(): Promise<void> {
|
|
37
|
+
if (!this.object_address) {
|
|
38
|
+
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data.object)));
|
|
39
|
+
if (this.object_address) {
|
|
40
|
+
await this.update_content('Demand', this.object_address);
|
|
41
|
+
if (!this.content) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.object:' + this.object_address);
|
|
42
|
+
this.permission_address = (this.content as ObjectDemand).permission;
|
|
43
|
+
this.type_parameter = Demand.parseObjectType(this.content.type_raw);
|
|
44
|
+
} else {
|
|
45
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
46
|
+
if (!IsValidArgType(n?.type_parameter)) {
|
|
47
|
+
ERROR(Errors.IsValidArgType, 'CallDemand_Data.data.object.type_parameter');
|
|
48
|
+
}
|
|
49
|
+
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
50
|
+
this.type_parameter = n.type_parameter;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
33
54
|
async call(account?:string) : Promise<CallResult> {
|
|
34
55
|
var checkOwner = false; const guards : string[] = [];
|
|
35
56
|
const perms : PermissionIndexType[] = [];
|
|
36
|
-
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data.object)));
|
|
37
|
-
if (this.object_address) {
|
|
38
|
-
await this.update_content('Demand', this.object_address);
|
|
39
|
-
if (!this.content) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.object:' + this.object_address);
|
|
40
|
-
this.permission_address = (this.content as ObjectDemand).permission;
|
|
41
|
-
this.type_parameter = Demand.parseObjectType(this.content.type_raw);
|
|
42
|
-
} else {
|
|
43
|
-
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
44
|
-
if (!n?.type_parameter || !IsValidArgType(n.type_parameter)) {
|
|
45
|
-
ERROR(Errors.IsValidArgType, 'CallDemand_Data.data.object.type_parameter');
|
|
46
|
-
}
|
|
47
|
-
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
48
|
-
this.type_parameter = n.type_parameter;
|
|
49
|
-
}
|
|
50
57
|
|
|
58
|
+
await this.prepare();
|
|
51
59
|
if (this.permission_address) {
|
|
52
60
|
if (!this.data?.object) {
|
|
53
61
|
perms.push(PermissionIndex.demand)
|
|
@@ -72,98 +80,98 @@ export class CallDemand extends CallBase {
|
|
|
72
80
|
if ((this.content as ObjectDemand)?.guard?.object) {
|
|
73
81
|
guards.push((this.content as ObjectDemand).guard?.object!);
|
|
74
82
|
}
|
|
75
|
-
}
|
|
76
|
-
const guard = await LocalMark.Instance().get_address(this.data?.guard?.address);
|
|
77
|
-
if (guard) {
|
|
78
|
-
guards.push(guard)
|
|
79
|
-
}
|
|
80
|
-
}*/
|
|
83
|
+
}
|
|
81
84
|
}
|
|
82
85
|
return await this.check_permission_and_call(this.permission_address, perms, guards, checkOwner, undefined, account)
|
|
83
86
|
}
|
|
84
87
|
return await this.exec(account);
|
|
85
88
|
}
|
|
86
89
|
protected async operate(txb:TransactionBlock, passport?:PassportObject, account?:string) {
|
|
87
|
-
let obj : Demand | undefined ; let
|
|
90
|
+
let obj : Demand | undefined ; let perm: Permission | undefined;
|
|
91
|
+
let permission : PermissionObject | undefined;
|
|
88
92
|
|
|
89
93
|
if (this.object_address) {
|
|
90
|
-
obj = Demand.From(txb, this.type_parameter!, this.permission_address!, this.object_address)
|
|
94
|
+
obj = Demand.From(txb, this.type_parameter!, this.permission_address!, this.object_address);
|
|
95
|
+
permission = this.permission_address;
|
|
91
96
|
} else {
|
|
92
97
|
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
permission = await LocalMark.Instance().get_address(GetObjectExisted(n?.permission));
|
|
99
|
+
if (!permission) {
|
|
100
|
+
perm = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
|
|
101
|
+
permission = perm.get_object();
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
if (this.data.time_expire !== undefined) {
|
|
98
105
|
obj = Demand.New(txb, this.type_parameter!, this.data.time_expire?.op === 'duration' ? true : false,
|
|
99
106
|
this.data.time_expire?.op === 'duration' ? this.data.time_expire.minutes : this.data.time_expire?.time,
|
|
100
|
-
permission
|
|
107
|
+
permission, this.data?.description??'', perm?undefined:passport)
|
|
101
108
|
} else {
|
|
102
109
|
obj = Demand.New(txb, this.type_parameter!, true, 30*24*60, // 30days default
|
|
103
|
-
permission
|
|
110
|
+
permission, this.data?.description??'', perm?undefined:passport)
|
|
104
111
|
}
|
|
105
112
|
}
|
|
106
113
|
|
|
107
|
-
if (obj)
|
|
108
|
-
|
|
109
|
-
if (this.data?.present !== undefined) {
|
|
110
|
-
if ((this.content as ObjectDemand)?.guard?.service_id_in_guard !== undefined && (this.content as ObjectDemand)?.guard?.service_id_in_guard !== null) {
|
|
111
|
-
obj?.present((this.content as ObjectDemand)!.guard!.service_id_in_guard!, undefined, this.data.present.recommend_words, pst);
|
|
112
|
-
} else {
|
|
113
|
-
const service_address = await LocalMark.Instance().get_address(this.data.present.service);
|
|
114
|
-
if (!service_address) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.present.service');
|
|
115
|
-
const r = await query_objects({objects:[service_address]});
|
|
116
|
-
if (r?.objects?.length !== 1 || r?.objects[0]?.type !== 'Service') {
|
|
117
|
-
ERROR(Errors.InvalidParam, 'CallDemand_Data.data.present.service: ' + service_address);
|
|
118
|
-
}
|
|
119
|
-
const service_type = Service.parseOrderObjectType(r.objects[0].type_raw);
|
|
120
|
-
if (!service_type) {
|
|
121
|
-
ERROR(Errors.InvalidParam, 'CallDemand_Data.data.present.service: ' + service_address);
|
|
122
|
-
}
|
|
114
|
+
if (!obj) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.object');
|
|
115
|
+
if (!permission) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.object.permission');
|
|
123
116
|
|
|
124
|
-
|
|
117
|
+
const pst = perm?undefined:passport;
|
|
118
|
+
if (this.data?.present !== undefined) {
|
|
119
|
+
if ((this.content as ObjectDemand)?.guard?.service_id_in_guard !== undefined && (this.content as ObjectDemand)?.guard?.service_id_in_guard !== null) {
|
|
120
|
+
obj?.present((this.content as ObjectDemand)!.guard!.service_id_in_guard!, undefined, this.data.present.recommend_words, pst);
|
|
121
|
+
} else {
|
|
122
|
+
const service_address = await LocalMark.Instance().get_address(this.data.present.service);
|
|
123
|
+
if (!service_address) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.present.service');
|
|
124
|
+
const r = await query_objects({objects:[service_address]});
|
|
125
|
+
if (r?.objects?.length !== 1 || r?.objects[0]?.type !== 'Service') {
|
|
126
|
+
ERROR(Errors.InvalidParam, 'CallDemand_Data.data.present.service: ' + service_address);
|
|
127
|
+
}
|
|
128
|
+
const service_type = Service.parseOrderObjectType(r.objects[0].type_raw);
|
|
129
|
+
if (!service_type) {
|
|
130
|
+
ERROR(Errors.InvalidParam, 'CallDemand_Data.data.present.service: ' + service_address);
|
|
125
131
|
}
|
|
126
|
-
}
|
|
127
132
|
|
|
128
|
-
|
|
129
|
-
obj?.set_description(this.data.description, pst);
|
|
133
|
+
obj?.present(service_address, service_type, this.data.present.recommend_words, pst);
|
|
130
134
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
obj
|
|
148
|
-
} else if (this.data.bounty.op === 'refund') {
|
|
149
|
-
obj?.refund(pst);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (this.data?.guard !== undefined) {
|
|
154
|
-
const guard = await LocalMark.Instance().get_address(this.data?.guard.address);
|
|
155
|
-
if (!guard) {
|
|
156
|
-
ERROR(Errors.InvalidParam, 'CallDemand_Data.data.guard.address')
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
138
|
+
obj?.set_description(this.data.description, pst);
|
|
139
|
+
}
|
|
140
|
+
if (this.data?.time_expire !== undefined && this.object_address) {
|
|
141
|
+
obj?.expand_time(this.data.time_expire.op === 'duration' ? true : false,
|
|
142
|
+
this.data.time_expire.op === 'duration' ? this.data.time_expire.minutes : this.data.time_expire.time, pst)
|
|
143
|
+
}
|
|
144
|
+
if (this.data?.bounty !== undefined) {
|
|
145
|
+
if (this.data.bounty.op === 'add') {
|
|
146
|
+
const bounty = await LocalMark.Instance().get_address((this.data.bounty.object as any)?.address)
|
|
147
|
+
if (bounty) {
|
|
148
|
+
obj.deposit(bounty)
|
|
149
|
+
} else if ((this.data.bounty.object as any)?.balance !== undefined){
|
|
150
|
+
const r = await Account.Instance().get_coin_object(txb, (this.data.bounty.object as any)?.balance, account, this.type_parameter);
|
|
151
|
+
if (r) obj.deposit(r)
|
|
157
152
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
153
|
+
} else if (this.data.bounty.op === 'reward') {
|
|
154
|
+
const service = await localStorage.Instance().get_address(this.data.bounty.service);
|
|
155
|
+
if (!service) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.bounty.service');
|
|
156
|
+
obj?.yes(service, pst);
|
|
157
|
+
} else if (this.data.bounty.op === 'refund') {
|
|
158
|
+
obj?.refund(pst);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (this.data?.guard !== undefined) {
|
|
163
|
+
const guard = await LocalMark.Instance().get_address(this.data?.guard.address);
|
|
164
|
+
if (!guard) {
|
|
165
|
+
ERROR(Errors.InvalidParam, 'CallDemand_Data.data.guard.address')
|
|
166
166
|
}
|
|
167
|
+
obj?.set_guard(guard, this.data.guard?.service_id_in_guard ?? undefined, pst);
|
|
168
|
+
}
|
|
169
|
+
if (perm) {
|
|
170
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
171
|
+
await this.new_with_mark('Permission', txb, perm.launch(), GetObjectParam(n?.permission), account);
|
|
172
|
+
}
|
|
173
|
+
if (!this.data.object) {
|
|
174
|
+
await this.new_with_mark('Demand', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
167
175
|
}
|
|
168
176
|
}
|
|
169
177
|
}
|