wowok 1.3.4 → 1.3.6

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",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
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
@@ -24,7 +24,7 @@ export class Demand {
24
24
  this.txb = txb;
25
25
  this.object = '';
26
26
  }
27
- static New(txb:TransactionBlock, bounty_type:string, permission:PermissionObject, description:string,
27
+ static New(txb:TransactionBlock, bounty_type:string, ms_expand:boolean, time:number, permission:PermissionObject, description:string,
28
28
  bounty:TransactionResult | string, passport?:PassportObject) : Demand {
29
29
  if (!Protocol.IsValidObjects([permission, bounty])) {
30
30
  ERROR(Errors.IsValidObjects, 'permission, bounty');
@@ -35,18 +35,24 @@ export class Demand {
35
35
  if (!IsValidArgType(bounty_type)) {
36
36
  ERROR(Errors.IsValidArgType, bounty_type);
37
37
  }
38
-
38
+ if (!IsValidUintLarge(time)) {
39
+ ERROR(Errors.IsValidUint, 'time')
40
+ }
41
+
39
42
  let d = new Demand(txb, bounty_type, permission);
43
+ const clock = txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
40
44
  if (passport) {
41
45
  d.object = txb.moveCall({
42
46
  target:Protocol.Instance().DemandFn('new_with_passport') as FnCallType,
43
- arguments:[passport, txb.pure.string(description), txb.object(bounty), Protocol.TXB_OBJECT(txb, permission)],
47
+ arguments:[passport, txb.pure.string(description), txb.object(bounty), txb.pure.bool(ms_expand), txb.pure.u64(time),
48
+ txb.object(clock), Protocol.TXB_OBJECT(txb, permission)],
44
49
  typeArguments:[bounty_type],
45
50
  })
46
51
  } else {
47
52
  d.object = txb.moveCall({
48
53
  target:Protocol.Instance().DemandFn('new') as FnCallType,
49
- arguments:[txb.pure.string(description), txb.object(bounty), Protocol.TXB_OBJECT(txb, permission)],
54
+ arguments:[txb.pure.string(description), txb.object(bounty), txb.pure.bool(ms_expand), txb.pure.u64(time),
55
+ txb.object(clock), Protocol.TXB_OBJECT(txb, permission)],
50
56
  typeArguments:[bounty_type],
51
57
  })
52
58
  }
package/src/permission.ts CHANGED
@@ -523,6 +523,7 @@ export class Permission {
523
523
  onPermissionAnswer({who:address_queried, object:permission});
524
524
  })
525
525
  }
526
+
526
527
  static HasPermission(answer:PermissionAnswer|undefined, index:PermissionIndexType, bStrict:boolean=false) : {has:boolean, guard?:string, owner?:boolean} | undefined {
527
528
  if (answer) {
528
529
  if (answer.admin) return {has:true, owner:answer.owner}; // admin
package/src/protocol.ts CHANGED
@@ -191,9 +191,9 @@ export enum ENTRYPOINT {
191
191
  }
192
192
 
193
193
  const TESTNET = {
194
- package: "0xdfead784f096e93d025e3e29c4fa48cf5585867e7bcc304c83d3f410f210e4c9",
195
- wowok_object: '0xe386bb9e01b3528b75f3751ad8a1e418b207ad979fea364087deef5250a73d3f',
196
- entity_object: '0xbc8be56e8924f7ddcce0ebbc8bd9a2bf1f00d1db9a12e36b9290f009ba305dd9',
194
+ package: "0xa5a2e79de613b6585a584dd9aee8f464a1a1f2826fefc656f44e95ee3c60d673",
195
+ wowok_object: '0x4723d6660029b1d1a70d6ebb7bfed4b3f06c7e811d6b9845b41d7451555fee02',
196
+ entity_object: '0xb91ae0f0e38f205c7d4f90639fa0bd6fc6448889f8de38547dd6fb29304fc89b',
197
197
  }
198
198
 
199
199
  const MAINNET = {
@@ -253,7 +253,7 @@ export class Protocol {
253
253
  break;
254
254
  };
255
255
  }
256
- Package(): string { return this.package }
256
+ Package(): string { return this.package }
257
257
  WowokObject(): string { return this.wowok_object }
258
258
  EntityObject(): string { return this.entity_object }
259
259
  GraphqlUrl() : string { return this.graphql }
@@ -380,6 +380,7 @@ export class Protocol {
380
380
  ];
381
381
 
382
382
  GetCoinTypeInfo = (token_type: string, handler:(info:CoinTypeInfo)=>void) : CoinTypeInfo | 'loading' => {
383
+ if (!token_type) return 'loading';
383
384
  let r = this.COINS_TYPE().find((v) => v?.type === token_type);
384
385
  if (!r) {
385
386
  Protocol.Client().getCoinMetadata({coinType:token_type}).then((res) => {
package/src/service.ts CHANGED
@@ -4,7 +4,8 @@ import { FnCallType, GuardObject, PassportObject, PermissionObject, RepositoryOb
4
4
  ServiceObject, DiscountObject, OrderObject, OrderAddress, CoinObject, Protocol, ValueType,
5
5
  TxbObject} from './protocol';
6
6
  import { ERROR, Errors } from './exception';
7
- import { type TransactionResult, Transaction as TransactionBlock } from '@mysten/sui/transactions';
7
+ import { Transaction as TransactionBlock, } from '@mysten/sui/transactions';
8
+ import { SuiObjectData } from '@mysten/sui/client';
8
9
 
9
10
  export type Service_Guard_Percent = {
10
11
  guard:GuardObject;
@@ -57,6 +58,7 @@ export type DicountDispatch = {
57
58
  discount: Service_Discount;
58
59
  }
59
60
 
61
+ export type handleDiscountObject = (owner:string, objects:(SuiObjectData|null|undefined)[]) => void;
60
62
  export class Service {
61
63
  protected pay_token_type;
62
64
  protected permission;
@@ -760,11 +762,8 @@ export class Service {
760
762
  }
761
763
 
762
764
  set_customer_required(pubkey:string, customer_required: BuyRequiredEnum[], passport?:PassportObject) {
763
- if (!pubkey) {
765
+ if(customer_required.length > 0 && !pubkey) {
764
766
  ERROR(Errors.InvalidParam, 'pubkey')
765
- }
766
- if(!customer_required) {
767
- ERROR(Errors.InvalidParam, 'customer_required')
768
767
  }
769
768
 
770
769
  let req = array_unique(customer_required) as string[];
@@ -925,6 +924,7 @@ export class Service {
925
924
  const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
926
925
  if (passport) {
927
926
  if (discount) {
927
+ console.log(1)
928
928
  order = this.txb.moveCall({
929
929
  target:Protocol.Instance().ServiceFn('dicount_buy_with_passport') as FnCallType,
930
930
  arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', name),
@@ -932,6 +932,7 @@ export class Service {
932
932
  Protocol.TXB_OBJECT(this.txb, coin), Protocol.TXB_OBJECT(this.txb, discount), this.txb.object(clock)],
933
933
  typeArguments:[this.pay_token_type]
934
934
  })} else {
935
+ console.log(2)
935
936
  order = this.txb.moveCall({
936
937
  target:Protocol.Instance().ServiceFn('buy_with_passport') as FnCallType,
937
938
  arguments: [passport, Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', name),
@@ -940,6 +941,7 @@ export class Service {
940
941
  typeArguments:[this.pay_token_type]
941
942
  })}
942
943
  } else {
944
+ console.log(3)
943
945
  if (discount) {
944
946
  order = this.txb.moveCall({
945
947
  target:Protocol.Instance().ServiceFn('disoucnt_buy') as FnCallType,
@@ -950,6 +952,7 @@ export class Service {
950
952
  Protocol.TXB_OBJECT(this.txb, discount), this.txb.object(clock)],
951
953
  typeArguments:[this.pay_token_type]
952
954
  })} else {
955
+ console.log(4)
953
956
  order = this.txb.moveCall({
954
957
  target:Protocol.Instance().ServiceFn('buy') as FnCallType,
955
958
  arguments: [Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.vector('string', name),
@@ -1026,5 +1029,13 @@ export class Service {
1026
1029
  return service_endpoint + '/sales/' + encodeURI(item_name);
1027
1030
  }
1028
1031
  }
1029
-
1032
+ static DiscountObjects = (owner:string, handleDiscountObject:handleDiscountObject) => {
1033
+ Protocol.Client().getOwnedObjects({owner:owner,
1034
+ filter:{MoveModule:{module:'order', package:Protocol.Instance().Package()}},
1035
+ options:{showContent:true, showType:true}}).then((res) => {
1036
+ handleDiscountObject(owner, res.data.map((v)=>v.data));
1037
+ }).catch((e) => {
1038
+ console.log(e);
1039
+ })
1040
+ }
1030
1041
  }
package/src/utils.ts CHANGED
@@ -388,7 +388,9 @@ export const MAX_ENDPOINT_LENGTH = 1024;
388
388
  export const IsValidDesription = (description:string) : boolean => { return description?.length <= MAX_DESCRIPTION_LENGTH }
389
389
  export const IsValidName = (name:string) : boolean => { if(!name) return false; return name.length <= MAX_NAME_LENGTH && name.length != 0 }
390
390
  export const IsValidName_AllowEmpty = (name:string) : boolean => { return name.length <= MAX_NAME_LENGTH }
391
- export const IsValidEndpoint = (endpoint:string) : boolean => { if (!endpoint) return false; return endpoint.length <= MAX_ENDPOINT_LENGTH }
391
+ export const IsValidEndpoint = (endpoint:string) : boolean => {
392
+ return (endpoint.length > 0 && endpoint.length <= MAX_ENDPOINT_LENGTH && isValidHttpUrl(endpoint)) ;
393
+ }
392
394
  export const IsValidAddress = (addr:string | undefined) : boolean => {
393
395
  if (!addr || !isValidSuiAddress(addr)) {
394
396
  return false;