wowok 1.4.23 → 1.4.27

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.4.23",
3
+ "version": "1.4.27",
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",
@@ -36,7 +36,10 @@
36
36
  "grantor",
37
37
  "grantee",
38
38
  "move language",
39
- "move"
39
+ "move",
40
+ "treasury",
41
+ "payment",
42
+ "Withholding"
40
43
  ],
41
44
  "author": "wowok",
42
45
  "license": "Apache-2.0",
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, ResourceObject} from './protocol';
3
- import { IsValidDesription, IsValidUintLarge, IsValidAddress, IsValidArgType, } from './utils'
2
+ import { FnCallType, Protocol, PassportObject, PermissionObject, GuardObject, DemandAddress, TxbObject } from './protocol';
3
+ import { IsValidDesription, IsValidAddress, IsValidArgType, IsValidU64, parseObjectType } from './utils'
4
4
  import { Errors, ERROR} from './exception'
5
5
 
6
6
  export class Demand {
@@ -35,7 +35,7 @@ export class Demand {
35
35
  if (!IsValidArgType(bounty_type)) {
36
36
  ERROR(Errors.IsValidArgType, bounty_type);
37
37
  }
38
- if (!IsValidUintLarge(time)) {
38
+ if (!IsValidU64(time)) {
39
39
  ERROR(Errors.IsValidUint, 'time')
40
40
  }
41
41
 
@@ -95,7 +95,7 @@ export class Demand {
95
95
 
96
96
  // minutes_duration TRUE , time is minutes count; otherwise, the deadline time
97
97
  expand_time(minutes_duration:boolean, time: number, passport?:PassportObject) {
98
- if (!IsValidUintLarge(time)) {
98
+ if (!IsValidU64(time)) {
99
99
  ERROR(Errors.IsValidUint, 'time');
100
100
  }
101
101
  const clock = this.txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
@@ -250,16 +250,8 @@ export class Demand {
250
250
  })
251
251
  this.permission = new_permission
252
252
  }
253
- static parseObjectType = (chain_type:string) : string => {
254
- if (chain_type) {
255
- const s = 'demand::Demand<'
256
- const i = chain_type.indexOf(s);
257
- if (i > 0) {
258
- let r = chain_type.slice(i + s.length, chain_type.length-1);
259
- return r
260
- }
261
- }
262
- return '';
253
+ static parseObjectType = (chain_type?:string | null) : string => {
254
+ return parseObjectType(chain_type, 'demand::Demand<')
263
255
  }
264
256
 
265
257
  static MAX_BOUNTY_COUNT = 300;
package/src/guard.ts CHANGED
@@ -250,31 +250,32 @@ export class Guard {
250
250
  [MODULES.vote, 'Vote-Guard Wight', 1110, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The voting weight corresponding to the Vote-Guard.', ['guard address']],
251
251
  [MODULES.vote, 'Has Voted by Address', 1111, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Whether an address has already voted?', ['address']],
252
252
  [MODULES.vote, 'Voted Weight by Address', 1112, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The weight of whether an address has been voted on.', ['adddress']],
253
- [MODULES.vote, 'Has Option', 1113, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Whether a voting option is included?', ['option name']],
254
- [MODULES.vote, 'Has Object of Option', 1114, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Whether a voting option refers to an object?', ['option name']],
255
- [MODULES.vote, 'Option Object', 1115, [ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The object referenced by a voting option.', ['option name']],
256
- [MODULES.vote, 'Option Counts', 1116, [ValueType.TYPE_STRING], ValueType.TYPE_U64, 'The number of votes for the voting option.', ['option name']],
257
- [MODULES.vote, 'Option Votes', 1117, [ValueType.TYPE_STRING], ValueType.TYPE_U64, 'The number of voted addresses for the voting option.', ['option name']],
253
+ [MODULES.vote, 'Has Option', 1113, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Whether a voting option is included?', ['option content']],
254
+ [MODULES.vote, 'Has Object of Option', 1114, [ValueType.TYPE_STRING], ValueType.TYPE_BOOL, 'Whether a voting option refers to an object?', ['option content']],
255
+ [MODULES.vote, 'Option Object', 1115, [ValueType.TYPE_STRING], ValueType.TYPE_ADDRESS, 'The object referenced by a voting option.', ['option content']],
256
+ [MODULES.vote, 'Option Counts', 1116, [ValueType.TYPE_STRING], ValueType.TYPE_U64, 'The number of votes for the voting option.', ['option content']],
257
+ [MODULES.vote, 'Option Votes', 1117, [ValueType.TYPE_STRING], ValueType.TYPE_U64, 'The number of voted addresses for the voting option.', ['option content']],
258
258
  [MODULES.vote, 'Address Count Voted', 1118, [], ValueType.TYPE_U64, 'Total number of addresses voted.', []],
259
- [MODULES.vote, 'Top1 Option by Addresses', 1119, [], ValueType.TYPE_STRING, 'The name of the voting option ranked first by the number of voting addresses.', []],
259
+ [MODULES.vote, 'Top1 Option by Addresses', 1119, [], ValueType.TYPE_STRING, 'The content of the voting option ranked first by the number of voting addresses.', []],
260
260
  [MODULES.vote, 'Top1 Counts by Addresses', 1120, [], ValueType.TYPE_U64, 'Number of votes for the top voting option by number of voting addresses.', []],
261
- [MODULES.vote, 'Top1 Option by Votes', 1121, [], ValueType.TYPE_STRING, 'The name of the voting option ranked first by the number of votes.', []],
261
+ [MODULES.vote, 'Top1 Option by Votes', 1121, [], ValueType.TYPE_STRING, 'The content of the voting option ranked first by the number of votes.', []],
262
262
  [MODULES.vote, 'Top1 Counts by Votes', 1122, [], ValueType.TYPE_U64, 'Number of votes for the top voting option by number of votes.', []],
263
-
263
+ [MODULES.vote, 'Voted Time by Address', 1113, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The time of whether an address has been voted on.', ['adddress']],
264
+
264
265
  [MODULES.payment, 'Sender', 1200, [], ValueType.TYPE_ADDRESS, 'Payment originator address.', []],
265
- [MODULES.payment, 'Total Amount', 1201, [], ValueType.TYPE_U64, "Payment amount.", []],
266
- [MODULES.payment, 'Tips', 1202, [], ValueType.TYPE_STRING, 'Payment remarks.', ['address']],
266
+ [MODULES.payment, 'Total Amount', 1201, [], ValueType.TYPE_U128, "Payment amount.", []],
267
+ [MODULES.payment, 'Remark', 1202, [], ValueType.TYPE_STRING, 'Payment remark.', ['address']],
267
268
  [MODULES.payment, 'Has Guard for Perpose', 1203, [], ValueType.TYPE_BOOL, 'Whether the payment references a Guard?', []],
268
269
  [MODULES.payment, 'Has Object for Perpose', 1204, [], ValueType.TYPE_BOOL, 'Whether the payment references an Object?', []],
269
270
  [MODULES.payment, 'Guard for Perpose', 1205, [], ValueType.TYPE_ADDRESS, 'The Guard referenced by this payment.', []],
270
271
  [MODULES.payment, 'Object for Perpose', 1206, [], ValueType.TYPE_ADDRESS, "The Object referenced by this payment.", []],
271
- [MODULES.payment, 'Number of Transfer', 1207, [], ValueType.TYPE_U64, 'Number of recipients to receive payment from.', []],
272
+ [MODULES.payment, 'Number of Recipients', 1207, [], ValueType.TYPE_U64, 'Number of recipients to receive payment from.', []],
272
273
  [MODULES.payment, 'Is a Recipient', 1208, [ValueType.TYPE_ADDRESS], ValueType.TYPE_BOOL, 'Is a recipient received the payment?', ['address']],
273
274
  [MODULES.payment, 'Amount for a Recipient', 1209, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The amount of payment received by an address.', ['address']],
274
275
  [MODULES.payment, 'Time', 1210, [], ValueType.TYPE_U64, 'Payment time', []],
275
276
  [MODULES.payment, 'Is from Treasury', 1211, [], ValueType.TYPE_BOOL, 'Whether the payment comes from a Treasury?', []],
276
277
  [MODULES.payment, 'Treasury Address', 1212, [], ValueType.TYPE_ADDRESS, 'The Treasury from which the payment comes.', []],
277
- [MODULES.payment, 'Index', 1213, [], ValueType.TYPE_U64, 'Payment index or id.', []],
278
+ [MODULES.payment, 'Biz-ID', 1213, [], ValueType.TYPE_U64, 'Bisiness ID number of the payment.', []],
278
279
 
279
280
  [MODULES.withholding, 'Amount', 1300, [], ValueType.TYPE_U64, 'Total amount deposited with withholding.' , []],
280
281
  [MODULES.withholding, 'Original Type Deposited', 1301, [], ValueType.TYPE_STRING, "Original type name of asserts deposited.", []],
@@ -295,11 +296,10 @@ export class Guard {
295
296
  [MODULES.treasury, 'Permission', 1400, [], ValueType.TYPE_ADDRESS, 'Permission object address.', []],
296
297
  [MODULES.treasury, 'Balance', 1401, [], ValueType.TYPE_U64, "Treasury balance.", []],
297
298
  [MODULES.treasury, 'Number of Flow Records', 1402, [], ValueType.TYPE_U64, 'Number of treasury transactions.', []],
298
- [MODULES.treasury, 'Deposit Flow', 1403, [], ValueType.TYPE_U128, 'Treasury inflow amount.', []],
299
- [MODULES.treasury, 'Withdraw Flow', 1404, [], ValueType.TYPE_U128, 'Treasury outflow amount.', []],
300
- [MODULES.treasury, 'Flow over a Period of Time', 1405, [ValueType.TYPE_U64, ValueType.TYPE_U64], ValueType.TYPE_U128, 'The flow amount between certain periods.', ['begin time', 'end time']],
301
- [MODULES.treasury, 'Deposit Flow over a Period of Time', 1406, [ValueType.TYPE_U64, ValueType.TYPE_U64], ValueType.TYPE_U128, "The inflow amount between certain periods.", ['begin time', 'end time']],
302
- [MODULES.treasury, 'Withdraw Flow over a Period of Time', 1407, [ValueType.TYPE_U64, ValueType.TYPE_U64], ValueType.TYPE_U128, 'The outflow amount between certain periods.', ['begin time', 'end time']],
299
+ [MODULES.treasury, 'Inflow Amount', 1403, [], ValueType.TYPE_U128, 'Treasury inflow amount.', []],
300
+ [MODULES.treasury, 'Outflow Amount', 1404, [], ValueType.TYPE_U128, 'Treasury outflow amount.', []],
301
+ [MODULES.treasury, 'Number of Payment', 1405, [ValueType.TYPE_ADDRESS], ValueType.TYPE_U64, 'The number of flows generated by a payment.', ['payment address']],
302
+ [MODULES.treasury, 'Can anyone deposit ', 1406, [], ValueType.TYPE_BOOL, "Whether to allow any address to deposit?", []],
303
303
  ];
304
304
 
305
305
  static BoolCmd = Guard.QUERIES.filter(q => q[4] === ValueType.TYPE_BOOL);
package/src/index.ts CHANGED
@@ -14,4 +14,6 @@ export * from './graphql'
14
14
  export * from './entity'
15
15
  export * from './wowok'
16
16
  export * from './resource'
17
- export * from './treasury'
17
+ export * from './treasury'
18
+ export * from './payment'
19
+ export * from './withholding'
package/src/machine.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import { Transaction as TransactionBlock, TransactionObjectArgument, type TransactionResult } from '@mysten/sui/transactions';
2
2
  import { Protocol, FnCallType, PermissionObject, RepositoryObject, PassportObject, MachineObject, MachineAddress, GuardObject, TxbObject} from './protocol';
3
3
  import { IsValidInt, Bcs, array_unique, IsValidArray, IsValidAddress, IsValidName, IsValidName_AllowEmpty,
4
- IsValidEndpoint, IsValidDesription,
5
- IsValidUintLarge,
6
- IsValidU64} from './utils'
4
+ IsValidEndpoint, IsValidDesription, IsValidU64 } from './utils'
7
5
  import { Permission, PermissionIndexType } from './permission';
8
6
  import { Errors, ERROR} from './exception'
9
7
  import { ValueType } from './protocol';
package/src/passport.ts CHANGED
@@ -94,7 +94,7 @@ export class GuardParser {
94
94
 
95
95
  // console.log(res[0].data?.content);
96
96
  let content = res[0].data!.content as any;
97
- if (content?.type != protocol.Package() + '::guard::Guard') {
97
+ if (content?.type != protocol.Package('base') + '::guard::Guard') {
98
98
  ERROR(Errors.Fail, 'GuardObject object invalid')
99
99
  }
100
100
 
@@ -260,7 +260,7 @@ export class GuardParser {
260
260
  if (index === -1) ERROR(Errors.Fail, 'Parse_Guard_Helper invalid type: ' + c.type);
261
261
 
262
262
 
263
- if (c.fields.input.type === (protocol.Package() + '::bcs::BCS')) {
263
+ if (c.fields.input.type === (protocol.Package('base') + '::bcs::BCS')) {
264
264
  const constants = GuardParser.parse_constant(c.fields.constants); // MUST first
265
265
  const inputs = GuardParser.parse_bcs(constants, Uint8Array.from(c.fields.input.fields.bytes));
266
266
  me.guard_list.push({id: c.fields.id.id, input:[...inputs], constant:[...constants], digest:r.data?.digest??'', version:r.data?.version ?? ''});
package/src/payment.ts ADDED
@@ -0,0 +1,63 @@
1
+ import { CoinObject, FnCallType, PaymentAddress, Protocol, TxbObject} from './protocol';
2
+ import { IsValidDesription, IsValidAddress, IsValidArray, } from './utils';
3
+ import { ERROR, Errors } from './exception';
4
+ import { Transaction as TransactionBlock} from '@mysten/sui/transactions';
5
+
6
+ export interface Payment_Receiver {
7
+ address: string;
8
+ coin: CoinObject;
9
+ }
10
+
11
+ export interface PaymentParam {
12
+ receiver: Payment_Receiver[];
13
+ business_index: bigint;
14
+ business_remark: string;
15
+ for_object?: string;
16
+ for_guard?: string;
17
+ }
18
+
19
+ export const PAYMENT_MAX_RECEIVER_COUNT = 200;
20
+ export function create_payment(txb:TransactionBlock, pay_token_type:string, param:PaymentParam) : PaymentAddress {
21
+ if (!pay_token_type) ERROR(Errors.InvalidParam, 'Payment.New.pay_token_type');
22
+
23
+ if (param.receiver.length > PAYMENT_MAX_RECEIVER_COUNT) {
24
+ ERROR(Errors.InvalidParam, 'Payment.New.param.receiver');
25
+ }
26
+
27
+ if (!IsValidArray(param.receiver, (item:Payment_Receiver) => { return IsValidAddress(item.address) && Protocol.IsValidObjects([item.coin])})) {
28
+ ERROR(Errors.IsValidArray, 'Payment.New.param.receiver');
29
+ }
30
+
31
+ if (param?.for_object && !IsValidAddress(param.for_object)) {
32
+ ERROR(Errors.IsValidAddress, 'Payment.New.param.for_object')
33
+ }
34
+ if (param?.for_guard && !IsValidAddress(param.for_guard)) {
35
+ ERROR(Errors.IsValidAddress, 'Payment.New.param.for_guard')
36
+ }
37
+ if (param?.business_remark && !IsValidDesription(param?.business_remark)) {
38
+ ERROR(Errors.IsValidDesription, 'Payment.New.param.business_remark')
39
+ }
40
+
41
+ let obj = txb.pure.option('address', param.for_object ? param.for_object : undefined);
42
+ const clock = txb.sharedObjectRef(Protocol.CLOCK_OBJECT);
43
+
44
+ if (param.for_guard) {
45
+ return txb.moveCall({
46
+ target:Protocol.Instance().PaymentFn('create_withGuard') as FnCallType,
47
+ arguments:[txb.pure.vector('address', param.receiver.map((i)=>i.address)), txb.makeMoveVec({elements:param.receiver.map((i)=>i.coin)}),
48
+ obj, txb.object(param.for_guard), txb.pure.u64(param.business_index), txb.pure.string(param.business_remark), txb.object(clock)],
49
+ typeArguments:[pay_token_type],
50
+ })
51
+ } else {
52
+ return txb.moveCall({
53
+ target:Protocol.Instance().PaymentFn('new') as FnCallType,
54
+ arguments:[txb.pure.vector('address', param.receiver.map((i)=>i.address)), txb.makeMoveVec({elements:param.receiver.map((i)=>i.coin)}),
55
+ obj, txb.pure.u64(param.business_index), txb.pure.string(param.business_remark), txb.object(clock)],
56
+ typeArguments:[pay_token_type],
57
+ })
58
+ }
59
+ }
60
+
61
+
62
+
63
+
package/src/permission.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { FnCallType, TxbObject, PermissionObject, PermissionAddress, GuardObject, Protocol} from './protocol';
2
- import { array_unique, IsValidAddress, IsValidArray, IsValidDesription, IsValidUintLarge, Bcs, IsValidName} from './utils';
2
+ import { array_unique, IsValidAddress, IsValidArray, IsValidDesription, Bcs, IsValidName, IsValidU64} from './utils';
3
3
  import { ERROR, Errors } from './exception';
4
- import { ValueType } from './protocol';
5
4
  import { BCS } from '@mysten/bcs';
6
5
  import { Transaction as TransactionBlock } from '@mysten/sui/transactions';
7
6
 
@@ -80,10 +79,11 @@ export enum PermissionIndex {
80
79
  progress_parent = 655,
81
80
 
82
81
  treasury = 700,
83
- treasury_deposit = 701,
84
- treasury_withdraw = 702,
85
- treasury_free_deposit_set = 703,
82
+ treasury_receive = 701,
83
+ treasury_deposit = 702,
84
+ treasury_withdraw = 703,
86
85
  treasury_descritption = 704,
86
+ treasury_free_deposit_set = 705,
87
87
  user_defined_start = 1000,
88
88
  }
89
89
 
@@ -184,6 +184,7 @@ export const PermissionInfo : PermissionInfoType[] = [
184
184
 
185
185
  {index:PermissionIndex.treasury, name: 'Treasury', description:'Launch new Treasury', module: 'treasury'},
186
186
  {index:PermissionIndex.treasury_deposit, name: 'Deposit', description:'Deposit coins', module: 'treasury'},
187
+ {index:PermissionIndex.treasury_receive, name: 'Receive', description:'Receive coins from some address sent', module: 'treasury'},
187
188
  {index:PermissionIndex.treasury_withdraw, name: 'Withdraw', description:'Withdraw coins', module: 'treasury'},
188
189
  {index:PermissionIndex.treasury_free_deposit_set, name: 'Be Free Deposit', description:'Set whether deposits can be made without permission', module: 'treasury'},
189
190
  {index:PermissionIndex.treasury_descritption, name: 'Description', description:'Set Treasury description', module: 'treasury'},
@@ -565,7 +566,7 @@ export class Permission {
565
566
  static BUSINESS_PERMISSIONS_START = PermissionIndex.user_defined_start;
566
567
 
567
568
  static IsValidUserDefinedIndex = (index:number) => {
568
- return index >= Permission.BUSINESS_PERMISSIONS_START && IsValidUintLarge(index)
569
+ return index >= Permission.BUSINESS_PERMISSIONS_START && IsValidU64(index)
569
570
  }
570
571
 
571
572
  static IsValidPermissionIndex = (index:PermissionIndexType) : boolean => {
package/src/progress.ts CHANGED
@@ -78,7 +78,6 @@ export class Progress {
78
78
  }
79
79
 
80
80
  launch() : ProgressAddress {
81
-
82
81
  return this.txb.moveCall({
83
82
  target:Protocol.Instance().ProgressFn('create') as FnCallType,
84
83
  arguments: [Protocol.TXB_OBJECT(this.txb, this.object)],
package/src/protocol.ts CHANGED
@@ -3,7 +3,7 @@ import { SuiClient, SuiObjectResponse, SuiObjectDataOptions, SuiTransactionBlock
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
4
  import { toHEX, fromHEX, BcsReader } from '@mysten/bcs';
5
5
  import { Transaction as TransactionBlock, Inputs, TransactionResult, TransactionArgument } from '@mysten/sui/transactions';
6
- import { capitalize, IsValidAddress, IsValidArray, IsValidU128, IsValidU64, IsValidU8, IsValidUintLarge } from './utils'
6
+ import { capitalize, IsValidAddress, IsValidArray, IsValidU128, IsValidU256, IsValidU64, IsValidU8 } from './utils'
7
7
  import { GuardConstant } from './guard';
8
8
  import { isValidSuiAddress, isValidSuiObjectId } from '@mysten/sui/utils'
9
9
 
@@ -11,7 +11,6 @@ export enum MODULES {
11
11
  machine = 'machine',
12
12
  node = 'node',
13
13
  progress = 'progress',
14
- community = 'community',
15
14
  repository = 'repository',
16
15
  permission = 'permission',
17
16
  passport = 'passport',
@@ -56,6 +55,11 @@ export type ResourceObject = TransactionResult | string | TransactionArgument;
56
55
  export type ResourceAddress = TransactionResult;
57
56
  export type EntityObject = TransactionResult | string | TransactionArgument;
58
57
  export type EntityAddress = TransactionResult;
58
+ export type TreasuryAddress = TransactionResult;
59
+ export type PaymentObject = TransactionResult | string | TransactionArgument;
60
+ export type PaymentAddress = TransactionResult;
61
+ export type ReceivedObject = TransactionResult | string | TransactionArgument;
62
+ export type CoinWrapperObject = TransactionResult;
59
63
 
60
64
  export type TxbObject = string | TransactionResult | TransactionArgument | GuardObject | RepositoryObject | PermissionObject | MachineObject | PassportObject |
61
65
  DemandObject | ServiceObject | RewardObject | OrderObject | DiscountObject | VoteObject | DemandObject | ResourceObject | EntityObject;
@@ -190,7 +194,7 @@ export const SER_VALUE: ValueTypeString[] = [
190
194
  {type: ValueType.TYPE_VEC_STRING, name: '[string]', description:'ascii string array. eg:["abc", "hi"]'},
191
195
  {type: ValueType.TYPE_STRING, name: 'string', description:'eg:"wowok"', },
192
196
  {type: ValueType.TYPE_OPTION_STRING, name: 'option', description:'option of string. eg:none or string value'},
193
- {type: ValueType.TYPE_U256, name: 'number', description:'unsigned-256 number. eg:12345678901233', validator:IsValidUintLarge},
197
+ {type: ValueType.TYPE_U256, name: 'number', description:'unsigned-256 number. eg:12345678901233', validator:IsValidU256},
194
198
  ]
195
199
 
196
200
  //export type ConstantType = ValueType | ContextType.TYPE_WITNESS_ID;
@@ -204,20 +208,22 @@ export enum ENTRYPOINT {
204
208
  }
205
209
  /*
206
210
  const TESTNET = {
207
- package: "0xbd3d0929072f7647e521bf72851ccdc7e2169052b22bfdc5b49439c48cfb119a",
211
+ wowok: "0xbd3d0929072f7647e521bf72851ccdc7e2169052b22bfdc5b49439c48cfb119a",
208
212
  wowok_object: '0xb0a521a287e9d5e08932b3984dbe6ce159e836179c41bd08c556ef77ecdb7439',
209
213
  entity_object: '0x16aab98920e7341d1dc19631031253234b2b71fc2ab8c32d65ee3ded8072acef',
210
214
  treasury_cap:'0xb75a2ca2f651755c134ad521175f33f9e3f9008ad44340f76b3229e1f30cfdff',
211
215
  }
212
216
  */
213
217
  const TESTNET = {
214
- package: "0xf108d64c8143ec040da0d5538e834a67f0a9c661f92011195b60f51b3bc33a46",
215
- wowok_object: '0xc4fc2a42a5fbcfc68b3d8ac079e4d5a07f637c541e0183446a9da655965cda5e',
216
- entity_object: '0x8bbab9023092dc89c3c60c766b204c0dfbe3da46a2de486d8ab92ba91a4c905f',
217
- treasury_cap:'0x07e7b3c355b63bade82c1e0e2653e655a1b20da6cc531db5707ad1292fd418e4',
218
+ wowok: "0xb82ef16ea48fb4f732310c3a0c86c34d0b8711f4dac1c4ca693005345047bfa4",
219
+ base: '0x74fb58a0b148f19852a721293a797fdeb59dec5da71ca31838fc810af2d32fdd',
220
+ wowok_object: '0x41c93c2903227632a33394d37fd3b7f62a33bc72b16a7f9aafc8161b78b232be',
221
+ entity_object: '0x0b34c975a4b179755dabdec5c50505bd21c0439c463d171a54fa44f215e3bb57',
222
+ treasury_cap:'0xacb8b1d380d4f75a802dd7412142290bebd7f6266785690de2daf68f6a7ba9ce',
218
223
  }
219
224
  const MAINNET = {
220
- package: "",
225
+ wowok: "",
226
+ base:"",
221
227
  wowok_object: '',
222
228
  entity_object: '',
223
229
  treasury_cap:'',
@@ -231,7 +237,7 @@ export interface CoinTypeInfo {
231
237
  }
232
238
  export class Protocol {
233
239
  protected network = '';
234
- protected package = '';
240
+ protected package = new Map<string, string>();
235
241
  protected signer = '';
236
242
  protected wowok_object = '';
237
243
  protected entity_object = '';
@@ -262,14 +268,16 @@ export class Protocol {
262
268
  case ENTRYPOINT.devnet:
263
269
  break;
264
270
  case ENTRYPOINT.testnet:
265
- this.package = TESTNET.package;
271
+ this.package.set('wowok', TESTNET.wowok);
272
+ this.package.set('base', TESTNET.base);
266
273
  this.wowok_object = TESTNET.wowok_object;
267
274
  this.entity_object= TESTNET.entity_object;
268
275
  this.treasury_cap = TESTNET.treasury_cap;
269
276
  this.graphql = 'https://sui-testnet.mystenlabs.com/graphql';
270
277
  break;
271
278
  case ENTRYPOINT.mainnet:
272
- this.package = MAINNET.package;
279
+ this.package.set('wowok', MAINNET.wowok);
280
+ this.package.set('base', MAINNET.base);
273
281
  this.wowok_object = MAINNET.wowok_object;
274
282
  this.entity_object= MAINNET.entity_object;
275
283
  this.treasury_cap = MAINNET.treasury_cap;
@@ -277,7 +285,10 @@ export class Protocol {
277
285
  break;
278
286
  };
279
287
  }
280
- Package(): string { return this.package }
288
+ Package(type:string): string {
289
+ return this.package.get(type) ?? ''
290
+ }
291
+
281
292
  WowokObject(): string { return this.wowok_object }
282
293
  EntityObject(): string { return this.entity_object }
283
294
  TreasuryCap() : string { return this.treasury_cap }
@@ -296,22 +307,23 @@ export class Protocol {
296
307
  }; return "";
297
308
  };
298
309
 
299
- MachineFn = (fn:any) => { return `${this.package}::${MODULES.machine}::${fn}`};
300
- ProgressFn = (fn:any) => { return `${this.package}::${MODULES.progress}::${fn}`};
301
- CommunityFn = (fn: any) => { return `${this.package}::${MODULES.community}::${fn}`};
302
- RepositoryFn = (fn:any) => { return `${this.package}::${MODULES.repository}::${fn}`};
303
- PermissionFn = (fn: any) => { return `${this.package}::${MODULES.permission}::${fn}`};
304
- PassportFn = (fn:any) => { return `${this.package}::${MODULES.passport}::${fn}`};
305
- GuardFn = (fn: any) => { return `${this.package}::${MODULES.guard}::${fn}`};
306
- VoteFn = (fn:any) => { return `${this.package}::${MODULES.vote}::${fn}`};
307
- DemandFn = (fn: any) => { return `${this.package}::${MODULES.demand}::${fn}`};
308
- OrderFn = (fn:any) => { return `${this.package}::${MODULES.order}::${fn}`};
309
- RewardFn = (fn: any) => { return `${this.package}::${MODULES.reward}::${fn}`};
310
- ServiceFn = (fn: any) => { return `${this.package}::${MODULES.service}::${fn}`};
311
- ResourceFn = (fn: any) => { return `${this.package}::${MODULES.resource}::${fn}`};
312
- EntityFn = (fn: any) => { return `${this.package}::${MODULES.entity}::${fn}`};
313
- WowokFn = (fn: any) => { return `${this.package}::${MODULES.wowok}::${fn}`};
314
- TreasuryFn = (fn: any) => { return `${this.package}::${MODULES.treasury}::${fn}`};
310
+ MachineFn = (fn:any) => { return `${this.package.get('wowok')}::${MODULES.machine}::${fn}`};
311
+ ProgressFn = (fn:any) => { return `${this.package.get('wowok')}::${MODULES.progress}::${fn}`};
312
+ RepositoryFn = (fn:any) => { return `${this.package.get('wowok')}::${MODULES.repository}::${fn}`};
313
+ PermissionFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.permission}::${fn}`};
314
+ PassportFn = (fn:any) => { return `${this.package.get('wowok')}::${MODULES.passport}::${fn}`};
315
+ GuardFn = (fn: any) => { return `${this.package.get('base')}::${MODULES.guard}::${fn}`};
316
+ VoteFn = (fn:any) => { return `${this.package.get('wowok')}::${MODULES.vote}::${fn}`};
317
+ DemandFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.demand}::${fn}`};
318
+ OrderFn = (fn:any) => { return `${this.package.get('wowok')}::${MODULES.order}::${fn}`};
319
+ RewardFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.reward}::${fn}`};
320
+ ServiceFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.service}::${fn}`};
321
+ ResourceFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.resource}::${fn}`};
322
+ EntityFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.entity}::${fn}`};
323
+ WowokFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.wowok}::${fn}`};
324
+ TreasuryFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.treasury}::${fn}`};
325
+ PaymentFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.payment}::${fn}`};
326
+ WithholdingFn = (fn: any) => { return `${this.package.get('wowok')}::${MODULES.withholding}::${fn}`};
315
327
 
316
328
  Query = async (objects: Query_Param[], options:SuiObjectDataOptions={showContent:true}) : Promise<SuiObjectResponse[]> => {
317
329
  const client = new SuiClient({ url: this.NetworkUrl() });
@@ -342,7 +354,6 @@ export class Protocol {
342
354
 
343
355
  const privkey = fromHEX(priv_key);
344
356
  const keypair = Ed25519Keypair.fromSecretKey(privkey);
345
-
346
357
  const response = await client.signAndExecuteTransaction({
347
358
  transaction: this.CurrentSession(),
348
359
  signer: keypair,
@@ -356,8 +367,8 @@ export class Protocol {
356
367
  static SUI_TOKEN_TYPE = '0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI'; // TOKEN_TYPE
357
368
  // used in demand, reward, ...
358
369
  static SUI_COIN_TYPE = '0x0000000000000000000000000000000000000000000000000000000000000002::coin::Coin<0x2::sui::SUI>'; // COIN TYPE
359
- WOWOK_TOKEN_TYPE = () => { return this.package + '::wowok::WOWOK' }
360
- WOWOK_COIN_TYPE = () => { return '0x2::coin::Coin<' + this.package + '::wowok::WOWOK>'}
370
+ WOWOK_TOKEN_TYPE = () => { return this.package.get('wowok') + '::wowok::WOWOK' }
371
+ WOWOK_COIN_TYPE = () => { return '0x2::coin::Coin<' + this.package.get('wowok') + '::wowok::WOWOK>'}
361
372
  COINS_TYPE = () => {
362
373
  switch(this.network) {
363
374
  case ENTRYPOINT.testnet:
@@ -392,13 +403,13 @@ export class Protocol {
392
403
  CoinTypes_Testnet:CoinTypeInfo[] = [
393
404
  {symbol:'SUI', type:'0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI', decimals:9, alias:true},
394
405
  {symbol:'SUI', type:'0x2::sui::SUI', decimals:9, },
395
- {symbol:'WOW', type:TESTNET.package + '::wowok::WOWOK', decimals:9},
406
+ {symbol:'WOW', type:TESTNET.wowok + '::wowok::WOWOK', decimals:9},
396
407
  ];
397
408
 
398
409
  CoinTypes_Mainnet:CoinTypeInfo[] = [
399
410
  {symbol:'SUI', type:'0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI', decimals:9, alias:true},
400
411
  {symbol:'SUI', type:'0x2::sui::SUI', decimals:9, },
401
- {symbol:'WOW', type:TESTNET.package + '::wowok::WOWOK', decimals:9},
412
+ {symbol:'WOW', type:TESTNET.wowok + '::wowok::WOWOK', decimals:9},
402
413
  {symbol:'USDT', type:'0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN', decimals:6},
403
414
  {symbol:'USDC', type:'0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN', decimals:6},
404
415
  {symbol:'WETH', type:'0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN', decimals:8},
@@ -438,13 +449,20 @@ export class Protocol {
438
449
  })
439
450
  }
440
451
  WOWOK_OBJECTS_TYPE = () => (Object.keys(MODULES) as Array<keyof typeof MODULES>).map((key) =>
441
- { let i = this.package + '::' + key + '::'; return i + capitalize(key); })
452
+ { let i = this.package.get('wowok') + '::' + key + '::'; return i + capitalize(key); })
442
453
  WOWOK_OBJECTS_PREFIX_TYPE = () => (Object.keys(MODULES) as Array<keyof typeof MODULES>).map((key) =>
443
- { return this.package + '::' + key + '::'; })
454
+ { return this.package.get('wowok') + '::' + key + '::'; })
455
+ private hasPackage(pack:string) : boolean {
456
+ for (let value of this.package.values()) {
457
+ if (value === pack) {
458
+ return true;
459
+ }
460
+ } return false;
461
+ }
444
462
  object_name_from_type_repr = (type_repr:string) : string => {
445
463
  if (!type_repr) return ''
446
464
  let i = type_repr.indexOf('::');
447
- if (i > 0 && type_repr.slice(0, i) === this.package) {
465
+ if (i > 0 && this.hasPackage(type_repr.slice(0, i))) {
448
466
  i = type_repr.indexOf('<');
449
467
  if (i > 0) {
450
468
  type_repr = type_repr.slice(0, i);
@@ -457,6 +475,22 @@ export class Protocol {
457
475
  }
458
476
  return ''
459
477
  }
478
+ module_object_name_from_type_repr = (type_repr:string) : string => {
479
+ if (!type_repr) return ''
480
+ let i = type_repr.indexOf('::');
481
+ if (i > 0 && this.hasPackage(type_repr.slice(0, i))) {
482
+ i = type_repr.indexOf('<');
483
+ if (i > 0) {
484
+ type_repr = type_repr.slice(0, i);
485
+ }
486
+
487
+ let n = type_repr.indexOf('::');
488
+ if (n > 0) {
489
+ return type_repr.slice(n+2);
490
+ }
491
+ }
492
+ return ''
493
+ }
460
494
  }
461
495
 
462
496
  export class RpcResultParser {
@@ -471,8 +505,7 @@ export class RpcResultParser {
471
505
  if (response?.objectChanges) {
472
506
  response.objectChanges.forEach((change) => {
473
507
  RpcResultParser.Object_Type_Extra().forEach((name) => {
474
- let type = protocol.Package() + '::' + name;
475
- if (change.type == 'created' && change.objectType.includes(type)) {
508
+ if (change.type == 'created' && protocol.module_object_name_from_type_repr(change.objectType)===name) {
476
509
  if (ret.has(name)) {
477
510
  ret.get(name)?.push(change.objectId);
478
511
  } else {
package/src/repository.ts CHANGED
@@ -2,7 +2,7 @@ import { Protocol, FnCallType, ValueType, RepositoryValueType, RepositoryAddress
2
2
  import { PermissionIndexType, Permission } from './permission'
3
3
  import { Bcs, array_unique, IsValidDesription, IsValidAddress, IsValidArray, IsValidName, ValueTypeConvert} from './utils';
4
4
  import { ERROR, Errors } from './exception';
5
- import { MAX_U8, MAX_U128, MAX_U256, MAX_U64, stringToUint8Array } from './utils';
5
+ import { MAX_U8, MAX_U128, MAX_U256, MAX_U64, parseObjectType } from './utils';
6
6
  import { type TransactionResult, Transaction as TransactionBlock } from '@mysten/sui/transactions';
7
7
 
8
8
  export enum Repository_Policy_Mode {
@@ -394,16 +394,8 @@ export class Repository {
394
394
  static IsValidValue = (value:Uint8Array) => {
395
395
  return value.length < Repository.MAX_VALUE_LENGTH;
396
396
  }
397
- static parseObjectType = (chain_type:string) : string => {
398
- if (chain_type) {
399
- const s = 'repository::Repository<'
400
- const i = chain_type.indexOf(s);
401
- if (i > 0) {
402
- let r = chain_type.slice(i + s.length, chain_type.length-1);
403
- return r
404
- }
405
- }
406
- return '';
397
+ static parseObjectType = (chain_type?:string | null) : string => {
398
+ return parseObjectType(chain_type, 'repository::Repository<');
407
399
  }
408
400
 
409
401
  static rpc_de_data(fields:any) : RepData [] {
package/src/resource.ts CHANGED
@@ -21,6 +21,8 @@ export class Resource {
21
21
  static LikeName = "like";
22
22
  static DislikeName = "dislike";
23
23
  static FavorName = "favor";
24
+ static LaunchName = 'launch';
25
+ static OrderName = 'order';
24
26
 
25
27
  protected object:TxbObject;
26
28
  protected txb;
@@ -55,14 +57,14 @@ export class Resource {
55
57
  });
56
58
  }
57
59
 
58
- add2(object:string, name:string[]) {
59
- if (!IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'add2');
60
+ add2(object:TxbObject, name:string[]) {
61
+ if (typeof(object) === 'string' && !IsValidAddress(object)) ERROR(Errors.IsValidAddress, 'add2');
60
62
  if (!IsValidArray(name, IsValidName)) ERROR(Errors.IsValidArray, 'add2');
61
63
  if (!name) return
62
64
 
63
65
  this.txb.moveCall({
64
66
  target:Protocol.Instance().ResourceFn('add2') as FnCallType,
65
- arguments:[Protocol.TXB_OBJECT(this.txb, this.object), this.txb.pure.address(object),
67
+ arguments:[Protocol.TXB_OBJECT(this.txb, this.object), typeof(object) === 'string' ? this.txb.pure.address(object) : object,
66
68
  this.txb.pure.vector('string', name)]
67
69
  });
68
70
  }