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/treasury.ts
CHANGED
|
@@ -1,63 +1,69 @@
|
|
|
1
|
-
import { TransactionBlock, IsValidArgType, PassportObject,
|
|
1
|
+
import { TransactionBlock, IsValidArgType, PassportObject, Errors, ERROR, Permission, PermissionIndex,
|
|
2
2
|
PermissionIndexType, Treasury, Treasury_WithdrawMode, WithdrawParam,
|
|
3
3
|
} from 'wowok';
|
|
4
|
-
import { query_objects, ObjectTreasury } from '../query/objects.js';
|
|
5
|
-
import { CallBase, CallResult,
|
|
4
|
+
import { query_objects, ObjectTreasury, Treasury_ReceivedObject } from '../query/objects.js';
|
|
5
|
+
import { AccountOrMark_Address, CallBase, CallResult, GetAccountOrMark_Address, GetObjectExisted,
|
|
6
|
+
GetObjectMain, GetObjectParam, ObjectTypedMain, TypeNamedObjectWithPermission } from "./base.js";
|
|
6
7
|
import { Account } from '../local/account.js';
|
|
7
8
|
import { LocalMark } from '../local/local.js';
|
|
8
9
|
import { get_object_address } from '../common.js';
|
|
9
10
|
|
|
11
|
+
export interface ReceiverParam {
|
|
12
|
+
address: AccountOrMark_Address;
|
|
13
|
+
amount: string|number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TreasuryWithdrawParam extends WithdrawParam {
|
|
17
|
+
receiver: ReceiverParam[];
|
|
18
|
+
withdraw_guard?: string,
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
/// The execution priority is determined by the order in which the object attributes are arranged
|
|
11
22
|
export interface CallTreasury_Data {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
object: ObjectTypedMain;
|
|
24
|
+
deposit?: {balance:string|number; index?:number|string; remark?:string; for_object?:string; for_guard?:string};
|
|
25
|
+
receive?: {received_objects:string[]} | 'recently';
|
|
26
|
+
withdraw?: TreasuryWithdrawParam;
|
|
27
|
+
|
|
15
28
|
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
29
|
deposit_guard?: string;
|
|
20
30
|
withdraw_guard?: {op:'add' | 'set'; data:{guard:string, amount:string|number}[]} | {op:'remove', guards:string[]} | {op:'removeall'};
|
|
21
31
|
withdraw_mode?: Treasury_WithdrawMode;
|
|
22
32
|
}
|
|
23
33
|
export class CallTreasury extends CallBase {
|
|
24
34
|
data: CallTreasury_Data;
|
|
35
|
+
object_address: string | undefined = undefined;
|
|
36
|
+
permission_address: string | undefined = undefined;
|
|
37
|
+
type_parameter: string | undefined = undefined;
|
|
38
|
+
|
|
25
39
|
constructor(data:CallTreasury_Data) {
|
|
26
40
|
super();
|
|
27
41
|
this.data = data;
|
|
28
42
|
}
|
|
29
43
|
|
|
30
44
|
async call(account?:string) : Promise<CallResult> {
|
|
31
|
-
if (!this.data.type_parameter || !IsValidArgType(this.data.type_parameter)) {
|
|
32
|
-
ERROR(Errors.IsValidArgType, 'treasury.type_parameter');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
45
|
var checkOwner = false; const guards : string[] = [];
|
|
36
|
-
const perms : PermissionIndexType[] = [];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (!this.data.type_parameter || !permission_address) {
|
|
44
|
-
await this.update_content(object_address, 'Treasury');
|
|
45
|
-
if (this.content) {
|
|
46
|
-
permission_address = (this.content as ObjectTreasury).permission;
|
|
47
|
-
this.data.type_parameter = this.content.type_raw!;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
46
|
+
const perms : PermissionIndexType[] = [];
|
|
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);
|
|
50
53
|
} else {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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;
|
|
60
|
+
}
|
|
55
61
|
|
|
56
|
-
if (permission_address) {
|
|
62
|
+
if (this.permission_address) {
|
|
57
63
|
if (!this.data?.object) {
|
|
58
64
|
perms.push(PermissionIndex.treasury)
|
|
59
65
|
}
|
|
60
|
-
if (this.data?.description !== undefined && object_address) {
|
|
66
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
61
67
|
perms.push(PermissionIndex.treasury_descritption)
|
|
62
68
|
}
|
|
63
69
|
if (this.data?.withdraw_mode !== undefined) {
|
|
@@ -73,23 +79,9 @@ export class CallTreasury extends CallBase {
|
|
|
73
79
|
perms.push(PermissionIndex.treasury_deposit_guard)
|
|
74
80
|
}
|
|
75
81
|
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
|
-
}
|
|
82
|
+
if (this.object_address) {
|
|
83
|
+
if ((this.content as ObjectTreasury)?.deposit_guard) {
|
|
84
|
+
guards.push((this.content as ObjectTreasury).deposit_guard!)
|
|
93
85
|
}
|
|
94
86
|
}
|
|
95
87
|
}
|
|
@@ -104,59 +96,76 @@ export class CallTreasury extends CallBase {
|
|
|
104
96
|
} else { // withdraw with permission
|
|
105
97
|
perms.push(PermissionIndex.treasury_withdraw)
|
|
106
98
|
}
|
|
107
|
-
return await this.check_permission_and_call(permission_address, perms, guards, checkOwner, undefined, account)
|
|
99
|
+
return await this.check_permission_and_call(this.permission_address, perms, guards, checkOwner, undefined, account)
|
|
108
100
|
}
|
|
109
101
|
return await this.exec(account);
|
|
110
102
|
}
|
|
111
103
|
protected async operate (txb:TransactionBlock, passport?:PassportObject, account?:string) {
|
|
112
104
|
let obj : Treasury | undefined ; let permission: any;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
await LocalMark.Instance().get_many_address(
|
|
116
|
-
[(this.data?.permission as any)?.address,
|
|
117
|
-
(this.data?.object as any)?.address]);
|
|
118
|
-
|
|
119
|
-
if (!object_address) {
|
|
120
|
-
if (!permission_address) {
|
|
121
|
-
const d = (this.data?.permission as any)?.description ?? '';
|
|
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)
|
|
105
|
+
if (this.object_address) {
|
|
106
|
+
obj = Treasury.From(txb, this.type_parameter!, this.permission_address!, this.object_address)
|
|
125
107
|
} else {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
ERROR(Errors.InvalidParam, 'CallTreasury_Data.data.type_parameter or permission')
|
|
108
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
109
|
+
if (!this.permission_address) {
|
|
110
|
+
permission = Permission.New(txb, GetObjectParam(n?.permission)?.description ?? '');
|
|
130
111
|
}
|
|
112
|
+
obj = Treasury.New(txb, this.type_parameter!, permission ? permission.get_object(): this.permission_address,
|
|
113
|
+
this.data?.description??'', permission?undefined:passport)
|
|
131
114
|
}
|
|
132
115
|
|
|
116
|
+
|
|
133
117
|
if (obj) {
|
|
134
118
|
const pst = permission?undefined:passport;
|
|
135
|
-
if (this.data?.description !== undefined && object_address) {
|
|
136
|
-
obj?.set_description(this.data.description, pst);
|
|
137
|
-
}
|
|
138
119
|
if (this.data.deposit !== undefined) {
|
|
139
|
-
const coin = await Account.Instance().get_coin_object(txb, this.data.deposit.
|
|
120
|
+
const coin = await Account.Instance().get_coin_object(txb, this.data.deposit.balance, account, this.type_parameter);
|
|
140
121
|
if (coin) {
|
|
141
|
-
const index = this.data.deposit
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
for_object:await get_object_address(this.data.deposit.data?.for_object)
|
|
145
|
-
})
|
|
122
|
+
const index = this.data.deposit?.index ?? 0;
|
|
123
|
+
const [for_guard, for_object] = await LocalMark.Instance().get_many_address([this.data.deposit?.for_guard, this.data.deposit?.for_object])
|
|
124
|
+
obj?.deposit({coin:coin, index:BigInt(index), remark:this.data.deposit.remark ??'', for_guard, for_object});
|
|
146
125
|
}
|
|
147
126
|
}
|
|
148
|
-
if (this.data?.receive !== undefined) {
|
|
149
|
-
|
|
150
|
-
|
|
127
|
+
if (this.data?.receive !== undefined && this.object_address) {
|
|
128
|
+
if (this.data.receive === 'recently') {
|
|
129
|
+
const r = await Treasury.GetTreasuryRecievedObject(this.object_address, this.type_parameter!);
|
|
130
|
+
if (!r) {
|
|
131
|
+
ERROR(Errors.InvalidParam, 'CallTreasury_Data.data.receive.received_objects');
|
|
132
|
+
}
|
|
133
|
+
r.received.forEach(v => {
|
|
134
|
+
obj?.receive(v.payment, v.id, pst);
|
|
135
|
+
})
|
|
136
|
+
} else if (this.data.receive?.received_objects?.length > 0) {
|
|
137
|
+
const r = await query_objects({objects:this.data.receive.received_objects});
|
|
138
|
+
if (r?.objects?.length!== this.data.receive.received_objects.length) {
|
|
139
|
+
ERROR(Errors.InvalidParam, 'CallTreasury_Data.data.receive.received_objects');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
for (let i=0; i<r?.objects?.length; ++i) {
|
|
143
|
+
if (r.objects[i].type !== 'Treasury_ReceivedObject') {
|
|
144
|
+
ERROR(Errors.InvalidParam, 'CallTreasury_Data.data.receive.received_objects:'+ r.objects[i].object);
|
|
145
|
+
}
|
|
146
|
+
const v = r.objects[i] as Treasury_ReceivedObject;
|
|
147
|
+
obj?.receive(v.payment, v.object, pst);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
151
150
|
}
|
|
152
151
|
|
|
153
152
|
if (this.data?.withdraw !== undefined) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
153
|
+
const [for_guard, for_object] = await LocalMark.Instance().get_many_address([this.data.withdraw?.for_guard, this.data.withdraw?.for_object]);
|
|
154
|
+
const receiver = [];
|
|
155
|
+
for (let i=0;i < this.data.withdraw.receiver.length; ++i) {
|
|
156
|
+
const v = this.data.withdraw.receiver[i];
|
|
157
|
+
const address = await GetAccountOrMark_Address(v.address);
|
|
158
|
+
if (!address) ERROR(Errors.InvalidParam, 'CallTreasury_Data.data.withdraw.receiver:'+ v.address);
|
|
159
|
+
|
|
160
|
+
receiver.push({address:address, amount:BigInt(v.amount)})
|
|
161
|
+
}
|
|
162
|
+
obj?.withdraw({items:receiver, index:this.data.withdraw.index ?? 0, remark:this.data.withdraw.remark??'',
|
|
163
|
+
for_guard, for_object, withdraw_guard: await LocalMark.Instance().get_address(this.data.withdraw.withdraw_guard)}, pst);
|
|
158
164
|
}
|
|
159
165
|
|
|
166
|
+
if (this.data?.description !== undefined && this.object_address) {
|
|
167
|
+
obj?.set_description(this.data.description, pst);
|
|
168
|
+
}
|
|
160
169
|
if (this.data?.deposit_guard !== undefined) {
|
|
161
170
|
const guard = await LocalMark.Instance().get_address(this.data?.deposit_guard);
|
|
162
171
|
obj?.set_deposit_guard(guard, pst);
|
|
@@ -185,10 +194,11 @@ export class CallTreasury extends CallBase {
|
|
|
185
194
|
obj?.set_withdraw_mode(this.data.withdraw_mode, pst)
|
|
186
195
|
}
|
|
187
196
|
if (permission) {
|
|
188
|
-
|
|
197
|
+
const n = GetObjectMain(this.data.object) as TypeNamedObjectWithPermission;
|
|
198
|
+
await this.new_with_mark('Permission', txb, permission.launch(), GetObjectParam(n?.permission), account);
|
|
189
199
|
}
|
|
190
|
-
if (!object_address) {
|
|
191
|
-
await this.new_with_mark('Treasury', txb, obj.launch(), (this.data?.object
|
|
200
|
+
if (!this.object_address) {
|
|
201
|
+
await this.new_with_mark('Treasury', txb, obj.launch(), GetObjectMain(this.data?.object), account);
|
|
192
202
|
}
|
|
193
203
|
}
|
|
194
204
|
}
|
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/events.ts
CHANGED
|
@@ -54,7 +54,7 @@ export interface EventCursor {
|
|
|
54
54
|
txDigest: string
|
|
55
55
|
}
|
|
56
56
|
export interface EventQuery {
|
|
57
|
-
type: 'OnNewArb' | 'OnPresentService' | 'OnNewProgress' | 'OnNewOrder';
|
|
57
|
+
type: 'OnNewArb' | 'OnPresentService' | 'OnNewProgress' | 'OnNewOrder' | string;
|
|
58
58
|
/** optional paging cursor */
|
|
59
59
|
cursor?: EventCursor | null | undefined;
|
|
60
60
|
/** maximum number of items per page, default to [QUERY_MAX_RESULT_LIMIT] if not specified. */
|
|
@@ -73,15 +73,17 @@ export const query_events_json = async (json:string) : Promise<string> => {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export const query_events = (query: EventQuery) : Promise<EventAnswer | undefined> => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
const type = query.type.toLowerCase();
|
|
77
|
+
if (type.includes('arb') || type.includes('arbitration')) {
|
|
78
|
+
return newArbEvents(query.cursor, query.limit, query.order)
|
|
79
|
+
} else if (type.includes('present') || type.includes('demand')) {
|
|
80
|
+
return newProgressEvents(query.cursor, query.limit, query.order)
|
|
81
|
+
} else if (type.includes('progress') || type.includes('machine')) {
|
|
82
|
+
return presentServiceEvents(query.cursor, query.limit, query.order)
|
|
83
|
+
} else if (type.includes('order') || type.includes('service')) {
|
|
84
|
+
return newOrderEvents(query.cursor, query.limit, query.order)
|
|
85
|
+
} else {
|
|
86
|
+
return Promise.resolve(undefined);
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
|
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}[];
|
|
@@ -437,6 +443,7 @@ export interface QueryTableItem_AddressName {
|
|
|
437
443
|
parent: string | ObjectRepository;
|
|
438
444
|
address: string | number | bigint;
|
|
439
445
|
name: string;
|
|
446
|
+
no_cache?: boolean;
|
|
440
447
|
}
|
|
441
448
|
export interface QueryTableItem_Address {
|
|
442
449
|
parent: string | ObjectDemand | ObjectPermission | ObjectArb | ObjectMark;
|
|
@@ -508,7 +515,10 @@ export function raw2type(type_raw:string | undefined) : ObjectBaseType | undefin
|
|
|
508
515
|
return t
|
|
509
516
|
} else if (t === 'Resource') {
|
|
510
517
|
return 'PersonalMark';
|
|
518
|
+
} else if (t === 'CoinWrapper') {
|
|
519
|
+
return 'Treasury_ReceivedObject';
|
|
511
520
|
}
|
|
521
|
+
|
|
512
522
|
const start = type_raw?.indexOf('0x2::dynamic_field::Field<');
|
|
513
523
|
if (start === 0) {
|
|
514
524
|
const end = type_raw?.substring('0x2::dynamic_field::Field<'.length);
|
|
@@ -611,7 +621,7 @@ export function data2object(data?:any) : ObjectBase {
|
|
|
611
621
|
object:id, type:type, type_raw:type_raw, owner:owner, version:version,
|
|
612
622
|
machine:content?.machine, permission:content?.permission, description:content?.description,
|
|
613
623
|
arbitration:content?.arbitrations, bPaused:content?.bPaused, bPublished:content?.bPublished,
|
|
614
|
-
buy_guard:content?.buy_guard, endpoint:content?.endpoint,
|
|
624
|
+
buy_guard:content?.buy_guard, endpoint:content?.endpoint, payee_treasury:content?.payee, repository:content?.repositories,
|
|
615
625
|
withdraw_guard:content?.withdraw_guard?.fields?.contents?.map((v:any) => {
|
|
616
626
|
return {object:v?.fields?.key, percent:v?.fields?.value}
|
|
617
627
|
}),
|
|
@@ -749,6 +759,10 @@ export function data2object(data?:any) : ObjectBase {
|
|
|
749
759
|
return {object:id, type:type, type_raw:type_raw, owner:owner, version:version,
|
|
750
760
|
address:content?.name, name:content?.value?.fields?.nick, tags:content?.value?.fields?.tags
|
|
751
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;
|
|
752
766
|
}
|
|
753
767
|
}
|
|
754
768
|
|