wowok 2.1.40 → 2.1.41

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 (399) hide show
  1. package/dist/cjs/bcs/bcs.js +1 -253
  2. package/dist/cjs/bcs/effects.js +1 -199
  3. package/dist/cjs/bcs/index.js +1 -51
  4. package/dist/cjs/bcs/pure.js +1 -36
  5. package/dist/cjs/bcs/type-tag-serializer.js +1 -104
  6. package/dist/cjs/bcs/types.js +1 -3
  7. package/dist/cjs/client/index.js +1 -4
  8. package/dist/cjs/client/network.js +1 -15
  9. package/dist/cjs/cryptography/index.js +1 -6
  10. package/dist/cjs/cryptography/intent.js +1 -14
  11. package/dist/cjs/cryptography/keypair.js +1 -74
  12. package/dist/cjs/cryptography/mnemonics.js +1 -20
  13. package/dist/cjs/cryptography/publickey.js +1 -80
  14. package/dist/cjs/cryptography/signature-scheme.js +1 -22
  15. package/dist/cjs/cryptography/signature.js +1 -41
  16. package/dist/cjs/experimental/cache.js +1 -58
  17. package/dist/cjs/experimental/client.js +1 -19
  18. package/dist/cjs/experimental/core.js +1 -80
  19. package/dist/cjs/experimental/errors.js +1 -24
  20. package/dist/cjs/experimental/index.js +1 -5
  21. package/dist/cjs/experimental/persistent-storage.js +1 -220
  22. package/dist/cjs/experimental/persistent-storage.test.js +1 -144
  23. package/dist/cjs/experimental/transports/utils.js +1 -96
  24. package/dist/cjs/experimental/types.js +1 -1
  25. package/dist/cjs/faucet/faucet.js +1 -99
  26. package/dist/cjs/faucet/index.js +1 -1
  27. package/dist/cjs/grpc/client.js +1 -42
  28. package/dist/cjs/grpc/core.js +1 -587
  29. package/dist/cjs/grpc/index.js +1 -2
  30. package/dist/cjs/grpc/proto/google/protobuf/any.js +1 -106
  31. package/dist/cjs/grpc/proto/google/protobuf/duration.js +1 -58
  32. package/dist/cjs/grpc/proto/google/protobuf/empty.js +1 -7
  33. package/dist/cjs/grpc/proto/google/protobuf/field_mask.js +1 -47
  34. package/dist/cjs/grpc/proto/google/protobuf/struct.js +1 -191
  35. package/dist/cjs/grpc/proto/google/protobuf/timestamp.js +1 -91
  36. package/dist/cjs/grpc/proto/google/rpc/error_details.js +1 -265
  37. package/dist/cjs/grpc/proto/google/rpc/status.js +1 -23
  38. package/dist/cjs/grpc/proto/sui/rpc/v2/argument.js +1 -46
  39. package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.js +1 -29
  40. package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.js +1 -22
  41. package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.js +1 -54
  42. package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.js +1 -60
  43. package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.js +1 -144
  44. package/dist/cjs/grpc/proto/sui/rpc/v2/effects.js +1 -271
  45. package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.js +1 -64
  46. package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.js +1 -6
  47. package/dist/cjs/grpc/proto/sui/rpc/v2/event.js +1 -62
  48. package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.js +1 -64
  49. package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.js +1 -481
  50. package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.js +1 -40
  51. package/dist/cjs/grpc/proto/sui/rpc/v2/input.js +1 -61
  52. package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.js +1 -57
  53. package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.js +1 -39
  54. package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.js +1 -329
  55. package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.js +1 -447
  56. package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.js +1 -27
  57. package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.js +1 -206
  58. package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.js +1 -19
  59. package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.js +1 -109
  60. package/dist/cjs/grpc/proto/sui/rpc/v2/object.js +1 -90
  61. package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.js +1 -30
  62. package/dist/cjs/grpc/proto/sui/rpc/v2/owner.js +1 -39
  63. package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.js +1 -30
  64. package/dist/cjs/grpc/proto/sui/rpc/v2/signature.js +1 -501
  65. package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.js +1 -10
  66. package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +1 -15
  67. package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.js +1 -62
  68. package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.js +1 -31
  69. package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.js +1 -504
  70. package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.js +1 -15
  71. package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.js +1 -37
  72. package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.js +1 -709
  73. package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.js +1 -950
  74. package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +1 -19
  75. package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.js +1 -144
  76. package/dist/cjs/index.js +1 -22
  77. package/dist/cjs/jsonRpc/client.js +1 -516
  78. package/dist/cjs/jsonRpc/core.js +1 -587
  79. package/dist/cjs/jsonRpc/errors.js +1 -38
  80. package/dist/cjs/jsonRpc/http-transport.js +1 -70
  81. package/dist/cjs/jsonRpc/index.js +1 -3
  82. package/dist/cjs/jsonRpc/json-rpc-resolver.js +1 -296
  83. package/dist/cjs/jsonRpc/rpc-websocket-client.js +1 -155
  84. package/dist/cjs/jsonRpc/types/chain.js +1 -1
  85. package/dist/cjs/jsonRpc/types/changes.js +1 -1
  86. package/dist/cjs/jsonRpc/types/coins.js +1 -1
  87. package/dist/cjs/jsonRpc/types/common.js +1 -1
  88. package/dist/cjs/jsonRpc/types/generated.js +1 -1
  89. package/dist/cjs/jsonRpc/types/index.js +1 -1
  90. package/dist/cjs/jsonRpc/types/params.js +1 -1
  91. package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +1 -58
  92. package/dist/cjs/keypairs/ed25519/index.js +1 -2
  93. package/dist/cjs/keypairs/ed25519/keypair.js +1 -90
  94. package/dist/cjs/keypairs/ed25519/publickey.js +1 -50
  95. package/dist/cjs/keypairs/index.js +1 -4
  96. package/dist/cjs/keypairs/passkey/index.js +1 -2
  97. package/dist/cjs/keypairs/passkey/keypair.js +1 -155
  98. package/dist/cjs/keypairs/passkey/publickey.js +1 -117
  99. package/dist/cjs/keypairs/passkey/types.js +1 -1
  100. package/dist/cjs/keypairs/secp256k1/index.js +1 -2
  101. package/dist/cjs/keypairs/secp256k1/keypair.js +1 -82
  102. package/dist/cjs/keypairs/secp256k1/publickey.js +1 -51
  103. package/dist/cjs/keypairs/secp256r1/index.js +1 -2
  104. package/dist/cjs/keypairs/secp256r1/keypair.js +1 -78
  105. package/dist/cjs/keypairs/secp256r1/publickey.js +1 -52
  106. package/dist/cjs/multisig/index.js +1 -2
  107. package/dist/cjs/multisig/publickey.js +1 -201
  108. package/dist/cjs/multisig/signer.js +1 -58
  109. package/dist/cjs/transactions/Arguments.js +1 -9
  110. package/dist/cjs/transactions/Commands.js +1 -102
  111. package/dist/cjs/transactions/Inputs.js +1 -52
  112. package/dist/cjs/transactions/ObjectCache.js +1 -205
  113. package/dist/cjs/transactions/Transaction.js +1 -574
  114. package/dist/cjs/transactions/TransactionData.js +1 -409
  115. package/dist/cjs/transactions/__tests__/Transaction.test.js +1 -160
  116. package/dist/cjs/transactions/__tests__/bcs.test.js +1 -182
  117. package/dist/cjs/transactions/data/internal.js +1 -169
  118. package/dist/cjs/transactions/data/v1.js +1 -469
  119. package/dist/cjs/transactions/data/v2.js +1 -97
  120. package/dist/cjs/transactions/executor/caching.js +1 -65
  121. package/dist/cjs/transactions/executor/parallel.js +1 -347
  122. package/dist/cjs/transactions/executor/queue.js +1 -59
  123. package/dist/cjs/transactions/executor/serial.js +1 -99
  124. package/dist/cjs/transactions/hash.js +1 -8
  125. package/dist/cjs/transactions/index.js +1 -12
  126. package/dist/cjs/transactions/intents/CoinWithBalance.js +1 -145
  127. package/dist/cjs/transactions/object.js +1 -87
  128. package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js +1 -11
  129. package/dist/cjs/transactions/pure.js +1 -36
  130. package/dist/cjs/transactions/resolve.js +1 -69
  131. package/dist/cjs/transactions/serializer.js +1 -167
  132. package/dist/cjs/transactions/utils.js +1 -121
  133. package/dist/cjs/utils/constants.js +1 -18
  134. package/dist/cjs/utils/derived-objects.js +1 -8
  135. package/dist/cjs/utils/dynamic-fields.js +1 -17
  136. package/dist/cjs/utils/format.js +1 -11
  137. package/dist/cjs/utils/index.js +1 -8
  138. package/dist/cjs/utils/move-registry.js +1 -24
  139. package/dist/cjs/utils/sui-types.js +1 -66
  140. package/dist/cjs/utils/suins.js +1 -33
  141. package/dist/cjs/verify/index.js +1 -1
  142. package/dist/cjs/verify/verify.js +1 -87
  143. package/dist/cjs/version.js +1 -2
  144. package/dist/cjs/w/call/allocation.js +1 -345
  145. package/dist/cjs/w/call/arb.js +1 -103
  146. package/dist/cjs/w/call/arbitration.js +1 -1192
  147. package/dist/cjs/w/call/base.js +1 -293
  148. package/dist/cjs/w/call/contact.js +1 -345
  149. package/dist/cjs/w/call/demand.js +1 -681
  150. package/dist/cjs/w/call/entity.js +1 -173
  151. package/dist/cjs/w/call/guard-ins.js +1 -4449
  152. package/dist/cjs/w/call/guard.d.ts +111 -0
  153. package/dist/cjs/w/call/guard.js +1 -1048
  154. package/dist/cjs/w/call/index.js +1 -22
  155. package/dist/cjs/w/call/machine.js +1 -1127
  156. package/dist/cjs/w/call/order.js +1 -337
  157. package/dist/cjs/w/call/passport.js +1 -220
  158. package/dist/cjs/w/call/payment.js +1 -178
  159. package/dist/cjs/w/call/permission.js +1 -1162
  160. package/dist/cjs/w/call/personal.js +1 -139
  161. package/dist/cjs/w/call/progress.js +1 -678
  162. package/dist/cjs/w/call/proof.js +1 -66
  163. package/dist/cjs/w/call/repository.js +1 -1024
  164. package/dist/cjs/w/call/resource.js +1 -108
  165. package/dist/cjs/w/call/reward.js +1 -675
  166. package/dist/cjs/w/call/service.js +1 -1960
  167. package/dist/cjs/w/call/treasury.js +1 -873
  168. package/dist/cjs/w/call/util.d.ts +1 -0
  169. package/dist/cjs/w/call/util.js +1 -566
  170. package/dist/cjs/w/common.js +1 -571
  171. package/dist/cjs/w/exception.js +1 -618
  172. package/dist/cjs/w/index.js +1 -8
  173. package/dist/cjs/w/local/account.js +1 -656
  174. package/dist/cjs/w/local/cache.js +1 -161
  175. package/dist/cjs/w/local/config.js +1 -43
  176. package/dist/cjs/w/local/index.js +1 -228
  177. package/dist/cjs/w/local/local.js +1 -574
  178. package/dist/cjs/w/local/storage.js +1 -185
  179. package/dist/cjs/w/local/token.js +1 -131
  180. package/dist/cjs/w/local/util.js +1 -26
  181. package/dist/cjs/w/local/wip.js +1 -864
  182. package/dist/cjs/w/messenger/crypto.js +1 -380
  183. package/dist/cjs/w/messenger/index.js +1 -4
  184. package/dist/cjs/w/messenger/messenger-api.js +1 -1154
  185. package/dist/cjs/w/messenger/messenger-manager.js +1 -1003
  186. package/dist/cjs/w/messenger/messenger.js +1 -1093
  187. package/dist/cjs/w/messenger/server.js +1 -343
  188. package/dist/cjs/w/messenger/session.js +1 -628
  189. package/dist/cjs/w/messenger/storage.js +1 -1023
  190. package/dist/cjs/w/messenger/templates/wts-html-template.js +1 -371
  191. package/dist/cjs/w/messenger/types.js +1 -76
  192. package/dist/cjs/w/messenger/utils.js +1 -12
  193. package/dist/cjs/w/query/bult-in.js +1 -95
  194. package/dist/cjs/w/query/event.js +1 -137
  195. package/dist/cjs/w/query/index.js +1 -5
  196. package/dist/cjs/w/query/object.js +1 -1550
  197. package/dist/cjs/w/query/received.js +1 -62
  198. package/dist/cjs/w/query/util.js +1 -49
  199. package/dist/cjs/w/util.js +1 -587
  200. package/dist/esm/bcs/bcs.js +1 -253
  201. package/dist/esm/bcs/effects.js +1 -199
  202. package/dist/esm/bcs/index.js +1 -51
  203. package/dist/esm/bcs/pure.js +1 -36
  204. package/dist/esm/bcs/type-tag-serializer.js +1 -104
  205. package/dist/esm/bcs/types.js +1 -3
  206. package/dist/esm/client/index.js +1 -4
  207. package/dist/esm/client/network.js +1 -15
  208. package/dist/esm/cryptography/index.js +1 -6
  209. package/dist/esm/cryptography/intent.js +1 -14
  210. package/dist/esm/cryptography/keypair.js +1 -74
  211. package/dist/esm/cryptography/mnemonics.js +1 -20
  212. package/dist/esm/cryptography/publickey.js +1 -80
  213. package/dist/esm/cryptography/signature-scheme.js +1 -22
  214. package/dist/esm/cryptography/signature.js +1 -41
  215. package/dist/esm/experimental/cache.js +1 -58
  216. package/dist/esm/experimental/client.js +1 -19
  217. package/dist/esm/experimental/core.js +1 -80
  218. package/dist/esm/experimental/errors.js +1 -24
  219. package/dist/esm/experimental/index.js +1 -5
  220. package/dist/esm/experimental/persistent-storage.js +1 -220
  221. package/dist/esm/experimental/persistent-storage.test.js +1 -144
  222. package/dist/esm/experimental/transports/utils.js +1 -96
  223. package/dist/esm/experimental/types.js +1 -1
  224. package/dist/esm/faucet/faucet.js +1 -99
  225. package/dist/esm/faucet/index.js +1 -1
  226. package/dist/esm/grpc/client.js +1 -42
  227. package/dist/esm/grpc/core.js +1 -587
  228. package/dist/esm/grpc/index.js +1 -2
  229. package/dist/esm/grpc/proto/google/protobuf/any.js +1 -106
  230. package/dist/esm/grpc/proto/google/protobuf/duration.js +1 -58
  231. package/dist/esm/grpc/proto/google/protobuf/empty.js +1 -7
  232. package/dist/esm/grpc/proto/google/protobuf/field_mask.js +1 -47
  233. package/dist/esm/grpc/proto/google/protobuf/struct.js +1 -191
  234. package/dist/esm/grpc/proto/google/protobuf/timestamp.js +1 -91
  235. package/dist/esm/grpc/proto/google/rpc/error_details.js +1 -265
  236. package/dist/esm/grpc/proto/google/rpc/status.js +1 -23
  237. package/dist/esm/grpc/proto/sui/rpc/v2/argument.js +1 -46
  238. package/dist/esm/grpc/proto/sui/rpc/v2/balance_change.js +1 -29
  239. package/dist/esm/grpc/proto/sui/rpc/v2/bcs.js +1 -22
  240. package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint.js +1 -54
  241. package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_contents.js +1 -60
  242. package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_summary.js +1 -144
  243. package/dist/esm/grpc/proto/sui/rpc/v2/effects.js +1 -271
  244. package/dist/esm/grpc/proto/sui/rpc/v2/epoch.js +1 -64
  245. package/dist/esm/grpc/proto/sui/rpc/v2/error_reason.js +1 -6
  246. package/dist/esm/grpc/proto/sui/rpc/v2/event.js +1 -62
  247. package/dist/esm/grpc/proto/sui/rpc/v2/executed_transaction.js +1 -64
  248. package/dist/esm/grpc/proto/sui/rpc/v2/execution_status.js +1 -481
  249. package/dist/esm/grpc/proto/sui/rpc/v2/gas_cost_summary.js +1 -40
  250. package/dist/esm/grpc/proto/sui/rpc/v2/input.js +1 -61
  251. package/dist/esm/grpc/proto/sui/rpc/v2/jwk.js +1 -57
  252. package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.client.js +1 -39
  253. package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.js +1 -329
  254. package/dist/esm/grpc/proto/sui/rpc/v2/move_package.js +1 -447
  255. package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.client.js +1 -27
  256. package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.js +1 -206
  257. package/dist/esm/grpc/proto/sui/rpc/v2/name_service.client.js +1 -19
  258. package/dist/esm/grpc/proto/sui/rpc/v2/name_service.js +1 -109
  259. package/dist/esm/grpc/proto/sui/rpc/v2/object.js +1 -90
  260. package/dist/esm/grpc/proto/sui/rpc/v2/object_reference.js +1 -30
  261. package/dist/esm/grpc/proto/sui/rpc/v2/owner.js +1 -39
  262. package/dist/esm/grpc/proto/sui/rpc/v2/protocol_config.js +1 -30
  263. package/dist/esm/grpc/proto/sui/rpc/v2/signature.js +1 -501
  264. package/dist/esm/grpc/proto/sui/rpc/v2/signature_scheme.js +1 -10
  265. package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +1 -15
  266. package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.js +1 -62
  267. package/dist/esm/grpc/proto/sui/rpc/v2/state_service.client.js +1 -31
  268. package/dist/esm/grpc/proto/sui/rpc/v2/state_service.js +1 -504
  269. package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.client.js +1 -15
  270. package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.js +1 -37
  271. package/dist/esm/grpc/proto/sui/rpc/v2/system_state.js +1 -709
  272. package/dist/esm/grpc/proto/sui/rpc/v2/transaction.js +1 -950
  273. package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +1 -19
  274. package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.js +1 -144
  275. package/dist/esm/index.js +1 -22
  276. package/dist/esm/jsonRpc/client.js +1 -516
  277. package/dist/esm/jsonRpc/core.js +1 -587
  278. package/dist/esm/jsonRpc/errors.js +1 -38
  279. package/dist/esm/jsonRpc/http-transport.js +1 -70
  280. package/dist/esm/jsonRpc/index.js +1 -3
  281. package/dist/esm/jsonRpc/json-rpc-resolver.js +1 -296
  282. package/dist/esm/jsonRpc/rpc-websocket-client.js +1 -155
  283. package/dist/esm/jsonRpc/types/chain.js +1 -1
  284. package/dist/esm/jsonRpc/types/changes.js +1 -1
  285. package/dist/esm/jsonRpc/types/coins.js +1 -1
  286. package/dist/esm/jsonRpc/types/common.js +1 -1
  287. package/dist/esm/jsonRpc/types/generated.js +1 -1
  288. package/dist/esm/jsonRpc/types/index.js +1 -1
  289. package/dist/esm/jsonRpc/types/params.js +1 -1
  290. package/dist/esm/keypairs/ed25519/ed25519-hd-key.js +1 -58
  291. package/dist/esm/keypairs/ed25519/index.js +1 -2
  292. package/dist/esm/keypairs/ed25519/keypair.js +1 -90
  293. package/dist/esm/keypairs/ed25519/publickey.js +1 -50
  294. package/dist/esm/keypairs/index.js +1 -4
  295. package/dist/esm/keypairs/passkey/index.js +1 -2
  296. package/dist/esm/keypairs/passkey/keypair.js +1 -155
  297. package/dist/esm/keypairs/passkey/publickey.js +1 -117
  298. package/dist/esm/keypairs/passkey/types.js +1 -1
  299. package/dist/esm/keypairs/secp256k1/index.js +1 -2
  300. package/dist/esm/keypairs/secp256k1/keypair.js +1 -82
  301. package/dist/esm/keypairs/secp256k1/publickey.js +1 -51
  302. package/dist/esm/keypairs/secp256r1/index.js +1 -2
  303. package/dist/esm/keypairs/secp256r1/keypair.js +1 -78
  304. package/dist/esm/keypairs/secp256r1/publickey.js +1 -52
  305. package/dist/esm/multisig/index.js +1 -2
  306. package/dist/esm/multisig/publickey.js +1 -201
  307. package/dist/esm/multisig/signer.js +1 -58
  308. package/dist/esm/transactions/Arguments.js +1 -9
  309. package/dist/esm/transactions/Commands.js +1 -102
  310. package/dist/esm/transactions/Inputs.js +1 -52
  311. package/dist/esm/transactions/ObjectCache.js +1 -205
  312. package/dist/esm/transactions/Transaction.js +1 -574
  313. package/dist/esm/transactions/TransactionData.js +1 -409
  314. package/dist/esm/transactions/__tests__/Transaction.test.js +1 -160
  315. package/dist/esm/transactions/__tests__/bcs.test.js +1 -182
  316. package/dist/esm/transactions/data/internal.js +1 -169
  317. package/dist/esm/transactions/data/v1.js +1 -469
  318. package/dist/esm/transactions/data/v2.js +1 -97
  319. package/dist/esm/transactions/executor/caching.js +1 -65
  320. package/dist/esm/transactions/executor/parallel.js +1 -347
  321. package/dist/esm/transactions/executor/queue.js +1 -59
  322. package/dist/esm/transactions/executor/serial.js +1 -99
  323. package/dist/esm/transactions/hash.js +1 -8
  324. package/dist/esm/transactions/index.js +1 -12
  325. package/dist/esm/transactions/intents/CoinWithBalance.js +1 -145
  326. package/dist/esm/transactions/object.js +1 -87
  327. package/dist/esm/transactions/plugins/NamedPackagesPlugin.js +1 -11
  328. package/dist/esm/transactions/pure.js +1 -36
  329. package/dist/esm/transactions/resolve.js +1 -69
  330. package/dist/esm/transactions/serializer.js +1 -167
  331. package/dist/esm/transactions/utils.js +1 -121
  332. package/dist/esm/utils/constants.js +1 -18
  333. package/dist/esm/utils/derived-objects.js +1 -8
  334. package/dist/esm/utils/dynamic-fields.js +1 -17
  335. package/dist/esm/utils/format.js +1 -11
  336. package/dist/esm/utils/index.js +1 -8
  337. package/dist/esm/utils/move-registry.js +1 -24
  338. package/dist/esm/utils/sui-types.js +1 -66
  339. package/dist/esm/utils/suins.js +1 -33
  340. package/dist/esm/verify/index.js +1 -1
  341. package/dist/esm/verify/verify.js +1 -87
  342. package/dist/esm/version.js +1 -2
  343. package/dist/esm/w/call/allocation.js +1 -345
  344. package/dist/esm/w/call/arb.js +1 -103
  345. package/dist/esm/w/call/arbitration.js +1 -1192
  346. package/dist/esm/w/call/base.js +1 -293
  347. package/dist/esm/w/call/contact.js +1 -345
  348. package/dist/esm/w/call/demand.js +1 -681
  349. package/dist/esm/w/call/entity.js +1 -173
  350. package/dist/esm/w/call/guard-ins.js +1 -4449
  351. package/dist/esm/w/call/guard.d.ts +111 -0
  352. package/dist/esm/w/call/guard.js +1 -1048
  353. package/dist/esm/w/call/index.js +1 -22
  354. package/dist/esm/w/call/machine.js +1 -1127
  355. package/dist/esm/w/call/order.js +1 -337
  356. package/dist/esm/w/call/passport.js +1 -220
  357. package/dist/esm/w/call/payment.js +1 -178
  358. package/dist/esm/w/call/permission.js +1 -1162
  359. package/dist/esm/w/call/personal.js +1 -139
  360. package/dist/esm/w/call/progress.js +1 -678
  361. package/dist/esm/w/call/proof.js +1 -66
  362. package/dist/esm/w/call/repository.js +1 -1024
  363. package/dist/esm/w/call/resource.js +1 -108
  364. package/dist/esm/w/call/reward.js +1 -675
  365. package/dist/esm/w/call/service.js +1 -1960
  366. package/dist/esm/w/call/treasury.js +1 -873
  367. package/dist/esm/w/call/util.d.ts +1 -0
  368. package/dist/esm/w/call/util.js +1 -566
  369. package/dist/esm/w/common.js +1 -571
  370. package/dist/esm/w/exception.js +1 -618
  371. package/dist/esm/w/index.js +1 -8
  372. package/dist/esm/w/local/account.js +1 -656
  373. package/dist/esm/w/local/cache.js +1 -161
  374. package/dist/esm/w/local/config.js +1 -43
  375. package/dist/esm/w/local/index.js +1 -228
  376. package/dist/esm/w/local/local.js +1 -574
  377. package/dist/esm/w/local/storage.js +1 -185
  378. package/dist/esm/w/local/token.js +1 -131
  379. package/dist/esm/w/local/util.js +1 -26
  380. package/dist/esm/w/local/wip.js +1 -864
  381. package/dist/esm/w/messenger/crypto.js +1 -380
  382. package/dist/esm/w/messenger/index.js +1 -4
  383. package/dist/esm/w/messenger/messenger-api.js +1 -1154
  384. package/dist/esm/w/messenger/messenger-manager.js +1 -1003
  385. package/dist/esm/w/messenger/messenger.js +1 -1093
  386. package/dist/esm/w/messenger/server.js +1 -343
  387. package/dist/esm/w/messenger/session.js +1 -628
  388. package/dist/esm/w/messenger/storage.js +1 -1023
  389. package/dist/esm/w/messenger/templates/wts-html-template.js +1 -371
  390. package/dist/esm/w/messenger/types.js +1 -76
  391. package/dist/esm/w/messenger/utils.js +1 -12
  392. package/dist/esm/w/query/bult-in.js +1 -95
  393. package/dist/esm/w/query/event.js +1 -137
  394. package/dist/esm/w/query/index.js +1 -5
  395. package/dist/esm/w/query/object.js +1 -1550
  396. package/dist/esm/w/query/received.js +1 -62
  397. package/dist/esm/w/query/util.js +1 -49
  398. package/dist/esm/w/util.js +1 -587
  399. package/package.json +5 -2
