wowok_agent 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wowok_agent",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Create, collaborate, and transact on your own terms with the AI-driven web3 collaboration protocol.",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -8,7 +8,6 @@ import { CallBase, CallResult, AddressMark, Namedbject} from "./base";
8
8
  export interface CallArbitration_Data {
9
9
  object?: {address:string} | {namedNew: Namedbject}; // undefined or {named_new...} for creating a new object
10
10
  permission?: {address:string} | {namedNew: Namedbject, description?:string};
11
- mark?:AddressMark;
12
11
  type_parameter: string;
13
12
  permission_new?: string;
14
13
  description?: string;
@@ -121,10 +120,9 @@ export class CallArbitration extends CallBase {
121
120
  withdraw_treasury = Treasury.New(txb, this.data?.type_parameter!, permission ? permission.get_object() : permission_address,
122
121
  d, permission?undefined:passport);
123
122
  }
124
-
125
123
  obj = Arbitration.New(txb, this.data.type_parameter!, permission ? permission.get_object() : permission_address, this.data?.description??'',
126
124
  BigInt(this.data?.fee ?? 0), withdraw_treasury? withdraw_treasury.get_object() : treasury_address, permission?undefined:passport);
127
- } else if (object_address) {
125
+ } else {
128
126
  if (IsValidAddress(object_address) && this.data.type_parameter && permission_address) {
129
127
  obj = Arbitration.From(txb, this.data.type_parameter, permission_address, object_address)
130
128
  } else {
@@ -136,9 +134,6 @@ export class CallArbitration extends CallBase {
136
134
  if (this.data?.description !== undefined && object_address) {
137
135
  obj?.set_description(this.data.description, passport);
138
136
  }
139
- if (this.data?.bPaused !== undefined) {
140
- obj?.pause(this.data.bPaused, passport);
141
- }
142
137
  if (this.data?.endpoint !== undefined) {
143
138
  obj?.set_endpoint(this.data.endpoint, passport)
144
139
  }
@@ -148,8 +143,20 @@ export class CallArbitration extends CallBase {
148
143
  if (treasury_address !== undefined && object_address) {
149
144
  obj?.set_withdrawTreasury(treasury_address, passport)
150
145
  }
151
- if (this.data.usage_guard !== undefined) {
152
- obj?.set_guard(this.data.usage_guard, passport)
146
+ if (this.data?.arb_new !== undefined) {
147
+ await this.new_with_mark(txb, obj?.dispute(this.data.arb_new.data, passport), (this.data?.arb_new as any)?.namedNew, account);
148
+ }
149
+ if (this.data?.arb_arbitration !== undefined) {
150
+ obj?.arbitration(this.data.arb_arbitration, passport)
151
+ }
152
+ if (this.data?.arb_vote !== undefined) {
153
+ obj?.vote(this.data.arb_vote, passport)
154
+ }
155
+ if (this.data?.arb_withdraw_fee !== undefined) {
156
+ obj?.withdraw_fee(this.data.arb_withdraw_fee.arb, this.data.arb_withdraw_fee.data, passport)
157
+ }
158
+ if (this.data?.permission_new !== undefined) {
159
+ obj?.change_permission(this.data.permission_new);
153
160
  }
154
161
  if (this.data?.voting_guard !== undefined) {
155
162
  switch (this.data.voting_guard.op) {
@@ -168,23 +175,12 @@ export class CallArbitration extends CallBase {
168
175
  break;
169
176
  }
170
177
  }
171
-
172
- if (this.data?.arb_new !== undefined) {
173
- await this.new_with_mark(txb, obj?.dispute(this.data.arb_new.data, passport), (this.data?.arb_new as any)?.namedNew, account);
174
- }
175
- if (this.data?.arb_arbitration !== undefined) {
176
- obj?.arbitration(this.data.arb_arbitration, passport)
177
- }
178
- if (this.data?.arb_vote !== undefined) {
179
- obj?.vote(this.data.arb_vote, passport)
180
- }
181
- if (this.data?.arb_withdraw_fee !== undefined) {
182
- obj?.withdraw_fee(this.data.arb_withdraw_fee.arb, this.data.arb_withdraw_fee.data, passport)
178
+ if (this.data.usage_guard !== undefined) {
179
+ obj?.set_guard(this.data.usage_guard, passport)
183
180
  }
184
- if (this.data?.permission_new !== undefined) {
185
- obj?.change_permission(this.data.permission_new);
181
+ if (this.data?.bPaused !== undefined) {
182
+ obj?.pause(this.data.bPaused, passport);
186
183
  }
187
-
188
184
  if (withdraw_treasury) {
189
185
  await this.new_with_mark(txb, withdraw_treasury.launch(), (this.data?.fee_treasury as any)?.namedNew, account);
190
186
  }
package/src/call/base.ts CHANGED
@@ -9,7 +9,7 @@ import { Account } from '../account';
9
9
  import { ObjectBase, queryTableItem_Personal, raw2type} from '../objects';
10
10
 
11
11
  export interface Namedbject {
12
- name: string;
12
+ name?: string;
13
13
  tags?: string[];
14
14
  }
15
15
 
@@ -32,6 +32,7 @@ export interface CallWithWitnessParam {
32
32
  }
33
33
  export type CallResult = GuardInfo_forCall | CallResponse | undefined;
34
34
 
35
+
35
36
  export function ResponseData(response: CallResponse | undefined) : ResponseData[] {
36
37
  const res : ResponseData[] = [];
37
38
  response?.objectChanges?.forEach(v => {
package/src/call/guard.ts CHANGED
@@ -5,7 +5,8 @@
5
5
 
6
6
  import { Bcs, ContextType, ERROR, Errors, IsValidU8, OperatorType, ValueType, GUARD_QUERIES, IsValidAddress,
7
7
  concatenate, TransactionBlock, Protocol, FnCallType, hasDuplicates, insertAtHead, CallResponse,
8
- IsValidDesription, PassportObject} from "wowok";
8
+ IsValidDesription, PassportObject,
9
+ IsValidGuardIdentifier} from "wowok";
9
10
  import { CallBase, CallResult, Namedbject } from "./base";
10
11
 
11
12
  export interface GuardConst {
@@ -26,6 +27,7 @@ export type GuardNode = { identifier: number; } // Data from GuardConst
26
27
  | {calc: OperatorType.TYPE_NUMBER_ADD | OperatorType.TYPE_NUMBER_DEVIDE | OperatorType.TYPE_NUMBER_MOD
27
28
  | OperatorType.TYPE_NUMBER_MULTIPLY | OperatorType.TYPE_NUMBER_SUBTRACT; parameters: GuardNode[];}
28
29
  | {value_type: ValueType; value:any; } // Data
30
+ | {identifier: number} // data from GuardConst
29
31
  | {context: ContextType.TYPE_CLOCK | ContextType.TYPE_GUARD | ContextType.TYPE_SIGNER }; // Data from run-time environment
30
32
 
31
33
  export interface CallGuard_Data {
@@ -74,7 +76,6 @@ export class CallGuard extends CallBase {
74
76
  this.data?.table?.forEach((v) => {
75
77
  if (v.bWitness) {
76
78
  const n = new Uint8Array(1); n.set([v.value_type], 0);
77
- console.log(n)
78
79
  txb.moveCall({
79
80
  target:Protocol.Instance().guardFn("constant_add") as FnCallType,
80
81
  arguments:[txb.object(obj), txb.pure.u8(v.identifier), txb.pure.bool(true), txb.pure.vector('u8', [].slice.call(n)), txb.pure.bool(false)]
@@ -107,13 +108,13 @@ const buildNode = (guard_node:GuardNode, type_required:ValueType | 'number' | 'v
107
108
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, ContextType.TYPE_CONSTANT));
108
109
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, node.identifier))
109
110
  } else {
110
- ERROR(Errors.InvalidParam, 'node identifier - ' + node.toString());
111
+ ERROR(Errors.InvalidParam, 'node identifier - ' + JSON.stringify(node));
111
112
  }
112
113
  } else if (node?.query !== undefined) {
113
114
  var q: any[] | undefined;
114
- if (typeof(node.query === 'string')) {
115
+ if (typeof(node.query) === 'string') {
115
116
  q = GUARD_QUERIES.find(v=>v[1] === node.query);
116
- } else if (typeof(node.query === 'number')) {
117
+ } else if (typeof(node.query) === 'number') {
117
118
  q = GUARD_QUERIES.find(v=>v[2] === node.query);
118
119
  }
119
120
  if (!q) ERROR(Errors.InvalidParam, 'query invalid - ' + node?.query);
@@ -124,13 +125,13 @@ const buildNode = (guard_node:GuardNode, type_required:ValueType | 'number' | 'v
124
125
  buildNode(node.parameters[i], q![3][i], table, output); // Recursive check
125
126
  }
126
127
  } else {
127
- ERROR(Errors.InvalidParam, 'node query parameters length not match - ' + node.toString())
128
+ ERROR(Errors.InvalidParam, 'node query parameters length not match - ' + JSON.stringify(node))
128
129
  }
129
130
 
130
131
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, OperatorType.TYPE_QUERY)); // QUERY TYPE + addr + cmd
131
132
  if (typeof(node.object) === 'string') {
132
133
  if (!IsValidAddress(node.object)) {
133
- ERROR(Errors.InvalidParam, 'node object from address string - ' + node.toString())
134
+ ERROR(Errors.InvalidParam, 'node object from address string - ' + JSON.stringify(node))
134
135
  }
135
136
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, ValueType.TYPE_ADDRESS));
136
137
  output.push(Bcs.getInstance().ser(ValueType.TYPE_ADDRESS, node.object)); // object address
@@ -141,7 +142,7 @@ const buildNode = (guard_node:GuardNode, type_required:ValueType | 'number' | 'v
141
142
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, ContextType.TYPE_CONSTANT));
142
143
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, node.object)); // object id
143
144
  } else {
144
- ERROR(Errors.InvalidParam, 'node object from identifier - ' + node.toString());
145
+ ERROR(Errors.InvalidParam, 'node object from identifier - ' + JSON.stringify(node));
145
146
  }
146
147
  }
147
148
  output.push(Bcs.getInstance().ser('u16', q![2])); // cmd(u16)
@@ -149,18 +150,18 @@ const buildNode = (guard_node:GuardNode, type_required:ValueType | 'number' | 'v
149
150
  checkType(ValueType.TYPE_BOOL, type_required, node); // bool
150
151
  switch (node?.logic) {
151
152
  case OperatorType.TYPE_LOGIC_ALWAYS_TRUE:
152
- if (node.parameters.length !== 0) ERROR(Errors.InvalidParam, 'node logic parameters length must be 0'+ node.toString());
153
+ if (node.parameters.length !== 0) ERROR(Errors.InvalidParam, 'node logic parameters length must be 0'+ JSON.stringify(node));
153
154
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, node.logic)); // TYPE
154
155
  break;
155
156
  case OperatorType.TYPE_LOGIC_AND:
156
157
  case OperatorType.TYPE_LOGIC_OR:
157
- if (node.parameters.length < 2) ERROR(Errors.InvalidParam, 'node logic parameters length must >= 2'+ node.toString());
158
+ if (node.parameters.length < 2) ERROR(Errors.InvalidParam, 'node logic parameters length must >= 2'+ JSON.stringify(node));
158
159
  (node.parameters as GuardNode[]).reverse().forEach(v => buildNode(v, ValueType.TYPE_BOOL, table, output)); // reserve
159
160
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, node.logic)); // TYPE
160
161
  output.push((Bcs.getInstance().ser(ValueType.TYPE_U8, node.parameters.length)));
161
162
  break;
162
163
  case OperatorType.TYPE_LOGIC_NOT:
163
- if (node.parameters.length !== 1) ERROR(Errors.InvalidParam, 'node logic parameters length must be 1'+ node.toString());
164
+ if (node.parameters.length !== 1) ERROR(Errors.InvalidParam, 'node logic parameters length must be 1'+ JSON.stringify(node));
164
165
  (node.parameters as GuardNode[]).reverse().forEach(v => buildNode(v, ValueType.TYPE_BOOL, table, output)); // reserve
165
166
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, node.logic)); // TYPE
166
167
  break;
@@ -169,20 +170,20 @@ const buildNode = (guard_node:GuardNode, type_required:ValueType | 'number' | 'v
169
170
  case OperatorType.TYPE_LOGIC_AS_U256_LESSER:
170
171
  case OperatorType.TYPE_LOGIC_AS_U256_LESSER_EQUAL:
171
172
  case OperatorType.TYPE_LOGIC_AS_U256_EQUAL:
172
- if (node.parameters.length < 2) ERROR(Errors.InvalidParam, 'node logic parameters length must >= 2'+ node.toString());
173
+ if (node.parameters.length < 2) ERROR(Errors.InvalidParam, 'node logic parameters length must >= 2'+ JSON.stringify(node));
173
174
  (node.parameters as GuardNode[]).reverse().forEach(v => buildNode(v, 'number', table, output));
174
175
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, node.logic)); // TYPE
175
176
  output.push((Bcs.getInstance().ser(ValueType.TYPE_U8, node.parameters.length)));
176
177
  break;
177
178
  case OperatorType.TYPE_LOGIC_EQUAL:
178
- if (node.parameters.length < 2) ERROR(Errors.InvalidParam, 'node logic parameters length must >= 2'+ node.toString());
179
+ if (node.parameters.length < 2) ERROR(Errors.InvalidParam, 'node logic parameters length must >= 2'+ JSON.stringify(node));
179
180
  var any_type: any = 'variable';
180
181
  (node.parameters as GuardNode[]).reverse().forEach(v => buildNode(v, any_type, table, output));
181
182
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, node.logic)); // TYPE
182
183
  output.push((Bcs.getInstance().ser(ValueType.TYPE_U8, node.parameters.length)));
