@berachain/berajs 0.2.13 → 0.3.0

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 (413) hide show
  1. package/dist/actions/clients/BeraApolloClient.d.ts.map +1 -1
  2. package/dist/actions/clients/clientName.d.ts +10 -0
  3. package/dist/actions/clients/clientName.d.ts.map +1 -0
  4. package/dist/actions/clients/exports.d.ts +2 -0
  5. package/dist/actions/clients/exports.d.ts.map +1 -1
  6. package/dist/actions/clients/exports.mjs +26 -7
  7. package/dist/actions/clients/exports.mjs.map +1 -1
  8. package/dist/actions/clients/fetchBeep.d.ts.map +1 -1
  9. package/dist/actions/clients/fetchEnso.d.ts +17 -0
  10. package/dist/actions/clients/fetchEnso.d.ts.map +1 -0
  11. package/dist/actions/clients/fetchLayerzero.d.ts +12 -0
  12. package/dist/actions/clients/fetchLayerzero.d.ts.map +1 -0
  13. package/dist/actions/clients/fetchOpenApi.d.ts +4 -1
  14. package/dist/actions/clients/fetchOpenApi.d.ts.map +1 -1
  15. package/dist/actions/clients/getApolloClient.d.ts.map +1 -1
  16. package/dist/actions/dex/aggregators/base.d.ts +30 -5
  17. package/dist/actions/dex/aggregators/base.d.ts.map +1 -1
  18. package/dist/actions/dex/aggregators/bex.d.ts +11 -1
  19. package/dist/actions/dex/aggregators/bex.d.ts.map +1 -1
  20. package/dist/actions/dex/aggregators/bgt.d.ts +2 -2
  21. package/dist/actions/dex/aggregators/bgt.d.ts.map +1 -1
  22. package/dist/actions/dex/aggregators/enso/enso.d.ts.map +1 -1
  23. package/dist/actions/dex/aggregators/enso/ensoErc4626.d.ts +1 -0
  24. package/dist/actions/dex/aggregators/enso/ensoErc4626.d.ts.map +1 -1
  25. package/dist/actions/dex/aggregators/erc4626.d.ts +2 -2
  26. package/dist/actions/dex/aggregators/erc4626.d.ts.map +1 -1
  27. package/dist/actions/dex/aggregators/fly.d.ts.map +1 -1
  28. package/dist/actions/dex/aggregators/haiku.d.ts +7 -1
  29. package/dist/actions/dex/aggregators/haiku.d.ts.map +1 -1
  30. package/dist/actions/dex/aggregators/honey.d.ts +2 -2
  31. package/dist/actions/dex/aggregators/honey.d.ts.map +1 -1
  32. package/dist/actions/dex/aggregators/kyberswap.d.ts.map +1 -1
  33. package/dist/actions/dex/aggregators/oogabooga.d.ts.map +1 -1
  34. package/dist/actions/dex/aggregators/openOcean.d.ts.map +1 -1
  35. package/dist/actions/dex/aggregators/wbera.d.ts +3 -2
  36. package/dist/actions/dex/aggregators/wbera.d.ts.map +1 -1
  37. package/dist/actions/dex/getAllPools.d.ts.map +1 -1
  38. package/dist/actions/dex/getApiPool.d.ts.map +1 -1
  39. package/dist/actions/enso/getEnsoUserTokensWithBalances.d.ts.map +1 -1
  40. package/dist/actions/enso/util.d.ts +1 -6
  41. package/dist/actions/enso/util.d.ts.map +1 -1
  42. package/dist/actions/exports.d.ts +3 -5
  43. package/dist/actions/exports.d.ts.map +1 -1
  44. package/dist/actions/exports.mjs +31 -50
  45. package/dist/actions/exports.mjs.map +1 -1
  46. package/dist/actions/governance/exports.mjs +3 -3
  47. package/dist/actions/honey/getHoney24hVolume.d.ts +2 -2
  48. package/dist/actions/honey/getHoney24hVolume.d.ts.map +1 -1
  49. package/dist/actions/honey/getHoneyCollaterals.d.ts +1 -1
  50. package/dist/actions/honey/getHoneyCollaterals.d.ts.map +1 -1
  51. package/dist/actions/pol/getEarnedStakedBeraVault.d.ts +0 -23
  52. package/dist/actions/pol/getEarnedStakedBeraVault.d.ts.map +1 -1
  53. package/dist/actions/pol/getLSTStakeConfig.d.ts.map +1 -1
  54. package/dist/actions/pol/getSWBeraVaultMetadata.d.ts +1 -14
  55. package/dist/actions/pol/getSWBeraVaultMetadata.d.ts.map +1 -1
  56. package/dist/actions/pol/getStakedBeraAPY.d.ts +14 -0
  57. package/dist/actions/pol/getStakedBeraAPY.d.ts.map +1 -0
  58. package/dist/actions/pol/getStakedBeraSnapshots.d.ts +14 -4
  59. package/dist/actions/pol/getStakedBeraSnapshots.d.ts.map +1 -1
  60. package/dist/actions/pol/getStakingDailyAssets.d.ts +2 -2
  61. package/dist/actions/pol/getStakingDailyAssets.d.ts.map +1 -1
  62. package/dist/actions/server/exports.mjs +5 -5
  63. package/dist/actions/validators/getActiveBoostAndCommissionChangeDelay.d.ts +1 -1
  64. package/dist/actions/validators/getActiveBoostAndCommissionChangeDelay.d.ts.map +1 -1
  65. package/dist/actions/validators/getUserActiveValidators.d.ts +37 -1
  66. package/dist/actions/validators/getUserActiveValidators.d.ts.map +1 -1
  67. package/dist/actions/validators/getValidatorRewardAllocation.d.ts +4 -0
  68. package/dist/actions/validators/getValidatorRewardAllocation.d.ts.map +1 -1
  69. package/dist/{chunk-ZWTGVIPJ.mjs → chunk-4576RF2K.mjs} +29 -4
  70. package/dist/chunk-4576RF2K.mjs.map +1 -0
  71. package/dist/{chunk-UA3Z47LT.mjs → chunk-5PBYMJRG.mjs} +95 -24
  72. package/dist/chunk-5PBYMJRG.mjs.map +1 -0
  73. package/dist/{chunk-AEN6IJFU.mjs → chunk-7KN7TDUC.mjs} +2 -2
  74. package/dist/chunk-7OESHTBN.mjs +29 -0
  75. package/dist/chunk-7OESHTBN.mjs.map +1 -0
  76. package/dist/{chunk-IFNIPVTZ.mjs → chunk-BSLXKPX4.mjs} +4 -48
  77. package/dist/chunk-BSLXKPX4.mjs.map +1 -0
  78. package/dist/{chunk-PHYZRH4I.mjs → chunk-BZKA6DBM.mjs} +9 -13
  79. package/dist/chunk-BZKA6DBM.mjs.map +1 -0
  80. package/dist/{chunk-LE4CYW7S.mjs → chunk-FWRYUIJK.mjs} +3 -3
  81. package/dist/{chunk-PJRLHTGC.mjs → chunk-HPRLNT6R.mjs} +3 -3
  82. package/dist/chunk-J6GM7HWX.mjs +19 -0
  83. package/dist/chunk-J6GM7HWX.mjs.map +1 -0
  84. package/dist/{chunk-P3YZ7F22.mjs → chunk-LL7XR2H5.mjs} +34 -3
  85. package/dist/chunk-LL7XR2H5.mjs.map +1 -0
  86. package/dist/{chunk-EJIGERYM.mjs → chunk-M3MIGSH3.mjs} +2 -2
  87. package/dist/{chunk-NZAH3SGT.mjs → chunk-MVNQY2D4.mjs} +9 -4
  88. package/dist/chunk-MVNQY2D4.mjs.map +1 -0
  89. package/dist/{chunk-TGN55GKE.mjs → chunk-SC3BSCTN.mjs} +2 -2
  90. package/dist/{chunk-DOZJB6IJ.mjs → chunk-SMBAW7AG.mjs} +394 -344
  91. package/dist/chunk-SMBAW7AG.mjs.map +1 -0
  92. package/dist/{chunk-QQASX4LJ.mjs → chunk-TXWDUJOY.mjs} +2 -2
  93. package/dist/{chunk-EGAB6NFQ.mjs → chunk-UWJQ6UKG.mjs} +2 -2
  94. package/dist/chunk-XO2BFPTB.mjs +50 -0
  95. package/dist/chunk-XO2BFPTB.mjs.map +1 -0
  96. package/dist/{chunk-7TFV6UKF.mjs → chunk-XXKPXNQD.mjs} +1 -2
  97. package/dist/chunk-XXKPXNQD.mjs.map +1 -0
  98. package/dist/{chunk-J3LTASDE.mjs → chunk-ZHV3MQ4F.mjs} +4 -4
  99. package/dist/contexts/BeraFlags/BeraFlags.d.ts +1 -1
  100. package/dist/contexts/BeraFlags/BeraFlags.d.ts.map +1 -1
  101. package/dist/contexts/BeraFlags/defaultFlags.d.ts +2 -2
  102. package/dist/contexts/BeraFlags/defaultFlags.d.ts.map +1 -1
  103. package/dist/contexts/BexStatusProvider.d.ts +1 -1
  104. package/dist/contexts/BexStatusProvider.d.ts.map +1 -1
  105. package/dist/contexts/TokensProvider.d.ts +1 -1
  106. package/dist/contexts/TokensProvider.d.ts.map +1 -1
  107. package/dist/contexts/exports.mjs +9 -9
  108. package/dist/enum/contracts.d.ts +3 -0
  109. package/dist/enum/contracts.d.ts.map +1 -1
  110. package/dist/enum/exports.mjs +6 -4
  111. package/dist/enum/exports.mjs.map +1 -1
  112. package/dist/errors/RequestError.d.ts +19 -0
  113. package/dist/errors/RequestError.d.ts.map +1 -1
  114. package/dist/errors/errorMap.d.ts +4 -3
  115. package/dist/errors/errorMap.d.ts.map +1 -1
  116. package/dist/errors/exports.mjs +5 -5
  117. package/dist/hooks/dex/useAggregatorsQuotes.d.ts.map +1 -1
  118. package/dist/hooks/dex/useAllUserPools.d.ts.map +1 -1
  119. package/dist/hooks/dex/useCrossChainNativeFee.d.ts +32 -0
  120. package/dist/hooks/dex/useCrossChainNativeFee.d.ts.map +1 -0
  121. package/dist/hooks/dex/useOnChainPoolData.d.ts.map +1 -1
  122. package/dist/hooks/dex/usePools.d.ts.map +1 -1
  123. package/dist/hooks/dex/useSingleAggregatorQuote.d.ts.map +1 -1
  124. package/dist/hooks/enso/useBendZapSupply.d.ts +2 -2
  125. package/dist/hooks/enso/useBendZapSupply.d.ts.map +1 -1
  126. package/dist/hooks/enso/useEnsoUserTokensWithBalances.d.ts.map +1 -1
  127. package/dist/hooks/exports.d.ts +2 -5
  128. package/dist/hooks/exports.d.ts.map +1 -1
  129. package/dist/hooks/exports.mjs +590 -905
  130. package/dist/hooks/exports.mjs.map +1 -1
  131. package/dist/hooks/governance/exports.mjs +4 -4
  132. package/dist/hooks/honey/useHoneyChartData.d.ts.map +1 -1
  133. package/dist/hooks/pol/useRewardTokenToBeraRate.d.ts.map +1 -1
  134. package/dist/hooks/pol/useRewardVaultBalanceFromStakingToken.d.ts.map +1 -1
  135. package/dist/hooks/pol/useRewardVaults.d.ts.map +1 -1
  136. package/dist/hooks/pol/useStakedAPY.d.ts +11 -0
  137. package/dist/hooks/pol/useStakedAPY.d.ts.map +1 -0
  138. package/dist/hooks/pol/useStakedData.d.ts +2 -2
  139. package/dist/hooks/pol/useStakedData.d.ts.map +1 -1
  140. package/dist/hooks/pol/useStakingVaultsMetadata.d.ts +0 -1
  141. package/dist/hooks/pol/useStakingVaultsMetadata.d.ts.map +1 -1
  142. package/dist/hooks/tokens/useMultipleTokenInformation.d.ts +30 -0
  143. package/dist/hooks/tokens/useMultipleTokenInformation.d.ts.map +1 -1
  144. package/dist/hooks/tokens/usePollBalance.d.ts.map +1 -1
  145. package/dist/hooks/validators/useUserActiveValidators.d.ts +5 -0
  146. package/dist/hooks/validators/useUserActiveValidators.d.ts.map +1 -1
  147. package/dist/hooks/validators/useValidator.d.ts.map +1 -1
  148. package/dist/hooks/validators/useValidatorIncentiveDistribution.d.ts +3 -4
  149. package/dist/hooks/validators/useValidatorIncentiveDistribution.d.ts.map +1 -1
  150. package/dist/hooks/validators/useValidatorRewardAllocation.d.ts +1 -0
  151. package/dist/hooks/validators/useValidatorRewardAllocation.d.ts.map +1 -1
  152. package/dist/utils/crossChainBridge.d.ts +74 -0
  153. package/dist/utils/crossChainBridge.d.ts.map +1 -0
  154. package/dist/utils/exports.d.ts +1 -1
  155. package/dist/utils/exports.d.ts.map +1 -1
  156. package/dist/utils/exports.mjs +142 -72
  157. package/dist/utils/exports.mjs.map +1 -1
  158. package/dist/utils/getTestClient.d.ts +5 -3
  159. package/dist/utils/getTestClient.d.ts.map +1 -1
  160. package/dist/utils/parseWhiskToken.d.ts.map +1 -1
  161. package/package.json +8 -6
  162. package/src/actions/clients/BeraApolloClient.ts +4 -2
  163. package/src/actions/clients/clientName.ts +17 -0
  164. package/src/actions/clients/clientName.unit.test.ts +39 -0
  165. package/src/actions/clients/exports.ts +2 -0
  166. package/src/actions/clients/fetchBeep.ts +4 -1
  167. package/src/actions/clients/fetchEnso.ts +48 -0
  168. package/src/actions/clients/fetchLayerzero.ts +34 -0
  169. package/src/actions/clients/fetchOpenApi.ts +9 -2
  170. package/src/actions/clients/fetchOpenApi.unit.test.ts +26 -10
  171. package/src/actions/clients/getApolloClient.ts +3 -11
  172. package/src/actions/dex/__tests__/aggregators.unit.test.ts +231 -2
  173. package/src/actions/dex/aggregators/base.ts +75 -17
  174. package/src/actions/dex/aggregators/bex.ts +41 -1
  175. package/src/actions/dex/aggregators/bgt.ts +11 -6
  176. package/src/actions/dex/aggregators/enso/enso.ts +1 -0
  177. package/src/actions/dex/aggregators/enso/ensoErc4626.ts +27 -9
  178. package/src/actions/dex/aggregators/erc4626.ts +19 -5
  179. package/src/actions/dex/aggregators/fly.ts +1 -0
  180. package/src/actions/dex/aggregators/haiku.ts +33 -2
  181. package/src/actions/dex/aggregators/honey.ts +17 -6
  182. package/src/actions/dex/aggregators/kyberswap.ts +1 -0
  183. package/src/actions/dex/aggregators/oogabooga.ts +1 -0
  184. package/src/actions/dex/aggregators/openOcean.ts +1 -0
  185. package/src/actions/dex/aggregators/wbera.ts +17 -11
  186. package/src/actions/enso/getBendMultiplyBundle.ts +1 -1
  187. package/src/actions/enso/getEnsoUserTokensWithBalances.ts +4 -8
  188. package/src/actions/enso/util.ts +0 -59
  189. package/src/actions/exports.ts +3 -5
  190. package/src/actions/honey/getHoney24hVolume.ts +3 -12
  191. package/src/actions/honey/getHoneyCollaterals.ts +1 -1
  192. package/src/actions/pol/getBeraTokenTotalSupply.ts +3 -33
  193. package/src/actions/pol/getLSTStakeConfig.ts +0 -6
  194. package/src/actions/pol/getSWBeraVaultMetadata.ts +2 -106
  195. package/src/actions/pol/getStakedBeraAPY.ts +45 -0
  196. package/src/actions/pol/getStakedBeraSnapshots.ts +18 -34
  197. package/src/actions/validators/getActiveBoostAndCommissionChangeDelay.ts +1 -1
  198. package/src/actions/validators/getUserActiveValidators.ts +116 -54
  199. package/src/actions/validators/getValidatorRewardAllocation.ts +12 -1
  200. package/src/contexts/BeraFlags/BeraFlags.tsx +1 -4
  201. package/src/contexts/BeraFlags/defaultFlags.ts +1 -3
  202. package/src/contexts/BexStatusProvider.tsx +1 -1
  203. package/src/contexts/TokensProvider.tsx +1 -4
  204. package/src/enum/contracts.ts +3 -0
  205. package/src/errors/BeraError.unit.test.ts +23 -0
  206. package/src/errors/RequestError.ts +46 -9
  207. package/src/errors/RequestError.unit.test.ts +54 -0
  208. package/src/errors/errorMap.ts +8 -3
  209. package/src/errors/getErrorMessage.unit.test.ts +32 -0
  210. package/src/hooks/dex/useAggregatorsQuotes.ts +7 -1
  211. package/src/hooks/dex/useCrossChainNativeFee.ts +83 -0
  212. package/src/hooks/dex/useCrossChainNativeFee.unit.test.ts +63 -0
  213. package/src/hooks/dex/useOnChainPoolData.ts +30 -13
  214. package/src/hooks/dex/useSingleAggregatorQuote.ts +4 -2
  215. package/src/hooks/enso/useBendZapSupply.ts +9 -38
  216. package/src/hooks/enso/useEnsoUserTokensWithBalances.ts +10 -2
  217. package/src/hooks/enso/useZapStakeBera.ts +1 -1
  218. package/src/hooks/exports.ts +2 -5
  219. package/src/hooks/pol/useAutoclaimedIncentives.ts +6 -3
  220. package/src/hooks/pol/useAutoclaimedIncentivesTxHash.ts +5 -2
  221. package/src/hooks/pol/useRewardTokenToBeraRate.ts +5 -4
  222. package/src/hooks/pol/useRewardVaultBalanceFromStakingToken.ts +0 -1
  223. package/src/hooks/pol/{useStakedAPR.ts → useStakedAPY.ts} +11 -9
  224. package/src/hooks/pol/useStakedData.ts +13 -14
  225. package/src/hooks/pol/useStakingVaultsMetadata.ts +3 -8
  226. package/src/hooks/tokens/useMultipleTokenInformation.ts +64 -21
  227. package/src/hooks/tokens/useMultipleTokenInformation.unit.test.ts +91 -0
  228. package/src/hooks/tokens/usePollBalance.ts +4 -2
  229. package/src/hooks/validators/useUserActiveValidators.ts +54 -9
  230. package/src/hooks/validators/useValidatorIncentiveDistribution.ts +3 -4
  231. package/src/types/bribeBoost.d.ts +0 -49
  232. package/src/types/dex.d.ts +17 -0
  233. package/src/types/enso.d.ts +1 -27
  234. package/src/types/global.d.ts +7 -0
  235. package/src/types/pol.d.ts +3 -48
  236. package/src/utils/crossChainBridge.ts +290 -0
  237. package/src/utils/crossChainBridge.unit.test.ts +177 -0
  238. package/src/utils/exports.ts +1 -1
  239. package/dist/BeraError-7-A5JYy_.d.ts +0 -123
  240. package/dist/BexStatusProvider-DRymVlQf.d.ts +0 -70
  241. package/dist/HoneyConfigProvider-COOuDNra.d.ts +0 -390
  242. package/dist/RequestError-DkUbo3ro.d.ts +0 -145
  243. package/dist/actions/clients/fetchOpenApi.unit.test.d.ts +0 -2
  244. package/dist/actions/clients/fetchOpenApi.unit.test.d.ts.map +0 -1
  245. package/dist/actions/dex/__tests__/aggregators.unit.test.d.ts +0 -2
  246. package/dist/actions/dex/__tests__/aggregators.unit.test.d.ts.map +0 -1
  247. package/dist/actions/dex/__tests__/allPools.integration.test.d.ts +0 -2
  248. package/dist/actions/dex/__tests__/allPools.integration.test.d.ts.map +0 -1
  249. package/dist/actions/dex/__tests__/getOnChainPool.unit.test.d.ts +0 -2
  250. package/dist/actions/dex/__tests__/getOnChainPool.unit.test.d.ts.map +0 -1
  251. package/dist/actions/dex/aggregators/enso/ensoErc4626.debug.test.d.ts +0 -2
  252. package/dist/actions/dex/aggregators/enso/ensoErc4626.debug.test.d.ts.map +0 -1
  253. package/dist/actions/dex/aggregators/haiku.integration.test.d.ts +0 -2
  254. package/dist/actions/dex/aggregators/haiku.integration.test.d.ts.map +0 -1
  255. package/dist/actions/dex/b-sdk.d.ts +0 -3
  256. package/dist/actions/enso/__tests__/getBendDemultiplyBundle.action.unit.test.d.ts +0 -2
  257. package/dist/actions/enso/__tests__/getBendDemultiplyBundle.action.unit.test.d.ts.map +0 -1
  258. package/dist/actions/enso/__tests__/getBendDemultiplyBundle.unit.test.d.ts +0 -2
  259. package/dist/actions/enso/__tests__/getBendDemultiplyBundle.unit.test.d.ts.map +0 -1
  260. package/dist/actions/enso/__tests__/getBendMultiplyBundle.action.unit.test.d.ts +0 -2
  261. package/dist/actions/enso/__tests__/getBendMultiplyBundle.action.unit.test.d.ts.map +0 -1
  262. package/dist/actions/enso/__tests__/getBendMultiplyBundle.unit.test.d.ts +0 -2
  263. package/dist/actions/enso/__tests__/getBendMultiplyBundle.unit.test.d.ts.map +0 -1
  264. package/dist/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.d.ts +0 -2
  265. package/dist/actions/enso/__tests__/getEnsoUserTokensWithBalances.debug.test.d.ts.map +0 -1
  266. package/dist/actions/enso/__tests__/util.unit.test.d.ts +0 -2
  267. package/dist/actions/enso/__tests__/util.unit.test.d.ts.map +0 -1
  268. package/dist/actions/enso/getEnsoSwapBundle.d.ts +0 -3
  269. package/dist/actions/enso/getEnsoSwapBundle.d.ts.map +0 -1
  270. package/dist/actions/governance/__tests__/checkProposalField.unit.test.d.ts +0 -2
  271. package/dist/actions/governance/__tests__/checkProposalField.unit.test.d.ts.map +0 -1
  272. package/dist/actions/governance/__tests__/getDecodedFunctionData.integration.test.d.ts +0 -2
  273. package/dist/actions/governance/__tests__/getDecodedFunctionData.integration.test.d.ts.map +0 -1
  274. package/dist/actions/governance/__tests__/getQuorum.integration.test.d.ts +0 -2
  275. package/dist/actions/governance/__tests__/getQuorum.integration.test.d.ts.map +0 -1
  276. package/dist/actions/honey/tests/pyth.integration.test.d.ts +0 -2
  277. package/dist/actions/honey/tests/pyth.integration.test.d.ts.map +0 -1
  278. package/dist/actions/pol/__tests__/getAllValidators.integration.test.d.ts +0 -2
  279. package/dist/actions/pol/__tests__/getAllValidators.integration.test.d.ts.map +0 -1
  280. package/dist/actions/pol/__tests__/getValidator.integration.test.d.ts +0 -2
  281. package/dist/actions/pol/__tests__/getValidator.integration.test.d.ts.map +0 -1
  282. package/dist/actions/pol/__tests__/rewardVaults.integration.test.d.ts +0 -2
  283. package/dist/actions/pol/__tests__/rewardVaults.integration.test.d.ts.map +0 -1
  284. package/dist/actions/pol/getBgtAprSimultaion.unit.test.d.ts +0 -2
  285. package/dist/actions/pol/getBgtAprSimultaion.unit.test.d.ts.map +0 -1
  286. package/dist/actions/pol/getBgtIncentiveDistributorPaused.d.ts +0 -10
  287. package/dist/actions/pol/getBgtIncentiveDistributorPaused.d.ts.map +0 -1
  288. package/dist/actions/pol/getBlockTime.debug.test.d.ts +0 -2
  289. package/dist/actions/pol/getBlockTime.debug.test.d.ts.map +0 -1
  290. package/dist/actions/pol/getRewardProofsByValidator.d.ts +0 -9
  291. package/dist/actions/pol/getRewardProofsByValidator.d.ts.map +0 -1
  292. package/dist/actions/pol/getRewardVaultBeaconImplementation.integration.test.d.ts +0 -2
  293. package/dist/actions/pol/getRewardVaultBeaconImplementation.integration.test.d.ts.map +0 -1
  294. package/dist/actions/pol/getRewardVaultDurationConstants.integration.test.d.ts +0 -2
  295. package/dist/actions/pol/getRewardVaultDurationConstants.integration.test.d.ts.map +0 -1
  296. package/dist/actions/pol/getStakedBeraAPR.d.ts +0 -12
  297. package/dist/actions/pol/getStakedBeraAPR.d.ts.map +0 -1
  298. package/dist/actions/pol/getUserClaimableIncentives.d.ts +0 -9
  299. package/dist/actions/pol/getUserClaimableIncentives.d.ts.map +0 -1
  300. package/dist/actions/prices/__tests__/prices.integration.test.d.ts +0 -2
  301. package/dist/actions/prices/__tests__/prices.integration.test.d.ts.map +0 -1
  302. package/dist/actions/tokens/getWalletBalances.integration.test.d.ts +0 -2
  303. package/dist/actions/tokens/getWalletBalances.integration.test.d.ts.map +0 -1
  304. package/dist/actions/transactions/beraWriteContract.integration.test.d.ts +0 -2
  305. package/dist/actions/transactions/beraWriteContract.integration.test.d.ts.map +0 -1
  306. package/dist/actions/validators/getActiveBoostAndCommissionChangeDelay.integration.test.d.ts +0 -2
  307. package/dist/actions/validators/getActiveBoostAndCommissionChangeDelay.integration.test.d.ts.map +0 -1
  308. package/dist/actions/validators/getValidatorAnalytics.d.ts +0 -12
  309. package/dist/actions/validators/getValidatorAnalytics.d.ts.map +0 -1
  310. package/dist/actions/validators/utils/__tests__/validatorUtils.integration.test.d.ts +0 -2
  311. package/dist/actions/validators/utils/__tests__/validatorUtils.integration.test.d.ts.map +0 -1
  312. package/dist/actions/validators/utils/aggregateValidatorIncentives.unit.test.d.ts +0 -2
  313. package/dist/actions/validators/utils/aggregateValidatorIncentives.unit.test.d.ts.map +0 -1
  314. package/dist/chunk-7TFV6UKF.mjs.map +0 -1
  315. package/dist/chunk-BSOWLS3W.mjs +0 -40
  316. package/dist/chunk-BSOWLS3W.mjs.map +0 -1
  317. package/dist/chunk-DOZJB6IJ.mjs.map +0 -1
  318. package/dist/chunk-IFNIPVTZ.mjs.map +0 -1
  319. package/dist/chunk-NZAH3SGT.mjs.map +0 -1
  320. package/dist/chunk-P3YZ7F22.mjs.map +0 -1
  321. package/dist/chunk-PHYZRH4I.mjs.map +0 -1
  322. package/dist/chunk-UA3Z47LT.mjs.map +0 -1
  323. package/dist/chunk-ZWTGVIPJ.mjs.map +0 -1
  324. package/dist/contexts/block-time-provider.d.ts +0 -10
  325. package/dist/defaultFlags-D6KfkTZx.d.ts +0 -10
  326. package/dist/dex-C_BB0b0O.d.ts +0 -37
  327. package/dist/errors/BeraError.unit.test.d.ts +0 -2
  328. package/dist/errors/BeraError.unit.test.d.ts.map +0 -1
  329. package/dist/errors/BeraTracing.unit.test.d.ts +0 -2
  330. package/dist/errors/BeraTracing.unit.test.d.ts.map +0 -1
  331. package/dist/errors/RequestError.unit.test.d.ts +0 -2
  332. package/dist/errors/RequestError.unit.test.d.ts.map +0 -1
  333. package/dist/errors/assert.unit.test.d.ts +0 -2
  334. package/dist/errors/assert.unit.test.d.ts.map +0 -1
  335. package/dist/errors/getRevertReason.integration.test.d.ts +0 -2
  336. package/dist/errors/getRevertReason.integration.test.d.ts.map +0 -1
  337. package/dist/errors/spanStatus.unit.test.d.ts +0 -2
  338. package/dist/errors/spanStatus.unit.test.d.ts.map +0 -1
  339. package/dist/getApolloClient-MWm_iq4u.d.ts +0 -39
  340. package/dist/getProposalVotes-DAUrdX2n.d.ts +0 -12
  341. package/dist/getValidatorQueuedOperatorAddress-N2I7wHd6.d.ts +0 -511
  342. package/dist/global.d-CR3zicga.d.ts +0 -231
  343. package/dist/global.d-CiZJ2eHz.d.ts +0 -231
  344. package/dist/honey-CYm0RWf4.d.ts +0 -14
  345. package/dist/hooks/enso/useEnsoSwapBundle.d.ts +0 -26
  346. package/dist/hooks/enso/useEnsoSwapBundle.d.ts.map +0 -1
  347. package/dist/hooks/pol/useBgtIncentiveDistributorPaused.d.ts +0 -8
  348. package/dist/hooks/pol/useBgtIncentiveDistributorPaused.d.ts.map +0 -1
  349. package/dist/hooks/pol/useStakedAPR.d.ts +0 -11
  350. package/dist/hooks/pol/useStakedAPR.d.ts.map +0 -1
  351. package/dist/hooks/validators/useUserClaimableIncentives.d.ts +0 -8
  352. package/dist/hooks/validators/useUserClaimableIncentives.d.ts.map +0 -1
  353. package/dist/hooks/validators/useValidatorAnalytics.d.ts +0 -11
  354. package/dist/hooks/validators/useValidatorAnalytics.d.ts.map +0 -1
  355. package/dist/pol.d-CeRgXBL8.d.ts +0 -167
  356. package/dist/txnEnum-ByI5dtDi.d.ts +0 -106
  357. package/dist/types/bribe-boost.d.ts +0 -69
  358. package/dist/types/bribeBoost.d.ts +0 -69
  359. package/dist/types/dex.d.ts +0 -225
  360. package/dist/types/enso.d.ts +0 -76
  361. package/dist/types/global.d.ts +0 -198
  362. package/dist/types/governance.d.ts +0 -112
  363. package/dist/types/honeySwap.d.ts +0 -23
  364. package/dist/types/pol.d.ts +0 -78
  365. package/dist/types/staking.d.ts +0 -22
  366. package/dist/useHoneySwapState-CXVWAThr.d.ts +0 -32
  367. package/dist/useHoneySwapState-twi7NTaO.d.ts +0 -32
  368. package/dist/utils/createEmitter.unit.test.d.ts +0 -2
  369. package/dist/utils/createEmitter.unit.test.d.ts.map +0 -1
  370. package/dist/utils/formatIncentivesTokenMap.d.ts +0 -3
  371. package/dist/utils/formatIncentivesTokenMap.d.ts.map +0 -1
  372. package/dist/utils/formatNumber.unit.test.d.ts +0 -2
  373. package/dist/utils/formatNumber.unit.test.d.ts.map +0 -1
  374. package/dist/utils/formatTimestamps.unit.test.d.ts +0 -2
  375. package/dist/utils/formatTimestamps.unit.test.d.ts.map +0 -1
  376. package/dist/utils/getContractName.unit.test.d.ts +0 -2
  377. package/dist/utils/getContractName.unit.test.d.ts.map +0 -1
  378. package/dist/utils/getHoneySwapMessage.test.d.ts +0 -2
  379. package/dist/utils/getHoneySwapMessage.test.d.ts.map +0 -1
  380. package/dist/utils/layerZeroScan.d.ts +0 -39
  381. package/dist/utils/layerZeroScan.d.ts.map +0 -1
  382. package/dist/utils/math.unit.test.d.ts +0 -2
  383. package/dist/utils/math.unit.test.d.ts.map +0 -1
  384. package/dist/utils/parseBaseArgs.unit.test.d.ts +0 -2
  385. package/dist/utils/parseBaseArgs.unit.test.d.ts.map +0 -1
  386. package/dist/utils/polyfillAbortSignalAny.unit.test.d.ts +0 -2
  387. package/dist/utils/polyfillAbortSignalAny.unit.test.d.ts.map +0 -1
  388. package/dist/utils/time.unit.test.d.ts +0 -2
  389. package/dist/utils/time.unit.test.d.ts.map +0 -1
  390. package/dist/utils/tokens.unit.test.d.ts +0 -2
  391. package/dist/utils/tokens.unit.test.d.ts.map +0 -1
  392. package/dist/utils/truncateHash.unit.test.d.ts +0 -2
  393. package/dist/utils/truncateHash.unit.test.d.ts.map +0 -1
  394. package/src/actions/enso/getEnsoSwapBundle.ts +0 -72
  395. package/src/actions/pol/getBgtIncentiveDistributorPaused.ts +0 -28
  396. package/src/actions/pol/getRewardProofsByValidator.ts +0 -49
  397. package/src/actions/pol/getStakedBeraAPR.ts +0 -56
  398. package/src/actions/pol/getUserClaimableIncentives.ts +0 -40
  399. package/src/actions/validators/getValidatorAnalytics.ts +0 -37
  400. package/src/hooks/enso/useEnsoSwapBundle.ts +0 -121
  401. package/src/hooks/pol/useBgtIncentiveDistributorPaused.ts +0 -34
  402. package/src/hooks/validators/useUserClaimableIncentives.ts +0 -148
  403. package/src/hooks/validators/useValidatorAnalytics.ts +0 -37
  404. package/src/utils/formatIncentivesTokenMap.ts +0 -19
  405. package/src/utils/layerZeroScan.ts +0 -124
  406. /package/dist/{chunk-AEN6IJFU.mjs.map → chunk-7KN7TDUC.mjs.map} +0 -0
  407. /package/dist/{chunk-LE4CYW7S.mjs.map → chunk-FWRYUIJK.mjs.map} +0 -0
  408. /package/dist/{chunk-PJRLHTGC.mjs.map → chunk-HPRLNT6R.mjs.map} +0 -0
  409. /package/dist/{chunk-EJIGERYM.mjs.map → chunk-M3MIGSH3.mjs.map} +0 -0
  410. /package/dist/{chunk-TGN55GKE.mjs.map → chunk-SC3BSCTN.mjs.map} +0 -0
  411. /package/dist/{chunk-QQASX4LJ.mjs.map → chunk-TXWDUJOY.mjs.map} +0 -0
  412. /package/dist/{chunk-EGAB6NFQ.mjs.map → chunk-UWJQ6UKG.mjs.map} +0 -0
  413. /package/dist/{chunk-J3LTASDE.mjs.map → chunk-ZHV3MQ4F.mjs.map} +0 -0
