wowok_agent 2.1.40 → 2.2.0
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/dist/index.js +1237 -1
- package/dist/schema/call/allocation.js +24 -1
- package/dist/schema/call/arbitration.js +92 -1
- package/dist/schema/call/base.js +134 -1
- package/dist/schema/call/contact.js +37 -1
- package/dist/schema/call/demand.js +47 -1
- package/dist/schema/call/guard.js +58 -1
- package/dist/schema/call/handler.js +171 -1
- package/dist/schema/call/index.js +18 -1
- package/dist/schema/call/machine.js +152 -1
- package/dist/schema/call/order.js +34 -1
- package/dist/schema/call/payment.js +17 -1
- package/dist/schema/call/permission.js +105 -1
- package/dist/schema/call/personal.js +68 -1
- package/dist/schema/call/progress.js +26 -1
- package/dist/schema/call/proof.js +27 -1
- package/dist/schema/call/repository.js +76 -1
- package/dist/schema/call/reward.js +42 -1
- package/dist/schema/call/service.js +82 -1
- package/dist/schema/call/treasury.js +71 -1
- package/dist/schema/common/index.js +345 -1
- package/dist/schema/index.js +7 -1
- package/dist/schema/local/index.js +855 -1
- package/dist/schema/local/wip.js +187 -1
- package/dist/schema/messenger/index.js +446 -1
- package/dist/schema/query/index.js +1265 -1
- package/dist/schema/utils/guard-parser.js +401 -1
- package/dist/schema/utils/guard-query-utils.js +22 -1
- package/dist/schema/utils/node-parser.js +353 -1
- package/dist/schema/utils/permission-index-utils.js +7 -1
- package/package.json +3 -6
|
@@ -1 +1,345 @@
|
|
|
1
|
-
import{z}from'zod';import{isValidAddress,ValueType as a20a,ObjectType as a20b,ENTRYPOINT,isValidWowAddress,isValidName,isValidDescription,MAX_DESCRIPTION_LENGTH,isValidLongName,MAX_LONG_NAME_LENGTH}from'wowok';const isValidMoveIdentifier=a=>{if(a['length']===0x0)return![];const b=a[0x0];if(b==='_')return a['length']>0x1&&/^[a-zA-Z0-9_]+$/['test'](a['slice'](0x1));if(/^[a-zA-Z]$/['test'](b))return/^[a-zA-Z0-9_]*$/['test'](a['slice'](0x1));return![];};export const DescriptionSchema=z['string']()['refine'](isValidDescription,{'message':'Description\x20string\x20(max\x20'+MAX_DESCRIPTION_LENGTH+'\x20bcs\x20characters)'})['describe']('Description\x20string\x20(max\x20'+MAX_DESCRIPTION_LENGTH+'\x20bcs\x20characters)');export const LongNameSchema=z['string']()['refine'](isValidLongName,{'message':'max\x20'+MAX_LONG_NAME_LENGTH+'\x20bcs\x20characters'});export const WowAddressSchema=z['string']()['refine'](isValidAddress,{'message':'Invalid\x20ID\x20format:\x20must\x20be\x20\x270x\x27\x20prefix\x20followed\x20by\x2064\x20hex\x20characters'})['describe']('Valid\x20ID:\x200x\x20prefix\x20+\x2064\x20hex\x20characters,\x20or\x20builtin\x20ID\x20(0x5-0x9,\x20@0xaaa,\x20@0xaab,\x20@0x403,\x20@0xacc,\x20@0xc)');const WOW_TOKEN_TYPE='0x2::wow::WOW';export const TokenTypeSchema=z['string']()['refine'](a=>{if(a===WOW_TOKEN_TYPE)return!![];const b=a['split']('::');if(b['length']!==0x3)return![];const [c,d,e]=b;if(!isValidWowAddress(c))return![];if(!isValidMoveIdentifier(d))return![];if(!isValidMoveIdentifier(e))return![];return!![];},{'message':'Invalid\x20token\x20type\x20format.\x20Expected:\x20{address}::{module}::{struct}\x20where\x20address\x20is\x200x+64hex,\x20module/struct\x20are\x20valid\x20Move\x20identifiers,\x20or\x20\x270x2::wow::WOW\x27'})['describe']('Token\x20type\x20in\x20format:\x20{address}::{module}::{struct}.\x20Example:\x200x2::wow::WOW');export const TokenTypeWithDefaultSchema=TokenTypeSchema['default'](WOW_TOKEN_TYPE)['describe']('Token\x20type\x20in\x20format:\x20{address}::{module}::{struct}.\x20Default:\x200x2::wow::WOW');export const NameSchema=z['string']()['refine'](isValidName,'Name\x20string\x20(max\x2064\x20bcs\x20characters,\x20must\x20not\x20start\x20with\x20\x270x\x27)');export const NotEmptyNameSchema=z['string']()['nonempty']()['refine'](isValidName,'Name\x20string\x20(at\x20least\x201\x20character,\x20max\x20length\x2064\x20bcs\x20characters)');export const NameOrAddressSchema=z['string']()['refine'](a=>{if(isValidWowAddress(a))return!![];if(isValidName(a))return!![];return![];},{'message':'Invalid\x20ID\x20format:\x20must\x20be\x20\x270x\x27\x20prefix,\x20or\x20a\x20builtin\x20ID\x20(0x5-0x9,\x20@0xaaa,\x20@0xaab,\x20@0x403,\x20@0xacc,\x20@0xc)'})['describe']('Account/Object\x20name\x20or\x20ID.\x20If\x20specifying\x20an\x20account,\x20use\x20empty\x20string\x20\x27\x27\x20for\x20the\x20default\x20account.\x20'+'If\x20it\x20starts\x20with\x20\x270x\x27,\x20it\x20will\x20be\x20treated\x20as\x20an\x20ID.\x20'+'Otherwise,\x20it\x20will\x20be\x20treated\x20as\x20a\x20name\x20(max\x2064\x20bcs\x20characters).');export const AccountOrMark_AddressSchema=z['object']({'name_or_address':NameOrAddressSchema['optional'](),'local_mark_first':z['boolean']()['optional']()['describe']('Whether\x20to\x20prioritize\x20local\x20marks,\x20if\x20true,\x20prioritize\x20local\x20marks,\x20otherwise\x20prioritize\x20global\x20marks')})['strict']()['describe']('Account\x20or\x20address\x20lookup\x20object.\x20Use\x20this\x20to\x20specify\x20which\x20account\x20to\x20use\x20for\x20an\x20operation.\x20'+'EXAMPLE:\x20{\x20name_or_address:\x20\x27testor2\x27\x20}\x20-\x20looks\x20up\x20account\x20by\x20name;\x20'+'EXAMPLE:\x20{\x20name_or_address:\x20\x270x1234...\x27\x20}\x20-\x20uses\x20address\x20directly;\x20'+'If\x20name_or_address\x20is\x20empty\x20string\x20\x27\x27,\x20uses\x20the\x20default\x20local\x20account.');export const ManyAccountOrMark_AddressSchema=z['object']({'entities':z['array'](AccountOrMark_AddressSchema),'check_all_founded':z['boolean']()['optional']()['describe']('Whether\x20to\x20check\x20all\x20entities\x20are\x20found,\x20if\x20true,\x20all\x20entities\x20must\x20be\x20found\x20(abort\x20and\x20throw\x20exception\x20if\x20any\x20ID\x20not\x20found);\x20if\x20false,\x20only\x20return\x20found\x20IDs')})['strict']()['describe']('Used\x20to\x20batch\x20find\x20account\x20or\x20object\x20IDs\x20by\x20name');export const AccountOrMark_AddressAISchema=z['union']([z['string']()['describe']('Account\x20name,\x20address\x20(0x...),\x20or\x20mark\x20name.\x20'+'When\x20using\x20string\x20format,\x20local\x20marks\x20are\x20searched\x20first.\x20'+'EXAMPLE:\x20\x27alice\x27\x20-\x20searches\x20local\x20marks\x20first,\x20then\x20global;\x20'+'EXAMPLE:\x20\x270x1234...\x27\x20-\x20uses\x20address\x20directly'),AccountOrMark_AddressSchema])['describe']('Account\x20or\x20address\x20lookup.\x20Can\x20be\x20a\x20simple\x20string\x20(recommended\x20for\x20AI)\x20'+'or\x20full\x20object\x20with\x20explicit\x20local_mark_first\x20control');export const ManyAccountOrMark_AddressAISchema=z['union']([z['array'](z['string']())['describe']('Array\x20of\x20account\x20names,\x20addresses,\x20or\x20mark\x20names.\x20'+'Local\x20marks\x20are\x20searched\x20first\x20for\x20each\x20entry'),ManyAccountOrMark_AddressSchema])['describe']('Batch\x20account\x20or\x20address\x20lookup.\x20Can\x20be\x20an\x20array\x20of\x20strings\x20(recommended\x20for\x20AI)\x20'+'or\x20full\x20object\x20with\x20explicit\x20control');export const ObjectOwnerSchema=z['union']([z['object']({'AddressOwner':z['string']()['describe']('Address\x20owner')})['strict'](),z['object']({'ObjectOwner':z['string']()['describe']('Object\x20owner')})['strict'](),z['object']({'Shared':z['object']({'initial_shared_version':z['union']([z['string'](),z['number']()])['describe']('Version\x20when\x20object\x20became\x20shared')})['strict']()['describe']('Shared\x20object')})['strict'](),z['literal']('Immutable'),z['object']({'ConsensusAddressOwner':z['object']({'owner':z['string']()['describe']('Consensus\x20ID\x20owner'),'start_version':z['union']([z['string'](),z['number']()])['describe']('Version\x20when\x20object\x20recently\x20became\x20consensus\x20object')})['strict']()['describe']('Consensus\x20ID\x20owner')})['strict']()])['describe']('Object\x20owner');const ValueTypeStringNames=['Bool','Address','String','U8','U16','U32','U64','U128','U256','VecBool','VecAddress','VecString','VecU8','VecU16','VecU32','VecU64','VecU128','VecU256','VecVecU8'];export const ValueTypeUserSchema=z['union']([z['literal'](a20a['Bool'])['describe']('Bool\x20(0)'),z['literal'](a20a['Address'])['describe']('Address\x20(1)'),z['literal'](a20a['String'])['describe']('String\x20(2)'),z['literal'](a20a['U8'])['describe']('U8\x20(3)'),z['literal'](a20a['U16'])['describe']('U16\x20(4)'),z['literal'](a20a['U32'])['describe']('U32\x20(5)'),z['literal'](a20a['U64'])['describe']('U64\x20(6)'),z['literal'](a20a['U128'])['describe']('U128\x20(7)'),z['literal'](a20a['U256'])['describe']('U256\x20(8)'),z['literal'](a20a['VecBool'])['describe']('VecBool\x20(9)'),z['literal'](a20a['VecAddress'])['describe']('VecAddress\x20(10)'),z['literal'](a20a['VecString'])['describe']('VecString\x20(11)'),z['literal'](a20a['VecU8'])['describe']('VecU8\x20(12)'),z['literal'](a20a['VecU16'])['describe']('VecU16\x20(13)'),z['literal'](a20a['VecU32'])['describe']('VecU32\x20(14)'),z['literal'](a20a['VecU64'])['describe']('VecU64\x20(15)'),z['literal'](a20a['VecU128'])['describe']('VecU128\x20(16)'),z['literal'](a20a['VecU256'])['describe']('VecU256\x20(17)'),z['literal'](a20a['VecVecU8'])['describe']('VecVecU8\x20(18)'),z['literal']('Bool')['describe']('Bool'),z['literal']('Address')['describe']('Address'),z['literal']('String')['describe']('String'),z['literal']('U8')['describe']('U8'),z['literal']('U16')['describe']('U16'),z['literal']('U32')['describe']('U32'),z['literal']('U64')['describe']('U64'),z['literal']('U128')['describe']('U128'),z['literal']('U256')['describe']('U256'),z['literal']('VecBool')['describe']('VecBool'),z['literal']('VecAddress')['describe']('VecAddress'),z['literal']('VecString')['describe']('VecString'),z['literal']('VecU8')['describe']('VecU8'),z['literal']('VecU16')['describe']('VecU16'),z['literal']('VecU32')['describe']('VecU32'),z['literal']('VecU64')['describe']('VecU64'),z['literal']('VecU128')['describe']('VecU128'),z['literal']('VecU256')['describe']('VecU256'),z['literal']('VecVecU8')['describe']('VecVecU8'),z['literal']('bool')['describe']('bool'),z['literal']('address')['describe']('address'),z['literal']('string')['describe']('string'),z['literal']('u8')['describe']('u8'),z['literal']('u16')['describe']('u16'),z['literal']('u32')['describe']('u32'),z['literal']('u64')['describe']('u64'),z['literal']('u128')['describe']('u128'),z['literal']('u256')['describe']('u256'),z['literal']('vecbool')['describe']('vecbool'),z['literal']('vecaddress')['describe']('vecaddress'),z['literal']('vecstring')['describe']('vecstring'),z['literal']('vecu8')['describe']('vecu8'),z['literal']('vecu16')['describe']('vecu16'),z['literal']('vecu32')['describe']('vecu32'),z['literal']('vecu64')['describe']('vecu64'),z['literal']('vecu128')['describe']('vecu128'),z['literal']('vecu256')['describe']('vecu256'),z['literal']('vecvecu8')['describe']('vecvecu8')])['describe']('User\x20available\x20value\x20type\x20(number\x20or\x20string,\x20e.g.,\x206\x20or\x20\x27U64\x27\x20or\x20\x27u64\x27)');export const ValueTypeSchema=ValueTypeUserSchema['or'](z['literal'](a20a['Value'])['describe']('Value\x20(19)'))['or'](z['literal']('Value')['describe']('Value'))['describe']('Value\x20type\x20(number\x20or\x20string,\x20e.g.,\x206\x20or\x20\x27U64\x27)');export const ObjectTypeSchema=z['enum']([a20b['Permission'],a20b['Repository'],a20b['Arb'],a20b['Arbitration'],a20b['Service'],a20b['Machine'],a20b['Order'],a20b['Progress'],a20b['Payment'],a20b['Treasury'],a20b['Guard'],a20b['Demand'],a20b['Passport'],a20b['Allocation'],a20b['Resource'],a20b['Reward'],a20b['Discount'],a20b['EntityRegistrar'],a20b['EntityLinker'],a20b['Proof'],a20b['WReceivedObject'],a20b['Contact'],a20b['TableItem_ProgressHistory'],a20b['TableItem_PermissionPerm'],a20b['TableItem_DemandPresenter'],a20b['TableItem_MachineNode'],a20b['TableItem_TreasuryHistory'],a20b['TableItem_RepositoryData'],a20b['TableItem_RewardRecord'],a20b['TableItem_EntityLinker'],a20b['TableItem_AddressMark'],a20b['TableItem_EntityRegistrar']])['describe']('Wowok\x20object\x20type');export const BalanceTypeSchema=z['union']([z['number'](),z['string']()])['describe']('Balance\x20type');export const QueryIdSchema=z['number']()['int']()['min'](0x0)['describe']('Query\x20ID');export const CacheExpireTypeSchema=z['union']([z['number'](),z['literal']('INFINITE')])['describe']('Cache\x20expiration\x20time\x20type');export const ValueContainerSchema=z['lazy'](()=>z['object']({'valueType':ValueTypeSchema['describe']('Value\x20type'),'value':SupportedValueSchema['describe']('Value')})['strict']()['describe']('Value\x20container\x20with\x20type\x20and\x20value'));export const SupportedValueUserSchema=z['union']([z['boolean'](),z['union']([AccountOrMark_AddressSchema,z['string']()]),z['string'](),z['number'](),z['array'](z['boolean']()),z['union']([ManyAccountOrMark_AddressSchema,z['array'](z['string']())]),z['array'](z['string']()),z['array'](z['number']()),z['array'](z['array'](z['number']()))])['describe']('User\x20available\x20supported\x20value\x20type');export const SupportedValueSchema=SupportedValueUserSchema['or'](ValueContainerSchema)['describe']('Supported\x20value\x20type');export const GuardIdentifierSchema=z['number']()['int']()['min'](0x0)['max'](0xff)['describe']('Identifier\x20(0-255)\x20for\x20data\x20lookup\x20in\x20Guard\x20table.');export const GuardTableItemBaseSchema=z['object']({'identifier':GuardIdentifierSchema,'b_submission':z['boolean']()['describe']('Whether\x20user\x20submission\x20is\x20required\x20for\x20this\x20data'),'value_type':ValueTypeUserSchema['describe']('Type\x20of\x20the\x20value'),'value':SupportedValueUserSchema['optional']()['describe']('The\x20actual\x20value\x20data'),'name':z['string']()['default']('')['describe']('Name\x20or\x20description\x20of\x20this\x20data')})['strict']()['describe']('Guard\x20table\x20item');export const GuardTableItemSchema=GuardTableItemBaseSchema['extend']({'object_type':ObjectTypeSchema['optional']()['describe']('Object\x20type\x20when\x20value_type\x20is\x20Address\x20and\x20represents\x20a\x20specific\x20object')})['strict']()['describe']('Guard\x20table\x20item');export const EntrypointSchema=z['enum']([ENTRYPOINT['Localnet'],ENTRYPOINT['Testnet']])['describe']('Network\x20entrypoint:\x20Specifies\x20which\x20network\x20the\x20operation\x20occurs\x20on');export const FaucetNetworkSchema=z['enum']([ENTRYPOINT['Localnet'],ENTRYPOINT['Testnet']])['describe']('Network\x20entrypoint\x20for\x20Faucet:\x20Specifies\x20which\x20network\x20the\x20operation\x20occurs\x20on');export const ObjectBaseSchema=z['object']({'object':z['string']()['describe']('Object\x20ID'),'type':ObjectTypeSchema['optional']()['describe']('Object\x20type'),'type_raw':z['string']()['optional']()['describe']('Raw\x20object\x20type'),'owner':z['union']([ObjectOwnerSchema,z['null']()])['optional']()['describe']('Object\x20owner'),'version':z['string']()['optional']()['describe']('Object\x20version'),'previousTransaction':z['string']()['optional']()['describe']('Previous\x20transaction\x20ID'),'cache_expire':CacheExpireTypeSchema['optional']()['describe']('Cache\x20expiration\x20time'),'query_name':z['string']()['optional']()['describe']('Original\x20query\x20name\x20or\x20address\x20used\x20to\x20retrieve\x20this\x20object'),'_guard_node_comments':z['array'](z['object']({'type':z['string'](),'description':z['string']()}))['optional']()['describe']('Additional\x20comments\x20for\x20Guard\x20node\x20instructions')})['passthrough']()['describe']('Object\x20base\x20information');export const QueryEnvSchema=z['object']({'no_cache':z['boolean']()['optional']()['describe']('Whether\x20to\x20disable\x20cache'),'network':EntrypointSchema['optional']()})['strict']()['describe']('Query\x20environment\x20parameters');export const QueryReceivedSchema=QueryEnvSchema['extend']({'object':z['string']()['describe']('Object\x20ID\x20to\x20query'),'all_type':z['boolean']()['optional']()['describe']('Whether\x20to\x20query\x20all\x20types\x20of\x20received\x20objects'),'cursor':z['union']([z['string'](),z['null']()])['optional']()['describe']('Pagination\x20cursor'),'limit':z['union']([z['number'](),z['null']()])['optional']()['describe']('Number\x20of\x20records\x20returned\x20per\x20page')})['strict']()['describe']('Request\x20parameters\x20for\x20querying\x20object\x27s\x20received\x20objects');export const ReceivedBalanceObjectSchema=z['object']({'id':z['string']()['describe']('Received\x20CoinWrapper\x20object\x20ID'),'balance':BalanceTypeSchema,'payment':z['string']()['describe']('Payment\x20object\x20ID')})['strict']()['describe']('Received\x20CoinWrapper\x20object\x20record');export const CoinWrapperTokenTypeSchema=z['string']()['refine'](a=>{const b=a['match'](/^CoinWrapper<(.+)>$/);if(b){const g=b[0x1];if(g===WOW_TOKEN_TYPE)return!![];const h=g['split']('::');if(h['length']!==0x3)return![];const [i,j,k]=h;if(!isValidWowAddress(i))return![];if(!isValidMoveIdentifier(j))return![];if(!isValidMoveIdentifier(k))return![];return!![];}if(a===WOW_TOKEN_TYPE)return!![];const c=a['split']('::');if(c['length']!==0x3)return![];const [d,e,f]=c;if(!isValidWowAddress(d))return![];if(!isValidMoveIdentifier(e))return![];if(!isValidMoveIdentifier(f))return![];return!![];},{'message':'Invalid\x20token\x20type\x20format.\x20Expected:\x20CoinWrapper<{address}::{module}::{struct}>\x20or\x20{address}::{module}::{struct}.\x20Example:\x20CoinWrapper<0x2::wow::WOW>\x20or\x200x2::wow::WOW'})['describe']('Token\x20type\x20in\x20format:\x20CoinWrapper<{address}::{module}::{struct}>\x20or\x20{address}::{module}::{struct}.\x20Example:\x20CoinWrapper<0x2::wow::WOW>');export const ReceivedBalanceSchema=z['object']({'balance':BalanceTypeSchema,'token_type':CoinWrapperTokenTypeSchema['describe']('Asset\x20type\x20of\x20Coin\x20objects.\x20Supports\x20CoinWrapper<...>\x20format\x20for\x20order\x20receive\x20operations.'),'received':z['array'](ReceivedBalanceObjectSchema)['describe']('Received\x20records\x20of\x20Coin\x20objects')})['strict']()['describe']('Received\x20record\x20of\x20Coin\x20objects');export const ReceivedBalanceOrRecentlySchema=z['union']([ReceivedBalanceSchema,z['literal']('recently')])['describe']('Specified\x20received\x20balance\x20record\x20or\x20all\x20recently\x20received\x20balance\x20record');export const ReceivedNormalSchema=z['object']({'id':z['string']()['nonempty']()['describe']('Received\x20object\x20ID'),'type':z['string']()['nonempty']()['describe']('Object\x20type')})['strict']()['describe']('Received\x20normal\x20object\x20record');export const ReceivedObjectsOrRecentlySchema=z['union']([z['array'](ReceivedNormalSchema),ReceivedBalanceSchema,z['literal']('recently')])['describe']('Specified\x20received\x20object\x20records\x20or\x20all\x20recently\x20received\x20object\x20records');export const QueryReceivedResultSchema=z['object']({'result':z['union']([ReceivedBalanceSchema,z['array'](ReceivedNormalSchema)])['describe']('Received\x20CoinWrapper\x20object\x20record\x20or\x20received\x20other\x20objects\x20array')})['strict']()['describe']('Query\x20received\x20result');
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { isValidAddress, ValueType as WowValueType, ObjectType as WowObjectType, ENTRYPOINT, isValidWowAddress, isValidName, isValidDescription, MAX_DESCRIPTION_LENGTH, isValidLongName, MAX_LONG_NAME_LENGTH } from "wowok";
|
|
3
|
+
const isValidMoveIdentifier = (s) => {
|
|
4
|
+
if (s.length === 0)
|
|
5
|
+
return false;
|
|
6
|
+
const firstChar = s[0];
|
|
7
|
+
if (firstChar === '_') {
|
|
8
|
+
return s.length > 1 && /^[a-zA-Z0-9_]+$/.test(s.slice(1));
|
|
9
|
+
}
|
|
10
|
+
if (/^[a-zA-Z]$/.test(firstChar)) {
|
|
11
|
+
return /^[a-zA-Z0-9_]*$/.test(s.slice(1));
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
};
|
|
15
|
+
export const DescriptionSchema = z
|
|
16
|
+
.string()
|
|
17
|
+
.refine(isValidDescription, {
|
|
18
|
+
message: `Description string (max ${MAX_DESCRIPTION_LENGTH} bcs characters)`
|
|
19
|
+
})
|
|
20
|
+
.describe(`Description string (max ${MAX_DESCRIPTION_LENGTH} bcs characters)`);
|
|
21
|
+
export const LongNameSchema = z
|
|
22
|
+
.string()
|
|
23
|
+
.refine(isValidLongName, {
|
|
24
|
+
message: `max ${MAX_LONG_NAME_LENGTH} bcs characters`
|
|
25
|
+
});
|
|
26
|
+
export const WowAddressSchema = z
|
|
27
|
+
.string()
|
|
28
|
+
.refine(isValidAddress, {
|
|
29
|
+
message: "Invalid ID format: must be '0x' prefix followed by 64 hex characters"
|
|
30
|
+
})
|
|
31
|
+
.describe("Valid ID: 0x prefix + 64 hex characters, or builtin ID (0x5-0x9, @0xaaa, @0xaab, @0x403, @0xacc, @0xc)");
|
|
32
|
+
const WOW_TOKEN_TYPE = "0x2::wow::WOW";
|
|
33
|
+
export const TokenTypeSchema = z
|
|
34
|
+
.string()
|
|
35
|
+
.refine((val) => {
|
|
36
|
+
if (val === WOW_TOKEN_TYPE)
|
|
37
|
+
return true;
|
|
38
|
+
const parts = val.split("::");
|
|
39
|
+
if (parts.length !== 3)
|
|
40
|
+
return false;
|
|
41
|
+
const [address, module, structName] = parts;
|
|
42
|
+
if (!isValidWowAddress(address))
|
|
43
|
+
return false;
|
|
44
|
+
if (!isValidMoveIdentifier(module))
|
|
45
|
+
return false;
|
|
46
|
+
if (!isValidMoveIdentifier(structName))
|
|
47
|
+
return false;
|
|
48
|
+
return true;
|
|
49
|
+
}, {
|
|
50
|
+
message: "Invalid token type format. Expected: {address}::{module}::{struct} where address is 0x+64hex, module/struct are valid Move identifiers, or '0x2::wow::WOW'"
|
|
51
|
+
})
|
|
52
|
+
.describe("Token type in format: {address}::{module}::{struct}. Example: 0x2::wow::WOW");
|
|
53
|
+
export const TokenTypeWithDefaultSchema = TokenTypeSchema
|
|
54
|
+
.default(WOW_TOKEN_TYPE)
|
|
55
|
+
.describe("Token type in format: {address}::{module}::{struct}. Default: 0x2::wow::WOW");
|
|
56
|
+
export const NameSchema = z
|
|
57
|
+
.string()
|
|
58
|
+
.refine(isValidName, "Name string (max 64 bcs characters, must not start with '0x')");
|
|
59
|
+
export const NotEmptyNameSchema = z.string().nonempty()
|
|
60
|
+
.refine(isValidName, "Name string (at least 1 character, max length 64 bcs characters)");
|
|
61
|
+
export const NameOrAddressSchema = z
|
|
62
|
+
.string()
|
|
63
|
+
.refine((val) => {
|
|
64
|
+
if (isValidWowAddress(val))
|
|
65
|
+
return true;
|
|
66
|
+
if (isValidName(val))
|
|
67
|
+
return true;
|
|
68
|
+
return false;
|
|
69
|
+
}, {
|
|
70
|
+
message: "Invalid ID format: must be '0x' prefix, or a builtin ID (0x5-0x9, @0xaaa, @0xaab, @0x403, @0xacc, @0xc)"
|
|
71
|
+
}).describe("Account/Object name or ID. If specifying an account, use empty string '' for the default account. " +
|
|
72
|
+
"If it starts with '0x', it will be treated as an ID. " +
|
|
73
|
+
"Otherwise, it will be treated as a name (max 64 bcs characters).");
|
|
74
|
+
export const AccountOrMark_AddressSchema = z.object({
|
|
75
|
+
name_or_address: NameOrAddressSchema.optional(),
|
|
76
|
+
local_mark_first: z.boolean().optional().describe("Whether to prioritize local marks, if true, prioritize local marks, otherwise prioritize global marks"),
|
|
77
|
+
}).strict().describe("Account or address lookup object. Use this to specify which account to use for an operation. " +
|
|
78
|
+
"EXAMPLE: { name_or_address: 'testor2' } - looks up account by name; " +
|
|
79
|
+
"EXAMPLE: { name_or_address: '0x1234...' } - uses address directly; " +
|
|
80
|
+
"If name_or_address is empty string '', uses the default local account.");
|
|
81
|
+
export const ManyAccountOrMark_AddressSchema = z.object({
|
|
82
|
+
entities: z.array(AccountOrMark_AddressSchema),
|
|
83
|
+
check_all_founded: z.boolean().optional().describe("Whether to check all entities are found, if true, all entities must be found (abort and throw exception if any ID not found); if false, only return found IDs"),
|
|
84
|
+
}).strict().describe("Used to batch find account or object IDs by name");
|
|
85
|
+
export const AccountOrMark_AddressAISchema = z.union([
|
|
86
|
+
z.string().describe("Account name, address (0x...), or mark name. " +
|
|
87
|
+
"When using string format, local marks are searched first. " +
|
|
88
|
+
"EXAMPLE: 'alice' - searches local marks first, then global; " +
|
|
89
|
+
"EXAMPLE: '0x1234...' - uses address directly"),
|
|
90
|
+
AccountOrMark_AddressSchema
|
|
91
|
+
]).describe("Account or address lookup. Can be a simple string (recommended for AI) " +
|
|
92
|
+
"or full object with explicit local_mark_first control");
|
|
93
|
+
export const ManyAccountOrMark_AddressAISchema = z.union([
|
|
94
|
+
z.array(z.string()).describe("Array of account names, addresses, or mark names. " +
|
|
95
|
+
"Local marks are searched first for each entry"),
|
|
96
|
+
ManyAccountOrMark_AddressSchema
|
|
97
|
+
]).describe("Batch account or address lookup. Can be an array of strings (recommended for AI) " +
|
|
98
|
+
"or full object with explicit control");
|
|
99
|
+
export const ObjectOwnerSchema = z.union([
|
|
100
|
+
z.object({
|
|
101
|
+
AddressOwner: z.string().describe("Address owner"),
|
|
102
|
+
}).strict(),
|
|
103
|
+
z.object({
|
|
104
|
+
ObjectOwner: z.string().describe("Object owner"),
|
|
105
|
+
}).strict(),
|
|
106
|
+
z.object({
|
|
107
|
+
Shared: z.object({
|
|
108
|
+
initial_shared_version: z.union([z.string(), z.number()]).describe("Version when object became shared"),
|
|
109
|
+
}).strict().describe("Shared object"),
|
|
110
|
+
}).strict(),
|
|
111
|
+
z.literal("Immutable"),
|
|
112
|
+
z.object({
|
|
113
|
+
ConsensusAddressOwner: z.object({
|
|
114
|
+
owner: z.string().describe("Consensus ID owner"),
|
|
115
|
+
start_version: z.union([z.string(), z.number()]).describe("Version when object recently became consensus object"),
|
|
116
|
+
}).strict().describe("Consensus ID owner"),
|
|
117
|
+
}).strict(),
|
|
118
|
+
]).describe("Object owner");
|
|
119
|
+
const ValueTypeStringNames = [
|
|
120
|
+
"Bool", "Address", "String", "U8", "U16", "U32", "U64", "U128", "U256",
|
|
121
|
+
"VecBool", "VecAddress", "VecString", "VecU8", "VecU16", "VecU32", "VecU64", "VecU128", "VecU256", "VecVecU8"
|
|
122
|
+
];
|
|
123
|
+
export const ValueTypeUserSchema = z.union([
|
|
124
|
+
z.literal(WowValueType.Bool).describe("Bool (0)"),
|
|
125
|
+
z.literal(WowValueType.Address).describe("Address (1)"),
|
|
126
|
+
z.literal(WowValueType.String).describe("String (2)"),
|
|
127
|
+
z.literal(WowValueType.U8).describe("U8 (3)"),
|
|
128
|
+
z.literal(WowValueType.U16).describe("U16 (4)"),
|
|
129
|
+
z.literal(WowValueType.U32).describe("U32 (5)"),
|
|
130
|
+
z.literal(WowValueType.U64).describe("U64 (6)"),
|
|
131
|
+
z.literal(WowValueType.U128).describe("U128 (7)"),
|
|
132
|
+
z.literal(WowValueType.U256).describe("U256 (8)"),
|
|
133
|
+
z.literal(WowValueType.VecBool).describe("VecBool (9)"),
|
|
134
|
+
z.literal(WowValueType.VecAddress).describe("VecAddress (10)"),
|
|
135
|
+
z.literal(WowValueType.VecString).describe("VecString (11)"),
|
|
136
|
+
z.literal(WowValueType.VecU8).describe("VecU8 (12)"),
|
|
137
|
+
z.literal(WowValueType.VecU16).describe("VecU16 (13)"),
|
|
138
|
+
z.literal(WowValueType.VecU32).describe("VecU32 (14)"),
|
|
139
|
+
z.literal(WowValueType.VecU64).describe("VecU64 (15)"),
|
|
140
|
+
z.literal(WowValueType.VecU128).describe("VecU128 (16)"),
|
|
141
|
+
z.literal(WowValueType.VecU256).describe("VecU256 (17)"),
|
|
142
|
+
z.literal(WowValueType.VecVecU8).describe("VecVecU8 (18)"),
|
|
143
|
+
z.literal("Bool").describe("Bool"),
|
|
144
|
+
z.literal("Address").describe("Address"),
|
|
145
|
+
z.literal("String").describe("String"),
|
|
146
|
+
z.literal("U8").describe("U8"),
|
|
147
|
+
z.literal("U16").describe("U16"),
|
|
148
|
+
z.literal("U32").describe("U32"),
|
|
149
|
+
z.literal("U64").describe("U64"),
|
|
150
|
+
z.literal("U128").describe("U128"),
|
|
151
|
+
z.literal("U256").describe("U256"),
|
|
152
|
+
z.literal("VecBool").describe("VecBool"),
|
|
153
|
+
z.literal("VecAddress").describe("VecAddress"),
|
|
154
|
+
z.literal("VecString").describe("VecString"),
|
|
155
|
+
z.literal("VecU8").describe("VecU8"),
|
|
156
|
+
z.literal("VecU16").describe("VecU16"),
|
|
157
|
+
z.literal("VecU32").describe("VecU32"),
|
|
158
|
+
z.literal("VecU64").describe("VecU64"),
|
|
159
|
+
z.literal("VecU128").describe("VecU128"),
|
|
160
|
+
z.literal("VecU256").describe("VecU256"),
|
|
161
|
+
z.literal("VecVecU8").describe("VecVecU8"),
|
|
162
|
+
z.literal("bool").describe("bool"),
|
|
163
|
+
z.literal("address").describe("address"),
|
|
164
|
+
z.literal("string").describe("string"),
|
|
165
|
+
z.literal("u8").describe("u8"),
|
|
166
|
+
z.literal("u16").describe("u16"),
|
|
167
|
+
z.literal("u32").describe("u32"),
|
|
168
|
+
z.literal("u64").describe("u64"),
|
|
169
|
+
z.literal("u128").describe("u128"),
|
|
170
|
+
z.literal("u256").describe("u256"),
|
|
171
|
+
z.literal("vecbool").describe("vecbool"),
|
|
172
|
+
z.literal("vecaddress").describe("vecaddress"),
|
|
173
|
+
z.literal("vecstring").describe("vecstring"),
|
|
174
|
+
z.literal("vecu8").describe("vecu8"),
|
|
175
|
+
z.literal("vecu16").describe("vecu16"),
|
|
176
|
+
z.literal("vecu32").describe("vecu32"),
|
|
177
|
+
z.literal("vecu64").describe("vecu64"),
|
|
178
|
+
z.literal("vecu128").describe("vecu128"),
|
|
179
|
+
z.literal("vecu256").describe("vecu256"),
|
|
180
|
+
z.literal("vecvecu8").describe("vecvecu8"),
|
|
181
|
+
]).describe("User available value type (number or string, e.g., 6 or 'U64' or 'u64')");
|
|
182
|
+
export const ValueTypeSchema = ValueTypeUserSchema.or(z.literal(WowValueType.Value).describe("Value (19)")).or(z.literal("Value").describe("Value"))
|
|
183
|
+
.describe("Value type (number or string, e.g., 6 or 'U64')");
|
|
184
|
+
export const ObjectTypeSchema = z.enum([
|
|
185
|
+
WowObjectType.Permission,
|
|
186
|
+
WowObjectType.Repository,
|
|
187
|
+
WowObjectType.Arb,
|
|
188
|
+
WowObjectType.Arbitration,
|
|
189
|
+
WowObjectType.Service,
|
|
190
|
+
WowObjectType.Machine,
|
|
191
|
+
WowObjectType.Order,
|
|
192
|
+
WowObjectType.Progress,
|
|
193
|
+
WowObjectType.Payment,
|
|
194
|
+
WowObjectType.Treasury,
|
|
195
|
+
WowObjectType.Guard,
|
|
196
|
+
WowObjectType.Demand,
|
|
197
|
+
WowObjectType.Passport,
|
|
198
|
+
WowObjectType.Allocation,
|
|
199
|
+
WowObjectType.Resource,
|
|
200
|
+
WowObjectType.Reward,
|
|
201
|
+
WowObjectType.Discount,
|
|
202
|
+
WowObjectType.EntityRegistrar,
|
|
203
|
+
WowObjectType.EntityLinker,
|
|
204
|
+
WowObjectType.Proof,
|
|
205
|
+
WowObjectType.WReceivedObject,
|
|
206
|
+
WowObjectType.Contact,
|
|
207
|
+
WowObjectType.TableItem_ProgressHistory,
|
|
208
|
+
WowObjectType.TableItem_PermissionPerm,
|
|
209
|
+
WowObjectType.TableItem_DemandPresenter,
|
|
210
|
+
WowObjectType.TableItem_MachineNode,
|
|
211
|
+
WowObjectType.TableItem_TreasuryHistory,
|
|
212
|
+
WowObjectType.TableItem_RepositoryData,
|
|
213
|
+
WowObjectType.TableItem_RewardRecord,
|
|
214
|
+
WowObjectType.TableItem_EntityLinker,
|
|
215
|
+
WowObjectType.TableItem_AddressMark,
|
|
216
|
+
WowObjectType.TableItem_EntityRegistrar,
|
|
217
|
+
]).describe("Wowok object type");
|
|
218
|
+
export const BalanceTypeSchema = z.union([z.number(), z.string()]).describe("Balance type");
|
|
219
|
+
export const QueryIdSchema = z.number().int().min(0).describe("Query ID");
|
|
220
|
+
export const CacheExpireTypeSchema = z.union([z.number(), z.literal("INFINITE")]).describe("Cache expiration time type");
|
|
221
|
+
export const ValueContainerSchema = z.lazy(() => z.object({
|
|
222
|
+
valueType: ValueTypeSchema.describe("Value type"),
|
|
223
|
+
value: SupportedValueSchema.describe("Value"),
|
|
224
|
+
}).strict().describe("Value container with type and value"));
|
|
225
|
+
export const SupportedValueUserSchema = z.union([
|
|
226
|
+
z.boolean(),
|
|
227
|
+
z.union([AccountOrMark_AddressSchema, z.string()]),
|
|
228
|
+
z.string(),
|
|
229
|
+
z.number(),
|
|
230
|
+
z.array(z.boolean()),
|
|
231
|
+
z.union([ManyAccountOrMark_AddressSchema, z.array(z.string())]),
|
|
232
|
+
z.array(z.string()),
|
|
233
|
+
z.array(z.number()),
|
|
234
|
+
z.array(z.array(z.number())),
|
|
235
|
+
]).describe("User available supported value type");
|
|
236
|
+
export const SupportedValueSchema = SupportedValueUserSchema.or(ValueContainerSchema).describe("Supported value type");
|
|
237
|
+
export const GuardIdentifierSchema = z.number().int().min(0).max(255).describe("Identifier (0-255) for data lookup in Guard table.");
|
|
238
|
+
export const GuardTableItemBaseSchema = z.object({
|
|
239
|
+
identifier: GuardIdentifierSchema,
|
|
240
|
+
b_submission: z.boolean().describe("Whether user submission is required for this data"),
|
|
241
|
+
value_type: ValueTypeUserSchema.describe("Type of the value"),
|
|
242
|
+
value: SupportedValueUserSchema.optional().describe("The actual value data"),
|
|
243
|
+
name: z.string().default("").describe("Name or description of this data"),
|
|
244
|
+
}).strict().describe("Guard table item");
|
|
245
|
+
export const GuardTableItemSchema = GuardTableItemBaseSchema.extend({
|
|
246
|
+
object_type: ObjectTypeSchema.optional().describe("Object type when value_type is Address and represents a specific object"),
|
|
247
|
+
}).strict().describe("Guard table item");
|
|
248
|
+
export const EntrypointSchema = z.enum([
|
|
249
|
+
ENTRYPOINT.Localnet,
|
|
250
|
+
ENTRYPOINT.Testnet,
|
|
251
|
+
]).describe("Network entrypoint: Specifies which network the operation occurs on");
|
|
252
|
+
export const FaucetNetworkSchema = z.enum([
|
|
253
|
+
ENTRYPOINT.Localnet,
|
|
254
|
+
ENTRYPOINT.Testnet,
|
|
255
|
+
]).describe("Network entrypoint for Faucet: Specifies which network the operation occurs on");
|
|
256
|
+
export const ObjectBaseSchema = z.object({
|
|
257
|
+
object: z.string().describe("Object ID"),
|
|
258
|
+
type: ObjectTypeSchema.optional().describe("Object type"),
|
|
259
|
+
type_raw: z.string().optional().describe("Raw object type"),
|
|
260
|
+
owner: z.union([ObjectOwnerSchema, z.null()]).optional().describe("Object owner"),
|
|
261
|
+
version: z.string().optional().describe("Object version"),
|
|
262
|
+
previousTransaction: z.string().optional().describe("Previous transaction ID"),
|
|
263
|
+
cache_expire: CacheExpireTypeSchema.optional().describe("Cache expiration time"),
|
|
264
|
+
query_name: z.string().optional().describe("Original query name or address used to retrieve this object"),
|
|
265
|
+
_guard_node_comments: z.array(z.object({
|
|
266
|
+
type: z.string(),
|
|
267
|
+
description: z.string()
|
|
268
|
+
})).optional().describe("Additional comments for Guard node instructions"),
|
|
269
|
+
}).passthrough().describe("Object base information");
|
|
270
|
+
export const QueryEnvSchema = z.object({
|
|
271
|
+
no_cache: z.boolean().optional().describe("Whether to disable cache"),
|
|
272
|
+
network: EntrypointSchema.optional(),
|
|
273
|
+
}).strict().describe("Query environment parameters");
|
|
274
|
+
export const QueryReceivedSchema = QueryEnvSchema.extend({
|
|
275
|
+
object: z.string().describe("Object ID to query"),
|
|
276
|
+
all_type: z.boolean().optional().describe("Whether to query all types of received objects"),
|
|
277
|
+
cursor: z.union([z.string(), z.null()]).optional().describe("Pagination cursor"),
|
|
278
|
+
limit: z.union([z.number(), z.null()]).optional().describe("Number of records returned per page"),
|
|
279
|
+
}).strict().describe("Request parameters for querying object's received objects");
|
|
280
|
+
export const ReceivedBalanceObjectSchema = z.object({
|
|
281
|
+
id: z.string().describe("Received CoinWrapper object ID"),
|
|
282
|
+
balance: BalanceTypeSchema,
|
|
283
|
+
payment: z.string().describe("Payment object ID"),
|
|
284
|
+
}).strict().describe("Received CoinWrapper object record");
|
|
285
|
+
export const CoinWrapperTokenTypeSchema = z
|
|
286
|
+
.string()
|
|
287
|
+
.refine((val) => {
|
|
288
|
+
const match = val.match(/^CoinWrapper<(.+)>$/);
|
|
289
|
+
if (match) {
|
|
290
|
+
const inner = match[1];
|
|
291
|
+
if (inner === WOW_TOKEN_TYPE)
|
|
292
|
+
return true;
|
|
293
|
+
const parts = inner.split("::");
|
|
294
|
+
if (parts.length !== 3)
|
|
295
|
+
return false;
|
|
296
|
+
const [address, module, structName] = parts;
|
|
297
|
+
if (!isValidWowAddress(address))
|
|
298
|
+
return false;
|
|
299
|
+
if (!isValidMoveIdentifier(module))
|
|
300
|
+
return false;
|
|
301
|
+
if (!isValidMoveIdentifier(structName))
|
|
302
|
+
return false;
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
if (val === WOW_TOKEN_TYPE)
|
|
306
|
+
return true;
|
|
307
|
+
const parts = val.split("::");
|
|
308
|
+
if (parts.length !== 3)
|
|
309
|
+
return false;
|
|
310
|
+
const [address, module, structName] = parts;
|
|
311
|
+
if (!isValidWowAddress(address))
|
|
312
|
+
return false;
|
|
313
|
+
if (!isValidMoveIdentifier(module))
|
|
314
|
+
return false;
|
|
315
|
+
if (!isValidMoveIdentifier(structName))
|
|
316
|
+
return false;
|
|
317
|
+
return true;
|
|
318
|
+
}, {
|
|
319
|
+
message: "Invalid token type format. Expected: CoinWrapper<{address}::{module}::{struct}> or {address}::{module}::{struct}. Example: CoinWrapper<0x2::wow::WOW> or 0x2::wow::WOW"
|
|
320
|
+
})
|
|
321
|
+
.describe("Token type in format: CoinWrapper<{address}::{module}::{struct}> or {address}::{module}::{struct}. Example: CoinWrapper<0x2::wow::WOW>");
|
|
322
|
+
export const ReceivedBalanceSchema = z.object({
|
|
323
|
+
balance: BalanceTypeSchema,
|
|
324
|
+
token_type: CoinWrapperTokenTypeSchema.describe("Asset type of Coin objects. Supports CoinWrapper<...> format for order receive operations."),
|
|
325
|
+
received: z.array(ReceivedBalanceObjectSchema).describe("Received records of Coin objects"),
|
|
326
|
+
}).strict().describe("Received record of Coin objects");
|
|
327
|
+
export const ReceivedBalanceOrRecentlySchema = z.union([
|
|
328
|
+
ReceivedBalanceSchema,
|
|
329
|
+
z.literal("recently")
|
|
330
|
+
]).describe("Specified received balance record or all recently received balance record");
|
|
331
|
+
export const ReceivedNormalSchema = z.object({
|
|
332
|
+
id: z.string().nonempty().describe("Received object ID"),
|
|
333
|
+
type: z.string().nonempty().describe("Object type")
|
|
334
|
+
}).strict().describe("Received normal object record");
|
|
335
|
+
export const ReceivedObjectsOrRecentlySchema = z.union([
|
|
336
|
+
z.array(ReceivedNormalSchema),
|
|
337
|
+
ReceivedBalanceSchema,
|
|
338
|
+
z.literal("recently"),
|
|
339
|
+
]).describe("Specified received object records or all recently received object records");
|
|
340
|
+
export const QueryReceivedResultSchema = z.object({
|
|
341
|
+
result: z.union([
|
|
342
|
+
ReceivedBalanceSchema,
|
|
343
|
+
z.array(ReceivedNormalSchema),
|
|
344
|
+
]).describe("Received CoinWrapper object record or received other objects array")
|
|
345
|
+
}).strict().describe("Query received result");
|
package/dist/schema/index.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
export*from'./call/index.js';
|
|
1
|
+
export * from './call/index.js';
|
|
2
|
+
export * from './query/index.js';
|
|
3
|
+
export * from './local/index.js';
|
|
4
|
+
export * from './messenger/index.js';
|
|
5
|
+
export * from './common/index.js';
|
|
6
|
+
export * from './utils/guard-parser.js';
|
|
7
|
+
export * from './utils/node-parser.js';
|