wowok 1.1.5 → 1.2.1

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.
Files changed (67) hide show
  1. package/README.md +6 -2
  2. package/dist/demand.d.ts +0 -2
  3. package/dist/demand.d.ts.map +1 -1
  4. package/dist/demand.js +0 -8
  5. package/dist/entity.d.ts +23 -0
  6. package/dist/entity.d.ts.map +1 -0
  7. package/dist/entity.js +71 -0
  8. package/dist/exception.d.ts +2 -1
  9. package/dist/exception.d.ts.map +1 -1
  10. package/dist/exception.js +1 -0
  11. package/dist/guard.d.ts +12 -12
  12. package/dist/guard.d.ts.map +1 -1
  13. package/dist/guard.js +65 -52
  14. package/dist/index.d.ts +3 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +3 -0
  17. package/dist/machine.d.ts +0 -2
  18. package/dist/machine.d.ts.map +1 -1
  19. package/dist/machine.js +0 -7
  20. package/dist/passport.d.ts +13 -9
  21. package/dist/passport.d.ts.map +1 -1
  22. package/dist/passport.js +60 -55
  23. package/dist/permission.d.ts +0 -2
  24. package/dist/permission.d.ts.map +1 -1
  25. package/dist/permission.js +0 -7
  26. package/dist/progress.d.ts +0 -2
  27. package/dist/progress.d.ts.map +1 -1
  28. package/dist/progress.js +9 -7
  29. package/dist/protocol.d.ts +15 -8
  30. package/dist/protocol.d.ts.map +1 -1
  31. package/dist/protocol.js +29 -26
  32. package/dist/repository.d.ts +0 -2
  33. package/dist/repository.d.ts.map +1 -1
  34. package/dist/repository.js +10 -9
  35. package/dist/resource.d.ts +2 -5
  36. package/dist/resource.d.ts.map +1 -1
  37. package/dist/resource.js +4 -30
  38. package/dist/reward.d.ts +0 -2
  39. package/dist/reward.d.ts.map +1 -1
  40. package/dist/reward.js +9 -7
  41. package/dist/service.d.ts +0 -2
  42. package/dist/service.d.ts.map +1 -1
  43. package/dist/service.js +10 -8
  44. package/dist/utils.d.ts +1 -0
  45. package/dist/utils.d.ts.map +1 -1
  46. package/dist/utils.js +10 -0
  47. package/dist/vote.d.ts +0 -2
  48. package/dist/vote.d.ts.map +1 -1
  49. package/dist/vote.js +0 -7
  50. package/dist/wowok.d.ts +12 -0
  51. package/dist/wowok.d.ts.map +1 -0
  52. package/dist/wowok.js +48 -0
  53. package/package.json +10 -3
  54. package/src/demand.ts +1 -10
  55. package/src/entity.ts +27 -1
  56. package/src/guard.ts +55 -55
  57. package/src/index.ts +11 -8
  58. package/src/machine.ts +0 -8
  59. package/src/passport.ts +69 -65
  60. package/src/permission.ts +0 -8
  61. package/src/progress.ts +2 -2
  62. package/src/protocol.ts +28 -28
  63. package/src/repository.ts +2 -2
  64. package/src/resource.ts +3 -35
  65. package/src/reward.ts +2 -2
  66. package/src/service.ts +2 -2
  67. package/src/vote.ts +0 -8
package/README.md CHANGED
@@ -1,12 +1,16 @@
1
1
 
2
2
  # Wowok
3
3
 
4
- AI-oriented web3 collaboration protocol, driving innovaion and making it more likely to happen.
4
+ Create, collaborate, and transact on your own terms with the AI-driven web3 collaboration protocol.
5
5
 
