@berachain/berajs 0.2.8-beta.1 → 0.2.8-beta.11

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 (222) hide show
  1. package/dist/RequestError-BRIiJgHk.d.ts +144 -0
  2. package/dist/RequestError-DSUzJ1Iy.d.cts +144 -0
  3. package/dist/abi/exports.cjs.map +1 -1
  4. package/dist/abi/exports.mjs +1 -1
  5. package/dist/actions/exports.cjs +1 -1
  6. package/dist/actions/exports.cjs.map +1 -1
  7. package/dist/actions/exports.d.cts +22 -105
  8. package/dist/actions/exports.d.ts +22 -105
  9. package/dist/actions/exports.mjs +1 -1
  10. package/dist/actions/exports.mjs.map +1 -1
  11. package/dist/actions/governance/exports.cjs +2 -0
  12. package/dist/actions/governance/exports.cjs.map +1 -0
  13. package/dist/actions/governance/exports.d.cts +140 -0
  14. package/dist/actions/governance/exports.d.ts +140 -0
  15. package/dist/actions/governance/exports.mjs +2 -0
  16. package/dist/actions/governance/exports.mjs.map +1 -0
  17. package/dist/chunk-33XNWMPP.cjs +2 -0
  18. package/dist/chunk-33XNWMPP.cjs.map +1 -0
  19. package/dist/chunk-4TALWNXE.cjs +2 -0
  20. package/dist/chunk-4TALWNXE.cjs.map +1 -0
  21. package/dist/chunk-54BTOQE3.cjs +2 -0
  22. package/dist/chunk-54BTOQE3.cjs.map +1 -0
  23. package/dist/chunk-5QAFKFM5.mjs +2 -0
  24. package/dist/chunk-5QAFKFM5.mjs.map +1 -0
  25. package/dist/chunk-6DIA6PXV.cjs +2 -0
  26. package/dist/chunk-6DIA6PXV.cjs.map +1 -0
  27. package/dist/{chunk-NMH7LHPW.cjs → chunk-6JJIZCVY.cjs} +2 -2
  28. package/dist/chunk-6JJIZCVY.cjs.map +1 -0
  29. package/dist/chunk-BE6B4PQF.cjs +2 -0
  30. package/dist/chunk-BE6B4PQF.cjs.map +1 -0
  31. package/dist/chunk-CHFETMC6.cjs +4 -0
  32. package/dist/chunk-CHFETMC6.cjs.map +1 -0
  33. package/dist/{chunk-I7M43BB4.cjs → chunk-D6L7LTA2.cjs} +2 -2
  34. package/dist/chunk-D6L7LTA2.cjs.map +1 -0
  35. package/dist/chunk-DDEQFR3M.cjs.map +1 -1
  36. package/dist/chunk-ENT2OSXT.mjs +2 -0
  37. package/dist/chunk-ENT2OSXT.mjs.map +1 -0
  38. package/dist/{chunk-74QD4JAH.mjs → chunk-GXV2JA36.mjs} +2 -2
  39. package/dist/chunk-GXV2JA36.mjs.map +1 -0
  40. package/dist/chunk-H6ZO4SLB.mjs +4 -0
  41. package/dist/chunk-H6ZO4SLB.mjs.map +1 -0
  42. package/dist/chunk-JDDRTHFG.mjs +2 -0
  43. package/dist/chunk-JDDRTHFG.mjs.map +1 -0
  44. package/dist/{chunk-T5FSQ3YE.mjs → chunk-JDZGYU5T.mjs} +2 -2
  45. package/dist/{chunk-T5FSQ3YE.mjs.map → chunk-JDZGYU5T.mjs.map} +1 -1
  46. package/dist/chunk-JIPSTWKO.mjs +2 -0
  47. package/dist/{chunk-KI66MQ43.mjs.map → chunk-JIPSTWKO.mjs.map} +1 -1
  48. package/dist/chunk-JSTCUTXP.cjs +2 -0
  49. package/dist/chunk-JSTCUTXP.cjs.map +1 -0
  50. package/dist/{chunk-MJZHJFZO.mjs → chunk-JXM5S4IU.mjs} +2 -2
  51. package/dist/chunk-K5L2B4DU.mjs +2 -0
  52. package/dist/{chunk-EFG3OYYQ.mjs.map → chunk-K5L2B4DU.mjs.map} +1 -1
  53. package/dist/chunk-KUQEX7H3.mjs +2 -0
  54. package/dist/chunk-KUQEX7H3.mjs.map +1 -0
  55. package/dist/chunk-NXXMW2O7.mjs +2 -0
  56. package/dist/chunk-NXXMW2O7.mjs.map +1 -0
  57. package/dist/chunk-OIYXOKTT.cjs.map +1 -1
  58. package/dist/chunk-OUD27MU7.cjs.map +1 -1
  59. package/dist/chunk-PRLVZIKD.mjs +2 -0
  60. package/dist/chunk-PRLVZIKD.mjs.map +1 -0
  61. package/dist/chunk-QVIAMSZ6.cjs +2 -0
  62. package/dist/chunk-QVIAMSZ6.cjs.map +1 -0
  63. package/dist/chunk-RCWM55DE.cjs +2 -0
  64. package/dist/chunk-RCWM55DE.cjs.map +1 -0
  65. package/dist/chunk-REWME3FY.cjs +2 -0
  66. package/dist/chunk-REWME3FY.cjs.map +1 -0
  67. package/dist/chunk-RJN36GBU.mjs +2 -0
  68. package/dist/chunk-RJN36GBU.mjs.map +1 -0
  69. package/dist/chunk-RWOICHRW.cjs.map +1 -1
  70. package/dist/chunk-S4CDSVLK.cjs +2 -0
  71. package/dist/chunk-S4CDSVLK.cjs.map +1 -0
  72. package/dist/chunk-WLJHFHKF.mjs +2 -0
  73. package/dist/chunk-WLJHFHKF.mjs.map +1 -0
  74. package/dist/chunk-WRFDB3QJ.cjs.map +1 -1
  75. package/dist/chunk-XNJLSA6P.cjs.map +1 -1
  76. package/dist/chunk-XZC34BHM.cjs +2 -0
  77. package/dist/chunk-XZC34BHM.cjs.map +1 -0
  78. package/dist/chunk-Y2FETC6T.cjs +2 -0
  79. package/dist/chunk-Y2FETC6T.cjs.map +1 -0
  80. package/dist/chunk-ZW2N63FI.mjs +2 -0
  81. package/dist/chunk-ZW2N63FI.mjs.map +1 -0
  82. package/dist/contexts/exports.cjs +1 -1
  83. package/dist/contexts/exports.cjs.map +1 -1
  84. package/dist/contexts/exports.mjs +1 -1
  85. package/dist/contexts/exports.mjs.map +1 -1
  86. package/dist/enum/exports.cjs +1 -1
  87. package/dist/enum/exports.cjs.map +1 -1
  88. package/dist/enum/exports.d.cts +1 -1
  89. package/dist/enum/exports.d.ts +1 -1
  90. package/dist/enum/exports.mjs +1 -1
  91. package/dist/enum/exports.mjs.map +1 -1
  92. package/dist/enum/governance/exports.cjs +2 -0
  93. package/dist/enum/governance/exports.cjs.map +1 -0
  94. package/dist/enum/governance/exports.d.cts +60 -0
  95. package/dist/enum/governance/exports.d.ts +60 -0
  96. package/dist/enum/governance/exports.mjs +2 -0
  97. package/dist/enum/governance/exports.mjs.map +1 -0
  98. package/dist/errors/exports.cjs +1 -1
  99. package/dist/errors/exports.cjs.map +1 -1
  100. package/dist/errors/exports.d.cts +3 -89
  101. package/dist/errors/exports.d.ts +3 -89
  102. package/dist/errors/exports.mjs +1 -1
  103. package/dist/{getValidatorQueuedOperatorAddress-BQXkSFd9.d.cts → getValidatorQueuedOperatorAddress-CPuIw7n5.d.cts} +2 -2
  104. package/dist/{getValidatorQueuedOperatorAddress-DUZOmxLV.d.ts → getValidatorQueuedOperatorAddress-CbZQ0kv2.d.ts} +2 -2
  105. package/dist/{global.d-6aSWIkV_.d.cts → global.d-B9nLZ7ul.d.cts} +3 -239
  106. package/dist/{global.d-SU9Epq0M.d.ts → global.d-ylUk_etZ.d.ts} +3 -239
  107. package/dist/hooks/exports.cjs +3 -3
  108. package/dist/hooks/exports.cjs.map +1 -1
  109. package/dist/hooks/exports.d.cts +19 -198
  110. package/dist/hooks/exports.d.ts +19 -198
  111. package/dist/hooks/exports.mjs +3 -3
  112. package/dist/hooks/exports.mjs.map +1 -1
  113. package/dist/hooks/governance/exports.cjs +2 -0
  114. package/dist/hooks/governance/exports.cjs.map +1 -0
  115. package/dist/hooks/governance/exports.d.cts +181 -0
  116. package/dist/hooks/governance/exports.d.ts +181 -0
  117. package/dist/hooks/governance/exports.mjs +2 -0
  118. package/dist/hooks/governance/exports.mjs.map +1 -0
  119. package/dist/pol.d-o6Iw75bK.d.cts +134 -0
  120. package/dist/pol.d-qR8bGEP5.d.ts +134 -0
  121. package/dist/{txnEnum-CCuQUFlh.d.cts → txnEnum-CwAJN4zV.d.cts} +3 -60
  122. package/dist/{txnEnum-CCuQUFlh.d.ts → txnEnum-CwAJN4zV.d.ts} +3 -60
  123. package/dist/types/exports.cjs.map +1 -1
  124. package/dist/types/exports.d.cts +7 -7
  125. package/dist/types/exports.d.ts +7 -7
  126. package/dist/types/governance/exports.cjs +1 -0
  127. package/dist/types/governance/exports.cjs.map +1 -0
  128. package/dist/types/governance/exports.d.cts +109 -0
  129. package/dist/types/governance/exports.d.ts +109 -0
  130. package/dist/types/governance/exports.mjs +1 -0
  131. package/dist/types/governance/exports.mjs.map +1 -0
  132. package/dist/utils/exports.cjs +1 -1
  133. package/dist/utils/exports.cjs.map +1 -1
  134. package/dist/utils/exports.d.cts +10 -2
  135. package/dist/utils/exports.d.ts +10 -2
  136. package/dist/utils/exports.mjs +1 -1
  137. package/dist/utils/exports.mjs.map +1 -1
  138. package/package.json +49 -8
  139. package/src/actions/clients/BeraApolloClient.ts +9 -0
  140. package/src/actions/clients/getApolloClient.ts +23 -6
  141. package/src/actions/dex/getOnChainPool.ts +1 -1
  142. package/src/actions/enso/getBendMultiplyBundle.ts +9 -2
  143. package/src/actions/enso/util.ts +6 -8
  144. package/src/actions/exports.ts +1 -10
  145. package/src/actions/governance/checkProposalField.ts +108 -54
  146. package/src/actions/governance/computeActualStatus.ts +7 -3
  147. package/src/actions/governance/exports.ts +9 -0
  148. package/src/actions/governance/getAllProposals.ts +15 -8
  149. package/src/actions/governance/getBodyErrors.ts +13 -5
  150. package/src/actions/governance/getDecodedFunctionData.ts +31 -22
  151. package/src/actions/governance/getProposalDetails.ts +8 -4
  152. package/src/actions/governance/getProposalFromTx.ts +19 -10
  153. package/src/actions/governance/getProposalParams.ts +17 -17
  154. package/src/actions/governance/getProposalVotes.ts +7 -3
  155. package/src/actions/governance/getQuorum.ts +7 -7
  156. package/src/actions/governance/parseProposalBody.ts +19 -9
  157. package/src/actions/honey/getChartData.ts +5 -5
  158. package/src/actions/honey/getHoney24hVolume.ts +30 -0
  159. package/src/actions/honey/getHoneyPythPriceOracle.ts +1 -1
  160. package/src/actions/honey/getHoneyRootPriceOracle.ts +1 -1
  161. package/src/actions/pol/getEarnedStakedBeraVault.ts +12 -2
  162. package/src/actions/pol/getRewardVaultBeaconImplementation.ts +1 -1
  163. package/src/actions/pol/getRewardVaultIncentives.ts +2 -2
  164. package/src/actions/pol/getStakingDailyAssets.ts +7 -1
  165. package/src/actions/pol/getTotalStakedAmount.ts +1 -1
  166. package/src/actions/pol/getUserClaimableIncentives.ts +1 -1
  167. package/src/actions/pol/getUserVaultsReward.ts +1 -1
  168. package/src/actions/tokens/getTokenInformation.ts +8 -15
  169. package/src/actions/tokens/getUnderlyingToken.ts +1 -1
  170. package/src/actions/validators/getUserBoosts.ts +1 -1
  171. package/src/enum/exports.ts +0 -1
  172. package/src/enum/governance/exports.ts +1 -0
  173. package/src/enum/txnEnum.ts +2 -0
  174. package/src/errors/BeraError.ts +7 -2
  175. package/src/errors/RequestError.ts +2 -1
  176. package/src/hooks/dex/usePoolHistoricalData.ts +1 -1
  177. package/src/hooks/enso/useBendZapSupply.ts +1 -1
  178. package/src/hooks/exports.ts +1 -15
  179. package/src/hooks/governance/exports.ts +14 -0
  180. package/src/hooks/honey/useHoney24hVolume.ts +16 -0
  181. package/src/hooks/perps/usePythUpdateFee.ts +1 -1
  182. package/src/hooks/validators/useValidatorRewardAllocation.ts +1 -1
  183. package/src/types/exports.ts +0 -1
  184. package/src/types/governance/exports.ts +1 -0
  185. package/src/utils/beraFetch.ts +70 -15
  186. package/src/utils/getErrorResponse.ts +1 -1
  187. package/dist/RequestError-A8XJ6QR9.d.cts +0 -57
  188. package/dist/RequestError-Dk97z8rm.d.ts +0 -57
  189. package/dist/chunk-2EN6PPAW.cjs +0 -2
  190. package/dist/chunk-2EN6PPAW.cjs.map +0 -1
  191. package/dist/chunk-2YBHAMDV.cjs +0 -2
  192. package/dist/chunk-2YBHAMDV.cjs.map +0 -1
  193. package/dist/chunk-57RINXU6.cjs +0 -2
  194. package/dist/chunk-57RINXU6.cjs.map +0 -1
  195. package/dist/chunk-74QD4JAH.mjs.map +0 -1
  196. package/dist/chunk-74WA35RI.cjs +0 -2
  197. package/dist/chunk-74WA35RI.cjs.map +0 -1
  198. package/dist/chunk-7ITWLMO7.cjs +0 -4
  199. package/dist/chunk-7ITWLMO7.cjs.map +0 -1
  200. package/dist/chunk-BEKH5EYT.mjs +0 -2
  201. package/dist/chunk-BEKH5EYT.mjs.map +0 -1
  202. package/dist/chunk-DK42F2ZM.cjs +0 -2
  203. package/dist/chunk-DK42F2ZM.cjs.map +0 -1
  204. package/dist/chunk-EFG3OYYQ.mjs +0 -2
  205. package/dist/chunk-GO5E7UUD.cjs +0 -2
  206. package/dist/chunk-GO5E7UUD.cjs.map +0 -1
  207. package/dist/chunk-I7M43BB4.cjs.map +0 -1
  208. package/dist/chunk-IDFMLLDY.mjs +0 -2
  209. package/dist/chunk-IDFMLLDY.mjs.map +0 -1
  210. package/dist/chunk-JE5GI2OC.mjs +0 -4
  211. package/dist/chunk-JE5GI2OC.mjs.map +0 -1
  212. package/dist/chunk-KI66MQ43.mjs +0 -2
  213. package/dist/chunk-NMH7LHPW.cjs.map +0 -1
  214. package/dist/chunk-NVHV2LDK.cjs +0 -2
  215. package/dist/chunk-NVHV2LDK.cjs.map +0 -1
  216. package/dist/chunk-PLIH6KQM.mjs +0 -2
  217. package/dist/chunk-PLIH6KQM.mjs.map +0 -1
  218. package/dist/chunk-QRAIGQF2.mjs +0 -2
  219. package/dist/chunk-QRAIGQF2.mjs.map +0 -1
  220. package/src/actions/honey/getHoneyGlobalData.ts +0 -21
  221. package/src/hooks/honey/useHoneyGlobalData.ts +0 -23
  222. /package/dist/{chunk-MJZHJFZO.mjs.map → chunk-JXM5S4IU.mjs.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/hooks/governance/useCreateProposal.ts","../../../src/actions/governance/getProposalParams.ts","../../../src/utils/hasAnyTruthyValues.ts","../../../src/hooks/governance/useGetPastVotes.ts","../../../src/hooks/governance/useProposalSnapshot.ts","../../../src/hooks/governance/useHasVoted.ts","../../../src/hooks/governance/useIsCanceller.ts","../../../src/actions/governance/constants.ts","../../../src/hooks/governance/usePollAllProposals.ts","../../../src/hooks/governance/usePollProposal.ts","../../../src/hooks/governance/usePollProposalThreshold.ts","../../../src/hooks/governance/usePollProposalVotes.ts","../../../src/hooks/governance/usePollUserDelegates.ts","../../../src/hooks/governance/useProposalFromTx.ts","../../../src/hooks/governance/useProposalState.ts","../../../src/hooks/governance/useProposalTimelockState.ts","../../../src/hooks/governance/useQuorum.ts","../../../src/actions/governance/getQuorum.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useState } from \"react\";\n\nimport { getProposalParams } from \"../../actions/governance/getProposalParams\";\nimport { ProposalTypeEnum } from \"../../enum/governance\";\nimport type {\n CustomProposal,\n CustomProposalErrors,\n GovernanceTopic,\n PROPOSAL_GENRE,\n SafeProposalAction,\n} from \"../../types/governance\";\n\nconst defaultAction = {\n type: ProposalTypeEnum.CUSTOM_PROPOSAL,\n target: \"\",\n ABI: \"\",\n value: 0n,\n functionSignature: \"\",\n args: [],\n input: \"ABI\",\n rawCalldata: \"0x\",\n message: \"\",\n} satisfies SafeProposalAction;\n\nexport const useCreateProposal = ({\n initialData = {},\n currentTopic,\n onError,\n}: {\n initialData?: any;\n currentTopic: GovernanceTopic;\n onError: (e: CustomProposalErrors) => void;\n}) => {\n const [proposal, setProposal] = useState<CustomProposal>({\n title: \"\",\n description: \"\",\n forumLink: \"\",\n actions: [defaultAction],\n ...initialData,\n topic: new Set(),\n });\n\n useEffect(() => {\n setProposal((p) => ({\n ...p,\n topic: new Set<PROPOSAL_GENRE>([currentTopic.id]),\n }));\n }, [currentTopic]);\n\n const addProposalAction = useCallback(() => {\n setProposal((p) => ({ ...p, actions: [...p.actions, defaultAction] }));\n }, []);\n\n const removeProposalAction = useCallback(\n (idx: number) => {\n setProposal((p) => {\n const actions = [...p.actions];\n actions.splice(idx, 1);\n return { ...p, actions };\n });\n },\n [setProposal],\n );\n\n const computeParamsAndErrors = useCallback(() => {\n if (!proposal) {\n return;\n }\n\n const computedParams = getProposalParams({\n proposal,\n currentTopic,\n onError,\n });\n\n return computedParams;\n }, [proposal, currentTopic]);\n\n return {\n proposal,\n setProposal,\n addProposalAction,\n removeProposalAction,\n computeParamsAndErrors,\n };\n};\n","import matter from \"gray-matter\";\nimport {\n type Address,\n encodeFunctionData,\n erc20Abi,\n parseAbiItem,\n toHex,\n} from \"viem\";\n\nimport { beraChefAbi } from \"@berachain/abis/pol/rewards/beraChef\";\nimport { rewardVaultAbi } from \"@berachain/abis/pol/rewards/rewardVault\";\n\nimport { ProposalErrorCodes, ProposalTypeEnum } from \"../../enum/governance\";\nimport type {\n CustomProposal,\n CustomProposalActionErrors,\n CustomProposalErrors,\n GovernanceTopic,\n} from \"../../types/governance\";\nimport { hasAnyTruthyValues } from \"../../utils/hasAnyTruthyValues\";\nimport { checkProposalField } from \"./checkProposalField\";\nimport { getBodyErrors } from \"./getBodyErrors\";\n\nexport interface GetProposalParamsArgs {\n /** The proposal to encode and validate */\n proposal: CustomProposal;\n /** The current governance topic */\n currentTopic: GovernanceTopic;\n /** Called with validation errors if the proposal is invalid */\n onError?: (e: CustomProposalErrors) => void;\n}\n\n/**\n * Validates a governance proposal and encodes its on-chain call parameters.\n * Returns the encoded targets, values, calldatas, and description, or `undefined` if validation fails.\n */\nexport function getProposalParams({\n proposal,\n currentTopic,\n onError,\n}: GetProposalParamsArgs) {\n const e: CustomProposalErrors = getBodyErrors({ proposal, currentTopic });\n\n const actions: Address[] = [];\n\n e.actions = proposal.actions.map((action, idx) => {\n const errors: CustomProposalActionErrors = {};\n errors.target = checkProposalField({\n fieldOrType: \"address\",\n value: action.target,\n });\n\n if (action.type === ProposalTypeEnum.CUSTOM_PROPOSAL) {\n if (action.input === \"ABI\") {\n errors.ABI = checkProposalField({\n fieldOrType: \"abi\",\n value: action.ABI,\n });\n if (!action.functionSignature) {\n errors.functionSignature = ProposalErrorCodes.REQUIRED;\n } else {\n try {\n const parsedSignatureAbi = parseAbiItem(action.functionSignature);\n if (parsedSignatureAbi.type !== \"function\") {\n console.error(\n \"parsedSignatureAbi is not a function\",\n parsedSignatureAbi,\n );\n\n errors.functionSignature = ProposalErrorCodes.INVALID_ABI;\n } else {\n errors.args = parsedSignatureAbi.inputs.map((input, index) => {\n try {\n if (\"components\" in input) {\n return checkProposalField({\n // @ts-expect-error this is not typed, will throw if not valid\n fieldOrType: input.type,\n value: action.args?.[index],\n components: input.components,\n });\n }\n\n return checkProposalField({\n // @ts-expect-error this is not typed, will throw if not valid\n fieldOrType: input.type,\n value: action.args?.[index],\n });\n } catch {\n return null;\n }\n });\n\n if (!errors.args.some((v) => v)) {\n actions[idx] = encodeFunctionData({\n abi: [parsedSignatureAbi],\n args: action.args,\n });\n }\n }\n } catch {\n errors.functionSignature = ProposalErrorCodes.INVALID_ABI;\n }\n }\n } else if (action.input === \"rawCalldata\") {\n errors.rawCalldata = checkProposalField({\n fieldOrType: \"hex\",\n value: action.rawCalldata,\n });\n actions[idx] = action.rawCalldata!;\n } else if (action.input === \"message\") {\n errors.message = checkProposalField({\n fieldOrType: \"string\",\n value: action.message,\n });\n actions[idx] = toHex(action.message!);\n } else {\n throw new Error(\"Invalid input type\");\n }\n } else if (\n action.type === ProposalTypeEnum.WHITELIST_REWARD_VAULT ||\n action.type === ProposalTypeEnum.BLACKLIST_REWARD_VAULT\n ) {\n errors.vault = checkProposalField({\n fieldOrType: \"address\",\n value: action.vault,\n });\n\n if (!errors.vault) {\n const whiteList =\n action.type === ProposalTypeEnum.WHITELIST_REWARD_VAULT;\n\n actions[idx] = encodeFunctionData({\n abi: beraChefAbi,\n functionName: \"setVaultWhitelistedStatus\",\n args: [action.vault!, whiteList, \"\"],\n });\n }\n } else if (\n action.type === ProposalTypeEnum.WHITELIST_REWARD_VAULT_INCENTIVE\n ) {\n errors.token = checkProposalField({\n fieldOrType: \"address\",\n value: action.token,\n });\n\n errors.minIncentiveRate = checkProposalField({\n fieldOrType: \"uint256\",\n value: action.minIncentiveRate,\n });\n\n errors.managerAddress = checkProposalField({\n fieldOrType: \"address\",\n value: action.managerAddress,\n });\n\n if (!errors.token && !errors.minIncentiveRate && !errors.managerAddress) {\n actions[idx] = encodeFunctionData({\n abi: rewardVaultAbi,\n functionName: \"whitelistIncentiveToken\",\n args: [\n action.token!,\n BigInt(action.minIncentiveRate!),\n action.managerAddress!,\n ],\n });\n }\n } else if (action.type === ProposalTypeEnum.ERC20_TRANSFER) {\n errors.amount = checkProposalField({\n fieldOrType: \"uint256\",\n value: action.amount,\n });\n errors.to = checkProposalField({\n fieldOrType: \"address\",\n value: action.to,\n });\n if (!errors.amount && !errors.to) {\n actions[idx] = encodeFunctionData({\n abi: erc20Abi,\n functionName: \"transfer\",\n args: [action.to!, BigInt(action.amount!)],\n });\n }\n }\n\n const hasErrors = hasAnyTruthyValues(errors);\n\n if (!hasErrors) {\n return null;\n }\n\n return errors;\n });\n\n onError?.(e);\n\n if (\n Object.getOwnPropertyNames(e)\n .map((name) => e[name as keyof typeof e])\n .some((v) => {\n if (Array.isArray(v)) {\n return v.filter((v) => v).length > 0;\n }\n\n if (v === null) {\n return false;\n }\n\n return !!v;\n })\n ) {\n console.warn(\"Proposal has errors\", e);\n return;\n }\n\n if (actions.length === 0) {\n throw new Error(\"No actions submitted in proposal\");\n }\n\n const link = new URL(proposal.forumLink);\n\n const description = matter.stringify(proposal.description, {\n title: proposal.title,\n topics: Array.from(proposal.topic.values()),\n forumLink: link.toString(),\n version: \"1.0.0\",\n \"content-encoding\": \"utf-8\",\n \"content-type\": \"text/markdown\",\n actions: proposal.actions.map((action) => {\n const actionMetadata: Record<string, string> = {\n type: action.type,\n };\n\n if (action.type === ProposalTypeEnum.CUSTOM_PROPOSAL) {\n actionMetadata.inputType = action.input!;\n }\n\n return actionMetadata;\n }),\n });\n\n return [\n proposal.actions.map((action) => action.target as `0x${string}`),\n proposal.actions.map((action) => action.value ?? 0n),\n actions,\n description,\n ] as const;\n}\n","export function hasAnyTruthyValues<T extends Record<string, any>>(\n obj: T,\n): boolean {\n return Object.values(obj).some((value) => {\n if (Array.isArray(value)) {\n return value.some((item) =>\n typeof item === \"object\" && item !== null\n ? hasAnyTruthyValues(item)\n : !!item,\n );\n }\n if (typeof value === \"object\" && value !== null) {\n return hasAnyTruthyValues(value);\n }\n return !!value;\n });\n}\n","import useSWRImmutable from \"swr/immutable\";\nimport { type Address, formatUnits } from \"viem\";\n\nimport { bgtAbi } from \"@berachain/abis/pol/bgt\";\n\nimport { useBeraWallet, usePublicClient } from \"@berachain/wagmi/hooks\";\n\nimport { assertPublicClient } from \"../../errors/assert\";\nimport { parseBaseArgs } from \"../../utils/parseBaseArgs\";\nimport { useProposalSnapshot } from \"./useProposalSnapshot\";\n\n/**\n * Returns the amount of voting power that a wallet had when the voting period began.\n * {@link https://docs.openzeppelin.com/contracts/5.x/api/governance#Votes-getPastVotes-address-uint256-}\n */\nexport const useGetPastVotes = (\n args: {\n wallet?: Address;\n } & (\n | {\n proposalId?: bigint;\n timepoint: number | bigint;\n }\n | {\n proposalId: bigint;\n timepoint?: number | bigint;\n }\n ),\n) => {\n const { address: account } = useBeraWallet();\n const publicClient = usePublicClient();\n\n const wallet = args.wallet || account;\n\n const { data: snapshot } = useProposalSnapshot({\n proposalId: args.proposalId,\n });\n\n const ts = args.timepoint || snapshot;\n\n const QUERY_KEY =\n ts && publicClient && wallet\n ? ([\"useGetPastVotes\", ts, wallet] as const)\n : null;\n\n return useSWRImmutable(QUERY_KEY, async ([, ts, wallet]) => {\n assertPublicClient(publicClient);\n const { config } = parseBaseArgs({\n chainId: publicClient.chain.id,\n });\n if (Number(ts) > Date.now() / 1000) {\n throw new Error(\"timepoint is in the future\");\n }\n\n const votes = await publicClient.readContract({\n abi: bgtAbi,\n address: config.tokens.bgt,\n functionName: \"getPastVotes\",\n args: [wallet, BigInt(ts)],\n });\n\n return formatUnits(votes, 18);\n });\n};\n","import type { SWRResponse } from \"swr\";\nimport useSWRImmutable from \"swr/immutable\";\n\nimport { berachainGovernanceAbi as governanceAbi } from \"@berachain/abis/gov/berachainGovernance\";\n\nimport { usePublicClient } from \"@berachain/wagmi/hooks\";\n\nimport { assertPublicClient } from \"../../errors/assert\";\nimport { parseBaseArgs } from \"../../utils/parseBaseArgs\";\n\n/**\n * Timepoint used to retrieve user’s votes and quorum. If using block\n * number (as per Compound’s Comp), the snapshot is performed at\n * the end of this block. Hence, voting for this proposal starts at the beginning of the following block.\n *\n * {@link https://docs.openzeppelin.com/contracts/5.x/api/governance#IGovernor-proposalSnapshot-uint256-}\n */\nexport const useProposalSnapshot = ({\n proposalId,\n}: {\n proposalId: number | bigint | string | undefined;\n}): SWRResponse<string> => {\n const publicClient = usePublicClient();\n\n const QUERY_KEY =\n publicClient && proposalId\n ? ([\"useProposalSnapshot\", proposalId] as const)\n : null;\n\n return useSWRImmutable(QUERY_KEY, async ([, proposalId]) => {\n assertPublicClient(publicClient);\n\n const { config } = parseBaseArgs({\n chainId: publicClient.chain.id,\n });\n const snapshot = await publicClient.readContract({\n abi: governanceAbi,\n address: config.governance.governor,\n functionName: \"proposalSnapshot\",\n args: [BigInt(proposalId)],\n });\n\n return snapshot.toString();\n });\n};\n","import useSWR from \"swr\";\nimport { type Address, isAddress } from \"viem\";\n\nimport { berachainGovernanceAbi as governanceAbi } from \"@berachain/abis/gov/berachainGovernance\";\n\nimport { useBeraWallet, usePublicClient } from \"@berachain/wagmi/hooks\";\n\nimport { assertPublicClient } from \"../../errors/assert\";\nimport { parseBaseArgs } from \"../../utils/parseBaseArgs\";\n\nexport const useHasVoted = ({\n proposalId,\n wallet,\n}: {\n proposalId: string;\n wallet?: Address;\n}) => {\n const { address: account } = useBeraWallet();\n const publicClient = usePublicClient();\n\n const address = wallet || account;\n return useSWR(\n publicClient && address && isAddress(address)\n ? ([\"useHasVoted\", proposalId, address] as const)\n : null,\n ([, proposalId, address]) => {\n assertPublicClient(publicClient);\n const { config } = parseBaseArgs({\n chainId: publicClient.chain.id,\n });\n return publicClient.readContract({\n address: config.governance.governor,\n abi: governanceAbi,\n functionName: \"hasVoted\",\n args: [BigInt(proposalId), address],\n });\n },\n );\n};\n","import useSWR from \"swr\";\nimport type { Address } from \"viem\";\n\nimport { timeLockAbi as governanceTimelockAbi } from \"@berachain/abis/gov/timeLock\";\n\nimport { usePublicClient } from \"@berachain/wagmi/hooks\";\n\nimport { CANCELLER_ROLE } from \"../../actions/governance/constants\";\nimport { POLLING } from \"../../enum/polling\";\nimport { assertPublicClient } from \"../../errors/assert\";\nimport { parseBaseArgs } from \"../../utils/parseBaseArgs\";\n\nexport const useIsCanceller = ({\n account,\n ...baseArgs\n}: {\n account: Address | undefined;\n} & BeraJS.BaseFunctionArgs) => {\n const publicClient = usePublicClient();\n const { config: chainConfig } = parseBaseArgs(baseArgs);\n\n const QUERY_KEY =\n account && publicClient ? ([\"useCancellerRole\", account] as const) : null;\n\n return useSWR(\n QUERY_KEY,\n async ([, account]) => {\n assertPublicClient(publicClient);\n\n const canceller = await publicClient.readContract({\n abi: governanceTimelockAbi,\n address: chainConfig.governance.timelock,\n functionName: \"hasRole\",\n args: [CANCELLER_ROLE, account],\n });\n\n return canceller;\n },\n {\n refreshInterval: POLLING.SLOW,\n revalidateOnFocus: false,\n },\n );\n};\n","/**\n * keccak256(\"CANCELLER_ROLE\")\n *\n * @see https://beratrail.io/address/0xD4e9dD9bb5acC31B550b618701c836fAEF6E0eE1/contract/80094/readContract#F1\n */\nexport const CANCELLER_ROLE =\n \"0xfd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783\";\n","import { useEffect, useMemo, useState } from \"react\";\nimport useSWRInfinite, { type SWRInfiniteResponse } from \"swr/infinite\";\n\nimport {\n type OrderDirection,\n type Proposal_Filter,\n Proposal_OrderBy,\n type ProposalSelectionFragment,\n ProposalStatus,\n} from \"@berachain/graphql/governance\";\n\nimport { getAllProposals } from \"../../actions/governance/getAllProposals\";\nimport { POLLING } from \"../../enum/polling\";\nimport type { DefaultHookOptions } from \"../../types/global\";\n\nconst DEFAULT_PER_PAGE = 10;\n\nconst fromUiStatusToSubgraphStatuses = (\n status: ProposalStatus,\n): ProposalStatus[] => {\n switch (status) {\n case ProposalStatus.QuorumNotReached:\n return [ProposalStatus.Active, ProposalStatus.Pending];\n case ProposalStatus.PendingQueue:\n case ProposalStatus.Defeated:\n return [ProposalStatus.Active];\n case ProposalStatus.PendingExecution:\n return [ProposalStatus.InQueue];\n default:\n return [status];\n }\n};\n\ntype UsePollAllProposalsArgs = {\n topic: string;\n where?: Proposal_Filter;\n perPage?: number;\n orderBy?: Proposal_OrderBy;\n orderDirection?: OrderDirection;\n status_in?: ProposalStatus[];\n text?: string;\n autoRefreshProposals?: boolean;\n};\n\ntype ProposalResult = {\n data: ProposalSelectionFragment[][];\n hasMore: boolean;\n} & Omit<SWRInfiniteResponse<ProposalSelectionFragment[]>, \"data\">;\n\ntype PollAllProposalsKey =\n | [\n \"usePollAllProposals\",\n number,\n string,\n Proposal_Filter | undefined,\n ProposalStatus[] | undefined,\n Proposal_OrderBy | undefined,\n OrderDirection | undefined,\n number,\n string | undefined,\n ]\n | null;\n\nexport function usePollAllProposalsQueryKey(\n topic: string,\n args: Partial<UsePollAllProposalsArgs> = {},\n): (\n pageIndex: number,\n previousPageData?: ProposalSelectionFragment[],\n) => PollAllProposalsKey {\n const subgraphPageSize = 2 * (args.perPage ?? DEFAULT_PER_PAGE);\n\n return (pageIndex, previousPageData) => {\n if (\n pageIndex !== 0 &&\n previousPageData &&\n previousPageData.length < subgraphPageSize\n ) {\n return null;\n }\n\n const statuses = args.status_in\n ?.flatMap(fromUiStatusToSubgraphStatuses)\n .filter((s, i, arr) => arr.indexOf(s) === i);\n\n return [\n \"usePollAllProposals\",\n pageIndex,\n topic,\n args.where,\n statuses,\n args.orderBy,\n args.orderDirection,\n subgraphPageSize,\n args.text,\n ];\n };\n}\n\n/**\n * Fetch all proposals for a given topic\n */\nexport function usePollAllProposals(\n args: UsePollAllProposalsArgs,\n options?: DefaultHookOptions & { autoRefresh?: boolean },\n): ProposalResult {\n const autoRefreshProposals = options?.autoRefresh ?? false;\n\n const perPage = args.perPage ?? DEFAULT_PER_PAGE;\n const subgraphPageSize = 2 * perPage;\n\n const getKey = usePollAllProposalsQueryKey(args.topic, args);\n\n async function fetcher(key: PollAllProposalsKey) {\n if (!key) return [];\n const [\n ,\n pageIndex,\n topic,\n where,\n statuses,\n orderBy,\n orderDirection,\n pageSize,\n text,\n ] = key;\n\n const proposals = await getAllProposals({\n where: {\n topics_contains: [topic],\n status_in: statuses?.length ? statuses : undefined,\n ...where,\n },\n orderBy,\n orderDirection,\n text,\n perPage: pageSize,\n offset: pageIndex * pageSize,\n });\n\n return (proposals ?? []).filter(Boolean) as ProposalSelectionFragment[];\n }\n\n const swr = useSWRInfinite<ProposalSelectionFragment[], PollAllProposalsKey>(\n getKey,\n fetcher,\n {\n // Increase initialSize in order to prefetch more proposals at a time.\n initialSize: 1,\n refreshInterval: options?.opts?.refreshInterval ?? POLLING.SLOW,\n ...options?.opts,\n },\n );\n\n const data = useMemo(() => {\n if (!swr.data) return [];\n\n const flattened = swr.data\n .flat()\n .filter((p) => {\n if (!p) return false;\n if (!args.status_in?.length) return true;\n return args.status_in.includes(p.status);\n })\n .sort((a, b) => {\n if (!args.text) return 0;\n if (args.orderBy === Proposal_OrderBy.CreatedAt) {\n const result = Number(b.createdAt) - Number(a.createdAt);\n return args.orderDirection === \"asc\" ? result : -result;\n }\n return 0;\n });\n\n const chunked: ProposalSelectionFragment[][] = [];\n for (let i = 0; i < flattened.length; i += perPage) {\n chunked.push(flattened.slice(i, i + perPage));\n }\n return chunked;\n }, [swr.data, args, perPage]);\n\n const lastPage = swr.data?.[swr.data.length - 1];\n const hasMore = !!lastPage && lastPage.length === subgraphPageSize;\n\n const [timestamp, setTimestamp] = useState(Date.now() / 1000);\n\n useEffect(() => {\n if (!autoRefreshProposals) return;\n const interval = setInterval(() => {\n setTimestamp(Date.now() / 1000);\n }, POLLING.FAST);\n\n return () => clearInterval(interval);\n }, [autoRefreshProposals]);\n\n useEffect(() => {\n if (!swr.data) return;\n\n let shouldMutate = false;\n for (const proposal of swr.data.flat()) {\n switch (proposal.status) {\n case ProposalStatus.Pending:\n if (timestamp >= Number(proposal.voteStartAt)) {\n shouldMutate = true;\n }\n break;\n case ProposalStatus.Active:\n if (timestamp >= Number(proposal.voteEndAt)) {\n shouldMutate = true;\n }\n break;\n case ProposalStatus.InQueue:\n if (Date.now() / 1000 + 1 >= Number(proposal.queueEnd)) {\n shouldMutate = true;\n }\n break;\n default:\n break;\n }\n if (shouldMutate) break;\n }\n\n if (shouldMutate) {\n swr.mutate();\n }\n }, [swr.data, timestamp]);\n\n return {\n ...swr,\n data,\n hasMore,\n };\n}\n","import { useEffect, useState } from \"react\";\nimport useSWR from \"swr\";\n\nimport {\n ProposalStatus,\n type ProposalWithVotesFragment,\n} from \"@berachain/graphql/governance\";\nimport { usePublicClient } from \"@berachain/wagmi/hooks\";\n\nimport { getProposalDetails } from \"../../actions/governance/getProposalDetails\";\nimport { POLLING } from \"../../enum/polling\";\nimport { assertPublicClient } from \"../../errors/assert\";\nimport type {\n DefaultHookOptions,\n DefaultHookReturnType,\n} from \"../../types/global\";\n\nexport interface UsePollProposalResponse\n extends DefaultHookReturnType<ProposalWithVotesFragment> {}\n\n/**\n * Polls a proposal and returns the proposal details.\n * Pulls data from the subgraph and onchain.\n *\n * @param proposalId - The ID of the proposal to poll\n * @param options - Optional configuration options\n * @param options.autoRefresh - If true, the data will be refreshed automatically based on the block number and status threshold\n * @returns {UsePollProposalResponse} Object containing:\n * - data: ProposalWithVotesFragment | undefined - The proposal data if successful\n * - error: Error | undefined - Error object if request failed\n * - isLoading: boolean - True while data is being fetched\n * - isValidating: boolean - True while data is being revalidated\n * - mutate: () => Promise<ProposalWithVotesFragment | undefined> - Function to manually refresh the data\n * - refresh: () => Promise<void> - Function to manually refresh the data\n */\nexport const usePollProposal = (\n proposalId: string,\n options?: DefaultHookOptions & { autoRefresh?: boolean },\n): UsePollProposalResponse => {\n const autoRefreshProposal = options?.autoRefresh ?? false;\n const publicClient = usePublicClient();\n\n const QUERY_KEY =\n proposalId && publicClient\n ? ([\"usePollProposal\", proposalId] as const)\n : null;\n\n const swrResponse = useSWR(\n QUERY_KEY,\n ([, proposalId]) => {\n assertPublicClient(publicClient);\n\n return getProposalDetails({ proposalId, client: publicClient });\n },\n {\n ...options?.opts,\n refreshInterval: options?.opts?.refreshInterval ?? POLLING.SLOW,\n },\n );\n\n const [timestamp, setTimestamp] = useState(Date.now());\n\n useEffect(() => {\n if (!autoRefreshProposal) return;\n const interval = setInterval(() => {\n setTimestamp(Date.now() / 1000);\n }, POLLING.FAST);\n\n return () => clearInterval(interval);\n }, []);\n\n useEffect(() => {\n if (swrResponse.data === undefined) return;\n\n switch (swrResponse.data.status) {\n case ProposalStatus.Pending:\n if (timestamp >= Number(swrResponse.data.voteStartAt)) {\n swrResponse.mutate();\n }\n break;\n case ProposalStatus.Active:\n if (timestamp >= Number(swrResponse.data.voteEndAt)) {\n swrResponse.mutate();\n }\n break;\n case ProposalStatus.InQueue:\n if (Date.now() / 1000 + 1 >= Number(swrResponse.data.queueEnd)) {\n swrResponse.mutate();\n }\n break;\n }\n }, [swrResponse.data?.status, timestamp]);\n\n // const votes = swrResponse.data?.votes.nodes ?? [];\n return {\n ...swrResponse,\n refresh: () => swrResponse?.mutate?.(),\n };\n};\n","import useSWR from \"swr\";\nimport { type Address, formatEther } from \"viem\";\n\nimport { berachainGovernanceAbi as governanceAbi } from \"@berachain/abis/gov/berachainGovernance\";\n\nimport { usePublicClient } from \"@berachain/wagmi/hooks\";\n\nimport { POLLING } from \"../../enum/polling\";\nimport { assertPublicClient } from \"../../errors/assert\";\nimport type { DefaultHookReturnType } from \"../../types/global\";\n\nexport const usePollProposalThreshold = (\n governorAddress: Address,\n): DefaultHookReturnType<{ votesThreshold: string }> => {\n const publicClient = usePublicClient();\n\n const QUERY_KEY = publicClient\n ? ([\"usePollProposalThreshold\", governorAddress] as const)\n : null;\n\n const swrResponse = useSWR<{ votesThreshold: string }, any, typeof QUERY_KEY>(\n QUERY_KEY,\n async ([, governorAddress]) => {\n assertPublicClient(publicClient);\n\n const votesThreshold = await publicClient.readContract({\n address: governorAddress,\n abi: governanceAbi,\n functionName: \"proposalThreshold\",\n });\n return { votesThreshold: formatEther(votesThreshold) };\n },\n {\n refreshInterval: POLLING.SLOW,\n },\n );\n\n return {\n ...swrResponse,\n refresh: swrResponse.mutate,\n };\n};\n","import useSWRInfinite, { type SWRInfiniteKeyLoader } from \"swr/infinite\";\n\nimport type { GetProposalVotesQueryVariables } from \"@berachain/graphql/governance\";\n\nimport { getProposalVotes } from \"../../actions/governance/getProposalVotes\";\n\ntype UsePollProposalVotesArgs = Omit<\n GetProposalVotesQueryVariables,\n \"offset\" | \"limit\"\n>;\n\n// const ACTUAL_PER_PAGE = 500;\n\nconst DEFAULT_LIMIT = 1000;\n/**\n * Fetches all the votes for a proposal from the Subgraph\n * @param args - The arguments to pass to the query\n * @param total - The total amount of pages of votes to fetch\n */\nexport const usePollProposalVotes = (\n args: UsePollProposalVotesArgs,\n total: number,\n) => {\n return useSWRInfinite(\n usePollProposalVotesQueryKey(args, total),\n async ([_key, page]: [string, number]) => {\n return getProposalVotes({\n variables: {\n ...args,\n limit: DEFAULT_LIMIT,\n offset: DEFAULT_LIMIT * page,\n },\n });\n },\n {\n parallel: true,\n // Fetches all the data at once, we limit the number of pages by providing a total\n initialSize: Number.POSITIVE_INFINITY,\n },\n );\n};\n\nexport const usePollProposalVotesQueryKey =\n (\n { ...args }: UsePollProposalVotesArgs,\n total: number,\n ): SWRInfiniteKeyLoader =>\n (\n pageIndex: number,\n // previousPageData: Awaited<ReturnType<typeof getProposalVotes>>,\n ) => {\n if (pageIndex > Math.floor(total / DEFAULT_LIMIT)) {\n return null;\n }\n\n return [\n \"usePollProposalVotes\",\n pageIndex,\n DEFAULT_LIMIT,\n args.proposalId,\n args.orderBy,\n args.orderDirection,\n ];\n };\n","import useSWR from \"swr\";\nimport { type Address, formatEther } from \"viem\";\n\nimport { bgtAbi } from \"@berachain/abis/pol/bgt\";\n\nimport { useBeraWallet, usePublicClient } from \"@berachain/wagmi/hooks\";\n\nimport { POLLING } from \"../../enum/polling\";\nimport { assertPublicClient } from \"../../errors/assert\";\nimport type {\n DefaultHookOptions,\n DefaultHookReturnType,\n} from \"../../types/global\";\nimport { parseBaseArgs } from \"../../utils/parseBaseArgs\";\n\nexport const usePollUserDelegates = (\n options?: DefaultHookOptions,\n): DefaultHookReturnType<{\n delegate: Address;\n currentVotes: string | undefined;\n}> => {\n const { address: account } = useBeraWallet();\n const publicClient = usePublicClient();\n const QUERY_KEY = account\n ? ([\"usePollUserDelegates\", account] as const)\n : null;\n\n const swrResponse = useSWR<\n { delegate: Address; currentVotes: string | undefined },\n any,\n typeof QUERY_KEY\n >(\n QUERY_KEY,\n async ([, account]) => {\n assertPublicClient(publicClient);\n const { config } = parseBaseArgs({\n chainId: publicClient.chain.id,\n });\n if (!publicClient || !account) {\n throw new Error(\"usePollUserDelegates needs publicClient and account\");\n }\n\n // use promise all to better catch errors and have type safety\n const [delegate, currentVotes] = await Promise.all([\n publicClient.readContract({\n address: config.tokens.bgt,\n abi: bgtAbi,\n functionName: \"delegates\",\n args: [account],\n }),\n publicClient.readContract({\n address: config.tokens.bgt,\n abi: bgtAbi,\n functionName: \"getVotes\",\n args: [account],\n }),\n ]);\n\n return {\n delegate: delegate,\n currentVotes: formatEther(currentVotes),\n };\n },\n {\n ...options?.opts,\n refreshInterval: options?.opts?.refreshInterval ?? POLLING.SLOW,\n },\n );\n\n return {\n ...swrResponse,\n refresh: () => swrResponse?.mutate?.(),\n };\n};\n","import useSWR, { type SWRResponse } from \"swr\";\nimport type { Address } from \"viem\";\n\nimport type { ProposalWithVotesFragment } from \"@berachain/graphql/governance\";\nimport { usePublicClient, useTransactionReceipt } from \"@berachain/wagmi/hooks\";\n\nimport { getProposalFromTx } from \"../../actions/governance/getProposalFromTx\";\n\nexport const useProposalFromTx = (\n txHash?: Address,\n): SWRResponse<ProposalWithVotesFragment | null> => {\n const { data: tx } = useTransactionReceipt({\n hash: txHash,\n });\n\n const publicClient = usePublicClient();\n\n const QUERY_KEY =\n tx && publicClient ? ([\"useProposalFromTx\", txHash] as const) : null;\n\n const swrResponse = useSWR(QUERY_KEY, async ([, txHash]) => {\n if (!tx) {\n throw new Error(\"Transaction not found\");\n }\n\n // This might happen for some render order issues.\n // Since tx is read by the external scope, it might be outdated.\n // Throwing an error here will cause the hook to re-run with the latest tx object.\n if (tx.transactionHash !== txHash) {\n throw new Error(\"Transaction hash mismatch\");\n }\n\n return getProposalFromTx({ tx, publicClient });\n });\n\n return swrResponse;\n};\n","import type { SWRResponse } from \"swr\";\nimport useSWRImmutable from \"swr/immutable\";\nimport type { Address } from \"viem\";\n\nimport { berachainGovernanceAbi as governanceAbi } from \"@berachain/abis/gov/berachainGovernance\";\n\nimport { usePublicClient } from \"@berachain/wagmi/hooks\";\n\nimport { ProposalState } from \"../../enum/governance\";\nimport { assertPublicClient } from \"../../errors/assert\";\n\nconst ProposalStateMap: Record<ProposalState, string> = {\n [ProposalState.Pending]: \"pending\",\n [ProposalState.Active]: \"active\",\n [ProposalState.Canceled]: \"canceled\",\n [ProposalState.Defeated]: \"defeated\",\n [ProposalState.Succeeded]: \"succeeded\",\n [ProposalState.Queued]: \"queued\",\n [ProposalState.Expired]: \"expired\",\n [ProposalState.Executed]: \"executed\",\n};\n\nexport const useProposalState = ({\n proposalId,\n governorAddress,\n}: {\n proposalId: number | bigint | string | undefined;\n governorAddress: Address;\n}): SWRResponse<string> => {\n const publicClient = usePublicClient();\n\n const QUERY_KEY =\n governorAddress && publicClient && proposalId\n ? ([\"useProposalState\", proposalId] as const)\n : null;\n\n return useSWRImmutable(QUERY_KEY, async ([, proposalId]) => {\n assertPublicClient(publicClient);\n\n const snapshot = (await publicClient.readContract({\n abi: governanceAbi,\n address: governorAddress,\n functionName: \"state\",\n args: [BigInt(proposalId)],\n })) as ProposalState;\n\n return ProposalStateMap[snapshot];\n });\n};\n","import useSWR, { type SWRResponse } from \"swr\";\nimport type { Address } from \"viem\";\n\nimport { timeLockAbi as governanceTimelockAbi } from \"@berachain/abis/gov/timeLock\";\n\nimport { usePublicClient } from \"@berachain/wagmi/hooks\";\n\nimport { POLLING } from \"../../enum/polling\";\nimport { assertPublicClient } from \"../../errors/assert\";\n\nconst TimelockOperationState = {\n 0: \"unset\",\n 1: \"waiting\",\n 2: \"ready\",\n 3: \"done\",\n} as const;\n\n/**\n * Fetches the state of a proposal timelock\n * @returns state of the proposal timelock (unset, waiting, ready, done)\n */\nexport function useProposalTimelockState({\n proposalTimelockId,\n timelockAddress,\n}: {\n proposalTimelockId: Address | undefined;\n timelockAddress: Address;\n}): SWRResponse<\n (typeof TimelockOperationState)[keyof typeof TimelockOperationState]\n> {\n const publicClient = usePublicClient();\n\n const QUERY_KEY =\n timelockAddress && publicClient && proposalTimelockId\n ? ([\n \"useProposalTimelockState\",\n proposalTimelockId,\n timelockAddress,\n ] as const)\n : null;\n\n return useSWR(\n QUERY_KEY,\n async ([, proposalTimelockId, timelockAddress]) => {\n assertPublicClient(publicClient);\n\n const snapshot = await publicClient.readContract({\n abi: governanceTimelockAbi,\n address: timelockAddress,\n functionName: \"getOperationState\",\n args: [proposalTimelockId],\n });\n\n return TimelockOperationState[\n snapshot as keyof typeof TimelockOperationState\n ];\n },\n {\n refreshInterval: POLLING.SLOW,\n },\n );\n}\n","import useSWR from \"swr\";\n\nimport { usePublicClient } from \"@berachain/wagmi/hooks\";\n\nimport { getQuorum } from \"../../actions/governance/getQuorum\";\n\n/**\n * Queries the quorum for a given timestamp.\n *\n * @returns current quorum if timestamp is in the future.\n */\nexport function useQuorum(\n { at }: { at: number | string },\n {\n isEnabled = true,\n }: {\n isEnabled?: boolean;\n },\n) {\n const now = Math.floor(Date.now() / 1000);\n const publicClient = usePublicClient();\n const QUERY_KEY =\n isEnabled && publicClient\n ? ([\n \"useQuorum\",\n // Using Now because we cannot query quorum in the future, so no need to have different query keys.\n Number(at) > now ? \"now\" : at,\n ] as const)\n : null;\n\n const response = useSWR(QUERY_KEY, async ([, at]) => {\n if (at === \"now\") {\n return getQuorum({ publicClient });\n }\n return getQuorum({ at, publicClient });\n });\n\n return {\n ...response,\n data: response.data ? Number(response.data) : undefined,\n };\n}\n","import { formatEther, type PublicClient } from \"viem\";\n\nimport { berachainGovernanceAbi as governanceAbi } from \"@berachain/abis/gov/berachainGovernance\";\n\nimport { assertPublicClient } from \"../../errors/assert\";\nimport { parseBaseArgs } from \"../../utils/parseBaseArgs\";\n\nexport type GetQuorumArgs = BeraJS.BaseFunctionArgs & {\n /** Timestamp in seconds; defaults to now. Returns the current quorum when in the future. */\n at?: number | string;\n publicClient: PublicClient | undefined;\n};\n\n/**\n * Queries the quorum for a given timestamp.\n *\n * @returns current quorum if timestamp is in the future.\n */\nexport async function getQuorum({\n at,\n publicClient,\n ...args\n}: GetQuorumArgs): Promise<string> {\n const { config } = parseBaseArgs(args);\n assertPublicClient(publicClient);\n\n const quorum = await publicClient.readContract({\n address: config.governance.governor,\n abi: governanceAbi,\n functionName: \"quorum\",\n // Needs to be pending or you'll get a ERC5805FutureLookup error when reading current quorum\n // this is because now will always be in the future compared to the latest block\n blockTag: \"pending\",\n args: [BigInt(at ?? Math.floor(Date.now() / 1000))],\n });\n\n return formatEther(quorum);\n}\n"],"mappings":"+UAEA,OAAS,eAAAA,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QCFjD,OAAOC,MAAY,cACnB,OAEE,sBAAAC,EACA,YAAAC,EACA,gBAAAC,EACA,SAAAC,MACK,OAEP,OAAS,eAAAC,MAAmB,uCAC5B,OAAS,kBAAAC,MAAsB,0CCVxB,SAASC,EACdC,EACS,CACT,OAAO,OAAO,OAAOA,CAAG,EAAE,KAAMC,GAC1B,MAAM,QAAQA,CAAK,EACdA,EAAM,KAAMC,GACjB,OAAOA,GAAS,UAAYA,IAAS,KACjCH,EAAmBG,CAAI,EACvB,CAAC,CAACA,CACR,EAEE,OAAOD,GAAU,UAAYA,IAAU,KAClCF,EAAmBE,CAAK,EAE1B,CAAC,CAACA,CACV,CACH,CDoBO,SAASE,EAAkB,CAChC,SAAAC,EACA,aAA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C,OAAqB,0CAgBxD,eAAsBC,EAAU,CAC9B,GAAAC,EACA,aAAAC,EACA,GAAGC,CACL,EAAmC,CACjC,GAAM,CAAE,OAAAC,CAAO,EAAIC,EAAcF,CAAI,EACrCG,EAAmBJ,CAAY,EAE/B,IAAMK,EAAS,MAAML,EAAa,aAAa,CAC7C,QAASE,EAAO,WAAW,SAC3B,IAAKI,GACL,aAAc,SAGd,SAAU,UACV,KAAM,CAAC,OAAOP,GAAM,KAAK,MAAM,KAAK,IAAI,EAAI,GAAI,CAAC,CAAC,CACpD,CAAC,EAED,OAAOQ,GAAYF,CAAM,CAC3B,CD1BO,SAASG,GACd,CAAE,GAAAC,CAAG,EACL,CACE,UAAAC,EAAY,EACd,EAGA,CACA,IAAMC,EAAM,KAAK,MAAM,KAAK,IAAI,EAAI,GAAI,EAClCC,EAAeC,GAAgB,EAC/BC,EACJJ,GAAaE,EACR,CACC,YAEA,OAAOH,CAAE,EAAIE,EAAM,MAAQF,CAC7B,EACA,KAEAM,EAAWC,GAAOF,EAAW,MAAO,CAAC,CAAEL,CAAE,IACzCA,IAAO,MACFQ,EAAU,CAAE,aAAAL,CAAa,CAAC,EAE5BK,EAAU,CAAE,GAAAR,EAAI,aAAAG,CAAa,CAAC,CACtC,EAED,MAAO,CACL,GAAGG,EACH,KAAMA,EAAS,KAAO,OAAOA,EAAS,IAAI,EAAI,MAChD,CACF","names":["useCallback","useEffect","useState","matter","encodeFunctionData","erc20Abi","parseAbiItem","toHex","beraChefAbi","rewardVaultAbi","hasAnyTruthyValues","obj","value","item","getProposalParams","proposal","currentTopic","onError","e","getBodyErrors","actions","action","idx","errors","checkProposalField","parsedSignatureAbi","parseAbiItem","input","index","v","encodeFunctionData","toHex","whiteList","beraChefAbi","rewardVaultAbi","erc20Abi","hasAnyTruthyValues","name","link","description","matter","actionMetadata","defaultAction","useCreateProposal","initialData","currentTopic","onError","proposal","setProposal","useState","useEffect","p","addProposalAction","useCallback","removeProposalAction","idx","actions","computeParamsAndErrors","getProposalParams","useSWRImmutable","formatUnits","bgtAbi","useBeraWallet","usePublicClient","useSWRImmutable","governanceAbi","usePublicClient","useProposalSnapshot","proposalId","publicClient","usePublicClient","useSWRImmutable","assertPublicClient","config","parseBaseArgs","governanceAbi","useGetPastVotes","args","account","useBeraWallet","publicClient","usePublicClient","wallet","snapshot","useProposalSnapshot","ts","useSWRImmutable","assertPublicClient","config","parseBaseArgs","votes","bgtAbi","formatUnits","useSWR","isAddress","governanceAbi","useBeraWallet","usePublicClient","useHasVoted","proposalId","wallet","account","useBeraWallet","publicClient","usePublicClient","address","useSWR","isAddress","assertPublicClient","config","parseBaseArgs","governanceAbi","useSWR","governanceTimelockAbi","usePublicClient","CANCELLER_ROLE","useIsCanceller","account","baseArgs","publicClient","usePublicClient","chainConfig","parseBaseArgs","useSWR","assertPublicClient","governanceTimelockAbi","CANCELLER_ROLE","useEffect","useMemo","useState","useSWRInfinite","Proposal_OrderBy","ProposalStatus","DEFAULT_PER_PAGE","fromUiStatusToSubgraphStatuses","status","ProposalStatus","usePollAllProposalsQueryKey","topic","args","subgraphPageSize","pageIndex","previousPageData","statuses","s","i","arr","usePollAllProposals","options","autoRefreshProposals","perPage","getKey","fetcher","key","where","orderBy","orderDirection","pageSize","text","getAllProposals","swr","useSWRInfinite","data","useMemo","flattened","p","a","b","Proposal_OrderBy","result","chunked","lastPage","hasMore","timestamp","setTimestamp","useState","useEffect","interval","shouldMutate","proposal","useEffect","useState","useSWR","ProposalStatus","usePublicClient","usePollProposal","proposalId","options","autoRefreshProposal","publicClient","usePublicClient","swrResponse","useSWR","assertPublicClient","getProposalDetails","timestamp","setTimestamp","useState","useEffect","interval","ProposalStatus","useSWR","formatEther","governanceAbi","usePublicClient","usePollProposalThreshold","governorAddress","publicClient","usePublicClient","swrResponse","useSWR","assertPublicClient","votesThreshold","governanceAbi","formatEther","useSWRInfinite","DEFAULT_LIMIT","usePollProposalVotes","args","total","useSWRInfinite","usePollProposalVotesQueryKey","_key","page","getProposalVotes","pageIndex","useSWR","formatEther","bgtAbi","useBeraWallet","usePublicClient","usePollUserDelegates","options","account","useBeraWallet","publicClient","usePublicClient","swrResponse","useSWR","assertPublicClient","config","parseBaseArgs","delegate","currentVotes","bgtAbi","formatEther","useSWR","usePublicClient","useTransactionReceipt","useProposalFromTx","txHash","tx","useTransactionReceipt","publicClient","usePublicClient","useSWR","getProposalFromTx","useSWRImmutable","governanceAbi","usePublicClient","ProposalStateMap","useProposalState","proposalId","governorAddress","publicClient","usePublicClient","useSWRImmutable","assertPublicClient","snapshot","governanceAbi","useSWR","governanceTimelockAbi","usePublicClient","TimelockOperationState","useProposalTimelockState","proposalTimelockId","timelockAddress","publicClient","usePublicClient","useSWR","assertPublicClient","snapshot","governanceTimelockAbi","useSWR","usePublicClient","formatEther","governanceAbi","getQuorum","at","publicClient","args","config","parseBaseArgs","assertPublicClient","quorum","governanceAbi","formatEther","useQuorum","at","isEnabled","now","publicClient","usePublicClient","QUERY_KEY","response","useSWR","getQuorum"]}