183
184
  break;
184
185
  case OperatorType.TYPE_LOGIC_HAS_SUBSTRING:
185
- if (node.parameters.length < 2) ERROR(Errors.InvalidParam, 'node logic parameters length must >= 2'+ node.toString());
186
+ if (node.parameters.length < 2) ERROR(Errors.InvalidParam, 'node logic parameters length must >= 2'+ JSON.stringify(node));
186
187
  (node.parameters as GuardNode[]).reverse().forEach(v => buildNode(v, ValueType.TYPE_STRING, table, output));
187
188
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, node.logic)); // TYPE
188
189
  output.push((Bcs.getInstance().ser(ValueType.TYPE_U8, node.parameters.length)));
@@ -190,13 +191,13 @@ const buildNode = (guard_node:GuardNode, type_required:ValueType | 'number' | 'v
190
191
  }
191
192
  } else if (node?.calc !== undefined) {
192
193
  checkType(ValueType.TYPE_U256, type_required, node);
193
- if (node.parameters.length < 2) ERROR(Errors.InvalidParam, 'node calc parameters length must >= 2'+ node.toString());
194
+ if (node.parameters.length < 2) ERROR(Errors.InvalidParam, 'node calc parameters length must >= 2'+ JSON.stringify(node));
194
195
  (node.parameters as GuardNode[]).reverse().forEach(v => buildNode(v, 'number', table, output));
195
196
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, node.calc)); // TYPE
196
197
  output.push((Bcs.getInstance().ser(ValueType.TYPE_U8, node.parameters.length)));
