@layerzerolabs/lz-solana-sdk-v2 3.0.52 → 3.0.54

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 (604) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/index.cjs +2764 -4309
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.mts +14 -115
  5. package/dist/index.d.ts +14 -115
  6. package/dist/index.mjs +2764 -4307
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/umi.cjs +14486 -0
  9. package/dist/umi.cjs.map +1 -0
  10. package/dist/umi.d.mts +8807 -0
  11. package/dist/umi.d.ts +8807 -0
  12. package/dist/umi.mjs +14401 -0
  13. package/dist/umi.mjs.map +1 -0
  14. package/package.json +26 -10
  15. package/src/deployment.test.ts +1 -1
  16. package/src/deployment.ts +2 -2
  17. package/src/dvn.ts +248 -449
  18. package/src/endpoint.ts +793 -964
  19. package/src/executor.ts +286 -413
  20. package/src/generated/kinobi/blocked_messagelib/errors/blockedMessagelib.ts +42 -0
  21. package/src/generated/kinobi/blocked_messagelib/errors/index.ts +9 -0
  22. package/src/generated/kinobi/blocked_messagelib/index.ts +12 -0
  23. package/src/generated/kinobi/blocked_messagelib/instructions/index.ts +9 -0
  24. package/src/generated/kinobi/blocked_messagelib/instructions/version.ts +80 -0
  25. package/src/generated/kinobi/blocked_messagelib/programs/blockedMessagelib.ts +55 -0
  26. package/src/generated/kinobi/blocked_messagelib/programs/index.ts +9 -0
  27. package/src/generated/kinobi/blocked_messagelib/shared/index.ts +117 -0
  28. package/src/generated/kinobi/dvn/accounts/dvnConfig.ts +199 -0
  29. package/src/generated/kinobi/dvn/accounts/executeHash.ts +148 -0
  30. package/src/generated/kinobi/dvn/accounts/index.ts +11 -0
  31. package/src/generated/kinobi/dvn/accounts/receiveConfig.ts +154 -0
  32. package/src/generated/kinobi/dvn/errors/dvn.ts +263 -0
  33. package/src/generated/kinobi/dvn/errors/index.ts +9 -0
  34. package/src/generated/kinobi/dvn/events/adminConfigSetEvent.ts +23 -0
  35. package/src/generated/kinobi/dvn/events/feeWithdrawnEvent.ts +35 -0
  36. package/src/generated/kinobi/dvn/events/index.ts +3 -0
  37. package/src/generated/kinobi/dvn/events/multisigConfigSetEvent.ts +28 -0
  38. package/src/generated/kinobi/dvn/index.ts +14 -0
  39. package/src/generated/kinobi/dvn/instructions/closeExecute.ts +126 -0
  40. package/src/generated/kinobi/dvn/instructions/index.ts +15 -0
  41. package/src/generated/kinobi/dvn/instructions/initDvn.ts +155 -0
  42. package/src/generated/kinobi/dvn/instructions/invoke.ts +161 -0
  43. package/src/generated/kinobi/dvn/instructions/quoteDvn.ts +150 -0
  44. package/src/generated/kinobi/dvn/instructions/setConfig.ts +138 -0
  45. package/src/generated/kinobi/dvn/instructions/verifiable.ts +139 -0
  46. package/src/generated/kinobi/dvn/instructions/withdrawFee.ts +139 -0
  47. package/src/generated/kinobi/dvn/programs/dvn.ts +48 -0
  48. package/src/generated/kinobi/dvn/programs/index.ts +9 -0
  49. package/src/generated/kinobi/dvn/shared/index.ts +117 -0
  50. package/src/generated/kinobi/dvn/types/acl.ts +29 -0
  51. package/src/generated/kinobi/dvn/types/adminConfig.ts +116 -0
  52. package/src/generated/kinobi/dvn/types/dstConfig.ts +43 -0
  53. package/src/generated/kinobi/dvn/types/executeTransactionDigest.ts +55 -0
  54. package/src/generated/kinobi/dvn/types/index.ts +18 -0
  55. package/src/generated/kinobi/dvn/types/lzOption.ts +29 -0
  56. package/src/generated/kinobi/dvn/types/multisig.ts +29 -0
  57. package/src/generated/kinobi/dvn/types/multisigConfig.ts +130 -0
  58. package/src/generated/kinobi/dvn/types/transactionAccount.ts +37 -0
  59. package/src/generated/kinobi/dvn/types/ulnConfig.ts +49 -0
  60. package/src/generated/kinobi/dvn/types/verificationState.ts +28 -0
  61. package/src/generated/kinobi/endpoint/accounts/composeMessageState.ts +166 -0
  62. package/src/generated/kinobi/endpoint/accounts/endpointSettings.ts +171 -0
  63. package/src/generated/kinobi/endpoint/accounts/index.ts +17 -0
  64. package/src/generated/kinobi/endpoint/accounts/messageLibInfo.ts +170 -0
  65. package/src/generated/kinobi/endpoint/accounts/nonce.ts +151 -0
  66. package/src/generated/kinobi/endpoint/accounts/oAppRegistry.ts +151 -0
  67. package/src/generated/kinobi/endpoint/accounts/payloadHash.ts +144 -0
  68. package/src/generated/kinobi/endpoint/accounts/pendingInboundNonce.ts +163 -0
  69. package/src/generated/kinobi/endpoint/accounts/receiveLibraryConfig.ts +175 -0
  70. package/src/generated/kinobi/endpoint/accounts/sendLibraryConfig.ts +167 -0
  71. package/src/generated/kinobi/endpoint/errors/endpoint.ts +276 -0
  72. package/src/generated/kinobi/endpoint/errors/index.ts +9 -0
  73. package/src/generated/kinobi/endpoint/events/adminTransferredEvent.ts +27 -0
  74. package/src/generated/kinobi/endpoint/events/composeDeliveredEvent.ts +40 -0
  75. package/src/generated/kinobi/endpoint/events/composeSentEvent.ts +43 -0
  76. package/src/generated/kinobi/endpoint/events/defaultReceiveLibrarySetEvent.ts +35 -0
  77. package/src/generated/kinobi/endpoint/events/defaultReceiveLibraryTimeoutSetEvent.ts +46 -0
  78. package/src/generated/kinobi/endpoint/events/defaultSendLibrarySetEvent.ts +32 -0
  79. package/src/generated/kinobi/endpoint/events/delegateSetEvent.ts +27 -0
  80. package/src/generated/kinobi/endpoint/events/inboundNonceSkippedEvent.ts +46 -0
  81. package/src/generated/kinobi/endpoint/events/index.ts +22 -0
  82. package/src/generated/kinobi/endpoint/events/libraryRegisteredEvent.ts +34 -0
  83. package/src/generated/kinobi/endpoint/events/lzComposeAlertEvent.ts +65 -0
  84. package/src/generated/kinobi/endpoint/events/lzReceiveAlertEvent.ts +67 -0
  85. package/src/generated/kinobi/endpoint/events/lzTokenSetEvent.ts +28 -0
  86. package/src/generated/kinobi/endpoint/events/oAppRegisteredEvent.ts +31 -0
  87. package/src/generated/kinobi/endpoint/events/packetBurntEvent.ts +49 -0
  88. package/src/generated/kinobi/endpoint/events/packetDeliveredEvent.ts +46 -0
  89. package/src/generated/kinobi/endpoint/events/packetNilifiedEvent.ts +49 -0
  90. package/src/generated/kinobi/endpoint/events/packetSentEvent.ts +38 -0
  91. package/src/generated/kinobi/endpoint/events/packetVerifiedEvent.ts +49 -0
  92. package/src/generated/kinobi/endpoint/events/receiveLibrarySetEvent.ts +37 -0
  93. package/src/generated/kinobi/endpoint/events/receiveLibraryTimeoutSetEvent.ts +50 -0
  94. package/src/generated/kinobi/endpoint/events/rentWithdrawnEvent.ts +35 -0
  95. package/src/generated/kinobi/endpoint/events/sendLibrarySetEvent.ts +37 -0
  96. package/src/generated/kinobi/endpoint/index.ts +14 -0
  97. package/src/generated/kinobi/endpoint/instructions/burn.ts +166 -0
  98. package/src/generated/kinobi/endpoint/instructions/clear.ts +169 -0
  99. package/src/generated/kinobi/endpoint/instructions/clearCompose.ts +142 -0
  100. package/src/generated/kinobi/endpoint/instructions/index.ts +40 -0
  101. package/src/generated/kinobi/endpoint/instructions/initConfig.ts +145 -0
  102. package/src/generated/kinobi/endpoint/instructions/initDefaultReceiveLibrary.ts +172 -0
  103. package/src/generated/kinobi/endpoint/instructions/initDefaultSendLibrary.ts +171 -0
  104. package/src/generated/kinobi/endpoint/instructions/initEndpoint.ts +142 -0
  105. package/src/generated/kinobi/endpoint/instructions/initNonce.ts +158 -0
  106. package/src/generated/kinobi/endpoint/instructions/initReceiveLibrary.ts +154 -0
  107. package/src/generated/kinobi/endpoint/instructions/initSendLibrary.ts +152 -0
  108. package/src/generated/kinobi/endpoint/instructions/initVerify.ts +159 -0
  109. package/src/generated/kinobi/endpoint/instructions/lzComposeAlert.ts +159 -0
  110. package/src/generated/kinobi/endpoint/instructions/lzReceiveAlert.ts +161 -0
  111. package/src/generated/kinobi/endpoint/instructions/nilify.ts +165 -0
  112. package/src/generated/kinobi/endpoint/instructions/quote.ts +160 -0
  113. package/src/generated/kinobi/endpoint/instructions/registerLibrary.ts +167 -0
  114. package/src/generated/kinobi/endpoint/instructions/registerOapp.ts +154 -0
  115. package/src/generated/kinobi/endpoint/instructions/send.ts +178 -0
  116. package/src/generated/kinobi/endpoint/instructions/sendCompose.ts +166 -0
  117. package/src/generated/kinobi/endpoint/instructions/setConfig.ts +154 -0
  118. package/src/generated/kinobi/endpoint/instructions/setDefaultReceiveLibrary.ts +160 -0
  119. package/src/generated/kinobi/endpoint/instructions/setDefaultReceiveLibraryTimeout.ts +163 -0
  120. package/src/generated/kinobi/endpoint/instructions/setDefaultSendLibrary.ts +156 -0
  121. package/src/generated/kinobi/endpoint/instructions/setDelegate.ts +130 -0
  122. package/src/generated/kinobi/endpoint/instructions/setLzToken.ts +138 -0
  123. package/src/generated/kinobi/endpoint/instructions/setReceiveLibrary.ts +163 -0
  124. package/src/generated/kinobi/endpoint/instructions/setReceiveLibraryTimeout.ts +164 -0
  125. package/src/generated/kinobi/endpoint/instructions/setSendLibrary.ts +158 -0
  126. package/src/generated/kinobi/endpoint/instructions/skip.ts +173 -0
  127. package/src/generated/kinobi/endpoint/instructions/transferAdmin.ts +137 -0
  128. package/src/generated/kinobi/endpoint/instructions/verify.ts +171 -0
  129. package/src/generated/kinobi/endpoint/instructions/withdrawRent.ts +139 -0
  130. package/src/generated/kinobi/endpoint/programs/endpoint.ts +52 -0
  131. package/src/generated/kinobi/endpoint/programs/index.ts +9 -0
  132. package/src/generated/kinobi/endpoint/shared/index.ts +117 -0
  133. package/src/generated/kinobi/endpoint/types/index.ts +12 -0
  134. package/src/generated/kinobi/endpoint/types/messageLibType.ts +26 -0
  135. package/src/generated/kinobi/endpoint/types/messagingFee.ts +29 -0
  136. package/src/generated/kinobi/endpoint/types/messagingReceipt.ts +41 -0
  137. package/src/generated/kinobi/endpoint/types/receiveLibraryTimeout.ts +35 -0
  138. package/src/generated/kinobi/executor/accounts/executorConfig.ts +208 -0
  139. package/src/generated/kinobi/executor/accounts/index.ts +10 -0
  140. package/src/generated/kinobi/executor/accounts/nonce.ts +151 -0
  141. package/src/generated/kinobi/executor/errors/executor.ts +279 -0
  142. package/src/generated/kinobi/executor/errors/index.ts +9 -0
  143. package/src/generated/kinobi/executor/events/index.ts +1 -0
  144. package/src/generated/kinobi/executor/events/nativeDropAppliedEvent.ts +62 -0
  145. package/src/generated/kinobi/executor/index.ts +14 -0
  146. package/src/generated/kinobi/executor/instructions/adminSetConfig.ts +130 -0
  147. package/src/generated/kinobi/executor/instructions/compose.ts +155 -0
  148. package/src/generated/kinobi/executor/instructions/executable.ts +134 -0
  149. package/src/generated/kinobi/executor/instructions/execute.ts +159 -0
  150. package/src/generated/kinobi/executor/instructions/index.ts +16 -0
  151. package/src/generated/kinobi/executor/instructions/initExecutor.ts +154 -0
  152. package/src/generated/kinobi/executor/instructions/nativeDrop.ts +174 -0
  153. package/src/generated/kinobi/executor/instructions/ownerSetConfig.ts +130 -0
  154. package/src/generated/kinobi/executor/instructions/quoteExecutor.ts +147 -0
  155. package/src/generated/kinobi/executor/programs/executor.ts +52 -0
  156. package/src/generated/kinobi/executor/programs/index.ts +9 -0
  157. package/src/generated/kinobi/executor/shared/index.ts +117 -0
  158. package/src/generated/kinobi/executor/types/acl.ts +29 -0
  159. package/src/generated/kinobi/executor/types/adminSetConfigParams.ts +92 -0
  160. package/src/generated/kinobi/executor/types/dstConfig.ts +49 -0
  161. package/src/generated/kinobi/executor/types/executionState.ts +27 -0
  162. package/src/generated/kinobi/executor/types/index.ts +17 -0
  163. package/src/generated/kinobi/executor/types/lzComposeParams.ts +45 -0
  164. package/src/generated/kinobi/executor/types/lzOption.ts +29 -0
  165. package/src/generated/kinobi/executor/types/lzReceiveParams.ts +50 -0
  166. package/src/generated/kinobi/executor/types/nativeDropRequest.ts +35 -0
  167. package/src/generated/kinobi/executor/types/ownerSetConfigParams.ts +129 -0
  168. package/src/generated/kinobi/pricefeed/accounts/index.ts +9 -0
  169. package/src/generated/kinobi/pricefeed/accounts/priceFeed.ts +175 -0
  170. package/src/generated/kinobi/pricefeed/errors/index.ts +9 -0
  171. package/src/generated/kinobi/pricefeed/errors/pricefeed.ts +94 -0
  172. package/src/generated/kinobi/pricefeed/index.ts +14 -0
  173. package/src/generated/kinobi/pricefeed/instructions/getFee.ts +120 -0
  174. package/src/generated/kinobi/pricefeed/instructions/index.ts +14 -0
  175. package/src/generated/kinobi/pricefeed/instructions/initPriceFeed.ts +148 -0
  176. package/src/generated/kinobi/pricefeed/instructions/setPrice.ts +134 -0
  177. package/src/generated/kinobi/pricefeed/instructions/setPriceFeed.ts +131 -0
  178. package/src/generated/kinobi/pricefeed/instructions/setSolPrice.ts +126 -0
  179. package/src/generated/kinobi/pricefeed/instructions/transferAdmin.ts +125 -0
  180. package/src/generated/kinobi/pricefeed/programs/index.ts +9 -0
  181. package/src/generated/kinobi/pricefeed/programs/pricefeed.ts +55 -0
  182. package/src/generated/kinobi/pricefeed/shared/index.ts +117 -0
  183. package/src/generated/kinobi/pricefeed/types/index.ts +11 -0
  184. package/src/generated/kinobi/pricefeed/types/modelType.ts +74 -0
  185. package/src/generated/kinobi/pricefeed/types/price.ts +47 -0
  186. package/src/generated/kinobi/pricefeed/types/priceParams.ts +47 -0
  187. package/src/generated/kinobi/simple_messagelib/accounts/index.ts +11 -0
  188. package/src/generated/kinobi/simple_messagelib/accounts/messageLib.ts +180 -0
  189. package/src/generated/kinobi/simple_messagelib/accounts/receiveConfigStore.ts +162 -0
  190. package/src/generated/kinobi/simple_messagelib/accounts/sendConfigStore.ts +154 -0
  191. package/src/generated/kinobi/simple_messagelib/errors/index.ts +9 -0
  192. package/src/generated/kinobi/simple_messagelib/errors/simpleMessagelib.ts +146 -0
  193. package/src/generated/kinobi/simple_messagelib/index.ts +14 -0
  194. package/src/generated/kinobi/simple_messagelib/instructions/index.ts +23 -0
  195. package/src/generated/kinobi/simple_messagelib/instructions/initConfig.ts +160 -0
  196. package/src/generated/kinobi/simple_messagelib/instructions/initDefaultConfig.ts +164 -0
  197. package/src/generated/kinobi/simple_messagelib/instructions/initMessageLib.ts +161 -0
  198. package/src/generated/kinobi/simple_messagelib/instructions/quote.ts +128 -0
  199. package/src/generated/kinobi/simple_messagelib/instructions/revertCall.ts +84 -0
  200. package/src/generated/kinobi/simple_messagelib/instructions/send.ts +155 -0
  201. package/src/generated/kinobi/simple_messagelib/instructions/sendWithLzToken.ts +202 -0
  202. package/src/generated/kinobi/simple_messagelib/instructions/setConfig.ts +145 -0
  203. package/src/generated/kinobi/simple_messagelib/instructions/setDefaultConfig.ts +164 -0
  204. package/src/generated/kinobi/simple_messagelib/instructions/setFee.ts +122 -0
  205. package/src/generated/kinobi/simple_messagelib/instructions/setWlCaller.ts +121 -0
  206. package/src/generated/kinobi/simple_messagelib/instructions/transferAdmin.ts +125 -0
  207. package/src/generated/kinobi/simple_messagelib/instructions/validatePacket.ts +129 -0
  208. package/src/generated/kinobi/simple_messagelib/instructions/version.ts +80 -0
  209. package/src/generated/kinobi/simple_messagelib/instructions/withdrawFees.ts +127 -0
  210. package/src/generated/kinobi/simple_messagelib/programs/index.ts +9 -0
  211. package/src/generated/kinobi/simple_messagelib/programs/simpleMessagelib.ts +55 -0
  212. package/src/generated/kinobi/simple_messagelib/shared/index.ts +117 -0
  213. package/src/generated/kinobi/simple_messagelib/types/index.ts +11 -0
  214. package/src/generated/kinobi/simple_messagelib/types/messagingFee.ts +29 -0
  215. package/src/generated/kinobi/simple_messagelib/types/packet.ts +52 -0
  216. package/src/generated/kinobi/simple_messagelib/types/version.ts +33 -0
  217. package/src/generated/kinobi/uln/accounts/confirmations.ts +160 -0
  218. package/src/generated/kinobi/uln/accounts/index.ts +12 -0
  219. package/src/generated/kinobi/uln/accounts/receiveConfig.ts +154 -0
  220. package/src/generated/kinobi/uln/accounts/sendConfig.ts +156 -0
  221. package/src/generated/kinobi/uln/accounts/ulnSettings.ts +169 -0
  222. package/src/generated/kinobi/uln/errors/index.ts +9 -0
  223. package/src/generated/kinobi/uln/errors/uln.ts +474 -0
  224. package/src/generated/kinobi/uln/events/adminTransferredEvent.ts +27 -0
  225. package/src/generated/kinobi/uln/events/configSetEvent.ts +38 -0
  226. package/src/generated/kinobi/uln/events/defaultConfigSetEvent.ts +52 -0
  227. package/src/generated/kinobi/uln/events/feesPaidEvent.ts +49 -0
  228. package/src/generated/kinobi/uln/events/index.ts +7 -0
  229. package/src/generated/kinobi/uln/events/payloadVerifiedEvent.ts +47 -0
  230. package/src/generated/kinobi/uln/events/rentWithdrawnEvent.ts +35 -0
  231. package/src/generated/kinobi/uln/events/treasurySetEvent.ts +29 -0
  232. package/src/generated/kinobi/uln/index.ts +14 -0
  233. package/src/generated/kinobi/uln/instructions/closeVerify.ts +127 -0
  234. package/src/generated/kinobi/uln/instructions/commitVerification.ts +134 -0
  235. package/src/generated/kinobi/uln/instructions/index.ts +24 -0
  236. package/src/generated/kinobi/uln/instructions/initConfig.ts +156 -0
  237. package/src/generated/kinobi/uln/instructions/initDefaultConfig.ts +179 -0
  238. package/src/generated/kinobi/uln/instructions/initUln.ts +143 -0
  239. package/src/generated/kinobi/uln/instructions/initVerify.ts +149 -0
  240. package/src/generated/kinobi/uln/instructions/quote.ts +136 -0
  241. package/src/generated/kinobi/uln/instructions/send.ts +181 -0
  242. package/src/generated/kinobi/uln/instructions/sendWithLzToken.ts +226 -0
  243. package/src/generated/kinobi/uln/instructions/setConfig.ts +165 -0
  244. package/src/generated/kinobi/uln/instructions/setDefaultConfig.ts +167 -0
  245. package/src/generated/kinobi/uln/instructions/setTreasury.ts +135 -0
  246. package/src/generated/kinobi/uln/instructions/transferAdmin.ts +133 -0
  247. package/src/generated/kinobi/uln/instructions/verify.ts +140 -0
  248. package/src/generated/kinobi/uln/instructions/version.ts +80 -0
  249. package/src/generated/kinobi/uln/instructions/withdrawRent.ts +135 -0
  250. package/src/generated/kinobi/uln/programs/index.ts +9 -0
  251. package/src/generated/kinobi/uln/programs/uln.ts +48 -0
  252. package/src/generated/kinobi/uln/shared/index.ts +117 -0
  253. package/src/generated/kinobi/uln/types/config.ts +88 -0
  254. package/src/generated/kinobi/uln/types/executorConfig.ts +32 -0
  255. package/src/generated/kinobi/uln/types/index.ts +18 -0
  256. package/src/generated/kinobi/uln/types/lzTokenTreasury.ts +32 -0
  257. package/src/generated/kinobi/uln/types/messagingFee.ts +29 -0
  258. package/src/generated/kinobi/uln/types/packet.ts +52 -0
  259. package/src/generated/kinobi/uln/types/treasury.ts +47 -0
  260. package/src/generated/kinobi/uln/types/treasuryFee.ts +42 -0
  261. package/src/generated/kinobi/uln/types/ulnConfig.ts +49 -0
  262. package/src/generated/kinobi/uln/types/version.ts +33 -0
  263. package/src/generated/kinobi/uln/types/workerFee.ts +29 -0
  264. package/src/generated/kinobi/worker_interface/errors/index.ts +9 -0
  265. package/src/generated/kinobi/worker_interface/errors/workerInterface.ts +68 -0
  266. package/src/generated/kinobi/worker_interface/index.ts +13 -0
  267. package/src/generated/kinobi/worker_interface/instructions/index.ts +10 -0
  268. package/src/generated/kinobi/worker_interface/instructions/quoteDvn.ts +150 -0
  269. package/src/generated/kinobi/worker_interface/instructions/quoteExecutor.ts +147 -0
  270. package/src/generated/kinobi/worker_interface/programs/index.ts +9 -0
  271. package/src/generated/kinobi/worker_interface/programs/workerInterface.ts +55 -0
  272. package/src/generated/kinobi/worker_interface/shared/index.ts +117 -0
  273. package/src/generated/kinobi/worker_interface/types/index.ts +9 -0
  274. package/src/generated/kinobi/worker_interface/types/lzOption.ts +29 -0
  275. package/src/index.ts +31 -47
  276. package/src/next_nonce.ts +107 -0
  277. package/src/pda.ts +328 -0
  278. package/src/pricefeed.ts +115 -168
  279. package/src/receive.ts +285 -0
  280. package/src/send-helper.ts +269 -188
  281. package/src/simple-message-lib.ts +254 -146
  282. package/src/{base-oapp.ts → solita/base-oapp.ts} +2 -3
  283. package/src/solita/config.ts +32 -0
  284. package/src/solita/deployment.ts +128 -0
  285. package/src/solita/dvn.ts +606 -0
  286. package/src/solita/endpoint.ts +1517 -0
  287. package/src/solita/executor.ts +577 -0
  288. package/src/solita/index.ts +100 -0
  289. package/src/solita/pricefeed.ts +208 -0
  290. package/src/{recevie.ts → solita/recevie.ts} +2 -3
  291. package/src/solita/send-helper.ts +503 -0
  292. package/src/solita/simple-message-lib.ts +302 -0
  293. package/src/solita/types.ts +222 -0
  294. package/src/solita/uln.ts +1045 -0
  295. package/src/solita/utility.ts +589 -0
  296. package/src/types.ts +59 -65
  297. package/src/uln.ts +495 -466
  298. package/src/utility.ts +226 -180
  299. /package/src/generated/{blocked_messagelib → solita/blocked_messagelib}/index.ts +0 -0
  300. /package/src/generated/{blocked_messagelib → solita/blocked_messagelib}/instructions/index.ts +0 -0
  301. /package/src/generated/{blocked_messagelib → solita/blocked_messagelib}/instructions/version.ts +0 -0
  302. /package/src/generated/{dvn → solita/dvn}/accounts/DvnConfig.ts +0 -0
  303. /package/src/generated/{dvn → solita/dvn}/accounts/ExecuteHash.ts +0 -0
  304. /package/src/generated/{dvn → solita/dvn}/accounts/ReceiveConfig.ts +0 -0
  305. /package/src/generated/{dvn → solita/dvn}/accounts/index.ts +0 -0
  306. /package/src/generated/{dvn → solita/dvn}/errors/index.ts +0 -0
  307. /package/src/generated/{dvn → solita/dvn}/events/AdminConfigSetEvent.ts +0 -0
  308. /package/src/generated/{dvn → solita/dvn}/events/FeeWithdrawnEvent.ts +0 -0
  309. /package/src/generated/{dvn → solita/dvn}/events/MultisigConfigSetEvent.ts +0 -0
  310. /package/src/generated/{dvn → solita/dvn}/events/index.ts +0 -0
  311. /package/src/generated/{dvn → solita/dvn}/index.ts +0 -0
  312. /package/src/generated/{dvn → solita/dvn}/instructions/closeExecute.ts +0 -0
  313. /package/src/generated/{dvn → solita/dvn}/instructions/index.ts +0 -0
  314. /package/src/generated/{dvn → solita/dvn}/instructions/initDvn.ts +0 -0
  315. /package/src/generated/{dvn → solita/dvn}/instructions/invoke.ts +0 -0
  316. /package/src/generated/{dvn → solita/dvn}/instructions/quoteDvn.ts +0 -0
  317. /package/src/generated/{dvn → solita/dvn}/instructions/setConfig.ts +0 -0
  318. /package/src/generated/{dvn → solita/dvn}/instructions/verifiable.ts +0 -0
  319. /package/src/generated/{dvn → solita/dvn}/instructions/withdrawFee.ts +0 -0
  320. /package/src/generated/{dvn → solita/dvn}/types/Acl.ts +0 -0
  321. /package/src/generated/{dvn → solita/dvn}/types/AdminConfig.ts +0 -0
  322. /package/src/generated/{dvn → solita/dvn}/types/CloseExecuteParams.ts +0 -0
  323. /package/src/generated/{dvn → solita/dvn}/types/DstConfig.ts +0 -0
  324. /package/src/generated/{dvn → solita/dvn}/types/ExecuteTransactionDigest.ts +0 -0
  325. /package/src/generated/{dvn → solita/dvn}/types/InitDvnParams.ts +0 -0
  326. /package/src/generated/{dvn → solita/dvn}/types/InvokeParams.ts +0 -0
  327. /package/src/generated/{dvn → solita/dvn}/types/LzOption.ts +0 -0
  328. /package/src/generated/{dvn → solita/dvn}/types/Multisig.ts +0 -0
  329. /package/src/generated/{dvn → solita/dvn}/types/MultisigConfig.ts +0 -0
  330. /package/src/generated/{dvn → solita/dvn}/types/QuoteDvnParams.ts +0 -0
  331. /package/src/generated/{dvn → solita/dvn}/types/SetConfigParams.ts +0 -0
  332. /package/src/generated/{dvn → solita/dvn}/types/TransactionAccount.ts +0 -0
  333. /package/src/generated/{dvn → solita/dvn}/types/UlnConfig.ts +0 -0
  334. /package/src/generated/{dvn → solita/dvn}/types/VerifiableParams.ts +0 -0
  335. /package/src/generated/{dvn → solita/dvn}/types/VerificationState.ts +0 -0
  336. /package/src/generated/{dvn → solita/dvn}/types/WithdrawFeeParams.ts +0 -0
  337. /package/src/generated/{dvn → solita/dvn}/types/index.ts +0 -0
  338. /package/src/generated/{endpoint → solita/endpoint}/accounts/ComposeMessageState.ts +0 -0
  339. /package/src/generated/{endpoint → solita/endpoint}/accounts/EndpointSettings.ts +0 -0
  340. /package/src/generated/{endpoint → solita/endpoint}/accounts/MessageLibInfo.ts +0 -0
  341. /package/src/generated/{endpoint → solita/endpoint}/accounts/Nonce.ts +0 -0
  342. /package/src/generated/{endpoint → solita/endpoint}/accounts/OAppRegistry.ts +0 -0
  343. /package/src/generated/{endpoint → solita/endpoint}/accounts/PayloadHash.ts +0 -0
  344. /package/src/generated/{endpoint → solita/endpoint}/accounts/PendingInboundNonce.ts +0 -0
  345. /package/src/generated/{endpoint → solita/endpoint}/accounts/ReceiveLibraryConfig.ts +0 -0
  346. /package/src/generated/{endpoint → solita/endpoint}/accounts/SendLibraryConfig.ts +0 -0
  347. /package/src/generated/{endpoint → solita/endpoint}/accounts/index.ts +0 -0
  348. /package/src/generated/{endpoint → solita/endpoint}/errors/index.ts +0 -0
  349. /package/src/generated/{endpoint → solita/endpoint}/events/AdminTransferredEvent.ts +0 -0
  350. /package/src/generated/{endpoint → solita/endpoint}/events/ComposeDeliveredEvent.ts +0 -0
  351. /package/src/generated/{endpoint → solita/endpoint}/events/ComposeSentEvent.ts +0 -0
  352. /package/src/generated/{endpoint → solita/endpoint}/events/DefaultReceiveLibrarySetEvent.ts +0 -0
  353. /package/src/generated/{endpoint → solita/endpoint}/events/DefaultReceiveLibraryTimeoutSetEvent.ts +0 -0
  354. /package/src/generated/{endpoint → solita/endpoint}/events/DefaultSendLibrarySetEvent.ts +0 -0
  355. /package/src/generated/{endpoint → solita/endpoint}/events/DelegateSetEvent.ts +0 -0
  356. /package/src/generated/{endpoint → solita/endpoint}/events/InboundNonceSkippedEvent.ts +0 -0
  357. /package/src/generated/{endpoint → solita/endpoint}/events/LibraryRegisteredEvent.ts +0 -0
  358. /package/src/generated/{endpoint → solita/endpoint}/events/LzComposeAlertEvent.ts +0 -0
  359. /package/src/generated/{endpoint → solita/endpoint}/events/LzReceiveAlertEvent.ts +0 -0
  360. /package/src/generated/{endpoint → solita/endpoint}/events/LzTokenSetEvent.ts +0 -0
  361. /package/src/generated/{endpoint → solita/endpoint}/events/OAppRegisteredEvent.ts +0 -0
  362. /package/src/generated/{endpoint → solita/endpoint}/events/PacketBurntEvent.ts +0 -0
  363. /package/src/generated/{endpoint → solita/endpoint}/events/PacketDeliveredEvent.ts +0 -0
  364. /package/src/generated/{endpoint → solita/endpoint}/events/PacketNilifiedEvent.ts +0 -0
  365. /package/src/generated/{endpoint → solita/endpoint}/events/PacketSentEvent.ts +0 -0
  366. /package/src/generated/{endpoint → solita/endpoint}/events/PacketVerifiedEvent.ts +0 -0
  367. /package/src/generated/{endpoint → solita/endpoint}/events/ReceiveLibrarySetEvent.ts +0 -0
  368. /package/src/generated/{endpoint → solita/endpoint}/events/ReceiveLibraryTimeoutSetEvent.ts +0 -0
  369. /package/src/generated/{endpoint → solita/endpoint}/events/RentWithdrawnEvent.ts +0 -0
  370. /package/src/generated/{endpoint → solita/endpoint}/events/SendLibrarySetEvent.ts +0 -0
  371. /package/src/generated/{endpoint → solita/endpoint}/events/index.ts +0 -0
  372. /package/src/generated/{endpoint → solita/endpoint}/index.ts +0 -0
  373. /package/src/generated/{endpoint → solita/endpoint}/instructions/burn.ts +0 -0
  374. /package/src/generated/{endpoint → solita/endpoint}/instructions/clear.ts +0 -0
  375. /package/src/generated/{endpoint → solita/endpoint}/instructions/clearCompose.ts +0 -0
  376. /package/src/generated/{endpoint → solita/endpoint}/instructions/index.ts +0 -0
  377. /package/src/generated/{endpoint → solita/endpoint}/instructions/initConfig.ts +0 -0
  378. /package/src/generated/{endpoint → solita/endpoint}/instructions/initDefaultReceiveLibrary.ts +0 -0
  379. /package/src/generated/{endpoint → solita/endpoint}/instructions/initDefaultSendLibrary.ts +0 -0
  380. /package/src/generated/{endpoint → solita/endpoint}/instructions/initEndpoint.ts +0 -0
  381. /package/src/generated/{endpoint → solita/endpoint}/instructions/initNonce.ts +0 -0
  382. /package/src/generated/{endpoint → solita/endpoint}/instructions/initReceiveLibrary.ts +0 -0
  383. /package/src/generated/{endpoint → solita/endpoint}/instructions/initSendLibrary.ts +0 -0
  384. /package/src/generated/{endpoint → solita/endpoint}/instructions/initVerify.ts +0 -0
  385. /package/src/generated/{endpoint → solita/endpoint}/instructions/lzComposeAlert.ts +0 -0
  386. /package/src/generated/{endpoint → solita/endpoint}/instructions/lzReceiveAlert.ts +0 -0
  387. /package/src/generated/{endpoint → solita/endpoint}/instructions/nilify.ts +0 -0
  388. /package/src/generated/{endpoint → solita/endpoint}/instructions/quote.ts +0 -0
  389. /package/src/generated/{endpoint → solita/endpoint}/instructions/registerLibrary.ts +0 -0
  390. /package/src/generated/{endpoint → solita/endpoint}/instructions/registerOapp.ts +0 -0
  391. /package/src/generated/{endpoint → solita/endpoint}/instructions/send.ts +0 -0
  392. /package/src/generated/{endpoint → solita/endpoint}/instructions/sendCompose.ts +0 -0
  393. /package/src/generated/{endpoint → solita/endpoint}/instructions/setConfig.ts +0 -0
  394. /package/src/generated/{endpoint → solita/endpoint}/instructions/setDefaultReceiveLibrary.ts +0 -0
  395. /package/src/generated/{endpoint → solita/endpoint}/instructions/setDefaultReceiveLibraryTimeout.ts +0 -0
  396. /package/src/generated/{endpoint → solita/endpoint}/instructions/setDefaultSendLibrary.ts +0 -0
  397. /package/src/generated/{endpoint → solita/endpoint}/instructions/setDelegate.ts +0 -0
  398. /package/src/generated/{endpoint → solita/endpoint}/instructions/setLzToken.ts +0 -0
  399. /package/src/generated/{endpoint → solita/endpoint}/instructions/setReceiveLibrary.ts +0 -0
  400. /package/src/generated/{endpoint → solita/endpoint}/instructions/setReceiveLibraryTimeout.ts +0 -0
  401. /package/src/generated/{endpoint → solita/endpoint}/instructions/setSendLibrary.ts +0 -0
  402. /package/src/generated/{endpoint → solita/endpoint}/instructions/skip.ts +0 -0
  403. /package/src/generated/{endpoint → solita/endpoint}/instructions/transferAdmin.ts +0 -0
  404. /package/src/generated/{endpoint → solita/endpoint}/instructions/verify.ts +0 -0
  405. /package/src/generated/{endpoint → solita/endpoint}/instructions/withdrawRent.ts +0 -0
  406. /package/src/generated/{endpoint → solita/endpoint}/types/BurnParams.ts +0 -0
  407. /package/src/generated/{endpoint → solita/endpoint}/types/ClearComposeParams.ts +0 -0
  408. /package/src/generated/{endpoint → solita/endpoint}/types/ClearParams.ts +0 -0
  409. /package/src/generated/{endpoint → solita/endpoint}/types/InitConfigParams.ts +0 -0
  410. /package/src/generated/{endpoint → solita/endpoint}/types/InitDefaultReceiveLibraryParams.ts +0 -0
  411. /package/src/generated/{endpoint → solita/endpoint}/types/InitDefaultSendLibraryParams.ts +0 -0
  412. /package/src/generated/{endpoint → solita/endpoint}/types/InitEndpointParams.ts +0 -0
  413. /package/src/generated/{endpoint → solita/endpoint}/types/InitNonceParams.ts +0 -0
  414. /package/src/generated/{endpoint → solita/endpoint}/types/InitReceiveLibraryParams.ts +0 -0
  415. /package/src/generated/{endpoint → solita/endpoint}/types/InitSendLibraryParams.ts +0 -0
  416. /package/src/generated/{endpoint → solita/endpoint}/types/InitVerifyParams.ts +0 -0
  417. /package/src/generated/{endpoint → solita/endpoint}/types/LzComposeAlertParams.ts +0 -0
  418. /package/src/generated/{endpoint → solita/endpoint}/types/LzReceiveAlertParams.ts +0 -0
  419. /package/src/generated/{endpoint → solita/endpoint}/types/MessageLibType.ts +0 -0
  420. /package/src/generated/{endpoint → solita/endpoint}/types/MessagingFee.ts +0 -0
  421. /package/src/generated/{endpoint → solita/endpoint}/types/MessagingReceipt.ts +0 -0
  422. /package/src/generated/{endpoint → solita/endpoint}/types/NilifyParams.ts +0 -0
  423. /package/src/generated/{endpoint → solita/endpoint}/types/QuoteParams.ts +0 -0
  424. /package/src/generated/{endpoint → solita/endpoint}/types/ReceiveLibraryTimeout.ts +0 -0
  425. /package/src/generated/{endpoint → solita/endpoint}/types/RegisterLibraryParams.ts +0 -0
  426. /package/src/generated/{endpoint → solita/endpoint}/types/RegisterOAppParams.ts +0 -0
  427. /package/src/generated/{endpoint → solita/endpoint}/types/SendComposeParams.ts +0 -0
  428. /package/src/generated/{endpoint → solita/endpoint}/types/SendParams.ts +0 -0
  429. /package/src/generated/{endpoint → solita/endpoint}/types/SetConfigParams.ts +0 -0
  430. /package/src/generated/{endpoint → solita/endpoint}/types/SetDefaultReceiveLibraryParams.ts +0 -0
  431. /package/src/generated/{endpoint → solita/endpoint}/types/SetDefaultReceiveLibraryTimeoutParams.ts +0 -0
  432. /package/src/generated/{endpoint → solita/endpoint}/types/SetDefaultSendLibraryParams.ts +0 -0
  433. /package/src/generated/{endpoint → solita/endpoint}/types/SetDelegateParams.ts +0 -0
  434. /package/src/generated/{endpoint → solita/endpoint}/types/SetLzTokenParams.ts +0 -0
  435. /package/src/generated/{endpoint → solita/endpoint}/types/SetReceiveLibraryParams.ts +0 -0
  436. /package/src/generated/{endpoint → solita/endpoint}/types/SetReceiveLibraryTimeoutParams.ts +0 -0
  437. /package/src/generated/{endpoint → solita/endpoint}/types/SetSendLibraryParams.ts +0 -0
  438. /package/src/generated/{endpoint → solita/endpoint}/types/SkipParams.ts +0 -0
  439. /package/src/generated/{endpoint → solita/endpoint}/types/TransferAdminParams.ts +0 -0
  440. /package/src/generated/{endpoint → solita/endpoint}/types/VerifyParams.ts +0 -0
  441. /package/src/generated/{endpoint → solita/endpoint}/types/WithdrawRentParams.ts +0 -0
  442. /package/src/generated/{endpoint → solita/endpoint}/types/index.ts +0 -0
  443. /package/src/generated/{executor → solita/executor}/accounts/ExecutorConfig.ts +0 -0
  444. /package/src/generated/{executor → solita/executor}/accounts/Nonce.ts +0 -0
  445. /package/src/generated/{executor → solita/executor}/accounts/index.ts +0 -0
  446. /package/src/generated/{executor → solita/executor}/errors/index.ts +0 -0
  447. /package/src/generated/{executor → solita/executor}/events/NativeDropAppliedEvent.ts +0 -0
  448. /package/src/generated/{executor → solita/executor}/events/index.ts +0 -0
  449. /package/src/generated/{executor → solita/executor}/index.ts +0 -0
  450. /package/src/generated/{executor → solita/executor}/instructions/adminSetConfig.ts +0 -0
  451. /package/src/generated/{executor → solita/executor}/instructions/compose.ts +0 -0
  452. /package/src/generated/{executor → solita/executor}/instructions/executable.ts +0 -0
  453. /package/src/generated/{executor → solita/executor}/instructions/execute.ts +0 -0
  454. /package/src/generated/{executor → solita/executor}/instructions/index.ts +0 -0
  455. /package/src/generated/{executor → solita/executor}/instructions/initExecutor.ts +0 -0
  456. /package/src/generated/{executor → solita/executor}/instructions/nativeDrop.ts +0 -0
  457. /package/src/generated/{executor → solita/executor}/instructions/ownerSetConfig.ts +0 -0
  458. /package/src/generated/{executor → solita/executor}/instructions/quoteExecutor.ts +0 -0
  459. /package/src/generated/{executor → solita/executor}/types/Acl.ts +0 -0
  460. /package/src/generated/{executor → solita/executor}/types/AdminSetConfigParams.ts +0 -0
  461. /package/src/generated/{executor → solita/executor}/types/ComposeParams.ts +0 -0
  462. /package/src/generated/{executor → solita/executor}/types/DstConfig.ts +0 -0
  463. /package/src/generated/{executor → solita/executor}/types/ExecutableParams.ts +0 -0
  464. /package/src/generated/{executor → solita/executor}/types/ExecuteParams.ts +0 -0
  465. /package/src/generated/{executor → solita/executor}/types/ExecutionState.ts +0 -0
  466. /package/src/generated/{executor → solita/executor}/types/InitExecutorParams.ts +0 -0
  467. /package/src/generated/{executor → solita/executor}/types/LzComposeParams.ts +0 -0
  468. /package/src/generated/{executor → solita/executor}/types/LzOption.ts +0 -0
  469. /package/src/generated/{executor → solita/executor}/types/LzReceiveParams.ts +0 -0
  470. /package/src/generated/{executor → solita/executor}/types/NativeDropParams.ts +0 -0
  471. /package/src/generated/{executor → solita/executor}/types/NativeDropRequest.ts +0 -0
  472. /package/src/generated/{executor → solita/executor}/types/OwnerSetConfigParams.ts +0 -0
  473. /package/src/generated/{executor → solita/executor}/types/QuoteExecutorParams.ts +0 -0
  474. /package/src/generated/{executor → solita/executor}/types/index.ts +0 -0
  475. /package/src/generated/{pricefeed → solita/pricefeed}/accounts/PriceFeed.ts +0 -0
  476. /package/src/generated/{pricefeed → solita/pricefeed}/accounts/index.ts +0 -0
  477. /package/src/generated/{pricefeed → solita/pricefeed}/errors/index.ts +0 -0
  478. /package/src/generated/{pricefeed → solita/pricefeed}/index.ts +0 -0
  479. /package/src/generated/{pricefeed → solita/pricefeed}/instructions/getFee.ts +0 -0
  480. /package/src/generated/{pricefeed → solita/pricefeed}/instructions/index.ts +0 -0
  481. /package/src/generated/{pricefeed → solita/pricefeed}/instructions/initPriceFeed.ts +0 -0
  482. /package/src/generated/{pricefeed → solita/pricefeed}/instructions/setPrice.ts +0 -0
  483. /package/src/generated/{pricefeed → solita/pricefeed}/instructions/setPriceFeed.ts +0 -0
  484. /package/src/generated/{pricefeed → solita/pricefeed}/instructions/setSolPrice.ts +0 -0
  485. /package/src/generated/{pricefeed → solita/pricefeed}/instructions/transferAdmin.ts +0 -0
  486. /package/src/generated/{pricefeed → solita/pricefeed}/types/GetFeeParams.ts +0 -0
  487. /package/src/generated/{pricefeed → solita/pricefeed}/types/InitPriceFeedParams.ts +0 -0
  488. /package/src/generated/{pricefeed → solita/pricefeed}/types/ModelType.ts +0 -0
  489. /package/src/generated/{pricefeed → solita/pricefeed}/types/Price.ts +0 -0
  490. /package/src/generated/{pricefeed → solita/pricefeed}/types/PriceParams.ts +0 -0
  491. /package/src/generated/{pricefeed → solita/pricefeed}/types/SetPriceFeedParams.ts +0 -0
  492. /package/src/generated/{pricefeed → solita/pricefeed}/types/SetPriceParams.ts +0 -0
  493. /package/src/generated/{pricefeed → solita/pricefeed}/types/SetSolPriceParams.ts +0 -0
  494. /package/src/generated/{pricefeed → solita/pricefeed}/types/TransferAdminParams.ts +0 -0
  495. /package/src/generated/{pricefeed → solita/pricefeed}/types/index.ts +0 -0
  496. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/accounts/MessageLib.ts +0 -0
  497. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/accounts/ReceiveConfigStore.ts +0 -0
  498. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/accounts/SendConfigStore.ts +0 -0
  499. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/accounts/index.ts +0 -0
  500. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/errors/index.ts +0 -0
  501. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/index.ts +0 -0
  502. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/index.ts +0 -0
  503. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/initConfig.ts +0 -0
  504. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/initDefaultConfig.ts +0 -0
  505. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/initMessageLib.ts +0 -0
  506. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/quote.ts +0 -0
  507. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/revertCall.ts +0 -0
  508. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/send.ts +0 -0
  509. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/sendWithLzToken.ts +0 -0
  510. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/setConfig.ts +0 -0
  511. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/setDefaultConfig.ts +0 -0
  512. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/setFee.ts +0 -0
  513. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/setWlCaller.ts +0 -0
  514. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/transferAdmin.ts +0 -0
  515. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/validatePacket.ts +0 -0
  516. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/version.ts +0 -0
  517. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/instructions/withdrawFees.ts +0 -0
  518. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/InitConfigParams.ts +0 -0
  519. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/InitDefaultConfigParams.ts +0 -0
  520. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/InitMessageLibParams.ts +0 -0
  521. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/MessagingFee.ts +0 -0
  522. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/Packet.ts +0 -0
  523. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/QuoteParams.ts +0 -0
  524. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/SendParams.ts +0 -0
  525. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/SendWithLzTokenParams.ts +0 -0
  526. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/SetConfigParams.ts +0 -0
  527. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/SetDefaultConfigParams.ts +0 -0
  528. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/SetFeeParams.ts +0 -0
  529. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/SetWlCallerParams.ts +0 -0
  530. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/TransferAdminParams.ts +0 -0
  531. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/ValidatePacketParams.ts +0 -0
  532. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/Version.ts +0 -0
  533. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/WithdrawFeesParams.ts +0 -0
  534. /package/src/generated/{simple_messagelib → solita/simple_messagelib}/types/index.ts +0 -0
  535. /package/src/generated/{uln → solita/uln}/accounts/Confirmations.ts +0 -0
  536. /package/src/generated/{uln → solita/uln}/accounts/ReceiveConfig.ts +0 -0
  537. /package/src/generated/{uln → solita/uln}/accounts/SendConfig.ts +0 -0
  538. /package/src/generated/{uln → solita/uln}/accounts/UlnSettings.ts +0 -0
  539. /package/src/generated/{uln → solita/uln}/accounts/index.ts +0 -0
  540. /package/src/generated/{uln → solita/uln}/errors/index.ts +0 -0
  541. /package/src/generated/{uln → solita/uln}/events/AdminTransferredEvent.ts +0 -0
  542. /package/src/generated/{uln → solita/uln}/events/ConfigSetEvent.ts +0 -0
  543. /package/src/generated/{uln → solita/uln}/events/DefaultConfigSetEvent.ts +0 -0
  544. /package/src/generated/{uln → solita/uln}/events/FeesPaidEvent.ts +0 -0
  545. /package/src/generated/{uln → solita/uln}/events/LzTokenSetEvent.ts +0 -0
  546. /package/src/generated/{uln → solita/uln}/events/PayloadVerifiedEvent.ts +0 -0
  547. /package/src/generated/{uln → solita/uln}/events/RentWithdrawnEvent.ts +0 -0
  548. /package/src/generated/{uln → solita/uln}/events/TreasuryFeeCapSetEvent.ts +0 -0
  549. /package/src/generated/{uln → solita/uln}/events/TreasurySetEvent.ts +0 -0
  550. /package/src/generated/{uln → solita/uln}/events/index.ts +0 -0
  551. /package/src/generated/{uln → solita/uln}/index.ts +0 -0
  552. /package/src/generated/{uln → solita/uln}/instructions/closeVerify.ts +0 -0
  553. /package/src/generated/{uln → solita/uln}/instructions/commitVerification.ts +0 -0
  554. /package/src/generated/{uln → solita/uln}/instructions/index.ts +0 -0
  555. /package/src/generated/{uln → solita/uln}/instructions/initConfig.ts +0 -0
  556. /package/src/generated/{uln → solita/uln}/instructions/initDefaultConfig.ts +0 -0
  557. /package/src/generated/{uln → solita/uln}/instructions/initUln.ts +0 -0
  558. /package/src/generated/{uln → solita/uln}/instructions/initVerify.ts +0 -0
  559. /package/src/generated/{uln → solita/uln}/instructions/quote.ts +0 -0
  560. /package/src/generated/{uln → solita/uln}/instructions/send.ts +0 -0
  561. /package/src/generated/{uln → solita/uln}/instructions/sendWithLzToken.ts +0 -0
  562. /package/src/generated/{uln → solita/uln}/instructions/setConfig.ts +0 -0
  563. /package/src/generated/{uln → solita/uln}/instructions/setDefaultConfig.ts +0 -0
  564. /package/src/generated/{uln → solita/uln}/instructions/setTreasury.ts +0 -0
  565. /package/src/generated/{uln → solita/uln}/instructions/transferAdmin.ts +0 -0
  566. /package/src/generated/{uln → solita/uln}/instructions/verify.ts +0 -0
  567. /package/src/generated/{uln → solita/uln}/instructions/version.ts +0 -0
  568. /package/src/generated/{uln → solita/uln}/instructions/withdrawRent.ts +0 -0
  569. /package/src/generated/{uln → solita/uln}/types/CloseVerifyParams.ts +0 -0
  570. /package/src/generated/{uln → solita/uln}/types/CommitVerificationParams.ts +0 -0
  571. /package/src/generated/{uln → solita/uln}/types/Config.ts +0 -0
  572. /package/src/generated/{uln → solita/uln}/types/ExecutorConfig.ts +0 -0
  573. /package/src/generated/{uln → solita/uln}/types/InitConfigParams.ts +0 -0
  574. /package/src/generated/{uln → solita/uln}/types/InitDefaultConfigParams.ts +0 -0
  575. /package/src/generated/{uln → solita/uln}/types/InitUlnParams.ts +0 -0
  576. /package/src/generated/{uln → solita/uln}/types/InitVerifyParams.ts +0 -0
  577. /package/src/generated/{uln → solita/uln}/types/LzTokenTreasury.ts +0 -0
  578. /package/src/generated/{uln → solita/uln}/types/MessagingFee.ts +0 -0
  579. /package/src/generated/{uln → solita/uln}/types/Packet.ts +0 -0
  580. /package/src/generated/{uln → solita/uln}/types/QuoteParams.ts +0 -0
  581. /package/src/generated/{uln → solita/uln}/types/SendParams.ts +0 -0
  582. /package/src/generated/{uln → solita/uln}/types/SendWithLzTokenParams.ts +0 -0
  583. /package/src/generated/{uln → solita/uln}/types/SetConfigParams.ts +0 -0
  584. /package/src/generated/{uln → solita/uln}/types/SetDefaultConfigParams.ts +0 -0
  585. /package/src/generated/{uln → solita/uln}/types/SetTreasuryParams.ts +0 -0
  586. /package/src/generated/{uln → solita/uln}/types/TransferAdminParams.ts +0 -0
  587. /package/src/generated/{uln → solita/uln}/types/Treasury.ts +0 -0
  588. /package/src/generated/{uln → solita/uln}/types/TreasuryFee.ts +0 -0
  589. /package/src/generated/{uln → solita/uln}/types/UlnConfig.ts +0 -0
  590. /package/src/generated/{uln → solita/uln}/types/VerifyParams.ts +0 -0
  591. /package/src/generated/{uln → solita/uln}/types/Version.ts +0 -0
  592. /package/src/generated/{uln → solita/uln}/types/WithdrawRentParams.ts +0 -0
  593. /package/src/generated/{uln → solita/uln}/types/WorkerFee.ts +0 -0
  594. /package/src/generated/{uln → solita/uln}/types/index.ts +0 -0
  595. /package/src/generated/{worker_interface → solita/worker_interface}/errors/index.ts +0 -0
  596. /package/src/generated/{worker_interface → solita/worker_interface}/index.ts +0 -0
  597. /package/src/generated/{worker_interface → solita/worker_interface}/instructions/index.ts +0 -0
  598. /package/src/generated/{worker_interface → solita/worker_interface}/instructions/quoteDvn.ts +0 -0
  599. /package/src/generated/{worker_interface → solita/worker_interface}/instructions/quoteExecutor.ts +0 -0
  600. /package/src/generated/{worker_interface → solita/worker_interface}/types/LzOption.ts +0 -0
  601. /package/src/generated/{worker_interface → solita/worker_interface}/types/QuoteDvnParams.ts +0 -0
  602. /package/src/generated/{worker_interface → solita/worker_interface}/types/QuoteExecutorParams.ts +0 -0
  603. /package/src/generated/{worker_interface → solita/worker_interface}/types/index.ts +0 -0
  604. /package/src/{pda-deriver.ts → solita/pda-deriver.ts} +0 -0
