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