wowok_agent 1.2.44 → 1.3.47
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 +13 -28
- package/dist/call/arbitration.d.ts.map +1 -1
- package/dist/call/arbitration.js +91 -84
- package/dist/call/arbitration.js.map +1 -1
- package/dist/call/base.d.ts +31 -2
- package/dist/call/base.d.ts.map +1 -1
- package/dist/call/base.js +41 -3
- package/dist/call/base.js.map +1 -1
- package/dist/call/call.d.ts +6 -0
- package/dist/call/call.d.ts.map +1 -1
- package/dist/call/call.js.map +1 -1
- package/dist/call/demand.d.ts +9 -22
- package/dist/call/demand.d.ts.map +1 -1
- package/dist/call/demand.js +70 -78
- package/dist/call/demand.js.map +1 -1
- package/dist/call/machine.d.ts +35 -44
- package/dist/call/machine.d.ts.map +1 -1
- package/dist/call/machine.js +105 -115
- package/dist/call/machine.js.map +1 -1
- package/dist/call/object_permission.d.ts.map +1 -1
- package/dist/call/object_permission.js.map +1 -1
- package/dist/call/permission.d.ts +30 -18
- package/dist/call/permission.d.ts.map +1 -1
- package/dist/call/permission.js +39 -38
- package/dist/call/permission.js.map +1 -1
- package/dist/call/personal.d.ts +6 -6
- package/dist/call/personal.d.ts.map +1 -1
- package/dist/call/personal.js +11 -13
- package/dist/call/personal.js.map +1 -1
- package/dist/call/repository.d.ts +4 -12
- package/dist/call/repository.d.ts.map +1 -1
- package/dist/call/repository.js +49 -37
- package/dist/call/repository.js.map +1 -1
- package/dist/call/service.d.ts +50 -70
- package/dist/call/service.d.ts.map +1 -1
- package/dist/call/service.js +187 -164
- package/dist/call/service.js.map +1 -1
- package/dist/call/treasury.d.ts +22 -26
- package/dist/call/treasury.d.ts.map +1 -1
- package/dist/call/treasury.js +74 -73
- package/dist/call/treasury.js.map +1 -1
- package/dist/common.d.ts +1 -0
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +6 -0
- package/dist/common.js.map +1 -1
- package/dist/local/local.d.ts +1 -1
- package/dist/local/local.d.ts.map +1 -1
- package/dist/local/local.js +4 -1
- package/dist/local/local.js.map +1 -1
- package/dist/query/events.d.ts +1 -1
- package/dist/query/events.d.ts.map +1 -1
- package/dist/query/events.js +15 -9
- package/dist/query/events.js.map +1 -1
- package/dist/query/objects.d.ts +7 -2
- package/dist/query/objects.d.ts.map +1 -1
- package/dist/query/objects.js +8 -1
- package/dist/query/objects.js.map +1 -1
- package/package.json +4 -2
- package/src/call/arbitration.ts +117 -105
- package/src/call/base.ts +78 -10
- package/src/call/call.ts +6 -0
- package/src/call/demand.ts +77 -86
- package/src/call/machine.ts +119 -132
- package/src/call/object_permission.ts +1 -1
- package/src/call/permission.ts +68 -45
- package/src/call/personal.ts +18 -20
- package/src/call/repository.ts +54 -47
- package/src/call/service.ts +236 -197
- package/src/call/treasury.ts +96 -86
- package/src/common.ts +7 -1
- package/src/local/account.ts +1 -1
- package/src/local/local.ts +6 -2
- package/src/query/events.ts +12 -10
- package/src/query/objects.ts +18 -4
- package/tsconfig.tsbuildinfo +1 -1
package/src/call/base.ts
CHANGED
|
@@ -1,21 +1,91 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { Entity, Resource, TxbAddress, array_unique, TagName, ResourceObject, PassportObject, Errors, ERROR, Permission,
|
|
4
|
-
PermissionIndexType, GuardParser, Passport, WitnessFill, CallResponse, TransactionBlock
|
|
4
|
+
PermissionIndexType, GuardParser, Passport, WitnessFill, CallResponse, TransactionBlock,
|
|
5
|
+
WithdrawFee, TreasuryObject
|
|
5
6
|
} from 'wowok';
|
|
6
7
|
import { query_permission } from '../query/permission.js';
|
|
7
8
|
import { Account } from '../local/account.js';
|
|
8
|
-
import {
|
|
9
|
+
import { ObjectBase, ObjectBaseType, query_objects, query_personal, raw2type} from '../query/objects.js';
|
|
9
10
|
import { LocalMark } from '../local/local.js';
|
|
10
11
|
|
|
11
12
|
export interface Namedbject {
|
|
12
|
-
name?: string;
|
|
13
|
-
tags?: string[];
|
|
13
|
+
name?: string; // name of the object, if not defined, the object will be created without name
|
|
14
|
+
tags?: string[]; // tags of the object, if not defined, the object will be created without tags
|
|
14
15
|
// true: use address as the name if the name exist; otherwise, use this name and change the original name to its address
|
|
15
16
|
useAddressIfNameExist?: boolean;
|
|
16
|
-
onChain?: boolean; // true: onchain, false: local(default)
|
|
17
|
+
onChain?: boolean; // true: onchain mark, false: local mark(default)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface NamedObjectWithDescription extends Namedbject {
|
|
21
|
+
description?:string; // description of the new object, if not defined, the object will be created with no description.
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface NamedObjectWithPermission extends Namedbject {
|
|
25
|
+
// permission object, undefined or {named_new...} for creating a new object; if defined, the permission object must exist.
|
|
26
|
+
permission?: ObjectParam;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface TypeNamedObjectWithPermission extends NamedObjectWithPermission {
|
|
30
|
+
// type of the object, e.g. '0x2::coin::Coin<0x2::sui::SUI>'
|
|
31
|
+
type_parameter: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/// object address or namedNew for creating a new object
|
|
35
|
+
export type ObjectTypedMain = string | TypeNamedObjectWithPermission ;
|
|
36
|
+
export type ObjectMain = string | NamedObjectWithPermission ;
|
|
37
|
+
export type ObjectParam = string | NamedObjectWithDescription;
|
|
38
|
+
|
|
39
|
+
export const GetObjectExisted = (object: ObjectMain | ObjectTypedMain | ObjectParam | undefined) : string | undefined => {
|
|
40
|
+
return (typeof object === 'string' ) ? object : undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const GetObjectMain = (object: ObjectMain | ObjectTypedMain | undefined) : NamedObjectWithPermission | TypeNamedObjectWithPermission | undefined => {
|
|
44
|
+
return (typeof object === 'object' && object !== null && 'type_parameter' in object) ?
|
|
45
|
+
(object as TypeNamedObjectWithPermission) :
|
|
46
|
+
(typeof object === 'object' && object !== null && 'permission' in object) ?
|
|
47
|
+
(object as NamedObjectWithPermission) : undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const GetObjectParam = (object: ObjectParam | undefined) : NamedObjectWithDescription | undefined => {
|
|
51
|
+
return (typeof object === 'object' && object!== null && 'description' in object)? (object as NamedObjectWithDescription) : undefined;
|
|
17
52
|
}
|
|
18
53
|
|
|
54
|
+
// address from local Account or local Mark.
|
|
55
|
+
export type AccountOrMark_Address = {account?: string} | {name_or_address: string};
|
|
56
|
+
|
|
57
|
+
export const GetAccountOrMark_Address = async (entity?: AccountOrMark_Address) : Promise<string | undefined> => {
|
|
58
|
+
if (typeof((entity as any)?.name_or_address) === 'string') {
|
|
59
|
+
return await LocalMark.Instance().get_address((entity as any).name_or_address);
|
|
60
|
+
} else {
|
|
61
|
+
const acc = await Account.Instance().get((entity as any)?.account);
|
|
62
|
+
return acc?.address;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const GetManyAccountOrMark_Address = async (entities: AccountOrMark_Address[]) : Promise<(string | undefined)[]> => {
|
|
67
|
+
const res = [];
|
|
68
|
+
for (let i = 0; i < entities.length; ++i) {
|
|
69
|
+
const addr = await GetAccountOrMark_Address(entities[i]);
|
|
70
|
+
if (addr) res.push(addr);
|
|
71
|
+
}
|
|
72
|
+
return res;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface WithdrawParam {
|
|
76
|
+
index: bigint | string | number,
|
|
77
|
+
remark: string,
|
|
78
|
+
for_object?: string,
|
|
79
|
+
for_guard?: string,
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const SetWithdrawFee = async (param: WithdrawParam, treasury?:TreasuryObject) : Promise<WithdrawFee> => {
|
|
83
|
+
if (!treasury) {
|
|
84
|
+
ERROR(Errors.InvalidParam, 'WithdrawFee: treasury_address invalid');
|
|
85
|
+
}
|
|
86
|
+
const [object, guard] = await LocalMark.Instance().get_many_address([param.for_object, param.for_guard]);
|
|
87
|
+
return {index:BigInt(param.index), remark:param.remark, for_object:object, for_guard:guard, treasury:treasury};
|
|
88
|
+
}
|
|
19
89
|
export interface AddressMark {
|
|
20
90
|
address: TxbAddress;
|
|
21
91
|
name?: string;
|
|
@@ -99,7 +169,6 @@ export class CallBase {
|
|
|
99
169
|
if (guards_needed.length > 0) {
|
|
100
170
|
guards = guards.concat(guards_needed);
|
|
101
171
|
}
|
|
102
|
-
|
|
103
172
|
if (guards.length > 0) { // prepare passport
|
|
104
173
|
const p: GuardParser | undefined = await GuardParser.Create([...guards]);
|
|
105
174
|
const futures = p ? p.future_fills() : [];
|
|
@@ -156,10 +225,10 @@ export class CallBase {
|
|
|
156
225
|
}
|
|
157
226
|
}
|
|
158
227
|
|
|
159
|
-
protected async update_content(
|
|
160
|
-
if (this.content) return ;
|
|
228
|
+
protected async update_content(type:ObjectBaseType, object?:string) {
|
|
229
|
+
if (this.content || !object) return ;
|
|
161
230
|
|
|
162
|
-
const r = await query_objects({objects:[object]});
|
|
231
|
+
const r = await query_objects({objects:[object], no_cache:true});
|
|
163
232
|
if (r?.objects?.length !== 1 || r?.objects[0]?.type !== type) {
|
|
164
233
|
ERROR(Errors.Fail, `Fetch ${type} object ${object} failed`)
|
|
165
234
|
}
|
|
@@ -173,7 +242,6 @@ export class CallBase {
|
|
|
173
242
|
this.resouceObject = undefined;
|
|
174
243
|
}
|
|
175
244
|
const r = await Account.Instance().sign_and_commit(txb, account);
|
|
176
|
-
|
|
177
245
|
if (!r) {
|
|
178
246
|
ERROR(Errors.Fail, 'sign and commit failed');
|
|
179
247
|
}
|
package/src/call/call.ts
CHANGED
|
@@ -20,27 +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
24
|
}
|
|
24
25
|
|
|
25
26
|
export interface CallServiceObject {
|
|
26
27
|
data: CallService_Data;
|
|
27
28
|
account?: string | null;
|
|
28
29
|
witness?: GuardInfo_forCall | null;
|
|
30
|
+
no_cache?: boolean;
|
|
29
31
|
}
|
|
30
32
|
export interface CallMachineObject {
|
|
31
33
|
data: CallMachine_Data;
|
|
32
34
|
account?: string | null;
|
|
33
35
|
witness?: GuardInfo_forCall | null;
|
|
36
|
+
no_cache?: boolean; // true: no cache to query the machine, false: use cache if exist
|
|
34
37
|
}
|
|
35
38
|
export interface CallTreasuryObject {
|
|
36
39
|
data: CallTreasury_Data;
|
|
37
40
|
account?: string | null;
|
|
38
41
|
witness?: GuardInfo_forCall | null;
|
|
42
|
+
no_cache?: boolean;
|
|
39
43
|
}
|
|
40
44
|
export interface CallArbitrationObject {
|
|
41
45
|
data: CallArbitration_Data;
|
|
42
46
|
account?: string | null;
|
|
43
47
|
witness?: GuardInfo_forCall | null;
|
|
48
|
+
no_cache?: boolean;
|
|
44
49
|
}
|
|
45
50
|
export interface CallGuardObject {
|
|
46
51
|
data: CallGuard_Data;
|
|
@@ -50,6 +55,7 @@ export interface CallRepositoryObject {
|
|
|
50
55
|
data: CallRepository_Data;
|
|
51
56
|
account?: string | null;
|
|
52
57
|
witness?: GuardInfo_forCall | null;
|
|
58
|
+
no_cache?: boolean;
|
|
53
59
|
}
|
|
54
60
|
export interface CallPersonalObject {
|
|
55
61
|
data: CallPersonal_Data;
|
package/src/call/demand.ts
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import { TransactionBlock, IsValidArgType,
|
|
2
|
-
import { PassportObject, IsValidAddress, Errors, ERROR, Permission, PermissionIndex,
|
|
1
|
+
import { TransactionBlock, IsValidArgType, Service, PassportObject, Errors, ERROR, Permission, PermissionIndex,
|
|
3
2
|
PermissionIndexType, Demand, } from 'wowok';
|
|
4
|
-
import {
|
|
5
|
-
import { CallBase, CallResult,
|
|
3
|
+
import { ObjectDemand, query_objects } from '../query/objects.js';
|
|
4
|
+
import { CallBase, CallResult, GetObjectExisted, GetObjectMain, GetObjectParam, ObjectTypedMain, TypeNamedObjectWithPermission } from "./base.js";
|
|
6
5
|
import { Account } from '../local/account.js';
|
|
7
6
|
import { LocalMark } from '../local/local.js';
|
|
8
7
|
|
|
9
8
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
10
9
|
export interface CallDemand_Data {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
object: ObjectTypedMain;
|
|
11
|
+
// service to present.
|
|
12
|
+
// If Demand.guard.service_id_in_guard is set, the service address must be provided as the service_id_in_guard identifier while Guard verification is performed.
|
|
13
|
+
// Otherwise, the service address is used to present the service to the Demand.
|
|
14
|
+
present?: {service?: string; recommend_words:string;};
|
|
15
|
+
|
|
14
16
|
description?: string;
|
|
15
17
|
time_expire?: {op: 'duration'; minutes:number} | {op:'time'; time:number};
|
|
16
18
|
bounty?: {op:'add'; object:{address:string}|{balance:string|number}} | {op:'reward'; service:string} | {op:'refund'} ;
|
|
17
|
-
|
|
19
|
+
// If service_id_in_guard is set, the service address must be provided as the service_id_in_guard identifier while Guard verification is performed.
|
|
18
20
|
guard?: {address:string; service_id_in_guard?:number};
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export class CallDemand extends CallBase {
|
|
22
24
|
data: CallDemand_Data;
|
|
23
|
-
|
|
25
|
+
object_address: string | undefined = undefined;
|
|
26
|
+
permission_address: string | undefined = undefined;
|
|
27
|
+
type_parameter: string | undefined = undefined;
|
|
24
28
|
|
|
25
29
|
constructor(data: CallDemand_Data) {
|
|
26
30
|
super();
|
|
@@ -29,105 +33,102 @@ export class CallDemand extends CallBase {
|
|
|
29
33
|
async call(account?:string) : Promise<CallResult> {
|
|
30
34
|
var checkOwner = false; const guards : string[] = [];
|
|
31
35
|
const perms : PermissionIndexType[] = [];
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (!this.data.type_parameter || !permission_address) {
|
|
39
|
-
await this.update_content(object_address, 'Demand');
|
|
40
|
-
if (this.content) {
|
|
41
|
-
permission_address = (this.content as ObjectDemand).permission;
|
|
42
|
-
this.data.type_parameter = this.content.type_raw!;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
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);
|
|
45
42
|
} else {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
50
|
|
|
51
|
-
if (permission_address) {
|
|
51
|
+
if (this.permission_address) {
|
|
52
52
|
if (!this.data?.object) {
|
|
53
53
|
perms.push(PermissionIndex.demand)
|
|
54
54
|
}
|
|
55
|
-
if (this.data?.description !== undefined && object_address) {
|
|
55
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
56
56
|
perms.push(PermissionIndex.demand_description)
|
|
57
57
|
}
|
|
58
|
-
if (this.data?.time_expire !== undefined && object_address) {
|
|
58
|
+
if (this.data?.time_expire !== undefined && this.object_address) {
|
|
59
59
|
perms.push(PermissionIndex.demand_expand_time)
|
|
60
60
|
}
|
|
61
|
-
if (this.data?.guard !== undefined) {
|
|
62
|
-
perms.push(PermissionIndex.demand_guard)
|
|
63
|
-
}
|
|
64
61
|
if (this.data?.bounty?.op === 'reward') {
|
|
65
62
|
perms.push(PermissionIndex.demand_yes)
|
|
66
63
|
}
|
|
67
64
|
if (this.data?.bounty?.op === 'refund') {
|
|
68
65
|
perms.push(PermissionIndex.demand_refund)
|
|
69
66
|
}
|
|
70
|
-
if (this.data?.
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
if (this.data?.guard !== undefined) {
|
|
68
|
+
perms.push(PermissionIndex.demand_guard)
|
|
69
|
+
}
|
|
70
|
+
if (this.data?.present !== undefined) {
|
|
71
|
+
if (this.object_address) {
|
|
72
|
+
if ((this.content as ObjectDemand)?.guard?.object) {
|
|
73
|
+
guards.push((this.content as ObjectDemand).guard?.object!);
|
|
74
|
+
}
|
|
75
|
+
} /*else {
|
|
76
|
+
const guard = await LocalMark.Instance().get_address(this.data?.guard?.address);
|
|
73
77
|
if (guard) {
|
|
74
78
|
guards.push(guard)
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
if (!object_address) { // new
|
|
78
|
-
const guard = await LocalMark.Instance().get_address(this.data?.guard?.address);
|
|
79
|
-
if (guard) {
|
|
80
|
-
guards.push(guard)
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
await this.update_content(object_address, 'Demand');
|
|
84
|
-
|
|
85
|
-
if ((this.content as ObjectDemand)?.guard?.object) {
|
|
86
|
-
guards.push((this.content as ObjectDemand).guard?.object!)
|
|
87
|
-
}
|
|
88
79
|
}
|
|
89
|
-
}
|
|
80
|
+
}*/
|
|
90
81
|
}
|
|
91
|
-
return await this.check_permission_and_call(permission_address, perms, guards, checkOwner, undefined, account)
|
|
82
|
+
return await this.check_permission_and_call(this.permission_address, perms, guards, checkOwner, undefined, account)
|
|
92
83
|
}
|
|
93
84
|
return await this.exec(account);
|
|
94
85
|
}
|
|
95
86
|
protected async operate(txb:TransactionBlock, passport?:PassportObject, account?:string) {
|
|
96
87
|
let obj : Demand | undefined ; let permission: any;
|
|
97
|
-
var [permission_address, object_address] = this?.content ?
|
|
98
|
-
[(this.content as ObjectDemand).permission, this.content.object] :
|
|
99
|
-
await LocalMark.Instance().get_many_address(
|
|
100
|
-
[(this.data?.permission as any)?.address,
|
|
101
|
-
(this.data?.object as any)?.address]);
|
|
102
88
|
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
89
|
+
if (this.object_address) {
|
|
90
|
+
obj = Demand.From(txb, this.type_parameter!, this.permission_address!, this.object_address)
|
|
91
|
+
} else {
|
|
92
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
93
|
+
if (!this.permission_address) {
|
|
94
|
+
permission = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
|
|
107
95
|
}
|
|
108
96
|
|
|
109
97
|
if (this.data.time_expire !== undefined) {
|
|
110
|
-
obj = Demand.New(txb, this.
|
|
98
|
+
obj = Demand.New(txb, this.type_parameter!, this.data.time_expire?.op === 'duration' ? true : false,
|
|
111
99
|
this.data.time_expire?.op === 'duration' ? this.data.time_expire.minutes : this.data.time_expire?.time,
|
|
112
|
-
permission ? permission.get_object(): permission_address, this.data?.description??'', permission?undefined:passport)
|
|
113
|
-
} else {
|
|
114
|
-
obj = Demand.New(txb, this.data.type_parameter!, true, 30*24*60, // 30days default
|
|
115
|
-
permission ? permission.get_object(): permission_address, this.data?.description??'', permission?undefined:passport)
|
|
116
|
-
}
|
|
117
|
-
} else {
|
|
118
|
-
if (this.data.type_parameter && permission_address) {
|
|
119
|
-
obj = Demand.From(txb, this.data.type_parameter, permission_address, object_address)
|
|
100
|
+
permission ? permission.get_object(): this.permission_address, this.data?.description??'', permission?undefined:passport)
|
|
120
101
|
} else {
|
|
121
|
-
|
|
102
|
+
obj = Demand.New(txb, this.type_parameter!, true, 30*24*60, // 30days default
|
|
103
|
+
permission ? permission.get_object(): this.permission_address, this.data?.description??'', permission?undefined:passport)
|
|
122
104
|
}
|
|
123
105
|
}
|
|
124
106
|
|
|
125
107
|
if (obj) {
|
|
126
108
|
const pst = permission?undefined:passport;
|
|
127
|
-
if (this.data?.
|
|
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
|
+
}
|
|
123
|
+
|
|
124
|
+
obj?.present(service_address, service_type, this.data.present.recommend_words, pst);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
128
129
|
obj?.set_description(this.data.description, pst);
|
|
129
130
|
}
|
|
130
|
-
if (this.data?.time_expire !== undefined && object_address) {
|
|
131
|
+
if (this.data?.time_expire !== undefined && this.object_address) {
|
|
131
132
|
obj?.expand_time(this.data.time_expire.op === 'duration' ? true : false,
|
|
132
133
|
this.data.time_expire.op === 'duration' ? this.data.time_expire.minutes : this.data.time_expire.time, pst)
|
|
133
134
|
}
|
|
@@ -135,12 +136,9 @@ export class CallDemand extends CallBase {
|
|
|
135
136
|
if (this.data.bounty.op === 'add') {
|
|
136
137
|
const bounty = await LocalMark.Instance().get_address((this.data.bounty.object as any)?.address)
|
|
137
138
|
if (bounty) {
|
|
138
|
-
obj.deposit(
|
|
139
|
+
obj.deposit(bounty)
|
|
139
140
|
} else if ((this.data.bounty.object as any)?.balance !== undefined){
|
|
140
|
-
|
|
141
|
-
ERROR(Errors.IsValidCoinType, 'CallDemand_Data.data.type_parameter')
|
|
142
|
-
}
|
|
143
|
-
const r = await Account.Instance().get_coin_object(txb, (this.data.bounty.object as any)?.balance, account, this.data.type_parameter);
|
|
141
|
+
const r = await Account.Instance().get_coin_object(txb, (this.data.bounty.object as any)?.balance, account, this.type_parameter);
|
|
144
142
|
if (r) obj.deposit(r)
|
|
145
143
|
}
|
|
146
144
|
} else if (this.data.bounty.op === 'reward') {
|
|
@@ -151,14 +149,6 @@ export class CallDemand extends CallBase {
|
|
|
151
149
|
obj?.refund(pst);
|
|
152
150
|
}
|
|
153
151
|
}
|
|
154
|
-
if (this.data?.present !== undefined) {
|
|
155
|
-
//@ demand guard and its pst, if set
|
|
156
|
-
const service = typeof(this.data.present.service) === 'string' ? (await LocalMark.Instance().get_address(this.data.present.service)): this.data.present.service;
|
|
157
|
-
if (service === undefined) {
|
|
158
|
-
ERROR(Errors.InvalidParam, 'CallDemand_Data.data.present.service')
|
|
159
|
-
}
|
|
160
|
-
obj?.present(typeof(this.data.present.service) === 'string' ? service : this.data.present.service, this.data.present.service_pay_type, this.data.present.recommend_words, pst);
|
|
161
|
-
}
|
|
162
152
|
|
|
163
153
|
if (this.data?.guard !== undefined) {
|
|
164
154
|
const guard = await LocalMark.Instance().get_address(this.data?.guard.address);
|
|
@@ -168,10 +158,11 @@ export class CallDemand extends CallBase {
|
|
|
168
158
|
obj?.set_guard(guard, this.data.guard?.service_id_in_guard ?? undefined, pst);
|
|
169
159
|
}
|
|
170
160
|
if (permission) {
|
|
171
|
-
|
|
161
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
162
|
+
await this.new_with_mark('Permission', txb, permission.launch(), GetObjectParam(n?.permission), account);
|
|
172
163
|
}
|
|
173
164
|
if (!this.data.object) {
|
|
174
|
-
await this.new_with_mark('Demand', txb, obj.launch(), (this.data?.object
|
|
165
|
+
await this.new_with_mark('Demand', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
175
166
|
}
|
|
176
167
|
}
|
|
177
168
|
}
|