wowok 2.2.7 → 2.2.9

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 (64) hide show
  1. package/NOTICE +4 -4
  2. package/README.md +32 -1
  3. package/THIRD_PARTY_LICENSES/MIT_LICENSE.txt +2 -2
  4. package/dist/cjs/w/call/allocation.js +1 -1
  5. package/dist/cjs/w/call/arbitration.js +1 -1
  6. package/dist/cjs/w/call/contact.js +1 -1
  7. package/dist/cjs/w/call/demand.js +1 -1
  8. package/dist/cjs/w/call/machine.js +1 -1
  9. package/dist/cjs/w/call/order.js +1 -1
  10. package/dist/cjs/w/call/permission.js +1 -1
  11. package/dist/cjs/w/call/repository.js +1 -1
  12. package/dist/cjs/w/call/reward.js +1 -1
  13. package/dist/cjs/w/call/service.js +1 -1
  14. package/dist/cjs/w/call/treasury.js +1 -1
  15. package/dist/cjs/w/local/storage.d.ts +1 -1
  16. package/dist/cjs/w/local/storage.js +1 -1
  17. package/dist/cjs/w/messenger/pq/store-adapter.d.ts +1 -1
  18. package/dist/cjs/w/messenger/storage.d.ts +1 -1
  19. package/dist/cjs/w/messenger/storage.js +1 -1
  20. package/dist/cjs/w/query/event.d.ts +2 -1
  21. package/dist/cjs/w/query/event.js +1 -1
  22. package/dist/cjs/w/query/object.d.ts +11 -0
  23. package/dist/cjs/w/query/object.js +1 -1
  24. package/dist/cjs/w/query/received.d.ts +3 -1
  25. package/dist/cjs/w/query/received.js +1 -1
  26. package/dist/esm/w/call/allocation.js +1 -1
  27. package/dist/esm/w/call/arbitration.js +1 -1
  28. package/dist/esm/w/call/contact.js +1 -1
  29. package/dist/esm/w/call/demand.js +1 -1
  30. package/dist/esm/w/call/machine.js +1 -1
  31. package/dist/esm/w/call/order.js +1 -1
  32. package/dist/esm/w/call/permission.js +1 -1
  33. package/dist/esm/w/call/repository.js +1 -1
  34. package/dist/esm/w/call/reward.js +1 -1
  35. package/dist/esm/w/call/service.js +1 -1
  36. package/dist/esm/w/call/treasury.js +1 -1
  37. package/dist/esm/w/local/storage.d.ts +1 -1
  38. package/dist/esm/w/local/storage.js +1 -1
  39. package/dist/esm/w/messenger/pq/store-adapter.d.ts +1 -1
  40. package/dist/esm/w/messenger/storage.d.ts +1 -1
  41. package/dist/esm/w/messenger/storage.js +1 -1
  42. package/dist/esm/w/query/event.d.ts +2 -1
  43. package/dist/esm/w/query/event.js +1 -1
  44. package/dist/esm/w/query/object.d.ts +11 -0
  45. package/dist/esm/w/query/object.js +1 -1
  46. package/dist/esm/w/query/received.d.ts +3 -1
  47. package/dist/esm/w/query/received.js +1 -1
  48. package/package.json +2 -15
  49. package/prebuilds/better-sqlite3-v12.9.0-node-v115-darwin-arm64.node +0 -0
  50. package/prebuilds/better-sqlite3-v12.9.0-node-v115-darwin-x64.node +0 -0
  51. package/prebuilds/better-sqlite3-v12.9.0-node-v115-linux-arm.node +0 -0
  52. package/prebuilds/better-sqlite3-v12.9.0-node-v115-linux-arm64.node +0 -0
  53. package/prebuilds/better-sqlite3-v12.9.0-node-v115-linux-x64.node +0 -0
  54. package/prebuilds/better-sqlite3-v12.9.0-node-v115-win32-arm64.node +0 -0
  55. package/prebuilds/better-sqlite3-v12.9.0-node-v115-win32-x64.node +0 -0
  56. package/prebuilds/better-sqlite3-v12.9.0-node-v127-darwin-arm64.node +0 -0
  57. package/prebuilds/better-sqlite3-v12.9.0-node-v127-darwin-x64.node +0 -0
  58. package/prebuilds/better-sqlite3-v12.9.0-node-v127-linux-arm.node +0 -0
  59. package/prebuilds/better-sqlite3-v12.9.0-node-v127-linux-arm64.node +0 -0
  60. package/prebuilds/better-sqlite3-v12.9.0-node-v127-linux-x64.node +0 -0
  61. package/prebuilds/better-sqlite3-v12.9.0-node-v127-win32-arm64.node +0 -0
  62. package/prebuilds/better-sqlite3-v12.9.0-node-v127-win32-x64.node +0 -0
  63. package/scripts/download-prebuilds.js +0 -252
  64. package/scripts/install-better-sqlite3.js +0 -377