@@ -0,0 +1,134 @@
1
+ import { a as TokenWithMetadata, b as Token } from './HoneyConfigProvider-DfkjmzEf.cjs';
2
+ import { Address } from 'viem';
3
+ import { ApiValidatorFragment } from '@berachain/graphql/pol/api';
4
+
5
+ interface ProtocolMetadata {
6
+ name: string;
7
+ logoURI: string;
8
+ url: string;
9
+ description: string;
10
+ tags?: string[];
11
+ }
12
+
13
+ /**
14
+ * Configuration for a single staking option.
15
+ * Maps receipt tokens to their accepted input tokens.
16
+ */
17
+ type StakingConfig = {
18
+ /** Unique identifier for this staking config */
19
+ id: string;
20
+ /** The token received when staking (e.g., sWBERA, siBERA) */
21
+ receiptToken: TokenWithMetadata;
22
+ /** Tokens that can be staked to receive the receipt token */
23
+ inputTokens: TokenWithMetadata[];
24
+ };
25
+
26
+ interface BribeBoostReward {
27
+ token: string;
28
+ total_unclaimed: string;
29
+ }
30
+
31
+ interface BribeBoostRewardItem {
32
+ rewards: BribeBoostReward[];
33
+ validator: string;
34
+ }
35
+
36
+ interface BribeBoostRewardProof {
37
+ validator?: string;
38
+ pagination: {
39
+ next: number;
40
+ previous: number;
41
+ record_per_page: number;
42
+ current_page: number;
43
+ total_page: number;
44
+ };
45
+ rewards:
46
+ | {
47
+ id: string;
48
+ dist_id: string;
49
+ token: Address;
50
+ recipient: string;
51
+ amount: string;
52
+ merkle_proof: string[];
53
+ available_at: number;
54
+ }[]
55
+ | null;
56
+ }
57
+
58
+ interface BribeBoostValidatorApr {
59
+ id: string;
60
+ boost_total_bgt: string;
61
+ rewards_total_usd: string;
62
+ daily_rate: string;
63
+ apr: string;
64
+ apy: string;
65
+ tokens: Address[]; // Confirm this type with backend real data
66
+ validator: string;
67
+ start_block: number;
68
+ end_block: number;
69
+ start_timestamp: number;
70
+ end_timestamp: number;
71
+ created_at: string;
72
+ updated_at: string;
73
+ }
74
+
75
+ type IncentiveReward = {
76
+ tokenMetadata: Token | undefined;
77
+ tokenPrice: number;
78
+ tokenValue: number;
79
+ id: string;
80
+ dist_id: string;
81
+ token: string;
82
+ recipient: string;
83
+ formattedAmount: string;
84
+ amount: string;
85
+ merkle_proof: string[];
86
+ available_at: number;
87
+ };
88
+ interface IncentiveRewardChunksWithValidatorData {
89
+ validator: ApiValidatorInListFragment | ApiValidatorFragment | undefined;
90
+ maxTimestamp: number | undefined;
91
+ minTimestamp: number | undefined;
92
+ totalValue: number;
93
+ tokenTotals: {
94
+ chainId: number;
95
+ address: Address;
96
+ amount: number;
97
+ value: number;
98
+ metadata: Token | undefined;
99
+ }[];
100
+ rewards: IncentiveReward[];
101
+ isCurrent: boolean;
102
+ }
103
+
104
+ interface AggregatedTokenTotals {
105
+ address: Address;
106
+ amount: number;
107
+ value: number;
108
+ metadata: Token | undefined;
109
+ chainId: number;
110
+ }
111
+
112
+ type ClaimedIncentives = Record<string, string>;
113
+
114
+ type ClaimedIncentivesLocalState = Record<string, ClaimedIncentives>;
115
+
116
+ interface UserVaultInfo {
117
+ balance: bigint;
118
+ delegatedBalance: bigint;
119
+ withdrawableBalance: bigint;
120
+ rewards: string;
121
+ percentage: string;
122
+ }
123
+
124
+ type StakedBeraAsset = {
125
+ token: TokenWithMetadata;
126
+ apr: number;
127
+ stakedAmount: number;
128
+ stakedAmountUsd: number;
129
+ earnedAmount: number;
130
+ earnedAmountUsd: number;
131
+ isLoadingEarnings?: boolean;
132
+ };
133
+
134
+ export type { AggregatedTokenTotals as A, BribeBoostRewardProof as B, ClaimedIncentives as C, IncentiveReward as I, ProtocolMetadata as P, StakingConfig as S, UserVaultInfo as U, BribeBoostRewardItem as a, StakedBeraAsset as b, BribeBoostReward as c, BribeBoostValidatorApr as d, ClaimedIncentivesLocalState as e, IncentiveRewardChunksWithValidatorData as f };
@@ -0,0 +1,134 @@
1
+ import { a as TokenWithMetadata, b as Token } from './HoneyConfigProvider-DVP_9KZn.js';
2
+ import { Address } from 'viem';
3
+ import { ApiValidatorFragment } from '@berachain/graphql/pol/api';
4
+
5
+ interface ProtocolMetadata {
6
+ name: string;
7
+ logoURI: string;
8
+ url: string;
9
+ description: string;
10
+ tags?: string[];
11
+ }
12
+
13
+ /**
14
+ * Configuration for a single staking option.
15
+ * Maps receipt tokens to their accepted input tokens.
16
+ */
17
+ type StakingConfig = {
18
+ /** Unique identifier for this staking config */
19
+ id: string;
20
+ /** The token received when staking (e.g., sWBERA, siBERA) */
21
+ receiptToken: TokenWithMetadata;
22
+ /** Tokens that can be staked to receive the receipt token */
23
+ inputTokens: TokenWithMetadata[];
24
+ };
25
+
26
+ interface BribeBoostReward {
27
+ token: string;
28
+ total_unclaimed: string;
29
+ }
30
+
31
+ interface BribeBoostRewardItem {
32
+ rewards: BribeBoostReward[];
33
+ validator: string;
34
+ }
35
+
36
+ interface BribeBoostRewardProof {
37
+ validator?: string;
38
+ pagination: {
39
+ next: number;
40
+ previous: number;
41
+ record_per_page: number;
42
+ current_page: number;
43
+ total_page: number;
44
+ };
45
+ rewards:
46
+ | {
47
+ id: string;
48
+ dist_id: string;
49
+ token: Address;
50
+ recipient: string;
51
+ amount: string;
52
+ merkle_proof: string[];
53
+ available_at: number;
54
+ }[]
55
+ | null;
56
+ }
57
+
58
+ interface BribeBoostValidatorApr {
59
+ id: string;
60
+ boost_total_bgt: string;
61
+ rewards_total_usd: string;
62
+ daily_rate: string;
63
+ apr: string;
64
+ apy: string;
65
+ tokens: Address[]; // Confirm this type with backend real data
66
+ validator: string;
67
+ start_block: number;
68
+ end_block: number;
69
+ start_timestamp: number;
70
+ end_timestamp: number;
71
+ created_at: string;
72
+ updated_at: string;
73
+ }
74
+
75
+ type IncentiveReward = {
76
+ tokenMetadata: Token | undefined;
77
+ tokenPrice: number;
78
+ tokenValue: number;
79
+ id: string;
80
+ dist_id: string;
81
+ token: string;
82
+ recipient: string;
83
+ formattedAmount: string;
84
+ amount: string;
85
+ merkle_proof: string[];
86
+ available_at: number;
87
+ };
88
+ interface IncentiveRewardChunksWithValidatorData {
89
+ validator: ApiValidatorInListFragment | ApiValidatorFragment | undefined;
90
+ maxTimestamp: number | undefined;
91
+ minTimestamp: number | undefined;
92
+ totalValue: number;
93
+ tokenTotals: {
94
+ chainId: number;
95
+ address: Address;
96
+ amount: number;
97
+ value: number;
98
+ metadata: Token | undefined;
99
+ }[];
100
+ rewards: IncentiveReward[];
101
+ isCurrent: boolean;
102
+ }
103
+
104
+ interface AggregatedTokenTotals {
105
+ address: Address;
106
+ amount: number;
107
+ value: number;
108
+ metadata: Token | undefined;
109
+ chainId: number;
110
+ }
111
+
112
+ type ClaimedIncentives = Record<string, string>;
113
+
114
+ type ClaimedIncentivesLocalState = Record<string, ClaimedIncentives>;
115
+
116
+ interface UserVaultInfo {
117
+ balance: bigint;
118
+ delegatedBalance: bigint;
119
+ withdrawableBalance: bigint;
120
+ rewards: string;
121
+ percentage: string;
122
+ }
123
+
124
+ type StakedBeraAsset = {
125
+ token: TokenWithMetadata;
126
+ apr: number;
127
+ stakedAmount: number;
128
+ stakedAmountUsd: number;
129
+ earnedAmount: number;
130
+ earnedAmountUsd: number;
131
+ isLoadingEarnings?: boolean;
132
+ };
133
+
134
+ export type { AggregatedTokenTotals as A, BribeBoostRewardProof as B, ClaimedIncentives as C, IncentiveReward as I, ProtocolMetadata as P, StakingConfig as S, UserVaultInfo as U, BribeBoostRewardItem as a, StakedBeraAsset as b, BribeBoostReward as c, BribeBoostValidatorApr as d, ClaimedIncentivesLocalState as e, IncentiveRewardChunksWithValidatorData as f };
@@ -1,62 +1,3 @@
1
- /**
2
- * Maps the proposal state from the governor contract to a more human-readable format.
3
- * Don't edit this enum manually, it's synced with the governor contract.
4
- *
5
- * @see https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/IGovernor.sol
6
- */
7
- declare enum ProposalState {
8
- Pending = 0,
9
- Active = 1,
10
- Canceled = 2,
11
- Defeated = 3,
12
- Succeeded = 4,
13
- Queued = 5,
14
- Expired = 6,
15
- Executed = 7
16
- }
17
- declare enum VoteEnum {
18
- AGAINST = "no",
19
- FOR = "yes",
20
- ABSTAIN = "abstain"
21
- }
22
- declare enum ProposalErrorCodes {
23
- REQUIRED = "Required",
24
- INVALID_AMOUNT = "Invalid amount",
25
- NEGATIVE_AMOUNT = "Negative amount",
26
- INVALID_ADDRESS = "Invalid address",
27
- INVALID_ACTION = "Invalid action",
28
- INVALID_ABI = "Invalid ABI",
29
- MUST_BE_HTTPS = "Must be HTTPS",
30
- MUST_BE_HTTPS_OR_IPFS = "Must be HTTPS or IPFS",
31
- INVALID_BASEPATH = "Must be a berachain forum link",
32
- /**
33
- * Mainly used when it's not a reward vault
34
- */
35
- INVALID_CONTRACT = "This is not a valid contract"
36
- }
37
- declare enum ProposalTypeEnum {
38
- CUSTOM_PROPOSAL = "custom-action",
39
- WHITELIST_REWARD_VAULT = "whitelist-reward-vault",
40
- BLACKLIST_REWARD_VAULT = "blacklist-reward-vault",
41
- ERC20_TRANSFER = "erc20-transfer",
42
- WHITELIST_REWARD_VAULT_INCENTIVE = "whitelist-reward-vault-incentive"
43
- }
44
- declare const VoteColorMap: {
45
- readonly yes: "#059669";
46
- readonly 1: "#059669";
47
- readonly no: "#DC2629";
48
- readonly 2: "#DC2629";
49
- readonly veto: "#0284C7";
50
- readonly 4: "#0284C7";
51
- readonly abstain: "#78716c";
52
- readonly 3: "#78716c";
53
- readonly yes_secondary: "#ECFDF5";
54
- readonly no_secondary: "#FEF2F2";
55
- readonly veto_secondary: "#F0F9FF";
56
- readonly abstain_secondary: "#E7E5E4";
57
- readonly default: "#57534e";
58
- };
59
-
60
1
  /**
61
2
  * A list of contract names that are not mapped in the devrel's contract mapping or that are generated by factories (e.g. RewardVault).
62
3
  */
