wowok 1.5.51 → 1.5.54
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/README.md +7 -3
- package/package.json +1 -1
- package/src/demand.ts +46 -25
- package/src/exception.ts +1 -0
- package/src/guard.ts +29 -0
- package/src/protocol.ts +8 -8
- package/src/repository.ts +5 -0
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
#
|
|
2
|
+
# WoWok
|
|
3
3
|
|
|
4
4
|
Create, collaborate, and transact on your own terms with the AI-driven web3 collaboration protocol.
|
|
5
5
|
|
|
@@ -12,8 +12,9 @@ X: [https://x.com/Wowok_Ai](https://x.com/Wowok_Ai)
|
|
|
12
12
|
### Installation
|
|
13
13
|
|
|
14
14
|
```
|
|
15
|
-
$ npm i wowok
|
|
15
|
+
$ npm i wowok@latest
|
|
16
16
|
```
|
|
17
|
+
The protocol address may change due to protocol upgrade. Please update the SDK to the latest version.
|
|
17
18
|
|
|
18
19
|
### Examples
|
|
19
20
|
#### [An airdrop collection system for different behaviors, allowing three collection mechanisms:](https://github.com/wowok-ai/sdk-examples/tree/main/airdrop)
|
|
@@ -26,5 +27,8 @@ $ npm i wowok
|
|
|
26
27
|
* Encrypted personal information transfer and order management
|
|
27
28
|
* Support compensation and dispute voting arbitration
|
|
28
29
|
|
|
29
|
-
#### [
|
|
30
|
+
#### [How can social resources collaborate to meet a Kenya 10-day personalized travel dream](https://github.com/wowok-ai/sdk-examples/tree/main/kenya)
|
|
31
|
+
* Demand + Service + Machine/Progress + Order + Permission + Treasury + Arbitration
|
|
32
|
+
|
|
33
|
+
#### [See more examples...](https://github.com/wowok-ai/sdk-examples)
|
|
30
34
|
|
package/package.json
CHANGED
package/src/demand.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type TransactionResult, Transaction as TransactionBlock } from '@mysten/sui/transactions';
|
|
2
|
-
import { FnCallType, Protocol, PassportObject, PermissionObject, GuardObject, DemandAddress, TxbObject } from './protocol';
|
|
3
|
-
import { IsValidDesription, IsValidAddress, IsValidArgType, IsValidU64, parseObjectType } from './utils'
|
|
2
|
+
import { FnCallType, Protocol, PassportObject, PermissionObject, GuardObject, DemandAddress, TxbObject, ServiceObject } from './protocol';
|
|
3
|
+
import { IsValidDesription, IsValidAddress, IsValidArgType, IsValidU64, parseObjectType, IsValidU8 } from './utils'
|
|
4
4
|
import { Errors, ERROR} from './exception'
|
|
5
5
|
|
|
6
6
|
export class Demand {
|
|
@@ -107,16 +107,20 @@ export class Demand {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
set_guard(guard?:GuardObject, passport?:PassportObject) {
|
|
110
|
+
set_guard(guard?:GuardObject, service_identifier?:number, passport?:PassportObject) {
|
|
111
111
|
if (guard && !Protocol.IsValidObjects([guard])) {
|
|
112
112
|
ERROR(Errors.IsValidObjects, 'guard');
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
if (service_identifier !== undefined && !IsValidU8(service_identifier)) {
|
|
115
|
+
ERROR(Errors.InvalidParam, 'set_guard.service_identifier');
|
|
116
|
+
}
|
|
117
|
+
let id = this.txb.pure.option('u8', service_identifier !== undefined ? service_identifier : undefined);
|
|
118
|
+
|
|
115
119
|
if (passport) {
|
|
116
120
|
if (guard) {
|
|
117
121
|
this.txb.moveCall({
|
|
118
122
|
target:Protocol.Instance().DemandFn('guard_set_with_passport') as FnCallType,
|
|
119
|
-
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard),
|
|
123
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard), id,
|
|
120
124
|
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
121
125
|
typeArguments:[this.bounty_type],
|
|
122
126
|
})
|
|
@@ -131,7 +135,7 @@ export class Demand {
|
|
|
131
135
|
if (guard) {
|
|
132
136
|
this.txb.moveCall({
|
|
133
137
|
target:Protocol.Instance().DemandFn('guard_set') as FnCallType,
|
|
134
|
-
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard),
|
|
138
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, guard), id,
|
|
135
139
|
Protocol.TXB_OBJECT(this.txb, this.permission)],
|
|
136
140
|
typeArguments:[this.bounty_type],
|
|
137
141
|
})
|
|
@@ -202,31 +206,48 @@ export class Demand {
|
|
|
202
206
|
})
|
|
203
207
|
}
|
|
204
208
|
|
|
205
|
-
present(
|
|
209
|
+
present(service: ServiceObject | number, service_pay_type:string, tips:string, passport?:PassportObject) {
|
|
206
210
|
if (!IsValidDesription(tips)) {
|
|
207
|
-
ERROR(Errors.IsValidDesription, 'tips')
|
|
208
|
-
}
|
|
209
|
-
if (!IsValidAddress(service_address)) {
|
|
210
|
-
ERROR(Errors.IsValidAddress, 'service_address')
|
|
211
|
+
ERROR(Errors.IsValidDesription, 'present.tips')
|
|
211
212
|
}
|
|
212
|
-
if (!IsValidArgType(service_pay_type)) {
|
|
213
|
+
if (service_pay_type && !IsValidArgType(service_pay_type)) {
|
|
213
214
|
ERROR(Errors.IsValidArgType, 'service_pay_type')
|
|
214
215
|
}
|
|
215
|
-
|
|
216
|
+
if (typeof(service) === 'number') {
|
|
217
|
+
if (!IsValidU8(service) || !passport) {
|
|
218
|
+
ERROR(Errors.IsValidU8, 'present.service or present.passport')
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
if (!Protocol.IsValidObjects([service])) {
|
|
222
|
+
ERROR(Errors.IsValidObjects, 'present.service')
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
216
226
|
if (passport) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
this.txb.pure.string(tips)],
|
|
221
|
-
|
|
222
|
-
|
|
227
|
+
if (typeof(service) === 'number') {
|
|
228
|
+
this.txb.moveCall({
|
|
229
|
+
target:Protocol.Instance().DemandFn('present_with_passport2') as FnCallType,
|
|
230
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.string(tips)],
|
|
231
|
+
typeArguments:[this.bounty_type],
|
|
232
|
+
})
|
|
233
|
+
} else {
|
|
234
|
+
this.txb.moveCall({
|
|
235
|
+
target:Protocol.Instance().DemandFn('present_with_passport') as FnCallType,
|
|
236
|
+
arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, service),
|
|
237
|
+
this.txb.pure.string(tips)],
|
|
238
|
+
typeArguments:[this.bounty_type, service_pay_type],
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
|
|
223
242
|
} else {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
this.txb.
|
|
228
|
-
|
|
229
|
-
|
|
243
|
+
if (typeof(service) !== 'number') {
|
|
244
|
+
this.txb.moveCall({
|
|
245
|
+
target:Protocol.Instance().DemandFn('present') as FnCallType,
|
|
246
|
+
arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, service),
|
|
247
|
+
this.txb.pure.string(tips)],
|
|
248
|
+
typeArguments:[this.bounty_type, service_pay_type],
|
|
249
|
+
})
|
|
250
|
+
}
|
|
230
251
|
}
|
|
231
252
|
}
|
|
232
253
|
change_permission(new_permission:PermissionObject) {
|
package/src/exception.ts
CHANGED
package/src/guard.ts
CHANGED
|
@@ -21,6 +21,14 @@ export interface Guard_Options {
|
|
|
21
21
|
group?: string;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export interface GuardAnswer {
|
|
25
|
+
txb: TransactionBlock;
|
|
26
|
+
err?: string;
|
|
27
|
+
identifiers: number[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type OnQueryAnswer = (answer: GuardAnswer) => void;
|
|
31
|
+
|
|
24
32
|
export class Guard {
|
|
25
33
|
static MAX_INPUT_LENGTH = 10240;
|
|
26
34
|
// static MAX_PAYLOADS_LENGTH = 4096;
|
|
@@ -104,6 +112,27 @@ export class Guard {
|
|
|
104
112
|
arguments: []
|
|
105
113
|
});
|
|
106
114
|
}
|
|
115
|
+
|
|
116
|
+
static QueryAddressIdentifiers(guard:GuardObject, onQueryAnswer:OnQueryAnswer, sender:string) {
|
|
117
|
+
const txb = new TransactionBlock();
|
|
118
|
+
txb.moveCall({
|
|
119
|
+
target: Protocol.Instance().GuardFn('query_address_identifiers') as FnCallType,
|
|
120
|
+
arguments: [txb.object(guard)]
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
Protocol.Client().devInspectTransactionBlock({sender:sender, transactionBlock:txb}).then((res) => {
|
|
124
|
+
if (res.results && res.results[0]?.returnValues && res.results[0]?.returnValues?.length !== 1 ) {
|
|
125
|
+
onQueryAnswer({err:'not match', txb:txb, identifiers:[]});
|
|
126
|
+
return
|
|
127
|
+
}
|
|
128
|
+
const identifiers = Bcs.getInstance().de('vector<u8>', Uint8Array.from((res.results as any)[0].returnValues[0][0]));
|
|
129
|
+
onQueryAnswer({identifiers:identifiers, txb:txb});
|
|
130
|
+
}).catch((e) => {
|
|
131
|
+
console.log(e);
|
|
132
|
+
onQueryAnswer({err:e, txb:txb, identifiers:[]});
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
107
136
|
static QUERIES:any[] = [
|
|
108
137
|
// module, 'name', 'id', [input], output
|
|
109
138
|
[MODULES.permission, 'Owner', 1, [], ValueType.TYPE_ADDRESS, "Owner's address."],
|
package/src/protocol.ts
CHANGED
|
@@ -221,14 +221,14 @@ const TESTNET = {
|
|
|
221
221
|
}
|
|
222
222
|
*/
|
|
223
223
|
const TESTNET = {
|
|
224
|
-
wowok: "
|
|
225
|
-
wowok_origin:'
|
|
226
|
-
base: '
|
|
227
|
-
base_origin: '
|
|
228
|
-
|
|
229
|
-
wowok_object: '
|
|
230
|
-
entity_object: '
|
|
231
|
-
treasury_cap:'
|
|
224
|
+
wowok: "0x55d89b02397f9086c1025380d5b92d3bb0daa906341a6173c5943045b83c10fa",
|
|
225
|
+
wowok_origin:'0x55d89b02397f9086c1025380d5b92d3bb0daa906341a6173c5943045b83c10fa' ,
|
|
226
|
+
base: '0xf02b247c28b38a1484fbac51b165fea3e70da6c5ca41256ed3c7e1b746fc7173',
|
|
227
|
+
base_origin: '0xf02b247c28b38a1484fbac51b165fea3e70da6c5ca41256ed3c7e1b746fc7173',
|
|
228
|
+
|
|
229
|
+
wowok_object: '0xa6057ffe4d7ec2c0fc0be6361460f9e705e29e94ee856e5b09d1b19b44108022',
|
|
230
|
+
entity_object: '0x155bfce91711af83a9e7b313f057ed6759dc06cfe52ec5993b2b85eab79623ea',
|
|
231
|
+
treasury_cap:'0xf3eb0e39d7435112c127d5f2130f8bf40ed4250756902b6c21df5140205bdf82',
|
|
232
232
|
}
|
|
233
233
|
const MAINNET = {
|
|
234
234
|
wowok: "",
|
package/src/repository.ts
CHANGED
|
@@ -380,6 +380,11 @@ export class Repository {
|
|
|
380
380
|
static MAX_KEY_LENGTH = 128;
|
|
381
381
|
static MAX_VALUE_LENGTH = 204800;
|
|
382
382
|
static MAX_REFERENCE_COUNT = 100;
|
|
383
|
+
|
|
384
|
+
static TYPE_NORMAL = 0;
|
|
385
|
+
static TYPE_WOWOK_GRANTEE = 1;
|
|
386
|
+
static TYPE_WOWOK_ORACLE = 2;
|
|
387
|
+
|
|
383
388
|
static IsValidName = (key:string) => {
|
|
384
389
|
return key.length <= Repository.MAX_KEY_LENGTH && key.length != 0;
|
|
385
390
|
}
|