@layerzerolabs/lz-iotal1-sdk-v2 3.0.143

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 (279) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +19 -0
  3. package/deployments/iotal1-mainnet/blocked_message_lib.json +58 -0
  4. package/deployments/iotal1-mainnet/blocked_msglib_ptb_builder.json +58 -0
  5. package/deployments/iotal1-mainnet/call.json +46 -0
  6. package/deployments/iotal1-mainnet/counter.json +85 -0
  7. package/deployments/iotal1-mainnet/dvn.json +49 -0
  8. package/deployments/iotal1-mainnet/dvn_call_type.json +45 -0
  9. package/deployments/iotal1-mainnet/dvn_fee_lib.json +59 -0
  10. package/deployments/iotal1-mainnet/dvn_layerzero.json +56 -0
  11. package/deployments/iotal1-mainnet/dvn_ptb_builder.json +45 -0
  12. package/deployments/iotal1-mainnet/endpoint_ptb_builder.json +70 -0
  13. package/deployments/iotal1-mainnet/endpoint_v2.json +86 -0
  14. package/deployments/iotal1-mainnet/executor.json +49 -0
  15. package/deployments/iotal1-mainnet/executor_call_type.json +45 -0
  16. package/deployments/iotal1-mainnet/executor_fee_lib.json +60 -0
  17. package/deployments/iotal1-mainnet/executor_layerzero.json +56 -0
  18. package/deployments/iotal1-mainnet/executor_ptb_builder.json +45 -0
  19. package/deployments/iotal1-mainnet/layerzero_views.json +46 -0
  20. package/deployments/iotal1-mainnet/message_lib_common.json +47 -0
  21. package/deployments/iotal1-mainnet/msglib_ptb_builder_call_types.json +45 -0
  22. package/deployments/iotal1-mainnet/multi_call.json +45 -0
  23. package/deployments/iotal1-mainnet/oapp.json +50 -0
  24. package/deployments/iotal1-mainnet/object-BlockedMessageLib.json +9 -0
  25. package/deployments/iotal1-mainnet/object-BlockedMsglibPtbBuilder.json +9 -0
  26. package/deployments/iotal1-mainnet/object-Counter.json +9 -0
  27. package/deployments/iotal1-mainnet/object-CounterAdminCap.json +9 -0
  28. package/deployments/iotal1-mainnet/object-CounterOApp.json +9 -0
  29. package/deployments/iotal1-mainnet/object-DVN.json +5 -0
  30. package/deployments/iotal1-mainnet/object-DVNCap.json +9 -0
  31. package/deployments/iotal1-mainnet/object-DVNFeeLib.json +9 -0
  32. package/deployments/iotal1-mainnet/object-EndpointPtbBuilder.json +9 -0
  33. package/deployments/iotal1-mainnet/object-EndpointPtbBuilderAdminCap.json +9 -0
  34. package/deployments/iotal1-mainnet/object-EndpointV2.json +9 -0
  35. package/deployments/iotal1-mainnet/object-EndpointV2AdminCap.json +9 -0
  36. package/deployments/iotal1-mainnet/object-Executor.json +5 -0
  37. package/deployments/iotal1-mainnet/object-ExecutorCap.json +9 -0
  38. package/deployments/iotal1-mainnet/object-ExecutorFeeLib.json +9 -0
  39. package/deployments/iotal1-mainnet/object-ExecutorOwnerCap.json +5 -0
  40. package/deployments/iotal1-mainnet/object-OFTComposerManager.json +9 -0
  41. package/deployments/iotal1-mainnet/object-PackageWhitelistValidator.json +9 -0
  42. package/deployments/iotal1-mainnet/object-PriceFeed.json +9 -0
  43. package/deployments/iotal1-mainnet/object-PriceFeedOwnerCap.json +9 -0
  44. package/deployments/iotal1-mainnet/object-SimpleMessageLib.json +9 -0
  45. package/deployments/iotal1-mainnet/object-SimpleMessageLibAdminCap.json +9 -0
  46. package/deployments/iotal1-mainnet/object-SmlPtbBuilder.json +9 -0
  47. package/deployments/iotal1-mainnet/object-Treasury.json +9 -0
  48. package/deployments/iotal1-mainnet/object-TreasuryAdminCap.json +9 -0
  49. package/deployments/iotal1-mainnet/object-ULN302.json +9 -0
  50. package/deployments/iotal1-mainnet/object-ULN302AdminCap.json +9 -0
  51. package/deployments/iotal1-mainnet/object-Uln302PtbBuilder.json +9 -0
  52. package/deployments/iotal1-mainnet/object-Uln302Verification.json +9 -0
  53. package/deployments/iotal1-mainnet/object-WorkerRegistry.json +9 -0
  54. package/deployments/iotal1-mainnet/object-ZroCoinMetadata.json +9 -0
  55. package/deployments/iotal1-mainnet/object-ZroTreasuryCap.json +9 -0
  56. package/deployments/iotal1-mainnet/oft_common.json +61 -0
  57. package/deployments/iotal1-mainnet/package_whitelist_validator.json +113 -0
  58. package/deployments/iotal1-mainnet/price_feed.json +70 -0
  59. package/deployments/iotal1-mainnet/price_feed_call_types.json +45 -0
  60. package/deployments/iotal1-mainnet/ptb_move_call.json +48 -0
  61. package/deployments/iotal1-mainnet/simple_message_lib.json +69 -0
  62. package/deployments/iotal1-mainnet/simple_msglib_ptb_builder.json +58 -0
  63. package/deployments/iotal1-mainnet/treasury.json +69 -0
  64. package/deployments/iotal1-mainnet/uln_302.json +87 -0
  65. package/deployments/iotal1-mainnet/uln_302_ptb_builder.json +58 -0
  66. package/deployments/iotal1-mainnet/uln_common.json +49 -0
  67. package/deployments/iotal1-mainnet/utils.json +57 -0
  68. package/deployments/iotal1-mainnet/worker_common.json +46 -0
  69. package/deployments/iotal1-mainnet/worker_registry.json +58 -0
  70. package/deployments/iotal1-mainnet/zro.json +67 -0
  71. package/deployments/iotal1-sandbox-local/blocked_message_lib.json +58 -0
  72. package/deployments/iotal1-sandbox-local/blocked_msglib_ptb_builder.json +58 -0
  73. package/deployments/iotal1-sandbox-local/call.json +46 -0
  74. package/deployments/iotal1-sandbox-local/counter.json +148 -0
  75. package/deployments/iotal1-sandbox-local/dvn.json +49 -0
  76. package/deployments/iotal1-sandbox-local/dvn_call_type.json +73 -0
  77. package/deployments/iotal1-sandbox-local/dvn_fee_lib.json +59 -0
  78. package/deployments/iotal1-sandbox-local/dvn_layerzero.json +56 -0
  79. package/deployments/iotal1-sandbox-local/dvn_ptb_builder.json +45 -0
  80. package/deployments/iotal1-sandbox-local/endpoint_ptb_builder.json +70 -0
  81. package/deployments/iotal1-sandbox-local/endpoint_v2.json +86 -0
  82. package/deployments/iotal1-sandbox-local/executor.json +49 -0
  83. package/deployments/iotal1-sandbox-local/executor_call_type.json +73 -0
  84. package/deployments/iotal1-sandbox-local/executor_fee_lib.json +60 -0
  85. package/deployments/iotal1-sandbox-local/executor_layerzero.json +56 -0
  86. package/deployments/iotal1-sandbox-local/executor_ptb_builder.json +45 -0
  87. package/deployments/iotal1-sandbox-local/layerzero_views.json +46 -0
  88. package/deployments/iotal1-sandbox-local/message_lib_common.json +47 -0
  89. package/deployments/iotal1-sandbox-local/msglib_ptb_builder_call_types.json +45 -0
  90. package/deployments/iotal1-sandbox-local/multi_call.json +45 -0
  91. package/deployments/iotal1-sandbox-local/oapp.json +50 -0
  92. package/deployments/iotal1-sandbox-local/object-BlockedMessageLib.json +9 -0
  93. package/deployments/iotal1-sandbox-local/object-BlockedMsglibPtbBuilder.json +9 -0
  94. package/deployments/iotal1-sandbox-local/object-Counter.json +9 -0
  95. package/deployments/iotal1-sandbox-local/object-CounterAdminCap.json +9 -0
  96. package/deployments/iotal1-sandbox-local/object-CounterOApp.json +9 -0
  97. package/deployments/iotal1-sandbox-local/object-DVN.json +5 -0
  98. package/deployments/iotal1-sandbox-local/object-DVNCap.json +9 -0
  99. package/deployments/iotal1-sandbox-local/object-DVNFeeLib.json +9 -0
  100. package/deployments/iotal1-sandbox-local/object-EndpointPtbBuilder.json +9 -0
  101. package/deployments/iotal1-sandbox-local/object-EndpointPtbBuilderAdminCap.json +9 -0
  102. package/deployments/iotal1-sandbox-local/object-EndpointV2.json +9 -0
  103. package/deployments/iotal1-sandbox-local/object-EndpointV2AdminCap.json +9 -0
  104. package/deployments/iotal1-sandbox-local/object-Executor.json +5 -0
  105. package/deployments/iotal1-sandbox-local/object-ExecutorCap.json +9 -0
  106. package/deployments/iotal1-sandbox-local/object-ExecutorFeeLib.json +9 -0
  107. package/deployments/iotal1-sandbox-local/object-ExecutorOwnerCap.json +5 -0
  108. package/deployments/iotal1-sandbox-local/object-PackageWhitelistValidator.json +9 -0
  109. package/deployments/iotal1-sandbox-local/object-PriceFeed.json +9 -0
  110. package/deployments/iotal1-sandbox-local/object-PriceFeedOwnerCap.json +9 -0
  111. package/deployments/iotal1-sandbox-local/object-SimpleMessageLib.json +9 -0
  112. package/deployments/iotal1-sandbox-local/object-SimpleMessageLibAdminCap.json +9 -0
  113. package/deployments/iotal1-sandbox-local/object-SmlPtbBuilder.json +9 -0
  114. package/deployments/iotal1-sandbox-local/object-Treasury.json +9 -0
  115. package/deployments/iotal1-sandbox-local/object-TreasuryAdminCap.json +9 -0
  116. package/deployments/iotal1-sandbox-local/object-ULN302.json +9 -0
  117. package/deployments/iotal1-sandbox-local/object-ULN302AdminCap.json +9 -0
  118. package/deployments/iotal1-sandbox-local/object-Uln302PtbBuilder.json +9 -0
  119. package/deployments/iotal1-sandbox-local/object-Uln302Verification.json +9 -0
  120. package/deployments/iotal1-sandbox-local/object-WorkerRegistry.json +9 -0
  121. package/deployments/iotal1-sandbox-local/object-ZroCoinMetadata.json +9 -0
  122. package/deployments/iotal1-sandbox-local/object-ZroTreasuryCap.json +9 -0
  123. package/deployments/iotal1-sandbox-local/package_whitelist_validator.json +113 -0
  124. package/deployments/iotal1-sandbox-local/price_feed.json +98 -0
  125. package/deployments/iotal1-sandbox-local/price_feed_call_types.json +45 -0
  126. package/deployments/iotal1-sandbox-local/ptb_move_call.json +48 -0
  127. package/deployments/iotal1-sandbox-local/simple_message_lib.json +69 -0
  128. package/deployments/iotal1-sandbox-local/simple_msglib_ptb_builder.json +58 -0
  129. package/deployments/iotal1-sandbox-local/treasury.json +97 -0
  130. package/deployments/iotal1-sandbox-local/uln_302.json +87 -0
  131. package/deployments/iotal1-sandbox-local/uln_302_ptb_builder.json +58 -0
  132. package/deployments/iotal1-sandbox-local/uln_common.json +49 -0
  133. package/deployments/iotal1-sandbox-local/utils.json +78 -0
  134. package/deployments/iotal1-sandbox-local/worker_common.json +46 -0
  135. package/deployments/iotal1-sandbox-local/worker_registry.json +58 -0
  136. package/deployments/iotal1-sandbox-local/zro.json +67 -0
  137. package/deployments/iotal1-testnet/blocked_message_lib.json +58 -0
  138. package/deployments/iotal1-testnet/blocked_msglib_ptb_builder.json +58 -0
  139. package/deployments/iotal1-testnet/call.json +46 -0
  140. package/deployments/iotal1-testnet/counter.json +85 -0
  141. package/deployments/iotal1-testnet/dvn.json +49 -0
  142. package/deployments/iotal1-testnet/dvn_call_type.json +45 -0
  143. package/deployments/iotal1-testnet/dvn_fee_lib.json +59 -0
  144. package/deployments/iotal1-testnet/dvn_layerzero.json +56 -0
  145. package/deployments/iotal1-testnet/dvn_ptb_builder.json +45 -0
  146. package/deployments/iotal1-testnet/endpoint_ptb_builder.json +70 -0
  147. package/deployments/iotal1-testnet/endpoint_v2.json +86 -0
  148. package/deployments/iotal1-testnet/executor.json +49 -0
  149. package/deployments/iotal1-testnet/executor_call_type.json +45 -0
  150. package/deployments/iotal1-testnet/executor_fee_lib.json +60 -0
  151. package/deployments/iotal1-testnet/executor_layerzero.json +56 -0
  152. package/deployments/iotal1-testnet/executor_ptb_builder.json +45 -0
  153. package/deployments/iotal1-testnet/layerzero_views.json +46 -0
  154. package/deployments/iotal1-testnet/message_lib_common.json +47 -0
  155. package/deployments/iotal1-testnet/msglib_ptb_builder_call_types.json +45 -0
  156. package/deployments/iotal1-testnet/multi_call.json +45 -0
  157. package/deployments/iotal1-testnet/oapp.json +50 -0
  158. package/deployments/iotal1-testnet/object-BlockedMessageLib.json +9 -0
  159. package/deployments/iotal1-testnet/object-BlockedMsglibPtbBuilder.json +9 -0
  160. package/deployments/iotal1-testnet/object-Counter.json +9 -0
  161. package/deployments/iotal1-testnet/object-CounterAdminCap.json +9 -0
  162. package/deployments/iotal1-testnet/object-CounterOApp.json +9 -0
  163. package/deployments/iotal1-testnet/object-DVN.json +5 -0
  164. package/deployments/iotal1-testnet/object-DVNCap.json +9 -0
  165. package/deployments/iotal1-testnet/object-DVNFeeLib.json +9 -0
  166. package/deployments/iotal1-testnet/object-EndpointPtbBuilder.json +9 -0
  167. package/deployments/iotal1-testnet/object-EndpointPtbBuilderAdminCap.json +9 -0
  168. package/deployments/iotal1-testnet/object-EndpointV2.json +9 -0
  169. package/deployments/iotal1-testnet/object-EndpointV2AdminCap.json +9 -0
  170. package/deployments/iotal1-testnet/object-Executor.json +5 -0
  171. package/deployments/iotal1-testnet/object-ExecutorCap.json +9 -0
  172. package/deployments/iotal1-testnet/object-ExecutorFeeLib.json +9 -0
  173. package/deployments/iotal1-testnet/object-ExecutorOwnerCap.json +5 -0
  174. package/deployments/iotal1-testnet/object-PackageWhitelistValidator.json +9 -0
  175. package/deployments/iotal1-testnet/object-PriceFeed.json +9 -0
  176. package/deployments/iotal1-testnet/object-PriceFeedOwnerCap.json +9 -0
  177. package/deployments/iotal1-testnet/object-SimpleMessageLib.json +9 -0
  178. package/deployments/iotal1-testnet/object-SimpleMessageLibAdminCap.json +9 -0
  179. package/deployments/iotal1-testnet/object-SmlPtbBuilder.json +9 -0
  180. package/deployments/iotal1-testnet/object-Treasury.json +9 -0
  181. package/deployments/iotal1-testnet/object-TreasuryAdminCap.json +9 -0
  182. package/deployments/iotal1-testnet/object-ULN302.json +9 -0
  183. package/deployments/iotal1-testnet/object-ULN302AdminCap.json +9 -0
  184. package/deployments/iotal1-testnet/object-Uln302PtbBuilder.json +9 -0
  185. package/deployments/iotal1-testnet/object-Uln302Verification.json +9 -0
  186. package/deployments/iotal1-testnet/object-WorkerRegistry.json +9 -0
  187. package/deployments/iotal1-testnet/object-ZroCoinMetadata.json +9 -0
  188. package/deployments/iotal1-testnet/object-ZroTreasuryCap.json +9 -0
  189. package/deployments/iotal1-testnet/package_whitelist_validator.json +113 -0
  190. package/deployments/iotal1-testnet/price_feed.json +70 -0
  191. package/deployments/iotal1-testnet/price_feed_call_types.json +45 -0
  192. package/deployments/iotal1-testnet/ptb_move_call.json +48 -0
  193. package/deployments/iotal1-testnet/simple_message_lib.json +69 -0
  194. package/deployments/iotal1-testnet/simple_msglib_ptb_builder.json +58 -0
  195. package/deployments/iotal1-testnet/treasury.json +69 -0
  196. package/deployments/iotal1-testnet/uln_302.json +87 -0
  197. package/deployments/iotal1-testnet/uln_302_ptb_builder.json +58 -0
  198. package/deployments/iotal1-testnet/uln_common.json +49 -0
  199. package/deployments/iotal1-testnet/utils.json +57 -0
  200. package/deployments/iotal1-testnet/worker_common.json +46 -0
  201. package/deployments/iotal1-testnet/worker_registry.json +58 -0
  202. package/deployments/iotal1-testnet/zro.json +67 -0
  203. package/dist/index.cjs +11279 -0
  204. package/dist/index.cjs.map +1 -0
  205. package/dist/index.d.mts +5824 -0
  206. package/dist/index.d.ts +5824 -0
  207. package/dist/index.mjs +11107 -0
  208. package/dist/index.mjs.map +1 -0
  209. package/package.json +68 -0
  210. package/src/bcs/dvn.ts +7 -0
  211. package/src/bcs/endpoint.ts +7 -0
  212. package/src/bcs/executor.ts +27 -0
  213. package/src/bcs/index.ts +8 -0
  214. package/src/bcs/messaging-fee.ts +6 -0
  215. package/src/bcs/move-call.ts +28 -0
  216. package/src/bcs/oapp.ts +14 -0
  217. package/src/bcs/price-feed.ts +21 -0
  218. package/src/bcs/uln.ts +15 -0
  219. package/src/generated/addresses.ts +344 -0
  220. package/src/index.ts +5 -0
  221. package/src/module-manager.ts +360 -0
  222. package/src/modules/call.ts +245 -0
  223. package/src/modules/endpoint.ts +2417 -0
  224. package/src/modules/index.ts +10 -0
  225. package/src/modules/layerzero-views.ts +205 -0
  226. package/src/modules/message-libs/blocked-message-lib.ts +112 -0
  227. package/src/modules/message-libs/index.ts +4 -0
  228. package/src/modules/message-libs/simple-message-lib.ts +270 -0
  229. package/src/modules/message-libs/uln302.ts +827 -0
  230. package/src/modules/oapps/counter.ts +458 -0
  231. package/src/modules/oapps/index.ts +3 -0
  232. package/src/modules/oapps/oapp.ts +744 -0
  233. package/src/modules/ptb-builders/blocked-message-lib-ptb-builder.ts +49 -0
  234. package/src/modules/ptb-builders/dvn-ptb-builder.ts +58 -0
  235. package/src/modules/ptb-builders/endpoint-ptb-builder.ts +520 -0
  236. package/src/modules/ptb-builders/executor-ptb-builder.ts +58 -0
  237. package/src/modules/ptb-builders/index.ts +9 -0
  238. package/src/modules/ptb-builders/package-whitelist-validator.ts +142 -0
  239. package/src/modules/ptb-builders/ptb-builder.ts +357 -0
  240. package/src/modules/ptb-builders/simple-message-lib-ptb-builder.ts +53 -0
  241. package/src/modules/ptb-builders/uln302-ptb-builder.ts +222 -0
  242. package/src/modules/utils.ts +902 -0
  243. package/src/modules/workers/dvn-fee-lib.ts +89 -0
  244. package/src/modules/workers/dvn-layerzero.ts +85 -0
  245. package/src/modules/workers/dvn.ts +1727 -0
  246. package/src/modules/workers/executor-fee-lib.ts +94 -0
  247. package/src/modules/workers/executor-layerzero.ts +79 -0
  248. package/src/modules/workers/executor.ts +1170 -0
  249. package/src/modules/workers/index.ts +10 -0
  250. package/src/modules/workers/price-feed.ts +575 -0
  251. package/src/modules/workers/treasury.ts +295 -0
  252. package/src/modules/workers/worker-registry.ts +110 -0
  253. package/src/modules/zro.ts +94 -0
  254. package/src/resource.ts +104 -0
  255. package/src/sdk.ts +183 -0
  256. package/src/types/dvn.ts +20 -0
  257. package/src/types/endpoint.ts +16 -0
  258. package/src/types/errors.ts +10 -0
  259. package/src/types/executor.ts +23 -0
  260. package/src/types/index.ts +13 -0
  261. package/src/types/layerzero-views.ts +59 -0
  262. package/src/types/message-lib.ts +38 -0
  263. package/src/types/modules.ts +36 -0
  264. package/src/types/move-types.ts +24 -0
  265. package/src/types/oapp.ts +6 -0
  266. package/src/types/options.ts +333 -0
  267. package/src/types/price-feed.ts +21 -0
  268. package/src/types/ptb-builder.ts +29 -0
  269. package/src/types/simulation.ts +8 -0
  270. package/src/utils/argument.ts +198 -0
  271. package/src/utils/index.ts +8 -0
  272. package/src/utils/move-call-object-fetcher.ts +105 -0
  273. package/src/utils/non-sender-object-validator.ts +102 -0
  274. package/src/utils/package-allowlist-validator.ts +134 -0
  275. package/src/utils/ptb-validator.ts +14 -0
  276. package/src/utils/share-object-validator.ts +37 -0
  277. package/src/utils/transaction.ts +157 -0
  278. package/src/utils/type-name.ts +99 -0
  279. package/src/utils/validate-with-details.ts +50 -0
