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.
Files changed (74) hide show
  1. package/dist/call/arbitration.d.ts +4 -3
  2. package/dist/call/arbitration.d.ts.map +1 -1
  3. package/dist/call/arbitration.js +134 -131
  4. package/dist/call/arbitration.js.map +1 -1
  5. package/dist/call/base.d.ts +15 -7
  6. package/dist/call/base.d.ts.map +1 -1
  7. package/dist/call/base.js +21 -23
  8. package/dist/call/base.js.map +1 -1
  9. package/dist/call/call.d.ts +0 -6
  10. package/dist/call/call.d.ts.map +1 -1
  11. package/dist/call/demand.d.ts +1 -0
  12. package/dist/call/demand.d.ts.map +1 -1
  13. package/dist/call/demand.js +86 -80
  14. package/dist/call/demand.js.map +1 -1
  15. package/dist/call/machine.d.ts +10 -10
  16. package/dist/call/machine.d.ts.map +1 -1
  17. package/dist/call/machine.js +174 -146
  18. package/dist/call/machine.js.map +1 -1
  19. package/dist/call/permission.d.ts +10 -9
  20. package/dist/call/permission.d.ts.map +1 -1
  21. package/dist/call/permission.js +90 -85
  22. package/dist/call/permission.js.map +1 -1
  23. package/dist/call/personal.d.ts +3 -3
  24. package/dist/call/personal.d.ts.map +1 -1
  25. package/dist/call/personal.js +6 -12
  26. package/dist/call/personal.js.map +1 -1
  27. package/dist/call/repository.d.ts +24 -8
  28. package/dist/call/repository.d.ts.map +1 -1
  29. package/dist/call/repository.js +114 -94
  30. package/dist/call/repository.js.map +1 -1
  31. package/dist/call/service.d.ts +15 -26
  32. package/dist/call/service.d.ts.map +1 -1
  33. package/dist/call/service.js +274 -264
  34. package/dist/call/service.js.map +1 -1
  35. package/dist/call/treasury.d.ts +5 -7
  36. package/dist/call/treasury.d.ts.map +1 -1
  37. package/dist/call/treasury.js +108 -97
  38. package/dist/call/treasury.js.map +1 -1
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +1 -0
  42. package/dist/index.js.map +1 -1
  43. package/dist/query/objects.d.ts +2 -1
  44. package/dist/query/objects.d.ts.map +1 -1
  45. package/dist/query/objects.js +7 -7
  46. package/dist/query/objects.js.map +1 -1
  47. package/dist/query/owned.d.ts +2 -0
  48. package/dist/query/owned.d.ts.map +1 -0
  49. package/dist/query/owned.js +2 -0
  50. package/dist/query/owned.js.map +1 -0
  51. package/dist/query/permission.d.ts +3 -2
  52. package/dist/query/permission.d.ts.map +1 -1
  53. package/dist/query/permission.js +6 -3
  54. package/dist/query/permission.js.map +1 -1
  55. package/dist/query/treasury_received.d.ts +14 -0
  56. package/dist/query/treasury_received.d.ts.map +1 -0
  57. package/dist/query/treasury_received.js +19 -0
  58. package/dist/query/treasury_received.js.map +1 -0
  59. package/package.json +1 -1
  60. package/src/call/arbitration.ts +144 -141
  61. package/src/call/base.ts +27 -29
  62. package/src/call/call.ts +6 -6
  63. package/src/call/demand.ts +89 -81
  64. package/src/call/machine.ts +184 -145
  65. package/src/call/permission.ts +98 -90
  66. package/src/call/personal.ts +8 -13
  67. package/src/call/repository.ts +138 -95
  68. package/src/call/service.ts +290 -272
  69. package/src/call/treasury.ts +110 -99
  70. package/src/index.ts +1 -0
  71. package/src/query/objects.ts +10 -10
  72. package/src/query/permission.ts +9 -6
  73. package/src/query/treasury_received.ts +35 -0
  74. 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
- 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;
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 = {account?: string} | {name_or_address: string};
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)?.name_or_address) === 'string') {
59
- return await LocalMark.Instance().get_address((entity as any).name_or_address);
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
- const acc = await Account.Instance().get((entity as any)?.account);
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<(string | undefined)[]> => {
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 WithdrawParam {
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: WithdrawParam, treasury?:TreasuryObject) : Promise<WithdrawFee> => {
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 addr = await Account.Instance().get(account);
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 addr = await Account.Instance().get(account);
211
-
212
- if (addr) {
213
- const r = await query_personal({address:addr.address}); //@ use cache
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
- ERROR(Errors.InvalidParam, 'account - ' + account)
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;
@@ -1,9 +1,11 @@
1
1
  import { TransactionBlock, IsValidArgType, Service, PassportObject, Errors, ERROR, Permission, PermissionIndex,
2
- PermissionIndexType, Demand, } from 'wowok';
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
- } /*else {
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 permission: any;
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
- if (!this.permission_address) {
94
- permission = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
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 ? permission.get_object(): this.permission_address, this.data?.description??'', permission?undefined:passport)
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 ? permission.get_object(): this.permission_address, this.data?.description??'', permission?undefined:passport)
110
+ permission, this.data?.description??'', perm?undefined:passport)
104
111
  }
105
112
  }
106
113
 
107
- if (obj) {
108
- const pst = permission?undefined:passport;
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
- obj?.present(service_address, service_type, this.data.present.recommend_words, pst);
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
- if (this.data?.description !== undefined && this.object_address) {
129
- obj?.set_description(this.data.description, pst);
133
+ obj?.present(service_address, service_type, this.data.present.recommend_words, pst);
130
134
  }
131
- if (this.data?.time_expire !== undefined && this.object_address) {
132
- obj?.expand_time(this.data.time_expire.op === 'duration' ? true : false,
133
- this.data.time_expire.op === 'duration' ? this.data.time_expire.minutes : this.data.time_expire.time, pst)
134
- }
135
- if (this.data?.bounty !== undefined) {
136
- if (this.data.bounty.op === 'add') {
137
- const bounty = await LocalMark.Instance().get_address((this.data.bounty.object as any)?.address)
138
- if (bounty) {
139
- obj.deposit(bounty)
140
- } else if ((this.data.bounty.object as any)?.balance !== undefined){
141
- const r = await Account.Instance().get_coin_object(txb, (this.data.bounty.object as any)?.balance, account, this.type_parameter);
142
- if (r) obj.deposit(r)
143
- }
144
- } else if (this.data.bounty.op === 'reward') {
145
- const service = await localStorage.Instance().get_address(this.data.bounty.service);
146
- if (!service) ERROR(Errors.InvalidParam, 'CallDemand_Data.data.bounty.service');
147
- obj?.yes(service, pst);
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
- obj?.set_guard(guard, this.data.guard?.service_id_in_guard ?? undefined, pst);
159
- }
160
- if (permission) {
161
- const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
162
- await this.new_with_mark('Permission', txb, permission.launch(), GetObjectParam(n?.permission), account);
163
- }
164
- if (!this.data.object) {
165
- await this.new_with_mark('Demand', txb, obj.launch(), GetObjectMain(this.data?.object), account);
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
  }