wowok_agent 1.2.45 → 1.3.48
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 +14 -28
- package/dist/call/arbitration.d.ts.map +1 -1
- package/dist/call/arbitration.js +158 -145
- package/dist/call/arbitration.js.map +1 -1
- package/dist/call/base.d.ts +33 -2
- package/dist/call/base.d.ts.map +1 -1
- package/dist/call/base.js +49 -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 +10 -22
- package/dist/call/demand.d.ts.map +1 -1
- package/dist/call/demand.js +107 -109
- package/dist/call/demand.js.map +1 -1
- package/dist/call/machine.d.ts +36 -44
- package/dist/call/machine.d.ts.map +1 -1
- package/dist/call/machine.js +179 -179
- 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 +31 -18
- package/dist/call/permission.d.ts.map +1 -1
- package/dist/call/permission.js +92 -86
- 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 +5 -12
- package/dist/call/repository.d.ts.map +1 -1
- package/dist/call/repository.js +114 -92
- package/dist/call/repository.js.map +1 -1
- package/dist/call/service.d.ts +51 -70
- package/dist/call/service.d.ts.map +1 -1
- package/dist/call/service.js +335 -302
- package/dist/call/service.js.map +1 -1
- package/dist/call/treasury.d.ts +23 -26
- package/dist/call/treasury.d.ts.map +1 -1
- package/dist/call/treasury.js +124 -112
- 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/objects.d.ts +6 -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 +178 -161
- package/src/call/base.ts +84 -10
- package/src/call/call.ts +6 -0
- package/src/call/demand.ts +120 -121
- package/src/call/machine.ts +193 -194
- package/src/call/object_permission.ts +1 -1
- package/src/call/permission.ts +121 -90
- package/src/call/personal.ts +18 -20
- package/src/call/repository.ts +120 -101
- package/src/call/service.ts +375 -325
- package/src/call/treasury.ts +143 -121
- package/src/common.ts +7 -1
- package/src/local/account.ts +1 -1
- package/src/local/local.ts +6 -2
- package/src/query/objects.ts +17 -4
- package/tsconfig.tsbuildinfo +1 -1
package/src/call/treasury.ts
CHANGED
|
@@ -1,63 +1,75 @@
|
|
|
1
|
-
import { TransactionBlock, IsValidArgType, PassportObject,
|
|
2
|
-
PermissionIndexType, Treasury, Treasury_WithdrawMode, WithdrawParam,
|
|
1
|
+
import { TransactionBlock, IsValidArgType, PassportObject, Errors, ERROR, Permission, PermissionIndex,
|
|
2
|
+
PermissionIndexType, Treasury, Treasury_WithdrawMode, WithdrawParam,
|
|
3
|
+
PermissionObject,
|
|
3
4
|
} from 'wowok';
|
|
4
|
-
import { query_objects, ObjectTreasury } from '../query/objects.js';
|
|
5
|
-
import { CallBase, CallResult,
|
|
5
|
+
import { query_objects, ObjectTreasury, Treasury_ReceivedObject } from '../query/objects.js';
|
|
6
|
+
import { AccountOrMark_Address, CallBase, CallResult, GetAccountOrMark_Address, GetObjectExisted,
|
|
7
|
+
GetObjectMain, GetObjectParam, ObjectTypedMain, TypeNamedObjectWithPermission } from "./base.js";
|
|
6
8
|
import { Account } from '../local/account.js';
|
|
7
9
|
import { LocalMark } from '../local/local.js';
|
|
8
10
|
import { get_object_address } from '../common.js';
|
|
9
11
|
|
|
12
|
+
export interface ReceiverParam {
|
|
13
|
+
address: AccountOrMark_Address;
|
|
14
|
+
amount: string|number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface TreasuryWithdrawParam extends WithdrawParam {
|
|
18
|
+
receiver: ReceiverParam[];
|
|
19
|
+
withdraw_guard?: string,
|
|
20
|
+
}
|
|
21
|
+
|
|
10
22
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
11
23
|
export interface CallTreasury_Data {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
object: ObjectTypedMain;
|
|
25
|
+
deposit?: {balance:string|number; index?:number|string; remark?:string; for_object?:string; for_guard?:string};
|
|
26
|
+
receive?: {received_objects:string[]} | 'recently';
|
|
27
|
+
withdraw?: TreasuryWithdrawParam;
|
|
28
|
+
|
|
15
29
|
description?: string;
|
|
16
|
-
deposit?: {data:{balance:string|number; index?:number|string; remark?:string; for_object?:string; for_guard?:string}; guard?:string};
|
|
17
|
-
receive?: {payment:string; received_object:string};
|
|
18
|
-
withdraw?: WithdrawParam;
|
|
19
30
|
deposit_guard?: string;
|
|
20
31
|
withdraw_guard?: {op:'add' | 'set'; data:{guard:string, amount:string|number}[]} | {op:'remove', guards:string[]} | {op:'removeall'};
|
|
21
32
|
withdraw_mode?: Treasury_WithdrawMode;
|
|
22
33
|
}
|
|
23
34
|
export class CallTreasury extends CallBase {
|
|
24
35
|
data: CallTreasury_Data;
|
|
36
|
+
object_address: string | undefined = undefined;
|
|
37
|
+
permission_address: string | undefined = undefined;
|
|
38
|
+
type_parameter: string | undefined = undefined;
|
|
39
|
+
|
|
25
40
|
constructor(data:CallTreasury_Data) {
|
|
26
41
|
super();
|
|
27
42
|
this.data = data;
|
|
28
43
|
}
|
|
29
44
|
|
|
30
|
-
async
|
|
31
|
-
if (!this.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (this.content) {
|
|
46
|
-
permission_address = (this.content as ObjectTreasury).permission;
|
|
47
|
-
this.data.type_parameter = this.content.type_raw!;
|
|
48
|
-
}
|
|
45
|
+
protected async prepare(): Promise<void> {
|
|
46
|
+
if (!this.object_address) {
|
|
47
|
+
this.object_address = (await LocalMark.Instance().get_address(GetObjectExisted(this.data.object)));
|
|
48
|
+
if (this.object_address) {
|
|
49
|
+
await this.update_content('Treasury', this.object_address);
|
|
50
|
+
if (!this.content) ERROR(Errors.InvalidParam, 'CallArbitration_Data.data.object:' + this.object_address);
|
|
51
|
+
this.permission_address = (this.content as ObjectTreasury).permission;
|
|
52
|
+
this.type_parameter = Treasury.parseObjectType(this.content.type_raw);
|
|
53
|
+
} else {
|
|
54
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
55
|
+
if (!IsValidArgType(n?.type_parameter)) {
|
|
56
|
+
ERROR(Errors.IsValidArgType, 'CallTreasury_Data.data.object.type_parameter');
|
|
57
|
+
}
|
|
58
|
+
this.permission_address = (await LocalMark.Instance().get_address(GetObjectExisted(n?.permission)));
|
|
59
|
+
this.type_parameter = n.type_parameter;
|
|
49
60
|
}
|
|
50
|
-
} else {
|
|
51
|
-
if (!this.data?.type_parameter || !IsValidArgType(this.data.type_parameter)) {
|
|
52
|
-
ERROR(Errors.IsValidArgType, 'CallTreasury_Data.data.type_parameter')
|
|
53
|
-
}
|
|
54
61
|
}
|
|
62
|
+
}
|
|
63
|
+
async call(account?:string) : Promise<CallResult> {
|
|
64
|
+
var checkOwner = false; const guards : string[] = [];
|
|
65
|
+
const perms : PermissionIndexType[] = [];
|
|
55
66
|
|
|
56
|
-
|
|
67
|
+
await this.prepare();
|
|
68
|
+
if (this.permission_address) {
|
|
57
69
|
if (!this.data?.object) {
|
|
58
70
|
perms.push(PermissionIndex.treasury)
|
|
59
71
|
}
|
|
60
|
-
if (this.data?.description !== undefined && object_address) {
|
|
72
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
61
73
|
perms.push(PermissionIndex.treasury_descritption)
|
|
62
74
|
}
|
|
63
75
|
if (this.data?.withdraw_mode !== undefined) {
|
|
@@ -73,23 +85,9 @@ export class CallTreasury extends CallBase {
|
|
|
73
85
|
perms.push(PermissionIndex.treasury_deposit_guard)
|
|
74
86
|
}
|
|
75
87
|
if (this.data?.deposit !== undefined) {
|
|
76
|
-
if (this.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
guards.push(guard)
|
|
80
|
-
}
|
|
81
|
-
} else {
|
|
82
|
-
if (!object_address) {
|
|
83
|
-
const guard = await LocalMark.Instance().get_address(this.data.deposit_guard);
|
|
84
|
-
if (guard) {
|
|
85
|
-
guards.push(guard);
|
|
86
|
-
}
|
|
87
|
-
} else {
|
|
88
|
-
await this.update_content(object_address, 'Treasury');
|
|
89
|
-
|
|
90
|
-
if ((this.content as ObjectTreasury)?.deposit_guard) {
|
|
91
|
-
guards.push((this.content as ObjectTreasury).deposit_guard!)
|
|
92
|
-
}
|
|
88
|
+
if (this.object_address) {
|
|
89
|
+
if ((this.content as ObjectTreasury)?.deposit_guard) {
|
|
90
|
+
guards.push((this.content as ObjectTreasury).deposit_guard!)
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
93
|
}
|
|
@@ -104,92 +102,116 @@ export class CallTreasury extends CallBase {
|
|
|
104
102
|
} else { // withdraw with permission
|
|
105
103
|
perms.push(PermissionIndex.treasury_withdraw)
|
|
106
104
|
}
|
|
107
|
-
return await this.check_permission_and_call(permission_address, perms, guards, checkOwner, undefined, account)
|
|
105
|
+
return await this.check_permission_and_call(this.permission_address, perms, guards, checkOwner, undefined, account)
|
|
108
106
|
}
|
|
109
107
|
return await this.exec(account);
|
|
110
108
|
}
|
|
111
109
|
protected async operate (txb:TransactionBlock, passport?:PassportObject, account?:string) {
|
|
112
|
-
let obj : Treasury | undefined ; let
|
|
113
|
-
|
|
114
|
-
[(this.content as ObjectTreasury).permission, this.content.object] :
|
|
115
|
-
await LocalMark.Instance().get_many_address(
|
|
116
|
-
[(this.data?.permission as any)?.address,
|
|
117
|
-
(this.data?.object as any)?.address]);
|
|
110
|
+
let obj : Treasury | undefined ; let perm: Permission | undefined;
|
|
111
|
+
let permission : PermissionObject | undefined;
|
|
118
112
|
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
permission = Permission.New(txb, d);
|
|
123
|
-
}
|
|
124
|
-
obj = Treasury.New(txb, this.data.type_parameter!, permission ? permission.get_object() : permission_address, this.data?.description??'', permission?undefined:passport)
|
|
113
|
+
if (this.object_address) {
|
|
114
|
+
obj = Treasury.From(txb, this.type_parameter!, this.permission_address!, this.object_address);
|
|
115
|
+
permission = this.permission_address;
|
|
125
116
|
} else {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
117
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
118
|
+
permission = await LocalMark.Instance().get_address(GetObjectExisted(n?.permission));
|
|
119
|
+
if (!permission) {
|
|
120
|
+
perm = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
|
|
121
|
+
permission = perm.get_object();
|
|
130
122
|
}
|
|
123
|
+
|
|
124
|
+
obj = Treasury.New(txb, this.type_parameter!, permission,
|
|
125
|
+
this.data?.description??'', perm?undefined:passport)
|
|
131
126
|
}
|
|
132
127
|
|
|
133
|
-
if (obj)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
128
|
+
if (!obj) ERROR(Errors.InvalidParam, 'CallTreasury_Data.object:' + this.object_address);
|
|
129
|
+
if (!permission) ERROR(Errors.InvalidParam, 'CallTreasury_Data.permission:' + this.permission_address);
|
|
130
|
+
|
|
131
|
+
const pst = perm?undefined:passport;
|
|
132
|
+
if (this.data.deposit !== undefined) {
|
|
133
|
+
const coin = await Account.Instance().get_coin_object(txb, this.data.deposit.balance, account, this.type_parameter);
|
|
134
|
+
if (coin) {
|
|
135
|
+
const index = this.data.deposit?.index ?? 0;
|
|
136
|
+
const [for_guard, for_object] = await LocalMark.Instance().get_many_address([this.data.deposit?.for_guard, this.data.deposit?.for_object])
|
|
137
|
+
obj?.deposit({coin:coin, index:BigInt(index), remark:this.data.deposit.remark ??'', for_guard, for_object});
|
|
137
138
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
}
|
|
140
|
+
if (this.data?.receive !== undefined && this.object_address) {
|
|
141
|
+
if (this.data.receive === 'recently') {
|
|
142
|
+
const r = await Treasury.GetTreasuryRecievedObject(this.object_address, this.type_parameter!);
|
|
143
|
+
if (!r) {
|
|
144
|
+
ERROR(Errors.InvalidParam, 'CallTreasury_Data.data.receive.received_objects');
|
|
145
|
+
}
|
|
146
|
+
r.received.forEach(v => {
|
|
147
|
+
obj?.receive(v.payment, v.id, pst);
|
|
148
|
+
})
|
|
149
|
+
} else if (this.data.receive?.received_objects?.length > 0) {
|
|
150
|
+
const r = await query_objects({objects:this.data.receive.received_objects});
|
|
151
|
+
if (r?.objects?.length!== this.data.receive.received_objects.length) {
|
|
152
|
+
ERROR(Errors.InvalidParam, 'CallTreasury_Data.data.receive.received_objects');
|
|
146
153
|
}
|
|
147
|
-
}
|
|
148
|
-
if (this.data?.receive !== undefined) {
|
|
149
|
-
const [payment, receive] = await LocalMark.Instance().get_many_address([this.data.receive.payment, this.data.receive.received_object])
|
|
150
|
-
if (payment && receive) obj?.receive(payment, receive, pst);
|
|
151
|
-
}
|
|
152
154
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
for (let i=0; i<r?.objects?.length; ++i) {
|
|
156
|
+
if (r.objects[i].type !== 'Treasury_ReceivedObject') {
|
|
157
|
+
ERROR(Errors.InvalidParam, 'CallTreasury_Data.data.receive.received_objects:'+ r.objects[i].object);
|
|
158
|
+
}
|
|
159
|
+
const v = r.objects[i] as Treasury_ReceivedObject;
|
|
160
|
+
obj?.receive(v.payment, v.object, pst);
|
|
161
|
+
}
|
|
158
162
|
}
|
|
163
|
+
}
|
|
159
164
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
case 'set':
|
|
168
|
-
if (this.data.withdraw_guard.op === 'set') obj?.remove_withdraw_guard([], true, pst);
|
|
169
|
-
for (let i = 0; i < this.data.withdraw_guard.data.length; ++ i) {
|
|
170
|
-
let v = this.data.withdraw_guard.data[i];
|
|
171
|
-
const guard = await LocalMark.Instance().get_address(v.guard);
|
|
172
|
-
if (guard) obj?.add_withdraw_guard(guard, BigInt(v.amount), pst);
|
|
173
|
-
}
|
|
174
|
-
break;
|
|
175
|
-
case 'remove':
|
|
176
|
-
obj?.remove_withdraw_guard(await LocalMark.Instance().get_many_address2(this.data.withdraw_guard.guards), false, pst)
|
|
177
|
-
break;
|
|
165
|
+
if (this.data?.withdraw !== undefined) {
|
|
166
|
+
const [for_guard, for_object] = await LocalMark.Instance().get_many_address([this.data.withdraw?.for_guard, this.data.withdraw?.for_object]);
|
|
167
|
+
const receiver = [];
|
|
168
|
+
for (let i=0;i < this.data.withdraw.receiver.length; ++i) {
|
|
169
|
+
const v = this.data.withdraw.receiver[i];
|
|
170
|
+
const address = await GetAccountOrMark_Address(v.address);
|
|
171
|
+
if (!address) ERROR(Errors.InvalidParam, 'CallTreasury_Data.data.withdraw.receiver:'+ v.address);
|
|
178
172
|
|
|
179
|
-
|
|
180
|
-
obj?.remove_withdraw_guard([], true, pst)
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
173
|
+
receiver.push({address:address, amount:BigInt(v.amount)})
|
|
183
174
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
175
|
+
obj?.withdraw({items:receiver, index:this.data.withdraw.index ?? 0, remark:this.data.withdraw.remark??'',
|
|
176
|
+
for_guard, for_object, withdraw_guard: await LocalMark.Instance().get_address(this.data.withdraw.withdraw_guard)}, pst);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
180
|
+
obj?.set_description(this.data.description, pst);
|
|
181
|
+
}
|
|
182
|
+
if (this.data?.deposit_guard !== undefined) {
|
|
183
|
+
const guard = await LocalMark.Instance().get_address(this.data?.deposit_guard);
|
|
184
|
+
obj?.set_deposit_guard(guard, pst);
|
|
185
|
+
}
|
|
186
|
+
if (this.data?.withdraw_guard !== undefined) {
|
|
187
|
+
switch (this.data.withdraw_guard.op) {
|
|
188
|
+
case 'add':
|
|
189
|
+
case 'set':
|
|
190
|
+
if (this.data.withdraw_guard.op === 'set') obj?.remove_withdraw_guard([], true, pst);
|
|
191
|
+
for (let i = 0; i < this.data.withdraw_guard.data.length; ++ i) {
|
|
192
|
+
let v = this.data.withdraw_guard.data[i];
|
|
193
|
+
const guard = await LocalMark.Instance().get_address(v.guard);
|
|
194
|
+
if (guard) obj?.add_withdraw_guard(guard, BigInt(v.amount), pst);
|
|
195
|
+
}
|
|
196
|
+
break;
|
|
197
|
+
case 'remove':
|
|
198
|
+
obj?.remove_withdraw_guard(await LocalMark.Instance().get_many_address2(this.data.withdraw_guard.guards), false, pst)
|
|
199
|
+
break;
|
|
200
|
+
|
|
201
|
+
case 'removeall':
|
|
202
|
+
obj?.remove_withdraw_guard([], true, pst)
|
|
203
|
+
break;
|
|
189
204
|
}
|
|
190
|
-
if (!object_address) {
|
|
191
|
-
await this.new_with_mark('Treasury', txb, obj.launch(), (this.data?.object as any)?.namedNew, account);
|
|
192
|
-
}
|
|
193
205
|
}
|
|
206
|
+
if (this.data?.withdraw_mode !== undefined) {
|
|
207
|
+
obj?.set_withdraw_mode(this.data.withdraw_mode, pst)
|
|
208
|
+
}
|
|
209
|
+
if (perm) {
|
|
210
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
211
|
+
await this.new_with_mark('Permission', txb, perm.launch(), GetObjectParam(n?.permission), account);
|
|
212
|
+
}
|
|
213
|
+
if (!this.object_address) {
|
|
214
|
+
await this.new_with_mark('Treasury', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
215
|
+
}
|
|
194
216
|
}
|
|
195
217
|
}
|
package/src/common.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LocalMark } from "./local/local.js";
|
|
2
|
-
|
|
2
|
+
import NodeRSA from 'node-rsa';
|
|
3
3
|
|
|
4
4
|
export const isBrowser = () => {
|
|
5
5
|
return typeof window !== 'undefined' && typeof indexedDB !== 'undefined';
|
|
@@ -11,4 +11,10 @@ export const get_object_address = async (object: any) => {
|
|
|
11
11
|
} else {
|
|
12
12
|
return object
|
|
13
13
|
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const crypto_string = (str: string, pubkey:string) : string => {
|
|
17
|
+
const rsa = new NodeRSA();
|
|
18
|
+
rsa.importKey(pubkey, 'pkcs8-public-pem');
|
|
19
|
+
return rsa.encrypt(str, 'base64');
|
|
14
20
|
}
|
package/src/local/account.ts
CHANGED
|
@@ -255,7 +255,7 @@ export class Account {
|
|
|
255
255
|
|
|
256
256
|
get_coin_object = async (txb: TransactionBlock, balance_required:string | bigint | number, address_or_name?:string, token_type?:string) : Promise<TransactionResult | undefined> => {
|
|
257
257
|
const a = await this.get(address_or_name);
|
|
258
|
-
|
|
258
|
+
|
|
259
259
|
if (a) {
|
|
260
260
|
const b = BigInt(balance_required);
|
|
261
261
|
|
package/src/local/local.ts
CHANGED
|
@@ -80,7 +80,11 @@ export class LocalMark {
|
|
|
80
80
|
return name
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
async get(name
|
|
83
|
+
async get(name?: string) : Promise<MarkData | undefined> {
|
|
84
|
+
if (name === undefined || name === null) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
84
88
|
const r = await this.storage.get(name);
|
|
85
89
|
if (r) {
|
|
86
90
|
return JSON.parse(r);
|
|
@@ -117,7 +121,7 @@ export class LocalMark {
|
|
|
117
121
|
}
|
|
118
122
|
|
|
119
123
|
async get_many_address2(name_or_addresses: (string | null | undefined)[]) : Promise<string[]> {
|
|
120
|
-
return (await this.get_many_address(name_or_addresses)).filter(v => v!==undefined && v!== null) as string[]
|
|
124
|
+
return (await this.get_many_address(name_or_addresses)).filter((v):v is string => v!==undefined && v!== null) as string[]
|
|
121
125
|
}
|
|
122
126
|
|
|
123
127
|
async del(name:string) {
|
package/src/query/objects.ts
CHANGED
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
import { Protocol, Machine_Node, Machine, Treasury_WithdrawMode, Treasury_Operation,
|
|
7
7
|
Repository_Type, Repository_Policy_Mode, Repository_Policy, Service_Discount_Type, Service_Sale,
|
|
8
|
-
Progress, History, ERROR, Errors, IsValidAddress, Bcs, Entity_Info, Tags, uint2address
|
|
8
|
+
Progress, History, ERROR, Errors, IsValidAddress, Bcs, Entity_Info, Tags, uint2address,
|
|
9
|
+
TreasuryReceivedObject} from 'wowok';
|
|
9
10
|
import { CacheExpireType, CacheName, CachedData, Cache } from '../local/cache.js'
|
|
10
11
|
import { LocalMark } from '../local/local.js';
|
|
11
12
|
|
|
12
13
|
export type ObjectBaseType = 'Demand' | 'Progress' | 'Service' | 'Machine' | 'Order' | 'Treasury' | 'Arbitration' | 'Arb' | 'Payment' | 'Guard' | 'Discount' |
|
|
13
14
|
'Personal' | 'Permission' | 'PersonalMark' | 'Repository' | 'TableItem_ProgressHistory' | 'TableItem_PermissionEntity' |
|
|
14
15
|
'TableItem_DemandPresenter' | 'TableItem_MachineNode' | 'TableItem_ServiceSale' | 'TableItem_TreasuryHistory' | 'TableItem_ArbVote' |
|
|
15
|
-
'TableItem_RepositoryData' | 'TableItem_PersonalMark';
|
|
16
|
+
'TableItem_RepositoryData' | 'TableItem_PersonalMark' | 'Treasury_ReceivedObject';
|
|
16
17
|
|
|
17
18
|
export interface ObjectBase {
|
|
18
19
|
object: string;
|
|
@@ -23,6 +24,11 @@ export interface ObjectBase {
|
|
|
23
24
|
cache_expire?: CacheExpireType;
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
export interface Treasury_ReceivedObject extends ObjectBase {
|
|
28
|
+
balance: string;
|
|
29
|
+
payment: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
export interface ObjectPermission extends ObjectBase {
|
|
27
33
|
builder: string;
|
|
28
34
|
admin: string[];
|
|
@@ -107,7 +113,7 @@ export interface ObjectService extends ObjectBase {
|
|
|
107
113
|
endpoint?: string | null;
|
|
108
114
|
extern_withdraw_treasury: string[];
|
|
109
115
|
machine?: string | null;
|
|
110
|
-
|
|
116
|
+
payee_treasury: string;
|
|
111
117
|
repository: string[];
|
|
112
118
|
sales_count: number;
|
|
113
119
|
withdraw_guard: {guard:string, percent:number}[];
|
|
@@ -509,7 +515,10 @@ export function raw2type(type_raw:string | undefined) : ObjectBaseType | undefin
|
|
|
509
515
|
return t
|
|
510
516
|
} else if (t === 'Resource') {
|
|
511
517
|
return 'PersonalMark';
|
|
518
|
+
} else if (t === 'CoinWrapper') {
|
|
519
|
+
return 'Treasury_ReceivedObject';
|
|
512
520
|
}
|
|
521
|
+
|
|
513
522
|
const start = type_raw?.indexOf('0x2::dynamic_field::Field<');
|
|
514
523
|
if (start === 0) {
|
|
515
524
|
const end = type_raw?.substring('0x2::dynamic_field::Field<'.length);
|
|
@@ -612,7 +621,7 @@ export function data2object(data?:any) : ObjectBase {
|
|
|
612
621
|
object:id, type:type, type_raw:type_raw, owner:owner, version:version,
|
|
613
622
|
machine:content?.machine, permission:content?.permission, description:content?.description,
|
|
614
623
|
arbitration:content?.arbitrations, bPaused:content?.bPaused, bPublished:content?.bPublished,
|
|
615
|
-
buy_guard:content?.buy_guard, endpoint:content?.endpoint,
|
|
624
|
+
buy_guard:content?.buy_guard, endpoint:content?.endpoint, payee_treasury:content?.payee, repository:content?.repositories,
|
|
616
625
|
withdraw_guard:content?.withdraw_guard?.fields?.contents?.map((v:any) => {
|
|
617
626
|
return {object:v?.fields?.key, percent:v?.fields?.value}
|
|
618
627
|
}),
|
|
@@ -750,6 +759,10 @@ export function data2object(data?:any) : ObjectBase {
|
|
|
750
759
|
return {object:id, type:type, type_raw:type_raw, owner:owner, version:version,
|
|
751
760
|
address:content?.name, name:content?.value?.fields?.nick, tags:content?.value?.fields?.tags
|
|
752
761
|
} as TableItem_PersonalMark;
|
|
762
|
+
case 'Treasury_ReceivedObject':
|
|
763
|
+
return { object:id, type:type, type_raw:type_raw, owner:owner, version:version,
|
|
764
|
+
balance: content.coin?.fields?.balance, payment:content?.payment
|
|
765
|
+
} as Treasury_ReceivedObject;
|
|
753
766
|
}
|
|
754
767
|
}
|
|
755
768
|
|