@across-protocol/sdk 4.3.137-alpha.3 → 4.3.137

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 (363) hide show
  1. package/dist/cjs/src/addressAggregator/adapters/abstract.js +5 -9
  2. package/dist/cjs/src/addressAggregator/adapters/abstract.js.map +1 -1
  3. package/dist/cjs/src/apiClient/productionClient.js +23 -26
  4. package/dist/cjs/src/apiClient/productionClient.js.map +1 -1
  5. package/dist/cjs/src/arch/evm/index.d.ts +0 -1
  6. package/dist/cjs/src/arch/evm/index.js +0 -1
  7. package/dist/cjs/src/arch/evm/index.js.map +1 -1
  8. package/dist/cjs/src/arch/index.d.ts +0 -1
  9. package/dist/cjs/src/arch/index.js +1 -2
  10. package/dist/cjs/src/arch/index.js.map +1 -1
  11. package/dist/cjs/src/caching/Arweave/ArweaveClient.js +2 -6
  12. package/dist/cjs/src/caching/Arweave/ArweaveClient.js.map +1 -1
  13. package/dist/cjs/src/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +2 -9
  14. package/dist/cjs/src/clients/SpokePoolClient/EVMSpokePoolClient.js +12 -33
  15. package/dist/cjs/src/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  16. package/dist/cjs/src/clients/SpokePoolClient/index.d.ts +0 -3
  17. package/dist/cjs/src/clients/SpokePoolClient/index.js +1 -7
  18. package/dist/cjs/src/clients/SpokePoolClient/index.js.map +1 -1
  19. package/dist/cjs/src/clients/SpokePoolClient/types.d.ts +0 -1
  20. package/dist/cjs/src/clients/SpokePoolClient/types.js +1 -2
  21. package/dist/cjs/src/clients/SpokePoolClient/types.js.map +1 -1
  22. package/dist/cjs/src/clients/index.d.ts +1 -1
  23. package/dist/cjs/src/clients/index.js +1 -3
  24. package/dist/cjs/src/clients/index.js.map +1 -1
  25. package/dist/cjs/src/coingecko/Coingecko.js +8 -30
  26. package/dist/cjs/src/coingecko/Coingecko.js.map +1 -1
  27. package/dist/cjs/src/gasPriceOracle/index.d.ts +1 -1
  28. package/dist/cjs/src/gasPriceOracle/oracle.d.ts +1 -3
  29. package/dist/cjs/src/gasPriceOracle/oracle.js +10 -15
  30. package/dist/cjs/src/gasPriceOracle/oracle.js.map +1 -1
  31. package/dist/cjs/src/gasPriceOracle/types.d.ts +1 -6
  32. package/dist/cjs/src/gasPriceOracle/types.js +0 -5
  33. package/dist/cjs/src/gasPriceOracle/types.js.map +1 -1
  34. package/dist/cjs/src/priceClient/adapters/baseAdapter.d.ts +2 -1
  35. package/dist/cjs/src/priceClient/adapters/baseAdapter.js +5 -10
  36. package/dist/cjs/src/priceClient/adapters/baseAdapter.js.map +1 -1
  37. package/dist/cjs/src/relayFeeCalculator/chain-queries/factory.d.ts +152 -81
  38. package/dist/cjs/src/relayFeeCalculator/chain-queries/factory.js +0 -5
  39. package/dist/cjs/src/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  40. package/dist/cjs/src/relayFeeCalculator/chain-queries/index.d.ts +0 -1
  41. package/dist/cjs/src/relayFeeCalculator/chain-queries/index.js +0 -1
  42. package/dist/cjs/src/relayFeeCalculator/chain-queries/index.js.map +1 -1
  43. package/dist/cjs/src/relayFeeCalculator/relayFeeCalculator.d.ts +150 -77
  44. package/dist/cjs/src/utils/AddressUtils.d.ts +0 -11
  45. package/dist/cjs/src/utils/AddressUtils.js +1 -52
  46. package/dist/cjs/src/utils/AddressUtils.js.map +1 -1
  47. package/dist/cjs/src/utils/CCTPUtils.js +12 -15
  48. package/dist/cjs/src/utils/CCTPUtils.js.map +1 -1
  49. package/dist/cjs/src/utils/FetchUtils.d.ts +5 -0
  50. package/dist/cjs/src/utils/FetchUtils.js +68 -0
  51. package/dist/cjs/src/utils/FetchUtils.js.map +1 -0
  52. package/dist/cjs/src/utils/IPFSUtils.js +2 -17
  53. package/dist/cjs/src/utils/IPFSUtils.js.map +1 -1
  54. package/dist/cjs/src/utils/Multicall.js +0 -1
  55. package/dist/cjs/src/utils/Multicall.js.map +1 -1
  56. package/dist/cjs/src/utils/NetworkUtils.d.ts +0 -1
  57. package/dist/cjs/src/utils/NetworkUtils.js +3 -9
  58. package/dist/cjs/src/utils/NetworkUtils.js.map +1 -1
  59. package/dist/cjs/src/utils/TokenUtils.d.ts +300 -154
  60. package/dist/cjs/src/utils/TypeGuards.d.ts +1 -3
  61. package/dist/cjs/src/utils/TypeGuards.js +0 -5
  62. package/dist/cjs/src/utils/TypeGuards.js.map +1 -1
  63. package/dist/cjs/src/utils/abi/typechain/factories/index.d.ts +0 -1
  64. package/dist/cjs/src/utils/abi/typechain/factories/index.js +2 -4
  65. package/dist/cjs/src/utils/abi/typechain/factories/index.js.map +1 -1
  66. package/dist/cjs/src/utils/abi/typechain/index.d.ts +0 -2
  67. package/dist/cjs/src/utils/abi/typechain/index.js +2 -4
  68. package/dist/cjs/src/utils/abi/typechain/index.js.map +1 -1
  69. package/dist/cjs/src/utils/index.d.ts +1 -0
  70. package/dist/cjs/src/utils/index.js +1 -0
  71. package/dist/cjs/src/utils/index.js.map +1 -1
  72. package/dist/esm/src/addressAggregator/adapters/abstract.js +5 -9
  73. package/dist/esm/src/addressAggregator/adapters/abstract.js.map +1 -1
  74. package/dist/esm/src/apiClient/productionClient.js +24 -27
  75. package/dist/esm/src/apiClient/productionClient.js.map +1 -1
  76. package/dist/esm/src/arch/evm/index.d.ts +0 -1
  77. package/dist/esm/src/arch/evm/index.js +0 -1
  78. package/dist/esm/src/arch/evm/index.js.map +1 -1
  79. package/dist/esm/src/arch/index.d.ts +0 -1
  80. package/dist/esm/src/arch/index.js +0 -2
  81. package/dist/esm/src/arch/index.js.map +1 -1
  82. package/dist/esm/src/caching/Arweave/ArweaveClient.js +3 -7
  83. package/dist/esm/src/caching/Arweave/ArweaveClient.js.map +1 -1
  84. package/dist/esm/src/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +2 -20
  85. package/dist/esm/src/clients/SpokePoolClient/EVMSpokePoolClient.js +12 -44
  86. package/dist/esm/src/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  87. package/dist/esm/src/clients/SpokePoolClient/index.d.ts +0 -8
  88. package/dist/esm/src/clients/SpokePoolClient/index.js +1 -10
  89. package/dist/esm/src/clients/SpokePoolClient/index.js.map +1 -1
  90. package/dist/esm/src/clients/SpokePoolClient/types.d.ts +0 -1
  91. package/dist/esm/src/clients/SpokePoolClient/types.js +0 -1
  92. package/dist/esm/src/clients/SpokePoolClient/types.js.map +1 -1
  93. package/dist/esm/src/clients/index.d.ts +1 -1
  94. package/dist/esm/src/clients/index.js +1 -1
  95. package/dist/esm/src/clients/index.js.map +1 -1
  96. package/dist/esm/src/coingecko/Coingecko.js +11 -31
  97. package/dist/esm/src/coingecko/Coingecko.js.map +1 -1
  98. package/dist/esm/src/gasPriceOracle/index.d.ts +1 -1
  99. package/dist/esm/src/gasPriceOracle/oracle.d.ts +1 -3
  100. package/dist/esm/src/gasPriceOracle/oracle.js +11 -17
  101. package/dist/esm/src/gasPriceOracle/oracle.js.map +1 -1
  102. package/dist/esm/src/gasPriceOracle/types.d.ts +1 -6
  103. package/dist/esm/src/gasPriceOracle/types.js +0 -4
  104. package/dist/esm/src/gasPriceOracle/types.js.map +1 -1
  105. package/dist/esm/src/priceClient/adapters/baseAdapter.d.ts +2 -1
  106. package/dist/esm/src/priceClient/adapters/baseAdapter.js +5 -10
  107. package/dist/esm/src/priceClient/adapters/baseAdapter.js.map +1 -1
  108. package/dist/esm/src/relayFeeCalculator/chain-queries/factory.d.ts +152 -81
  109. package/dist/esm/src/relayFeeCalculator/chain-queries/factory.js +1 -6
  110. package/dist/esm/src/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  111. package/dist/esm/src/relayFeeCalculator/chain-queries/index.d.ts +0 -1
  112. package/dist/esm/src/relayFeeCalculator/chain-queries/index.js +0 -1
  113. package/dist/esm/src/relayFeeCalculator/chain-queries/index.js.map +1 -1
  114. package/dist/esm/src/relayFeeCalculator/relayFeeCalculator.d.ts +150 -77
  115. package/dist/esm/src/utils/AddressUtils.d.ts +0 -11
  116. package/dist/esm/src/utils/AddressUtils.js +1 -59
  117. package/dist/esm/src/utils/AddressUtils.js.map +1 -1
  118. package/dist/esm/src/utils/CCTPUtils.js +12 -15
  119. package/dist/esm/src/utils/CCTPUtils.js.map +1 -1
  120. package/dist/esm/src/utils/FetchUtils.d.ts +5 -0
  121. package/dist/esm/src/utils/FetchUtils.js +66 -0
  122. package/dist/esm/src/utils/FetchUtils.js.map +1 -0
  123. package/dist/esm/src/utils/IPFSUtils.js +2 -20
  124. package/dist/esm/src/utils/IPFSUtils.js.map +1 -1
  125. package/dist/esm/src/utils/Multicall.js +0 -1
  126. package/dist/esm/src/utils/Multicall.js.map +1 -1
  127. package/dist/esm/src/utils/NetworkUtils.d.ts +0 -6
  128. package/dist/esm/src/utils/NetworkUtils.js +3 -13
  129. package/dist/esm/src/utils/NetworkUtils.js.map +1 -1
  130. package/dist/esm/src/utils/TokenUtils.d.ts +300 -154
  131. package/dist/esm/src/utils/TypeGuards.d.ts +1 -3
  132. package/dist/esm/src/utils/TypeGuards.js +0 -4
  133. package/dist/esm/src/utils/TypeGuards.js.map +1 -1
  134. package/dist/esm/src/utils/abi/typechain/factories/index.d.ts +0 -1
  135. package/dist/esm/src/utils/abi/typechain/factories/index.js +0 -1
  136. package/dist/esm/src/utils/abi/typechain/factories/index.js.map +1 -1
  137. package/dist/esm/src/utils/abi/typechain/index.d.ts +0 -2
  138. package/dist/esm/src/utils/abi/typechain/index.js +0 -1
  139. package/dist/esm/src/utils/abi/typechain/index.js.map +1 -1
  140. package/dist/esm/src/utils/index.d.ts +1 -0
  141. package/dist/esm/src/utils/index.js +1 -0
  142. package/dist/esm/src/utils/index.js.map +1 -1
  143. package/dist/types/src/addressAggregator/adapters/abstract.d.ts.map +1 -1
  144. package/dist/types/src/apiClient/productionClient.d.ts.map +1 -1
  145. package/dist/types/src/arch/evm/index.d.ts +0 -1
  146. package/dist/types/src/arch/evm/index.d.ts.map +1 -1
  147. package/dist/types/src/arch/index.d.ts +0 -1
  148. package/dist/types/src/arch/index.d.ts.map +1 -1
  149. package/dist/types/src/caching/Arweave/ArweaveClient.d.ts.map +1 -1
  150. package/dist/types/src/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +2 -20
  151. package/dist/types/src/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  152. package/dist/types/src/clients/SpokePoolClient/index.d.ts +0 -8
  153. package/dist/types/src/clients/SpokePoolClient/index.d.ts.map +1 -1
  154. package/dist/types/src/clients/SpokePoolClient/types.d.ts +0 -1
  155. package/dist/types/src/clients/SpokePoolClient/types.d.ts.map +1 -1
  156. package/dist/types/src/clients/index.d.ts +1 -1
  157. package/dist/types/src/clients/index.d.ts.map +1 -1
  158. package/dist/types/src/coingecko/Coingecko.d.ts.map +1 -1
  159. package/dist/types/src/gasPriceOracle/index.d.ts +1 -1
  160. package/dist/types/src/gasPriceOracle/index.d.ts.map +1 -1
  161. package/dist/types/src/gasPriceOracle/oracle.d.ts +1 -3
  162. package/dist/types/src/gasPriceOracle/oracle.d.ts.map +1 -1
  163. package/dist/types/src/gasPriceOracle/types.d.ts +1 -6
  164. package/dist/types/src/gasPriceOracle/types.d.ts.map +1 -1
  165. package/dist/types/src/priceClient/adapters/baseAdapter.d.ts +2 -1
  166. package/dist/types/src/priceClient/adapters/baseAdapter.d.ts.map +1 -1
  167. package/dist/types/src/relayFeeCalculator/chain-queries/factory.d.ts +152 -81
  168. package/dist/types/src/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
  169. package/dist/types/src/relayFeeCalculator/chain-queries/index.d.ts +0 -1
  170. package/dist/types/src/relayFeeCalculator/chain-queries/index.d.ts.map +1 -1
  171. package/dist/types/src/relayFeeCalculator/relayFeeCalculator.d.ts +150 -77
  172. package/dist/types/src/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  173. package/dist/types/src/utils/AddressUtils.d.ts +0 -11
  174. package/dist/types/src/utils/AddressUtils.d.ts.map +1 -1
  175. package/dist/types/src/utils/CCTPUtils.d.ts.map +1 -1
  176. package/dist/types/src/utils/FetchUtils.d.ts +6 -0
  177. package/dist/types/src/utils/FetchUtils.d.ts.map +1 -0
  178. package/dist/types/src/utils/IPFSUtils.d.ts.map +1 -1
  179. package/dist/types/src/utils/Multicall.d.ts.map +1 -1
  180. package/dist/types/src/utils/NetworkUtils.d.ts +0 -6
  181. package/dist/types/src/utils/NetworkUtils.d.ts.map +1 -1
  182. package/dist/types/src/utils/TokenUtils.d.ts +300 -154
  183. package/dist/types/src/utils/TokenUtils.d.ts.map +1 -1
  184. package/dist/types/src/utils/TypeGuards.d.ts +1 -3
  185. package/dist/types/src/utils/TypeGuards.d.ts.map +1 -1
  186. package/dist/types/src/utils/abi/typechain/factories/index.d.ts +0 -1
  187. package/dist/types/src/utils/abi/typechain/factories/index.d.ts.map +1 -1
  188. package/dist/types/src/utils/abi/typechain/index.d.ts +0 -2
  189. package/dist/types/src/utils/abi/typechain/index.d.ts.map +1 -1
  190. package/dist/types/src/utils/index.d.ts +1 -0
  191. package/dist/types/src/utils/index.d.ts.map +1 -1
  192. package/package.json +3 -5
  193. package/src/addressAggregator/adapters/abstract.ts +3 -9
  194. package/src/apiClient/productionClient.ts +28 -18
  195. package/src/arch/evm/index.ts +0 -1
  196. package/src/arch/index.ts +0 -1
  197. package/src/caching/Arweave/ArweaveClient.ts +3 -4
  198. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +18 -44
  199. package/src/clients/SpokePoolClient/index.ts +1 -12
  200. package/src/clients/SpokePoolClient/types.ts +0 -1
  201. package/src/clients/index.ts +0 -2
  202. package/src/coingecko/Coingecko.ts +10 -26
  203. package/src/gasPriceOracle/index.ts +1 -1
  204. package/src/gasPriceOracle/oracle.ts +3 -23
  205. package/src/gasPriceOracle/types.ts +1 -11
  206. package/src/priceClient/adapters/baseAdapter.ts +9 -9
  207. package/src/relayFeeCalculator/chain-queries/factory.ts +3 -18
  208. package/src/relayFeeCalculator/chain-queries/index.ts +0 -1
  209. package/src/utils/AddressUtils.ts +1 -61
  210. package/src/utils/CCTPUtils.ts +7 -9
  211. package/src/utils/FetchUtils.ts +66 -0
  212. package/src/utils/IPFSUtils.ts +9 -12
  213. package/src/utils/Multicall.ts +0 -1
  214. package/src/utils/NetworkUtils.ts +3 -13
  215. package/src/utils/TypeGuards.ts +1 -6
  216. package/src/utils/abi/typechain/factories/index.ts +0 -1
  217. package/src/utils/abi/typechain/index.ts +0 -2
  218. package/src/utils/index.ts +1 -0
  219. package/dist/cjs/src/arch/evm/UpgradeUtils.d.ts +0 -2
  220. package/dist/cjs/src/arch/evm/UpgradeUtils.js +0 -33
  221. package/dist/cjs/src/arch/evm/UpgradeUtils.js.map +0 -1
  222. package/dist/cjs/src/arch/tvm/BlockUtils.d.ts +0 -1
  223. package/dist/cjs/src/arch/tvm/BlockUtils.js +0 -7
  224. package/dist/cjs/src/arch/tvm/BlockUtils.js.map +0 -1
  225. package/dist/cjs/src/arch/tvm/MessageUtils.d.ts +0 -1
  226. package/dist/cjs/src/arch/tvm/MessageUtils.js +0 -5
  227. package/dist/cjs/src/arch/tvm/MessageUtils.js.map +0 -1
  228. package/dist/cjs/src/arch/tvm/ResourceUtils.d.ts +0 -14
  229. package/dist/cjs/src/arch/tvm/ResourceUtils.js +0 -69
  230. package/dist/cjs/src/arch/tvm/ResourceUtils.js.map +0 -1
  231. package/dist/cjs/src/arch/tvm/SpokeUtils.d.ts +0 -12
  232. package/dist/cjs/src/arch/tvm/SpokeUtils.js +0 -207
  233. package/dist/cjs/src/arch/tvm/SpokeUtils.js.map +0 -1
  234. package/dist/cjs/src/arch/tvm/TransactionUtils.d.ts +0 -7
  235. package/dist/cjs/src/arch/tvm/TransactionUtils.js +0 -43
  236. package/dist/cjs/src/arch/tvm/TransactionUtils.js.map +0 -1
  237. package/dist/cjs/src/arch/tvm/index.d.ts +0 -6
  238. package/dist/cjs/src/arch/tvm/index.js +0 -10
  239. package/dist/cjs/src/arch/tvm/index.js.map +0 -1
  240. package/dist/cjs/src/arch/tvm/types.d.ts +0 -2
  241. package/dist/cjs/src/arch/tvm/types.js +0 -3
  242. package/dist/cjs/src/arch/tvm/types.js.map +0 -1
  243. package/dist/cjs/src/arch/tvm/utils/address.d.ts +0 -3
  244. package/dist/cjs/src/arch/tvm/utils/address.js +0 -17
  245. package/dist/cjs/src/arch/tvm/utils/address.js.map +0 -1
  246. package/dist/cjs/src/arch/tvm/utils/index.d.ts +0 -2
  247. package/dist/cjs/src/arch/tvm/utils/index.js +0 -6
  248. package/dist/cjs/src/arch/tvm/utils/index.js.map +0 -1
  249. package/dist/cjs/src/arch/tvm/utils/wait.d.ts +0 -1
  250. package/dist/cjs/src/arch/tvm/utils/wait.js +0 -5
  251. package/dist/cjs/src/arch/tvm/utils/wait.js.map +0 -1
  252. package/dist/cjs/src/clients/SpokePoolClient/TVMSpokePoolClient.d.ts +0 -11
  253. package/dist/cjs/src/clients/SpokePoolClient/TVMSpokePoolClient.js +0 -47
  254. package/dist/cjs/src/clients/SpokePoolClient/TVMSpokePoolClient.js.map +0 -1
  255. package/dist/cjs/src/gasPriceOracle/adapters/tron.d.ts +0 -4
  256. package/dist/cjs/src/gasPriceOracle/adapters/tron.js +0 -58
  257. package/dist/cjs/src/gasPriceOracle/adapters/tron.js.map +0 -1
  258. package/dist/cjs/src/relayFeeCalculator/chain-queries/tvmQuery.d.ts +0 -16
  259. package/dist/cjs/src/relayFeeCalculator/chain-queries/tvmQuery.js +0 -52
  260. package/dist/cjs/src/relayFeeCalculator/chain-queries/tvmQuery.js.map +0 -1
  261. package/dist/cjs/src/utils/abi/typechain/SP1AutoVerifier.d.ts +0 -42
  262. package/dist/cjs/src/utils/abi/typechain/SP1AutoVerifier.js +0 -3
  263. package/dist/cjs/src/utils/abi/typechain/SP1AutoVerifier.js.map +0 -1
  264. package/dist/cjs/src/utils/abi/typechain/factories/SP1AutoVerifier__factory.d.ts +0 -26
  265. package/dist/cjs/src/utils/abi/typechain/factories/SP1AutoVerifier__factory.js +0 -43
  266. package/dist/cjs/src/utils/abi/typechain/factories/SP1AutoVerifier__factory.js.map +0 -1
  267. package/dist/esm/src/arch/evm/UpgradeUtils.d.ts +0 -9
  268. package/dist/esm/src/arch/evm/UpgradeUtils.js +0 -37
  269. package/dist/esm/src/arch/evm/UpgradeUtils.js.map +0 -1
  270. package/dist/esm/src/arch/tvm/BlockUtils.d.ts +0 -1
  271. package/dist/esm/src/arch/tvm/BlockUtils.js +0 -2
  272. package/dist/esm/src/arch/tvm/BlockUtils.js.map +0 -1
  273. package/dist/esm/src/arch/tvm/MessageUtils.d.ts +0 -1
  274. package/dist/esm/src/arch/tvm/MessageUtils.js +0 -2
  275. package/dist/esm/src/arch/tvm/MessageUtils.js.map +0 -1
  276. package/dist/esm/src/arch/tvm/ResourceUtils.d.ts +0 -32
  277. package/dist/esm/src/arch/tvm/ResourceUtils.js +0 -88
  278. package/dist/esm/src/arch/tvm/ResourceUtils.js.map +0 -1
  279. package/dist/esm/src/arch/tvm/SpokeUtils.d.ts +0 -48
  280. package/dist/esm/src/arch/tvm/SpokeUtils.js +0 -237
  281. package/dist/esm/src/arch/tvm/SpokeUtils.js.map +0 -1
  282. package/dist/esm/src/arch/tvm/TransactionUtils.d.ts +0 -20
  283. package/dist/esm/src/arch/tvm/TransactionUtils.js +0 -55
  284. package/dist/esm/src/arch/tvm/TransactionUtils.js.map +0 -1
  285. package/dist/esm/src/arch/tvm/index.d.ts +0 -6
  286. package/dist/esm/src/arch/tvm/index.js +0 -7
  287. package/dist/esm/src/arch/tvm/index.js.map +0 -1
  288. package/dist/esm/src/arch/tvm/types.d.ts +0 -2
  289. package/dist/esm/src/arch/tvm/types.js +0 -2
  290. package/dist/esm/src/arch/tvm/types.js.map +0 -1
  291. package/dist/esm/src/arch/tvm/utils/address.d.ts +0 -18
  292. package/dist/esm/src/arch/tvm/utils/address.js +0 -31
  293. package/dist/esm/src/arch/tvm/utils/address.js.map +0 -1
  294. package/dist/esm/src/arch/tvm/utils/index.d.ts +0 -2
  295. package/dist/esm/src/arch/tvm/utils/index.js +0 -3
  296. package/dist/esm/src/arch/tvm/utils/index.js.map +0 -1
  297. package/dist/esm/src/arch/tvm/utils/wait.d.ts +0 -1
  298. package/dist/esm/src/arch/tvm/utils/wait.js +0 -2
  299. package/dist/esm/src/arch/tvm/utils/wait.js.map +0 -1
  300. package/dist/esm/src/clients/SpokePoolClient/TVMSpokePoolClient.d.ts +0 -32
  301. package/dist/esm/src/clients/SpokePoolClient/TVMSpokePoolClient.js +0 -66
  302. package/dist/esm/src/clients/SpokePoolClient/TVMSpokePoolClient.js.map +0 -1
  303. package/dist/esm/src/gasPriceOracle/adapters/tron.d.ts +0 -10
  304. package/dist/esm/src/gasPriceOracle/adapters/tron.js +0 -68
  305. package/dist/esm/src/gasPriceOracle/adapters/tron.js.map +0 -1
  306. package/dist/esm/src/relayFeeCalculator/chain-queries/tvmQuery.d.ts +0 -32
  307. package/dist/esm/src/relayFeeCalculator/chain-queries/tvmQuery.js +0 -65
  308. package/dist/esm/src/relayFeeCalculator/chain-queries/tvmQuery.js.map +0 -1
  309. package/dist/esm/src/utils/abi/typechain/SP1AutoVerifier.d.ts +0 -42
  310. package/dist/esm/src/utils/abi/typechain/SP1AutoVerifier.js +0 -2
  311. package/dist/esm/src/utils/abi/typechain/SP1AutoVerifier.js.map +0 -1
  312. package/dist/esm/src/utils/abi/typechain/factories/SP1AutoVerifier__factory.d.ts +0 -26
  313. package/dist/esm/src/utils/abi/typechain/factories/SP1AutoVerifier__factory.js +0 -43
  314. package/dist/esm/src/utils/abi/typechain/factories/SP1AutoVerifier__factory.js.map +0 -1
  315. package/dist/types/src/arch/evm/UpgradeUtils.d.ts +0 -10
  316. package/dist/types/src/arch/evm/UpgradeUtils.d.ts.map +0 -1
  317. package/dist/types/src/arch/tvm/BlockUtils.d.ts +0 -2
  318. package/dist/types/src/arch/tvm/BlockUtils.d.ts.map +0 -1
  319. package/dist/types/src/arch/tvm/MessageUtils.d.ts +0 -2
  320. package/dist/types/src/arch/tvm/MessageUtils.d.ts.map +0 -1
  321. package/dist/types/src/arch/tvm/ResourceUtils.d.ts +0 -33
  322. package/dist/types/src/arch/tvm/ResourceUtils.d.ts.map +0 -1
  323. package/dist/types/src/arch/tvm/SpokeUtils.d.ts +0 -49
  324. package/dist/types/src/arch/tvm/SpokeUtils.d.ts.map +0 -1
  325. package/dist/types/src/arch/tvm/TransactionUtils.d.ts +0 -21
  326. package/dist/types/src/arch/tvm/TransactionUtils.d.ts.map +0 -1
  327. package/dist/types/src/arch/tvm/index.d.ts +0 -7
  328. package/dist/types/src/arch/tvm/index.d.ts.map +0 -1
  329. package/dist/types/src/arch/tvm/types.d.ts +0 -3
  330. package/dist/types/src/arch/tvm/types.d.ts.map +0 -1
  331. package/dist/types/src/arch/tvm/utils/address.d.ts +0 -19
  332. package/dist/types/src/arch/tvm/utils/address.d.ts.map +0 -1
  333. package/dist/types/src/arch/tvm/utils/index.d.ts +0 -3
  334. package/dist/types/src/arch/tvm/utils/index.d.ts.map +0 -1
  335. package/dist/types/src/arch/tvm/utils/wait.d.ts +0 -2
  336. package/dist/types/src/arch/tvm/utils/wait.d.ts.map +0 -1
  337. package/dist/types/src/clients/SpokePoolClient/TVMSpokePoolClient.d.ts +0 -33
  338. package/dist/types/src/clients/SpokePoolClient/TVMSpokePoolClient.d.ts.map +0 -1
  339. package/dist/types/src/gasPriceOracle/adapters/tron.d.ts +0 -11
  340. package/dist/types/src/gasPriceOracle/adapters/tron.d.ts.map +0 -1
  341. package/dist/types/src/relayFeeCalculator/chain-queries/tvmQuery.d.ts +0 -33
  342. package/dist/types/src/relayFeeCalculator/chain-queries/tvmQuery.d.ts.map +0 -1
  343. package/dist/types/src/utils/abi/typechain/SP1AutoVerifier.d.ts +0 -43
  344. package/dist/types/src/utils/abi/typechain/SP1AutoVerifier.d.ts.map +0 -1
  345. package/dist/types/src/utils/abi/typechain/factories/SP1AutoVerifier__factory.d.ts +0 -27
  346. package/dist/types/src/utils/abi/typechain/factories/SP1AutoVerifier__factory.d.ts.map +0 -1
  347. package/src/arch/evm/UpgradeUtils.ts +0 -18
  348. package/src/arch/tvm/BlockUtils.ts +0 -1
  349. package/src/arch/tvm/MessageUtils.ts +0 -1
  350. package/src/arch/tvm/ResourceUtils.ts +0 -92
  351. package/src/arch/tvm/SpokeUtils.ts +0 -225
  352. package/src/arch/tvm/TransactionUtils.ts +0 -62
  353. package/src/arch/tvm/index.ts +0 -6
  354. package/src/arch/tvm/types.ts +0 -2
  355. package/src/arch/tvm/utils/address.ts +0 -33
  356. package/src/arch/tvm/utils/index.ts +0 -2
  357. package/src/arch/tvm/utils/wait.ts +0 -1
  358. package/src/clients/SpokePoolClient/TVMSpokePoolClient.ts +0 -65
  359. package/src/gasPriceOracle/adapters/tron.ts +0 -50
  360. package/src/relayFeeCalculator/chain-queries/tvmQuery.ts +0 -88
  361. package/src/utils/abi/contracts/SP1AutoVerifier.json +0 -25
  362. package/src/utils/abi/typechain/SP1AutoVerifier.ts +0 -112
  363. package/src/utils/abi/typechain/factories/SP1AutoVerifier__factory.ts +0 -49