197
198
  } else if (node?.value_type !== undefined) {
198
199
  checkType(node?.value_type, type_required, node);
199
- if (node?.value === undefined) ERROR(Errors.InvalidParam, 'node value undefined - ' + node.toString());
200
+ if (node?.value === undefined) ERROR(Errors.InvalidParam, 'node value undefined - ' + JSON.stringify(node));
200
201
  output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, node.value_type)); // TYPE
201
202
 
202
203
  if (node.value_type == ValueType.TYPE_STRING || node.value_type === ValueType.TYPE_VEC_U8) {
@@ -219,8 +220,15 @@ const buildNode = (guard_node:GuardNode, type_required:ValueType | 'number' | 'v
219
220
  checkType(ValueType.TYPE_ADDRESS, type_required, node);
220
221
  break;
221
222
  }
223
+ } else if (node?.identifier !== undefined) {
224
+ if (!IsValidGuardIdentifier(node.identifier)) ERROR(Errors.IsValidGuardIdentifier, 'node - '+JSON.stringify(node));
225
+ const i = table.find(v => v.identifier === node.identifier);
226
+ if (!i) ERROR(Errors.InvalidParam, 'identifier not found. node - '+JSON.stringify(node));
227
+ checkType(i!.value_type, type_required, node);
228
+ output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, ContextType.TYPE_CONSTANT));
229
+ output.push(Bcs.getInstance().ser(ValueType.TYPE_U8, node.identifier));
222
230
  } else {
223
- ERROR(Errors.InvalidParam, 'node - ' + node.toString())
231
+ ERROR(Errors.InvalidParam, 'node - ' + JSON.stringify(node))
224
232
  }
