wowok 1.8.2 → 2.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (892) hide show
  1. package/README.md +4 -33
  2. package/dist/cjs/bcs/bcs.d.ts +1973 -0
  3. package/dist/cjs/bcs/bcs.js +327 -0
  4. package/dist/cjs/bcs/effects.d.ts +579 -0
  5. package/dist/cjs/bcs/effects.js +231 -0
  6. package/dist/cjs/bcs/index.d.ts +2589 -0
  7. package/dist/cjs/bcs/index.js +79 -0
  8. package/dist/cjs/bcs/pure.d.ts +22 -0
  9. package/dist/cjs/bcs/pure.js +62 -0
  10. package/dist/cjs/bcs/type-tag-serializer.d.ts +7 -0
  11. package/dist/cjs/bcs/type-tag-serializer.js +124 -0
  12. package/dist/cjs/bcs/types.d.ts +114 -0
  13. package/dist/cjs/bcs/types.js +26 -0
  14. package/dist/cjs/client/index.d.ts +5 -0
  15. package/dist/cjs/client/index.js +34 -0
  16. package/dist/cjs/client/network.d.ts +5 -0
  17. package/dist/cjs/client/network.js +43 -0
  18. package/dist/cjs/cryptography/index.d.ts +7 -0
  19. package/dist/cjs/cryptography/index.js +46 -0
  20. package/dist/cjs/cryptography/intent.d.ts +6 -0
  21. package/dist/cjs/cryptography/intent.js +34 -0
  22. package/dist/cjs/cryptography/keypair.d.ts +73 -0
  23. package/dist/cjs/cryptography/keypair.js +125 -0
  24. package/dist/cjs/cryptography/mnemonics.d.ts +27 -0
  25. package/dist/cjs/cryptography/mnemonics.js +50 -0
  26. package/dist/cjs/cryptography/publickey.d.ts +67 -0
  27. package/dist/cjs/cryptography/publickey.js +142 -0
  28. package/dist/cjs/cryptography/signature-scheme.d.ts +24 -0
  29. package/dist/cjs/cryptography/signature-scheme.js +47 -0
  30. package/dist/cjs/cryptography/signature.d.ts +62 -0
  31. package/dist/cjs/cryptography/signature.js +71 -0
  32. package/dist/cjs/experimental/cache.d.ts +12 -0
  33. package/dist/cjs/experimental/client.d.ts +12 -0
  34. package/dist/cjs/experimental/core.d.ts +33 -0
  35. package/dist/cjs/experimental/errors.d.ts +8 -0
  36. package/dist/cjs/experimental/index.d.ts +7 -0
  37. package/dist/cjs/experimental/persistent-storage.d.ts +134 -0
  38. package/dist/cjs/experimental/persistent-storage.test.d.ts +5 -0
  39. package/dist/cjs/experimental/transports/utils.d.ts +3 -0
  40. package/dist/cjs/experimental/types.d.ts +367 -0
  41. package/dist/cjs/faucet/faucet.d.ts +66 -0
  42. package/dist/cjs/faucet/faucet.js +138 -0
  43. package/dist/cjs/faucet/index.d.ts +1 -0
  44. package/dist/cjs/faucet/index.js +29 -0
  45. package/dist/cjs/graphql/client.js +98 -0
  46. package/dist/cjs/graphql/core.js +506 -0
  47. package/dist/cjs/graphql/generated/2024.1/tada-env.js +13141 -0
  48. package/dist/cjs/graphql/generated/2024.1/tsconfig.tada.js +11 -0
  49. package/dist/cjs/graphql/generated/2024.4/tada-env.js +13287 -0
  50. package/dist/cjs/graphql/generated/2024.4/tsconfig.tada.js +11 -0
  51. package/dist/cjs/graphql/generated/latest/tada-env.js +12925 -0
  52. package/dist/cjs/graphql/generated/latest/tsconfig.tada.js +11 -0
  53. package/dist/cjs/graphql/generated/queries.js +807 -0
  54. package/dist/cjs/graphql/index.js +25 -0
  55. package/dist/cjs/graphql/schemas/2024.1/index.js +28 -0
  56. package/dist/cjs/graphql/schemas/2024.4/index.js +28 -0
  57. package/dist/cjs/graphql/schemas/latest/index.js +28 -0
  58. package/dist/cjs/graphql/types.js +16 -0
  59. package/dist/cjs/grpc/client.d.ts +32 -0
  60. package/dist/cjs/grpc/client.js +64 -0
  61. package/dist/cjs/grpc/core.d.ts +28 -0
  62. package/dist/cjs/grpc/core.js +645 -0
  63. package/dist/cjs/grpc/index.d.ts +4 -0
  64. package/dist/cjs/grpc/index.js +26 -0
  65. package/dist/cjs/grpc/proto/google/protobuf/any.d.ts +173 -0
  66. package/dist/cjs/grpc/proto/google/protobuf/any.js +138 -0
  67. package/dist/cjs/grpc/proto/google/protobuf/duration.d.ts +104 -0
  68. package/dist/cjs/grpc/proto/google/protobuf/duration.js +94 -0
  69. package/dist/cjs/grpc/proto/google/protobuf/empty.d.ts +25 -0
  70. package/dist/cjs/grpc/proto/google/protobuf/empty.js +30 -0
  71. package/dist/cjs/grpc/proto/google/protobuf/field_mask.d.ts +231 -0
  72. package/dist/cjs/grpc/proto/google/protobuf/field_mask.js +77 -0
  73. package/dist/cjs/grpc/proto/google/protobuf/struct.d.ts +169 -0
  74. package/dist/cjs/grpc/proto/google/protobuf/struct.js +224 -0
  75. package/dist/cjs/grpc/proto/google/protobuf/timestamp.d.ts +145 -0
  76. package/dist/cjs/grpc/proto/google/protobuf/timestamp.js +134 -0
  77. package/dist/cjs/grpc/proto/google/rpc/error_details.d.ts +525 -0
  78. package/dist/cjs/grpc/proto/google/rpc/error_details.js +317 -0
  79. package/dist/cjs/grpc/proto/google/rpc/status.d.ts +46 -0
  80. package/dist/cjs/grpc/proto/google/rpc/status.js +52 -0
  81. package/dist/cjs/grpc/proto/sui/rpc/v2/argument.d.ts +66 -0
  82. package/dist/cjs/grpc/proto/sui/rpc/v2/argument.js +70 -0
  83. package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.d.ts +34 -0
  84. package/dist/cjs/grpc/proto/sui/rpc/v2/balance_change.js +52 -0
  85. package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.d.ts +30 -0
  86. package/dist/cjs/grpc/proto/sui/rpc/v2/bcs.js +45 -0
  87. package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.d.ts +68 -0
  88. package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint.js +77 -0
  89. package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.d.ts +74 -0
  90. package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_contents.js +84 -0
  91. package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.d.ts +195 -0
  92. package/dist/cjs/grpc/proto/sui/rpc/v2/checkpoint_summary.js +170 -0
  93. package/dist/cjs/grpc/proto/sui/rpc/v2/effects.d.ts +338 -0
  94. package/dist/cjs/grpc/proto/sui/rpc/v2/effects.js +300 -0
  95. package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.d.ts +62 -0
  96. package/dist/cjs/grpc/proto/sui/rpc/v2/epoch.js +87 -0
  97. package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.d.ts +17 -0
  98. package/dist/cjs/grpc/proto/sui/rpc/v2/error_reason.js +29 -0
  99. package/dist/cjs/grpc/proto/sui/rpc/v2/event.d.ts +88 -0
  100. package/dist/cjs/grpc/proto/sui/rpc/v2/event.js +86 -0
  101. package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.d.ts +80 -0
  102. package/dist/cjs/grpc/proto/sui/rpc/v2/executed_transaction.js +87 -0
  103. package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.d.ts +843 -0
  104. package/dist/cjs/grpc/proto/sui/rpc/v2/execution_status.js +519 -0
  105. package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.d.ts +41 -0
  106. package/dist/cjs/grpc/proto/sui/rpc/v2/gas_cost_summary.js +63 -0
  107. package/dist/cjs/grpc/proto/sui/rpc/v2/input.d.ts +98 -0
  108. package/dist/cjs/grpc/proto/sui/rpc/v2/input.js +85 -0
  109. package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.d.ts +70 -0
  110. package/dist/cjs/grpc/proto/sui/rpc/v2/jwk.js +81 -0
  111. package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.d.ts +95 -0
  112. package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.client.js +122 -0
  113. package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.d.ts +420 -0
  114. package/dist/cjs/grpc/proto/sui/rpc/v2/ledger_service.js +368 -0
  115. package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.d.ts +579 -0
  116. package/dist/cjs/grpc/proto/sui/rpc/v2/move_package.js +485 -0
  117. package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.d.ts +61 -0
  118. package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.client.js +81 -0
  119. package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.d.ts +229 -0
  120. package/dist/cjs/grpc/proto/sui/rpc/v2/move_package_service.js +241 -0
  121. package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.d.ts +41 -0
  122. package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.client.js +55 -0
  123. package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.d.ts +144 -0
  124. package/dist/cjs/grpc/proto/sui/rpc/v2/name_service.js +141 -0
  125. package/dist/cjs/grpc/proto/sui/rpc/v2/object.d.ts +127 -0
  126. package/dist/cjs/grpc/proto/sui/rpc/v2/object.js +114 -0
  127. package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.d.ts +34 -0
  128. package/dist/cjs/grpc/proto/sui/rpc/v2/object_reference.js +53 -0
  129. package/dist/cjs/grpc/proto/sui/rpc/v2/owner.d.ts +61 -0
  130. package/dist/cjs/grpc/proto/sui/rpc/v2/owner.js +63 -0
  131. package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.d.ts +30 -0
  132. package/dist/cjs/grpc/proto/sui/rpc/v2/protocol_config.js +61 -0
  133. package/dist/cjs/grpc/proto/sui/rpc/v2/signature.d.ts +630 -0
  134. package/dist/cjs/grpc/proto/sui/rpc/v2/signature.js +541 -0
  135. package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.d.ts +40 -0
  136. package/dist/cjs/grpc/proto/sui/rpc/v2/signature_scheme.js +33 -0
  137. package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.ts +35 -0
  138. package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +50 -0
  139. package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.d.ts +79 -0
  140. package/dist/cjs/grpc/proto/sui/rpc/v2/signature_verification_service.js +90 -0
  141. package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.d.ts +71 -0
  142. package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.client.js +88 -0
  143. package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.d.ts +690 -0
  144. package/dist/cjs/grpc/proto/sui/rpc/v2/state_service.js +546 -0
  145. package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts +55 -0
  146. package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.client.js +54 -0
  147. package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.d.ts +57 -0
  148. package/dist/cjs/grpc/proto/sui/rpc/v2/subscription_service.js +65 -0
  149. package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.d.ts +684 -0
  150. package/dist/cjs/grpc/proto/sui/rpc/v2/system_state.js +740 -0
  151. package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.d.ts +1321 -0
  152. package/dist/cjs/grpc/proto/sui/rpc/v2/transaction.js +1005 -0
  153. package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.ts +41 -0
  154. package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +49 -0
  155. package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.d.ts +184 -0
  156. package/dist/cjs/grpc/proto/sui/rpc/v2/transaction_execution_service.js +177 -0
  157. package/dist/cjs/index.d.ts +25 -0
  158. package/dist/cjs/index.js +93 -0
  159. package/dist/cjs/jsonRpc/client.d.ts +261 -0
  160. package/dist/cjs/jsonRpc/client.js +747 -0
  161. package/dist/cjs/jsonRpc/core.d.ts +87 -0
  162. package/dist/cjs/jsonRpc/core.js +638 -0
  163. package/dist/cjs/jsonRpc/errors.d.ts +12 -0
  164. package/dist/cjs/jsonRpc/errors.js +65 -0
  165. package/dist/cjs/jsonRpc/http-transport.d.ts +42 -0
  166. package/dist/cjs/jsonRpc/http-transport.js +121 -0
  167. package/dist/cjs/jsonRpc/index.d.ts +4 -0
  168. package/dist/cjs/jsonRpc/index.js +31 -0
  169. package/dist/cjs/jsonRpc/json-rpc-resolver.d.ts +4 -0
  170. package/dist/cjs/jsonRpc/json-rpc-resolver.js +321 -0
  171. package/dist/cjs/jsonRpc/rpc-websocket-client.d.ts +43 -0
  172. package/dist/cjs/jsonRpc/rpc-websocket-client.js +220 -0
  173. package/dist/cjs/jsonRpc/types/chain.d.ts +99 -0
  174. package/dist/cjs/jsonRpc/types/chain.js +16 -0
  175. package/dist/cjs/jsonRpc/types/changes.d.ts +19 -0
  176. package/dist/cjs/jsonRpc/types/changes.js +16 -0
  177. package/dist/cjs/jsonRpc/types/coins.d.ts +6 -0
  178. package/dist/cjs/jsonRpc/types/coins.js +16 -0
  179. package/dist/cjs/jsonRpc/types/common.d.ts +2 -0
  180. package/dist/cjs/jsonRpc/types/common.js +16 -0
  181. package/dist/cjs/jsonRpc/types/generated.d.ts +1492 -0
  182. package/dist/cjs/jsonRpc/types/generated.js +16 -0
  183. package/dist/cjs/jsonRpc/types/index.d.ts +6 -0
  184. package/dist/cjs/jsonRpc/types/index.js +16 -0
  185. package/dist/cjs/jsonRpc/types/params.d.ts +656 -0
  186. package/dist/cjs/jsonRpc/types/params.js +16 -0
  187. package/dist/cjs/keypairs/ed25519/ed25519-hd-key.d.ts +8 -0
  188. package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +82 -0
  189. package/dist/cjs/keypairs/ed25519/index.d.ts +2 -0
  190. package/dist/cjs/keypairs/ed25519/index.js +27 -0
  191. package/dist/cjs/keypairs/ed25519/keypair.d.ts +74 -0
  192. package/dist/cjs/keypairs/ed25519/keypair.js +169 -0
  193. package/dist/cjs/keypairs/ed25519/publickey.d.ts +30 -0
  194. package/dist/cjs/keypairs/ed25519/publickey.js +90 -0
  195. package/dist/cjs/keypairs/index.d.ts +4 -0
  196. package/dist/cjs/keypairs/index.js +21 -0
  197. package/dist/cjs/keypairs/passkey/index.d.ts +3 -0
  198. package/dist/cjs/keypairs/passkey/index.js +28 -0
  199. package/dist/cjs/keypairs/passkey/keypair.d.ts +113 -0
  200. package/dist/cjs/keypairs/passkey/keypair.js +268 -0
  201. package/dist/cjs/keypairs/passkey/publickey.d.ts +72 -0
  202. package/dist/cjs/keypairs/passkey/publickey.js +175 -0
  203. package/dist/cjs/keypairs/passkey/types.d.ts +12 -0
  204. package/dist/cjs/keypairs/passkey/types.js +16 -0
  205. package/dist/cjs/keypairs/secp256k1/index.d.ts +2 -0
  206. package/dist/cjs/keypairs/secp256k1/index.js +27 -0
  207. package/dist/cjs/keypairs/secp256k1/keypair.d.ts +73 -0
  208. package/dist/cjs/keypairs/secp256k1/keypair.js +159 -0
  209. package/dist/cjs/keypairs/secp256k1/publickey.d.ts +30 -0
  210. package/dist/cjs/keypairs/secp256k1/publickey.js +95 -0
  211. package/dist/cjs/keypairs/secp256r1/index.d.ts +2 -0
  212. package/dist/cjs/keypairs/secp256r1/index.js +27 -0
  213. package/dist/cjs/keypairs/secp256r1/keypair.d.ts +73 -0
  214. package/dist/cjs/keypairs/secp256r1/keypair.js +155 -0
  215. package/dist/cjs/keypairs/secp256r1/publickey.d.ts +30 -0
  216. package/dist/cjs/keypairs/secp256r1/publickey.js +96 -0
  217. package/dist/cjs/multisig/index.d.ts +2 -0
  218. package/dist/cjs/multisig/index.js +27 -0
  219. package/dist/cjs/multisig/publickey.d.ts +79 -0
  220. package/dist/cjs/multisig/publickey.js +296 -0
  221. package/dist/cjs/multisig/signer.d.ts +20 -0
  222. package/dist/cjs/multisig/signer.js +114 -0
  223. package/dist/cjs/package.json +5 -0
  224. package/dist/cjs/transactions/Arguments.d.ts +57 -0
  225. package/dist/cjs/transactions/Arguments.js +36 -0
  226. package/dist/cjs/transactions/Commands.d.ts +57 -0
  227. package/dist/cjs/transactions/Commands.js +143 -0
  228. package/dist/cjs/transactions/Inputs.d.ts +22 -0
  229. package/dist/cjs/transactions/Inputs.js +87 -0
  230. package/dist/cjs/transactions/ObjectCache.d.ts +83 -0
  231. package/dist/cjs/transactions/ObjectCache.js +251 -0
  232. package/dist/cjs/transactions/Transaction.d.ts +710 -0
  233. package/dist/cjs/transactions/Transaction.js +742 -0
  234. package/dist/cjs/transactions/TransactionData.d.ts +73 -0
  235. package/dist/cjs/transactions/TransactionData.js +472 -0
  236. package/dist/cjs/transactions/__tests__/Transaction.test.d.ts +1 -0
  237. package/dist/cjs/transactions/__tests__/bcs.test.d.ts +1 -0
  238. package/dist/cjs/transactions/data/internal.d.ts +1010 -0
  239. package/dist/cjs/transactions/data/internal.js +230 -0
  240. package/dist/cjs/transactions/data/v1.d.ts +312 -0
  241. package/dist/cjs/transactions/data/v1.js +538 -0
  242. package/dist/cjs/transactions/data/v2.d.ts +153 -0
  243. package/dist/cjs/transactions/data/v2.js +124 -0
  244. package/dist/cjs/transactions/executor/caching.d.ts +31 -0
  245. package/dist/cjs/transactions/executor/caching.js +118 -0
  246. package/dist/cjs/transactions/executor/parallel.d.ts +37 -0
  247. package/dist/cjs/transactions/executor/parallel.js +395 -0
  248. package/dist/cjs/transactions/executor/queue.d.ts +11 -0
  249. package/dist/cjs/transactions/executor/queue.js +87 -0
  250. package/dist/cjs/transactions/executor/serial.d.ts +31 -0
  251. package/dist/cjs/transactions/executor/serial.js +136 -0
  252. package/dist/cjs/transactions/hash.d.ts +7 -0
  253. package/dist/cjs/transactions/hash.js +31 -0
  254. package/dist/cjs/transactions/index.d.ts +21 -0
  255. package/dist/cjs/transactions/index.js +50 -0
  256. package/dist/cjs/transactions/intents/CoinWithBalance.d.ts +9 -0
  257. package/dist/cjs/transactions/intents/CoinWithBalance.js +206 -0
  258. package/dist/cjs/transactions/object.d.ts +24 -0
  259. package/dist/cjs/transactions/object.js +116 -0
  260. package/dist/cjs/transactions/plugins/NamedPackagesPlugin.d.ts +31 -0
  261. package/dist/cjs/transactions/plugins/NamedPackagesPlugin.js +37 -0
  262. package/dist/cjs/transactions/pure.d.ts +20 -0
  263. package/dist/cjs/transactions/pure.js +64 -0
  264. package/dist/cjs/transactions/resolve.d.ts +13 -0
  265. package/dist/cjs/transactions/resolve.js +103 -0
  266. package/dist/cjs/transactions/serializer.d.ts +7 -0
  267. package/dist/cjs/transactions/serializer.js +189 -0
  268. package/dist/cjs/transactions/utils.d.ts +10 -0
  269. package/dist/cjs/transactions/utils.js +143 -0
  270. package/dist/cjs/utils/constants.d.ts +17 -0
  271. package/dist/cjs/utils/constants.js +57 -0
  272. package/dist/cjs/utils/derived-objects.d.ts +5 -0
  273. package/dist/cjs/utils/derived-objects.js +33 -0
  274. package/dist/cjs/utils/dynamic-fields.d.ts +2 -0
  275. package/dist/cjs/utils/dynamic-fields.js +40 -0
  276. package/dist/cjs/utils/format.d.ts +2 -0
  277. package/dist/cjs/utils/format.js +35 -0
  278. package/dist/cjs/utils/index.d.ts +8 -0
  279. package/dist/cjs/utils/index.js +65 -0
  280. package/dist/cjs/utils/move-registry.d.ts +6 -0
  281. package/dist/cjs/utils/move-registry.js +44 -0
  282. package/dist/cjs/utils/sui-types.d.ts +26 -0
  283. package/dist/cjs/utils/sui-types.js +90 -0
  284. package/dist/cjs/utils/suins.d.ts +2 -0
  285. package/dist/cjs/utils/suins.js +56 -0
  286. package/dist/cjs/verify/index.d.ts +1 -0
  287. package/dist/cjs/verify/index.js +28 -0
  288. package/dist/cjs/verify/verify.d.ts +16 -0
  289. package/dist/cjs/verify/verify.js +125 -0
  290. package/dist/cjs/version.d.ts +2 -0
  291. package/dist/cjs/version.js +26 -0
  292. package/dist/cjs/w/call/allocation.d.ts +35 -0
  293. package/dist/cjs/w/call/allocation.js +439 -0
  294. package/dist/cjs/w/call/arb.d.ts +17 -0
  295. package/dist/cjs/w/call/arb.js +149 -0
  296. package/dist/cjs/w/call/arbitration.d.ts +106 -0
  297. package/dist/cjs/w/call/arbitration.js +1623 -0
  298. package/dist/cjs/w/call/base.d.ts +42 -0
  299. package/dist/cjs/w/call/base.js +363 -0
  300. package/dist/cjs/w/call/contact.d.ts +45 -0
  301. package/dist/cjs/w/call/contact.js +479 -0
  302. package/dist/cjs/w/call/demand.d.ts +79 -0
  303. package/dist/cjs/w/call/demand.js +872 -0
  304. package/dist/cjs/w/call/entity.d.ts +33 -0
  305. package/dist/cjs/w/call/entity.js +230 -0
  306. package/dist/cjs/w/call/guard-ins.d.ts +31 -0
  307. package/dist/cjs/w/call/guard-ins.js +4391 -0
  308. package/dist/cjs/w/call/guard.d.ts +254 -0
  309. package/dist/cjs/w/call/guard.js +1210 -0
  310. package/dist/cjs/w/call/index.d.ts +37 -0
  311. package/dist/cjs/w/call/index.js +71 -0
  312. package/dist/cjs/w/call/machine.d.ts +124 -0
  313. package/dist/cjs/w/call/machine.js +1486 -0
  314. package/dist/cjs/w/call/order.d.ts +73 -0
  315. package/dist/cjs/w/call/order.js +485 -0
  316. package/dist/cjs/w/call/passport.d.ts +24 -0
  317. package/dist/cjs/w/call/passport.js +281 -0
  318. package/dist/cjs/w/call/payment.d.ts +27 -0
  319. package/dist/cjs/w/call/payment.js +241 -0
  320. package/dist/cjs/w/call/permission.d.ts +222 -0
  321. package/dist/cjs/w/call/permission.js +1368 -0
  322. package/dist/cjs/w/call/personal.d.ts +51 -0
  323. package/dist/cjs/w/call/personal.js +184 -0
  324. package/dist/cjs/w/call/progress.d.ts +94 -0
  325. package/dist/cjs/w/call/progress.js +833 -0
  326. package/dist/cjs/w/call/proof.d.ts +27 -0
  327. package/dist/cjs/w/call/proof.js +124 -0
  328. package/dist/cjs/w/call/repository.d.ts +97 -0
  329. package/dist/cjs/w/call/repository.js +1324 -0
  330. package/dist/cjs/w/call/resource.d.ts +27 -0
  331. package/dist/cjs/w/call/resource.js +149 -0
  332. package/dist/cjs/w/call/reward.d.ts +52 -0
  333. package/dist/cjs/w/call/reward.js +879 -0
  334. package/dist/cjs/w/call/service.d.ts +184 -0
  335. package/dist/cjs/w/call/service.js +2468 -0
  336. package/dist/cjs/w/call/treasury.d.ts +77 -0
  337. package/dist/cjs/w/call/treasury.js +1192 -0
  338. package/dist/cjs/w/call/util.d.ts +12 -0
  339. package/dist/cjs/w/call/util.js +661 -0
  340. package/dist/cjs/w/common.d.ts +359 -0
  341. package/dist/cjs/w/common.js +625 -0
  342. package/dist/cjs/w/exception.d.ts +82 -0
  343. package/dist/cjs/w/exception.js +604 -0
  344. package/dist/cjs/w/index.d.ts +8 -0
  345. package/dist/cjs/w/index.js +25 -0
  346. package/dist/cjs/w/local/.eslintrc.js +15 -0
  347. package/dist/cjs/w/local/account.d.ts +134 -0
  348. package/dist/cjs/w/local/account.js +770 -0
  349. package/dist/cjs/w/local/cache.d.ts +35 -0
  350. package/dist/cjs/w/local/cache.js +181 -0
  351. package/dist/cjs/w/local/config.d.ts +15 -0
  352. package/dist/cjs/w/local/config.js +83 -0
  353. package/dist/cjs/w/local/index.d.ts +193 -0
  354. package/dist/cjs/w/local/index.js +322 -0
  355. package/dist/cjs/w/local/local.d.ts +93 -0
  356. package/dist/cjs/w/local/local.js +673 -0
  357. package/dist/cjs/w/local/storage.d.ts +61 -0
  358. package/dist/cjs/w/local/storage.js +219 -0
  359. package/dist/cjs/w/local/token.d.ts +22 -0
  360. package/dist/cjs/w/local/token.js +182 -0
  361. package/dist/cjs/w/local/util.d.ts +5 -0
  362. package/dist/cjs/w/local/util.js +57 -0
  363. package/dist/cjs/w/local/wip.d.ts +218 -0
  364. package/dist/cjs/w/local/wip.js +911 -0
  365. package/dist/cjs/w/messenger/.eslintrc.js +15 -0
  366. package/dist/cjs/w/messenger/crypto.d.ts +269 -0
  367. package/dist/cjs/w/messenger/crypto.js +448 -0
  368. package/dist/cjs/w/messenger/index.d.ts +23 -0
  369. package/dist/cjs/w/messenger/index.js +37 -0
  370. package/dist/cjs/w/messenger/messenger-api.d.ts +225 -0
  371. package/dist/cjs/w/messenger/messenger-api.js +1247 -0
  372. package/dist/cjs/w/messenger/messenger-manager.d.ts +80 -0
  373. package/dist/cjs/w/messenger/messenger-manager.js +1143 -0
  374. package/dist/cjs/w/messenger/messenger.d.ts +231 -0
  375. package/dist/cjs/w/messenger/messenger.js +1512 -0
  376. package/dist/cjs/w/messenger/server.d.ts +134 -0
  377. package/dist/cjs/w/messenger/server.js +535 -0
  378. package/dist/cjs/w/messenger/session.d.ts +78 -0
  379. package/dist/cjs/w/messenger/session.js +418 -0
  380. package/dist/cjs/w/messenger/storage.d.ts +192 -0
  381. package/dist/cjs/w/messenger/storage.js +964 -0
  382. package/dist/cjs/w/messenger/types.d.ts +705 -0
  383. package/dist/cjs/w/messenger/types.js +107 -0
  384. package/dist/cjs/w/messenger/utils.d.ts +15 -0
  385. package/dist/cjs/w/messenger/utils.js +37 -0
  386. package/dist/cjs/w/query/bult-in.d.ts +73 -0
  387. package/dist/cjs/w/query/bult-in.js +121 -0
  388. package/dist/cjs/w/query/event.d.ts +82 -0
  389. package/dist/cjs/w/query/event.js +157 -0
  390. package/dist/cjs/w/query/index.d.ts +5 -0
  391. package/dist/cjs/w/query/index.js +22 -0
  392. package/dist/cjs/w/query/object.d.ts +658 -0
  393. package/dist/cjs/w/query/object.js +1671 -0
  394. package/dist/cjs/w/query/received.d.ts +34 -0
  395. package/dist/cjs/w/query/received.js +93 -0
  396. package/dist/cjs/w/query/util.d.ts +5 -0
  397. package/dist/cjs/w/query/util.js +82 -0
  398. package/dist/cjs/w/util.d.ts +19 -0
  399. package/dist/cjs/w/util.js +715 -0
  400. package/dist/cjs/zklogin/address.js +93 -0
  401. package/dist/cjs/zklogin/bcs.js +41 -0
  402. package/dist/cjs/zklogin/index.js +45 -0
  403. package/dist/cjs/zklogin/jwt-decode.js +88 -0
  404. package/dist/cjs/zklogin/jwt-utils.js +128 -0
  405. package/dist/cjs/zklogin/nonce.js +60 -0
  406. package/dist/cjs/zklogin/poseidon.js +64 -0
  407. package/dist/cjs/zklogin/publickey.js +281 -0
  408. package/dist/cjs/zklogin/signature.js +57 -0
  409. package/dist/cjs/zklogin/utils.js +98 -0
  410. package/dist/esm/bcs/bcs.d.ts +1973 -0
  411. package/dist/esm/bcs/bcs.js +319 -0
  412. package/dist/esm/bcs/effects.d.ts +579 -0
  413. package/dist/esm/bcs/effects.js +211 -0
  414. package/dist/esm/bcs/index.d.ts +2589 -0
  415. package/dist/esm/bcs/index.js +98 -0
  416. package/dist/esm/bcs/pure.d.ts +22 -0
  417. package/dist/esm/bcs/pure.js +42 -0
  418. package/dist/esm/bcs/type-tag-serializer.d.ts +7 -0
  419. package/dist/esm/bcs/type-tag-serializer.js +104 -0
  420. package/dist/esm/bcs/types.d.ts +114 -0
  421. package/dist/esm/bcs/types.js +6 -0
  422. package/dist/esm/client/index.d.ts +5 -0
  423. package/dist/esm/client/index.js +23 -0
  424. package/dist/esm/client/network.d.ts +5 -0
  425. package/dist/esm/client/network.js +23 -0
  426. package/dist/esm/cryptography/index.d.ts +7 -0
  427. package/dist/esm/cryptography/index.js +46 -0
  428. package/dist/esm/cryptography/intent.d.ts +6 -0
  429. package/dist/esm/cryptography/intent.js +14 -0
  430. package/dist/esm/cryptography/keypair.d.ts +73 -0
  431. package/dist/esm/cryptography/keypair.js +108 -0
  432. package/dist/esm/cryptography/mnemonics.d.ts +27 -0
  433. package/dist/esm/cryptography/mnemonics.js +30 -0
  434. package/dist/esm/cryptography/publickey.d.ts +67 -0
  435. package/dist/esm/cryptography/publickey.js +125 -0
  436. package/dist/esm/cryptography/signature-scheme.d.ts +24 -0
  437. package/dist/esm/cryptography/signature-scheme.js +27 -0
  438. package/dist/esm/cryptography/signature.d.ts +62 -0
  439. package/dist/esm/cryptography/signature.js +54 -0
  440. package/dist/esm/experimental/cache.d.ts +12 -0
  441. package/dist/esm/experimental/client.d.ts +12 -0
  442. package/dist/esm/experimental/core.d.ts +33 -0
  443. package/dist/esm/experimental/errors.d.ts +8 -0
  444. package/dist/esm/experimental/index.d.ts +7 -0
  445. package/dist/esm/experimental/persistent-storage.d.ts +134 -0
  446. package/dist/esm/experimental/persistent-storage.test.d.ts +5 -0
  447. package/dist/esm/experimental/transports/utils.d.ts +3 -0
  448. package/dist/esm/experimental/types.d.ts +367 -0
  449. package/dist/esm/faucet/faucet.d.ts +66 -0
  450. package/dist/esm/faucet/faucet.js +118 -0
  451. package/dist/esm/faucet/index.d.ts +1 -0
  452. package/dist/esm/faucet/index.js +16 -0
  453. package/dist/esm/graphql/client.js +79 -0
  454. package/dist/esm/graphql/core.js +505 -0
  455. package/dist/esm/graphql/generated/2024.1/tada-env.js +13121 -0
  456. package/dist/esm/graphql/generated/2024.1/tsconfig.tada.js +16 -0
  457. package/dist/esm/graphql/generated/2024.4/tada-env.js +13267 -0
  458. package/dist/esm/graphql/generated/2024.4/tsconfig.tada.js +16 -0
  459. package/dist/esm/graphql/generated/latest/tada-env.js +12905 -0
  460. package/dist/esm/graphql/generated/latest/tsconfig.tada.js +16 -0
  461. package/dist/esm/graphql/generated/queries.js +788 -0
  462. package/dist/esm/graphql/index.js +8 -0
  463. package/dist/esm/graphql/schemas/2024.1/index.js +8 -0
  464. package/dist/esm/graphql/schemas/2024.4/index.js +8 -0
  465. package/dist/esm/graphql/schemas/latest/index.js +8 -0
  466. package/dist/esm/graphql/types.js +0 -0
  467. package/dist/esm/grpc/client.d.ts +32 -0
  468. package/dist/esm/grpc/client.js +45 -0
  469. package/dist/esm/grpc/core.d.ts +28 -0
  470. package/dist/esm/grpc/core.js +634 -0
  471. package/dist/esm/grpc/index.d.ts +4 -0
  472. package/dist/esm/grpc/index.js +6 -0
  473. package/dist/esm/grpc/proto/google/protobuf/any.d.ts +173 -0
  474. package/dist/esm/grpc/proto/google/protobuf/any.js +118 -0
  475. package/dist/esm/grpc/proto/google/protobuf/duration.d.ts +104 -0
  476. package/dist/esm/grpc/proto/google/protobuf/duration.js +74 -0
  477. package/dist/esm/grpc/proto/google/protobuf/empty.d.ts +25 -0
  478. package/dist/esm/grpc/proto/google/protobuf/empty.js +10 -0
  479. package/dist/esm/grpc/proto/google/protobuf/field_mask.d.ts +231 -0
  480. package/dist/esm/grpc/proto/google/protobuf/field_mask.js +57 -0
  481. package/dist/esm/grpc/proto/google/protobuf/struct.d.ts +169 -0
  482. package/dist/esm/grpc/proto/google/protobuf/struct.js +204 -0
  483. package/dist/esm/grpc/proto/google/protobuf/timestamp.d.ts +145 -0
  484. package/dist/esm/grpc/proto/google/protobuf/timestamp.js +114 -0
  485. package/dist/esm/grpc/proto/google/rpc/error_details.d.ts +525 -0
  486. package/dist/esm/grpc/proto/google/rpc/error_details.js +297 -0
  487. package/dist/esm/grpc/proto/google/rpc/status.d.ts +46 -0
  488. package/dist/esm/grpc/proto/google/rpc/status.js +32 -0
  489. package/dist/esm/grpc/proto/sui/rpc/v2/argument.d.ts +66 -0
  490. package/dist/esm/grpc/proto/sui/rpc/v2/argument.js +50 -0
  491. package/dist/esm/grpc/proto/sui/rpc/v2/balance_change.d.ts +34 -0
  492. package/dist/esm/grpc/proto/sui/rpc/v2/balance_change.js +32 -0
  493. package/dist/esm/grpc/proto/sui/rpc/v2/bcs.d.ts +30 -0
  494. package/dist/esm/grpc/proto/sui/rpc/v2/bcs.js +25 -0
  495. package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint.d.ts +68 -0
  496. package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint.js +57 -0
  497. package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_contents.d.ts +74 -0
  498. package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_contents.js +64 -0
  499. package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_summary.d.ts +195 -0
  500. package/dist/esm/grpc/proto/sui/rpc/v2/checkpoint_summary.js +150 -0
  501. package/dist/esm/grpc/proto/sui/rpc/v2/effects.d.ts +338 -0
  502. package/dist/esm/grpc/proto/sui/rpc/v2/effects.js +280 -0
  503. package/dist/esm/grpc/proto/sui/rpc/v2/epoch.d.ts +62 -0
  504. package/dist/esm/grpc/proto/sui/rpc/v2/epoch.js +67 -0
  505. package/dist/esm/grpc/proto/sui/rpc/v2/error_reason.d.ts +17 -0
  506. package/dist/esm/grpc/proto/sui/rpc/v2/error_reason.js +9 -0
  507. package/dist/esm/grpc/proto/sui/rpc/v2/event.d.ts +88 -0
  508. package/dist/esm/grpc/proto/sui/rpc/v2/event.js +66 -0
  509. package/dist/esm/grpc/proto/sui/rpc/v2/executed_transaction.d.ts +80 -0
  510. package/dist/esm/grpc/proto/sui/rpc/v2/executed_transaction.js +67 -0
  511. package/dist/esm/grpc/proto/sui/rpc/v2/execution_status.d.ts +843 -0
  512. package/dist/esm/grpc/proto/sui/rpc/v2/execution_status.js +499 -0
  513. package/dist/esm/grpc/proto/sui/rpc/v2/gas_cost_summary.d.ts +41 -0
  514. package/dist/esm/grpc/proto/sui/rpc/v2/gas_cost_summary.js +43 -0
  515. package/dist/esm/grpc/proto/sui/rpc/v2/input.d.ts +98 -0
  516. package/dist/esm/grpc/proto/sui/rpc/v2/input.js +65 -0
  517. package/dist/esm/grpc/proto/sui/rpc/v2/jwk.d.ts +70 -0
  518. package/dist/esm/grpc/proto/sui/rpc/v2/jwk.js +61 -0
  519. package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.client.d.ts +95 -0
  520. package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.client.js +103 -0
  521. package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.d.ts +420 -0
  522. package/dist/esm/grpc/proto/sui/rpc/v2/ledger_service.js +348 -0
  523. package/dist/esm/grpc/proto/sui/rpc/v2/move_package.d.ts +579 -0
  524. package/dist/esm/grpc/proto/sui/rpc/v2/move_package.js +465 -0
  525. package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.client.d.ts +61 -0
  526. package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.client.js +62 -0
  527. package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.d.ts +229 -0
  528. package/dist/esm/grpc/proto/sui/rpc/v2/move_package_service.js +221 -0
  529. package/dist/esm/grpc/proto/sui/rpc/v2/name_service.client.d.ts +41 -0
  530. package/dist/esm/grpc/proto/sui/rpc/v2/name_service.client.js +36 -0
  531. package/dist/esm/grpc/proto/sui/rpc/v2/name_service.d.ts +144 -0
  532. package/dist/esm/grpc/proto/sui/rpc/v2/name_service.js +121 -0
  533. package/dist/esm/grpc/proto/sui/rpc/v2/object.d.ts +127 -0
  534. package/dist/esm/grpc/proto/sui/rpc/v2/object.js +94 -0
  535. package/dist/esm/grpc/proto/sui/rpc/v2/object_reference.d.ts +34 -0
  536. package/dist/esm/grpc/proto/sui/rpc/v2/object_reference.js +33 -0
  537. package/dist/esm/grpc/proto/sui/rpc/v2/owner.d.ts +61 -0
  538. package/dist/esm/grpc/proto/sui/rpc/v2/owner.js +43 -0
  539. package/dist/esm/grpc/proto/sui/rpc/v2/protocol_config.d.ts +30 -0
  540. package/dist/esm/grpc/proto/sui/rpc/v2/protocol_config.js +41 -0
  541. package/dist/esm/grpc/proto/sui/rpc/v2/signature.d.ts +630 -0
  542. package/dist/esm/grpc/proto/sui/rpc/v2/signature.js +521 -0
  543. package/dist/esm/grpc/proto/sui/rpc/v2/signature_scheme.d.ts +40 -0
  544. package/dist/esm/grpc/proto/sui/rpc/v2/signature_scheme.js +13 -0
  545. package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.ts +35 -0
  546. package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.client.js +31 -0
  547. package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.d.ts +79 -0
  548. package/dist/esm/grpc/proto/sui/rpc/v2/signature_verification_service.js +70 -0
  549. package/dist/esm/grpc/proto/sui/rpc/v2/state_service.client.d.ts +71 -0
  550. package/dist/esm/grpc/proto/sui/rpc/v2/state_service.client.js +69 -0
  551. package/dist/esm/grpc/proto/sui/rpc/v2/state_service.d.ts +690 -0
  552. package/dist/esm/grpc/proto/sui/rpc/v2/state_service.js +526 -0
  553. package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts +55 -0
  554. package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.client.js +35 -0
  555. package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.d.ts +57 -0
  556. package/dist/esm/grpc/proto/sui/rpc/v2/subscription_service.js +45 -0
  557. package/dist/esm/grpc/proto/sui/rpc/v2/system_state.d.ts +684 -0
  558. package/dist/esm/grpc/proto/sui/rpc/v2/system_state.js +720 -0
  559. package/dist/esm/grpc/proto/sui/rpc/v2/transaction.d.ts +1321 -0
  560. package/dist/esm/grpc/proto/sui/rpc/v2/transaction.js +985 -0
  561. package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.ts +41 -0
  562. package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.client.js +30 -0
  563. package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.d.ts +184 -0
  564. package/dist/esm/grpc/proto/sui/rpc/v2/transaction_execution_service.js +157 -0
  565. package/dist/esm/index.d.ts +25 -0
  566. package/dist/esm/index.js +119 -0
  567. package/dist/esm/jsonRpc/client.d.ts +261 -0
  568. package/dist/esm/jsonRpc/client.js +734 -0
  569. package/dist/esm/jsonRpc/core.d.ts +87 -0
  570. package/dist/esm/jsonRpc/core.js +621 -0
  571. package/dist/esm/jsonRpc/errors.d.ts +12 -0
  572. package/dist/esm/jsonRpc/errors.js +46 -0
  573. package/dist/esm/jsonRpc/http-transport.d.ts +42 -0
  574. package/dist/esm/jsonRpc/http-transport.js +101 -0
  575. package/dist/esm/jsonRpc/index.d.ts +4 -0
  576. package/dist/esm/jsonRpc/index.js +20 -0
  577. package/dist/esm/jsonRpc/json-rpc-resolver.d.ts +4 -0
  578. package/dist/esm/jsonRpc/json-rpc-resolver.js +309 -0
  579. package/dist/esm/jsonRpc/rpc-websocket-client.d.ts +43 -0
  580. package/dist/esm/jsonRpc/rpc-websocket-client.js +201 -0
  581. package/dist/esm/jsonRpc/types/chain.d.ts +99 -0
  582. package/dist/esm/jsonRpc/types/chain.js +0 -0
  583. package/dist/esm/jsonRpc/types/changes.d.ts +19 -0
  584. package/dist/esm/jsonRpc/types/changes.js +0 -0
  585. package/dist/esm/jsonRpc/types/coins.d.ts +6 -0
  586. package/dist/esm/jsonRpc/types/coins.js +0 -0
  587. package/dist/esm/jsonRpc/types/common.d.ts +2 -0
  588. package/dist/esm/jsonRpc/types/common.js +0 -0
  589. package/dist/esm/jsonRpc/types/generated.d.ts +1492 -0
  590. package/dist/esm/jsonRpc/types/generated.js +0 -0
  591. package/dist/esm/jsonRpc/types/index.d.ts +6 -0
  592. package/dist/esm/jsonRpc/types/index.js +0 -0
  593. package/dist/esm/jsonRpc/types/params.d.ts +656 -0
  594. package/dist/esm/jsonRpc/types/params.js +0 -0
  595. package/dist/esm/keypairs/ed25519/ed25519-hd-key.d.ts +8 -0
  596. package/dist/esm/keypairs/ed25519/ed25519-hd-key.js +62 -0
  597. package/dist/esm/keypairs/ed25519/index.d.ts +2 -0
  598. package/dist/esm/keypairs/ed25519/index.js +10 -0
  599. package/dist/esm/keypairs/ed25519/keypair.d.ts +74 -0
  600. package/dist/esm/keypairs/ed25519/keypair.js +158 -0
  601. package/dist/esm/keypairs/ed25519/publickey.d.ts +30 -0
  602. package/dist/esm/keypairs/ed25519/publickey.js +75 -0
  603. package/dist/esm/keypairs/index.d.ts +4 -0
  604. package/dist/esm/keypairs/index.js +4 -0
  605. package/dist/esm/keypairs/passkey/index.d.ts +3 -0
  606. package/dist/esm/keypairs/passkey/index.js +12 -0
  607. package/dist/esm/keypairs/passkey/keypair.d.ts +113 -0
  608. package/dist/esm/keypairs/passkey/keypair.js +258 -0
  609. package/dist/esm/keypairs/passkey/publickey.d.ts +72 -0
  610. package/dist/esm/keypairs/passkey/publickey.js +156 -0
  611. package/dist/esm/keypairs/passkey/types.d.ts +12 -0
  612. package/dist/esm/keypairs/passkey/types.js +0 -0
  613. package/dist/esm/keypairs/secp256k1/index.d.ts +2 -0
  614. package/dist/esm/keypairs/secp256k1/index.js +10 -0
  615. package/dist/esm/keypairs/secp256k1/keypair.d.ts +73 -0
  616. package/dist/esm/keypairs/secp256k1/keypair.js +147 -0
  617. package/dist/esm/keypairs/secp256k1/publickey.d.ts +30 -0
  618. package/dist/esm/keypairs/secp256k1/publickey.js +80 -0
  619. package/dist/esm/keypairs/secp256r1/index.d.ts +2 -0
  620. package/dist/esm/keypairs/secp256r1/index.js +10 -0
  621. package/dist/esm/keypairs/secp256r1/keypair.d.ts +73 -0
  622. package/dist/esm/keypairs/secp256r1/keypair.js +143 -0
  623. package/dist/esm/keypairs/secp256r1/publickey.d.ts +30 -0
  624. package/dist/esm/keypairs/secp256r1/publickey.js +77 -0
  625. package/dist/esm/multisig/index.d.ts +2 -0
  626. package/dist/esm/multisig/index.js +10 -0
  627. package/dist/esm/multisig/publickey.d.ts +79 -0
  628. package/dist/esm/multisig/publickey.js +280 -0
  629. package/dist/esm/multisig/signer.d.ts +20 -0
  630. package/dist/esm/multisig/signer.js +94 -0
  631. package/dist/esm/package.json +5 -0
  632. package/dist/esm/transactions/Arguments.d.ts +57 -0
  633. package/dist/esm/transactions/Arguments.js +16 -0
  634. package/dist/esm/transactions/Commands.d.ts +57 -0
  635. package/dist/esm/transactions/Commands.js +123 -0
  636. package/dist/esm/transactions/Inputs.d.ts +22 -0
  637. package/dist/esm/transactions/Inputs.js +67 -0
  638. package/dist/esm/transactions/ObjectCache.d.ts +83 -0
  639. package/dist/esm/transactions/ObjectCache.js +231 -0
  640. package/dist/esm/transactions/Transaction.d.ts +710 -0
  641. package/dist/esm/transactions/Transaction.js +731 -0
  642. package/dist/esm/transactions/TransactionData.d.ts +73 -0
  643. package/dist/esm/transactions/TransactionData.js +453 -0
  644. package/dist/esm/transactions/__tests__/Transaction.test.d.ts +1 -0
  645. package/dist/esm/transactions/__tests__/bcs.test.d.ts +1 -0
  646. package/dist/esm/transactions/data/internal.d.ts +1010 -0
  647. package/dist/esm/transactions/data/internal.js +232 -0
  648. package/dist/esm/transactions/data/v1.d.ts +312 -0
  649. package/dist/esm/transactions/data/v1.js +542 -0
  650. package/dist/esm/transactions/data/v2.d.ts +153 -0
  651. package/dist/esm/transactions/data/v2.js +126 -0
  652. package/dist/esm/transactions/executor/caching.d.ts +31 -0
  653. package/dist/esm/transactions/executor/caching.js +99 -0
  654. package/dist/esm/transactions/executor/parallel.d.ts +37 -0
  655. package/dist/esm/transactions/executor/parallel.js +375 -0
  656. package/dist/esm/transactions/executor/queue.d.ts +11 -0
  657. package/dist/esm/transactions/executor/queue.js +68 -0
  658. package/dist/esm/transactions/executor/serial.d.ts +31 -0
  659. package/dist/esm/transactions/executor/serial.js +116 -0
  660. package/dist/esm/transactions/hash.d.ts +7 -0
  661. package/dist/esm/transactions/hash.js +11 -0
  662. package/dist/esm/transactions/index.d.ts +21 -0
  663. package/dist/esm/transactions/index.js +41 -0
  664. package/dist/esm/transactions/intents/CoinWithBalance.d.ts +9 -0
  665. package/dist/esm/transactions/intents/CoinWithBalance.js +186 -0
  666. package/dist/esm/transactions/object.d.ts +24 -0
  667. package/dist/esm/transactions/object.js +96 -0
  668. package/dist/esm/transactions/plugins/NamedPackagesPlugin.d.ts +31 -0
  669. package/dist/esm/transactions/plugins/NamedPackagesPlugin.js +17 -0
  670. package/dist/esm/transactions/pure.d.ts +20 -0
  671. package/dist/esm/transactions/pure.js +44 -0
  672. package/dist/esm/transactions/resolve.d.ts +13 -0
  673. package/dist/esm/transactions/resolve.js +83 -0
  674. package/dist/esm/transactions/serializer.d.ts +7 -0
  675. package/dist/esm/transactions/serializer.js +169 -0
  676. package/dist/esm/transactions/utils.d.ts +10 -0
  677. package/dist/esm/transactions/utils.js +123 -0
  678. package/dist/esm/utils/constants.d.ts +17 -0
  679. package/dist/esm/utils/constants.js +37 -0
  680. package/dist/esm/utils/derived-objects.d.ts +5 -0
  681. package/dist/esm/utils/derived-objects.js +13 -0
  682. package/dist/esm/utils/dynamic-fields.d.ts +2 -0
  683. package/dist/esm/utils/dynamic-fields.js +20 -0
  684. package/dist/esm/utils/format.d.ts +2 -0
  685. package/dist/esm/utils/format.js +15 -0
  686. package/dist/esm/utils/index.d.ts +8 -0
  687. package/dist/esm/utils/index.js +76 -0
  688. package/dist/esm/utils/move-registry.d.ts +6 -0
  689. package/dist/esm/utils/move-registry.js +24 -0
  690. package/dist/esm/utils/sui-types.d.ts +26 -0
  691. package/dist/esm/utils/sui-types.js +70 -0
  692. package/dist/esm/utils/suins.d.ts +2 -0
  693. package/dist/esm/utils/suins.js +36 -0
  694. package/dist/esm/verify/index.d.ts +1 -0
  695. package/dist/esm/verify/index.js +14 -0
  696. package/dist/esm/verify/verify.d.ts +16 -0
  697. package/dist/esm/verify/verify.js +108 -0
  698. package/dist/esm/version.d.ts +2 -0
  699. package/dist/esm/version.js +6 -0
  700. package/dist/esm/w/call/allocation.d.ts +35 -0
  701. package/dist/esm/w/call/allocation.js +433 -0
  702. package/dist/esm/w/call/arb.d.ts +17 -0
  703. package/dist/esm/w/call/arb.js +138 -0
  704. package/dist/esm/w/call/arbitration.d.ts +106 -0
  705. package/dist/esm/w/call/arbitration.js +1620 -0
  706. package/dist/esm/w/call/base.d.ts +42 -0
  707. package/dist/esm/w/call/base.js +350 -0
  708. package/dist/esm/w/call/contact.d.ts +45 -0
  709. package/dist/esm/w/call/contact.js +474 -0
  710. package/dist/esm/w/call/demand.d.ts +79 -0
  711. package/dist/esm/w/call/demand.js +869 -0
  712. package/dist/esm/w/call/entity.d.ts +33 -0
  713. package/dist/esm/w/call/entity.js +220 -0
  714. package/dist/esm/w/call/guard-ins.d.ts +31 -0
  715. package/dist/esm/w/call/guard-ins.js +4371 -0
  716. package/dist/esm/w/call/guard.d.ts +254 -0
  717. package/dist/esm/w/call/guard.js +1202 -0
  718. package/dist/esm/w/call/index.d.ts +37 -0
  719. package/dist/esm/w/call/index.js +57 -0
  720. package/dist/esm/w/call/machine.d.ts +124 -0
  721. package/dist/esm/w/call/machine.js +1492 -0
  722. package/dist/esm/w/call/order.d.ts +73 -0
  723. package/dist/esm/w/call/order.js +481 -0
  724. package/dist/esm/w/call/passport.d.ts +24 -0
  725. package/dist/esm/w/call/passport.js +266 -0
  726. package/dist/esm/w/call/payment.d.ts +27 -0
  727. package/dist/esm/w/call/payment.js +233 -0
  728. package/dist/esm/w/call/permission.d.ts +222 -0
  729. package/dist/esm/w/call/permission.js +1375 -0
  730. package/dist/esm/w/call/personal.d.ts +51 -0
  731. package/dist/esm/w/call/personal.js +177 -0
  732. package/dist/esm/w/call/progress.d.ts +94 -0
  733. package/dist/esm/w/call/progress.js +827 -0
  734. package/dist/esm/w/call/proof.d.ts +27 -0
  735. package/dist/esm/w/call/proof.js +110 -0
  736. package/dist/esm/w/call/repository.d.ts +97 -0
  737. package/dist/esm/w/call/repository.js +1325 -0
  738. package/dist/esm/w/call/resource.d.ts +27 -0
  739. package/dist/esm/w/call/resource.js +135 -0
  740. package/dist/esm/w/call/reward.d.ts +52 -0
  741. package/dist/esm/w/call/reward.js +874 -0
  742. package/dist/esm/w/call/service.d.ts +184 -0
  743. package/dist/esm/w/call/service.js +2472 -0
  744. package/dist/esm/w/call/treasury.d.ts +77 -0
  745. package/dist/esm/w/call/treasury.js +1186 -0
  746. package/dist/esm/w/call/util.d.ts +12 -0
  747. package/dist/esm/w/call/util.js +646 -0
  748. package/dist/esm/w/common.d.ts +359 -0
  749. package/dist/esm/w/common.js +605 -0
  750. package/dist/esm/w/exception.d.ts +82 -0
  751. package/dist/esm/w/exception.js +585 -0
  752. package/dist/esm/w/index.d.ts +8 -0
  753. package/dist/esm/w/index.js +8 -0
  754. package/dist/esm/w/local/.eslintrc.js +23 -0
  755. package/dist/esm/w/local/account.d.ts +134 -0
  756. package/dist/esm/w/local/account.js +746 -0
  757. package/dist/esm/w/local/cache.d.ts +35 -0
  758. package/dist/esm/w/local/cache.js +162 -0
  759. package/dist/esm/w/local/config.d.ts +15 -0
  760. package/dist/esm/w/local/config.js +64 -0
  761. package/dist/esm/w/local/index.d.ts +193 -0
  762. package/dist/esm/w/local/index.js +301 -0
  763. package/dist/esm/w/local/local.d.ts +93 -0
  764. package/dist/esm/w/local/local.js +654 -0
  765. package/dist/esm/w/local/storage.d.ts +61 -0
  766. package/dist/esm/w/local/storage.js +190 -0
  767. package/dist/esm/w/local/token.d.ts +22 -0
  768. package/dist/esm/w/local/token.js +163 -0
  769. package/dist/esm/w/local/util.d.ts +5 -0
  770. package/dist/esm/w/local/util.js +27 -0
  771. package/dist/esm/w/local/wip.d.ts +218 -0
  772. package/dist/esm/w/local/wip.js +882 -0
  773. package/dist/esm/w/messenger/.eslintrc.js +23 -0
  774. package/dist/esm/w/messenger/crypto.d.ts +269 -0
  775. package/dist/esm/w/messenger/crypto.js +428 -0
  776. package/dist/esm/w/messenger/index.d.ts +23 -0
  777. package/dist/esm/w/messenger/index.js +25 -0
  778. package/dist/esm/w/messenger/messenger-api.d.ts +225 -0
  779. package/dist/esm/w/messenger/messenger-api.js +1228 -0
  780. package/dist/esm/w/messenger/messenger-manager.d.ts +80 -0
  781. package/dist/esm/w/messenger/messenger-manager.js +1118 -0
  782. package/dist/esm/w/messenger/messenger.d.ts +231 -0
  783. package/dist/esm/w/messenger/messenger.js +1492 -0
  784. package/dist/esm/w/messenger/server.d.ts +134 -0
  785. package/dist/esm/w/messenger/server.js +520 -0
  786. package/dist/esm/w/messenger/session.d.ts +78 -0
  787. package/dist/esm/w/messenger/session.js +415 -0
  788. package/dist/esm/w/messenger/storage.d.ts +192 -0
  789. package/dist/esm/w/messenger/storage.js +935 -0
  790. package/dist/esm/w/messenger/types.d.ts +705 -0
  791. package/dist/esm/w/messenger/types.js +88 -0
  792. package/dist/esm/w/messenger/utils.d.ts +15 -0
  793. package/dist/esm/w/messenger/utils.js +17 -0
  794. package/dist/esm/w/query/bult-in.d.ts +73 -0
  795. package/dist/esm/w/query/bult-in.js +112 -0
  796. package/dist/esm/w/query/event.d.ts +82 -0
  797. package/dist/esm/w/query/event.js +137 -0
  798. package/dist/esm/w/query/index.d.ts +5 -0
  799. package/dist/esm/w/query/index.js +5 -0
  800. package/dist/esm/w/query/object.d.ts +658 -0
  801. package/dist/esm/w/query/object.js +1648 -0
  802. package/dist/esm/w/query/received.d.ts +34 -0
  803. package/dist/esm/w/query/received.js +73 -0
  804. package/dist/esm/w/query/util.d.ts +5 -0
  805. package/dist/esm/w/query/util.js +62 -0
  806. package/dist/esm/w/util.d.ts +19 -0
  807. package/dist/esm/w/util.js +710 -0
  808. package/dist/esm/zklogin/address.js +78 -0
  809. package/dist/esm/zklogin/bcs.js +21 -0
  810. package/dist/esm/zklogin/index.js +38 -0
  811. package/dist/esm/zklogin/jwt-decode.js +68 -0
  812. package/dist/esm/zklogin/jwt-utils.js +108 -0
  813. package/dist/esm/zklogin/nonce.js +40 -0
  814. package/dist/esm/zklogin/poseidon.js +61 -0
  815. package/dist/esm/zklogin/publickey.js +265 -0
  816. package/dist/esm/zklogin/signature.js +37 -0
  817. package/dist/esm/zklogin/utils.js +78 -0
  818. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  819. package/dist/tsconfig.tsbuildinfo +1 -0
  820. package/package.json +295 -61
  821. package/dist/arbitration.d.ts +0 -65
  822. package/dist/arbitration.d.ts.map +0 -1
  823. package/dist/arbitration.js +0 -517
  824. package/dist/arbitration.js.map +0 -1
  825. package/dist/demand.d.ts +0 -27
  826. package/dist/demand.d.ts.map +0 -1
  827. package/dist/demand.js +0 -266
  828. package/dist/demand.js.map +0 -1
  829. package/dist/entity.d.ts +0 -46
  830. package/dist/entity.d.ts.map +0 -1
  831. package/dist/entity.js +0 -146
  832. package/dist/entity.js.map +0 -1
  833. package/dist/exception.d.ts +0 -37
  834. package/dist/exception.d.ts.map +0 -1
  835. package/dist/exception.js +0 -41
  836. package/dist/exception.js.map +0 -1
  837. package/dist/guard.d.ts +0 -110
  838. package/dist/guard.d.ts.map +0 -1
  839. package/dist/guard.js +0 -936
  840. package/dist/guard.js.map +0 -1
  841. package/dist/index.d.ts +0 -40
  842. package/dist/index.d.ts.map +0 -1
  843. package/dist/index.js +0 -28
  844. package/dist/index.js.map +0 -1
  845. package/dist/machine.d.ts +0 -68
  846. package/dist/machine.d.ts.map +0 -1
  847. package/dist/machine.js +0 -520
  848. package/dist/machine.js.map +0 -1
  849. package/dist/passport.d.ts +0 -129
  850. package/dist/passport.d.ts.map +0 -1
  851. package/dist/passport.js +0 -1233
  852. package/dist/passport.js.map +0 -1
  853. package/dist/payment.d.ts +0 -28
  854. package/dist/payment.d.ts.map +0 -1
  855. package/dist/payment.js +0 -60
  856. package/dist/payment.js.map +0 -1
  857. package/dist/permission.d.ts +0 -155
  858. package/dist/permission.d.ts.map +0 -1
  859. package/dist/permission.js +0 -462
  860. package/dist/permission.js.map +0 -1
  861. package/dist/progress.d.ts +0 -66
  862. package/dist/progress.d.ts.map +0 -1
  863. package/dist/progress.js +0 -311
  864. package/dist/progress.js.map +0 -1
  865. package/dist/protocol.d.ts +0 -247
  866. package/dist/protocol.d.ts.map +0 -1
  867. package/dist/protocol.js +0 -726
  868. package/dist/protocol.js.map +0 -1
  869. package/dist/repository.d.ts +0 -94
  870. package/dist/repository.d.ts.map +0 -1
  871. package/dist/repository.js +0 -783
  872. package/dist/repository.js.map +0 -1
  873. package/dist/resource.d.ts +0 -36
  874. package/dist/resource.d.ts.map +0 -1
  875. package/dist/resource.js +0 -129
  876. package/dist/resource.js.map +0 -1
  877. package/dist/service.d.ts +0 -144
  878. package/dist/service.d.ts.map +0 -1
  879. package/dist/service.js +0 -1303
  880. package/dist/service.js.map +0 -1
  881. package/dist/treasury.d.ts +0 -55
  882. package/dist/treasury.d.ts.map +0 -1
  883. package/dist/treasury.js +0 -393
  884. package/dist/treasury.js.map +0 -1
  885. package/dist/utils.d.ts +0 -94
  886. package/dist/utils.d.ts.map +0 -1
  887. package/dist/utils.js +0 -582
  888. package/dist/utils.js.map +0 -1
  889. package/dist/wowok.d.ts +0 -15
  890. package/dist/wowok.d.ts.map +0 -1
  891. package/dist/wowok.js +0 -66
  892. package/dist/wowok.js.map +0 -1