@@ -145,6 +86,8 @@ declare enum TransactionActionType {
145
86
  QUEUE_UNBONDING_BERA = "Queue Unstake BERA",
146
87
  BEND_MARKET_REPAY_AND_WITHDRAW_COLLATERAL = "Bend Market Repay and Withdraw Collateral",
147
88
  BEND_MARKET_SUPPLY_COLLATERAL_AND_BORROW = "Bend Market Supply Collateral and Borrow",
89
+ BEND_MARKET_MULTIPLY = "Bend Market Multiply",
90
+ BEND_MARKET_DEMULTIPLY = "Bend Market Demultiply",
148
91
  BEND_VAULT_SUPPLY = "Bend Vault Supply",
149
92
  BEND_VAULT_WITHDRAW = "Bend Vault Withdraw",
150
93
  BEND_CURATOR_REALLOCATE = "Bend Curator Reallocate",
@@ -159,4 +102,4 @@ declare enum TransactionActionType {
159
102
  BEND_CURATOR_SET_ALLOCATOR = "Bend Curator Set Allocator"
160
103
  }
161
104
 
162
- export { ContractName as C, ProposalErrorCodes as P, TransactionActionType as T, VoteColorMap as V, ProposalState as a, ProposalTypeEnum as b, VoteEnum as c };
105
+ export { ContractName as C, TransactionActionType as T };
@@ -1,62 +1,3 @@
1
- /**
2
- * Maps the proposal state from the governor contract to a more human-readable format.
3
- * Don't edit this enum manually, it's synced with the governor contract.
4
- *
5
- * @see https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/governance/IGovernor.sol
6
- */
7
- declare enum ProposalState {
8
- Pending = 0,
9
- Active = 1,
10
- Canceled = 2,
11
- Defeated = 3,
12
- Succeeded = 4,
13
- Queued = 5,
14
- Expired = 6,
15
- Executed = 7
16
- }
17
- declare enum VoteEnum {
18
- AGAINST = "no",
19
- FOR = "yes",
20
- ABSTAIN = "abstain"
21
- }
22
- declare enum ProposalErrorCodes {
23
- REQUIRED = "Required",
24
- INVALID_AMOUNT = "Invalid amount",
25
- NEGATIVE_AMOUNT = "Negative amount",
26
- INVALID_ADDRESS = "Invalid address",
27
- INVALID_ACTION = "Invalid action",
28
- INVALID_ABI = "Invalid ABI",
29
- MUST_BE_HTTPS = "Must be HTTPS",
30
- MUST_BE_HTTPS_OR_IPFS = "Must be HTTPS or IPFS",
31
- INVALID_BASEPATH = "Must be a berachain forum link",
32
- /**
33
- * Mainly used when it's not a reward vault
34
- */
35
- INVALID_CONTRACT = "This is not a valid contract"
36
- }
37
- declare enum ProposalTypeEnum {
38
- CUSTOM_PROPOSAL = "custom-action",
39
- WHITELIST_REWARD_VAULT = "whitelist-reward-vault",
40
- BLACKLIST_REWARD_VAULT = "blacklist-reward-vault",
41
- ERC20_TRANSFER = "erc20-transfer",
42
- WHITELIST_REWARD_VAULT_INCENTIVE = "whitelist-reward-vault-incentive"
43
- }
44
- declare const VoteColorMap: {
45
- readonly yes: "#059669";
46
- readonly 1: "#059669";
47
- readonly no: "#DC2629";
48
- readonly 2: "#DC2629";
49
- readonly veto: "#0284C7";
50
- readonly 4: "#0284C7";
51
- readonly abstain: "#78716c";
52
- readonly 3: "#78716c";
53
- readonly yes_secondary: "#ECFDF5";
54
- readonly no_secondary: "#FEF2F2";
55
- readonly veto_secondary: "#F0F9FF";
56
- readonly abstain_secondary: "#E7E5E4";
57
- readonly default: "#57534e";
58
- };
59
-
60
1
  /**
61
2
  * A list of contract names that are not mapped in the devrel's contract mapping or that are generated by factories (e.g. RewardVault).
62
3
  */
@@ -145,6 +86,8 @@ declare enum TransactionActionType {
145
86
  QUEUE_UNBONDING_BERA = "Queue Unstake BERA",
146
87
  BEND_MARKET_REPAY_AND_WITHDRAW_COLLATERAL = "Bend Market Repay and Withdraw Collateral",
147
88
  BEND_MARKET_SUPPLY_COLLATERAL_AND_BORROW = "Bend Market Supply Collateral and Borrow",
89
+ BEND_MARKET_MULTIPLY = "Bend Market Multiply",
90
+ BEND_MARKET_DEMULTIPLY = "Bend Market Demultiply",
148
91
  BEND_VAULT_SUPPLY = "Bend Vault Supply",
149
92
  BEND_VAULT_WITHDRAW = "Bend Vault Withdraw",
150
93
  BEND_CURATOR_REALLOCATE = "Bend Curator Reallocate",
@@ -159,4 +102,4 @@ declare enum TransactionActionType {
159
102
  BEND_CURATOR_SET_ALLOCATOR = "Bend Curator Set Allocator"
160
103
  }
161
104
 
162
- export { ContractName as C, ProposalErrorCodes as P, TransactionActionType as T, VoteColorMap as V, ProposalState as a, ProposalTypeEnum as b, VoteEnum as c };
105
+ export { ContractName as C, TransactionActionType as T };
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/pong/coding/monobera/packages/berajs/dist/types/exports.cjs"],"names":[],"mappings":"AAAA","file":"/Users/pong/coding/monobera/packages/berajs/dist/types/exports.cjs"}
1
+ {"version":3,"sources":["/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/types/exports.cjs"],"names":[],"mappings":"AAAA","file":"/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/types/exports.cjs"}
@@ -1,19 +1,19 @@
1
- export { A as AggregatedTokenTotals, g as BribeBoostReward, b as BribeBoostRewardItem, B as BribeBoostRewardProof, h as BribeBoostValidatorApr, i as ClaimedIncentives, j as ClaimedIncentivesLocalState, C as CustomProposal, k as CustomProposalActionErrors, a as CustomProposalErrors, D as DefaultHookOptions, c as DefaultHookReturnType, G as GovernanceTopic, I as IContractWrite, l as IContractWriteFn, m as IncentiveReward, n as IncentiveRewardChunksWithValidatorData, o as PROPOSAL_GENRE, p as Proposal, q as ProposalAction, r as ProposalVotes, P as ProtocolMetadata, s as SafeProposalAction, d as StakedBeraAsset, S as StakingConfig, U as UserVaultInfo, V as VerifiedAbi, t as Vote, u as Voter } from '../global.d-6aSWIkV_.cjs';
1
+ export { A as AggregatedTokenTotals, c as BribeBoostReward, a as BribeBoostRewardItem, B as BribeBoostRewardProof, d as BribeBoostValidatorApr, C as ClaimedIncentives, e as ClaimedIncentivesLocalState, I as IncentiveReward, f as IncentiveRewardChunksWithValidatorData, P as ProtocolMetadata, b as StakedBeraAsset, S as StakingConfig, U as UserVaultInfo } from '../pol.d-o6Iw75bK.cjs';
2
2
  import { M as MinimalERC20 } from '../HoneyConfigProvider-DfkjmzEf.cjs';
3
3
  export { A as AllowanceQueryItem, j as AllowanceToken, B as BalanceToken, y as BexStatus, w as Calldata, H as HoneySwapActions, I as IAggregatorArgs, z as IAggregatorQuote, g as IRawAggregatorQuote, v as IUserPosition, h as PythPriceFeedMap, S as SwapRequest, b as Token, i as TokenCurrentPriceMap, x as TokenPriceInfo, t as TokenWithAmount, a as TokenWithMetadata, D as TokenWithPrice } from '../HoneyConfigProvider-DfkjmzEf.cjs';
4
4
  import { BundleData, EnsoClient } from '@ensofinance/sdk';
5
5
  import { TransactionRequest, Address, Hex, PublicClient } from 'viem';
6
- import '@berachain/graphql/governance';
7
- import '../txnEnum-CCuQUFlh.cjs';
6
+ export { D as DefaultHookOptions, a as DefaultHookReturnType, I as IContractWrite, c as IContractWriteFn } from '../global.d-B9nLZ7ul.cjs';
8
7
  import '@berachain/graphql/pol/api';
9
- import '@wagmi/core';
10
- import 'swr';
11
- import '@berachain/config';
12
- import '../BeraError-_mQdkanr.cjs';
13
8
  import 'react/jsx-runtime';
14
9
  import 'react';
15
10
  import '@berachain-foundation/berancer-sdk';
16
11
  import '../honey-CYm0RWf4.cjs';
12
+ import '@wagmi/core';
13
+ import 'swr';
14
+ import '@berachain/config';
15
+ import '../txnEnum-CwAJN4zV.cjs';
16
+ import '../BeraError-_mQdkanr.cjs';
17
17
 
18
18
  type Quantity = string | number;
19
19
  type ActionOutputReference<T> = T | StrictOutputReference<T>;
@@ -1,19 +1,19 @@
1
- export { A as AggregatedTokenTotals, g as BribeBoostReward, b as BribeBoostRewardItem, B as BribeBoostRewardProof, h as BribeBoostValidatorApr, i as ClaimedIncentives, j as ClaimedIncentivesLocalState, C as CustomProposal, k as CustomProposalActionErrors, a as CustomProposalErrors, D as DefaultHookOptions, c as DefaultHookReturnType, G as GovernanceTopic, I as IContractWrite, l as IContractWriteFn, m as IncentiveReward, n as IncentiveRewardChunksWithValidatorData, o as PROPOSAL_GENRE, p as Proposal, q as ProposalAction, r as ProposalVotes, P as ProtocolMetadata, s as SafeProposalAction, d as StakedBeraAsset, S as StakingConfig, U as UserVaultInfo, V as VerifiedAbi, t as Vote, u as Voter } from '../global.d-SU9Epq0M.js';
1
+ export { A as AggregatedTokenTotals, c as BribeBoostReward, a as BribeBoostRewardItem, B as BribeBoostRewardProof, d as BribeBoostValidatorApr, C as ClaimedIncentives, e as ClaimedIncentivesLocalState, I as IncentiveReward, f as IncentiveRewardChunksWithValidatorData, P as ProtocolMetadata, b as StakedBeraAsset, S as StakingConfig, U as UserVaultInfo } from '../pol.d-qR8bGEP5.js';
2
2
  import { M as MinimalERC20 } from '../HoneyConfigProvider-DVP_9KZn.js';
3
3
  export { A as AllowanceQueryItem, j as AllowanceToken, B as BalanceToken, y as BexStatus, w as Calldata, H as HoneySwapActions, I as IAggregatorArgs, z as IAggregatorQuote, g as IRawAggregatorQuote, v as IUserPosition, h as PythPriceFeedMap, S as SwapRequest, b as Token, i as TokenCurrentPriceMap, x as TokenPriceInfo, t as TokenWithAmount, a as TokenWithMetadata, D as TokenWithPrice } from '../HoneyConfigProvider-DVP_9KZn.js';
4
4
  import { BundleData, EnsoClient } from '@ensofinance/sdk';
5
5
  import { TransactionRequest, Address, Hex, PublicClient } from 'viem';
6
- import '@berachain/graphql/governance';
7
- import '../txnEnum-CCuQUFlh.js';
6
+ export { D as DefaultHookOptions, a as DefaultHookReturnType, I as IContractWrite, c as IContractWriteFn } from '../global.d-ylUk_etZ.js';
8
7
  import '@berachain/graphql/pol/api';
9
- import '@wagmi/core';
10
- import 'swr';
11
- import '@berachain/config';
12
- import '../BeraError-_mQdkanr.js';
13
8
  import 'react/jsx-runtime';
14
9
  import 'react';
15
10
  import '@berachain-foundation/berancer-sdk';
16
11
  import '../honey-CYm0RWf4.js';
12
+ import '@wagmi/core';
13
+ import 'swr';
14
+ import '@berachain/config';
15
+ import '../txnEnum-CwAJN4zV.js';
16
+ import '../BeraError-_mQdkanr.js';
17
17
 
18
18
  type Quantity = string | number;
19
19
  type ActionOutputReference<T> = T | StrictOutputReference<T>;
@@ -0,0 +1 @@
1
+ "use strict";//# sourceMappingURL=exports.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/types/governance/exports.cjs"],"names":[],"mappings":"AAAA","file":"/Users/liammcaweeney/Work/bera/monobera/packages/berajs/dist/types/governance/exports.cjs"}