225
233
  }
226
234
 
@@ -250,8 +258,7 @@ const checkType = (type: ValueType | ContextType.TYPE_CLOCK | ContextType.TYPE_G
250
258
 
251
259
  if (type !== type_required) {
252
260
  var str = '';
253
- if (node) str = ' - ' + node.toString();
254
- console.log(node)
261
+ if (node) str = ' - ' + JSON.stringify(node);
255
262
  ERROR(Errors.InvalidParam, 'checkType: ' + type + ' require type: ' + type_required + str);
256
263
  }
257
264
  }
@@ -30,7 +30,7 @@ export interface CallMachine_Data {
30
30
  progress_next?: {progress:string; data:ProgressNext; deliverable:Deliverable; guard?:string | 'fetch'};
31
31
  }
32
32
  export class CallMachine extends CallBase { //@ todo self-owned node operate
33
- data: CallMachine_Data
33
+ data: CallMachine_Data;
34
34
  constructor(data:CallMachine_Data) {
35
35
  super();
36
36
  this.data = data;
@@ -210,13 +210,13 @@ export class CallMachine extends CallBase { //@ todo self-owned node operate
210
210
  if (this.data?.bPublished ) {
211
211
  obj?.publish(passport)
212
212
  }
213
- if (this.data?.clone_new && obj) {
213
+ if (this.data?.clone_new !== undefined && obj) {
214
214
  await this.new_with_mark(txb, obj?.clone(true, passport) as TxbAddress, (this.data?.clone_new as any)?.namedNew, account);
215
215
  }
216
216
  if (permission) {
217
217
  await this.new_with_mark(txb, permission.launch(), (this.data?.permission as any)?.namedNew, account);
218
218
  }
219
- if (!this.data.object) {
219
+ if (!object_address) {
220
220
  await this.new_with_mark(txb, obj.launch(), (this.data?.object as any)?.namedNew, account);
221
221
  }
222
222
  }
@@ -1,8 +1,5 @@
1
1
  import { CallBase, CallResult } from "./base";
2
- import { TransactionBlock, CallResponse, Protocol, Demand, DemandObject, Machine, Service, Treasury, Arbitration, Repository} from 'wowok';
3
- import { PassportObject, IsValidAddress, Errors, ERROR, Permission, Permission_Entity, Permission_Index, UserDefinedIndex,
4
- PermissionIndexType, WitnessFill
5
- } from 'wowok';
2
+ import { TransactionBlock, PassportObject, IsValidAddress, Errors, ERROR, Demand, Machine, Service, Treasury, Arbitration, Repository} from 'wowok';
6
3
  import { ObjectArbitration, ObjectDemand, ObjectMachine, ObjectRepository, ObjectService, ObjectTreasury, query_objects } from "../objects";
7
4
 
8
5
  export interface CallObjectPermission_Data {
@@ -1,17 +1,17 @@
1
1
  import { CallBase, CallResult, Namedbject } from "./base";
2
- import { PassportObject, IsValidAddress, Errors, ERROR, Permission, Permission_Entity, Permission_Index, UserDefinedIndex,
2
+ import { PassportObject, IsValidAddress, Errors, ERROR, Permission, Permission_Entity, Permission_Index, BizPermission,
3
3
  PermissionIndexType, TransactionBlock
4
4
  } from 'wowok';
5
5
 
6
6
  export interface CallPermission_Data {
7
7
  object?: {address:string} | {namedNew: Namedbject}; // undefined or {named_new...} for creating a new object
8
8
  builder?: string;
9
- admin?: {op:'add' | 'remove' | 'set', admins:string[]};
9
+ admin?: {op:'add' | 'remove' | 'set', address:string[]};
10
10
  description?: string;
11
11
  permission?: {op:'add entity'; entities:Permission_Entity[]} | {op:'add permission'; permissions:Permission_Index[]}
12
12
  | {op:'remove entity'; addresses:string[]} | {op:'remove permission'; address:string; index:PermissionIndexType[]}
13
13
  | {op:'transfer permission', from_address: string; to_address: string};
14
- biz_permission?: {op:'add'; data: UserDefinedIndex[]} | {op:'remove'; permissions: PermissionIndexType[]};
14
+ biz_permission?: {op:'add'; data: BizPermission[]} | {op:'remove'; permissions: PermissionIndexType[]};
15
15
  }
16
16
  export class CallPermission extends CallBase {
17
17
  data: CallPermission_Data;
@@ -53,12 +53,12 @@ export class CallPermission extends CallBase {
53
53
  switch(this.data.biz_permission.op) {
54
54
  case 'add':
55
55
  this.data.biz_permission.data.forEach(v => {
56
- obj?.add_userdefine(v.index, v.name);
56
+ obj?.add_bizPermission(v.index, v.name);
57
57
  })
58
58
  break;
59
59
  case 'remove':
60
60
  this.data.biz_permission.permissions.forEach(v => {
61
- obj?.remove_userdefine(v);
61
+ obj?.remove_bizPermission(v);
62
62
  })
63
63
  break;
64
64
  }
@@ -88,14 +88,14 @@ export class CallPermission extends CallBase {
88
88
  if (this.data?.admin !== undefined) {
89
89
  switch(this.data.admin.op) {
90
90
  case 'add':
91
- obj?.add_admin(this.data.admin.admins);
91
+ obj?.add_admin(this.data.admin.address);
92
92
  break;
93
93
  case 'remove':
94
- obj?.remove_admin(this.data.admin.admins);
94
+ obj?.remove_admin(this.data.admin.address);
95
95
  break;
96
96
  case 'set':
97
97
  obj?.remove_admin([], true);
98
- obj?.add_admin(this.data.admin.admins);
98
+ obj?.add_admin(this.data.admin.address);
99
99
  break
100
100
  }
101
101
  }
@@ -5,11 +5,12 @@ import { CallBase, CallResult, Namedbject } from "./base";
5
5
  export interface CallPersonal_Data {
6
6
  object?: {address:string} | {namedNew: Namedbject}; // undefined or {named_new...} for creating a new object
7
7
  information?: Entity_Info;
8
- transfer_to?: string;
9
8
  mark?: {op:'add'; data:{address:string; name?:string; tags:string[]}[]}
10
9
  | {op:'remove'; data:{address:string; tags:string[]}[]}
11
- | {op:'removeall'; address:string[]};
12
- close?: boolean; // close a personal resource
10
+ | {op:'removeall'; address:string[],}
11
+ | {op:'transfer'; address: string}
12
+ | {op:'destroy';}
13
+ | {op:'replace'; address: string};
13
14
  }
14
15
 
15
16
  export class CallPersonal extends CallBase {
@@ -31,7 +32,7 @@ export class CallPersonal extends CallBase {
31
32
  obj = Resource.From(txb, object_address)
32
33
  }
33
34
 
34
- if (this.data?.close) {
35
+ if (this.data?.mark?.op === 'destroy') {
35
36
  entity.destroy_resource(obj)
36
37
  return ; //@ return
37
38
  }
@@ -60,8 +61,11 @@ export class CallPersonal extends CallBase {
60
61
  break;
61
62
  }
62
63
  }
63
- if (this.data?.transfer_to !== undefined && obj) {
64
- entity.transfer_resource(obj, this.data.transfer_to);
64
+ if (this.data?.mark?.op === 'transfer' && obj && IsValidAddress(this.data.mark.address)) {
65
+ entity.transfer_resource(obj, this.data.mark.address);
66
+ }
67
+ if (this.data?.mark?.op === 'replace' && IsValidAddress(this.data.mark.address)) {
68
+ entity.use_resource(Resource.From(txb, this.data.mark.address));
65
69
  }
66
70
 
67
71
  if (!object_address && obj) {
@@ -15,7 +15,7 @@ export interface CallService_Data {
15
15
  bPublished?: boolean;
16
16
  description?: string;
17
17
  gen_discount?: DicountDispatch[];
18
- arbitration?: {op:'set' | 'add'; arbitrations:{address:string, token_type:string}[]}
18
+ arbitration?: {op:'set' | 'add'; arbitrations:{address:string, type_parameter:string}[]}
19
19
  | {op:'removeall'} | {op:'remove', addresses:string[]};
20
20
  buy_guard?: string;
21
21
  endpoint?: string;
@@ -184,6 +184,9 @@ export class CallService extends CallBase {
184
184
  if (this.data?.machine !== undefined) {
185
185
  obj?.set_machine(this.data.machine, passport)
186
186
  }
187
+ if (this.data?.gen_discount !== undefined) {
188
+ obj?.discount_transfer(this.data.gen_discount, passport)
189
+ }
187
190
  if (this.data?.repository !== undefined) {
188
191
  switch (this.data.repository.op) {
189
192
  case 'add':
@@ -221,11 +224,11 @@ export class CallService extends CallBase {
221
224
  if (this.data?.arbitration !== undefined) {
222
225
  switch(this.data.arbitration.op) {
223
226
  case 'add':
224
- this.data.arbitration.arbitrations.forEach(v=>obj?.add_arbitration(v.address, v.token_type, passport))
227
+ this.data.arbitration.arbitrations.forEach(v=>obj?.add_arbitration(v.address, v.type_parameter, passport))
225
228
  break;
226
229
  case 'set':
227
230
  obj?.remove_arbitration([], true, passport)
228
- this.data.arbitration.arbitrations.forEach(v=>obj?.add_arbitration(v.address, v.token_type, passport))
231
+ this.data.arbitration.arbitrations.forEach(v=>obj?.add_arbitration(v.address, v.type_parameter, passport))
229
232
  break;
230
233
  case 'remove':
231
234
  obj?.remove_arbitration(this.data.arbitration.addresses, false, passport)
@@ -235,9 +238,6 @@ export class CallService extends CallBase {
235
238
  break;
236
239
  }
237
240
  }
238
- if (this.data?.gen_discount !== undefined) {
239
- obj?.discount_transfer(this.data.gen_discount, passport)
240
- }
241
241
  if (this.data?.sales !== undefined) {
242
242
  switch(this.data.sales.op) {
243
243
  case 'add':
package/src/call.ts CHANGED
@@ -16,25 +16,26 @@ import { CallBase, CallResult, CallWithWitnessParam } from "./call/base";
16
16
  import { CallGuard, CallGuard_Data } from "./call/guard";
17
17
  import { CallObjectPermission, CallObjectPermission_Data } from "./call/object_permission";
18
18
 
19
-
20
- export interface CallObjectData {
21
- type: 'Demand' | 'Service' | 'Machine' | 'Treasury' | 'Arbitration' | 'Guard' | 'Repository' | 'Personal' | 'Permission' | 'ObjectPermission';
22
- data: CallDemand_Data | CallMachine_Data | CallArbitration_Data | CallPermission_Data | CallObjectPermission_Data
23
- | CallTreasury_Data | CallService_Data | CallRepository_Data;
19
+ export type CallObjectType = 'Demand' | 'Service' | 'Machine' | 'Treasury' | 'Arbitration' | 'Guard' | 'Repository' | 'Personal' | 'Permission' | 'ObjectPermission';
20
+ export type CallObjectData = CallDemand_Data | CallMachine_Data | CallArbitration_Data | CallPermission_Data | CallObjectPermission_Data
21
+ | CallTreasury_Data | CallService_Data | CallRepository_Data;
22
+ export interface CallObject {
23
+ type: CallObjectType;
24
+ data: CallObjectData;
24
25
  account?: string;
25
26
  witness?: CallWithWitnessParam;
26
27
  }
27
28
 
28
29
  export const call_object_json = async (json: string) : Promise<string> => {
29
30
  try {
30
- const c : CallObjectData = JSON.parse(json);
31
+ const c : CallObject = JSON.parse(json);
31
32
  return JSON.stringify({data:await call_object(c)});
32
33
  } catch (e) {
33
34
  return JSON.stringify({error:e?.toString()})
34
35
  }
35
36
  }
36
37
 
37
- export const call_object = async (call: CallObjectData) : Promise<CallResult> => {
38
+ export const call_object = async (call: CallObject) : Promise<CallResult> => {
38
39
  var obj = call_object_new(call);
39
40
 
40
41
  if (obj) {
@@ -46,7 +47,7 @@ export const call_object = async (call: CallObjectData) : Promise<CallResult> =>
46
47
  }
47
48
  }
48
49
 
49
- function call_object_new (call: CallObjectData) : CallBase | undefined {
50
+ function call_object_new (call: CallObject) : CallBase | undefined {
50
51
  switch (call.type) {
51
52
  case 'Demand':
52
53
  return new CallDemand(call.data as CallDemand_Data);
package/src/objects.ts CHANGED
@@ -461,7 +461,7 @@ export function raw2type(type_raw:string | undefined) : ObjectBaseType | undefin
461
461
 
462
462
  const t = Protocol.Instance().object_name_from_type_repr(type_raw);
463
463
  if (t === 'Permission' || t === 'Demand' || t === 'Machine' || t === 'Progress' || t === 'Order' || t === 'Service' ||
464
- t === 'Treasury' || t === 'Arb' || t === 'Repository' || t === 'Payment' || t === 'Discount' || t === 'Guard') {
464
+ t === 'Treasury' || t === 'Arb' || t === 'Repository' || t === 'Payment' || t === 'Discount' || t === 'Guard' || t === 'Arbitration') {
465
465
  return t
466
466
  } else if (t === 'Resource') {
467
467
  return 'PersonalMark';