@@ -0,0 +1,2472 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import {
5
+ toTxObject,
6
+ toTxString,
7
+ isValidDescription,
8
+ MAX_DESCRIPTION_LENGTH,
9
+ isValidName,
10
+ isValidLongName,
11
+ isValidU16,
12
+ isValidU64,
13
+ PackageAddress,
14
+ MAX_LONG_NAME_LENGTH,
15
+ isValidArray,
16
+ IsValidArgType,
17
+ GetObjectExisted,
18
+ GetObject,
19
+ GetObjectDescription,
20
+ serviceFn,
21
+ MAX_NAME_LENGTH,
22
+ isValidHttpUrl
23
+ } from "../common.js";
24
+ import { W_ERROR, WErrors } from "../exception.js";
25
+ import { ObjectType } from "../query/object.js";
26
+ import { owner_receive, parseObjectType, validObjects } from "../util.js";
27
+ import { allocators } from "./allocation.js";
28
+ import { CallBase, getCoinParam } from "./base.js";
29
+ import { BuiltinPermissionIndex, newPermission } from "./permission.js";
30
+ import { GetManyAccountOrMark_Address } from "../local/index.js";
31
+ import { LocalMark } from "../local/local.js";
32
+ import {
33
+ agent_set,
34
+ order_required_info_update,
35
+ owner_change
36
+ } from "./order.js";
37
+ import { create as progressCreate } from "./progress.js";
38
+ import { create as orderCreate } from "./order.js";
39
+ import { create as permissionCreate } from "./permission.js";
40
+ import { queryObjectsWithType } from "../query/util.js";
41
+ import { query_received } from "../query/received.js";
42
+ class CallService extends CallBase {
43
+ constructor(data) {
44
+ super();
45
+ __publicField(this, "data");
46
+ __publicField(this, "object_address");
47
+ __publicField(this, "permission_address");
48
+ __publicField(this, "new_permission_description");
49
+ __publicField(this, "parameter_type");
50
+ __publicField(this, "checkPublished", (op) => {
51
+ if (this.content && !this.content.bPublished) {
52
+ W_ERROR(
53
+ WErrors.Fail,
54
+ `Service object has not been published yet, so the operation (${op}) cannot proceed.`
55
+ );
56
+ }
57
+ });
58
+ __publicField(this, "checkNotPublished", (op) => {
59
+ if (this.content && this.content.bPublished) {
60
+ W_ERROR(
61
+ WErrors.Fail,
62
+ `Service object has been published and operation (${op}) cannot proceed.
63
+ If further modifications are needed, you can 'clone' a new Service and then proceed with the operation.`
64
+ );
65
+ }
66
+ });
67
+ __publicField(this, "checkNotPaused", (op) => {
68
+ if (this.content && this.content.bPaused) {
69
+ W_ERROR(
70
+ WErrors.Fail,
71
+ `Service object has been paused and operation (${op}) cannot proceed.`
72
+ );
73
+ }
74
+ });
75
+ this.data = data;
76
+ }
77
+ async prepare(env) {
78
+ await super.prepare(env);
79
+ if (!this.object_address) {
80
+ this.object_address = await GetObjectExisted(this.data?.object);
81
+ }
82
+ if (this.object_address) {
83
+ await this.update_content(
84
+ env,
85
+ ObjectType.Service,
86
+ this.object_address
87
+ );
88
+ if (!this.content)
89
+ W_ERROR(
90
+ WErrors.InvalidParam,
91
+ "CallService_Data.data.object:" + this.object_address
92
+ );
93
+ this.permission_address = this.content.permission;
94
+ this.parameter_type = parseObjectType(
95
+ this.content.type_raw,
96
+ "service::Service"
97
+ );
98
+ if (!this.permission_address) {
99
+ W_ERROR(
100
+ WErrors.InvalidParam,
101
+ "CallService_Data.data.object.permission is empty"
102
+ );
103
+ }
104
+ if (!IsValidArgType(this.parameter_type)) {
105
+ W_ERROR(
106
+ WErrors.IsValidArgType,
107
+ "CallService_Data.data.object.type_parameter is empty"
108
+ );
109
+ }
110
+ } else {
111
+ const n = GetObject(
112
+ this.data.object
113
+ );
114
+ this.permission_address = await GetObjectExisted(n?.permission);
115
+ this.new_permission_description = GetObjectDescription(
116
+ n?.permission
117
+ );
118
+ this.parameter_type = n?.type_parameter;
119
+ if (!IsValidArgType(this.parameter_type)) {
120
+ W_ERROR(
121
+ WErrors.IsValidArgType,
122
+ "CallService_Data.data.object.type_parameter invalid"
123
+ );
124
+ }
125
+ }
126
+ }
127
+ async call(env) {
128
+ await this.prepare(env);
129
+ const guards = [];
130
+ const perms = [];
131
+ const add_guard = (guard) => {
132
+ if (!guards.includes(guard)) {
133
+ guards.push(guard);
134
+ }
135
+ };
136
+ const add_perm = (index) => {
137
+ if (this.permission_address && !perms.includes(index)) {
138
+ perms.push(index);
139
+ }
140
+ };
141
+ if (this.permission_address && !this.object_address) {
142
+ add_perm(BuiltinPermissionIndex.SERVICE_NEW);
143
+ }
144
+ if (this.data?.order_new) {
145
+ if (!this.content) {
146
+ W_ERROR(
147
+ WErrors.InvalidParam,
148
+ `CallService_Data.data.order_new fail because the Service ${JSON.stringify(this.data.object)} content not ready`
149
+ );
150
+ }
151
+ this.order_allowed();
152
+ if (this.content.buy_guard != null) {
153
+ add_guard(this.content.buy_guard);
154
+ }
155
+ }
156
+ if (this.permission_address && this.data?.description != null && this.object_address) {
157
+ add_perm(BuiltinPermissionIndex.SERVICE_DESCRIPTION);
158
+ }
159
+ if (this.permission_address && this.data?.location != null) {
160
+ add_perm(BuiltinPermissionIndex.SERVICE_LOCATION);
161
+ }
162
+ if (this.permission_address && this.data?.repositories != null) {
163
+ add_perm(BuiltinPermissionIndex.SERVICE_REPOSITORY);
164
+ }
165
+ if (this.permission_address && this.data?.sales != null) {
166
+ add_perm(BuiltinPermissionIndex.SERVICE_SALES);
167
+ }
168
+ if (this.permission_address && this.data?.machine !== void 0) {
169
+ this.checkNotPublished("machine");
170
+ add_perm(BuiltinPermissionIndex.SERVICE_MACHINE);
171
+ }
172
+ if (this.permission_address && this.data?.discount != null) {
173
+ add_perm(BuiltinPermissionIndex.SERVICE_DISCOUNT);
174
+ }
175
+ if (this.permission_address && this.data?.arbitrations != null) {
176
+ this.checkNotPublished("arbitrations");
177
+ add_perm(BuiltinPermissionIndex.SERVICE_ARBITRATION);
178
+ }
179
+ if (this.permission_address && this.data?.customer_required != null) {
180
+ add_perm(BuiltinPermissionIndex.SERVICE_CUSTOMER_INFO_REQUIRED);
181
+ }
182
+ if (this.permission_address && this.data?.pause !== void 0) {
183
+ add_perm(BuiltinPermissionIndex.SERVICE_PAUSE);
184
+ }
185
+ if (this.permission_address && this.data?.publish) {
186
+ add_perm(BuiltinPermissionIndex.SERVICE_PUBLISH);
187
+ }
188
+ if (this.permission_address && this.data?.order_allocators !== void 0) {
189
+ this.checkNotPublished("order_allocators");
190
+ add_perm(BuiltinPermissionIndex.SERVICE_ORDER_ALLOCATOR);
191
+ }
192
+ if (this.permission_address && this.data?.compensation_fund_add != null) {
193
+ add_perm(BuiltinPermissionIndex.SERVICE_COMPENSATION_FUND_DEPOSIT);
194
+ }
195
+ if (this.permission_address && this.data?.compensation_locked_time_add !== void 0) {
196
+ add_perm(
197
+ BuiltinPermissionIndex.SERVICE_COMPENSATION_LOCKED_TIME_ADD
198
+ );
199
+ }
200
+ if (this.permission_address && this.data?.rewards != null) {
201
+ add_perm(BuiltinPermissionIndex.SERVICE_REWARD);
202
+ }
203
+ if (this.permission_address && this.data?.compensation_fund_receive != null) {
204
+ add_perm(BuiltinPermissionIndex.SERVICE_COMPENSATION_FUND_RECEIVE);
205
+ }
206
+ if (this.permission_address && this.data?.owner_receive != null) {
207
+ add_perm(BuiltinPermissionIndex.SERVICE_OWNER_RECEIVE);
208
+ }
209
+ if (this.permission_address && this.data?.um !== void 0) {
210
+ add_perm(BuiltinPermissionIndex.SERVICE_UM);
211
+ }
212
+ if (this.permission_address || guards.length > 0) {
213
+ return await this.check_permission_and_call(
214
+ env,
215
+ this.permission_address,
216
+ perms,
217
+ guards
218
+ );
219
+ }
220
+ return await this.exec(env);
221
+ }
222
+ async operate(env, tx, passport, submission) {
223
+ let permission = this.permission_address;
224
+ let object = this.object_address;
225
+ if (!this.object_address) {
226
+ if (!permission) {
227
+ permission = newPermission(
228
+ tx,
229
+ this.new_permission_description ?? ""
230
+ );
231
+ }
232
+ if (permission && this.parameter_type) {
233
+ object = newService(
234
+ tx,
235
+ this.parameter_type,
236
+ permission,
237
+ this.data?.description ?? "",
238
+ passport
239
+ );
240
+ }
241
+ }
242
+ if (!object || !permission) {
243
+ W_ERROR(
244
+ WErrors.InvalidParam,
245
+ "CallService_Data.data.object:" + this.object_address
246
+ );
247
+ }
248
+ let buyResult;
249
+ if (this.data?.order_new != null && this.content) {
250
+ this.order_allowed();
251
+ const n = this.data?.order_new;
252
+ n.buy.discount = await LocalMark.Instance().get_address(
253
+ this.data.order_new.buy.discount
254
+ );
255
+ buyResult = await buy(
256
+ env,
257
+ tx,
258
+ object,
259
+ this.parameter_type,
260
+ this.content.machine,
261
+ n.buy,
262
+ passport
263
+ );
264
+ if (!buyResult) {
265
+ W_ERROR(WErrors.Fail, "Buy failed, no order created");
266
+ }
267
+ if (n?.agents != null) {
268
+ agent_set(tx, {
269
+ order: buyResult.order,
270
+ agents: await GetManyAccountOrMark_Address(n.agents)
271
+ });
272
+ }
273
+ if (n?.order_required_info !== void 0) {
274
+ await order_required_info_update(
275
+ tx,
276
+ buyResult.order,
277
+ n.order_required_info
278
+ );
279
+ }
280
+ if (n?.transfer != null) {
281
+ await owner_change(tx, {
282
+ order: buyResult.order,
283
+ new_owner: n.transfer
284
+ });
285
+ }
286
+ if (n?.namedNewAllocation != null && buyResult?.allocation) {
287
+ await this.new_with_mark(
288
+ env,
289
+ tx,
290
+ ObjectType.Allocation,
291
+ buyResult?.allocation,
292
+ GetObject(n.namedNewAllocation)
293
+ );
294
+ }
295
+ if (buyResult?.progress) {
296
+ if (n?.namedNewProgress != null) {
297
+ await this.new_with_mark(
298
+ env,
299
+ tx,
300
+ ObjectType.Progress,
301
+ progressCreate(tx, buyResult?.progress),
302
+ GetObject(n.namedNewProgress)
303
+ );
304
+ } else {
305
+ progressCreate(tx, buyResult?.progress);
306
+ }
307
+ }
308
+ if (buyResult?.order) {
309
+ const addr = orderCreate(tx, buyResult?.order);
310
+ if (n?.namedNewOrder != null) {
311
+ await this.new_with_mark(
312
+ env,
313
+ tx,
314
+ ObjectType.Order,
315
+ addr,
316
+ GetObject(n.namedNewOrder)
317
+ );
318
+ }
319
+ }
320
+ }
321
+ if (this.data.description != null && !this.object_address) {
322
+ description_set(
323
+ tx,
324
+ object,
325
+ this.parameter_type,
326
+ permission,
327
+ this.data.description,
328
+ passport
329
+ );
330
+ }
331
+ if (this.data.location != null) {
332
+ location_set(
333
+ tx,
334
+ object,
335
+ this.parameter_type,
336
+ permission,
337
+ this.data.location,
338
+ passport
339
+ );
340
+ }
341
+ if (this.data.sales != null) {
342
+ switch (this.data.sales.op) {
343
+ case "add": {
344
+ sales_add(
345
+ tx,
346
+ object,
347
+ this.parameter_type,
348
+ permission,
349
+ this.data.sales.sales,
350
+ passport
351
+ );
352
+ break;
353
+ }
354
+ case "set": {
355
+ sales_set(
356
+ tx,
357
+ object,
358
+ this.parameter_type,
359
+ permission,
360
+ this.data.sales.sales,
361
+ passport
362
+ );
363
+ break;
364
+ }
365
+ case "remove": {
366
+ sales_remove(
367
+ tx,
368
+ object,
369
+ this.parameter_type,
370
+ permission,
371
+ this.data.sales.sales_name,
372
+ passport
373
+ );
374
+ break;
375
+ }
376
+ case "clear": {
377
+ sales_clear(
378
+ tx,
379
+ object,
380
+ this.parameter_type,
381
+ permission,
382
+ passport
383
+ );
384
+ break;
385
+ }
386
+ }
387
+ }
388
+ if (this.data.repositories != null) {
389
+ switch (this.data.repositories.op) {
390
+ case "add":
391
+ case "set": {
392
+ if (this.data.repositories.objects.length > MAX_REPOSITORY_COUNT) {
393
+ W_ERROR(
394
+ WErrors.InvalidParam,
395
+ "CallService_Data.data.repositories.objects:" + this.data.repositories.objects
396
+ );
397
+ }
398
+ if (this.data.repositories.op === "set") {
399
+ repository_clear(
400
+ tx,
401
+ object,
402
+ this.parameter_type,
403
+ permission,
404
+ passport
405
+ );
406
+ }
407
+ const r = await LocalMark.Instance().get_many_address_availables(
408
+ this.data.repositories.objects
409
+ );
410
+ r.forEach((repo) => {
411
+ repository_add(
412
+ tx,
413
+ object,
414
+ this.parameter_type,
415
+ permission,
416
+ repo,
417
+ passport
418
+ );
419
+ });
420
+ break;
421
+ }
422
+ case "remove": {
423
+ if (this.data.repositories.objects.length > MAX_REPOSITORY_COUNT) {
424
+ W_ERROR(
425
+ WErrors.InvalidParam,
426
+ "CallService_Data.data.repositories.objects:" + this.data.repositories.objects
427
+ );
428
+ }
429
+ const addrs = await LocalMark.Instance().get_many_address_availables(
430
+ this.data.repositories.objects
431
+ );
432
+ repository_remove(
433
+ tx,
434
+ object,
435
+ this.parameter_type,
436
+ permission,
437
+ addrs,
438
+ passport
439
+ );
440
+ break;
441
+ }
442
+ case "clear": {
443
+ repository_clear(
444
+ tx,
445
+ object,
446
+ this.parameter_type,
447
+ permission,
448
+ passport
449
+ );
450
+ break;
451
+ }
452
+ }
453
+ }
454
+ if (this.data.rewards != null) {
455
+ switch (this.data.rewards.op) {
456
+ case "add":
457
+ case "set": {
458
+ if (this.data.rewards.objects.length > MAX_REWARD_COUNT) {
459
+ W_ERROR(
460
+ WErrors.InvalidParam,
461
+ `rewards count exceeds maximum limit ${MAX_REWARD_COUNT}`
462
+ );
463
+ }
464
+ if (this.data.rewards.op === "set") {
465
+ reward_clear(
466
+ tx,
467
+ object,
468
+ this.parameter_type,
469
+ permission,
470
+ passport
471
+ );
472
+ }
473
+ const rewards = await queryObjectsWithType(
474
+ env,
475
+ this.data.rewards.objects,
476
+ ObjectType.Reward,
477
+ "reward::Reward",
478
+ false
479
+ );
480
+ rewards.forEach((reward) => {
481
+ reward_add(
482
+ tx,
483
+ object,
484
+ this.parameter_type,
485
+ permission,
486
+ reward.object,
487
+ reward.type,
488
+ passport
489
+ );
490
+ });
491
+ break;
492
+ }
493
+ case "remove": {
494
+ if (this.data.rewards.objects.length > MAX_REWARD_COUNT) {
495
+ W_ERROR(
496
+ WErrors.InvalidParam,
497
+ `rewards count exceeds maximum limit ${MAX_REWARD_COUNT}`
498
+ );
499
+ }
500
+ const addrs = await LocalMark.Instance().get_many_address_availables(
501
+ this.data.rewards.objects
502
+ );
503
+ reward_remove(
504
+ tx,
505
+ object,
506
+ this.parameter_type,
507
+ permission,
508
+ addrs,
509
+ passport
510
+ );
511
+ break;
512
+ }
513
+ case "clear": {
514
+ reward_clear(
515
+ tx,
516
+ object,
517
+ this.parameter_type,
518
+ permission,
519
+ passport
520
+ );
521
+ break;
522
+ }
523
+ }
524
+ }
525
+ if (this.data.arbitrations != null) {
526
+ switch (this.data.arbitrations.op) {
527
+ case "add":
528
+ case "set": {
529
+ if (this.data.arbitrations.objects.length > MAX_ARBITRATION_COUNT) {
530
+ W_ERROR(
531
+ WErrors.InvalidParam,
532
+ `arbitrations count exceeds maximum limit ${MAX_ARBITRATION_COUNT}`
533
+ );
534
+ }
535
+ if (this.data.arbitrations.op === "set") {
536
+ arbitration_clear(
537
+ tx,
538
+ object,
539
+ this.parameter_type,
540
+ permission,
541
+ passport
542
+ );
543
+ }
544
+ const arbitrations = await queryObjectsWithType(
545
+ env,
546
+ this.data.arbitrations.objects,
547
+ ObjectType.Arbitration,
548
+ "arbitration::Arbitration",
549
+ false
550
+ );
551
+ arbitrations.forEach((arbitration) => {
552
+ arbitrations_add(
553
+ tx,
554
+ object,
555
+ this.parameter_type,
556
+ permission,
557
+ arbitration.object,
558
+ arbitration.type,
559
+ passport
560
+ );
561
+ });
562
+ break;
563
+ }
564
+ case "remove": {
565
+ if (this.data.arbitrations.objects.length > MAX_ARBITRATION_COUNT) {
566
+ W_ERROR(
567
+ WErrors.InvalidParam,
568
+ `arbitrations count exceeds maximum limit ${MAX_ARBITRATION_COUNT}`
569
+ );
570
+ }
571
+ const addrs = await LocalMark.Instance().get_many_address_availables(
572
+ this.data.arbitrations.objects
573
+ );
574
+ arbitrations_remove(
575
+ tx,
576
+ object,
577
+ this.parameter_type,
578
+ permission,
579
+ addrs,
580
+ passport
581
+ );
582
+ break;
583
+ }
584
+ case "clear": {
585
+ arbitration_clear(
586
+ tx,
587
+ object,
588
+ this.parameter_type,
589
+ permission,
590
+ passport
591
+ );
592
+ break;
593
+ }
594
+ }
595
+ }
596
+ if (this.data.discount != null) {
597
+ await discount(
598
+ tx,
599
+ object,
600
+ this.parameter_type,
601
+ permission,
602
+ this.data.discount,
603
+ passport
604
+ );
605
+ }
606
+ if (this.data.discount_destroy != null) {
607
+ const r = await LocalMark.Instance().get_many_address_availables(
608
+ this.data.discount_destroy
609
+ );
610
+ discount_destroy(tx, r);
611
+ }
612
+ if (this.data.machine !== void 0) {
613
+ if (this.data.machine) {
614
+ const m = await LocalMark.Instance().get_address(
615
+ this.data.machine
616
+ );
617
+ if (m) {
618
+ this.data.machine = m;
619
+ } else {
620
+ W_ERROR(
621
+ WErrors.IsValidArgType,
622
+ `Machine not found ${this.data.machine}`
623
+ );
624
+ }
625
+ }
626
+ machine_set(
627
+ tx,
628
+ object,
629
+ this.parameter_type,
630
+ permission,
631
+ this.data.machine,
632
+ passport
633
+ );
634
+ }
635
+ if (this.data.customer_required != null) {
636
+ customer_required_set(
637
+ tx,
638
+ object,
639
+ this.parameter_type,
640
+ permission,
641
+ this.data.customer_required,
642
+ passport
643
+ );
644
+ }
645
+ if (this.data.order_allocators !== void 0) {
646
+ order_allocators_set(
647
+ tx,
648
+ object,
649
+ this.parameter_type,
650
+ permission,
651
+ this.data.order_allocators ? await allocators(tx, this.data.order_allocators) : null,
652
+ passport
653
+ );
654
+ }
655
+ if (this.data.compensation_fund_add != null) {
656
+ compensation_fund_add(
657
+ env,
658
+ tx,
659
+ object,
660
+ this.parameter_type,
661
+ permission,
662
+ this.data.compensation_fund_add,
663
+ passport
664
+ );
665
+ }
666
+ if (this.data.compensation_locked_time_add !== void 0) {
667
+ compensation_lock_duration_set(
668
+ tx,
669
+ object,
670
+ this.parameter_type,
671
+ permission,
672
+ this.data.compensation_locked_time_add,
673
+ passport
674
+ );
675
+ }
676
+ if (this.data.compensation_fund_receive != null && this.object_address) {
677
+ if (this.data.compensation_fund_receive === "recently") {
678
+ const received = await query_received({
679
+ object: this.object_address,
680
+ network: env.network,
681
+ no_cache: env.no_cache
682
+ });
683
+ if (Array.isArray(received)) {
684
+ W_ERROR(
685
+ WErrors.InvalidParam,
686
+ "CallAllocation_Data.data.received_coins: received is ReceivedNormal[]"
687
+ );
688
+ } else {
689
+ this.data.compensation_fund_receive = received;
690
+ }
691
+ }
692
+ if (typeof this.data.compensation_fund_receive === "object" && "received" in this.data.compensation_fund_receive && this.data.compensation_fund_receive.received?.length > 0) {
693
+ if (this.data.compensation_fund_receive.token_type !== this.parameter_type) {
694
+ W_ERROR(
695
+ WErrors.InvalidParam,
696
+ `token_type ${this.data.compensation_fund_receive.token_type} is not equal to parameter_type ${this.parameter_type}`
697
+ );
698
+ }
699
+ for (const item of this.data.compensation_fund_receive.received) {
700
+ const [received_object, payment_object] = await Promise.all(
701
+ [
702
+ LocalMark.Instance().get_address(item.id),
703
+ LocalMark.Instance().get_address(item.payment)
704
+ ]
705
+ );
706
+ if (!received_object || !payment_object) {
707
+ W_ERROR(
708
+ WErrors.IsValidArgType,
709
+ `Compensation fund receive object ${item.id} or payment object ${item.payment} not found`
710
+ );
711
+ }
712
+ compensation_fund_receive(
713
+ tx,
714
+ object,
715
+ this.parameter_type,
716
+ permission,
717
+ item.id,
718
+ item.payment,
719
+ passport
720
+ );
721
+ }
722
+ }
723
+ }
724
+ if (this.data.owner_receive != null && this.object_address) {
725
+ if (this.data.owner_receive === "recently") {
726
+ this.data.owner_receive = await query_received({
727
+ object: this.object_address,
728
+ all_type: true,
729
+ network: env.network,
730
+ no_cache: env.no_cache
731
+ });
732
+ }
733
+ await owner_receive(
734
+ tx,
735
+ object,
736
+ permission,
737
+ this.data.owner_receive,
738
+ this.parameter_type,
739
+ (name) => `${PackageAddress}::service::${name}`,
740
+ passport
741
+ );
742
+ }
743
+ if (this.data.um !== void 0) {
744
+ let um_address = null;
745
+ if (this.data.um) {
746
+ um_address = await LocalMark.Instance().get_address(this.data.um) || null;
747
+ if (!um_address) {
748
+ W_ERROR(
749
+ WErrors.InvalidParam,
750
+ "CallService_Data.data.um:" + this.data.um
751
+ );
752
+ }
753
+ }
754
+ um_set(
755
+ tx,
756
+ object,
757
+ this.parameter_type,
758
+ permission,
759
+ um_address,
760
+ passport
761
+ );
762
+ }
763
+ if (this.data.pause != null) {
764
+ pause(
765
+ tx,
766
+ object,
767
+ this.parameter_type,
768
+ permission,
769
+ this.data.pause,
770
+ passport
771
+ );
772
+ }
773
+ if (this.data.publish) {
774
+ publish(tx, object, this.parameter_type, permission, passport);
775
+ }
776
+ if (!this.permission_address) {
777
+ const p = GetObject(
778
+ this.data?.object
779
+ );
780
+ await this.new_with_mark(
781
+ env,
782
+ tx,
783
+ ObjectType.Permission,
784
+ permissionCreate(tx, permission),
785
+ GetObject(p.permission)
786
+ );
787
+ }
788
+ if (!this.object_address) {
789
+ await this.new_with_mark(
790
+ env,
791
+ tx,
792
+ ObjectType.Service,
793
+ create(tx, object, this.parameter_type),
794
+ GetObject(this.data?.object)
795
+ );
796
+ }
797
+ }
798
+ order_allowed() {
799
+ if (this.content?.bPaused) {
800
+ W_ERROR(WErrors.InvalidParam, "Service is paused");
801
+ return false;
802
+ }
803
+ if (this.content?.bPublished !== true) {
804
+ W_ERROR(WErrors.InvalidParam, "Service is not published");
805
+ return false;
806
+ }
807
+ return true;
808
+ }
809
+ }
810
+ const MAX_SALE_COUNT = 50;
811
+ const MAX_REPOSITORY_COUNT = 100;
812
+ const MAX_ARBITRATION_COUNT = 20;
813
+ const MAX_REWARD_COUNT = 20;
814
+ const MAX_CUSTOMER_REQUIRED_INFO_COUNT = 10;
815
+ const MAX_PUBKEY_LENGTH = 1024;
816
+ const MAX_DISCOUNT_COUNT_ONCE = 1e3;
817
+ const MAX_DISCOUNT_RECEIVER_ONCE = 1e3;
818
+ const MAX_DISCOUNT_TOTAL_COUNT = 2e4;
819
+ const MAX_REQUIRED_INFO_SIZE = 20;
820
+ const DEFAULT_COMPENSATION_LOCK_DURATION = 2592e6;
821
+ const DISCOUNT_TYPE_RATES = 0;
822
+ const DISCOUNT_TYPE_MINUS = 1;
823
+ const MAX_WIP_LENGTH = 1024;
824
+ const MAX_WIP_HASH_LENGTH = 64;
825
+ function sale(tx, sale2) {
826
+ if (typeof sale2.name === "string" && !isValidLongName(sale2.name)) {
827
+ W_ERROR(
828
+ WErrors.InvalidParam,
829
+ `Name ${sale2.name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`
830
+ );
831
+ }
832
+ if (sale2.wip.length > MAX_WIP_LENGTH) {
833
+ W_ERROR(
834
+ WErrors.InvalidParam,
835
+ `WIP ${sale2.wip} exceeds maximum length ${MAX_WIP_LENGTH}`
836
+ );
837
+ }
838
+ if (!isValidHttpUrl(sale2.wip)) {
839
+ W_ERROR(
840
+ WErrors.IsValidHttpUrl,
841
+ `WIP ${sale2.wip} is not a valid HTTP/HTTPS URL`
842
+ );
843
+ }
844
+ if (sale2.wip_hash.length > MAX_WIP_HASH_LENGTH) {
845
+ W_ERROR(
846
+ WErrors.InvalidParam,
847
+ `WIP hash ${sale2.wip_hash} exceeds maximum length ${MAX_WIP_HASH_LENGTH}`
848
+ );
849
+ }
850
+ return tx.moveCall({
851
+ target: serviceFn("sale"),
852
+ arguments: [
853
+ toTxString(tx, sale2.name),
854
+ tx.pure.u64(sale2.price),
855
+ tx.pure.u64(sale2.stock),
856
+ tx.pure.bool(sale2.suspension),
857
+ toTxString(tx, sale2.wip),
858
+ toTxString(tx, sale2.wip_hash)
859
+ ]
860
+ });
861
+ }
862
+ function quote_item(tx, item) {
863
+ if (!isValidLongName(item.name)) {
864
+ W_ERROR(
865
+ WErrors.InvalidParam,
866
+ `Quote item name ${item.name} is not valid`
867
+ );
868
+ }
869
+ if (!isValidU64(item.stock)) {
870
+ W_ERROR(
871
+ WErrors.IsValidU64,
872
+ `Quote item stock ${item.stock} is not valid`
873
+ );
874
+ }
875
+ if (item.wip_hash.length > MAX_WIP_HASH_LENGTH) {
876
+ W_ERROR(
877
+ WErrors.InvalidParam,
878
+ `Quote item wip_hash ${item.wip_hash} exceeds maximum length ${MAX_WIP_HASH_LENGTH}`
879
+ );
880
+ }
881
+ return tx.moveCall({
882
+ target: serviceFn("quote_item"),
883
+ arguments: [
884
+ toTxString(tx, item.name),
885
+ tx.pure.u64(item.stock),
886
+ toTxString(tx, item.wip_hash)
887
+ ]
888
+ });
889
+ }
890
+ function discount_send(tx, discount2, recipient) {
891
+ if (discount2.length === 0) {
892
+ return;
893
+ }
894
+ validObjects([...discount2, recipient]);
895
+ if (discount2.length > MAX_DISCOUNT_COUNT_ONCE) {
896
+ W_ERROR(
897
+ WErrors.InvalidParam,
898
+ `Discount count ${discount2.length} exceeds maximum limit ${MAX_DISCOUNT_COUNT_ONCE}`
899
+ );
900
+ }
901
+ if (discount2.length === 1) {
902
+ tx.moveCall({
903
+ target: serviceFn("discount_send_singleton"),
904
+ arguments: [
905
+ toTxObject(tx, discount2[0]),
906
+ tx.pure.address(recipient)
907
+ ]
908
+ });
909
+ return;
910
+ } else {
911
+ tx.moveCall({
912
+ target: serviceFn("discount_send"),
913
+ arguments: [
914
+ tx.makeMoveVec({
915
+ elements: discount2,
916
+ type: `${PackageAddress}::service::Discount`
917
+ }),
918
+ tx.pure.address(recipient)
919
+ ]
920
+ });
921
+ }
922
+ }
923
+ function discount_destroy(tx, discount2) {
924
+ validObjects([...discount2]);
925
+ discount2.forEach((item) => {
926
+ tx.moveCall({
927
+ target: serviceFn("discount_destroy"),
928
+ arguments: [toTxObject(tx, item)]
929
+ });
930
+ });
931
+ }
932
+ const buy = async (env, tx, service, service_type, machine, buy2, passport) => {
933
+ if (buy2.items.length === 0) {
934
+ return void 0;
935
+ }
936
+ validObjects([service, buy2.discount, machine, passport]);
937
+ if (!IsValidArgType(service_type)) {
938
+ W_ERROR(
939
+ WErrors.InvalidParam,
940
+ `Buy service type ${service_type} is not valid`
941
+ );
942
+ }
943
+ if (!isValidArray(buy2.items, (item) => {
944
+ if (!isValidLongName(item.name)) {
945
+ W_ERROR(
946
+ WErrors.InvalidParam,
947
+ `Buy item name ${item.name} is not valid`
948
+ );
949
+ }
950
+ if (!isValidU64(item.stock)) {
951
+ W_ERROR(
952
+ WErrors.IsValidU64,
953
+ `Buy item stock ${item.stock} is not valid`
954
+ );
955
+ }
956
+ return true;
957
+ })) {
958
+ W_ERROR(WErrors.InvalidParam, "Buy items is not valid");
959
+ }
960
+ if (typeof buy2.payment_remark === "string" && !isValidName(buy2.payment_remark)) {
961
+ W_ERROR(
962
+ WErrors.InvalidParam,
963
+ `Buy payment remark ${buy2.payment_remark} is not valid`
964
+ );
965
+ }
966
+ buy2.payment_remark = buy2.payment_remark || "";
967
+ if (buy2.payment_index != null && !isValidU64(buy2.payment_index)) {
968
+ W_ERROR(
969
+ WErrors.IsValidU64,
970
+ `Buy payment index ${buy2.payment_index} is not valid`
971
+ );
972
+ }
973
+ const coinParam = await getCoinParam(env, tx, buy2.total_pay, service_type);
974
+ buy2.discount = await LocalMark.Instance().get_address(buy2.discount);
975
+ let quote = void 0;
976
+ if (buy2.discount) {
977
+ quote = tx.moveCall({
978
+ target: serviceFn("quote_with_discount"),
979
+ arguments: [
980
+ toTxObject(tx, service),
981
+ tx.makeMoveVec({
982
+ elements: buy2.items.map((item) => quote_item(tx, item)),
983
+ type: `${PackageAddress}::service::QuoteItem`
984
+ }),
985
+ toTxObject(tx, buy2.discount)
986
+ ],
987
+ typeArguments: [service_type]
988
+ });
989
+ } else {
990
+ quote = tx.moveCall({
991
+ target: serviceFn("quote"),
992
+ arguments: [
993
+ toTxObject(tx, service),
994
+ tx.makeMoveVec({
995
+ elements: buy2.items.map((item) => quote_item(tx, item)),
996
+ type: `${PackageAddress}::service::QuoteItem`
997
+ })
998
+ ],
999
+ typeArguments: [service_type]
1000
+ });
1001
+ }
1002
+ let order;
1003
+ if (passport) {
1004
+ order = tx.moveCall({
1005
+ target: serviceFn("buy_with_passport"),
1006
+ arguments: [
1007
+ toTxObject(tx, service),
1008
+ toTxObject(tx, passport),
1009
+ quote,
1010
+ tx.object.mutRegistrar(),
1011
+ tx.object.clock()
1012
+ ],
1013
+ typeArguments: [service_type]
1014
+ });
1015
+ } else {
1016
+ order = tx.moveCall({
1017
+ target: serviceFn("buy"),
1018
+ arguments: [
1019
+ toTxObject(tx, service),
1020
+ quote,
1021
+ tx.object.mutRegistrar(),
1022
+ tx.object.clock()
1023
+ ],
1024
+ typeArguments: [service_type]
1025
+ });
1026
+ }
1027
+ const result = {
1028
+ order
1029
+ };
1030
+ result.allocation = tx.moveCall({
1031
+ target: serviceFn("order_allocation"),
1032
+ arguments: [
1033
+ toTxObject(tx, service),
1034
+ toTxObject(tx, order),
1035
+ coinParam,
1036
+ tx.pure.string(buy2.payment_remark ?? ""),
1037
+ tx.pure.u64(buy2.payment_index || 0),
1038
+ tx.object.mutRegistrar(),
1039
+ tx.object.clock()
1040
+ ],
1041
+ typeArguments: [service_type]
1042
+ });
1043
+ if (machine) {
1044
+ result.progress = tx.moveCall({
1045
+ target: serviceFn("order_progress"),
1046
+ arguments: [
1047
+ toTxObject(tx, service),
1048
+ toTxObject(tx, order),
1049
+ toTxObject(tx, machine),
1050
+ tx.object.mutRegistrar(),
1051
+ tx.object.clock()
1052
+ ],
1053
+ typeArguments: [service_type]
1054
+ });
1055
+ }
1056
+ return result;
1057
+ };
1058
+ function newService(tx, service_type, permission, description, passport) {
1059
+ validObjects([permission, passport]);
1060
+ if (typeof description === "string" && !isValidDescription(description)) {
1061
+ W_ERROR(
1062
+ WErrors.IsValidDescription,
1063
+ `Description exceeds maximum length ${MAX_DESCRIPTION_LENGTH}`
1064
+ );
1065
+ }
1066
+ if (!IsValidArgType(service_type)) {
1067
+ W_ERROR(
1068
+ WErrors.InvalidParam,
1069
+ `New service type ${service_type} is not valid`
1070
+ );
1071
+ }
1072
+ if (passport) {
1073
+ return tx.moveCall({
1074
+ target: serviceFn("new_with_passport"),
1075
+ arguments: [
1076
+ toTxObject(tx, permission),
1077
+ toTxObject(tx, passport),
1078
+ toTxString(tx, description),
1079
+ tx.object.mutRegistrar(),
1080
+ tx.object.clock()
1081
+ ],
1082
+ typeArguments: [service_type]
1083
+ });
1084
+ } else {
1085
+ return tx.moveCall({
1086
+ target: serviceFn("new"),
1087
+ arguments: [
1088
+ toTxObject(tx, permission),
1089
+ toTxString(tx, description),
1090
+ tx.object.mutRegistrar(),
1091
+ tx.object.clock()
1092
+ ],
1093
+ typeArguments: [service_type]
1094
+ });
1095
+ }
1096
+ }
1097
+ function description_set(tx, service, service_type, permission, description, passport) {
1098
+ validObjects([service, permission, passport]);
1099
+ if (typeof description === "string" && !isValidDescription(description)) {
1100
+ W_ERROR(
1101
+ WErrors.IsValidDescription,
1102
+ `Description exceeds maximum length ${MAX_DESCRIPTION_LENGTH}`
1103
+ );
1104
+ }
1105
+ if (!IsValidArgType(service_type)) {
1106
+ W_ERROR(
1107
+ WErrors.InvalidParam,
1108
+ `Description set service type ${service_type} is not valid`
1109
+ );
1110
+ }
1111
+ if (passport) {
1112
+ tx.moveCall({
1113
+ target: serviceFn("description_set_with_passport"),
1114
+ arguments: [
1115
+ toTxObject(tx, service),
1116
+ toTxObject(tx, permission),
1117
+ toTxObject(tx, passport),
1118
+ toTxString(tx, description)
1119
+ ],
1120
+ typeArguments: [service_type]
1121
+ });
1122
+ } else {
1123
+ tx.moveCall({
1124
+ target: serviceFn("description_set"),
1125
+ arguments: [
1126
+ toTxObject(tx, service),
1127
+ toTxObject(tx, permission),
1128
+ toTxString(tx, description)
1129
+ ],
1130
+ typeArguments: [service_type]
1131
+ });
1132
+ }
1133
+ }
1134
+ function um_set(tx, service, service_type, permission, um, passport) {
1135
+ validObjects([service, permission]);
1136
+ if (!IsValidArgType(service_type)) {
1137
+ W_ERROR(
1138
+ WErrors.InvalidParam,
1139
+ `Service type ${service_type} is not valid`
1140
+ );
1141
+ }
1142
+ if (um) {
1143
+ if (passport) {
1144
+ tx.moveCall({
1145
+ target: serviceFn(`um_set_with_passport`),
1146
+ arguments: [
1147
+ toTxObject(tx, service),
1148
+ toTxObject(tx, permission),
1149
+ passport,
1150
+ toTxObject(tx, um),
1151
+ tx.object.mutRegistrar(),
1152
+ tx.object.clock()
1153
+ ],
1154
+ typeArguments: [service_type]
1155
+ });
1156
+ } else {
1157
+ tx.moveCall({
1158
+ target: serviceFn(`um_set`),
1159
+ arguments: [
1160
+ toTxObject(tx, service),
1161
+ toTxObject(tx, permission),
1162
+ toTxObject(tx, um),
1163
+ tx.object.mutRegistrar(),
1164
+ tx.object.clock()
1165
+ ],
1166
+ typeArguments: [service_type]
1167
+ });
1168
+ }
1169
+ } else {
1170
+ if (passport) {
1171
+ tx.moveCall({
1172
+ target: serviceFn(`um_none_with_passport`),
1173
+ arguments: [
1174
+ toTxObject(tx, service),
1175
+ toTxObject(tx, permission),
1176
+ passport,
1177
+ tx.object.mutRegistrar()
1178
+ ],
1179
+ typeArguments: [service_type]
1180
+ });
1181
+ } else {
1182
+ tx.moveCall({
1183
+ target: serviceFn(`um_none`),
1184
+ arguments: [
1185
+ toTxObject(tx, service),
1186
+ toTxObject(tx, permission),
1187
+ tx.object.mutRegistrar()
1188
+ ],
1189
+ typeArguments: [service_type]
1190
+ });
1191
+ }
1192
+ }
1193
+ }
1194
+ function location_set(tx, service, service_type, permission, location, passport) {
1195
+ validObjects([service, permission, passport]);
1196
+ if (typeof location === "string" && !isValidLongName(location)) {
1197
+ W_ERROR(
1198
+ WErrors.InvalidParam,
1199
+ `Location ${location} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`
1200
+ );
1201
+ }
1202
+ if (!IsValidArgType(service_type)) {
1203
+ W_ERROR(
1204
+ WErrors.InvalidParam,
1205
+ `Location set service type ${service_type} is not valid`
1206
+ );
1207
+ }
1208
+ if (passport) {
1209
+ tx.moveCall({
1210
+ target: serviceFn("location_set_with_passport"),
1211
+ arguments: [
1212
+ toTxObject(tx, service),
1213
+ toTxObject(tx, permission),
1214
+ toTxObject(tx, passport),
1215
+ toTxString(tx, location)
1216
+ ],
1217
+ typeArguments: [service_type]
1218
+ });
1219
+ } else {
1220
+ tx.moveCall({
1221
+ target: serviceFn("location_set"),
1222
+ arguments: [
1223
+ toTxObject(tx, service),
1224
+ toTxObject(tx, permission),
1225
+ toTxString(tx, location)
1226
+ ],
1227
+ typeArguments: [service_type]
1228
+ });
1229
+ }
1230
+ }
1231
+ function create(tx, service, service_type) {
1232
+ validObjects([service]);
1233
+ if (!IsValidArgType(service_type)) {
1234
+ W_ERROR(
1235
+ WErrors.InvalidParam,
1236
+ `Create service type ${service_type} is not valid`
1237
+ );
1238
+ }
1239
+ return tx.moveCall({
1240
+ target: serviceFn("create"),
1241
+ arguments: [toTxObject(tx, service)],
1242
+ typeArguments: [service_type]
1243
+ });
1244
+ }
1245
+ function sales_add(tx, service, service_type, permission, sales, passport) {
1246
+ if (sales.length === 0) {
1247
+ return;
1248
+ }
1249
+ validObjects([service, permission, passport]);
1250
+ if (!IsValidArgType(service_type)) {
1251
+ W_ERROR(
1252
+ WErrors.InvalidParam,
1253
+ `Sales add service type ${service_type} is not valid`
1254
+ );
1255
+ }
1256
+ if (passport) {
1257
+ tx.moveCall({
1258
+ target: serviceFn("sales_add_with_passport"),
1259
+ arguments: [
1260
+ toTxObject(tx, service),
1261
+ toTxObject(tx, permission),
1262
+ toTxObject(tx, passport),
1263
+ tx.makeMoveVec({
1264
+ elements: sales.map((s) => sale(tx, s)),
1265
+ type: `${PackageAddress}::service::Sale`
1266
+ })
1267
+ ],
1268
+ typeArguments: [service_type]
1269
+ });
1270
+ } else {
1271
+ tx.moveCall({
1272
+ target: serviceFn("sales_add"),
1273
+ arguments: [
1274
+ toTxObject(tx, service),
1275
+ toTxObject(tx, permission),
1276
+ tx.makeMoveVec({
1277
+ elements: sales.map((s) => sale(tx, s)),
1278
+ type: `${PackageAddress}::service::Sale`
1279
+ })
1280
+ ],
1281
+ typeArguments: [service_type]
1282
+ });
1283
+ }
1284
+ }
1285
+ function sales_remove(tx, service, service_type, permission, sales_name, passport) {
1286
+ if (sales_name.length === 0) {
1287
+ return;
1288
+ }
1289
+ validObjects([service, permission, passport]);
1290
+ if (!IsValidArgType(service_type)) {
1291
+ W_ERROR(
1292
+ WErrors.InvalidParam,
1293
+ `Sales remove service type ${service_type} is not valid`
1294
+ );
1295
+ }
1296
+ if (passport) {
1297
+ tx.moveCall({
1298
+ target: serviceFn("sales_remove_with_passport"),
1299
+ arguments: [
1300
+ toTxObject(tx, service),
1301
+ toTxObject(tx, permission),
1302
+ toTxObject(tx, passport),
1303
+ tx.pure.vector("string", sales_name)
1304
+ ],
1305
+ typeArguments: [service_type]
1306
+ });
1307
+ } else {
1308
+ tx.moveCall({
1309
+ target: serviceFn("sales_remove"),
1310
+ arguments: [
1311
+ toTxObject(tx, service),
1312
+ toTxObject(tx, permission),
1313
+ tx.pure.vector("string", sales_name)
1314
+ ],
1315
+ typeArguments: [service_type]
1316
+ });
1317
+ }
1318
+ }
1319
+ function sales_clear(tx, service, service_type, permission, passport) {
1320
+ validObjects([service, permission, passport]);
1321
+ if (!IsValidArgType(service_type)) {
1322
+ W_ERROR(
1323
+ WErrors.InvalidParam,
1324
+ `Sales clear service type ${service_type} is not valid`
1325
+ );
1326
+ }
1327
+ if (passport) {
1328
+ tx.moveCall({
1329
+ target: serviceFn("sales_clear_with_passport"),
1330
+ arguments: [
1331
+ toTxObject(tx, service),
1332
+ toTxObject(tx, permission),
1333
+ toTxObject(tx, passport)
1334
+ ],
1335
+ typeArguments: [service_type]
1336
+ });
1337
+ } else {
1338
+ tx.moveCall({
1339
+ target: serviceFn("sales_clear"),
1340
+ arguments: [toTxObject(tx, service), toTxObject(tx, permission)],
1341
+ typeArguments: [service_type]
1342
+ });
1343
+ }
1344
+ }
1345
+ function sales_set(tx, service, service_type, permission, sales, passport) {
1346
+ if (sales.length === 0) {
1347
+ return;
1348
+ }
1349
+ validObjects([service, permission, passport]);
1350
+ if (!IsValidArgType(service_type)) {
1351
+ W_ERROR(
1352
+ WErrors.InvalidParam,
1353
+ `Sales set service type ${service_type} is not valid`
1354
+ );
1355
+ }
1356
+ if (passport) {
1357
+ tx.moveCall({
1358
+ target: serviceFn("sales_set_with_passport"),
1359
+ arguments: [
1360
+ toTxObject(tx, service),
1361
+ toTxObject(tx, permission),
1362
+ toTxObject(tx, passport),
1363
+ tx.makeMoveVec({
1364
+ elements: sales.map((s) => sale(tx, s)),
1365
+ type: `${PackageAddress}::service::Sale`
1366
+ })
1367
+ ],
1368
+ typeArguments: [service_type]
1369
+ });
1370
+ } else {
1371
+ tx.moveCall({
1372
+ target: serviceFn("sales_set"),
1373
+ arguments: [
1374
+ toTxObject(tx, service),
1375
+ toTxObject(tx, permission),
1376
+ tx.makeMoveVec({
1377
+ elements: sales.map((s) => sale(tx, s)),
1378
+ type: `${PackageAddress}::service::Sale`
1379
+ })
1380
+ ],
1381
+ typeArguments: [service_type]
1382
+ });
1383
+ }
1384
+ }
1385
+ function price_add(tx, service, service_type, permission, sale_name, price_add2, passport) {
1386
+ validObjects([service, permission, passport]);
1387
+ if (!IsValidArgType(service_type)) {
1388
+ W_ERROR(
1389
+ WErrors.InvalidParam,
1390
+ `Price add service type ${service_type} is not valid`
1391
+ );
1392
+ }
1393
+ if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
1394
+ W_ERROR(
1395
+ WErrors.InvalidParam,
1396
+ `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`
1397
+ );
1398
+ }
1399
+ if (!isValidU64(price_add2)) {
1400
+ W_ERROR(WErrors.IsValidU64, `Price add ${price_add2} is not valid`);
1401
+ }
1402
+ if (passport) {
1403
+ tx.moveCall({
1404
+ target: serviceFn("price_add_with_passport"),
1405
+ arguments: [
1406
+ toTxObject(tx, service),
1407
+ toTxObject(tx, permission),
1408
+ toTxObject(tx, passport),
1409
+ toTxString(tx, sale_name),
1410
+ tx.pure.u64(price_add2)
1411
+ ],
1412
+ typeArguments: [service_type]
1413
+ });
1414
+ } else {
1415
+ tx.moveCall({
1416
+ target: serviceFn("price_add"),
1417
+ arguments: [
1418
+ toTxObject(tx, service),
1419
+ toTxObject(tx, permission),
1420
+ toTxString(tx, sale_name),
1421
+ tx.pure.u64(price_add2)
1422
+ ],
1423
+ typeArguments: [service_type]
1424
+ });
1425
+ }
1426
+ }
1427
+ function price_reduce(tx, service, service_type, permission, sale_name, price_reduce2, passport) {
1428
+ validObjects([service, permission, passport]);
1429
+ if (!IsValidArgType(service_type)) {
1430
+ W_ERROR(
1431
+ WErrors.InvalidParam,
1432
+ `Price reduce service type ${service_type} is not valid`
1433
+ );
1434
+ }
1435
+ if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
1436
+ W_ERROR(
1437
+ WErrors.InvalidParam,
1438
+ `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`
1439
+ );
1440
+ }
1441
+ if (!isValidU64(price_reduce2)) {
1442
+ W_ERROR(
1443
+ WErrors.IsValidU64,
1444
+ `Price reduce ${price_reduce2} is not valid`
1445
+ );
1446
+ }
1447
+ if (passport) {
1448
+ tx.moveCall({
1449
+ target: serviceFn("price_reduce_with_passport"),
1450
+ arguments: [
1451
+ toTxObject(tx, service),
1452
+ toTxObject(tx, permission),
1453
+ toTxObject(tx, passport),
1454
+ toTxString(tx, sale_name),
1455
+ tx.pure.u64(price_reduce2)
1456
+ ],
1457
+ typeArguments: [service_type]
1458
+ });
1459
+ } else {
1460
+ tx.moveCall({
1461
+ target: serviceFn("price_reduce"),
1462
+ arguments: [
1463
+ toTxObject(tx, service),
1464
+ toTxObject(tx, permission),
1465
+ toTxString(tx, sale_name),
1466
+ tx.pure.u64(price_reduce2)
1467
+ ],
1468
+ typeArguments: [service_type]
1469
+ });
1470
+ }
1471
+ }
1472
+ function stock_add(tx, service, service_type, permission, sale_name, stock_add2, passport) {
1473
+ validObjects([service, permission, passport]);
1474
+ if (!IsValidArgType(service_type)) {
1475
+ W_ERROR(
1476
+ WErrors.InvalidParam,
1477
+ `Stock add service type ${service_type} is not valid`
1478
+ );
1479
+ }
1480
+ if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
1481
+ W_ERROR(
1482
+ WErrors.InvalidParam,
1483
+ `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`
1484
+ );
1485
+ }
1486
+ if (!isValidU64(stock_add2)) {
1487
+ W_ERROR(WErrors.IsValidU64, `Stock add ${stock_add2} is not valid`);
1488
+ }
1489
+ if (passport) {
1490
+ tx.moveCall({
1491
+ target: serviceFn("stock_add_with_passport"),
1492
+ arguments: [
1493
+ toTxObject(tx, service),
1494
+ toTxObject(tx, permission),
1495
+ toTxObject(tx, passport),
1496
+ toTxString(tx, sale_name),
1497
+ tx.pure.u64(stock_add2)
1498
+ ],
1499
+ typeArguments: [service_type]
1500
+ });
1501
+ } else {
1502
+ tx.moveCall({
1503
+ target: serviceFn("stock_add"),
1504
+ arguments: [
1505
+ toTxObject(tx, service),
1506
+ toTxObject(tx, permission),
1507
+ toTxString(tx, sale_name),
1508
+ tx.pure.u64(stock_add2)
1509
+ ],
1510
+ typeArguments: [service_type]
1511
+ });
1512
+ }
1513
+ }
1514
+ function stock_reduce(tx, service, service_type, permission, sale_name, stock_reduce2, passport) {
1515
+ validObjects([service, permission, passport]);
1516
+ if (!IsValidArgType(service_type)) {
1517
+ W_ERROR(
1518
+ WErrors.InvalidParam,
1519
+ `Stock reduce service type ${service_type} is not valid`
1520
+ );
1521
+ }
1522
+ if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
1523
+ W_ERROR(
1524
+ WErrors.InvalidParam,
1525
+ `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`
1526
+ );
1527
+ }
1528
+ if (!isValidU64(stock_reduce2)) {
1529
+ W_ERROR(
1530
+ WErrors.IsValidU64,
1531
+ `Stock reduce ${stock_reduce2} is not valid`
1532
+ );
1533
+ }
1534
+ if (passport) {
1535
+ tx.moveCall({
1536
+ target: serviceFn("stock_reduce_with_passport"),
1537
+ arguments: [
1538
+ toTxObject(tx, service),
1539
+ toTxObject(tx, permission),
1540
+ toTxObject(tx, passport),
1541
+ toTxString(tx, sale_name),
1542
+ tx.pure.u64(stock_reduce2)
1543
+ ],
1544
+ typeArguments: [service_type]
1545
+ });
1546
+ } else {
1547
+ tx.moveCall({
1548
+ target: serviceFn("stock_reduce"),
1549
+ arguments: [
1550
+ toTxObject(tx, service),
1551
+ toTxObject(tx, permission),
1552
+ toTxString(tx, sale_name),
1553
+ tx.pure.u64(stock_reduce2)
1554
+ ],
1555
+ typeArguments: [service_type]
1556
+ });
1557
+ }
1558
+ }
1559
+ function sale_suspension(tx, service, service_type, permission, sale_name, suspension, passport) {
1560
+ validObjects([service, permission, passport]);
1561
+ if (!IsValidArgType(service_type)) {
1562
+ W_ERROR(
1563
+ WErrors.InvalidParam,
1564
+ `Sale suspension service type ${service_type} is not valid`
1565
+ );
1566
+ }
1567
+ if (typeof sale_name === "string" && !isValidLongName(sale_name)) {
1568
+ W_ERROR(
1569
+ WErrors.InvalidParam,
1570
+ `Sale name ${sale_name} exceeds maximum length ${MAX_LONG_NAME_LENGTH}`
1571
+ );
1572
+ }
1573
+ if (passport) {
1574
+ tx.moveCall({
1575
+ target: serviceFn("sale_suspension_with_passport"),
1576
+ arguments: [
1577
+ toTxObject(tx, service),
1578
+ toTxObject(tx, permission),
1579
+ toTxObject(tx, passport),
1580
+ toTxString(tx, sale_name),
1581
+ tx.pure.bool(suspension)
1582
+ ],
1583
+ typeArguments: [service_type]
1584
+ });
1585
+ } else {
1586
+ tx.moveCall({
1587
+ target: serviceFn("sale_suspension"),
1588
+ arguments: [
1589
+ toTxObject(tx, service),
1590
+ toTxObject(tx, permission),
1591
+ toTxString(tx, sale_name),
1592
+ tx.pure.bool(suspension)
1593
+ ],
1594
+ typeArguments: [service_type]
1595
+ });
1596
+ }
1597
+ }
1598
+ function repository_add(tx, service, service_type, permission, repository, passport) {
1599
+ validObjects([service, permission, repository, passport]);
1600
+ if (!IsValidArgType(service_type)) {
1601
+ W_ERROR(
1602
+ WErrors.InvalidParam,
1603
+ `Repository add service type ${service_type} is not valid`
1604
+ );
1605
+ }
1606
+ if (passport) {
1607
+ tx.moveCall({
1608
+ target: serviceFn("repository_add_with_passport"),
1609
+ arguments: [
1610
+ toTxObject(tx, service),
1611
+ toTxObject(tx, permission),
1612
+ toTxObject(tx, passport),
1613
+ toTxObject(tx, repository),
1614
+ tx.object.mutRegistrar(),
1615
+ tx.object.clock()
1616
+ ],
1617
+ typeArguments: [service_type]
1618
+ });
1619
+ } else {
1620
+ tx.moveCall({
1621
+ target: serviceFn("repository_add"),
1622
+ arguments: [
1623
+ toTxObject(tx, service),
1624
+ toTxObject(tx, permission),
1625
+ toTxObject(tx, repository),
1626
+ tx.object.mutRegistrar(),
1627
+ tx.object.clock()
1628
+ ],
1629
+ typeArguments: [service_type]
1630
+ });
1631
+ }
1632
+ }
1633
+ function repository_remove(tx, service, service_type, permission, repositories, passport) {
1634
+ if (repositories.length === 0) {
1635
+ return;
1636
+ }
1637
+ validObjects([service, permission, passport, ...repositories]);
1638
+ if (!IsValidArgType(service_type)) {
1639
+ W_ERROR(
1640
+ WErrors.InvalidParam,
1641
+ `Repository remove service type ${service_type} is not valid`
1642
+ );
1643
+ }
1644
+ if (passport) {
1645
+ tx.moveCall({
1646
+ target: serviceFn("repository_remove_with_passport"),
1647
+ arguments: [
1648
+ toTxObject(tx, service),
1649
+ toTxObject(tx, permission),
1650
+ toTxObject(tx, passport),
1651
+ tx.pure.vector("address", repositories),
1652
+ tx.object.mutRegistrar()
1653
+ ],
1654
+ typeArguments: [service_type]
1655
+ });
1656
+ } else {
1657
+ tx.moveCall({
1658
+ target: serviceFn("repository_remove"),
1659
+ arguments: [
1660
+ toTxObject(tx, service),
1661
+ toTxObject(tx, permission),
1662
+ tx.pure.vector("address", repositories),
1663
+ tx.object.mutRegistrar()
1664
+ ],
1665
+ typeArguments: [service_type]
1666
+ });
1667
+ }
1668
+ }
1669
+ function repository_clear(tx, service, service_type, permission, passport) {
1670
+ validObjects([service, permission, passport]);
1671
+ if (!IsValidArgType(service_type)) {
1672
+ W_ERROR(
1673
+ WErrors.InvalidParam,
1674
+ `Repository clear service type ${service_type} is not valid`
1675
+ );
1676
+ }
1677
+ if (passport) {
1678
+ tx.moveCall({
1679
+ target: serviceFn("repository_clear_with_passport"),
1680
+ arguments: [
1681
+ toTxObject(tx, service),
1682
+ toTxObject(tx, permission),
1683
+ toTxObject(tx, passport),
1684
+ tx.object.mutRegistrar()
1685
+ ],
1686
+ typeArguments: [service_type]
1687
+ });
1688
+ } else {
1689
+ tx.moveCall({
1690
+ target: serviceFn("repository_clear"),
1691
+ arguments: [
1692
+ toTxObject(tx, service),
1693
+ toTxObject(tx, permission),
1694
+ tx.object.mutRegistrar()
1695
+ ],
1696
+ typeArguments: [service_type]
1697
+ });
1698
+ }
1699
+ }
1700
+ function buy_guard_set(tx, service, service_type, permission, guard, passport) {
1701
+ validObjects([service, permission, guard, passport]);
1702
+ if (!IsValidArgType(service_type)) {
1703
+ W_ERROR(
1704
+ WErrors.InvalidParam,
1705
+ `Buy guard set service type ${service_type} is not valid`
1706
+ );
1707
+ }
1708
+ if (passport) {
1709
+ if (guard) {
1710
+ tx.moveCall({
1711
+ target: serviceFn("buy_guard_set_with_passport"),
1712
+ arguments: [
1713
+ toTxObject(tx, service),
1714
+ toTxObject(tx, permission),
1715
+ toTxObject(tx, passport),
1716
+ toTxObject(tx, guard),
1717
+ tx.object.mutRegistrar(),
1718
+ tx.object.clock()
1719
+ ],
1720
+ typeArguments: [service_type]
1721
+ });
1722
+ } else {
1723
+ tx.moveCall({
1724
+ target: serviceFn("buy_guard_none_with_passport"),
1725
+ arguments: [
1726
+ toTxObject(tx, service),
1727
+ toTxObject(tx, permission),
1728
+ toTxObject(tx, passport),
1729
+ tx.object.mutRegistrar()
1730
+ ],
1731
+ typeArguments: [service_type]
1732
+ });
1733
+ }
1734
+ } else {
1735
+ if (guard) {
1736
+ tx.moveCall({
1737
+ target: serviceFn("buy_guard_set"),
1738
+ arguments: [
1739
+ toTxObject(tx, service),
1740
+ toTxObject(tx, permission),
1741
+ toTxObject(tx, guard),
1742
+ tx.object.mutRegistrar(),
1743
+ tx.object.clock()
1744
+ ],
1745
+ typeArguments: [service_type]
1746
+ });
1747
+ } else {
1748
+ tx.moveCall({
1749
+ target: serviceFn("buy_guard_none"),
1750
+ arguments: [
1751
+ toTxObject(tx, service),
1752
+ toTxObject(tx, permission),
1753
+ tx.object.mutRegistrar()
1754
+ ],
1755
+ typeArguments: [service_type]
1756
+ });
1757
+ }
1758
+ }
1759
+ }
1760
+ function machine_set(tx, service, service_type, permission, machine, passport) {
1761
+ validObjects([service, permission, machine, passport]);
1762
+ if (!IsValidArgType(service_type)) {
1763
+ W_ERROR(
1764
+ WErrors.InvalidParam,
1765
+ `Machine set service type ${service_type} is not valid`
1766
+ );
1767
+ }
1768
+ if (passport) {
1769
+ if (machine) {
1770
+ tx.moveCall({
1771
+ target: serviceFn("machine_set_with_passport"),
1772
+ arguments: [
1773
+ toTxObject(tx, service),
1774
+ toTxObject(tx, permission),
1775
+ toTxObject(tx, passport),
1776
+ toTxObject(tx, machine),
1777
+ tx.object.mutRegistrar(),
1778
+ tx.object.clock()
1779
+ ],
1780
+ typeArguments: [service_type]
1781
+ });
1782
+ } else {
1783
+ tx.moveCall({
1784
+ target: serviceFn("machine_none_with_passport"),
1785
+ arguments: [
1786
+ toTxObject(tx, service),
1787
+ toTxObject(tx, permission),
1788
+ toTxObject(tx, passport),
1789
+ tx.object.mutRegistrar()
1790
+ ],
1791
+ typeArguments: [service_type]
1792
+ });
1793
+ }
1794
+ } else {
1795
+ if (machine) {
1796
+ tx.moveCall({
1797
+ target: serviceFn("machine_set"),
1798
+ arguments: [
1799
+ toTxObject(tx, service),
1800
+ toTxObject(tx, permission),
1801
+ toTxObject(tx, machine),
1802
+ tx.object.mutRegistrar(),
1803
+ tx.object.clock()
1804
+ ],
1805
+ typeArguments: [service_type]
1806
+ });
1807
+ } else {
1808
+ tx.moveCall({
1809
+ target: serviceFn("machine_set_none"),
1810
+ arguments: [
1811
+ toTxObject(tx, service),
1812
+ toTxObject(tx, permission),
1813
+ tx.object.mutRegistrar()
1814
+ ],
1815
+ typeArguments: [service_type]
1816
+ });
1817
+ }
1818
+ }
1819
+ }
1820
+ function publish(tx, service, service_type, permission, passport) {
1821
+ validObjects([service, permission, passport]);
1822
+ if (!IsValidArgType(service_type)) {
1823
+ W_ERROR(
1824
+ WErrors.InvalidParam,
1825
+ `Publish service type ${service_type} is not valid`
1826
+ );
1827
+ }
1828
+ if (passport) {
1829
+ tx.moveCall({
1830
+ target: serviceFn("publish_with_passport"),
1831
+ arguments: [
1832
+ toTxObject(tx, service),
1833
+ toTxObject(tx, permission),
1834
+ toTxObject(tx, passport)
1835
+ ],
1836
+ typeArguments: [service_type]
1837
+ });
1838
+ } else {
1839
+ tx.moveCall({
1840
+ target: serviceFn("publish"),
1841
+ arguments: [toTxObject(tx, service), toTxObject(tx, permission)],
1842
+ typeArguments: [service_type]
1843
+ });
1844
+ }
1845
+ }
1846
+ function pause(tx, service, service_type, permission, bPaused, passport) {
1847
+ validObjects([service, permission, passport]);
1848
+ if (!IsValidArgType(service_type)) {
1849
+ W_ERROR(
1850
+ WErrors.InvalidParam,
1851
+ `Pause service type ${service_type} is not valid`
1852
+ );
1853
+ }
1854
+ if (passport) {
1855
+ tx.moveCall({
1856
+ target: serviceFn("pause_with_passport"),
1857
+ arguments: [
1858
+ toTxObject(tx, service),
1859
+ toTxObject(tx, permission),
1860
+ toTxObject(tx, passport),
1861
+ tx.pure.bool(bPaused),
1862
+ tx.object.clock()
1863
+ ],
1864
+ typeArguments: [service_type]
1865
+ });
1866
+ } else {
1867
+ tx.moveCall({
1868
+ target: serviceFn("pause"),
1869
+ arguments: [
1870
+ toTxObject(tx, service),
1871
+ toTxObject(tx, permission),
1872
+ tx.pure.bool(bPaused),
1873
+ tx.object.clock()
1874
+ ],
1875
+ typeArguments: [service_type]
1876
+ });
1877
+ }
1878
+ }
1879
+ function customer_required_set(tx, service, service_type, permission, required_info, passport) {
1880
+ if (required_info.length > MAX_REQUIRED_INFO_SIZE) {
1881
+ W_ERROR(
1882
+ WErrors.InvalidParam,
1883
+ `Customer required set size ${required_info.length} is exceed maximum size ${MAX_REQUIRED_INFO_SIZE}`
1884
+ );
1885
+ }
1886
+ validObjects([service, permission, passport]);
1887
+ if (!IsValidArgType(service_type)) {
1888
+ W_ERROR(
1889
+ WErrors.InvalidParam,
1890
+ `Customer required set service type ${service_type} is not valid`
1891
+ );
1892
+ }
1893
+ required_info.forEach((item) => {
1894
+ if (!isValidName(item)) {
1895
+ W_ERROR(
1896
+ WErrors.InvalidParam,
1897
+ `Customer required info ${item} is exceed maximum length ${MAX_NAME_LENGTH} or start with "0x"`
1898
+ );
1899
+ }
1900
+ });
1901
+ if (passport) {
1902
+ tx.moveCall({
1903
+ target: serviceFn("custom_required_info_set_with_passport"),
1904
+ arguments: [
1905
+ toTxObject(tx, service),
1906
+ toTxObject(tx, permission),
1907
+ toTxObject(tx, passport),
1908
+ tx.pure.vector("string", required_info)
1909
+ ],
1910
+ typeArguments: [service_type]
1911
+ });
1912
+ } else {
1913
+ tx.moveCall({
1914
+ target: serviceFn("custom_required_info_set"),
1915
+ arguments: [
1916
+ toTxObject(tx, service),
1917
+ toTxObject(tx, permission),
1918
+ tx.pure.vector("string", required_info)
1919
+ ],
1920
+ typeArguments: [service_type]
1921
+ });
1922
+ }
1923
+ }
1924
+ function arbitrations_add(tx, service, service_type, permission, arbitration, arbitration_type, passport) {
1925
+ validObjects([service, permission, arbitration, passport]);
1926
+ if (!IsValidArgType(service_type)) {
1927
+ W_ERROR(
1928
+ WErrors.InvalidParam,
1929
+ `Arbitrations add service type ${service_type} is not valid`
1930
+ );
1931
+ }
1932
+ if (!IsValidArgType(arbitration_type)) {
1933
+ W_ERROR(
1934
+ WErrors.InvalidParam,
1935
+ `Arbitrations add arbitration type ${arbitration_type} is not valid`
1936
+ );
1937
+ }
1938
+ if (passport) {
1939
+ tx.moveCall({
1940
+ target: serviceFn("arbitration_add_with_passport"),
1941
+ arguments: [
1942
+ toTxObject(tx, service),
1943
+ toTxObject(tx, permission),
1944
+ toTxObject(tx, passport),
1945
+ toTxObject(tx, arbitration),
1946
+ tx.object.mutRegistrar(),
1947
+ tx.object.clock()
1948
+ ],
1949
+ typeArguments: [service_type]
1950
+ });
1951
+ } else {
1952
+ tx.moveCall({
1953
+ target: serviceFn("arbitrations_add"),
1954
+ arguments: [
1955
+ toTxObject(tx, service),
1956
+ toTxObject(tx, permission),
1957
+ toTxObject(tx, arbitration),
1958
+ tx.object.mutRegistrar(),
1959
+ tx.object.clock()
1960
+ ],
1961
+ typeArguments: [service_type, arbitration_type]
1962
+ });
1963
+ }
1964
+ }
1965
+ function arbitrations_remove(tx, service, service_type, permission, arbitrations, passport) {
1966
+ if (arbitrations.length === 0) {
1967
+ return;
1968
+ }
1969
+ validObjects([service, permission, passport]);
1970
+ if (!IsValidArgType(service_type)) {
1971
+ W_ERROR(
1972
+ WErrors.InvalidParam,
1973
+ `Arbitrations remove service type ${service_type} is not valid`
1974
+ );
1975
+ }
1976
+ if (passport) {
1977
+ tx.moveCall({
1978
+ target: serviceFn("arbitration_remove_with_passport"),
1979
+ arguments: [
1980
+ toTxObject(tx, service),
1981
+ toTxObject(tx, permission),
1982
+ toTxObject(tx, passport),
1983
+ tx.pure.vector("address", arbitrations),
1984
+ tx.object.mutRegistrar()
1985
+ ],
1986
+ typeArguments: [service_type]
1987
+ });
1988
+ } else {
1989
+ tx.moveCall({
1990
+ target: serviceFn("arbitration_remove"),
1991
+ arguments: [
1992
+ toTxObject(tx, service),
1993
+ toTxObject(tx, permission),
1994
+ tx.pure.vector("address", arbitrations),
1995
+ tx.object.mutRegistrar()
1996
+ ],
1997
+ typeArguments: [service_type]
1998
+ });
1999
+ }
2000
+ }
2001
+ function arbitration_clear(tx, service, service_type, permission, passport) {
2002
+ validObjects([service, permission, passport]);
2003
+ if (!IsValidArgType(service_type)) {
2004
+ W_ERROR(
2005
+ WErrors.InvalidParam,
2006
+ `Arbitrations clear service type ${service_type} is not valid`
2007
+ );
2008
+ }
2009
+ if (passport) {
2010
+ tx.moveCall({
2011
+ target: serviceFn("arbitration_clear_with_passport"),
2012
+ arguments: [
2013
+ toTxObject(tx, service),
2014
+ toTxObject(tx, permission),
2015
+ toTxObject(tx, passport),
2016
+ tx.object.mutRegistrar()
2017
+ ],
2018
+ typeArguments: [service_type]
2019
+ });
2020
+ } else {
2021
+ tx.moveCall({
2022
+ target: serviceFn("arbitration_clear"),
2023
+ arguments: [
2024
+ toTxObject(tx, service),
2025
+ toTxObject(tx, permission),
2026
+ tx.object.mutRegistrar()
2027
+ ],
2028
+ typeArguments: [service_type]
2029
+ });
2030
+ }
2031
+ }
2032
+ async function compensation_fund_add(env, tx, service, service_type, permission, coin, passport) {
2033
+ validObjects([service, permission, passport]);
2034
+ if (!IsValidArgType(service_type)) {
2035
+ W_ERROR(
2036
+ WErrors.InvalidParam,
2037
+ `Compensation fund add service type ${service_type} is not valid`
2038
+ );
2039
+ }
2040
+ const coinParam = await getCoinParam(env, tx, coin, service_type);
2041
+ if (passport) {
2042
+ tx.moveCall({
2043
+ target: serviceFn("compensation_fund_add_with_passport"),
2044
+ arguments: [
2045
+ toTxObject(tx, service),
2046
+ toTxObject(tx, permission),
2047
+ toTxObject(tx, passport),
2048
+ coinParam
2049
+ ],
2050
+ typeArguments: [service_type]
2051
+ });
2052
+ } else {
2053
+ tx.moveCall({
2054
+ target: serviceFn("compensation_fund_add"),
2055
+ arguments: [
2056
+ toTxObject(tx, service),
2057
+ toTxObject(tx, permission),
2058
+ coinParam
2059
+ ],
2060
+ typeArguments: [service_type]
2061
+ });
2062
+ }
2063
+ }
2064
+ function compensation_lock_duration_set(tx, service, service_type, permission, duration_ms, passport) {
2065
+ if (!isValidU64(duration_ms) || duration_ms === 0) {
2066
+ return;
2067
+ }
2068
+ validObjects([service, permission, passport]);
2069
+ if (!IsValidArgType(service_type)) {
2070
+ W_ERROR(
2071
+ WErrors.InvalidParam,
2072
+ `Compensation lock duration set service type ${service_type} is not valid`
2073
+ );
2074
+ }
2075
+ if (passport) {
2076
+ tx.moveCall({
2077
+ target: serviceFn("compensation_lock_duration_add_with_passport"),
2078
+ arguments: [
2079
+ toTxObject(tx, service),
2080
+ toTxObject(tx, permission),
2081
+ toTxObject(tx, passport),
2082
+ tx.pure.u64(duration_ms)
2083
+ ],
2084
+ typeArguments: [service_type]
2085
+ });
2086
+ } else {
2087
+ tx.moveCall({
2088
+ target: serviceFn("compensation_lock_duration_add"),
2089
+ arguments: [
2090
+ toTxObject(tx, service),
2091
+ toTxObject(tx, permission),
2092
+ tx.pure.u64(duration_ms)
2093
+ ],
2094
+ typeArguments: [service_type]
2095
+ });
2096
+ }
2097
+ }
2098
+ function order_allocators_set(tx, service, service_type, permission, allocators2, passport) {
2099
+ validObjects([service, permission, allocators2, passport]);
2100
+ if (!IsValidArgType(service_type)) {
2101
+ W_ERROR(
2102
+ WErrors.InvalidParam,
2103
+ `Order allocators set service type ${service_type} is not valid`
2104
+ );
2105
+ }
2106
+ if (passport) {
2107
+ tx.moveCall({
2108
+ target: serviceFn("order_allocators_set_with_passport"),
2109
+ arguments: [
2110
+ toTxObject(tx, service),
2111
+ toTxObject(tx, permission),
2112
+ toTxObject(tx, passport),
2113
+ tx.object.option({
2114
+ type: `${PackageAddress}::allocation::Allocators`,
2115
+ value: allocators2 ?? null
2116
+ })
2117
+ ],
2118
+ typeArguments: [service_type]
2119
+ });
2120
+ } else {
2121
+ tx.moveCall({
2122
+ target: serviceFn("order_allocators_set"),
2123
+ arguments: [
2124
+ toTxObject(tx, service),
2125
+ toTxObject(tx, permission),
2126
+ tx.object.option({
2127
+ type: `${PackageAddress}::allocation::Allocators`,
2128
+ value: allocators2 ?? null
2129
+ })
2130
+ ],
2131
+ typeArguments: [service_type]
2132
+ });
2133
+ }
2134
+ }
2135
+ function reward_add(tx, service, service_type, permission, reward, reward_type, passport) {
2136
+ validObjects([service, permission, reward, passport]);
2137
+ if (!IsValidArgType(service_type)) {
2138
+ W_ERROR(
2139
+ WErrors.InvalidParam,
2140
+ `Rewards add service type ${service_type} is not valid`
2141
+ );
2142
+ }
2143
+ if (!IsValidArgType(reward_type)) {
2144
+ W_ERROR(
2145
+ WErrors.InvalidParam,
2146
+ `Rewards add reward type ${reward_type} is not valid`
2147
+ );
2148
+ }
2149
+ if (passport) {
2150
+ tx.moveCall({
2151
+ target: serviceFn("reward_add_with_passport"),
2152
+ arguments: [
2153
+ toTxObject(tx, service),
2154
+ toTxObject(tx, permission),
2155
+ toTxObject(tx, passport),
2156
+ toTxObject(tx, reward),
2157
+ tx.object.mutRegistrar(),
2158
+ tx.object.clock()
2159
+ ],
2160
+ typeArguments: [service_type, reward_type]
2161
+ });
2162
+ } else {
2163
+ tx.moveCall({
2164
+ target: serviceFn("reward_add"),
2165
+ arguments: [
2166
+ toTxObject(tx, service),
2167
+ toTxObject(tx, permission),
2168
+ toTxObject(tx, reward),
2169
+ tx.object.mutRegistrar(),
2170
+ tx.object.clock()
2171
+ ],
2172
+ typeArguments: [service_type, reward_type]
2173
+ });
2174
+ }
2175
+ }
2176
+ function reward_remove(tx, service, service_type, permission, rewards, passport) {
2177
+ if (rewards.length === 0) {
2178
+ return;
2179
+ }
2180
+ validObjects([service, permission, passport]);
2181
+ if (!IsValidArgType(service_type)) {
2182
+ W_ERROR(
2183
+ WErrors.InvalidParam,
2184
+ `Rewards remove service type ${service_type} is not valid`
2185
+ );
2186
+ }
2187
+ if (passport) {
2188
+ tx.moveCall({
2189
+ target: serviceFn("reward_remove_with_passport"),
2190
+ arguments: [
2191
+ toTxObject(tx, service),
2192
+ toTxObject(tx, permission),
2193
+ toTxObject(tx, passport),
2194
+ tx.pure.vector("address", rewards),
2195
+ tx.object.mutRegistrar()
2196
+ ],
2197
+ typeArguments: [service_type]
2198
+ });
2199
+ } else {
2200
+ tx.moveCall({
2201
+ target: serviceFn("reward_remove"),
2202
+ arguments: [
2203
+ toTxObject(tx, service),
2204
+ toTxObject(tx, permission),
2205
+ tx.pure.vector("address", rewards),
2206
+ tx.object.mutRegistrar()
2207
+ ],
2208
+ typeArguments: [service_type]
2209
+ });
2210
+ }
2211
+ }
2212
+ function reward_clear(tx, service, service_type, permission, passport) {
2213
+ validObjects([service, permission, passport]);
2214
+ if (!IsValidArgType(service_type)) {
2215
+ W_ERROR(
2216
+ WErrors.InvalidParam,
2217
+ `Rewards clear service type ${service_type} is not valid`
2218
+ );
2219
+ }
2220
+ if (passport) {
2221
+ tx.moveCall({
2222
+ target: serviceFn("reward_clear_with_passport"),
2223
+ arguments: [
2224
+ toTxObject(tx, service),
2225
+ toTxObject(tx, permission),
2226
+ toTxObject(tx, passport),
2227
+ tx.object.mutRegistrar()
2228
+ ],
2229
+ typeArguments: [service_type]
2230
+ });
2231
+ } else {
2232
+ tx.moveCall({
2233
+ target: serviceFn("reward_clear"),
2234
+ arguments: [
2235
+ toTxObject(tx, service),
2236
+ toTxObject(tx, permission),
2237
+ tx.object.mutRegistrar()
2238
+ ],
2239
+ typeArguments: [service_type]
2240
+ });
2241
+ }
2242
+ }
2243
+ function compensation_fund_receive(tx, service, service_type, permission, received_object, payment, passport) {
2244
+ if (!payment) {
2245
+ W_ERROR(
2246
+ WErrors.InvalidParam,
2247
+ `Compensation fund receive payment is required`
2248
+ );
2249
+ }
2250
+ validObjects([service, permission, received_object, payment, passport]);
2251
+ if (!IsValidArgType(service_type)) {
2252
+ W_ERROR(
2253
+ WErrors.InvalidParam,
2254
+ `Compensation fund receive service type ${service_type} is not valid`
2255
+ );
2256
+ }
2257
+ if (passport) {
2258
+ tx.moveCall({
2259
+ target: serviceFn("compensation_fund_receive_with_passport"),
2260
+ arguments: [
2261
+ toTxObject(tx, service),
2262
+ toTxObject(tx, permission),
2263
+ toTxObject(tx, passport),
2264
+ toTxObject(tx, received_object),
2265
+ toTxObject(tx, payment)
2266
+ ],
2267
+ typeArguments: [service_type]
2268
+ });
2269
+ } else {
2270
+ tx.moveCall({
2271
+ target: serviceFn("compensation_fund_receive"),
2272
+ arguments: [
2273
+ toTxObject(tx, service),
2274
+ toTxObject(tx, permission),
2275
+ toTxObject(tx, received_object),
2276
+ toTxObject(tx, payment)
2277
+ ],
2278
+ typeArguments: [service_type]
2279
+ });
2280
+ }
2281
+ }
2282
+ function compensation_fund_withdraw(tx, service, service_type, payment_info, receipt, permission, passport) {
2283
+ validObjects([service, permission, receipt, payment_info, passport]);
2284
+ if (!IsValidArgType(service_type)) {
2285
+ W_ERROR(
2286
+ WErrors.InvalidParam,
2287
+ `Compensation fund withdraw service type ${service_type} is not valid`
2288
+ );
2289
+ }
2290
+ if (passport) {
2291
+ tx.moveCall({
2292
+ target: serviceFn("compensation_fund_withdraw_with_passport"),
2293
+ arguments: [
2294
+ toTxObject(tx, service),
2295
+ toTxObject(tx, permission),
2296
+ toTxObject(tx, passport),
2297
+ tx.pure.address(receipt),
2298
+ toTxObject(tx, payment_info),
2299
+ tx.object.mutRegistrar(),
2300
+ tx.object.clock()
2301
+ ],
2302
+ typeArguments: [service_type]
2303
+ });
2304
+ } else {
2305
+ tx.moveCall({
2306
+ target: serviceFn("compensation_fund_withdraw"),
2307
+ arguments: [
2308
+ toTxObject(tx, service),
2309
+ toTxObject(tx, permission),
2310
+ tx.pure.address(receipt),
2311
+ toTxObject(tx, payment_info),
2312
+ tx.object.mutRegistrar(),
2313
+ tx.object.clock()
2314
+ ],
2315
+ typeArguments: [service_type]
2316
+ });
2317
+ }
2318
+ }
2319
+ async function discount(tx, service, service_type, permission, discount2, passport) {
2320
+ let recipient = [];
2321
+ if (Array.isArray(discount2.recipient)) {
2322
+ recipient = discount2.recipient;
2323
+ } else {
2324
+ recipient = await GetManyAccountOrMark_Address(discount2.recipient);
2325
+ }
2326
+ if (recipient.length === 0 || discount2.count === 0) {
2327
+ return;
2328
+ }
2329
+ if (recipient.length > MAX_DISCOUNT_RECEIVER_ONCE) {
2330
+ W_ERROR(
2331
+ WErrors.InvalidParam,
2332
+ `Discount recipient length ${recipient.length} is exceed max ${MAX_DISCOUNT_RECEIVER_ONCE}`
2333
+ );
2334
+ }
2335
+ if (!isValidName(discount2.name)) {
2336
+ W_ERROR(
2337
+ WErrors.InvalidParam,
2338
+ `Discount name ${discount2.name} is not valid`
2339
+ );
2340
+ }
2341
+ if (!isValidU16(discount2.count) || discount2.count > MAX_DISCOUNT_COUNT_ONCE) {
2342
+ W_ERROR(
2343
+ WErrors.InvalidParam,
2344
+ `Discount count ${discount2.count} is exceed max ${MAX_DISCOUNT_COUNT_ONCE}`
2345
+ );
2346
+ }
2347
+ if (recipient.length * discount2.count > MAX_DISCOUNT_TOTAL_COUNT) {
2348
+ W_ERROR(
2349
+ WErrors.InvalidParam,
2350
+ `Discount total count ${recipient.length * discount2.count} is exceed max ${MAX_DISCOUNT_TOTAL_COUNT}`
2351
+ );
2352
+ }
2353
+ if (discount2.benchmark != null && !isValidU64(discount2.benchmark)) {
2354
+ W_ERROR(
2355
+ WErrors.InvalidParam,
2356
+ `Discount benchmark ${discount2.benchmark} is not valid`
2357
+ );
2358
+ }
2359
+ const start = discount2.time_ms_start ?? Date.now();
2360
+ if (discount2.time_ms_end < start) {
2361
+ W_ERROR(
2362
+ WErrors.InvalidParam,
2363
+ `Discount time_ms_end ${discount2.time_ms_end} is not valid`
2364
+ );
2365
+ }
2366
+ if (discount2.discount_value != null && !isValidU64(discount2.discount_value)) {
2367
+ W_ERROR(
2368
+ WErrors.InvalidParam,
2369
+ `Discount discount_value ${discount2.discount_value} is not valid`
2370
+ );
2371
+ }
2372
+ validObjects([service, permission, passport, ...recipient]);
2373
+ if (!IsValidArgType(service_type)) {
2374
+ W_ERROR(
2375
+ WErrors.InvalidParam,
2376
+ `Discount service type ${service_type} is not valid`
2377
+ );
2378
+ }
2379
+ if (passport) {
2380
+ tx.moveCall({
2381
+ target: serviceFn("discount_with_passport"),
2382
+ arguments: [
2383
+ toTxObject(tx, service),
2384
+ toTxObject(tx, permission),
2385
+ toTxObject(tx, passport),
2386
+ tx.pure.string(discount2.name),
2387
+ tx.pure.u8(discount2.discount_type),
2388
+ tx.pure.u64(discount2.discount_value),
2389
+ tx.pure.option("u64", discount2.benchmark ?? null),
2390
+ tx.pure.bool(discount2.transferable),
2391
+ tx.pure.option("u64", discount2.time_ms_start ?? null),
2392
+ tx.pure.u64(discount2.time_ms_end),
2393
+ tx.pure.u16(discount2.count),
2394
+ tx.pure.vector("address", recipient),
2395
+ tx.object.clock()
2396
+ ],
2397
+ typeArguments: [service_type]
2398
+ });
2399
+ } else {
2400
+ tx.moveCall({
2401
+ target: serviceFn("discount"),
2402
+ arguments: [
2403
+ toTxObject(tx, service),
2404
+ toTxObject(tx, permission),
2405
+ tx.pure.string(discount2.name),
2406
+ tx.pure.u8(discount2.discount_type),
2407
+ tx.pure.u64(discount2.discount_value),
2408
+ tx.pure.option("u64", discount2.benchmark ?? null),
2409
+ tx.pure.bool(discount2.transferable),
2410
+ tx.pure.option("u64", discount2.time_ms_start ?? null),
2411
+ tx.pure.u64(discount2.time_ms_end),
2412
+ tx.pure.u16(discount2.count),
2413
+ tx.pure.vector("address", recipient),
2414
+ tx.object.clock()
2415
+ ],
2416
+ typeArguments: [service_type]
2417
+ });
2418
+ }
2419
+ }
2420
+ export {
2421
+ CallService,
2422
+ DEFAULT_COMPENSATION_LOCK_DURATION,
2423
+ DISCOUNT_TYPE_MINUS,
2424
+ DISCOUNT_TYPE_RATES,
2425
+ MAX_ARBITRATION_COUNT,
2426
+ MAX_CUSTOMER_REQUIRED_INFO_COUNT,
2427
+ MAX_DISCOUNT_COUNT_ONCE,
2428
+ MAX_DISCOUNT_RECEIVER_ONCE,
2429
+ MAX_DISCOUNT_TOTAL_COUNT,
2430
+ MAX_PUBKEY_LENGTH,
2431
+ MAX_REPOSITORY_COUNT,
2432
+ MAX_REQUIRED_INFO_SIZE,
2433
+ MAX_REWARD_COUNT,
2434
+ MAX_SALE_COUNT,
2435
+ arbitration_clear,
2436
+ arbitrations_add,
2437
+ arbitrations_remove,
2438
+ buy,
2439
+ buy_guard_set,
2440
+ compensation_fund_add,
2441
+ compensation_fund_receive,
2442
+ compensation_fund_withdraw,
2443
+ compensation_lock_duration_set,
2444
+ create,
2445
+ customer_required_set,
2446
+ description_set,
2447
+ discount,
2448
+ discount_destroy,
2449
+ discount_send,
2450
+ location_set,
2451
+ machine_set,
2452
+ newService,
2453
+ order_allocators_set,
2454
+ pause,
2455
+ price_add,
2456
+ price_reduce,
2457
+ publish,
2458
+ repository_add,
2459
+ repository_clear,
2460
+ repository_remove,
2461
+ reward_add,
2462
+ reward_clear,
2463
+ reward_remove,
2464
+ sale_suspension,
2465
+ sales_add,
2466
+ sales_clear,
2467
+ sales_remove,
2468
+ sales_set,
2469
+ stock_add,
2470
+ stock_reduce,
2471
+ um_set
2472
+ };