@@ -0,0 +1,290 @@
1
+ import { fetchLayerzero } from "../actions/clients/fetchLayerzero";
2
+ import { BeraError } from "../errors/BeraError";
3
+ import { InvalidArgumentError } from "../errors/InvalidArgumentError";
4
+ import { RequestError } from "../errors/RequestError";
5
+ import { beraFetchJson } from "./beraFetch";
6
+
7
+ // Enso routes cross-chain zaps over one of these bridges (from the "bridge"
8
+ // hop's `protocol` in its route response). Each has its own status API +
9
+ // explorer, so tracking has to branch on the bridge.
10
+ export type BridgeProtocol = "relay" | "stargate" | "ccip" | "layerzero";
11
+
12
+ const RELAY_API_URL = "https://api.relay.link";
13
+
14
+ // Public explorer origins for deep-linking a bridged tx. See getBridgeExplorerUrl.
15
+ const LAYERZERO_SCAN_EXPLORER = "https://layerzeroscan.com";
16
+ const RELAY_EXPLORER = "https://relay.link";
17
+
18
+ export enum BridgeMessageStatus {
19
+ INFLIGHT = "INFLIGHT",
20
+ DELIVERED = "DELIVERED",
21
+ FAILED = "FAILED",
22
+ }
23
+
24
+ export type BridgeMessage = {
25
+ srcTxHash?: string;
26
+ dstTxHash?: string;
27
+ status: BridgeMessageStatus;
28
+ statusMessage?: string;
29
+ /**
30
+ * Bridge-specific id for deep-linking the explorer, when the explorer keys
31
+ * on something other than the source tx hash (Relay uses its requestId).
32
+ */
33
+ explorerId?: string;
34
+ };
35
+
36
+ export type BridgeDeliveredMessage = BridgeMessage & {
37
+ dstTxHash: string;
38
+ };
39
+
40
+ // --- LayerZero / Stargate ---------------------------------------------------
41
+
42
+ async function getLayerZeroMessage(srcTxHash: string): Promise<BridgeMessage> {
43
+ const { data } = await fetchLayerzero("/messages/tx/{tx}", {
44
+ path: { tx: srcTxHash },
45
+ });
46
+
47
+ const message = data[0];
48
+ if (!message) {
49
+ // not indexed yet — keep polling
50
+ return { srcTxHash, status: BridgeMessageStatus.INFLIGHT };
51
+ }
52
+
53
+ return {
54
+ srcTxHash: message.source?.tx?.txHash,
55
+ // the destination union has several shapes; only the plain-delivery one
56
+ // carries `tx.txHash`, so narrow before reading it.
57
+ dstTxHash:
58
+ message.destination && "tx" in message.destination
59
+ ? message.destination.tx?.txHash
60
+ : undefined,
61
+ statusMessage: message.status?.message,
62
+ // v1 exposes many transient states; anything not DELIVERED/FAILED means
63
+ // "keep polling", so collapse unknown names to INFLIGHT.
64
+ status:
65
+ message.status?.name === "DELIVERED"
66
+ ? BridgeMessageStatus.DELIVERED
67
+ : message.status?.name === "FAILED"
68
+ ? BridgeMessageStatus.FAILED
69
+ : BridgeMessageStatus.INFLIGHT,
70
+ };
71
+ }
72
+
73
+ // --- Relay ------------------------------------------------------------------
74
+
75
+ // Relay has no OpenAPI schema/client yet (unlike LayerZero's fetchLayerzero),
76
+ // so this stays hand-rolled over beraFetchJson with a local response type.
77
+ // Raw shape of the Relay requests API (only the fields we consume).
78
+ type RelayRequestsResponse = {
79
+ requests: {
80
+ id: string;
81
+ status: string;
82
+ data?: {
83
+ failReason?: string;
84
+ outTxs?: { hash?: string }[];
85
+ };
86
+ }[];
87
+ };
88
+
89
+ async function getRelayMessage(srcTxHash: string): Promise<BridgeMessage> {
90
+ const { requests } = await beraFetchJson<RelayRequestsResponse>({
91
+ url: `${RELAY_API_URL}/requests/v2?hash=${srcTxHash}`,
92
+ type: "rest",
93
+ name: "Relay",
94
+ });
95
+
96
+ const request = requests[0];
97
+ if (!request) {
98
+ // not indexed yet — keep polling
99
+ return { srcTxHash, status: BridgeMessageStatus.INFLIGHT };
100
+ }
101
+
102
+ return {
103
+ srcTxHash,
104
+ dstTxHash: request.data?.outTxs?.[0]?.hash,
105
+ statusMessage: request.data?.failReason,
106
+ // Relay's explorer keys on the requestId, not the source tx hash.
107
+ explorerId: request.id,
108
+ status:
109
+ request.status === "success"
110
+ ? BridgeMessageStatus.DELIVERED
111
+ : request.status === "failure" || request.status === "refund"
112
+ ? BridgeMessageStatus.FAILED
113
+ : BridgeMessageStatus.INFLIGHT,
114
+ };
115
+ }
116
+
117
+ // --- Unified poller ---------------------------------------------------------
118
+
119
+ function sleep(ms: number) {
120
+ return new Promise((resolve) => setTimeout(resolve, ms));
121
+ }
122
+
123
+ function getBridgeMessage(
124
+ bridgeProtocol: string,
125
+ srcTxHash: string,
126
+ ): Promise<BridgeMessage> {
127
+ switch (bridgeProtocol) {
128
+ case "relay":
129
+ return getRelayMessage(srcTxHash);
130
+ // Enso's "stargate" is LayerZero's Stargate; both track on LayerZero Scan.
131
+ case "stargate":
132
+ case "layerzero":
133
+ return getLayerZeroMessage(srcTxHash);
134
+ default:
135
+ // ccip and anything else aren't tracked (ccip is excluded at routing time
136
+ // via `ignoreBridges` in ensoErc4626) — reject so the caller can decide
137
+ // (the tracker treats this as "can't poll", not "failed").
138
+ throw new InvalidArgumentError({
139
+ property: "bridgeProtocol",
140
+ value: bridgeProtocol,
141
+ expected: "relay | stargate | layerzero",
142
+ });
143
+ }
144
+ }
145
+
146
+ export interface BridgeExplorerUrlArgs {
147
+ /** Bridge Enso routed through; picks which explorer to link. */
148
+ bridgeProtocol?: string;
149
+ /** Source-chain tx hash — how LayerZero/Stargate + the fallback key. */
150
+ srcTxHash?: string;
151
+ /**
152
+ * Relay's requestId, when known. Relay's explorer prefers it but also resolves
153
+ * on the src tx hash, so a missing id still links to the bridge explorer.
154
+ */
155
+ explorerId?: string;
156
+ /**
157
+ * Source-chain block explorer origin (e.g. https://etherscan.io). Only a
158
+ * last resort for an unknown/untracked bridge; tracked bridges always link to
159
+ * their own bridge explorer (which shows the src→dst delivery still in flight).
160
+ */
161
+ fallbackExplorerUrl: string;
162
+ }
163
+
164
+ /**
165
+ * Deep-link a bridged tx to the right *bridge* explorer — the one showing the
166
+ * source→destination delivery, which is what's still in flight once a tracker is
167
+ * visible (the source tx already confirmed). Enso picks the bridge per-route, so
168
+ * a single hardcoded explorer is wrong for the others; each keys differently
169
+ * (LayerZero/Stargate on the src tx hash, Relay on its requestId or the src tx
170
+ * hash). Only a genuinely unknown protocol falls back to the source chain's own
171
+ * block explorer.
172
+ *
173
+ * We deliberately don't route this through Enso's `getBridgeStatus`
174
+ * (`/{protocol}/bridge/check`): it normalizes status but doesn't return Relay's
175
+ * requestId, which the Relay deep link prefers — so we'd still branch per bridge.
176
+ */
177
+ export function getBridgeExplorerUrl({
178
+ bridgeProtocol,
179
+ srcTxHash,
180
+ explorerId,
181
+ fallbackExplorerUrl,
182
+ }: BridgeExplorerUrlArgs): string | undefined {
183
+ switch (bridgeProtocol) {
184
+ case "relay":
185
+ // Relay's explorer resolves on either the requestId or the src tx hash,
186
+ // so stay on the bridge explorer even before we've fetched the id.
187
+ return srcTxHash || explorerId
188
+ ? `${RELAY_EXPLORER}/transaction/${explorerId ?? srcTxHash}`
189
+ : undefined;
190
+ case "stargate":
191
+ case "layerzero":
192
+ return srcTxHash
193
+ ? `${LAYERZERO_SCAN_EXPLORER}/tx/${srcTxHash}`
194
+ : undefined;
195
+ default:
196
+ // Unknown/untracked bridge (shouldn't surface — ccip is routed out and the
197
+ // tracker needs a known protocol to poll): no bridge explorer exists, so
198
+ // the source chain's block explorer is the only link we can build.
199
+ return srcTxHash ? `${fallbackExplorerUrl}/tx/${srcTxHash}` : undefined;
200
+ }
201
+ }
202
+
203
+ /**
204
+ * One-shot status lookup for a bridged tx. Used to grab the explorer id (e.g.
205
+ * Relay's requestId) for the pending-state link before delivery. Swallows
206
+ * errors into an INFLIGHT result so a not-yet-indexed tx doesn't throw.
207
+ */
208
+ export async function getBridgeMessageOnce(
209
+ bridgeProtocol: string,
210
+ srcTxHash: string,
211
+ ): Promise<BridgeMessage> {
212
+ try {
213
+ return await getBridgeMessage(bridgeProtocol, srcTxHash);
214
+ } catch {
215
+ return { srcTxHash, status: BridgeMessageStatus.INFLIGHT };
216
+ }
217
+ }
218
+
219
+ export type WaitForMessageReceivedOptions = {
220
+ /** Which bridge Enso routed through; narrowed at getBridgeMessage's switch. */
221
+ bridgeProtocol: string;
222
+ /** Polling interval in ms (default: 3000). */
223
+ pollInterval?: number;
224
+ /** Timeout in ms (default: 600000 / 10 minutes). */
225
+ timeout?: number;
226
+ };
227
+
228
+ /**
229
+ * Polls the bridge's status API until the cross-chain message is delivered or
230
+ * fails, then resolves with the delivered message (incl. destination tx hash).
231
+ * HTTP errors are silently retried until timeout. Throws InvalidArgumentError
232
+ * if srcTxHash/bridgeProtocol is missing or unsupported, or BeraError if the
233
+ * message fails or times out.
234
+ */
235
+ export async function waitForBridgeMessageReceived(
236
+ srcTxHash: string,
237
+ options: WaitForMessageReceivedOptions,
238
+ ): Promise<BridgeDeliveredMessage> {
239
+ const { bridgeProtocol, pollInterval = 3000, timeout = 600_000 } = options;
240
+
241
+ if (!srcTxHash) {
242
+ throw new InvalidArgumentError({
243
+ property: "srcTxHash",
244
+ value: srcTxHash,
245
+ expected: "string",
246
+ });
247
+ }
248
+
249
+ const startTime = Date.now();
250
+
251
+ while (true) {
252
+ if (Date.now() - startTime > timeout) {
253
+ throw new BeraError({
254
+ message: `Bridge message tracking timed out after ${timeout}ms`,
255
+ reason: "BRIDGE_TIMEOUT",
256
+ level: "warning",
257
+ });
258
+ }
259
+
260
+ try {
261
+ const message = await getBridgeMessage(bridgeProtocol, srcTxHash);
262
+
263
+ if (message.status === BridgeMessageStatus.FAILED) {
264
+ throw new BeraError({
265
+ message: `Bridge message failed: ${message.statusMessage}`,
266
+ reason: "BRIDGE_MESSAGE_FAILED",
267
+ });
268
+ }
269
+
270
+ // Only resolve once we actually have the destination tx hash the type
271
+ // promises. A DELIVERED status without one (e.g. LZ's destination union
272
+ // lacking `tx`) means the dst tx isn't indexed yet — keep polling rather
273
+ // than cast a message with `dstTxHash: undefined`.
274
+ if (
275
+ message.status === BridgeMessageStatus.DELIVERED &&
276
+ message.dstTxHash
277
+ ) {
278
+ return message as BridgeDeliveredMessage;
279
+ }
280
+ } catch (error) {
281
+ // re-throw non-retryable errors (validation, failed message) but allow
282
+ // RequestError to retry (network issues, temporary API errors)
283
+ if (error instanceof BeraError && !(error instanceof RequestError)) {
284
+ throw error;
285
+ }
286
+ }
287
+
288
+ await sleep(pollInterval);
289
+ }
290
+ }
@@ -0,0 +1,177 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+
3
+ import {
4
+ BridgeMessageStatus,
5
+ getBridgeExplorerUrl,
6
+ getBridgeMessageOnce,
7
+ } from "./crossChainBridge";
8
+
9
+ const mockFetchLayerzero = vi.fn();
10
+ const mockBeraFetchJson = vi.fn();
11
+
12
+ vi.mock("../actions/clients/fetchLayerzero", () => ({
13
+ fetchLayerzero: (...args: unknown[]) => mockFetchLayerzero(...args),
14
+ }));
15
+ vi.mock("./beraFetch", () => ({
16
+ beraFetchJson: (...args: unknown[]) => mockBeraFetchJson(...args),
17
+ }));
18
+
19
+ const TX = "0xabc";
20
+ const SRC = "0xsrc";
21
+ const DST = "0xdst";
22
+ const FALLBACK = "https://etherscan.io";
23
+
24
+ describe("getBridgeExplorerUrl", () => {
25
+ it("links LayerZero/Stargate to LZ Scan by src tx hash", () => {
26
+ for (const bridgeProtocol of ["layerzero", "stargate"]) {
27
+ expect(
28
+ getBridgeExplorerUrl({
29
+ bridgeProtocol,
30
+ srcTxHash: TX,
31
+ fallbackExplorerUrl: FALLBACK,
32
+ }),
33
+ ).toBe(`https://layerzeroscan.com/tx/${TX}`);
34
+ }
35
+ });
36
+
37
+ it("links Relay to relay.link by explorerId (requestId)", () => {
38
+ expect(
39
+ getBridgeExplorerUrl({
40
+ bridgeProtocol: "relay",
41
+ srcTxHash: TX,
42
+ explorerId: "req-1",
43
+ fallbackExplorerUrl: FALLBACK,
44
+ }),
45
+ ).toBe("https://relay.link/transaction/req-1");
46
+ });
47
+
48
+ it("keeps Relay on its explorer via src tx hash when no explorerId yet", () => {
49
+ expect(
50
+ getBridgeExplorerUrl({
51
+ bridgeProtocol: "relay",
52
+ srcTxHash: TX,
53
+ fallbackExplorerUrl: FALLBACK,
54
+ }),
55
+ ).toBe(`https://relay.link/transaction/${TX}`);
56
+ });
57
+
58
+ it("falls back to the src chain for untracked/unknown bridges", () => {
59
+ expect(
60
+ getBridgeExplorerUrl({
61
+ bridgeProtocol: "ccip",
62
+ srcTxHash: TX,
63
+ fallbackExplorerUrl: FALLBACK,
64
+ }),
65
+ ).toBe(`${FALLBACK}/tx/${TX}`);
66
+ expect(
67
+ getBridgeExplorerUrl({
68
+ srcTxHash: TX,
69
+ fallbackExplorerUrl: FALLBACK,
70
+ }),
71
+ ).toBe(`${FALLBACK}/tx/${TX}`);
72
+ });
73
+
74
+ it("returns undefined when there's no tx hash to key on", () => {
75
+ expect(
76
+ getBridgeExplorerUrl({
77
+ bridgeProtocol: "layerzero",
78
+ fallbackExplorerUrl: FALLBACK,
79
+ }),
80
+ ).toBeUndefined();
81
+ });
82
+ });
83
+
84
+ // Parser tests: feed representative API JSON (shapes captured from the live
85
+ // LayerZero Scan + Relay APIs) through the mappers via getBridgeMessageOnce,
86
+ // which dispatches by protocol. Guards against the response shape / status
87
+ // vocabulary drifting away from what the mappers expect.
88
+ describe("getBridgeMessageOnce parsers", () => {
89
+ beforeEach(() => {
90
+ mockFetchLayerzero.mockReset();
91
+ mockBeraFetchJson.mockReset();
92
+ });
93
+
94
+ describe("LayerZero / Stargate", () => {
95
+ it("maps a delivered message with its destination tx hash", async () => {
96
+ mockFetchLayerzero.mockResolvedValue({
97
+ data: [
98
+ {
99
+ source: { tx: { txHash: SRC } },
100
+ destination: { tx: { txHash: DST } },
101
+ status: { name: "DELIVERED" },
102
+ },
103
+ ],
104
+ });
105
+ const msg = await getBridgeMessageOnce("layerzero", SRC);
106
+ expect(msg.status).toBe(BridgeMessageStatus.DELIVERED);
107
+ expect(msg.dstTxHash).toBe(DST);
108
+ });
109
+
110
+ it("maps FAILED and carries the status message", async () => {
111
+ mockFetchLayerzero.mockResolvedValue({
112
+ data: [{ status: { name: "FAILED", message: "revert reason" } }],
113
+ });
114
+ const msg = await getBridgeMessageOnce("stargate", SRC);
115
+ expect(msg.status).toBe(BridgeMessageStatus.FAILED);
116
+ expect(msg.statusMessage).toBe("revert reason");
117
+ });
118
+
119
+ it("collapses transient states (e.g. CONFIRMING) to INFLIGHT", async () => {
120
+ mockFetchLayerzero.mockResolvedValue({
121
+ data: [{ status: { name: "CONFIRMING" } }],
122
+ });
123
+ const msg = await getBridgeMessageOnce("layerzero", SRC);
124
+ expect(msg.status).toBe(BridgeMessageStatus.INFLIGHT);
125
+ });
126
+
127
+ it("treats a not-yet-indexed (empty) response as INFLIGHT", async () => {
128
+ mockFetchLayerzero.mockResolvedValue({ data: [] });
129
+ const msg = await getBridgeMessageOnce("layerzero", SRC);
130
+ expect(msg.status).toBe(BridgeMessageStatus.INFLIGHT);
131
+ });
132
+ });
133
+
134
+ describe("Relay", () => {
135
+ it("maps success -> DELIVERED with requestId + dst tx hash", async () => {
136
+ mockBeraFetchJson.mockResolvedValue({
137
+ requests: [
138
+ { id: "req-1", status: "success", data: { outTxs: [{ hash: DST }] } },
139
+ ],
140
+ });
141
+ const msg = await getBridgeMessageOnce("relay", SRC);
142
+ expect(msg.status).toBe(BridgeMessageStatus.DELIVERED);
143
+ expect(msg.dstTxHash).toBe(DST);
144
+ expect(msg.explorerId).toBe("req-1");
145
+ });
146
+
147
+ it("maps failure and refund -> FAILED", async () => {
148
+ for (const status of ["failure", "refund"]) {
149
+ mockBeraFetchJson.mockResolvedValue({
150
+ requests: [{ id: "r", status, data: { failReason: "boom" } }],
151
+ });
152
+ const msg = await getBridgeMessageOnce("relay", SRC);
153
+ expect(msg.status).toBe(BridgeMessageStatus.FAILED);
154
+ expect(msg.statusMessage).toBe("boom");
155
+ }
156
+ });
157
+
158
+ it("treats pending / unknown status as INFLIGHT", async () => {
159
+ mockBeraFetchJson.mockResolvedValue({
160
+ requests: [{ id: "r", status: "pending", data: {} }],
161
+ });
162
+ const msg = await getBridgeMessageOnce("relay", SRC);
163
+ expect(msg.status).toBe(BridgeMessageStatus.INFLIGHT);
164
+ });
165
+
166
+ it("treats a not-yet-indexed (empty) response as INFLIGHT", async () => {
167
+ mockBeraFetchJson.mockResolvedValue({ requests: [] });
168
+ const msg = await getBridgeMessageOnce("relay", SRC);
169
+ expect(msg.status).toBe(BridgeMessageStatus.INFLIGHT);
170
+ });
171
+ });
172
+
173
+ it("swallows an unsupported bridge into INFLIGHT (never throws)", async () => {
174
+ const msg = await getBridgeMessageOnce("ccip", SRC);
175
+ expect(msg.status).toBe(BridgeMessageStatus.INFLIGHT);
176
+ });
177
+ });
@@ -1,6 +1,7 @@
1
1
  export { defaultFlags as defaultBeraFlags } from "../contexts/BeraFlags/defaultFlags";