@@ -0,0 +1,1517 @@
1
+ import {
2
+ AccountMeta,
3
+ Commitment,
4
+ Connection,
5
+ GetAccountInfoConfig,
6
+ PublicKey,
7
+ TransactionInstruction,
8
+ } from '@solana/web3.js'
9
+ import BN from 'bn.js'
10
+ import invariant from 'tiny-invariant'
11
+
12
+ import { keccak_256 } from '@layerzerolabs/lz-foundation'
13
+ import { arrayify } from '@layerzerolabs/lz-utilities'
14
+ import { PacketV1Codec, addressToBytes32 } from '@layerzerolabs/lz-v2-utilities'
15
+
16
+ import {
17
+ MessageLibInterface,
18
+ SetConfigType,
19
+ SimpleMessageLibProgram,
20
+ SolanaPacketPath,
21
+ UlnProgram,
22
+ simulateTransaction,
23
+ } from '.'
24
+ import * as pdaDeriver from './pda-deriver'
25
+ import { EventPDADeriver, MessageLibPDADeriver, OAPP_SEED } from './pda-deriver'
26
+ import { ComposeMessageState, EndpointSettings, MessageLibInfo, PayloadHash } from '../generated/solita/endpoint'
27
+ import * as accounts from '../generated/solita/endpoint/accounts'
28
+ import * as errors from '../generated/solita/endpoint/errors'
29
+ import * as events from '../generated/solita/endpoint/events'
30
+ import * as instructions from '../generated/solita/endpoint/instructions'
31
+ import * as types from '../generated/solita/endpoint/types'
32
+ import { Version } from '../generated/solita/simple_messagelib'
33
+
34
+ export { accounts, instructions, types, events, errors }
35
+ export { PROGRAM_ID } from '../generated/solita/endpoint'
36
+
37
+ // https://github.com/coral-xyz/anchor/blob/c7ccbb8f620aed3ffecf8ab2f9c9007946f0f5cc/lang/src/event.rs#L2
38
+ export const EventEmitDiscriminator = 'e445a52e51cb9a1d' // Sha256(anchor:event)[..8] then evert
39
+
40
+ export const DefaultMessageLib = PublicKey.default // [0u8; 32]
41
+
42
+ /**
43
+ * Class representing an Endpoint.
44
+ */
45
+ export class Endpoint {
46
+ deriver: pdaDeriver.EndpointPDADeriver
47
+ eventAuthorityPDA: PublicKey
48
+
49
+ /**
50
+ * Creates an instance of the Endpoint class.
51
+ *
52
+ * @param {PublicKey} program - The program public key.
53
+ */
54
+ constructor(public program: PublicKey) {
55
+ this.deriver = new pdaDeriver.EndpointPDADeriver(program)
56
+ const [eventAuthorityPDA] = new EventPDADeriver(program).eventAuthority()
57
+ this.eventAuthorityPDA = eventAuthorityPDA
58
+ }
59
+
60
+ /**
61
+ * Initializes the endpoint settings, including eid and admin, and registers the blocked message library.
62
+ *
63
+ * @param {number} endpointId - The endpoint ID.
64
+ * @param {PublicKey} payer - The payer public key.
65
+ * @param {PublicKey} admin - The admin public key.
66
+ * @returns {TransactionInstruction} The transaction instruction.
67
+ */
68
+ initEndpoint(endpointId: number, payer: PublicKey, admin: PublicKey): TransactionInstruction {
69
+ const [settingPDA] = this.deriver.setting()
70
+ return instructions.createInitEndpointInstruction(
71
+ {
72
+ payer,
73
+ endpoint: settingPDA,
74
+ } satisfies instructions.InitEndpointInstructionAccounts,
75
+ {
76
+ params: {
77
+ eid: endpointId,
78
+ admin,
79
+ } satisfies types.InitEndpointParams,
80
+ } satisfies instructions.InitEndpointInstructionArgs,
81
+ this.program
82
+ )
83
+ }
84
+
85
+ // async initOrUpdateConfig(connection:Connection,)
86
+ /**
87
+ * Registers a library.
88
+ * call this function after endpoint initialized. Only admin can call this function.
89
+ *
90
+ * @param {PublicKey} admin - The admin public key.
91
+ * @param {PublicKey} messageLibProgram - The message library program public key.
92
+ * @param {types.MessageLibType} [libType=types.MessageLibType.SendAndReceive] - The library type.
93
+ * @returns {TransactionInstruction} The transaction instruction.
94
+ */
95
+ registerLibrary(
96
+ admin: PublicKey,
97
+ messageLibProgram: PublicKey,
98
+ libType: types.MessageLibType = types.MessageLibType.SendAndReceive
99
+ ): TransactionInstruction {
100
+ const [msgLibPda] = new pdaDeriver.MessageLibPDADeriver(messageLibProgram).messageLib()
101
+ const [msgLibInfoPda] = this.deriver.messageLibraryInfo(msgLibPda)
102
+
103
+ const [settingPDA] = this.deriver.setting()
104
+ return instructions.createRegisterLibraryInstruction(
105
+ {
106
+ admin,
107
+ endpoint: settingPDA,
108
+ messageLibInfo: msgLibInfoPda,
109
+ eventAuthority: this.eventAuthorityPDA,
110
+ program: this.program,
111
+ },
112
+ {
113
+ params: {
114
+ libProgram: messageLibProgram,
115
+ libType,
116
+ },
117
+ },
118
+ this.program
119
+ )
120
+ }
121
+
122
+ /**
123
+ * Sets the default send library.
124
+ *
125
+ * @param {Connection} connection - The connection to the Solana cluster.
126
+ * @param {PublicKey} admin - The admin public key.
127
+ * @param {PublicKey} messageLibProgram - The message library program public key.
128
+ * @param {number} dstEid - The destination endpoint ID.
129
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
130
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
131
+ */
132
+ async setDefaultSendLibrary(
133
+ connection: Connection,
134
+ admin: PublicKey,
135
+ messageLibProgram: PublicKey,
136
+ dstEid: number,
137
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
138
+ ): Promise<TransactionInstruction | null> {
139
+ const [msgLib] = new pdaDeriver.MessageLibPDADeriver(messageLibProgram).messageLib()
140
+ const [defaultSendLibConfig] = this.deriver.defaultSendLibraryConfig(dstEid)
141
+ const [settingPDA] = this.deriver.setting()
142
+ const [msgLibInfo] = this.deriver.messageLibraryInfo(msgLib)
143
+
144
+ const info = await connection.getAccountInfo(defaultSendLibConfig, commitmentOrConfig)
145
+ if (!info) {
146
+ return instructions.createInitDefaultSendLibraryInstruction(
147
+ {
148
+ admin,
149
+ endpoint: settingPDA,
150
+ defaultSendLibraryConfig: defaultSendLibConfig,
151
+ messageLibInfo: msgLibInfo,
152
+ program: this.program,
153
+ eventAuthority: this.eventAuthorityPDA,
154
+ } satisfies instructions.InitDefaultSendLibraryInstructionAccounts,
155
+ {
156
+ params: {
157
+ eid: dstEid,
158
+ newLib: msgLib,
159
+ } satisfies types.InitDefaultSendLibraryParams,
160
+ } satisfies instructions.InitDefaultSendLibraryInstructionArgs,
161
+ this.program
162
+ )
163
+ } else {
164
+ // get current default send library
165
+ const sendLibConfig = await accounts.SendLibraryConfig.fromAccountAddress(
166
+ connection,
167
+ defaultSendLibConfig,
168
+ commitmentOrConfig
169
+ )
170
+ if (sendLibConfig.messageLib.toBase58() === msgLib.toBase58()) {
171
+ return null
172
+ }
173
+
174
+ return instructions.createSetDefaultSendLibraryInstruction(
175
+ {
176
+ admin,
177
+ endpoint: settingPDA,
178
+ defaultSendLibraryConfig: defaultSendLibConfig,
179
+ messageLibInfo: msgLibInfo,
180
+ program: this.program,
181
+ eventAuthority: this.eventAuthorityPDA,
182
+ } satisfies instructions.SetDefaultSendLibraryInstructionAccounts,
183
+ {
184
+ params: {
185
+ eid: dstEid,
186
+ newLib: msgLib,
187
+ } satisfies types.SetDefaultSendLibraryParams,
188
+ } satisfies instructions.SetDefaultSendLibraryInstructionArgs,
189
+ this.program
190
+ )
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Sets the default receive library.
196
+ *
197
+ * @param {Connection} connection - The connection to the Solana cluster.
198
+ * @param {PublicKey} admin - The admin public key.
199
+ * @param {PublicKey} messageLibProgram - The message library program public key.
200
+ * @param {number} srcEid - The source endpoint ID.
201
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
202
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
203
+ */
204
+ async setDefaultReceiveLibrary(
205
+ connection: Connection,
206
+ admin: PublicKey,
207
+ messageLibProgram: PublicKey,
208
+ srcEid: number,
209
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
210
+ ): Promise<TransactionInstruction | null> {
211
+ const [msgLib] = new pdaDeriver.MessageLibPDADeriver(messageLibProgram).messageLib()
212
+ const [defaultReceiveLibConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid)
213
+ const [settingPDA] = this.deriver.setting()
214
+ const [defaultMsgLibInfo] = this.deriver.messageLibraryInfo(msgLib)
215
+ const info = await connection.getAccountInfo(defaultReceiveLibConfig, commitmentOrConfig)
216
+ if (!info) {
217
+ return instructions.createInitDefaultReceiveLibraryInstruction(
218
+ {
219
+ admin,
220
+ endpoint: settingPDA,
221
+ defaultReceiveLibraryConfig: defaultReceiveLibConfig,
222
+ messageLibInfo: defaultMsgLibInfo,
223
+ program: this.program,
224
+ eventAuthority: this.eventAuthorityPDA,
225
+ } satisfies instructions.InitDefaultReceiveLibraryInstructionAccounts,
226
+ {
227
+ params: {
228
+ eid: srcEid,
229
+ newLib: msgLib,
230
+ } satisfies types.InitDefaultReceiveLibraryParams,
231
+ } satisfies instructions.InitDefaultReceiveLibraryInstructionArgs,
232
+ this.program
233
+ )
234
+ } else {
235
+ // get current default receive library
236
+ const receiveLibConfig = await accounts.ReceiveLibraryConfig.fromAccountAddress(
237
+ connection,
238
+ defaultReceiveLibConfig,
239
+ commitmentOrConfig
240
+ )
241
+ if (receiveLibConfig.messageLib.toBase58() === msgLib.toBase58()) {
242
+ return null
243
+ }
244
+
245
+ return instructions.createSetDefaultReceiveLibraryInstruction(
246
+ {
247
+ admin,
248
+ endpoint: settingPDA,
249
+ defaultReceiveLibraryConfig: defaultReceiveLibConfig,
250
+ messageLibInfo: defaultMsgLibInfo,
251
+ program: this.program,
252
+ eventAuthority: this.eventAuthorityPDA,
253
+ } satisfies instructions.SetDefaultReceiveLibraryInstructionAccounts,
254
+ {
255
+ params: {
256
+ eid: srcEid,
257
+ newLib: msgLib,
258
+ gracePeriod: 0, // TODO: set grace period
259
+ } satisfies types.SetDefaultReceiveLibraryParams,
260
+ } satisfies instructions.SetDefaultReceiveLibraryInstructionArgs,
261
+ this.program
262
+ )
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Initializes the OApp configuration.
268
+ *
269
+ * @param {PublicKey} delegate - The delegate public key.
270
+ * @param {MessageLibInterface} msgLibSDK - The message library SDK.
271
+ * @param {PublicKey} payer - The payer public key.
272
+ * @param {PublicKey} oappID - The OApp ID public key.
273
+ * @param {number} eid - The endpoint ID.
274
+ * @returns {TransactionInstruction} The transaction instruction.
275
+ */
276
+ initOAppConfig(
277
+ delegate: PublicKey,
278
+ msgLibSDK: MessageLibInterface,
279
+ payer: PublicKey,
280
+ oappID: PublicKey,
281
+ eid: number
282
+ ): TransactionInstruction {
283
+ const [msgLib] = new MessageLibPDADeriver(msgLibSDK.program).messageLib()
284
+ const [oappRegistry] = this.deriver.oappRegistry(oappID)
285
+
286
+ const [msgLibInfo] = this.deriver.messageLibraryInfo(msgLib)
287
+ // if (!(await uln.getOappConfig(connection, oappID, eid, commitmentOrConfig))) {
288
+ // init oapp config
289
+ return instructions.createInitConfigInstruction(
290
+ {
291
+ delegate,
292
+ oappRegistry,
293
+ messageLib: msgLib,
294
+ messageLibInfo: msgLibInfo,
295
+ messageLibProgram: msgLibSDK.program,
296
+ anchorRemainingAccounts: msgLibSDK.getInitConfigIXAccountMetaForCPI(payer, oappID, eid),
297
+ } satisfies instructions.InitConfigInstructionAccounts,
298
+ {
299
+ params: {
300
+ eid: eid,
301
+ oapp: oappID,
302
+ } satisfies types.InitConfigParams,
303
+ } satisfies instructions.InitConfigInstructionArgs,
304
+ this.program
305
+ )
306
+ }
307
+
308
+ /**
309
+ * Initializes the OApp nonce.
310
+ *
311
+ * @param {PublicKey} delegate - The delegate public key.
312
+ * @param {number} dstEid - The destination endpoint ID.
313
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
314
+ * @param {Uint8Array} remoteOappAddr - The remote OApp address.
315
+ * @returns {TransactionInstruction} The transaction instruction.
316
+ */
317
+ initOAppNonce(
318
+ delegate: PublicKey, // payer
319
+ dstEid: number,
320
+ oappIDPDA: PublicKey,
321
+ remoteOappAddr: Uint8Array
322
+ ): TransactionInstruction {
323
+ const [nonce] = this.deriver.nonce(oappIDPDA, dstEid, remoteOappAddr)
324
+ const [pendingNonce] = this.deriver.pendingNonce(oappIDPDA, dstEid, remoteOappAddr)
325
+ const [oappRegistry] = this.deriver.oappRegistry(oappIDPDA)
326
+
327
+ return instructions.createInitNonceInstruction(
328
+ {
329
+ nonce,
330
+ pendingInboundNonce: pendingNonce,
331
+ oappRegistry,
332
+ delegate,
333
+ } satisfies instructions.InitNonceInstructionAccounts,
334
+ {
335
+ params: {
336
+ localOapp: oappIDPDA,
337
+ remoteOapp: Array.from(remoteOappAddr),
338
+ remoteEid: dstEid,
339
+ } satisfies types.InitNonceParams,
340
+ } satisfies instructions.InitNonceInstructionArgs,
341
+ this.program
342
+ )
343
+ }
344
+
345
+ /**
346
+ * Initializes the send library.
347
+ *
348
+ * @param {PublicKey} delegate - The delegate public key.
349
+ * @param {PublicKey} sender - The sender public key.
350
+ * @param {number} dstEid - The destination endpoint ID.
351
+ * @returns {TransactionInstruction} The transaction instruction.
352
+ */
353
+ initSendLibrary(delegate: PublicKey, sender: PublicKey, dstEid: number): TransactionInstruction {
354
+ const [oappRegistry] = this.deriver.oappRegistry(sender)
355
+ const [sendLibraryConfig] = this.deriver.sendLibraryConfig(sender, dstEid)
356
+
357
+ return instructions.createInitSendLibraryInstruction(
358
+ {
359
+ delegate,
360
+ oappRegistry,
361
+ sendLibraryConfig: sendLibraryConfig,
362
+ } satisfies instructions.InitSendLibraryInstructionAccounts,
363
+ {
364
+ params: {
365
+ sender,
366
+ eid: dstEid,
367
+ } satisfies types.InitSendLibraryParams,
368
+ } satisfies instructions.InitSendLibraryInstructionArgs,
369
+ this.program
370
+ )
371
+ }
372
+
373
+ /**
374
+ * Sets the send library.
375
+ *
376
+ * @param {PublicKey} oappAdmin - The OApp admin public key.
377
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
378
+ * @param {PublicKey} newSendLibProgram - The new send library program public key.
379
+ * @param {number} dstEid - The destination endpoint ID.
380
+ * @returns {TransactionInstruction} The transaction instruction.
381
+ */
382
+ setSendLibrary(
383
+ oappAdmin: PublicKey,
384
+ oappIDPDA: PublicKey,
385
+ newSendLibProgram: PublicKey,
386
+ dstEid: number
387
+ ): TransactionInstruction {
388
+ const [newSendLib] = new MessageLibPDADeriver(newSendLibProgram).messageLib()
389
+ const [sendLibraryConfig] = this.deriver.sendLibraryConfig(oappIDPDA, dstEid)
390
+ const [sendLibraryInfo] = this.deriver.messageLibraryInfo(newSendLib)
391
+ const [oappRegistry] = this.deriver.oappRegistry(oappIDPDA)
392
+
393
+ const ix = instructions.createSetSendLibraryInstruction(
394
+ {
395
+ signer: oappAdmin,
396
+ sendLibraryConfig: sendLibraryConfig,
397
+ messageLibInfo: sendLibraryInfo,
398
+ oappRegistry,
399
+ program: this.program,
400
+ eventAuthority: this.eventAuthorityPDA,
401
+ } satisfies instructions.SetSendLibraryInstructionAccounts,
402
+ {
403
+ params: {
404
+ sender: oappIDPDA,
405
+ eid: dstEid,
406
+ newLib: newSendLib,
407
+ } satisfies types.SetSendLibraryParams,
408
+ } satisfies instructions.SetSendLibraryInstructionArgs,
409
+ this.program
410
+ )
411
+ return ix
412
+ }
413
+
414
+ /**
415
+ * Initializes the receive library.
416
+ *
417
+ * @param {PublicKey} delegate - The delegate public key.
418
+ * @param {PublicKey} receiver - The receiver public key.
419
+ * @param {number} srcEid - The source endpoint ID.
420
+ * @returns {TransactionInstruction} The transaction instruction.
421
+ */
422
+ initReceiveLibrary(delegate: PublicKey, receiver: PublicKey, srcEid: number): TransactionInstruction {
423
+ const [oappRegistry] = this.deriver.oappRegistry(receiver)
424
+ const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(receiver, srcEid)
425
+
426
+ return instructions.createInitReceiveLibraryInstruction(
427
+ {
428
+ delegate,
429
+ oappRegistry,
430
+ receiveLibraryConfig: receiveLibraryConfig,
431
+ } satisfies instructions.InitReceiveLibraryInstructionAccounts,
432
+ {
433
+ params: {
434
+ receiver,
435
+ eid: srcEid,
436
+ } satisfies types.InitReceiveLibraryParams,
437
+ } satisfies instructions.InitReceiveLibraryInstructionArgs,
438
+ this.program
439
+ )
440
+ }
441
+
442
+ /**
443
+ * Sets the receive library.
444
+ *
445
+ * @param {PublicKey} oappAdmin - The OApp admin public key.
446
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
447
+ * @param {PublicKey} newReceiveLibProgram - The new receive library program public key.
448
+ * @param {number} srcEid - The source endpoint ID.
449
+ * @param {bigint | number} [gracePeriod] - The grace period.
450
+ * @returns {TransactionInstruction} The transaction instruction.
451
+ */
452
+ setReceiveLibrary(
453
+ oappAdmin: PublicKey,
454
+ oappIDPDA: PublicKey,
455
+ newReceiveLibProgram: PublicKey,
456
+ srcEid: number,
457
+ gracePeriod?: bigint | number
458
+ ): TransactionInstruction {
459
+ const [newReceiveLib] = new MessageLibPDADeriver(newReceiveLibProgram).messageLib()
460
+ const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(oappIDPDA, srcEid)
461
+ const [receiveLibraryInfo] = this.deriver.messageLibraryInfo(newReceiveLib)
462
+ const [oappRegistry] = this.deriver.oappRegistry(oappIDPDA)
463
+
464
+ const ix = instructions.createSetReceiveLibraryInstruction(
465
+ {
466
+ signer: oappAdmin,
467
+ receiveLibraryConfig: receiveLibraryConfig,
468
+ messageLibInfo: receiveLibraryInfo,
469
+ oappRegistry,
470
+ program: this.program,
471
+ eventAuthority: this.eventAuthorityPDA,
472
+ } satisfies instructions.SetReceiveLibraryInstructionAccounts,
473
+ {
474
+ params: {
475
+ receiver: oappIDPDA,
476
+ eid: srcEid,
477
+ newLib: newReceiveLib,
478
+ gracePeriod: gracePeriod === undefined ? 0 : new BN(gracePeriod.toString()),
479
+ } satisfies types.SetReceiveLibraryParams,
480
+ } satisfies instructions.SetReceiveLibraryInstructionArgs,
481
+ this.program
482
+ )
483
+ return ix
484
+ }
485
+
486
+ /**
487
+ * Sets the OApp configuration.
488
+ *
489
+ * @param {Connection} connection - The connection to the Solana cluster.
490
+ * @param {PublicKey} oappDelegate - The OApp delegate public key.
491
+ * @param {PublicKey} oappID - The OApp ID public key.
492
+ * @param {PublicKey} msgLibProgram - The message library program public key.
493
+ * @param {number} eid - The endpoint ID.
494
+ * @param {object} config - The configuration object.
495
+ * @param {SetConfigType} config.configType - The configuration type.
496
+ * @param {UlnProgram.types.ExecutorConfig | UlnProgram.types.UlnConfig} config.value - The configuration value.
497
+ * @param {Commitment} [commitment='confirmed'] - The commitment level.
498
+ * @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
499
+ * @throws {Error} If the message library version is unsupported.
500
+ */
501
+ async setOappConfig(
502
+ connection: Connection,
503
+ oappDelegate: PublicKey,
504
+ oappID: PublicKey,
505
+ msgLibProgram: PublicKey,
506
+ eid: number,
507
+ config: {
508
+ configType: SetConfigType
509
+ value: UlnProgram.types.ExecutorConfig | UlnProgram.types.UlnConfig
510
+ },
511
+ commitment: Commitment = 'confirmed'
512
+ ): Promise<TransactionInstruction> {
513
+ const [msgLib] = new MessageLibPDADeriver(msgLibProgram).messageLib()
514
+ const [msgLibInfo] = this.deriver.messageLibraryInfo(msgLib)
515
+
516
+ const msgLibVersion = await this.getMessageLibVersion(connection, oappDelegate, msgLibProgram, commitment)
517
+ let msgLibClient: MessageLibInterface
518
+ if (msgLibVersion?.major.toString() === '0' && msgLibVersion.minor == 0 && msgLibVersion.endpointVersion == 2) {
519
+ msgLibClient = new SimpleMessageLibProgram.SimpleMessageLib(msgLibProgram)
520
+ } else if (
521
+ msgLibVersion?.major.toString() === '3' &&
522
+ msgLibVersion.minor == 0 &&
523
+ msgLibVersion.endpointVersion == 2
524
+ ) {
525
+ msgLibClient = new UlnProgram.Uln(msgLibProgram)
526
+ } else {
527
+ throw new Error(
528
+ `unsupported message lib version ${msgLibVersion?.major.toString()}.${msgLibVersion?.minor.toString()}`
529
+ )
530
+ }
531
+
532
+ const [oappRegistry] = this.deriver.oappRegistry(oappID)
533
+ const ix = instructions.createSetConfigInstruction(
534
+ {
535
+ signer: oappDelegate,
536
+ messageLibInfo: msgLibInfo,
537
+ messageLib: msgLib,
538
+ messageLibProgram: msgLibProgram,
539
+ oappRegistry,
540
+ anchorRemainingAccounts: await msgLibClient.getSetConfigIXAccountMetaForCPI(this.program, oappID, eid),
541
+ },
542
+ {
543
+ params: {
544
+ eid,
545
+ configType: config.configType,
546
+ config:
547
+ msgLibProgram.toBase58() === SimpleMessageLibProgram.PROGRAM_ID.toBase58()
548
+ ? new Uint8Array(10)
549
+ : UlnProgram.Uln.constructSetConfigData(config.configType, config.value),
550
+ oapp: oappID,
551
+ } satisfies types.SetConfigParams,
552
+ } satisfies instructions.SetConfigInstructionArgs,
553
+ this.program
554
+ )
555
+ return ix
556
+ }
557
+
558
+ /// send a simulated transaction to the endpoint to get the fee for sending a message
559
+ /**
560
+ *
561
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
562
+ *
563
+ * caculate the fee for sending a message with ULN:
564
+ * 1. executorFee: feeForGas + feeForOptionType
565
+ * * feeForGas: ((gas + gasForCalldata) * gasPriceInUnit * priceRatio / priceRatioDenominator) * multiplier_bps / 10000
566
+ * * feeForOptionType: nativeDrop/lzReceive/lzCompose
567
+ * 2. oracleFee: feeForGas
568
+ * * feeForGas: same above
569
+ *
570
+ * The priceRatioDenominator is 10^20
571
+ * totalFee = executorFee + oracleFee * numOracles(requiredOracles + optionalOracles)
572
+ *
573
+ * @param {Connection} connection - The connection to the Solana cluster.
574
+ * @param {PublicKey} payer - The payer public key.
575
+ * @param {PacketPath} path - The packet path.
576
+ * @param {MessageLibInterface} msgLibProgram - The message library program.
577
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
578
+ * @throws {Error} If the default send library is not initialized or the message library is blocked.
579
+ */
580
+ async getQuoteIXAccountMetaForCPI(
581
+ connection: Connection,
582
+ payer: PublicKey,
583
+ path: SolanaPacketPath,
584
+ msgLibProgram: MessageLibInterface
585
+ ): Promise<AccountMeta[]> {
586
+ const { sender: sender_, dstEid, receiver: receiver_ } = path
587
+ const sender = new PublicKey(arrayify(sender_))
588
+ const receiver = addressToBytes32(receiver_)
589
+ const sendLibInfo = await this.getSendLibrary(connection, sender, dstEid)
590
+ if (!sendLibInfo?.programId) {
591
+ throw new Error('default send library not initialized or blocked message lib')
592
+ }
593
+ const { msgLib, programId: owner } = sendLibInfo
594
+ const [sendLibraryInfo] = this.deriver.messageLibraryInfo(msgLib)
595
+ const remainingAccounts = await msgLibProgram.getQuoteIXAccountMetaForCPI(connection, payer, path)
596
+
597
+ const [setting] = this.deriver.setting()
598
+ const [defaultSendLibraryConfig] = this.deriver.defaultSendLibraryConfig(dstEid)
599
+ const [sendLibraryConfig] = this.deriver.sendLibraryConfig(sender, dstEid)
600
+ const [nonce] = this.deriver.nonce(sender, dstEid, receiver)
601
+
602
+ const accounts = instructions.createQuoteInstructionAccounts(
603
+ {
604
+ sendLibraryConfig: sendLibraryConfig,
605
+ sendLibraryProgram: owner,
606
+ defaultSendLibraryConfig: defaultSendLibraryConfig,
607
+ endpoint: setting,
608
+ nonce,
609
+ sendLibraryInfo,
610
+ anchorRemainingAccounts: remainingAccounts,
611
+ } satisfies instructions.QuoteInstructionAccounts,
612
+ this.program
613
+ )
614
+ return Promise.resolve(
615
+ [
616
+ {
617
+ pubkey: this.program,
618
+ isSigner: false,
619
+ isWritable: false,
620
+ },
621
+ ].concat(accounts)
622
+ )
623
+ }
624
+
625
+ /**
626
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the send instruction.
627
+ *
628
+ * @param {Connection} connection - The connection to the Solana cluster.
629
+ * @param {PublicKey} payer - The payer public key.
630
+ * @param {PacketPath} path - The packet path.
631
+ * @param {MessageLibInterface} msgLibProgram - The message library program.
632
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
633
+ * @returns {Promise<AccountMeta[]>} A promise that resolves to an array of account metadata.
634
+ * @throws {Error} If the default send library is not initialized or the message library is blocked.
635
+ */
636
+ async getSendIXAccountMetaForCPI(
637
+ connection: Connection,
638
+ payer: PublicKey,
639
+ path: SolanaPacketPath,
640
+ msgLibProgram: MessageLibInterface,
641
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
642
+ ): Promise<AccountMeta[]> {
643
+ const { sender: sender_, dstEid, receiver: receiver_ } = path
644
+ const sender = new PublicKey(arrayify(sender_))
645
+ const receiver = addressToBytes32(receiver_)
646
+ const info = await this.getSendLibrary(connection, sender, dstEid, commitmentOrConfig)
647
+ if (!info?.programId) {
648
+ throw new Error('default send library not initialized or blocked message lib')
649
+ }
650
+ const sendLibrary = info.msgLib
651
+
652
+ const [sendLibraryInfo] = this.deriver.messageLibraryInfo(sendLibrary)
653
+ const remainingAccounts = await msgLibProgram.getSendIXAccountMetaForCPI(connection, payer, path)
654
+
655
+ const [defaultSendLibraryConfig] = this.deriver.defaultSendLibraryConfig(dstEid)
656
+ const [sendLibraryConfig] = this.deriver.sendLibraryConfig(sender, dstEid)
657
+ const [nonce] = this.deriver.nonce(sender, dstEid, receiver)
658
+
659
+ const accounts = instructions.createSendInstructionAccounts(
660
+ {
661
+ sender, //signer
662
+ /// this account should be derived from message lib
663
+ sendLibraryProgram: info.programId,
664
+ sendLibraryConfig,
665
+ defaultSendLibraryConfig: defaultSendLibraryConfig,
666
+ sendLibraryInfo,
667
+ endpoint: this.deriver.setting()[0],
668
+ program: this.program,
669
+ nonce: nonce,
670
+ eventAuthority: this.eventAuthorityPDA,
671
+ anchorRemainingAccounts: remainingAccounts,
672
+ } satisfies instructions.SendInstructionAccounts,
673
+ this.program
674
+ )
675
+
676
+ accounts.forEach((item: AccountMeta) => {
677
+ item.isSigner = false
678
+ })
679
+ return [
680
+ {
681
+ pubkey: this.program,
682
+ isSigner: false,
683
+ isWritable: false,
684
+ },
685
+ ].concat(accounts)
686
+ }
687
+
688
+ /**
689
+ * Skips a message.
690
+ *
691
+ * @param {PublicKey} payer - The payer public key.
692
+ * @param {PublicKey} sender - The sender public key.
693
+ * @param {PublicKey} receiver - The receiver public key.
694
+ * @param {number} srcEid - The source endpoint ID.
695
+ * @param {string} nonce - The nonce.
696
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
697
+ */
698
+ async skip(
699
+ payer: PublicKey,
700
+ sender: PublicKey,
701
+ receiver: PublicKey,
702
+ srcEid: number,
703
+ nonce: string
704
+ ): Promise<TransactionInstruction | null> {
705
+ const [nonceAccount] = this.deriver.nonce(receiver, srcEid, addressToBytes32(sender.toBase58()))
706
+ const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender.toBytes(), parseInt(nonce))
707
+ const [pendingInboundNonce] = this.deriver.pendingNonce(receiver, srcEid, sender.toBytes())
708
+ // get the delegate from endpoint
709
+ const [oAppRegistry] = PublicKey.findProgramAddressSync(
710
+ [Buffer.from(OAPP_SEED, 'utf-8'), receiver.toBuffer()],
711
+ this.program
712
+ )
713
+ const ix = instructions.createSkipInstruction(
714
+ {
715
+ signer: payer,
716
+ oappRegistry: oAppRegistry,
717
+ nonce: nonceAccount,
718
+ pendingInboundNonce: pendingInboundNonce,
719
+ payloadHash: payloadHash,
720
+ endpoint: this.deriver.setting()[0],
721
+ eventAuthority: this.eventAuthorityPDA,
722
+ program: this.program,
723
+ } satisfies instructions.SkipInstructionAccounts,
724
+ {
725
+ params: {
726
+ receiver: receiver,
727
+ srcEid: srcEid,
728
+ sender: Array.from(sender.toBytes()),
729
+ nonce: new BN(nonce),
730
+ } satisfies types.SkipParams,
731
+ } satisfies instructions.SkipInstructionArgs,
732
+ this.program
733
+ )
734
+ return Promise.resolve(ix)
735
+ }
736
+
737
+ /**
738
+ * Initializes the verification process.
739
+ *
740
+ * @param {Connection} connection - The connection to the Solana cluster.
741
+ * @param {PublicKey} payer - The payer public key.
742
+ * @param {PublicKey} sender - The sender public key.
743
+ * @param {PublicKey} receiver - The receiver public key.
744
+ * @param {number} srcEid - The source endpoint ID.
745
+ * @param {string} nonce - The nonce.
746
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
747
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
748
+ */
749
+ async initVerify(
750
+ connection: Connection,
751
+ payer: PublicKey,
752
+ sender: PublicKey,
753
+ receiver: PublicKey,
754
+ srcEid: number,
755
+ nonce: string,
756
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
757
+ ): Promise<TransactionInstruction | null> {
758
+ const [nonceAccount] = this.deriver.nonce(receiver, srcEid, addressToBytes32(sender.toBase58()))
759
+ const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender.toBytes(), parseInt(nonce))
760
+ const payloadHashInfo = await connection.getAccountInfo(payloadHash, commitmentOrConfig)
761
+ if (payloadHashInfo) {
762
+ // throw new Error('init verify already executed')
763
+ return null
764
+ }
765
+ return instructions.createInitVerifyInstruction(
766
+ {
767
+ payer,
768
+ nonce: nonceAccount,
769
+ payloadHash,
770
+ } satisfies instructions.InitVerifyInstructionAccounts,
771
+ {
772
+ params: {
773
+ srcEid,
774
+ sender: Array.from(sender.toBytes()),
775
+ receiver,
776
+ nonce: new BN(nonce),
777
+ } satisfies types.InitVerifyParams,
778
+ } satisfies instructions.InitVerifyInstructionArgs,
779
+ this.program
780
+ )
781
+ }
782
+
783
+ /**
784
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the verify instruction.
785
+ *
786
+ * @param {PacketV1Codec} packet - The packet.
787
+ * @param {PublicKey} receiveLibrary - The receive library public key.
788
+ * @returns {AccountMeta[]} An array of account metadata.
789
+ */
790
+ getVerifyIXAccountMetaForCPI(packet: PacketV1Codec, receiveLibrary: PublicKey): AccountMeta[] {
791
+ const receiver = new PublicKey(Buffer.from(packet.receiver().slice(2), 'hex'))
792
+ const srcEid = packet.srcEid()
793
+ const sender = addressToBytes32(packet.sender())
794
+
795
+ const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender, parseInt(packet.nonce()))
796
+ const [defaultReceiveLibraryConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid)
797
+ const [receiveLibraryConfig] = this.deriver.receiveLibraryConfig(receiver, srcEid)
798
+
799
+ const [nonce] = this.deriver.nonce(receiver, srcEid, sender)
800
+ const [pendingNonce] = this.deriver.pendingNonce(receiver, srcEid, sender)
801
+ // const [receiveLibraryPDA] = this.endpointDeriver.receiveLibrary(receiver, srcEid)
802
+ const accounts = instructions.createVerifyInstructionAccounts(
803
+ {
804
+ receiveLibrary: receiveLibrary,
805
+ receiveLibraryConfig: receiveLibraryConfig,
806
+ defaultReceiveLibraryConfig: defaultReceiveLibraryConfig,
807
+ nonce: nonce,
808
+ pendingInboundNonce: pendingNonce,
809
+ payloadHash: payloadHash,
810
+ program: this.program,
811
+ eventAuthority: this.eventAuthorityPDA,
812
+ } satisfies instructions.VerifyInstructionAccounts,
813
+ this.program
814
+ )
815
+ accounts.forEach((key) => {
816
+ key.isSigner = false
817
+ })
818
+ const program: AccountMeta = {
819
+ pubkey: this.program,
820
+ isSigner: false,
821
+ isWritable: false,
822
+ }
823
+ return [program, ...accounts]
824
+ }
825
+
826
+ /***
827
+ * resetConfig is only supported by ULN
828
+ */
829
+ // async getResetConfigIXAccountMetaForCPI(
830
+ // connection: Connection,
831
+ // msgLibProgram: PublicKey,
832
+ // oappID: PublicKey,
833
+ // eid: number,
834
+ // commitmentOrConfig: Commitment | GetAccountInfoConfig = 'confirmed'
835
+ // ): Promise<AccountMeta[]> {
836
+ // const uln = new UlnProgram.Uln(msgLibProgram)
837
+ // const [msgLib] = uln.ulnDeriver.messageLib()
838
+ // const [msgLibInfo] = this.endpointDeriver.messageLibraryAuthority(msgLib)
839
+
840
+ // const ix = instructions.createResetConfigInstruction(
841
+ // {
842
+ // oapp: oappID,
843
+ // messageLibAuthority: msgLibInfo,
844
+ // messageLib: msgLib,
845
+ // anchorRemainingAccounts: await uln.getResetConfigIXAccountMetaForCPI(
846
+ // connection,
847
+ // this.program,
848
+ // oappID,
849
+ // eid,
850
+ // commitmentOrConfig
851
+ // ),
852
+ // } as instructions.ResetConfigInstructionAccounts,
853
+ // // Fake params. Just to get the ix.keys
854
+ // {
855
+ // params: {
856
+ // eid: eid,
857
+ // messageLib: msgLib,
858
+ // } as types.ResetConfigParams,
859
+ // } as instructions.ResetConfigInstructionArgs
860
+ // )
861
+ // ix.keys.forEach((key) => {
862
+ // key.isSigner = false
863
+ // })
864
+ // return [
865
+ // {
866
+ // pubkey: this.program,
867
+ // isWritable: false,
868
+ // isSigner: false,
869
+ // } as AccountMeta,
870
+ // ].concat(ix.keys)
871
+ // }
872
+
873
+ /**
874
+ * snapshotConfig is only supported by ULN
875
+ */
876
+ // async getSnapshotConfigIXAccountMetaForCPI(
877
+ // connection: Connection,
878
+ // msgLibProgram: PublicKey,
879
+ // oappID: PublicKey,
880
+ // eid: number,
881
+ // commitmentOrConfig: Commitment | GetAccountInfoConfig = 'confirmed'
882
+ // ): Promise<AccountMeta[]> {
883
+ // const uln = new UlnProgram.Uln(msgLibProgram)
884
+ // const [msgLib] = uln.ulnDeriver.messageLib()
885
+ // const [msgLibInfo] = this.endpointDeriver.messageLibraryAuthority(msgLib)
886
+
887
+ // const ix = instructions.createSnapshotConfigInstruction(
888
+ // {
889
+ // oapp: oappID,
890
+ // messageLibAuthority: msgLibInfo,
891
+ // messageLib: msgLib,
892
+ // anchorRemainingAccounts: await uln.getSnapshotConfigIXAccountMetaForCPI(
893
+ // connection,
894
+ // this.program,
895
+ // oappID,
896
+ // eid,
897
+ // commitmentOrConfig
898
+ // ),
899
+ // } satisfies instructions.SnapshotConfigInstructionAccounts,
900
+ // // Fake params. Just to get the ix.keys
901
+ // {
902
+ // params: {
903
+ // eid: eid,
904
+ // messageLib: msgLib,
905
+ // } as types.SnapshotConfigParams,
906
+ // } as instructions.SnapshotConfigInstructionArgs
907
+ // )
908
+ // ix.keys.forEach((key) => {
909
+ // key.isSigner = false
910
+ // })
911
+ // return [
912
+ // {
913
+ // pubkey: this.program,
914
+ // isWritable: false,
915
+ // isSigner: false,
916
+ // },
917
+ // ].concat(ix.keys)
918
+ // }
919
+
920
+ /**
921
+ * @param composer. The composer is usually the PDA of the app's ID. It depends on the oapp's implementation.
922
+ */
923
+ // getDeliverComposedMessageIXAccountMetaForCPI(
924
+ // payer: PublicKey,
925
+ // composer: PublicKey,
926
+ // packet: PacketV1Codec
927
+ // ): AccountMeta[] {
928
+ // const receiver = new PublicKey(Buffer.from(packet.receiver().slice(2), 'hex'))
929
+ // const guid = Uint8Array.from(Buffer.from(packet.guid().slice(2), 'hex'))
930
+ // const message = ethers.utils.arrayify(ethers.utils.keccak256(packet.message()))
931
+ // const ix = instructions.createDeliverComposedMessageInstruction(
932
+ // {
933
+ // payer,
934
+ // receiver,
935
+ // composedMessage: this.endpointDeriver.composedMessage(receiver, guid, composer, message)[0],
936
+ // endpoint: this.endpointDeriver.setting()[0],
937
+ // endpointProgram: this.program,
938
+ // } satisfies instructions.DeliverComposedMessageInstructionAccounts,
939
+ // // Fake params. Just to get the ix.keys
940
+ // {
941
+ // params: {
942
+ // composer: payer,
943
+ // guid: Array.from(guid),
944
+ // message: Uint8Array.from([]),
945
+ // } as types.DeliverComposedMessageParams,
946
+ // } as instructions.DeliverComposedMessageInstructionArgs
947
+ // )
948
+ // ix.keys.forEach((key) => {
949
+ // key.isSigner = false
950
+ // })
951
+ // return [
952
+ // {
953
+ // pubkey: this.program,
954
+ // isWritable: false,
955
+ // isSigner: false,
956
+ // },
957
+ // ].concat(ix.keys)
958
+ // }
959
+
960
+ /**
961
+ * @param composer. The composer is usually the PDA of the app's ID. It depends on the oapp's implementation.
962
+ */
963
+ // getClearComposedMessageIXAccountMetaForCPI(composer: PublicKey, packet: PacketV1Codec): AccountMeta[] {
964
+ // const receiver = new PublicKey(Buffer.from(packet.receiver().slice(2), 'hex'))
965
+ // const guid = Uint8Array.from(Buffer.from(packet.guid().slice(2), 'hex'))
966
+ // const message = ethers.utils.arrayify(ethers.utils.keccak256(packet.message()))
967
+ // const ix = instructions.createClearComposedMessageInstruction(
968
+ // {
969
+ // composer,
970
+ // composedMessage: this.endpointDeriver.composedMessage(receiver, guid, composer, message)[0],
971
+ // endpoint: this.endpointDeriver.setting()[0],
972
+ // endpointProgram: this.program,
973
+ // } satisfies instructions.ClearComposedMessageInstructionAccounts,
974
+ // // Fake params. Just to get the ix.keys
975
+ // {
976
+ // params: {
977
+ // receiver: composer,
978
+ // guid: Array.from(guid),
979
+ // message: Uint8Array.from([]),
980
+ // } as types.ClearComposedMessageParams,
981
+ // } as instructions.ClearComposedMessageInstructionArgs
982
+ // )
983
+ // ix.keys.forEach((key) => {
984
+ // key.isSigner = false
985
+ // })
986
+ // return [
987
+ // {
988
+ // pubkey: this.program,
989
+ // isWritable: false,
990
+ // isSigner: false,
991
+ // } as AccountMeta,
992
+ // ].concat(ix.keys)
993
+ // }
994
+
995
+ /**
996
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the register OApp instruction.
997
+ *
998
+ * @param {PublicKey} payer - The payer public key.
999
+ * @param {PublicKey} oapp - The OApp public key.
1000
+ * @returns {AccountMeta[]} An array of account metadata.
1001
+ */
1002
+ getRegisterOappIxAccountMetaForCPI(payer: PublicKey, oapp: PublicKey): AccountMeta[] {
1003
+ const [oappRegistry] = this.deriver.oappRegistry(oapp)
1004
+ const eventAuthority = this.eventAuthorityPDA
1005
+ const keys = instructions.createRegisterOappInstructionAccounts(
1006
+ {
1007
+ payer,
1008
+ oapp,
1009
+ oappRegistry,
1010
+ eventAuthority,
1011
+ program: this.program,
1012
+ } satisfies instructions.RegisterOappInstructionAccounts,
1013
+ this.program
1014
+ )
1015
+ keys.forEach((key) => {
1016
+ key.isSigner = false
1017
+ })
1018
+ return [
1019
+ {
1020
+ pubkey: this.program,
1021
+ isSigner: false,
1022
+ isWritable: false,
1023
+ },
1024
+ ].concat(keys)
1025
+ }
1026
+
1027
+ /**
1028
+ * Gets the account metadata for the CPI (Cross-Program Invocation) of the skip instruction.
1029
+ *
1030
+ * @param {PublicKey} receiver - The receiver public key.
1031
+ * @param {Uint8Array} sender - The sender address.
1032
+ * @param {number} srcEid - The source endpoint ID.
1033
+ * @param {number} nonce - The nonce.
1034
+ * @returns {AccountMeta[]} An array of account metadata.
1035
+ */
1036
+ getSkipIxAccountMetaForCPI(receiver: PublicKey, sender: Uint8Array, srcEid: number, nonce: number): AccountMeta[] {
1037
+ const [noncePDA] = this.deriver.nonce(receiver, srcEid, sender)
1038
+ const [pendingNonce] = this.deriver.pendingNonce(receiver, srcEid, sender)
1039
+ const [payloadHash] = this.deriver.payloadHash(receiver, srcEid, sender, nonce)
1040
+ const [oappRegistry] = this.deriver.oappRegistry(receiver)
1041
+ const keys = instructions.createSkipInstructionAccounts(
1042
+ {
1043
+ signer: receiver,
1044
+ oappRegistry,
1045
+ nonce: noncePDA,
1046
+ pendingInboundNonce: pendingNonce,
1047
+ payloadHash,
1048
+ endpoint: this.deriver.setting()[0],
1049
+ program: this.program,
1050
+ eventAuthority: this.eventAuthorityPDA,
1051
+ } satisfies instructions.SkipInstructionAccounts,
1052
+ this.program
1053
+ )
1054
+ keys.forEach((key) => {
1055
+ key.isSigner = false
1056
+ })
1057
+ return [
1058
+ {
1059
+ pubkey: this.program,
1060
+ isSigner: false,
1061
+ isWritable: false,
1062
+ },
1063
+ ].concat(keys)
1064
+ }
1065
+
1066
+ /**
1067
+ * Checks if the given message library program is the default send library.
1068
+ *
1069
+ * @param {Connection} connection - The connection to the Solana cluster.
1070
+ * @param {PublicKey} messageLibProgram - The message library program public key.
1071
+ * @param {number} dstEid - The destination endpoint ID.
1072
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
1073
+ * @returns {Promise<boolean>} A promise that resolves to true if the message library program is the default send library, false otherwise.
1074
+ */
1075
+ async isDefaultSendLibrary(
1076
+ connection: Connection,
1077
+ messageLibProgram: PublicKey,
1078
+ dstEid: number,
1079
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
1080
+ ): Promise<boolean> {
1081
+ const [msgLib] = new pdaDeriver.MessageLibPDADeriver(messageLibProgram).messageLib()
1082
+ const info = await this.getDefaultSendLibrary(connection, dstEid, commitmentOrConfig)
1083
+ if (info) {
1084
+ // const [defaultSendLib] = new MessageLibPDADeriver(messageLibProgram).messageLib()
1085
+ return info.msgLib.equals(msgLib)
1086
+ }
1087
+ return false
1088
+ }
1089
+
1090
+ /**
1091
+ * Checks if the given message library program is the default receive library.
1092
+ *
1093
+ * @param {Connection} connection - The connection to the Solana cluster.
1094
+ * @param {PublicKey} messageLibProgram - The message library program public key.
1095
+ * @param {number} srcEid - The source endpoint ID.
1096
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
1097
+ * @returns {Promise<boolean>} A promise that resolves to true if the message library program is the default receive library, false otherwise.
1098
+ */
1099
+ async isDefaultReceiveLibrary(
1100
+ connection: Connection,
1101
+ messageLibProgram: PublicKey,
1102
+ srcEid: number,
1103
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
1104
+ ): Promise<boolean> {
1105
+ const [msgLib] = new pdaDeriver.MessageLibPDADeriver(messageLibProgram).messageLib()
1106
+ const info = await this.getDefaultReceiveLibrary(connection, srcEid, commitmentOrConfig)
1107
+ if (info) {
1108
+ return info.msgLib.equals(msgLib)
1109
+ }
1110
+ return false
1111
+ }
1112
+
1113
+ // all of below functions are retrieving accounts state
1114
+ /**
1115
+ * Gets the endpoint settings.
1116
+ *
1117
+ * @param {Connection} connection - The connection to the Solana cluster.
1118
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
1119
+ * @returns {Promise<EndpointSettings | null>} A promise that resolves to the endpoint settings or null if not found.
1120
+ */
1121
+ async getSetting(
1122
+ connection: Connection,
1123
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
1124
+ ): Promise<EndpointSettings | null> {
1125
+ const [setting] = this.deriver.setting()
1126
+ try {
1127
+ return await accounts.EndpointSettings.fromAccountAddress(connection, setting, commitmentOrConfig)
1128
+ } catch (e) {
1129
+ return null
1130
+ }
1131
+ }
1132
+
1133
+ /**
1134
+ * Gets the message library information.
1135
+ *
1136
+ * @param {Connection} connection - The connection to the Solana cluster.
1137
+ * @param {PublicKey} messageLibProgram - The message library program public key, It is a PDA of the message library program
1138
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
1139
+ * @returns {Promise<MessageLibInfo | null>} A promise that resolves to the message library information or null if not found.
1140
+ */
1141
+ async getMessageLibInfo(
1142
+ connection: Connection,
1143
+ messageLibProgram: PublicKey,
1144
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
1145
+ ): Promise<MessageLibInfo | null> {
1146
+ const [msgLib] = new pdaDeriver.MessageLibPDADeriver(messageLibProgram).messageLib()
1147
+ const [messageLibInfo] = this.deriver.messageLibraryInfo(msgLib)
1148
+ try {
1149
+ return await accounts.MessageLibInfo.fromAccountAddress(connection, messageLibInfo, commitmentOrConfig)
1150
+ } catch (e) {
1151
+ return null
1152
+ }
1153
+ }
1154
+
1155
+ /**
1156
+ * Gets the default receive library.
1157
+ *
1158
+ * @param {Connection} connection - The connection to the Solana cluster.
1159
+ * @param {number} srcEid - The source endpoint ID.
1160
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
1161
+ * @returns {Promise<{ msgLib: PublicKey; owner?: PublicKey } | null>} A promise that resolves to the default receive library or null if not found.
1162
+ */
1163
+ async getDefaultReceiveLibrary(
1164
+ connection: Connection,
1165
+ srcEid: number,
1166
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
1167
+ ): Promise<{ msgLib: PublicKey; owner?: PublicKey } | null> {
1168
+ const [defaultReceiveLibConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid)
1169
+ try {
1170
+ const defaultInfo = await accounts.ReceiveLibraryConfig.fromAccountAddress(
1171
+ connection,
1172
+ defaultReceiveLibConfig,
1173
+ commitmentOrConfig
1174
+ )
1175
+ const messageLibInfo = await connection.getAccountInfo(defaultInfo.messageLib, commitmentOrConfig)
1176
+ // notice: BlockedMessageLib is not initialized its PDA, so it will be null if defaultInfo.messageLib is BlockedMessageLib
1177
+ if (!messageLibInfo) {
1178
+ return {
1179
+ msgLib: defaultInfo.messageLib,
1180
+ }
1181
+ }
1182
+ return {
1183
+ owner: messageLibInfo.owner,
1184
+ msgLib: defaultInfo.messageLib,
1185
+ }
1186
+ } catch (e) {
1187
+ return null
1188
+ }
1189
+ }
1190
+
1191
+ /**
1192
+ * Gets the default send library.
1193
+ *
1194
+ * @param {Connection} connection - The connection to the Solana cluster.
1195
+ * @param {number} dstEid - The destination endpoint ID.
1196
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
1197
+ * @returns {Promise<{ msgLib: PublicKey; owner?: PublicKey } | null>} A promise that resolves to the default send library or null if not found.
1198
+ */
1199
+ async getDefaultSendLibrary(
1200
+ connection: Connection,
1201
+ dstEid: number,
1202
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
1203
+ ): Promise<{ msgLib: PublicKey; owner?: PublicKey } | null> {
1204
+ const [defaultSendLibConfig] = this.deriver.defaultSendLibraryConfig(dstEid)
1205
+ try {
1206
+ const defaultInfo = await accounts.SendLibraryConfig.fromAccountAddress(
1207
+ connection,
1208
+ defaultSendLibConfig,
1209
+ commitmentOrConfig
1210
+ )
1211
+ const messageLibInfo = await connection.getAccountInfo(defaultInfo.messageLib, commitmentOrConfig)
1212
+ // notice: BlockedMessageLib is not initialized its PDA, so it will be null if defaultInfo.messageLib is BlockedMessageLib
1213
+ if (!messageLibInfo) {
1214
+ return {
1215
+ msgLib: defaultInfo.messageLib,
1216
+ }
1217
+ }
1218
+ return {
1219
+ owner: messageLibInfo.owner,
1220
+ msgLib: defaultInfo.messageLib,
1221
+ }
1222
+ } catch (e) {
1223
+ return null
1224
+ }
1225
+ }
1226
+
1227
+ /**
1228
+ * Gets the configured send library for the app.
1229
+ *
1230
+ * @param {Connection} connection - The connection to the Solana cluster.
1231
+ * @param {PublicKey} oappPda - The OApp PDA.
1232
+ * @param {number} dstEid - The destination endpoint ID.
1233
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig='confirmed'] - The commitment level or account info configuration.
1234
+ * @returns {Promise<{ msgLib: PublicKey; programId?: PublicKey; isDefault: boolean } | null>} A promise that resolves to the configured send library or null if not found.
1235
+ */
1236
+ async getSendLibrary(
1237
+ connection: Connection,
1238
+ oappPda: PublicKey,
1239
+ dstEid: number,
1240
+ commitmentOrConfig: Commitment | GetAccountInfoConfig = 'confirmed'
1241
+ ): Promise<{ msgLib: PublicKey; programId?: PublicKey; isDefault: boolean } | null> {
1242
+ const [sendLibConfig] = this.deriver.sendLibraryConfig(oappPda, dstEid)
1243
+ const [defaultSendLibConfig] = this.deriver.defaultSendLibraryConfig(dstEid)
1244
+ const [defaultSendLibConfigBuf, sendLibConfigBuf] = await connection.getMultipleAccountsInfo(
1245
+ [defaultSendLibConfig, sendLibConfig],
1246
+ commitmentOrConfig
1247
+ )
1248
+ if (!defaultSendLibConfigBuf || !sendLibConfigBuf) {
1249
+ console.warn('send library not initialized, return empty array')
1250
+ return null
1251
+ }
1252
+ const [sendLibConfigInfo] = accounts.SendLibraryConfig.fromAccountInfo(sendLibConfigBuf, 0)
1253
+ const [defaultSendLibConfigInfo] = accounts.SendLibraryConfig.fromAccountInfo(defaultSendLibConfigBuf, 0)
1254
+ const msgLib =
1255
+ sendLibConfigInfo.messageLib.toString() === DefaultMessageLib.toString()
1256
+ ? defaultSendLibConfigInfo.messageLib
1257
+ : sendLibConfigInfo.messageLib
1258
+ const isDefault = sendLibConfigInfo.messageLib.toString() === DefaultMessageLib.toString()
1259
+ const msgLibInfo = await connection.getAccountInfo(msgLib, commitmentOrConfig)
1260
+
1261
+ // notice: BlockedMessageLib is not initialized its PDA, so it will be null if msgLib is BlockedMessageLib
1262
+ if (!msgLibInfo) {
1263
+ return {
1264
+ programId: undefined,
1265
+ msgLib,
1266
+ isDefault,
1267
+ }
1268
+ } else {
1269
+ return {
1270
+ programId: msgLibInfo.owner,
1271
+ msgLib,
1272
+ isDefault,
1273
+ }
1274
+ }
1275
+ }
1276
+
1277
+ /**
1278
+ * Gets the configured receive library for the app.
1279
+ *
1280
+ * @param {Connection} connection - The connection to the Solana cluster.
1281
+ * @param {PublicKey} oappPda - The OApp PDA.
1282
+ * @param {number} srcEid - The source endpoint ID.
1283
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
1284
+ * @returns {Promise<{ msgLib: PublicKey; programId?: PublicKey; isDefault: boolean; timeout: { msgLib: PublicKey; expiry: bigint } | null } | null>} A promise that resolves to the configured receive library or null if not found.
1285
+ */
1286
+ async getReceiveLibrary(
1287
+ connection: Connection,
1288
+ oappPda: PublicKey,
1289
+ srcEid: number,
1290
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
1291
+ ): Promise<{
1292
+ msgLib: PublicKey // message library pda, it might be null if the message lib is blocked
1293
+ programId?: PublicKey
1294
+ isDefault: boolean
1295
+ timeout: { msgLib: PublicKey; expiry: bigint } | null
1296
+ } | null> {
1297
+ const [receiveLibConfig] = this.deriver.receiveLibraryConfig(oappPda, srcEid)
1298
+ const accountInfo = await connection.getAccountInfo(receiveLibConfig, commitmentOrConfig)
1299
+ if (accountInfo == null) {
1300
+ // throw new Error(`Unable to find MessageLibConfig account at ${sendLibPda}`)
1301
+ return null
1302
+ }
1303
+ const [info] = accounts.ReceiveLibraryConfig.fromAccountInfo(accountInfo, 0)
1304
+ if (info.messageLib.toString() == DefaultMessageLib.toString()) {
1305
+ // use default message lib
1306
+ const [defaultReceiveLibConfig] = this.deriver.defaultReceiveLibraryConfig(srcEid)
1307
+ const defaultInfo = await accounts.ReceiveLibraryConfig.fromAccountAddress(
1308
+ connection,
1309
+ defaultReceiveLibConfig,
1310
+ commitmentOrConfig
1311
+ )
1312
+ const messageLibInfo = await connection.getAccountInfo(defaultInfo.messageLib, commitmentOrConfig)
1313
+ if (messageLibInfo) {
1314
+ const { timeout } = defaultInfo
1315
+ if (timeout) {
1316
+ return {
1317
+ programId: defaultInfo.messageLib,
1318
+ msgLib: defaultInfo.messageLib,
1319
+ isDefault: true,
1320
+ timeout: { msgLib: timeout.messageLib, expiry: BigInt(timeout.expiry.toString()) },
1321
+ }
1322
+ }
1323
+ }
1324
+ return {
1325
+ programId: messageLibInfo?.owner,
1326
+ msgLib: defaultInfo.messageLib,
1327
+ isDefault: true,
1328
+ timeout: null,
1329
+ }
1330
+ }
1331
+ const messageLibInfo = await connection.getAccountInfo(info.messageLib, commitmentOrConfig)
1332
+ invariant(messageLibInfo, 'messageLibInfo should not be null')
1333
+ const { timeout } = info
1334
+ if (timeout) {
1335
+ // const slot = await connection.getSlot()
1336
+ // const timestamp = await connection.getBlockTime(slot)
1337
+ // invariant(timestamp, 'timestamp should not be null')
1338
+ // const isValid = parseInt(timeout.expiry.toString()) > timestamp
1339
+ return {
1340
+ programId: messageLibInfo.owner,
1341
+ msgLib: info.messageLib,
1342
+ isDefault: false,
1343
+ timeout: { msgLib: timeout.messageLib, expiry: BigInt(timeout.expiry.toString()) },
1344
+ }
1345
+ }
1346
+ return { programId: messageLibInfo.owner, msgLib: info.messageLib, isDefault: false, timeout: null }
1347
+ }
1348
+
1349
+ // rename to a more generic name
1350
+ /**
1351
+ * Gets the inbound payload hash.
1352
+ *
1353
+ * @param {Connection} connection - The connection to the Solana cluster.
1354
+ * @param {PublicKey} receiver - The receiver public key.
1355
+ * @param {number} srcEid - The source endpoint ID.
1356
+ * @param {Uint8Array} sender - The sender address.
1357
+ * @param {number} nonce - The nonce.
1358
+ * @param {Uint8Array} _payloadHash - The payload hash.
1359
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
1360
+ * @returns {Promise<PayloadHash | null>} A promise that resolves to the payload hash or null if not found.
1361
+ */
1362
+ async getInboundPayloadHash(
1363
+ connection: Connection,
1364
+ receiver: PublicKey,
1365
+ srcEid: number,
1366
+ sender: Uint8Array,
1367
+ nonce: number,
1368
+ _payloadHash: Uint8Array,
1369
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
1370
+ ): Promise<PayloadHash | null> {
1371
+ const [payloadHashPDA] = this.deriver.payloadHash(receiver, srcEid, sender, nonce)
1372
+ const accountInfo = await connection.getAccountInfo(payloadHashPDA, commitmentOrConfig)
1373
+ if (!accountInfo) {
1374
+ return null
1375
+ }
1376
+ return PayloadHash.fromAccountInfo(accountInfo, 0)[0]
1377
+ }
1378
+
1379
+ /**
1380
+ * Gets the composed message state.
1381
+ *
1382
+ * @param {Connection} connection - The connection to the Solana cluster.
1383
+ * @param {PublicKey} from - The sender public key.
1384
+ * @param {types.SendComposeParams} params - The send compose parameters.
1385
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
1386
+ * @returns {Promise<ComposeMessageState | null>} A promise that resolves to the composed message state or null if not found.
1387
+ */
1388
+ async getComposedMessageState(
1389
+ connection: Connection,
1390
+ from: PublicKey,
1391
+ params: types.SendComposeParams,
1392
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
1393
+ ): Promise<ComposeMessageState | null> {
1394
+ const message = keccak_256(params.message)
1395
+ const [composedMessagePDA] = this.deriver.composedMessage(
1396
+ from,
1397
+ Uint8Array.from(params.guid),
1398
+ params.index,
1399
+ params.to,
1400
+ message
1401
+ )
1402
+ const accountInfo = await connection.getAccountInfo(composedMessagePDA, commitmentOrConfig)
1403
+ if (!accountInfo) {
1404
+ return null
1405
+ }
1406
+ return ComposeMessageState.fromAccountInfo(accountInfo, 0)[0]
1407
+ }
1408
+
1409
+ /**
1410
+ * Gets the nonce.
1411
+ *
1412
+ * @param {Connection} connection - The connection to the Solana cluster.
1413
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
1414
+ * @param {number} remoteEid - The remote endpoint ID.
1415
+ * @param {Uint8Array} remoteOappAddr - The remote OApp address.
1416
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
1417
+ * @returns {Promise<accounts.Nonce | null>} A promise that resolves to the nonce or null if not found.
1418
+ */
1419
+ async getNonce(
1420
+ connection: Connection,
1421
+ oappIDPDA: PublicKey,
1422
+ remoteEid: number,
1423
+ remoteOappAddr: Uint8Array,
1424
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
1425
+ ): Promise<accounts.Nonce | null> {
1426
+ const [nonce] = this.deriver.nonce(oappIDPDA, remoteEid, remoteOappAddr)
1427
+ try {
1428
+ return await accounts.Nonce.fromAccountAddress(connection, nonce, commitmentOrConfig)
1429
+ } catch (e) {
1430
+ return null
1431
+ }
1432
+ }
1433
+
1434
+ /**
1435
+ * Gets the pending inbound nonce.
1436
+ *
1437
+ * @param {Connection} connection - The connection to the Solana cluster.
1438
+ * @param {PublicKey} oappIDPDA - The OApp ID PDA.
1439
+ * @param {number} remoteEid - The remote endpoint ID.
1440
+ * @param {Uint8Array} remoteOappAddr - The remote OApp address.
1441
+ * @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment level or account info configuration.
1442
+ * @returns {Promise<accounts.PendingInboundNonce | null>} A promise that resolves to the pending inbound nonce or null if not found.
1443
+ */
1444
+ async getPendingInboundNonce(
1445
+ connection: Connection,
1446
+ oappIDPDA: PublicKey,
1447
+ remoteEid: number,
1448
+ remoteOappAddr: Uint8Array,
1449
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig
1450
+ ): Promise<accounts.PendingInboundNonce | null> {
1451
+ const [nonce] = this.deriver.pendingNonce(oappIDPDA, remoteEid, remoteOappAddr)
1452
+ try {
1453
+ return await accounts.PendingInboundNonce.fromAccountAddress(connection, nonce, commitmentOrConfig)
1454
+ } catch (e) {
1455
+ return null
1456
+ }
1457
+ }
1458
+
1459
+ /**
1460
+ * Gets the message library version.
1461
+ *
1462
+ * @param {Connection} connection - The connection to the Solana cluster.
1463
+ * @param {PublicKey} payer - The payer public key.
1464
+ * @param {PublicKey} messageLibProgram - The message library program public key.
1465
+ * @param {Commitment} [commitment='confirmed'] - The commitment level.
1466
+ * @returns {Promise<Version | null>} A promise that resolves to the version or null if not found.
1467
+ */
1468
+ async getMessageLibVersion(
1469
+ connection: Connection,
1470
+ payer: PublicKey,
1471
+ messageLibProgram: PublicKey,
1472
+ commitment: Commitment = 'confirmed'
1473
+ ): Promise<Version | null> {
1474
+ const ix = SimpleMessageLibProgram.instructions.createVersionInstruction(messageLibProgram)
1475
+
1476
+ const simulateResp = await simulateTransaction(connection, [ix], messageLibProgram, payer, commitment)
1477
+ const version = SimpleMessageLibProgram.types.versionBeet.read(simulateResp, 0)
1478
+ return version
1479
+ }
1480
+
1481
+ /**
1482
+ * Transfers the admin role to a new admin.
1483
+ *
1484
+ * @param {Connection} connection - The connection to the Solana cluster.
1485
+ * @param {PublicKey} admin - The current admin public key.
1486
+ * @param {PublicKey} newAdmin - The new admin public key.
1487
+ * @param {Commitment} [commitment='confirmed'] - The commitment level.
1488
+ * @returns {Promise<TransactionInstruction | null>} A promise that resolves to the transaction instruction or null if not needed.
1489
+ */
1490
+ async transferAdmin(
1491
+ connection: Connection,
1492
+ admin: PublicKey,
1493
+ newAdmin: PublicKey,
1494
+ commitment: Commitment = 'confirmed'
1495
+ ): Promise<TransactionInstruction | null> {
1496
+ const [settingPDA] = this.deriver.setting()
1497
+ const endpointSettings = await accounts.EndpointSettings.fromAccountAddress(connection, settingPDA, commitment)
1498
+ if (endpointSettings.admin.toBase58() === newAdmin.toBase58()) {
1499
+ console.warn('endpoint admin not need change')
1500
+ return null
1501
+ }
1502
+ return instructions.createTransferAdminInstruction(
1503
+ {
1504
+ admin,
1505
+ endpoint: settingPDA,
1506
+ eventAuthority: this.eventAuthorityPDA,
1507
+ program: this.program,
1508
+ },
1509
+ {
1510
+ params: {
1511
+ admin: newAdmin,
1512
+ },
1513
+ },
1514
+ this.program
1515
+ )
1516
+ }
1517
+ }