@@ -1,1960 +1 @@
1
- import { toTxObject, toTxString, isValidDescription, MAX_DESCRIPTION_LENGTH, isValidName, isValidLongName, isValidU16, isValidU64, PackageAddress, MAX_LONG_NAME_LENGTH, isValidArray, IsValidArgType, GetObjectExisted, GetObject, GetObjectDescription, serviceFn, MAX_NAME_LENGTH, isValidHttpUrl, } from "../common.js";
2
- import { W_ERROR, WErrors } from "../exception.js";
3
- import { ObjectType } from "../query/object.js";
4
- import { owner_receive, parseObjectType, validObjects } from "../util.js";
5
- import { allocators } from "./allocation.js";
6
- import { CallBase, getCoinParam } from "./base.js";
7
- import { BuiltinPermissionIndex, newPermission } from "./permission.js";
8
- import { GetManyAccountOrMark_Address, verify_wip } from "../local/index.js";
9
- import { WIP } from "../local/wip.js";
10
- import { LocalMark } from "../local/local.js";
11
- import { agent_set, order_required_info_update, owner_change, } from "./order.js";
12
- import { create as progressCreate } from "./progress.js";
13
- import { create as orderCreate } from "./order.js";
14
- import { create as permissionCreate } from "./permission.js";
15
- import { queryObjectsWithType } from "../query/util.js";
16
- import { query_received } from "../query/received.js";
17
- export const NAMED_OPERATOR_ORDER_PAYER = "";
18
- export class CallService extends CallBase {
19
- data;
20
- object_address = undefined;
21
- permission_address = undefined;
22
- new_permission_description = undefined;
23
- parameter_type = undefined;
24
- constructor(data) {
25
- super();
26
- this.data = data;
27
- }
28
- async prepare(env) {
29
- await super.prepare(env);
30
- if (!this.object_address) {
31
- this.object_address = await GetObjectExisted(this.data?.object);
32
- }
33
- if (this.object_address) {
34
- this.content = undefined;
35
- await this.update_content(env, ObjectType.Service, this.object_address);
36
- if (!this.content)
37
- W_ERROR(WErrors.InvalidParam, "CallService_Data.data.object:" + this.object_address);
38
- this.permission_address = this.content.permission;
39
- this.parameter_type = parseObjectType(this.content.type_raw, "service::Service");
40
- if (!this.permission_address) {
41
- W_ERROR(WErrors.InvalidParam, "CallService_Data.data.object.permission is empty");
42
- }
43
- if (!IsValidArgType(this.parameter_type)) {
44
- W_ERROR(WErrors.IsValidArgType, "CallService_Data.data.object.type_parameter is empty");
45
- }
46
- }
47
- else {
48
- const n = GetObject(this.data.object);
49
- this.permission_address = await GetObjectExisted(n?.permission);
50
- this.new_permission_description = GetObjectDescription(n?.permission);
51
- this.parameter_type = n?.type_parameter;
52
- if (!IsValidArgType(this.parameter_type)) {
53
- W_ERROR(WErrors.IsValidArgType, "CallService_Data.data.object.type_parameter invalid");
54
- }
55
- }
56
- }
57
- async call(env) {
58
- await this.prepare(env);
59
- const guards = [];
60
- const perms = [];
61
- const add_guard = (guard) => {
62
- if (!guards.includes(guard)) {
63
- guards.push(guard);
64
- }
65
- };
66
- const add_perm = (index) => {
67
- if (this.permission_address && !perms.includes(index)) {
68
- perms.push(index);
69
- }
70
- };
71
- if (this.permission_address && !this.object_address) {
72
- add_perm(BuiltinPermissionIndex.SERVICE_NEW);
73
- }
74
- if (this.data?.order_new) {
75
- if (!this.content) {
76
- W_ERROR(WErrors.InvalidParam, `CallService_Data.data.order_new fail because the Service ${JSON.stringify(this.data.object)} content not ready`);
77
- }
78
- this.order_allowed();
79
- if (this.content.buy_guard != null) {
80
- add_guard(this.content.buy_guard);
81
- }
82
- }
83
- if (this.permission_address &&
84
- this.data?.description != null &&
85
- this.object_address) {
86
- add_perm(BuiltinPermissionIndex.SERVICE_DESCRIPTION);
87
- }
88
- if (this.permission_address && this.data?.location != null) {
89
- add_perm(BuiltinPermissionIndex.SERVICE_LOCATION);
90
- }
91
- if (this.permission_address && this.data?.repositories != null) {
92
- add_perm(BuiltinPermissionIndex.SERVICE_REPOSITORY);
93
- }
94
- if (this.permission_address && this.data?.sales != null) {
95
- add_perm(BuiltinPermissionIndex.SERVICE_SALES);
96
- }
97
- if (this.permission_address && this.data?.machine !== undefined) {
98
- this.checkNotPublished("machine");
99
- add_perm(BuiltinPermissionIndex.SERVICE_MACHINE);
100
- }
101
- if (this.permission_address && this.data?.discount != null) {
102
- add_perm(BuiltinPermissionIndex.SERVICE_DISCOUNT);
103
- }
104
- if (this.permission_address && this.data?.arbitrations != null) {
105
- this.checkNotPublished("arbitrations");
106
- add_perm(BuiltinPermissionIndex.SERVICE_ARBITRATION);
107
- }
108
- if (this.permission_address && this.data?.customer_required != null) {
109
- add_perm(BuiltinPermissionIndex.SERVICE_CUSTOMER_INFO_REQUIRED);
110
- }
111
- if (this.permission_address && this.data?.pause !== undefined) {
112
- add_perm(BuiltinPermissionIndex.SERVICE_PAUSE);
113
- }
114
- if (this.permission_address && this.data?.publish) {
115
- add_perm(BuiltinPermissionIndex.SERVICE_PUBLISH);
116
- }
117
- if (this.permission_address &&
118
- this.data?.order_allocators !== undefined) {
119
- this.checkNotPublished("order_allocators");
120
- add_perm(BuiltinPermissionIndex.SERVICE_ORDER_ALLOCATOR);
121
- }
122
- if (this.permission_address && this.data?.buy_guard != null) {
123
- const g = await LocalMark.Instance().get_address(this.data?.buy_guard);
124
- if (!g) {
125
- W_ERROR(WErrors.InvalidParam, "CallService_Data.data.buy_guard:" + this.data?.buy_guard);
126
- }
127
- this.data.buy_guard = g;
128
- add_perm(BuiltinPermissionIndex.SERVICE_BUY_GUARD);
129
- }
130
- if (this.permission_address &&
131
- this.data?.compensation_fund_add != null) {
132
- add_perm(BuiltinPermissionIndex.SERVICE_COMPENSATION_FUND_DEPOSIT);
133
- }
134
- if (this.permission_address &&
135
- this.data?.compensation_locked_time_add !== undefined) {
136
- add_perm(BuiltinPermissionIndex.SERVICE_COMPENSATION_LOCKED_TIME_ADD);
137
- }
138
- if (this.permission_address && this.data?.rewards != null) {
139
- add_perm(BuiltinPermissionIndex.SERVICE_REWARD);
140
- }
141
- if (this.permission_address &&
142
- this.data?.compensation_fund_receive != null) {
143
- add_perm(BuiltinPermissionIndex.SERVICE_COMPENSATION_FUND_RECEIVE);
144
- }
145
- if (this.permission_address && this.data?.owner_receive != null) {
146
- add_perm(BuiltinPermissionIndex.SERVICE_OWNER_RECEIVE);
147
- }
148
- if (this.permission_address && this.data?.um !== undefined) {
149
- add_perm(BuiltinPermissionIndex.SERVICE_UM);
150
- }
151
- if (this.permission_address || guards.length > 0) {
152
- return await this.check_permission_and_call(env, this.permission_address, perms, guards);
153
- }
154
- return await this.exec(env);
155
- }
156
- async operate(env, tx, passport, submission) {
157
- let permission = this.permission_address;
158
- let object = this.object_address;
159
- if (!this.object_address) {
160
- if (!permission) {
161
- permission = newPermission(tx, this.new_permission_description ?? "");
162
- }
163
- if (permission && this.parameter_type) {
164
- object = newService(tx, this.parameter_type, permission, this.data?.description ?? "", passport);
165
- }
166
- }
167
- if (!object || !permission) {
168
- W_ERROR(WErrors.InvalidParam, "CallService_Data.data.object:" + this.object_address);
169
- }
170
- let buyResult;
171
- if (this.data?.order_new != null && this.content) {
172
- this.order_allowed();
173
- const n = this.data?.order_new;
174
- const serviceSales = this.content.sales;
175
- const verifiedWipUrls = new Set();
176
- for (const item of n.buy.items) {
177
- const sale = serviceSales.find((s) => s.name === item.name);
178
- if (!sale) {
179
- W_ERROR(WErrors.InvalidParam, `Product "${item.name}" not found in Service sales`);
180
- }
181
- if (verifiedWipUrls.has(sale.wip)) {
182
- continue;
183
- }
184
- if (sale.wip === "") {
185
- continue;
186
- }
187
- const wipVerification = await verify_wip(sale.wip, item.wip_hash);
188
- if (!wipVerification.valid) {
189
- W_ERROR(WErrors.InvalidParam, `WIP file verification failed for product "${item.name}" at ${sale.wip}: ${wipVerification.error}`);
190
- }
191
- verifiedWipUrls.add(sale.wip);
192
- }
193
- n.buy.discount = await LocalMark.Instance().get_address(this.data.order_new.buy.discount);
194
- buyResult = await buy(env, tx, object, this.parameter_type, this.content.machine, n.buy, passport);
195
- if (!buyResult) {
196
- W_ERROR(WErrors.Fail, "Buy failed, no order created");
197
- }
198
- if (n?.agents != null) {
199
- agent_set(tx, {
200
- order: buyResult.order,
201
- agents: await GetManyAccountOrMark_Address(n.agents),
202
- });
203
- }
204
- if (n?.order_required_info !== undefined &&
205
- n.order_required_info.length > 0) {
206
- await order_required_info_update(tx, buyResult.order, n.order_required_info);
207
- }
208
- if (n?.transfer != null) {
209
- await owner_change(tx, {
210
- order: buyResult.order,
211
- new_owner: n.transfer,
212
- });
213
- }
214
- if (n?.namedNewAllocation != null && buyResult?.allocation) {
215
- await this.new_with_mark(env, tx, ObjectType.Allocation, buyResult?.allocation, GetObject(n.namedNewAllocation));
216
- }
217
- if (buyResult?.progress) {
218
- if (n?.namedNewProgress != null) {
219
- await this.new_with_mark(env, tx, ObjectType.Progress, progressCreate(tx, buyResult?.progress), GetObject(n.namedNewProgress));
220
- }
221
- else {
222
- progressCreate(tx, buyResult?.progress);
223
- }
224
- }
225
- if (buyResult?.order) {
226
- const addr = orderCreate(tx, buyResult?.order);
227
- if (n?.namedNewOrder != null) {
228
- await this.new_with_mark(env, tx, ObjectType.Order, addr, GetObject(n.namedNewOrder));
229
- }
230
- }
231
- }
232
- if (this.data.description != null && !this.object_address) {
233
- description_set(tx, object, this.parameter_type, permission, this.data.description, passport);
234
- }
235
- if (this.data.location != null) {
236
- location_set(tx, object, this.parameter_type, permission, this.data.location, passport);
237
- }
238
- if (this.data.sales != null) {
239
- switch (this.data.sales.op) {
240
- case "add":
241
- case "set": {
242
- for (const sale of this.data.sales.sales) {
243
- if (sale.wip !== "") {
244
- const wipVerification = await verify_wip(sale.wip, sale.wip_hash !== ""
245
- ? sale.wip_hash
246
- : undefined);
247
- if (!wipVerification.valid) {
248
- W_ERROR(WErrors.InvalidParam, `WIP file verification failed for product "${sale.name}" at ${sale.wip}: ${wipVerification.error}`);
249
- }
250
- const wip = new WIP();
251
- const wipFile = await wip.load(sale.wip);
252
- sale.wip_hash = wip.getHash(wipFile);
253
- }
254
- }
255
- if (this.data.sales.op === "add") {
256
- sales_add(tx, object, this.parameter_type, permission, this.data.sales.sales, passport);
257
- }
258
- else {
259
- sales_set(tx, object, this.parameter_type, permission, this.data.sales.sales, passport);
260
- }
261
- break;
262
- }
263
- case "remove": {
264
- sales_remove(tx, object, this.parameter_type, permission, this.data.sales.sales_name, passport);
265
- break;
266
- }
267
- case "clear": {
268
- sales_clear(tx, object, this.parameter_type, permission, passport);
269
- break;
270
- }
271
- }
272
- }
273
- if (this.data.repositories != null) {
274
- switch (this.data.repositories.op) {
275
- case "add":
276
- case "set": {
277
- if (this.data.repositories.objects.length >
278
- MAX_REPOSITORY_COUNT) {
279
- W_ERROR(WErrors.InvalidParam, "CallService_Data.data.repositories.objects:" +
280
- this.data.repositories.objects);
281
- }
282
- if (this.data.repositories.op === "set") {
283
- repository_clear(tx, object, this.parameter_type, permission, passport);
284
- }
285
- const r = await LocalMark.Instance().get_many_address_availables(this.data.repositories.objects);
286
- r.forEach((repo) => {
287
- repository_add(tx, object, this.parameter_type, permission, repo, passport);
288
- });
289
- break;
290
- }
291
- case "remove": {
292
- if (this.data.repositories.objects.length >
293
- MAX_REPOSITORY_COUNT) {
294
- W_ERROR(WErrors.InvalidParam, "CallService_Data.data.repositories.objects:" +
295
- this.data.repositories.objects);
296
- }
297
- const addrs = await LocalMark.Instance().get_many_address_availables(this.data.repositories.objects);
298
- repository_remove(tx, object, this.parameter_type, permission, addrs, passport);
299
- break;
300
- }
301
- case "clear": {
302
- repository_clear(tx, object, this.parameter_type, permission, passport);
303
- break;
304
- }
305
- }
306
- }
307
- if (this.data.rewards != null) {
308
- switch (this.data.rewards.op) {
309
- case "add":
310
- case "set": {
311
- if (this.data.rewards.objects.length > MAX_REWARD_COUNT) {
312
- W_ERROR(WErrors.InvalidParam, `rewards count exceeds maximum limit ${MAX_REWARD_COUNT}`);
313
- }
314
- if (this.data.rewards.op === "set") {
315
- reward_clear(tx, object, this.parameter_type, permission, passport);
316
- }
317
- const rewards = await queryObjectsWithType(env, this.data.rewards.objects, ObjectType.Reward, "reward::Reward", true);
318
- rewards.forEach((reward) => {
319
- reward_add(tx, object, this.parameter_type, permission, reward.object, reward.type, passport);
320
- });
321
- break;
322
- }
323
- case "remove": {
324
- if (this.data.rewards.objects.length > MAX_REWARD_COUNT) {
325
- W_ERROR(WErrors.InvalidParam, `rewards count exceeds maximum limit ${MAX_REWARD_COUNT}`);
326
- }
327
- const addrs = await LocalMark.Instance().get_many_address_availables(this.data.rewards.objects);
328
- reward_remove(tx, object, this.parameter_type, permission, addrs, passport);
329
- break;
330
- }
331
- case "clear": {
332
- reward_clear(tx, object, this.parameter_type, permission, passport);
333
- break;
334
- }
335
- }
336
- }
337
- if (this.data.arbitrations != null) {
338
- switch (this.data.arbitrations.op) {
339
- case "add":
340
- case "set": {
341
- if (this.data.arbitrations.objects.length >
342
- MAX_ARBITRATION_COUNT) {
343
- W_ERROR(WErrors.InvalidParam, `arbitrations count exceeds maximum limit ${MAX_ARBITRATION_COUNT}`);
344
- }
345
- if (this.data.arbitrations.op === "set") {
346
- arbitration_clear(tx, object, this.parameter_type, permission, passport);
347
- }
348
- const arbitrations = await queryObjectsWithType(env, this.data.arbitrations.objects, ObjectType.Arbitration, "arbitration::Arbitration", true);
349
- arbitrations.forEach((arbitration) => {
350
- arbitrations_add(tx, object, this.parameter_type, permission, arbitration.object, arbitration.type, passport);
351
- });
352
- break;
353
- }
354
- case "remove": {
355
- if (this.data.arbitrations.objects.length >
356
- MAX_ARBITRATION_COUNT) {
357
- W_ERROR(WErrors.InvalidParam, `arbitrations count exceeds maximum limit ${MAX_ARBITRATION_COUNT}`);
358
- }
359
- const addrs = await LocalMark.Instance().get_many_address_availables(this.data.arbitrations.objects);
360
- arbitrations_remove(tx, object, this.parameter_type, permission, addrs, passport);
361
- break;
362
- }
363
- case "clear": {
364
- arbitration_clear(tx, object, this.parameter_type, permission, passport);
365
- break;
366
- }
367
- }
368
- }
369
- if (this.data.discount != null) {
370
- await discount(tx, object, this.parameter_type, permission, this.data.discount, passport);
371
- }
372
- if (this.data.discount_destroy != null) {
373
- const r = await LocalMark.Instance().get_many_address_availables(this.data.discount_destroy);
374
- discount_destroy(tx, r);
375
- }
376
- if (this.data.machine !== undefined) {
377
- if (this.data.machine) {
378
- const m = await LocalMark.Instance().get_address(this.data.machine);
379
- if (m) {
380
- this.data.machine = m;
381
- }
382
- else {
383
- W_ERROR(WErrors.IsValidArgType, `Machine not found ${this.data.machine}`);
384
- }
385
- }
386
- machine_set(tx, object, this.parameter_type, permission, this.data.machine, passport);
387
- }
388
- if (this.data.customer_required != null) {
389
- customer_required_set(tx, object, this.parameter_type, permission, this.data.customer_required, passport);
390
- }
391
- if (this.data.order_allocators !== undefined) {
392
- order_allocators_set(tx, object, this.parameter_type, permission, this.data.order_allocators
393
- ? await allocators(tx, this.data.order_allocators)
394
- : null, passport);
395
- }
396
- if (this.data.buy_guard !== undefined) {
397
- buy_guard_set(tx, object, this.parameter_type, permission, this.data.buy_guard, passport);
398
- }
399
- if (this.data.compensation_fund_add != null) {
400
- await compensation_fund_add(env, tx, object, this.parameter_type, permission, this.data.compensation_fund_add, passport);
401
- }
402
- if (this.data.compensation_locked_time_add !== undefined) {
403
- compensation_lock_duration_set(tx, object, this.parameter_type, permission, this.data.compensation_locked_time_add, passport);
404
- }
405
- if (this.data.compensation_fund_receive != null &&
406
- this.object_address) {
407
- if (this.data.compensation_fund_receive === "recently") {
408
- const received = await query_received({
409
- object: this.object_address,
410
- network: env.network,
411
- no_cache: env.no_cache,
412
- });
413
- if (Array.isArray(received)) {
414
- W_ERROR(WErrors.InvalidParam, "CallAllocation_Data.data.received_coins: received is ReceivedNormal[]");
415
- }
416
- else {
417
- this.data.compensation_fund_receive = received;
418
- }
419
- }
420
- if (typeof this.data.compensation_fund_receive === "object" &&
421
- "received" in this.data.compensation_fund_receive &&
422
- this.data.compensation_fund_receive.received?.length > 0) {
423
- if (this.data.compensation_fund_receive.token_type !==
424
- this.parameter_type) {
425
- W_ERROR(WErrors.InvalidParam, `token_type ${this.data.compensation_fund_receive.token_type} is not equal to parameter_type ${this.parameter_type}`);
426
- }
427
- for (const item of this.data.compensation_fund_receive
428
- .received) {
429
- const [received_object, payment_object] = await Promise.all([
430
- LocalMark.Instance().get_address(item.id),
431
- LocalMark.Instance().get_address(item.payment),
432
- ]);
433
- if (!received_object || !payment_object) {
434
- W_ERROR(WErrors.IsValidArgType, `Compensation fund receive object ${item.id} or payment object ${item.payment} not found`);
435
- }
436
- compensation_fund_receive(tx, object, this.parameter_type, permission, item.id, item.payment, passport);
437
- }
438
- }
439
- }
440
- if (this.data.owner_receive != null && this.object_address) {
441
- if (this.data.owner_receive === "recently") {
442
- this.data.owner_receive = await query_received({
443
- object: this.object_address,
444
- all_type: true,
445
- network: env.network,
446
- no_cache: env.no_cache,
447
- });
448
- }
449
- await owner_receive(tx, object, permission, this.data.owner_receive, this.parameter_type, (name) => `${PackageAddress}::service::${name}`, passport);
450
- }
451
- if (this.data.um !== undefined) {
452
- let um_address = null;
453
- if (this.data.um) {
454
- um_address =
455
- (await LocalMark.Instance().get_address(this.data.um)) ||
456
- null;
457
- if (!um_address) {
458
- W_ERROR(WErrors.InvalidParam, "CallService_Data.data.um:" + this.data.um);
459
- }
460
- }
461
- um_set(tx, object, this.parameter_type, permission, um_address, passport);
462
- }
463
- if (this.data.pause != null) {
464
- pause(tx, object, this.parameter_type, permission, this.data.pause, passport);
465
- }
466
- if (this.data.publish) {
467
- publish(tx, object, this.parameter_type, permission, passport);
468
- }
469
- if (!this.permission_address) {
470
- const p = GetObject(this.data?.object);
471
- await this.new_with_mark(env, tx, ObjectType.Permission, permissionCreate(tx, permission), GetObject(p.permission));
472
- }
473
- if (!this.object_address) {
474
- await this.new_with_mark(env, tx, ObjectType.Service, create(tx, object, this.parameter_type), GetObject(this.data?.object));
475
- }
476
- }
477
- checkPublished = (op) => {
478
- if (this.content && !this.content.bPublished) {
479
- W_ERROR(WErrors.Fail, `Service object has not been published yet, so the operation (${op}) cannot proceed.`);
480
- }
481
- };
482
- checkNotPublished = (op) => {
483
- if (this.content && this.content.bPublished) {
484
- W_ERROR(WErrors.Fail, `Service object has been published and operation (${op}) cannot proceed.
485
- If further modifications are needed, you can 'clone' a new Service and then proceed with the operation.`);
486
- }
487
- };
488
- checkNotPaused = (op) => {
489
- if (this.content && this.content.bPaused) {
490
- W_ERROR(WErrors.Fail, `Service object has been paused and operation (${op}) cannot proceed.`);
491
- }
492
- };
493
- order_allowed() {
494
- if (this.content?.bPaused) {
495
- W_ERROR(WErrors.InvalidParam, "Service is paused");
496
- return false;
497
- }
498
- if (this.content?.bPublished !== true) {
499
- W_ERROR(WErrors.InvalidParam, "Service is not published");
500
- return false;
501
- }
502
- return true;
503
- }
504
- }
505
- export const MAX_SALE_COUNT = 50;
506
- export const MAX_REPOSITORY_COUNT = 100;
507
- export const MAX_ARBITRATION_COUNT = 20;
508
- export const MAX_REWARD_COUNT = 20;
509
- export const MAX_CUSTOMER_REQUIRED_INFO_COUNT = 10;
510
- export const MAX_PUBKEY_LENGTH = 1024;
511
- export const MAX_DISCOUNT_COUNT_ONCE = 1000;
512
- export const MAX_DISCOUNT_RECEIVER_ONCE = 1000;
513
- export const MAX_DISCOUNT_TOTAL_COUNT = 20000;
514
- export const MAX_REQUIRED_INFO_SIZE = 20;
515
- export const DEFAULT_COMPENSATION_LOCK_DURATION = 2592000000;
516
- export const DISCOUNT_TYPE_RATES = 0;
517
- export const DISCOUNT_TYPE_MINUS = 1;
518
- const MAX_WIP_LENGTH = 1024;
519
- const MAX_WIP_HASH_LENGTH = 64;
520
- function sale(tx, sale) {
521
- if (typeof sale.name === "string" && !isValidLongName(sale.name)) {
522
- W_ERROR(WErrors.InvalidParam, `Name ${sale.name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
523
- }
524
- if (sale.wip.length > MAX_WIP_LENGTH) {
525
- W_ERROR(WErrors.InvalidParam, `WIP ${sale.wip} exceeds maximum length ${MAX_WIP_LENGTH}`);
526
- }
527
- const finalWip = sale.wip;
528
- if (sale.wip.length > 0 && !isValidHttpUrl(sale.wip)) {
529
- W_ERROR(WErrors.IsValidHttpUrl, `WIP ${sale.wip} is not a valid HTTP/HTTPS URL`);
530
- }
531
- const finalWipHash = sale.wip_hash.includes(":")
532
- ? sale.wip_hash.split(":")[1]
533
- : sale.wip_hash;
534
- if (finalWipHash.length > MAX_WIP_HASH_LENGTH) {
535
- W_ERROR(WErrors.InvalidParam, `WIP hash ${finalWipHash} exceeds maximum length ${MAX_WIP_HASH_LENGTH}`);
536
- }
537
- return tx.moveCall({
538
- target: serviceFn("sale"),
539
- arguments: [
540
- toTxString(tx, sale.name),
541
- tx.pure.u64(sale.price),
542
- tx.pure.u64(sale.stock),
543
- tx.pure.bool(sale.suspension),
544
- toTxString(tx, finalWip),
545
- toTxString(tx, finalWipHash),
546
- ],
547
- });
548
- }
549
- function quote_item(tx, item) {
550
- if (!isValidLongName(item.name)) {
551
- W_ERROR(WErrors.InvalidParam, `Quote item name ${item.name} is not valid`);
552
- }
553
- if (!isValidU64(item.stock)) {
554
- W_ERROR(WErrors.IsValidU64, `Quote item stock ${item.stock} is not valid`);
555
- }
556
- const finalWipHash = item.wip_hash.includes(":")
557
- ? item.wip_hash.split(":")[1]
558
- : item.wip_hash;
559
- if (finalWipHash.length > MAX_WIP_HASH_LENGTH) {
560
- W_ERROR(WErrors.InvalidParam, `Quote item wip_hash ${finalWipHash} exceeds maximum length ${MAX_WIP_HASH_LENGTH}`);
561
- }
562
- return tx.moveCall({
563
- target: serviceFn("quote_item"),
564
- arguments: [
565
- toTxString(tx, item.name),
566
- tx.pure.u64(item.stock),
567
- toTxString(tx, finalWipHash),
568
- ],
569
- });
570
- }
571
- export function discount_send(tx, discount, recipient) {
572
- if (discount.length === 0) {
573
- return;
574
- }
575
- validObjects([...discount, recipient]);
576
- if (discount.length > MAX_DISCOUNT_COUNT_ONCE) {
577
- W_ERROR(WErrors.InvalidParam, `Discount count ${discount.length} exceeds maximum limit ${MAX_DISCOUNT_COUNT_ONCE}`);
578
- }
579
- if (discount.length === 1) {
580
- tx.moveCall({
581
- target: serviceFn("discount_send_singleton"),
582
- arguments: [
583
- toTxObject(tx, discount[0]),
584
- tx.pure.address(recipient),
585
- ],
586
- });
587
- return;
588
- }
589
- else {
590
- tx.moveCall({
591
- target: serviceFn("discount_send"),
592
- arguments: [
593
- tx.makeMoveVec({
594
- elements: discount,
595
- type: `${PackageAddress}::service::Discount`,
596
- }),
597
- tx.pure.address(recipient),
598
- ],
599
- });
600
- }
601
- }
602
- export function discount_destroy(tx, discount) {
603
- validObjects([...discount]);
604
- discount.forEach((item) => {
605
- tx.moveCall({
606
- target: serviceFn("discount_destroy"),
607
- arguments: [toTxObject(tx, item)],
608
- });
609
- });
610
- }
611
- export const buy = async (env, tx, service, service_type, machine, buy, passport) => {
612
- if (buy.items.length === 0) {
613
- return undefined;
614
- }
615
- validObjects([service, buy.discount, machine, passport]);
616
- if (!IsValidArgType(service_type)) {
617
- W_ERROR(WErrors.InvalidParam, `Buy service type ${service_type} is not valid`);
618
- }
619
- if (!isValidArray(buy.items, (item) => {
620
- if (!isValidLongName(item.name)) {
621
- W_ERROR(WErrors.InvalidParam, `Buy item name ${item.name} is not valid`);
622
- }
623
- if (!isValidU64(item.stock)) {
624
- W_ERROR(WErrors.IsValidU64, `Buy item stock ${item.stock} is not valid`);
625
- }
626
- return true;
627
- })) {
628
- W_ERROR(WErrors.InvalidParam, "Buy items is not valid");
629
- }
630
- if (typeof buy.payment_remark === "string" &&
631
- !isValidName(buy.payment_remark)) {
632
- W_ERROR(WErrors.InvalidParam, `Buy payment remark ${buy.payment_remark} is not valid`);
633
- }
634
- buy.payment_remark = buy.payment_remark || "";
635
- if (buy.payment_index != null && !isValidU64(buy.payment_index)) {
636
- W_ERROR(WErrors.IsValidU64, `Buy payment index ${buy.payment_index} is not valid`);
637
- }
638
- const coinParam = await getCoinParam(env, tx, buy.total_pay, service_type);
639
- buy.discount = await LocalMark.Instance().get_address(buy.discount);
640
- let quote = undefined;
641
- if (buy.discount) {
642
- quote = tx.moveCall({
643
- target: serviceFn("quote_with_discount"),
644
- arguments: [
645
- toTxObject(tx, service),
646
- tx.makeMoveVec({
647
- elements: buy.items.map((item) => quote_item(tx, item)),
648
- type: `${PackageAddress}::service::QuoteItem`,
649
- }),
650
- toTxObject(tx, buy.discount),
651
- ],
652
- typeArguments: [service_type],
653
- });
654
- }
655
- else {
656
- quote = tx.moveCall({
657
- target: serviceFn("quote"),
658
- arguments: [
659
- toTxObject(tx, service),
660
- tx.makeMoveVec({
661
- elements: buy.items.map((item) => quote_item(tx, item)),
662
- type: `${PackageAddress}::service::QuoteItem`,
663
- }),
664
- ],
665
- typeArguments: [service_type],
666
- });
667
- }
668
- let order;
669
- if (passport) {
670
- order = tx.moveCall({
671
- target: serviceFn("buy_with_passport"),
672
- arguments: [
673
- toTxObject(tx, service),
674
- toTxObject(tx, passport),
675
- quote,
676
- tx.object.mutRegistrar(),
677
- tx.object.clock(),
678
- ],
679
- typeArguments: [service_type],
680
- });
681
- }
682
- else {
683
- order = tx.moveCall({
684
- target: serviceFn("buy"),
685
- arguments: [
686
- toTxObject(tx, service),
687
- quote,
688
- tx.object.mutRegistrar(),
689
- tx.object.clock(),
690
- ],
691
- typeArguments: [service_type],
692
- });
693
- }
694
- const result = {
695
- order: order,
696
- };
697
- result.allocation = tx.moveCall({
698
- target: serviceFn("order_allocation"),
699
- arguments: [
700
- toTxObject(tx, service),
701
- toTxObject(tx, order),
702
- coinParam,
703
- tx.pure.string(buy.payment_remark ?? ""),
704
- tx.pure.u64(buy.payment_index || 0),
705
- tx.object.mutRegistrar(),
706
- tx.object.clock(),
707
- ],
708
- typeArguments: [service_type],
709
- });
710
- if (machine) {
711
- result.progress = tx.moveCall({
712
- target: serviceFn("order_progress"),
713
- arguments: [
714
- toTxObject(tx, service),
715
- toTxObject(tx, order),
716
- toTxObject(tx, machine),
717
- tx.object.mutRegistrar(),
718
- tx.object.clock(),
719
- ],
720
- typeArguments: [service_type],
721
- });
722
- }
723
- return result;
724
- };
725
- export function newService(tx, service_type, permission, description, passport) {
726
- validObjects([permission, passport]);
727
- if (typeof description === "string" && !isValidDescription(description)) {
728
- W_ERROR(WErrors.IsValidDescription, `Description exceeds maximum length ${MAX_DESCRIPTION_LENGTH}`);
729
- }
730
- if (!IsValidArgType(service_type)) {
731
- W_ERROR(WErrors.InvalidParam, `New service type ${service_type} is not valid`);
732
- }
733
- if (passport) {
734
- return tx.moveCall({
735
- target: serviceFn("new_with_passport"),
736
- arguments: [
737
- toTxObject(tx, permission),
738
- toTxObject(tx, passport),
739
- toTxString(tx, description),
740
- tx.object.mutRegistrar(),
741
- tx.object.clock(),
742
- ],
743
- typeArguments: [service_type],
744
- });
745
- }
746
- else {
747
- return tx.moveCall({
748
- target: serviceFn("new"),
749
- arguments: [
750
- toTxObject(tx, permission),
751
- toTxString(tx, description),
752
- tx.object.mutRegistrar(),
753
- tx.object.clock(),
754
- ],
755
- typeArguments: [service_type],
756
- });
757
- }
758
- }
759
- export function description_set(tx, service, service_type, permission, description, passport) {
760
- validObjects([service, permission, passport]);
761
- if (typeof description === "string" && !isValidDescription(description)) {
762
- W_ERROR(WErrors.IsValidDescription, `Description exceeds maximum length ${MAX_DESCRIPTION_LENGTH}`);
763
- }
764
- if (!IsValidArgType(service_type)) {
765
- W_ERROR(WErrors.InvalidParam, `Description set service type ${service_type} is not valid`);
766
- }
767
- if (passport) {
768
- tx.moveCall({
769
- target: serviceFn("description_set_with_passport"),
770
- arguments: [
771
- toTxObject(tx, service),
772
- toTxObject(tx, permission),
773
- toTxObject(tx, passport),
774
- toTxString(tx, description),
775
- ],
776
- typeArguments: [service_type],
777
- });
778
- }
779
- else {
780
- tx.moveCall({
781
- target: serviceFn("description_set"),
782
- arguments: [
783
- toTxObject(tx, service),
784
- toTxObject(tx, permission),
785
- toTxString(tx, description),
786
- ],
787
- typeArguments: [service_type],
788
- });
789
- }
790
- }
791
- export function um_set(tx, service, service_type, permission, um, passport) {
792
- validObjects([service, permission]);
793
- if (!IsValidArgType(service_type)) {
794
- W_ERROR(WErrors.InvalidParam, `Service type ${service_type} is not valid`);
795
- }
796
- if (um) {
797
- if (passport) {
798
- tx.moveCall({
799
- target: serviceFn(`um_set_with_passport`),
800
- arguments: [
801
- toTxObject(tx, service),
802
- toTxObject(tx, permission),
803
- passport,
804
- toTxObject(tx, um),
805
- tx.object.mutRegistrar(),
806
- tx.object.clock(),
807
- ],
808
- typeArguments: [service_type],
809
- });
810
- }
811
- else {
812
- tx.moveCall({
813
- target: serviceFn(`um_set`),
814
- arguments: [
815
- toTxObject(tx, service),
816
- toTxObject(tx, permission),
817
- toTxObject(tx, um),
818
- tx.object.mutRegistrar(),
819
- tx.object.clock(),
820
- ],
821
- typeArguments: [service_type],
822
- });
823
- }
824
- }
825
- else {
826
- if (passport) {
827
- tx.moveCall({
828
- target: serviceFn(`um_none_with_passport`),
829
- arguments: [
830
- toTxObject(tx, service),
831
- toTxObject(tx, permission),
832
- passport,
833
- tx.object.mutRegistrar(),
834
- ],
835
- typeArguments: [service_type],
836
- });
837
- }
838
- else {
839
- tx.moveCall({
840
- target: serviceFn(`um_none`),
841
- arguments: [
842
- toTxObject(tx, service),
843
- toTxObject(tx, permission),
844
- tx.object.mutRegistrar(),
845
- ],
846
- typeArguments: [service_type],
847
- });
848
- }
849
- }
850
- }
851
- export function location_set(tx, service, service_type, permission, location, passport) {
852
- validObjects([service, permission, passport]);
853
- if (typeof location === "string" && !isValidLongName(location)) {
854
- W_ERROR(WErrors.InvalidParam, `Location ${location} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
855
- }
856
- if (!IsValidArgType(service_type)) {
857
- W_ERROR(WErrors.InvalidParam, `Location set service type ${service_type} is not valid`);
858
- }
859
- if (passport) {
860
- tx.moveCall({
861
- target: serviceFn("location_set_with_passport"),
862
- arguments: [
863
- toTxObject(tx, service),
864
- toTxObject(tx, permission),
865
- toTxObject(tx, passport),
866
- toTxString(tx, location),
867
- ],
868
- typeArguments: [service_type],
869
- });
870
- }
871
- else {
872
- tx.moveCall({
873
- target: serviceFn("location_set"),
874
- arguments: [
875
- toTxObject(tx, service),
876
- toTxObject(tx, permission),
877
- toTxString(tx, location),
878
- ],
879
- typeArguments: [service_type],
880
- });
881
- }
882
- }
883
- export function create(tx, service, service_type) {
884
- validObjects([service]);
885
- if (!IsValidArgType(service_type)) {
886
- W_ERROR(WErrors.InvalidParam, `Create service type ${service_type} is not valid`);
887
- }
888
- return tx.moveCall({
889
- target: serviceFn("create"),
890
- arguments: [toTxObject(tx, service)],
891
- typeArguments: [service_type],
892
- });
893
- }
894
- export function sales_add(tx, service, service_type, permission, sales, passport) {
895
- if (sales.length === 0) {
896
- return;
897
- }
898
- validObjects([service, permission, passport]);
899
- if (!IsValidArgType(service_type)) {
900
- W_ERROR(WErrors.InvalidParam, `Sales add service type ${service_type} is not valid`);
901
- }
902
- if (passport) {
903
- tx.moveCall({
904
- target: serviceFn("sales_add_with_passport"),
905
- arguments: [
906
- toTxObject(tx, service),
907
- toTxObject(tx, permission),
908
- toTxObject(tx, passport),
909
- tx.makeMoveVec({
910
- elements: sales.map((s) => sale(tx, s)),
911
- type: `${PackageAddress}::service::Sale`,
912
- }),
913
- ],
914
- typeArguments: [service_type],
915
- });
916
- }
917
- else {
918
- tx.moveCall({
919
- target: serviceFn("sales_add"),
920
- arguments: [
921
- toTxObject(tx, service),
922
- toTxObject(tx, permission),
923
- tx.makeMoveVec({
924
- elements: sales.map((s) => sale(tx, s)),
925
- type: `${PackageAddress}::service::Sale`,
926
- }),
927
- ],
928
- typeArguments: [service_type],
929
- });
930
- }
931
- }
932
- export function sales_remove(tx, service, service_type, permission, sales_name, passport) {
933
- if (sales_name.length === 0) {
934
- return;
935
- }
936
- validObjects([service, permission, passport]);
937
- if (!IsValidArgType(service_type)) {
938
- W_ERROR(WErrors.InvalidParam, `Sales remove service type ${service_type} is not valid`);
939
- }
940
- if (passport) {
941
- tx.moveCall({
942
- target: serviceFn("sales_remove_with_passport"),
943
- arguments: [
944
- toTxObject(tx, service),
945
- toTxObject(tx, permission),
946
- toTxObject(tx, passport),
947
- tx.pure.vector("string", sales_name),
948
- ],
949
- typeArguments: [service_type],
950
- });
951
- }
952
- else {
953
- tx.moveCall({
954
- target: serviceFn("sales_remove"),
955
- arguments: [
956
- toTxObject(tx, service),
957
- toTxObject(tx, permission),
958
- tx.pure.vector("string", sales_name),
959
- ],
960
- typeArguments: [service_type],
961
- });
962
- }
963
- }
964
- export function sales_clear(tx, service, service_type, permission, passport) {
965
- validObjects([service, permission, passport]);
966
- if (!IsValidArgType(service_type)) {
967
- W_ERROR(WErrors.InvalidParam, `Sales clear service type ${service_type} is not valid`);
968
- }
969
- if (passport) {
970
- tx.moveCall({
971
- target: serviceFn("sales_clear_with_passport"),
972
- arguments: [
973
- toTxObject(tx, service),
974
- toTxObject(tx, permission),
975
- toTxObject(tx, passport),
976
- ],
977
- typeArguments: [service_type],
978
- });
979
- }
980
- else {
981
- tx.moveCall({
982
- target: serviceFn("sales_clear"),
983
- arguments: [toTxObject(tx, service), toTxObject(tx, permission)],
984
- typeArguments: [service_type],
985
- });
986
- }
987
- }
988
- export function sales_set(tx, service, service_type, permission, sales, passport) {
989
- if (sales.length === 0) {
990
- return;
991
- }
992
- validObjects([service, permission, passport]);
993
- if (!IsValidArgType(service_type)) {
994
- W_ERROR(WErrors.InvalidParam, `Sales set service type ${service_type} is not valid`);
995
- }
996
- if (passport) {
997
- tx.moveCall({
998
- target: serviceFn("sales_set_with_passport"),
999
- arguments: [
1000
- toTxObject(tx, service),
1001
- toTxObject(tx, permission),
1002
- toTxObject(tx, passport),
1003
- tx.makeMoveVec({
1004
- elements: sales.map((s) => sale(tx, s)),
1005
- type: `${PackageAddress}::service::Sale`,
1006
- }),
1007
- ],
1008
- typeArguments: [service_type],
1009
- });
1010
- }
1011
- else {
1012
- tx.moveCall({
1013
- target: serviceFn("sales_set"),
1014
- arguments: [
1015
- toTxObject(tx, service),
1016
- toTxObject(tx, permission),
1017
- tx.makeMoveVec({
1018
- elements: sales.map((s) => sale(tx, s)),
1019
- type: `${PackageAddress}::service::Sale`,
1020
- }),
1021
- ],
1022
- typeArguments: [service_type],
1023
- });
1024
- }
1025
- }
1026
- export function price_add(tx, service, service_type, permission, sale_name, price_add, passport) {
1027
- validObjects([service, permission, passport]);
1028
- if (!IsValidArgType(service_type)) {
1029
- W_ERROR(WErrors.InvalidParam, `Price add service type ${service_type} is not valid`);
1030
- }
1031
- if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
1032
- W_ERROR(WErrors.InvalidParam, `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
1033
- }
1034
- if (!isValidU64(price_add)) {
1035
- W_ERROR(WErrors.IsValidU64, `Price add ${price_add} is not valid`);
1036
- }
1037
- if (passport) {
1038
- tx.moveCall({
1039
- target: serviceFn("price_add_with_passport"),
1040
- arguments: [
1041
- toTxObject(tx, service),
1042
- toTxObject(tx, permission),
1043
- toTxObject(tx, passport),
1044
- toTxString(tx, sale_name),
1045
- tx.pure.u64(price_add),
1046
- ],
1047
- typeArguments: [service_type],
1048
- });
1049
- }
1050
- else {
1051
- tx.moveCall({
1052
- target: serviceFn("price_add"),
1053
- arguments: [
1054
- toTxObject(tx, service),
1055
- toTxObject(tx, permission),
1056
- toTxString(tx, sale_name),
1057
- tx.pure.u64(price_add),
1058
- ],
1059
- typeArguments: [service_type],
1060
- });
1061
- }
1062
- }
1063
- export function price_reduce(tx, service, service_type, permission, sale_name, price_reduce, passport) {
1064
- validObjects([service, permission, passport]);
1065
- if (!IsValidArgType(service_type)) {
1066
- W_ERROR(WErrors.InvalidParam, `Price reduce service type ${service_type} is not valid`);
1067
- }
1068
- if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
1069
- W_ERROR(WErrors.InvalidParam, `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
1070
- }
1071
- if (!isValidU64(price_reduce)) {
1072
- W_ERROR(WErrors.IsValidU64, `Price reduce ${price_reduce} is not valid`);
1073
- }
1074
- if (passport) {
1075
- tx.moveCall({
1076
- target: serviceFn("price_reduce_with_passport"),
1077
- arguments: [
1078
- toTxObject(tx, service),
1079
- toTxObject(tx, permission),
1080
- toTxObject(tx, passport),
1081
- toTxString(tx, sale_name),
1082
- tx.pure.u64(price_reduce),
1083
- ],
1084
- typeArguments: [service_type],
1085
- });
1086
- }
1087
- else {
1088
- tx.moveCall({
1089
- target: serviceFn("price_reduce"),
1090
- arguments: [
1091
- toTxObject(tx, service),
1092
- toTxObject(tx, permission),
1093
- toTxString(tx, sale_name),
1094
- tx.pure.u64(price_reduce),
1095
- ],
1096
- typeArguments: [service_type],
1097
- });
1098
- }
1099
- }
1100
- export function stock_add(tx, service, service_type, permission, sale_name, stock_add, passport) {
1101
- validObjects([service, permission, passport]);
1102
- if (!IsValidArgType(service_type)) {
1103
- W_ERROR(WErrors.InvalidParam, `Stock add service type ${service_type} is not valid`);
1104
- }
1105
- if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
1106
- W_ERROR(WErrors.InvalidParam, `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
1107
- }
1108
- if (!isValidU64(stock_add)) {
1109
- W_ERROR(WErrors.IsValidU64, `Stock add ${stock_add} is not valid`);
1110
- }
1111
- if (passport) {
1112
- tx.moveCall({
1113
- target: serviceFn("stock_add_with_passport"),
1114
- arguments: [
1115
- toTxObject(tx, service),
1116
- toTxObject(tx, permission),
1117
- toTxObject(tx, passport),
1118
- toTxString(tx, sale_name),
1119
- tx.pure.u64(stock_add),
1120
- ],
1121
- typeArguments: [service_type],
1122
- });
1123
- }
1124
- else {
1125
- tx.moveCall({
1126
- target: serviceFn("stock_add"),
1127
- arguments: [
1128
- toTxObject(tx, service),
1129
- toTxObject(tx, permission),
1130
- toTxString(tx, sale_name),
1131
- tx.pure.u64(stock_add),
1132
- ],
1133
- typeArguments: [service_type],
1134
- });
1135
- }
1136
- }
1137
- export function stock_reduce(tx, service, service_type, permission, sale_name, stock_reduce, passport) {
1138
- validObjects([service, permission, passport]);
1139
- if (!IsValidArgType(service_type)) {
1140
- W_ERROR(WErrors.InvalidParam, `Stock reduce service type ${service_type} is not valid`);
1141
- }
1142
- if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
1143
- W_ERROR(WErrors.InvalidParam, `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
1144
- }
1145
- if (!isValidU64(stock_reduce)) {
1146
- W_ERROR(WErrors.IsValidU64, `Stock reduce ${stock_reduce} is not valid`);
1147
- }
1148
- if (passport) {
1149
- tx.moveCall({
1150
- target: serviceFn("stock_reduce_with_passport"),
1151
- arguments: [
1152
- toTxObject(tx, service),
1153
- toTxObject(tx, permission),
1154
- toTxObject(tx, passport),
1155
- toTxString(tx, sale_name),
1156
- tx.pure.u64(stock_reduce),
1157
- ],
1158
- typeArguments: [service_type],
1159
- });
1160
- }
1161
- else {
1162
- tx.moveCall({
1163
- target: serviceFn("stock_reduce"),
1164
- arguments: [
1165
- toTxObject(tx, service),
1166
- toTxObject(tx, permission),
1167
- toTxString(tx, sale_name),
1168
- tx.pure.u64(stock_reduce),
1169
- ],
1170
- typeArguments: [service_type],
1171
- });
1172
- }
1173
- }
1174
- export function sale_suspension(tx, service, service_type, permission, sale_name, suspension, passport) {
1175
- validObjects([service, permission, passport]);
1176
- if (!IsValidArgType(service_type)) {
1177
- W_ERROR(WErrors.InvalidParam, `Sale suspension service type ${service_type} is not valid`);
1178
- }
1179
- if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
1180
- W_ERROR(WErrors.InvalidParam, `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`);
1181
- }
1182
- if (passport) {
1183
- tx.moveCall({
1184
- target: serviceFn("sale_suspension_with_passport"),
1185
- arguments: [
1186
- toTxObject(tx, service),
1187
- toTxObject(tx, permission),
1188
- toTxObject(tx, passport),
1189
- toTxString(tx, sale_name),
1190
- tx.pure.bool(suspension),
1191
- ],
1192
- typeArguments: [service_type],
1193
- });
1194
- }
1195
- else {
1196
- tx.moveCall({
1197
- target: serviceFn("sale_suspension"),
1198
- arguments: [
1199
- toTxObject(tx, service),
1200
- toTxObject(tx, permission),
1201
- toTxString(tx, sale_name),
1202
- tx.pure.bool(suspension),
1203
- ],
1204
- typeArguments: [service_type],
1205
- });
1206
- }
1207
- }
1208
- export function repository_add(tx, service, service_type, permission, repository, passport) {
1209
- validObjects([service, permission, repository, passport]);
1210
- if (!IsValidArgType(service_type)) {
1211
- W_ERROR(WErrors.InvalidParam, `Repository add service type ${service_type} is not valid`);
1212
- }
1213
- if (passport) {
1214
- tx.moveCall({
1215
- target: serviceFn("repository_add_with_passport"),
1216
- arguments: [
1217
- toTxObject(tx, service),
1218
- toTxObject(tx, permission),
1219
- toTxObject(tx, passport),
1220
- toTxObject(tx, repository),
1221
- tx.object.mutRegistrar(),
1222
- tx.object.clock(),
1223
- ],
1224
- typeArguments: [service_type],
1225
- });
1226
- }
1227
- else {
1228
- tx.moveCall({
1229
- target: serviceFn("repository_add"),
1230
- arguments: [
1231
- toTxObject(tx, service),
1232
- toTxObject(tx, permission),
1233
- toTxObject(tx, repository),
1234
- tx.object.mutRegistrar(),
1235
- tx.object.clock(),
1236
- ],
1237
- typeArguments: [service_type],
1238
- });
1239
- }
1240
- }
1241
- export function repository_remove(tx, service, service_type, permission, repositories, passport) {
1242
- if (repositories.length === 0) {
1243
- return;
1244
- }
1245
- validObjects([service, permission, passport, ...repositories]);
1246
- if (!IsValidArgType(service_type)) {
1247
- W_ERROR(WErrors.InvalidParam, `Repository remove service type ${service_type} is not valid`);
1248
- }
1249
- if (passport) {
1250
- tx.moveCall({
1251
- target: serviceFn("repository_remove_with_passport"),
1252
- arguments: [
1253
- toTxObject(tx, service),
1254
- toTxObject(tx, permission),
1255
- toTxObject(tx, passport),
1256
- tx.pure.vector("address", repositories),
1257
- tx.object.mutRegistrar(),
1258
- ],
1259
- typeArguments: [service_type],
1260
- });
1261
- }
1262
- else {
1263
- tx.moveCall({
1264
- target: serviceFn("repository_remove"),
1265
- arguments: [
1266
- toTxObject(tx, service),
1267
- toTxObject(tx, permission),
1268
- tx.pure.vector("address", repositories),
1269
- tx.object.mutRegistrar(),
1270
- ],
1271
- typeArguments: [service_type],
1272
- });
1273
- }
1274
- }
1275
- export function repository_clear(tx, service, service_type, permission, passport) {
1276
- validObjects([service, permission, passport]);
1277
- if (!IsValidArgType(service_type)) {
1278
- W_ERROR(WErrors.InvalidParam, `Repository clear service type ${service_type} is not valid`);
1279
- }
1280
- if (passport) {
1281
- tx.moveCall({
1282
- target: serviceFn("repository_clear_with_passport"),
1283
- arguments: [
1284
- toTxObject(tx, service),
1285
- toTxObject(tx, permission),
1286
- toTxObject(tx, passport),
1287
- tx.object.mutRegistrar(),
1288
- ],
1289
- typeArguments: [service_type],
1290
- });
1291
- }
1292
- else {
1293
- tx.moveCall({
1294
- target: serviceFn("repository_clear"),
1295
- arguments: [
1296
- toTxObject(tx, service),
1297
- toTxObject(tx, permission),
1298
- tx.object.mutRegistrar(),
1299
- ],
1300
- typeArguments: [service_type],
1301
- });
1302
- }
1303
- }
1304
- export function buy_guard_set(tx, service, service_type, permission, guard, passport) {
1305
- validObjects([service, permission, guard, passport]);
1306
- if (!IsValidArgType(service_type)) {
1307
- W_ERROR(WErrors.InvalidParam, `Buy guard set service type ${service_type} is not valid`);
1308
- }
1309
- if (passport) {
1310
- if (guard) {
1311
- tx.moveCall({
1312
- target: serviceFn("buy_guard_set_with_passport"),
1313
- arguments: [
1314
- toTxObject(tx, service),
1315
- toTxObject(tx, permission),
1316
- toTxObject(tx, passport),
1317
- toTxObject(tx, guard),
1318
- tx.object.mutRegistrar(),
1319
- tx.object.clock(),
1320
- ],
1321
- typeArguments: [service_type],
1322
- });
1323
- }
1324
- else {
1325
- tx.moveCall({
1326
- target: serviceFn("buy_guard_none_with_passport"),
1327
- arguments: [
1328
- toTxObject(tx, service),
1329
- toTxObject(tx, permission),
1330
- toTxObject(tx, passport),
1331
- tx.object.mutRegistrar(),
1332
- ],
1333
- typeArguments: [service_type],
1334
- });
1335
- }
1336
- }
1337
- else {
1338
- if (guard) {
1339
- tx.moveCall({
1340
- target: serviceFn("buy_guard_set"),
1341
- arguments: [
1342
- toTxObject(tx, service),
1343
- toTxObject(tx, permission),
1344
- toTxObject(tx, guard),
1345
- tx.object.mutRegistrar(),
1346
- tx.object.clock(),
1347
- ],
1348
- typeArguments: [service_type],
1349
- });
1350
- }
1351
- else {
1352
- tx.moveCall({
1353
- target: serviceFn("buy_guard_none"),
1354
- arguments: [
1355
- toTxObject(tx, service),
1356
- toTxObject(tx, permission),
1357
- tx.object.mutRegistrar(),
1358
- ],
1359
- typeArguments: [service_type],
1360
- });
1361
- }
1362
- }
1363
- }
1364
- export function machine_set(tx, service, service_type, permission, machine, passport) {
1365
- validObjects([service, permission, machine, passport]);
1366
- if (!IsValidArgType(service_type)) {
1367
- W_ERROR(WErrors.InvalidParam, `Machine set service type ${service_type} is not valid`);
1368
- }
1369
- if (passport) {
1370
- if (machine) {
1371
- tx.moveCall({
1372
- target: serviceFn("machine_set_with_passport"),
1373
- arguments: [
1374
- toTxObject(tx, service),
1375
- toTxObject(tx, permission),
1376
- toTxObject(tx, passport),
1377
- toTxObject(tx, machine),
1378
- tx.object.mutRegistrar(),
1379
- tx.object.clock(),
1380
- ],
1381
- typeArguments: [service_type],
1382
- });
1383
- }
1384
- else {
1385
- tx.moveCall({
1386
- target: serviceFn("machine_none_with_passport"),
1387
- arguments: [
1388
- toTxObject(tx, service),
1389
- toTxObject(tx, permission),
1390
- toTxObject(tx, passport),
1391
- tx.object.mutRegistrar(),
1392
- ],
1393
- typeArguments: [service_type],
1394
- });
1395
- }
1396
- }
1397
- else {
1398
- if (machine) {
1399
- tx.moveCall({
1400
- target: serviceFn("machine_set"),
1401
- arguments: [
1402
- toTxObject(tx, service),
1403
- toTxObject(tx, permission),
1404
- toTxObject(tx, machine),
1405
- tx.object.mutRegistrar(),
1406
- tx.object.clock(),
1407
- ],
1408
- typeArguments: [service_type],
1409
- });
1410
- }
1411
- else {
1412
- tx.moveCall({
1413
- target: serviceFn("machine_set_none"),
1414
- arguments: [
1415
- toTxObject(tx, service),
1416
- toTxObject(tx, permission),
1417
- tx.object.mutRegistrar(),
1418
- ],
1419
- typeArguments: [service_type],
1420
- });
1421
- }
1422
- }
1423
- }
1424
- export function publish(tx, service, service_type, permission, passport) {
1425
- validObjects([service, permission, passport]);
1426
- if (!IsValidArgType(service_type)) {
1427
- W_ERROR(WErrors.InvalidParam, `Publish service type ${service_type} is not valid`);
1428
- }
1429
- if (passport) {
1430
- tx.moveCall({
1431
- target: serviceFn("publish_with_passport"),
1432
- arguments: [
1433
- toTxObject(tx, service),
1434
- toTxObject(tx, permission),
1435
- toTxObject(tx, passport),
1436
- ],
1437
- typeArguments: [service_type],
1438
- });
1439
- }
1440
- else {
1441
- tx.moveCall({
1442
- target: serviceFn("publish"),
1443
- arguments: [toTxObject(tx, service), toTxObject(tx, permission)],
1444
- typeArguments: [service_type],
1445
- });
1446
- }
1447
- }
1448
- export function pause(tx, service, service_type, permission, bPaused, passport) {
1449
- validObjects([service, permission, passport]);
1450
- if (!IsValidArgType(service_type)) {
1451
- W_ERROR(WErrors.InvalidParam, `Pause service type ${service_type} is not valid`);
1452
- }
1453
- if (passport) {
1454
- tx.moveCall({
1455
- target: serviceFn("pause_with_passport"),
1456
- arguments: [
1457
- toTxObject(tx, service),
1458
- toTxObject(tx, permission),
1459
- toTxObject(tx, passport),
1460
- tx.pure.bool(bPaused),
1461
- tx.object.clock(),
1462
- ],
1463
- typeArguments: [service_type],
1464
- });
1465
- }
1466
- else {
1467
- tx.moveCall({
1468
- target: serviceFn("pause"),
1469
- arguments: [
1470
- toTxObject(tx, service),
1471
- toTxObject(tx, permission),
1472
- tx.pure.bool(bPaused),
1473
- tx.object.clock(),
1474
- ],
1475
- typeArguments: [service_type],
1476
- });
1477
- }
1478
- }
1479
- export function customer_required_set(tx, service, service_type, permission, required_info, passport) {
1480
- if (required_info.length > MAX_REQUIRED_INFO_SIZE) {
1481
- W_ERROR(WErrors.InvalidParam, `Customer required set size ${required_info.length} is exceed maximum size ${MAX_REQUIRED_INFO_SIZE}`);
1482
- }
1483
- validObjects([service, permission, passport]);
1484
- if (!IsValidArgType(service_type)) {
1485
- W_ERROR(WErrors.InvalidParam, `Customer required set service type ${service_type} is not valid`);
1486
- }
1487
- required_info.forEach((item) => {
1488
- if (!isValidName(item)) {
1489
- W_ERROR(WErrors.InvalidParam, `Customer required info ${item} is exceed maximum length ${MAX_NAME_LENGTH} or start with "0x"`);
1490
- }
1491
- });
1492
- if (passport) {
1493
- tx.moveCall({
1494
- target: serviceFn("custom_required_info_set_with_passport"),
1495
- arguments: [
1496
- toTxObject(tx, service),
1497
- toTxObject(tx, permission),
1498
- toTxObject(tx, passport),
1499
- tx.pure.vector("string", required_info),
1500
- ],
1501
- typeArguments: [service_type],
1502
- });
1503
- }
1504
- else {
1505
- tx.moveCall({
1506
- target: serviceFn("custom_required_info_set"),
1507
- arguments: [
1508
- toTxObject(tx, service),
1509
- toTxObject(tx, permission),
1510
- tx.pure.vector("string", required_info),
1511
- ],
1512
- typeArguments: [service_type],
1513
- });
1514
- }
1515
- }
1516
- export function arbitrations_add(tx, service, service_type, permission, arbitration, arbitration_type, passport) {
1517
- validObjects([service, permission, arbitration, passport]);
1518
- if (!IsValidArgType(service_type)) {
1519
- W_ERROR(WErrors.InvalidParam, `Arbitrations add service type ${service_type} is not valid`);
1520
- }
1521
- if (!IsValidArgType(arbitration_type)) {
1522
- W_ERROR(WErrors.InvalidParam, `Arbitrations add arbitration type ${arbitration_type} is not valid`);
1523
- }
1524
- if (passport) {
1525
- tx.moveCall({
1526
- target: serviceFn("arbitration_add_with_passport"),
1527
- arguments: [
1528
- toTxObject(tx, service),
1529
- toTxObject(tx, permission),
1530
- toTxObject(tx, passport),
1531
- toTxObject(tx, arbitration),
1532
- tx.object.mutRegistrar(),
1533
- tx.object.clock(),
1534
- ],
1535
- typeArguments: [service_type],
1536
- });
1537
- }
1538
- else {
1539
- tx.moveCall({
1540
- target: serviceFn("arbitration_add"),
1541
- arguments: [
1542
- toTxObject(tx, service),
1543
- toTxObject(tx, permission),
1544
- toTxObject(tx, arbitration),
1545
- tx.object.mutRegistrar(),
1546
- tx.object.clock(),
1547
- ],
1548
- typeArguments: [service_type, arbitration_type],
1549
- });
1550
- }
1551
- }
1552
- export function arbitrations_remove(tx, service, service_type, permission, arbitrations, passport) {
1553
- if (arbitrations.length === 0) {
1554
- return;
1555
- }
1556
- validObjects([service, permission, passport]);
1557
- if (!IsValidArgType(service_type)) {
1558
- W_ERROR(WErrors.InvalidParam, `Arbitrations remove service type ${service_type} is not valid`);
1559
- }
1560
- if (passport) {
1561
- tx.moveCall({
1562
- target: serviceFn("arbitration_remove_with_passport"),
1563
- arguments: [
1564
- toTxObject(tx, service),
1565
- toTxObject(tx, permission),
1566
- toTxObject(tx, passport),
1567
- tx.pure.vector("address", arbitrations),
1568
- tx.object.mutRegistrar(),
1569
- ],
1570
- typeArguments: [service_type],
1571
- });
1572
- }
1573
- else {
1574
- tx.moveCall({
1575
- target: serviceFn("arbitration_remove"),
1576
- arguments: [
1577
- toTxObject(tx, service),
1578
- toTxObject(tx, permission),
1579
- tx.pure.vector("address", arbitrations),
1580
- tx.object.mutRegistrar(),
1581
- ],
1582
- typeArguments: [service_type],
1583
- });
1584
- }
1585
- }
1586
- export function arbitration_clear(tx, service, service_type, permission, passport) {
1587
- validObjects([service, permission, passport]);
1588
- if (!IsValidArgType(service_type)) {
1589
- W_ERROR(WErrors.InvalidParam, `Arbitrations clear service type ${service_type} is not valid`);
1590
- }
1591
- if (passport) {
1592
- tx.moveCall({
1593
- target: serviceFn("arbitration_clear_with_passport"),
1594
- arguments: [
1595
- toTxObject(tx, service),
1596
- toTxObject(tx, permission),
1597
- toTxObject(tx, passport),
1598
- tx.object.mutRegistrar(),
1599
- ],
1600
- typeArguments: [service_type],
1601
- });
1602
- }
1603
- else {
1604
- tx.moveCall({
1605
- target: serviceFn("arbitration_clear"),
1606
- arguments: [
1607
- toTxObject(tx, service),
1608
- toTxObject(tx, permission),
1609
- tx.object.mutRegistrar(),
1610
- ],
1611
- typeArguments: [service_type],
1612
- });
1613
- }
1614
- }
1615
- export async function compensation_fund_add(env, tx, service, service_type, permission, coin, passport) {
1616
- validObjects([service, permission, passport]);
1617
- if (!IsValidArgType(service_type)) {
1618
- W_ERROR(WErrors.InvalidParam, `Compensation fund add service type ${service_type} is not valid`);
1619
- }
1620
- const coinParam = await getCoinParam(env, tx, coin, service_type);
1621
- if (passport) {
1622
- tx.moveCall({
1623
- target: serviceFn("compensation_fund_add_with_passport"),
1624
- arguments: [
1625
- toTxObject(tx, service),
1626
- toTxObject(tx, permission),
1627
- toTxObject(tx, passport),
1628
- coinParam,
1629
- ],
1630
- typeArguments: [service_type],
1631
- });
1632
- }
1633
- else {
1634
- tx.moveCall({
1635
- target: serviceFn("compensation_fund_add"),
1636
- arguments: [
1637
- toTxObject(tx, service),
1638
- toTxObject(tx, permission),
1639
- coinParam,
1640
- ],
1641
- typeArguments: [service_type],
1642
- });
1643
- }
1644
- }
1645
- export function compensation_lock_duration_set(tx, service, service_type, permission, duration_ms, passport) {
1646
- if (!isValidU64(duration_ms) || duration_ms === 0) {
1647
- return;
1648
- }
1649
- validObjects([service, permission, passport]);
1650
- if (!IsValidArgType(service_type)) {
1651
- W_ERROR(WErrors.InvalidParam, `Compensation lock duration set service type ${service_type} is not valid`);
1652
- }
1653
- if (passport) {
1654
- tx.moveCall({
1655
- target: serviceFn("compensation_lock_duration_add_with_passport"),
1656
- arguments: [
1657
- toTxObject(tx, service),
1658
- toTxObject(tx, permission),
1659
- toTxObject(tx, passport),
1660
- tx.pure.u64(duration_ms),
1661
- ],
1662
- typeArguments: [service_type],
1663
- });
1664
- }
1665
- else {
1666
- tx.moveCall({
1667
- target: serviceFn("compensation_lock_duration_add"),
1668
- arguments: [
1669
- toTxObject(tx, service),
1670
- toTxObject(tx, permission),
1671
- tx.pure.u64(duration_ms),
1672
- ],
1673
- typeArguments: [service_type],
1674
- });
1675
- }
1676
- }
1677
- export function order_allocators_set(tx, service, service_type, permission, allocators, passport) {
1678
- validObjects([service, permission, allocators, passport]);
1679
- if (!IsValidArgType(service_type)) {
1680
- W_ERROR(WErrors.InvalidParam, `Order allocators set service type ${service_type} is not valid`);
1681
- }
1682
- if (passport) {
1683
- tx.moveCall({
1684
- target: serviceFn("order_allocators_set_with_passport"),
1685
- arguments: [
1686
- toTxObject(tx, service),
1687
- toTxObject(tx, permission),
1688
- toTxObject(tx, passport),
1689
- tx.object.option({
1690
- type: `${PackageAddress}::allocation::Allocators`,
1691
- value: allocators ?? null,
1692
- }),
1693
- ],
1694
- typeArguments: [service_type],
1695
- });
1696
- }
1697
- else {
1698
- tx.moveCall({
1699
- target: serviceFn("order_allocators_set"),
1700
- arguments: [
1701
- toTxObject(tx, service),
1702
- toTxObject(tx, permission),
1703
- tx.object.option({
1704
- type: `${PackageAddress}::allocation::Allocators`,
1705
- value: allocators ?? null,
1706
- }),
1707
- ],
1708
- typeArguments: [service_type],
1709
- });
1710
- }
1711
- }
1712
- export function reward_add(tx, service, service_type, permission, reward, reward_type, passport) {
1713
- validObjects([service, permission, reward, passport]);
1714
- if (!IsValidArgType(service_type)) {
1715
- W_ERROR(WErrors.InvalidParam, `Rewards add service type ${service_type} is not valid`);
1716
- }
1717
- if (!IsValidArgType(reward_type)) {
1718
- W_ERROR(WErrors.InvalidParam, `Rewards add reward type ${reward_type} is not valid`);
1719
- }
1720
- if (passport) {
1721
- tx.moveCall({
1722
- target: serviceFn("reward_add_with_passport"),
1723
- arguments: [
1724
- toTxObject(tx, service),
1725
- toTxObject(tx, permission),
1726
- toTxObject(tx, passport),
1727
- toTxObject(tx, reward),
1728
- tx.object.mutRegistrar(),
1729
- tx.object.clock(),
1730
- ],
1731
- typeArguments: [service_type, reward_type],
1732
- });
1733
- }
1734
- else {
1735
- tx.moveCall({
1736
- target: serviceFn("reward_add"),
1737
- arguments: [
1738
- toTxObject(tx, service),
1739
- toTxObject(tx, permission),
1740
- toTxObject(tx, reward),
1741
- tx.object.mutRegistrar(),
1742
- tx.object.clock(),
1743
- ],
1744
- typeArguments: [service_type, reward_type],
1745
- });
1746
- }
1747
- }
1748
- export function reward_remove(tx, service, service_type, permission, rewards, passport) {
1749
- if (rewards.length === 0) {
1750
- return;
1751
- }
1752
- validObjects([service, permission, passport]);
1753
- if (!IsValidArgType(service_type)) {
1754
- W_ERROR(WErrors.InvalidParam, `Rewards remove service type ${service_type} is not valid`);
1755
- }
1756
- if (passport) {
1757
- tx.moveCall({
1758
- target: serviceFn("reward_remove_with_passport"),
1759
- arguments: [
1760
- toTxObject(tx, service),
1761
- toTxObject(tx, permission),
1762
- toTxObject(tx, passport),
1763
- tx.pure.vector("address", rewards),
1764
- tx.object.mutRegistrar(),
1765
- ],
1766
- typeArguments: [service_type],
1767
- });
1768
- }
1769
- else {
1770
- tx.moveCall({
1771
- target: serviceFn("reward_remove"),
1772
- arguments: [
1773
- toTxObject(tx, service),
1774
- toTxObject(tx, permission),
1775
- tx.pure.vector("address", rewards),
1776
- tx.object.mutRegistrar(),
1777
- ],
1778
- typeArguments: [service_type],
1779
- });
1780
- }
1781
- }
1782
- export function reward_clear(tx, service, service_type, permission, passport) {
1783
- validObjects([service, permission, passport]);
1784
- if (!IsValidArgType(service_type)) {
1785
- W_ERROR(WErrors.InvalidParam, `Rewards clear service type ${service_type} is not valid`);
1786
- }
1787
- if (passport) {
1788
- tx.moveCall({
1789
- target: serviceFn("reward_clear_with_passport"),
1790
- arguments: [
1791
- toTxObject(tx, service),
1792
- toTxObject(tx, permission),
1793
- toTxObject(tx, passport),
1794
- tx.object.mutRegistrar(),
1795
- ],
1796
- typeArguments: [service_type],
1797
- });
1798
- }
1799
- else {
1800
- tx.moveCall({
1801
- target: serviceFn("reward_clear"),
1802
- arguments: [
1803
- toTxObject(tx, service),
1804
- toTxObject(tx, permission),
1805
- tx.object.mutRegistrar(),
1806
- ],
1807
- typeArguments: [service_type],
1808
- });
1809
- }
1810
- }
1811
- export function compensation_fund_receive(tx, service, service_type, permission, received_object, payment, passport) {
1812
- if (!payment) {
1813
- W_ERROR(WErrors.InvalidParam, `Compensation fund receive payment is required`);
1814
- }
1815
- validObjects([service, permission, received_object, payment, passport]);
1816
- if (!IsValidArgType(service_type)) {
1817
- W_ERROR(WErrors.InvalidParam, `Compensation fund receive service type ${service_type} is not valid`);
1818
- }
1819
- if (passport) {
1820
- tx.moveCall({
1821
- target: serviceFn("compensation_fund_receive_with_passport"),
1822
- arguments: [
1823
- toTxObject(tx, service),
1824
- toTxObject(tx, permission),
1825
- toTxObject(tx, passport),
1826
- toTxObject(tx, received_object),
1827
- toTxObject(tx, payment),
1828
- ],
1829
- typeArguments: [service_type],
1830
- });
1831
- }
1832
- else {
1833
- tx.moveCall({
1834
- target: serviceFn("compensation_fund_receive"),
1835
- arguments: [
1836
- toTxObject(tx, service),
1837
- toTxObject(tx, permission),
1838
- toTxObject(tx, received_object),
1839
- toTxObject(tx, payment),
1840
- ],
1841
- typeArguments: [service_type],
1842
- });
1843
- }
1844
- }
1845
- export function compensation_fund_withdraw(tx, service, service_type, payment_info, receipt, permission, passport) {
1846
- validObjects([service, permission, receipt, payment_info, passport]);
1847
- if (!IsValidArgType(service_type)) {
1848
- W_ERROR(WErrors.InvalidParam, `Compensation fund withdraw service type ${service_type} is not valid`);
1849
- }
1850
- if (passport) {
1851
- tx.moveCall({
1852
- target: serviceFn("compensation_fund_withdraw_with_passport"),
1853
- arguments: [
1854
- toTxObject(tx, service),
1855
- toTxObject(tx, permission),
1856
- toTxObject(tx, passport),
1857
- tx.pure.address(receipt),
1858
- toTxObject(tx, payment_info),
1859
- tx.object.mutRegistrar(),
1860
- tx.object.clock(),
1861
- ],
1862
- typeArguments: [service_type],
1863
- });
1864
- }
1865
- else {
1866
- tx.moveCall({
1867
- target: serviceFn("compensation_fund_withdraw"),
1868
- arguments: [
1869
- toTxObject(tx, service),
1870
- toTxObject(tx, permission),
1871
- tx.pure.address(receipt),
1872
- toTxObject(tx, payment_info),
1873
- tx.object.mutRegistrar(),
1874
- tx.object.clock(),
1875
- ],
1876
- typeArguments: [service_type],
1877
- });
1878
- }
1879
- }
1880
- export async function discount(tx, service, service_type, permission, discount, passport) {
1881
- let recipient = [];
1882
- if (Array.isArray(discount.recipient)) {
1883
- recipient = discount.recipient;
1884
- }
1885
- else {
1886
- recipient = await GetManyAccountOrMark_Address(discount.recipient);
1887
- }
1888
- if (recipient.length === 0 || discount.count === 0) {
1889
- return;
1890
- }
1891
- if (recipient.length > MAX_DISCOUNT_RECEIVER_ONCE) {
1892
- W_ERROR(WErrors.InvalidParam, `Discount recipient length ${recipient.length} is exceed max ${MAX_DISCOUNT_RECEIVER_ONCE}`);
1893
- }
1894
- if (!isValidName(discount.name)) {
1895
- W_ERROR(WErrors.InvalidParam, `Discount name ${discount.name} is not valid`);
1896
- }
1897
- if (!isValidU16(discount.count) ||
1898
- discount.count > MAX_DISCOUNT_COUNT_ONCE) {
1899
- W_ERROR(WErrors.InvalidParam, `Discount count ${discount.count} is exceed max ${MAX_DISCOUNT_COUNT_ONCE}`);
1900
- }
1901
- if (recipient.length * discount.count > MAX_DISCOUNT_TOTAL_COUNT) {
1902
- W_ERROR(WErrors.InvalidParam, `Discount total count ${recipient.length * discount.count} is exceed max ${MAX_DISCOUNT_TOTAL_COUNT}`);
1903
- }
1904
- if (discount.benchmark != null && !isValidU64(discount.benchmark)) {
1905
- W_ERROR(WErrors.InvalidParam, `Discount benchmark ${discount.benchmark} is not valid`);
1906
- }
1907
- const start = discount.time_ms_start ?? Date.now();
1908
- if (discount.time_ms_end < start) {
1909
- W_ERROR(WErrors.InvalidParam, `Discount time_ms_end ${discount.time_ms_end} is not valid`);
1910
- }
1911
- if (discount.discount_value != null &&
1912
- !isValidU64(discount.discount_value)) {
1913
- W_ERROR(WErrors.InvalidParam, `Discount discount_value ${discount.discount_value} is not valid`);
1914
- }
1915
- validObjects([service, permission, passport, ...recipient]);
1916
- if (!IsValidArgType(service_type)) {
1917
- W_ERROR(WErrors.InvalidParam, `Discount service type ${service_type} is not valid`);
1918
- }
1919
- if (passport) {
1920
- tx.moveCall({
1921
- target: serviceFn("discount_with_passport"),
1922
- arguments: [
1923
- toTxObject(tx, service),
1924
- toTxObject(tx, permission),
1925
- toTxObject(tx, passport),
1926
- tx.pure.string(discount.name),
1927
- tx.pure.u8(discount.discount_type),
1928
- tx.pure.u64(discount.discount_value),
1929
- tx.pure.option("u64", discount.benchmark ?? null),
1930
- tx.pure.bool(discount.transferable),
1931
- tx.pure.option("u64", discount.time_ms_start ?? null),
1932
- tx.pure.u64(discount.time_ms_end),
1933
- tx.pure.u16(discount.count),
1934
- tx.pure.vector("address", recipient),
1935
- tx.object.clock(),
1936
- ],
1937
- typeArguments: [service_type],
1938
- });
1939
- }
1940
- else {
1941
- tx.moveCall({
1942
- target: serviceFn("discount"),
1943
- arguments: [
1944
- toTxObject(tx, service),
1945
- toTxObject(tx, permission),
1946
- tx.pure.string(discount.name),
1947
- tx.pure.u8(discount.discount_type),
1948
- tx.pure.u64(discount.discount_value),
1949
- tx.pure.option("u64", discount.benchmark ?? null),
1950
- tx.pure.bool(discount.transferable),
1951
- tx.pure.option("u64", discount.time_ms_start ?? null),
1952
- tx.pure.u64(discount.time_ms_end),
1953
- tx.pure.u16(discount.count),
1954
- tx.pure.vector("address", recipient),
1955
- tx.object.clock(),
1956
- ],
1957
- typeArguments: [service_type],
1958
- });
1959
- }
1960
- }
1
+ import{toTxObject,toTxString,isValidDescription,MAX_DESCRIPTION_LENGTH,isValidName,isValidLongName,isValidU16,isValidU64,PackageAddress,MAX_LONG_NAME_LENGTH,isValidArray,IsValidArgType,GetObjectExisted,GetObject,GetObjectDescription,serviceFn,MAX_NAME_LENGTH,isValidHttpUrl}from'../common.js';import{W_ERROR,WErrors}from'../exception.js';import{ObjectType}from'../query/object.js';import{owner_receive,parseObjectType,validObjects}from'../util.js';import{allocators}from'./allocation.js';import{CallBase,getCoinParam}from'./base.js';import{BuiltinPermissionIndex,newPermission}from'./permission.js';import{GetManyAccountOrMark_Address,verify_wip}from'../local/index.js';import{WIP}from'../local/wip.js';import{LocalMark}from'../local/local.js';import{agent_set,order_required_info_update,owner_change}from'./order.js';import{create as a164a}from'./progress.js';import{create as a164b}from'./order.js';import{create as a164c}from'./permission.js';import{queryObjectsWithType}from'../query/util.js';import{query_received}from'../query/received.js';export const NAMED_OPERATOR_ORDER_PAYER='';export class CallService extends CallBase{['data'];['object_address']=undefined;['permission_address']=undefined;['new_permission_description']=undefined;['parameter_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['Service'],this['object_address']);if(!this['content'])W_ERROR(WErrors['InvalidParam'],'CallService_Data.data.object:'+this['object_address']);this['permission_address']=this['content']['permission'],this['parameter_type']=parseObjectType(this['content']['type_raw'],'service::Service'),!this['permission_address']&&W_ERROR(WErrors['InvalidParam'],'CallService_Data.data.object.permission\x20is\x20empty'),!IsValidArgType(this['parameter_type'])&&W_ERROR(WErrors['IsValidArgType'],'CallService_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['parameter_type']=b?.['type_parameter'],!IsValidArgType(this['parameter_type'])&&W_ERROR(WErrors['IsValidArgType'],'CallService_Data.data.object.type_parameter\x20invalid');}}async['call'](a){await this['prepare'](a);const b=[],c=[],d=f=>{!b['includes'](f)&&b['push'](f);},e=f=>{this['permission_address']&&!c['includes'](f)&&c['push'](f);};this['permission_address']&&!this['object_address']&&e(BuiltinPermissionIndex['SERVICE_NEW']);this['data']?.['order_new']&&(!this['content']&&W_ERROR(WErrors['InvalidParam'],'CallService_Data.data.order_new\x20fail\x20because\x20the\x20Service\x20'+JSON['stringify'](this['data']['object'])+'\x20content\x20not\x20ready'),this['order_allowed'](),this['content']['buy_guard']!=null&&d(this['content']['buy_guard']));this['permission_address']&&this['data']?.['description']!=null&&this['object_address']&&e(BuiltinPermissionIndex['SERVICE_DESCRIPTION']);this['permission_address']&&this['data']?.['location']!=null&&e(BuiltinPermissionIndex['SERVICE_LOCATION']);this['permission_address']&&this['data']?.['repositories']!=null&&e(BuiltinPermissionIndex['SERVICE_REPOSITORY']);this['permission_address']&&this['data']?.['sales']!=null&&e(BuiltinPermissionIndex['SERVICE_SALES']);this['permission_address']&&this['data']?.['machine']!==undefined&&(this['checkNotPublished']('machine'),e(BuiltinPermissionIndex['SERVICE_MACHINE']));this['permission_address']&&this['data']?.['discount']!=null&&e(BuiltinPermissionIndex['SERVICE_DISCOUNT']);this['permission_address']&&this['data']?.['arbitrations']!=null&&(this['checkNotPublished']('arbitrations'),e(BuiltinPermissionIndex['SERVICE_ARBITRATION']));this['permission_address']&&this['data']?.['customer_required']!=null&&e(BuiltinPermissionIndex['SERVICE_CUSTOMER_INFO_REQUIRED']);this['permission_address']&&this['data']?.['pause']!==undefined&&e(BuiltinPermissionIndex['SERVICE_PAUSE']);this['permission_address']&&this['data']?.['publish']&&e(BuiltinPermissionIndex['SERVICE_PUBLISH']);this['permission_address']&&this['data']?.['order_allocators']!==undefined&&(this['checkNotPublished']('order_allocators'),e(BuiltinPermissionIndex['SERVICE_ORDER_ALLOCATOR']));if(this['permission_address']&&this['data']?.['buy_guard']!=null){const f=await LocalMark['Instance']()['get_address'](this['data']?.['buy_guard']);!f&&W_ERROR(WErrors['InvalidParam'],'CallService_Data.data.buy_guard:'+this['data']?.['buy_guard']),this['data']['buy_guard']=f,e(BuiltinPermissionIndex['SERVICE_BUY_GUARD']);}this['permission_address']&&this['data']?.['compensation_fund_add']!=null&&e(BuiltinPermissionIndex['SERVICE_COMPENSATION_FUND_DEPOSIT']);this['permission_address']&&this['data']?.['compensation_locked_time_add']!==undefined&&e(BuiltinPermissionIndex['SERVICE_COMPENSATION_LOCKED_TIME_ADD']);this['permission_address']&&this['data']?.['rewards']!=null&&e(BuiltinPermissionIndex['SERVICE_REWARD']);this['permission_address']&&this['data']?.['compensation_fund_receive']!=null&&e(BuiltinPermissionIndex['SERVICE_COMPENSATION_FUND_RECEIVE']);this['permission_address']&&this['data']?.['owner_receive']!=null&&e(BuiltinPermissionIndex['SERVICE_OWNER_RECEIVE']);this['permission_address']&&this['data']?.['um']!==undefined&&e(BuiltinPermissionIndex['SERVICE_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'];!this['object_address']&&(!e&&(e=newPermission(b,this['new_permission_description']??'')),e&&this['parameter_type']&&(f=newService(b,this['parameter_type'],e,this['data']?.['description']??'',c)));(!f||!e)&&W_ERROR(WErrors['InvalidParam'],'CallService_Data.data.object:'+this['object_address']);let g;if(this['data']?.['order_new']!=null&&this['content']){this['order_allowed']();const h=this['data']?.['order_new'],i=this['content']['sales'],j=new Set();for(const k of h['buy']['items']){const l=i['find'](q=>q['name']===k['name']);!l&&W_ERROR(WErrors['InvalidParam'],'Product\x20\x22'+k['name']+'\x22\x20not\x20found\x20in\x20Service\x20sales');if(j['has'](l['wip']))continue;if(l['wip']==='')continue;const o=await verify_wip(l['wip'],k['wip_hash']);!o['valid']&&W_ERROR(WErrors['InvalidParam'],'WIP\x20file\x20verification\x20failed\x20for\x20product\x20\x22'+k['name']+'\x22\x20at\x20'+l['wip']+':\x20'+o['error']),j['add'](l['wip']);}h['buy']['discount']=await LocalMark['Instance']()['get_address'](this['data']['order_new']['buy']['discount']),g=await buy(a,b,f,this['parameter_type'],this['content']['machine'],h['buy'],c);!g&&W_ERROR(WErrors['Fail'],'Buy\x20failed,\x20no\x20order\x20created');h?.['agents']!=null&&agent_set(b,{'order':g['order'],'agents':await GetManyAccountOrMark_Address(h['agents'])});h?.['order_required_info']!==undefined&&h['order_required_info']['length']>0x0&&await order_required_info_update(b,g['order'],h['order_required_info']);h?.['transfer']!=null&&await owner_change(b,{'order':g['order'],'new_owner':h['transfer']});h?.['namedNewAllocation']!=null&&g?.['allocation']&&await this['new_with_mark'](a,b,ObjectType['Allocation'],g?.['allocation'],GetObject(h['namedNewAllocation']));g?.['progress']&&(h?.['namedNewProgress']!=null?await this['new_with_mark'](a,b,ObjectType['Progress'],a164a(b,g?.['progress']),GetObject(h['namedNewProgress'])):a164a(b,g?.['progress']));if(g?.['order']){const q=a164b(b,g?.['order']);h?.['namedNewOrder']!=null&&await this['new_with_mark'](a,b,ObjectType['Order'],q,GetObject(h['namedNewOrder']));}}this['data']['description']!=null&&!this['object_address']&&description_set(b,f,this['parameter_type'],e,this['data']['description'],c);this['data']['location']!=null&&location_set(b,f,this['parameter_type'],e,this['data']['location'],c);if(this['data']['sales']!=null)switch(this['data']['sales']['op']){case'add':case'set':{for(const s of this['data']['sales']['sales']){if(s['wip']!==''){const t=await verify_wip(s['wip'],s['wip_hash']!==''?s['wip_hash']:undefined);!t['valid']&&W_ERROR(WErrors['InvalidParam'],'WIP\x20file\x20verification\x20failed\x20for\x20product\x20\x22'+s['name']+'\x22\x20at\x20'+s['wip']+':\x20'+t['error']);const u=new WIP(),v=await u['load'](s['wip']);s['wip_hash']=u['getHash'](v);}}this['data']['sales']['op']==='add'?sales_add(b,f,this['parameter_type'],e,this['data']['sales']['sales'],c):sales_set(b,f,this['parameter_type'],e,this['data']['sales']['sales'],c);break;}case'remove':{sales_remove(b,f,this['parameter_type'],e,this['data']['sales']['sales_name'],c);break;}case'clear':{sales_clear(b,f,this['parameter_type'],e,c);break;}}if(this['data']['repositories']!=null)switch(this['data']['repositories']['op']){case'add':case'set':{this['data']['repositories']['objects']['length']>MAX_REPOSITORY_COUNT&&W_ERROR(WErrors['InvalidParam'],'CallService_Data.data.repositories.objects:'+this['data']['repositories']['objects']);this['data']['repositories']['op']==='set'&&repository_clear(b,f,this['parameter_type'],e,c);const w=await LocalMark['Instance']()['get_many_address_availables'](this['data']['repositories']['objects']);w['forEach'](x=>{repository_add(b,f,this['parameter_type'],e,x,c);});break;}case'remove':{this['data']['repositories']['objects']['length']>MAX_REPOSITORY_COUNT&&W_ERROR(WErrors['InvalidParam'],'CallService_Data.data.repositories.objects:'+this['data']['repositories']['objects']);const x=await LocalMark['Instance']()['get_many_address_availables'](this['data']['repositories']['objects']);repository_remove(b,f,this['parameter_type'],e,x,c);break;}case'clear':{repository_clear(b,f,this['parameter_type'],e,c);break;}}if(this['data']['rewards']!=null)switch(this['data']['rewards']['op']){case'add':case'set':{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,this['parameter_type'],e,c);const y=await queryObjectsWithType(a,this['data']['rewards']['objects'],ObjectType['Reward'],'reward::Reward',!![]);y['forEach'](z=>{reward_add(b,f,this['parameter_type'],e,z['object'],z['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 z=await LocalMark['Instance']()['get_many_address_availables'](this['data']['rewards']['objects']);reward_remove(b,f,this['parameter_type'],e,z,c);break;}case'clear':{reward_clear(b,f,this['parameter_type'],e,c);break;}}if(this['data']['arbitrations']!=null)switch(this['data']['arbitrations']['op']){case'add':case'set':{this['data']['arbitrations']['objects']['length']>MAX_ARBITRATION_COUNT&&W_ERROR(WErrors['InvalidParam'],'arbitrations\x20count\x20exceeds\x20maximum\x20limit\x20'+MAX_ARBITRATION_COUNT);this['data']['arbitrations']['op']==='set'&&arbitration_clear(b,f,this['parameter_type'],e,c);const A=await queryObjectsWithType(a,this['data']['arbitrations']['objects'],ObjectType['Arbitration'],'arbitration::Arbitration',!![]);A['forEach'](B=>{arbitrations_add(b,f,this['parameter_type'],e,B['object'],B['type'],c);});break;}case'remove':{this['data']['arbitrations']['objects']['length']>MAX_ARBITRATION_COUNT&&W_ERROR(WErrors['InvalidParam'],'arbitrations\x20count\x20exceeds\x20maximum\x20limit\x20'+MAX_ARBITRATION_COUNT);const B=await LocalMark['Instance']()['get_many_address_availables'](this['data']['arbitrations']['objects']);arbitrations_remove(b,f,this['parameter_type'],e,B,c);break;}case'clear':{arbitration_clear(b,f,this['parameter_type'],e,c);break;}}this['data']['discount']!=null&&await discount(b,f,this['parameter_type'],e,this['data']['discount'],c);if(this['data']['discount_destroy']!=null){const C=await LocalMark['Instance']()['get_many_address_availables'](this['data']['discount_destroy']);discount_destroy(b,C);}if(this['data']['machine']!==undefined){if(this['data']['machine']){const D=await LocalMark['Instance']()['get_address'](this['data']['machine']);D?this['data']['machine']=D:W_ERROR(WErrors['IsValidArgType'],'Machine\x20not\x20found\x20'+this['data']['machine']);}machine_set(b,f,this['parameter_type'],e,this['data']['machine'],c);}this['data']['customer_required']!=null&&customer_required_set(b,f,this['parameter_type'],e,this['data']['customer_required'],c);this['data']['order_allocators']!==undefined&&order_allocators_set(b,f,this['parameter_type'],e,this['data']['order_allocators']?await allocators(b,this['data']['order_allocators']):null,c);this['data']['buy_guard']!==undefined&&buy_guard_set(b,f,this['parameter_type'],e,this['data']['buy_guard'],c);this['data']['compensation_fund_add']!=null&&await compensation_fund_add(a,b,f,this['parameter_type'],e,this['data']['compensation_fund_add'],c);this['data']['compensation_locked_time_add']!==undefined&&compensation_lock_duration_set(b,f,this['parameter_type'],e,this['data']['compensation_locked_time_add'],c);if(this['data']['compensation_fund_receive']!=null&&this['object_address']){if(this['data']['compensation_fund_receive']==='recently'){const E=await query_received({'object':this['object_address'],'network':a['network'],'no_cache':a['no_cache']});Array['isArray'](E)?W_ERROR(WErrors['InvalidParam'],'CallAllocation_Data.data.received_coins:\x20received\x20is\x20ReceivedNormal[]'):this['data']['compensation_fund_receive']=E;}if(typeof this['data']['compensation_fund_receive']==='object'&&'received'in this['data']['compensation_fund_receive']&&this['data']['compensation_fund_receive']['received']?.['length']>0x0){this['data']['compensation_fund_receive']['token_type']!==this['parameter_type']&&W_ERROR(WErrors['InvalidParam'],'token_type\x20'+this['data']['compensation_fund_receive']['token_type']+'\x20is\x20not\x20equal\x20to\x20parameter_type\x20'+this['parameter_type']);for(const F of this['data']['compensation_fund_receive']['received']){const [G,H]=await Promise['all']([LocalMark['Instance']()['get_address'](F['id']),LocalMark['Instance']()['get_address'](F['payment'])]);(!G||!H)&&W_ERROR(WErrors['IsValidArgType'],'Compensation\x20fund\x20receive\x20object\x20'+F['id']+'\x20or\x20payment\x20object\x20'+F['payment']+'\x20not\x20found'),compensation_fund_receive(b,f,this['parameter_type'],e,F['id'],F['payment'],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['parameter_type'],I=>PackageAddress+'::service::'+I,c));if(this['data']['um']!==undefined){let I=null;this['data']['um']&&(I=await LocalMark['Instance']()['get_address'](this['data']['um'])||null,!I&&W_ERROR(WErrors['InvalidParam'],'CallService_Data.data.um:'+this['data']['um'])),um_set(b,f,this['parameter_type'],e,I,c);}this['data']['pause']!=null&&pause(b,f,this['parameter_type'],e,this['data']['pause'],c);this['data']['publish']&&publish(b,f,this['parameter_type'],e,c);if(!this['permission_address']){const J=GetObject(this['data']?.['object']);await this['new_with_mark'](a,b,ObjectType['Permission'],a164c(b,e),GetObject(J['permission']));}!this['object_address']&&await this['new_with_mark'](a,b,ObjectType['Service'],create(b,f,this['parameter_type']),GetObject(this['data']?.['object']));}['checkPublished']=a=>{this['content']&&!this['content']['bPublished']&&W_ERROR(WErrors['Fail'],'Service\x20object\x20has\x20not\x20been\x20published\x20yet,\x20so\x20the\x20operation\x20('+a+')\x20cannot\x20proceed.');};['checkNotPublished']=a=>{this['content']&&this['content']['bPublished']&&W_ERROR(WErrors['Fail'],'Service\x20object\x20has\x20been\x20published\x20and\x20operation\x20('+a+')\x20cannot\x20proceed.\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20further\x20modifications\x20are\x20needed,\x20you\x20can\x20\x27clone\x27\x20a\x20new\x20Service\x20and\x20then\x20proceed\x20with\x20the\x20operation.');};['checkNotPaused']=a=>{this['content']&&this['content']['bPaused']&&W_ERROR(WErrors['Fail'],'Service\x20object\x20has\x20been\x20paused\x20and\x20operation\x20('+a+')\x20cannot\x20proceed.');};['order_allowed'](){if(this['content']?.['bPaused'])return W_ERROR(WErrors['InvalidParam'],'Service\x20is\x20paused'),![];if(this['content']?.['bPublished']!==!![])return W_ERROR(WErrors['InvalidParam'],'Service\x20is\x20not\x20published'),![];return!![];}}export const MAX_SALE_COUNT=0x32;export const MAX_REPOSITORY_COUNT=0x64;export const MAX_ARBITRATION_COUNT=0x14;export const MAX_REWARD_COUNT=0x14;export const MAX_CUSTOMER_REQUIRED_INFO_COUNT=0xa;export const MAX_PUBKEY_LENGTH=0x400;export const MAX_DISCOUNT_COUNT_ONCE=0x3e8;export const MAX_DISCOUNT_RECEIVER_ONCE=0x3e8;export const MAX_DISCOUNT_TOTAL_COUNT=0x4e20;export const MAX_REQUIRED_INFO_SIZE=0x14;export const DEFAULT_COMPENSATION_LOCK_DURATION=0x9a7ec800;export const DISCOUNT_TYPE_RATES=0x0;export const DISCOUNT_TYPE_MINUS=0x1;const MAX_WIP_LENGTH=0x400,MAX_WIP_HASH_LENGTH=0x40;function sale(a,b){typeof b['name']==='string'&&!isValidLongName(b['name'])&&W_ERROR(WErrors['InvalidParam'],'Name\x20'+b['name']+'\x20exceeds\x20maximum\x20length\x20'+MAX_LONG_NAME_LENGTH);b['wip']['length']>MAX_WIP_LENGTH&&W_ERROR(WErrors['InvalidParam'],'WIP\x20'+b['wip']+'\x20exceeds\x20maximum\x20length\x20'+MAX_WIP_LENGTH);const c=b['wip'];b['wip']['length']>0x0&&!isValidHttpUrl(b['wip'])&&W_ERROR(WErrors['IsValidHttpUrl'],'WIP\x20'+b['wip']+'\x20is\x20not\x20a\x20valid\x20HTTP/HTTPS\x20URL');const d=b['wip_hash']['includes'](':')?b['wip_hash']['split'](':')[0x1]:b['wip_hash'];return d['length']>MAX_WIP_HASH_LENGTH&&W_ERROR(WErrors['InvalidParam'],'WIP\x20hash\x20'+d+'\x20exceeds\x20maximum\x20length\x20'+MAX_WIP_HASH_LENGTH),a['moveCall']({'target':serviceFn('sale'),'arguments':[toTxString(a,b['name']),a['pure']['u64'](b['price']),a['pure']['u64'](b['stock']),a['pure']['bool'](b['suspension']),toTxString(a,c),toTxString(a,d)]});}function quote_item(a,b){!isValidLongName(b['name'])&&W_ERROR(WErrors['InvalidParam'],'Quote\x20item\x20name\x20'+b['name']+'\x20is\x20not\x20valid');!isValidU64(b['stock'])&&W_ERROR(WErrors['IsValidU64'],'Quote\x20item\x20stock\x20'+b['stock']+'\x20is\x20not\x20valid');const c=b['wip_hash']['includes'](':')?b['wip_hash']['split'](':')[0x1]:b['wip_hash'];return c['length']>MAX_WIP_HASH_LENGTH&&W_ERROR(WErrors['InvalidParam'],'Quote\x20item\x20wip_hash\x20'+c+'\x20exceeds\x20maximum\x20length\x20'+MAX_WIP_HASH_LENGTH),a['moveCall']({'target':serviceFn('quote_item'),'arguments':[toTxString(a,b['name']),a['pure']['u64'](b['stock']),toTxString(a,c)]});}export function discount_send(a,b,c){if(b['length']===0x0)return;validObjects([...b,c]);b['length']>MAX_DISCOUNT_COUNT_ONCE&&W_ERROR(WErrors['InvalidParam'],'Discount\x20count\x20'+b['length']+'\x20exceeds\x20maximum\x20limit\x20'+MAX_DISCOUNT_COUNT_ONCE);if(b['length']===0x1){a['moveCall']({'target':serviceFn('discount_send_singleton'),'arguments':[toTxObject(a,b[0x0]),a['pure']['address'](c)]});return;}else a['moveCall']({'target':serviceFn('discount_send'),'arguments':[a['makeMoveVec']({'elements':b,'type':PackageAddress+'::service::Discount'}),a['pure']['address'](c)]});}export function discount_destroy(a,b){validObjects([...b]),b['forEach'](c=>{a['moveCall']({'target':serviceFn('discount_destroy'),'arguments':[toTxObject(a,c)]});});}export const buy=async(a,b,c,d,e,f,g)=>{if(f['items']['length']===0x0)return undefined;validObjects([c,f['discount'],e,g]);!IsValidArgType(d)&&W_ERROR(WErrors['InvalidParam'],'Buy\x20service\x20type\x20'+d+'\x20is\x20not\x20valid');!isValidArray(f['items'],l=>{return!isValidLongName(l['name'])&&W_ERROR(WErrors['InvalidParam'],'Buy\x20item\x20name\x20'+l['name']+'\x20is\x20not\x20valid'),!isValidU64(l['stock'])&&W_ERROR(WErrors['IsValidU64'],'Buy\x20item\x20stock\x20'+l['stock']+'\x20is\x20not\x20valid'),!![];})&&W_ERROR(WErrors['InvalidParam'],'Buy\x20items\x20is\x20not\x20valid');typeof f['payment_remark']==='string'&&!isValidName(f['payment_remark'])&&W_ERROR(WErrors['InvalidParam'],'Buy\x20payment\x20remark\x20'+f['payment_remark']+'\x20is\x20not\x20valid');f['payment_remark']=f['payment_remark']||'';f['payment_index']!=null&&!isValidU64(f['payment_index'])&&W_ERROR(WErrors['IsValidU64'],'Buy\x20payment\x20index\x20'+f['payment_index']+'\x20is\x20not\x20valid');const h=await getCoinParam(a,b,f['total_pay'],d);f['discount']=await LocalMark['Instance']()['get_address'](f['discount']);let i=undefined;f['discount']?i=b['moveCall']({'target':serviceFn('quote_with_discount'),'arguments':[toTxObject(b,c),b['makeMoveVec']({'elements':f['items']['map'](l=>quote_item(b,l)),'type':PackageAddress+'::service::QuoteItem'}),toTxObject(b,f['discount'])],'typeArguments':[d]}):i=b['moveCall']({'target':serviceFn('quote'),'arguments':[toTxObject(b,c),b['makeMoveVec']({'elements':f['items']['map'](l=>quote_item(b,l)),'type':PackageAddress+'::service::QuoteItem'})],'typeArguments':[d]});let j;g?j=b['moveCall']({'target':serviceFn('buy_with_passport'),'arguments':[toTxObject(b,c),toTxObject(b,g),i,b['object']['mutRegistrar'](),b['object']['clock']()],'typeArguments':[d]}):j=b['moveCall']({'target':serviceFn('buy'),'arguments':[toTxObject(b,c),i,b['object']['mutRegistrar'](),b['object']['clock']()],'typeArguments':[d]});const k={'order':j};return k['allocation']=b['moveCall']({'target':serviceFn('order_allocation'),'arguments':[toTxObject(b,c),toTxObject(b,j),h,b['pure']['string'](f['payment_remark']??''),b['pure']['u64'](f['payment_index']||0x0),b['object']['mutRegistrar'](),b['object']['clock']()],'typeArguments':[d]}),e&&(k['progress']=b['moveCall']({'target':serviceFn('order_progress'),'arguments':[toTxObject(b,c),toTxObject(b,j),toTxObject(b,e),b['object']['mutRegistrar'](),b['object']['clock']()],'typeArguments':[d]})),k;};export function newService(a,b,c,d,e){return validObjects([c,e]),typeof d==='string'&&!isValidDescription(d)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),!IsValidArgType(b)&&W_ERROR(WErrors['InvalidParam'],'New\x20service\x20type\x20'+b+'\x20is\x20not\x20valid'),e?a['moveCall']({'target':serviceFn('new_with_passport'),'arguments':[toTxObject(a,c),toTxObject(a,e),toTxString(a,d),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[b]}):a['moveCall']({'target':serviceFn('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]),typeof e==='string'&&!isValidDescription(e)&&W_ERROR(WErrors['IsValidDescription'],'Description\x20exceeds\x20maximum\x20length\x20'+MAX_DESCRIPTION_LENGTH),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Description\x20set\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('description_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),toTxString(a,e)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('description_set'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxString(a,e)],'typeArguments':[c]});}export function um_set(a,b,c,d,e,f){validObjects([b,d]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Service\x20type\x20'+c+'\x20is\x20not\x20valid'),e?f?a['moveCall']({'target':serviceFn('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':serviceFn('um_set'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):f?a['moveCall']({'target':serviceFn('um_none_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),f,a['object']['mutRegistrar']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('um_none'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['object']['mutRegistrar']()],'typeArguments':[c]});}export function location_set(a,b,c,d,e,f){validObjects([b,d,f]),typeof e==='string'&&!isValidLongName(e)&&W_ERROR(WErrors['InvalidParam'],'Location\x20'+e+'\x20exceeds\x20maximum\x20length\x20'+MAX_LONG_NAME_LENGTH),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Location\x20set\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('location_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),toTxString(a,e)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('location_set'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxString(a,e)],'typeArguments':[c]});}export function create(a,b,c){return validObjects([b]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Create\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),a['moveCall']({'target':serviceFn('create'),'arguments':[toTxObject(a,b)],'typeArguments':[c]});}export function sales_add(a,b,c,d,e,f){if(e['length']===0x0)return;validObjects([b,d,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Sales\x20add\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('sales_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['makeMoveVec']({'elements':e['map'](g=>sale(a,g)),'type':PackageAddress+'::service::Sale'})],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('sales_add'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['makeMoveVec']({'elements':e['map'](g=>sale(a,g)),'type':PackageAddress+'::service::Sale'})],'typeArguments':[c]});}export function sales_remove(a,b,c,d,e,f){if(e['length']===0x0)return;validObjects([b,d,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Sales\x20remove\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('sales_remove_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['pure']['vector']('string',e)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('sales_remove'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['pure']['vector']('string',e)],'typeArguments':[c]});}export function sales_clear(a,b,c,d,e){validObjects([b,d,e]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Sales\x20clear\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),e?a['moveCall']({'target':serviceFn('sales_clear_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('sales_clear'),'arguments':[toTxObject(a,b),toTxObject(a,d)],'typeArguments':[c]});}export function sales_set(a,b,c,d,e,f){if(e['length']===0x0)return;validObjects([b,d,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Sales\x20set\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('sales_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['makeMoveVec']({'elements':e['map'](g=>sale(a,g)),'type':PackageAddress+'::service::Sale'})],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('sales_set'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['makeMoveVec']({'elements':e['map'](g=>sale(a,g)),'type':PackageAddress+'::service::Sale'})],'typeArguments':[c]});}export function price_add(a,b,c,d,e,f,g){validObjects([b,d,g]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Price\x20add\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),typeof e==='string'&&!isValidLongName(e)&&W_ERROR(WErrors['InvalidParam'],'Sale\x20name\x20'+e+'\x20exceeds\x20maximum\x20length\x20'+MAX_LONG_NAME_LENGTH),!isValidU64(f)&&W_ERROR(WErrors['IsValidU64'],'Price\x20add\x20'+f+'\x20is\x20not\x20valid'),g?a['moveCall']({'target':serviceFn('price_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,g),toTxString(a,e),a['pure']['u64'](f)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('price_add'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxString(a,e),a['pure']['u64'](f)],'typeArguments':[c]});}export function price_reduce(a,b,c,d,e,f,g){validObjects([b,d,g]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Price\x20reduce\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),typeof e==='string'&&!isValidLongName(e)&&W_ERROR(WErrors['InvalidParam'],'Sale\x20name\x20'+e+'\x20exceeds\x20maximum\x20length\x20'+MAX_LONG_NAME_LENGTH),!isValidU64(f)&&W_ERROR(WErrors['IsValidU64'],'Price\x20reduce\x20'+f+'\x20is\x20not\x20valid'),g?a['moveCall']({'target':serviceFn('price_reduce_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,g),toTxString(a,e),a['pure']['u64'](f)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('price_reduce'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxString(a,e),a['pure']['u64'](f)],'typeArguments':[c]});}export function stock_add(a,b,c,d,e,f,g){validObjects([b,d,g]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Stock\x20add\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),typeof e==='string'&&!isValidLongName(e)&&W_ERROR(WErrors['InvalidParam'],'Sale\x20name\x20'+e+'\x20exceeds\x20maximum\x20length\x20'+MAX_LONG_NAME_LENGTH),!isValidU64(f)&&W_ERROR(WErrors['IsValidU64'],'Stock\x20add\x20'+f+'\x20is\x20not\x20valid'),g?a['moveCall']({'target':serviceFn('stock_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,g),toTxString(a,e),a['pure']['u64'](f)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('stock_add'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxString(a,e),a['pure']['u64'](f)],'typeArguments':[c]});}export function stock_reduce(a,b,c,d,e,f,g){validObjects([b,d,g]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Stock\x20reduce\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),typeof e==='string'&&!isValidLongName(e)&&W_ERROR(WErrors['InvalidParam'],'Sale\x20name\x20'+e+'\x20exceeds\x20maximum\x20length\x20'+MAX_LONG_NAME_LENGTH),!isValidU64(f)&&W_ERROR(WErrors['IsValidU64'],'Stock\x20reduce\x20'+f+'\x20is\x20not\x20valid'),g?a['moveCall']({'target':serviceFn('stock_reduce_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,g),toTxString(a,e),a['pure']['u64'](f)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('stock_reduce'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxString(a,e),a['pure']['u64'](f)],'typeArguments':[c]});}export function sale_suspension(a,b,c,d,e,f,g){validObjects([b,d,g]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Sale\x20suspension\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),typeof e==='string'&&!isValidLongName(e)&&W_ERROR(WErrors['InvalidParam'],'Sale\x20name\x20'+e+'\x20exceeds\x20maximum\x20length\x20'+MAX_LONG_NAME_LENGTH),g?a['moveCall']({'target':serviceFn('sale_suspension_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,g),toTxString(a,e),a['pure']['bool'](f)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('sale_suspension'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxString(a,e),a['pure']['bool'](f)],'typeArguments':[c]});}export function repository_add(a,b,c,d,e,f){validObjects([b,d,e,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Repository\x20add\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('repository_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('repository_add'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]});}export function repository_remove(a,b,c,d,e,f){if(e['length']===0x0)return;validObjects([b,d,f,...e]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Repository\x20remove\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('repository_remove_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['pure']['vector']('address',e),a['object']['mutRegistrar']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('repository_remove'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['pure']['vector']('address',e),a['object']['mutRegistrar']()],'typeArguments':[c]});}export function repository_clear(a,b,c,d,e){validObjects([b,d,e]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Repository\x20clear\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),e?a['moveCall']({'target':serviceFn('repository_clear_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('repository_clear'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['object']['mutRegistrar']()],'typeArguments':[c]});}export function buy_guard_set(a,b,c,d,e,f){validObjects([b,d,e,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Buy\x20guard\x20set\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?e?a['moveCall']({'target':serviceFn('buy_guard_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('buy_guard_none_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['object']['mutRegistrar']()],'typeArguments':[c]}):e?a['moveCall']({'target':serviceFn('buy_guard_set'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('buy_guard_none'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['object']['mutRegistrar']()],'typeArguments':[c]});}export function machine_set(a,b,c,d,e,f){validObjects([b,d,e,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Machine\x20set\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?e?a['moveCall']({'target':serviceFn('machine_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('machine_none_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['object']['mutRegistrar']()],'typeArguments':[c]}):e?a['moveCall']({'target':serviceFn('machine_set'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('machine_set_none'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['object']['mutRegistrar']()],'typeArguments':[c]});}export function publish(a,b,c,d,e){validObjects([b,d,e]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Publish\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),e?a['moveCall']({'target':serviceFn('publish_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('publish'),'arguments':[toTxObject(a,b),toTxObject(a,d)],'typeArguments':[c]});}export function pause(a,b,c,d,e,f){validObjects([b,d,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Pause\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('pause_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['pure']['bool'](e),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('pause'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['pure']['bool'](e),a['object']['clock']()],'typeArguments':[c]});}export function customer_required_set(a,b,c,d,e,f){e['length']>MAX_REQUIRED_INFO_SIZE&&W_ERROR(WErrors['InvalidParam'],'Customer\x20required\x20set\x20size\x20'+e['length']+'\x20is\x20exceed\x20maximum\x20size\x20'+MAX_REQUIRED_INFO_SIZE),validObjects([b,d,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Customer\x20required\x20set\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),e['forEach'](g=>{!isValidName(g)&&W_ERROR(WErrors['InvalidParam'],'Customer\x20required\x20info\x20'+g+'\x20is\x20exceed\x20maximum\x20length\x20'+MAX_NAME_LENGTH+'\x20or\x20start\x20with\x20\x220x\x22');}),f?a['moveCall']({'target':serviceFn('custom_required_info_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['pure']['vector']('string',e)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('custom_required_info_set'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['pure']['vector']('string',e)],'typeArguments':[c]});}export function arbitrations_add(a,b,c,d,e,f,g){validObjects([b,d,e,g]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Arbitrations\x20add\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),!IsValidArgType(f)&&W_ERROR(WErrors['InvalidParam'],'Arbitrations\x20add\x20arbitration\x20type\x20'+f+'\x20is\x20not\x20valid'),g?a['moveCall']({'target':serviceFn('arbitration_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,g),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('arbitration_add'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c,f]});}export function arbitrations_remove(a,b,c,d,e,f){if(e['length']===0x0)return;validObjects([b,d,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Arbitrations\x20remove\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('arbitration_remove_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['pure']['vector']('address',e),a['object']['mutRegistrar']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('arbitration_remove'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['pure']['vector']('address',e),a['object']['mutRegistrar']()],'typeArguments':[c]});}export function arbitration_clear(a,b,c,d,e){validObjects([b,d,e]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Arbitrations\x20clear\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),e?a['moveCall']({'target':serviceFn('arbitration_clear_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('arbitration_clear'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['object']['mutRegistrar']()],'typeArguments':[c]});}export async function compensation_fund_add(a,b,c,d,e,f,g){validObjects([c,e,g]);!IsValidArgType(d)&&W_ERROR(WErrors['InvalidParam'],'Compensation\x20fund\x20add\x20service\x20type\x20'+d+'\x20is\x20not\x20valid');const h=await getCoinParam(a,b,f,d);g?b['moveCall']({'target':serviceFn('compensation_fund_add_with_passport'),'arguments':[toTxObject(b,c),toTxObject(b,e),toTxObject(b,g),h],'typeArguments':[d]}):b['moveCall']({'target':serviceFn('compensation_fund_add'),'arguments':[toTxObject(b,c),toTxObject(b,e),h],'typeArguments':[d]});}export function compensation_lock_duration_set(a,b,c,d,e,f){if(!isValidU64(e)||e===0x0)return;validObjects([b,d,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Compensation\x20lock\x20duration\x20set\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('compensation_lock_duration_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['pure']['u64'](e)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('compensation_lock_duration_add'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['pure']['u64'](e)],'typeArguments':[c]});}export function order_allocators_set(a,b,c,d,e,f){validObjects([b,d,e,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Order\x20allocators\x20set\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('order_allocators_set_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['object']['option']({'type':PackageAddress+'::allocation::Allocators','value':e??null})],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('order_allocators_set'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['object']['option']({'type':PackageAddress+'::allocation::Allocators','value':e??null})],'typeArguments':[c]});}export function reward_add(a,b,c,d,e,f,g){validObjects([b,d,e,g]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Rewards\x20add\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),!IsValidArgType(f)&&W_ERROR(WErrors['InvalidParam'],'Rewards\x20add\x20reward\x20type\x20'+f+'\x20is\x20not\x20valid'),g?a['moveCall']({'target':serviceFn('reward_add_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,g),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c,f]}):a['moveCall']({'target':serviceFn('reward_add'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c,f]});}export function reward_remove(a,b,c,d,e,f){if(e['length']===0x0)return;validObjects([b,d,f]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Rewards\x20remove\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('reward_remove_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['pure']['vector']('address',e),a['object']['mutRegistrar']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('reward_remove'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['pure']['vector']('address',e),a['object']['mutRegistrar']()],'typeArguments':[c]});}export function reward_clear(a,b,c,d,e){validObjects([b,d,e]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Rewards\x20clear\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),e?a['moveCall']({'target':serviceFn('reward_clear_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),a['object']['mutRegistrar']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('reward_clear'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['object']['mutRegistrar']()],'typeArguments':[c]});}export function compensation_fund_receive(a,b,c,d,e,f,g){!f&&W_ERROR(WErrors['InvalidParam'],'Compensation\x20fund\x20receive\x20payment\x20is\x20required'),validObjects([b,d,e,f,g]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Compensation\x20fund\x20receive\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),g?a['moveCall']({'target':serviceFn('compensation_fund_receive_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,g),toTxObject(a,e),toTxObject(a,f)],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('compensation_fund_receive'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,e),toTxObject(a,f)],'typeArguments':[c]});}export function compensation_fund_withdraw(a,b,c,d,e,f,g){validObjects([b,f,e,d,g]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Compensation\x20fund\x20withdraw\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),g?a['moveCall']({'target':serviceFn('compensation_fund_withdraw_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,f),toTxObject(a,g),a['pure']['address'](e),toTxObject(a,d),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('compensation_fund_withdraw'),'arguments':[toTxObject(a,b),toTxObject(a,f),a['pure']['address'](e),toTxObject(a,d),a['object']['mutRegistrar'](),a['object']['clock']()],'typeArguments':[c]});}export async function discount(a,b,c,d,e,f){let g=[];Array['isArray'](e['recipient'])?g=e['recipient']:g=await GetManyAccountOrMark_Address(e['recipient']);if(g['length']===0x0||e['count']===0x0)return;g['length']>MAX_DISCOUNT_RECEIVER_ONCE&&W_ERROR(WErrors['InvalidParam'],'Discount\x20recipient\x20length\x20'+g['length']+'\x20is\x20exceed\x20max\x20'+MAX_DISCOUNT_RECEIVER_ONCE);!isValidName(e['name'])&&W_ERROR(WErrors['InvalidParam'],'Discount\x20name\x20'+e['name']+'\x20is\x20not\x20valid');(!isValidU16(e['count'])||e['count']>MAX_DISCOUNT_COUNT_ONCE)&&W_ERROR(WErrors['InvalidParam'],'Discount\x20count\x20'+e['count']+'\x20is\x20exceed\x20max\x20'+MAX_DISCOUNT_COUNT_ONCE);g['length']*e['count']>MAX_DISCOUNT_TOTAL_COUNT&&W_ERROR(WErrors['InvalidParam'],'Discount\x20total\x20count\x20'+g['length']*e['count']+'\x20is\x20exceed\x20max\x20'+MAX_DISCOUNT_TOTAL_COUNT);e['benchmark']!=null&&!isValidU64(e['benchmark'])&&W_ERROR(WErrors['InvalidParam'],'Discount\x20benchmark\x20'+e['benchmark']+'\x20is\x20not\x20valid');const h=e['time_ms_start']??Date['now']();e['time_ms_end']<h&&W_ERROR(WErrors['InvalidParam'],'Discount\x20time_ms_end\x20'+e['time_ms_end']+'\x20is\x20not\x20valid'),e['discount_value']!=null&&!isValidU64(e['discount_value'])&&W_ERROR(WErrors['InvalidParam'],'Discount\x20discount_value\x20'+e['discount_value']+'\x20is\x20not\x20valid'),validObjects([b,d,f,...g]),!IsValidArgType(c)&&W_ERROR(WErrors['InvalidParam'],'Discount\x20service\x20type\x20'+c+'\x20is\x20not\x20valid'),f?a['moveCall']({'target':serviceFn('discount_with_passport'),'arguments':[toTxObject(a,b),toTxObject(a,d),toTxObject(a,f),a['pure']['string'](e['name']),a['pure']['u8'](e['discount_type']),a['pure']['u64'](e['discount_value']),a['pure']['option']('u64',e['benchmark']??null),a['pure']['bool'](e['transferable']),a['pure']['option']('u64',e['time_ms_start']??null),a['pure']['u64'](e['time_ms_end']),a['pure']['u16'](e['count']),a['pure']['vector']('address',g),a['object']['clock']()],'typeArguments':[c]}):a['moveCall']({'target':serviceFn('discount'),'arguments':[toTxObject(a,b),toTxObject(a,d),a['pure']['string'](e['name']),a['pure']['u8'](e['discount_type']),a['pure']['u64'](e['discount_value']),a['pure']['option']('u64',e['benchmark']??null),a['pure']['bool'](e['transferable']),a['pure']['option']('u64',e['time_ms_start']??null),a['pure']['u64'](e['time_ms_end']),a['pure']['u16'](e['count']),a['pure']['vector']('address',g),a['object']['clock']()],'typeArguments':[c]});}