@@ -1 +1 @@
1
- import{toTxObject,toTxU16,toTxAddress,toTxAddressVec,toTxU16Vec,MAX_DESCRIPTION_LENGTH,isValidLongName,MAX_LONG_NAME_LENGTH,GetObject,GetObjectExisted,PackageAddress,serviceFn,IsValidArgType,contactFn}from'../common.js';import{W_ERROR,WErrors}from'../exception.js';import{isValidDescription,toTxString}from'../common.js';import{CallBase}from'./base.js';import{ObjectType,query_objects}from'../query/object.js';import{GetAccountOrMark_Address,GetManyAccountOrMark_Address,LocalMark}from'../local/index.js';import{parseObjectType,permission_set}from'../util.js';import{demandFn,machineFn,treasuryFn,arbitrationFn,repositoryFn,rewardFn}from'../common.js';import{query_received}from'../query/received.js';export var BuiltinPermissionIndex;(function(a){a[a['REPOSITORY_NEW']=0x64]='REPOSITORY_NEW',a[a['REPOSITORY_DESCRIPTION']=0x65]='REPOSITORY_DESCRIPTION',a[a['REPOSITORY_POLICY']=0x66]='REPOSITORY_POLICY',a[a['REPOSITORY_REWARD']=0x67]='REPOSITORY_REWARD',a[a['REPOSITORY_OWNER_RECEIVE']=0x68]='REPOSITORY_OWNER_RECEIVE',a[a['REPOSITORY_UM']=0x69]='REPOSITORY_UM',a[a['REWARD_NEW']=0x96]='REWARD_NEW',a[a['REWARD_DESCRIPTION']=0x97]='REWARD_DESCRIPTION',a[a['REWARD_GUARD']=0x98]='REWARD_GUARD',a[a['REWARD_COIN_ADD']=0x99]='REWARD_COIN_ADD',a[a['REWARD_RECEIVE']=0x9a]='REWARD_RECEIVE',a[a['REWARD_GUARD_EXPIRATION_TIME_ADD']=0x9b]='REWARD_GUARD_EXPIRATION_TIME_ADD',a[a['REWARD_OWNER_RECEIVE']=0x9c]='REWARD_OWNER_RECEIVE',a[a['REWARD_UM']=0x9d]='REWARD_UM',a[a['MACHINE_NEW']=0xc8]='MACHINE_NEW',a[a['MACHINE_DESCRIPTION']=0xc9]='MACHINE_DESCRIPTION',a[a['MACHINE_CONSENSUS_REPOSITORIES']=0xcb]='MACHINE_CONSENSUS_REPOSITORIES',a[a['MACHINE_PAUSE']=0xcc]='MACHINE_PAUSE',a[a['MACHINE_PUBLISH']=0xcd]='MACHINE_PUBLISH',a[a['MACHINE_NODE']=0xce]='MACHINE_NODE',a[a['MACHINE_OWNER_RECEIVE']=0xcf]='MACHINE_OWNER_RECEIVE',a[a['MACHINE_UM']=0xd0]='MACHINE_UM',a[a['PROGRESS_NEW']=0xdc]='PROGRESS_NEW',a[a['PROGRESS_NAMED_OPERATOR']=0xdd]='PROGRESS_NAMED_OPERATOR',a[a['PROGRESS_TASK']=0xde]='PROGRESS_TASK',a[a['PROGRESS_CONTEXT_REPOSITORY']=0xdf]='PROGRESS_CONTEXT_REPOSITORY',a[a['PROGRESS_UNHOLD']=0xe0]='PROGRESS_UNHOLD',a[a['PROGRESS_OWNER_RECEIVE']=0xe1]='PROGRESS_OWNER_RECEIVE',a[a['TREASURY_NEW']=0xfa]='TREASURY_NEW',a[a['TREASURY_DESCRIPTION']=0xfb]='TREASURY_DESCRIPTION',a[a['TREASURY_DEPOSIT']=0xfc]='TREASURY_DEPOSIT',a[a['TREASURY_RECEIVE']=0xfd]='TREASURY_RECEIVE',a[a['TREASURY_WITHDRAW']=0xfe]='TREASURY_WITHDRAW',a[a['TREASURY_EXTERNAL_DEPOSIT']=0xff]='TREASURY_EXTERNAL_DEPOSIT',a[a['TREASURY_EXTERNAL_WITHDRAW']=0x100]='TREASURY_EXTERNAL_WITHDRAW',a[a['TREASURY_EXTERNAL_DEPOSIT_GUARD']=0x101]='TREASURY_EXTERNAL_DEPOSIT_GUARD',a[a['TREASURY_EXTERNAL_WITHDRAW_GUARD']=0x102]='TREASURY_EXTERNAL_WITHDRAW_GUARD',a[a['TREASURY_OWNER_RECEIVE']=0x103]='TREASURY_OWNER_RECEIVE',a[a['TREASURY_UM']=0x104]='TREASURY_UM',a[a['SERVICE_NEW']=0x12c]='SERVICE_NEW',a[a['SERVICE_DESCRIPTION']=0x12d]='SERVICE_DESCRIPTION',a[a['SERVICE_LOCATION']=0x12f]='SERVICE_LOCATION',a[a['SERVICE_REPOSITORY']=0x130]='SERVICE_REPOSITORY',a[a['SERVICE_SALES']=0x131]='SERVICE_SALES',a[a['SERVICE_MACHINE']=0x132]='SERVICE_MACHINE',a[a['SERVICE_BUY_GUARD']=0x133]='SERVICE_BUY_GUARD',a[a['SERVICE_ARBITRATION']=0x134]='SERVICE_ARBITRATION',a[a['SERVICE_CUSTOMER_INFO_REQUIRED']=0x135]='SERVICE_CUSTOMER_INFO_REQUIRED',a[a['SERVICE_PAUSE']=0x136]='SERVICE_PAUSE',a[a['SERVICE_PUBLISH']=0x137]='SERVICE_PUBLISH',a[a['SERVICE_DISCOUNT']=0x138]='SERVICE_DISCOUNT',a[a['SERVICE_ORDER_ALLOCATOR']=0x139]='SERVICE_ORDER_ALLOCATOR',a[a['SERVICE_COMPENSATION_FUND_WITHDRAW']=0x13a]='SERVICE_COMPENSATION_FUND_WITHDRAW',a[a['SERVICE_COMPENSATION_FUND_DEPOSIT']=0x13b]='SERVICE_COMPENSATION_FUND_DEPOSIT',a[a['SERVICE_COMPENSATION_FUND_RECEIVE']=0x13c]='SERVICE_COMPENSATION_FUND_RECEIVE',a[a['SERVICE_COMPENSATION_LOCKED_TIME_ADD']=0x13d]='SERVICE_COMPENSATION_LOCKED_TIME_ADD',a[a['SERVICE_REWARD']=0x13e]='SERVICE_REWARD',a[a['SERVICE_OWNER_RECEIVE']=0x13f]='SERVICE_OWNER_RECEIVE',a[a['SERVICE_UM']=0x140]='SERVICE_UM',a[a['ARBITRATION_NEW']=0x15e]='ARBITRATION_NEW',a[a['ARBITRATION_DESCRIPTION']=0x15f]='ARBITRATION_DESCRIPTION',a[a['ARBITRATION_LOCATION']=0x161]='ARBITRATION_LOCATION',a[a['ARBITRATION_VOTING_GUARD']=0x162]='ARBITRATION_VOTING_GUARD',a[a['ARBITRATION_USAGE_GUARD']=0x163]='ARBITRATION_USAGE_GUARD',a[a['ARBITRATION_PAUSE']=0x164]='ARBITRATION_PAUSE',a[a['ARBITRATION_FEE']=0x165]='ARBITRATION_FEE',a[a['ARBITRATION_VOTE']=0x166]='ARBITRATION_VOTE',a[a['ARBITRATION_ARBITRATION']=0x167]='ARBITRATION_ARBITRATION',a[a['ARBITRATION_FEEDBACK']=0x168]='ARBITRATION_FEEDBACK',a[a['ARBITRATION_CONFIRM']=0x169]='ARBITRATION_CONFIRM',a[a['ARBITRATION_VOTING_DEADLINE_CHANGE']=0x16a]='ARBITRATION_VOTING_DEADLINE_CHANGE',a[a['ARBITRATION_RESET']=0x16b]='ARBITRATION_RESET',a[a['ARBITRATION_ARB_WITHDRAW']=0x16c]='ARBITRATION_ARB_WITHDRAW',a[a['ARBITRATION_FEES_ALLOC']=0x16d]='ARBITRATION_FEES_ALLOC',a[a['ARBITRATION_FEES_TRANSFER']=0x16e]='ARBITRATION_FEES_TRANSFER',a[a['ARBITRATION_OWNER_RECEIVE']=0x16f]='ARBITRATION_OWNER_RECEIVE',a[a['ARBITRATION_UM']=0x170]='ARBITRATION_UM',a[a['DEMAND_NEW']=0x190]='DEMAND_NEW',a[a['DEMAND_DESCRIPTION']=0x191]='DEMAND_DESCRIPTION',a[a['DEMAND_LOCATION']=0x192]='DEMAND_LOCATION',a[a['DEMAND_GUARD']=0x194]='DEMAND_GUARD',a[a['DEMAND_REWARD']=0x195]='DEMAND_REWARD',a[a['DEMAND_FEEDBACK']=0x196]='DEMAND_FEEDBACK',a[a['DEMAND_OWNER_RECEIVE']=0x197]='DEMAND_OWNER_RECEIVE',a[a['DEMAND_UM']=0x198]='DEMAND_UM',a[a['MESSNGER_NEW']=0x1c2]='MESSNGER_NEW',a[a['MESSNGER_DESCRIPTION']=0x1c3]='MESSNGER_DESCRIPTION',a[a['MESSNGER_LOCATION']=0x1c4]='MESSNGER_LOCATION',a[a['MESSNGER_IM']=0x1c5]='MESSNGER_IM',a[a['MESSNGER_OWNER_RECEIVE']=0x1c6]='MESSNGER_OWNER_RECEIVE';}(BuiltinPermissionIndex||(BuiltinPermissionIndex={})));export const PermissionInfo=[{'index':BuiltinPermissionIndex['REPOSITORY_NEW'],'name':'repository.new','description':'Create\x20new\x20repository','object_type':ObjectType['Repository']},{'index':BuiltinPermissionIndex['REPOSITORY_DESCRIPTION'],'name':'repository.description','description':'Set\x20repository\x20description','object_type':ObjectType['Repository']},{'index':BuiltinPermissionIndex['REPOSITORY_POLICY'],'name':'repository.policy','description':'Manage\x20repository\x20policies','object_type':ObjectType['Repository']},{'index':BuiltinPermissionIndex['REPOSITORY_REWARD'],'name':'repository.reward','description':'Manage\x20repository\x20rewards','object_type':ObjectType['Repository']},{'index':BuiltinPermissionIndex['REPOSITORY_OWNER_RECEIVE'],'name':'repository.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20repository','object_type':ObjectType['Repository']},{'index':BuiltinPermissionIndex['REPOSITORY_UM'],'name':'repository.um','description':'Manage\x20repository\x20UM\x20(User\x20Manager)','object_type':ObjectType['Repository']},{'index':BuiltinPermissionIndex['REWARD_NEW'],'name':'reward.new','description':'Create\x20new\x20reward','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_DESCRIPTION'],'name':'reward.description','description':'Set\x20reward\x20description','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_GUARD'],'name':'reward.guard','description':'Manage\x20reward\x20guards','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_COIN_ADD'],'name':'reward.coin_add','description':'Add\x20coin\x20to\x20reward','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_RECEIVE'],'name':'reward.receive','description':'Receive\x20payment\x20for\x20reward','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_GUARD_EXPIRATION_TIME_ADD'],'name':'reward.guard_expiration_time_add','description':'Add\x20guard\x20expiration\x20time','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_OWNER_RECEIVE'],'name':'reward.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20reward','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_UM'],'name':'reward.um','description':'Manage\x20reward\x20UM\x20(User\x20Manager)','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['MACHINE_NEW'],'name':'machine.new','description':'Create\x20new\x20machine','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_DESCRIPTION'],'name':'machine.description','description':'Set\x20machine\x20description','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_CONSENSUS_REPOSITORIES'],'name':'machine.consensus_repositories','description':'Manage\x20machine\x20consensus\x20repositories','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_PAUSE'],'name':'machine.pause','description':'Pause\x20or\x20resume\x20machine','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_PUBLISH'],'name':'machine.publish','description':'Publish\x20machine','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_NODE'],'name':'machine.node','description':'Manage\x20machine\x20nodes','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_OWNER_RECEIVE'],'name':'machine.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20machine','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_UM'],'name':'machine.um','description':'Manage\x20machine\x20UM\x20(User\x20Manager)','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['PROGRESS_NEW'],'name':'progress.new','description':'Create\x20new\x20progress','object_type':ObjectType['Progress']},{'index':BuiltinPermissionIndex['PROGRESS_NAMED_OPERATOR'],'name':'progress.namedOperator','description':'Manage\x20progress\x20named\x20operators\x20(add,\x20remove,\x20set)','object_type':ObjectType['Progress']},{'index':BuiltinPermissionIndex['PROGRESS_TASK'],'name':'progress.task','description':'Set\x20progress\x20task','object_type':ObjectType['Progress']},{'index':BuiltinPermissionIndex['PROGRESS_CONTEXT_REPOSITORY'],'name':'progress.context_repository','description':'Manage\x20progress\x20context\x20repositories\x20(add,\x20remove,\x20clear)','object_type':ObjectType['Progress']},{'index':BuiltinPermissionIndex['PROGRESS_UNHOLD'],'name':'progress.unhold','description':'Unhold\x20progress','object_type':ObjectType['Progress']},{'index':BuiltinPermissionIndex['PROGRESS_OWNER_RECEIVE'],'name':'progress.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20progress','object_type':ObjectType['Progress']},{'index':BuiltinPermissionIndex['TREASURY_NEW'],'name':'treasury.new','description':'Create\x20new\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_DESCRIPTION'],'name':'treasury.description','description':'Set\x20treasury\x20description','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_DEPOSIT'],'name':'treasury.deposit','description':'Deposit\x20coins\x20to\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_RECEIVE'],'name':'treasury.receive','description':'Receive\x20payment\x20for\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_WITHDRAW'],'name':'treasury.withdraw','description':'Withdraw\x20coins\x20from\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_EXTERNAL_DEPOSIT'],'name':'treasury.external_deposit','description':'External\x20deposit\x20to\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_EXTERNAL_WITHDRAW'],'name':'treasury.external_withdraw','description':'External\x20withdraw\x20from\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_EXTERNAL_DEPOSIT_GUARD'],'name':'treasury.external_deposit_guard','description':'Manage\x20treasury\x20external\x20deposit\x20guards','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_EXTERNAL_WITHDRAW_GUARD'],'name':'treasury.external_withdraw_guard','description':'Manage\x20treasury\x20external\x20withdraw\x20guards','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_OWNER_RECEIVE'],'name':'treasury.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_UM'],'name':'treasury.um','description':'Manage\x20treasury\x20UM\x20(User\x20Manager)','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['SERVICE_NEW'],'name':'service.new','description':'Create\x20new\x20service','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_DESCRIPTION'],'name':'service.description','description':'Set\x20service\x20description','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_LOCATION'],'name':'service.location','description':'Set\x20service\x20location','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_REPOSITORY'],'name':'service.repository','description':'Manage\x20service\x20repositories','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_SALES'],'name':'service.sales','description':'Manage\x20service\x20sales','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_MACHINE'],'name':'service.machine','description':'Manage\x20service\x20machines','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_BUY_GUARD'],'name':'service.buy_guard','description':'Manage\x20service\x20buy\x20guards','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_ARBITRATION'],'name':'service.arbitration','description':'Manage\x20service\x20arbitrations','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_CUSTOMER_INFO_REQUIRED'],'name':'service.customer_info_required','description':'Manage\x20service\x20customer\x20info\x20requirements','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_PAUSE'],'name':'service.pause','description':'Pause\x20or\x20resume\x20service','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_PUBLISH'],'name':'service.publish','description':'Publish\x20service','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_DISCOUNT'],'name':'service.discount','description':'Manage\x20service\x20discounts','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_ORDER_ALLOCATOR'],'name':'service.order_allocator','description':'Manage\x20service\x20order\x20allocators','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_COMPENSATION_FUND_WITHDRAW'],'name':'service.compensation_fund_withdraw','description':'Withdraw\x20from\x20service\x20compensation\x20fund','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_COMPENSATION_FUND_DEPOSIT'],'name':'service.compensation_fund_deposit','description':'Deposit\x20to\x20service\x20compensation\x20fund','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_COMPENSATION_FUND_RECEIVE'],'name':'service.compensation_fund_receive','description':'Receive\x20payments\x20for\x20service\x20compensation\x20fund','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_COMPENSATION_LOCKED_TIME_ADD'],'name':'service.compensation_locked_time_add','description':'Add\x20locked\x20time\x20to\x20service\x20compensation','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_REWARD'],'name':'service.reward','description':'Manage\x20service\x20rewards','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_OWNER_RECEIVE'],'name':'service.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20service','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_UM'],'name':'service.um','description':'Manage\x20service\x20UM\x20(User\x20Manager)','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['ARBITRATION_NEW'],'name':'arbitration.new','description':'Create\x20new\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_DESCRIPTION'],'name':'arbitration.description','description':'Set\x20arbitration\x20description','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_LOCATION'],'name':'arbitration.location','description':'Set\x20arbitration\x20location','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_VOTING_GUARD'],'name':'arbitration.voting_guard','description':'Manage\x20arbitration\x20voting\x20guards','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_USAGE_GUARD'],'name':'arbitration.usage_guard','description':'Set\x20arbitration\x20usage\x20guard','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_PAUSE'],'name':'arbitration.pause','description':'Pause\x20or\x20resume\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_FEE'],'name':'arbitration.fee','description':'Set\x20arbitration\x20fee','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_VOTE'],'name':'arbitration.vote','description':'Vote\x20on\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_ARBITRATION'],'name':'arbitration.arbitration','description':'Perform\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_FEEDBACK'],'name':'arbitration.feedback','description':'Provide\x20arbitration\x20feedback','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_CONFIRM'],'name':'arbitration.confirm','description':'Confirm\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_VOTING_DEADLINE_CHANGE'],'name':'arbitration.voting_deadline_change','description':'Change\x20voting\x20deadline','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_RESET'],'name':'arbitration.reset','description':'Reset\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_ARB_WITHDRAW'],'name':'arbitration.arb_withdraw','description':'Withdraw\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_FEES_ALLOC'],'name':'arbitration.fees_alloc','description':'Allocate\x20arbitration\x20fees','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_FEES_TRANSFER'],'name':'arbitration.fees_transfer','description':'Transfer\x20arbitration\x20fees','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_OWNER_RECEIVE'],'name':'arbitration.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_UM'],'name':'arbitration.um','description':'Manage\x20arbitration\x20UM\x20(User\x20Manager)','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['DEMAND_NEW'],'name':'demand.new','description':'Create\x20new\x20demand','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_DESCRIPTION'],'name':'demand.description','description':'Set\x20demand\x20description','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_LOCATION'],'name':'demand.location','description':'Set\x20demand\x20location','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_GUARD'],'name':'demand.guard','description':'Manage\x20demand\x20guards','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_REWARD'],'name':'demand.reward','description':'Manage\x20demand\x20rewards','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_FEEDBACK'],'name':'demand.feedback','description':'Provide\x20demand\x20feedback','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_OWNER_RECEIVE'],'name':'demand.owner_receive','description':'Receive\x20objects\x20for\x20demand','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_UM'],'name':'demand.um','description':'Manage\x20demand\x20UM\x20(User\x20Manager)','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['MESSNGER_NEW'],'name':'messenger.new','description':'Create\x20new\x20messenger','object_type':ObjectType['Contact']},{'index':BuiltinPermissionIndex['MESSNGER_DESCRIPTION'],'name':'messenger.description','description':'Set\x20messenger\x20description','object_type':ObjectType['Contact']},{'index':BuiltinPermissionIndex['MESSNGER_LOCATION'],'name':'messenger.location','description':'Set\x20messenger\x20location','object_type':ObjectType['Contact']},{'index':BuiltinPermissionIndex['MESSNGER_IM'],'name':'messenger.im','description':'Manager\x20im\x20address','object_type':ObjectType['Contact']},{'index':BuiltinPermissionIndex['MESSNGER_OWNER_RECEIVE'],'name':'messenger.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20messenger','object_type':ObjectType['Contact']}];export class CallPermission extends CallBase{['data'];['object_address']=undefined;['object_data']=undefined;constructor(a){super(),this['data']=a;}async['prepare'](a){await super['prepare'](a),!this['object_address']&&(this['object_address']=await GetObjectExisted(this['data']?.['object']));}async['call'](a){await this['prepare'](a);let b=![],c=![];if(this['object_address'])return(this['data']?.['builder']!=null||this['data']?.['admin']!=null||this['data']?.['um']!==undefined)&&(b=!![]),(this['data']?.['table']!=null||this['data']?.['entity']!=null||this['data']?.['remark']!=null||this['data']?.['description']!=null)&&(c=!![]),await this['check_permission_and_call'](a,this['object_address'],[],[],b,c);return await this['exec'](a);}async['operate'](a,c,d,e){let f;this['object_address']?f=toTxObject(c,this['object_address']):f=newPermission(c,this['data']?.['description']??'');!f&&W_ERROR(WErrors['InvalidParam'],'CallPermission_Data.data.object');this['data']?.['description']!=null&&this['object_address']&&descriptionSet(c,f,this['data']['description']);if(this['data']?.['remark']!=null)switch(this['data']['remark']['op']){case'set':{const g=this['data']['remark']['index'],h=this['data']['remark']['remark'];remarkSet(c,f,g,h);break;}case'remove':{const i=this['data']['remark']['index'];remarkRemove(c,f,i);break;}case'clear':{remarkClear(c,f);break;}}if(this['data']?.['table']!=null)switch(this['data']['table']['op']){case'add\x20perm\x20by\x20index':{const j=this['data']['table']['index'],k=await GetManyAccountOrMark_Address(this['data']['table']['entity']);permAdd(c,f,j,k);break;}case'remove\x20perm\x20by\x20index':{const l=this['data']['table']['index'],m=await GetManyAccountOrMark_Address(this['data']['table']['entity']);permRemove(c,f,l,m);break;}case'set\x20perm\x20by\x20index':{const n=this['data']['table']['index'],o=await GetManyAccountOrMark_Address(this['data']['table']['entity']);permSet(c,f,n,o);break;}case'add\x20perm\x20by\x20entity':{const q=await GetAccountOrMark_Address(this['data']['table']['entity']);q&&entityAdd(c,f,q,this['data']['table']['index']);break;}case'remove\x20perm\x20by\x20entity':{const s=await GetAccountOrMark_Address(this['data']['table']['entity']);s&&entityRemove(c,f,s,this['data']['table']['index']);break;}case'set\x20perm\x20by\x20entity':{const t=await GetAccountOrMark_Address(this['data']['table']['entity']);t&&entitySet(c,f,t,this['data']['table']['index']);break;}}if(this['data']?.['entity']!=null)switch(this['data']['entity']['op']){case'swap':{const u=await GetAccountOrMark_Address(this['data']['entity']['entity1']),v=await GetAccountOrMark_Address(this['data']['entity']['entity2']);if(u&&v)entitySwap(c,f,u,v);break;}case'replace':{const w=await GetAccountOrMark_Address(this['data']['entity']['entity1']),x=await GetAccountOrMark_Address(this['data']['entity']['entity2']);if(w&&x)entityReplace(c,f,w,x);break;}case'copy':{const y=await GetAccountOrMark_Address(this['data']['entity']['entity1']),z=await GetAccountOrMark_Address(this['data']['entity']['entity2']);if(y&&z)entityCopy(c,f,y,z);break;}case'del':{const A=await GetAccountOrMark_Address(this['data']['entity']['entity']);if(A)entityDel(c,f,A);break;}}if(this['data']?.['admin']!=null){const B=await GetManyAccountOrMark_Address(this['data']['admin']['addresses']);switch(this['data']['admin']?.['op']){case'add':{adminAdd(c,f,B);break;}case'set':{adminSet(c,f,B);break;}case'remove':{adminRemove(c,f,B);break;}}}if(this['data']?.['apply']!=null&&this['data']['apply']['length']>0x0){const C=await query_objects({'objects':this['data']['apply'],'no_cache':a['no_cache'],'network':a['network']});(!C['objects']||C['objects']['length']!==this['data']['apply']['length'])&&W_ERROR(WErrors['InvalidParam'],'CallPermission_Data.data.apply\x20some\x20objects\x20not\x20found\x20'+this['data']['apply']),C['objects']?.['forEach'](D=>{switch(D['type']){case'Demand':const E=D;permission_set(c,E['object'],E['permission'],f,parseObjectType(E['type_raw'],'demand::Demand'),L=>demandFn(L));break;case'Machine':const F=D;permission_set(c,F['object'],F['permission'],f,undefined,L=>machineFn(L));break;case'Service':const G=D;permission_set(c,G['object'],G['permission'],f,parseObjectType(G['type_raw'],'service::Service'),L=>serviceFn(L));break;case'Treasury':const H=D;permission_set(c,H['object'],H['permission'],f,parseObjectType(H['type_raw'],'treasury::Treasury'),L=>treasuryFn(L));break;case'Arbitration':const I=D;permission_set(c,I['object'],I['permission'],f,parseObjectType(I['type_raw'],'arbitration::Arbitration'),L=>arbitrationFn(L));break;case'Repository':const J=D;permission_set(c,J['object'],J['permission'],f,undefined,L=>repositoryFn(L));break;case'Reward':const K=D;permission_set(c,K['object'],K['permission'],f,parseObjectType(K['type_raw'],'reward::Reward'),L=>rewardFn(L));break;}});}if(this['data']?.['builder']!=null){const D=await GetAccountOrMark_Address(this['data']['builder']);if(D)transferPermission(c,f,D);}if(this['data']['owner_receive']!=null&&this['object_address']){this['data']['owner_receive']==='recently'&&(this['data']['owner_receive']=await query_received({'object':this['object_address'],'all_type':!![]}));if(Array['isArray'](this['data']['owner_receive']))for(const E of this['data']['owner_receive']){!IsValidArgType(E['type'])&&W_ERROR(WErrors['IsValidArgType'],'Invalid\x20type:\x20'+E['type']);const F=await LocalMark['Instance']()['get_address'](E['id']);!F&&W_ERROR(WErrors['IsValidArgType'],'Received\x20'+E['id']+'\x20is\x20invalid'),ownerReceiveObject(c,f,F,E['type']);}else for(const G of this['data']['owner_receive']['received']){const [H,I]=await Promise['all']([LocalMark['Instance']()['get_address'](G['id']),LocalMark['Instance']()['get_address'](G['payment'])]);(!H||!I)&&W_ERROR(WErrors['IsValidArgType'],'Received\x20'+G['id']+'\x20or\x20Payment\x20'+G['payment']+'\x20is\x20invalid'),ownerReceive(c,f,H,I,this['data']['owner_receive']['token_type']);}}if(this['data']['um']!==undefined){let J=null;this['data']['um']&&(J=await LocalMark['Instance']()['get_address'](this['data']['um'])||null,!J&&W_ERROR(WErrors['InvalidParam'],'CallPermission_Data.data.um:'+this['data']['um'])),um_set(c,f,J);}!this['object_address']&&await this['new_with_mark'](a,c,ObjectType['Permission'],create(c,f),GetObject(this['data']?.['object']));}}export function permissionFn(a){return PackageAddress+'::permission::'+a;}export const MAX_ENTITY_COUNT=0x3e8;export const MAX_PERM_FOR_ENTITY=0x3e8;export const MAX_ADMIN_COUNT=0x1f4;export const USER_DEFINED_PERM_INDEX_START=0x3e8;export function isBizPermIndex(a){return a>=USER_DEFINED_PERM_INDEX_START;}export function newPermission(a,b){return typeof b==='string'&&!isValidDescription(b)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),a['moveCall']({'target':permissionFn('new'),'arguments':[toTxString(a,b)]});}export function create(a,b){return a['moveCall']({'target':permissionFn('create'),'arguments':[toTxObject(a,b)]});}export function descriptionSet(a,b,c){typeof c==='string'&&!isValidDescription(c)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),a['moveCall']({'target':permissionFn('description_set'),'arguments':[toTxObject(a,b),toTxString(a,c)]});}export function remarkSet(a,b,c,d){typeof d==='string'&&!isValidLongName(d)&&W_ERROR(WErrors['IsValidDescription'],'Remark\x20exceeds\x20maximum\x20length\x20'+MAX_LONG_NAME_LENGTH),a['moveCall']({'target':permissionFn('remark_set'),'arguments':[toTxObject(a,b),toTxU16(a,c),toTxString(a,d)]});}export function remarkRemove(a,b,c){a['moveCall']({'target':permissionFn('remark_remove'),'arguments':[toTxObject(a,b),toTxU16(a,c)]});}export function remarkClear(a,b){a['moveCall']({'target':permissionFn('remark_clear'),'arguments':[toTxObject(a,b)]});}export function permAdd(a,b,c,d){a['moveCall']({'target':permissionFn('perm_add'),'arguments':[toTxObject(a,b),toTxU16(a,c),toTxAddressVec(a,d,MAX_ENTITY_COUNT),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function permRemove(a,b,c,d){a['moveCall']({'target':permissionFn('perm_remove'),'arguments':[toTxObject(a,b),toTxU16(a,c),toTxAddressVec(a,d,MAX_ENTITY_COUNT)]});}export function permSet(a,b,c,d){a['moveCall']({'target':permissionFn('perm_set'),'arguments':[toTxObject(a,b),toTxU16(a,c),toTxAddressVec(a,d,MAX_ENTITY_COUNT),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function entityAdd(a,b,c,d){a['moveCall']({'target':permissionFn('entity_add'),'arguments':[toTxObject(a,b),toTxAddress(a,c),toTxU16Vec(a,d,MAX_PERM_FOR_ENTITY),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function entityRemove(a,b,c,d){a['moveCall']({'target':permissionFn('entity_remove'),'arguments':[toTxObject(a,b),toTxAddress(a,c),toTxU16Vec(a,d,MAX_PERM_FOR_ENTITY)]});}export function entitySet(a,b,c,d){a['moveCall']({'target':permissionFn('entity_set'),'arguments':[toTxObject(a,b),toTxAddress(a,c),toTxU16Vec(a,d,MAX_PERM_FOR_ENTITY),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function entitySwap(a,b,c,d){a['moveCall']({'target':permissionFn('entity_swap'),'arguments':[toTxObject(a,b),toTxAddress(a,c),toTxAddress(a,d),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function entityReplace(a,b,c,d){a['moveCall']({'target':permissionFn('entity_replace'),'arguments':[toTxObject(a,b),toTxAddress(a,c),toTxAddress(a,d),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function entityDel(a,b,c){a['moveCall']({'target':permissionFn('entity_del'),'arguments':[toTxObject(a,b),toTxAddress(a,c),a['object']['mutRegistrar']()]});}export function entityCopy(a,b,c,d){a['moveCall']({'target':permissionFn('entity_copy'),'arguments':[toTxObject(a,b),toTxAddress(a,c),toTxAddress(a,d),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function adminAdd(a,b,c){a['moveCall']({'target':permissionFn('admin_add'),'arguments':[toTxObject(a,b),toTxAddressVec(a,c,MAX_ADMIN_COUNT)]});}export function adminRemove(a,b,c){a['moveCall']({'target':permissionFn('admin_remove'),'arguments':[toTxObject(a,b),toTxAddressVec(a,c,MAX_ADMIN_COUNT)]});}export function adminSet(a,b,c){a['moveCall']({'target':permissionFn('admin_set'),'arguments':[toTxObject(a,b),toTxAddressVec(a,c,MAX_ADMIN_COUNT)]});}export function transferPermission(a,b,c){a['moveCall']({'target':permissionFn('transfer'),'arguments':[toTxObject(a,b),toTxAddress(a,c)]});}export function um_set(a,b,c){c?a['moveCall']({'target':contactFn('permission_um_set'),'arguments':[toTxObject(a,c),toTxObject(a,b),a['object']['mutRegistrar'](),a['object']['clock']()]}):a['moveCall']({'target':permissionFn('um_none'),'arguments':[toTxObject(a,b),a['object']['mutRegistrar']()]});}export function ownerReceiveObject(a,b,c,d){a['moveCall']({'target':permissionFn('owner_receive_object'),'arguments':[toTxObject(a,b),toTxObject(a,c)],'typeArguments':[d]});}export function ownerReceive(a,b,c,d,e){a['moveCall']({'target':permissionFn('owner_receive'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,d)],'typeArguments':[e]});}export function query_permissions(a){if(!a)return PermissionInfo;return PermissionInfo['filter'](b=>{if(a['objectType']&&b['object_type']!==a['objectType'])return![];if(a['name']&&!b['name']['includes'](a['name']))return![];if(a['index']!==undefined&&b['index']!==a['index'])return![];if(a['description']&&!b['description']['includes'](a['description']))return![];return!![];});}
1
+ import{toTxObject,toTxU16,toTxAddress,toTxAddressVec,toTxU16Vec,MAX_DESCRIPTION_LENGTH,isValidLongName,MAX_LONG_NAME_LENGTH,GetObject,GetObjectExisted,PackageAddress,serviceFn,IsValidArgType,contactFn}from'../common.js';import{W_ERROR,WErrors}from'../exception.js';import{isValidDescription,toTxString}from'../common.js';import{CallBase}from'./base.js';import{ObjectType,query_objects}from'../query/object.js';import{GetAccountOrMark_Address,GetManyAccountOrMark_Address,LocalMark}from'../local/index.js';import{parseObjectType,permission_set}from'../util.js';import{demandFn,machineFn,treasuryFn,arbitrationFn,repositoryFn,rewardFn}from'../common.js';import{query_received}from'../query/received.js';export var BuiltinPermissionIndex;(function(a){a[a['REPOSITORY_NEW']=0x64]='REPOSITORY_NEW',a[a['REPOSITORY_DESCRIPTION']=0x65]='REPOSITORY_DESCRIPTION',a[a['REPOSITORY_POLICY']=0x66]='REPOSITORY_POLICY',a[a['REPOSITORY_REWARD']=0x67]='REPOSITORY_REWARD',a[a['REPOSITORY_OWNER_RECEIVE']=0x68]='REPOSITORY_OWNER_RECEIVE',a[a['REPOSITORY_UM']=0x69]='REPOSITORY_UM',a[a['REWARD_NEW']=0x96]='REWARD_NEW',a[a['REWARD_DESCRIPTION']=0x97]='REWARD_DESCRIPTION',a[a['REWARD_GUARD']=0x98]='REWARD_GUARD',a[a['REWARD_COIN_ADD']=0x99]='REWARD_COIN_ADD',a[a['REWARD_RECEIVE']=0x9a]='REWARD_RECEIVE',a[a['REWARD_GUARD_EXPIRATION_TIME_ADD']=0x9b]='REWARD_GUARD_EXPIRATION_TIME_ADD',a[a['REWARD_OWNER_RECEIVE']=0x9c]='REWARD_OWNER_RECEIVE',a[a['REWARD_UM']=0x9d]='REWARD_UM',a[a['MACHINE_NEW']=0xc8]='MACHINE_NEW',a[a['MACHINE_DESCRIPTION']=0xc9]='MACHINE_DESCRIPTION',a[a['MACHINE_CONSENSUS_REPOSITORIES']=0xcb]='MACHINE_CONSENSUS_REPOSITORIES',a[a['MACHINE_PAUSE']=0xcc]='MACHINE_PAUSE',a[a['MACHINE_PUBLISH']=0xcd]='MACHINE_PUBLISH',a[a['MACHINE_NODE']=0xce]='MACHINE_NODE',a[a['MACHINE_OWNER_RECEIVE']=0xcf]='MACHINE_OWNER_RECEIVE',a[a['MACHINE_UM']=0xd0]='MACHINE_UM',a[a['PROGRESS_NEW']=0xdc]='PROGRESS_NEW',a[a['PROGRESS_NAMED_OPERATOR']=0xdd]='PROGRESS_NAMED_OPERATOR',a[a['PROGRESS_TASK']=0xde]='PROGRESS_TASK',a[a['PROGRESS_CONTEXT_REPOSITORY']=0xdf]='PROGRESS_CONTEXT_REPOSITORY',a[a['PROGRESS_UNHOLD']=0xe0]='PROGRESS_UNHOLD',a[a['PROGRESS_OWNER_RECEIVE']=0xe1]='PROGRESS_OWNER_RECEIVE',a[a['TREASURY_NEW']=0xfa]='TREASURY_NEW',a[a['TREASURY_DESCRIPTION']=0xfb]='TREASURY_DESCRIPTION',a[a['TREASURY_DEPOSIT']=0xfc]='TREASURY_DEPOSIT',a[a['TREASURY_RECEIVE']=0xfd]='TREASURY_RECEIVE',a[a['TREASURY_WITHDRAW']=0xfe]='TREASURY_WITHDRAW',a[a['TREASURY_EXTERNAL_DEPOSIT']=0xff]='TREASURY_EXTERNAL_DEPOSIT',a[a['TREASURY_EXTERNAL_WITHDRAW']=0x100]='TREASURY_EXTERNAL_WITHDRAW',a[a['TREASURY_EXTERNAL_DEPOSIT_GUARD']=0x101]='TREASURY_EXTERNAL_DEPOSIT_GUARD',a[a['TREASURY_EXTERNAL_WITHDRAW_GUARD']=0x102]='TREASURY_EXTERNAL_WITHDRAW_GUARD',a[a['TREASURY_OWNER_RECEIVE']=0x103]='TREASURY_OWNER_RECEIVE',a[a['TREASURY_UM']=0x104]='TREASURY_UM',a[a['SERVICE_NEW']=0x12c]='SERVICE_NEW',a[a['SERVICE_DESCRIPTION']=0x12d]='SERVICE_DESCRIPTION',a[a['SERVICE_LOCATION']=0x12f]='SERVICE_LOCATION',a[a['SERVICE_REPOSITORY']=0x130]='SERVICE_REPOSITORY',a[a['SERVICE_SALES']=0x131]='SERVICE_SALES',a[a['SERVICE_MACHINE']=0x132]='SERVICE_MACHINE',a[a['SERVICE_BUY_GUARD']=0x133]='SERVICE_BUY_GUARD',a[a['SERVICE_ARBITRATION']=0x134]='SERVICE_ARBITRATION',a[a['SERVICE_CUSTOMER_INFO_REQUIRED']=0x135]='SERVICE_CUSTOMER_INFO_REQUIRED',a[a['SERVICE_PAUSE']=0x136]='SERVICE_PAUSE',a[a['SERVICE_PUBLISH']=0x137]='SERVICE_PUBLISH',a[a['SERVICE_DISCOUNT']=0x138]='SERVICE_DISCOUNT',a[a['SERVICE_ORDER_ALLOCATOR']=0x139]='SERVICE_ORDER_ALLOCATOR',a[a['SERVICE_COMPENSATION_FUND_WITHDRAW']=0x13a]='SERVICE_COMPENSATION_FUND_WITHDRAW',a[a['SERVICE_COMPENSATION_FUND_DEPOSIT']=0x13b]='SERVICE_COMPENSATION_FUND_DEPOSIT',a[a['SERVICE_COMPENSATION_FUND_RECEIVE']=0x13c]='SERVICE_COMPENSATION_FUND_RECEIVE',a[a['SERVICE_COMPENSATION_LOCKED_TIME_ADD']=0x13d]='SERVICE_COMPENSATION_LOCKED_TIME_ADD',a[a['SERVICE_REWARD']=0x13e]='SERVICE_REWARD',a[a['SERVICE_OWNER_RECEIVE']=0x13f]='SERVICE_OWNER_RECEIVE',a[a['SERVICE_UM']=0x140]='SERVICE_UM',a[a['ARBITRATION_NEW']=0x15e]='ARBITRATION_NEW',a[a['ARBITRATION_DESCRIPTION']=0x15f]='ARBITRATION_DESCRIPTION',a[a['ARBITRATION_LOCATION']=0x161]='ARBITRATION_LOCATION',a[a['ARBITRATION_VOTING_GUARD']=0x162]='ARBITRATION_VOTING_GUARD',a[a['ARBITRATION_USAGE_GUARD']=0x163]='ARBITRATION_USAGE_GUARD',a[a['ARBITRATION_PAUSE']=0x164]='ARBITRATION_PAUSE',a[a['ARBITRATION_FEE']=0x165]='ARBITRATION_FEE',a[a['ARBITRATION_VOTE']=0x166]='ARBITRATION_VOTE',a[a['ARBITRATION_ARBITRATION']=0x167]='ARBITRATION_ARBITRATION',a[a['ARBITRATION_FEEDBACK']=0x168]='ARBITRATION_FEEDBACK',a[a['ARBITRATION_CONFIRM']=0x169]='ARBITRATION_CONFIRM',a[a['ARBITRATION_VOTING_DEADLINE_CHANGE']=0x16a]='ARBITRATION_VOTING_DEADLINE_CHANGE',a[a['ARBITRATION_RESET']=0x16b]='ARBITRATION_RESET',a[a['ARBITRATION_ARB_WITHDRAW']=0x16c]='ARBITRATION_ARB_WITHDRAW',a[a['ARBITRATION_FEES_ALLOC']=0x16d]='ARBITRATION_FEES_ALLOC',a[a['ARBITRATION_FEES_TRANSFER']=0x16e]='ARBITRATION_FEES_TRANSFER',a[a['ARBITRATION_OWNER_RECEIVE']=0x16f]='ARBITRATION_OWNER_RECEIVE',a[a['ARBITRATION_UM']=0x170]='ARBITRATION_UM',a[a['DEMAND_NEW']=0x190]='DEMAND_NEW',a[a['DEMAND_DESCRIPTION']=0x191]='DEMAND_DESCRIPTION',a[a['DEMAND_LOCATION']=0x192]='DEMAND_LOCATION',a[a['DEMAND_GUARD']=0x194]='DEMAND_GUARD',a[a['DEMAND_REWARD']=0x195]='DEMAND_REWARD',a[a['DEMAND_FEEDBACK']=0x196]='DEMAND_FEEDBACK',a[a['DEMAND_OWNER_RECEIVE']=0x197]='DEMAND_OWNER_RECEIVE',a[a['DEMAND_UM']=0x198]='DEMAND_UM',a[a['MESSNGER_NEW']=0x1c2]='MESSNGER_NEW',a[a['MESSNGER_DESCRIPTION']=0x1c3]='MESSNGER_DESCRIPTION',a[a['MESSNGER_LOCATION']=0x1c4]='MESSNGER_LOCATION',a[a['MESSNGER_IM']=0x1c5]='MESSNGER_IM',a[a['MESSNGER_OWNER_RECEIVE']=0x1c6]='MESSNGER_OWNER_RECEIVE';}(BuiltinPermissionIndex||(BuiltinPermissionIndex={})));export const PermissionInfo=[{'index':BuiltinPermissionIndex['REPOSITORY_NEW'],'name':'repository.new','description':'Create\x20new\x20repository','object_type':ObjectType['Repository']},{'index':BuiltinPermissionIndex['REPOSITORY_DESCRIPTION'],'name':'repository.description','description':'Set\x20repository\x20description','object_type':ObjectType['Repository']},{'index':BuiltinPermissionIndex['REPOSITORY_POLICY'],'name':'repository.policy','description':'Manage\x20repository\x20policies','object_type':ObjectType['Repository']},{'index':BuiltinPermissionIndex['REPOSITORY_REWARD'],'name':'repository.reward','description':'Manage\x20repository\x20rewards','object_type':ObjectType['Repository']},{'index':BuiltinPermissionIndex['REPOSITORY_OWNER_RECEIVE'],'name':'repository.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20repository','object_type':ObjectType['Repository']},{'index':BuiltinPermissionIndex['REPOSITORY_UM'],'name':'repository.um','description':'Manage\x20repository\x20UM\x20(User\x20Manager)','object_type':ObjectType['Repository']},{'index':BuiltinPermissionIndex['REWARD_NEW'],'name':'reward.new','description':'Create\x20new\x20reward','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_DESCRIPTION'],'name':'reward.description','description':'Set\x20reward\x20description','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_GUARD'],'name':'reward.guard','description':'Manage\x20reward\x20guards','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_COIN_ADD'],'name':'reward.coin_add','description':'Add\x20coin\x20to\x20reward','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_RECEIVE'],'name':'reward.receive','description':'Receive\x20payment\x20for\x20reward','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_GUARD_EXPIRATION_TIME_ADD'],'name':'reward.guard_expiration_time_add','description':'Add\x20guard\x20expiration\x20time','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_OWNER_RECEIVE'],'name':'reward.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20reward','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['REWARD_UM'],'name':'reward.um','description':'Manage\x20reward\x20UM\x20(User\x20Manager)','object_type':ObjectType['Reward']},{'index':BuiltinPermissionIndex['MACHINE_NEW'],'name':'machine.new','description':'Create\x20new\x20machine','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_DESCRIPTION'],'name':'machine.description','description':'Set\x20machine\x20description','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_CONSENSUS_REPOSITORIES'],'name':'machine.consensus_repositories','description':'Manage\x20machine\x20consensus\x20repositories','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_PAUSE'],'name':'machine.pause','description':'Pause\x20or\x20resume\x20machine','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_PUBLISH'],'name':'machine.publish','description':'Publish\x20machine','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_NODE'],'name':'machine.node','description':'Manage\x20machine\x20nodes','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_OWNER_RECEIVE'],'name':'machine.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20machine','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['MACHINE_UM'],'name':'machine.um','description':'Manage\x20machine\x20UM\x20(User\x20Manager)','object_type':ObjectType['Machine']},{'index':BuiltinPermissionIndex['PROGRESS_NEW'],'name':'progress.new','description':'Create\x20new\x20progress','object_type':ObjectType['Progress']},{'index':BuiltinPermissionIndex['PROGRESS_NAMED_OPERATOR'],'name':'progress.namedOperator','description':'Manage\x20progress\x20named\x20operators\x20(add,\x20remove,\x20set)','object_type':ObjectType['Progress']},{'index':BuiltinPermissionIndex['PROGRESS_TASK'],'name':'progress.task','description':'Set\x20progress\x20task','object_type':ObjectType['Progress']},{'index':BuiltinPermissionIndex['PROGRESS_CONTEXT_REPOSITORY'],'name':'progress.context_repository','description':'Manage\x20progress\x20context\x20repositories\x20(add,\x20remove,\x20clear)','object_type':ObjectType['Progress']},{'index':BuiltinPermissionIndex['PROGRESS_UNHOLD'],'name':'progress.unhold','description':'Unhold\x20progress','object_type':ObjectType['Progress']},{'index':BuiltinPermissionIndex['PROGRESS_OWNER_RECEIVE'],'name':'progress.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20progress','object_type':ObjectType['Progress']},{'index':BuiltinPermissionIndex['TREASURY_NEW'],'name':'treasury.new','description':'Create\x20new\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_DESCRIPTION'],'name':'treasury.description','description':'Set\x20treasury\x20description','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_DEPOSIT'],'name':'treasury.deposit','description':'Deposit\x20coins\x20to\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_RECEIVE'],'name':'treasury.receive','description':'Receive\x20payment\x20for\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_WITHDRAW'],'name':'treasury.withdraw','description':'Withdraw\x20coins\x20from\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_EXTERNAL_DEPOSIT'],'name':'treasury.external_deposit','description':'External\x20deposit\x20to\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_EXTERNAL_WITHDRAW'],'name':'treasury.external_withdraw','description':'External\x20withdraw\x20from\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_EXTERNAL_DEPOSIT_GUARD'],'name':'treasury.external_deposit_guard','description':'Manage\x20treasury\x20external\x20deposit\x20guards','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_EXTERNAL_WITHDRAW_GUARD'],'name':'treasury.external_withdraw_guard','description':'Manage\x20treasury\x20external\x20withdraw\x20guards','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_OWNER_RECEIVE'],'name':'treasury.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20treasury','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['TREASURY_UM'],'name':'treasury.um','description':'Manage\x20treasury\x20UM\x20(User\x20Manager)','object_type':ObjectType['Treasury']},{'index':BuiltinPermissionIndex['SERVICE_NEW'],'name':'service.new','description':'Create\x20new\x20service','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_DESCRIPTION'],'name':'service.description','description':'Set\x20service\x20description','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_LOCATION'],'name':'service.location','description':'Set\x20service\x20location','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_REPOSITORY'],'name':'service.repository','description':'Manage\x20service\x20repositories','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_SALES'],'name':'service.sales','description':'Manage\x20service\x20sales','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_MACHINE'],'name':'service.machine','description':'Manage\x20service\x20machines','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_BUY_GUARD'],'name':'service.buy_guard','description':'Manage\x20service\x20buy\x20guards','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_ARBITRATION'],'name':'service.arbitration','description':'Manage\x20service\x20arbitrations','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_CUSTOMER_INFO_REQUIRED'],'name':'service.customer_info_required','description':'Manage\x20service\x20customer\x20info\x20requirements','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_PAUSE'],'name':'service.pause','description':'Pause\x20or\x20resume\x20service','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_PUBLISH'],'name':'service.publish','description':'Publish\x20service','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_DISCOUNT'],'name':'service.discount','description':'Manage\x20service\x20discounts','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_ORDER_ALLOCATOR'],'name':'service.order_allocator','description':'Manage\x20service\x20order\x20allocators','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_COMPENSATION_FUND_WITHDRAW'],'name':'service.compensation_fund_withdraw','description':'Withdraw\x20from\x20service\x20compensation\x20fund','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_COMPENSATION_FUND_DEPOSIT'],'name':'service.compensation_fund_deposit','description':'Deposit\x20to\x20service\x20compensation\x20fund','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_COMPENSATION_FUND_RECEIVE'],'name':'service.compensation_fund_receive','description':'Receive\x20payments\x20for\x20service\x20compensation\x20fund','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_COMPENSATION_LOCKED_TIME_ADD'],'name':'service.compensation_locked_time_add','description':'Add\x20locked\x20time\x20to\x20service\x20compensation','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_REWARD'],'name':'service.reward','description':'Manage\x20service\x20rewards','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_OWNER_RECEIVE'],'name':'service.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20service','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['SERVICE_UM'],'name':'service.um','description':'Manage\x20service\x20UM\x20(User\x20Manager)','object_type':ObjectType['Service']},{'index':BuiltinPermissionIndex['ARBITRATION_NEW'],'name':'arbitration.new','description':'Create\x20new\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_DESCRIPTION'],'name':'arbitration.description','description':'Set\x20arbitration\x20description','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_LOCATION'],'name':'arbitration.location','description':'Set\x20arbitration\x20location','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_VOTING_GUARD'],'name':'arbitration.voting_guard','description':'Manage\x20arbitration\x20voting\x20guards','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_USAGE_GUARD'],'name':'arbitration.usage_guard','description':'Set\x20arbitration\x20usage\x20guard','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_PAUSE'],'name':'arbitration.pause','description':'Pause\x20or\x20resume\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_FEE'],'name':'arbitration.fee','description':'Set\x20arbitration\x20fee','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_VOTE'],'name':'arbitration.vote','description':'Vote\x20on\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_ARBITRATION'],'name':'arbitration.arbitration','description':'Perform\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_FEEDBACK'],'name':'arbitration.feedback','description':'Provide\x20arbitration\x20feedback','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_CONFIRM'],'name':'arbitration.confirm','description':'Confirm\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_VOTING_DEADLINE_CHANGE'],'name':'arbitration.voting_deadline_change','description':'Change\x20voting\x20deadline','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_RESET'],'name':'arbitration.reset','description':'Reset\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_ARB_WITHDRAW'],'name':'arbitration.arb_withdraw','description':'Withdraw\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_FEES_ALLOC'],'name':'arbitration.fees_alloc','description':'Allocate\x20arbitration\x20fees','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_FEES_TRANSFER'],'name':'arbitration.fees_transfer','description':'Transfer\x20arbitration\x20fees','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_OWNER_RECEIVE'],'name':'arbitration.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20arbitration','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['ARBITRATION_UM'],'name':'arbitration.um','description':'Manage\x20arbitration\x20UM\x20(User\x20Manager)','object_type':ObjectType['Arbitration']},{'index':BuiltinPermissionIndex['DEMAND_NEW'],'name':'demand.new','description':'Create\x20new\x20demand','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_DESCRIPTION'],'name':'demand.description','description':'Set\x20demand\x20description','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_LOCATION'],'name':'demand.location','description':'Set\x20demand\x20location','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_GUARD'],'name':'demand.guard','description':'Manage\x20demand\x20guards','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_REWARD'],'name':'demand.reward','description':'Manage\x20demand\x20rewards','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_FEEDBACK'],'name':'demand.feedback','description':'Provide\x20demand\x20feedback','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_OWNER_RECEIVE'],'name':'demand.owner_receive','description':'Receive\x20objects\x20for\x20demand','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['DEMAND_UM'],'name':'demand.um','description':'Manage\x20demand\x20UM\x20(User\x20Manager)','object_type':ObjectType['Demand']},{'index':BuiltinPermissionIndex['MESSNGER_NEW'],'name':'messenger.new','description':'Create\x20new\x20messenger','object_type':ObjectType['Contact']},{'index':BuiltinPermissionIndex['MESSNGER_DESCRIPTION'],'name':'messenger.description','description':'Set\x20messenger\x20description','object_type':ObjectType['Contact']},{'index':BuiltinPermissionIndex['MESSNGER_LOCATION'],'name':'messenger.location','description':'Set\x20messenger\x20location','object_type':ObjectType['Contact']},{'index':BuiltinPermissionIndex['MESSNGER_IM'],'name':'messenger.im','description':'Manager\x20im\x20address','object_type':ObjectType['Contact']},{'index':BuiltinPermissionIndex['MESSNGER_OWNER_RECEIVE'],'name':'messenger.owner_receive','description':'Receive\x20objects\x20or\x20payments\x20for\x20messenger','object_type':ObjectType['Contact']}];export class CallPermission extends CallBase{['data'];['object_address']=undefined;['object_data']=undefined;constructor(a){super(),this['data']=a;}async['prepare'](a){await super['prepare'](a),!this['object_address']&&(this['object_address']=await GetObjectExisted(this['data']?.['object']));}async['call'](a){await this['prepare'](a);let b=![],c=![];if(this['object_address'])return(this['data']?.['builder']!=null||this['data']?.['admin']!=null||this['data']?.['um']!==undefined)&&(b=!![]),(this['data']?.['table']!=null||this['data']?.['entity']!=null||this['data']?.['remark']!=null||this['data']?.['description']!=null)&&(c=!![]),await this['check_permission_and_call'](a,this['object_address'],[],[],b,c);return await this['exec'](a);}async['operate'](a,c,d,e){let f;this['object_address']?f=toTxObject(c,this['object_address']):f=newPermission(c,this['data']?.['description']??'');!f&&W_ERROR(WErrors['InvalidParam'],'CallPermission_Data.data.object');this['data']?.['description']!=null&&this['object_address']&&descriptionSet(c,f,this['data']['description']);if(this['data']?.['remark']!=null)switch(this['data']['remark']['op']){case'set':{const g=this['data']['remark']['index'],h=this['data']['remark']['remark'];remarkSet(c,f,g,h);break;}case'remove':{const i=this['data']['remark']['index'];remarkRemove(c,f,i);break;}case'clear':{remarkClear(c,f);break;}}if(this['data']?.['table']!=null)switch(this['data']['table']['op']){case'add\x20perm\x20by\x20index':{const j=this['data']['table']['index'],k=await GetManyAccountOrMark_Address(this['data']['table']['entity']);permAdd(c,f,j,k);break;}case'remove\x20perm\x20by\x20index':{const l=this['data']['table']['index'],m=await GetManyAccountOrMark_Address(this['data']['table']['entity']);permRemove(c,f,l,m);break;}case'set\x20perm\x20by\x20index':{const n=this['data']['table']['index'],o=await GetManyAccountOrMark_Address(this['data']['table']['entity']);permSet(c,f,n,o);break;}case'add\x20perm\x20by\x20entity':{const q=await GetAccountOrMark_Address(this['data']['table']['entity']);q&&entityAdd(c,f,q,this['data']['table']['index']);break;}case'remove\x20perm\x20by\x20entity':{const s=await GetAccountOrMark_Address(this['data']['table']['entity']);s&&entityRemove(c,f,s,this['data']['table']['index']);break;}case'set\x20perm\x20by\x20entity':{const t=await GetAccountOrMark_Address(this['data']['table']['entity']);t&&entitySet(c,f,t,this['data']['table']['index']);break;}}if(this['data']?.['entity']!=null)switch(this['data']['entity']['op']){case'swap':{const u=await GetAccountOrMark_Address(this['data']['entity']['entity1']),v=await GetAccountOrMark_Address(this['data']['entity']['entity2']);if(u&&v)entitySwap(c,f,u,v);break;}case'replace':{const w=await GetAccountOrMark_Address(this['data']['entity']['entity1']),x=await GetAccountOrMark_Address(this['data']['entity']['entity2']);if(w&&x)entityReplace(c,f,w,x);break;}case'copy':{const y=await GetAccountOrMark_Address(this['data']['entity']['entity1']),z=await GetAccountOrMark_Address(this['data']['entity']['entity2']);if(y&&z)entityCopy(c,f,y,z);break;}case'del':{const A=await GetAccountOrMark_Address(this['data']['entity']['entity']);if(A)entityDel(c,f,A);break;}}if(this['data']?.['admin']!=null){const B=await GetManyAccountOrMark_Address(this['data']['admin']['addresses']);switch(this['data']['admin']?.['op']){case'add':{adminAdd(c,f,B);break;}case'set':{adminSet(c,f,B);break;}case'remove':{adminRemove(c,f,B);break;}}}if(this['data']?.['apply']!=null&&this['data']['apply']['length']>0x0){const C=await query_objects({'objects':this['data']['apply'],'no_cache':a['no_cache'],'network':a['network']});(!C['objects']||C['objects']['length']!==this['data']['apply']['length'])&&W_ERROR(WErrors['InvalidParam'],'CallPermission_Data.data.apply\x20some\x20objects\x20not\x20found\x20'+this['data']['apply']),C['objects']?.['forEach'](D=>{switch(D['type']){case'Demand':const E=D;permission_set(c,E['object'],E['permission'],f,parseObjectType(E['type_raw'],'demand::Demand'),L=>demandFn(L));break;case'Machine':const F=D;permission_set(c,F['object'],F['permission'],f,undefined,L=>machineFn(L));break;case'Service':const G=D;permission_set(c,G['object'],G['permission'],f,parseObjectType(G['type_raw'],'service::Service'),L=>serviceFn(L));break;case'Treasury':const H=D;permission_set(c,H['object'],H['permission'],f,parseObjectType(H['type_raw'],'treasury::Treasury'),L=>treasuryFn(L));break;case'Arbitration':const I=D;permission_set(c,I['object'],I['permission'],f,parseObjectType(I['type_raw'],'arbitration::Arbitration'),L=>arbitrationFn(L));break;case'Repository':const J=D;permission_set(c,J['object'],J['permission'],f,undefined,L=>repositoryFn(L));break;case'Reward':const K=D;permission_set(c,K['object'],K['permission'],f,parseObjectType(K['type_raw'],'reward::Reward'),L=>rewardFn(L));break;}});}if(this['data']?.['builder']!=null){const D=await GetAccountOrMark_Address(this['data']['builder']);if(D)transferPermission(c,f,D);}if(this['data']['owner_receive']!=null&&this['object_address']){this['data']['owner_receive']==='recently'&&(this['data']['owner_receive']=await query_received({'name_or_address':{'name_or_address':this['object_address'],'local_mark_first':!![]},'all_type':!![],'no_cache':a['no_cache'],'network':a['network']}));if(Array['isArray'](this['data']['owner_receive']))for(const E of this['data']['owner_receive']){!IsValidArgType(E['type'])&&W_ERROR(WErrors['IsValidArgType'],'Invalid\x20type:\x20'+E['type']);const F=await LocalMark['Instance']()['get_address'](E['id']);!F&&W_ERROR(WErrors['IsValidArgType'],'Received\x20'+E['id']+'\x20is\x20invalid'),ownerReceiveObject(c,f,F,E['type']);}else for(const G of this['data']['owner_receive']['received']){const [H,I]=await Promise['all']([LocalMark['Instance']()['get_address'](G['id']),LocalMark['Instance']()['get_address'](G['payment'])]);(!H||!I)&&W_ERROR(WErrors['IsValidArgType'],'Received\x20'+G['id']+'\x20or\x20Payment\x20'+G['payment']+'\x20is\x20invalid'),ownerReceive(c,f,H,I,this['data']['owner_receive']['token_type']);}}if(this['data']['um']!==undefined){let J=null;this['data']['um']&&(J=await LocalMark['Instance']()['get_address'](this['data']['um'])||null,!J&&W_ERROR(WErrors['InvalidParam'],'CallPermission_Data.data.um:'+this['data']['um'])),um_set(c,f,J);}!this['object_address']&&await this['new_with_mark'](a,c,ObjectType['Permission'],create(c,f),GetObject(this['data']?.['object']));}}export function permissionFn(a){return PackageAddress+'::permission::'+a;}export const MAX_ENTITY_COUNT=0x3e8;export const MAX_PERM_FOR_ENTITY=0x3e8;export const MAX_ADMIN_COUNT=0x1f4;export const USER_DEFINED_PERM_INDEX_START=0x3e8;export function isBizPermIndex(a){return a>=USER_DEFINED_PERM_INDEX_START;}export function newPermission(a,b){return typeof b==='string'&&!isValidDescription(b)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),a['moveCall']({'target':permissionFn('new'),'arguments':[toTxString(a,b)]});}export function create(a,b){return a['moveCall']({'target':permissionFn('create'),'arguments':[toTxObject(a,b)]});}export function descriptionSet(a,b,c){typeof c==='string'&&!isValidDescription(c)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),a['moveCall']({'target':permissionFn('description_set'),'arguments':[toTxObject(a,b),toTxString(a,c)]});}export function remarkSet(a,b,c,d){typeof d==='string'&&!isValidLongName(d)&&W_ERROR(WErrors['IsValidDescription'],'Remark\x20exceeds\x20maximum\x20length\x20'+MAX_LONG_NAME_LENGTH),a['moveCall']({'target':permissionFn('remark_set'),'arguments':[toTxObject(a,b),toTxU16(a,c),toTxString(a,d)]});}export function remarkRemove(a,b,c){a['moveCall']({'target':permissionFn('remark_remove'),'arguments':[toTxObject(a,b),toTxU16(a,c)]});}export function remarkClear(a,b){a['moveCall']({'target':permissionFn('remark_clear'),'arguments':[toTxObject(a,b)]});}export function permAdd(a,b,c,d){a['moveCall']({'target':permissionFn('perm_add'),'arguments':[toTxObject(a,b),toTxU16(a,c),toTxAddressVec(a,d,MAX_ENTITY_COUNT),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function permRemove(a,b,c,d){a['moveCall']({'target':permissionFn('perm_remove'),'arguments':[toTxObject(a,b),toTxU16(a,c),toTxAddressVec(a,d,MAX_ENTITY_COUNT)]});}export function permSet(a,b,c,d){a['moveCall']({'target':permissionFn('perm_set'),'arguments':[toTxObject(a,b),toTxU16(a,c),toTxAddressVec(a,d,MAX_ENTITY_COUNT),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function entityAdd(a,b,c,d){a['moveCall']({'target':permissionFn('entity_add'),'arguments':[toTxObject(a,b),toTxAddress(a,c),toTxU16Vec(a,d,MAX_PERM_FOR_ENTITY),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function entityRemove(a,b,c,d){a['moveCall']({'target':permissionFn('entity_remove'),'arguments':[toTxObject(a,b),toTxAddress(a,c),toTxU16Vec(a,d,MAX_PERM_FOR_ENTITY)]});}export function entitySet(a,b,c,d){a['moveCall']({'target':permissionFn('entity_set'),'arguments':[toTxObject(a,b),toTxAddress(a,c),toTxU16Vec(a,d,MAX_PERM_FOR_ENTITY),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function entitySwap(a,b,c,d){a['moveCall']({'target':permissionFn('entity_swap'),'arguments':[toTxObject(a,b),toTxAddress(a,c),toTxAddress(a,d),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function entityReplace(a,b,c,d){a['moveCall']({'target':permissionFn('entity_replace'),'arguments':[toTxObject(a,b),toTxAddress(a,c),toTxAddress(a,d),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function entityDel(a,b,c){a['moveCall']({'target':permissionFn('entity_del'),'arguments':[toTxObject(a,b),toTxAddress(a,c),a['object']['mutRegistrar']()]});}export function entityCopy(a,b,c,d){a['moveCall']({'target':permissionFn('entity_copy'),'arguments':[toTxObject(a,b),toTxAddress(a,c),toTxAddress(a,d),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function adminAdd(a,b,c){a['moveCall']({'target':permissionFn('admin_add'),'arguments':[toTxObject(a,b),toTxAddressVec(a,c,MAX_ADMIN_COUNT)]});}export function adminRemove(a,b,c){a['moveCall']({'target':permissionFn('admin_remove'),'arguments':[toTxObject(a,b),toTxAddressVec(a,c,MAX_ADMIN_COUNT)]});}export function adminSet(a,b,c){a['moveCall']({'target':permissionFn('admin_set'),'arguments':[toTxObject(a,b),toTxAddressVec(a,c,MAX_ADMIN_COUNT)]});}export function transferPermission(a,b,c){a['moveCall']({'target':permissionFn('transfer'),'arguments':[toTxObject(a,b),toTxAddress(a,c)]});}export function um_set(a,b,c){c?a['moveCall']({'target':contactFn('permission_um_set'),'arguments':[toTxObject(a,c),toTxObject(a,b),a['object']['mutRegistrar'](),a['object']['clock']()]}):a['moveCall']({'target':permissionFn('um_none'),'arguments':[toTxObject(a,b),a['object']['mutRegistrar']()]});}export function ownerReceiveObject(a,b,c,d){a['moveCall']({'target':permissionFn('owner_receive_object'),'arguments':[toTxObject(a,b),toTxObject(a,c)],'typeArguments':[d]});}export function ownerReceive(a,b,c,d,e){a['moveCall']({'target':permissionFn('owner_receive'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,d)],'typeArguments':[e]});}export function query_permissions(a){if(!a)return PermissionInfo;return PermissionInfo['filter'](b=>{if(a['objectType']&&b['object_type']!==a['objectType'])return![];if(a['name']&&!b['name']['includes'](a['name']))return![];if(a['index']!==undefined&&b['index']!==a['index'])return![];if(a['description']&&!b['description']['includes'](a['description']))return![];return!![];});}
@@ -1 +1 @@
1
- import{toTxObject,toTxString,isValidDescription,MAX_DESCRIPTION_LENGTH,isValidName,PackageAddress,IsValidArgType,isValidU8,repositoryFn,parseValueType}from'../common.js';import{W_ERROR,WErrors}from'../exception.js';import{owner_receive,validObjects,valueToBcsBytes,uint2address}from'../util.js';import{GetObjectExisted,GetObject,GetObjectDescription}from'../common.js';import{GetAccountOrMark_Address}from'../local/index.js';import{LocalMark}from'../local/local.js';import{CallBase}from'./base.js';import{BuiltinPermissionIndex,newPermission}from'./permission.js';import{IdFrom,ObjectType,parseIdFrom}from'../query/object.js';import{create as a162a}from'./permission.js';import{queryObjectsWithType}from'../query/util.js';import{query_received}from'../query/received.js';export const MAX_POLICY_DESCRIPTION_LEN=0x1f4;export const MAX_POLICY_COUNT=0x32;export const MAX_POLICY_GUARD_COUNT=0xa;export const MAX_DATA_SIZE=0xa000;export const MAX_ID_COUNT_ONCE=0x64;export const MAX_REWARD_COUNT=0x14;export class CallRepository extends CallBase{['data'];['object_address']=undefined;['permission_address']=undefined;['new_permission_description']=undefined;constructor(a){super(),this['data']=a;}async['prepare'](a){await super['prepare'](a);!this['object_address']&&(this['object_address']=await GetObjectExisted(this['data']?.['object']));if(this['object_address']){this['content']=undefined,await this['update_content'](a,ObjectType['Repository'],this['object_address']);if(!this['content'])W_ERROR(WErrors['InvalidParam'],'CallRepository_Data.data.object:'+this['object_address']);this['permission_address']=this['content']['permission'],!this['permission_address']&&W_ERROR(WErrors['InvalidParam'],'CallRepository_Data.data.object.permission\x20is\x20empty');}else{const b=GetObject(this['data']['object']);this['permission_address']=await GetObjectExisted(b?.['permission']),this['new_permission_description']=GetObjectDescription(b?.['permission']);}}async['call'](a){await this['prepare'](a);const b=[],c=[],d=f=>{!c['includes'](f)&&c['push'](f);},e=f=>{this['permission_address']&&!b['includes'](f)&&b['push'](f);};this['permission_address']&&!this['object_address']&&e(BuiltinPermissionIndex['REPOSITORY_NEW']);this['permission_address']&&this['data']?.['description']!=null&&this['object_address']&&e(BuiltinPermissionIndex['REPOSITORY_DESCRIPTION']);this['permission_address']&&this['data']?.['policies']!=null&&e(BuiltinPermissionIndex['REPOSITORY_POLICY']);if(this['data']?.['data_add']!=null){!this['content']&&W_ERROR(WErrors['InvalidParam'],'CallRepository_Data.data.data_add\x20fail\x20because\x20the\x20Repository\x20content\x20not\x20ready');const f=this['content']['policies']['find'](g=>g['name']===this['data']['data_add']['name']);!f&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20policy\x20name:\x20'+this['data']['data_add']['name']);if('items'in this['data']['data_add'])for(const g of this['data']['data_add']['items']){for(const h of g['data']){let i;if(typeof h['id']==='number'||typeof h['id']==='bigint'||typeof h['id']==='string')i=uint2address(h['id']);else{const j=await GetAccountOrMark_Address(h['id']);!j&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20id\x20address:\x20'+h['id']),i=j;}h['id']=i;}if(g['write_guard']){const k=await LocalMark['Instance']()['get_address'](g['write_guard']);k?(!f['write_guard']['find'](l=>l['guard']===k)&&W_ERROR(WErrors['InvalidParam'],g['write_guard']+'\x20('+k+')\x20is\x20not\x20match\x20in\x20policy\x20'+f['name']+'\x20with\x20write_guards:\x20'+f['write_guard']['map'](l=>l['guard'])['join'](',\x20')),g['write_guard']=k,d(k)):W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+g['write_guard']);}}else{if(this['data']['data_add']['write_guard']){const l=await LocalMark['Instance']()['get_address'](this['data']['data_add']['write_guard']);l?(!f['write_guard']['find'](m=>m['guard']===l)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+this['data']['data_add']['write_guard']+'\x20in\x20policy\x20'+f['name']),this['data']['data_add']['write_guard']=l,d(l)):W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+this['data']['data_add']['write_guard']);}}}if(this['data']?.['data_remove']!=null){const m=this['content']['policies']['find'](n=>n['name']===this['data']['data_remove']['name']);!m&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20policy\x20name:\x20'+this['data']['data_remove']['name']);if('items'in this['data']['data_remove'])for(const n of this['data']['data_remove']['items']){const o=[];for(const q of n['id']){let s;if(typeof q==='number'||typeof q==='bigint'||typeof q==='string')s=uint2address(q);else{const t=await GetAccountOrMark_Address(q);!t&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20id\x20address:\x20'+q),s=t;}o['push'](s);}n['id']=o;if(n['write_guard']){const u=await LocalMark['Instance']()['get_address'](n['write_guard']);u?(!m['write_guard']['find'](v=>v['guard']===u)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+n['write_guard']+'\x20in\x20policy\x20'+m['name']),n['write_guard']=u,d(u)):W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+n['write_guard']);}}else{if(this['data']['data_remove']['write_guard']){const v=await LocalMark['Instance']()['get_address'](this['data']['data_remove']['write_guard']);v?(!m['write_guard']['find'](w=>w['guard']===v)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+this['data']['data_remove']['write_guard']+'\x20in\x20policy\x20'+m['name']),this['data']['data_remove']['write_guard']=v,d(v)):W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+this['data']['data_remove']['write_guard']);}}}this['permission_address']&&this['data']?.['rewards']!=null&&e(BuiltinPermissionIndex['REPOSITORY_REWARD']);this['permission_address']&&this['data']?.['owner_receive']!=null&&e(BuiltinPermissionIndex['REPOSITORY_OWNER_RECEIVE']);this['permission_address']&&this['data']?.['um']!==undefined&&e(BuiltinPermissionIndex['REPOSITORY_UM']);if(this['permission_address']||c['length']>0x0)return await this['check_permission_and_call'](a,this['permission_address'],b,c);return await this['exec'](a);}async['operate'](a,b,c,d){let e=this['permission_address'],f=this['object_address'];!this['object_address']&&(!e&&(e=newPermission(b,this['new_permission_description']??'')),e&&(f=newRepository(b,toTxObject(b,e),this['data']?.['description']??'',c)));(!f||!e)&&W_ERROR(WErrors['InvalidParam'],'CallRepository_Data.data.object:'+this['object_address']);this['data']?.['description']!=null&&this['object_address']&&description_set(b,f,e,this['data']['description'],c);if(this['data']?.['policies']!=null){(this['data']['policies']['op']==='set'||this['data']['policies']['op']==='add')&&await Promise['all'](this['data']['policies']['policy']['map'](async g=>{await Promise['all'](g['write_guard']['map'](async h=>{const i=await LocalMark['Instance']()['get_address'](h['guard']);i?h['guard']=i:W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+h['guard']);}));if(g['quote_guard']&&typeof g['quote_guard']==='string'){const h=await LocalMark['Instance']()['get_address'](g['quote_guard']);h?g['quote_guard']=h:W_ERROR(WErrors['InvalidParam'],'Invalid\x20quote_guard\x20address:\x20'+g['quote_guard']);}}));switch(this['data']['policies']['op']){case'set':{policy_set(b,f,e,this['data']['policies']['policy'],c);break;}case'add':{policy_add(b,f,e,this['data']['policies']['policy'],c);break;}case'remove':{policy_remove(b,f,e,this['data']['policies']['policy'],c);break;}case'clear':{policy_clear(b,f,e,c);break;}}}if(this['data']?.['data_add']!=null&&this['content']){const g=this['content']['policies']['find'](h=>h['name']===this['data']['data_add']['name']);!g&&W_ERROR(WErrors['InvalidParam'],'policy\x20'+this['data']['data_add']['name']+'\x20not\x20found\x20in\x20policies\x20'+this['content']['policies']['map'](h=>h['name'])),'items'in this['data']['data_add']?data(b,f,g,this['data']['data_add']['items'],c):data_id_from(b,f,g,this['data']['data_add'],c);}if(this['data']?.['data_remove']!=null){const h=this['content']['policies']['find'](i=>i['name']===this['data']['data_remove']['name']);!h&&W_ERROR(WErrors['InvalidParam'],'policy\x20'+this['data']['data_remove']['name']+'\x20not\x20found\x20in\x20policies\x20'+this['content']['policies']['map'](i=>i['name'])),'items'in this['data']['data_remove']?data_remove(b,f,h,{'items':this['data']['data_remove']['items']},c):data_remove(b,f,h,{'write_guard':this['data']['data_remove']['write_guard']},c);}if(this['data']?.['rewards']!=null)switch(this['data']['rewards']['op']){case'set':case'add':{this['data']['rewards']['objects']['length']>MAX_REWARD_COUNT&&W_ERROR(WErrors['InvalidParam'],'rewards\x20count\x20exceeds\x20maximum\x20limit\x20'+MAX_REWARD_COUNT);this['data']['rewards']['op']==='set'&&reward_clear(b,f,e,c);const i=await queryObjectsWithType(a,this['data']['rewards']['objects'],ObjectType['Reward'],'reward::Reward',!![]);i['forEach'](j=>{reward_add(b,f,e,j['object'],j['type'],c);});break;}case'remove':{this['data']['rewards']['objects']['length']>MAX_REWARD_COUNT&&W_ERROR(WErrors['InvalidParam'],'rewards\x20count\x20exceeds\x20maximum\x20limit\x20'+MAX_REWARD_COUNT);const j=await LocalMark['Instance']()['get_many_address_availables'](this['data']['rewards']['objects']);reward_remove(b,f,e,j,c);break;}case'clear':{reward_clear(b,f,e,c);break;}}this['data']['owner_receive']!=null&&this['object_address']&&(this['data']['owner_receive']==='recently'&&(this['data']['owner_receive']=await query_received({'object':this['object_address'],'all_type':!![]})),await owner_receive(b,f,e,this['data']['owner_receive'],undefined,k=>PackageAddress+'::repository::'+k,c));if(this['data']['um']!==undefined){let k=null;this['data']['um']&&(k=await LocalMark['Instance']()['get_address'](this['data']['um'])||null,!k&&W_ERROR(WErrors['InvalidParam'],'CallRepository_Data.data.um:'+this['data']['um'])),um_set(b,f,e,k,c);}if(!this['permission_address']){const l=GetObject(this['data']?.['object']);await this['new_with_mark'](a,b,ObjectType['Permission'],a162a(b,e),GetObject(l['permission']));}!this['object_address']&&await this['new_with_mark'](a,b,ObjectType['Repository'],create(b,f),GetObject(this['data']?.['object']));}}export function create(a,b){return validObjects([b]),a['moveCall']({'target':repositoryFn('create'),'arguments':[toTxObject(a,b)]});}function policy_guard(a,b){return validObjects([b['guard']]),b['id_from_submission']!=null&&!isValidU8(b['id_from_submission'])&&W_ERROR(WErrors['IsValidU8'],'Id\x20from\x20submission\x20'+b['id_from_submission']+'\x20is\x20not\x20valid'),b['data_from_submission']!=null&&!isValidU8(b['data_from_submission'])&&W_ERROR(WErrors['IsValidU8'],'Data\x20from\x20submission\x20'+b['data_from_submission']+'\x20is\x20not\x20valid'),a['moveCall']({'target':repositoryFn('policy_guard'),'arguments':[toTxObject(a,b['guard']),a['pure']['option']('u8',b['id_from_submission']??null),a['pure']['option']('u8',b['data_from_submission']??null)]});}export function policy(a,b){typeof b['name']==='string'&&!isValidName(b['name'])&&W_ERROR(WErrors['InvalidParam'],'Policy\x20name\x20'+b['name']+'\x20is\x20not\x20valid');typeof b['description']==='string'&&!isValidDescription(b['description'])&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH);validObjects([b['quote_guard'],...b['write_guard']['map'](f=>f['guard'])]);const c=parseIdFrom(b['id_from']),d=parseValueType(b['value_type']),e=a['moveCall']({'target':repositoryFn('policy'),'arguments':[toTxString(a,b['name']),toTxString(a,b['description']),a['pure']['u8'](c),a['pure']['u8'](d)]});if(b['quote_guard'])a['moveCall']({'target':repositoryFn('policy_quote_guard_set'),'arguments':[e,toTxObject(a,b['quote_guard'])]});else b['quote_guard']===null&&a['moveCall']({'target':repositoryFn('policy_quote_guard_none'),'arguments':[e]});return b['write_guard']['length']>0x0&&a['moveCall']({'target':repositoryFn('policy_write_guard_set'),'arguments':[e,a['makeMoveVec']({'elements':b['write_guard']['map'](f=>policy_guard(a,f)),'type':PackageAddress+'::repository::PolicyGuard'})]}),e;}export async function data_id_from(a,b,c,d,e){const f=parseIdFrom(c['id_from']);f===IdFrom['None']&&W_ERROR(WErrors['InvalidParam'],'id_from\x20must\x20be\x20set\x20when\x20id_from\x20is\x20IdFrom.None');if(d['write_guard']){!e&&W_ERROR(WErrors['InvalidParam'],'passport\x20is\x20required\x20when\x20write_guard\x20is\x20specified');if(c['write_guard']['find'](g=>g['guard']===d['write_guard'])){const g=parseValueType(c['value_type']);a['moveCall']({'target':repositoryFn('data_when_id_from_set_with_passport'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['address'](d['write_guard']),a['pure']['vector']('u8',await valueToBcsBytes(g,d['data'])),a['object']['clock'](),e]});}else W_ERROR(WErrors['InvalidParam'],'Write\x20guard\x20'+d['write_guard']+'\x20is\x20not\x20in\x20policy\x20'+c['name']);}else{if(c['write_guard']['length']===0x0){const h=parseValueType(c['value_type']);a['moveCall']({'target':repositoryFn('data_when_id_from_set'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['vector']('u8',await valueToBcsBytes(h,d['data'])),a['object']['clock']()]});}else W_ERROR(WErrors['InvalidParam'],'specify\x20write\x20guard\x20in\x20policy\x20'+c['write_guard']['map'](i=>i['guard']));}}export function um_set(a,b,c,d,e){validObjects([b,c]),d?e?a['moveCall']({'target':repositoryFn('um_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),e,toTxObject(a,d),a['object']['mutRegistrar'](),a['object']['clock']()]}):a['moveCall']({'target':repositoryFn('um_set'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,d),a['object']['mutRegistrar'](),a['object']['clock']()]}):e?a['moveCall']({'target':repositoryFn('um_none_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),e,a['object']['mutRegistrar']()]}):a['moveCall']({'target':repositoryFn('um_none'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['object']['mutRegistrar']()]});}export async function data(a,b,c,d,e){validObjects([b]);c['id_from']!==IdFrom['None']&&W_ERROR(WErrors['InvalidParam'],'id_from\x20must\x20be\x20IdFrom.None\x20when\x20items\x20is\x20provided');const f=[],g=[],h=[];for(const i of d){if(!i['write_guard'])c['write_guard']['length']===0x0?f['push'](i):W_ERROR(WErrors['InvalidParam'],'specify\x20write\x20guard\x20in\x20policy\x20'+c['write_guard']['map'](j=>j['guard']));else{const j=i['write_guard'],k=c['write_guard']['find'](m=>m['guard']===j);!k&&W_ERROR(WErrors['InvalidParam'],'Guard\x20'+j+'\x20not\x20found\x20in\x20policy\x20'+c['write_guard']['map'](m=>m['guard']));const l=k['id_from_submission']!==undefined;if(l){if(i['data']['length']>0x0){const m=i['data'][i['data']['length']-0x1],n=h['findIndex'](o=>o['guard']===j);n>=0x0?h[n]={'guard':j,'id':m['id'],'data':m['data']}:h['push']({'guard':j,'id':m['id'],'data':m['data']});}}else{const o=g['find'](p=>p['guard']===j);o?o['items']['push'](i):g['push']({'guard':j,'items':[i]});}}}if(f['length']>0x0){const p=parseValueType(c['value_type']),q=f['flatMap'](s=>s['data']['map'](t=>t['id'])),r=await Promise['all'](f['flatMap'](s=>s['data'])['map'](async s=>await valueToBcsBytes(p,s['data'])));q['length']!==r['length']&&W_ERROR(WErrors['InvalidParam'],'Id\x20and\x20data\x20arrays\x20must\x20have\x20the\x20same\x20length'),a['moveCall']({'target':repositoryFn('id_data'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['vector']('address',q),a['makeMoveVec']({'elements':r['map'](s=>a['pure']['vector']('u8',s)),'type':'vector<u8>'})]});}if(h['length']>0x0){!e&&W_ERROR(WErrors['InvalidParam'],'Guard\x20specified\x20but\x20no\x20passport\x20provided');const s=parseValueType(c['value_type']),t=h['map'](w=>w['id']),u=await Promise['all'](h['map'](async w=>await valueToBcsBytes(s,w['data']))),v=h['map'](w=>w['guard']);(t['length']!==u['length']||t['length']!==v['length'])&&W_ERROR(WErrors['InvalidParam'],'Id,\x20data,\x20and\x20guard\x20arrays\x20must\x20have\x20the\x20same\x20length'),a['moveCall']({'target':repositoryFn('id_data_mixed_with_passport'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['vector']('address',v),a['pure']['vector']('address',t),a['makeMoveVec']({'elements':u['map'](w=>a['pure']['vector']('u8',w)),'type':'vector<u8>'}),toTxObject(a,e)]});}for(const {guard:w,items:x}of g){!e&&W_ERROR(WErrors['InvalidParam'],'Guard\x20specified\x20but\x20no\x20passport\x20provided');const y=parseValueType(c['value_type']),z=x['flatMap'](C=>C['data']),A=z['map'](C=>C['id']),B=await Promise['all'](z['map'](async C=>await valueToBcsBytes(y,C['data'])));A['length']!==B['length']&&W_ERROR(WErrors['InvalidParam'],'Id\x20and\x20data\x20arrays\x20must\x20have\x20the\x20same\x20length\x20for\x20guard\x20'+w),a['moveCall']({'target':repositoryFn('id_data_with_passport'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['address'](w),a['pure']['vector']('address',A),a['makeMoveVec']({'elements':B['map'](C=>a['pure']['vector']('u8',C)),'type':'vector<u8>'}),toTxObject(a,e)]});}}export function newRepository(a,b,c,d){return validObjects([b,d]),typeof c==='string'&&!isValidDescription(c)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),d?a['moveCall']({'target':repositoryFn('new_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxString(a,c),a['object']['mutRegistrar'](),a['object']['clock']()]}):a['moveCall']({'target':repositoryFn('new'),'arguments':[toTxObject(a,b),toTxString(a,c),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function description_set(a,b,c,d,e){validObjects([b,c,e]),typeof d==='string'&&!isValidDescription(d)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),e?a['moveCall']({'target':repositoryFn('description_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,e),toTxString(a,d)]}):a['moveCall']({'target':repositoryFn('description_set'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxString(a,d)]});}export function policy_add(a,b,c,d,e){if(d['length']===0x0)return;validObjects([b,c,e]),e?a['moveCall']({'target':repositoryFn('policy_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,e),a['makeMoveVec']({'elements':d['map'](f=>policy(a,f)),'type':PackageAddress+'::repository::PolicyRule'}),a['object']['mutRegistrar'](),a['object']['clock']()]}):a['moveCall']({'target':repositoryFn('policy_add'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['makeMoveVec']({'elements':d['map'](f=>policy(a,f)),'type':PackageAddress+'::repository::PolicyRule'}),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function policy_set(a,b,c,d,e){validObjects([b,c,e]),e?a['moveCall']({'target':repositoryFn('policy_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,e),a['makeMoveVec']({'elements':d['map'](f=>policy(a,f)),'type':PackageAddress+'::repository::PolicyRule'}),a['object']['mutRegistrar'](),a['object']['clock']()]}):a['moveCall']({'target':repositoryFn('policy_set'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['makeMoveVec']({'elements':d['map'](f=>policy(a,f)),'type':PackageAddress+'::repository::PolicyRule'}),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function policy_remove(a,b,c,d,e){if(d['length']===0x0)return;validObjects([b,c,e]),e?a['moveCall']({'target':repositoryFn('policy_remove_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,e),a['pure']['vector']('string',d),a['object']['mutRegistrar']()]}):a['moveCall']({'target':repositoryFn('policy_remove'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['pure']['vector']('string',d),a['object']['mutRegistrar']()]});}export function policy_clear(a,b,c,d){validObjects([b,c,d]),d?a['moveCall']({'target':repositoryFn('policy_clear_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,d),a['object']['mutRegistrar']()]}):a['moveCall']({'target':repositoryFn('policy_clear'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['object']['mutRegistrar']()]});}export function reward_add(a,b,c,d,e,f){validObjects([b,c,f,d]),!IsValidArgType(e)&&W_ERROR(WErrors['IsValidArgType'],'Reward\x20type\x20'+e+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':repositoryFn('reward_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,f),a['object'](d)],'typeArguments':[e]}):a['moveCall']({'target':repositoryFn('reward_add'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['object'](d)],'typeArguments':[e]});}export function reward_remove(a,b,c,d,e){if(d['length']===0x0)return;validObjects([b,c,e,...d]),e?a['moveCall']({'target':repositoryFn('reward_remove_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,e),a['pure']['vector']('address',d)]}):a['moveCall']({'target':repositoryFn('reward_remove'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['pure']['vector']('address',d)]});}export function reward_clear(a,b,c,d){validObjects([b,c,d]),d?a['moveCall']({'target':repositoryFn('reward_clear_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,d)]}):a['moveCall']({'target':repositoryFn('reward_clear'),'arguments':[toTxObject(a,b),toTxObject(a,c)]});}export async function data_remove(a,b,c,d,e){validObjects([b]);if('items'in d){c['id_from']!==IdFrom['None']&&W_ERROR(WErrors['InvalidParam'],'id_from\x20must\x20be\x20IdFrom.None\x20when\x20items\x20is\x20provided');const f=[],g=[],h=[];for(const i of d['items']){if(!i['write_guard'])c['write_guard']['length']===0x0?f['push'](...i['id']):W_ERROR(WErrors['InvalidParam'],'specify\x20write\x20guard\x20in\x20policy\x20'+c['write_guard']['map'](j=>j['guard']));else{const j=i['write_guard'],k=c['write_guard']['find'](m=>m['guard']===j);!k&&W_ERROR(WErrors['InvalidParam'],'Guard\x20'+j+'\x20not\x20found\x20in\x20policy\x20'+c['write_guard']['map'](m=>m['guard']));const l=k['id_from_submission']!==undefined;if(l)h['push'](j);else{const m=g['find'](n=>n['guard']===j);m?m['id']['push'](...i['id']):g['push']({'guard':j,'id':[...i['id']]});}}}if(f['length']>0x0){c['write_guard']['length']!==0x0&&W_ERROR(WErrors['InvalidParam'],'specify\x20write\x20guard\x20in\x20policy\x20'+c['write_guard']['map'](o=>o['guard']));const n=[...new Set(f)];a['moveCall']({'target':repositoryFn('id_data_remove'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['vector']('address',n)]});}if(h['length']>0x0){!e&&W_ERROR(WErrors['InvalidParam'],'Guard\x20specified\x20but\x20no\x20passport\x20provided');const o=[...new Set(h)];a['moveCall']({'target':repositoryFn('id_data_mixed_remove_with_passport'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['vector']('address',o),toTxObject(a,e)]});}for(const {guard:p,id:q}of g){const r=[...new Set(q)];a['moveCall']({'target':repositoryFn('id_data_remove_with_passport'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['address'](p),a['pure']['vector']('address',r),toTxObject(a,e)]});}}else{const s=d['write_guard'];c['id_from']===IdFrom['None']&&W_ERROR(WErrors['InvalidParam'],'id_from\x20must\x20be\x20set\x20when\x20id_from\x20is\x20IdFrom.None'),s?c['write_guard']['find'](t=>t['guard']===s)?a['moveCall']({'target':repositoryFn('data_remove_when_id_from_set_with_passport'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['address'](s),a['object']['clock'](),toTxObject(a,e)]}):W_ERROR(WErrors['InvalidParam'],'Write\x20guard\x20'+s+'\x20is\x20not\x20in\x20policy\x20'+c['write_guard']['map'](t=>t['guard'])):c['write_guard']['length']===0x0?a['moveCall']({'target':repositoryFn('data_remove_when_id_from_set'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['object']['clock']()]}):W_ERROR(WErrors['InvalidParam'],'specify\x20write\x20guard\x20in\x20policy\x20'+c['write_guard']['map'](t=>t['guard']));}}
1
+ import{toTxObject,toTxString,isValidDescription,MAX_DESCRIPTION_LENGTH,isValidName,PackageAddress,IsValidArgType,isValidU8,repositoryFn,parseValueType}from'../common.js';import{W_ERROR,WErrors}from'../exception.js';import{owner_receive,validObjects,valueToBcsBytes,uint2address}from'../util.js';import{GetObjectExisted,GetObject,GetObjectDescription}from'../common.js';import{GetAccountOrMark_Address}from'../local/index.js';import{LocalMark}from'../local/local.js';import{CallBase}from'./base.js';import{BuiltinPermissionIndex,newPermission}from'./permission.js';import{IdFrom,ObjectType,parseIdFrom}from'../query/object.js';import{create as a162a}from'./permission.js';import{queryObjectsWithType}from'../query/util.js';import{query_received}from'../query/received.js';export const MAX_POLICY_DESCRIPTION_LEN=0x1f4;export const MAX_POLICY_COUNT=0x32;export const MAX_POLICY_GUARD_COUNT=0xa;export const MAX_DATA_SIZE=0xa000;export const MAX_ID_COUNT_ONCE=0x64;export const MAX_REWARD_COUNT=0x14;export class CallRepository extends CallBase{['data'];['object_address']=undefined;['permission_address']=undefined;['new_permission_description']=undefined;constructor(a){super(),this['data']=a;}async['prepare'](a){await super['prepare'](a);!this['object_address']&&(this['object_address']=await GetObjectExisted(this['data']?.['object']));if(this['object_address']){this['content']=undefined,await this['update_content'](a,ObjectType['Repository'],this['object_address']);if(!this['content'])W_ERROR(WErrors['InvalidParam'],'CallRepository_Data.data.object:'+this['object_address']);this['permission_address']=this['content']['permission'],!this['permission_address']&&W_ERROR(WErrors['InvalidParam'],'CallRepository_Data.data.object.permission\x20is\x20empty');}else{const b=GetObject(this['data']['object']);this['permission_address']=await GetObjectExisted(b?.['permission']),this['new_permission_description']=GetObjectDescription(b?.['permission']);}}async['call'](a){await this['prepare'](a);const b=[],c=[],d=f=>{!c['includes'](f)&&c['push'](f);},e=f=>{this['permission_address']&&!b['includes'](f)&&b['push'](f);};this['permission_address']&&!this['object_address']&&e(BuiltinPermissionIndex['REPOSITORY_NEW']);this['permission_address']&&this['data']?.['description']!=null&&this['object_address']&&e(BuiltinPermissionIndex['REPOSITORY_DESCRIPTION']);this['permission_address']&&this['data']?.['policies']!=null&&e(BuiltinPermissionIndex['REPOSITORY_POLICY']);if(this['data']?.['data_add']!=null){!this['content']&&W_ERROR(WErrors['InvalidParam'],'CallRepository_Data.data.data_add\x20fail\x20because\x20the\x20Repository\x20content\x20not\x20ready');const f=this['content']['policies']['find'](g=>g['name']===this['data']['data_add']['name']);!f&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20policy\x20name:\x20'+this['data']['data_add']['name']);if('items'in this['data']['data_add'])for(const g of this['data']['data_add']['items']){for(const h of g['data']){let i;if(typeof h['id']==='number'||typeof h['id']==='bigint'||typeof h['id']==='string')i=uint2address(h['id']);else{const j=await GetAccountOrMark_Address(h['id']);!j&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20id\x20address:\x20'+h['id']),i=j;}h['id']=i;}if(g['write_guard']){const k=await LocalMark['Instance']()['get_address'](g['write_guard']);k?(!f['write_guard']['find'](l=>l['guard']===k)&&W_ERROR(WErrors['InvalidParam'],g['write_guard']+'\x20('+k+')\x20is\x20not\x20match\x20in\x20policy\x20'+f['name']+'\x20with\x20write_guards:\x20'+f['write_guard']['map'](l=>l['guard'])['join'](',\x20')),g['write_guard']=k,d(k)):W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+g['write_guard']);}}else{if(this['data']['data_add']['write_guard']){const l=await LocalMark['Instance']()['get_address'](this['data']['data_add']['write_guard']);l?(!f['write_guard']['find'](m=>m['guard']===l)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+this['data']['data_add']['write_guard']+'\x20in\x20policy\x20'+f['name']),this['data']['data_add']['write_guard']=l,d(l)):W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+this['data']['data_add']['write_guard']);}}}if(this['data']?.['data_remove']!=null){const m=this['content']['policies']['find'](n=>n['name']===this['data']['data_remove']['name']);!m&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20policy\x20name:\x20'+this['data']['data_remove']['name']);if('items'in this['data']['data_remove'])for(const n of this['data']['data_remove']['items']){const o=[];for(const q of n['id']){let s;if(typeof q==='number'||typeof q==='bigint'||typeof q==='string')s=uint2address(q);else{const t=await GetAccountOrMark_Address(q);!t&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20id\x20address:\x20'+q),s=t;}o['push'](s);}n['id']=o;if(n['write_guard']){const u=await LocalMark['Instance']()['get_address'](n['write_guard']);u?(!m['write_guard']['find'](v=>v['guard']===u)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+n['write_guard']+'\x20in\x20policy\x20'+m['name']),n['write_guard']=u,d(u)):W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+n['write_guard']);}}else{if(this['data']['data_remove']['write_guard']){const v=await LocalMark['Instance']()['get_address'](this['data']['data_remove']['write_guard']);v?(!m['write_guard']['find'](w=>w['guard']===v)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+this['data']['data_remove']['write_guard']+'\x20in\x20policy\x20'+m['name']),this['data']['data_remove']['write_guard']=v,d(v)):W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+this['data']['data_remove']['write_guard']);}}}this['permission_address']&&this['data']?.['rewards']!=null&&e(BuiltinPermissionIndex['REPOSITORY_REWARD']);this['permission_address']&&this['data']?.['owner_receive']!=null&&e(BuiltinPermissionIndex['REPOSITORY_OWNER_RECEIVE']);this['permission_address']&&this['data']?.['um']!==undefined&&e(BuiltinPermissionIndex['REPOSITORY_UM']);if(this['permission_address']||c['length']>0x0)return await this['check_permission_and_call'](a,this['permission_address'],b,c);return await this['exec'](a);}async['operate'](a,b,c,d){let e=this['permission_address'],f=this['object_address'];!this['object_address']&&(!e&&(e=newPermission(b,this['new_permission_description']??'')),e&&(f=newRepository(b,toTxObject(b,e),this['data']?.['description']??'',c)));(!f||!e)&&W_ERROR(WErrors['InvalidParam'],'CallRepository_Data.data.object:'+this['object_address']);this['data']?.['description']!=null&&this['object_address']&&description_set(b,f,e,this['data']['description'],c);if(this['data']?.['policies']!=null){(this['data']['policies']['op']==='set'||this['data']['policies']['op']==='add')&&await Promise['all'](this['data']['policies']['policy']['map'](async g=>{await Promise['all'](g['write_guard']['map'](async h=>{const i=await LocalMark['Instance']()['get_address'](h['guard']);i?h['guard']=i:W_ERROR(WErrors['InvalidParam'],'Invalid\x20write_guard\x20address:\x20'+h['guard']);}));if(g['quote_guard']&&typeof g['quote_guard']==='string'){const h=await LocalMark['Instance']()['get_address'](g['quote_guard']);h?g['quote_guard']=h:W_ERROR(WErrors['InvalidParam'],'Invalid\x20quote_guard\x20address:\x20'+g['quote_guard']);}}));switch(this['data']['policies']['op']){case'set':{policy_set(b,f,e,this['data']['policies']['policy'],c);break;}case'add':{policy_add(b,f,e,this['data']['policies']['policy'],c);break;}case'remove':{policy_remove(b,f,e,this['data']['policies']['policy'],c);break;}case'clear':{policy_clear(b,f,e,c);break;}}}if(this['data']?.['data_add']!=null&&this['content']){const g=this['content']['policies']['find'](h=>h['name']===this['data']['data_add']['name']);!g&&W_ERROR(WErrors['InvalidParam'],'policy\x20'+this['data']['data_add']['name']+'\x20not\x20found\x20in\x20policies\x20'+this['content']['policies']['map'](h=>h['name'])),'items'in this['data']['data_add']?data(b,f,g,this['data']['data_add']['items'],c):data_id_from(b,f,g,this['data']['data_add'],c);}if(this['data']?.['data_remove']!=null){const h=this['content']['policies']['find'](i=>i['name']===this['data']['data_remove']['name']);!h&&W_ERROR(WErrors['InvalidParam'],'policy\x20'+this['data']['data_remove']['name']+'\x20not\x20found\x20in\x20policies\x20'+this['content']['policies']['map'](i=>i['name'])),'items'in this['data']['data_remove']?data_remove(b,f,h,{'items':this['data']['data_remove']['items']},c):data_remove(b,f,h,{'write_guard':this['data']['data_remove']['write_guard']},c);}if(this['data']?.['rewards']!=null)switch(this['data']['rewards']['op']){case'set':case'add':{this['data']['rewards']['objects']['length']>MAX_REWARD_COUNT&&W_ERROR(WErrors['InvalidParam'],'rewards\x20count\x20exceeds\x20maximum\x20limit\x20'+MAX_REWARD_COUNT);this['data']['rewards']['op']==='set'&&reward_clear(b,f,e,c);const i=await queryObjectsWithType(a,this['data']['rewards']['objects'],ObjectType['Reward'],'reward::Reward',!![]);i['forEach'](j=>{reward_add(b,f,e,j['object'],j['type'],c);});break;}case'remove':{this['data']['rewards']['objects']['length']>MAX_REWARD_COUNT&&W_ERROR(WErrors['InvalidParam'],'rewards\x20count\x20exceeds\x20maximum\x20limit\x20'+MAX_REWARD_COUNT);const j=await LocalMark['Instance']()['get_many_address_availables'](this['data']['rewards']['objects']);reward_remove(b,f,e,j,c);break;}case'clear':{reward_clear(b,f,e,c);break;}}this['data']['owner_receive']!=null&&this['object_address']&&(this['data']['owner_receive']==='recently'&&(this['data']['owner_receive']=await query_received({'name_or_address':{'name_or_address':this['object_address'],'local_mark_first':!![]},'all_type':!![],'no_cache':a['no_cache'],'network':a['network']})),await owner_receive(b,f,e,this['data']['owner_receive'],undefined,k=>PackageAddress+'::repository::'+k,c));if(this['data']['um']!==undefined){let k=null;this['data']['um']&&(k=await LocalMark['Instance']()['get_address'](this['data']['um'])||null,!k&&W_ERROR(WErrors['InvalidParam'],'CallRepository_Data.data.um:'+this['data']['um'])),um_set(b,f,e,k,c);}if(!this['permission_address']){const l=GetObject(this['data']?.['object']);await this['new_with_mark'](a,b,ObjectType['Permission'],a162a(b,e),GetObject(l['permission']));}!this['object_address']&&await this['new_with_mark'](a,b,ObjectType['Repository'],create(b,f),GetObject(this['data']?.['object']));}}export function create(a,b){return validObjects([b]),a['moveCall']({'target':repositoryFn('create'),'arguments':[toTxObject(a,b)]});}function policy_guard(a,b){return validObjects([b['guard']]),b['id_from_submission']!=null&&!isValidU8(b['id_from_submission'])&&W_ERROR(WErrors['IsValidU8'],'Id\x20from\x20submission\x20'+b['id_from_submission']+'\x20is\x20not\x20valid'),b['data_from_submission']!=null&&!isValidU8(b['data_from_submission'])&&W_ERROR(WErrors['IsValidU8'],'Data\x20from\x20submission\x20'+b['data_from_submission']+'\x20is\x20not\x20valid'),a['moveCall']({'target':repositoryFn('policy_guard'),'arguments':[toTxObject(a,b['guard']),a['pure']['option']('u8',b['id_from_submission']??null),a['pure']['option']('u8',b['data_from_submission']??null)]});}export function policy(a,b){typeof b['name']==='string'&&!isValidName(b['name'])&&W_ERROR(WErrors['InvalidParam'],'Policy\x20name\x20'+b['name']+'\x20is\x20not\x20valid');typeof b['description']==='string'&&!isValidDescription(b['description'])&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH);validObjects([b['quote_guard'],...b['write_guard']['map'](f=>f['guard'])]);const c=parseIdFrom(b['id_from']),d=parseValueType(b['value_type']),e=a['moveCall']({'target':repositoryFn('policy'),'arguments':[toTxString(a,b['name']),toTxString(a,b['description']),a['pure']['u8'](c),a['pure']['u8'](d)]});if(b['quote_guard'])a['moveCall']({'target':repositoryFn('policy_quote_guard_set'),'arguments':[e,toTxObject(a,b['quote_guard'])]});else b['quote_guard']===null&&a['moveCall']({'target':repositoryFn('policy_quote_guard_none'),'arguments':[e]});return b['write_guard']['length']>0x0&&a['moveCall']({'target':repositoryFn('policy_write_guard_set'),'arguments':[e,a['makeMoveVec']({'elements':b['write_guard']['map'](f=>policy_guard(a,f)),'type':PackageAddress+'::repository::PolicyGuard'})]}),e;}export async function data_id_from(a,b,c,d,e){const f=parseIdFrom(c['id_from']);f===IdFrom['None']&&W_ERROR(WErrors['InvalidParam'],'id_from\x20must\x20be\x20set\x20when\x20id_from\x20is\x20IdFrom.None');if(d['write_guard']){!e&&W_ERROR(WErrors['InvalidParam'],'passport\x20is\x20required\x20when\x20write_guard\x20is\x20specified');if(c['write_guard']['find'](g=>g['guard']===d['write_guard'])){const g=parseValueType(c['value_type']);a['moveCall']({'target':repositoryFn('data_when_id_from_set_with_passport'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['address'](d['write_guard']),a['pure']['vector']('u8',await valueToBcsBytes(g,d['data'])),a['object']['clock'](),e]});}else W_ERROR(WErrors['InvalidParam'],'Write\x20guard\x20'+d['write_guard']+'\x20is\x20not\x20in\x20policy\x20'+c['name']);}else{if(c['write_guard']['length']===0x0){const h=parseValueType(c['value_type']);a['moveCall']({'target':repositoryFn('data_when_id_from_set'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['vector']('u8',await valueToBcsBytes(h,d['data'])),a['object']['clock']()]});}else W_ERROR(WErrors['InvalidParam'],'specify\x20write\x20guard\x20in\x20policy\x20'+c['write_guard']['map'](i=>i['guard']));}}export function um_set(a,b,c,d,e){validObjects([b,c]),d?e?a['moveCall']({'target':repositoryFn('um_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),e,toTxObject(a,d),a['object']['mutRegistrar'](),a['object']['clock']()]}):a['moveCall']({'target':repositoryFn('um_set'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,d),a['object']['mutRegistrar'](),a['object']['clock']()]}):e?a['moveCall']({'target':repositoryFn('um_none_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),e,a['object']['mutRegistrar']()]}):a['moveCall']({'target':repositoryFn('um_none'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['object']['mutRegistrar']()]});}export async function data(a,b,c,d,e){validObjects([b]);c['id_from']!==IdFrom['None']&&W_ERROR(WErrors['InvalidParam'],'id_from\x20must\x20be\x20IdFrom.None\x20when\x20items\x20is\x20provided');const f=[],g=[],h=[];for(const i of d){if(!i['write_guard'])c['write_guard']['length']===0x0?f['push'](i):W_ERROR(WErrors['InvalidParam'],'specify\x20write\x20guard\x20in\x20policy\x20'+c['write_guard']['map'](j=>j['guard']));else{const j=i['write_guard'],k=c['write_guard']['find'](m=>m['guard']===j);!k&&W_ERROR(WErrors['InvalidParam'],'Guard\x20'+j+'\x20not\x20found\x20in\x20policy\x20'+c['write_guard']['map'](m=>m['guard']));const l=k['id_from_submission']!==undefined;if(l){if(i['data']['length']>0x0){const m=i['data'][i['data']['length']-0x1],n=h['findIndex'](o=>o['guard']===j);n>=0x0?h[n]={'guard':j,'id':m['id'],'data':m['data']}:h['push']({'guard':j,'id':m['id'],'data':m['data']});}}else{const o=g['find'](p=>p['guard']===j);o?o['items']['push'](i):g['push']({'guard':j,'items':[i]});}}}if(f['length']>0x0){const p=parseValueType(c['value_type']),q=f['flatMap'](s=>s['data']['map'](t=>t['id'])),r=await Promise['all'](f['flatMap'](s=>s['data'])['map'](async s=>await valueToBcsBytes(p,s['data'])));q['length']!==r['length']&&W_ERROR(WErrors['InvalidParam'],'Id\x20and\x20data\x20arrays\x20must\x20have\x20the\x20same\x20length'),a['moveCall']({'target':repositoryFn('id_data'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['vector']('address',q),a['makeMoveVec']({'elements':r['map'](s=>a['pure']['vector']('u8',s)),'type':'vector<u8>'})]});}if(h['length']>0x0){!e&&W_ERROR(WErrors['InvalidParam'],'Guard\x20specified\x20but\x20no\x20passport\x20provided');const s=parseValueType(c['value_type']),t=h['map'](w=>w['id']),u=await Promise['all'](h['map'](async w=>await valueToBcsBytes(s,w['data']))),v=h['map'](w=>w['guard']);(t['length']!==u['length']||t['length']!==v['length'])&&W_ERROR(WErrors['InvalidParam'],'Id,\x20data,\x20and\x20guard\x20arrays\x20must\x20have\x20the\x20same\x20length'),a['moveCall']({'target':repositoryFn('id_data_mixed_with_passport'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['vector']('address',v),a['pure']['vector']('address',t),a['makeMoveVec']({'elements':u['map'](w=>a['pure']['vector']('u8',w)),'type':'vector<u8>'}),toTxObject(a,e)]});}for(const {guard:w,items:x}of g){!e&&W_ERROR(WErrors['InvalidParam'],'Guard\x20specified\x20but\x20no\x20passport\x20provided');const y=parseValueType(c['value_type']),z=x['flatMap'](C=>C['data']),A=z['map'](C=>C['id']),B=await Promise['all'](z['map'](async C=>await valueToBcsBytes(y,C['data'])));A['length']!==B['length']&&W_ERROR(WErrors['InvalidParam'],'Id\x20and\x20data\x20arrays\x20must\x20have\x20the\x20same\x20length\x20for\x20guard\x20'+w),a['moveCall']({'target':repositoryFn('id_data_with_passport'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['address'](w),a['pure']['vector']('address',A),a['makeMoveVec']({'elements':B['map'](C=>a['pure']['vector']('u8',C)),'type':'vector<u8>'}),toTxObject(a,e)]});}}export function newRepository(a,b,c,d){return validObjects([b,d]),typeof c==='string'&&!isValidDescription(c)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),d?a['moveCall']({'target':repositoryFn('new_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxString(a,c),a['object']['mutRegistrar'](),a['object']['clock']()]}):a['moveCall']({'target':repositoryFn('new'),'arguments':[toTxObject(a,b),toTxString(a,c),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function description_set(a,b,c,d,e){validObjects([b,c,e]),typeof d==='string'&&!isValidDescription(d)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),e?a['moveCall']({'target':repositoryFn('description_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,e),toTxString(a,d)]}):a['moveCall']({'target':repositoryFn('description_set'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxString(a,d)]});}export function policy_add(a,b,c,d,e){if(d['length']===0x0)return;validObjects([b,c,e]),e?a['moveCall']({'target':repositoryFn('policy_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,e),a['makeMoveVec']({'elements':d['map'](f=>policy(a,f)),'type':PackageAddress+'::repository::PolicyRule'}),a['object']['mutRegistrar'](),a['object']['clock']()]}):a['moveCall']({'target':repositoryFn('policy_add'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['makeMoveVec']({'elements':d['map'](f=>policy(a,f)),'type':PackageAddress+'::repository::PolicyRule'}),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function policy_set(a,b,c,d,e){validObjects([b,c,e]),e?a['moveCall']({'target':repositoryFn('policy_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,e),a['makeMoveVec']({'elements':d['map'](f=>policy(a,f)),'type':PackageAddress+'::repository::PolicyRule'}),a['object']['mutRegistrar'](),a['object']['clock']()]}):a['moveCall']({'target':repositoryFn('policy_set'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['makeMoveVec']({'elements':d['map'](f=>policy(a,f)),'type':PackageAddress+'::repository::PolicyRule'}),a['object']['mutRegistrar'](),a['object']['clock']()]});}export function policy_remove(a,b,c,d,e){if(d['length']===0x0)return;validObjects([b,c,e]),e?a['moveCall']({'target':repositoryFn('policy_remove_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,e),a['pure']['vector']('string',d),a['object']['mutRegistrar']()]}):a['moveCall']({'target':repositoryFn('policy_remove'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['pure']['vector']('string',d),a['object']['mutRegistrar']()]});}export function policy_clear(a,b,c,d){validObjects([b,c,d]),d?a['moveCall']({'target':repositoryFn('policy_clear_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,d),a['object']['mutRegistrar']()]}):a['moveCall']({'target':repositoryFn('policy_clear'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['object']['mutRegistrar']()]});}export function reward_add(a,b,c,d,e,f){validObjects([b,c,f,d]),!IsValidArgType(e)&&W_ERROR(WErrors['IsValidArgType'],'Reward\x20type\x20'+e+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':repositoryFn('reward_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,f),a['object'](d)],'typeArguments':[e]}):a['moveCall']({'target':repositoryFn('reward_add'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['object'](d)],'typeArguments':[e]});}export function reward_remove(a,b,c,d,e){if(d['length']===0x0)return;validObjects([b,c,e,...d]),e?a['moveCall']({'target':repositoryFn('reward_remove_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,e),a['pure']['vector']('address',d)]}):a['moveCall']({'target':repositoryFn('reward_remove'),'arguments':[toTxObject(a,b),toTxObject(a,c),a['pure']['vector']('address',d)]});}export function reward_clear(a,b,c,d){validObjects([b,c,d]),d?a['moveCall']({'target':repositoryFn('reward_clear_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,c),toTxObject(a,d)]}):a['moveCall']({'target':repositoryFn('reward_clear'),'arguments':[toTxObject(a,b),toTxObject(a,c)]});}export async function data_remove(a,b,c,d,e){validObjects([b]);if('items'in d){c['id_from']!==IdFrom['None']&&W_ERROR(WErrors['InvalidParam'],'id_from\x20must\x20be\x20IdFrom.None\x20when\x20items\x20is\x20provided');const f=[],g=[],h=[];for(const i of d['items']){if(!i['write_guard'])c['write_guard']['length']===0x0?f['push'](...i['id']):W_ERROR(WErrors['InvalidParam'],'specify\x20write\x20guard\x20in\x20policy\x20'+c['write_guard']['map'](j=>j['guard']));else{const j=i['write_guard'],k=c['write_guard']['find'](m=>m['guard']===j);!k&&W_ERROR(WErrors['InvalidParam'],'Guard\x20'+j+'\x20not\x20found\x20in\x20policy\x20'+c['write_guard']['map'](m=>m['guard']));const l=k['id_from_submission']!==undefined;if(l)h['push'](j);else{const m=g['find'](n=>n['guard']===j);m?m['id']['push'](...i['id']):g['push']({'guard':j,'id':[...i['id']]});}}}if(f['length']>0x0){c['write_guard']['length']!==0x0&&W_ERROR(WErrors['InvalidParam'],'specify\x20write\x20guard\x20in\x20policy\x20'+c['write_guard']['map'](o=>o['guard']));const n=[...new Set(f)];a['moveCall']({'target':repositoryFn('id_data_remove'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['vector']('address',n)]});}if(h['length']>0x0){!e&&W_ERROR(WErrors['InvalidParam'],'Guard\x20specified\x20but\x20no\x20passport\x20provided');const o=[...new Set(h)];a['moveCall']({'target':repositoryFn('id_data_mixed_remove_with_passport'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['vector']('address',o),toTxObject(a,e)]});}for(const {guard:p,id:q}of g){const r=[...new Set(q)];a['moveCall']({'target':repositoryFn('id_data_remove_with_passport'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['address'](p),a['pure']['vector']('address',r),toTxObject(a,e)]});}}else{const s=d['write_guard'];c['id_from']===IdFrom['None']&&W_ERROR(WErrors['InvalidParam'],'id_from\x20must\x20be\x20set\x20when\x20id_from\x20is\x20IdFrom.None'),s?c['write_guard']['find'](t=>t['guard']===s)?a['moveCall']({'target':repositoryFn('data_remove_when_id_from_set_with_passport'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['pure']['address'](s),a['object']['clock'](),toTxObject(a,e)]}):W_ERROR(WErrors['InvalidParam'],'Write\x20guard\x20'+s+'\x20is\x20not\x20in\x20policy\x20'+c['write_guard']['map'](t=>t['guard'])):c['write_guard']['length']===0x0?a['moveCall']({'target':repositoryFn('data_remove_when_id_from_set'),'arguments':[toTxObject(a,b),toTxString(a,c['name']),a['object']['clock']()]}):W_ERROR(WErrors['InvalidParam'],'specify\x20write\x20guard\x20in\x20policy\x20'+c['write_guard']['map'](t=>t['guard']));}}
@@ -1 +1 @@
1
- import{toTxObject,toTxString,isValidDescription,MAX_DESCRIPTION_LENGTH,isValidU8,PackageAddress,isValidU64,IsValidArgType,rewardFn}from'../common.js';import{W_ERROR,WErrors}from'../exception.js';import{parseObjectType,validObjects}from'../util.js';import{GetObjectExisted,GetObject,GetObjectDescription}from'../common.js';import{LocalMark}from'../local/local.js';import{CallBase,getCoinParam}from'./base.js';import{BuiltinPermissionIndex,newPermission}from'./permission.js';import{owner_receive}from'../util.js';import{AmountType,ObjectType}from'../query/object.js';import{GetAccountOrMark_Address}from'../local/index.js';import{create as a164a}from'./permission.js';import{query_received}from'../query/received.js';export class CallReward extends CallBase{['data'];['object_address']=undefined;['permission_address']=undefined;['new_permission_description']=undefined;['reward_type']=undefined;constructor(a){super(),this['data']=a;}async['prepare'](a){await super['prepare'](a);!this['object_address']&&(this['object_address']=await GetObjectExisted(this['data']?.['object']));if(this['object_address']){this['content']=undefined,await this['update_content'](a,ObjectType['Reward'],this['object_address']);if(!this['content'])W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.object:'+this['object_address']);this['permission_address']=this['content']['permission'],this['reward_type']=parseObjectType(this['content']['type_raw'],'reward::Reward'),!this['permission_address']&&W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.object.permission\x20is\x20empty'),!IsValidArgType(this['reward_type'])&&W_ERROR(WErrors['IsValidArgType'],'CallReward_Data.data.object.type_parameter\x20is\x20empty');}else{const b=GetObject(this['data']['object']);this['permission_address']=await GetObjectExisted(b?.['permission']),this['new_permission_description']=GetObjectDescription(b?.['permission']),this['reward_type']=b?.['type_parameter'],!IsValidArgType(this['reward_type'])&&W_ERROR(WErrors['IsValidArgType'],'CallReward_Data.data.object.type\x20invalid');}}async['call'](a){await this['prepare'](a);const b=[],c=[],d=this['content'],e=h=>{this['permission_address']&&!c['includes'](h)&&c['push'](h);};this['permission_address']&&!this['object_address']&&e(BuiltinPermissionIndex['REWARD_NEW']);if(this['data']?.['claim']!=null){const h=await LocalMark['Instance']()['get_address'](this['data']['claim']);if(h){if(d){const i=d['guards']['find'](j=>j['guard']===h);!i&&W_ERROR(WErrors['InvalidParam'],'Guard\x20'+h+'\x20is\x20not\x20fount\x20in\x20reward\x20guards\x20'+d['guards']['map'](j=>j['guard'])),i?.['amount']?.['type']===AmountType['Fixed']&&BigInt(i?.['amount']?.['value'])>BigInt(d['balance'])&&W_ERROR(WErrors['InvalidParam'],'Guard\x20'+h+'\x20amount\x20'+i?.['amount']?.['value']+'\x20is\x20greater\x20than\x20reward\x20balance\x20'+d['balance']);}this['data']['claim']=h,b['push'](h);}else W_ERROR(WErrors['IsValidArgType'],'CallReward_Data.data.claim\x20is\x20not\x20a\x20valid\x20guard\x20address');}this['permission_address']&&this['data']?.['description']!=null&&this['object_address']&&e(BuiltinPermissionIndex['REWARD_DESCRIPTION']);this['permission_address']&&this['data']?.['coin_add']!=null&&e(BuiltinPermissionIndex['REWARD_COIN_ADD']);this['permission_address']&&this['data']?.['receive']!=null&&e(BuiltinPermissionIndex['REWARD_RECEIVE']);this['permission_address']&&this['data']?.['guard_expiration_time']!==undefined&&e(BuiltinPermissionIndex['REWARD_GUARD_EXPIRATION_TIME_ADD']);this['permission_address']&&this['data']?.['guard_add']!=null&&e(BuiltinPermissionIndex['REWARD_GUARD']);this['permission_address']&&this['data']?.['guard_remove_expired']&&e(BuiltinPermissionIndex['DEMAND_GUARD']);this['permission_address']&&this['data']?.['owner_receive']!=null&&e(BuiltinPermissionIndex['REWARD_OWNER_RECEIVE']);this['permission_address']&&this['data']?.['um']!==undefined&&e(BuiltinPermissionIndex['REWARD_UM']);if(this['permission_address']||b['length']>0x0)return await this['check_permission_and_call'](a,this['permission_address'],c,b);return await this['exec'](a);}async['operate'](a,b,c,d){let e=this['permission_address'],f=this['object_address'];const g=this['content'];!this['object_address']&&(!e&&(e=newPermission(b,this['new_permission_description']??'')),e&&this['reward_type']&&(f=newReward(b,this['reward_type'],toTxObject(b,e),this['data']?.['description']??'',c)));(!f||!e||!this['reward_type'])&&W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.object:'+this['object_address']);this['data']?.['claim']!=null&&claim(b,f,this['reward_type'],this['data']['claim'],c);this['data']?.['description']!=null&&this['object_address']&&description_set(b,f,this['reward_type'],e,this['data']['description'],c);this['data']?.['coin_add']!=null&&await coin_add(a,b,f,this['reward_type'],e,this['data']['coin_add'],c);if(this['data']?.['receive']!=null&&this['object_address']){if(this['data']['receive']==='recently'){const h=await query_received({'object':this['object_address'],'network':a['network'],'no_cache':a['no_cache']});Array['isArray'](h)?W_ERROR(WErrors['InvalidParam'],'CallAllocation_Data.data.received_coins:\x20received\x20is\x20ReceivedNormal[]'):this['data']['receive']=h;}if(typeof this['data']['receive']==='object'&&'received'in this['data']['receive']&&this['data']['receive']['received']?.['length']>0x0){this['data']['receive']?.['token_type']!==this['reward_type']&&W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.receive.token_type:'+this['data']['receive']?.['token_type']);for(const i of this['data']['receive']['received']){const [j,k]=await Promise['all']([LocalMark['Instance']()['get_address'](i['id']),LocalMark['Instance']()['get_address'](i['payment'])]);k&&j?receive(b,f,this['reward_type'],e,toTxObject(b,j),toTxObject(b,k),c):W_ERROR(WErrors['InvalidParam'],'Payment\x20object\x20'+i['payment']+'\x20or\x20received\x20object\x20'+i['id']+'\x20is\x20not\x20valid');}}}this['data']?.['guard_add']!=null&&(g&&g['guard_not_added_expiration_time']!=null&&BigInt(g['guard_not_added_expiration_time'])>=BigInt(Date['now']())&&W_ERROR(WErrors['InvalidParam'],'The\x20time\x20lock\x20does\x20not\x20allow\x20the\x20addition\x20of\x20new\x20guards.\x20'+this['data']['guard_expiration_time']+'\x20\x20is\x20before\x20current\x20time\x20'+Date['now']()),this['data']['guard_add']['length']>MAX_GUARD_COUNT&&W_ERROR(WErrors['InvalidParam'],'guard_add\x20count\x20exceeds\x20maximum\x20limit\x20'+MAX_GUARD_COUNT),await Promise['all'](this['data']['guard_add']['map'](l=>guard_add(b,f,this['reward_type'],e,l,c))));this['data']['guard_remove_expired']&&guard_remove_expired(b,f,this['reward_type'],e,c);this['data']?.['guard_expiration_time']!==undefined&&guard_expiration_time_add(b,f,this['reward_type'],e,this['data']['guard_expiration_time'],c);this['data']?.['owner_receive']!=null&&this['object_address']&&(this['data']['owner_receive']==='recently'&&(this['data']['owner_receive']=await query_received({'object':this['object_address'],'all_type':!![],'network':a['network'],'no_cache':a['no_cache']})),await owner_receive(b,f,e,this['data']['owner_receive'],this['reward_type'],l=>PackageAddress+'::reward::'+l,c));if(this['data']['um']!==undefined){let l=null;this['data']['um']&&(l=await LocalMark['Instance']()['get_address'](this['data']['um'])||null,!l&&W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.um:'+this['data']['um'])),um_set(b,f,this['reward_type'],e,l,c);}if(!this['permission_address']){const m=GetObject(this['data']?.['object']);await this['new_with_mark'](a,b,ObjectType['Permission'],a164a(b,e),GetObject(m['permission']));}!this['object_address']&&await this['new_with_mark'](a,b,ObjectType['Reward'],create(b,f,this['reward_type']),GetObject(this['data']?.['object']));}}export const MAX_GUARD_COUNT=0xc8;export const MAX_RECORD_COUNT=0x1450;export function create(a,b,c){return validObjects([b]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Create\x20reward\x20type\x20'+c+'\x20is\x20not\x20valid'),a['moveCall']({'target':rewardFn('create'),'arguments':[toTxObject(a,b)],'typeArguments':[c]});}async function reward_guard(a,b){const c=await LocalMark['Instance']()['get_address'](b['guard']);c?b['guard']=c:W_ERROR(WErrors['InvalidParam'],'Guard\x20'+b['guard']+'\x20is\x20not\x20valid');validObjects([b['guard']]);if('GuardIdentifier'in b['recipient']){const d=b['recipient']['GuardIdentifier'];typeof d!=='number'&&W_ERROR(WErrors['InvalidParam'],'Recipient\x20GuardIdentifier\x20'+d+'\x20must\x20be\x20a\x20number');!isValidU8(d)&&W_ERROR(WErrors['InvalidParam'],'Recipient\x20GuardIdentifier\x20'+d+'\x20must\x20be\x20a\x20valid\x20u8');if(b['amount']['type']===AmountType['GuardU64Identifier'])return typeof b['amount']['value']!=='number'&&W_ERROR(WErrors['InvalidParam'],'Amount\x20GuardU64Identifier\x20value\x20must\x20be\x20a\x20number'),!isValidU8(b['amount']['value'])&&W_ERROR(WErrors['InvalidParam'],'Amount\x20GuardU64Identifier\x20'+b['amount']['value']+'\x20must\x20be\x20a\x20valid\x20u8'),a['moveCall']({'target':rewardFn('guard_u8_u8'),'arguments':[toTxObject(a,b['guard']),a['pure']['u8'](d),a['pure']['u8'](b['amount']['value']),a['pure']['option']('u64',b['expiration_time']??null),a['pure']['option']('u8',b['store_from_id']??null)]});else{if(b['amount']['type']===AmountType['Fixed'])return typeof b['amount']['value']!=='number'&&W_ERROR(WErrors['InvalidParam'],'Amount\x20Fixed\x20value\x20must\x20be\x20a\x20number'),!isValidU64(b['amount']['value'])&&W_ERROR(WErrors['InvalidParam'],'Amount\x20Fixed\x20'+b['amount']['value']+'\x20must\x20be\x20a\x20valid\x20u64'),a['moveCall']({'target':rewardFn('guard_u8_u64'),'arguments':[toTxObject(a,b['guard']),a['pure']['u8'](d),a['pure']['u64'](b['amount']['value']),a['pure']['option']('u64',b['expiration_time']??null),a['pure']['option']('u8',b['store_from_id']??null)]});}}else{if('Entity'in b['recipient']){const e=b['recipient']['Entity'],f=await GetAccountOrMark_Address(e);!f&&W_ERROR(WErrors['InvalidParam'],'Recipient\x20Entity\x20'+e+'\x20must\x20be\x20a\x20valid\x20address');if(b['amount']['type']===AmountType['GuardU64Identifier'])return typeof b['amount']['value']!=='number'&&W_ERROR(WErrors['InvalidParam'],'Amount\x20GuardU64Identifier\x20value\x20must\x20be\x20a\x20number'),!isValidU8(b['amount']['value'])&&W_ERROR(WErrors['InvalidParam'],'Amount\x20GuardU64Identifier\x20'+b['amount']['value']+'\x20must\x20be\x20a\x20valid\x20u8'),a['moveCall']({'target':rewardFn('guard_entity_u8'),'arguments':[toTxObject(a,b['guard']),a['pure']['address'](f),a['pure']['u8'](b['amount']['value']),a['pure']['option']('u64',b['expiration_time']??null),a['pure']['option']('u8',b['store_from_id']??null)]});else{if(b['amount']['type']===AmountType['Fixed'])return typeof b['amount']['value']!=='number'&&W_ERROR(WErrors['InvalidParam'],'Amount\x20Fixed\x20value\x20must\x20be\x20a\x20number'),!isValidU64(b['amount']['value'])&&W_ERROR(WErrors['InvalidParam'],'Amount\x20Fixed\x20'+b['amount']['value']+'\x20must\x20be\x20a\x20valid\x20u64'),a['moveCall']({'target':rewardFn('guard_entity_u64'),'arguments':[toTxObject(a,b['guard']),a['pure']['address'](f),a['pure']['u64'](b['amount']['value']),a['pure']['option']('u64',b['expiration_time']??null),a['pure']['option']('u8',b['store_from_id']??null)]});}}else{if('Signer'in b['recipient']){if(b['amount']['type']===AmountType['GuardU64Identifier'])return typeof b['amount']['value']!=='number'&&W_ERROR(WErrors['InvalidParam'],'Amount\x20GuardU64Identifier\x20value\x20must\x20be\x20a\x20number'),!isValidU8(b['amount']['value'])&&W_ERROR(WErrors['InvalidParam'],'Amount\x20GuardU64Identifier\x20'+b['amount']['value']+'\x20must\x20be\x20a\x20valid\x20u8'),a['moveCall']({'target':rewardFn('guard_signer_u8'),'arguments':[toTxObject(a,b['guard']),a['pure']['u8'](b['amount']['value']),a['pure']['option']('u64',b['expiration_time']??null),a['pure']['option']('u8',b['store_from_id']??null)]});else{if(b['amount']['type']===AmountType['Fixed'])return typeof b['amount']['value']!=='number'&&W_ERROR(WErrors['InvalidParam'],'Amount\x20Fixed\x20value\x20must\x20be\x20a\x20number'),!isValidU64(b['amount']['value'])&&W_ERROR(WErrors['InvalidParam'],'Amount\x20Fixed\x20'+b['amount']['value']+'\x20must\x20be\x20a\x20valid\x20u64'),a['moveCall']({'target':rewardFn('guard_signer_u64'),'arguments':[toTxObject(a,b['guard']),a['pure']['u64'](b['amount']['value']),a['pure']['option']('u64',b['expiration_time']??null),a['pure']['option']('u8',b['store_from_id']??null)]});}}}}return W_ERROR(WErrors['InvalidParam'],'Invalid\x20recipient\x20or\x20amount\x20type\x20combination'),undefined;}export function claim(a,b,c,d,e){return!e&&W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.claim:\x20passport\x20is\x20required'),validObjects([b,e,d]),!IsValidArgType(c)&&W_ERROR(WErrors['IsValidArgType'],'Invalid\x20reward\x20type\x20'+c),a['moveCall']({'target':rewardFn('claim'),'arguments':[toTxObject(a,b),toTxObject(a,e),toTxObject(a,d),a['object']['clock']()],'typeArguments':[c]});}export function newReward(a,b,c,d,e){return validObjects([c,e]),!IsValidArgType(b)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+b),typeof d==='string'&&!isValidDescription(d)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),e?a['moveCall']({'target':rewardFn('new_with_passport'),'arguments':[toTxObject(a,c),toTxObject(a,e),toTxString(a,d),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[b]}):a['moveCall']({'target':rewardFn('new'),'arguments':[toTxObject(a,c),toTxString(a,d),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[b]});}export function description_set(a,b,c,d,e,f){validObjects([b,d,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+c),typeof e==='string'&&!isValidDescription(e)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),f?a['moveCall']({'target':rewardFn('description_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),toTxString(a,e)],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('description_set'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxString(a,e)],'typeArguments':[c]});}export async function guard_add(a,b,c,d,e,f){validObjects([b,d,f]);!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+c);const g=await reward_guard(a,e);!g&&W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.guard_add\x20'+e+'\x20failed'),f?a['moveCall']({'target':rewardFn('guard_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),g,a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('guard_add'),'arguments':[toTxObject(a,b),toTxObject(a,d),g,a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]});}export function guard_remove_expired(a,b,c,d,e){validObjects([b,d,e]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+c),e?a['moveCall']({'target':rewardFn('guard_remove_expired_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('guard_remove_expired'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]});}export async function coin_add(a,b,d,e,f,g,h){validObjects([d,f,h]);!IsValidArgType(e)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+e);const i=await getCoinParam(a,b,g,e);h?b['moveCall']({'target':rewardFn('coin_add_with_passport'),'arguments':[toTxObject(b,d),toTxObject(b,f),toTxObject(b,h),i],'typeArguments':[e]}):b['moveCall']({'target':rewardFn('coin_add'),'arguments':[toTxObject(b,d),toTxObject(b,f),i],'typeArguments':[e]});}export function receive(a,b,c,d,e,f,g){return validObjects([b,d,g,e,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+c),g?a['moveCall']({'target':rewardFn('receive_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,g),toTxObject(a,e),toTxObject(a,f)],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('receive'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),toTxObject(a,f)],'typeArguments':[c]});}export function guard_expiration_time_add(a,b,c,d,e,f){validObjects([b,d,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+c),f?a['moveCall']({'target':rewardFn('guard_expiration_time_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['pure']['option']('u64',e??null),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('guard_expiration_time_add'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['pure']['option']('u64',e??null),a['object']['clock']()],'typeArguments':[c]});}export function um_set(a,b,c,d,e,f){validObjects([b,d]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+c),e?f?a['moveCall']({'target':rewardFn('um_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),f,toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('um_set'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):f?a['moveCall']({'target':rewardFn('um_none_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),f,a['object']['mutRegistrar']()],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('um_none'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['object']['mutRegistrar']()],'typeArguments':[c]});}
1
+ import{toTxObject,toTxString,isValidDescription,MAX_DESCRIPTION_LENGTH,isValidU8,PackageAddress,isValidU64,IsValidArgType,rewardFn}from'../common.js';import{W_ERROR,WErrors}from'../exception.js';import{parseObjectType,validObjects}from'../util.js';import{GetObjectExisted,GetObject,GetObjectDescription}from'../common.js';import{LocalMark}from'../local/local.js';import{CallBase,getCoinParam}from'./base.js';import{BuiltinPermissionIndex,newPermission}from'./permission.js';import{owner_receive}from'../util.js';import{AmountType,ObjectType}from'../query/object.js';import{GetAccountOrMark_Address}from'../local/index.js';import{create as a164a}from'./permission.js';import{query_received}from'../query/received.js';export class CallReward extends CallBase{['data'];['object_address']=undefined;['permission_address']=undefined;['new_permission_description']=undefined;['reward_type']=undefined;constructor(a){super(),this['data']=a;}async['prepare'](a){await super['prepare'](a);!this['object_address']&&(this['object_address']=await GetObjectExisted(this['data']?.['object']));if(this['object_address']){this['content']=undefined,await this['update_content'](a,ObjectType['Reward'],this['object_address']);if(!this['content'])W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.object:'+this['object_address']);this['permission_address']=this['content']['permission'],this['reward_type']=parseObjectType(this['content']['type_raw'],'reward::Reward'),!this['permission_address']&&W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.object.permission\x20is\x20empty'),!IsValidArgType(this['reward_type'])&&W_ERROR(WErrors['IsValidArgType'],'CallReward_Data.data.object.type_parameter\x20is\x20empty');}else{const b=GetObject(this['data']['object']);this['permission_address']=await GetObjectExisted(b?.['permission']),this['new_permission_description']=GetObjectDescription(b?.['permission']),this['reward_type']=b?.['type_parameter'],!IsValidArgType(this['reward_type'])&&W_ERROR(WErrors['IsValidArgType'],'CallReward_Data.data.object.type\x20invalid');}}async['call'](a){await this['prepare'](a);const b=[],c=[],d=this['content'],e=h=>{this['permission_address']&&!c['includes'](h)&&c['push'](h);};this['permission_address']&&!this['object_address']&&e(BuiltinPermissionIndex['REWARD_NEW']);if(this['data']?.['claim']!=null){const h=await LocalMark['Instance']()['get_address'](this['data']['claim']);if(h){if(d){const i=d['guards']['find'](j=>j['guard']===h);!i&&W_ERROR(WErrors['InvalidParam'],'Guard\x20'+h+'\x20is\x20not\x20fount\x20in\x20reward\x20guards\x20'+d['guards']['map'](j=>j['guard'])),i?.['amount']?.['type']===AmountType['Fixed']&&BigInt(i?.['amount']?.['value'])>BigInt(d['balance'])&&W_ERROR(WErrors['InvalidParam'],'Guard\x20'+h+'\x20amount\x20'+i?.['amount']?.['value']+'\x20is\x20greater\x20than\x20reward\x20balance\x20'+d['balance']);}this['data']['claim']=h,b['push'](h);}else W_ERROR(WErrors['IsValidArgType'],'CallReward_Data.data.claim\x20is\x20not\x20a\x20valid\x20guard\x20address');}this['permission_address']&&this['data']?.['description']!=null&&this['object_address']&&e(BuiltinPermissionIndex['REWARD_DESCRIPTION']);this['permission_address']&&this['data']?.['coin_add']!=null&&e(BuiltinPermissionIndex['REWARD_COIN_ADD']);this['permission_address']&&this['data']?.['receive']!=null&&e(BuiltinPermissionIndex['REWARD_RECEIVE']);this['permission_address']&&this['data']?.['guard_expiration_time']!==undefined&&e(BuiltinPermissionIndex['REWARD_GUARD_EXPIRATION_TIME_ADD']);this['permission_address']&&this['data']?.['guard_add']!=null&&e(BuiltinPermissionIndex['REWARD_GUARD']);this['permission_address']&&this['data']?.['guard_remove_expired']&&e(BuiltinPermissionIndex['DEMAND_GUARD']);this['permission_address']&&this['data']?.['owner_receive']!=null&&e(BuiltinPermissionIndex['REWARD_OWNER_RECEIVE']);this['permission_address']&&this['data']?.['um']!==undefined&&e(BuiltinPermissionIndex['REWARD_UM']);if(this['permission_address']||b['length']>0x0)return await this['check_permission_and_call'](a,this['permission_address'],c,b);return await this['exec'](a);}async['operate'](a,b,c,d){let e=this['permission_address'],f=this['object_address'];const g=this['content'];!this['object_address']&&(!e&&(e=newPermission(b,this['new_permission_description']??'')),e&&this['reward_type']&&(f=newReward(b,this['reward_type'],toTxObject(b,e),this['data']?.['description']??'',c)));(!f||!e||!this['reward_type'])&&W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.object:'+this['object_address']);this['data']?.['claim']!=null&&claim(b,f,this['reward_type'],this['data']['claim'],c);this['data']?.['description']!=null&&this['object_address']&&description_set(b,f,this['reward_type'],e,this['data']['description'],c);this['data']?.['coin_add']!=null&&await coin_add(a,b,f,this['reward_type'],e,this['data']['coin_add'],c);if(this['data']?.['receive']!=null&&this['object_address']){if(this['data']['receive']==='recently'){const h=await query_received({'name_or_address':{'name_or_address':this['object_address'],'local_mark_first':!![]},'all_type':!![],'network':a['network'],'no_cache':a['no_cache']});Array['isArray'](h)?W_ERROR(WErrors['InvalidParam'],'CallAllocation_Data.data.received_coins:\x20received\x20is\x20ReceivedNormal[]'):this['data']['receive']=h;}if(typeof this['data']['receive']==='object'&&'received'in this['data']['receive']&&this['data']['receive']['received']?.['length']>0x0){this['data']['receive']?.['token_type']!==this['reward_type']&&W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.receive.token_type:'+this['data']['receive']?.['token_type']);for(const i of this['data']['receive']['received']){const [j,k]=await Promise['all']([LocalMark['Instance']()['get_address'](i['id']),LocalMark['Instance']()['get_address'](i['payment'])]);k&&j?receive(b,f,this['reward_type'],e,toTxObject(b,j),toTxObject(b,k),c):W_ERROR(WErrors['InvalidParam'],'Payment\x20object\x20'+i['payment']+'\x20or\x20received\x20object\x20'+i['id']+'\x20is\x20not\x20valid');}}}this['data']?.['guard_add']!=null&&(g&&g['guard_not_added_expiration_time']!=null&&BigInt(g['guard_not_added_expiration_time'])>=BigInt(Date['now']())&&W_ERROR(WErrors['InvalidParam'],'The\x20time\x20lock\x20does\x20not\x20allow\x20the\x20addition\x20of\x20new\x20guards.\x20'+this['data']['guard_expiration_time']+'\x20\x20is\x20before\x20current\x20time\x20'+Date['now']()),this['data']['guard_add']['length']>MAX_GUARD_COUNT&&W_ERROR(WErrors['InvalidParam'],'guard_add\x20count\x20exceeds\x20maximum\x20limit\x20'+MAX_GUARD_COUNT),await Promise['all'](this['data']['guard_add']['map'](l=>guard_add(b,f,this['reward_type'],e,l,c))));this['data']['guard_remove_expired']&&guard_remove_expired(b,f,this['reward_type'],e,c);this['data']?.['guard_expiration_time']!==undefined&&guard_expiration_time_add(b,f,this['reward_type'],e,this['data']['guard_expiration_time'],c);this['data']?.['owner_receive']!=null&&this['object_address']&&(this['data']['owner_receive']==='recently'&&(this['data']['owner_receive']=await query_received({'name_or_address':{'name_or_address':this['object_address'],'local_mark_first':!![]},'all_type':!![],'network':a['network'],'no_cache':a['no_cache']})),await owner_receive(b,f,e,this['data']['owner_receive'],this['reward_type'],l=>PackageAddress+'::reward::'+l,c));if(this['data']['um']!==undefined){let l=null;this['data']['um']&&(l=await LocalMark['Instance']()['get_address'](this['data']['um'])||null,!l&&W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.um:'+this['data']['um'])),um_set(b,f,this['reward_type'],e,l,c);}if(!this['permission_address']){const m=GetObject(this['data']?.['object']);await this['new_with_mark'](a,b,ObjectType['Permission'],a164a(b,e),GetObject(m['permission']));}!this['object_address']&&await this['new_with_mark'](a,b,ObjectType['Reward'],create(b,f,this['reward_type']),GetObject(this['data']?.['object']));}}export const MAX_GUARD_COUNT=0xc8;export const MAX_RECORD_COUNT=0x1450;export function create(a,b,c){return validObjects([b]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Create\x20reward\x20type\x20'+c+'\x20is\x20not\x20valid'),a['moveCall']({'target':rewardFn('create'),'arguments':[toTxObject(a,b)],'typeArguments':[c]});}async function reward_guard(a,b){const c=await LocalMark['Instance']()['get_address'](b['guard']);c?b['guard']=c:W_ERROR(WErrors['InvalidParam'],'Guard\x20'+b['guard']+'\x20is\x20not\x20valid');validObjects([b['guard']]);if('GuardIdentifier'in b['recipient']){const d=b['recipient']['GuardIdentifier'];typeof d!=='number'&&W_ERROR(WErrors['InvalidParam'],'Recipient\x20GuardIdentifier\x20'+d+'\x20must\x20be\x20a\x20number');!isValidU8(d)&&W_ERROR(WErrors['InvalidParam'],'Recipient\x20GuardIdentifier\x20'+d+'\x20must\x20be\x20a\x20valid\x20u8');if(b['amount']['type']===AmountType['GuardU64Identifier'])return typeof b['amount']['value']!=='number'&&W_ERROR(WErrors['InvalidParam'],'Amount\x20GuardU64Identifier\x20value\x20must\x20be\x20a\x20number'),!isValidU8(b['amount']['value'])&&W_ERROR(WErrors['InvalidParam'],'Amount\x20GuardU64Identifier\x20'+b['amount']['value']+'\x20must\x20be\x20a\x20valid\x20u8'),a['moveCall']({'target':rewardFn('guard_u8_u8'),'arguments':[toTxObject(a,b['guard']),a['pure']['u8'](d),a['pure']['u8'](b['amount']['value']),a['pure']['option']('u64',b['expiration_time']??null),a['pure']['option']('u8',b['store_from_id']??null)]});else{if(b['amount']['type']===AmountType['Fixed'])return typeof b['amount']['value']!=='number'&&W_ERROR(WErrors['InvalidParam'],'Amount\x20Fixed\x20value\x20must\x20be\x20a\x20number'),!isValidU64(b['amount']['value'])&&W_ERROR(WErrors['InvalidParam'],'Amount\x20Fixed\x20'+b['amount']['value']+'\x20must\x20be\x20a\x20valid\x20u64'),a['moveCall']({'target':rewardFn('guard_u8_u64'),'arguments':[toTxObject(a,b['guard']),a['pure']['u8'](d),a['pure']['u64'](b['amount']['value']),a['pure']['option']('u64',b['expiration_time']??null),a['pure']['option']('u8',b['store_from_id']??null)]});}}else{if('Entity'in b['recipient']){const e=b['recipient']['Entity'],f=await GetAccountOrMark_Address(e);!f&&W_ERROR(WErrors['InvalidParam'],'Recipient\x20Entity\x20'+e+'\x20must\x20be\x20a\x20valid\x20address');if(b['amount']['type']===AmountType['GuardU64Identifier'])return typeof b['amount']['value']!=='number'&&W_ERROR(WErrors['InvalidParam'],'Amount\x20GuardU64Identifier\x20value\x20must\x20be\x20a\x20number'),!isValidU8(b['amount']['value'])&&W_ERROR(WErrors['InvalidParam'],'Amount\x20GuardU64Identifier\x20'+b['amount']['value']+'\x20must\x20be\x20a\x20valid\x20u8'),a['moveCall']({'target':rewardFn('guard_entity_u8'),'arguments':[toTxObject(a,b['guard']),a['pure']['address'](f),a['pure']['u8'](b['amount']['value']),a['pure']['option']('u64',b['expiration_time']??null),a['pure']['option']('u8',b['store_from_id']??null)]});else{if(b['amount']['type']===AmountType['Fixed'])return typeof b['amount']['value']!=='number'&&W_ERROR(WErrors['InvalidParam'],'Amount\x20Fixed\x20value\x20must\x20be\x20a\x20number'),!isValidU64(b['amount']['value'])&&W_ERROR(WErrors['InvalidParam'],'Amount\x20Fixed\x20'+b['amount']['value']+'\x20must\x20be\x20a\x20valid\x20u64'),a['moveCall']({'target':rewardFn('guard_entity_u64'),'arguments':[toTxObject(a,b['guard']),a['pure']['address'](f),a['pure']['u64'](b['amount']['value']),a['pure']['option']('u64',b['expiration_time']??null),a['pure']['option']('u8',b['store_from_id']??null)]});}}else{if('Signer'in b['recipient']){if(b['amount']['type']===AmountType['GuardU64Identifier'])return typeof b['amount']['value']!=='number'&&W_ERROR(WErrors['InvalidParam'],'Amount\x20GuardU64Identifier\x20value\x20must\x20be\x20a\x20number'),!isValidU8(b['amount']['value'])&&W_ERROR(WErrors['InvalidParam'],'Amount\x20GuardU64Identifier\x20'+b['amount']['value']+'\x20must\x20be\x20a\x20valid\x20u8'),a['moveCall']({'target':rewardFn('guard_signer_u8'),'arguments':[toTxObject(a,b['guard']),a['pure']['u8'](b['amount']['value']),a['pure']['option']('u64',b['expiration_time']??null),a['pure']['option']('u8',b['store_from_id']??null)]});else{if(b['amount']['type']===AmountType['Fixed'])return typeof b['amount']['value']!=='number'&&W_ERROR(WErrors['InvalidParam'],'Amount\x20Fixed\x20value\x20must\x20be\x20a\x20number'),!isValidU64(b['amount']['value'])&&W_ERROR(WErrors['InvalidParam'],'Amount\x20Fixed\x20'+b['amount']['value']+'\x20must\x20be\x20a\x20valid\x20u64'),a['moveCall']({'target':rewardFn('guard_signer_u64'),'arguments':[toTxObject(a,b['guard']),a['pure']['u64'](b['amount']['value']),a['pure']['option']('u64',b['expiration_time']??null),a['pure']['option']('u8',b['store_from_id']??null)]});}}}}return W_ERROR(WErrors['InvalidParam'],'Invalid\x20recipient\x20or\x20amount\x20type\x20combination'),undefined;}export function claim(a,b,c,d,e){return!e&&W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.claim:\x20passport\x20is\x20required'),validObjects([b,e,d]),!IsValidArgType(c)&&W_ERROR(WErrors['IsValidArgType'],'Invalid\x20reward\x20type\x20'+c),a['moveCall']({'target':rewardFn('claim'),'arguments':[toTxObject(a,b),toTxObject(a,e),toTxObject(a,d),a['object']['clock']()],'typeArguments':[c]});}export function newReward(a,b,c,d,e){return validObjects([c,e]),!IsValidArgType(b)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+b),typeof d==='string'&&!isValidDescription(d)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),e?a['moveCall']({'target':rewardFn('new_with_passport'),'arguments':[toTxObject(a,c),toTxObject(a,e),toTxString(a,d),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[b]}):a['moveCall']({'target':rewardFn('new'),'arguments':[toTxObject(a,c),toTxString(a,d),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[b]});}export function description_set(a,b,c,d,e,f){validObjects([b,d,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+c),typeof e==='string'&&!isValidDescription(e)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),f?a['moveCall']({'target':rewardFn('description_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),toTxString(a,e)],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('description_set'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxString(a,e)],'typeArguments':[c]});}export async function guard_add(a,b,c,d,e,f){validObjects([b,d,f]);!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+c);const g=await reward_guard(a,e);!g&&W_ERROR(WErrors['InvalidParam'],'CallReward_Data.data.guard_add\x20'+e+'\x20failed'),f?a['moveCall']({'target':rewardFn('guard_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),g,a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('guard_add'),'arguments':[toTxObject(a,b),toTxObject(a,d),g,a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]});}export function guard_remove_expired(a,b,c,d,e){validObjects([b,d,e]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+c),e?a['moveCall']({'target':rewardFn('guard_remove_expired_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('guard_remove_expired'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]});}export async function coin_add(a,b,d,e,f,g,h){validObjects([d,f,h]);!IsValidArgType(e)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+e);const i=await getCoinParam(a,b,g,e);h?b['moveCall']({'target':rewardFn('coin_add_with_passport'),'arguments':[toTxObject(b,d),toTxObject(b,f),toTxObject(b,h),i],'typeArguments':[e]}):b['moveCall']({'target':rewardFn('coin_add'),'arguments':[toTxObject(b,d),toTxObject(b,f),i],'typeArguments':[e]});}export function receive(a,b,c,d,e,f,g){return validObjects([b,d,g,e,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+c),g?a['moveCall']({'target':rewardFn('receive_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,g),toTxObject(a,e),toTxObject(a,f)],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('receive'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),toTxObject(a,f)],'typeArguments':[c]});}export function guard_expiration_time_add(a,b,c,d,e,f){validObjects([b,d,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+c),f?a['moveCall']({'target':rewardFn('guard_expiration_time_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['pure']['option']('u64',e??null),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('guard_expiration_time_add'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['pure']['option']('u64',e??null),a['object']['clock']()],'typeArguments':[c]});}export function um_set(a,b,c,d,e,f){validObjects([b,d]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Invalid\x20reward\x20type\x20'+c),e?f?a['moveCall']({'target':rewardFn('um_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),f,toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('um_set'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):f?a['moveCall']({'target':rewardFn('um_none_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),f,a['object']['mutRegistrar']()],'typeArguments':[c]}):a['moveCall']({'target':rewardFn('um_none'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['object']['mutRegistrar']()],'typeArguments':[c]});}