2
2
  export * from "./beraFetch";
3
3
  export * from "./constants";
4
+ export * from "./crossChainBridge";
4
5
  export * from "./formatInputTokenValue";
5
6
  export * from "./formatNumber";
6
7
  export * from "./formatTimestamps";
@@ -11,7 +12,6 @@ export * from "./getServerSideClient";
11
12
  export { getTestClient } from "./getTestClient";
12
13
  export * from "./isDifferenceExceedingThreshold";
13
14
  export * from "./isSubgraphStale";
14
- export * from "./layerZeroScan";
15
15
  export * from "./math";
16
16
  export * from "./parseBaseArgs";
17
17
  export * from "./parseWhiskToken";
@@ -1,123 +0,0 @@
1
- import { Abi } from 'viem';
2
-
3
- /**
4
- * Severity levels for error reporting.
5
- * Mirrors Sentry's SeverityLevel for compatibility, but owned by berajs
6
- * so we don't depend on @sentry/nextjs.
7
- */
8
- type SeverityLevel = "fatal" | "error" | "warning" | "log" | "info" | "debug";
9
-
10
- /**
11
- * Span status codes for tracing.
12
- * Mirrors Sentry's SpanStatusType for compatibility, but owned by berajs
13
- * so we don't depend on @sentry/nextjs.
14
- *
15
- * @see https://develop.sentry.dev/sdk/foundations/transport/event-payloads/span/
16
- */
17
- type SpanStatusType = "ok" | "cancelled" | "unknown_error" | "invalid_argument" | "deadline_exceeded" | "not_found" | "already_exists" | "permission_denied" | "resource_exhausted" | "failed_precondition" | "aborted" | "out_of_range" | "unimplemented" | "internal_error" | "unavailable" | "data_loss" | "unauthenticated";
18
- /**
19
- * Maps an HTTP status code to a span status.
20
- */
21
- declare function httpStatusToSpanStatus(code: number): SpanStatusType;
22
- /**
23
- * Maps a BeraError reason code to a span status.
24
- * Returns undefined if no mapping exists (caller keeps existing spanStatus).
25
- */
26
- declare function reasonToSpanStatus(reason: string | null): SpanStatusType | undefined;
27
-
28
- interface IBeraErrorArgs {
29
- message?: string;
30
- displayMessage?: string;
31
- cause?: unknown;
32
- reason?: string;
33
- chainId?: number;
34
- fingerprint?: string[];
35
- /**
36
- * The level of the error to be used for error reporting.
37
- */
38
- level?: SeverityLevel;
39
- tags?: {
40
- [key in TagsKey]?: Primitive;
41
- };
42
- extra?: Record<string, unknown>;
43
- /**
44
- * Optional ABI to be used to parse the error.
45
- */
46
- abi?: Abi;
47
- /**
48
- * Span status for tracing. When set, the tracing adapter uses this to
49
- * set the span status instead of a generic "internal_error".
50
- * Auto-inferred from `reason` when not explicitly provided.
51
- */
52
- spanStatus?: SpanStatusType;
53
- }
54
- type Primitive = number | string | boolean | bigint | symbol | null | undefined;
55
- /**
56
- * An helper type to make sure we only use the allowed tags. Sync this with docs/errors.md
57
- */
58
- type TagsKey = "wallet.chain" | "wallet.connector" | "wallet.address" | "error.reason" | "operation.type" | "operation.key" | "operation.txn.functionName" | "operation.txn.to" | "operation.txn.status" | "operation.source.url" | "operation.source.name" | "operation.source.queryName" | "operation.source.type";
59
- /**
60
- * Base error class for the entire berajs SDK.
61
- *
62
- * All errors should be a BeraError or one of its subclasses. Unknown errors should be
63
- * normalized via `initBeraError({ cause })`.
64
- *
65
- * Key design: the constructor runs an **automatic reason detection pipeline** when `reason`
66
- * is not explicitly provided. It calls `parseViemError` on the `cause` to extract a
67
- * machine-readable reason code (e.g. "NotEnoughBalance", "BAL#508", "UserRejectedRequestError").
68
- * That reason is then matched against `errorMap.ts` to resolve a user-friendly `displayMessage`.
69
- *
70
- * This means: for most viem errors, you only need to pass `cause` and everything else
71
- * (reason, displayMessage, level) is derived automatically.
72
- *
73
- * @see parseViemError — the reason extraction engine
74
- * @see errorMap.ts — reason → displayMessage mapping
75
- * @see initBeraError — normalizes any error into a BeraError (preferred entry point)
76
- */
77
- declare class BeraError extends Error {
78
- /**
79
- * A human-readable message that can be displayed to end user.
80
- *
81
- * In berachain dapps, this is shown in the error pop-up.
82
- */
83
- displayMessage: string;
84
- /**
85
- * The cause of the error.
86
- *
87
- * This is typically the error that was thrown.
88
- */
89
- cause: unknown;
90
- /**
91
- * The chain id of the error.
92
- */
93
- chainId?: number;
94
- /**
95
- * The code for the reason for the error.
96
- *
97
- * This is typically the error code can be found in the errorMap.ts file. I.e. NotEnoughBalance or BAL#508
98
- */
99
- reason: string | null;
100
- /**
101
- * The fingerprint for the error.
102
- *
103
- * This is typically used to group errors in Sentry.
104
- */
105
- fingerprint: string[] | undefined;
106
- private _tags;
107
- set tags(tags: {
108
- [key: string | TagsKey]: Primitive;
109
- });
110
- get tags(): {
111
- [key: string | TagsKey]: Primitive;
112
- };
113
- level: SeverityLevel;
114
- /**
115
- * Span status for tracing providers.
116
- * Auto-inferred from `reason` when not explicitly provided.
117
- */
118
- spanStatus?: SpanStatusType;
119
- extra: Record<string, unknown>;
120
- constructor({ message: m, displayMessage: dm, cause, reason, level, abi, tags, chainId, fingerprint, spanStatus, }: IBeraErrorArgs);
121
- }
122
-
123
- export { BeraError as B, type IBeraErrorArgs as I, type SeverityLevel as S, type SpanStatusType as a, httpStatusToSpanStatus as h, reasonToSpanStatus as r };
@@ -1,70 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as react from 'react';
3
- import { Dispatch, SetStateAction, PropsWithChildren } from 'react';
4
- import { Hex } from 'viem';
5
- import { EdgeConfigSchema } from '@berachain/config/internal/edge-config';
6
-
7
- type FactoryStatus = {
8
- /**
9
- * If the composable stable factory is enabled
10
- */
11
- composableStable: "paused" | "enabled";
12
- /**
13
- * If the weighted factory is enabled
14
- */
15
- weighted: "paused" | "enabled";
16
- };
17
- interface BexStatusProviderProps {
18
- isVaultPaused: boolean;
19
- pool?: {
20
- id: Hex;
21
- isInRecoveryMode: boolean;
22
- isPaused: boolean;
23
- };
24
- factories: FactoryStatus;
25
- labels?: NonNullable<EdgeConfigSchema["bex"]>["emergencyLabels"];
26
- }
27
- declare const BexStateContext: react.Context<{
28
- protocol: {
29
- isPaused: boolean;
30
- factories: FactoryStatus & {
31
- allPaused: boolean;
32
- };
33
- };
34
- onPoolChange: Dispatch<SetStateAction<BexStatusProviderProps["pool"]>>;
35
- pool?: {
36
- id: Hex;
37
- isInRecoveryMode: boolean;
38
- isPaused: boolean;
39
- disablePoolWithdrawals: boolean;
40
- disablePoolDeposits: boolean;
41
- };
42
- labels?: NonNullable<EdgeConfigSchema["bex"]>["emergencyLabels"];
43
- }>;
44
- /**
45
- * @description Determines the status of a pool or vault and returns the appropriate messages and flags to disable functionality.
46
- * More information here https://www.notion.so/berachain/BEX-RecoveryMode-and-Pause-explained-17c6120abced80e0985dd589b57ff018
47
- *
48
- * @returns status flags to enable/disable/notify users across the BEX
49
- *
50
- **/
51
- declare function useBexStatus(): {
52
- protocol: {
53
- isPaused: boolean;
54
- factories: FactoryStatus & {
55
- allPaused: boolean;
56
- };
57
- };
58
- onPoolChange: Dispatch<SetStateAction<BexStatusProviderProps["pool"]>>;
59
- pool?: {
60
- id: Hex;
61
- isInRecoveryMode: boolean;
62
- isPaused: boolean;
63
- disablePoolWithdrawals: boolean;
64
- disablePoolDeposits: boolean;
65
- };
66
- labels?: NonNullable<EdgeConfigSchema["bex"]>["emergencyLabels"];
67
- };
68
- declare function BexStatusProvider({ children, isVaultPaused, labels, factories, }: PropsWithChildren<BexStatusProviderProps>): react_jsx_runtime.JSX.Element;
69
-
70
- export { BexStateContext as B, BexStatusProvider as a, type BexStatusProviderProps as b, useBexStatus as u };