6
6
  Github: [https://github.com/wowok-ai/sdk](https://github.com/wowok-ai/sdk)
7
- Examples: [https://github.com/wowok-ai/sdk-examples](https://github.com/wowok-ai/sdk-examples)
7
+ Examples: [https://github.com/wowok-ai/sdk-examples](https://github.com/wowok-ai/sdk-examples)
8
+ Introduction: [https://wowok-ai.github.io/wowok-ai](https://wowok-ai.github.io/wowok-ai)
8
9
  Docs: [https://github.com/wowok-ai/sdk/wiki](https://github.com/wowok-ai/sdk/wiki)
9
10
 
11
+ X: [https://x.com/Wowok_Ai](https://x.com/Wowok_Ai)
12
+
13
+
10
14
  ### Installation
11
15
 
12
16
  ```
package/dist/demand.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { type TransactionResult } from '@mysten/sui.js/transactions';
2
2
  import { Protocol, PassportObject, PermissionObject, GuardObject, DemandAddress, TxbObject } from './protocol';
3
- import { Resource } from './resource';
4
3
  export declare class Demand {
5
4
  protected bounty_type: string;
6
5
  protected permission: PermissionObject;
@@ -13,7 +12,6 @@ export declare class Demand {
13
12
  static New(protocol: Protocol, bounty_type: string, permission: PermissionObject, description: string, bounty: TransactionResult, passport?: PassportObject): Demand;
14
13
  launch(): DemandAddress;
15
14
  destroy(): void;
16
- mark(like: 'like' | 'unlike', resource: Resource): void;
17
15
  refund(passport?: PassportObject): void;
18
16
  expand_time(minutes_duration: number, passport?: PassportObject): void;
19
17
  set_guard(guard?: GuardObject, passport?: PassportObject): void;
@@ -1 +1 @@
1
- {"version":3,"file":"demand.d.ts","sourceRoot":"","sources":["../src/demand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EAAc,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAiB,MAAM,YAAY,CAAC;AAG1I,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAGrC,qBAAa,MAAM;IACf,SAAS,CAAC,WAAW,SAAC;IACtB,SAAS,CAAC,UAAU,mBAAE;IACtB,SAAS,CAAC,MAAM,EAAG,SAAS,CAAE;IAC9B,SAAS,CAAC,QAAQ,WAAC;IAEnB,eAAe;IACf,UAAU;IAEV,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,EAAE,UAAU,EAAC,gBAAgB,EAAE,MAAM,EAAC,SAAS,GAAI,MAAM;IAM1G,OAAO;IAMP,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,EAAE,UAAU,EAAC,gBAAgB,EAAE,WAAW,EAAC,MAAM,EAC7F,MAAM,EAAC,iBAAiB,EAAE,QAAQ,CAAC,EAAC,cAAc,GAAI,MAAM;IA6BhE,MAAM,IAAK,aAAa;IASxB,OAAO;IASP,IAAI,CAAC,IAAI,EAAC,MAAM,GAAG,QAAQ,EAAE,QAAQ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AAC,QAAQ,EAAE,WAAW,EAAC,MAAM,EAAE,UAAU,EAAC,gBAAgB,EAAE,WAAW,EAAC,MAAM,EAC7F,MAAM,EAAC,iBAAiB,EAAE,QAAQ,CAAC,EAAC,cAAc,GAAI,MAAM;IA6BhE,MAAM,IAAK,aAAa;IASxB,OAAO;IASP,MAAM,CAAC,QAAQ,CAAC,EAAC,cAAc;IAiB/B,WAAW,CAAC,gBAAgB,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,cAAc;IAuB9D,SAAS,CAAC,KAAK,CAAC,EAAC,WAAW,EAAE,QAAQ,CAAC,EAAC,cAAc;IAuCrD,eAAe,CAAC,WAAW,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,cAAc;IAsB5D,GAAG,CAAC,eAAe,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,cAAc;IAyBpD,OAAO,CAAC,MAAM,EAAC,SAAS;IAaxB,OAAO,CAAC,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,EAAE,QAAQ,CAAC,EAAC,cAAc;IA4B/F,iBAAiB,CAAC,cAAc,EAAC,gBAAgB;IAcjD,MAAM,CAAC,gBAAgB,SAAO;IAC9B,MAAM,CAAC,oBAAoB,SAAO;CACrC"}
package/dist/demand.js CHANGED
@@ -64,14 +64,6 @@ export class Demand {
64
64
  typeArguments: [this.bounty_type]
65
65
  });
66
66
  }
67
- mark(like, resource) {
68
- let txb = this.protocol.CurrentSession();
69
- txb.moveCall({
70
- target: this.protocol.DemandFn(like),
71
- arguments: [Protocol.TXB_OBJECT(txb, resource.get_object()), Protocol.TXB_OBJECT(txb, this.object)],
72
- typeArguments: [this.bounty_type]
73
- });
74
- }
75
67
  refund(passport) {
76
68
  let txb = this.protocol.CurrentSession();
77
69
  if (passport) {
@@ -0,0 +1,23 @@
1
+ import { Protocol, TxbObject, ResourceAddress } from './protocol';
2
+ import { Resource } from './resource';
3
+ export interface Entity_Info {
4
+ name: string;
5
+ description?: string;
6
+ avatar?: string;
7
+ twitter?: string;
8
+ discord?: string;
9
+ homepage?: string;
10
+ }
11
+ export declare class Entity {
12
+ protected object: TxbObject;
13
+ protected protocol: Protocol;
14
+ get_object(): TxbObject;
15
+ private constructor();
16
+ static From(protocol: Protocol): Entity;
17
+ mark(resource: Resource, address: string, like: 'like' | 'dislike'): void;
18
+ update(info: Entity_Info): void;
19
+ create_resource(description: string): ResourceAddress;
20
+ destroy_resource(resource: Resource): import("@mysten/sui.js/transactions").TransactionResult;
21
+ transfer_resource(resource: Resource, new_address: string): import("@mysten/sui.js/transactions").TransactionResult;
22
+ }
23
+ //# sourceMappingURL=entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../src/entity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAc,SAAS,EAAE,eAAe,EAAmC,MAAM,YAAY,CAAC;AAG/G,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,MAAM;IAEf,SAAS,CAAC,MAAM,EAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,QAAQ,WAAC;IAEnB,UAAU;IACV,OAAO;IAKP,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAC,QAAQ,GAAI,MAAM;IAMvC,IAAI,CAAC,QAAQ,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,GAAG,SAAS;IAU/D,MAAM,CAAC,IAAI,EAAE,WAAW;IAexB,eAAe,CAAC,WAAW,EAAC,MAAM,GAAI,eAAe;IASrD,gBAAgB,CAAC,QAAQ,EAAC,QAAQ;IAQlC,iBAAiB,CAAC,QAAQ,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM;CAQ1D"}
package/dist/entity.js ADDED
@@ -0,0 +1,71 @@
1
+ import { BCS } from '@mysten/bcs';
2
+ import { Protocol } from './protocol';
3
+ import { IsValidDesription, IsValidAddress, IsValidName, isValidHttpUrl, } from './utils';
4
+ import { ERROR, Errors } from './exception';
5
+ export class Entity {
6
+ object;
7
+ protocol;
8
+ get_object() { return this.object; }
9
+ constructor(protocol) {
10
+ this.protocol = protocol;
11
+ this.object = '';
12
+ }
13
+ static From(protocol) {
14
+ let r = new Entity(protocol);
15
+ r.object = Protocol.TXB_OBJECT(protocol.CurrentSession(), protocol.EntityObject());
16
+ return r;
17
+ }
18
+ mark(resource, address, like) {
19
+ if (!IsValidAddress(address))
20
+ ERROR(Errors.IsValidAddress, like);
21
+ let txb = this.protocol.CurrentSession();
22
+ txb.moveCall({
23
+ target: this.protocol.EntityFn(like),
24
+ arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, resource.get_object()), txb.pure(address, BCS.ADDRESS)]
25
+ });
26
+ }
27
+ update(info) {
28
+ if (!IsValidName(info.name))
29
+ ERROR(Errors.IsValidName, 'update');
30
+ if (info?.description && !IsValidDesription(info.description))
31
+ ERROR(Errors.IsValidDesription, 'update');
32
+ if (info?.avatar && !isValidHttpUrl(info.avatar))
33
+ ERROR(Errors.isValidHttpUrl, 'update:avatar');
34
+ if (info?.twitter && !IsValidName(info.twitter))
35
+ ERROR(Errors.IsValidName, 'update:twitter');
36
+ if (info?.homepage && !isValidHttpUrl(info.homepage))
37
+ ERROR(Errors.isValidHttpUrl, 'update:homepage');
38
+ if (info?.discord && !IsValidName(info.discord))
39
+ ERROR(Errors.IsValidName, 'update:discord');
40
+ let txb = this.protocol.CurrentSession();
41
+ txb.moveCall({
42
+ target: this.protocol.EntityFn('avatar_update'),
43
+ arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(JSON.stringify(info), BCS.STRING)]
44
+ });
45
+ }
46
+ create_resource(description) {
47
+ if (!IsValidDesription(description))
48
+ ERROR(Errors.IsValidDesription, 'create_resource');
49
+ let txb = this.protocol.CurrentSession();
50
+ return txb.moveCall({
51
+ target: this.protocol.EntityFn('resource_create'),
52
+ arguments: [Protocol.TXB_OBJECT(txb, this.object), txb.pure(description, BCS.STRING)]
53
+ });
54
+ }
55
+ destroy_resource(resource) {
56
+ let txb = this.protocol.CurrentSession();
57
+ return txb.moveCall({
58
+ target: this.protocol.EntityFn('resource_destroy'),
59
+ arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, resource.get_object())]
60
+ });
61
+ }
62
+ transfer_resource(resource, new_address) {
63
+ if (!IsValidAddress(new_address))
64
+ ERROR(Errors.IsValidAddress, 'transfer_resource');
65
+ let txb = this.protocol.CurrentSession();
66
+ return txb.moveCall({
67
+ target: this.protocol.EntityFn('resource_transfer'),
68
+ arguments: [Protocol.TXB_OBJECT(txb, this.object), Protocol.TXB_OBJECT(txb, resource.get_object()), txb.pure(new_address, BCS.ADDRESS)]
69
+ });
70
+ }
71
+ }
@@ -15,7 +15,8 @@ export declare enum Errors {
15
15
  IsValidPermissionIndex = "invalid permission index",
16
16
  IsValidKey = "invalid key",
17
17
  Fail = "fail",
18
- IsValidIndentifier = "indentifier invalid"
18
+ IsValidIndentifier = "indentifier invalid",
19
+ isValidHttpUrl = "invalid url"
19
20
  }
20
21
  export declare const ERROR: (error: Errors, info?: any) => never;
21
22
  //# sourceMappingURL=exception.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AACA,oBAAY,MAAM;IACd,iBAAiB,wBAAwB;IACzC,WAAW,iBAAiB;IAC5B,sBAAsB,iBAAiB;IACvC,eAAe,qBAAqB;IACpC,cAAc,oBAAoB;IAClC,cAAc,yBAAyB;IACvC,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,cAAc,oBAAoB;IAClC,YAAY,kBAAkB;IAC9B,cAAc,oBAAoB;IAClC,UAAU,uBAAuB;IACjC,YAAY,sBAAuB;IACnC,sBAAsB,6BAA6B;IACnD,UAAU,gBAAgB;IAC1B,IAAI,SAAS;IACb,kBAAkB,wBAAwB;CAC7C;AAED,eAAO,MAAM,KAAK,UAAU,MAAM,SAAQ,GAAG,UAG5C,CAAA"}
1
+ {"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AACA,oBAAY,MAAM;IACd,iBAAiB,wBAAwB;IACzC,WAAW,iBAAiB;IAC5B,sBAAsB,iBAAiB;IACvC,eAAe,qBAAqB;IACpC,cAAc,oBAAoB;IAClC,cAAc,yBAAyB;IACvC,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,cAAc,oBAAoB;IAClC,YAAY,kBAAkB;IAC9B,cAAc,oBAAoB;IAClC,UAAU,uBAAuB;IACjC,YAAY,sBAAuB;IACnC,sBAAsB,6BAA6B;IACnD,UAAU,gBAAgB;IAC1B,IAAI,SAAS;IACb,kBAAkB,wBAAwB;IAC1C,cAAc,gBAAgB;CACjC;AAED,eAAO,MAAM,KAAK,UAAU,MAAM,SAAQ,GAAG,UAG5C,CAAA"}
package/dist/exception.js CHANGED
@@ -17,6 +17,7 @@ export var Errors;
17
17
  Errors["IsValidKey"] = "invalid key";
18
18
  Errors["Fail"] = "fail";
19
19
  Errors["IsValidIndentifier"] = "indentifier invalid";
20
+ Errors["isValidHttpUrl"] = "invalid url";
20
21
  })(Errors || (Errors = {}));
21
22
  export const ERROR = (error, info) => {
22
23
  const e = error + info ? (': ' + info) : '';
package/dist/guard.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Protocol, GuardAddress, Data_Type, MODULES, ContextType, ValueType, OperatorType, VariableType } from './protocol';
2
- export type GuardVariable = Map<number, Guard_Vriable>;
1
+ import { Protocol, GuardAddress, Data_Type, MODULES, ContextType, ValueType, OperatorType, ConstantType } from './protocol';
2
+ export type GuardConstant = Map<number, Guard_Vriable>;
3
3
  export interface Guard_Vriable {
4
- type: VariableType;
4
+ type: ConstantType;
5
5
  value?: Uint8Array;
6
6
  witness?: Uint8Array;
7
7
  }
@@ -15,29 +15,29 @@ export declare class Guard {
15
15
  static IsBoolCmd: (cmd: number) => boolean;
16
16
  static GetCmd: (cmd: number) => any;
17
17
  }
18
- export declare class GuardVariableHelper {
18
+ export declare class GuardConstantHelper {
19
19
  static IsValidIndentifier: (identifier: number) => boolean;
20
- static get_variable_value(variables: GuardVariable, identifier: number, type: VariableType): Uint8Array | undefined;
21
- static get_variable_witness(variables: GuardVariable, identifier: number): Uint8Array | undefined;
22
- static add_future_variable(variables: GuardVariable, identifier: number, witness: any, value?: any, bNeedSerialize?: boolean): void;
23
- static add_variable(variables: GuardVariable, identifier: number, type: ValueType, value: any, bNeedSerialize?: boolean): false | undefined;
20
+ static get_constant_value(constants: GuardConstant, identifier: number, type: ConstantType): Uint8Array | undefined;
21
+ static get_constant_witness(constants: GuardConstant, identifier: number): Uint8Array | undefined;
22
+ static add_future_constant(constants: GuardConstant, identifier: number, witness: any, value?: any, bNeedSerialize?: boolean): void;
23
+ static add_constant(constants: GuardConstant, identifier: number, type: ValueType, value: any, bNeedSerialize?: boolean): false | undefined;
24
24
  }
25
25
  export declare class GuardMaker {
26
26
  protected data: Uint8Array[];
27
27
  protected type_validator: Data_Type[];
28
- protected variable: GuardVariable;
28
+ protected constant: GuardConstant;
29
29
  private static index;
30
30
  private static get_index;
31
31
  constructor();
32
- add_variable(type: VariableType, value: any, bNeedSerialize?: boolean): number;
32
+ add_constant(type: ConstantType, value: any, bNeedSerialize?: boolean): number;
33
33
  private serValueParam;
34
34
  add_param(type: ValueType | ContextType, param?: any): GuardMaker;
35
35
  add_query(module: MODULES, query_name: string, object_address_from: string | number, bWitness?: boolean): GuardMaker;
36
36
  add_logic(type: OperatorType): GuardMaker;
37
37
  build(bNot?: boolean): GuardMaker;
38
38
  IsReady(): boolean;
39
- combine(otherBuilt: GuardMaker, bAnd?: boolean, bCombinVariable?: boolean): GuardMaker;
40
- get_variable(): GuardVariable;
39
+ combine(otherBuilt: GuardMaker, bAnd?: boolean, bCombinConstant?: boolean): GuardMaker;
40
+ get_constant(): GuardConstant;
41
41
  get_input(): Uint8Array[];
42
42
  static input_combine(input1: Uint8Array, input2: Uint8Array, bAnd?: boolean): Uint8Array;
43
43
  static input_not(input: Uint8Array): Uint8Array;
@@ -1 +1 @@
1
- {"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAc,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAG,YAAY,EAAE,YAAY,EAAY,MAAM,YAAY,CAAC;AAKnJ,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,YAAY,CAAE;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,UAAU,CAAC;CACxB;AAED,qBAAa,KAAK;IACd,MAAM,CAAC,gBAAgB,SAAQ;IAC/B,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,EAAE,KAAK,EAAC,UAAU,GAAI,YAAY;IA4DrF,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAI,YAAY;IAOtD,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAC,QAAQ,GAAI,YAAY;IAOvD,MAAM,CAAC,OAAO,EAAC,GAAG,EAAE,CAiIlB;IACF,MAAM,CAAC,OAAO,QAA0D;IACxE,MAAM,CAAC,SAAS,QAAQ,MAAM,KAAI,OAAO,CAAsE;IAC/G,MAAM,CAAC,MAAM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MAAM,EAAE,mBAAmB,EAAC,MAAM,GAAG,MAAM,EAAE,QAAQ,GAAC,OAAa,GAAI,UAAU;IAgDtH,SAAS,CAAC,IAAI,EAAC,YAAY,GAAI,UAAU;IAsCzC,KAAK,CAAC,IAAI,UAAQ,GAAI,UAAU;IAchC,OAAO,IAAK,OAAO;IAInB,OAAO,CAAC,UAAU,EAAC,UAAU,EAAE,IAAI,GAAC,OAAc,EAAE,eAAe,UAAM,GAAI,UAAU;IAmBvF,YAAY;IACZ,SAAS;IAET,MAAM,CAAC,aAAa,CAAC,MAAM,EAAC,UAAU,EAAE,MAAM,EAAC,UAAU,EAAE,IAAI,GAAC,OAAc,GAAI,UAAU;IAI5F,MAAM,CAAC,SAAS,CAAC,KAAK,EAAC,UAAU,GAAI,UAAU;IAI/C,MAAM,CAAC,UAAU,CAAC,IAAI,EAAC,MAAM,GAAI,OAAO;CAS3C"}
package/dist/guard.js CHANGED
@@ -13,19 +13,19 @@ export class Guard {
13
13
  ERROR(Errors.IsValidDesription);
14
14
  }
15
15
  let bcs_input = maker.get_input()[0];
16
- let variables = maker.get_variable();
16
+ let constants = maker.get_constant();
17
17
  if (bcs_input.length == 0 || bcs_input.length > Guard.MAX_INPUT_LENGTH) {
18
18
  ERROR(Errors.InvalidParam, 'launch input');
19
19
  }
20
20
  let bValid = true;
21
- variables?.forEach((v, k) => {
22
- if (!GuardVariableHelper.IsValidIndentifier(k))
21
+ constants?.forEach((v, k) => {
22
+ if (!GuardConstantHelper.IsValidIndentifier(k))
23
23
  bValid = false;
24
24
  if (!v.value && !v.witness)
25
25
  bValid = false;
26
26
  });
27
27
  if (!bValid) {
28
- ERROR(Errors.InvalidParam, 'launch variables');
28
+ ERROR(Errors.InvalidParam, 'launch constants');
29
29
  }
30
30
  let txb = protocol.CurrentSession();
31
31
  let input = new Uint8Array(bcs_input); // copy new uint8array to reserve!
@@ -34,22 +34,22 @@ export class Guard {
34
34
  target: protocol.GuardFn('new'),
35
35
  arguments: [txb.pure(description, BCS.STRING), txb.pure([].slice.call(input.reverse()))],
36
36
  });
37
- variables?.forEach((v, k) => {
37
+ constants?.forEach((v, k) => {
38
38
  if (v.type == ContextType.TYPE_WITNESS_ID) {
39
39
  if (!v.witness) {
40
- ERROR(Errors.InvalidParam, 'variables type');
40
+ ERROR(Errors.InvalidParam, 'constants type');
41
41
  }
42
42
  txb.moveCall({
43
- target: protocol.GuardFn("variable_add"),
43
+ target: protocol.GuardFn("constant_add"),
44
44
  arguments: [guard, txb.pure(k, BCS.U8), txb.pure(v.type, BCS.U8), txb.pure([].slice.call(v.witness)), txb.pure(true, BCS.BOOL)]
45
45
  });
46
46
  }
47
47
  else {
48
48
  if (!v.value) {
49
- ERROR(Errors.InvalidParam, 'variables type');
49
+ ERROR(Errors.InvalidParam, 'constants type');
50
50
  }
51
51
  txb.moveCall({
52
- target: protocol.GuardFn("variable_add"),
52
+ target: protocol.GuardFn("constant_add"),
53
53
  arguments: [guard, txb.pure(k, BCS.U8), txb.pure(v.type, BCS.U8), txb.pure([].slice.call(v.value)), txb.pure(true, BCS.BOOL)]
54
54
  });
55
55
  }
@@ -192,6 +192,19 @@ export class Guard {
192
192
  [MODULES.vote, 'top1_count', 190, [], ValueType.TYPE_U64],
193
193
  [MODULES.vote, 'top1_name_by_votes', 191, [], ValueType.TYPE_VEC_U8],
194
194
  [MODULES.vote, 'top1_votes', 192, [], ValueType.TYPE_U64],
195
+ [MODULES.wowok, 'initor', 210, [], ValueType.TYPE_ADDRESS],
196
+ [MODULES.wowok, 'everyone_guard', 211, [], ValueType.TYPE_ADDRESS],
197
+ [MODULES.wowok, 'entities', 212, [], ValueType.TYPE_ADDRESS],
198
+ [MODULES.wowok, 'grantor_count', 213, [], ValueType.TYPE_U64],
199
+ [MODULES.wowok, 'has_grantor', 214, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
200
+ [MODULES.wowok, 'grantor_name', 215, [ValueType.TYPE_ADDRESS], ValueType.TYPE_VEC_U8],
201
+ [MODULES.wowok, 'grantor_register_time', 216, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
202
+ [MODULES.wowok, 'grantor_expired_time', 217, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
203
+ [MODULES.wowok, 'grantor_grantee', 218, [ValueType.TYPE_ADDRESS], ValueType.TYPE_ADDRESS],
204
+ [MODULES.entity, 'has_entity', 230, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL],
205
+ [MODULES.entity, 'entity_like', 231, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
206
+ [MODULES.entity, 'entity_dislike', 232, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64],
207
+ [MODULES.entity, 'entity_infomation', 233, [ValueType.TYPE_ADDRESS], ValueType.TYPE_VEC_U8],
195
208
  ];
196
209
  static BoolCmd = Guard.QUERIES.filter(q => q[4] == ValueType.TYPE_BOOL);
197
210
  static IsBoolCmd = (cmd) => { return Guard.BoolCmd.includes((q) => { return q[2] == cmd; }); };
@@ -199,45 +212,45 @@ export class Guard {
199
212
  return Guard.QUERIES.find((q) => { return q[2] == cmd; });
200
213
  };
201
214
  }
202
- export class GuardVariableHelper {
215
+ export class GuardConstantHelper {
203
216
  static IsValidIndentifier = (identifier) => {
204
217
  if (!IsValidInt(identifier) || identifier > 255)
205
218
  return false;
206
219
  return true;
207
220
  };
208
- static get_variable_value(variables, identifier, type) {
209
- if (variables.has(identifier)) {
210
- let v = variables.get(identifier);
221
+ static get_constant_value(constants, identifier, type) {
222
+ if (constants.has(identifier)) {
223
+ let v = constants.get(identifier);
211
224
  if (v?.value && v.type == type) {
212
225
  return v.value;
213
226
  }
214
227
  }
215
228
  }
216
- static get_variable_witness(variables, identifier) {
217
- if (variables.has(identifier)) {
218
- let v = variables.get(identifier);
229
+ static get_constant_witness(constants, identifier) {
230
+ if (constants.has(identifier)) {
231
+ let v = constants.get(identifier);
219
232
  if (v?.witness && v.type == ContextType.TYPE_WITNESS_ID) {
220
233
  return v.witness;
221
234
  }
222
235
  }
223
236
  }
224
- static add_future_variable(variables, identifier, witness, value, bNeedSerialize = true) {
225
- if (!GuardVariableHelper.IsValidIndentifier(identifier))
226
- ERROR(Errors.IsValidIndentifier, 'add_future_variable');
237
+ static add_future_constant(constants, identifier, witness, value, bNeedSerialize = true) {
238
+ if (!GuardConstantHelper.IsValidIndentifier(identifier))
239
+ ERROR(Errors.IsValidIndentifier, 'add_future_constant');
227
240
  if (!witness && !value)
228
241
  ERROR(Errors.InvalidParam, 'both witness and value invalid');
229
- let v = variables.get(identifier);
242
+ let v = constants.get(identifier);
230
243
  if (!v || v.type == ContextType.TYPE_WITNESS_ID) {
231
244
  if (bNeedSerialize) {
232
- variables.set(identifier, { type: ContextType.TYPE_WITNESS_ID, value: value ? Bcs.getInstance().ser_address(value) : undefined, witness: witness ? Bcs.getInstance().ser_address(witness) : undefined });
245
+ constants.set(identifier, { type: ContextType.TYPE_WITNESS_ID, value: value ? Bcs.getInstance().ser_address(value) : undefined, witness: witness ? Bcs.getInstance().ser_address(witness) : undefined });
233
246
  }
234
247
  else {
235
- variables.set(identifier, { type: ContextType.TYPE_WITNESS_ID, value: value ? value : undefined, witness: witness ? witness : undefined });
248
+ constants.set(identifier, { type: ContextType.TYPE_WITNESS_ID, value: value ? value : undefined, witness: witness ? witness : undefined });
236
249
  }
237
250
  }
238
251
  }
239
- static add_variable(variables, identifier, type, value, bNeedSerialize = true) {
240
- if (!GuardVariableHelper.IsValidIndentifier(identifier))
252
+ static add_constant(constants, identifier, type, value, bNeedSerialize = true) {
253
+ if (!GuardConstantHelper.IsValidIndentifier(identifier))
241
254
  return false;
242
255
  if (!value)
243
256
  return false;
@@ -262,27 +275,27 @@ export class GuardVariableHelper {
262
275
  case ValueType.TYPE_VEC_U256:
263
276
  let ser = SER_VALUE.find(s => s.type == type);
264
277
  if (!ser)
265
- ERROR(Errors.Fail, 'add_variable: invalid type');
266
- bNeedSerialize ? variables.set(identifier, { type: type, value: Bcs.getInstance().ser(ser.name, value) }) :
267
- variables.set(identifier, { type: type, value: value });
278
+ ERROR(Errors.Fail, 'add_constant: invalid type');
279
+ bNeedSerialize ? constants.set(identifier, { type: type, value: Bcs.getInstance().ser(ser.name, value) }) :
280
+ constants.set(identifier, { type: type, value: value });
268
281
  return;
269
282
  case ValueType.TYPE_VEC_U8:
270
283
  if (typeof (value) === 'string') {
271
- variables.set(identifier, { type: type, value: Bcs.getInstance().ser_string(value) });
284
+ constants.set(identifier, { type: type, value: Bcs.getInstance().ser_string(value) });
272
285
  }
273
286
  else {
274
- variables.set(identifier, { type: type, value: value });
287
+ constants.set(identifier, { type: type, value: value });
275
288
  }
276
289
  return;
277
290
  default:
278
- ERROR(Errors.Fail, 'add_variable serialize not impl yet');
291
+ ERROR(Errors.Fail, 'add_constant serialize not impl yet');
279
292
  }
280
293
  }
281
294
  }
282
295
  export class GuardMaker {
283
296
  data = [];
284
297
  type_validator = [];
285
- variable = new Map();
298
+ constant = new Map();
286
299
  static index = 0;
287
300
  static get_index() {
288
301
  if (GuardMaker.index == 256) {
@@ -291,14 +304,14 @@ export class GuardMaker {
291
304
  return GuardMaker.index++;
292
305
  }
293
306
  constructor() { }
294
- add_variable(type, value, bNeedSerialize = true) {
307
+ add_constant(type, value, bNeedSerialize = true) {
295
308
  let identifier = GuardMaker.get_index();
296
309
  if (type == ContextType.TYPE_WITNESS_ID) {
297
- // add witness to variable
298
- GuardVariableHelper.add_future_variable(this.variable, identifier, value, undefined, bNeedSerialize);
310
+ // add witness to constant
311
+ GuardConstantHelper.add_future_constant(this.constant, identifier, value, undefined, bNeedSerialize);
299
312
  }
300
313
  else {
301
- GuardVariableHelper.add_variable(this.variable, identifier, type, value, bNeedSerialize);
314
+ GuardConstantHelper.add_constant(this.constant, identifier, type, value, bNeedSerialize);
302
315
  }
303
316
  return identifier;
304
317
  }
@@ -362,16 +375,16 @@ export class GuardMaker {
362
375
  this.data.push(Bcs.getInstance().ser_address(param));
363
376
  this.type_validator.push(ValueType.TYPE_ADDRESS);
364
377
  break;
365
- case ContextType.TYPE_VARIABLE:
378
+ case ContextType.TYPE_CONSTANT:
366
379
  if (!param) {
367
380
  ERROR(Errors.InvalidParam, 'param invalid');
368
381
  }
369
382
  if (typeof (param) != 'number' || !IsValidInt(param) || param > 255) {
370
383
  ERROR(Errors.InvalidParam, 'add_param param');
371
384
  }
372
- var v = this.variable.get(param);
385
+ var v = this.constant.get(param);
373
386
  if (!v)
374
- ERROR(Errors.Fail, 'identifier not in variable');
387
+ ERROR(Errors.Fail, 'identifier not in constant');
375
388
  this.type_validator.push(v.type);
376
389
  this.data.push(Bcs.getInstance().ser_u8(type));
377
390
  this.data.push(Bcs.getInstance().ser_u8(param));
@@ -382,14 +395,14 @@ export class GuardMaker {
382
395
  ;
383
396
  return this;
384
397
  }
385
- // object_address_from: string for static address; number as identifier invariable
398
+ // object_address_from: string for static address; number as identifier inconstant
386
399
  add_query(module, query_name, object_address_from, bWitness = false) {
387
400
  let query_index = Guard.QUERIES.findIndex((q) => { return q[0] == module && q[1] == query_name; });
388
401
  if (query_index == -1) {
389
402
  ERROR(Errors.InvalidParam, 'query_name');
390
403
  }
391
404
  if (typeof (object_address_from) == 'number') {
392
- if (!GuardVariableHelper.IsValidIndentifier(object_address_from)) {
405
+ if (!GuardConstantHelper.IsValidIndentifier(object_address_from)) {
393
406
  ERROR(Errors.InvalidParam, 'object_address_from');
394
407
  }
395
408
  }
@@ -413,12 +426,12 @@ export class GuardMaker {
413
426
  this.data.push(Bcs.getInstance().ser_address(object_address_from)); // object address
414
427
  }
415
428
  else {
416
- let v = this.variable.get(object_address_from);
429
+ let v = this.constant.get(object_address_from);
417
430
  if (!v)
418
- ERROR(Errors.Fail, 'object_address_from not in variable');
431
+ ERROR(Errors.Fail, 'object_address_from not in constant');
419
432
  if ((bWitness && v?.type == ContextType.TYPE_WITNESS_ID) || (!bWitness && v?.type == ValueType.TYPE_ADDRESS)) {
420
- this.data.push(Bcs.getInstance().ser_u8(ContextType.TYPE_VARIABLE));
421
- this.data.push(Bcs.getInstance().ser_u8(object_address_from)); // object identifer in variables
433
+ this.data.push(Bcs.getInstance().ser_u8(ContextType.TYPE_CONSTANT));
434
+ this.data.push(Bcs.getInstance().ser_u8(object_address_from)); // object identifer in constants
422
435
  }
423
436
  else {
424
437
  ERROR(Errors.Fail, 'type bWitness not match');
@@ -502,20 +515,20 @@ export class GuardMaker {
502
515
  IsReady() {
503
516
  return this.type_validator.length == 1 && this.type_validator[0] == ValueType.TYPE_BOOL && this.data.length == 1;
504
517
  }
505
- combine(otherBuilt, bAnd = true, bCombinVariable = false) {
518
+ combine(otherBuilt, bAnd = true, bCombinConstant = false) {
506
519
  if (!otherBuilt.IsReady() || !this.IsReady()) {
507
520
  ERROR(Errors.Fail, 'both should built yet');
508
521
  }
509
522
  ;
510
523
  let maker = new GuardMaker();
511
- this.variable.forEach((v, k) => {
512
- maker.variable.set(k, { type: v.type, value: v.value, witness: v.witness });
524
+ this.constant.forEach((v, k) => {
525
+ maker.constant.set(k, { type: v.type, value: v.value, witness: v.witness });
513
526
  });
514
- otherBuilt.variable.forEach((v, k) => {
515
- if (maker.variable.has(k) && !bCombinVariable) {
516
- ERROR(Errors.Fail, 'variable identifier exist');
527
+ otherBuilt.constant.forEach((v, k) => {
528
+ if (maker.constant.has(k) && !bCombinConstant) {
529
+ ERROR(Errors.Fail, 'constant identifier exist');
517
530
  }
518
- maker.variable.set(k, { type: v.type, value: v.value, witness: v.witness });
531
+ maker.constant.set(k, { type: v.type, value: v.value, witness: v.witness });
519
532
  });
520
533
  let op = bAnd ? OperatorType.TYPE_LOGIC_AND : OperatorType.TYPE_LOGIC_OR;
521
534
  maker.data.push(concatenate(Uint8Array, ...this.data, ...otherBuilt.data, Bcs.getInstance().ser_u8(op)));
@@ -523,7 +536,7 @@ export class GuardMaker {
523
536
  maker.type_validator = this.type_validator;
524
537
  return maker;
525
538
  }
526
- get_variable() { return this.variable; }
539
+ get_constant() { return this.constant; }
527
540
  get_input() { return this.data; }
528
541
  static input_combine(input1, input2, bAnd = true) {
529
542
  let op = bAnd ? OperatorType.TYPE_LOGIC_AND : OperatorType.TYPE_LOGIC_OR;
package/dist/index.d.ts CHANGED
@@ -11,4 +11,7 @@ export * from './passport';
11
11
  export * from './machine';
12
12
  export * from './service';
13
13
  export * from './graphql';
14
+ export * from './entity';
15
+ export * from './wowok';
16
+ export * from './resource';
14
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAe,YAAY,CAAA;AAC3B,cAAe,UAAU,CAAA;AACzB,cAAe,SAAS,CAAA;AACxB,cAAe,cAAc,CAAA;AAC7B,cAAe,SAAS,CAAA;AACxB,cAAe,cAAc,CAAA;AAC7B,cAAe,QAAQ,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -11,3 +11,6 @@ export * from './passport';
11
11
  export * from './machine';
12
12
  export * from './service';
13
13
  export * from './graphql';
14
+ export * from './entity';
15
+ export * from './wowok';
16
+ export * from './resource';
package/dist/machine.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { type TransactionResult } from '@mysten/sui.js/transactions';
2
2
  import { Protocol, PermissionObject, RepositoryObject, PassportObject, MachineObject, MachineAddress, GuardObject, TxbObject } from './protocol';
3
3
  import { PermissionIndexType } from './permission';
4
- import { Resource } from './resource';
5
4
  export type MachineNodeObject = TransactionResult | String;
6
5
  export interface Machine_Forward {
7
6
  name: string;
@@ -33,7 +32,6 @@ export declare class Machine {
33
32
  remove_node(nodes_name: string[], bTransferMyself?: boolean, passport?: PassportObject): void;
34
33
  destroy(): void;
35
34
  launch(): MachineAddress;
36
- mark(like: 'like' | 'unlike', resource: Resource): void;
37
35
  set_description(description: string, passport?: PassportObject): void;
38
36
  add_repository(repository: RepositoryObject, passport?: PassportObject): void;
39
37
  remove_repository(repositories: string[], removeall?: boolean, passport?: PassportObject): void;
@@ -1 +1 @@
1
- {"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAE/F,OAAO,EAAE,QAAQ,EAAc,gBAAgB,EAAE,gBAAgB,EAAG,cAAc,EAAE,aAAa,EAAE,cAAc,EAAG,WAAW,EAAE,SAAS,EAAC,MAAM,YAAY,CAAC;AAG9J,OAAO,EAAc,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,MAAM,CAAC;AAE3D,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,WAAW,CAAC;CACvB;AACD,MA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,CAAC,EAAC,cAAc;IAc/C,OAAO,CAAC,QAAQ,CAAC,EAAC,cAAc;IAgBhC,iBAAiB,CAAC,cAAc,EAAC,gBAAgB;IAcjD,MAAM,CAAC,iBAAiB,SAAM;IAC9B,MAAM,CAAC,oBAAoB,SAAiB;CAC/C"}
package/dist/machine.js CHANGED
@@ -174,13 +174,6 @@ export class Machine {
174
174
  arguments: [Protocol.TXB_OBJECT(txb, this.object)],
175
175
  });
176
176
  }
177
- mark(like, resource) {
178
- let txb = this.protocol.CurrentSession();
179
- txb.moveCall({
180
- target: this.protocol.MachineFn(like),
181
- arguments: [Protocol.TXB_OBJECT(txb, resource.get_object()), Protocol.TXB_OBJECT(txb, this.object)],
182
- });
183
- }
184
177
  set_description(description, passport) {
185
178
  if (!IsValidDesription(description)) {
186
179
  ERROR(Errors.IsValidDesription);