wowok 1.5.51 → 1.5.52

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 CHANGED
@@ -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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wowok",
3
- "version": "1.5.51",
3
+ "version": "1.5.52",
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",
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(service_address: string, service_pay_type:string, tips:string, passport?:PassportObject) {
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
- this.txb.moveCall({
218
- target:Protocol.Instance().DemandFn('present_with_passport') as FnCallType,
219
- arguments:[passport, Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, service_address),
220
- this.txb.pure.string(tips)],
221
- typeArguments:[this.bounty_type, service_pay_type],
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
- this.txb.moveCall({
225
- target:Protocol.Instance().DemandFn('present') as FnCallType,
226
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), Protocol.TXB_OBJECT(this.txb, service_address),
227
- this.txb.pure.string(tips)],
228
- typeArguments:[this.bounty_type, service_pay_type],
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
@@ -10,6 +10,7 @@ export enum Errors {
10
10
  IsValidUint = 'invalid uint',
11
11
  IsValidInt = 'invalid int',
12
12
  IsValidU64 = 'invalid u64',
13
+ IsValidU8 = 'invalid u8',
13
14
  IsValidPercent = 'invalid percent',
14
15
  IsValidArray = 'invalid array',
15
16
  IsValidObjects = 'invalid objects',
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: "0x03ff6124da870ac002831580572339292d12eed6d41bc1e15c20a63b725e4d13",
225
- wowok_origin:'0x03ff6124da870ac002831580572339292d12eed6d41bc1e15c20a63b725e4d13' ,
226
- base: '0x697414cbf771c0cb0ab4e2ec335fc310a19936b628cfdb0d8d4190042ee998f9',
227
- base_origin: '0x697414cbf771c0cb0ab4e2ec335fc310a19936b628cfdb0d8d4190042ee998f9',
228
-
229
- wowok_object: '0x05929fea08ee82f0711ae25590dcd58182af81ff34cc275eb1caca4f7c7041f5',
230
- entity_object: '0x42e6da560324e891e8d695464da3ccc9f1fc0d33bc3b962cb7338d8f9198a595',
231
- treasury_cap:'0x66a76f713edd26d4db2aa64343edc10e3df6cacbd66f2e5c5e5b6fbddac6e575',
224
+ wowok: "0x4cd9cecc9720f778678a8d7c4005834a99aff27bb573b15738fbbc6419e380ac",
225
+ wowok_origin:'0x4cd9cecc9720f778678a8d7c4005834a99aff27bb573b15738fbbc6419e380ac' ,
226
+ base: '0x985dd058e7f7d6c216b8a55d0170c47c1a6db048a8045c56c6cca4ba9333684d',
227
+ base_origin: '0x985dd058e7f7d6c216b8a55d0170c47c1a6db048a8045c56c6cca4ba9333684d',
228
+
229
+ wowok_object: '0x60aab3dc3e911a5f952a97fd411531b4e1e61676cdf0f8fe10685ce15310dd31',
230
+ entity_object: '0xec60850cde84c92bad3a161f7c5db4f7b86440e1fdc819be94523a29fff67497',
231
+ treasury_cap:'0x4bf3375d58afc7b9de3335e777223b3fad16f154305c313d65ec75c2183e2df9',
232
232
  }
233
233
  const MAINNET = {
234
234
  wowok: "",