@@ -0,0 +1,1727 @@
1
+ import { bcs } from '@iota/iota-sdk/bcs'
2
+ import { IotaClient } from '@iota/iota-sdk/client'
3
+ import { Transaction, TransactionArgument, TransactionResult } from '@iota/iota-sdk/transactions'
4
+
5
+ import { Bytes32Bcs, DvnDstConfigBcs } from '../../bcs'
6
+ import { ModuleManager } from '../../module-manager'
7
+ import { DvnDstConfig, ObjectOptions } from '../../types'
8
+ import {
9
+ asAddress,
10
+ asBool,
11
+ asBytes,
12
+ asBytes32,
13
+ asObject,
14
+ asU128,
15
+ asU16,
16
+ asU256,
17
+ asU32,
18
+ asU64,
19
+ executeSimulate,
20
+ } from '../../utils'
21
+
22
+ const MODULE_NAME = 'dvn'
23
+
24
+ export const DVNErrorCode = {
25
+ // DVN related errors (with DVN_ prefix)
26
+ DVN_EExpiredSignature: 1,
27
+ DVN_EEidNotSupported: 2,
28
+ DVN_EHashAlreadyUsed: 3,
29
+ DVN_EPtbBuilderAlreadyInitialized: 4,
30
+
31
+ // Multisig related errors (matching multisig.move)
32
+ Multisig_EDuplicatedSigner: 1,
33
+ Multisig_EInvalidSignatureLength: 2,
34
+ Multisig_EInvalidSignerLength: 3,
35
+ Multisig_EQuorumIsZero: 4,
36
+ Multisig_ESignaturesLessThanQuorum: 5,
37
+ Multisig_ESignerAlreadyExists: 6,
38
+ Multisig_ESignerNotFound: 7,
39
+ Multisig_ESignerNotInCommittee: 8,
40
+ Multisig_ESignersSizeIsLessThanQuorum: 9,
41
+
42
+ // DVNInfoV1 related errors (matching dvn_info_v1.move)
43
+ DVNInfoV1_EInvalidData: 1,
44
+ DVNInfoV1_EInvalidVersion: 2,
45
+ } as const
46
+
47
+ export class DVN {
48
+ public packageId: string
49
+ public readonly client: IotaClient
50
+ private readonly objects: ObjectOptions
51
+
52
+ constructor(
53
+ packageId: string,
54
+ client: IotaClient,
55
+ objects: ObjectOptions,
56
+ private readonly moduleManager: ModuleManager
57
+ ) {
58
+ this.packageId = packageId
59
+ this.client = client
60
+ this.objects = objects
61
+ }
62
+
63
+ // === Set Functions ===
64
+
65
+ /**
66
+ * Set admin role for an address (admin only)
67
+ * @param tx - The transaction to add the move call to
68
+ * @param adminCap - The admin capability object ID
69
+ * @param admin - The admin address or transaction argument
70
+ * @param active - Whether to activate or deactivate the admin role or transaction argument
71
+ */
72
+ setAdminMoveCall(
73
+ tx: Transaction,
74
+ adminCap: string | TransactionArgument,
75
+ admin: string | TransactionArgument,
76
+ active: boolean | TransactionArgument
77
+ ): void {
78
+ tx.moveCall({
79
+ target: this.#target('set_admin'),
80
+ arguments: [tx.object(this.objects.dvn), asObject(tx, adminCap), asAddress(tx, admin), asBool(tx, active)],
81
+ })
82
+ }
83
+
84
+ /**
85
+ * Set default multiplier basis points for fee calculation (admin only)
86
+ * @param tx - The transaction to add the move call to
87
+ * @param adminCap - The admin capability object ID
88
+ * @param multiplierBps - The multiplier in basis points or transaction argument
89
+ */
90
+ setDefaultMultiplierBpsMoveCall(
91
+ tx: Transaction,
92
+ adminCap: string | TransactionArgument,
93
+ multiplierBps: number | TransactionArgument
94
+ ): void {
95
+ tx.moveCall({
96
+ target: this.#target('set_default_multiplier_bps'),
97
+ arguments: [tx.object(this.objects.dvn), asObject(tx, adminCap), asU16(tx, multiplierBps)],
98
+ })
99
+ }
100
+
101
+ /**
102
+ * Set deposit address for DVN fees (admin only)
103
+ * @param tx - The transaction to add the move call to
104
+ * @param adminCap - The admin capability object ID
105
+ * @param depositAddress - The new deposit address or transaction argument
106
+ */
107
+ setDepositAddressMoveCall(
108
+ tx: Transaction,
109
+ adminCap: string | TransactionArgument,
110
+ depositAddress: string | TransactionArgument
111
+ ): void {
112
+ tx.moveCall({
113
+ target: this.#target('set_deposit_address'),
114
+ arguments: [tx.object(this.objects.dvn), asObject(tx, adminCap), asAddress(tx, depositAddress)],
115
+ })
116
+ }
117
+
118
+ /**
119
+ * Set price feed for DVN (admin only)
120
+ * @param tx - The transaction to add the move call to
121
+ * @param adminCap - The admin capability object ID
122
+ * @param priceFeed - The price feed address or transaction argument
123
+ */
124
+ setPriceFeedMoveCall(
125
+ tx: Transaction,
126
+ adminCap: string | TransactionArgument,
127
+ priceFeed: string | TransactionArgument
128
+ ): void {
129
+ tx.moveCall({
130
+ target: this.#target('set_price_feed'),
131
+ arguments: [tx.object(this.objects.dvn), asObject(tx, adminCap), asAddress(tx, priceFeed)],
132
+ })
133
+ }
134
+
135
+ /**
136
+ * Set supported option types for a destination EID (admin only)
137
+ * @param tx - The transaction to add the move call to
138
+ * @param adminCap - The admin capability object ID
139
+ * @param dstEid - Destination endpoint ID
140
+ * @param optionTypes - Array of supported option types
141
+ */
142
+ setSupportedOptionTypesMoveCall(
143
+ tx: Transaction,
144
+ adminCap: string | TransactionArgument,
145
+ dstEid: number | TransactionArgument,
146
+ optionTypes: Uint8Array | TransactionArgument
147
+ ): void {
148
+ tx.moveCall({
149
+ target: this.#target('set_supported_option_types'),
150
+ arguments: [
151
+ tx.object(this.objects.dvn),
152
+ asObject(tx, adminCap),
153
+ asU32(tx, dstEid),
154
+ asBytes(tx, optionTypes),
155
+ ],
156
+ })
157
+ }
158
+
159
+ /**
160
+ * Set worker fee library (admin only)
161
+ * @param tx - The transaction to add the move call to
162
+ * @param adminCap - The admin capability object ID
163
+ * @param workerFeeLib - The worker fee library address
164
+ */
165
+ setWorkerFeeLibMoveCall(
166
+ tx: Transaction,
167
+ adminCap: string | TransactionArgument,
168
+ workerFeeLib: string | TransactionArgument
169
+ ): void {
170
+ tx.moveCall({
171
+ target: this.#target('set_worker_fee_lib'),
172
+ arguments: [tx.object(this.objects.dvn), asObject(tx, adminCap), asAddress(tx, workerFeeLib)],
173
+ })
174
+ }
175
+
176
+ /**
177
+ * Set destination configuration for DVN (admin only)
178
+ * @param tx - The transaction to add the move call to
179
+ * @param adminCap - The admin capability object ID
180
+ * @param dstEid - Destination endpoint ID
181
+ * @param gas - Gas amount for verification
182
+ * @param multiplierBps - Multiplier in basis points
183
+ * @param floorMarginUsd - Floor margin in USD
184
+ */
185
+ setDstConfigMoveCall(
186
+ tx: Transaction,
187
+ adminCap: string | TransactionArgument,
188
+ dstEid: number | TransactionArgument,
189
+ gas: bigint | number | string | TransactionArgument,
190
+ multiplierBps: number | TransactionArgument,
191
+ floorMarginUsd: bigint | number | string | TransactionArgument
192
+ ): void {
193
+ tx.moveCall({
194
+ target: this.#target('set_dst_config'),
195
+ arguments: [
196
+ tx.object(this.objects.dvn),
197
+ asObject(tx, adminCap),
198
+ asU32(tx, dstEid),
199
+ asU256(tx, gas),
200
+ asU16(tx, multiplierBps),
201
+ asU128(tx, floorMarginUsd),
202
+ ],
203
+ })
204
+ }
205
+
206
+ /**
207
+ * Initialize PTB builder move calls for DVN worker operations (admin only) - can only be called once
208
+ * @param tx - The transaction to add the move call to
209
+ * @param adminCap - The admin capability object ID
210
+ * @param targetPtbBuilder - Target PTB builder address
211
+ * @param getFeeMoveCalls - Get fee move calls transaction argument
212
+ * @param assignJobMoveCalls - Assign job move calls transaction argument
213
+ * @returns Transaction result containing the init PTB builder call
214
+ */
215
+ initPtbBuilderMoveCallsMoveCall(
216
+ tx: Transaction,
217
+ adminCap: string | TransactionArgument,
218
+ targetPtbBuilder: string | TransactionArgument,
219
+ getFeeMoveCalls: TransactionArgument,
220
+ assignJobMoveCalls: TransactionArgument
221
+ ): TransactionResult {
222
+ return tx.moveCall({
223
+ target: this.#target('init_ptb_builder_move_calls'),
224
+ arguments: [
225
+ tx.object(this.objects.dvn),
226
+ asObject(tx, adminCap),
227
+ asAddress(tx, targetPtbBuilder),
228
+ getFeeMoveCalls, // First element of DVN PTB result tuple
229
+ assignJobMoveCalls, // Second element of DVN PTB result tuple
230
+ ],
231
+ })
232
+ }
233
+
234
+ /**
235
+ * Set PTB builder move calls for DVN worker operations (admin with signatures)
236
+ * @param tx - The transaction to add the move call to
237
+ * @param adminCap - The admin capability object ID
238
+ * @param targetPtbBuilder - Target PTB builder address
239
+ * @param getFeeMoveCalls - Get fee move calls transaction argument
240
+ * @param assignJobMoveCalls - Assign job move calls transaction argument
241
+ * @param expiration - Signature expiration timestamp
242
+ * @param signatures - Multisig signatures for authorization
243
+ * @returns Transaction result containing the set PTB builder call
244
+ */
245
+ setPtbBuilderMoveCallsMoveCall(
246
+ tx: Transaction,
247
+ adminCap: string | TransactionArgument,
248
+ targetPtbBuilder: string | TransactionArgument,
249
+ getFeeMoveCalls: TransactionArgument,
250
+ assignJobMoveCalls: TransactionArgument,
251
+ expiration: bigint | number | string | TransactionArgument,
252
+ signatures: Uint8Array | TransactionArgument
253
+ ): TransactionResult {
254
+ return tx.moveCall({
255
+ target: this.#target('set_ptb_builder_move_calls'),
256
+ arguments: [
257
+ tx.object(this.objects.dvn),
258
+ asObject(tx, adminCap),
259
+ asAddress(tx, targetPtbBuilder),
260
+ getFeeMoveCalls, // First element of DVN PTB result tuple
261
+ assignJobMoveCalls, // Second element of DVN PTB result tuple
262
+ asU64(tx, expiration),
263
+ asBytes(tx, signatures),
264
+ tx.object.clock(),
265
+ ],
266
+ })
267
+ }
268
+
269
+ // === Set Functions with Signatures ===
270
+
271
+ /**
272
+ * Set supported message library (admin with signatures)
273
+ * @param tx - The transaction to add the move call to
274
+ * @param adminCap - The admin capability object ID
275
+ * @param messageLib - The message library address
276
+ * @param supported - Whether to support or remove support for the message library
277
+ * @param expiration - Signature expiration timestamp
278
+ * @param signatures - Multisig signatures for authorization
279
+ */
280
+ setSupportedMessageLibMoveCall(
281
+ tx: Transaction,
282
+ adminCap: string | TransactionArgument,
283
+ messageLib: string | TransactionArgument,
284
+ supported: boolean | TransactionArgument,
285
+ expiration: bigint | number | string | TransactionArgument,
286
+ signatures: Uint8Array | TransactionArgument
287
+ ): void {
288
+ tx.moveCall({
289
+ target: this.#target('set_supported_message_lib'),
290
+ arguments: [
291
+ tx.object(this.objects.dvn),
292
+ asObject(tx, adminCap),
293
+ asAddress(tx, messageLib),
294
+ asBool(tx, supported),
295
+ asU64(tx, expiration),
296
+ asBytes(tx, signatures),
297
+ tx.object.clock(),
298
+ ],
299
+ })
300
+ }
301
+
302
+ /**
303
+ * Set allowlist status for an OApp sender (admin with signatures)
304
+ * @param tx - The transaction to add the move call to
305
+ * @param adminCap - The admin capability object ID
306
+ * @param oapp - The OApp address to allowlist/remove
307
+ * @param allowed - Whether to allow or remove from allowlist
308
+ * @param expiration - Signature expiration timestamp
309
+ * @param signatures - Multisig signatures for authorization
310
+ */
311
+ setAllowlistMoveCall(
312
+ tx: Transaction,
313
+ adminCap: string | TransactionArgument,
314
+ oapp: string | TransactionArgument,
315
+ allowed: boolean | TransactionArgument,
316
+ expiration: bigint | number | string | TransactionArgument,
317
+ signatures: Uint8Array | TransactionArgument
318
+ ): void {
319
+ tx.moveCall({
320
+ target: this.#target('set_allowlist'),
321
+ arguments: [
322
+ tx.object(this.objects.dvn),
323
+ asObject(tx, adminCap),
324
+ asAddress(tx, oapp),
325
+ asBool(tx, allowed),
326
+ asU64(tx, expiration),
327
+ asBytes(tx, signatures),
328
+ tx.object.clock(),
329
+ ],
330
+ })
331
+ }
332
+
333
+ /**
334
+ * Set denylist status for an OApp sender (admin with signatures)
335
+ * @param tx - The transaction to add the move call to
336
+ * @param adminCap - The admin capability object ID
337
+ * @param oapp - The OApp address to denylist/remove
338
+ * @param denied - Whether to deny or remove from denylist
339
+ * @param expiration - Signature expiration timestamp
340
+ * @param signatures - Multisig signatures for authorization
341
+ */
342
+ setDenylistMoveCall(
343
+ tx: Transaction,
344
+ adminCap: string | TransactionArgument,
345
+ oapp: string | TransactionArgument,
346
+ denied: boolean | TransactionArgument,
347
+ expiration: bigint | number | string | TransactionArgument,
348
+ signatures: Uint8Array | TransactionArgument
349
+ ): void {
350
+ tx.moveCall({
351
+ target: this.#target('set_denylist'),
352
+ arguments: [
353
+ tx.object(this.objects.dvn),
354
+ asObject(tx, adminCap),
355
+ asAddress(tx, oapp),
356
+ asBool(tx, denied),
357
+ asU64(tx, expiration),
358
+ asBytes(tx, signatures),
359
+ tx.object.clock(),
360
+ ],
361
+ })
362
+ }
363
+
364
+ /**
365
+ * Set paused state with multisig signatures (admin with signatures)
366
+ * @param tx - The transaction to add the move call to
367
+ * @param adminCap - The admin capability object ID
368
+ * @param paused - Whether to pause or unpause the DVN
369
+ * @param expiration - Signature expiration timestamp
370
+ * @param signatures - Multisig signatures for authorization
371
+ */
372
+ setPausedMoveCall(
373
+ tx: Transaction,
374
+ adminCap: string | TransactionArgument,
375
+ paused: boolean | TransactionArgument,
376
+ expiration: bigint | number | string | TransactionArgument,
377
+ signatures: Uint8Array | TransactionArgument
378
+ ): void {
379
+ tx.moveCall({
380
+ target: this.#target('set_paused'),
381
+ arguments: [
382
+ tx.object(this.objects.dvn),
383
+ asObject(tx, adminCap),
384
+ asBool(tx, paused),
385
+ asU64(tx, expiration),
386
+ asBytes(tx, signatures),
387
+ tx.object.clock(),
388
+ ],
389
+ })
390
+ }
391
+
392
+ /**
393
+ * Set quorum threshold with multisig signatures (admin with signatures)
394
+ * @param tx - The transaction to add the move call to
395
+ * @param adminCap - The admin capability object ID
396
+ * @param quorum - The new quorum threshold
397
+ * @param expiration - Signature expiration timestamp
398
+ * @param signatures - Multisig signatures for authorization
399
+ */
400
+ setQuorumMoveCall(
401
+ tx: Transaction,
402
+ adminCap: string | TransactionArgument,
403
+ quorum: bigint | number | string | TransactionArgument,
404
+ expiration: bigint | number | string | TransactionArgument,
405
+ signatures: Uint8Array | TransactionArgument
406
+ ): void {
407
+ tx.moveCall({
408
+ target: this.#target('set_quorum'),
409
+ arguments: [
410
+ tx.object(this.objects.dvn),
411
+ asObject(tx, adminCap),
412
+ asU64(tx, quorum),
413
+ asU64(tx, expiration),
414
+ asBytes(tx, signatures),
415
+ tx.object.clock(),
416
+ ],
417
+ })
418
+ }
419
+
420
+ /**
421
+ * Set DVN signer with multisig signatures (admin with signatures)
422
+ * @param tx - The transaction to add the move call to
423
+ * @param adminCap - The admin capability object ID
424
+ * @param signer - The signer public key as bytes
425
+ * @param active - Whether to activate or deactivate the signer
426
+ * @param expiration - Signature expiration timestamp
427
+ * @param signatures - Multisig signatures for authorization
428
+ */
429
+ setDvnSignerMoveCall(
430
+ tx: Transaction,
431
+ adminCap: string | TransactionArgument,
432
+ signer: Uint8Array | TransactionArgument,
433
+ active: boolean | TransactionArgument,
434
+ expiration: bigint | number | string | TransactionArgument,
435
+ signatures: Uint8Array | TransactionArgument
436
+ ): void {
437
+ tx.moveCall({
438
+ target: this.#target('set_dvn_signer'),
439
+ arguments: [
440
+ tx.object(this.objects.dvn),
441
+ asObject(tx, adminCap),
442
+ asBytes(tx, signer),
443
+ asBool(tx, active),
444
+ asU64(tx, expiration),
445
+ asBytes(tx, signatures),
446
+ tx.object.clock(),
447
+ ],
448
+ })
449
+ }
450
+
451
+ /**
452
+ * Change admin status using quorum signatures
453
+ * @param tx - The transaction to add the move call to
454
+ * @param admin - The admin address to change
455
+ * @param active - Whether to activate or deactivate the admin
456
+ * @param expiration - Signature expiration timestamp
457
+ * @param signatures - Multisig signatures for authorization
458
+ */
459
+ quorumChangeAdminMoveCall(
460
+ tx: Transaction,
461
+ admin: string | TransactionArgument,
462
+ active: boolean | TransactionArgument,
463
+ expiration: bigint | number | string | TransactionArgument,
464
+ signatures: Uint8Array | TransactionArgument
465
+ ): void {
466
+ tx.moveCall({
467
+ target: this.#target('quorum_change_admin'),
468
+ arguments: [
469
+ tx.object(this.objects.dvn),
470
+ asAddress(tx, admin),
471
+ asBool(tx, active),
472
+ asU64(tx, expiration),
473
+ asBytes(tx, signatures),
474
+ tx.object.clock(),
475
+ ],
476
+ })
477
+ }
478
+
479
+ // Verification Functions
480
+
481
+ /**
482
+ * Verify a packet with DVN signatures (admin with signatures) - returns Call object for ULN302
483
+ * @param tx - The transaction to add the move call to
484
+ * @param adminCap - The admin capability object ID
485
+ * @param targetMessageLib - The target message library address (usually ULN302)
486
+ * @param packetHeader - The packet header as bytes
487
+ * @param payloadHash - The payload hash as bytes
488
+ * @param confirmations - Required confirmations count
489
+ * @param expiration - Signature expiration timestamp
490
+ * @param signatures - DVN multisig signatures
491
+ * @returns Transaction result containing the verification Call object
492
+ */
493
+ verifyMoveCall(
494
+ tx: Transaction,
495
+ adminCap: string | TransactionArgument,
496
+ targetMessageLib: string | TransactionArgument,
497
+ packetHeader: Uint8Array | TransactionArgument,
498
+ payloadHash: Uint8Array | TransactionArgument,
499
+ confirmations: bigint | number | string | TransactionArgument,
500
+ expiration: bigint | number | string | TransactionArgument,
501
+ signatures: Uint8Array | TransactionArgument
502
+ ): TransactionResult {
503
+ return tx.moveCall({
504
+ target: this.#target('verify'),
505
+ arguments: [
506
+ tx.object(this.objects.dvn),
507
+ asObject(tx, adminCap),
508
+ asAddress(tx, targetMessageLib),
509
+ asBytes(tx, packetHeader),
510
+ asBytes32(tx, payloadHash, this.moduleManager.getUtils()),
511
+ asU64(tx, confirmations),
512
+ asU64(tx, expiration),
513
+ asBytes(tx, signatures),
514
+ tx.object.clock(),
515
+ ],
516
+ })
517
+ }
518
+
519
+ // Worker Functions
520
+
521
+ /**
522
+ * Assign verification job for DVN (called via PTB with MultiCall created by send function in ULN302)
523
+ * @param tx - The transaction to add the move call to
524
+ * @param dvnMultiCall - The DVN multi-call transaction result
525
+ * @returns Transaction result containing a Call for fee calculation
526
+ */
527
+ assignJobMoveCall(tx: Transaction, dvnMultiCall: TransactionArgument): TransactionResult {
528
+ return tx.moveCall({
529
+ target: this.#target('assign_job'),
530
+ arguments: [tx.object(this.objects.dvn), dvnMultiCall],
531
+ })
532
+ }
533
+
534
+ /**
535
+ * Confirm assign job operation with fee calculation
536
+ * @param tx - The transaction to add the move call to
537
+ * @param dvnMultiCall - The DVN multi-call transaction result
538
+ * @param feelibCall - The fee library call transaction result
539
+ */
540
+ confirmAssignJobMoveCall(
541
+ tx: Transaction,
542
+ dvnMultiCall: TransactionArgument,
543
+ feelibCall: TransactionArgument
544
+ ): void {
545
+ tx.moveCall({
546
+ target: this.#target('confirm_assign_job'),
547
+ arguments: [tx.object(this.objects.dvn), dvnMultiCall, feelibCall],
548
+ })
549
+ }
550
+
551
+ /**
552
+ * Get fee for verification (using MultiCall created by quote function in ULN302)
553
+ * @param tx - The transaction to add the move call to
554
+ * @param dvnMultiCall - The DVN multi-call transaction result
555
+ * @returns Transaction result containing a Call for fee calculation
556
+ */
557
+ getFeeMoveCall(tx: Transaction, dvnMultiCall: TransactionArgument): TransactionResult {
558
+ return tx.moveCall({
559
+ target: this.#target('get_fee'),
560
+ arguments: [tx.object(this.objects.dvn), dvnMultiCall],
561
+ })
562
+ }
563
+
564
+ /**
565
+ * Confirm get fee operation with fee calculation
566
+ * @param tx - The transaction to add the move call to
567
+ * @param dvnMultiCall - The DVN multi-call transaction result
568
+ * @param feelibCall - The fee library call transaction result
569
+ */
570
+ confirmGetFeeMoveCall(tx: Transaction, dvnMultiCall: TransactionArgument, feelibCall: TransactionArgument): void {
571
+ tx.moveCall({
572
+ target: this.#target('confirm_get_fee'),
573
+ arguments: [tx.object(this.objects.dvn), dvnMultiCall, feelibCall],
574
+ })
575
+ }
576
+
577
+ // === View Functions ===
578
+
579
+ /**
580
+ * Get the size of the allowlist
581
+ * @param tx - The transaction to add the move call to
582
+ * @returns Transaction result containing the allowlist size
583
+ */
584
+ allowlistSizeMoveCall(tx: Transaction): TransactionResult {
585
+ return tx.moveCall({
586
+ target: this.#target('allowlist_size'),
587
+ arguments: [tx.object(this.objects.dvn)],
588
+ })
589
+ }
590
+
591
+ /**
592
+ * Get the size of the allowlist
593
+ * @returns Promise<bigint> - The number of addresses in the allowlist
594
+ */
595
+ async allowlistSize(): Promise<bigint> {
596
+ return executeSimulate(
597
+ this.client,
598
+ (tx) => {
599
+ this.allowlistSizeMoveCall(tx)
600
+ },
601
+ (result) => BigInt(bcs.U64.parse(result[0].value))
602
+ )
603
+ }
604
+
605
+ /**
606
+ * Get default multiplier basis points
607
+ * @param tx - The transaction to add the move call to
608
+ * @returns Transaction result containing the default multiplier bps
609
+ */
610
+ defaultMultiplierBpsMoveCall(tx: Transaction): TransactionResult {
611
+ return tx.moveCall({
612
+ target: this.#target('default_multiplier_bps'),
613
+ arguments: [tx.object(this.objects.dvn)],
614
+ })
615
+ }
616
+
617
+ /**
618
+ * Get default multiplier basis points
619
+ * @returns Promise<number> - The default multiplier in basis points
620
+ */
621
+ async defaultMultiplierBps(): Promise<number> {
622
+ return executeSimulate(
623
+ this.client,
624
+ (tx) => {
625
+ this.defaultMultiplierBpsMoveCall(tx)
626
+ },
627
+ (result) => bcs.U16.parse(result[0].value)
628
+ )
629
+ }
630
+
631
+ /**
632
+ * Get DVN deposit address for fee collection
633
+ * @param tx - The transaction to add the move call to
634
+ * @returns Transaction result containing the deposit address
635
+ */
636
+ depositAddressMoveCall(tx: Transaction): TransactionResult {
637
+ return tx.moveCall({
638
+ target: this.#target('deposit_address'),
639
+ arguments: [tx.object(this.objects.dvn)],
640
+ })
641
+ }
642
+
643
+ /**
644
+ * Get DVN deposit address for fee collection
645
+ * @returns Promise<string> - The deposit address
646
+ */
647
+ async depositAddress(): Promise<string> {
648
+ return executeSimulate(
649
+ this.client,
650
+ (tx) => {
651
+ this.depositAddressMoveCall(tx)
652
+ },
653
+ (result) => bcs.Address.parse(result[0].value)
654
+ )
655
+ }
656
+
657
+ /**
658
+ * Get destination configuration for DVN
659
+ * @param tx - The transaction to add the move call to
660
+ * @param dstEid - Destination endpoint ID
661
+ * @returns Transaction result containing the destination configuration
662
+ */
663
+ dstConfigMoveCall(tx: Transaction, dstEid: number | TransactionArgument): TransactionResult {
664
+ return tx.moveCall({
665
+ target: this.#target('dst_config'),
666
+ arguments: [tx.object(this.objects.dvn), asU32(tx, dstEid)],
667
+ })
668
+ }
669
+
670
+ /**
671
+ * Get destination configuration for DVN
672
+ * @param dstEid - Destination endpoint ID
673
+ * @returns Promise<DvnDstConfig> - The destination configuration
674
+ */
675
+ async dstConfig(dstEid: number): Promise<DvnDstConfig> {
676
+ return executeSimulate(
677
+ this.client,
678
+ (tx) => {
679
+ this.dstConfigMoveCall(tx, dstEid)
680
+ },
681
+ (result) => {
682
+ const value = DvnDstConfigBcs.parse(result[0].value)
683
+ return {
684
+ gas: BigInt(value.gas),
685
+ multiplierBps: value.multiplier_bps,
686
+ floorMarginUsd: BigInt(value.floor_margin_usd),
687
+ }
688
+ }
689
+ )
690
+ }
691
+
692
+ /**
693
+ * Check if an address has ACL (Access Control List) permission
694
+ * @param tx - The transaction to add the move call to
695
+ * @param account - The account address to check
696
+ * @returns Transaction result containing the ACL permission status
697
+ */
698
+ hasAclMoveCall(tx: Transaction, account: string | TransactionArgument): TransactionResult {
699
+ return tx.moveCall({
700
+ target: this.#target('has_acl'),
701
+ arguments: [tx.object(this.objects.dvn), asAddress(tx, account)],
702
+ })
703
+ }
704
+
705
+ /**
706
+ * Check if an address has ACL (Access Control List) permission
707
+ * @param account - The account address to check
708
+ * @returns Promise<boolean> - True if the address has ACL permission
709
+ */
710
+ async hasAcl(account: string): Promise<boolean> {
711
+ return executeSimulate(
712
+ this.client,
713
+ (tx) => {
714
+ this.hasAclMoveCall(tx, account)
715
+ },
716
+ (result) => bcs.Bool.parse(result[0].value)
717
+ )
718
+ }
719
+
720
+ /**
721
+ * Get all registered DVN admins
722
+ * @param tx - The transaction to add the move call to
723
+ * @returns Transaction result containing array of admin addresses
724
+ */
725
+ adminsMoveCall(tx: Transaction): TransactionResult {
726
+ return tx.moveCall({
727
+ target: this.#target('admins'),
728
+ arguments: [tx.object(this.objects.dvn)],
729
+ })
730
+ }
731
+
732
+ /**
733
+ * Get all registered DVN admins
734
+ * @returns Promise<string[]> - Array of admin addresses
735
+ */
736
+ async admins(): Promise<string[]> {
737
+ return executeSimulate(
738
+ this.client,
739
+ (tx) => {
740
+ this.adminsMoveCall(tx)
741
+ },
742
+ (result) => {
743
+ const parsed = bcs.vector(bcs.Address).parse(result[0].value)
744
+ return parsed
745
+ }
746
+ )
747
+ }
748
+
749
+ /**
750
+ * Check if an admin cap is valid
751
+ * @param tx - The transaction to add the move call to
752
+ * @param adminCap - The admin capability object ID to check
753
+ * @returns Transaction result containing the admin status
754
+ */
755
+ isAdminMoveCall(tx: Transaction, adminCap: string | TransactionArgument): TransactionResult {
756
+ return tx.moveCall({
757
+ target: this.#target('is_admin'),
758
+ arguments: [tx.object(this.objects.dvn), asObject(tx, adminCap)],
759
+ })
760
+ }
761
+
762
+ /**
763
+ * Check if an admin cap is valid
764
+ * @param adminCap - The admin capability object ID to check
765
+ * @returns Promise<boolean> - True if the admin cap is valid
766
+ */
767
+ async isAdmin(adminCap: string): Promise<boolean> {
768
+ return executeSimulate(
769
+ this.client,
770
+ (tx) => {
771
+ this.isAdminMoveCall(tx, adminCap)
772
+ },
773
+ (result) => bcs.Bool.parse(result[0].value)
774
+ )
775
+ }
776
+
777
+ /**
778
+ * Check if an address is an admin
779
+ * @param tx - The transaction to add the move call to
780
+ * @param admin - The admin address to check
781
+ * @returns Transaction result containing the admin status
782
+ */
783
+ isAdminAddressMoveCall(tx: Transaction, admin: string | TransactionArgument): TransactionResult {
784
+ return tx.moveCall({
785
+ target: this.#target('is_admin_address'),
786
+ arguments: [tx.object(this.objects.dvn), asAddress(tx, admin)],
787
+ })
788
+ }
789
+
790
+ /**
791
+ * Check if an address is an admin
792
+ * @param admin - The admin address to check
793
+ * @returns Promise<boolean> - True if the address is an admin
794
+ */
795
+ async isAdminAddress(admin: string): Promise<boolean> {
796
+ return executeSimulate(
797
+ this.client,
798
+ (tx) => {
799
+ this.isAdminAddressMoveCall(tx, admin)
800
+ },
801
+ (result) => bcs.Bool.parse(result[0].value)
802
+ )
803
+ }
804
+
805
+ /**
806
+ * Check if a message library is supported by this DVN
807
+ * @param tx - The transaction to add the move call to
808
+ * @param messageLib - The message library address to check
809
+ * @returns Transaction result containing the support status
810
+ */
811
+ isSupportedMessageLibMoveCall(tx: Transaction, messageLib: string | TransactionArgument): TransactionResult {
812
+ return tx.moveCall({
813
+ target: this.#target('is_supported_message_lib'),
814
+ arguments: [tx.object(this.objects.dvn), asAddress(tx, messageLib)],
815
+ })
816
+ }
817
+
818
+ /**
819
+ * Check if a message library is supported by this DVN
820
+ * @param messageLib - The message library address to check
821
+ * @returns Promise<boolean> - True if the message library is supported
822
+ */
823
+ async isSupportedMessageLib(messageLib: string): Promise<boolean> {
824
+ return executeSimulate(
825
+ this.client,
826
+ (tx) => {
827
+ this.isSupportedMessageLibMoveCall(tx, messageLib)
828
+ },
829
+ (result) => bcs.Bool.parse(result[0].value)
830
+ )
831
+ }
832
+
833
+ /**
834
+ * Check if an address is allowlisted
835
+ * @param tx - The transaction to add the move call to
836
+ * @param account - The account address to check
837
+ * @returns Transaction result containing the allowlist status
838
+ */
839
+ isAllowlistedMoveCall(tx: Transaction, account: string | TransactionArgument): TransactionResult {
840
+ return tx.moveCall({
841
+ target: this.#target('is_allowlisted'),
842
+ arguments: [tx.object(this.objects.dvn), asAddress(tx, account)],
843
+ })
844
+ }
845
+
846
+ /**
847
+ * Check if an address is in the allowlist
848
+ * @param account - The account address to check
849
+ * @returns Promise<boolean> - True if the address is allowlisted
850
+ */
851
+ async isAllowlisted(account: string): Promise<boolean> {
852
+ return executeSimulate(
853
+ this.client,
854
+ (tx) => {
855
+ this.isAllowlistedMoveCall(tx, account)
856
+ },
857
+ (result) => bcs.Bool.parse(result[0].value)
858
+ )
859
+ }
860
+
861
+ /**
862
+ * Check if an address is denylisted
863
+ * @param tx - The transaction to add the move call to
864
+ * @param account - The account address to check
865
+ * @returns Transaction result containing the denylist status
866
+ */
867
+ isDenylistedMoveCall(tx: Transaction, account: string | TransactionArgument): TransactionResult {
868
+ return tx.moveCall({
869
+ target: this.#target('is_denylisted'),
870
+ arguments: [tx.object(this.objects.dvn), asAddress(tx, account)],
871
+ })
872
+ }
873
+
874
+ /**
875
+ * Check if an address is in the denylist
876
+ * @param account - The account address to check
877
+ * @returns Promise<boolean> - True if the address is denylisted
878
+ */
879
+ async isDenylisted(account: string): Promise<boolean> {
880
+ return executeSimulate(
881
+ this.client,
882
+ (tx) => {
883
+ this.isDenylistedMoveCall(tx, account)
884
+ },
885
+ (result) => bcs.Bool.parse(result[0].value)
886
+ )
887
+ }
888
+
889
+ /**
890
+ * Check if DVN is paused
891
+ * @param tx - The transaction to add the move call to
892
+ * @returns Transaction result containing the paused status
893
+ */
894
+ isPausedMoveCall(tx: Transaction): TransactionResult {
895
+ return tx.moveCall({
896
+ target: this.#target('is_paused'),
897
+ arguments: [tx.object(this.objects.dvn)],
898
+ })
899
+ }
900
+
901
+ /**
902
+ * Check if DVN worker is paused
903
+ * @returns Promise<boolean> - True if the worker is paused
904
+ */
905
+ async isPaused(): Promise<boolean> {
906
+ return executeSimulate(
907
+ this.client,
908
+ (tx) => {
909
+ this.isPausedMoveCall(tx)
910
+ },
911
+ (result) => bcs.Bool.parse(result[0].value)
912
+ )
913
+ }
914
+
915
+ /**
916
+ * Check if an address is a registered DVN signer
917
+ * @param tx - The transaction to add the move call to
918
+ * @param signer - The signer public key as bytes
919
+ * @returns Transaction result containing the signer status
920
+ */
921
+ isSignerMoveCall(tx: Transaction, signer: Uint8Array | TransactionArgument): TransactionResult {
922
+ return tx.moveCall({
923
+ target: this.#target('is_signer'),
924
+ arguments: [tx.object(this.objects.dvn), asBytes(tx, signer)],
925
+ })
926
+ }
927
+
928
+ /**
929
+ * Check if an address is a registered DVN signer
930
+ * @param signer - The signer public key as bytes
931
+ * @returns Promise<boolean> - True if the address is a registered signer
932
+ */
933
+ async isSigner(signer: Uint8Array): Promise<boolean> {
934
+ return executeSimulate(
935
+ this.client,
936
+ (tx) => {
937
+ this.isSignerMoveCall(tx, signer)
938
+ },
939
+ (result) => bcs.Bool.parse(result[0].value)
940
+ )
941
+ }
942
+
943
+ /**
944
+ * Get DVN price feed address
945
+ * @param tx - The transaction to add the move call to
946
+ * @returns Transaction result containing the price feed address
947
+ */
948
+ priceFeedMoveCall(tx: Transaction): TransactionResult {
949
+ return tx.moveCall({
950
+ target: this.#target('price_feed'),
951
+ arguments: [tx.object(this.objects.dvn)],
952
+ })
953
+ }
954
+
955
+ /**
956
+ * Get DVN price feed address
957
+ * @returns Promise<string> - The price feed address
958
+ */
959
+ async priceFeed(): Promise<string> {
960
+ return executeSimulate(
961
+ this.client,
962
+ (tx) => {
963
+ this.priceFeedMoveCall(tx)
964
+ },
965
+ (result) => bcs.Address.parse(result[0].value)
966
+ )
967
+ }
968
+
969
+ /**
970
+ * Get DVN quorum threshold
971
+ * @param tx - The transaction to add the move call to
972
+ * @returns Transaction result containing the quorum threshold
973
+ */
974
+ quorumMoveCall(tx: Transaction): TransactionResult {
975
+ return tx.moveCall({
976
+ target: this.#target('quorum'),
977
+ arguments: [tx.object(this.objects.dvn)],
978
+ })
979
+ }
980
+
981
+ /**
982
+ * Get DVN quorum threshold
983
+ * @returns Promise<bigint> - The quorum threshold
984
+ */
985
+ async quorum(): Promise<bigint> {
986
+ return executeSimulate(
987
+ this.client,
988
+ (tx) => {
989
+ this.quorumMoveCall(tx)
990
+ },
991
+ (result) => BigInt(bcs.U64.parse(result[0].value))
992
+ )
993
+ }
994
+
995
+ /**
996
+ * Get the total count of registered DVN signers
997
+ * @param tx - The transaction to add the move call to
998
+ * @returns Transaction result containing the signer count
999
+ */
1000
+ signerCountMoveCall(tx: Transaction): TransactionResult {
1001
+ return tx.moveCall({
1002
+ target: this.#target('signer_count'),
1003
+ arguments: [tx.object(this.objects.dvn)],
1004
+ })
1005
+ }
1006
+
1007
+ /**
1008
+ * Get the total count of registered DVN signers
1009
+ * @returns Promise<bigint> - The number of registered signers
1010
+ */
1011
+ async signerCount(): Promise<bigint> {
1012
+ return executeSimulate(
1013
+ this.client,
1014
+ (tx) => {
1015
+ this.signerCountMoveCall(tx)
1016
+ },
1017
+ (result) => BigInt(bcs.U64.parse(result[0].value))
1018
+ )
1019
+ }
1020
+
1021
+ /**
1022
+ * Get all registered DVN signers
1023
+ * @param tx - The transaction to add the move call to
1024
+ * @returns Transaction result containing array of signer public keys
1025
+ */
1026
+ signersMoveCall(tx: Transaction): TransactionResult {
1027
+ return tx.moveCall({
1028
+ target: this.#target('signers'),
1029
+ arguments: [tx.object(this.objects.dvn)],
1030
+ })
1031
+ }
1032
+
1033
+ /**
1034
+ * Get all registered DVN signers
1035
+ * @returns Promise<Uint8Array[]> - Array of signer public keys as byte arrays
1036
+ */
1037
+ async signers(): Promise<Uint8Array[]> {
1038
+ return executeSimulate(
1039
+ this.client,
1040
+ (tx) => {
1041
+ this.signersMoveCall(tx)
1042
+ },
1043
+ (result) => {
1044
+ const parsed = bcs.vector(bcs.vector(bcs.u8())).parse(result[0].value)
1045
+ return parsed.map((signer) => Buffer.from(signer))
1046
+ }
1047
+ )
1048
+ }
1049
+
1050
+ /**
1051
+ * Get supported option types for a destination EID
1052
+ * @param tx - The transaction to add the move call to
1053
+ * @param dstEid - Destination endpoint ID
1054
+ * @returns Transaction result containing supported option types
1055
+ */
1056
+ supportedOptionTypesMoveCall(tx: Transaction, dstEid: number | TransactionArgument): TransactionResult {
1057
+ return tx.moveCall({
1058
+ target: this.#target('supported_option_types'),
1059
+ arguments: [tx.object(this.objects.dvn), asU32(tx, dstEid)],
1060
+ })
1061
+ }
1062
+
1063
+ /**
1064
+ * Get supported option types for a destination EID
1065
+ * @param dstEid - Destination endpoint ID
1066
+ * @returns Promise<Uint8Array> - Array of supported option types as bytes
1067
+ */
1068
+ async supportedOptionTypes(dstEid: number): Promise<Uint8Array> {
1069
+ return executeSimulate(
1070
+ this.client,
1071
+ (tx) => {
1072
+ this.supportedOptionTypesMoveCall(tx, dstEid)
1073
+ },
1074
+ (result) => {
1075
+ const parsed = bcs.vector(bcs.u8()).parse(result[0].value)
1076
+ return Buffer.from(parsed)
1077
+ }
1078
+ )
1079
+ }
1080
+
1081
+ /**
1082
+ * Get DVN Verifier ID (VID)
1083
+ * @param tx - The transaction to add the move call to
1084
+ * @returns Transaction result containing the VID
1085
+ */
1086
+ vidMoveCall(tx: Transaction): TransactionResult {
1087
+ return tx.moveCall({
1088
+ target: this.#target('vid'),
1089
+ arguments: [tx.object(this.objects.dvn)],
1090
+ })
1091
+ }
1092
+
1093
+ /**
1094
+ * Get DVN VID (Verifier ID)
1095
+ * @returns Promise<number> - The DVN verifier ID
1096
+ */
1097
+ async vid(): Promise<number> {
1098
+ return executeSimulate(
1099
+ this.client,
1100
+ (tx) => {
1101
+ this.vidMoveCall(tx)
1102
+ },
1103
+ (result) => bcs.U32.parse(result[0].value)
1104
+ )
1105
+ }
1106
+
1107
+ /**
1108
+ * Get DVN worker capability address
1109
+ * @param tx - The transaction to add the move call to
1110
+ * @returns Transaction result containing the worker capability address
1111
+ */
1112
+ workerCapAddressMoveCall(tx: Transaction): TransactionResult {
1113
+ return tx.moveCall({
1114
+ target: this.#target('worker_cap_address'),
1115
+ arguments: [tx.object(this.objects.dvn)],
1116
+ })
1117
+ }
1118
+
1119
+ /**
1120
+ * Get DVN worker capability address
1121
+ * @returns Promise<string> - The worker capability address
1122
+ */
1123
+ async workerCapAddress(): Promise<string> {
1124
+ return executeSimulate(
1125
+ this.client,
1126
+ (tx) => {
1127
+ this.workerCapAddressMoveCall(tx)
1128
+ },
1129
+ (result) => bcs.Address.parse(result[0].value)
1130
+ )
1131
+ }
1132
+
1133
+ /**
1134
+ * Get DVN worker fee library address
1135
+ * @param tx - The transaction to add the move call to
1136
+ * @returns Transaction result containing the worker fee library address
1137
+ */
1138
+ workerFeeLibMoveCall(tx: Transaction): TransactionResult {
1139
+ return tx.moveCall({
1140
+ target: this.#target('worker_fee_lib'),
1141
+ arguments: [tx.object(this.objects.dvn)],
1142
+ })
1143
+ }
1144
+
1145
+ /**
1146
+ * Get DVN worker fee library address
1147
+ * @returns Promise<string> - The worker fee library address
1148
+ */
1149
+ async workerFeeLib(): Promise<string> {
1150
+ return executeSimulate(
1151
+ this.client,
1152
+ (tx) => {
1153
+ this.workerFeeLibMoveCall(tx)
1154
+ },
1155
+ (result) => bcs.Address.parse(result[0].value)
1156
+ )
1157
+ }
1158
+
1159
+ /**
1160
+ * Get admin capability ID from admin address
1161
+ * @param tx - The transaction to add the move call to
1162
+ * @param admin - The admin address
1163
+ * @returns Transaction result containing the admin capability ID
1164
+ */
1165
+ adminCapIdMoveCall(tx: Transaction, admin: string | TransactionArgument): TransactionResult {
1166
+ return tx.moveCall({
1167
+ target: this.#target('admin_cap_id'),
1168
+ arguments: [tx.object(this.objects.dvn), asAddress(tx, admin)],
1169
+ })
1170
+ }
1171
+
1172
+ /**
1173
+ * Get admin capability ID from admin address
1174
+ * @param admin - The admin address
1175
+ * @returns Promise<string> - The admin capability ID
1176
+ */
1177
+ async adminCapId(admin: string): Promise<string> {
1178
+ return executeSimulate(
1179
+ this.client,
1180
+ (tx) => {
1181
+ this.adminCapIdMoveCall(tx, admin)
1182
+ },
1183
+ (result) => bcs.Address.parse(result[0].value)
1184
+ )
1185
+ }
1186
+
1187
+ /**
1188
+ * Check if PTB builder has been initialized
1189
+ * @param tx - The transaction to add the move call to
1190
+ * @returns Transaction result containing the PTB builder initialization status
1191
+ */
1192
+ isPtbBuilderInitializedMoveCall(tx: Transaction): TransactionResult {
1193
+ return tx.moveCall({
1194
+ target: this.#target('is_ptb_builder_initialized'),
1195
+ arguments: [tx.object(this.objects.dvn)],
1196
+ })
1197
+ }
1198
+
1199
+ /**
1200
+ * Check if PTB builder has been initialized
1201
+ * @returns Promise<boolean> - True if the PTB builder has been initialized
1202
+ */
1203
+ async isPtbBuilderInitialized(): Promise<boolean> {
1204
+ return executeSimulate(
1205
+ this.client,
1206
+ (tx) => {
1207
+ this.isPtbBuilderInitializedMoveCall(tx)
1208
+ },
1209
+ (result) => bcs.Bool.parse(result[0].value)
1210
+ )
1211
+ }
1212
+
1213
+ /**
1214
+ * Get DVN object address from worker registry using this DVN's worker capability (as a move call)
1215
+ * This function chains Move calls to decode worker info and extract the DVN object address
1216
+ * @param tx - The transaction to add the move call to
1217
+ * @returns Transaction result containing the DVN object address
1218
+ */
1219
+ getDvnObjectAddressMoveCall(tx: Transaction): TransactionResult {
1220
+ // Step 1: Get this DVN's worker capability address
1221
+ const workerCapAddress = this.workerCapAddressMoveCall(tx)
1222
+
1223
+ // Step 2: Get worker info bytes from registry
1224
+ const workerInfoBytes = this.moduleManager
1225
+ .getWorkerRegistry(this.client)
1226
+ .getWorkerInfoMoveCall(tx, workerCapAddress)
1227
+
1228
+ // Step 3: Decode worker info using worker_common::worker_info_v1::decode
1229
+ const workerInfo = tx.moveCall({
1230
+ target: `${this.moduleManager.packages.workerCommon}::worker_info_v1::decode`,
1231
+ arguments: [workerInfoBytes],
1232
+ })
1233
+
1234
+ // Step 4: Extract worker_info field from decoded WorkerInfoV1
1235
+ const dvnInfoBytes = tx.moveCall({
1236
+ target: `${this.moduleManager.packages.workerCommon}::worker_info_v1::worker_info`,
1237
+ arguments: [workerInfo],
1238
+ })
1239
+
1240
+ // Step 5: Decode DVN info using dvn::dvn_info_v1::decode
1241
+ const dvnInfo = tx.moveCall({
1242
+ target: `${this.packageId}::dvn_info_v1::decode`,
1243
+ arguments: [dvnInfoBytes],
1244
+ })
1245
+
1246
+ // Step 6: Extract dvn_object address from decoded DVNInfoV1
1247
+ return tx.moveCall({
1248
+ target: `${this.packageId}::dvn_info_v1::dvn_object`,
1249
+ arguments: [dvnInfo],
1250
+ })
1251
+ }
1252
+
1253
+ /**
1254
+ * Get DVN object address from worker registry using this DVN's worker capability
1255
+ * This function uses Move calls to decode worker info and extract the DVN object address
1256
+ * @returns Promise<string> - The DVN object address
1257
+ * @throws Will throw an error if worker info is not found or if decoding fails
1258
+ */
1259
+ async getDvnObjectAddress(): Promise<string> {
1260
+ return executeSimulate(
1261
+ this.client,
1262
+ (tx) => {
1263
+ this.getDvnObjectAddressMoveCall(tx)
1264
+ },
1265
+ (result) => {
1266
+ // The result is the DVN object address directly from the Move call chain
1267
+ return bcs.Address.parse(result[0].value)
1268
+ }
1269
+ )
1270
+ }
1271
+
1272
+ // === Witness Functions ===
1273
+
1274
+ /**
1275
+ * Create a LayerZero witness for DVN package whitelist registration
1276
+ * @param tx - The transaction to add the move call to
1277
+ * @returns Transaction result containing the LayerZero witness
1278
+ */
1279
+ createLayerZeroWitnessMoveCall(tx: Transaction): TransactionResult {
1280
+ return tx.moveCall({
1281
+ target: `${this.packageId}::dvn_witness::new`,
1282
+ arguments: [],
1283
+ })
1284
+ }
1285
+
1286
+ // === Hash Functions ===
1287
+
1288
+ /**
1289
+ * Create a verify hash for packet verification
1290
+ * @param tx - The transaction to add the move call to
1291
+ * @param packetHeader - The packet header as bytes
1292
+ * @param payloadHash - The payload hash as bytes
1293
+ * @param confirmations - Required confirmations count
1294
+ * @param target - Target address for verification
1295
+ * @param vid - Verifier ID
1296
+ * @param expiration - Signature expiration timestamp
1297
+ * @returns Transaction result containing the verify hash
1298
+ */
1299
+ createVerifyHashMoveCall(
1300
+ tx: Transaction,
1301
+ packetHeader: Uint8Array | TransactionArgument,
1302
+ payloadHash: Uint8Array | TransactionArgument,
1303
+ confirmations: bigint | number | string | TransactionArgument,
1304
+ target: string | TransactionArgument,
1305
+ vid: number | TransactionArgument,
1306
+ expiration: bigint | number | string | TransactionArgument
1307
+ ): TransactionResult {
1308
+ return tx.moveCall({
1309
+ target: this.#target('create_verify_hash', 'hashes'),
1310
+ arguments: [
1311
+ asBytes(tx, packetHeader),
1312
+ asBytes(tx, payloadHash),
1313
+ asU64(tx, confirmations),
1314
+ asAddress(tx, target),
1315
+ asU32(tx, vid),
1316
+ asU64(tx, expiration),
1317
+ ],
1318
+ })
1319
+ }
1320
+
1321
+ /**
1322
+ * Create a verify hash for packet verification
1323
+ * @param packetHeader - The packet header as bytes
1324
+ * @param payloadHash - The payload hash as bytes
1325
+ * @param confirmations - Required confirmations count
1326
+ * @param target - Target address for verification
1327
+ * @param vid - Verifier ID
1328
+ * @param expiration - Signature expiration timestamp
1329
+ * @returns Promise<Uint8Array> - The verify hash as bytes
1330
+ */
1331
+ async createVerifyHash(
1332
+ packetHeader: Uint8Array,
1333
+ payloadHash: Uint8Array,
1334
+ confirmations: bigint,
1335
+ target: string,
1336
+ vid: number,
1337
+ expiration: bigint
1338
+ ): Promise<Uint8Array> {
1339
+ return executeSimulate(
1340
+ this.client,
1341
+ (tx) => {
1342
+ this.createVerifyHashMoveCall(tx, packetHeader, payloadHash, confirmations, target, vid, expiration)
1343
+ },
1344
+ (result) => {
1345
+ const bytes32Struct = Bytes32Bcs.parse(result[0].value)
1346
+ return Buffer.from(bytes32Struct.bytes)
1347
+ }
1348
+ )
1349
+ }
1350
+
1351
+ /**
1352
+ * Create a set DVN signer hash for signature verification
1353
+ * @param tx - The transaction to add the move call to
1354
+ * @param signer - The signer public key as bytes
1355
+ * @param active - Whether to activate or deactivate the signer
1356
+ * @param vid - Verifier ID
1357
+ * @param expiration - Signature expiration timestamp
1358
+ * @returns Transaction result containing the set DVN signer hash
1359
+ */
1360
+ createSetDvnSignerHashMoveCall(
1361
+ tx: Transaction,
1362
+ signer: Uint8Array | TransactionArgument,
1363
+ active: boolean | TransactionArgument,
1364
+ vid: number | TransactionArgument,
1365
+ expiration: bigint | number | string | TransactionArgument
1366
+ ): TransactionResult {
1367
+ return tx.moveCall({
1368
+ target: this.#target('create_set_dvn_signer_hash', 'hashes'),
1369
+ arguments: [asBytes(tx, signer), asBool(tx, active), asU32(tx, vid), asU64(tx, expiration)],
1370
+ })
1371
+ }
1372
+
1373
+ /**
1374
+ * Create a set DVN signer hash for signature verification
1375
+ * @param signer - The signer public key as bytes
1376
+ * @param active - Whether to activate or deactivate the signer
1377
+ * @param vid - Verifier ID
1378
+ * @param expiration - Signature expiration timestamp
1379
+ * @returns Promise<Uint8Array> - The set DVN signer hash as bytes
1380
+ */
1381
+ async createSetDvnSignerHash(
1382
+ signer: Uint8Array,
1383
+ active: boolean,
1384
+ vid: number,
1385
+ expiration: bigint
1386
+ ): Promise<Uint8Array> {
1387
+ return executeSimulate(
1388
+ this.client,
1389
+ (tx) => {
1390
+ this.createSetDvnSignerHashMoveCall(tx, signer, active, vid, expiration)
1391
+ },
1392
+ (result) => {
1393
+ const bytes32Struct = Bytes32Bcs.parse(result[0].value)
1394
+ return Buffer.from(bytes32Struct.bytes)
1395
+ }
1396
+ )
1397
+ }
1398
+
1399
+ /**
1400
+ * Create a set quorum hash for signature verification
1401
+ * @param tx - The transaction to add the move call to
1402
+ * @param quorum - The new quorum threshold
1403
+ * @param vid - Verifier ID
1404
+ * @param expiration - Signature expiration timestamp
1405
+ * @returns Transaction result containing the set quorum hash
1406
+ */
1407
+ createSetQuorumHashMoveCall(
1408
+ tx: Transaction,
1409
+ quorum: bigint | number | string | TransactionArgument,
1410
+ vid: number | TransactionArgument,
1411
+ expiration: bigint | number | string | TransactionArgument
1412
+ ): TransactionResult {
1413
+ return tx.moveCall({
1414
+ target: this.#target('create_set_quorum_hash', 'hashes'),
1415
+ arguments: [asU64(tx, quorum), asU32(tx, vid), asU64(tx, expiration)],
1416
+ })
1417
+ }
1418
+
1419
+ /**
1420
+ * Create a set quorum hash for signature verification
1421
+ * @param quorum - The new quorum threshold
1422
+ * @param vid - Verifier ID
1423
+ * @param expiration - Signature expiration timestamp
1424
+ * @returns Promise<Uint8Array> - The set quorum hash as bytes
1425
+ */
1426
+ async createSetQuorumHash(quorum: bigint, vid: number, expiration: bigint): Promise<Uint8Array> {
1427
+ return executeSimulate(
1428
+ this.client,
1429
+ (tx) => {
1430
+ this.createSetQuorumHashMoveCall(tx, quorum, vid, expiration)
1431
+ },
1432
+ (result) => {
1433
+ const bytes32Struct = Bytes32Bcs.parse(result[0].value)
1434
+ return Buffer.from(bytes32Struct.bytes)
1435
+ }
1436
+ )
1437
+ }
1438
+
1439
+ /**
1440
+ * Create a quorum change admin hash for signature verification
1441
+ * @param tx - The transaction to add the move call to
1442
+ * @param admin - The admin address to change
1443
+ * @param active - Whether to activate or deactivate the admin
1444
+ * @param vid - Verifier ID
1445
+ * @param expiration - Signature expiration timestamp
1446
+ * @returns Transaction result containing the quorum change admin hash
1447
+ */
1448
+ createQuorumChangeAdminHashMoveCall(
1449
+ tx: Transaction,
1450
+ admin: string | TransactionArgument,
1451
+ active: boolean | TransactionArgument,
1452
+ vid: number | TransactionArgument,
1453
+ expiration: bigint | number | string | TransactionArgument
1454
+ ): TransactionResult {
1455
+ return tx.moveCall({
1456
+ target: this.#target('create_quorum_change_admin_hash', 'hashes'),
1457
+ arguments: [asAddress(tx, admin), asBool(tx, active), asU32(tx, vid), asU64(tx, expiration)],
1458
+ })
1459
+ }
1460
+
1461
+ /**
1462
+ * Create a quorum change admin hash for signature verification
1463
+ * @param admin - The admin address to change
1464
+ * @param active - Whether to activate or deactivate the admin
1465
+ * @param vid - Verifier ID
1466
+ * @param expiration - Signature expiration timestamp
1467
+ * @returns Promise<Uint8Array> - The quorum change admin hash as bytes
1468
+ */
1469
+ async createQuorumChangeAdminHash(
1470
+ admin: string,
1471
+ active: boolean,
1472
+ vid: number,
1473
+ expiration: bigint
1474
+ ): Promise<Uint8Array> {
1475
+ return executeSimulate(
1476
+ this.client,
1477
+ (tx) => {
1478
+ this.createQuorumChangeAdminHashMoveCall(tx, admin, active, vid, expiration)
1479
+ },
1480
+ (result) => {
1481
+ const bytes32Struct = Bytes32Bcs.parse(result[0].value)
1482
+ return Buffer.from(bytes32Struct.bytes)
1483
+ }
1484
+ )
1485
+ }
1486
+
1487
+ /**
1488
+ * Create a set allowlist hash for signature verification
1489
+ * @param tx - The transaction to add the move call to
1490
+ * @param oapp - The OApp address to allowlist/remove
1491
+ * @param allowed - Whether to allow or remove from allowlist
1492
+ * @param vid - Verifier ID
1493
+ * @param expiration - Signature expiration timestamp
1494
+ * @returns Transaction result containing the set allowlist hash
1495
+ */
1496
+ createSetAllowlistHashMoveCall(
1497
+ tx: Transaction,
1498
+ oapp: string | TransactionArgument,
1499
+ allowed: boolean | TransactionArgument,
1500
+ vid: number | TransactionArgument,
1501
+ expiration: bigint | number | string | TransactionArgument
1502
+ ): TransactionResult {
1503
+ return tx.moveCall({
1504
+ target: this.#target('create_set_allowlist_hash', 'hashes'),
1505
+ arguments: [asAddress(tx, oapp), asBool(tx, allowed), asU32(tx, vid), asU64(tx, expiration)],
1506
+ })
1507
+ }
1508
+
1509
+ /**
1510
+ * Create a set allowlist hash for signature verification
1511
+ * @param oapp - The OApp address to allowlist/remove
1512
+ * @param allowed - Whether to allow or remove from allowlist
1513
+ * @param vid - Verifier ID
1514
+ * @param expiration - Signature expiration timestamp
1515
+ * @returns Promise<Uint8Array> - The set allowlist hash as bytes
1516
+ */
1517
+ async createSetAllowlistHash(oapp: string, allowed: boolean, vid: number, expiration: bigint): Promise<Uint8Array> {
1518
+ return executeSimulate(
1519
+ this.client,
1520
+ (tx) => {
1521
+ this.createSetAllowlistHashMoveCall(tx, oapp, allowed, vid, expiration)
1522
+ },
1523
+ (result) => {
1524
+ const bytes32Struct = Bytes32Bcs.parse(result[0].value)
1525
+ return Buffer.from(bytes32Struct.bytes)
1526
+ }
1527
+ )
1528
+ }
1529
+
1530
+ /**
1531
+ * Create a set denylist hash for signature verification
1532
+ * @param tx - The transaction to add the move call to
1533
+ * @param oapp - The OApp address to denylist/remove
1534
+ * @param denied - Whether to deny or remove from denylist
1535
+ * @param vid - Verifier ID
1536
+ * @param expiration - Signature expiration timestamp
1537
+ * @returns Transaction result containing the set denylist hash
1538
+ */
1539
+ createSetDenylistHashMoveCall(
1540
+ tx: Transaction,
1541
+ oapp: string | TransactionArgument,
1542
+ denied: boolean | TransactionArgument,
1543
+ vid: number | TransactionArgument,
1544
+ expiration: bigint | number | string | TransactionArgument
1545
+ ): TransactionResult {
1546
+ return tx.moveCall({
1547
+ target: this.#target('create_set_denylist_hash', 'hashes'),
1548
+ arguments: [asAddress(tx, oapp), asBool(tx, denied), asU32(tx, vid), asU64(tx, expiration)],
1549
+ })
1550
+ }
1551
+
1552
+ /**
1553
+ * Create a set denylist hash for signature verification
1554
+ * @param oapp - The OApp address to denylist/remove
1555
+ * @param denied - Whether to deny or remove from denylist
1556
+ * @param vid - Verifier ID
1557
+ * @param expiration - Signature expiration timestamp
1558
+ * @returns Promise<Uint8Array> - The set denylist hash as bytes
1559
+ */
1560
+ async createSetDenylistHash(oapp: string, denied: boolean, vid: number, expiration: bigint): Promise<Uint8Array> {
1561
+ return executeSimulate(
1562
+ this.client,
1563
+ (tx) => {
1564
+ this.createSetDenylistHashMoveCall(tx, oapp, denied, vid, expiration)
1565
+ },
1566
+ (result) => {
1567
+ const bytes32Struct = Bytes32Bcs.parse(result[0].value)
1568
+ return Buffer.from(bytes32Struct.bytes)
1569
+ }
1570
+ )
1571
+ }
1572
+
1573
+ /**
1574
+ * Create a set pause hash for signature verification
1575
+ * @param tx - The transaction to add the move call to
1576
+ * @param paused - Whether to pause or unpause the DVN
1577
+ * @param vid - Verifier ID
1578
+ * @param expiration - Signature expiration timestamp
1579
+ * @returns Transaction result containing the set pause hash
1580
+ */
1581
+ createSetPauseHashMoveCall(
1582
+ tx: Transaction,
1583
+ paused: boolean | TransactionArgument,
1584
+ vid: number | TransactionArgument,
1585
+ expiration: bigint | number | string | TransactionArgument
1586
+ ): TransactionResult {
1587
+ return tx.moveCall({
1588
+ target: this.#target('create_set_pause_hash', 'hashes'),
1589
+ arguments: [asBool(tx, paused), asU32(tx, vid), asU64(tx, expiration)],
1590
+ })
1591
+ }
1592
+
1593
+ /**
1594
+ * Create a set pause hash for signature verification
1595
+ * @param paused - Whether to pause or unpause the DVN
1596
+ * @param vid - Verifier ID
1597
+ * @param expiration - Signature expiration timestamp
1598
+ * @returns Promise<Uint8Array> - The set pause hash as bytes
1599
+ */
1600
+ async createSetPauseHash(paused: boolean, vid: number, expiration: bigint): Promise<Uint8Array> {
1601
+ return executeSimulate(
1602
+ this.client,
1603
+ (tx) => {
1604
+ this.createSetPauseHashMoveCall(tx, paused, vid, expiration)
1605
+ },
1606
+ (result) => {
1607
+ const bytes32Struct = Bytes32Bcs.parse(result[0].value)
1608
+ return Buffer.from(bytes32Struct.bytes)
1609
+ }
1610
+ )
1611
+ }
1612
+
1613
+ /**
1614
+ * Create a set PTB builder move calls hash for signature verification
1615
+ * @param tx - The transaction to add the move call to
1616
+ * @param targetPtbBuilder - Target PTB builder address
1617
+ * @param getFeeMoveCalls - Get fee move calls transaction argument
1618
+ * @param assignJobMoveCalls - Assign job move calls transaction argument
1619
+ * @param vid - Verifier ID
1620
+ * @param expiration - Signature expiration timestamp
1621
+ * @returns Transaction result containing the set PTB builder move calls hash
1622
+ */
1623
+ createSetPtbBuilderMoveCallsHashMoveCall(
1624
+ tx: Transaction,
1625
+ targetPtbBuilder: string | TransactionArgument,
1626
+ getFeeMoveCalls: TransactionArgument,
1627
+ assignJobMoveCalls: TransactionArgument,
1628
+ vid: number | TransactionArgument,
1629
+ expiration: bigint | number | string | TransactionArgument
1630
+ ): TransactionResult {
1631
+ return tx.moveCall({
1632
+ target: this.#target('create_set_ptb_builder_move_calls_hash', 'hashes'),
1633
+ arguments: [
1634
+ asAddress(tx, targetPtbBuilder),
1635
+ getFeeMoveCalls,
1636
+ assignJobMoveCalls,
1637
+ asU32(tx, vid),
1638
+ asU64(tx, expiration),
1639
+ ],
1640
+ })
1641
+ }
1642
+
1643
+ /**
1644
+ * Populate verify with DVN verification and ULN verify call
1645
+ * @param tx - The transaction to add the move call to
1646
+ * @param adminCap - The admin capability object ID
1647
+ * @param targetMessageLib - The target message library address (usually ULN302)
1648
+ * @param targetVerification - The verification object address for the target message library
1649
+ * @param packetHeader - The packet header as bytes
1650
+ * @param payloadHash - The payload hash as bytes
1651
+ * @param confirmations - Required confirmations count
1652
+ * @param expiration - Signature expiration timestamp
1653
+ * @param signatures - DVN multisig signatures
1654
+ */
1655
+ populateVerify(
1656
+ tx: Transaction,
1657
+ adminCap: string | TransactionArgument,
1658
+ targetMessageLib: string,
1659
+ targetVerification: string,
1660
+ packetHeader: Uint8Array | TransactionArgument,
1661
+ payloadHash: Uint8Array | TransactionArgument,
1662
+ confirmations: bigint | number | string | TransactionArgument,
1663
+ expiration: bigint | number | string | TransactionArgument,
1664
+ signatures: Uint8Array | TransactionArgument
1665
+ ): void {
1666
+ // Step 1: Call DVN's verifyMoveCall to get the verification call
1667
+ const dvnCall = this.verifyMoveCall(
1668
+ tx,
1669
+ adminCap,
1670
+ targetMessageLib,
1671
+ packetHeader,
1672
+ payloadHash,
1673
+ confirmations,
1674
+ expiration,
1675
+ signatures
1676
+ )
1677
+
1678
+ // Step 2: Get the message library object address based on targetMessageLib
1679
+ const messageLibObjectAddress = this.#getUlnObjectAddress(targetMessageLib)
1680
+
1681
+ tx.moveCall({
1682
+ target: this.#getUlnVerifyTarget(targetMessageLib),
1683
+ arguments: [tx.object(messageLibObjectAddress), asObject(tx, targetVerification), dvnCall],
1684
+ })
1685
+ }
1686
+
1687
+ /**
1688
+ * Get message library object address based on targetMessageLib package address
1689
+ * @param targetMessageLib - The target message library package address
1690
+ * @returns Message library object address
1691
+ * @throws Error if targetMessageLib doesn't match any known message library
1692
+ * @private
1693
+ */
1694
+ #getUlnObjectAddress(targetMessageLib: string): string {
1695
+ // Check if targetMessageLib equals ULN302 package address
1696
+ if (targetMessageLib === this.moduleManager.packages.uln302) {
1697
+ return this.objects.uln302
1698
+ }
1699
+
1700
+ throw new Error('Target message library not match objects')
1701
+ }
1702
+
1703
+ /**
1704
+ * Get ULN verify target path based on targetMessageLib package address
1705
+ * @param targetMessageLib - The target message library package address
1706
+ * @returns Message library verify target path
1707
+ * @throws Error if targetMessageLib doesn't match any known message library
1708
+ * @private
1709
+ */
1710
+ #getUlnVerifyTarget(targetMessageLib: string): string {
1711
+ if (targetMessageLib === this.moduleManager.packages.uln302) {
1712
+ return `${targetMessageLib}::uln_302::verify`
1713
+ }
1714
+
1715
+ throw new Error('Target message library not match any target')
1716
+ }
1717
+ /**
1718
+ * Generate the full target path for move calls
1719
+ * @param name - The function name to call
1720
+ * @param module_name - The module name (defaults to MODULE_NAME)
1721
+ * @returns The full module path for the move call
1722
+ * @private
1723
+ */
1724
+ #target(name: string, module_name = MODULE_NAME): string {
1725
+ return `${this.packageId}::${module_name}::${name}`
1726
+ }
1727
+ }