@@ -1 +0,0 @@
1
- {"version":3,"file":"SP1AutoVerifier__factory.d.ts","sourceRoot":"","sources":["../../../../../../../src/utils/abi/typechain/factories/SP1AutoVerifier__factory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAY,MAAM,EAAS,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EACV,eAAe,EACf,wBAAwB,EACzB,MAAM,oBAAoB,CAAC;AA4B5B,qBAAa,wBAAwB;IACnC,MAAM,CAAC,QAAQ,CAAC,GAAG;;;;;;;;;;;;;;;;;;OAAQ;IAC3B,MAAM,CAAC,eAAe,IAAI,wBAAwB;IAGlD,MAAM,CAAC,OAAO,CACZ,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,GAAG,QAAQ,GAClC,eAAe;CAGnB"}
@@ -1,18 +0,0 @@
1
- import { Contract } from "ethers";
2
- import { paginatedEventQuery } from "../../utils";
3
-
4
- /**
5
- * Query for EIP-1967 contract upgrade events.
6
- * @param contract A contract instance (must be a UUPS or transparent proxy that emits the Upgraded event).
7
- * @param startBlock Optional start of the block range (inclusive). Defaults to 0.
8
- * @param endBlock Optional end of the block range (inclusive). Defaults to latest.
9
- * @returns An array of block numbers at which upgrades occurred, sorted ascending.
10
- */
11
- export async function get1967Upgrades(contract: Contract, startBlock?: number, endBlock?: number): Promise<number[]> {
12
- const from = startBlock ?? 0;
13
- const to = endBlock ?? (await contract.provider.getBlockNumber());
14
-
15
- const events = await paginatedEventQuery(contract, contract.filters.Upgraded(), { from, to });
16
-
17
- return events.map(({ blockNumber }) => blockNumber);
18
- }
@@ -1 +0,0 @@
1
- export { averageBlockTime, EVMBlockFinder as TVMBlockFinder } from "../evm/BlockUtils";
@@ -1 +0,0 @@
1
- export * from "../evm/MessageUtils";
@@ -1,92 +0,0 @@
1
- import { TronWeb } from "tronweb";
2
- import type { ContractFunctionParameter } from "tronweb/lib/esm/types/TransactionBuilder";
3
- import { evmToTronAddress } from "./utils/address";
4
-
5
- export interface TronResourceEstimate {
6
- energyRequired: number;
7
- /** Recommended feeLimit in SUN (1 TRX = 1,000,000 SUN). */
8
- feeLimit: number;
9
- }
10
-
11
- export interface TronAccountResources {
12
- freeNetLimit: number;
13
- freeNetUsed: number;
14
- energyLimit: number;
15
- energyUsed: number;
16
- }
17
-
18
- // Safety multiplier applied to the estimated fee limit (1.2x).
19
- const FEE_LIMIT_MULTIPLIER = 1.2;
20
-
21
- /**
22
- * Query the current energy price in SUN per unit of energy.
23
- * @param tronWeb A TronWeb instance.
24
- * @returns The current energy price in SUN.
25
- */
26
- async function getEnergyPrice(tronWeb: TronWeb): Promise<number> {
27
- // getEnergyPrices() returns a comma-separated string of "timestamp:price" pairs.
28
- // The last entry is the current price.
29
- const pricesStr = await tronWeb.trx.getEnergyPrices();
30
- const entries = pricesStr.split(",");
31
- const lastEntry = entries[entries.length - 1];
32
- const price = Number(lastEntry.split(":")[1]);
33
-
34
- if (!Number.isFinite(price) || price <= 0) {
35
- throw new Error(`getEnergyPrice: unexpected energy price: ${lastEntry}`);
36
- }
37
-
38
- return price;
39
- }
40
-
41
- /**
42
- * Estimate the energy cost and recommended feeLimit for a smart contract call.
43
- *
44
- * @param tronWeb An authenticated TronWeb instance.
45
- * @param contractAddress The target contract address (EVM hex or TRON Base58 format).
46
- * @param functionSelector The Solidity function selector (e.g., "transfer(address,uint256)").
47
- * @param parameters The function parameters in TronWeb's ContractFunctionParameter format.
48
- * @param ownerAddress The address that will execute the transaction (EVM hex or TRON Base58).
49
- * @returns The estimated energy required and recommended feeLimit in SUN.
50
- */
51
- export async function estimateTransactionFee(
52
- tronWeb: TronWeb,
53
- contractAddress: string,
54
- functionSelector: string,
55
- parameters: ContractFunctionParameter[],
56
- ownerAddress: string
57
- ): Promise<TronResourceEstimate> {
58
- // Normalise addresses to TRON Base58 if they are in EVM hex format.
59
- const tronContractAddress = contractAddress.startsWith("0x") ? evmToTronAddress(contractAddress) : contractAddress;
60
- const tronOwnerAddress = ownerAddress.startsWith("0x") ? evmToTronAddress(ownerAddress) : ownerAddress;
61
-
62
- const [estimate, energyPrice] = await Promise.all([
63
- tronWeb.transactionBuilder.estimateEnergy(tronContractAddress, functionSelector, {}, parameters, tronOwnerAddress),
64
- getEnergyPrice(tronWeb),
65
- ]);
66
-
67
- const energyRequired = estimate.energy_required;
68
-
69
- // Calculate feeLimit: energy * price-per-unit, with a safety margin.
70
- const feeLimit = Math.ceil(energyRequired * energyPrice * FEE_LIMIT_MULTIPLIER);
71
-
72
- return { energyRequired, feeLimit };
73
- }
74
-
75
- /**
76
- * Query the current resource allocation and usage for an account.
77
- *
78
- * @param tronWeb A TronWeb instance.
79
- * @param address The account address (EVM hex or TRON Base58 format).
80
- * @returns The account's bandwidth and energy limits and usage.
81
- */
82
- export async function getAccountResources(tronWeb: TronWeb, address: string): Promise<TronAccountResources> {
83
- const tronAddress = address.startsWith("0x") ? evmToTronAddress(address) : address;
84
- const resources = await tronWeb.trx.getAccountResources(tronAddress);
85
-
86
- return {
87
- freeNetLimit: resources.freeNetLimit ?? 0,
88
- freeNetUsed: resources.freeNetUsed ?? 0,
89
- energyLimit: resources.NetLimit ?? 0,
90
- energyUsed: resources.NetUsed ?? 0,
91
- };
92
- }
@@ -1,225 +0,0 @@
1
- import assert from "assert";
2
- import { Contract, providers } from "ethers";
3
- import { CHAIN_IDs } from "../../constants";
4
- import { FillStatus, FillWithBlock, RelayData } from "../../interfaces";
5
- import { get1967Upgrades } from "../evm/UpgradeUtils";
6
- import { relayFillStatus as evmRelayFillStatus } from "../evm/SpokeUtils";
7
- import {
8
- BigNumber,
9
- getRelayDataHash,
10
- isDefined,
11
- isUnsafeDepositId,
12
- paginatedEventQuery,
13
- spreadEventWithBlockNumber,
14
- unpackFillEvent,
15
- } from "../../utils";
16
-
17
- type BlockTag = providers.BlockTag;
18
-
19
- // Re-export functions that work unchanged on TRON's JSON-RPC.
20
- export { populateV3Relay, getTimestampForBlock, fillStatusArray } from "../evm/SpokeUtils";
21
-
22
- // Local implementations for functions requiring historical eth_call,
23
- // which TRON does not support (only "latest" blockTag is accepted).
24
-
25
- /**
26
- * @notice Retrieve the on-chain time at a specific block number.
27
- * TRON does not support historical eth_call so block timestamps are used
28
- * instead of SpokePool.getCurrentTime(). In production these are equivalent.
29
- */
30
- export async function getTimeAt(spokePool: Contract, blockNumber: number): Promise<number> {
31
- const block = await spokePool.provider.getBlock(blockNumber);
32
- return block.timestamp;
33
- }
34
-
35
- // Fallback fill deadline buffer (6 hours) used when a contract upgrade is
36
- // detected in the query range. An upgrade implies fillDeadlineBuffer may
37
- // have changed and we cannot read historical state on TRON, so we use a
38
- // conservative upper bound.
39
- const FALLBACK_FILL_DEADLINE_BUFFER = 21600; // 6 hours in seconds
40
-
41
- /**
42
- * @notice Return the maximum fill deadline buffer across a block range.
43
- * TRON does not support historical eth_call, so we read the current value.
44
- * If a contract upgrade (EIP-1967 Upgraded event) occurred within the range,
45
- * the value may have changed at the upgrade boundary. In that case, return
46
- * the greater of the current value and a conservative 6-hour fallback.
47
- */
48
- export async function getMaxFillDeadlineInRange(
49
- spokePool: Contract,
50
- startBlock: number,
51
- endBlock: number
52
- ): Promise<number> {
53
- const [fillDeadlineBuffer, upgrades] = await Promise.all([
54
- spokePool.fillDeadlineBuffer(),
55
- get1967Upgrades(spokePool, startBlock, endBlock),
56
- ]);
57
-
58
- const currentBuffer = Number(fillDeadlineBuffer);
59
-
60
- if (upgrades.length > 0) {
61
- return Math.max(currentBuffer, FALLBACK_FILL_DEADLINE_BUFFER);
62
- }
63
-
64
- return currentBuffer;
65
- }
66
-
67
- /**
68
- * @notice Not supported on TVM — callers should use findDepositBlock instead.
69
- */
70
- export function getDepositIdAtBlock(_contract: Contract, _blockTag: number): Promise<BigNumber> {
71
- throw new Error("getDepositIdAtBlock: not supported on TVM");
72
- }
73
-
74
- /**
75
- * @notice Find the block at which a deposit was created.
76
- * TRON does not support historical eth_call, so event queries replace the
77
- * EVM binary-search over numberOfDeposits().
78
- */
79
- export async function findDepositBlock(
80
- spokePool: Contract,
81
- depositId: BigNumber,
82
- lowBlock: number,
83
- highBlock?: number
84
- ): Promise<number | undefined> {
85
- if (isUnsafeDepositId(depositId)) {
86
- throw new Error(`Cannot search for depositId ${depositId}`);
87
- }
88
-
89
- highBlock ??= await spokePool.provider.getBlockNumber();
90
- assert(highBlock > lowBlock, `Block numbers out of range (${lowBlock} >= ${highBlock})`);
91
-
92
- const events = await paginatedEventQuery(
93
- spokePool,
94
- spokePool.filters.FundsDeposited(null, null, null, null, null, depositId),
95
- { from: lowBlock, to: highBlock }
96
- );
97
-
98
- if (events.length === 0) {
99
- return undefined;
100
- }
101
-
102
- return events[0].blockNumber;
103
- }
104
-
105
- /**
106
- * @notice Determine the fill status of a relay at a given block.
107
- * For "latest" queries, delegates to the EVM implementation (TRON's
108
- * eth_call works normally for "latest"). For historical queries the
109
- * status is reconstructed from on-chain events because TRON does not
110
- * support eth_call with historical blockTags.
111
- */
112
- export async function relayFillStatus(
113
- spokePool: Contract,
114
- relayData: RelayData,
115
- blockTag: BlockTag = "latest",
116
- destinationChainId?: number
117
- ): Promise<FillStatus> {
118
- if (blockTag === "latest") {
119
- return evmRelayFillStatus(spokePool, relayData, blockTag, destinationChainId);
120
- }
121
-
122
- destinationChainId ??= await spokePool.chainId();
123
- assert(isDefined(destinationChainId));
124
-
125
- const hash = getRelayDataHash(relayData, destinationChainId);
126
-
127
- // Historical blockTag: check the current state first as an optimisation.
128
- // Fill status can only increase (Unfilled -> RequestedSlowFill -> Filled),
129
- // so if the deposit is still Unfilled now it was Unfilled at every prior block.
130
- const latestStatus = Number(await spokePool.fillStatuses(hash));
131
- if (latestStatus === FillStatus.Unfilled) {
132
- return FillStatus.Unfilled;
133
- }
134
-
135
- // Reconstruct from events up to the requested block.
136
- const fromBlock = 0;
137
- const toBlock = Number(blockTag);
138
-
139
- const fillEvents = await paginatedEventQuery(
140
- spokePool,
141
- spokePool.filters.FilledRelay(null, null, null, null, null, relayData.originChainId, relayData.depositId),
142
- { from: fromBlock, to: toBlock }
143
- );
144
-
145
- if (fillEvents.length > 0) {
146
- return FillStatus.Filled;
147
- }
148
-
149
- // No fill before blockTag — check for slow fill requests.
150
- if (latestStatus >= FillStatus.RequestedSlowFill) {
151
- const slowFillEvents = await paginatedEventQuery(
152
- spokePool,
153
- spokePool.filters.RequestedSlowFill(null, null, null, null, relayData.originChainId, relayData.depositId),
154
- { from: fromBlock, to: toBlock }
155
- );
156
-
157
- if (slowFillEvents.length > 0) {
158
- return FillStatus.RequestedSlowFill;
159
- }
160
- }
161
-
162
- return FillStatus.Unfilled;
163
- }
164
-
165
- /**
166
- * @notice Find the block at which a fill was completed.
167
- * TRON does not support historical eth_call, so event queries replace the
168
- * EVM binary-search over fillStatuses().
169
- */
170
- export async function findFillBlock(
171
- spokePool: Contract,
172
- relayData: RelayData,
173
- lowBlockNumber: number,
174
- highBlockNumber?: number
175
- ): Promise<number | undefined> {
176
- const { provider } = spokePool;
177
- highBlockNumber ??= await provider.getBlockNumber();
178
- assert(highBlockNumber > lowBlockNumber, `Block numbers out of range (${lowBlockNumber} >= ${highBlockNumber})`);
179
-
180
- const events = await paginatedEventQuery(
181
- spokePool,
182
- spokePool.filters.FilledRelay(null, null, null, null, null, relayData.originChainId, relayData.depositId),
183
- { from: lowBlockNumber, to: highBlockNumber }
184
- );
185
-
186
- if (events.length === 0) {
187
- return undefined;
188
- }
189
-
190
- return events[0].blockNumber;
191
- }
192
-
193
- /**
194
- * @notice Find the fill event for a deposit.
195
- * Queries fill events directly rather than binary-searching then re-querying.
196
- */
197
- export async function findFillEvent(
198
- spokePool: Contract,
199
- relayData: RelayData,
200
- lowBlockNumber: number,
201
- highBlockNumber?: number
202
- ): Promise<FillWithBlock | undefined> {
203
- const { provider } = spokePool;
204
- highBlockNumber ??= await provider.getBlockNumber();
205
-
206
- const events = await paginatedEventQuery(
207
- spokePool,
208
- spokePool.filters.FilledRelay(null, null, null, null, null, relayData.originChainId, relayData.depositId),
209
- { from: lowBlockNumber, to: highBlockNumber }
210
- );
211
-
212
- if (events.length === 0) {
213
- return undefined;
214
- }
215
-
216
- const event = events[0];
217
- // In production the chainId returned from the provider matches 1:1 with the actual chainId. Querying the provider
218
- // object saves an RPC query because the chainId is cached by StaticJsonRpcProvider instances. In hre, the SpokePool
219
- // may be configured with a different chainId than what is returned by the provider.
220
- const destinationChainId = Object.values(CHAIN_IDs).includes(relayData.originChainId)
221
- ? (await spokePool.provider.getNetwork()).chainId
222
- : Number(await spokePool.chainId());
223
-
224
- return unpackFillEvent(spreadEventWithBlockNumber(event), destinationChainId);
225
- }
@@ -1,62 +0,0 @@
1
- import { TronWeb } from "tronweb";
2
- import { PopulatedTransaction } from "ethers";
3
- import { evmToTronAddress } from "./utils/address";
4
-
5
- export interface TronTransactionResult {
6
- txid: string;
7
- result: boolean;
8
- }
9
-
10
- /**
11
- * Submit a populated EVM transaction to TRON via TronWeb.
12
- *
13
- * The EVM `populateV3Relay()` already produces correct ABI-encoded calldata.
14
- * This function extracts `to` and `data` from the PopulatedTransaction,
15
- * converts the target address to TRON Base58 format, and uses TronWeb's
16
- * `triggerSmartContract` → `sign` → `sendRawTransaction` pipeline.
17
- *
18
- * @param tronWeb An authenticated TronWeb instance (with private key set).
19
- * @param populatedTx The populated transaction containing `to` and `data`.
20
- * @param feeLimit The maximum TRX to burn for energy consumption, in SUN (1 TRX = 1,000,000 SUN).
21
- * @returns The transaction ID and result status.
22
- */
23
- export async function submitTransaction(
24
- tronWeb: TronWeb,
25
- populatedTx: PopulatedTransaction,
26
- feeLimit: number
27
- ): Promise<TronTransactionResult> {
28
- const { to, data } = populatedTx;
29
- if (!to || !data) {
30
- throw new Error("submitTransaction: populatedTx must have both 'to' and 'data' fields");
31
- }
32
-
33
- const tronAddress = evmToTronAddress(to);
34
- const ownerAddress = tronWeb.defaultAddress?.base58;
35
- if (!ownerAddress) {
36
- throw new Error("submitTransaction: TronWeb instance must have a default address configured");
37
- }
38
-
39
- // Use triggerSmartContract with the `input` option to pass pre-encoded calldata.
40
- // The function selector is empty — the full calldata (selector + params) is in `input`.
41
- const txWrapper = await tronWeb.transactionBuilder.triggerSmartContract(
42
- tronAddress,
43
- // Use empty function selector — the `input` option provides the full calldata.
44
- "",
45
- { feeLimit, input: data },
46
- [],
47
- ownerAddress
48
- );
49
-
50
- if (!txWrapper?.result?.result) {
51
- const message = txWrapper?.result?.message ?? "Unknown error";
52
- throw new Error(`submitTransaction: triggerSmartContract failed: ${message}`);
53
- }
54
-
55
- const signedTx = await tronWeb.trx.sign(txWrapper.transaction);
56
- const broadcast = await tronWeb.trx.sendRawTransaction(signedTx);
57
-
58
- return {
59
- txid: broadcast.txid ?? signedTx.txID,
60
- result: broadcast.result ?? false,
61
- };
62
- }
@@ -1,6 +0,0 @@
1
- export * from "./SpokeUtils";
2
- export * from "./BlockUtils";
3
- export * from "./TransactionUtils";
4
- export * from "./ResourceUtils";
5
- export * from "./utils";
6
- export * from "./MessageUtils";
@@ -1,2 +0,0 @@
1
- export { Provider } from "../evm/types";
2
- export type { TronWeb } from "tronweb";
@@ -1,33 +0,0 @@
1
- import { TronWeb } from "tronweb";
2
-
3
- /**
4
- * Convert an EVM-format hex address (0x...) to a TRON Base58Check address (T...).
5
- * @param evmAddress The 0x-prefixed hex address.
6
- * @returns The TRON Base58Check-encoded address.
7
- */
8
- export function evmToTronAddress(evmAddress: string): string {
9
- // TronWeb.address.fromHex expects a hex address (with or without 0x prefix)
10
- // and returns the Base58Check-encoded TRON address.
11
- return TronWeb.address.fromHex(evmAddress);
12
- }
13
-
14
- /**
15
- * Convert a TRON Base58Check address (T...) to an EVM-format hex address (0x...).
16
- * @param tronAddress The TRON Base58Check-encoded address.
17
- * @returns The 0x-prefixed hex address.
18
- */
19
- export function tronToEvmAddress(tronAddress: string): string {
20
- // TronWeb.address.toHex returns hex with a 41 prefix (TRON's address prefix).
21
- // We strip the leading "41" and add "0x" to get standard EVM format.
22
- const hex = TronWeb.address.toHex(tronAddress);
23
- return "0x" + hex.slice(2);
24
- }
25
-
26
- /**
27
- * Check whether a string is a valid TRON Base58Check address.
28
- * @param address The string to check.
29
- * @returns True if the address is a valid TRON Base58Check address.
30
- */
31
- export function isTronBase58Address(address: string): boolean {
32
- return TronWeb.isAddress(address);
33
- }
@@ -1,2 +0,0 @@
1
- export * from "./address";
2
- export * from "./wait";
@@ -1 +0,0 @@
1
- export * from "../../evm/utils/wait";
@@ -1,65 +0,0 @@
1
- import {
2
- findDepositBlock,
3
- getMaxFillDeadlineInRange as getMaxFillDeadline,
4
- getTimeAt as _getTimeAt,
5
- relayFillStatus,
6
- } from "../../arch/tvm";
7
- import { FillStatus, RelayData } from "../../interfaces";
8
- import { BigNumber } from "../../utils";
9
- import { EVMSpokePoolClient } from "./EVMSpokePoolClient";
10
- import { TVM_SPOKE_POOL_CLIENT_TYPE } from "./types";
11
-
12
- /**
13
- * A TVM-specific SpokePoolClient for TRON.
14
- *
15
- * TRON is EVM-compatible for reads and event queries, but diverges in three areas:
16
- * 1. No historical `eth_call` — only "latest" blockTag is accepted.
17
- * 2. No `eth_sendRawTransaction` — TRON uses Protobuf-encoded transactions via TronWeb.
18
- * 3. Energy/bandwidth fee model instead of gas.
19
- *
20
- * This client extends EVMSpokePoolClient, overriding only the methods affected by (1).
21
- * Transaction submission (2) and fee estimation (3) are handled by the arch/tvm utilities.
22
- */
23
- export class TVMSpokePoolClient extends EVMSpokePoolClient {
24
- // @ts-expect-error: Narrowing the base class literal type from "EVM" to "TVM".
25
- override readonly type = TVM_SPOKE_POOL_CLIENT_TYPE;
26
-
27
- public override relayFillStatus(relayData: RelayData, atHeight?: number): Promise<FillStatus> {
28
- return relayFillStatus(this.spokePool, relayData, atHeight, this.chainId);
29
- }
30
-
31
- public override getMaxFillDeadlineInRange(startBlock: number, endBlock: number): Promise<number> {
32
- return getMaxFillDeadline(this.spokePool, startBlock, endBlock);
33
- }
34
-
35
- public override getTimeAt(blockNumber: number): Promise<number> {
36
- return _getTimeAt(this.spokePool, blockNumber);
37
- }
38
-
39
- /**
40
- * Override to use TVM's event-based findDepositBlock
41
- * instead of EVM's binary-search over historical numberOfDeposits().
42
- */
43
- protected override _findDepositBlock(
44
- depositId: BigNumber,
45
- lowBlock: number,
46
- highBlock?: number
47
- ): Promise<number | undefined> {
48
- return findDepositBlock(this.spokePool, depositId, lowBlock, highBlock);
49
- }
50
-
51
- /**
52
- * Override to avoid historical eth_call for getCurrentTime.
53
- * TRON does not support eth_call with historical blockTags, so we
54
- * use the block timestamp from provider.getBlock() instead of
55
- * SpokePool.getCurrentTime({ blockTag }).
56
- */
57
- protected override async _getCurrentTime(blockNumber: number): Promise<number> {
58
- const block = await this.spokePool.provider.getBlock(blockNumber);
59
- const currentTime = block.timestamp;
60
- if (currentTime < this.currentTime) {
61
- throw new Error(`TVMSpokePoolClient::update: currentTime: ${currentTime} < ${this.currentTime}`);
62
- }
63
- return currentTime;
64
- }
65
- }
@@ -1,50 +0,0 @@
1
- import { TronWeb } from "tronweb";
2
- import { toBN } from "../../utils";
3
- import { TvmGasPriceEstimate } from "../types";
4
- import { GasPriceEstimateOptions } from "../oracle";
5
-
6
- /**
7
- * @notice Returns energy and bandwidth prices for the TRON network.
8
- * @param provider A TronWeb instance.
9
- * @param _opts Gas price estimate options (unused, kept for interface consistency).
10
- * @returns TvmGasPriceEstimate with energyPrice and bandwidthPrice in SUN per unit.
11
- */
12
- export async function gasPrices(provider: TronWeb, _opts: GasPriceEstimateOptions): Promise<TvmGasPriceEstimate> {
13
- const [energyPrice, bandwidthPrice] = await Promise.all([getEnergyPrice(provider), getBandwidthPrice(provider)]);
14
-
15
- return {
16
- energyPrice: toBN(energyPrice),
17
- bandwidthPrice: toBN(bandwidthPrice),
18
- };
19
- }
20
-
21
- /**
22
- * Query the current energy price in SUN per unit of energy.
23
- * Parses the last entry from the comma-separated "timestamp:price" string.
24
- */
25
- async function getEnergyPrice(tronWeb: TronWeb): Promise<number> {
26
- const pricesStr = await tronWeb.trx.getEnergyPrices();
27
- const entries = pricesStr.split(",");
28
- const lastEntry = entries[entries.length - 1];
29
- const price = Number(lastEntry.split(":")[1]);
30
-
31
- if (!Number.isFinite(price) || price <= 0) {
32
- throw new Error(`getEnergyPrice: unexpected energy price: ${lastEntry}`);
33
- }
34
-
35
- return price;
36
- }
37
-
38
- /**
39
- * Query the current bandwidth price (getTransactionFee) from chain parameters.
40
- */
41
- async function getBandwidthPrice(tronWeb: TronWeb): Promise<number> {
42
- const params = await tronWeb.trx.getChainParameters();
43
- const entry = params.find((p: { key: string; value: number }) => p.key === "getTransactionFee");
44
-
45
- if (!entry) {
46
- throw new Error("getBandwidthPrice: getTransactionFee not found in chain parameters");
47
- }
48
-
49
- return entry.value;
50
- }
@@ -1,88 +0,0 @@
1
- import assert from "assert";
2
- import { PopulatedTransaction, providers, VoidSigner } from "ethers";
3
- import { TronWeb } from "tronweb";
4
- import { getGasPriceEstimate, GasPriceEstimateOptions } from "../../gasPriceOracle";
5
- import { TvmGasPriceEstimate } from "../../gasPriceOracle/types";
6
- import { RelayData } from "../../interfaces";
7
- import { Address, BigNumber, BigNumberish, bnZero, EvmAddress, TransactionCostEstimate } from "../../utils";
8
- import { arch } from "../..";
9
- import { Logger } from "../relayFeeCalculator";
10
- import { QueryBase, SymbolMappingType } from "./baseQuery";
11
-
12
- /**
13
- * A TVM-specific query implementation for TRON.
14
- *
15
- * TRON's JSON-RPC is EVM-compatible for reads and gas estimation, so this
16
- * class extends QueryBase and overrides only the gas price oracle dispatch
17
- * to use TronWeb (energy/bandwidth pricing) instead of the EVM oracle.
18
- *
19
- * The ethers provider is derived from the TronWeb instance's fullNode URL.
20
- */
21
- export class TvmQuery extends QueryBase {
22
- readonly tronWeb: TronWeb;
23
-
24
- constructor(
25
- tronWeb: TronWeb,
26
- symbolMapping: SymbolMappingType,
27
- spokePoolAddress: string,
28
- simulatedRelayerAddress: EvmAddress,
29
- logger: Logger,
30
- coingeckoProApiKey?: string,
31
- fixedGasPrice?: BigNumberish,
32
- coingeckoBaseCurrency: string = "eth"
33
- ) {
34
- const provider = new providers.StaticJsonRpcProvider(tronWeb.fullNode.host);
35
- super(
36
- provider,
37
- symbolMapping,
38
- spokePoolAddress,
39
- simulatedRelayerAddress,
40
- logger,
41
- coingeckoProApiKey,
42
- fixedGasPrice,
43
- coingeckoBaseCurrency
44
- );
45
- this.tronWeb = tronWeb;
46
- }
47
-
48
- /**
49
- * Estimate the gas cost of a transaction using TVM energy pricing.
50
- *
51
- * Gas units (energy) are estimated via the ethers provider (TRON's JSON-RPC
52
- * returns energy units for eth_estimateGas). The energy price is queried
53
- * from TronWeb's gas price oracle.
54
- */
55
- override async estimateGas(
56
- unsignedTx: PopulatedTransaction,
57
- senderAddress: Address,
58
- provider: providers.Provider,
59
- options: Partial<
60
- GasPriceEstimateOptions & {
61
- gasPrice: BigNumberish;
62
- gasUnits: BigNumberish;
63
- }
64
- > = {}
65
- ): Promise<TransactionCostEstimate> {
66
- const { gasPrice: _gasPrice, gasUnits } = options;
67
-
68
- const voidSigner = new VoidSigner(senderAddress.toEvmAddress(), provider);
69
-
70
- const [nativeGasCost, gasPriceEstimate] = await Promise.all([
71
- gasUnits ? Promise.resolve(BigNumber.from(gasUnits)) : voidSigner.estimateGas(unsignedTx),
72
- _gasPrice
73
- ? Promise.resolve({ energyPrice: BigNumber.from(_gasPrice.toString()), bandwidthPrice: bnZero })
74
- : getGasPriceEstimate(this.tronWeb),
75
- ]);
76
-
77
- assert(nativeGasCost.gt(bnZero), "Gas cost should not be 0");
78
-
79
- const gasPrice = (gasPriceEstimate as TvmGasPriceEstimate).energyPrice;
80
- const tokenGasCost = nativeGasCost.mul(gasPrice);
81
-
82
- return { nativeGasCost, tokenGasCost, gasPrice };
83
- }
84
-
85
- override getAuxiliaryNativeTokenCost(deposit: RelayData): BigNumber {
86
- return arch.tvm.getAuxiliaryNativeTokenCost(deposit);
87
- }
88
- }